pinctrl-bcm2835.c 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105
  1. /*
  2. * Driver for Broadcom BCM2835 GPIO unit (pinctrl + GPIO)
  3. *
  4. * Copyright (C) 2012 Chris Boot, Simon Arlott, Stephen Warren
  5. *
  6. * This driver is inspired by:
  7. * pinctrl-nomadik.c, please see original file for copyright information
  8. * pinctrl-tegra.c, please see original file for copyright information
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. */
  20. #include <linux/bitmap.h>
  21. #include <linux/bug.h>
  22. #include <linux/delay.h>
  23. #include <linux/device.h>
  24. #include <linux/err.h>
  25. #include <linux/gpio/driver.h>
  26. #include <linux/io.h>
  27. #include <linux/irq.h>
  28. #include <linux/irqdesc.h>
  29. #include <linux/module.h>
  30. #include <linux/of_address.h>
  31. #include <linux/of.h>
  32. #include <linux/of_irq.h>
  33. #include <linux/pinctrl/consumer.h>
  34. #include <linux/pinctrl/machine.h>
  35. #include <linux/pinctrl/pinconf.h>
  36. #include <linux/pinctrl/pinctrl.h>
  37. #include <linux/pinctrl/pinmux.h>
  38. #include <linux/platform_device.h>
  39. #include <linux/seq_file.h>
  40. #include <linux/slab.h>
  41. #include <linux/spinlock.h>
  42. #include <linux/types.h>
  43. #define MODULE_NAME "pinctrl-bcm2835"
  44. #define BCM2835_NUM_GPIOS 54
  45. #define BCM2835_NUM_BANKS 2
  46. #define BCM2835_NUM_IRQS 3
  47. #define BCM2835_PIN_BITMAP_SZ \
  48. DIV_ROUND_UP(BCM2835_NUM_GPIOS, sizeof(unsigned long) * 8)
  49. /* GPIO register offsets */
  50. #define GPFSEL0 0x0 /* Function Select */
  51. #define GPSET0 0x1c /* Pin Output Set */
  52. #define GPCLR0 0x28 /* Pin Output Clear */
  53. #define GPLEV0 0x34 /* Pin Level */
  54. #define GPEDS0 0x40 /* Pin Event Detect Status */
  55. #define GPREN0 0x4c /* Pin Rising Edge Detect Enable */
  56. #define GPFEN0 0x58 /* Pin Falling Edge Detect Enable */
  57. #define GPHEN0 0x64 /* Pin High Detect Enable */
  58. #define GPLEN0 0x70 /* Pin Low Detect Enable */
  59. #define GPAREN0 0x7c /* Pin Async Rising Edge Detect */
  60. #define GPAFEN0 0x88 /* Pin Async Falling Edge Detect */
  61. #define GPPUD 0x94 /* Pin Pull-up/down Enable */
  62. #define GPPUDCLK0 0x98 /* Pin Pull-up/down Enable Clock */
  63. #define FSEL_REG(p) (GPFSEL0 + (((p) / 10) * 4))
  64. #define FSEL_SHIFT(p) (((p) % 10) * 3)
  65. #define GPIO_REG_OFFSET(p) ((p) / 32)
  66. #define GPIO_REG_SHIFT(p) ((p) % 32)
  67. enum bcm2835_pinconf_param {
  68. /* argument: bcm2835_pinconf_pull */
  69. BCM2835_PINCONF_PARAM_PULL,
  70. };
  71. #define BCM2835_PINCONF_PACK(_param_, _arg_) ((_param_) << 16 | (_arg_))
  72. #define BCM2835_PINCONF_UNPACK_PARAM(_conf_) ((_conf_) >> 16)
  73. #define BCM2835_PINCONF_UNPACK_ARG(_conf_) ((_conf_) & 0xffff)
  74. struct bcm2835_pinctrl {
  75. struct device *dev;
  76. void __iomem *base;
  77. int irq[BCM2835_NUM_IRQS];
  78. /* note: locking assumes each bank will have its own unsigned long */
  79. unsigned long enabled_irq_map[BCM2835_NUM_BANKS];
  80. unsigned int irq_type[BCM2835_NUM_GPIOS];
  81. struct pinctrl_dev *pctl_dev;
  82. struct gpio_chip gpio_chip;
  83. struct pinctrl_gpio_range gpio_range;
  84. int irq_group[BCM2835_NUM_IRQS];
  85. spinlock_t irq_lock[BCM2835_NUM_BANKS];
  86. };
  87. /* pins are just named GPIO0..GPIO53 */
  88. #define BCM2835_GPIO_PIN(a) PINCTRL_PIN(a, "gpio" #a)
  89. static struct pinctrl_pin_desc bcm2835_gpio_pins[] = {
  90. BCM2835_GPIO_PIN(0),
  91. BCM2835_GPIO_PIN(1),
  92. BCM2835_GPIO_PIN(2),
  93. BCM2835_GPIO_PIN(3),
  94. BCM2835_GPIO_PIN(4),
  95. BCM2835_GPIO_PIN(5),
  96. BCM2835_GPIO_PIN(6),
  97. BCM2835_GPIO_PIN(7),
  98. BCM2835_GPIO_PIN(8),
  99. BCM2835_GPIO_PIN(9),
  100. BCM2835_GPIO_PIN(10),
  101. BCM2835_GPIO_PIN(11),
  102. BCM2835_GPIO_PIN(12),
  103. BCM2835_GPIO_PIN(13),
  104. BCM2835_GPIO_PIN(14),
  105. BCM2835_GPIO_PIN(15),
  106. BCM2835_GPIO_PIN(16),
  107. BCM2835_GPIO_PIN(17),
  108. BCM2835_GPIO_PIN(18),
  109. BCM2835_GPIO_PIN(19),
  110. BCM2835_GPIO_PIN(20),
  111. BCM2835_GPIO_PIN(21),
  112. BCM2835_GPIO_PIN(22),
  113. BCM2835_GPIO_PIN(23),
  114. BCM2835_GPIO_PIN(24),
  115. BCM2835_GPIO_PIN(25),
  116. BCM2835_GPIO_PIN(26),
  117. BCM2835_GPIO_PIN(27),
  118. BCM2835_GPIO_PIN(28),
  119. BCM2835_GPIO_PIN(29),
  120. BCM2835_GPIO_PIN(30),
  121. BCM2835_GPIO_PIN(31),
  122. BCM2835_GPIO_PIN(32),
  123. BCM2835_GPIO_PIN(33),
  124. BCM2835_GPIO_PIN(34),
  125. BCM2835_GPIO_PIN(35),
  126. BCM2835_GPIO_PIN(36),
  127. BCM2835_GPIO_PIN(37),
  128. BCM2835_GPIO_PIN(38),
  129. BCM2835_GPIO_PIN(39),
  130. BCM2835_GPIO_PIN(40),
  131. BCM2835_GPIO_PIN(41),
  132. BCM2835_GPIO_PIN(42),
  133. BCM2835_GPIO_PIN(43),
  134. BCM2835_GPIO_PIN(44),
  135. BCM2835_GPIO_PIN(45),
  136. BCM2835_GPIO_PIN(46),
  137. BCM2835_GPIO_PIN(47),
  138. BCM2835_GPIO_PIN(48),
  139. BCM2835_GPIO_PIN(49),
  140. BCM2835_GPIO_PIN(50),
  141. BCM2835_GPIO_PIN(51),
  142. BCM2835_GPIO_PIN(52),
  143. BCM2835_GPIO_PIN(53),
  144. };
  145. /* one pin per group */
  146. static const char * const bcm2835_gpio_groups[] = {
  147. "gpio0",
  148. "gpio1",
  149. "gpio2",
  150. "gpio3",
  151. "gpio4",
  152. "gpio5",
  153. "gpio6",
  154. "gpio7",
  155. "gpio8",
  156. "gpio9",
  157. "gpio10",
  158. "gpio11",
  159. "gpio12",
  160. "gpio13",
  161. "gpio14",
  162. "gpio15",
  163. "gpio16",
  164. "gpio17",
  165. "gpio18",
  166. "gpio19",
  167. "gpio20",
  168. "gpio21",
  169. "gpio22",
  170. "gpio23",
  171. "gpio24",
  172. "gpio25",
  173. "gpio26",
  174. "gpio27",
  175. "gpio28",
  176. "gpio29",
  177. "gpio30",
  178. "gpio31",
  179. "gpio32",
  180. "gpio33",
  181. "gpio34",
  182. "gpio35",
  183. "gpio36",
  184. "gpio37",
  185. "gpio38",
  186. "gpio39",
  187. "gpio40",
  188. "gpio41",
  189. "gpio42",
  190. "gpio43",
  191. "gpio44",
  192. "gpio45",
  193. "gpio46",
  194. "gpio47",
  195. "gpio48",
  196. "gpio49",
  197. "gpio50",
  198. "gpio51",
  199. "gpio52",
  200. "gpio53",
  201. };
  202. enum bcm2835_fsel {
  203. BCM2835_FSEL_GPIO_IN = 0,
  204. BCM2835_FSEL_GPIO_OUT = 1,
  205. BCM2835_FSEL_ALT0 = 4,
  206. BCM2835_FSEL_ALT1 = 5,
  207. BCM2835_FSEL_ALT2 = 6,
  208. BCM2835_FSEL_ALT3 = 7,
  209. BCM2835_FSEL_ALT4 = 3,
  210. BCM2835_FSEL_ALT5 = 2,
  211. BCM2835_FSEL_COUNT = 8,
  212. BCM2835_FSEL_MASK = 0x7,
  213. };
  214. static const char * const bcm2835_functions[BCM2835_FSEL_COUNT] = {
  215. [BCM2835_FSEL_GPIO_IN] = "gpio_in",
  216. [BCM2835_FSEL_GPIO_OUT] = "gpio_out",
  217. [BCM2835_FSEL_ALT0] = "alt0",
  218. [BCM2835_FSEL_ALT1] = "alt1",
  219. [BCM2835_FSEL_ALT2] = "alt2",
  220. [BCM2835_FSEL_ALT3] = "alt3",
  221. [BCM2835_FSEL_ALT4] = "alt4",
  222. [BCM2835_FSEL_ALT5] = "alt5",
  223. };
  224. static const char * const irq_type_names[] = {
  225. [IRQ_TYPE_NONE] = "none",
  226. [IRQ_TYPE_EDGE_RISING] = "edge-rising",
  227. [IRQ_TYPE_EDGE_FALLING] = "edge-falling",
  228. [IRQ_TYPE_EDGE_BOTH] = "edge-both",
  229. [IRQ_TYPE_LEVEL_HIGH] = "level-high",
  230. [IRQ_TYPE_LEVEL_LOW] = "level-low",
  231. };
  232. static inline u32 bcm2835_gpio_rd(struct bcm2835_pinctrl *pc, unsigned reg)
  233. {
  234. return readl(pc->base + reg);
  235. }
  236. static inline void bcm2835_gpio_wr(struct bcm2835_pinctrl *pc, unsigned reg,
  237. u32 val)
  238. {
  239. writel(val, pc->base + reg);
  240. }
  241. static inline int bcm2835_gpio_get_bit(struct bcm2835_pinctrl *pc, unsigned reg,
  242. unsigned bit)
  243. {
  244. reg += GPIO_REG_OFFSET(bit) * 4;
  245. return (bcm2835_gpio_rd(pc, reg) >> GPIO_REG_SHIFT(bit)) & 1;
  246. }
  247. /* note NOT a read/modify/write cycle */
  248. static inline void bcm2835_gpio_set_bit(struct bcm2835_pinctrl *pc,
  249. unsigned reg, unsigned bit)
  250. {
  251. reg += GPIO_REG_OFFSET(bit) * 4;
  252. bcm2835_gpio_wr(pc, reg, BIT(GPIO_REG_SHIFT(bit)));
  253. }
  254. static inline enum bcm2835_fsel bcm2835_pinctrl_fsel_get(
  255. struct bcm2835_pinctrl *pc, unsigned pin)
  256. {
  257. u32 val = bcm2835_gpio_rd(pc, FSEL_REG(pin));
  258. enum bcm2835_fsel status = (val >> FSEL_SHIFT(pin)) & BCM2835_FSEL_MASK;
  259. dev_dbg(pc->dev, "get %08x (%u => %s)\n", val, pin,
  260. bcm2835_functions[status]);
  261. return status;
  262. }
  263. static inline void bcm2835_pinctrl_fsel_set(
  264. struct bcm2835_pinctrl *pc, unsigned pin,
  265. enum bcm2835_fsel fsel)
  266. {
  267. u32 val = bcm2835_gpio_rd(pc, FSEL_REG(pin));
  268. enum bcm2835_fsel cur = (val >> FSEL_SHIFT(pin)) & BCM2835_FSEL_MASK;
  269. dev_dbg(pc->dev, "read %08x (%u => %s)\n", val, pin,
  270. bcm2835_functions[cur]);
  271. if (cur == fsel)
  272. return;
  273. if (cur != BCM2835_FSEL_GPIO_IN && fsel != BCM2835_FSEL_GPIO_IN) {
  274. /* always transition through GPIO_IN */
  275. val &= ~(BCM2835_FSEL_MASK << FSEL_SHIFT(pin));
  276. val |= BCM2835_FSEL_GPIO_IN << FSEL_SHIFT(pin);
  277. dev_dbg(pc->dev, "trans %08x (%u <= %s)\n", val, pin,
  278. bcm2835_functions[BCM2835_FSEL_GPIO_IN]);
  279. bcm2835_gpio_wr(pc, FSEL_REG(pin), val);
  280. }
  281. val &= ~(BCM2835_FSEL_MASK << FSEL_SHIFT(pin));
  282. val |= fsel << FSEL_SHIFT(pin);
  283. dev_dbg(pc->dev, "write %08x (%u <= %s)\n", val, pin,
  284. bcm2835_functions[fsel]);
  285. bcm2835_gpio_wr(pc, FSEL_REG(pin), val);
  286. }
  287. static int bcm2835_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
  288. {
  289. return pinctrl_gpio_direction_input(chip->base + offset);
  290. }
  291. static int bcm2835_gpio_get(struct gpio_chip *chip, unsigned offset)
  292. {
  293. struct bcm2835_pinctrl *pc = gpiochip_get_data(chip);
  294. return bcm2835_gpio_get_bit(pc, GPLEV0, offset);
  295. }
  296. static int bcm2835_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
  297. {
  298. struct bcm2835_pinctrl *pc = gpiochip_get_data(chip);
  299. enum bcm2835_fsel fsel = bcm2835_pinctrl_fsel_get(pc, offset);
  300. /* Alternative function doesn't clearly provide a direction */
  301. if (fsel > BCM2835_FSEL_GPIO_OUT)
  302. return -EINVAL;
  303. return (fsel == BCM2835_FSEL_GPIO_IN);
  304. }
  305. static void bcm2835_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
  306. {
  307. struct bcm2835_pinctrl *pc = gpiochip_get_data(chip);
  308. bcm2835_gpio_set_bit(pc, value ? GPSET0 : GPCLR0, offset);
  309. }
  310. static int bcm2835_gpio_direction_output(struct gpio_chip *chip,
  311. unsigned offset, int value)
  312. {
  313. bcm2835_gpio_set(chip, offset, value);
  314. return pinctrl_gpio_direction_output(chip->base + offset);
  315. }
  316. static struct gpio_chip bcm2835_gpio_chip = {
  317. .label = MODULE_NAME,
  318. .owner = THIS_MODULE,
  319. .request = gpiochip_generic_request,
  320. .free = gpiochip_generic_free,
  321. .direction_input = bcm2835_gpio_direction_input,
  322. .direction_output = bcm2835_gpio_direction_output,
  323. .get_direction = bcm2835_gpio_get_direction,
  324. .get = bcm2835_gpio_get,
  325. .set = bcm2835_gpio_set,
  326. .base = -1,
  327. .ngpio = BCM2835_NUM_GPIOS,
  328. .can_sleep = false,
  329. };
  330. static void bcm2835_gpio_irq_handle_bank(struct bcm2835_pinctrl *pc,
  331. unsigned int bank, u32 mask)
  332. {
  333. unsigned long events;
  334. unsigned offset;
  335. unsigned gpio;
  336. unsigned int type;
  337. events = bcm2835_gpio_rd(pc, GPEDS0 + bank * 4);
  338. events &= mask;
  339. events &= pc->enabled_irq_map[bank];
  340. for_each_set_bit(offset, &events, 32) {
  341. gpio = (32 * bank) + offset;
  342. /* FIXME: no clue why the code looks up the type here */
  343. type = pc->irq_type[gpio];
  344. generic_handle_irq(irq_linear_revmap(pc->gpio_chip.irqdomain,
  345. gpio));
  346. }
  347. }
  348. static void bcm2835_gpio_irq_handler(struct irq_desc *desc)
  349. {
  350. struct gpio_chip *chip = irq_desc_get_handler_data(desc);
  351. struct bcm2835_pinctrl *pc = gpiochip_get_data(chip);
  352. struct irq_chip *host_chip = irq_desc_get_chip(desc);
  353. int irq = irq_desc_get_irq(desc);
  354. int group;
  355. int i;
  356. for (i = 0; i < ARRAY_SIZE(pc->irq); i++) {
  357. if (pc->irq[i] == irq) {
  358. group = pc->irq_group[i];
  359. break;
  360. }
  361. }
  362. /* This should not happen, every IRQ has a bank */
  363. if (i == ARRAY_SIZE(pc->irq))
  364. BUG();
  365. chained_irq_enter(host_chip, desc);
  366. switch (group) {
  367. case 0: /* IRQ0 covers GPIOs 0-27 */
  368. bcm2835_gpio_irq_handle_bank(pc, 0, 0x0fffffff);
  369. break;
  370. case 1: /* IRQ1 covers GPIOs 28-45 */
  371. bcm2835_gpio_irq_handle_bank(pc, 0, 0xf0000000);
  372. bcm2835_gpio_irq_handle_bank(pc, 1, 0x00003fff);
  373. break;
  374. case 2: /* IRQ2 covers GPIOs 46-53 */
  375. bcm2835_gpio_irq_handle_bank(pc, 1, 0x003fc000);
  376. break;
  377. }
  378. chained_irq_exit(host_chip, desc);
  379. }
  380. static inline void __bcm2835_gpio_irq_config(struct bcm2835_pinctrl *pc,
  381. unsigned reg, unsigned offset, bool enable)
  382. {
  383. u32 value;
  384. reg += GPIO_REG_OFFSET(offset) * 4;
  385. value = bcm2835_gpio_rd(pc, reg);
  386. if (enable)
  387. value |= BIT(GPIO_REG_SHIFT(offset));
  388. else
  389. value &= ~(BIT(GPIO_REG_SHIFT(offset)));
  390. bcm2835_gpio_wr(pc, reg, value);
  391. }
  392. /* fast path for IRQ handler */
  393. static void bcm2835_gpio_irq_config(struct bcm2835_pinctrl *pc,
  394. unsigned offset, bool enable)
  395. {
  396. switch (pc->irq_type[offset]) {
  397. case IRQ_TYPE_EDGE_RISING:
  398. __bcm2835_gpio_irq_config(pc, GPREN0, offset, enable);
  399. break;
  400. case IRQ_TYPE_EDGE_FALLING:
  401. __bcm2835_gpio_irq_config(pc, GPFEN0, offset, enable);
  402. break;
  403. case IRQ_TYPE_EDGE_BOTH:
  404. __bcm2835_gpio_irq_config(pc, GPREN0, offset, enable);
  405. __bcm2835_gpio_irq_config(pc, GPFEN0, offset, enable);
  406. break;
  407. case IRQ_TYPE_LEVEL_HIGH:
  408. __bcm2835_gpio_irq_config(pc, GPHEN0, offset, enable);
  409. break;
  410. case IRQ_TYPE_LEVEL_LOW:
  411. __bcm2835_gpio_irq_config(pc, GPLEN0, offset, enable);
  412. break;
  413. }
  414. }
  415. static void bcm2835_gpio_irq_enable(struct irq_data *data)
  416. {
  417. struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
  418. struct bcm2835_pinctrl *pc = gpiochip_get_data(chip);
  419. unsigned gpio = irqd_to_hwirq(data);
  420. unsigned offset = GPIO_REG_SHIFT(gpio);
  421. unsigned bank = GPIO_REG_OFFSET(gpio);
  422. unsigned long flags;
  423. spin_lock_irqsave(&pc->irq_lock[bank], flags);
  424. set_bit(offset, &pc->enabled_irq_map[bank]);
  425. bcm2835_gpio_irq_config(pc, gpio, true);
  426. spin_unlock_irqrestore(&pc->irq_lock[bank], flags);
  427. }
  428. static void bcm2835_gpio_irq_disable(struct irq_data *data)
  429. {
  430. struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
  431. struct bcm2835_pinctrl *pc = gpiochip_get_data(chip);
  432. unsigned gpio = irqd_to_hwirq(data);
  433. unsigned offset = GPIO_REG_SHIFT(gpio);
  434. unsigned bank = GPIO_REG_OFFSET(gpio);
  435. unsigned long flags;
  436. spin_lock_irqsave(&pc->irq_lock[bank], flags);
  437. bcm2835_gpio_irq_config(pc, gpio, false);
  438. /* Clear events that were latched prior to clearing event sources */
  439. bcm2835_gpio_set_bit(pc, GPEDS0, gpio);
  440. clear_bit(offset, &pc->enabled_irq_map[bank]);
  441. spin_unlock_irqrestore(&pc->irq_lock[bank], flags);
  442. }
  443. static int __bcm2835_gpio_irq_set_type_disabled(struct bcm2835_pinctrl *pc,
  444. unsigned offset, unsigned int type)
  445. {
  446. switch (type) {
  447. case IRQ_TYPE_NONE:
  448. case IRQ_TYPE_EDGE_RISING:
  449. case IRQ_TYPE_EDGE_FALLING:
  450. case IRQ_TYPE_EDGE_BOTH:
  451. case IRQ_TYPE_LEVEL_HIGH:
  452. case IRQ_TYPE_LEVEL_LOW:
  453. pc->irq_type[offset] = type;
  454. break;
  455. default:
  456. return -EINVAL;
  457. }
  458. return 0;
  459. }
  460. /* slower path for reconfiguring IRQ type */
  461. static int __bcm2835_gpio_irq_set_type_enabled(struct bcm2835_pinctrl *pc,
  462. unsigned offset, unsigned int type)
  463. {
  464. switch (type) {
  465. case IRQ_TYPE_NONE:
  466. if (pc->irq_type[offset] != type) {
  467. bcm2835_gpio_irq_config(pc, offset, false);
  468. pc->irq_type[offset] = type;
  469. }
  470. break;
  471. case IRQ_TYPE_EDGE_RISING:
  472. if (pc->irq_type[offset] == IRQ_TYPE_EDGE_BOTH) {
  473. /* RISING already enabled, disable FALLING */
  474. pc->irq_type[offset] = IRQ_TYPE_EDGE_FALLING;
  475. bcm2835_gpio_irq_config(pc, offset, false);
  476. pc->irq_type[offset] = type;
  477. } else if (pc->irq_type[offset] != type) {
  478. bcm2835_gpio_irq_config(pc, offset, false);
  479. pc->irq_type[offset] = type;
  480. bcm2835_gpio_irq_config(pc, offset, true);
  481. }
  482. break;
  483. case IRQ_TYPE_EDGE_FALLING:
  484. if (pc->irq_type[offset] == IRQ_TYPE_EDGE_BOTH) {
  485. /* FALLING already enabled, disable RISING */
  486. pc->irq_type[offset] = IRQ_TYPE_EDGE_RISING;
  487. bcm2835_gpio_irq_config(pc, offset, false);
  488. pc->irq_type[offset] = type;
  489. } else if (pc->irq_type[offset] != type) {
  490. bcm2835_gpio_irq_config(pc, offset, false);
  491. pc->irq_type[offset] = type;
  492. bcm2835_gpio_irq_config(pc, offset, true);
  493. }
  494. break;
  495. case IRQ_TYPE_EDGE_BOTH:
  496. if (pc->irq_type[offset] == IRQ_TYPE_EDGE_RISING) {
  497. /* RISING already enabled, enable FALLING too */
  498. pc->irq_type[offset] = IRQ_TYPE_EDGE_FALLING;
  499. bcm2835_gpio_irq_config(pc, offset, true);
  500. pc->irq_type[offset] = type;
  501. } else if (pc->irq_type[offset] == IRQ_TYPE_EDGE_FALLING) {
  502. /* FALLING already enabled, enable RISING too */
  503. pc->irq_type[offset] = IRQ_TYPE_EDGE_RISING;
  504. bcm2835_gpio_irq_config(pc, offset, true);
  505. pc->irq_type[offset] = type;
  506. } else if (pc->irq_type[offset] != type) {
  507. bcm2835_gpio_irq_config(pc, offset, false);
  508. pc->irq_type[offset] = type;
  509. bcm2835_gpio_irq_config(pc, offset, true);
  510. }
  511. break;
  512. case IRQ_TYPE_LEVEL_HIGH:
  513. case IRQ_TYPE_LEVEL_LOW:
  514. if (pc->irq_type[offset] != type) {
  515. bcm2835_gpio_irq_config(pc, offset, false);
  516. pc->irq_type[offset] = type;
  517. bcm2835_gpio_irq_config(pc, offset, true);
  518. }
  519. break;
  520. default:
  521. return -EINVAL;
  522. }
  523. return 0;
  524. }
  525. static int bcm2835_gpio_irq_set_type(struct irq_data *data, unsigned int type)
  526. {
  527. struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
  528. struct bcm2835_pinctrl *pc = gpiochip_get_data(chip);
  529. unsigned gpio = irqd_to_hwirq(data);
  530. unsigned offset = GPIO_REG_SHIFT(gpio);
  531. unsigned bank = GPIO_REG_OFFSET(gpio);
  532. unsigned long flags;
  533. int ret;
  534. spin_lock_irqsave(&pc->irq_lock[bank], flags);
  535. if (test_bit(offset, &pc->enabled_irq_map[bank]))
  536. ret = __bcm2835_gpio_irq_set_type_enabled(pc, gpio, type);
  537. else
  538. ret = __bcm2835_gpio_irq_set_type_disabled(pc, gpio, type);
  539. if (type & IRQ_TYPE_EDGE_BOTH)
  540. irq_set_handler_locked(data, handle_edge_irq);
  541. else
  542. irq_set_handler_locked(data, handle_level_irq);
  543. spin_unlock_irqrestore(&pc->irq_lock[bank], flags);
  544. return ret;
  545. }
  546. static void bcm2835_gpio_irq_ack(struct irq_data *data)
  547. {
  548. struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
  549. struct bcm2835_pinctrl *pc = gpiochip_get_data(chip);
  550. unsigned gpio = irqd_to_hwirq(data);
  551. bcm2835_gpio_set_bit(pc, GPEDS0, gpio);
  552. }
  553. static struct irq_chip bcm2835_gpio_irq_chip = {
  554. .name = MODULE_NAME,
  555. .irq_enable = bcm2835_gpio_irq_enable,
  556. .irq_disable = bcm2835_gpio_irq_disable,
  557. .irq_set_type = bcm2835_gpio_irq_set_type,
  558. .irq_ack = bcm2835_gpio_irq_ack,
  559. .irq_mask = bcm2835_gpio_irq_disable,
  560. .irq_unmask = bcm2835_gpio_irq_enable,
  561. };
  562. static int bcm2835_pctl_get_groups_count(struct pinctrl_dev *pctldev)
  563. {
  564. return ARRAY_SIZE(bcm2835_gpio_groups);
  565. }
  566. static const char *bcm2835_pctl_get_group_name(struct pinctrl_dev *pctldev,
  567. unsigned selector)
  568. {
  569. return bcm2835_gpio_groups[selector];
  570. }
  571. static int bcm2835_pctl_get_group_pins(struct pinctrl_dev *pctldev,
  572. unsigned selector,
  573. const unsigned **pins,
  574. unsigned *num_pins)
  575. {
  576. *pins = &bcm2835_gpio_pins[selector].number;
  577. *num_pins = 1;
  578. return 0;
  579. }
  580. static void bcm2835_pctl_pin_dbg_show(struct pinctrl_dev *pctldev,
  581. struct seq_file *s,
  582. unsigned offset)
  583. {
  584. struct bcm2835_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev);
  585. struct gpio_chip *chip = &pc->gpio_chip;
  586. enum bcm2835_fsel fsel = bcm2835_pinctrl_fsel_get(pc, offset);
  587. const char *fname = bcm2835_functions[fsel];
  588. int value = bcm2835_gpio_get_bit(pc, GPLEV0, offset);
  589. int irq = irq_find_mapping(chip->irqdomain, offset);
  590. seq_printf(s, "function %s in %s; irq %d (%s)",
  591. fname, value ? "hi" : "lo",
  592. irq, irq_type_names[pc->irq_type[offset]]);
  593. }
  594. static void bcm2835_pctl_dt_free_map(struct pinctrl_dev *pctldev,
  595. struct pinctrl_map *maps, unsigned num_maps)
  596. {
  597. int i;
  598. for (i = 0; i < num_maps; i++)
  599. if (maps[i].type == PIN_MAP_TYPE_CONFIGS_PIN)
  600. kfree(maps[i].data.configs.configs);
  601. kfree(maps);
  602. }
  603. static int bcm2835_pctl_dt_node_to_map_func(struct bcm2835_pinctrl *pc,
  604. struct device_node *np, u32 pin, u32 fnum,
  605. struct pinctrl_map **maps)
  606. {
  607. struct pinctrl_map *map = *maps;
  608. if (fnum >= ARRAY_SIZE(bcm2835_functions)) {
  609. dev_err(pc->dev, "%s: invalid brcm,function %d\n",
  610. of_node_full_name(np), fnum);
  611. return -EINVAL;
  612. }
  613. map->type = PIN_MAP_TYPE_MUX_GROUP;
  614. map->data.mux.group = bcm2835_gpio_groups[pin];
  615. map->data.mux.function = bcm2835_functions[fnum];
  616. (*maps)++;
  617. return 0;
  618. }
  619. static int bcm2835_pctl_dt_node_to_map_pull(struct bcm2835_pinctrl *pc,
  620. struct device_node *np, u32 pin, u32 pull,
  621. struct pinctrl_map **maps)
  622. {
  623. struct pinctrl_map *map = *maps;
  624. unsigned long *configs;
  625. if (pull > 2) {
  626. dev_err(pc->dev, "%s: invalid brcm,pull %d\n",
  627. of_node_full_name(np), pull);
  628. return -EINVAL;
  629. }
  630. configs = kzalloc(sizeof(*configs), GFP_KERNEL);
  631. if (!configs)
  632. return -ENOMEM;
  633. configs[0] = BCM2835_PINCONF_PACK(BCM2835_PINCONF_PARAM_PULL, pull);
  634. map->type = PIN_MAP_TYPE_CONFIGS_PIN;
  635. map->data.configs.group_or_pin = bcm2835_gpio_pins[pin].name;
  636. map->data.configs.configs = configs;
  637. map->data.configs.num_configs = 1;
  638. (*maps)++;
  639. return 0;
  640. }
  641. static int bcm2835_pctl_dt_node_to_map(struct pinctrl_dev *pctldev,
  642. struct device_node *np,
  643. struct pinctrl_map **map, unsigned *num_maps)
  644. {
  645. struct bcm2835_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev);
  646. struct property *pins, *funcs, *pulls;
  647. int num_pins, num_funcs, num_pulls, maps_per_pin;
  648. struct pinctrl_map *maps, *cur_map;
  649. int i, err;
  650. u32 pin, func, pull;
  651. pins = of_find_property(np, "brcm,pins", NULL);
  652. if (!pins) {
  653. dev_err(pc->dev, "%s: missing brcm,pins property\n",
  654. of_node_full_name(np));
  655. return -EINVAL;
  656. }
  657. funcs = of_find_property(np, "brcm,function", NULL);
  658. pulls = of_find_property(np, "brcm,pull", NULL);
  659. if (!funcs && !pulls) {
  660. dev_err(pc->dev,
  661. "%s: neither brcm,function nor brcm,pull specified\n",
  662. of_node_full_name(np));
  663. return -EINVAL;
  664. }
  665. num_pins = pins->length / 4;
  666. num_funcs = funcs ? (funcs->length / 4) : 0;
  667. num_pulls = pulls ? (pulls->length / 4) : 0;
  668. if (num_funcs > 1 && num_funcs != num_pins) {
  669. dev_err(pc->dev,
  670. "%s: brcm,function must have 1 or %d entries\n",
  671. of_node_full_name(np), num_pins);
  672. return -EINVAL;
  673. }
  674. if (num_pulls > 1 && num_pulls != num_pins) {
  675. dev_err(pc->dev,
  676. "%s: brcm,pull must have 1 or %d entries\n",
  677. of_node_full_name(np), num_pins);
  678. return -EINVAL;
  679. }
  680. maps_per_pin = 0;
  681. if (num_funcs)
  682. maps_per_pin++;
  683. if (num_pulls)
  684. maps_per_pin++;
  685. cur_map = maps = kzalloc(num_pins * maps_per_pin * sizeof(*maps),
  686. GFP_KERNEL);
  687. if (!maps)
  688. return -ENOMEM;
  689. for (i = 0; i < num_pins; i++) {
  690. err = of_property_read_u32_index(np, "brcm,pins", i, &pin);
  691. if (err)
  692. goto out;
  693. if (pin >= ARRAY_SIZE(bcm2835_gpio_pins)) {
  694. dev_err(pc->dev, "%s: invalid brcm,pins value %d\n",
  695. of_node_full_name(np), pin);
  696. err = -EINVAL;
  697. goto out;
  698. }
  699. if (num_funcs) {
  700. err = of_property_read_u32_index(np, "brcm,function",
  701. (num_funcs > 1) ? i : 0, &func);
  702. if (err)
  703. goto out;
  704. err = bcm2835_pctl_dt_node_to_map_func(pc, np, pin,
  705. func, &cur_map);
  706. if (err)
  707. goto out;
  708. }
  709. if (num_pulls) {
  710. err = of_property_read_u32_index(np, "brcm,pull",
  711. (num_pulls > 1) ? i : 0, &pull);
  712. if (err)
  713. goto out;
  714. err = bcm2835_pctl_dt_node_to_map_pull(pc, np, pin,
  715. pull, &cur_map);
  716. if (err)
  717. goto out;
  718. }
  719. }
  720. *map = maps;
  721. *num_maps = num_pins * maps_per_pin;
  722. return 0;
  723. out:
  724. bcm2835_pctl_dt_free_map(pctldev, maps, num_pins * maps_per_pin);
  725. return err;
  726. }
  727. static const struct pinctrl_ops bcm2835_pctl_ops = {
  728. .get_groups_count = bcm2835_pctl_get_groups_count,
  729. .get_group_name = bcm2835_pctl_get_group_name,
  730. .get_group_pins = bcm2835_pctl_get_group_pins,
  731. .pin_dbg_show = bcm2835_pctl_pin_dbg_show,
  732. .dt_node_to_map = bcm2835_pctl_dt_node_to_map,
  733. .dt_free_map = bcm2835_pctl_dt_free_map,
  734. };
  735. static int bcm2835_pmx_free(struct pinctrl_dev *pctldev,
  736. unsigned offset)
  737. {
  738. struct bcm2835_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev);
  739. /* disable by setting to GPIO_IN */
  740. bcm2835_pinctrl_fsel_set(pc, offset, BCM2835_FSEL_GPIO_IN);
  741. return 0;
  742. }
  743. static int bcm2835_pmx_get_functions_count(struct pinctrl_dev *pctldev)
  744. {
  745. return BCM2835_FSEL_COUNT;
  746. }
  747. static const char *bcm2835_pmx_get_function_name(struct pinctrl_dev *pctldev,
  748. unsigned selector)
  749. {
  750. return bcm2835_functions[selector];
  751. }
  752. static int bcm2835_pmx_get_function_groups(struct pinctrl_dev *pctldev,
  753. unsigned selector,
  754. const char * const **groups,
  755. unsigned * const num_groups)
  756. {
  757. /* every pin can do every function */
  758. *groups = bcm2835_gpio_groups;
  759. *num_groups = ARRAY_SIZE(bcm2835_gpio_groups);
  760. return 0;
  761. }
  762. static int bcm2835_pmx_set(struct pinctrl_dev *pctldev,
  763. unsigned func_selector,
  764. unsigned group_selector)
  765. {
  766. struct bcm2835_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev);
  767. bcm2835_pinctrl_fsel_set(pc, group_selector, func_selector);
  768. return 0;
  769. }
  770. static void bcm2835_pmx_gpio_disable_free(struct pinctrl_dev *pctldev,
  771. struct pinctrl_gpio_range *range,
  772. unsigned offset)
  773. {
  774. struct bcm2835_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev);
  775. /* disable by setting to GPIO_IN */
  776. bcm2835_pinctrl_fsel_set(pc, offset, BCM2835_FSEL_GPIO_IN);
  777. }
  778. static int bcm2835_pmx_gpio_set_direction(struct pinctrl_dev *pctldev,
  779. struct pinctrl_gpio_range *range,
  780. unsigned offset,
  781. bool input)
  782. {
  783. struct bcm2835_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev);
  784. enum bcm2835_fsel fsel = input ?
  785. BCM2835_FSEL_GPIO_IN : BCM2835_FSEL_GPIO_OUT;
  786. bcm2835_pinctrl_fsel_set(pc, offset, fsel);
  787. return 0;
  788. }
  789. static const struct pinmux_ops bcm2835_pmx_ops = {
  790. .free = bcm2835_pmx_free,
  791. .get_functions_count = bcm2835_pmx_get_functions_count,
  792. .get_function_name = bcm2835_pmx_get_function_name,
  793. .get_function_groups = bcm2835_pmx_get_function_groups,
  794. .set_mux = bcm2835_pmx_set,
  795. .gpio_disable_free = bcm2835_pmx_gpio_disable_free,
  796. .gpio_set_direction = bcm2835_pmx_gpio_set_direction,
  797. };
  798. static int bcm2835_pinconf_get(struct pinctrl_dev *pctldev,
  799. unsigned pin, unsigned long *config)
  800. {
  801. /* No way to read back config in HW */
  802. return -ENOTSUPP;
  803. }
  804. static int bcm2835_pinconf_set(struct pinctrl_dev *pctldev,
  805. unsigned pin, unsigned long *configs,
  806. unsigned num_configs)
  807. {
  808. struct bcm2835_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev);
  809. enum bcm2835_pinconf_param param;
  810. u16 arg;
  811. u32 off, bit;
  812. int i;
  813. for (i = 0; i < num_configs; i++) {
  814. param = BCM2835_PINCONF_UNPACK_PARAM(configs[i]);
  815. arg = BCM2835_PINCONF_UNPACK_ARG(configs[i]);
  816. if (param != BCM2835_PINCONF_PARAM_PULL)
  817. return -EINVAL;
  818. off = GPIO_REG_OFFSET(pin);
  819. bit = GPIO_REG_SHIFT(pin);
  820. bcm2835_gpio_wr(pc, GPPUD, arg & 3);
  821. /*
  822. * BCM2835 datasheet say to wait 150 cycles, but not of what.
  823. * But the VideoCore firmware delay for this operation
  824. * based nearly on the same amount of VPU cycles and this clock
  825. * runs at 250 MHz.
  826. */
  827. udelay(1);
  828. bcm2835_gpio_wr(pc, GPPUDCLK0 + (off * 4), BIT(bit));
  829. udelay(1);
  830. bcm2835_gpio_wr(pc, GPPUDCLK0 + (off * 4), 0);
  831. } /* for each config */
  832. return 0;
  833. }
  834. static const struct pinconf_ops bcm2835_pinconf_ops = {
  835. .pin_config_get = bcm2835_pinconf_get,
  836. .pin_config_set = bcm2835_pinconf_set,
  837. };
  838. static struct pinctrl_desc bcm2835_pinctrl_desc = {
  839. .name = MODULE_NAME,
  840. .pins = bcm2835_gpio_pins,
  841. .npins = ARRAY_SIZE(bcm2835_gpio_pins),
  842. .pctlops = &bcm2835_pctl_ops,
  843. .pmxops = &bcm2835_pmx_ops,
  844. .confops = &bcm2835_pinconf_ops,
  845. .owner = THIS_MODULE,
  846. };
  847. static struct pinctrl_gpio_range bcm2835_pinctrl_gpio_range = {
  848. .name = MODULE_NAME,
  849. .npins = BCM2835_NUM_GPIOS,
  850. };
  851. static int bcm2835_pinctrl_probe(struct platform_device *pdev)
  852. {
  853. struct device *dev = &pdev->dev;
  854. struct device_node *np = dev->of_node;
  855. struct bcm2835_pinctrl *pc;
  856. struct resource iomem;
  857. int err, i;
  858. BUILD_BUG_ON(ARRAY_SIZE(bcm2835_gpio_pins) != BCM2835_NUM_GPIOS);
  859. BUILD_BUG_ON(ARRAY_SIZE(bcm2835_gpio_groups) != BCM2835_NUM_GPIOS);
  860. pc = devm_kzalloc(dev, sizeof(*pc), GFP_KERNEL);
  861. if (!pc)
  862. return -ENOMEM;
  863. platform_set_drvdata(pdev, pc);
  864. pc->dev = dev;
  865. err = of_address_to_resource(np, 0, &iomem);
  866. if (err) {
  867. dev_err(dev, "could not get IO memory\n");
  868. return err;
  869. }
  870. pc->base = devm_ioremap_resource(dev, &iomem);
  871. if (IS_ERR(pc->base))
  872. return PTR_ERR(pc->base);
  873. pc->gpio_chip = bcm2835_gpio_chip;
  874. pc->gpio_chip.parent = dev;
  875. pc->gpio_chip.of_node = np;
  876. for (i = 0; i < BCM2835_NUM_BANKS; i++) {
  877. unsigned long events;
  878. unsigned offset;
  879. /* clear event detection flags */
  880. bcm2835_gpio_wr(pc, GPREN0 + i * 4, 0);
  881. bcm2835_gpio_wr(pc, GPFEN0 + i * 4, 0);
  882. bcm2835_gpio_wr(pc, GPHEN0 + i * 4, 0);
  883. bcm2835_gpio_wr(pc, GPLEN0 + i * 4, 0);
  884. bcm2835_gpio_wr(pc, GPAREN0 + i * 4, 0);
  885. bcm2835_gpio_wr(pc, GPAFEN0 + i * 4, 0);
  886. /* clear all the events */
  887. events = bcm2835_gpio_rd(pc, GPEDS0 + i * 4);
  888. for_each_set_bit(offset, &events, 32)
  889. bcm2835_gpio_wr(pc, GPEDS0 + i * 4, BIT(offset));
  890. spin_lock_init(&pc->irq_lock[i]);
  891. }
  892. err = gpiochip_add_data(&pc->gpio_chip, pc);
  893. if (err) {
  894. dev_err(dev, "could not add GPIO chip\n");
  895. return err;
  896. }
  897. err = gpiochip_irqchip_add(&pc->gpio_chip, &bcm2835_gpio_irq_chip,
  898. 0, handle_level_irq, IRQ_TYPE_NONE);
  899. if (err) {
  900. dev_info(dev, "could not add irqchip\n");
  901. return err;
  902. }
  903. for (i = 0; i < BCM2835_NUM_IRQS; i++) {
  904. pc->irq[i] = irq_of_parse_and_map(np, i);
  905. pc->irq_group[i] = i;
  906. /*
  907. * Use the same handler for all groups: this is necessary
  908. * since we use one gpiochip to cover all lines - the
  909. * irq handler then needs to figure out which group and
  910. * bank that was firing the IRQ and look up the per-group
  911. * and bank data.
  912. */
  913. gpiochip_set_chained_irqchip(&pc->gpio_chip,
  914. &bcm2835_gpio_irq_chip,
  915. pc->irq[i],
  916. bcm2835_gpio_irq_handler);
  917. }
  918. pc->pctl_dev = devm_pinctrl_register(dev, &bcm2835_pinctrl_desc, pc);
  919. if (IS_ERR(pc->pctl_dev)) {
  920. gpiochip_remove(&pc->gpio_chip);
  921. return PTR_ERR(pc->pctl_dev);
  922. }
  923. pc->gpio_range = bcm2835_pinctrl_gpio_range;
  924. pc->gpio_range.base = pc->gpio_chip.base;
  925. pc->gpio_range.gc = &pc->gpio_chip;
  926. pinctrl_add_gpio_range(pc->pctl_dev, &pc->gpio_range);
  927. return 0;
  928. }
  929. static int bcm2835_pinctrl_remove(struct platform_device *pdev)
  930. {
  931. struct bcm2835_pinctrl *pc = platform_get_drvdata(pdev);
  932. gpiochip_remove(&pc->gpio_chip);
  933. return 0;
  934. }
  935. static const struct of_device_id bcm2835_pinctrl_match[] = {
  936. { .compatible = "brcm,bcm2835-gpio" },
  937. {}
  938. };
  939. MODULE_DEVICE_TABLE(of, bcm2835_pinctrl_match);
  940. static struct platform_driver bcm2835_pinctrl_driver = {
  941. .probe = bcm2835_pinctrl_probe,
  942. .remove = bcm2835_pinctrl_remove,
  943. .driver = {
  944. .name = MODULE_NAME,
  945. .of_match_table = bcm2835_pinctrl_match,
  946. },
  947. };
  948. module_platform_driver(bcm2835_pinctrl_driver);
  949. MODULE_AUTHOR("Chris Boot, Simon Arlott, Stephen Warren");
  950. MODULE_DESCRIPTION("BCM2835 Pin control driver");
  951. MODULE_LICENSE("GPL");