* [PATCH 1/9] sh-pfc: Add OF support
2013-02-13 3:29 [PATCH v2.1 0/9] SH pinctrl DT support Simon Horman
@ 2013-02-13 3:29 ` Simon Horman
2013-02-15 19:37 ` Linus Walleij
2013-02-13 3:29 ` [PATCH 2/9] ARM: shmobile: r8a7740: Add pin control device in device tree Simon Horman
` (7 subsequent siblings)
8 siblings, 1 reply; 14+ messages in thread
From: Simon Horman @ 2013-02-13 3:29 UTC (permalink / raw)
To: linux-arm-kernel
From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Support device instantiation through the device tree. The compatible
property is used to select the SoC pinmux information.
Set the gpio_chip device field to the PFC device to enable automatic
GPIO OF support.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Cc: devicetree-discuss@lists.ozlabs.org
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
---
.../bindings/pinctrl/renesas,pfc-pinctrl.txt | 77 ++++++++++++++++++++
drivers/pinctrl/sh-pfc/core.c | 62 +++++++++++++++-
drivers/pinctrl/sh-pfc/pinctrl.c | 54 ++++++++++++++
3 files changed, 191 insertions(+), 2 deletions(-)
create mode 100644 Documentation/devicetree/bindings/pinctrl/renesas,pfc-pinctrl.txt
diff --git a/Documentation/devicetree/bindings/pinctrl/renesas,pfc-pinctrl.txt b/Documentation/devicetree/bindings/pinctrl/renesas,pfc-pinctrl.txt
new file mode 100644
index 0000000..77752c2
--- /dev/null
+++ b/Documentation/devicetree/bindings/pinctrl/renesas,pfc-pinctrl.txt
@@ -0,0 +1,77 @@
+* Renesas GPIO and Pin Mux/Config controller
+
+Required Properties:
+- compatible: should be one of the following.
+ - "renesas,pfc-r8a7740": for R8A7740 (R-Mobile A1) compatible pin-controller.
+ - "renesas,pfc-r8a7779": for R8A7779 (R-Car H1) compatible pin-controller.
+ - "renesas,pfc-sh7372": for SH7372 (SH-Mobile AP4) compatible pin-controller.
+ - "renesas,pfc-sh73a0": for SH73A0 (SH-Mobile AG5) compatible pin-controller.
+
+- reg: Base address and length of each memory resource used by the pin
+ controller hardware module.
+
+- gpio-controller: Marks the device node as a gpio controller.
+
+- #gpio-cells: Should be 2. The first cell is the pin number and the second cell
+ is used to specify optional parameters as bit flags. Only the GPIO active low
+ flag (bit 0) is currently supported.
+
+
+The PFC node also acts as a container for pin control maps represented as
+subnodes. Each subnode contains a function name and one or more pin or pin group
+name. The subnode names are ignored, all subnodes are parsed through phandles
+and processed purely based on their content.
+
+Required Subnode Properties:
+- renesas,pins : An array of strings. Each string contains the name of a pin or
+ pin group.
+- renesas,function: A string containing the name of the function to mux to the
+ pin or pin group.
+
+ Valid values for group and function names can be found in the group and
+ function arrays of the PFC data file corresponding to the SoC
+ (drivers/pinctrl/spear/pfc-*.c)
+
+Please refer to pinctrl-bindings.txt in this directory for details of the common
+pinctrl bindings used by client devices.
+
+
+The syntax of the gpio specifier used by client nodes should be the following
+with values derived from the SoC user manual.
+
+ <[phandle of the gpio controller node]
+ [pin number within the gpio controller]
+ [flags and pull up/down]>
+
+
+Example 1: SH73A0 (SH-Mobile AG5) pin controller node
+
+ gpio: pfc@e6050000 {
+ compatible = "renesas,pfc-sh73a0";
+ reg = <0xe6050000 0x8000>,
+ <0xe605801c 0x1c>;
+ gpio-controller;
+ #gpio-cells = <2>;
+ };
+
+Example 2: A GPIO LED node that references a GPIO
+
+ leds {
+ compatible = "gpio-leds";
+ led1 {
+ gpios = <&gpio 20 1>; /* Active low */
+ };
+ };
+
+Example 3: KZM-A9-GT (SH-Mobile AG5) default pin state and pin control maps
+ for the LCD device
+
+ &gpio {
+ pinctrl-0 = <&lcd_pins>;
+ pinctrl-names = "default";
+
+ lcd_pins: pfc_lcd_pins {
+ renesas,pins = "lcd_data24", "lcd_sync";
+ renesas,function = "lcd";
+ };
+ };
diff --git a/drivers/pinctrl/sh-pfc/core.c b/drivers/pinctrl/sh-pfc/core.c
index 912b579..d0e8e77 100644
--- a/drivers/pinctrl/sh-pfc/core.c
+++ b/drivers/pinctrl/sh-pfc/core.c
@@ -19,6 +19,7 @@
#include <linux/ioport.h>
#include <linux/kernel.h>
#include <linux/module.h>
+#include <linux/of_device.h>
#include <linux/pinctrl/machine.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
@@ -510,8 +511,55 @@ int sh_pfc_config_gpio(struct sh_pfc *pfc, unsigned gpio, int pinmux_type,
return sh_pfc_config_mux(pfc, mark, pinmux_type, cfg_mode);
}
+#ifdef CONFIG_OF
+static const struct of_device_id sh_pfc_of_table[] = {
+#ifdef CONFIG_PINCTRL_PFC_R8A7740
+ {
+ .compatible = "renesas,pfc-r8a7740",
+ .data = &r8a7740_pinmux_info,
+ },
+#endif
+#ifdef CONFIG_PINCTRL_PFC_R8A7779
+ {
+ .compatible = "renesas,pfc-r8a7779",
+ .data = &r8a7779_pinmux_info,
+ },
+#endif
+#ifdef CONFIG_PINCTRL_PFC_SH7367
+ {
+ .compatible = "renesas,pfc-sh7367",
+ .data = &sh7367_pinmux_info,
+ },
+#endif
+#ifdef CONFIG_PINCTRL_PFC_SH7372
+ {
+ .compatible = "renesas,pfc-sh7372",
+ .data = &sh7372_pinmux_info,
+ },
+#endif
+#ifdef CONFIG_PINCTRL_PFC_SH7377
+ {
+ .compatible = "renesas,pfc-sh7377",
+ .data = &sh7377_pinmux_info,
+ },
+#endif
+#ifdef CONFIG_PINCTRL_PFC_SH73A0
+ {
+ .compatible = "renesas,pfc-sh73a0",
+ .data = &sh73a0_pinmux_info,
+ },
+#endif
+ { },
+};
+MODULE_DEVICE_TABLE(of, sh_pfc_of_table);
+#endif
+
static int sh_pfc_probe(struct platform_device *pdev)
{
+ const struct platform_device_id *platid = platform_get_device_id(pdev);
+#ifdef CONFIG_OF
+ struct device_node *np = pdev->dev.of_node;
+#endif
struct sh_pfc_soc_info *info;
struct sh_pfc *pfc;
int ret;
@@ -521,8 +569,15 @@ static int sh_pfc_probe(struct platform_device *pdev)
*/
BUILD_BUG_ON(PINMUX_FLAG_TYPE > ((1 << PINMUX_FLAG_DBIT_SHIFT) - 1));
- info = pdev->id_entry->driver_data
- ? (void *)pdev->id_entry->driver_data : pdev->dev.platform_data;
+ if (platid)
+ info = (void *)platid->driver_data;
+#ifdef CONFIG_OF
+ else if (np)
+ info = (void *)of_match_device(sh_pfc_of_table, &pdev->dev)->data;
+#endif
+ else
+ info = pdev->dev.platform_data;
+
if (info = NULL)
return -ENODEV;
@@ -646,6 +701,9 @@ static struct platform_driver sh_pfc_driver = {
.driver = {
.name = DRV_NAME,
.owner = THIS_MODULE,
+#ifdef CONFIG_OF
+ .of_match_table = sh_pfc_of_table,
+#endif
},
};
diff --git a/drivers/pinctrl/sh-pfc/pinctrl.c b/drivers/pinctrl/sh-pfc/pinctrl.c
index 6ee4105..78b78d2 100644
--- a/drivers/pinctrl/sh-pfc/pinctrl.c
+++ b/drivers/pinctrl/sh-pfc/pinctrl.c
@@ -15,7 +15,9 @@
#include <linux/err.h>
#include <linux/init.h>
#include <linux/module.h>
+#include <linux/of.h>
#include <linux/pinctrl/consumer.h>
+#include <linux/pinctrl/machine.h>
#include <linux/pinctrl/pinconf.h>
#include <linux/pinctrl/pinconf-generic.h>
#include <linux/pinctrl/pinctrl.h>
@@ -65,11 +67,63 @@ static void sh_pfc_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s,
seq_printf(s, "%s", DRV_NAME);
}
+static int sh_pfc_dt_node_to_map(struct pinctrl_dev *pctldev,
+ struct device_node *np,
+ struct pinctrl_map **map, unsigned *num_maps)
+{
+ struct sh_pfc_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev);
+ struct pinctrl_map *maps;
+ struct property *prop;
+ unsigned int index = 0;
+ const char *function;
+ const char *group;
+ int ret;
+
+ ret = of_property_read_string(np, "renesas,function", &function);
+ if (ret < 0) {
+ dev_err(pmx->pfc->dev, "No function provided in DT\n");
+ return ret;
+ }
+
+ ret = of_property_count_strings(np, "renesas,pins");
+ if (ret < 0)
+ return ret;
+
+ if (!ret) {
+ dev_err(pmx->pfc->dev, "No pin(group) provided in DT node\n");
+ return -ENODEV;
+ }
+
+ maps = kzalloc(sizeof(*maps) * ret, GFP_KERNEL);
+ if (maps = NULL)
+ return -ENOMEM;
+
+ of_property_for_each_string(np, "renesas,pins", prop, group) {
+ maps[index].type = PIN_MAP_TYPE_MUX_GROUP;
+ maps[index].data.mux.group = group;
+ maps[index].data.mux.function = function;
+ index++;
+ }
+
+ *map = maps;
+ *num_maps = index;
+
+ return 0;
+}
+
+static void sh_pfc_dt_free_map(struct pinctrl_dev *pctldev,
+ struct pinctrl_map *map, unsigned num_maps)
+{
+ kfree(map);
+}
+
static struct pinctrl_ops sh_pfc_pinctrl_ops = {
.get_groups_count = sh_pfc_get_groups_count,
.get_group_name = sh_pfc_get_group_name,
.get_group_pins = sh_pfc_get_group_pins,
.pin_dbg_show = sh_pfc_pin_dbg_show,
+ .dt_node_to_map = sh_pfc_dt_node_to_map,
+ .dt_free_map = sh_pfc_dt_free_map,
};
static int sh_pfc_get_functions_count(struct pinctrl_dev *pctldev)
--
1.7.10.4
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH 1/9] sh-pfc: Add OF support
2013-02-13 3:29 ` [PATCH 1/9] sh-pfc: Add OF support Simon Horman
@ 2013-02-15 19:37 ` Linus Walleij
0 siblings, 0 replies; 14+ messages in thread
From: Linus Walleij @ 2013-02-15 19:37 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Feb 13, 2013 at 4:29 AM, Simon Horman
<horms+renesas@verge.net.au> wrote:
> From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
>
> Support device instantiation through the device tree. The compatible
> property is used to select the SoC pinmux information.
>
> Set the gpio_chip device field to the PFC device to enable automatic
> GPIO OF support.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> Cc: devicetree-discuss@lists.ozlabs.org
> Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Looks good to me.
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 2/9] ARM: shmobile: r8a7740: Add pin control device in device tree
2013-02-13 3:29 [PATCH v2.1 0/9] SH pinctrl DT support Simon Horman
2013-02-13 3:29 ` [PATCH 1/9] sh-pfc: Add OF support Simon Horman
@ 2013-02-13 3:29 ` Simon Horman
2013-02-13 3:29 ` [PATCH 3/9] ARM: shmobile: armadillo: Populate platform devices from " Simon Horman
` (6 subsequent siblings)
8 siblings, 0 replies; 14+ messages in thread
From: Simon Horman @ 2013-02-13 3:29 UTC (permalink / raw)
To: linux-arm-kernel
From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Add a pfc node in the r8a7740 device tree.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
---
arch/arm/boot/dts/r8a7740.dtsi | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/arch/arm/boot/dts/r8a7740.dtsi b/arch/arm/boot/dts/r8a7740.dtsi
index 798fa35..9d7800a 100644
--- a/arch/arm/boot/dts/r8a7740.dtsi
+++ b/arch/arm/boot/dts/r8a7740.dtsi
@@ -18,4 +18,12 @@
compatible = "arm,cortex-a9";
};
};
+
+ gpio: pfc@e6050000 {
+ compatible = "renesas,pfc-r8a7740";
+ reg = <0xe6050000 0x8000>,
+ <0xe605800c 0x20>;
+ gpio-controller;
+ #gpio-cells = <2>;
+ };
};
--
1.7.10.4
^ permalink raw reply related [flat|nested] 14+ messages in thread* [PATCH 3/9] ARM: shmobile: armadillo: Populate platform devices from device tree
2013-02-13 3:29 [PATCH v2.1 0/9] SH pinctrl DT support Simon Horman
2013-02-13 3:29 ` [PATCH 1/9] sh-pfc: Add OF support Simon Horman
2013-02-13 3:29 ` [PATCH 2/9] ARM: shmobile: r8a7740: Add pin control device in device tree Simon Horman
@ 2013-02-13 3:29 ` Simon Horman
2013-02-13 3:29 ` [PATCH 4/9] ARM: shmobile: sh73a0: Add pin control device in " Simon Horman
` (5 subsequent siblings)
8 siblings, 0 replies; 14+ messages in thread
From: Simon Horman @ 2013-02-13 3:29 UTC (permalink / raw)
To: linux-arm-kernel
From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Call of_platform_populate() at machine initialization time to populate
platform devices. Remove the explicit pinmux initialization as the PFC
device will be instantiated from the device tree.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
---
arch/arm/mach-shmobile/board-armadillo800eva.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/arch/arm/mach-shmobile/board-armadillo800eva.c b/arch/arm/mach-shmobile/board-armadillo800eva.c
index 5086795..a10e644 100644
--- a/arch/arm/mach-shmobile/board-armadillo800eva.c
+++ b/arch/arm/mach-shmobile/board-armadillo800eva.c
@@ -25,6 +25,7 @@
#include <linux/kernel.h>
#include <linux/input.h>
#include <linux/irq.h>
+#include <linux/of_platform.h>
#include <linux/platform_device.h>
#include <linux/gpio.h>
#include <linux/gpio_keys.h>
@@ -916,11 +917,11 @@ static struct platform_device *eva_devices[] __initdata = {
};
static const struct pinctrl_map eva_pinctrl_map[] = {
- PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_lcdc_fb.0", "pfc-r8a7740",
+ PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_lcdc_fb.0", "e6050000.pfc",
"lcd0_data24_0", "lcd0"),
- PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_lcdc_fb.0", "pfc-r8a7740",
+ PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_lcdc_fb.0", "e6050000.pfc",
"lcd0_lclk_1", "lcd0"),
- PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_lcdc_fb.0", "pfc-r8a7740",
+ PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_lcdc_fb.0", "e6050000.pfc",
"lcd0_sync", "lcd0"),
};
@@ -973,7 +974,8 @@ static void __init eva_init(void)
pinctrl_register_mappings(eva_pinctrl_map, ARRAY_SIZE(eva_pinctrl_map));
- r8a7740_pinmux_init();
+ of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
+
r8a7740_meram_workaround();
/* SCIFA1 */
--
1.7.10.4
^ permalink raw reply related [flat|nested] 14+ messages in thread* [PATCH 4/9] ARM: shmobile: sh73a0: Add pin control device in device tree
2013-02-13 3:29 [PATCH v2.1 0/9] SH pinctrl DT support Simon Horman
` (2 preceding siblings ...)
2013-02-13 3:29 ` [PATCH 3/9] ARM: shmobile: armadillo: Populate platform devices from " Simon Horman
@ 2013-02-13 3:29 ` Simon Horman
2013-02-13 3:29 ` [PATCH 5/9] ARM: shmobile: kzm9g: Populate platform devices from " Simon Horman
` (4 subsequent siblings)
8 siblings, 0 replies; 14+ messages in thread
From: Simon Horman @ 2013-02-13 3:29 UTC (permalink / raw)
To: linux-arm-kernel
From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Add a pfc node in the sh73a0 device tree.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
[horms+renesas@verge.net.au: resolved conflict in sh73a0.dtsi]
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
---
arch/arm/boot/dts/sh73a0.dtsi | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/arch/arm/boot/dts/sh73a0.dtsi b/arch/arm/boot/dts/sh73a0.dtsi
index 721f486..fc7f0fd 100644
--- a/arch/arm/boot/dts/sh73a0.dtsi
+++ b/arch/arm/boot/dts/sh73a0.dtsi
@@ -22,6 +22,14 @@
};
};
+ gpio: pfc@e6050000 {
+ compatible = "renesas,pfc-sh73a0";
+ reg = <0xe6050000 0x8000>,
+ <0xe605801c 0x1c>;
+ gpio-controller;
+ #gpio-cells = <2>;
+ };
+
gic: interrupt-controller@f0001000 {
compatible = "arm,cortex-a9-gic";
#interrupt-cells = <3>;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 14+ messages in thread* [PATCH 5/9] ARM: shmobile: kzm9g: Populate platform devices from device tree
2013-02-13 3:29 [PATCH v2.1 0/9] SH pinctrl DT support Simon Horman
` (3 preceding siblings ...)
2013-02-13 3:29 ` [PATCH 4/9] ARM: shmobile: sh73a0: Add pin control device in " Simon Horman
@ 2013-02-13 3:29 ` Simon Horman
2013-02-13 3:29 ` [PATCH 6/9] ARM: shmobile: kzm9g: reference: " Simon Horman
` (3 subsequent siblings)
8 siblings, 0 replies; 14+ messages in thread
From: Simon Horman @ 2013-02-13 3:29 UTC (permalink / raw)
To: linux-arm-kernel
From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Call of_platform_populate() at machine initialization time to populate
platform devices. Remove the explicit pinmux initialization as the PFC
device will be instantiated from the device tree.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
---
arch/arm/mach-shmobile/board-kzm9g.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/arch/arm/mach-shmobile/board-kzm9g.c b/arch/arm/mach-shmobile/board-kzm9g.c
index 2b529d2..b89a9a8 100644
--- a/arch/arm/mach-shmobile/board-kzm9g.c
+++ b/arch/arm/mach-shmobile/board-kzm9g.c
@@ -30,6 +30,7 @@
#include <linux/mmc/sh_mmcif.h>
#include <linux/mmc/sh_mobile_sdhi.h>
#include <linux/mfd/tmio.h>
+#include <linux/of_platform.h>
#include <linux/pinctrl/machine.h>
#include <linux/platform_device.h>
#include <linux/regulator/fixed.h>
@@ -601,23 +602,23 @@ static struct platform_device *kzm_devices[] __initdata = {
};
static const struct pinctrl_map kzm_pinctrl_map[] = {
- PIN_MAP_MUX_GROUP_DEFAULT("sh_fsi2.0", "pfc-sh73a0",
+ PIN_MAP_MUX_GROUP_DEFAULT("sh_fsi2.0", "e6050000.pfc",
"fsia_mclk_in", "fsia"),
- PIN_MAP_MUX_GROUP_DEFAULT("sh_fsi2.0", "pfc-sh73a0",
+ PIN_MAP_MUX_GROUP_DEFAULT("sh_fsi2.0", "e6050000.pfc",
"fsia_sclk_in", "fsia"),
- PIN_MAP_MUX_GROUP_DEFAULT("sh_fsi2.0", "pfc-sh73a0",
+ PIN_MAP_MUX_GROUP_DEFAULT("sh_fsi2.0", "e6050000.pfc",
"fsia_data_in", "fsia"),
- PIN_MAP_MUX_GROUP_DEFAULT("sh_fsi2.0", "pfc-sh73a0",
+ PIN_MAP_MUX_GROUP_DEFAULT("sh_fsi2.0", "e6050000.pfc",
"fsia_data_out", "fsia"),
- PIN_MAP_MUX_GROUP_DEFAULT("i2c-sh_mobile.3", "pfc-sh73a0",
+ PIN_MAP_MUX_GROUP_DEFAULT("i2c-sh_mobile.3", "e6050000.pfc",
"i2c3_1", "i2c3"),
- PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.4", "pfc-sh73a0",
+ PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.4", "e6050000.pfc",
"scifa4_data", "scifa4"),
- PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.4", "pfc-sh73a0",
+ PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.4", "e6050000.pfc",
"scifa4_ctrl", "scifa4"),
- PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_lcdc_fb.0", "pfc-sh73a0",
+ PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_lcdc_fb.0", "e6050000.pfc",
"lcd_data24", "lcd"),
- PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_lcdc_fb.0", "pfc-sh73a0",
+ PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_lcdc_fb.0", "e6050000.pfc",
"lcd_sync", "lcd"),
};
@@ -684,7 +685,7 @@ static void __init kzm_init(void)
pinctrl_register_mappings(kzm_pinctrl_map, ARRAY_SIZE(kzm_pinctrl_map));
- sh73a0_pinmux_init();
+ of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
/* CS4 for SMSC/USB */
gpio_request(GPIO_FN_CS4_, NULL); /* CS4 */
--
1.7.10.4
^ permalink raw reply related [flat|nested] 14+ messages in thread* [PATCH 6/9] ARM: shmobile: kzm9g: reference: Populate platform devices from device tree
2013-02-13 3:29 [PATCH v2.1 0/9] SH pinctrl DT support Simon Horman
` (4 preceding siblings ...)
2013-02-13 3:29 ` [PATCH 5/9] ARM: shmobile: kzm9g: Populate platform devices from " Simon Horman
@ 2013-02-13 3:29 ` Simon Horman
2013-02-13 3:29 ` [PATCH 7/9] ARM: shmobile: kzm9g: Add LED1-LED4 to the " Simon Horman
` (2 subsequent siblings)
8 siblings, 0 replies; 14+ messages in thread
From: Simon Horman @ 2013-02-13 3:29 UTC (permalink / raw)
To: linux-arm-kernel
Call of_platform_populate() at machine initialization time to populate
platform devices. Remove the explicit pinmux initialization as the PFC
device will be instantiated from the device tree.
This change is for the kzm9g reference DT implementation and is in keeping
with a similar change for the default kzm9g implementation made by Laurent
Pinchart.
Reported-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Cc: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
---
arch/arm/boot/dts/sh73a0-kzm9g-reference.dts | 12 ++++++++++++
arch/arm/mach-shmobile/board-kzm9g-reference.c | 7 ++-----
2 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/arch/arm/boot/dts/sh73a0-kzm9g-reference.dts b/arch/arm/boot/dts/sh73a0-kzm9g-reference.dts
index 06f52f9..9901caf 100644
--- a/arch/arm/boot/dts/sh73a0-kzm9g-reference.dts
+++ b/arch/arm/boot/dts/sh73a0-kzm9g-reference.dts
@@ -35,6 +35,18 @@
};
};
+&i2c3 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&i2c3_pins>;
+};
+
+&gpio {
+ i2c3_pins: pfc_i2c3_pins {
+ renesas,pins = "i2c3_1";
+ renesas,function = "i2c3";
+ };
+};
+
&mmcif {
vmmc-supply = <&fixedregulator1v8>;
vqmmc-supply = <&fixedregulator1v8>;
diff --git a/arch/arm/mach-shmobile/board-kzm9g-reference.c b/arch/arm/mach-shmobile/board-kzm9g-reference.c
index 7282048..625e337 100644
--- a/arch/arm/mach-shmobile/board-kzm9g-reference.c
+++ b/arch/arm/mach-shmobile/board-kzm9g-reference.c
@@ -34,11 +34,9 @@
#include <asm/mach/arch.h>
static const struct pinctrl_map kzm_pinctrl_map[] = {
- PIN_MAP_MUX_GROUP_DEFAULT("i2c-sh_mobile.3", "pfc-sh73a0",
- "i2c3_1", "i2c3"),
- PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.4", "pfc-sh73a0",
+ PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.4", "e6050000.pfc",
"scifa4_data", "scifa4"),
- PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.4", "pfc-sh73a0",
+ PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.4", "e6050000.pfc",
"scifa4_ctrl", "scifa4"),
};
@@ -46,7 +44,6 @@ static void __init kzm_init(void)
{
sh73a0_add_standard_devices_dt();
pinctrl_register_mappings(kzm_pinctrl_map, ARRAY_SIZE(kzm_pinctrl_map));
- sh73a0_pinmux_init();
/* enable MMCIF */
gpio_request(GPIO_FN_MMCCLK0, NULL);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 14+ messages in thread* [PATCH 7/9] ARM: shmobile: kzm9g: Add LED1-LED4 to the device tree
2013-02-13 3:29 [PATCH v2.1 0/9] SH pinctrl DT support Simon Horman
` (5 preceding siblings ...)
2013-02-13 3:29 ` [PATCH 6/9] ARM: shmobile: kzm9g: reference: " Simon Horman
@ 2013-02-13 3:29 ` Simon Horman
2013-02-13 3:29 ` [PATCH 8/9] ARM: shmobile: armadillo: Move pinctrl mappings to " Simon Horman
2013-02-13 3:29 ` [PATCH 9/9] ARM: shmobile: kzm9g: " Simon Horman
8 siblings, 0 replies; 14+ messages in thread
From: Simon Horman @ 2013-02-13 3:29 UTC (permalink / raw)
To: linux-arm-kernel
From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
LED1 to LED4 are GPIO LEDs. Add corresponding DT nodes.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
---
arch/arm/boot/dts/sh73a0-kzm9g.dts | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/arch/arm/boot/dts/sh73a0-kzm9g.dts b/arch/arm/boot/dts/sh73a0-kzm9g.dts
index 7b37901..203efb8 100644
--- a/arch/arm/boot/dts/sh73a0-kzm9g.dts
+++ b/arch/arm/boot/dts/sh73a0-kzm9g.dts
@@ -19,4 +19,20 @@
device_type = "memory";
reg = <0x41000000 0x1e800000>;
};
+
+ leds {
+ compatible = "gpio-leds";
+ led1 {
+ gpios = <&gpio 20 1>; /* Active low */
+ };
+ led2 {
+ gpios = <&gpio 21 1>; /* Active low */
+ };
+ led3 {
+ gpios = <&gpio 22 1>; /* Active low */
+ };
+ led4 {
+ gpios = <&gpio 23 1>; /* Active low */
+ };
+ };
};
--
1.7.10.4
^ permalink raw reply related [flat|nested] 14+ messages in thread* [PATCH 8/9] ARM: shmobile: armadillo: Move pinctrl mappings to device tree
2013-02-13 3:29 [PATCH v2.1 0/9] SH pinctrl DT support Simon Horman
` (6 preceding siblings ...)
2013-02-13 3:29 ` [PATCH 7/9] ARM: shmobile: kzm9g: Add LED1-LED4 to the " Simon Horman
@ 2013-02-13 3:29 ` Simon Horman
2013-02-13 3:29 ` [PATCH 9/9] ARM: shmobile: kzm9g: " Simon Horman
8 siblings, 0 replies; 14+ messages in thread
From: Simon Horman @ 2013-02-13 3:29 UTC (permalink / raw)
To: linux-arm-kernel
From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Replace the pinctrl mappings in board code by device tree mappings.
Reference the mapping as the default pin controller state to apply it at
boot time.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
---
arch/arm/boot/dts/r8a7740-armadillo800eva.dts | 10 ++++++++++
arch/arm/mach-shmobile/board-armadillo800eva.c | 12 ------------
2 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/arch/arm/boot/dts/r8a7740-armadillo800eva.dts b/arch/arm/boot/dts/r8a7740-armadillo800eva.dts
index a8e7bd9..f324405 100644
--- a/arch/arm/boot/dts/r8a7740-armadillo800eva.dts
+++ b/arch/arm/boot/dts/r8a7740-armadillo800eva.dts
@@ -20,3 +20,13 @@
reg = <0x40000000 0x20000000>;
};
};
+
+&gpio {
+ pinctrl-0 = <&lcd0_pins>;
+ pinctrl-names = "default";
+
+ lcd0_pins: pfc_lcd0_pins {
+ renesas,pins = "lcd0_data24_0", "lcd0_lclk_0", "lcd0_sync";
+ renesas,function = "lcd0";
+ };
+};
diff --git a/arch/arm/mach-shmobile/board-armadillo800eva.c b/arch/arm/mach-shmobile/board-armadillo800eva.c
index a10e644..e5dfaeb 100644
--- a/arch/arm/mach-shmobile/board-armadillo800eva.c
+++ b/arch/arm/mach-shmobile/board-armadillo800eva.c
@@ -29,7 +29,6 @@
#include <linux/platform_device.h>
#include <linux/gpio.h>
#include <linux/gpio_keys.h>
-#include <linux/pinctrl/machine.h>
#include <linux/regulator/fixed.h>
#include <linux/regulator/machine.h>
#include <linux/sh_eth.h>
@@ -916,15 +915,6 @@ static struct platform_device *eva_devices[] __initdata = {
&i2c_gpio_device,
};
-static const struct pinctrl_map eva_pinctrl_map[] = {
- PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_lcdc_fb.0", "e6050000.pfc",
- "lcd0_data24_0", "lcd0"),
- PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_lcdc_fb.0", "e6050000.pfc",
- "lcd0_lclk_1", "lcd0"),
- PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_lcdc_fb.0", "e6050000.pfc",
- "lcd0_sync", "lcd0"),
-};
-
static void __init eva_clock_init(void)
{
struct clk *system = clk_get(NULL, "system_clk");
@@ -972,8 +962,6 @@ static void __init eva_init(void)
regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers,
ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
- pinctrl_register_mappings(eva_pinctrl_map, ARRAY_SIZE(eva_pinctrl_map));
-
of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
r8a7740_meram_workaround();
--
1.7.10.4
^ permalink raw reply related [flat|nested] 14+ messages in thread* [PATCH 9/9] ARM: shmobile: kzm9g: Move pinctrl mappings to device tree
2013-02-13 3:29 [PATCH v2.1 0/9] SH pinctrl DT support Simon Horman
` (7 preceding siblings ...)
2013-02-13 3:29 ` [PATCH 8/9] ARM: shmobile: armadillo: Move pinctrl mappings to " Simon Horman
@ 2013-02-13 3:29 ` Simon Horman
8 siblings, 0 replies; 14+ messages in thread
From: Simon Horman @ 2013-02-13 3:29 UTC (permalink / raw)
To: linux-arm-kernel
From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Replace the pinctrl mappings in board code by device tree mappings.
Reference the mapping as the default pin controller state to apply it at
boot time.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
---
arch/arm/boot/dts/sh73a0-kzm9g.dts | 10 ++++++++++
arch/arm/mach-shmobile/board-kzm9g.c | 24 ------------------------
2 files changed, 10 insertions(+), 24 deletions(-)
diff --git a/arch/arm/boot/dts/sh73a0-kzm9g.dts b/arch/arm/boot/dts/sh73a0-kzm9g.dts
index 203efb8..ba321c2 100644
--- a/arch/arm/boot/dts/sh73a0-kzm9g.dts
+++ b/arch/arm/boot/dts/sh73a0-kzm9g.dts
@@ -36,3 +36,13 @@
};
};
};
+
+&gpio {
+ pinctrl-0 = <&lcd_pins>;
+ pinctrl-names = "default";
+
+ lcd_pins: pfc_lcd_pins {
+ renesas,pins = "lcd_data24", "lcd_sync";
+ renesas,function = "lcd";
+ };
+};
diff --git a/arch/arm/mach-shmobile/board-kzm9g.c b/arch/arm/mach-shmobile/board-kzm9g.c
index b89a9a8..949ef36 100644
--- a/arch/arm/mach-shmobile/board-kzm9g.c
+++ b/arch/arm/mach-shmobile/board-kzm9g.c
@@ -31,7 +31,6 @@
#include <linux/mmc/sh_mobile_sdhi.h>
#include <linux/mfd/tmio.h>
#include <linux/of_platform.h>
-#include <linux/pinctrl/machine.h>
#include <linux/platform_device.h>
#include <linux/regulator/fixed.h>
#include <linux/regulator/machine.h>
@@ -601,27 +600,6 @@ static struct platform_device *kzm_devices[] __initdata = {
&fsi_ak4648_device,
};
-static const struct pinctrl_map kzm_pinctrl_map[] = {
- PIN_MAP_MUX_GROUP_DEFAULT("sh_fsi2.0", "e6050000.pfc",
- "fsia_mclk_in", "fsia"),
- PIN_MAP_MUX_GROUP_DEFAULT("sh_fsi2.0", "e6050000.pfc",
- "fsia_sclk_in", "fsia"),
- PIN_MAP_MUX_GROUP_DEFAULT("sh_fsi2.0", "e6050000.pfc",
- "fsia_data_in", "fsia"),
- PIN_MAP_MUX_GROUP_DEFAULT("sh_fsi2.0", "e6050000.pfc",
- "fsia_data_out", "fsia"),
- PIN_MAP_MUX_GROUP_DEFAULT("i2c-sh_mobile.3", "e6050000.pfc",
- "i2c3_1", "i2c3"),
- PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.4", "e6050000.pfc",
- "scifa4_data", "scifa4"),
- PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.4", "e6050000.pfc",
- "scifa4_ctrl", "scifa4"),
- PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_lcdc_fb.0", "e6050000.pfc",
- "lcd_data24", "lcd"),
- PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_lcdc_fb.0", "e6050000.pfc",
- "lcd_sync", "lcd"),
-};
-
/*
* FIXME
*
@@ -683,8 +661,6 @@ static void __init kzm_init(void)
ARRAY_SIZE(fixed2v8_power_consumers), 2800000);
regulator_register_fixed(2, dummy_supplies, ARRAY_SIZE(dummy_supplies));
- pinctrl_register_mappings(kzm_pinctrl_map, ARRAY_SIZE(kzm_pinctrl_map));
-
of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
/* CS4 for SMSC/USB */
--
1.7.10.4
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 1/9] sh-pfc: Add OF support
2013-01-04 0:40 [PATCH 0/9] SH pinctrl DT support Laurent Pinchart
@ 2013-01-04 0:40 ` Laurent Pinchart
2013-01-04 1:12 ` Tony Prisk
0 siblings, 1 reply; 14+ messages in thread
From: Laurent Pinchart @ 2013-01-04 0:40 UTC (permalink / raw)
To: linux-sh
Cc: Paul Mundt, Magnus Damm, Simon Horman, Linus Walleij,
Kuninori Morimoto, Phil Edworthy, Nobuhiro Iwamatsu,
Guennadi Liakhovetski, devicetree-discuss
Support device instantiation through the device tree. The compatible
property is used to select the SoC pinmux information.
Set the gpio_chip device field to the PFC device to enable automatic
GPIO OF support.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Cc: devicetree-discuss@lists.ozlabs.org
---
.../bindings/pinctrl/renesas,pfc-pinctrl.txt | 76 ++++++++++++++++++++
drivers/pinctrl/sh-pfc/core.c | 62 +++++++++++++++-
drivers/pinctrl/sh-pfc/pinctrl.c | 54 ++++++++++++++
3 files changed, 190 insertions(+), 2 deletions(-)
create mode 100644 Documentation/devicetree/bindings/pinctrl/renesas,pfc-pinctrl.txt
(Comment from the cover letter repeated here)
To be perfectly honest I'm a bit unsure about the DT bindings. The platforms
that implement pinctrl DT bindings use a wide variety of architectures. I
haven't found clear guidelines regarding how those bindings should be
implemented (Documentation/devicetree/pinctrl just states that bindings are
driver-specific). Comments will be appreciated.
diff --git a/Documentation/devicetree/bindings/pinctrl/renesas,pfc-pinctrl.txt b/Documentation/devicetree/bindings/pinctrl/renesas,pfc-pinctrl.txt
new file mode 100644
index 0000000..aa41bbe
--- /dev/null
+++ b/Documentation/devicetree/bindings/pinctrl/renesas,pfc-pinctrl.txt
@@ -0,0 +1,76 @@
+* Renesas GPIO and Pin Mux/Config controller
+
+Required Properties:
+- compatible: should be one of the following.
+ - "renesas,pfc-r8a7740": for R8A7740 (R-Mobile A1) compatible pin-controller.
+ - "renesas,pfc-r8a7779": for R8A7779 (R-Car H1) compatible pin-controller.
+ - "renesas,pfc-sh7372": for SH7372 (SH-Mobile AP4) compatible pin-controller.
+ - "renesas,pfc-sh73a0": for SH73A0 (SH-Mobile AG5) compatible pin-controller.
+
+- reg: Base address and length of each memory resource used by the pin
+ controller hardware module.
+
+- gpio-controller: Marks the device node as a gpio controller.
+
+- #gpio-cells: Should be 2. The first cell is the pin number and the second cell
+ is used to specify optional parameters (currently unused).
+
+
+The PFC node also acts as a container for pin control maps represented as
+subnodes. Each subnode contains a function name and one or more pin or pin group
+name. The subnode names are ignored, all subnodes are parsed through phandles
+and processed purely based on their content.
+
+Required Subnode Properties:
+- renesas,pins : An array of strings. Each string contains the name of a pin or
+ pin group.
+- renesas,function: A string containing the name of the function to mux to the
+ pin or pin group.
+
+ Valid values for group and function names can be found in the group and
+ function arrays of the PFC data file corresponding to the SoC
+ (drivers/pinctrl/spear/pfc-*.c)
+
+Please refer to pinctrl-bindings.txt in this directory for details of the common
+pinctrl bindings used by client devices.
+
+
+The syntax of the gpio specifier used by client nodes should be the following
+with values derived from the SoC user manual.
+
+ <[phandle of the gpio controller node]
+ [pin number within the gpio controller]
+ [flags and pull up/down]>
+
+
+Example 1: SH73A0 (SH-Mobile AG5) pin controller node
+
+ gpio: pfc@e6050000 {
+ compatible = "renesas,pfc-sh73a0";
+ reg = <0xe6050000 0x8000>,
+ <0xe605801c 0x1c>;
+ gpio-controller;
+ #gpio-cells = <2>;
+ };
+
+Example 2: A GPIO LED node that references a GPIO
+
+ leds {
+ compatible = "gpio-leds";
+ led1 {
+ gpios = <&gpio 20 1>; /* Active low */
+ };
+ };
+
+Example 3: KZM-A9-GT (SH-Mobile AG5) default pin state and pin control maps
+ for the LCD device
+
+ &gpio {
+ pinctrl-0 = <&lcd_pins>;
+ pinctrl-names = "default";
+
+ lcd_pins: pfc_lcd_pins {
+ renesas,pins = "lcd_data24", "lcd_sync";
+ renesas,function = "lcd";
+ };
+ };
diff --git a/drivers/pinctrl/sh-pfc/core.c b/drivers/pinctrl/sh-pfc/core.c
index 912b579..d0e8e77 100644
--- a/drivers/pinctrl/sh-pfc/core.c
+++ b/drivers/pinctrl/sh-pfc/core.c
@@ -19,6 +19,7 @@
#include <linux/ioport.h>
#include <linux/kernel.h>
#include <linux/module.h>
+#include <linux/of_device.h>
#include <linux/pinctrl/machine.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
@@ -510,8 +511,55 @@ int sh_pfc_config_gpio(struct sh_pfc *pfc, unsigned gpio, int pinmux_type,
return sh_pfc_config_mux(pfc, mark, pinmux_type, cfg_mode);
}
+#ifdef CONFIG_OF
+static const struct of_device_id sh_pfc_of_table[] = {
+#ifdef CONFIG_PINCTRL_PFC_R8A7740
+ {
+ .compatible = "renesas,pfc-r8a7740",
+ .data = &r8a7740_pinmux_info,
+ },
+#endif
+#ifdef CONFIG_PINCTRL_PFC_R8A7779
+ {
+ .compatible = "renesas,pfc-r8a7779",
+ .data = &r8a7779_pinmux_info,
+ },
+#endif
+#ifdef CONFIG_PINCTRL_PFC_SH7367
+ {
+ .compatible = "renesas,pfc-sh7367",
+ .data = &sh7367_pinmux_info,
+ },
+#endif
+#ifdef CONFIG_PINCTRL_PFC_SH7372
+ {
+ .compatible = "renesas,pfc-sh7372",
+ .data = &sh7372_pinmux_info,
+ },
+#endif
+#ifdef CONFIG_PINCTRL_PFC_SH7377
+ {
+ .compatible = "renesas,pfc-sh7377",
+ .data = &sh7377_pinmux_info,
+ },
+#endif
+#ifdef CONFIG_PINCTRL_PFC_SH73A0
+ {
+ .compatible = "renesas,pfc-sh73a0",
+ .data = &sh73a0_pinmux_info,
+ },
+#endif
+ { },
+};
+MODULE_DEVICE_TABLE(of, sh_pfc_of_table);
+#endif
+
static int sh_pfc_probe(struct platform_device *pdev)
{
+ const struct platform_device_id *platid = platform_get_device_id(pdev);
+#ifdef CONFIG_OF
+ struct device_node *np = pdev->dev.of_node;
+#endif
struct sh_pfc_soc_info *info;
struct sh_pfc *pfc;
int ret;
@@ -521,8 +569,15 @@ static int sh_pfc_probe(struct platform_device *pdev)
*/
BUILD_BUG_ON(PINMUX_FLAG_TYPE > ((1 << PINMUX_FLAG_DBIT_SHIFT) - 1));
- info = pdev->id_entry->driver_data
- ? (void *)pdev->id_entry->driver_data : pdev->dev.platform_data;
+ if (platid)
+ info = (void *)platid->driver_data;
+#ifdef CONFIG_OF
+ else if (np)
+ info = (void *)of_match_device(sh_pfc_of_table, &pdev->dev)->data;
+#endif
+ else
+ info = pdev->dev.platform_data;
+
if (info = NULL)
return -ENODEV;
@@ -646,6 +701,9 @@ static struct platform_driver sh_pfc_driver = {
.driver = {
.name = DRV_NAME,
.owner = THIS_MODULE,
+#ifdef CONFIG_OF
+ .of_match_table = sh_pfc_of_table,
+#endif
},
};
diff --git a/drivers/pinctrl/sh-pfc/pinctrl.c b/drivers/pinctrl/sh-pfc/pinctrl.c
index 6ee4105..78b78d2 100644
--- a/drivers/pinctrl/sh-pfc/pinctrl.c
+++ b/drivers/pinctrl/sh-pfc/pinctrl.c
@@ -15,7 +15,9 @@
#include <linux/err.h>
#include <linux/init.h>
#include <linux/module.h>
+#include <linux/of.h>
#include <linux/pinctrl/consumer.h>
+#include <linux/pinctrl/machine.h>
#include <linux/pinctrl/pinconf.h>
#include <linux/pinctrl/pinconf-generic.h>
#include <linux/pinctrl/pinctrl.h>
@@ -65,11 +67,63 @@ static void sh_pfc_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s,
seq_printf(s, "%s", DRV_NAME);
}
+static int sh_pfc_dt_node_to_map(struct pinctrl_dev *pctldev,
+ struct device_node *np,
+ struct pinctrl_map **map, unsigned *num_maps)
+{
+ struct sh_pfc_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev);
+ struct pinctrl_map *maps;
+ struct property *prop;
+ unsigned int index = 0;
+ const char *function;
+ const char *group;
+ int ret;
+
+ ret = of_property_read_string(np, "renesas,function", &function);
+ if (ret < 0) {
+ dev_err(pmx->pfc->dev, "No function provided in DT\n");
+ return ret;
+ }
+
+ ret = of_property_count_strings(np, "renesas,pins");
+ if (ret < 0)
+ return ret;
+
+ if (!ret) {
+ dev_err(pmx->pfc->dev, "No pin(group) provided in DT node\n");
+ return -ENODEV;
+ }
+
+ maps = kzalloc(sizeof(*maps) * ret, GFP_KERNEL);
+ if (maps = NULL)
+ return -ENOMEM;
+
+ of_property_for_each_string(np, "renesas,pins", prop, group) {
+ maps[index].type = PIN_MAP_TYPE_MUX_GROUP;
+ maps[index].data.mux.group = group;
+ maps[index].data.mux.function = function;
+ index++;
+ }
+
+ *map = maps;
+ *num_maps = index;
+
+ return 0;
+}
+
+static void sh_pfc_dt_free_map(struct pinctrl_dev *pctldev,
+ struct pinctrl_map *map, unsigned num_maps)
+{
+ kfree(map);
+}
+
static struct pinctrl_ops sh_pfc_pinctrl_ops = {
.get_groups_count = sh_pfc_get_groups_count,
.get_group_name = sh_pfc_get_group_name,
.get_group_pins = sh_pfc_get_group_pins,
.pin_dbg_show = sh_pfc_pin_dbg_show,
+ .dt_node_to_map = sh_pfc_dt_node_to_map,
+ .dt_free_map = sh_pfc_dt_free_map,
};
static int sh_pfc_get_functions_count(struct pinctrl_dev *pctldev)
--
1.7.8.6
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH 1/9] sh-pfc: Add OF support
2013-01-04 0:40 ` [PATCH 1/9] sh-pfc: Add OF support Laurent Pinchart
@ 2013-01-04 1:12 ` Tony Prisk
2013-01-07 18:56 ` Laurent Pinchart
0 siblings, 1 reply; 14+ messages in thread
From: Tony Prisk @ 2013-01-04 1:12 UTC (permalink / raw)
To: Laurent Pinchart
Cc: linux-sh, Simon Horman, Phil Edworthy, Kuninori Morimoto,
devicetree-discuss, Magnus Damm, Paul Mundt, Nobuhiro Iwamatsu,
Guennadi Liakhovetski
On Fri, 2013-01-04 at 01:40 +0100, Laurent Pinchart wrote:
> +- #gpio-cells: Should be 2. The first cell is the pin number and the second cell
> + is used to specify optional parameters (currently unused).
...
> + gpio: pfc@e6050000 {
> + compatible = "renesas,pfc-sh73a0";
> + reg = <0xe6050000 0x8000>,
> + <0xe605801c 0x1c>;
> + gpio-controller;
> + #gpio-cells = <2>;
> + };
> +
> +Example 2: A GPIO LED node that references a GPIO
> +
> + leds {
> + compatible = "gpio-leds";
> + led1 {
> + gpios = <&gpio 20 1>; /* Active low */
> + };
> + };
> +
The second cell of gpio is '(currently unused)' but the example shows it
being used?
Regards
Tony Prisk
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH 1/9] sh-pfc: Add OF support
2013-01-04 1:12 ` Tony Prisk
@ 2013-01-07 18:56 ` Laurent Pinchart
0 siblings, 0 replies; 14+ messages in thread
From: Laurent Pinchart @ 2013-01-07 18:56 UTC (permalink / raw)
To: Tony Prisk
Cc: Laurent Pinchart, linux-sh, Simon Horman, Phil Edworthy,
Kuninori Morimoto, devicetree-discuss, Magnus Damm, Paul Mundt,
Nobuhiro Iwamatsu, Guennadi Liakhovetski
Hi Tony,
On Friday 04 January 2013 14:12:06 Tony Prisk wrote:
> On Fri, 2013-01-04 at 01:40 +0100, Laurent Pinchart wrote:
> > +- #gpio-cells: Should be 2. The first cell is the pin number and the
> > second cell
> > + is used to specify optional parameters (currently unused).
>
> ...
>
> > + gpio: pfc@e6050000 {
> > + compatible = "renesas,pfc-sh73a0";
> > + reg = <0xe6050000 0x8000>,
> > + <0xe605801c 0x1c>;
> > + gpio-controller;
> > + #gpio-cells = <2>;
> > + };
> > +
> > +Example 2: A GPIO LED node that references a GPIO
> > +
> > + leds {
> > + compatible = "gpio-leds";
> > + led1 {
> > + gpios = <&gpio 20 1>; /* Active low */
> > + };
> > + };
> > +
>
> The second cell of gpio is '(currently unused)' but the example shows it
> being used?
My bad. The second cell can be used to specify that the GPIO is active low.
I'll fix the documentation accordingly.
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 14+ messages in thread