From 534ab91fcf63d7c2a359ef0f8d605bacfc4df79b Mon Sep 17 00:00:00 2001 From: Peter Robinson Date: Mon, 20 Apr 2020 11:48:23 +0100 Subject: Rockchips fixes --- arm64-Fix-some-GPIO-setup-on-Pinebook-Pro.patch | 50 +++++++ configs/fedora/generic/arm/CONFIG_ROCKCHIP_CDN_DP | 2 +- kernel-aarch64-debug-fedora.config | 2 +- kernel-aarch64-fedora.config | 2 +- kernel-armv7hl-debug-fedora.config | 2 +- kernel-armv7hl-fedora.config | 2 +- kernel-armv7hl-lpae-debug-fedora.config | 2 +- kernel-armv7hl-lpae-fedora.config | 2 +- kernel.spec | 4 + usb-fusb302-Convert-to-use-GPIO-descriptors.patch | 155 ++++++++++++++++++++++ 10 files changed, 216 insertions(+), 7 deletions(-) create mode 100644 arm64-Fix-some-GPIO-setup-on-Pinebook-Pro.patch create mode 100644 usb-fusb302-Convert-to-use-GPIO-descriptors.patch diff --git a/arm64-Fix-some-GPIO-setup-on-Pinebook-Pro.patch b/arm64-Fix-some-GPIO-setup-on-Pinebook-Pro.patch new file mode 100644 index 000000000..7bfd204b5 --- /dev/null +++ b/arm64-Fix-some-GPIO-setup-on-Pinebook-Pro.patch @@ -0,0 +1,50 @@ +From c45fbddb2cd7ce6198e33ebe6dc4c1301d7875d4 Mon Sep 17 00:00:00 2001 +From: Peter Robinson +Date: Sun, 19 Apr 2020 20:50:08 +0100 +Subject: [PATCH] Fix some GPIO setup on Pinebook Pro + +This patchset contains two small fixes for the dts of the Pinebook Pro. +The first fixes inverted logic on the headphone detect GPIO. +The second patch fixes unreliable DC charger detection. + +Tobias Schramm (2): + arm64: dts: rockchip: fix inverted headphone detection + arm64: dts: rockchip: enable DC charger detection pullup + +Signed-off-by: Peter Robinson +--- + arch/arm64/boot/dts/rockchip/rk3399-pinebook-pro.dts | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/arch/arm64/boot/dts/rockchip/rk3399-pinebook-pro.dts b/arch/arm64/boot/dts/rockchip/rk3399-pinebook-pro.dts +index 5ea281b55fe2..294d21bf45f5 100644 +--- a/arch/arm64/boot/dts/rockchip/rk3399-pinebook-pro.dts ++++ b/arch/arm64/boot/dts/rockchip/rk3399-pinebook-pro.dts +@@ -147,7 +147,7 @@ es8316-sound { + "Speaker", "Speaker Amplifier OUTL", + "Speaker", "Speaker Amplifier OUTR"; + +- simple-audio-card,hp-det-gpio = <&gpio0 RK_PB0 GPIO_ACTIVE_LOW>; ++ simple-audio-card,hp-det-gpio = <&gpio0 RK_PB0 GPIO_ACTIVE_HIGH>; + simple-audio-card,aux-devs = <&speaker_amp>; + simple-audio-card,pin-switches = "Speaker"; + +@@ -788,13 +788,13 @@ lidbtn_gpio: lidbtn-gpio { + + dc-charger { + dc_det_gpio: dc-det-gpio { +- rockchip,pins = <4 RK_PD0 RK_FUNC_GPIO &pcfg_pull_none>; ++ rockchip,pins = <4 RK_PD0 RK_FUNC_GPIO &pcfg_pull_up>; + }; + }; + + es8316 { + hp_det_gpio: hp-det-gpio { +- rockchip,pins = <0 RK_PB0 RK_FUNC_GPIO &pcfg_pull_down>; ++ rockchip,pins = <0 RK_PB0 RK_FUNC_GPIO &pcfg_pull_up>; + }; + }; + +-- +2.26.1 + diff --git a/configs/fedora/generic/arm/CONFIG_ROCKCHIP_CDN_DP b/configs/fedora/generic/arm/CONFIG_ROCKCHIP_CDN_DP index 86d2137bd..98a696d76 100644 --- a/configs/fedora/generic/arm/CONFIG_ROCKCHIP_CDN_DP +++ b/configs/fedora/generic/arm/CONFIG_ROCKCHIP_CDN_DP @@ -1 +1 @@ -CONFIG_ROCKCHIP_CDN_DP=y +# CONFIG_ROCKCHIP_CDN_DP is not set diff --git a/kernel-aarch64-debug-fedora.config b/kernel-aarch64-debug-fedora.config index 77b4f910a..0a2eab1f2 100644 --- a/kernel-aarch64-debug-fedora.config +++ b/kernel-aarch64-debug-fedora.config @@ -5148,7 +5148,7 @@ CONFIG_RMI4_SMB=m CONFIG_RMI4_SPI=m # CONFIG_RMNET is not set CONFIG_ROCKCHIP_ANALOGIX_DP=y -CONFIG_ROCKCHIP_CDN_DP=y +# CONFIG_ROCKCHIP_CDN_DP is not set CONFIG_ROCKCHIP_DW_HDMI=y CONFIG_ROCKCHIP_DW_MIPI_DSI=y CONFIG_ROCKCHIP_EFUSE=m diff --git a/kernel-aarch64-fedora.config b/kernel-aarch64-fedora.config index 81f59f036..7532f0f4b 100644 --- a/kernel-aarch64-fedora.config +++ b/kernel-aarch64-fedora.config @@ -5127,7 +5127,7 @@ CONFIG_RMI4_SMB=m CONFIG_RMI4_SPI=m # CONFIG_RMNET is not set CONFIG_ROCKCHIP_ANALOGIX_DP=y -CONFIG_ROCKCHIP_CDN_DP=y +# CONFIG_ROCKCHIP_CDN_DP is not set CONFIG_ROCKCHIP_DW_HDMI=y CONFIG_ROCKCHIP_DW_MIPI_DSI=y CONFIG_ROCKCHIP_EFUSE=m diff --git a/kernel-armv7hl-debug-fedora.config b/kernel-armv7hl-debug-fedora.config index c3994369d..908fe1217 100644 --- a/kernel-armv7hl-debug-fedora.config +++ b/kernel-armv7hl-debug-fedora.config @@ -5247,7 +5247,7 @@ CONFIG_RMI4_SMB=m CONFIG_RMI4_SPI=m # CONFIG_RMNET is not set CONFIG_ROCKCHIP_ANALOGIX_DP=y -CONFIG_ROCKCHIP_CDN_DP=y +# CONFIG_ROCKCHIP_CDN_DP is not set CONFIG_ROCKCHIP_DW_HDMI=y CONFIG_ROCKCHIP_DW_MIPI_DSI=y CONFIG_ROCKCHIP_EFUSE=m diff --git a/kernel-armv7hl-fedora.config b/kernel-armv7hl-fedora.config index ccc05f00a..c56bd894e 100644 --- a/kernel-armv7hl-fedora.config +++ b/kernel-armv7hl-fedora.config @@ -5227,7 +5227,7 @@ CONFIG_RMI4_SMB=m CONFIG_RMI4_SPI=m # CONFIG_RMNET is not set CONFIG_ROCKCHIP_ANALOGIX_DP=y -CONFIG_ROCKCHIP_CDN_DP=y +# CONFIG_ROCKCHIP_CDN_DP is not set CONFIG_ROCKCHIP_DW_HDMI=y CONFIG_ROCKCHIP_DW_MIPI_DSI=y CONFIG_ROCKCHIP_EFUSE=m diff --git a/kernel-armv7hl-lpae-debug-fedora.config b/kernel-armv7hl-lpae-debug-fedora.config index 1dd79f5fa..bb077007b 100644 --- a/kernel-armv7hl-lpae-debug-fedora.config +++ b/kernel-armv7hl-lpae-debug-fedora.config @@ -5074,7 +5074,7 @@ CONFIG_RMI4_SMB=m CONFIG_RMI4_SPI=m # CONFIG_RMNET is not set CONFIG_ROCKCHIP_ANALOGIX_DP=y -CONFIG_ROCKCHIP_CDN_DP=y +# CONFIG_ROCKCHIP_CDN_DP is not set CONFIG_ROCKCHIP_DW_HDMI=y CONFIG_ROCKCHIP_DW_MIPI_DSI=y CONFIG_ROCKCHIP_EFUSE=m diff --git a/kernel-armv7hl-lpae-fedora.config b/kernel-armv7hl-lpae-fedora.config index ad95f951f..d06900a42 100644 --- a/kernel-armv7hl-lpae-fedora.config +++ b/kernel-armv7hl-lpae-fedora.config @@ -5054,7 +5054,7 @@ CONFIG_RMI4_SMB=m CONFIG_RMI4_SPI=m # CONFIG_RMNET is not set CONFIG_ROCKCHIP_ANALOGIX_DP=y -CONFIG_ROCKCHIP_CDN_DP=y +# CONFIG_ROCKCHIP_CDN_DP is not set CONFIG_ROCKCHIP_DW_HDMI=y CONFIG_ROCKCHIP_DW_MIPI_DSI=y CONFIG_ROCKCHIP_EFUSE=m diff --git a/kernel.spec b/kernel.spec index a2224af2a..6be5edf28 100644 --- a/kernel.spec +++ b/kernel.spec @@ -868,6 +868,10 @@ Patch344: arm64-pine64-pinetab.patch Patch345: arm64-pine64-pinephone.patch # https://patchwork.kernel.org/cover/11440399/ Patch346: Add-support-for-PinePhone-LCD-panel.patch +# https://www.spinics.net/lists/devicetree/msg346446.html +Patch347: arm64-Fix-some-GPIO-setup-on-Pinebook-Pro.patch +# https://www.spinics.net/lists/devicetree/msg347052.html +Patch348: usb-fusb302-Convert-to-use-GPIO-descriptors.patch # 400 - IBM (ppc/s390x) patches diff --git a/usb-fusb302-Convert-to-use-GPIO-descriptors.patch b/usb-fusb302-Convert-to-use-GPIO-descriptors.patch new file mode 100644 index 000000000..8ba00ea69 --- /dev/null +++ b/usb-fusb302-Convert-to-use-GPIO-descriptors.patch @@ -0,0 +1,155 @@ +From 619bb30cc0fe1754f8dfa0fa4ea94fd937857fbd Mon Sep 17 00:00:00 2001 +From: Linus Walleij +Date: Mon, 20 Apr 2020 09:55:38 +0100 +Subject: [PATCH] usb: fusb302: Convert to use GPIO descriptors + +This converts the FUSB302 driver to use GPIO descriptors. +The conversion to descriptors per se is pretty straight-forward. + +In the process I discovered that: + +1. The driver uses a completely undocumented device tree binding + for the interrupt GPIO line, "fcs,int_n". Ooops. + +2. The undocumented binding, presumably since it has not seen + review, is just "fcs,int_n", lacking the compulsory "-gpios" + suffix and also something that is not a good name because + the "_n" implies the line is inverted which is something we + handle with flags in the device tree. Ooops. + +3. Possibly the driver should not be requesting the line as a + GPIO and request the corresponding interrupt line by open + coding, the GPIO chip is very likely doubleing as an IRQ + controller and can probably provide an interrupt directly + for this line with interrupts-extended = <&gpio0 ...>; + +4. Possibly the IRQ should just be tagged on the I2C client node + in the device tree like apparently ACPI does, as it overrides + this IRQ with client->irq if that exists. + +But now it is too late to do much about that and as I can see +this is used like this in the Pinebook which is a shipping product +so let'a just contain the mess and move on. + +The property currently appears in: +arch/arm64/boot/dts/rockchip/rk3399-pinebook-pro.dts + +Create a quirk in the GPIO OF library to allow this property +specifically to be specified without the "-gpios" suffix, we have +other such bindings already. + +Signed-off-by: Linus Walleij +--- + drivers/gpio/gpiolib-of.c | 21 +++++++++++++++++++++ + drivers/usb/typec/tcpm/fusb302.c | 32 +++++++++----------------------- + 2 files changed, 30 insertions(+), 23 deletions(-) + +diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c +index ccc449df3792..20c2c428168e 100644 +--- a/drivers/gpio/gpiolib-of.c ++++ b/drivers/gpio/gpiolib-of.c +@@ -460,6 +460,24 @@ static struct gpio_desc *of_find_arizona_gpio(struct device *dev, + return of_get_named_gpiod_flags(dev->of_node, con_id, 0, of_flags); + } + ++static struct gpio_desc *of_find_usb_gpio(struct device *dev, ++ const char *con_id, ++ enum of_gpio_flags *of_flags) ++{ ++ /* ++ * Currently this USB quirk is only for the Fairchild FUSB302 host which is using ++ * an undocumented DT GPIO line named "fcs,int_n" without the compulsory "-gpios" ++ * suffix. ++ */ ++ if (!IS_ENABLED(CONFIG_TYPEC_FUSB302)) ++ return ERR_PTR(-ENOENT); ++ ++ if (!con_id || strcmp(con_id, "fcs,int_n")) ++ return ERR_PTR(-ENOENT); ++ ++ return of_get_named_gpiod_flags(dev->of_node, con_id, 0, of_flags); ++} ++ + struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id, + unsigned int idx, unsigned long *flags) + { +@@ -504,6 +522,9 @@ struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id, + if (PTR_ERR(desc) == -ENOENT) + desc = of_find_arizona_gpio(dev, con_id, &of_flags); + ++ if (PTR_ERR(desc) == -ENOENT) ++ desc = of_find_usb_gpio(dev, con_id, &of_flags); ++ + if (IS_ERR(desc)) + return desc; + +diff --git a/drivers/usb/typec/tcpm/fusb302.c b/drivers/usb/typec/tcpm/fusb302.c +index b498960ff72b..b28facece43c 100644 +--- a/drivers/usb/typec/tcpm/fusb302.c ++++ b/drivers/usb/typec/tcpm/fusb302.c +@@ -9,14 +9,13 @@ + #include + #include + #include +-#include ++#include + #include + #include + #include + #include + #include + #include +-#include + #include + #include + #include +@@ -83,7 +82,7 @@ struct fusb302_chip { + struct work_struct irq_work; + bool irq_suspended; + bool irq_while_suspended; +- int gpio_int_n; ++ struct gpio_desc *gpio_int_n; + int gpio_int_n_irq; + struct extcon_dev *extcon; + +@@ -1618,30 +1617,17 @@ static void fusb302_irq_work(struct work_struct *work) + + static int init_gpio(struct fusb302_chip *chip) + { +- struct device_node *node; ++ struct device *dev = chip->dev; + int ret = 0; + +- node = chip->dev->of_node; +- chip->gpio_int_n = of_get_named_gpio(node, "fcs,int_n", 0); +- if (!gpio_is_valid(chip->gpio_int_n)) { +- ret = chip->gpio_int_n; +- dev_err(chip->dev, "cannot get named GPIO Int_N, ret=%d", ret); +- return ret; +- } +- ret = devm_gpio_request(chip->dev, chip->gpio_int_n, "fcs,int_n"); +- if (ret < 0) { +- dev_err(chip->dev, "cannot request GPIO Int_N, ret=%d", ret); +- return ret; +- } +- ret = gpio_direction_input(chip->gpio_int_n); +- if (ret < 0) { +- dev_err(chip->dev, +- "cannot set GPIO Int_N to input, ret=%d", ret); +- return ret; ++ chip->gpio_int_n = devm_gpiod_get(dev, "fcs,int_n", GPIOD_IN); ++ if (IS_ERR(chip->gpio_int_n)) { ++ dev_err(dev, "failed to request gpio_int_n\n"); ++ return PTR_ERR(chip->gpio_int_n); + } +- ret = gpio_to_irq(chip->gpio_int_n); ++ ret = gpiod_to_irq(chip->gpio_int_n); + if (ret < 0) { +- dev_err(chip->dev, ++ dev_err(dev, + "cannot request IRQ for GPIO Int_N, ret=%d", ret); + return ret; + } +-- +2.26.1 + -- cgit