[U-Boot] [PATCH 3/3] mmc: bcm2835_sdhci: Add pinmux support

Simon Glass sjg at chromium.org
Wed Jan 17 20:06:39 UTC 2018


Hi Alex,

On 16 January 2018 at 05:46, Alexander Graf <agraf at suse.de> wrote:
> The bcm2835 firmware provided device trees expect device tree users
> to support pin muxing for the SD devices to work properly.
>
> This patch adds pin muxing support to the sdhci based SD controller
> on said family of SoCs, so that its pins are getting configured
> correctly on boot.
>
> Signed-off-by: Alexander Graf <agraf at suse.de>
> ---
>  drivers/mmc/bcm2835_sdhci.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> diff --git a/drivers/mmc/bcm2835_sdhci.c b/drivers/mmc/bcm2835_sdhci.c
> index 3157354d2a..62ad109361 100644
> --- a/drivers/mmc/bcm2835_sdhci.c
> +++ b/drivers/mmc/bcm2835_sdhci.c
> @@ -45,6 +45,7 @@
>  #include <asm/arch/mbox.h>
>  #include <mach/sdhci.h>
>  #include <mach/timer.h>
> +#include <mach/gpio.h>
>
>  /* 400KHz is max freq for card ID etc. Use that as min */
>  #define MIN_FREQ 400000
> @@ -178,6 +179,7 @@ static int bcm2835_sdhci_probe(struct udevice *dev)
>         fdt_addr_t base;
>         int emmc_freq;
>         int ret;
> +       int pinctrl_handle;
>
>         base = devfdt_get_addr(dev);
>         if (base == FDT_ADDR_T_NONE)
> @@ -190,6 +192,15 @@ static int bcm2835_sdhci_probe(struct udevice *dev)
>         }
>         emmc_freq = ret;
>
> +       pinctrl_handle = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "pinctrl-0", -1);

You can't do this sort of thing :-)

This should go in a pinctrl driver. The clue is that you are having to
look up things manually here. You can create a basic driver very
easily.

> +       if (pinctrl_handle != -1) {
> +               struct udevice *dev;
> +
> +               /* Need to set up pinmuxing */
> +               if (!uclass_first_device(UCLASS_GPIO, &dev) && dev)
> +                       bcm2835_gpio_set_pinmux(dev, pinctrl_handle);
> +       }
> +
>         /*
>          * See the comments in bcm2835_sdhci_raw_writel().
>          *
> --
> 2.12.3
>

Regards,
Simon


More information about the U-Boot mailing list