Fixing MMC access on Raspberry Pi CM3
Subsystems (7)
v2 cover Fixing MMC access on Raspberry Pi CM3
Changes from the first patch series:
- Base Compute Module 3 device tree off upstream device tree for CM3 + IO3 dev board, instead of R. Pi 3B.
- Keep Makefile.bcm283x without a newline at the end of file.
- Make mci init before pinctrl by moving mci-bcm2835 to device_initcall() instead of changing link order.
- Add CONFIG_PINCTRL to rpi_defconfig.
Best regards
Tomaz
Tomaz Solc (8):
ARM: rpi: switch emmc from sdhost to sdhci
Kconfig: add pin controllers submenu.
pinctrl: bcm2835: move existing code from gpio.
pinctrl: bcm2835: register the pin controller.
mci: bcm2835: use device_initcall(), not coredev.
mci: bcm2835: parse other device tree properties.
ARM: rpi: Add device tree for Compute Module 3.
ARM: rpi: add CONFIG_PINCTRL to rpi_defconfig.
arch/arm/boards/raspberry-pi/lowlevel.c | 10 +++++
arch/arm/configs/rpi_defconfig | 4 +-
arch/arm/dts/Makefile | 1 +
arch/arm/dts/bcm2837-rpi-3.dts | 9 ++++
arch/arm/dts/bcm2837-rpi-cm3.dts | 18 ++++++++
arch/arm/mach-bcm283x/Kconfig | 6 +++
drivers/gpio/Kconfig | 4 --
drivers/gpio/Makefile | 1 -
drivers/mci/mci-bcm2835.c | 5 ++-
drivers/pinctrl/Kconfig | 10 +++++
drivers/pinctrl/Makefile | 1 +
.../gpio-bcm2835.c => pinctrl/pinctrl-bcm2835.c} | 52 +++++++++++++++++++++-
images/Makefile.bcm283x | 6 ++-
13 files changed, 117 insertions(+), 10 deletions(-)
create mode 100644 arch/arm/dts/bcm2837-rpi-cm3.dts
rename drivers/{gpio/gpio-bcm2835.c => pinctrl/pinctrl-bcm2835.c} (77%)Signature · 7 lines
2.11.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 1/8 ARM: rpi: switch emmc from sdhost to sdhci
BCM2837 has two mmc interfaces: sdhost and sdhci. On Raspberry Pi 3, sdhost is normally used for SD card/MMC flash and sdhci for the wireless interface. Barebox currently only has a driver for sdhci, so we disable the sdhost interface and remap the pins so that the sdhci has access to the SD card/MMC flash.
--- arch/arm/dts/bcm2837-rpi-3.dts | 9 +++++++++ 1 file changed, 9 insertions(+)
arch/arm/dts/bcm2837-rpi-3.dts +9 -0
@@ -9,3 +9,12 @@ reg = <0x0 0x0>; }; }; + +&sdhci { + pinctrl-0 = <&emmc_gpio48>; + /delete-node/ wifi@1; +}; + +&sdhost { + status = "disabled"; +};
Signature · 7 lines
2.11.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 2/8 Kconfig: add pin controllers submenu.
In reply to Tomaz Solc--- drivers/pinctrl/Kconfig | 4 ++++ 1 file changed, 4 insertions(+)
drivers/pinctrl/Kconfig +4 -0
@@ -1,3 +1,5 @@ +menu "Pin controllers" + config PINCTRL bool "Pin controller core support" default y if OFDEVICE
@@ -83,3 +85,5 @@ config PINCTRL_VF610 help Pinmux controller found on Vybrid VF610 family of SoCs endif + +endmenu
Signature · 7 lines
2.11.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 3/8 pinctrl: bcm2835: move existing code from gpio.
In reply to Tomaz Solc---
arch/arm/configs/rpi_defconfig | 2 +-
drivers/gpio/Kconfig | 4 ----
drivers/gpio/Makefile | 1 -
drivers/pinctrl/Kconfig | 6 ++++++
drivers/pinctrl/Makefile | 1 +
drivers/{gpio/gpio-bcm2835.c => pinctrl/pinctrl-bcm2835.c} | 0
6 files changed, 8 insertions(+), 6 deletions(-)
rename drivers/{gpio/gpio-bcm2835.c => pinctrl/pinctrl-bcm2835.c} (100%)arch/arm/configs/rpi_defconfig +1 -1
@@ -71,7 +71,7 @@ CONFIG_LED_GPIO=y CONFIG_LED_TRIGGERS=y CONFIG_WATCHDOG=y CONFIG_WATCHDOG_BCM2835=y -CONFIG_GPIO_BCM283X=y +CONFIG_PINCTRL_BCM283X=y # CONFIG_PINCTRL is not set CONFIG_REGULATOR=y CONFIG_FS_EXT4=y
drivers/gpio/Kconfig +0 -4
@@ -21,10 +21,6 @@ config GPIO_74164 shift registers. This driver can be used to provide access to more gpio outputs. -config GPIO_BCM283X - bool "GPIO support for BCM283X" - depends on ARCH_BCM283X - config GPIO_CLPS711X bool "GPIO support for CLPS711X" depends on ARCH_CLPS711X
drivers/gpio/Makefile +0 -1
@@ -2,7 +2,6 @@ obj-$(CONFIG_GPIOLIB) += gpiolib.o obj-$(CONFIG_GPIO_74164) += gpio-74164.o obj-$(CONFIG_MACH_MIPS_ATH79) += gpio-ath79.o -obj-$(CONFIG_GPIO_BCM283X) += gpio-bcm2835.o obj-$(CONFIG_GPIO_DAVINCI) += gpio-davinci.o obj-$(CONFIG_GPIO_CLPS711X) += gpio-clps711x.o obj-$(CONFIG_GPIO_DIGIC) += gpio-digic.o
drivers/pinctrl/Kconfig +6 -0
@@ -17,6 +17,12 @@ config PINCTRL_AT91 help The pinmux controller found on AT91 SoCs. +config PINCTRL_BCM283X + bool "GPIO and pinmux support for BCM283X" + depends on ARCH_BCM283X + help + The pinmux controller on BCM2835 + config PINCTRL_IMX_IOMUX_V1 bool help
drivers/pinctrl/Makefile +1 -0
@@ -1,5 +1,6 @@ obj-$(CONFIG_PINCTRL) += pinctrl.o obj-$(CONFIG_PINCTRL_AT91) += pinctrl-at91.o +obj-$(CONFIG_PINCTRL_BCM283X) += pinctrl-bcm2835.o obj-$(CONFIG_PINCTRL_IMX_IOMUX_V1) += imx-iomux-v1.o obj-$(CONFIG_PINCTRL_IMX_IOMUX_V2) += imx-iomux-v2.o obj-$(CONFIG_PINCTRL_IMX_IOMUX_V3) += imx-iomux-v3.o
drivers/pinctrl/pinctrl-bcm2835.c renamed from drivers/gpio/gpio-bcm2835.c +0 -0
Signature · 7 lines
2.11.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 4/8 pinctrl: bcm2835: register the pin controller.
In reply to Tomaz SolcThis adds hooks for the pin controller driver to the existing bcm2835_set_function().
--- drivers/pinctrl/pinctrl-bcm2835.c | 52 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-)
drivers/pinctrl/pinctrl-bcm2835.c +51 -1
@@ -1,7 +1,9 @@/* * Author: Carlo Caione <[email protected]> * -* Based on linux/arch/arm/mach-bcm2708/bcm2708_gpio.c +* GPIO code based on linux/arch/arm/mach-bcm2708/bcm2708_gpio.c +* +* pinctrl part added by Tomaz Solc <[email protected]> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as
@@ -21,6 +23,7 @@#include <io.h> #include <gpio.h> #include <init.h> +#include <pinctrl.h> #define GPIOFSEL (x) (0x00+(x)*4)#define GPIOSET (x) (0x1c+(x)*4)
@@ -46,6 +49,7 @@ enum {struct bcm2835_gpio_chip {void __iomem *base;struct gpio_chip chip; +struct pinctrl_device pctl; };static int bcm2835_set_function (struct gpio_chip *chip,unsigned gpio,int function)
@@ -110,6 +114,39 @@ static struct gpio_ops bcm2835_gpio_ops = { .set = bcm2835_gpio_set_value, }; +static int bcm2835_pinctrl_set_state (struct pinctrl_device *pdev,struct device_node *np) +{ +const __be32 *list; +u32 function; +int i, size; + + list =of_get_property (np,"brcm,pins" , &size); +if (!list) { +return -EINVAL ; + } + + size /=sizeof (*list); + +if (of_property_read_u32 (np,"brcm,function" , &function)) { +return -EINVAL ; + } + +for (i =0 ; i < size; i++) { +int pin =be32_to_cpu (list[i]); + struct bcm2835_gpio_chip *bcmgpio = container_of(pdev, struct bcm2835_gpio_chip, pctl); + +dev_dbg (pdev->dev,"set_state pin %d to function %d\n" , pin, function); + +bcm2835_set_function (&bcmgpio->chip, pin, function); + } + +return 0 ; +} + +static struct pinctrl_ops bcm2835_pinctrl_ops = { + .set_state = bcm2835_pinctrl_set_state, +}; +static int bcm2835_gpio_probe (struct device_d *dev) {struct resource *iores;
@@ -125,14 +162,27 @@ static int bcm2835_gpio_probe(struct device_d *dev) bcmgpio->chip.base =0 ; bcmgpio->chip.ngpio =54 ; bcmgpio->chip.dev = dev; + bcmgpio->pctl.ops = &bcm2835_pinctrl_ops; + bcmgpio->pctl.dev = dev; ret =gpiochip_add (&bcmgpio->chip);if (ret) {dev_err (dev,"couldn't add gpiochip, ret = %d\n" , ret); goto err; } +dev_info (dev,"probed gpiochip%d with base %d\n" , dev->id, bcmgpio->chip.base); +if (IS_ENABLED (CONFIG_PINCTRL )) { + ret =pinctrl_register (&bcmgpio->pctl); +if (ret) { +dev_err (dev,"couldn't add pinctrl, ret = %d\n" , ret); +// don't free bcmgpio, since it's already used by gpiochip. + }else { +dev_dbg (dev,"bcm283x pinctrl registered\n" ); + } + } +return 0 ; err:
Signature · 7 lines
2.11.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 5/8 mci: bcm2835: use device_initcall(), not coredev.
In reply to Tomaz Solcpinctrl driver needs to be initialized before mci driver on Raspberry Pi. Otherwise the pinctrl device tree properties in the mci node are ignored. pinctrl is initialized by coredevice_initcall(), so moving mci-bcm2835 to device_initcall() ensures that it is initialized later.
There is no reason for mci-bcm2835 to use coredevice_initcall(). Other mci drivers already use device_initcall().
--- drivers/mci/mci-bcm2835.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mci/mci-bcm2835.c +1 -1
@@ -561,4 +561,4 @@ static int bcm2835_mci_add(void) {return platform_driver_register (&bcm2835_mci_driver); } -coredevice_initcall (bcm2835_mci_add); +device_initcall (bcm2835_mci_add);
Signature · 7 lines
2.11.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 6/8 mci: bcm2835: parse other device tree properties.
In reply to Tomaz SolcThe driver was missing a call to mci_of_parse() which fills in properties such as "bus-width", "no-sd" into the mci_host struct.
--- drivers/mci/mci-bcm2835.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/mci/mci-bcm2835.c +3 -0
@@ -506,6 +506,9 @@ static int bcm2835_mci_probe(struct device_d *hw_dev) host->mci.hw_dev = hw_dev; host->hw_dev = hw_dev; host->max_clock =clk_get_rate (clk); + +mci_of_parse (&host->mci); + iores =dev_request_mem_resource (hw_dev,0 );if (IS_ERR (iores)) {dev_err (host->hw_dev,"Failed request mem region, aborting...\n" );
Signature · 7 lines
2.11.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 7/8 ARM: rpi: Add device tree for Compute Module 3.
In reply to Tomaz SolcCompute Module needs "no-sd" property on the MMC interface otherwise mci-bcm2835 hangs on SD card probe.
--- arch/arm/boards/raspberry-pi/lowlevel.c | 10 ++++++++++ arch/arm/dts/Makefile | 1 + arch/arm/dts/bcm2837-rpi-cm3.dts | 18 ++++++++++++++++++ arch/arm/mach-bcm283x/Kconfig | 6 ++++++ images/Makefile.bcm283x | 6 +++++- 5 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 arch/arm/dts/bcm2837-rpi-cm3.dts
arch/arm/boards/raspberry-pi/lowlevel.c +10 -0
@@ -33,3 +33,13 @@ ENTRY_FUNCTION(start_raspberry_pi3, r0, r1, r2)barebox_arm_entry (BCM2835_SDRAM_BASE ,SZ_512M , fdt); } + +extern char __dtb_bcm2837_rpi_cm3_start[]; +ENTRY_FUNCTION(start_raspberry_pi_cm3, r0, r1, r2) +{ +void *fdt = __dtb_bcm2837_rpi_cm3_start +get_runtime_offset (); + +arm_cpu_lowlevel_init (); + +barebox_arm_entry (BCM2835_SDRAM_BASE ,SZ_512M , fdt); +}
arch/arm/dts/Makefile +1 -0
@@ -75,6 +75,7 @@ pbl-dtb-$(CONFIG_MACH_REALQ7) += imx6q-dmo-edmqmx6.dtb.o pbl-dtb-$(CONFIG_MACH_RPI) += bcm2835-rpi.dtb.o pbl-dtb-$(CONFIG_MACH_RPI2) += bcm2836-rpi-2.dtb.o pbl-dtb-$(CONFIG_MACH_RPI3) += bcm2837-rpi-3.dtb.o +pbl-dtb-$(CONFIG_MACH_RPI_CM3) += bcm2837-rpi-cm3.dtb.o pbl-dtb-$(CONFIG_MACH_SABRELITE) += imx6q-sabrelite.dtb.o imx6dl-sabrelite.dtb.o pbl-dtb-$(CONFIG_MACH_SABRESD) += imx6q-sabresd.dtb.o pbl-dtb-$(CONFIG_MACH_FREESCALE_IMX6SX_SABRESDB) += imx6sx-sdb.dtb.o
arch/arm/dts/bcm2837-rpi-cm3.dts new file +18 -0
@@ -0,0 +1,18 @@ +#include <arm/bcm2837-rpi-cm3-io3.dts> + +/ { + chosen { + stdout-path = &uart0; + }; + + memory { + reg = <0x0 0x0>; + }; +}; + +&sdhci { + pinctrl-0 = <&emmc_gpio48>; + no-sd; + non-removable; + status = "okay"; +};
arch/arm/mach-bcm283x/Kconfig +6 -0
@@ -25,6 +25,12 @@ config MACH_RPI3 select MACH_RPI_COMMON select ARM_SECURE_MONITOR +config MACH_RPI_CM3 + bool "RaspberryPi Compute Module 3 (BCM2837/CORTEX-A53)" + select CPU_V7 + select MACH_RPI_COMMON + select ARM_SECURE_MONITOR + endmenu config MACH_RPI_DEBUG_UART_BASE
images/Makefile.bcm283x +5 -1
@@ -12,4 +12,8 @@ image-$(CONFIG_MACH_RPI2) += barebox-raspberry-pi-2.img pblb-$(CONFIG_MACH_RPI3) += start_raspberry_pi3 FILE_barebox-raspberry-pi-3.img = start_raspberry_pi3.pblb -image-$(CONFIG_MACH_RPI3) += barebox-raspberry-pi-3.img +image-$(CONFIG_MACH_RPI3) += barebox-raspberry-pi-3.img + +pblb-$(CONFIG_MACH_RPI_CM3) += start_raspberry_pi_cm3 +FILE_barebox-raspberry-pi-cm3.img = start_raspberry_pi_cm3.pblb +image-$(CONFIG_MACH_RPI_CM3) += barebox-raspberry-pi-cm3.img
Signature · 7 lines
2.11.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 8/8 ARM: rpi: add CONFIG_PINCTRL to rpi_defconfig.
In reply to Tomaz SolcRequired for emmc pin function switching on Raspberry Pi 3.
--- arch/arm/configs/rpi_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/configs/rpi_defconfig +1 -1
@@ -71,8 +71,8 @@ CONFIG_LED_GPIO=y CONFIG_LED_TRIGGERS=y CONFIG_WATCHDOG=y CONFIG_WATCHDOG_BCM2835=y +CONFIG_PINCTRL=y CONFIG_PINCTRL_BCM283X=y -# CONFIG_PINCTRL is not set CONFIG_REGULATOR=y CONFIG_FS_EXT4=y CONFIG_FS_FAT=y
Signature · 7 lines
2.11.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Sascha Hauer
AppliedQuoted 12 lines · Tomaz Solc
Changes from the first patch series:
- Base Compute Module 3 device tree off upstream device tree for CM3 + IO3 dev board, instead of R. Pi 3B.
- Keep Makefile.bcm283x without a newline at the end of file.
- Make mci init before pinctrl by moving mci-bcm2835 todevice_initcall()instead of changing link order.
- AddCONFIG_PINCTRLtorpi_defconfig.Best regards
Tomaz
Quoted 9 lines
Tomaz Solc (8):
ARM: rpi: switch emmc from sdhost to sdhci
Kconfig: add pin controllers submenu.
pinctrl: bcm2835: move existing code from gpio.
pinctrl: bcm2835: register the pin controller.
mci: bcm2835: usedevice_initcall(), not coredev.
mci: bcm2835: parse other device tree properties.
ARM: rpi: Add device tree for Compute Module 3.
ARM: rpi: addCONFIG_PINCTRLtorpi_defconfig.
Applied, thanks
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox