Add Pinctrl driver for Starfive JH8100 SoC
Subsystems (5)
v3 cover Add Pinctrl driver for Starfive JH8100 SoC
Starfive JH8100 SoC consists of 4 pinctrl domains - sys_east, sys_west, sys_gmac, and aon. This patch series adds pinctrl drivers for these 4 pinctrl domains and this patch series is depending on the JH8100 base patch series in [1] and [2]. The relevant dt-binding documentation for each pinctrl domain has been updated accordingly.
[1] https://lore.kernel.org/lkml/[email protected]/
[2] https://lore.kernel.org/lkml/[email protected]/
---
Changes in v3:
- Replace "additionalProperties: false" in dt-bindings docs by "unevaluatedProperties: false" to allow reference to properties in generic pinmux and pincfg schema.
- Remove redundant keyword "allOf" from the "compatible" property definition.
- Drop all PAD_GPIO*_* macros from dt-bindings header "starfive,jh8100-pinctrl.h" and move them to DTS header "jh8100-pinfunc.h".
- Drop "GPOUT_LOW", "GPOUT_HIGH", "GPOEN_ENABLE", "GPOEN_DISABLE", and "GPI_NONE" from dt-bindings header.
- Add macros "PAD_SLEW_RATE_FAST"and "PAD_SLEW_RATE_SLOW" to dt-bindings header.
- Change the commit message of the main driver and sys_east domain subdriver to inform what SoC they run on, and to explain that the main driver provides common APIs to all domain subdrivers to perform their respective tasks, and how the main driver and domain drivers work together.
- Add macros JH8100_SYS_E_NGPIO, JH8100_SYS_W_NGPIO, JH8100_SYS_G_NGPIO, JH8100_AON_NGPIO to header pinctrl-starfive-jh8100.h to represent total number of GPIO_PADs in sys-east, sys-west, sys-gmac, and aon (always-on) domains.
- In function jh8100_get_padcfg_base() of main driver, macros: PAD_GPIO47_E, PAD_GPIO15_W, PAD_RGPIO15 are replaced by JH8100_SYS_E_NGPIO, JH8100_SYS_W_NGPIO, and JH8100_AON_NGPIO respectively.
- Add function jh8100_padcfg_ds_from_uA() to main driver to convert uA (microamperes) from dts property drive-strength-microamp to drive strength value when setting the pin configuration register.
- Add function jh8100_padcfg_ds_to_uA() to main driver to convert drive strength value from pin configuration register to uA (microamperes) when reading pin configuration.
- Remove "of_gpio.h" and use only the gpiod interfaces in <linux/gpio/consumer.h>.
- Remove cross-include "../core.h" from the main driver and move it to header "pinctrl-starfive-jh8100.h".
- Remove cross-include "../pinctrl-utils.h" from the main driver and add the function prototype "pinctrl_utils_free_map()" to header "pinctrl-starfive-jh8100.h".
- Remove cross-include "../pinmux.h" from the main driver and add the "pinmux_generic_*" function prototypes to header "pinctrl-starfive-jh8100.h".
- Remove cross-include “../pinconf.h” from the main driver and add the function prototype "pinconf_generic_parse_dt_config()" to header "pinctrl-starfive-jh8100.h".
- Replace "GPOUT_LOW", "GPOUT_HIGH", "GPOEN_ENABLE", "GPOEN_DISABLE", and "GPI_NONE" in the main driver by constant numbers 0, 1, 0, 1, and 255 respectively.
- Update function jh8100_get_padcfg_base() to return base address of pad configuration registers for sys-west and aon domains.
- Update function jh8100_set_one_pin_mux() to support pad function selection in sys-west domain.
- Update function jh8100_gpio_direction_output() to remove JH8100_PADCFG_BIAS_MASK from mask so that when gpioset configure a pin as output, the pin bias setting (pull-up/pull-down) will not be cleared by the driver.
- Remove function jh8100_gpio_irq_setup() and the GPIO wakeup irq enablement in probe function from main driver. It is replaced by function gpiochip_wakeup_irq_setup() in gpiolib core "drivers/gpio/gpiolib.c".
The function gpiochip_wakeup_irq_setup() is added as the wakeup gpio irq setup function in the gpiolib core.
- The interrupt handler jh8100_gpio_wake_irq_handler() in the main driver is removed. It is replaced by gpio_wake_irq_handler() in gpiolib core "drivers/gpio/gpiolib.c".
- Remove the inline function pin_to_hwirq() from driver header file "pinctrl-starfive-jh8100.h".
- Remove cross-include "../core.h", “../pinmux.h”, and “../pinconf.h” from the sys-east, sys-west, sys-gmac, and aon domain sub-drivers.
- In sys_east domain sub-driver, macros PAD_GPIO0_E through PAD_GPIO47_E are replaced by constant numbers 0 through 47.
- In sys_west domain sub-driver, macros PAD_GPIO0_W through PAD_GPIO15_W are replaced by constant numbers 0 through 15.
- In AON domain sub-driver, macros PAD_RGPIO0 through PAD_RGPIO15 are replaced by constant numbers 0 through 15.
Changes in v2:
- Add "(always-on)" to document title to clarify acronym AON.
- Replace "drive-strength" by "drive-strength-microamp".
- Update "slew-rate" property in sys-east, sys-west, and aon document.
- remove redundant "bindings" from commit subject and message.
- Change regular expression "-[0-9]+$" to "-grp$" to standardize client node names to end with suffix "-grp" instead of "-<numerical _number>".
- Use 4 spaces indentation for DTS examples.
- Update DTS examples in sys-east, sys-west, and aon document with client driver pinmuxing.
- Remove redundant syscon and gmac macros from dt-binding header file.
- Remove redundant register macros from dt-binding header file.
- Add "wakeup-gpios" and "wakeup-source" to aon document.
- Add "gpio-line-names" to sys-east and sys-west document.
- Update the description of syscon register usage in each document.
- Update sys-gmac and aon document with information of GMAC voltage. reference syscon and GMAC pad syscon.
- Fix the pinctrl device nodes compatible string too long issue.
- Move all common codes from subdrivers to the main driver.
- Change the commit log to "add main and sys_east driver" to indicate the commit of both main and sys-east driver.
- Turn pin_to_hwirq macro to a static inline function to hide gpio internal detail, and also, for easier code readability.
- Change "JH8100_PADCFG_BIAS" to "JH8100_PADCFG_BIAS_MASK".
- Change "#define JH8100_PADCFG_DS_4MA BIT(1)" to
#define JH8100_PADCFG_DS_4MA (1U << 1)".
- Replace "jh8100_gpio_request" by "pinctrl_gpio_request".
- Replace "jh8100_gpio_free" by "pinctrl_gpio_free".
- Replace "jh8100_gpio_set_config" by "gpiochip_generic_config".
- Use irq_print_chip function to display irqchip name to user space.
- Use girq to represent GPIO interrupt controller.
- Update code to ensure wakeup-gpios is always an input line.
- Remove the jh8100_gpio_add_pin_ranges function and use gpio-ranges in device tree to provide information for GPIO core to add pin range for each pinctrl.
- Change "StarFive GPIO chip registered" to "StarFive JH8100 GPIO chip registered".
---
Alex Soo (7):
dt-bindings: pinctrl: starfive: Add JH8100 pinctrl
pinctrl: starfive: jh8100: add main driver and sys_east domain
sub-driver
pinctrl: starfive: jh8100: add sys_west domain sub-driver
pinctrl: starfive: jh8100: add sys_gmac domain sub-driver
pinctrl: starfive: jh8100: add AON domain sub-driver
gpiolib: enable GPIO interrupt to wake up a system from sleep
riscv: dts: starfive: jh8100: add pinctrl device tree nodes
.../pinctrl/starfive,jh8100-aon-pinctrl.yaml | 260 ++++ .../starfive,jh8100-sys-east-pinctrl.yaml | 222 ++++ .../starfive,jh8100-sys-gmac-pinctrl.yaml | 162 +++ .../starfive,jh8100-sys-west-pinctrl.yaml | 219 ++++ MAINTAINERS | 7 + arch/riscv/boot/dts/starfive/jh8100-evb.dts | 7 + arch/riscv/boot/dts/starfive/jh8100-pinfunc.h | 504 ++++++++ arch/riscv/boot/dts/starfive/jh8100.dtsi | 46 + drivers/gpio/gpiolib.c | 87 ++ drivers/pinctrl/starfive/Kconfig | 59 + drivers/pinctrl/starfive/Makefile | 6 + .../starfive/pinctrl-starfive-jh8100-aon.c | 150 +++ .../pinctrl-starfive-jh8100-sys-east.c | 220 ++++ .../pinctrl-starfive-jh8100-sys-gmac.c | 89 ++ .../pinctrl-starfive-jh8100-sys-west.c | 164 +++ .../starfive/pinctrl-starfive-jh8100.c | 1103 +++++++++++++++++ .../starfive/pinctrl-starfive-jh8100.h | 125 ++ .../pinctrl/starfive,jh8100-pinctrl.h | 13 + 18 files changed, 3443 insertions(+) create mode 100644 Documentation/devicetree/bindings/pinctrl/starfive,jh8100-aon-pinctrl.yaml create mode 100644 Documentation/devicetree/bindings/pinctrl/starfive,jh8100-sys-east-pinctrl.yaml create mode 100644 Documentation/devicetree/bindings/pinctrl/starfive,jh8100-sys-gmac-pinctrl.yaml create mode 100644 Documentation/devicetree/bindings/pinctrl/starfive,jh8100-sys-west-pinctrl.yaml create mode 100644 arch/riscv/boot/dts/starfive/jh8100-pinfunc.h create mode 100644 drivers/pinctrl/starfive/pinctrl-starfive-jh8100-aon.c create mode 100644 drivers/pinctrl/starfive/pinctrl-starfive-jh8100-sys-east.c create mode 100644 drivers/pinctrl/starfive/pinctrl-starfive-jh8100-sys-gmac.c create mode 100644 drivers/pinctrl/starfive/pinctrl-starfive-jh8100-sys-west.c create mode 100644 drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c create mode 100644 drivers/pinctrl/starfive/pinctrl-starfive-jh8100.h create mode 100644 include/dt-bindings/pinctrl/starfive,jh8100-pinctrl.h
Signature · 7 lines
2.43.2 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
RFC PATCH v3 1/7 dt-bindings: pinctrl: starfive: Add JH8100 pinctrl
Add documentation and header file for JH8100 pinctrl driver.
--- .../pinctrl/starfive,jh8100-aon-pinctrl.yaml | 260 ++++++++++++++++++ .../starfive,jh8100-sys-east-pinctrl.yaml | 222 +++++++++++++++ .../starfive,jh8100-sys-gmac-pinctrl.yaml | 162 +++++++++++ .../starfive,jh8100-sys-west-pinctrl.yaml | 219 +++++++++++++++ .../pinctrl/starfive,jh8100-pinctrl.h | 13 + 5 files changed, 876 insertions(+) create mode 100644 Documentation/devicetree/bindings/pinctrl/starfive,jh8100-aon-pinctrl.yaml create mode 100644 Documentation/devicetree/bindings/pinctrl/starfive,jh8100-sys-east-pinctrl.yaml create mode 100644 Documentation/devicetree/bindings/pinctrl/starfive,jh8100-sys-gmac-pinctrl.yaml create mode 100644 Documentation/devicetree/bindings/pinctrl/starfive,jh8100-sys-west-pinctrl.yaml create mode 100644 include/dt-bindings/pinctrl/starfive,jh8100-pinctrl.h
Documentation/devicetree/bindings/pinctrl/starfive,jh8100-aon-pinctrl.yaml new file +260 -0
@@ -0,0 +1,260 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pinctrl/starfive,jh8100-aon-pinctrl.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: StarFive JH8100 AON (always-on) Pin Controller + +description: | + Pinctrl bindings for JH8100 RISC-V SoC from StarFive Technology Ltd. + + The JH8100 SoC has 4 pinctrl domains - sys_east, sys_west, sys_gmac, and aon. + This document provides an overview of the "aon" pinctrl domain. + + The "aon" domain has a pin controller which provides + - I/O multiplexing for peripheral signals specific to this domain. + - GPIO pins which support external GPIO interrupts or external wake-up. + - syscon registers to configure device I/O reference voltage. + + In the AON Pin Controller, the pins named PAD_RGPIO0 to PAD_GPIO15 can be + multiplexed and have configurable bias, drive strength, schmitt trigger etc. + Only peripherals in the AON domain can have their I/O go through the 16 + "PAD_RGPIOs". This includes I2C, UART, watchdog, eMMC, SDIO0, XSPI etc. + + All these peripherals can be connected to any of the 16 PAD_RGPIOs in such a way + that any iopad can be set up to be controlled by any of the peripherals. + + The pin muxing is illustrated by the diagram below. + _____________ + | | + RGPIO0 --------------| |--- PAD_RGPIO0 + RGPIO1 --------------| AON I/O MUX |--- PAD_RGPIO1 + ... | | ... + I2C8 SDA interface --| |--- PAD_RGPIO15 + | | + ------------- + + The AON Pin Controller provides syscon registers to configure + + 1. reference voltage of + - eMMC I/O interface + supported voltage - 1.8V + - SDIO0 I/O interface + supported voltage - 3.3V, 1.8V + - PAD_RGPIO bank + - 16 PAD_RGPIOs (PAD_RGPIO0 to PAD_GPIO15) + - all devices attached to PAD_RGPIOs must use I/O voltage 3.3V. + - XSPI I/O interface + supported voltage level - 3.3V + + Regulator supplies the device voltage, and each device has a corresponding syscon + register bit [1:0] that must be configured to indicate the device voltage level. + + +--------+--------+-------------------+ + | Bit[1] | Bit[0] | Reference Voltage | + +--------+--------+-------------------+ + | 0 | 0 | 3.3 V | + +--------+--------+-------------------+ + | 0 | 1 | 2.5 V | + +--------+--------+-------------------+ + | 1 | x | 1.8 V | + +--------+--------+-------------------+ + + 2. reference voltage and slew rate of GMAC0 + + Voltage level on GMAC0 interface is dependent on the PHY that it is pairing with. The + supported voltage levels are 3.3V, 2.5V, and 1.8V. + + GMAC0 has 2 set of syscon registers - + + 2.1 PAD_VREF_GMAC0_syscon - bit [1:0] must be configured to indicate the voltage level on + GMAC0 interface. The default setting is 3.3V. + + +--------+--------+-----------------------------------+ + | Bit[1] | Bit[0] | GMAC0 Interface Reference Voltage | + +--------+--------+-----------------------------------+ + | 0 | 0 | 3.3V | + +--------+--------+-----------------------------------+ + | 0 | 1 | 2.5V | + +--------+--------+-----------------------------------+ + | 1 | x | 1.8V | + +--------+--------+-----------------------------------+ + + 2.2 PAD_GMAC0_<SIGNAL_NAME>_syscon - each GMAC0 pad has a corresponding syscon bit [0] set + to 0 by default. When GMAC0 mode is RGMII and voltage level is 2.5V, the bit [0] must be + set to 1. + + +-------------+-----------------------+---------+ + | GMAC0 Mode | GMAC0 Voltage Level | Bit[0] | + +-------------+-----------------------+---------+ + | | 3.3V | 0 | + | |-----------------------+---------+ + | RGMII | 2.5V | 1 | + | |-----------------------+---------+ + | | 1.8V | 0 | + +-------------+-----------------------+---------+ + | | 3.3V | 0 | + | |-----------------------+---------+ + | RMII | 2.5V | 0 | + | |-----------------------+---------+ + | | 1.8V | 0 | + +-------------+-----------------------+---------+ + + the bit [2] can be used to configure GMAC0 signal slew rate, + + +--------+-----------+ + | Bit[2] | Slew Rate | + +--------+-----------+ + | 0 | Fast | + +--------+-----------+ + | 1 | Slow | + +--------+-----------+ + + Under any circumstances, the syscon register's reference voltage setting must not be + lower than the actual device voltage, otherwise, the device I/O pads will get damaged. + + Follow the guidelines below when configure reference voltage - + + To increase the device voltage, set bit [1:0] to the new operating state first before + raising the actual voltage to the higher operating point. + + To decrease the device voltage, hold bit [1:0] to the current operating state until + the actual voltage has stabilized at the lower operating point before changing the + setting. + + Alternatively, a device voltage change can always be initiated by first setting syscon + register bit [1:0] = 0, the safe 3.3V startup condition, before changing the device + voltage. Then once the actual voltage is changed and has stabilized at the new operating + point, bit [1:0] can be reset as appropriate. + +maintainers: + - Alex Soo <[email protected]> + +properties: + compatible: + - items: + - const: starfive,jh8100-aon-pinctrl + - const: syscon + - const: simple-mfd + + reg: + maxItems: 1 + + resets: + maxItems: 1 + + interrupts: + maxItems: 1 + + interrupt-controller: true + + gpio-controller: true + + '#gpio-cells': + const: 2 + + gpio-ranges: + maxItems: 1 + + wakeup-gpios: + maxItems: 1 + description: GPIO pin to be used for waking up the system from sleep mode. + + wakeup-source: + maxItems: 1 + description: to indicate pinctrl has wakeup capability. + +patternProperties: + '-grp$': + type: object + additionalProperties: false + patternProperties: + '-pins$': + type: object + description: | + A pinctrl node should contain at least one subnode representing the + pinctrl groups available in the domain. Each subnode will list the + pins it needs, and how they should be configured, with regard to + muxer configuration, bias, input enable/disable, input schmitt + trigger enable/disable, slew-rate and drive strength. + allOf: + - $ref: /schemas/pinctrl/pincfg-node.yaml + - $ref: /schemas/pinctrl/pinmux-node.yaml + unevaluatedProperties: false + + properties: + pinmux: + description: | + The list of GPIOs and their mux settings or function select. + The GPIOMUX and PINMUX macros are used to configure the + I/O multiplexing and function selection respectively. + + bias-disable: true + + bias-pull-up: + type: boolean + + bias-pull-down: + type: boolean + + drive-strength-microamp: + enum: [ 2000, 4000, 8000, 12000 ] + + input-enable: true + + input-disable: true + + input-schmitt-enable: true + + input-schmitt-disable: true + + slew-rate: + enum: [ 0, 1 ] + default: 0 + description: | + 0: slow (half frequency) + 1: fast + +required: + - compatible + - reg + - resets + - interrupts + - interrupt-controller + - gpio-controller + - '#gpio-cells' + +additionalProperties: false + +examples: + - | + soc { + #address-cells = <2>; + #size-cells = <2>; + + pinctrl_aon: pinctrl@1f300000 { + compatible = "starfive,jh8100-aon-pinctrl", "syscon", "simple-mfd"; + reg = <0x0 0x1f300000 0x0 0x10000>; + resets = <&aoncrg 0>; + interrupts = <160>; + interrupt-controller; + gpio-controller; + #gpio-cells = <2>; + gpio-ranges = <&pinctrl_aon 0 0 16>; + + i2c7_pins: i2c7-grp { + i2c7-scl-pins { + pinmux = <0x23265409>; + bias-pull-up; + input-enable; + }; + + i2c7-sda-pins { + pinmux = <0x2427580a>; + bias-pull-up; + input-enable; + }; + }; + }; + };
Documentation/devicetree/bindings/pinctrl/starfive,jh8100-sys-east-pinctrl.yaml new file +222 -0
222 lines not on this page · raw message
Documentation/devicetree/bindings/pinctrl/starfive,jh8100-sys-gmac-pinctrl.yaml new file +162 -0
162 lines not on this page · raw message
Documentation/devicetree/bindings/pinctrl/starfive,jh8100-sys-west-pinctrl.yaml new file +219 -0
219 lines not on this page · raw message
include/dt-bindings/pinctrl/starfive,jh8100-pinctrl.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 OR MIT */ +/* +* Copyright (C) 2023-2024 StarFive Technology Co., Ltd. +*/ + +#ifndef __DT_BINDINGS_PINCTRL_STARFIVE_JH8100_H__ +#define __DT_BINDINGS_PINCTRL_STARFIVE_JH8100_H__ + +/* Pad Slew Rates */ +#define PAD_SLEW_RATE_FAST 1 +#define PAD_SLEW_RATE_SLOW 0 + +#endif
Signature · 7 lines
2.25.1 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
Rob Herring (Arm)
maintainerRe: [RFC PATCH v3 1/7] dt-bindings: pinctrl: starfive: Add JH8100 pinctrl
Quoted 16 lines · Alex Soo
Add documentation and header file for JH8100 pinctrl driver.
Signed-off-by Alex Soo <[email protected]>--- .../pinctrl/starfive,jh8100-aon-pinctrl.yaml | 260 ++++++++++++++++++ .../starfive,jh8100-sys-east-pinctrl.yaml | 222 +++++++++++++++ .../starfive,jh8100-sys-gmac-pinctrl.yaml | 162 +++++++++++ .../starfive,jh8100-sys-west-pinctrl.yaml | 219 +++++++++++++++ .../pinctrl/starfive,jh8100-pinctrl.h | 13 + 5 files changed, 876 insertions(+) create mode 100644 Documentation/devicetree/bindings/pinctrl/starfive,jh8100-aon-pinctrl.yaml create mode 100644 Documentation/devicetree/bindings/pinctrl/starfive,jh8100-sys-east-pinctrl.yaml create mode 100644 Documentation/devicetree/bindings/pinctrl/starfive,jh8100-sys-gmac-pinctrl.yaml create mode 100644 Documentation/devicetree/bindings/pinctrl/starfive,jh8100-sys-west-pinctrl.yaml create mode 100644 include/dt-bindings/pinctrl/starfive,jh8100-pinctrl.h
My bot found errors running 'make dt_binding_check' on your patch:
yamllint warnings/errors:./Documentation/devicetree/bindings/pinctrl/starfive,jh8100-sys-gmac-pinctrl.yaml:109:7: [warning] wrong indentation: expected 4 but found 6 (indentation) ./Documentation/devicetree/bindings/pinctrl/starfive,jh8100-sys-west-pinctrl.yaml:96:7: [warning] wrong indentation: expected 4 but found 6 (indentation) ./Documentation/devicetree/bindings/pinctrl/starfive,jh8100-sys-east-pinctrl.yaml:99:7: [warning] wrong indentation: expected 4 but found 6 (indentation) ./Documentation/devicetree/bindings/pinctrl/starfive,jh8100-aon-pinctrl.yaml:136:7: [warning] wrong indentation: expected 4 but found 6 (indentation)
dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/pinctrl/starfive,jh8100-sys-gmac-pinctrl.yaml: properties:compatible: [{'items': [{'const': 'starfive,jh8100-sys-pinctrl-gmac'}, {'const': 'syscon'}, {'const': 'simple-mfd'}]}] is not of type 'object', 'boolean'
from schema $id: http://json-schema.org/draft-07/schema#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/pinctrl/starfive,jh8100-sys-gmac-pinctrl.yaml: properties:compatible: [{'items': [{'const': 'starfive,jh8100-sys-pinctrl-gmac'}, {'const': 'syscon'}, {'const': 'simple-mfd'}]}] is not of type 'object', 'boolean'
from schema $id: http://devicetree.org/meta-schemas/keywords.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/pinctrl/starfive,jh8100-sys-west-pinctrl.yaml: properties:compatible: [{'items': [{'const': 'starfive,jh8100-sys-pinctrl-west'}, {'const': 'syscon'}, {'const': 'simple-mfd'}]}] is not of type 'object', 'boolean'
from schema $id: http://json-schema.org/draft-07/schema#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/pinctrl/starfive,jh8100-sys-west-pinctrl.yaml: properties:compatible: [{'items': [{'const': 'starfive,jh8100-sys-pinctrl-west'}, {'const': 'syscon'}, {'const': 'simple-mfd'}]}] is not of type 'object', 'boolean'
from schema $id: http://devicetree.org/meta-schemas/keywords.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/pinctrl/starfive,jh8100-sys-east-pinctrl.yaml: properties:compatible: [{'items': [{'const': 'starfive,jh8100-sys-pinctrl-east'}, {'const': 'syscon'}, {'const': 'simple-mfd'}]}] is not of type 'object', 'boolean'
from schema $id: http://json-schema.org/draft-07/schema#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/pinctrl/starfive,jh8100-sys-east-pinctrl.yaml: properties:compatible: [{'items': [{'const': 'starfive,jh8100-sys-pinctrl-east'}, {'const': 'syscon'}, {'const': 'simple-mfd'}]}] is not of type 'object', 'boolean'
from schema $id: http://devicetree.org/meta-schemas/keywords.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/pinctrl/starfive,jh8100-aon-pinctrl.yaml: properties:compatible: [{'items': [{'const': 'starfive,jh8100-aon-pinctrl'}, {'const': 'syscon'}, {'const': 'simple-mfd'}]}] is not of type 'object', 'boolean'
from schema $id: http://json-schema.org/draft-07/schema#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/pinctrl/starfive,jh8100-aon-pinctrl.yaml: properties:compatible: [{'items': [{'const': 'starfive,jh8100-aon-pinctrl'}, {'const': 'syscon'}, {'const': 'simple-mfd'}]}] is not of type 'object', 'boolean'
from schema $id: http://devicetree.org/meta-schemas/keywords.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/pinctrl/starfive,jh8100-sys-gmac-pinctrl.yaml: ignoring, error in schema: properties: compatible /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/pinctrl/starfive,jh8100-sys-west-pinctrl.yaml: ignoring, error in schema: properties: compatible /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/pinctrl/starfive,jh8100-sys-east-pinctrl.yaml: ignoring, error in schema: properties: compatible /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/pinctrl/starfive,jh8100-aon-pinctrl.yaml: ignoring, error in schema: properties: compatible Documentation/devicetree/bindings/pinctrl/starfive,jh8100-sys-west-pinctrl.example.dtb: /example-0/soc/pinctrl@123e0000: failed to match any schema with compatible: ['starfive,jh8100-sys-pinctrl-west', 'syscon', 'simple-mfd'] Documentation/devicetree/bindings/pinctrl/starfive,jh8100-sys-gmac-pinctrl.example.dtb: /example-0/soc/pinctrl@12770000: failed to match any schema with compatible: ['starfive,jh8100-sys-pinctrl-gmac', 'syscon', 'simple-mfd'] Documentation/devicetree/bindings/pinctrl/starfive,jh8100-sys-east-pinctrl.example.dtb: /example-0/soc/pinctrl@122d0000: failed to match any schema with compatible: ['starfive,jh8100-sys-pinctrl-east', 'syscon', 'simple-mfd'] Documentation/devicetree/bindings/pinctrl/starfive,jh8100-aon-pinctrl.example.dtb: /example-0/soc/pinctrl@1f300000: failed to match any schema with compatible: ['starfive,jh8100-aon-pinctrl', 'syscon', 'simple-mfd']
doc reference errors (make refcheckdocs):
See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/[email protected]
The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.
If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:
pip3 install dtschema --upgrade
Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.
Conor Dooley
maintainerRe: [RFC PATCH v3 1/7] dt-bindings: pinctrl: starfive: Add JH8100 pinctrl
In reply to Alex SooQuoted 11 lines · Alex Soo
Add documentation and header file for JH8100 pinctrl driver.
Signed-off-by Alex Soo <[email protected]>include/dt-bindings/pinctrl/starfive,jh8100-pinctrl.h new file +1
-0@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 OR MIT */
include/dt-bindings/pinctrl/starfive,jh8100-pinctrl.h line 11
Quoted 10 lines
include/dt-bindings/pinctrl/starfive,jh8100-pinctrl.h new file +10
-0+/* +* Copyright (C) 2023-2024 StarFive Technology Co., Ltd. +*/ + +#ifndef __DT_BINDINGS_PINCTRL_STARFIVE_JH8100_H__ +#define __DT_BINDINGS_PINCTRL_STARFIVE_JH8100_H__ + +/* Pad Slew Rates */ +#define PAD_SLEW_RATE_FAST 1 +#define PAD_SLEW_RATE_SLOW 0
Should this really be in the bindings? I don't see it having a direct user in the driver.
Also, if this is the only header you have, I think the RFC tag could be dropped, since there'll not be a header we need to worry about getting into U-Boot etc with values that may change when the SoC moves from an FPGA etc to tape out.
Cheers,
Conor.
RE: [RFC PATCH v3 1/7] dt-bindings: pinctrl: starfive: Add JH8100 pinctrl
Quoted 45 lines
-----Original Message-----
From: Conor Dooley <[email protected]>
Sent: Saturday, May 4, 2024 12:07 AM
To: Yuklin Soo <[email protected]>
Cc: Linus Walleij <[email protected]>; Bartosz Golaszewski <[email protected]>; Hal Feng <[email protected]>; Leyfoon Tan <[email protected]>; Jianlong Huang <[email protected]>; Emil Renner Berthing <[email protected]>; Rob Herring <[email protected]>; Krzysztof Kozlowski <[email protected]>; Conor Dooley <[email protected]>; Drew Fustini <[email protected]>; [email protected]; linux- [email protected]; [email protected]; linux- [email protected]; Paul Walmsley <[email protected]>; Palmer Dabbelt <[email protected]>; Albert Ou <[email protected]>
Subject: Re: [RFC PATCH v3 1/7] dt-bindings: pinctrl: starfive: Add JH8100 pinctrlQuoted 12 lines · Alex Soo
Add documentation and header file for JH8100 pinctrl driver.
Signed-off-by Alex Soo <[email protected]>include/dt-bindings/pinctrl/starfive,jh8100-pinctrl.h new file +1
-0@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 OR MIT */ include/dt-bindings/pinctrl/starfive,jh8100-pinctrl.h line 11
Quoted 10 lines
include/dt-bindings/pinctrl/starfive,jh8100-pinctrl.h new file +10
-0+/* +* Copyright (C) 2023-2024 StarFive Technology Co., Ltd. +*/ + +#ifndef __DT_BINDINGS_PINCTRL_STARFIVE_JH8100_H__ +#define __DT_BINDINGS_PINCTRL_STARFIVE_JH8100_H__ + +/* Pad Slew Rates */ +#define PAD_SLEW_RATE_FAST 1 +#define PAD_SLEW_RATE_SLOW 0Should this really be in the bindings? I don't see it having a direct user in the driver.
Quoted 3 lines
Also, if this is the only header you have, I think the RFC tag could be dropped, since there'll not be a header we need to worry about getting into U-Boot etc with values that may change when the SoC moves from an FPGA etc to tape out.
I will drop the PAD_SLEW_RATE_* macros from dt-bindings header and move them to the DTS header file. Will submit the next version (V4) without the "RFC PATCH" subject prefix.
Quoted 3 lines
Cheers,
Conor.
RFC PATCH v3 2/7 pinctrl: starfive: jh8100: add main driver and sys_east domain sub-driver
In reply to Alex SooAdd Starfive JH8100 SoC pinctrl main driver to provide the common APIs that are used by the sub-drivers of pinctrl domains:
- sys_east,
- sys_west,
- sys_gmac,
- aon (always-on)
to implement the following tasks:
- applies pin multiplexing, function selection, and pin configuration for devices during system initialization or change of pinctrl state due to power management.
- read or set pin configuration from user space.
Also, add the sys_east domain sub-driver since it requires at least one domain sub-driver to run the probe function in the main driver to enable the basic pinctrl functionalities on the system.
--- drivers/pinctrl/starfive/Kconfig | 21 + drivers/pinctrl/starfive/Makefile | 3 + .../pinctrl-starfive-jh8100-sys-east.c | 220 ++++ .../starfive/pinctrl-starfive-jh8100.c | 1094 +++++++++++++++++ .../starfive/pinctrl-starfive-jh8100.h | 111 ++ 5 files changed, 1449 insertions(+) create mode 100644 drivers/pinctrl/starfive/pinctrl-starfive-jh8100-sys-east.c create mode 100644 drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c create mode 100644 drivers/pinctrl/starfive/pinctrl-starfive-jh8100.h
drivers/pinctrl/starfive/Kconfig +21 -0
@@ -49,3 +49,24 @@ config PINCTRL_STARFIVE_JH7110_AON This also provides an interface to the GPIO pins not used by other peripherals supporting inputs, outputs, configuring pull-up/pull-down and interrupts on input changes. + +config PINCTRL_STARFIVE_JH8100 + bool + select GENERIC_PINCONF + select GENERIC_PINCTRL_GROUPS + select GENERIC_PINMUX_FUNCTIONS + select GPIOLIB + select GPIOLIB_IRQCHIP + select OF_GPIO + +config PINCTRL_STARFIVE_JH8100_SYS_EAST + tristate "StarFive JH8100 SoC System IOMUX-East pinctrl and GPIO driver" + depends on ARCH_STARFIVE || COMPILE_TEST + depends on OF + select PINCTRL_STARFIVE_JH8100 + default ARCH_STARFIVE + help + Say yes here to support system iomux-east pin control on the StarFive JH8100 SoC. + This also provides an interface to the GPIO pins not used by other + peripherals supporting inputs, outputs, configuring pull-up/pull-down + and interrupts on input changes.
drivers/pinctrl/starfive/Makefile +3 -0
@@ -5,3 +5,6 @@ obj-$(CONFIG_PINCTRL_STARFIVE_JH7100) += pinctrl-starfive-jh7100.o obj-$(CONFIG_PINCTRL_STARFIVE_JH7110) += pinctrl-starfive-jh7110.o obj-$(CONFIG_PINCTRL_STARFIVE_JH7110_SYS) += pinctrl-starfive-jh7110-sys.o obj-$(CONFIG_PINCTRL_STARFIVE_JH7110_AON) += pinctrl-starfive-jh7110-aon.o + +obj-$(CONFIG_PINCTRL_STARFIVE_JH8100) += pinctrl-starfive-jh8100.o +obj-$(CONFIG_PINCTRL_STARFIVE_JH8100_SYS_EAST) += pinctrl-starfive-jh8100-sys-east.o
drivers/pinctrl/starfive/pinctrl-starfive-jh8100-sys-east.c new file +220 -0
220 lines not on this page · raw message
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +1094 -0
1,094 lines not on this page · raw message
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.h new file +111 -0
111 lines not on this page · raw message
Signature · 7 lines
2.25.1 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
Re: [RFC PATCH v3 2/7] pinctrl: starfive: jh8100: add main driver and sys_east domain sub-driver
Fri, May 03, 2024 at 07:14:31PM +0800, Alex Soo kirjoitti:
Quoted 19 lines
Add Starfive JH8100 SoC pinctrl main driver to provide the common APIs that are used by the sub-drivers of pinctrl domains:
-sys_east,
-sys_west,
-sys_gmac,
- aon (always-on)to implement the following tasks:
- applies pin multiplexing, function selection, and pin configuration for devices during system initialization or change of pinctrl state due to power management.
- read or set pin configuration from user space.Also, add the
sys_eastdomain sub-driver since it requires at least one domain sub-driver to run the probe function in the main driver to enable the basic pinctrl functionalities on the system.
...
drivers/pinctrl/starfive/Kconfig config PINCTRL_STARFIVE_JH7110_AON · line 60
Quoted 9 lines
drivers/pinctrl/starfive/Kconfig +8
-0+config PINCTRL_STARFIVE_JH8100 + bool + select GENERIC_PINCONF + select GENERIC_PINCTRL_GROUPS + select GENERIC_PINMUX_FUNCTIONS + select GPIOLIB + select GPIOLIB_IRQCHIP + select OF_GPIO
Why?
...
Quoted 7 lines
+/*
+ * Pinctrl / GPIO driver for StarFive JH8100 SoC sys east controller
+ *
+ * Copyright (C) 2023-2024 StarFive Technology Co., Ltd.
+ * Author: Alex Soo <[email protected]>+ *
Unneeded blank line.
Quoted 1 line
+ */
...
drivers/pinctrl/starfive/pinctrl-starfive-jh8100-sys-east.c line 14
Quoted 5 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100-sys-east.c new file +5
-0+#include <linux/gpio/driver.h> +#include <linux/module.h> +#include <linux/pinctrl/pinctrl.h> +#include <linux/platform_device.h> +#include <linux/pm_runtime.h>
This lacks some of inclusions.
E.g., array_size.h, mod_devicetable.h, io.h.
...
Quoted 1 line
+#ifdef
CONFIG_PM_SLEEP
SHouldn't be in a new code. Use proper PM macros.
drivers/pinctrl/starfive/pinctrl-starfive-jh8100-sys-east.c line 136
Quoted 9 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100-sys-east.c new file +8
-0+static int jh8100_sys_e_pinctrl_suspend (struct device *dev) +{ +struct jh8100_pinctrl *sfp; +int i; + + sfp =dev_get_drvdata (dev); +if (!sfp) +return -EINVAL ;
When this check can be true?
Quoted 4 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100-sys-east.c new file +4
-0+for (i =0 ; i < sfp->info->nregs; i++) + sfp->jh8100_sys_east_regs[i] =readl_relaxed (sfp->base + (i *4 )); + +return pinctrl_force_sleep (sfp->pctl);
drivers/pinctrl/starfive/pinctrl-starfive-jh8100-sys-east.c line 151
Quoted 10 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100-sys-east.c new file +9
-0+} + +static int jh8100_sys_e_pinctrl_resume (struct device *dev) +{ +struct jh8100_pinctrl *sfp; +int i; + sfp =dev_get_drvdata (dev); +if (!sfp) +return -EINVAL ;
Ditto.
Review
Quoted 2 lines
(quoted diff) +2
-0+ for (i = 0; i < sfp->info->nregs; i++) + writel_relaxed(sfp->jh8100_sys_east_regs[i], sfp->base + (i * 4));
Too many parentheses.
Quoted 3 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100-sys-east.c new file +3
-0+ return pinctrl_force_default(sfp->pctl); +} +#endif
...
drivers/pinctrl/starfive/pinctrl-starfive-jh8100-sys-east.c line 162
Quoted 3 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100-sys-east.c new file +3
-0+static SIMPLE_DEV_PM_OPS(jh8100_sys_e_pinctrl_dev_pm_ops, + jh8100_sys_e_pinctrl_suspend, + jh8100_sys_e_pinctrl_resume);
Don't use obsoleted macros, use new ones.
...
drivers/pinctrl/starfive/pinctrl-starfive-jh8100-sys-east.c line 212
Quoted 3 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100-sys-east.c new file +3
-0+#ifdef CONFIG_PM_SLEEP + .pm = &jh8100_sys_e_pinctrl_dev_pm_ops, +#endif
Ditto, no ugly ifdeffery.
Quoted 3 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100-sys-east.c new file +3
-0+ .of_match_table = jh8100_sys_e_pinctrl_of_match, + }, +};
...
Quoted 7 lines
+/*
+ * Pinctrl / GPIO driver for StarFive JH8100 SoC
+ *
+ * Copyright (C) 2023-2024 StarFive Technology Co., Ltd.
+ * Author: Alex Soo <[email protected]>+ *
Unneeded blank line.
Quoted 1 line
+ */
...
+ array_size.h
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c line 11
Quoted 2 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +2
-0+#include <linux/bits.h> +#include <linux/clk.h>
+ container_of.h
Quoted 6 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +6
-0+#include <linux/gpio/consumer.h> +#include <linux/gpio/driver.h> +#include <linux/io.h> +#include <linux/irq.h> +#include <linux/mod_devicetable.h> +#include <linux/module.h>
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c line 27
Quoted 10 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +10
-0+#include <linux/mutex.h> +#include <linux/of.h> +#include <linux/of_device.h> +#include <linux/of_irq.h> +#include <linux/platform_device.h> +#include <linux/pm_wakeirq.h> +#include <linux/reset.h> +#include <linux/seq_file.h> +#include <linux/spinlock.h> +#include <linux/string.h>
+ types.h
...
Quoted 14 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +14
-0+static unsigned int jh8100_pinmux_din (u32 v) +{ +return (v &GENMASK (31 ,24 )) >>24 ; +} + +static u32 jh8100_pinmux_dout (u32 v) +{ +return (v &GENMASK (23 ,16 )) >>16 ; +} + +static u32 jh8100_pinmux_doen (u32 v) +{ +return (v &GENMASK (15 ,10 )) >>10 ; +}
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c line 81
Quoted 10 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +10
-0+ +static u32 jh8100_pinmux_function (u32 v) +{ +return (v &GENMASK (9 ,8 )) >>8 ; +} + +static unsigned int jh8100_pinmux_pin (u32 v) +{ +return v &GENMASK (7 ,0 ); +}
These all are reinventions of bitfield.h.
...
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c line 107
Quoted 9 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +8
-0+static void jh8100_pin_dbg_show (struct pinctrl_dev *pctldev, +struct seq_file *s,unsigned int pin) +{ +struct jh8100_pinctrl *sfp =pinctrl_dev_get_drvdata (pctldev); +const struct jh8100_pinctrl_domain_info *info = sfp->info; + +seq_printf (s,"%s" ,dev_name (pctldev->dev)); +if (pin < sfp->gc.ngpio) {
When this is not true?
If that case even possible, invert the conditional to reduce the indentation level.
Quoted 13 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +13
-0+unsigned int offset =4 * (pin /4 ); +unsigned int shift =8 * (pin %4 ); +u32 dout =readl_relaxed (sfp->base + info->dout_reg_base + offset); +u32 doen =readl_relaxed (sfp->base + info->doen_reg_base + offset); +u32 gpi =readl_relaxed (sfp->base + info->gpi_reg_base + offset); + + dout = (dout >> shift) & info->dout_mask; + doen = (doen >> shift) & info->doen_mask; + gpi = ((gpi >> shift) -2 ) & info->gpi_mask; + +seq_printf (s," dout=%u doen=%u din=%u" , dout, doen, gpi); + } +}
...
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c line 151
Quoted 7 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +7
-0+ pgnames =devm_kcalloc (dev, ngroups,sizeof (*pgnames),GFP_KERNEL ); +if (!pgnames) +return -ENOMEM ; + + map =kcalloc (nmaps,sizeof (*map),GFP_KERNEL ); +if (!map) +return -ENOMEM ;
Why one is managed and another is not? Shouldn't be both either managed or not?
...
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c line 155
Quoted 1 line
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +1
-0+mutex_lock (&sfp->mutex);
Don't you want to use cleanup.h from day 1?
...
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c line 156
Quoted 1 line
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +1
-0+for_each_child_of_node (np, child) {
Why not using _scoped() variant?
...
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c line 157
Quoted 1 line
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +1
-0+int npins =of_property_count_u32_elems (child,"pinmux" );
Why signed?
Please, decouple definition and assignment.
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c line 166
Quoted 9 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +9
-0+int *pins; +u32 *pinmux; +int i; + +if (npins <1 ) { +dev_err (dev, +"invalid pinctrl group %pOFn.%pOFn: pinmux not set\n" , + np, child); + ret = -EINVAL ;
Can npins be negative? In such case why shadowing an error code?
Quoted 2 lines
(quoted diff) +2
-0+ goto put_child; + }
...
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c line 203
Quoted 2 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +2
-0+ ret =pinctrl_generic_add_group (pctldev, grpname, + pins, npins, pinmux);
One line?
...
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c line 363
Quoted 10 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +10
-0+for (i =0 ; i < group->grp.npins; i++) { +u32 v = pinmux[i]; + +jh8100_set_one_pin_mux (sfp, +jh8100_pinmux_pin (v), +jh8100_pinmux_din (v), +jh8100_pinmux_dout (v), +jh8100_pinmux_doen (v), +jh8100_pinmux_function (v)); + }
Indentation?
...
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c line 380
Quoted 3 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +3
-0+static u32 jh8100_padcfg_ds_to_mA (u32 padcfg) +{ +return jh8100_drive_strength_mA[(padcfg >>1 ) &3U ];
GENMASK() ?
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c line 385
Quoted 5 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +5
-0+} + +static u32 jh8100_padcfg_ds_to_uA (u32 padcfg) +{ +return jh8100_drive_strength_mA[(padcfg >>1 ) &3U ] *1000 ;
Ditto.
Quoted 1 line
+}
...
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c line 390
Quoted 3 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +3
-0+static u32 jh8100_padcfg_ds_from_mA (u32 v) +{ +int i;
Why signed?
Quoted 6 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +6
-0+for (i =0 ; i <ARRAY_SIZE (jh8100_drive_strength_mA); i++) { +if (v <= jh8100_drive_strength_mA[i]) +break ; + } +return i <<1 ; +}
...
Review
Quoted 2 lines
(quoted diff) +2
-0+static int jh8100_gpio_get_direction(struct gpio_chip *gc, + unsigned int gpio)
One line?
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c line 676
Quoted 11 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +10
-0+{ +struct jh8100_pinctrl *sfp =container_of (gc, + struct jh8100_pinctrl, gc); +const struct jh8100_pinctrl_domain_info *info = sfp->info; +unsigned int offset =4 * (gpio /4 ); +unsigned int shift =8 * (gpio %4 ); +u32 doen =readl_relaxed (sfp->base + info->doen_reg_base + offset); + doen = (doen >> shift) & info->doen_mask; + +return doen ==0 ?GPIO_LINE_DIRECTION_OUT :GPIO_LINE_DIRECTION_IN ;
if ((doen >> shift) & info->doen_mask) return GPIO_LINE_DIRECTION_IN; return GPIO_LINE_DIRECTION_OUT;
Quoted 1 line
+}
...
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c line 683
Quoted 5 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +5
-0+static int jh8100_gpio_direction_input (struct gpio_chip *gc, +unsigned int gpio) +{ +struct jh8100_pinctrl *sfp =container_of (gc, + struct jh8100_pinctrl, gc);
Broken indentation, just put on one line.
Quoted 9 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +9
-0+/* enable input and schmitt trigger */ +jh8100_padcfg_rmw (sfp, gpio, +JH8100_PADCFG_IE |JH8100_PADCFG_SMT , +JH8100_PADCFG_IE |JH8100_PADCFG_SMT ); + +jh8100_set_one_pin_mux (sfp, gpio,255 ,0 ,1 ,0 ); + +return 0 ; +}
...
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c line 703
Quoted 9 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +8
-0+static int jh8100_gpio_direction_output (struct gpio_chip *gc, +unsigned int gpio,int value) +{ +struct jh8100_pinctrl *sfp =container_of (gc, + struct jh8100_pinctrl, gc); +jh8100_set_one_pin_mux (sfp, gpio, +255 , value ?1 :0 , +0 ,0 );
Use room on the previous lines.
Quoted 6 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +6
-0+/* disable input, schmitt trigger and bias */ +jh8100_padcfg_rmw (sfp, gpio, +JH8100_PADCFG_IE |JH8100_PADCFG_SMT , +0 ); +return 0 ; +}
...
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c line 668
Quoted 3 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +3
-0+{ +struct jh8100_pinctrl *sfp =container_of (gc, + struct jh8100_pinctrl, gc);
One line. You may create a helper to_jh8100_pinctrl() and use everywhere,
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c line 718
Quoted 3 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +3
-0+const struct jh8100_pinctrl_domain_info *info = sfp->info; +void __iomem *reg = sfp->base + info->gpioin_reg_base + +4 * (gpio /32 );
Split definition and assignment. It will increase readability.
Quoted 2 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +2
-0+return !!(readl_relaxed (reg) &BIT (gpio %32 )); +}
...
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c line 732
Quoted 10 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +10
-0+static void jh8100_gpio_set (struct gpio_chip *gc, +unsigned int gpio,int value) +{ +struct jh8100_pinctrl *sfp =container_of (gc, + struct jh8100_pinctrl, gc); +const struct jh8100_pinctrl_domain_info *info = sfp->info; +unsigned int offset =4 * (gpio /4 ); +unsigned int shift =8 * (gpio %4 ); +void __iomem *reg_dout = sfp->base + info->dout_reg_base + offset; +u32 dout = (value ?1 :0 ) << shift;
u32 dout = value ? BIT(shift) : 0;
Quoted 8 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +8
-0+u32 mask = info->dout_mask << shift; +unsigned long flags; + +raw_spin_lock_irqsave (&sfp->lock, flags); + dout |=readl_relaxed (reg_dout) & ~mask; +writel_relaxed (dout, reg_dout); +raw_spin_unlock_irqrestore (&sfp->lock, flags); +}
...
Quoted 7 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +7
-0+static void jh8100_irq_mask (struct irq_data *d) +{ +struct jh8100_pinctrl *sfp =jh8100_from_irq_data (d); +const struct jh8100_gpio_irq_reg *irq_reg = sfp->info->irq_reg; +irq_hw_number_t gpio =irqd_to_hwirq (d); +void __iomem *ie = sfp->base + irq_reg->ie_reg_base + +4 * (gpio /32 );
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c line 776
Quoted 10 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +10
-0+u32 mask =BIT (gpio %32 ); +unsigned long flags; +u32 value; + +raw_spin_lock_irqsave (&sfp->lock, flags); + value =readl_relaxed (ie) & ~mask; +writel_relaxed (value, ie); +raw_spin_unlock_irqrestore (&sfp->lock, flags); + +gpiochip_disable_irq (&sfp->gc, d->hwirq);
You have gpio, why not use it here?
Quoted 1 line
+}
...
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c line 813
Quoted 12 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +12
-0+static void jh8100_irq_unmask (struct irq_data *d) +{ +struct jh8100_pinctrl *sfp =jh8100_from_irq_data (d); +const struct jh8100_gpio_irq_reg *irq_reg = sfp->info->irq_reg; +irq_hw_number_t gpio =irqd_to_hwirq (d); +void __iomem *ie = sfp->base + irq_reg->ie_reg_base + +4 * (gpio /32 ); +u32 mask =BIT (gpio %32 ); +unsigned long flags; +u32 value; + +gpiochip_enable_irq (&sfp->gc, d->hwirq);
Ditto.
Quoted 5 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +5
-0+raw_spin_lock_irqsave (&sfp->lock, flags); + value =readl_relaxed (ie) | mask; +writel_relaxed (value, ie); +raw_spin_unlock_irqrestore (&sfp->lock, flags); +}
...
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c line 890
Quoted 12 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +12
-0+static int jh8100_irq_set_wake (struct irq_data *d,unsigned int enable) +{ +struct jh8100_pinctrl *sfp =jh8100_from_irq_data (d); +int ret =0 ; + +if (enable) + ret =enable_irq_wake (sfp->wakeup_irq); +else + ret =disable_irq_wake (sfp->wakeup_irq); +if (ret) +dev_err (sfp->dev,"failed to %s wake-up interrupt\n" , + enable ?"enable" :"disable" );
str_enable_disable() (will require string_choices.h).
Quoted 2 lines
(quoted diff) +2
-0+ return ret; +}
...
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c line 899
Quoted 5 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +5
-0+static void jh8100_irq_print_chip (struct irq_data *d,struct seq_file *p) +{ +struct jh8100_pinctrl *sfp =jh8100_from_irq_data (d); + +seq_printf (p, sfp->gc.label);
This is bad. Use seq_puts() or proper formatting string.
Quoted 1 line
+}
...
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c line 950
Quoted 1 line
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +1
-0+writel_relaxed (~0U , sfp->base + sfp->info->irq_reg->ic_reg_base);
GENMASK() ?
...
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c line 953
Quoted 1 line
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +1
-0+writel_relaxed (~0U , sfp->base + sfp->info->irq_reg->ic1_reg_base);
Ditto.
...
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c line 979
Quoted 3 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +3
-0+ info =of_device_get_match_data (&pdev->dev); +if (!info) +return -ENODEV ;
Use device_get_match_data() from property.h.
...
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c line 991
Quoted 3 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +3
-0+ clk =devm_clk_get_optional (dev,NULL ); +if (IS_ERR (clk)) +return dev_err_probe (dev,PTR_ERR (clk),"could not get clock\n" );
Why not _enabled() variant?
...
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c line 1006
Quoted 2 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +2
-0+/* +* we don't want to assert reset and risk undoing pin muxing for the
We
Quoted 3 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +3
-0+* early boot serial console, but let's make sure the reset line is +* deasserted in case someone runs a really minimal bootloader. +*/
...
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c line 1037
Quoted 3 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +3
-0+ ret =devm_pinctrl_register_and_init (dev, + jh8100_pinctrl_desc, + sfp, &sfp->pctl);
Can occupy less lines.
Quoted 3 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +3
-0+if (ret) +return dev_err_probe (dev, ret, +"could not register pinctrl driver\n" );
...
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c line 1080
Quoted 1 line
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +1
-0+if (sfp->gc.ngpio >0 ) {
Is it really can be not true?
Quoted 6 lines
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c new file +6
-0+ ret =devm_gpiochip_add_data (dev, &sfp->gc, sfp); +if (ret) +return dev_err_probe (dev, ret,"could not register gpiochip\n" ); + +dev_info (dev,"StarFive JH8100 GPIO chip registered %d GPIOs\n" , sfp->gc.ngpio); + }
...
Quoted 7 lines
+/*
+ * Pinctrl / GPIO driver for StarFive JH8100 SoC
+ *
+ * Copyright (C) 2023-2024 StarFive Technology Co., Ltd.
+ * Author: Alex Soo <[email protected]>+ *
Unneeded blank line.
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.h line 11
Quoted 4 lines
+ */
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.h new file +3
-0+ +#ifndef __PINCTRL_STARFIVE_JH8100_H__ +#define __PINCTRL_STARFIVE_JH8100_H__
A lot of inclusions are missed, like
types.h
Quoted 1 line
+#include "
../core.h"
Some of the forward declarations are missed, like
struct device;
Quoted 1 line
+#endif /*
__PINCTRL_STARFIVE_JH8100_H__*/
Signature · 2 lines
With Best Regards, Andy Shevchenko
RFC PATCH v3 3/7 pinctrl: starfive: jh8100: add sys_west domain sub-driver
In reply to Alex SooAdd sys_west domain sub-driver.
--- drivers/pinctrl/starfive/Kconfig | 12 ++ drivers/pinctrl/starfive/Makefile | 1 + .../pinctrl-starfive-jh8100-sys-west.c | 164 ++++++++++++++++++ .../starfive/pinctrl-starfive-jh8100.c | 6 + .../starfive/pinctrl-starfive-jh8100.h | 5 + 5 files changed, 188 insertions(+) create mode 100644 drivers/pinctrl/starfive/pinctrl-starfive-jh8100-sys-west.c
drivers/pinctrl/starfive/Kconfig +12 -0
@@ -70,3 +70,15 @@ config PINCTRL_STARFIVE_JH8100_SYS_EAST This also provides an interface to the GPIO pins not used by other peripherals supporting inputs, outputs, configuring pull-up/pull-down and interrupts on input changes. + +config PINCTRL_STARFIVE_JH8100_SYS_WEST + tristate "StarFive JH8100 SoC System IOMUX-West pinctrl and GPIO driver" + depends on ARCH_STARFIVE || COMPILE_TEST + depends on OF + select PINCTRL_STARFIVE_JH8100 + default ARCH_STARFIVE + help + Say yes here to support system iomux-west pin control on the StarFive JH8100 SoC. + This also provides an interface to the GPIO pins not used by other + peripherals supporting inputs, outputs, configuring pull-up/pull-down + and interrupts on input changes.
drivers/pinctrl/starfive/Makefile +1 -0
@@ -8,3 +8,4 @@ obj-$(CONFIG_PINCTRL_STARFIVE_JH7110_AON) += pinctrl-starfive-jh7110-aon.o obj-$(CONFIG_PINCTRL_STARFIVE_JH8100) += pinctrl-starfive-jh8100.o obj-$(CONFIG_PINCTRL_STARFIVE_JH8100_SYS_EAST) += pinctrl-starfive-jh8100-sys-east.o +obj-$(CONFIG_PINCTRL_STARFIVE_JH8100_SYS_WEST) += pinctrl-starfive-jh8100-sys-west.o
drivers/pinctrl/starfive/pinctrl-starfive-jh8100-sys-west.c new file +164 -0
164 lines not on this page · raw message
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c +6 -0
@@ -333,6 +333,9 @@ static int jh8100_set_one_pin_mux(struct jh8100_pinctrl *sfp,if (!strcmp (sfp->info->name,JH8100_SYS_E_DOMAIN_NAME ) && pin < sfp->gc.ngpio && func ==1 )jh8100_set_function (sfp, pin, func); +else if (!strcmp (sfp->info->name,JH8100_SYS_W_DOMAIN_NAME ) && + pin < sfp->gc.ngpio -1 && func ==2 ) +jh8100_set_function (sfp, pin, func);return 0 ; }
@@ -410,6 +413,9 @@ static int jh8100_get_padcfg_base(struct jh8100_pinctrl *sfp,if (!strcmp (sfp->info->name,JH8100_SYS_E_DOMAIN_NAME )) {if (pin <JH8100_SYS_E_NGPIO )return JH8100_SYS_E_GPO_PDA_00_47_CFG ; + }else if (!strcmp (sfp->info->name,JH8100_SYS_W_DOMAIN_NAME )) { +if (pin <JH8100_SYS_W_NGPIO ) +return JH8100_SYS_W_GPO_PDA_00_15_CFG ; }return -ENXIO ;
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.h +5 -0
@@ -12,12 +12,16 @@#include "../core.h" +#define JH8100_SYS_W_DOMAIN_NAME "jh8100-sys-west"#define JH8100_SYS_E_DOMAIN_NAME "jh8100-sys-east" +#define JH8100_SYS_W_NGPIO 16#define JH8100_SYS_E_NGPIO 48 +#define JH8100_SYS_W_REG_NUM 44#define JH8100_SYS_E_REG_NUM 116 +#define JH8100_SYS_W_GPO_PDA_00_15_CFG 0x074#define JH8100_SYS_E_GPO_PDA_00_47_CFG 0x114struct jh8100_pinctrl {
@@ -30,6 +34,7 @@ struct jh8100_pinctrl {/* register read/write mutex */ struct mutex mutex;const struct jh8100_pinctrl_domain_info *info; +unsigned int jh8100_sys_west_regs[JH8100_SYS_W_REG_NUM ];unsigned int jh8100_sys_east_regs[JH8100_SYS_E_REG_NUM ];/* wakeup */ struct irq_domain *irq_domain;
Signature · 7 lines
2.25.1 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
RFC PATCH v3 4/7 pinctrl: starfive: jh8100: add sys_gmac domain sub-driver
In reply to Alex SooAdd sys_gmac domain sub-driver.
--- drivers/pinctrl/starfive/Kconfig | 12 +++ drivers/pinctrl/starfive/Makefile | 1 + .../pinctrl-starfive-jh8100-sys-gmac.c | 89 +++++++++++++++++++ .../starfive/pinctrl-starfive-jh8100.h | 4 + 4 files changed, 106 insertions(+) create mode 100644 drivers/pinctrl/starfive/pinctrl-starfive-jh8100-sys-gmac.c
drivers/pinctrl/starfive/Kconfig +12 -0
@@ -82,3 +82,15 @@ config PINCTRL_STARFIVE_JH8100_SYS_WEST This also provides an interface to the GPIO pins not used by other peripherals supporting inputs, outputs, configuring pull-up/pull-down and interrupts on input changes. + +config PINCTRL_STARFIVE_JH8100_SYS_GMAC + tristate "StarFive JH8100 SoC System IOMUX-GMAC pinctrl and GPIO driver" + depends on ARCH_STARFIVE || COMPILE_TEST + depends on OF + select PINCTRL_STARFIVE_JH8100 + default ARCH_STARFIVE + help + Say yes here to support system iomux-gmac pin control on the StarFive JH8100 SoC. + This provides syscon registers to indicate voltage level on SDIO1/GMAC1, to indicate + GMAC1 pads voltage level under different GMAC interface modes, and to configure + GMAC1 interface slew rate.
drivers/pinctrl/starfive/Makefile +1 -0
@@ -9,3 +9,4 @@ obj-$(CONFIG_PINCTRL_STARFIVE_JH7110_AON) += pinctrl-starfive-jh7110-aon.o obj-$(CONFIG_PINCTRL_STARFIVE_JH8100) += pinctrl-starfive-jh8100.o obj-$(CONFIG_PINCTRL_STARFIVE_JH8100_SYS_EAST) += pinctrl-starfive-jh8100-sys-east.o obj-$(CONFIG_PINCTRL_STARFIVE_JH8100_SYS_WEST) += pinctrl-starfive-jh8100-sys-west.o +obj-$(CONFIG_PINCTRL_STARFIVE_JH8100_SYS_GMAC) += pinctrl-starfive-jh8100-sys-gmac.o
drivers/pinctrl/starfive/pinctrl-starfive-jh8100-sys-gmac.c new file +89 -0
89 lines not on this page · raw message
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.h +4 -0
@@ -14,12 +14,15 @@#define JH8100_SYS_W_DOMAIN_NAME "jh8100-sys-west"#define JH8100_SYS_E_DOMAIN_NAME "jh8100-sys-east" +#define JH8100_SYS_G_DOMAIN_NAME "jh8100-sys-gmac"#define JH8100_SYS_W_NGPIO 16#define JH8100_SYS_E_NGPIO 48 +#define JH8100_SYS_G_NGPIO 0#define JH8100_SYS_W_REG_NUM 44#define JH8100_SYS_E_REG_NUM 116 +#define JH8100_SYS_G_REG_NUM 19#define JH8100_SYS_W_GPO_PDA_00_15_CFG 0x074#define JH8100_SYS_E_GPO_PDA_00_47_CFG 0x114
@@ -36,6 +39,7 @@ struct jh8100_pinctrl {const struct jh8100_pinctrl_domain_info *info;unsigned int jh8100_sys_west_regs[JH8100_SYS_W_REG_NUM ];unsigned int jh8100_sys_east_regs[JH8100_SYS_E_REG_NUM ]; +unsigned int jh8100_sys_gmac_regs[JH8100_SYS_G_REG_NUM ];/* wakeup */ struct irq_domain *irq_domain;struct gpio_desc *wakeup_gpio;
Signature · 7 lines
2.25.1 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
RFC PATCH v3 5/7 pinctrl: starfive: jh8100: add AON domain sub-driver
In reply to Alex SooAdd AON domain sub-driver.
--- MAINTAINERS | 7 + drivers/pinctrl/starfive/Kconfig | 14 ++ drivers/pinctrl/starfive/Makefile | 1 + .../starfive/pinctrl-starfive-jh8100-aon.c | 150 ++++++++++++++++++ .../starfive/pinctrl-starfive-jh8100.c | 3 + .../starfive/pinctrl-starfive-jh8100.h | 5 + 6 files changed, 180 insertions(+) create mode 100644 drivers/pinctrl/starfive/pinctrl-starfive-jh8100-aon.c
MAINTAINERS +7 -0
@@ -21125,6 +21125,13 @@ S: Maintained F: drivers/reset/starfive/reset-starfive-jh81* F: include/dt-bindings/reset/starfive?jh81*.h +STARFIVE JH8100 PINCTRL DRIVERS +M: Alex Soo <[email protected]> +S: Supported +F: Documentation/devicetree/bindings/pinctrl/starfive,jh81*.yaml +F: drivers/pinctrl/starfive/pinctrl-starfive-jh81* +F: include/dt-bindings/pinctrl/starfive,jh8100-pinctrl.h + STATIC BRANCH/CALL M: Peter Zijlstra <[email protected]> M: Josh Poimboeuf <[email protected]>
drivers/pinctrl/starfive/Kconfig +14 -0
@@ -94,3 +94,17 @@ config PINCTRL_STARFIVE_JH8100_SYS_GMAC This provides syscon registers to indicate voltage level on SDIO1/GMAC1, to indicate GMAC1 pads voltage level under different GMAC interface modes, and to configure GMAC1 interface slew rate. + +config PINCTRL_STARFIVE_JH8100_AON + tristate "Always-on pinctrl and GPIO driver for the StarFive JH8100 SoC" + depends on ARCH_STARFIVE || COMPILE_TEST + depends on OF + select PINCTRL_STARFIVE_JH8100 + default ARCH_STARFIVE + help + Say yes here to support always-on pin control on the StarFive JH8100 SoC. + This provides an interface to the RGPIO pins not used by other peripherals + supporting inputs, outputs, configuring pull-up/pull-down and interrupts + on input changes. And also, the syscon registers to indicate voltage level + on eMMC/SDIO0/XSPI/RGPIOs/GMAC0, to indicate GMAC0 pads voltage level under + different GMAC interface modes, and to configure GMAC0 interface slew rate.
drivers/pinctrl/starfive/Makefile +1 -0
@@ -10,3 +10,4 @@ obj-$(CONFIG_PINCTRL_STARFIVE_JH8100) += pinctrl-starfive-jh8100.o obj-$(CONFIG_PINCTRL_STARFIVE_JH8100_SYS_EAST) += pinctrl-starfive-jh8100-sys-east.o obj-$(CONFIG_PINCTRL_STARFIVE_JH8100_SYS_WEST) += pinctrl-starfive-jh8100-sys-west.o obj-$(CONFIG_PINCTRL_STARFIVE_JH8100_SYS_GMAC) += pinctrl-starfive-jh8100-sys-gmac.o +obj-$(CONFIG_PINCTRL_STARFIVE_JH8100_AON) += pinctrl-starfive-jh8100-aon.o
drivers/pinctrl/starfive/pinctrl-starfive-jh8100-aon.c new file +150 -0
150 lines not on this page · raw message
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.c +3 -0
@@ -416,6 +416,9 @@ static int jh8100_get_padcfg_base(struct jh8100_pinctrl *sfp, }else if (!strcmp (sfp->info->name,JH8100_SYS_W_DOMAIN_NAME )) {if (pin <JH8100_SYS_W_NGPIO )return JH8100_SYS_W_GPO_PDA_00_15_CFG ; + }else if (!strcmp (sfp->info->name,JH8100_AON_DOMAIN_NAME )) { +if (pin <JH8100_AON_NGPIO ) +return JH8100_AON_GPO_PDA_00_15_CFG ; }return -ENXIO ;
drivers/pinctrl/starfive/pinctrl-starfive-jh8100.h +5 -0
@@ -15,17 +15,21 @@#define JH8100_SYS_W_DOMAIN_NAME "jh8100-sys-west"#define JH8100_SYS_E_DOMAIN_NAME "jh8100-sys-east"#define JH8100_SYS_G_DOMAIN_NAME "jh8100-sys-gmac" +#define JH8100_AON_DOMAIN_NAME "jh8100-aon"#define JH8100_SYS_W_NGPIO 16#define JH8100_SYS_E_NGPIO 48#define JH8100_SYS_G_NGPIO 0 +#define JH8100_AON_NGPIO 16#define JH8100_SYS_W_REG_NUM 44#define JH8100_SYS_E_REG_NUM 116#define JH8100_SYS_G_REG_NUM 19 +#define JH8100_AON_REG_NUM 65#define JH8100_SYS_W_GPO_PDA_00_15_CFG 0x074#define JH8100_SYS_E_GPO_PDA_00_47_CFG 0x114 +#define JH8100_AON_GPO_PDA_00_15_CFG 0x90struct jh8100_pinctrl {struct device *dev;
@@ -40,6 +44,7 @@ struct jh8100_pinctrl {unsigned int jh8100_sys_west_regs[JH8100_SYS_W_REG_NUM ];unsigned int jh8100_sys_east_regs[JH8100_SYS_E_REG_NUM ];unsigned int jh8100_sys_gmac_regs[JH8100_SYS_G_REG_NUM ]; +unsigned int jh8100_aon_regs[JH8100_AON_REG_NUM ];/* wakeup */ struct irq_domain *irq_domain;struct gpio_desc *wakeup_gpio;
Signature · 1 line
2.25.1
RFC PATCH v3 6/7 gpiolib: enable GPIO interrupt to wake up a system from sleep
In reply to Alex SooAdd function gpiochip_wakeup_irq_setup() to configure and enable a GPIO pin with interrupt wakeup capability according to user-defined wakeup-gpios property in the device tree. Interrupt generated by toggling the logic level (rising/falling edge) on the specified GPIO pin can wake up a system from sleep mode.
--- drivers/gpio/gpiolib.c | 87 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+)
drivers/gpio/gpiolib.c +87 -0
@@ -19,6 +19,7 @@#include <linux/module.h> #include <linux/of.h> #include <linux/pinctrl/consumer.h> +#include <linux/pm_wakeirq.h> #include <linux/seq_file.h> #include <linux/slab.h> #include <linux/spinlock.h>
@@ -96,6 +97,7 @@ static void gpiochip_irqchip_remove(struct gpio_chip *gc);static int gpiochip_irqchip_init_hw (struct gpio_chip *gc);static int gpiochip_irqchip_init_valid_mask (struct gpio_chip *gc);static void gpiochip_irqchip_free_valid_mask (struct gpio_chip *gc); +static int gpiochip_wakeup_irq_setup (struct gpio_chip *gc);static bool gpiolib_initialized;
@@ -1045,8 +1047,15 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,if (ret) goto err_remove_irqchip; } + + ret =gpiochip_wakeup_irq_setup (gc); +if (ret) + goto err_remove_device; +return 0 ; +err_remove_device: +gcdev_unregister (gdev); err_remove_irqchip:gpiochip_irqchip_remove (gc); err_remove_irqchip_mask:
@@ -1874,6 +1883,84 @@ static int gpiochip_irqchip_add_allocated_domain(struct gpio_chip *gc,return 0 ; } +static irqreturn_t gpio_wake_irq_handler (int irq,void *data) +{ +struct irq_data *irq_data = data; + +if (!irq_data || irq != irq_data->irq) +return IRQ_NONE ; + +return IRQ_HANDLED ; +} + +static int gpiochip_wakeup_irq_setup (struct gpio_chip *gc) +{ +struct device *dev = gc->parent; +struct gpio_irq_chip *girq = &gc->irq; +struct gpio_desc *wakeup_gpiod; +struct irq_desc *wakeup_irqd; +struct irq_domain *irq_domain; +struct irq_data *irq_data; +unsigned int offset; +int wakeup_irq; +int ret; + +if (!(device_property_read_bool (dev,"wakeup-source" ))) +return 0 ; + + irq_domain = girq->domain; + +if (!irq_domain) { +dev_err (dev,"Couldn't allocate IRQ domain\n" ); +return -ENXIO ; + } + + wakeup_gpiod =devm_gpiod_get_optional (dev,"wakeup" ,GPIOD_IN ); + +if (IS_ERR (wakeup_gpiod)) { +dev_err (dev,"invalid wakeup gpio: %lu\n" ,PTR_ERR (wakeup_gpiod)); +return PTR_ERR (wakeup_gpiod); + } +if (!wakeup_gpiod) { +dev_dbg (dev,"property wakeup-gpios is not defined\n" ); +return 0 ; + } + + offset =gpio_chip_hwgpio (wakeup_gpiod); + wakeup_irq =gpiod_to_irq (wakeup_gpiod); +if (wakeup_irq <0 ) { +dev_err (dev,"failed to convert wakeup GPIO to IRQ\n" ); +return wakeup_irq; + } + irq_domain->ops->map (irq_domain, wakeup_irq, offset); + wakeup_irqd =irq_to_desc (wakeup_irq); + irq_data =irq_get_irq_data (wakeup_irq); + girq->handler = handle_edge_irq; + +if (!(wakeup_irqd->status_use_accessors &IRQ_NOREQUEST )) { +device_init_wakeup (dev,1 ); + ret =devm_request_threaded_irq (dev, wakeup_irq,NULL , + gpio_wake_irq_handler, +IRQF_TRIGGER_FALLING | +IRQF_TRIGGER_RISING | +IRQF_ONESHOT | +IRQF_SHARED , +"pm-wakeup-gpio" , irq_data); +if (ret) { +dev_err (dev,"unable to request wakeup IRQ: %d\n" , ret); +return ret; + } + } + + ret =dev_pm_set_wake_irq (dev, wakeup_irq); +if (ret) { +dev_err (dev,"failed to enable gpio irq wake\n" ); +return ret; + } + +return 0 ; +} +/** * gpiochip_add_irqchip() - adds an IRQ chip to a GPIO chip * @gc: the GPIO chip to add the IRQ chip to
Signature · 1 line
2.25.1
Re: [RFC PATCH v3 6/7] gpiolib: enable GPIO interrupt to wake up a system from sleep
Fri, May 03, 2024 at 07:14:35PM +0800, Alex Soo kirjoitti:
Quoted 5 lines
Add function
gpiochip_wakeup_irq_setup()to configure and enable a GPIO pin with interrupt wakeup capability according to user-defined wakeup-gpios property in the device tree. Interrupt generated by toggling the logic level (rising/falling edge) on the specified GPIO pin can wake up a system from sleep mode.
...
drivers/gpio/gpiolib.c static int gpiochip_irqchip_add_allocated_domain(struct gpio_chip *gc, · line 1890
Quoted 5 lines
drivers/gpio/gpiolib.c +5
-0+static irqreturn_t gpio_wake_irq_handler (int irq,void *data) +{ +struct irq_data *irq_data = data; + +if (!irq_data || irq != irq_data->irq)
Hmm... When irq_data can be NULL?
Quoted 4 lines
drivers/gpio/gpiolib.c +4
-0+return IRQ_NONE ; + +return IRQ_HANDLED ; +}
...
drivers/gpio/gpiolib.c static int gpiochip_irqchip_add_allocated_domain(struct gpio_chip *gc, · line 1908
Quoted 13 lines
drivers/gpio/gpiolib.c +13
-0+static int gpiochip_wakeup_irq_setup (struct gpio_chip *gc) +{ +struct device *dev = gc->parent; +struct gpio_irq_chip *girq = &gc->irq; +struct gpio_desc *wakeup_gpiod; +struct irq_desc *wakeup_irqd; +struct irq_domain *irq_domain; +struct irq_data *irq_data; +unsigned int offset; +int wakeup_irq; +int ret; + +if (!(device_property_read_bool (dev,"wakeup-source" )))
Too many parentheses.
drivers/gpio/gpiolib.c static int gpiochip_irqchip_add_allocated_domain(struct gpio_chip *gc, · line 1912
Quoted 5 lines
drivers/gpio/gpiolib.c +4
-0+return 0 ; + + irq_domain = girq->domain; +
Unneeded blank line. Ditto for all similar cases.
drivers/gpio/gpiolib.c static int gpiochip_irqchip_add_allocated_domain(struct gpio_chip *gc, · line 1915
Quoted 3 lines
drivers/gpio/gpiolib.c +3
-0+if (!irq_domain) { +dev_err (dev,"Couldn't allocate IRQ domain\n" ); +return -ENXIO ;
return dev_err_probe(...);
Ditto for all similar cases.
Quoted 1 line
(quoted diff) +1
-0+ }
...
Quoted 11 lines
drivers/gpio/gpiolib.c +11
-0+ wakeup_gpiod =devm_gpiod_get_optional (dev,"wakeup" ,GPIOD_IN ); + +if (IS_ERR (wakeup_gpiod)) { +dev_err (dev,"invalid wakeup gpio: %lu\n" ,PTR_ERR (wakeup_gpiod)); +return PTR_ERR (wakeup_gpiod); + } +if (!wakeup_gpiod) { +dev_dbg (dev,"property wakeup-gpios is not defined\n" ); +return 0 ; + } +
drivers/gpio/gpiolib.c static int gpiochip_irqchip_add_allocated_domain(struct gpio_chip *gc, · line 1937
Quoted 10 lines
drivers/gpio/gpiolib.c +9
-0+ offset =gpio_chip_hwgpio (wakeup_gpiod); + wakeup_irq =gpiod_to_irq (wakeup_gpiod); +if (wakeup_irq <0 ) { +dev_err (dev,"failed to convert wakeup GPIO to IRQ\n" ); +return wakeup_irq; + } + irq_domain->ops->map (irq_domain, wakeup_irq, offset); + wakeup_irqd =irq_to_desc (wakeup_irq); + irq_data =irq_get_irq_data (wakeup_irq);
What these lines are for?
drivers/gpio/gpiolib.c static int gpiochip_irqchip_add_allocated_domain(struct gpio_chip *gc, · line 1945
Quoted 9 lines
drivers/gpio/gpiolib.c +8
-0+ girq->handler = handle_edge_irq; + +if (!(wakeup_irqd->status_use_accessors &IRQ_NOREQUEST )) { +device_init_wakeup (dev,1 ); + ret = devm_request_threaded_irq(dev, wakeup_irq, NULL, + gpio_wake_irq_handler, + IRQF_TRIGGER_FALLING | + IRQF_TRIGGER_RISING |
What's wrong with the flags from DT?
Quoted 8 lines
drivers/gpio/gpiolib.c +8
-0+IRQF_ONESHOT | +IRQF_SHARED , + "pm-wakeup-gpio", irq_data); +if (ret) { +dev_err (dev,"unable to request wakeup IRQ: %d\n" , ret); +return ret; + } + }
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [RFC PATCH v3 6/7] gpiolib: enable GPIO interrupt to wake up a system from sleep
In reply to Alex SooQuoted 7 lines · Alex Soo
Add function
gpiochip_wakeup_irq_setup()to configure and enable a GPIO pin with interrupt wakeup capability according to user-defined wakeup-gpios property in the device tree. Interrupt generated by toggling the logic level (rising/falling edge) on the specified GPIO pin can wake up a system from sleep mode.Signed-off-by Alex Soo <[email protected]>
This is a very helpful patch I think.
I'm looking forward to the next iteration.
drivers/gpio/gpiolib.c int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data, · line 1053
Quoted 8 lines
drivers/gpio/gpiolib.c +4
-0@@ -1045,8 +1047,15 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,if (ret) goto err_remove_irqchip; } + + ret =gpiochip_wakeup_irq_setup (gc); +if (ret) + goto err_remove_device;
Do we have any in-tree drivers that do this by themselves already?
In that case we should convert them to use this function in the same patch to avoid regressions.
drivers/gpio/gpiolib.c static int gpiochip_irqchip_add_allocated_domain(struct gpio_chip *gc, · line 1888
Quoted 3 lines
drivers/gpio/gpiolib.c +3
-0+static irqreturn_t gpio_wake_irq_handler (int irq,void *data) +{ +struct irq_data *irq_data = data;
I'm minimalist so I usually just call the parameter "d" instead of "data" and irq_data I would call *id but it's your pick.
drivers/gpio/gpiolib.c static int gpiochip_irqchip_add_allocated_domain(struct gpio_chip *gc, · line 1893
Quoted 5 lines
drivers/gpio/gpiolib.c +5
-0+ +if (!irq_data || irq != irq_data->irq) +return IRQ_NONE ; + +return IRQ_HANDLED ;
Please add some debug print:
struct gpio_chip *gc = irq_data->chip_data;
chip_dbg(gc, "GPIO wakeup on IRQ %d\n", irq);
The rest looks good to me (after fixing Andy's comments!)
I would perhaps put some
debug print that "GPIO wakeup enabled at offset %d" in the end as well, so people can easily follow this in the debug prints.
Yours,
Linus Walleij
RFC PATCH v3 7/7 riscv: dts: starfive: jh8100: add pinctrl device tree nodes
In reply to Alex SooAdd pinctrl_east/pinctrl_west/pinctrl_gmac/pinctrl_aon device tree nodes for JH8100 SoC.
--- arch/riscv/boot/dts/starfive/jh8100-evb.dts | 7 + arch/riscv/boot/dts/starfive/jh8100-pinfunc.h | 504 ++++++++++++++++++ arch/riscv/boot/dts/starfive/jh8100.dtsi | 46 ++ 3 files changed, 557 insertions(+) create mode 100644 arch/riscv/boot/dts/starfive/jh8100-pinfunc.h
arch/riscv/boot/dts/starfive/jh8100-evb.dts +7 -0
@@ -4,6 +4,8 @@ */ #include "jh8100.dtsi" +#include "jh8100-pinfunc.h" +#include <dt-bindings/pinctrl/starfive,jh8100-pinctrl.h> / { model = "StarFive JH8100 EVB";
@@ -26,3 +28,8 @@ memory@40000000 { &uart0 { status = "okay"; }; + +&pinctrl_aon { + wakeup-gpios = <&pinctrl_aon PAD_RGPIO1 GPIO_ACTIVE_HIGH>; + wakeup-source; +};
arch/riscv/boot/dts/starfive/jh8100-pinfunc.h new file +504 -0
504 lines not on this page · raw message
arch/riscv/boot/dts/starfive/jh8100.dtsi +46 -0
76 lines not on this page · raw message
Signature · 1 line
2.25.1
Quoted 9 lines · Alex Soo
Starfive JH8100 SoC consists of 4 pinctrl domains -
sys_east,sys_west,sys_gmac, and aon. This patch series adds pinctrl drivers for these 4 pinctrl domains and this patch series is depending on the JH8100 base patch series in [1] and [2]. The relevant dt-binding documentation for each pinctrl domain has been updated accordingly.[1] https://lore.kernel.org/lkml/[email protected]/
[2] https://lore.kernel.org/lkml/[email protected]/
v3 is starting to look very nice, why is this patch set still in "RFC"?
I would like some proper review from the StarFive maintainers at this point so we can get it finished.
Yours,
Linus Walleij
Quoted 34 lines
-----Original Message-----
From: Linus Walleij <[email protected]>
Sent: Monday, May 6, 2024 2:35 PM
To: Yuklin Soo <[email protected]>
Cc: Bartosz Golaszewski <[email protected]>; Hal Feng <[email protected]>; Leyfoon Tan <[email protected]>; Jianlong Huang <[email protected]>; Emil Renner Berthing <[email protected]>; Rob Herring <[email protected]>; Krzysztof Kozlowski <[email protected]>; Conor Dooley <[email protected]>; Drew Fustini <[email protected]>; [email protected]; linux- [email protected]; [email protected]; linux- [email protected]; Paul Walmsley <[email protected]>; Palmer Dabbelt <[email protected]>; Albert Ou <[email protected]>
Subject: Re: [RFC PATCH v3 0/7] Add Pinctrl driver for Starfive JH8100 SoCQuoted 11 lines · Alex Soo
Starfive JH8100 SoC consists of 4 pinctrl domains -
sys_east,sys_west,sys_gmac, and aon. This patch series adds pinctrl drivers for these 4 pinctrl domains and this patch series is depending on the JH8100 base patch series in [1] and [2].
The relevant dt-binding documentation for each pinctrl domain has been updated accordingly.[1]
https://lore.kernel.org/lkml/20231201121410.95298-1-jeeheng.sia@starfi
vetech.com/ [2]
https://lore.kernel.org/lkml/20231206115000.295825-1-jeeheng.sia@starf
Quoted 1 line
ivetech.com/
Quoted 7 lines
v3 is starting to look very nice, why is this patch set still in "RFC"?
I would like some proper review from the StarFive maintainers at this point so we can get it finished.
Yours,
Linus Walleij
Hi Linus
Thanks for reviewing the patches.
There is a discussion in another thread about the JH8100 SoC being validated on FPGA/Emulation only now. The suggestion is to send the patches as "RFC" before the real silicon availability.
https://patchew.org/linux/[email protected]/[email protected]/
Regards
Ley Foon
Conor Dooley
maintainerQuoted 42 lines · Leyfoon Tan
Quoted 34 lines
-----Original Message-----
From: Linus Walleij <[email protected]>
Sent: Monday, May 6, 2024 2:35 PM
To: Yuklin Soo <[email protected]>
Cc: Bartosz Golaszewski <[email protected]>; Hal Feng <[email protected]>; Leyfoon Tan <[email protected]>; Jianlong Huang <[email protected]>; Emil Renner Berthing <[email protected]>; Rob Herring <[email protected]>; Krzysztof Kozlowski <[email protected]>; Conor Dooley <[email protected]>; Drew Fustini <[email protected]>; [email protected]; linux- [email protected]; [email protected]; linux- [email protected]; Paul Walmsley <[email protected]>; Palmer Dabbelt <[email protected]>; Albert Ou <[email protected]>
Subject: Re: [RFC PATCH v3 0/7] Add Pinctrl driver for Starfive JH8100 SoCQuoted 11 lines · Alex Soo
Starfive JH8100 SoC consists of 4 pinctrl domains -
sys_east,sys_west,sys_gmac, and aon. This patch series adds pinctrl drivers for these 4 pinctrl domains and this patch series is depending on the JH8100 base patch series in [1] and [2].
The relevant dt-binding documentation for each pinctrl domain has been updated accordingly.[1]
https://lore.kernel.org/lkml/20231201121410.95298-1-jeeheng.sia@starfi
vetech.com/ [2]
https://lore.kernel.org/lkml/20231206115000.295825-1-jeeheng.sia@starf
Quoted 1 line
ivetech.com/
Quoted 7 lines
v3 is starting to look very nice, why is this patch set still in "RFC"?
I would like some proper review from the StarFive maintainers at this point so we can get it finished.
Yours,
Linus Walleij
Quoted 7 lines
Hi Linus
Thanks for reviewing the patches.
There is a discussion in another thread about the JH8100 SoC being validated on FPGA/Emulation only now. The suggestion is to send the patches as "RFC" before the real silicon availability.
https://patchew.org/linux/[email protected]/[email protected]/
I know I said "drivers" in that mail you link to, but I was mostly concerned about binding headers etc, of which I think there are actually none here, so see my reply to this thread a few days ago:
https://lore.kernel.org/all/20240503-undress-mantra-e5e46b2f6360@spud/
Fri, May 03, 2024 at 07:14:29PM +0800, Alex Soo kirjoitti:
Quoted 6 lines
Starfive JH8100 SoC consists of 4 pinctrl domains -
sys_east,sys_west,sys_gmac, and aon. This patch series adds pinctrl drivers for these 4 pinctrl domains and this patch series is depending on the JH8100 base patch series in [1] and [2]. The relevant dt-binding documentation for each pinctrl domain has been updated accordingly.
I commented one of pinctrl: prefixed patch, but it looks like the same comments are applicable to all of them.
Signature · 2 lines
With Best Regards, Andy Shevchenko