From: Lars Pedersen <lapeddk@gmail.com>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org, Bruno Thomsen <bruno.thomsen@gmail.com>
Subject: Re: [PATCH] ARM: i.MX: Kamstrup mx7 concentrator board support
Date: Mon, 12 Apr 2021 14:09:03 +0200 [thread overview]
Message-ID: <CAKd8=GvvoobiudVaRp7qdDU-P4k1herndE-AXoiZkLtoc5R-vw@mail.gmail.com> (raw)
In-Reply-To: <7551e835-6109-2386-6b4b-7224aae675bb@pengutronix.de>
Hello again. Thanks for the quick response :)
On Mon, 12 Apr 2021 at 13:24, Ahmad Fatoum <a.fatoum@pengutronix.de> wrote:
>
> Hello Lars,
>
> On 12.04.21 12:45, Lars Pedersen wrote:
> >>> +#define BOARD_RESTART_GPIO IMX_GPIO_NR(7, 12)
> >>> +#define TPM_RESET_GPIO IMX_GPIO_NR(3, 8)
> >>> +
> >>> +static void kamstrup_mx7_tpm_reset(void)
> >>> +{
> >>> + imx7_setup_pad(MX7D_PAD_LCD_DATA03__GPIO3_IO8);
> >>> +
> >>> + gpio_request(TPM_RESET_GPIO, "tpm-reset");
> >>> + gpio_direction_output(TPM_RESET_GPIO, 1);
> >>> + mdelay(100);
> >>> + gpio_set_value(TPM_RESET_GPIO, 0);
> >>> + mdelay(100);
> >>> + gpio_set_value(TPM_RESET_GPIO, 1);
> >>> + gpio_free(TPM_RESET_GPIO);
> >>
> >> We are trying to cut down on code that doesn't use the driver model.
> >> Couldn't this be represented as a gpio-hog in the device tree or
> >> a reset line for the SPI device?
> >
> > I can't find anything in the DT binding for the SPI/TPM driver to use
> > a reset line.
>
> Proper way would be for this to be added into Linux then,
> but that's out of scope for the patch here.
>
> > Can a DT gpio-hog toggle the pin? Don't you need a
> > driver for this?
>
> You can't pulse with a gpio-hog. I assumed the TPM is in reset by
> default.
>
> > I see the following options:
> >
> > 1) gpio-hog with a label and use new gpiolib in board.c.
> > 2) gpio-hog and control the pin in a boot script.
>
> If there's no straight-forward way to do it without board code,
> it's ok the way it is with one change though: I missed it the first
> time, but your board breaks multi-image support because you don't
> check whether the initcall is indeed running on your board (See for
> example imx_v7_defconfig, which builds over a hundred boards at once).
>
> Easiest way to get this right is to write a board driver.
> See arch/arm/boards/lxa-mc1/board.c for an example.
In arch/arm/boards/freescale-mx7-sabresd/board.c they do something like:
if (!of_machine_is_compatible("fsl,imx7d-sdb"))
return 0;
Can't I just do the same?
if (!of_machine_is_compatible("kam,imx7d-flex-concentrator-mfg"))
return 0;
The board driver in arch/arm/boards/lxa-mc1/board.c seems more complicated.
>
> >>> +}
> >>> +
> >>> +static void __noreturn kamstrup_mx7_board_restart_gpio(struct restart_handler *rst)
> >>> +{
> >>> + imx7_setup_pad(MX7D_PAD_ENET1_TX_CLK__GPIO7_IO12);
> >>> +
> >>> + gpio_direction_output(BOARD_RESTART_GPIO, 0);
> >>> + mdelay(1);
> >>> + gpio_set_value(BOARD_RESTART_GPIO, 0);
> >>
> >> I just sent out a patch[1] with a driver implementing the "gpio-restart" device
> >> tree binding. Could you test that one and use it here instead?
> >>
> >
> > I have applied the patches on a master branch (Last patch failed to
> > apply but was only watchdog) and the gpio-restart works perfectly.
>
> Thanks for testing! You can add your Tested-By on the patch in question
> if you like.
>
> >
> >>> +
> >>> + hang();
> >>> +}
> >>> +
> >>> +static int kamstrup_mx7_concentrator_coredevices_init(void)
> >>> +{
> >>> + kamstrup_mx7_tpm_reset();
> >>> + restart_handler_register_fn("board", kamstrup_mx7_board_restart_gpio);
> >>> + barebox_set_model("Kamstrup OMNIA Concentrator");
> >>
> >> The default model name is "Kamstrup OMNIA Flex Concentrator".
> >> If that's too long, you could override /model in the barebox device tree.
> >> With the changes suggested above, you could drop board.c then altogether.
> >>
> >
> > I'll move this into the device tree or delete it entirely.
>
> Great. :-)
>
>
> Cheers,
> Ahmad
>
> --
> Pengutronix e.K. | |
> Steuerwalder Str. 21 | http://www.pengutronix.de/ |
> 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
> Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2021-04-12 12:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-09 13:20 Lars Pedersen
2021-04-10 10:43 ` Ahmad Fatoum
2021-04-12 10:45 ` Lars Pedersen
2021-04-12 11:24 ` Ahmad Fatoum
2021-04-12 12:09 ` Lars Pedersen [this message]
2021-04-12 12:43 ` Ahmad Fatoum
2021-04-12 14:17 ` Lars Pedersen
2021-04-12 14:20 ` Ahmad Fatoum
2021-04-12 12:22 ` Rouven Czerwinski
2021-04-12 12:39 ` Lars Pedersen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAKd8=GvvoobiudVaRp7qdDU-P4k1herndE-AXoiZkLtoc5R-vw@mail.gmail.com' \
--to=lapeddk@gmail.com \
--cc=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=bruno.thomsen@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox