pinctrl-baytrail.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  1. /*
  2. * Pinctrl GPIO driver for Intel Baytrail
  3. * Copyright (c) 2012-2013, Intel Corporation.
  4. *
  5. * Author: Mathias Nyman <mathias.nyman@linux.intel.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms and conditions of the GNU General Public License,
  9. * version 2, as published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope it will be useful, but WITHOUT
  12. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  14. * more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along with
  17. * this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. */
  21. #include <linux/kernel.h>
  22. #include <linux/module.h>
  23. #include <linux/init.h>
  24. #include <linux/types.h>
  25. #include <linux/bitops.h>
  26. #include <linux/interrupt.h>
  27. #include <linux/gpio.h>
  28. #include <linux/acpi.h>
  29. #include <linux/platform_device.h>
  30. #include <linux/seq_file.h>
  31. #include <linux/io.h>
  32. #include <linux/pm_runtime.h>
  33. #include <linux/pinctrl/pinctrl.h>
  34. /* memory mapped register offsets */
  35. #define BYT_CONF0_REG 0x000
  36. #define BYT_CONF1_REG 0x004
  37. #define BYT_VAL_REG 0x008
  38. #define BYT_DFT_REG 0x00c
  39. #define BYT_INT_STAT_REG 0x800
  40. /* BYT_CONF0_REG register bits */
  41. #define BYT_IODEN BIT(31)
  42. #define BYT_DIRECT_IRQ_EN BIT(27)
  43. #define BYT_TRIG_NEG BIT(26)
  44. #define BYT_TRIG_POS BIT(25)
  45. #define BYT_TRIG_LVL BIT(24)
  46. #define BYT_PULL_STR_SHIFT 9
  47. #define BYT_PULL_STR_MASK (3 << BYT_PULL_STR_SHIFT)
  48. #define BYT_PULL_STR_2K (0 << BYT_PULL_STR_SHIFT)
  49. #define BYT_PULL_STR_10K (1 << BYT_PULL_STR_SHIFT)
  50. #define BYT_PULL_STR_20K (2 << BYT_PULL_STR_SHIFT)
  51. #define BYT_PULL_STR_40K (3 << BYT_PULL_STR_SHIFT)
  52. #define BYT_PULL_ASSIGN_SHIFT 7
  53. #define BYT_PULL_ASSIGN_MASK (3 << BYT_PULL_ASSIGN_SHIFT)
  54. #define BYT_PULL_ASSIGN_UP (1 << BYT_PULL_ASSIGN_SHIFT)
  55. #define BYT_PULL_ASSIGN_DOWN (2 << BYT_PULL_ASSIGN_SHIFT)
  56. #define BYT_PIN_MUX 0x07
  57. /* BYT_VAL_REG register bits */
  58. #define BYT_INPUT_EN BIT(2) /* 0: input enabled (active low)*/
  59. #define BYT_OUTPUT_EN BIT(1) /* 0: output enabled (active low)*/
  60. #define BYT_LEVEL BIT(0)
  61. #define BYT_DIR_MASK (BIT(1) | BIT(2))
  62. #define BYT_TRIG_MASK (BIT(26) | BIT(25) | BIT(24))
  63. #define BYT_NGPIO_SCORE 102
  64. #define BYT_NGPIO_NCORE 28
  65. #define BYT_NGPIO_SUS 44
  66. #define BYT_SCORE_ACPI_UID "1"
  67. #define BYT_NCORE_ACPI_UID "2"
  68. #define BYT_SUS_ACPI_UID "3"
  69. /*
  70. * Baytrail gpio controller consist of three separate sub-controllers called
  71. * SCORE, NCORE and SUS. The sub-controllers are identified by their acpi UID.
  72. *
  73. * GPIO numbering is _not_ ordered meaning that gpio # 0 in ACPI namespace does
  74. * _not_ correspond to the first gpio register at controller's gpio base.
  75. * There is no logic or pattern in mapping gpio numbers to registers (pads) so
  76. * each sub-controller needs to have its own mapping table
  77. */
  78. /* score_pins[gpio_nr] = pad_nr */
  79. static unsigned const score_pins[BYT_NGPIO_SCORE] = {
  80. 85, 89, 93, 96, 99, 102, 98, 101, 34, 37,
  81. 36, 38, 39, 35, 40, 84, 62, 61, 64, 59,
  82. 54, 56, 60, 55, 63, 57, 51, 50, 53, 47,
  83. 52, 49, 48, 43, 46, 41, 45, 42, 58, 44,
  84. 95, 105, 70, 68, 67, 66, 69, 71, 65, 72,
  85. 86, 90, 88, 92, 103, 77, 79, 83, 78, 81,
  86. 80, 82, 13, 12, 15, 14, 17, 18, 19, 16,
  87. 2, 1, 0, 4, 6, 7, 9, 8, 33, 32,
  88. 31, 30, 29, 27, 25, 28, 26, 23, 21, 20,
  89. 24, 22, 5, 3, 10, 11, 106, 87, 91, 104,
  90. 97, 100,
  91. };
  92. static unsigned const ncore_pins[BYT_NGPIO_NCORE] = {
  93. 19, 18, 17, 20, 21, 22, 24, 25, 23, 16,
  94. 14, 15, 12, 26, 27, 1, 4, 8, 11, 0,
  95. 3, 6, 10, 13, 2, 5, 9, 7,
  96. };
  97. static unsigned const sus_pins[BYT_NGPIO_SUS] = {
  98. 29, 33, 30, 31, 32, 34, 36, 35, 38, 37,
  99. 18, 7, 11, 20, 17, 1, 8, 10, 19, 12,
  100. 0, 2, 23, 39, 28, 27, 22, 21, 24, 25,
  101. 26, 51, 56, 54, 49, 55, 48, 57, 50, 58,
  102. 52, 53, 59, 40,
  103. };
  104. static struct pinctrl_gpio_range byt_ranges[] = {
  105. {
  106. .name = BYT_SCORE_ACPI_UID, /* match with acpi _UID in probe */
  107. .npins = BYT_NGPIO_SCORE,
  108. .pins = score_pins,
  109. },
  110. {
  111. .name = BYT_NCORE_ACPI_UID,
  112. .npins = BYT_NGPIO_NCORE,
  113. .pins = ncore_pins,
  114. },
  115. {
  116. .name = BYT_SUS_ACPI_UID,
  117. .npins = BYT_NGPIO_SUS,
  118. .pins = sus_pins,
  119. },
  120. {
  121. },
  122. };
  123. struct byt_gpio {
  124. struct gpio_chip chip;
  125. struct platform_device *pdev;
  126. spinlock_t lock;
  127. void __iomem *reg_base;
  128. struct pinctrl_gpio_range *range;
  129. };
  130. #define to_byt_gpio(c) container_of(c, struct byt_gpio, chip)
  131. static void __iomem *byt_gpio_reg(struct gpio_chip *chip, unsigned offset,
  132. int reg)
  133. {
  134. struct byt_gpio *vg = to_byt_gpio(chip);
  135. u32 reg_offset;
  136. if (reg == BYT_INT_STAT_REG)
  137. reg_offset = (offset / 32) * 4;
  138. else
  139. reg_offset = vg->range->pins[offset] * 16;
  140. return vg->reg_base + reg_offset + reg;
  141. }
  142. static bool is_special_pin(struct byt_gpio *vg, unsigned offset)
  143. {
  144. /* SCORE pin 92-93 */
  145. if (!strcmp(vg->range->name, BYT_SCORE_ACPI_UID) &&
  146. offset >= 92 && offset <= 93)
  147. return true;
  148. /* SUS pin 11-21 */
  149. if (!strcmp(vg->range->name, BYT_SUS_ACPI_UID) &&
  150. offset >= 11 && offset <= 21)
  151. return true;
  152. return false;
  153. }
  154. static int byt_gpio_request(struct gpio_chip *chip, unsigned offset)
  155. {
  156. struct byt_gpio *vg = to_byt_gpio(chip);
  157. void __iomem *reg = byt_gpio_reg(chip, offset, BYT_CONF0_REG);
  158. u32 value;
  159. bool special;
  160. /*
  161. * In most cases, func pin mux 000 means GPIO function.
  162. * But, some pins may have func pin mux 001 represents
  163. * GPIO function. Only allow user to export pin with
  164. * func pin mux preset as GPIO function by BIOS/FW.
  165. */
  166. value = readl(reg) & BYT_PIN_MUX;
  167. special = is_special_pin(vg, offset);
  168. if ((special && value != 1) || (!special && value)) {
  169. dev_err(&vg->pdev->dev,
  170. "pin %u cannot be used as GPIO.\n", offset);
  171. return -EINVAL;
  172. }
  173. pm_runtime_get(&vg->pdev->dev);
  174. return 0;
  175. }
  176. static void byt_gpio_free(struct gpio_chip *chip, unsigned offset)
  177. {
  178. struct byt_gpio *vg = to_byt_gpio(chip);
  179. void __iomem *reg = byt_gpio_reg(&vg->chip, offset, BYT_CONF0_REG);
  180. u32 value;
  181. /* clear interrupt triggering */
  182. value = readl(reg);
  183. value &= ~(BYT_TRIG_POS | BYT_TRIG_NEG | BYT_TRIG_LVL);
  184. writel(value, reg);
  185. pm_runtime_put(&vg->pdev->dev);
  186. }
  187. static int byt_irq_type(struct irq_data *d, unsigned type)
  188. {
  189. struct byt_gpio *vg = to_byt_gpio(irq_data_get_irq_chip_data(d));
  190. u32 offset = irqd_to_hwirq(d);
  191. u32 value;
  192. unsigned long flags;
  193. void __iomem *reg = byt_gpio_reg(&vg->chip, offset, BYT_CONF0_REG);
  194. if (offset >= vg->chip.ngpio)
  195. return -EINVAL;
  196. spin_lock_irqsave(&vg->lock, flags);
  197. value = readl(reg);
  198. /* For level trigges the BYT_TRIG_POS and BYT_TRIG_NEG bits
  199. * are used to indicate high and low level triggering
  200. */
  201. value &= ~(BYT_TRIG_POS | BYT_TRIG_NEG | BYT_TRIG_LVL);
  202. switch (type) {
  203. case IRQ_TYPE_LEVEL_HIGH:
  204. value |= BYT_TRIG_LVL;
  205. case IRQ_TYPE_EDGE_RISING:
  206. value |= BYT_TRIG_POS;
  207. break;
  208. case IRQ_TYPE_LEVEL_LOW:
  209. value |= BYT_TRIG_LVL;
  210. case IRQ_TYPE_EDGE_FALLING:
  211. value |= BYT_TRIG_NEG;
  212. break;
  213. case IRQ_TYPE_EDGE_BOTH:
  214. value |= (BYT_TRIG_NEG | BYT_TRIG_POS);
  215. break;
  216. }
  217. writel(value, reg);
  218. spin_unlock_irqrestore(&vg->lock, flags);
  219. return 0;
  220. }
  221. static int byt_gpio_get(struct gpio_chip *chip, unsigned offset)
  222. {
  223. void __iomem *reg = byt_gpio_reg(chip, offset, BYT_VAL_REG);
  224. return readl(reg) & BYT_LEVEL;
  225. }
  226. static void byt_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
  227. {
  228. struct byt_gpio *vg = to_byt_gpio(chip);
  229. void __iomem *reg = byt_gpio_reg(chip, offset, BYT_VAL_REG);
  230. unsigned long flags;
  231. u32 old_val;
  232. spin_lock_irqsave(&vg->lock, flags);
  233. old_val = readl(reg);
  234. if (value)
  235. writel(old_val | BYT_LEVEL, reg);
  236. else
  237. writel(old_val & ~BYT_LEVEL, reg);
  238. spin_unlock_irqrestore(&vg->lock, flags);
  239. }
  240. static int byt_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
  241. {
  242. struct byt_gpio *vg = to_byt_gpio(chip);
  243. void __iomem *reg = byt_gpio_reg(chip, offset, BYT_VAL_REG);
  244. unsigned long flags;
  245. u32 value;
  246. spin_lock_irqsave(&vg->lock, flags);
  247. value = readl(reg) | BYT_DIR_MASK;
  248. value &= ~BYT_INPUT_EN; /* active low */
  249. writel(value, reg);
  250. spin_unlock_irqrestore(&vg->lock, flags);
  251. return 0;
  252. }
  253. static int byt_gpio_direction_output(struct gpio_chip *chip,
  254. unsigned gpio, int value)
  255. {
  256. struct byt_gpio *vg = to_byt_gpio(chip);
  257. void __iomem *conf_reg = byt_gpio_reg(chip, gpio, BYT_CONF0_REG);
  258. void __iomem *reg = byt_gpio_reg(chip, gpio, BYT_VAL_REG);
  259. unsigned long flags;
  260. u32 reg_val;
  261. spin_lock_irqsave(&vg->lock, flags);
  262. /*
  263. * Before making any direction modifications, do a check if gpio
  264. * is set for direct IRQ. On baytrail, setting GPIO to output does
  265. * not make sense, so let's at least warn the caller before they shoot
  266. * themselves in the foot.
  267. */
  268. WARN(readl(conf_reg) & BYT_DIRECT_IRQ_EN,
  269. "Potential Error: Setting GPIO with direct_irq_en to output");
  270. reg_val = readl(reg) | BYT_DIR_MASK;
  271. reg_val &= ~BYT_OUTPUT_EN;
  272. if (value)
  273. writel(reg_val | BYT_LEVEL, reg);
  274. else
  275. writel(reg_val & ~BYT_LEVEL, reg);
  276. spin_unlock_irqrestore(&vg->lock, flags);
  277. return 0;
  278. }
  279. static void byt_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
  280. {
  281. struct byt_gpio *vg = to_byt_gpio(chip);
  282. int i;
  283. unsigned long flags;
  284. u32 conf0, val, offs;
  285. spin_lock_irqsave(&vg->lock, flags);
  286. for (i = 0; i < vg->chip.ngpio; i++) {
  287. const char *pull_str = NULL;
  288. const char *pull = NULL;
  289. const char *label;
  290. offs = vg->range->pins[i] * 16;
  291. conf0 = readl(vg->reg_base + offs + BYT_CONF0_REG);
  292. val = readl(vg->reg_base + offs + BYT_VAL_REG);
  293. label = gpiochip_is_requested(chip, i);
  294. if (!label)
  295. label = "Unrequested";
  296. switch (conf0 & BYT_PULL_ASSIGN_MASK) {
  297. case BYT_PULL_ASSIGN_UP:
  298. pull = "up";
  299. break;
  300. case BYT_PULL_ASSIGN_DOWN:
  301. pull = "down";
  302. break;
  303. }
  304. switch (conf0 & BYT_PULL_STR_MASK) {
  305. case BYT_PULL_STR_2K:
  306. pull_str = "2k";
  307. break;
  308. case BYT_PULL_STR_10K:
  309. pull_str = "10k";
  310. break;
  311. case BYT_PULL_STR_20K:
  312. pull_str = "20k";
  313. break;
  314. case BYT_PULL_STR_40K:
  315. pull_str = "40k";
  316. break;
  317. }
  318. seq_printf(s,
  319. " gpio-%-3d (%-20.20s) %s %s %s pad-%-3d offset:0x%03x mux:%d %s%s%s",
  320. i,
  321. label,
  322. val & BYT_INPUT_EN ? " " : "in",
  323. val & BYT_OUTPUT_EN ? " " : "out",
  324. val & BYT_LEVEL ? "hi" : "lo",
  325. vg->range->pins[i], offs,
  326. conf0 & 0x7,
  327. conf0 & BYT_TRIG_NEG ? " fall" : " ",
  328. conf0 & BYT_TRIG_POS ? " rise" : " ",
  329. conf0 & BYT_TRIG_LVL ? " level" : " ");
  330. if (pull && pull_str)
  331. seq_printf(s, " %-4s %-3s", pull, pull_str);
  332. else
  333. seq_puts(s, " ");
  334. if (conf0 & BYT_IODEN)
  335. seq_puts(s, " open-drain");
  336. seq_puts(s, "\n");
  337. }
  338. spin_unlock_irqrestore(&vg->lock, flags);
  339. }
  340. static void byt_gpio_irq_handler(unsigned irq, struct irq_desc *desc)
  341. {
  342. struct irq_data *data = irq_desc_get_irq_data(desc);
  343. struct byt_gpio *vg = to_byt_gpio(irq_desc_get_handler_data(desc));
  344. struct irq_chip *chip = irq_data_get_irq_chip(data);
  345. u32 base, pin, mask;
  346. void __iomem *reg;
  347. u32 pending;
  348. unsigned virq;
  349. int looplimit = 0;
  350. /* check from GPIO controller which pin triggered the interrupt */
  351. for (base = 0; base < vg->chip.ngpio; base += 32) {
  352. reg = byt_gpio_reg(&vg->chip, base, BYT_INT_STAT_REG);
  353. while ((pending = readl(reg))) {
  354. pin = __ffs(pending);
  355. mask = BIT(pin);
  356. /* Clear before handling so we can't lose an edge */
  357. writel(mask, reg);
  358. virq = irq_find_mapping(vg->chip.irqdomain, base + pin);
  359. generic_handle_irq(virq);
  360. /* In case bios or user sets triggering incorretly a pin
  361. * might remain in "interrupt triggered" state.
  362. */
  363. if (looplimit++ > 32) {
  364. dev_err(&vg->pdev->dev,
  365. "Gpio %d interrupt flood, disabling\n",
  366. base + pin);
  367. reg = byt_gpio_reg(&vg->chip, base + pin,
  368. BYT_CONF0_REG);
  369. mask = readl(reg);
  370. mask &= ~(BYT_TRIG_NEG | BYT_TRIG_POS |
  371. BYT_TRIG_LVL);
  372. writel(mask, reg);
  373. mask = readl(reg); /* flush */
  374. break;
  375. }
  376. }
  377. }
  378. chip->irq_eoi(data);
  379. }
  380. static void byt_irq_unmask(struct irq_data *d)
  381. {
  382. }
  383. static void byt_irq_mask(struct irq_data *d)
  384. {
  385. }
  386. static struct irq_chip byt_irqchip = {
  387. .name = "BYT-GPIO",
  388. .irq_mask = byt_irq_mask,
  389. .irq_unmask = byt_irq_unmask,
  390. .irq_set_type = byt_irq_type,
  391. .flags = IRQCHIP_SKIP_SET_WAKE,
  392. };
  393. static void byt_gpio_irq_init_hw(struct byt_gpio *vg)
  394. {
  395. void __iomem *reg;
  396. u32 base, value;
  397. /* clear interrupt status trigger registers */
  398. for (base = 0; base < vg->chip.ngpio; base += 32) {
  399. reg = byt_gpio_reg(&vg->chip, base, BYT_INT_STAT_REG);
  400. writel(0xffffffff, reg);
  401. /* make sure trigger bits are cleared, if not then a pin
  402. might be misconfigured in bios */
  403. value = readl(reg);
  404. if (value)
  405. dev_err(&vg->pdev->dev,
  406. "GPIO interrupt error, pins misconfigured\n");
  407. }
  408. }
  409. static int byt_gpio_probe(struct platform_device *pdev)
  410. {
  411. struct byt_gpio *vg;
  412. struct gpio_chip *gc;
  413. struct resource *mem_rc, *irq_rc;
  414. struct device *dev = &pdev->dev;
  415. struct acpi_device *acpi_dev;
  416. struct pinctrl_gpio_range *range;
  417. acpi_handle handle = ACPI_HANDLE(dev);
  418. int ret;
  419. if (acpi_bus_get_device(handle, &acpi_dev))
  420. return -ENODEV;
  421. vg = devm_kzalloc(dev, sizeof(struct byt_gpio), GFP_KERNEL);
  422. if (!vg) {
  423. dev_err(&pdev->dev, "can't allocate byt_gpio chip data\n");
  424. return -ENOMEM;
  425. }
  426. for (range = byt_ranges; range->name; range++) {
  427. if (!strcmp(acpi_dev->pnp.unique_id, range->name)) {
  428. vg->chip.ngpio = range->npins;
  429. vg->range = range;
  430. break;
  431. }
  432. }
  433. if (!vg->chip.ngpio || !vg->range)
  434. return -ENODEV;
  435. vg->pdev = pdev;
  436. platform_set_drvdata(pdev, vg);
  437. mem_rc = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  438. vg->reg_base = devm_ioremap_resource(dev, mem_rc);
  439. if (IS_ERR(vg->reg_base))
  440. return PTR_ERR(vg->reg_base);
  441. spin_lock_init(&vg->lock);
  442. gc = &vg->chip;
  443. gc->label = dev_name(&pdev->dev);
  444. gc->owner = THIS_MODULE;
  445. gc->request = byt_gpio_request;
  446. gc->free = byt_gpio_free;
  447. gc->direction_input = byt_gpio_direction_input;
  448. gc->direction_output = byt_gpio_direction_output;
  449. gc->get = byt_gpio_get;
  450. gc->set = byt_gpio_set;
  451. gc->dbg_show = byt_gpio_dbg_show;
  452. gc->base = -1;
  453. gc->can_sleep = false;
  454. gc->dev = dev;
  455. ret = gpiochip_add(gc);
  456. if (ret) {
  457. dev_err(&pdev->dev, "failed adding byt-gpio chip\n");
  458. return ret;
  459. }
  460. /* set up interrupts */
  461. irq_rc = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
  462. if (irq_rc && irq_rc->start) {
  463. byt_gpio_irq_init_hw(vg);
  464. ret = gpiochip_irqchip_add(gc, &byt_irqchip, 0,
  465. handle_simple_irq, IRQ_TYPE_NONE);
  466. if (ret) {
  467. dev_err(dev, "failed to add irqchip\n");
  468. gpiochip_remove(gc);
  469. return ret;
  470. }
  471. gpiochip_set_chained_irqchip(gc, &byt_irqchip,
  472. (unsigned)irq_rc->start,
  473. byt_gpio_irq_handler);
  474. }
  475. pm_runtime_enable(dev);
  476. return 0;
  477. }
  478. static int byt_gpio_runtime_suspend(struct device *dev)
  479. {
  480. return 0;
  481. }
  482. static int byt_gpio_runtime_resume(struct device *dev)
  483. {
  484. return 0;
  485. }
  486. static const struct dev_pm_ops byt_gpio_pm_ops = {
  487. .runtime_suspend = byt_gpio_runtime_suspend,
  488. .runtime_resume = byt_gpio_runtime_resume,
  489. };
  490. static const struct acpi_device_id byt_gpio_acpi_match[] = {
  491. { "INT33B2", 0 },
  492. { "INT33FC", 0 },
  493. { }
  494. };
  495. MODULE_DEVICE_TABLE(acpi, byt_gpio_acpi_match);
  496. static int byt_gpio_remove(struct platform_device *pdev)
  497. {
  498. struct byt_gpio *vg = platform_get_drvdata(pdev);
  499. pm_runtime_disable(&pdev->dev);
  500. gpiochip_remove(&vg->chip);
  501. return 0;
  502. }
  503. static struct platform_driver byt_gpio_driver = {
  504. .probe = byt_gpio_probe,
  505. .remove = byt_gpio_remove,
  506. .driver = {
  507. .name = "byt_gpio",
  508. .owner = THIS_MODULE,
  509. .pm = &byt_gpio_pm_ops,
  510. .acpi_match_table = ACPI_PTR(byt_gpio_acpi_match),
  511. },
  512. };
  513. static int __init byt_gpio_init(void)
  514. {
  515. return platform_driver_register(&byt_gpio_driver);
  516. }
  517. subsys_initcall(byt_gpio_init);