arm: vt8500: Add support for pinctrl/gpio module
Subsystems (6)
cover arm: vt8500: Add support for pinctrl/gpio module
This patch series removes the existing GPIO driver and replaces it with a combined pinctrl+gpio driver.
Patch 1 - Increase the available GPIO space for the newly added gpios.
Because there is no hardware documentation from Wondermedia we don't know how many GPIO's there actually are. New gpio pins have been located since the original GPIO driver was written, hence the increase.
Patch 2 - The main pinctrl/gpio driver and the data for the 5 supported SoCs.
Each SoC is different, and therefore has its own data. This design was borrowed from the Tegra pinctrl driver. The pin numbering is based on a bank+pin encoding so that when other pin functions are found later on we can add them without having to renumber existing pins.
Patch 3 - Update the SoC dts(i) files to support the new pinctrl driver.
Patch 4 - Remove the existing GPIO driver nodes from the dtsi's.
Patch 5 - Remove the existing GPIO driver.
Patch 6 - Remove the pinmux configuration code from mach-vt8500/vt8500.c that
was used to configure the graphics hardware at boot time. This is now done in the pinctrl node of the dtsi.
I suspect this series may need to be broken up since there are two arm-soc patches, and 4 pinctrl/gpio patches.
Patch 1 is fairly independant, but is required for the new driver to function properly.
Patches 2-5 are pinctrl/gpio patches.
Patch 6 relies on all the previous patches being available or the graphics hardware will be non-functional.
Let me know how you want to handle this and I'll break it up if necessary.
Regards
Tony Prisk
Tony Prisk (6):
arm: vt8500: Increase available GPIOs on arch-vt8500
pinctrl: gpio: vt8500: Add pincontrol driver for arch-vt8500
arm: dts: vt8500: Update Wondermedia SoC dtsi files for pinctrl
driver
arm: vt8500: Remove gpio devicetree nodes
gpio: vt8500: Remove arch-vt8500 gpio driver
arm: vt8500: Remove pinmux configuration from mach-vt8500/vt8500.c
.../devicetree/bindings/pinctrl/pinctrl-vt8500.txt | 56 ++ arch/arm/Kconfig | 3 +- arch/arm/boot/dts/vt8500.dtsi | 7 +- arch/arm/boot/dts/wm8505.dtsi | 7 +- arch/arm/boot/dts/wm8650.dtsi | 7 +- arch/arm/boot/dts/wm8850.dtsi | 7 +- arch/arm/mach-vt8500/Kconfig | 1 + arch/arm/mach-vt8500/vt8500.c | 70 +-- drivers/gpio/Kconfig | 6 - drivers/gpio/Makefile | 1 - drivers/gpio/gpio-vt8500.c | 355 ----------- drivers/pinctrl/Kconfig | 37 ++ drivers/pinctrl/Makefile | 5 + drivers/pinctrl/pinctrl-vt8500.c | 509 ++++++++++++++++ drivers/pinctrl/pinctrl-wm8505.c | 540 +++++++++++++++++ drivers/pinctrl/pinctrl-wm8650.c | 378 ++++++++++++ drivers/pinctrl/pinctrl-wm8750.c | 417 +++++++++++++ drivers/pinctrl/pinctrl-wm8850.c | 396 +++++++++++++ drivers/pinctrl/pinctrl-wmt.c | 625 ++++++++++++++++++++ drivers/pinctrl/pinctrl-wmt.h | 79 +++ 20 files changed, 3062 insertions(+), 444 deletions(-) create mode 100644 Documentation/devicetree/bindings/pinctrl/pinctrl-vt8500.txt delete mode 100644 drivers/gpio/gpio-vt8500.c create mode 100644 drivers/pinctrl/pinctrl-vt8500.c create mode 100644 drivers/pinctrl/pinctrl-wm8505.c create mode 100644 drivers/pinctrl/pinctrl-wm8650.c create mode 100644 drivers/pinctrl/pinctrl-wm8750.c 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/6 arm: vt8500: Increase available GPIOs on arch-vt8500
With the inclusion of the pin control driver, more GPIO pins have been identified on the arch-vt8500 SoCs requiring an increase in the available GPIOs.
--- arch/arm/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm/Kconfig +2 -1
@@ -1661,9 +1661,10 @@ config ARCH_NR_GPIO int default 1024 if ARCH_SHMOBILE || ARCH_TEGRA 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 || ARCH_SUNXI + default 288 if ARCH_SUNXI default 0 help Maximum number of GPIOs in the system.
Signature · 1 line
1.7.9.5
PATCH 1/6 arm: vt8500: Increase available GPIOs on arch-vt8500
Quoted 3 lines · Tony Prisk
With the inclusion of the pin control driver, more GPIO pins have been identified on the arch-vt8500 SoCs requiring an increase in the available GPIOs.
There is a patch from Maxime Ripard in February fixing the broken orering of these options. It was sent to Arnd and Olof - but was it merged? Arnd/Olof needs to merge for -rc and people need to take note of it (it will conflict for example with your patch.)
PATCH 1/6 arm: vt8500: Increase available GPIOs on arch-vt8500
Quoted 10 lines · Russell King - ARM Linux
Quoted 3 lines · Tony Prisk
With the inclusion of the pin control driver, more GPIO pins have been identified on the arch-vt8500 SoCs requiring an increase in the available GPIOs.
There is a patch from Maxime Ripard in February fixing the broken orering of these options. It was sent to Arnd and Olof - but was it merged? Arnd/Olof needs to merge for -rc and people need to take note of it (it will conflict for example with your patch.)
Quoted 4 lines
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
I was aware of the patch to reorder the gpio numbering, and my patch originally reordered them as well then I realised I should undo it to avoid complicating things.
Quite happy to rebase this on a later -rc once the original patch is merged.
Regards
Tony P
PATCH 2/6 pinctrl: gpio: vt8500: Add pincontrol driver for arch-vt8500
In reply to Tony PriskThis patch adds support for the GPIO/pinmux controller found on the VIA VT8500 and Wondermedia WM8xxx-series SoCs.
Each pin within the controller is capable of operating as a GPIO or as an alternate function. The pins are numbered according to their control bank/bit so that if new pins are added, the existing numbering is maintained.
All currently supported SoCs are included: VT8500, WM8505, WM8650, WM8750 and WM8850.
--- .../devicetree/bindings/pinctrl/pinctrl-vt8500.txt | 56 ++ arch/arm/mach-vt8500/Kconfig | 1 + drivers/pinctrl/Kconfig | 37 ++ drivers/pinctrl/Makefile | 5 + drivers/pinctrl/pinctrl-vt8500.c | 509 ++++++++++++++++ drivers/pinctrl/pinctrl-wm8505.c | 540 +++++++++++++++++ drivers/pinctrl/pinctrl-wm8650.c | 378 ++++++++++++ drivers/pinctrl/pinctrl-wm8750.c | 417 +++++++++++++ drivers/pinctrl/pinctrl-wm8850.c | 396 +++++++++++++ drivers/pinctrl/pinctrl-wmt.c | 625 ++++++++++++++++++++ drivers/pinctrl/pinctrl-wmt.h | 79 +++ 11 files changed, 3043 insertions(+) create mode 100644 Documentation/devicetree/bindings/pinctrl/pinctrl-vt8500.txt create mode 100644 drivers/pinctrl/pinctrl-vt8500.c create mode 100644 drivers/pinctrl/pinctrl-wm8505.c create mode 100644 drivers/pinctrl/pinctrl-wm8650.c create mode 100644 drivers/pinctrl/pinctrl-wm8750.c create mode 100644 drivers/pinctrl/pinctrl-wm8850.c create mode 100644 drivers/pinctrl/pinctrl-wmt.c create mode 100644 drivers/pinctrl/pinctrl-wmt.h
Documentation/devicetree/bindings/pinctrl/pinctrl-vt8500.txt new file +56 -0
@@ -0,0 +1,56 @@ +VIA VT8500 and Wondermedia WM8xxx-series pinmux/gpio controller + +These SoCs contain a combined Pinmux/GPIO module. Each pin may operate as +either a GPIO in, GPIO out or as an alternate function (I2C, SPI etc). + +Required properties: +- compatible: "via,vt8500-pinctrl", "wm,wm8505-pinctrl", "wm,wm8650-pinctrl", + "wm8750-pinctrl" or "wm,wm8850-pinctrl" +- reg: Should contain the physical address of the module's registers. +- gpio-controller: Marks the device node as a GPIO controller. +- #gpio-cells : Should be two. The first cell is the pin number and the + second cell is used to specify optional parameters. + +Please refer to ../gpio/gpio.txt for a general description of GPIO bindings. + +Please refer to pinctrl-bindings.txt in this directory for details of the +common pinctrl bindings used by client devices, including the meaning of the +phrase "pin configuration node". + +Each pin configuration node lists the pin(s) to which it applies, and one or +more of the mux functions to select on those pin(s), and pull-up/down +configuration. Each subnode only affects those parameters that are explicitly +listed. In other words, a subnode that lists only a mux function implies no +information about any pull configuration. Similarly, a subnode that lists only +a pull parameter implies no information about the mux function. + +Required subnode-properties: +- wm,pins: An array of cells. Each cell contains the ID of a pin. + +Optional subnode-properties: +- wm,pinmux: A value and mask pair describing the configuration changes to + the pinmux register. Only bits marked 1 in the mask will be changed. + +- wm,function: Integer, containing the function to mux to the pin(s): + 0: GPIO in + 1: GPIO out + 2: alternate + +- wm,pull: Integer, representing the pull-down/up to apply to the pin(s): + 0: none + 1: down + 2: up + +Each of wm,function and wm,pull may contain either a single value which +will be applied to all pins in wm,pins, or one value for each entry in +wm,pins. + +Example: + + pinctrl: pinctrl { + compatible = "wm,wm8505-pinctrl"; + reg = <0xD8110000 0x10000>; + wm,pinmux = <0x80000004 0x80000006>; + gpio-controller; + #gpio-cells = <2>; + };
arch/arm/mach-vt8500/Kconfig +1 -0
@@ -7,6 +7,7 @@ config ARCH_VT8500 select GENERIC_CLOCKEVENTS select HAVE_CLK select VT8500_TIMER + select PINCTRL help Support for VIA/WonderMedia VT8500/WM85xx System-on-Chip.
drivers/pinctrl/Kconfig +37 -0
@@ -202,6 +202,43 @@ config PINCTRL_U300 select PINMUX select GENERIC_PINCONF +config PINCTRL_WMT + bool + select PINMUX + select GENERIC_PINCONF + +config PINCTRL_VT8500 + bool "VIA VT8500 pin controller driver" + depends on ARCH_VT8500 + select PINCTRL_WMT + help + Say yes here to support the gpio/pin control module on + VIA VT8500 SoCs. + +config PINCTRL_WM8505 + bool "Wondermedia WM8505 pin controller driver" + depends on ARCH_VT8500 + select PINCTRL_WMT + help + Say yes here to support the gpio/pin control module on + Wondermedia WM8505 SoCs. + +config PINCTRL_WM8650 + bool "Wondermedia WM8650 pin controller driver" + depends on ARCH_VT8500 + select PINCTRL_WMT + help + Say yes here to support the gpio/pin control module on + Wondermedia WM8650 SoCs. + +config PINCTRL_WM8850 + bool "Wondermedia WM8850 pin controller driver" + depends on ARCH_VT8500 + select PINCTRL_WMT + help + Say yes here to support the gpio/pin control module on + Wondermedia WM8850 SoCs. + config PINCTRL_COH901 bool "ST-Ericsson U300 COH 901 335/571 GPIO" depends on GPIOLIB && ARCH_U300 && PINCTRL_U300
drivers/pinctrl/Makefile +5 -0
@@ -41,6 +41,11 @@ obj-$(CONFIG_PINCTRL_TEGRA20) += pinctrl-tegra20.o obj-$(CONFIG_PINCTRL_TEGRA30) += pinctrl-tegra30.o obj-$(CONFIG_PINCTRL_TEGRA114) += pinctrl-tegra114.o obj-$(CONFIG_PINCTRL_U300) += pinctrl-u300.o +obj-$(CONFIG_PINCTRL_WMT) += pinctrl-wmt.o +obj-$(CONFIG_PINCTRL_VT8500) += pinctrl-vt8500.o +obj-$(CONFIG_PINCTRL_WM8505) += pinctrl-wm8505.o +obj-$(CONFIG_PINCTRL_WM8650) += pinctrl-wm8650.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-vt8500.c new file +509 -0
509 lines not on this page · raw message
drivers/pinctrl/pinctrl-wm8505.c new file +540 -0
540 lines not on this page · raw message
drivers/pinctrl/pinctrl-wm8650.c new file +378 -0
378 lines not on this page · raw message
drivers/pinctrl/pinctrl-wm8750.c new file +417 -0
417 lines not on this page · raw message
drivers/pinctrl/pinctrl-wm8850.c new file +396 -0
396 lines not on this page · raw message
drivers/pinctrl/pinctrl-wmt.c new file +625 -0
625 lines not on this page · raw message
drivers/pinctrl/pinctrl-wmt.h new file +79 -0
18 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.7.9.5
Part of the diff is not shown here. View the raw message.
PATCH 2/6 pinctrl: gpio: vt8500: Add pincontrol driver for arch-vt8500
Quoted 11 lines · Tony Prisk
This patch adds support for the GPIO/pinmux controller found on the VIA VT8500 and Wondermedia WM8xxx-series SoCs.
Each pin within the controller is capable of operating as a GPIO or as an alternate function. The pins are numbered according to their control bank/bit so that if new pins are added, the existing numbering is maintained.
All currently supported SoCs are included: VT8500, WM8505, WM8650, WM8750 and WM8850.
Documentation/devicetree/bindings/pinctrl/pinctrl-vt8500.txt line 12
Quoted 8 lines
Documentation/devicetree/bindings/pinctrl/pinctrl-vt8500.txt +7
-0+Required properties: +- compatible: "via,vt8500-pinctrl", "wm,wm8505-pinctrl", "wm,wm8650-pinctrl", + "wm8750-pinctrl" or "wm,wm8850-pinctrl" +- reg: Should contain the physical address of the module's registers. +- gpio-controller: Marks the device node as a GPIO controller. +- #gpio-cells : Should be two. The first cell is the pin number and the + second cell is used to specify optional parameters.
Can the GPIOs generate interrupts? If the HW can support this, even if the driver doesn't initially support it, the binding should describe the required interrupt-controller and #interrupt-cells properties.
Quoted 2 lines
+Required subnode-properties:
+- wm,pins: An array of cells. Each cell contains the ID of a pin.
That's a little odd. Presumably this is to allow configuring "pin configuration" data beyond the mux function and pull. Why aren't those options exposed as explicit properties, rather than allowing manual register tweaking?
[Bulk] Re: [PATCH 2/6] pinctrl: gpio: vt8500: Add pincontrol driver for arch-vt8500
Quoted 13 lines · Stephen Warren
Quoted 11 lines · Tony Prisk
This patch adds support for the GPIO/pinmux controller found on the VIA VT8500 and Wondermedia WM8xxx-series SoCs.
Each pin within the controller is capable of operating as a GPIO or as an alternate function. The pins are numbered according to their control bank/bit so that if new pins are added, the existing numbering is maintained.
All currently supported SoCs are included: VT8500, WM8505, WM8650, WM8750 and WM8850.
Documentation/devicetree/bindings/pinctrl/pinctrl-vt8500.txt +0
-0
Quoted 11 lines
Documentation/devicetree/bindings/pinctrl/pinctrl-vt8500.txt line 12
Quoted 7 lines
Documentation/devicetree/bindings/pinctrl/pinctrl-vt8500.txt +7
-0+Required properties: +- compatible: "via,vt8500-pinctrl", "wm,wm8505-pinctrl", "wm,wm8650-pinctrl", + "wm8750-pinctrl" or "wm,wm8850-pinctrl" +- reg: Should contain the physical address of the module's registers. +- gpio-controller: Marks the device node as a GPIO controller. +- #gpio-cells : Should be two. The first cell is the pin number and the + second cell is used to specify optional parameters.Can the GPIOs generate interrupts? If the HW can support this, even if the driver doesn't initially support it, the binding should describe the required interrupt-controller and #interrupt-cells properties.
Yes they can - we don't have a use-case for them so, as you mentioned, there is no support. Will add the binding info.
Quoted 9 lines
Quoted 3 lines
+Required subnode-properties:
+- wm,pins: An array of cells. Each cell contains the ID of a pin.That's a little odd. Presumably this is to allow configuring "pin configuration" data beyond the mux function and pull. Why aren't those options exposed as explicit properties, rather than allowing manual register tweaking?
Little confused about this one - wm,pins is the same as the brcm binding and is the pins being configured.
I assume you mean wm,pinmux is confusing.
The wm,pinmux does, as you guessed, control some addition pinmux alternate features. I exposed it this way because we don't know what most of the bits in the register do (There is no vendor hardware documentation for these SoCs), and rather than having to churn the code constantly to add the new configurations it seemed to make sense to just expose the register this way and let people configure it in the DT. It is masked so that we can change only the bits we know and leave the rest as configured by the bootloader.
Also, it would also add a lot of complexity to the pinctrl code to support the few additional functions we know this register provides because each SoC has a different layout for bits in this register, and we don't actually know which pins/pads are controlled by each bit (again, lack of documentation).
I realise this is contradictory to the point of having a pinctrl driver, but it was the best I could come up with given the poor information we have.
Always open to suggestions..
Regards
Tony P
[Bulk] Re: [PATCH 2/6] pinctrl: gpio: vt8500: Add pincontrol driver for arch-vt8500
Quoted 30 lines · Tony Prisk
Quoted 7 lines · Stephen Warren
Quoted 2 lines
+Required subnode-properties:
+- wm,pins: An array of cells. Each cell contains the ID of a pin.That's a little odd. Presumably this is to allow configuring "pin configuration" data beyond the mux function and pull. Why aren't those options exposed as explicit properties, rather than allowing manual register tweaking?
Little confused about this one - wm,pins is the same as the brcm binding and is the pins being configured.
I assume you mean wm,pinmux is confusing.
The wm,pinmux does, as you guessed, control some addition pinmux alternate features. I exposed it this way because we don't know what most of the bits in the register do (There is no vendor hardware documentation for these SoCs), and rather than having to churn the code constantly to add the new configurations it seemed to make sense to just expose the register this way and let people configure it in the DT. It is masked so that we can change only the bits we know and leave the rest as configured by the bootloader.
Also, it would also add a lot of complexity to the pinctrl code to support the few additional functions we know this register provides because each SoC has a different layout for bits in this register, and we don't actually know which pins/pads are controlled by each bit (again, lack of documentation).
Quoted 5 lines
I realise this is contradictory to the point of having a pinctrl driver, but it was the best I could come up with given the poor information we have.
Always open to suggestions..
In that case I strongly prefer that you try to encode this into the driver as such if that is possible. Putting it into the device tree will be subject to flux, and while we can handle some drastic code changes internally in the kernel, device trees will need to stay backward-compatible.
Isn't it possible to put a table for this into the kernel code and just switch the right numbers in from the compatible= string?
Yours,
Linus Walleij
[Bulk] Re: [PATCH 2/6] pinctrl: gpio: vt8500: Add pincontrol driver for arch-vt8500
Quoted 43 lines · Linus Walleij
Quoted 30 lines · Tony Prisk
Quoted 7 lines · Stephen Warren
Quoted 2 lines
+Required subnode-properties:
+- wm,pins: An array of cells. Each cell contains the ID of a pin.That's a little odd. Presumably this is to allow configuring "pin configuration" data beyond the mux function and pull. Why aren't those options exposed as explicit properties, rather than allowing manual register tweaking?
Little confused about this one - wm,pins is the same as the brcm binding and is the pins being configured.
I assume you mean wm,pinmux is confusing.
The wm,pinmux does, as you guessed, control some addition pinmux alternate features. I exposed it this way because we don't know what most of the bits in the register do (There is no vendor hardware documentation for these SoCs), and rather than having to churn the code constantly to add the new configurations it seemed to make sense to just expose the register this way and let people configure it in the DT. It is masked so that we can change only the bits we know and leave the rest as configured by the bootloader.
Also, it would also add a lot of complexity to the pinctrl code to support the few additional functions we know this register provides because each SoC has a different layout for bits in this register, and we don't actually know which pins/pads are controlled by each bit (again, lack of documentation).
Quoted 5 lines
I realise this is contradictory to the point of having a pinctrl driver, but it was the best I could come up with given the poor information we have.
Always open to suggestions..
In that case I strongly prefer that you try to encode this into the driver as such if that is possible. Putting it into the device tree will be subject to flux, and while we can handle some drastic code changes internally in the kernel, device trees will need to stay backward-compatible.
Quoted 5 lines
Isn't it possible to put a table for this into the kernel code and just switch the right numbers in from the compatible= string?
Yours,
Linus Walleij
To give an example of what this register does...
On VT8500 we have some basic hardware docs which show this register as:
bit 0 - CCIR/LCD selection
bit 1:2 - AC97/PCM/I2S/Reserved
bit 3:4 - NOR+GUP/SF+NAND/SF+NAND/SF+PATA
bit 5:6 - UART2 disabled/UART1+UART2 pin shared/4 full function UARTS bit 7 - PATA enable/disable
bit 8:31 - Reserved
It doesn't have any details about which pads are related to which function, so implementing a proper pinmux feature would be next to impossible.
The only reason we use this register at present is to enable the LCD selection (bit 0 in this example - bit 31 on the other SoCs).
Other than that, we rely on uboot to have 'done the right thing'.
Regards
Tony P
[Bulk] Re: [PATCH 2/6] pinctrl: gpio: vt8500: Add pincontrol driver for arch-vt8500
Quoted 2 lines · Tony Prisk
The only reason we use this register at present is to enable the LCD selection (bit 0 in this example - bit 31 on the other SoCs).
OK then I guess there is not immediate need for that to be in the device tree right now? I'm happy if you open-code that.
Quoted 1 line
Other than that, we rely on uboot to have 'done the right thing'.
Do you have the U-boot sources to inspect on how this works then? You are legally entitled to them...
Or do you mean some earlier proprietary step has set them up, or something like power-on state? Then I'm following...
Yours,
Linus Walleij
[Bulk] Re: [PATCH 2/6] pinctrl: gpio: vt8500: Add pincontrol driver for arch-vt8500
Quoted 7 lines · Linus Walleij
Quoted 2 lines · Tony Prisk
The only reason we use this register at present is to enable the LCD selection (bit 0 in this example - bit 31 on the other SoCs).
OK then I guess there is not immediate need for that to be in the device tree right now? I'm happy if you open-code that.
Sorry - don't understand the meaning of 'open-code'. Could you elaborate on what you mean.
I only included the pinmux property so we could remove the requirement for arch-vt8500/vt8500.c to find a gpio DT node and modify this register (Patch 6).
If it's going to cause too many headaches implementing this particular bit, it could be dropped and the code stay in vt8500.c - I just wanted to move the code to where it should belong.
Quoted 5 lines
Quoted 2 lines
Other than that, we rely on uboot to have 'done the right thing'.
Do you have the U-boot sources to inspect on how this works then? You are legally entitled to them...
We have some uboot sources - although they are piecemeal and getting source code from Wondermedia is difficult to say the least.
Example reply from Wondermedia:
Hi Tony Prisk,
I m a Sr. engineer of Wondermedia company, any technical question
you can ask me. About Linux kernel Source of Android 4.0, We don?t release the linux kernel source code, for the most of customer cant develop the program by themself, if we open the source code, they also cant make development on our platform. They will ask many and many question.So we only release linux kernel source code to big company, such as pansonic, sony &...
If you also need linux kernel source code, you should Sign NDA
with our company and depend on the quantity of tablet you buy. If you have any question, you can ask me.
BR
??? Mason liu
CS-AP R&D-Hardware Dept.
Sr.HW
To which I basically said 'No I won't sign an NDA', and he came back and said 'No you can't have the source'.
Quoted 3 lines
Or do you mean some earlier proprietary step has set them up, or something like power-on state? Then I'm following...
Some of it is done in w-boot (no source code released, runs before u-boot), other stuff is power-on default.
Quoted 8 lines
Yours,
Linus Walleij_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
[Bulk] Re: [PATCH 2/6] pinctrl: gpio: vt8500: Add pincontrol driver for arch-vt8500
Quoted 11 lines · Tony Prisk
Quoted 7 lines · Linus Walleij
Quoted 2 lines · Tony Prisk
The only reason we use this register at present is to enable the LCD selection (bit 0 in this example - bit 31 on the other SoCs).
OK then I guess there is not immediate need for that to be in the device tree right now? I'm happy if you open-code that.
Sorry - don't understand the meaning of 'open-code'. Could you elaborate on what you mean.
To open-code is to write the information into the code as e.g. constants instead of stashing it into the device tree.
Quoted 7 lines
I only included the pinmux property so we could remove the requirement for
arch-vt8500/vt8500.cto find a gpio DT node and modify this register (Patch 6).If it's going to cause too many headaches implementing this particular bit, it could be dropped and the code stay in
vt8500.c- I just wanted to move the code to where it should belong.
I think this is better.
The problem is that if you add this to the DT, it will need to be supported forever, we are not allowed to remove bindings from the device tree, one day when we understand it.
Quoted 11 lines
Example reply from Wondermedia:
Hi Tony Prisk,
I m a Sr. engineer of Wondermedia company, any technical question
you can ask me. About Linux kernel Source of Android 4.0, We don?t release the linux kernel source code, for the most of customer cant develop the program by themself, if we open the source code, they also cant make development on our platform. They will ask many and many question.So we only release linux kernel source code to big company, such as pansonic, sony &...
Hm there is some education about how the community works to be done at this company.
It is by universal misunderstanding that we agree with each other. If, by some misfortune, we understood each other, we would never agree. (Baudelaire.)
So we get all the fun of reverse-engineering instead, well whatever :-/
Quoted 5 lines
Quoted 2 lines
Or do you mean some earlier proprietary step has set them up, or something like power-on state? Then I'm following...
Some of it is done in w-boot (no source code released, runs before u-boot), other stuff is power-on default.
OK. I get it, I think.
Yours,
Linus Walleij
PATCH 2/6 pinctrl: gpio: vt8500: Add pincontrol driver for arch-vt8500
In reply to Tony PriskQuoted 2 lines · Tony Prisk
This patch adds support for the GPIO/pinmux controller found on the VIA VT8500 and Wondermedia WM8xxx-series SoCs.
(...)
Allright!
The per-soc plugs and data look allright.
Maybe you want to put all files in drivers/pinctrl/wmt/*?
Just to keep track of things...
I start reviewing here:
(...)
Quoted 2 lines
drivers/pinctrl/pinctrl-wmt.c new file +0
-0
(...)
drivers/pinctrl/pinctrl-wmt.c line 41
Quoted 7 lines
drivers/pinctrl/pinctrl-wmt.c new file +7
-0+static void wmt_setbits (struct wmt_pinctrl_data *data,u32 reg,u32 mask) +{ +u32 val; + + val =readl (data->base + reg); + val |= mask; +writel (val, data->base + reg);
Consider readl_relaxed(), writel_relaxed()
drivers/pinctrl/pinctrl-wmt.c line 50
Quoted 9 lines
drivers/pinctrl/pinctrl-wmt.c new file +9
-0+} + +static void wmt_clearbits (struct wmt_pinctrl_data *data,u32 reg,u32 mask) +{ +u32 val; + + val =readl (data->base + reg); + val &= ~mask; +writel (val, data->base + reg);
Dito.
Quoted 1 line
+}
I usually type "static inline" on such functions, not for the compiler but for the human reader so as to understand it is to be quick.
(...)
Quoted 8 lines
drivers/pinctrl/pinctrl-wmt.c new file +8
-0+static int wmt_set_pinmux (struct wmt_pinctrl_data *data,unsigned func, +unsigned pin) +{ +u32 bank =WMT_BANK_FROM_PIN (pin); +u32 bit =WMT_BIT_FROM_PIN (pin); +u32 reg_en = data->banks[bank].reg_en; +u32 reg_dir = data->banks[bank].reg_dir; +
drivers/pinctrl/pinctrl-wmt.c line 108
Quoted 10 lines
drivers/pinctrl/pinctrl-wmt.c new file +10
-0+if (reg_dir ==NO_REG ) { +dev_err (data->dev,"pin:%d no direction register defined\n" , + pin); +return -EINVAL ; + } + +/* +* If reg_en == NO_REG, we assume it is a dedicated GPIO and cannot be +* disabled (as on VT8500) and that no alternate function is available. +*/
There is something strange about the indentation of this comment that hurts my head. Please indent it like the surrounding code.
Quoted 22 lines
drivers/pinctrl/pinctrl-wmt.c new file +22
-0+switch (func) { +case WMT_FSEL_GPIO_IN : +if (reg_en !=NO_REG ) +wmt_setbits (data, reg_en,BIT (bit)); +wmt_clearbits (data, reg_dir,BIT (bit)); +break ; +case WMT_FSEL_GPIO_OUT : +if (reg_en !=NO_REG ) +wmt_setbits (data, reg_en,BIT (bit)); +wmt_setbits (data, reg_dir,BIT (bit)); +break ; +case WMT_FSEL_ALT : +if (reg_en ==NO_REG ) { +dev_err (data->dev,"pin:%d no alt function available\n" , + pin); +return -EINVAL ; + } +wmt_clearbits (data, reg_en,BIT (bit)); + } + +return 0 ; +}
(...)
drivers/pinctrl/pinctrl-wmt.c line 223
Quoted 10 lines
drivers/pinctrl/pinctrl-wmt.c new file +10
-0+static int wmt_pctl_find_group_by_pin (struct wmt_pinctrl_data *data,u32 pin) +{ +int i; + +for (i =0 ; i < data->npins; i++) { +if (data->pins[i].number == pin) +return i; + } + +return -1 ;
Is that a valid return code?
Use -EINVAL or something.
drivers/pinctrl/pinctrl-wmt.c line 231
Quoted 8 lines
drivers/pinctrl/pinctrl-wmt.c new file +8
-0+} + +static int wmt_pctl_dt_node_to_map_func (struct wmt_pinctrl_data *data, +struct device_node *np, +u32 pin,u32 fnum, +struct pinctrl_map **maps) +{ +u32 group;
int group;
drivers/pinctrl/pinctrl-wmt.c line 240
Quoted 9 lines
drivers/pinctrl/pinctrl-wmt.c new file +9
-0+struct pinctrl_map *map = *maps; + +if (fnum >=ARRAY_SIZE (wmt_functions)) { +dev_err (data->dev,"invalid wm,function %d\n" , fnum); +return -EINVAL ; + } + + group =wmt_pctl_find_group_by_pin (data, pin); +if (group ==-1 ) {
if (group < 0)
drivers/pinctrl/pinctrl-wmt.c
Quoted 2 lines
drivers/pinctrl/pinctrl-wmt.c new file +2
-0+dev_err (data->dev,"unable to match pin %d to group\n" , pin); +return -EINVAL ;
Then just return group;
Quoted 6 lines
drivers/pinctrl/pinctrl-wmt.c new file +6
-0+ } + + map->type =PIN_MAP_TYPE_MUX_GROUP ; + map->data.mux.group = data->groups[group]; + map->data.mux.function = wmt_functions[fnum]; + (*maps)++;
drivers/pinctrl/pinctrl-wmt.c line 258
Quoted 10 lines
drivers/pinctrl/pinctrl-wmt.c new file +10
-0+ +return 0 ; +} + +static int wmt_pctl_dt_node_to_map_pull (struct wmt_pinctrl_data *data, +struct device_node *np, +u32 pin,u32 pull, +struct pinctrl_map **maps) +{ +u32 group;
int group;
drivers/pinctrl/pinctrl-wmt.c line 262
Quoted 4 lines
drivers/pinctrl/pinctrl-wmt.c new file +4
-0+unsigned long *configs; +struct pinctrl_map *map = *maps; + +
You can never have enough whitespace?
drivers/pinctrl/pinctrl-wmt.c line 269
Quoted 7 lines
drivers/pinctrl/pinctrl-wmt.c new file +7
-0+if (pull >2 ) { +dev_err (data->dev,"invalid wm,pull %d\n" , pull); +return -EINVAL ; + } + + group =wmt_pctl_find_group_by_pin (data, pin); +if (group ==-1 ) {
if (group < 0)
drivers/pinctrl/pinctrl-wmt.c
Quoted 2 lines
drivers/pinctrl/pinctrl-wmt.c new file +2
-0+dev_err (data->dev,"unable to match pin %d to group\n" , pin); +return -EINVAL ;
return group;
Quoted 11 lines
drivers/pinctrl/pinctrl-wmt.c new file +11
-0+ } + + configs =kzalloc (sizeof (*configs),GFP_KERNEL ); +if (!configs) +return -ENOMEM ; + + configs[0 ] =0 ; + + map->type =PIN_MAP_TYPE_CONFIGS_PIN ; + map->data.configs.group_or_pin = data->groups[group]; + map->data.configs.configs = configs;
drivers/pinctrl/pinctrl-wmt.c line 292
Quoted 10 lines
drivers/pinctrl/pinctrl-wmt.c new file +10
-0+ map->data.configs.num_configs =1 ; + (*maps)++; + +return 0 ; +} + +static inline u32 prop_u32 (struct property *p,int i) +{ +return be32_to_cpup (((__be32 *)p->value) + i); +}
Oh um I don't understand this helper. Can you explain or atleast add a comment?
If you really need it it should *not* be added to this driver but to the generic OF helpers in <linux/of_*>
Quoted 19 lines
drivers/pinctrl/pinctrl-wmt.c new file +19
-0+static int wmt_pctl_dt_node_to_map (struct pinctrl_dev *pctldev, +struct device_node *np, +struct pinctrl_map **map, +unsigned *num_maps) +{ +struct pinctrl_map *maps, *cur_map; +struct property *pins, *funcs, *pulls; +u32 pin, func, pull; +int num_pins, num_funcs, num_pulls, maps_per_pin; +int i, err; +struct wmt_pinctrl_data *data =pinctrl_dev_get_drvdata (pctldev); + + pins =of_find_property (np,"wm,pins" ,NULL ); +if (!pins) { +dev_err (data->dev,"missing wmt,pins property\n" ); +return -EINVAL ; + } + + funcs =of_find_property (np,"wm,function" ,NULL );
drivers/pinctrl/pinctrl-wmt.c line 322
Quoted 10 lines
drivers/pinctrl/pinctrl-wmt.c new file +10
-0+ pulls =of_find_property (np,"wm,pull" ,NULL ); + +if (!funcs && !pulls) { +dev_err (data->dev,"neither wm,function nor wm,pull specified\n" ); +return -EINVAL ; + } + + num_pins = pins->length /4 ; + num_funcs = funcs ? (funcs->length /4 ) :0 ; + num_pulls = pulls ? (pulls->length /4 ) :0 ;
Explain the magic constant (4) or use a #define.
Quoted 16 lines
drivers/pinctrl/pinctrl-wmt.c new file +16
-0+ +if (num_funcs >1 && num_funcs != num_pins) { +dev_err (data->dev,"wm,function must have 1 or %d entries\n" , + num_pins); +return -EINVAL ; + } + +if (num_pulls >1 && num_pulls != num_pins) { +dev_err (data->dev,"wm,pull must have 1 or %d entries\n" , + num_pins); +return -EINVAL ; + } + + maps_per_pin =0 ; +if (num_funcs) + maps_per_pin++;
drivers/pinctrl/pinctrl-wmt.c line 348
Quoted 10 lines
drivers/pinctrl/pinctrl-wmt.c new file +10
-0+if (num_pulls) + maps_per_pin++; + + cur_map = maps =kzalloc (num_pins * maps_per_pin *sizeof (*maps), +GFP_KERNEL ); +if (!maps) +return -ENOMEM ; + +for (i =0 ; i < num_pins; i++) { + pin =prop_u32 (pins, i);
So I don't get this. What is wrong with of_property_read_u32()?
I think there is something very strange about this parsing code if you can't use the common accessors to get the stuff you want, if you really need to inspect properties like that static inline does, then it should be explained and the function should *not* be in this driver but a helper in <linux/of_*> somewhere.
(...)
drivers/pinctrl/pinctrl-wmt.c line 483
Quoted 9 lines
drivers/pinctrl/pinctrl-wmt.c new file +9
-0+static int wmt_gpio_get_direction (struct gpio_chip *chip,unsigned offset) +{ +struct wmt_pinctrl_data *data =dev_get_drvdata (chip->dev); +u32 bank =WMT_BANK_FROM_PIN (offset); +u32 bit =WMT_BIT_FROM_PIN (offset); +u32 reg_dir = data->banks[bank].reg_dir; +u32 val; + + val =readl (data->base + reg_dir) &BIT (bit);
Consider readl_relaxed()
Don't do the & operation there plese...
Quoted 1 line
+ if (val)
Do if (val & BIT(bit)) here instead.
Quoted 19 lines
drivers/pinctrl/pinctrl-wmt.c new file +19
-0+return GPIOF_DIR_OUT ; + else + return GPIOF_DIR_IN; +} + +static int wmt_gpio_direction_input (struct gpio_chip *chip,unsigned offset) +{ +return pinctrl_gpio_direction_input (chip->base + offset); +} + +static int wmt_gpio_direction_output (struct gpio_chip *chip,unsigned offset, +int value) +{ +return pinctrl_gpio_direction_output (chip->base + offset); +} + +static int wmt_gpio_get_value (struct gpio_chip *chip,unsigned offset) +{ +struct wmt_pinctrl_data *data =dev_get_drvdata (chip->dev);
drivers/pinctrl/pinctrl-wmt.c line 513
Quoted 10 lines
drivers/pinctrl/pinctrl-wmt.c new file +10
-0+u32 bank =WMT_BANK_FROM_PIN (offset); +u32 bit =WMT_BIT_FROM_PIN (offset); +u32 reg_data_in = data->banks[bank].reg_data_in; + +if (reg_data_in ==NO_REG ) { +dev_err (data->dev,"no data in register defined\n" ); +return -EINVAL ; + } + +return (readl (data->base + reg_data_in) >> bit) &1 ;
Consider readl_relaxed()
Consider this pattern:
return !!(readl(data->base + reg_data_in) & BIT(bit));
drivers/pinctrl/pinctrl-wmt.c line 517
Quoted 2 lines
drivers/pinctrl/pinctrl-wmt.c new file +2
-0+static void wmt_gpio_set_value (struct gpio_chip *chip,unsigned offset, +int value)
Just int val since you use "val" rather than "value" elsewhere in the code.
Quoted 32 lines
drivers/pinctrl/pinctrl-wmt.c new file +32
-0+{ +struct wmt_pinctrl_data *data =dev_get_drvdata (chip->dev); +u32 bank =WMT_BANK_FROM_PIN (offset); +u32 bit =WMT_BIT_FROM_PIN (offset); +u32 reg_data_out = data->banks[bank].reg_data_out; + +if (reg_data_out ==NO_REG ) { +dev_err (data->dev,"no data out register defined\n" ); +return ; + } + +if (value) +wmt_setbits (data, reg_data_out,BIT (bit)); +else +wmt_clearbits (data, reg_data_out,BIT (bit)); +} + +static struct gpio_chip wmt_gpio_chip = { + .label ="gpio-wmt" , + .owner =THIS_MODULE , + .request = wmt_gpio_request, + .free = wmt_gpio_free, + .get_direction = wmt_gpio_get_direction, + .direction_input = wmt_gpio_direction_input, + .direction_output = wmt_gpio_direction_output, + .get = wmt_gpio_get_value, + .set = wmt_gpio_set_value, + .base =-1 , + .can_sleep =0 , +}; + +void wmt_dt_pinmux_config (struct wmt_pinctrl_data *data)
drivers/pinctrl/pinctrl-wmt.c line 559
Quoted 10 lines
drivers/pinctrl/pinctrl-wmt.c new file +10
-0+{ +struct device_node *np = data->dev->of_node; +u32 pinmux[2 ]; +u32 val; +int ret; + + ret =of_property_read_u32_array (np,"wm,pinmux" , pinmux,2 ); +if (!ret) { +/* pinmux[0] = data, pinmux[1] = mask */ + val =readl (data->base +0x200 );
+0x200?
Please #define this magic constand so we understand what kind of register this is.
But I understand this may be that register that does some pinmuxing that is not properly documented... Then just
#define VT8500_MAGIC_PMX_REG 0x200 or whatever.
drivers/pinctrl/pinctrl-wmt.c line 562
Quoted 3 lines
drivers/pinctrl/pinctrl-wmt.c new file +3
-0+ val &= ~(~pinmux[0 ] & pinmux[1 ]); + val |= (pinmux[0 ] & pinmux[1 ]); +writel (val, data->base +0x200 );
Consider readl_relaxed()/writel_relaxed().
Quoted 25 lines
drivers/pinctrl/pinctrl-wmt.c new file +25
-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; +wmt_dt_pinmux_config (data); + + data->pctl_dev =pinctrl_register (&wmt_desc, &pdev->dev, data); +if (IS_ERR (data->pctl_dev)) { +dev_err (&pdev->dev,"Failed to register pinctrl\n" ); +return -EINVAL ;
drivers/pinctrl/pinctrl-wmt.c line 597
Quoted 10 lines
drivers/pinctrl/pinctrl-wmt.c new file +10
-0+ } + + err =gpiochip_add (&data->gpio_chip); +if (err) { +dev_err (&pdev->dev,"could not add GPIO chip\n" ); + goto fail_gpio; + } + + err =gpiochip_add_pin_range (&data->gpio_chip,dev_name (data->dev), +0 ,0 , data->nbanks *32 );
Good that you use gpiochip_add_pin_range()!
drivers/pinctrl/pinctrl-wmt.c line 603
Quoted 6 lines
drivers/pinctrl/pinctrl-wmt.c new file +6
-0+if (err) + goto fail_range; + +dev_info (&pdev->dev,"Pin controller initialized\n" ); + +return 0 ;
Newline.
Quoted 12 lines
drivers/pinctrl/pinctrl-wmt.c new file +12
-0+fail_range: + err =gpiochip_remove (&data->gpio_chip); +if (err) +dev_err (&pdev->dev,"failed to remove gpio chip\n" ); +fail_gpio: +pinctrl_unregister (data->pctl_dev); +return err; +} + +int wmt_pinctrl_remove (struct platform_device *pdev) +{ +struct wmt_pinctrl_data *data =platform_get_drvdata (pdev);
drivers/pinctrl/pinctrl-wmt.c line 625
Quoted 10 lines
drivers/pinctrl/pinctrl-wmt.c new file +10
-0+int err; + + err =gpiochip_remove (&data->gpio_chip); +if (err) +dev_err (&pdev->dev,"failed to remove gpio chip\n" ); + +pinctrl_unregister (data->pctl_dev); + +return 0 ; +}
Quite a bit of code. I might have missed something that I will come back and complain about later...
Yours,
Linus Walleij
PATCH 2/6 pinctrl: gpio: vt8500: Add pincontrol driver for arch-vt8500
Quoted 11 lines · Linus Walleij
Quoted 2 lines · Tony Prisk
This patch adds support for the GPIO/pinmux controller found on the VIA VT8500 and Wondermedia WM8xxx-series SoCs.
(...)
drivers/pinctrl/pinctrl-wmt.c line 348
Quoted 4 lines
drivers/pinctrl/pinctrl-wmt.c new file +3
-0+static int wmt_pctl_dt_node_to_map (struct pinctrl_dev *pctldev, + for (i = 0; i < num_pins; i++) { + pin =prop_u32 (pins, i);
Quoted 7 lines
So I don't get this. What is wrong with
of_property_read_u32()?I think there is something very strange about this parsing code if you can't use the common accessors to get the stuff you want, if you really need to inspect properties like that static inline does, then it should be explained and the function should *not* be in this driver but a helper in <linux/of_*> somewhere.
There is no of_property_read_u32_index(), which would read the nth u32 in a list of them. You're right there probably should be. My fault for not creating one when I first wrote that code in the Tegra driver:-(
PATCH 2/6 pinctrl: gpio: vt8500: Add pincontrol driver for arch-vt8500
Quoted 11 lines · Stephen Warren
Quoted 5 lines · Linus Walleij
I think there is something very strange about this parsing code if you can't use the common accessors to get the stuff you want, if you really need to inspect properties like that static inline does, then it should be explained and the function should *not* be in this driver but a helper in <linux/of_*> somewhere.
There is no
of_property_read_u32_index(), which would read the nth u32 in a list of them. You're right there probably should be. My fault for not creating one when I first wrote that code in the Tegra driver:-(
Hm OK so Tony,
can we have a separate patch for adding that to the OF helpers, (to be ACKed by Rob).
I bet Stephen will quickly send a patch for fixing up the Tegra driver after that :-)
Yours,
Linus Walleij
PATCH 2/6 pinctrl: gpio: vt8500: Add pincontrol driver for arch-vt8500
Quoted 18 lines · Linus Walleij
Quoted 11 lines · Stephen Warren
Quoted 5 lines · Linus Walleij
I think there is something very strange about this parsing code if you can't use the common accessors to get the stuff you want, if you really need to inspect properties like that static inline does, then it should be explained and the function should *not* be in this driver but a helper in <linux/of_*> somewhere.
There is no
of_property_read_u32_index(), which would read the nth u32 in a list of them. You're right there probably should be. My fault for not creating one when I first wrote that code in the Tegra driver:-(Hm OK so Tony,
can we have a separate patch for adding that to the OF helpers, (to be ACKed by Rob).
Quoted 5 lines
I bet Stephen will quickly send a patch for fixing up the Tegra driver after that :-)
Yours,
Linus Walleij
Will do.
Regards
Tony P
PATCH 2/6 pinctrl: gpio: vt8500: Add pincontrol driver for arch-vt8500
In reply to Linus WalleijQuoted 465 lines · Linus Walleij
Quoted 2 lines · Tony Prisk
This patch adds support for the GPIO/pinmux controller found on the VIA VT8500 and Wondermedia WM8xxx-series SoCs.
(...)
Allright!
The per-soc plugs and data look allright.
Maybe you want to put all files in
drivers/pinctrl/wmt/*?Just to keep track of things...
I start reviewing here:
(...)
Quoted 2 lines
drivers/pinctrl/pinctrl-wmt.c new file +0
-0(...)
drivers/pinctrl/pinctrl-wmt.c line 41
Quoted 7 lines
drivers/pinctrl/pinctrl-wmt.c new file +7
-0+static void wmt_setbits (struct wmt_pinctrl_data *data,u32 reg,u32 mask) +{ +u32 val; + + val =readl (data->base + reg); + val |= mask; +writel (val, data->base + reg);Consider
readl_relaxed(),writel_relaxed()drivers/pinctrl/pinctrl-wmt.c line 50
Quoted 9 lines
drivers/pinctrl/pinctrl-wmt.c new file +9
-0+} + +static void wmt_clearbits (struct wmt_pinctrl_data *data,u32 reg,u32 mask) +{ +u32 val; + + val =readl (data->base + reg); + val &= ~mask; +writel (val, data->base + reg);Dito.
Quoted 1 line
+}
I usually type "static inline" on such functions, not for the compiler but for the human reader so as to understand it is to be quick.
(...)
Quoted 8 lines
drivers/pinctrl/pinctrl-wmt.c new file +8
-0+static int wmt_set_pinmux (struct wmt_pinctrl_data *data,unsigned func, +unsigned pin) +{ +u32 bank =WMT_BANK_FROM_PIN (pin); +u32 bit =WMT_BIT_FROM_PIN (pin); +u32 reg_en = data->banks[bank].reg_en; +u32 reg_dir = data->banks[bank].reg_dir; +drivers/pinctrl/pinctrl-wmt.c line 108
Quoted 10 lines
drivers/pinctrl/pinctrl-wmt.c new file +10
-0+if (reg_dir ==NO_REG ) { +dev_err (data->dev,"pin:%d no direction register defined\n" , + pin); +return -EINVAL ; + } + +/* +* If reg_en == NO_REG, we assume it is a dedicated GPIO and cannot be +* disabled (as on VT8500) and that no alternate function is available. +*/ There is something strange about the indentation of this comment that hurts my head. Please indent it like the surrounding code.
Quoted 22 lines
drivers/pinctrl/pinctrl-wmt.c new file +22
-0+switch (func) { +case WMT_FSEL_GPIO_IN : +if (reg_en !=NO_REG ) +wmt_setbits (data, reg_en,BIT (bit)); +wmt_clearbits (data, reg_dir,BIT (bit)); +break ; +case WMT_FSEL_GPIO_OUT : +if (reg_en !=NO_REG ) +wmt_setbits (data, reg_en,BIT (bit)); +wmt_setbits (data, reg_dir,BIT (bit)); +break ; +case WMT_FSEL_ALT : +if (reg_en ==NO_REG ) { +dev_err (data->dev,"pin:%d no alt function available\n" , + pin); +return -EINVAL ; + } +wmt_clearbits (data, reg_en,BIT (bit)); + } + +return 0 ; +}(...)
drivers/pinctrl/pinctrl-wmt.c line 223
Quoted 10 lines
drivers/pinctrl/pinctrl-wmt.c new file +10
-0+static int wmt_pctl_find_group_by_pin (struct wmt_pinctrl_data *data,u32 pin) +{ +int i; + +for (i =0 ; i < data->npins; i++) { +if (data->pins[i].number == pin) +return i; + } + +return -1 ;Is that a valid return code?
Use
-EINVALor something.drivers/pinctrl/pinctrl-wmt.c line 231
Quoted 8 lines
drivers/pinctrl/pinctrl-wmt.c new file +8
-0+} + +static int wmt_pctl_dt_node_to_map_func (struct wmt_pinctrl_data *data, +struct device_node *np, +u32 pin,u32 fnum, +struct pinctrl_map **maps) +{ +u32 group;int group;
drivers/pinctrl/pinctrl-wmt.c line 240
Quoted 9 lines
drivers/pinctrl/pinctrl-wmt.c new file +9
-0+struct pinctrl_map *map = *maps; + +if (fnum >=ARRAY_SIZE (wmt_functions)) { +dev_err (data->dev,"invalid wm,function %d\n" , fnum); +return -EINVAL ; + } + + group =wmt_pctl_find_group_by_pin (data, pin); +if (group ==-1 ) {if (group < 0)
drivers/pinctrl/pinctrl-wmt.c
Quoted 2 lines
drivers/pinctrl/pinctrl-wmt.c new file +2
-0+dev_err (data->dev,"unable to match pin %d to group\n" , pin); +return -EINVAL ;Then just return group;
Quoted 6 lines
drivers/pinctrl/pinctrl-wmt.c new file +6
-0+ } + + map->type =PIN_MAP_TYPE_MUX_GROUP ; + map->data.mux.group = data->groups[group]; + map->data.mux.function = wmt_functions[fnum]; + (*maps)++;drivers/pinctrl/pinctrl-wmt.c line 258
Quoted 10 lines
drivers/pinctrl/pinctrl-wmt.c new file +10
-0+ +return 0 ; +} + +static int wmt_pctl_dt_node_to_map_pull (struct wmt_pinctrl_data *data, +struct device_node *np, +u32 pin,u32 pull, +struct pinctrl_map **maps) +{ +u32 group;int group;
drivers/pinctrl/pinctrl-wmt.c line 262
Quoted 4 lines
drivers/pinctrl/pinctrl-wmt.c new file +4
-0+unsigned long *configs; +struct pinctrl_map *map = *maps; + +You can never have enough whitespace?
drivers/pinctrl/pinctrl-wmt.c line 269
Quoted 7 lines
drivers/pinctrl/pinctrl-wmt.c new file +7
-0+if (pull >2 ) { +dev_err (data->dev,"invalid wm,pull %d\n" , pull); +return -EINVAL ; + } + + group =wmt_pctl_find_group_by_pin (data, pin); +if (group ==-1 ) {if (group < 0)
drivers/pinctrl/pinctrl-wmt.c
Quoted 2 lines
drivers/pinctrl/pinctrl-wmt.c new file +2
-0+dev_err (data->dev,"unable to match pin %d to group\n" , pin); +return -EINVAL ;return group;
Quoted 11 lines
drivers/pinctrl/pinctrl-wmt.c new file +11
-0+ } + + configs =kzalloc (sizeof (*configs),GFP_KERNEL ); +if (!configs) +return -ENOMEM ; + + configs[0 ] =0 ; + + map->type =PIN_MAP_TYPE_CONFIGS_PIN ; + map->data.configs.group_or_pin = data->groups[group]; + map->data.configs.configs = configs;drivers/pinctrl/pinctrl-wmt.c line 292
Quoted 10 lines
drivers/pinctrl/pinctrl-wmt.c new file +10
-0+ map->data.configs.num_configs =1 ; + (*maps)++; + +return 0 ; +} + +static inline u32 prop_u32 (struct property *p,int i) +{ +return be32_to_cpup (((__be32 *)p->value) + i); +}Oh um I don't understand this helper. Can you explain or atleast add a comment?
If you really need it it should *not* be added to this driver but to the generic OF helpers in <linux/of_*>
Quoted 19 lines
drivers/pinctrl/pinctrl-wmt.c new file +19
-0+static int wmt_pctl_dt_node_to_map (struct pinctrl_dev *pctldev, +struct device_node *np, +struct pinctrl_map **map, +unsigned *num_maps) +{ +struct pinctrl_map *maps, *cur_map; +struct property *pins, *funcs, *pulls; +u32 pin, func, pull; +int num_pins, num_funcs, num_pulls, maps_per_pin; +int i, err; +struct wmt_pinctrl_data *data =pinctrl_dev_get_drvdata (pctldev); + + pins =of_find_property (np,"wm,pins" ,NULL ); +if (!pins) { +dev_err (data->dev,"missing wmt,pins property\n" ); +return -EINVAL ; + } + + funcs =of_find_property (np,"wm,function" ,NULL );drivers/pinctrl/pinctrl-wmt.c line 322
Quoted 10 lines
drivers/pinctrl/pinctrl-wmt.c new file +10
-0+ pulls =of_find_property (np,"wm,pull" ,NULL ); + +if (!funcs && !pulls) { +dev_err (data->dev,"neither wm,function nor wm,pull specified\n" ); +return -EINVAL ; + } + + num_pins = pins->length /4 ; + num_funcs = funcs ? (funcs->length /4 ) :0 ; + num_pulls = pulls ? (pulls->length /4 ) :0 ;Explain the magic constant (4) or use a #define.
Quoted 16 lines
drivers/pinctrl/pinctrl-wmt.c new file +16
-0+ +if (num_funcs >1 && num_funcs != num_pins) { +dev_err (data->dev,"wm,function must have 1 or %d entries\n" , + num_pins); +return -EINVAL ; + } + +if (num_pulls >1 && num_pulls != num_pins) { +dev_err (data->dev,"wm,pull must have 1 or %d entries\n" , + num_pins); +return -EINVAL ; + } + + maps_per_pin =0 ; +if (num_funcs) + maps_per_pin++;drivers/pinctrl/pinctrl-wmt.c line 348
Quoted 10 lines
drivers/pinctrl/pinctrl-wmt.c new file +10
-0+if (num_pulls) + maps_per_pin++; + + cur_map = maps =kzalloc (num_pins * maps_per_pin *sizeof (*maps), +GFP_KERNEL ); +if (!maps) +return -ENOMEM ; + +for (i =0 ; i < num_pins; i++) { + pin =prop_u32 (pins, i);So I don't get this. What is wrong with
of_property_read_u32()?I think there is something very strange about this parsing code if you can't use the common accessors to get the stuff you want, if you really need to inspect properties like that static inline does, then it should be explained and the function should *not* be in this driver but a helper in <linux/of_*> somewhere.
(...)
drivers/pinctrl/pinctrl-wmt.c line 483
Quoted 9 lines
drivers/pinctrl/pinctrl-wmt.c new file +9
-0+static int wmt_gpio_get_direction (struct gpio_chip *chip,unsigned offset) +{ +struct wmt_pinctrl_data *data =dev_get_drvdata (chip->dev); +u32 bank =WMT_BANK_FROM_PIN (offset); +u32 bit =WMT_BIT_FROM_PIN (offset); +u32 reg_dir = data->banks[bank].reg_dir; +u32 val; + + val =readl (data->base + reg_dir) &BIT (bit);Consider
readl_relaxed()Don't do the & operation there plese...
Quoted 1 line
+ if (val)
Do if (val & BIT(bit)) here instead.
Quoted 19 lines
drivers/pinctrl/pinctrl-wmt.c new file +19
-0+return GPIOF_DIR_OUT ; + else + return GPIOF_DIR_IN; +} + +static int wmt_gpio_direction_input (struct gpio_chip *chip,unsigned offset) +{ +return pinctrl_gpio_direction_input (chip->base + offset); +} + +static int wmt_gpio_direction_output (struct gpio_chip *chip,unsigned offset, +int value) +{ +return pinctrl_gpio_direction_output (chip->base + offset); +} + +static int wmt_gpio_get_value (struct gpio_chip *chip,unsigned offset) +{ +struct wmt_pinctrl_data *data =dev_get_drvdata (chip->dev);drivers/pinctrl/pinctrl-wmt.c line 513
Quoted 10 lines
drivers/pinctrl/pinctrl-wmt.c new file +10
-0+u32 bank =WMT_BANK_FROM_PIN (offset); +u32 bit =WMT_BIT_FROM_PIN (offset); +u32 reg_data_in = data->banks[bank].reg_data_in; + +if (reg_data_in ==NO_REG ) { +dev_err (data->dev,"no data in register defined\n" ); +return -EINVAL ; + } + +return (readl (data->base + reg_data_in) >> bit) &1 ;Consider
readl_relaxed()Consider this pattern:
return !!(readl(data->base +reg_data_in) & BIT(bit));drivers/pinctrl/pinctrl-wmt.c line 517
Quoted 2 lines
drivers/pinctrl/pinctrl-wmt.c new file +2
-0+static void wmt_gpio_set_value (struct gpio_chip *chip,unsigned offset, +int value)Just int val since you use "val" rather than "value" elsewhere in the code.
Quoted 32 lines
drivers/pinctrl/pinctrl-wmt.c new file +32
-0+{ +struct wmt_pinctrl_data *data =dev_get_drvdata (chip->dev); +u32 bank =WMT_BANK_FROM_PIN (offset); +u32 bit =WMT_BIT_FROM_PIN (offset); +u32 reg_data_out = data->banks[bank].reg_data_out; + +if (reg_data_out ==NO_REG ) { +dev_err (data->dev,"no data out register defined\n" ); +return ; + } + +if (value) +wmt_setbits (data, reg_data_out,BIT (bit)); +else +wmt_clearbits (data, reg_data_out,BIT (bit)); +} + +static struct gpio_chip wmt_gpio_chip = { + .label ="gpio-wmt" , + .owner =THIS_MODULE , + .request = wmt_gpio_request, + .free = wmt_gpio_free, + .get_direction = wmt_gpio_get_direction, + .direction_input = wmt_gpio_direction_input, + .direction_output = wmt_gpio_direction_output, + .get = wmt_gpio_get_value, + .set = wmt_gpio_set_value, + .base =-1 , + .can_sleep =0 , +}; + +void wmt_dt_pinmux_config (struct wmt_pinctrl_data *data)drivers/pinctrl/pinctrl-wmt.c line 559
Quoted 10 lines
drivers/pinctrl/pinctrl-wmt.c new file +10
-0+{ +struct device_node *np = data->dev->of_node; +u32 pinmux[2 ]; +u32 val; +int ret; + + ret =of_property_read_u32_array (np,"wm,pinmux" , pinmux,2 ); +if (!ret) { +/* pinmux[0] = data, pinmux[1] = mask */ + val =readl (data->base +0x200 );+0x200?
Please #define this magic constand so we understand what kind of register this is.
But I understand this may be that register that does some pinmuxing that is not properly documented... Then just
#define
VT8500_MAGIC_PMX_REG0x200or whatever.drivers/pinctrl/pinctrl-wmt.c line 562
Quoted 3 lines
drivers/pinctrl/pinctrl-wmt.c new file +3
-0+ val &= ~(~pinmux[0 ] & pinmux[1 ]); + val |= (pinmux[0 ] & pinmux[1 ]); +writel (val, data->base +0x200 );Consider readl_relaxed()/writel_relaxed().
Quoted 25 lines
drivers/pinctrl/pinctrl-wmt.c new file +25
-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; +wmt_dt_pinmux_config (data); + + data->pctl_dev =pinctrl_register (&wmt_desc, &pdev->dev, data); +if (IS_ERR (data->pctl_dev)) { +dev_err (&pdev->dev,"Failed to register pinctrl\n" ); +return -EINVAL ;drivers/pinctrl/pinctrl-wmt.c line 597
Quoted 10 lines
drivers/pinctrl/pinctrl-wmt.c new file +10
-0+ } + + err =gpiochip_add (&data->gpio_chip); +if (err) { +dev_err (&pdev->dev,"could not add GPIO chip\n" ); + goto fail_gpio; + } + + err =gpiochip_add_pin_range (&data->gpio_chip,dev_name (data->dev), +0 ,0 , data->nbanks *32 );Good that you use
gpiochip_add_pin_range()!drivers/pinctrl/pinctrl-wmt.c line 603
Quoted 6 lines
drivers/pinctrl/pinctrl-wmt.c new file +6
-0+if (err) + goto fail_range; + +dev_info (&pdev->dev,"Pin controller initialized\n" ); + +return 0 ;Newline.
Quoted 12 lines
drivers/pinctrl/pinctrl-wmt.c new file +12
-0+fail_range: + err =gpiochip_remove (&data->gpio_chip); +if (err) +dev_err (&pdev->dev,"failed to remove gpio chip\n" ); +fail_gpio: +pinctrl_unregister (data->pctl_dev); +return err; +} + +int wmt_pinctrl_remove (struct platform_device *pdev) +{ +struct wmt_pinctrl_data *data =platform_get_drvdata (pdev);drivers/pinctrl/pinctrl-wmt.c line 625
Quoted 10 lines
drivers/pinctrl/pinctrl-wmt.c new file +10
-0+int err; + + err =gpiochip_remove (&data->gpio_chip); +if (err) +dev_err (&pdev->dev,"failed to remove gpio chip\n" ); + +pinctrl_unregister (data->pctl_dev); + +return 0 ; +}Quite a bit of code. I might have missed something that I will come back and complain about later...
Quoted 2 lines
Yours,
Linus Walleij
Thanks for the feedback. I'll look over it shortly and tidy it up.
Regards
Tony P
PATCH 3/6 arm: dts: vt8500: Update Wondermedia SoC dtsi files for pinctrl driver
In reply to Tony PriskThis patch adds pinctrl nodes to the VIA VT8500 and Wondermedia SoC dtsi files to support the pinctrl driver.
--- arch/arm/boot/dts/vt8500.dtsi | 8 ++++++++ arch/arm/boot/dts/wm8505.dtsi | 8 ++++++++ arch/arm/boot/dts/wm8650.dtsi | 8 ++++++++ arch/arm/boot/dts/wm8850.dtsi | 8 ++++++++ 4 files changed, 32 insertions(+)
arch/arm/boot/dts/vt8500.dtsi +8 -0
@@ -32,6 +32,14 @@ #gpio-cells = <3>; }; + pinctrl: pinctrl at d8110000 { + compatible = "via,vt8500-pinctrl"; + gpio-controller; + reg = <0xd8110000 0x10000>; + #gpio-cells = <2>; + wm,pinmux = <0x00000001 0x00000001>; + }; + pmc at d8130000 { compatible = "via,vt8500-pmc"; reg = <0xd8130000 0x1000>;
arch/arm/boot/dts/wm8505.dtsi +8 -0
@@ -47,6 +47,14 @@ #gpio-cells = <3>; }; + pinctrl: pinctrl at d8110000 { + compatible = "wm,wm8505-pinctrl"; + gpio-controller; + reg = <0xd8110000 0x10000>; + #gpio-cells = <2>; + wm,pinmux = <0x80000000 0x80000000>; + }; + pmc at d8130000 { compatible = "via,vt8500-pmc"; reg = <0xd8130000 0x1000>;
arch/arm/boot/dts/wm8650.dtsi +8 -0
@@ -41,6 +41,14 @@ #gpio-cells = <3>; }; + pinctrl: pinctrl at d8110000 { + compatible = "wm,wm8650-pinctrl"; + gpio-controller; + reg = <0xd8110000 0x10000>; + #gpio-cells = <2>; + wm,pinmux = <0x80000000 0x80000000>; + }; + pmc at d8130000 { compatible = "via,vt8500-pmc"; reg = <0xd8130000 0x1000>;
arch/arm/boot/dts/wm8850.dtsi +8 -0
@@ -48,6 +48,14 @@ #gpio-cells = <3>; }; + pinctrl: pinctrl at d8110000 { + compatible = "wm,wm8850-pinctrl"; + gpio-controller; + reg = <0xd8110000 0x10000>; + #gpio-cells = <2>; + wm,pinmux = <0x80000000 0x80000000>; + }; + pmc at d8130000 { compatible = "via,vt8500-pmc"; reg = <0xd8130000 0x1000>;
Signature · 1 line
1.7.9.5
PATCH 3/6 arm: dts: vt8500: Update Wondermedia SoC dtsi files for pinctrl driver
arch/arm/boot/dts/vt8500.dtsi line 41
Quoted 12 lines · Tony Prisk
This patch adds pinctrl nodes to the VIA VT8500 and Wondermedia SoC dtsi files to support the pinctrl driver.
arch/arm/boot/dts/vt8500.dtsi +7
-0+ pinctrl: pinctrl at d8110000 { + compatible = "via,vt8500-pinctrl"; + gpio-controller; + reg = <0xd8110000 0x10000>; + #gpio-cells = <2>; + wm,pinmux = <0x00000001 0x00000001>; + };
In the binding documentation, "wm,pinmux" is listed under "optional sub-node properties", but here the property is included in the main node, not a sub-node.
I'm a little confused what this property means then...
PATCH 3/6 arm: dts: vt8500: Update Wondermedia SoC dtsi files for pinctrl driver
Quoted 18 lines · Stephen Warren
arch/arm/boot/dts/vt8500.dtsi line 41
Quoted 12 lines · Tony Prisk
This patch adds pinctrl nodes to the VIA VT8500 and Wondermedia SoC dtsi files to support the pinctrl driver.
arch/arm/boot/dts/vt8500.dtsi +7
-0+ pinctrl: pinctrl at d8110000 { + compatible = "via,vt8500-pinctrl"; + gpio-controller; + reg = <0xd8110000 0x10000>; + #gpio-cells = <2>; + wm,pinmux = <0x00000001 0x00000001>; + };In the binding documentation, "wm,pinmux" is listed under "optional sub-node properties", but here the property is included in the main node, not a sub-node.
Quoted 6 lines
I'm a little confused what this property means then...
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sorry - this was copied in large part from the brcm,bcm2835-gpio.txt binding. I added wm,pinmux alongside the existing wm,pins, wm,function and wm,pull properties.
You are correct that this shouldn't be listed as a subnode property.
Regards
Tony P
PATCH 4/6 arm: vt8500: Remove gpio devicetree nodes
In reply to Tony PriskRemove the gpio related devicetree nodes as these are no longer required with the move to a combined pinctrl/gpio driver.
--- arch/arm/boot/dts/vt8500.dtsi | 7 ------- arch/arm/boot/dts/wm8505.dtsi | 7 ------- arch/arm/boot/dts/wm8650.dtsi | 7 ------- arch/arm/boot/dts/wm8850.dtsi | 7 ------- 4 files changed, 28 deletions(-)
arch/arm/boot/dts/vt8500.dtsi +0 -7
@@ -25,13 +25,6 @@ #interrupt-cells = <1>; }; - gpio: gpio-controller at d8110000 { - compatible = "via,vt8500-gpio"; - gpio-controller; - reg = <0xd8110000 0x10000>; - #gpio-cells = <3>; - }; - pinctrl: pinctrl at d8110000 { compatible = "via,vt8500-pinctrl"; gpio-controller;
arch/arm/boot/dts/wm8505.dtsi +0 -7
@@ -40,13 +40,6 @@ interrupts = <56 57 58 59 60 61 62 63>; }; - gpio: gpio-controller at d8110000 { - compatible = "wm,wm8505-gpio"; - gpio-controller; - reg = <0xd8110000 0x10000>; - #gpio-cells = <3>; - }; - pinctrl: pinctrl at d8110000 { compatible = "wm,wm8505-pinctrl"; gpio-controller;
arch/arm/boot/dts/wm8650.dtsi +0 -7
@@ -34,13 +34,6 @@ 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>; - }; - pinctrl: pinctrl at d8110000 { compatible = "wm,wm8650-pinctrl"; gpio-controller;
arch/arm/boot/dts/wm8850.dtsi +0 -7
@@ -41,13 +41,6 @@ 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>; - }; - pinctrl: pinctrl at d8110000 { compatible = "wm,wm8850-pinctrl"; gpio-controller;
Signature · 1 line
1.7.9.5
PATCH 4/6 arm: vt8500: Remove gpio devicetree nodes
Quoted 4 lines · Tony Prisk
Remove the gpio related devicetree nodes as these are no longer required with the move to a combined pinctrl/gpio driver.
Signed-off-by Tony Prisk <[email protected]>
(...)
arch/arm/boot/dts/vt8500.dtsi line 33
Quoted 6 lines
arch/arm/boot/dts/vt8500.dtsi +0
-6- gpio: gpio-controller at d8110000 { - compatible = "via,vt8500-gpio"; - gpio-controller; - reg = <0xd8110000 0x10000>; - #gpio-cells = <3>; - };
Whopeedo. If I understand the fine devicetree folks you may remove this stuff from the devicetree, but the code in the new pin control driver should still be backward-compatible with devicetrees that look like this.
It's not like I care, just noting that this is the philosophy around such things.
Yours,
Linus Walleij
PATCH 4/6 arm: vt8500: Remove gpio devicetree nodes
Quoted 7 lines · Linus Walleij
arch/arm/boot/dts/vt8500.dtsi line 33
Quoted 6 lines
arch/arm/boot/dts/vt8500.dtsi +0
-6- gpio: gpio-controller at d8110000 { - compatible = "via,vt8500-gpio"; - gpio-controller; - reg = <0xd8110000 0x10000>; - #gpio-cells = <3>; - };
Quoted 7 lines
Whopeedo. If I understand the fine devicetree folks you may remove this stuff from the devicetree, but the code in the new pin control driver should still be backward-compatible with devicetrees that look like this.
It's not like I care, just noting that this is the philosophy around such things.
Right. For brand new code that does not have a lot of users, we can be more pragmatic though. If you are sure enough that it does not break for any existing users, we can change the binding. This may well be the case for vt8500.
Arnd
PATCH 5/6 gpio: vt8500: Remove arch-vt8500 gpio driver
In reply to Tony PriskWith the move to a combined pinctrl/gpio driver, the arch-vt8500 gpio driver is no longer required.
--- drivers/gpio/Kconfig | 6 - drivers/gpio/Makefile | 1 - drivers/gpio/gpio-vt8500.c | 355 -------------------------------------------- 3 files changed, 362 deletions(-) delete mode 100644 drivers/gpio/gpio-vt8500.c
drivers/gpio/Kconfig +0 -6
@@ -227,12 +227,6 @@ config GPIO_TS5500 blocks of the TS-5500: DIO1, DIO2 and the LCD port, and the TS-5600 LCD port. -config GPIO_VT8500 - bool "VIA/Wondermedia SoC GPIO Support" - depends on ARCH_VT8500 - help - Say yes here to support the VT8500/WM8505/WM8650 GPIO controller. - config GPIO_XILINX bool "Xilinx GPIO support" depends on PPC_OF || MICROBLAZE
drivers/gpio/Makefile +0 -1
@@ -80,7 +80,6 @@ obj-$(CONFIG_GPIO_TWL6040) += gpio-twl6040.o obj-$(CONFIG_GPIO_UCB1400) += gpio-ucb1400.o obj-$(CONFIG_GPIO_VIPERBOARD) += gpio-viperboard.o obj-$(CONFIG_GPIO_VR41XX) += gpio-vr41xx.o -obj-$(CONFIG_GPIO_VT8500) += gpio-vt8500.o obj-$(CONFIG_GPIO_VX855) += gpio-vx855.o obj-$(CONFIG_GPIO_WM831X) += gpio-wm831x.o obj-$(CONFIG_GPIO_WM8350) += gpio-wm8350.o
drivers/gpio/gpio-vt8500.c deleted +0 -355
355 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH 6/6 arm: vt8500: Remove pinmux configuration from mach-vt8500/vt8500.c
In reply to Tony PriskWith the new pinctrl driver and wm,pinmux property the configuration code required for initializing the framebuffer hardware can be removed from vt8500.c and configured in devicetree with pinctrl driver properties.
--- arch/arm/mach-vt8500/vt8500.c | 70 +---------------------------------------- 1 file changed, 1 insertion(+), 69 deletions(-)
arch/arm/mach-vt8500/vt8500.c +1 -69
@@ -34,12 +34,8 @@#include "common.h" -#define LEGACY_GPIO_BASE 0xD8110000#define LEGACY_PMC_BASE 0xD8130000 -/* Registers in GPIO Controller */ -#define VT8500_GPIO_MUX_REG 0x200 -/* Registers in Power Management Controller */ #define VT8500_HCR_REG 0x12#define VT8500_PMSR_REG 0x60
@@ -77,71 +73,6 @@ static void vt8500_power_off(void)void __init vt8500_init (void ) {struct device_node *np; -#if defined(CONFIG_FB_VT8500 ) || defined(CONFIG_FB_WM8505 ) -struct device_node *fb; -void __iomem *gpio_base; -#endif - -#ifdef CONFIG_FB_VT8500 - fb =of_find_compatible_node (NULL ,NULL ,"via,vt8500-fb" ); -if (fb) { - np =of_find_compatible_node (NULL ,NULL ,"via,vt8500-gpio" ); -if (np) { - gpio_base =of_iomap (np,0 ); - -if (!gpio_base) -pr_err ("%s: of_iomap(gpio_mux) failed\n" , - __func__); - -of_node_put (np); - }else { - gpio_base =ioremap (LEGACY_GPIO_BASE ,0x1000 ); -if (!gpio_base) -pr_err ("%s: ioremap(legacy_gpio_mux) failed\n" , - __func__); - } -if (gpio_base) { -writel (readl (gpio_base +VT8500_GPIO_MUX_REG ) |1 , - gpio_base +VT8500_GPIO_MUX_REG ); -iounmap (gpio_base); - }else -pr_err ("%s: Could not remap GPIO mux\n" , __func__); - -of_node_put (fb); - } -#endif - -#ifdef CONFIG_FB_WM8505 - fb =of_find_compatible_node (NULL ,NULL ,"wm,wm8505-fb" ); -if (fb) { - np =of_find_compatible_node (NULL ,NULL ,"wm,wm8505-gpio" ); -if (!np) - np =of_find_compatible_node (NULL ,NULL , -"wm,wm8650-gpio" ); -if (np) { - gpio_base =of_iomap (np,0 ); - -if (!gpio_base) -pr_err ("%s: of_iomap(gpio_mux) failed\n" , - __func__); - -of_node_put (np); - }else { - gpio_base =ioremap (LEGACY_GPIO_BASE ,0x1000 ); -if (!gpio_base) -pr_err ("%s: ioremap(legacy_gpio_mux) failed\n" , - __func__); - } -if (gpio_base) { -writel (readl (gpio_base +VT8500_GPIO_MUX_REG ) | -0x80000000 , gpio_base +VT8500_GPIO_MUX_REG ); -iounmap (gpio_base); - }else -pr_err ("%s: Could not remap GPIO mux\n" , __func__); - -of_node_put (fb); - } -#endif np =of_find_compatible_node (NULL ,NULL ,"via,vt8500-pmc" );if (np) {
@@ -156,6 +87,7 @@ void __init vt8500_init(void)if (!pmc_base)pr_err ("%s:ioremap(power_off) failed\n" , __func__); } +if (pmc_base) pm_power_off = &vt8500_power_off;else
Signature · 1 line
1.7.9.5