linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/7] ARM: mach-shmobile: kzm9g: Reference DT implementation
@ 2012-11-26  0:16 Simon Horman
  2012-11-26  0:16 ` [PATCH 1/7] mmc: sh-mmcif: provide default allowed voltage Simon Horman
                   ` (7 more replies)
  0 siblings, 8 replies; 25+ messages in thread
From: Simon Horman @ 2012-11-26  0:16 UTC (permalink / raw)
  To: linux-arm-kernel

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

-- 
1.7.10.4

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

* [PATCH 1/7] mmc: sh-mmcif: provide default allowed voltage
  2012-11-26  0:16 [PATCH 0/7] ARM: mach-shmobile: kzm9g: Reference DT implementation Simon Horman
@ 2012-11-26  0:16 ` Simon Horman
  2012-11-26  4:06   ` Magnus Damm
  2012-11-26  0:16 ` [PATCH 2/7] mmc: sdhi: enchance OF support for flags and cd-gpios Simon Horman
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 25+ messages in thread
From: Simon Horman @ 2012-11-26  0:16 UTC (permalink / raw)
  To: linux-arm-kernel

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

Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Simon Horman <horms@verge.net.au>
---
 drivers/mmc/host/sh_mmcif.c |    7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c
index 11d2bc3..88d6866 100644
--- a/drivers/mmc/host/sh_mmcif.c
+++ b/drivers/mmc/host/sh_mmcif.c
@@ -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");
 }
 
-- 
1.7.10.4

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

* [PATCH 2/7] mmc: sdhi: enchance OF support for flags and cd-gpios
  2012-11-26  0:16 [PATCH 0/7] ARM: mach-shmobile: kzm9g: Reference DT implementation Simon Horman
  2012-11-26  0:16 ` [PATCH 1/7] mmc: sh-mmcif: provide default allowed voltage Simon Horman
@ 2012-11-26  0:16 ` Simon Horman
  2012-11-26 10:16   ` Guennadi Liakhovetski
  2012-11-26 10:18   ` Guennadi Liakhovetski
  2012-11-26  0:16 ` [PATCH 3/7] sh: pfc: Allow device tree registration Simon Horman
                   ` (5 subsequent siblings)
  7 siblings, 2 replies; 25+ messages in thread
From: Simon Horman @ 2012-11-26  0:16 UTC (permalink / raw)
  To: linux-arm-kernel

Enhance 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>;
	};

Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Simon Horman <horms@verge.net.au>
---
 drivers/mmc/host/sh_mobile_sdhi.c |   76 +++++++++++++++++++++++++++++++------
 1 file changed, 65 insertions(+), 11 deletions(-)

diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c
index 0bdc146..8c7e658 100644
--- a/drivers/mmc/host/sh_mobile_sdhi.c
+++ b/drivers/mmc/host/sh_mobile_sdhi.c
@@ -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
-- 
1.7.10.4

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

* [PATCH 3/7] sh: pfc: Allow device tree registration
  2012-11-26  0:16 [PATCH 0/7] ARM: mach-shmobile: kzm9g: Reference DT implementation Simon Horman
  2012-11-26  0:16 ` [PATCH 1/7] mmc: sh-mmcif: provide default allowed voltage Simon Horman
  2012-11-26  0:16 ` [PATCH 2/7] mmc: sdhi: enchance OF support for flags and cd-gpios Simon Horman
@ 2012-11-26  0:16 ` Simon Horman
  2012-11-26 12:54   ` Laurent Pinchart
  2012-11-27  0:07   ` Laurent Pinchart
  2012-11-26  0:16 ` [PATCH 4/7] ARM: shmobile: pfc-sh73a0: Register device tree Simon Horman
                   ` (4 subsequent siblings)
  7 siblings, 2 replies; 25+ messages in thread
From: Simon Horman @ 2012-11-26  0:16 UTC (permalink / raw)
  To: linux-arm-kernel

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.

Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
---
 drivers/sh/pfc/gpio.c  |   15 +++++++++++++++
 include/linux/sh_pfc.h |    7 +++++++
 2 files changed, 22 insertions(+)

diff --git a/drivers/sh/pfc/gpio.c b/drivers/sh/pfc/gpio.c
index 038fa07..322b927 100644
--- a/drivers/sh/pfc/gpio.c
+++ b/drivers/sh/pfc/gpio.c
@@ -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);
 
diff --git a/include/linux/sh_pfc.h b/include/linux/sh_pfc.h
index c19a092..9963370 100644
--- a/include/linux/sh_pfc.h
+++ b/include/linux/sh_pfc.h
@@ -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 */
-- 
1.7.10.4

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

* [PATCH 4/7] ARM: shmobile: pfc-sh73a0: Register device tree
  2012-11-26  0:16 [PATCH 0/7] ARM: mach-shmobile: kzm9g: Reference DT implementation Simon Horman
                   ` (2 preceding siblings ...)
  2012-11-26  0:16 ` [PATCH 3/7] sh: pfc: Allow device tree registration Simon Horman
@ 2012-11-26  0:16 ` Simon Horman
  2012-11-26 14:06   ` Laurent Pinchart
  2012-11-26  0:16 ` [PATCH 5/7] ARM: mach-shmobile: sh73a0: Allow initialisation of GIC by DT Simon Horman
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 25+ messages in thread
From: Simon Horman @ 2012-11-26  0:16 UTC (permalink / raw)
  To: linux-arm-kernel

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 <horms@verge.net.au>
---
 arch/arm/mach-shmobile/pfc-sh73a0.c |   45 +++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/arch/arm/mach-shmobile/pfc-sh73a0.c b/arch/arm/mach-shmobile/pfc-sh73a0.c
index b442f9d..d1a04c0b 100644
--- a/arch/arm/mach-shmobile/pfc-sh73a0.c
+++ b/arch/arm/mach-shmobile/pfc-sh73a0.c
@@ -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);
 }
-- 
1.7.10.4

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

* [PATCH 5/7] ARM: mach-shmobile: sh73a0: Allow initialisation of GIC by DT
  2012-11-26  0:16 [PATCH 0/7] ARM: mach-shmobile: kzm9g: Reference DT implementation Simon Horman
                   ` (3 preceding siblings ...)
  2012-11-26  0:16 ` [PATCH 4/7] ARM: shmobile: pfc-sh73a0: Register device tree Simon Horman
@ 2012-11-26  0:16 ` Simon Horman
  2012-11-26  0:16 ` [PATCH 6/7] ARM: mach-shmobile: sh73a0: Minimal setup using DT Simon Horman
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 25+ messages in thread
From: Simon Horman @ 2012-11-26  0:16 UTC (permalink / raw)
  To: linux-arm-kernel

This 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>;
	};

Signed-off-by: Simon Horman <horms@verge.net.au>
---
 arch/arm/mach-shmobile/include/mach/common.h |    1 +
 arch/arm/mach-shmobile/intc-sh73a0.c         |   14 ++++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/arch/arm/mach-shmobile/include/mach/common.h b/arch/arm/mach-shmobile/include/mach/common.h
index d47e215..b50447e 100644
--- a/arch/arm/mach-shmobile/include/mach/common.h
+++ b/arch/arm/mach-shmobile/include/mach/common.h
@@ -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);
diff --git a/arch/arm/mach-shmobile/intc-sh73a0.c b/arch/arm/mach-shmobile/intc-sh73a0.c
index f0c5e51..e492350 100644
--- a/arch/arm/mach-shmobile/intc-sh73a0.c
+++ b/arch/arm/mach-shmobile/intc-sh73a0.c
@@ -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
-- 
1.7.10.4

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

* [PATCH 6/7] ARM: mach-shmobile: sh73a0: Minimal setup using DT
  2012-11-26  0:16 [PATCH 0/7] ARM: mach-shmobile: kzm9g: Reference DT implementation Simon Horman
                   ` (4 preceding siblings ...)
  2012-11-26  0:16 ` [PATCH 5/7] ARM: mach-shmobile: sh73a0: Allow initialisation of GIC by DT Simon Horman
@ 2012-11-26  0:16 ` Simon Horman
  2012-11-26  4:23   ` Magnus Damm
  2012-11-26  0:16 ` [PATCH 7/7] ARM: mach-shmobile: kzm9g: Reference DT implementation Simon Horman
  2012-11-26  6:10 ` [PATCH 0/7] " Tetsuyuki Kobayashi
  7 siblings, 1 reply; 25+ messages in thread
From: Simon Horman @ 2012-11-26  0:16 UTC (permalink / raw)
  To: linux-arm-kernel

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 0x4
			      0 190 0x4>;
	};

Signed-off-by: Simon Horman <horms@verge.net.au>
---
 arch/arm/mach-shmobile/include/mach/common.h |    2 ++
 arch/arm/mach-shmobile/setup-sh73a0.c        |   41 ++++++++++++++++++++++----
 2 files changed, 38 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-shmobile/include/mach/common.h b/arch/arm/mach-shmobile/include/mach/common.h
index b50447e..06b905e 100644
--- a/arch/arm/mach-shmobile/include/mach/common.h
+++ b/arch/arm/mach-shmobile/include/mach/common.h
@@ -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;
diff --git a/arch/arm/mach-shmobile/setup-sh73a0.c b/arch/arm/mach-shmobile/setup-sh73a0.c
index db99a4a..9096caa 100644
--- a/arch/arm/mach-shmobile/setup-sh73a0.c
+++ b/arch/arm/mach-shmobile/setup-sh73a0.c
@@ -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();
 
 	/* 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();
+}
+
+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();
+}
+
-- 
1.7.10.4

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

* [PATCH 7/7] ARM: mach-shmobile: kzm9g: Reference DT implementation
  2012-11-26  0:16 [PATCH 0/7] ARM: mach-shmobile: kzm9g: Reference DT implementation Simon Horman
                   ` (5 preceding siblings ...)
  2012-11-26  0:16 ` [PATCH 6/7] ARM: mach-shmobile: sh73a0: Minimal setup using DT Simon Horman
@ 2012-11-26  0:16 ` Simon Horman
  2012-11-26  8:34   ` Tetsuyuki Kobayashi
  2012-11-26  6:10 ` [PATCH 0/7] " Tetsuyuki Kobayashi
  7 siblings, 1 reply; 25+ messages in thread
From: Simon Horman @ 2012-11-26  0:16 UTC (permalink / raw)
  To: linux-arm-kernel

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_REFERENCE should be selected in the kernel config.
And the sh73a0-kzm9g-reference.dtb flattened device tree blob should be used.

Signed-off-by: Simon Horman <horms@verge.net.au>
---
 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

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index c1ce813..b6c4fa2 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -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 \
diff --git a/arch/arm/boot/dts/sh73a0-kzm9g-reference.dts b/arch/arm/boot/dts/sh73a0-kzm9g-reference.dts
new file mode 100644
index 0000000..978892a
--- /dev/null
+++ b/arch/arm/boot/dts/sh73a0-kzm9g-reference.dts
@@ -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>;
+	};
+
+	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>;
+	};
+
+	gpio: gpio at 0 {
+		compatible = "renesas,sh_pfc-sh73a0";
+		gpio-controller;
+		#gpio-cells = <2>;
+	};
+
+	fixedregulator1v8: fixedregulator at 0 {
+		compatible = "regulator-fixed";
+		regulator-name = "fixed-1.8V";
+		regulator-min-microvolt = <1800000>;
+		regulator-max-microvolt = <1800000>;
+	};
+
+	fixedregulator2v8: fixedregulator at 1 {
+		compatible = "regulator-fixed";
+		regulator-name = "fixed-2.8V";
+		regulator-min-microvolt = <2800000>;
+		regulator-max-microvolt = <2800000>;
+	};
+
+	mmcif at 0x10010000 {
+		compatible = "renesas,sh-mmcif";
+		reg = <0xe6bd0000 0x100>;
+		interrupt-parent = <&gic>;
+		interrupts = <0 140 0x4
+			      0 141 0x4>;
+		reg-io-width = <4>;
+		vmmc-supply = <&fixedregulator1v8>;
+		vqmmc-supply = <&fixedregulator1v8>;
+	};
+
+	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>;
+	};
+};
diff --git a/arch/arm/mach-shmobile/Kconfig b/arch/arm/mach-shmobile/Kconfig
index 8ae100c..ca95c2b 100644
--- a/arch/arm/mach-shmobile/Kconfig
+++ b/arch/arm/mach-shmobile/Kconfig
@@ -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
diff --git a/arch/arm/mach-shmobile/Makefile b/arch/arm/mach-shmobile/Makefile
index fe2c97c..87f50fa 100644
--- a/arch/arm/mach-shmobile/Makefile
+++ b/arch/arm/mach-shmobile/Makefile
@@ -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)
diff --git a/arch/arm/mach-shmobile/board-kzm9g-reference.c b/arch/arm/mach-shmobile/board-kzm9g-reference.c
new file mode 100644
index 0000000..a3bee425
--- /dev/null
+++ b/arch/arm/mach-shmobile/board-kzm9g-reference.c
@@ -0,0 +1,142 @@
+/*
+ * KZM-A9-GT board support - Reference Device Tree Implementation
+ *
+ * Copyright (C) 2012	Horms Solutions Ltd.
+ *
+ * Based on board-kzm9g.c
+ * Copyright (C) 2012	Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include <linux/delay.h>
+#include <linux/gpio.h>
+#include <linux/io.h>
+#include <linux/irq.h>
+#include <linux/input.h>
+#include <linux/of_platform.h>
+#include <mach/sh73a0.h>
+#include <mach/common.h>
+#include <asm/hardware/cache-l2x0.h>
+#include <asm/hardware/gic.h>
+#include <asm/mach-types.h>
+#include <asm/mach/arch.h>
+
+static const struct of_dev_auxdata kzm_auxdata_lookup[] __initconst = {
+	OF_DEV_AUXDATA("renesas,rmobile-iic", 0xe6820000,
+		       "i2c-sh_mobile.0", NULL),
+	OF_DEV_AUXDATA("renesas,rmobile-iic", 0xe6822000,
+		       "i2c-sh_mobile.1", NULL),
+	OF_DEV_AUXDATA("renesas,rmobile-iic", 0xe6824000,
+		       "i2c-sh_mobile.2", NULL),
+	OF_DEV_AUXDATA("renesas,rmobile-iic", 0xe6826000,
+		       "i2c-sh_mobile.3", NULL),
+	OF_DEV_AUXDATA("renesas,rmobile-iic", 0xe6828000,
+		       "i2c-sh_mobile.4", NULL),
+	OF_DEV_AUXDATA("renesas,shmobile-sdhi", 0xee100000,
+		       "sh_mobile_sdhi.0", NULL),
+	OF_DEV_AUXDATA("renesas,shmobile-sdhi", 0xee140000,
+		       "sh_mobile_sdhi.2", NULL),
+	OF_DEV_AUXDATA("renesas,sh-mmcif", 0xe6bd0000, "sh_mmcif.0", NULL),
+	{},
+};
+
+static void __init kzm_init(void)
+{
+	sh73a0_pinmux_init();
+
+	/* enable SCIFA4 */
+	gpio_request(GPIO_FN_SCIFA4_TXD, NULL);
+	gpio_request(GPIO_FN_SCIFA4_RXD, NULL);
+	gpio_request(GPIO_FN_SCIFA4_RTS_, NULL);
+	gpio_request(GPIO_FN_SCIFA4_CTS_, NULL);
+
+	/* Touchscreen */
+	gpio_request(GPIO_PORT223, NULL); /* IRQ8 */
+	gpio_direction_input(GPIO_PORT223);
+
+	/* enable MMCIF */
+	gpio_request(GPIO_FN_MMCCLK0,		NULL);
+	gpio_request(GPIO_FN_MMCCMD0_PU,	NULL);
+	gpio_request(GPIO_FN_MMCD0_0_PU,	NULL);
+	gpio_request(GPIO_FN_MMCD0_1_PU,	NULL);
+	gpio_request(GPIO_FN_MMCD0_2_PU,	NULL);
+	gpio_request(GPIO_FN_MMCD0_3_PU,	NULL);
+	gpio_request(GPIO_FN_MMCD0_4_PU,	NULL);
+	gpio_request(GPIO_FN_MMCD0_5_PU,	NULL);
+	gpio_request(GPIO_FN_MMCD0_6_PU,	NULL);
+	gpio_request(GPIO_FN_MMCD0_7_PU,	NULL);
+
+	/* enable SD */
+	gpio_request(GPIO_FN_SDHIWP0,		NULL);
+	gpio_request(GPIO_FN_SDHICD0,		NULL);
+	gpio_request(GPIO_FN_SDHICMD0,		NULL);
+	gpio_request(GPIO_FN_SDHICLK0,		NULL);
+	gpio_request(GPIO_FN_SDHID0_3,		NULL);
+	gpio_request(GPIO_FN_SDHID0_2,		NULL);
+	gpio_request(GPIO_FN_SDHID0_1,		NULL);
+	gpio_request(GPIO_FN_SDHID0_0,		NULL);
+	gpio_request(GPIO_FN_SDHI0_VCCQ_MC0_ON,	NULL);
+	gpio_request(GPIO_PORT15, NULL);
+	gpio_direction_output(GPIO_PORT15, 1); /* power */
+
+	/* enable Micro SD */
+	gpio_request(GPIO_FN_SDHID2_0,		NULL);
+	gpio_request(GPIO_FN_SDHID2_1,		NULL);
+	gpio_request(GPIO_FN_SDHID2_2,		NULL);
+	gpio_request(GPIO_FN_SDHID2_3,		NULL);
+	gpio_request(GPIO_FN_SDHICMD2,		NULL);
+	gpio_request(GPIO_FN_SDHICLK2,		NULL);
+	gpio_request(GPIO_PORT14, NULL);
+	gpio_direction_output(GPIO_PORT14, 1); /* power */
+
+	/* I2C 3 */
+	gpio_request(GPIO_FN_PORT27_I2C_SCL3, NULL);
+	gpio_request(GPIO_FN_PORT28_I2C_SDA3, NULL);
+
+#ifdef CONFIG_CACHE_L2X0
+	/* Early BRESP enable, Shared attribute override enable, 64K*8way */
+	l2x0_init(IOMEM(0xf0100000), 0x40460000, 0x82000fff);
+#endif
+
+	sh73a0_add_standard_devices_dt();
+	of_platform_populate(NULL, of_default_bus_match_table,
+			     kzm_auxdata_lookup, NULL);
+}
+
+static void kzm9g_restart(char mode, const char *cmd)
+{
+#define RESCNT2 IOMEM(0xe6188020)
+	/* Do soft power on reset */
+	writel((1 << 31), RESCNT2);
+}
+
+static const char *kzm9g_boards_compat_dt[] __initdata = {
+	"renesas,kzm9g-reference",
+	NULL,
+};
+
+DT_MACHINE_START(KZM9G_DT, "kzm9g-reference")
+	.smp		= smp_ops(sh73a0_smp_ops),
+	.map_io		= sh73a0_map_io,
+	.init_early	= sh73a0_add_early_devices_dt,
+	.nr_irqs	= NR_IRQS_LEGACY,
+	.init_irq	= sh73a0_init_irq_dt,
+	.handle_irq	= gic_handle_irq,
+	.init_machine	= kzm_init,
+	.init_late	= shmobile_init_late,
+	.timer		= &shmobile_timer,
+	.restart	= kzm9g_restart,
+	.dt_compat	= kzm9g_boards_compat_dt,
+MACHINE_END
-- 
1.7.10.4

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

* [PATCH 1/7] mmc: sh-mmcif: provide default allowed voltage
  2012-11-26  0:16 ` [PATCH 1/7] mmc: sh-mmcif: provide default allowed voltage Simon Horman
@ 2012-11-26  4:06   ` Magnus Damm
  2012-11-26  4:39     ` Simon Horman
  0 siblings, 1 reply; 25+ messages in thread
From: Magnus Damm @ 2012-11-26  4:06 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Simon,

On Mon, Nov 26, 2012 at 9:16 AM, Simon Horman <horms@verge.net.au> wrote:
> 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
>
> Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> Signed-off-by: Simon Horman <horms@verge.net.au>
> ---
>  drivers/mmc/host/sh_mmcif.c |    7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)

Thanks for your patch!

> diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c
> index 11d2bc3..88d6866 100644
> --- a/drivers/mmc/host/sh_mmcif.c
> +++ b/drivers/mmc/host/sh_mmcif.c
> @@ -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");
>  }

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

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

* [PATCH 6/7] ARM: mach-shmobile: sh73a0: Minimal setup using DT
  2012-11-26  0:16 ` [PATCH 6/7] ARM: mach-shmobile: sh73a0: Minimal setup using DT Simon Horman
@ 2012-11-26  4:23   ` Magnus Damm
  2012-11-26  4:58     ` Simon Horman
  0 siblings, 1 reply; 25+ messages in thread
From: Magnus Damm @ 2012-11-26  4:23 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Simon,

Thanks for your efforts.

On Mon, Nov 26, 2012 at 9:16 AM, Simon Horman <horms@verge.net.au> wrote:
> 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 0x4
>                               0 190 0x4>;
>         };

Uhm, doesn't the above want to go into sh73a0.dtsi?

> Signed-off-by: Simon Horman <horms@verge.net.au>
> ---
>  arch/arm/mach-shmobile/include/mach/common.h |    2 ++
>  arch/arm/mach-shmobile/setup-sh73a0.c        |   41 ++++++++++++++++++++++----
>  2 files changed, 38 insertions(+), 5 deletions(-)
>
> diff --git a/arch/arm/mach-shmobile/include/mach/common.h b/arch/arm/mach-shmobile/include/mach/common.h
> index b50447e..06b905e 100644
> --- a/arch/arm/mach-shmobile/include/mach/common.h
> +++ b/arch/arm/mach-shmobile/include/mach/common.h
> @@ -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;
> diff --git a/arch/arm/mach-shmobile/setup-sh73a0.c b/arch/arm/mach-shmobile/setup-sh73a0.c
> index db99a4a..9096caa 100644
> --- a/arch/arm/mach-shmobile/setup-sh73a0.c
> +++ b/arch/arm/mach-shmobile/setup-sh73a0.c
> @@ -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();
>
>         /* 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.

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

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

* [PATCH 1/7] mmc: sh-mmcif: provide default allowed voltage
  2012-11-26  4:06   ` Magnus Damm
@ 2012-11-26  4:39     ` Simon Horman
  0 siblings, 0 replies; 25+ messages in thread
From: Simon Horman @ 2012-11-26  4:39 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Nov 26, 2012 at 01:06:26PM +0900, Magnus Damm wrote:
> Hi Simon,
> 
> On Mon, Nov 26, 2012 at 9:16 AM, Simon Horman <horms@verge.net.au> wrote:
> > 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
> >
> > Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> > Signed-off-by: Simon Horman <horms@verge.net.au>
> > ---
> >  drivers/mmc/host/sh_mmcif.c |    7 ++-----
> >  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> Thanks for your patch!
> 
> > diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c
> > index 11d2bc3..88d6866 100644
> > --- a/drivers/mmc/host/sh_mmcif.c
> > +++ b/drivers/mmc/host/sh_mmcif.c
> > @@ -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");
> >  }
> 
> 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.

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

* [PATCH 6/7] ARM: mach-shmobile: sh73a0: Minimal setup using DT
  2012-11-26  4:23   ` Magnus Damm
@ 2012-11-26  4:58     ` Simon Horman
  2012-11-26 12:53       ` Laurent Pinchart
  0 siblings, 1 reply; 25+ messages in thread
From: Simon Horman @ 2012-11-26  4:58 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Nov 26, 2012 at 01:23:12PM +0900, Magnus Damm wrote:
> Hi Simon,
> 
> Thanks for your efforts.
> 
> On Mon, Nov 26, 2012 at 9:16 AM, Simon Horman <horms@verge.net.au> wrote:
> > 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 0x4
> >                               0 190 0x4>;
> >         };
> 
> 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.

> > Signed-off-by: Simon Horman <horms@verge.net.au>
> > ---
> >  arch/arm/mach-shmobile/include/mach/common.h |    2 ++
> >  arch/arm/mach-shmobile/setup-sh73a0.c        |   41 ++++++++++++++++++++++----
> >  2 files changed, 38 insertions(+), 5 deletions(-)
> >
> > diff --git a/arch/arm/mach-shmobile/include/mach/common.h b/arch/arm/mach-shmobile/include/mach/common.h
> > index b50447e..06b905e 100644
> > --- a/arch/arm/mach-shmobile/include/mach/common.h
> > +++ b/arch/arm/mach-shmobile/include/mach/common.h
> > @@ -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;
> > diff --git a/arch/arm/mach-shmobile/setup-sh73a0.c b/arch/arm/mach-shmobile/setup-sh73a0.c
> > index db99a4a..9096caa 100644
> > --- a/arch/arm/mach-shmobile/setup-sh73a0.c
> > +++ b/arch/arm/mach-shmobile/setup-sh73a0.c
> > @@ -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();
> >
> >         /* 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?

The reason is that I wasn't aware of shmobile_setup_delay()

> 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.

> > +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.

I'm not sure that I understand but I will look at refactoring the
code to make use of.

> 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.

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

* [PATCH 0/7] ARM: mach-shmobile: kzm9g: Reference DT implementation
  2012-11-26  0:16 [PATCH 0/7] ARM: mach-shmobile: kzm9g: Reference DT implementation Simon Horman
                   ` (6 preceding siblings ...)
  2012-11-26  0:16 ` [PATCH 7/7] ARM: mach-shmobile: kzm9g: Reference DT implementation Simon Horman
@ 2012-11-26  6:10 ` Tetsuyuki Kobayashi
  2012-11-27  0:32   ` Simon Horman
  7 siblings, 1 reply; 25+ messages in thread
From: Tetsuyuki Kobayashi @ 2012-11-26  6:10 UTC (permalink / raw)
  To: linux-arm-kernel

Hello Simon-san,

(2012/11/26 9:16), Simon Horman wrote:

> 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 out

I 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.

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

* [PATCH 7/7] ARM: mach-shmobile: kzm9g: Reference DT implementation
  2012-11-26  0:16 ` [PATCH 7/7] ARM: mach-shmobile: kzm9g: Reference DT implementation Simon Horman
@ 2012-11-26  8:34   ` Tetsuyuki Kobayashi
  2012-11-27  0:33     ` Simon Horman
  0 siblings, 1 reply; 25+ messages in thread
From: Tetsuyuki Kobayashi @ 2012-11-26  8:34 UTC (permalink / raw)
  To: linux-arm-kernel

Hello Simon-san,

(2012/11/26 9:16), Simon Horman wrote:
> 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_REFERENCE should be selected in the kernel config.
> And the sh73a0-kzm9g-reference.dtb flattened device tree blob should be used.
> 
> Signed-off-by: Simon Horman <horms@verge.net.au>
> ---
>   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
> 
> diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
> index c1ce813..b6c4fa2 100644
> --- a/arch/arm/boot/dts/Makefile
> +++ b/arch/arm/boot/dts/Makefile
> @@ -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 \
> diff --git a/arch/arm/boot/dts/sh73a0-kzm9g-reference.dts b/arch/arm/boot/dts/sh73a0-kzm9g-reference.dts
> new file mode 100644
> index 0000000..978892a
> --- /dev/null
> +++ b/arch/arm/boot/dts/sh73a0-kzm9g-reference.dts
> @@ -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>;
> +	};
> +
> +	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.

> +
> +	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>;

> +
> +		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 172 0x4
			      0 173 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 184 0x4
			      0 185 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 188 0x4
			      0 189 0x4
> +			      0 190 0x4>;
> +	};

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

* [PATCH 2/7] mmc: sdhi: enchance OF support for flags and cd-gpios
  2012-11-26  0:16 ` [PATCH 2/7] mmc: sdhi: enchance OF support for flags and cd-gpios Simon Horman
@ 2012-11-26 10:16   ` Guennadi Liakhovetski
  2012-11-26 10:18   ` Guennadi Liakhovetski
  1 sibling, 0 replies; 25+ messages in thread
From: Guennadi Liakhovetski @ 2012-11-26 10:16 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Simon

Thanks for the patch, please, see some comments inline.

On Mon, 26 Nov 2012, Simon Horman wrote:

> Enhance 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.

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";

> 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 <g.liakhovetski@gmx.de>
> Signed-off-by: Simon Horman <horms@verge.net.au>
> ---
>  drivers/mmc/host/sh_mobile_sdhi.c |   76 +++++++++++++++++++++++++++++++------
>  1 file changed, 65 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c
> index 0bdc146..8c7e658 100644
> --- a/drivers/mmc/host/sh_mobile_sdhi.c
> +++ b/drivers/mmc/host/sh_mobile_sdhi.c
> @@ -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

__devinit is being removed:

http://thread.gmane.org/gmane.linux.ports.arm.omap/89686

please, drop it from this patch.

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

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

Hm, does this mean, that if you define CONFIG_OF in your kernel and don't 
provide platform data the driver will just Oops?...

> +
> +	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;
> +

This breaks the no-DT and no-platform-data case. With this your patch the 
clock wouldn't be obtain then.

>  		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 {

Please, remember, that the driver should be able to work with no platform 
data, no DT and CONFIG_OF either defined or not.

> +		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
> -- 
> 1.7.10.4
> 

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/

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

* [PATCH 2/7] mmc: sdhi: enchance OF support for flags and cd-gpios
  2012-11-26  0:16 ` [PATCH 2/7] mmc: sdhi: enchance OF support for flags and cd-gpios Simon Horman
  2012-11-26 10:16   ` Guennadi Liakhovetski
@ 2012-11-26 10:18   ` Guennadi Liakhovetski
  1 sibling, 0 replies; 25+ messages in thread
From: Guennadi Liakhovetski @ 2012-11-26 10:18 UTC (permalink / raw)
  To: linux-arm-kernel

On 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

> Enhance 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>;
> 	};
> 
> Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> Signed-off-by: Simon Horman <horms@verge.net.au>
> ---
>  drivers/mmc/host/sh_mobile_sdhi.c |   76 +++++++++++++++++++++++++++++++------
>  1 file changed, 65 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c
> index 0bdc146..8c7e658 100644
> --- a/drivers/mmc/host/sh_mobile_sdhi.c
> +++ b/drivers/mmc/host/sh_mobile_sdhi.c
> @@ -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
> -- 
> 1.7.10.4
> 

---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/

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

* [PATCH 6/7] ARM: mach-shmobile: sh73a0: Minimal setup using DT
  2012-11-26  4:58     ` Simon Horman
@ 2012-11-26 12:53       ` Laurent Pinchart
  2012-11-27  0:32         ` Simon Horman
  0 siblings, 1 reply; 25+ messages in thread
From: Laurent Pinchart @ 2012-11-26 12:53 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Simon,

On Monday 26 November 2012 13:58:06 Simon Horman wrote:
> On Mon, Nov 26, 2012 at 01:23:12PM +0900, Magnus Damm wrote:
> > On Mon, Nov 26, 2012 at 9:16 AM, Simon Horman <horms@verge.net.au> wrote:
> > > 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 0x4
> > >                 
> > >                               0 190 0x4>;
> > >         
> > >         };
> > 
> > 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?

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.

>   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.

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.

> * 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 ?

>   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.

-- 
Regards,

Laurent Pinchart

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

* [PATCH 3/7] sh: pfc: Allow device tree registration
  2012-11-26  0:16 ` [PATCH 3/7] sh: pfc: Allow device tree registration Simon Horman
@ 2012-11-26 12:54   ` Laurent Pinchart
  2012-11-27  0:07   ` Laurent Pinchart
  1 sibling, 0 replies; 25+ messages in thread
From: Laurent Pinchart @ 2012-11-26 12:54 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Simon,

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.

> 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 <lethal@linux-sh.org>
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Simon Horman <horms@verge.net.au>
> ---
>  drivers/sh/pfc/gpio.c  |   15 +++++++++++++++
>  include/linux/sh_pfc.h |    7 +++++++
>  2 files changed, 22 insertions(+)
> 
> diff --git a/drivers/sh/pfc/gpio.c b/drivers/sh/pfc/gpio.c
> index 038fa07..322b927 100644
> --- a/drivers/sh/pfc/gpio.c
> +++ b/drivers/sh/pfc/gpio.c
> @@ -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);
> 
> diff --git a/include/linux/sh_pfc.h b/include/linux/sh_pfc.h
> index c19a092..9963370 100644
> --- a/include/linux/sh_pfc.h
> +++ b/include/linux/sh_pfc.h
> @@ -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 */
-- 
Regards,

Laurent Pinchart

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

* [PATCH 4/7] ARM: shmobile: pfc-sh73a0: Register device tree
  2012-11-26  0:16 ` [PATCH 4/7] ARM: shmobile: pfc-sh73a0: Register device tree Simon Horman
@ 2012-11-26 14:06   ` Laurent Pinchart
  2012-11-27  3:36     ` Simon Horman
  0 siblings, 1 reply; 25+ messages in thread
From: Laurent Pinchart @ 2012-11-26 14:06 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Simon,

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 <horms@verge.net.au>
> ---
>  arch/arm/mach-shmobile/pfc-sh73a0.c |   45 ++++++++++++++++++++++++++++++++
>  1 file changed, 45 insertions(+)
> 
> diff --git a/arch/arm/mach-shmobile/pfc-sh73a0.c
> b/arch/arm/mach-shmobile/pfc-sh73a0.c index b442f9d..d1a04c0b 100644
> --- a/arch/arm/mach-shmobile/pfc-sh73a0.c
> +++ b/arch/arm/mach-shmobile/pfc-sh73a0.c
> @@ -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];
> +}

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.

> +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);
>  }
-- 
Regards,

Laurent Pinchart

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

* [PATCH 3/7] sh: pfc: Allow device tree registration
  2012-11-26  0:16 ` [PATCH 3/7] sh: pfc: Allow device tree registration Simon Horman
  2012-11-26 12:54   ` Laurent Pinchart
@ 2012-11-27  0:07   ` Laurent Pinchart
  2012-11-27  0:42     ` Simon Horman
  1 sibling, 1 reply; 25+ messages in thread
From: Laurent Pinchart @ 2012-11-27  0:07 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Simon,

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.

> Cc: Paul Mundt <lethal@linux-sh.org>
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Simon Horman <horms@verge.net.au>
> ---
>  drivers/sh/pfc/gpio.c  |   15 +++++++++++++++
>  include/linux/sh_pfc.h |    7 +++++++
>  2 files changed, 22 insertions(+)
> 
> diff --git a/drivers/sh/pfc/gpio.c b/drivers/sh/pfc/gpio.c
> index 038fa07..322b927 100644
> --- a/drivers/sh/pfc/gpio.c
> +++ b/drivers/sh/pfc/gpio.c
> @@ -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);
> 
> diff --git a/include/linux/sh_pfc.h b/include/linux/sh_pfc.h
> index c19a092..9963370 100644
> --- a/include/linux/sh_pfc.h
> +++ b/include/linux/sh_pfc.h
> @@ -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 */
-- 
Regards,

Laurent Pinchart

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

* [PATCH 6/7] ARM: mach-shmobile: sh73a0: Minimal setup using DT
  2012-11-26 12:53       ` Laurent Pinchart
@ 2012-11-27  0:32         ` Simon Horman
  0 siblings, 0 replies; 25+ messages in thread
From: Simon Horman @ 2012-11-27  0:32 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Nov 26, 2012 at 01:53:06PM +0100, Laurent Pinchart wrote:
> Hi Simon,
> 
> On Monday 26 November 2012 13:58:06 Simon Horman wrote:
> > On Mon, Nov 26, 2012 at 01:23:12PM +0900, Magnus Damm wrote:
> > > On Mon, Nov 26, 2012 at 9:16 AM, Simon Horman <horms@verge.net.au> wrote:
> > > > 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 0x4
> > > >                 
> > > >                               0 190 0x4>;
> > > >         
> > > >         };
> > > 
> > > 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?
> 
> 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.
> 
> >   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.
> 
> 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.

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.

> > * 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.

> >   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.

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

* [PATCH 0/7] ARM: mach-shmobile: kzm9g: Reference DT implementation
  2012-11-26  6:10 ` [PATCH 0/7] " Tetsuyuki Kobayashi
@ 2012-11-27  0:32   ` Simon Horman
  0 siblings, 0 replies; 25+ messages in thread
From: Simon Horman @ 2012-11-27  0:32 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Nov 26, 2012 at 03:10:24PM +0900, Tetsuyuki Kobayashi wrote:
> Hello Simon-san,
> 
> (2012/11/26 9:16), Simon Horman wrote:
> 
> > 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 out
> 
> I 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.

Thanks. I found that I had missed two interrupts for
each i2c controller. I will fix this in the next revision.

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

* [PATCH 7/7] ARM: mach-shmobile: kzm9g: Reference DT implementation
  2012-11-26  8:34   ` Tetsuyuki Kobayashi
@ 2012-11-27  0:33     ` Simon Horman
  0 siblings, 0 replies; 25+ messages in thread
From: Simon Horman @ 2012-11-27  0:33 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Nov 26, 2012 at 05:34:59PM +0900, Tetsuyuki Kobayashi wrote:
> Hello Simon-san,
> 
> (2012/11/26 9:16), Simon Horman wrote:
> > 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_REFERENCE should be selected in the kernel config.
> > And the sh73a0-kzm9g-reference.dtb flattened device tree blob should be used.
> > 
> > Signed-off-by: Simon Horman <horms@verge.net.au>
> > ---
> >   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
> > 
> > diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
> > index c1ce813..b6c4fa2 100644
> > --- a/arch/arm/boot/dts/Makefile
> > +++ b/arch/arm/boot/dts/Makefile
> > @@ -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 \
> > diff --git a/arch/arm/boot/dts/sh73a0-kzm9g-reference.dts b/arch/arm/boot/dts/sh73a0-kzm9g-reference.dts
> > new file mode 100644
> > index 0000000..978892a
> > --- /dev/null
> > +++ b/arch/arm/boot/dts/sh73a0-kzm9g-reference.dts
> > @@ -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>;
> > +	};
> > +
> > +	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.

Thanks, sorry for missing that the first time around.

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

* [PATCH 3/7] sh: pfc: Allow device tree registration
  2012-11-27  0:07   ` Laurent Pinchart
@ 2012-11-27  0:42     ` Simon Horman
  0 siblings, 0 replies; 25+ messages in thread
From: Simon Horman @ 2012-11-27  0:42 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Nov 27, 2012 at 01:07:28AM +0100, Laurent Pinchart wrote:
> Hi Simon,
> 
> 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.

Thanks.

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

* [PATCH 4/7] ARM: shmobile: pfc-sh73a0: Register device tree
  2012-11-26 14:06   ` Laurent Pinchart
@ 2012-11-27  3:36     ` Simon Horman
  0 siblings, 0 replies; 25+ messages in thread
From: Simon Horman @ 2012-11-27  3:36 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Nov 26, 2012 at 03:06:37PM +0100, Laurent Pinchart wrote:
> Hi Simon,
> 
> 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 <horms@verge.net.au>
> > ---
> >  arch/arm/mach-shmobile/pfc-sh73a0.c |   45 ++++++++++++++++++++++++++++++++
> >  1 file changed, 45 insertions(+)
> > 
> > diff --git a/arch/arm/mach-shmobile/pfc-sh73a0.c
> > b/arch/arm/mach-shmobile/pfc-sh73a0.c index b442f9d..d1a04c0b 100644
> > --- a/arch/arm/mach-shmobile/pfc-sh73a0.c
> > +++ b/arch/arm/mach-shmobile/pfc-sh73a0.c
> > @@ -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];
> > +}
> 
> 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.

No reason other than that I wasn't aware of of_gpio_simple_xlate.

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

end of thread, other threads:[~2012-11-27  3:36 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-26  0:16 [PATCH 0/7] ARM: mach-shmobile: kzm9g: Reference DT implementation Simon Horman
2012-11-26  0:16 ` [PATCH 1/7] mmc: sh-mmcif: provide default allowed voltage Simon Horman
2012-11-26  4:06   ` Magnus Damm
2012-11-26  4:39     ` Simon Horman
2012-11-26  0:16 ` [PATCH 2/7] mmc: sdhi: enchance OF support for flags and cd-gpios Simon Horman
2012-11-26 10:16   ` Guennadi Liakhovetski
2012-11-26 10:18   ` Guennadi Liakhovetski
2012-11-26  0:16 ` [PATCH 3/7] sh: pfc: Allow device tree registration Simon Horman
2012-11-26 12:54   ` Laurent Pinchart
2012-11-27  0:07   ` Laurent Pinchart
2012-11-27  0:42     ` Simon Horman
2012-11-26  0:16 ` [PATCH 4/7] ARM: shmobile: pfc-sh73a0: Register device tree Simon Horman
2012-11-26 14:06   ` Laurent Pinchart
2012-11-27  3:36     ` Simon Horman
2012-11-26  0:16 ` [PATCH 5/7] ARM: mach-shmobile: sh73a0: Allow initialisation of GIC by DT Simon Horman
2012-11-26  0:16 ` [PATCH 6/7] ARM: mach-shmobile: sh73a0: Minimal setup using DT Simon Horman
2012-11-26  4:23   ` Magnus Damm
2012-11-26  4:58     ` Simon Horman
2012-11-26 12:53       ` Laurent Pinchart
2012-11-27  0:32         ` Simon Horman
2012-11-26  0:16 ` [PATCH 7/7] ARM: mach-shmobile: kzm9g: Reference DT implementation Simon Horman
2012-11-26  8:34   ` Tetsuyuki Kobayashi
2012-11-27  0:33     ` Simon Horman
2012-11-26  6:10 ` [PATCH 0/7] " Tetsuyuki Kobayashi
2012-11-27  0:32   ` Simon Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).