Add pin control driver for Wondermedia SoCS
Subsystems (5)
RFC PATCH 1/1 Add pin control driver for Wondermedia SoCS
Before I get all carried away and start filling in all the data for this driver, I was hoping someone (or a few people) could review the basic design in case it requires changes to the data structures.
This driver is based on pinctrl-bcm2835.c as it seems to be similar in design. The pin controller on Wondermedia SoC's only allows each pin to either be a GPIO or to be its 'alternate' function. Functions cannot be remapped to any other pin.
I have seperated out the data from the code as there are several SoC's to support and each has it's own variation of registers / pin layout. I borrowed this part of the design from the Tegra pinctrl driver.
Regards
Tony Prisk
Tony Prisk (1):
pinctrl: gpio: vt8500: Add pin control driver for Wondermedia SoCs
arch/arm/Kconfig | 4 +- arch/arm/boot/dts/wm8850-w70v2.dts | 15 + arch/arm/boot/dts/wm8850.dtsi | 7 +- arch/arm/mach-vt8500/Kconfig | 1 + drivers/pinctrl/Kconfig | 10 + drivers/pinctrl/Makefile | 2 + drivers/pinctrl/pinctrl-wm8850.c | 166 +++++++++++ drivers/pinctrl/pinctrl-wmt.c | 565 ++++++++++++++++++++++++++++++++++++ drivers/pinctrl/pinctrl-wmt.h | 73 +++++ 9 files changed, 840 insertions(+), 3 deletions(-) create mode 100644 drivers/pinctrl/pinctrl-wm8850.c create mode 100644 drivers/pinctrl/pinctrl-wmt.c create mode 100644 drivers/pinctrl/pinctrl-wmt.h
Signature · 1 line
1.7.9.5
PATCH 1/1 pinctrl: gpio: vt8500: Add pin control driver for Wondermedia SoCs
--- arch/arm/Kconfig | 4 +- arch/arm/boot/dts/wm8850-w70v2.dts | 15 + arch/arm/boot/dts/wm8850.dtsi | 7 +- arch/arm/mach-vt8500/Kconfig | 1 + drivers/pinctrl/Kconfig | 10 + drivers/pinctrl/Makefile | 2 + drivers/pinctrl/pinctrl-wm8850.c | 166 +++++++++++ drivers/pinctrl/pinctrl-wmt.c | 565 ++++++++++++++++++++++++++++++++++++ drivers/pinctrl/pinctrl-wmt.h | 73 +++++ 9 files changed, 840 insertions(+), 3 deletions(-) create mode 100644 drivers/pinctrl/pinctrl-wm8850.c create mode 100644 drivers/pinctrl/pinctrl-wmt.c create mode 100644 drivers/pinctrl/pinctrl-wmt.h
arch/arm/Kconfig +2 -2
@@ -1618,10 +1618,10 @@ config LOCAL_TIMERS config ARCH_NR_GPIO int default 1024 if ARCH_SHMOBILE || ARCH_TEGRA + default 512 if SOC_OMAP5 default 355 if ARCH_U8500 + default 352 if ARCH_VT8500 default 264 if MACH_H4700 - default 512 if SOC_OMAP5 - default 288 if ARCH_VT8500 default 0 help Maximum number of GPIOs in the system.
arch/arm/boot/dts/wm8850-w70v2.dts +15 -0
@@ -52,3 +52,18 @@ keymap = <116>; /* KEY_POWER */ }; }; + +&pinmux { + pinctrl-names = "default"; + pinctrl-0 = <&i2c &sdmmc>; + + i2c: i2c { + wm,pins = <168 169 170 171 172 173>; + wm,function = <2>; /* alt */ + }; + + sdmmc: sdmmc { + wm,pins = <113 114 115 116 117 118 119>; + wm,function = <2>; /* alt */ + }; +};
arch/arm/boot/dts/wm8850.dtsi +6 -1
@@ -39,13 +39,18 @@ reg = <0xD8150000 0x10000>; interrupts = <56 57 58 59 60 61 62 63>; }; - +/* gpio: gpio-controller at d8110000 { compatible = "wm,wm8650-gpio"; gpio-controller; reg = <0xd8110000 0x10000>; #gpio-cells = <3>; }; +*/ + pinmux: pinmux at d8110000 { + compatible = "wm,wm8850-gpio"; + reg = <0xd8110000 0x10000>; + }; pmc at d8130000 { compatible = "via,vt8500-pmc";
arch/arm/mach-vt8500/Kconfig +1 -0
@@ -29,5 +29,6 @@ config ARCH_WM8850 depends on ARCH_MULTI_V7 select ARCH_VT8500 select CPU_V7 + select PINCTRL help Support for WonderMedia WM8850 System-on-Chip.
drivers/pinctrl/Kconfig +10 -0
@@ -170,6 +170,16 @@ config PINCTRL_U300 select PINMUX select GENERIC_PINCONF +config PINCTRL_WMT + bool + select PINMUX + select PINCONF + +config PINCTRL_WM8850 + bool "Wondermedia WM8850 pin controller driver" + depends on ARCH_VT8500 + select PINCTRL_WMT + config PINCTRL_COH901 bool "ST-Ericsson U300 COH 901 335/571 GPIO" depends on GPIOLIB && ARCH_U300 && PINCTRL_U300
drivers/pinctrl/Makefile +2 -0
@@ -34,6 +34,8 @@ obj-$(CONFIG_PINCTRL_TEGRA) += pinctrl-tegra.o obj-$(CONFIG_PINCTRL_TEGRA20) += pinctrl-tegra20.o obj-$(CONFIG_PINCTRL_TEGRA30) += pinctrl-tegra30.o obj-$(CONFIG_PINCTRL_U300) += pinctrl-u300.o +obj-$(CONFIG_PINCTRL_WMT) += pinctrl-wmt.o +obj-$(CONFIG_PINCTRL_WM8850) += pinctrl-wm8850.o obj-$(CONFIG_PINCTRL_COH901) += pinctrl-coh901.o obj-$(CONFIG_PINCTRL_SAMSUNG) += pinctrl-samsung.o obj-$(CONFIG_PINCTRL_EXYNOS) += pinctrl-exynos.o
drivers/pinctrl/pinctrl-wm8850.c new file +166 -0
166 lines not on this page · raw message
drivers/pinctrl/pinctrl-wmt.c new file +565 -0
565 lines not on this page · raw message
drivers/pinctrl/pinctrl-wmt.h new file +73 -0
73 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Re: [PATCH] pinctrl: gpio: vt8500: Add pin control driver for Wondermedia SoCs
On Fri, Feb 15, 2013 at 3:48 AM, Tony Prisk <[email protected]> wrote:
Hm some of these remarks would apply to the BCM2835 driver as well, I missed to complain at the time it was added. Probably I was all too excited about the new Raspberry.
Mainly you want Stephens review on this since he wrote the driver you based it on...
arch/arm/Kconfig config LOCAL_TIMERS · line 1625
Quoted 12 lines
+++ b/arch/arm/Kconfig
arch/arm/Kconfig +2
-2@@ -1618,10 +1618,10 @@ config LOCAL_TIMERS config ARCH_NR_GPIO int default 1024 if ARCH_SHMOBILE || ARCH_TEGRA + default 512 if SOC_OMAP5 default 355 if ARCH_U8500 + default 352 if ARCH_VT8500 default 264 if MACH_H4700 - default 512 if SOC_OMAP5 - default 288 if ARCH_VT8500 default 0
This seems like a totally unrelated chunk, put that in some other patch and send off to the ARM SoC people if you want it changed.
drivers/pinctrl/Makefile obj-$(CONFIG_PINCTRL_TEGRA) += pinctrl-tegra.o · line 38
Quoted 2 lines
drivers/pinctrl/Makefile +2
-0+obj-$(CONFIG_PINCTRL_WMT) += pinctrl-wmt.o +obj-$(CONFIG_PINCTRL_WM8850) += pinctrl-wm8850.o
So one front-end driver and one pluggable SoC-driver I guess.
Quoted 1 line
+++
b/drivers/pinctrl/pinctrl-wm8850.c
(skipping this file, looks like OK and pure data)
Quoted 1 line
+++
b/drivers/pinctrl/pinctrl-wmt.c
(...)
drivers/pinctrl/pinctrl-wmt.c line 71
Quoted 3 lines
drivers/pinctrl/pinctrl-wmt.c new file +3
-0+#define WMT_PINCONF_PACK (__param, __arg) ((__param << 16) | __arg) +#define WMT_PINCONF_UNPACK_PARAM (__conf) (__conf >> 16) +#define WMT_PINCONF_UNPACK_ARG (__conf) (__conf & 0xffff)
Please use the generic pinconf helper library, there are no magic configurations in this driver. Look at other drivers using generic pinconf and get pack/unpack for free and tested.
(then follows a large block of nice, clean code)
drivers/pinctrl/pinctrl-wmt.c line 412
Quoted 8 lines
drivers/pinctrl/pinctrl-wmt.c new file +8
-0+static int wmt_pinconf_set (struct pinctrl_dev *pctldev,unsigned pin, +unsigned long config) +{ +struct wmt_pinctrl_data *data =pinctrl_dev_get_drvdata (pctldev); +enum wmt_pinconf_param param =WMT_PINCONF_UNPACK_PARAM (config); +u16 arg =WMT_PINCONF_UNPACK_ARG (config); +u32 bank = pin >>5 ; +u32 bit = pin &0x1f ;
Comment the two lines above. What kind of magic is happening? I can guess, but it's better if it's stated.
(...)
drivers/pinctrl/pinctrl-wmt.c line 481
Quoted 5 lines
drivers/pinctrl/pinctrl-wmt.c new file +5
-0+static int wmt_gpio_get_value (struct gpio_chip *chip,unsigned offset) +{ +struct wmt_pinctrl_data *data =dev_get_drvdata (chip->dev); +u32 bank = offset >>5 ; +u32 bit = offset &0x1f ;
Hm it looks like duplicated code as well. What abot a small static inline helper function to do the magic?
Quoted 16 lines
drivers/pinctrl/pinctrl-wmt.c new file +16
-0+int wmt_pinctrl_probe (struct platform_device *pdev, +struct wmt_pinctrl_data *data) +{ +int err; + wmt_desc.pins = data->pins; + wmt_desc.npins = data->npins; + + data->gpio_chip = wmt_gpio_chip; + data->gpio_chip.dev = &pdev->dev; + data->gpio_chip.of_node = pdev->dev.of_node; + data->gpio_chip.ngpio = data->nbanks *32 ; + +platform_set_drvdata (pdev, data); + + data->dev = &pdev->dev; + data->pctl_dev =pinctrl_register (&wmt_desc, &pdev->dev, data);
drivers/pinctrl/pinctrl-wmt.c line 539
Quoted 10 lines
drivers/pinctrl/pinctrl-wmt.c new file +10
-0+if (IS_ERR (data->pctl_dev)) { +dev_err (&pdev->dev,"Failed to register pinctrl\n" ); +return -EINVAL ; + } + + err =gpiochip_add (&data->gpio_chip); +if (err) { +dev_err (&pdev->dev,"could not add GPIO chip\n" ); +return err; + }
Nice with gpiochip and pinctrl in the same probe, just as it should be.
drivers/pinctrl/pinctrl-wmt.c line 546
Quoted 7 lines
drivers/pinctrl/pinctrl-wmt.c new file +7
-0+ + data->gpio_range = wmt_pinctrl_gpio_range; + + data->gpio_range.gc = &data->gpio_chip; + data->gpio_range.base = data->gpio_chip.base; + data->gpio_range.npins = data->nbanks *32 ; +pinctrl_add_gpio_range (data->pctl_dev, &data->gpio_range);
Don't do this. Register ranges from the gpiochip side instead of from the pinctrl side of things. This way of doing things is deprecated.
Grep for gpiochip_add_pin_range for examples.
When you have this right I guess you could probably patch the BCM driver as well since it's so similar.
Quoted 4 lines
drivers/pinctrl/pinctrl-wmt.c new file +4
-0+dev_info (&pdev->dev,"Pin controller initialized\n" ); + +return 0 ; +}
(...)
Quoted 1 line
+++
b/drivers/pinctrl/pinctrl-wmt.h
Looks OK.
Yours,
Linus Walleij
Re: [PATCH] pinctrl: gpio: vt8500: Add pin control driver for Wondermedia SoCs
Quoted 122 lines · Linus Walleij
On Fri, Feb 15, 2013 at 3:48 AM, Tony Prisk <[email protected]> wrote:
Hm some of these remarks would apply to the BCM2835 driver as well, I missed to complain at the time it was added. Probably I was all too excited about the new Raspberry.
Mainly you want Stephens review on this since he wrote the driver you based it on...
arch/arm/Kconfig config LOCAL_TIMERS · line 1625
Quoted 12 lines
+++ b/arch/arm/Kconfig
arch/arm/Kconfig +2
-2@@ -1618,10 +1618,10 @@ config LOCAL_TIMERS config ARCH_NR_GPIO int default 1024 if ARCH_SHMOBILE || ARCH_TEGRA + default 512 if SOC_OMAP5 default 355 if ARCH_U8500 + default 352 if ARCH_VT8500 default 264 if MACH_H4700 - default 512 if SOC_OMAP5 - default 288 if ARCH_VT8500 default 0This seems like a totally unrelated chunk, put that in some other patch and send off to the ARM SoC people if you want it changed.
drivers/pinctrl/Makefile obj-$(CONFIG_PINCTRL_TEGRA) += pinctrl-tegra.o · line 38
Quoted 2 lines
drivers/pinctrl/Makefile +2
-0+obj-$(CONFIG_PINCTRL_WMT) += pinctrl-wmt.o +obj-$(CONFIG_PINCTRL_WM8850) += pinctrl-wm8850.oSo one front-end driver and one pluggable SoC-driver I guess.
Quoted 1 line
+++
b/drivers/pinctrl/pinctrl-wm8850.c(skipping this file, looks like OK and pure data)
Quoted 1 line
+++
b/drivers/pinctrl/pinctrl-wmt.c(...)
drivers/pinctrl/pinctrl-wmt.c line 71
Quoted 3 lines
drivers/pinctrl/pinctrl-wmt.c new file +3
-0+#define WMT_PINCONF_PACK (__param, __arg) ((__param << 16) | __arg) +#define WMT_PINCONF_UNPACK_PARAM (__conf) (__conf >> 16) +#define WMT_PINCONF_UNPACK_ARG (__conf) (__conf & 0xffff)Please use the generic pinconf helper library, there are no magic configurations in this driver. Look at other drivers using generic pinconf and get pack/unpack for free and tested.
(then follows a large block of nice, clean code)
drivers/pinctrl/pinctrl-wmt.c line 412
Quoted 8 lines
drivers/pinctrl/pinctrl-wmt.c new file +8
-0+static int wmt_pinconf_set (struct pinctrl_dev *pctldev,unsigned pin, +unsigned long config) +{ +struct wmt_pinctrl_data *data =pinctrl_dev_get_drvdata (pctldev); +enum wmt_pinconf_param param =WMT_PINCONF_UNPACK_PARAM (config); +u16 arg =WMT_PINCONF_UNPACK_ARG (config); +u32 bank = pin >>5 ; +u32 bit = pin &0x1f ;Comment the two lines above. What kind of magic is happening? I can guess, but it's better if it's stated.
(...)
drivers/pinctrl/pinctrl-wmt.c line 481
Quoted 5 lines
drivers/pinctrl/pinctrl-wmt.c new file +5
-0+static int wmt_gpio_get_value (struct gpio_chip *chip,unsigned offset) +{ +struct wmt_pinctrl_data *data =dev_get_drvdata (chip->dev); +u32 bank = offset >>5 ; +u32 bit = offset &0x1f ;Hm it looks like duplicated code as well. What abot a small static inline helper function to do the magic?
Quoted 16 lines
drivers/pinctrl/pinctrl-wmt.c new file +16
-0+int wmt_pinctrl_probe (struct platform_device *pdev, +struct wmt_pinctrl_data *data) +{ +int err; + wmt_desc.pins = data->pins; + wmt_desc.npins = data->npins; + + data->gpio_chip = wmt_gpio_chip; + data->gpio_chip.dev = &pdev->dev; + data->gpio_chip.of_node = pdev->dev.of_node; + data->gpio_chip.ngpio = data->nbanks *32 ; + +platform_set_drvdata (pdev, data); + + data->dev = &pdev->dev; + data->pctl_dev =pinctrl_register (&wmt_desc, &pdev->dev, data);drivers/pinctrl/pinctrl-wmt.c line 539
Quoted 10 lines
drivers/pinctrl/pinctrl-wmt.c new file +10
-0+if (IS_ERR (data->pctl_dev)) { +dev_err (&pdev->dev,"Failed to register pinctrl\n" ); +return -EINVAL ; + } + + err =gpiochip_add (&data->gpio_chip); +if (err) { +dev_err (&pdev->dev,"could not add GPIO chip\n" ); +return err; + }Nice with gpiochip and pinctrl in the same probe, just as it should be.
drivers/pinctrl/pinctrl-wmt.c line 546
Quoted 7 lines
drivers/pinctrl/pinctrl-wmt.c new file +7
-0+ + data->gpio_range = wmt_pinctrl_gpio_range; + + data->gpio_range.gc = &data->gpio_chip; + data->gpio_range.base = data->gpio_chip.base; + data->gpio_range.npins = data->nbanks *32 ; +pinctrl_add_gpio_range (data->pctl_dev, &data->gpio_range);Don't do this. Register ranges from the gpiochip side instead of from the pinctrl side of things. This way of doing things is deprecated.
Grep for
gpiochip_add_pin_rangefor examples.When you have this right I guess you could probably patch the BCM driver as well since it's so similar.
Quoted 4 lines
drivers/pinctrl/pinctrl-wmt.c new file +4
-0+dev_info (&pdev->dev,"Pin controller initialized\n" ); + +return 0 ; +}(...)
Quoted 6 lines
Quoted 1 line
+++
b/drivers/pinctrl/pinctrl-wmt.hLooks OK.
Yours,
Linus Walleij
Thanks for the review.
Re: the Kconfig change for increasing the number of GPIO's - I know this is out of place, but it was easier to just diff all the changes and sort out the correct patches later.
I just wanted to get a feel for any problems around the main driver before I started typing in lines and lines of data... only to be told the data was bad and needed to be changed :)
Thanks again
Regards
Tony Prisk
Re: [PATCH] pinctrl: gpio: vt8500: Add pin control driver for Wondermedia SoCs
In reply to Tony PriskOn 02/14/2013 07:48 PM, Tony Prisk wrote:
Sorry for the slow review.
No patch description?
Quoted 9 lines
arch/arm/Kconfig | 4 +- arch/arm/boot/dts/wm8850-w70v2.dts | 15 + arch/arm/boot/dts/wm8850.dtsi | 7 +- arch/arm/mach-vt8500/Kconfig | 1 + drivers/pinctrl/Kconfig | 10 + drivers/pinctrl/Makefile | 2 + drivers/pinctrl/pinctrl-wm8850.c | 166 +++++++++++ drivers/pinctrl/pinctrl-wmt.c | 565 ++++++++++++++++++++++++++++++++++++ drivers/pinctrl/pinctrl-wmt.h | 73 +++++
No DT binding documentation?
It doesnt' seem a good idea to add the pinctrl driver and touch the various DT files in a single patch.
Quoted 4 lines
arch/arm/boot/dts/wm8850.dtsi +1
-0+/* gpio: gpio-controller at d8110000 {
arch/arm/boot/dts/wm8850.dtsi line 53
Quoted 10 lines
arch/arm/boot/dts/wm8850.dtsi +5
-0compatible = "wm,wm8650-gpio"; gpio-controller; reg = <0xd8110000 0x10000>; #gpio-cells = <3>; }; +*/ + pinmux: pinmux at d8110000 { + compatible = "wm,wm8850-gpio"; + reg = <0xd8110000 0x10000>; + };
If the old code is wrong, why not delete it? but the main change is just removing the GPIO-related properties - is the new driver no longer a GPIO provider, why?
arch/arm/mach-vt8500/Kconfig config ARCH_WM8850 · line 32
Quoted 7 lines
arch/arm/mach-vt8500/Kconfig +1
-0@@ -29,5 +29,6 @@ config ARCH_WM8850 depends on ARCH_MULTI_V7 select ARCH_VT8500 select CPU_V7 + select PINCTRL
Don't you want to select the specific pinctrl driver here too; is it actually useful for it to be optional?
drivers/pinctrl/Kconfig config PINCTRL_U300 · line 181
Quoted 6 lines
drivers/pinctrl/Kconfig +4
-0+config PINCTRL_WM8850 + bool "Wondermedia WM8850 pin controller driver" + depends on ARCH_VT8500 + select PINCTRL_WMT
If this is user-visible, there should be a description.
Quoted 5 lines
drivers/pinctrl/pinctrl-wm8850.c +3
-0+/* Please keep sorted by bank/bit */ +#define WMT_PIN_EXTGPIO0 WMT_PIN(0, 0) +#define WMT_PIN_EXTGPIO1 WMT_PIN(0, 1)
...
drivers/pinctrl/pinctrl-wm8850.c line 67
Quoted 2 lines
drivers/pinctrl/pinctrl-wm8850.c +2
-0+#define WMT_PIN_I2C2_SCL WMT_PIN(5, 12) +#define WMT_PIN_I2C2_SDA WMT_PIN(5, 13)
There are a lot of gaps in that list. Does the HW really not support pin muxing on the rest of the bits in the registers?
drivers/pinctrl/pinctrl-wmt.c line 165
Quoted 9 lines
drivers/pinctrl/pinctrl-wmt.c +7
-0+static int wmt_pmx_gpio_set_direction (struct pinctrl_dev *pctldev, +struct pinctrl_gpio_range *range, +unsigned offset, +bool input) +{ +struct wmt_pinctrl_data *data =pinctrl_dev_get_drvdata (pctldev); +#include <linux/pinctrl/consumer.h>
That should be at the top of the file.
drivers/pinctrl/pinctrl-wmt.c line 167
Quoted 2 lines
drivers/pinctrl/pinctrl-wmt.c +2
-0+wmt_set_pinmux (data, (input ?WMT_FSEL_GPIO_IN :WMT_FSEL_GPIO_OUT ), + offset);
Nit: The inner brackets are redundant.
Quoted 4 lines
drivers/pinctrl/pinctrl-wmt.c +4
-0+static int wmt_get_groups_count (struct pinctrl_dev *pctldev) +{ +struct wmt_pinctrl_data *data =pinctrl_dev_get_drvdata (pctldev); +
drivers/pinctrl/pinctrl-wmt.c line 195
Quoted 10 lines
drivers/pinctrl/pinctrl-wmt.c +10
-0+return data->ngroups; +} + +static const char *wmt_get_group_name (struct pinctrl_dev *pctldev, +unsigned selector) +{ +struct wmt_pinctrl_data *data =pinctrl_dev_get_drvdata (pctldev); + +return data->groups[selector]; +}
Hmmm. Given there's a 1:1 mapping between pin names and group names, I wonder if this core driver shouldn't synthesize the array of group names from the array of pins instead of requiring the per-SoC driver to duplicate all the pin names in a group array.
Of course, we should probably fix the pinctrl core to allow pin muxing on pins in addition to groups too. I keep feeling guilty about not having done that before.
Quoted 1 line
+static int wmt_pctl_dt_node_to_map_pull(struct
wmt_pinctrl_data*data,
...
drivers/pinctrl/pinctrl-wmt.c line 259
Quoted 4 lines
drivers/pinctrl/pinctrl-wmt.c +4
-0+struct pinctrl_map *map = *maps; + + +if (pull >2 ) {
Nit: redundant blank line there.
drivers/pinctrl/pinctrl-wmt.c line 274
Quoted 1 line
drivers/pinctrl/pinctrl-wmt.c +1
-0+ configs[0 ] =0 ;
= pull;?
Quoted 1 line
+static struct
gpio_chipwmt_gpio_chip= {
...
drivers/pinctrl/pinctrl-wmt.c line 511
Quoted 1 line
drivers/pinctrl/pinctrl-wmt.c +1
-0+ .can_sleep = 0,
Nit: No need to set that; 0 is the default for any not-explicitly-initialized fields.
Quoted 1 line
+int wmt_pinctrl_probe(struct
platform_device*pdev,
...
drivers/pinctrl/pinctrl-wmt.c line 548
Quoted 1 line
drivers/pinctrl/pinctrl-wmt.c +1
-0+dev_info (&pdev->dev,"Pin controller initialized\n" );
Nit: I'm never really sure that's useful.
Re: [PATCH] pinctrl: gpio: vt8500: Add pin control driver for Wondermedia SoCs
Thanks for the review Stephen,
I have posted replies to most of your points/questions inline.
The review was slightly more in-depth than I expected and as you noticed, the patch is poor in quality. I was more 'testing the water' that people were happy with the basic design of the code, rather than the specifics as I have 4 SoC's worth of data to add, and didn't want to have to redo it all if I had to make a data format change.
It seems that on the whole the design is ok, so I will post a proper patch series for this to be reviewed (after addressing the issues you pointed out).
Regards
Tony Prisk
Quoted 5 lines · Stephen Warren
On 02/14/2013 07:48 PM, Tony Prisk wrote:
Sorry for the slow review.
No patch description?
This was never supposed to be a proper patch - I was more looking for a consensus from 'the world' that this was an acceptable approach before I populated 4 soc's worth of data.
Quoted 11 lines
Quoted 10 lines
arch/arm/Kconfig | 4 +- arch/arm/boot/dts/wm8850-w70v2.dts | 15 + arch/arm/boot/dts/wm8850.dtsi | 7 +- arch/arm/mach-vt8500/Kconfig | 1 + drivers/pinctrl/Kconfig | 10 + drivers/pinctrl/Makefile | 2 + drivers/pinctrl/pinctrl-wm8850.c | 166 +++++++++++ drivers/pinctrl/pinctrl-wmt.c | 565 ++++++++++++++++++++++++++++++++++++ drivers/pinctrl/pinctrl-wmt.h | 73 +++++
Quoted 4 lines
No DT binding documentation?
It doesnt' seem a good idea to add the pinctrl driver and touch the various DT files in a single patch.
Again - this is not a proper patch.
Quoted 4 lines
Quoted 3 lines
arch/arm/boot/dts/wm8850.dtsi +0
-0
Quoted 16 lines
arch/arm/boot/dts/wm8850.dtsi line 53
Quoted 12 lines
arch/arm/boot/dts/wm8850.dtsi +6
-0+/* gpio: gpio-controller at d8110000 { compatible = "wm,wm8650-gpio"; gpio-controller; reg = <0xd8110000 0x10000>; #gpio-cells = <3>; }; +*/ + pinmux: pinmux at d8110000 { + compatible = "wm,wm8850-gpio"; + reg = <0xd8110000 0x10000>; + };If the old code is wrong, why not delete it? but the main change is just removing the GPIO-related properties - is the new driver no longer a GPIO provider, why?
New driver is a gpio provider - but wasn't when I pushed this 'preview'. Old code needs to be removed - is done in a seperate patch so as not to break current support all in one go.
Quoted 11 lines
arch/arm/mach-vt8500/Kconfig config ARCH_WM8850 · line 32
Quoted 8 lines
arch/arm/mach-vt8500/Kconfig +1
-0@@ -29,5 +29,6 @@ config ARCH_WM8850 depends on ARCH_MULTI_V7 select ARCH_VT8500 select CPU_V7 + select PINCTRLDon't you want to select the specific pinctrl driver here too; is it actually useful for it to be optional?
Its not 'required' so to speak, so I didn't want to force it on anyone who doesn't particularly want it - Also, there are 4 SoCs to support, so it would mean selecting them all.
Quoted 9 lines
drivers/pinctrl/Kconfig config PINCTRL_U300 · line 181
Quoted 7 lines
drivers/pinctrl/Kconfig +4
-0+config PINCTRL_WM8850 + bool "Wondermedia WM8850 pin controller driver" + depends on ARCH_VT8500 + select PINCTRL_WMTIf this is user-visible, there should be a description.
Fixed in the proper patch.
Quoted 7 lines
Quoted 6 lines
drivers/pinctrl/pinctrl-wm8850.c +3
-0+/* Please keep sorted by bank/bit */ +#define WMT_PIN_EXTGPIO0 WMT_PIN(0, 0) +#define WMT_PIN_EXTGPIO1 WMT_PIN(0, 1)...
Quoted 5 lines
drivers/pinctrl/pinctrl-wm8850.c line 67
Quoted 2 lines
drivers/pinctrl/pinctrl-wm8850.c +2
-0+#define WMT_PIN_I2C2_SCL WMT_PIN(5, 12) +#define WMT_PIN_I2C2_SDA WMT_PIN(5, 13)There are a lot of gaps in that list. Does the HW really not support pin muxing on the rest of the bits in the registers?
Nobody who knows is willing to say :). Most of the code for Wondermedia SoCs is based of the vendor source that has come out, and we therefore only know what the vendor has included support for.
No doubt there will be other pins which have valid functions, but we don't know what they are and don't have support for them at the moment. The reason I went with the bank/pin encoding is so that if/when we add other pins, it won't affect any pin numbering.
Quoted 12 lines
drivers/pinctrl/pinctrl-wmt.c line 165
Quoted 10 lines
drivers/pinctrl/pinctrl-wmt.c +7
-0+static int wmt_pmx_gpio_set_direction (struct pinctrl_dev *pctldev, +struct pinctrl_gpio_range *range, +unsigned offset, +bool input) +{ +struct wmt_pinctrl_data *data =pinctrl_dev_get_drvdata (pctldev); +#include <linux/pinctrl/consumer.h> That should be at the top of the file.
Copy-paste error.
Quoted 5 lines
drivers/pinctrl/pinctrl-wmt.c line 167
Quoted 3 lines
drivers/pinctrl/pinctrl-wmt.c +2
-0+wmt_set_pinmux (data, (input ?WMT_FSEL_GPIO_IN :WMT_FSEL_GPIO_OUT ), + offset);Nit: The inner brackets are redundant.
Ok.
Quoted 12 lines
Quoted 12 lines
drivers/pinctrl/pinctrl-wmt.c +11
-0+static int wmt_get_groups_count (struct pinctrl_dev *pctldev) +{ +struct wmt_pinctrl_data *data =pinctrl_dev_get_drvdata (pctldev); + +return data->ngroups; +} + +static const char *wmt_get_group_name (struct pinctrl_dev *pctldev, +unsigned selector) +{ +struct wmt_pinctrl_data *data =pinctrl_dev_get_drvdata (pctldev);
Quoted 8 lines
drivers/pinctrl/pinctrl-wmt.c line 195
Quoted 3 lines
drivers/pinctrl/pinctrl-wmt.c +3
-0+ +return data->groups[selector]; +}Hmmm. Given there's a 1:1 mapping between pin names and group names, I wonder if this core driver shouldn't synthesize the array of group names from the array of pins instead of requiring the per-SoC driver to duplicate all the pin names in a group array.
Could do.
Quoted 4 lines
Of course, we should probably fix the pinctrl core to allow pin muxing on pins in addition to groups too. I keep feeling guilty about not having done that before.
Would be nice.
Quoted 9 lines
Quoted 2 lines
+static int wmt_pctl_dt_node_to_map_pull(struct
wmt_pinctrl_data*data,...
drivers/pinctrl/pinctrl-wmt.c line 259
Quoted 4 lines
drivers/pinctrl/pinctrl-wmt.c +4
-0+struct pinctrl_map *map = *maps; + + +if (pull >2 ) {Nit: redundant blank line there.
Oops :)
Quoted 11 lines
drivers/pinctrl/pinctrl-wmt.c line 274
Quoted 2 lines
drivers/pinctrl/pinctrl-wmt.c +1
-0+ configs[0 ] =0 ;= pull;?
Quoted 1 line
+static struct
gpio_chipwmt_gpio_chip= {...
drivers/pinctrl/pinctrl-wmt.c line 511
Quoted 1 line
drivers/pinctrl/pinctrl-wmt.c +1
-0+ .can_sleep = 0,Nit: No need to set that; 0 is the default for any not-explicitly-initialized fields.
OK.
Quoted 6 lines
Quoted 2 lines
+int wmt_pinctrl_probe(struct
platform_device*pdev,...
drivers/pinctrl/pinctrl-wmt.c line 548
Quoted 1 line
drivers/pinctrl/pinctrl-wmt.c +1
-0+dev_info (&pdev->dev,"Pin controller initialized\n" );Nit: I'm never really sure that's useful.
Agreed.
Re: [PATCH] pinctrl: gpio: vt8500: Add pin control driver for Wondermedia SoCs
Quoted 10 lines · Tony Prisk
Thanks for the review Stephen,
I have posted replies to most of your points/questions inline.
The review was slightly more in-depth than I expected and as you noticed, the patch is poor in quality. I was more 'testing the water' that people were happy with the basic design of the code, rather than the specifics as I have 4 SoC's worth of data to add, and didn't want to have to redo it all if I had to make a data format change.
Quoted 3 lines
It seems that on the whole the design is ok, so I will post a proper patch series for this to be reviewed (after addressing the issues you pointed out).
Oh, OK. It might have been a good idea to mention this in the patch description, or have posted it as [PATCH RFC].
Quoted 12 lines
Quoted 11 lines
Quoted 5 lines
drivers/pinctrl/pinctrl-wm8850.c +3
-0+/* Please keep sorted by bank/bit */ +#define WMT_PIN_EXTGPIO0 WMT_PIN(0, 0) +#define WMT_PIN_EXTGPIO1 WMT_PIN(0, 1)...
drivers/pinctrl/pinctrl-wm8850.c line 67
Quoted 2 lines
drivers/pinctrl/pinctrl-wm8850.c +2
-0+#define WMT_PIN_I2C2_SCL WMT_PIN(5, 12) +#define WMT_PIN_I2C2_SDA WMT_PIN(5, 13)There are a lot of gaps in that list. Does the HW really not support pin muxing on the rest of the bits in the registers?
Quoted 8 lines
Nobody who knows is willing to say :). Most of the code for Wondermedia SoCs is based of the vendor source that has come out, and we therefore only know what the vendor has included support for.
No doubt there will be other pins which have valid functions, but we don't know what they are and don't have support for them at the moment. The reason I went with the bank/pin encoding is so that if/when we add other pins, it won't affect any pin numbering.
Doing the pin numbering that way was a good choice.
So, there's an idea that when first defining a DT binding for HW, that binding should be complete and accurate, rather than being minimal, with a plan to incrementally expand it later. I would take that to mean that for a pinctrl binding, the list of pins/groups/function/config-options that the binding supports is complete. Obviously this isn't possible if there's no complete documentation for the HW:-(
I hope this case will be allowed though, since any modifications to support new pins/groups/functions should be possible to add in a backwards-compatible way, especially with a forward-looking number scheme for the pins.
We should consider this kind of issue if/when we actually implement stricter rules for modifications to DT bindings, so as not to disallow solving this problem.