ARM: mach-shmobile: kzm9g: Reference DT implementation
Subsystems (7)
cover ARM: mach-shmobile: kzm9g: Reference DT implementation
Hi Magnus, Hi all,
this series is a first pass at providing a refernce DT implementation for the kzm9g baord which is intended to act as a guide for mach-shmobile developers.
The first two patches of the series make minor modifications to the mmcif and sdhi drivers to allow registration of those devices using device tree on the KZM9G board.
The following three patches enhance sh77a0 SoC support to allow minimal registratioj using device tree.
The final patch adds a fresh board and dts file which initialises the kfm9g board using device tree as much as possible.
Simon Horman (7):
mmc: sh-mmcif: provide default allowed voltage
mmc: sdhi: enchance OF support for flags and cd-gpios
sh: pfc: Allow device tree registration
ARM: shmobile: pfc-sh73a0: Register device tree
ARM: mach-shmobile: sh73a0: Allow initialisation of GIC by DT
ARM: mach-shmobile: sh73a0: Minimal setup using DT
ARM: mach-shmobile: kzm9g: Reference DT implementation
arch/arm/boot/dts/Makefile | 3 +- arch/arm/boot/dts/sh73a0-kzm9g-reference.dts | 153 ++++++++++++++++++++++++ arch/arm/mach-shmobile/Kconfig | 10 ++ arch/arm/mach-shmobile/Makefile | 8 +- arch/arm/mach-shmobile/board-kzm9g-reference.c | 142 ++++++++++++++++++++++ arch/arm/mach-shmobile/include/mach/common.h | 3 + arch/arm/mach-shmobile/intc-sh73a0.c | 14 +++ arch/arm/mach-shmobile/pfc-sh73a0.c | 45 +++++++ arch/arm/mach-shmobile/setup-sh73a0.c | 41 ++++++- drivers/mmc/host/sh_mmcif.c | 7 +- drivers/mmc/host/sh_mobile_sdhi.c | 76 ++++++++++-- drivers/sh/pfc/gpio.c | 15 +++ include/linux/sh_pfc.h | 7 ++ 13 files changed, 501 insertions(+), 23 deletions(-) create mode 100644 arch/arm/boot/dts/sh73a0-kzm9g-reference.dts create mode 100644 arch/arm/mach-shmobile/board-kzm9g-reference.c
Signature · 1 line
1.7.10.4
PATCH 1/7 mmc: sh-mmcif: provide default allowed voltage
Use MMC_VDD_165_195 as the allowed voltages in the absence of platform data. This should allow device tree to initialise MMCIF for a number of boards.
A more complete solution would be to provide either MMCIF or MMC device try bindings to set the allowed voltages.
Tested on the KZM-A9-GT board
--- drivers/mmc/host/sh_mmcif.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/mmc/host/sh_mmcif.c +2 -5
@@ -1293,12 +1293,9 @@ static void sh_mmcif_init_ocr(struct sh_mmcif_host *host)mmc_regulator_get_supply (mmc); -if (!pd) -return ; -if (!mmc->ocr_avail) - mmc->ocr_avail = pd->ocr; -else if (pd->ocr) + mmc->ocr_avail = pd ? pd->ocr :MMC_VDD_165_195 ; +else if (pd && pd->ocr)dev_warn (mmc_dev (mmc),"Platform OCR mask is ignored\n" ); }
Signature · 1 line
1.7.10.4
Magnus Damm
maintainerPATCH 1/7 mmc: sh-mmcif: provide default allowed voltage
Hi Simon,
Quoted 7 lines · Simon Horman
Use
MMC_VDD_165_195as the allowed voltages in the absence of platform data. This should allow device tree to initialise MMCIF for a number of boards.A more complete solution would be to provide either MMCIF or MMC device try bindings to set the allowed voltages.
Quoted 7 lines
Tested on the KZM-A9-GT board
Cc Guennadi Liakhovetski <[email protected]>Signed-off-by Simon Horman <[email protected]>--- drivers/mmc/host/sh_mmcif.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
Thanks for your patch!
Quoted 8 lines
drivers/mmc/host/sh_mmcif.c +0
-0@@ -1293,12 +1293,9 @@ static void sh_mmcif_init_ocr(struct sh_mmcif_host *host)mmc_regulator_get_supply (mmc);
drivers/mmc/host/sh_mmcif.c static void sh_mmcif_init_ocr(struct sh_mmcif_host *host) · line 1300
Quoted 10 lines
drivers/mmc/host/sh_mmcif.c +2
-5-if (!pd) -return ; -if (!mmc->ocr_avail) - mmc->ocr_avail = pd->ocr; -else if (pd->ocr) + mmc->ocr_avail = pd ? pd->ocr :MMC_VDD_165_195 ; +else if (pd && pd->ocr)dev_warn (mmc_dev (mmc),"Platform OCR mask is ignored\n" ); }
I may be mistaken, but I somehow thought that the code in mmc_regulator_get_supply() would take care of this automatically for us already. So this kind of patch isn't really needed as long as you tie in regulators via DT as expected.
Thanks,
/ magnus
PATCH 1/7 mmc: sh-mmcif: provide default allowed voltage
Quoted 28 lines · Magnus Damm
Hi Simon,
Quoted 7 lines · Simon Horman
Use
MMC_VDD_165_195as the allowed voltages in the absence of platform data. This should allow device tree to initialise MMCIF for a number of boards.A more complete solution would be to provide either MMCIF or MMC device try bindings to set the allowed voltages.
Quoted 7 lines
Tested on the KZM-A9-GT board
Cc Guennadi Liakhovetski <[email protected]>Signed-off-by Simon Horman <[email protected]>--- drivers/mmc/host/sh_mmcif.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)Thanks for your patch!
Quoted 8 lines
drivers/mmc/host/sh_mmcif.c +0
-0@@ -1293,12 +1293,9 @@ static void sh_mmcif_init_ocr(struct sh_mmcif_host *host)mmc_regulator_get_supply (mmc);
Quoted 15 lines
drivers/mmc/host/sh_mmcif.c static void sh_mmcif_init_ocr(struct sh_mmcif_host *host) · line 1300
Quoted 10 lines
drivers/mmc/host/sh_mmcif.c +2
-5-if (!pd) -return ; -if (!mmc->ocr_avail) - mmc->ocr_avail = pd->ocr; -else if (pd->ocr) + mmc->ocr_avail = pd ? pd->ocr :MMC_VDD_165_195 ; +else if (pd && pd->ocr)dev_warn (mmc_dev (mmc),"Platform OCR mask is ignored\n" ); }I may be mistaken, but I somehow thought that the code in
mmc_regulator_get_supply()would take care of this automatically for us already. So this kind of patch isn't really needed as long as you tie in regulators via DT as expected.
Thanks, I'll check that. I did write this patch before hooking up the regulators correctly.
PATCH 2/7 mmc: sdhi: enchance OF support for flags and cd-gpios
In reply to Simon HormanEnhance the OF support for SDHI by adding the following bindings:
* renesas,shmobile-sdhi-has-idle-wait:
Equivalent to setting TMIO_MMC_HAS_IDLE_WAIT in the flags of platform data
* renesas,shmobile-sdhi-use-gpio-cd:
Equivalent to setting TMIO_MMC_USE_GPIO_CD in
the flags of platform data
* renesas,shmobile-sdhi-wrprotect-disable:
Equivalent to setting TMIO_MMC_WRPROTECT_DISABLE in the flags of platform data
* cd-gpios:
Equivalent to setting cd_gpio in platform data
This patch also requests the clock based on the device tree node name if the platform data is absent.
The motivation for this is to allow registration of the SDHI device of the KZM-A9-GT board through device tree.
The following device tree snippet illustrates the use of the bindings described above.
sdhi0 at 0xee100000 {
compatible = "renesas,shmobile-sdhi";
reg = <0xee100000 0x100>;
interrupt-parent = <&gic>;
interrupts = <0 83 0x4
0 84 0x4
0 85 0x4>;
interrupt-names = "card_detect", "sdcard", "sdio";
reg-io-width = <2>;
vmmc-supply = <&fixedregulator2v8>;
vqmmc-supply = <&fixedregulator2v8>;
renesas,shmobile-sdhi-has-idle-wait;
};
sdhi2 at 0xee140000 {
compatible = "renesas,shmobile-sdhi";
reg = <0xee140000 0x100>;
interrupt-parent = <&gic>;
interrupts = <0 103 0x4
0 104 0x4
0 105 0x4>;
interrupt-names = "card_detect", "sdcard", "sdio";
reg-io-width = <2>;
vmmc-supply = <&fixedregulator2v8>;
vqmmc-supply = <&fixedregulator2v8>;
renesas,shmobile-sdhi-has-idle-wait;
renesas,shmobile-sdhi-use-gpio-cd;
renesas,shmobile-sdhi-wrprotect-disable;
cd-gpios = <&gpio 13 1>;
};--- drivers/mmc/host/sh_mobile_sdhi.c | 76 +++++++++++++++++++++++++++++++------ 1 file changed, 65 insertions(+), 11 deletions(-)
drivers/mmc/host/sh_mobile_sdhi.c +65 -11
@@ -29,6 +29,7 @@#include <linux/mfd/tmio.h> #include <linux/sh_dma.h> #include <linux/delay.h> +#include <linux/of_gpio.h> #include "tmio_mmc.h"
@@ -117,13 +118,64 @@ static const struct sh_mobile_sdhi_ops sdhi_ops = { .cd_wakeup = sh_mobile_sdhi_cd_wakeup, }; +static int __devinit +sh_mobile_sdhi_probe_clk (struct platform_device *pdev, +struct sh_mobile_sdhi *priv, +const char *clk_name) +{ + priv->clk =clk_get (&pdev->dev, clk_name); +if (IS_ERR (priv->clk)) { +dev_err (&pdev->dev,"cannot get clock \"%s\"\n" , clk_name); +return PTR_ERR (priv->clk); + } + +return 0 ; +} + +#ifdef CONFIG_OF +static int __devinit +sh_mobile_sdhi_probe_config_dt (struct platform_device *pdev, +struct sh_mobile_sdhi *priv) +{ +struct tmio_mmc_data *mmc_data = &priv->mmc_data; +struct device_node *np = pdev->dev.of_node; +int ret; + +BUG_ON (!np); + + ret =sh_mobile_sdhi_probe_clk (pdev, priv, np->name); +if (ret) +return ret; + + ret =of_get_named_gpio (np,"cd-gpios" ,0 ); +if (gpio_is_valid (ret)) + mmc_data->cd_gpio = ret; + +if (of_get_property (np,"renesas,shmobile-sdhi-has-idle-wait" ,NULL )) + mmc_data->flags |=TMIO_MMC_HAS_IDLE_WAIT ; +if (of_get_property (np,"renesas,shmobile-sdhi-use-gpio-cd" ,NULL )) + mmc_data->flags |=TMIO_MMC_USE_GPIO_CD ; +if (of_get_property (np,"renesas,shmobile-sdhi-wrprotect-disable" , +NULL )) + mmc_data->flags |=TMIO_MMC_WRPROTECT_DISABLE ; + +return 0 ; +} +#else +static int __devinit +sh_mobile_sdhi_probe_config_dt (struct platform_device *pdev, +struct sh_mobile_sdhi *priv) +{ +return 0 ; +} +#endif +static int __devinit sh_mobile_sdhi_probe (struct platform_device *pdev) {struct sh_mobile_sdhi *priv;struct tmio_mmc_data *mmc_data;struct sh_mobile_sdhi_info *p = pdev->dev.platform_data;struct tmio_mmc_host *host; -char clk_name[8 ];int irq, ret, i =0 ;bool multiplexed_isr = true;
@@ -144,21 +196,17 @@ static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev) } } -snprintf (clk_name,sizeof (clk_name),"sdhi%d" , pdev->id); - priv->clk =clk_get (&pdev->dev, clk_name); -if (IS_ERR (priv->clk)) { -dev_err (&pdev->dev,"cannot get clock \"%s\"\n" , clk_name); - ret =PTR_ERR (priv->clk); - goto eclkget; - } - mmc_data->clk_enable = sh_mobile_sdhi_clk_enable; mmc_data->clk_disable = sh_mobile_sdhi_clk_disable; mmc_data->capabilities =MMC_CAP_MMC_HIGHSPEED ;if (p) { +char clk_name[8 ]; +snprintf (clk_name,sizeof (clk_name),"sdhi%d" , pdev->id); + ret =sh_mobile_sdhi_probe_clk (pdev, priv, clk_name); +if (ret) + goto eclkget; + mmc_data->flags = p->tmio_flags; -if (mmc_data->flags &TMIO_MMC_HAS_IDLE_WAIT ) - mmc_data->write16_hook = sh_mobile_sdhi_write16_hook; mmc_data->ocr_mask = p->tmio_ocr_mask; mmc_data->capabilities |= p->tmio_caps; mmc_data->capabilities2 |= p->tmio_caps2;
@@ -176,7 +224,13 @@ static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev) priv->dma_priv.alignment_shift =1 ;/* 2-byte alignment */ mmc_data->dma = &priv->dma_priv; } + }else { + ret =sh_mobile_sdhi_probe_config_dt (pdev, priv); +if (ret) + goto eclkget; } +if (mmc_data->flags &TMIO_MMC_HAS_IDLE_WAIT ) + mmc_data->write16_hook = sh_mobile_sdhi_write16_hook;/* * All SDHI blocks support 2-byte and larger block sizes in 4-bit
Signature · 1 line
1.7.10.4
PATCH 2/7 mmc: sdhi: enchance OF support for flags and cd-gpios
Hi Simon
Thanks for the patch, please, see some comments inline.
Quoted 14 lines · Simon Horman
Enhance the OF support for SDHI by adding the following bindings:
* renesas,shmobile-sdhi-has-idle-wait:
Equivalent to settingTMIO_MMC_HAS_IDLE_WAITin the flags of platform data* renesas,shmobile-sdhi-use-gpio-cd:
Equivalent to settingTMIO_MMC_USE_GPIO_CDin
the flags of platform data* renesas,shmobile-sdhi-wrprotect-disable:
Equivalent to settingTMIO_MMC_WRPROTECT_DISABLEin the flags of platform data
Quoted 5 lines
* cd-gpios:
Equivalent to settingcd_gpioin platform dataThis patch also requests the clock based on the device tree node name if the platform data is absent.
I'm not sure this is a good idea. IIUC, the idea is, that you either only have one clock, then you don't use a name, or you use several clocks, then your driver should know the names and what each of them is used for. See, e.g. drivers/mtd/nand/gpmi-nand/gpmi-nand.c::gpmi_get_clks()
static char *extra_clks_for_mx6q[GPMI_CLK_MAX] = {
"gpmi_apb", "gpmi_bch", "gpmi_bch_apb", "per1_bch",
};static int __devinit gpmi_get_clks(struct gpmi_nand_data *this)
{
...
/* The main clock is stored in the first. */
r->clock[0] = clk_get(this->dev, "gpmi_io");etc., and clock declaration in arch/arm/boot/dts/imx6q.dtsi:
gpmi-nand at 00112000 {
compatible = "fsl,imx6q-gpmi-nand";
...
clocks = <&clks 152>, <&clks 153>, <&clks 151>,
<&clks 150>, <&clks 149>;
clock-names = "gpmi_io", "gpmi_apb", "gpmi_bch",
"gpmi_bch_apb", "per1_bch";Quoted 56 lines
The motivation for this is to allow registration of the SDHI device of the KZM-A9-GT board through device tree.
The following device tree snippet illustrates the use of the bindings described above.
sdhi0 at 0xee100000 { compatible = "renesas,shmobile-sdhi"; reg = <0xee100000 0x100>; interrupt-parent = <&gic>; interrupts = <0 83 0x4 0 84 0x4 0 85 0x4>; interrupt-names = "card_detect", "sdcard", "sdio"; reg-io-width = <2>; vmmc-supply = <&fixedregulator2v8>; vqmmc-supply = <&fixedregulator2v8>; renesas,shmobile-sdhi-has-idle-wait; }; sdhi2 at 0xee140000 { compatible = "renesas,shmobile-sdhi"; reg = <0xee140000 0x100>; interrupt-parent = <&gic>; interrupts = <0 103 0x4 0 104 0x4 0 105 0x4>; interrupt-names = "card_detect", "sdcard", "sdio"; reg-io-width = <2>; vmmc-supply = <&fixedregulator2v8>; vqmmc-supply = <&fixedregulator2v8>; renesas,shmobile-sdhi-has-idle-wait; renesas,shmobile-sdhi-use-gpio-cd; renesas,shmobile-sdhi-wrprotect-disable; cd-gpios = <&gpio 13 1>; };Cc Guennadi Liakhovetski <[email protected]>Signed-off-by Simon Horman <[email protected]>--- drivers/mmc/host/sh_mobile_sdhi.c | 76 +++++++++++++++++++++++++++++++------ 1 file changed, 65 insertions(+), 11 deletions(-)drivers/mmc/host/sh_mobile_sdhi.c +1
-0@@ -29,6 +29,7 @@#include <linux/mfd/tmio.h> #include <linux/sh_dma.h> #include <linux/delay.h> +#include <linux/of_gpio.h> #include "tmio_mmc.h"
drivers/mmc/host/sh_mobile_sdhi.c static const struct sh_mobile_sdhi_ops sdhi_ops = { · line 121
Quoted 4 lines
drivers/mmc/host/sh_mobile_sdhi.c +1
-0@@ -117,13 +118,64 @@ static const struct sh_mobile_sdhi_ops sdhi_ops = { .cd_wakeup = sh_mobile_sdhi_cd_wakeup, }; +static int __devinit
__devinit is being removed:
http://thread.gmane.org/gmane.linux.ports.arm.omap/89686
please, drop it from this patch.
drivers/mmc/host/sh_mobile_sdhi.c static const struct sh_mobile_sdhi_ops sdhi_ops = { · line 125
Quoted 4 lines
drivers/mmc/host/sh_mobile_sdhi.c +4
-0+sh_mobile_sdhi_probe_clk(struct platform_device *pdev, + struct sh_mobile_sdhi *priv, + const char *clk_name) +{
Once you resolve the doubt about the clock name, maybe this function could be dropped and you could just call clk_get() directly? Preferably from sh_mobile_sdhi_probe() directly (also see below)?
Quoted 9 lines
drivers/mmc/host/sh_mobile_sdhi.c +9
-0+ priv->clk =clk_get (&pdev->dev, clk_name); +if (IS_ERR (priv->clk)) { +dev_err (&pdev->dev,"cannot get clock \"%s\"\n" , clk_name); +return PTR_ERR (priv->clk); + } + +return 0 ; +} +
drivers/mmc/host/sh_mobile_sdhi.c static const struct sh_mobile_sdhi_ops sdhi_ops = { · line 144
Quoted 10 lines
drivers/mmc/host/sh_mobile_sdhi.c +10
-0+#ifdef CONFIG_OF +static int __devinit +sh_mobile_sdhi_probe_config_dt (struct platform_device *pdev, +struct sh_mobile_sdhi *priv) +{ +struct tmio_mmc_data *mmc_data = &priv->mmc_data; +struct device_node *np = pdev->dev.of_node; +int ret; + +BUG_ON (!np);
Hm, does this mean, that if you define CONFIG_OF in your kernel and don't provide platform data the driver will just Oops?...
Quoted 50 lines
drivers/mmc/host/sh_mobile_sdhi.c +28
-9+ + ret =sh_mobile_sdhi_probe_clk (pdev, priv, np->name); +if (ret) +return ret; + + ret =of_get_named_gpio (np,"cd-gpios" ,0 ); +if (gpio_is_valid (ret)) + mmc_data->cd_gpio = ret; + +if (of_get_property (np,"renesas,shmobile-sdhi-has-idle-wait" ,NULL )) + mmc_data->flags |=TMIO_MMC_HAS_IDLE_WAIT ; +if (of_get_property (np,"renesas,shmobile-sdhi-use-gpio-cd" ,NULL )) + mmc_data->flags |=TMIO_MMC_USE_GPIO_CD ; +if (of_get_property (np,"renesas,shmobile-sdhi-wrprotect-disable" , +NULL )) + mmc_data->flags |=TMIO_MMC_WRPROTECT_DISABLE ; + + return 0; +} +#else +static int __devinit +sh_mobile_sdhi_probe_config_dt (struct platform_device *pdev, +struct sh_mobile_sdhi *priv) +{ +return 0 ; +} +#endif +static int __devinit sh_mobile_sdhi_probe (struct platform_device *pdev) {struct sh_mobile_sdhi *priv;struct tmio_mmc_data *mmc_data;struct sh_mobile_sdhi_info *p = pdev->dev.platform_data;struct tmio_mmc_host *host; -char clk_name[8 ];int irq, ret, i =0 ;bool multiplexed_isr = true;@@ -144,21 +196,17 @@ static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev) } } -snprintf (clk_name,sizeof (clk_name),"sdhi%d" , pdev->id); - priv->clk =clk_get (&pdev->dev, clk_name); -if (IS_ERR (priv->clk)) { -dev_err (&pdev->dev,"cannot get clock \"%s\"\n" , clk_name); - ret =PTR_ERR (priv->clk); - goto eclkget; - } -
drivers/mmc/host/sh_mobile_sdhi.c static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev) · line 208
Quoted 10 lines
drivers/mmc/host/sh_mobile_sdhi.c +6
-0mmc_data->clk_enable = sh_mobile_sdhi_clk_enable; mmc_data->clk_disable = sh_mobile_sdhi_clk_disable; mmc_data->capabilities =MMC_CAP_MMC_HIGHSPEED ;if (p) { +char clk_name[8 ]; +snprintf (clk_name,sizeof (clk_name),"sdhi%d" , pdev->id); + ret =sh_mobile_sdhi_probe_clk (pdev, priv, clk_name); +if (ret) + goto eclkget; +
This breaks the no-DT and no-platform-data case. With this your patch the clock wouldn't be obtain then.
drivers/mmc/host/sh_mobile_sdhi.c static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev) · line 227
Quoted 11 lines
drivers/mmc/host/sh_mobile_sdhi.c +1
-2mmc_data->flags = p->tmio_flags; -if (mmc_data->flags &TMIO_MMC_HAS_IDLE_WAIT ) - mmc_data->write16_hook = sh_mobile_sdhi_write16_hook; mmc_data->ocr_mask = p->tmio_ocr_mask; mmc_data->capabilities |= p->tmio_caps; mmc_data->capabilities2 |= p->tmio_caps2;@@ -176,7 +224,13 @@ static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev) priv->dma_priv.alignment_shift =1 ;/* 2-byte alignment */ mmc_data->dma = &priv->dma_priv; } + }else {
Please, remember, that the driver should be able to work with no platform data, no DT and CONFIG_OF either defined or not.
Quoted 12 lines
drivers/mmc/host/sh_mobile_sdhi.c +5
-0+ ret =sh_mobile_sdhi_probe_config_dt (pdev, priv); +if (ret) + goto eclkget; } +if (mmc_data->flags &TMIO_MMC_HAS_IDLE_WAIT ) + mmc_data->write16_hook = sh_mobile_sdhi_write16_hook;/* * All SDHI blocks support 2-byte and larger block sizes in 4-bit Signature · 1 line
1.7.10.4
Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
PATCH 2/7 mmc: sdhi: enchance OF support for flags and cd-gpios
In reply to Simon HormanOn Mon, 26 Nov 2012, Simon Horman wrote:
Sorry, forgot to mention: it is always good to add devicetree-discuss at lists.ozlabs.org to such patches, also we need a document undet Documentation/devicetree/bindings/mmc/.
Thanks
Guennadi
Quoted 186 lines
Enhance the OF support for SDHI by adding the following bindings:
* renesas,shmobile-sdhi-has-idle-wait:
Equivalent to settingTMIO_MMC_HAS_IDLE_WAITin the flags of platform data* renesas,shmobile-sdhi-use-gpio-cd:
Equivalent to settingTMIO_MMC_USE_GPIO_CDin
the flags of platform data* renesas,shmobile-sdhi-wrprotect-disable:
Equivalent to settingTMIO_MMC_WRPROTECT_DISABLEin the flags of platform data* cd-gpios:
Equivalent to settingcd_gpioin platform dataThis patch also requests the clock based on the device tree node name if the platform data is absent.
The motivation for this is to allow registration of the SDHI device of the KZM-A9-GT board through device tree.
The following device tree snippet illustrates the use of the bindings described above.
sdhi0 at 0xee100000 { compatible = "renesas,shmobile-sdhi"; reg = <0xee100000 0x100>; interrupt-parent = <&gic>; interrupts = <0 83 0x4 0 84 0x4 0 85 0x4>; interrupt-names = "card_detect", "sdcard", "sdio"; reg-io-width = <2>; vmmc-supply = <&fixedregulator2v8>; vqmmc-supply = <&fixedregulator2v8>; renesas,shmobile-sdhi-has-idle-wait; }; sdhi2 at 0xee140000 { compatible = "renesas,shmobile-sdhi"; reg = <0xee140000 0x100>; interrupt-parent = <&gic>; interrupts = <0 103 0x4 0 104 0x4 0 105 0x4>; interrupt-names = "card_detect", "sdcard", "sdio"; reg-io-width = <2>; vmmc-supply = <&fixedregulator2v8>; vqmmc-supply = <&fixedregulator2v8>; renesas,shmobile-sdhi-has-idle-wait; renesas,shmobile-sdhi-use-gpio-cd; renesas,shmobile-sdhi-wrprotect-disable; cd-gpios = <&gpio 13 1>; };Cc Guennadi Liakhovetski <[email protected]>Signed-off-by Simon Horman <[email protected]>--- drivers/mmc/host/sh_mobile_sdhi.c | 76 +++++++++++++++++++++++++++++++------ 1 file changed, 65 insertions(+), 11 deletions(-)drivers/mmc/host/sh_mobile_sdhi.c +65
-11@@ -29,6 +29,7 @@#include <linux/mfd/tmio.h> #include <linux/sh_dma.h> #include <linux/delay.h> +#include <linux/of_gpio.h> #include "tmio_mmc.h" @@ -117,13 +118,64 @@ static const struct sh_mobile_sdhi_ops sdhi_ops = { .cd_wakeup = sh_mobile_sdhi_cd_wakeup, }; +static int __devinit +sh_mobile_sdhi_probe_clk (struct platform_device *pdev, +struct sh_mobile_sdhi *priv, +const char *clk_name) +{ + priv->clk =clk_get (&pdev->dev, clk_name); +if (IS_ERR (priv->clk)) { +dev_err (&pdev->dev,"cannot get clock \"%s\"\n" , clk_name); +return PTR_ERR (priv->clk); + } + +return 0 ; +} + +#ifdef CONFIG_OF +static int __devinit +sh_mobile_sdhi_probe_config_dt (struct platform_device *pdev, +struct sh_mobile_sdhi *priv) +{ +struct tmio_mmc_data *mmc_data = &priv->mmc_data; +struct device_node *np = pdev->dev.of_node; +int ret; + +BUG_ON (!np); + + ret =sh_mobile_sdhi_probe_clk (pdev, priv, np->name); +if (ret) +return ret; + + ret =of_get_named_gpio (np,"cd-gpios" ,0 ); +if (gpio_is_valid (ret)) + mmc_data->cd_gpio = ret; + +if (of_get_property (np,"renesas,shmobile-sdhi-has-idle-wait" ,NULL )) + mmc_data->flags |=TMIO_MMC_HAS_IDLE_WAIT ; +if (of_get_property (np,"renesas,shmobile-sdhi-use-gpio-cd" ,NULL )) + mmc_data->flags |=TMIO_MMC_USE_GPIO_CD ; +if (of_get_property (np,"renesas,shmobile-sdhi-wrprotect-disable" , +NULL )) + mmc_data->flags |=TMIO_MMC_WRPROTECT_DISABLE ; + +return 0 ; +} +#else +static int __devinit +sh_mobile_sdhi_probe_config_dt (struct platform_device *pdev, +struct sh_mobile_sdhi *priv) +{ +return 0 ; +} +#endif +static int __devinit sh_mobile_sdhi_probe (struct platform_device *pdev) {struct sh_mobile_sdhi *priv;struct tmio_mmc_data *mmc_data;struct sh_mobile_sdhi_info *p = pdev->dev.platform_data;struct tmio_mmc_host *host; -char clk_name[8 ];int irq, ret, i =0 ;bool multiplexed_isr = true;@@ -144,21 +196,17 @@ static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev) } } -snprintf (clk_name,sizeof (clk_name),"sdhi%d" , pdev->id); - priv->clk =clk_get (&pdev->dev, clk_name); -if (IS_ERR (priv->clk)) { -dev_err (&pdev->dev,"cannot get clock \"%s\"\n" , clk_name); - ret =PTR_ERR (priv->clk); - goto eclkget; - } - mmc_data->clk_enable = sh_mobile_sdhi_clk_enable; mmc_data->clk_disable = sh_mobile_sdhi_clk_disable; mmc_data->capabilities =MMC_CAP_MMC_HIGHSPEED ;if (p) { +char clk_name[8 ]; +snprintf (clk_name,sizeof (clk_name),"sdhi%d" , pdev->id); + ret =sh_mobile_sdhi_probe_clk (pdev, priv, clk_name); +if (ret) + goto eclkget; + mmc_data->flags = p->tmio_flags; -if (mmc_data->flags &TMIO_MMC_HAS_IDLE_WAIT ) - mmc_data->write16_hook = sh_mobile_sdhi_write16_hook; mmc_data->ocr_mask = p->tmio_ocr_mask; mmc_data->capabilities |= p->tmio_caps; mmc_data->capabilities2 |= p->tmio_caps2;@@ -176,7 +224,13 @@ static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev) priv->dma_priv.alignment_shift =1 ;/* 2-byte alignment */ mmc_data->dma = &priv->dma_priv; } + }else { + ret =sh_mobile_sdhi_probe_config_dt (pdev, priv); +if (ret) + goto eclkget; } +if (mmc_data->flags &TMIO_MMC_HAS_IDLE_WAIT ) + mmc_data->write16_hook = sh_mobile_sdhi_write16_hook;/* * All SDHI blocks support 2-byte and larger block sizes in 4-bit Signature · 1 line
1.7.10.4
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
PATCH 3/7 sh: pfc: Allow device tree registration
In reply to Simon HormanThis is a crude mechanism to allow the pfc driver to be registered through device tree. The mofication of this is to provide a way for pfc gpios to be looked up by device tree for devices which use pfc gpios.
More specifically, the motivation is to allow the registration of the card-detect gpio for the Micro-SD SDHI slot of the KZM9G board.
--- drivers/sh/pfc/gpio.c | 15 +++++++++++++++ include/linux/sh_pfc.h | 7 +++++++ 2 files changed, 22 insertions(+)
drivers/sh/pfc/gpio.c +15 -0
@@ -136,6 +136,19 @@ static void sh_pfc_gpio_setup(struct sh_pfc_chip *chip) gc->ngpio = (pfc->last_gpio - pfc->first_gpio) +1 ; } +#ifdef CONFIG_OF_GPIO +static void +sh_pfc_register_gpiochip_dt (struct sh_pfc *pfc,struct gpio_chip *chip) +{ + chip->of_node = pfc->of_node; + chip->of_gpio_n_cells = pfc->of_gpio_n_cells; + chip->of_xlate = pfc->of_xlate; +} +#else +static void sh_pfc_register_gpiochip_dt (struct sh_pfc *pfc, +struct gpio_chip *chip) {} +#endif +int sh_pfc_register_gpiochip (struct sh_pfc *pfc) {struct sh_pfc_chip *chip;
@@ -153,6 +166,8 @@ int sh_pfc_register_gpiochip(struct sh_pfc *pfc)if (unlikely (ret <0 ))kfree (chip); +sh_pfc_register_gpiochip_dt (pfc, &chip->gpio_chip); +pr_info ("%s handling gpio %d -> %d\n" , pfc->name, pfc->first_gpio, pfc->last_gpio);
include/linux/sh_pfc.h +7 -0
@@ -124,6 +124,13 @@ struct sh_pfc {struct pfc_window *window;unsigned long unlock_reg; + +#ifdef CONFIG_OF_GPIO +struct device_node *of_node; +int of_gpio_n_cells; +int (*of_xlate)(struct gpio_chip *gc, +const struct of_phandle_args *gpiospec,u32 *flags); +#endif };/* XXX compat for now */
Signature · 1 line
1.7.10.4
PATCH 3/7 sh: pfc: Allow device tree registration
Hi Simon,
Quoted 3 lines · On Monday 26 November 2012 09:16:50 Simon Horman wrote:
This is a crude mechanism to allow the pfc driver to be registered through device tree. The mofication of this is to provide a way for pfc gpios to be looked up by device tree for devices which use pfc gpios.
Indeed it's a bit of a hack :-) I'll see how I can rebase that on top of my PFC patch series. I'd rather avoid this intermediate step as it would make PFC rework more complex.
Quoted 62 lines
More specifically, the motivation is to allow the registration of the card-detect gpio for the Micro-SD SDHI slot of the KZM9G board.
Cc Paul Mundt <[email protected]>Cc Laurent Pinchart <[email protected]>Signed-off-by Simon Horman <[email protected]>--- drivers/sh/pfc/gpio.c | 15 +++++++++++++++ include/linux/sh_pfc.h | 7 +++++++ 2 files changed, 22 insertions(+)drivers/sh/pfc/gpio.c +15
-0@@ -136,6 +136,19 @@ static void sh_pfc_gpio_setup(struct sh_pfc_chip *chip) gc->ngpio = (pfc->last_gpio - pfc->first_gpio) +1 ; } +#ifdef CONFIG_OF_GPIO +static void +sh_pfc_register_gpiochip_dt (struct sh_pfc *pfc,struct gpio_chip *chip) +{ + chip->of_node = pfc->of_node; + chip->of_gpio_n_cells = pfc->of_gpio_n_cells; + chip->of_xlate = pfc->of_xlate; +} +#else +static void sh_pfc_register_gpiochip_dt (struct sh_pfc *pfc, +struct gpio_chip *chip) {} +#endif +int sh_pfc_register_gpiochip (struct sh_pfc *pfc) {struct sh_pfc_chip *chip;@@ -153,6 +166,8 @@ int sh_pfc_register_gpiochip(struct sh_pfc *pfc)if (unlikely (ret <0 ))kfree (chip); +sh_pfc_register_gpiochip_dt (pfc, &chip->gpio_chip); +pr_info ("%s handling gpio %d -> %d\n" , pfc->name, pfc->first_gpio, pfc->last_gpio);include/linux/sh_pfc.h +7
-0@@ -124,6 +124,13 @@ struct sh_pfc {struct pfc_window *window;unsigned long unlock_reg; + +#ifdef CONFIG_OF_GPIO +struct device_node *of_node; +int of_gpio_n_cells; +int (*of_xlate)(struct gpio_chip *gc, +const struct of_phandle_args *gpiospec,u32 *flags); +#endif };/* XXX compat for now */
Signature · 3 lines
Regards, Laurent Pinchart
PATCH 3/7 sh: pfc: Allow device tree registration
In reply to Simon HormanHi Simon,
Quoted 7 lines · On Monday 26 November 2012 09:16:50 Simon Horman wrote:
This is a crude mechanism to allow the pfc driver to be registered through device tree. The mofication of this is to provide a way for pfc gpios to be looked up by device tree for devices which use pfc gpios.
More specifically, the motivation is to allow the registration of the card-detect gpio for the Micro-SD SDHI slot of the KZM9G board.
I've just posted v2 of my PCF patches ("SH pin control and GPIO rework with OF support") that include OF support for GPIOs. This patch as well as patch 4/7 and the gpio node in patch 7/7 and shouldn't be required anymore.
Quoted 59 lines
Cc Paul Mundt <[email protected]>Cc Laurent Pinchart <[email protected]>Signed-off-by Simon Horman <[email protected]>--- drivers/sh/pfc/gpio.c | 15 +++++++++++++++ include/linux/sh_pfc.h | 7 +++++++ 2 files changed, 22 insertions(+)drivers/sh/pfc/gpio.c +15
-0@@ -136,6 +136,19 @@ static void sh_pfc_gpio_setup(struct sh_pfc_chip *chip) gc->ngpio = (pfc->last_gpio - pfc->first_gpio) +1 ; } +#ifdef CONFIG_OF_GPIO +static void +sh_pfc_register_gpiochip_dt (struct sh_pfc *pfc,struct gpio_chip *chip) +{ + chip->of_node = pfc->of_node; + chip->of_gpio_n_cells = pfc->of_gpio_n_cells; + chip->of_xlate = pfc->of_xlate; +} +#else +static void sh_pfc_register_gpiochip_dt (struct sh_pfc *pfc, +struct gpio_chip *chip) {} +#endif +int sh_pfc_register_gpiochip (struct sh_pfc *pfc) {struct sh_pfc_chip *chip;@@ -153,6 +166,8 @@ int sh_pfc_register_gpiochip(struct sh_pfc *pfc)if (unlikely (ret <0 ))kfree (chip); +sh_pfc_register_gpiochip_dt (pfc, &chip->gpio_chip); +pr_info ("%s handling gpio %d -> %d\n" , pfc->name, pfc->first_gpio, pfc->last_gpio);include/linux/sh_pfc.h +7
-0@@ -124,6 +124,13 @@ struct sh_pfc {struct pfc_window *window;unsigned long unlock_reg; + +#ifdef CONFIG_OF_GPIO +struct device_node *of_node; +int of_gpio_n_cells; +int (*of_xlate)(struct gpio_chip *gc, +const struct of_phandle_args *gpiospec,u32 *flags); +#endif };/* XXX compat for now */
Signature · 3 lines
Regards, Laurent Pinchart
PATCH 3/7 sh: pfc: Allow device tree registration
Quoted 8 lines · Laurent Pinchart
Hi Simon,
Quoted 5 lines · On Monday 26 November 2012 09:16:50 Simon Horman wrote:
This is a crude mechanism to allow the pfc driver to be registered through device tree. The mofication of this is to provide a way for pfc gpios to be looked up by device tree for devices which use pfc gpios.
Quoted 6 lines
Quoted 2 lines
More specifically, the motivation is to allow the registration of the card-detect gpio for the Micro-SD SDHI slot of the KZM9G board.
I've just posted v2 of my PCF patches ("SH pin control and GPIO rework with OF support") that include OF support for GPIOs. This patch as well as patch 4/7 and the gpio node in patch 7/7 and shouldn't be required anymore.
Thanks.
PATCH 4/7 ARM: shmobile: pfc-sh73a0: Register device tree
In reply to Simon HormanRegister the pfc with sh73a0_init_gpio_dt() to allow gpios provided by pfc to be accessed by devices which are registered using device tree.
The motivation of this is to allow the gpio used for carrier detect but the Micro SD SDHI port of the KZM-9A-GT board to be accessed using device tree. Thus, allowing the SDHI device of the KZM-9A-GT board to be registered using device tree.
--- arch/arm/mach-shmobile/pfc-sh73a0.c | 45 +++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+)
arch/arm/mach-shmobile/pfc-sh73a0.c +45 -0
@@ -2797,7 +2797,52 @@ static struct pinmux_info sh73a0_pinmux_info = { .gpio_irq_size = ARRAY_SIZE(pinmux_irqs), }; +#ifdef CONFIG_OF_GPIO +static int sh73a0_gpio_xlate (struct gpio_chip *gc, +const struct of_phandle_args *gpiospec, +u32 *flags) +{ +if (WARN_ON (gc->of_gpio_n_cells <2 )) +return -EINVAL ; + +if (WARN_ON (gpiospec->args_count < gc->of_gpio_n_cells)) +return -EINVAL ; + +if (gpiospec->args[0 ] > gc->ngpio) +return -EINVAL ; + +if (flags) + *flags = gpiospec->args[1 ]; + +return gpiospec->args[0 ]; +} + +static const struct of_device_id sh73a0_gpio_dt_match[]__initdata = { + { .compatible ="renesas,sh_pfc-sh73a0" , }, + {} +}; + +static inline void sh73a0_init_gpio_dt (void ) +{ +struct device_node *of_node; + +if (!of_have_populated_dt ()) +return ; + + of_node =of_find_matching_node (NULL , sh73a0_gpio_dt_match); + sh73a0_pinmux_info.of_node = of_node; + sh73a0_pinmux_info.of_gpio_n_cells =2 ; + sh73a0_pinmux_info.of_xlate = sh73a0_gpio_xlate; +} + +#else + +static inline void sh73a0_init_gpio_dt (void ) {} + +#endif +void sh73a0_pinmux_init (void ) { +sh73a0_init_gpio_dt ();register_pinmux (&sh73a0_pinmux_info); }
Signature · 1 line
1.7.10.4
PATCH 4/7 ARM: shmobile: pfc-sh73a0: Register device tree
Hi Simon,
Quoted 31 lines · On Monday 26 November 2012 09:16:51 Simon Horman wrote:
Register the pfc with
sh73a0_init_gpio_dt()to allow gpios provided by pfc to be accessed by devices which are registered using device tree.The motivation of this is to allow the gpio used for carrier detect but the Micro SD SDHI port of the KZM-9A-GT board to be accessed using device tree. Thus, allowing the SDHI device of the KZM-9A-GT board to be registered using device tree.
Signed-off-by Simon Horman <[email protected]>--- arch/arm/mach-shmobile/pfc-sh73a0.c | 45 ++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+)(quoted diff) +0
-0
b/arch/arm/mach-shmobile/pfc-sh73a0.cindex b442f9d..d1a04c0b 100644arch/arm/mach-shmobile/pfc-sh73a0.c +9
-0@@ -2797,7 +2797,52 @@ static struct pinmux_info sh73a0_pinmux_info = { .gpio_irq_size = ARRAY_SIZE(pinmux_irqs), }; +#ifdef CONFIG_OF_GPIO +static int sh73a0_gpio_xlate (struct gpio_chip *gc, +const struct of_phandle_args *gpiospec, +u32 *flags) +{ +if (WARN_ON (gc->of_gpio_n_cells <2 )) +return -EINVAL ; + +if (WARN_ON (gpiospec->args_count < gc->of_gpio_n_cells))
arch/arm/mach-shmobile/pfc-sh73a0.c static struct pinmux_info sh73a0_pinmux_info = { · line 2818
Quoted 10 lines
arch/arm/mach-shmobile/pfc-sh73a0.c +10
-0+return -EINVAL ; + +if (gpiospec->args[0 ] > gc->ngpio) +return -EINVAL ; + +if (flags) + *flags = gpiospec->args[1 ]; + +return gpiospec->args[0 ]; +}
Is there any reason not to use of_gpio_simple_xlate here ? If there isn't, of_xlate and of_gpio_n_cells default to of_gpio_simple_xlate and 2 respectively when of_xlate isn't specified, so you could omit both.
Quoted 29 lines
arch/arm/mach-shmobile/pfc-sh73a0.c +25
-0+static const struct of_device_id sh73a0_gpio_dt_match[]__initdata = { + { .compatible ="renesas,sh_pfc-sh73a0" , }, + {} +}; + +static inline void sh73a0_init_gpio_dt (void ) +{ +struct device_node *of_node; + +if (!of_have_populated_dt ()) +return ; + + of_node =of_find_matching_node (NULL , sh73a0_gpio_dt_match); + sh73a0_pinmux_info.of_node = of_node; + sh73a0_pinmux_info.of_gpio_n_cells =2 ; + sh73a0_pinmux_info.of_xlate = sh73a0_gpio_xlate; +} + +#else + +static inline void sh73a0_init_gpio_dt (void ) {} + +#endif +void sh73a0_pinmux_init (void ) { +sh73a0_init_gpio_dt ();register_pinmux (&sh73a0_pinmux_info); }
Signature · 3 lines
Regards, Laurent Pinchart
PATCH 4/7 ARM: shmobile: pfc-sh73a0: Register device tree
Quoted 40 lines · Laurent Pinchart
Hi Simon,
Quoted 37 lines · On Monday 26 November 2012 09:16:51 Simon Horman wrote:
Register the pfc with
sh73a0_init_gpio_dt()to allow gpios provided by pfc to be accessed by devices which are registered using device tree.The motivation of this is to allow the gpio used for carrier detect but the Micro SD SDHI port of the KZM-9A-GT board to be accessed using device tree. Thus, allowing the SDHI device of the KZM-9A-GT board to be registered using device tree.
Signed-off-by Simon Horman <[email protected]>--- arch/arm/mach-shmobile/pfc-sh73a0.c | 45 ++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+)(quoted diff) +0
-0
b/arch/arm/mach-shmobile/pfc-sh73a0.cindex b442f9d..d1a04c0b 100644arch/arm/mach-shmobile/pfc-sh73a0.c +15
-0@@ -2797,7 +2797,52 @@ static struct pinmux_info sh73a0_pinmux_info = { .gpio_irq_size = ARRAY_SIZE(pinmux_irqs), }; +#ifdef CONFIG_OF_GPIO +static int sh73a0_gpio_xlate (struct gpio_chip *gc, +const struct of_phandle_args *gpiospec, +u32 *flags) +{ +if (WARN_ON (gc->of_gpio_n_cells <2 )) +return -EINVAL ; + +if (WARN_ON (gpiospec->args_count < gc->of_gpio_n_cells)) +return -EINVAL ; + +if (gpiospec->args[0 ] > gc->ngpio) +return -EINVAL ; + +if (flags)
Quoted 8 lines
arch/arm/mach-shmobile/pfc-sh73a0.c static struct pinmux_info sh73a0_pinmux_info = { · line 2818
Quoted 4 lines
arch/arm/mach-shmobile/pfc-sh73a0.c +4
-0+ *flags = gpiospec->args[1 ]; + +return gpiospec->args[0 ]; +}Is there any reason not to use
of_gpio_simple_xlatehere ? If there isn't,of_xlateandof_gpio_n_cellsdefault toof_gpio_simple_xlateand 2 respectively whenof_xlateisn't specified, so you could omit both.
No reason other than that I wasn't aware of of_gpio_simple_xlate.
PATCH 5/7 ARM: mach-shmobile: sh73a0: Allow initialisation of GIC by DT
In reply to Simon HormanThis allows the GIC interrupt controller of the sh73a0 SoC to be initialised using a flattened device tree blob.
It does not allow the INTC interrupt controller which is also present on the sh73a0 SoC to be enabled via device tree. Nor does it handle sharing of interrupts between the GIC and INTC interrupt controllers.
This limits the usefulness of this code to applications which only wish to access devices which use interrupts that can be handled by the GIC interrupt controller. Other applications should, for now, continue using non-device tree initialisation of the sh72a0 interrupt controllers.
An example dts snippet follows:
gic: interrupt-controller at f0001000 {
compatible = "arm,cortex-a9-gic";
#interrupt-cells = <3>;
#address-cells = <1>;
interrupt-controller;
reg = <0xf0001000 0x1000>,
<0xf0000100 0x100>;
};--- arch/arm/mach-shmobile/include/mach/common.h | 1 + arch/arm/mach-shmobile/intc-sh73a0.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+)
arch/arm/mach-shmobile/include/mach/common.h +1 -0
@@ -49,6 +49,7 @@ extern struct clk sh7372_extal1_clk;extern struct clk sh7372_extal2_clk;extern void sh73a0_init_irq (void ); +extern void sh73a0_init_irq_dt (void );extern void sh73a0_map_io (void );extern void sh73a0_add_early_devices (void );extern void sh73a0_add_standard_devices (void );
arch/arm/mach-shmobile/intc-sh73a0.c +14 -0
@@ -21,6 +21,7 @@#include <linux/interrupt.h> #include <linux/module.h> #include <linux/irq.h> +#include <linux/of_irq.h> #include <linux/io.h> #include <linux/sh_intc.h> #include <mach/intc.h>
@@ -464,3 +465,16 @@ void __init sh73a0_init_irq(void) sh73a0_pint1_cascade.handler = sh73a0_pint1_demux;setup_irq (gic_spi (34 ), &sh73a0_pint1_cascade); } + +#ifdef CONFIG_OF +static const struct of_device_id irq_of_match[]__initconst = { + { .compatible ="arm,cortex-a9-gic" , .data = gic_of_init, }, + { }, +}; + +void __init sh73a0_init_irq_dt (void ) +{ +of_irq_init (irq_of_match); + gic_arch_extn.irq_set_wake = sh73a0_set_wake; +} +#endif
Signature · 1 line
1.7.10.4
PATCH 6/7 ARM: mach-shmobile: sh73a0: Minimal setup using DT
In reply to Simon HormanAllow a minimal setup of the sh73a0 SoC using a flattened device tree.
* Allow configuration of the i2c controllers using a flattened device tree.
* SCI serial controller and CMT clock source, whose drivers do not yet support configuration using a flattened device tree, are still configured using C code in order to allow booting of a board with this SoC.
An example dts snuppet follows:
i2c0: i2c at 0xe6820000 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "renesas,rmobile-iic";
reg = <0xe6820000 0x425>;
interrupt-parent = <&gic>;
interrupts = <0 167 0x4
0 170 0x4>;
};
i2c1: i2c at 0xe6822000 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "renesas,rmobile-iic";
reg = <0xe6822000 0x425>;
interrupt-parent = <&gic>;
interrupts = <0 51 0x4
0 44 0x4>;
touchscreen at 55 {
compatible = "sitronix,st1232";
reg = <0x55>;
interrupt-parent = <&gic>;
interrupts = <0 9 0x4>;
};
};
i2c2: i2c at 0xe6824000 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "renesas,rmobile-iic";
reg = <0xe6824000 0x425>;
interrupt-parent = <&gic>;
interrupts = <0 171 0x4
0 174 0x4>;
};
i2c3: i2c at 0xe6826000 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "renesas,rmobile-iic";
reg = <0xe6826000 0x425>;
interrupt-parent = <&gic>;
interrupts = <0 183 0x4
0 186 0x4>;
};
i2c4: i2c at 0xe6828000 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "renesas,rmobile-iic";
reg = <0xe6828000 0x425>;
interrupt-parent = <&gic>;
interrupts = <0 187 0x4
0 190 0x4>;
};--- arch/arm/mach-shmobile/include/mach/common.h | 2 ++ arch/arm/mach-shmobile/setup-sh73a0.c | 41 ++++++++++++++++++++++---- 2 files changed, 38 insertions(+), 5 deletions(-)
arch/arm/mach-shmobile/include/mach/common.h +2 -0
@@ -52,7 +52,9 @@ extern void sh73a0_init_irq(void);extern void sh73a0_init_irq_dt (void );extern void sh73a0_map_io (void );extern void sh73a0_add_early_devices (void ); +extern void sh73a0_add_early_devices_dt (void );extern void sh73a0_add_standard_devices (void ); +extern void sh73a0_add_standard_devices_dt (void );extern void sh73a0_clock_init (void );extern void sh73a0_pinmux_init (void );extern struct clk sh73a0_extal1_clk;
arch/arm/mach-shmobile/setup-sh73a0.c +36 -5
80 lines not on this page · raw message
Signature · 1 line
1.7.10.4
Magnus Damm
maintainerPATCH 6/7 ARM: mach-shmobile: sh73a0: Minimal setup using DT
Hi Simon,
Thanks for your efforts.
Quoted 58 lines · Simon Horman
Allow a minimal setup of the sh73a0 SoC using a flattened device tree.
* Allow configuration of the i2c controllers using a flattened device tree.
* SCI serial controller and CMT clock source, whose drivers do not yet support configuration using a flattened device tree, are still configured using C code in order to allow booting of a board with this SoC.
An example dts snuppet follows:
i2c0: i2c at 0xe6820000 { #address-cells = <1>; #size-cells = <0>; compatible = "renesas,rmobile-iic"; reg = <0xe6820000 0x425>; interrupt-parent = <&gic>; interrupts = <0 167 0x4 0 170 0x4>; }; i2c1: i2c at 0xe6822000 { #address-cells = <1>; #size-cells = <0>; compatible = "renesas,rmobile-iic"; reg = <0xe6822000 0x425>; interrupt-parent = <&gic>; interrupts = <0 51 0x4 0 44 0x4>; touchscreen at 55 { compatible = "sitronix,st1232"; reg = <0x55>; interrupt-parent = <&gic>; interrupts = <0 9 0x4>; }; }; i2c2: i2c at 0xe6824000 { #address-cells = <1>; #size-cells = <0>; compatible = "renesas,rmobile-iic"; reg = <0xe6824000 0x425>; interrupt-parent = <&gic>; interrupts = <0 171 0x4 0 174 0x4>; }; i2c3: i2c at 0xe6826000 { #address-cells = <1>; #size-cells = <0>; compatible = "renesas,rmobile-iic"; reg = <0xe6826000 0x425>; interrupt-parent = <&gic>; interrupts = <0 183 0x4 0 186 0x4>; }; i2c4: i2c at 0xe6828000 {
Quoted 8 lines
#address-cells = <1>;
#size-cells = <0>;
compatible = "renesas,rmobile-iic";
reg = <0xe6828000 0x425>;
interrupt-parent = <&gic>;
interrupts = <0 187 0x4
0 190 0x4>;
};Uhm, doesn't the above want to go into sh73a0.dtsi?
Quoted 90 lines
Signed-off-by Simon Horman <[email protected]>--- arch/arm/mach-shmobile/include/mach/common.h | 2 ++ arch/arm/mach-shmobile/setup-sh73a0.c | 41 ++++++++++++++++++++++---- 2 files changed, 38 insertions(+), 5 deletions(-)arch/arm/mach-shmobile/include/mach/common.h +2
-0@@ -52,7 +52,9 @@ extern void sh73a0_init_irq(void);extern void sh73a0_init_irq_dt (void );extern void sh73a0_map_io (void );extern void sh73a0_add_early_devices (void ); +extern void sh73a0_add_early_devices_dt (void );extern void sh73a0_add_standard_devices (void ); +extern void sh73a0_add_standard_devices_dt (void );extern void sh73a0_clock_init (void );extern void sh73a0_pinmux_init (void );extern struct clk sh73a0_extal1_clk;arch/arm/mach-shmobile/setup-sh73a0.c +21
-5@@ -23,6 +23,7 @@#include <linux/interrupt.h> #include <linux/irq.h> #include <linux/platform_device.h> +#include <linux/of_platform.h> #include <linux/delay.h> #include <linux/input.h> #include <linux/io.h> @@ -754,7 +755,7 @@ static struct platform_device pmu_device = { .resource = pmu_resources, }; -static struct platform_device *sh73a0_early_devices[]__initdata = { +static struct platform_device *sh73a0_early_devices_dt[]__initdata = { &scif0_device, &scif1_device, &scif2_device,@@ -765,6 +766,9 @@ static struct platform_device *sh73a0_early_devices[] __initdata = { &scif7_device, &scif8_device, &cmt10_device, +}; + +static struct platform_device *sh73a0_early_devices[]__initdata = { &tmu00_device, &tmu01_device, };@@ -782,11 +786,18 @@ static struct platform_device *sh73a0_late_devices[] __initdata = {#define SRCR2 IOMEM(0xe61580b0) -void __init sh73a0_add_standard_devices (void ) +void __init sh73a0_add_standard_devices_dt (void ) {/* Clear software reset bit on SY-DMAC module */ __raw_writel (__raw_readl (SRCR2 ) & ~(1 <<18 ),SRCR2 ); +platform_add_devices (sh73a0_early_devices_dt, +ARRAY_SIZE (sh73a0_early_devices_dt)); +} + +void __init sh73a0_add_standard_devices (void ) +{ +sh73a0_add_standard_devices_dt ();platform_add_devices (sh73a0_early_devices,ARRAY_SIZE (sh73a0_early_devices)); platform_add_devices(sh73a0_late_devices,@@ -803,14 +814,34 @@ static void __init sh73a0_earlytimer_init(void)sh73a0_register_twd (); } -void __init sh73a0_add_early_devices (void ) +static void __init +sh73a0_add_early_devices_start (void ) { -early_platform_add_devices (sh73a0_early_devices, -ARRAY_SIZE (sh73a0_early_devices)); +early_platform_add_devices (sh73a0_early_devices_dt, +ARRAY_SIZE (sh73a0_early_devices_dt)); +} +static void __init +sh73a0_add_early_devices_finish (void ) +{/* setup early console here as well */ shmobile_setup_console ();
arch/arm/mach-shmobile/setup-sh73a0.c static void __init sh73a0_earlytimer_init(void) · line 838
Quoted 10 lines
arch/arm/mach-shmobile/setup-sh73a0.c +6
-0/* override timer setup with soc-specific code */ shmobile_timer.init = sh73a0_earlytimer_init; } + +void __init sh73a0_add_early_devices_dt (void ) +{ +sh73a0_add_early_devices_start (); +sh73a0_add_early_devices_finish (); +}
What's the reason behind using sh73a0_earlytimer_init() for the sh73a0 DT case instead of using shmobile_setup_delay() as the DT code for sh7372 does?
For the DT case on sh7372 we don't really use early platform driver timers at all, instead we use timers as regular platform devices. For this to work as expected we need to setup a worst case udelay calculation via shmobile_setup_delay(). I suggest using the same style for sh73a0.
arch/arm/mach-shmobile/setup-sh73a0.c static void __init sh73a0_earlytimer_init(void) · line 847
Quoted 8 lines
arch/arm/mach-shmobile/setup-sh73a0.c +8
-0+void __init sh73a0_add_early_devices (void ) +{ +sh73a0_add_early_devices_start (); +early_platform_add_devices (sh73a0_early_devices, +ARRAY_SIZE (sh73a0_early_devices)); +sh73a0_add_early_devices_finish (); +} +
Hm, without sh73a0_earlytimer_init() the functions sh73a0_add_early_devices_start() and sh73a0_add_early_devices_finish() look overly complicated compared to the sh7372 DT implementation.
However, I have not checked your code in detail but if your DT code for sh73a0 happens to be shorter than the DT code for sh7372 then please adjust the sh7372 code to be as short and simple as possible.
Thanks,
/ magnus
PATCH 6/7 ARM: mach-shmobile: sh73a0: Minimal setup using DT
Quoted 72 lines · Magnus Damm
Hi Simon,
Thanks for your efforts.
Quoted 58 lines · Simon Horman
Allow a minimal setup of the sh73a0 SoC using a flattened device tree.
* Allow configuration of the i2c controllers using a flattened device tree.
* SCI serial controller and CMT clock source, whose drivers do not yet support configuration using a flattened device tree, are still configured using C code in order to allow booting of a board with this SoC.
An example dts snuppet follows:
i2c0: i2c at 0xe6820000 { #address-cells = <1>; #size-cells = <0>; compatible = "renesas,rmobile-iic"; reg = <0xe6820000 0x425>; interrupt-parent = <&gic>; interrupts = <0 167 0x4 0 170 0x4>; }; i2c1: i2c at 0xe6822000 { #address-cells = <1>; #size-cells = <0>; compatible = "renesas,rmobile-iic"; reg = <0xe6822000 0x425>; interrupt-parent = <&gic>; interrupts = <0 51 0x4 0 44 0x4>; touchscreen at 55 { compatible = "sitronix,st1232"; reg = <0x55>; interrupt-parent = <&gic>; interrupts = <0 9 0x4>; }; }; i2c2: i2c at 0xe6824000 { #address-cells = <1>; #size-cells = <0>; compatible = "renesas,rmobile-iic"; reg = <0xe6824000 0x425>; interrupt-parent = <&gic>; interrupts = <0 171 0x4 0 174 0x4>; }; i2c3: i2c at 0xe6826000 { #address-cells = <1>; #size-cells = <0>; compatible = "renesas,rmobile-iic"; reg = <0xe6826000 0x425>; interrupt-parent = <&gic>; interrupts = <0 183 0x4 0 186 0x4>; }; i2c4: i2c at 0xe6828000 {Quoted 8 lines
#address-cells = <1>; #size-cells = <0>; compatible = "renesas,rmobile-iic"; reg = <0xe6828000 0x425>; interrupt-parent = <&gic>; interrupts = <0 187 0x4 0 190 0x4>; };
Quoted 1 line
Uhm, doesn't the above want to go into
sh73a0.dtsi?
There are two things that I am unsure of:
* What should go into sh73a0.dtsi and what should go into sh73a0-kzm9g-refere3nce.dts.
The i2c seems like it should go into sh73a0.dtsi as it is part of the soc. Likewise the interrupt controllers.
But when it comes to mmcif and sdhi I am less sure. Both of these make use of regulators. Are the regulators part of the board or the SoC? If the are part of the board then it makes it more difficult to put mmcif and sdhi into sh73a0.dtsi as they need to reference the regulators somehow.
* What to do the of_dev_auxdata.
Currently I add this in patch 4 to the board-kzm9g.c. It is used to force the name of the i2c, mmcif and sdhi devices in order to allow their clock lookup to work (though come to think of it it may not be necessary for mmcif and sdhi).
In any case, the location of the of_dev_auxdata might be come a bit tricky if it covers devices in both the board and SoC dts files.
Quoted 91 lines
Quoted 91 lines
Signed-off-by Simon Horman <[email protected]>--- arch/arm/mach-shmobile/include/mach/common.h | 2 ++ arch/arm/mach-shmobile/setup-sh73a0.c | 41 ++++++++++++++++++++++---- 2 files changed, 38 insertions(+), 5 deletions(-)arch/arm/mach-shmobile/include/mach/common.h +2
-0@@ -52,7 +52,9 @@ extern void sh73a0_init_irq(void);extern void sh73a0_init_irq_dt (void );extern void sh73a0_map_io (void );extern void sh73a0_add_early_devices (void ); +extern void sh73a0_add_early_devices_dt (void );extern void sh73a0_add_standard_devices (void ); +extern void sh73a0_add_standard_devices_dt (void );extern void sh73a0_clock_init (void );extern void sh73a0_pinmux_init (void );extern struct clk sh73a0_extal1_clk;arch/arm/mach-shmobile/setup-sh73a0.c +21
-5@@ -23,6 +23,7 @@#include <linux/interrupt.h> #include <linux/irq.h> #include <linux/platform_device.h> +#include <linux/of_platform.h> #include <linux/delay.h> #include <linux/input.h> #include <linux/io.h> @@ -754,7 +755,7 @@ static struct platform_device pmu_device = { .resource = pmu_resources, }; -static struct platform_device *sh73a0_early_devices[]__initdata = { +static struct platform_device *sh73a0_early_devices_dt[]__initdata = { &scif0_device, &scif1_device, &scif2_device,@@ -765,6 +766,9 @@ static struct platform_device *sh73a0_early_devices[] __initdata = { &scif7_device, &scif8_device, &cmt10_device, +}; + +static struct platform_device *sh73a0_early_devices[]__initdata = { &tmu00_device, &tmu01_device, };@@ -782,11 +786,18 @@ static struct platform_device *sh73a0_late_devices[] __initdata = {#define SRCR2 IOMEM(0xe61580b0) -void __init sh73a0_add_standard_devices (void ) +void __init sh73a0_add_standard_devices_dt (void ) {/* Clear software reset bit on SY-DMAC module */ __raw_writel (__raw_readl (SRCR2 ) & ~(1 <<18 ),SRCR2 ); +platform_add_devices (sh73a0_early_devices_dt, +ARRAY_SIZE (sh73a0_early_devices_dt)); +} + +void __init sh73a0_add_standard_devices (void ) +{ +sh73a0_add_standard_devices_dt ();platform_add_devices (sh73a0_early_devices,ARRAY_SIZE (sh73a0_early_devices)); platform_add_devices(sh73a0_late_devices,@@ -803,14 +814,34 @@ static void __init sh73a0_earlytimer_init(void)sh73a0_register_twd (); } -void __init sh73a0_add_early_devices (void ) +static void __init +sh73a0_add_early_devices_start (void ) { -early_platform_add_devices (sh73a0_early_devices, -ARRAY_SIZE (sh73a0_early_devices)); +early_platform_add_devices (sh73a0_early_devices_dt, +ARRAY_SIZE (sh73a0_early_devices_dt)); +} +static void __init +sh73a0_add_early_devices_finish (void ) +{/* setup early console here as well */ shmobile_setup_console ();
Quoted 13 lines
arch/arm/mach-shmobile/setup-sh73a0.c static void __init sh73a0_earlytimer_init(void) · line 838
Quoted 9 lines
arch/arm/mach-shmobile/setup-sh73a0.c +6
-0/* override timer setup with soc-specific code */ shmobile_timer.init = sh73a0_earlytimer_init; } + +void __init sh73a0_add_early_devices_dt (void ) +{ +sh73a0_add_early_devices_start (); +sh73a0_add_early_devices_finish (); +}What's the reason behind using
sh73a0_earlytimer_init()for the sh73a0 DT case instead of usingshmobile_setup_delay()as the DT code for sh7372 does?
The reason is that I wasn't aware of shmobile_setup_delay()
Quoted 5 lines
For the DT case on sh7372 we don't really use early platform driver timers at all, instead we use timers as regular platform devices. For this to work as expected we need to setup a worst case udelay calculation via
shmobile_setup_delay(). I suggest using the same style for sh73a0.
Thanks, I will look into this.
Quoted 4 lines
Quoted 4 lines
arch/arm/mach-shmobile/setup-sh73a0.c +4
-0+void __init sh73a0_add_early_devices (void ) +{ +sh73a0_add_early_devices_start (); + early_platform_add_devices(sh73a0_early_devices,
Quoted 8 lines
arch/arm/mach-shmobile/setup-sh73a0.c static void __init sh73a0_earlytimer_init(void) · line 847
Quoted 4 lines
arch/arm/mach-shmobile/setup-sh73a0.c +4
-0+ ARRAY_SIZE(sh73a0_early_devices)); +sh73a0_add_early_devices_finish (); +} +Hm, without
sh73a0_earlytimer_init()the functionssh73a0_add_early_devices_start()andsh73a0_add_early_devices_finish()look overly complicated compared to the sh7372 DT implementation.
I'm not sure that I understand but I will look at refactoring the code to make use of.
Quoted 3 lines
However, I have not checked your code in detail but if your DT code for sh73a0 happens to be shorter than the DT code for sh7372 then please adjust the sh7372 code to be as short and simple as possible.
Ok, I'll see what I can do.
PATCH 6/7 ARM: mach-shmobile: sh73a0: Minimal setup using DT
Hi Simon,
Quoted 91 lines · On Monday 26 November 2012 13:58:06 Simon Horman wrote:
Quoted 82 lines · Magnus Damm
Quoted 81 lines · Simon Horman
Allow a minimal setup of the sh73a0 SoC using a flattened device tree.
* Allow configuration of the i2c controllers using a flattened device tree.
* SCI serial controller and CMT clock source, whose drivers do not yet support configuration using a flattened device tree, are still configured
using C code in order to allow booting of a board with this SoC.An example dts snuppet follows:
i2c0: i2c at 0xe6820000 { #address-cells = <1>; #size-cells = <0>; compatible = "renesas,rmobile-iic"; reg = <0xe6820000 0x425>; interrupt-parent = <&gic>; interrupts = <0 167 0x4 0 170 0x4>; }; i2c1: i2c at 0xe6822000 { #address-cells = <1>; #size-cells = <0>; compatible = "renesas,rmobile-iic"; reg = <0xe6822000 0x425>; interrupt-parent = <&gic>; interrupts = <0 51 0x4 0 44 0x4>; touchscreen at 55 { compatible = "sitronix,st1232"; reg = <0x55>; interrupt-parent = <&gic>; interrupts = <0 9 0x4>; }; }; i2c2: i2c at 0xe6824000 { #address-cells = <1>; #size-cells = <0>; compatible = "renesas,rmobile-iic"; reg = <0xe6824000 0x425>; interrupt-parent = <&gic>; interrupts = <0 171 0x4 0 174 0x4>; }; i2c3: i2c at 0xe6826000 { #address-cells = <1>; #size-cells = <0>; compatible = "renesas,rmobile-iic"; reg = <0xe6826000 0x425>; interrupt-parent = <&gic>; interrupts = <0 183 0x4 0 186 0x4>; }; i2c4: i2c at 0xe6828000 { #address-cells = <1>; #size-cells = <0>; compatible = "renesas,rmobile-iic"; reg = <0xe6828000 0x425>; interrupt-parent = <&gic>; interrupts = <0 187 0x4Quoted 5 lines
Quoted 3 lines
0 190 0x4>; };Uhm, doesn't the above want to go into
sh73a0.dtsi?There are two things that I am unsure of:
Quoted 8 lines
* What should go into
sh73a0.dtsiand what should go intosh73a0-kzm9g-refere3nce.dts.The i2c seems like it should go into
sh73a0.dtsias it is part of the soc. Likewise the interrupt controllers.But when it comes to mmcif and sdhi I am less sure. Both of these make use of regulators. Are the regulators part of the board or the SoC?
It depends on the regulators. In theory you could have on-SoC regulators that would thus be part of the SoC. In practice I'm not sure how often that happens.
Most of the regulators are provided by the PMIC, so we can create PMIC- specific .dtsi files that would be included by boards. See twl4030.dtsi for an example. Other board-specific regulators, including fixed regulators, should be provided by the board.
Quoted 3 lines
If the are part of the board then it makes it more difficult to put mmcif and sdhi into
sh73a0.dtsias they need to reference the regulators somehow.
I think you can split a node across several files. You could have
mmcif: mmcif at 0x10010000 {
compatible = "renesas,sh-mmcif";
reg = <0xe6bd0000 0x100>;
interrupt-parent = <&gic>;
interrupts = <0 140 0x4
0 141 0x4>;
reg-io-width = <4>;
};in the SoC .dtsi, and
&mmcif {
vmmc-supply = <&fixedregulator1v8>;
vqmmc-supply = <&fixedregulator1v8>;
};in the board .dts.
Quoted 6 lines
* What to do the
of_dev_auxdata.Currently I add this in patch 4 to the
board-kzm9g.c. It is used to force the name of the i2c, mmcif and sdhi devices in order to allow their clock lookup to work (though come to think of it it may not be necessary for mmcif and sdhi).
Shouldn't clocks be specified as an attribute in DT nodes that reference the clock node ?
Quoted 2 lines
In any case, the location of the
of_dev_auxdatamight be come a bit tricky if it covers devices in both the board and SoC dts files.
Signature · 3 lines
Regards, Laurent Pinchart
PATCH 6/7 ARM: mach-shmobile: sh73a0: Minimal setup using DT
Quoted 127 lines · Laurent Pinchart
Hi Simon,
Quoted 91 lines · On Monday 26 November 2012 13:58:06 Simon Horman wrote:
Quoted 82 lines · Magnus Damm
Quoted 81 lines · Simon Horman
Allow a minimal setup of the sh73a0 SoC using a flattened device tree.
* Allow configuration of the i2c controllers using a flattened device tree.
* SCI serial controller and CMT clock source, whose drivers do not yet support configuration using a flattened device tree, are still configured
using C code in order to allow booting of a board with this SoC.An example dts snuppet follows:
i2c0: i2c at 0xe6820000 { #address-cells = <1>; #size-cells = <0>; compatible = "renesas,rmobile-iic"; reg = <0xe6820000 0x425>; interrupt-parent = <&gic>; interrupts = <0 167 0x4 0 170 0x4>; }; i2c1: i2c at 0xe6822000 { #address-cells = <1>; #size-cells = <0>; compatible = "renesas,rmobile-iic"; reg = <0xe6822000 0x425>; interrupt-parent = <&gic>; interrupts = <0 51 0x4 0 44 0x4>; touchscreen at 55 { compatible = "sitronix,st1232"; reg = <0x55>; interrupt-parent = <&gic>; interrupts = <0 9 0x4>; }; }; i2c2: i2c at 0xe6824000 { #address-cells = <1>; #size-cells = <0>; compatible = "renesas,rmobile-iic"; reg = <0xe6824000 0x425>; interrupt-parent = <&gic>; interrupts = <0 171 0x4 0 174 0x4>; }; i2c3: i2c at 0xe6826000 { #address-cells = <1>; #size-cells = <0>; compatible = "renesas,rmobile-iic"; reg = <0xe6826000 0x425>; interrupt-parent = <&gic>; interrupts = <0 183 0x4 0 186 0x4>; }; i2c4: i2c at 0xe6828000 { #address-cells = <1>; #size-cells = <0>; compatible = "renesas,rmobile-iic"; reg = <0xe6828000 0x425>; interrupt-parent = <&gic>; interrupts = <0 187 0x4Quoted 5 lines
Quoted 3 lines
0 190 0x4>; };Uhm, doesn't the above want to go into
sh73a0.dtsi?There are two things that I am unsure of:
Quoted 8 lines
* What should go into
sh73a0.dtsiand what should go intosh73a0-kzm9g-refere3nce.dts.The i2c seems like it should go into
sh73a0.dtsias it is part of the soc. Likewise the interrupt controllers.But when it comes to mmcif and sdhi I am less sure. Both of these make use of regulators. Are the regulators part of the board or the SoC?
It depends on the regulators. In theory you could have on-SoC regulators that would thus be part of the SoC. In practice I'm not sure how often that happens.
Most of the regulators are provided by the PMIC, so we can create PMIC- specific .dtsi files that would be included by boards. See
twl4030.dtsifor an example. Other board-specific regulators, including fixed regulators, should be provided by the board.Quoted 3 lines
If the are part of the board then it makes it more difficult to put mmcif and sdhi into
sh73a0.dtsias they need to reference the regulators somehow.I think you can split a node across several files. You could have
mmcif: mmcif at 0x10010000 { compatible = "renesas,sh-mmcif"; reg = <0xe6bd0000 0x100>; interrupt-parent = <&gic>; interrupts = <0 140 0x4 0 141 0x4>; reg-io-width = <4>; };
Quoted 8 lines
in the SoC .dtsi, and
&mmcif { vmmc-supply = <&fixedregulator1v8>; vqmmc-supply = <&fixedregulator1v8>; };in the board .dts.
Thanks, I discovered that after writing my previous email. I think it is an approach well suited to the needs of kzm9g and I intend to use it.
Quoted 9 lines
Quoted 6 lines
* What to do the
of_dev_auxdata.Currently I add this in patch 4 to the
board-kzm9g.c. It is used to force the name of the i2c, mmcif and sdhi devices in order to allow their clock lookup to work (though come to think of it it may not be necessary for mmcif and sdhi).Shouldn't clocks be specified as an attribute in DT nodes that reference the clock node ?
Oh, I will look into that.
Magnus's suggestion was to register the names that DT will use in the clock .c file.
In either case I think we can get rid of auxdata.
Quoted 2 lines
Quoted 2 lines
In any case, the location of the
of_dev_auxdatamight be come a bit tricky if it covers devices in both the board and SoC dts files.
PATCH 7/7 ARM: mach-shmobile: kzm9g: Reference DT implementation
In reply to Simon HormanProvide alternate board code for the kzm9g to demonstrate how DT may be used given the current state of driver device tree support. This is intended to act as a reference for mach-shmobile developers.
Some notes:
* Brings up the GIC interrupt handler using device tree
* Brings up the following devices using device tree
- ST1232 (Touchscreen)
- MMCIF (MMC)
- SDHI (MMC)
* Does not bring up the INTC interrupt controller at all, thus external devices may not be used
* Uses existing C code and not device tree to initialise the following, which are needed for a working board:
- SCIF (Serial)
- CMT (Clock)
- PFC (GPIO)
To use this alternate board code instead of the normal board code, CONFIG_MACH_KZM9G_REFERENCE should be selected in the kernel config. And the sh73a0-kzm9g-reference.dtb flattened device tree blob should be used.
--- arch/arm/boot/dts/Makefile | 3 +- arch/arm/boot/dts/sh73a0-kzm9g-reference.dts | 153 ++++++++++++++++++++++++ arch/arm/mach-shmobile/Kconfig | 10 ++ arch/arm/mach-shmobile/Makefile | 8 +- arch/arm/mach-shmobile/board-kzm9g-reference.c | 142 ++++++++++++++++++++++ 5 files changed, 314 insertions(+), 2 deletions(-) create mode 100644 arch/arm/boot/dts/sh73a0-kzm9g-reference.dts create mode 100644 arch/arm/mach-shmobile/board-kzm9g-reference.c
arch/arm/boot/dts/Makefile +2 -1
@@ -75,7 +75,8 @@ dtb-$(CONFIG_ARCH_PRIMA2) += prima2-evb.dtb dtb-$(CONFIG_ARCH_U8500) += snowball.dtb dtb-$(CONFIG_ARCH_SHMOBILE) += emev2-kzm9d.dtb \ r8a7740-armadillo800eva.dtb \ - sh73a0-kzm9g.dtb + sh73a0-kzm9g.dtb \ + sh73a0-kzm9g-reference.dtb dtb-$(CONFIG_ARCH_SPEAR13XX) += spear1310-evb.dtb \ spear1340-evb.dtb dtb-$(CONFIG_ARCH_SPEAR3XX)+= spear300-evb.dtb \
arch/arm/boot/dts/sh73a0-kzm9g-reference.dts new file +153 -0
153 lines not on this page · raw message
arch/arm/mach-shmobile/Kconfig +10 -0
@@ -136,6 +136,16 @@ config MACH_KZM9G select SND_SOC_AK4642 if SND_SIMPLE_CARD select USE_OF +config MACH_KZM9G_REFERENCE + bool "KZM-A9-GT board - Reference Device Tree Implementation" + depends on MACH_KZM9G + ---help--- + Use reference implementation of KZM-A9-GT board support + which makes as greater use of device tree at the expense + of not supporting a number of devices. + + This is intended to aid developers + comment "SH-Mobile System Configuration" config CPU_HAS_INTEVT
arch/arm/mach-shmobile/Makefile +7 -1
@@ -55,7 +55,13 @@ obj-$(CONFIG_MACH_BONITO) += board-bonito.o obj-$(CONFIG_MACH_MARZEN) += board-marzen.o obj-$(CONFIG_MACH_ARMADILLO800EVA) += board-armadillo800eva.o obj-$(CONFIG_MACH_KZM9D) += board-kzm9d.o -obj-$(CONFIG_MACH_KZM9G) += board-kzm9g.o +ifeq ($(CONFIG_MACH_KZM9G),y) +ifeq ($(CONFIG_MACH_KZM9G_REFERENCE),y) +obj-y += board-kzm9g-reference.o +else +obj-y += board-kzm9g.o +endif +endif # Framework support obj-$(CONFIG_SMP) += $(smp-y)
arch/arm/mach-shmobile/board-kzm9g-reference.c new file +142 -0
142 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH 7/7 ARM: mach-shmobile: kzm9g: Reference DT implementation
Hello Simon-san,
Quoted 88 lines · Simon Horman
Provide alternate board code for the kzm9g to demonstrate how DT may be used given the current state of driver device tree support. This is intended to act as a reference for mach-shmobile developers.
Some notes:
* Brings up the GIC interrupt handler using device tree
* Brings up the following devices using device tree
- ST1232 (Touchscreen)
- MMCIF (MMC)
- SDHI (MMC)
* Does not bring up the INTC interrupt controller at all, thus external devices may not be used
* Uses existing C code and not device tree to initialise the following, which are needed for a working board:
- SCIF (Serial)
- CMT (Clock)
- PFC (GPIO)To use this alternate board code instead of the normal board code,
CONFIG_MACH_KZM9G_REFERENCEshould be selected in the kernel config. And the sh73a0-kzm9g-reference.dtb flattened device tree blob should be used.Signed-off-by Simon Horman <[email protected]>--- arch/arm/boot/dts/Makefile | 3 +- arch/arm/boot/dts/sh73a0-kzm9g-reference.dts | 153 ++++++++++++++++++++++++ arch/arm/mach-shmobile/Kconfig | 10 ++ arch/arm/mach-shmobile/Makefile | 8 +- arch/arm/mach-shmobile/board-kzm9g-reference.c | 142 ++++++++++++++++++++++ 5 files changed, 314 insertions(+), 2 deletions(-)create mode 100644
arch/arm/boot/dts/sh73a0-kzm9g-reference.dtscreate mode 100644arch/arm/mach-shmobile/board-kzm9g-reference.carch/arm/boot/dts/Makefile +2
-1@@ -75,7 +75,8 @@ dtb-$(CONFIG_ARCH_PRIMA2) += prima2-evb.dtb dtb-$(CONFIG_ARCH_U8500) += snowball.dtb dtb-$(CONFIG_ARCH_SHMOBILE) += emev2-kzm9d.dtb \ r8a7740-armadillo800eva.dtb \ - sh73a0-kzm9g.dtb + sh73a0-kzm9g.dtb \ + sh73a0-kzm9g-reference.dtb dtb-$(CONFIG_ARCH_SPEAR13XX) += spear1310-evb.dtb \ spear1340-evb.dtb dtb-$(CONFIG_ARCH_SPEAR3XX)+= spear300-evb.dtb \arch/arm/boot/dts/sh73a0-kzm9g-reference.dts new file +33
-0@@ -0,0 +1,153 @@ +/* + * Device Tree Source for the KZM-A9-GT board + * + * Copyright (C) 2012 Horms Solutions Ltd. + * + * Based on sh73a0-kzm9g.dts + * Copyright (C) 2012 Renesas Solutions Corp. + * + * This file is licensed under the terms of the GNU General Public License + * version 2. This program is licensed "as is" without any warranty of any + * kind, whether express or implied. + */ + +/dts-v1/; +/include/ "skeleton.dtsi" + +/ { + model = "KZM-A9-GT"; + compatible = "renesas,kzm9g-reference", "renesas,sh73a0"; + + memory { + device_type = "memory"; + reg = <0x41000000 0x1e800000>; + }; + + gic: interrupt-controller at f0001000 { + compatible = "arm,cortex-a9-gic"; + #interrupt-cells = <3>; + #address-cells = <1>; + interrupt-controller; + reg = <0xf0001000 0x1000>, + <0xf0000100 0x100>; + };
arch/arm/boot/dts/sh73a0-kzm9g-reference.dts line 43
Quoted 10 lines
arch/arm/boot/dts/sh73a0-kzm9g-reference.dts new file +10
-0+ + i2c0: i2c at 0xe6820000 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "renesas,rmobile-iic"; + reg = <0xe6820000 0x425>; + interrupt-parent = <&gic>; + interrupts = <0 167 0x4 + 0 170 0x4>; + };
I reported /dev/i2c-0 seems not working. I found the reason. About i2c0 interrupt, it should be:
interrupts = <0 167 0x4
0 168 0x4 0 169 0x4
0 170 0x4>;
The same as i2c1 - ic24. There are 4 interrupts each.
arch/arm/boot/dts/sh73a0-kzm9g-reference.dts line 52
Quoted 9 lines
arch/arm/boot/dts/sh73a0-kzm9g-reference.dts new file +9
-0+ + i2c1: i2c at 0xe6822000 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "renesas,rmobile-iic"; + reg = <0xe6822000 0x425>; + interrupt-parent = <&gic>; + interrupts = <0 51 0x4 + 0 44 0x4>;
interrupts = <0 51 0x4 0 52 0x4 0 53 0x4 0 54 0x4>;
Quoted 6 lines
arch/arm/boot/dts/sh73a0-kzm9g-reference.dts new file +6
-0+ + touchscreen at 55 { + compatible = "sitronix,st1232"; + reg = <0x55>; + interrupt-parent = <&gic>; + interrupts = <0 9 0x4>;
arch/arm/boot/dts/sh73a0-kzm9g-reference.dts line 68
Quoted 10 lines
arch/arm/boot/dts/sh73a0-kzm9g-reference.dts new file +10
-0+ }; + }; + + i2c2: i2c at 0xe6824000 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "renesas,rmobile-iic"; + reg = <0xe6824000 0x425>; + interrupt-parent = <&gic>; + interrupts = <0 171 0x4
0 172 0x4 0 173 0x4
arch/arm/boot/dts/sh73a0-kzm9g-reference.dts line 78
Quoted 10 lines
arch/arm/boot/dts/sh73a0-kzm9g-reference.dts new file +10
-0+ 0 174 0x4>; + }; + + i2c3: i2c at 0xe6826000 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "renesas,rmobile-iic"; + reg = <0xe6826000 0x425>; + interrupt-parent = <&gic>; + interrupts = <0 183 0x4
0 184 0x4 0 185 0x4
arch/arm/boot/dts/sh73a0-kzm9g-reference.dts line 88
Quoted 10 lines
arch/arm/boot/dts/sh73a0-kzm9g-reference.dts new file +10
-0+ 0 186 0x4>; + }; + + i2c4: i2c at 0xe6828000 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "renesas,rmobile-iic"; + reg = <0xe6828000 0x425>; + interrupt-parent = <&gic>; + interrupts = <0 187 0x4
0 188 0x4 0 189 0x4
Quoted 2 lines
arch/arm/boot/dts/sh73a0-kzm9g-reference.dts new file +2
-0+ 0 190 0x4>; + };
PATCH 7/7 ARM: mach-shmobile: kzm9g: Reference DT implementation
Quoted 105 lines · Tetsuyuki Kobayashi
Hello Simon-san,
Quoted 88 lines · Simon Horman
Provide alternate board code for the kzm9g to demonstrate how DT may be used given the current state of driver device tree support. This is intended to act as a reference for mach-shmobile developers.
Some notes:
* Brings up the GIC interrupt handler using device tree
* Brings up the following devices using device tree
- ST1232 (Touchscreen)
- MMCIF (MMC)
- SDHI (MMC)
* Does not bring up the INTC interrupt controller at all, thus external devices may not be used
* Uses existing C code and not device tree to initialise the following, which are needed for a working board:
- SCIF (Serial)
- CMT (Clock)
- PFC (GPIO)To use this alternate board code instead of the normal board code,
CONFIG_MACH_KZM9G_REFERENCEshould be selected in the kernel config. And the sh73a0-kzm9g-reference.dtb flattened device tree blob should be used.Signed-off-by Simon Horman <[email protected]>--- arch/arm/boot/dts/Makefile | 3 +- arch/arm/boot/dts/sh73a0-kzm9g-reference.dts | 153 ++++++++++++++++++++++++ arch/arm/mach-shmobile/Kconfig | 10 ++ arch/arm/mach-shmobile/Makefile | 8 +- arch/arm/mach-shmobile/board-kzm9g-reference.c | 142 ++++++++++++++++++++++ 5 files changed, 314 insertions(+), 2 deletions(-)create mode 100644
arch/arm/boot/dts/sh73a0-kzm9g-reference.dtscreate mode 100644arch/arm/mach-shmobile/board-kzm9g-reference.carch/arm/boot/dts/Makefile +2
-1@@ -75,7 +75,8 @@ dtb-$(CONFIG_ARCH_PRIMA2) += prima2-evb.dtb dtb-$(CONFIG_ARCH_U8500) += snowball.dtb dtb-$(CONFIG_ARCH_SHMOBILE) += emev2-kzm9d.dtb \ r8a7740-armadillo800eva.dtb \ - sh73a0-kzm9g.dtb + sh73a0-kzm9g.dtb \ + sh73a0-kzm9g-reference.dtb dtb-$(CONFIG_ARCH_SPEAR13XX) += spear1310-evb.dtb \ spear1340-evb.dtb dtb-$(CONFIG_ARCH_SPEAR3XX)+= spear300-evb.dtb \arch/arm/boot/dts/sh73a0-kzm9g-reference.dts new file +33
-0@@ -0,0 +1,153 @@ +/* + * Device Tree Source for the KZM-A9-GT board + * + * Copyright (C) 2012 Horms Solutions Ltd. + * + * Based on sh73a0-kzm9g.dts + * Copyright (C) 2012 Renesas Solutions Corp. + * + * This file is licensed under the terms of the GNU General Public License + * version 2. This program is licensed "as is" without any warranty of any + * kind, whether express or implied. + */ + +/dts-v1/; +/include/ "skeleton.dtsi" + +/ { + model = "KZM-A9-GT"; + compatible = "renesas,kzm9g-reference", "renesas,sh73a0"; + + memory { + device_type = "memory"; + reg = <0x41000000 0x1e800000>; + }; + + gic: interrupt-controller at f0001000 { + compatible = "arm,cortex-a9-gic"; + #interrupt-cells = <3>; + #address-cells = <1>; + interrupt-controller; + reg = <0xf0001000 0x1000>, + <0xf0000100 0x100>; + };arch/arm/boot/dts/sh73a0-kzm9g-reference.dts line 43
Quoted 10 lines
arch/arm/boot/dts/sh73a0-kzm9g-reference.dts new file +10
-0+ + i2c0: i2c at 0xe6820000 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "renesas,rmobile-iic"; + reg = <0xe6820000 0x425>; + interrupt-parent = <&gic>; + interrupts = <0 167 0x4 + 0 170 0x4>; + };I reported
/dev/i2c-0seems not working. I found the reason. About i2c0 interrupt, it should be:
Quoted 6 lines
interrupts = <0 167
0x40 168 0x4 0 169 0x40 170
0x4>;The same as i2c1 - ic24. There are 4 interrupts each.
Thanks, sorry for missing that the first time around.
cover ARM: mach-shmobile: kzm9g: Reference DT implementation
In reply to Simon HormanHello Simon-san,
Quoted 4 lines · Simon Horman
this series is a first pass at providing a refernce DT implementation for the kzm9g baord which is intended to act as a guide for mach-shmobile developers.
I tried this patch series on v3.7-rc7 with CONFIG_MACH_KZM9G_REFERENCE=y. It boot up correctly with rootfs on SD card. It works good for following devices
- serial port on /dev/ttySC4
- SD card on /dev/mmcblk0
- micro SD card on /dev/mmcblk1
- eMMC on /dev/mmcblk2
I found /dev/i2c-0 seems not to work correctly. "i2cdump" command fails like this.
# i2cdump 0 0x40
No size specified (using byte-data access)
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-0, address 0x40, mode byte
Continue? [Y/n]
0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
00: [ 180.171875] i2c-sh_mobile i2c-sh_mobile.0: Transfer request timed out
[ 180.187500] i2c-sh_mobile i2c-sh_mobile.0: Polling timed out
XX [ 185.187500] i2c-sh_mobile i2c-sh_mobile.0: Transfer request timed out
[ 185.203125] i2c-sh_mobile i2c-sh_mobile.0: Polling timed out
XX ^C[ 190.203125] i2c-sh_mobile i2c-sh_mobile.0: Transfer request timed out
[ 190.218750] i2c-sh_mobile i2c-sh_mobile.0: Polling timed outI quited the command by ^C.
When I try the same on v3.7-rc7 without CONFIG_MACH_KZM9G_REFERENCE=y "i2cdump" command does not time out and shows some data.
cover ARM: mach-shmobile: kzm9g: Reference DT implementation
Quoted 31 lines · Tetsuyuki Kobayashi
Hello Simon-san,
Quoted 4 lines · Simon Horman
this series is a first pass at providing a refernce DT implementation for the kzm9g baord which is intended to act as a guide for mach-shmobile developers.
I tried this patch series on v3.7-rc7 with
CONFIG_MACH_KZM9G_REFERENCE=y. It boot up correctly with rootfs on SD card. It works good for following devices
- serial port on/dev/ttySC4
- SD card on/dev/mmcblk0
- micro SD card on/dev/mmcblk1
- eMMC on/dev/mmcblk2I found
/dev/i2c-0seems not to work correctly. "i2cdump" command fails like this.# i2cdump 0 0x40 No size specified (using byte-data access) WARNING! This program can confuse your I2C bus, cause data loss and worse! I will probe file /dev/i2c-0, address 0x40, mode byte Continue? [Y/n] 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef 00: [ 180.171875] i2c-sh_mobile i2c-sh_mobile.0: Transfer request timed out [ 180.187500] i2c-sh_mobile i2c-sh_mobile.0: Polling timed out XX [ 185.187500] i2c-sh_mobile i2c-sh_mobile.0: Transfer request timed out [ 185.203125] i2c-sh_mobile i2c-sh_mobile.0: Polling timed out XX ^C[ 190.203125] i2c-sh_mobile i2c-sh_mobile.0: Transfer request timed out [ 190.218750] i2c-sh_mobile i2c-sh_mobile.0: Polling timed out
Quoted 3 lines
I quited the command by ^C.
When I try the same on v3.7-rc7 withoutCONFIG_MACH_KZM9G_REFERENCE=y"i2cdump" command does not time out and shows some data.
Thanks. I found that I had missed two interrupts for each i2c controller. I will fix this in the next revision.