pinctrl: meson: Fix gpio-ranged for GPIO Hog
Subsystems (4)
cover pinctrl: meson: Fix gpio-ranged for GPIO Hog
Whem trying to add a gpio hog to enable the USB Hub on the Odroid-C2, I encountered a strange bug where when calling gpiochip_add_data() the gpiolib code was trying to add the Hog but failed because the gpio ranges were missing.
In the meson-pinctrl driver, the gpio ranges are added manually /after/ the call to gpiochip_add_data().
The arch/arm meson8 and meson8b patches has not been tested, this is why this patchset is an RFT.
So this patchset uses the DT gpio-ranges attribute instead and solves the issue.
The final patch is the actual GPIO Hog for the Odroid-C2 board, which is an ugly hack but is necessary to have USB Ports working on the board until the generic power sequence framework is merged.
Neil Armstrong (6):
ARM64: dts: meson-gxbb: Add gpio-ranges properties
ARM64: dts: meson-gxl: Add gpio-ranges properties
ARM: dts: meson8: Add gpio-ranges properties
ARM: dts: meson8b: Add gpio-ranges properties
pinctrl: meson: use gpio-ranges from DT
ARM64: dts: meson-gxbb: Add USB Hub GPIO hog
arch/arm/boot/dts/meson8.dtsi | 2 ++ arch/arm/boot/dts/meson8b.dtsi | 2 ++ arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts | 15 +++++++++++++++ arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi | 2 ++ arch/arm64/boot/dts/amlogic/meson-gxl.dtsi | 2 ++ drivers/pinctrl/meson/pinctrl-meson.c | 14 +------------- 6 files changed, 24 insertions(+), 13 deletions(-)
Signature · 1 line
1.9.1
PATCH 1/6 ARM64: dts: meson-gxbb: Add gpio-ranges properties
--- arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi +2 -0
@@ -129,6 +129,7 @@ reg-names = "mux", "pull", "gpio"; gpio-controller; #gpio-cells = <2>; + gpio-ranges = <&pinctrl_aobus 0 0 14>; }; uart_ao_a_pins: uart_ao_a {
@@ -245,6 +246,7 @@ reg-names = "mux", "pull", "pull-enable", "gpio"; gpio-controller; #gpio-cells = <2>; + gpio-ranges = <&pinctrl_periphs 0 14 120>; }; emmc_pins: emmc {
Signature · 1 line
1.9.1
Re: [RFT PATCH 1/6] ARM64: dts: meson-gxbb: Add gpio-ranges properties
Quoted 1 line · Neil Armstrong
Signed-off-by Neil Armstrong <[email protected]>
Yours,
Linus Walleij
PATCH 2/6 ARM64: dts: meson-gxl: Add gpio-ranges properties
In reply to Neil Armstrong--- arch/arm64/boot/dts/amlogic/meson-gxl.dtsi | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/boot/dts/amlogic/meson-gxl.dtsi +2 -0
@@ -79,6 +79,7 @@ reg-names = "mux", "pull", "gpio"; gpio-controller; #gpio-cells = <2>; + gpio-ranges = <&pinctrl_aobus 0 0 14>; }; uart_ao_a_pins: uart_ao_a {
@@ -142,6 +143,7 @@ reg-names = "mux", "pull", "pull-enable", "gpio"; gpio-controller; #gpio-cells = <2>; + gpio-ranges = <&pinctrl_periphs 0 14 101>; }; emmc_pins: emmc {
Signature · 1 line
1.9.1
Re: [RFT PATCH 2/6] ARM64: dts: meson-gxl: Add gpio-ranges properties
Quoted 1 line · Neil Armstrong
Signed-off-by Neil Armstrong <[email protected]>
Yours,
Linus Walleij
PATCH 3/6 ARM: dts: meson8: Add gpio-ranges properties
In reply to Neil Armstrong--- arch/arm/boot/dts/meson8.dtsi | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/boot/dts/meson8.dtsi +2 -0
@@ -106,6 +106,7 @@ reg-names = "mux", "pull", "pull-enable", "gpio"; gpio-controller; #gpio-cells = <2>; + gpio-ranges = <&pinctrl_cbus 0 0 120>; }; spi_nor_pins: nor {
@@ -148,6 +149,7 @@ reg-names = "mux", "pull", "gpio"; gpio-controller; #gpio-cells = <2>; + gpio-ranges = <&pinctrl_aobus 0 120 16>; }; uart_ao_a_pins: uart_ao_a {
Signature · 1 line
1.9.1
Re: [RFT PATCH 3/6] ARM: dts: meson8: Add gpio-ranges properties
Quoted 1 line · Neil Armstrong
Signed-off-by Neil Armstrong <[email protected]>
Yours,
Linus Walleij
PATCH 4/6 ARM: dts: meson8b: Add gpio-ranges properties
In reply to Neil Armstrong--- arch/arm/boot/dts/meson8b.dtsi | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/boot/dts/meson8b.dtsi +2 -0
@@ -198,6 +198,7 @@ reg-names = "mux", "pull", "pull-enable", "gpio"; gpio-controller; #gpio-cells = <2>; + gpio-ranges = <&pinctrl_cbus 0 0 130>; }; };
@@ -215,6 +216,7 @@ reg-names = "mux", "pull", "gpio"; gpio-controller; #gpio-cells = <2>; + gpio-ranges = <&pinctrl_aobus 0 130 16>; }; uart_ao_a_pins: uart_ao_a {
Signature · 1 line
1.9.1
Re: [RFT PATCH 4/6] ARM: dts: meson8b: Add gpio-ranges properties
Quoted 1 line · Neil Armstrong
Signed-off-by Neil Armstrong <[email protected]>
Yours,
Linus Walleij
PATCH 5/6 pinctrl: meson: use gpio-ranges from DT
In reply to Neil ArmstrongWhen trying to add a gpio-hog, we enter a weird loop where the gpio-ranges is needed when gpiochip_add_data() is called but in the current implementation the ranges are added from the driver afterwards.
A simple solution is to rely on the DR gpio-ranges attribute and remove the call to gpiochip_add_pin_range().
--- drivers/pinctrl/meson/pinctrl-meson.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-)
drivers/pinctrl/meson/pinctrl-meson.c +1 -13
@@ -555,22 +555,10 @@ static int meson_gpiolib_register(struct meson_pinctrl *pc)if (ret) {dev_err (pc->dev,"can't add gpio chip %s\n" , pc->data->name); - goto fail; - } - - ret =gpiochip_add_pin_range (&pc->chip,dev_name (pc->dev), -0 , pc->data->pin_base, - pc->chip.ngpio); -if (ret) { -dev_err (pc->dev,"can't add pin range\n" ); - goto fail; +return ret; }return 0 ; -fail: -gpiochip_remove (&pc->chip); - -return ret; }static struct regmap_config meson_regmap_config = {
Signature · 1 line
1.9.1
Martin Blumenstingl
reviewerRe: [RFT PATCH 5/6] pinctrl: meson: use gpio-ranges from DT
Hi Neil,
Quoted 6 lines · Neil Armstrong
When trying to add a gpio-hog, we enter a weird loop where the gpio-ranges is needed when
gpiochip_add_data()is called but in the current implementation the ranges are added from the driver afterwards.A simple solution is to rely on the DR gpio-ranges attribute and remove the call to
gpiochip_add_pin_range().
did you mean devicetree or DT instead of "DR"?
Regards,
Martin
Re: [RFT PATCH 5/6] pinctrl: meson: use gpio-ranges from DT
Quoted 7 lines · Martin Blumenstingl
Hi Neil,
Quoted 4 lines · Neil Armstrong
When trying to add a gpio-hog, we enter a weird loop where the gpio-ranges is needed when
gpiochip_add_data()is called but in the current implementation the ranges are added from the driver afterwards.
Quoted 8 lines
Quoted 2 lines
A simple solution is to rely on the DR gpio-ranges attribute and remove the call to
gpiochip_add_pin_range().did you mean devicetree or DT instead of "DR"?
Regards,
Martin
Indeed, sorry for the typo.
Neil
Re: [RFT PATCH 5/6] pinctrl: meson: use gpio-ranges from DT
In reply to Neil ArmstrongOn Thu, Mar 23, 2017 at 5:27 PM, Neil Armstrong <[email protected]> wrote:
'> When trying to add a gpio-hog, we enter a weird loop where the gpio-ranges
Quoted 7 lines
is needed when
gpiochip_add_data()is called but in the current implementation the ranges are added from the driver afterwards.A simple solution is to rely on the DR gpio-ranges attribute and remove the call to
gpiochip_add_pin_range().Signed-off-by Neil Armstrong <[email protected]>
This is fine once the ranges have been applied to the device trees I guess.
Tell me when you want me to merge this.
Yours,
Linus Walleij
Re: [RFT PATCH 5/6] pinctrl: meson: use gpio-ranges from DT
Quoted 9 lines · Linus Walleij
On Thu, Mar 23, 2017 at 5:27 PM, Neil Armstrong <[email protected]> wrote:
'> When trying to add a gpio-hog, we enter a weird loop where the gpio-ranges
Quoted 6 lines
is needed when
gpiochip_add_data()is called but in the current implementation the ranges are added from the driver afterwards.A simple solution is to rely on the DR gpio-ranges attribute and remove the call to
gpiochip_add_pin_range().
Quoted 9 lines
Quoted 1 line
Signed-off-by Neil Armstrong <[email protected]>This is fine once the ranges have been applied to the device trees I guess.
Tell me when you want me to merge this.
Yours,
Linus Walleij
Hi Linus,
Kevin should merge the DT patches since they have now Tested and Reviewed by's, so you can merge it now if you can. Since it will live in you pinctrl tree, it will only impact linux-next until Kevin merges them.
Thanks,
Neil
Kevin Hilman
maintainerRe: [RFT PATCH 5/6] pinctrl: meson: use gpio-ranges from DT
Quoted 16 lines · Neil Armstrong
Quoted 15 lines · Linus Walleij
On Thu, Mar 23, 2017 at 5:27 PM, Neil Armstrong <[email protected]> wrote:
'> When trying to add a gpio-hog, we enter a weird loop where the gpio-ranges
Quoted 7 lines
is needed when
gpiochip_add_data()is called but in the current implementation the ranges are added from the driver afterwards.A simple solution is to rely on the DR gpio-ranges attribute and remove the call to
gpiochip_add_pin_range().Signed-off-by Neil Armstrong <[email protected]>This is fine once the ranges have been applied to the device trees I guess.
Tell me when you want me to merge this.
Quoted 8 lines
Quoted 3 lines
Yours,
Linus WalleijHi Linus,
Kevin should merge the DT patches since they have now Tested and Reviewed by's, so you can merge it now if you can. Since it will live in you pinctrl tree, it will only impact linux-next until Kevin merges them.
I've applied the DT patches now (branch: v4.12/dt64)
Kevin
Re: [RFT PATCH 5/6] pinctrl: meson: use gpio-ranges from DT
In reply to Neil ArmstrongQuoted 8 lines · Neil Armstrong
When trying to add a gpio-hog, we enter a weird loop where the gpio-ranges is needed when
gpiochip_add_data()is called but in the current implementation the ranges are added from the driver afterwards.A simple solution is to rely on the DR gpio-ranges attribute and remove the call to
gpiochip_add_pin_range().Signed-off-by Neil Armstrong <[email protected]>
Patch applied.
Yours,
Linus Walleij
PATCH 6/6 ARM64: dts: meson-gxbb: Add USB Hub GPIO hog
In reply to Neil ArmstrongThe ODroid-C2 on-board USB Hub needs to to have it's reset signal set to high level in order to be enumerated by the USB Host Controller.
But this management must be part of the currently in-development Generic Power Sequence patch that will allow a USB Controller driver to start and stop a power sequence associated to the USB Bus.
In the meantime, a simple USB Hog will work to enable the USB Hub.
--- arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts +15 -0
@@ -177,6 +177,21 @@ pinctrl-names = "default"; }; +&gpio_ao { + /* + * WARNING: The USB Hub on the Odroid-C2 needs a reset signal + * to be turned high in order to be detected by the USB Controller + * This signal should be handled by a USB specific power sequence + * in order to reset the Hub when USB bus is powered down. + */ + usb-hub { + gpio-hog; + gpios = <GPIOAO_4 GPIO_ACTIVE_HIGH>; + output-high; + line-name = "usb-hub-reset"; + }; +}; + &usb0_phy { status = "okay"; phy-supply = <&usb_otg_pwr>;
Signature · 1 line
1.9.1
Re: [RFT PATCH 6/6] ARM64: dts: meson-gxbb: Add USB Hub GPIO hog
Quoted 10 lines · Neil Armstrong
The ODroid-C2 on-board USB Hub needs to to have it's reset signal set to high level in order to be enumerated by the USB Host Controller.
But this management must be part of the currently in-development Generic Power Sequence patch that will allow a USB Controller driver to start and stop a power sequence associated to the USB Bus.
In the meantime, a simple USB Hog will work to enable the USB Hub.
Signed-off-by Neil Armstrong <[email protected]>
Yours,
Linus Walleij
Quoted 15 lines · Neil Armstrong
Whem trying to add a gpio hog to enable the USB Hub on the Odroid-C2, I encountered a strange bug where when calling
gpiochip_add_data()the gpiolib code was trying to add the Hog but failed because the gpio ranges were missing.In the meson-pinctrl driver, the gpio ranges are added manually /after/ the call to
gpiochip_add_data().
Thearch/armmeson8 and meson8b patches has not been tested, this is why this patchset is an RFT.So this patchset uses the DT gpio-ranges attribute instead and solves the issue.
The final patch is the actual GPIO Hog for the Odroid-C2 board, which is an ugly hack but is necessary to have USB Ports working on the board until the generic power sequence framework is merged.
Quoted 7 lines
Neil Armstrong (6):
ARM64: dts: meson-gxbb: Add gpio-ranges properties
ARM64: dts: meson-gxl: Add gpio-ranges properties
ARM: dts: meson8: Add gpio-ranges properties
ARM: dts: meson8b: Add gpio-ranges properties
pinctrl: meson: use gpio-ranges from DT
ARM64: dts: meson-gxbb: Add USB Hub GPIO hog
Not sure what kind of extra testing is needed on meson8*, but I tested on meson8b-odroidc1 by replacing the heartbeat LED GPIO with a GPIO hog[1] and see the LED turn on and stay on, so it seems good to me.
Kevin
[1]
arch/arm/boot/dts/meson8b-odroidc1.dts +9 -0
@@ -60,6 +60,7 @@ reg = <0x40000000 0x40000000>; }; +/* leds { compatible = "gpio-leds"; blue {
@@ -69,10 +70,18 @@ default-state = "off"; }; }; +*/ }; &uart_AO { status = "okay"; pinctrl-0 = <&uart_ao_a_pins>; pinctrl-names = "default"; + + usb-hub { + gpio-hog; + gpios = <GPIOAO_13 GPIO_ACTIVE_HIGH>; + output-high; + line-name = "usb-hub-reset"; + }; };