pfc.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727
  1. /*
  2. * Pinmuxed GPIO support for SuperH.
  3. *
  4. * Copyright (C) 2008 Magnus Damm
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file "COPYING" in the main directory of this archive
  8. * for more details.
  9. */
  10. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  11. #include <linux/errno.h>
  12. #include <linux/kernel.h>
  13. #include <linux/list.h>
  14. #include <linux/module.h>
  15. #include <linux/clk.h>
  16. #include <linux/err.h>
  17. #include <linux/io.h>
  18. #include <linux/irq.h>
  19. #include <linux/bitops.h>
  20. #include <linux/gpio.h>
  21. #include <linux/slab.h>
  22. #include <linux/ioport.h>
  23. static void pfc_iounmap(struct pinmux_info *pip)
  24. {
  25. int k;
  26. for (k = 0; k < pip->num_resources; k++)
  27. if (pip->window[k].virt)
  28. iounmap(pip->window[k].virt);
  29. kfree(pip->window);
  30. pip->window = NULL;
  31. }
  32. static int pfc_ioremap(struct pinmux_info *pip)
  33. {
  34. struct resource *res;
  35. int k;
  36. if (!pip->num_resources)
  37. return 0;
  38. pip->window = kzalloc(pip->num_resources * sizeof(*pip->window),
  39. GFP_NOWAIT);
  40. if (!pip->window)
  41. goto err1;
  42. for (k = 0; k < pip->num_resources; k++) {
  43. res = pip->resource + k;
  44. WARN_ON(resource_type(res) != IORESOURCE_MEM);
  45. pip->window[k].phys = res->start;
  46. pip->window[k].size = resource_size(res);
  47. pip->window[k].virt = ioremap_nocache(res->start,
  48. resource_size(res));
  49. if (!pip->window[k].virt)
  50. goto err2;
  51. }
  52. return 0;
  53. err2:
  54. pfc_iounmap(pip);
  55. err1:
  56. return -1;
  57. }
  58. static void __iomem *pfc_phys_to_virt(struct pinmux_info *pip,
  59. unsigned long address)
  60. {
  61. struct pfc_window *window;
  62. int k;
  63. /* scan through physical windows and convert address */
  64. for (k = 0; k < pip->num_resources; k++) {
  65. window = pip->window + k;
  66. if (address < window->phys)
  67. continue;
  68. if (address >= (window->phys + window->size))
  69. continue;
  70. return window->virt + (address - window->phys);
  71. }
  72. /* no windows defined, register must be 1:1 mapped virt:phys */
  73. return (void __iomem *)address;
  74. }
  75. static int enum_in_range(pinmux_enum_t enum_id, struct pinmux_range *r)
  76. {
  77. if (enum_id < r->begin)
  78. return 0;
  79. if (enum_id > r->end)
  80. return 0;
  81. return 1;
  82. }
  83. static unsigned long gpio_read_raw_reg(void __iomem *mapped_reg,
  84. unsigned long reg_width)
  85. {
  86. switch (reg_width) {
  87. case 8:
  88. return ioread8(mapped_reg);
  89. case 16:
  90. return ioread16(mapped_reg);
  91. case 32:
  92. return ioread32(mapped_reg);
  93. }
  94. BUG();
  95. return 0;
  96. }
  97. static void gpio_write_raw_reg(void __iomem *mapped_reg,
  98. unsigned long reg_width,
  99. unsigned long data)
  100. {
  101. switch (reg_width) {
  102. case 8:
  103. iowrite8(data, mapped_reg);
  104. return;
  105. case 16:
  106. iowrite16(data, mapped_reg);
  107. return;
  108. case 32:
  109. iowrite32(data, mapped_reg);
  110. return;
  111. }
  112. BUG();
  113. }
  114. static void gpio_write_bit(struct pinmux_data_reg *dr,
  115. unsigned long in_pos, unsigned long value)
  116. {
  117. unsigned long pos;
  118. pos = dr->reg_width - (in_pos + 1);
  119. pr_debug("write_bit addr = %lx, value = %d, pos = %ld, "
  120. "r_width = %ld\n",
  121. dr->reg, !!value, pos, dr->reg_width);
  122. if (value)
  123. set_bit(pos, &dr->reg_shadow);
  124. else
  125. clear_bit(pos, &dr->reg_shadow);
  126. gpio_write_raw_reg(dr->mapped_reg, dr->reg_width, dr->reg_shadow);
  127. }
  128. static int gpio_read_reg(void __iomem *mapped_reg, unsigned long reg_width,
  129. unsigned long field_width, unsigned long in_pos,
  130. unsigned long reg)
  131. {
  132. unsigned long data, mask, pos;
  133. data = 0;
  134. mask = (1 << field_width) - 1;
  135. pos = reg_width - ((in_pos + 1) * field_width);
  136. pr_debug("read_reg: addr = %lx, pos = %ld, "
  137. "r_width = %ld, f_width = %ld\n",
  138. reg, pos, reg_width, field_width);
  139. data = gpio_read_raw_reg(mapped_reg, reg_width);
  140. return (data >> pos) & mask;
  141. }
  142. static void gpio_write_reg(void __iomem *mapped_reg, unsigned long reg_width,
  143. unsigned long field_width, unsigned long in_pos,
  144. unsigned long value, unsigned long reg)
  145. {
  146. unsigned long mask, pos;
  147. mask = (1 << field_width) - 1;
  148. pos = reg_width - ((in_pos + 1) * field_width);
  149. pr_debug("write_reg addr = %lx, value = %ld, pos = %ld, "
  150. "r_width = %ld, f_width = %ld\n",
  151. reg, value, pos, reg_width, field_width);
  152. mask = ~(mask << pos);
  153. value = value << pos;
  154. switch (reg_width) {
  155. case 8:
  156. iowrite8((ioread8(mapped_reg) & mask) | value, mapped_reg);
  157. break;
  158. case 16:
  159. iowrite16((ioread16(mapped_reg) & mask) | value, mapped_reg);
  160. break;
  161. case 32:
  162. iowrite32((ioread32(mapped_reg) & mask) | value, mapped_reg);
  163. break;
  164. }
  165. }
  166. static int setup_data_reg(struct pinmux_info *gpioc, unsigned gpio)
  167. {
  168. struct pinmux_gpio *gpiop = &gpioc->gpios[gpio];
  169. struct pinmux_data_reg *data_reg;
  170. int k, n;
  171. if (!enum_in_range(gpiop->enum_id, &gpioc->data))
  172. return -1;
  173. k = 0;
  174. while (1) {
  175. data_reg = gpioc->data_regs + k;
  176. if (!data_reg->reg_width)
  177. break;
  178. data_reg->mapped_reg = pfc_phys_to_virt(gpioc, data_reg->reg);
  179. for (n = 0; n < data_reg->reg_width; n++) {
  180. if (data_reg->enum_ids[n] == gpiop->enum_id) {
  181. gpiop->flags &= ~PINMUX_FLAG_DREG;
  182. gpiop->flags |= (k << PINMUX_FLAG_DREG_SHIFT);
  183. gpiop->flags &= ~PINMUX_FLAG_DBIT;
  184. gpiop->flags |= (n << PINMUX_FLAG_DBIT_SHIFT);
  185. return 0;
  186. }
  187. }
  188. k++;
  189. }
  190. BUG();
  191. return -1;
  192. }
  193. static void setup_data_regs(struct pinmux_info *gpioc)
  194. {
  195. struct pinmux_data_reg *drp;
  196. int k;
  197. for (k = gpioc->first_gpio; k <= gpioc->last_gpio; k++)
  198. setup_data_reg(gpioc, k);
  199. k = 0;
  200. while (1) {
  201. drp = gpioc->data_regs + k;
  202. if (!drp->reg_width)
  203. break;
  204. drp->reg_shadow = gpio_read_raw_reg(drp->mapped_reg,
  205. drp->reg_width);
  206. k++;
  207. }
  208. }
  209. static int get_data_reg(struct pinmux_info *gpioc, unsigned gpio,
  210. struct pinmux_data_reg **drp, int *bitp)
  211. {
  212. struct pinmux_gpio *gpiop = &gpioc->gpios[gpio];
  213. int k, n;
  214. if (!enum_in_range(gpiop->enum_id, &gpioc->data))
  215. return -1;
  216. k = (gpiop->flags & PINMUX_FLAG_DREG) >> PINMUX_FLAG_DREG_SHIFT;
  217. n = (gpiop->flags & PINMUX_FLAG_DBIT) >> PINMUX_FLAG_DBIT_SHIFT;
  218. *drp = gpioc->data_regs + k;
  219. *bitp = n;
  220. return 0;
  221. }
  222. static int get_config_reg(struct pinmux_info *gpioc, pinmux_enum_t enum_id,
  223. struct pinmux_cfg_reg **crp, int *indexp,
  224. unsigned long **cntp)
  225. {
  226. struct pinmux_cfg_reg *config_reg;
  227. unsigned long r_width, f_width;
  228. int k, n;
  229. k = 0;
  230. while (1) {
  231. config_reg = gpioc->cfg_regs + k;
  232. r_width = config_reg->reg_width;
  233. f_width = config_reg->field_width;
  234. if (!r_width)
  235. break;
  236. for (n = 0; n < (r_width / f_width) * (1 << f_width); n++) {
  237. if (config_reg->enum_ids[n] == enum_id) {
  238. *crp = config_reg;
  239. *indexp = n;
  240. *cntp = &config_reg->cnt[n / (1 << f_width)];
  241. return 0;
  242. }
  243. }
  244. k++;
  245. }
  246. return -1;
  247. }
  248. static int get_gpio_enum_id(struct pinmux_info *gpioc, unsigned gpio,
  249. int pos, pinmux_enum_t *enum_idp)
  250. {
  251. pinmux_enum_t enum_id = gpioc->gpios[gpio].enum_id;
  252. pinmux_enum_t *data = gpioc->gpio_data;
  253. int k;
  254. if (!enum_in_range(enum_id, &gpioc->data)) {
  255. if (!enum_in_range(enum_id, &gpioc->mark)) {
  256. pr_err("non data/mark enum_id for gpio %d\n", gpio);
  257. return -1;
  258. }
  259. }
  260. if (pos) {
  261. *enum_idp = data[pos + 1];
  262. return pos + 1;
  263. }
  264. for (k = 0; k < gpioc->gpio_data_size; k++) {
  265. if (data[k] == enum_id) {
  266. *enum_idp = data[k + 1];
  267. return k + 1;
  268. }
  269. }
  270. pr_err("cannot locate data/mark enum_id for gpio %d\n", gpio);
  271. return -1;
  272. }
  273. static void write_config_reg(struct pinmux_info *gpioc,
  274. struct pinmux_cfg_reg *crp,
  275. int index)
  276. {
  277. unsigned long ncomb, pos, value;
  278. void __iomem *mapped_reg;
  279. ncomb = 1 << crp->field_width;
  280. pos = index / ncomb;
  281. value = index % ncomb;
  282. mapped_reg = pfc_phys_to_virt(gpioc, crp->reg);
  283. gpio_write_reg(mapped_reg, crp->reg_width, crp->field_width,
  284. pos, value, crp->reg);
  285. }
  286. static int check_config_reg(struct pinmux_info *gpioc,
  287. struct pinmux_cfg_reg *crp,
  288. int index)
  289. {
  290. unsigned long ncomb, pos, value;
  291. void __iomem *mapped_reg;
  292. ncomb = 1 << crp->field_width;
  293. pos = index / ncomb;
  294. value = index % ncomb;
  295. mapped_reg = pfc_phys_to_virt(gpioc, crp->reg);
  296. if (gpio_read_reg(mapped_reg, crp->reg_width,
  297. crp->field_width, pos, crp->reg) == value)
  298. return 0;
  299. return -1;
  300. }
  301. enum { GPIO_CFG_DRYRUN, GPIO_CFG_REQ, GPIO_CFG_FREE };
  302. static int pinmux_config_gpio(struct pinmux_info *gpioc, unsigned gpio,
  303. int pinmux_type, int cfg_mode)
  304. {
  305. struct pinmux_cfg_reg *cr = NULL;
  306. pinmux_enum_t enum_id;
  307. struct pinmux_range *range;
  308. int in_range, pos, index;
  309. unsigned long *cntp;
  310. switch (pinmux_type) {
  311. case PINMUX_TYPE_FUNCTION:
  312. range = NULL;
  313. break;
  314. case PINMUX_TYPE_OUTPUT:
  315. range = &gpioc->output;
  316. break;
  317. case PINMUX_TYPE_INPUT:
  318. range = &gpioc->input;
  319. break;
  320. case PINMUX_TYPE_INPUT_PULLUP:
  321. range = &gpioc->input_pu;
  322. break;
  323. case PINMUX_TYPE_INPUT_PULLDOWN:
  324. range = &gpioc->input_pd;
  325. break;
  326. default:
  327. goto out_err;
  328. }
  329. pos = 0;
  330. enum_id = 0;
  331. index = 0;
  332. while (1) {
  333. pos = get_gpio_enum_id(gpioc, gpio, pos, &enum_id);
  334. if (pos <= 0)
  335. goto out_err;
  336. if (!enum_id)
  337. break;
  338. /* first check if this is a function enum */
  339. in_range = enum_in_range(enum_id, &gpioc->function);
  340. if (!in_range) {
  341. /* not a function enum */
  342. if (range) {
  343. /*
  344. * other range exists, so this pin is
  345. * a regular GPIO pin that now is being
  346. * bound to a specific direction.
  347. *
  348. * for this case we only allow function enums
  349. * and the enums that match the other range.
  350. */
  351. in_range = enum_in_range(enum_id, range);
  352. /*
  353. * special case pass through for fixed
  354. * input-only or output-only pins without
  355. * function enum register association.
  356. */
  357. if (in_range && enum_id == range->force)
  358. continue;
  359. } else {
  360. /*
  361. * no other range exists, so this pin
  362. * must then be of the function type.
  363. *
  364. * allow function type pins to select
  365. * any combination of function/in/out
  366. * in their MARK lists.
  367. */
  368. in_range = 1;
  369. }
  370. }
  371. if (!in_range)
  372. continue;
  373. if (get_config_reg(gpioc, enum_id, &cr, &index, &cntp) != 0)
  374. goto out_err;
  375. switch (cfg_mode) {
  376. case GPIO_CFG_DRYRUN:
  377. if (!*cntp || !check_config_reg(gpioc, cr, index))
  378. continue;
  379. break;
  380. case GPIO_CFG_REQ:
  381. write_config_reg(gpioc, cr, index);
  382. *cntp = *cntp + 1;
  383. break;
  384. case GPIO_CFG_FREE:
  385. *cntp = *cntp - 1;
  386. break;
  387. }
  388. }
  389. return 0;
  390. out_err:
  391. return -1;
  392. }
  393. static DEFINE_SPINLOCK(gpio_lock);
  394. static struct pinmux_info *chip_to_pinmux(struct gpio_chip *chip)
  395. {
  396. return container_of(chip, struct pinmux_info, chip);
  397. }
  398. static int sh_gpio_request(struct gpio_chip *chip, unsigned offset)
  399. {
  400. struct pinmux_info *gpioc = chip_to_pinmux(chip);
  401. struct pinmux_data_reg *dummy;
  402. unsigned long flags;
  403. int i, ret, pinmux_type;
  404. ret = -EINVAL;
  405. if (!gpioc)
  406. goto err_out;
  407. spin_lock_irqsave(&gpio_lock, flags);
  408. if ((gpioc->gpios[offset].flags & PINMUX_FLAG_TYPE) != PINMUX_TYPE_NONE)
  409. goto err_unlock;
  410. /* setup pin function here if no data is associated with pin */
  411. if (get_data_reg(gpioc, offset, &dummy, &i) != 0)
  412. pinmux_type = PINMUX_TYPE_FUNCTION;
  413. else
  414. pinmux_type = PINMUX_TYPE_GPIO;
  415. if (pinmux_type == PINMUX_TYPE_FUNCTION) {
  416. if (pinmux_config_gpio(gpioc, offset,
  417. pinmux_type,
  418. GPIO_CFG_DRYRUN) != 0)
  419. goto err_unlock;
  420. if (pinmux_config_gpio(gpioc, offset,
  421. pinmux_type,
  422. GPIO_CFG_REQ) != 0)
  423. BUG();
  424. }
  425. gpioc->gpios[offset].flags &= ~PINMUX_FLAG_TYPE;
  426. gpioc->gpios[offset].flags |= pinmux_type;
  427. ret = 0;
  428. err_unlock:
  429. spin_unlock_irqrestore(&gpio_lock, flags);
  430. err_out:
  431. return ret;
  432. }
  433. static void sh_gpio_free(struct gpio_chip *chip, unsigned offset)
  434. {
  435. struct pinmux_info *gpioc = chip_to_pinmux(chip);
  436. unsigned long flags;
  437. int pinmux_type;
  438. if (!gpioc)
  439. return;
  440. spin_lock_irqsave(&gpio_lock, flags);
  441. pinmux_type = gpioc->gpios[offset].flags & PINMUX_FLAG_TYPE;
  442. pinmux_config_gpio(gpioc, offset, pinmux_type, GPIO_CFG_FREE);
  443. gpioc->gpios[offset].flags &= ~PINMUX_FLAG_TYPE;
  444. gpioc->gpios[offset].flags |= PINMUX_TYPE_NONE;
  445. spin_unlock_irqrestore(&gpio_lock, flags);
  446. }
  447. static int pinmux_direction(struct pinmux_info *gpioc,
  448. unsigned gpio, int new_pinmux_type)
  449. {
  450. int pinmux_type;
  451. int ret = -EINVAL;
  452. if (!gpioc)
  453. goto err_out;
  454. pinmux_type = gpioc->gpios[gpio].flags & PINMUX_FLAG_TYPE;
  455. switch (pinmux_type) {
  456. case PINMUX_TYPE_GPIO:
  457. break;
  458. case PINMUX_TYPE_OUTPUT:
  459. case PINMUX_TYPE_INPUT:
  460. case PINMUX_TYPE_INPUT_PULLUP:
  461. case PINMUX_TYPE_INPUT_PULLDOWN:
  462. pinmux_config_gpio(gpioc, gpio, pinmux_type, GPIO_CFG_FREE);
  463. break;
  464. default:
  465. goto err_out;
  466. }
  467. if (pinmux_config_gpio(gpioc, gpio,
  468. new_pinmux_type,
  469. GPIO_CFG_DRYRUN) != 0)
  470. goto err_out;
  471. if (pinmux_config_gpio(gpioc, gpio,
  472. new_pinmux_type,
  473. GPIO_CFG_REQ) != 0)
  474. BUG();
  475. gpioc->gpios[gpio].flags &= ~PINMUX_FLAG_TYPE;
  476. gpioc->gpios[gpio].flags |= new_pinmux_type;
  477. ret = 0;
  478. err_out:
  479. return ret;
  480. }
  481. static int sh_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
  482. {
  483. struct pinmux_info *gpioc = chip_to_pinmux(chip);
  484. unsigned long flags;
  485. int ret;
  486. spin_lock_irqsave(&gpio_lock, flags);
  487. ret = pinmux_direction(gpioc, offset, PINMUX_TYPE_INPUT);
  488. spin_unlock_irqrestore(&gpio_lock, flags);
  489. return ret;
  490. }
  491. static void sh_gpio_set_value(struct pinmux_info *gpioc,
  492. unsigned gpio, int value)
  493. {
  494. struct pinmux_data_reg *dr = NULL;
  495. int bit = 0;
  496. if (!gpioc || get_data_reg(gpioc, gpio, &dr, &bit) != 0)
  497. BUG();
  498. else
  499. gpio_write_bit(dr, bit, value);
  500. }
  501. static int sh_gpio_direction_output(struct gpio_chip *chip, unsigned offset,
  502. int value)
  503. {
  504. struct pinmux_info *gpioc = chip_to_pinmux(chip);
  505. unsigned long flags;
  506. int ret;
  507. sh_gpio_set_value(gpioc, offset, value);
  508. spin_lock_irqsave(&gpio_lock, flags);
  509. ret = pinmux_direction(gpioc, offset, PINMUX_TYPE_OUTPUT);
  510. spin_unlock_irqrestore(&gpio_lock, flags);
  511. return ret;
  512. }
  513. static int sh_gpio_get_value(struct pinmux_info *gpioc, unsigned gpio)
  514. {
  515. struct pinmux_data_reg *dr = NULL;
  516. int bit = 0;
  517. if (!gpioc || get_data_reg(gpioc, gpio, &dr, &bit) != 0)
  518. return -EINVAL;
  519. return gpio_read_reg(dr->mapped_reg, dr->reg_width, 1, bit, dr->reg);
  520. }
  521. static int sh_gpio_get(struct gpio_chip *chip, unsigned offset)
  522. {
  523. return sh_gpio_get_value(chip_to_pinmux(chip), offset);
  524. }
  525. static void sh_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
  526. {
  527. sh_gpio_set_value(chip_to_pinmux(chip), offset, value);
  528. }
  529. static int sh_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
  530. {
  531. struct pinmux_info *gpioc = chip_to_pinmux(chip);
  532. pinmux_enum_t enum_id;
  533. pinmux_enum_t *enum_ids;
  534. int i, k, pos;
  535. pos = 0;
  536. enum_id = 0;
  537. while (1) {
  538. pos = get_gpio_enum_id(gpioc, offset, pos, &enum_id);
  539. if (pos <= 0 || !enum_id)
  540. break;
  541. for (i = 0; i < gpioc->gpio_irq_size; i++) {
  542. enum_ids = gpioc->gpio_irq[i].enum_ids;
  543. for (k = 0; enum_ids[k]; k++) {
  544. if (enum_ids[k] == enum_id)
  545. return gpioc->gpio_irq[i].irq;
  546. }
  547. }
  548. }
  549. return -ENOSYS;
  550. }
  551. int register_pinmux(struct pinmux_info *pip)
  552. {
  553. struct gpio_chip *chip = &pip->chip;
  554. int ret;
  555. pr_info("%s handling gpio %d -> %d\n",
  556. pip->name, pip->first_gpio, pip->last_gpio);
  557. ret = pfc_ioremap(pip);
  558. if (ret < 0)
  559. return ret;
  560. setup_data_regs(pip);
  561. chip->request = sh_gpio_request;
  562. chip->free = sh_gpio_free;
  563. chip->direction_input = sh_gpio_direction_input;
  564. chip->get = sh_gpio_get;
  565. chip->direction_output = sh_gpio_direction_output;
  566. chip->set = sh_gpio_set;
  567. chip->to_irq = sh_gpio_to_irq;
  568. WARN_ON(pip->first_gpio != 0); /* needs testing */
  569. chip->label = pip->name;
  570. chip->owner = THIS_MODULE;
  571. chip->base = pip->first_gpio;
  572. chip->ngpio = (pip->last_gpio - pip->first_gpio) + 1;
  573. ret = gpiochip_add(chip);
  574. if (ret < 0)
  575. pfc_iounmap(pip);
  576. return ret;
  577. }
  578. int unregister_pinmux(struct pinmux_info *pip)
  579. {
  580. pr_info("%s deregistering\n", pip->name);
  581. pfc_iounmap(pip);
  582. return gpiochip_remove(&pip->chip);
  583. }