Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'pinctrl-v6.15-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl

Pull pin control updates from Linus Walleij:
"Core changes:

- None really.

New drivers:

- AMD ISP411 "AMD ISP" driver

- Exynos 2200 and 7870 SoC subdrivers

- Sophgo RISC-V SG2042 and SG2044 subdrivers

- Amlogic A4 subdriver

- Rockchip RK3528 subdriver

- Broadcom BCM21664 subdriver

- Allwinner A523/T527 subdriver

- Ingenic X1600 subdriver

- Microchip SAMA7D65 subdriver, essentially a re-branded Atmel AT91
PIO4 driver, but nowadays a Microschip SoC line

Improvements:

- Bring in the devm_kmemdup_array() helper and use it throughout,
also bring in changes to other subsystems for this to establish
this helper

- Support EGPIO on the Qualcomm SA8775P SoC

- Extend EINT support in the Mediatek driver"

* tag 'pinctrl-v6.15-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl: (101 commits)
pinctrl: mediatek: Add EINT support for multiple addresses
pinctrl: amlogic-a4: Drop surplus semicolon
pinctrl: nuvoton: Reduce use of OF-specific APIs
pinctrl: nuvoton: Convert to use struct group_desc
pinctrl: nuvoton: Make use of struct pinfunction and PINCTRL_PINFUNCTION()
pinctrl: nuvoton: Convert to use struct pingroup and PINCTRL_PINGROUP()
pinctrl: npcm8xx: Fix incorrect struct npcm8xx_pincfg assignment
pinctrl: tegra: Fix off by one in tegra_pinctrl_get_group()
pinctrl: PINCTRL_AMDISP should depend on DRM_AMD_ISP
pinctrl: qcom: sa8775p: Enable egpio function
dt-bindings: pinctrl: qcom: Add egpio function for sa8775p
pinctrl: qcom: tlmm-test: Validate irq_enable delivers edge irqs
pinctrl: qcom: Clear latched interrupt status when changing IRQ type
dt-bindings: pinctrl: airoha: Add missing gpio-ranges property
pinctrl: bcm281xx: Add missing assignment in bcm21664_pinctrl_lock_all()
pinctrl: amd: isp411: Fix IS_ERR() vs NULL check in probe()
dt-bindings: pinctrl: at91-pio4: add microchip,sama7d65-pinctrl
pinctrl: tegra: Set SFIO mode to Mux Register
pinctrl-tegra: Restore SFSEL bit when freeing pins
pinctrl: tegra: Add descriptions for SoC data fields
...

+8764 -1181
+3
Documentation/devicetree/bindings/pinctrl/airoha,en7581-pinctrl.yaml
··· 24 24 '#gpio-cells': 25 25 const: 2 26 26 27 + gpio-ranges: 28 + maxItems: 1 29 + 27 30 interrupt-controller: true 28 31 29 32 '#interrupt-cells':
+175
Documentation/devicetree/bindings/pinctrl/allwinner,sun55i-a523-pinctrl.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/pinctrl/allwinner,sun55i-a523-pinctrl.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Allwinner A523 Pin Controller 8 + 9 + maintainers: 10 + - Andre Przywara <andre.przywara@arm.com> 11 + 12 + properties: 13 + "#gpio-cells": 14 + const: 3 15 + description: 16 + GPIO consumers must use three arguments, first the number of the 17 + bank, then the pin number inside that bank, and finally the GPIO 18 + flags. 19 + 20 + "#interrupt-cells": 21 + const: 3 22 + description: 23 + Interrupts consumers must use three arguments, first the number 24 + of the bank, then the pin number inside that bank, and finally 25 + the interrupts flags. 26 + 27 + compatible: 28 + enum: 29 + - allwinner,sun55i-a523-pinctrl 30 + - allwinner,sun55i-a523-r-pinctrl 31 + 32 + reg: 33 + maxItems: 1 34 + 35 + interrupts: 36 + minItems: 2 37 + maxItems: 10 38 + description: 39 + One interrupt per external interrupt bank supported on the 40 + controller, sorted by bank number ascending order. 41 + 42 + clocks: 43 + items: 44 + - description: Bus Clock 45 + - description: High Frequency Oscillator 46 + - description: Low Frequency Oscillator 47 + 48 + clock-names: 49 + items: 50 + - const: apb 51 + - const: hosc 52 + - const: losc 53 + 54 + gpio-controller: true 55 + interrupt-controller: true 56 + gpio-line-names: true 57 + 58 + input-debounce: 59 + description: 60 + Debouncing periods in microseconds, one period per interrupt 61 + bank found in the controller 62 + $ref: /schemas/types.yaml#/definitions/uint32-array 63 + minItems: 2 64 + maxItems: 10 65 + 66 + patternProperties: 67 + # It's pretty scary, but the basic idea is that: 68 + # - One node name can start with either s- or r- for PRCM nodes, 69 + # - Then, the name itself can be any repetition of <string>- (to 70 + # accommodate with nodes like uart4-rts-cts-pins), where each 71 + # string can be either starting with 'p' but in a string longer 72 + # than 3, or something that doesn't start with 'p', 73 + # - Then, the bank name is optional and will be between pa and pm. 74 + # Some pins groups that have several options will have the pin 75 + # numbers then, 76 + # - Finally, the name will end with either -pin or pins. 77 + 78 + "^([rs]-)?(([a-z0-9]{3,}|[a-oq-z][a-z0-9]*?)?-)+?(p[a-m][0-9]*?-)??pins?$": 79 + type: object 80 + 81 + properties: 82 + pins: true 83 + function: true 84 + bias-disable: true 85 + bias-pull-up: true 86 + bias-pull-down: true 87 + 88 + drive-strength: 89 + $ref: /schemas/types.yaml#/definitions/uint32 90 + enum: [10, 20, 30, 40] 91 + 92 + allwinner,pinmux: 93 + $ref: /schemas/types.yaml#/definitions/uint32-array 94 + description: 95 + Pinmux selector value, for each pin. Almost every time this value 96 + is the same for all pins, so any array shorter than the number of 97 + pins will repeat the last value, to allow just specifying a single 98 + cell, for all cells. 99 + 100 + required: 101 + - pins 102 + - allwinner,pinmux 103 + - function 104 + 105 + additionalProperties: false 106 + 107 + "^vcc-p[a-m]-supply$": 108 + description: 109 + Power supplies for pin banks. 110 + 111 + required: 112 + - "#gpio-cells" 113 + - compatible 114 + - reg 115 + - clocks 116 + - clock-names 117 + - gpio-controller 118 + - "#interrupt-cells" 119 + - interrupts 120 + - interrupt-controller 121 + 122 + allOf: 123 + - $ref: pinctrl.yaml# 124 + - if: 125 + properties: 126 + compatible: 127 + enum: 128 + - allwinner,sun55i-a523-pinctrl 129 + 130 + then: 131 + properties: 132 + interrupts: 133 + minItems: 10 134 + maxItems: 10 135 + 136 + - if: 137 + properties: 138 + compatible: 139 + enum: 140 + - allwinner,sun55i-a523-r-pinctrl 141 + 142 + then: 143 + properties: 144 + interrupts: 145 + minItems: 2 146 + maxItems: 2 147 + 148 + additionalProperties: false 149 + 150 + examples: 151 + - | 152 + r_pio: pinctrl@7022000 { 153 + compatible = "allwinner,sun55i-a523-r-pinctrl"; 154 + reg = <0x7022000 0x800>; 155 + interrupts = <0 159 4>, <0 161 4>; 156 + clocks = <&r_ccu 1>, <&osc24M>, <&osc32k>; 157 + clock-names = "apb", "hosc", "losc"; 158 + gpio-controller; 159 + #gpio-cells = <3>; 160 + interrupt-controller; 161 + #interrupt-cells = <3>; 162 + 163 + r_i2c_pins: r-i2c-pins { 164 + pins = "PL0", "PL1"; 165 + allwinner,pinmux = <2>; 166 + function = "r_i2c0"; 167 + bias-pull-up; 168 + }; 169 + 170 + r_spi_pins: r-spi-pins { 171 + pins = "PL11" ,"PL12", "PL13"; 172 + allwinner,pinmux = <6>; 173 + function = "r_spi"; 174 + }; 175 + };
+126
Documentation/devicetree/bindings/pinctrl/amlogic,pinctrl-a4.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/pinctrl/amlogic,pinctrl-a4.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Amlogic pinmux controller 8 + 9 + maintainers: 10 + - Xianwei Zhao <xianwei.zhao@amlogic.com> 11 + 12 + allOf: 13 + - $ref: pinctrl.yaml# 14 + 15 + properties: 16 + compatible: 17 + const: amlogic,pinctrl-a4 18 + 19 + "#address-cells": 20 + const: 2 21 + 22 + "#size-cells": 23 + const: 2 24 + 25 + ranges: true 26 + 27 + patternProperties: 28 + "^gpio@[0-9a-f]+$": 29 + type: object 30 + 31 + additionalProperties: false 32 + properties: 33 + reg: 34 + minItems: 1 35 + items: 36 + - description: pin config register 37 + - description: pin mux setting register (some special pin fixed function) 38 + - description: pin drive strength register (optional) 39 + 40 + reg-names: 41 + minItems: 1 42 + items: 43 + - const: gpio 44 + - const: mux 45 + - const: ds 46 + 47 + gpio-controller: true 48 + 49 + "#gpio-cells": 50 + const: 2 51 + 52 + gpio-ranges: 53 + maxItems: 1 54 + 55 + required: 56 + - reg 57 + - reg-names 58 + - gpio-controller 59 + - "#gpio-cells" 60 + - gpio-ranges 61 + 62 + "^func-[0-9a-z-]+$": 63 + type: object 64 + additionalProperties: false 65 + patternProperties: 66 + "^group-[0-9a-z-]+$": 67 + type: object 68 + allOf: 69 + - $ref: /schemas/pinctrl/pincfg-node.yaml 70 + - $ref: /schemas/pinctrl/pinmux-node.yaml 71 + 72 + required: 73 + - pinmux 74 + 75 + required: 76 + - compatible 77 + - "#address-cells" 78 + - "#size-cells" 79 + - ranges 80 + 81 + additionalProperties: false 82 + 83 + examples: 84 + - | 85 + #include <dt-bindings/pinctrl/amlogic,pinctrl.h> 86 + apb { 87 + #address-cells = <2>; 88 + #size-cells = <2>; 89 + periphs_pinctrl: pinctrl { 90 + compatible = "amlogic,pinctrl-a4"; 91 + #address-cells = <2>; 92 + #size-cells = <2>; 93 + ranges; 94 + 95 + gpio@4240 { 96 + reg = <0 0x4240 0 0x40>, <0 0x4000 0 0x8>; 97 + reg-names = "gpio", "mux"; 98 + gpio-controller; 99 + #gpio-cells = <2>; 100 + gpio-ranges = <&periphs_pinctrl 0 8 10>; 101 + }; 102 + 103 + func-uart-b { 104 + group-default { 105 + pinmux = <AML_PINMUX(AMLOGIC_GPIO_B, 1, 4)>; 106 + bias-pull-up; 107 + drive-strength-microamp = <4000>; 108 + }; 109 + 110 + group-pins1 { 111 + pinmux = <AML_PINMUX(AMLOGIC_GPIO_B, 5, 2)>; 112 + bias-pull-up; 113 + drive-strength-microamp = <4000>; 114 + }; 115 + }; 116 + 117 + func-uart-c { 118 + group-default { 119 + pinmux = <AML_PINMUX(AMLOGIC_GPIO_B, 3, 1)>, 120 + <AML_PINMUX(AMLOGIC_GPIO_B, 2, 1)>; 121 + bias-pull-up; 122 + drive-strength-microamp = <4000>; 123 + }; 124 + }; 125 + }; 126 + };
+1
Documentation/devicetree/bindings/pinctrl/atmel,at91-pio4-pinctrl.txt
··· 6 6 Required properties: 7 7 - compatible: 8 8 "atmel,sama5d2-pinctrl" 9 + "microchip,sama7d65-pinctrl", "microchip,sama7g5-pinctrl" 9 10 "microchip,sama7g5-pinctrl" 10 11 - reg: base address and length of the PIO controller. 11 12 - interrupts: interrupt outputs from the controller, one for each bank.
+152
Documentation/devicetree/bindings/pinctrl/brcm,bcm21664-pinctrl.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/pinctrl/brcm,bcm21664-pinctrl.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Broadcom BCM21664 pin controller 8 + 9 + maintainers: 10 + - Florian Fainelli <florian.fainelli@broadcom.com> 11 + - Ray Jui <rjui@broadcom.com> 12 + - Scott Branden <sbranden@broadcom.com> 13 + 14 + allOf: 15 + - $ref: pinctrl.yaml# 16 + 17 + properties: 18 + compatible: 19 + const: brcm,bcm21664-pinctrl 20 + 21 + reg: 22 + maxItems: 1 23 + 24 + patternProperties: 25 + '-pins$': 26 + type: object 27 + additionalProperties: false 28 + 29 + patternProperties: 30 + '-grp[0-9]$': 31 + type: object 32 + 33 + properties: 34 + pins: 35 + description: 36 + Specifies the name(s) of one or more pins to be configured by 37 + this node. 38 + items: 39 + enum: [ adcsyn, batrm, bsc1clk, bsc1dat, camcs0, camcs1, clk32k, 40 + clk_cx8, dclk1, dclk4, dclkreq1, dclkreq4, dmic0clk, 41 + dmic0dq, dsi0te, gpio00, gpio01, gpio02, gpio03, gpio04, 42 + gpio05, gpio06, gpio07, gpio08, gpio09, gpio10, gpio11, 43 + gpio12, gpio13, gpio14, gpio15, gpio16, gpio17, gpio18, 44 + gpio19, gpio20, gpio21, gpio22, gpio23, gpio24, gpio25, 45 + gpio26, gpio27, gpio28, gpio32, gpio33, gpio34, gpio93, 46 + gpio94, gps_calreq, gps_hostreq, gps_pablank, gps_tmark, 47 + icusbdm, icusbdp, lcdcs0, lcdres, lcdscl, lcdsda, lcdte, 48 + mdmgpio00, mdmgpio01, mdmgpio02, mdmgpio03, mdmgpio04, 49 + mdmgpio05, mdmgpio06, mdmgpio07, mdmgpio08, mmc0ck, 50 + mmc0cmd, mmc0dat0, mmc0dat1, mmc0dat2, mmc0dat3, mmc0dat4, 51 + mmc0dat5, mmc0dat6, mmc0dat7, mmc0rst, mmc1ck, mmc1cmd, 52 + mmc1dat0, mmc1dat1, mmc1dat2, mmc1dat3, mmc1dat4, 53 + mmc1dat5, mmc1dat6, mmc1dat7, mmc1rst, pc1, pc2, pmbscclk, 54 + pmbscdat, pmuint, resetn, rfst2g_mtsloten3g, 55 + rtxdata2g_txdata3g1, rtxen2g_txdata3g2, rxdata3g0, 56 + rxdata3g1, rxdata3g2, sdck, sdcmd, sddat0, sddat1, sddat2, 57 + sddat3, simclk, simdat, simdet, simrst, spi0clk, spi0fss, 58 + spi0rxd, spi0txd, sri_c, sri_d, sri_e, sspck, sspdi, 59 + sspdo, sspsyn, stat1, stat2, swclktck, swdiotms, sysclken, 60 + tdi, tdo, testmode, traceclk, tracedt00, tracedt01, 61 + tracedt02, tracedt03, tracedt04, tracedt05, tracedt06, 62 + tracedt07, tracedt08, tracedt09, tracedt10, tracedt11, 63 + tracedt12, tracedt13, tracedt14, tracedt15, trstb, 64 + txdata3g0, ubctsn, ubrtsn, ubrx, ubtx ] 65 + 66 + function: 67 + description: 68 + Specifies the pin mux selection. 69 + enum: [ alt1, alt2, alt3, alt4, alt5, alt6 ] 70 + 71 + bias-disable: true 72 + 73 + bias-pull-up: 74 + type: boolean 75 + 76 + bias-pull-down: 77 + type: boolean 78 + 79 + slew-rate: 80 + description: | 81 + Meaning depends on configured pin mux: 82 + bsc*clk/pmbscclk or bsc*dat/pmbscdat or gpio16/gpio17: 83 + 0: Standard (100 kbps) & Fast (400 kbps) mode 84 + 1: Highspeed (3.4 Mbps) mode 85 + Otherwise: 86 + 0: fast slew rate 87 + 1: normal slew rate 88 + 89 + drive-strength: 90 + enum: [ 2, 4, 6, 8, 10, 12, 14, 16 ] 91 + 92 + input-enable: true 93 + input-disable: true 94 + 95 + input-schmitt-enable: true 96 + input-schmitt-disable: true 97 + 98 + required: 99 + - pins 100 + 101 + additionalProperties: false 102 + 103 + allOf: 104 + - $ref: pincfg-node.yaml# 105 + # Limitations for I2C pins 106 + - if: 107 + properties: 108 + pins: 109 + contains: 110 + enum: [ bsc1clk, bsc1dat, gpio16, gpio17, pmbscclk, 111 + pmbscdat ] 112 + then: 113 + properties: 114 + drive-strength: false 115 + bias-pull-down: false 116 + input-schmitt-enable: false 117 + input-schmitt-disable: false 118 + 119 + 120 + required: 121 + - compatible 122 + - reg 123 + 124 + unevaluatedProperties: false 125 + 126 + examples: 127 + - | 128 + pinctrl@35004800 { 129 + compatible = "brcm,bcm21664-pinctrl"; 130 + reg = <0x35004800 0x7f0>; 131 + 132 + dev-a-active-pins { 133 + /* group node defining 1 standard pin */ 134 + std-grp0 { 135 + pins = "gpio00"; 136 + function = "alt1"; 137 + input-schmitt-enable; 138 + bias-disable; 139 + slew-rate = <1>; 140 + drive-strength = <4>; 141 + }; 142 + 143 + /* group node defining 2 I2C pins */ 144 + i2c-grp0 { 145 + pins = "bsc1clk", "bsc1dat"; 146 + function = "alt2"; 147 + bias-pull-up; 148 + input-enable; 149 + }; 150 + }; 151 + }; 152 + ...
+2
Documentation/devicetree/bindings/pinctrl/ingenic,pinctrl.yaml
··· 42 42 - ingenic,jz4780-pinctrl 43 43 - ingenic,x1000-pinctrl 44 44 - ingenic,x1500-pinctrl 45 + - ingenic,x1600-pinctrl 45 46 - ingenic,x1830-pinctrl 46 47 - ingenic,x2000-pinctrl 47 48 - ingenic,x2100-pinctrl ··· 82 81 - ingenic,jz4780-gpio 83 82 - ingenic,x1000-gpio 84 83 - ingenic,x1500-gpio 84 + - ingenic,x1600-gpio 85 85 - ingenic,x1830-gpio 86 86 - ingenic,x2000-gpio 87 87 - ingenic,x2100-gpio
+1 -1
Documentation/devicetree/bindings/pinctrl/qcom,sa8775p-tlmm.yaml
··· 79 79 cri_trng, cri_trng0, cri_trng1, dbg_out, ddr_bist, ddr_pxi0, 80 80 ddr_pxi1, ddr_pxi2, ddr_pxi3, ddr_pxi4, ddr_pxi5, edp0_hot, 81 81 edp0_lcd, edp1_hot, edp1_lcd, edp2_hot, edp2_lcd, edp3_hot, 82 - edp3_lcd, emac0_mcg0, emac0_mcg1, emac0_mcg2, emac0_mcg3, 82 + edp3_lcd, egpio, emac0_mcg0, emac0_mcg1, emac0_mcg2, emac0_mcg3, 83 83 emac0_mdc, emac0_mdio, emac0_ptp_aux, emac0_ptp_pps, emac1_mcg0, 84 84 emac1_mcg1, emac1_mcg2, emac1_mcg3, emac1_mdc, emac1_mdio, 85 85 emac1_ptp_aux, emac1_ptp_pps, gcc_gp1, gcc_gp2, gcc_gp3,
+1
Documentation/devicetree/bindings/pinctrl/rockchip,pinctrl.yaml
··· 44 44 - rockchip,rk3328-pinctrl 45 45 - rockchip,rk3368-pinctrl 46 46 - rockchip,rk3399-pinctrl 47 + - rockchip,rk3528-pinctrl 47 48 - rockchip,rk3562-pinctrl 48 49 - rockchip,rk3568-pinctrl 49 50 - rockchip,rk3576-pinctrl
+3
Documentation/devicetree/bindings/pinctrl/samsung,pinctrl-wakeup-interrupt.yaml
··· 40 40 - items: 41 41 - enum: 42 42 - samsung,exynos5433-wakeup-eint 43 + - samsung,exynos7870-wakeup-eint 43 44 - samsung,exynos7885-wakeup-eint 44 45 - samsung,exynos850-wakeup-eint 45 46 - samsung,exynos8895-wakeup-eint ··· 48 47 - items: 49 48 - enum: 50 49 - google,gs101-wakeup-eint 50 + - samsung,exynos2200-wakeup-eint 51 51 - samsung,exynos9810-wakeup-eint 52 52 - samsung,exynos990-wakeup-eint 53 53 - samsung,exynosautov9-wakeup-eint ··· 106 104 - contains: 107 105 enum: 108 106 - samsung,exynos5433-wakeup-eint 107 + - samsung,exynos7870-wakeup-eint 109 108 - samsung,exynos7885-wakeup-eint 110 109 - samsung,exynos8895-wakeup-eint 111 110 then:
+2
Documentation/devicetree/bindings/pinctrl/samsung,pinctrl.yaml
··· 42 42 - samsung,s3c2450-pinctrl 43 43 - samsung,s3c64xx-pinctrl 44 44 - samsung,s5pv210-pinctrl 45 + - samsung,exynos2200-pinctrl 45 46 - samsung,exynos3250-pinctrl 46 47 - samsung,exynos4210-pinctrl 47 48 - samsung,exynos4x12-pinctrl ··· 52 51 - samsung,exynos5420-pinctrl 53 52 - samsung,exynos5433-pinctrl 54 53 - samsung,exynos7-pinctrl 54 + - samsung,exynos7870-pinctrl 55 55 - samsung,exynos7885-pinctrl 56 56 - samsung,exynos850-pinctrl 57 57 - samsung,exynos8895-pinctrl
+129
Documentation/devicetree/bindings/pinctrl/sophgo,sg2042-pinctrl.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/pinctrl/sophgo,sg2042-pinctrl.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Sophgo SG2042 Pin Controller 8 + 9 + maintainers: 10 + - Inochi Amaoto <inochiama@outlook.com> 11 + 12 + properties: 13 + compatible: 14 + enum: 15 + - sophgo,sg2042-pinctrl 16 + - sophgo,sg2044-pinctrl 17 + 18 + reg: 19 + maxItems: 1 20 + 21 + patternProperties: 22 + '-cfg$': 23 + type: object 24 + description: 25 + A pinctrl node should contain at least one subnode representing the 26 + pinctrl groups available on the machine. 27 + 28 + additionalProperties: false 29 + 30 + patternProperties: 31 + '-pins$': 32 + type: object 33 + description: | 34 + Each subnode will list the pins it needs, and how they should 35 + be configured, with regard to muxer configuration, bias input 36 + enable/disable, input schmitt trigger enable, drive strength 37 + output enable/disable state. For configuration detail, 38 + refer to https://github.com/sophgo/sophgo-doc/. 39 + 40 + allOf: 41 + - $ref: pincfg-node.yaml# 42 + - $ref: pinmux-node.yaml# 43 + 44 + properties: 45 + pinmux: 46 + description: | 47 + The list of GPIOs and their mux settings that properties in the 48 + node apply to. This should be set using the PINMUX macro. 49 + 50 + bias-disable: true 51 + 52 + bias-pull-up: 53 + type: boolean 54 + 55 + bias-pull-down: 56 + type: boolean 57 + 58 + drive-strength-microamp: 59 + description: typical current when output low level. 60 + 61 + input-schmitt-enable: true 62 + 63 + input-schmitt-disable: true 64 + 65 + required: 66 + - pinmux 67 + 68 + additionalProperties: false 69 + 70 + required: 71 + - compatible 72 + - reg 73 + 74 + allOf: 75 + - if: 76 + properties: 77 + compatible: 78 + contains: 79 + const: sophgo,sg2042-pinctrl 80 + then: 81 + patternProperties: 82 + '-cfg$': 83 + patternProperties: 84 + '-pins$': 85 + properties: 86 + drive-strength-microamp: 87 + enum: [ 5400, 8100, 10700, 13400, 88 + 16100, 18800, 21400, 24100, 89 + 26800, 29400, 32100, 34800, 90 + 37400, 40100, 42800, 45400 ] 91 + 92 + - if: 93 + properties: 94 + compatible: 95 + contains: 96 + const: sophgo,sg2044-pinctrl 97 + then: 98 + patternProperties: 99 + '-cfg$': 100 + patternProperties: 101 + '-pins$': 102 + properties: 103 + drive-strength-microamp: 104 + enum: [ 3200, 6400, 9600, 12700, 105 + 15900, 19100, 22200, 25300, 106 + 29500, 32700, 35900, 39000, 107 + 42000, 45200, 48300, 51400] 108 + 109 + additionalProperties: false 110 + 111 + examples: 112 + - | 113 + #include <dt-bindings/pinctrl/pinctrl-sg2042.h> 114 + 115 + pinctrl@30011000 { 116 + compatible = "sophgo,sg2042-pinctrl"; 117 + reg = <30011000 0x1000>; 118 + 119 + uart0_cfg: uart0-cfg { 120 + uart0-pins { 121 + pinmux = <PINMUX(PIN_UART0_TX, 0)>, 122 + <PINMUX(PIN_UART0_RX, 0)>; 123 + bias-pull-up; 124 + drive-strength-microamp = <13400>; 125 + }; 126 + }; 127 + }; 128 + 129 + ...
+15
MAINTAINERS
··· 1253 1253 F: drivers/perf/amlogic/ 1254 1254 F: include/soc/amlogic/ 1255 1255 1256 + AMLOGIC PINCTRL DRIVER 1257 + M: Xianwei Zhao <xianwei.zhao@amlogic.com> 1258 + L: linux-amlogic@lists.infradead.org 1259 + L: linux-gpio@vger.kernel.org 1260 + S: Maintained 1261 + F: Documentation/devicetree/bindings/pinctrl/amlogic,pinctrl-a4.yaml 1262 + F: drivers/pinctrl/meson/pinctrl-amlogic-a4.c 1263 + 1256 1264 AMLOGIC RTC DRIVER 1257 1265 M: Yiting Deng <yiting.deng@amlogic.com> 1258 1266 M: Xianwei Zhao <xianwei.zhao@amlogic.com> ··· 12058 12050 F: arch/x86/include/asm/intel-mid.h 12059 12051 F: arch/x86/pci/intel_mid_pci.c 12060 12052 F: arch/x86/platform/intel-mid/ 12053 + F: drivers/dma/hsu/ 12061 12054 F: drivers/extcon/extcon-intel-mrfld.c 12055 + F: drivers/gpio/gpio-merrifield.c 12056 + F: drivers/gpio/gpio-tangier.* 12062 12057 F: drivers/iio/adc/intel_mrfld_adc.c 12063 12058 F: drivers/mfd/intel_soc_pmic_mrfld.c 12059 + F: drivers/pinctrl/intel/pinctrl-merrifield.c 12060 + F: drivers/pinctrl/intel/pinctrl-moorefield.c 12061 + F: drivers/pinctrl/intel/pinctrl-tangier.* 12064 12062 F: drivers/platform/x86/intel/mrfld_pwrbtn.c 12065 12063 F: drivers/platform/x86/intel_scu_* 12066 12064 F: drivers/staging/media/atomisp/ 12065 + F: drivers/tty/serial/8250/8250_mid.c 12067 12066 F: drivers/watchdog/intel-mid_wdt.c 12068 12067 F: include/linux/mfd/intel_soc_pmic_mrfld.h 12069 12068 F: include/linux/platform_data/x86/intel-mid_wdt.h
+2 -2
drivers/iio/adc/xilinx-xadc-core.c
··· 1245 1245 channel_templates = xadc_us_channels; 1246 1246 max_channels = ARRAY_SIZE(xadc_us_channels); 1247 1247 } 1248 - channels = devm_kmemdup(dev, channel_templates, 1249 - sizeof(channels[0]) * max_channels, GFP_KERNEL); 1248 + channels = devm_kmemdup_array(dev, channel_templates, max_channels, 1249 + sizeof(*channel_templates), GFP_KERNEL); 1250 1250 if (!channels) 1251 1251 return -ENOMEM; 1252 1252
+2 -3
drivers/input/keyboard/ipaq-micro-keys.c
··· 102 102 103 103 keys->input->keycodesize = sizeof(micro_keycodes[0]); 104 104 keys->input->keycodemax = ARRAY_SIZE(micro_keycodes); 105 - keys->codes = devm_kmemdup(&pdev->dev, micro_keycodes, 106 - keys->input->keycodesize * keys->input->keycodemax, 107 - GFP_KERNEL); 105 + keys->codes = devm_kmemdup_array(&pdev->dev, micro_keycodes, keys->input->keycodemax, 106 + keys->input->keycodesize, GFP_KERNEL); 108 107 if (!keys->codes) 109 108 return -ENOMEM; 110 109
+1 -2
drivers/input/sparse-keymap.c
··· 176 176 for (e = keymap; e->type != KE_END; e++) 177 177 map_size++; 178 178 179 - map = devm_kmemdup(&dev->dev, keymap, map_size * sizeof(*map), 180 - GFP_KERNEL); 179 + map = devm_kmemdup_array(&dev->dev, keymap, map_size, sizeof(*keymap), GFP_KERNEL); 181 180 if (!map) 182 181 return -ENOMEM; 183 182
+14
drivers/pinctrl/Kconfig
··· 49 49 Requires ACPI/FDT device enumeration code to set up a platform 50 50 device. 51 51 52 + config PINCTRL_AMDISP 53 + tristate "AMDISP GPIO pin control" 54 + depends on DRM_AMD_ISP || COMPILE_TEST 55 + depends on HAS_IOMEM 56 + select GPIOLIB 57 + select PINCONF 58 + select GENERIC_PINCONF 59 + help 60 + The driver for memory mapped GPIO functionality on AMD platforms 61 + with ISP support. All the pins are output controlled only 62 + 63 + Requires AMDGPU to MFD add device for enumeration to set up as 64 + platform device. 65 + 52 66 config PINCTRL_APPLE_GPIO 53 67 tristate "Apple SoC GPIO pin controller driver" 54 68 depends on ARCH_APPLE
+1
drivers/pinctrl/Makefile
··· 10 10 obj-$(CONFIG_OF) += devicetree.o 11 11 12 12 obj-$(CONFIG_PINCTRL_AMD) += pinctrl-amd.o 13 + obj-$(CONFIG_PINCTRL_AMDISP) += pinctrl-amdisp.o 13 14 obj-$(CONFIG_PINCTRL_APPLE_GPIO) += pinctrl-apple-gpio.o 14 15 obj-$(CONFIG_PINCTRL_ARTPEC6) += pinctrl-artpec6.o 15 16 obj-$(CONFIG_PINCTRL_AS3722) += pinctrl-as3722.o
+787 -64
drivers/pinctrl/bcm/pinctrl-bcm281xx.c
··· 52 52 #define BCM281XX_HDMI_PIN_REG_MODE_MASK 0x0010 53 53 #define BCM281XX_HDMI_PIN_REG_MODE_SHIFT 4 54 54 55 + /* BCM21664 access lock registers */ 56 + #define BCM21664_WR_ACCESS_OFFSET 0x07F0 57 + #define BCM21664_WR_ACCESS_PASSWORD 0xA5A501 58 + #define BCM21664_ACCESS_LOCK_OFFSET(lock) (0x0780 + (lock * 4)) 59 + #define BCM21664_ACCESS_LOCK_COUNT 5 60 + 55 61 /* 56 62 * bcm281xx_pin_type - types of pin register 57 63 */ ··· 78 72 struct bcm281xx_pin_function { 79 73 const char *name; 80 74 const char * const *groups; 81 - const unsigned ngroups; 75 + const unsigned int ngroups; 76 + }; 77 + 78 + /* 79 + * Device types (used in bcm281xx_pinctrl_desc to differentiate 80 + * the two device types from each other) 81 + */ 82 + enum bcm281xx_pinctrl_type { 83 + BCM281XX_PINCTRL_TYPE, 84 + BCM21664_PINCTRL_TYPE, 85 + }; 86 + 87 + /* 88 + * bcm281xx_pinctrl_info - description of a pinctrl device supported 89 + * by this driver, intended to be used as a provider of OF match data. 90 + */ 91 + struct bcm281xx_pinctrl_info { 92 + enum bcm281xx_pinctrl_type device_type; 93 + 94 + /* List of all pins */ 95 + const struct pinctrl_pin_desc *pins; 96 + unsigned int npins; 97 + 98 + const struct bcm281xx_pin_function *functions; 99 + unsigned int nfunctions; 100 + 101 + const struct regmap_config *regmap_config; 82 102 }; 83 103 84 104 /* ··· 112 80 * @reg_base - base of pinctrl registers 113 81 */ 114 82 struct bcm281xx_pinctrl_data { 83 + struct device *dev; 115 84 void __iomem *reg_base; 116 85 117 - /* List of all pins */ 118 - const struct pinctrl_pin_desc *pins; 119 - const unsigned npins; 120 - 121 - const struct bcm281xx_pin_function *functions; 122 - const unsigned nfunctions; 123 - 124 86 struct regmap *regmap; 87 + const struct bcm281xx_pinctrl_info *info; 125 88 }; 126 89 127 90 /* ··· 960 933 BCM281XX_PIN_FUNCTION(alt4), 961 934 }; 962 935 963 - static struct bcm281xx_pinctrl_data bcm281xx_pinctrl = { 936 + static const struct regmap_config bcm281xx_pinctrl_regmap_config = { 937 + .reg_bits = 32, 938 + .reg_stride = 4, 939 + .val_bits = 32, 940 + .max_register = BCM281XX_PIN_VC_CAM3_SDA * 4, 941 + }; 942 + 943 + static const struct bcm281xx_pinctrl_info bcm281xx_pinctrl = { 944 + .device_type = BCM281XX_PINCTRL_TYPE, 945 + 964 946 .pins = bcm281xx_pinctrl_pins, 965 947 .npins = ARRAY_SIZE(bcm281xx_pinctrl_pins), 966 948 .functions = bcm281xx_functions, 967 949 .nfunctions = ARRAY_SIZE(bcm281xx_functions), 950 + 951 + .regmap_config = &bcm281xx_pinctrl_regmap_config, 968 952 }; 969 953 954 + /* BCM21664 data */ 955 + #define BCM21664_PIN_ADCSYN 0 956 + #define BCM21664_PIN_BATRM 1 957 + #define BCM21664_PIN_BSC1CLK 2 958 + #define BCM21664_PIN_BSC1DAT 3 959 + #define BCM21664_PIN_CAMCS0 4 960 + #define BCM21664_PIN_CAMCS1 5 961 + #define BCM21664_PIN_CLK32K 6 962 + #define BCM21664_PIN_CLK_CX8 7 963 + #define BCM21664_PIN_DCLK1 8 964 + #define BCM21664_PIN_DCLK4 9 965 + #define BCM21664_PIN_DCLKREQ1 10 966 + #define BCM21664_PIN_DCLKREQ4 11 967 + #define BCM21664_PIN_DMIC0CLK 12 968 + #define BCM21664_PIN_DMIC0DQ 13 969 + #define BCM21664_PIN_DSI0TE 14 970 + #define BCM21664_PIN_GPIO00 15 971 + #define BCM21664_PIN_GPIO01 16 972 + #define BCM21664_PIN_GPIO02 17 973 + #define BCM21664_PIN_GPIO03 18 974 + #define BCM21664_PIN_GPIO04 19 975 + #define BCM21664_PIN_GPIO05 20 976 + #define BCM21664_PIN_GPIO06 21 977 + #define BCM21664_PIN_GPIO07 22 978 + #define BCM21664_PIN_GPIO08 23 979 + #define BCM21664_PIN_GPIO09 24 980 + #define BCM21664_PIN_GPIO10 25 981 + #define BCM21664_PIN_GPIO11 26 982 + #define BCM21664_PIN_GPIO12 27 983 + #define BCM21664_PIN_GPIO13 28 984 + #define BCM21664_PIN_GPIO14 29 985 + #define BCM21664_PIN_GPIO15 30 986 + #define BCM21664_PIN_GPIO16 31 987 + #define BCM21664_PIN_GPIO17 32 988 + #define BCM21664_PIN_GPIO18 33 989 + #define BCM21664_PIN_GPIO19 34 990 + #define BCM21664_PIN_GPIO20 35 991 + #define BCM21664_PIN_GPIO21 36 992 + #define BCM21664_PIN_GPIO22 37 993 + #define BCM21664_PIN_GPIO23 38 994 + #define BCM21664_PIN_GPIO24 39 995 + #define BCM21664_PIN_GPIO25 40 996 + #define BCM21664_PIN_GPIO26 41 997 + #define BCM21664_PIN_GPIO27 42 998 + #define BCM21664_PIN_GPIO28 43 999 + #define BCM21664_PIN_GPIO32 44 1000 + #define BCM21664_PIN_GPIO33 45 1001 + #define BCM21664_PIN_GPIO34 46 1002 + #define BCM21664_PIN_GPS_CALREQ 47 1003 + #define BCM21664_PIN_GPS_HOSTREQ 48 1004 + #define BCM21664_PIN_GPS_PABLANK 49 1005 + #define BCM21664_PIN_GPS_TMARK 50 1006 + #define BCM21664_PIN_ICUSBDM 51 1007 + #define BCM21664_PIN_ICUSBDP 52 1008 + #define BCM21664_PIN_LCDCS0 53 1009 + #define BCM21664_PIN_LCDRES 54 1010 + #define BCM21664_PIN_LCDSCL 55 1011 + #define BCM21664_PIN_LCDSDA 56 1012 + #define BCM21664_PIN_LCDTE 57 1013 + #define BCM21664_PIN_MDMGPIO00 58 1014 + #define BCM21664_PIN_MDMGPIO01 59 1015 + #define BCM21664_PIN_MDMGPIO02 60 1016 + #define BCM21664_PIN_MDMGPIO03 61 1017 + #define BCM21664_PIN_MDMGPIO04 62 1018 + #define BCM21664_PIN_MDMGPIO05 63 1019 + #define BCM21664_PIN_MDMGPIO06 64 1020 + #define BCM21664_PIN_MDMGPIO07 65 1021 + #define BCM21664_PIN_MDMGPIO08 66 1022 + #define BCM21664_PIN_MMC0CK 67 1023 + #define BCM21664_PIN_MMC0CMD 68 1024 + #define BCM21664_PIN_MMC0DAT0 69 1025 + #define BCM21664_PIN_MMC0DAT1 70 1026 + #define BCM21664_PIN_MMC0DAT2 71 1027 + #define BCM21664_PIN_MMC0DAT3 72 1028 + #define BCM21664_PIN_MMC0DAT4 73 1029 + #define BCM21664_PIN_MMC0DAT5 74 1030 + #define BCM21664_PIN_MMC0DAT6 75 1031 + #define BCM21664_PIN_MMC0DAT7 76 1032 + #define BCM21664_PIN_MMC0RST 77 1033 + #define BCM21664_PIN_MMC1CK 78 1034 + #define BCM21664_PIN_MMC1CMD 79 1035 + #define BCM21664_PIN_MMC1DAT0 80 1036 + #define BCM21664_PIN_MMC1DAT1 81 1037 + #define BCM21664_PIN_MMC1DAT2 82 1038 + #define BCM21664_PIN_MMC1DAT3 83 1039 + #define BCM21664_PIN_MMC1DAT4 84 1040 + #define BCM21664_PIN_MMC1DAT5 85 1041 + #define BCM21664_PIN_MMC1DAT6 86 1042 + #define BCM21664_PIN_MMC1DAT7 87 1043 + #define BCM21664_PIN_MMC1RST 88 1044 + #define BCM21664_PIN_PC1 89 1045 + #define BCM21664_PIN_PC2 90 1046 + #define BCM21664_PIN_PMBSCCLK 91 1047 + #define BCM21664_PIN_PMBSCDAT 92 1048 + #define BCM21664_PIN_PMUINT 93 1049 + #define BCM21664_PIN_RESETN 94 1050 + #define BCM21664_PIN_RFST2G_MTSLOTEN3G 95 1051 + #define BCM21664_PIN_RTXDATA2G_TXDATA3G1 96 1052 + #define BCM21664_PIN_RTXEN2G_TXDATA3G2 97 1053 + #define BCM21664_PIN_RXDATA3G0 98 1054 + #define BCM21664_PIN_RXDATA3G1 99 1055 + #define BCM21664_PIN_RXDATA3G2 100 1056 + #define BCM21664_PIN_SDCK 101 1057 + #define BCM21664_PIN_SDCMD 102 1058 + #define BCM21664_PIN_SDDAT0 103 1059 + #define BCM21664_PIN_SDDAT1 104 1060 + #define BCM21664_PIN_SDDAT2 105 1061 + #define BCM21664_PIN_SDDAT3 106 1062 + #define BCM21664_PIN_SIMCLK 107 1063 + #define BCM21664_PIN_SIMDAT 108 1064 + #define BCM21664_PIN_SIMDET 109 1065 + #define BCM21664_PIN_SIMRST 110 1066 + #define BCM21664_PIN_GPIO93 111 1067 + #define BCM21664_PIN_GPIO94 112 1068 + #define BCM21664_PIN_SPI0CLK 113 1069 + #define BCM21664_PIN_SPI0FSS 114 1070 + #define BCM21664_PIN_SPI0RXD 115 1071 + #define BCM21664_PIN_SPI0TXD 116 1072 + #define BCM21664_PIN_SRI_C 117 1073 + #define BCM21664_PIN_SRI_D 118 1074 + #define BCM21664_PIN_SRI_E 119 1075 + #define BCM21664_PIN_SSPCK 120 1076 + #define BCM21664_PIN_SSPDI 121 1077 + #define BCM21664_PIN_SSPDO 122 1078 + #define BCM21664_PIN_SSPSYN 123 1079 + #define BCM21664_PIN_STAT1 124 1080 + #define BCM21664_PIN_STAT2 125 1081 + #define BCM21664_PIN_SWCLKTCK 126 1082 + #define BCM21664_PIN_SWDIOTMS 127 1083 + #define BCM21664_PIN_SYSCLKEN 128 1084 + #define BCM21664_PIN_TDI 129 1085 + #define BCM21664_PIN_TDO 130 1086 + #define BCM21664_PIN_TESTMODE 131 1087 + #define BCM21664_PIN_TRACECLK 132 1088 + #define BCM21664_PIN_TRACEDT00 133 1089 + #define BCM21664_PIN_TRACEDT01 134 1090 + #define BCM21664_PIN_TRACEDT02 135 1091 + #define BCM21664_PIN_TRACEDT03 136 1092 + #define BCM21664_PIN_TRACEDT04 137 1093 + #define BCM21664_PIN_TRACEDT05 138 1094 + #define BCM21664_PIN_TRACEDT06 139 1095 + #define BCM21664_PIN_TRACEDT07 140 1096 + #define BCM21664_PIN_TRSTB 141 1097 + #define BCM21664_PIN_TXDATA3G0 142 1098 + #define BCM21664_PIN_UBCTSN 143 1099 + #define BCM21664_PIN_UBRTSN 144 1100 + #define BCM21664_PIN_UBRX 145 1101 + #define BCM21664_PIN_UBTX 146 1102 + #define BCM21664_PIN_TRACEDT08 147 1103 + #define BCM21664_PIN_TRACEDT09 148 1104 + #define BCM21664_PIN_TRACEDT10 149 1105 + #define BCM21664_PIN_TRACEDT11 150 1106 + #define BCM21664_PIN_TRACEDT12 151 1107 + #define BCM21664_PIN_TRACEDT13 152 1108 + #define BCM21664_PIN_TRACEDT14 153 1109 + #define BCM21664_PIN_TRACEDT15 154 1110 + 1111 + static const struct pinctrl_pin_desc bcm21664_pinctrl_pins[] = { 1112 + BCM281XX_PIN_DESC(BCM21664_PIN_ADCSYN, "adcsyn", std), 1113 + BCM281XX_PIN_DESC(BCM21664_PIN_BATRM, "batrm", std), 1114 + BCM281XX_PIN_DESC(BCM21664_PIN_BSC1CLK, "bsc1clk", i2c), 1115 + BCM281XX_PIN_DESC(BCM21664_PIN_BSC1DAT, "bsc1dat", i2c), 1116 + BCM281XX_PIN_DESC(BCM21664_PIN_CAMCS0, "camcs0", std), 1117 + BCM281XX_PIN_DESC(BCM21664_PIN_CAMCS1, "camcs1", std), 1118 + BCM281XX_PIN_DESC(BCM21664_PIN_CLK32K, "clk32k", std), 1119 + BCM281XX_PIN_DESC(BCM21664_PIN_CLK_CX8, "clk_cx8", std), 1120 + BCM281XX_PIN_DESC(BCM21664_PIN_DCLK1, "dclk1", std), 1121 + BCM281XX_PIN_DESC(BCM21664_PIN_DCLK4, "dclk4", std), 1122 + BCM281XX_PIN_DESC(BCM21664_PIN_DCLKREQ1, "dclkreq1", std), 1123 + BCM281XX_PIN_DESC(BCM21664_PIN_DCLKREQ4, "dclkreq4", std), 1124 + BCM281XX_PIN_DESC(BCM21664_PIN_DMIC0CLK, "dmic0clk", std), 1125 + BCM281XX_PIN_DESC(BCM21664_PIN_DMIC0DQ, "dmic0dq", std), 1126 + BCM281XX_PIN_DESC(BCM21664_PIN_DSI0TE, "dsi0te", std), 1127 + BCM281XX_PIN_DESC(BCM21664_PIN_GPIO00, "gpio00", std), 1128 + BCM281XX_PIN_DESC(BCM21664_PIN_GPIO01, "gpio01", std), 1129 + BCM281XX_PIN_DESC(BCM21664_PIN_GPIO02, "gpio02", std), 1130 + BCM281XX_PIN_DESC(BCM21664_PIN_GPIO03, "gpio03", std), 1131 + BCM281XX_PIN_DESC(BCM21664_PIN_GPIO04, "gpio04", std), 1132 + BCM281XX_PIN_DESC(BCM21664_PIN_GPIO05, "gpio05", std), 1133 + BCM281XX_PIN_DESC(BCM21664_PIN_GPIO06, "gpio06", std), 1134 + BCM281XX_PIN_DESC(BCM21664_PIN_GPIO07, "gpio07", std), 1135 + BCM281XX_PIN_DESC(BCM21664_PIN_GPIO08, "gpio08", std), 1136 + BCM281XX_PIN_DESC(BCM21664_PIN_GPIO09, "gpio09", std), 1137 + BCM281XX_PIN_DESC(BCM21664_PIN_GPIO10, "gpio10", std), 1138 + BCM281XX_PIN_DESC(BCM21664_PIN_GPIO11, "gpio11", std), 1139 + BCM281XX_PIN_DESC(BCM21664_PIN_GPIO12, "gpio12", std), 1140 + BCM281XX_PIN_DESC(BCM21664_PIN_GPIO13, "gpio13", std), 1141 + BCM281XX_PIN_DESC(BCM21664_PIN_GPIO14, "gpio14", std), 1142 + BCM281XX_PIN_DESC(BCM21664_PIN_GPIO15, "gpio15", std), 1143 + BCM281XX_PIN_DESC(BCM21664_PIN_GPIO16, "gpio16", i2c), 1144 + BCM281XX_PIN_DESC(BCM21664_PIN_GPIO17, "gpio17", i2c), 1145 + BCM281XX_PIN_DESC(BCM21664_PIN_GPIO18, "gpio18", std), 1146 + BCM281XX_PIN_DESC(BCM21664_PIN_GPIO19, "gpio19", std), 1147 + BCM281XX_PIN_DESC(BCM21664_PIN_GPIO20, "gpio20", std), 1148 + BCM281XX_PIN_DESC(BCM21664_PIN_GPIO21, "gpio21", std), 1149 + BCM281XX_PIN_DESC(BCM21664_PIN_GPIO22, "gpio22", std), 1150 + BCM281XX_PIN_DESC(BCM21664_PIN_GPIO23, "gpio23", std), 1151 + BCM281XX_PIN_DESC(BCM21664_PIN_GPIO24, "gpio24", std), 1152 + BCM281XX_PIN_DESC(BCM21664_PIN_GPIO25, "gpio25", std), 1153 + BCM281XX_PIN_DESC(BCM21664_PIN_GPIO26, "gpio26", std), 1154 + BCM281XX_PIN_DESC(BCM21664_PIN_GPIO27, "gpio27", std), 1155 + BCM281XX_PIN_DESC(BCM21664_PIN_GPIO28, "gpio28", std), 1156 + BCM281XX_PIN_DESC(BCM21664_PIN_GPIO32, "gpio32", std), 1157 + BCM281XX_PIN_DESC(BCM21664_PIN_GPIO33, "gpio33", std), 1158 + BCM281XX_PIN_DESC(BCM21664_PIN_GPIO34, "gpio34", std), 1159 + BCM281XX_PIN_DESC(BCM21664_PIN_GPS_CALREQ, "gps_calreq", std), 1160 + BCM281XX_PIN_DESC(BCM21664_PIN_GPS_HOSTREQ, "gps_hostreq", std), 1161 + BCM281XX_PIN_DESC(BCM21664_PIN_GPS_PABLANK, "gps_pablank", std), 1162 + BCM281XX_PIN_DESC(BCM21664_PIN_GPS_TMARK, "gps_tmark", std), 1163 + BCM281XX_PIN_DESC(BCM21664_PIN_ICUSBDM, "icusbdm", std), 1164 + BCM281XX_PIN_DESC(BCM21664_PIN_ICUSBDP, "icusbdp", std), 1165 + BCM281XX_PIN_DESC(BCM21664_PIN_LCDCS0, "lcdcs0", std), 1166 + BCM281XX_PIN_DESC(BCM21664_PIN_LCDRES, "lcdres", std), 1167 + BCM281XX_PIN_DESC(BCM21664_PIN_LCDSCL, "lcdscl", std), 1168 + BCM281XX_PIN_DESC(BCM21664_PIN_LCDSDA, "lcdsda", std), 1169 + BCM281XX_PIN_DESC(BCM21664_PIN_LCDTE, "lcdte", std), 1170 + BCM281XX_PIN_DESC(BCM21664_PIN_MDMGPIO00, "mdmgpio00", std), 1171 + BCM281XX_PIN_DESC(BCM21664_PIN_MDMGPIO01, "mdmgpio01", std), 1172 + BCM281XX_PIN_DESC(BCM21664_PIN_MDMGPIO02, "mdmgpio02", std), 1173 + BCM281XX_PIN_DESC(BCM21664_PIN_MDMGPIO03, "mdmgpio03", std), 1174 + BCM281XX_PIN_DESC(BCM21664_PIN_MDMGPIO04, "mdmgpio04", std), 1175 + BCM281XX_PIN_DESC(BCM21664_PIN_MDMGPIO05, "mdmgpio05", std), 1176 + BCM281XX_PIN_DESC(BCM21664_PIN_MDMGPIO06, "mdmgpio06", std), 1177 + BCM281XX_PIN_DESC(BCM21664_PIN_MDMGPIO07, "mdmgpio07", std), 1178 + BCM281XX_PIN_DESC(BCM21664_PIN_MDMGPIO08, "mdmgpio08", std), 1179 + BCM281XX_PIN_DESC(BCM21664_PIN_MMC0CK, "mmc0ck", std), 1180 + BCM281XX_PIN_DESC(BCM21664_PIN_MMC0CMD, "mmc0cmd", std), 1181 + BCM281XX_PIN_DESC(BCM21664_PIN_MMC0DAT0, "mmc0dat0", std), 1182 + BCM281XX_PIN_DESC(BCM21664_PIN_MMC0DAT1, "mmc0dat1", std), 1183 + BCM281XX_PIN_DESC(BCM21664_PIN_MMC0DAT2, "mmc0dat2", std), 1184 + BCM281XX_PIN_DESC(BCM21664_PIN_MMC0DAT3, "mmc0dat3", std), 1185 + BCM281XX_PIN_DESC(BCM21664_PIN_MMC0DAT4, "mmc0dat4", std), 1186 + BCM281XX_PIN_DESC(BCM21664_PIN_MMC0DAT5, "mmc0dat5", std), 1187 + BCM281XX_PIN_DESC(BCM21664_PIN_MMC0DAT6, "mmc0dat6", std), 1188 + BCM281XX_PIN_DESC(BCM21664_PIN_MMC0DAT7, "mmc0dat7", std), 1189 + BCM281XX_PIN_DESC(BCM21664_PIN_MMC0RST, "mmc0rst", std), 1190 + BCM281XX_PIN_DESC(BCM21664_PIN_MMC1CK, "mmc1ck", std), 1191 + BCM281XX_PIN_DESC(BCM21664_PIN_MMC1CMD, "mmc1cmd", std), 1192 + BCM281XX_PIN_DESC(BCM21664_PIN_MMC1DAT0, "mmc1dat0", std), 1193 + BCM281XX_PIN_DESC(BCM21664_PIN_MMC1DAT1, "mmc1dat1", std), 1194 + BCM281XX_PIN_DESC(BCM21664_PIN_MMC1DAT2, "mmc1dat2", std), 1195 + BCM281XX_PIN_DESC(BCM21664_PIN_MMC1DAT3, "mmc1dat3", std), 1196 + BCM281XX_PIN_DESC(BCM21664_PIN_MMC1DAT4, "mmc1dat4", std), 1197 + BCM281XX_PIN_DESC(BCM21664_PIN_MMC1DAT5, "mmc1dat5", std), 1198 + BCM281XX_PIN_DESC(BCM21664_PIN_MMC1DAT6, "mmc1dat6", std), 1199 + BCM281XX_PIN_DESC(BCM21664_PIN_MMC1DAT7, "mmc1dat7", std), 1200 + BCM281XX_PIN_DESC(BCM21664_PIN_MMC1RST, "mmc1rst", std), 1201 + BCM281XX_PIN_DESC(BCM21664_PIN_PC1, "pc1", std), 1202 + BCM281XX_PIN_DESC(BCM21664_PIN_PC2, "pc2", std), 1203 + BCM281XX_PIN_DESC(BCM21664_PIN_PMBSCCLK, "pmbscclk", i2c), 1204 + BCM281XX_PIN_DESC(BCM21664_PIN_PMBSCDAT, "pmbscdat", i2c), 1205 + BCM281XX_PIN_DESC(BCM21664_PIN_PMUINT, "pmuint", std), 1206 + BCM281XX_PIN_DESC(BCM21664_PIN_RESETN, "resetn", std), 1207 + BCM281XX_PIN_DESC(BCM21664_PIN_RFST2G_MTSLOTEN3G, "rfst2g_mtsloten3g", std), 1208 + BCM281XX_PIN_DESC(BCM21664_PIN_RTXDATA2G_TXDATA3G1, "rtxdata2g_txdata3g1", std), 1209 + BCM281XX_PIN_DESC(BCM21664_PIN_RTXEN2G_TXDATA3G2, "rtxen2g_txdata3g2", std), 1210 + BCM281XX_PIN_DESC(BCM21664_PIN_RXDATA3G0, "rxdata3g0", std), 1211 + BCM281XX_PIN_DESC(BCM21664_PIN_RXDATA3G1, "rxdata3g1", std), 1212 + BCM281XX_PIN_DESC(BCM21664_PIN_RXDATA3G2, "rxdata3g2", std), 1213 + BCM281XX_PIN_DESC(BCM21664_PIN_SDCK, "sdck", std), 1214 + BCM281XX_PIN_DESC(BCM21664_PIN_SDCMD, "sdcmd", std), 1215 + BCM281XX_PIN_DESC(BCM21664_PIN_SDDAT0, "sddat0", std), 1216 + BCM281XX_PIN_DESC(BCM21664_PIN_SDDAT1, "sddat1", std), 1217 + BCM281XX_PIN_DESC(BCM21664_PIN_SDDAT2, "sddat2", std), 1218 + BCM281XX_PIN_DESC(BCM21664_PIN_SDDAT3, "sddat3", std), 1219 + BCM281XX_PIN_DESC(BCM21664_PIN_SIMCLK, "simclk", std), 1220 + BCM281XX_PIN_DESC(BCM21664_PIN_SIMDAT, "simdat", std), 1221 + BCM281XX_PIN_DESC(BCM21664_PIN_SIMDET, "simdet", std), 1222 + BCM281XX_PIN_DESC(BCM21664_PIN_SIMRST, "simrst", std), 1223 + BCM281XX_PIN_DESC(BCM21664_PIN_GPIO93, "gpio93", std), 1224 + BCM281XX_PIN_DESC(BCM21664_PIN_GPIO94, "gpio94", std), 1225 + BCM281XX_PIN_DESC(BCM21664_PIN_SPI0CLK, "spi0clk", std), 1226 + BCM281XX_PIN_DESC(BCM21664_PIN_SPI0FSS, "spi0fss", std), 1227 + BCM281XX_PIN_DESC(BCM21664_PIN_SPI0RXD, "spi0rxd", std), 1228 + BCM281XX_PIN_DESC(BCM21664_PIN_SPI0TXD, "spi0txd", std), 1229 + BCM281XX_PIN_DESC(BCM21664_PIN_SRI_C, "sri_c", std), 1230 + BCM281XX_PIN_DESC(BCM21664_PIN_SRI_D, "sri_d", std), 1231 + BCM281XX_PIN_DESC(BCM21664_PIN_SRI_E, "sri_e", std), 1232 + BCM281XX_PIN_DESC(BCM21664_PIN_SSPCK, "sspck", std), 1233 + BCM281XX_PIN_DESC(BCM21664_PIN_SSPDI, "sspdi", std), 1234 + BCM281XX_PIN_DESC(BCM21664_PIN_SSPDO, "sspdo", std), 1235 + BCM281XX_PIN_DESC(BCM21664_PIN_SSPSYN, "sspsyn", std), 1236 + BCM281XX_PIN_DESC(BCM21664_PIN_STAT1, "stat1", std), 1237 + BCM281XX_PIN_DESC(BCM21664_PIN_STAT2, "stat2", std), 1238 + BCM281XX_PIN_DESC(BCM21664_PIN_SWCLKTCK, "swclktck", std), 1239 + BCM281XX_PIN_DESC(BCM21664_PIN_SWDIOTMS, "swdiotms", std), 1240 + BCM281XX_PIN_DESC(BCM21664_PIN_SYSCLKEN, "sysclken", std), 1241 + BCM281XX_PIN_DESC(BCM21664_PIN_TDI, "tdi", std), 1242 + BCM281XX_PIN_DESC(BCM21664_PIN_TDO, "tdo", std), 1243 + BCM281XX_PIN_DESC(BCM21664_PIN_TESTMODE, "testmode", std), 1244 + BCM281XX_PIN_DESC(BCM21664_PIN_TRACECLK, "traceclk", std), 1245 + BCM281XX_PIN_DESC(BCM21664_PIN_TRACEDT00, "tracedt00", std), 1246 + BCM281XX_PIN_DESC(BCM21664_PIN_TRACEDT01, "tracedt01", std), 1247 + BCM281XX_PIN_DESC(BCM21664_PIN_TRACEDT02, "tracedt02", std), 1248 + BCM281XX_PIN_DESC(BCM21664_PIN_TRACEDT03, "tracedt03", std), 1249 + BCM281XX_PIN_DESC(BCM21664_PIN_TRACEDT04, "tracedt04", std), 1250 + BCM281XX_PIN_DESC(BCM21664_PIN_TRACEDT05, "tracedt05", std), 1251 + BCM281XX_PIN_DESC(BCM21664_PIN_TRACEDT06, "tracedt06", std), 1252 + BCM281XX_PIN_DESC(BCM21664_PIN_TRACEDT07, "tracedt07", std), 1253 + BCM281XX_PIN_DESC(BCM21664_PIN_TRSTB, "trstb", std), 1254 + BCM281XX_PIN_DESC(BCM21664_PIN_TXDATA3G0, "txdata3g0", std), 1255 + BCM281XX_PIN_DESC(BCM21664_PIN_UBCTSN, "ubctsn", std), 1256 + BCM281XX_PIN_DESC(BCM21664_PIN_UBRTSN, "ubrtsn", std), 1257 + BCM281XX_PIN_DESC(BCM21664_PIN_UBRX, "ubrx", std), 1258 + BCM281XX_PIN_DESC(BCM21664_PIN_UBTX, "ubtx", std), 1259 + BCM281XX_PIN_DESC(BCM21664_PIN_TRACEDT08, "tracedt08", std), 1260 + BCM281XX_PIN_DESC(BCM21664_PIN_TRACEDT09, "tracedt09", std), 1261 + BCM281XX_PIN_DESC(BCM21664_PIN_TRACEDT10, "tracedt10", std), 1262 + BCM281XX_PIN_DESC(BCM21664_PIN_TRACEDT11, "tracedt11", std), 1263 + BCM281XX_PIN_DESC(BCM21664_PIN_TRACEDT12, "tracedt12", std), 1264 + BCM281XX_PIN_DESC(BCM21664_PIN_TRACEDT13, "tracedt13", std), 1265 + BCM281XX_PIN_DESC(BCM21664_PIN_TRACEDT14, "tracedt14", std), 1266 + BCM281XX_PIN_DESC(BCM21664_PIN_TRACEDT15, "tracedt15", std), 1267 + }; 1268 + 1269 + static const char * const bcm21664_alt_groups[] = { 1270 + "adcsyn", 1271 + "batrm", 1272 + "bsc1clk", 1273 + "bsc1dat", 1274 + "camcs0", 1275 + "camcs1", 1276 + "clk32k", 1277 + "clk_cx8", 1278 + "dclk1", 1279 + "dclk4", 1280 + "dclkreq1", 1281 + "dclkreq4", 1282 + "dmic0clk", 1283 + "dmic0dq", 1284 + "dsi0te", 1285 + "gpio00", 1286 + "gpio01", 1287 + "gpio02", 1288 + "gpio03", 1289 + "gpio04", 1290 + "gpio05", 1291 + "gpio06", 1292 + "gpio07", 1293 + "gpio08", 1294 + "gpio09", 1295 + "gpio10", 1296 + "gpio11", 1297 + "gpio12", 1298 + "gpio13", 1299 + "gpio14", 1300 + "gpio15", 1301 + "gpio16", 1302 + "gpio17", 1303 + "gpio18", 1304 + "gpio19", 1305 + "gpio20", 1306 + "gpio21", 1307 + "gpio22", 1308 + "gpio23", 1309 + "gpio24", 1310 + "gpio25", 1311 + "gpio26", 1312 + "gpio27", 1313 + "gpio28", 1314 + "gpio32", 1315 + "gpio33", 1316 + "gpio34", 1317 + "gps_calreq", 1318 + "gps_hostreq", 1319 + "gps_pablank", 1320 + "gps_tmark", 1321 + "icusbdm", 1322 + "icusbdp", 1323 + "lcdcs0", 1324 + "lcdres", 1325 + "lcdscl", 1326 + "lcdsda", 1327 + "lcdte", 1328 + "mdmgpio00", 1329 + "mdmgpio01", 1330 + "mdmgpio02", 1331 + "mdmgpio03", 1332 + "mdmgpio04", 1333 + "mdmgpio05", 1334 + "mdmgpio06", 1335 + "mdmgpio07", 1336 + "mdmgpio08", 1337 + "mmc0ck", 1338 + "mmc0cmd", 1339 + "mmc0dat0", 1340 + "mmc0dat1", 1341 + "mmc0dat2", 1342 + "mmc0dat3", 1343 + "mmc0dat4", 1344 + "mmc0dat5", 1345 + "mmc0dat6", 1346 + "mmc0dat7", 1347 + "mmc0rst", 1348 + "mmc1ck", 1349 + "mmc1cmd", 1350 + "mmc1dat0", 1351 + "mmc1dat1", 1352 + "mmc1dat2", 1353 + "mmc1dat3", 1354 + "mmc1dat4", 1355 + "mmc1dat5", 1356 + "mmc1dat6", 1357 + "mmc1dat7", 1358 + "mmc1rst", 1359 + "pc1", 1360 + "pc2", 1361 + "pmbscclk", 1362 + "pmbscdat", 1363 + "pmuint", 1364 + "resetn", 1365 + "rfst2g_mtsloten3g", 1366 + "rtxdata2g_txdata3g1", 1367 + "rtxen2g_txdata3g2", 1368 + "rxdata3g0", 1369 + "rxdata3g1", 1370 + "rxdata3g2", 1371 + "sdck", 1372 + "sdcmd", 1373 + "sddat0", 1374 + "sddat1", 1375 + "sddat2", 1376 + "sddat3", 1377 + "simclk", 1378 + "simdat", 1379 + "simdet", 1380 + "simrst", 1381 + "gpio93", 1382 + "gpio94", 1383 + "spi0clk", 1384 + "spi0fss", 1385 + "spi0rxd", 1386 + "spi0txd", 1387 + "sri_c", 1388 + "sri_d", 1389 + "sri_e", 1390 + "sspck", 1391 + "sspdi", 1392 + "sspdo", 1393 + "sspsyn", 1394 + "stat1", 1395 + "stat2", 1396 + "swclktck", 1397 + "swdiotms", 1398 + "sysclken", 1399 + "tdi", 1400 + "tdo", 1401 + "testmode", 1402 + "traceclk", 1403 + "tracedt00", 1404 + "tracedt01", 1405 + "tracedt02", 1406 + "tracedt03", 1407 + "tracedt04", 1408 + "tracedt05", 1409 + "tracedt06", 1410 + "tracedt07", 1411 + "trstb", 1412 + "txdata3g0", 1413 + "ubctsn", 1414 + "ubrtsn", 1415 + "ubrx", 1416 + "ubtx", 1417 + "tracedt08", 1418 + "tracedt09", 1419 + "tracedt10", 1420 + "tracedt11", 1421 + "tracedt12", 1422 + "tracedt13", 1423 + "tracedt14", 1424 + "tracedt15", 1425 + }; 1426 + 1427 + #define BCM21664_PIN_FUNCTION(fcn_name) \ 1428 + { \ 1429 + .name = #fcn_name, \ 1430 + .groups = bcm21664_alt_groups, \ 1431 + .ngroups = ARRAY_SIZE(bcm21664_alt_groups), \ 1432 + } 1433 + 1434 + static const struct bcm281xx_pin_function bcm21664_functions[] = { 1435 + BCM21664_PIN_FUNCTION(alt1), 1436 + BCM21664_PIN_FUNCTION(alt2), 1437 + BCM21664_PIN_FUNCTION(alt3), 1438 + BCM21664_PIN_FUNCTION(alt4), 1439 + BCM21664_PIN_FUNCTION(alt5), 1440 + BCM21664_PIN_FUNCTION(alt6), 1441 + }; 1442 + 1443 + static const struct regmap_config bcm21664_pinctrl_regmap_config = { 1444 + .reg_bits = 32, 1445 + .reg_stride = 4, 1446 + .val_bits = 32, 1447 + .max_register = BCM21664_WR_ACCESS_OFFSET, 1448 + }; 1449 + 1450 + static const struct bcm281xx_pinctrl_info bcm21664_pinctrl = { 1451 + .device_type = BCM21664_PINCTRL_TYPE, 1452 + 1453 + .pins = bcm21664_pinctrl_pins, 1454 + .npins = ARRAY_SIZE(bcm21664_pinctrl_pins), 1455 + .functions = bcm21664_functions, 1456 + .nfunctions = ARRAY_SIZE(bcm21664_functions), 1457 + 1458 + .regmap_config = &bcm21664_pinctrl_regmap_config, 1459 + }; 1460 + 1461 + /* BCM21664 pinctrl access lock handlers */ 1462 + static int bcm21664_pinctrl_lock_all(struct bcm281xx_pinctrl_data *pdata) 1463 + { 1464 + int i, rc; 1465 + 1466 + for (i = 0; i < BCM21664_ACCESS_LOCK_COUNT; i++) { 1467 + rc = regmap_write(pdata->regmap, BCM21664_WR_ACCESS_OFFSET, 1468 + BCM21664_WR_ACCESS_PASSWORD); 1469 + if (rc) { 1470 + dev_err(pdata->dev, "Failed to enable write access: %d\n", 1471 + rc); 1472 + return rc; 1473 + } 1474 + rc = regmap_write(pdata->regmap, BCM21664_ACCESS_LOCK_OFFSET(i), 1475 + 0xffffffff); 1476 + if (rc) { 1477 + dev_err(pdata->dev, "Failed to write access lock: %d\n", 1478 + rc); 1479 + return rc; 1480 + } 1481 + } 1482 + 1483 + return 0; 1484 + } 1485 + 1486 + static int bcm21664_pinctrl_set_pin_lock(struct bcm281xx_pinctrl_data *pdata, 1487 + unsigned int pin, bool lock) 1488 + { 1489 + unsigned int access_lock = pin / 32; 1490 + int rc; 1491 + 1492 + dev_dbg(pdata->dev, 1493 + "%s(): %s pin %s (%d)\n", 1494 + __func__, lock ? "Lock" : "Unlock", pdata->info->pins[pin].name, 1495 + pin); 1496 + 1497 + rc = regmap_write(pdata->regmap, BCM21664_WR_ACCESS_OFFSET, 1498 + BCM21664_WR_ACCESS_PASSWORD); 1499 + if (rc) { 1500 + dev_err(pdata->dev, "Failed to enable write access: %d\n", 1501 + rc); 1502 + return rc; 1503 + } 1504 + 1505 + rc = regmap_update_bits(pdata->regmap, 1506 + BCM21664_ACCESS_LOCK_OFFSET(access_lock), 1507 + BIT(pin % 32), 1508 + (int)lock << (pin % 32)); 1509 + 1510 + if (rc) { 1511 + dev_err(pdata->dev, "Failed to %s pin: %d\n", 1512 + lock ? "lock" : "unlock", rc); 1513 + return rc; 1514 + } 1515 + 1516 + return 0; 1517 + } 1518 + 970 1519 static inline enum bcm281xx_pin_type pin_type_get(struct pinctrl_dev *pctldev, 971 - unsigned pin) 1520 + unsigned int pin) 972 1521 { 973 1522 struct bcm281xx_pinctrl_data *pdata = pinctrl_dev_get_drvdata(pctldev); 974 1523 975 - if (pin >= pdata->npins) 1524 + if (pin >= pdata->info->npins) 976 1525 return BCM281XX_PIN_TYPE_UNKNOWN; 977 1526 978 - return *(enum bcm281xx_pin_type *)(pdata->pins[pin].drv_data); 1527 + return *(enum bcm281xx_pin_type *)(pdata->info->pins[pin].drv_data); 979 1528 } 980 1529 981 1530 #define BCM281XX_PIN_SHIFT(type, param) \ ··· 1573 970 *reg_mask |= param_mask; 1574 971 } 1575 972 1576 - static const struct regmap_config bcm281xx_pinctrl_regmap_config = { 1577 - .reg_bits = 32, 1578 - .reg_stride = 4, 1579 - .val_bits = 32, 1580 - .max_register = BCM281XX_PIN_VC_CAM3_SDA * 4, 1581 - }; 1582 - 1583 973 static int bcm281xx_pinctrl_get_groups_count(struct pinctrl_dev *pctldev) 1584 974 { 1585 975 struct bcm281xx_pinctrl_data *pdata = pinctrl_dev_get_drvdata(pctldev); 1586 976 1587 - return pdata->npins; 977 + return pdata->info->npins; 1588 978 } 1589 979 1590 980 static const char *bcm281xx_pinctrl_get_group_name(struct pinctrl_dev *pctldev, 1591 - unsigned group) 981 + unsigned int group) 1592 982 { 1593 983 struct bcm281xx_pinctrl_data *pdata = pinctrl_dev_get_drvdata(pctldev); 1594 984 1595 - return pdata->pins[group].name; 985 + return pdata->info->pins[group].name; 1596 986 } 1597 987 1598 988 static int bcm281xx_pinctrl_get_group_pins(struct pinctrl_dev *pctldev, 1599 - unsigned group, 989 + unsigned int group, 1600 990 const unsigned **pins, 1601 - unsigned *num_pins) 991 + unsigned int *num_pins) 1602 992 { 1603 993 struct bcm281xx_pinctrl_data *pdata = pinctrl_dev_get_drvdata(pctldev); 1604 994 1605 - *pins = &pdata->pins[group].number; 995 + *pins = &pdata->info->pins[group].number; 1606 996 *num_pins = 1; 1607 997 1608 998 return 0; ··· 1603 1007 1604 1008 static void bcm281xx_pinctrl_pin_dbg_show(struct pinctrl_dev *pctldev, 1605 1009 struct seq_file *s, 1606 - unsigned offset) 1010 + unsigned int offset) 1607 1011 { 1608 1012 seq_printf(s, " %s", dev_name(pctldev->dev)); 1609 1013 } ··· 1621 1025 { 1622 1026 struct bcm281xx_pinctrl_data *pdata = pinctrl_dev_get_drvdata(pctldev); 1623 1027 1624 - return pdata->nfunctions; 1028 + return pdata->info->nfunctions; 1625 1029 } 1626 1030 1627 1031 static const char *bcm281xx_pinctrl_get_fcn_name(struct pinctrl_dev *pctldev, 1628 - unsigned function) 1032 + unsigned int function) 1629 1033 { 1630 1034 struct bcm281xx_pinctrl_data *pdata = pinctrl_dev_get_drvdata(pctldev); 1631 1035 1632 - return pdata->functions[function].name; 1036 + return pdata->info->functions[function].name; 1633 1037 } 1634 1038 1635 1039 static int bcm281xx_pinctrl_get_fcn_groups(struct pinctrl_dev *pctldev, 1636 - unsigned function, 1040 + unsigned int function, 1637 1041 const char * const **groups, 1638 - unsigned * const num_groups) 1042 + unsigned int * const num_groups) 1639 1043 { 1640 1044 struct bcm281xx_pinctrl_data *pdata = pinctrl_dev_get_drvdata(pctldev); 1641 1045 1642 - *groups = pdata->functions[function].groups; 1643 - *num_groups = pdata->functions[function].ngroups; 1046 + *groups = pdata->info->functions[function].groups; 1047 + *num_groups = pdata->info->functions[function].ngroups; 1644 1048 1645 1049 return 0; 1646 1050 } 1647 1051 1648 1052 static int bcm281xx_pinmux_set(struct pinctrl_dev *pctldev, 1649 - unsigned function, 1650 - unsigned group) 1053 + unsigned int function, 1054 + unsigned int group) 1651 1055 { 1652 1056 struct bcm281xx_pinctrl_data *pdata = pinctrl_dev_get_drvdata(pctldev); 1653 - const struct bcm281xx_pin_function *f = &pdata->functions[function]; 1654 - u32 offset = 4 * pdata->pins[group].number; 1057 + const struct bcm281xx_pin_function *f = &pdata->info->functions[function]; 1058 + enum bcm281xx_pinctrl_type device_type = pdata->info->device_type; 1059 + unsigned int pin = pdata->info->pins[group].number; 1060 + u32 offset = 4 * pin; 1655 1061 int rc = 0; 1656 1062 1657 1063 dev_dbg(pctldev->dev, 1658 1064 "%s(): Enable function %s (%d) of pin %s (%d) @offset 0x%x.\n", 1659 - __func__, f->name, function, pdata->pins[group].name, 1660 - pdata->pins[group].number, offset); 1065 + __func__, f->name, function, pdata->info->pins[group].name, 1066 + pin, offset); 1067 + 1068 + if (device_type == BCM21664_PINCTRL_TYPE) { 1069 + rc = bcm21664_pinctrl_set_pin_lock(pdata, pin, false); 1070 + if (rc) { 1071 + /* Error is printed in bcm21664_pinctrl_set_pin_lock */ 1072 + return rc; 1073 + } 1074 + } 1661 1075 1662 1076 rc = regmap_update_bits(pdata->regmap, offset, 1663 1077 BCM281XX_PIN_REG_F_SEL_MASK, ··· 1675 1069 if (rc) 1676 1070 dev_err(pctldev->dev, 1677 1071 "Error updating register for pin %s (%d).\n", 1678 - pdata->pins[group].name, pdata->pins[group].number); 1072 + pdata->info->pins[group].name, pin); 1073 + 1074 + if (device_type == BCM21664_PINCTRL_TYPE) { 1075 + rc = bcm21664_pinctrl_set_pin_lock(pdata, pin, true); 1076 + if (rc) { 1077 + /* Error is printed in bcm21664_pinctrl_set_pin_lock */ 1078 + return rc; 1079 + } 1080 + } 1679 1081 1680 1082 return rc; 1681 1083 } ··· 1696 1082 }; 1697 1083 1698 1084 static int bcm281xx_pinctrl_pin_config_get(struct pinctrl_dev *pctldev, 1699 - unsigned pin, 1085 + unsigned int pin, 1700 1086 unsigned long *config) 1701 1087 { 1702 1088 return -ENOTSUPP; ··· 1705 1091 1706 1092 /* Goes through the configs and update register val/mask */ 1707 1093 static int bcm281xx_std_pin_update(struct pinctrl_dev *pctldev, 1708 - unsigned pin, 1094 + unsigned int pin, 1709 1095 unsigned long *configs, 1710 - unsigned num_configs, 1096 + unsigned int num_configs, 1711 1097 u32 *val, 1712 1098 u32 *mask) 1713 1099 { ··· 1782 1168 "Invalid Drive Strength value (%d) for " 1783 1169 "pin %s (%d). Valid values are " 1784 1170 "(2..16) mA, even numbers only.\n", 1785 - arg, pdata->pins[pin].name, pin); 1171 + arg, pdata->info->pins[pin].name, pin); 1786 1172 return -EINVAL; 1787 1173 } 1788 1174 bcm281xx_pin_update(val, mask, (arg/2)-1, ··· 1793 1179 default: 1794 1180 dev_err(pctldev->dev, 1795 1181 "Unrecognized pin config %d for pin %s (%d).\n", 1796 - param, pdata->pins[pin].name, pin); 1182 + param, pdata->info->pins[pin].name, pin); 1797 1183 return -EINVAL; 1798 1184 1799 1185 } /* switch config */ ··· 1821 1207 1822 1208 /* Goes through the configs and update register val/mask */ 1823 1209 static int bcm281xx_i2c_pin_update(struct pinctrl_dev *pctldev, 1824 - unsigned pin, 1210 + unsigned int pin, 1825 1211 unsigned long *configs, 1826 - unsigned num_configs, 1212 + unsigned int num_configs, 1827 1213 u32 *val, 1828 1214 u32 *mask) 1829 1215 { ··· 1847 1233 "Invalid pull-up value (%d) for pin %s " 1848 1234 "(%d). Valid values are 568, 720, 831, " 1849 1235 "1080, 1200, 1800, 2700 Ohms.\n", 1850 - arg, pdata->pins[pin].name, pin); 1236 + arg, pdata->info->pins[pin].name, pin); 1851 1237 return -EINVAL; 1852 1238 } 1853 1239 ··· 1880 1266 default: 1881 1267 dev_err(pctldev->dev, 1882 1268 "Unrecognized pin config %d for pin %s (%d).\n", 1883 - param, pdata->pins[pin].name, pin); 1269 + param, pdata->info->pins[pin].name, pin); 1270 + return -EINVAL; 1271 + 1272 + } /* switch config */ 1273 + } /* for each config */ 1274 + 1275 + return 0; 1276 + } 1277 + 1278 + /* Goes through the configs and update register val/mask */ 1279 + static int bcm21664_i2c_pin_update(struct pinctrl_dev *pctldev, 1280 + unsigned int pin, 1281 + unsigned long *configs, 1282 + unsigned int num_configs, 1283 + u32 *val, 1284 + u32 *mask) 1285 + { 1286 + struct bcm281xx_pinctrl_data *pdata = pinctrl_dev_get_drvdata(pctldev); 1287 + int i; 1288 + enum pin_config_param param; 1289 + u32 arg; 1290 + 1291 + for (i = 0; i < num_configs; i++) { 1292 + param = pinconf_to_config_param(configs[i]); 1293 + arg = pinconf_to_config_argument(configs[i]); 1294 + 1295 + /* 1296 + * BCM21664 I2C pins use the same config bits as standard pins, 1297 + * but only pull up/none, slew rate and input enable/disable 1298 + * options are supported. 1299 + */ 1300 + switch (param) { 1301 + case PIN_CONFIG_BIAS_PULL_UP: 1302 + bcm281xx_pin_update(val, mask, 1, 1303 + BCM281XX_PIN_SHIFT(STD, PULL_UP), 1304 + BCM281XX_PIN_MASK(STD, PULL_UP)); 1305 + break; 1306 + 1307 + case PIN_CONFIG_BIAS_DISABLE: 1308 + bcm281xx_pin_update(val, mask, 0, 1309 + BCM281XX_PIN_SHIFT(STD, PULL_UP), 1310 + BCM281XX_PIN_MASK(STD, PULL_UP)); 1311 + break; 1312 + 1313 + case PIN_CONFIG_SLEW_RATE: 1314 + arg = (arg >= 1 ? 1 : 0); 1315 + bcm281xx_pin_update(val, mask, arg, 1316 + BCM281XX_PIN_SHIFT(STD, SLEW), 1317 + BCM281XX_PIN_MASK(STD, SLEW)); 1318 + break; 1319 + 1320 + case PIN_CONFIG_INPUT_ENABLE: 1321 + /* inversed since register is for input _disable_ */ 1322 + arg = (arg >= 1 ? 0 : 1); 1323 + bcm281xx_pin_update(val, mask, arg, 1324 + BCM281XX_PIN_SHIFT(STD, INPUT_DIS), 1325 + BCM281XX_PIN_MASK(STD, INPUT_DIS)); 1326 + break; 1327 + 1328 + default: 1329 + dev_err(pctldev->dev, 1330 + "Unrecognized pin config %d for pin %s (%d).\n", 1331 + param, pdata->info->pins[pin].name, pin); 1884 1332 return -EINVAL; 1885 1333 1886 1334 } /* switch config */ ··· 1953 1277 1954 1278 /* Goes through the configs and update register val/mask */ 1955 1279 static int bcm281xx_hdmi_pin_update(struct pinctrl_dev *pctldev, 1956 - unsigned pin, 1280 + unsigned int pin, 1957 1281 unsigned long *configs, 1958 - unsigned num_configs, 1282 + unsigned int num_configs, 1959 1283 u32 *val, 1960 1284 u32 *mask) 1961 1285 { ··· 1987 1311 default: 1988 1312 dev_err(pctldev->dev, 1989 1313 "Unrecognized pin config %d for pin %s (%d).\n", 1990 - param, pdata->pins[pin].name, pin); 1314 + param, pdata->info->pins[pin].name, pin); 1991 1315 return -EINVAL; 1992 1316 1993 1317 } /* switch config */ ··· 1997 1321 } 1998 1322 1999 1323 static int bcm281xx_pinctrl_pin_config_set(struct pinctrl_dev *pctldev, 2000 - unsigned pin, 1324 + unsigned int pin, 2001 1325 unsigned long *configs, 2002 - unsigned num_configs) 1326 + unsigned int num_configs) 2003 1327 { 2004 1328 struct bcm281xx_pinctrl_data *pdata = pinctrl_dev_get_drvdata(pctldev); 1329 + enum bcm281xx_pinctrl_type device_type = pdata->info->device_type; 2005 1330 enum bcm281xx_pin_type pin_type; 2006 1331 u32 offset = 4 * pin; 2007 1332 u32 cfg_val, cfg_mask; ··· 2020 1343 break; 2021 1344 2022 1345 case BCM281XX_PIN_TYPE_I2C: 2023 - rc = bcm281xx_i2c_pin_update(pctldev, pin, configs, 2024 - num_configs, &cfg_val, &cfg_mask); 1346 + if (device_type == BCM21664_PINCTRL_TYPE) 1347 + rc = bcm21664_i2c_pin_update(pctldev, pin, configs, 1348 + num_configs, &cfg_val, &cfg_mask); 1349 + else 1350 + rc = bcm281xx_i2c_pin_update(pctldev, pin, configs, 1351 + num_configs, &cfg_val, &cfg_mask); 2025 1352 break; 2026 1353 2027 1354 case BCM281XX_PIN_TYPE_HDMI: ··· 2035 1354 2036 1355 default: 2037 1356 dev_err(pctldev->dev, "Unknown pin type for pin %s (%d).\n", 2038 - pdata->pins[pin].name, pin); 1357 + pdata->info->pins[pin].name, pin); 2039 1358 return -EINVAL; 2040 1359 2041 1360 } /* switch pin type */ ··· 2045 1364 2046 1365 dev_dbg(pctldev->dev, 2047 1366 "%s(): Set pin %s (%d) with config 0x%x, mask 0x%x\n", 2048 - __func__, pdata->pins[pin].name, pin, cfg_val, cfg_mask); 1367 + __func__, pdata->info->pins[pin].name, pin, cfg_val, cfg_mask); 1368 + 1369 + if (device_type == BCM21664_PINCTRL_TYPE) { 1370 + rc = bcm21664_pinctrl_set_pin_lock(pdata, pin, false); 1371 + if (rc) { 1372 + /* Error is printed in bcm21664_pinctrl_set_pin_lock */ 1373 + return rc; 1374 + } 1375 + } 2049 1376 2050 1377 rc = regmap_update_bits(pdata->regmap, offset, cfg_mask, cfg_val); 2051 1378 if (rc) { 2052 1379 dev_err(pctldev->dev, 2053 1380 "Error updating register for pin %s (%d).\n", 2054 - pdata->pins[pin].name, pin); 1381 + pdata->info->pins[pin].name, pin); 2055 1382 return rc; 1383 + } 1384 + 1385 + if (device_type == BCM21664_PINCTRL_TYPE) { 1386 + rc = bcm21664_pinctrl_set_pin_lock(pdata, pin, true); 1387 + if (rc) { 1388 + /* Error is printed in bcm21664_pinctrl_set_pin_lock */ 1389 + return rc; 1390 + } 2056 1391 } 2057 1392 2058 1393 return 0; ··· 2087 1390 .owner = THIS_MODULE, 2088 1391 }; 2089 1392 1393 + static struct bcm281xx_pinctrl_data bcm281xx_pinctrl_pdata; 1394 + 2090 1395 static int __init bcm281xx_pinctrl_probe(struct platform_device *pdev) 2091 1396 { 2092 - struct bcm281xx_pinctrl_data *pdata = &bcm281xx_pinctrl; 1397 + struct bcm281xx_pinctrl_data *pdata = &bcm281xx_pinctrl_pdata; 2093 1398 struct pinctrl_dev *pctl; 1399 + int rc; 1400 + 1401 + /* Set device pointer in platform data */ 1402 + pdata->dev = &pdev->dev; 1403 + 1404 + /* Get the data to use from OF match */ 1405 + pdata->info = of_device_get_match_data(&pdev->dev); 1406 + if (!pdata->info) { 1407 + dev_err(&pdev->dev, "Failed to get data from OF match\n"); 1408 + return -ENODEV; 1409 + } 2094 1410 2095 1411 /* So far We can assume there is only 1 bank of registers */ 2096 1412 pdata->reg_base = devm_platform_ioremap_resource(pdev, 0); ··· 2114 1404 2115 1405 /* Initialize the dynamic part of pinctrl_desc */ 2116 1406 pdata->regmap = devm_regmap_init_mmio(&pdev->dev, pdata->reg_base, 2117 - &bcm281xx_pinctrl_regmap_config); 1407 + pdata->info->regmap_config); 2118 1408 if (IS_ERR(pdata->regmap)) { 2119 1409 dev_err(&pdev->dev, "Regmap MMIO init failed.\n"); 2120 1410 return -ENODEV; 2121 1411 } 2122 1412 2123 1413 bcm281xx_pinctrl_desc.name = dev_name(&pdev->dev); 2124 - bcm281xx_pinctrl_desc.pins = bcm281xx_pinctrl.pins; 2125 - bcm281xx_pinctrl_desc.npins = bcm281xx_pinctrl.npins; 1414 + bcm281xx_pinctrl_desc.pins = pdata->info->pins; 1415 + bcm281xx_pinctrl_desc.npins = pdata->info->npins; 1416 + 1417 + /* 1418 + * For BCM21664, lock all pins by default; they will be unlocked 1419 + * as needed 1420 + */ 1421 + if (pdata->info->device_type == BCM21664_PINCTRL_TYPE) { 1422 + rc = bcm21664_pinctrl_lock_all(pdata); 1423 + if (rc) { 1424 + dev_err(&pdev->dev, "Failed to lock all pins\n"); 1425 + return rc; 1426 + } 1427 + } 2126 1428 2127 1429 pctl = devm_pinctrl_register(&pdev->dev, &bcm281xx_pinctrl_desc, pdata); 2128 1430 if (IS_ERR(pctl)) { ··· 2148 1426 } 2149 1427 2150 1428 static const struct of_device_id bcm281xx_pinctrl_of_match[] = { 2151 - { .compatible = "brcm,bcm11351-pinctrl", }, 1429 + { .compatible = "brcm,bcm11351-pinctrl", .data = &bcm281xx_pinctrl }, 1430 + { .compatible = "brcm,bcm21664-pinctrl", .data = &bcm21664_pinctrl }, 2152 1431 { }, 2153 1432 }; 2154 1433
+7 -7
drivers/pinctrl/bcm/pinctrl-bcm2835.c
··· 346 346 struct bcm2835_pinctrl *pc = gpiochip_get_data(chip); 347 347 enum bcm2835_fsel fsel = bcm2835_pinctrl_fsel_get(pc, offset); 348 348 349 - /* Alternative function doesn't clearly provide a direction */ 350 - if (fsel > BCM2835_FSEL_GPIO_OUT) 351 - return -EINVAL; 349 + if (fsel == BCM2835_FSEL_GPIO_OUT) 350 + return GPIO_LINE_DIRECTION_OUT; 352 351 353 - if (fsel == BCM2835_FSEL_GPIO_IN) 354 - return GPIO_LINE_DIRECTION_IN; 355 - 356 - return GPIO_LINE_DIRECTION_OUT; 352 + /* 353 + * Alternative function doesn't clearly provide a direction. Default 354 + * to INPUT. 355 + */ 356 + return GPIO_LINE_DIRECTION_IN; 357 357 } 358 358 359 359 static void bcm2835_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
+8 -2
drivers/pinctrl/devicetree.c
··· 143 143 pctldev = get_pinctrl_dev_from_of_node(np_pctldev); 144 144 if (pctldev) 145 145 break; 146 - /* Do not defer probing of hogs (circular loop) */ 146 + /* 147 + * Do not defer probing of hogs (circular loop) 148 + * 149 + * Return 1 to let the caller catch the case. 150 + */ 147 151 if (np_pctldev == p->dev->of_node) { 148 152 of_node_put(np_pctldev); 149 - return -ENODEV; 153 + return 1; 150 154 } 151 155 } 152 156 of_node_put(np_pctldev); ··· 269 265 ret = dt_to_map_one_config(p, pctldev, statename, 270 266 np_config); 271 267 of_node_put(np_config); 268 + if (ret == 1) 269 + continue; 272 270 if (ret < 0) 273 271 goto err; 274 272 }
-2
drivers/pinctrl/intel/Kconfig
··· 39 39 40 40 config PINCTRL_INTEL_PLATFORM 41 41 tristate "Intel pinctrl and GPIO platform driver" 42 - depends on ACPI 43 42 select PINCTRL_INTEL 44 43 help 45 44 This pinctrl driver provides an interface that allows configuring ··· 140 141 141 142 config PINCTRL_METEORPOINT 142 143 tristate "Intel Meteor Point pinctrl and GPIO driver" 143 - depends on ACPI 144 144 select PINCTRL_INTEL 145 145 help 146 146 Meteor Point is the PCH of Intel Meteor Lake. This pinctrl driver
+6 -5
drivers/pinctrl/intel/pinctrl-baytrail.c
··· 1355 1355 void __iomem *reg; 1356 1356 unsigned long pending; 1357 1357 1358 + chained_irq_enter(chip, desc); 1359 + 1358 1360 /* check from GPIO controller which pin triggered the interrupt */ 1359 1361 for (base = 0; base < vg->chip.ngpio; base += 32) { 1360 1362 reg = byt_gpio_reg(vg, base, BYT_INT_STAT_REG); ··· 1371 1369 for_each_set_bit(pin, &pending, 32) 1372 1370 generic_handle_domain_irq(vg->chip.irq.domain, base + pin); 1373 1371 } 1374 - chip->irq_eoi(data); 1372 + 1373 + chained_irq_exit(chip, desc); 1375 1374 } 1376 1375 1377 1376 static bool byt_direct_irq_sanity_check(struct intel_pinctrl *vg, int pin, u32 conf0) ··· 1560 1557 vg->soc = soc; 1561 1558 1562 1559 vg->ncommunities = vg->soc->ncommunities; 1563 - vg->communities = devm_kcalloc(vg->dev, vg->ncommunities, 1564 - sizeof(*vg->communities), GFP_KERNEL); 1560 + vg->communities = devm_kmemdup_array(vg->dev, vg->soc->communities, vg->ncommunities, 1561 + sizeof(*vg->soc->communities), GFP_KERNEL); 1565 1562 if (!vg->communities) 1566 1563 return -ENOMEM; 1567 1564 1568 1565 for (i = 0; i < vg->soc->ncommunities; i++) { 1569 1566 struct intel_community *comm = vg->communities + i; 1570 - 1571 - *comm = vg->soc->communities[i]; 1572 1567 1573 1568 comm->pad_regs = devm_platform_ioremap_resource(pdev, 0); 1574 1569 if (IS_ERR(comm->pad_regs))
+2 -3
drivers/pinctrl/intel/pinctrl-cherryview.c
··· 1631 1631 pctrl->soc = soc_data; 1632 1632 1633 1633 pctrl->ncommunities = pctrl->soc->ncommunities; 1634 - pctrl->communities = devm_kmemdup(dev, pctrl->soc->communities, 1635 - pctrl->ncommunities * sizeof(*pctrl->communities), 1636 - GFP_KERNEL); 1634 + pctrl->communities = devm_kmemdup_array(dev, pctrl->soc->communities, pctrl->ncommunities, 1635 + sizeof(*pctrl->soc->communities), GFP_KERNEL); 1637 1636 if (!pctrl->communities) 1638 1637 return -ENOMEM; 1639 1638
+3 -5
drivers/pinctrl/intel/pinctrl-intel.c
··· 1543 1543 .clk_rate = 19200000, 1544 1544 .npwm = 1, 1545 1545 .base_unit_bits = 22, 1546 - .bypass = true, 1547 1546 }; 1548 1547 struct pwm_chip *chip; 1549 1548 ··· 1576 1577 * to the registers. 1577 1578 */ 1578 1579 pctrl->ncommunities = pctrl->soc->ncommunities; 1579 - pctrl->communities = devm_kcalloc(dev, pctrl->ncommunities, 1580 - sizeof(*pctrl->communities), GFP_KERNEL); 1580 + pctrl->communities = devm_kmemdup_array(dev, pctrl->soc->communities, pctrl->ncommunities, 1581 + sizeof(*pctrl->soc->communities), GFP_KERNEL); 1581 1582 if (!pctrl->communities) 1582 1583 return -ENOMEM; 1583 1584 ··· 1586 1587 void __iomem *regs; 1587 1588 u32 offset; 1588 1589 u32 value; 1589 - 1590 - *community = pctrl->soc->communities[i]; 1591 1590 1592 1591 regs = devm_platform_ioremap_resource(pdev, community->barno); 1593 1592 if (IS_ERR(regs)) ··· 1938 1941 MODULE_AUTHOR("Mika Westerberg <mika.westerberg@linux.intel.com>"); 1939 1942 MODULE_DESCRIPTION("Intel pinctrl/GPIO core driver"); 1940 1943 MODULE_LICENSE("GPL v2"); 1944 + MODULE_IMPORT_NS("PWM_LPSS");
+4 -1
drivers/pinctrl/intel/pinctrl-lynxpoint.c
··· 549 549 unsigned long pending; 550 550 u32 base, pin; 551 551 552 + chained_irq_enter(chip, desc); 553 + 552 554 /* check from GPIO controller which pin triggered the interrupt */ 553 555 for (base = 0; base < lg->chip.ngpio; base += 32) { 554 556 reg = lp_gpio_reg(&lg->chip, base, LP_INT_STAT); ··· 562 560 for_each_set_bit(pin, &pending, 32) 563 561 generic_handle_domain_irq(lg->chip.irq.domain, base + pin); 564 562 } 565 - chip->irq_eoi(data); 563 + 564 + chained_irq_exit(chip, desc); 566 565 } 567 566 568 567 static void lp_irq_ack(struct irq_data *d)
+2 -3
drivers/pinctrl/intel/pinctrl-tangier.c
··· 524 524 struct device *dev = &pdev->dev; 525 525 struct tng_family *families; 526 526 struct tng_pinctrl *tp; 527 - size_t families_len; 528 527 void __iomem *regs; 529 528 unsigned int i; 530 529 ··· 542 543 * Make a copy of the families which we can use to hold pointers 543 544 * to the registers. 544 545 */ 545 - families_len = size_mul(sizeof(*families), tp->nfamilies); 546 - families = devm_kmemdup(dev, tp->families, families_len, GFP_KERNEL); 546 + families = devm_kmemdup_array(dev, tp->families, tp->nfamilies, 547 + sizeof(*tp->families), GFP_KERNEL); 547 548 if (!families) 548 549 return -ENOMEM; 549 550
+195 -114
drivers/pinctrl/mediatek/mtk-eint.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 - // Copyright (c) 2014-2018 MediaTek Inc. 2 + // Copyright (c) 2014-2025 MediaTek Inc. 3 3 4 4 /* 5 5 * Library for MediaTek External Interrupt Support 6 6 * 7 7 * Author: Maoguang Meng <maoguang.meng@mediatek.com> 8 8 * Sean Wang <sean.wang@mediatek.com> 9 + * Hao Chang <ot_chhao.chang@mediatek.com> 10 + * Qingliang Li <qingliang.li@mediatek.com> 9 11 * 10 12 */ 11 13 ··· 22 20 #include <linux/platform_device.h> 23 21 24 22 #include "mtk-eint.h" 23 + #include "pinctrl-mtk-common-v2.h" 25 24 26 25 #define MTK_EINT_EDGE_SENSITIVE 0 27 26 #define MTK_EINT_LEVEL_SENSITIVE 1 ··· 71 68 unsigned int eint_num, 72 69 unsigned int offset) 73 70 { 74 - unsigned int eint_base = 0; 71 + unsigned int idx = eint->pins[eint_num].index; 72 + unsigned int inst = eint->pins[eint_num].instance; 75 73 void __iomem *reg; 76 74 77 - if (eint_num >= eint->hw->ap_num) 78 - eint_base = eint->hw->ap_num; 79 - 80 - reg = eint->base + offset + ((eint_num - eint_base) / 32) * 4; 75 + reg = eint->base[inst] + offset + (idx / 32 * 4); 81 76 82 77 return reg; 83 78 } ··· 84 83 unsigned int eint_num) 85 84 { 86 85 unsigned int sens; 87 - unsigned int bit = BIT(eint_num % 32); 86 + unsigned int bit = BIT(eint->pins[eint_num].index % 32); 88 87 void __iomem *reg = mtk_eint_get_offset(eint, eint_num, 89 88 eint->regs->sens); 90 89 ··· 93 92 else 94 93 sens = MTK_EINT_EDGE_SENSITIVE; 95 94 96 - if (eint_num < eint->hw->db_cnt && sens != MTK_EINT_EDGE_SENSITIVE) 95 + if (eint->pins[eint_num].debounce && sens != MTK_EINT_EDGE_SENSITIVE) 97 96 return 1; 98 97 else 99 98 return 0; ··· 103 102 { 104 103 int start_level, curr_level; 105 104 unsigned int reg_offset; 106 - u32 mask = BIT(hwirq & 0x1f); 107 - u32 port = (hwirq >> 5) & eint->hw->port_mask; 108 - void __iomem *reg = eint->base + (port << 2); 105 + unsigned int mask = BIT(eint->pins[hwirq].index & 0x1f); 106 + unsigned int port = (eint->pins[hwirq].index >> 5) & eint->hw->port_mask; 107 + void __iomem *reg = eint->base[eint->pins[hwirq].instance] + (port << 2); 109 108 110 109 curr_level = eint->gpio_xlate->get_gpio_state(eint->pctl, hwirq); 111 110 ··· 127 126 static void mtk_eint_mask(struct irq_data *d) 128 127 { 129 128 struct mtk_eint *eint = irq_data_get_irq_chip_data(d); 130 - u32 mask = BIT(d->hwirq & 0x1f); 129 + unsigned int idx = eint->pins[d->hwirq].index; 130 + unsigned int inst = eint->pins[d->hwirq].instance; 131 + unsigned int mask = BIT(idx & 0x1f); 131 132 void __iomem *reg = mtk_eint_get_offset(eint, d->hwirq, 132 133 eint->regs->mask_set); 133 134 134 - eint->cur_mask[d->hwirq >> 5] &= ~mask; 135 + eint->cur_mask[inst][idx >> 5] &= ~mask; 135 136 136 137 writel(mask, reg); 137 138 } ··· 141 138 static void mtk_eint_unmask(struct irq_data *d) 142 139 { 143 140 struct mtk_eint *eint = irq_data_get_irq_chip_data(d); 144 - u32 mask = BIT(d->hwirq & 0x1f); 141 + unsigned int idx = eint->pins[d->hwirq].index; 142 + unsigned int inst = eint->pins[d->hwirq].instance; 143 + unsigned int mask = BIT(idx & 0x1f); 145 144 void __iomem *reg = mtk_eint_get_offset(eint, d->hwirq, 146 145 eint->regs->mask_clr); 147 146 148 - eint->cur_mask[d->hwirq >> 5] |= mask; 147 + eint->cur_mask[inst][idx >> 5] |= mask; 149 148 150 149 writel(mask, reg); 151 150 152 - if (eint->dual_edge[d->hwirq]) 151 + if (eint->pins[d->hwirq].dual_edge) 153 152 mtk_eint_flip_edge(eint, d->hwirq); 154 153 } 155 154 156 155 static unsigned int mtk_eint_get_mask(struct mtk_eint *eint, 157 156 unsigned int eint_num) 158 157 { 159 - unsigned int bit = BIT(eint_num % 32); 158 + unsigned int bit = BIT(eint->pins[eint_num].index % 32); 160 159 void __iomem *reg = mtk_eint_get_offset(eint, eint_num, 161 160 eint->regs->mask); 162 161 ··· 168 163 static void mtk_eint_ack(struct irq_data *d) 169 164 { 170 165 struct mtk_eint *eint = irq_data_get_irq_chip_data(d); 171 - u32 mask = BIT(d->hwirq & 0x1f); 166 + unsigned int mask = BIT(eint->pins[d->hwirq].index & 0x1f); 172 167 void __iomem *reg = mtk_eint_get_offset(eint, d->hwirq, 173 168 eint->regs->ack); 174 169 ··· 179 174 { 180 175 struct mtk_eint *eint = irq_data_get_irq_chip_data(d); 181 176 bool masked; 182 - u32 mask = BIT(d->hwirq & 0x1f); 177 + unsigned int mask = BIT(eint->pins[d->hwirq].index & 0x1f); 183 178 void __iomem *reg; 184 179 185 180 if (((type & IRQ_TYPE_EDGE_BOTH) && (type & IRQ_TYPE_LEVEL_MASK)) || ··· 191 186 } 192 187 193 188 if ((type & IRQ_TYPE_EDGE_BOTH) == IRQ_TYPE_EDGE_BOTH) 194 - eint->dual_edge[d->hwirq] = 1; 189 + eint->pins[d->hwirq].dual_edge = 1; 195 190 else 196 - eint->dual_edge[d->hwirq] = 0; 191 + eint->pins[d->hwirq].dual_edge = 0; 197 192 198 193 if (!mtk_eint_get_mask(eint, d->hwirq)) { 199 194 mtk_eint_mask(d); ··· 228 223 static int mtk_eint_irq_set_wake(struct irq_data *d, unsigned int on) 229 224 { 230 225 struct mtk_eint *eint = irq_data_get_irq_chip_data(d); 231 - int shift = d->hwirq & 0x1f; 232 - int reg = d->hwirq >> 5; 226 + unsigned int idx = eint->pins[d->hwirq].index; 227 + unsigned int inst = eint->pins[d->hwirq].instance; 228 + unsigned int shift = idx & 0x1f; 229 + unsigned int port = idx >> 5; 233 230 234 231 if (on) 235 - eint->wake_mask[reg] |= BIT(shift); 232 + eint->wake_mask[inst][port] |= BIT(shift); 236 233 else 237 - eint->wake_mask[reg] &= ~BIT(shift); 234 + eint->wake_mask[inst][port] &= ~BIT(shift); 238 235 239 236 return 0; 240 237 } 241 238 242 239 static void mtk_eint_chip_write_mask(const struct mtk_eint *eint, 243 - void __iomem *base, u32 *buf) 240 + void __iomem *base, unsigned int **buf) 244 241 { 245 - int port; 242 + int inst, port, port_num; 246 243 void __iomem *reg; 247 244 248 - for (port = 0; port < eint->hw->ports; port++) { 249 - reg = base + (port << 2); 250 - writel_relaxed(~buf[port], reg + eint->regs->mask_set); 251 - writel_relaxed(buf[port], reg + eint->regs->mask_clr); 245 + for (inst = 0; inst < eint->nbase; inst++) { 246 + port_num = DIV_ROUND_UP(eint->base_pin_num[inst], 32); 247 + for (port = 0; port < port_num; port++) { 248 + reg = eint->base[inst] + (port << 2); 249 + writel_relaxed(~buf[inst][port], reg + eint->regs->mask_set); 250 + writel_relaxed(buf[inst][port], reg + eint->regs->mask_clr); 251 + } 252 252 } 253 253 } 254 254 ··· 313 303 314 304 static unsigned int mtk_eint_hw_init(struct mtk_eint *eint) 315 305 { 316 - void __iomem *dom_en = eint->base + eint->regs->dom_en; 317 - void __iomem *mask_set = eint->base + eint->regs->mask_set; 318 - unsigned int i; 306 + void __iomem *dom_reg, *mask_reg; 307 + unsigned int i, j; 319 308 320 - for (i = 0; i < eint->hw->ap_num; i += 32) { 321 - writel(0xffffffff, dom_en); 322 - writel(0xffffffff, mask_set); 323 - dom_en += 4; 324 - mask_set += 4; 309 + for (i = 0; i < eint->nbase; i++) { 310 + dom_reg = eint->base[i] + eint->regs->dom_en; 311 + mask_reg = eint->base[i] + eint->regs->mask_set; 312 + for (j = 0; j < eint->base_pin_num[i]; j += 32) { 313 + writel(0xffffffff, dom_reg); 314 + writel(0xffffffff, mask_reg); 315 + dom_reg += 4; 316 + mask_reg += 4; 317 + } 325 318 } 326 319 327 320 return 0; ··· 335 322 { 336 323 unsigned int rst, ctrl_offset; 337 324 unsigned int bit, dbnc; 325 + unsigned int inst = eint->pins[index].instance; 326 + unsigned int idx = eint->pins[index].index; 338 327 339 - ctrl_offset = (index / 4) * 4 + eint->regs->dbnc_ctrl; 340 - dbnc = readl(eint->base + ctrl_offset); 341 - bit = MTK_EINT_DBNC_SET_EN << ((index % 4) * 8); 328 + ctrl_offset = (idx / 4) * 4 + eint->regs->dbnc_ctrl; 329 + dbnc = readl(eint->base[inst] + ctrl_offset); 330 + bit = MTK_EINT_DBNC_SET_EN << ((idx % 4) * 8); 342 331 if ((bit & dbnc) > 0) { 343 - ctrl_offset = (index / 4) * 4 + eint->regs->dbnc_set; 344 - rst = MTK_EINT_DBNC_RST_BIT << ((index % 4) * 8); 345 - writel(rst, eint->base + ctrl_offset); 332 + ctrl_offset = (idx / 4) * 4 + eint->regs->dbnc_set; 333 + rst = MTK_EINT_DBNC_RST_BIT << ((idx % 4) * 8); 334 + writel(rst, eint->base[inst] + ctrl_offset); 346 335 } 347 336 } 348 337 ··· 352 337 { 353 338 struct irq_chip *chip = irq_desc_get_chip(desc); 354 339 struct mtk_eint *eint = irq_desc_get_handler_data(desc); 355 - unsigned int status, eint_num; 356 - int offset, mask_offset, index; 357 - void __iomem *reg = mtk_eint_get_offset(eint, 0, eint->regs->stat); 340 + unsigned int i, j, port, status, shift, mask, eint_num; 341 + void __iomem *reg; 358 342 int dual_edge, start_level, curr_level; 359 343 360 344 chained_irq_enter(chip, desc); 361 - for (eint_num = 0; eint_num < eint->hw->ap_num; eint_num += 32, 362 - reg += 4) { 363 - status = readl(reg); 364 - while (status) { 365 - offset = __ffs(status); 366 - mask_offset = eint_num >> 5; 367 - index = eint_num + offset; 368 - status &= ~BIT(offset); 369 - 370 - /* 371 - * If we get an interrupt on pin that was only required 372 - * for wake (but no real interrupt requested), mask the 373 - * interrupt (as would mtk_eint_resume do anyway later 374 - * in the resume sequence). 375 - */ 376 - if (eint->wake_mask[mask_offset] & BIT(offset) && 377 - !(eint->cur_mask[mask_offset] & BIT(offset))) { 378 - writel_relaxed(BIT(offset), reg - 379 - eint->regs->stat + 380 - eint->regs->mask_set); 381 - } 382 - 383 - dual_edge = eint->dual_edge[index]; 384 - if (dual_edge) { 385 - /* 386 - * Clear soft-irq in case we raised it last 387 - * time. 388 - */ 389 - writel(BIT(offset), reg - eint->regs->stat + 390 - eint->regs->soft_clr); 391 - 392 - start_level = 393 - eint->gpio_xlate->get_gpio_state(eint->pctl, 394 - index); 395 - } 396 - 397 - generic_handle_domain_irq(eint->domain, index); 398 - 399 - if (dual_edge) { 400 - curr_level = mtk_eint_flip_edge(eint, index); 345 + for (i = 0; i < eint->nbase; i++) { 346 + for (j = 0; j < eint->base_pin_num[i]; j += 32) { 347 + port = j >> 5; 348 + status = readl(eint->base[i] + port * 4 + eint->regs->stat); 349 + while (status) { 350 + shift = __ffs(status); 351 + status &= ~BIT(shift); 352 + mask = BIT(shift); 353 + eint_num = eint->pin_list[i][shift + j]; 401 354 402 355 /* 403 - * If level changed, we might lost one edge 404 - * interrupt, raised it through soft-irq. 356 + * If we get an interrupt on pin that was only required 357 + * for wake (but no real interrupt requested), mask the 358 + * interrupt (as would mtk_eint_resume do anyway later 359 + * in the resume sequence). 405 360 */ 406 - if (start_level != curr_level) 407 - writel(BIT(offset), reg - 408 - eint->regs->stat + 409 - eint->regs->soft_set); 410 - } 361 + if (eint->wake_mask[i][port] & mask && 362 + !(eint->cur_mask[i][port] & mask)) { 363 + reg = mtk_eint_get_offset(eint, eint_num, 364 + eint->regs->mask_set); 365 + writel_relaxed(mask, reg); 366 + } 411 367 412 - if (index < eint->hw->db_cnt) 413 - mtk_eint_debounce_process(eint, index); 368 + dual_edge = eint->pins[eint_num].dual_edge; 369 + if (dual_edge) { 370 + /* 371 + * Clear soft-irq in case we raised it last 372 + * time. 373 + */ 374 + reg = mtk_eint_get_offset(eint, eint_num, 375 + eint->regs->soft_clr); 376 + writel(mask, reg); 377 + 378 + start_level = 379 + eint->gpio_xlate->get_gpio_state(eint->pctl, 380 + eint_num); 381 + } 382 + 383 + generic_handle_domain_irq(eint->domain, eint_num); 384 + 385 + if (dual_edge) { 386 + curr_level = mtk_eint_flip_edge(eint, eint_num); 387 + 388 + /* 389 + * If level changed, we might lost one edge 390 + * interrupt, raised it through soft-irq. 391 + */ 392 + if (start_level != curr_level) { 393 + reg = mtk_eint_get_offset(eint, eint_num, 394 + eint->regs->soft_set); 395 + writel(mask, reg); 396 + } 397 + } 398 + 399 + if (eint->pins[eint_num].debounce) 400 + mtk_eint_debounce_process(eint, eint_num); 401 + } 414 402 } 415 403 } 416 404 chained_irq_exit(chip, desc); ··· 441 423 int virq, eint_offset; 442 424 unsigned int set_offset, bit, clr_bit, clr_offset, rst, i, unmask, 443 425 dbnc; 426 + unsigned int inst = eint->pins[eint_num].instance; 427 + unsigned int idx = eint->pins[eint_num].index; 444 428 struct irq_data *d; 445 429 446 430 if (!eint->hw->db_time) ··· 452 432 eint_offset = (eint_num % 4) * 8; 453 433 d = irq_get_irq_data(virq); 454 434 455 - set_offset = (eint_num / 4) * 4 + eint->regs->dbnc_set; 456 - clr_offset = (eint_num / 4) * 4 + eint->regs->dbnc_clr; 435 + set_offset = (idx / 4) * 4 + eint->regs->dbnc_set; 436 + clr_offset = (idx / 4) * 4 + eint->regs->dbnc_clr; 457 437 458 438 if (!mtk_eint_can_en_debounce(eint, eint_num)) 459 439 return -EINVAL; ··· 474 454 } 475 455 476 456 clr_bit = 0xff << eint_offset; 477 - writel(clr_bit, eint->base + clr_offset); 457 + writel(clr_bit, eint->base[inst] + clr_offset); 478 458 479 459 bit = ((dbnc << MTK_EINT_DBNC_SET_DBNC_BITS) | MTK_EINT_DBNC_SET_EN) << 480 460 eint_offset; 481 461 rst = MTK_EINT_DBNC_RST_BIT << eint_offset; 482 - writel(rst | bit, eint->base + set_offset); 462 + writel(rst | bit, eint->base[inst] + set_offset); 483 463 484 464 /* 485 465 * Delay a while (more than 2T) to wait for hw debounce counter reset ··· 507 487 508 488 int mtk_eint_do_init(struct mtk_eint *eint) 509 489 { 510 - int i; 490 + unsigned int size, i, port, inst = 0; 491 + struct mtk_pinctrl *hw = (struct mtk_pinctrl *)eint->pctl; 511 492 512 493 /* If clients don't assign a specific regs, let's use generic one */ 513 494 if (!eint->regs) 514 495 eint->regs = &mtk_generic_eint_regs; 515 496 516 - eint->wake_mask = devm_kcalloc(eint->dev, eint->hw->ports, 517 - sizeof(*eint->wake_mask), GFP_KERNEL); 497 + eint->base_pin_num = devm_kmalloc_array(eint->dev, eint->nbase, sizeof(u16), 498 + GFP_KERNEL | __GFP_ZERO); 499 + if (!eint->base_pin_num) 500 + return -ENOMEM; 501 + 502 + if (eint->nbase == 1) { 503 + size = eint->hw->ap_num * sizeof(struct mtk_eint_pin); 504 + eint->pins = devm_kmalloc(eint->dev, size, GFP_KERNEL); 505 + if (!eint->pins) 506 + goto err_pins; 507 + 508 + eint->base_pin_num[inst] = eint->hw->ap_num; 509 + for (i = 0; i < eint->hw->ap_num; i++) { 510 + eint->pins[i].instance = inst; 511 + eint->pins[i].index = i; 512 + eint->pins[i].debounce = (i < eint->hw->db_cnt) ? 1 : 0; 513 + } 514 + } 515 + 516 + if (hw && hw->soc && hw->soc->eint_pin) { 517 + eint->pins = hw->soc->eint_pin; 518 + for (i = 0; i < eint->hw->ap_num; i++) { 519 + inst = eint->pins[i].instance; 520 + if (inst >= eint->nbase) 521 + continue; 522 + eint->base_pin_num[inst]++; 523 + } 524 + } 525 + 526 + eint->pin_list = devm_kmalloc(eint->dev, eint->nbase * sizeof(u16 *), GFP_KERNEL); 527 + if (!eint->pin_list) 528 + goto err_pin_list; 529 + 530 + eint->wake_mask = devm_kmalloc(eint->dev, eint->nbase * sizeof(u32 *), GFP_KERNEL); 518 531 if (!eint->wake_mask) 519 - return -ENOMEM; 532 + goto err_wake_mask; 520 533 521 - eint->cur_mask = devm_kcalloc(eint->dev, eint->hw->ports, 522 - sizeof(*eint->cur_mask), GFP_KERNEL); 534 + eint->cur_mask = devm_kmalloc(eint->dev, eint->nbase * sizeof(u32 *), GFP_KERNEL); 523 535 if (!eint->cur_mask) 524 - return -ENOMEM; 536 + goto err_cur_mask; 525 537 526 - eint->dual_edge = devm_kcalloc(eint->dev, eint->hw->ap_num, 527 - sizeof(int), GFP_KERNEL); 528 - if (!eint->dual_edge) 529 - return -ENOMEM; 538 + for (i = 0; i < eint->nbase; i++) { 539 + eint->pin_list[i] = devm_kzalloc(eint->dev, eint->base_pin_num[i] * sizeof(u16), 540 + GFP_KERNEL); 541 + port = DIV_ROUND_UP(eint->base_pin_num[i], 32); 542 + eint->wake_mask[i] = devm_kzalloc(eint->dev, port * sizeof(u32), GFP_KERNEL); 543 + eint->cur_mask[i] = devm_kzalloc(eint->dev, port * sizeof(u32), GFP_KERNEL); 544 + if (!eint->pin_list[i] || !eint->wake_mask[i] || !eint->cur_mask[i]) 545 + goto err_eint; 546 + } 530 547 531 548 eint->domain = irq_domain_add_linear(eint->dev->of_node, 532 549 eint->hw->ap_num, 533 550 &irq_domain_simple_ops, NULL); 534 551 if (!eint->domain) 535 - return -ENOMEM; 552 + goto err_eint; 536 553 537 554 if (eint->hw->db_time) { 538 555 for (i = 0; i < MTK_EINT_DBNC_MAX; i++) ··· 580 523 581 524 mtk_eint_hw_init(eint); 582 525 for (i = 0; i < eint->hw->ap_num; i++) { 526 + inst = eint->pins[i].instance; 527 + if (inst >= eint->nbase) 528 + continue; 529 + eint->pin_list[inst][eint->pins[i].index] = i; 583 530 int virq = irq_create_mapping(eint->domain, i); 584 - 585 531 irq_set_chip_and_handler(virq, &mtk_eint_irq_chip, 586 532 handle_level_irq); 587 533 irq_set_chip_data(virq, eint); ··· 594 534 eint); 595 535 596 536 return 0; 537 + 538 + err_eint: 539 + for (i = 0; i < eint->nbase; i++) { 540 + if (eint->cur_mask[i]) 541 + devm_kfree(eint->dev, eint->cur_mask[i]); 542 + if (eint->wake_mask[i]) 543 + devm_kfree(eint->dev, eint->wake_mask[i]); 544 + if (eint->pin_list[i]) 545 + devm_kfree(eint->dev, eint->pin_list[i]); 546 + } 547 + devm_kfree(eint->dev, eint->cur_mask); 548 + err_cur_mask: 549 + devm_kfree(eint->dev, eint->wake_mask); 550 + err_wake_mask: 551 + devm_kfree(eint->dev, eint->pin_list); 552 + err_pin_list: 553 + if (eint->nbase == 1) 554 + devm_kfree(eint->dev, eint->pins); 555 + err_pins: 556 + devm_kfree(eint->dev, eint->base_pin_num); 557 + return -ENOMEM; 597 558 } 598 559 EXPORT_SYMBOL_GPL(mtk_eint_do_init); 599 560
+18 -5
drivers/pinctrl/mediatek/mtk-eint.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 */ 2 2 /* 3 - * Copyright (C) 2014-2018 MediaTek Inc. 3 + * Copyright (C) 2014-2025 MediaTek Inc. 4 4 * 5 5 * Author: Maoguang Meng <maoguang.meng@mediatek.com> 6 6 * Sean Wang <sean.wang@mediatek.com> 7 - * 7 + * Hao Chang <ot_chhao.chang@mediatek.com> 8 + * Qingliang Li <qingliang.li@mediatek.com> 8 9 */ 9 10 #ifndef __MTK_EINT_H 10 11 #define __MTK_EINT_H ··· 41 40 const unsigned int *db_time; 42 41 }; 43 42 43 + struct mtk_eint_pin { 44 + u16 number; 45 + u8 instance; 46 + u8 index; 47 + bool debounce; 48 + bool dual_edge; 49 + }; 50 + 44 51 extern const unsigned int debounce_time_mt2701[]; 45 52 extern const unsigned int debounce_time_mt6765[]; 46 53 extern const unsigned int debounce_time_mt6795[]; ··· 65 56 66 57 struct mtk_eint { 67 58 struct device *dev; 68 - void __iomem *base; 59 + void __iomem **base; 60 + u8 nbase; 61 + u16 *base_pin_num; 69 62 struct irq_domain *domain; 70 63 int irq; 71 64 72 65 int *dual_edge; 73 - u32 *wake_mask; 74 - u32 *cur_mask; 66 + u16 **pin_list; 67 + u32 **wake_mask; 68 + u32 **cur_mask; 75 69 76 70 /* Used to fit into various EINT device */ 77 71 const struct mtk_eint_hw *hw; 78 72 const struct mtk_eint_regs *regs; 73 + struct mtk_eint_pin *pins; 79 74 u16 num_db_time; 80 75 81 76 /* Used to fit into various pinctrl device */
+31 -6
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
··· 13 13 #include <linux/platform_device.h> 14 14 #include <linux/io.h> 15 15 #include <linux/module.h> 16 + #include <linux/of_address.h> 16 17 #include <linux/of_irq.h> 17 18 18 19 #include "mtk-eint.h" ··· 368 367 int mtk_build_eint(struct mtk_pinctrl *hw, struct platform_device *pdev) 369 368 { 370 369 struct device_node *np = pdev->dev.of_node; 371 - int ret; 370 + int ret, i, j, count_reg_names; 372 371 373 372 if (!IS_ENABLED(CONFIG_EINT_MTK)) 374 373 return 0; ··· 380 379 if (!hw->eint) 381 380 return -ENOMEM; 382 381 383 - hw->eint->base = devm_platform_ioremap_resource_byname(pdev, "eint"); 384 - if (IS_ERR(hw->eint->base)) { 385 - ret = PTR_ERR(hw->eint->base); 386 - goto err_free_eint; 382 + count_reg_names = of_property_count_strings(np, "reg-names"); 383 + if (count_reg_names < hw->soc->nbase_names) 384 + return -EINVAL; 385 + 386 + hw->eint->nbase = count_reg_names - hw->soc->nbase_names; 387 + hw->eint->base = devm_kmalloc_array(&pdev->dev, hw->eint->nbase, 388 + sizeof(*hw->eint->base), GFP_KERNEL | __GFP_ZERO); 389 + if (!hw->eint->base) { 390 + ret = -ENOMEM; 391 + goto err_free_base; 392 + } 393 + 394 + for (i = hw->soc->nbase_names, j = 0; i < count_reg_names; i++, j++) { 395 + hw->eint->base[j] = of_iomap(np, i); 396 + if (IS_ERR(hw->eint->base[j])) { 397 + ret = PTR_ERR(hw->eint->base[j]); 398 + goto err_free_eint; 399 + } 387 400 } 388 401 389 402 hw->eint->irq = irq_of_parse_and_map(np, 0); ··· 416 401 hw->eint->pctl = hw; 417 402 hw->eint->gpio_xlate = &mtk_eint_xt; 418 403 419 - return mtk_eint_do_init(hw->eint); 404 + ret = mtk_eint_do_init(hw->eint); 405 + if (ret) 406 + goto err_free_eint; 407 + 408 + return 0; 420 409 421 410 err_free_eint: 411 + for (j = 0; j < hw->eint->nbase; j++) { 412 + if (hw->eint->base[j]) 413 + iounmap(hw->eint->base[j]); 414 + } 415 + devm_kfree(hw->dev, hw->eint->base); 416 + err_free_base: 422 417 devm_kfree(hw->dev, hw->eint); 423 418 hw->eint = NULL; 424 419 return ret;
+1
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
··· 242 242 unsigned int nfuncs; 243 243 const struct mtk_eint_regs *eint_regs; 244 244 const struct mtk_eint_hw *eint_hw; 245 + struct mtk_eint_pin *eint_pin; 245 246 246 247 /* Specific parameters per SoC */ 247 248 u8 gpio_m;
+7
drivers/pinctrl/mediatek/pinctrl-paris.h
··· 49 49 __VA_ARGS__, { } }, \ 50 50 } 51 51 52 + #define MTK_EINT_PIN(_number, _instance, _index, _debounce) { \ 53 + .number = _number, \ 54 + .instance = _instance, \ 55 + .index = _index, \ 56 + .debounce = _debounce, \ 57 + } 58 + 52 59 #define PINCTRL_PIN_GROUP(_name_, id) \ 53 60 { \ 54 61 .grp = PINCTRL_PINGROUP(_name_,id##_pins, ARRAY_SIZE(id##_pins)), \
+11
drivers/pinctrl/meson/Kconfig
··· 67 67 select PINCTRL_MESON_AXG_PMX 68 68 default y 69 69 70 + config PINCTRL_AMLOGIC_A4 71 + bool "AMLOGIC pincontrol" 72 + depends on ARM64 73 + default y 74 + help 75 + This is the driver for the pin controller found on Amlogic SoCs. 76 + 77 + This driver is simplify subsequent support for new amlogic SoCs, 78 + to support new Amlogic SoCs, only need to add the corresponding dts file, 79 + no additional binding header files or C file are added. 80 + 70 81 config PINCTRL_AMLOGIC_C3 71 82 tristate "Amlogic C3 SoC pinctrl driver" 72 83 depends on ARM64
+1
drivers/pinctrl/meson/Makefile
··· 10 10 obj-$(CONFIG_PINCTRL_MESON_G12A) += pinctrl-meson-g12a.o 11 11 obj-$(CONFIG_PINCTRL_MESON_A1) += pinctrl-meson-a1.o 12 12 obj-$(CONFIG_PINCTRL_MESON_S4) += pinctrl-meson-s4.o 13 + obj-$(CONFIG_PINCTRL_AMLOGIC_A4) += pinctrl-amlogic-a4.o 13 14 obj-$(CONFIG_PINCTRL_AMLOGIC_C3) += pinctrl-amlogic-c3.o 14 15 obj-$(CONFIG_PINCTRL_AMLOGIC_T7) += pinctrl-amlogic-t7.o
+1053
drivers/pinctrl/meson/pinctrl-amlogic-a4.c
··· 1 + // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) 2 + /* 3 + * Copyright (c) 2024 Amlogic, Inc. All rights reserved. 4 + * Author: Xianwei Zhao <xianwei.zhao@amlogic.com> 5 + */ 6 + 7 + #include <linux/err.h> 8 + #include <linux/gpio/driver.h> 9 + #include <linux/init.h> 10 + #include <linux/io.h> 11 + #include <linux/module.h> 12 + #include <linux/of.h> 13 + #include <linux/of_address.h> 14 + #include <linux/platform_device.h> 15 + #include <linux/regmap.h> 16 + #include <linux/seq_file.h> 17 + #include <linux/slab.h> 18 + #include <linux/string_helpers.h> 19 + 20 + #include <linux/pinctrl/consumer.h> 21 + #include <linux/pinctrl/pinconf.h> 22 + #include <linux/pinctrl/pinctrl.h> 23 + #include <linux/pinctrl/pinmux.h> 24 + #include <dt-bindings/pinctrl/amlogic,pinctrl.h> 25 + 26 + #include "../core.h" 27 + #include "../pinconf.h" 28 + 29 + #define gpio_chip_to_bank(chip) \ 30 + container_of(chip, struct aml_gpio_bank, gpio_chip) 31 + 32 + #define AML_REG_PULLEN 0 33 + #define AML_REG_PULL 1 34 + #define AML_REG_DIR 2 35 + #define AML_REG_OUT 3 36 + #define AML_REG_IN 4 37 + #define AML_REG_DS 5 38 + #define AML_NUM_REG 6 39 + 40 + enum aml_pinconf_drv { 41 + PINCONF_DRV_500UA, 42 + PINCONF_DRV_2500UA, 43 + PINCONF_DRV_3000UA, 44 + PINCONF_DRV_4000UA, 45 + }; 46 + 47 + struct aml_pio_control { 48 + u32 gpio_offset; 49 + u32 reg_offset[AML_NUM_REG]; 50 + u32 bit_offset[AML_NUM_REG]; 51 + }; 52 + 53 + struct aml_reg_bit { 54 + u32 bank_id; 55 + u32 reg_offs[AML_NUM_REG]; 56 + u32 bit_offs[AML_NUM_REG]; 57 + }; 58 + 59 + struct aml_pctl_data { 60 + unsigned int number; 61 + struct aml_reg_bit rb_offs[]; 62 + }; 63 + 64 + struct aml_pmx_func { 65 + const char *name; 66 + const char **groups; 67 + unsigned int ngroups; 68 + }; 69 + 70 + struct aml_pctl_group { 71 + const char *name; 72 + unsigned int npins; 73 + unsigned int *pins; 74 + unsigned int *func; 75 + }; 76 + 77 + struct aml_gpio_bank { 78 + struct gpio_chip gpio_chip; 79 + struct aml_pio_control pc; 80 + u32 bank_id; 81 + unsigned int pin_base; 82 + struct regmap *reg_mux; 83 + struct regmap *reg_gpio; 84 + struct regmap *reg_ds; 85 + }; 86 + 87 + struct aml_pinctrl { 88 + struct device *dev; 89 + struct pinctrl_dev *pctl; 90 + struct aml_gpio_bank *banks; 91 + int nbanks; 92 + struct aml_pmx_func *functions; 93 + int nfunctions; 94 + struct aml_pctl_group *groups; 95 + int ngroups; 96 + 97 + const struct aml_pctl_data *data; 98 + }; 99 + 100 + static const unsigned int aml_bit_strides[AML_NUM_REG] = { 101 + 1, 1, 1, 1, 1, 2 102 + }; 103 + 104 + static const unsigned int aml_def_regoffs[AML_NUM_REG] = { 105 + 3, 4, 2, 1, 0, 7 106 + }; 107 + 108 + static const char *aml_bank_name[31] = { 109 + "GPIOA", "GPIOB", "GPIOC", "GPIOD", "GPIOE", "GPIOF", "GPIOG", 110 + "GPIOH", "GPIOI", "GPIOJ", "GPIOK", "GPIOL", "GPIOM", "GPION", 111 + "GPIOO", "GPIOP", "GPIOQ", "GPIOR", "GPIOS", "GPIOT", "GPIOU", 112 + "GPIOV", "GPIOW", "GPIOX", "GPIOY", "GPIOZ", "GPIODV", "GPIOAO", 113 + "GPIOCC", "TEST_N", "ANALOG" 114 + }; 115 + 116 + static int aml_pmx_calc_reg_and_offset(struct pinctrl_gpio_range *range, 117 + unsigned int pin, unsigned int *reg, 118 + unsigned int *offset) 119 + { 120 + unsigned int shift; 121 + 122 + shift = (pin - range->pin_base) << 2; 123 + *reg = (shift / 32) * 4; 124 + *offset = shift % 32; 125 + 126 + return 0; 127 + } 128 + 129 + static int aml_pctl_set_function(struct aml_pinctrl *info, 130 + struct pinctrl_gpio_range *range, 131 + int pin_id, int func) 132 + { 133 + struct aml_gpio_bank *bank = gpio_chip_to_bank(range->gc); 134 + int reg; 135 + int offset; 136 + 137 + if (!bank->reg_mux) 138 + return 0; 139 + 140 + aml_pmx_calc_reg_and_offset(range, pin_id, &reg, &offset); 141 + return regmap_update_bits(bank->reg_mux, reg, 142 + 0xf << offset, (func & 0xf) << offset); 143 + } 144 + 145 + static int aml_pmx_get_funcs_count(struct pinctrl_dev *pctldev) 146 + { 147 + struct aml_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); 148 + 149 + return info->nfunctions; 150 + } 151 + 152 + static const char *aml_pmx_get_fname(struct pinctrl_dev *pctldev, 153 + unsigned int selector) 154 + { 155 + struct aml_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); 156 + 157 + return info->functions[selector].name; 158 + } 159 + 160 + static int aml_pmx_get_groups(struct pinctrl_dev *pctldev, 161 + unsigned int selector, 162 + const char * const **grps, 163 + unsigned * const ngrps) 164 + { 165 + struct aml_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); 166 + 167 + *grps = info->functions[selector].groups; 168 + *ngrps = info->functions[selector].ngroups; 169 + 170 + return 0; 171 + } 172 + 173 + static int aml_pmx_set_mux(struct pinctrl_dev *pctldev, unsigned int fselector, 174 + unsigned int group_id) 175 + { 176 + struct aml_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); 177 + struct aml_pctl_group *group = &info->groups[group_id]; 178 + struct pinctrl_gpio_range *range; 179 + int i; 180 + 181 + for (i = 0; i < group->npins; i++) { 182 + range = pinctrl_find_gpio_range_from_pin(pctldev, group->pins[i]); 183 + aml_pctl_set_function(info, range, group->pins[i], group->func[i]); 184 + } 185 + 186 + return 0; 187 + } 188 + 189 + static int aml_pmx_request_gpio(struct pinctrl_dev *pctldev, 190 + struct pinctrl_gpio_range *range, 191 + unsigned int pin) 192 + { 193 + struct aml_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); 194 + 195 + return aml_pctl_set_function(info, range, pin, 0); 196 + } 197 + 198 + static const struct pinmux_ops aml_pmx_ops = { 199 + .set_mux = aml_pmx_set_mux, 200 + .get_functions_count = aml_pmx_get_funcs_count, 201 + .get_function_name = aml_pmx_get_fname, 202 + .get_function_groups = aml_pmx_get_groups, 203 + .gpio_request_enable = aml_pmx_request_gpio, 204 + }; 205 + 206 + static int aml_calc_reg_and_bit(struct pinctrl_gpio_range *range, 207 + unsigned int pin, 208 + unsigned int reg_type, 209 + unsigned int *reg, unsigned int *bit) 210 + { 211 + struct aml_gpio_bank *bank = gpio_chip_to_bank(range->gc); 212 + 213 + *bit = (pin - range->pin_base) * aml_bit_strides[reg_type] 214 + + bank->pc.bit_offset[reg_type]; 215 + *reg = (bank->pc.reg_offset[reg_type] + (*bit / 32)) * 4; 216 + *bit &= 0x1f; 217 + 218 + return 0; 219 + } 220 + 221 + static int aml_pinconf_get_pull(struct aml_pinctrl *info, unsigned int pin) 222 + { 223 + struct pinctrl_gpio_range *range = 224 + pinctrl_find_gpio_range_from_pin(info->pctl, pin); 225 + struct aml_gpio_bank *bank = gpio_chip_to_bank(range->gc); 226 + unsigned int reg, bit, val; 227 + int ret, conf; 228 + 229 + aml_calc_reg_and_bit(range, pin, AML_REG_PULLEN, &reg, &bit); 230 + 231 + ret = regmap_read(bank->reg_gpio, reg, &val); 232 + if (ret) 233 + return ret; 234 + 235 + if (!(val & BIT(bit))) { 236 + conf = PIN_CONFIG_BIAS_DISABLE; 237 + } else { 238 + aml_calc_reg_and_bit(range, pin, AML_REG_PULL, &reg, &bit); 239 + 240 + ret = regmap_read(bank->reg_gpio, reg, &val); 241 + if (ret) 242 + return ret; 243 + 244 + if (val & BIT(bit)) 245 + conf = PIN_CONFIG_BIAS_PULL_UP; 246 + else 247 + conf = PIN_CONFIG_BIAS_PULL_DOWN; 248 + } 249 + 250 + return conf; 251 + } 252 + 253 + static int aml_pinconf_get_drive_strength(struct aml_pinctrl *info, 254 + unsigned int pin, 255 + u16 *drive_strength_ua) 256 + { 257 + struct pinctrl_gpio_range *range = 258 + pinctrl_find_gpio_range_from_pin(info->pctl, pin); 259 + struct aml_gpio_bank *bank = gpio_chip_to_bank(range->gc); 260 + unsigned int reg, bit; 261 + unsigned int val; 262 + int ret; 263 + 264 + if (!bank->reg_ds) 265 + return -EOPNOTSUPP; 266 + 267 + aml_calc_reg_and_bit(range, pin, AML_REG_DS, &reg, &bit); 268 + ret = regmap_read(bank->reg_ds, reg, &val); 269 + if (ret) 270 + return ret; 271 + 272 + switch ((val >> bit) & 0x3) { 273 + case PINCONF_DRV_500UA: 274 + *drive_strength_ua = 500; 275 + break; 276 + case PINCONF_DRV_2500UA: 277 + *drive_strength_ua = 2500; 278 + break; 279 + case PINCONF_DRV_3000UA: 280 + *drive_strength_ua = 3000; 281 + break; 282 + case PINCONF_DRV_4000UA: 283 + *drive_strength_ua = 4000; 284 + break; 285 + default: 286 + return -EINVAL; 287 + } 288 + 289 + return 0; 290 + } 291 + 292 + static int aml_pinconf_get_gpio_bit(struct aml_pinctrl *info, 293 + unsigned int pin, 294 + unsigned int reg_type) 295 + { 296 + struct pinctrl_gpio_range *range = 297 + pinctrl_find_gpio_range_from_pin(info->pctl, pin); 298 + struct aml_gpio_bank *bank = gpio_chip_to_bank(range->gc); 299 + unsigned int reg, bit, val; 300 + int ret; 301 + 302 + aml_calc_reg_and_bit(range, pin, reg_type, &reg, &bit); 303 + ret = regmap_read(bank->reg_gpio, reg, &val); 304 + if (ret) 305 + return ret; 306 + 307 + return BIT(bit) & val ? 1 : 0; 308 + } 309 + 310 + static int aml_pinconf_get_output(struct aml_pinctrl *info, 311 + unsigned int pin) 312 + { 313 + int ret = aml_pinconf_get_gpio_bit(info, pin, AML_REG_DIR); 314 + 315 + if (ret < 0) 316 + return ret; 317 + 318 + return !ret; 319 + } 320 + 321 + static int aml_pinconf_get_drive(struct aml_pinctrl *info, 322 + unsigned int pin) 323 + { 324 + return aml_pinconf_get_gpio_bit(info, pin, AML_REG_OUT); 325 + } 326 + 327 + static int aml_pinconf_get(struct pinctrl_dev *pcdev, unsigned int pin, 328 + unsigned long *config) 329 + { 330 + struct aml_pinctrl *info = pinctrl_dev_get_drvdata(pcdev); 331 + enum pin_config_param param = pinconf_to_config_param(*config); 332 + u16 arg; 333 + int ret; 334 + 335 + switch (param) { 336 + case PIN_CONFIG_BIAS_DISABLE: 337 + case PIN_CONFIG_BIAS_PULL_DOWN: 338 + case PIN_CONFIG_BIAS_PULL_UP: 339 + if (aml_pinconf_get_pull(info, pin) == param) 340 + arg = 1; 341 + else 342 + return -EINVAL; 343 + break; 344 + case PIN_CONFIG_DRIVE_STRENGTH_UA: 345 + ret = aml_pinconf_get_drive_strength(info, pin, &arg); 346 + if (ret) 347 + return ret; 348 + break; 349 + case PIN_CONFIG_OUTPUT_ENABLE: 350 + ret = aml_pinconf_get_output(info, pin); 351 + if (ret <= 0) 352 + return -EINVAL; 353 + arg = 1; 354 + break; 355 + case PIN_CONFIG_OUTPUT: 356 + ret = aml_pinconf_get_output(info, pin); 357 + if (ret <= 0) 358 + return -EINVAL; 359 + 360 + ret = aml_pinconf_get_drive(info, pin); 361 + if (ret < 0) 362 + return -EINVAL; 363 + 364 + arg = ret; 365 + break; 366 + 367 + default: 368 + return -ENOTSUPP; 369 + } 370 + 371 + *config = pinconf_to_config_packed(param, arg); 372 + dev_dbg(info->dev, "pinconf for pin %u is %lu\n", pin, *config); 373 + 374 + return 0; 375 + } 376 + 377 + static int aml_pinconf_disable_bias(struct aml_pinctrl *info, 378 + unsigned int pin) 379 + { 380 + struct pinctrl_gpio_range *range = 381 + pinctrl_find_gpio_range_from_pin(info->pctl, pin); 382 + struct aml_gpio_bank *bank = gpio_chip_to_bank(range->gc); 383 + unsigned int reg, bit = 0; 384 + 385 + aml_calc_reg_and_bit(range, pin, AML_REG_PULLEN, &reg, &bit); 386 + 387 + return regmap_update_bits(bank->reg_gpio, reg, BIT(bit), 0); 388 + } 389 + 390 + static int aml_pinconf_enable_bias(struct aml_pinctrl *info, unsigned int pin, 391 + bool pull_up) 392 + { 393 + struct pinctrl_gpio_range *range = 394 + pinctrl_find_gpio_range_from_pin(info->pctl, pin); 395 + struct aml_gpio_bank *bank = gpio_chip_to_bank(range->gc); 396 + unsigned int reg, bit, val = 0; 397 + int ret; 398 + 399 + aml_calc_reg_and_bit(range, pin, AML_REG_PULL, &reg, &bit); 400 + if (pull_up) 401 + val = BIT(bit); 402 + 403 + ret = regmap_update_bits(bank->reg_gpio, reg, BIT(bit), val); 404 + if (ret) 405 + return ret; 406 + 407 + aml_calc_reg_and_bit(range, pin, AML_REG_PULLEN, &reg, &bit); 408 + return regmap_update_bits(bank->reg_gpio, reg, BIT(bit), BIT(bit)); 409 + } 410 + 411 + static int aml_pinconf_set_drive_strength(struct aml_pinctrl *info, 412 + unsigned int pin, 413 + u16 drive_strength_ua) 414 + { 415 + struct pinctrl_gpio_range *range = 416 + pinctrl_find_gpio_range_from_pin(info->pctl, pin); 417 + struct aml_gpio_bank *bank = gpio_chip_to_bank(range->gc); 418 + unsigned int reg, bit, ds_val; 419 + 420 + if (!bank->reg_ds) { 421 + dev_err(info->dev, "drive-strength not supported\n"); 422 + return -EOPNOTSUPP; 423 + } 424 + 425 + aml_calc_reg_and_bit(range, pin, AML_REG_DS, &reg, &bit); 426 + 427 + if (drive_strength_ua <= 500) { 428 + ds_val = PINCONF_DRV_500UA; 429 + } else if (drive_strength_ua <= 2500) { 430 + ds_val = PINCONF_DRV_2500UA; 431 + } else if (drive_strength_ua <= 3000) { 432 + ds_val = PINCONF_DRV_3000UA; 433 + } else if (drive_strength_ua <= 4000) { 434 + ds_val = PINCONF_DRV_4000UA; 435 + } else { 436 + dev_warn_once(info->dev, 437 + "pin %u: invalid drive-strength : %d , default to 4mA\n", 438 + pin, drive_strength_ua); 439 + ds_val = PINCONF_DRV_4000UA; 440 + } 441 + 442 + return regmap_update_bits(bank->reg_ds, reg, 0x3 << bit, ds_val << bit); 443 + } 444 + 445 + static int aml_pinconf_set_gpio_bit(struct aml_pinctrl *info, 446 + unsigned int pin, 447 + unsigned int reg_type, 448 + bool arg) 449 + { 450 + struct pinctrl_gpio_range *range = 451 + pinctrl_find_gpio_range_from_pin(info->pctl, pin); 452 + struct aml_gpio_bank *bank = gpio_chip_to_bank(range->gc); 453 + unsigned int reg, bit; 454 + 455 + aml_calc_reg_and_bit(range, pin, reg_type, &reg, &bit); 456 + return regmap_update_bits(bank->reg_gpio, reg, BIT(bit), 457 + arg ? BIT(bit) : 0); 458 + } 459 + 460 + static int aml_pinconf_set_output(struct aml_pinctrl *info, 461 + unsigned int pin, 462 + bool out) 463 + { 464 + return aml_pinconf_set_gpio_bit(info, pin, AML_REG_DIR, !out); 465 + } 466 + 467 + static int aml_pinconf_set_drive(struct aml_pinctrl *info, 468 + unsigned int pin, 469 + bool high) 470 + { 471 + return aml_pinconf_set_gpio_bit(info, pin, AML_REG_OUT, high); 472 + } 473 + 474 + static int aml_pinconf_set_output_drive(struct aml_pinctrl *info, 475 + unsigned int pin, 476 + bool high) 477 + { 478 + int ret; 479 + 480 + ret = aml_pinconf_set_output(info, pin, true); 481 + if (ret) 482 + return ret; 483 + 484 + return aml_pinconf_set_drive(info, pin, high); 485 + } 486 + 487 + static int aml_pinconf_set(struct pinctrl_dev *pcdev, unsigned int pin, 488 + unsigned long *configs, unsigned int num_configs) 489 + { 490 + struct aml_pinctrl *info = pinctrl_dev_get_drvdata(pcdev); 491 + enum pin_config_param param; 492 + unsigned int arg = 0; 493 + int i, ret; 494 + 495 + for (i = 0; i < num_configs; i++) { 496 + param = pinconf_to_config_param(configs[i]); 497 + 498 + switch (param) { 499 + case PIN_CONFIG_DRIVE_STRENGTH_UA: 500 + case PIN_CONFIG_OUTPUT_ENABLE: 501 + case PIN_CONFIG_OUTPUT: 502 + arg = pinconf_to_config_argument(configs[i]); 503 + break; 504 + 505 + default: 506 + break; 507 + } 508 + 509 + switch (param) { 510 + case PIN_CONFIG_BIAS_DISABLE: 511 + ret = aml_pinconf_disable_bias(info, pin); 512 + break; 513 + case PIN_CONFIG_BIAS_PULL_UP: 514 + ret = aml_pinconf_enable_bias(info, pin, true); 515 + break; 516 + case PIN_CONFIG_BIAS_PULL_DOWN: 517 + ret = aml_pinconf_enable_bias(info, pin, false); 518 + break; 519 + case PIN_CONFIG_DRIVE_STRENGTH_UA: 520 + ret = aml_pinconf_set_drive_strength(info, pin, arg); 521 + break; 522 + case PIN_CONFIG_OUTPUT_ENABLE: 523 + ret = aml_pinconf_set_output(info, pin, arg); 524 + break; 525 + case PIN_CONFIG_OUTPUT: 526 + ret = aml_pinconf_set_output_drive(info, pin, arg); 527 + break; 528 + default: 529 + ret = -ENOTSUPP; 530 + } 531 + 532 + if (ret) 533 + return ret; 534 + } 535 + 536 + return 0; 537 + } 538 + 539 + static int aml_pinconf_group_set(struct pinctrl_dev *pcdev, 540 + unsigned int num_group, 541 + unsigned long *configs, 542 + unsigned int num_configs) 543 + { 544 + struct aml_pinctrl *info = pinctrl_dev_get_drvdata(pcdev); 545 + int i; 546 + 547 + for (i = 0; i < info->groups[num_group].npins; i++) { 548 + aml_pinconf_set(pcdev, info->groups[num_group].pins[i], configs, 549 + num_configs); 550 + } 551 + 552 + return 0; 553 + } 554 + 555 + static int aml_pinconf_group_get(struct pinctrl_dev *pcdev, 556 + unsigned int group, unsigned long *config) 557 + { 558 + return -EOPNOTSUPP; 559 + } 560 + 561 + static const struct pinconf_ops aml_pinconf_ops = { 562 + .pin_config_get = aml_pinconf_get, 563 + .pin_config_set = aml_pinconf_set, 564 + .pin_config_group_get = aml_pinconf_group_get, 565 + .pin_config_group_set = aml_pinconf_group_set, 566 + .is_generic = true, 567 + }; 568 + 569 + static int aml_get_groups_count(struct pinctrl_dev *pctldev) 570 + { 571 + struct aml_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); 572 + 573 + return info->ngroups; 574 + } 575 + 576 + static const char *aml_get_group_name(struct pinctrl_dev *pctldev, 577 + unsigned int selector) 578 + { 579 + struct aml_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); 580 + 581 + return info->groups[selector].name; 582 + } 583 + 584 + static int aml_get_group_pins(struct pinctrl_dev *pctldev, 585 + unsigned int selector, const unsigned int **pins, 586 + unsigned int *npins) 587 + { 588 + struct aml_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); 589 + 590 + if (selector >= info->ngroups) 591 + return -EINVAL; 592 + 593 + *pins = info->groups[selector].pins; 594 + *npins = info->groups[selector].npins; 595 + 596 + return 0; 597 + } 598 + 599 + static inline const struct aml_pctl_group * 600 + aml_pctl_find_group_by_name(const struct aml_pinctrl *info, 601 + const char *name) 602 + { 603 + int i; 604 + 605 + for (i = 0; i < info->ngroups; i++) { 606 + if (!strcmp(info->groups[i].name, name)) 607 + return &info->groups[i]; 608 + } 609 + 610 + return NULL; 611 + } 612 + 613 + static void aml_pin_dbg_show(struct pinctrl_dev *pcdev, struct seq_file *s, 614 + unsigned int offset) 615 + { 616 + seq_printf(s, " %s", dev_name(pcdev->dev)); 617 + } 618 + 619 + static const struct pinctrl_ops aml_pctrl_ops = { 620 + .get_groups_count = aml_get_groups_count, 621 + .get_group_name = aml_get_group_name, 622 + .get_group_pins = aml_get_group_pins, 623 + .dt_node_to_map = pinconf_generic_dt_node_to_map_pinmux, 624 + .dt_free_map = pinconf_generic_dt_free_map, 625 + .pin_dbg_show = aml_pin_dbg_show, 626 + }; 627 + 628 + static int aml_pctl_parse_functions(struct device_node *np, 629 + struct aml_pinctrl *info, u32 index, 630 + int *grp_index) 631 + { 632 + struct device *dev = info->dev; 633 + struct aml_pmx_func *func; 634 + struct aml_pctl_group *grp; 635 + int ret, i; 636 + 637 + func = &info->functions[index]; 638 + func->name = np->name; 639 + func->ngroups = of_get_child_count(np); 640 + if (func->ngroups == 0) 641 + return dev_err_probe(dev, -EINVAL, "No groups defined\n"); 642 + 643 + func->groups = devm_kcalloc(dev, func->ngroups, sizeof(*func->groups), GFP_KERNEL); 644 + if (!func->groups) 645 + return -ENOMEM; 646 + 647 + i = 0; 648 + for_each_child_of_node_scoped(np, child) { 649 + func->groups[i++] = child->name; 650 + grp = &info->groups[*grp_index]; 651 + grp->name = child->name; 652 + *grp_index += 1; 653 + ret = pinconf_generic_parse_dt_pinmux(child, dev, &grp->pins, 654 + &grp->func, &grp->npins); 655 + if (ret) { 656 + dev_err(dev, "function :%s, groups:%s fail\n", func->name, child->name); 657 + return ret; 658 + } 659 + } 660 + dev_dbg(dev, "Function[%d\t name:%s,\tgroups:%d]\n", index, func->name, func->ngroups); 661 + 662 + return 0; 663 + } 664 + 665 + static u32 aml_bank_pins(struct device_node *np) 666 + { 667 + struct of_phandle_args of_args; 668 + 669 + if (of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3, 670 + 0, &of_args)) 671 + return 0; 672 + else 673 + return of_args.args[2]; 674 + } 675 + 676 + static int aml_bank_number(struct device_node *np) 677 + { 678 + struct of_phandle_args of_args; 679 + 680 + if (of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3, 681 + 0, &of_args)) 682 + return -EINVAL; 683 + else 684 + return of_args.args[1] >> 8; 685 + } 686 + 687 + static unsigned int aml_count_pins(struct device_node *np) 688 + { 689 + struct device_node *child; 690 + unsigned int pins = 0; 691 + 692 + for_each_child_of_node(np, child) { 693 + if (of_property_read_bool(child, "gpio-controller")) 694 + pins += aml_bank_pins(child); 695 + } 696 + 697 + return pins; 698 + } 699 + 700 + /* 701 + * A pinctrl device contains two types of nodes. The one named GPIO 702 + * bank which includes gpio-controller property. The other one named 703 + * function which includes one or more pin groups. The pin group 704 + * include pinmux property(global index in pinctrl dev, and mux vlaue 705 + * in mux reg) and pin configuration properties. 706 + */ 707 + static void aml_pctl_dt_child_count(struct aml_pinctrl *info, 708 + struct device_node *np) 709 + { 710 + struct device_node *child; 711 + 712 + for_each_child_of_node(np, child) { 713 + if (of_property_read_bool(child, "gpio-controller")) { 714 + info->nbanks++; 715 + } else { 716 + info->nfunctions++; 717 + info->ngroups += of_get_child_count(child); 718 + } 719 + } 720 + } 721 + 722 + static struct regmap *aml_map_resource(struct device *dev, unsigned int id, 723 + struct device_node *node, char *name) 724 + { 725 + struct resource res; 726 + void __iomem *base; 727 + int i; 728 + 729 + struct regmap_config aml_regmap_config = { 730 + .reg_bits = 32, 731 + .val_bits = 32, 732 + .reg_stride = 4, 733 + }; 734 + 735 + i = of_property_match_string(node, "reg-names", name); 736 + if (i < 0) 737 + return NULL; 738 + if (of_address_to_resource(node, i, &res)) 739 + return NULL; 740 + base = devm_ioremap_resource(dev, &res); 741 + if (IS_ERR(base)) 742 + return ERR_CAST(base); 743 + 744 + aml_regmap_config.max_register = resource_size(&res) - 4; 745 + aml_regmap_config.name = devm_kasprintf(dev, GFP_KERNEL, 746 + "%s-%s", aml_bank_name[id], name); 747 + if (!aml_regmap_config.name) 748 + return ERR_PTR(-ENOMEM); 749 + 750 + return devm_regmap_init_mmio(dev, base, &aml_regmap_config); 751 + } 752 + 753 + static inline int aml_gpio_calc_reg_and_bit(struct aml_gpio_bank *bank, 754 + unsigned int reg_type, 755 + unsigned int gpio, 756 + unsigned int *reg, 757 + unsigned int *bit) 758 + { 759 + *bit = gpio * aml_bit_strides[reg_type] + bank->pc.bit_offset[reg_type]; 760 + *reg = (bank->pc.reg_offset[reg_type] + (*bit / 32)) * 4; 761 + *bit &= 0x1f; 762 + 763 + return 0; 764 + } 765 + 766 + static int aml_gpio_get_direction(struct gpio_chip *chip, unsigned int gpio) 767 + { 768 + struct aml_gpio_bank *bank = gpiochip_get_data(chip); 769 + unsigned int bit, reg, val; 770 + int ret; 771 + 772 + aml_gpio_calc_reg_and_bit(bank, AML_REG_DIR, gpio, &reg, &bit); 773 + 774 + ret = regmap_read(bank->reg_gpio, reg, &val); 775 + if (ret) 776 + return ret; 777 + 778 + return BIT(bit) & val ? GPIO_LINE_DIRECTION_IN : GPIO_LINE_DIRECTION_OUT; 779 + } 780 + 781 + static int aml_gpio_direction_input(struct gpio_chip *chip, unsigned int gpio) 782 + { 783 + struct aml_gpio_bank *bank = gpiochip_get_data(chip); 784 + unsigned int bit, reg; 785 + 786 + aml_gpio_calc_reg_and_bit(bank, AML_REG_DIR, gpio, &reg, &bit); 787 + 788 + return regmap_update_bits(bank->reg_gpio, reg, BIT(bit), BIT(bit)); 789 + } 790 + 791 + static int aml_gpio_direction_output(struct gpio_chip *chip, unsigned int gpio, 792 + int value) 793 + { 794 + struct aml_gpio_bank *bank = gpiochip_get_data(chip); 795 + unsigned int bit, reg; 796 + int ret; 797 + 798 + aml_gpio_calc_reg_and_bit(bank, AML_REG_DIR, gpio, &reg, &bit); 799 + ret = regmap_update_bits(bank->reg_gpio, reg, BIT(bit), 0); 800 + if (ret < 0) 801 + return ret; 802 + 803 + aml_gpio_calc_reg_and_bit(bank, AML_REG_OUT, gpio, &reg, &bit); 804 + 805 + return regmap_update_bits(bank->reg_gpio, reg, BIT(bit), 806 + value ? BIT(bit) : 0); 807 + } 808 + 809 + static void aml_gpio_set(struct gpio_chip *chip, unsigned int gpio, int value) 810 + { 811 + struct aml_gpio_bank *bank = gpiochip_get_data(chip); 812 + unsigned int bit, reg; 813 + 814 + aml_gpio_calc_reg_and_bit(bank, AML_REG_OUT, gpio, &reg, &bit); 815 + 816 + regmap_update_bits(bank->reg_gpio, reg, BIT(bit), 817 + value ? BIT(bit) : 0); 818 + } 819 + 820 + static int aml_gpio_get(struct gpio_chip *chip, unsigned int gpio) 821 + { 822 + struct aml_gpio_bank *bank = gpiochip_get_data(chip); 823 + unsigned int reg, bit, val; 824 + 825 + aml_gpio_calc_reg_and_bit(bank, AML_REG_IN, gpio, &reg, &bit); 826 + regmap_read(bank->reg_gpio, reg, &val); 827 + 828 + return !!(val & BIT(bit)); 829 + } 830 + 831 + static const struct gpio_chip aml_gpio_template = { 832 + .request = gpiochip_generic_request, 833 + .free = gpiochip_generic_free, 834 + .set_config = gpiochip_generic_config, 835 + .set = aml_gpio_set, 836 + .get = aml_gpio_get, 837 + .direction_input = aml_gpio_direction_input, 838 + .direction_output = aml_gpio_direction_output, 839 + .get_direction = aml_gpio_get_direction, 840 + .can_sleep = false, 841 + }; 842 + 843 + static void init_bank_register_bit(struct aml_pinctrl *info, 844 + struct aml_gpio_bank *bank) 845 + { 846 + const struct aml_pctl_data *data = info->data; 847 + const struct aml_reg_bit *aml_rb; 848 + bool def_offs = true; 849 + int i; 850 + 851 + if (data) { 852 + for (i = 0; i < data->number; i++) { 853 + aml_rb = &data->rb_offs[i]; 854 + if (bank->bank_id == aml_rb->bank_id) { 855 + def_offs = false; 856 + break; 857 + } 858 + } 859 + } 860 + 861 + if (def_offs) { 862 + for (i = 0; i < AML_NUM_REG; i++) { 863 + bank->pc.reg_offset[i] = aml_def_regoffs[i]; 864 + bank->pc.bit_offset[i] = 0; 865 + } 866 + } else { 867 + for (i = 0; i < AML_NUM_REG; i++) { 868 + bank->pc.reg_offset[i] = aml_rb->reg_offs[i]; 869 + bank->pc.bit_offset[i] = aml_rb->bit_offs[i]; 870 + } 871 + } 872 + } 873 + 874 + static int aml_gpiolib_register_bank(struct aml_pinctrl *info, 875 + int bank_nr, struct device_node *np) 876 + { 877 + struct aml_gpio_bank *bank = &info->banks[bank_nr]; 878 + struct device *dev = info->dev; 879 + int ret = 0; 880 + 881 + ret = aml_bank_number(np); 882 + if (ret < 0) { 883 + dev_err(dev, "get num=%d bank identity fail\n", bank_nr); 884 + return -EINVAL; 885 + } 886 + bank->bank_id = ret; 887 + 888 + bank->reg_mux = aml_map_resource(dev, bank->bank_id, np, "mux"); 889 + if (IS_ERR_OR_NULL(bank->reg_mux)) { 890 + if (bank->bank_id == AMLOGIC_GPIO_TEST_N || 891 + bank->bank_id == AMLOGIC_GPIO_ANALOG) 892 + bank->reg_mux = NULL; 893 + else 894 + return dev_err_probe(dev, bank->reg_mux ? PTR_ERR(bank->reg_mux) : -ENOENT, 895 + "mux registers not found\n"); 896 + } 897 + 898 + bank->reg_gpio = aml_map_resource(dev, bank->bank_id, np, "gpio"); 899 + if (IS_ERR_OR_NULL(bank->reg_gpio)) 900 + return dev_err_probe(dev, bank->reg_gpio ? PTR_ERR(bank->reg_gpio) : -ENOENT, 901 + "gpio registers not found\n"); 902 + 903 + bank->reg_ds = aml_map_resource(dev, bank->bank_id, np, "ds"); 904 + if (IS_ERR_OR_NULL(bank->reg_ds)) { 905 + dev_dbg(info->dev, "ds registers not found - skipping\n"); 906 + bank->reg_ds = bank->reg_gpio; 907 + } 908 + 909 + bank->gpio_chip = aml_gpio_template; 910 + bank->gpio_chip.base = -1; 911 + bank->gpio_chip.ngpio = aml_bank_pins(np); 912 + bank->gpio_chip.fwnode = of_fwnode_handle(np); 913 + bank->gpio_chip.parent = dev; 914 + 915 + init_bank_register_bit(info, bank); 916 + bank->gpio_chip.label = aml_bank_name[bank->bank_id]; 917 + 918 + bank->pin_base = bank->bank_id << 8; 919 + 920 + return 0; 921 + } 922 + 923 + static int aml_pctl_probe_dt(struct platform_device *pdev, 924 + struct pinctrl_desc *pctl_desc, 925 + struct aml_pinctrl *info) 926 + { 927 + struct device *dev = &pdev->dev; 928 + struct pinctrl_pin_desc *pdesc; 929 + struct device_node *np = dev->of_node; 930 + int grp_index = 0; 931 + int i = 0, j = 0, k = 0, bank; 932 + int ret = 0; 933 + 934 + aml_pctl_dt_child_count(info, np); 935 + if (!info->nbanks) 936 + return dev_err_probe(dev, -EINVAL, "you need at least one gpio bank\n"); 937 + 938 + dev_dbg(dev, "nbanks = %d\n", info->nbanks); 939 + dev_dbg(dev, "nfunctions = %d\n", info->nfunctions); 940 + dev_dbg(dev, "ngroups = %d\n", info->ngroups); 941 + 942 + info->functions = devm_kcalloc(dev, info->nfunctions, sizeof(*info->functions), GFP_KERNEL); 943 + 944 + info->groups = devm_kcalloc(dev, info->ngroups, sizeof(*info->groups), GFP_KERNEL); 945 + 946 + info->banks = devm_kcalloc(dev, info->nbanks, sizeof(*info->banks), GFP_KERNEL); 947 + 948 + if (!info->functions || !info->groups || !info->banks) 949 + return -ENOMEM; 950 + 951 + info->data = (struct aml_pctl_data *)of_device_get_match_data(dev); 952 + 953 + pctl_desc->npins = aml_count_pins(np); 954 + 955 + pdesc = devm_kcalloc(dev, pctl_desc->npins, sizeof(*pdesc), GFP_KERNEL); 956 + if (!pdesc) 957 + return -ENOMEM; 958 + 959 + pctl_desc->pins = pdesc; 960 + 961 + bank = 0; 962 + for_each_child_of_node_scoped(np, child) { 963 + if (of_property_read_bool(child, "gpio-controller")) { 964 + const char *bank_name = NULL; 965 + char **pin_names; 966 + 967 + ret = aml_gpiolib_register_bank(info, bank, child); 968 + if (ret) 969 + return ret; 970 + 971 + k = info->banks[bank].pin_base; 972 + bank_name = info->banks[bank].gpio_chip.label; 973 + 974 + pin_names = devm_kasprintf_strarray(dev, bank_name, 975 + info->banks[bank].gpio_chip.ngpio); 976 + if (IS_ERR(pin_names)) 977 + return PTR_ERR(pin_names); 978 + 979 + for (j = 0; j < info->banks[bank].gpio_chip.ngpio; j++, k++) { 980 + pdesc->number = k; 981 + pdesc->name = pin_names[j]; 982 + pdesc++; 983 + } 984 + bank++; 985 + } else { 986 + ret = aml_pctl_parse_functions(child, info, 987 + i++, &grp_index); 988 + if (ret) 989 + return ret; 990 + } 991 + } 992 + 993 + return 0; 994 + } 995 + 996 + static int aml_pctl_probe(struct platform_device *pdev) 997 + { 998 + struct device *dev = &pdev->dev; 999 + struct aml_pinctrl *info; 1000 + struct pinctrl_desc *pctl_desc; 1001 + int ret, i; 1002 + 1003 + pctl_desc = devm_kzalloc(dev, sizeof(*pctl_desc), GFP_KERNEL); 1004 + if (!pctl_desc) 1005 + return -ENOMEM; 1006 + 1007 + info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL); 1008 + if (!info) 1009 + return -ENOMEM; 1010 + 1011 + info->dev = dev; 1012 + platform_set_drvdata(pdev, info); 1013 + ret = aml_pctl_probe_dt(pdev, pctl_desc, info); 1014 + if (ret) 1015 + return ret; 1016 + 1017 + pctl_desc->owner = THIS_MODULE; 1018 + pctl_desc->pctlops = &aml_pctrl_ops; 1019 + pctl_desc->pmxops = &aml_pmx_ops; 1020 + pctl_desc->confops = &aml_pinconf_ops; 1021 + pctl_desc->name = dev_name(dev); 1022 + 1023 + info->pctl = devm_pinctrl_register(dev, pctl_desc, info); 1024 + if (IS_ERR(info->pctl)) 1025 + return dev_err_probe(dev, PTR_ERR(info->pctl), "Failed pinctrl registration\n"); 1026 + 1027 + for (i = 0; i < info->nbanks; i++) { 1028 + ret = gpiochip_add_data(&info->banks[i].gpio_chip, &info->banks[i]); 1029 + if (ret) 1030 + return dev_err_probe(dev, ret, "Failed to add gpiochip(%d)!\n", i); 1031 + } 1032 + 1033 + return 0; 1034 + } 1035 + 1036 + static const struct of_device_id aml_pctl_of_match[] = { 1037 + { .compatible = "amlogic,pinctrl-a4", }, 1038 + { /* sentinel */ } 1039 + }; 1040 + MODULE_DEVICE_TABLE(of, aml_pctl_dt_match); 1041 + 1042 + static struct platform_driver aml_pctl_driver = { 1043 + .driver = { 1044 + .name = "amlogic-pinctrl", 1045 + .of_match_table = aml_pctl_of_match, 1046 + }, 1047 + .probe = aml_pctl_probe, 1048 + }; 1049 + module_platform_driver(aml_pctl_driver); 1050 + 1051 + MODULE_AUTHOR("Xianwei Zhao <xianwei.zhao@amlogic.com>"); 1052 + MODULE_DESCRIPTION("Pin controller and GPIO driver for Amlogic SoC"); 1053 + MODULE_LICENSE("Dual BSD/GPL");
+56 -64
drivers/pinctrl/nuvoton/pinctrl-ma35.c
··· 98 98 17100, 25600, 34100, 42800, 48000, 56000, 77000, 82000, 99 99 }; 100 100 101 - struct ma35_pin_func { 102 - const char *name; 103 - const char **groups; 104 - u32 ngroups; 105 - }; 106 - 107 101 struct ma35_pin_setting { 108 102 u32 offset; 109 103 u32 shift; 110 104 u32 muxval; 111 105 unsigned long *configs; 112 106 unsigned int nconfigs; 113 - }; 114 - 115 - struct ma35_pin_group { 116 - const char *name; 117 - unsigned int npins; 118 - unsigned int *pins; 119 - struct ma35_pin_setting *settings; 120 107 }; 121 108 122 109 struct ma35_pin_bank { ··· 134 147 struct pinctrl_dev *pctl; 135 148 const struct ma35_pinctrl_soc_info *info; 136 149 struct regmap *regmap; 137 - struct ma35_pin_group *groups; 150 + struct group_desc *groups; 138 151 unsigned int ngroups; 139 - struct ma35_pin_func *functions; 152 + struct pinfunction *functions; 140 153 unsigned int nfunctions; 141 154 }; 142 155 ··· 153 166 { 154 167 struct ma35_pinctrl *npctl = pinctrl_dev_get_drvdata(pctldev); 155 168 156 - return npctl->groups[selector].name; 169 + return npctl->groups[selector].grp.name; 157 170 } 158 171 159 172 static int ma35_get_group_pins(struct pinctrl_dev *pctldev, unsigned int selector, ··· 164 177 if (selector >= npctl->ngroups) 165 178 return -EINVAL; 166 179 167 - *pins = npctl->groups[selector].pins; 168 - *npins = npctl->groups[selector].npins; 180 + *pins = npctl->groups[selector].grp.pins; 181 + *npins = npctl->groups[selector].grp.npins; 169 182 170 183 return 0; 171 184 } 172 185 173 - static struct ma35_pin_group *ma35_pinctrl_find_group_by_name( 174 - const struct ma35_pinctrl *npctl, const char *name) 186 + static struct group_desc * 187 + ma35_pinctrl_find_group_by_name(const struct ma35_pinctrl *npctl, const char *name) 175 188 { 176 189 int i; 177 190 178 191 for (i = 0; i < npctl->ngroups; i++) { 179 - if (!strcmp(npctl->groups[i].name, name)) 192 + if (!strcmp(npctl->groups[i].grp.name, name)) 180 193 return &npctl->groups[i]; 181 194 } 182 195 return NULL; ··· 188 201 unsigned int *num_maps) 189 202 { 190 203 struct ma35_pinctrl *npctl = pinctrl_dev_get_drvdata(pctldev); 191 - struct ma35_pin_group *grp; 204 + struct ma35_pin_setting *setting; 192 205 struct pinctrl_map *new_map; 193 206 struct device_node *parent; 207 + struct group_desc *grp; 194 208 int map_num = 1; 195 209 int i; 196 210 ··· 205 217 return -EINVAL; 206 218 } 207 219 208 - map_num += grp->npins; 220 + map_num += grp->grp.npins; 209 221 new_map = kcalloc(map_num, sizeof(*new_map), GFP_KERNEL); 210 222 if (!new_map) 211 223 return -ENOMEM; ··· 217 229 if (!parent) 218 230 return -EINVAL; 219 231 232 + setting = grp->data; 233 + 220 234 new_map[0].type = PIN_MAP_TYPE_MUX_GROUP; 221 235 new_map[0].data.mux.function = parent->name; 222 236 new_map[0].data.mux.group = np->name; 223 237 of_node_put(parent); 224 238 225 239 new_map++; 226 - for (i = 0; i < grp->npins; i++) { 240 + for (i = 0; i < grp->grp.npins; i++) { 227 241 new_map[i].type = PIN_MAP_TYPE_CONFIGS_PIN; 228 - new_map[i].data.configs.group_or_pin = pin_get_name(pctldev, grp->pins[i]); 229 - new_map[i].data.configs.configs = grp->settings[i].configs; 230 - new_map[i].data.configs.num_configs = grp->settings[i].nconfigs; 242 + new_map[i].data.configs.group_or_pin = pin_get_name(pctldev, grp->grp.pins[i]); 243 + new_map[i].data.configs.configs = setting[i].configs; 244 + new_map[i].data.configs.num_configs = setting[i].nconfigs; 231 245 } 232 246 dev_dbg(pctldev->dev, "maps: function %s group %s num %d\n", 233 247 (*map)->data.mux.function, (*map)->data.mux.group, map_num); ··· 277 287 unsigned int group) 278 288 { 279 289 struct ma35_pinctrl *npctl = pinctrl_dev_get_drvdata(pctldev); 280 - struct ma35_pin_group *grp = &npctl->groups[group]; 281 - struct ma35_pin_setting *setting = grp->settings; 290 + struct group_desc *grp = &npctl->groups[group]; 291 + struct ma35_pin_setting *setting = grp->data; 282 292 u32 i, regval; 283 293 284 294 dev_dbg(npctl->dev, "enable function %s group %s\n", 285 - npctl->functions[selector].name, npctl->groups[group].name); 295 + npctl->functions[selector].name, grp->grp.name); 286 296 287 - for (i = 0; i < grp->npins; i++) { 297 + for (i = 0; i < grp->grp.npins; i++) { 288 298 regmap_read(npctl->regmap, setting->offset, &regval); 289 299 regval &= ~GENMASK(setting->shift + MA35_MFP_BITS_PER_PORT - 1, 290 300 setting->shift); ··· 519 529 bank->irqtype = 0; 520 530 bank->irqinten = 0; 521 531 bank->chip.label = bank->name; 522 - bank->chip.of_gpio_n_cells = 2; 523 532 bank->chip.parent = &pdev->dev; 524 533 bank->chip.request = ma35_gpio_core_to_request; 525 534 bank->chip.direction_input = ma35_gpio_core_direction_in; ··· 975 986 .is_generic = true, 976 987 }; 977 988 978 - static int ma35_pinctrl_parse_groups(struct device_node *np, struct ma35_pin_group *grp, 989 + static int ma35_pinctrl_parse_groups(struct fwnode_handle *fwnode, struct group_desc *grp, 979 990 struct ma35_pinctrl *npctl, u32 index) 980 991 { 992 + struct device_node *np = to_of_node(fwnode); 981 993 struct ma35_pin_setting *pin; 982 994 unsigned long *configs; 983 995 unsigned int nconfigs; 996 + unsigned int *pins; 984 997 int i, j, count, ret; 985 998 u32 *elems; 986 - 987 - grp->name = np->name; 988 999 989 1000 ret = pinconf_generic_parse_dt_config(np, NULL, &configs, &nconfigs); 990 1001 if (ret) 991 1002 return ret; 992 1003 993 - count = of_property_count_elems_of_size(np, "nuvoton,pins", sizeof(u32)); 1004 + count = fwnode_property_count_u32(fwnode, "nuvoton,pins"); 994 1005 if (!count || count % 3) 995 1006 return -EINVAL; 996 1007 ··· 998 1009 if (!elems) 999 1010 return -ENOMEM; 1000 1011 1001 - ret = of_property_read_u32_array(np, "nuvoton,pins", elems, count); 1012 + grp->grp.name = np->name; 1013 + 1014 + ret = fwnode_property_read_u32_array(fwnode, "nuvoton,pins", elems, count); 1002 1015 if (ret) 1003 1016 return -EINVAL; 1017 + grp->grp.npins = count / 3; 1004 1018 1005 - grp->npins = count / 3; 1006 - 1007 - grp->pins = devm_kcalloc(npctl->dev, grp->npins, sizeof(*grp->pins), GFP_KERNEL); 1008 - if (!grp->pins) 1019 + pins = devm_kcalloc(npctl->dev, grp->grp.npins, sizeof(*pins), GFP_KERNEL); 1020 + if (!pins) 1009 1021 return -ENOMEM; 1022 + grp->grp.pins = pins; 1010 1023 1011 - grp->settings = devm_kcalloc(npctl->dev, grp->npins, sizeof(*grp->settings), GFP_KERNEL); 1012 - if (!grp->settings) 1024 + pin = devm_kcalloc(npctl->dev, grp->grp.npins, sizeof(*pin), GFP_KERNEL); 1025 + if (!pin) 1013 1026 return -ENOMEM; 1014 - 1015 - pin = grp->settings; 1027 + grp->data = pin; 1016 1028 1017 1029 for (i = 0, j = 0; i < count; i += 3, j++) { 1018 1030 pin->offset = elems[i] * MA35_MFP_REG_SZ_PER_BANK + MA35_MFP_REG_BASE; ··· 1021 1031 pin->muxval = elems[i + 2]; 1022 1032 pin->configs = configs; 1023 1033 pin->nconfigs = nconfigs; 1024 - grp->pins[j] = npctl->info->get_pin_num(pin->offset, pin->shift); 1034 + pins[j] = npctl->info->get_pin_num(pin->offset, pin->shift); 1025 1035 pin++; 1026 1036 } 1027 1037 return 0; 1028 1038 } 1029 1039 1030 - static int ma35_pinctrl_parse_functions(struct device_node *np, struct ma35_pinctrl *npctl, 1040 + static int ma35_pinctrl_parse_functions(struct fwnode_handle *fwnode, struct ma35_pinctrl *npctl, 1031 1041 u32 index) 1032 1042 { 1033 - struct device_node *child; 1034 - struct ma35_pin_func *func; 1035 - struct ma35_pin_group *grp; 1043 + struct device_node *np = to_of_node(fwnode); 1044 + struct fwnode_handle *child; 1045 + struct pinfunction *func; 1046 + struct group_desc *grp; 1036 1047 static u32 grp_index; 1048 + const char **groups; 1037 1049 u32 ret, i = 0; 1038 1050 1039 1051 dev_dbg(npctl->dev, "parse function(%d): %s\n", index, np->name); ··· 1047 1055 if (func->ngroups <= 0) 1048 1056 return 0; 1049 1057 1050 - func->groups = devm_kcalloc(npctl->dev, func->ngroups, sizeof(char *), GFP_KERNEL); 1051 - if (!func->groups) 1058 + groups = devm_kcalloc(npctl->dev, func->ngroups, sizeof(*groups), GFP_KERNEL); 1059 + if (!groups) 1052 1060 return -ENOMEM; 1053 1061 1054 - for_each_child_of_node(np, child) { 1055 - func->groups[i] = child->name; 1062 + fwnode_for_each_child_node(fwnode, child) { 1063 + struct device_node *node = to_of_node(child); 1064 + 1065 + groups[i] = node->name; 1056 1066 grp = &npctl->groups[grp_index++]; 1057 1067 ret = ma35_pinctrl_parse_groups(child, grp, npctl, i++); 1058 1068 if (ret) { 1059 - of_node_put(child); 1069 + fwnode_handle_put(child); 1060 1070 return ret; 1061 1071 } 1062 1072 } 1073 + 1074 + func->groups = groups; 1063 1075 return 0; 1064 1076 } 1065 1077 1066 1078 static int ma35_pinctrl_probe_dt(struct platform_device *pdev, struct ma35_pinctrl *npctl) 1067 1079 { 1080 + struct device *dev = &pdev->dev; 1068 1081 struct fwnode_handle *child; 1069 1082 u32 idx = 0; 1070 1083 int ret; 1071 1084 1072 - device_for_each_child_node(&pdev->dev, child) { 1073 - if (fwnode_property_present(child, "gpio-controller")) 1074 - continue; 1085 + for_each_gpiochip_node(dev, child) { 1075 1086 npctl->nfunctions++; 1076 1087 npctl->ngroups += of_get_child_count(to_of_node(child)); 1077 1088 } ··· 1092 1097 if (!npctl->groups) 1093 1098 return -ENOMEM; 1094 1099 1095 - device_for_each_child_node(&pdev->dev, child) { 1096 - if (fwnode_property_present(child, "gpio-controller")) 1097 - continue; 1098 - 1099 - ret = ma35_pinctrl_parse_functions(to_of_node(child), npctl, idx++); 1100 + for_each_gpiochip_node(dev, child) { 1101 + ret = ma35_pinctrl_parse_functions(child, npctl, idx++); 1100 1102 if (ret) { 1101 1103 fwnode_handle_put(child); 1102 1104 dev_err(&pdev->dev, "failed to parse function\n"); ··· 1138 1146 npctl->info = info; 1139 1147 npctl->dev = &pdev->dev; 1140 1148 1141 - npctl->regmap = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, "nuvoton,sys"); 1149 + npctl->regmap = syscon_regmap_lookup_by_phandle(dev_of_node(dev), "nuvoton,sys"); 1142 1150 if (IS_ERR(npctl->regmap)) 1143 1151 return dev_err_probe(&pdev->dev, PTR_ERR(npctl->regmap), 1144 1152 "No syscfg phandle specified\n");
-1
drivers/pinctrl/nuvoton/pinctrl-ma35d1.c
··· 9 9 #include <linux/io.h> 10 10 #include <linux/mod_devicetable.h> 11 11 #include <linux/module.h> 12 - #include <linux/of.h> 13 12 #include <linux/platform_device.h> 14 13 #include <linux/pm.h> 15 14
+8 -36
drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c
··· 7 7 #include <linux/interrupt.h> 8 8 #include <linux/irq.h> 9 9 #include <linux/mfd/syscon.h> 10 + #include <linux/mod_devicetable.h> 10 11 #include <linux/module.h> 11 - #include <linux/of.h> 12 - #include <linux/of_address.h> 13 - #include <linux/of_irq.h> 14 12 #include <linux/platform_device.h> 15 13 #include <linux/property.h> 16 14 #include <linux/regmap.h> ··· 502 504 503 505 static const int nprd_smi_pins[] = { 190 }; 504 506 505 - /* 506 - * pin: name, number 507 - * group: name, npins, pins 508 - * function: name, ngroups, groups 509 - */ 510 - struct npcm7xx_group { 511 - const char *name; 512 - const unsigned int *pins; 513 - int npins; 514 - }; 515 - 516 507 #define NPCM7XX_GRPS \ 517 508 NPCM7XX_GRP(smb0), \ 518 509 NPCM7XX_GRP(smb0b), \ ··· 629 642 #undef NPCM7XX_GRP 630 643 }; 631 644 632 - static struct npcm7xx_group npcm7xx_groups[] = { 633 - #define NPCM7XX_GRP(x) { .name = #x, .pins = x ## _pins, \ 634 - .npins = ARRAY_SIZE(x ## _pins) } 645 + static struct pingroup npcm7xx_groups[] = { 646 + #define NPCM7XX_GRP(x) PINCTRL_PINGROUP(#x, x ## _pins, ARRAY_SIZE(x ## _pins)) 635 647 NPCM7XX_GRPS 636 648 #undef NPCM7XX_GRP 637 649 }; 638 650 639 651 #define NPCM7XX_SFUNC(a) NPCM7XX_FUNC(a, #a) 640 652 #define NPCM7XX_FUNC(a, b...) static const char *a ## _grp[] = { b } 641 - #define NPCM7XX_MKFUNC(nm) { .name = #nm, .ngroups = ARRAY_SIZE(nm ## _grp), \ 642 - .groups = nm ## _grp } 643 - struct npcm7xx_func { 644 - const char *name; 645 - const unsigned int ngroups; 646 - const char *const *groups; 647 - }; 648 653 649 654 NPCM7XX_SFUNC(smb0); 650 655 NPCM7XX_SFUNC(smb0b); ··· 755 776 NPCM7XX_SFUNC(nprd_smi); 756 777 757 778 /* Function names */ 758 - static struct npcm7xx_func npcm7xx_funcs[] = { 779 + static struct pinfunction npcm7xx_funcs[] = { 780 + #define NPCM7XX_MKFUNC(nm) PINCTRL_PINFUNCTION(#nm, nm ## _grp, ARRAY_SIZE(nm ## _grp)) 759 781 NPCM7XX_MKFUNC(smb0), 760 782 NPCM7XX_MKFUNC(smb0b), 761 783 NPCM7XX_MKFUNC(smb0c), ··· 872 892 NPCM7XX_MKFUNC(lkgpo1), 873 893 NPCM7XX_MKFUNC(lkgpo2), 874 894 NPCM7XX_MKFUNC(nprd_smi), 895 + #undef NPCM7XX_MKFUNC 875 896 }; 876 897 877 898 #define NPCM7XX_PINCFG(a, b, c, d, e, f, g, h, i, j, k) \ ··· 1830 1849 static int npcm7xx_gpio_of(struct npcm7xx_pinctrl *pctrl) 1831 1850 { 1832 1851 int ret = -ENXIO; 1833 - struct resource res; 1834 1852 struct device *dev = pctrl->dev; 1835 1853 struct fwnode_reference_args args; 1836 1854 struct fwnode_handle *child; 1837 1855 int id = 0; 1838 1856 1839 1857 for_each_gpiochip_node(dev, child) { 1840 - struct device_node *np = to_of_node(child); 1841 - 1842 - ret = of_address_to_resource(np, 0, &res); 1843 - if (ret < 0) { 1844 - dev_err(dev, "Resource fail for GPIO bank %u\n", id); 1845 - return ret; 1846 - } 1847 - 1848 - pctrl->gpio_bank[id].base = ioremap(res.start, resource_size(&res)); 1858 + pctrl->gpio_bank[id].base = fwnode_iomap(child, 0); 1849 1859 if (!pctrl->gpio_bank[id].base) 1850 1860 return -EINVAL; 1851 1861 ··· 1858 1886 return ret; 1859 1887 } 1860 1888 1861 - ret = irq_of_parse_and_map(np, 0); 1889 + ret = fwnode_irq_get(child, 0); 1862 1890 if (!ret) { 1863 1891 dev_err(dev, "No IRQ for GPIO bank %u\n", id); 1864 1892 return -EINVAL;
+12 -27
drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c
··· 587 587 static const int hgpio6_pins[] = { 59 }; 588 588 static const int hgpio7_pins[] = { 60 }; 589 589 590 - /* 591 - * pin: name, number 592 - * group: name, npins, pins 593 - * function: name, ngroups, groups 594 - */ 595 - struct npcm8xx_pingroup { 596 - const char *name; 597 - const unsigned int *pins; 598 - int npins; 599 - }; 600 - 601 590 #define NPCM8XX_GRPS \ 602 591 NPCM8XX_GRP(gpi36), \ 603 592 NPCM8XX_GRP(gpi35), \ ··· 818 829 #undef NPCM8XX_GRP 819 830 }; 820 831 821 - static struct npcm8xx_pingroup npcm8xx_pingroups[] = { 822 - #define NPCM8XX_GRP(x) { .name = #x, .pins = x ## _pins, \ 823 - .npins = ARRAY_SIZE(x ## _pins) } 832 + static struct pingroup npcm8xx_pingroups[] = { 833 + #define NPCM8XX_GRP(x) PINCTRL_PINGROUP(#x, x ## _pins, ARRAY_SIZE(x ## _pins)) 824 834 NPCM8XX_GRPS 825 835 #undef NPCM8XX_GRP 826 836 }; 827 837 828 838 #define NPCM8XX_SFUNC(a) NPCM8XX_FUNC(a, #a) 829 839 #define NPCM8XX_FUNC(a, b...) static const char *a ## _grp[] = { b } 830 - #define NPCM8XX_MKFUNC(nm) { .name = #nm, .ngroups = ARRAY_SIZE(nm ## _grp), \ 831 - .groups = nm ## _grp } 832 - struct npcm8xx_func { 833 - const char *name; 834 - const unsigned int ngroups; 835 - const char *const *groups; 836 - }; 837 840 838 841 NPCM8XX_SFUNC(gpi36); 839 842 NPCM8XX_SFUNC(gpi35); ··· 1048 1067 NPCM8XX_SFUNC(hgpio7); 1049 1068 1050 1069 /* Function names */ 1051 - static struct npcm8xx_func npcm8xx_funcs[] = { 1070 + static struct pinfunction npcm8xx_funcs[] = { 1071 + #define NPCM8XX_MKFUNC(nm) PINCTRL_PINFUNCTION(#nm, nm ## _grp, ARRAY_SIZE(nm ## _grp)) 1052 1072 NPCM8XX_MKFUNC(gpi36), 1053 1073 NPCM8XX_MKFUNC(gpi35), 1054 1074 NPCM8XX_MKFUNC(tp_jtag3), ··· 1269 1287 NPCM8XX_MKFUNC(hgpio5), 1270 1288 NPCM8XX_MKFUNC(hgpio6), 1271 1289 NPCM8XX_MKFUNC(hgpio7), 1290 + #undef NPCM8XX_MKFUNC 1272 1291 }; 1273 1292 1274 1293 #define NPCM8XX_PINCFG(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q) \ 1275 - [a] { .fn0 = fn_ ## b, .reg0 = NPCM8XX_GCR_ ## c, .bit0 = d, \ 1294 + [a] = { \ 1295 + .flag = q, \ 1296 + .fn0 = fn_ ## b, .reg0 = NPCM8XX_GCR_ ## c, .bit0 = d, \ 1276 1297 .fn1 = fn_ ## e, .reg1 = NPCM8XX_GCR_ ## f, .bit1 = g, \ 1277 1298 .fn2 = fn_ ## h, .reg2 = NPCM8XX_GCR_ ## i, .bit2 = j, \ 1278 1299 .fn3 = fn_ ## k, .reg3 = NPCM8XX_GCR_ ## l, .bit3 = m, \ 1279 1300 .fn4 = fn_ ## n, .reg4 = NPCM8XX_GCR_ ## o, .bit4 = p, \ 1280 - .flag = q } 1301 + } 1281 1302 1282 1303 /* Drive strength controlled by NPCM8XX_GP_N_ODSC */ 1283 1304 #define DRIVE_STRENGTH_LO_SHIFT 8 ··· 2346 2361 return dev_err_probe(dev, ret, "gpio-ranges fail for GPIO bank %u\n", id); 2347 2362 2348 2363 ret = fwnode_irq_get(child, 0); 2349 - if (!ret) 2350 - return dev_err_probe(dev, ret, "No IRQ for GPIO bank %u\n", id); 2364 + if (ret < 0) 2365 + return dev_err_probe(dev, ret, "Failed to retrieve IRQ for bank %u\n", id); 2351 2366 2352 2367 pctrl->gpio_bank[id].irq = ret; 2353 2368 pctrl->gpio_bank[id].irq_chip = npcmgpio_irqchip; ··· 2424 2439 platform_set_drvdata(pdev, pctrl); 2425 2440 2426 2441 pctrl->gcr_regmap = 2427 - syscon_regmap_lookup_by_phandle(dev->of_node, "nuvoton,sysgcr"); 2442 + syscon_regmap_lookup_by_phandle(dev_of_node(dev), "nuvoton,sysgcr"); 2428 2443 if (IS_ERR(pctrl->gcr_regmap)) 2429 2444 return dev_err_probe(dev, PTR_ERR(pctrl->gcr_regmap), 2430 2445 "Failed to find nuvoton,sysgcr property\n");
+5 -13
drivers/pinctrl/nuvoton/pinctrl-wpcm450.c
··· 10 10 // block, shared between all GPIO banks 11 11 12 12 #include <linux/device.h> 13 - #include <linux/fwnode.h> 14 13 #include <linux/gpio/driver.h> 15 14 #include <linux/interrupt.h> 16 15 #include <linux/irq.h> ··· 17 18 #include <linux/module.h> 18 19 #include <linux/mod_devicetable.h> 19 20 #include <linux/platform_device.h> 21 + #include <linux/property.h> 20 22 #include <linux/regmap.h> 21 23 22 24 #include <linux/pinctrl/pinconf.h> ··· 482 482 483 483 #define WPCM450_SFUNC(a) WPCM450_FUNC(a, #a) 484 484 #define WPCM450_FUNC(a, b...) static const char *a ## _grp[] = { b } 485 - #define WPCM450_MKFUNC(nm) { .name = #nm, .ngroups = ARRAY_SIZE(nm ## _grp), \ 486 - .groups = nm ## _grp } 487 - struct wpcm450_func { 488 - const char *name; 489 - const unsigned int ngroups; 490 - const char *const *groups; 491 - }; 492 485 493 486 WPCM450_SFUNC(smb3); 494 487 WPCM450_SFUNC(smb4); ··· 548 555 #undef WPCM450_GRP 549 556 550 557 /* Function names */ 551 - static struct wpcm450_func wpcm450_funcs[] = { 558 + static struct pinfunction wpcm450_funcs[] = { 559 + #define WPCM450_MKFUNC(nm) PINCTRL_PINFUNCTION(#nm, nm ## _grp, ARRAY_SIZE(nm ## _grp)) 552 560 WPCM450_MKFUNC(smb3), 553 561 WPCM450_MKFUNC(smb4), 554 562 WPCM450_MKFUNC(smb5), ··· 610 616 WPCM450_MKFUNC(hg6), 611 617 WPCM450_MKFUNC(hg7), 612 618 WPCM450_MKFUNC(gpio), 619 + #undef WPCM450_MKFUNC 613 620 }; 614 621 615 622 #define WPCM450_PINCFG(a, b, c, d, e, f, g) \ ··· 1028 1033 return dev_err_probe(dev, PTR_ERR(pctrl->gpio_base), 1029 1034 "Resource fail for GPIO controller\n"); 1030 1035 1031 - device_for_each_child_node(dev, child) { 1036 + for_each_gpiochip_node(dev, child) { 1032 1037 void __iomem *dat = NULL; 1033 1038 void __iomem *set = NULL; 1034 1039 void __iomem *dirout = NULL; ··· 1038 1043 struct gpio_irq_chip *girq; 1039 1044 u32 reg; 1040 1045 int i; 1041 - 1042 - if (!fwnode_property_read_bool(child, "gpio-controller")) 1043 - continue; 1044 1046 1045 1047 ret = fwnode_property_read_u32(child, "reg", &reg); 1046 1048 if (ret < 0)
+130
drivers/pinctrl/pinconf-generic.c
··· 234 234 } 235 235 236 236 /** 237 + * pinconf_generic_parse_dt_pinmux() 238 + * parse the pinmux properties into generic pin mux values. 239 + * @np: node containing the pinmux properties 240 + * @dev: pincontrol core device 241 + * @pid: array with pin identity entries 242 + * @pmux: array with pin mux value entries 243 + * @npins: number of pins 244 + * 245 + * pinmux propertity: mux value [0,7]bits and pin identity [8,31]bits. 246 + */ 247 + int pinconf_generic_parse_dt_pinmux(struct device_node *np, struct device *dev, 248 + unsigned int **pid, unsigned int **pmux, 249 + unsigned int *npins) 250 + { 251 + unsigned int *pid_t; 252 + unsigned int *pmux_t; 253 + struct property *prop; 254 + unsigned int npins_t, i; 255 + u32 value; 256 + int ret; 257 + 258 + prop = of_find_property(np, "pinmux", NULL); 259 + if (!prop) { 260 + dev_info(dev, "Missing pinmux property\n"); 261 + return -ENOENT; 262 + } 263 + 264 + if (!pid || !pmux || !npins) { 265 + dev_err(dev, "parameters error\n"); 266 + return -EINVAL; 267 + } 268 + 269 + npins_t = prop->length / sizeof(u32); 270 + pid_t = devm_kcalloc(dev, npins_t, sizeof(*pid_t), GFP_KERNEL); 271 + pmux_t = devm_kcalloc(dev, npins_t, sizeof(*pmux_t), GFP_KERNEL); 272 + if (!pid_t || !pmux_t) { 273 + dev_err(dev, "kalloc memory fail\n"); 274 + return -ENOMEM; 275 + } 276 + for (i = 0; i < npins_t; i++) { 277 + ret = of_property_read_u32_index(np, "pinmux", i, &value); 278 + if (ret) { 279 + dev_err(dev, "get pinmux value fail\n"); 280 + goto exit; 281 + } 282 + pmux_t[i] = value & 0xff; 283 + pid_t[i] = (value >> 8) & 0xffffff; 284 + } 285 + *pid = pid_t; 286 + *pmux = pmux_t; 287 + *npins = npins_t; 288 + 289 + return 0; 290 + exit: 291 + devm_kfree(dev, pid_t); 292 + devm_kfree(dev, pmux_t); 293 + return ret; 294 + } 295 + EXPORT_SYMBOL_GPL(pinconf_generic_parse_dt_pinmux); 296 + 297 + /** 237 298 * pinconf_generic_parse_dt_config() 238 299 * parse the config properties into generic pinconfig values. 239 300 * @np: node containing the pinconfig properties ··· 355 294 return ret; 356 295 } 357 296 EXPORT_SYMBOL_GPL(pinconf_generic_parse_dt_config); 297 + 298 + int pinconf_generic_dt_node_to_map_pinmux(struct pinctrl_dev *pctldev, 299 + struct device_node *np, 300 + struct pinctrl_map **map, 301 + unsigned int *num_maps) 302 + { 303 + struct device *dev = pctldev->dev; 304 + struct device_node *pnode; 305 + unsigned long *configs = NULL; 306 + unsigned int num_configs = 0; 307 + struct property *prop; 308 + unsigned int reserved_maps; 309 + int reserve; 310 + int ret; 311 + 312 + prop = of_find_property(np, "pinmux", NULL); 313 + if (!prop) { 314 + dev_info(dev, "Missing pinmux property\n"); 315 + return -ENOENT; 316 + } 317 + 318 + pnode = of_get_parent(np); 319 + if (!pnode) { 320 + dev_info(dev, "Missing function node\n"); 321 + return -EINVAL; 322 + } 323 + 324 + reserved_maps = 0; 325 + *map = NULL; 326 + *num_maps = 0; 327 + 328 + ret = pinconf_generic_parse_dt_config(np, pctldev, &configs, 329 + &num_configs); 330 + if (ret < 0) { 331 + dev_err(dev, "%pOF: could not parse node property\n", np); 332 + return ret; 333 + } 334 + 335 + reserve = 1; 336 + if (num_configs) 337 + reserve++; 338 + 339 + ret = pinctrl_utils_reserve_map(pctldev, map, &reserved_maps, 340 + num_maps, reserve); 341 + if (ret < 0) 342 + goto exit; 343 + 344 + ret = pinctrl_utils_add_map_mux(pctldev, map, 345 + &reserved_maps, num_maps, np->name, 346 + pnode->name); 347 + if (ret < 0) 348 + goto exit; 349 + 350 + if (num_configs) { 351 + ret = pinctrl_utils_add_map_configs(pctldev, map, &reserved_maps, 352 + num_maps, np->name, configs, 353 + num_configs, PIN_MAP_TYPE_CONFIGS_GROUP); 354 + if (ret < 0) 355 + goto exit; 356 + } 357 + 358 + exit: 359 + kfree(configs); 360 + if (ret) 361 + pinctrl_utils_free_map(pctldev, *map, *num_maps); 362 + 363 + return ret; 364 + } 365 + EXPORT_SYMBOL_GPL(pinconf_generic_dt_node_to_map_pinmux); 358 366 359 367 int pinconf_generic_dt_subnode_to_map(struct pinctrl_dev *pctldev, 360 368 struct device_node *np, struct pinctrl_map **map,
+4
drivers/pinctrl/pinconf.h
··· 138 138 struct pinctrl_dev *pctldev, 139 139 unsigned long **configs, 140 140 unsigned int *nconfigs); 141 + 142 + int pinconf_generic_parse_dt_pinmux(struct device_node *np, struct device *dev, 143 + unsigned int **pid, unsigned int **pmux, 144 + unsigned int *npins); 141 145 #endif
+231
drivers/pinctrl/pinctrl-amdisp.c
··· 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 2 + /* 3 + * AMD ISP Pinctrl Driver 4 + * 5 + * Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved. 6 + * 7 + */ 8 + 9 + #include <linux/gpio/driver.h> 10 + #include <linux/module.h> 11 + #include <linux/platform_device.h> 12 + 13 + #include "pinctrl-amdisp.h" 14 + 15 + #define DRV_NAME "amdisp-pinctrl" 16 + #define GPIO_CONTROL_PIN 4 17 + #define GPIO_OFFSET_0 0x0 18 + #define GPIO_OFFSET_1 0x4 19 + #define GPIO_OFFSET_2 0x50 20 + 21 + static const u32 gpio_offset[] = { 22 + GPIO_OFFSET_0, 23 + GPIO_OFFSET_1, 24 + GPIO_OFFSET_2 25 + }; 26 + 27 + struct amdisp_pinctrl_data { 28 + const struct pinctrl_pin_desc *pins; 29 + unsigned int npins; 30 + const struct amdisp_function *functions; 31 + unsigned int nfunctions; 32 + const struct amdisp_pingroup *groups; 33 + unsigned int ngroups; 34 + }; 35 + 36 + static const struct amdisp_pinctrl_data amdisp_pinctrl_data = { 37 + .pins = amdisp_pins, 38 + .npins = ARRAY_SIZE(amdisp_pins), 39 + .functions = amdisp_functions, 40 + .nfunctions = ARRAY_SIZE(amdisp_functions), 41 + .groups = amdisp_groups, 42 + .ngroups = ARRAY_SIZE(amdisp_groups), 43 + }; 44 + 45 + struct amdisp_pinctrl { 46 + struct device *dev; 47 + struct pinctrl_dev *pctrl; 48 + struct pinctrl_desc desc; 49 + struct pinctrl_gpio_range gpio_range; 50 + struct gpio_chip gc; 51 + const struct amdisp_pinctrl_data *data; 52 + void __iomem *gpiobase; 53 + raw_spinlock_t lock; 54 + }; 55 + 56 + static int amdisp_get_groups_count(struct pinctrl_dev *pctldev) 57 + { 58 + struct amdisp_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); 59 + 60 + return pctrl->data->ngroups; 61 + } 62 + 63 + static const char *amdisp_get_group_name(struct pinctrl_dev *pctldev, 64 + unsigned int group) 65 + { 66 + struct amdisp_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); 67 + 68 + return pctrl->data->groups[group].name; 69 + } 70 + 71 + static int amdisp_get_group_pins(struct pinctrl_dev *pctldev, 72 + unsigned int group, 73 + const unsigned int **pins, 74 + unsigned int *num_pins) 75 + { 76 + struct amdisp_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); 77 + 78 + *pins = pctrl->data->groups[group].pins; 79 + *num_pins = pctrl->data->groups[group].npins; 80 + return 0; 81 + } 82 + 83 + const struct pinctrl_ops amdisp_pinctrl_ops = { 84 + .get_groups_count = amdisp_get_groups_count, 85 + .get_group_name = amdisp_get_group_name, 86 + .get_group_pins = amdisp_get_group_pins, 87 + }; 88 + 89 + static int amdisp_gpio_get_direction(struct gpio_chip *gc, unsigned int gpio) 90 + { 91 + /* amdisp gpio only has output mode */ 92 + return GPIO_LINE_DIRECTION_OUT; 93 + } 94 + 95 + static int amdisp_gpio_direction_input(struct gpio_chip *gc, unsigned int gpio) 96 + { 97 + return -EOPNOTSUPP; 98 + } 99 + 100 + static int amdisp_gpio_direction_output(struct gpio_chip *gc, unsigned int gpio, 101 + int value) 102 + { 103 + /* Nothing to do, amdisp gpio only has output mode */ 104 + return 0; 105 + } 106 + 107 + static int amdisp_gpio_get(struct gpio_chip *gc, unsigned int gpio) 108 + { 109 + unsigned long flags; 110 + u32 pin_reg; 111 + struct amdisp_pinctrl *pctrl = gpiochip_get_data(gc); 112 + 113 + raw_spin_lock_irqsave(&pctrl->lock, flags); 114 + pin_reg = readl(pctrl->gpiobase + gpio_offset[gpio]); 115 + raw_spin_unlock_irqrestore(&pctrl->lock, flags); 116 + 117 + return !!(pin_reg & BIT(GPIO_CONTROL_PIN)); 118 + } 119 + 120 + static void amdisp_gpio_set(struct gpio_chip *gc, unsigned int gpio, int value) 121 + { 122 + unsigned long flags; 123 + u32 pin_reg; 124 + struct amdisp_pinctrl *pctrl = gpiochip_get_data(gc); 125 + 126 + raw_spin_lock_irqsave(&pctrl->lock, flags); 127 + pin_reg = readl(pctrl->gpiobase + gpio_offset[gpio]); 128 + if (value) 129 + pin_reg |= BIT(GPIO_CONTROL_PIN); 130 + else 131 + pin_reg &= ~BIT(GPIO_CONTROL_PIN); 132 + writel(pin_reg, pctrl->gpiobase + gpio_offset[gpio]); 133 + raw_spin_unlock_irqrestore(&pctrl->lock, flags); 134 + } 135 + 136 + static int amdisp_gpiochip_add(struct platform_device *pdev, 137 + struct amdisp_pinctrl *pctrl) 138 + { 139 + struct gpio_chip *gc = &pctrl->gc; 140 + struct pinctrl_gpio_range *grange = &pctrl->gpio_range; 141 + int ret; 142 + 143 + gc->label = dev_name(pctrl->dev); 144 + gc->parent = &pdev->dev; 145 + gc->names = amdisp_range_pins_name; 146 + gc->request = gpiochip_generic_request; 147 + gc->free = gpiochip_generic_free; 148 + gc->get_direction = amdisp_gpio_get_direction; 149 + gc->direction_input = amdisp_gpio_direction_input; 150 + gc->direction_output = amdisp_gpio_direction_output; 151 + gc->get = amdisp_gpio_get; 152 + gc->set = amdisp_gpio_set; 153 + gc->base = -1; 154 + gc->ngpio = ARRAY_SIZE(amdisp_range_pins); 155 + 156 + grange->id = 0; 157 + grange->pin_base = 0; 158 + grange->base = 0; 159 + grange->pins = amdisp_range_pins; 160 + grange->npins = ARRAY_SIZE(amdisp_range_pins); 161 + grange->name = gc->label; 162 + grange->gc = gc; 163 + 164 + ret = devm_gpiochip_add_data(&pdev->dev, gc, pctrl); 165 + if (ret) 166 + return ret; 167 + 168 + pinctrl_add_gpio_range(pctrl->pctrl, grange); 169 + 170 + return 0; 171 + } 172 + 173 + static int amdisp_pinctrl_probe(struct platform_device *pdev) 174 + { 175 + struct amdisp_pinctrl *pctrl; 176 + struct resource *res; 177 + int ret; 178 + 179 + pctrl = devm_kzalloc(&pdev->dev, sizeof(*pctrl), GFP_KERNEL); 180 + if (!pctrl) 181 + return -ENOMEM; 182 + 183 + pdev->dev.init_name = DRV_NAME; 184 + 185 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 186 + if (!res) 187 + return -EINVAL; 188 + 189 + pctrl->gpiobase = devm_ioremap_resource(&pdev->dev, res); 190 + if (IS_ERR(pctrl->gpiobase)) 191 + return PTR_ERR(pctrl->gpiobase); 192 + 193 + platform_set_drvdata(pdev, pctrl); 194 + 195 + pctrl->dev = &pdev->dev; 196 + pctrl->data = &amdisp_pinctrl_data; 197 + pctrl->desc.owner = THIS_MODULE; 198 + pctrl->desc.pctlops = &amdisp_pinctrl_ops; 199 + pctrl->desc.pmxops = NULL; 200 + pctrl->desc.name = dev_name(&pdev->dev); 201 + pctrl->desc.pins = pctrl->data->pins; 202 + pctrl->desc.npins = pctrl->data->npins; 203 + ret = devm_pinctrl_register_and_init(&pdev->dev, &pctrl->desc, 204 + pctrl, &pctrl->pctrl); 205 + if (ret) 206 + return ret; 207 + 208 + ret = pinctrl_enable(pctrl->pctrl); 209 + if (ret) 210 + return ret; 211 + 212 + ret = amdisp_gpiochip_add(pdev, pctrl); 213 + if (ret) 214 + return ret; 215 + 216 + return 0; 217 + } 218 + 219 + static struct platform_driver amdisp_pinctrl_driver = { 220 + .driver = { 221 + .name = DRV_NAME, 222 + }, 223 + .probe = amdisp_pinctrl_probe, 224 + }; 225 + module_platform_driver(amdisp_pinctrl_driver); 226 + 227 + MODULE_AUTHOR("Benjamin Chan <benjamin.chan@amd.com>"); 228 + MODULE_AUTHOR("Pratap Nirujogi <pratap.nirujogi@amd.com>"); 229 + MODULE_DESCRIPTION("AMDISP pinctrl driver"); 230 + MODULE_LICENSE("GPL v2"); 231 + MODULE_ALIAS("platform:" DRV_NAME);
+95
drivers/pinctrl/pinctrl-amdisp.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 2 + /* 3 + * AMD ISP Pinctrl Driver 4 + * 5 + * Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved. 6 + * 7 + */ 8 + 9 + static const struct pinctrl_pin_desc amdisp_pins[] = { 10 + PINCTRL_PIN(0, "GPIO_0"), /* sensor0 control */ 11 + PINCTRL_PIN(1, "GPIO_1"), /* sensor1 control */ 12 + PINCTRL_PIN(2, "GPIO_2"), /* sensor2 control */ 13 + }; 14 + 15 + #define AMDISP_GPIO_PINS(pin) \ 16 + static const unsigned int gpio##pin##_pins[] = { pin } 17 + AMDISP_GPIO_PINS(0); 18 + AMDISP_GPIO_PINS(1); 19 + AMDISP_GPIO_PINS(2); 20 + 21 + static const unsigned int amdisp_range_pins[] = { 22 + 0, 1, 2 23 + }; 24 + 25 + static const char * const amdisp_range_pins_name[] = { 26 + "gpio0", "gpio1", "gpio2" 27 + }; 28 + 29 + enum amdisp_functions { 30 + mux_gpio, 31 + mux_NA 32 + }; 33 + 34 + static const char * const gpio_groups[] = { 35 + "gpio0", "gpio1", "gpio2" 36 + }; 37 + 38 + /** 39 + * struct amdisp_function - a pinmux function 40 + * @name: Name of the pinmux function. 41 + * @groups: List of pingroups for this function. 42 + * @ngroups: Number of entries in @groups. 43 + */ 44 + struct amdisp_function { 45 + const char *name; 46 + const char * const *groups; 47 + unsigned int ngroups; 48 + }; 49 + 50 + #define FUNCTION(fname) \ 51 + [mux_##fname] = { \ 52 + .name = #fname, \ 53 + .groups = fname##_groups, \ 54 + .ngroups = ARRAY_SIZE(fname##_groups), \ 55 + } 56 + 57 + static const struct amdisp_function amdisp_functions[] = { 58 + FUNCTION(gpio), 59 + }; 60 + 61 + /** 62 + * struct amdisp_pingroup - a pinmux group 63 + * @name: Name of the pinmux group. 64 + * @pins: List of pins for this group. 65 + * @npins: Number of entries in @pins. 66 + * @funcs: List of functions belongs to this group. 67 + * @nfuncs: Number of entries in @funcs. 68 + * @offset: Group offset in amdisp pinmux groups. 69 + */ 70 + struct amdisp_pingroup { 71 + const char *name; 72 + const unsigned int *pins; 73 + unsigned int npins; 74 + unsigned int *funcs; 75 + unsigned int nfuncs; 76 + unsigned int offset; 77 + }; 78 + 79 + #define PINGROUP(id, f0) \ 80 + { \ 81 + .name = "gpio" #id, \ 82 + .pins = gpio##id##_pins, \ 83 + .npins = ARRAY_SIZE(gpio##id##_pins), \ 84 + .funcs = (int[]){ \ 85 + mux_##f0, \ 86 + }, \ 87 + .nfuncs = 1, \ 88 + .offset = id, \ 89 + } 90 + 91 + static const struct amdisp_pingroup amdisp_groups[] = { 92 + PINGROUP(0, gpio), 93 + PINGROUP(1, gpio), 94 + PINGROUP(2, gpio), 95 + };
+88 -103
drivers/pinctrl/pinctrl-cy8c95x0.c
··· 40 40 41 41 /* Port Select configures the port */ 42 42 #define CY8C95X0_PORTSEL 0x18 43 + 43 44 /* Port settings, write PORTSEL first */ 44 45 #define CY8C95X0_INTMASK 0x19 45 46 #define CY8C95X0_SELPWM 0x1A ··· 54 53 #define CY8C95X0_DRV_PP_FAST 0x21 55 54 #define CY8C95X0_DRV_PP_SLOW 0x22 56 55 #define CY8C95X0_DRV_HIZ 0x23 56 + 57 + /* Internal device configuration */ 58 + #define CY8C95X0_ENABLE_WDE 0x2D 57 59 #define CY8C95X0_DEVID 0x2E 58 60 #define CY8C95X0_WATCHDOG 0x2F 59 61 #define CY8C95X0_COMMAND 0x30 ··· 141 137 * @irq_trig_low: I/O bits affected by a low voltage level 142 138 * @irq_trig_high: I/O bits affected by a high voltage level 143 139 * @push_pull: I/O bits configured as push pull driver 144 - * @shiftmask: Mask used to compensate for Gport2 width 140 + * @map: Mask used to compensate for Gport2 width 145 141 * @nport: Number of Gports in this chip 146 142 * @gpio_chip: gpiolib chip 147 143 * @driver_data: private driver data ··· 162 158 DECLARE_BITMAP(irq_trig_low, MAX_LINE); 163 159 DECLARE_BITMAP(irq_trig_high, MAX_LINE); 164 160 DECLARE_BITMAP(push_pull, MAX_LINE); 165 - DECLARE_BITMAP(shiftmask, MAX_LINE); 161 + DECLARE_BITMAP(map, MAX_LINE); 166 162 unsigned int nport; 167 163 struct gpio_chip gpio_chip; 168 164 unsigned long driver_data; ··· 313 309 "gp76", 314 310 "gp77", 315 311 }; 316 - 317 - static int cy8c95x0_pinmux_direction(struct cy8c95x0_pinctrl *chip, 318 - unsigned int pin, bool input); 319 312 320 313 static inline u8 cypress_get_port(struct cy8c95x0_pinctrl *chip, unsigned int pin) 321 314 { ··· 478 477 #endif 479 478 }; 480 479 481 - static inline int cy8c95x0_regmap_update_bits_base(struct cy8c95x0_pinctrl *chip, 482 - unsigned int reg, 483 - unsigned int port, 484 - unsigned int mask, 485 - unsigned int val, 486 - bool *change, bool async, 487 - bool force) 480 + /* Caller should never modify PORTSEL directly */ 481 + static int cy8c95x0_regmap_update_bits_base(struct cy8c95x0_pinctrl *chip, 482 + unsigned int reg, unsigned int port, 483 + unsigned int mask, unsigned int val, 484 + bool *change, bool async, bool force) 488 485 { 489 486 int ret, off, i; 490 - 491 - /* Caller should never modify PORTSEL directly */ 492 - if (reg == CY8C95X0_PORTSEL) 493 - return -EINVAL; 494 487 495 488 /* Registers behind the PORTSEL mux have their own range in regmap */ 496 489 if (cy8c95x0_muxed_register(reg)) { ··· 502 507 if (ret < 0) 503 508 return ret; 504 509 505 - /* Mimic what hardware does and update the cache when a WC bit is written. 510 + /* 511 + * Mimic what hardware does and update the cache when a WC bit is written. 506 512 * Allows to mark the registers as non-volatile and reduces I/O cycles. 507 513 */ 508 514 if (cy8c95x0_wc_register(reg) && (mask & val)) { ··· 519 523 regcache_cache_only(chip->regmap, false); 520 524 } 521 525 522 - return ret; 526 + return 0; 523 527 } 524 528 525 529 /** ··· 571 575 } 572 576 573 577 /** 574 - * cy8c95x0_regmap_read() - reads a register using the regmap cache 578 + * cy8c95x0_regmap_read_bits() - reads a register using the regmap cache 575 579 * @chip: The pinctrl to work on 576 580 * @reg: The register to read from. Can be direct access or muxed register. 577 581 * @port: The port to be used for muxed registers or quick path direct access 578 582 * registers. Otherwise unused. 579 - * @read_val: Value read from hardware or cache 583 + * @mask: Bitmask to apply 584 + * @val: Value read from hardware or cache 580 585 * 581 586 * This function handles the register reads from the direct access registers and 582 587 * the muxed registers while caching all register accesses, internally handling ··· 587 590 * 588 591 * Return: 0 for successful request, else a corresponding error value 589 592 */ 590 - static int cy8c95x0_regmap_read(struct cy8c95x0_pinctrl *chip, unsigned int reg, 591 - unsigned int port, unsigned int *read_val) 593 + static int cy8c95x0_regmap_read_bits(struct cy8c95x0_pinctrl *chip, unsigned int reg, 594 + unsigned int port, unsigned int mask, unsigned int *val) 592 595 { 593 - int off, ret; 596 + unsigned int off; 597 + unsigned int tmp; 598 + int ret; 594 599 595 600 /* Registers behind the PORTSEL mux have their own range in regmap */ 596 601 if (cy8c95x0_muxed_register(reg)) { ··· 604 605 else 605 606 off = reg; 606 607 } 607 - guard(mutex)(&chip->i2c_lock); 608 608 609 - ret = regmap_read(chip->regmap, off, read_val); 609 + scoped_guard(mutex, &chip->i2c_lock) 610 + ret = regmap_read(chip->regmap, off, &tmp); 611 + if (ret) 612 + return ret; 610 613 611 - return ret; 614 + *val = tmp & mask; 615 + return 0; 612 616 } 613 617 614 618 static int cy8c95x0_write_regs_mask(struct cy8c95x0_pinctrl *chip, int reg, ··· 619 617 { 620 618 DECLARE_BITMAP(tmask, MAX_LINE); 621 619 DECLARE_BITMAP(tval, MAX_LINE); 620 + unsigned long bits, offset; 622 621 int write_val; 623 - u8 bits; 624 622 int ret; 625 623 626 624 /* Add the 4 bit gap of Gport2 */ 627 - bitmap_andnot(tmask, mask, chip->shiftmask, MAX_LINE); 628 - bitmap_shift_left(tmask, tmask, 4, MAX_LINE); 629 - bitmap_replace(tmask, tmask, mask, chip->shiftmask, BANK_SZ * 3); 625 + bitmap_scatter(tmask, mask, chip->map, MAX_LINE); 626 + bitmap_scatter(tval, val, chip->map, MAX_LINE); 630 627 631 - bitmap_andnot(tval, val, chip->shiftmask, MAX_LINE); 632 - bitmap_shift_left(tval, tval, 4, MAX_LINE); 633 - bitmap_replace(tval, tval, val, chip->shiftmask, BANK_SZ * 3); 628 + for_each_set_clump8(offset, bits, tmask, chip->tpin) { 629 + unsigned int i = offset / 8; 634 630 635 - for (unsigned int i = 0; i < chip->nport; i++) { 636 - /* Skip over unused banks */ 637 - bits = bitmap_get_value8(tmask, i * BANK_SZ); 638 - if (!bits) 639 - continue; 640 - 641 - write_val = bitmap_get_value8(tval, i * BANK_SZ); 631 + write_val = bitmap_get_value8(tval, offset); 642 632 643 633 ret = cy8c95x0_regmap_update_bits(chip, reg, i, bits, write_val); 644 634 if (ret < 0) { ··· 647 653 { 648 654 DECLARE_BITMAP(tmask, MAX_LINE); 649 655 DECLARE_BITMAP(tval, MAX_LINE); 650 - DECLARE_BITMAP(tmp, MAX_LINE); 651 - int read_val; 652 - u8 bits; 656 + unsigned long bits, offset; 657 + unsigned int read_val; 653 658 int ret; 654 659 655 660 /* Add the 4 bit gap of Gport2 */ 656 - bitmap_andnot(tmask, mask, chip->shiftmask, MAX_LINE); 657 - bitmap_shift_left(tmask, tmask, 4, MAX_LINE); 658 - bitmap_replace(tmask, tmask, mask, chip->shiftmask, BANK_SZ * 3); 661 + bitmap_scatter(tmask, mask, chip->map, MAX_LINE); 662 + bitmap_scatter(tval, val, chip->map, MAX_LINE); 659 663 660 - bitmap_andnot(tval, val, chip->shiftmask, MAX_LINE); 661 - bitmap_shift_left(tval, tval, 4, MAX_LINE); 662 - bitmap_replace(tval, tval, val, chip->shiftmask, BANK_SZ * 3); 664 + for_each_set_clump8(offset, bits, tmask, chip->tpin) { 665 + unsigned int i = offset / 8; 663 666 664 - for (unsigned int i = 0; i < chip->nport; i++) { 665 - /* Skip over unused banks */ 666 - bits = bitmap_get_value8(tmask, i * BANK_SZ); 667 - if (!bits) 668 - continue; 669 - 670 - ret = cy8c95x0_regmap_read(chip, reg, i, &read_val); 667 + ret = cy8c95x0_regmap_read_bits(chip, reg, i, bits, &read_val); 671 668 if (ret < 0) { 672 669 dev_err(chip->dev, "failed reading register %d, port %u: err %d\n", reg, i, ret); 673 670 return ret; 674 671 } 675 672 676 - read_val &= bits; 677 - read_val |= bitmap_get_value8(tval, i * BANK_SZ) & ~bits; 678 - bitmap_set_value8(tval, read_val, i * BANK_SZ); 673 + read_val |= bitmap_get_value8(tval, offset) & ~bits; 674 + bitmap_set_value8(tval, read_val, offset); 679 675 } 680 676 681 677 /* Fill the 4 bit gap of Gport2 */ 682 - bitmap_shift_right(tmp, tval, 4, MAX_LINE); 683 - bitmap_replace(val, tmp, tval, chip->shiftmask, MAX_LINE); 678 + bitmap_gather(val, tval, chip->map, MAX_LINE); 679 + 680 + return 0; 681 + } 682 + 683 + static int cy8c95x0_pinmux_direction(struct cy8c95x0_pinctrl *chip, unsigned int pin, bool input) 684 + { 685 + u8 port = cypress_get_port(chip, pin); 686 + u8 bit = cypress_get_pin_mask(chip, pin); 687 + int ret; 688 + 689 + ret = cy8c95x0_regmap_write_bits(chip, CY8C95X0_DIRECTION, port, bit, input ? bit : 0); 690 + if (ret) 691 + return ret; 692 + 693 + /* 694 + * Disable driving the pin by forcing it to HighZ. Only setting 695 + * the direction register isn't sufficient in Push-Pull mode. 696 + */ 697 + if (input && test_bit(pin, chip->push_pull)) { 698 + ret = cy8c95x0_regmap_write_bits(chip, CY8C95X0_DRV_HIZ, port, bit, bit); 699 + if (ret) 700 + return ret; 701 + 702 + __clear_bit(pin, chip->push_pull); 703 + } 684 704 685 705 return 0; 686 706 } ··· 725 717 struct cy8c95x0_pinctrl *chip = gpiochip_get_data(gc); 726 718 u8 port = cypress_get_port(chip, off); 727 719 u8 bit = cypress_get_pin_mask(chip, off); 728 - u32 reg_val; 720 + unsigned int reg_val; 729 721 int ret; 730 722 731 - ret = cy8c95x0_regmap_read(chip, CY8C95X0_INPUT, port, &reg_val); 723 + ret = cy8c95x0_regmap_read_bits(chip, CY8C95X0_INPUT, port, bit, &reg_val); 732 724 if (ret < 0) { 733 725 /* 734 726 * NOTE: ··· 739 731 return 0; 740 732 } 741 733 742 - return !!(reg_val & bit); 734 + return reg_val ? 1 : 0; 743 735 } 744 736 745 737 static void cy8c95x0_gpio_set_value(struct gpio_chip *gc, unsigned int off, ··· 757 749 struct cy8c95x0_pinctrl *chip = gpiochip_get_data(gc); 758 750 u8 port = cypress_get_port(chip, off); 759 751 u8 bit = cypress_get_pin_mask(chip, off); 760 - u32 reg_val; 752 + unsigned int reg_val; 761 753 int ret; 762 754 763 - ret = cy8c95x0_regmap_read(chip, CY8C95X0_DIRECTION, port, &reg_val); 755 + ret = cy8c95x0_regmap_read_bits(chip, CY8C95X0_DIRECTION, port, bit, &reg_val); 764 756 if (ret < 0) 765 757 return ret; 766 758 767 - if (reg_val & bit) 759 + if (reg_val) 768 760 return GPIO_LINE_DIRECTION_IN; 769 761 770 762 return GPIO_LINE_DIRECTION_OUT; ··· 777 769 enum pin_config_param param = pinconf_to_config_param(*config); 778 770 u8 port = cypress_get_port(chip, off); 779 771 u8 bit = cypress_get_pin_mask(chip, off); 772 + unsigned int reg_val; 780 773 unsigned int reg; 781 - u32 reg_val; 782 774 u16 arg = 0; 783 775 int ret; 784 776 ··· 835 827 * Writing 1 to one of the drive mode registers will automatically 836 828 * clear conflicting set bits in the other drive mode registers. 837 829 */ 838 - ret = cy8c95x0_regmap_read(chip, reg, port, &reg_val); 830 + ret = cy8c95x0_regmap_read_bits(chip, reg, port, bit, &reg_val); 839 831 if (ret < 0) 840 832 return ret; 841 833 842 - if (reg_val & bit) 834 + if (reg_val) 843 835 arg = 1; 844 836 if (param == PIN_CONFIG_OUTPUT_ENABLE) 845 837 arg = !arg; 846 838 847 - *config = pinconf_to_config_packed(param, (u16)arg); 839 + *config = pinconf_to_config_packed(param, arg); 848 840 return 0; 849 841 } 850 842 ··· 1103 1095 if (!ret) 1104 1096 return IRQ_RETVAL(0); 1105 1097 1106 - ret = 0; 1098 + ret = false; 1107 1099 for_each_set_bit(level, pending, MAX_LINE) { 1108 1100 /* Already accounted for 4bit gap in GPort2 */ 1109 1101 nested_irq = irq_find_mapping(gc->irq.domain, level); ··· 1122 1114 else 1123 1115 handle_nested_irq(nested_irq); 1124 1116 1125 - ret = 1; 1117 + ret = true; 1126 1118 } 1127 1119 1128 1120 return IRQ_RETVAL(ret); ··· 1256 1248 return cy8c95x0_set_mode(chip, pin, false); 1257 1249 } 1258 1250 1259 - static int cy8c95x0_pinmux_direction(struct cy8c95x0_pinctrl *chip, 1260 - unsigned int pin, bool input) 1261 - { 1262 - u8 port = cypress_get_port(chip, pin); 1263 - u8 bit = cypress_get_pin_mask(chip, pin); 1264 - int ret; 1265 - 1266 - ret = cy8c95x0_regmap_write_bits(chip, CY8C95X0_DIRECTION, port, bit, input ? bit : 0); 1267 - if (ret) 1268 - return ret; 1269 - 1270 - /* 1271 - * Disable driving the pin by forcing it to HighZ. Only setting 1272 - * the direction register isn't sufficient in Push-Pull mode. 1273 - */ 1274 - if (input && test_bit(pin, chip->push_pull)) { 1275 - ret = cy8c95x0_regmap_write_bits(chip, CY8C95X0_DRV_HIZ, port, bit, bit); 1276 - if (ret) 1277 - return ret; 1278 - 1279 - __clear_bit(pin, chip->push_pull); 1280 - } 1281 - 1282 - return 0; 1283 - } 1284 - 1285 1251 static int cy8c95x0_gpio_set_direction(struct pinctrl_dev *pctldev, 1286 1252 struct pinctrl_gpio_range *range, 1287 1253 unsigned int pin, bool input) ··· 1287 1305 unsigned long *configs, unsigned int num_configs) 1288 1306 { 1289 1307 struct cy8c95x0_pinctrl *chip = pinctrl_dev_get_drvdata(pctldev); 1290 - int ret = 0; 1308 + int ret; 1291 1309 int i; 1292 1310 1293 1311 for (i = 0; i < num_configs; i++) { ··· 1296 1314 return ret; 1297 1315 } 1298 1316 1299 - return ret; 1317 + return 0; 1300 1318 } 1301 1319 1302 1320 static const struct pinconf_ops cy8c95x0_pinconf_ops = { ··· 1468 1486 return PTR_ERR(chip->regmap); 1469 1487 1470 1488 bitmap_zero(chip->push_pull, MAX_LINE); 1471 - bitmap_zero(chip->shiftmask, MAX_LINE); 1472 - bitmap_set(chip->shiftmask, 0, 20); 1489 + 1490 + /* Setup HW pins mapping */ 1491 + bitmap_fill(chip->map, MAX_LINE); 1492 + bitmap_clear(chip->map, 20, 4); 1493 + 1473 1494 mutex_init(&chip->i2c_lock); 1474 1495 1475 1496 if (dmi_first_match(cy8c95x0_dmi_acpi_irq_info)) {
+260 -2
drivers/pinctrl/pinctrl-ingenic.c
··· 3 3 * Ingenic SoCs pinctrl driver 4 4 * 5 5 * Copyright (c) 2017 Paul Cercueil <paul@crapouillou.net> 6 - * Copyright (c) 2017, 2019 Paul Boddie <paul@boddie.org.uk> 6 + * Copyright (c) 2017, 2019, 2020, 2023 Paul Boddie <paul@boddie.org.uk> 7 7 * Copyright (c) 2019, 2020 周琰杰 (Zhou Yanjie) <zhouyanjie@wanyeetech.com> 8 8 */ 9 9 ··· 57 57 #define JZ4770_GPIO_PAT0 0x40 58 58 #define JZ4770_GPIO_FLAG 0x50 59 59 #define JZ4770_GPIO_PEN 0x70 60 + 61 + #define X1600_GPIO_PU 0x80 60 62 61 63 #define X1830_GPIO_PEL 0x110 62 64 #define X1830_GPIO_PEH 0x120 ··· 114 112 ID_JZ4780, 115 113 ID_X1000, 116 114 ID_X1500, 115 + ID_X1600, 117 116 ID_X1830, 118 117 ID_X2000, 119 118 ID_X2100, ··· 165 162 IS_ENABLED(CONFIG_MACH_JZ4780) << ID_JZ4780 | 166 163 IS_ENABLED(CONFIG_MACH_X1000) << ID_X1000 | 167 164 IS_ENABLED(CONFIG_MACH_X1500) << ID_X1500 | 165 + IS_ENABLED(CONFIG_MACH_X1600) << ID_X1600 | 168 166 IS_ENABLED(CONFIG_MACH_X1830) << ID_X1830 | 169 167 IS_ENABLED(CONFIG_MACH_X2000) << ID_X2000 | 170 168 IS_ENABLED(CONFIG_MACH_X2100) << ID_X2100; ··· 210 206 static int jz4730_pwm_pwm0_pins[] = { 0x5e, }; 211 207 static int jz4730_pwm_pwm1_pins[] = { 0x5f, }; 212 208 209 + static int jz4730_mii_pins[] = { 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 210 + 0x77, 0x78, 0x19, 0x7a, 0x1b, 0x7c, }; 211 + 212 + static int jz4730_i2s_mclk_pins[] = { 0x44, }; 213 + static int jz4730_i2s_acreset_pins[] = { 0x45, }; 214 + static int jz4730_i2s_data_pins[] = { 0x46, 0x47, }; 215 + static int jz4730_i2s_clock_pins[] = { 0x4d, 0x4e, }; 216 + 213 217 static u8 jz4730_lcd_8bit_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, }; 214 218 215 219 static const struct group_desc jz4730_groups[] = { ··· 239 227 INGENIC_PIN_GROUP("nand-cs5", jz4730_nand_cs5, 1), 240 228 INGENIC_PIN_GROUP("pwm0", jz4730_pwm_pwm0, 1), 241 229 INGENIC_PIN_GROUP("pwm1", jz4730_pwm_pwm1, 1), 230 + INGENIC_PIN_GROUP("mii", jz4730_mii, 1), 231 + INGENIC_PIN_GROUP("i2s-mclk-out", jz4730_i2s_mclk, 1), 232 + INGENIC_PIN_GROUP("i2s-acreset", jz4730_i2s_acreset, 1), 233 + INGENIC_PIN_GROUP("i2s-data", jz4730_i2s_data, 1), 234 + INGENIC_PIN_GROUP("i2s-master", jz4730_i2s_clock, 1), 235 + INGENIC_PIN_GROUP("i2s-slave", jz4730_i2s_clock, 2), 242 236 }; 243 237 244 238 static const char *jz4730_mmc_groups[] = { "mmc-1bit", "mmc-4bit", }; ··· 260 242 }; 261 243 static const char *jz4730_pwm0_groups[] = { "pwm0", }; 262 244 static const char *jz4730_pwm1_groups[] = { "pwm1", }; 245 + static const char *jz4730_mii_groups[] = { "mii", }; 246 + static const char *jz4730_i2s_groups[] = { "i2s-data", "i2s-master", "i2s-slave", }; 263 247 264 248 static const struct function_desc jz4730_functions[] = { 265 249 INGENIC_PIN_FUNCTION("mmc", jz4730_mmc), ··· 273 253 INGENIC_PIN_FUNCTION("nand", jz4730_nand), 274 254 INGENIC_PIN_FUNCTION("pwm0", jz4730_pwm0), 275 255 INGENIC_PIN_FUNCTION("pwm1", jz4730_pwm1), 256 + INGENIC_PIN_FUNCTION("mii", jz4730_mii), 257 + INGENIC_PIN_FUNCTION("i2s", jz4730_i2s), 276 258 }; 277 259 278 260 static const struct ingenic_chip_info jz4730_chip_info = { ··· 2373 2351 .access_table = &x1000_access_table, 2374 2352 }; 2375 2353 2354 + static const u32 x1600_pull_ups[4] = { 2355 + 0xffffffff, 0xdffbf7bf, 0x987e0000, 0x0000003f, 2356 + }; 2357 + 2358 + static const u32 x1600_pull_downs[4] = { 2359 + 0x00000000, 0x00000000, 0x07000007, 0x00000000, 2360 + }; 2361 + 2362 + static int x1600_uart0_data_pins[] = { 0x27, 0x28, }; 2363 + static int x1600_uart0_hwflow_pins[] = { 0x29, 0x2a, }; 2364 + static int x1600_uart1_data_pins[] = { 0x23, 0x22, }; 2365 + static int x1600_uart1_hwflow_pins[] = { 0x25, 0x24, }; 2366 + static int x1600_uart2_data_a_pins[] = { 0x1f, 0x1e, }; 2367 + static int x1600_uart2_data_b_pins[] = { 0x21, 0x20, }; 2368 + static int x1600_uart3_data_b_pins[] = { 0x25, 0x24, }; 2369 + static int x1600_uart3_data_d_pins[] = { 0x65, 0x64, }; 2370 + static int x1600_sfc_pins[] = { 0x53, 0x54, 0x55, 0x56, 0x51, 0x52, 0x24, }; 2371 + static int x1600_ssi_dt_a_pins[] = { 0x1e, }; 2372 + static int x1600_ssi_dt_b_pins[] = { 0x2d, }; 2373 + static int x1600_ssi_dr_a_pins[] = { 0x1d, }; 2374 + static int x1600_ssi_dr_b_pins[] = { 0x2e, }; 2375 + static int x1600_ssi_clk_a_pins[] = { 0x1f, }; 2376 + static int x1600_ssi_clk_b_pins[] = { 0x2c, }; 2377 + static int x1600_ssi_ce0_a_pins[] = { 0x1c, }; 2378 + static int x1600_ssi_ce0_b_pins[] = { 0x31, }; 2379 + static int x1600_ssi_ce1_a_pins[] = { 0x22, }; 2380 + static int x1600_ssi_ce1_b_pins[] = { 0x30, }; 2381 + static int x1600_mmc0_1bit_b_pins[] = { 0x2c, 0x2d, 0x2e, }; 2382 + static int x1600_mmc0_4bit_b_pins[] = { 0x2f, 0x30, 0x31, }; 2383 + static int x1600_mmc0_1bit_c_pins[] = { 0x51, 0x53, 0x54, }; 2384 + static int x1600_mmc0_4bit_c_pins[] = { 0x56, 0x55, 0x52, }; 2385 + static int x1600_mmc1_1bit_pins[] = { 0x60, 0x61, 0x62, }; 2386 + static int x1600_mmc1_4bit_pins[] = { 0x63, 0x64, 0x65, }; 2387 + static int x1600_i2c0_a_pins[] = { 0x1d, 0x1c, }; 2388 + static int x1600_i2c0_b_pins[] = { 0x3f, 0x3e, }; 2389 + static int x1600_i2c1_b_15_pins[] = { 0x30, 0x2f, }; 2390 + static int x1600_i2c1_b_19_pins[] = { 0x34, 0x33, }; 2391 + static int x1600_i2s_data_tx_pins[] = { 0x39, }; 2392 + static int x1600_i2s_data_rx_pins[] = { 0x35, }; 2393 + static int x1600_i2s_clk_rx_pins[] = { 0x37, 0x38, }; 2394 + static int x1600_i2s_clk_tx_pins[] = { 0x3b, 0x3c, }; 2395 + static int x1600_i2s_sysclk_pins[] = { 0x36, 0x3a, }; 2396 + 2397 + static int x1600_cim_pins[] = { 2398 + 0x14, 0x16, 0x15, 0x18, 0x13, 2399 + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 2400 + }; 2401 + 2402 + static int x1600_slcd_8bit_pins[] = { 2403 + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 2404 + 0x17, 0x19, 0x1a, 0x1b, 2405 + }; 2406 + 2407 + static int x1600_slcd_16bit_pins[] = { 2408 + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 2409 + }; 2410 + 2411 + static int x1600_lcd_16bit_pins[] = { 2412 + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 2413 + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 2414 + 0x18, 0x19, 0x1a, 0x1b, 2415 + }; 2416 + 2417 + static int x1600_lcd_18bit_pins[] = { 2418 + 0x10, 0x11, 2419 + }; 2420 + 2421 + static int x1600_lcd_24bit_pins[] = { 2422 + 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 2423 + }; 2424 + 2425 + static int x1600_pwm_pwm0_pins[] = { 0x40, }; 2426 + static int x1600_pwm_pwm1_pins[] = { 0x41, }; 2427 + static int x1600_pwm_pwm2_pins[] = { 0x42, }; 2428 + static int x1600_pwm_pwm3_pins[] = { 0x58, }; 2429 + static int x1600_pwm_pwm4_pins[] = { 0x59, }; 2430 + static int x1600_pwm_pwm5_b_pins[] = { 0x33, }; 2431 + static int x1600_pwm_pwm5_c_pins[] = { 0x5a, }; 2432 + static int x1600_pwm_pwm6_b9_pins[] = { 0x29, }; 2433 + static int x1600_pwm_pwm6_b20_pins[] = { 0x34, }; 2434 + static int x1600_pwm_pwm7_b10_pins[] = { 0x2a, }; 2435 + static int x1600_pwm_pwm7_b21_pins[] = { 0x35, }; 2436 + 2437 + static int x1600_mac_pins[] = { 2438 + 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 2439 + }; 2440 + 2441 + static int x1600_sfc_funcs[] = { 0, 0, 0, 0, 0, 0, 2, }; 2442 + 2443 + static const struct group_desc x1600_groups[] = { 2444 + INGENIC_PIN_GROUP("uart0-data", x1600_uart0_data, 0), 2445 + INGENIC_PIN_GROUP("uart0-hwflow", x1600_uart0_hwflow, 0), 2446 + INGENIC_PIN_GROUP("uart1-data", x1600_uart1_data, 1), 2447 + INGENIC_PIN_GROUP("uart1-hwflow", x1600_uart1_hwflow, 1), 2448 + INGENIC_PIN_GROUP("uart2-data-a", x1600_uart2_data_a, 2), 2449 + INGENIC_PIN_GROUP("uart2-data-b", x1600_uart2_data_b, 1), 2450 + INGENIC_PIN_GROUP("uart3-data-b", x1600_uart3_data_b, 0), 2451 + INGENIC_PIN_GROUP("uart3-data-d", x1600_uart3_data_d, 2), 2452 + INGENIC_PIN_GROUP_FUNCS("sfc", x1600_sfc, x1600_sfc_funcs), 2453 + INGENIC_PIN_GROUP("ssi-dt-a", x1600_ssi_dt_a, 0), 2454 + INGENIC_PIN_GROUP("ssi-dt-b", x1600_ssi_dt_b, 1), 2455 + INGENIC_PIN_GROUP("ssi-dr-a", x1600_ssi_dr_a, 0), 2456 + INGENIC_PIN_GROUP("ssi-dr-b", x1600_ssi_dr_b, 1), 2457 + INGENIC_PIN_GROUP("ssi-clk-a", x1600_ssi_clk_a, 0), 2458 + INGENIC_PIN_GROUP("ssi-clk-b", x1600_ssi_clk_b, 1), 2459 + INGENIC_PIN_GROUP("ssi-ce0-a", x1600_ssi_ce0_a, 0), 2460 + INGENIC_PIN_GROUP("ssi-ce0-b", x1600_ssi_ce0_b, 1), 2461 + INGENIC_PIN_GROUP("ssi-ce1-a", x1600_ssi_ce1_a, 2), 2462 + INGENIC_PIN_GROUP("ssi-ce1-b", x1600_ssi_ce1_b, 1), 2463 + INGENIC_PIN_GROUP("mmc0-1bit-b", x1600_mmc0_1bit_b, 0), 2464 + INGENIC_PIN_GROUP("mmc0-4bit-b", x1600_mmc0_4bit_b, 0), 2465 + INGENIC_PIN_GROUP("mmc0-1bit-c", x1600_mmc0_1bit_c, 1), 2466 + INGENIC_PIN_GROUP("mmc0-4bit-c", x1600_mmc0_4bit_c, 1), 2467 + INGENIC_PIN_GROUP("mmc1-1bit", x1600_mmc1_1bit, 0), 2468 + INGENIC_PIN_GROUP("mmc1-4bit", x1600_mmc1_4bit, 0), 2469 + INGENIC_PIN_GROUP("i2c0-data-a", x1600_i2c0_a, 2), 2470 + INGENIC_PIN_GROUP("i2c0-data-b", x1600_i2c0_b, 0), 2471 + INGENIC_PIN_GROUP("i2c1-data-b-15", x1600_i2c1_b_15, 2), 2472 + INGENIC_PIN_GROUP("i2c1-data-b-19", x1600_i2c1_b_19, 0), 2473 + INGENIC_PIN_GROUP("i2s-data-tx", x1600_i2s_data_tx, 0), 2474 + INGENIC_PIN_GROUP("i2s-data-rx", x1600_i2s_data_rx, 0), 2475 + INGENIC_PIN_GROUP("i2s-clk-rx", x1600_i2s_clk_rx, 0), 2476 + INGENIC_PIN_GROUP("i2s-clk-tx", x1600_i2s_clk_tx, 0), 2477 + INGENIC_PIN_GROUP("i2s-sysclk", x1600_i2s_sysclk, 0), 2478 + INGENIC_PIN_GROUP("cim-data", x1600_cim, 2), 2479 + INGENIC_PIN_GROUP("slcd-8bit", x1600_slcd_8bit, 1), 2480 + INGENIC_PIN_GROUP("slcd-16bit", x1600_slcd_16bit, 1), 2481 + INGENIC_PIN_GROUP("lcd-16bit", x1600_lcd_16bit, 0), 2482 + INGENIC_PIN_GROUP("lcd-18bit", x1600_lcd_18bit, 0), 2483 + INGENIC_PIN_GROUP("lcd-24bit", x1600_lcd_24bit, 0), 2484 + INGENIC_PIN_GROUP("pwm0", x1600_pwm_pwm0, 0), 2485 + INGENIC_PIN_GROUP("pwm1", x1600_pwm_pwm1, 0), 2486 + INGENIC_PIN_GROUP("pwm2", x1600_pwm_pwm2, 0), 2487 + INGENIC_PIN_GROUP("pwm3", x1600_pwm_pwm3, 1), 2488 + INGENIC_PIN_GROUP("pwm4", x1600_pwm_pwm4, 1), 2489 + INGENIC_PIN_GROUP("pwm5-b", x1600_pwm_pwm5_b, 2), 2490 + INGENIC_PIN_GROUP("pwm5-c", x1600_pwm_pwm5_c, 1), 2491 + INGENIC_PIN_GROUP("pwm6-b9", x1600_pwm_pwm6_b9, 1), 2492 + INGENIC_PIN_GROUP("pwm6-b20", x1600_pwm_pwm6_b20, 2), 2493 + INGENIC_PIN_GROUP("pwm7-b10", x1600_pwm_pwm7_b10, 1), 2494 + INGENIC_PIN_GROUP("pwm7-b21", x1600_pwm_pwm7_b21, 2), 2495 + INGENIC_PIN_GROUP("mac", x1600_mac, 1), 2496 + }; 2497 + 2498 + static const char * const x1600_uart0_groups[] = { "uart0-data", "uart0-hwflow", }; 2499 + static const char * const x1600_uart1_groups[] = { "uart1-data", "uart1-hwflow", }; 2500 + static const char * const x1600_uart2_groups[] = { "uart2-data-a", "uart2-data-b", }; 2501 + static const char * const x1600_uart3_groups[] = { "uart3-data-b", "uart3-data-d", }; 2502 + 2503 + static const char * const x1600_sfc_groups[] = { "sfc", }; 2504 + 2505 + static const char * const x1600_ssi_groups[] = { 2506 + "ssi-dt-a", "ssi-dt-b", 2507 + "ssi-dr-a", "ssi-dr-b", 2508 + "ssi-clk-a", "ssi-clk-b", 2509 + "ssi-ce0-a", "ssi-ce0-b", 2510 + "ssi-ce1-a", "ssi-ce1-b", 2511 + }; 2512 + 2513 + static const char * const x1600_mmc0_groups[] = { "mmc0-1bit-b", "mmc0-4bit-b", 2514 + "mmc0-1bit-c", "mmc0-4bit-c", 2515 + }; 2516 + 2517 + static const char * const x1600_mmc1_groups[] = { "mmc1-1bit", "mmc1-4bit", }; 2518 + 2519 + static const char * const x1600_i2c0_groups[] = { "i2c0-data-a", "i2c0-data-b", }; 2520 + static const char * const x1600_i2c1_groups[] = { "i2c1-data-b-15", "i2c1-data-b-19", }; 2521 + 2522 + static const char * const x1600_i2s_groups[] = { 2523 + "i2s-data-tx", "i2s-data-rx", "i2s-clk-rx", "i2s-clk-tx", "i2s-sysclk", 2524 + }; 2525 + 2526 + static const char * const x1600_cim_groups[] = { "cim-data", }; 2527 + 2528 + static const char * const x1600_lcd_groups[] = { "slcd-8bit", "slcd-16bit", 2529 + "lcd-16bit", "lcd-18bit", "lcd-24bit", "lcd-no-pins", 2530 + }; 2531 + 2532 + static const char * const x1600_pwm0_groups[] = { "pwm0", }; 2533 + static const char * const x1600_pwm1_groups[] = { "pwm1", }; 2534 + static const char * const x1600_pwm2_groups[] = { "pwm2", }; 2535 + static const char * const x1600_pwm3_groups[] = { "pwm3", }; 2536 + static const char * const x1600_pwm4_groups[] = { "pwm4", }; 2537 + static const char * const x1600_pwm5_groups[] = { "pwm5-b", "pwm5-c", }; 2538 + static const char * const x1600_pwm6_groups[] = { "pwm6-b9", "pwm6-b20", }; 2539 + static const char * const x1600_pwm7_groups[] = { "pwm7-b10", "pwm7-b21", }; 2540 + 2541 + static const char * const x1600_mac_groups[] = { "mac", }; 2542 + 2543 + static const struct function_desc x1600_functions[] = { 2544 + INGENIC_PIN_FUNCTION("uart0", x1600_uart0), 2545 + INGENIC_PIN_FUNCTION("uart1", x1600_uart1), 2546 + INGENIC_PIN_FUNCTION("uart2", x1600_uart2), 2547 + INGENIC_PIN_FUNCTION("uart3", x1600_uart3), 2548 + INGENIC_PIN_FUNCTION("sfc", x1600_sfc), 2549 + INGENIC_PIN_FUNCTION("ssi", x1600_ssi), 2550 + INGENIC_PIN_FUNCTION("mmc0", x1600_mmc0), 2551 + INGENIC_PIN_FUNCTION("mmc1", x1600_mmc1), 2552 + INGENIC_PIN_FUNCTION("i2c0", x1600_i2c0), 2553 + INGENIC_PIN_FUNCTION("i2c1", x1600_i2c1), 2554 + INGENIC_PIN_FUNCTION("i2s", x1600_i2s), 2555 + INGENIC_PIN_FUNCTION("cim", x1600_cim), 2556 + INGENIC_PIN_FUNCTION("lcd", x1600_lcd), 2557 + INGENIC_PIN_FUNCTION("pwm0", x1600_pwm0), 2558 + INGENIC_PIN_FUNCTION("pwm1", x1600_pwm1), 2559 + INGENIC_PIN_FUNCTION("pwm2", x1600_pwm2), 2560 + INGENIC_PIN_FUNCTION("pwm3", x1600_pwm3), 2561 + INGENIC_PIN_FUNCTION("pwm4", x1600_pwm4), 2562 + INGENIC_PIN_FUNCTION("pwm5", x1600_pwm5), 2563 + INGENIC_PIN_FUNCTION("pwm6", x1600_pwm6), 2564 + INGENIC_PIN_FUNCTION("pwm7", x1600_pwm7), 2565 + INGENIC_PIN_FUNCTION("mac", x1600_mac), 2566 + }; 2567 + 2568 + static const struct ingenic_chip_info x1600_chip_info = { 2569 + .num_chips = 4, 2570 + .reg_offset = 0x100, 2571 + .version = ID_X1600, 2572 + .groups = x1600_groups, 2573 + .num_groups = ARRAY_SIZE(x1600_groups), 2574 + .functions = x1600_functions, 2575 + .num_functions = ARRAY_SIZE(x1600_functions), 2576 + .pull_ups = x1600_pull_ups, 2577 + .pull_downs = x1600_pull_downs, 2578 + .access_table = &x1000_access_table, 2579 + }; 2580 + 2376 2581 static const u32 x1830_pull_ups[4] = { 2377 2582 0x5fdfffc0, 0xffffefff, 0x1ffffbff, 0x0fcff3fc, 2378 2583 }; ··· 4109 3860 pulldown = (bias == GPIO_PULL_DOWN) && (jzpc->info->pull_downs[offt] & BIT(idx)); 4110 3861 4111 3862 } else { 4112 - if (is_soc_or_above(jzpc, ID_JZ4770)) 3863 + if (is_soc_or_above(jzpc, ID_X1600)) 3864 + pull = ingenic_get_pin_config(jzpc, pin, X1600_GPIO_PU); 3865 + else if (is_soc_or_above(jzpc, ID_JZ4770)) 4113 3866 pull = !ingenic_get_pin_config(jzpc, pin, JZ4770_GPIO_PEN); 4114 3867 else if (is_soc_or_above(jzpc, ID_JZ4740)) 4115 3868 pull = !ingenic_get_pin_config(jzpc, pin, JZ4740_GPIO_PULL_DIS); ··· 4210 3959 REG_SET(X1830_GPIO_PEH), bias << idxh); 4211 3960 } 4212 3961 3962 + } else if (is_soc_or_above(jzpc, ID_X1600)) { 3963 + ingenic_config_pin(jzpc, pin, X1600_GPIO_PU, bias); 4213 3964 } else if (is_soc_or_above(jzpc, ID_JZ4770)) { 4214 3965 ingenic_config_pin(jzpc, pin, JZ4770_GPIO_PEN, !bias); 4215 3966 } else if (is_soc_or_above(jzpc, ID_JZ4740)) { ··· 4403 4150 { .compatible = "ingenic,jz4775-gpio" }, 4404 4151 { .compatible = "ingenic,jz4780-gpio" }, 4405 4152 { .compatible = "ingenic,x1000-gpio" }, 4153 + { .compatible = "ingenic,x1600-gpio" }, 4406 4154 { .compatible = "ingenic,x1830-gpio" }, 4407 4155 { .compatible = "ingenic,x2000-gpio" }, 4408 4156 { .compatible = "ingenic,x2100-gpio" }, ··· 4650 4396 { 4651 4397 .compatible = "ingenic,x1500-pinctrl", 4652 4398 .data = IF_ENABLED(CONFIG_MACH_X1500, &x1500_chip_info) 4399 + }, 4400 + { 4401 + .compatible = "ingenic,x1600-pinctrl", 4402 + .data = IF_ENABLED(CONFIG_MACH_X1600, &x1600_chip_info) 4653 4403 }, 4654 4404 { 4655 4405 .compatible = "ingenic,x1830-pinctrl",
+20 -3
drivers/pinctrl/pinctrl-mcp23s08.c
··· 382 382 { 383 383 struct mcp23s08 *mcp = data; 384 384 int intcap, intcon, intf, i, gpio, gpio_orig, intcap_mask, defval, gpinten; 385 + bool need_unmask = false; 385 386 unsigned long int enabled_interrupts; 386 387 unsigned int child_irq; 387 388 bool intf_set, intcap_changed, gpio_bit_changed, ··· 397 396 goto unlock; 398 397 } 399 398 400 - if (mcp_read(mcp, MCP_INTCAP, &intcap)) 401 - goto unlock; 402 - 403 399 if (mcp_read(mcp, MCP_INTCON, &intcon)) 404 400 goto unlock; 405 401 ··· 404 406 goto unlock; 405 407 406 408 if (mcp_read(mcp, MCP_DEFVAL, &defval)) 409 + goto unlock; 410 + 411 + /* Mask level interrupts to avoid their immediate reactivation after clearing */ 412 + if (intcon) { 413 + need_unmask = true; 414 + if (mcp_write(mcp, MCP_GPINTEN, gpinten & ~intcon)) 415 + goto unlock; 416 + } 417 + 418 + if (mcp_read(mcp, MCP_INTCAP, &intcap)) 407 419 goto unlock; 408 420 409 421 /* This clears the interrupt(configurable on S18) */ ··· 478 470 } 479 471 } 480 472 473 + if (need_unmask) { 474 + mutex_lock(&mcp->lock); 475 + goto unlock; 476 + } 477 + 481 478 return IRQ_HANDLED; 482 479 483 480 unlock: 481 + if (need_unmask) 482 + if (mcp_write(mcp, MCP_GPINTEN, gpinten)) 483 + dev_err(mcp->chip.parent, "can't unmask GPINTEN\n"); 484 + 484 485 mutex_unlock(&mcp->lock); 485 486 return IRQ_HANDLED; 486 487 }
-6
drivers/pinctrl/pinctrl-pistachio.c
··· 1393 1393 dev_err(pctl->dev, "Failed to retrieve IRQ for bank %u\n", i); 1394 1394 goto err; 1395 1395 } 1396 - if (!ret) { 1397 - fwnode_handle_put(child); 1398 - dev_err(pctl->dev, "No IRQ for bank %u\n", i); 1399 - ret = -EINVAL; 1400 - goto err; 1401 - } 1402 1396 irq = ret; 1403 1397 1404 1398 bank = &pctl->gpio_banks[i];
+159 -1
drivers/pinctrl/pinctrl-rockchip.c
··· 2003 2003 return 0; 2004 2004 } 2005 2005 2006 + #define RK3528_DRV_BITS_PER_PIN 8 2007 + #define RK3528_DRV_PINS_PER_REG 2 2008 + #define RK3528_DRV_GPIO0_OFFSET 0x100 2009 + #define RK3528_DRV_GPIO1_OFFSET 0x20120 2010 + #define RK3528_DRV_GPIO2_OFFSET 0x30160 2011 + #define RK3528_DRV_GPIO3_OFFSET 0x20190 2012 + #define RK3528_DRV_GPIO4_OFFSET 0x101C0 2013 + 2014 + static int rk3528_calc_drv_reg_and_bit(struct rockchip_pin_bank *bank, 2015 + int pin_num, struct regmap **regmap, 2016 + int *reg, u8 *bit) 2017 + { 2018 + struct rockchip_pinctrl *info = bank->drvdata; 2019 + 2020 + *regmap = info->regmap_base; 2021 + 2022 + if (bank->bank_num == 0) 2023 + *reg = RK3528_DRV_GPIO0_OFFSET; 2024 + else if (bank->bank_num == 1) 2025 + *reg = RK3528_DRV_GPIO1_OFFSET; 2026 + else if (bank->bank_num == 2) 2027 + *reg = RK3528_DRV_GPIO2_OFFSET; 2028 + else if (bank->bank_num == 3) 2029 + *reg = RK3528_DRV_GPIO3_OFFSET; 2030 + else if (bank->bank_num == 4) 2031 + *reg = RK3528_DRV_GPIO4_OFFSET; 2032 + else 2033 + dev_err(info->dev, "unsupported bank_num %d\n", bank->bank_num); 2034 + 2035 + *reg += ((pin_num / RK3528_DRV_PINS_PER_REG) * 4); 2036 + *bit = pin_num % RK3528_DRV_PINS_PER_REG; 2037 + *bit *= RK3528_DRV_BITS_PER_PIN; 2038 + 2039 + return 0; 2040 + } 2041 + 2042 + #define RK3528_PULL_BITS_PER_PIN 2 2043 + #define RK3528_PULL_PINS_PER_REG 8 2044 + #define RK3528_PULL_GPIO0_OFFSET 0x200 2045 + #define RK3528_PULL_GPIO1_OFFSET 0x20210 2046 + #define RK3528_PULL_GPIO2_OFFSET 0x30220 2047 + #define RK3528_PULL_GPIO3_OFFSET 0x20230 2048 + #define RK3528_PULL_GPIO4_OFFSET 0x10240 2049 + 2050 + static int rk3528_calc_pull_reg_and_bit(struct rockchip_pin_bank *bank, 2051 + int pin_num, struct regmap **regmap, 2052 + int *reg, u8 *bit) 2053 + { 2054 + struct rockchip_pinctrl *info = bank->drvdata; 2055 + 2056 + *regmap = info->regmap_base; 2057 + 2058 + if (bank->bank_num == 0) 2059 + *reg = RK3528_PULL_GPIO0_OFFSET; 2060 + else if (bank->bank_num == 1) 2061 + *reg = RK3528_PULL_GPIO1_OFFSET; 2062 + else if (bank->bank_num == 2) 2063 + *reg = RK3528_PULL_GPIO2_OFFSET; 2064 + else if (bank->bank_num == 3) 2065 + *reg = RK3528_PULL_GPIO3_OFFSET; 2066 + else if (bank->bank_num == 4) 2067 + *reg = RK3528_PULL_GPIO4_OFFSET; 2068 + else 2069 + dev_err(info->dev, "unsupported bank_num %d\n", bank->bank_num); 2070 + 2071 + *reg += ((pin_num / RK3528_PULL_PINS_PER_REG) * 4); 2072 + *bit = pin_num % RK3528_PULL_PINS_PER_REG; 2073 + *bit *= RK3528_PULL_BITS_PER_PIN; 2074 + 2075 + return 0; 2076 + } 2077 + 2078 + #define RK3528_SMT_BITS_PER_PIN 1 2079 + #define RK3528_SMT_PINS_PER_REG 8 2080 + #define RK3528_SMT_GPIO0_OFFSET 0x400 2081 + #define RK3528_SMT_GPIO1_OFFSET 0x20410 2082 + #define RK3528_SMT_GPIO2_OFFSET 0x30420 2083 + #define RK3528_SMT_GPIO3_OFFSET 0x20430 2084 + #define RK3528_SMT_GPIO4_OFFSET 0x10440 2085 + 2086 + static int rk3528_calc_schmitt_reg_and_bit(struct rockchip_pin_bank *bank, 2087 + int pin_num, 2088 + struct regmap **regmap, 2089 + int *reg, u8 *bit) 2090 + { 2091 + struct rockchip_pinctrl *info = bank->drvdata; 2092 + 2093 + *regmap = info->regmap_base; 2094 + 2095 + if (bank->bank_num == 0) 2096 + *reg = RK3528_SMT_GPIO0_OFFSET; 2097 + else if (bank->bank_num == 1) 2098 + *reg = RK3528_SMT_GPIO1_OFFSET; 2099 + else if (bank->bank_num == 2) 2100 + *reg = RK3528_SMT_GPIO2_OFFSET; 2101 + else if (bank->bank_num == 3) 2102 + *reg = RK3528_SMT_GPIO3_OFFSET; 2103 + else if (bank->bank_num == 4) 2104 + *reg = RK3528_SMT_GPIO4_OFFSET; 2105 + else 2106 + dev_err(info->dev, "unsupported bank_num %d\n", bank->bank_num); 2107 + 2108 + *reg += ((pin_num / RK3528_SMT_PINS_PER_REG) * 4); 2109 + *bit = pin_num % RK3528_SMT_PINS_PER_REG; 2110 + *bit *= RK3528_SMT_BITS_PER_PIN; 2111 + 2112 + return 0; 2113 + } 2114 + 2006 2115 #define RK3562_DRV_BITS_PER_PIN 8 2007 2116 #define RK3562_DRV_PINS_PER_REG 2 2008 2117 #define RK3562_DRV_GPIO0_OFFSET 0x20070 ··· 2749 2640 rmask_bits = RK3588_DRV_BITS_PER_PIN; 2750 2641 ret = strength; 2751 2642 goto config; 2752 - } else if (ctrl->type == RK3562 || 2643 + } else if (ctrl->type == RK3528 || 2644 + ctrl->type == RK3562 || 2753 2645 ctrl->type == RK3568) { 2754 2646 rmask_bits = RK3568_DRV_BITS_PER_PIN; 2755 2647 ret = (1 << (strength + 1)) - 1; ··· 2895 2785 case RK3328: 2896 2786 case RK3368: 2897 2787 case RK3399: 2788 + case RK3528: 2898 2789 case RK3562: 2899 2790 case RK3568: 2900 2791 case RK3576: ··· 2957 2846 case RK3328: 2958 2847 case RK3368: 2959 2848 case RK3399: 2849 + case RK3528: 2960 2850 case RK3562: 2961 2851 case RK3568: 2962 2852 case RK3576: ··· 3227 3115 case RK3328: 3228 3116 case RK3368: 3229 3117 case RK3399: 3118 + case RK3528: 3230 3119 case RK3562: 3231 3120 case RK3568: 3232 3121 case RK3576: ··· 4350 4237 .drv_calc_reg = rk3399_calc_drv_reg_and_bit, 4351 4238 }; 4352 4239 4240 + static struct rockchip_pin_bank rk3528_pin_banks[] = { 4241 + PIN_BANK_IOMUX_FLAGS_OFFSET(0, 32, "gpio0", 4242 + IOMUX_WIDTH_4BIT, 4243 + IOMUX_WIDTH_4BIT, 4244 + IOMUX_WIDTH_4BIT, 4245 + IOMUX_WIDTH_4BIT, 4246 + 0, 0, 0, 0), 4247 + PIN_BANK_IOMUX_FLAGS_OFFSET(1, 32, "gpio1", 4248 + IOMUX_WIDTH_4BIT, 4249 + IOMUX_WIDTH_4BIT, 4250 + IOMUX_WIDTH_4BIT, 4251 + IOMUX_WIDTH_4BIT, 4252 + 0x20020, 0x20028, 0x20030, 0x20038), 4253 + PIN_BANK_IOMUX_FLAGS_OFFSET(2, 32, "gpio2", 4254 + IOMUX_WIDTH_4BIT, 4255 + IOMUX_WIDTH_4BIT, 4256 + IOMUX_WIDTH_4BIT, 4257 + IOMUX_WIDTH_4BIT, 4258 + 0x30040, 0, 0, 0), 4259 + PIN_BANK_IOMUX_FLAGS_OFFSET(3, 32, "gpio3", 4260 + IOMUX_WIDTH_4BIT, 4261 + IOMUX_WIDTH_4BIT, 4262 + IOMUX_WIDTH_4BIT, 4263 + IOMUX_WIDTH_4BIT, 4264 + 0x20060, 0x20068, 0x20070, 0), 4265 + PIN_BANK_IOMUX_FLAGS_OFFSET(4, 32, "gpio4", 4266 + IOMUX_WIDTH_4BIT, 4267 + IOMUX_WIDTH_4BIT, 4268 + IOMUX_WIDTH_4BIT, 4269 + IOMUX_WIDTH_4BIT, 4270 + 0x10080, 0x10088, 0x10090, 0x10098), 4271 + }; 4272 + 4273 + static struct rockchip_pin_ctrl rk3528_pin_ctrl = { 4274 + .pin_banks = rk3528_pin_banks, 4275 + .nr_banks = ARRAY_SIZE(rk3528_pin_banks), 4276 + .label = "RK3528-GPIO", 4277 + .type = RK3528, 4278 + .pull_calc_reg = rk3528_calc_pull_reg_and_bit, 4279 + .drv_calc_reg = rk3528_calc_drv_reg_and_bit, 4280 + .schmitt_calc_reg = rk3528_calc_schmitt_reg_and_bit, 4281 + }; 4282 + 4353 4283 static struct rockchip_pin_bank rk3562_pin_banks[] = { 4354 4284 PIN_BANK_IOMUX_FLAGS_OFFSET(0, 32, "gpio0", 4355 4285 IOMUX_WIDTH_4BIT, ··· 4560 4404 .data = &rk3368_pin_ctrl }, 4561 4405 { .compatible = "rockchip,rk3399-pinctrl", 4562 4406 .data = &rk3399_pin_ctrl }, 4407 + { .compatible = "rockchip,rk3528-pinctrl", 4408 + .data = &rk3528_pin_ctrl }, 4563 4409 { .compatible = "rockchip,rk3562-pinctrl", 4564 4410 .data = &rk3562_pin_ctrl }, 4565 4411 { .compatible = "rockchip,rk3568-pinctrl",
+1
drivers/pinctrl/pinctrl-rockchip.h
··· 196 196 RK3328, 197 197 RK3368, 198 198 RK3399, 199 + RK3528, 199 200 RK3562, 200 201 RK3568, 201 202 RK3576,
+4 -4
drivers/pinctrl/pxa/pinctrl-pxa2xx.c
··· 281 281 for (df = pctl->ppins[i].functions; df->name; df++) 282 282 if (!pxa2xx_find_function(pctl, df->name, functions)) 283 283 (functions + pctl->nfuncs++)->name = df->name; 284 - pctl->functions = devm_kmemdup(pctl->dev, functions, 285 - pctl->nfuncs * sizeof(*functions), 286 - GFP_KERNEL); 284 + pctl->functions = devm_kmemdup_array(pctl->dev, functions, pctl->nfuncs, 285 + sizeof(*functions), GFP_KERNEL); 287 286 if (!pctl->functions) 288 287 return -ENOMEM; 289 288 ··· 313 314 pctl->ppins[j].pin.name; 314 315 func = pctl->functions + i; 315 316 func->ngroups = ngroups; 316 - func->groups = devm_kmemdup(pctl->dev, gtmp, ngroups * sizeof(*gtmp), GFP_KERNEL); 317 + func->groups = devm_kmemdup_array(pctl->dev, gtmp, ngroups, 318 + sizeof(*gtmp), GFP_KERNEL); 317 319 if (!func->groups) 318 320 return -ENOMEM; 319 321 }
+12 -2
drivers/pinctrl/qcom/Kconfig.msm
··· 138 138 Qualcomm TLMM block found on the Qualcomm 8916 platform. 139 139 140 140 config PINCTRL_MSM8917 141 - tristate "Qualcomm 8917 pin controller driver" 141 + tristate "Qualcomm 8917/8937 pin controller driver" 142 142 help 143 143 This is the pinctrl, pinmux, pinconf and gpiolib driver for the 144 - Qualcomm TLMM block found on the Qualcomm MSM8917 platform. 144 + Qualcomm TLMM block found on the Qualcomm MSM8917, MSM8937 platform. 145 145 146 146 config PINCTRL_MSM8953 147 147 tristate "Qualcomm 8953 pin controller driver" ··· 435 435 Qualcomm Technologies Inc Top Level Mode Multiplexer block (TLMM) 436 436 block found on the Qualcomm Technologies Inc X1E80100 platform. 437 437 Say Y here to compile statically, or M here to compile it as a module. 438 + If unsure, say N. 439 + 440 + config PINCTRL_TLMM_TEST 441 + tristate "Qualcomm TLMM test driver" 442 + depends on ARM64 || COMPILE_TEST 443 + depends on KUNIT 444 + help 445 + This driver provides test cases for the interrupt capabilities of 446 + TLMM driver (pinctrl-msm). Specify a floating gpio to use for testing 447 + using the module parameter "gpio" and execute the kunit suite. 438 448 If unsure, say N. 439 449 440 450 endif
+1
drivers/pinctrl/qcom/Makefile
··· 71 71 obj-$(CONFIG_PINCTRL_SC8280XP_LPASS_LPI) += pinctrl-sc8280xp-lpass-lpi.o 72 72 obj-$(CONFIG_PINCTRL_LPASS_LPI) += pinctrl-lpass-lpi.o 73 73 obj-$(CONFIG_PINCTRL_X1E80100) += pinctrl-x1e80100.o 74 + obj-$(CONFIG_PINCTRL_TLMM_TEST) += tlmm-test.o
+6 -6
drivers/pinctrl/qcom/pinctrl-msm.c
··· 1045 1045 const struct msm_pingroup *g; 1046 1046 u32 intr_target_mask = GENMASK(2, 0); 1047 1047 unsigned long flags; 1048 - bool was_enabled; 1049 - u32 val; 1048 + u32 val, oldval; 1050 1049 1051 1050 if (msm_gpio_needs_dual_edge_parent_workaround(d, type)) { 1052 1051 set_bit(d->hwirq, pctrl->dual_edge_irqs); ··· 1107 1108 * internal circuitry of TLMM, toggling the RAW_STATUS 1108 1109 * could cause the INTR_STATUS to be set for EDGE interrupts. 1109 1110 */ 1110 - val = msm_readl_intr_cfg(pctrl, g); 1111 - was_enabled = val & BIT(g->intr_raw_status_bit); 1111 + val = oldval = msm_readl_intr_cfg(pctrl, g); 1112 1112 val |= BIT(g->intr_raw_status_bit); 1113 1113 if (g->intr_detection_width == 2) { 1114 1114 val &= ~(3 << g->intr_detection_bit); ··· 1160 1162 /* 1161 1163 * The first time we set RAW_STATUS_EN it could trigger an interrupt. 1162 1164 * Clear the interrupt. This is safe because we have 1163 - * IRQCHIP_SET_TYPE_MASKED. 1165 + * IRQCHIP_SET_TYPE_MASKED. When changing the interrupt type, we could 1166 + * also still have a non-matching interrupt latched, so clear whenever 1167 + * making changes to the interrupt configuration. 1164 1168 */ 1165 - if (!was_enabled) 1169 + if (val != oldval) 1166 1170 msm_ack_intr_status(pctrl, g); 1167 1171 1168 1172 if (test_bit(d->hwirq, pctrl->dual_edge_irqs))
+7 -1
drivers/pinctrl/qcom/pinctrl-msm8917.c
··· 539 539 msm_mux_webcam_standby, 540 540 msm_mux_wsa_io, 541 541 msm_mux_wsa_irq, 542 + msm_mux_wsa_reset, 542 543 msm_mux__, 543 544 }; 544 545 ··· 1124 1123 "gpio94", "gpio95", 1125 1124 }; 1126 1125 1126 + static const char * const wsa_reset_groups[] = { 1127 + "gpio96", 1128 + }; 1129 + 1127 1130 static const char * const blsp_spi8_groups[] = { 1128 1131 "gpio96", "gpio97", "gpio98", "gpio99", 1129 1132 }; ··· 1383 1378 MSM_PIN_FUNCTION(webcam_standby), 1384 1379 MSM_PIN_FUNCTION(wsa_io), 1385 1380 MSM_PIN_FUNCTION(wsa_irq), 1381 + MSM_PIN_FUNCTION(wsa_reset), 1386 1382 }; 1387 1383 1388 1384 static const struct msm_pingroup msm8917_groups[] = { ··· 1622 1616 } 1623 1617 module_exit(msm8917_pinctrl_exit); 1624 1618 1625 - MODULE_DESCRIPTION("Qualcomm msm8917 pinctrl driver"); 1619 + MODULE_DESCRIPTION("Qualcomm msm8917/msm8937 pinctrl driver"); 1626 1620 MODULE_LICENSE("GPL");
+34 -24
drivers/pinctrl/qcom/pinctrl-sa8775p.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0-only 2 2 /* 3 - * Copyright (c) 2022, Qualcomm Innovation Center, Inc. All rights reserved. 3 + * Copyright (c) 2022,2025, Qualcomm Innovation Center, Inc. All rights reserved. 4 4 * Copyright (c) 2023, Linaro Limited 5 5 */ 6 6 ··· 467 467 msm_mux_edp2_lcd, 468 468 msm_mux_edp3_hot, 469 469 msm_mux_edp3_lcd, 470 + msm_mux_egpio, 470 471 msm_mux_emac0_mcg0, 471 472 msm_mux_emac0_mcg1, 472 473 msm_mux_emac0_mcg2, ··· 743 742 744 743 static const char * const edp3_lcd_groups[] = { 745 744 "gpio49", 745 + }; 746 + 747 + static const char *const egpio_groups[] = { 748 + "gpio126", "gpio127", "gpio128", "gpio129", "gpio130", "gpio131", 749 + "gpio132", "gpio133", "gpio134", "gpio135", "gpio136", "gpio137", 750 + "gpio138", "gpio139", "gpio140", "gpio141", "gpio142", "gpio143", 751 + "gpio144", "gpio145", "gpio146", "gpio147", "gpio148", 746 752 }; 747 753 748 754 static const char * const emac0_mcg0_groups[] = { ··· 1217 1209 MSM_PIN_FUNCTION(edp2_lcd), 1218 1210 MSM_PIN_FUNCTION(edp3_hot), 1219 1211 MSM_PIN_FUNCTION(edp3_lcd), 1212 + MSM_PIN_FUNCTION(egpio), 1220 1213 MSM_PIN_FUNCTION(emac0_mcg0), 1221 1214 MSM_PIN_FUNCTION(emac0_mcg1), 1222 1215 MSM_PIN_FUNCTION(emac0_mcg2), ··· 1463 1454 [123] = PINGROUP(123, hs2_mi2s, phase_flag, _, _, _, _, _, _, _), 1464 1455 [124] = PINGROUP(124, hs2_mi2s, phase_flag, _, _, _, _, _, _, _), 1465 1456 [125] = PINGROUP(125, hs2_mi2s, phase_flag, _, _, _, _, _, _, _), 1466 - [126] = PINGROUP(126, _, _, _, _, _, _, _, _, _), 1467 - [127] = PINGROUP(127, _, _, _, _, _, _, _, _, _), 1468 - [128] = PINGROUP(128, _, _, _, _, _, _, _, _, _), 1469 - [129] = PINGROUP(129, _, _, _, _, _, _, _, _, _), 1470 - [130] = PINGROUP(130, _, _, _, _, _, _, _, _, _), 1471 - [131] = PINGROUP(131, _, _, _, _, _, _, _, _, _), 1472 - [132] = PINGROUP(132, _, _, _, _, _, _, _, _, _), 1473 - [133] = PINGROUP(133, _, _, _, _, _, _, _, _, _), 1474 - [134] = PINGROUP(134, _, _, _, _, _, _, _, _, _), 1475 - [135] = PINGROUP(135, _, _, _, _, _, _, _, _, _), 1476 - [136] = PINGROUP(136, _, _, _, _, _, _, _, _, _), 1477 - [137] = PINGROUP(137, _, _, _, _, _, _, _, _, _), 1478 - [138] = PINGROUP(138, _, _, _, _, _, _, _, _, _), 1479 - [139] = PINGROUP(139, _, _, _, _, _, _, _, _, _), 1480 - [140] = PINGROUP(140, _, _, _, _, _, _, _, _, _), 1481 - [141] = PINGROUP(141, _, _, _, _, _, _, _, _, _), 1482 - [142] = PINGROUP(142, _, _, _, _, _, _, _, _, _), 1483 - [143] = PINGROUP(143, _, _, _, _, _, _, _, _, _), 1484 - [144] = PINGROUP(144, dbg_out, _, _, _, _, _, _, _, _), 1485 - [145] = PINGROUP(145, _, _, _, _, _, _, _, _, _), 1486 - [146] = PINGROUP(146, _, _, _, _, _, _, _, _, _), 1487 - [147] = PINGROUP(147, _, _, _, _, _, _, _, _, _), 1488 - [148] = PINGROUP(148, _, _, _, _, _, _, _, _, _), 1457 + [126] = PINGROUP(126, _, _, _, _, _, _, _, _, egpio), 1458 + [127] = PINGROUP(127, _, _, _, _, _, _, _, _, egpio), 1459 + [128] = PINGROUP(128, _, _, _, _, _, _, _, _, egpio), 1460 + [129] = PINGROUP(129, _, _, _, _, _, _, _, _, egpio), 1461 + [130] = PINGROUP(130, _, _, _, _, _, _, _, _, egpio), 1462 + [131] = PINGROUP(131, _, _, _, _, _, _, _, _, egpio), 1463 + [132] = PINGROUP(132, _, _, _, _, _, _, _, _, egpio), 1464 + [133] = PINGROUP(133, _, _, _, _, _, _, _, _, egpio), 1465 + [134] = PINGROUP(134, _, _, _, _, _, _, _, _, egpio), 1466 + [135] = PINGROUP(135, _, _, _, _, _, _, _, _, egpio), 1467 + [136] = PINGROUP(136, _, _, _, _, _, _, _, _, egpio), 1468 + [137] = PINGROUP(137, _, _, _, _, _, _, _, _, egpio), 1469 + [138] = PINGROUP(138, _, _, _, _, _, _, _, _, egpio), 1470 + [139] = PINGROUP(139, _, _, _, _, _, _, _, _, egpio), 1471 + [140] = PINGROUP(140, _, _, _, _, _, _, _, _, egpio), 1472 + [141] = PINGROUP(141, _, _, _, _, _, _, _, _, egpio), 1473 + [142] = PINGROUP(142, _, _, _, _, _, _, _, _, egpio), 1474 + [143] = PINGROUP(143, _, _, _, _, _, _, _, _, egpio), 1475 + [144] = PINGROUP(144, dbg_out, _, _, _, _, _, _, _, egpio), 1476 + [145] = PINGROUP(145, _, _, _, _, _, _, _, _, egpio), 1477 + [146] = PINGROUP(146, _, _, _, _, _, _, _, _, egpio), 1478 + [147] = PINGROUP(147, _, _, _, _, _, _, _, _, egpio), 1479 + [148] = PINGROUP(148, _, _, _, _, _, _, _, _, egpio), 1489 1480 [149] = UFS_RESET(ufs_reset, 0x1a2000), 1490 1481 [150] = SDC_QDSD_PINGROUP(sdc1_rclk, 0x199000, 15, 0), 1491 1482 [151] = SDC_QDSD_PINGROUP(sdc1_clk, 0x199000, 13, 6), ··· 1520 1511 .ngpios = 150, 1521 1512 .wakeirq_map = sa8775p_pdc_map, 1522 1513 .nwakeirq_map = ARRAY_SIZE(sa8775p_pdc_map), 1514 + .egpio_func = 9, 1523 1515 }; 1524 1516 1525 1517 static int sa8775p_pinctrl_probe(struct platform_device *pdev)
+663
drivers/pinctrl/qcom/tlmm-test.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Copyright (c) 2025, Qualcomm Innovation Center, Inc. All rights reserved. 4 + */ 5 + 6 + #define pr_fmt(fmt) "tlmm-test: " fmt 7 + 8 + #include <kunit/test.h> 9 + #include <linux/delay.h> 10 + #include <linux/gpio/consumer.h> 11 + #include <linux/interrupt.h> 12 + #include <linux/kernel.h> 13 + #include <linux/module.h> 14 + #include <linux/of.h> 15 + #include <linux/of_address.h> 16 + #include <linux/of_irq.h> 17 + #include <linux/pinctrl/consumer.h> 18 + #include <linux/platform_device.h> 19 + 20 + /* 21 + * This TLMM test module serves the purpose of validating that the TLMM driver 22 + * (pinctrl-msm) delivers expected number of interrupts in response to changing 23 + * GPIO state. 24 + * 25 + * To achieve this without external equipment the test takes a module parameter 26 + * "gpio", which the tester is expected to specify an unused and non-connected 27 + * pin. The GPIO state is then driven by adjusting the bias of the pin, at 28 + * suitable times through the different test cases. 29 + * 30 + * Upon execution, the test initialization will find the TLMM node (subject to 31 + * tlmm_of_match[] allow listing) and create the necessary references 32 + * dynamically, rather then relying on e.g. Devicetree and phandles. 33 + */ 34 + 35 + #define MSM_PULL_MASK GENMASK(2, 0) 36 + #define MSM_PULL_DOWN 1 37 + #define MSM_PULL_UP 3 38 + #define TLMM_REG_SIZE 0x1000 39 + 40 + static int tlmm_test_gpio = -1; 41 + module_param_named(gpio, tlmm_test_gpio, int, 0600); 42 + 43 + static struct { 44 + void __iomem *base; 45 + void __iomem *reg; 46 + int irq; 47 + 48 + u32 low_val; 49 + u32 high_val; 50 + } tlmm_suite; 51 + 52 + /** 53 + * struct tlmm_test_priv - Per-test context 54 + * @intr_count: number of times hard handler was hit with TLMM_TEST_COUNT op set 55 + * @thread_count: number of times thread handler was hit with TLMM_TEST_COUNT op set 56 + * @intr_op: operations to be performed by the hard IRQ handler 57 + * @intr_op_remain: number of times the TLMM_TEST_THEN_* operations should be 58 + * performed by the hard IRQ handler 59 + * @thread_op: operations to be performed by the threaded IRQ handler 60 + * @thread_op_remain: number of times the TLMM_TEST_THEN_* operations should 61 + * be performed by the threaded IRQ handler 62 + */ 63 + struct tlmm_test_priv { 64 + atomic_t intr_count; 65 + atomic_t thread_count; 66 + 67 + unsigned int intr_op; 68 + atomic_t intr_op_remain; 69 + 70 + unsigned int thread_op; 71 + atomic_t thread_op_remain; 72 + }; 73 + 74 + /* Operation masks for @intr_op and @thread_op */ 75 + #define TLMM_TEST_COUNT BIT(0) 76 + #define TLMM_TEST_OUTPUT_LOW BIT(1) 77 + #define TLMM_TEST_OUTPUT_HIGH BIT(2) 78 + #define TLMM_TEST_THEN_HIGH BIT(3) 79 + #define TLMM_TEST_THEN_LOW BIT(4) 80 + #define TLMM_TEST_WAKE_THREAD BIT(5) 81 + 82 + static void tlmm_output_low(void) 83 + { 84 + writel(tlmm_suite.low_val, tlmm_suite.reg); 85 + readl(tlmm_suite.reg); 86 + } 87 + 88 + static void tlmm_output_high(void) 89 + { 90 + writel(tlmm_suite.high_val, tlmm_suite.reg); 91 + readl(tlmm_suite.reg); 92 + } 93 + 94 + static irqreturn_t tlmm_test_intr_fn(int irq, void *dev_id) 95 + { 96 + struct tlmm_test_priv *priv = dev_id; 97 + 98 + if (priv->intr_op & TLMM_TEST_COUNT) 99 + atomic_inc(&priv->intr_count); 100 + 101 + if (priv->intr_op & TLMM_TEST_OUTPUT_LOW) 102 + tlmm_output_low(); 103 + if (priv->intr_op & TLMM_TEST_OUTPUT_HIGH) 104 + tlmm_output_high(); 105 + 106 + if (atomic_dec_if_positive(&priv->intr_op_remain) > 0) { 107 + udelay(1); 108 + 109 + if (priv->intr_op & TLMM_TEST_THEN_LOW) 110 + tlmm_output_low(); 111 + if (priv->intr_op & TLMM_TEST_THEN_HIGH) 112 + tlmm_output_high(); 113 + } 114 + 115 + return priv->intr_op & TLMM_TEST_WAKE_THREAD ? IRQ_WAKE_THREAD : IRQ_HANDLED; 116 + } 117 + 118 + static irqreturn_t tlmm_test_intr_thread_fn(int irq, void *dev_id) 119 + { 120 + struct tlmm_test_priv *priv = dev_id; 121 + 122 + if (priv->thread_op & TLMM_TEST_COUNT) 123 + atomic_inc(&priv->thread_count); 124 + 125 + if (priv->thread_op & TLMM_TEST_OUTPUT_LOW) 126 + tlmm_output_low(); 127 + if (priv->thread_op & TLMM_TEST_OUTPUT_HIGH) 128 + tlmm_output_high(); 129 + 130 + if (atomic_dec_if_positive(&priv->thread_op_remain) > 0) { 131 + udelay(1); 132 + if (priv->thread_op & TLMM_TEST_THEN_LOW) 133 + tlmm_output_low(); 134 + if (priv->thread_op & TLMM_TEST_THEN_HIGH) 135 + tlmm_output_high(); 136 + } 137 + 138 + return IRQ_HANDLED; 139 + } 140 + 141 + static void tlmm_test_request_hard_irq(struct kunit *test, unsigned long irqflags) 142 + { 143 + struct tlmm_test_priv *priv = test->priv; 144 + int ret; 145 + 146 + ret = request_irq(tlmm_suite.irq, tlmm_test_intr_fn, irqflags, test->name, priv); 147 + KUNIT_EXPECT_EQ(test, ret, 0); 148 + } 149 + 150 + static void tlmm_test_request_threaded_irq(struct kunit *test, unsigned long irqflags) 151 + { 152 + struct tlmm_test_priv *priv = test->priv; 153 + int ret; 154 + 155 + ret = request_threaded_irq(tlmm_suite.irq, 156 + tlmm_test_intr_fn, tlmm_test_intr_thread_fn, 157 + irqflags, test->name, priv); 158 + 159 + KUNIT_EXPECT_EQ(test, ret, 0); 160 + } 161 + 162 + static void tlmm_test_silent(struct kunit *test, unsigned long irqflags) 163 + { 164 + struct tlmm_test_priv *priv = test->priv; 165 + 166 + priv->intr_op = TLMM_TEST_COUNT; 167 + 168 + /* GPIO line at non-triggering level */ 169 + if (irqflags == IRQF_TRIGGER_LOW || irqflags == IRQF_TRIGGER_FALLING) 170 + tlmm_output_high(); 171 + else 172 + tlmm_output_low(); 173 + 174 + tlmm_test_request_hard_irq(test, irqflags); 175 + msleep(100); 176 + free_irq(tlmm_suite.irq, priv); 177 + 178 + KUNIT_ASSERT_EQ(test, atomic_read(&priv->intr_count), 0); 179 + } 180 + 181 + /* 182 + * Test that no RISING interrupts are triggered on a silent pin 183 + */ 184 + static void tlmm_test_silent_rising(struct kunit *test) 185 + { 186 + tlmm_test_silent(test, IRQF_TRIGGER_RISING); 187 + } 188 + 189 + /* 190 + * Test that no FALLING interrupts are triggered on a silent pin 191 + */ 192 + static void tlmm_test_silent_falling(struct kunit *test) 193 + { 194 + tlmm_test_silent(test, IRQF_TRIGGER_FALLING); 195 + } 196 + 197 + /* 198 + * Test that no LOW interrupts are triggered on a silent pin 199 + */ 200 + static void tlmm_test_silent_low(struct kunit *test) 201 + { 202 + tlmm_test_silent(test, IRQF_TRIGGER_LOW); 203 + } 204 + 205 + /* 206 + * Test that no HIGH interrupts are triggered on a silent pin 207 + */ 208 + static void tlmm_test_silent_high(struct kunit *test) 209 + { 210 + tlmm_test_silent(test, IRQF_TRIGGER_HIGH); 211 + } 212 + 213 + /* 214 + * Square wave with 10 high pulses, assert that we get 10 rising interrupts 215 + */ 216 + static void tlmm_test_rising(struct kunit *test) 217 + { 218 + struct tlmm_test_priv *priv = test->priv; 219 + int i; 220 + 221 + priv->intr_op = TLMM_TEST_COUNT; 222 + 223 + tlmm_output_low(); 224 + 225 + tlmm_test_request_hard_irq(test, IRQF_TRIGGER_RISING); 226 + for (i = 0; i < 10; i++) { 227 + tlmm_output_low(); 228 + msleep(20); 229 + tlmm_output_high(); 230 + msleep(20); 231 + } 232 + 233 + free_irq(tlmm_suite.irq, priv); 234 + 235 + KUNIT_ASSERT_EQ(test, atomic_read(&priv->intr_count), 10); 236 + } 237 + 238 + /* 239 + * Square wave with 10 low pulses, assert that we get 10 falling interrupts 240 + */ 241 + static void tlmm_test_falling(struct kunit *test) 242 + { 243 + struct tlmm_test_priv *priv = test->priv; 244 + int i; 245 + 246 + priv->intr_op = TLMM_TEST_COUNT; 247 + 248 + tlmm_output_high(); 249 + 250 + tlmm_test_request_hard_irq(test, IRQF_TRIGGER_FALLING); 251 + for (i = 0; i < 10; i++) { 252 + tlmm_output_high(); 253 + msleep(20); 254 + tlmm_output_low(); 255 + msleep(20); 256 + } 257 + free_irq(tlmm_suite.irq, priv); 258 + 259 + KUNIT_ASSERT_EQ(test, atomic_read(&priv->intr_count), 10); 260 + } 261 + 262 + /* 263 + * Drive line low 10 times, handler drives it high to "clear the interrupt 264 + * source", assert we get 10 interrupts 265 + */ 266 + static void tlmm_test_low(struct kunit *test) 267 + { 268 + struct tlmm_test_priv *priv = test->priv; 269 + int i; 270 + 271 + priv->intr_op = TLMM_TEST_COUNT | TLMM_TEST_OUTPUT_HIGH; 272 + atomic_set(&priv->intr_op_remain, 9); 273 + 274 + tlmm_output_high(); 275 + 276 + tlmm_test_request_hard_irq(test, IRQF_TRIGGER_LOW); 277 + for (i = 0; i < 10; i++) { 278 + msleep(20); 279 + tlmm_output_low(); 280 + } 281 + msleep(100); 282 + free_irq(tlmm_suite.irq, priv); 283 + 284 + KUNIT_ASSERT_EQ(test, atomic_read(&priv->intr_count), 10); 285 + } 286 + 287 + /* 288 + * Drive line high 10 times, handler drives it low to "clear the interrupt 289 + * source", assert we get 10 interrupts 290 + */ 291 + static void tlmm_test_high(struct kunit *test) 292 + { 293 + struct tlmm_test_priv *priv = test->priv; 294 + int i; 295 + 296 + priv->intr_op = TLMM_TEST_COUNT | TLMM_TEST_OUTPUT_LOW; 297 + atomic_set(&priv->intr_op_remain, 9); 298 + 299 + tlmm_output_low(); 300 + 301 + tlmm_test_request_hard_irq(test, IRQF_TRIGGER_HIGH); 302 + for (i = 0; i < 10; i++) { 303 + msleep(20); 304 + tlmm_output_high(); 305 + } 306 + msleep(100); 307 + free_irq(tlmm_suite.irq, priv); 308 + 309 + KUNIT_ASSERT_EQ(test, atomic_read(&priv->intr_count), 10); 310 + } 311 + 312 + /* 313 + * Handler drives GPIO high to "clear the interrupt source", then low to 314 + * simulate a new interrupt, repeated 10 times, assert we get 10 interrupts 315 + */ 316 + static void tlmm_test_falling_in_handler(struct kunit *test) 317 + { 318 + struct tlmm_test_priv *priv = test->priv; 319 + 320 + priv->intr_op = TLMM_TEST_COUNT | TLMM_TEST_OUTPUT_HIGH | TLMM_TEST_THEN_LOW; 321 + atomic_set(&priv->intr_op_remain, 10); 322 + 323 + tlmm_output_high(); 324 + 325 + tlmm_test_request_hard_irq(test, IRQF_TRIGGER_FALLING); 326 + msleep(20); 327 + tlmm_output_low(); 328 + msleep(100); 329 + free_irq(tlmm_suite.irq, priv); 330 + 331 + KUNIT_ASSERT_EQ(test, atomic_read(&priv->intr_count), 10); 332 + } 333 + 334 + /* 335 + * Handler drives GPIO low to "clear the interrupt source", then high to 336 + * simulate a new interrupt, repeated 10 times, assert we get 10 interrupts 337 + */ 338 + static void tlmm_test_rising_in_handler(struct kunit *test) 339 + { 340 + struct tlmm_test_priv *priv = test->priv; 341 + 342 + priv->intr_op = TLMM_TEST_COUNT | TLMM_TEST_OUTPUT_LOW | TLMM_TEST_THEN_HIGH; 343 + atomic_set(&priv->intr_op_remain, 10); 344 + 345 + tlmm_output_low(); 346 + 347 + tlmm_test_request_hard_irq(test, IRQF_TRIGGER_RISING); 348 + msleep(20); 349 + tlmm_output_high(); 350 + msleep(100); 351 + free_irq(tlmm_suite.irq, priv); 352 + 353 + KUNIT_ASSERT_EQ(test, atomic_read(&priv->intr_count), 10); 354 + } 355 + 356 + /* 357 + * Square wave with 10 high pulses, assert that we get 10 rising hard and 358 + * 10 threaded interrupts 359 + */ 360 + static void tlmm_test_thread_rising(struct kunit *test) 361 + { 362 + struct tlmm_test_priv *priv = test->priv; 363 + int i; 364 + 365 + priv->intr_op = TLMM_TEST_COUNT | TLMM_TEST_WAKE_THREAD; 366 + priv->thread_op = TLMM_TEST_COUNT; 367 + 368 + tlmm_output_low(); 369 + 370 + tlmm_test_request_threaded_irq(test, IRQF_TRIGGER_RISING); 371 + for (i = 0; i < 10; i++) { 372 + tlmm_output_low(); 373 + msleep(20); 374 + tlmm_output_high(); 375 + msleep(20); 376 + } 377 + free_irq(tlmm_suite.irq, priv); 378 + 379 + KUNIT_ASSERT_EQ(test, atomic_read(&priv->intr_count), 10); 380 + KUNIT_ASSERT_EQ(test, atomic_read(&priv->thread_count), 10); 381 + } 382 + 383 + /* 384 + * Square wave with 10 low pulses, assert that we get 10 falling interrupts 385 + */ 386 + static void tlmm_test_thread_falling(struct kunit *test) 387 + { 388 + struct tlmm_test_priv *priv = test->priv; 389 + int i; 390 + 391 + priv->intr_op = TLMM_TEST_COUNT | TLMM_TEST_WAKE_THREAD; 392 + priv->thread_op = TLMM_TEST_COUNT; 393 + 394 + tlmm_output_high(); 395 + 396 + tlmm_test_request_threaded_irq(test, IRQF_TRIGGER_FALLING); 397 + for (i = 0; i < 10; i++) { 398 + tlmm_output_high(); 399 + msleep(20); 400 + tlmm_output_low(); 401 + msleep(20); 402 + } 403 + free_irq(tlmm_suite.irq, priv); 404 + 405 + KUNIT_ASSERT_EQ(test, atomic_read(&priv->intr_count), 10); 406 + KUNIT_ASSERT_EQ(test, atomic_read(&priv->thread_count), 10); 407 + } 408 + 409 + /* 410 + * Drive line high 10 times, threaded handler drives it low to "clear the 411 + * interrupt source", assert we get 10 interrupts 412 + */ 413 + static void tlmm_test_thread_high(struct kunit *test) 414 + { 415 + struct tlmm_test_priv *priv = test->priv; 416 + int i; 417 + 418 + priv->intr_op = TLMM_TEST_COUNT | TLMM_TEST_WAKE_THREAD; 419 + priv->thread_op = TLMM_TEST_COUNT | TLMM_TEST_OUTPUT_LOW; 420 + 421 + tlmm_output_low(); 422 + 423 + tlmm_test_request_threaded_irq(test, IRQF_TRIGGER_HIGH | IRQF_ONESHOT); 424 + for (i = 0; i < 10; i++) { 425 + tlmm_output_high(); 426 + msleep(20); 427 + } 428 + free_irq(tlmm_suite.irq, priv); 429 + 430 + KUNIT_ASSERT_EQ(test, atomic_read(&priv->intr_count), 10); 431 + KUNIT_ASSERT_EQ(test, atomic_read(&priv->thread_count), 10); 432 + } 433 + 434 + /* 435 + * Drive line low 10 times, threaded handler drives it high to "clear the 436 + * interrupt source", assert we get 10 interrupts 437 + */ 438 + static void tlmm_test_thread_low(struct kunit *test) 439 + { 440 + struct tlmm_test_priv *priv = test->priv; 441 + int i; 442 + 443 + priv->intr_op = TLMM_TEST_COUNT | TLMM_TEST_WAKE_THREAD; 444 + priv->thread_op = TLMM_TEST_COUNT | TLMM_TEST_OUTPUT_HIGH; 445 + 446 + tlmm_output_high(); 447 + 448 + tlmm_test_request_threaded_irq(test, IRQF_TRIGGER_LOW | IRQF_ONESHOT); 449 + for (i = 0; i < 10; i++) { 450 + tlmm_output_low(); 451 + msleep(20); 452 + } 453 + free_irq(tlmm_suite.irq, priv); 454 + 455 + KUNIT_ASSERT_EQ(test, atomic_read(&priv->intr_count), 10); 456 + KUNIT_ASSERT_EQ(test, atomic_read(&priv->thread_count), 10); 457 + } 458 + 459 + /* 460 + * Handler drives GPIO low to "clear the interrupt source", then high in the 461 + * threaded handler to simulate a new interrupt, repeated 10 times, assert we 462 + * get 10 interrupts 463 + */ 464 + static void tlmm_test_thread_rising_in_handler(struct kunit *test) 465 + { 466 + struct tlmm_test_priv *priv = test->priv; 467 + 468 + priv->intr_op = TLMM_TEST_COUNT | TLMM_TEST_OUTPUT_LOW | TLMM_TEST_WAKE_THREAD; 469 + priv->thread_op = TLMM_TEST_COUNT | TLMM_TEST_THEN_HIGH; 470 + atomic_set(&priv->thread_op_remain, 10); 471 + 472 + tlmm_output_low(); 473 + 474 + tlmm_test_request_threaded_irq(test, IRQF_TRIGGER_RISING); 475 + msleep(20); 476 + tlmm_output_high(); 477 + msleep(100); 478 + free_irq(tlmm_suite.irq, priv); 479 + 480 + KUNIT_ASSERT_EQ(test, atomic_read(&priv->intr_count), 10); 481 + KUNIT_ASSERT_EQ(test, atomic_read(&priv->thread_count), 10); 482 + } 483 + 484 + /* 485 + * Handler drives GPIO high to "clear the interrupt source", then low in the 486 + * threaded handler to simulate a new interrupt, repeated 10 times, assert we 487 + * get 10 interrupts 488 + */ 489 + static void tlmm_test_thread_falling_in_handler(struct kunit *test) 490 + { 491 + struct tlmm_test_priv *priv = test->priv; 492 + 493 + priv->intr_op = TLMM_TEST_COUNT | TLMM_TEST_OUTPUT_HIGH | TLMM_TEST_WAKE_THREAD; 494 + priv->thread_op = TLMM_TEST_COUNT | TLMM_TEST_THEN_LOW; 495 + atomic_set(&priv->thread_op_remain, 10); 496 + 497 + tlmm_output_high(); 498 + 499 + tlmm_test_request_threaded_irq(test, IRQF_TRIGGER_FALLING); 500 + msleep(20); 501 + tlmm_output_low(); 502 + msleep(100); 503 + free_irq(tlmm_suite.irq, priv); 504 + 505 + KUNIT_ASSERT_EQ(test, atomic_read(&priv->intr_count), 10); 506 + KUNIT_ASSERT_EQ(test, atomic_read(&priv->thread_count), 10); 507 + } 508 + 509 + /* 510 + * Validate that edge interrupts occurring while irq is disabled is delivered 511 + * once the interrupt is reenabled. 512 + */ 513 + static void tlmm_test_rising_while_disabled(struct kunit *test) 514 + { 515 + struct tlmm_test_priv *priv = test->priv; 516 + unsigned int after_edge; 517 + unsigned int before_edge; 518 + 519 + priv->intr_op = TLMM_TEST_COUNT; 520 + atomic_set(&priv->thread_op_remain, 10); 521 + 522 + tlmm_output_low(); 523 + 524 + tlmm_test_request_hard_irq(test, IRQF_TRIGGER_RISING); 525 + msleep(20); 526 + 527 + disable_irq(tlmm_suite.irq); 528 + before_edge = atomic_read(&priv->intr_count); 529 + 530 + tlmm_output_high(); 531 + msleep(20); 532 + after_edge = atomic_read(&priv->intr_count); 533 + 534 + msleep(20); 535 + enable_irq(tlmm_suite.irq); 536 + msleep(20); 537 + 538 + free_irq(tlmm_suite.irq, priv); 539 + 540 + KUNIT_ASSERT_EQ(test, before_edge, 0); 541 + KUNIT_ASSERT_EQ(test, after_edge, 0); 542 + KUNIT_ASSERT_EQ(test, atomic_read(&priv->intr_count), 1); 543 + } 544 + 545 + static int tlmm_test_init(struct kunit *test) 546 + { 547 + struct tlmm_test_priv *priv; 548 + 549 + priv = kunit_kzalloc(test, sizeof(*priv), GFP_KERNEL); 550 + 551 + atomic_set(&priv->intr_count, 0); 552 + atomic_set(&priv->thread_count, 0); 553 + 554 + atomic_set(&priv->intr_op_remain, 0); 555 + atomic_set(&priv->thread_op_remain, 0); 556 + 557 + test->priv = priv; 558 + 559 + return 0; 560 + } 561 + 562 + /* 563 + * NOTE: When adding compatibles to this list, ensure that TLMM_REG_SIZE and 564 + * pull configuration values are supported and correct. 565 + */ 566 + static const struct of_device_id tlmm_of_match[] = { 567 + { .compatible = "qcom,sc8280xp-tlmm" }, 568 + { .compatible = "qcom,x1e80100-tlmm" }, 569 + {} 570 + }; 571 + 572 + static int tlmm_test_init_suite(struct kunit_suite *suite) 573 + { 574 + struct of_phandle_args args = {}; 575 + struct resource res; 576 + int ret; 577 + u32 val; 578 + 579 + if (tlmm_test_gpio < 0) { 580 + pr_err("use the tlmm-test.gpio module parameter to specify which GPIO to use\n"); 581 + return -EINVAL; 582 + } 583 + 584 + struct device_node *tlmm __free(device_node) = of_find_matching_node(NULL, tlmm_of_match); 585 + if (!tlmm) { 586 + pr_err("failed to find tlmm node\n"); 587 + return -EINVAL; 588 + } 589 + 590 + ret = of_address_to_resource(tlmm, 0, &res); 591 + if (ret < 0) 592 + return ret; 593 + 594 + tlmm_suite.base = ioremap(res.start, resource_size(&res)); 595 + if (!tlmm_suite.base) 596 + return -ENOMEM; 597 + 598 + args.np = tlmm; 599 + args.args_count = 2; 600 + args.args[0] = tlmm_test_gpio; 601 + args.args[1] = 0; 602 + 603 + tlmm_suite.irq = irq_create_of_mapping(&args); 604 + if (!tlmm_suite.irq) { 605 + pr_err("failed to map TLMM irq %d\n", args.args[0]); 606 + goto err_unmap; 607 + } 608 + 609 + tlmm_suite.reg = tlmm_suite.base + tlmm_test_gpio * TLMM_REG_SIZE; 610 + val = readl(tlmm_suite.reg) & ~MSM_PULL_MASK; 611 + tlmm_suite.low_val = val | MSM_PULL_DOWN; 612 + tlmm_suite.high_val = val | MSM_PULL_UP; 613 + 614 + return 0; 615 + 616 + err_unmap: 617 + iounmap(tlmm_suite.base); 618 + tlmm_suite.base = NULL; 619 + return -EINVAL; 620 + } 621 + 622 + static void tlmm_test_exit_suite(struct kunit_suite *suite) 623 + { 624 + irq_dispose_mapping(tlmm_suite.irq); 625 + iounmap(tlmm_suite.base); 626 + 627 + tlmm_suite.base = NULL; 628 + tlmm_suite.irq = -1; 629 + } 630 + 631 + static struct kunit_case tlmm_test_cases[] = { 632 + KUNIT_CASE(tlmm_test_silent_rising), 633 + KUNIT_CASE(tlmm_test_silent_falling), 634 + KUNIT_CASE(tlmm_test_silent_low), 635 + KUNIT_CASE(tlmm_test_silent_high), 636 + KUNIT_CASE(tlmm_test_rising), 637 + KUNIT_CASE(tlmm_test_falling), 638 + KUNIT_CASE(tlmm_test_high), 639 + KUNIT_CASE(tlmm_test_low), 640 + KUNIT_CASE(tlmm_test_rising_in_handler), 641 + KUNIT_CASE(tlmm_test_falling_in_handler), 642 + KUNIT_CASE(tlmm_test_thread_rising), 643 + KUNIT_CASE(tlmm_test_thread_falling), 644 + KUNIT_CASE(tlmm_test_thread_high), 645 + KUNIT_CASE(tlmm_test_thread_low), 646 + KUNIT_CASE(tlmm_test_thread_rising_in_handler), 647 + KUNIT_CASE(tlmm_test_thread_falling_in_handler), 648 + KUNIT_CASE(tlmm_test_rising_while_disabled), 649 + {} 650 + }; 651 + 652 + static struct kunit_suite tlmm_test_suite = { 653 + .name = "tlmm-test", 654 + .init = tlmm_test_init, 655 + .suite_init = tlmm_test_init_suite, 656 + .suite_exit = tlmm_test_exit_suite, 657 + .test_cases = tlmm_test_cases, 658 + }; 659 + 660 + kunit_test_suites(&tlmm_test_suite); 661 + 662 + MODULE_DESCRIPTION("Qualcomm TLMM test"); 663 + MODULE_LICENSE("GPL");
+5
drivers/pinctrl/renesas/pinctrl-rza2.c
··· 246 246 int ret; 247 247 248 248 chip.label = devm_kasprintf(priv->dev, GFP_KERNEL, "%pOFn", np); 249 + if (!chip.label) 250 + return -ENOMEM; 251 + 249 252 chip.parent = priv->dev; 250 253 chip.ngpio = priv->npins; 251 254 ··· 258 255 dev_err(priv->dev, "Unable to parse gpio-ranges\n"); 259 256 return ret; 260 257 } 258 + 259 + of_node_put(of_args.np); 261 260 262 261 if ((of_args.args[0] != 0) || 263 262 (of_args.args[1] != 0) ||
+21 -1
drivers/pinctrl/renesas/pinctrl-rzg2l.c
··· 318 318 * @pmc: PMC registers cache 319 319 * @pfc: PFC registers cache 320 320 * @iolh: IOLH registers cache 321 + * @pupd: PUPD registers cache 321 322 * @ien: IEN registers cache 322 323 * @sd_ch: SD_CH registers cache 323 324 * @eth_poc: ET_POC registers cache ··· 332 331 u32 *pfc; 333 332 u32 *iolh[2]; 334 333 u32 *ien[2]; 334 + u32 *pupd[2]; 335 335 u8 sd_ch[2]; 336 336 u8 eth_poc[2]; 337 337 u8 eth_mode; ··· 2714 2712 if (!cache->ien[i]) 2715 2713 return -ENOMEM; 2716 2714 2715 + cache->pupd[i] = devm_kcalloc(pctrl->dev, nports, sizeof(*cache->pupd[i]), 2716 + GFP_KERNEL); 2717 + if (!cache->pupd[i]) 2718 + return -ENOMEM; 2719 + 2717 2720 /* Allocate dedicated cache. */ 2718 2721 dedicated_cache->iolh[i] = devm_kcalloc(pctrl->dev, n_dedicated_pins, 2719 2722 sizeof(*dedicated_cache->iolh[i]), ··· 2762 2755 ret = of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3, 0, &of_args); 2763 2756 if (ret) 2764 2757 return dev_err_probe(pctrl->dev, ret, "Unable to parse gpio-ranges\n"); 2758 + 2759 + of_node_put(of_args.np); 2765 2760 2766 2761 if (of_args.args[0] != 0 || of_args.args[1] != 0 || 2767 2762 of_args.args[2] != pctrl->data->n_port_pins) ··· 2962 2953 struct rzg2l_pinctrl_reg_cache *cache = pctrl->cache; 2963 2954 2964 2955 for (u32 port = 0; port < nports; port++) { 2965 - bool has_iolh, has_ien; 2956 + bool has_iolh, has_ien, has_pupd; 2966 2957 u32 off, caps; 2967 2958 u8 pincnt; 2968 2959 u64 cfg; ··· 2974 2965 caps = FIELD_GET(PIN_CFG_MASK, cfg); 2975 2966 has_iolh = !!(caps & (PIN_CFG_IOLH_A | PIN_CFG_IOLH_B | PIN_CFG_IOLH_C)); 2976 2967 has_ien = !!(caps & PIN_CFG_IEN); 2968 + has_pupd = !!(caps & PIN_CFG_PUPD); 2977 2969 2978 2970 if (suspend) 2979 2971 RZG2L_PCTRL_REG_ACCESS32(suspend, pctrl->base + PFC(off), cache->pfc[port]); ··· 2990 2980 if (pincnt >= 4) { 2991 2981 RZG2L_PCTRL_REG_ACCESS32(suspend, pctrl->base + IOLH(off) + 4, 2992 2982 cache->iolh[1][port]); 2983 + } 2984 + } 2985 + 2986 + if (has_pupd) { 2987 + RZG2L_PCTRL_REG_ACCESS32(suspend, pctrl->base + PUPD(off), 2988 + cache->pupd[0][port]); 2989 + if (pincnt >= 4) { 2990 + RZG2L_PCTRL_REG_ACCESS32(suspend, pctrl->base + PUPD(off), 2991 + cache->pupd[1][port]); 2993 2992 } 2994 2993 } 2995 2994 ··· 3405 3386 .name = DRV_NAME, 3406 3387 .of_match_table = of_match_ptr(rzg2l_pinctrl_of_table), 3407 3388 .pm = pm_sleep_ptr(&rzg2l_pinctrl_pm_ops), 3389 + .suppress_bind_attrs = true, 3408 3390 }, 3409 3391 .probe = rzg2l_pinctrl_probe, 3410 3392 };
+2
drivers/pinctrl/renesas/pinctrl-rzv2m.c
··· 940 940 return ret; 941 941 } 942 942 943 + of_node_put(of_args.np); 944 + 943 945 if (of_args.args[0] != 0 || of_args.args[1] != 0 || 944 946 of_args.args[2] != pctrl->data->n_port_pins) { 945 947 dev_err(pctrl->dev, "gpio-ranges does not match selected SOC\n");
+356 -49
drivers/pinctrl/samsung/pinctrl-exynos-arm64.c
··· 41 41 }; 42 42 43 43 /* 44 + * Bank type for alive type. Bit fields: 45 + * CON: 4, DAT: 1, PUD: 2, DRV: 3 46 + */ 47 + static const struct samsung_pin_bank_type exynos7870_bank_type_alive = { 48 + .fld_width = { 4, 1, 2, 3, }, 49 + .reg_offset = { 0x00, 0x04, 0x08, 0x0c, }, 50 + }; 51 + 52 + /* 44 53 * Bank type for non-alive type. Bit fields: 45 54 * CON: 4, DAT: 1, PUD: 4, DRV: 4, CONPDN: 2, PUDPDN: 4 46 55 */ ··· 78 69 79 70 /* Pad retention control code for accessing PMU regmap */ 80 71 static atomic_t exynos_shared_retention_refcnt; 72 + 73 + /* pin banks of exynos2200 pin-controller - ALIVE */ 74 + static const struct samsung_pin_bank_data exynos2200_pin_banks0[] __initconst = { 75 + EXYNOS850_PIN_BANK_EINTW(8, 0x0, "gpa0", 0x00), 76 + EXYNOS850_PIN_BANK_EINTW(8, 0x20, "gpa1", 0x04), 77 + EXYNOS850_PIN_BANK_EINTW(8, 0x40, "gpa2", 0x08), 78 + EXYNOS850_PIN_BANK_EINTW(8, 0x60, "gpa3", 0x0c), 79 + EXYNOS850_PIN_BANK_EINTW(2, 0x80, "gpa4", 0x10), 80 + EXYNOS_PIN_BANK_EINTN(4, 0xa0, "gpq0"), 81 + EXYNOS_PIN_BANK_EINTN(2, 0xc0, "gpq1"), 82 + EXYNOS_PIN_BANK_EINTN(2, 0xe0, "gpq2"), 83 + }; 84 + 85 + /* pin banks of exynos2200 pin-controller - CMGP */ 86 + static const struct samsung_pin_bank_data exynos2200_pin_banks1[] __initconst = { 87 + EXYNOS850_PIN_BANK_EINTW(2, 0x0, "gpm0", 0x00), 88 + EXYNOS850_PIN_BANK_EINTW(2, 0x20, "gpm1", 0x04), 89 + EXYNOS850_PIN_BANK_EINTW(2, 0x40, "gpm2", 0x08), 90 + EXYNOS850_PIN_BANK_EINTW(2, 0x60, "gpm3", 0x0c), 91 + EXYNOS850_PIN_BANK_EINTW(2, 0x80, "gpm4", 0x10), 92 + EXYNOS850_PIN_BANK_EINTW(2, 0xa0, "gpm5", 0x14), 93 + EXYNOS850_PIN_BANK_EINTW(2, 0xc0, "gpm6", 0x18), 94 + EXYNOS850_PIN_BANK_EINTW(2, 0xe0, "gpm7", 0x1c), 95 + EXYNOS850_PIN_BANK_EINTW(2, 0x100, "gpm8", 0x20), 96 + EXYNOS850_PIN_BANK_EINTW(2, 0x120, "gpm9", 0x24), 97 + EXYNOS850_PIN_BANK_EINTW(2, 0x140, "gpm10", 0x28), 98 + EXYNOS850_PIN_BANK_EINTW(2, 0x160, "gpm11", 0x2c), 99 + EXYNOS850_PIN_BANK_EINTW(2, 0x180, "gpm12", 0x30), 100 + EXYNOS850_PIN_BANK_EINTW(2, 0x1a0, "gpm13", 0x34), 101 + EXYNOS850_PIN_BANK_EINTW(1, 0x1c0, "gpm14", 0x38), 102 + EXYNOS850_PIN_BANK_EINTW(1, 0x1e0, "gpm15", 0x3c), 103 + EXYNOS850_PIN_BANK_EINTW(1, 0x200, "gpm16", 0x40), 104 + EXYNOS850_PIN_BANK_EINTW(1, 0x220, "gpm17", 0x44), 105 + EXYNOS850_PIN_BANK_EINTW(1, 0x240, "gpm20", 0x48), 106 + EXYNOS850_PIN_BANK_EINTW(1, 0x260, "gpm21", 0x4c), 107 + EXYNOS850_PIN_BANK_EINTW(1, 0x280, "gpm22", 0x50), 108 + EXYNOS850_PIN_BANK_EINTW(1, 0x2a0, "gpm23", 0x54), 109 + EXYNOS850_PIN_BANK_EINTW(1, 0x2c0, "gpm24", 0x58), 110 + }; 111 + 112 + /* pin banks of exynos2200 pin-controller - HSI1 */ 113 + static const struct samsung_pin_bank_data exynos2200_pin_banks2[] __initconst = { 114 + EXYNOS850_PIN_BANK_EINTG(4, 0x0, "gpf0", 0x00), 115 + }; 116 + 117 + /* pin banks of exynos2200 pin-controller - UFS */ 118 + static const struct samsung_pin_bank_data exynos2200_pin_banks3[] __initconst = { 119 + EXYNOS850_PIN_BANK_EINTG(7, 0x0, "gpf1", 0x00), 120 + }; 121 + 122 + /* pin banks of exynos2200 pin-controller - HSI1UFS */ 123 + static const struct samsung_pin_bank_data exynos2200_pin_banks4[] __initconst = { 124 + EXYNOS850_PIN_BANK_EINTG(2, 0x0, "gpf2", 0x00), 125 + }; 126 + 127 + /* pin banks of exynos2200 pin-controller - PERIC0 */ 128 + static const struct samsung_pin_bank_data exynos2200_pin_banks5[] __initconst = { 129 + EXYNOS850_PIN_BANK_EINTG(4, 0x0, "gpb0", 0x00), 130 + EXYNOS850_PIN_BANK_EINTG(4, 0x20, "gpb1", 0x04), 131 + EXYNOS850_PIN_BANK_EINTG(4, 0x40, "gpb2", 0x08), 132 + EXYNOS850_PIN_BANK_EINTG(4, 0x60, "gpb3", 0x0c), 133 + EXYNOS850_PIN_BANK_EINTG(4, 0x80, "gpp4", 0x10), 134 + EXYNOS850_PIN_BANK_EINTG(2, 0xa0, "gpc0", 0x14), 135 + EXYNOS850_PIN_BANK_EINTG(2, 0xc0, "gpc1", 0x18), 136 + EXYNOS850_PIN_BANK_EINTG(2, 0xe0, "gpc2", 0x1c), 137 + EXYNOS850_PIN_BANK_EINTG(7, 0x100, "gpg1", 0x20), 138 + EXYNOS850_PIN_BANK_EINTG(2, 0x120, "gpg2", 0x24), 139 + }; 140 + 141 + /* pin banks of exynos2200 pin-controller - PERIC1 */ 142 + static const struct samsung_pin_bank_data exynos2200_pin_banks6[] __initconst = { 143 + EXYNOS850_PIN_BANK_EINTG(4, 0x0, "gpp7", 0x00), 144 + EXYNOS850_PIN_BANK_EINTG(4, 0x20, "gpp8", 0x04), 145 + EXYNOS850_PIN_BANK_EINTG(4, 0x40, "gpp9", 0x08), 146 + EXYNOS850_PIN_BANK_EINTG(4, 0x60, "gpp10", 0x0c), 147 + }; 148 + 149 + /* pin banks of exynos2200 pin-controller - PERIC2 */ 150 + static const struct samsung_pin_bank_data exynos2200_pin_banks7[] __initconst = { 151 + EXYNOS850_PIN_BANK_EINTG(4, 0x0, "gpp0", 0x00), 152 + EXYNOS850_PIN_BANK_EINTG(4, 0x20, "gpp1", 0x04), 153 + EXYNOS850_PIN_BANK_EINTG(4, 0x40, "gpp2", 0x08), 154 + EXYNOS850_PIN_BANK_EINTG(4, 0x60, "gpp3", 0x0c), 155 + EXYNOS850_PIN_BANK_EINTG(4, 0x80, "gpp5", 0x10), 156 + EXYNOS850_PIN_BANK_EINTG(4, 0xa0, "gpp6", 0x14), 157 + EXYNOS850_PIN_BANK_EINTG(4, 0xc0, "gpp11", 0x18), 158 + EXYNOS850_PIN_BANK_EINTG(2, 0xe0, "gpc3", 0x1c), 159 + EXYNOS850_PIN_BANK_EINTG(2, 0x100, "gpc4", 0x20), 160 + EXYNOS850_PIN_BANK_EINTG(2, 0x120, "gpc5", 0x24), 161 + EXYNOS850_PIN_BANK_EINTG(2, 0x140, "gpc6", 0x28), 162 + EXYNOS850_PIN_BANK_EINTG(2, 0x160, "gpc7", 0x2c), 163 + EXYNOS850_PIN_BANK_EINTG(2, 0x180, "gpc8", 0x30), 164 + EXYNOS850_PIN_BANK_EINTG(2, 0x1a0, "gpc9", 0x34), 165 + EXYNOS850_PIN_BANK_EINTG(5, 0x1c0, "gpg0", 0x38), 166 + }; 167 + 168 + /* pin banks of exynos2200 pin-controller - VTS */ 169 + static const struct samsung_pin_bank_data exynos2200_pin_banks8[] __initconst = { 170 + EXYNOS850_PIN_BANK_EINTG(7, 0x0, "gpv0", 0x00), 171 + }; 172 + 173 + static const struct samsung_pin_ctrl exynos2200_pin_ctrl[] = { 174 + { 175 + /* pin-controller instance 0 ALIVE data */ 176 + .pin_banks = exynos2200_pin_banks0, 177 + .nr_banks = ARRAY_SIZE(exynos2200_pin_banks0), 178 + .eint_gpio_init = exynos_eint_gpio_init, 179 + .eint_wkup_init = exynos_eint_wkup_init, 180 + .suspend = exynos_pinctrl_suspend, 181 + .resume = exynos_pinctrl_resume, 182 + }, { 183 + /* pin-controller instance 1 CMGP data */ 184 + .pin_banks = exynos2200_pin_banks1, 185 + .nr_banks = ARRAY_SIZE(exynos2200_pin_banks1), 186 + .eint_gpio_init = exynos_eint_gpio_init, 187 + .eint_wkup_init = exynos_eint_wkup_init, 188 + .suspend = exynos_pinctrl_suspend, 189 + .resume = exynos_pinctrl_resume, 190 + }, { 191 + /* pin-controller instance 2 HSI1 data */ 192 + .pin_banks = exynos2200_pin_banks2, 193 + .nr_banks = ARRAY_SIZE(exynos2200_pin_banks2), 194 + }, { 195 + /* pin-controller instance 3 UFS data */ 196 + .pin_banks = exynos2200_pin_banks3, 197 + .nr_banks = ARRAY_SIZE(exynos2200_pin_banks3), 198 + .eint_gpio_init = exynos_eint_gpio_init, 199 + .suspend = exynos_pinctrl_suspend, 200 + .resume = exynos_pinctrl_resume, 201 + }, { 202 + /* pin-controller instance 4 HSI1UFS data */ 203 + .pin_banks = exynos2200_pin_banks4, 204 + .nr_banks = ARRAY_SIZE(exynos2200_pin_banks4), 205 + .eint_gpio_init = exynos_eint_gpio_init, 206 + .suspend = exynos_pinctrl_suspend, 207 + .resume = exynos_pinctrl_resume, 208 + }, { 209 + /* pin-controller instance 5 PERIC0 data */ 210 + .pin_banks = exynos2200_pin_banks5, 211 + .nr_banks = ARRAY_SIZE(exynos2200_pin_banks5), 212 + .eint_gpio_init = exynos_eint_gpio_init, 213 + .suspend = exynos_pinctrl_suspend, 214 + .resume = exynos_pinctrl_resume, 215 + }, { 216 + /* pin-controller instance 6 PERIC1 data */ 217 + .pin_banks = exynos2200_pin_banks6, 218 + .nr_banks = ARRAY_SIZE(exynos2200_pin_banks6), 219 + .eint_gpio_init = exynos_eint_gpio_init, 220 + .suspend = exynos_pinctrl_suspend, 221 + .resume = exynos_pinctrl_resume, 222 + }, { 223 + /* pin-controller instance 7 PERIC2 data */ 224 + .pin_banks = exynos2200_pin_banks7, 225 + .nr_banks = ARRAY_SIZE(exynos2200_pin_banks7), 226 + .eint_gpio_init = exynos_eint_gpio_init, 227 + .suspend = exynos_pinctrl_suspend, 228 + .resume = exynos_pinctrl_resume, 229 + }, { 230 + /* pin-controller instance 8 VTS data */ 231 + .pin_banks = exynos2200_pin_banks8, 232 + .nr_banks = ARRAY_SIZE(exynos2200_pin_banks8), 233 + }, 234 + }; 235 + 236 + const struct samsung_pinctrl_of_match_data exynos2200_of_data __initconst = { 237 + .ctrl = exynos2200_pin_ctrl, 238 + .num_ctrl = ARRAY_SIZE(exynos2200_pin_ctrl), 239 + }; 81 240 82 241 /* pin banks of exynos5433 pin-controller - ALIVE */ 83 242 static const struct samsung_pin_bank_data exynos5433_pin_banks0[] __initconst = { ··· 625 448 const struct samsung_pinctrl_of_match_data exynos7_of_data __initconst = { 626 449 .ctrl = exynos7_pin_ctrl, 627 450 .num_ctrl = ARRAY_SIZE(exynos7_pin_ctrl), 451 + }; 452 + 453 + /* pin banks of exynos7870 pin-controller 0 (ALIVE) */ 454 + static const struct samsung_pin_bank_data exynos7870_pin_banks0[] __initconst = { 455 + EXYNOS7870_PIN_BANK_EINTN(6, 0x000, "etc0"), 456 + EXYNOS7870_PIN_BANK_EINTN(3, 0x020, "etc1"), 457 + EXYNOS7870_PIN_BANK_EINTW(8, 0x040, "gpa0", 0x00), 458 + EXYNOS7870_PIN_BANK_EINTW(8, 0x060, "gpa1", 0x04), 459 + EXYNOS7870_PIN_BANK_EINTW(8, 0x080, "gpa2", 0x08), 460 + EXYNOS7870_PIN_BANK_EINTN(2, 0x0c0, "gpq0"), 461 + }; 462 + 463 + /* pin banks of exynos7870 pin-controller 1 (DISPAUD) */ 464 + static const struct samsung_pin_bank_data exynos7870_pin_banks1[] __initconst = { 465 + EXYNOS8895_PIN_BANK_EINTG(4, 0x000, "gpz0", 0x00), 466 + EXYNOS8895_PIN_BANK_EINTG(6, 0x020, "gpz1", 0x04), 467 + EXYNOS8895_PIN_BANK_EINTG(4, 0x040, "gpz2", 0x08), 468 + }; 469 + 470 + /* pin banks of exynos7870 pin-controller 2 (ESE) */ 471 + static const struct samsung_pin_bank_data exynos7870_pin_banks2[] __initconst = { 472 + EXYNOS8895_PIN_BANK_EINTG(5, 0x000, "gpc7", 0x00), 473 + }; 474 + 475 + /* pin banks of exynos7870 pin-controller 3 (FSYS) */ 476 + static const struct samsung_pin_bank_data exynos7870_pin_banks3[] __initconst = { 477 + EXYNOS8895_PIN_BANK_EINTG(3, 0x000, "gpr0", 0x00), 478 + EXYNOS8895_PIN_BANK_EINTG(8, 0x020, "gpr1", 0x04), 479 + EXYNOS8895_PIN_BANK_EINTG(2, 0x040, "gpr2", 0x08), 480 + EXYNOS8895_PIN_BANK_EINTG(4, 0x060, "gpr3", 0x0c), 481 + EXYNOS8895_PIN_BANK_EINTG(6, 0x080, "gpr4", 0x10), 482 + }; 483 + 484 + /* pin banks of exynos7870 pin-controller 4 (MIF) */ 485 + static const struct samsung_pin_bank_data exynos7870_pin_banks4[] __initconst = { 486 + EXYNOS8895_PIN_BANK_EINTG(2, 0x000, "gpm0", 0x00), 487 + }; 488 + 489 + /* pin banks of exynos7870 pin-controller 5 (NFC) */ 490 + static const struct samsung_pin_bank_data exynos7870_pin_banks5[] __initconst = { 491 + EXYNOS8895_PIN_BANK_EINTG(4, 0x000, "gpc2", 0x00), 492 + }; 493 + 494 + /* pin banks of exynos7870 pin-controller 6 (TOP) */ 495 + static const struct samsung_pin_bank_data exynos7870_pin_banks6[] __initconst = { 496 + EXYNOS8895_PIN_BANK_EINTG(4, 0x000, "gpb0", 0x00), 497 + EXYNOS8895_PIN_BANK_EINTG(3, 0x020, "gpc0", 0x04), 498 + EXYNOS8895_PIN_BANK_EINTG(4, 0x040, "gpc1", 0x08), 499 + EXYNOS8895_PIN_BANK_EINTG(4, 0x060, "gpc4", 0x0c), 500 + EXYNOS8895_PIN_BANK_EINTG(2, 0x080, "gpc5", 0x10), 501 + EXYNOS8895_PIN_BANK_EINTG(4, 0x0a0, "gpc6", 0x14), 502 + EXYNOS8895_PIN_BANK_EINTG(2, 0x0c0, "gpc8", 0x18), 503 + EXYNOS8895_PIN_BANK_EINTG(2, 0x0e0, "gpc9", 0x1c), 504 + EXYNOS8895_PIN_BANK_EINTG(7, 0x100, "gpd1", 0x20), 505 + EXYNOS8895_PIN_BANK_EINTG(6, 0x120, "gpd2", 0x24), 506 + EXYNOS8895_PIN_BANK_EINTG(8, 0x140, "gpd3", 0x28), 507 + EXYNOS8895_PIN_BANK_EINTG(7, 0x160, "gpd4", 0x2c), 508 + EXYNOS8895_PIN_BANK_EINTG(3, 0x1a0, "gpe0", 0x34), 509 + EXYNOS8895_PIN_BANK_EINTG(4, 0x1c0, "gpf0", 0x38), 510 + EXYNOS8895_PIN_BANK_EINTG(2, 0x1e0, "gpf1", 0x3c), 511 + EXYNOS8895_PIN_BANK_EINTG(2, 0x200, "gpf2", 0x40), 512 + EXYNOS8895_PIN_BANK_EINTG(4, 0x220, "gpf3", 0x44), 513 + EXYNOS8895_PIN_BANK_EINTG(5, 0x240, "gpf4", 0x48), 514 + }; 515 + 516 + /* pin banks of exynos7870 pin-controller 7 (TOUCH) */ 517 + static const struct samsung_pin_bank_data exynos7870_pin_banks7[] __initconst = { 518 + EXYNOS8895_PIN_BANK_EINTG(3, 0x000, "gpc3", 0x00), 519 + }; 520 + 521 + static const struct samsung_pin_ctrl exynos7870_pin_ctrl[] __initconst = { 522 + { 523 + /* pin-controller instance 0 Alive data */ 524 + .pin_banks = exynos7870_pin_banks0, 525 + .nr_banks = ARRAY_SIZE(exynos7870_pin_banks0), 526 + .eint_wkup_init = exynos_eint_wkup_init, 527 + .suspend = exynos_pinctrl_suspend, 528 + .resume = exynos_pinctrl_resume, 529 + }, { 530 + /* pin-controller instance 1 DISPAUD data */ 531 + .pin_banks = exynos7870_pin_banks1, 532 + .nr_banks = ARRAY_SIZE(exynos7870_pin_banks1), 533 + }, { 534 + /* pin-controller instance 2 ESE data */ 535 + .pin_banks = exynos7870_pin_banks2, 536 + .nr_banks = ARRAY_SIZE(exynos7870_pin_banks2), 537 + .eint_gpio_init = exynos_eint_gpio_init, 538 + .suspend = exynos_pinctrl_suspend, 539 + .resume = exynos_pinctrl_resume, 540 + }, { 541 + /* pin-controller instance 3 FSYS data */ 542 + .pin_banks = exynos7870_pin_banks3, 543 + .nr_banks = ARRAY_SIZE(exynos7870_pin_banks3), 544 + .eint_gpio_init = exynos_eint_gpio_init, 545 + .suspend = exynos_pinctrl_suspend, 546 + .resume = exynos_pinctrl_resume, 547 + }, { 548 + /* pin-controller instance 4 MIF data */ 549 + .pin_banks = exynos7870_pin_banks4, 550 + .nr_banks = ARRAY_SIZE(exynos7870_pin_banks4), 551 + .eint_gpio_init = exynos_eint_gpio_init, 552 + .suspend = exynos_pinctrl_suspend, 553 + .resume = exynos_pinctrl_resume, 554 + }, { 555 + /* pin-controller instance 5 NFC data */ 556 + .pin_banks = exynos7870_pin_banks5, 557 + .nr_banks = ARRAY_SIZE(exynos7870_pin_banks5), 558 + .eint_gpio_init = exynos_eint_gpio_init, 559 + .suspend = exynos_pinctrl_suspend, 560 + .resume = exynos_pinctrl_resume, 561 + }, { 562 + /* pin-controller instance 6 TOP data */ 563 + .pin_banks = exynos7870_pin_banks6, 564 + .nr_banks = ARRAY_SIZE(exynos7870_pin_banks6), 565 + .eint_gpio_init = exynos_eint_gpio_init, 566 + .suspend = exynos_pinctrl_suspend, 567 + .resume = exynos_pinctrl_resume, 568 + }, { 569 + /* pin-controller instance 7 TOUCH data */ 570 + .pin_banks = exynos7870_pin_banks7, 571 + .nr_banks = ARRAY_SIZE(exynos7870_pin_banks7), 572 + .eint_gpio_init = exynos_eint_gpio_init, 573 + .suspend = exynos_pinctrl_suspend, 574 + .resume = exynos_pinctrl_resume, 575 + }, 576 + }; 577 + 578 + const struct samsung_pinctrl_of_match_data exynos7870_of_data __initconst = { 579 + .ctrl = exynos7870_pin_ctrl, 580 + .num_ctrl = ARRAY_SIZE(exynos7870_pin_ctrl), 628 581 }; 629 582 630 583 /* pin banks of exynos7885 pin-controller 0 (ALIVE) */ ··· 1677 1370 1678 1371 /* pin banks of gs101 pin-controller (ALIVE) */ 1679 1372 static const struct samsung_pin_bank_data gs101_pin_alive[] = { 1680 - EXYNOS850_PIN_BANK_EINTW(8, 0x0, "gpa0", 0x00), 1681 - EXYNOS850_PIN_BANK_EINTW(7, 0x20, "gpa1", 0x04), 1682 - EXYNOS850_PIN_BANK_EINTW(5, 0x40, "gpa2", 0x08), 1683 - EXYNOS850_PIN_BANK_EINTW(4, 0x60, "gpa3", 0x0c), 1684 - EXYNOS850_PIN_BANK_EINTW(4, 0x80, "gpa4", 0x10), 1685 - EXYNOS850_PIN_BANK_EINTW(7, 0xa0, "gpa5", 0x14), 1686 - EXYNOS850_PIN_BANK_EINTW(8, 0xc0, "gpa9", 0x18), 1687 - EXYNOS850_PIN_BANK_EINTW(2, 0xe0, "gpa10", 0x1c), 1373 + GS101_PIN_BANK_EINTW(8, 0x0, "gpa0", 0x00, 0x00), 1374 + GS101_PIN_BANK_EINTW(7, 0x20, "gpa1", 0x04, 0x08), 1375 + GS101_PIN_BANK_EINTW(5, 0x40, "gpa2", 0x08, 0x10), 1376 + GS101_PIN_BANK_EINTW(4, 0x60, "gpa3", 0x0c, 0x18), 1377 + GS101_PIN_BANK_EINTW(4, 0x80, "gpa4", 0x10, 0x1c), 1378 + GS101_PIN_BANK_EINTW(7, 0xa0, "gpa5", 0x14, 0x20), 1379 + GS101_PIN_BANK_EINTW(8, 0xc0, "gpa9", 0x18, 0x28), 1380 + GS101_PIN_BANK_EINTW(2, 0xe0, "gpa10", 0x1c, 0x30), 1688 1381 }; 1689 1382 1690 1383 /* pin banks of gs101 pin-controller (FAR_ALIVE) */ 1691 1384 static const struct samsung_pin_bank_data gs101_pin_far_alive[] = { 1692 - EXYNOS850_PIN_BANK_EINTW(8, 0x0, "gpa6", 0x00), 1693 - EXYNOS850_PIN_BANK_EINTW(4, 0x20, "gpa7", 0x04), 1694 - EXYNOS850_PIN_BANK_EINTW(8, 0x40, "gpa8", 0x08), 1695 - EXYNOS850_PIN_BANK_EINTW(2, 0x60, "gpa11", 0x0c), 1385 + GS101_PIN_BANK_EINTW(8, 0x0, "gpa6", 0x00, 0x00), 1386 + GS101_PIN_BANK_EINTW(4, 0x20, "gpa7", 0x04, 0x08), 1387 + GS101_PIN_BANK_EINTW(8, 0x40, "gpa8", 0x08, 0x0c), 1388 + GS101_PIN_BANK_EINTW(2, 0x60, "gpa11", 0x0c, 0x14), 1696 1389 }; 1697 1390 1698 1391 /* pin banks of gs101 pin-controller (GSACORE) */ 1699 1392 static const struct samsung_pin_bank_data gs101_pin_gsacore[] = { 1700 - EXYNOS850_PIN_BANK_EINTG(2, 0x0, "gps0", 0x00), 1701 - EXYNOS850_PIN_BANK_EINTG(8, 0x20, "gps1", 0x04), 1702 - EXYNOS850_PIN_BANK_EINTG(3, 0x40, "gps2", 0x08), 1393 + GS101_PIN_BANK_EINTG(2, 0x0, "gps0", 0x00, 0x00), 1394 + GS101_PIN_BANK_EINTG(8, 0x20, "gps1", 0x04, 0x04), 1395 + GS101_PIN_BANK_EINTG(3, 0x40, "gps2", 0x08, 0x0c), 1703 1396 }; 1704 1397 1705 1398 /* pin banks of gs101 pin-controller (GSACTRL) */ 1706 1399 static const struct samsung_pin_bank_data gs101_pin_gsactrl[] = { 1707 - EXYNOS850_PIN_BANK_EINTW(6, 0x0, "gps3", 0x00), 1400 + GS101_PIN_BANK_EINTW(6, 0x0, "gps3", 0x00, 0x00), 1708 1401 }; 1709 1402 1710 1403 /* pin banks of gs101 pin-controller (PERIC0) */ 1711 1404 static const struct samsung_pin_bank_data gs101_pin_peric0[] = { 1712 - EXYNOS850_PIN_BANK_EINTG(5, 0x0, "gpp0", 0x00), 1713 - EXYNOS850_PIN_BANK_EINTG(4, 0x20, "gpp1", 0x04), 1714 - EXYNOS850_PIN_BANK_EINTG(4, 0x40, "gpp2", 0x08), 1715 - EXYNOS850_PIN_BANK_EINTG(2, 0x60, "gpp3", 0x0c), 1716 - EXYNOS850_PIN_BANK_EINTG(4, 0x80, "gpp4", 0x10), 1717 - EXYNOS850_PIN_BANK_EINTG(2, 0xa0, "gpp5", 0x14), 1718 - EXYNOS850_PIN_BANK_EINTG(4, 0xc0, "gpp6", 0x18), 1719 - EXYNOS850_PIN_BANK_EINTG(2, 0xe0, "gpp7", 0x1c), 1720 - EXYNOS850_PIN_BANK_EINTG(4, 0x100, "gpp8", 0x20), 1721 - EXYNOS850_PIN_BANK_EINTG(2, 0x120, "gpp9", 0x24), 1722 - EXYNOS850_PIN_BANK_EINTG(4, 0x140, "gpp10", 0x28), 1723 - EXYNOS850_PIN_BANK_EINTG(2, 0x160, "gpp11", 0x2c), 1724 - EXYNOS850_PIN_BANK_EINTG(4, 0x180, "gpp12", 0x30), 1725 - EXYNOS850_PIN_BANK_EINTG(2, 0x1a0, "gpp13", 0x34), 1726 - EXYNOS850_PIN_BANK_EINTG(4, 0x1c0, "gpp14", 0x38), 1727 - EXYNOS850_PIN_BANK_EINTG(2, 0x1e0, "gpp15", 0x3c), 1728 - EXYNOS850_PIN_BANK_EINTG(4, 0x200, "gpp16", 0x40), 1729 - EXYNOS850_PIN_BANK_EINTG(2, 0x220, "gpp17", 0x44), 1730 - EXYNOS850_PIN_BANK_EINTG(4, 0x240, "gpp18", 0x48), 1731 - EXYNOS850_PIN_BANK_EINTG(4, 0x260, "gpp19", 0x4c), 1405 + GS101_PIN_BANK_EINTG(5, 0x0, "gpp0", 0x00, 0x00), 1406 + GS101_PIN_BANK_EINTG(4, 0x20, "gpp1", 0x04, 0x08), 1407 + GS101_PIN_BANK_EINTG(4, 0x40, "gpp2", 0x08, 0x0c), 1408 + GS101_PIN_BANK_EINTG(2, 0x60, "gpp3", 0x0c, 0x10), 1409 + GS101_PIN_BANK_EINTG(4, 0x80, "gpp4", 0x10, 0x14), 1410 + GS101_PIN_BANK_EINTG(2, 0xa0, "gpp5", 0x14, 0x18), 1411 + GS101_PIN_BANK_EINTG(4, 0xc0, "gpp6", 0x18, 0x1c), 1412 + GS101_PIN_BANK_EINTG(2, 0xe0, "gpp7", 0x1c, 0x20), 1413 + GS101_PIN_BANK_EINTG(4, 0x100, "gpp8", 0x20, 0x24), 1414 + GS101_PIN_BANK_EINTG(2, 0x120, "gpp9", 0x24, 0x28), 1415 + GS101_PIN_BANK_EINTG(4, 0x140, "gpp10", 0x28, 0x2c), 1416 + GS101_PIN_BANK_EINTG(2, 0x160, "gpp11", 0x2c, 0x30), 1417 + GS101_PIN_BANK_EINTG(4, 0x180, "gpp12", 0x30, 0x34), 1418 + GS101_PIN_BANK_EINTG(2, 0x1a0, "gpp13", 0x34, 0x38), 1419 + GS101_PIN_BANK_EINTG(4, 0x1c0, "gpp14", 0x38, 0x3c), 1420 + GS101_PIN_BANK_EINTG(2, 0x1e0, "gpp15", 0x3c, 0x40), 1421 + GS101_PIN_BANK_EINTG(4, 0x200, "gpp16", 0x40, 0x44), 1422 + GS101_PIN_BANK_EINTG(2, 0x220, "gpp17", 0x44, 0x48), 1423 + GS101_PIN_BANK_EINTG(4, 0x240, "gpp18", 0x48, 0x4c), 1424 + GS101_PIN_BANK_EINTG(4, 0x260, "gpp19", 0x4c, 0x50), 1732 1425 }; 1733 1426 1734 1427 /* pin banks of gs101 pin-controller (PERIC1) */ 1735 1428 static const struct samsung_pin_bank_data gs101_pin_peric1[] = { 1736 - EXYNOS850_PIN_BANK_EINTG(8, 0x0, "gpp20", 0x00), 1737 - EXYNOS850_PIN_BANK_EINTG(4, 0x20, "gpp21", 0x04), 1738 - EXYNOS850_PIN_BANK_EINTG(2, 0x40, "gpp22", 0x08), 1739 - EXYNOS850_PIN_BANK_EINTG(8, 0x60, "gpp23", 0x0c), 1740 - EXYNOS850_PIN_BANK_EINTG(4, 0x80, "gpp24", 0x10), 1741 - EXYNOS850_PIN_BANK_EINTG(4, 0xa0, "gpp25", 0x14), 1742 - EXYNOS850_PIN_BANK_EINTG(5, 0xc0, "gpp26", 0x18), 1743 - EXYNOS850_PIN_BANK_EINTG(4, 0xe0, "gpp27", 0x1c), 1429 + GS101_PIN_BANK_EINTG(8, 0x0, "gpp20", 0x00, 0x00), 1430 + GS101_PIN_BANK_EINTG(4, 0x20, "gpp21", 0x04, 0x08), 1431 + GS101_PIN_BANK_EINTG(2, 0x40, "gpp22", 0x08, 0x0c), 1432 + GS101_PIN_BANK_EINTG(8, 0x60, "gpp23", 0x0c, 0x10), 1433 + GS101_PIN_BANK_EINTG(4, 0x80, "gpp24", 0x10, 0x18), 1434 + GS101_PIN_BANK_EINTG(4, 0xa0, "gpp25", 0x14, 0x1c), 1435 + GS101_PIN_BANK_EINTG(5, 0xc0, "gpp26", 0x18, 0x20), 1436 + GS101_PIN_BANK_EINTG(4, 0xe0, "gpp27", 0x1c, 0x28), 1744 1437 }; 1745 1438 1746 1439 /* pin banks of gs101 pin-controller (HSI1) */ 1747 1440 static const struct samsung_pin_bank_data gs101_pin_hsi1[] = { 1748 - EXYNOS850_PIN_BANK_EINTG(6, 0x0, "gph0", 0x00), 1749 - EXYNOS850_PIN_BANK_EINTG(7, 0x20, "gph1", 0x04), 1441 + GS101_PIN_BANK_EINTG(6, 0x0, "gph0", 0x00, 0x00), 1442 + GS101_PIN_BANK_EINTG(7, 0x20, "gph1", 0x04, 0x08), 1750 1443 }; 1751 1444 1752 1445 /* pin banks of gs101 pin-controller (HSI2) */ 1753 1446 static const struct samsung_pin_bank_data gs101_pin_hsi2[] = { 1754 - EXYNOS850_PIN_BANK_EINTG(6, 0x0, "gph2", 0x00), 1755 - EXYNOS850_PIN_BANK_EINTG(2, 0x20, "gph3", 0x04), 1756 - EXYNOS850_PIN_BANK_EINTG(6, 0x40, "gph4", 0x08), 1447 + GS101_PIN_BANK_EINTG(6, 0x0, "gph2", 0x00, 0x00), 1448 + GS101_PIN_BANK_EINTG(2, 0x20, "gph3", 0x04, 0x08), 1449 + GS101_PIN_BANK_EINTG(6, 0x40, "gph4", 0x08, 0x0c), 1757 1450 }; 1758 1451 1759 1452 static const struct samsung_pin_ctrl gs101_pin_ctrl[] __initconst = {
+41
drivers/pinctrl/samsung/pinctrl-exynos.h
··· 112 112 .pctl_res_idx = pctl_idx, \ 113 113 } \ 114 114 115 + #define EXYNOS7870_PIN_BANK_EINTN(pins, reg, id) \ 116 + { \ 117 + .type = &exynos7870_bank_type_alive, \ 118 + .pctl_offset = reg, \ 119 + .nr_pins = pins, \ 120 + .eint_type = EINT_TYPE_NONE, \ 121 + .name = id \ 122 + } 123 + 124 + #define EXYNOS7870_PIN_BANK_EINTW(pins, reg, id, offs) \ 125 + { \ 126 + .type = &exynos7870_bank_type_alive, \ 127 + .pctl_offset = reg, \ 128 + .nr_pins = pins, \ 129 + .eint_type = EINT_TYPE_WKUP, \ 130 + .eint_offset = offs, \ 131 + .name = id \ 132 + } 133 + 115 134 #define EXYNOS850_PIN_BANK_EINTN(pins, reg, id) \ 116 135 { \ 117 136 .type = &exynos850_bank_type_alive, \ ··· 191 172 .eint_con_offset = con_offs, \ 192 173 .eint_mask_offset = mask_offs, \ 193 174 .eint_pend_offset = pend_offs, \ 175 + .name = id \ 176 + } 177 + 178 + #define GS101_PIN_BANK_EINTG(pins, reg, id, offs, fltcon_offs) \ 179 + { \ 180 + .type = &exynos850_bank_type_off, \ 181 + .pctl_offset = reg, \ 182 + .nr_pins = pins, \ 183 + .eint_type = EINT_TYPE_GPIO, \ 184 + .eint_offset = offs, \ 185 + .eint_fltcon_offset = fltcon_offs, \ 186 + .name = id \ 187 + } 188 + 189 + #define GS101_PIN_BANK_EINTW(pins, reg, id, offs, fltcon_offs) \ 190 + { \ 191 + .type = &exynos850_bank_type_alive, \ 192 + .pctl_offset = reg, \ 193 + .nr_pins = pins, \ 194 + .eint_type = EINT_TYPE_WKUP, \ 195 + .eint_offset = offs, \ 196 + .eint_fltcon_offset = fltcon_offs, \ 194 197 .name = id \ 195 198 } 196 199
+5
drivers/pinctrl/samsung/pinctrl-samsung.c
··· 1230 1230 bank->eint_con_offset = bdata->eint_con_offset; 1231 1231 bank->eint_mask_offset = bdata->eint_mask_offset; 1232 1232 bank->eint_pend_offset = bdata->eint_pend_offset; 1233 + bank->eint_fltcon_offset = bdata->eint_fltcon_offset; 1233 1234 bank->name = bdata->name; 1234 1235 1235 1236 raw_spin_lock_init(&bank->slock); ··· 1470 1469 #ifdef CONFIG_PINCTRL_EXYNOS_ARM64 1471 1470 { .compatible = "google,gs101-pinctrl", 1472 1471 .data = &gs101_of_data }, 1472 + { .compatible = "samsung,exynos2200-pinctrl", 1473 + .data = &exynos2200_of_data }, 1473 1474 { .compatible = "samsung,exynos5433-pinctrl", 1474 1475 .data = &exynos5433_of_data }, 1475 1476 { .compatible = "samsung,exynos7-pinctrl", 1476 1477 .data = &exynos7_of_data }, 1478 + { .compatible = "samsung,exynos7870-pinctrl", 1479 + .data = &exynos7870_of_data }, 1477 1480 { .compatible = "samsung,exynos7885-pinctrl", 1478 1481 .data = &exynos7885_of_data }, 1479 1482 { .compatible = "samsung,exynos850-pinctrl",
+6
drivers/pinctrl/samsung/pinctrl-samsung.h
··· 144 144 * @eint_con_offset: ExynosAuto SoC-specific EINT control register offset of bank. 145 145 * @eint_mask_offset: ExynosAuto SoC-specific EINT mask register offset of bank. 146 146 * @eint_pend_offset: ExynosAuto SoC-specific EINT pend register offset of bank. 147 + * @eint_fltcon_offset: GS101 SoC-specific EINT filter config register offset. 147 148 * @name: name to be prefixed for each pin in this pin bank. 148 149 */ 149 150 struct samsung_pin_bank_data { ··· 159 158 u32 eint_con_offset; 160 159 u32 eint_mask_offset; 161 160 u32 eint_pend_offset; 161 + u32 eint_fltcon_offset; 162 162 const char *name; 163 163 }; 164 164 ··· 177 175 * @eint_con_offset: ExynosAuto SoC-specific EINT register or interrupt offset of bank. 178 176 * @eint_mask_offset: ExynosAuto SoC-specific EINT mask register offset of bank. 179 177 * @eint_pend_offset: ExynosAuto SoC-specific EINT pend register offset of bank. 178 + * @eint_fltcon_offset: GS101 SoC-specific EINT filter config register offset. 180 179 * @name: name to be prefixed for each pin in this pin bank. 181 180 * @id: id of the bank, propagated to the pin range. 182 181 * @pin_base: starting pin number of the bank. ··· 204 201 u32 eint_con_offset; 205 202 u32 eint_mask_offset; 206 203 u32 eint_pend_offset; 204 + u32 eint_fltcon_offset; 207 205 const char *name; 208 206 u32 id; 209 207 ··· 377 373 }; 378 374 379 375 /* list of all exported SoC specific data */ 376 + extern const struct samsung_pinctrl_of_match_data exynos2200_of_data; 380 377 extern const struct samsung_pinctrl_of_match_data exynos3250_of_data; 381 378 extern const struct samsung_pinctrl_of_match_data exynos4210_of_data; 382 379 extern const struct samsung_pinctrl_of_match_data exynos4x12_of_data; ··· 387 382 extern const struct samsung_pinctrl_of_match_data exynos5420_of_data; 388 383 extern const struct samsung_pinctrl_of_match_data exynos5433_of_data; 389 384 extern const struct samsung_pinctrl_of_match_data exynos7_of_data; 385 + extern const struct samsung_pinctrl_of_match_data exynos7870_of_data; 390 386 extern const struct samsung_pinctrl_of_match_data exynos7885_of_data; 391 387 extern const struct samsung_pinctrl_of_match_data exynos850_of_data; 392 388 extern const struct samsung_pinctrl_of_match_data exynos8895_of_data;
+40 -6
drivers/pinctrl/sophgo/Kconfig
··· 3 3 # Sophgo SoC PINCTRL drivers 4 4 # 5 5 6 - config PINCTRL_SOPHGO_CV18XX 7 - bool 6 + config PINCTRL_SOPHGO_COMMON 7 + tristate 8 8 select GENERIC_PINCTRL_GROUPS 9 9 select GENERIC_PINMUX_FUNCTIONS 10 10 select GENERIC_PINCONF 11 + 12 + config PINCTRL_SOPHGO_CV18XX_OPS 13 + bool 11 14 12 15 config PINCTRL_SOPHGO_CV1800B 13 16 tristate "Sophgo CV1800B SoC Pinctrl driver" 14 17 depends on ARCH_SOPHGO || COMPILE_TEST 15 18 depends on OF 16 - select PINCTRL_SOPHGO_CV18XX 19 + select PINCTRL_SOPHGO_COMMON 20 + select PINCTRL_SOPHGO_CV18XX_OPS 17 21 help 18 22 Say Y to select the pinctrl driver for CV1800B SoC. 19 23 This pin controller allows selecting the mux function for ··· 28 24 tristate "Sophgo CV1812H SoC Pinctrl driver" 29 25 depends on ARCH_SOPHGO || COMPILE_TEST 30 26 depends on OF 31 - select PINCTRL_SOPHGO_CV18XX 27 + select PINCTRL_SOPHGO_COMMON 28 + select PINCTRL_SOPHGO_CV18XX_OPS 32 29 help 33 30 Say Y to select the pinctrl driver for CV1812H SoC. 34 31 This pin controller allows selecting the mux function for ··· 40 35 tristate "Sophgo SG2000 SoC Pinctrl driver" 41 36 depends on ARCH_SOPHGO || COMPILE_TEST 42 37 depends on OF 43 - select PINCTRL_SOPHGO_CV18XX 38 + select PINCTRL_SOPHGO_COMMON 39 + select PINCTRL_SOPHGO_CV18XX_OPS 44 40 help 45 41 Say Y to select the pinctrl driver for SG2000 SoC. 46 42 This pin controller allows selecting the mux function for ··· 52 46 tristate "Sophgo SG2002 SoC Pinctrl driver" 53 47 depends on ARCH_SOPHGO || COMPILE_TEST 54 48 depends on OF 55 - select PINCTRL_SOPHGO_CV18XX 49 + select PINCTRL_SOPHGO_COMMON 50 + select PINCTRL_SOPHGO_CV18XX_OPS 56 51 help 57 52 Say Y to select the pinctrl driver for SG2002 SoC. 58 53 This pin controller allows selecting the mux function for 59 54 each pin. This driver can also be built as a module called 60 55 pinctrl-sg2002. 56 + 57 + config PINCTRL_SOPHGO_SG2042_OPS 58 + bool 59 + 60 + config PINCTRL_SOPHGO_SG2042 61 + tristate "Sophgo SG2042 SoC Pinctrl driver" 62 + depends on ARCH_SOPHGO || COMPILE_TEST 63 + depends on OF 64 + select PINCTRL_SOPHGO_COMMON 65 + select PINCTRL_SOPHGO_SG2042_OPS 66 + help 67 + Say Y to select the pinctrl driver for SG2042 SoC. 68 + This pin controller allows selecting the mux function for 69 + each pin. This driver can also be built as a module called 70 + pinctrl-sg2042. 71 + 72 + config PINCTRL_SOPHGO_SG2044 73 + tristate "Sophgo SG2044 SoC Pinctrl driver" 74 + depends on ARCH_SOPHGO || COMPILE_TEST 75 + depends on OF 76 + select PINCTRL_SOPHGO_COMMON 77 + select PINCTRL_SOPHGO_SG2042_OPS 78 + help 79 + Say Y to select the pinctrl driver for SG2044 SoC. 80 + This pin controller allows selecting the mux function for 81 + each pin. This driver can also be built as a module called 82 + pinctrl-sg2044.
+7 -1
drivers/pinctrl/sophgo/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 3 - obj-$(CONFIG_PINCTRL_SOPHGO_CV18XX) += pinctrl-cv18xx.o 3 + obj-$(CONFIG_PINCTRL_SOPHGO_COMMON) += pinctrl-sophgo.o 4 + pinctrl-sophgo-objs += pinctrl-sophgo-common.o 5 + pinctrl-sophgo-$(CONFIG_PINCTRL_SOPHGO_CV18XX_OPS) += pinctrl-cv18xx.o 6 + pinctrl-sophgo-$(CONFIG_PINCTRL_SOPHGO_SG2042_OPS) += pinctrl-sg2042-ops.o 7 + 4 8 obj-$(CONFIG_PINCTRL_SOPHGO_CV1800B) += pinctrl-cv1800b.o 5 9 obj-$(CONFIG_PINCTRL_SOPHGO_CV1812H) += pinctrl-cv1812h.o 6 10 obj-$(CONFIG_PINCTRL_SOPHGO_SG2000) += pinctrl-sg2000.o 7 11 obj-$(CONFIG_PINCTRL_SOPHGO_SG2002) += pinctrl-sg2002.o 12 + obj-$(CONFIG_PINCTRL_SOPHGO_SG2042) += pinctrl-sg2042.o 13 + obj-$(CONFIG_PINCTRL_SOPHGO_SG2044) += pinctrl-sg2044.o
+18 -9
drivers/pinctrl/sophgo/pinctrl-cv1800b.c
··· 34 34 [VDDIO_SD0_SPI] = "VDDIO_SD0_SPI", 35 35 }; 36 36 37 - static int cv1800b_get_pull_up(struct cv1800_pin *pin, const u32 *psmap) 37 + static int cv1800b_get_pull_up(const struct sophgo_pin *sp, const u32 *psmap) 38 38 { 39 + const struct cv1800_pin *pin = sophgo_to_cv1800_pin(sp); 39 40 u32 pstate = psmap[pin->power_domain]; 40 41 enum cv1800_pin_io_type type = cv1800_pin_io_type(pin); 41 42 ··· 55 54 return -ENOTSUPP; 56 55 } 57 56 58 - static int cv1800b_get_pull_down(struct cv1800_pin *pin, const u32 *psmap) 57 + static int cv1800b_get_pull_down(const struct sophgo_pin *sp, const u32 *psmap) 59 58 { 59 + const struct cv1800_pin *pin = sophgo_to_cv1800_pin(sp); 60 60 u32 pstate = psmap[pin->power_domain]; 61 61 enum cv1800_pin_io_type type = cv1800_pin_io_type(pin); 62 62 ··· 110 108 17800 111 109 }; 112 110 113 - static int cv1800b_get_oc_map(struct cv1800_pin *pin, const u32 *psmap, 111 + static int cv1800b_get_oc_map(const struct sophgo_pin *sp, const u32 *psmap, 114 112 const u32 **map) 115 113 { 114 + const struct cv1800_pin *pin = sophgo_to_cv1800_pin(sp); 116 115 enum cv1800_pin_io_type type = cv1800_pin_io_type(pin); 117 116 u32 pstate = psmap[pin->power_domain]; 118 117 ··· 156 153 1100000 157 154 }; 158 155 159 - static int cv1800b_get_schmitt_map(struct cv1800_pin *pin, const u32 *psmap, 156 + static int cv1800b_get_schmitt_map(const struct sophgo_pin *sp, const u32 *psmap, 160 157 const u32 **map) 161 158 { 159 + const struct cv1800_pin *pin = sophgo_to_cv1800_pin(sp); 162 160 enum cv1800_pin_io_type type = cv1800_pin_io_type(pin); 163 161 u32 pstate = psmap[pin->power_domain]; 164 162 ··· 181 177 return -ENOTSUPP; 182 178 } 183 179 184 - static const struct cv1800_vddio_cfg_ops cv1800b_vddio_cfg_ops = { 180 + static const struct sophgo_vddio_cfg_ops cv1800b_vddio_cfg_ops = { 185 181 .get_pull_up = cv1800b_get_pull_up, 186 182 .get_pull_down = cv1800b_get_pull_down, 187 183 .get_oc_map = cv1800b_get_oc_map, 188 - .get_schmitt_map = cv1800b_get_schmitt_map, 184 + .get_schmitt_map = cv1800b_get_schmitt_map, 189 185 }; 190 186 191 187 static const struct pinctrl_pin_desc cv1800b_pins[] = { ··· 437 433 CV1800_PINCONF_AREA_SYS, 0x120, 5), 438 434 }; 439 435 440 - static const struct cv1800_pinctrl_data cv1800b_pindata = { 436 + static const struct sophgo_pinctrl_data cv1800b_pindata = { 441 437 .pins = cv1800b_pins, 442 438 .pindata = cv1800b_pin_data, 443 439 .pdnames = cv1800b_power_domain_desc, 444 440 .vddio_ops = &cv1800b_vddio_cfg_ops, 441 + .cfg_ops = &cv1800_cfg_ops, 442 + .pctl_ops = &cv1800_pctrl_ops, 443 + .pmx_ops = &cv1800_pmx_ops, 444 + .pconf_ops = &cv1800_pconf_ops, 445 445 .npins = ARRAY_SIZE(cv1800b_pins), 446 - .npd = ARRAY_SIZE(cv1800b_power_domain_desc), 446 + .npds = ARRAY_SIZE(cv1800b_power_domain_desc), 447 + .pinsize = sizeof(struct cv1800_pin), 447 448 }; 448 449 449 450 static const struct of_device_id cv1800b_pinctrl_ids[] = { ··· 458 449 MODULE_DEVICE_TABLE(of, cv1800b_pinctrl_ids); 459 450 460 451 static struct platform_driver cv1800b_pinctrl_driver = { 461 - .probe = cv1800_pinctrl_probe, 452 + .probe = sophgo_pinctrl_probe, 462 453 .driver = { 463 454 .name = "cv1800b-pinctrl", 464 455 .suppress_bind_attrs = true,
+18 -9
drivers/pinctrl/sophgo/pinctrl-cv1812h.c
··· 40 40 [VDDIO_VIVO] = "VDDIO_VIVO", 41 41 }; 42 42 43 - static int cv1812h_get_pull_up(struct cv1800_pin *pin, const u32 *psmap) 43 + static int cv1812h_get_pull_up(const struct sophgo_pin *sp, const u32 *psmap) 44 44 { 45 + const struct cv1800_pin *pin = sophgo_to_cv1800_pin(sp); 45 46 u32 pstate = psmap[pin->power_domain]; 46 47 enum cv1800_pin_io_type type = cv1800_pin_io_type(pin); 47 48 ··· 61 60 return -ENOTSUPP; 62 61 } 63 62 64 - static int cv1812h_get_pull_down(struct cv1800_pin *pin, const u32 *psmap) 63 + static int cv1812h_get_pull_down(const struct sophgo_pin *sp, const u32 *psmap) 65 64 { 65 + const struct cv1800_pin *pin = sophgo_to_cv1800_pin(sp); 66 66 u32 pstate = psmap[pin->power_domain]; 67 67 enum cv1800_pin_io_type type = cv1800_pin_io_type(pin); 68 68 ··· 116 114 17800 117 115 }; 118 116 119 - static int cv1812h_get_oc_map(struct cv1800_pin *pin, const u32 *psmap, 117 + static int cv1812h_get_oc_map(const struct sophgo_pin *sp, const u32 *psmap, 120 118 const u32 **map) 121 119 { 120 + const struct cv1800_pin *pin = sophgo_to_cv1800_pin(sp); 122 121 enum cv1800_pin_io_type type = cv1800_pin_io_type(pin); 123 122 u32 pstate = psmap[pin->power_domain]; 124 123 ··· 162 159 1100000 163 160 }; 164 161 165 - static int cv1812h_get_schmitt_map(struct cv1800_pin *pin, const u32 *psmap, 162 + static int cv1812h_get_schmitt_map(const struct sophgo_pin *sp, const u32 *psmap, 166 163 const u32 **map) 167 164 { 165 + const struct cv1800_pin *pin = sophgo_to_cv1800_pin(sp); 168 166 enum cv1800_pin_io_type type = cv1800_pin_io_type(pin); 169 167 u32 pstate = psmap[pin->power_domain]; 170 168 ··· 187 183 return -ENOTSUPP; 188 184 } 189 185 190 - static const struct cv1800_vddio_cfg_ops cv1812h_vddio_cfg_ops = { 186 + static const struct sophgo_vddio_cfg_ops cv1812h_vddio_cfg_ops = { 191 187 .get_pull_up = cv1812h_get_pull_up, 192 188 .get_pull_down = cv1812h_get_pull_down, 193 189 .get_oc_map = cv1812h_get_oc_map, 194 - .get_schmitt_map = cv1812h_get_schmitt_map, 190 + .get_schmitt_map = cv1812h_get_schmitt_map, 195 191 }; 196 192 197 193 static const struct pinctrl_pin_desc cv1812h_pins[] = { ··· 746 742 CV1800_PINCONF_AREA_RTC, 0x028), 747 743 }; 748 744 749 - static const struct cv1800_pinctrl_data cv1812h_pindata = { 745 + static const struct sophgo_pinctrl_data cv1812h_pindata = { 750 746 .pins = cv1812h_pins, 751 747 .pindata = cv1812h_pin_data, 752 748 .pdnames = cv1812h_power_domain_desc, 753 749 .vddio_ops = &cv1812h_vddio_cfg_ops, 750 + .cfg_ops = &cv1800_cfg_ops, 751 + .pctl_ops = &cv1800_pctrl_ops, 752 + .pmx_ops = &cv1800_pmx_ops, 753 + .pconf_ops = &cv1800_pconf_ops, 754 754 .npins = ARRAY_SIZE(cv1812h_pins), 755 - .npd = ARRAY_SIZE(cv1812h_power_domain_desc), 755 + .npds = ARRAY_SIZE(cv1812h_power_domain_desc), 756 + .pinsize = sizeof(struct cv1800_pin), 756 757 }; 757 758 758 759 static const struct of_device_id cv1812h_pinctrl_ids[] = { ··· 767 758 MODULE_DEVICE_TABLE(of, cv1812h_pinctrl_ids); 768 759 769 760 static struct platform_driver cv1812h_pinctrl_driver = { 770 - .probe = cv1800_pinctrl_probe, 761 + .probe = sophgo_pinctrl_probe, 771 762 .driver = { 772 763 .name = "cv1812h-pinctrl", 773 764 .suppress_bind_attrs = true,
+142 -456
drivers/pinctrl/sophgo/pinctrl-cv18xx.c
··· 15 15 #include <linux/seq_file.h> 16 16 #include <linux/spinlock.h> 17 17 18 - #include <linux/pinctrl/consumer.h> 19 - #include <linux/pinctrl/machine.h> 20 18 #include <linux/pinctrl/pinconf-generic.h> 21 19 #include <linux/pinctrl/pinconf.h> 22 20 #include <linux/pinctrl/pinctrl.h> ··· 22 24 23 25 #include <dt-bindings/pinctrl/pinctrl-cv18xx.h> 24 26 25 - #include "../core.h" 26 27 #include "../pinctrl-utils.h" 27 - #include "../pinconf.h" 28 28 #include "../pinmux.h" 29 29 #include "pinctrl-cv18xx.h" 30 30 31 - struct cv1800_pinctrl { 32 - struct device *dev; 33 - struct pinctrl_dev *pctl_dev; 34 - const struct cv1800_pinctrl_data *data; 35 - struct pinctrl_desc pdesc; 31 + struct cv1800_priv { 36 32 u32 *power_cfg; 37 - 38 - struct mutex mutex; 39 - raw_spinlock_t lock; 40 - 41 33 void __iomem *regs[2]; 42 34 }; 43 - 44 - struct cv1800_pin_mux_config { 45 - struct cv1800_pin *pin; 46 - u32 config; 47 - }; 48 - 49 - static unsigned int cv1800_dt_get_pin(u32 value) 50 - { 51 - return value & GENMASK(15, 0); 52 - } 53 35 54 36 static unsigned int cv1800_dt_get_pin_mux(u32 value) 55 37 { ··· 44 66 #define cv1800_pinctrl_get_component_addr(pctrl, _comp) \ 45 67 ((pctrl)->regs[(_comp)->area] + (_comp)->offset) 46 68 47 - static int cv1800_cmp_pin(const void *key, const void *pivot) 48 - { 49 - const struct cv1800_pin *pin = pivot; 50 - int pin_id = (long)key; 51 - int pivid = pin->pin; 52 - 53 - return pin_id - pivid; 54 - } 55 - 56 - static int cv1800_set_power_cfg(struct cv1800_pinctrl *pctrl, 69 + static int cv1800_set_power_cfg(struct sophgo_pinctrl *pctrl, 57 70 u8 domain, u32 cfg) 58 71 { 59 - if (domain >= pctrl->data->npd) 72 + struct cv1800_priv *priv = pctrl->priv_ctrl; 73 + 74 + if (domain >= pctrl->data->npds) 60 75 return -ENOTSUPP; 61 76 62 - if (pctrl->power_cfg[domain] && pctrl->power_cfg[domain] != cfg) 77 + if (priv->power_cfg[domain] && priv->power_cfg[domain] != cfg) 63 78 return -EINVAL; 64 79 65 - pctrl->power_cfg[domain] = cfg; 80 + priv->power_cfg[domain] = cfg; 66 81 67 82 return 0; 68 83 } 69 84 70 - static int cv1800_get_power_cfg(struct cv1800_pinctrl *pctrl, 85 + static int cv1800_get_power_cfg(struct sophgo_pinctrl *pctrl, 71 86 u8 domain) 72 87 { 73 - return pctrl->power_cfg[domain]; 74 - } 88 + struct cv1800_priv *priv = pctrl->priv_ctrl; 75 89 76 - static struct cv1800_pin *cv1800_get_pin(struct cv1800_pinctrl *pctrl, 77 - unsigned long pin) 78 - { 79 - return bsearch((void *)pin, pctrl->data->pindata, pctrl->data->npins, 80 - sizeof(struct cv1800_pin), cv1800_cmp_pin); 90 + return priv->power_cfg[domain]; 81 91 } 82 92 83 93 #define PIN_BGA_ID_OFFSET 8 ··· 78 112 "ETH" 79 113 }; 80 114 81 - static const char *cv1800_get_power_cfg_desc(struct cv1800_pinctrl *pctrl, 115 + static const char *cv1800_get_power_cfg_desc(struct sophgo_pinctrl *pctrl, 82 116 u8 domain) 83 117 { 84 118 return pctrl->data->pdnames[domain]; ··· 87 121 static void cv1800_pctrl_dbg_show(struct pinctrl_dev *pctldev, 88 122 struct seq_file *seq, unsigned int pin_id) 89 123 { 90 - struct cv1800_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); 91 - struct cv1800_pin *pin = cv1800_get_pin(pctrl, pin_id); 124 + struct sophgo_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); 125 + struct cv1800_priv *priv = pctrl->priv_ctrl; 126 + const struct sophgo_pin *sp = sophgo_get_pin(pctrl, pin_id); 127 + const struct cv1800_pin *pin = sophgo_to_cv1800_pin(sp); 92 128 enum cv1800_pin_io_type type = cv1800_pin_io_type(pin); 129 + u32 pin_hwid = pin->pin.id; 93 130 u32 value; 94 131 void __iomem *reg; 95 132 96 - if (pin->pin >> PIN_BGA_ID_OFFSET) 133 + if (pin_hwid >> PIN_BGA_ID_OFFSET) 97 134 seq_printf(seq, "pos: %c%u ", 98 - 'A' + (pin->pin >> PIN_BGA_ID_OFFSET) - 1, 99 - pin->pin & PIN_BGA_ID_MASK); 135 + 'A' + (pin_hwid >> PIN_BGA_ID_OFFSET) - 1, 136 + pin_hwid & PIN_BGA_ID_MASK); 100 137 else 101 - seq_printf(seq, "pos: %u ", pin->pin); 138 + seq_printf(seq, "pos: %u ", pin_hwid); 102 139 103 140 seq_printf(seq, "power-domain: %s ", 104 141 cv1800_get_power_cfg_desc(pctrl, pin->power_domain)); 105 142 seq_printf(seq, "type: %s ", io_type_desc[type]); 106 143 107 - reg = cv1800_pinctrl_get_component_addr(pctrl, &pin->mux); 144 + reg = cv1800_pinctrl_get_component_addr(priv, &pin->mux); 108 145 value = readl(reg); 109 146 seq_printf(seq, "mux: 0x%08x ", value); 110 147 111 - if (pin->flags & CV1800_PIN_HAVE_MUX2) { 112 - reg = cv1800_pinctrl_get_component_addr(pctrl, &pin->mux2); 148 + if (pin->pin.flags & CV1800_PIN_HAVE_MUX2) { 149 + reg = cv1800_pinctrl_get_component_addr(priv, &pin->mux2); 113 150 value = readl(reg); 114 151 seq_printf(seq, "mux2: 0x%08x ", value); 115 152 } 116 153 117 154 if (type == IO_TYPE_1V8_ONLY || type == IO_TYPE_1V8_OR_3V3) { 118 - reg = cv1800_pinctrl_get_component_addr(pctrl, &pin->conf); 155 + reg = cv1800_pinctrl_get_component_addr(priv, &pin->conf); 119 156 value = readl(reg); 120 157 seq_printf(seq, "conf: 0x%08x ", value); 121 158 } 122 159 } 123 160 124 - static int cv1800_verify_pinmux_config(const struct cv1800_pin_mux_config *config) 161 + static int cv1800_verify_pinmux_config(const struct sophgo_pin_mux_config *config) 125 162 { 163 + struct cv1800_pin *pin = sophgo_to_cv1800_pin(config->pin); 126 164 unsigned int mux = cv1800_dt_get_pin_mux(config->config); 127 165 unsigned int mux2 = cv1800_dt_get_pin_mux2(config->config); 128 166 129 - if (mux > config->pin->mux.max) 167 + if (mux > pin->mux.max) 130 168 return -EINVAL; 131 169 132 - if (config->pin->flags & CV1800_PIN_HAVE_MUX2) { 133 - if (mux != config->pin->mux2.pfunc) 170 + if (pin->pin.flags & CV1800_PIN_HAVE_MUX2) { 171 + if (mux != pin->mux2.pfunc) 134 172 return -EINVAL; 135 173 136 - if (mux2 > config->pin->mux2.max) 174 + if (mux2 > pin->mux2.max) 137 175 return -EINVAL; 138 176 } else { 139 177 if (mux2 != PIN_MUX_INVALD) ··· 147 177 return 0; 148 178 } 149 179 150 - static int cv1800_verify_pin_group(const struct cv1800_pin_mux_config *mux, 151 - unsigned long npins) 180 + static int cv1800_verify_pin_group(const struct sophgo_pin_mux_config *mux, 181 + unsigned int npins) 152 182 { 183 + struct cv1800_pin *pin; 153 184 enum cv1800_pin_io_type type; 154 185 u8 power_domain; 155 186 int i; ··· 158 187 if (npins == 1) 159 188 return 0; 160 189 161 - type = cv1800_pin_io_type(mux[0].pin); 162 - power_domain = mux[0].pin->power_domain; 190 + pin = sophgo_to_cv1800_pin(mux[0].pin); 191 + type = cv1800_pin_io_type(pin); 192 + power_domain = pin->power_domain; 163 193 164 194 for (i = 0; i < npins; i++) { 165 - if (type != cv1800_pin_io_type(mux[i].pin) || 166 - power_domain != mux[i].pin->power_domain) 195 + pin = sophgo_to_cv1800_pin(mux[i].pin); 196 + 197 + if (type != cv1800_pin_io_type(pin) || 198 + power_domain != pin->power_domain) 167 199 return -ENOTSUPP; 168 200 } 169 201 170 202 return 0; 171 203 } 172 204 173 - static int cv1800_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev, 174 - struct device_node *np, 175 - struct pinctrl_map **maps, 176 - unsigned int *num_maps) 205 + static int cv1800_dt_node_to_map_post(struct device_node *cur, 206 + struct sophgo_pinctrl *pctrl, 207 + struct sophgo_pin_mux_config *pinmuxs, 208 + unsigned int npins) 177 209 { 178 - struct cv1800_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); 179 - struct device *dev = pctrl->dev; 180 - struct device_node *child; 181 - struct pinctrl_map *map; 182 - const char **grpnames; 183 - const char *grpname; 184 - int ngroups = 0; 185 - int nmaps = 0; 210 + const struct cv1800_pin *pin = sophgo_to_cv1800_pin(pinmuxs[0].pin); 211 + u32 power; 186 212 int ret; 187 213 188 - for_each_available_child_of_node(np, child) 189 - ngroups += 1; 214 + ret = of_property_read_u32(cur, "power-source", &power); 215 + if (ret) 216 + return ret; 190 217 191 - grpnames = devm_kcalloc(dev, ngroups, sizeof(*grpnames), GFP_KERNEL); 192 - if (!grpnames) 193 - return -ENOMEM; 218 + if (!(power == PIN_POWER_STATE_3V3 || power == PIN_POWER_STATE_1V8)) 219 + return -ENOTSUPP; 194 220 195 - map = kcalloc(ngroups * 2, sizeof(*map), GFP_KERNEL); 196 - if (!map) 197 - return -ENOMEM; 198 - 199 - ngroups = 0; 200 - mutex_lock(&pctrl->mutex); 201 - for_each_available_child_of_node(np, child) { 202 - int npins = of_property_count_u32_elems(child, "pinmux"); 203 - unsigned int *pins; 204 - struct cv1800_pin_mux_config *pinmuxs; 205 - u32 config, power; 206 - int i; 207 - 208 - if (npins < 1) { 209 - dev_err(dev, "invalid pinctrl group %pOFn.%pOFn\n", 210 - np, child); 211 - ret = -EINVAL; 212 - goto dt_failed; 213 - } 214 - 215 - grpname = devm_kasprintf(dev, GFP_KERNEL, "%pOFn.%pOFn", 216 - np, child); 217 - if (!grpname) { 218 - ret = -ENOMEM; 219 - goto dt_failed; 220 - } 221 - 222 - grpnames[ngroups++] = grpname; 223 - 224 - pins = devm_kcalloc(dev, npins, sizeof(*pins), GFP_KERNEL); 225 - if (!pins) { 226 - ret = -ENOMEM; 227 - goto dt_failed; 228 - } 229 - 230 - pinmuxs = devm_kcalloc(dev, npins, sizeof(*pinmuxs), GFP_KERNEL); 231 - if (!pinmuxs) { 232 - ret = -ENOMEM; 233 - goto dt_failed; 234 - } 235 - 236 - for (i = 0; i < npins; i++) { 237 - ret = of_property_read_u32_index(child, "pinmux", 238 - i, &config); 239 - if (ret) 240 - goto dt_failed; 241 - 242 - pins[i] = cv1800_dt_get_pin(config); 243 - pinmuxs[i].config = config; 244 - pinmuxs[i].pin = cv1800_get_pin(pctrl, pins[i]); 245 - 246 - if (!pinmuxs[i].pin) { 247 - dev_err(dev, "failed to get pin %d\n", pins[i]); 248 - ret = -ENODEV; 249 - goto dt_failed; 250 - } 251 - 252 - ret = cv1800_verify_pinmux_config(&pinmuxs[i]); 253 - if (ret) { 254 - dev_err(dev, "group %s pin %d is invalid\n", 255 - grpname, i); 256 - goto dt_failed; 257 - } 258 - } 259 - 260 - ret = cv1800_verify_pin_group(pinmuxs, npins); 261 - if (ret) { 262 - dev_err(dev, "group %s is invalid\n", grpname); 263 - goto dt_failed; 264 - } 265 - 266 - ret = of_property_read_u32(child, "power-source", &power); 267 - if (ret) 268 - goto dt_failed; 269 - 270 - if (!(power == PIN_POWER_STATE_3V3 || power == PIN_POWER_STATE_1V8)) { 271 - dev_err(dev, "group %s have unsupported power: %u\n", 272 - grpname, power); 273 - ret = -ENOTSUPP; 274 - goto dt_failed; 275 - } 276 - 277 - ret = cv1800_set_power_cfg(pctrl, pinmuxs[0].pin->power_domain, 278 - power); 279 - if (ret) 280 - goto dt_failed; 281 - 282 - map[nmaps].type = PIN_MAP_TYPE_MUX_GROUP; 283 - map[nmaps].data.mux.function = np->name; 284 - map[nmaps].data.mux.group = grpname; 285 - nmaps += 1; 286 - 287 - ret = pinconf_generic_parse_dt_config(child, pctldev, 288 - &map[nmaps].data.configs.configs, 289 - &map[nmaps].data.configs.num_configs); 290 - if (ret) { 291 - dev_err(dev, "failed to parse pin config of group %s: %d\n", 292 - grpname, ret); 293 - goto dt_failed; 294 - } 295 - 296 - ret = pinctrl_generic_add_group(pctldev, grpname, 297 - pins, npins, pinmuxs); 298 - if (ret < 0) { 299 - dev_err(dev, "failed to add group %s: %d\n", grpname, ret); 300 - goto dt_failed; 301 - } 302 - 303 - /* don't create a map if there are no pinconf settings */ 304 - if (map[nmaps].data.configs.num_configs == 0) 305 - continue; 306 - 307 - map[nmaps].type = PIN_MAP_TYPE_CONFIGS_GROUP; 308 - map[nmaps].data.configs.group_or_pin = grpname; 309 - nmaps += 1; 310 - } 311 - 312 - ret = pinmux_generic_add_function(pctldev, np->name, 313 - grpnames, ngroups, NULL); 314 - if (ret < 0) { 315 - dev_err(dev, "error adding function %s: %d\n", np->name, ret); 316 - goto function_failed; 317 - } 318 - 319 - *maps = map; 320 - *num_maps = nmaps; 321 - mutex_unlock(&pctrl->mutex); 322 - 323 - return 0; 324 - 325 - dt_failed: 326 - of_node_put(child); 327 - function_failed: 328 - pinctrl_utils_free_map(pctldev, map, nmaps); 329 - mutex_unlock(&pctrl->mutex); 330 - return ret; 221 + return cv1800_set_power_cfg(pctrl, pin->power_domain, power); 331 222 } 332 223 333 - static const struct pinctrl_ops cv1800_pctrl_ops = { 224 + const struct pinctrl_ops cv1800_pctrl_ops = { 334 225 .get_groups_count = pinctrl_generic_get_group_count, 335 226 .get_group_name = pinctrl_generic_get_group_name, 336 227 .get_group_pins = pinctrl_generic_get_group_pins, 337 228 .pin_dbg_show = cv1800_pctrl_dbg_show, 338 - .dt_node_to_map = cv1800_pctrl_dt_node_to_map, 229 + .dt_node_to_map = sophgo_pctrl_dt_node_to_map, 339 230 .dt_free_map = pinctrl_utils_free_map, 340 231 }; 232 + EXPORT_SYMBOL_GPL(cv1800_pctrl_ops); 341 233 342 - static int cv1800_pmx_set_mux(struct pinctrl_dev *pctldev, 343 - unsigned int fsel, unsigned int gsel) 234 + static void cv1800_set_pinmux_config(struct sophgo_pinctrl *pctrl, 235 + const struct sophgo_pin *sp, u32 config) 344 236 { 345 - struct cv1800_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); 346 - const struct group_desc *group; 347 - const struct cv1800_pin_mux_config *configs; 348 - unsigned int i; 237 + const struct cv1800_pin *pin = sophgo_to_cv1800_pin(sp); 238 + struct cv1800_priv *priv = pctrl->priv_ctrl; 239 + void __iomem *reg_mux; 240 + void __iomem *reg_mux2; 241 + u32 mux; 242 + u32 mux2; 349 243 350 - group = pinctrl_generic_get_group(pctldev, gsel); 351 - if (!group) 352 - return -EINVAL; 244 + reg_mux = cv1800_pinctrl_get_component_addr(priv, &pin->mux); 245 + reg_mux2 = cv1800_pinctrl_get_component_addr(priv, &pin->mux2); 246 + mux = cv1800_dt_get_pin_mux(config); 247 + mux2 = cv1800_dt_get_pin_mux2(config); 353 248 354 - configs = group->data; 355 - 356 - for (i = 0; i < group->grp.npins; i++) { 357 - const struct cv1800_pin *pin = configs[i].pin; 358 - u32 value = configs[i].config; 359 - void __iomem *reg_mux; 360 - void __iomem *reg_mux2; 361 - unsigned long flags; 362 - u32 mux; 363 - u32 mux2; 364 - 365 - reg_mux = cv1800_pinctrl_get_component_addr(pctrl, &pin->mux); 366 - reg_mux2 = cv1800_pinctrl_get_component_addr(pctrl, &pin->mux2); 367 - mux = cv1800_dt_get_pin_mux(value); 368 - mux2 = cv1800_dt_get_pin_mux2(value); 369 - 370 - raw_spin_lock_irqsave(&pctrl->lock, flags); 371 - writel_relaxed(mux, reg_mux); 372 - if (mux2 != PIN_MUX_INVALD) 373 - writel_relaxed(mux2, reg_mux2); 374 - raw_spin_unlock_irqrestore(&pctrl->lock, flags); 375 - } 376 - 377 - return 0; 249 + writel_relaxed(mux, reg_mux); 250 + if (mux2 != PIN_MUX_INVALD) 251 + writel_relaxed(mux2, reg_mux2); 378 252 } 379 253 380 - static const struct pinmux_ops cv1800_pmx_ops = { 254 + const struct pinmux_ops cv1800_pmx_ops = { 381 255 .get_functions_count = pinmux_generic_get_function_count, 382 256 .get_function_name = pinmux_generic_get_function_name, 383 257 .get_function_groups = pinmux_generic_get_function_groups, 384 - .set_mux = cv1800_pmx_set_mux, 258 + .set_mux = sophgo_pmx_set_mux, 385 259 .strict = true, 386 260 }; 261 + EXPORT_SYMBOL_GPL(cv1800_pmx_ops); 387 262 388 263 #define PIN_IO_PULLUP BIT(2) 389 264 #define PIN_IO_PULLDOWN BIT(3) ··· 238 421 #define PIN_IO_BUS_HOLD BIT(10) 239 422 #define PIN_IO_OUT_FAST_SLEW BIT(11) 240 423 241 - static u32 cv1800_pull_down_typical_resistor(struct cv1800_pinctrl *pctrl, 242 - struct cv1800_pin *pin) 243 - { 244 - return pctrl->data->vddio_ops->get_pull_down(pin, pctrl->power_cfg); 245 - } 246 - 247 - static u32 cv1800_pull_up_typical_resistor(struct cv1800_pinctrl *pctrl, 248 - struct cv1800_pin *pin) 249 - { 250 - return pctrl->data->vddio_ops->get_pull_up(pin, pctrl->power_cfg); 251 - } 252 - 253 - static int cv1800_pinctrl_oc2reg(struct cv1800_pinctrl *pctrl, 254 - struct cv1800_pin *pin, u32 target) 255 - { 256 - const u32 *map; 257 - int i, len; 258 - 259 - len = pctrl->data->vddio_ops->get_oc_map(pin, pctrl->power_cfg, &map); 260 - if (len < 0) 261 - return len; 262 - 263 - for (i = 0; i < len; i++) { 264 - if (map[i] >= target) 265 - return i; 266 - } 267 - 268 - return -EINVAL; 269 - } 270 - 271 - static int cv1800_pinctrl_reg2oc(struct cv1800_pinctrl *pctrl, 272 - struct cv1800_pin *pin, u32 reg) 273 - { 274 - const u32 *map; 275 - int len; 276 - 277 - len = pctrl->data->vddio_ops->get_oc_map(pin, pctrl->power_cfg, &map); 278 - if (len < 0) 279 - return len; 280 - 281 - if (reg >= len) 282 - return -EINVAL; 283 - 284 - return map[reg]; 285 - } 286 - 287 - static int cv1800_pinctrl_schmitt2reg(struct cv1800_pinctrl *pctrl, 288 - struct cv1800_pin *pin, u32 target) 289 - { 290 - const u32 *map; 291 - int i, len; 292 - 293 - len = pctrl->data->vddio_ops->get_schmitt_map(pin, pctrl->power_cfg, 294 - &map); 295 - if (len < 0) 296 - return len; 297 - 298 - for (i = 0; i < len; i++) { 299 - if (map[i] == target) 300 - return i; 301 - } 302 - 303 - return -EINVAL; 304 - } 305 - 306 - static int cv1800_pinctrl_reg2schmitt(struct cv1800_pinctrl *pctrl, 307 - struct cv1800_pin *pin, u32 reg) 308 - { 309 - const u32 *map; 310 - int len; 311 - 312 - len = pctrl->data->vddio_ops->get_schmitt_map(pin, pctrl->power_cfg, 313 - &map); 314 - if (len < 0) 315 - return len; 316 - 317 - if (reg >= len) 318 - return -EINVAL; 319 - 320 - return map[reg]; 321 - } 322 - 323 424 static int cv1800_pconf_get(struct pinctrl_dev *pctldev, 324 425 unsigned int pin_id, unsigned long *config) 325 426 { 326 - struct cv1800_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); 427 + struct sophgo_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); 428 + struct cv1800_priv *priv = pctrl->priv_ctrl; 327 429 int param = pinconf_to_config_param(*config); 328 - struct cv1800_pin *pin = cv1800_get_pin(pctrl, pin_id); 430 + const struct sophgo_pin *sp = sophgo_get_pin(pctrl, pin_id); 431 + const struct cv1800_pin *pin = sophgo_to_cv1800_pin(sp); 329 432 enum cv1800_pin_io_type type; 330 433 u32 value; 331 434 u32 arg; ··· 259 522 if (type == IO_TYPE_ETH || type == IO_TYPE_AUDIO) 260 523 return -ENOTSUPP; 261 524 262 - value = readl(cv1800_pinctrl_get_component_addr(pctrl, &pin->conf)); 525 + value = readl(cv1800_pinctrl_get_component_addr(priv, &pin->conf)); 263 526 264 527 switch (param) { 265 528 case PIN_CONFIG_BIAS_PULL_DOWN: 266 529 enabled = FIELD_GET(PIN_IO_PULLDOWN, value); 267 - arg = cv1800_pull_down_typical_resistor(pctrl, pin); 530 + arg = sophgo_pinctrl_typical_pull_down(pctrl, sp, priv->power_cfg); 268 531 break; 269 532 case PIN_CONFIG_BIAS_PULL_UP: 270 533 enabled = FIELD_GET(PIN_IO_PULLUP, value); 271 - arg = cv1800_pull_up_typical_resistor(pctrl, pin); 534 + arg = sophgo_pinctrl_typical_pull_up(pctrl, sp, priv->power_cfg); 272 535 break; 273 536 case PIN_CONFIG_DRIVE_STRENGTH_UA: 274 537 enabled = true; 275 538 arg = FIELD_GET(PIN_IO_DRIVE, value); 276 - ret = cv1800_pinctrl_reg2oc(pctrl, pin, arg); 539 + ret = sophgo_pinctrl_reg2oc(pctrl, sp, priv->power_cfg, arg); 277 540 if (ret < 0) 278 541 return ret; 279 542 arg = ret; 280 543 break; 281 544 case PIN_CONFIG_INPUT_SCHMITT_UV: 282 545 arg = FIELD_GET(PIN_IO_SCHMITT, value); 283 - ret = cv1800_pinctrl_reg2schmitt(pctrl, pin, arg); 546 + ret = sophgo_pinctrl_reg2schmitt(pctrl, sp, priv->power_cfg, arg); 284 547 if (ret < 0) 285 548 return ret; 286 549 arg = ret; ··· 307 570 return enabled ? 0 : -EINVAL; 308 571 } 309 572 310 - static int cv1800_pinconf_compute_config(struct cv1800_pinctrl *pctrl, 311 - struct cv1800_pin *pin, 573 + static int cv1800_pinconf_compute_config(struct sophgo_pinctrl *pctrl, 574 + const struct sophgo_pin *sp, 312 575 unsigned long *configs, 313 576 unsigned int num_configs, 314 - u32 *value) 577 + u32 *value, u32 *mask) 315 578 { 579 + struct cv1800_priv *priv = pctrl->priv_ctrl; 580 + const struct cv1800_pin *pin = sophgo_to_cv1800_pin(sp); 316 581 int i; 317 - u32 v = 0; 582 + u32 v = 0, m = 0; 318 583 enum cv1800_pin_io_type type; 319 584 int ret; 320 585 ··· 335 596 case PIN_CONFIG_BIAS_PULL_DOWN: 336 597 v &= ~PIN_IO_PULLDOWN; 337 598 v |= FIELD_PREP(PIN_IO_PULLDOWN, arg); 599 + m |= PIN_IO_PULLDOWN; 338 600 break; 339 601 case PIN_CONFIG_BIAS_PULL_UP: 340 602 v &= ~PIN_IO_PULLUP; 341 603 v |= FIELD_PREP(PIN_IO_PULLUP, arg); 604 + m |= PIN_IO_PULLUP; 342 605 break; 343 606 case PIN_CONFIG_DRIVE_STRENGTH_UA: 344 - ret = cv1800_pinctrl_oc2reg(pctrl, pin, arg); 607 + ret = sophgo_pinctrl_oc2reg(pctrl, sp, 608 + priv->power_cfg, arg); 345 609 if (ret < 0) 346 610 return ret; 347 611 v &= ~PIN_IO_DRIVE; 348 612 v |= FIELD_PREP(PIN_IO_DRIVE, ret); 613 + m |= PIN_IO_DRIVE; 349 614 break; 350 615 case PIN_CONFIG_INPUT_SCHMITT_UV: 351 - ret = cv1800_pinctrl_schmitt2reg(pctrl, pin, arg); 616 + ret = sophgo_pinctrl_schmitt2reg(pctrl, sp, 617 + priv->power_cfg, arg); 352 618 if (ret < 0) 353 619 return ret; 354 620 v &= ~PIN_IO_SCHMITT; 355 621 v |= FIELD_PREP(PIN_IO_SCHMITT, ret); 622 + m |= PIN_IO_SCHMITT; 356 623 break; 357 624 case PIN_CONFIG_POWER_SOURCE: 358 625 /* Ignore power source as it is always fixed */ ··· 366 621 case PIN_CONFIG_SLEW_RATE: 367 622 v &= ~PIN_IO_OUT_FAST_SLEW; 368 623 v |= FIELD_PREP(PIN_IO_OUT_FAST_SLEW, arg); 624 + m |= PIN_IO_OUT_FAST_SLEW; 369 625 break; 370 626 case PIN_CONFIG_BIAS_BUS_HOLD: 371 627 v &= ~PIN_IO_BUS_HOLD; 372 628 v |= FIELD_PREP(PIN_IO_BUS_HOLD, arg); 629 + m |= PIN_IO_BUS_HOLD; 373 630 break; 374 631 default: 375 632 return -ENOTSUPP; ··· 379 632 } 380 633 381 634 *value = v; 635 + *mask = m; 382 636 383 637 return 0; 384 638 } 385 639 386 - static int cv1800_pin_set_config(struct cv1800_pinctrl *pctrl, 387 - unsigned int pin_id, 388 - u32 value) 640 + static int cv1800_set_pinconf_config(struct sophgo_pinctrl *pctrl, 641 + const struct sophgo_pin *sp, 642 + u32 value, u32 mask) 389 643 { 390 - struct cv1800_pin *pin = cv1800_get_pin(pctrl, pin_id); 391 - unsigned long flags; 644 + struct cv1800_priv *priv = pctrl->priv_ctrl; 645 + struct cv1800_pin *pin = sophgo_to_cv1800_pin(sp); 392 646 void __iomem *addr; 647 + u32 reg; 393 648 394 - if (!pin) 395 - return -EINVAL; 649 + addr = cv1800_pinctrl_get_component_addr(priv, &pin->conf); 396 650 397 - addr = cv1800_pinctrl_get_component_addr(pctrl, &pin->conf); 398 - 399 - raw_spin_lock_irqsave(&pctrl->lock, flags); 400 - writel(value, addr); 401 - raw_spin_unlock_irqrestore(&pctrl->lock, flags); 402 - 403 - return 0; 404 - } 405 - 406 - static int cv1800_pconf_set(struct pinctrl_dev *pctldev, 407 - unsigned int pin_id, unsigned long *configs, 408 - unsigned int num_configs) 409 - { 410 - struct cv1800_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); 411 - struct cv1800_pin *pin = cv1800_get_pin(pctrl, pin_id); 412 - u32 value; 413 - 414 - if (!pin) 415 - return -ENODEV; 416 - 417 - if (cv1800_pinconf_compute_config(pctrl, pin, 418 - configs, num_configs, &value)) 419 - return -ENOTSUPP; 420 - 421 - return cv1800_pin_set_config(pctrl, pin_id, value); 422 - } 423 - 424 - static int cv1800_pconf_group_set(struct pinctrl_dev *pctldev, 425 - unsigned int gsel, 426 - unsigned long *configs, 427 - unsigned int num_configs) 428 - { 429 - struct cv1800_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); 430 - const struct group_desc *group; 431 - const struct cv1800_pin_mux_config *pinmuxs; 432 - u32 value; 433 - int i; 434 - 435 - group = pinctrl_generic_get_group(pctldev, gsel); 436 - if (!group) 437 - return -EINVAL; 438 - 439 - pinmuxs = group->data; 440 - 441 - if (cv1800_pinconf_compute_config(pctrl, pinmuxs[0].pin, 442 - configs, num_configs, &value)) 443 - return -ENOTSUPP; 444 - 445 - for (i = 0; i < group->grp.npins; i++) 446 - cv1800_pin_set_config(pctrl, group->grp.pins[i], value); 651 + reg = readl(addr); 652 + reg &= ~mask; 653 + reg |= value; 654 + writel(reg, addr); 447 655 448 656 return 0; 449 657 } 450 658 451 - static const struct pinconf_ops cv1800_pconf_ops = { 659 + const struct pinconf_ops cv1800_pconf_ops = { 452 660 .pin_config_get = cv1800_pconf_get, 453 - .pin_config_set = cv1800_pconf_set, 454 - .pin_config_group_set = cv1800_pconf_group_set, 661 + .pin_config_set = sophgo_pconf_set, 662 + .pin_config_group_set = sophgo_pconf_group_set, 455 663 .is_generic = true, 456 664 }; 665 + EXPORT_SYMBOL_GPL(cv1800_pconf_ops); 457 666 458 - int cv1800_pinctrl_probe(struct platform_device *pdev) 667 + static int cv1800_pinctrl_init(struct platform_device *pdev, 668 + struct sophgo_pinctrl *pctrl) 459 669 { 460 - struct device *dev = &pdev->dev; 461 - struct cv1800_pinctrl *pctrl; 462 - const struct cv1800_pinctrl_data *pctrl_data; 463 - int ret; 670 + const struct sophgo_pinctrl_data *pctrl_data = pctrl->data; 671 + struct cv1800_priv *priv; 464 672 465 - pctrl_data = device_get_match_data(dev); 466 - if (!pctrl_data) 467 - return -ENODEV; 468 - 469 - if (pctrl_data->npins == 0 || pctrl_data->npd == 0) 470 - return dev_err_probe(dev, -EINVAL, "invalid pin data\n"); 471 - 472 - pctrl = devm_kzalloc(dev, sizeof(*pctrl), GFP_KERNEL); 473 - if (!pctrl) 673 + priv = devm_kzalloc(&pdev->dev, sizeof(struct cv1800_priv), GFP_KERNEL); 674 + if (!priv) 474 675 return -ENOMEM; 475 676 476 - pctrl->power_cfg = devm_kcalloc(dev, pctrl_data->npd, 477 - sizeof(u32), GFP_KERNEL); 478 - if (!pctrl->power_cfg) 677 + priv->power_cfg = devm_kcalloc(&pdev->dev, pctrl_data->npds, 678 + sizeof(u32), GFP_KERNEL); 679 + if (!priv->power_cfg) 479 680 return -ENOMEM; 480 681 481 - pctrl->regs[0] = devm_platform_ioremap_resource_byname(pdev, "sys"); 482 - if (IS_ERR(pctrl->regs[0])) 483 - return PTR_ERR(pctrl->regs[0]); 682 + priv->regs[0] = devm_platform_ioremap_resource_byname(pdev, "sys"); 683 + if (IS_ERR(priv->regs[0])) 684 + return PTR_ERR(priv->regs[0]); 484 685 485 - pctrl->regs[1] = devm_platform_ioremap_resource_byname(pdev, "rtc"); 486 - if (IS_ERR(pctrl->regs[1])) 487 - return PTR_ERR(pctrl->regs[1]); 686 + priv->regs[1] = devm_platform_ioremap_resource_byname(pdev, "rtc"); 687 + if (IS_ERR(priv->regs[1])) 688 + return PTR_ERR(priv->regs[1]); 488 689 489 - pctrl->pdesc.name = dev_name(dev); 490 - pctrl->pdesc.pins = pctrl_data->pins; 491 - pctrl->pdesc.npins = pctrl_data->npins; 492 - pctrl->pdesc.pctlops = &cv1800_pctrl_ops; 493 - pctrl->pdesc.pmxops = &cv1800_pmx_ops; 494 - pctrl->pdesc.confops = &cv1800_pconf_ops; 495 - pctrl->pdesc.owner = THIS_MODULE; 690 + pctrl->priv_ctrl = priv; 496 691 497 - pctrl->data = pctrl_data; 498 - pctrl->dev = dev; 499 - raw_spin_lock_init(&pctrl->lock); 500 - mutex_init(&pctrl->mutex); 501 - 502 - platform_set_drvdata(pdev, pctrl); 503 - 504 - ret = devm_pinctrl_register_and_init(dev, &pctrl->pdesc, 505 - pctrl, &pctrl->pctl_dev); 506 - if (ret) 507 - return dev_err_probe(dev, ret, 508 - "fail to register pinctrl driver\n"); 509 - 510 - return pinctrl_enable(pctrl->pctl_dev); 692 + return 0; 511 693 } 512 - EXPORT_SYMBOL_GPL(cv1800_pinctrl_probe); 694 + 695 + const struct sophgo_cfg_ops cv1800_cfg_ops = { 696 + .pctrl_init = cv1800_pinctrl_init, 697 + .verify_pinmux_config = cv1800_verify_pinmux_config, 698 + .verify_pin_group = cv1800_verify_pin_group, 699 + .dt_node_to_map_post = cv1800_dt_node_to_map_post, 700 + .compute_pinconf_config = cv1800_pinconf_compute_config, 701 + .set_pinconf_config = cv1800_set_pinconf_config, 702 + .set_pinmux_config = cv1800_set_pinmux_config, 703 + }; 704 + EXPORT_SYMBOL_GPL(cv1800_cfg_ops);
+25 -41
drivers/pinctrl/sophgo/pinctrl-cv18xx.h
··· 8 8 9 9 #include <linux/bits.h> 10 10 #include <linux/bitfield.h> 11 - #include <linux/device.h> 12 11 #include <linux/mutex.h> 13 12 #include <linux/spinlock.h> 14 13 #include <linux/platform_device.h> 15 14 #include <linux/pinctrl/pinctrl.h> 16 15 #include <linux/pinctrl/pinconf.h> 16 + 17 + #include "pinctrl-sophgo.h" 17 18 18 19 enum cv1800_pin_io_type { 19 20 IO_TYPE_1V8_ONLY = 0, ··· 50 49 #define CV1800_PIN_FLAG_IO_TYPE(type) \ 51 50 FIELD_PREP_CONST(CV1800_PIN_IO_TYPE, type) 52 51 struct cv1800_pin { 53 - u16 pin; 54 - u16 flags; 52 + struct sophgo_pin pin; 55 53 u8 power_domain; 56 54 struct cv1800_pinmux mux; 57 55 struct cv1800_pinmux2 mux2; 58 56 struct cv1800_pinconf conf; 59 57 }; 60 58 59 + #define sophgo_to_cv1800_pin(_pin) \ 60 + container_of((_pin), struct cv1800_pin, pin) 61 + 61 62 #define PIN_POWER_STATE_1V8 1800 62 63 #define PIN_POWER_STATE_3V3 3300 63 64 64 - /** 65 - * struct cv1800_vddio_cfg_ops - pin vddio operations 66 - * 67 - * @get_pull_up: get resistor for pull up; 68 - * @get_pull_down: get resistor for pull down. 69 - * @get_oc_map: get mapping for typical low level output current value to 70 - * register value map. 71 - * @get_schmitt_map: get mapping for register value to typical schmitt 72 - * threshold. 73 - */ 74 - struct cv1800_vddio_cfg_ops { 75 - int (*get_pull_up)(struct cv1800_pin *pin, const u32 *psmap); 76 - int (*get_pull_down)(struct cv1800_pin *pin, const u32 *psmap); 77 - int (*get_oc_map)(struct cv1800_pin *pin, const u32 *psmap, 78 - const u32 **map); 79 - int (*get_schmitt_map)(struct cv1800_pin *pin, const u32 *psmap, 80 - const u32 **map); 81 - }; 82 - 83 - struct cv1800_pinctrl_data { 84 - const struct pinctrl_pin_desc *pins; 85 - const struct cv1800_pin *pindata; 86 - const char * const *pdnames; 87 - const struct cv1800_vddio_cfg_ops *vddio_ops; 88 - u16 npins; 89 - u16 npd; 90 - }; 91 - 92 - static inline enum cv1800_pin_io_type cv1800_pin_io_type(struct cv1800_pin *pin) 65 + static inline enum cv1800_pin_io_type cv1800_pin_io_type(const struct cv1800_pin *pin) 93 66 { 94 - return FIELD_GET(CV1800_PIN_IO_TYPE, pin->flags); 67 + return FIELD_GET(CV1800_PIN_IO_TYPE, pin->pin.flags); 95 68 }; 96 69 97 - int cv1800_pinctrl_probe(struct platform_device *pdev); 70 + extern const struct pinctrl_ops cv1800_pctrl_ops; 71 + extern const struct pinmux_ops cv1800_pmx_ops; 72 + extern const struct pinconf_ops cv1800_pconf_ops; 73 + extern const struct sophgo_cfg_ops cv1800_cfg_ops; 98 74 99 75 #define CV1800_FUNC_PIN(_id, _power_domain, _type, \ 100 76 _mux_area, _mux_offset, _mux_func_max) \ 101 77 { \ 102 - .pin = (_id), \ 78 + .pin = { \ 79 + .id = (_id), \ 80 + .flags = CV1800_PIN_FLAG_IO_TYPE(_type), \ 81 + }, \ 103 82 .power_domain = (_power_domain), \ 104 - .flags = CV1800_PIN_FLAG_IO_TYPE(_type), \ 105 83 .mux = { \ 106 84 .area = (_mux_area), \ 107 85 .offset = (_mux_offset), \ ··· 92 112 _mux_area, _mux_offset, _mux_func_max, \ 93 113 _conf_area, _conf_offset) \ 94 114 { \ 95 - .pin = (_id), \ 115 + .pin = { \ 116 + .id = (_id), \ 117 + .flags = CV1800_PIN_FLAG_IO_TYPE(_type), \ 118 + }, \ 96 119 .power_domain = (_power_domain), \ 97 - .flags = CV1800_PIN_FLAG_IO_TYPE(_type), \ 98 120 .mux = { \ 99 121 .area = (_mux_area), \ 100 122 .offset = (_mux_offset), \ ··· 114 132 _mux2_func_max, \ 115 133 _conf_area, _conf_offset) \ 116 134 { \ 117 - .pin = (_id), \ 135 + .pin = { \ 136 + .id = (_id), \ 137 + .flags = CV1800_PIN_FLAG_IO_TYPE(_type) | \ 138 + CV1800_PIN_HAVE_MUX2, \ 139 + }, \ 118 140 .power_domain = (_power_domain), \ 119 - .flags = CV1800_PIN_FLAG_IO_TYPE(_type) | \ 120 - CV1800_PIN_HAVE_MUX2, \ 121 141 .mux = { \ 122 142 .area = (_mux_area), \ 123 143 .offset = (_mux_offset), \
+18 -9
drivers/pinctrl/sophgo/pinctrl-sg2000.c
··· 40 40 [VDDIO_VIVO] = "VDDIO_VIVO", 41 41 }; 42 42 43 - static int sg2000_get_pull_up(struct cv1800_pin *pin, const u32 *psmap) 43 + static int sg2000_get_pull_up(const struct sophgo_pin *sp, const u32 *psmap) 44 44 { 45 + const struct cv1800_pin *pin = sophgo_to_cv1800_pin(sp); 45 46 u32 pstate = psmap[pin->power_domain]; 46 47 enum cv1800_pin_io_type type = cv1800_pin_io_type(pin); 47 48 ··· 61 60 return -ENOTSUPP; 62 61 } 63 62 64 - static int sg2000_get_pull_down(struct cv1800_pin *pin, const u32 *psmap) 63 + static int sg2000_get_pull_down(const struct sophgo_pin *sp, const u32 *psmap) 65 64 { 65 + const struct cv1800_pin *pin = sophgo_to_cv1800_pin(sp); 66 66 u32 pstate = psmap[pin->power_domain]; 67 67 enum cv1800_pin_io_type type = cv1800_pin_io_type(pin); 68 68 ··· 116 114 17800 117 115 }; 118 116 119 - static int sg2000_get_oc_map(struct cv1800_pin *pin, const u32 *psmap, 117 + static int sg2000_get_oc_map(const struct sophgo_pin *sp, const u32 *psmap, 120 118 const u32 **map) 121 119 { 120 + const struct cv1800_pin *pin = sophgo_to_cv1800_pin(sp); 122 121 enum cv1800_pin_io_type type = cv1800_pin_io_type(pin); 123 122 u32 pstate = psmap[pin->power_domain]; 124 123 ··· 162 159 1100000 163 160 }; 164 161 165 - static int sg2000_get_schmitt_map(struct cv1800_pin *pin, const u32 *psmap, 162 + static int sg2000_get_schmitt_map(const struct sophgo_pin *sp, const u32 *psmap, 166 163 const u32 **map) 167 164 { 165 + const struct cv1800_pin *pin = sophgo_to_cv1800_pin(sp); 168 166 enum cv1800_pin_io_type type = cv1800_pin_io_type(pin); 169 167 u32 pstate = psmap[pin->power_domain]; 170 168 ··· 187 183 return -ENOTSUPP; 188 184 } 189 185 190 - static const struct cv1800_vddio_cfg_ops sg2000_vddio_cfg_ops = { 186 + static const struct sophgo_vddio_cfg_ops sg2000_vddio_cfg_ops = { 191 187 .get_pull_up = sg2000_get_pull_up, 192 188 .get_pull_down = sg2000_get_pull_down, 193 189 .get_oc_map = sg2000_get_oc_map, 194 - .get_schmitt_map = sg2000_get_schmitt_map, 190 + .get_schmitt_map = sg2000_get_schmitt_map, 195 191 }; 196 192 197 193 static const struct pinctrl_pin_desc sg2000_pins[] = { ··· 746 742 CV1800_PINCONF_AREA_RTC, 0x028), 747 743 }; 748 744 749 - static const struct cv1800_pinctrl_data sg2000_pindata = { 745 + static const struct sophgo_pinctrl_data sg2000_pindata = { 750 746 .pins = sg2000_pins, 751 747 .pindata = sg2000_pin_data, 752 748 .pdnames = sg2000_power_domain_desc, 753 749 .vddio_ops = &sg2000_vddio_cfg_ops, 750 + .cfg_ops = &cv1800_cfg_ops, 751 + .pctl_ops = &cv1800_pctrl_ops, 752 + .pmx_ops = &cv1800_pmx_ops, 753 + .pconf_ops = &cv1800_pconf_ops, 754 754 .npins = ARRAY_SIZE(sg2000_pins), 755 - .npd = ARRAY_SIZE(sg2000_power_domain_desc), 755 + .npds = ARRAY_SIZE(sg2000_power_domain_desc), 756 + .pinsize = sizeof(struct cv1800_pin), 756 757 }; 757 758 758 759 static const struct of_device_id sg2000_pinctrl_ids[] = { ··· 767 758 MODULE_DEVICE_TABLE(of, sg2000_pinctrl_ids); 768 759 769 760 static struct platform_driver sg2000_pinctrl_driver = { 770 - .probe = cv1800_pinctrl_probe, 761 + .probe = sophgo_pinctrl_probe, 771 762 .driver = { 772 763 .name = "sg2000-pinctrl", 773 764 .suppress_bind_attrs = true,
+18 -9
drivers/pinctrl/sophgo/pinctrl-sg2002.c
··· 34 34 [VDDIO_SD1] = "VDDIO_SD1", 35 35 }; 36 36 37 - static int sg2002_get_pull_up(struct cv1800_pin *pin, const u32 *psmap) 37 + static int sg2002_get_pull_up(const struct sophgo_pin *sp, const u32 *psmap) 38 38 { 39 + const struct cv1800_pin *pin = sophgo_to_cv1800_pin(sp); 39 40 u32 pstate = psmap[pin->power_domain]; 40 41 enum cv1800_pin_io_type type = cv1800_pin_io_type(pin); 41 42 ··· 55 54 return -ENOTSUPP; 56 55 } 57 56 58 - static int sg2002_get_pull_down(struct cv1800_pin *pin, const u32 *psmap) 57 + static int sg2002_get_pull_down(const struct sophgo_pin *sp, const u32 *psmap) 59 58 { 59 + const struct cv1800_pin *pin = sophgo_to_cv1800_pin(sp); 60 60 u32 pstate = psmap[pin->power_domain]; 61 61 enum cv1800_pin_io_type type = cv1800_pin_io_type(pin); 62 62 ··· 110 108 17800 111 109 }; 112 110 113 - static int sg2002_get_oc_map(struct cv1800_pin *pin, const u32 *psmap, 111 + static int sg2002_get_oc_map(const struct sophgo_pin *sp, const u32 *psmap, 114 112 const u32 **map) 115 113 { 114 + const struct cv1800_pin *pin = sophgo_to_cv1800_pin(sp); 116 115 enum cv1800_pin_io_type type = cv1800_pin_io_type(pin); 117 116 u32 pstate = psmap[pin->power_domain]; 118 117 ··· 156 153 1100000 157 154 }; 158 155 159 - static int sg2002_get_schmitt_map(struct cv1800_pin *pin, const u32 *psmap, 156 + static int sg2002_get_schmitt_map(const struct sophgo_pin *sp, const u32 *psmap, 160 157 const u32 **map) 161 158 { 159 + const struct cv1800_pin *pin = sophgo_to_cv1800_pin(sp); 162 160 enum cv1800_pin_io_type type = cv1800_pin_io_type(pin); 163 161 u32 pstate = psmap[pin->power_domain]; 164 162 ··· 181 177 return -ENOTSUPP; 182 178 } 183 179 184 - static const struct cv1800_vddio_cfg_ops sg2002_vddio_cfg_ops = { 180 + static const struct sophgo_vddio_cfg_ops sg2002_vddio_cfg_ops = { 185 181 .get_pull_up = sg2002_get_pull_up, 186 182 .get_pull_down = sg2002_get_pull_down, 187 183 .get_oc_map = sg2002_get_oc_map, 188 - .get_schmitt_map = sg2002_get_schmitt_map, 184 + .get_schmitt_map = sg2002_get_schmitt_map, 189 185 }; 190 186 191 187 static const struct pinctrl_pin_desc sg2002_pins[] = { ··· 517 513 CV1800_PINCONF_AREA_SYS, 0xc84), 518 514 }; 519 515 520 - static const struct cv1800_pinctrl_data sg2002_pindata = { 516 + static const struct sophgo_pinctrl_data sg2002_pindata = { 521 517 .pins = sg2002_pins, 522 518 .pindata = sg2002_pin_data, 523 519 .pdnames = sg2002_power_domain_desc, 524 520 .vddio_ops = &sg2002_vddio_cfg_ops, 521 + .cfg_ops = &cv1800_cfg_ops, 522 + .pctl_ops = &cv1800_pctrl_ops, 523 + .pmx_ops = &cv1800_pmx_ops, 524 + .pconf_ops = &cv1800_pconf_ops, 525 525 .npins = ARRAY_SIZE(sg2002_pins), 526 - .npd = ARRAY_SIZE(sg2002_power_domain_desc), 526 + .npds = ARRAY_SIZE(sg2002_power_domain_desc), 527 + .pinsize = sizeof(struct cv1800_pin), 527 528 }; 528 529 529 530 static const struct of_device_id sg2002_pinctrl_ids[] = { ··· 538 529 MODULE_DEVICE_TABLE(of, sg2002_pinctrl_ids); 539 530 540 531 static struct platform_driver sg2002_pinctrl_driver = { 541 - .probe = cv1800_pinctrl_probe, 532 + .probe = sophgo_pinctrl_probe, 542 533 .driver = { 543 534 .name = "sg2002-pinctrl", 544 535 .suppress_bind_attrs = true,
+296
drivers/pinctrl/sophgo/pinctrl-sg2042-ops.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Sophgo sg2042 SoCs pinctrl driver. 4 + * 5 + * Copyright (C) 2024 Inochi Amaoto <inochiama@outlook.com> 6 + * 7 + */ 8 + 9 + #include <linux/bitfield.h> 10 + #include <linux/bits.h> 11 + #include <linux/cleanup.h> 12 + #include <linux/export.h> 13 + #include <linux/io.h> 14 + #include <linux/of.h> 15 + #include <linux/platform_device.h> 16 + #include <linux/seq_file.h> 17 + #include <linux/spinlock.h> 18 + 19 + #include <linux/pinctrl/pinconf-generic.h> 20 + #include <linux/pinctrl/pinconf.h> 21 + #include <linux/pinctrl/pinctrl.h> 22 + #include <linux/pinctrl/pinmux.h> 23 + 24 + #include "../pinctrl-utils.h" 25 + #include "../pinmux.h" 26 + 27 + #include "pinctrl-sg2042.h" 28 + 29 + #define PIN_IO_PULL_ONE_ENABLE BIT(0) 30 + #define PIN_IO_PULL_DIR_UP (BIT(1) | PIN_IO_PULL_ONE_ENABLE) 31 + #define PIN_IO_PULL_DIR_DOWN (0 | PIN_IO_PULL_ONE_ENABLE) 32 + #define PIN_IO_PULL_ONE_MASK GENMASK(1, 0) 33 + 34 + #define PIN_IO_PULL_UP BIT(2) 35 + #define PIN_IO_PULL_UP_DONW BIT(3) 36 + #define PIN_IO_PULL_UP_MASK GENMASK(3, 2) 37 + 38 + #define PIN_IO_MUX GENMASK(5, 4) 39 + #define PIN_IO_DRIVE GENMASK(9, 6) 40 + #define PIN_IO_SCHMITT_ENABLE BIT(10) 41 + #define PIN_IO_OUTPUT_ENABLE BIT(11) 42 + 43 + struct sg2042_priv { 44 + void __iomem *regs; 45 + }; 46 + 47 + static u8 sg2042_dt_get_pin_mux(u32 value) 48 + { 49 + return value >> 16; 50 + } 51 + 52 + static inline u32 sg2042_get_pin_reg(struct sophgo_pinctrl *pctrl, 53 + const struct sophgo_pin *sp) 54 + { 55 + struct sg2042_priv *priv = pctrl->priv_ctrl; 56 + const struct sg2042_pin *pin = sophgo_to_sg2042_pin(sp); 57 + void __iomem *reg = priv->regs + pin->offset; 58 + 59 + if (sp->flags & PIN_FLAG_WRITE_HIGH) 60 + return readl(reg) >> 16; 61 + else 62 + return readl(reg) & 0xffff; 63 + } 64 + 65 + static int sg2042_set_pin_reg(struct sophgo_pinctrl *pctrl, 66 + const struct sophgo_pin *sp, 67 + u32 value, u32 mask) 68 + { 69 + struct sg2042_priv *priv = pctrl->priv_ctrl; 70 + const struct sg2042_pin *pin = sophgo_to_sg2042_pin(sp); 71 + void __iomem *reg = priv->regs + pin->offset; 72 + u32 v = readl(reg); 73 + 74 + if (sp->flags & PIN_FLAG_WRITE_HIGH) { 75 + v &= ~(mask << 16); 76 + v |= value << 16; 77 + } else { 78 + v &= ~mask; 79 + v |= value; 80 + } 81 + 82 + writel(v, reg); 83 + 84 + return 0; 85 + } 86 + 87 + static void sg2042_pctrl_dbg_show(struct pinctrl_dev *pctldev, 88 + struct seq_file *seq, unsigned int pin_id) 89 + { 90 + struct sophgo_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); 91 + const struct sophgo_pin *sp = sophgo_get_pin(pctrl, pin_id); 92 + u32 value, mux; 93 + 94 + value = sg2042_get_pin_reg(pctrl, sp); 95 + mux = FIELD_GET(PIN_IO_MUX, value); 96 + seq_printf(seq, "mux:%u reg:0x%04x ", mux, value); 97 + } 98 + 99 + const struct pinctrl_ops sg2042_pctrl_ops = { 100 + .get_groups_count = pinctrl_generic_get_group_count, 101 + .get_group_name = pinctrl_generic_get_group_name, 102 + .get_group_pins = pinctrl_generic_get_group_pins, 103 + .pin_dbg_show = sg2042_pctrl_dbg_show, 104 + .dt_node_to_map = sophgo_pctrl_dt_node_to_map, 105 + .dt_free_map = pinctrl_utils_free_map, 106 + }; 107 + EXPORT_SYMBOL_GPL(sg2042_pctrl_ops); 108 + 109 + static void sg2042_set_pinmux_config(struct sophgo_pinctrl *pctrl, 110 + const struct sophgo_pin *sp, u32 config) 111 + { 112 + u32 mux = sg2042_dt_get_pin_mux(config); 113 + 114 + if (!(sp->flags & PIN_FLAG_NO_PINMUX)) 115 + sg2042_set_pin_reg(pctrl, sp, mux, PIN_IO_MUX); 116 + } 117 + 118 + const struct pinmux_ops sg2042_pmx_ops = { 119 + .get_functions_count = pinmux_generic_get_function_count, 120 + .get_function_name = pinmux_generic_get_function_name, 121 + .get_function_groups = pinmux_generic_get_function_groups, 122 + .set_mux = sophgo_pmx_set_mux, 123 + .strict = true, 124 + }; 125 + EXPORT_SYMBOL_GPL(sg2042_pmx_ops); 126 + 127 + static int sg2042_pconf_get(struct pinctrl_dev *pctldev, 128 + unsigned int pin_id, unsigned long *config) 129 + { 130 + struct sophgo_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); 131 + int param = pinconf_to_config_param(*config); 132 + const struct sophgo_pin *sp = sophgo_get_pin(pctrl, pin_id); 133 + u32 value; 134 + u32 arg; 135 + bool enabled; 136 + int ret; 137 + 138 + if (!sp) 139 + return -EINVAL; 140 + 141 + value = sg2042_get_pin_reg(pctrl, sp); 142 + 143 + switch (param) { 144 + case PIN_CONFIG_BIAS_DISABLE: 145 + if (sp->flags & PIN_FLAG_ONLY_ONE_PULL) 146 + arg = FIELD_GET(PIN_IO_PULL_ONE_ENABLE, value); 147 + else 148 + arg = FIELD_GET(PIN_IO_PULL_UP_MASK, value); 149 + enabled = arg == 0; 150 + break; 151 + case PIN_CONFIG_BIAS_PULL_DOWN: 152 + if (sp->flags & PIN_FLAG_ONLY_ONE_PULL) { 153 + arg = FIELD_GET(PIN_IO_PULL_ONE_MASK, value); 154 + enabled = arg == PIN_IO_PULL_DIR_DOWN; 155 + } else { 156 + enabled = FIELD_GET(PIN_IO_PULL_UP_DONW, value) != 0; 157 + } 158 + arg = sophgo_pinctrl_typical_pull_down(pctrl, sp, NULL); 159 + break; 160 + case PIN_CONFIG_BIAS_PULL_UP: 161 + if (sp->flags & PIN_FLAG_ONLY_ONE_PULL) { 162 + arg = FIELD_GET(PIN_IO_PULL_ONE_MASK, value); 163 + enabled = arg == PIN_IO_PULL_DIR_UP; 164 + } else { 165 + enabled = FIELD_GET(PIN_IO_PULL_UP, value) != 0; 166 + } 167 + arg = sophgo_pinctrl_typical_pull_up(pctrl, sp, NULL); 168 + break; 169 + case PIN_CONFIG_DRIVE_STRENGTH_UA: 170 + enabled = FIELD_GET(PIN_IO_OUTPUT_ENABLE, value) != 0; 171 + arg = FIELD_GET(PIN_IO_DRIVE, value); 172 + ret = sophgo_pinctrl_reg2oc(pctrl, sp, NULL, arg); 173 + if (ret < 0) 174 + return ret; 175 + arg = ret; 176 + break; 177 + case PIN_CONFIG_INPUT_SCHMITT_ENABLE: 178 + arg = FIELD_GET(PIN_IO_SCHMITT_ENABLE, value); 179 + enabled = arg != 0; 180 + break; 181 + default: 182 + return -ENOTSUPP; 183 + } 184 + 185 + *config = pinconf_to_config_packed(param, arg); 186 + 187 + return enabled ? 0 : -EINVAL; 188 + } 189 + 190 + static int sg2042_pinconf_compute_config(struct sophgo_pinctrl *pctrl, 191 + const struct sophgo_pin *sp, 192 + unsigned long *configs, 193 + unsigned int num_configs, 194 + u32 *value, u32 *mask) 195 + { 196 + int i; 197 + u16 v = 0, m = 0; 198 + int ret; 199 + 200 + if (!sp) 201 + return -EINVAL; 202 + 203 + for (i = 0; i < num_configs; i++) { 204 + int param = pinconf_to_config_param(configs[i]); 205 + u32 arg = pinconf_to_config_argument(configs[i]); 206 + 207 + switch (param) { 208 + case PIN_CONFIG_BIAS_DISABLE: 209 + if (sp->flags & PIN_FLAG_ONLY_ONE_PULL) { 210 + v &= ~PIN_IO_PULL_ONE_ENABLE; 211 + m |= PIN_IO_PULL_ONE_ENABLE; 212 + } else { 213 + v &= ~PIN_IO_PULL_UP_MASK; 214 + m |= PIN_IO_PULL_UP_MASK; 215 + } 216 + break; 217 + case PIN_CONFIG_BIAS_PULL_DOWN: 218 + if (sp->flags & PIN_FLAG_ONLY_ONE_PULL) { 219 + v &= ~PIN_IO_PULL_ONE_MASK; 220 + v |= PIN_IO_PULL_DIR_DOWN; 221 + m |= PIN_IO_PULL_ONE_MASK; 222 + } else { 223 + v |= PIN_IO_PULL_UP_DONW; 224 + m |= PIN_IO_PULL_UP_DONW; 225 + } 226 + break; 227 + case PIN_CONFIG_BIAS_PULL_UP: 228 + if (sp->flags & PIN_FLAG_ONLY_ONE_PULL) { 229 + v &= ~PIN_IO_PULL_ONE_MASK; 230 + v |= PIN_IO_PULL_DIR_UP; 231 + m |= PIN_IO_PULL_ONE_MASK; 232 + } else { 233 + v |= PIN_IO_PULL_UP; 234 + m |= PIN_IO_PULL_UP; 235 + } 236 + break; 237 + case PIN_CONFIG_DRIVE_STRENGTH_UA: 238 + v &= ~(PIN_IO_DRIVE | PIN_IO_OUTPUT_ENABLE); 239 + if (arg != 0) { 240 + ret = sophgo_pinctrl_oc2reg(pctrl, sp, NULL, arg); 241 + if (ret < 0) 242 + return ret; 243 + if (!(sp->flags & PIN_FLAG_NO_OEX_EN)) 244 + v |= PIN_IO_OUTPUT_ENABLE; 245 + v |= FIELD_PREP(PIN_IO_DRIVE, ret); 246 + } 247 + m |= PIN_IO_DRIVE | PIN_IO_OUTPUT_ENABLE; 248 + break; 249 + case PIN_CONFIG_INPUT_SCHMITT_ENABLE: 250 + v |= PIN_IO_SCHMITT_ENABLE; 251 + m |= PIN_IO_SCHMITT_ENABLE; 252 + break; 253 + default: 254 + return -ENOTSUPP; 255 + } 256 + } 257 + 258 + *value = v; 259 + *mask = m; 260 + 261 + return 0; 262 + } 263 + 264 + const struct pinconf_ops sg2042_pconf_ops = { 265 + .pin_config_get = sg2042_pconf_get, 266 + .pin_config_set = sophgo_pconf_set, 267 + .pin_config_group_set = sophgo_pconf_group_set, 268 + .is_generic = true, 269 + }; 270 + EXPORT_SYMBOL_GPL(sg2042_pconf_ops); 271 + 272 + static int sophgo_pinctrl_init(struct platform_device *pdev, 273 + struct sophgo_pinctrl *pctrl) 274 + { 275 + struct sg2042_priv *priv; 276 + 277 + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); 278 + if (!priv) 279 + return -ENOMEM; 280 + 281 + priv->regs = devm_platform_ioremap_resource(pdev, 0); 282 + if (IS_ERR(priv->regs)) 283 + return PTR_ERR(priv->regs); 284 + 285 + pctrl->priv_ctrl = priv; 286 + 287 + return 0; 288 + } 289 + 290 + const struct sophgo_cfg_ops sg2042_cfg_ops = { 291 + .pctrl_init = sophgo_pinctrl_init, 292 + .compute_pinconf_config = sg2042_pinconf_compute_config, 293 + .set_pinconf_config = sg2042_set_pin_reg, 294 + .set_pinmux_config = sg2042_set_pinmux_config, 295 + }; 296 + EXPORT_SYMBOL_GPL(sg2042_cfg_ops);
+655
drivers/pinctrl/sophgo/pinctrl-sg2042.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Sophgo SG2042 SoC pinctrl driver. 4 + * 5 + * Copyright (C) 2024 Inochi Amaoto <inochiama@outlook.com> 6 + */ 7 + 8 + #include <linux/module.h> 9 + #include <linux/platform_device.h> 10 + #include <linux/of.h> 11 + 12 + #include <linux/pinctrl/pinctrl.h> 13 + #include <linux/pinctrl/pinmux.h> 14 + 15 + #include <dt-bindings/pinctrl/pinctrl-sg2042.h> 16 + 17 + #include "pinctrl-sg2042.h" 18 + 19 + static int sg2042_get_pull_up(const struct sophgo_pin *sp, const u32 *psmap) 20 + { 21 + return 35000; 22 + } 23 + 24 + static int sg2042_get_pull_down(const struct sophgo_pin *sp, const u32 *psmap) 25 + { 26 + return 28000; 27 + } 28 + 29 + static const u32 sg2042_oc_map[] = { 30 + 5400, 8100, 10700, 13400, 31 + 16100, 18800, 21400, 24100, 32 + 26800, 29400, 32100, 34800, 33 + 37400, 40100, 42800, 45400 34 + }; 35 + 36 + static int sg2042_get_oc_map(const struct sophgo_pin *sp, const u32 *psmap, 37 + const u32 **map) 38 + { 39 + *map = sg2042_oc_map; 40 + return ARRAY_SIZE(sg2042_oc_map); 41 + } 42 + 43 + static const struct sophgo_vddio_cfg_ops sg2042_vddio_cfg_ops = { 44 + .get_pull_up = sg2042_get_pull_up, 45 + .get_pull_down = sg2042_get_pull_down, 46 + .get_oc_map = sg2042_get_oc_map, 47 + }; 48 + 49 + static const struct pinctrl_pin_desc sg2042_pins[] = { 50 + PINCTRL_PIN(PIN_LPC_LCLK, "lpc_lclk"), 51 + PINCTRL_PIN(PIN_LPC_LFRAME, "lpc_lframe"), 52 + PINCTRL_PIN(PIN_LPC_LAD0, "lpc_lad0"), 53 + PINCTRL_PIN(PIN_LPC_LAD1, "lpc_lad1"), 54 + PINCTRL_PIN(PIN_LPC_LAD2, "lpc_lad2"), 55 + PINCTRL_PIN(PIN_LPC_LAD3, "lpc_lad3"), 56 + PINCTRL_PIN(PIN_LPC_LDRQ0, "lpc_ldrq0"), 57 + PINCTRL_PIN(PIN_LPC_LDRQ1, "lpc_ldrq1"), 58 + PINCTRL_PIN(PIN_LPC_SERIRQ, "lpc_serirq"), 59 + PINCTRL_PIN(PIN_LPC_CLKRUN, "lpc_clkrun"), 60 + PINCTRL_PIN(PIN_LPC_LPME, "lpc_lpme"), 61 + PINCTRL_PIN(PIN_LPC_LPCPD, "lpc_lpcpd"), 62 + PINCTRL_PIN(PIN_LPC_LSMI, "lpc_lsmi"), 63 + PINCTRL_PIN(PIN_PCIE0_L0_RESET, "pcie0_l0_reset"), 64 + PINCTRL_PIN(PIN_PCIE0_L1_RESET, "pcie0_l1_reset"), 65 + PINCTRL_PIN(PIN_PCIE0_L0_WAKEUP, "pcie0_l0_wakeup"), 66 + PINCTRL_PIN(PIN_PCIE0_L1_WAKEUP, "pcie0_l1_wakeup"), 67 + PINCTRL_PIN(PIN_PCIE0_L0_CLKREQ_IN, "pcie0_l0_clkreq_in"), 68 + PINCTRL_PIN(PIN_PCIE0_L1_CLKREQ_IN, "pcie0_l1_clkreq_in"), 69 + PINCTRL_PIN(PIN_PCIE1_L0_RESET, "pcie1_l0_reset"), 70 + PINCTRL_PIN(PIN_PCIE1_L1_RESET, "pcie1_l1_reset"), 71 + PINCTRL_PIN(PIN_PCIE1_L0_WAKEUP, "pcie1_l0_wakeup"), 72 + PINCTRL_PIN(PIN_PCIE1_L1_WAKEUP, "pcie1_l1_wakeup"), 73 + PINCTRL_PIN(PIN_PCIE1_L0_CLKREQ_IN, "pcie1_l0_clkreq_in"), 74 + PINCTRL_PIN(PIN_PCIE1_L1_CLKREQ_IN, "pcie1_l1_clkreq_in"), 75 + PINCTRL_PIN(PIN_SPIF0_CLK_SEL1, "spif0_clk_sel1"), 76 + PINCTRL_PIN(PIN_SPIF0_CLK_SEL0, "spif0_clk_sel0"), 77 + PINCTRL_PIN(PIN_SPIF0_WP, "spif0_wp"), 78 + PINCTRL_PIN(PIN_SPIF0_HOLD, "spif0_hold"), 79 + PINCTRL_PIN(PIN_SPIF0_SDI, "spif0_sdi"), 80 + PINCTRL_PIN(PIN_SPIF0_CS, "spif0_cs"), 81 + PINCTRL_PIN(PIN_SPIF0_SCK, "spif0_sck"), 82 + PINCTRL_PIN(PIN_SPIF0_SDO, "spif0_sdo"), 83 + PINCTRL_PIN(PIN_SPIF1_CLK_SEL1, "spif1_clk_sel1"), 84 + PINCTRL_PIN(PIN_SPIF1_CLK_SEL0, "spif1_clk_sel0"), 85 + PINCTRL_PIN(PIN_SPIF1_WP, "spif1_wp"), 86 + PINCTRL_PIN(PIN_SPIF1_HOLD, "spif1_hold"), 87 + PINCTRL_PIN(PIN_SPIF1_SDI, "spif1_sdi"), 88 + PINCTRL_PIN(PIN_SPIF1_CS, "spif1_cs"), 89 + PINCTRL_PIN(PIN_SPIF1_SCK, "spif1_sck"), 90 + PINCTRL_PIN(PIN_SPIF1_SDO, "spif1_sdo"), 91 + PINCTRL_PIN(PIN_EMMC_WP, "emmc_wp"), 92 + PINCTRL_PIN(PIN_EMMC_CD, "emmc_cd"), 93 + PINCTRL_PIN(PIN_EMMC_RST, "emmc_rst"), 94 + PINCTRL_PIN(PIN_EMMC_PWR_EN, "emmc_pwr_en"), 95 + PINCTRL_PIN(PIN_SDIO_CD, "sdio_cd"), 96 + PINCTRL_PIN(PIN_SDIO_WP, "sdio_wp"), 97 + PINCTRL_PIN(PIN_SDIO_RST, "sdio_rst"), 98 + PINCTRL_PIN(PIN_SDIO_PWR_EN, "sdio_pwr_en"), 99 + PINCTRL_PIN(PIN_RGMII0_TXD0, "rgmii0_txd0"), 100 + PINCTRL_PIN(PIN_RGMII0_TXD1, "rgmii0_txd1"), 101 + PINCTRL_PIN(PIN_RGMII0_TXD2, "rgmii0_txd2"), 102 + PINCTRL_PIN(PIN_RGMII0_TXD3, "rgmii0_txd3"), 103 + PINCTRL_PIN(PIN_RGMII0_TXCTRL, "rgmii0_txctrl"), 104 + PINCTRL_PIN(PIN_RGMII0_RXD0, "rgmii0_rxd0"), 105 + PINCTRL_PIN(PIN_RGMII0_RXD1, "rgmii0_rxd1"), 106 + PINCTRL_PIN(PIN_RGMII0_RXD2, "rgmii0_rxd2"), 107 + PINCTRL_PIN(PIN_RGMII0_RXD3, "rgmii0_rxd3"), 108 + PINCTRL_PIN(PIN_RGMII0_RXCTRL, "rgmii0_rxctrl"), 109 + PINCTRL_PIN(PIN_RGMII0_TXC, "rgmii0_txc"), 110 + PINCTRL_PIN(PIN_RGMII0_RXC, "rgmii0_rxc"), 111 + PINCTRL_PIN(PIN_RGMII0_REFCLKO, "rgmii0_refclko"), 112 + PINCTRL_PIN(PIN_RGMII0_IRQ, "rgmii0_irq"), 113 + PINCTRL_PIN(PIN_RGMII0_MDC, "rgmii0_mdc"), 114 + PINCTRL_PIN(PIN_RGMII0_MDIO, "rgmii0_mdio"), 115 + PINCTRL_PIN(PIN_PWM0, "pwm0"), 116 + PINCTRL_PIN(PIN_PWM1, "pwm1"), 117 + PINCTRL_PIN(PIN_PWM2, "pwm2"), 118 + PINCTRL_PIN(PIN_PWM3, "pwm3"), 119 + PINCTRL_PIN(PIN_FAN0, "fan0"), 120 + PINCTRL_PIN(PIN_FAN1, "fan1"), 121 + PINCTRL_PIN(PIN_FAN2, "fan2"), 122 + PINCTRL_PIN(PIN_FAN3, "fan3"), 123 + PINCTRL_PIN(PIN_IIC0_SDA, "iic0_sda"), 124 + PINCTRL_PIN(PIN_IIC0_SCL, "iic0_scl"), 125 + PINCTRL_PIN(PIN_IIC1_SDA, "iic1_sda"), 126 + PINCTRL_PIN(PIN_IIC1_SCL, "iic1_scl"), 127 + PINCTRL_PIN(PIN_IIC2_SDA, "iic2_sda"), 128 + PINCTRL_PIN(PIN_IIC2_SCL, "iic2_scl"), 129 + PINCTRL_PIN(PIN_IIC3_SDA, "iic3_sda"), 130 + PINCTRL_PIN(PIN_IIC3_SCL, "iic3_scl"), 131 + PINCTRL_PIN(PIN_UART0_TX, "uart0_tx"), 132 + PINCTRL_PIN(PIN_UART0_RX, "uart0_rx"), 133 + PINCTRL_PIN(PIN_UART0_RTS, "uart0_rts"), 134 + PINCTRL_PIN(PIN_UART0_CTS, "uart0_cts"), 135 + PINCTRL_PIN(PIN_UART1_TX, "uart1_tx"), 136 + PINCTRL_PIN(PIN_UART1_RX, "uart1_rx"), 137 + PINCTRL_PIN(PIN_UART1_RTS, "uart1_rts"), 138 + PINCTRL_PIN(PIN_UART1_CTS, "uart1_cts"), 139 + PINCTRL_PIN(PIN_UART2_TX, "uart2_tx"), 140 + PINCTRL_PIN(PIN_UART2_RX, "uart2_rx"), 141 + PINCTRL_PIN(PIN_UART2_RTS, "uart2_rts"), 142 + PINCTRL_PIN(PIN_UART2_CTS, "uart2_cts"), 143 + PINCTRL_PIN(PIN_UART3_TX, "uart3_tx"), 144 + PINCTRL_PIN(PIN_UART3_RX, "uart3_rx"), 145 + PINCTRL_PIN(PIN_UART3_RTS, "uart3_rts"), 146 + PINCTRL_PIN(PIN_UART3_CTS, "uart3_cts"), 147 + PINCTRL_PIN(PIN_SPI0_CS0, "spi0_cs0"), 148 + PINCTRL_PIN(PIN_SPI0_CS1, "spi0_cs1"), 149 + PINCTRL_PIN(PIN_SPI0_SDI, "spi0_sdi"), 150 + PINCTRL_PIN(PIN_SPI0_SDO, "spi0_sdo"), 151 + PINCTRL_PIN(PIN_SPI0_SCK, "spi0_sck"), 152 + PINCTRL_PIN(PIN_SPI1_CS0, "spi1_cs0"), 153 + PINCTRL_PIN(PIN_SPI1_CS1, "spi1_cs1"), 154 + PINCTRL_PIN(PIN_SPI1_SDI, "spi1_sdi"), 155 + PINCTRL_PIN(PIN_SPI1_SDO, "spi1_sdo"), 156 + PINCTRL_PIN(PIN_SPI1_SCK, "spi1_sck"), 157 + PINCTRL_PIN(PIN_JTAG0_TDO, "jtag0_tdo"), 158 + PINCTRL_PIN(PIN_JTAG0_TCK, "jtag0_tck"), 159 + PINCTRL_PIN(PIN_JTAG0_TDI, "jtag0_tdi"), 160 + PINCTRL_PIN(PIN_JTAG0_TMS, "jtag0_tms"), 161 + PINCTRL_PIN(PIN_JTAG0_TRST, "jtag0_trst"), 162 + PINCTRL_PIN(PIN_JTAG0_SRST, "jtag0_srst"), 163 + PINCTRL_PIN(PIN_JTAG1_TDO, "jtag1_tdo"), 164 + PINCTRL_PIN(PIN_JTAG1_TCK, "jtag1_tck"), 165 + PINCTRL_PIN(PIN_JTAG1_TDI, "jtag1_tdi"), 166 + PINCTRL_PIN(PIN_JTAG1_TMS, "jtag1_tms"), 167 + PINCTRL_PIN(PIN_JTAG1_TRST, "jtag1_trst"), 168 + PINCTRL_PIN(PIN_JTAG1_SRST, "jtag1_srst"), 169 + PINCTRL_PIN(PIN_JTAG2_TDO, "jtag2_tdo"), 170 + PINCTRL_PIN(PIN_JTAG2_TCK, "jtag2_tck"), 171 + PINCTRL_PIN(PIN_JTAG2_TDI, "jtag2_tdi"), 172 + PINCTRL_PIN(PIN_JTAG2_TMS, "jtag2_tms"), 173 + PINCTRL_PIN(PIN_JTAG2_TRST, "jtag2_trst"), 174 + PINCTRL_PIN(PIN_JTAG2_SRST, "jtag2_srst"), 175 + PINCTRL_PIN(PIN_GPIO0, "gpio0"), 176 + PINCTRL_PIN(PIN_GPIO1, "gpio1"), 177 + PINCTRL_PIN(PIN_GPIO2, "gpio2"), 178 + PINCTRL_PIN(PIN_GPIO3, "gpio3"), 179 + PINCTRL_PIN(PIN_GPIO4, "gpio4"), 180 + PINCTRL_PIN(PIN_GPIO5, "gpio5"), 181 + PINCTRL_PIN(PIN_GPIO6, "gpio6"), 182 + PINCTRL_PIN(PIN_GPIO7, "gpio7"), 183 + PINCTRL_PIN(PIN_GPIO8, "gpio8"), 184 + PINCTRL_PIN(PIN_GPIO9, "gpio9"), 185 + PINCTRL_PIN(PIN_GPIO10, "gpio10"), 186 + PINCTRL_PIN(PIN_GPIO11, "gpio11"), 187 + PINCTRL_PIN(PIN_GPIO12, "gpio12"), 188 + PINCTRL_PIN(PIN_GPIO13, "gpio13"), 189 + PINCTRL_PIN(PIN_GPIO14, "gpio14"), 190 + PINCTRL_PIN(PIN_GPIO15, "gpio15"), 191 + PINCTRL_PIN(PIN_GPIO16, "gpio16"), 192 + PINCTRL_PIN(PIN_GPIO17, "gpio17"), 193 + PINCTRL_PIN(PIN_GPIO18, "gpio18"), 194 + PINCTRL_PIN(PIN_GPIO19, "gpio19"), 195 + PINCTRL_PIN(PIN_GPIO20, "gpio20"), 196 + PINCTRL_PIN(PIN_GPIO21, "gpio21"), 197 + PINCTRL_PIN(PIN_GPIO22, "gpio22"), 198 + PINCTRL_PIN(PIN_GPIO23, "gpio23"), 199 + PINCTRL_PIN(PIN_GPIO24, "gpio24"), 200 + PINCTRL_PIN(PIN_GPIO25, "gpio25"), 201 + PINCTRL_PIN(PIN_GPIO26, "gpio26"), 202 + PINCTRL_PIN(PIN_GPIO27, "gpio27"), 203 + PINCTRL_PIN(PIN_GPIO28, "gpio28"), 204 + PINCTRL_PIN(PIN_GPIO29, "gpio29"), 205 + PINCTRL_PIN(PIN_GPIO30, "gpio30"), 206 + PINCTRL_PIN(PIN_GPIO31, "gpio31"), 207 + PINCTRL_PIN(PIN_MODE_SEL0, "mode_sel0"), 208 + PINCTRL_PIN(PIN_MODE_SEL1, "mode_sel1"), 209 + PINCTRL_PIN(PIN_MODE_SEL2, "mode_sel2"), 210 + PINCTRL_PIN(PIN_BOOT_SEL0, "boot_sel0"), 211 + PINCTRL_PIN(PIN_BOOT_SEL1, "boot_sel1"), 212 + PINCTRL_PIN(PIN_BOOT_SEL2, "boot_sel2"), 213 + PINCTRL_PIN(PIN_BOOT_SEL3, "boot_sel3"), 214 + PINCTRL_PIN(PIN_BOOT_SEL4, "boot_sel4"), 215 + PINCTRL_PIN(PIN_BOOT_SEL5, "boot_sel5"), 216 + PINCTRL_PIN(PIN_BOOT_SEL6, "boot_sel6"), 217 + PINCTRL_PIN(PIN_BOOT_SEL7, "boot_sel7"), 218 + PINCTRL_PIN(PIN_MULTI_SCKT, "multi_sckt"), 219 + PINCTRL_PIN(PIN_SCKT_ID0, "sckt_id0"), 220 + PINCTRL_PIN(PIN_SCKT_ID1, "sckt_id1"), 221 + PINCTRL_PIN(PIN_PLL_CLK_IN_MAIN, "pll_clk_in_main"), 222 + PINCTRL_PIN(PIN_PLL_CLK_IN_DDR_L, "pll_clk_in_ddr_l"), 223 + PINCTRL_PIN(PIN_PLL_CLK_IN_DDR_R, "pll_clk_in_ddr_r"), 224 + PINCTRL_PIN(PIN_XTAL_32K, "xtal_32k"), 225 + PINCTRL_PIN(PIN_SYS_RST, "sys_rst"), 226 + PINCTRL_PIN(PIN_PWR_BUTTON, "pwr_button"), 227 + PINCTRL_PIN(PIN_TEST_EN, "test_en"), 228 + PINCTRL_PIN(PIN_TEST_MODE_MBIST, "test_mode_mbist"), 229 + PINCTRL_PIN(PIN_TEST_MODE_SCAN, "test_mode_scan"), 230 + PINCTRL_PIN(PIN_TEST_MODE_BSD, "test_mode_bsd"), 231 + PINCTRL_PIN(PIN_BISR_BYP, "bisr_byp"), 232 + }; 233 + 234 + static const struct sg2042_pin sg2042_pin_data[ARRAY_SIZE(sg2042_pins)] = { 235 + SG2042_GENERAL_PIN(PIN_LPC_LCLK, 0x000, 236 + PIN_FLAG_ONLY_ONE_PULL), 237 + SG2042_GENERAL_PIN(PIN_LPC_LFRAME, 0x000, 238 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 239 + SG2042_GENERAL_PIN(PIN_LPC_LAD0, 0x004, 240 + PIN_FLAG_ONLY_ONE_PULL), 241 + SG2042_GENERAL_PIN(PIN_LPC_LAD1, 0x004, 242 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 243 + SG2042_GENERAL_PIN(PIN_LPC_LAD2, 0x008, 244 + PIN_FLAG_ONLY_ONE_PULL), 245 + SG2042_GENERAL_PIN(PIN_LPC_LAD3, 0x008, 246 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 247 + SG2042_GENERAL_PIN(PIN_LPC_LDRQ0, 0x00c, 248 + PIN_FLAG_ONLY_ONE_PULL), 249 + SG2042_GENERAL_PIN(PIN_LPC_LDRQ1, 0x00c, 250 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 251 + SG2042_GENERAL_PIN(PIN_LPC_SERIRQ, 0x010, 252 + PIN_FLAG_ONLY_ONE_PULL), 253 + SG2042_GENERAL_PIN(PIN_LPC_CLKRUN, 0x010, 254 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 255 + SG2042_GENERAL_PIN(PIN_LPC_LPME, 0x014, 256 + PIN_FLAG_ONLY_ONE_PULL), 257 + SG2042_GENERAL_PIN(PIN_LPC_LPCPD, 0x014, 258 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 259 + SG2042_GENERAL_PIN(PIN_LPC_LSMI, 0x018, 260 + PIN_FLAG_ONLY_ONE_PULL), 261 + SG2042_GENERAL_PIN(PIN_PCIE0_L0_RESET, 0x018, 262 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 263 + SG2042_GENERAL_PIN(PIN_PCIE0_L1_RESET, 0x01c, 264 + PIN_FLAG_ONLY_ONE_PULL), 265 + SG2042_GENERAL_PIN(PIN_PCIE0_L0_WAKEUP, 0x01c, 266 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 267 + SG2042_GENERAL_PIN(PIN_PCIE0_L1_WAKEUP, 0x020, 268 + PIN_FLAG_ONLY_ONE_PULL), 269 + SG2042_GENERAL_PIN(PIN_PCIE0_L0_CLKREQ_IN, 0x020, 270 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 271 + SG2042_GENERAL_PIN(PIN_PCIE0_L1_CLKREQ_IN, 0x024, 272 + PIN_FLAG_ONLY_ONE_PULL), 273 + SG2042_GENERAL_PIN(PIN_PCIE1_L0_RESET, 0x024, 274 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 275 + SG2042_GENERAL_PIN(PIN_PCIE1_L1_RESET, 0x028, 276 + PIN_FLAG_ONLY_ONE_PULL), 277 + SG2042_GENERAL_PIN(PIN_PCIE1_L0_WAKEUP, 0x028, 278 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 279 + SG2042_GENERAL_PIN(PIN_PCIE1_L1_WAKEUP, 0x02c, 280 + PIN_FLAG_ONLY_ONE_PULL), 281 + SG2042_GENERAL_PIN(PIN_PCIE1_L0_CLKREQ_IN, 0x02c, 282 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 283 + SG2042_GENERAL_PIN(PIN_PCIE1_L1_CLKREQ_IN, 0x030, 284 + PIN_FLAG_ONLY_ONE_PULL), 285 + SG2042_GENERAL_PIN(PIN_SPIF0_CLK_SEL1, 0x030, 286 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 287 + SG2042_GENERAL_PIN(PIN_SPIF0_CLK_SEL0, 0x034, 288 + PIN_FLAG_ONLY_ONE_PULL), 289 + SG2042_GENERAL_PIN(PIN_SPIF0_WP, 0x034, 290 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 291 + SG2042_GENERAL_PIN(PIN_SPIF0_HOLD, 0x038, 292 + PIN_FLAG_ONLY_ONE_PULL), 293 + SG2042_GENERAL_PIN(PIN_SPIF0_SDI, 0x038, 294 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 295 + SG2042_GENERAL_PIN(PIN_SPIF0_CS, 0x03c, 296 + PIN_FLAG_ONLY_ONE_PULL), 297 + SG2042_GENERAL_PIN(PIN_SPIF0_SCK, 0x03c, 298 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 299 + SG2042_GENERAL_PIN(PIN_SPIF0_SDO, 0x040, 300 + PIN_FLAG_ONLY_ONE_PULL), 301 + SG2042_GENERAL_PIN(PIN_SPIF1_CLK_SEL1, 0x040, 302 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 303 + SG2042_GENERAL_PIN(PIN_SPIF1_CLK_SEL0, 0x044, 304 + PIN_FLAG_ONLY_ONE_PULL), 305 + SG2042_GENERAL_PIN(PIN_SPIF1_WP, 0x044, 306 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 307 + SG2042_GENERAL_PIN(PIN_SPIF1_HOLD, 0x048, 308 + PIN_FLAG_ONLY_ONE_PULL), 309 + SG2042_GENERAL_PIN(PIN_SPIF1_SDI, 0x048, 310 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 311 + SG2042_GENERAL_PIN(PIN_SPIF1_CS, 0x04c, 312 + PIN_FLAG_ONLY_ONE_PULL), 313 + SG2042_GENERAL_PIN(PIN_SPIF1_SCK, 0x04c, 314 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 315 + SG2042_GENERAL_PIN(PIN_SPIF1_SDO, 0x050, 316 + PIN_FLAG_ONLY_ONE_PULL), 317 + SG2042_GENERAL_PIN(PIN_EMMC_WP, 0x050, 318 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 319 + SG2042_GENERAL_PIN(PIN_EMMC_CD, 0x054, 320 + PIN_FLAG_ONLY_ONE_PULL), 321 + SG2042_GENERAL_PIN(PIN_EMMC_RST, 0x054, 322 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 323 + SG2042_GENERAL_PIN(PIN_EMMC_PWR_EN, 0x058, 324 + PIN_FLAG_ONLY_ONE_PULL), 325 + SG2042_GENERAL_PIN(PIN_SDIO_CD, 0x058, 326 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 327 + SG2042_GENERAL_PIN(PIN_SDIO_WP, 0x05c, 328 + PIN_FLAG_ONLY_ONE_PULL), 329 + SG2042_GENERAL_PIN(PIN_SDIO_RST, 0x05c, 330 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 331 + SG2042_GENERAL_PIN(PIN_SDIO_PWR_EN, 0x060, 332 + PIN_FLAG_ONLY_ONE_PULL), 333 + SG2042_GENERAL_PIN(PIN_RGMII0_TXD0, 0x060, 334 + PIN_FLAG_WRITE_HIGH), 335 + SG2042_GENERAL_PIN(PIN_RGMII0_TXD1, 0x064, 336 + PIN_FLAG_DEFAULT), 337 + SG2042_GENERAL_PIN(PIN_RGMII0_TXD2, 0x064, 338 + PIN_FLAG_WRITE_HIGH), 339 + SG2042_GENERAL_PIN(PIN_RGMII0_TXD3, 0x068, 340 + PIN_FLAG_DEFAULT), 341 + SG2042_GENERAL_PIN(PIN_RGMII0_TXCTRL, 0x068, 342 + PIN_FLAG_WRITE_HIGH), 343 + SG2042_GENERAL_PIN(PIN_RGMII0_RXD0, 0x06c, 344 + PIN_FLAG_DEFAULT), 345 + SG2042_GENERAL_PIN(PIN_RGMII0_RXD1, 0x06c, 346 + PIN_FLAG_WRITE_HIGH), 347 + SG2042_GENERAL_PIN(PIN_RGMII0_RXD2, 0x070, 348 + PIN_FLAG_DEFAULT), 349 + SG2042_GENERAL_PIN(PIN_RGMII0_RXD3, 0x070, 350 + PIN_FLAG_WRITE_HIGH), 351 + SG2042_GENERAL_PIN(PIN_RGMII0_RXCTRL, 0x074, 352 + PIN_FLAG_DEFAULT), 353 + SG2042_GENERAL_PIN(PIN_RGMII0_TXC, 0x074, 354 + PIN_FLAG_WRITE_HIGH), 355 + SG2042_GENERAL_PIN(PIN_RGMII0_RXC, 0x078, 356 + PIN_FLAG_DEFAULT), 357 + SG2042_GENERAL_PIN(PIN_RGMII0_REFCLKO, 0x078, 358 + PIN_FLAG_WRITE_HIGH), 359 + SG2042_GENERAL_PIN(PIN_RGMII0_IRQ, 0x07c, 360 + PIN_FLAG_DEFAULT), 361 + SG2042_GENERAL_PIN(PIN_RGMII0_MDC, 0x07c, 362 + PIN_FLAG_WRITE_HIGH), 363 + SG2042_GENERAL_PIN(PIN_RGMII0_MDIO, 0x080, 364 + PIN_FLAG_DEFAULT), 365 + SG2042_GENERAL_PIN(PIN_PWM0, 0x080, 366 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 367 + SG2042_GENERAL_PIN(PIN_PWM1, 0x084, 368 + PIN_FLAG_ONLY_ONE_PULL), 369 + SG2042_GENERAL_PIN(PIN_PWM2, 0x084, 370 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 371 + SG2042_GENERAL_PIN(PIN_PWM3, 0x088, 372 + PIN_FLAG_ONLY_ONE_PULL), 373 + SG2042_GENERAL_PIN(PIN_FAN0, 0x088, 374 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 375 + SG2042_GENERAL_PIN(PIN_FAN1, 0x08c, 376 + PIN_FLAG_ONLY_ONE_PULL), 377 + SG2042_GENERAL_PIN(PIN_FAN2, 0x08c, 378 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 379 + SG2042_GENERAL_PIN(PIN_FAN3, 0x090, 380 + PIN_FLAG_ONLY_ONE_PULL), 381 + SG2042_GENERAL_PIN(PIN_IIC0_SDA, 0x090, 382 + PIN_FLAG_WRITE_HIGH), 383 + SG2042_GENERAL_PIN(PIN_IIC0_SCL, 0x094, 384 + PIN_FLAG_DEFAULT), 385 + SG2042_GENERAL_PIN(PIN_IIC1_SDA, 0x094, 386 + PIN_FLAG_WRITE_HIGH), 387 + SG2042_GENERAL_PIN(PIN_IIC1_SCL, 0x098, 388 + PIN_FLAG_DEFAULT), 389 + SG2042_GENERAL_PIN(PIN_IIC2_SDA, 0x098, 390 + PIN_FLAG_WRITE_HIGH), 391 + SG2042_GENERAL_PIN(PIN_IIC2_SCL, 0x09c, 392 + PIN_FLAG_DEFAULT), 393 + SG2042_GENERAL_PIN(PIN_IIC3_SDA, 0x09c, 394 + PIN_FLAG_WRITE_HIGH), 395 + SG2042_GENERAL_PIN(PIN_IIC3_SCL, 0x0a0, 396 + PIN_FLAG_DEFAULT), 397 + SG2042_GENERAL_PIN(PIN_UART0_TX, 0x0a0, 398 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 399 + SG2042_GENERAL_PIN(PIN_UART0_RX, 0x0a4, 400 + PIN_FLAG_ONLY_ONE_PULL), 401 + SG2042_GENERAL_PIN(PIN_UART0_RTS, 0x0a4, 402 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 403 + SG2042_GENERAL_PIN(PIN_UART0_CTS, 0x0a8, 404 + PIN_FLAG_ONLY_ONE_PULL), 405 + SG2042_GENERAL_PIN(PIN_UART1_TX, 0x0a8, 406 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 407 + SG2042_GENERAL_PIN(PIN_UART1_RX, 0x0ac, 408 + PIN_FLAG_ONLY_ONE_PULL), 409 + SG2042_GENERAL_PIN(PIN_UART1_RTS, 0x0ac, 410 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 411 + SG2042_GENERAL_PIN(PIN_UART1_CTS, 0x0b0, 412 + PIN_FLAG_ONLY_ONE_PULL), 413 + SG2042_GENERAL_PIN(PIN_UART2_TX, 0x0b0, 414 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 415 + SG2042_GENERAL_PIN(PIN_UART2_RX, 0x0b4, 416 + PIN_FLAG_ONLY_ONE_PULL), 417 + SG2042_GENERAL_PIN(PIN_UART2_RTS, 0x0b4, 418 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 419 + SG2042_GENERAL_PIN(PIN_UART2_CTS, 0x0b8, 420 + PIN_FLAG_ONLY_ONE_PULL), 421 + SG2042_GENERAL_PIN(PIN_UART3_TX, 0x0b8, 422 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 423 + SG2042_GENERAL_PIN(PIN_UART3_RX, 0x0bc, 424 + PIN_FLAG_ONLY_ONE_PULL), 425 + SG2042_GENERAL_PIN(PIN_UART3_RTS, 0x0bc, 426 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 427 + SG2042_GENERAL_PIN(PIN_UART3_CTS, 0x0c0, 428 + PIN_FLAG_ONLY_ONE_PULL), 429 + SG2042_GENERAL_PIN(PIN_SPI0_CS0, 0x0c0, 430 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 431 + SG2042_GENERAL_PIN(PIN_SPI0_CS1, 0x0c4, 432 + PIN_FLAG_ONLY_ONE_PULL), 433 + SG2042_GENERAL_PIN(PIN_SPI0_SDI, 0x0c4, 434 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 435 + SG2042_GENERAL_PIN(PIN_SPI0_SDO, 0x0c8, 436 + PIN_FLAG_ONLY_ONE_PULL), 437 + SG2042_GENERAL_PIN(PIN_SPI0_SCK, 0x0c8, 438 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 439 + SG2042_GENERAL_PIN(PIN_SPI1_CS0, 0x0cc, 440 + PIN_FLAG_ONLY_ONE_PULL), 441 + SG2042_GENERAL_PIN(PIN_SPI1_CS1, 0x0cc, 442 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 443 + SG2042_GENERAL_PIN(PIN_SPI1_SDI, 0x0d0, 444 + PIN_FLAG_ONLY_ONE_PULL), 445 + SG2042_GENERAL_PIN(PIN_SPI1_SDO, 0x0d0, 446 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 447 + SG2042_GENERAL_PIN(PIN_SPI1_SCK, 0x0d4, 448 + PIN_FLAG_ONLY_ONE_PULL), 449 + SG2042_GENERAL_PIN(PIN_JTAG0_TDO, 0x0d4, 450 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 451 + SG2042_GENERAL_PIN(PIN_JTAG0_TCK, 0x0d8, 452 + PIN_FLAG_ONLY_ONE_PULL), 453 + SG2042_GENERAL_PIN(PIN_JTAG0_TDI, 0x0d8, 454 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 455 + SG2042_GENERAL_PIN(PIN_JTAG0_TMS, 0x0dc, 456 + PIN_FLAG_ONLY_ONE_PULL), 457 + SG2042_GENERAL_PIN(PIN_JTAG0_TRST, 0x0dc, 458 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 459 + SG2042_GENERAL_PIN(PIN_JTAG0_SRST, 0x0e0, 460 + PIN_FLAG_ONLY_ONE_PULL), 461 + SG2042_GENERAL_PIN(PIN_JTAG1_TDO, 0x0e0, 462 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 463 + SG2042_GENERAL_PIN(PIN_JTAG1_TCK, 0x0e4, 464 + PIN_FLAG_ONLY_ONE_PULL), 465 + SG2042_GENERAL_PIN(PIN_JTAG1_TDI, 0x0e4, 466 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 467 + SG2042_GENERAL_PIN(PIN_JTAG1_TMS, 0x0e8, 468 + PIN_FLAG_ONLY_ONE_PULL), 469 + SG2042_GENERAL_PIN(PIN_JTAG1_TRST, 0x0e8, 470 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 471 + SG2042_GENERAL_PIN(PIN_JTAG1_SRST, 0x0ec, 472 + PIN_FLAG_ONLY_ONE_PULL), 473 + SG2042_GENERAL_PIN(PIN_JTAG2_TDO, 0x0ec, 474 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 475 + SG2042_GENERAL_PIN(PIN_JTAG2_TCK, 0x0f0, 476 + PIN_FLAG_ONLY_ONE_PULL), 477 + SG2042_GENERAL_PIN(PIN_JTAG2_TDI, 0x0f0, 478 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 479 + SG2042_GENERAL_PIN(PIN_JTAG2_TMS, 0x0f4, 480 + PIN_FLAG_ONLY_ONE_PULL), 481 + SG2042_GENERAL_PIN(PIN_JTAG2_TRST, 0x0f4, 482 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 483 + SG2042_GENERAL_PIN(PIN_JTAG2_SRST, 0x0f8, 484 + PIN_FLAG_ONLY_ONE_PULL), 485 + SG2042_GENERAL_PIN(PIN_GPIO0, 0x0f8, 486 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 487 + SG2042_GENERAL_PIN(PIN_GPIO1, 0x0fc, 488 + PIN_FLAG_ONLY_ONE_PULL), 489 + SG2042_GENERAL_PIN(PIN_GPIO2, 0x0fc, 490 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 491 + SG2042_GENERAL_PIN(PIN_GPIO3, 0x100, 492 + PIN_FLAG_ONLY_ONE_PULL), 493 + SG2042_GENERAL_PIN(PIN_GPIO4, 0x100, 494 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 495 + SG2042_GENERAL_PIN(PIN_GPIO5, 0x104, 496 + PIN_FLAG_ONLY_ONE_PULL), 497 + SG2042_GENERAL_PIN(PIN_GPIO6, 0x104, 498 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 499 + SG2042_GENERAL_PIN(PIN_GPIO7, 0x108, 500 + PIN_FLAG_ONLY_ONE_PULL), 501 + SG2042_GENERAL_PIN(PIN_GPIO8, 0x108, 502 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 503 + SG2042_GENERAL_PIN(PIN_GPIO9, 0x10c, 504 + PIN_FLAG_ONLY_ONE_PULL), 505 + SG2042_GENERAL_PIN(PIN_GPIO10, 0x10c, 506 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 507 + SG2042_GENERAL_PIN(PIN_GPIO11, 0x110, 508 + PIN_FLAG_ONLY_ONE_PULL), 509 + SG2042_GENERAL_PIN(PIN_GPIO12, 0x110, 510 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 511 + SG2042_GENERAL_PIN(PIN_GPIO13, 0x114, 512 + PIN_FLAG_ONLY_ONE_PULL), 513 + SG2042_GENERAL_PIN(PIN_GPIO14, 0x114, 514 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 515 + SG2042_GENERAL_PIN(PIN_GPIO15, 0x118, 516 + PIN_FLAG_ONLY_ONE_PULL), 517 + SG2042_GENERAL_PIN(PIN_GPIO16, 0x118, 518 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 519 + SG2042_GENERAL_PIN(PIN_GPIO17, 0x11c, 520 + PIN_FLAG_ONLY_ONE_PULL), 521 + SG2042_GENERAL_PIN(PIN_GPIO18, 0x11c, 522 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 523 + SG2042_GENERAL_PIN(PIN_GPIO19, 0x120, 524 + PIN_FLAG_ONLY_ONE_PULL), 525 + SG2042_GENERAL_PIN(PIN_GPIO20, 0x120, 526 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 527 + SG2042_GENERAL_PIN(PIN_GPIO21, 0x124, 528 + PIN_FLAG_ONLY_ONE_PULL), 529 + SG2042_GENERAL_PIN(PIN_GPIO22, 0x124, 530 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 531 + SG2042_GENERAL_PIN(PIN_GPIO23, 0x128, 532 + PIN_FLAG_ONLY_ONE_PULL), 533 + SG2042_GENERAL_PIN(PIN_GPIO24, 0x128, 534 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 535 + SG2042_GENERAL_PIN(PIN_GPIO25, 0x12c, 536 + PIN_FLAG_ONLY_ONE_PULL), 537 + SG2042_GENERAL_PIN(PIN_GPIO26, 0x12c, 538 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 539 + SG2042_GENERAL_PIN(PIN_GPIO27, 0x130, 540 + PIN_FLAG_ONLY_ONE_PULL), 541 + SG2042_GENERAL_PIN(PIN_GPIO28, 0x130, 542 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 543 + SG2042_GENERAL_PIN(PIN_GPIO29, 0x134, 544 + PIN_FLAG_ONLY_ONE_PULL), 545 + SG2042_GENERAL_PIN(PIN_GPIO30, 0x134, 546 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL), 547 + SG2042_GENERAL_PIN(PIN_GPIO31, 0x138, 548 + PIN_FLAG_ONLY_ONE_PULL), 549 + SG2042_GENERAL_PIN(PIN_MODE_SEL0, 0x138, 550 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL | 551 + PIN_FLAG_NO_PINMUX | PIN_FLAG_NO_OEX_EN), 552 + SG2042_GENERAL_PIN(PIN_MODE_SEL1, 0x13c, 553 + PIN_FLAG_ONLY_ONE_PULL | PIN_FLAG_NO_PINMUX | 554 + PIN_FLAG_NO_OEX_EN), 555 + SG2042_GENERAL_PIN(PIN_MODE_SEL2, 0x13c, 556 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL | 557 + PIN_FLAG_NO_PINMUX | PIN_FLAG_NO_OEX_EN), 558 + SG2042_GENERAL_PIN(PIN_BOOT_SEL0, 0x140, 559 + PIN_FLAG_ONLY_ONE_PULL | PIN_FLAG_NO_PINMUX | 560 + PIN_FLAG_NO_OEX_EN), 561 + SG2042_GENERAL_PIN(PIN_BOOT_SEL1, 0x140, 562 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL | 563 + PIN_FLAG_NO_PINMUX | PIN_FLAG_NO_OEX_EN), 564 + SG2042_GENERAL_PIN(PIN_BOOT_SEL2, 0x144, 565 + PIN_FLAG_ONLY_ONE_PULL | PIN_FLAG_NO_PINMUX | 566 + PIN_FLAG_NO_OEX_EN), 567 + SG2042_GENERAL_PIN(PIN_BOOT_SEL3, 0x144, 568 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL | 569 + PIN_FLAG_NO_PINMUX | PIN_FLAG_NO_OEX_EN), 570 + SG2042_GENERAL_PIN(PIN_BOOT_SEL4, 0x148, 571 + PIN_FLAG_ONLY_ONE_PULL | PIN_FLAG_NO_PINMUX | 572 + PIN_FLAG_NO_OEX_EN), 573 + SG2042_GENERAL_PIN(PIN_BOOT_SEL5, 0x148, 574 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL | 575 + PIN_FLAG_NO_PINMUX | PIN_FLAG_NO_OEX_EN), 576 + SG2042_GENERAL_PIN(PIN_BOOT_SEL6, 0x14c, 577 + PIN_FLAG_ONLY_ONE_PULL | PIN_FLAG_NO_PINMUX | 578 + PIN_FLAG_NO_OEX_EN), 579 + SG2042_GENERAL_PIN(PIN_BOOT_SEL7, 0x14c, 580 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL | 581 + PIN_FLAG_NO_PINMUX | PIN_FLAG_NO_OEX_EN), 582 + SG2042_GENERAL_PIN(PIN_MULTI_SCKT, 0x150, 583 + PIN_FLAG_ONLY_ONE_PULL | PIN_FLAG_NO_PINMUX | 584 + PIN_FLAG_NO_OEX_EN), 585 + SG2042_GENERAL_PIN(PIN_SCKT_ID0, 0x150, 586 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL | 587 + PIN_FLAG_NO_PINMUX | PIN_FLAG_NO_OEX_EN), 588 + SG2042_GENERAL_PIN(PIN_SCKT_ID1, 0x154, 589 + PIN_FLAG_ONLY_ONE_PULL | PIN_FLAG_NO_PINMUX | 590 + PIN_FLAG_NO_OEX_EN), 591 + SG2042_GENERAL_PIN(PIN_PLL_CLK_IN_MAIN, 0x154, 592 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL | 593 + PIN_FLAG_NO_PINMUX | PIN_FLAG_NO_OEX_EN), 594 + SG2042_GENERAL_PIN(PIN_PLL_CLK_IN_DDR_L, 0x158, 595 + PIN_FLAG_ONLY_ONE_PULL | PIN_FLAG_NO_PINMUX | 596 + PIN_FLAG_NO_OEX_EN), 597 + SG2042_GENERAL_PIN(PIN_PLL_CLK_IN_DDR_R, 0x158, 598 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL | 599 + PIN_FLAG_NO_PINMUX | PIN_FLAG_NO_OEX_EN), 600 + SG2042_GENERAL_PIN(PIN_XTAL_32K, 0x15c, 601 + PIN_FLAG_ONLY_ONE_PULL | PIN_FLAG_NO_PINMUX | 602 + PIN_FLAG_NO_OEX_EN), 603 + SG2042_GENERAL_PIN(PIN_SYS_RST, 0x15c, 604 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL | 605 + PIN_FLAG_NO_PINMUX | PIN_FLAG_NO_OEX_EN), 606 + SG2042_GENERAL_PIN(PIN_PWR_BUTTON, 0x160, 607 + PIN_FLAG_ONLY_ONE_PULL | PIN_FLAG_NO_PINMUX | 608 + PIN_FLAG_NO_OEX_EN), 609 + SG2042_GENERAL_PIN(PIN_TEST_EN, 0x160, 610 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL | 611 + PIN_FLAG_NO_PINMUX | PIN_FLAG_NO_OEX_EN), 612 + SG2042_GENERAL_PIN(PIN_TEST_MODE_MBIST, 0x164, 613 + PIN_FLAG_ONLY_ONE_PULL | PIN_FLAG_NO_PINMUX | 614 + PIN_FLAG_NO_OEX_EN), 615 + SG2042_GENERAL_PIN(PIN_TEST_MODE_SCAN, 0x164, 616 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL | 617 + PIN_FLAG_NO_PINMUX | PIN_FLAG_NO_OEX_EN), 618 + SG2042_GENERAL_PIN(PIN_TEST_MODE_BSD, 0x168, 619 + PIN_FLAG_ONLY_ONE_PULL | PIN_FLAG_NO_PINMUX | 620 + PIN_FLAG_NO_OEX_EN), 621 + SG2042_GENERAL_PIN(PIN_BISR_BYP, 0x168, 622 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_ONLY_ONE_PULL | 623 + PIN_FLAG_NO_PINMUX | PIN_FLAG_NO_OEX_EN), 624 + }; 625 + 626 + static const struct sophgo_pinctrl_data sg2042_pindata = { 627 + .pins = sg2042_pins, 628 + .pindata = sg2042_pin_data, 629 + .vddio_ops = &sg2042_vddio_cfg_ops, 630 + .cfg_ops = &sg2042_cfg_ops, 631 + .pctl_ops = &sg2042_pctrl_ops, 632 + .pmx_ops = &sg2042_pmx_ops, 633 + .pconf_ops = &sg2042_pconf_ops, 634 + .npins = ARRAY_SIZE(sg2042_pins), 635 + .pinsize = sizeof(struct sg2042_pin), 636 + }; 637 + 638 + static const struct of_device_id sg2042_pinctrl_ids[] = { 639 + { .compatible = "sophgo,sg2042-pinctrl", .data = &sg2042_pindata }, 640 + { } 641 + }; 642 + MODULE_DEVICE_TABLE(of, sg2042_pinctrl_ids); 643 + 644 + static struct platform_driver sg2042_pinctrl_driver = { 645 + .probe = sophgo_pinctrl_probe, 646 + .driver = { 647 + .name = "sg2042-pinctrl", 648 + .suppress_bind_attrs = true, 649 + .of_match_table = sg2042_pinctrl_ids, 650 + }, 651 + }; 652 + module_platform_driver(sg2042_pinctrl_driver); 653 + 654 + MODULE_DESCRIPTION("Pinctrl driver for the SG2002 series SoC"); 655 + MODULE_LICENSE("GPL");
+49
drivers/pinctrl/sophgo/pinctrl-sg2042.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + /* 3 + * Copyright (C) 2024 Inochi Amaoto <inochiama@outlook.com> 4 + */ 5 + 6 + #ifndef _PINCTRL_SOPHGO_SG2042_H 7 + #define _PINCTRL_SOPHGO_SG2042_H 8 + 9 + #include <linux/bits.h> 10 + #include <linux/bitfield.h> 11 + #include <linux/device.h> 12 + #include <linux/mutex.h> 13 + #include <linux/spinlock.h> 14 + #include <linux/platform_device.h> 15 + #include <linux/pinctrl/pinctrl.h> 16 + #include <linux/pinctrl/pinconf.h> 17 + 18 + #include "pinctrl-sophgo.h" 19 + 20 + #define PIN_FLAG_DEFAULT 0 21 + #define PIN_FLAG_WRITE_HIGH BIT(0) 22 + #define PIN_FLAG_ONLY_ONE_PULL BIT(1) 23 + #define PIN_FLAG_NO_PINMUX BIT(2) 24 + #define PIN_FLAG_NO_OEX_EN BIT(3) 25 + #define PIN_FLAG_IS_ETH BIT(4) 26 + 27 + struct sg2042_pin { 28 + struct sophgo_pin pin; 29 + u16 offset; 30 + }; 31 + 32 + #define sophgo_to_sg2042_pin(_pin) \ 33 + container_of((_pin), struct sg2042_pin, pin) 34 + 35 + extern const struct pinctrl_ops sg2042_pctrl_ops; 36 + extern const struct pinmux_ops sg2042_pmx_ops; 37 + extern const struct pinconf_ops sg2042_pconf_ops; 38 + extern const struct sophgo_cfg_ops sg2042_cfg_ops; 39 + 40 + #define SG2042_GENERAL_PIN(_id, _offset, _flag) \ 41 + { \ 42 + .pin = { \ 43 + .id = (_id), \ 44 + .flags = (_flag), \ 45 + }, \ 46 + .offset = (_offset), \ 47 + } 48 + 49 + #endif
+718
drivers/pinctrl/sophgo/pinctrl-sg2044.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Sophgo SG2042 SoC pinctrl driver. 4 + * 5 + * Copyright (C) 2024 Inochi Amaoto <inochiama@outlook.com> 6 + */ 7 + 8 + #include <linux/module.h> 9 + #include <linux/platform_device.h> 10 + #include <linux/of.h> 11 + 12 + #include <linux/pinctrl/pinctrl.h> 13 + #include <linux/pinctrl/pinmux.h> 14 + 15 + #include <dt-bindings/pinctrl/pinctrl-sg2044.h> 16 + 17 + #include "pinctrl-sg2042.h" 18 + 19 + static int sg2044_get_pull_up(const struct sophgo_pin *sp, const u32 *psmap) 20 + { 21 + return 19500; 22 + } 23 + 24 + static int sg2044_get_pull_down(const struct sophgo_pin *sp, const u32 *psmap) 25 + { 26 + return 23200; 27 + } 28 + 29 + static const u32 sg2044_oc_map[] = { 30 + 3200, 6400, 9600, 12700, 31 + 15900, 19100, 22200, 25300, 32 + 29500, 32700, 35900, 39000, 33 + 42000, 45200, 48300, 51400 34 + }; 35 + 36 + static int sg2044_get_oc_map(const struct sophgo_pin *sp, const u32 *psmap, 37 + const u32 **map) 38 + { 39 + *map = sg2044_oc_map; 40 + return ARRAY_SIZE(sg2044_oc_map); 41 + } 42 + 43 + static const struct sophgo_vddio_cfg_ops sg2044_vddio_cfg_ops = { 44 + .get_pull_up = sg2044_get_pull_up, 45 + .get_pull_down = sg2044_get_pull_down, 46 + .get_oc_map = sg2044_get_oc_map, 47 + }; 48 + 49 + static const struct pinctrl_pin_desc sg2044_pins[] = { 50 + PINCTRL_PIN(PIN_IIC0_SMBSUS_IN, "iic0_smbsus_in"), 51 + PINCTRL_PIN(PIN_IIC0_SMBSUS_OUT, "iic0_smbsus_out"), 52 + PINCTRL_PIN(PIN_IIC0_SMBALERT, "iic0_smbalert"), 53 + PINCTRL_PIN(PIN_IIC1_SMBSUS_IN, "iic1_smbsus_in"), 54 + PINCTRL_PIN(PIN_IIC1_SMBSUS_OUT, "iic1_smbsus_out"), 55 + PINCTRL_PIN(PIN_IIC1_SMBALERT, "iic1_smbalert"), 56 + PINCTRL_PIN(PIN_IIC2_SMBSUS_IN, "iic2_smbsus_in"), 57 + PINCTRL_PIN(PIN_IIC2_SMBSUS_OUT, "iic2_smbsus_out"), 58 + PINCTRL_PIN(PIN_IIC2_SMBALERT, "iic2_smbalert"), 59 + PINCTRL_PIN(PIN_IIC3_SMBSUS_IN, "iic3_smbsus_in"), 60 + PINCTRL_PIN(PIN_IIC3_SMBSUS_OUT, "iic3_smbsus_out"), 61 + PINCTRL_PIN(PIN_IIC3_SMBALERT, "iic3_smbalert"), 62 + PINCTRL_PIN(PIN_PCIE0_L0_RESET, "pcie0_l0_reset"), 63 + PINCTRL_PIN(PIN_PCIE0_L1_RESET, "pcie0_l1_reset"), 64 + PINCTRL_PIN(PIN_PCIE0_L0_WAKEUP, "pcie0_l0_wakeup"), 65 + PINCTRL_PIN(PIN_PCIE0_L1_WAKEUP, "pcie0_l1_wakeup"), 66 + PINCTRL_PIN(PIN_PCIE0_L0_CLKREQ_IN, "pcie0_l0_clkreq_in"), 67 + PINCTRL_PIN(PIN_PCIE0_L1_CLKREQ_IN, "pcie0_l1_clkreq_in"), 68 + PINCTRL_PIN(PIN_PCIE1_L0_RESET, "pcie1_l0_reset"), 69 + PINCTRL_PIN(PIN_PCIE1_L1_RESET, "pcie1_l1_reset"), 70 + PINCTRL_PIN(PIN_PCIE1_L0_WAKEUP, "pcie1_l0_wakeup"), 71 + PINCTRL_PIN(PIN_PCIE1_L1_WAKEUP, "pcie1_l1_wakeup"), 72 + PINCTRL_PIN(PIN_PCIE1_L0_CLKREQ_IN, "pcie1_l0_clkreq_in"), 73 + PINCTRL_PIN(PIN_PCIE1_L1_CLKREQ_IN, "pcie1_l1_clkreq_in"), 74 + PINCTRL_PIN(PIN_PCIE2_L0_RESET, "pcie2_l0_reset"), 75 + PINCTRL_PIN(PIN_PCIE2_L1_RESET, "pcie2_l1_reset"), 76 + PINCTRL_PIN(PIN_PCIE2_L0_WAKEUP, "pcie2_l0_wakeup"), 77 + PINCTRL_PIN(PIN_PCIE2_L1_WAKEUP, "pcie2_l1_wakeup"), 78 + PINCTRL_PIN(PIN_PCIE2_L0_CLKREQ_IN, "pcie2_l0_clkreq_in"), 79 + PINCTRL_PIN(PIN_PCIE2_L1_CLKREQ_IN, "pcie2_l1_clkreq_in"), 80 + PINCTRL_PIN(PIN_PCIE3_L0_RESET, "pcie3_l0_reset"), 81 + PINCTRL_PIN(PIN_PCIE3_L1_RESET, "pcie3_l1_reset"), 82 + PINCTRL_PIN(PIN_PCIE3_L0_WAKEUP, "pcie3_l0_wakeup"), 83 + PINCTRL_PIN(PIN_PCIE3_L1_WAKEUP, "pcie3_l1_wakeup"), 84 + PINCTRL_PIN(PIN_PCIE3_L0_CLKREQ_IN, "pcie3_l0_clkreq_in"), 85 + PINCTRL_PIN(PIN_PCIE3_L1_CLKREQ_IN, "pcie3_l1_clkreq_in"), 86 + PINCTRL_PIN(PIN_PCIE4_L0_RESET, "pcie4_l0_reset"), 87 + PINCTRL_PIN(PIN_PCIE4_L1_RESET, "pcie4_l1_reset"), 88 + PINCTRL_PIN(PIN_PCIE4_L0_WAKEUP, "pcie4_l0_wakeup"), 89 + PINCTRL_PIN(PIN_PCIE4_L1_WAKEUP, "pcie4_l1_wakeup"), 90 + PINCTRL_PIN(PIN_PCIE4_L0_CLKREQ_IN, "pcie4_l0_clkreq_in"), 91 + PINCTRL_PIN(PIN_PCIE4_L1_CLKREQ_IN, "pcie4_l1_clkreq_in"), 92 + PINCTRL_PIN(PIN_SPIF0_CLK_SEL1, "spif0_clk_sel1"), 93 + PINCTRL_PIN(PIN_SPIF0_CLK_SEL0, "spif0_clk_sel0"), 94 + PINCTRL_PIN(PIN_SPIF0_WP, "spif0_wp"), 95 + PINCTRL_PIN(PIN_SPIF0_HOLD, "spif0_hold"), 96 + PINCTRL_PIN(PIN_SPIF0_SDI, "spif0_sdi"), 97 + PINCTRL_PIN(PIN_SPIF0_CS, "spif0_cs"), 98 + PINCTRL_PIN(PIN_SPIF0_SCK, "spif0_sck"), 99 + PINCTRL_PIN(PIN_SPIF0_SDO, "spif0_sdo"), 100 + PINCTRL_PIN(PIN_SPIF1_CLK_SEL1, "spif1_clk_sel1"), 101 + PINCTRL_PIN(PIN_SPIF1_CLK_SEL0, "spif1_clk_sel0"), 102 + PINCTRL_PIN(PIN_SPIF1_WP, "spif1_wp"), 103 + PINCTRL_PIN(PIN_SPIF1_HOLD, "spif1_hold"), 104 + PINCTRL_PIN(PIN_SPIF1_SDI, "spif1_sdi"), 105 + PINCTRL_PIN(PIN_SPIF1_CS, "spif1_cs"), 106 + PINCTRL_PIN(PIN_SPIF1_SCK, "spif1_sck"), 107 + PINCTRL_PIN(PIN_SPIF1_SDO, "spif1_sdo"), 108 + PINCTRL_PIN(PIN_EMMC_WP, "emmc_wp"), 109 + PINCTRL_PIN(PIN_EMMC_CD, "emmc_cd"), 110 + PINCTRL_PIN(PIN_EMMC_RST, "emmc_rst"), 111 + PINCTRL_PIN(PIN_EMMC_PWR_EN, "emmc_pwr_en"), 112 + PINCTRL_PIN(PIN_SDIO_CD, "sdio_cd"), 113 + PINCTRL_PIN(PIN_SDIO_WP, "sdio_wp"), 114 + PINCTRL_PIN(PIN_SDIO_RST, "sdio_rst"), 115 + PINCTRL_PIN(PIN_SDIO_PWR_EN, "sdio_pwr_en"), 116 + PINCTRL_PIN(PIN_RGMII0_TXD0, "rgmii0_txd0"), 117 + PINCTRL_PIN(PIN_RGMII0_TXD1, "rgmii0_txd1"), 118 + PINCTRL_PIN(PIN_RGMII0_TXD2, "rgmii0_txd2"), 119 + PINCTRL_PIN(PIN_RGMII0_TXD3, "rgmii0_txd3"), 120 + PINCTRL_PIN(PIN_RGMII0_TXCTRL, "rgmii0_txctrl"), 121 + PINCTRL_PIN(PIN_RGMII0_RXD0, "rgmii0_rxd0"), 122 + PINCTRL_PIN(PIN_RGMII0_RXD1, "rgmii0_rxd1"), 123 + PINCTRL_PIN(PIN_RGMII0_RXD2, "rgmii0_rxd2"), 124 + PINCTRL_PIN(PIN_RGMII0_RXD3, "rgmii0_rxd3"), 125 + PINCTRL_PIN(PIN_RGMII0_RXCTRL, "rgmii0_rxctrl"), 126 + PINCTRL_PIN(PIN_RGMII0_TXC, "rgmii0_txc"), 127 + PINCTRL_PIN(PIN_RGMII0_RXC, "rgmii0_rxc"), 128 + PINCTRL_PIN(PIN_RGMII0_REFCLKO, "rgmii0_refclko"), 129 + PINCTRL_PIN(PIN_RGMII0_IRQ, "rgmii0_irq"), 130 + PINCTRL_PIN(PIN_RGMII0_MDC, "rgmii0_mdc"), 131 + PINCTRL_PIN(PIN_RGMII0_MDIO, "rgmii0_mdio"), 132 + PINCTRL_PIN(PIN_PWM0, "pwm0"), 133 + PINCTRL_PIN(PIN_PWM1, "pwm1"), 134 + PINCTRL_PIN(PIN_PWM2, "pwm2"), 135 + PINCTRL_PIN(PIN_PWM3, "pwm3"), 136 + PINCTRL_PIN(PIN_FAN0, "fan0"), 137 + PINCTRL_PIN(PIN_FAN1, "fan1"), 138 + PINCTRL_PIN(PIN_FAN2, "fan2"), 139 + PINCTRL_PIN(PIN_FAN3, "fan3"), 140 + PINCTRL_PIN(PIN_IIC0_SDA, "iic0_sda"), 141 + PINCTRL_PIN(PIN_IIC0_SCL, "iic0_scl"), 142 + PINCTRL_PIN(PIN_IIC1_SDA, "iic1_sda"), 143 + PINCTRL_PIN(PIN_IIC1_SCL, "iic1_scl"), 144 + PINCTRL_PIN(PIN_IIC2_SDA, "iic2_sda"), 145 + PINCTRL_PIN(PIN_IIC2_SCL, "iic2_scl"), 146 + PINCTRL_PIN(PIN_IIC3_SDA, "iic3_sda"), 147 + PINCTRL_PIN(PIN_IIC3_SCL, "iic3_scl"), 148 + PINCTRL_PIN(PIN_UART0_TX, "uart0_tx"), 149 + PINCTRL_PIN(PIN_UART0_RX, "uart0_rx"), 150 + PINCTRL_PIN(PIN_UART0_RTS, "uart0_rts"), 151 + PINCTRL_PIN(PIN_UART0_CTS, "uart0_cts"), 152 + PINCTRL_PIN(PIN_UART1_TX, "uart1_tx"), 153 + PINCTRL_PIN(PIN_UART1_RX, "uart1_rx"), 154 + PINCTRL_PIN(PIN_UART1_RTS, "uart1_rts"), 155 + PINCTRL_PIN(PIN_UART1_CTS, "uart1_cts"), 156 + PINCTRL_PIN(PIN_UART2_TX, "uart2_tx"), 157 + PINCTRL_PIN(PIN_UART2_RX, "uart2_rx"), 158 + PINCTRL_PIN(PIN_UART2_RTS, "uart2_rts"), 159 + PINCTRL_PIN(PIN_UART2_CTS, "uart2_cts"), 160 + PINCTRL_PIN(PIN_UART3_TX, "uart3_tx"), 161 + PINCTRL_PIN(PIN_UART3_RX, "uart3_rx"), 162 + PINCTRL_PIN(PIN_UART3_RTS, "uart3_rts"), 163 + PINCTRL_PIN(PIN_UART3_CTS, "uart3_cts"), 164 + PINCTRL_PIN(PIN_SPI0_CS0, "spi0_cs0"), 165 + PINCTRL_PIN(PIN_SPI0_CS1, "spi0_cs1"), 166 + PINCTRL_PIN(PIN_SPI0_SDI, "spi0_sdi"), 167 + PINCTRL_PIN(PIN_SPI0_SDO, "spi0_sdo"), 168 + PINCTRL_PIN(PIN_SPI0_SCK, "spi0_sck"), 169 + PINCTRL_PIN(PIN_SPI1_CS0, "spi1_cs0"), 170 + PINCTRL_PIN(PIN_SPI1_CS1, "spi1_cs1"), 171 + PINCTRL_PIN(PIN_SPI1_SDI, "spi1_sdi"), 172 + PINCTRL_PIN(PIN_SPI1_SDO, "spi1_sdo"), 173 + PINCTRL_PIN(PIN_SPI1_SCK, "spi1_sck"), 174 + PINCTRL_PIN(PIN_JTAG0_TDO, "jtag0_tdo"), 175 + PINCTRL_PIN(PIN_JTAG0_TCK, "jtag0_tck"), 176 + PINCTRL_PIN(PIN_JTAG0_TDI, "jtag0_tdi"), 177 + PINCTRL_PIN(PIN_JTAG0_TMS, "jtag0_tms"), 178 + PINCTRL_PIN(PIN_JTAG0_TRST, "jtag0_trst"), 179 + PINCTRL_PIN(PIN_JTAG0_SRST, "jtag0_srst"), 180 + PINCTRL_PIN(PIN_JTAG1_TDO, "jtag1_tdo"), 181 + PINCTRL_PIN(PIN_JTAG1_TCK, "jtag1_tck"), 182 + PINCTRL_PIN(PIN_JTAG1_TDI, "jtag1_tdi"), 183 + PINCTRL_PIN(PIN_JTAG1_TMS, "jtag1_tms"), 184 + PINCTRL_PIN(PIN_JTAG1_TRST, "jtag1_trst"), 185 + PINCTRL_PIN(PIN_JTAG1_SRST, "jtag1_srst"), 186 + PINCTRL_PIN(PIN_JTAG2_TDO, "jtag2_tdo"), 187 + PINCTRL_PIN(PIN_JTAG2_TCK, "jtag2_tck"), 188 + PINCTRL_PIN(PIN_JTAG2_TDI, "jtag2_tdi"), 189 + PINCTRL_PIN(PIN_JTAG2_TMS, "jtag2_tms"), 190 + PINCTRL_PIN(PIN_JTAG2_TRST, "jtag2_trst"), 191 + PINCTRL_PIN(PIN_JTAG2_SRST, "jtag2_srst"), 192 + PINCTRL_PIN(PIN_JTAG3_TDO, "jtag3_tdo"), 193 + PINCTRL_PIN(PIN_JTAG3_TCK, "jtag3_tck"), 194 + PINCTRL_PIN(PIN_JTAG3_TDI, "jtag3_tdi"), 195 + PINCTRL_PIN(PIN_JTAG3_TMS, "jtag3_tms"), 196 + PINCTRL_PIN(PIN_JTAG3_TRST, "jtag3_trst"), 197 + PINCTRL_PIN(PIN_JTAG3_SRST, "jtag3_srst"), 198 + PINCTRL_PIN(PIN_GPIO0, "gpio0"), 199 + PINCTRL_PIN(PIN_GPIO1, "gpio1"), 200 + PINCTRL_PIN(PIN_GPIO2, "gpio2"), 201 + PINCTRL_PIN(PIN_GPIO3, "gpio3"), 202 + PINCTRL_PIN(PIN_GPIO4, "gpio4"), 203 + PINCTRL_PIN(PIN_GPIO5, "gpio5"), 204 + PINCTRL_PIN(PIN_GPIO6, "gpio6"), 205 + PINCTRL_PIN(PIN_GPIO7, "gpio7"), 206 + PINCTRL_PIN(PIN_GPIO8, "gpio8"), 207 + PINCTRL_PIN(PIN_GPIO9, "gpio9"), 208 + PINCTRL_PIN(PIN_GPIO10, "gpio10"), 209 + PINCTRL_PIN(PIN_GPIO11, "gpio11"), 210 + PINCTRL_PIN(PIN_GPIO12, "gpio12"), 211 + PINCTRL_PIN(PIN_GPIO13, "gpio13"), 212 + PINCTRL_PIN(PIN_GPIO14, "gpio14"), 213 + PINCTRL_PIN(PIN_GPIO15, "gpio15"), 214 + PINCTRL_PIN(PIN_GPIO16, "gpio16"), 215 + PINCTRL_PIN(PIN_GPIO17, "gpio17"), 216 + PINCTRL_PIN(PIN_GPIO18, "gpio18"), 217 + PINCTRL_PIN(PIN_GPIO19, "gpio19"), 218 + PINCTRL_PIN(PIN_GPIO20, "gpio20"), 219 + PINCTRL_PIN(PIN_GPIO21, "gpio21"), 220 + PINCTRL_PIN(PIN_GPIO22, "gpio22"), 221 + PINCTRL_PIN(PIN_GPIO23, "gpio23"), 222 + PINCTRL_PIN(PIN_GPIO24, "gpio24"), 223 + PINCTRL_PIN(PIN_GPIO25, "gpio25"), 224 + PINCTRL_PIN(PIN_GPIO26, "gpio26"), 225 + PINCTRL_PIN(PIN_GPIO27, "gpio27"), 226 + PINCTRL_PIN(PIN_GPIO28, "gpio28"), 227 + PINCTRL_PIN(PIN_GPIO29, "gpio29"), 228 + PINCTRL_PIN(PIN_GPIO30, "gpio30"), 229 + PINCTRL_PIN(PIN_GPIO31, "gpio31"), 230 + PINCTRL_PIN(PIN_MODE_SEL0, "mode_sel0"), 231 + PINCTRL_PIN(PIN_MODE_SEL1, "mode_sel1"), 232 + PINCTRL_PIN(PIN_MODE_SEL2, "mode_sel2"), 233 + PINCTRL_PIN(PIN_BOOT_SEL0, "boot_sel0"), 234 + PINCTRL_PIN(PIN_BOOT_SEL1, "boot_sel1"), 235 + PINCTRL_PIN(PIN_BOOT_SEL2, "boot_sel2"), 236 + PINCTRL_PIN(PIN_BOOT_SEL3, "boot_sel3"), 237 + PINCTRL_PIN(PIN_BOOT_SEL4, "boot_sel4"), 238 + PINCTRL_PIN(PIN_BOOT_SEL5, "boot_sel5"), 239 + PINCTRL_PIN(PIN_BOOT_SEL6, "boot_sel6"), 240 + PINCTRL_PIN(PIN_BOOT_SEL7, "boot_sel7"), 241 + PINCTRL_PIN(PIN_MULTI_SCKT, "multi_sckt"), 242 + PINCTRL_PIN(PIN_SCKT_ID0, "sckt_id0"), 243 + PINCTRL_PIN(PIN_SCKT_ID1, "sckt_id1"), 244 + PINCTRL_PIN(PIN_PLL_CLK_IN_MAIN, "pll_clk_in_main"), 245 + PINCTRL_PIN(PIN_PLL_CLK_IN_DDR_0, "pll_clk_in_ddr_0"), 246 + PINCTRL_PIN(PIN_PLL_CLK_IN_DDR_1, "pll_clk_in_ddr_1"), 247 + PINCTRL_PIN(PIN_PLL_CLK_IN_DDR_2, "pll_clk_in_ddr_2"), 248 + PINCTRL_PIN(PIN_PLL_CLK_IN_DDR_3, "pll_clk_in_ddr_3"), 249 + PINCTRL_PIN(PIN_XTAL_32K, "xtal_32k"), 250 + PINCTRL_PIN(PIN_SYS_RST, "sys_rst"), 251 + PINCTRL_PIN(PIN_PWR_BUTTON, "pwr_button"), 252 + PINCTRL_PIN(PIN_TEST_EN, "test_en"), 253 + PINCTRL_PIN(PIN_TEST_MODE_MBIST, "test_mode_mbist"), 254 + PINCTRL_PIN(PIN_TEST_MODE_SCAN, "test_mode_scan"), 255 + PINCTRL_PIN(PIN_TEST_MODE_BSD, "test_mode_bsd"), 256 + PINCTRL_PIN(PIN_BISR_BYP, "bisr_byp"), 257 + }; 258 + 259 + static const struct sg2042_pin sg2044_pin_data[ARRAY_SIZE(sg2044_pins)] = { 260 + SG2042_GENERAL_PIN(PIN_IIC0_SMBSUS_IN, 0x000, 261 + PIN_FLAG_DEFAULT), 262 + SG2042_GENERAL_PIN(PIN_IIC0_SMBSUS_OUT, 0x000, 263 + PIN_FLAG_WRITE_HIGH), 264 + SG2042_GENERAL_PIN(PIN_IIC0_SMBALERT, 0x004, 265 + PIN_FLAG_DEFAULT), 266 + SG2042_GENERAL_PIN(PIN_IIC1_SMBSUS_IN, 0x004, 267 + PIN_FLAG_WRITE_HIGH), 268 + SG2042_GENERAL_PIN(PIN_IIC1_SMBSUS_OUT, 0x008, 269 + PIN_FLAG_DEFAULT), 270 + SG2042_GENERAL_PIN(PIN_IIC1_SMBALERT, 0x008, 271 + PIN_FLAG_WRITE_HIGH), 272 + SG2042_GENERAL_PIN(PIN_IIC2_SMBSUS_IN, 0x00c, 273 + PIN_FLAG_DEFAULT), 274 + SG2042_GENERAL_PIN(PIN_IIC2_SMBSUS_OUT, 0x00c, 275 + PIN_FLAG_WRITE_HIGH), 276 + SG2042_GENERAL_PIN(PIN_IIC2_SMBALERT, 0x010, 277 + PIN_FLAG_DEFAULT), 278 + SG2042_GENERAL_PIN(PIN_IIC3_SMBSUS_IN, 0x010, 279 + PIN_FLAG_WRITE_HIGH), 280 + SG2042_GENERAL_PIN(PIN_IIC3_SMBSUS_OUT, 0x014, 281 + PIN_FLAG_DEFAULT), 282 + SG2042_GENERAL_PIN(PIN_IIC3_SMBALERT, 0x014, 283 + PIN_FLAG_WRITE_HIGH), 284 + SG2042_GENERAL_PIN(PIN_PCIE0_L0_RESET, 0x018, 285 + PIN_FLAG_DEFAULT), 286 + SG2042_GENERAL_PIN(PIN_PCIE0_L1_RESET, 0x018, 287 + PIN_FLAG_WRITE_HIGH), 288 + SG2042_GENERAL_PIN(PIN_PCIE0_L0_WAKEUP, 0x01c, 289 + PIN_FLAG_DEFAULT), 290 + SG2042_GENERAL_PIN(PIN_PCIE0_L1_WAKEUP, 0x01c, 291 + PIN_FLAG_WRITE_HIGH), 292 + SG2042_GENERAL_PIN(PIN_PCIE0_L0_CLKREQ_IN, 0x020, 293 + PIN_FLAG_DEFAULT), 294 + SG2042_GENERAL_PIN(PIN_PCIE0_L1_CLKREQ_IN, 0x020, 295 + PIN_FLAG_WRITE_HIGH), 296 + SG2042_GENERAL_PIN(PIN_PCIE1_L0_RESET, 0x024, 297 + PIN_FLAG_DEFAULT), 298 + SG2042_GENERAL_PIN(PIN_PCIE1_L1_RESET, 0x024, 299 + PIN_FLAG_WRITE_HIGH), 300 + SG2042_GENERAL_PIN(PIN_PCIE1_L0_WAKEUP, 0x028, 301 + PIN_FLAG_DEFAULT), 302 + SG2042_GENERAL_PIN(PIN_PCIE1_L1_WAKEUP, 0x028, 303 + PIN_FLAG_WRITE_HIGH), 304 + SG2042_GENERAL_PIN(PIN_PCIE1_L0_CLKREQ_IN, 0x02c, 305 + PIN_FLAG_DEFAULT), 306 + SG2042_GENERAL_PIN(PIN_PCIE1_L1_CLKREQ_IN, 0x02c, 307 + PIN_FLAG_WRITE_HIGH), 308 + SG2042_GENERAL_PIN(PIN_PCIE2_L0_RESET, 0x030, 309 + PIN_FLAG_DEFAULT), 310 + SG2042_GENERAL_PIN(PIN_PCIE2_L1_RESET, 0x030, 311 + PIN_FLAG_WRITE_HIGH), 312 + SG2042_GENERAL_PIN(PIN_PCIE2_L0_WAKEUP, 0x034, 313 + PIN_FLAG_DEFAULT), 314 + SG2042_GENERAL_PIN(PIN_PCIE2_L1_WAKEUP, 0x034, 315 + PIN_FLAG_WRITE_HIGH), 316 + SG2042_GENERAL_PIN(PIN_PCIE2_L0_CLKREQ_IN, 0x038, 317 + PIN_FLAG_DEFAULT), 318 + SG2042_GENERAL_PIN(PIN_PCIE2_L1_CLKREQ_IN, 0x038, 319 + PIN_FLAG_WRITE_HIGH), 320 + SG2042_GENERAL_PIN(PIN_PCIE3_L0_RESET, 0x03c, 321 + PIN_FLAG_DEFAULT), 322 + SG2042_GENERAL_PIN(PIN_PCIE3_L1_RESET, 0x03c, 323 + PIN_FLAG_WRITE_HIGH), 324 + SG2042_GENERAL_PIN(PIN_PCIE3_L0_WAKEUP, 0x040, 325 + PIN_FLAG_DEFAULT), 326 + SG2042_GENERAL_PIN(PIN_PCIE3_L1_WAKEUP, 0x040, 327 + PIN_FLAG_WRITE_HIGH), 328 + SG2042_GENERAL_PIN(PIN_PCIE3_L0_CLKREQ_IN, 0x044, 329 + PIN_FLAG_DEFAULT), 330 + SG2042_GENERAL_PIN(PIN_PCIE3_L1_CLKREQ_IN, 0x044, 331 + PIN_FLAG_WRITE_HIGH), 332 + SG2042_GENERAL_PIN(PIN_PCIE4_L0_RESET, 0x048, 333 + PIN_FLAG_DEFAULT), 334 + SG2042_GENERAL_PIN(PIN_PCIE4_L1_RESET, 0x048, 335 + PIN_FLAG_WRITE_HIGH), 336 + SG2042_GENERAL_PIN(PIN_PCIE4_L0_WAKEUP, 0x04c, 337 + PIN_FLAG_DEFAULT), 338 + SG2042_GENERAL_PIN(PIN_PCIE4_L1_WAKEUP, 0x04c, 339 + PIN_FLAG_WRITE_HIGH), 340 + SG2042_GENERAL_PIN(PIN_PCIE4_L0_CLKREQ_IN, 0x050, 341 + PIN_FLAG_DEFAULT), 342 + SG2042_GENERAL_PIN(PIN_PCIE4_L1_CLKREQ_IN, 0x050, 343 + PIN_FLAG_WRITE_HIGH), 344 + SG2042_GENERAL_PIN(PIN_SPIF0_CLK_SEL1, 0x054, 345 + PIN_FLAG_DEFAULT), 346 + SG2042_GENERAL_PIN(PIN_SPIF0_CLK_SEL0, 0x054, 347 + PIN_FLAG_WRITE_HIGH), 348 + SG2042_GENERAL_PIN(PIN_SPIF0_WP, 0x058, 349 + PIN_FLAG_DEFAULT), 350 + SG2042_GENERAL_PIN(PIN_SPIF0_HOLD, 0x058, 351 + PIN_FLAG_WRITE_HIGH), 352 + SG2042_GENERAL_PIN(PIN_SPIF0_SDI, 0x05c, 353 + PIN_FLAG_DEFAULT), 354 + SG2042_GENERAL_PIN(PIN_SPIF0_CS, 0x05c, 355 + PIN_FLAG_WRITE_HIGH), 356 + SG2042_GENERAL_PIN(PIN_SPIF0_SCK, 0x060, 357 + PIN_FLAG_DEFAULT), 358 + SG2042_GENERAL_PIN(PIN_SPIF0_SDO, 0x060, 359 + PIN_FLAG_WRITE_HIGH), 360 + SG2042_GENERAL_PIN(PIN_SPIF1_CLK_SEL1, 0x064, 361 + PIN_FLAG_DEFAULT), 362 + SG2042_GENERAL_PIN(PIN_SPIF1_CLK_SEL0, 0x064, 363 + PIN_FLAG_WRITE_HIGH), 364 + SG2042_GENERAL_PIN(PIN_SPIF1_WP, 0x068, 365 + PIN_FLAG_DEFAULT), 366 + SG2042_GENERAL_PIN(PIN_SPIF1_HOLD, 0x068, 367 + PIN_FLAG_WRITE_HIGH), 368 + SG2042_GENERAL_PIN(PIN_SPIF1_SDI, 0x06c, 369 + PIN_FLAG_DEFAULT), 370 + SG2042_GENERAL_PIN(PIN_SPIF1_CS, 0x06c, 371 + PIN_FLAG_WRITE_HIGH), 372 + SG2042_GENERAL_PIN(PIN_SPIF1_SCK, 0x070, 373 + PIN_FLAG_DEFAULT), 374 + SG2042_GENERAL_PIN(PIN_SPIF1_SDO, 0x070, 375 + PIN_FLAG_WRITE_HIGH), 376 + SG2042_GENERAL_PIN(PIN_EMMC_WP, 0x074, 377 + PIN_FLAG_DEFAULT), 378 + SG2042_GENERAL_PIN(PIN_EMMC_CD, 0x074, 379 + PIN_FLAG_WRITE_HIGH), 380 + SG2042_GENERAL_PIN(PIN_EMMC_RST, 0x078, 381 + PIN_FLAG_DEFAULT), 382 + SG2042_GENERAL_PIN(PIN_EMMC_PWR_EN, 0x078, 383 + PIN_FLAG_WRITE_HIGH), 384 + SG2042_GENERAL_PIN(PIN_SDIO_CD, 0x07c, 385 + PIN_FLAG_DEFAULT), 386 + SG2042_GENERAL_PIN(PIN_SDIO_WP, 0x07c, 387 + PIN_FLAG_WRITE_HIGH), 388 + SG2042_GENERAL_PIN(PIN_SDIO_RST, 0x080, 389 + PIN_FLAG_DEFAULT), 390 + SG2042_GENERAL_PIN(PIN_SDIO_PWR_EN, 0x080, 391 + PIN_FLAG_WRITE_HIGH), 392 + SG2042_GENERAL_PIN(PIN_RGMII0_TXD0, 0x084, 393 + PIN_FLAG_DEFAULT), 394 + SG2042_GENERAL_PIN(PIN_RGMII0_TXD1, 0x084, 395 + PIN_FLAG_WRITE_HIGH), 396 + SG2042_GENERAL_PIN(PIN_RGMII0_TXD2, 0x088, 397 + PIN_FLAG_DEFAULT), 398 + SG2042_GENERAL_PIN(PIN_RGMII0_TXD3, 0x088, 399 + PIN_FLAG_WRITE_HIGH), 400 + SG2042_GENERAL_PIN(PIN_RGMII0_TXCTRL, 0x08c, 401 + PIN_FLAG_DEFAULT), 402 + SG2042_GENERAL_PIN(PIN_RGMII0_RXD0, 0x08c, 403 + PIN_FLAG_WRITE_HIGH), 404 + SG2042_GENERAL_PIN(PIN_RGMII0_RXD1, 0x090, 405 + PIN_FLAG_DEFAULT), 406 + SG2042_GENERAL_PIN(PIN_RGMII0_RXD2, 0x090, 407 + PIN_FLAG_WRITE_HIGH), 408 + SG2042_GENERAL_PIN(PIN_RGMII0_RXD3, 0x094, 409 + PIN_FLAG_DEFAULT), 410 + SG2042_GENERAL_PIN(PIN_RGMII0_RXCTRL, 0x094, 411 + PIN_FLAG_WRITE_HIGH), 412 + SG2042_GENERAL_PIN(PIN_RGMII0_TXC, 0x098, 413 + PIN_FLAG_DEFAULT), 414 + SG2042_GENERAL_PIN(PIN_RGMII0_RXC, 0x098, 415 + PIN_FLAG_WRITE_HIGH), 416 + SG2042_GENERAL_PIN(PIN_RGMII0_REFCLKO, 0x09c, 417 + PIN_FLAG_DEFAULT), 418 + SG2042_GENERAL_PIN(PIN_RGMII0_IRQ, 0x09c, 419 + PIN_FLAG_WRITE_HIGH), 420 + SG2042_GENERAL_PIN(PIN_RGMII0_MDC, 0x0a0, 421 + PIN_FLAG_DEFAULT), 422 + SG2042_GENERAL_PIN(PIN_RGMII0_MDIO, 0x0a0, 423 + PIN_FLAG_WRITE_HIGH), 424 + SG2042_GENERAL_PIN(PIN_PWM0, 0x0a4, 425 + PIN_FLAG_DEFAULT), 426 + SG2042_GENERAL_PIN(PIN_PWM1, 0x0a4, 427 + PIN_FLAG_WRITE_HIGH), 428 + SG2042_GENERAL_PIN(PIN_PWM2, 0x0a8, 429 + PIN_FLAG_DEFAULT), 430 + SG2042_GENERAL_PIN(PIN_PWM3, 0x0a8, 431 + PIN_FLAG_WRITE_HIGH), 432 + SG2042_GENERAL_PIN(PIN_FAN0, 0x0ac, 433 + PIN_FLAG_DEFAULT), 434 + SG2042_GENERAL_PIN(PIN_FAN1, 0x0ac, 435 + PIN_FLAG_WRITE_HIGH), 436 + SG2042_GENERAL_PIN(PIN_FAN2, 0x0b0, 437 + PIN_FLAG_DEFAULT), 438 + SG2042_GENERAL_PIN(PIN_FAN3, 0x0b0, 439 + PIN_FLAG_WRITE_HIGH), 440 + SG2042_GENERAL_PIN(PIN_IIC0_SDA, 0x0b4, 441 + PIN_FLAG_DEFAULT), 442 + SG2042_GENERAL_PIN(PIN_IIC0_SCL, 0x0b4, 443 + PIN_FLAG_WRITE_HIGH), 444 + SG2042_GENERAL_PIN(PIN_IIC1_SDA, 0x0b8, 445 + PIN_FLAG_DEFAULT), 446 + SG2042_GENERAL_PIN(PIN_IIC1_SCL, 0x0b8, 447 + PIN_FLAG_WRITE_HIGH), 448 + SG2042_GENERAL_PIN(PIN_IIC2_SDA, 0x0bc, 449 + PIN_FLAG_DEFAULT), 450 + SG2042_GENERAL_PIN(PIN_IIC2_SCL, 0x0bc, 451 + PIN_FLAG_WRITE_HIGH), 452 + SG2042_GENERAL_PIN(PIN_IIC3_SDA, 0x0c0, 453 + PIN_FLAG_DEFAULT), 454 + SG2042_GENERAL_PIN(PIN_IIC3_SCL, 0x0c0, 455 + PIN_FLAG_WRITE_HIGH), 456 + SG2042_GENERAL_PIN(PIN_UART0_TX, 0x0c4, 457 + PIN_FLAG_DEFAULT), 458 + SG2042_GENERAL_PIN(PIN_UART0_RX, 0x0c4, 459 + PIN_FLAG_WRITE_HIGH), 460 + SG2042_GENERAL_PIN(PIN_UART0_RTS, 0x0c8, 461 + PIN_FLAG_DEFAULT), 462 + SG2042_GENERAL_PIN(PIN_UART0_CTS, 0x0c8, 463 + PIN_FLAG_WRITE_HIGH), 464 + SG2042_GENERAL_PIN(PIN_UART1_TX, 0x0cc, 465 + PIN_FLAG_DEFAULT), 466 + SG2042_GENERAL_PIN(PIN_UART1_RX, 0x0cc, 467 + PIN_FLAG_WRITE_HIGH), 468 + SG2042_GENERAL_PIN(PIN_UART1_RTS, 0x0d0, 469 + PIN_FLAG_DEFAULT), 470 + SG2042_GENERAL_PIN(PIN_UART1_CTS, 0x0d0, 471 + PIN_FLAG_WRITE_HIGH), 472 + SG2042_GENERAL_PIN(PIN_UART2_TX, 0x0d4, 473 + PIN_FLAG_DEFAULT), 474 + SG2042_GENERAL_PIN(PIN_UART2_RX, 0x0d4, 475 + PIN_FLAG_WRITE_HIGH), 476 + SG2042_GENERAL_PIN(PIN_UART2_RTS, 0x0d8, 477 + PIN_FLAG_DEFAULT), 478 + SG2042_GENERAL_PIN(PIN_UART2_CTS, 0x0d8, 479 + PIN_FLAG_WRITE_HIGH), 480 + SG2042_GENERAL_PIN(PIN_UART3_TX, 0x0dc, 481 + PIN_FLAG_DEFAULT), 482 + SG2042_GENERAL_PIN(PIN_UART3_RX, 0x0dc, 483 + PIN_FLAG_WRITE_HIGH), 484 + SG2042_GENERAL_PIN(PIN_UART3_RTS, 0x0e0, 485 + PIN_FLAG_DEFAULT), 486 + SG2042_GENERAL_PIN(PIN_UART3_CTS, 0x0e0, 487 + PIN_FLAG_WRITE_HIGH), 488 + SG2042_GENERAL_PIN(PIN_SPI0_CS0, 0x0e4, 489 + PIN_FLAG_DEFAULT), 490 + SG2042_GENERAL_PIN(PIN_SPI0_CS1, 0x0e4, 491 + PIN_FLAG_WRITE_HIGH), 492 + SG2042_GENERAL_PIN(PIN_SPI0_SDI, 0x0e8, 493 + PIN_FLAG_DEFAULT), 494 + SG2042_GENERAL_PIN(PIN_SPI0_SDO, 0x0e8, 495 + PIN_FLAG_WRITE_HIGH), 496 + SG2042_GENERAL_PIN(PIN_SPI0_SCK, 0x0ec, 497 + PIN_FLAG_DEFAULT), 498 + SG2042_GENERAL_PIN(PIN_SPI1_CS0, 0x0ec, 499 + PIN_FLAG_WRITE_HIGH), 500 + SG2042_GENERAL_PIN(PIN_SPI1_CS1, 0x0f0, 501 + PIN_FLAG_DEFAULT), 502 + SG2042_GENERAL_PIN(PIN_SPI1_SDI, 0x0f0, 503 + PIN_FLAG_WRITE_HIGH), 504 + SG2042_GENERAL_PIN(PIN_SPI1_SDO, 0x0f4, 505 + PIN_FLAG_DEFAULT), 506 + SG2042_GENERAL_PIN(PIN_SPI1_SCK, 0x0f4, 507 + PIN_FLAG_WRITE_HIGH), 508 + SG2042_GENERAL_PIN(PIN_JTAG0_TDO, 0x0f8, 509 + PIN_FLAG_DEFAULT), 510 + SG2042_GENERAL_PIN(PIN_JTAG0_TCK, 0x0f8, 511 + PIN_FLAG_WRITE_HIGH), 512 + SG2042_GENERAL_PIN(PIN_JTAG0_TDI, 0x0fc, 513 + PIN_FLAG_DEFAULT), 514 + SG2042_GENERAL_PIN(PIN_JTAG0_TMS, 0x0fc, 515 + PIN_FLAG_WRITE_HIGH), 516 + SG2042_GENERAL_PIN(PIN_JTAG0_TRST, 0x100, 517 + PIN_FLAG_DEFAULT), 518 + SG2042_GENERAL_PIN(PIN_JTAG0_SRST, 0x100, 519 + PIN_FLAG_WRITE_HIGH), 520 + SG2042_GENERAL_PIN(PIN_JTAG1_TDO, 0x104, 521 + PIN_FLAG_DEFAULT), 522 + SG2042_GENERAL_PIN(PIN_JTAG1_TCK, 0x104, 523 + PIN_FLAG_WRITE_HIGH), 524 + SG2042_GENERAL_PIN(PIN_JTAG1_TDI, 0x108, 525 + PIN_FLAG_DEFAULT), 526 + SG2042_GENERAL_PIN(PIN_JTAG1_TMS, 0x108, 527 + PIN_FLAG_WRITE_HIGH), 528 + SG2042_GENERAL_PIN(PIN_JTAG1_TRST, 0x10c, 529 + PIN_FLAG_DEFAULT), 530 + SG2042_GENERAL_PIN(PIN_JTAG1_SRST, 0x10c, 531 + PIN_FLAG_WRITE_HIGH), 532 + SG2042_GENERAL_PIN(PIN_JTAG2_TDO, 0x110, 533 + PIN_FLAG_DEFAULT), 534 + SG2042_GENERAL_PIN(PIN_JTAG2_TCK, 0x110, 535 + PIN_FLAG_WRITE_HIGH), 536 + SG2042_GENERAL_PIN(PIN_JTAG2_TDI, 0x114, 537 + PIN_FLAG_DEFAULT), 538 + SG2042_GENERAL_PIN(PIN_JTAG2_TMS, 0x114, 539 + PIN_FLAG_WRITE_HIGH), 540 + SG2042_GENERAL_PIN(PIN_JTAG2_TRST, 0x118, 541 + PIN_FLAG_DEFAULT), 542 + SG2042_GENERAL_PIN(PIN_JTAG2_SRST, 0x118, 543 + PIN_FLAG_WRITE_HIGH), 544 + SG2042_GENERAL_PIN(PIN_JTAG3_TDO, 0x11c, 545 + PIN_FLAG_DEFAULT), 546 + SG2042_GENERAL_PIN(PIN_JTAG3_TCK, 0x11c, 547 + PIN_FLAG_WRITE_HIGH), 548 + SG2042_GENERAL_PIN(PIN_JTAG3_TDI, 0x120, 549 + PIN_FLAG_DEFAULT), 550 + SG2042_GENERAL_PIN(PIN_JTAG3_TMS, 0x120, 551 + PIN_FLAG_WRITE_HIGH), 552 + SG2042_GENERAL_PIN(PIN_JTAG3_TRST, 0x124, 553 + PIN_FLAG_DEFAULT), 554 + SG2042_GENERAL_PIN(PIN_JTAG3_SRST, 0x124, 555 + PIN_FLAG_WRITE_HIGH), 556 + SG2042_GENERAL_PIN(PIN_GPIO0, 0x128, 557 + PIN_FLAG_DEFAULT), 558 + SG2042_GENERAL_PIN(PIN_GPIO1, 0x128, 559 + PIN_FLAG_WRITE_HIGH), 560 + SG2042_GENERAL_PIN(PIN_GPIO2, 0x12c, 561 + PIN_FLAG_DEFAULT), 562 + SG2042_GENERAL_PIN(PIN_GPIO3, 0x12c, 563 + PIN_FLAG_WRITE_HIGH), 564 + SG2042_GENERAL_PIN(PIN_GPIO4, 0x130, 565 + PIN_FLAG_DEFAULT), 566 + SG2042_GENERAL_PIN(PIN_GPIO5, 0x130, 567 + PIN_FLAG_WRITE_HIGH), 568 + SG2042_GENERAL_PIN(PIN_GPIO6, 0x134, 569 + PIN_FLAG_DEFAULT), 570 + SG2042_GENERAL_PIN(PIN_GPIO7, 0x134, 571 + PIN_FLAG_WRITE_HIGH), 572 + SG2042_GENERAL_PIN(PIN_GPIO8, 0x138, 573 + PIN_FLAG_DEFAULT), 574 + SG2042_GENERAL_PIN(PIN_GPIO9, 0x138, 575 + PIN_FLAG_WRITE_HIGH), 576 + SG2042_GENERAL_PIN(PIN_GPIO10, 0x13c, 577 + PIN_FLAG_DEFAULT), 578 + SG2042_GENERAL_PIN(PIN_GPIO11, 0x13c, 579 + PIN_FLAG_WRITE_HIGH), 580 + SG2042_GENERAL_PIN(PIN_GPIO12, 0x140, 581 + PIN_FLAG_DEFAULT), 582 + SG2042_GENERAL_PIN(PIN_GPIO13, 0x140, 583 + PIN_FLAG_WRITE_HIGH), 584 + SG2042_GENERAL_PIN(PIN_GPIO14, 0x144, 585 + PIN_FLAG_DEFAULT), 586 + SG2042_GENERAL_PIN(PIN_GPIO15, 0x144, 587 + PIN_FLAG_WRITE_HIGH), 588 + SG2042_GENERAL_PIN(PIN_GPIO16, 0x148, 589 + PIN_FLAG_DEFAULT), 590 + SG2042_GENERAL_PIN(PIN_GPIO17, 0x148, 591 + PIN_FLAG_WRITE_HIGH), 592 + SG2042_GENERAL_PIN(PIN_GPIO18, 0x14c, 593 + PIN_FLAG_DEFAULT), 594 + SG2042_GENERAL_PIN(PIN_GPIO19, 0x14c, 595 + PIN_FLAG_WRITE_HIGH), 596 + SG2042_GENERAL_PIN(PIN_GPIO20, 0x150, 597 + PIN_FLAG_DEFAULT), 598 + SG2042_GENERAL_PIN(PIN_GPIO21, 0x150, 599 + PIN_FLAG_WRITE_HIGH), 600 + SG2042_GENERAL_PIN(PIN_GPIO22, 0x154, 601 + PIN_FLAG_DEFAULT), 602 + SG2042_GENERAL_PIN(PIN_GPIO23, 0x154, 603 + PIN_FLAG_WRITE_HIGH), 604 + SG2042_GENERAL_PIN(PIN_GPIO24, 0x158, 605 + PIN_FLAG_DEFAULT), 606 + SG2042_GENERAL_PIN(PIN_GPIO25, 0x158, 607 + PIN_FLAG_WRITE_HIGH), 608 + SG2042_GENERAL_PIN(PIN_GPIO26, 0x15c, 609 + PIN_FLAG_DEFAULT), 610 + SG2042_GENERAL_PIN(PIN_GPIO27, 0x15c, 611 + PIN_FLAG_WRITE_HIGH), 612 + SG2042_GENERAL_PIN(PIN_GPIO28, 0x160, 613 + PIN_FLAG_DEFAULT), 614 + SG2042_GENERAL_PIN(PIN_GPIO29, 0x160, 615 + PIN_FLAG_WRITE_HIGH), 616 + SG2042_GENERAL_PIN(PIN_GPIO30, 0x164, 617 + PIN_FLAG_DEFAULT), 618 + SG2042_GENERAL_PIN(PIN_GPIO31, 0x164, 619 + PIN_FLAG_WRITE_HIGH), 620 + SG2042_GENERAL_PIN(PIN_MODE_SEL0, 0x168, 621 + PIN_FLAG_NO_PINMUX | PIN_FLAG_NO_OEX_EN), 622 + SG2042_GENERAL_PIN(PIN_MODE_SEL1, 0x168, 623 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_NO_PINMUX | 624 + PIN_FLAG_NO_OEX_EN), 625 + SG2042_GENERAL_PIN(PIN_MODE_SEL2, 0x16c, 626 + PIN_FLAG_NO_PINMUX | PIN_FLAG_NO_OEX_EN), 627 + SG2042_GENERAL_PIN(PIN_BOOT_SEL0, 0x16c, 628 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_NO_PINMUX | 629 + PIN_FLAG_NO_OEX_EN), 630 + SG2042_GENERAL_PIN(PIN_BOOT_SEL1, 0x170, 631 + PIN_FLAG_NO_PINMUX | PIN_FLAG_NO_OEX_EN), 632 + SG2042_GENERAL_PIN(PIN_BOOT_SEL2, 0x170, 633 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_NO_PINMUX | 634 + PIN_FLAG_NO_OEX_EN), 635 + SG2042_GENERAL_PIN(PIN_BOOT_SEL3, 0x174, 636 + PIN_FLAG_NO_PINMUX | PIN_FLAG_NO_OEX_EN), 637 + SG2042_GENERAL_PIN(PIN_BOOT_SEL4, 0x174, 638 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_NO_PINMUX | 639 + PIN_FLAG_NO_OEX_EN), 640 + SG2042_GENERAL_PIN(PIN_BOOT_SEL5, 0x178, 641 + PIN_FLAG_NO_PINMUX | PIN_FLAG_NO_OEX_EN), 642 + SG2042_GENERAL_PIN(PIN_BOOT_SEL6, 0x178, 643 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_NO_PINMUX | 644 + PIN_FLAG_NO_OEX_EN), 645 + SG2042_GENERAL_PIN(PIN_BOOT_SEL7, 0x17c, 646 + PIN_FLAG_NO_PINMUX | PIN_FLAG_NO_OEX_EN), 647 + SG2042_GENERAL_PIN(PIN_MULTI_SCKT, 0x17c, 648 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_NO_PINMUX | 649 + PIN_FLAG_NO_OEX_EN), 650 + SG2042_GENERAL_PIN(PIN_SCKT_ID0, 0x180, 651 + PIN_FLAG_NO_PINMUX | PIN_FLAG_NO_OEX_EN), 652 + SG2042_GENERAL_PIN(PIN_SCKT_ID1, 0x180, 653 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_NO_PINMUX | 654 + PIN_FLAG_NO_OEX_EN), 655 + SG2042_GENERAL_PIN(PIN_PLL_CLK_IN_MAIN, 0x184, 656 + PIN_FLAG_NO_PINMUX | PIN_FLAG_NO_OEX_EN), 657 + SG2042_GENERAL_PIN(PIN_PLL_CLK_IN_DDR_0, 0x184, 658 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_NO_PINMUX | 659 + PIN_FLAG_NO_OEX_EN), 660 + SG2042_GENERAL_PIN(PIN_PLL_CLK_IN_DDR_1, 0x188, 661 + PIN_FLAG_NO_PINMUX | PIN_FLAG_NO_OEX_EN), 662 + SG2042_GENERAL_PIN(PIN_PLL_CLK_IN_DDR_2, 0x188, 663 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_NO_PINMUX | 664 + PIN_FLAG_NO_OEX_EN), 665 + SG2042_GENERAL_PIN(PIN_PLL_CLK_IN_DDR_3, 0x18c, 666 + PIN_FLAG_NO_PINMUX | PIN_FLAG_NO_OEX_EN), 667 + SG2042_GENERAL_PIN(PIN_XTAL_32K, 0x18c, 668 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_NO_PINMUX | 669 + PIN_FLAG_NO_OEX_EN), 670 + SG2042_GENERAL_PIN(PIN_SYS_RST, 0x190, 671 + PIN_FLAG_NO_PINMUX | PIN_FLAG_NO_OEX_EN), 672 + SG2042_GENERAL_PIN(PIN_PWR_BUTTON, 0x190, 673 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_NO_PINMUX | 674 + PIN_FLAG_NO_OEX_EN), 675 + SG2042_GENERAL_PIN(PIN_TEST_EN, 0x194, 676 + PIN_FLAG_NO_PINMUX | PIN_FLAG_NO_OEX_EN), 677 + SG2042_GENERAL_PIN(PIN_TEST_MODE_MBIST, 0x194, 678 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_NO_PINMUX | 679 + PIN_FLAG_NO_OEX_EN), 680 + SG2042_GENERAL_PIN(PIN_TEST_MODE_SCAN, 0x198, 681 + PIN_FLAG_NO_PINMUX | PIN_FLAG_NO_OEX_EN), 682 + SG2042_GENERAL_PIN(PIN_TEST_MODE_BSD, 0x198, 683 + PIN_FLAG_WRITE_HIGH | PIN_FLAG_NO_PINMUX | 684 + PIN_FLAG_NO_OEX_EN), 685 + SG2042_GENERAL_PIN(PIN_BISR_BYP, 0x19c, 686 + PIN_FLAG_NO_PINMUX | PIN_FLAG_NO_OEX_EN), 687 + }; 688 + 689 + static const struct sophgo_pinctrl_data sg2044_pindata = { 690 + .pins = sg2044_pins, 691 + .pindata = sg2044_pin_data, 692 + .vddio_ops = &sg2044_vddio_cfg_ops, 693 + .cfg_ops = &sg2042_cfg_ops, 694 + .pctl_ops = &sg2042_pctrl_ops, 695 + .pmx_ops = &sg2042_pmx_ops, 696 + .pconf_ops = &sg2042_pconf_ops, 697 + .npins = ARRAY_SIZE(sg2044_pins), 698 + .pinsize = sizeof(struct sg2042_pin), 699 + }; 700 + 701 + static const struct of_device_id sg2044_pinctrl_ids[] = { 702 + { .compatible = "sophgo,sg2044-pinctrl", .data = &sg2044_pindata }, 703 + { } 704 + }; 705 + MODULE_DEVICE_TABLE(of, sg2044_pinctrl_ids); 706 + 707 + static struct platform_driver sg2044_pinctrl_driver = { 708 + .probe = sophgo_pinctrl_probe, 709 + .driver = { 710 + .name = "sg2044-pinctrl", 711 + .suppress_bind_attrs = true, 712 + .of_match_table = sg2044_pinctrl_ids, 713 + }, 714 + }; 715 + module_platform_driver(sg2044_pinctrl_driver); 716 + 717 + MODULE_DESCRIPTION("Pinctrl driver for the SG2002 series SoC"); 718 + MODULE_LICENSE("GPL");
+451
drivers/pinctrl/sophgo/pinctrl-sophgo-common.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Sophgo SoCs pinctrl common ops. 4 + * 5 + * Copyright (C) 2024 Inochi Amaoto <inochiama@outlook.com> 6 + * 7 + */ 8 + 9 + #include <linux/bsearch.h> 10 + #include <linux/cleanup.h> 11 + #include <linux/export.h> 12 + #include <linux/io.h> 13 + #include <linux/of.h> 14 + #include <linux/module.h> 15 + #include <linux/platform_device.h> 16 + #include <linux/seq_file.h> 17 + #include <linux/spinlock.h> 18 + 19 + #include <linux/pinctrl/pinconf-generic.h> 20 + #include <linux/pinctrl/pinctrl.h> 21 + 22 + #include "../pinctrl-utils.h" 23 + #include "../pinconf.h" 24 + #include "../pinmux.h" 25 + 26 + #include "pinctrl-sophgo.h" 27 + 28 + static u16 sophgo_dt_get_pin(u32 value) 29 + { 30 + return value; 31 + } 32 + 33 + static int sophgo_cmp_pin(const void *key, const void *pivot) 34 + { 35 + const struct sophgo_pin *pin = pivot; 36 + int pin_id = (long)key; 37 + int pivid = pin->id; 38 + 39 + return pin_id - pivid; 40 + } 41 + 42 + const struct sophgo_pin *sophgo_get_pin(struct sophgo_pinctrl *pctrl, 43 + unsigned long pin_id) 44 + { 45 + return bsearch((void *)pin_id, pctrl->data->pindata, pctrl->data->npins, 46 + pctrl->data->pinsize, sophgo_cmp_pin); 47 + } 48 + 49 + static int sophgo_verify_pinmux_config(struct sophgo_pinctrl *pctrl, 50 + const struct sophgo_pin_mux_config *config) 51 + { 52 + if (pctrl->data->cfg_ops->verify_pinmux_config) 53 + return pctrl->data->cfg_ops->verify_pinmux_config(config); 54 + return 0; 55 + } 56 + 57 + static int sophgo_verify_pin_group(struct sophgo_pinctrl *pctrl, 58 + const struct sophgo_pin_mux_config *config, 59 + unsigned int npins) 60 + { 61 + if (pctrl->data->cfg_ops->verify_pin_group) 62 + return pctrl->data->cfg_ops->verify_pin_group(config, npins); 63 + return 0; 64 + } 65 + 66 + static int sophgo_dt_node_to_map_post(struct device_node *cur, 67 + struct sophgo_pinctrl *pctrl, 68 + struct sophgo_pin_mux_config *config, 69 + unsigned int npins) 70 + { 71 + if (pctrl->data->cfg_ops->dt_node_to_map_post) 72 + return pctrl->data->cfg_ops->dt_node_to_map_post(cur, pctrl, 73 + config, npins); 74 + return 0; 75 + } 76 + 77 + int sophgo_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev, struct device_node *np, 78 + struct pinctrl_map **maps, unsigned int *num_maps) 79 + { 80 + struct sophgo_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); 81 + struct device *dev = pctrl->dev; 82 + struct device_node *child; 83 + struct pinctrl_map *map; 84 + const char **grpnames; 85 + const char *grpname; 86 + int ngroups = 0; 87 + int nmaps = 0; 88 + int ret; 89 + 90 + for_each_available_child_of_node(np, child) 91 + ngroups += 1; 92 + 93 + grpnames = devm_kcalloc(dev, ngroups, sizeof(*grpnames), GFP_KERNEL); 94 + if (!grpnames) 95 + return -ENOMEM; 96 + 97 + map = kcalloc(ngroups * 2, sizeof(*map), GFP_KERNEL); 98 + if (!map) 99 + return -ENOMEM; 100 + 101 + ngroups = 0; 102 + guard(mutex)(&pctrl->mutex); 103 + for_each_available_child_of_node(np, child) { 104 + int npins = of_property_count_u32_elems(child, "pinmux"); 105 + unsigned int *pins; 106 + struct sophgo_pin_mux_config *pinmuxs; 107 + u32 config; 108 + int i; 109 + 110 + if (npins < 1) { 111 + dev_err(dev, "invalid pinctrl group %pOFn.%pOFn\n", 112 + np, child); 113 + ret = -EINVAL; 114 + goto dt_failed; 115 + } 116 + 117 + grpname = devm_kasprintf(dev, GFP_KERNEL, "%pOFn.%pOFn", 118 + np, child); 119 + if (!grpname) { 120 + ret = -ENOMEM; 121 + goto dt_failed; 122 + } 123 + 124 + grpnames[ngroups++] = grpname; 125 + 126 + pins = devm_kcalloc(dev, npins, sizeof(*pins), GFP_KERNEL); 127 + if (!pins) { 128 + ret = -ENOMEM; 129 + goto dt_failed; 130 + } 131 + 132 + pinmuxs = devm_kcalloc(dev, npins, sizeof(*pinmuxs), GFP_KERNEL); 133 + if (!pinmuxs) { 134 + ret = -ENOMEM; 135 + goto dt_failed; 136 + } 137 + 138 + for (i = 0; i < npins; i++) { 139 + ret = of_property_read_u32_index(child, "pinmux", 140 + i, &config); 141 + if (ret) 142 + goto dt_failed; 143 + 144 + pins[i] = sophgo_dt_get_pin(config); 145 + pinmuxs[i].config = config; 146 + pinmuxs[i].pin = sophgo_get_pin(pctrl, pins[i]); 147 + 148 + if (!pinmuxs[i].pin) { 149 + dev_err(dev, "failed to get pin %d\n", pins[i]); 150 + ret = -ENODEV; 151 + goto dt_failed; 152 + } 153 + 154 + ret = sophgo_verify_pinmux_config(pctrl, &pinmuxs[i]); 155 + if (ret) { 156 + dev_err(dev, "group %s pin %d is invalid\n", 157 + grpname, i); 158 + goto dt_failed; 159 + } 160 + } 161 + 162 + ret = sophgo_verify_pin_group(pctrl, pinmuxs, npins); 163 + if (ret) { 164 + dev_err(dev, "group %s is invalid\n", grpname); 165 + goto dt_failed; 166 + } 167 + 168 + ret = sophgo_dt_node_to_map_post(child, pctrl, pinmuxs, npins); 169 + if (ret) 170 + goto dt_failed; 171 + 172 + map[nmaps].type = PIN_MAP_TYPE_MUX_GROUP; 173 + map[nmaps].data.mux.function = np->name; 174 + map[nmaps].data.mux.group = grpname; 175 + nmaps += 1; 176 + 177 + ret = pinconf_generic_parse_dt_config(child, pctldev, 178 + &map[nmaps].data.configs.configs, 179 + &map[nmaps].data.configs.num_configs); 180 + if (ret) { 181 + dev_err(dev, "failed to parse pin config of group %s: %d\n", 182 + grpname, ret); 183 + goto dt_failed; 184 + } 185 + 186 + ret = pinctrl_generic_add_group(pctldev, grpname, 187 + pins, npins, pinmuxs); 188 + if (ret < 0) { 189 + dev_err(dev, "failed to add group %s: %d\n", grpname, ret); 190 + goto dt_failed; 191 + } 192 + 193 + /* don't create a map if there are no pinconf settings */ 194 + if (map[nmaps].data.configs.num_configs == 0) 195 + continue; 196 + 197 + map[nmaps].type = PIN_MAP_TYPE_CONFIGS_GROUP; 198 + map[nmaps].data.configs.group_or_pin = grpname; 199 + nmaps += 1; 200 + } 201 + 202 + ret = pinmux_generic_add_function(pctldev, np->name, 203 + grpnames, ngroups, NULL); 204 + if (ret < 0) { 205 + dev_err(dev, "error adding function %s: %d\n", np->name, ret); 206 + goto function_failed; 207 + } 208 + 209 + *maps = map; 210 + *num_maps = nmaps; 211 + 212 + return 0; 213 + 214 + dt_failed: 215 + of_node_put(child); 216 + function_failed: 217 + pinctrl_utils_free_map(pctldev, map, nmaps); 218 + return ret; 219 + } 220 + 221 + int sophgo_pmx_set_mux(struct pinctrl_dev *pctldev, 222 + unsigned int fsel, unsigned int gsel) 223 + { 224 + struct sophgo_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); 225 + const struct group_desc *group; 226 + const struct sophgo_pin_mux_config *configs; 227 + unsigned int i; 228 + 229 + group = pinctrl_generic_get_group(pctldev, gsel); 230 + if (!group) 231 + return -EINVAL; 232 + 233 + configs = group->data; 234 + 235 + for (i = 0; i < group->grp.npins; i++) { 236 + const struct sophgo_pin *pin = configs[i].pin; 237 + u32 value = configs[i].config; 238 + 239 + guard(raw_spinlock_irqsave)(&pctrl->lock); 240 + 241 + pctrl->data->cfg_ops->set_pinmux_config(pctrl, pin, value); 242 + } 243 + 244 + return 0; 245 + } 246 + 247 + static int sophgo_pin_set_config(struct sophgo_pinctrl *pctrl, 248 + unsigned int pin_id, 249 + u32 value, u32 mask) 250 + { 251 + const struct sophgo_pin *pin = sophgo_get_pin(pctrl, pin_id); 252 + 253 + if (!pin) 254 + return -EINVAL; 255 + 256 + guard(raw_spinlock_irqsave)(&pctrl->lock); 257 + 258 + return pctrl->data->cfg_ops->set_pinconf_config(pctrl, pin, value, mask); 259 + } 260 + 261 + int sophgo_pconf_set(struct pinctrl_dev *pctldev, unsigned int pin_id, 262 + unsigned long *configs, unsigned int num_configs) 263 + { 264 + struct sophgo_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); 265 + const struct sophgo_pin *pin = sophgo_get_pin(pctrl, pin_id); 266 + u32 value, mask; 267 + 268 + if (!pin) 269 + return -ENODEV; 270 + 271 + if (pctrl->data->cfg_ops->compute_pinconf_config(pctrl, pin, 272 + configs, num_configs, 273 + &value, &mask)) 274 + return -ENOTSUPP; 275 + 276 + return sophgo_pin_set_config(pctrl, pin_id, value, mask); 277 + } 278 + 279 + int sophgo_pconf_group_set(struct pinctrl_dev *pctldev, unsigned int gsel, 280 + unsigned long *configs, unsigned int num_configs) 281 + { 282 + struct sophgo_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); 283 + const struct group_desc *group; 284 + const struct sophgo_pin_mux_config *pinmuxs; 285 + u32 value, mask; 286 + int i; 287 + 288 + group = pinctrl_generic_get_group(pctldev, gsel); 289 + if (!group) 290 + return -EINVAL; 291 + 292 + pinmuxs = group->data; 293 + 294 + if (pctrl->data->cfg_ops->compute_pinconf_config(pctrl, pinmuxs[0].pin, 295 + configs, num_configs, 296 + &value, &mask)) 297 + return -ENOTSUPP; 298 + 299 + for (i = 0; i < group->grp.npins; i++) 300 + sophgo_pin_set_config(pctrl, group->grp.pins[i], value, mask); 301 + 302 + return 0; 303 + } 304 + 305 + u32 sophgo_pinctrl_typical_pull_down(struct sophgo_pinctrl *pctrl, 306 + const struct sophgo_pin *pin, 307 + const u32 *power_cfg) 308 + { 309 + return pctrl->data->vddio_ops->get_pull_down(pin, power_cfg); 310 + } 311 + 312 + u32 sophgo_pinctrl_typical_pull_up(struct sophgo_pinctrl *pctrl, 313 + const struct sophgo_pin *pin, 314 + const u32 *power_cfg) 315 + { 316 + return pctrl->data->vddio_ops->get_pull_up(pin, power_cfg); 317 + } 318 + 319 + int sophgo_pinctrl_oc2reg(struct sophgo_pinctrl *pctrl, 320 + const struct sophgo_pin *pin, 321 + const u32 *power_cfg, u32 target) 322 + { 323 + const u32 *map; 324 + int i, len; 325 + 326 + if (!pctrl->data->vddio_ops->get_oc_map) 327 + return -ENOTSUPP; 328 + 329 + len = pctrl->data->vddio_ops->get_oc_map(pin, power_cfg, &map); 330 + if (len < 0) 331 + return len; 332 + 333 + for (i = 0; i < len; i++) { 334 + if (map[i] >= target) 335 + return i; 336 + } 337 + 338 + return -EINVAL; 339 + } 340 + 341 + int sophgo_pinctrl_reg2oc(struct sophgo_pinctrl *pctrl, 342 + const struct sophgo_pin *pin, 343 + const u32 *power_cfg, u32 reg) 344 + { 345 + const u32 *map; 346 + int len; 347 + 348 + if (!pctrl->data->vddio_ops->get_oc_map) 349 + return -ENOTSUPP; 350 + 351 + len = pctrl->data->vddio_ops->get_oc_map(pin, power_cfg, &map); 352 + if (len < 0) 353 + return len; 354 + 355 + if (reg >= len) 356 + return -EINVAL; 357 + 358 + return map[reg]; 359 + } 360 + 361 + int sophgo_pinctrl_schmitt2reg(struct sophgo_pinctrl *pctrl, 362 + const struct sophgo_pin *pin, 363 + const u32 *power_cfg, u32 target) 364 + { 365 + const u32 *map; 366 + int i, len; 367 + 368 + if (!pctrl->data->vddio_ops->get_schmitt_map) 369 + return -ENOTSUPP; 370 + 371 + len = pctrl->data->vddio_ops->get_schmitt_map(pin, power_cfg, &map); 372 + if (len < 0) 373 + return len; 374 + 375 + for (i = 0; i < len; i++) { 376 + if (map[i] == target) 377 + return i; 378 + } 379 + 380 + return -EINVAL; 381 + } 382 + 383 + int sophgo_pinctrl_reg2schmitt(struct sophgo_pinctrl *pctrl, 384 + const struct sophgo_pin *pin, 385 + const u32 *power_cfg, u32 reg) 386 + { 387 + const u32 *map; 388 + int len; 389 + 390 + if (!pctrl->data->vddio_ops->get_schmitt_map) 391 + return -ENOTSUPP; 392 + 393 + len = pctrl->data->vddio_ops->get_schmitt_map(pin, power_cfg, &map); 394 + if (len < 0) 395 + return len; 396 + 397 + if (reg >= len) 398 + return -EINVAL; 399 + 400 + return map[reg]; 401 + } 402 + 403 + int sophgo_pinctrl_probe(struct platform_device *pdev) 404 + { 405 + struct device *dev = &pdev->dev; 406 + struct sophgo_pinctrl *pctrl; 407 + const struct sophgo_pinctrl_data *pctrl_data; 408 + int ret; 409 + 410 + pctrl_data = device_get_match_data(dev); 411 + if (!pctrl_data) 412 + return -ENODEV; 413 + 414 + if (pctrl_data->npins == 0) 415 + return dev_err_probe(dev, -EINVAL, "invalid pin data\n"); 416 + 417 + pctrl = devm_kzalloc(dev, sizeof(*pctrl), GFP_KERNEL); 418 + if (!pctrl) 419 + return -ENOMEM; 420 + 421 + pctrl->pdesc.name = dev_name(dev); 422 + pctrl->pdesc.pins = pctrl_data->pins; 423 + pctrl->pdesc.npins = pctrl_data->npins; 424 + pctrl->pdesc.pctlops = pctrl_data->pctl_ops; 425 + pctrl->pdesc.pmxops = pctrl_data->pmx_ops; 426 + pctrl->pdesc.confops = pctrl_data->pconf_ops; 427 + pctrl->pdesc.owner = THIS_MODULE; 428 + 429 + pctrl->data = pctrl_data; 430 + pctrl->dev = dev; 431 + raw_spin_lock_init(&pctrl->lock); 432 + mutex_init(&pctrl->mutex); 433 + 434 + ret = pctrl->data->cfg_ops->pctrl_init(pdev, pctrl); 435 + if (ret) 436 + return ret; 437 + 438 + platform_set_drvdata(pdev, pctrl); 439 + 440 + ret = devm_pinctrl_register_and_init(dev, &pctrl->pdesc, 441 + pctrl, &pctrl->pctrl_dev); 442 + if (ret) 443 + return dev_err_probe(dev, ret, 444 + "fail to register pinctrl driver\n"); 445 + 446 + return pinctrl_enable(pctrl->pctrl_dev); 447 + } 448 + EXPORT_SYMBOL_GPL(sophgo_pinctrl_probe); 449 + 450 + MODULE_DESCRIPTION("Common pinctrl helper function for the Sophgo SoC"); 451 + MODULE_LICENSE("GPL");
+136
drivers/pinctrl/sophgo/pinctrl-sophgo.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + /* 3 + * Copyright (C) 2024 Inochi Amaoto <inochiama@outlook.com> 4 + */ 5 + 6 + #ifndef _PINCTRL_SOPHGO_H 7 + #define _PINCTRL_SOPHGO_H 8 + 9 + #include <linux/device.h> 10 + #include <linux/mutex.h> 11 + #include <linux/pinctrl/pinctrl.h> 12 + #include <linux/platform_device.h> 13 + #include <linux/spinlock.h> 14 + 15 + #include "../core.h" 16 + 17 + struct sophgo_pinctrl; 18 + 19 + struct sophgo_pin { 20 + u16 id; 21 + u16 flags; 22 + }; 23 + 24 + struct sophgo_pin_mux_config { 25 + const struct sophgo_pin *pin; 26 + u32 config; 27 + }; 28 + 29 + /** 30 + * struct sophgo_cfg_ops - pin configuration operations 31 + * 32 + * @pctrl_init: soc specific init callback 33 + * @verify_pinmux_config: verify the pinmux config for a pin 34 + * @verify_pin_group: verify the whole pinmux group 35 + * @dt_node_to_map_post: post init for the pinmux config map 36 + * @compute_pinconf_config: compute pinconf config 37 + * @set_pinconf_config: set pinconf config (the caller holds lock) 38 + * @set_pinmux_config: set mux config (the caller holds lock) 39 + */ 40 + struct sophgo_cfg_ops { 41 + int (*pctrl_init)(struct platform_device *pdev, 42 + struct sophgo_pinctrl *pctrl); 43 + int (*verify_pinmux_config)(const struct sophgo_pin_mux_config *config); 44 + int (*verify_pin_group)(const struct sophgo_pin_mux_config *pinmuxs, 45 + unsigned int npins); 46 + int (*dt_node_to_map_post)(struct device_node *cur, 47 + struct sophgo_pinctrl *pctrl, 48 + struct sophgo_pin_mux_config *pinmuxs, 49 + unsigned int npins); 50 + int (*compute_pinconf_config)(struct sophgo_pinctrl *pctrl, 51 + const struct sophgo_pin *sp, 52 + unsigned long *configs, 53 + unsigned int num_configs, 54 + u32 *value, u32 *mask); 55 + int (*set_pinconf_config)(struct sophgo_pinctrl *pctrl, 56 + const struct sophgo_pin *sp, 57 + u32 value, u32 mask); 58 + void (*set_pinmux_config)(struct sophgo_pinctrl *pctrl, 59 + const struct sophgo_pin *sp, u32 config); 60 + }; 61 + 62 + /** 63 + * struct sophgo_vddio_cfg_ops - pin vddio operations 64 + * 65 + * @get_pull_up: get resistor for pull up; 66 + * @get_pull_down: get resistor for pull down. 67 + * @get_oc_map: get mapping for typical low level output current value to 68 + * register value map. 69 + * @get_schmitt_map: get mapping for register value to typical schmitt 70 + * threshold. 71 + */ 72 + struct sophgo_vddio_cfg_ops { 73 + int (*get_pull_up)(const struct sophgo_pin *pin, const u32 *psmap); 74 + int (*get_pull_down)(const struct sophgo_pin *pin, const u32 *psmap); 75 + int (*get_oc_map)(const struct sophgo_pin *pin, const u32 *psmap, 76 + const u32 **map); 77 + int (*get_schmitt_map)(const struct sophgo_pin *pin, const u32 *psmap, 78 + const u32 **map); 79 + }; 80 + 81 + struct sophgo_pinctrl_data { 82 + const struct pinctrl_pin_desc *pins; 83 + const void *pindata; 84 + const char * const *pdnames; 85 + const struct sophgo_vddio_cfg_ops *vddio_ops; 86 + const struct sophgo_cfg_ops *cfg_ops; 87 + const struct pinctrl_ops *pctl_ops; 88 + const struct pinmux_ops *pmx_ops; 89 + const struct pinconf_ops *pconf_ops; 90 + u16 npins; 91 + u16 npds; 92 + u16 pinsize; 93 + }; 94 + 95 + struct sophgo_pinctrl { 96 + struct device *dev; 97 + struct pinctrl_dev *pctrl_dev; 98 + const struct sophgo_pinctrl_data *data; 99 + struct pinctrl_desc pdesc; 100 + 101 + struct mutex mutex; 102 + raw_spinlock_t lock; 103 + void *priv_ctrl; 104 + }; 105 + 106 + const struct sophgo_pin *sophgo_get_pin(struct sophgo_pinctrl *pctrl, 107 + unsigned long pin_id); 108 + int sophgo_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev, struct device_node *np, 109 + struct pinctrl_map **maps, unsigned int *num_maps); 110 + int sophgo_pmx_set_mux(struct pinctrl_dev *pctldev, 111 + unsigned int fsel, unsigned int gsel); 112 + int sophgo_pconf_set(struct pinctrl_dev *pctldev, unsigned int pin_id, 113 + unsigned long *configs, unsigned int num_configs); 114 + int sophgo_pconf_group_set(struct pinctrl_dev *pctldev, unsigned int gsel, 115 + unsigned long *configs, unsigned int num_configs); 116 + u32 sophgo_pinctrl_typical_pull_down(struct sophgo_pinctrl *pctrl, 117 + const struct sophgo_pin *pin, 118 + const u32 *power_cfg); 119 + u32 sophgo_pinctrl_typical_pull_up(struct sophgo_pinctrl *pctrl, 120 + const struct sophgo_pin *pin, 121 + const u32 *power_cfg); 122 + int sophgo_pinctrl_oc2reg(struct sophgo_pinctrl *pctrl, 123 + const struct sophgo_pin *pin, 124 + const u32 *power_cfg, u32 target); 125 + int sophgo_pinctrl_reg2oc(struct sophgo_pinctrl *pctrl, 126 + const struct sophgo_pin *pin, 127 + const u32 *power_cfg, u32 reg); 128 + int sophgo_pinctrl_schmitt2reg(struct sophgo_pinctrl *pctrl, 129 + const struct sophgo_pin *pin, 130 + const u32 *power_cfg, u32 target); 131 + int sophgo_pinctrl_reg2schmitt(struct sophgo_pinctrl *pctrl, 132 + const struct sophgo_pin *pin, 133 + const u32 *power_cfg, u32 reg); 134 + int sophgo_pinctrl_probe(struct platform_device *pdev); 135 + 136 + #endif /* _PINCTRL_SOPHGO_H */
+5 -1
drivers/pinctrl/spacemit/pinctrl-k1.c
··· 9 9 #include <linux/seq_file.h> 10 10 #include <linux/spinlock.h> 11 11 #include <linux/module.h> 12 + #include <linux/mutex.h> 12 13 13 14 #include <linux/pinctrl/pinconf-generic.h> 14 15 #include <linux/pinctrl/pinconf.h> ··· 750 749 pctrl->data = pctrl_data; 751 750 pctrl->dev = dev; 752 751 raw_spin_lock_init(&pctrl->lock); 753 - mutex_init(&pctrl->mutex); 752 + 753 + ret = devm_mutex_init(dev, &pctrl->mutex); 754 + if (ret) 755 + return ret; 754 756 755 757 platform_set_drvdata(pdev, pctrl); 756 758
+10
drivers/pinctrl/sunxi/Kconfig
··· 131 131 default ARM64 && ARCH_SUNXI 132 132 select PINCTRL_SUNXI 133 133 134 + config PINCTRL_SUN55I_A523 135 + bool "Support for the Allwinner A523 PIO" 136 + default ARM64 && ARCH_SUNXI 137 + select PINCTRL_SUNXI 138 + 139 + config PINCTRL_SUN55I_A523_R 140 + bool "Support for the Allwinner A523 R-PIO" 141 + default ARM64 && ARCH_SUNXI 142 + select PINCTRL_SUNXI 143 + 134 144 endif
+3
drivers/pinctrl/sunxi/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 # Core 3 3 obj-y += pinctrl-sunxi.o 4 + obj-y += pinctrl-sunxi-dt.o 4 5 5 6 # SoC Drivers 6 7 obj-$(CONFIG_PINCTRL_SUNIV_F1C100S) += pinctrl-suniv-f1c100s.o ··· 27 26 obj-$(CONFIG_PINCTRL_SUN50I_H6_R) += pinctrl-sun50i-h6-r.o 28 27 obj-$(CONFIG_PINCTRL_SUN50I_H616) += pinctrl-sun50i-h616.o 29 28 obj-$(CONFIG_PINCTRL_SUN50I_H616_R) += pinctrl-sun50i-h616-r.o 29 + obj-$(CONFIG_PINCTRL_SUN55I_A523) += pinctrl-sun55i-a523.o 30 + obj-$(CONFIG_PINCTRL_SUN55I_A523_R) += pinctrl-sun55i-a523-r.o 30 31 obj-$(CONFIG_PINCTRL_SUN9I_A80) += pinctrl-sun9i-a80.o 31 32 obj-$(CONFIG_PINCTRL_SUN9I_A80_R) += pinctrl-sun9i-a80-r.o
+2 -4
drivers/pinctrl/sunxi/pinctrl-sun20i-d1.c
··· 820 820 821 821 static int d1_pinctrl_probe(struct platform_device *pdev) 822 822 { 823 - unsigned long variant = (unsigned long)of_device_get_match_data(&pdev->dev); 824 - 825 - return sunxi_pinctrl_init_with_variant(pdev, &d1_pinctrl_data, variant); 823 + return sunxi_pinctrl_init_with_flags(pdev, &d1_pinctrl_data, 824 + SUNXI_PINCTRL_NEW_REG_LAYOUT); 826 825 } 827 826 828 827 static const struct of_device_id d1_pinctrl_match[] = { 829 828 { 830 829 .compatible = "allwinner,sun20i-d1-pinctrl", 831 - .data = (void *)PINCTRL_SUN20I_D1 832 830 }, 833 831 {} 834 832 };
+6 -2
drivers/pinctrl/sunxi/pinctrl-sun4i-a10.c
··· 17 17 18 18 #include "pinctrl-sunxi.h" 19 19 20 + #define PINCTRL_SUN4I_A10 BIT(0) 21 + #define PINCTRL_SUN7I_A20 BIT(1) 22 + #define PINCTRL_SUN8I_R40 BIT(2) 23 + 20 24 static const struct sunxi_desc_pin sun4i_a10_pins[] = { 21 25 SUNXI_PIN(SUNXI_PINCTRL_PIN(A, 0), 22 26 SUNXI_FUNCTION(0x0, "gpio_in"), ··· 1299 1295 { 1300 1296 unsigned long variant = (unsigned long)of_device_get_match_data(&pdev->dev); 1301 1297 1302 - return sunxi_pinctrl_init_with_variant(pdev, &sun4i_a10_pinctrl_data, 1303 - variant); 1298 + return sunxi_pinctrl_init_with_flags(pdev, &sun4i_a10_pinctrl_data, 1299 + variant); 1304 1300 } 1305 1301 1306 1302 static const struct of_device_id sun4i_a10_pinctrl_match[] = {
+54
drivers/pinctrl/sunxi/pinctrl-sun55i-a523-r.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Allwinner A523 SoC r-pinctrl driver. 4 + * 5 + * Copyright (C) 2024 Arm Ltd. 6 + */ 7 + 8 + #include <linux/module.h> 9 + #include <linux/platform_device.h> 10 + #include <linux/of.h> 11 + #include <linux/of_device.h> 12 + #include <linux/pinctrl/pinctrl.h> 13 + 14 + #include "pinctrl-sunxi.h" 15 + 16 + static const u8 a523_r_nr_bank_pins[SUNXI_PINCTRL_MAX_BANKS] = 17 + /* PL PM */ 18 + { 14, 6 }; 19 + 20 + static const unsigned int a523_r_irq_bank_map[] = { 0, 1 }; 21 + 22 + static const u8 a523_r_irq_bank_muxes[SUNXI_PINCTRL_MAX_BANKS] = 23 + /* PL PM */ 24 + { 14, 14 }; 25 + 26 + static struct sunxi_pinctrl_desc a523_r_pinctrl_data = { 27 + .irq_banks = ARRAY_SIZE(a523_r_irq_bank_map), 28 + .irq_bank_map = a523_r_irq_bank_map, 29 + .irq_read_needs_mux = true, 30 + .io_bias_cfg_variant = BIAS_VOLTAGE_PIO_POW_MODE_SEL, 31 + .pin_base = PL_BASE, 32 + }; 33 + 34 + static int a523_r_pinctrl_probe(struct platform_device *pdev) 35 + { 36 + return sunxi_pinctrl_dt_table_init(pdev, a523_r_nr_bank_pins, 37 + a523_r_irq_bank_muxes, 38 + &a523_r_pinctrl_data, 39 + SUNXI_PINCTRL_NEW_REG_LAYOUT); 40 + } 41 + 42 + static const struct of_device_id a523_r_pinctrl_match[] = { 43 + { .compatible = "allwinner,sun55i-a523-r-pinctrl", }, 44 + {} 45 + }; 46 + 47 + static struct platform_driver a523_r_pinctrl_driver = { 48 + .probe = a523_r_pinctrl_probe, 49 + .driver = { 50 + .name = "sun55i-a523-r-pinctrl", 51 + .of_match_table = a523_r_pinctrl_match, 52 + }, 53 + }; 54 + builtin_platform_driver(a523_r_pinctrl_driver);
+54
drivers/pinctrl/sunxi/pinctrl-sun55i-a523.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Allwinner A523 SoC pinctrl driver. 4 + * 5 + * Copyright (C) 2023 Arm Ltd. 6 + */ 7 + 8 + #include <linux/module.h> 9 + #include <linux/platform_device.h> 10 + #include <linux/of.h> 11 + #include <linux/of_device.h> 12 + #include <linux/pinctrl/pinctrl.h> 13 + 14 + #include "pinctrl-sunxi.h" 15 + 16 + static const u8 a523_nr_bank_pins[SUNXI_PINCTRL_MAX_BANKS] = 17 + /* PA PB PC PD PE PF PG PH PI PJ PK */ 18 + { 0, 15, 17, 24, 16, 7, 15, 20, 17, 28, 24 }; 19 + 20 + static const unsigned int a523_irq_bank_map[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; 21 + 22 + static const u8 a523_irq_bank_muxes[SUNXI_PINCTRL_MAX_BANKS] = 23 + /* PA PB PC PD PE PF PG PH PI PJ PK */ 24 + { 0, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14}; 25 + 26 + static struct sunxi_pinctrl_desc a523_pinctrl_data = { 27 + .irq_banks = ARRAY_SIZE(a523_irq_bank_map), 28 + .irq_bank_map = a523_irq_bank_map, 29 + .irq_read_needs_mux = true, 30 + .io_bias_cfg_variant = BIAS_VOLTAGE_PIO_POW_MODE_SEL, 31 + }; 32 + 33 + static int a523_pinctrl_probe(struct platform_device *pdev) 34 + { 35 + return sunxi_pinctrl_dt_table_init(pdev, a523_nr_bank_pins, 36 + a523_irq_bank_muxes, 37 + &a523_pinctrl_data, 38 + SUNXI_PINCTRL_NEW_REG_LAYOUT | 39 + SUNXI_PINCTRL_ELEVEN_BANKS); 40 + } 41 + 42 + static const struct of_device_id a523_pinctrl_match[] = { 43 + { .compatible = "allwinner,sun55i-a523-pinctrl", }, 44 + {} 45 + }; 46 + 47 + static struct platform_driver a523_pinctrl_driver = { 48 + .probe = a523_pinctrl_probe, 49 + .driver = { 50 + .name = "sun55i-a523-pinctrl", 51 + .of_match_table = a523_pinctrl_match, 52 + }, 53 + }; 54 + builtin_platform_driver(a523_pinctrl_driver);
+6 -2
drivers/pinctrl/sunxi/pinctrl-sun5i.c
··· 16 16 17 17 #include "pinctrl-sunxi.h" 18 18 19 + #define PINCTRL_SUN5I_A10S BIT(0) 20 + #define PINCTRL_SUN5I_A13 BIT(1) 21 + #define PINCTRL_SUN5I_GR8 BIT(2) 22 + 19 23 static const struct sunxi_desc_pin sun5i_pins[] = { 20 24 SUNXI_PIN_VARIANT(SUNXI_PINCTRL_PIN(A, 0), 21 25 PINCTRL_SUN5I_A10S, ··· 723 719 { 724 720 unsigned long variant = (unsigned long)of_device_get_match_data(&pdev->dev); 725 721 726 - return sunxi_pinctrl_init_with_variant(pdev, &sun5i_pinctrl_data, 727 - variant); 722 + return sunxi_pinctrl_init_with_flags(pdev, &sun5i_pinctrl_data, 723 + variant); 728 724 } 729 725 730 726 static const struct of_device_id sun5i_pinctrl_match[] = {
+5 -3
drivers/pinctrl/sunxi/pinctrl-sun6i-a31.c
··· 17 17 18 18 #include "pinctrl-sunxi.h" 19 19 20 + #define PINCTRL_SUN6I_A31 BIT(0) 21 + #define PINCTRL_SUN6I_A31S BIT(1) 22 + 20 23 static const struct sunxi_desc_pin sun6i_a31_pins[] = { 21 24 SUNXI_PIN(SUNXI_PINCTRL_PIN(A, 0), 22 25 SUNXI_FUNCTION(0x0, "gpio_in"), ··· 975 972 unsigned long variant = 976 973 (unsigned long)of_device_get_match_data(&pdev->dev); 977 974 978 - return sunxi_pinctrl_init_with_variant(pdev, 979 - &sun6i_a31_pinctrl_data, 980 - variant); 975 + return sunxi_pinctrl_init_with_flags(pdev, &sun6i_a31_pinctrl_data, 976 + variant); 981 977 } 982 978 983 979 static const struct of_device_id sun6i_a31_pinctrl_match[] = {
+5 -2
drivers/pinctrl/sunxi/pinctrl-sun8i-v3s.c
··· 22 22 23 23 #include "pinctrl-sunxi.h" 24 24 25 + #define PINCTRL_SUN8I_V3 BIT(0) 26 + #define PINCTRL_SUN8I_V3S BIT(1) 27 + 25 28 static const struct sunxi_desc_pin sun8i_v3s_pins[] = { 26 29 /* Hole */ 27 30 SUNXI_PIN(SUNXI_PINCTRL_PIN(B, 0), ··· 555 552 { 556 553 unsigned long variant = (unsigned long)of_device_get_match_data(&pdev->dev); 557 554 558 - return sunxi_pinctrl_init_with_variant(pdev, &sun8i_v3s_pinctrl_data, 559 - variant); 555 + return sunxi_pinctrl_init_with_flags(pdev, &sun8i_v3s_pinctrl_data, 556 + variant); 560 557 } 561 558 562 559 static const struct of_device_id sun8i_v3s_pinctrl_match[] = {
+374
drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Copyright (C) 2017-2025 Arm Ltd. 4 + * 5 + * Generic DT driven Allwinner pinctrl driver routines. 6 + * Builds the pin tables from minimal driver information and pin groups 7 + * described in the DT. Then hands those tables of to the traditional 8 + * sunxi pinctrl driver. 9 + * sunxi_pinctrl_init() expects a table like shown below, previously spelled 10 + * out in a per-SoC .c file. This code generates this table, like so: 11 + * 12 + * SUNXI_PIN(SUNXI_PINCTRL_PIN(F, 1), // code iterates over every implemented 13 + * // pin, based on pins_per_bank[] array passed in 14 + * 15 + * SUNXI_FUNCTION(0x0, "gpio_in"), // always added, for every pin 16 + * SUNXI_FUNCTION(0x1, "gpio_out"), // always added, for every pin 17 + * 18 + * SUNXI_FUNCTION(0x2, "mmc0"), // based on pingroup found in DT: 19 + * // mmc0-pins { 20 + * // pins = "PF0", "PF1", ... 21 + * // function = "mmc0"; 22 + * // allwinner,pinmux = <2>; 23 + * 24 + * SUNXI_FUNCTION_IRQ_BANK(0x6, 4, 1)), // derived by irq_bank_muxes[] 25 + * // array passed in 26 + */ 27 + 28 + #include <linux/export.h> 29 + #include <linux/of.h> 30 + #include <linux/of_address.h> 31 + #include <linux/of_device.h> 32 + #include <linux/pinctrl/pinctrl.h> 33 + #include <linux/platform_device.h> 34 + #include <linux/slab.h> 35 + 36 + #include "pinctrl-sunxi.h" 37 + 38 + #define INVALID_MUX 0xff 39 + 40 + /* 41 + * Return the "index"th element from the "allwinner,pinmux" property. If the 42 + * property does not hold enough entries, return the last one instead. 43 + * For almost every group the pinmux value is actually the same, so this 44 + * allows to just list one value in the property. 45 + */ 46 + static u8 sunxi_pinctrl_dt_read_pinmux(const struct device_node *node, 47 + int index) 48 + { 49 + int ret, num_elems; 50 + u32 value; 51 + 52 + num_elems = of_property_count_u32_elems(node, "allwinner,pinmux"); 53 + if (num_elems <= 0) 54 + return INVALID_MUX; 55 + 56 + if (index >= num_elems) 57 + index = num_elems - 1; 58 + 59 + ret = of_property_read_u32_index(node, "allwinner,pinmux", index, 60 + &value); 61 + if (ret) 62 + return INVALID_MUX; 63 + 64 + return value; 65 + } 66 + 67 + /* 68 + * Allocate a table with a sunxi_desc_pin structure for every pin needed. 69 + * Fills in the respective pin names ("PA0") and their pin numbers. 70 + * Returns the pins array. We cannot use the member in *desc yet, as this 71 + * is marked as const, and we will need to change the array still. 72 + */ 73 + static struct sunxi_desc_pin *init_pins_table(struct device *dev, 74 + const u8 *pins_per_bank, 75 + struct sunxi_pinctrl_desc *desc) 76 + { 77 + struct sunxi_desc_pin *pins, *cur_pin; 78 + int name_size = 0; 79 + int port_base = desc->pin_base / PINS_PER_BANK; 80 + char *pin_names, *cur_name; 81 + int i, j; 82 + 83 + /* 84 + * Find the total number of pins. 85 + * Also work out how much memory we need to store all the pin names. 86 + */ 87 + for (i = 0; i < SUNXI_PINCTRL_MAX_BANKS; i++) { 88 + desc->npins += pins_per_bank[i]; 89 + if (pins_per_bank[i] < 10) { 90 + /* 4 bytes for "PXy\0" */ 91 + name_size += pins_per_bank[i] * 4; 92 + } else { 93 + /* 4 bytes for each "PXy\0" */ 94 + name_size += 10 * 4; 95 + 96 + /* 5 bytes for each "PXyy\0" */ 97 + name_size += (pins_per_bank[i] - 10) * 5; 98 + } 99 + } 100 + 101 + if (desc->npins == 0) { 102 + dev_err(dev, "no ports defined\n"); 103 + return ERR_PTR(-EINVAL); 104 + } 105 + 106 + pins = devm_kzalloc(dev, desc->npins * sizeof(*pins), GFP_KERNEL); 107 + if (!pins) 108 + return ERR_PTR(-ENOMEM); 109 + 110 + /* Allocate memory to store the name for every pin. */ 111 + pin_names = devm_kmalloc(dev, name_size, GFP_KERNEL); 112 + if (!pin_names) 113 + return ERR_PTR(-ENOMEM); 114 + 115 + /* Fill the pins array with the name and the number for each pin. */ 116 + cur_name = pin_names; 117 + cur_pin = pins; 118 + for (i = 0; i < SUNXI_PINCTRL_MAX_BANKS; i++) { 119 + for (j = 0; j < pins_per_bank[i]; j++, cur_pin++) { 120 + int nchars = sprintf(cur_name, "P%c%d", 121 + port_base + 'A' + i, j); 122 + 123 + cur_pin->pin.number = (port_base + i) * PINS_PER_BANK + j; 124 + cur_pin->pin.name = cur_name; 125 + cur_name += nchars + 1; 126 + } 127 + } 128 + 129 + return pins; 130 + } 131 + 132 + /* 133 + * Work out the number of functions for each pin. This will visit every 134 + * child node of the pinctrl DT node to find all advertised functions. 135 + * Provide memory to hold the per-function information and assign it to 136 + * the pin table. 137 + * Fill in the GPIO in/out functions already (that every pin has), also add 138 + * an "irq" function at the end, for those pins in IRQ-capable ports. 139 + * We do not fill in the extra functions (those describe in DT nodes) yet. 140 + * We (ab)use the "variant" member in each pin to keep track of the number of 141 + * extra functions needed. At the end this will get reset to 2, so that we 142 + * can add extra function later, after the two GPIO functions. 143 + */ 144 + static int prepare_function_table(struct device *dev, struct device_node *pnode, 145 + struct sunxi_desc_pin *pins, int npins, 146 + const u8 *irq_bank_muxes) 147 + { 148 + struct device_node *node; 149 + struct property *prop; 150 + struct sunxi_desc_function *func; 151 + int num_funcs, irq_bank, last_bank, i; 152 + 153 + /* 154 + * We need at least three functions per pin: 155 + * - one for GPIO in 156 + * - one for GPIO out 157 + * - one for the sentinel signalling the end of the list 158 + */ 159 + num_funcs = 3 * npins; 160 + 161 + /* 162 + * Add a function for each pin in a bank supporting interrupts. 163 + * We temporarily (ab)use the variant field to store the number of 164 + * functions per pin. This will be cleaned back to 0 before we hand 165 + * over the whole structure to the generic sunxi pinctrl setup code. 166 + */ 167 + for (i = 0; i < npins; i++) { 168 + struct sunxi_desc_pin *pin = &pins[i]; 169 + int bank = pin->pin.number / PINS_PER_BANK; 170 + 171 + if (irq_bank_muxes[bank]) { 172 + pin->variant++; 173 + num_funcs++; 174 + } 175 + } 176 + 177 + /* 178 + * Go over each pin group (every child of the pinctrl DT node) and 179 + * add the number of special functions each pins has. Also update the 180 + * total number of functions required. 181 + * We might slightly overshoot here in case of double definitions. 182 + */ 183 + for_each_child_of_node(pnode, node) { 184 + const char *name; 185 + 186 + of_property_for_each_string(node, "pins", prop, name) { 187 + for (i = 0; i < npins; i++) { 188 + if (strcmp(pins[i].pin.name, name)) 189 + continue; 190 + 191 + pins[i].variant++; 192 + num_funcs++; 193 + break; 194 + } 195 + } 196 + } 197 + 198 + /* 199 + * Allocate the memory needed for the functions in one table. 200 + * We later use pointers into this table to mark each pin. 201 + */ 202 + func = devm_kzalloc(dev, num_funcs * sizeof(*func), GFP_KERNEL); 203 + if (!func) 204 + return -ENOMEM; 205 + 206 + /* 207 + * Assign the function's memory and fill in GPIOs, IRQ and a sentinel. 208 + * The extra functions will be filled in later. 209 + */ 210 + irq_bank = 0; 211 + last_bank = 0; 212 + for (i = 0; i < npins; i++) { 213 + struct sunxi_desc_pin *pin = &pins[i]; 214 + int bank = pin->pin.number / PINS_PER_BANK; 215 + int lastfunc = pin->variant + 1; 216 + int irq_mux = irq_bank_muxes[bank]; 217 + 218 + func[0].name = "gpio_in"; 219 + func[0].muxval = 0; 220 + func[1].name = "gpio_out"; 221 + func[1].muxval = 1; 222 + 223 + if (irq_mux) { 224 + if (bank > last_bank) 225 + irq_bank++; 226 + func[lastfunc].muxval = irq_mux; 227 + func[lastfunc].irqbank = irq_bank; 228 + func[lastfunc].irqnum = pin->pin.number % PINS_PER_BANK; 229 + func[lastfunc].name = "irq"; 230 + } 231 + 232 + if (bank > last_bank) 233 + last_bank = bank; 234 + 235 + pin->functions = func; 236 + 237 + /* Skip over the other needed functions and the sentinel. */ 238 + func += pin->variant + 3; 239 + 240 + /* 241 + * Reset the value for filling in the remaining functions 242 + * behind the GPIOs later. 243 + */ 244 + pin->variant = 2; 245 + } 246 + 247 + return 0; 248 + } 249 + 250 + /* 251 + * Iterate over all pins in a single group and add the function name and its 252 + * mux value to the respective pin. 253 + * The "variant" member is again used to temporarily track the number of 254 + * already added functions. 255 + */ 256 + static void fill_pin_function(struct device *dev, struct device_node *node, 257 + struct sunxi_desc_pin *pins, int npins) 258 + { 259 + const char *name, *funcname; 260 + struct sunxi_desc_function *func; 261 + struct property *prop; 262 + int pin, i, index; 263 + u8 muxval; 264 + 265 + if (of_property_read_string(node, "function", &funcname)) { 266 + dev_warn(dev, "missing \"function\" property\n"); 267 + return; 268 + } 269 + 270 + index = 0; 271 + of_property_for_each_string(node, "pins", prop, name) { 272 + /* Find the index of this pin in our table. */ 273 + for (pin = 0; pin < npins; pin++) 274 + if (!strcmp(pins[pin].pin.name, name)) 275 + break; 276 + if (pin == npins) { 277 + dev_warn(dev, "%s: cannot find pin %s\n", 278 + of_node_full_name(node), name); 279 + index++; 280 + continue; 281 + } 282 + 283 + /* Read the associated mux value. */ 284 + muxval = sunxi_pinctrl_dt_read_pinmux(node, index); 285 + if (muxval == INVALID_MUX) { 286 + dev_warn(dev, "%s: invalid mux value for pin %s\n", 287 + of_node_full_name(node), name); 288 + index++; 289 + continue; 290 + } 291 + 292 + /* 293 + * Check for double definitions by comparing the to-be-added 294 + * function with already assigned ones. 295 + * Ignore identical pairs (function name and mux value the 296 + * same), but warn about conflicting assignments. 297 + */ 298 + for (i = 2; i < pins[pin].variant; i++) { 299 + func = &pins[pin].functions[i]; 300 + 301 + /* Skip over totally unrelated functions. */ 302 + if (strcmp(func->name, funcname) && 303 + func->muxval != muxval) 304 + continue; 305 + 306 + /* Ignore (but skip below) any identical functions. */ 307 + if (!strcmp(func->name, funcname) && 308 + muxval == func->muxval) 309 + break; 310 + 311 + dev_warn(dev, 312 + "pin %s: function %s redefined to mux %d\n", 313 + name, funcname, muxval); 314 + break; 315 + } 316 + 317 + /* Skip any pins with that function already assigned. */ 318 + if (i < pins[pin].variant) { 319 + index++; 320 + continue; 321 + } 322 + 323 + /* Assign function and muxval to the next free slot. */ 324 + func = &pins[pin].functions[pins[pin].variant]; 325 + func->muxval = muxval; 326 + func->name = funcname; 327 + 328 + pins[pin].variant++; 329 + index++; 330 + } 331 + } 332 + 333 + /* 334 + * Initialise the pinctrl table, by building it from driver provided 335 + * information: the number of pins per bank, the IRQ capable banks and their 336 + * IRQ mux value. 337 + * Then iterate over all pinctrl DT node children to enter the function name 338 + * and mux values for each mentioned pin. 339 + * At the end hand over this structure to the actual sunxi pinctrl driver. 340 + */ 341 + int sunxi_pinctrl_dt_table_init(struct platform_device *pdev, 342 + const u8 *pins_per_bank, 343 + const u8 *irq_bank_muxes, 344 + struct sunxi_pinctrl_desc *desc, 345 + unsigned long flags) 346 + { 347 + struct device_node *pnode = pdev->dev.of_node, *node; 348 + struct sunxi_desc_pin *pins; 349 + int ret, i; 350 + 351 + pins = init_pins_table(&pdev->dev, pins_per_bank, desc); 352 + if (IS_ERR(pins)) 353 + return PTR_ERR(pins); 354 + 355 + ret = prepare_function_table(&pdev->dev, pnode, pins, desc->npins, 356 + irq_bank_muxes); 357 + if (ret) 358 + return ret; 359 + 360 + /* 361 + * Now iterate over all groups and add the respective function name 362 + * and mux values to each pin listed within. 363 + */ 364 + for_each_child_of_node(pnode, node) 365 + fill_pin_function(&pdev->dev, node, pins, desc->npins); 366 + 367 + /* Clear the temporary storage. */ 368 + for (i = 0; i < desc->npins; i++) 369 + pins[i].variant = 0; 370 + 371 + desc->pins = pins; 372 + 373 + return sunxi_pinctrl_init_with_flags(pdev, desc, flags); 374 + }
+37 -17
drivers/pinctrl/sunxi/pinctrl-sunxi.c
··· 58 58 * The following functions calculate the register and the bit offset to access. 59 59 * They take a pin number which is relative to the start of the current device. 60 60 */ 61 + 62 + /* 63 + * When using the extended register layout, Bank K does not fit into the 64 + * space used for the other banks. Instead it lives at offset 0x500. 65 + */ 66 + static u32 sunxi_bank_offset(const struct sunxi_pinctrl *pctl, u32 pin) 67 + { 68 + u32 offset = 0; 69 + 70 + if (pin >= PK_BASE) { 71 + pin -= PK_BASE; 72 + offset = PIO_BANK_K_OFFSET; 73 + } 74 + 75 + return offset + (pin / PINS_PER_BANK) * pctl->bank_mem_size; 76 + } 77 + 61 78 static void sunxi_mux_reg(const struct sunxi_pinctrl *pctl, 62 79 u32 pin, u32 *reg, u32 *shift, u32 *mask) 63 80 { 64 - u32 bank = pin / PINS_PER_BANK; 65 81 u32 offset = pin % PINS_PER_BANK * MUX_FIELD_WIDTH; 66 82 67 - *reg = bank * pctl->bank_mem_size + MUX_REGS_OFFSET + 83 + *reg = sunxi_bank_offset(pctl, pin) + MUX_REGS_OFFSET + 68 84 offset / BITS_PER_TYPE(u32) * sizeof(u32); 69 85 *shift = offset % BITS_PER_TYPE(u32); 70 86 *mask = (BIT(MUX_FIELD_WIDTH) - 1) << *shift; ··· 89 73 static void sunxi_data_reg(const struct sunxi_pinctrl *pctl, 90 74 u32 pin, u32 *reg, u32 *shift, u32 *mask) 91 75 { 92 - u32 bank = pin / PINS_PER_BANK; 93 76 u32 offset = pin % PINS_PER_BANK * DATA_FIELD_WIDTH; 94 77 95 - *reg = bank * pctl->bank_mem_size + DATA_REGS_OFFSET + 78 + *reg = sunxi_bank_offset(pctl, pin) + DATA_REGS_OFFSET + 96 79 offset / BITS_PER_TYPE(u32) * sizeof(u32); 97 80 *shift = offset % BITS_PER_TYPE(u32); 98 81 *mask = (BIT(DATA_FIELD_WIDTH) - 1) << *shift; ··· 100 85 static void sunxi_dlevel_reg(const struct sunxi_pinctrl *pctl, 101 86 u32 pin, u32 *reg, u32 *shift, u32 *mask) 102 87 { 103 - u32 bank = pin / PINS_PER_BANK; 104 88 u32 offset = pin % PINS_PER_BANK * pctl->dlevel_field_width; 105 89 106 - *reg = bank * pctl->bank_mem_size + DLEVEL_REGS_OFFSET + 90 + *reg = sunxi_bank_offset(pctl, pin) + DLEVEL_REGS_OFFSET + 107 91 offset / BITS_PER_TYPE(u32) * sizeof(u32); 108 92 *shift = offset % BITS_PER_TYPE(u32); 109 93 *mask = (BIT(pctl->dlevel_field_width) - 1) << *shift; ··· 111 97 static void sunxi_pull_reg(const struct sunxi_pinctrl *pctl, 112 98 u32 pin, u32 *reg, u32 *shift, u32 *mask) 113 99 { 114 - u32 bank = pin / PINS_PER_BANK; 115 100 u32 offset = pin % PINS_PER_BANK * PULL_FIELD_WIDTH; 116 101 117 - *reg = bank * pctl->bank_mem_size + pctl->pull_regs_offset + 102 + *reg = sunxi_bank_offset(pctl, pin) + pctl->pull_regs_offset + 118 103 offset / BITS_PER_TYPE(u32) * sizeof(u32); 119 104 *shift = offset % BITS_PER_TYPE(u32); 120 105 *mask = (BIT(PULL_FIELD_WIDTH) - 1) << *shift; ··· 736 723 val = uV > 1800000 && uV <= 2500000 ? BIT(bank) : 0; 737 724 738 725 raw_spin_lock_irqsave(&pctl->lock, flags); 739 - reg = readl(pctl->membase + PIO_POW_MOD_CTL_REG); 726 + reg = readl(pctl->membase + pctl->pow_mod_sel_offset + 727 + PIO_POW_MOD_CTL_OFS); 740 728 reg &= ~BIT(bank); 741 - writel(reg | val, pctl->membase + PIO_POW_MOD_CTL_REG); 729 + writel(reg | val, pctl->membase + pctl->pow_mod_sel_offset + 730 + PIO_POW_MOD_CTL_OFS); 742 731 raw_spin_unlock_irqrestore(&pctl->lock, flags); 743 732 744 733 fallthrough; ··· 748 733 val = uV <= 1800000 ? 1 : 0; 749 734 750 735 raw_spin_lock_irqsave(&pctl->lock, flags); 751 - reg = readl(pctl->membase + PIO_POW_MOD_SEL_REG); 736 + reg = readl(pctl->membase + pctl->pow_mod_sel_offset); 752 737 reg &= ~(1 << bank); 753 - writel(reg | val << bank, pctl->membase + PIO_POW_MOD_SEL_REG); 738 + writel(reg | val << bank, 739 + pctl->membase + pctl->pow_mod_sel_offset); 754 740 raw_spin_unlock_irqrestore(&pctl->lock, flags); 755 741 return 0; 756 742 default: ··· 1488 1472 return 0; 1489 1473 } 1490 1474 1491 - int sunxi_pinctrl_init_with_variant(struct platform_device *pdev, 1492 - const struct sunxi_pinctrl_desc *desc, 1493 - unsigned long variant) 1475 + int sunxi_pinctrl_init_with_flags(struct platform_device *pdev, 1476 + const struct sunxi_pinctrl_desc *desc, 1477 + unsigned long flags) 1494 1478 { 1495 1479 struct device_node *node = pdev->dev.of_node; 1496 1480 struct pinctrl_desc *pctrl_desc; ··· 1513 1497 1514 1498 pctl->dev = &pdev->dev; 1515 1499 pctl->desc = desc; 1516 - pctl->variant = variant; 1517 - if (pctl->variant >= PINCTRL_SUN20I_D1) { 1500 + pctl->variant = flags & SUNXI_PINCTRL_VARIANT_MASK; 1501 + if (flags & SUNXI_PINCTRL_NEW_REG_LAYOUT) { 1518 1502 pctl->bank_mem_size = D1_BANK_MEM_SIZE; 1519 1503 pctl->pull_regs_offset = D1_PULL_REGS_OFFSET; 1520 1504 pctl->dlevel_field_width = D1_DLEVEL_FIELD_WIDTH; ··· 1523 1507 pctl->pull_regs_offset = PULL_REGS_OFFSET; 1524 1508 pctl->dlevel_field_width = DLEVEL_FIELD_WIDTH; 1525 1509 } 1510 + if (flags & SUNXI_PINCTRL_ELEVEN_BANKS) 1511 + pctl->pow_mod_sel_offset = PIO_11B_POW_MOD_SEL_REG; 1512 + else 1513 + pctl->pow_mod_sel_offset = PIO_POW_MOD_SEL_REG; 1526 1514 1527 1515 pctl->irq_array = devm_kcalloc(&pdev->dev, 1528 1516 IRQ_PER_BANK * pctl->desc->irq_banks,
+26 -19
drivers/pinctrl/sunxi/pinctrl-sunxi.h
··· 25 25 #define PG_BASE 192 26 26 #define PH_BASE 224 27 27 #define PI_BASE 256 28 + #define PJ_BASE 288 29 + #define PK_BASE 320 28 30 #define PL_BASE 352 29 31 #define PM_BASE 384 30 32 #define PN_BASE 416 33 + 34 + /* maximum number of banks per controller (PA -> PK) */ 35 + #define SUNXI_PINCTRL_MAX_BANKS 11 31 36 32 37 #define SUNXI_PINCTRL_PIN(bank, pin) \ 33 38 PINCTRL_PIN(P ## bank ## _BASE + (pin), "P" #bank #pin) ··· 87 82 #define SUN4I_FUNC_INPUT 0 88 83 #define SUN4I_FUNC_IRQ 6 89 84 90 - #define PINCTRL_SUN5I_A10S BIT(1) 91 - #define PINCTRL_SUN5I_A13 BIT(2) 92 - #define PINCTRL_SUN5I_GR8 BIT(3) 93 - #define PINCTRL_SUN6I_A31 BIT(4) 94 - #define PINCTRL_SUN6I_A31S BIT(5) 95 - #define PINCTRL_SUN4I_A10 BIT(6) 96 - #define PINCTRL_SUN7I_A20 BIT(7) 97 - #define PINCTRL_SUN8I_R40 BIT(8) 98 - #define PINCTRL_SUN8I_V3 BIT(9) 99 - #define PINCTRL_SUN8I_V3S BIT(10) 100 - /* Variants below here have an updated register layout. */ 101 - #define PINCTRL_SUN20I_D1 BIT(11) 85 + #define SUNXI_PINCTRL_VARIANT_MASK GENMASK(7, 0) 86 + #define SUNXI_PINCTRL_NEW_REG_LAYOUT BIT(8) 87 + #define SUNXI_PINCTRL_PORTF_SWITCH BIT(9) 88 + #define SUNXI_PINCTRL_ELEVEN_BANKS BIT(10) 102 89 103 - #define PIO_POW_MOD_SEL_REG 0x340 104 - #define PIO_POW_MOD_CTL_REG 0x344 90 + #define PIO_POW_MOD_SEL_REG 0x340 91 + #define PIO_11B_POW_MOD_SEL_REG 0x380 92 + #define PIO_POW_MOD_CTL_OFS 0x004 93 + 94 + #define PIO_BANK_K_OFFSET 0x500 105 95 106 96 enum sunxi_desc_bias_voltage { 107 97 BIAS_VOLTAGE_NONE, ··· 164 164 struct gpio_chip *chip; 165 165 const struct sunxi_pinctrl_desc *desc; 166 166 struct device *dev; 167 - struct sunxi_pinctrl_regulator regulators[9]; 167 + struct sunxi_pinctrl_regulator regulators[11]; 168 168 struct irq_domain *domain; 169 169 struct sunxi_pinctrl_function *functions; 170 170 unsigned nfunctions; ··· 178 178 u32 bank_mem_size; 179 179 u32 pull_regs_offset; 180 180 u32 dlevel_field_width; 181 + u32 pow_mod_sel_offset; 181 182 }; 182 183 183 184 #define SUNXI_PIN(_pin, ...) \ ··· 300 299 return GRP_CFG_REG + bank * 0x4; 301 300 } 302 301 303 - int sunxi_pinctrl_init_with_variant(struct platform_device *pdev, 304 - const struct sunxi_pinctrl_desc *desc, 305 - unsigned long variant); 302 + int sunxi_pinctrl_init_with_flags(struct platform_device *pdev, 303 + const struct sunxi_pinctrl_desc *desc, 304 + unsigned long flags); 306 305 307 306 #define sunxi_pinctrl_init(_dev, _desc) \ 308 - sunxi_pinctrl_init_with_variant(_dev, _desc, 0) 307 + sunxi_pinctrl_init_with_flags(_dev, _desc, 0) 308 + 309 + int sunxi_pinctrl_dt_table_init(struct platform_device *pdev, 310 + const u8 *pins_per_bank, 311 + const u8 *irq_bank_muxes, 312 + struct sunxi_pinctrl_desc *desc, 313 + unsigned long flags); 309 314 310 315 #endif /* __PINCTRL_SUNXI_H */
+65 -8
drivers/pinctrl/tegra/pinctrl-tegra.c
··· 96 96 {"nvidia,slew-rate-falling", TEGRA_PINCONF_PARAM_SLEW_RATE_FALLING}, 97 97 {"nvidia,slew-rate-rising", TEGRA_PINCONF_PARAM_SLEW_RATE_RISING}, 98 98 {"nvidia,drive-type", TEGRA_PINCONF_PARAM_DRIVE_TYPE}, 99 + {"nvidia,gpio-mode", TEGRA_PINCONF_PARAM_GPIO_MODE}, 99 100 }; 100 101 101 102 static int tegra_pinctrl_dt_subnode_to_map(struct pinctrl_dev *pctldev, ··· 271 270 val = pmx_readl(pmx, g->mux_bank, g->mux_reg); 272 271 val &= ~(0x3 << g->mux_bit); 273 272 val |= i << g->mux_bit; 273 + /* Set the SFIO/GPIO selection to SFIO when under pinmux control*/ 274 + if (pmx->soc->sfsel_in_mux) 275 + val |= (1 << g->sfsel_bit); 274 276 pmx_writel(pmx, val, g->mux_bank, g->mux_reg); 275 277 276 278 return 0; 277 279 } 278 280 279 - static const struct tegra_pingroup *tegra_pinctrl_get_group(struct pinctrl_dev *pctldev, 280 - unsigned int offset) 281 + static int tegra_pinctrl_get_group_index(struct pinctrl_dev *pctldev, 282 + unsigned int offset) 281 283 { 282 284 struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); 283 285 unsigned int group, num_pins, j; ··· 293 289 continue; 294 290 for (j = 0; j < num_pins; j++) { 295 291 if (offset == pins[j]) 296 - return &pmx->soc->groups[group]; 292 + return group; 297 293 } 298 294 } 299 295 300 - dev_err(pctldev->dev, "Pingroup not found for pin %u\n", offset); 301 - return NULL; 296 + return -EINVAL; 297 + } 298 + 299 + static const struct tegra_pingroup *tegra_pinctrl_get_group(struct pinctrl_dev *pctldev, 300 + unsigned int offset, 301 + int group_index) 302 + { 303 + struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); 304 + 305 + if (group_index < 0 || group_index >= pmx->soc->ngroups) 306 + return NULL; 307 + 308 + return &pmx->soc->groups[group_index]; 309 + } 310 + 311 + static struct tegra_pingroup_config *tegra_pinctrl_get_group_config(struct pinctrl_dev *pctldev, 312 + unsigned int offset, 313 + int group_index) 314 + { 315 + struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); 316 + 317 + if (group_index < 0) 318 + return NULL; 319 + 320 + return &pmx->pingroup_configs[group_index]; 302 321 } 303 322 304 323 static int tegra_pinctrl_gpio_request_enable(struct pinctrl_dev *pctldev, ··· 330 303 { 331 304 struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); 332 305 const struct tegra_pingroup *group; 306 + struct tegra_pingroup_config *config; 307 + int group_index; 333 308 u32 value; 334 309 335 310 if (!pmx->soc->sfsel_in_mux) 336 311 return 0; 337 312 338 - group = tegra_pinctrl_get_group(pctldev, offset); 313 + group_index = tegra_pinctrl_get_group_index(pctldev, offset); 314 + group = tegra_pinctrl_get_group(pctldev, offset, group_index); 339 315 340 316 if (!group) 341 317 return -EINVAL; ··· 346 316 if (group->mux_reg < 0 || group->sfsel_bit < 0) 347 317 return -EINVAL; 348 318 319 + config = tegra_pinctrl_get_group_config(pctldev, offset, group_index); 320 + if (!config) 321 + return -EINVAL; 349 322 value = pmx_readl(pmx, group->mux_bank, group->mux_reg); 323 + config->is_sfsel = (value & BIT(group->sfsel_bit)) != 0; 350 324 value &= ~BIT(group->sfsel_bit); 351 325 pmx_writel(pmx, value, group->mux_bank, group->mux_reg); 352 326 ··· 363 329 { 364 330 struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); 365 331 const struct tegra_pingroup *group; 332 + struct tegra_pingroup_config *config; 333 + int group_index; 366 334 u32 value; 367 335 368 336 if (!pmx->soc->sfsel_in_mux) 369 337 return; 370 338 371 - group = tegra_pinctrl_get_group(pctldev, offset); 339 + group_index = tegra_pinctrl_get_group_index(pctldev, offset); 340 + group = tegra_pinctrl_get_group(pctldev, offset, group_index); 372 341 373 342 if (!group) 374 343 return; ··· 379 342 if (group->mux_reg < 0 || group->sfsel_bit < 0) 380 343 return; 381 344 345 + config = tegra_pinctrl_get_group_config(pctldev, offset, group_index); 346 + if (!config) 347 + return; 382 348 value = pmx_readl(pmx, group->mux_bank, group->mux_reg); 383 - value |= BIT(group->sfsel_bit); 349 + if (config->is_sfsel) 350 + value |= BIT(group->sfsel_bit); 384 351 pmx_writel(pmx, value, group->mux_bank, group->mux_reg); 385 352 } 386 353 ··· 508 467 } 509 468 *bit = g->drvtype_bit; 510 469 *width = 2; 470 + break; 471 + case TEGRA_PINCONF_PARAM_GPIO_MODE: 472 + if (pmx->soc->sfsel_in_mux) { 473 + *bank = g->mux_bank; 474 + *reg = g->mux_reg; 475 + *bit = g->sfsel_bit; 476 + *width = 1; 477 + } else { 478 + *reg = -EINVAL; 479 + } 511 480 break; 512 481 default: 513 482 dev_err(pmx->dev, "Invalid config param %04x\n", param); ··· 838 787 839 788 pmx->dev = &pdev->dev; 840 789 pmx->soc = soc_data; 790 + 791 + pmx->pingroup_configs = devm_kcalloc(&pdev->dev, 792 + pmx->soc->ngroups, sizeof(*pmx->pingroup_configs), 793 + GFP_KERNEL); 794 + if (!pmx->pingroup_configs) 795 + return -ENOMEM; 841 796 842 797 /* 843 798 * Each mux group will appear in 4 functions' list of groups.
+24 -10
drivers/pinctrl/tegra/pinctrl-tegra.h
··· 8 8 #ifndef __PINMUX_TEGRA_H__ 9 9 #define __PINMUX_TEGRA_H__ 10 10 11 + struct tegra_pingroup_config { 12 + bool is_sfsel; 13 + }; 14 + 11 15 struct tegra_pmx { 12 16 struct device *dev; 13 17 struct pinctrl_dev *pctl; ··· 25 21 int nbanks; 26 22 void __iomem **regs; 27 23 u32 *backup_regs; 24 + /* Array of size soc->ngroups */ 25 + struct tegra_pingroup_config *pingroup_configs; 28 26 }; 29 27 30 28 enum tegra_pinconf_param { ··· 60 54 TEGRA_PINCONF_PARAM_SLEW_RATE_RISING, 61 55 /* argument: Integer, range is HW-dependant */ 62 56 TEGRA_PINCONF_PARAM_DRIVE_TYPE, 57 + /* argument: Boolean */ 58 + TEGRA_PINCONF_PARAM_GPIO_MODE, 63 59 }; 64 60 65 61 enum tegra_pinconf_pull { ··· 184 176 185 177 /** 186 178 * struct tegra_pinctrl_soc_data - Tegra pin controller driver configuration 187 - * @ngpios: The number of GPIO pins the pin controller HW affects. 188 - * @pins: An array describing all pins the pin controller affects. 189 - * All pins which are also GPIOs must be listed first within the 190 - * array, and be numbered identically to the GPIO controller's 191 - * numbering. 192 - * @npins: The numbmer of entries in @pins. 193 - * @functions: An array describing all mux functions the SoC supports. 194 - * @nfunctions: The numbmer of entries in @functions. 195 - * @groups: An array describing all pin groups the pin SoC supports. 196 - * @ngroups: The numbmer of entries in @groups. 179 + * @ngpios: The number of GPIO pins the pin controller HW affects. 180 + * @gpio_compatible: Device-tree GPIO compatible string. 181 + * @pins: An array describing all pins the pin controller affects. 182 + * All pins which are also GPIOs must be listed first within the 183 + * array, and be numbered identically to the GPIO controller's 184 + * numbering. 185 + * @npins: The number of entries in @pins. 186 + * @functions: An array describing all mux functions the SoC supports. 187 + * @nfunctions: The number of entries in @functions. 188 + * @groups: An array describing all pin groups the pin SoC supports. 189 + * @ngroups: The number of entries in @groups. 190 + * @hsm_in_mux: High-speed mode field. Only applicable to devices with one pin per group. 191 + * @schmitt_in_mux: Schmitt trigger field. Only applicable to devices with one pin per group. 192 + * @drvtype_in_mux: Drivetype field. Only applicable to devices with one pin per group. 193 + * @sfsel_in_mux: Special function selection field. 194 + * Only applicable to devices with one pin per group. 197 195 */ 198 196 struct tegra_pinctrl_soc_data { 199 197 unsigned ngpios;
+2 -2
drivers/pwm/pwm-lpss.c
··· 10 10 * Author: Alan Cox <alan@linux.intel.com> 11 11 */ 12 12 13 + #define DEFAULT_SYMBOL_NAMESPACE "PWM_LPSS" 14 + 13 15 #include <linux/bits.h> 14 16 #include <linux/delay.h> 15 17 #include <linux/io.h> ··· 21 19 #include <linux/pm_runtime.h> 22 20 #include <linux/pwm.h> 23 21 #include <linux/time.h> 24 - 25 - #define DEFAULT_SYMBOL_NAMESPACE "PWM_LPSS" 26 22 27 23 #include "pwm-lpss.h" 28 24
+46
include/dt-bindings/pinctrl/amlogic,pinctrl.h
··· 1 + /* SPDX-License-Identifier: (GPL-2.0-only OR MIT) */ 2 + /* 3 + * Copyright (c) 2024 Amlogic, Inc. All rights reserved. 4 + * Author: Xianwei Zhao <xianwei.zhao@amlogic.com> 5 + */ 6 + 7 + #ifndef _DT_BINDINGS_AMLOGIC_PINCTRL_H 8 + #define _DT_BINDINGS_AMLOGIC_PINCTRL_H 9 + /* Normal PIN bank */ 10 + #define AMLOGIC_GPIO_A 0 11 + #define AMLOGIC_GPIO_B 1 12 + #define AMLOGIC_GPIO_C 2 13 + #define AMLOGIC_GPIO_D 3 14 + #define AMLOGIC_GPIO_E 4 15 + #define AMLOGIC_GPIO_F 5 16 + #define AMLOGIC_GPIO_G 6 17 + #define AMLOGIC_GPIO_H 7 18 + #define AMLOGIC_GPIO_I 8 19 + #define AMLOGIC_GPIO_J 9 20 + #define AMLOGIC_GPIO_K 10 21 + #define AMLOGIC_GPIO_L 11 22 + #define AMLOGIC_GPIO_M 12 23 + #define AMLOGIC_GPIO_N 13 24 + #define AMLOGIC_GPIO_O 14 25 + #define AMLOGIC_GPIO_P 15 26 + #define AMLOGIC_GPIO_Q 16 27 + #define AMLOGIC_GPIO_R 17 28 + #define AMLOGIC_GPIO_S 18 29 + #define AMLOGIC_GPIO_T 19 30 + #define AMLOGIC_GPIO_U 20 31 + #define AMLOGIC_GPIO_V 21 32 + #define AMLOGIC_GPIO_W 22 33 + #define AMLOGIC_GPIO_X 23 34 + #define AMLOGIC_GPIO_Y 24 35 + #define AMLOGIC_GPIO_Z 25 36 + 37 + /* Special PIN bank */ 38 + #define AMLOGIC_GPIO_DV 26 39 + #define AMLOGIC_GPIO_AO 27 40 + #define AMLOGIC_GPIO_CC 28 41 + #define AMLOGIC_GPIO_TEST_N 29 42 + #define AMLOGIC_GPIO_ANALOG 30 43 + 44 + #define AML_PINMUX(bank, offset, mode) (((((bank) << 8) + (offset)) << 8) | (mode)) 45 + 46 + #endif /* _DT_BINDINGS_AMLOGIC_PINCTRL_H */
+196
include/dt-bindings/pinctrl/pinctrl-sg2042.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause */ 2 + /* 3 + * Copyright (C) 2024 Inochi Amaoto <inochiama@outlook.com> 4 + * 5 + */ 6 + 7 + #ifndef _DT_BINDINGS_PINCTRL_SG2042_H 8 + #define _DT_BINDINGS_PINCTRL_SG2042_H 9 + 10 + #define PINMUX(pin, mux) \ 11 + (((pin) & 0xffff) | (((mux) & 0xff) << 16)) 12 + 13 + #define PIN_LPC_LCLK 0 14 + #define PIN_LPC_LFRAME 1 15 + #define PIN_LPC_LAD0 2 16 + #define PIN_LPC_LAD1 3 17 + #define PIN_LPC_LAD2 4 18 + #define PIN_LPC_LAD3 5 19 + #define PIN_LPC_LDRQ0 6 20 + #define PIN_LPC_LDRQ1 7 21 + #define PIN_LPC_SERIRQ 8 22 + #define PIN_LPC_CLKRUN 9 23 + #define PIN_LPC_LPME 10 24 + #define PIN_LPC_LPCPD 11 25 + #define PIN_LPC_LSMI 12 26 + #define PIN_PCIE0_L0_RESET 13 27 + #define PIN_PCIE0_L1_RESET 14 28 + #define PIN_PCIE0_L0_WAKEUP 15 29 + #define PIN_PCIE0_L1_WAKEUP 16 30 + #define PIN_PCIE0_L0_CLKREQ_IN 17 31 + #define PIN_PCIE0_L1_CLKREQ_IN 18 32 + #define PIN_PCIE1_L0_RESET 19 33 + #define PIN_PCIE1_L1_RESET 20 34 + #define PIN_PCIE1_L0_WAKEUP 21 35 + #define PIN_PCIE1_L1_WAKEUP 22 36 + #define PIN_PCIE1_L0_CLKREQ_IN 23 37 + #define PIN_PCIE1_L1_CLKREQ_IN 24 38 + #define PIN_SPIF0_CLK_SEL1 25 39 + #define PIN_SPIF0_CLK_SEL0 26 40 + #define PIN_SPIF0_WP 27 41 + #define PIN_SPIF0_HOLD 28 42 + #define PIN_SPIF0_SDI 29 43 + #define PIN_SPIF0_CS 30 44 + #define PIN_SPIF0_SCK 31 45 + #define PIN_SPIF0_SDO 32 46 + #define PIN_SPIF1_CLK_SEL1 33 47 + #define PIN_SPIF1_CLK_SEL0 34 48 + #define PIN_SPIF1_WP 35 49 + #define PIN_SPIF1_HOLD 36 50 + #define PIN_SPIF1_SDI 37 51 + #define PIN_SPIF1_CS 38 52 + #define PIN_SPIF1_SCK 39 53 + #define PIN_SPIF1_SDO 40 54 + #define PIN_EMMC_WP 41 55 + #define PIN_EMMC_CD 42 56 + #define PIN_EMMC_RST 43 57 + #define PIN_EMMC_PWR_EN 44 58 + #define PIN_SDIO_CD 45 59 + #define PIN_SDIO_WP 46 60 + #define PIN_SDIO_RST 47 61 + #define PIN_SDIO_PWR_EN 48 62 + #define PIN_RGMII0_TXD0 49 63 + #define PIN_RGMII0_TXD1 50 64 + #define PIN_RGMII0_TXD2 51 65 + #define PIN_RGMII0_TXD3 52 66 + #define PIN_RGMII0_TXCTRL 53 67 + #define PIN_RGMII0_RXD0 54 68 + #define PIN_RGMII0_RXD1 55 69 + #define PIN_RGMII0_RXD2 56 70 + #define PIN_RGMII0_RXD3 57 71 + #define PIN_RGMII0_RXCTRL 58 72 + #define PIN_RGMII0_TXC 59 73 + #define PIN_RGMII0_RXC 60 74 + #define PIN_RGMII0_REFCLKO 61 75 + #define PIN_RGMII0_IRQ 62 76 + #define PIN_RGMII0_MDC 63 77 + #define PIN_RGMII0_MDIO 64 78 + #define PIN_PWM0 65 79 + #define PIN_PWM1 66 80 + #define PIN_PWM2 67 81 + #define PIN_PWM3 68 82 + #define PIN_FAN0 69 83 + #define PIN_FAN1 70 84 + #define PIN_FAN2 71 85 + #define PIN_FAN3 72 86 + #define PIN_IIC0_SDA 73 87 + #define PIN_IIC0_SCL 74 88 + #define PIN_IIC1_SDA 75 89 + #define PIN_IIC1_SCL 76 90 + #define PIN_IIC2_SDA 77 91 + #define PIN_IIC2_SCL 78 92 + #define PIN_IIC3_SDA 79 93 + #define PIN_IIC3_SCL 80 94 + #define PIN_UART0_TX 81 95 + #define PIN_UART0_RX 82 96 + #define PIN_UART0_RTS 83 97 + #define PIN_UART0_CTS 84 98 + #define PIN_UART1_TX 85 99 + #define PIN_UART1_RX 86 100 + #define PIN_UART1_RTS 87 101 + #define PIN_UART1_CTS 88 102 + #define PIN_UART2_TX 89 103 + #define PIN_UART2_RX 90 104 + #define PIN_UART2_RTS 91 105 + #define PIN_UART2_CTS 92 106 + #define PIN_UART3_TX 93 107 + #define PIN_UART3_RX 94 108 + #define PIN_UART3_RTS 95 109 + #define PIN_UART3_CTS 96 110 + #define PIN_SPI0_CS0 97 111 + #define PIN_SPI0_CS1 98 112 + #define PIN_SPI0_SDI 99 113 + #define PIN_SPI0_SDO 100 114 + #define PIN_SPI0_SCK 101 115 + #define PIN_SPI1_CS0 102 116 + #define PIN_SPI1_CS1 103 117 + #define PIN_SPI1_SDI 104 118 + #define PIN_SPI1_SDO 105 119 + #define PIN_SPI1_SCK 106 120 + #define PIN_JTAG0_TDO 107 121 + #define PIN_JTAG0_TCK 108 122 + #define PIN_JTAG0_TDI 109 123 + #define PIN_JTAG0_TMS 110 124 + #define PIN_JTAG0_TRST 111 125 + #define PIN_JTAG0_SRST 112 126 + #define PIN_JTAG1_TDO 113 127 + #define PIN_JTAG1_TCK 114 128 + #define PIN_JTAG1_TDI 115 129 + #define PIN_JTAG1_TMS 116 130 + #define PIN_JTAG1_TRST 117 131 + #define PIN_JTAG1_SRST 118 132 + #define PIN_JTAG2_TDO 119 133 + #define PIN_JTAG2_TCK 120 134 + #define PIN_JTAG2_TDI 121 135 + #define PIN_JTAG2_TMS 122 136 + #define PIN_JTAG2_TRST 123 137 + #define PIN_JTAG2_SRST 124 138 + #define PIN_GPIO0 125 139 + #define PIN_GPIO1 126 140 + #define PIN_GPIO2 127 141 + #define PIN_GPIO3 128 142 + #define PIN_GPIO4 129 143 + #define PIN_GPIO5 130 144 + #define PIN_GPIO6 131 145 + #define PIN_GPIO7 132 146 + #define PIN_GPIO8 133 147 + #define PIN_GPIO9 134 148 + #define PIN_GPIO10 135 149 + #define PIN_GPIO11 136 150 + #define PIN_GPIO12 137 151 + #define PIN_GPIO13 138 152 + #define PIN_GPIO14 139 153 + #define PIN_GPIO15 140 154 + #define PIN_GPIO16 141 155 + #define PIN_GPIO17 142 156 + #define PIN_GPIO18 143 157 + #define PIN_GPIO19 144 158 + #define PIN_GPIO20 145 159 + #define PIN_GPIO21 146 160 + #define PIN_GPIO22 147 161 + #define PIN_GPIO23 148 162 + #define PIN_GPIO24 149 163 + #define PIN_GPIO25 150 164 + #define PIN_GPIO26 151 165 + #define PIN_GPIO27 152 166 + #define PIN_GPIO28 153 167 + #define PIN_GPIO29 154 168 + #define PIN_GPIO30 155 169 + #define PIN_GPIO31 156 170 + #define PIN_MODE_SEL0 157 171 + #define PIN_MODE_SEL1 158 172 + #define PIN_MODE_SEL2 159 173 + #define PIN_BOOT_SEL0 160 174 + #define PIN_BOOT_SEL1 161 175 + #define PIN_BOOT_SEL2 162 176 + #define PIN_BOOT_SEL3 163 177 + #define PIN_BOOT_SEL4 164 178 + #define PIN_BOOT_SEL5 165 179 + #define PIN_BOOT_SEL6 166 180 + #define PIN_BOOT_SEL7 167 181 + #define PIN_MULTI_SCKT 168 182 + #define PIN_SCKT_ID0 169 183 + #define PIN_SCKT_ID1 170 184 + #define PIN_PLL_CLK_IN_MAIN 171 185 + #define PIN_PLL_CLK_IN_DDR_L 172 186 + #define PIN_PLL_CLK_IN_DDR_R 173 187 + #define PIN_XTAL_32K 174 188 + #define PIN_SYS_RST 175 189 + #define PIN_PWR_BUTTON 176 190 + #define PIN_TEST_EN 177 191 + #define PIN_TEST_MODE_MBIST 178 192 + #define PIN_TEST_MODE_SCAN 179 193 + #define PIN_TEST_MODE_BSD 180 194 + #define PIN_BISR_BYP 181 195 + 196 + #endif /* _DT_BINDINGS_PINCTRL_SG2042_H */
+221
include/dt-bindings/pinctrl/pinctrl-sg2044.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause */ 2 + /* 3 + * Copyright (C) 2024 Inochi Amaoto <inochiama@outlook.com> 4 + * 5 + */ 6 + 7 + #ifndef _DT_BINDINGS_PINCTRL_SG2044_H 8 + #define _DT_BINDINGS_PINCTRL_SG2044_H 9 + 10 + #define PINMUX(pin, mux) \ 11 + (((pin) & 0xffff) | (((mux) & 0xff) << 16)) 12 + 13 + #define PIN_IIC0_SMBSUS_IN 0 14 + #define PIN_IIC0_SMBSUS_OUT 1 15 + #define PIN_IIC0_SMBALERT 2 16 + #define PIN_IIC1_SMBSUS_IN 3 17 + #define PIN_IIC1_SMBSUS_OUT 4 18 + #define PIN_IIC1_SMBALERT 5 19 + #define PIN_IIC2_SMBSUS_IN 6 20 + #define PIN_IIC2_SMBSUS_OUT 7 21 + #define PIN_IIC2_SMBALERT 8 22 + #define PIN_IIC3_SMBSUS_IN 9 23 + #define PIN_IIC3_SMBSUS_OUT 10 24 + #define PIN_IIC3_SMBALERT 11 25 + #define PIN_PCIE0_L0_RESET 12 26 + #define PIN_PCIE0_L1_RESET 13 27 + #define PIN_PCIE0_L0_WAKEUP 14 28 + #define PIN_PCIE0_L1_WAKEUP 15 29 + #define PIN_PCIE0_L0_CLKREQ_IN 16 30 + #define PIN_PCIE0_L1_CLKREQ_IN 17 31 + #define PIN_PCIE1_L0_RESET 18 32 + #define PIN_PCIE1_L1_RESET 19 33 + #define PIN_PCIE1_L0_WAKEUP 20 34 + #define PIN_PCIE1_L1_WAKEUP 21 35 + #define PIN_PCIE1_L0_CLKREQ_IN 22 36 + #define PIN_PCIE1_L1_CLKREQ_IN 23 37 + #define PIN_PCIE2_L0_RESET 24 38 + #define PIN_PCIE2_L1_RESET 25 39 + #define PIN_PCIE2_L0_WAKEUP 26 40 + #define PIN_PCIE2_L1_WAKEUP 27 41 + #define PIN_PCIE2_L0_CLKREQ_IN 28 42 + #define PIN_PCIE2_L1_CLKREQ_IN 29 43 + #define PIN_PCIE3_L0_RESET 30 44 + #define PIN_PCIE3_L1_RESET 31 45 + #define PIN_PCIE3_L0_WAKEUP 32 46 + #define PIN_PCIE3_L1_WAKEUP 33 47 + #define PIN_PCIE3_L0_CLKREQ_IN 34 48 + #define PIN_PCIE3_L1_CLKREQ_IN 35 49 + #define PIN_PCIE4_L0_RESET 36 50 + #define PIN_PCIE4_L1_RESET 37 51 + #define PIN_PCIE4_L0_WAKEUP 38 52 + #define PIN_PCIE4_L1_WAKEUP 39 53 + #define PIN_PCIE4_L0_CLKREQ_IN 40 54 + #define PIN_PCIE4_L1_CLKREQ_IN 41 55 + #define PIN_SPIF0_CLK_SEL1 42 56 + #define PIN_SPIF0_CLK_SEL0 43 57 + #define PIN_SPIF0_WP 44 58 + #define PIN_SPIF0_HOLD 45 59 + #define PIN_SPIF0_SDI 46 60 + #define PIN_SPIF0_CS 47 61 + #define PIN_SPIF0_SCK 48 62 + #define PIN_SPIF0_SDO 49 63 + #define PIN_SPIF1_CLK_SEL1 50 64 + #define PIN_SPIF1_CLK_SEL0 51 65 + #define PIN_SPIF1_WP 52 66 + #define PIN_SPIF1_HOLD 53 67 + #define PIN_SPIF1_SDI 54 68 + #define PIN_SPIF1_CS 55 69 + #define PIN_SPIF1_SCK 56 70 + #define PIN_SPIF1_SDO 57 71 + #define PIN_EMMC_WP 58 72 + #define PIN_EMMC_CD 59 73 + #define PIN_EMMC_RST 60 74 + #define PIN_EMMC_PWR_EN 61 75 + #define PIN_SDIO_CD 62 76 + #define PIN_SDIO_WP 63 77 + #define PIN_SDIO_RST 64 78 + #define PIN_SDIO_PWR_EN 65 79 + #define PIN_RGMII0_TXD0 66 80 + #define PIN_RGMII0_TXD1 67 81 + #define PIN_RGMII0_TXD2 68 82 + #define PIN_RGMII0_TXD3 69 83 + #define PIN_RGMII0_TXCTRL 70 84 + #define PIN_RGMII0_RXD0 71 85 + #define PIN_RGMII0_RXD1 72 86 + #define PIN_RGMII0_RXD2 73 87 + #define PIN_RGMII0_RXD3 74 88 + #define PIN_RGMII0_RXCTRL 75 89 + #define PIN_RGMII0_TXC 76 90 + #define PIN_RGMII0_RXC 77 91 + #define PIN_RGMII0_REFCLKO 78 92 + #define PIN_RGMII0_IRQ 79 93 + #define PIN_RGMII0_MDC 80 94 + #define PIN_RGMII0_MDIO 81 95 + #define PIN_PWM0 82 96 + #define PIN_PWM1 83 97 + #define PIN_PWM2 84 98 + #define PIN_PWM3 85 99 + #define PIN_FAN0 86 100 + #define PIN_FAN1 87 101 + #define PIN_FAN2 88 102 + #define PIN_FAN3 89 103 + #define PIN_IIC0_SDA 90 104 + #define PIN_IIC0_SCL 91 105 + #define PIN_IIC1_SDA 92 106 + #define PIN_IIC1_SCL 93 107 + #define PIN_IIC2_SDA 94 108 + #define PIN_IIC2_SCL 95 109 + #define PIN_IIC3_SDA 96 110 + #define PIN_IIC3_SCL 97 111 + #define PIN_UART0_TX 98 112 + #define PIN_UART0_RX 99 113 + #define PIN_UART0_RTS 100 114 + #define PIN_UART0_CTS 101 115 + #define PIN_UART1_TX 102 116 + #define PIN_UART1_RX 103 117 + #define PIN_UART1_RTS 104 118 + #define PIN_UART1_CTS 105 119 + #define PIN_UART2_TX 106 120 + #define PIN_UART2_RX 107 121 + #define PIN_UART2_RTS 108 122 + #define PIN_UART2_CTS 109 123 + #define PIN_UART3_TX 110 124 + #define PIN_UART3_RX 111 125 + #define PIN_UART3_RTS 112 126 + #define PIN_UART3_CTS 113 127 + #define PIN_SPI0_CS0 114 128 + #define PIN_SPI0_CS1 115 129 + #define PIN_SPI0_SDI 116 130 + #define PIN_SPI0_SDO 117 131 + #define PIN_SPI0_SCK 118 132 + #define PIN_SPI1_CS0 119 133 + #define PIN_SPI1_CS1 120 134 + #define PIN_SPI1_SDI 121 135 + #define PIN_SPI1_SDO 122 136 + #define PIN_SPI1_SCK 123 137 + #define PIN_JTAG0_TDO 124 138 + #define PIN_JTAG0_TCK 125 139 + #define PIN_JTAG0_TDI 126 140 + #define PIN_JTAG0_TMS 127 141 + #define PIN_JTAG0_TRST 128 142 + #define PIN_JTAG0_SRST 129 143 + #define PIN_JTAG1_TDO 130 144 + #define PIN_JTAG1_TCK 131 145 + #define PIN_JTAG1_TDI 132 146 + #define PIN_JTAG1_TMS 133 147 + #define PIN_JTAG1_TRST 134 148 + #define PIN_JTAG1_SRST 135 149 + #define PIN_JTAG2_TDO 136 150 + #define PIN_JTAG2_TCK 137 151 + #define PIN_JTAG2_TDI 138 152 + #define PIN_JTAG2_TMS 139 153 + #define PIN_JTAG2_TRST 140 154 + #define PIN_JTAG2_SRST 141 155 + #define PIN_JTAG3_TDO 142 156 + #define PIN_JTAG3_TCK 143 157 + #define PIN_JTAG3_TDI 144 158 + #define PIN_JTAG3_TMS 145 159 + #define PIN_JTAG3_TRST 146 160 + #define PIN_JTAG3_SRST 147 161 + #define PIN_GPIO0 148 162 + #define PIN_GPIO1 149 163 + #define PIN_GPIO2 150 164 + #define PIN_GPIO3 151 165 + #define PIN_GPIO4 152 166 + #define PIN_GPIO5 153 167 + #define PIN_GPIO6 154 168 + #define PIN_GPIO7 155 169 + #define PIN_GPIO8 156 170 + #define PIN_GPIO9 157 171 + #define PIN_GPIO10 158 172 + #define PIN_GPIO11 159 173 + #define PIN_GPIO12 160 174 + #define PIN_GPIO13 161 175 + #define PIN_GPIO14 162 176 + #define PIN_GPIO15 163 177 + #define PIN_GPIO16 164 178 + #define PIN_GPIO17 165 179 + #define PIN_GPIO18 166 180 + #define PIN_GPIO19 167 181 + #define PIN_GPIO20 168 182 + #define PIN_GPIO21 169 183 + #define PIN_GPIO22 170 184 + #define PIN_GPIO23 171 185 + #define PIN_GPIO24 172 186 + #define PIN_GPIO25 173 187 + #define PIN_GPIO26 174 188 + #define PIN_GPIO27 175 189 + #define PIN_GPIO28 176 190 + #define PIN_GPIO29 177 191 + #define PIN_GPIO30 178 192 + #define PIN_GPIO31 179 193 + #define PIN_MODE_SEL0 180 194 + #define PIN_MODE_SEL1 181 195 + #define PIN_MODE_SEL2 182 196 + #define PIN_BOOT_SEL0 183 197 + #define PIN_BOOT_SEL1 184 198 + #define PIN_BOOT_SEL2 185 199 + #define PIN_BOOT_SEL3 186 200 + #define PIN_BOOT_SEL4 187 201 + #define PIN_BOOT_SEL5 188 202 + #define PIN_BOOT_SEL6 189 203 + #define PIN_BOOT_SEL7 190 204 + #define PIN_MULTI_SCKT 191 205 + #define PIN_SCKT_ID0 192 206 + #define PIN_SCKT_ID1 193 207 + #define PIN_PLL_CLK_IN_MAIN 194 208 + #define PIN_PLL_CLK_IN_DDR_0 195 209 + #define PIN_PLL_CLK_IN_DDR_1 196 210 + #define PIN_PLL_CLK_IN_DDR_2 197 211 + #define PIN_PLL_CLK_IN_DDR_3 198 212 + #define PIN_XTAL_32K 199 213 + #define PIN_SYS_RST 200 214 + #define PIN_PWR_BUTTON 201 215 + #define PIN_TEST_EN 202 216 + #define PIN_TEST_MODE_MBIST 203 217 + #define PIN_TEST_MODE_SCAN 204 218 + #define PIN_TEST_MODE_BSD 205 219 + #define PIN_BISR_BYP 206 220 + 221 + #endif /* _DT_BINDINGS_PINCTRL_SG2044_H */
+4
include/linux/pinctrl/pinconf-generic.h
··· 232 232 PIN_MAP_TYPE_INVALID); 233 233 } 234 234 235 + int pinconf_generic_dt_node_to_map_pinmux(struct pinctrl_dev *pctldev, 236 + struct device_node *np, 237 + struct pinctrl_map **map, 238 + unsigned int *num_maps); 235 239 #endif /* __LINUX_PINCTRL_PINCONF_GENERIC_H */
+30 -3
include/linux/platform_data/x86/pwm-lpss.h
··· 15 15 unsigned int npwm; 16 16 unsigned long base_unit_bits; 17 17 /* 18 - * Some versions of the IP may stuck in the state machine if enable 19 - * bit is not set, and hence update bit will show busy status till 20 - * the reset. For the rest it may be otherwise. 18 + * NOTE: 19 + * Intel Broxton, Apollo Lake, and Gemini Lake have different programming flow. 20 + * 21 + * Initial Enable or First Activation 22 + * 1. Program the base unit and on time divisor values. 23 + * 2. Set the software update bit. 24 + * 3. Poll in a loop on the PWMCTRL bit until software update bit is cleared.+ 25 + * 4. Enable the PWM output by setting PWM Enable. 26 + * 5. Repeat the above steps for the next PWM Module. 27 + * 28 + * Dynamic update while PWM is Enabled 29 + * 1. Program the base unit and on-time divisor values. 30 + * 2. Set the software update bit. 31 + * 3. Repeat the above steps for the next PWM module. 32 + * 33 + * + After setting PWMCTRL register's SW update bit, hardware automatically 34 + * deasserts the SW update bit after a brief delay. It was observed that 35 + * setting of PWM enable is typically done via read-modify-write of the PWMCTRL 36 + * register. If there is no/little delay between setting software update bit 37 + * and setting enable bit via read-modify-write, it is possible that the read 38 + * could return with software enable as 1. In that case, the last write to set 39 + * enable to 1 could also set sw_update to 1. If this happens, sw_update gets 40 + * stuck and the driver code can hang as it explicitly waits for sw_update bit 41 + * to be 0 after setting the enable bit to 1. To avoid this race condition, 42 + * SW should poll on the software update bit to make sure that it is 0 before 43 + * doing the read-modify-write to set the enable bit to 1. 44 + * 45 + * Also, we noted that if sw_update bit was set in step #1 above then when it 46 + * is set again in step #2, sw_update bit never gets cleared and the flow hangs. 47 + * As such, we need to make sure that sw_update bit is 0 when doing step #1. 21 48 */ 22 49 bool bypass; 23 50 /*