pinctrl-baytrail.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  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. WARN(value & BYT_DIRECT_IRQ_EN,
  199. "Bad pad config for io mode, force direct_irq_en bit clearing");
  200. /* For level trigges the BYT_TRIG_POS and BYT_TRIG_NEG bits
  201. * are used to indicate high and low level triggering
  202. */
  203. value &= ~(BYT_DIRECT_IRQ_EN | BYT_TRIG_POS | BYT_TRIG_NEG |
  204. BYT_TRIG_LVL);
  205. switch (type) {
  206. case IRQ_TYPE_LEVEL_HIGH:
  207. value |= BYT_TRIG_LVL;
  208. case IRQ_TYPE_EDGE_RISING:
  209. value |= BYT_TRIG_POS;
  210. break;
  211. case IRQ_TYPE_LEVEL_LOW:
  212. value |= BYT_TRIG_LVL;
  213. case IRQ_TYPE_EDGE_FALLING:
  214. value |= BYT_TRIG_NEG;
  215. break;
  216. case IRQ_TYPE_EDGE_BOTH:
  217. value |= (BYT_TRIG_NEG | BYT_TRIG_POS);
  218. break;
  219. }
  220. writel(value, reg);
  221. spin_unlock_irqrestore(&vg->lock, flags);
  222. return 0;
  223. }
  224. static int byt_gpio_get(struct gpio_chip *chip, unsigned offset)
  225. {
  226. void __iomem *reg = byt_gpio_reg(chip, offset, BYT_VAL_REG);
  227. return readl(reg) & BYT_LEVEL;
  228. }
  229. static void byt_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
  230. {
  231. struct byt_gpio *vg = to_byt_gpio(chip);
  232. void __iomem *reg = byt_gpio_reg(chip, offset, BYT_VAL_REG);
  233. unsigned long flags;
  234. u32 old_val;
  235. spin_lock_irqsave(&vg->lock, flags);
  236. old_val = readl(reg);
  237. if (value)
  238. writel(old_val | BYT_LEVEL, reg);
  239. else
  240. writel(old_val & ~BYT_LEVEL, reg);
  241. spin_unlock_irqrestore(&vg->lock, flags);
  242. }
  243. static int byt_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
  244. {
  245. struct byt_gpio *vg = to_byt_gpio(chip);
  246. void __iomem *reg = byt_gpio_reg(chip, offset, BYT_VAL_REG);
  247. unsigned long flags;
  248. u32 value;
  249. spin_lock_irqsave(&vg->lock, flags);
  250. value = readl(reg) | BYT_DIR_MASK;
  251. value &= ~BYT_INPUT_EN; /* active low */
  252. writel(value, reg);
  253. spin_unlock_irqrestore(&vg->lock, flags);
  254. return 0;
  255. }
  256. static int byt_gpio_direction_output(struct gpio_chip *chip,
  257. unsigned gpio, int value)
  258. {
  259. struct byt_gpio *vg = to_byt_gpio(chip);
  260. void __iomem *conf_reg = byt_gpio_reg(chip, gpio, BYT_CONF0_REG);
  261. void __iomem *reg = byt_gpio_reg(chip, gpio, BYT_VAL_REG);
  262. unsigned long flags;
  263. u32 reg_val;
  264. spin_lock_irqsave(&vg->lock, flags);
  265. /*
  266. * Before making any direction modifications, do a check if gpio
  267. * is set for direct IRQ. On baytrail, setting GPIO to output does
  268. * not make sense, so let's at least warn the caller before they shoot
  269. * themselves in the foot.
  270. */
  271. WARN(readl(conf_reg) & BYT_DIRECT_IRQ_EN,
  272. "Potential Error: Setting GPIO with direct_irq_en to output");
  273. reg_val = readl(reg) | BYT_DIR_MASK;
  274. reg_val &= ~(BYT_OUTPUT_EN | BYT_INPUT_EN);
  275. if (value)
  276. writel(reg_val | BYT_LEVEL, reg);
  277. else
  278. writel(reg_val & ~BYT_LEVEL, reg);
  279. spin_unlock_irqrestore(&vg->lock, flags);
  280. return 0;
  281. }
  282. static void byt_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
  283. {
  284. struct byt_gpio *vg = to_byt_gpio(chip);
  285. int i;
  286. unsigned long flags;
  287. u32 conf0, val, offs;
  288. spin_lock_irqsave(&vg->lock, flags);
  289. for (i = 0; i < vg->chip.ngpio; i++) {
  290. const char *pull_str = NULL;
  291. const char *pull = NULL;
  292. const char *label;
  293. offs = vg->range->pins[i] * 16;
  294. conf0 = readl(vg->reg_base + offs + BYT_CONF0_REG);
  295. val = readl(vg->reg_base + offs + BYT_VAL_REG);
  296. label = gpiochip_is_requested(chip, i);
  297. if (!label)
  298. label = "Unrequested";
  299. switch (conf0 & BYT_PULL_ASSIGN_MASK) {
  300. case BYT_PULL_ASSIGN_UP:
  301. pull = "up";
  302. break;
  303. case BYT_PULL_ASSIGN_DOWN:
  304. pull = "down";
  305. break;
  306. }
  307. switch (conf0 & BYT_PULL_STR_MASK) {
  308. case BYT_PULL_STR_2K:
  309. pull_str = "2k";
  310. break;
  311. case BYT_PULL_STR_10K:
  312. pull_str = "10k";
  313. break;
  314. case BYT_PULL_STR_20K:
  315. pull_str = "20k";
  316. break;
  317. case BYT_PULL_STR_40K:
  318. pull_str = "40k";
  319. break;
  320. }
  321. seq_printf(s,
  322. " gpio-%-3d (%-20.20s) %s %s %s pad-%-3d offset:0x%03x mux:%d %s%s%s",
  323. i,
  324. label,
  325. val & BYT_INPUT_EN ? " " : "in",
  326. val & BYT_OUTPUT_EN ? " " : "out",
  327. val & BYT_LEVEL ? "hi" : "lo",
  328. vg->range->pins[i], offs,
  329. conf0 & 0x7,
  330. conf0 & BYT_TRIG_NEG ? " fall" : " ",
  331. conf0 & BYT_TRIG_POS ? " rise" : " ",
  332. conf0 & BYT_TRIG_LVL ? " level" : " ");
  333. if (pull && pull_str)
  334. seq_printf(s, " %-4s %-3s", pull, pull_str);
  335. else
  336. seq_puts(s, " ");
  337. if (conf0 & BYT_IODEN)
  338. seq_puts(s, " open-drain");
  339. seq_puts(s, "\n");
  340. }
  341. spin_unlock_irqrestore(&vg->lock, flags);
  342. }
  343. static void byt_gpio_irq_handler(unsigned irq, struct irq_desc *desc)
  344. {
  345. struct irq_data *data = irq_desc_get_irq_data(desc);
  346. struct byt_gpio *vg = to_byt_gpio(irq_desc_get_handler_data(desc));
  347. struct irq_chip *chip = irq_data_get_irq_chip(data);
  348. u32 base, pin, mask;
  349. void __iomem *reg;
  350. u32 pending;
  351. unsigned virq;
  352. int looplimit = 0;
  353. /* check from GPIO controller which pin triggered the interrupt */
  354. for (base = 0; base < vg->chip.ngpio; base += 32) {
  355. reg = byt_gpio_reg(&vg->chip, base, BYT_INT_STAT_REG);
  356. while ((pending = readl(reg))) {
  357. pin = __ffs(pending);
  358. mask = BIT(pin);
  359. /* Clear before handling so we can't lose an edge */
  360. writel(mask, reg);
  361. virq = irq_find_mapping(vg->chip.irqdomain, base + pin);
  362. generic_handle_irq(virq);
  363. /* In case bios or user sets triggering incorretly a pin
  364. * might remain in "interrupt triggered" state.
  365. */
  366. if (looplimit++ > 32) {
  367. dev_err(&vg->pdev->dev,
  368. "Gpio %d interrupt flood, disabling\n",
  369. base + pin);
  370. reg = byt_gpio_reg(&vg->chip, base + pin,
  371. BYT_CONF0_REG);
  372. mask = readl(reg);
  373. mask &= ~(BYT_TRIG_NEG | BYT_TRIG_POS |
  374. BYT_TRIG_LVL);
  375. writel(mask, reg);
  376. mask = readl(reg); /* flush */
  377. break;
  378. }
  379. }
  380. }
  381. chip->irq_eoi(data);
  382. }
  383. static void byt_irq_unmask(struct irq_data *d)
  384. {
  385. }
  386. static void byt_irq_mask(struct irq_data *d)
  387. {
  388. }
  389. static struct irq_chip byt_irqchip = {
  390. .name = "BYT-GPIO",
  391. .irq_mask = byt_irq_mask,
  392. .irq_unmask = byt_irq_unmask,
  393. .irq_set_type = byt_irq_type,
  394. .flags = IRQCHIP_SKIP_SET_WAKE,
  395. };
  396. static void byt_gpio_irq_init_hw(struct byt_gpio *vg)
  397. {
  398. void __iomem *reg;
  399. u32 base, value;
  400. /* clear interrupt status trigger registers */
  401. for (base = 0; base < vg->chip.ngpio; base += 32) {
  402. reg = byt_gpio_reg(&vg->chip, base, BYT_INT_STAT_REG);
  403. writel(0xffffffff, reg);
  404. /* make sure trigger bits are cleared, if not then a pin
  405. might be misconfigured in bios */
  406. value = readl(reg);
  407. if (value)
  408. dev_err(&vg->pdev->dev,
  409. "GPIO interrupt error, pins misconfigured\n");
  410. }
  411. }
  412. static int byt_gpio_probe(struct platform_device *pdev)
  413. {
  414. struct byt_gpio *vg;
  415. struct gpio_chip *gc;
  416. struct resource *mem_rc, *irq_rc;
  417. struct device *dev = &pdev->dev;
  418. struct acpi_device *acpi_dev;
  419. struct pinctrl_gpio_range *range;
  420. acpi_handle handle = ACPI_HANDLE(dev);
  421. int ret;
  422. if (acpi_bus_get_device(handle, &acpi_dev))
  423. return -ENODEV;
  424. vg = devm_kzalloc(dev, sizeof(struct byt_gpio), GFP_KERNEL);
  425. if (!vg) {
  426. dev_err(&pdev->dev, "can't allocate byt_gpio chip data\n");
  427. return -ENOMEM;
  428. }
  429. for (range = byt_ranges; range->name; range++) {
  430. if (!strcmp(acpi_dev->pnp.unique_id, range->name)) {
  431. vg->chip.ngpio = range->npins;
  432. vg->range = range;
  433. break;
  434. }
  435. }
  436. if (!vg->chip.ngpio || !vg->range)
  437. return -ENODEV;
  438. vg->pdev = pdev;
  439. platform_set_drvdata(pdev, vg);
  440. mem_rc = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  441. vg->reg_base = devm_ioremap_resource(dev, mem_rc);
  442. if (IS_ERR(vg->reg_base))
  443. return PTR_ERR(vg->reg_base);
  444. spin_lock_init(&vg->lock);
  445. gc = &vg->chip;
  446. gc->label = dev_name(&pdev->dev);
  447. gc->owner = THIS_MODULE;
  448. gc->request = byt_gpio_request;
  449. gc->free = byt_gpio_free;
  450. gc->direction_input = byt_gpio_direction_input;
  451. gc->direction_output = byt_gpio_direction_output;
  452. gc->get = byt_gpio_get;
  453. gc->set = byt_gpio_set;
  454. gc->dbg_show = byt_gpio_dbg_show;
  455. gc->base = -1;
  456. gc->can_sleep = false;
  457. gc->dev = dev;
  458. ret = gpiochip_add(gc);
  459. if (ret) {
  460. dev_err(&pdev->dev, "failed adding byt-gpio chip\n");
  461. return ret;
  462. }
  463. /* set up interrupts */
  464. irq_rc = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
  465. if (irq_rc && irq_rc->start) {
  466. byt_gpio_irq_init_hw(vg);
  467. ret = gpiochip_irqchip_add(gc, &byt_irqchip, 0,
  468. handle_simple_irq, IRQ_TYPE_NONE);
  469. if (ret) {
  470. dev_err(dev, "failed to add irqchip\n");
  471. gpiochip_remove(gc);
  472. return ret;
  473. }
  474. gpiochip_set_chained_irqchip(gc, &byt_irqchip,
  475. (unsigned)irq_rc->start,
  476. byt_gpio_irq_handler);
  477. }
  478. pm_runtime_enable(dev);
  479. return 0;
  480. }
  481. static int byt_gpio_runtime_suspend(struct device *dev)
  482. {
  483. return 0;
  484. }
  485. static int byt_gpio_runtime_resume(struct device *dev)
  486. {
  487. return 0;
  488. }
  489. static const struct dev_pm_ops byt_gpio_pm_ops = {
  490. .runtime_suspend = byt_gpio_runtime_suspend,
  491. .runtime_resume = byt_gpio_runtime_resume,
  492. };
  493. static const struct acpi_device_id byt_gpio_acpi_match[] = {
  494. { "INT33B2", 0 },
  495. { "INT33FC", 0 },
  496. { }
  497. };
  498. MODULE_DEVICE_TABLE(acpi, byt_gpio_acpi_match);
  499. static int byt_gpio_remove(struct platform_device *pdev)
  500. {
  501. struct byt_gpio *vg = platform_get_drvdata(pdev);
  502. pm_runtime_disable(&pdev->dev);
  503. gpiochip_remove(&vg->chip);
  504. return 0;
  505. }
  506. static struct platform_driver byt_gpio_driver = {
  507. .probe = byt_gpio_probe,
  508. .remove = byt_gpio_remove,
  509. .driver = {
  510. .name = "byt_gpio",
  511. .pm = &byt_gpio_pm_ops,
  512. .acpi_match_table = ACPI_PTR(byt_gpio_acpi_match),
  513. },
  514. };
  515. static int __init byt_gpio_init(void)
  516. {
  517. return platform_driver_register(&byt_gpio_driver);
  518. }
  519. subsys_initcall(byt_gpio_init);
  520. static void __exit byt_gpio_exit(void)
  521. {
  522. platform_driver_unregister(&byt_gpio_driver);
  523. }
  524. module_exit(byt_gpio_exit);