mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Oleksij Rempel <o.rempel@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH v1 2/6] ARM: at91: xload-mmc: add sama5d3_atmci_start_image() helper
Date: Tue, 13 Apr 2021 07:01:56 +0200	[thread overview]
Message-ID: <20210413050156.GF6950@pengutronix.de> (raw)
In-Reply-To: <20210409131149.2184-3-o.rempel@pengutronix.de>

On Fri, Apr 09, 2021 at 03:11:45PM +0200, Oleksij Rempel wrote:
> This helper should be called from the xloader
> 
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> ---
>  arch/arm/mach-at91/Kconfig              |  2 +
>  arch/arm/mach-at91/include/mach/xload.h |  2 +
>  arch/arm/mach-at91/xload-mmc.c          | 51 +++++++++++++++++++++++++
>  3 files changed, 55 insertions(+)
> 
> diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
> index 52eefc7361..0fc8d25111 100644
> --- a/arch/arm/mach-at91/Kconfig
> +++ b/arch/arm/mach-at91/Kconfig
> @@ -45,6 +45,7 @@ config HAVE_AT91_DDRAMC
>  
>  config AT91_MCI_PBL
>  	bool
> +	depends on MCI_ATMEL_PBL
>  	depends on MCI_ATMEL_SDHCI_PBL
>  	default y
>  
> @@ -599,6 +600,7 @@ config MACH_MICROCHIP_KSZ9477_EVB
>  	bool "Microchip EVB-KSZ9477 Evaluation Kit"
>  	select SOC_SAMA5D3
>  	select OFDEVICE
> +	select MCI_ATMEL_PBL
>  	select COMMON_CLK_OF_PROVIDER
>  	help
>  	  Select this if you are using Microchip's EVB-KSZ9477 Evaluation Kit.
> diff --git a/arch/arm/mach-at91/include/mach/xload.h b/arch/arm/mach-at91/include/mach/xload.h
> index 9201e7d0b7..bbc70af210 100644
> --- a/arch/arm/mach-at91/include/mach/xload.h
> +++ b/arch/arm/mach-at91/include/mach/xload.h
> @@ -5,6 +5,8 @@
>  #include <pbl.h>
>  
>  void __noreturn sama5d2_sdhci_start_image(u32 r4);
> +void __noreturn sama5d3_atmci_start_image(u32 r4, unsigned int clock,
> +					  unsigned int slot);
>  
>  int at91_sdhci_bio_init(struct pbl_bio *bio, void __iomem *base);
>  int at91_mci_bio_init(struct pbl_bio *bio, void __iomem *base,
> diff --git a/arch/arm/mach-at91/xload-mmc.c b/arch/arm/mach-at91/xload-mmc.c
> index e9edeccb7f..2e00cfc2a9 100644
> --- a/arch/arm/mach-at91/xload-mmc.c
> +++ b/arch/arm/mach-at91/xload-mmc.c
> @@ -3,6 +3,7 @@
>  #include <mach/sama5_bootsource.h>
>  #include <mach/hardware.h>
>  #include <mach/sama5d2_ll.h>
> +#include <mach/sama5d3_ll.h>
>  #include <mach/gpio.h>
>  #include <linux/sizes.h>
>  #include <asm/cache.h>
> @@ -44,6 +45,23 @@ static const struct sdhci_instance {
>  	},
>  };
>  
> +static const struct atmci_instance {
> +	void __iomem *base;
> +	unsigned id;
> +	u8 periph;
> +	s8 pins[15];
> +} atmci_instances[] = {
> +	[0] = {
> +		.base = IOMEM(SAMA5D3_BASE_HSMCI0),
> +		.id = SAMA5D3_ID_HSMCI0,
> +		.periph = AT91_MUX_PERIPH_A,
> +		.pins = {
> +			AT91_PIN_PD0, AT91_PIN_PD1, AT91_PIN_PD2, AT91_PIN_PD3,
> +			AT91_PIN_PD4, AT91_PIN_PD5, AT91_PIN_PD6, AT91_PIN_PD7,
> +			AT91_PIN_PD8, AT91_PIN_PD9, -1 }
> +	},
> +};

What about SAMA5D3_BASE_HSMCI1? Please either add it here or don't
access it below.

Sascha

> +
>  /**
>   * sama5d2_sdhci_start_image - Load and start an image from FAT-formatted SDHCI
>   * @r4: value of r4 passed by BootROM
> @@ -82,3 +100,36 @@ void __noreturn sama5d2_sdhci_start_image(u32 r4)
>  out_panic:
>  	panic("FAT chainloading failed\n");
>  }
> +
> +void __noreturn sama5d3_atmci_start_image(u32 boot_src, unsigned int clock,
> +					  unsigned int slot)
> +{
> +	void *buf = (void *)SAMA5_DDRCS;
> +	const struct atmci_instance *instance;
> +	struct pbl_bio bio;
> +	const s8 *pin;
> +	int ret;
> +
> +	ret = sama5_bootsource_instance(boot_src);
> +	if (ret > 1)
> +		panic("Couldn't determine boot MCI instance\n");
> +
> +	instance = &atmci_instances[boot_src];
> +
> +	sama5d3_pmc_enable_periph_clock(SAMA5D2_ID_PIOD);
> +	for (pin = instance->pins; *pin >= 0; pin++) {
> +		at91_mux_pio3_pin(IOMEM(SAMA5D3_BASE_PIOD),
> +					 pin_to_mask(*pin), instance->periph, 0);
> +	}
> +
> +	sama5d3_pmc_enable_periph_clock(instance->id);
> +
> +	ret = at91_mci_bio_init(&bio, instance->base, clock, slot);
> +	if (ret)
> +		goto out_panic;
> +
> +	at91_fat_start_image(&bio, buf, SZ_16M, boot_src);
> +
> +out_panic:
> +	panic("FAT chainloading failed\n");
> +}
> -- 
> 2.29.2
> 
> 
> _______________________________________________
> 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


  reply	other threads:[~2021-04-13  5:06 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-09 13:11 [PATCH v1 0/6] add multiimage support for sama5d3 based microchip-ksz9477-evb board Oleksij Rempel
2021-04-09 13:11 ` [PATCH v1 1/6] mci: atmel_mci: add PBL support Oleksij Rempel
2021-04-13  4:58   ` Sascha Hauer
2021-04-23 14:14     ` Oleksij Rempel
2021-05-03 11:39       ` Sascha Hauer
2021-04-09 13:11 ` [PATCH v1 2/6] ARM: at91: xload-mmc: add sama5d3_atmci_start_image() helper Oleksij Rempel
2021-04-13  5:01   ` Sascha Hauer [this message]
2021-04-09 13:11 ` [PATCH v1 3/6] ARM: at91: ddramc: add sama5d3_barebox_entry() handler Oleksij Rempel
2021-04-09 13:11 ` [PATCH v1 4/6] ARM: at91: add __sama5d3_stashed_bootrom_r4 helper Oleksij Rempel
2021-04-09 13:11 ` [PATCH v1 5/6] ARM: at91: add sama5d3_lowlevel_init() helpers Oleksij Rempel
2021-04-09 13:11 ` [PATCH v1 6/6] ARM: at91: sama5d3: add multiimage support for the microchip-ksz9477-evb Oleksij Rempel

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=20210413050156.GF6950@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=o.rempel@pengutronix.de \
    /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