Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions arch/riscv/boot/dts/starfive/jh7110-pine64-star64.dts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@
};

&sysgpio {
starfive,force-high-inputs = <GPI_SYS_USB_OVERCURRENT>;

usb0_pins: usb0-0 {
vbus-pins {
pinmux = <GPIOMUX(25, GPOUT_SYS_USB_DRIVE_VBUS,
Expand Down
43 changes: 43 additions & 0 deletions drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,41 @@ static void jh7110_disable_clock(void *data)
clk_disable_unprepare(data);
}

static int jh7110_force_input_pins(struct jh7110_pinctrl *sfp,
const char *property, u32 forced_input)
{
int i, nforce;
int ret;
u32 pin, val;
unsigned int offset, shift;
struct device *dev = sfp->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;
Expand Down Expand Up @@ -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);
Expand Down