diff options
| author | Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> | 2013-06-17 14:50:02 -0400 |
|---|---|---|
| committer | Linus Walleij <linus.walleij@linaro.org> | 2013-06-18 04:57:51 -0400 |
| commit | fe1c9a822ce72c6ec8476a2501c412265ee2172c (patch) | |
| tree | 743e3e67152fd5883e02a4eded386787d7fa8be5 | |
| parent | 3a7f520e63727e14de9567515d8727c2c01fedb4 (diff) | |
sh-pfc: Add DT support
Support device instantiation through the device tree. The compatible
property is used to select the SoC pinmux information.
Set the gpio_chip device field to the PFC device to enable automatic
GPIO OF support.
Cc: devicetree-discuss@lists.ozlabs.org
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
| -rw-r--r-- | Documentation/devicetree/bindings/pinctrl/renesas,pfc-pinctrl.txt | 135 | ||||
| -rw-r--r-- | drivers/pinctrl/sh-pfc/core.c | 64 | ||||
| -rw-r--r-- | drivers/pinctrl/sh-pfc/pinctrl.c | 116 |
3 files changed, 314 insertions, 1 deletions
diff --git a/Documentation/devicetree/bindings/pinctrl/renesas,pfc-pinctrl.txt b/Documentation/devicetree/bindings/pinctrl/renesas,pfc-pinctrl.txt new file mode 100644 index 000000000000..8264cbcdd418 --- /dev/null +++ b/Documentation/devicetree/bindings/pinctrl/renesas,pfc-pinctrl.txt | |||
| @@ -0,0 +1,135 @@ | |||
| 1 | * Renesas Pin Function Controller (GPIO and Pin Mux/Config) | ||
| 2 | |||
| 3 | The Pin Function Controller (PFC) is a Pin Mux/Config controller. On SH7372, | ||
| 4 | SH73A0, R8A73A4 and R8A7740 it also acts as a GPIO controller. | ||
| 5 | |||
| 6 | |||
| 7 | Pin Control | ||
| 8 | ----------- | ||
| 9 | |||
| 10 | Required Properties: | ||
| 11 | |||
| 12 | - compatible: should be one of the following. | ||
| 13 | - "renesas,pfc-r8a73a4": for R8A73A4 (R-Mobile APE6) compatible pin-controller. | ||
| 14 | - "renesas,pfc-r8a7740": for R8A7740 (R-Mobile A1) compatible pin-controller. | ||
| 15 | - "renesas,pfc-r8a7778": for R8A7778 (R-Mobile M1) compatible pin-controller. | ||
| 16 | - "renesas,pfc-r8a7779": for R8A7779 (R-Car H1) compatible pin-controller. | ||
| 17 | - "renesas,pfc-r8a7790": for R8A7790 (R-Car H2) compatible pin-controller. | ||
| 18 | - "renesas,pfc-sh7372": for SH7372 (SH-Mobile AP4) compatible pin-controller. | ||
| 19 | - "renesas,pfc-sh73a0": for SH73A0 (SH-Mobile AG5) compatible pin-controller. | ||
| 20 | |||
| 21 | - reg: Base address and length of each memory resource used by the pin | ||
| 22 | controller hardware module. | ||
| 23 | |||
| 24 | Optional properties: | ||
| 25 | |||
| 26 | - #gpio-range-cells: Mandatory when the PFC doesn't handle GPIO, forbidden | ||
| 27 | otherwise. Should be 3. | ||
| 28 | |||
| 29 | The PFC node also acts as a container for pin configuration nodes. Please refer | ||
| 30 | to pinctrl-bindings.txt in this directory for the definition of the term "pin | ||
| 31 | configuration node" and for the common pinctrl bindings used by client devices. | ||
| 32 | |||
| 33 | Each pin configuration node represents desired functions to select on a pin | ||
| 34 | group or a list of pin groups. The functions and pin groups can be specified | ||
| 35 | directly in the pin configuration node, or grouped in child subnodes. Several | ||
| 36 | functions can thus be referenced as a single pin configuration node by client | ||
| 37 | devices. | ||
| 38 | |||
| 39 | A configuration node or subnode must contain a function and reference at least | ||
| 40 | one pin group. | ||
| 41 | |||
| 42 | All pin configuration nodes and subnodes names are ignored. All of those nodes | ||
| 43 | are parsed through phandles and processed purely based on their content. | ||
| 44 | |||
| 45 | Pin Configuration Node Properties: | ||
| 46 | |||
| 47 | - renesas,groups : An array of strings, each string containing the name of a pin | ||
| 48 | group. | ||
| 49 | |||
| 50 | - renesas,function: A string containing the name of the function to mux to the | ||
| 51 | pin group(s) specified by the renesas,groups property | ||
| 52 | |||
| 53 | Valid values for pin, group and function names can be found in the group and | ||
| 54 | function arrays of the PFC data file corresponding to the SoC | ||
| 55 | (drivers/pinctrl/sh-pfc/pfc-*.c) | ||
| 56 | |||
| 57 | |||
| 58 | GPIO | ||
| 59 | ---- | ||
| 60 | |||
| 61 | On SH7372, SH73A0, R8A73A4 and R8A7740 the PFC node is also a GPIO controller | ||
| 62 | node. | ||
| 63 | |||
| 64 | Required Properties: | ||
| 65 | |||
| 66 | - gpio-controller: Marks the device node as a gpio controller. | ||
| 67 | |||
| 68 | - #gpio-cells: Should be 2. The first cell is the GPIO number and the second | ||
| 69 | cell specifies GPIO flags, as defined in <dt-bindings/gpio/gpio.h>. Only the | ||
| 70 | GPIO_ACTIVE_HIGH and GPIO_ACTIVE_LOW flags are supported. | ||
| 71 | |||
| 72 | The syntax of the gpio specifier used by client nodes should be the following | ||
| 73 | with values derived from the SoC user manual. | ||
| 74 | |||
| 75 | <[phandle of the gpio controller node] | ||
| 76 | [pin number within the gpio controller] | ||
| 77 | [flags]> | ||
| 78 | |||
| 79 | On other mach-shmobile platforms GPIO is handled by the gpio-rcar driver. | ||
| 80 | Please refer to Documentation/devicetree/bindings/gpio/renesas,gpio-rcar.txt | ||
| 81 | for documentation of the GPIO device tree bindings on those platforms. | ||
| 82 | |||
| 83 | |||
| 84 | Examples | ||
| 85 | -------- | ||
| 86 | |||
| 87 | Example 1: SH73A0 (SH-Mobile AG5) pin controller node | ||
| 88 | |||
| 89 | pfc: pfc@e6050000 { | ||
| 90 | compatible = "renesas,pfc-sh73a0"; | ||
| 91 | reg = <0xe6050000 0x8000>, | ||
| 92 | <0xe605801c 0x1c>; | ||
| 93 | gpio-controller; | ||
| 94 | #gpio-cells = <2>; | ||
| 95 | }; | ||
| 96 | |||
| 97 | Example 2: A GPIO LED node that references a GPIO | ||
| 98 | |||
| 99 | #include <dt-bindings/gpio/gpio.h> | ||
| 100 | |||
| 101 | leds { | ||
| 102 | compatible = "gpio-leds"; | ||
| 103 | led1 { | ||
| 104 | gpios = <&pfc 20 GPIO_ACTIVE_LOW>; | ||
| 105 | }; | ||
| 106 | }; | ||
| 107 | |||
| 108 | Example 3: KZM-A9-GT (SH-Mobile AG5) default pin state hog and pin control maps | ||
| 109 | for the MMCIF and SCIFA4 devices | ||
| 110 | |||
| 111 | &pfc { | ||
| 112 | pinctrl-0 = <&scifa4_pins>; | ||
| 113 | pinctrl-names = "default"; | ||
| 114 | |||
| 115 | mmcif_pins: mmcif { | ||
| 116 | renesas,groups = "mmc0_data8_0", "mmc0_ctrl_0"; | ||
| 117 | renesas,function = "mmc0"; | ||
| 118 | }; | ||
| 119 | |||
| 120 | scifa4_pins: scifa4 { | ||
| 121 | renesas,groups = "scifa4_data", "scifa4_ctrl"; | ||
| 122 | renesas,function = "scifa4"; | ||
| 123 | }; | ||
| 124 | }; | ||
| 125 | |||
| 126 | Example 4: KZM-A9-GT (SH-Mobile AG5) default pin state for the MMCIF device | ||
| 127 | |||
| 128 | &mmcif { | ||
| 129 | pinctrl-0 = <&mmcif_pins>; | ||
| 130 | pinctrl-names = "default"; | ||
| 131 | |||
| 132 | bus-width = <8>; | ||
| 133 | vmmc-supply = <®_1p8v>; | ||
| 134 | status = "okay"; | ||
| 135 | }; | ||
diff --git a/drivers/pinctrl/sh-pfc/core.c b/drivers/pinctrl/sh-pfc/core.c index 13f40c59ebfb..4eea849a1ad8 100644 --- a/drivers/pinctrl/sh-pfc/core.c +++ b/drivers/pinctrl/sh-pfc/core.c | |||
| @@ -18,6 +18,8 @@ | |||
| 18 | #include <linux/ioport.h> | 18 | #include <linux/ioport.h> |
| 19 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
| 20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
| 21 | #include <linux/of.h> | ||
| 22 | #include <linux/of_device.h> | ||
| 21 | #include <linux/pinctrl/machine.h> | 23 | #include <linux/pinctrl/machine.h> |
| 22 | #include <linux/platform_device.h> | 24 | #include <linux/platform_device.h> |
| 23 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
| @@ -348,13 +350,72 @@ int sh_pfc_config_mux(struct sh_pfc *pfc, unsigned mark, int pinmux_type) | |||
| 348 | return 0; | 350 | return 0; |
| 349 | } | 351 | } |
| 350 | 352 | ||
| 353 | #ifdef CONFIG_OF | ||
| 354 | static const struct of_device_id sh_pfc_of_table[] = { | ||
| 355 | #ifdef CONFIG_PINCTRL_PFC_R8A73A4 | ||
| 356 | { | ||
| 357 | .compatible = "renesas,pfc-r8a73a4", | ||
| 358 | .data = &r8a73a4_pinmux_info, | ||
| 359 | }, | ||
| 360 | #endif | ||
| 361 | #ifdef CONFIG_PINCTRL_PFC_R8A7740 | ||
| 362 | { | ||
| 363 | .compatible = "renesas,pfc-r8a7740", | ||
| 364 | .data = &r8a7740_pinmux_info, | ||
| 365 | }, | ||
| 366 | #endif | ||
| 367 | #ifdef CONFIG_PINCTRL_PFC_R8A7778 | ||
| 368 | { | ||
| 369 | .compatible = "renesas,pfc-r8a7778", | ||
| 370 | .data = &r8a7778_pinmux_info, | ||
| 371 | }, | ||
