pinctrl: Intel Cherryview/Braswell support
Subsystems (3)
Mika Westerberg
maintainerv2 cover pinctrl: Intel Cherryview/Braswell support
Hi,
This is second version of the patch series adding pinctrl/GPIO support for Intel Braswell and Cherrryview. The previous version can be found here:
https://lkml.org/lkml/2014/10/27/118
I've dropped patches [2/4] and [3/4] as they are already applied to the pinctrl tree.
Changes to the previous version:
[1/2] - Removed unnecessary cast and added Rafael's ACK.
[2/2] - Use Ohms instead of kOhms in pin configuration.
- Change chv_config_set_pull() to be not so convoluted.
- Remove locking when we just read single register. This is not needed.
- Use BIT() instead of (1 << something)
Mika Westerberg (2):
gpio / ACPI: Add knowledge about pin controllers to acpi_get_gpiod()
pinctrl: Add Intel Cherryview/Braswell pin controller support
drivers/gpio/gpiolib-acpi.c | 62 +- drivers/pinctrl/intel/Kconfig | 12 + drivers/pinctrl/intel/Makefile | 1 + drivers/pinctrl/intel/pinctrl-cherryview.c | 1519 ++++++++++++++++++++++++++++ 4 files changed, 1591 insertions(+), 3 deletions(-) create mode 100644 drivers/pinctrl/intel/pinctrl-cherryview.c
Signature · 1 line
2.1.1
Mika Westerberg
maintainerPATCH v2 1/2 gpio / ACPI: Add knowledge about pin controllers to acpi_get_gpiod()
The GPIO resources (GpioIo/GpioInt) used in ACPI contain a GPIO number which is relative to the hardware GPIO controller. Typically this number can be translated directly to Linux GPIO number because the mapping is pretty much 1:1.
However, when the GPIO driver is using pins exported by a pin controller driver via set of GPIO ranges, the mapping might not be 1:1 anymore and direct translation does not work.
In such cases we need to translate the ACPI GPIO number to be suitable for the GPIO controller driver in question by checking all the pin controller GPIO ranges under the given device and using those to get the proper GPIO number.
--- drivers/gpio/gpiolib-acpi.c | 62 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 3 deletions(-)
drivers/gpio/gpiolib-acpi.c +59 -3
@@ -11,12 +11,14 @@*/ #include <linux/errno.h> +#include <linux/gpio.h> #include <linux/gpio/consumer.h> #include <linux/gpio/driver.h> #include <linux/export.h> #include <linux/acpi.h> #include <linux/interrupt.h> #include <linux/mutex.h> +#include <linux/pinctrl/pinctrl.h> #include "gpiolib.h"
@@ -55,6 +57,58 @@ static int acpi_gpiochip_find(struct gpio_chip *gc, void *data)return ACPI_HANDLE (gc->dev) == data; } +#ifdef CONFIG_PINCTRL +/** +* acpi_gpiochip_pin_to_gpio_offset() - translates ACPI GPIO to Linux GPIO +* @chip: GPIO chip +* @pin: ACPI GPIO pin number from GpioIo/GpioInt resource +* +* Function takes ACPI GpioIo/GpioInt pin number as a parameter and +* translates it to a corresponding offset suitable to be passed to a +* GPIO controller driver. +* +* Typically the returned offset is same as @pin, but if the GPIO +* controller uses pin controller and the mapping is not contigous the +* offset might be different. +*/ +static int acpi_gpiochip_pin_to_gpio_offset (struct gpio_chip *chip,int pin) +{ +struct gpio_pin_range *pin_range; + +/* If there are no ranges in this chip, use 1:1 mapping */ +if (list_empty (&chip->pin_ranges)) +return pin; + +list_for_each_entry (pin_range, &chip->pin_ranges, node) { +const struct pinctrl_gpio_range *range = &pin_range->range; +int i; + +if (range->pins) { +for (i =0 ; i < range->npins; i++) { +if (range->pins[i] == pin) +return range->base + i - chip->base; + } + }else { +if (pin >= range->pin_base && + pin < range->pin_base + range->npins) { +unsigned gpio_base; + + gpio_base = range->base - chip->base; +return gpio_base + pin - range->pin_base; + } + } + } + +return -EINVAL ; +} +#else +static inline int acpi_gpiochip_pin_to_gpio_offset (struct gpio_chip *chip, +int pin) +{ +return pin; +} +#endif +/** * acpi_get_gpiod() - Translate ACPI GPIO pin to GPIO descriptor usable with GPIO API * @path: ACPI GPIO controller full path name, (e.g. "\\_SB.GPO1")
@@ -69,6 +123,7 @@ static struct gpio_desc *acpi_get_gpiod(char *path, int pin)struct gpio_chip *chip;acpi_handle handle;acpi_status status; +int offset; status =acpi_get_handle (NULL , path, &handle);if (ACPI_FAILURE (status))
@@ -78,10 +133,11 @@ static struct gpio_desc *acpi_get_gpiod(char *path, int pin)if (!chip)return ERR_PTR (-ENODEV ); -if (pin <0 || pin > chip->ngpio) -return ERR_PTR (-EINVAL ); + offset =acpi_gpiochip_pin_to_gpio_offset (chip, pin); +if (offset <0 ) +return ERR_PTR (offset); -return gpiochip_get_desc (chip, pin); +return gpiochip_get_desc (chip, offset); }static irqreturn_t acpi_gpio_irq_handler (int irq,void *data)
Signature · 1 line
2.1.1
Re: [PATCH v2 1/2] gpio / ACPI: Add knowledge about pin controllers to acpi_get_gpiod()
Quoted 9 lines · Mika Westerberg
The GPIO resources (GpioIo/GpioInt) used in ACPI contain a GPIO number which is relative to the hardware GPIO controller. Typically this number can be translated directly to Linux GPIO number because the mapping is pretty much 1:1.
However, when the GPIO driver is using pins exported by a pin controller driver via set of GPIO ranges, the mapping might not be 1:1 anymore and direct translation does not work.
Quoted 7 lines
In such cases we need to translate the ACPI GPIO number to be suitable for the GPIO controller driver in question by checking all the pin controller GPIO ranges under the given device and using those to get the proper GPIO number.
Signed-off-by Mika Westerberg <[email protected]>
Sweet, patch applied.
Yours,
Linus Walleij
Mika Westerberg
maintainerPATCH v2 2/2 pinctrl: Add Intel Cherryview/Braswell pin controller support
In reply to Mika WesterbergThis driver supports the pin/GPIO controllers found in newer Intel SoCs like Cherryview and Braswell. The driver provides full GPIO support and minimal set of pin controlling funtionality.
The driver is based on the original Cherryview GPIO driver authored by Ning Li and Alan Cox.
--- drivers/pinctrl/intel/Kconfig | 12 + drivers/pinctrl/intel/Makefile | 1 + drivers/pinctrl/intel/pinctrl-cherryview.c | 1519 ++++++++++++++++++++++++++++ 3 files changed, 1532 insertions(+) create mode 100644 drivers/pinctrl/intel/pinctrl-cherryview.c
drivers/pinctrl/intel/Kconfig +12 -0
@@ -13,3 +13,15 @@ config PINCTRL_BAYTRAIL so only a small amount is available for gpio use. Requires ACPI device enumeration code to set up a platform device. + +config PINCTRL_CHERRYVIEW + tristate "Intel Cherryview/Braswell pinctrl and GPIO driver" + depends on ACPI + select PINMUX + select PINCONF + select GENERIC_PINCONF + select GPIOLIB + select GPIOLIB_IRQCHIP + help + Cherryview/Braswell pinctrl driver provides an interface that + allows configuring of SoC pins and using them as GPIOs.
drivers/pinctrl/intel/Makefile +1 -0
@@ -1,3 +1,4 @@ # Intel pin control drivers obj-$(CONFIG_PINCTRL_BAYTRAIL) += pinctrl-baytrail.o +obj-$(CONFIG_PINCTRL_CHERRYVIEW) += pinctrl-cherryview.o
drivers/pinctrl/intel/pinctrl-cherryview.c new file +1519 -0
1,519 lines not on this page · raw message
Signature · 1 line
2.1.1
Re: [PATCH v2 2/2] pinctrl: Add Intel Cherryview/Braswell pin controller support
Quoted 8 lines · Mika Westerberg
This driver supports the pin/GPIO controllers found in newer Intel SoCs like Cherryview and Braswell. The driver provides full GPIO support and minimal set of pin controlling funtionality.
The driver is based on the original Cherryview GPIO driver authored by Ning Li and Alan Cox.
Signed-off-by Mika Westerberg <[email protected]>
Simply a beautiful driver for a complex hardware (as pin controllers go) so patch applied. Thanks a lot for you efforts of taking this effort to adapt the embedded Intel to the world of pin control!
Yours,
Linus Walleij
Quoted 9 lines · Mika Westerberg
Hi,
This is second version of the patch series adding pinctrl/GPIO support for Intel Braswell and Cherrryview. The previous version can be found here:
https://lkml.org/lkml/2014/10/27/118
I've dropped patches [2/4] and [3/4] as they are already applied to the pinctrl tree.
Mika,
I am also trying to add ACPI enablement to my pinctrl driver (not yet submitted), but I'm new to ACPI and pin control drivers, so I have a lot of catching up to do.
In reviewing this patchset, it appears to me that pinctrl-cherryview.c is a normal pinctrl driver that has an acpi_match_table entry, and nothing more.
Assuming that this driver is booting on an ACPI system, what is the mechanism that calls into the driver to configure the pins? Is there a definition for pin control in ASL that provides similar functionality as the pinctrl nodes in a device tree?
Mika Westerberg
maintainerQuoted 14 lines · Timur Tabi
Quoted 9 lines · Mika Westerberg
Hi,
This is second version of the patch series adding pinctrl/GPIO support for Intel Braswell and Cherrryview. The previous version can be found here:
https://lkml.org/lkml/2014/10/27/118
I've dropped patches [2/4] and [3/4] as they are already applied to the pinctrl tree.
Mika,
Quoted 7 lines
I am also trying to add ACPI enablement to my pinctrl driver (not yet submitted), but I'm new to ACPI and pin control drivers, so I have a lot of catching up to do.
In reviewing this patchset, it appears to me that
pinctrl-cherryview.cis a normal pinctrl driver that has anacpi_match_tableentry, and nothing more.
Indeed, it just a normal platform driver that can be enumerated from ACPI using the .acpi_match_table entry.
Quoted 4 lines
Assuming that this driver is booting on an ACPI system, what is the mechanism that calls into the driver to configure the pins? Is there a definition for pin control in ASL that provides similar functionality as the pinctrl nodes in a device tree?
There is nothing like that yet in ACPI world but with the ACPI _DSD patches we are getting properties similar to DT which means that we can provide pinctrl bindings from ACPI systems as well. Typically it has been the BIOS that configures things but it cannot get everything 100% right.
Currently I've been testing the muxing functionality so that I have a small board file that sets mappings and the driver core handles everything from there. For example I have development board where SPI pins are muxed as GPIOs by the BIOS and with the mappings when the SPI device appears the core will mux SPI out of those pins.
Mika Westerberg
maintainerQuoted 37 lines · Mika Westerberg
Quoted 14 lines · Timur Tabi
Quoted 9 lines · Mika Westerberg
Hi,
This is second version of the patch series adding pinctrl/GPIO support for Intel Braswell and Cherrryview. The previous version can be found here:
https://lkml.org/lkml/2014/10/27/118
I've dropped patches [2/4] and [3/4] as they are already applied to the pinctrl tree.
Mika,
Quoted 7 lines
I am also trying to add ACPI enablement to my pinctrl driver (not yet submitted), but I'm new to ACPI and pin control drivers, so I have a lot of catching up to do.
In reviewing this patchset, it appears to me that
pinctrl-cherryview.cis a normal pinctrl driver that has anacpi_match_tableentry, and nothing more.Indeed, it just a normal platform driver that can be enumerated from ACPI using the .acpi_match_table entry.
Quoted 4 lines
Assuming that this driver is booting on an ACPI system, what is the mechanism that calls into the driver to configure the pins? Is there a definition for pin control in ASL that provides similar functionality as the pinctrl nodes in a device tree?
There is nothing like that yet in ACPI world but with the ACPI
_DSDpatches we are getting properties similar to DT which means that we can provide pinctrl bindings from ACPI systems as well. Typically it has been the BIOS that configures things but it cannot get everything 100% right.
Quoted 5 lines
Currently I've been testing the muxing functionality so that I have a small board file that sets mappings and the driver core handles everything from there. For example I have development board where SPI pins are muxed as GPIOs by the BIOS and with the mappings when the SPI device appears the core will mux SPI out of those pins.
For reference the latest ACPI _DSD patches can be found here
Quoted 44 lines · Mika Westerberg
Quoted 37 lines · Mika Westerberg
Quoted 14 lines · Timur Tabi
Quoted 9 lines · Mika Westerberg
Hi,
This is second version of the patch series adding pinctrl/GPIO support for Intel Braswell and Cherrryview. The previous version can be found here:
https://lkml.org/lkml/2014/10/27/118
I've dropped patches [2/4] and [3/4] as they are already applied to the pinctrl tree.
Mika,
Quoted 7 lines
I am also trying to add ACPI enablement to my pinctrl driver (not yet submitted), but I'm new to ACPI and pin control drivers, so I have a lot of catching up to do.
In reviewing this patchset, it appears to me that
pinctrl-cherryview.cis a normal pinctrl driver that has anacpi_match_tableentry, and nothing more.Indeed, it just a normal platform driver that can be enumerated from ACPI using the .acpi_match_table entry.
Quoted 4 lines
Assuming that this driver is booting on an ACPI system, what is the mechanism that calls into the driver to configure the pins? Is there a definition for pin control in ASL that provides similar functionality as the pinctrl nodes in a device tree?
There is nothing like that yet in ACPI world but with the ACPI
_DSDpatches we are getting properties similar to DT which means that we can provide pinctrl bindings from ACPI systems as well. Typically it has been the BIOS that configures things but it cannot get everything 100% right.Quoted 5 lines
Currently I've been testing the muxing functionality so that I have a small board file that sets mappings and the driver core handles everything from there. For example I have development board where SPI pins are muxed as GPIOs by the BIOS and with the mappings when the SPI device appears the core will mux SPI out of those pins.
Quoted 3 lines
For reference the latest ACPI
_DSDpatches can be found here
Actually, it's better to pull the device-properties branch:
git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git device-properties
because that contains the lastest changes. It will be rebased in the future, though, so don't merge it into your "immutable" branches.
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Quoted 4 lines · Rafael J. Wysocki
Quoted 2 lines · Mika Westerberg
For reference the latest ACPI
_DSDpatches can be found here
Quoted 8 lines
Quoted 1 line
Actually, it's better to pull the device-properties branch:
git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.gitdevice-propertiesbecause that contains the lastest changes. It will be rebased in the future, though, so don't merge it into your "immutable" branches.
I've landed these two patches for v3.19, I guess we can wait for the device properties to land properly upstream before proceeding with ACPI support ...? Or are you guys working with one finger constantly on the fast-forward button? :D
Yours,
Linus Walleij
Quoted 9 lines · Linus Walleij
Quoted 8 lines · Rafael J. Wysocki
Quoted 3 lines · Mika Westerberg
For reference the latest ACPI
_DSDpatches can be found hereActually, it's better to pull the device-properties branch:
Quoted 8 lines
Quoted 4 lines
git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.gitdevice-propertiesbecause that contains the lastest changes. It will be rebased in the future, though, so don't merge it into your "immutable" branches.
I've landed these two patches for v3.19, I guess we can wait for the device properties to land properly upstream before proceeding with ACPI support ...?
That would be reasonable IMO.
Quoted 1 line
Or are you guys working with one finger constantly on the fast-forward button? :D
We hoped we'd be able to get the device properties patchset in earlier. Unfortunately, that didn't happen and is kind of blocking stuff as you can see.
Rafael
Mika Westerberg
maintainerQuoted 12 lines · Rafael J. Wysocki
Quoted 11 lines · Linus Walleij
Quoted 10 lines · Rafael J. Wysocki
Quoted 3 lines · Mika Westerberg
For reference the latest ACPI
_DSDpatches can be found hereActually, it's better to pull the device-properties branch:
git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.gitdevice-properties
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
because that contains the lastest changes. It will be rebased in the future, though, so don't merge it into your "immutable" branches.
I've landed these two patches for v3.19, I guess we can wait for the device properties to land properly upstream before proceeding with ACPI support ...?
That would be reasonable IMO.
I agree.
Just wanted to let Timur know that we can support similar bindings in ACPI world in the future.
Quoted 4 lines · Linus Walleij
I've landed these two patches for v3.19, I guess we can wait for the device properties to land properly upstream before proceeding with ACPI support ...? Or are you guys working with one finger constantly on the fast-forward button? :D
I'll consider any ACPI enhancements as soon as they're more-or-less stable, although I prefer to wait until they're in linux-next.
Signature · 2 lines
Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Quoted 6 lines · Rafael J. Wysocki
Actually, it's better to pull the device-properties branch:
git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.gitdevice-propertiesbecause that contains the lastest changes. It will be rebased in the future, though, so don't merge it into your "immutable" branches.
I wish there were more examples on converting OF calls to device_prop* calls. I can't figure out how to obtain the size of a property without reading the property data. I think device_property_present() should be modified to take an optional size property, just like of_find_property().
Signature · 3 lines
Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Quoted 5 lines · Timur Tabi
Quoted 4 lines · Rafael J. Wysocki
Actually, it's better to pull the device-properties branch:
git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.gitdevice-properties
Quoted 7 lines
Quoted 2 lines
because that contains the lastest changes. It will be rebased in the future, though, so don't merge it into your "immutable" branches.
I wish there were more examples on converting OF calls to device_prop* calls. I can't figure out how to obtain the size of a property without reading the property data. I think
device_property_present()should be modified to take an optional size property, just likeof_find_property().
What exactly do you need the size of the property alone for?
Rafael
Quoted 1 line · Rafael J. Wysocki
What exactly do you need the size of the property alone for?
There are lots of situations where you don't know the size of the property in advance (e.g. strings), and drivers use of_find_property() or of_get_property() to pre-allocate a buffer or to verify that the property is correctly formed in the device tree.
Signature · 3 lines
Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Quoted 5 lines · Timur Tabi
There are lots of situations where you don't know the size of the property in advance (e.g. strings), and drivers use
of_find_property()orof_get_property()to pre-allocate a buffer or to verify that the property is correctly formed in the device tree.
To follow-up, I have this problem right now with pinctrl_dt_to_map(). The pinctrl-%d property in the device tree is an array of phandles. The array can be any size, and pinctrl_dt_to_map() queries the size of the property to determine how many phandles there are. It iterates over all of them. How do I support that with device_property_read_u32_array()? That function expects to be told how many phandles there are, and it doesn't even tell me if there are more or fewer than the number I've given.
Signature · 3 lines
Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Quoted 7 lines · Timur Tabi
Quoted 5 lines · Timur Tabi
There are lots of situations where you don't know the size of the property in advance (e.g. strings), and drivers use
of_find_property()orof_get_property()to pre-allocate a buffer or to verify that the property is correctly formed in the device tree.
Quoted 7 lines
To follow-up, I have this problem right now with
pinctrl_dt_to_map(). The pinctrl-%d property in the device tree is an array of phandles. The array can be any size, andpinctrl_dt_to_map()queries the size of the property to determine how many phandles there are. It iterates over all of them. How do I support that withdevice_property_read_u32_array()? That function expects to be told how many phandles there are, and it doesn't even tell me if there are more or fewer than the number I've given.
Well, first of all, you won't use phandles with ACPI. :-)
That seems to be the case in which some ACPI-specific code would need to be written. In ACPI, instead of the list of phandles you'll have a list of references to device objects that you can walk in an analogous way. I'm not sure how much of that code can be shared between DT and ACPI ATM, but it looks like at least some of it can be shared.
And it looks like we'll need a device_property_read_string_index(). :-)
BTW, where's the pinctrl binding documented?
Rafael
Quoted 1 line · Rafael J. Wysocki
Well, first of all, you won't use phandles with ACPI.:-)
Yes, which makes things complicated for me. The pinctrl binding makes heavy use of phandles, so it will be a challenge to come up with a substitue.
Quoted 3 lines
That seems to be the case in which some ACPI-specific code would need to be written. In ACPI, instead of the list of phandles you'll have a list of references to device objects that you can walk in an analogous way.
Can you point me to an example Linux driver that parses references?
Quoted 3 lines
I'm
not sure how much of that code can be shared between DT and ACPI ATM, but it looks like at least some of it can be shared.
So ACPI does not support the concept if variable length properties?
Quoted 1 line
And it looks like we'll need a device_property_read_string_index().:-)
Multi-string properties are also very popular in device tree.
Quoted 2 lines
BTW, where's the pinctrl binding documented?
Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
Signature · 3 lines
Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Quoted 6 lines · Timur Tabi
Quoted 4 lines
I'm
not sure how much of that code can be shared between DT and ACPI ATM, but it looks like at least some of it can be shared.So ACPI does not support the concept if variable length properties?
Ah, I see that it does:
int acpi_dev_prop_read_array(struct acpi_device *adev, const char *propname,
enum dev_prop_type proptype, void *val, size_t nval)
{
...
if (!val) return obj->package.count;
If I pass NULL for 'val', it returns the number of items.
Signature · 3 lines
Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Quoted 15 lines · Timur Tabi
Quoted 6 lines · Timur Tabi
Quoted 4 lines
I'm
not sure how much of that code can be shared between DT and ACPI ATM, but it looks like at least some of it can be shared.So ACPI does not support the concept if variable length properties?
Ah, I see that it does:
int acpi_dev_prop_read_array(struct
acpi_device*adev, const char *propname,
enumdev_prop_typeproptype, void *val,size_tnval)
{
...
Quoted 5 lines
if (!val) return obj->package.count;If I pass NULL for 'val', it returns the number of items.
Yes, it does that.
If you pass NULL for val to device_property_read_*_array(), it will also return the number of items in the property. Including the string one.
We're missing a couple of calls that you'd need for pinctrl, but I'd rather add those along with some users.
Rafael
Quoted 7 lines · Timur Tabi
Quoted 1 line · Rafael J. Wysocki
Well, first of all, you won't use phandles with ACPI.:-)
Yes, which makes things complicated for me. The pinctrl binding makes heavy use of phandles, so it will be a challenge to come up with a substitue.
Quoted 5 lines
Quoted 3 lines
That seems to be the case in which some ACPI-specific code would need to be written. In ACPI, instead of the list of phandles you'll have a list of references to device objects that you can walk in an analogous way.
Can you point me to an example Linux driver that parses references?
The GPIO subsystem does that, but it probably is too complicated for your case, because ACPI has its own native way of representing GPIOs and what we do there is to translate the ACPI way into what the GPIO core expects. Not exactly straightforward, that.
Anyway, if you want me to describe it to you, please let me know.
For pinctrl we don't have any "native ACPI way" of representing things, so we'll need to start with the DT binding directly. That's why I asked about it.
[cut]
Quoted 3 lines
Quoted 1 line
And it looks like we'll need a device_property_read_string_index().:-)
Multi-string properties are also very popular in device tree.
Those we do handle already.
Quoted 4 lines
Quoted 2 lines
BTW, where's the pinctrl binding documented?
Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
Thanks!
Rafael
Quoted 7 lines · Timur Tabi
Quoted 1 line · Rafael J. Wysocki
What exactly do you need the size of the property alone for?
There are lots of situations where you don't know the size of the property in advance (e.g. strings), and drivers use
of_find_property()orof_get_property()to pre-allocate a buffer or to verify that the property is correctly formed in the device tree.
The problem is that in ACPI properties are not contiguous buffers full of data. They generally have internal structure.
But device_property_read_string(), for example, gives you a pointer to the value of the property and you can check the size of that just fine using strlen(). Isn't that sufficient?
Rafael
Quoted 3 lines · Mika Westerberg
There is nothing like that yet in ACPI world but with the ACPI
_DSDpatches we are getting properties similar to DT which means that we can provide pinctrl bindings from ACPI systems as well.
Do you know if anyone has signed up to actually do the work of defining how pinctrl will look in ACPI? I'm guessing the simplest approach would be to:
1) Modify pinctrl_dt_to_map() so that it uses functions like device_read_property() instead of of_find_property() (i.e. use ACPI/DT-agnostic calls instead of DT-specific calls).
2) Define all of the DSD property in ASL so that pinctrl_dt_to_map() works as-is.
3) Possibly rename pinctrl_dt_to_map() to something like pinctrl_prop_to_map() or whatever.
Quoted 3 lines
Typically it has
been the BIOS that configures things but it cannot get everything 100% right.
True, but this assumes that the BIOS can already talk to the pin control device without using the Linux driver. If we use DSD properties to describe the pin control functions, then we're actually using the Linux driver to do pin control, albeit indirectly.
Quoted 5 lines
Currently I've been testing the muxing functionality so that I have a small board file that sets mappings and the driver core handles everything from there. For example I have development board where SPI pins are muxed as GPIOs by the BIOS and with the mappings when the SPI device appears the core will mux SPI out of those pins.
How do you actually get the kernel to call into your pinctrl driver, without using any device tree properties or DSD properties?
Signature · 3 lines
Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Mika Westerberg
maintainerQuoted 7 lines · Timur Tabi
Quoted 3 lines · Mika Westerberg
There is nothing like that yet in ACPI world but with the ACPI
_DSDpatches we are getting properties similar to DT which means that we can provide pinctrl bindings from ACPI systems as well.Do you know if anyone has signed up to actually do the work of defining how pinctrl will look in ACPI?
No, not yet.
Quoted 11 lines
I'm guessing the simplest approach would be to:
1) Modify
pinctrl_dt_to_map()so that it uses functions likedevice_read_property()instead ofof_find_property()(i.e. use ACPI/DT-agnostic calls instead of DT-specific calls).2) Define all of the DSD property in ASL so that
pinctrl_dt_to_map()works as-is.3) Possibly rename
pinctrl_dt_to_map()to something likepinctrl_prop_to_map()or whatever.
Yes, something like that.
We still need to account the fact that BIOS is supposed to configure the pins in advance. The pinctrl mappings are just for refining that, like muxing out the SPI pins instead of GPIOs and so on.
Quoted 8 lines
Quoted 3 lines
Typically it has
been the BIOS that configures things but it cannot get everything 100% right.True, but this assumes that the BIOS can already talk to the pin control device without using the Linux driver. If we use DSD properties to describe the pin control functions, then we're actually using the Linux driver to do pin control, albeit indirectly.
Right.
Quoted 8 lines
Quoted 5 lines
Currently I've been testing the muxing functionality so that I have a small board file that sets mappings and the driver core handles everything from there. For example I have development board where SPI pins are muxed as GPIOs by the BIOS and with the mappings when the SPI device appears the core will mux SPI out of those pins.
How do you actually get the kernel to call into your pinctrl driver, without using any device tree properties or DSD properties?
I'm using a small board file (which is not included in this patch set) that lives in arch/x86/platform/*.
Quoted 3 lines · Mika Westerberg
We still need to account the fact that BIOS is supposed to configure the pins in advance. The pinctrl mappings are just for refining that, like muxing out the SPI pins instead of GPIOs and so on.
Pinctrl currently has no real way of reading out the state from the hardware and presenting it as a selected group+function combination, it only knows what has been selected intrinsically with the system, so some enhancements may be needed to make pinctrl reflect the state when booting.
Yours,
Linus Walleij
Quoted 9 lines · Timur Tabi
Quoted 4 lines · Mika Westerberg
There is nothing like that yet in ACPI world but with the ACPI
_DSDpatches we are getting properties similar to DT which means that we can provide pinctrl bindings from ACPI systems as well.Do you know if anyone has signed up to actually do the work of defining how pinctrl will look in ACPI? I'm guessing the simplest approach would be to:
Actually, for the most part we /don't/ want to try and put pinctrl into an ACPI binding. The assumption is that on an ACPI platform it would be the combination of ACPI and firmware responsible for the pin mappings, not the operating system.
Before even attempting to put pinctrl mappings into your driver, there should instead be a conversation at the ACPI spec level about whether or not it makes sense and what such a binding should look like.
g.
Quoted 11 lines · Grant Likely
Quoted 9 lines · Timur Tabi
Quoted 4 lines · Mika Westerberg
There is nothing like that yet in ACPI world but with the ACPI
_DSDpatches we are getting properties similar to DT which means that we can provide pinctrl bindings from ACPI systems as well.Do you know if anyone has signed up to actually do the work of defining how pinctrl will look in ACPI? I'm guessing the simplest approach would be to:
Quoted 8 lines
Actually, for the most part we /don't/ want to try and put pinctrl into an ACPI binding. The assumption is that on an ACPI platform it would be the combination of ACPI and firmware responsible for the pin mappings, not the operating system.
Before even attempting to put pinctrl mappings into your driver, there should instead be a conversation at the ACPI spec level about whether or not it makes sense and what such a binding should look like.
We may need to support pinctrl on ACPI platforms in the meantime, though, for reasons that Mika mentioned at one point (there are systems where the firmware mangles things etc., which quite frankly is to be expected).
So while I'm all for discussing this in the ASWG, what's the interim approach we should be using, in your opinion?
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Quoted 21 lines · Rafael J. Wysocki
Quoted 11 lines · Grant Likely
Quoted 9 lines · Timur Tabi
Quoted 4 lines · Mika Westerberg
There is nothing like that yet in ACPI world but with the ACPI
_DSDpatches we are getting properties similar to DT which means that we can provide pinctrl bindings from ACPI systems as well.Do you know if anyone has signed up to actually do the work of defining how pinctrl will look in ACPI? I'm guessing the simplest approach would be to:
Quoted 8 lines
Actually, for the most part we /don't/ want to try and put pinctrl into an ACPI binding. The assumption is that on an ACPI platform it would be the combination of ACPI and firmware responsible for the pin mappings, not the operating system.
Before even attempting to put pinctrl mappings into your driver, there should instead be a conversation at the ACPI spec level about whether or not it makes sense and what such a binding should look like.
Quoted 6 lines
We may need to support pinctrl on ACPI platforms in the meantime, though, for reasons that Mika mentioned at one point (there are systems where the firmware mangles things etc., which quite frankly is to be expected).
So while I'm all for discussing this in the ASWG, what's the interim approach we should be using, in your opinion?
Context would be useful at this point. I know (well, I /strongly/ suspect) that Timur is working on ARM server support, where as most of the work you, Darren and Mika are doing is focused on getting into embedded.
The reason I'm pushing for a pinctrl discussion at the ASWG level is because it affects OS portability. The OS should not not be required to have a driver for the pinctrl hardware in order to boot into a usable state (at least far enough to obtain further drivers). The same goes for clock controllers and power regulators. In x86 world this is the default assumption, but in the ARM world it needs to be re-enforced over and over to break out of the embedded mindset that a lot of us have.
So, to answer your question, what's the interim approach? I think it is two things:
1) The base assumption must be that firmware sets up the pinctrl hardware into a usable state at boot and ACPI is used to adjust it as part of the normal OSPM runtime PM operations on devices.
2) Where direct control over the pinctrl hardware is required by the OS, build it into the GPIO driver functionality (which from what I understand is exactly what Mika has done). If any data for the pinctrl is required from ACPI, it can be driver specific data, but any attempt to create a generic binding that the OS is expected to understand should be avoided. This is so we don't end up with the OS needing to understand more than is in the ACPI spec in order to boot.
For a more generic solution (building into OSPM the understanding of pin groups and how to control them when power managing devices), there needs to be work at the ASWG level to figure out what it is going to look like.
g.
Quoted 4 lines
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
Quoted 3 lines · Grant Likely
2) Where direct control over the pinctrl hardware is required by the OS, build it into the GPIO driver functionality (which from what I understand is exactly what Mika has done).
So you're saying that if the GPIO driver is asked to read/write data to GPIO #35, then the driver should first make sure that the pin #35 is configured for GPIO? What if that pin is configured for I2C instead, and now some random driver, is asking to read from GPIO #35, has now broken I2C?
Signature · 3 lines
Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Quoted 3 lines · Grant Likely
1) The base assumption must be that firmware sets up the pinctrl hardware into a usable state at boot and ACPI is used to adjust it as part of the normal OSPM runtime PM operations on devices.
On some SOCs, the GPIO controller and the pin control controller are the same device. So if the Linux driver owns GPIO, we can't have the UEFI runtime talk to the same hardware.
Signature · 3 lines
Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Quoted 4 lines · Grant Likely
Before even attempting to put pinctrl mappings into your driver, there should instead be a conversation at the ACPI spec level about whether or not it makes sense and what such a binding should look like.
Fair enough. For GPIO, using the Linux GPIO driver as a back-end for the ASL means that we don't have to duplicate the Linux GPIO driver in firmware, and it also allows a high degree of flexibility. That sounds like highly desirable features for any device support, including pin control.
I don't really understand ACPI/ASL enough to really have much insight in this area, but I've been waiting over six months for someone ... anyone ... to do someone on this area. So I'm kinda stuck -- I have a vested interested in this area, and yet I'm not in a position to contribute much.
Signature · 3 lines
Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Quoted 9 lines · Timur Tabi
Quoted 4 lines · Mika Westerberg
There is nothing like that yet in ACPI world but with the ACPI
_DSDpatches we are getting properties similar to DT which means that we can provide pinctrl bindings from ACPI systems as well.Do you know if anyone has signed up to actually do the work of defining how pinctrl will look in ACPI?
We don't even have a good standard for device tree yet, we're rehashing the set-up for pin controllers with per-pin granularity as we speak. For controllers combining groups with functions identified with strings, and for pin config we have a sort of generic solution.
Yours,
Linus Walleij
Hi,
Quoted 14 lines · Mika Westerberg
Hi,
This is second version of the patch series adding pinctrl/GPIO support for Intel Braswell and Cherrryview. The previous version can be found here:
https://lkml.org/lkml/2014/10/27/118
I've dropped patches [2/4] and [3/4] as they are already applied to the pinctrl tree.
Changes to the previous version:
[1/2] - Removed unnecessary cast and added Rafael's ACK.
Quoted 8 lines
[2/2] - Use Ohms instead of kOhms in pin configuration.
- Changechv_config_set_pull()to be not so convoluted.
- Remove locking when we just read single register. This is not needed.
- UseBIT()instead of (1 << something)Mika Westerberg (2):
gpio / ACPI: Add knowledge about pin controllers toacpi_get_gpiod()
pinctrl: Add Intel Cherryview/Braswell pin controller support
Pinctrl setup has traditionally always been done by firmware on x86, and some ARM platforms are again moving back to that state (since reconfiguring pinctrl in the kernel is in some cases not safe).
What's the purpose of exposing this to the kernel on x86 now? I can see the need to expose GPIO, but not pinctrl? Having the pin control hidden away in firmware has been one of the benefits on x86, and you're now undoing it... :)
-Olof
Mika Westerberg
maintainerQuoted 8 lines · Olof Johansson
Pinctrl setup has traditionally always been done by firmware on x86, and some ARM platforms are again moving back to that state (since reconfiguring pinctrl in the kernel is in some cases not safe).
What's the purpose of exposing this to the kernel on x86 now? I can see the need to expose GPIO, but not pinctrl? Having the pin control hidden away in firmware has been one of the benefits on x86, and you're now undoing it... :)
Well, the hardware is actually a pin controller so it can configure pins in different way.
In addition to that we still do expect that the pins are configured by the BIOS for the time being. The advantage of having pinctrl driver is more like fixing things that the BIOS got wrong (like for example SPI pins that were muxed as GPIOs), not to reconfigure everything.
Plus it has really nice debugfs interface :-)