arm/tegra: Initialize GPIO & pinmux from DT
Subsystems (6)
cover arm/tegra: Initialize GPIO & pinmux from DT
This patch modifies Tegra's device tree support to remove the dependency on harmony_pinmux_init(), thus making it completely board-independent.
Some notes:
* This series is built on top of linux-next with a bunch of patches applied, in particular the removal of irq_to_gpio and custom gpio_to_irq that I'm in the process of sending to Russell. I haven't yet thought through how/where to merge this without causing all kinds of conflicts.
* I took care to preserve bisectability of Tegra DT support. However, linux-next doesn't yet have entirely useful Tegra DT support; some stuff from Grant's devicetree/next hasn't been pushed into linux-next yet. If we don't care about bisectability, I can remove a couple commits and possibly squash some others.
* The approach taken here is to have a custom semantic SoC-specific binding for each the gpio and pinmux drivers. Other alternatives suggested included:
1) A generic "list of register writes" to be performed at boot. This has the advantage of reusability across different SoCs. However, this approach isn't semantic, and requires detailed knowledge of pinmux registers and potentially fiddly calculations when constructing the device tree.
2) The ability to define disabled child nodes of the pinmux controller that are not processed by tegra_pinmux_probe_dt(). Other devices may refer to those using phandles, and later enable/disable them, thus representing dynamic pinmuxing in the device tree. I wasn't convinced whether we should represent dynamic pinmuxing using phandles.
I discussed in more detail why I prefer the current proposal in various email threads.
* tegra_pinmux_probe_dt() enumerates all legal pingroup names, and searches for a pinmux controller subnode of that name, then processes each one that is found. An alternative that some may prefer would be to enumerate each child node of the pinmux controller, and have each node contain an explicit pingroup name property instead. Does anyone have any preference here? I suppose the latter option would obviate the need to add of_find_child_node_by_name().
Thanks for reading!
Stephen Warren (12):
dt: Add of_find_child_node_by_name()
arm/tegra: Prep boards for gpio/pinmux conversion to pdevs arm/tegra: Avoid duplicate gpio/pinmux devices with dt arm/tegra: board-dt: Add AUXDATA for tegra-gpio and tegra-pinmux arm/dt: Tegra: Add nvidia,gpios property to GPIO controller arm/dt: Tegra: Add pinmux node
gpio/tegra: Convert to a platform device
gpio/tegra: Add device tree support
arm/tegra: Convert pinmux driver to a platform device arm/tegra: Add device tree support to pinmux driver arm/tegra: board-dt: Remove dependency on non-dt pinmux functions arm/tegra: Remove temporary gpio/pinmux registration workaround
arch/arm/boot/dts/tegra-harmony.dts | 479 ++++++++++++++++++++++++++ arch/arm/boot/dts/tegra-seaboard.dts | 409 ++++++++++++++++++++++ arch/arm/boot/dts/tegra20.dtsi | 5 + arch/arm/mach-tegra/Makefile | 1 - arch/arm/mach-tegra/board-dt.c | 12 +- arch/arm/mach-tegra/board-harmony-pinmux.c | 8 + arch/arm/mach-tegra/board-paz00-pinmux.c | 8 + arch/arm/mach-tegra/board-seaboard-pinmux.c | 9 +- arch/arm/mach-tegra/board-trimslice-pinmux.c | 7 + arch/arm/mach-tegra/devices.c | 10 + arch/arm/mach-tegra/devices.h | 2 + arch/arm/mach-tegra/pinmux.c | 136 ++++++++ drivers/gpio/gpio-tegra.c | 56 +++- drivers/of/base.c | 18 + include/linux/of.h | 2 + 15 files changed, 1138 insertions(+), 24 deletions(-)
RFC PATCH 1/12 dt: Add of_find_child_node_by_name()
This function retrieves a named child node of a given parent node.
--- drivers/of/base.c | 18 ++++++++++++++++++ include/linux/of.h | 2 ++ 2 files changed, 20 insertions(+), 0 deletions(-)
drivers/of/base.c +18 -0
@@ -388,6 +388,24 @@ struct device_node *of_find_node_by_name(struct device_node *from, }EXPORT_SYMBOL (of_find_node_by_name); +struct device_node *of_find_child_node_by_name ( +const struct device_node *parent,const char *name) +{ +struct device_node *child; + +read_lock (&devtree_lock); + +for_each_child_of_node (parent, child) { +if (!strcmp (child->name, name)) +break ; + } + +read_unlock (&devtree_lock); + +return child; +} +EXPORT_SYMBOL (of_find_child_node_by_name); +/** * of_find_node_by_type - Find a node by its "device_type" property * @from: The node to start searching from, or NULL to start searching
include/linux/of.h +2 -0
@@ -161,6 +161,8 @@ extern struct device_node *of_find_node_by_name(struct device_node *from,#define for_each_node_by_name (dn, name) \ for (dn = of_find_node_by_name(NULL, name); dn; \ dn = of_find_node_by_name(dn, name)) +extern struct device_node *of_find_child_node_by_name ( +const struct device_node *node,const char *name);extern struct device_node *of_find_node_by_type (struct device_node *from,const char *type);#define for_each_node_by_type (dn, type) \
Signature · 1 line
1.7.0.4
RFC PATCH 2/12 arm/tegra: Prep boards for gpio/pinmux conversion to pdevs
In reply to Stephen WarrenThe Tegra GPIO driver will be converted from static registration via postcore_initcall() to be a platform device later in this patch series. A new Tegra pinmux platform device will also be added.
Prepare for this by modifying all boards to register the appropriate platform devices before-hand, so that when the drivers are converted, those devices will be probed, and git bisectability will be maintained.
--- arch/arm/mach-tegra/board-harmony-pinmux.c | 8 ++++++++ arch/arm/mach-tegra/board-paz00-pinmux.c | 8 ++++++++ arch/arm/mach-tegra/board-seaboard-pinmux.c | 9 +++++++-- arch/arm/mach-tegra/board-trimslice-pinmux.c | 7 +++++++ arch/arm/mach-tegra/devices.c | 10 ++++++++++ arch/arm/mach-tegra/devices.h | 2 ++ 6 files changed, 42 insertions(+), 2 deletions(-)
arch/arm/mach-tegra/board-harmony-pinmux.c +8 -0
@@ -20,6 +20,7 @@#include "gpio-names.h" #include "board-harmony.h" +#include "devices.h" static struct tegra_pingroup_config harmony_pinmux[] = { {TEGRA_PINGROUP_ATA ,TEGRA_MUX_IDE ,TEGRA_PUPD_NORMAL ,TEGRA_TRI_NORMAL },
@@ -140,6 +141,11 @@ static struct tegra_pingroup_config harmony_pinmux[] = { {TEGRA_PINGROUP_XM2D, TEGRA_MUX_NONE, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL}, }; +static struct platform_device *pinmux_devices[] = { + &tegra_gpio_device, + &tegra_pinmux_device, +}; +static struct tegra_gpio_table gpio_table[] = { { .gpio =TEGRA_GPIO_SD2_CD , .enable = true }, { .gpio = TEGRA_GPIO_SD2_WP, .enable = true },
@@ -155,6 +161,8 @@ static struct tegra_gpio_table gpio_table[] = {void harmony_pinmux_init (void ) { +platform_add_devices (pinmux_devices,ARRAY_SIZE (pinmux_devices)); +tegra_pinmux_config_table (harmony_pinmux,ARRAY_SIZE (harmony_pinmux));tegra_gpio_config (gpio_table,ARRAY_SIZE (gpio_table));
arch/arm/mach-tegra/board-paz00-pinmux.c +8 -0
@@ -20,6 +20,7 @@#include "gpio-names.h" #include "board-paz00.h" +#include "devices.h" static struct tegra_pingroup_config paz00_pinmux[] = { {TEGRA_PINGROUP_ATA ,TEGRA_MUX_GMI ,TEGRA_PUPD_NORMAL ,TEGRA_TRI_NORMAL },
@@ -140,6 +141,11 @@ static struct tegra_pingroup_config paz00_pinmux[] = { {TEGRA_PINGROUP_XM2D, TEGRA_MUX_NONE, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL}, }; +static struct platform_device *pinmux_devices[] = { + &tegra_gpio_device, + &tegra_pinmux_device, +}; +static struct tegra_gpio_table gpio_table[] = { { .gpio =TEGRA_GPIO_SD1_CD , .enable = true }, { .gpio = TEGRA_GPIO_SD1_WP, .enable = true },
@@ -149,6 +155,8 @@ static struct tegra_gpio_table gpio_table[] = {void paz00_pinmux_init (void ) { +platform_add_devices (pinmux_devices,ARRAY_SIZE (pinmux_devices)); +tegra_pinmux_config_table (paz00_pinmux,ARRAY_SIZE (paz00_pinmux));tegra_gpio_config (gpio_table,ARRAY_SIZE (gpio_table));
arch/arm/mach-tegra/board-seaboard-pinmux.c +7 -2
@@ -21,6 +21,7 @@#include "gpio-names.h" #include "board-seaboard.h" +#include "devices.h" #define DEFAULT_DRIVE (_name) \ { \
@@ -157,8 +158,10 @@ static __initdata struct tegra_pingroup_config seaboard_pinmux[] = { {TEGRA_PINGROUP_XM2D, TEGRA_MUX_NONE, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL}, }; - - +static struct platform_device *pinmux_devices[] = { + &tegra_gpio_device, + &tegra_pinmux_device, +};static struct tegra_gpio_table gpio_table[] = { { .gpio = TEGRA_GPIO_SD2_CD, .enable = true },
@@ -173,6 +176,8 @@ static struct tegra_gpio_table gpio_table[] = {void __init seaboard_pinmux_init (void ) { +platform_add_devices (pinmux_devices,ARRAY_SIZE (pinmux_devices)); +tegra_pinmux_config_table (seaboard_pinmux,ARRAY_SIZE (seaboard_pinmux)); tegra_drive_pinmux_config_table(seaboard_drive_pinmux,
arch/arm/mach-tegra/board-trimslice-pinmux.c +7 -0
@@ -21,6 +21,7 @@#include "gpio-names.h" #include "board-trimslice.h" +#include "devices.h" static __initdata struct tegra_pingroup_config trimslice_pinmux[] = { {TEGRA_PINGROUP_ATA ,TEGRA_MUX_IDE ,TEGRA_PUPD_NORMAL ,TEGRA_TRI_TRISTATE },
@@ -141,6 +142,11 @@ static __initdata struct tegra_pingroup_config trimslice_pinmux[] = { {TEGRA_PINGROUP_XM2D, TEGRA_MUX_NONE, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL}, }; +static struct platform_device *pinmux_devices[] = { + &tegra_gpio_device, + &tegra_pinmux_device, +}; +static struct tegra_gpio_table gpio_table[] = { { .gpio =TRIMSLICE_GPIO_SD4_CD , .enable = true },/* mmc4 cd */ { .gpio = TRIMSLICE_GPIO_SD4_WP, .enable = true }, /* mmc4 wp */
@@ -151,6 +157,7 @@ static struct tegra_gpio_table gpio_table[] = {void __init trimslice_pinmux_init (void ) { +platform_add_devices (pinmux_devices,ARRAY_SIZE (pinmux_devices));tegra_pinmux_config_table (trimslice_pinmux,ARRAY_SIZE (trimslice_pinmux));tegra_gpio_config (gpio_table,ARRAY_SIZE (gpio_table)); }
arch/arm/mach-tegra/devices.c +10 -0
@@ -31,6 +31,16 @@#include <mach/usb_phy.h> #include "gpio-names.h" +struct platform_device tegra_gpio_device = { + .name ="tegra-gpio" , + .id =-1 , +}; + +struct platform_device tegra_pinmux_device = { + .name ="tegra-pinmux" , + .id =-1 , +}; +static struct resource i2c_resource1[] = { [0 ] = { .start =INT_I2C ,
arch/arm/mach-tegra/devices.h +2 -0
@@ -21,6 +21,8 @@#include <linux/platform_device.h> +extern struct platform_device tegra_gpio_device; +extern struct platform_device tegra_pinmux_device;extern struct platform_device tegra_sdhci_device1;extern struct platform_device tegra_sdhci_device2;extern struct platform_device tegra_sdhci_device3;
Signature · 1 line
1.7.0.4
RFC PATCH 3/12 arm/tegra: Avoid duplicate gpio/pinmux devices with dt
In reply to Stephen WarrenA future change will set up complete gpio and pinmux platform device registration in device-tree files, via board-dt.c. When board-dt.c calls into harmony/seaboard_pinmux_init(), this will cause a duplicate registration of those platform devices, which will kernel boot failure.
To solve this, modify so that it only
registers the platform devices when actually running on Harmony; when board-dt.c is in use, a different machine type is used.
This change is a temporary measure to ensure git bisectability. It will be reverted when board-dt.c no longer calls harmony/seaboard_pinmux_init().
--- arch/arm/mach-tegra/board-harmony-pinmux.c | 5 ++++- arch/arm/mach-tegra/board-seaboard-pinmux.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-)
arch/arm/mach-tegra/board-harmony-pinmux.c +4 -1
@@ -14,6 +14,8 @@* */ +#include <asm/mach-types.h> +#include <linux/kernel.h> #include <linux/gpio.h> #include <mach/pinmux.h>
@@ -161,7 +163,8 @@ static struct tegra_gpio_table gpio_table[] = {void harmony_pinmux_init (void ) { -platform_add_devices (pinmux_devices,ARRAY_SIZE (pinmux_devices)); +if (machine_is_harmony ()) +platform_add_devices (pinmux_devices,ARRAY_SIZE (pinmux_devices));tegra_pinmux_config_table (harmony_pinmux,ARRAY_SIZE (harmony_pinmux));
arch/arm/mach-tegra/board-seaboard-pinmux.c +4 -1
@@ -12,6 +12,8 @@* */ +#include <asm/mach-types.h> +#include <linux/kernel.h> #include <linux/init.h> #include <linux/gpio.h>
@@ -176,7 +178,8 @@ static struct tegra_gpio_table gpio_table[] = {void __init seaboard_pinmux_init (void ) { -platform_add_devices (pinmux_devices,ARRAY_SIZE (pinmux_devices)); +if (machine_is_seaboard ()) +platform_add_devices (pinmux_devices,ARRAY_SIZE (pinmux_devices));tegra_pinmux_config_table (seaboard_pinmux,ARRAY_SIZE (seaboard_pinmux));
Signature · 1 line
1.7.0.4
RFC PATCH 4/12 arm/tegra: board-dt: Add AUXDATA for tegra-gpio and tegra-pinmux
In reply to Stephen WarrenAdd AUXDATA so that Tegra GPIO and pinmux devices that are instantiated from device-tree are named consistently with the static platform devices in mach-tegra/devices.c. Note that the device-tree file tegra20.dtsi already includes a node for the Tegra GPIO controller, whereas the node for the Tegra pinmux controller will be added in a subsequent commit.
--- arch/arm/mach-tegra/board-dt.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
arch/arm/mach-tegra/board-dt.c +2 -0
@@ -50,6 +50,8 @@ void seaboard_pinmux_init(void);struct of_dev_auxdata tegra20_auxdata_lookup[]__initdata = { +OF_DEV_AUXDATA ("nvidia,tegra20-gpio" ,TEGRA_GPIO_BASE ,"tegra-gpio" ,NULL ), +OF_DEV_AUXDATA ("nvidia,tegra20-pinmux" ,TEGRA_APB_MISC_BASE ,"tegra-pinmux" ,NULL ),OF_DEV_AUXDATA ("nvidia,tegra20-sdhci" ,TEGRA_SDMMC1_BASE ,"sdhci-tegra.0" ,NULL ),OF_DEV_AUXDATA ("nvidia,tegra20-sdhci" ,TEGRA_SDMMC2_BASE ,"sdhci-tegra.1" ,NULL ),OF_DEV_AUXDATA ("nvidia,tegra20-sdhci" ,TEGRA_SDMMC3_BASE ,"sdhci-tegra.2" ,NULL ),
Signature · 1 line
1.7.0.4
RFC PATCH 5/12 arm/dt: Tegra: Add nvidia,gpios property to GPIO controller
In reply to Stephen WarrenAdd board-specific gpio node for Harmony and Seaboard. This lists the GPIOs used by the board. Note that not all GPIOs that exist on the board are listed; only those used by devices currently supported by device tree.
--- arch/arm/boot/dts/tegra-harmony.dts | 15 +++++++++++++++ arch/arm/boot/dts/tegra-seaboard.dts | 8 ++++++++ 2 files changed, 23 insertions(+), 0 deletions(-)
arch/arm/boot/dts/tegra-harmony.dts +15 -0
@@ -15,6 +15,21 @@ reg = < 0x00000000 0x40000000 >; }; + gpio: gpio at 6000d000 { + nvidia,gpios = < + 69 // TEGRA_GPIO_PI5 SD2_CD + 57 // TEGRA_GPIO_PH1 SD2_WP + 155 // TEGRA_GPIO_PT3 SD2_POWER + 58 // TEGRA_GPIO_PH2 SD4_CD + 59 // TEGRA_GPIO_PH3 SD4_WP + 70 // TEGRA_GPIO_PI6 SD4_POWER + 187 // TEGRA_GPIO_PX3 CDC_IRQ + 178 // TEGRA_GPIO_PW2 HP_DET + 184 // TEGRA_GPIO_PX0 INT_MIC_EN + 185 // TEGRA_GPIO_PX1 EXT_MIC_EN + >; + }; + i2c at 7000c000 { clock-frequency = <400000>;
arch/arm/boot/dts/tegra-seaboard.dts +8 -0
@@ -16,6 +16,14 @@ reg = < 0x00000000 0x40000000 >; }; + gpio: gpio at 6000d000 { + nvidia,gpios = < + 69 // TEGRA_GPIO_PI5 SD2_CD + 57 // TEGRA_GPIO_PH1 SD2_WP + 70 // TEGRA_GPIO_PI6 SD2_POWER + >; + }; + serial at 70006300 { clock-frequency = < 216000000 >; };
Signature · 1 line
1.7.0.4
Re: [RFC PATCH 05/12] arm/dt: Tegra: Add nvidia,gpios property to GPIO controller
Quoted 4 lines · Stephen Warren
Add board-specific gpio node for Harmony and Seaboard. This lists the GPIOs used by the board. Note that not all GPIOs that exist on the board are listed; only those used by devices currently supported by device tree.
I don't want to bikeshed over this, but something like "nvidia,enabled-gpios" could be a bit more descriptive. Either way is OK though.
The property should be documented under the bindings Documentation/ hierarchy though.
-Olof
RE: [RFC PATCH 05/12] arm/dt: Tegra: Add nvidia,gpios property to GPIO controller
Olof Johansson wrote at Sunday, August 14, 2011 1:02 AM:
Quoted 9 lines · Stephen Warren
Quoted 4 lines
Add board-specific gpio node for Harmony and Seaboard. This lists the GPIOs used by the board. Note that not all GPIOs that exist on the board are listed; only those used by devices currently supported by device tree.
I don't want to bikeshed over this, but something like "nvidia,enabled-gpios" could be a bit more descriptive. Either way is OK though.
Yes, that's a much better name.
Existing board files do have a Boolean enabled/disabled flag per GPIO, which is currently always true, whereas this patch series only implements "enabled" entries. I thought about it briefly, and didn't think that explicitly disabling GPIOs that the bootloader had already enabled was likely to be useful. Do you agree? Possibly not since IIRC you added the tables that contain that Boolean.
Quoted 2 lines
The property should be documented under the bindings
Documentation/hierarchy though.
Yup. The next posting will include this.
Signature · 1 line
nvpublic
RFC PATCH 6/12 arm/dt: Tegra: Add pinmux node
In reply to Stephen WarrenAdd a pinmux node to tegra20.dtsi in order to instantiate the future pinmux device. Add pinmux nodes to Harmony and Seaboard, which detail the entire default pinmux configuration. This configuration is identical to that in board-harmony/seaboard-pinmux.c.
--- arch/arm/boot/dts/tegra-harmony.dts | 464 ++++++++++++++++++++++++++++++++++ arch/arm/boot/dts/tegra-seaboard.dts | 401 +++++++++++++++++++++++++++++ arch/arm/boot/dts/tegra20.dtsi | 5 + 3 files changed, 870 insertions(+), 0 deletions(-)
arch/arm/boot/dts/tegra-harmony.dts +464 -0
@@ -30,6 +30,470 @@ >; }; + pinmux: pinmux at 70000000 { + ATA { + nvidia,function = "IDE"; + }; + ATB { + nvidia,function = "SDIO4"; + }; + ATC { + nvidia,function = "NAND"; + }; + ATD { + nvidia,function = "GMI"; + }; + ATE { + nvidia,function = "GMI"; + }; + CDEV1 { + nvidia,function = "PLLA_OUT"; + }; + CDEV2 { + nvidia,function = "PLLP_OUT4"; + nvidia,pull = "down"; + nvidia,tristate; + }; + CRTP { + nvidia,function = "CRT"; + nvidia,tristate; + }; + CSUS { + nvidia,function = "VI_SENSOR_CLK"; + nvidia,pull = "down"; + nvidia,tristate; + }; + DAP1 { + nvidia,function = "DAP1"; + }; + DAP2 { + nvidia,function = "DAP2"; + nvidia,tristate; + }; + DAP3 { + nvidia,function = "DAP3"; + nvidia,tristate; + }; + DAP4 { + nvidia,function = "DAP4"; + nvidia,tristate; + }; + DDC { + nvidia,function = "I2C2"; + nvidia,pull = "up"; + }; + DTA { + nvidia,function = "SDIO2"; + nvidia,pull = "up"; + }; + DTB { + nvidia,function = "RSVD1"; + }; + DTC { + nvidia,function = "RSVD1"; + nvidia,tristate; + }; + DTD { + nvidia,function = "SDIO2"; + nvidia,pull = "up"; + }; + DTE { + nvidia,function = "RSVD1"; + nvidia,tristate; + }; + DTF { + nvidia,function = "I2C3"; + nvidia,tristate; + }; + GMA { + nvidia,function = "SDIO4"; + }; + GMB { + nvidia,function = "GMI"; + }; + GMC { + nvidia,function = "UARTD"; + }; + GMD { + nvidia,function = "GMI"; + }; + GME { + nvidia,function = "SDIO4"; + }; + GPU { + nvidia,function = "GMI"; + nvidia,tristate; + }; + GPU7 { + nvidia,function = "RTCK"; + }; + GPV { + nvidia,function = "PCIE"; + nvidia,tristate; + }; + HDINT { + nvidia,function = "HDMI"; + nvidia,pull = "up"; + nvidia,tristate; + }; + I2CP { + nvidia,function = "I2C"; + }; + IRRX { + nvidia,function = "UARTA"; + nvidia,pull = "up"; + nvidia,tristate; + }; + IRTX { + nvidia,function = "UARTA"; + nvidia,pull = "up"; + nvidia,tristate; + }; + KBCA { + nvidia,function = "KBC"; + nvidia,pull = "up"; + }; + KBCB { + nvidia,function = "KBC"; + nvidia,pull = "up"; + }; + KBCC { + nvidia,function = "KBC"; + nvidia,pull = "up"; + }; + KBCD { + nvidia,function = "KBC"; + nvidia,pull = "up"; + }; + KBCE { + nvidia,function = "KBC"; + nvidia,pull = "up"; + }; + KBCF { + nvidia,function = "KBC"; + nvidia,pull = "up"; + }; + LCSN { + nvidia,function = "DISPLAYA"; + nvidia,pull = "up"; + nvidia,tristate; + }; + LD0 { + nvidia,function = "DISPLAYA"; + nvidia,pull = "down"; + }; + LD1 { + nvidia,function = "DISPLAYA"; + nvidia,pull = "down"; + }; + LD10 { + nvidia,function = "DISPLAYA"; + nvidia,pull = "down"; + }; + LD11 { + nvidia,function = "DISPLAYA"; + nvidia,pull = "down"; + }; + LD12 { + nvidia,function = "DISPLAYA"; + nvidia,pull = "down"; + }; + LD13 { + nvidia,function = "DISPLAYA"; + nvidia,pull = "down"; + }; + LD14 { + nvidia,function = "DISPLAYA"; + nvidia,pull = "down"; + }; + LD15 { + nvidia,function = "DISPLAYA"; + nvidia,pull = "down"; + }; + LD16 { + nvidia,function = "DISPLAYA"; + nvidia,pull = "down"; + }; + LD17 { + nvidia,function = "DISPLAYA"; + nvidia,pull = "down"; + }; + LD2 { + nvidia,function = "DISPLAYA"; + nvidia,pull = "down"; + }; + LD3 { + nvidia,function = "DISPLAYA"; + nvidia,pull = "down"; + }; + LD4 { + nvidia,function = "DISPLAYA"; + nvidia,pull = "down"; + }; + LD5 { + nvidia,function = "DISPLAYA"; + nvidia,pull = "down"; + }; + LD6 { + nvidia,function = "DISPLAYA"; + nvidia,pull = "down"; + }; + LD7 { + nvidia,function = "DISPLAYA"; + nvidia,pull = "down"; + }; + LD8 { + nvidia,function = "DISPLAYA"; + nvidia,pull = "down"; + }; + LD9 { + nvidia,function = "DISPLAYA"; + nvidia,pull = "down"; + }; + LDC { + nvidia,function = "DISPLAYA"; + nvidia,pull = "up"; + nvidia,tristate; + }; + LDI { + nvidia,function = "DISPLAYA"; + nvidia,pull = "down"; + }; + LHP0 { + nvidia,function = "DISPLAYA"; + nvidia,pull = "down"; + }; + LHP1 { + nvidia,function = "DISPLAYA"; + nvidia,pull = "down"; + }; + LHP2 { + nvidia,function = "DISPLAYA"; + nvidia,pull = "down"; + }; + LHS { + nvidia,function = "DISPLAYA"; + nvidia,pull = "up"; + }; + LM0 { + nvidia,function = "DISPLAYA"; + nvidia,pull = "up"; + }; + LM1 { + nvidia,function = "DISPLAYA"; + nvidia,pull = "up"; + nvidia,tristate; + }; + LPP { + nvidia,function = "DISPLAYA"; + nvidia,pull = "down"; + }; + LPW0 { + nvidia,function = "DISPLAYA"; + nvidia,pull = "up"; + }; + LPW1 { + nvidia,function = "DISPLAYA"; + nvidia,pull = "up"; + nvidia,tristate; + }; + LPW2 { + nvidia,function = "DISPLAYA"; + nvidia,pull = "up"; + }; + LSC0 { + nvidia,function = "DISPLAYA"; + nvidia,pull = "up"; + }; + LSC1 { + nvidia,function = "DISPLAYA"; + nvidia,pull = "up"; + nvidia,tristate; + }; + LSCK { + nvidia,function = "DISPLAYA"; + nvidia,pull = "up"; + nvidia,tristate; + }; + LSDA { + nvidia,function = "DISPLAYA"; + nvidia,pull = "up"; + nvidia,tristate; + }; + LSDI { + nvidia,function = "DISPLAYA"; + nvidia,pull = "up"; + nvidia,tristate; + }; + LSPI { + nvidia,function = "DISPLAYA"; + nvidia,pull = "up"; + }; + LVP0 { + nvidia,function = "DISPLAYA"; + nvidia,pull = "up"; + nvidia,tristate; + }; + LVP1 { + nvidia,function = "DISPLAYA"; + nvidia,pull = "down"; + }; + LVS { + nvidia,function = "DISPLAYA"; + nvidia,pull = "up"; + }; + OWC { + nvidia,function = "RSVD2"; + nvidia,pull = "up"; + nvidia,tristate; + }; + PMC { + nvidia,function = "PWR_ON"; + }; + PTA { + nvidia,function = "HDMI"; + }; + RM { + nvidia,function = "I2C"; + }; + SDB { + nvidia,function = "PWM"; + nvidia,tristate; + }; + SDC { + nvidia,function = "PWM"; + nvidia,pull = "up"; + }; + SDD { + nvidia,function = "PWM"; + nvidia,pull = "up"; + nvidia,tristate; + }; + SDIO1 { + nvidia,function = "SDIO1"; + nvidia,tristate; + }; + SLXA { + nvidia,function = "PCIE"; + nvidia,tristate; + }; + SLXC { + nvidia,function = "SPDIF"; + nvidia,tristate; + }; + SLXD { + nvidia,function = "SPDIF"; + nvidia,tristate; + }; + SLXK { + nvidia,function = "PCIE"; + nvidia,tristate; + }; + SPDI { + nvidia,function = "RSVD2"; + nvidia,tristate; + }; + SPDO { + nvidia,function = "RSVD2"; + nvidia,tristate; + }; + SPIA { + nvidia,function = "GMI"; + }; + SPIB { + nvidia,function = "GMI"; + }; + SPIC { + nvidia,function = "GMI"; + nvidia,pull = "up"; + nvidia,tristate; + }; + SPID { + nvidia,function = "SPI1"; + nvidia,pull = "down"; + nvidia,tristate; + }; + SPIE { + nvidia,function = "SPI1"; + nvidia,pull = "up"; + nvidia,tristate; + }; + SPIF { + nvidia,function = "SPI1"; + nvidia,pull = "down"; + nvidia,tristate; + }; + SPIG { + nvidia,function = "SPI2_ALT"; + nvidia,tristate; + }; + SPIH { + nvidia,function = "SPI2_ALT"; + nvidia,pull = "up"; + nvidia,tristate; + }; + UAA { + nvidia,function = "ULPI"; + nvidia,pull = "up"; + nvidia,tristate; + }; + UAB { + nvidia,function = "ULPI"; + nvidia,pull = "up"; + nvidia,tristate; + }; + UAC { + nvidia,function = "RSVD2"; + nvidia,tristate; + }; + UAD { + nvidia,function = "IRDA"; + nvidia,pull = "up"; + nvidia,tristate; + }; + UCA { + nvidia,function = "UARTC"; + nvidia,pull = "up"; + nvidia,tristate; + }; + UCB { + nvidia,function = "UARTC"; + nvidia,pull = "up"; + nvidia,tristate; + }; + UDA { + nvidia,function = "ULPI"; + nvidia,tristate; + }; + CK32 { + nvidia,function = "NONE"; + }; + DDRC { + nvidia,function = "NONE"; + }; + PMCA { + nvidia,function = "NONE"; + }; + PMCB { + nvidia,function = "NONE"; + }; + PMCC { + nvidia,function = "NONE"; + }; + PMCD { + nvidia,function = "NONE"; + }; + PMCE { + nvidia,function = "NONE"; + }; + XM2C { + nvidia,function = "NONE"; + }; + XM2D { + nvidia,function = "NONE"; + }; + }; + i2c at 7000c000 { clock-frequency = <400000>;
arch/arm/boot/dts/tegra-seaboard.dts +401 -0
407 lines not on this page · raw message
arch/arm/boot/dts/tegra20.dtsi +5 -0
@@ -77,6 +77,11 @@ gpio-controller; }; + pinmux: pinmux at 70000000 { + compatible = "nvidia,tegra20-pinmux"; + reg = < 0x70000000 0xc00 >; + }; + serial at 70006000 { compatible = "nvidia,tegra20-uart"; reg = <0x70006000 0x40>;
Signature · 1 line
1.7.0.4
Re: [RFC PATCH 06/12] arm/dt: Tegra: Add pinmux node
Hi,
Quoted 4 lines · Stephen Warren
Add a pinmux node to
tegra20.dtsiin order to instantiate the future pinmux device. Add pinmux nodes to Harmony and Seaboard, which detail the entire default pinmux configuration. This configuration is identical to that inboard-harmony/seaboard-pinmux.c.
Again, documentation for the binding is needed.
Seeing the table coded up now though, I wonder if it could make sense to flip it around? The number of functions multiplexed out are fewer than the pin groups (and this would be even more true on platforms that have per-pin configurations and/or smaller groups).
I.e. something like:
sdio4 {
nvidia,pingroups = < DTA DTD >; // Not sure how to
reference this though -- integers would be hard to read. DTA/DTD aren't valid values in the syntax.
nvidia,pull-up
},And any pingroups not covered by a function would be left alone (one could easily define a few no-op functions to set pull up/down and tristate values on the unused groups).
[...]
Quoted 2 lines
+ ? ? ? pinmux: pinmux at 70000000 {
+ ? ? ? ? ? ? ? ATA {
I would prefer seeing these in lower case (since device tree tends to be no-caps). Should be easy to switch to strcasecmp in the code.
[...]
Quoted 2 lines
+ ? ? ? ? ? ? ? CDEV2 {
+ ? ? ? ? ? ? ? ? ? ? ? nvidia,function = "PLLP_OUT4";
The string here is a bit unfortunate. It's really just used to map from the string to an integer anyway, with the reverse mapping being produced by the debugfs output. But especially if the function is flipped above, the different pingroups referenced might not use the same value for each function, so some sort of lookup will still be needed. Not much to do about, it seems. :(
Quoted 1 line
+ ? ? ? ? ? ? ? ? ? ? ? nvidia,pull = "down";
This should be done by discrete properties instead: nvidia,pull-up, nvidia-pull-down (and omitted means normal), without values.
-Olof
RE: [RFC PATCH 06/12] arm/dt: Tegra: Add pinmux node
Olof Johansson wrote at Sunday, August 14, 2011 1:25 AM:
Quoted 7 lines · Stephen Warren
Quoted 4 lines
Add a pinmux node to
tegra20.dtsiin order to instantiate the future pinmux device. Add pinmux nodes to Harmony and Seaboard, which detail the entire default pinmux configuration. This configuration is identical to that inboard-harmony/seaboard-pinmux.c.Again, documentation for the binding is needed.
Yes. It should have been there, but I screwed up.
Quoted 4 lines
Seeing the table coded up now though, I wonder if it could make sense to flip it around? The number of functions multiplexed out are fewer than the pin groups (and this would be even more true on platforms that have per-pin configurations and/or smaller groups).
There are 116 pin groups and 61 functions, so this certainly would reduce the size of the tree.
Quoted 10 lines
I.e. something like:
sdio4 {
nvidia,pingroups = < DTA DTD >; // Not sure how to
reference this though -- integers would be hard to read. DTA/DTD aren't valid values in the syntax.nvidia,pull-up },And any pingroups not covered by a function would be left alone
I'm personally inclined not to do this.
a) The HW registers are laid out such that each pingroup has various properties, so the current binding represents that directly. That said, inverting the table would contain exactly the same data, so this argument is slightly tenuous/arbitrary, except that:
b) I think we'd still need tristate and pull properties per pin-group either way; within a given special function, I see no reason for every pingroup to need the same pull/tristate values (otherwise, I imagine the Tegra HW designers would have lumped all the pins into a single pingroup already). For example, an interface with data and control signals might need pullups on control signals, but none on data.
c) Similar to that, a RSVD/NONE (or otherwise unused) function might be used for a bunch of pingroups that are in fact used by GPIOs, and hence only the pull/tristate values are relevant, since the GPIO controller will actually control the data on the line. In this case, there's no reason to assume that different pingroups that have the same function are related in any way, and hence should have the same pull/tristate.
Given, b/c, we'd need an array of pull/tristate values per pingroup within a given function, and I think the syntax for that would be sufficiently complex that the binding in the current patchset makes more sense.
Do you agree?
Quoted 3 lines
(one
could easily define a few no-op functions to set pull up/down and tristate values on the unused groups).
The binding (and original pinmux code) does define RSVD1/2/3/4 functions for the case where a pingroup should be programmed to an unused/quiescent state. There's also a NONE function for the pingroups that don't support muxing, but just pullup/down and tristate.
Quoted 7 lines
[...]
Quoted 2 lines
+ ? ? ? pinmux: pinmux at 70000000 {
+ ? ? ? ? ? ? ? ATA {I would prefer seeing these in lower case (since device tree tends to be no-caps). Should be easy to switch to strcasecmp in the code.
Sure.
Quoted 10 lines
[...]
Quoted 2 lines
+ ? ? ? ? ? ? ? CDEV2 {
+ ? ? ? ? ? ? ? ? ? ? ? nvidia,function = "PLLP_OUT4";The string here is a bit unfortunate. It's really just used to map from the string to an integer anyway, with the reverse mapping being produced by the debugfs output. But especially if the function is flipped above, the different pingroups referenced might not use the same value for each function, so some sort of lookup will still be needed. Not much to do about, it seems. :(
I originally considered syntax like:
nvidia,function = <33>; // PLLP_OUT4
However, I figured this was problematic because:
a) Calculating the integers would be problematic; pinmux.h doesn't currently list the integer for each value in enum tegra_mux_func, although I suppose it and the binding documentation could easily be modified to do so.
b) With just an integer, it's much harder to know what the value means.
c) With both the integer and comment, they can get out of sync if incorrectly edited.
I'd be much more included to use integers if the *.dts files wer run though the pre-processor, and hence defines could be used. I do observe that Documentation/devicetree/booting-without-of.txt says:
It is also suggested that you pipe your source file through cpp (gcc preprocessor) so you can use #include's, #define for constants, etc...
Quoted 4 lines
Quoted 1 line
+ ? ? ? ? ? ? ? ? ? ? ? nvidia,pull = "down";
This should be done by discrete properties instead: nvidia,pull-up, nvidia-pull-down (and omitted means normal), without values.
OK.
Signature · 1 line
nvpublic
RFC PATCH 7/12 gpio/tegra: Convert to a platform device
In reply to Stephen Warren--- drivers/gpio/gpio-tegra.c | 25 ++++++++++++++----------- 1 files changed, 14 insertions(+), 11 deletions(-)
drivers/gpio/gpio-tegra.c +14 -11
@@ -20,10 +20,10 @@#include <linux/init.h> #include <linux/irq.h> #include <linux/interrupt.h> -#include <linux/io.h> #include <linux/gpio.h> #include <linux/of.h> +#include <linux/platform_device.h> #include <asm/mach/irq.h>
@@ -332,7 +332,7 @@ static struct irq_chip tegra_gpio_irq_chip = {*/ static struct lock_class_key gpio_lock_class; -static int __init tegra_gpio_init (void ) +static int __init tegra_gpio_probe (struct platform_device *pdev) {struct tegra_gpio_bank *bank;int gpio;
@@ -346,15 +346,6 @@ static int __init tegra_gpio_init(void) } } -#ifdef CONFIG_OF_GPIO -/* -* This isn't ideal, but it gets things hooked up until this -* driver is converted into a platform_device -*/ - tegra_gpio_chip.of_node =of_find_compatible_node (NULL ,NULL , -"nvidia,tegra20-gpio" ); -#endif /* CONFIG_OF_GPIO */ -gpiochip_add (&tegra_gpio_chip);for (gpio =0 ; gpio <TEGRA_NR_GPIOS ; gpio++) {
@@ -383,6 +374,18 @@ static int __init tegra_gpio_init(void)return 0 ; } +static struct platform_driver tegra_gpio_driver = { + .driver = { + .name ="tegra-gpio" , + .owner =THIS_MODULE , + }, + .probe = tegra_gpio_probe, +}; + +static int __init tegra_gpio_init (void ) +{ +return platform_driver_register (&tegra_gpio_driver); +}postcore_initcall (tegra_gpio_init);void __init tegra_gpio_config (struct tegra_gpio_table *table,int num)
Signature · 1 line
1.7.0.4
RFC PATCH 8/12 gpio/tegra: Add device tree support
In reply to Stephen Warren--- drivers/gpio/gpio-tegra.c | 31 +++++++++++++++++++++++++++++++ 1 files changed, 31 insertions(+), 0 deletions(-)
drivers/gpio/gpio-tegra.c +31 -0
@@ -326,6 +326,29 @@ static struct irq_chip tegra_gpio_irq_chip = {#endif }; +#ifdef CONFIG_OF +static void __init tegra_gpio_probe_dt (struct platform_device *pdev) +{ +const __be32 *gpios; +u32 gpioslen; +int i; + + gpios =of_get_property (pdev->dev.of_node,"nvidia,gpios" , &gpioslen); +if (gpios ==NULL ) +return ; + + gpioslen /=sizeof (*gpios); +for (i =0 ; i < gpioslen; i++, gpios++) { +u32 gpio =be32_to_cpup (gpios); +dev_err (&pdev->dev,"Enabling GPIO %d\n" , gpio); +tegra_gpio_enable (gpio); + } +} +#else +static inline void __init tegra_gpio_probe_dt (struct platform_device *pdev) +{ +} +#endif /* This lock class tells lockdep that GPIO irqs are in a different * category than their parents, so it won't report false recursion.
@@ -371,13 +394,21 @@ static int __init tegra_gpio_probe(struct platform_device *pdev)spin_lock_init (&bank->lvl_lock[j]); } +tegra_gpio_probe_dt (pdev); +return 0 ; } +static struct of_device_id tegra_gpio_of_match[]__devinitdata = { + { .compatible ="nvidia,tegra20-gpio" , }, + { }, +}; +static struct platform_driver tegra_gpio_driver = { .driver = { .name ="tegra-gpio" , .owner =THIS_MODULE , + .of_match_table = tegra_gpio_of_match, }, .probe = tegra_gpio_probe, };
Signature · 1 line
1.7.0.4
Re: [RFC PATCH 08/12] gpio/tegra: Add device tree support
Quoted 18 lines · Stephen Warren
Signed-off-by Stephen Warren <[email protected]>---
?drivers/gpio/gpio-tegra.c | ? 31 +++++++++++++++++++++++++++++++ ?1 files changed, 31 insertions(+), 0 deletions(-)drivers/gpio/gpio-tegra.c +0
-0@@ -326,6 +326,29 @@ static struct irq_chip tegra_gpio_irq_chip = {?#endif
?};drivers/gpio/gpio-tegra.c +5
-0+#ifdef CONFIG_OF +static void __init tegra_gpio_probe_dt (struct platform_device *pdev) +{ + ? ? ? const __be32 *gpios; + ? ? ? u32 gpioslen;
drivers/gpio/gpio-tegra.c
Quoted 10 lines
drivers/gpio/gpio-tegra.c +10
-0+ ? ? ? int i; + + ? ? ? gpios = of_get_property(pdev->dev.of_node, "nvidia,gpios", &gpioslen); + ? ? ? if (gpios == NULL) + ? ? ? ? ? ? ? return; + + ? ? ? gpioslen /= sizeof(*gpios); + ? ? ? for (i = 0; i < gpioslen; i++, gpios++) { + ? ? ? ? ? ? ? u32 gpio = be32_to_cpup(gpios); + ? ? ? ? ? ? ? dev_err(&pdev->dev, "Enabling GPIO %d\n", gpio);
Is really necessary to print all enabled gpio's to console? Also seen same in pinmux probe.
Quoted 36 lines
+ ? ? ? ? ? ? ?
tegra_gpio_enable(gpio);
+ ? ? ? }drivers/gpio/gpio-tegra.c +6
-0+} +#else +static inline void __init tegra_gpio_probe_dt (struct platform_device *pdev) +{ +} +#endif ?/* This lock class tells lockdep that GPIO irqs are in a different ?* category than their parents, so it won't report false recursion.
drivers/gpio/gpio-tegra.c +8
-1@@ -371,13 +394,21 @@ static int __init tegra_gpio_probe(struct platform_device *pdev) ? ? ? ? ? ? ? ? ? ? ? ?spin_lock_init(&bank->lvl_lock[j]); ? ? ? ?} + ? ? ? tegra_gpio_probe_dt(pdev); + ? ? ? ?return 0; ?} +static struct of_device_id tegra_gpio_of_match[]__devinitdata = { + ? ? ? { .compatible = "nvidia,tegra20-gpio", }, + ? ? ? { }, +}; + ?static struct platform_driver tegra_gpio_driver = { ? ? ? ?.driver ? ? ? ? = { ? ? ? ? ? ? ? ?.name ? = "tegra-gpio", ? ? ? ? ? ? ? ?.owner ?= THIS_MODULE, + ? ? ? ? ? ? ? .of_match_table = tegra_gpio_of_match, ? ? ? ?}, ? ? ? ?.probe ? ? ? ? ?= tegra_gpio_probe, ?}; --1.7.0.4
Quoted 6 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo at vger.kernel.org
More majordomo info at ?http://vger.kernel.org/majordomo-info.html Please read the FAQ at ?http://www.tux.org/lkml/
regards,
marek
Signature · 10 lines
as simple and primitive as possible ------------------------------------------------- Marek Belisko - OPEN-NANDRA Freelance Developer Ruska Nova Ves 219 | Presov, 08005 Slovak Republic Tel: +421 915 052 184 skype: marekwhite icq: 290551086 web: http://open-nandra.com
RE: [RFC PATCH 08/12] gpio/tegra: Add device tree support
Belisko Marek wrote at Saturday, August 13, 2011 3:49 AM:
Quoted 7 lines · Stephen Warren
Quoted 6 lines
Signed-off-by Stephen Warren <[email protected]>---
?drivers/gpio/gpio-tegra.c | ? 31 +++++++++++++++++++++++++++++++ ?1 files changed, 31 insertions(+), 0 deletions(-)drivers/gpio/gpio-tegra.c +0
-0
...
Quoted 9 lines
Quoted 9 lines
drivers/gpio/gpio-tegra.c +9
-0+static void __init tegra_gpio_probe_dt (struct platform_device *pdev) +{ + ? ? ? const __be32 *gpios; + ? ? ? u32 gpioslen; + ? ? ? int i; + + ? ? ? gpios = of_get_property(pdev->dev.of_node, "nvidia,gpios", &gpioslen); + ? ? ? if (gpios == NULL) + ? ? ? ? ? ? ? return;
Quoted 8 lines
Quoted 5 lines
+
+ ? ? ? gpioslen /=sizeof(*gpios);
+ ? ? ? for (i = 0; i < gpioslen; i++, gpios++) {
+ ? ? ? ? ? ? ? u32 gpio =be32_to_cpup(gpios);
+ ? ? ? ? ? ? ?dev_err(&pdev->dev, "Enabling GPIO %d\n", gpio);Is really necessary to print all enabled gpio's to console? Also seen same in pinmux probe.
Oops, that's certainly not necessary. That was debugging code, and I meant to convert to dev_dbg before posting.
Signature · 1 line
nvpublic
RFC PATCH 9/12 arm/tegra: Convert pinmux driver to a platform device
In reply to Stephen Warren--- arch/arm/mach-tegra/pinmux.c | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-)
arch/arm/mach-tegra/pinmux.c +21 -0
@@ -20,6 +20,7 @@#include <linux/errno.h> #include <linux/spinlock.h> #include <linux/io.h> +#include <linux/platform_device.h> #include <mach/iomap.h> #include <mach/pinmux.h>
@@ -665,6 +666,26 @@ void tegra_pinmux_config_pullupdown_table(const struct tegra_pingroup_config *co } } +static int __init tegra_pinmux_probe (struct platform_device *pdev) +{ +return 0 ; +} + +static struct platform_driver tegra_pinmux_driver = { + .driver = { + .name ="tegra-pinmux" , + .owner =THIS_MODULE , + }, + .probe = tegra_pinmux_probe, +}; + +static int __init tegra_pinmux_init (void ) +{ +return platform_driver_register (&tegra_pinmux_driver); +} +postcore_initcall (tegra_pinmux_init); + +#ifdef CONFIG_DEBUG_FS #include <linux/debugfs.h>
Signature · 1 line
1.7.0.4
RFC PATCH 10/12 arm/tegra: Add device tree support to pinmux driver
In reply to Stephen Warren--- arch/arm/mach-tegra/pinmux.c | 115 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 115 insertions(+), 0 deletions(-)
arch/arm/mach-tegra/pinmux.c +115 -0
@@ -20,6 +20,7 @@#include <linux/errno.h> #include <linux/spinlock.h> #include <linux/io.h> +#include <linux/of.h> #include <linux/platform_device.h> #include <mach/iomap.h>
@@ -147,6 +148,41 @@ static const char *func_name(enum tegra_mux_func func)return tegra_mux_names[func]; } +#ifdef CONFIG_OF +static int func_enum (const char *name,enum tegra_mux_func *func_out) +{ +int func; + +if (!strcmp (name,"RSVD1" )) { + *func_out =TEGRA_MUX_RSVD1 ; +return 0 ; + } +if (!strcmp (name,"RSVD2" )) { + *func_out =TEGRA_MUX_RSVD2 ; +return 0 ; + } +if (!strcmp (name,"RSVD3" )) { + *func_out =TEGRA_MUX_RSVD3 ; +return 0 ; + } +if (!strcmp (name,"RSVD4" )) { + *func_out =TEGRA_MUX_RSVD4 ; +return 0 ; + } +if (!strcmp (name,"NONE" )) { + *func_out =TEGRA_MUX_NONE ; +return 0 ; + } + +for (func =0 ; func <TEGRA_MAX_MUX ; func++) +if (!strcmp (name, tegra_mux_names[func])) { + *func_out = func; +return 0 ; + } + +return -EINVAL ; +} +#endif static const char *tri_name (unsigned long val) {
@@ -666,15 +702,94 @@ void tegra_pinmux_config_pullupdown_table(const struct tegra_pingroup_config *co } } +#ifdef CONFIG_OF +static void __init tegra_pinmux_probe_dt (struct platform_device *pdev) +{ +int pg; + +for (pg =0 ; pg <TEGRA_MAX_PINGROUP ; pg++) { +const char *pg_name =pingroup_name (pg); +struct tegra_pingroup_config config; +struct device_node *pg_node; +int ret; +const char *s; + + pg_node =of_find_child_node_by_name (pdev->dev.of_node, + pg_name); +if (pg_node ==NULL ) +continue ; + + config.pingroup = pg; + + ret =of_property_read_string (pg_node,"nvidia,function" , &s); +if (ret <0 ) { +dev_err (&pdev->dev, +"%s: Missing property nvidia,function\n" , + pg_name); +continue ; + } + ret =func_enum (s, &config.func); +if (ret <0 ) { +dev_err (&pdev->dev, +"%s: Invalid nvidia,function value %s\n" , + pg_name, s); +continue ; + } + + ret =of_property_read_string (pg_node,"nvidia,pull" , &s); +if (ret >=0 ) { +if (!strcmp (s,"up" )) + config.pupd =TEGRA_PUPD_PULL_UP ; +else if (!strcmp (s,"down" )) + config.pupd =TEGRA_PUPD_PULL_DOWN ; +else if (!strcmp (s,"normal" )) + config.pupd =TEGRA_PUPD_NORMAL ; +else { +dev_err (&pdev->dev, +"%s: Invalid nvidia,pull value %s\n" , + pg_name, s); +continue ; + } + }else + config.pupd =TEGRA_PUPD_NORMAL ; + +if (of_find_property (pg_node,"nvidia,tristate" ,NULL )) + config.tristate =TEGRA_TRI_TRISTATE ; +else + config.tristate =TEGRA_TRI_NORMAL ; + +dev_err (&pdev->dev,"%s: func %d (%s) pull %d tri %d\n" , + pg_name, config.func,func_name (config.func), + config.pupd, config.tristate); + +tegra_pinmux_config_pingroup (&config); + +of_node_put (pg_node); + } +} +#else +static inline void __init tegra_pinmux_probe_dt (struct platform_device *pdev) +{ +} +#endif +static int __init tegra_pinmux_probe (struct platform_device *pdev) { +tegra_pinmux_probe_dt (pdev); +return 0 ; } +static struct of_device_id tegra_pinmux_of_match[]__devinitdata = { + { .compatible ="nvidia,tegra20-pinmux" , }, + { }, +}; +static struct platform_driver tegra_pinmux_driver = { .driver = { .name ="tegra-pinmux" , .owner =THIS_MODULE , + .of_match_table = tegra_pinmux_of_match, }, .probe = tegra_pinmux_probe, };
Signature · 1 line
1.7.0.4
Re: [RFC PATCH 10/12] arm/tegra: Add device tree support to pinmux driver
Hi Stephen,
Quoted 69 lines · Stephen Warren
Signed-off-by Stephen Warren <[email protected]>--- arch/arm/mach-tegra/pinmux.c | 115 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 115 insertions(+), 0 deletions(-)arch/arm/mach-tegra/pinmux.c +42
-0@@ -20,6 +20,7 @@#include <linux/errno.h> #include <linux/spinlock.h> #include <linux/io.h> +#include <linux/of.h> #include <linux/platform_device.h> #include <mach/iomap.h> @@ -147,6 +148,41 @@ static const char *func_name(enum tegra_mux_func func)return tegra_mux_names[func]; } +#ifdef CONFIG_OF +static int func_enum (const char *name,enum tegra_mux_func *func_out) +{ +int func; + +if (!strcmp (name,"RSVD1" )) { + *func_out =TEGRA_MUX_RSVD1 ; +return 0 ; + } +if (!strcmp (name,"RSVD2" )) { + *func_out =TEGRA_MUX_RSVD2 ; +return 0 ; + } +if (!strcmp (name,"RSVD3" )) { + *func_out =TEGRA_MUX_RSVD3 ; +return 0 ; + } +if (!strcmp (name,"RSVD4" )) { + *func_out =TEGRA_MUX_RSVD4 ; +return 0 ; + } +if (!strcmp (name,"NONE" )) { + *func_out =TEGRA_MUX_NONE ; +return 0 ; + } + +for (func =0 ; func <TEGRA_MAX_MUX ; func++) +if (!strcmp (name, tegra_mux_names[func])) { + *func_out = func; +return 0 ; + } + +return -EINVAL ; +} +#endif static const char *tri_name (unsigned long val) {@@ -666,15 +702,94 @@ void tegra_pinmux_config_pullupdown_table(const struct tegra_pingroup_config *co } } +#ifdef CONFIG_OF +static void __init tegra_pinmux_probe_dt (struct platform_device *pdev) +{ +int pg; + +for (pg =0 ; pg <TEGRA_MAX_PINGROUP ; pg++) {
arch/arm/mach-tegra/pinmux.c void tegra_pinmux_config_pullupdown_table(const struct tegra_pingroup_config *co · line 720
Quoted 10 lines
arch/arm/mach-tegra/pinmux.c +10
-0+const char *pg_name =pingroup_name (pg); +struct tegra_pingroup_config config; +struct device_node *pg_node; +int ret; +const char *s; + + pg_node =of_find_child_node_by_name (pdev->dev.of_node, + pg_name); +if (pg_node ==NULL ) +continue ;
Rather than iterating over all of the mux names in the pinmux driver and searching for a matching DT node, could you not do it the other way round? So do an for_each_child_of_node() on the pinmux node then find the matching pingroup keyed by the node name? This would eliminate of_find_child_node_by_name(). You could also catch invalid configurations for non-existent pins this way.
Jamie
Re: [RFC PATCH 10/12] arm/tegra: Add device tree support to pinmux driver
Quoted 81 lines · Jamie Iles
Hi Stephen,
Quoted 78 lines · Stephen Warren
Signed-off-by Stephen Warren <[email protected]>--- arch/arm/mach-tegra/pinmux.c | 115 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 115 insertions(+), 0 deletions(-)arch/arm/mach-tegra/pinmux.c +51
-0@@ -20,6 +20,7 @@#include <linux/errno.h> #include <linux/spinlock.h> #include <linux/io.h> +#include <linux/of.h> #include <linux/platform_device.h> #include <mach/iomap.h> @@ -147,6 +148,41 @@ static const char *func_name(enum tegra_mux_func func)return tegra_mux_names[func]; } +#ifdef CONFIG_OF +static int func_enum (const char *name,enum tegra_mux_func *func_out) +{ +int func; + +if (!strcmp (name,"RSVD1" )) { + *func_out =TEGRA_MUX_RSVD1 ; +return 0 ; + } +if (!strcmp (name,"RSVD2" )) { + *func_out =TEGRA_MUX_RSVD2 ; +return 0 ; + } +if (!strcmp (name,"RSVD3" )) { + *func_out =TEGRA_MUX_RSVD3 ; +return 0 ; + } +if (!strcmp (name,"RSVD4" )) { + *func_out =TEGRA_MUX_RSVD4 ; +return 0 ; + } +if (!strcmp (name,"NONE" )) { + *func_out =TEGRA_MUX_NONE ; +return 0 ; + } + +for (func =0 ; func <TEGRA_MAX_MUX ; func++) +if (!strcmp (name, tegra_mux_names[func])) { + *func_out = func; +return 0 ; + } + +return -EINVAL ; +} +#endif static const char *tri_name (unsigned long val) {@@ -666,15 +702,94 @@ void tegra_pinmux_config_pullupdown_table(const struct tegra_pingroup_config *co } } +#ifdef CONFIG_OF +static void __init tegra_pinmux_probe_dt (struct platform_device *pdev) +{ +int pg; + +for (pg =0 ; pg <TEGRA_MAX_PINGROUP ; pg++) { +const char *pg_name =pingroup_name (pg); +struct tegra_pingroup_config config; +struct device_node *pg_node; +int ret; +const char *s; + + pg_node =of_find_child_node_by_name (pdev->dev.of_node, + pg_name); +if (pg_node ==NULL )
Quoted 8 lines
arch/arm/mach-tegra/pinmux.c void tegra_pinmux_config_pullupdown_table(const struct tegra_pingroup_config *co · line 720
Quoted 1 line
arch/arm/mach-tegra/pinmux.c +1
-0+continue ;Rather than iterating over all of the mux names in the pinmux driver and searching for a matching DT node, could you not do it the other way round? So do an
for_each_child_of_node()on the pinmux node then find the matching pingroup keyed by the node name? This would eliminateof_find_child_node_by_name(). You could also catch invalid configurations for non-existent pins this way.
I just re-read your introduction email and saw you've already discussed this! Would this require an explicit pin name property though or could you just key off of the pg_node->name?
Jamie
RE: [RFC PATCH 10/12] arm/tegra: Add device tree support to pinmux driver
Jamie Iles wrote at Saturday, August 13, 2011 4:49 AM:
Quoted 4 lines · Jamie Iles
Quoted 3 lines
Hi Stephen,
On Fri, Aug 12, 2011 at 04:54:55PM -0600, Stephen Warren wrote:
...
Quoted 1 line
Quoted 1 line
Quoted 1 line
arch/arm/mach-tegra/pinmux.c +0
-0
...
Quoted 24 lines
Quoted 15 lines
Quoted 15 lines
arch/arm/mach-tegra/pinmux.c +15
-0+#ifdef CONFIG_OF +static void __init tegra_pinmux_probe_dt (struct platform_device *pdev) +{ +int pg; + +for (pg =0 ; pg <TEGRA_MAX_PINGROUP ; pg++) { +const char *pg_name =pingroup_name (pg); +struct tegra_pingroup_config config; +struct device_node *pg_node; +int ret; +const char *s; + + pg_node =of_find_child_node_by_name (pdev->dev.of_node, + pg_name); +if (pg_node ==NULL )Quoted 8 lines
arch/arm/mach-tegra/pinmux.c
Quoted 1 line
arch/arm/mach-tegra/pinmux.c +1
-0+continue ;Rather than iterating over all of the mux names in the pinmux driver and searching for a matching DT node, could you not do it the other way round? So do an
for_each_child_of_node()on the pinmux node then find the matching pingroup keyed by the node name? This would eliminateof_find_child_node_by_name(). You could also catch invalid configurations for non-existent pins this way.
Quoted 3 lines
I just re-read your introduction email and saw you've already discussed this! Would this require an explicit pin name property though or could you just key off of the
pg_node->name?
No, I think pg_node->name will work out fine; it's what of_find_child_node_by_name is using anyway.
Signature · 1 line
nvpublic
Re: [RFC PATCH 10/12] arm/tegra: Add device tree support to pinmux driver
In reply to Stephen WarrenHi Stephen,
Quoted 21 lines · Stephen Warren
Signed-off-by Stephen Warren <[email protected]>--- arch/arm/mach-tegra/pinmux.c | 115 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 115 insertions(+), 0 deletions(-)arch/arm/mach-tegra/pinmux.c +1
-0@@ -20,6 +20,7 @@#include <linux/errno.h> #include <linux/spinlock.h> #include <linux/io.h> +#include <linux/of.h> #include <linux/platform_device.h> #include <mach/iomap.h> @@ -147,6 +148,41 @@ static const char *func_name(enum tegra_mux_func func)return tegra_mux_names[func]; }
[...]
Quoted 62 lines
static const char *tri_name(unsigned long val)
{arch/arm/mach-tegra/pinmux.c +55
-0@@ -666,15 +702,94 @@ void tegra_pinmux_config_pullupdown_table(const struct tegra_pingroup_config *co } } +#ifdef CONFIG_OF +static void __init tegra_pinmux_probe_dt (struct platform_device *pdev) +{ +int pg; + +for (pg =0 ; pg <TEGRA_MAX_PINGROUP ; pg++) { +const char *pg_name =pingroup_name (pg); +struct tegra_pingroup_config config; +struct device_node *pg_node; +int ret; +const char *s; + + pg_node =of_find_child_node_by_name (pdev->dev.of_node, + pg_name); +if (pg_node ==NULL ) +continue ; + + config.pingroup = pg; + + ret =of_property_read_string (pg_node,"nvidia,function" , &s); +if (ret <0 ) { +dev_err (&pdev->dev, +"%s: Missing property nvidia,function\n" , + pg_name); +continue ; + } + ret =func_enum (s, &config.func); +if (ret <0 ) { +dev_err (&pdev->dev, +"%s: Invalid nvidia,function value %s\n" , + pg_name, s); +continue ; + } + + ret =of_property_read_string (pg_node,"nvidia,pull" , &s); +if (ret >=0 ) { +if (!strcmp (s,"up" )) + config.pupd =TEGRA_PUPD_PULL_UP ; +else if (!strcmp (s,"down" )) + config.pupd =TEGRA_PUPD_PULL_DOWN ; +else if (!strcmp (s,"normal" )) + config.pupd =TEGRA_PUPD_NORMAL ; +else { +dev_err (&pdev->dev, +"%s: Invalid nvidia,pull value %s\n" , + pg_name, s); +continue ; + } + }else + config.pupd =TEGRA_PUPD_NORMAL ; + +if (of_find_property (pg_node,"nvidia,tristate" ,NULL )) + config.tristate =TEGRA_TRI_TRISTATE ; +else + config.tristate =TEGRA_TRI_NORMAL ;
arch/arm/mach-tegra/pinmux.c void tegra_pinmux_config_pullupdown_table(const struct tegra_pingroup_config *co · line 769
Quoted 10 lines
arch/arm/mach-tegra/pinmux.c +10
-0+ +dev_err (&pdev->dev,"%s: func %d (%s) pull %d tri %d\n" , + pg_name, config.func,func_name (config.func), + config.pupd, config.tristate); + +tegra_pinmux_config_pingroup (&config); + +of_node_put (pg_node); + } +}
I need to implement DT muxing configuration for my platform, and I believe that what you have here would work fine for me too, and to avoid duplicating the same thing, I wonder if this could be a little more generic.
So if the platform specific pinmux driver called the pinmux parser with a callback for a pingroup configuration function then this wouldn't need the nvidia specific properties. I'd envisage the setup callback to be something like:
int pingroup_configure(const char *name, unsigned long flags);
where the flags would be a bitmask of properties, so:
PINMUX_F_TRISTATE
PINMUX_F_PUPD
etc
which would map to pinmux,tristate properties etc. The tegra (or picoxcell...) specific driver would then map any regs and setup the pinmux tables and call the parser loop with the correct callback. This would require looping over the child nodes as we've discussed before, and the decoding of the func_enum in the nvidia driver, but I think that's okay.
Jamie
Re: [RFC PATCH 10/12] arm/tegra: Add device tree support to pinmux driver
Quoted 102 lines · Jamie Iles
Hi Stephen,
Quoted 21 lines · Stephen Warren
Signed-off-by Stephen Warren <[email protected]>--- arch/arm/mach-tegra/pinmux.c | 115 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 115 insertions(+), 0 deletions(-)arch/arm/mach-tegra/pinmux.c +1
-0@@ -20,6 +20,7 @@#include <linux/errno.h> #include <linux/spinlock.h> #include <linux/io.h> +#include <linux/of.h> #include <linux/platform_device.h> #include <mach/iomap.h> @@ -147,6 +148,41 @@ static const char *func_name(enum tegra_mux_func func)return tegra_mux_names[func]; }[...]
Quoted 62 lines
static const char *tri_name(unsigned long val)
{arch/arm/mach-tegra/pinmux.c +55
-0@@ -666,15 +702,94 @@ void tegra_pinmux_config_pullupdown_table(const struct tegra_pingroup_config *co } } +#ifdef CONFIG_OF +static void __init tegra_pinmux_probe_dt (struct platform_device *pdev) +{ +int pg; + +for (pg =0 ; pg <TEGRA_MAX_PINGROUP ; pg++) { +const char *pg_name =pingroup_name (pg); +struct tegra_pingroup_config config; +struct device_node *pg_node; +int ret; +const char *s; + + pg_node =of_find_child_node_by_name (pdev->dev.of_node, + pg_name); +if (pg_node ==NULL ) +continue ; + + config.pingroup = pg; + + ret =of_property_read_string (pg_node,"nvidia,function" , &s); +if (ret <0 ) { +dev_err (&pdev->dev, +"%s: Missing property nvidia,function\n" , + pg_name); +continue ; + } + ret =func_enum (s, &config.func); +if (ret <0 ) { +dev_err (&pdev->dev, +"%s: Invalid nvidia,function value %s\n" , + pg_name, s); +continue ; + } + + ret =of_property_read_string (pg_node,"nvidia,pull" , &s); +if (ret >=0 ) { +if (!strcmp (s,"up" )) + config.pupd =TEGRA_PUPD_PULL_UP ; +else if (!strcmp (s,"down" )) + config.pupd =TEGRA_PUPD_PULL_DOWN ; +else if (!strcmp (s,"normal" )) + config.pupd =TEGRA_PUPD_NORMAL ; +else { +dev_err (&pdev->dev, +"%s: Invalid nvidia,pull value %s\n" , + pg_name, s); +continue ; + } + }else + config.pupd =TEGRA_PUPD_NORMAL ; + +if (of_find_property (pg_node,"nvidia,tristate" ,NULL )) + config.tristate =TEGRA_TRI_TRISTATE ; +else + config.tristate =TEGRA_TRI_NORMAL ;arch/arm/mach-tegra/pinmux.c void tegra_pinmux_config_pullupdown_table(const struct tegra_pingroup_config *co · line 769
Quoted 10 lines
arch/arm/mach-tegra/pinmux.c +10
-0+ +dev_err (&pdev->dev,"%s: func %d (%s) pull %d tri %d\n" , + pg_name, config.func,func_name (config.func), + config.pupd, config.tristate); + +tegra_pinmux_config_pingroup (&config); + +of_node_put (pg_node); + } +}I need to implement DT muxing configuration for my platform, and I believe that what you have here would work fine for me too, and to avoid duplicating the same thing, I wonder if this could be a little more generic.
Quoted 6 lines
So if the platform specific pinmux driver called the pinmux parser with a callback for a pingroup configuration function then this wouldn't need the nvidia specific properties. I'd envisage the setup callback to be something like:
int pingroup_configure(const char *name, unsigned long flags);
and it if this took the device_node too then the platform specific bits could handle more esoteric properties if required. I'll have a go at prototyping this tomorrow unless there are any obvious reasons that this is a stupid idea!
Jamie
RE: [RFC PATCH 10/12] arm/tegra: Add device tree support to pinmux driver
Jamie Iles wrote at Monday, August 15, 2011 2:36 PM:
Quoted 5 lines · Jamie Iles
Quoted 4 lines
Hi Stephen,
Quoted 1 line · Stephen Warren
Signed-off-by Stephen Warren <[email protected]>
...
Quoted 1 line
Quoted 1 line
Quoted 1 line
arch/arm/mach-tegra/pinmux.c +0
-0
...
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
arch/arm/mach-tegra/pinmux.c +19
-0+static void __init tegra_pinmux_probe_dt (struct platform_device *pdev) +{ +int pg; + +for (pg =0 ; pg <TEGRA_MAX_PINGROUP ; pg++) { +const char *pg_name =pingroup_name (pg); +struct tegra_pingroup_config config; +struct device_node *pg_node; +int ret; +const char *s; + + pg_node =of_find_child_node_by_name (pdev->dev.of_node, + pg_name); +if (pg_node ==NULL ) +continue ; + + config.pingroup = pg; + + ret =of_property_read_string (pg_node,"nvidia,function" , &s);
...
Quoted 1 line
Quoted 1 line
Quoted 1 line
arch/arm/mach-tegra/pinmux.c +1
-0+ ret =of_property_read_string (pg_node,"nvidia,pull" , &s);
...
Quoted 1 line
Quoted 1 line
Quoted 1 line
arch/arm/mach-tegra/pinmux.c +1
-0+if (of_find_property (pg_node,"nvidia,tristate" ,NULL ))
...
Quoted 15 lines
Quoted 15 lines
arch/arm/mach-tegra/pinmux.c void tegra_pinmux_config_pullupdown_table(const struct tegra_pingroup_config *co · line 769
Quoted 5 lines
arch/arm/mach-tegra/pinmux.c +5
-0+tegra_pinmux_config_pingroup (&config); + +of_node_put (pg_node); + } +}I need to implement DT muxing configuration for my platform, and I believe that what you have here would work fine for me too, and to avoid duplicating the same thing, I wonder if this could be a little more generic.
So if the platform specific pinmux driver called the pinmux parser with a callback for a pingroup configuration function then this wouldn't need the nvidia specific properties. I'd envisage the setup callback to be something like:
Quoted 5 lines
Quoted 1 line
int pingroup_configure(const char *name, unsigned long flags);and it if this took the
device_nodetoo then the platform specific bits could handle more esoteric properties if required. I'll have a go at prototyping this tomorrow unless there are any obvious reasons that this is a stupid idea!
I expect some of the code could be shared.
The only worry I have is whether some SoCs don't configure things like pinmux function in the same place as pad function (pullup/down, tristate), and hence whether a generic binding is generally applicable. I suppose the code could always ignore unused properties.
I wonder how much of this is relevant to Linus W's pinctrl API?
Note that in the updated patch series I just posted, I reworked the binding a little; Tegra has two sets of pin-groups, one configuring muxing, pullup/ down, and tri-state, and the other configuring various driver strength/ rate properties. Hence, the tree is now e.g.:
pinmux: pinmux at 70000000 {
compatible = "nvidia,tegra20-pinmux";
reg = < 0x70000000 0xc00 >;
nvidia,mux-groups {
cdev1 {
nvidia,function = "plla_out";
};
cdev2 {
nvidia,function = "pllp_out4";
nvidia,pull-down;
nvidia,tristate;
};
};
nvidia,drive-groups {
sdio1 {
nvidia,schmitt;
nvidia,drive-power = <1>;
nvidia,pull-down-strength = <31>;
nvidia,pull-up-strength = <31>;
nvidia,slew-rate-rising = <3>;
nvidia,slew-rate-falling = <3>;
};
};
};But it's probably still reasonably easy to make the parser for the mux-groups node generic. Perhaps it makes sense for all SoCs to have a "mux-settings" node, even if they don't have any other custom nodes?
Signature · 1 line
nvpublic
Re: [RFC PATCH 10/12] arm/tegra: Add device tree support to pinmux driver
Quoted 54 lines · Stephen Warren
Jamie Iles wrote at Monday, August 15, 2011 2:36 PM:
Quoted 5 lines · Jamie Iles
Quoted 4 lines
Hi Stephen,
Quoted 1 line · Stephen Warren
Signed-off-by Stephen Warren <[email protected]>...
Quoted 1 line
Quoted 1 line
Quoted 1 line
arch/arm/mach-tegra/pinmux.c +0
-0...
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
arch/arm/mach-tegra/pinmux.c +19
-0+static void __init tegra_pinmux_probe_dt (struct platform_device *pdev) +{ +int pg; + +for (pg =0 ; pg <TEGRA_MAX_PINGROUP ; pg++) { +const char *pg_name =pingroup_name (pg); +struct tegra_pingroup_config config; +struct device_node *pg_node; +int ret; +const char *s; + + pg_node =of_find_child_node_by_name (pdev->dev.of_node, + pg_name); +if (pg_node ==NULL ) +continue ; + + config.pingroup = pg; + + ret =of_property_read_string (pg_node,"nvidia,function" , &s);...
Quoted 1 line
Quoted 1 line
Quoted 1 line
arch/arm/mach-tegra/pinmux.c +1
-0+ ret =of_property_read_string (pg_node,"nvidia,pull" , &s);...
Quoted 1 line
Quoted 1 line
Quoted 1 line
arch/arm/mach-tegra/pinmux.c +1
-0+if (of_find_property (pg_node,"nvidia,tristate" ,NULL ))...
Quoted 15 lines
Quoted 15 lines
arch/arm/mach-tegra/pinmux.c void tegra_pinmux_config_pullupdown_table(const struct tegra_pingroup_config *co · line 769
Quoted 5 lines
arch/arm/mach-tegra/pinmux.c +5
-0+tegra_pinmux_config_pingroup (&config); + +of_node_put (pg_node); + } +}I need to implement DT muxing configuration for my platform, and I believe that what you have here would work fine for me too, and to avoid duplicating the same thing, I wonder if this could be a little more generic.
So if the platform specific pinmux driver called the pinmux parser with a callback for a pingroup configuration function then this wouldn't need the nvidia specific properties. I'd envisage the setup callback to be something like:
Quoted 5 lines
Quoted 1 line
int pingroup_configure(const char *name, unsigned long flags);and it if this took the
device_nodetoo then the platform specific bits could handle more esoteric properties if required. I'll have a go at prototyping this tomorrow unless there are any obvious reasons that this is a stupid idea!
Quoted 6 lines
I expect some of the code could be shared.
The only worry I have is whether some SoCs don't configure things like pinmux function in the same place as pad function (pullup/down, tristate), and hence whether a generic binding is generally applicable. I suppose the code could always ignore unused properties.
Yes, well our hardware doesn't support any of these features other than setting the function so in the picoxcell backend I'd just WARN_ON() invalid flags settings.
Quoted 1 line
I wonder how much of this is relevant to Linus W's pinctrl API?
Hmm, not sure on that one, it's been a while since I've looked at Linus' patches.
Quoted 30 lines
Note that in the updated patch series I just posted, I reworked the binding a little; Tegra has two sets of pin-groups, one configuring muxing, pullup/ down, and tri-state, and the other configuring various driver strength/ rate properties. Hence, the tree is now e.g.:
pinmux: pinmux at 70000000 { compatible = "nvidia,tegra20-pinmux"; reg = < 0x70000000 0xc00 >; nvidia,mux-groups { cdev1 { nvidia,function = "plla_out"; }; cdev2 { nvidia,function = "pllp_out4"; nvidia,pull-down; nvidia,tristate; }; }; nvidia,drive-groups { sdio1 { nvidia,schmitt; nvidia,drive-power = <1>; nvidia,pull-down-strength = <31>; nvidia,pull-up-strength = <31>; nvidia,slew-rate-rising = <3>; nvidia,slew-rate-falling = <3>; }; }; };
Quoted 3 lines
But it's probably still reasonably easy to make the parser for the mux-groups node generic. Perhaps it makes sense for all SoCs to have a "mux-settings" node, even if they don't have any other custom nodes?
You have a much more complex chip than I do! I don't know if *all* SoC's have to have the same muxing binding, but it feels that this one should cover a lot of the most common bases.
Jamie
RFC PATCH 11/12 arm/tegra: board-dt: Remove dependency on non-dt pinmux functions
In reply to Stephen Warren--- arch/arm/mach-tegra/Makefile | 1 - arch/arm/mach-tegra/board-dt.c | 10 ---------- 2 files changed, 0 insertions(+), 11 deletions(-)
arch/arm/mach-tegra/Makefile +0 -1
@@ -30,7 +30,6 @@ obj-${CONFIG_MACH_SEABOARD} += board-seaboard.o obj-${CONFIG_MACH_SEABOARD} += board-seaboard-pinmux.o obj-${CONFIG_MACH_TEGRA_DT} += board-dt.o -obj-${CONFIG_MACH_TEGRA_DT} += board-harmony-pinmux.o obj-${CONFIG_MACH_TRIMSLICE} += board-trimslice.o obj-${CONFIG_MACH_TRIMSLICE} += board-trimslice-pinmux.o
arch/arm/mach-tegra/board-dt.c +0 -10
@@ -41,14 +41,9 @@#include <mach/irqs.h> #include "board.h" -#include "board-harmony.h" #include "clock.h" #include "devices.h" -void harmony_pinmux_init (void ); -void seaboard_pinmux_init (void ); - -struct of_dev_auxdata tegra20_auxdata_lookup[]__initdata = {OF_DEV_AUXDATA ("nvidia,tegra20-gpio" ,TEGRA_GPIO_BASE ,"tegra-gpio" ,NULL ),OF_DEV_AUXDATA ("nvidia,tegra20-pinmux" ,TEGRA_APB_MISC_BASE ,"tegra-pinmux" ,NULL ),
@@ -93,11 +88,6 @@ static void __init tegra_dt_init(void)tegra_clk_init_from_table (tegra_dt_clk_init_table); -if (of_machine_is_compatible ("nvidia,harmony" )) -harmony_pinmux_init (); -else if (of_machine_is_compatible ("nvidia,seaboard" )) -seaboard_pinmux_init (); -/* * Finished with the static registrations now; fill in the missing * devices
Signature · 1 line
1.7.0.4
RFC PATCH 12/12 arm/tegra: Remove temporary gpio/pinmux registration workaround
In reply to Stephen WarrenThis reverts commit "arm/tegra: Prevent duplicate gpio/pinmux pdev registration with dt"; board-dt.c no long calls harmony/ seaboard_pinmux_init(), so the workaround is no longer needed.
--- arch/arm/mach-tegra/board-harmony-pinmux.c | 5 +---- arch/arm/mach-tegra/board-seaboard-pinmux.c | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-)
arch/arm/mach-tegra/board-harmony-pinmux.c +1 -4
@@ -14,8 +14,6 @@* */ -#include <asm/mach-types.h> -#include <linux/kernel.h> #include <linux/gpio.h> #include <mach/pinmux.h>
@@ -163,8 +161,7 @@ static struct tegra_gpio_table gpio_table[] = {void harmony_pinmux_init (void ) { -if (machine_is_harmony ()) -platform_add_devices (pinmux_devices,ARRAY_SIZE (pinmux_devices)); +platform_add_devices (pinmux_devices,ARRAY_SIZE (pinmux_devices));tegra_pinmux_config_table (harmony_pinmux,ARRAY_SIZE (harmony_pinmux));
arch/arm/mach-tegra/board-seaboard-pinmux.c +1 -4
@@ -12,8 +12,6 @@* */ -#include <asm/mach-types.h> -#include <linux/kernel.h> #include <linux/init.h> #include <linux/gpio.h>
@@ -178,8 +176,7 @@ static struct tegra_gpio_table gpio_table[] = {void __init seaboard_pinmux_init (void ) { -if (machine_is_seaboard ()) -platform_add_devices (pinmux_devices,ARRAY_SIZE (pinmux_devices)); +platform_add_devices (pinmux_devices,ARRAY_SIZE (pinmux_devices));tegra_pinmux_config_table (seaboard_pinmux,ARRAY_SIZE (seaboard_pinmux));
Signature · 1 line
1.7.0.4
Re: [RFC PATCH 12/12] arm/tegra: Remove temporary gpio/pinmux registration workaround
Hello.
Quoted 1 line · Stephen Warren
This reverts commit "arm/tegra: Prevent duplicate gpio/pinmux pdev
Would be good to also include the commit ID for gitweb.
Quoted 4 lines
registration with dt";
board-dt.cno long calls harmony/seaboard_pinmux_init(), so the workaround is no longer needed.Signed-off-by Stephen Warren<[email protected]>
WBR, Sergei
RE: [RFC PATCH 12/12] arm/tegra: Remove temporary gpio/pinmux registration workaround
Sergei Shtylyov wrote at Monday, August 15, 2011 5:13 AM:
Quoted 7 lines
Hello.
Quoted 1 line · Stephen Warren
This reverts commit "arm/tegra: Prevent duplicate gpio/pinmux pdev
Would be good to also include the commit ID for gitweb.
I can't do that yet, because the commit that's being reverted is earlier in the patch series being posted, and hence doesn't have a commit ID that will be valid in any upstream repository.
I suppose this is the last commit in the series though, so I could remove it and submit the revert separately once the rest is upstream.
Quoted 6 lines
Quoted 4 lines
registration with dt";
board-dt.cno long calls harmony/seaboard_pinmux_init(), so the workaround is no longer needed.Signed-off-by Stephen Warren<[email protected]>WBR, Sergei
Signature · 1 line
nvpublic
Quoted 26 lines · Stephen Warren
This patch modifies Tegra's device tree support to remove the dependency on
harmony_pinmux_init(), thus making it completely board-independent.Some notes:
* This series is built on top of linux-next with a bunch of patches applied, in particular the removal of
irq_to_gpioand customgpio_to_irqthat I'm in the process of sending to Russell. I haven't yet thought through how/where to merge this without causing all kinds of conflicts.* I took care to preserve bisectability of Tegra DT support. However, linux-next doesn't yet have entirely useful Tegra DT support; some stuff from Grant's devicetree/next hasn't been pushed into linux-next yet. If we don't care about bisectability, I can remove a couple commits and possibly squash some others.
* The approach taken here is to have a custom semantic SoC-specific binding for each the gpio and pinmux drivers. Other alternatives suggested included:
1) A generic "list of register writes" to be performed at boot. This has the advantage of reusability across different SoCs. However, this approach isn't semantic, and requires detailed knowledge of pinmux registers and potentially fiddly calculations when constructing the device tree.
Quoted 9 lines
2) The ability to define disabled child nodes of the pinmux controller that are not processed by
tegra_pinmux_probe_dt(). Other devices may refer to those using phandles, and later enable/disable them, thus representing dynamic pinmuxing in the device tree. I wasn't convinced whether we should represent dynamic pinmuxing using phandles.I discussed in more detail why I prefer the current proposal in various email threads.
Glad to see the second soc specific pinmux binding besides the one below for i.mx.
http://permalink.gmane.org/gmane.linux.drivers.devicetree/6962
Quoted 8 lines
*
tegra_pinmux_probe_dt()enumerates all legal pingroup names, and searches for a pinmux controller subnode of that name, then processes each one that is found. An alternative that some may prefer would be to enumerate each child node of the pinmux controller, and have each node contain an explicit pingroup name property instead. Does anyone have any preference here? I suppose the latter option would obviate the need to addof_find_child_node_by_name().
I agree with Jamie that the latter option seems better/simper.
Quoted 16 lines
Thanks for reading!
Stephen Warren (12):
dt: Addof_find_child_node_by_name()
arm/tegra: Prep boards for gpio/pinmux conversion to pdevs arm/tegra: Avoid duplicate gpio/pinmux devices with dt arm/tegra: board-dt: Add AUXDATA for tegra-gpio and tegra-pinmux arm/dt: Tegra: Add nvidia,gpios property to GPIO controller arm/dt: Tegra: Add pinmux node
gpio/tegra: Convert to a platform device
gpio/tegra: Add device tree support
arm/tegra: Convert pinmux driver to a platform device arm/tegra: Add device tree support to pinmux driver arm/tegra: board-dt: Remove dependency on non-dt pinmux functions arm/tegra: Remove temporary gpio/pinmux registration workaround
Quoted 17 lines
arch/arm/boot/dts/tegra-harmony.dts | 479 ++++++++++++++++++++++++++ arch/arm/boot/dts/tegra-seaboard.dts | 409 ++++++++++++++++++++++ arch/arm/boot/dts/tegra20.dtsi | 5 + arch/arm/mach-tegra/Makefile | 1 - arch/arm/mach-tegra/board-dt.c | 12 +- arch/arm/mach-tegra/board-harmony-pinmux.c | 8 + arch/arm/mach-tegra/board-paz00-pinmux.c | 8 + arch/arm/mach-tegra/board-seaboard-pinmux.c | 9 +- arch/arm/mach-tegra/board-trimslice-pinmux.c | 7 + arch/arm/mach-tegra/devices.c | 10 + arch/arm/mach-tegra/devices.h | 2 + arch/arm/mach-tegra/pinmux.c | 136 ++++++++ drivers/gpio/gpio-tegra.c | 56 +++- drivers/of/base.c | 18 + include/linux/of.h | 2 + 15 files changed, 1138 insertions(+), 24 deletions(-)
Generally, you need to document the bindings you come with in Documentation/devicetree/bindings/
Signature · 2 lines
Regards, Shawn
Shawn Guo wrote at Saturday, August 13, 2011 7:09 AM:
Quoted 6 lines · Stephen Warren
Quoted 5 lines
This patch modifies Tegra's device tree support to remove the dependency on
harmony_pinmux_init(), thus making it completely board-independent.Some notes:
...
Quoted 9 lines
Quoted 7 lines
*
tegra_pinmux_probe_dt()enumerates all legal pingroup names, and searches for a pinmux controller subnode of that name, then processes each one that is found. An alternative that some may prefer would be to enumerate each child node of the pinmux controller, and have each node contain an explicit pingroup name property instead. Does anyone have any preference here? I suppose the latter option would obviate the need to addof_find_child_node_by_name().I agree with Jamie that the latter option seems better/simper.
OK, I'll flip the iteration around.
...
Quoted 17 lines
Quoted 8 lines
arch/arm/boot/dts/tegra-harmony.dts | 479 ++++++++++++++++++++++++++ arch/arm/boot/dts/tegra-seaboard.dts | 409 ++++++++++++++++++++++ arch/arm/boot/dts/tegra20.dtsi | 5 + arch/arm/mach-tegra/Makefile | 1 - arch/arm/mach-tegra/board-dt.c | 12 +- arch/arm/mach-tegra/board-harmony-pinmux.c | 8 + arch/arm/mach-tegra/board-paz00-pinmux.c | 8 + arch/arm/mach-tegra/board-seaboard-pinmux.c | 9 +-Quoted 9 lines
arch/arm/mach-tegra/board-trimslice-pinmux.c | 7 + arch/arm/mach-tegra/devices.c | 10 + arch/arm/mach-tegra/devices.h | 2 + arch/arm/mach-tegra/pinmux.c | 136 ++++++++ drivers/gpio/gpio-tegra.c | 56 +++- drivers/of/base.c | 18 + include/linux/of.h | 2 + 15 files changed, 1138 insertions(+), 24 deletions(-)
Quoted 2 lines
Generally, you need to document the bindings you come with in
Documentation/devicetree/bindings/
Uggh. I must have run format-patch on the wrong commit ID; the last thing I did was to add a couple commits containing the documentation:-( I really shouldn't try to post patch series last thing on Friday...
Signature · 1 line
nvpublic