Laurent Pinchart [Sun, 10 Mar 2013 15:44:02 +0000 (16:44 +0100)]
sh-pfc: Implement generic pinconf support
The existing PFC pinconf implementation, tied to the PFC-specific pin
types, isn't used by drivers or boards. Replace it with the generic
pinconf types to implement bias (pull-up/down) setup. Other pin
configuration options can be implemented later if needed.
Laurent Pinchart [Sun, 10 Mar 2013 14:29:14 +0000 (15:29 +0100)]
sh-pfc: Remove configuration dry-run and free
The purpose of the dry-run is to ensure that a pin about to be
configured isn't in use. However, the current implementation is a no-op.
This proves that the dry-run isn't essential. Remove it.
Freeing configuration then becomes a no-op as well. Remove it.
The sh_pfc_pin structure supplied in SoC data contains information about
pin configuration and name. It's abused to store GPIO data registers
information and pin config type. Move those fields out of the
pinmux_data_reg structure into the new sh_pfc_gpio_pin and
sh_pfc_pin_config structures.
Laurent Pinchart [Sat, 16 Feb 2013 17:34:32 +0000 (18:34 +0100)]
sh-pfc: Don't modify pinmux_data_reg SoC data
The pinmux_data_reg structure supplied in SoC data contains information
about data registers. It's abused to store per-device mapped iomem and
shadow values. Move those fields out of the pinmux_data_reg structure
into the per-device sh_pfc_chip structure.
Laurent Pinchart [Sat, 16 Feb 2013 23:26:33 +0000 (00:26 +0100)]
sh-pfc: Don't map data registers individually
All data registers are located in the same memory resource. Locate the
mapped resource at initializat time and use it directly instead of
computing a mapped address for each register. This gets rid of the
mapped_reg field of the pinmux_data_reg structure.
Laurent Pinchart [Fri, 15 Feb 2013 01:04:55 +0000 (02:04 +0100)]
sh-pfc: Move GPIO registers access functions to gpio.c
Move the sh_pfc_setup_data_regs(), sh_pfc_setup_data_reg(),
sh_pfc_get_data_reg(), sh_pfc_read_bit() and sh_pfc_write_bit()
function to gpio.c as they belong to the GPIO implementation. Inline
sh_pfc_read_bit() and sh_pfc_write_bit() in their only call location.
Wei Yongjun [Mon, 11 Mar 2013 14:08:12 +0000 (22:08 +0800)]
sh-pfc: Fix return value check in sh_pfc_register_pinctrl()
In case of error, the function pinctrl_register() returns NULL not
ERR_PTR(). The IS_ERR() test in the return value check should be
replaced with NULL test.
Laurent Pinchart [Sat, 16 Feb 2013 18:23:58 +0000 (19:23 +0100)]
sh: shx3: Add pin control resources
Add memory resources for the pin control platform device to let the
sh-pfc driver ioremap() registers properly instead of evily casting
register physical addresses to virtual addresses.
The memory resource address range has been extracted from the config and
data registes lists in the sh-pfc driver.
Laurent Pinchart [Sat, 16 Feb 2013 18:23:58 +0000 (19:23 +0100)]
sh: sh7786: Add pin control resources
Add memory resources for the pin control platform device to let the
sh-pfc driver ioremap() registers properly instead of evily casting
register physical addresses to virtual addresses.
The memory resource address range has been extracted from the config and
data registes lists in the sh-pfc driver.
Laurent Pinchart [Sat, 16 Feb 2013 18:23:58 +0000 (19:23 +0100)]
sh: sh7785: Add pin control resources
Add memory resources for the pin control platform device to let the
sh-pfc driver ioremap() registers properly instead of evily casting
register physical addresses to virtual addresses.
The memory resource address range has been extracted from the config and
data registes lists in the sh-pfc driver.
Laurent Pinchart [Sat, 16 Feb 2013 18:23:58 +0000 (19:23 +0100)]
sh: sh7757: Add pin control resources
Add memory resources for the pin control platform device to let the
sh-pfc driver ioremap() registers properly instead of evily casting
register physical addresses to virtual addresses.
The memory resource address range has been extracted from the config and
data registes lists in the sh-pfc driver.
Laurent Pinchart [Sat, 16 Feb 2013 18:23:58 +0000 (19:23 +0100)]
sh: sh7724: Add pin control resources
Add memory resources for the pin control platform device to let the
sh-pfc driver ioremap() registers properly instead of evily casting
register physical addresses to virtual addresses.
The memory resource address range has been extracted from the config and
data registes lists in the sh-pfc driver.
Laurent Pinchart [Sat, 16 Feb 2013 18:23:58 +0000 (19:23 +0100)]
sh: sh7723: Add pin control resources
Add memory resources for the pin control platform device to let the
sh-pfc driver ioremap() registers properly instead of evily casting
register physical addresses to virtual addresses.
The memory resource address range has been extracted from the config and
data registes lists in the sh-pfc driver.
Laurent Pinchart [Sat, 16 Feb 2013 18:23:58 +0000 (19:23 +0100)]
sh: sh7722: Add pin control resources
Add memory resources for the pin control platform device to let the
sh-pfc driver ioremap() registers properly instead of evily casting
register physical addresses to virtual addresses.
The memory resource address range has been extracted from the config and
data registes lists in the sh-pfc driver.
Laurent Pinchart [Sat, 16 Feb 2013 18:23:58 +0000 (19:23 +0100)]
sh: sh7720: Add pin control resources
Add memory resources for the pin control platform device to let the
sh-pfc driver ioremap() registers properly instead of evily casting
register physical addresses to virtual addresses.
The memory resource address range has been extracted from the config and
data registes lists in the sh-pfc driver.
Laurent Pinchart [Sat, 16 Feb 2013 18:23:58 +0000 (19:23 +0100)]
sh: sh7269: Add pin control resources
Add memory resources for the pin control platform device to let the
sh-pfc driver ioremap() registers properly instead of evily casting
register physical addresses to virtual addresses.
The memory resource address range has been extracted from the config and
data registes lists in the sh-pfc driver.
Laurent Pinchart [Sat, 16 Feb 2013 18:23:58 +0000 (19:23 +0100)]
sh: sh7264: Add pin control resources
Add memory resources for the pin control platform device to let the
sh-pfc driver ioremap() registers properly instead of evily casting
register physical addresses to virtual addresses.
The memory resource address range has been extracted from the config and
data registes lists in the sh-pfc driver.
Laurent Pinchart [Sat, 16 Feb 2013 18:23:58 +0000 (19:23 +0100)]
sh: sh7203: Add pin control resources
Add memory resources for the pin control platform device to let the
sh-pfc driver ioremap() registers properly instead of evily casting
register physical addresses to virtual addresses.
The memory resource address range has been extracted from the config and
data registes lists in the sh-pfc driver.
sh-pfc: Expose real groups and functions in pinctrl/pinmux operations
The sh-pfc driver exposes one fake group and function per GPIO pin. As
the pinctrl and pinmux APIs are not used by any SuperH and SH Mobile
board or driver, drop the fake groups and functions and replace them by
a real pinctrl and pinmux implementation.
Groups and functions must now be explicitly provided by PFC SoC-specific
data.
Laurent Pinchart [Sat, 16 Feb 2013 06:38:50 +0000 (07:38 +0100)]
ARM: shmobile: mackerel: Replace GPIO_PORTx enum with GPIO port numbers
The PFC GPIO API implementation moved to using port numbers. Replace all
GPIO_PORTx enum usage with the corresponding port number. The GPIO_PORTx
enum values are identical to the port number on this platform.
Laurent Pinchart [Sat, 16 Feb 2013 06:38:50 +0000 (07:38 +0100)]
ARM: shmobile: bonito: Replace GPIO_PORTx enum with GPIO port numbers
The PFC GPIO API implementation moved to using port numbers. Replace all
GPIO_PORTx enum usage with the corresponding port number. The GPIO_PORTx
enum values are identical to the port number on this platform.
Laurent Pinchart [Sat, 16 Feb 2013 06:38:50 +0000 (07:38 +0100)]
ARM: shmobile: armadillo: Replace GPIO_PORTx enum with GPIO port numbers
The PFC GPIO API implementation moved to using port numbers. Replace all
GPIO_PORTx enum usage with the corresponding port number. The GPIO_PORTx
enum values are identical to the port number on this platform.
Laurent Pinchart [Sat, 16 Feb 2013 06:38:50 +0000 (07:38 +0100)]
ARM: shmobile: ap4-evb: Replace GPIO_PORTx enum with GPIO port numbers
The PFC GPIO API implementation moved to using port numbers. Replace all
GPIO_PORTx enum usage with the corresponding port number. The GPIO_PORTx
enum values are identical to the port number on this platform.
Laurent Pinchart [Fri, 15 Feb 2013 00:33:38 +0000 (01:33 +0100)]
sh-pfc: Add support for sparse pin numbers
The PFC driver assumes that the value of the GPIO_PORTxxx enumeration
names are equal to the port number. This isn't true when the port number
space is sparse, as with the SH73A0.
Fix the issue by adding support for pin numbers ranges specified through
SoC data. When no range is specified the driver considers that the PFC
implements a single contiguous range for all pins.
Laurent Pinchart [Thu, 14 Feb 2013 16:36:56 +0000 (17:36 +0100)]
sh-pfc: Use pinmux identifiers in the pin muxing API
The PFC core exposes a sh_pfc_config_gpio() function that configures
pinmuxing for a given GPIO (either a real GPIO or a function GPIO).
Handling of real and function GPIOs belong to the GPIO layer, move the
GPIO number to mark translation to the caller and rename the function to
sh_pfc_config_mux().
Instead of converting the GPIO number to an enum_id and looking up IRQ
table entries by enum_id, replace the pinmux_irq enum_ids field with a
gpios field and lookup entries using the GPIO number.
Laurent Pinchart [Thu, 29 Nov 2012 12:03:53 +0000 (13:03 +0100)]
sh-pfc: Shrink the pinctrl GPIO range to include real GPIOs only
As a step towards GPIO function removal, shorten the GPIO range
registered with the pinctrl core. Function GPIOs are now handled in the
GPIO handlers directly instead of going through the pinctrl API.
Laurent Pinchart [Thu, 29 Nov 2012 01:23:26 +0000 (02:23 +0100)]
sh-pfc: Initialize pinmux_gpio flags statically
All function GPIO entries are initialized with the GPIO_FN macro that
expands to the PINMUX_GPIO macro, used to initialize real GPIOs. Create
a PINMUX_GPIO_FN macro that duplicates PINMUX_GPIO and sets flags to
PINMUX_TYPE_FUNCTION and use it in GPIO_FN, and make PINMUX_GPIO set
flags to PINMUX_TYPE_GPIO.
This removes the need to initialize GPIO flags at runtime and thus
simplifies the code, preparing for the GPIO and functions split.
Laurent Pinchart [Thu, 29 Nov 2012 11:24:51 +0000 (12:24 +0100)]
sh-pfc: Replace SoC info data and mark ranges with a number of pins
The data and mark ranges are only used to check whether a GPIO
corresponds to a real pin or a function. As pins come first in the list
of GPIOs and in the platform-specific GPIO enumerations, we can replace
the data and mark ranges by a number of pins.
Add an nr_pins field to struct sh_pfc_soc_info to store the number of
pins implemented by the SoC, remove the data and mark range fields and
introduce sh_pfc_gpio_is_pin() and sh_pfc_gpio_is_function() functions
to replace range-based checks.
Laurent Pinchart [Wed, 28 Nov 2012 16:51:00 +0000 (17:51 +0100)]
sh-pfc: Replace first_gpio and last_gpio with nr_gpios
The SoC information first_gpio field is always equal to 0, and the
last_gpio field is the index of the last entry in the pinmux_gpios
array. Replace the first_gpio and last_gpio fields by a nr_gpios field,
and initialize it to ARRAY_SIZE(pinmux_gpios).
Laurent Pinchart [Wed, 28 Nov 2012 19:56:48 +0000 (20:56 +0100)]
sh-pfc: Don't take the sh_pfc spinlock in sh_pfc_map_gpios()
The sh_pfc_map_gpios() function is only called at initialization time
when no other task can access the sh_pfc fields. Don't protect the
operation with a spinlock.
Laurent Pinchart [Sat, 16 Feb 2013 15:38:30 +0000 (16:38 +0100)]
sh-pfc: Don't define the per-device pinctrl struct instances as global
The pinctrl_desc and pinctrl_gpio_range structures registered with the
pinctrl core are per-device instances. Move them to the dynamically
allocated sh_pfc_pinctrl structure and initialize them at runtime.
Sachin Kamat [Wed, 13 Mar 2013 11:43:46 +0000 (17:13 +0530)]
pinctrl: generic: Fix compilation error
The function definition of pinconf_generic_dump_config is defined
under CONFIG_DEBUG_FS macro. Define the declaration too under this macro.
Without this patch we get the following build error:
drivers/built-in.o: In function `pcs_pinconf_config_dbg_show':
drivers/pinctrl/pinctrl-single.c:726: undefined reference to
`pinconf_generic_dump_config'
Axel Lin [Tue, 5 Mar 2013 06:58:53 +0000 (14:58 +0800)]
pinctrl: abx500: Fix checking if pin use AlternateFunction register
It's pointless to check "af.alt_bit1 == UNUSED" twice.
This looks like a copy-paste bug, I think what we want is to check if *both*
af.alt_bit1 and af.alt_bit2 are UNUSED.
Signed-off-by: Axel Lin <axel.lin@ingics.com> Acked-by: Patrice Chotard <patrice.chotard@st.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Haojian Zhuang [Sun, 17 Feb 2013 11:42:55 +0000 (19:42 +0800)]
pinctrl: single: support generic pinconf
Support the operation of generic pinconf. The supported config arguments
are INPUT_SCHMITT, INPUT_SCHMITT_ENABLE, DRIVE_STRENGHT, BIAS_DISABLE,
BIAS_PULLUP, BIAS_PULLDOWN, SLEW_RATE.
Haojian Zhuang [Sun, 17 Feb 2013 11:42:54 +0000 (19:42 +0800)]
pinctrl: single: set function mask as optional
Since Hisilicon's pin controller is divided into two parts. One is the
function mux, and the other is pin configuration. These two parts are
in the different memory regions. So make pinctrl-single,function-mask
as optional property. Then we can define pingroups without valid
function mux that is only used for pin configuration.
Haojian Zhuang [Sun, 17 Feb 2013 11:42:52 +0000 (19:42 +0800)]
pinctrl: single: create new gpio function range
Since gpio driver could create gpio range in DTS, it could invoke
pinctrl_request_gpio(). In the pinctrl-single driver, it needs to
configure pins with gpio function mode.
A new gpio function range should be created in DTS file in below.
2. gpio driver could get pin offset from gpio-ranges property.
pinctrl-single driver could get gpio function mode from gpio_func
that is stored in @gpiofuncs list in struct pcs_device.
This new pinctrl-single,gpio-range is used as complement for
gpio-ranges property in gpio driver.
Haojian Zhuang [Sun, 17 Feb 2013 11:42:51 +0000 (19:42 +0800)]
gpio: pl061: bind pinctrl by gpio request
Add the pl061_gpio_request() to request pinctrl. Create the logic
between pl061 gpio driver and pinctrl (pinctrl-single) driver.
While a gpio pin is requested, it will request pinctrl driver to
set that pin with gpio function mode. So pinctrl driver should
append .gpio_request_enable() in pinmux_ops.
Haojian Zhuang [Sun, 17 Feb 2013 11:42:50 +0000 (19:42 +0800)]
pinctrl: check pinctrl ready for gpio range
pinctrl_get_device_gpio_range() only checks whether a certain GPIO pin
is in gpio range. But maybe some GPIO pins don't have back-end pinctrl
interface, it means that these pins are always configured as GPIO
function. For example, gpio159 isn't related to back-end pinctrl device
in Hi3620 while other GPIO pins are related to back-end pinctrl device.
Append pinctrl_ready_for_gpio_range() that is used to check whether
pinctrl device with GPIO range is ready. This function will be called
after pinctrl_get_device_gpio_range() fails.
If pinctrl device with GPIO range is found, it means that pinctrl device
is already launched and a certain GPIO pin just don't have back-end pinctrl
interface. Then pinctrl_request_gpio() shouldn't return -EPROBE_DEFER in
this case.
Haojian Zhuang [Sun, 17 Feb 2013 11:42:48 +0000 (19:42 +0800)]
gpio: fix wrong checking condition for gpio range
If index++ calculates from 0, the checking condition of "while
(index++)" fails & it doesn't check any more. It doesn't follow
the loop that used at here.
Replace it by endless loop at here. Then it keeps parsing
"gpio-ranges" property until it ends.