x86, gpio: Increase ARCH_NR_GPIOs to 512
PATCH 1/2 x86, gpio: Increase ARCH_NR_GPIOs to 512
Some newer Intel SoCs like Braswell already have more than 256 GPIOs available so the default limit is exceeded. In order to support these add back the custom GPIO header with limit of 512 GPIOs for x86.
--- arch/x86/Kconfig | 1 + arch/x86/include/asm/gpio.h | 54 +++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 51 insertions(+), 4 deletions(-)
arch/x86/Kconfig +1 -0
@@ -136,6 +136,7 @@ config X86 select HAVE_ACPI_APEI if ACPI select HAVE_ACPI_APEI_NMI if ACPI select ACPI_LEGACY_TABLES_LOOKUP if ACPI + select ARCH_HAVE_CUSTOM_GPIO_H config INSTRUCTION_DECODER def_bool y
arch/x86/include/asm/gpio.h +50 -4
54 lines not on this page · raw message
Signature · 1 line
2.1.0
PATCH 2/2 gpio: Add support for Intel Cherryview/Braswell GPIO controller
From: Ning Li <[email protected]>
This driver supports the GPIO controllers found in newer Intel SoCs like Cherryview and Braswell.
--- drivers/gpio/Kconfig | 8 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-cherryview.c | 947 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 956 insertions(+) create mode 100644 drivers/gpio/gpio-cherryview.c
drivers/gpio/Kconfig +8 -0
@@ -736,6 +736,14 @@ config GPIO_INTEL_MID help Say Y here to support Intel Mid GPIO. +config GPIO_CHERRYVIEW + tristate "Intel CherryView/Braswell GPIO support" + depends on ACPI + select GPIOLIB_IRQCHIP + help + Enable support for GPIO host controllers found on Intel SoCs + such as CherryView and Braswell. + config GPIO_PCH tristate "Intel EG20T PCH/LAPIS Semiconductor IOH(ML7223/ML7831) GPIO" depends on PCI && (X86_32 || COMPILE_TEST)
drivers/gpio/Makefile +1 -0
@@ -20,6 +20,7 @@ obj-$(CONFIG_GPIO_AMD8111) += gpio-amd8111.o obj-$(CONFIG_GPIO_ARIZONA) += gpio-arizona.o obj-$(CONFIG_GPIO_BCM_KONA) += gpio-bcm-kona.o obj-$(CONFIG_GPIO_BT8XX) += gpio-bt8xx.o +obj-$(CONFIG_GPIO_CHERRYVIEW) += gpio-cherryview.o obj-$(CONFIG_GPIO_CLPS711X) += gpio-clps711x.o obj-$(CONFIG_GPIO_CS5535) += gpio-cs5535.o obj-$(CONFIG_GPIO_CRYSTAL_COVE) += gpio-crystalcove.o
drivers/gpio/gpio-cherryview.c new file +947 -0
947 lines not on this page · raw message
Signature · 1 line
2.1.0
Quoted 5 lines · Mika Westerberg
Some newer Intel SoCs like Braswell already have more than 256 GPIOs available so the default limit is exceeded. In order to support these add back the custom GPIO header with limit of 512 GPIOs for x86.
Signed-off-by Mika Westerberg <[email protected]>
Argh! This is the kind of stuff I want to get rid of ....
Preferably gpio should be a subsystem without a lot of hooks all over the place with arch-specific modifications for this and that, including the max number of GPIOs.
I would actually prefer if you bump the value ininclude/asm-generic/gpio.h to 512 over this.
But better still, now that we have descriptors etc would be to define some new per-arch selectable config option like CONFIG_ONLY_DYNAMIC_GPIO that changes the GPIO
core to use something like a radix tree to store and retrieve descriptors.
I.e. in drivers/gpio/gpiolib.c get rid of this:
static struct gpio_desc gpio_desc[ARCH_NR_GPIOS];
Replace it with a radix tree of descriptors.
This however makes it *impossible* to use things like desc_to_gpio() and/or gpio_to_desc() so the code has to be augmented all over the place to avoid any uses of GPIO numbers on that architecture, but I am sure it *can* be done on pure ACPI or device tree systems, and that's what we should aim for.
Comments?
Yours,
Linus Walleij
H. Peter Anvin
reviewerIsn't this exactly what ida is for?
Sent from my tablet, pardon any formatting problems.
Quoted 41 lines · Linus Walleij
Quoted 5 lines · Mika Westerberg
Some newer Intel SoCs like Braswell already have more than 256 GPIOs available so the default limit is exceeded. In order to support these add back the custom GPIO header with limit of 512 GPIOs for x86.
Signed-off-by Mika Westerberg <[email protected]>Argh! This is the kind of stuff I want to get rid of ....
Preferably gpio should be a subsystem without a lot of hooks all over the place with arch-specific modifications for this and that, including the max number of GPIOs.
I would actually prefer if you bump the value in
include/asm-generic/gpio.hto 512 over this.But better still, now that we have descriptors etc would be to define some new per-arch selectable config option like
CONFIG_ONLY_DYNAMIC_GPIOthat changes the GPIO
core to use something like a radix tree to store and retrieve descriptors.I.e. in
drivers/gpio/gpiolib.cget rid of this:
static structgpio_descgpio_desc[ARCH_NR_GPIOS];Replace it with a radix tree of descriptors.
This however makes it *impossible* to use things like
desc_to_gpio()and/orgpio_to_desc()so the code has to be augmented all over the place to avoid any uses of GPIO numbers on that architecture, but I am sure it *can* be done on pure ACPI or device tree systems, and that's what we should aim for.Comments?
Yours,
Linus Walleij
Quoted 9 lines · Linus Walleij
Quoted 5 lines · Mika Westerberg
Some newer Intel SoCs like Braswell already have more than 256 GPIOs available so the default limit is exceeded. In order to support these add back the custom GPIO header with limit of 512 GPIOs for x86.
Signed-off-by Mika Westerberg <[email protected]>
Quoted 8 lines
Argh! This is the kind of stuff I want to get rid of ....
Preferably gpio should be a subsystem without a lot of hooks all over the place with arch-specific modifications for this and that, including the max number of GPIOs.
I would actually prefer if you bump the value in
include/asm-generic/gpio.hto 512 over this.
OK, this makes sense and I can do the change for the next revision of the patch.
Quoted 11 lines
But better still, now that we have descriptors etc would be to define some new per-arch selectable config option like
CONFIG_ONLY_DYNAMIC_GPIOthat changes the GPIO
core to use something like a radix tree to store and retrieve descriptors.I.e. in
drivers/gpio/gpiolib.cget rid of this:
static structgpio_descgpio_desc[ARCH_NR_GPIOS];Replace it with a radix tree of descriptors.
Quoted 7 lines
This however makes it *impossible* to use things like
desc_to_gpio()and/orgpio_to_desc()so the code has to be augmented all over the place to avoid any uses of GPIO numbers on that architecture, but I am sure it *can* be done on pure ACPI or device tree systems, and that's what we should aim for.Comments?
That's a rather big rework to the GPIO subsystem and its users. I agree that it should be the goal eventually. For x86 such conversion is not that simple because we have systems out there that have neither ACPI nor DT available.
I should have responded to that thread long ago, but I am currently on holidays and strangely tend to check my mail less often than I should. :P
Quoted 18 lines · Linus Walleij
Argh! This is the kind of stuff I want to get rid of ....
Preferably gpio should be a subsystem without a lot of hooks all over the place with arch-specific modifications for this and that, including the max number of GPIOs.
I would actually prefer if you bump the value in
include/asm-generic/gpio.hto 512 over this.But better still, now that we have descriptors etc would be to define some new per-arch selectable config option like
CONFIG_ONLY_DYNAMIC_GPIOthat changes the GPIO
core to use something like a radix tree to store and retrieve descriptors.I.e. in
drivers/gpio/gpiolib.cget rid of this:
static structgpio_descgpio_desc[ARCH_NR_GPIOS];
Quoted 7 lines
Replace it with a radix tree of descriptors.
This however makes it *impossible* to use things like
desc_to_gpio()and/orgpio_to_desc()so the code has to be augmented all over the place to avoid any uses of GPIO numbers on that architecture, but I am sure it *can* be done on pure ACPI or device tree systems, and that's what we should aim for.
desc_to_gpio()/gpio_to_desc() could still work even if we remove the big array of GPIO descriptors. Actually that's what I intended to do when I first submitted the gpiod patches some time ago but it was rejected for performance reasons.
desc_to_gpio() actually doesn't even access this array - it does its job using the chip base and the beginning address of its descriptors array.
gpio_to_desc() would suffer a performance hit. What I initially proposed was to parse the linked list of GPIO chips and check if the requested number is in their assigned range. This is obviously slower than accessing an array, but if we consider that we generally don't have too many GPIO chips on a given hardware I don't think the hit would be that bad. It would also give some incentive for people to move to the gpiod interface.
I also have a patch in my queue that enables multiple users on the same GPIO descriptor (something requested since some time already). What happens with it is that descriptors ownership is fully transferred to the gpio_chip instances, and the static array becomes a array of double-pointers, making it considerable smaller and reducing the impact of increasing its size. Maybe I should submit that change just for this case?
Quoted 48 lines · Alexandre Courbot
I should have responded to that thread long ago, but I am currently on holidays and strangely tend to check my mail less often than I should. :P
Quoted 18 lines · Linus Walleij
Argh! This is the kind of stuff I want to get rid of ....
Preferably gpio should be a subsystem without a lot of hooks all over the place with arch-specific modifications for this and that, including the max number of GPIOs.
I would actually prefer if you bump the value in
include/asm-generic/gpio.hto 512 over this.But better still, now that we have descriptors etc would be to define some new per-arch selectable config option like
CONFIG_ONLY_DYNAMIC_GPIOthat changes the GPIO
core to use something like a radix tree to store and retrieve descriptors.I.e. in
drivers/gpio/gpiolib.cget rid of this:
static structgpio_descgpio_desc[ARCH_NR_GPIOS];Quoted 7 lines
Replace it with a radix tree of descriptors.
This however makes it *impossible* to use things like
desc_to_gpio()and/orgpio_to_desc()so the code has to be augmented all over the place to avoid any uses of GPIO numbers on that architecture, but I am sure it *can* be done on pure ACPI or device tree systems, and that's what we should aim for.desc_to_gpio()/gpio_to_desc() could still work even if we remove the big array of GPIO descriptors. Actually that's what I intended to do when I first submitted the gpiod patches some time ago but it was rejected for performance reasons.
desc_to_gpio()actually doesn't even access this array - it does its job using the chip base and the beginning address of its descriptors array.
gpio_to_desc()would suffer a performance hit. What I initially proposed was to parse the linked list of GPIO chips and check if the requested number is in their assigned range. This is obviously slower than accessing an array, but if we consider that we generally don't have too many GPIO chips on a given hardware I don't think the hit would be that bad. It would also give some incentive for people to move to the gpiod interface.
Quoted 1 line
From what I can tell based on x86 based systems, there is typically only
one GPIO controller in the PCH/SoC that controls all the pins. A good example is the Braswell/Cherryview controller.
So I agree with you that the performance hit would be negliglible.
Quoted 7 lines
I also have a patch in my queue that enables multiple users on the same GPIO descriptor (something requested since some time already). What happens with it is that descriptors ownership is fully transferred to the
gpio_chipinstances, and the static array becomes a array of double-pointers, making it considerable smaller and reducing the impact of increasing its size. Maybe I should submit that change just for this case?
Go for it :)
I can try to assist if any testing is needed.
Quoted 8 lines · Alexandre Courbot
Quoted 5 lines · Linus Walleij
This however makes it *impossible* to use things like
desc_to_gpio()and/orgpio_to_desc()so the code has to be augmented all over the place to avoid any uses of GPIO numbers on that architecture, but I am sure it *can* be done on pure ACPI or device tree systems, and that's what we should aim for.
Quoted 4 lines
desc_to_gpio()/gpio_to_desc() could still work even if we remove the big array of GPIO descriptors. Actually that's what I intended to do when I first submitted the gpiod patches some time ago but it was rejected for performance reasons.
OK. I'm ready to revisit the subject.
Quoted 3 lines
desc_to_gpio()actually doesn't even access this array - it does its job using the chip base and the beginning address of its descriptors array.
Right.
Quoted 7 lines
gpio_to_desc()would suffer a performance hit. What I initially proposed was to parse the linked list of GPIO chips and check if the requested number is in their assigned range. This is obviously slower than accessing an array, but if we consider that we generally don't have too many GPIO chips on a given hardware I don't think the hit would be that bad. It would also give some incentive for people to move to the gpiod interface.
I think the performance hit is acceptable, because this should not be on a hot path anyway. I would say go ahead with this refactoring.
Quoted 7 lines
I also have a patch in my queue that enables multiple users on the same GPIO descriptor (something requested since some time already). What happens with it is that descriptors ownership is fully transferred to the
gpio_chipinstances, and the static array becomes a array of double-pointers, making it considerable smaller and reducing the impact of increasing its size. Maybe I should submit that change just for this case?
Ummmmm I think that is an orthogonal thing, but honestly I'm not following the double-pointers thing, so I guess I need to see the patch.
Yours,
Linus Walleij
Quoted 30 lines · Linus Walleij
Quoted 8 lines · Alexandre Courbot
Quoted 5 lines · Linus Walleij
This however makes it *impossible* to use things like
desc_to_gpio()and/orgpio_to_desc()so the code has to be augmented all over the place to avoid any uses of GPIO numbers on that architecture, but I am sure it *can* be done on pure ACPI or device tree systems, and that's what we should aim for.Quoted 4 lines
desc_to_gpio()/gpio_to_desc() could still work even if we remove the big array of GPIO descriptors. Actually that's what I intended to do when I first submitted the gpiod patches some time ago but it was rejected for performance reasons.
OK. I'm ready to revisit the subject.
Quoted 3 lines
desc_to_gpio()actually doesn't even access this array - it does its job using the chip base and the beginning address of its descriptors array.Right.
Quoted 7 lines
gpio_to_desc()would suffer a performance hit. What I initially proposed was to parse the linked list of GPIO chips and check if the requested number is in their assigned range. This is obviously slower than accessing an array, but if we consider that we generally don't have too many GPIO chips on a given hardware I don't think the hit would be that bad. It would also give some incentive for people to move to the gpiod interface.
Quoted 2 lines
I think the performance hit is acceptable, because this should not be on a hot path anyway. I would say go ahead with this refactoring.
Great! I will come with something once my holidays are over. It should not be a complex change.
Quoted 9 lines
Quoted 8 lines
I also have a patch in my queue that enables multiple users on the same GPIO descriptor (something requested since some time already). What happens with it is that descriptors ownership is fully transferred to the
gpio_chipinstances, and the static array becomes a array of double-pointers, making it considerable smaller and reducing the impact of increasing its size. Maybe I should submit that change just for this case?
Quoted 3 lines
Ummmmm I think that is an orthogonal thing, but honestly I'm not following the double-pointers thing, so I guess I need to see the patch.
Yes, this is completely orthogonal, and actually this won't be needed if we decide to get rid of that array.