Skip to contentSkip to conversation

tegra-next

PATCH Applied Lucas Stach 2 participants 11 messages Dec 3, 2013 – Dec 4, 2013

Subsystems (7)
lore
Share & tools
lore
#0 lore raw

cover tegra-next

In an attempt to sneak those into -next before the .12 release, just a quick dump.
For the first time barebox is now able to load and boot a Linux kernel from SDcard on Tegra. Makes it a lot more useful in the real world.

Lucas Stach (8):
tegra: fix fallout from relocatable code changes in PLLX init
tegra: speed up system bus
tegra: switch main CPU complex to PLLX early
gpio: tegra: remove leftover debug code
clk: tegra: add SDMMC clocks
tegra: add SDMMC controller driver
dts: tegra: add SDMMC nodes
dts: tegra: activate SDMMC on Colibri T20

 arch/arm/dts/tegra20-colibri-iris.dts          |   5 +
 arch/arm/dts/tegra20-colibri.dtsi              |   4 +
 arch/arm/dts/tegra20.dtsi                      |  32 ++
 arch/arm/mach-tegra/include/mach/tegra20-car.h |  44 +++
 arch/arm/mach-tegra/tegra_avp_init.c           |   2 +
 arch/arm/mach-tegra/tegra_maincomplex_init.c   |   9 +
 drivers/clk/tegra/clk-tegra20.c                |  25 ++
 drivers/gpio/gpio-tegra.c                      |   2 -
 drivers/mci/Kconfig                            |   7 +
 drivers/mci/Makefile                           |   1 +
 drivers/mci/tegra-sdmmc.c                      | 465 +++++++++++++++++++++++++
 11 files changed, 594 insertions(+), 2 deletions(-)
 create mode 100644 drivers/mci/tegra-sdmmc.c
Signature · 7 lines
1.8.3.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

PATCH 1/1 gpio: reduce noise when parsing DT

Some GPIOs are optional, so it might not be an error if we can not find a DT property. Do the same thing as the Linux kernel and only print a debug message not an error.

---
 drivers/of/of_gpio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/of/of_gpio.c +1 -1
index 3afdf0d..1370d8f 100644
@@ -25,7 +25,7 @@ int of_get_named_gpio_flags(struct device_node *np, const char *propname,
 	ret = of_parse_phandle_with_args(np, propname, "#gpio-cells",
 					index, &out_args);
 	if (ret) {
-		pr_err("%s: cannot parse %s property: %d\n",
+		pr_debug("%s: cannot parse %s property: %d\n",
 			__func__, propname, ret);
 		return ret;
 	}
Signature · 7 lines
1.8.3.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

PATCH 1/8 tegra: fix fallout from relocatable code changes in PLLX init

In reply to Lucas Stach

---
Urgh, the only reason why this didn't blew earlier is that it was covered by another bug, which caused the main CPU complex to run off OSC clock.

---
 arch/arm/mach-tegra/tegra_avp_init.c | 2 ++
 1 file changed, 2 insertions(+)
arch/arm/mach-tegra/tegra_avp_init.c +2 -0
index 6cabdb3..2c2d6fc 100644
@@ -103,6 +103,8 @@ static void init_pllx(void)
 		    CRC_OSC_CTRL_OSC_FREQ_MASK) >> CRC_OSC_CTRL_OSC_FREQ_SHIFT;
 
 	conf = &pllx_config_table[chiptype][osc_freq];
+	/* we are not relocated yet - globals are a bit more tricky here */
+	conf = (struct pll_config *)((char *)conf - get_runtime_offset());
 
 	/* set PLL bypass and frequency parameters */
 	reg = CRC_PLLX_BASE_BYPASS;
Signature · 7 lines
1.8.3.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw

PATCH 2/8 tegra: speed up system bus

In reply to Lucas Stach

We run the system bus from the OSC clock during init, to avoid crashing the system while reconfiguring the PLLs.
Switch to a more reasonable clock when we are done with this.

---
 arch/arm/mach-tegra/include/mach/tegra20-car.h | 12 ++++++++++++
 drivers/clk/tegra/clk-tegra20.c                |  7 +++++++
 2 files changed, 19 insertions(+)
arch/arm/mach-tegra/include/mach/tegra20-car.h +12 -0
index d4cb238..d4ff6fb 100644
@@ -53,6 +53,18 @@
 #define CRC_SCLK_BURST_POLICY_SYS_STATE_RUN	2
 #define CRC_SCLK_BURST_POLICY_SYS_STATE_IDLE	1
 #define CRC_SCLK_BURST_POLICY_SYS_STATE_STDBY	0
+#define CRC_SCLK_BURST_POLICY_FIQ_SRC_SHIFT	12
+#define CRC_SCLK_BURST_POLICY_IRQ_SRC_SHIFT	8
+#define CRC_SCLK_BURST_POLICY_RUN_SRC_SHIFT	4
+#define CRC_SCLK_BURST_POLICY_IDLE_SRC_SHIFT	0
+#define CRC_SCLK_BURST_POLICY_SRC_CLKM		0
+#define CRC_SCLK_BURST_POLICY_SRC_PLLC_OUT1	1
+#define CRC_SCLK_BURST_POLICY_SRC_PLLP_OUT4	2
+#define CRC_SCLK_BURST_POLICY_SRC_PLLP_OUT3	3
+#define CRC_SCLK_BURST_POLICY_SRC_PLLP_OUT2	4
+#define CRC_SCLK_BURST_POLICY_SRC_CLKD		5
+#define CRC_SCLK_BURST_POLICY_SRC_CLKS		6
+#define CRC_SCLK_BURST_POLICY_SRC_PLLM_OUT1	7
 
 #define CRC_SUPER_SCLK_DIV		0x02c
 #define CRC_SUPER_SDIV_ENB		(1 << 31)
drivers/clk/tegra/clk-tegra20.c +7 -0
index e70f99a..b94b7bc 100644
@@ -325,6 +325,13 @@ static int tegra20_car_probe(struct device_d *dev)
 
 	tegra_init_from_table(init_table, clks, clk_max);
 
+	/* speed up system bus */
+	writel(CRC_SCLK_BURST_POLICY_SYS_STATE_RUN <<
+	       CRC_SCLK_BURST_POLICY_SYS_STATE_SHIFT |
+	       CRC_SCLK_BURST_POLICY_SRC_PLLC_OUT1 <<
+	       CRC_SCLK_BURST_POLICY_RUN_SRC_SHIFT,
+	       car_base + CRC_SCLK_BURST_POLICY);
+
 	clk_data.clks = clks;
 	clk_data.clk_num = ARRAY_SIZE(clks);
 	of_clk_add_provider(dev->device_node, of_clk_src_onecell_get,
Signature · 7 lines
1.8.3.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#4 lore raw

PATCH 3/8 tegra: switch main CPU complex to PLLX early

In reply to Lucas Stach

Running at 1GHz, rather than 13MHz certainly makes things a bit faster.

---
 arch/arm/mach-tegra/include/mach/tegra20-car.h | 32 ++++++++++++++++++++++++++
 arch/arm/mach-tegra/tegra_maincomplex_init.c   |  9 ++++++++
 2 files changed, 41 insertions(+)
arch/arm/mach-tegra/include/mach/tegra20-car.h +32 -0
index d4ff6fb..64873d7 100644
@@ -46,6 +46,38 @@
 #define CRC_CLK_OUT_ENB_L_AC97		(1 << 3)
 #define CRC_CLK_OUT_ENB_L_CPU		(1 << 0)
 
+#define CRC_CCLK_BURST_POLICY		0x020
+#define CRC_CCLK_BURST_POLICY_SYS_STATE_SHIFT	28
+#define CRC_CCLK_BURST_POLICY_SYS_STATE_FIQ	8
+#define CRC_CCLK_BURST_POLICY_SYS_STATE_IRQ	4
+#define CRC_CCLK_BURST_POLICY_SYS_STATE_RUN	2
+#define CRC_CCLK_BURST_POLICY_SYS_STATE_IDLE	1
+#define CRC_CCLK_BURST_POLICY_SYS_STATE_STDBY	0
+#define CRC_CCLK_BURST_POLICY_FIQ_SRC_SHIFT	12
+#define CRC_CCLK_BURST_POLICY_IRQ_SRC_SHIFT	8
+#define CRC_CCLK_BURST_POLICY_RUN_SRC_SHIFT	4
+#define CRC_CCLK_BURST_POLICY_IDLE_SRC_SHIFT	0
+#define CRC_CCLK_BURST_POLICY_SRC_CLKM		0
+#define CRC_CCLK_BURST_POLICY_SRC_PLLC_OUT0	1
+#define CRC_CCLK_BURST_POLICY_SRC_CLKS		2
+#define CRC_CCLK_BURST_POLICY_SRC_PLLM_OUT0	3
+#define CRC_CCLK_BURST_POLICY_SRC_PLLP_OUT0	4
+#define CRC_CCLK_BURST_POLICY_SRC_PLLP_OUT4	5
+#define CRC_CCLK_BURST_POLICY_SRC_PLLP_OUT3	6
+#define CRC_CCLK_BURST_POLICY_SRC_CLKD		7
+#define CRC_CCLK_BURST_POLICY_SRC_PLLX_OUT0	8
+
+#define CRC_SUPER_CCLK_DIV		0x024
+#define CRC_SUPER_CDIV_ENB		(1 << 31)
+#define CRC_SUPER_CDIV_DIS_FROM_COP_FIQ	(1 << 27)
+#define CRC_SUPER_CDIV_DIS_FROM_CPU_FIQ	(1 << 26)
+#define CRC_SUPER_CDIV_DIS_FROM_COP_IRQ	(1 << 25)
+#define CRC_SUPER_CDIV_DIS_FROM_CPU_IRQ	(1 << 24)
+#define CRC_SUPER_CDIV_DIVIDEND_SHIFT	8
+#define CRC_SUPER_CDIV_DIVIDEND_MASK	(0xff << CRC_SUPER_CDIV_DIVIDEND_SHIFT)
+#define CRC_SUPER_CDIV_DIVISOR_SHIFT	0
+#define CRC_SUPER_CDIV_DIVISOR_MASK	(0xff << CRC_SUPER_CDIV_DIVISOR_SHIFT)
+
 #define CRC_SCLK_BURST_POLICY		0x028
 #define CRC_SCLK_BURST_POLICY_SYS_STATE_SHIFT	28
 #define CRC_SCLK_BURST_POLICY_SYS_STATE_FIQ	8
arch/arm/mach-tegra/tegra_maincomplex_init.c +9 -0
index b3d59ab..5aad1dd 100644
@@ -20,6 +20,7 @@
 #include <asm/barebox-arm.h>
 #include <mach/lowlevel.h>
 #include <mach/tegra20-pmc.h>
+#include <mach/tegra20-car.h>
 
 void tegra_maincomplex_entry(void)
 {
@@ -27,6 +28,14 @@ void tegra_maincomplex_entry(void)
 
 	arm_cpu_lowlevel_init();
 
+	/* switch to PLLX */
+	writel(CRC_CCLK_BURST_POLICY_SYS_STATE_RUN <<
+	       CRC_CCLK_BURST_POLICY_SYS_STATE_SHIFT |
+	       CRC_CCLK_BURST_POLICY_SRC_PLLX_OUT0 <<
+	       CRC_CCLK_BURST_POLICY_RUN_SRC_SHIFT,
+	       TEGRA_CLK_RESET_BASE + CRC_CCLK_BURST_POLICY);
+	writel(CRC_SUPER_CDIV_ENB, TEGRA_CLK_RESET_BASE + CRC_SUPER_CCLK_DIV);
+
 	switch (tegra_get_chiptype()) {
 	case TEGRA20:
 		rambase = 0x0;
Signature · 7 lines
1.8.3.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#5 lore raw

PATCH 4/8 gpio: tegra: remove leftover debug code

In reply to Lucas Stach
---
 drivers/gpio/gpio-tegra.c | 2 --
 1 file changed, 2 deletions(-)
drivers/gpio/gpio-tegra.c +0 -2
index 1e00f5e..e84c71a 100644
@@ -106,12 +106,10 @@ static int tegra_gpio_get(struct gpio_chip *chip, unsigned offset)
 {
 	/* If gpio is in output mode then read from the out value */
 	if ((tegra_gpio_readl(GPIO_OE(offset)) >> GPIO_BIT(offset)) & 1) {
-		printf("GPIO output mode\n");
 		return (tegra_gpio_readl(GPIO_OUT(offset)) >>
 				GPIO_BIT(offset)) & 0x1;
 	}
 
-	printf("GPIO input mode\n");
 	return (tegra_gpio_readl(GPIO_IN(offset)) >> GPIO_BIT(offset)) & 0x1;
 }
 
Signature · 7 lines
1.8.3.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#6 lore raw

PATCH 5/8 clk: tegra: add SDMMC clocks

In reply to Lucas Stach

Provide peripheral clocks for the SD controller.

---
 drivers/clk/tegra/clk-tegra20.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/clk/tegra/clk-tegra20.c +18 -0
index b94b7bc..f68c811 100644
@@ -295,6 +295,20 @@ static void tegra20_periph_init(void)
 	clks[uarte] = tegra_clk_register_periph_nodiv("uarte", mux_pllpcm_clkm,
 			ARRAY_SIZE(mux_pllpcm_clkm), car_base,
 			CRC_CLK_SOURCE_UARTE, uarte, TEGRA_PERIPH_ON_APB);
+
+	/* peripheral clocks with a divider */
+	clks[sdmmc1] = tegra_clk_register_periph("sdmmc1", mux_pllpcm_clkm,
+			ARRAY_SIZE(mux_pllpcm_clkm), car_base,
+			CRC_CLK_SOURCE_SDMMC1, sdmmc1, 1);
+	clks[sdmmc2] = tegra_clk_register_periph("sdmmc2", mux_pllpcm_clkm,
+			ARRAY_SIZE(mux_pllpcm_clkm), car_base,
+			CRC_CLK_SOURCE_SDMMC2, sdmmc2, 1);
+	clks[sdmmc3] = tegra_clk_register_periph("sdmmc3", mux_pllpcm_clkm,
+			ARRAY_SIZE(mux_pllpcm_clkm), car_base,
+			CRC_CLK_SOURCE_SDMMC3, sdmmc3, 1);
+	clks[sdmmc4] = tegra_clk_register_periph("sdmmc4", mux_pllpcm_clkm,
+			ARRAY_SIZE(mux_pllpcm_clkm), car_base,
+			CRC_CLK_SOURCE_SDMMC4, sdmmc4, 1);
 }
 
 static struct tegra_clk_init_table init_table[] = {
@@ -310,6 +324,10 @@ static struct tegra_clk_init_table init_table[] = {
 	{uartc,		pll_p,		0,		1},
 	{uartd,		pll_p,		0,		1},
 	{uarte,		pll_p,		0,		1},
+	{sdmmc1,	pll_p,		48000000,	0},
+	{sdmmc2,	pll_p,		48000000,	0},
+	{sdmmc3,	pll_p,		48000000,	0},
+	{sdmmc4,	pll_p,		48000000,	0},
 	{clk_max,	clk_max,	0,		0}, /* sentinel */
 };
 
Signature · 7 lines
1.8.3.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#7 lore raw

PATCH 6/8 tegra: add SDMMC controller driver

In reply to Lucas Stach

Confirmed working on Tegra 2, may need some small adjustments for Tegra 3.

---
 drivers/mci/Kconfig       |   7 +
 drivers/mci/Makefile      |   1 +
 drivers/mci/tegra-sdmmc.c | 465 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 473 insertions(+)
 create mode 100644 drivers/mci/tegra-sdmmc.c
drivers/mci/Kconfig +7 -0
index bd85424..3c86483 100644
@@ -107,6 +107,13 @@ config MCI_MMCI
 	  Enable this entry to add support to read and write SD cards on a
 	  ARM AMBA PL180.
 
+config MCI_TEGRA
+	bool "Tegra SD/MMC"
+	depends on ARCH_TEGRA
+	help
+	  Enable this to support SD and MMC card read/write on a Tegra based
+	  systems.
+
 config MCI_SPI
 	bool "MMC/SD over SPI"
 	select CRC7
drivers/mci/Makefile +1 -0
index 421ca9f..1e8443c 100644
@@ -7,6 +7,7 @@ obj-$(CONFIG_MCI_MXS)		+= mxs.o
 obj-$(CONFIG_MCI_OMAP_HSMMC)	+= omap_hsmmc.o
 obj-$(CONFIG_MCI_PXA)		+= pxamci.o
 obj-$(CONFIG_MCI_S3C)		+= s3c.o
+obj-$(CONFIG_MCI_TEGRA)		+= tegra-sdmmc.o
 obj-$(CONFIG_MCI_SPI)		+= mci_spi.o
 obj-$(CONFIG_MCI_DW)		+= dw_mmc.o
 obj-$(CONFIG_MCI_MMCI)		+= mmci.o
drivers/mci/tegra-sdmmc.c new file +465 -0

465 lines not on this page · raw message

Signature · 7 lines
1.8.3.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#8 lore raw

PATCH 7/8 dts: tegra: add SDMMC nodes

In reply to Lucas Stach
---
 arch/arm/dts/tegra20.dtsi | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
arch/arm/dts/tegra20.dtsi +32 -0
index f63ead8..2b333f5 100644
@@ -46,4 +46,36 @@
 		compatible = "nvidia,tegra20-pmc";
 		reg = <0x7000e400 0x400>;
 	};
+
+	sdhci@c8000000 {
+		compatible = "nvidia,tegra20-sdhci";
+		reg = <0xc8000000 0x200>;
+		interrupts = <0 14 0x04>;
+		clocks = <&tegra_car 14>;
+		status = "disabled";
+	};
+
+	sdhci@c8000200 {
+		compatible = "nvidia,tegra20-sdhci";
+		reg = <0xc8000200 0x200>;
+		interrupts = <0 15 0x04>;
+		clocks = <&tegra_car 9>;
+		status = "disabled";
+	};
+
+	sdhci@c8000400 {
+		compatible = "nvidia,tegra20-sdhci";
+		reg = <0xc8000400 0x200>;
+		interrupts = <0 19 0x04>;
+		clocks = <&tegra_car 69>;
+		status = "disabled";
+	};
+
+	sdhci@c8000600 {
+		compatible = "nvidia,tegra20-sdhci";
+		reg = <0xc8000600 0x200>;
+		interrupts = <0 31 0x04>;
+		clocks = <&tegra_car 15>;
+		status = "disabled";
+	};
 };
Signature · 7 lines
1.8.3.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#9 lore raw

PATCH 8/8 dts: tegra: activate SDMMC on Colibri T20

In reply to Lucas Stach
---
 arch/arm/dts/tegra20-colibri-iris.dts | 5 +++++
 arch/arm/dts/tegra20-colibri.dtsi     | 4 ++++
 2 files changed, 9 insertions(+)
arch/arm/dts/tegra20-colibri-iris.dts +5 -0
index 804750e..6b4ee00 100644
@@ -29,4 +29,9 @@
 			};
 		};
 	};
+
+	sdhci@c8000600 {
+		status = "okay";
+		bus-width = <4>;
+	};
 };
arch/arm/dts/tegra20-colibri.dtsi +4 -0
index 3644e7d..1ae5375 100644
@@ -187,4 +187,8 @@
 			};
 		};
 	};
+
+	sdhci@c8000600 {
+		cd-gpios = <&gpio 23 0>; /* gpio PC7 */
+	};
 };
Signature · 7 lines
1.8.3.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#10 lore raw
In reply to Lucas Stach
Quoted 5 lines · Lucas Stach

In an attempt to sneak those into -next before the .12 release, just a quick dump.
For the first time barebox is now able to load and boot a Linux kernel from SDcard on Tegra. Makes it a lot more useful in the real world.

Indeed ;)

Applied, thanks

Sascha

Quoted 34 lines

Lucas Stach (8):
tegra: fix fallout from relocatable code changes in PLLX init
tegra: speed up system bus
tegra: switch main CPU complex to PLLX early
gpio: tegra: remove leftover debug code
clk: tegra: add SDMMC clocks
tegra: add SDMMC controller driver
dts: tegra: add SDMMC nodes
dts: tegra: activate SDMMC on Colibri T20

 arch/arm/dts/tegra20-colibri-iris.dts          |   5 +
 arch/arm/dts/tegra20-colibri.dtsi              |   4 +
 arch/arm/dts/tegra20.dtsi                      |  32 ++
 arch/arm/mach-tegra/include/mach/tegra20-car.h |  44 +++
 arch/arm/mach-tegra/tegra_avp_init.c           |   2 +
 arch/arm/mach-tegra/tegra_maincomplex_init.c   |   9 +
 drivers/clk/tegra/clk-tegra20.c                |  25 ++
 drivers/gpio/gpio-tegra.c                      |   2 -
 drivers/mci/Kconfig                            |   7 +
 drivers/mci/Makefile                           |   1 +
 drivers/mci/tegra-sdmmc.c                      | 465 +++++++++++++++++++++++++
 11 files changed, 594 insertions(+), 2 deletions(-)
 create mode 100644 drivers/mci/tegra-sdmmc.c
Signature · 7 lines
1.8.3.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
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