gpio: of: make it possible to reference gpios probed in acpi in device tree
PATCH 1/1 gpio: of: make it possible to reference gpios probed in acpi in device tree
sometimes it is necessary to use both acpi and device tree to declare devices. Not every gpio device driver which has an acpi_match_table has an of_match table (e.g. amd-pinctrl). Furthermore gpio is an device which can't be easily disabled in acpi and then redeclared in device tree, as it often gets used by other devices declared in acpi (e.g. via GpioInt or GpioIo). Thus a disable of acpi and migration to device tree is not always possible or very time consuming, while acpi by itself is very limited and not always sufficient. This won't affect most configurations, as most of the time either CONFIG_ACPI or CONFIG_OF gets enabled, not both.
--- drivers/gpio/gpiolib-of.c | 241 +++++++++++++++++++++++--------------- 1 file changed, 145 insertions(+), 96 deletions(-)
drivers/gpio/gpiolib-of.c +145 -96
@@ -18,6 +18,7 @@#include <linux/pinctrl/pinctrl.h> #include <linux/slab.h> #include <linux/string.h> +#include <linux/acpi.h> #include <linux/gpio/consumer.h> #include <linux/gpio/machine.h>
@@ -118,6 +119,107 @@ int of_gpio_count(const struct fwnode_handle *fwnode, const char *con_id)return ret ? ret : -ENOENT ; } +/** +* of_gpio_twocell_xlate - translate twocell gpiospec to the GPIO number and flags +* @gc: pointer to the gpio_chip structure +* @gpiospec: GPIO specifier as found in the device tree +* @flags: a flags pointer to fill in +* +* This is simple translation function, suitable for the most 1:1 mapped +* GPIO chips. This function performs only one sanity check: whether GPIO +* is less than ngpios (that is specified in the gpio_chip). +* +* Returns: +* GPIO number (>= 0) on success, negative errno on failure. +*/ +static int of_gpio_twocell_xlate (struct gpio_chip *gc, +const struct of_phandle_args *gpiospec, +u32 *flags) +{ +/* +* We're discouraging gpio_cells < 2, since that way you'll have to +* write your own xlate function (that will have to retrieve the GPIO +* number and the flags from a single gpio cell -- this is possible, +* but not recommended). +*/ +if (gc->of_gpio_n_cells !=2 ) { +WARN_ON (1 ); +return -EINVAL ; + } + +if (WARN_ON (gpiospec->args_count < gc->of_gpio_n_cells)) +return -EINVAL ; + +if (gpiospec->args[0 ] >= gc->ngpio) +return -EINVAL ; + +if (flags) + *flags = gpiospec->args[1 ]; + +return gpiospec->args[0 ]; +} + +/** +* of_gpio_threecell_xlate - translate threecell gpiospec to the GPIO number and flags +* @gc: pointer to the gpio_chip structure +* @gpiospec: GPIO specifier as found in the device tree +* @flags: a flags pointer to fill in +* +* This is simple translation function, suitable for the most 1:n mapped +* GPIO chips, i.e. several GPIO chip instances from one device tree node. +* In this case the following binding is implied: +* +* foo-gpios = <&gpio instance offset flags>; +* +* Returns: +* GPIO number (>= 0) on success, negative errno on failure. +*/ +static int of_gpio_threecell_xlate (struct gpio_chip *gc, +const struct of_phandle_args *gpiospec, +u32 *flags) +{ +if (gc->of_gpio_n_cells !=3 ) { +WARN_ON (1 ); +return -EINVAL ; + } + +if (WARN_ON (gpiospec->args_count !=3 )) +return -EINVAL ; + +/* +* Check chip instance number, the driver responds with true if +* this is the chip we are looking for. +*/ +if (!gc->of_node_instance_match (gc, gpiospec->args[0 ])) +return -EINVAL ; + +if (gpiospec->args[1 ] >= gc->ngpio) +return -EINVAL ; + +if (flags) + *flags = gpiospec->args[2 ]; + +return gpiospec->args[1 ]; +} + +static int of_gpiochip_init (struct gpio_chip *chip) +{ +if (!chip->of_xlate) { +if (chip->of_gpio_n_cells ==3 ) { +if (!chip->of_node_instance_match) +return -EINVAL ; + chip->of_xlate = of_gpio_threecell_xlate; + }else { + chip->of_gpio_n_cells =2 ; + chip->of_xlate = of_gpio_twocell_xlate; + } + } + +if (chip->of_gpio_n_cells >MAX_PHANDLE_ARGS ) +return -EINVAL ; +return 0 ; +} +static int of_gpiochip_match_node_and_xlate (struct gpio_chip *chip,const void *data) {
@@ -134,6 +236,40 @@ of_find_gpio_device_by_xlate(const struct of_phandle_args *gpiospec)return gpio_device_find (gpiospec, of_gpiochip_match_node_and_xlate); } +#ifdef CONFIG_ACPI +static int of_gpiochip_match_acpi_path (struct gpio_chip *chip, +const void *data) +{ +const char *acpi_path = data; +const char *chip_acpi_path; +acpi_handle handle; +int ret; + + handle =ACPI_HANDLE (chip->parent); +if (!handle) +return 0 ; + chip_acpi_path =acpi_handle_path (handle); +if (!chip_acpi_path) +return 0 ; + + ret = !strcmp (acpi_path, chip_acpi_path); + +if (ret) + ret = !of_gpiochip_init (chip); + +return ret; +} + +static struct gpio_device *of_find_gpio_device_by_acpi (const struct of_phandle_args *gpiospec) +{ +const char *acpi_path =NULL ; + +if (of_property_read_string (gpiospec->np,"acpi-path" , &acpi_path)) +return NULL ; +return gpio_device_find (acpi_path, of_gpiochip_match_acpi_path); +} +#endif +static struct gpio_desc *of_xlate_and_get_gpiod_flags (struct gpio_chip *chip,struct of_phandle_args *gpiospec,enum of_gpio_flags *flags)
@@ -423,6 +559,12 @@ static struct gpio_desc *of_get_named_gpiod_flags(const struct device_node *np, struct gpio_device *gdev __free(gpio_device_put) =of_find_gpio_device_by_xlate (&gpiospec); +#ifdef CONFIG_ACPI +if (!gdev) { + gdev =of_find_gpio_device_by_acpi (&gpiospec); + } +#endif +if (!gdev) { desc =ERR_PTR (-EPROBE_DEFER ); goto out;
@@ -948,89 +1090,6 @@ struct notifier_block gpio_of_notifier = { };#endif /* CONFIG_OF_DYNAMIC */ -/** -* of_gpio_twocell_xlate - translate twocell gpiospec to the GPIO number and flags -* @gc: pointer to the gpio_chip structure -* @gpiospec: GPIO specifier as found in the device tree -* @flags: a flags pointer to fill in -* -* This is simple translation function, suitable for the most 1:1 mapped -* GPIO chips. This function performs only one sanity check: whether GPIO -* is less than ngpios (that is specified in the gpio_chip). -* -* Returns: -* GPIO number (>= 0) on success, negative errno on failure. -*/ -static int of_gpio_twocell_xlate (struct gpio_chip *gc, -const struct of_phandle_args *gpiospec, -u32 *flags) -{ -/* -* We're discouraging gpio_cells < 2, since that way you'll have to -* write your own xlate function (that will have to retrieve the GPIO -* number and the flags from a single gpio cell -- this is possible, -* but not recommended). -*/ -if (gc->of_gpio_n_cells !=2 ) { -WARN_ON (1 ); -return -EINVAL ; - } - -if (WARN_ON (gpiospec->args_count < gc->of_gpio_n_cells)) -return -EINVAL ; - -if (gpiospec->args[0 ] >= gc->ngpio) -return -EINVAL ; - -if (flags) - *flags = gpiospec->args[1 ]; - -return gpiospec->args[0 ]; -} - -/** -* of_gpio_threecell_xlate - translate threecell gpiospec to the GPIO number and flags -* @gc: pointer to the gpio_chip structure -* @gpiospec: GPIO specifier as found in the device tree -* @flags: a flags pointer to fill in -* -* This is simple translation function, suitable for the most 1:n mapped -* GPIO chips, i.e. several GPIO chip instances from one device tree node. -* In this case the following binding is implied: -* -* foo-gpios = <&gpio instance offset flags>; -* -* Returns: -* GPIO number (>= 0) on success, negative errno on failure. -*/ -static int of_gpio_threecell_xlate (struct gpio_chip *gc, -const struct of_phandle_args *gpiospec, -u32 *flags) -{ -if (gc->of_gpio_n_cells !=3 ) { -WARN_ON (1 ); -return -EINVAL ; - } - -if (WARN_ON (gpiospec->args_count !=3 )) -return -EINVAL ; - -/* -* Check chip instance number, the driver responds with true if -* this is the chip we are looking for. -*/ -if (!gc->of_node_instance_match (gc, gpiospec->args[0 ])) -return -EINVAL ; - -if (gpiospec->args[1 ] >= gc->ngpio) -return -EINVAL ; - -if (flags) - *flags = gpiospec->args[2 ]; - -return gpiospec->args[1 ]; -} -#if IS_ENABLED (CONFIG_OF_GPIO_MM_GPIOCHIP )#include <linux/gpio/legacy-of-mm-gpiochip.h> /**
@@ -1256,19 +1315,9 @@ int of_gpiochip_add(struct gpio_chip *chip)if (!np)return 0 ; -if (!chip->of_xlate) { -if (chip->of_gpio_n_cells ==3 ) { -if (!chip->of_node_instance_match) -return -EINVAL ; - chip->of_xlate = of_gpio_threecell_xlate; - }else { - chip->of_gpio_n_cells =2 ; - chip->of_xlate = of_gpio_twocell_xlate; - } - } - -if (chip->of_gpio_n_cells >MAX_PHANDLE_ARGS ) -return -EINVAL ; + ret =of_gpiochip_init (chip); +if (ret) +return ret; ret =of_gpiochip_add_pin_range (chip);if (ret)
Signature · 1 line
2.49.1
Hi,
Quoted 9 lines · Markus Probst
sometimes it is necessary to use both acpi and device tree to declare devices. Not every gpio device driver which has an
acpi_match_tablehas anof_matchtable (e.g. amd-pinctrl). Furthermore gpio is an device which can't be easily disabled in acpi and then redeclared in device tree, as it often gets used by other devices declared in acpi (e.g. via GpioInt or GpioIo). Thus a disable of acpi and migration to device tree is not always possible or very time consuming, while acpi by itself is very limited and not always sufficient. This won't affect most configurations, as most of the time eitherCONFIG_ACPIorCONFIG_OFgets enabled, not both.
Can you provide a real example where this kind of mixup can happen? The ACPI ID PRP0001 specifically was added to allow using DT bindings in ACPI based systems.
Regarding the patch, please spell gpio -> GPIO, acpi ACPI and so on.
Quoted 10 lines
Signed-off-by Markus Probst <[email protected]>--- drivers/gpio/gpiolib-of.c | 241 +++++++++++++++++++++++--------------- 1 file changed, 145 insertions(+), 96 deletions(-)drivers/gpio/gpiolib-of.c +0
-0
drivers/gpio/gpiolib-of.c line 21
Quoted 4 lines
drivers/gpio/gpiolib-of.c +1
-0@@ -18,6 +18,7 @@#include <linux/pinctrl/pinctrl.h> #include <linux/slab.h> #include <linux/string.h> +#include <linux/acpi.h>
I'm not really sure if this is good idea to be honest.
Quoted 21 lines · Mika Westerberg
Hi,
Quoted 9 lines · Markus Probst
sometimes it is necessary to use both acpi and device tree to declare
devices. Not every gpio device driver which has anacpi_match_tablehas
anof_matchtable (e.g. amd-pinctrl). Furthermore gpio is an device which
can't be easily disabled in acpi and then redeclared in device tree, as
it often gets used by other devices declared in acpi (e.g. viaQuoted 8 lines
GpioInt or
GpioIo). Thus a disable of acpi and migration to device tree is not always
possible or very time consuming, while acpi by itself is very limited and
not always sufficient. This won't affect most configurations, as most of
the time eitherCONFIG_ACPIorCONFIG_OFgets enabled, not both.
Quoted 1 line
Can you provide a real example where this kind of mixup can happen?
In my specific usecase for the Synology DS923+, there are gpios for powering the usb vbus on (powered down by default), also for powering on sata disks. (defining a fixed-regulator for the usb vbus for example)
Quoted 4 lines
The
ACPI ID PRP0001 specifically was added to allow using DT bindings in ACPI
based systems.
Hmm, would requiring patching of the acpi tables. Not sure if it would work with the fixed-regulator though, as it uses dev->of_node instead of dev->fwnode. I will try to see if I can make it work this way.
Quoted 20 lines
Regarding the patch, please spell gpio -> GPIO, acpi ACPI and so on.
Quoted 11 lines
Signed-off-by Markus Probst <[email protected]>---
drivers/gpio/gpiolib-of.c | 241 +++++++++++++++++++++++-----------
----1 file changed, 145 insertions(+), 96 deletions(-)drivers/gpio/gpiolib-of.c +0
-0drivers/gpio/gpiolib-of.c line 21
Quoted 4 lines
drivers/gpio/gpiolib-of.c +1
-0@@ -18,6 +18,7 @@ #include <linux/pinctrl/pinctrl.h> #include <linux/slab.h> #include <linux/string.h> +#include <linux/acpi.h> I'm not really sure if this is good idea to be honest.
Quoted 22 lines · Markus Probst
Quoted 21 lines · Mika Westerberg
Hi,
Quoted 17 lines · Markus Probst
sometimes it is necessary to use both acpi and device tree to declare
devices. Not every gpio device driver which has anacpi_match_tablehas
anof_matchtable (e.g. amd-pinctrl). Furthermore gpio is an device which
can't be easily disabled in acpi and then redeclared in device tree, as
it often gets used by other devices declared in acpi (e.g. via GpioInt or
GpioIo). Thus a disable of acpi and migration to device tree is not always
possible or very time consuming, while acpi by itself is very limited and
not always sufficient. This won't affect most configurations, as most of
the time eitherCONFIG_ACPIorCONFIG_OFgets enabled, not both.
Quoted 5 lines
Quoted 1 line
Can you provide a real example where this kind of mixup can happen?
In my specific usecase for the Synology DS923+, there are gpios for powering the usb vbus on (powered down by default), also for powering on sata disks. (defining a fixed-regulator for the usb vbus for example)
Okay regulators are Power Resources in ACPI.
Quoted 7 lines
Quoted 4 lines
The
ACPI ID PRP0001 specifically was added to allow using DT bindings in ACPI
based systems.Hmm, would requiring patching of the acpi tables. Not sure if it would work with the fixed-regulator though, as it uses
dev->of_nodeinstead ofdev->fwnode. I will try to see if I can make it work this way.
I think you can do this by using SSDT overlays instead of patching the tables:
https://docs.kernel.org/admin-guide/acpi/ssdt-overlays.html
There is configfs interface too.
Quoted 30 lines · Mika Westerberg
Quoted 29 lines · Markus Probst
Quoted 28 lines · Mika Westerberg
Hi,
Quoted 14 lines · Markus Probst
sometimes it is necessary to use both acpi and device tree to declare
devices. Not every gpio device driver which has anacpi_match_table
has
anof_matchtable (e.g. amd-pinctrl). Furthermore gpio is an device
which
can't be easily disabled in acpi and then redeclared in device tree, as
it often gets used by other devices declared in acpi (e.g. via GpioInt or
GpioIo). Thus a disable of acpi and migration to device tree is notQuoted 8 lines
always
possible or very time consuming, while acpi by itself is very limited and
not always sufficient. This won't affect most configurations, as
most of
the time eitherCONFIG_ACPIorCONFIG_OFgets enabled, not both.Can you provide a real example where this kind of mixup can happen?
Quoted 7 lines
Quoted 5 lines
In my specific usecase for the Synology DS923+, there are gpios for powering the usb vbus on (powered down by default), also for powering
on sata disks. (defining a fixed-regulator for the usb vbus for example)Okay regulators are Power Resources in ACPI.
I did look into it and using a ssdt overlay sounds like a better idea than using a devicetree, but there is another problem with it. I cannot define a PowerResource that uses a gpio to control it (or at least haven't found any docs on it). The gpio controller uses AMDI0030 and is handled by the linux kernel driver (not acpi). An ACPI method can't talk to the driver to set it.
Maybe there is a way to expose a kernel function to acpi instead?
- Markus Probst
Quoted 19 lines
Quoted 11 lines
Quoted 6 lines
The
ACPI ID PRP0001 specifically was added to allow using DT bindings in
ACPI
based systems.Hmm, would requiring patching of the acpi tables. Not sure if it would
work with the fixed-regulator though, as it usesdev->of_nodeinstead
ofdev->fwnode. I will try to see if I can make it work this way.I think you can do this by using SSDT overlays instead of patching the
tables:https://docs.kernel.org/admin-guide/acpi/ssdt-overlays.html
There is configfs interface too.
Quoted 42 lines · Markus Probst
Quoted 33 lines · Mika Westerberg
Quoted 32 lines · Markus Probst
Quoted 31 lines · Mika Westerberg
Hi,
Quoted 17 lines · Markus Probst
sometimes it is necessary to use both acpi and device tree to declare
devices. Not every gpio device driver which has anacpi_match_table
has
anof_matchtable (e.g. amd-pinctrl). Furthermore gpio is an device
which
can't be easily disabled in acpi and then redeclared in device
tree, as
it often gets used by other devices declared in acpi (e.g. via
GpioInt or
GpioIo). Thus a disable of acpi and migration to device tree is
notQuoted 8 lines
always
possible or very time consuming, while acpi by itself is very limited and
not always sufficient. This won't affect most configurations, as
most of
the time eitherCONFIG_ACPIorCONFIG_OFgets enabled, not both.Can you provide a real example where this kind of mixup can happen?
Quoted 8 lines
Quoted 6 lines
In my specific usecase for the Synology DS923+, there are gpios for
powering the usb vbus on (powered down by default), also for powering
on sata disks. (defining a fixed-regulator for the usb vbus for example)Okay regulators are Power Resources in ACPI.
Quoted 8 lines
I did look into it and using a ssdt overlay sounds like a better idea than using a devicetree, but there is another problem with it. I cannot
define a PowerResource that uses a gpio to control it (or at least haven't found any docs on it). The gpio controller uses AMDI0030 and is
handled by the linux kernel driver (not acpi). An ACPI method can't talk to the driver to set it.
Okay, there is actually a way, using the gpio operation regions added in 473ed7be0da041275d57ab0bde1c21a6f23e637f.
If this works, it would make this patch obsolete (for me), assuming there is not another issue with it.
Quoted 24 lines
Maybe there is a way to expose a kernel function to acpi instead?
- Markus Probst
Quoted 20 lines
Quoted 7 lines
Quoted 7 lines
The
ACPI ID PRP0001 specifically was added to allow using DT bindings
in
ACPI
based systems.Quoted 5 lines
Hmm, would requiring patching of the acpi tables. Not sure if it would
work with the fixed-regulator though, as it usesdev->of_nodeinstead
ofdev->fwnode. I will try to see if I can make it work this way.I think you can do this by using SSDT overlays instead of patching the
tables:https://docs.kernel.org/admin-guide/acpi/ssdt-overlays.html
There is configfs interface too.
The SSDT Overlay approach did work, so I don't really have a usecase for this patch anymore.
This patch *could* still be useful, but as I can't name an example, there is probably no reason to merge it anymore.
- Markus Probst
Quoted 56 lines · Mika Westerberg
Quoted 27 lines · Markus Probst
Quoted 26 lines · Mika Westerberg
Hi,
Quoted 22 lines · Markus Probst
sometimes it is necessary to use both acpi and device tree to declare
devices. Not every gpio device driver which has anacpi_match_table
has
anof_matchtable (e.g. amd-pinctrl). Furthermore gpio is an device
which
can't be easily disabled in acpi and then redeclared in device tree, as
it often gets used by other devices declared in acpi (e.g. via GpioInt or
GpioIo). Thus a disable of acpi and migration to device tree is not
always
possible or very time consuming, while acpi by itself is very limited and
not always sufficient. This won't affect most configurations, as
most of
the time eitherCONFIG_ACPIorCONFIG_OFgets enabled, not both.Quoted 7 lines
Quoted 2 lines
Can you provide a real example where this kind of mixup can happen?
In my specific usecase for the Synology DS923+, there are gpios for powering the usb vbus on (powered down by default), also for powering
on sata disks. (defining a fixed-regulator for the usb vbus for example)Okay regulators are Power Resources in ACPI.
Quoted 10 lines
Quoted 5 lines
The
ACPI ID PRP0001 specifically was added to allow using DT bindings in
ACPI
based systems.Hmm, would requiring patching of the acpi tables. Not sure if it would
work with the fixed-regulator though, as it usesdev->of_nodeinstead
ofdev->fwnode. I will try to see if I can make it work this way.I think you can do this by using SSDT overlays instead of patching the
tables:https://docs.kernel.org/admin-guide/acpi/ssdt-overlays.html
There is configfs interface too.
Quoted 2 lines · Markus Probst
sometimes it is necessary to use both acpi and device tree to declare
This is a rather controversial change so "sometimes" is not convincing me. I would like to see a user of this added in upstream to consider it.
Quoted 2 lines
devices. Not every gpio device driver which has an
acpi_match_tablehas anof_matchtable (e.g. amd-pinctrl). Furthermore gpio is an device which
What is the use-case here because I'm unable to wrap my head around it? Referencing devices described in ACPI from DT? How would the associated DT source look like?
Bart
Quoted 9 lines
can't be easily disabled in acpi and then redeclared in device tree, as it often gets used by other devices declared in acpi (e.g. via GpioInt or GpioIo). Thus a disable of acpi and migration to device tree is not always possible or very time consuming, while acpi by itself is very limited and not always sufficient. This won't affect most configurations, as most of the time either
CONFIG_ACPIorCONFIG_OFgets enabled, not both.Signed-off-by Markus Probst <[email protected]>---
Quoted 11 lines · Bartosz Golaszewski
Quoted 3 lines · Markus Probst
sometimes it is necessary to use both acpi and device tree to declare
This is a rather controversial change so "sometimes" is not convincing
me. I would like to see a user of this added in upstream to consider it.
Quoted 8 lines
Quoted 4 lines
devices. Not every gpio device driver which has an
acpi_match_tablehas
anof_matchtable (e.g. amd-pinctrl). Furthermore gpio is an device whichWhat is the use-case here because I'm unable to wrap my head around it? Referencing devices described in ACPI from DT? How would the associated DT source look like?
In my specific usecase for the Synology DS923+, there are gpios for powering the usb vbus on (powered down by default), also for powering on sata disks. An example for a regulator defined in DT using a gpio in ACPI (in this case controlling the power of on of the usb ports):
gpio: gpio-controller@fed81500 {
acpi-path = "\\_SB_.GPIO";
#gpio-cells = <2>;
};
vbus1_regulator: fixedregulator@0 {
compatible = "regulator-fixed";
regulator-name = "vbus1_regulator";
regulator-min-microvolt = <5000000>;
regulator-max-microvolt = <5000000>;
gpio = <&gpio 0x2a 0x01>;
};- Markus Probst
Quoted 383 lines
Bart
Quoted 380 lines
can't be easily disabled in acpi and then redeclared in device tree, as
it often gets used by other devices declared in acpi (e.g. via GpioInt or
GpioIo). Thus a disable of acpi and migration to device tree is not always
possible or very time consuming, while acpi by itself is very limited and
not always sufficient. This won't affect most configurations, as most of
the time eitherCONFIG_ACPIorCONFIG_OFgets enabled, not both.Signed-off-by Markus Probst <[email protected]>---
Quoted 366 lines
Quoted 366 lines
Quoted 366 lines
Quoted 366 lines
Quoted 366 lines
Quoted 366 lines
Quoted 366 lines
Quoted 366 lines
Quoted 366 lines
Quoted 366 lines
Quoted 366 lines
Quoted 39 lines · Markus Probst
Quoted 11 lines · Bartosz Golaszewski
Quoted 3 lines · Markus Probst
sometimes it is necessary to use both acpi and device tree to declare
This is a rather controversial change so "sometimes" is not convincing
me. I would like to see a user of this added in upstream to consider it.Quoted 8 lines
Quoted 4 lines
devices. Not every gpio device driver which has an
acpi_match_tablehas
anof_matchtable (e.g. amd-pinctrl). Furthermore gpio is an device whichWhat is the use-case here because I'm unable to wrap my head around it? Referencing devices described in ACPI from DT? How would the associated DT source look like?
In my specific usecase for the Synology DS923+, there are gpios for powering the usb vbus on (powered down by default), also for powering on sata disks. An example for a regulator defined in DT using a gpio in ACPI (in this case controlling the power of on of the usb ports):
gpio: gpio-controller@fed81500 { acpi-path = "\\_SB_.GPIO"; #gpio-cells = <2>; }; vbus1_regulator: fixedregulator@0 { compatible = "regulator-fixed"; regulator-name = "vbus1_regulator"; regulator-min-microvolt = <5000000>; regulator-max-microvolt = <5000000>; gpio = <&gpio 0x2a 0x01>; };
Quoted 2 lines
- Markus Probst
Quoted 1 line
Krzysztof: Could you please look at this and chime in? Does this make any sense?
Quoted 14 lines
Quoted 14 lines
Bart
Quoted 12 lines
can't be easily disabled in acpi and then redeclared in device tree, as
it often gets used by other devices declared in acpi (e.g. via GpioInt or
GpioIo). Thus a disable of acpi and migration to device tree is not always
possible or very time consuming, while acpi by itself is very limited and
not always sufficient. This won't affect most configurations, as most of
the time eitherCONFIG_ACPIorCONFIG_OFgets enabled, not both.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Signed-off-by Markus Probst <[email protected]>---
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
[snip]
What happened here with your mailer?
Bart
Quoted 41 lines · Bartosz Golaszewski
Quoted 39 lines · Markus Probst
Quoted 11 lines · Bartosz Golaszewski
Quoted 3 lines · Markus Probst
sometimes it is necessary to use both acpi and device tree to declare
This is a rather controversial change so "sometimes" is not convincing
me. I would like to see a user of this added in upstream to consider it.Quoted 8 lines
Quoted 4 lines
devices. Not every gpio device driver which has an
acpi_match_tablehas
anof_matchtable (e.g. amd-pinctrl). Furthermore gpio is an device whichWhat is the use-case here because I'm unable to wrap my head around it? Referencing devices described in ACPI from DT? How would the associated DT source look like?
In my specific usecase for the Synology DS923+, there are gpios for powering the usb vbus on (powered down by default), also for powering on sata disks. An example for a regulator defined in DT using a gpio in ACPI (in this case controlling the power of on of the usb ports):
gpio: gpio-controller@fed81500 { acpi-path = "\\_SB_.GPIO"; #gpio-cells = <2>; }; vbus1_regulator: fixedregulator@0 { compatible = "regulator-fixed"; regulator-name = "vbus1_regulator"; regulator-min-microvolt = <5000000>; regulator-max-microvolt = <5000000>; gpio = <&gpio 0x2a 0x01>; };
Quoted 5 lines
Quoted 2 lines
- Markus Probst
Quoted 1 line
Krzysztof: Could you please look at this and chime in? Does this make any sense?
In a week (Gmail on mobile absolutely ducks), after I'll dig out from the emails. Feel free to ping again, in case I forget.
Quoted 40 lines · Bartosz Golaszewski
Quoted 39 lines · Markus Probst
Quoted 11 lines · Bartosz Golaszewski
Quoted 3 lines · Markus Probst
sometimes it is necessary to use both acpi and device tree to declare
This is a rather controversial change so "sometimes" is not convincing
me. I would like to see a user of this added in upstream to consider it.Quoted 8 lines
Quoted 4 lines
devices. Not every gpio device driver which has an
acpi_match_tablehas
anof_matchtable (e.g. amd-pinctrl). Furthermore gpio is an device whichWhat is the use-case here because I'm unable to wrap my head around it? Referencing devices described in ACPI from DT? How would the associated DT source look like?
In my specific usecase for the Synology DS923+, there are gpios for powering the usb vbus on (powered down by default), also for powering on sata disks. An example for a regulator defined in DT using a gpio in ACPI (in this case controlling the power of on of the usb ports):
gpio: gpio-controller@fed81500 { acpi-path = "\\_SB_.GPIO"; #gpio-cells = <2>; }; vbus1_regulator: fixedregulator@0 { compatible = "regulator-fixed"; regulator-name = "vbus1_regulator"; regulator-min-microvolt = <5000000>; regulator-max-microvolt = <5000000>; gpio = <&gpio 0x2a 0x01>; };
Quoted 4 lines
Quoted 2 lines
- Markus Probst
Quoted 1 line
Krzysztof: Could you please look at this and chime in? Does this make any sense?
There is no such property as acpi-path and I don't see here any ABI being documented. Nothing in dtschema, either. Nothing in DT spec. I also did not receive this patch. Actually - nothing from [email protected] in mail mailbox.
So no clue what is this about, but if you want to use undocumented property then obviously no.
Best regards,
Krzysztof
Quoted 48 lines · Krzysztof Kozlowski
Quoted 40 lines · Bartosz Golaszewski
Quoted 39 lines · Markus Probst
Quoted 11 lines · Bartosz Golaszewski
Quoted 3 lines · Markus Probst
sometimes it is necessary to use both acpi and device tree to declare
This is a rather controversial change so "sometimes" is not convincing
me. I would like to see a user of this added in upstream to consider it.Quoted 8 lines
Quoted 4 lines
devices. Not every gpio device driver which has an
acpi_match_tablehas
anof_matchtable (e.g. amd-pinctrl). Furthermore gpio is an device whichWhat is the use-case here because I'm unable to wrap my head around it? Referencing devices described in ACPI from DT? How would the associated DT source look like?
In my specific usecase for the Synology DS923+, there are gpios for powering the usb vbus on (powered down by default), also for powering on sata disks. An example for a regulator defined in DT using a gpio in ACPI (in this case controlling the power of on of the usb ports):
gpio: gpio-controller@fed81500 { acpi-path = "\\_SB_.GPIO"; #gpio-cells = <2>; }; vbus1_regulator: fixedregulator@0 { compatible = "regulator-fixed"; regulator-name = "vbus1_regulator"; regulator-min-microvolt = <5000000>; regulator-max-microvolt = <5000000>; gpio = <&gpio 0x2a 0x01>; };Quoted 4 lines
Quoted 2 lines
- Markus Probst
Quoted 1 line
Krzysztof: Could you please look at this and chime in? Does this make any sense?
Quoted 8 lines
There is no such property as acpi-path and I don't see here any ABI being documented. Nothing in dtschema, either. Nothing in DT spec. I also did not receive this patch. Actually - nothing from [email protected] in mail mailbox.
So no clue what is this about, but if you want to use undocumented property then obviously no.
I interpret this as a vague proposal of adding a way of referencing ACPI nodes from DT source and this is my question: does this make any sense? It doesn't to me at first glance but we do sometimes describe firmware details in DT so I figured I'd ask you.
It seems like Markus found a different solution in the end so it may not even be important anymore.
Bartosz
Quoted 54 lines · Bartosz Golaszewski
Quoted 53 lines · Krzysztof Kozlowski
Quoted 40 lines · Bartosz Golaszewski
Quoted 39 lines · Markus Probst
Quoted 11 lines · Bartosz Golaszewski
Quoted 3 lines · Markus Probst
sometimes it is necessary to use both acpi and device tree to declare
This is a rather controversial change so "sometimes" is not convincing
me. I would like to see a user of this added in upstream to consider it.Quoted 8 lines
Quoted 4 lines
devices. Not every gpio device driver which has an
acpi_match_tablehas
anof_matchtable (e.g. amd-pinctrl). Furthermore gpio is an device whichWhat is the use-case here because I'm unable to wrap my head around it? Referencing devices described in ACPI from DT? How would the associated DT source look like?
In my specific usecase for the Synology DS923+, there are gpios for powering the usb vbus on (powered down by default), also for powering on sata disks. An example for a regulator defined in DT using a gpio in ACPI (in this case controlling the power of on of the usb ports):
gpio: gpio-controller@fed81500 { acpi-path = "\\_SB_.GPIO"; #gpio-cells = <2>; }; vbus1_regulator: fixedregulator@0 { compatible = "regulator-fixed"; regulator-name = "vbus1_regulator"; regulator-min-microvolt = <5000000>; regulator-max-microvolt = <5000000>; gpio = <&gpio 0x2a 0x01>; };Quoted 4 lines
Quoted 2 lines
- Markus Probst
Quoted 1 line
Krzysztof: Could you please look at this and chime in? Does this make any sense?
There is no such property as acpi-path and I don't see here any ABI being documented. Nothing in dtschema, either. Nothing in DT spec. I also did not receive this patch. Actually - nothing from [email protected] in mail mailbox.
Quoted 8 lines
Quoted 3 lines
So no clue what is this about, but if you want to use undocumented property then obviously no.
I interpret this as a vague proposal of adding a way of referencing ACPI nodes from DT source and this is my question: does this make any sense? It doesn't to me at first glance but we do sometimes describe firmware details in DT so I figured I'd ask you.
I am not aware of mixed ACPI+DT systems and it looks like that's the purpose. And PRP0001 still assumes you are having ACPI system...
https://docs.kernel.org/firmware-guide/acpi/enumeration.html#device-tree-namespace-link-device-id
In any case, we rarely discuss ABI via driver patch. Any discussions should come via patch proposing this ABI - either to kernel bindings or to dtschema.
Quoted 5 lines
It seems like Markus found a different solution in the end so it may not even be important anymore.
Bartosz
Best regards,
Krzysztof