riscv: sophgo: Add pinctrl support for SG2042
Subsystems (5)
Inochi Amaoto
maintainerv2 cover riscv: sophgo: Add pinctrl support for SG2042
SG2042 has a simple pinctrl device for all configurable pins. It supports setting pull up/down, drive strength and input schmitt trigger.
Add support for SG2042 and SG2044 pinctrl device.
Changed from v1:
- https://lore.kernel.org/all/[email protected]/
1. Fix the binding documentation error.
2. Refactor the cv18xx code so SG2042 can uses the same code.
3. Add SG2044 pinctrl support as it has the same layout.
Inochi Amaoto (8):
pinctrl: sophgo: avoid to modify untouched bit when setting cv1800
pinconf
pinctrl: sophgo: introduce generic data structure for cv18xx pinctrl
driver
pinctrl: sophgo: generalize shareable code of cv18xx pinctrl driver
pinctrl: sophgo: introduce generic probe function
dt-bindings: pinctrl: Add pinctrl for Sophgo SG2042 series SoC
pinctrl: sophgo: add support for SG2042 SoC
pinctrl: sophgo: add support for SG2044 SoC
riscv: dts: sophgo: sg2042: add pinctrl support
.../pinctrl/sophgo,sg2042-pinctrl.yaml | 129 ++++ .../boot/dts/sophgo/sg2042-milkv-pioneer.dts | 72 ++ arch/riscv/boot/dts/sophgo/sg2042.dtsi | 6 + drivers/pinctrl/sophgo/Kconfig | 46 +- drivers/pinctrl/sophgo/Makefile | 8 +- drivers/pinctrl/sophgo/pinctrl-cv1800b.c | 27 +- drivers/pinctrl/sophgo/pinctrl-cv1812h.c | 27 +- drivers/pinctrl/sophgo/pinctrl-cv18xx.c | 602 ++++----------- drivers/pinctrl/sophgo/pinctrl-cv18xx.h | 66 +- drivers/pinctrl/sophgo/pinctrl-sg2000.c | 27 +- drivers/pinctrl/sophgo/pinctrl-sg2002.c | 27 +- drivers/pinctrl/sophgo/pinctrl-sg2042-ops.c | 296 ++++++++ drivers/pinctrl/sophgo/pinctrl-sg2042.c | 655 ++++++++++++++++ drivers/pinctrl/sophgo/pinctrl-sg2042.h | 49 ++ drivers/pinctrl/sophgo/pinctrl-sg2044.c | 718 ++++++++++++++++++ .../pinctrl/sophgo/pinctrl-sophgo-common.c | 451 +++++++++++ drivers/pinctrl/sophgo/pinctrl-sophgo.h | 136 ++++ include/dt-bindings/pinctrl/pinctrl-sg2042.h | 196 +++++ include/dt-bindings/pinctrl/pinctrl-sg2044.h | 221 ++++++ 19 files changed, 3217 insertions(+), 542 deletions(-) create mode 100644 Documentation/devicetree/bindings/pinctrl/sophgo,sg2042-pinctrl.yaml create mode 100644 drivers/pinctrl/sophgo/pinctrl-sg2042-ops.c create mode 100644 drivers/pinctrl/sophgo/pinctrl-sg2042.c create mode 100644 drivers/pinctrl/sophgo/pinctrl-sg2042.h create mode 100644 drivers/pinctrl/sophgo/pinctrl-sg2044.c create mode 100644 drivers/pinctrl/sophgo/pinctrl-sophgo-common.c create mode 100644 drivers/pinctrl/sophgo/pinctrl-sophgo.h create mode 100644 include/dt-bindings/pinctrl/pinctrl-sg2042.h create mode 100644 include/dt-bindings/pinctrl/pinctrl-sg2044.h
--
2.48.1
Inochi Amaoto
maintainerPATCH v2 1/8 pinctrl: sophgo: avoid to modify untouched bit when setting cv1800 pinconf
When setting pinconf configuration for cv1800 SoC, the driver just writes the value. It may zero some bits of the pinconf register and cause some unexpected error. Add a mask to avoid this.
--- drivers/pinctrl/sophgo/pinctrl-cv18xx.c | 33 +++++++++++++++++-------- 1 file changed, 23 insertions(+), 10 deletions(-)
drivers/pinctrl/sophgo/pinctrl-cv18xx.c +23 -10
@@ -574,10 +574,10 @@ static int cv1800_pinconf_compute_config(struct cv1800_pinctrl *pctrl,struct cv1800_pin *pin, unsigned long *configs, unsigned int num_configs, - u32 *value) + u32 *value, u32 *mask) { int i; -u32 v =0 ; +u32 v =0 , m =0 ;enum cv1800_pin_io_type type;int ret;
@@ -596,10 +596,12 @@ static int cv1800_pinconf_compute_config(struct cv1800_pinctrl *pctrl,case PIN_CONFIG_BIAS_PULL_DOWN : v &= ~PIN_IO_PULLDOWN ; v |=FIELD_PREP (PIN_IO_PULLDOWN , arg); + m |=PIN_IO_PULLDOWN ;break ;case PIN_CONFIG_BIAS_PULL_UP : v &= ~PIN_IO_PULLUP ; v |=FIELD_PREP (PIN_IO_PULLUP , arg); + m |=PIN_IO_PULLUP ;break ;case PIN_CONFIG_DRIVE_STRENGTH_UA : ret =cv1800_pinctrl_oc2reg (pctrl, pin, arg);
@@ -607,6 +609,7 @@ static int cv1800_pinconf_compute_config(struct cv1800_pinctrl *pctrl,return ret; v &= ~PIN_IO_DRIVE ; v |=FIELD_PREP (PIN_IO_DRIVE , ret); + m |=PIN_IO_DRIVE ;break ;case PIN_CONFIG_INPUT_SCHMITT_UV : ret =cv1800_pinctrl_schmitt2reg (pctrl, pin, arg);
@@ -614,6 +617,7 @@ static int cv1800_pinconf_compute_config(struct cv1800_pinctrl *pctrl,return ret; v &= ~PIN_IO_SCHMITT ; v |=FIELD_PREP (PIN_IO_SCHMITT , ret); + m |=PIN_IO_SCHMITT ;break ;case PIN_CONFIG_POWER_SOURCE :/* Ignore power source as it is always fixed */
@@ -621,10 +625,12 @@ static int cv1800_pinconf_compute_config(struct cv1800_pinctrl *pctrl,case PIN_CONFIG_SLEW_RATE : v &= ~PIN_IO_OUT_FAST_SLEW ; v |=FIELD_PREP (PIN_IO_OUT_FAST_SLEW , arg); + m |=PIN_IO_OUT_FAST_SLEW ;break ;case PIN_CONFIG_BIAS_BUS_HOLD : v &= ~PIN_IO_BUS_HOLD ; v |=FIELD_PREP (PIN_IO_BUS_HOLD , arg); + m |=PIN_IO_BUS_HOLD ;break ;default :return -ENOTSUPP ;
@@ -632,17 +638,19 @@ static int cv1800_pinconf_compute_config(struct cv1800_pinctrl *pctrl, } *value = v; + *mask = m;return 0 ; }static int cv1800_pin_set_config (struct cv1800_pinctrl *pctrl,unsigned int pin_id, -u32 value) +u32 value,u32 mask) {struct cv1800_pin *pin =cv1800_get_pin (pctrl, pin_id);unsigned long flags;void __iomem *addr; +u32 reg;if (!pin)return -EINVAL ;
@@ -650,7 +658,10 @@ static int cv1800_pin_set_config(struct cv1800_pinctrl *pctrl, addr =cv1800_pinctrl_get_component_addr (pctrl, &pin->conf);raw_spin_lock_irqsave (&pctrl->lock, flags); -writel (value, addr); + reg =readl (addr); + reg &= ~mask; + reg |= value; +writel (reg, addr);raw_spin_unlock_irqrestore (&pctrl->lock, flags);return 0 ;
@@ -662,16 +673,17 @@ static int cv1800_pconf_set(struct pinctrl_dev *pctldev, {struct cv1800_pinctrl *pctrl =pinctrl_dev_get_drvdata (pctldev);struct cv1800_pin *pin =cv1800_get_pin (pctrl, pin_id); -u32 value; +u32 value, mask;if (!pin)return -ENODEV ;if (cv1800_pinconf_compute_config (pctrl, pin, - configs, num_configs, &value)) + configs, num_configs, + &value, &mask))return -ENOTSUPP ; -return cv1800_pin_set_config (pctrl, pin_id, value); +return cv1800_pin_set_config (pctrl, pin_id, value, mask); } static int cv1800_pconf_group_set(struct pinctrl_dev *pctldev,
@@ -682,7 +694,7 @@ static int cv1800_pconf_group_set(struct pinctrl_dev *pctldev,struct cv1800_pinctrl *pctrl =pinctrl_dev_get_drvdata (pctldev);const struct group_desc *group;const struct cv1800_pin_mux_config *pinmuxs; -u32 value; +u32 value, mask;int i; group =pinctrl_generic_get_group (pctldev, gsel);
@@ -692,11 +704,12 @@ static int cv1800_pconf_group_set(struct pinctrl_dev *pctldev, pinmuxs = group->data;if (cv1800_pinconf_compute_config (pctrl, pinmuxs[0 ].pin, - configs, num_configs, &value)) + configs, num_configs, + &value, &mask))return -ENOTSUPP ;for (i =0 ; i < group->grp.npins; i++) -cv1800_pin_set_config (pctrl, group->grp.pins[i], value); +cv1800_pin_set_config (pctrl, group->grp.pins[i], value, mask);return 0 ; }
Signature · 1 line
2.48.1
Inochi Amaoto
maintainerPATCH v2 2/8 pinctrl: sophgo: introduce generic data structure for cv18xx pinctrl driver
In reply to Inochi AmaotoTo share DT parsing and vddio code, it is necessary to introduce some generic data structure to abstract the different cv18xx series and the incoming sg2042 series.
--- drivers/pinctrl/sophgo/pinctrl-cv1800b.c | 21 +- drivers/pinctrl/sophgo/pinctrl-cv1812h.c | 21 +- drivers/pinctrl/sophgo/pinctrl-cv18xx.c | 243 ++++++++++++----------- drivers/pinctrl/sophgo/pinctrl-cv18xx.h | 61 ++---- drivers/pinctrl/sophgo/pinctrl-sg2000.c | 21 +- drivers/pinctrl/sophgo/pinctrl-sg2002.c | 21 +- drivers/pinctrl/sophgo/pinctrl-sophgo.h | 66 ++++++ 7 files changed, 270 insertions(+), 184 deletions(-) create mode 100644 drivers/pinctrl/sophgo/pinctrl-sophgo.h
drivers/pinctrl/sophgo/pinctrl-cv1800b.c +13 -8
@@ -34,8 +34,9 @@ static const char *const cv1800b_power_domain_desc[] = { [VDDIO_SD0_SPI] = "VDDIO_SD0_SPI", }; -static int cv1800b_get_pull_up (struct cv1800_pin *pin,const u32 *psmap) +static int cv1800b_get_pull_up (const struct sophgo_pin *sp,const u32 *psmap) { +const struct cv1800_pin *pin =sophgo_to_cv1800_pin (sp);u32 pstate = psmap[pin->power_domain];enum cv1800_pin_io_type type =cv1800_pin_io_type (pin);
@@ -54,8 +55,9 @@ static int cv1800b_get_pull_up(struct cv1800_pin *pin, const u32 *psmap)return -ENOTSUPP ; } -static int cv1800b_get_pull_down (struct cv1800_pin *pin,const u32 *psmap) +static int cv1800b_get_pull_down (const struct sophgo_pin *sp,const u32 *psmap) { +const struct cv1800_pin *pin =sophgo_to_cv1800_pin (sp);u32 pstate = psmap[pin->power_domain];enum cv1800_pin_io_type type =cv1800_pin_io_type (pin);
@@ -108,9 +110,10 @@ static const u32 cv1800b_eth_oc_map[] = { 17800 }; -static int cv1800b_get_oc_map (struct cv1800_pin *pin,const u32 *psmap, +static int cv1800b_get_oc_map (const struct sophgo_pin *sp,const u32 *psmap,const u32 **map) { +const struct cv1800_pin *pin =sophgo_to_cv1800_pin (sp);enum cv1800_pin_io_type type =cv1800_pin_io_type (pin);u32 pstate = psmap[pin->power_domain];
@@ -153,9 +156,10 @@ static const u32 cv1800b_18od33_3v3_schmitt_map[] = { 1100000 }; -static int cv1800b_get_schmitt_map (struct cv1800_pin *pin,const u32 *psmap, +static int cv1800b_get_schmitt_map (const struct sophgo_pin *sp,const u32 *psmap,const u32 **map) { +const struct cv1800_pin *pin =sophgo_to_cv1800_pin (sp);enum cv1800_pin_io_type type =cv1800_pin_io_type (pin);u32 pstate = psmap[pin->power_domain];
@@ -177,11 +181,11 @@ static int cv1800b_get_schmitt_map(struct cv1800_pin *pin, const u32 *psmap,return -ENOTSUPP ; } -static const struct cv1800_vddio_cfg_ops cv1800b_vddio_cfg_ops = { +static const struct sophgo_vddio_cfg_ops cv1800b_vddio_cfg_ops = { .get_pull_up = cv1800b_get_pull_up, .get_pull_down = cv1800b_get_pull_down, .get_oc_map = cv1800b_get_oc_map, - .get_schmitt_map = cv1800b_get_schmitt_map, + .get_schmitt_map = cv1800b_get_schmitt_map, };static const struct pinctrl_pin_desc cv1800b_pins[] = {
@@ -433,13 +437,14 @@ static const struct cv1800_pin cv1800b_pin_data[ARRAY_SIZE(cv1800b_pins)] = { CV1800_PINCONF_AREA_SYS, 0x120, 5), }; -static const struct cv1800_pinctrl_data cv1800b_pindata = { +static const struct sophgo_pinctrl_data cv1800b_pindata = { .pins = cv1800b_pins, .pindata = cv1800b_pin_data, .pdnames = cv1800b_power_domain_desc, .vddio_ops = &cv1800b_vddio_cfg_ops, .npins =ARRAY_SIZE (cv1800b_pins), - .npd =ARRAY_SIZE (cv1800b_power_domain_desc), + .npds =ARRAY_SIZE (cv1800b_power_domain_desc), + .pinsize =sizeof (struct cv1800_pin ), };static const struct of_device_id cv1800b_pinctrl_ids[] = {
drivers/pinctrl/sophgo/pinctrl-cv1812h.c +13 -8
@@ -40,8 +40,9 @@ static const char *const cv1812h_power_domain_desc[] = { [VDDIO_VIVO] = "VDDIO_VIVO", }; -static int cv1812h_get_pull_up (struct cv1800_pin *pin,const u32 *psmap) +static int cv1812h_get_pull_up (const struct sophgo_pin *sp,const u32 *psmap) { +const struct cv1800_pin *pin =sophgo_to_cv1800_pin (sp);u32 pstate = psmap[pin->power_domain];enum cv1800_pin_io_type type =cv1800_pin_io_type (pin);
@@ -60,8 +61,9 @@ static int cv1812h_get_pull_up(struct cv1800_pin *pin, const u32 *psmap)return -ENOTSUPP ; } -static int cv1812h_get_pull_down (struct cv1800_pin *pin,const u32 *psmap) +static int cv1812h_get_pull_down (const struct sophgo_pin *sp,const u32 *psmap) { +const struct cv1800_pin *pin =sophgo_to_cv1800_pin (sp);u32 pstate = psmap[pin->power_domain];enum cv1800_pin_io_type type =cv1800_pin_io_type (pin);
@@ -114,9 +116,10 @@ static const u32 cv1812h_eth_oc_map[] = { 17800 }; -static int cv1812h_get_oc_map (struct cv1800_pin *pin,const u32 *psmap, +static int cv1812h_get_oc_map (const struct sophgo_pin *sp,const u32 *psmap,const u32 **map) { +const struct cv1800_pin *pin =sophgo_to_cv1800_pin (sp);enum cv1800_pin_io_type type =cv1800_pin_io_type (pin);u32 pstate = psmap[pin->power_domain];
@@ -159,9 +162,10 @@ static const u32 cv1812h_18od33_3v3_schmitt_map[] = { 1100000 }; -static int cv1812h_get_schmitt_map (struct cv1800_pin *pin,const u32 *psmap, +static int cv1812h_get_schmitt_map (const struct sophgo_pin *sp,const u32 *psmap,const u32 **map) { +const struct cv1800_pin *pin =sophgo_to_cv1800_pin (sp);enum cv1800_pin_io_type type =cv1800_pin_io_type (pin);u32 pstate = psmap[pin->power_domain];
@@ -183,11 +187,11 @@ static int cv1812h_get_schmitt_map(struct cv1800_pin *pin, const u32 *psmap,return -ENOTSUPP ; } -static const struct cv1800_vddio_cfg_ops cv1812h_vddio_cfg_ops = { +static const struct sophgo_vddio_cfg_ops cv1812h_vddio_cfg_ops = { .get_pull_up = cv1812h_get_pull_up, .get_pull_down = cv1812h_get_pull_down, .get_oc_map = cv1812h_get_oc_map, - .get_schmitt_map = cv1812h_get_schmitt_map, + .get_schmitt_map = cv1812h_get_schmitt_map, };static const struct pinctrl_pin_desc cv1812h_pins[] = {
@@ -742,13 +746,14 @@ static const struct cv1800_pin cv1812h_pin_data[ARRAY_SIZE(cv1812h_pins)] = { CV1800_PINCONF_AREA_RTC, 0x028), }; -static const struct cv1800_pinctrl_data cv1812h_pindata = { +static const struct sophgo_pinctrl_data cv1812h_pindata = { .pins = cv1812h_pins, .pindata = cv1812h_pin_data, .pdnames = cv1812h_power_domain_desc, .vddio_ops = &cv1812h_vddio_cfg_ops, .npins =ARRAY_SIZE (cv1812h_pins), - .npd =ARRAY_SIZE (cv1812h_power_domain_desc), + .npds =ARRAY_SIZE (cv1812h_power_domain_desc), + .pinsize =sizeof (struct cv1800_pin ), };static const struct of_device_id cv1812h_pinctrl_ids[] = {
drivers/pinctrl/sophgo/pinctrl-cv18xx.c +131 -112
547 lines not on this page · raw message
drivers/pinctrl/sophgo/pinctrl-cv18xx.h +21 -40
110 lines not on this page · raw message
drivers/pinctrl/sophgo/pinctrl-sg2000.c +13 -8
@@ -40,8 +40,9 @@ static const char *const sg2000_power_domain_desc[] = { [VDDIO_VIVO] = "VDDIO_VIVO", }; -static int sg2000_get_pull_up (struct cv1800_pin *pin,const u32 *psmap) +static int sg2000_get_pull_up (const struct sophgo_pin *sp,const u32 *psmap) { +const struct cv1800_pin *pin =sophgo_to_cv1800_pin (sp);u32 pstate = psmap[pin->power_domain];enum cv1800_pin_io_type type =cv1800_pin_io_type (pin);
@@ -60,8 +61,9 @@ static int sg2000_get_pull_up(struct cv1800_pin *pin, const u32 *psmap)return -ENOTSUPP ; } -static int sg2000_get_pull_down (struct cv1800_pin *pin,const u32 *psmap) +static int sg2000_get_pull_down (const struct sophgo_pin *sp,const u32 *psmap) { +const struct cv1800_pin *pin =sophgo_to_cv1800_pin (sp);u32 pstate = psmap[pin->power_domain];enum cv1800_pin_io_type type =cv1800_pin_io_type (pin);
@@ -114,9 +116,10 @@ static const u32 sg2000_eth_oc_map[] = { 17800 }; -static int sg2000_get_oc_map (struct cv1800_pin *pin,const u32 *psmap, +static int sg2000_get_oc_map (const struct sophgo_pin *sp,const u32 *psmap,const u32 **map) { +const struct cv1800_pin *pin =sophgo_to_cv1800_pin (sp);enum cv1800_pin_io_type type =cv1800_pin_io_type (pin);u32 pstate = psmap[pin->power_domain];
@@ -159,9 +162,10 @@ static const u32 sg2000_18od33_3v3_schmitt_map[] = { 1100000 }; -static int sg2000_get_schmitt_map (struct cv1800_pin *pin,const u32 *psmap, +static int sg2000_get_schmitt_map (const struct sophgo_pin *sp,const u32 *psmap,const u32 **map) { +const struct cv1800_pin *pin =sophgo_to_cv1800_pin (sp);enum cv1800_pin_io_type type =cv1800_pin_io_type (pin);u32 pstate = psmap[pin->power_domain];
@@ -183,11 +187,11 @@ static int sg2000_get_schmitt_map(struct cv1800_pin *pin, const u32 *psmap,return -ENOTSUPP ; } -static const struct cv1800_vddio_cfg_ops sg2000_vddio_cfg_ops = { +static const struct sophgo_vddio_cfg_ops sg2000_vddio_cfg_ops = { .get_pull_up = sg2000_get_pull_up, .get_pull_down = sg2000_get_pull_down, .get_oc_map = sg2000_get_oc_map, - .get_schmitt_map = sg2000_get_schmitt_map, + .get_schmitt_map = sg2000_get_schmitt_map, };static const struct pinctrl_pin_desc sg2000_pins[] = {
@@ -742,13 +746,14 @@ static const struct cv1800_pin sg2000_pin_data[ARRAY_SIZE(sg2000_pins)] = { CV1800_PINCONF_AREA_RTC, 0x028), }; -static const struct cv1800_pinctrl_data sg2000_pindata = { +static const struct sophgo_pinctrl_data sg2000_pindata = { .pins = sg2000_pins, .pindata = sg2000_pin_data, .pdnames = sg2000_power_domain_desc, .vddio_ops = &sg2000_vddio_cfg_ops, .npins =ARRAY_SIZE (sg2000_pins), - .npd =ARRAY_SIZE (sg2000_power_domain_desc), + .npds =ARRAY_SIZE (sg2000_power_domain_desc), + .pinsize =sizeof (struct cv1800_pin ), };static const struct of_device_id sg2000_pinctrl_ids[] = {
drivers/pinctrl/sophgo/pinctrl-sg2002.c +13 -8
@@ -34,8 +34,9 @@ static const char *const sg2002_power_domain_desc[] = { [VDDIO_SD1] = "VDDIO_SD1", }; -static int sg2002_get_pull_up (struct cv1800_pin *pin,const u32 *psmap) +static int sg2002_get_pull_up (const struct sophgo_pin *sp,const u32 *psmap) { +const struct cv1800_pin *pin =sophgo_to_cv1800_pin (sp);u32 pstate = psmap[pin->power_domain];enum cv1800_pin_io_type type =cv1800_pin_io_type (pin);
@@ -54,8 +55,9 @@ static int sg2002_get_pull_up(struct cv1800_pin *pin, const u32 *psmap)return -ENOTSUPP ; } -static int sg2002_get_pull_down (struct cv1800_pin *pin,const u32 *psmap) +static int sg2002_get_pull_down (const struct sophgo_pin *sp,const u32 *psmap) { +const struct cv1800_pin *pin =sophgo_to_cv1800_pin (sp);u32 pstate = psmap[pin->power_domain];enum cv1800_pin_io_type type =cv1800_pin_io_type (pin);
@@ -108,9 +110,10 @@ static const u32 sg2002_eth_oc_map[] = { 17800 }; -static int sg2002_get_oc_map (struct cv1800_pin *pin,const u32 *psmap, +static int sg2002_get_oc_map (const struct sophgo_pin *sp,const u32 *psmap,const u32 **map) { +const struct cv1800_pin *pin =sophgo_to_cv1800_pin (sp);enum cv1800_pin_io_type type =cv1800_pin_io_type (pin);u32 pstate = psmap[pin->power_domain];
@@ -153,9 +156,10 @@ static const u32 sg2002_18od33_3v3_schmitt_map[] = { 1100000 }; -static int sg2002_get_schmitt_map (struct cv1800_pin *pin,const u32 *psmap, +static int sg2002_get_schmitt_map (const struct sophgo_pin *sp,const u32 *psmap,const u32 **map) { +const struct cv1800_pin *pin =sophgo_to_cv1800_pin (sp);enum cv1800_pin_io_type type =cv1800_pin_io_type (pin);u32 pstate = psmap[pin->power_domain];
@@ -177,11 +181,11 @@ static int sg2002_get_schmitt_map(struct cv1800_pin *pin, const u32 *psmap,return -ENOTSUPP ; } -static const struct cv1800_vddio_cfg_ops sg2002_vddio_cfg_ops = { +static const struct sophgo_vddio_cfg_ops sg2002_vddio_cfg_ops = { .get_pull_up = sg2002_get_pull_up, .get_pull_down = sg2002_get_pull_down, .get_oc_map = sg2002_get_oc_map, - .get_schmitt_map = sg2002_get_schmitt_map, + .get_schmitt_map = sg2002_get_schmitt_map, };static const struct pinctrl_pin_desc sg2002_pins[] = {
@@ -513,13 +517,14 @@ static const struct cv1800_pin sg2002_pin_data[ARRAY_SIZE(sg2002_pins)] = { CV1800_PINCONF_AREA_SYS, 0xc84), }; -static const struct cv1800_pinctrl_data sg2002_pindata = { +static const struct sophgo_pinctrl_data sg2002_pindata = { .pins = sg2002_pins, .pindata = sg2002_pin_data, .pdnames = sg2002_power_domain_desc, .vddio_ops = &sg2002_vddio_cfg_ops, .npins =ARRAY_SIZE (sg2002_pins), - .npd =ARRAY_SIZE (sg2002_power_domain_desc), + .npds =ARRAY_SIZE (sg2002_power_domain_desc), + .pinsize =sizeof (struct cv1800_pin ), };static const struct of_device_id sg2002_pinctrl_ids[] = {
drivers/pinctrl/sophgo/pinctrl-sophgo.h new file +66 -0
66 lines not on this page · raw message
Signature · 1 line
2.48.1
Inochi Amaoto
maintainerPATCH v2 3/8 pinctrl: sophgo: generalize shareable code of cv18xx pinctrl driver
In reply to Inochi AmaotoWith generic data structure, it is possible to generalize vddio operators and DT parsing code of cv18xx pinctrl driver. Introduce sophgo_cfg_ops callback to allow the driver to adjust the soc logic and share common code.
--- drivers/pinctrl/sophgo/Kconfig | 19 +- drivers/pinctrl/sophgo/Makefile | 5 +- drivers/pinctrl/sophgo/pinctrl-cv1800b.c | 1 + drivers/pinctrl/sophgo/pinctrl-cv1812h.c | 1 + drivers/pinctrl/sophgo/pinctrl-cv18xx.c | 423 +++--------------- drivers/pinctrl/sophgo/pinctrl-cv18xx.h | 2 + drivers/pinctrl/sophgo/pinctrl-sg2000.c | 1 + drivers/pinctrl/sophgo/pinctrl-sg2002.c | 1 + .../pinctrl/sophgo/pinctrl-sophgo-common.c | 404 +++++++++++++++++ drivers/pinctrl/sophgo/pinctrl-sophgo.h | 63 +++ 10 files changed, 545 insertions(+), 375 deletions(-) create mode 100644 drivers/pinctrl/sophgo/pinctrl-sophgo-common.c
drivers/pinctrl/sophgo/Kconfig +13 -6
@@ -3,17 +3,21 @@ # Sophgo SoC PINCTRL drivers # -config PINCTRL_SOPHGO_CV18XX - bool +config PINCTRL_SOPHGO_COMMON + tristate select GENERIC_PINCTRL_GROUPS select GENERIC_PINMUX_FUNCTIONS select GENERIC_PINCONF +config PINCTRL_SOPHGO_CV18XX_OPS + bool + config PINCTRL_SOPHGO_CV1800B tristate "Sophgo CV1800B SoC Pinctrl driver" depends on ARCH_SOPHGO || COMPILE_TEST depends on OF - select PINCTRL_SOPHGO_CV18XX + select PINCTRL_SOPHGO_COMMON + select PINCTRL_SOPHGO_CV18XX_OPS help Say Y to select the pinctrl driver for CV1800B SoC. This pin controller allows selecting the mux function for
@@ -24,7 +28,8 @@ config PINCTRL_SOPHGO_CV1812H tristate "Sophgo CV1812H SoC Pinctrl driver" depends on ARCH_SOPHGO || COMPILE_TEST depends on OF - select PINCTRL_SOPHGO_CV18XX + select PINCTRL_SOPHGO_COMMON + select PINCTRL_SOPHGO_CV18XX_OPS help Say Y to select the pinctrl driver for CV1812H SoC. This pin controller allows selecting the mux function for
@@ -35,7 +40,8 @@ config PINCTRL_SOPHGO_SG2000 tristate "Sophgo SG2000 SoC Pinctrl driver" depends on ARCH_SOPHGO || COMPILE_TEST depends on OF - select PINCTRL_SOPHGO_CV18XX + select PINCTRL_SOPHGO_COMMON + select PINCTRL_SOPHGO_CV18XX_OPS help Say Y to select the pinctrl driver for SG2000 SoC. This pin controller allows selecting the mux function for
@@ -46,7 +52,8 @@ config PINCTRL_SOPHGO_SG2002 tristate "Sophgo SG2002 SoC Pinctrl driver" depends on ARCH_SOPHGO || COMPILE_TEST depends on OF - select PINCTRL_SOPHGO_CV18XX + select PINCTRL_SOPHGO_COMMON + select PINCTRL_SOPHGO_CV18XX_OPS help Say Y to select the pinctrl driver for SG2002 SoC. This pin controller allows selecting the mux function for
drivers/pinctrl/sophgo/Makefile +4 -1
@@ -1,6 +1,9 @@ # SPDX-License-Identifier: GPL-2.0 -obj-$(CONFIG_PINCTRL_SOPHGO_CV18XX) += pinctrl-cv18xx.o +obj-$(CONFIG_PINCTRL_SOPHGO_COMMON) += pinctrl-sophgo.o +pinctrl-sophgo-objs += pinctrl-sophgo-common.o +pinctrl-sophgo-$(CONFIG_PINCTRL_SOPHGO_CV18XX_OPS) += pinctrl-cv18xx.o + obj-$(CONFIG_PINCTRL_SOPHGO_CV1800B) += pinctrl-cv1800b.o obj-$(CONFIG_PINCTRL_SOPHGO_CV1812H) += pinctrl-cv1812h.o obj-$(CONFIG_PINCTRL_SOPHGO_SG2000) += pinctrl-sg2000.o
drivers/pinctrl/sophgo/pinctrl-cv1800b.c +1 -0
@@ -442,6 +442,7 @@ static const struct sophgo_pinctrl_data cv1800b_pindata = { .pindata = cv1800b_pin_data, .pdnames = cv1800b_power_domain_desc, .vddio_ops = &cv1800b_vddio_cfg_ops, + .cfg_ops = &cv1800_cfg_ops, .npins = ARRAY_SIZE(cv1800b_pins), .npds = ARRAY_SIZE(cv1800b_power_domain_desc), .pinsize = sizeof(struct cv1800_pin),
drivers/pinctrl/sophgo/pinctrl-cv1812h.c +1 -0
@@ -751,6 +751,7 @@ static const struct sophgo_pinctrl_data cv1812h_pindata = { .pindata = cv1812h_pin_data, .pdnames = cv1812h_power_domain_desc, .vddio_ops = &cv1812h_vddio_cfg_ops, + .cfg_ops = &cv1800_cfg_ops, .npins = ARRAY_SIZE(cv1812h_pins), .npds = ARRAY_SIZE(cv1812h_power_domain_desc), .pinsize = sizeof(struct cv1800_pin),
drivers/pinctrl/sophgo/pinctrl-cv18xx.c +55 -368
550 lines not on this page · raw message
drivers/pinctrl/sophgo/pinctrl-cv18xx.h +2 -0
@@ -68,6 +68,8 @@ static inline enum cv1800_pin_io_type cv1800_pin_io_type(const struct cv1800_pinreturn FIELD_GET (CV1800_PIN_IO_TYPE , pin->pin.flags); }; +extern const struct sophgo_cfg_ops cv1800_cfg_ops; +int cv1800_pinctrl_probe (struct platform_device *pdev); #define CV1800_FUNC_PIN(_id, _power_domain, _type, \
drivers/pinctrl/sophgo/pinctrl-sg2000.c +1 -0
@@ -751,6 +751,7 @@ static const struct sophgo_pinctrl_data sg2000_pindata = { .pindata = sg2000_pin_data, .pdnames = sg2000_power_domain_desc, .vddio_ops = &sg2000_vddio_cfg_ops, + .cfg_ops = &cv1800_cfg_ops, .npins = ARRAY_SIZE(sg2000_pins), .npds = ARRAY_SIZE(sg2000_power_domain_desc), .pinsize = sizeof(struct cv1800_pin),
drivers/pinctrl/sophgo/pinctrl-sg2002.c +1 -0
@@ -522,6 +522,7 @@ static const struct sophgo_pinctrl_data sg2002_pindata = { .pindata = sg2002_pin_data, .pdnames = sg2002_power_domain_desc, .vddio_ops = &sg2002_vddio_cfg_ops, + .cfg_ops = &cv1800_cfg_ops, .npins = ARRAY_SIZE(sg2002_pins), .npds = ARRAY_SIZE(sg2002_power_domain_desc), .pinsize = sizeof(struct cv1800_pin),
drivers/pinctrl/sophgo/pinctrl-sophgo-common.c new file +404 -0
404 lines not on this page · raw message
drivers/pinctrl/sophgo/pinctrl-sophgo.h +63 -0
89 lines not on this page · raw message
Signature · 1 line
2.48.1
Inochi Amaoto
maintainerPATCH v2 4/8 pinctrl: sophgo: introduce generic probe function
In reply to Inochi AmaotoSince different series of the Sophgo chip share a common pinctrl data structure. It is necessary to add a common probe function to alloc the this data structure. Add pctrl_init callback to allow soc to perform its own initialization.
--- drivers/pinctrl/sophgo/pinctrl-cv1800b.c | 5 +- drivers/pinctrl/sophgo/pinctrl-cv1812h.c | 5 +- drivers/pinctrl/sophgo/pinctrl-cv18xx.c | 59 ++++--------------- drivers/pinctrl/sophgo/pinctrl-cv18xx.h | 5 +- drivers/pinctrl/sophgo/pinctrl-sg2000.c | 5 +- drivers/pinctrl/sophgo/pinctrl-sg2002.c | 5 +- .../pinctrl/sophgo/pinctrl-sophgo-common.c | 47 +++++++++++++++ drivers/pinctrl/sophgo/pinctrl-sophgo.h | 7 +++ 8 files changed, 86 insertions(+), 52 deletions(-)
drivers/pinctrl/sophgo/pinctrl-cv1800b.c +4 -1
@@ -443,6 +443,9 @@ static const struct sophgo_pinctrl_data cv1800b_pindata = { .pdnames = cv1800b_power_domain_desc, .vddio_ops = &cv1800b_vddio_cfg_ops, .cfg_ops = &cv1800_cfg_ops, + .pctl_ops = &cv1800_pctrl_ops, + .pmx_ops = &cv1800_pmx_ops, + .pconf_ops = &cv1800_pconf_ops, .npins = ARRAY_SIZE(cv1800b_pins), .npds = ARRAY_SIZE(cv1800b_power_domain_desc), .pinsize = sizeof(struct cv1800_pin),
@@ -455,7 +458,7 @@ static const struct of_device_id cv1800b_pinctrl_ids[] = {MODULE_DEVICE_TABLE (of, cv1800b_pinctrl_ids);static struct platform_driver cv1800b_pinctrl_driver = { - .probe = cv1800_pinctrl_probe, + .probe = sophgo_pinctrl_probe, .driver = { .name ="cv1800b-pinctrl" , .suppress_bind_attrs = true,
drivers/pinctrl/sophgo/pinctrl-cv1812h.c +4 -1
@@ -752,6 +752,9 @@ static const struct sophgo_pinctrl_data cv1812h_pindata = { .pdnames = cv1812h_power_domain_desc, .vddio_ops = &cv1812h_vddio_cfg_ops, .cfg_ops = &cv1800_cfg_ops, + .pctl_ops = &cv1800_pctrl_ops, + .pmx_ops = &cv1800_pmx_ops, + .pconf_ops = &cv1800_pconf_ops, .npins = ARRAY_SIZE(cv1812h_pins), .npds = ARRAY_SIZE(cv1812h_power_domain_desc), .pinsize = sizeof(struct cv1800_pin),
@@ -764,7 +767,7 @@ static const struct of_device_id cv1812h_pinctrl_ids[] = {MODULE_DEVICE_TABLE (of, cv1812h_pinctrl_ids);static struct platform_driver cv1812h_pinctrl_driver = { - .probe = cv1800_pinctrl_probe, + .probe = sophgo_pinctrl_probe, .driver = { .name ="cv1812h-pinctrl" , .suppress_bind_attrs = true,
drivers/pinctrl/sophgo/pinctrl-cv18xx.c +13 -46
124 lines not on this page · raw message
drivers/pinctrl/sophgo/pinctrl-cv18xx.h +3 -2
@@ -68,10 +68,11 @@ static inline enum cv1800_pin_io_type cv1800_pin_io_type(const struct cv1800_pinreturn FIELD_GET (CV1800_PIN_IO_TYPE , pin->pin.flags); }; +extern const struct pinctrl_ops cv1800_pctrl_ops; +extern const struct pinmux_ops cv1800_pmx_ops; +extern const struct pinconf_ops cv1800_pconf_ops;extern const struct sophgo_cfg_ops cv1800_cfg_ops; -int cv1800_pinctrl_probe (struct platform_device *pdev); -#define CV1800_FUNC_PIN (_id, _power_domain, _type, \ _mux_area, _mux_offset, _mux_func_max) \ { \
drivers/pinctrl/sophgo/pinctrl-sg2000.c +4 -1
@@ -752,6 +752,9 @@ static const struct sophgo_pinctrl_data sg2000_pindata = { .pdnames = sg2000_power_domain_desc, .vddio_ops = &sg2000_vddio_cfg_ops, .cfg_ops = &cv1800_cfg_ops, + .pctl_ops = &cv1800_pctrl_ops, + .pmx_ops = &cv1800_pmx_ops, + .pconf_ops = &cv1800_pconf_ops, .npins = ARRAY_SIZE(sg2000_pins), .npds = ARRAY_SIZE(sg2000_power_domain_desc), .pinsize = sizeof(struct cv1800_pin),
@@ -764,7 +767,7 @@ static const struct of_device_id sg2000_pinctrl_ids[] = {MODULE_DEVICE_TABLE (of, sg2000_pinctrl_ids);static struct platform_driver sg2000_pinctrl_driver = { - .probe = cv1800_pinctrl_probe, + .probe = sophgo_pinctrl_probe, .driver = { .name ="sg2000-pinctrl" , .suppress_bind_attrs = true,
drivers/pinctrl/sophgo/pinctrl-sg2002.c +4 -1
@@ -523,6 +523,9 @@ static const struct sophgo_pinctrl_data sg2002_pindata = { .pdnames = sg2002_power_domain_desc, .vddio_ops = &sg2002_vddio_cfg_ops, .cfg_ops = &cv1800_cfg_ops, + .pctl_ops = &cv1800_pctrl_ops, + .pmx_ops = &cv1800_pmx_ops, + .pconf_ops = &cv1800_pconf_ops, .npins = ARRAY_SIZE(sg2002_pins), .npds = ARRAY_SIZE(sg2002_power_domain_desc), .pinsize = sizeof(struct cv1800_pin),
@@ -535,7 +538,7 @@ static const struct of_device_id sg2002_pinctrl_ids[] = {MODULE_DEVICE_TABLE (of, sg2002_pinctrl_ids);static struct platform_driver sg2002_pinctrl_driver = { - .probe = cv1800_pinctrl_probe, + .probe = sophgo_pinctrl_probe, .driver = { .name ="sg2002-pinctrl" , .suppress_bind_attrs = true,
drivers/pinctrl/sophgo/pinctrl-sophgo-common.c +47 -0
52 lines not on this page · raw message
drivers/pinctrl/sophgo/pinctrl-sophgo.h +7 -0
@@ -29,6 +29,7 @@ struct sophgo_pin_mux_config {/** * struct sophgo_cfg_ops - pin configuration operations * +* @pctrl_init: soc specific init callback * @verify_pinmux_config: verify the pinmux config for a pin * @verify_pin_group: verify the whole pinmux group * @dt_node_to_map_post: post init for the pinmux config map
@@ -37,6 +38,8 @@ struct sophgo_pin_mux_config {* @set_pinmux_config: set mux config (the caller holds lock) */ struct sophgo_cfg_ops { +int (*pctrl_init)(struct platform_device *pdev, +struct sophgo_pinctrl *pctrl);int (*verify_pinmux_config)(const struct sophgo_pin_mux_config *config);int (*verify_pin_group)(const struct sophgo_pin_mux_config *pinmuxs,unsigned int npins);
@@ -81,6 +84,9 @@ struct sophgo_pinctrl_data {const char *const *pdnames;const struct sophgo_vddio_cfg_ops *vddio_ops;const struct sophgo_cfg_ops *cfg_ops; +const struct pinctrl_ops *pctl_ops; +const struct pinmux_ops *pmx_ops; +const struct pinconf_ops *pconf_ops;u16 npins;u16 npds;u16 pinsize;
@@ -125,5 +131,6 @@ int sophgo_pinctrl_schmitt2reg(struct sophgo_pinctrl *pctrl,int sophgo_pinctrl_reg2schmitt (struct sophgo_pinctrl *pctrl,const struct sophgo_pin *pin,const u32 *power_cfg,u32 reg); +int sophgo_pinctrl_probe (struct platform_device *pdev);#endif /* _PINCTRL_SOPHGO_H */
Signature · 1 line
2.48.1
Inochi Amaoto
maintainerPATCH v2 5/8 dt-bindings: pinctrl: Add pinctrl for Sophgo SG2042 series SoC
In reply to Inochi AmaotoSG2042 introduces a simple pinctrl device for all configurable pins. For the SG2042 pinctl register file, each register (32 bits) is responsible for two pins, each occupying the upper 16 bits and lower 16 bits of the register. It supports setting pull up/down, drive strength and input schmitt trigger.
Add support for SG2042 pinctrl device.
--- .../pinctrl/sophgo,sg2042-pinctrl.yaml | 129 ++++++++++ include/dt-bindings/pinctrl/pinctrl-sg2042.h | 196 ++++++++++++++++ include/dt-bindings/pinctrl/pinctrl-sg2044.h | 221 ++++++++++++++++++ 3 files changed, 546 insertions(+) create mode 100644 Documentation/devicetree/bindings/pinctrl/sophgo,sg2042-pinctrl.yaml create mode 100644 include/dt-bindings/pinctrl/pinctrl-sg2042.h create mode 100644 include/dt-bindings/pinctrl/pinctrl-sg2044.h
Documentation/devicetree/bindings/pinctrl/sophgo,sg2042-pinctrl.yaml new file +129 -0
@@ -0,0 +1,129 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pinctrl/sophgo,sg2042-pinctrl.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Sophgo SG2042 Pin Controller + +maintainers: + - Inochi Amaoto <[email protected]> + +properties: + compatible: + enum: + - sophgo,sg2042-pinctrl + - sophgo,sg2044-pinctrl + + reg: + maxItems: 1 + +patternProperties: + '-cfg$': + type: object + description: + A pinctrl node should contain at least one subnode representing the + pinctrl groups available on the machine. + + additionalProperties: false + + patternProperties: + '-pins$': + type: object + description: | + 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, drive strength + output enable/disable state. For configuration detail, + refer to https://github.com/sophgo/sophgo-doc/. + + allOf: + - $ref: pincfg-node.yaml# + - $ref: pinmux-node.yaml# + + properties: + pinmux: + description: | + The list of GPIOs and their mux settings that properties in the + node apply to. This should be set using the PINMUX macro. + + bias-disable: true + + bias-pull-up: + type: boolean + + bias-pull-down: + type: boolean + + drive-strength-microamp: + description: typical current when output low level. + + input-schmitt-enable: true + + input-schmitt-disable: true + + required: + - pinmux + + additionalProperties: false + +required: + - compatible + - reg + +allOf: + - if: + properties: + compatible: + contains: + const: sophgo,sg2042-pinctrl + then: + patternProperties: + '-cfg$': + patternProperties: + '-pins$': + properties: + drive-strength-microamp: + enum: [ 5400, 8100, 10700, 13400, + 16100, 18800, 21400, 24100, + 26800, 29400, 32100, 34800, + 37400, 40100, 42800, 45400 ] + + - if: + properties: + compatible: + contains: + const: sophgo,sg2044-pinctrl + then: + patternProperties: + '-cfg$': + patternProperties: + '-pins$': + properties: + drive-strength-microamp: + enum: [ 3200, 6400, 9600, 12700, + 15900, 19100, 22200, 25300, + 29500, 32700, 35900, 39000, + 42000, 45200, 48300, 51400] + +additionalProperties: false + +examples: + - | + #include <dt-bindings/pinctrl/pinctrl-sg2042.h> + + pinctrl@30011000 { + compatible = "sophgo,sg2042-pinctrl"; + reg = <30011000 0x1000>; + + uart0_cfg: uart0-cfg { + uart0-pins { + pinmux = <PINMUX(PIN_UART0_TX, 0)>, + <PINMUX(PIN_UART0_RX, 0)>; + bias-pull-up; + drive-strength-microamp = <13400>; + }; + }; + }; + +...
include/dt-bindings/pinctrl/pinctrl-sg2042.h new file +196 -0
196 lines not on this page · raw message
include/dt-bindings/pinctrl/pinctrl-sg2044.h new file +221 -0
221 lines not on this page · raw message
Signature · 1 line
2.48.1
Re: [PATCH v2 5/8] dt-bindings: pinctrl: Add pinctrl for Sophgo SG2042 series SoC
Quoted 9 lines · Inochi Amaoto
SG2042 introduces a simple pinctrl device for all configurable pins. For the SG2042 pinctl register file, each register (32 bits) is responsible for two pins, each occupying the upper 16 bits and lower 16 bits of the register. It supports setting pull up/down, drive strength and input schmitt trigger.
Add support for SG2042 pinctrl device.
Signed-off-by Inochi Amaoto <[email protected]>
Quoted 9 lines
--- .../pinctrl/sophgo,sg2042-pinctrl.yaml | 129 ++++++++++ include/dt-bindings/pinctrl/pinctrl-sg2042.h | 196 ++++++++++++++++ include/dt-bindings/pinctrl/pinctrl-sg2044.h | 221 ++++++++++++++++++ 3 files changed, 546 insertions(+) create mode 100644 Documentation/devicetree/bindings/pinctrl/sophgo,sg2042-pinctrl.yaml create mode 100644 include/dt-bindings/pinctrl/pinctrl-sg2042.h create mode 100644 include/dt-bindings/pinctrl/pinctrl-sg2044.h
Inochi Amaoto
maintainerPATCH v2 6/8 pinctrl: sophgo: add support for SG2042 SoC
In reply to Inochi AmaotoAdd base driver for SG2042 SoC and pin definition.
--- drivers/pinctrl/sophgo/Kconfig | 15 + drivers/pinctrl/sophgo/Makefile | 2 + drivers/pinctrl/sophgo/pinctrl-sg2042-ops.c | 296 +++++++++ drivers/pinctrl/sophgo/pinctrl-sg2042.c | 655 ++++++++++++++++++++ drivers/pinctrl/sophgo/pinctrl-sg2042.h | 49 ++ 5 files changed, 1017 insertions(+) create mode 100644 drivers/pinctrl/sophgo/pinctrl-sg2042-ops.c create mode 100644 drivers/pinctrl/sophgo/pinctrl-sg2042.c create mode 100644 drivers/pinctrl/sophgo/pinctrl-sg2042.h
drivers/pinctrl/sophgo/Kconfig +15 -0
@@ -59,3 +59,18 @@ config PINCTRL_SOPHGO_SG2002 This pin controller allows selecting the mux function for each pin. This driver can also be built as a module called pinctrl-sg2002. + +config PINCTRL_SOPHGO_SG2042_OPS + bool + +config PINCTRL_SOPHGO_SG2042 + tristate "Sophgo SG2042 SoC Pinctrl driver" + depends on ARCH_SOPHGO || COMPILE_TEST + depends on OF + select PINCTRL_SOPHGO_COMMON + select PINCTRL_SOPHGO_SG2042_OPS + help + Say Y to select the pinctrl driver for SG2042 SoC. + This pin controller allows selecting the mux function for + each pin. This driver can also be built as a module called + pinctrl-sg2042.
drivers/pinctrl/sophgo/Makefile +2 -0
@@ -3,8 +3,10 @@ obj-$(CONFIG_PINCTRL_SOPHGO_COMMON) += pinctrl-sophgo.o pinctrl-sophgo-objs += pinctrl-sophgo-common.o pinctrl-sophgo-$(CONFIG_PINCTRL_SOPHGO_CV18XX_OPS) += pinctrl-cv18xx.o +pinctrl-sophgo-$(CONFIG_PINCTRL_SOPHGO_SG2042_OPS) += pinctrl-sg2042-ops.o obj-$(CONFIG_PINCTRL_SOPHGO_CV1800B) += pinctrl-cv1800b.o obj-$(CONFIG_PINCTRL_SOPHGO_CV1812H) += pinctrl-cv1812h.o obj-$(CONFIG_PINCTRL_SOPHGO_SG2000) += pinctrl-sg2000.o obj-$(CONFIG_PINCTRL_SOPHGO_SG2002) += pinctrl-sg2002.o +obj-$(CONFIG_PINCTRL_SOPHGO_SG2042) += pinctrl-sg2042.o
drivers/pinctrl/sophgo/pinctrl-sg2042-ops.c new file +296 -0
296 lines not on this page · raw message
drivers/pinctrl/sophgo/pinctrl-sg2042.c new file +655 -0
655 lines not on this page · raw message
drivers/pinctrl/sophgo/pinctrl-sg2042.h new file +49 -0
49 lines not on this page · raw message
Signature · 1 line
2.48.1
Inochi Amaoto
maintainerPATCH v2 7/8 pinctrl: sophgo: add support for SG2044 SoC
In reply to Inochi AmaotoSG2044 share the share common control logic with SG2042. So only pin definition is needed.
Add pin definition driver for SG2044 SoC.
--- drivers/pinctrl/sophgo/Kconfig | 12 + drivers/pinctrl/sophgo/Makefile | 1 + drivers/pinctrl/sophgo/pinctrl-sg2044.c | 718 ++++++++++++++++++++++++ 3 files changed, 731 insertions(+) create mode 100644 drivers/pinctrl/sophgo/pinctrl-sg2044.c
drivers/pinctrl/sophgo/Kconfig +12 -0
@@ -74,3 +74,15 @@ config PINCTRL_SOPHGO_SG2042 This pin controller allows selecting the mux function for each pin. This driver can also be built as a module called pinctrl-sg2042. + +config PINCTRL_SOPHGO_SG2044 + tristate "Sophgo SG2044 SoC Pinctrl driver" + depends on ARCH_SOPHGO || COMPILE_TEST + depends on OF + select PINCTRL_SOPHGO_COMMON + select PINCTRL_SOPHGO_SG2042_OPS + help + Say Y to select the pinctrl driver for SG2044 SoC. + This pin controller allows selecting the mux function for + each pin. This driver can also be built as a module called + pinctrl-sg2044.
drivers/pinctrl/sophgo/Makefile +1 -0
@@ -10,3 +10,4 @@ obj-$(CONFIG_PINCTRL_SOPHGO_CV1812H) += pinctrl-cv1812h.o obj-$(CONFIG_PINCTRL_SOPHGO_SG2000) += pinctrl-sg2000.o obj-$(CONFIG_PINCTRL_SOPHGO_SG2002) += pinctrl-sg2002.o obj-$(CONFIG_PINCTRL_SOPHGO_SG2042) += pinctrl-sg2042.o +obj-$(CONFIG_PINCTRL_SOPHGO_SG2044) += pinctrl-sg2044.o
drivers/pinctrl/sophgo/pinctrl-sg2044.c new file +718 -0
718 lines not on this page · raw message
Signature · 1 line
2.48.1
Inochi Amaoto
maintainerPATCH v2 8/8 riscv: dts: sophgo: sg2042: add pinctrl support
In reply to Inochi AmaotoAdd pinctrl node and related pin configuration for SG2042 SoC.
--- .../boot/dts/sophgo/sg2042-milkv-pioneer.dts | 72 +++++++++++++++++++ arch/riscv/boot/dts/sophgo/sg2042.dtsi | 6 ++ 2 files changed, 78 insertions(+)
arch/riscv/boot/dts/sophgo/sg2042-milkv-pioneer.dts +72 -0
@@ -42,6 +42,8 @@ &cgi_dpll1 { }; &emmc { + pinctrl-0 = <&emmc_cfg>; + pinctrl-names = "default"; bus-width = <4>; no-sdio; no-sd;
@@ -51,6 +53,8 @@ &emmc { }; &i2c1 { + pinctrl-0 = <&i2c1_cfg>; + pinctrl-names = "default"; status = "okay"; mcu: syscon@17 {
@@ -60,7 +64,73 @@ mcu: syscon@17 { }; }; +&pinctrl { + emmc_cfg: sdhci-emmc-cfg { + sdhci-emmc-wp-pins { + pinmux = <PINMUX(PIN_EMMC_WP, 0)>; + bias-disable; + drive-strength-microamp = <26800>; + input-schmitt-disable; + }; + + sdhci-emmc-cd-pins { + pinmux = <PINMUX(PIN_EMMC_CD, 0)>; + bias-pull-up; + drive-strength-microamp = <26800>; + input-schmitt-enable; + }; + + sdhci-emmc-rst-pwr-pins { + pinmux = <PINMUX(PIN_EMMC_RST, 0)>, + <PINMUX(PIN_EMMC_PWR_EN, 0)>; + bias-disable; + drive-strength-microamp = <26800>; + input-schmitt-disable; + }; + }; + + i2c1_cfg: i2c1-cfg { + i2c1-pins { + pinmux = <PINMUX(PIN_IIC1_SDA, 0)>, + <PINMUX(PIN_IIC1_SCL, 0)>; + bias-pull-up; + drive-strength-microamp = <26800>; + input-schmitt-enable; + }; + }; + + sd_cfg: sdhci-sd-cfg { + sdhci-sd-cd-wp-pins { + pinmux = <PINMUX(PIN_SDIO_CD, 0)>, + <PINMUX(PIN_SDIO_WP, 0)>; + bias-pull-up; + drive-strength-microamp = <26800>; + input-schmitt-enable; + }; + + sdhci-sd-rst-pwr-pins { + pinmux = <PINMUX(PIN_SDIO_RST, 0)>, + <PINMUX(PIN_SDIO_PWR_EN, 0)>; + bias-disable; + drive-strength-microamp = <26800>; + input-schmitt-disable; + }; + }; + + uart0_cfg: uart0-cfg { + uart0-rx-pins { + pinmux = <PINMUX(PIN_UART0_TX, 0)>, + <PINMUX(PIN_UART0_RX, 0)>; + bias-pull-up; + drive-strength-microamp = <26800>; + input-schmitt-enable; + }; + }; +}; + &sd { + pinctrl-0 = <&sd_cfg>; + pinctrl-names = "default"; bus-width = <4>; no-sdio; no-mmc;
@@ -69,6 +139,8 @@ &sd { }; &uart0 { + pinctrl-0 = <&uart0_cfg>; + pinctrl-names = "default"; status = "okay"; };
arch/riscv/boot/dts/sophgo/sg2042.dtsi +6 -0
@@ -8,6 +8,7 @@ #include <dt-bindings/clock/sophgo,sg2042-pll.h> #include <dt-bindings/clock/sophgo,sg2042-rpgate.h> #include <dt-bindings/interrupt-controller/irq.h> +#include <dt-bindings/pinctrl/pinctrl-sg2042.h> #include <dt-bindings/reset/sophgo,sg2042-reset.h> #include "sg2042-cpus.dtsi"
@@ -181,6 +182,11 @@ rpgate: clock-controller@7030010368 { #clock-cells = <1>; }; + pinctrl: pinctrl@7030011000 { + compatible = "sophgo,sg2042-pinctrl"; + reg = <0x70 0x30011000 0x0 0x1000>; + }; + clkgen: clock-controller@7030012000 { compatible = "sophgo,sg2042-clkgen"; reg = <0x70 0x30012000 0x0 0x1000>;
Signature · 1 line
2.48.1
Quoted 5 lines · Inochi Amaoto
SG2042 has a simple pinctrl device for all configurable pins. It supports setting pull up/down, drive strength and input schmitt trigger.
Add support for SG2042 and SG2044 pinctrl device.
(...)
Quoted 10 lines
Inochi Amaoto (8):
pinctrl: sophgo: avoid to modify untouched bit when setting cv1800
pinconf
pinctrl: sophgo: introduce generic data structure for cv18xx pinctrl
driver
pinctrl: sophgo: generalize shareable code of cv18xx pinctrl driver
pinctrl: sophgo: introduce generic probe function
dt-bindings: pinctrl: Add pinctrl for Sophgo SG2042 series SoC
pinctrl: sophgo: add support for SG2042 SoC
pinctrl: sophgo: add support for SG2044 SoC
I applied these patches 1-7 to the pinctrl tree and created an immutable branch:
https://web.git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git/log/?h=ib-sophgo
Quoted 1 line
riscv: dts: sophgo: sg2042: add pinctrl support
Apply this patch to the riscv/SoC tree.
If it is required, that tree can pull in my immutable branch, which is based on v6.14-rc1.
Yours,
Linus Walleij
Inochi Amaoto
maintainerQuoted 25 lines · Linus Walleij
Quoted 5 lines · Inochi Amaoto
SG2042 has a simple pinctrl device for all configurable pins. It supports setting pull up/down, drive strength and input schmitt trigger.
Add support for SG2042 and SG2044 pinctrl device.
(...)
Quoted 10 lines
Inochi Amaoto (8):
pinctrl: sophgo: avoid to modify untouched bit when setting cv1800
pinconf
pinctrl: sophgo: introduce generic data structure for cv18xx pinctrl
driver
pinctrl: sophgo: generalize shareable code of cv18xx pinctrl driver
pinctrl: sophgo: introduce generic probe function
dt-bindings: pinctrl: Add pinctrl for Sophgo SG2042 series SoC
pinctrl: sophgo: add support for SG2042 SoC
pinctrl: sophgo: add support for SG2044 SoCI applied these patches 1-7 to the pinctrl tree and created an immutable branch:
https://web.git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git/log/?h=ib-sophgoQuoted 1 line
riscv: dts: sophgo: sg2042: add pinctrl support
Quoted 7 lines
Apply this patch to the riscv/SoC tree.
If it is required, that tree can pull in my immutable branch, which is based on v6.14-rc1.
Yours,
Linus Walleij
Thanks, I will take care of the device tree.
Regards,
Inochi
Re: (subset) [PATCH v2 0/8] riscv: sophgo: Add pinctrl support for SG2042
In reply to Inochi AmaotoQuoted 6 lines · Inochi Amaoto
SG2042 has a simple pinctrl device for all configurable pins. It supports setting pull up/down, drive strength and input schmitt trigger.
Add support for SG2042 and SG2044 pinctrl device.
Quoted 7 lines
Changed from v1:
- https://lore.kernel.org/all/[email protected]/
1. Fix the binding documentation error.
2. Refactor the cv18xx code so SG2042 can uses the same code.
3. Add SG2044 pinctrl support as it has the same layout.[...]
Applied to for-next, thanks!
[8/8] riscv: dts: sophgo: sg2042: add pinctrl support
https://github.com/sophgo/linux/commit/5277657d53834cfbdbb9444088c1448b29bdfe98
Thanks,
Inochi
Inochi Amaoto
maintainerRe: (subset) [PATCH v2 0/8] riscv: sophgo: Add pinctrl support for SG2042
Quoted 15 lines · Inochi Amaoto
Quoted 6 lines · Inochi Amaoto
SG2042 has a simple pinctrl device for all configurable pins. It supports setting pull up/down, drive strength and input schmitt trigger.
Add support for SG2042 and SG2044 pinctrl device.
Quoted 7 lines
Changed from v1:
- https://lore.kernel.org/all/[email protected]/
1. Fix the binding documentation error.
2. Refactor the cv18xx code so SG2042 can uses the same code.
3. Add SG2044 pinctrl support as it has the same layout.[...]
Quoted 8 lines
Applied to for-next, thanks!
[8/8] riscv: dts: sophgo: sg2042: add pinctrl support
https://github.com/sophgo/linux/commit/5277657d53834cfbdbb9444088c1448b29bdfe98Thanks,
Inochi
This patch is unapplied temporarily for dependency issue. I will repick it in the next cycle.
Regards,
Inochi
Inochi Amaoto
maintainerRe: (subset) [PATCH v2 0/8] riscv: sophgo: Add pinctrl support for SG2042
In reply to Inochi AmaotoQuoted 6 lines · Inochi Amaoto
SG2042 has a simple pinctrl device for all configurable pins. It supports setting pull up/down, drive strength and input schmitt trigger.
Add support for SG2042 and SG2044 pinctrl device.
Quoted 7 lines
Changed from v1:
- https://lore.kernel.org/all/[email protected]/
1. Fix the binding documentation error.
2. Refactor the cv18xx code so SG2042 can uses the same code.
3. Add SG2044 pinctrl support as it has the same layout.[...]
Reapply this to the sophgo/for-next.
[8/8] riscv: dts: sophgo: sg2042: add pinctrl support
https://github.com/sophgo/linux/commit/a1d04b8461eced3c8933fc3f58ddcc4b44ca9073
Thanks,
Inochi