pinctrl-ocelot.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  1. // SPDX-License-Identifier: (GPL-2.0 OR MIT)
  2. /*
  3. * Microsemi SoCs pinctrl driver
  4. *
  5. * Author: <alexandre.belloni@free-electrons.com>
  6. * License: Dual MIT/GPL
  7. * Copyright (c) 2017 Microsemi Corporation
  8. */
  9. #include <linux/gpio/driver.h>
  10. #include <linux/interrupt.h>
  11. #include <linux/io.h>
  12. #include <linux/of_device.h>
  13. #include <linux/of_irq.h>
  14. #include <linux/of_platform.h>
  15. #include <linux/pinctrl/pinctrl.h>
  16. #include <linux/pinctrl/pinmux.h>
  17. #include <linux/pinctrl/pinconf.h>
  18. #include <linux/pinctrl/pinconf-generic.h>
  19. #include <linux/platform_device.h>
  20. #include <linux/regmap.h>
  21. #include <linux/slab.h>
  22. #include "core.h"
  23. #include "pinconf.h"
  24. #include "pinmux.h"
  25. #define OCELOT_GPIO_OUT_SET 0x0
  26. #define OCELOT_GPIO_OUT_CLR 0x4
  27. #define OCELOT_GPIO_OUT 0x8
  28. #define OCELOT_GPIO_IN 0xc
  29. #define OCELOT_GPIO_OE 0x10
  30. #define OCELOT_GPIO_INTR 0x14
  31. #define OCELOT_GPIO_INTR_ENA 0x18
  32. #define OCELOT_GPIO_INTR_IDENT 0x1c
  33. #define OCELOT_GPIO_ALT0 0x20
  34. #define OCELOT_GPIO_ALT1 0x24
  35. #define OCELOT_GPIO_SD_MAP 0x28
  36. #define OCELOT_PINS 22
  37. #define OCELOT_FUNC_PER_PIN 4
  38. enum {
  39. FUNC_NONE,
  40. FUNC_GPIO,
  41. FUNC_IRQ0_IN,
  42. FUNC_IRQ0_OUT,
  43. FUNC_IRQ1_IN,
  44. FUNC_IRQ1_OUT,
  45. FUNC_MIIM1,
  46. FUNC_PCI_WAKE,
  47. FUNC_PTP0,
  48. FUNC_PTP1,
  49. FUNC_PTP2,
  50. FUNC_PTP3,
  51. FUNC_PWM,
  52. FUNC_RECO_CLK0,
  53. FUNC_RECO_CLK1,
  54. FUNC_SFP0,
  55. FUNC_SFP1,
  56. FUNC_SFP2,
  57. FUNC_SFP3,
  58. FUNC_SFP4,
  59. FUNC_SFP5,
  60. FUNC_SG0,
  61. FUNC_SI,
  62. FUNC_TACHO,
  63. FUNC_TWI,
  64. FUNC_TWI_SCL_M,
  65. FUNC_UART,
  66. FUNC_UART2,
  67. FUNC_MAX
  68. };
  69. static const char *const ocelot_function_names[] = {
  70. [FUNC_NONE] = "none",
  71. [FUNC_GPIO] = "gpio",
  72. [FUNC_IRQ0_IN] = "irq0_in",
  73. [FUNC_IRQ0_OUT] = "irq0_out",
  74. [FUNC_IRQ1_IN] = "irq1_in",
  75. [FUNC_IRQ1_OUT] = "irq1_out",
  76. [FUNC_MIIM1] = "miim1",
  77. [FUNC_PCI_WAKE] = "pci_wake",
  78. [FUNC_PTP0] = "ptp0",
  79. [FUNC_PTP1] = "ptp1",
  80. [FUNC_PTP2] = "ptp2",
  81. [FUNC_PTP3] = "ptp3",
  82. [FUNC_PWM] = "pwm",
  83. [FUNC_RECO_CLK0] = "reco_clk0",
  84. [FUNC_RECO_CLK1] = "reco_clk1",
  85. [FUNC_SFP0] = "sfp0",
  86. [FUNC_SFP1] = "sfp1",
  87. [FUNC_SFP2] = "sfp2",
  88. [FUNC_SFP3] = "sfp3",
  89. [FUNC_SFP4] = "sfp4",
  90. [FUNC_SFP5] = "sfp5",
  91. [FUNC_SG0] = "sg0",
  92. [FUNC_SI] = "si",
  93. [FUNC_TACHO] = "tacho",
  94. [FUNC_TWI] = "twi",
  95. [FUNC_TWI_SCL_M] = "twi_scl_m",
  96. [FUNC_UART] = "uart",
  97. [FUNC_UART2] = "uart2",
  98. };
  99. struct ocelot_pmx_func {
  100. const char **groups;
  101. unsigned int ngroups;
  102. };
  103. struct ocelot_pin_caps {
  104. unsigned int pin;
  105. unsigned char functions[OCELOT_FUNC_PER_PIN];
  106. };
  107. struct ocelot_pinctrl {
  108. struct device *dev;
  109. struct pinctrl_dev *pctl;
  110. struct gpio_chip gpio_chip;
  111. struct regmap *map;
  112. struct ocelot_pmx_func func[FUNC_MAX];
  113. };
  114. #define OCELOT_P(p, f0, f1, f2) \
  115. static struct ocelot_pin_caps ocelot_pin_##p = { \
  116. .pin = p, \
  117. .functions = { \
  118. FUNC_GPIO, FUNC_##f0, FUNC_##f1, FUNC_##f2, \
  119. }, \
  120. }
  121. OCELOT_P(0, SG0, NONE, NONE);
  122. OCELOT_P(1, SG0, NONE, NONE);
  123. OCELOT_P(2, SG0, NONE, NONE);
  124. OCELOT_P(3, SG0, NONE, NONE);
  125. OCELOT_P(4, IRQ0_IN, IRQ0_OUT, TWI_SCL_M);
  126. OCELOT_P(5, IRQ1_IN, IRQ1_OUT, PCI_WAKE);
  127. OCELOT_P(6, UART, TWI_SCL_M, NONE);
  128. OCELOT_P(7, UART, TWI_SCL_M, NONE);
  129. OCELOT_P(8, SI, TWI_SCL_M, IRQ0_OUT);
  130. OCELOT_P(9, SI, TWI_SCL_M, IRQ1_OUT);
  131. OCELOT_P(10, PTP2, TWI_SCL_M, SFP0);
  132. OCELOT_P(11, PTP3, TWI_SCL_M, SFP1);
  133. OCELOT_P(12, UART2, TWI_SCL_M, SFP2);
  134. OCELOT_P(13, UART2, TWI_SCL_M, SFP3);
  135. OCELOT_P(14, MIIM1, TWI_SCL_M, SFP4);
  136. OCELOT_P(15, MIIM1, TWI_SCL_M, SFP5);
  137. OCELOT_P(16, TWI, NONE, SI);
  138. OCELOT_P(17, TWI, TWI_SCL_M, SI);
  139. OCELOT_P(18, PTP0, TWI_SCL_M, NONE);
  140. OCELOT_P(19, PTP1, TWI_SCL_M, NONE);
  141. OCELOT_P(20, RECO_CLK0, TACHO, NONE);
  142. OCELOT_P(21, RECO_CLK1, PWM, NONE);
  143. #define OCELOT_PIN(n) { \
  144. .number = n, \
  145. .name = "GPIO_"#n, \
  146. .drv_data = &ocelot_pin_##n \
  147. }
  148. static const struct pinctrl_pin_desc ocelot_pins[] = {
  149. OCELOT_PIN(0),
  150. OCELOT_PIN(1),
  151. OCELOT_PIN(2),
  152. OCELOT_PIN(3),
  153. OCELOT_PIN(4),
  154. OCELOT_PIN(5),
  155. OCELOT_PIN(6),
  156. OCELOT_PIN(7),
  157. OCELOT_PIN(8),
  158. OCELOT_PIN(9),
  159. OCELOT_PIN(10),
  160. OCELOT_PIN(11),
  161. OCELOT_PIN(12),
  162. OCELOT_PIN(13),
  163. OCELOT_PIN(14),
  164. OCELOT_PIN(15),
  165. OCELOT_PIN(16),
  166. OCELOT_PIN(17),
  167. OCELOT_PIN(18),
  168. OCELOT_PIN(19),
  169. OCELOT_PIN(20),
  170. OCELOT_PIN(21),
  171. };
  172. static int ocelot_get_functions_count(struct pinctrl_dev *pctldev)
  173. {
  174. return ARRAY_SIZE(ocelot_function_names);
  175. }
  176. static const char *ocelot_get_function_name(struct pinctrl_dev *pctldev,
  177. unsigned int function)
  178. {
  179. return ocelot_function_names[function];
  180. }
  181. static int ocelot_get_function_groups(struct pinctrl_dev *pctldev,
  182. unsigned int function,
  183. const char *const **groups,
  184. unsigned *const num_groups)
  185. {
  186. struct ocelot_pinctrl *info = pinctrl_dev_get_drvdata(pctldev);
  187. *groups = info->func[function].groups;
  188. *num_groups = info->func[function].ngroups;
  189. return 0;
  190. }
  191. static int ocelot_pin_function_idx(unsigned int pin, unsigned int function)
  192. {
  193. struct ocelot_pin_caps *p = ocelot_pins[pin].drv_data;
  194. int i;
  195. for (i = 0; i < OCELOT_FUNC_PER_PIN; i++) {
  196. if (function == p->functions[i])
  197. return i;
  198. }
  199. return -1;
  200. }
  201. static int ocelot_pinmux_set_mux(struct pinctrl_dev *pctldev,
  202. unsigned int selector, unsigned int group)
  203. {
  204. struct ocelot_pinctrl *info = pinctrl_dev_get_drvdata(pctldev);
  205. struct ocelot_pin_caps *pin = ocelot_pins[group].drv_data;
  206. int f;
  207. f = ocelot_pin_function_idx(group, selector);
  208. if (f < 0)
  209. return -EINVAL;
  210. /*
  211. * f is encoded on two bits.
  212. * bit 0 of f goes in BIT(pin) of ALT0, bit 1 of f goes in BIT(pin) of
  213. * ALT1
  214. * This is racy because both registers can't be updated at the same time
  215. * but it doesn't matter much for now.
  216. */
  217. regmap_update_bits(info->map, OCELOT_GPIO_ALT0, BIT(pin->pin),
  218. f << pin->pin);
  219. regmap_update_bits(info->map, OCELOT_GPIO_ALT1, BIT(pin->pin),
  220. f << (pin->pin - 1));
  221. return 0;
  222. }
  223. static int ocelot_gpio_set_direction(struct pinctrl_dev *pctldev,
  224. struct pinctrl_gpio_range *range,
  225. unsigned int pin, bool input)
  226. {
  227. struct ocelot_pinctrl *info = pinctrl_dev_get_drvdata(pctldev);
  228. regmap_update_bits(info->map, OCELOT_GPIO_OE, BIT(pin),
  229. input ? 0 : BIT(pin));
  230. return 0;
  231. }
  232. static int ocelot_gpio_request_enable(struct pinctrl_dev *pctldev,
  233. struct pinctrl_gpio_range *range,
  234. unsigned int offset)
  235. {
  236. struct ocelot_pinctrl *info = pinctrl_dev_get_drvdata(pctldev);
  237. regmap_update_bits(info->map, OCELOT_GPIO_ALT0, BIT(offset), 0);
  238. regmap_update_bits(info->map, OCELOT_GPIO_ALT1, BIT(offset), 0);
  239. return 0;
  240. }
  241. static const struct pinmux_ops ocelot_pmx_ops = {
  242. .get_functions_count = ocelot_get_functions_count,
  243. .get_function_name = ocelot_get_function_name,
  244. .get_function_groups = ocelot_get_function_groups,
  245. .set_mux = ocelot_pinmux_set_mux,
  246. .gpio_set_direction = ocelot_gpio_set_direction,
  247. .gpio_request_enable = ocelot_gpio_request_enable,
  248. };
  249. static int ocelot_pctl_get_groups_count(struct pinctrl_dev *pctldev)
  250. {
  251. return ARRAY_SIZE(ocelot_pins);
  252. }
  253. static const char *ocelot_pctl_get_group_name(struct pinctrl_dev *pctldev,
  254. unsigned int group)
  255. {
  256. return ocelot_pins[group].name;
  257. }
  258. static int ocelot_pctl_get_group_pins(struct pinctrl_dev *pctldev,
  259. unsigned int group,
  260. const unsigned int **pins,
  261. unsigned int *num_pins)
  262. {
  263. *pins = &ocelot_pins[group].number;
  264. *num_pins = 1;
  265. return 0;
  266. }
  267. static const struct pinctrl_ops ocelot_pctl_ops = {
  268. .get_groups_count = ocelot_pctl_get_groups_count,
  269. .get_group_name = ocelot_pctl_get_group_name,
  270. .get_group_pins = ocelot_pctl_get_group_pins,
  271. .dt_node_to_map = pinconf_generic_dt_node_to_map_pin,
  272. .dt_free_map = pinconf_generic_dt_free_map,
  273. };
  274. static struct pinctrl_desc ocelot_desc = {
  275. .name = "ocelot-pinctrl",
  276. .pins = ocelot_pins,
  277. .npins = ARRAY_SIZE(ocelot_pins),
  278. .pctlops = &ocelot_pctl_ops,
  279. .pmxops = &ocelot_pmx_ops,
  280. .owner = THIS_MODULE,
  281. };
  282. static int ocelot_create_group_func_map(struct device *dev,
  283. struct ocelot_pinctrl *info)
  284. {
  285. u16 pins[ARRAY_SIZE(ocelot_pins)];
  286. int f, npins, i;
  287. for (f = 0; f < FUNC_MAX; f++) {
  288. for (npins = 0, i = 0; i < ARRAY_SIZE(ocelot_pins); i++) {
  289. if (ocelot_pin_function_idx(i, f) >= 0)
  290. pins[npins++] = i;
  291. }
  292. info->func[f].ngroups = npins;
  293. info->func[f].groups = devm_kcalloc(dev,
  294. npins,
  295. sizeof(char *),
  296. GFP_KERNEL);
  297. if (!info->func[f].groups)
  298. return -ENOMEM;
  299. for (i = 0; i < npins; i++)
  300. info->func[f].groups[i] = ocelot_pins[pins[i]].name;
  301. }
  302. return 0;
  303. }
  304. static int ocelot_pinctrl_register(struct platform_device *pdev,
  305. struct ocelot_pinctrl *info)
  306. {
  307. int ret;
  308. ret = ocelot_create_group_func_map(&pdev->dev, info);
  309. if (ret) {
  310. dev_err(&pdev->dev, "Unable to create group func map.\n");
  311. return ret;
  312. }
  313. info->pctl = devm_pinctrl_register(&pdev->dev, &ocelot_desc, info);
  314. if (IS_ERR(info->pctl)) {
  315. dev_err(&pdev->dev, "Failed to register pinctrl\n");
  316. return PTR_ERR(info->pctl);
  317. }
  318. return 0;
  319. }
  320. static int ocelot_gpio_get(struct gpio_chip *chip, unsigned int offset)
  321. {
  322. struct ocelot_pinctrl *info = gpiochip_get_data(chip);
  323. unsigned int val;
  324. regmap_read(info->map, OCELOT_GPIO_IN, &val);
  325. return !!(val & BIT(offset));
  326. }
  327. static void ocelot_gpio_set(struct gpio_chip *chip, unsigned int offset,
  328. int value)
  329. {
  330. struct ocelot_pinctrl *info = gpiochip_get_data(chip);
  331. if (value)
  332. regmap_write(info->map, OCELOT_GPIO_OUT_SET, BIT(offset));
  333. else
  334. regmap_write(info->map, OCELOT_GPIO_OUT_CLR, BIT(offset));
  335. }
  336. static int ocelot_gpio_get_direction(struct gpio_chip *chip,
  337. unsigned int offset)
  338. {
  339. struct ocelot_pinctrl *info = gpiochip_get_data(chip);
  340. unsigned int val;
  341. regmap_read(info->map, OCELOT_GPIO_OE, &val);
  342. return !(val & BIT(offset));
  343. }
  344. static int ocelot_gpio_direction_input(struct gpio_chip *chip,
  345. unsigned int offset)
  346. {
  347. return pinctrl_gpio_direction_input(chip->base + offset);
  348. }
  349. static int ocelot_gpio_direction_output(struct gpio_chip *chip,
  350. unsigned int offset, int value)
  351. {
  352. struct ocelot_pinctrl *info = gpiochip_get_data(chip);
  353. unsigned int pin = BIT(offset);
  354. if (value)
  355. regmap_write(info->map, OCELOT_GPIO_OUT_SET, pin);
  356. else
  357. regmap_write(info->map, OCELOT_GPIO_OUT_CLR, pin);
  358. return pinctrl_gpio_direction_output(chip->base + offset);
  359. }
  360. static const struct gpio_chip ocelot_gpiolib_chip = {
  361. .request = gpiochip_generic_request,
  362. .free = gpiochip_generic_free,
  363. .set = ocelot_gpio_set,
  364. .get = ocelot_gpio_get,
  365. .get_direction = ocelot_gpio_get_direction,
  366. .direction_input = ocelot_gpio_direction_input,
  367. .direction_output = ocelot_gpio_direction_output,
  368. .owner = THIS_MODULE,
  369. };
  370. static void ocelot_irq_mask(struct irq_data *data)
  371. {
  372. struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
  373. struct ocelot_pinctrl *info = gpiochip_get_data(chip);
  374. unsigned int gpio = irqd_to_hwirq(data);
  375. regmap_update_bits(info->map, OCELOT_GPIO_INTR_ENA, BIT(gpio), 0);
  376. }
  377. static void ocelot_irq_unmask(struct irq_data *data)
  378. {
  379. struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
  380. struct ocelot_pinctrl *info = gpiochip_get_data(chip);
  381. unsigned int gpio = irqd_to_hwirq(data);
  382. regmap_update_bits(info->map, OCELOT_GPIO_INTR_ENA, BIT(gpio),
  383. BIT(gpio));
  384. }
  385. static void ocelot_irq_ack(struct irq_data *data)
  386. {
  387. struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
  388. struct ocelot_pinctrl *info = gpiochip_get_data(chip);
  389. unsigned int gpio = irqd_to_hwirq(data);
  390. regmap_write_bits(info->map, OCELOT_GPIO_INTR, BIT(gpio), BIT(gpio));
  391. }
  392. static int ocelot_irq_set_type(struct irq_data *data, unsigned int type);
  393. static struct irq_chip ocelot_eoi_irqchip = {
  394. .name = "gpio",
  395. .irq_mask = ocelot_irq_mask,
  396. .irq_eoi = ocelot_irq_ack,
  397. .irq_unmask = ocelot_irq_unmask,
  398. .flags = IRQCHIP_EOI_THREADED | IRQCHIP_EOI_IF_HANDLED,
  399. .irq_set_type = ocelot_irq_set_type,
  400. };
  401. static struct irq_chip ocelot_irqchip = {
  402. .name = "gpio",
  403. .irq_mask = ocelot_irq_mask,
  404. .irq_ack = ocelot_irq_ack,
  405. .irq_unmask = ocelot_irq_unmask,
  406. .irq_set_type = ocelot_irq_set_type,
  407. };
  408. static int ocelot_irq_set_type(struct irq_data *data, unsigned int type)
  409. {
  410. type &= IRQ_TYPE_SENSE_MASK;
  411. if (!(type & (IRQ_TYPE_EDGE_BOTH | IRQ_TYPE_LEVEL_HIGH)))
  412. return -EINVAL;
  413. if (type & IRQ_TYPE_LEVEL_HIGH)
  414. irq_set_chip_handler_name_locked(data, &ocelot_eoi_irqchip,
  415. handle_fasteoi_irq, NULL);
  416. if (type & IRQ_TYPE_EDGE_BOTH)
  417. irq_set_chip_handler_name_locked(data, &ocelot_irqchip,
  418. handle_edge_irq, NULL);
  419. return 0;
  420. }
  421. static void ocelot_irq_handler(struct irq_desc *desc)
  422. {
  423. struct irq_chip *parent_chip = irq_desc_get_chip(desc);
  424. struct gpio_chip *chip = irq_desc_get_handler_data(desc);
  425. struct ocelot_pinctrl *info = gpiochip_get_data(chip);
  426. unsigned int reg = 0, irq;
  427. unsigned long irqs;
  428. regmap_read(info->map, OCELOT_GPIO_INTR_IDENT, &reg);
  429. if (!reg)
  430. return;
  431. chained_irq_enter(parent_chip, desc);
  432. irqs = reg;
  433. for_each_set_bit(irq, &irqs, OCELOT_PINS) {
  434. generic_handle_irq(irq_linear_revmap(chip->irq.domain, irq));
  435. }
  436. chained_irq_exit(parent_chip, desc);
  437. }
  438. static int ocelot_gpiochip_register(struct platform_device *pdev,
  439. struct ocelot_pinctrl *info)
  440. {
  441. struct gpio_chip *gc;
  442. int ret, irq;
  443. info->gpio_chip = ocelot_gpiolib_chip;
  444. gc = &info->gpio_chip;
  445. gc->ngpio = OCELOT_PINS;
  446. gc->parent = &pdev->dev;
  447. gc->base = 0;
  448. gc->of_node = info->dev->of_node;
  449. gc->label = "ocelot-gpio";
  450. ret = devm_gpiochip_add_data(&pdev->dev, gc, info);
  451. if (ret)
  452. return ret;
  453. irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
  454. if (irq <= 0)
  455. return irq;
  456. ret = gpiochip_irqchip_add(gc, &ocelot_irqchip, 0, handle_edge_irq,
  457. IRQ_TYPE_NONE);
  458. if (ret)
  459. return ret;
  460. gpiochip_set_chained_irqchip(gc, &ocelot_irqchip, irq,
  461. ocelot_irq_handler);
  462. return 0;
  463. }
  464. static const struct regmap_config ocelot_pinctrl_regmap_config = {
  465. .reg_bits = 32,
  466. .val_bits = 32,
  467. .reg_stride = 4,
  468. .max_register = 0x64,
  469. };
  470. static const struct of_device_id ocelot_pinctrl_of_match[] = {
  471. { .compatible = "mscc,ocelot-pinctrl" },
  472. {},
  473. };
  474. static int ocelot_pinctrl_probe(struct platform_device *pdev)
  475. {
  476. struct device *dev = &pdev->dev;
  477. struct ocelot_pinctrl *info;
  478. void __iomem *base;
  479. int ret;
  480. info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
  481. if (!info)
  482. return -ENOMEM;
  483. base = devm_ioremap_resource(dev,
  484. platform_get_resource(pdev, IORESOURCE_MEM, 0));
  485. if (IS_ERR(base)) {
  486. dev_err(dev, "Failed to ioremap registers\n");
  487. return PTR_ERR(base);
  488. }
  489. info->map = devm_regmap_init_mmio(dev, base,
  490. &ocelot_pinctrl_regmap_config);
  491. if (IS_ERR(info->map)) {
  492. dev_err(dev, "Failed to create regmap\n");
  493. return PTR_ERR(info->map);
  494. }
  495. dev_set_drvdata(dev, info->map);
  496. info->dev = dev;
  497. ret = ocelot_pinctrl_register(pdev, info);
  498. if (ret)
  499. return ret;
  500. ret = ocelot_gpiochip_register(pdev, info);
  501. if (ret)
  502. return ret;
  503. return 0;
  504. }
  505. static struct platform_driver ocelot_pinctrl_driver = {
  506. .driver = {
  507. .name = "pinctrl-ocelot",
  508. .of_match_table = of_match_ptr(ocelot_pinctrl_of_match),
  509. .suppress_bind_attrs = true,
  510. },
  511. .probe = ocelot_pinctrl_probe,
  512. };
  513. builtin_platform_driver(ocelot_pinctrl_driver);