diff --git a/Documentation/devicetree/bindings/pinctrl/starfive,jh7110-sys-pinctrl.yaml b/Documentation/devicetree/bindings/pinctrl/starfive,jh7110-sys-pinctrl.yaml index 222b9e240f8af9..d793290afdd742 100644 --- a/Documentation/devicetree/bindings/pinctrl/starfive,jh7110-sys-pinctrl.yaml +++ b/Documentation/devicetree/bindings/pinctrl/starfive,jh7110-sys-pinctrl.yaml @@ -46,6 +46,16 @@ properties: '#gpio-cells': const: 2 + starfive,force-low-inputs: + description: + The list of input signals forced to be low inside the SoC itself. + $ref: /schemas/types.yaml#/definitions/uint32-array + + starfive,force-high-inputs: + description: + The list of input signals forced to be high inside the SoC itself. + $ref: /schemas/types.yaml#/definitions/uint32-array + patternProperties: '-[0-9]+$': type: object diff --git a/arch/riscv/boot/dts/starfive/jh7110-pine64-star64.dts b/arch/riscv/boot/dts/starfive/jh7110-pine64-star64.dts index 31e825be2065af..dab0e0054e6488 100644 --- a/arch/riscv/boot/dts/starfive/jh7110-pine64-star64.dts +++ b/arch/riscv/boot/dts/starfive/jh7110-pine64-star64.dts @@ -81,6 +81,8 @@ }; &sysgpio { + starfive,force-high-inputs = ; + usb0_pins: usb0-0 { vbus-pins { pinmux = dev; + const struct jh7110_pinctrl_soc_info *info = sfp->info; + + nforce = of_property_count_u32_elems(dev->of_node, property); + + if (nforce > 0) { + for (i = 0; i < nforce; i++) { + ret = of_property_read_u32_index(dev->of_node, property, + i, &pin); + if (ret) + return ret; + + offset = 4 * (pin / 4); + shift = 8 * (pin % 4); + + val = readl_relaxed(sfp->base + + info->gpi_reg_base + offset); + val &= info->gpi_mask << shift; + val |= (forced_input & info->gpi_mask) << shift; + + writel_relaxed(val, sfp->base + + info->gpi_reg_base + offset); + } + } + + return 0; +} + int jh7110_pinctrl_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -964,6 +999,14 @@ int jh7110_pinctrl_probe(struct platform_device *pdev) dev_info(dev, "StarFive GPIO chip registered %d GPIOs\n", sfp->gc.ngpio); + ret = jh7110_force_input_pins(sfp, "starfive,force-low-inputs", 0); + if (ret) + return ret; + + ret = jh7110_force_input_pins(sfp, "starfive,force-high-inputs", 1); + if (ret) + return ret; + return pinctrl_enable(sfp->pctl); } EXPORT_SYMBOL_GPL(jh7110_pinctrl_probe);