950-0857-pinctrl-bcm2712-pinctrl-pinconf-driver.patch 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324
  1. From af7e60a33f0b5ce84bffb69ba084ba1edd180195 Mon Sep 17 00:00:00 2001
  2. From: Phil Elwell <[email protected]>
  3. Date: Wed, 9 Jun 2021 15:48:28 +0100
  4. Subject: [PATCH] pinctrl: bcm2712 pinctrl/pinconf driver
  5. pinctrl: bcm2712: Reject invalid pulls
  6. Reject attempts to set pulls on aon-sgpios, and fix pull shift
  7. values.
  8. pinctrl: bcm2712: Add 7712 support, fix 2712 count
  9. Signed-off-by: Phil Elwell <[email protected]>
  10. pinctrl-bcm2712: add EMMC pins so pulls can be set
  11. These pins have pad controls but not mux controls. They look enough like
  12. GPIOs to squeeze in at the end of the list though.
  13. pinctrl: bcm2712: correct BCM2712C0 AON_GPIO pad pull control offset
  14. Signed-off-by: Jonathan Bell <[email protected]>
  15. pinctrl: bcm2712: on C0 the regular GPIO pad control register moves too
  16. Signed-off-by: Jonathan Bell <[email protected]>
  17. pinctrl: bcm2712: Implement (partially) pinconf_get
  18. Signed-off-by: Phil Elwell <[email protected]>
  19. pinctrl: bcm2712: Convert to generic pinconf
  20. Remove the legacy brcm,* pin configuration support and replace it with
  21. a proper generic pinconf interface, using named functions instead of
  22. alt function numbers. This is nicer for users, less error-prone, and
  23. immune to some of the C0->D0 changes.
  24. Signed-off-by: Phil Elwell <[email protected]>
  25. pinctrl: bcm2712: Remove vestigial pull parameter
  26. Now the legacy brcm, pinconf parameters are no longer supported, this
  27. custom pin config parameter is not needed.
  28. Signed-off-by: Phil Elwell <[email protected]>
  29. pinctrl: bcm2712: Guard against bad func numbers
  30. Signed-off-by: Phil Elwell <[email protected]>
  31. pinctrl: bcm2712: A better attempt at D0 support
  32. The BCM2712D0 sparse pinctrl maps play havoc with the old GPIO_REGS
  33. macro, so make the bit positions explicit. And delete the unwanted
  34. GPIO and pinmux declarations on D0.
  35. Note that a Pi 5 with D0 requires a separate DTS file with "bcm2712d0"
  36. compatible strings.
  37. Signed-off-by: Phil Elwell <[email protected]>
  38. pinctrl: bcm2712: Delete base register constants
  39. BCM2712D0 deletes many GPIOs and their associated mux and pad bits,
  40. so much so that the offsets to the start of the pad control registers
  41. changes. Remove the constant offsets from the *GPIO_REGS macros,
  42. compensating by adjusting the per-GPIO values.
  43. Signed-off-by: Phil Elwell <[email protected]>
  44. ---
  45. drivers/pinctrl/bcm/Kconfig | 9 +
  46. drivers/pinctrl/bcm/Makefile | 1 +
  47. drivers/pinctrl/bcm/pinctrl-bcm2712.c | 1216 +++++++++++++++++++++++++
  48. 3 files changed, 1226 insertions(+)
  49. create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm2712.c
  50. --- a/drivers/pinctrl/bcm/Kconfig
  51. +++ b/drivers/pinctrl/bcm/Kconfig
  52. @@ -3,6 +3,15 @@
  53. # Broadcom pinctrl drivers
  54. #
  55. +config PINCTRL_BCM2712
  56. + bool "Broadcom BCM2712 PINCONF driver"
  57. + depends on OF && (ARCH_BCM2835 || ARCH_BRCMSTB || COMPILE_TEST)
  58. + select PINMUX
  59. + select PINCONF
  60. + select GENERIC_PINCONF
  61. + help
  62. + Say Y here to enable the Broadcom BCM2835 GPIO driver.
  63. +
  64. config PINCTRL_BCM281XX
  65. bool "Broadcom BCM281xx pinctrl driver"
  66. depends on OF && (ARCH_BCM_MOBILE || COMPILE_TEST)
  67. --- a/drivers/pinctrl/bcm/Makefile
  68. +++ b/drivers/pinctrl/bcm/Makefile
  69. @@ -1,6 +1,7 @@
  70. # SPDX-License-Identifier: GPL-2.0
  71. # Broadcom pinctrl support
  72. +obj-$(CONFIG_PINCTRL_BCM2712) += pinctrl-bcm2712.o
  73. obj-$(CONFIG_PINCTRL_BCM281XX) += pinctrl-bcm281xx.o
  74. obj-$(CONFIG_PINCTRL_BCM2835) += pinctrl-bcm2835.o
  75. obj-$(CONFIG_PINCTRL_BCM4908) += pinctrl-bcm4908.o
  76. --- /dev/null
  77. +++ b/drivers/pinctrl/bcm/pinctrl-bcm2712.c
  78. @@ -0,0 +1,1216 @@
  79. +// SPDX-License-Identifier: GPL-2.0+
  80. +/*
  81. + * Driver for Broadcom BCM2712 GPIO units (pinctrl only)
  82. + *
  83. + * Copyright (C) 2021-3 Raspberry Pi Ltd.
  84. + * Copyright (C) 2012 Chris Boot, Simon Arlott, Stephen Warren
  85. + *
  86. + * Based heavily on the BCM2835 GPIO & pinctrl driver, which was inspired by:
  87. + * pinctrl-nomadik.c, please see original file for copyright information
  88. + * pinctrl-tegra.c, please see original file for copyright information
  89. + */
  90. +
  91. +#include <linux/bitmap.h>
  92. +#include <linux/bug.h>
  93. +#include <linux/delay.h>
  94. +#include <linux/device.h>
  95. +#include <linux/err.h>
  96. +#include <linux/io.h>
  97. +#include <linux/init.h>
  98. +#include <linux/interrupt.h>
  99. +#include <linux/of_address.h>
  100. +#include <linux/of.h>
  101. +#include <linux/pinctrl/consumer.h>
  102. +#include <linux/pinctrl/machine.h>
  103. +#include <linux/pinctrl/pinconf.h>
  104. +#include <linux/pinctrl/pinctrl.h>
  105. +#include <linux/pinctrl/pinmux.h>
  106. +#include <linux/pinctrl/pinconf-generic.h>
  107. +#include <linux/platform_device.h>
  108. +#include <linux/seq_file.h>
  109. +#include <linux/slab.h>
  110. +#include <linux/spinlock.h>
  111. +#include <linux/types.h>
  112. +
  113. +#define MODULE_NAME "pinctrl-bcm2712"
  114. +
  115. +/* Register offsets */
  116. +
  117. +#define BCM2712_PULL_NONE 0
  118. +#define BCM2712_PULL_DOWN 1
  119. +#define BCM2712_PULL_UP 2
  120. +#define BCM2712_PULL_MASK 0x3
  121. +
  122. +#define BCM2712_FSEL_COUNT 9
  123. +#define BCM2712_FSEL_MASK 0xf
  124. +
  125. +#define FUNC(f) \
  126. + [func_##f] = #f
  127. +#define PIN(i, f1, f2, f3, f4, f5, f6, f7, f8) \
  128. + [i] = { \
  129. + .funcs = { \
  130. + func_##f1, \
  131. + func_##f2, \
  132. + func_##f3, \
  133. + func_##f4, \
  134. + func_##f5, \
  135. + func_##f6, \
  136. + func_##f7, \
  137. + func_##f8, \
  138. + }, \
  139. + }
  140. +
  141. +#define REG_BIT_INVALID 0xffff
  142. +
  143. +#define BIT_TO_REG(b) (((b) >> 5) << 2)
  144. +#define BIT_TO_SHIFT(b) ((b) & 0x1f)
  145. +
  146. +#define GPIO_REGS(n, mr, mb, pr, pb) \
  147. + [n] = { ((mr)*4)*8 + (mb)*4, ((pr)*4)*8 + (pb)*2 }
  148. +
  149. +#define EMMC_REGS(n, r, b) \
  150. + [n] = { 0, ((r)*4)*8 + (b)*2 }
  151. +
  152. +#define AGPIO_REGS(n, mr, mb, pr, pb) \
  153. + [n] = { ((mr)*4)*8 + (mb)*4, ((pr)*4)*8 + (pb)*2 }
  154. +
  155. +#define SGPIO_REGS(n, mr, mb) \
  156. + [n+32] = { ((mr)*4)*8 + (mb)*4, REG_BIT_INVALID }
  157. +
  158. +#define GPIO_PIN(a) PINCTRL_PIN(a, "gpio" #a)
  159. +#define AGPIO_PIN(a) PINCTRL_PIN(a, "aon_gpio" #a)
  160. +#define SGPIO_PIN(a) PINCTRL_PIN(a+32, "aon_sgpio" #a)
  161. +
  162. +struct pin_regs {
  163. + u16 mux_bit;
  164. + u16 pad_bit;
  165. +};
  166. +
  167. +struct bcm2712_pinctrl {
  168. + struct device *dev;
  169. + void __iomem *base;
  170. + struct pinctrl_dev *pctl_dev;
  171. + struct pinctrl_desc pctl_desc;
  172. + const struct pin_regs *pin_regs;
  173. + const struct bcm2712_pin_funcs *pin_funcs;
  174. + const char *const *gpio_groups;
  175. + struct pinctrl_gpio_range gpio_range;
  176. + spinlock_t lock;
  177. +};
  178. +
  179. +struct bcm_plat_data {
  180. + const struct pinctrl_desc *pctl_desc;
  181. + const struct pinctrl_gpio_range *gpio_range;
  182. + const struct pin_regs *pin_regs;
  183. + const struct bcm2712_pin_funcs *pin_funcs;
  184. +};
  185. +
  186. +struct bcm2712_pin_funcs {
  187. + u8 funcs[BCM2712_FSEL_COUNT - 1];
  188. +};
  189. +
  190. +enum bcm2712_funcs {
  191. + func_gpio,
  192. + func_alt1,
  193. + func_alt2,
  194. + func_alt3,
  195. + func_alt4,
  196. + func_alt5,
  197. + func_alt6,
  198. + func_alt7,
  199. + func_alt8,
  200. + func_aon_cpu_standbyb,
  201. + func_aon_fp_4sec_resetb,
  202. + func_aon_gpclk,
  203. + func_aon_pwm,
  204. + func_arm_jtag,
  205. + func_aud_fs_clk0,
  206. + func_avs_pmu_bsc,
  207. + func_bsc_m0,
  208. + func_bsc_m1,
  209. + func_bsc_m2,
  210. + func_bsc_m3,
  211. + func_clk_observe,
  212. + func_ctl_hdmi_5v,
  213. + func_enet0,
  214. + func_enet0_mii,
  215. + func_enet0_rgmii,
  216. + func_ext_sc_clk,
  217. + func_fl0,
  218. + func_fl1,
  219. + func_gpclk0,
  220. + func_gpclk1,
  221. + func_gpclk2,
  222. + func_hdmi_tx0_auto_i2c,
  223. + func_hdmi_tx0_bsc,
  224. + func_hdmi_tx1_auto_i2c,
  225. + func_hdmi_tx1_bsc,
  226. + func_i2s_in,
  227. + func_i2s_out,
  228. + func_ir_in,
  229. + func_mtsif,
  230. + func_mtsif_alt,
  231. + func_mtsif_alt1,
  232. + func_pdm,
  233. + func_pkt,
  234. + func_pm_led_out,
  235. + func_sc0,
  236. + func_sd0,
  237. + func_sd2,
  238. + func_sd_card_a,
  239. + func_sd_card_b,
  240. + func_sd_card_c,
  241. + func_sd_card_d,
  242. + func_sd_card_e,
  243. + func_sd_card_f,
  244. + func_sd_card_g,
  245. + func_spdif_out,
  246. + func_spi_m,
  247. + func_spi_s,
  248. + func_sr_edm_sense,
  249. + func_te0,
  250. + func_te1,
  251. + func_tsio,
  252. + func_uart0,
  253. + func_uart1,
  254. + func_uart2,
  255. + func_usb_pwr,
  256. + func_usb_vbus,
  257. + func_uui,
  258. + func_vc_i2c0,
  259. + func_vc_i2c3,
  260. + func_vc_i2c4,
  261. + func_vc_i2c5,
  262. + func_vc_i2csl,
  263. + func_vc_pcm,
  264. + func_vc_pwm0,
  265. + func_vc_pwm1,
  266. + func_vc_spi0,
  267. + func_vc_spi3,
  268. + func_vc_spi4,
  269. + func_vc_spi5,
  270. + func_vc_uart0,
  271. + func_vc_uart2,
  272. + func_vc_uart3,
  273. + func_vc_uart4,
  274. + func__,
  275. + func_count = func__
  276. +};
  277. +
  278. +static const struct pin_regs bcm2712_c0_gpio_pin_regs[] = {
  279. + GPIO_REGS(0, 0, 0, 7, 7),
  280. + GPIO_REGS(1, 0, 1, 7, 8),
  281. + GPIO_REGS(2, 0, 2, 7, 9),
  282. + GPIO_REGS(3, 0, 3, 7, 10),
  283. + GPIO_REGS(4, 0, 4, 7, 11),
  284. + GPIO_REGS(5, 0, 5, 7, 12),
  285. + GPIO_REGS(6, 0, 6, 7, 13),
  286. + GPIO_REGS(7, 0, 7, 7, 14),
  287. + GPIO_REGS(8, 1, 0, 8, 0),
  288. + GPIO_REGS(9, 1, 1, 8, 1),
  289. + GPIO_REGS(10, 1, 2, 8, 2),
  290. + GPIO_REGS(11, 1, 3, 8, 3),
  291. + GPIO_REGS(12, 1, 4, 8, 4),
  292. + GPIO_REGS(13, 1, 5, 8, 5),
  293. + GPIO_REGS(14, 1, 6, 8, 6),
  294. + GPIO_REGS(15, 1, 7, 8, 7),
  295. + GPIO_REGS(16, 2, 0, 8, 8),
  296. + GPIO_REGS(17, 2, 1, 8, 9),
  297. + GPIO_REGS(18, 2, 2, 8, 10),
  298. + GPIO_REGS(19, 2, 3, 8, 11),
  299. + GPIO_REGS(20, 2, 4, 8, 12),
  300. + GPIO_REGS(21, 2, 5, 8, 13),
  301. + GPIO_REGS(22, 2, 6, 8, 14),
  302. + GPIO_REGS(23, 2, 7, 9, 0),
  303. + GPIO_REGS(24, 3, 0, 9, 1),
  304. + GPIO_REGS(25, 3, 1, 9, 2),
  305. + GPIO_REGS(26, 3, 2, 9, 3),
  306. + GPIO_REGS(27, 3, 3, 9, 4),
  307. + GPIO_REGS(28, 3, 4, 9, 5),
  308. + GPIO_REGS(29, 3, 5, 9, 6),
  309. + GPIO_REGS(30, 3, 6, 9, 7),
  310. + GPIO_REGS(31, 3, 7, 9, 8),
  311. + GPIO_REGS(32, 4, 0, 9, 9),
  312. + GPIO_REGS(33, 4, 1, 9, 10),
  313. + GPIO_REGS(34, 4, 2, 9, 11),
  314. + GPIO_REGS(35, 4, 3, 9, 12),
  315. + GPIO_REGS(36, 4, 4, 9, 13),
  316. + GPIO_REGS(37, 4, 5, 9, 14),
  317. + GPIO_REGS(38, 4, 6, 10, 0),
  318. + GPIO_REGS(39, 4, 7, 10, 1),
  319. + GPIO_REGS(40, 5, 0, 10, 2),
  320. + GPIO_REGS(41, 5, 1, 10, 3),
  321. + GPIO_REGS(42, 5, 2, 10, 4),
  322. + GPIO_REGS(43, 5, 3, 10, 5),
  323. + GPIO_REGS(44, 5, 4, 10, 6),
  324. + GPIO_REGS(45, 5, 5, 10, 7),
  325. + GPIO_REGS(46, 5, 6, 10, 8),
  326. + GPIO_REGS(47, 5, 7, 10, 9),
  327. + GPIO_REGS(48, 6, 0, 10, 10),
  328. + GPIO_REGS(49, 6, 1, 10, 11),
  329. + GPIO_REGS(50, 6, 2, 10, 12),
  330. + GPIO_REGS(51, 6, 3, 10, 13),
  331. + GPIO_REGS(52, 6, 4, 10, 14),
  332. + GPIO_REGS(53, 6, 5, 11, 0),
  333. + EMMC_REGS(54, 11, 1), /* EMMC_CMD */
  334. + EMMC_REGS(55, 11, 2), /* EMMC_DS */
  335. + EMMC_REGS(56, 11, 3), /* EMMC_CLK */
  336. + EMMC_REGS(57, 11, 4), /* EMMC_DAT0 */
  337. + EMMC_REGS(58, 11, 5), /* EMMC_DAT1 */
  338. + EMMC_REGS(59, 11, 6), /* EMMC_DAT2 */
  339. + EMMC_REGS(60, 11, 7), /* EMMC_DAT3 */
  340. + EMMC_REGS(61, 11, 8), /* EMMC_DAT4 */
  341. + EMMC_REGS(62, 11, 9), /* EMMC_DAT5 */
  342. + EMMC_REGS(63, 11, 10), /* EMMC_DAT6 */
  343. + EMMC_REGS(64, 11, 11), /* EMMC_DAT7 */
  344. +};
  345. +
  346. +static struct pin_regs bcm2712_c0_aon_gpio_pin_regs[] = {
  347. + AGPIO_REGS(0, 3, 0, 6, 10),
  348. + AGPIO_REGS(1, 3, 1, 6, 11),
  349. + AGPIO_REGS(2, 3, 2, 6, 12),
  350. + AGPIO_REGS(3, 3, 3, 6, 13),
  351. + AGPIO_REGS(4, 3, 4, 6, 14),
  352. + AGPIO_REGS(5, 3, 5, 7, 0),
  353. + AGPIO_REGS(6, 3, 6, 7, 1),
  354. + AGPIO_REGS(7, 3, 7, 7, 2),
  355. + AGPIO_REGS(8, 4, 0, 7, 3),
  356. + AGPIO_REGS(9, 4, 1, 7, 4),
  357. + AGPIO_REGS(10, 4, 2, 7, 5),
  358. + AGPIO_REGS(11, 4, 3, 7, 6),
  359. + AGPIO_REGS(12, 4, 4, 7, 7),
  360. + AGPIO_REGS(13, 4, 5, 7, 8),
  361. + AGPIO_REGS(14, 4, 6, 7, 9),
  362. + AGPIO_REGS(15, 4, 7, 7, 10),
  363. + AGPIO_REGS(16, 5, 0, 7, 11),
  364. + SGPIO_REGS(0, 0, 0),
  365. + SGPIO_REGS(1, 0, 1),
  366. + SGPIO_REGS(2, 0, 2),
  367. + SGPIO_REGS(3, 0, 3),
  368. + SGPIO_REGS(4, 1, 0),
  369. + SGPIO_REGS(5, 2, 0),
  370. +};
  371. +
  372. +static const struct pinctrl_pin_desc bcm2712_c0_gpio_pins[] = {
  373. + GPIO_PIN(0),
  374. + GPIO_PIN(1),
  375. + GPIO_PIN(2),
  376. + GPIO_PIN(3),
  377. + GPIO_PIN(4),
  378. + GPIO_PIN(5),
  379. + GPIO_PIN(6),
  380. + GPIO_PIN(7),
  381. + GPIO_PIN(8),
  382. + GPIO_PIN(9),
  383. + GPIO_PIN(10),
  384. + GPIO_PIN(11),
  385. + GPIO_PIN(12),
  386. + GPIO_PIN(13),
  387. + GPIO_PIN(14),
  388. + GPIO_PIN(15),
  389. + GPIO_PIN(16),
  390. + GPIO_PIN(17),
  391. + GPIO_PIN(18),
  392. + GPIO_PIN(19),
  393. + GPIO_PIN(20),
  394. + GPIO_PIN(21),
  395. + GPIO_PIN(22),
  396. + GPIO_PIN(23),
  397. + GPIO_PIN(24),
  398. + GPIO_PIN(25),
  399. + GPIO_PIN(26),
  400. + GPIO_PIN(27),
  401. + GPIO_PIN(28),
  402. + GPIO_PIN(29),
  403. + GPIO_PIN(30),
  404. + GPIO_PIN(31),
  405. + GPIO_PIN(32),
  406. + GPIO_PIN(33),
  407. + GPIO_PIN(34),
  408. + GPIO_PIN(35),
  409. + GPIO_PIN(36),
  410. + GPIO_PIN(37),
  411. + GPIO_PIN(38),
  412. + GPIO_PIN(39),
  413. + GPIO_PIN(40),
  414. + GPIO_PIN(41),
  415. + GPIO_PIN(42),
  416. + GPIO_PIN(43),
  417. + GPIO_PIN(44),
  418. + GPIO_PIN(45),
  419. + GPIO_PIN(46),
  420. + GPIO_PIN(47),
  421. + GPIO_PIN(48),
  422. + GPIO_PIN(49),
  423. + GPIO_PIN(50),
  424. + GPIO_PIN(51),
  425. + GPIO_PIN(52),
  426. + GPIO_PIN(53),
  427. + PINCTRL_PIN(54, "emmc_cmd"),
  428. + PINCTRL_PIN(55, "emmc_ds"),
  429. + PINCTRL_PIN(56, "emmc_clk"),
  430. + PINCTRL_PIN(57, "emmc_dat0"),
  431. + PINCTRL_PIN(58, "emmc_dat1"),
  432. + PINCTRL_PIN(59, "emmc_dat2"),
  433. + PINCTRL_PIN(60, "emmc_dat3"),
  434. + PINCTRL_PIN(61, "emmc_dat4"),
  435. + PINCTRL_PIN(62, "emmc_dat5"),
  436. + PINCTRL_PIN(63, "emmc_dat6"),
  437. + PINCTRL_PIN(64, "emmc_dat7"),
  438. +};
  439. +
  440. +static struct pinctrl_pin_desc bcm2712_c0_aon_gpio_pins[] = {
  441. + AGPIO_PIN(0),
  442. + AGPIO_PIN(1),
  443. + AGPIO_PIN(2),
  444. + AGPIO_PIN(3),
  445. + AGPIO_PIN(4),
  446. + AGPIO_PIN(5),
  447. + AGPIO_PIN(6),
  448. + AGPIO_PIN(7),
  449. + AGPIO_PIN(8),
  450. + AGPIO_PIN(9),
  451. + AGPIO_PIN(10),
  452. + AGPIO_PIN(11),
  453. + AGPIO_PIN(12),
  454. + AGPIO_PIN(13),
  455. + AGPIO_PIN(14),
  456. + AGPIO_PIN(15),
  457. + AGPIO_PIN(16),
  458. + SGPIO_PIN(0),
  459. + SGPIO_PIN(1),
  460. + SGPIO_PIN(2),
  461. + SGPIO_PIN(3),
  462. + SGPIO_PIN(4),
  463. + SGPIO_PIN(5),
  464. +};
  465. +
  466. +static const struct pin_regs bcm2712_d0_gpio_pin_regs[] = {
  467. + GPIO_REGS(1, 0, 0, 4, 5),
  468. + GPIO_REGS(2, 0, 1, 4, 6),
  469. + GPIO_REGS(3, 0, 2, 4, 7),
  470. + GPIO_REGS(4, 0, 3, 4, 8),
  471. + GPIO_REGS(10, 0, 4, 4, 9),
  472. + GPIO_REGS(11, 0, 5, 4, 10),
  473. + GPIO_REGS(12, 0, 6, 4, 11),
  474. + GPIO_REGS(13, 0, 7, 4, 12),
  475. + GPIO_REGS(14, 1, 0, 4, 13),
  476. + GPIO_REGS(15, 1, 1, 4, 14),
  477. + GPIO_REGS(18, 1, 2, 5, 0),
  478. + GPIO_REGS(19, 1, 3, 5, 1),
  479. + GPIO_REGS(20, 1, 4, 5, 2),
  480. + GPIO_REGS(21, 1, 5, 5, 3),
  481. + GPIO_REGS(22, 1, 6, 5, 4),
  482. + GPIO_REGS(23, 1, 7, 5, 5),
  483. + GPIO_REGS(24, 2, 0, 5, 6),
  484. + GPIO_REGS(25, 2, 1, 5, 7),
  485. + GPIO_REGS(26, 2, 2, 5, 8),
  486. + GPIO_REGS(27, 2, 3, 5, 9),
  487. + GPIO_REGS(28, 2, 4, 5, 10),
  488. + GPIO_REGS(29, 2, 5, 5, 11),
  489. + GPIO_REGS(30, 2, 6, 5, 12),
  490. + GPIO_REGS(31, 2, 7, 5, 13),
  491. + GPIO_REGS(32, 3, 0, 5, 14),
  492. + GPIO_REGS(33, 3, 1, 6, 0),
  493. + GPIO_REGS(34, 3, 2, 6, 1),
  494. + GPIO_REGS(35, 3, 3, 6, 2),
  495. +};
  496. +
  497. +static struct pin_regs bcm2712_d0_aon_gpio_pin_regs[] = {
  498. + AGPIO_REGS(0, 3, 0, 5, 9),
  499. + AGPIO_REGS(1, 3, 1, 5, 10),
  500. + AGPIO_REGS(2, 3, 2, 5, 11),
  501. + AGPIO_REGS(3, 3, 3, 5, 12),
  502. + AGPIO_REGS(4, 3, 4, 5, 13),
  503. + AGPIO_REGS(5, 3, 5, 5, 14),
  504. + AGPIO_REGS(6, 3, 6, 6, 0),
  505. + AGPIO_REGS(8, 3, 7, 6, 1),
  506. + AGPIO_REGS(9, 4, 0, 6, 2),
  507. + AGPIO_REGS(12, 4, 1, 6, 3),
  508. + AGPIO_REGS(13, 4, 2, 6, 4),
  509. + AGPIO_REGS(14, 4, 3, 6, 5),
  510. + SGPIO_REGS(0, 0, 0),
  511. + SGPIO_REGS(1, 0, 1),
  512. + SGPIO_REGS(2, 0, 2),
  513. + SGPIO_REGS(3, 0, 3),
  514. + SGPIO_REGS(4, 1, 0),
  515. + SGPIO_REGS(5, 2, 0),
  516. +};
  517. +
  518. +static const struct pinctrl_pin_desc bcm2712_d0_gpio_pins[] = {
  519. + GPIO_PIN(1),
  520. + GPIO_PIN(2),
  521. + GPIO_PIN(3),
  522. + GPIO_PIN(4),
  523. + GPIO_PIN(10),
  524. + GPIO_PIN(11),
  525. + GPIO_PIN(12),
  526. + GPIO_PIN(13),
  527. + GPIO_PIN(14),
  528. + GPIO_PIN(15),
  529. + GPIO_PIN(18),
  530. + GPIO_PIN(19),
  531. + GPIO_PIN(20),
  532. + GPIO_PIN(21),
  533. + GPIO_PIN(22),
  534. + GPIO_PIN(23),
  535. + GPIO_PIN(24),
  536. + GPIO_PIN(25),
  537. + GPIO_PIN(26),
  538. + GPIO_PIN(27),
  539. + GPIO_PIN(28),
  540. + GPIO_PIN(29),
  541. + GPIO_PIN(30),
  542. + GPIO_PIN(31),
  543. + GPIO_PIN(32),
  544. + GPIO_PIN(33),
  545. + GPIO_PIN(34),
  546. + GPIO_PIN(35),
  547. +};
  548. +
  549. +static struct pinctrl_pin_desc bcm2712_d0_aon_gpio_pins[] = {
  550. + AGPIO_PIN(0),
  551. + AGPIO_PIN(1),
  552. + AGPIO_PIN(2),
  553. + AGPIO_PIN(3),
  554. + AGPIO_PIN(4),
  555. + AGPIO_PIN(5),
  556. + AGPIO_PIN(6),
  557. + AGPIO_PIN(8),
  558. + AGPIO_PIN(9),
  559. + AGPIO_PIN(12),
  560. + AGPIO_PIN(13),
  561. + AGPIO_PIN(14),
  562. + SGPIO_PIN(0),
  563. + SGPIO_PIN(1),
  564. + SGPIO_PIN(2),
  565. + SGPIO_PIN(3),
  566. + SGPIO_PIN(4),
  567. + SGPIO_PIN(5),
  568. +};
  569. +
  570. +static const char * const bcm2712_func_names[] = {
  571. + FUNC(gpio),
  572. + FUNC(alt1),
  573. + FUNC(alt2),
  574. + FUNC(alt3),
  575. + FUNC(alt4),
  576. + FUNC(alt5),
  577. + FUNC(alt6),
  578. + FUNC(alt7),
  579. + FUNC(alt8),
  580. + FUNC(aon_cpu_standbyb),
  581. + FUNC(aon_fp_4sec_resetb),
  582. + FUNC(aon_gpclk),
  583. + FUNC(aon_pwm),
  584. + FUNC(arm_jtag),
  585. + FUNC(aud_fs_clk0),
  586. + FUNC(avs_pmu_bsc),
  587. + FUNC(bsc_m0),
  588. + FUNC(bsc_m1),
  589. + FUNC(bsc_m2),
  590. + FUNC(bsc_m3),
  591. + FUNC(clk_observe),
  592. + FUNC(ctl_hdmi_5v),
  593. + FUNC(enet0),
  594. + FUNC(enet0_mii),
  595. + FUNC(enet0_rgmii),
  596. + FUNC(ext_sc_clk),
  597. + FUNC(fl0),
  598. + FUNC(fl1),
  599. + FUNC(gpclk0),
  600. + FUNC(gpclk1),
  601. + FUNC(gpclk2),
  602. + FUNC(hdmi_tx0_auto_i2c),
  603. + FUNC(hdmi_tx0_bsc),
  604. + FUNC(hdmi_tx1_auto_i2c),
  605. + FUNC(hdmi_tx1_bsc),
  606. + FUNC(i2s_in),
  607. + FUNC(i2s_out),
  608. + FUNC(ir_in),
  609. + FUNC(mtsif),
  610. + FUNC(mtsif_alt),
  611. + FUNC(mtsif_alt1),
  612. + FUNC(pdm),
  613. + FUNC(pkt),
  614. + FUNC(pm_led_out),
  615. + FUNC(sc0),
  616. + FUNC(sd0),
  617. + FUNC(sd2),
  618. + FUNC(sd_card_a),
  619. + FUNC(sd_card_b),
  620. + FUNC(sd_card_c),
  621. + FUNC(sd_card_d),
  622. + FUNC(sd_card_e),
  623. + FUNC(sd_card_f),
  624. + FUNC(sd_card_g),
  625. + FUNC(spdif_out),
  626. + FUNC(spi_m),
  627. + FUNC(spi_s),
  628. + FUNC(sr_edm_sense),
  629. + FUNC(te0),
  630. + FUNC(te1),
  631. + FUNC(tsio),
  632. + FUNC(uart0),
  633. + FUNC(uart1),
  634. + FUNC(uart2),
  635. + FUNC(usb_pwr),
  636. + FUNC(usb_vbus),
  637. + FUNC(uui),
  638. + FUNC(vc_i2c0),
  639. + FUNC(vc_i2c3),
  640. + FUNC(vc_i2c4),
  641. + FUNC(vc_i2c5),
  642. + FUNC(vc_i2csl),
  643. + FUNC(vc_pcm),
  644. + FUNC(vc_pwm0),
  645. + FUNC(vc_pwm1),
  646. + FUNC(vc_spi0),
  647. + FUNC(vc_spi3),
  648. + FUNC(vc_spi4),
  649. + FUNC(vc_spi5),
  650. + FUNC(vc_uart0),
  651. + FUNC(vc_uart2),
  652. + FUNC(vc_uart3),
  653. + FUNC(vc_uart4),
  654. +};
  655. +
  656. +static const struct bcm2712_pin_funcs bcm2712_c0_aon_gpio_pin_funcs[] = {
  657. + PIN(0, ir_in, vc_spi0, vc_uart3, vc_i2c3, te0, vc_i2c0, _, _),
  658. + PIN(1, vc_pwm0, vc_spi0, vc_uart3, vc_i2c3, te1, aon_pwm, vc_i2c0, vc_pwm1),
  659. + PIN(2, vc_pwm0, vc_spi0, vc_uart3, ctl_hdmi_5v, fl0, aon_pwm, ir_in, vc_pwm1),
  660. + PIN(3, ir_in, vc_spi0, vc_uart3, aon_fp_4sec_resetb, fl1, sd_card_g, aon_gpclk, _),
  661. + PIN(4, gpclk0, vc_spi0, vc_i2csl, aon_gpclk, pm_led_out, aon_pwm, sd_card_g, vc_pwm0),
  662. + PIN(5, gpclk1, ir_in, vc_i2csl, clk_observe, aon_pwm, sd_card_g, vc_pwm0, _),
  663. + PIN(6, uart1, vc_uart4, gpclk2, ctl_hdmi_5v, vc_uart0, vc_spi3, _, _),
  664. + PIN(7, uart1, vc_uart4, gpclk0, aon_pwm, vc_uart0, vc_spi3, _, _),
  665. + PIN(8, uart1, vc_uart4, vc_i2csl, ctl_hdmi_5v, vc_uart0, vc_spi3, _, _),
  666. + PIN(9, uart1, vc_uart4, vc_i2csl, aon_pwm, vc_uart0, vc_spi3, _, _),
  667. + PIN(10, tsio, ctl_hdmi_5v, sc0, spdif_out, vc_spi5, usb_pwr, aon_gpclk, sd_card_f),
  668. + PIN(11, tsio, uart0, sc0, aud_fs_clk0, vc_spi5, usb_vbus, vc_uart2, sd_card_f),
  669. + PIN(12, tsio, uart0, vc_uart0, tsio, vc_spi5, usb_pwr, vc_uart2, sd_card_f),
  670. + PIN(13, bsc_m1, uart0, vc_uart0, uui, vc_spi5, arm_jtag, vc_uart2, vc_i2c3),
  671. + PIN(14, bsc_m1, uart0, vc_uart0, uui, vc_spi5, arm_jtag, vc_uart2, vc_i2c3),
  672. + PIN(15, ir_in, aon_fp_4sec_resetb, vc_uart0, pm_led_out, ctl_hdmi_5v, aon_pwm, aon_gpclk, _),
  673. + PIN(16, aon_cpu_standbyb, gpclk0, pm_led_out, ctl_hdmi_5v, vc_pwm0, usb_pwr, aud_fs_clk0, _),
  674. +};
  675. +
  676. +static const struct bcm2712_pin_funcs bcm2712_c0_aon_sgpio_pin_funcs[] = {
  677. + PIN(0, hdmi_tx0_bsc, hdmi_tx0_auto_i2c, bsc_m0, vc_i2c0, _, _, _, _),
  678. + PIN(1, hdmi_tx0_bsc, hdmi_tx0_auto_i2c, bsc_m0, vc_i2c0, _, _, _, _),
  679. + PIN(2, hdmi_tx1_bsc, hdmi_tx1_auto_i2c, bsc_m1, vc_i2c4, ctl_hdmi_5v, _, _, _),
  680. + PIN(3, hdmi_tx1_bsc, hdmi_tx1_auto_i2c, bsc_m1, vc_i2c4, _, _, _, _),
  681. + PIN(4, avs_pmu_bsc, bsc_m2, vc_i2c5, ctl_hdmi_5v, _, _, _, _),
  682. + PIN(5, avs_pmu_bsc, bsc_m2, vc_i2c5, _, _, _, _, _),
  683. +};
  684. +
  685. +static const struct bcm2712_pin_funcs bcm2712_c0_gpio_pin_funcs[] = {
  686. + PIN(0, bsc_m3, vc_i2c0, gpclk0, enet0, vc_pwm1, vc_spi0, ir_in, _),
  687. + PIN(1, bsc_m3, vc_i2c0, gpclk1, enet0, vc_pwm1, sr_edm_sense, vc_spi0, vc_uart3),
  688. + PIN(2, pdm, i2s_in, gpclk2, vc_spi4, pkt, vc_spi0, vc_uart3, _),
  689. + PIN(3, pdm, i2s_in, vc_spi4, pkt, vc_spi0, vc_uart3, _, _),
  690. + PIN(4, pdm, i2s_in, arm_jtag, vc_spi4, pkt, vc_spi0, vc_uart3, _),
  691. + PIN(5, pdm, vc_i2c3, arm_jtag, sd_card_e, vc_spi4, pkt, vc_pcm, vc_i2c5),
  692. + PIN(6, pdm, vc_i2c3, arm_jtag, sd_card_e, vc_spi4, pkt, vc_pcm, vc_i2c5),
  693. + PIN(7, i2s_out, spdif_out, arm_jtag, sd_card_e, vc_i2c3, enet0_rgmii, vc_pcm, vc_spi4),
  694. + PIN(8, i2s_out, aud_fs_clk0, arm_jtag, sd_card_e, vc_i2c3, enet0_mii, vc_pcm, vc_spi4),
  695. + PIN(9, i2s_out, aud_fs_clk0, arm_jtag, sd_card_e, enet0_mii, sd_card_c, vc_spi4, _),
  696. + PIN(10, bsc_m3, mtsif_alt1, i2s_in, i2s_out, vc_spi5, enet0_mii, sd_card_c, vc_spi4),
  697. + PIN(11, bsc_m3, mtsif_alt1, i2s_in, i2s_out, vc_spi5, enet0_mii, sd_card_c, vc_spi4),
  698. + PIN(12, spi_s, mtsif_alt1, i2s_in, i2s_out, vc_spi5, vc_i2csl, sd0, sd_card_d),
  699. + PIN(13, spi_s, mtsif_alt1, i2s_out, usb_vbus, vc_spi5, vc_i2csl, sd0, sd_card_d),
  700. + PIN(14, spi_s, vc_i2csl, enet0_rgmii, arm_jtag, vc_spi5, vc_pwm0, vc_i2c4, sd_card_d),
  701. + PIN(15, spi_s, vc_i2csl, vc_spi3, arm_jtag, vc_pwm0, vc_i2c4, gpclk0, _),
  702. + PIN(16, sd_card_b, i2s_out, vc_spi3, i2s_in, sd0, enet0_rgmii, gpclk1, _),
  703. + PIN(17, sd_card_b, i2s_out, vc_spi3, i2s_in, ext_sc_clk, sd0, enet0_rgmii, gpclk2),
  704. + PIN(18, sd_card_b, i2s_out, vc_spi3, i2s_in, sd0, enet0_rgmii, vc_pwm1, _),
  705. + PIN(19, sd_card_b, usb_pwr, vc_spi3, pkt, spdif_out, sd0, ir_in, vc_pwm1),
  706. + PIN(20, sd_card_b, uui, vc_uart0, arm_jtag, uart2, usb_pwr, vc_pcm, vc_uart4),
  707. + PIN(21, usb_pwr, uui, vc_uart0, arm_jtag, uart2, sd_card_b, vc_pcm, vc_uart4),
  708. + PIN(22, usb_pwr, enet0, vc_uart0, mtsif, uart2, usb_vbus, vc_pcm, vc_i2c5),
  709. + PIN(23, usb_vbus, enet0, vc_uart0, mtsif, uart2, i2s_out, vc_pcm, vc_i2c5),
  710. + PIN(24, mtsif, pkt, uart0, enet0_rgmii, enet0_rgmii, vc_i2c4, vc_uart3, _),
  711. + PIN(25, mtsif, pkt, sc0, uart0, enet0_rgmii, enet0_rgmii, vc_i2c4, vc_uart3),
  712. + PIN(26, mtsif, pkt, sc0, uart0, enet0_rgmii, vc_uart4, vc_spi5, _),
  713. + PIN(27, mtsif, pkt, sc0, uart0, enet0_rgmii, vc_uart4, vc_spi5, _),
  714. + PIN(28, mtsif, pkt, sc0, enet0_rgmii, vc_uart4, vc_spi5, _, _),
  715. + PIN(29, mtsif, pkt, sc0, enet0_rgmii, vc_uart4, vc_spi5, _, _),
  716. + PIN(30, mtsif, pkt, sc0, sd2, enet0_rgmii, gpclk0, vc_pwm0, _),
  717. + PIN(31, mtsif, pkt, sc0, sd2, enet0_rgmii, vc_spi3, vc_pwm0, _),
  718. + PIN(32, mtsif, pkt, sc0, sd2, enet0_rgmii, vc_spi3, vc_uart3, _),
  719. + PIN(33, mtsif, pkt, sd2, enet0_rgmii, vc_spi3, vc_uart3, _, _),
  720. + PIN(34, mtsif, pkt, ext_sc_clk, sd2, enet0_rgmii, vc_spi3, vc_i2c5, _),
  721. + PIN(35, mtsif, pkt, sd2, enet0_rgmii, vc_spi3, vc_i2c5, _, _),
  722. + PIN(36, sd0, mtsif, sc0, i2s_in, vc_uart3, vc_uart2, _, _),
  723. + PIN(37, sd0, mtsif, sc0, vc_spi0, i2s_in, vc_uart3, vc_uart2, _),
  724. + PIN(38, sd0, mtsif_alt, sc0, vc_spi0, i2s_in, vc_uart3, vc_uart2, _),
  725. + PIN(39, sd0, mtsif_alt, sc0, vc_spi0, vc_uart3, vc_uart2, _, _),
  726. + PIN(40, sd0, mtsif_alt, sc0, vc_spi0, bsc_m3, _, _, _),
  727. + PIN(41, sd0, mtsif_alt, sc0, vc_spi0, bsc_m3, _, _, _),
  728. + PIN(42, vc_spi0, mtsif_alt, vc_i2c0, sd_card_a, mtsif_alt1, arm_jtag, pdm, spi_m),
  729. + PIN(43, vc_spi0, mtsif_alt, vc_i2c0, sd_card_a, mtsif_alt1, arm_jtag, pdm, spi_m),
  730. + PIN(44, vc_spi0, mtsif_alt, enet0, sd_card_a, mtsif_alt1, arm_jtag, pdm, spi_m),
  731. + PIN(45, vc_spi0, mtsif_alt, enet0, sd_card_a, mtsif_alt1, arm_jtag, pdm, spi_m),
  732. + PIN(46, vc_spi0, mtsif_alt, sd_card_a, mtsif_alt1, arm_jtag, pdm, spi_m, _),
  733. + PIN(47, enet0, mtsif_alt, i2s_out, mtsif_alt1, arm_jtag, _, _, _),
  734. + PIN(48, sc0, usb_pwr, spdif_out, mtsif, _, _, _, _),
  735. + PIN(49, sc0, usb_pwr, aud_fs_clk0, mtsif, _, _, _, _),
  736. + PIN(50, sc0, usb_vbus, sc0, _, _, _, _, _),
  737. + PIN(51, sc0, enet0, sc0, sr_edm_sense, _, _, _, _),
  738. + PIN(52, sc0, enet0, vc_pwm1, _, _, _, _, _),
  739. + PIN(53, sc0, enet0_rgmii, ext_sc_clk, _, _, _, _, _),
  740. +};
  741. +
  742. +static const struct bcm2712_pin_funcs bcm2712_d0_aon_gpio_pin_funcs[] = {
  743. + PIN(0, ir_in, vc_spi0, vc_uart0, vc_i2c3, uart0, vc_i2c0, _, _),
  744. + PIN(1, vc_pwm0, vc_spi0, vc_uart0, vc_i2c3, uart0, aon_pwm, vc_i2c0, vc_pwm1),
  745. + PIN(2, vc_pwm0, vc_spi0, vc_uart0, ctl_hdmi_5v, uart0, aon_pwm, ir_in, vc_pwm1),
  746. + PIN(3, ir_in, vc_spi0, vc_uart0, uart0, sd_card_g, aon_gpclk, _, _),
  747. + PIN(4, gpclk0, vc_spi0, pm_led_out, aon_pwm, sd_card_g, vc_pwm0, _, _),
  748. + PIN(5, gpclk1, ir_in, aon_pwm, sd_card_g, vc_pwm0, _, _, _),
  749. + PIN(6, uart1, vc_uart2, ctl_hdmi_5v, gpclk2, vc_spi3, _, _, _),
  750. + PIN(7, _, _, _, _, _, _, _, _),
  751. + PIN(8, uart1, vc_uart2, ctl_hdmi_5v, vc_spi0, vc_spi3, _, _, _),
  752. + PIN(9, uart1, vc_uart2, vc_uart0, aon_pwm, vc_spi0, vc_uart2, vc_spi3, _),
  753. + PIN(10, _, _, _, _, _, _, _, _),
  754. + PIN(11, _, _, _, _, _, _, _, _),
  755. + PIN(12, uart1, vc_uart2, vc_uart0, vc_spi0, usb_pwr, vc_uart2, vc_spi3, _),
  756. + PIN(13, bsc_m1, vc_uart0, uui, vc_spi0, arm_jtag, vc_uart2, vc_i2c3, _),
  757. + PIN(14, bsc_m1, aon_gpclk, vc_uart0, uui, vc_spi0, arm_jtag, vc_uart2, vc_i2c3),
  758. +};
  759. +
  760. +static const struct bcm2712_pin_funcs bcm2712_d0_aon_sgpio_pin_funcs[] = {
  761. + PIN(0, hdmi_tx0_bsc, hdmi_tx0_auto_i2c, bsc_m0, vc_i2c0, _, _, _, _),
  762. + PIN(1, hdmi_tx0_bsc, hdmi_tx0_auto_i2c, bsc_m0, vc_i2c0, _, _, _, _),
  763. + PIN(2, hdmi_tx1_bsc, hdmi_tx1_auto_i2c, bsc_m1, vc_i2c0, ctl_hdmi_5v, _, _, _),
  764. + PIN(3, hdmi_tx1_bsc, hdmi_tx1_auto_i2c, bsc_m1, vc_i2c0, _, _, _, _),
  765. + PIN(4, avs_pmu_bsc, bsc_m2, vc_i2c3, ctl_hdmi_5v, _, _, _, _),
  766. + PIN(5, avs_pmu_bsc, bsc_m2, vc_i2c3, _, _, _, _, _),
  767. +};
  768. +
  769. +static const struct bcm2712_pin_funcs bcm2712_d0_gpio_pin_funcs[] = {
  770. + PIN(1, vc_i2c0, usb_pwr, gpclk0, sd_card_e, vc_spi3, sr_edm_sense, vc_spi0, vc_uart0),
  771. + PIN(2, vc_i2c0, usb_pwr, gpclk1, sd_card_e, vc_spi3, clk_observe, vc_spi0, vc_uart0),
  772. + PIN(3, vc_i2c3, usb_vbus, gpclk2, sd_card_e, vc_spi3, vc_spi0, vc_uart0, _),
  773. + PIN(4, vc_i2c3, vc_pwm1, vc_spi3, sd_card_e, vc_spi3, vc_spi0, vc_uart0, _),
  774. + PIN(10, bsc_m3, vc_pwm1, vc_spi3, sd_card_e, vc_spi3, gpclk0, _, _),
  775. + PIN(11, bsc_m3, vc_spi3, clk_observe, sd_card_c, gpclk1, _, _, _),
  776. + PIN(12, spi_s, vc_spi3, sd_card_c, sd_card_d, _, _, _, _),
  777. + PIN(13, spi_s, vc_spi3, sd_card_c, sd_card_d, _, _, _, _),
  778. + PIN(14, spi_s, uui, arm_jtag, vc_pwm0, vc_i2c0, sd_card_d, _, _),
  779. + PIN(15, spi_s, uui, arm_jtag, vc_pwm0, vc_i2c0, gpclk0, _, _),
  780. + PIN(18, sd_card_f, vc_pwm1, _, _, _, _, _, _),
  781. + PIN(19, sd_card_f, usb_pwr, vc_pwm1, _, _, _, _, _),
  782. + PIN(20, vc_i2c3, uui, vc_uart0, arm_jtag, vc_uart2, _, _, _),
  783. + PIN(21, vc_i2c3, uui, vc_uart0, arm_jtag, vc_uart2, _, _, _),
  784. + PIN(22, sd_card_f, vc_uart0, vc_i2c3, _, _, _, _, _),
  785. + PIN(23, vc_uart0, vc_i2c3, _, _, _, _, _, _),
  786. + PIN(24, sd_card_b, vc_spi0, arm_jtag, uart0, usb_pwr, vc_uart2, vc_uart0, _),
  787. + PIN(25, sd_card_b, vc_spi0, arm_jtag, uart0, usb_pwr, vc_uart2, vc_uart0, _),
  788. + PIN(26, sd_card_b, vc_spi0, arm_jtag, uart0, usb_vbus, vc_uart2, vc_spi0, _),
  789. + PIN(27, sd_card_b, vc_spi0, arm_jtag, uart0, vc_uart2, vc_spi0, _, _),
  790. + PIN(28, sd_card_b, vc_spi0, arm_jtag, vc_i2c0, vc_spi0, _, _, _),
  791. + PIN(29, arm_jtag, vc_i2c0, vc_spi0, _, _, _, _, _),
  792. + PIN(30, sd2, gpclk0, vc_pwm0, _, _, _, _, _),
  793. + PIN(31, sd2, vc_spi3, vc_pwm0, _, _, _, _, _),
  794. + PIN(32, sd2, vc_spi3, vc_uart3, _, _, _, _, _),
  795. + PIN(33, sd2, vc_spi3, vc_uart3, _, _, _, _, _),
  796. + PIN(34, sd2, vc_spi3, vc_i2c5, _, _, _, _, _),
  797. + PIN(35, sd2, vc_spi3, vc_i2c5, _, _, _, _, _),
  798. +};
  799. +
  800. +static inline u32 bcm2712_reg_rd(struct bcm2712_pinctrl *pc, unsigned reg)
  801. +{
  802. + return readl(pc->base + reg);
  803. +}
  804. +
  805. +static inline void bcm2712_reg_wr(struct bcm2712_pinctrl *pc, unsigned reg,
  806. + u32 val)
  807. +{
  808. + writel(val, pc->base + reg);
  809. +}
  810. +
  811. +static enum bcm2712_funcs bcm2712_pinctrl_fsel_get(
  812. + struct bcm2712_pinctrl *pc, unsigned pin)
  813. +{
  814. + u32 bit = pc->pin_regs[pin].mux_bit;
  815. + enum bcm2712_funcs func;
  816. + int fsel;
  817. + u32 val;
  818. +
  819. + if (!bit)
  820. + return func_gpio;
  821. +
  822. + val = bcm2712_reg_rd(pc, BIT_TO_REG(bit));
  823. + fsel = (val >> BIT_TO_SHIFT(bit)) & BCM2712_FSEL_MASK;
  824. + func = pc->pin_funcs[pin].funcs[fsel];
  825. + if (func >= func_count)
  826. + func = (enum bcm2712_funcs)fsel;
  827. +
  828. + dev_dbg(pc->dev, "get %04x: %08x (%u => %s)\n",
  829. + BIT_TO_REG(bit), val, pin,
  830. + bcm2712_func_names[func]);
  831. +
  832. + return func;
  833. +}
  834. +
  835. +static void bcm2712_pinctrl_fsel_set(
  836. + struct bcm2712_pinctrl *pc, unsigned pin,
  837. + enum bcm2712_funcs func)
  838. +{
  839. + u32 bit = pc->pin_regs[pin].mux_bit, val;
  840. + const u8 *pin_funcs;
  841. + unsigned long flags;
  842. + int fsel;
  843. + int cur;
  844. + int i;
  845. +
  846. + if (!bit || func >= func_count)
  847. + return;
  848. +
  849. + fsel = BCM2712_FSEL_COUNT;
  850. +
  851. + if (func >= BCM2712_FSEL_COUNT) {
  852. + /* Convert to an fsel number */
  853. + pin_funcs = pc->pin_funcs[pin].funcs;
  854. + for (i = 1; i < BCM2712_FSEL_COUNT; i++) {
  855. + if (pin_funcs[i - 1] == func) {
  856. + fsel = i;
  857. + break;
  858. + }
  859. + }
  860. + } else {
  861. + fsel = (enum bcm2712_funcs)func;
  862. + }
  863. + if (fsel >= BCM2712_FSEL_COUNT)
  864. + return;
  865. +
  866. + spin_lock_irqsave(&pc->lock, flags);
  867. +
  868. + val = bcm2712_reg_rd(pc, BIT_TO_REG(bit));
  869. + cur = (val >> BIT_TO_SHIFT(bit)) & BCM2712_FSEL_MASK;
  870. +
  871. + dev_dbg(pc->dev, "read %04x: %08x (%u => %s)\n",
  872. + BIT_TO_REG(bit), val, pin,
  873. + bcm2712_func_names[cur]);
  874. +
  875. + if (cur != fsel) {
  876. + val &= ~(BCM2712_FSEL_MASK << BIT_TO_SHIFT(bit));
  877. + val |= fsel << BIT_TO_SHIFT(bit);
  878. +
  879. + dev_dbg(pc->dev, "write %04x: %08x (%u <= %s)\n",
  880. + BIT_TO_REG(bit), val, pin,
  881. + bcm2712_func_names[fsel]);
  882. + bcm2712_reg_wr(pc, BIT_TO_REG(bit), val);
  883. + }
  884. +
  885. + spin_unlock_irqrestore(&pc->lock, flags);
  886. +}
  887. +
  888. +static int bcm2712_pctl_get_groups_count(struct pinctrl_dev *pctldev)
  889. +{
  890. + struct bcm2712_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev);
  891. +
  892. + return pc->pctl_desc.npins;
  893. +}
  894. +
  895. +static const char *bcm2712_pctl_get_group_name(struct pinctrl_dev *pctldev,
  896. + unsigned selector)
  897. +{
  898. + struct bcm2712_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev);
  899. +
  900. + return pc->gpio_groups[selector];
  901. +}
  902. +
  903. +static int bcm2712_pctl_get_group_pins(struct pinctrl_dev *pctldev,
  904. + unsigned selector,
  905. + const unsigned **pins,
  906. + unsigned *num_pins)
  907. +{
  908. + struct bcm2712_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev);
  909. +
  910. + *pins = &pc->pctl_desc.pins[selector].number;
  911. + *num_pins = 1;
  912. +
  913. + return 0;
  914. +}
  915. +
  916. +static void bcm2712_pctl_pin_dbg_show(struct pinctrl_dev *pctldev,
  917. + struct seq_file *s,
  918. + unsigned offset)
  919. +{
  920. + struct bcm2712_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev);
  921. + enum bcm2712_funcs fsel = bcm2712_pinctrl_fsel_get(pc, offset);
  922. + const char *fname = bcm2712_func_names[fsel];
  923. +
  924. + seq_printf(s, "function %s", fname);
  925. +}
  926. +
  927. +static void bcm2712_pctl_dt_free_map(struct pinctrl_dev *pctldev,
  928. + struct pinctrl_map *maps, unsigned num_maps)
  929. +{
  930. + int i;
  931. +
  932. + for (i = 0; i < num_maps; i++)
  933. + if (maps[i].type == PIN_MAP_TYPE_CONFIGS_PIN)
  934. + kfree(maps[i].data.configs.configs);
  935. +
  936. + kfree(maps);
  937. +}
  938. +
  939. +static const struct pinctrl_ops bcm2712_pctl_ops = {
  940. + .get_groups_count = bcm2712_pctl_get_groups_count,
  941. + .get_group_name = bcm2712_pctl_get_group_name,
  942. + .get_group_pins = bcm2712_pctl_get_group_pins,
  943. + .pin_dbg_show = bcm2712_pctl_pin_dbg_show,
  944. + .dt_node_to_map = pinconf_generic_dt_node_to_map_all,
  945. + .dt_free_map = bcm2712_pctl_dt_free_map,
  946. +};
  947. +
  948. +static int bcm2712_pmx_free(struct pinctrl_dev *pctldev,
  949. + unsigned offset)
  950. +{
  951. + struct bcm2712_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev);
  952. +
  953. + /* disable by setting to GPIO */
  954. + bcm2712_pinctrl_fsel_set(pc, offset, func_gpio);
  955. + return 0;
  956. +}
  957. +
  958. +static int bcm2712_pmx_get_functions_count(struct pinctrl_dev *pctldev)
  959. +{
  960. + return func_count;
  961. +}
  962. +
  963. +static const char *bcm2712_pmx_get_function_name(struct pinctrl_dev *pctldev,
  964. + unsigned selector)
  965. +{
  966. + return (selector < func_count) ? bcm2712_func_names[selector] : NULL;
  967. +}
  968. +
  969. +static int bcm2712_pmx_get_function_groups(struct pinctrl_dev *pctldev,
  970. + unsigned selector,
  971. + const char * const **groups,
  972. + unsigned * const num_groups)
  973. +{
  974. + struct bcm2712_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev);
  975. + /* every pin can do every function */
  976. + *groups = pc->gpio_groups;
  977. + *num_groups = pc->pctl_desc.npins;
  978. +
  979. + return 0;
  980. +}
  981. +
  982. +static int bcm2712_pmx_set(struct pinctrl_dev *pctldev,
  983. + unsigned func_selector,
  984. + unsigned group_selector)
  985. +{
  986. + struct bcm2712_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev);
  987. +
  988. + bcm2712_pinctrl_fsel_set(pc, group_selector, func_selector);
  989. +
  990. + return 0;
  991. +}
  992. +static int bcm2712_pmx_gpio_request_enable(struct pinctrl_dev *pctldev,
  993. + struct pinctrl_gpio_range *range,
  994. + unsigned pin)
  995. +{
  996. + struct bcm2712_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev);
  997. +
  998. + bcm2712_pinctrl_fsel_set(pc, pin, func_gpio);
  999. +
  1000. + return 0;
  1001. +}
  1002. +
  1003. +static void bcm2712_pmx_gpio_disable_free(struct pinctrl_dev *pctldev,
  1004. + struct pinctrl_gpio_range *range,
  1005. + unsigned offset)
  1006. +{
  1007. + struct bcm2712_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev);
  1008. +
  1009. + /* disable by setting to GPIO */
  1010. + bcm2712_pinctrl_fsel_set(pc, offset, func_gpio);
  1011. +}
  1012. +
  1013. +static const struct pinmux_ops bcm2712_pmx_ops = {
  1014. + .free = bcm2712_pmx_free,
  1015. + .get_functions_count = bcm2712_pmx_get_functions_count,
  1016. + .get_function_name = bcm2712_pmx_get_function_name,
  1017. + .get_function_groups = bcm2712_pmx_get_function_groups,
  1018. + .set_mux = bcm2712_pmx_set,
  1019. + .gpio_request_enable = bcm2712_pmx_gpio_request_enable,
  1020. + .gpio_disable_free = bcm2712_pmx_gpio_disable_free,
  1021. +};
  1022. +
  1023. +static unsigned int bcm2712_pull_config_get(struct bcm2712_pinctrl *pc,
  1024. + unsigned int pin)
  1025. +{
  1026. + u32 bit = pc->pin_regs[pin].pad_bit, val;
  1027. +
  1028. + if (unlikely(bit == REG_BIT_INVALID))
  1029. + return BCM2712_PULL_NONE;
  1030. +
  1031. + val = bcm2712_reg_rd(pc, BIT_TO_REG(bit));
  1032. + return (val >> BIT_TO_SHIFT(bit)) & BCM2712_PULL_MASK;
  1033. +}
  1034. +
  1035. +static void bcm2712_pull_config_set(struct bcm2712_pinctrl *pc,
  1036. + unsigned int pin, unsigned int arg)
  1037. +{
  1038. + u32 bit = pc->pin_regs[pin].pad_bit, val;
  1039. + unsigned long flags;
  1040. +
  1041. + if (unlikely(bit == REG_BIT_INVALID)) {
  1042. + dev_warn(pc->dev, "can't set pulls for %s\n", pc->gpio_groups[pin]);
  1043. + return;
  1044. + }
  1045. +
  1046. + spin_lock_irqsave(&pc->lock, flags);
  1047. +
  1048. + val = bcm2712_reg_rd(pc, BIT_TO_REG(bit));
  1049. + val &= ~(BCM2712_PULL_MASK << BIT_TO_SHIFT(bit));
  1050. + val |= (arg << BIT_TO_SHIFT(bit));
  1051. + bcm2712_reg_wr(pc, BIT_TO_REG(bit), val);
  1052. +
  1053. + spin_unlock_irqrestore(&pc->lock, flags);
  1054. +}
  1055. +
  1056. +static int bcm2712_pinconf_get(struct pinctrl_dev *pctldev,
  1057. + unsigned pin, unsigned long *config)
  1058. +{
  1059. + struct bcm2712_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev);
  1060. + enum pin_config_param param = pinconf_to_config_param(*config);
  1061. + u32 arg;
  1062. +
  1063. + switch (param) {
  1064. + case PIN_CONFIG_BIAS_DISABLE:
  1065. + arg = (bcm2712_pull_config_get(pc, pin) == BCM2712_PULL_NONE);
  1066. + break;
  1067. + case PIN_CONFIG_BIAS_PULL_DOWN:
  1068. + arg = (bcm2712_pull_config_get(pc, pin) == BCM2712_PULL_DOWN);
  1069. + break;
  1070. + case PIN_CONFIG_BIAS_PULL_UP:
  1071. + arg = (bcm2712_pull_config_get(pc, pin) == BCM2712_PULL_UP);
  1072. + break;
  1073. + default:
  1074. + return -ENOTSUPP;
  1075. + }
  1076. +
  1077. + *config = pinconf_to_config_packed(param, arg);
  1078. +
  1079. + return -ENOTSUPP;
  1080. +}
  1081. +
  1082. +static int bcm2712_pinconf_set(struct pinctrl_dev *pctldev,
  1083. + unsigned int pin, unsigned long *configs,
  1084. + unsigned int num_configs)
  1085. +{
  1086. + struct bcm2712_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev);
  1087. + u32 param, arg;
  1088. + int i;
  1089. +
  1090. + for (i = 0; i < num_configs; i++) {
  1091. + param = pinconf_to_config_param(configs[i]);
  1092. + arg = pinconf_to_config_argument(configs[i]);
  1093. +
  1094. + switch (param) {
  1095. + case PIN_CONFIG_BIAS_DISABLE:
  1096. + bcm2712_pull_config_set(pc, pin, BCM2712_PULL_NONE);
  1097. + break;
  1098. + case PIN_CONFIG_BIAS_PULL_DOWN:
  1099. + bcm2712_pull_config_set(pc, pin, BCM2712_PULL_DOWN);
  1100. + break;
  1101. + case PIN_CONFIG_BIAS_PULL_UP:
  1102. + bcm2712_pull_config_set(pc, pin, BCM2712_PULL_UP);
  1103. + break;
  1104. + default:
  1105. + return -ENOTSUPP;
  1106. + }
  1107. + } /* for each config */
  1108. +
  1109. + return 0;
  1110. +}
  1111. +
  1112. +static const struct pinconf_ops bcm2712_pinconf_ops = {
  1113. + .is_generic = true,
  1114. + .pin_config_get = bcm2712_pinconf_get,
  1115. + .pin_config_set = bcm2712_pinconf_set,
  1116. +};
  1117. +
  1118. +static const struct pinctrl_desc bcm2712_c0_pinctrl_desc = {
  1119. + .name = "pinctrl-bcm2712",
  1120. + .pins = bcm2712_c0_gpio_pins,
  1121. + .npins = ARRAY_SIZE(bcm2712_c0_gpio_pins),
  1122. + .pctlops = &bcm2712_pctl_ops,
  1123. + .pmxops = &bcm2712_pmx_ops,
  1124. + .confops = &bcm2712_pinconf_ops,
  1125. + .owner = THIS_MODULE,
  1126. +};
  1127. +
  1128. +static const struct pinctrl_desc bcm2712_c0_aon_pinctrl_desc = {
  1129. + .name = "aon-pinctrl-bcm2712",
  1130. + .pins = bcm2712_c0_aon_gpio_pins,
  1131. + .npins = ARRAY_SIZE(bcm2712_c0_aon_gpio_pins),
  1132. + .pctlops = &bcm2712_pctl_ops,
  1133. + .pmxops = &bcm2712_pmx_ops,
  1134. + .confops = &bcm2712_pinconf_ops,
  1135. + .owner = THIS_MODULE,
  1136. +};
  1137. +
  1138. +static const struct pinctrl_desc bcm2712_d0_pinctrl_desc = {
  1139. + .name = "pinctrl-bcm2712",
  1140. + .pins = bcm2712_d0_gpio_pins,
  1141. + .npins = ARRAY_SIZE(bcm2712_d0_gpio_pins),
  1142. + .pctlops = &bcm2712_pctl_ops,
  1143. + .pmxops = &bcm2712_pmx_ops,
  1144. + .confops = &bcm2712_pinconf_ops,
  1145. + .owner = THIS_MODULE,
  1146. +};
  1147. +
  1148. +static const struct pinctrl_desc bcm2712_d0_aon_pinctrl_desc = {
  1149. + .name = "aon-pinctrl-bcm2712",
  1150. + .pins = bcm2712_d0_aon_gpio_pins,
  1151. + .npins = ARRAY_SIZE(bcm2712_d0_aon_gpio_pins),
  1152. + .pctlops = &bcm2712_pctl_ops,
  1153. + .pmxops = &bcm2712_pmx_ops,
  1154. + .confops = &bcm2712_pinconf_ops,
  1155. + .owner = THIS_MODULE,
  1156. +};
  1157. +
  1158. +static const struct pinctrl_gpio_range bcm2712_c0_pinctrl_gpio_range = {
  1159. + .name = "pinctrl-bcm2712",
  1160. + .npins = ARRAY_SIZE(bcm2712_c0_gpio_pins),
  1161. +};
  1162. +
  1163. +static const struct pinctrl_gpio_range bcm2712_c0_aon_pinctrl_gpio_range = {
  1164. + .name = "aon-pinctrl-bcm2712",
  1165. + .npins = ARRAY_SIZE(bcm2712_c0_aon_gpio_pins),
  1166. +};
  1167. +
  1168. +static const struct pinctrl_gpio_range bcm2712_d0_pinctrl_gpio_range = {
  1169. + .name = "pinctrl-bcm2712",
  1170. + .npins = ARRAY_SIZE(bcm2712_d0_gpio_pins),
  1171. +};
  1172. +
  1173. +static const struct pinctrl_gpio_range bcm2712_d0_aon_pinctrl_gpio_range = {
  1174. + .name = "aon-pinctrl-bcm2712",
  1175. + .npins = ARRAY_SIZE(bcm2712_d0_aon_gpio_pins),
  1176. +};
  1177. +
  1178. +static const struct bcm_plat_data bcm2712_c0_plat_data = {
  1179. + .pctl_desc = &bcm2712_c0_pinctrl_desc,
  1180. + .gpio_range = &bcm2712_c0_pinctrl_gpio_range,
  1181. + .pin_regs = bcm2712_c0_gpio_pin_regs,
  1182. + .pin_funcs = bcm2712_c0_gpio_pin_funcs,
  1183. +};
  1184. +
  1185. +static const struct bcm_plat_data bcm2712_c0_aon_plat_data = {
  1186. + .pctl_desc = &bcm2712_c0_aon_pinctrl_desc,
  1187. + .gpio_range = &bcm2712_c0_aon_pinctrl_gpio_range,
  1188. + .pin_regs = bcm2712_c0_aon_gpio_pin_regs,
  1189. + .pin_funcs = bcm2712_c0_aon_gpio_pin_funcs,
  1190. +};
  1191. +
  1192. +static const struct bcm_plat_data bcm2712_d0_plat_data = {
  1193. + .pctl_desc = &bcm2712_d0_pinctrl_desc,
  1194. + .gpio_range = &bcm2712_d0_pinctrl_gpio_range,
  1195. + .pin_regs = bcm2712_d0_gpio_pin_regs,
  1196. + .pin_funcs = bcm2712_d0_gpio_pin_funcs,
  1197. +};
  1198. +
  1199. +static const struct bcm_plat_data bcm2712_d0_aon_plat_data = {
  1200. + .pctl_desc = &bcm2712_d0_aon_pinctrl_desc,
  1201. + .gpio_range = &bcm2712_d0_aon_pinctrl_gpio_range,
  1202. + .pin_regs = bcm2712_d0_aon_gpio_pin_regs,
  1203. + .pin_funcs = bcm2712_d0_aon_gpio_pin_funcs,
  1204. +};
  1205. +
  1206. +static const struct of_device_id bcm2712_pinctrl_match[] = {
  1207. + {
  1208. + .compatible = "brcm,bcm2712-pinctrl",
  1209. + .data = &bcm2712_c0_plat_data,
  1210. + },
  1211. + {
  1212. + .compatible = "brcm,bcm2712-aon-pinctrl",
  1213. + .data = &bcm2712_c0_aon_plat_data,
  1214. + },
  1215. +
  1216. + {
  1217. + .compatible = "brcm,bcm2712c0-pinctrl",
  1218. + .data = &bcm2712_c0_plat_data,
  1219. + },
  1220. + {
  1221. + .compatible = "brcm,bcm2712c0-aon-pinctrl",
  1222. + .data = &bcm2712_c0_aon_plat_data,
  1223. + },
  1224. +
  1225. + {
  1226. + .compatible = "brcm,bcm2712d0-pinctrl",
  1227. + .data = &bcm2712_d0_plat_data,
  1228. + },
  1229. + {
  1230. + .compatible = "brcm,bcm2712d0-aon-pinctrl",
  1231. + .data = &bcm2712_d0_aon_plat_data,
  1232. + },
  1233. + {}
  1234. +};
  1235. +
  1236. +static int bcm2712_pinctrl_probe(struct platform_device *pdev)
  1237. +{
  1238. + struct device *dev = &pdev->dev;
  1239. + struct device_node *np = dev->of_node;
  1240. + const struct bcm_plat_data *pdata;
  1241. + const struct of_device_id *match;
  1242. + struct bcm2712_pinctrl *pc;
  1243. + const char **names;
  1244. + int num_pins, i;
  1245. +
  1246. + match = of_match_node(bcm2712_pinctrl_match, np);
  1247. + if (!match)
  1248. + return -EINVAL;
  1249. + pdata = match->data;
  1250. +
  1251. + pc = devm_kzalloc(dev, sizeof(*pc), GFP_KERNEL);
  1252. + if (!pc)
  1253. + return -ENOMEM;
  1254. +
  1255. + platform_set_drvdata(pdev, pc);
  1256. + pc->dev = dev;
  1257. + spin_lock_init(&pc->lock);
  1258. +
  1259. + pc->base = devm_of_iomap(dev, np, 0, NULL);
  1260. + if (IS_ERR(pc->base)) {
  1261. + dev_err(dev, "could not get IO memory\n");
  1262. + return PTR_ERR(pc->base);
  1263. + }
  1264. +
  1265. + pc->pctl_desc = *pdata->pctl_desc;
  1266. + num_pins = pc->pctl_desc.npins;
  1267. + names = devm_kmalloc_array(dev, num_pins, sizeof(const char *),
  1268. + GFP_KERNEL);
  1269. + if (!names)
  1270. + return -ENOMEM;
  1271. + for (i = 0; i < num_pins; i++)
  1272. + names[i] = pc->pctl_desc.pins[i].name;
  1273. + pc->gpio_groups = names;
  1274. + pc->pin_regs = pdata->pin_regs;
  1275. + pc->pin_funcs = pdata->pin_funcs;
  1276. + pc->pctl_dev = devm_pinctrl_register(dev, &pc->pctl_desc, pc);
  1277. + if (IS_ERR(pc->pctl_dev))
  1278. + return PTR_ERR(pc->pctl_dev);
  1279. +
  1280. + pc->gpio_range = *pdata->gpio_range;
  1281. + pinctrl_add_gpio_range(pc->pctl_dev, &pc->gpio_range);
  1282. +
  1283. + return 0;
  1284. +}
  1285. +
  1286. +static struct platform_driver bcm2712_pinctrl_driver = {
  1287. + .probe = bcm2712_pinctrl_probe,
  1288. + .driver = {
  1289. + .name = MODULE_NAME,
  1290. + .of_match_table = bcm2712_pinctrl_match,
  1291. + .suppress_bind_attrs = true,
  1292. + },
  1293. +};
  1294. +builtin_platform_driver(bcm2712_pinctrl_driver);