mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/7] Fixing MMC access on Raspberry Pi CM3
@ 2019-02-14 13:24 Tomaz Solc
  2019-02-14 13:24 ` [PATCH 1/7] ARM: rpi: switch emmc from sdhost to sdhci Tomaz Solc
                   ` (6 more replies)
  0 siblings, 7 replies; 12+ messages in thread
From: Tomaz Solc @ 2019-02-14 13:24 UTC (permalink / raw)
  To: barebox; +Cc: Tomaz Solc

Dear all,

These are the changes required to get Raspberry Pi CM3 to boot from the
built-in MMC flash chip. With these patches applied, Barebox successfully boots
a Raspbian system using the following commands:

global linux.bootargs.base="earlyprintk console=tty0 console=ttyAMA0,115200
root=/dev/mmcblk0p2 rootfstype=ext4 rootwait noinitrd"

bootm -o /boot/bcm2710-rpi-cm3.dtb /boot/kernel7.img

Overview of the changes:

 - Implemented pinctrl driver hooks for BCM2835 GPIO, so that pinctrl-
   directives in the device tree are honored.
 - Added the missing device tree property parsing to mci-bcm2835 driver.
 - Added a new Kconfig setting for the Compute Module 3 since a slightly
   different device tree is required compared to Raspberry Pi 3.

Slightly ugly parts:

 - pinctrl needs to be initialized before mci. The only way I found to do this
   is to change the link order, since mci is already started early using
   coredevice_initcall().
 - having a separate MACH_RPI_CM3 in addition to MACH_RPI3 seems an overkill,
   but I couldn't find a clean way to just have a different device tree.

Best regards
Tomaz

Tomaz Solc (7):
  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: move after pinctrl in link order.
  mci: bcm2835: parse other device tree properties.
  ARM: rpi: Add device tree for Compute Module 3.

 arch/arm/boards/raspberry-pi/lowlevel.c            | 10 +++++
 arch/arm/configs/rpi_defconfig                     |  2 +-
 arch/arm/dts/Makefile                              |  1 +
 arch/arm/dts/bcm2837-rpi-3.dts                     |  9 ++++
 arch/arm/dts/bcm2837-rpi-cm3.dts                   | 26 +++++++++++
 arch/arm/mach-bcm283x/Kconfig                      |  6 +++
 drivers/Makefile                                   |  2 +-
 drivers/gpio/Kconfig                               |  4 --
 drivers/gpio/Makefile                              |  1 -
 drivers/mci/mci-bcm2835.c                          |  3 ++
 drivers/pinctrl/Kconfig                            | 10 +++++
 drivers/pinctrl/Makefile                           |  1 +
 .../gpio-bcm2835.c => pinctrl/pinctrl-bcm2835.c}   | 52 +++++++++++++++++++++-
 images/Makefile.bcm283x                            |  6 ++-
 14 files changed, 124 insertions(+), 9 deletions(-)
 create mode 100644 arch/arm/dts/bcm2837-rpi-cm3.dts
 rename drivers/{gpio/gpio-bcm2835.c => pinctrl/pinctrl-bcm2835.c} (77%)

-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/7] ARM: rpi: switch emmc from sdhost to sdhci
  2019-02-14 13:24 [PATCH 0/7] Fixing MMC access on Raspberry Pi CM3 Tomaz Solc
@ 2019-02-14 13:24 ` Tomaz Solc
  2019-02-14 13:24 ` [PATCH 2/7] Kconfig: add pin controllers submenu Tomaz Solc
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Tomaz Solc @ 2019-02-14 13:24 UTC (permalink / raw)
  To: barebox; +Cc: Tomaz Solc

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(+)

diff --git a/arch/arm/dts/bcm2837-rpi-3.dts b/arch/arm/dts/bcm2837-rpi-3.dts
index 194b41c23..51883613c 100644
--- a/arch/arm/dts/bcm2837-rpi-3.dts
+++ b/arch/arm/dts/bcm2837-rpi-3.dts
@@ -9,3 +9,12 @@
 		reg = <0x0 0x0>;
 	};
 };
+
+&sdhci {
+	pinctrl-0 = <&emmc_gpio48>;
+	/delete-node/ wifi@1;
+};
+
+&sdhost {
+	status = "disabled";
+};
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 2/7] Kconfig: add pin controllers submenu.
  2019-02-14 13:24 [PATCH 0/7] Fixing MMC access on Raspberry Pi CM3 Tomaz Solc
  2019-02-14 13:24 ` [PATCH 1/7] ARM: rpi: switch emmc from sdhost to sdhci Tomaz Solc
@ 2019-02-14 13:24 ` Tomaz Solc
  2019-02-14 13:24 ` [PATCH 3/7] pinctrl: bcm2835: move existing code from gpio Tomaz Solc
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Tomaz Solc @ 2019-02-14 13:24 UTC (permalink / raw)
  To: barebox; +Cc: Tomaz Solc

---
 drivers/pinctrl/Kconfig | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
index 12fff4f01..de83c124a 100644
--- a/drivers/pinctrl/Kconfig
+++ b/drivers/pinctrl/Kconfig
@@ -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
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 3/7] pinctrl: bcm2835: move existing code from gpio.
  2019-02-14 13:24 [PATCH 0/7] Fixing MMC access on Raspberry Pi CM3 Tomaz Solc
  2019-02-14 13:24 ` [PATCH 1/7] ARM: rpi: switch emmc from sdhost to sdhci Tomaz Solc
  2019-02-14 13:24 ` [PATCH 2/7] Kconfig: add pin controllers submenu Tomaz Solc
@ 2019-02-14 13:24 ` Tomaz Solc
  2019-02-14 13:24 ` [PATCH 4/7] pinctrl: bcm2835: register the pin controller Tomaz Solc
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Tomaz Solc @ 2019-02-14 13:24 UTC (permalink / raw)
  To: barebox; +Cc: 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%)

diff --git a/arch/arm/configs/rpi_defconfig b/arch/arm/configs/rpi_defconfig
index dc5ab1fe1..35943e025 100644
--- a/arch/arm/configs/rpi_defconfig
+++ b/arch/arm/configs/rpi_defconfig
@@ -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
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index ed93e868a..c535904ed 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -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
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index f5ed876d5..52280f0bb 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -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
diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
index de83c124a..45c3b351d 100644
--- a/drivers/pinctrl/Kconfig
+++ b/drivers/pinctrl/Kconfig
@@ -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
diff --git a/drivers/pinctrl/Makefile b/drivers/pinctrl/Makefile
index 9450dbbdf..35b2d4707 100644
--- a/drivers/pinctrl/Makefile
+++ b/drivers/pinctrl/Makefile
@@ -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
diff --git a/drivers/gpio/gpio-bcm2835.c b/drivers/pinctrl/pinctrl-bcm2835.c
similarity index 100%
rename from drivers/gpio/gpio-bcm2835.c
rename to drivers/pinctrl/pinctrl-bcm2835.c
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 4/7] pinctrl: bcm2835: register the pin controller.
  2019-02-14 13:24 [PATCH 0/7] Fixing MMC access on Raspberry Pi CM3 Tomaz Solc
                   ` (2 preceding siblings ...)
  2019-02-14 13:24 ` [PATCH 3/7] pinctrl: bcm2835: move existing code from gpio Tomaz Solc
@ 2019-02-14 13:24 ` Tomaz Solc
  2019-02-14 13:24 ` [PATCH 5/7] mci: move after pinctrl in link order Tomaz Solc
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Tomaz Solc @ 2019-02-14 13:24 UTC (permalink / raw)
  To: barebox; +Cc: Tomaz Solc

This 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(-)

diff --git a/drivers/pinctrl/pinctrl-bcm2835.c b/drivers/pinctrl/pinctrl-bcm2835.c
index 1802ab7cc..5fd5740e8 100644
--- a/drivers/pinctrl/pinctrl-bcm2835.c
+++ b/drivers/pinctrl/pinctrl-bcm2835.c
@@ -1,7 +1,9 @@
 /*
  * Author: Carlo Caione <carlo@carlocaione.org>
  *
- * 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 <tomaz.solc@tablix.org>
  *
  * 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:
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 5/7] mci: move after pinctrl in link order.
  2019-02-14 13:24 [PATCH 0/7] Fixing MMC access on Raspberry Pi CM3 Tomaz Solc
                   ` (3 preceding siblings ...)
  2019-02-14 13:24 ` [PATCH 4/7] pinctrl: bcm2835: register the pin controller Tomaz Solc
@ 2019-02-14 13:24 ` Tomaz Solc
  2019-02-14 23:34   ` Andrey Smirnov
  2019-02-18  8:42   ` Sascha Hauer
  2019-02-14 13:24 ` [PATCH 6/7] mci: bcm2835: parse other device tree properties Tomaz Solc
  2019-02-14 13:24 ` [PATCH 7/7] ARM: rpi: Add device tree for Compute Module 3 Tomaz Solc
  6 siblings, 2 replies; 12+ messages in thread
From: Tomaz Solc @ 2019-02-14 13:24 UTC (permalink / raw)
  To: barebox; +Cc: Tomaz Solc

pinctrl driver needs to be initialized before mci driver or the pinctrl
device tree properties in the mci node are ignored. Since mci is already
initialized by the coredevice_initcall(), changing the link order is currently
the only way to ensure that.
---
 drivers/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/Makefile b/drivers/Makefile
index 752fd6624..9f0a5e4d6 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -9,7 +9,6 @@ obj-y	+= usb/
 obj-$(CONFIG_DISK) += ata/
 obj-$(CONFIG_SPI) += spi/
 obj-$(CONFIG_I2C) += i2c/
-obj-$(CONFIG_MCI) += mci/
 obj-$(CONFIG_VIDEO) += video/
 obj-y	+= clk/
 obj-y	+= clocksource/
@@ -27,6 +26,7 @@ obj-$(CONFIG_HWRNG) += hw_random/
 obj-$(CONFIG_OFTREE) += of/
 obj-$(CONFIG_W1) += w1/
 obj-y += pinctrl/
+obj-$(CONFIG_MCI) += mci/
 obj-y += bus/
 obj-$(CONFIG_REGULATOR) += regulator/
 obj-$(CONFIG_RESET_CONTROLLER) += reset/
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 6/7] mci: bcm2835: parse other device tree properties.
  2019-02-14 13:24 [PATCH 0/7] Fixing MMC access on Raspberry Pi CM3 Tomaz Solc
                   ` (4 preceding siblings ...)
  2019-02-14 13:24 ` [PATCH 5/7] mci: move after pinctrl in link order Tomaz Solc
@ 2019-02-14 13:24 ` Tomaz Solc
  2019-02-14 13:24 ` [PATCH 7/7] ARM: rpi: Add device tree for Compute Module 3 Tomaz Solc
  6 siblings, 0 replies; 12+ messages in thread
From: Tomaz Solc @ 2019-02-14 13:24 UTC (permalink / raw)
  To: barebox; +Cc: Tomaz Solc

The 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(+)

diff --git a/drivers/mci/mci-bcm2835.c b/drivers/mci/mci-bcm2835.c
index 9438e66af..6509ea6e6 100644
--- a/drivers/mci/mci-bcm2835.c
+++ b/drivers/mci/mci-bcm2835.c
@@ -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");
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 7/7] ARM: rpi: Add device tree for Compute Module 3.
  2019-02-14 13:24 [PATCH 0/7] Fixing MMC access on Raspberry Pi CM3 Tomaz Solc
                   ` (5 preceding siblings ...)
  2019-02-14 13:24 ` [PATCH 6/7] mci: bcm2835: parse other device tree properties Tomaz Solc
@ 2019-02-14 13:24 ` Tomaz Solc
  2019-02-14 14:15   ` Roland Hieber
  6 siblings, 1 reply; 12+ messages in thread
From: Tomaz Solc @ 2019-02-14 13:24 UTC (permalink / raw)
  To: barebox; +Cc: Tomaz Solc

Compute Module needs "no-sd" property on the MMC interface otherwise
mci-bcm2835 hangs on SD card probe.

The switch to uart0 introduced in ab76f9d0 doesn't currently work on Compute
Module.
---
 arch/arm/boards/raspberry-pi/lowlevel.c | 10 ++++++++++
 arch/arm/dts/Makefile                   |  1 +
 arch/arm/dts/bcm2837-rpi-cm3.dts        | 26 ++++++++++++++++++++++++++
 arch/arm/mach-bcm283x/Kconfig           |  6 ++++++
 images/Makefile.bcm283x                 |  6 +++++-
 5 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/bcm2837-rpi-cm3.dts

diff --git a/arch/arm/boards/raspberry-pi/lowlevel.c b/arch/arm/boards/raspberry-pi/lowlevel.c
index 34c935092..1a3d39421 100644
--- a/arch/arm/boards/raspberry-pi/lowlevel.c
+++ b/arch/arm/boards/raspberry-pi/lowlevel.c
@@ -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);
+}
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 3cdee1ffb..82595f9b7 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -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
diff --git a/arch/arm/dts/bcm2837-rpi-cm3.dts b/arch/arm/dts/bcm2837-rpi-cm3.dts
new file mode 100644
index 000000000..636db9a1e
--- /dev/null
+++ b/arch/arm/dts/bcm2837-rpi-cm3.dts
@@ -0,0 +1,26 @@
+#include <arm64/broadcom/bcm2837-rpi-3-b.dts>
+
+/ {
+	chosen {
+		stdout-path = &uart0;
+	};
+
+	memory {
+		reg = <0x0 0x0>;
+	};
+};
+
+&uart0 {
+	status = "okay";
+	/delete-node/ bluetooth;
+};
+
+&sdhci {
+	pinctrl-0 = <&emmc_gpio48>;
+	no-sd;
+	/delete-node/ wifi@1;
+};
+
+&sdhost {
+	status = "disabled";
+};
diff --git a/arch/arm/mach-bcm283x/Kconfig b/arch/arm/mach-bcm283x/Kconfig
index af2f88c47..bb5f75dc9 100644
--- a/arch/arm/mach-bcm283x/Kconfig
+++ b/arch/arm/mach-bcm283x/Kconfig
@@ -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
diff --git a/images/Makefile.bcm283x b/images/Makefile.bcm283x
index 9199f153d..2189f266e 100644
--- a/images/Makefile.bcm283x
+++ b/images/Makefile.bcm283x
@@ -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
\ No newline at end of file
+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
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 7/7] ARM: rpi: Add device tree for Compute Module 3.
  2019-02-14 13:24 ` [PATCH 7/7] ARM: rpi: Add device tree for Compute Module 3 Tomaz Solc
@ 2019-02-14 14:15   ` Roland Hieber
  0 siblings, 0 replies; 12+ messages in thread
From: Roland Hieber @ 2019-02-14 14:15 UTC (permalink / raw)
  To: Tomaz Solc; +Cc: barebox

Hi Tomaz,

On Thu, Feb 14, 2019 at 02:24:29PM +0100, Tomaz Solc wrote:
> Compute Module needs "no-sd" property on the MMC interface otherwise
> mci-bcm2835 hangs on SD card probe.
> 
> The switch to uart0 introduced in ab76f9d0 doesn't currently work on Compute
> Module.
> ---
>  arch/arm/boards/raspberry-pi/lowlevel.c | 10 ++++++++++
>  arch/arm/dts/Makefile                   |  1 +
>  arch/arm/dts/bcm2837-rpi-cm3.dts        | 26 ++++++++++++++++++++++++++
>  arch/arm/mach-bcm283x/Kconfig           |  6 ++++++
>  images/Makefile.bcm283x                 |  6 +++++-
>  5 files changed, 48 insertions(+), 1 deletion(-)
>  create mode 100644 arch/arm/dts/bcm2837-rpi-cm3.dts
> 
> diff --git a/arch/arm/boards/raspberry-pi/lowlevel.c b/arch/arm/boards/raspberry-pi/lowlevel.c
> index 34c935092..1a3d39421 100644
> --- a/arch/arm/boards/raspberry-pi/lowlevel.c
> +++ b/arch/arm/boards/raspberry-pi/lowlevel.c
> @@ -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);
> +}
> diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
> index 3cdee1ffb..82595f9b7 100644
> --- a/arch/arm/dts/Makefile
> +++ b/arch/arm/dts/Makefile
> @@ -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
> diff --git a/arch/arm/dts/bcm2837-rpi-cm3.dts b/arch/arm/dts/bcm2837-rpi-cm3.dts
> new file mode 100644
> index 000000000..636db9a1e
> --- /dev/null
> +++ b/arch/arm/dts/bcm2837-rpi-cm3.dts
> @@ -0,0 +1,26 @@
> +#include <arm64/broadcom/bcm2837-rpi-3-b.dts>

This upstream dts only includes arm/bcm2837-rpi-3-b.dts, and there is
also a arch/arm/boot/dts/bcm2837-rpi-cm3.dtsi that does more than just
arm/bcm2837-rpi-3-b.dts, maybe include that one instead?

> +
> +/ {
> +	chosen {
> +		stdout-path = &uart0;
> +	};
> +
> +	memory {
> +		reg = <0x0 0x0>;
> +	};
> +};
> +
> +&uart0 {
> +	status = "okay";
> +	/delete-node/ bluetooth;
> +};
> +
> +&sdhci {
> +	pinctrl-0 = <&emmc_gpio48>;
> +	no-sd;
> +	/delete-node/ wifi@1;
> +};
> +
> +&sdhost {
> +	status = "disabled";
> +};
> diff --git a/arch/arm/mach-bcm283x/Kconfig b/arch/arm/mach-bcm283x/Kconfig
> index af2f88c47..bb5f75dc9 100644
> --- a/arch/arm/mach-bcm283x/Kconfig
> +++ b/arch/arm/mach-bcm283x/Kconfig
> @@ -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
> diff --git a/images/Makefile.bcm283x b/images/Makefile.bcm283x
> index 9199f153d..2189f266e 100644
> --- a/images/Makefile.bcm283x
> +++ b/images/Makefile.bcm283x
> @@ -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
> \ No newline at end of file
> +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

Please re-add the missing newline at the end.

 - Roland

-- 
Roland Hieber                     | r.hieber@pengutronix.de     |
Pengutronix e.K.                  | https://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim | Phone: +49-5121-206917-5086 |
Amtsgericht Hildesheim, HRA 2686  | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 5/7] mci: move after pinctrl in link order.
  2019-02-14 13:24 ` [PATCH 5/7] mci: move after pinctrl in link order Tomaz Solc
@ 2019-02-14 23:34   ` Andrey Smirnov
  2019-02-18  8:42   ` Sascha Hauer
  1 sibling, 0 replies; 12+ messages in thread
From: Andrey Smirnov @ 2019-02-14 23:34 UTC (permalink / raw)
  To: Tomaz Solc; +Cc: Barebox List

On Thu, Feb 14, 2019 at 5:26 AM Tomaz Solc <tomaz.solc@tablix.org> wrote:
>
> pinctrl driver needs to be initialized before mci driver or the pinctrl
> device tree properties in the mci node are ignored. Since mci is already
> initialized by the coredevice_initcall(), changing the link order is currently
> the only way to ensure that.

What about changing pinctrl_config_one() and device_probe() to do
probe deferral if corresponding pinctl is missing? Would this work?

Thanks,
Andrey Smirnov

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 5/7] mci: move after pinctrl in link order.
  2019-02-14 13:24 ` [PATCH 5/7] mci: move after pinctrl in link order Tomaz Solc
  2019-02-14 23:34   ` Andrey Smirnov
@ 2019-02-18  8:42   ` Sascha Hauer
  2019-02-18  9:54     ` Tomaž Šolc
  1 sibling, 1 reply; 12+ messages in thread
From: Sascha Hauer @ 2019-02-18  8:42 UTC (permalink / raw)
  To: Tomaz Solc; +Cc: barebox

On Thu, Feb 14, 2019 at 02:24:27PM +0100, Tomaz Solc wrote:
> pinctrl driver needs to be initialized before mci driver or the pinctrl
> device tree properties in the mci node are ignored. Since mci is already
> initialized by the coredevice_initcall(), changing the link order is currently
> the only way to ensure that.

The same applies most other subsystems, so instead of moving mci down I
would rather suggest to move pinctrl up.

The other thing is: Why does the bcm2835 mci driver use coredevice_initcall()
at all? Normally it should be a device_initcall(). Since the
coredevice_initcall() goes back to the initial commit of the driver I
suspect there is no special reason for that decision and so I think we
should just change to device_initcall().

Sascha

-- 
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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 5/7] mci: move after pinctrl in link order.
  2019-02-18  8:42   ` Sascha Hauer
@ 2019-02-18  9:54     ` Tomaž Šolc
  0 siblings, 0 replies; 12+ messages in thread
From: Tomaž Šolc @ 2019-02-18  9:54 UTC (permalink / raw)
  To: barebox

On 18. 02. 19 09:42, Sascha Hauer wrote:
> On Thu, Feb 14, 2019 at 02:24:27PM +0100, Tomaz Solc wrote:
>> pinctrl driver needs to be initialized before mci driver or the pinctrl
>> device tree properties in the mci node are ignored. Since mci is already
>> initialized by the coredevice_initcall(), changing the link order is currently
>> the only way to ensure that.
> 
> The same applies most other subsystems, so instead of moving mci down I
> would rather suggest to move pinctrl up.
> 
> The other thing is: Why does the bcm2835 mci driver use coredevice_initcall()
> at all? Normally it should be a device_initcall(). Since the
> coredevice_initcall() goes back to the initial commit of the driver I
> suspect there is no special reason for that decision and so I think we
> should just change to device_initcall().

Good point. I checked other drivers under mci/ and it seems they all use 
device_initcall(). I thought that storage must come before 
fs_initcall(), but that is not actually the case. As far as I can see, 
nothing breaks by moving mci-bcm2835 to device_initcall(). I'll update 
the patch.

Best regards
Tomaž

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2019-02-18  9:54 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-14 13:24 [PATCH 0/7] Fixing MMC access on Raspberry Pi CM3 Tomaz Solc
2019-02-14 13:24 ` [PATCH 1/7] ARM: rpi: switch emmc from sdhost to sdhci Tomaz Solc
2019-02-14 13:24 ` [PATCH 2/7] Kconfig: add pin controllers submenu Tomaz Solc
2019-02-14 13:24 ` [PATCH 3/7] pinctrl: bcm2835: move existing code from gpio Tomaz Solc
2019-02-14 13:24 ` [PATCH 4/7] pinctrl: bcm2835: register the pin controller Tomaz Solc
2019-02-14 13:24 ` [PATCH 5/7] mci: move after pinctrl in link order Tomaz Solc
2019-02-14 23:34   ` Andrey Smirnov
2019-02-18  8:42   ` Sascha Hauer
2019-02-18  9:54     ` Tomaž Šolc
2019-02-14 13:24 ` [PATCH 6/7] mci: bcm2835: parse other device tree properties Tomaz Solc
2019-02-14 13:24 ` [PATCH 7/7] ARM: rpi: Add device tree for Compute Module 3 Tomaz Solc
2019-02-14 14:15   ` Roland Hieber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox