mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 1/3] ARM: stm32mp: migrate board initcalls to board drivers
Date: Wed, 7 Oct 2020 10:08:05 +0200	[thread overview]
Message-ID: <20201007080805.GL11648@pengutronix.de> (raw)
In-Reply-To: <20201005081058.2572-1-a.fatoum@pengutronix.de>

On Mon, Oct 05, 2020 at 10:10:56AM +0200, Ahmad Fatoum wrote:
> Board drivers are now the way to go. Migrate the STM32 boards to use it,
> to encourage future copy-pasting in following suit.
> 
> As the board now supports both DK2 and DK1, rename the prefix to dkx_.
> dk1 specifics follow in a separate commit.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  arch/arm/boards/lxa-mc1/board.c         | 17 +++++++++++++----
>  arch/arm/boards/seeed-odyssey/board.c   | 15 +++++++++++++--
>  arch/arm/boards/stm32mp157c-dk2/board.c | 18 +++++++++++++-----
>  3 files changed, 39 insertions(+), 11 deletions(-)

Applied, thanks

Sascha

> 
> diff --git a/arch/arm/boards/lxa-mc1/board.c b/arch/arm/boards/lxa-mc1/board.c
> index 7f1f3ccd7e06..9126973dcbdc 100644
> --- a/arch/arm/boards/lxa-mc1/board.c
> +++ b/arch/arm/boards/lxa-mc1/board.c
> @@ -28,11 +28,9 @@ static int of_fixup_regulator_supply_disable(struct device_node *root, void *pat
>  	return 0;
>  }
>  
> -static int mc1_device_init(void)
> +static int mc1_probe(struct device_d *dev)
>  {
>  	int flags;
> -	if (!of_machine_is_compatible("lxa,stm32mp157c-mc1"))
> -		return 0;
>  
>  	flags = bootsource_get_instance() == 0 ? BBU_HANDLER_FLAG_DEFAULT : 0;
>  	stm32mp_bbu_mmc_register_handler("sd", "/dev/mmc0.ssbl", flags);
> @@ -55,4 +53,15 @@ static int mc1_device_init(void)
>  	 */
>  	return of_register_fixup(of_fixup_regulator_supply_disable, "/regulator_3v3");
>  }
> -device_initcall(mc1_device_init);
> +
> +static const struct of_device_id mc1_of_match[] = {
> +	{ .compatible = "lxa,stm32mp157c-mc1" },
> +	{ /* sentinel */ },
> +};
> +
> +static struct driver_d mc1_board_driver = {
> +	.name = "board-lxa-mc1",
> +	.probe = mc1_probe,
> +	.of_compatible = mc1_of_match,
> +};
> +device_platform_driver(mc1_board_driver);
> diff --git a/arch/arm/boards/seeed-odyssey/board.c b/arch/arm/boards/seeed-odyssey/board.c
> index e3fe5368731c..fd077c02b273 100644
> --- a/arch/arm/boards/seeed-odyssey/board.c
> +++ b/arch/arm/boards/seeed-odyssey/board.c
> @@ -7,7 +7,7 @@
>  #include <bootsource.h>
>  #include <of.h>
>  
> -static int odyssey_device_init(void)
> +static int odyssey_som_probe(struct device_d *dev)
>  {
>  	int flags;
>  	int instance = bootsource_get_instance();
> @@ -29,4 +29,15 @@ static int odyssey_device_init(void)
>  
>  	return 0;
>  }
> -device_initcall(odyssey_device_init);
> +
> +static const struct of_device_id odyssey_som_of_match[] = {
> +	{ .compatible = "seeed,stm32mp157c-odyssey-som" },
> +	{ /* sentinel */ },
> +};
> +
> +static struct driver_d odyssey_som_driver = {
> +	.name = "odyssey-som",
> +	.probe = odyssey_som_probe,
> +	.of_compatible = odyssey_som_of_match,
> +};
> +device_platform_driver(odyssey_som_driver);
> diff --git a/arch/arm/boards/stm32mp157c-dk2/board.c b/arch/arm/boards/stm32mp157c-dk2/board.c
> index 46366031218d..a547209cdf5e 100644
> --- a/arch/arm/boards/stm32mp157c-dk2/board.c
> +++ b/arch/arm/boards/stm32mp157c-dk2/board.c
> @@ -3,11 +3,8 @@
>  #include <init.h>
>  #include <mach/bbu.h>
>  
> -static int dk2_postcore_init(void)
> +static int dkx_probe(struct device_d *dev)
>  {
> -	if (!of_machine_is_compatible("st,stm32mp157c-dk2"))
> -		return 0;
> -
>  	stm32mp_bbu_mmc_register_handler("sd", "/dev/mmc0.ssbl",
>  					 BBU_HANDLER_FLAG_DEFAULT);
>  
> @@ -15,4 +12,15 @@ static int dk2_postcore_init(void)
>  
>  	return 0;
>  }
> -postcore_initcall(dk2_postcore_init);
> +
> +static const struct of_device_id dkx_of_match[] = {
> +	{ .compatible = "st,stm32mp157c-dk2" },
> +	{ /* sentinel */ },
> +};
> +
> +static struct driver_d dkx_board_driver = {
> +	.name = "board-stm32mp15xx-dkx",
> +	.probe = dkx_probe,
> +	.of_compatible = dkx_of_match,
> +};
> +postcore_platform_driver(dkx_board_driver);
> -- 
> 2.28.0
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
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

      parent reply	other threads:[~2020-10-07  8:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-05  8:10 Ahmad Fatoum
2020-10-05  8:10 ` [PATCH 2/3] ARM: stm32mp: dk2: rename to dkx to make dk1 support clearer Ahmad Fatoum
2020-10-05  8:10 ` [PATCH 3/3] ARM: stm32mp: defconfig: enable more useful options Ahmad Fatoum
2020-10-05  9:39 ` [PATCH] fixup! ARM: stm32mp: migrate board initcalls to board drivers Ahmad Fatoum
2020-10-07  8:08 ` Sascha Hauer [this message]

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=20201007080805.GL11648@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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