H Hartley Sweeten | e06003a | 2009-04-18 23:43:57 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Driver for the Cirrus EP93xx matrix keypad controller. |
| 3 | * |
| 4 | * Copyright (c) 2008 H Hartley Sweeten <hsweeten@visionengravers.com> |
| 5 | * |
| 6 | * Based on the pxa27x matrix keypad controller by Rodolfo Giometti. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License version 2 as |
| 10 | * published by the Free Software Foundation. |
| 11 | * |
| 12 | * NOTE: |
| 13 | * |
| 14 | * The 3-key reset is triggered by pressing the 3 keys in |
| 15 | * Row 0, Columns 2, 4, and 7 at the same time. This action can |
| 16 | * be disabled by setting the EP93XX_KEYPAD_DISABLE_3_KEY flag. |
| 17 | * |
| 18 | * Normal operation for the matrix does not autorepeat the key press. |
| 19 | * This action can be enabled by setting the EP93XX_KEYPAD_AUTOREPEAT |
| 20 | * flag. |
| 21 | */ |
| 22 | |
| 23 | #include <linux/platform_device.h> |
| 24 | #include <linux/interrupt.h> |
H Hartley Sweeten | e06003a | 2009-04-18 23:43:57 -0700 | [diff] [blame] | 25 | #include <linux/clk.h> |
H Hartley Sweeten | 60214f0 | 2009-12-15 08:39:51 -0800 | [diff] [blame] | 26 | #include <linux/io.h> |
| 27 | #include <linux/input/matrix_keypad.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 28 | #include <linux/slab.h> |
H Hartley Sweeten | e06003a | 2009-04-18 23:43:57 -0700 | [diff] [blame] | 29 | |
| 30 | #include <mach/hardware.h> |
H Hartley Sweeten | e06003a | 2009-04-18 23:43:57 -0700 | [diff] [blame] | 31 | #include <mach/ep93xx_keypad.h> |
| 32 | |
| 33 | /* |
| 34 | * Keypad Interface Register offsets |
| 35 | */ |
| 36 | #define KEY_INIT 0x00 /* Key Scan Initialization register */ |
| 37 | #define KEY_DIAG 0x04 /* Key Scan Diagnostic register */ |
| 38 | #define KEY_REG 0x08 /* Key Value Capture register */ |
| 39 | |
| 40 | /* Key Scan Initialization Register bit defines */ |
| 41 | #define KEY_INIT_DBNC_MASK (0x00ff0000) |
| 42 | #define KEY_INIT_DBNC_SHIFT (16) |
| 43 | #define KEY_INIT_DIS3KY (1<<15) |
| 44 | #define KEY_INIT_DIAG (1<<14) |
| 45 | #define KEY_INIT_BACK (1<<13) |
| 46 | #define KEY_INIT_T2 (1<<12) |
| 47 | #define KEY_INIT_PRSCL_MASK (0x000003ff) |
| 48 | #define KEY_INIT_PRSCL_SHIFT (0) |
| 49 | |
| 50 | /* Key Scan Diagnostic Register bit defines */ |
| 51 | #define KEY_DIAG_MASK (0x0000003f) |
| 52 | #define KEY_DIAG_SHIFT (0) |
| 53 | |
| 54 | /* Key Value Capture Register bit defines */ |
| 55 | #define KEY_REG_K (1<<15) |
| 56 | #define KEY_REG_INT (1<<14) |
| 57 | #define KEY_REG_2KEYS (1<<13) |
| 58 | #define KEY_REG_1KEY (1<<12) |
| 59 | #define KEY_REG_KEY2_MASK (0x00000fc0) |
| 60 | #define KEY_REG_KEY2_SHIFT (6) |
| 61 | #define KEY_REG_KEY1_MASK (0x0000003f) |
| 62 | #define KEY_REG_KEY1_SHIFT (0) |
| 63 | |
H Hartley Sweeten | 60214f0 | 2009-12-15 08:39:51 -0800 | [diff] [blame] | 64 | #define EP93XX_MATRIX_SIZE (EP93XX_MATRIX_ROWS * EP93XX_MATRIX_COLS) |
H Hartley Sweeten | e06003a | 2009-04-18 23:43:57 -0700 | [diff] [blame] | 65 | |
| 66 | struct ep93xx_keypad { |
| 67 | struct ep93xx_keypad_platform_data *pdata; |
H Hartley Sweeten | e06003a | 2009-04-18 23:43:57 -0700 | [diff] [blame] | 68 | struct input_dev *input_dev; |
H Hartley Sweeten | 60214f0 | 2009-12-15 08:39:51 -0800 | [diff] [blame] | 69 | struct clk *clk; |
| 70 | |
H Hartley Sweeten | e06003a | 2009-04-18 23:43:57 -0700 | [diff] [blame] | 71 | void __iomem *mmio_base; |
| 72 | |
H Hartley Sweeten | a5abd95 | 2010-01-13 00:34:12 -0800 | [diff] [blame] | 73 | unsigned short keycodes[EP93XX_MATRIX_SIZE]; |
H Hartley Sweeten | e06003a | 2009-04-18 23:43:57 -0700 | [diff] [blame] | 74 | |
| 75 | int key1; |
| 76 | int key2; |
| 77 | |
H Hartley Sweeten | 60214f0 | 2009-12-15 08:39:51 -0800 | [diff] [blame] | 78 | int irq; |
| 79 | |
| 80 | bool enabled; |
H Hartley Sweeten | e06003a | 2009-04-18 23:43:57 -0700 | [diff] [blame] | 81 | }; |
| 82 | |
H Hartley Sweeten | e06003a | 2009-04-18 23:43:57 -0700 | [diff] [blame] | 83 | static irqreturn_t ep93xx_keypad_irq_handler(int irq, void *dev_id) |
| 84 | { |
| 85 | struct ep93xx_keypad *keypad = dev_id; |
| 86 | struct input_dev *input_dev = keypad->input_dev; |
H Hartley Sweeten | 60214f0 | 2009-12-15 08:39:51 -0800 | [diff] [blame] | 87 | unsigned int status; |
H Hartley Sweeten | e06003a | 2009-04-18 23:43:57 -0700 | [diff] [blame] | 88 | int keycode, key1, key2; |
| 89 | |
H Hartley Sweeten | 60214f0 | 2009-12-15 08:39:51 -0800 | [diff] [blame] | 90 | status = __raw_readl(keypad->mmio_base + KEY_REG); |
| 91 | |
H Hartley Sweeten | e06003a | 2009-04-18 23:43:57 -0700 | [diff] [blame] | 92 | keycode = (status & KEY_REG_KEY1_MASK) >> KEY_REG_KEY1_SHIFT; |
H Hartley Sweeten | a5abd95 | 2010-01-13 00:34:12 -0800 | [diff] [blame] | 93 | key1 = keypad->keycodes[keycode]; |
H Hartley Sweeten | e06003a | 2009-04-18 23:43:57 -0700 | [diff] [blame] | 94 | |
| 95 | keycode = (status & KEY_REG_KEY2_MASK) >> KEY_REG_KEY2_SHIFT; |
H Hartley Sweeten | a5abd95 | 2010-01-13 00:34:12 -0800 | [diff] [blame] | 96 | key2 = keypad->keycodes[keycode]; |
H Hartley Sweeten | e06003a | 2009-04-18 23:43:57 -0700 | [diff] [blame] | 97 | |
| 98 | if (status & KEY_REG_2KEYS) { |
| 99 | if (keypad->key1 && key1 != keypad->key1 && key2 != keypad->key1) |
| 100 | input_report_key(input_dev, keypad->key1, 0); |
| 101 | |
| 102 | if (keypad->key2 && key1 != keypad->key2 && key2 != keypad->key2) |
| 103 | input_report_key(input_dev, keypad->key2, 0); |
| 104 | |
| 105 | input_report_key(input_dev, key1, 1); |
| 106 | input_report_key(input_dev, key2, 1); |
| 107 | |
| 108 | keypad->key1 = key1; |
| 109 | keypad->key2 = key2; |
| 110 | |
| 111 | } else if (status & KEY_REG_1KEY) { |
| 112 | if (keypad->key1 && key1 != keypad->key1) |
| 113 | input_report_key(input_dev, keypad->key1, 0); |
| 114 | |
| 115 | if (keypad->key2 && key1 != keypad->key2) |
| 116 | input_report_key(input_dev, keypad->key2, 0); |
| 117 | |
| 118 | input_report_key(input_dev, key1, 1); |
| 119 | |
| 120 | keypad->key1 = key1; |
| 121 | keypad->key2 = 0; |
| 122 | |
| 123 | } else { |
| 124 | input_report_key(input_dev, keypad->key1, 0); |
| 125 | input_report_key(input_dev, keypad->key2, 0); |
| 126 | |
| 127 | keypad->key1 = keypad->key2 = 0; |
| 128 | } |
| 129 | input_sync(input_dev); |
| 130 | |
| 131 | return IRQ_HANDLED; |
| 132 | } |
| 133 | |
| 134 | static void ep93xx_keypad_config(struct ep93xx_keypad *keypad) |
| 135 | { |
| 136 | struct ep93xx_keypad_platform_data *pdata = keypad->pdata; |
| 137 | unsigned int val = 0; |
| 138 | |
H Hartley Sweeten | 60214f0 | 2009-12-15 08:39:51 -0800 | [diff] [blame] | 139 | if (pdata->flags & EP93XX_KEYPAD_KDIV) |
| 140 | clk_set_rate(keypad->clk, EP93XX_KEYTCHCLK_DIV4); |
| 141 | else |
| 142 | clk_set_rate(keypad->clk, EP93XX_KEYTCHCLK_DIV16); |
H Hartley Sweeten | e06003a | 2009-04-18 23:43:57 -0700 | [diff] [blame] | 143 | |
| 144 | if (pdata->flags & EP93XX_KEYPAD_DISABLE_3_KEY) |
| 145 | val |= KEY_INIT_DIS3KY; |
| 146 | if (pdata->flags & EP93XX_KEYPAD_DIAG_MODE) |
| 147 | val |= KEY_INIT_DIAG; |
| 148 | if (pdata->flags & EP93XX_KEYPAD_BACK_DRIVE) |
| 149 | val |= KEY_INIT_BACK; |
| 150 | if (pdata->flags & EP93XX_KEYPAD_TEST_MODE) |
| 151 | val |= KEY_INIT_T2; |
| 152 | |
| 153 | val |= ((pdata->debounce << KEY_INIT_DBNC_SHIFT) & KEY_INIT_DBNC_MASK); |
| 154 | |
| 155 | val |= ((pdata->prescale << KEY_INIT_PRSCL_SHIFT) & KEY_INIT_PRSCL_MASK); |
| 156 | |
H Hartley Sweeten | 60214f0 | 2009-12-15 08:39:51 -0800 | [diff] [blame] | 157 | __raw_writel(val, keypad->mmio_base + KEY_INIT); |
H Hartley Sweeten | e06003a | 2009-04-18 23:43:57 -0700 | [diff] [blame] | 158 | } |
| 159 | |
| 160 | static int ep93xx_keypad_open(struct input_dev *pdev) |
| 161 | { |
| 162 | struct ep93xx_keypad *keypad = input_get_drvdata(pdev); |
| 163 | |
| 164 | if (!keypad->enabled) { |
| 165 | ep93xx_keypad_config(keypad); |
| 166 | clk_enable(keypad->clk); |
H Hartley Sweeten | 60214f0 | 2009-12-15 08:39:51 -0800 | [diff] [blame] | 167 | keypad->enabled = true; |
H Hartley Sweeten | e06003a | 2009-04-18 23:43:57 -0700 | [diff] [blame] | 168 | } |
| 169 | |
| 170 | return 0; |
| 171 | } |
| 172 | |
| 173 | static void ep93xx_keypad_close(struct input_dev *pdev) |
| 174 | { |
| 175 | struct ep93xx_keypad *keypad = input_get_drvdata(pdev); |
| 176 | |
| 177 | if (keypad->enabled) { |
| 178 | clk_disable(keypad->clk); |
H Hartley Sweeten | 60214f0 | 2009-12-15 08:39:51 -0800 | [diff] [blame] | 179 | keypad->enabled = false; |
H Hartley Sweeten | e06003a | 2009-04-18 23:43:57 -0700 | [diff] [blame] | 180 | } |
| 181 | } |
| 182 | |
| 183 | |
| 184 | #ifdef CONFIG_PM |
| 185 | /* |
| 186 | * NOTE: I don't know if this is correct, or will work on the ep93xx. |
| 187 | * |
| 188 | * None of the existing ep93xx drivers have power management support. |
| 189 | * But, this is basically what the pxa27x_keypad driver does. |
| 190 | */ |
| 191 | static int ep93xx_keypad_suspend(struct platform_device *pdev, |
| 192 | pm_message_t state) |
| 193 | { |
| 194 | struct ep93xx_keypad *keypad = platform_get_drvdata(pdev); |
| 195 | struct input_dev *input_dev = keypad->input_dev; |
| 196 | |
| 197 | mutex_lock(&input_dev->mutex); |
| 198 | |
| 199 | if (keypad->enabled) { |
| 200 | clk_disable(keypad->clk); |
H Hartley Sweeten | 60214f0 | 2009-12-15 08:39:51 -0800 | [diff] [blame] | 201 | keypad->enabled = false; |
H Hartley Sweeten | e06003a | 2009-04-18 23:43:57 -0700 | [diff] [blame] | 202 | } |
| 203 | |
| 204 | mutex_unlock(&input_dev->mutex); |
| 205 | |
| 206 | if (device_may_wakeup(&pdev->dev)) |
| 207 | enable_irq_wake(keypad->irq); |
| 208 | |
| 209 | return 0; |
| 210 | } |
| 211 | |
| 212 | static int ep93xx_keypad_resume(struct platform_device *pdev) |
| 213 | { |
| 214 | struct ep93xx_keypad *keypad = platform_get_drvdata(pdev); |
| 215 | struct input_dev *input_dev = keypad->input_dev; |
| 216 | |
| 217 | if (device_may_wakeup(&pdev->dev)) |
| 218 | disable_irq_wake(keypad->irq); |
| 219 | |
| 220 | mutex_lock(&input_dev->mutex); |
| 221 | |
| 222 | if (input_dev->users) { |
| 223 | if (!keypad->enabled) { |
| 224 | ep93xx_keypad_config(keypad); |
| 225 | clk_enable(keypad->clk); |
H Hartley Sweeten | 60214f0 | 2009-12-15 08:39:51 -0800 | [diff] [blame] | 226 | keypad->enabled = true; |
H Hartley Sweeten | e06003a | 2009-04-18 23:43:57 -0700 | [diff] [blame] | 227 | } |
| 228 | } |
| 229 | |
| 230 | mutex_unlock(&input_dev->mutex); |
| 231 | |
| 232 | return 0; |
| 233 | } |
| 234 | #else /* !CONFIG_PM */ |
| 235 | #define ep93xx_keypad_suspend NULL |
| 236 | #define ep93xx_keypad_resume NULL |
| 237 | #endif /* !CONFIG_PM */ |
| 238 | |
| 239 | static int __devinit ep93xx_keypad_probe(struct platform_device *pdev) |
| 240 | { |
| 241 | struct ep93xx_keypad *keypad; |
H Hartley Sweeten | a5abd95 | 2010-01-13 00:34:12 -0800 | [diff] [blame] | 242 | const struct matrix_keymap_data *keymap_data; |
H Hartley Sweeten | e06003a | 2009-04-18 23:43:57 -0700 | [diff] [blame] | 243 | struct input_dev *input_dev; |
| 244 | struct resource *res; |
H Hartley Sweeten | 60214f0 | 2009-12-15 08:39:51 -0800 | [diff] [blame] | 245 | int err; |
H Hartley Sweeten | e06003a | 2009-04-18 23:43:57 -0700 | [diff] [blame] | 246 | |
| 247 | keypad = kzalloc(sizeof(struct ep93xx_keypad), GFP_KERNEL); |
H Hartley Sweeten | 60214f0 | 2009-12-15 08:39:51 -0800 | [diff] [blame] | 248 | if (!keypad) |
H Hartley Sweeten | e06003a | 2009-04-18 23:43:57 -0700 | [diff] [blame] | 249 | return -ENOMEM; |
H Hartley Sweeten | 60214f0 | 2009-12-15 08:39:51 -0800 | [diff] [blame] | 250 | |
| 251 | keypad->pdata = pdev->dev.platform_data; |
| 252 | if (!keypad->pdata) { |
| 253 | err = -EINVAL; |
| 254 | goto failed_free; |
H Hartley Sweeten | e06003a | 2009-04-18 23:43:57 -0700 | [diff] [blame] | 255 | } |
| 256 | |
H Hartley Sweeten | a5abd95 | 2010-01-13 00:34:12 -0800 | [diff] [blame] | 257 | keymap_data = keypad->pdata->keymap_data; |
| 258 | if (!keymap_data) { |
| 259 | err = -EINVAL; |
| 260 | goto failed_free; |
| 261 | } |
| 262 | |
H Hartley Sweeten | 60214f0 | 2009-12-15 08:39:51 -0800 | [diff] [blame] | 263 | keypad->irq = platform_get_irq(pdev, 0); |
| 264 | if (!keypad->irq) { |
H Hartley Sweeten | e06003a | 2009-04-18 23:43:57 -0700 | [diff] [blame] | 265 | err = -ENXIO; |
| 266 | goto failed_free; |
| 267 | } |
| 268 | |
| 269 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 270 | if (!res) { |
H Hartley Sweeten | e06003a | 2009-04-18 23:43:57 -0700 | [diff] [blame] | 271 | err = -ENXIO; |
| 272 | goto failed_free; |
| 273 | } |
| 274 | |
| 275 | res = request_mem_region(res->start, resource_size(res), pdev->name); |
| 276 | if (!res) { |
H Hartley Sweeten | e06003a | 2009-04-18 23:43:57 -0700 | [diff] [blame] | 277 | err = -EBUSY; |
| 278 | goto failed_free; |
| 279 | } |
| 280 | |
| 281 | keypad->mmio_base = ioremap(res->start, resource_size(res)); |
| 282 | if (keypad->mmio_base == NULL) { |
H Hartley Sweeten | e06003a | 2009-04-18 23:43:57 -0700 | [diff] [blame] | 283 | err = -ENXIO; |
| 284 | goto failed_free_mem; |
| 285 | } |
| 286 | |
H Hartley Sweeten | 60214f0 | 2009-12-15 08:39:51 -0800 | [diff] [blame] | 287 | err = ep93xx_keypad_acquire_gpio(pdev); |
| 288 | if (err) |
H Hartley Sweeten | e06003a | 2009-04-18 23:43:57 -0700 | [diff] [blame] | 289 | goto failed_free_io; |
H Hartley Sweeten | 60214f0 | 2009-12-15 08:39:51 -0800 | [diff] [blame] | 290 | |
| 291 | keypad->clk = clk_get(&pdev->dev, NULL); |
| 292 | if (IS_ERR(keypad->clk)) { |
| 293 | err = PTR_ERR(keypad->clk); |
| 294 | goto failed_free_gpio; |
H Hartley Sweeten | e06003a | 2009-04-18 23:43:57 -0700 | [diff] [blame] | 295 | } |
| 296 | |
H Hartley Sweeten | e06003a | 2009-04-18 23:43:57 -0700 | [diff] [blame] | 297 | input_dev = input_allocate_device(); |
| 298 | if (!input_dev) { |
H Hartley Sweeten | e06003a | 2009-04-18 23:43:57 -0700 | [diff] [blame] | 299 | err = -ENOMEM; |
| 300 | goto failed_put_clk; |
| 301 | } |
| 302 | |
| 303 | keypad->input_dev = input_dev; |
| 304 | |
| 305 | input_dev->name = pdev->name; |
| 306 | input_dev->id.bustype = BUS_HOST; |
| 307 | input_dev->open = ep93xx_keypad_open; |
| 308 | input_dev->close = ep93xx_keypad_close; |
| 309 | input_dev->dev.parent = &pdev->dev; |
H Hartley Sweeten | a5abd95 | 2010-01-13 00:34:12 -0800 | [diff] [blame] | 310 | input_dev->keycode = keypad->keycodes; |
| 311 | input_dev->keycodesize = sizeof(keypad->keycodes[0]); |
| 312 | input_dev->keycodemax = ARRAY_SIZE(keypad->keycodes); |
H Hartley Sweeten | e06003a | 2009-04-18 23:43:57 -0700 | [diff] [blame] | 313 | |
| 314 | input_set_drvdata(input_dev, keypad); |
| 315 | |
| 316 | input_dev->evbit[0] = BIT_MASK(EV_KEY); |
| 317 | if (keypad->pdata->flags & EP93XX_KEYPAD_AUTOREPEAT) |
| 318 | input_dev->evbit[0] |= BIT_MASK(EV_REP); |
| 319 | |
H Hartley Sweeten | a5abd95 | 2010-01-13 00:34:12 -0800 | [diff] [blame] | 320 | matrix_keypad_build_keymap(keymap_data, 3, |
| 321 | input_dev->keycode, input_dev->keybit); |
H Hartley Sweeten | e06003a | 2009-04-18 23:43:57 -0700 | [diff] [blame] | 322 | platform_set_drvdata(pdev, keypad); |
| 323 | |
H Hartley Sweeten | 60214f0 | 2009-12-15 08:39:51 -0800 | [diff] [blame] | 324 | err = request_irq(keypad->irq, ep93xx_keypad_irq_handler, |
| 325 | IRQF_DISABLED, pdev->name, keypad); |
| 326 | if (err) |
H Hartley Sweeten | e06003a | 2009-04-18 23:43:57 -0700 | [diff] [blame] | 327 | goto failed_free_dev; |
H Hartley Sweeten | e06003a | 2009-04-18 23:43:57 -0700 | [diff] [blame] | 328 | |
H Hartley Sweeten | e06003a | 2009-04-18 23:43:57 -0700 | [diff] [blame] | 329 | err = input_register_device(input_dev); |
H Hartley Sweeten | 60214f0 | 2009-12-15 08:39:51 -0800 | [diff] [blame] | 330 | if (err) |
H Hartley Sweeten | e06003a | 2009-04-18 23:43:57 -0700 | [diff] [blame] | 331 | goto failed_free_irq; |
H Hartley Sweeten | e06003a | 2009-04-18 23:43:57 -0700 | [diff] [blame] | 332 | |
| 333 | device_init_wakeup(&pdev->dev, 1); |
| 334 | |
| 335 | return 0; |
| 336 | |
| 337 | failed_free_irq: |
H Hartley Sweeten | 60214f0 | 2009-12-15 08:39:51 -0800 | [diff] [blame] | 338 | free_irq(keypad->irq, pdev); |
H Hartley Sweeten | e06003a | 2009-04-18 23:43:57 -0700 | [diff] [blame] | 339 | platform_set_drvdata(pdev, NULL); |
| 340 | failed_free_dev: |
| 341 | input_free_device(input_dev); |
| 342 | failed_put_clk: |
| 343 | clk_put(keypad->clk); |
H Hartley Sweeten | 60214f0 | 2009-12-15 08:39:51 -0800 | [diff] [blame] | 344 | failed_free_gpio: |
| 345 | ep93xx_keypad_release_gpio(pdev); |
H Hartley Sweeten | e06003a | 2009-04-18 23:43:57 -0700 | [diff] [blame] | 346 | failed_free_io: |
H Hartley Sweeten | e06003a | 2009-04-18 23:43:57 -0700 | [diff] [blame] | 347 | iounmap(keypad->mmio_base); |
| 348 | failed_free_mem: |
| 349 | release_mem_region(res->start, resource_size(res)); |
| 350 | failed_free: |
| 351 | kfree(keypad); |
| 352 | return err; |
| 353 | } |
| 354 | |
| 355 | static int __devexit ep93xx_keypad_remove(struct platform_device *pdev) |
| 356 | { |
| 357 | struct ep93xx_keypad *keypad = platform_get_drvdata(pdev); |
| 358 | struct resource *res; |
H Hartley Sweeten | e06003a | 2009-04-18 23:43:57 -0700 | [diff] [blame] | 359 | |
| 360 | free_irq(keypad->irq, pdev); |
| 361 | |
| 362 | platform_set_drvdata(pdev, NULL); |
| 363 | |
| 364 | if (keypad->enabled) |
| 365 | clk_disable(keypad->clk); |
| 366 | clk_put(keypad->clk); |
| 367 | |
| 368 | input_unregister_device(keypad->input_dev); |
| 369 | |
H Hartley Sweeten | 60214f0 | 2009-12-15 08:39:51 -0800 | [diff] [blame] | 370 | ep93xx_keypad_release_gpio(pdev); |
H Hartley Sweeten | e06003a | 2009-04-18 23:43:57 -0700 | [diff] [blame] | 371 | |
| 372 | iounmap(keypad->mmio_base); |
| 373 | |
| 374 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 375 | release_mem_region(res->start, resource_size(res)); |
| 376 | |
| 377 | kfree(keypad); |
| 378 | |
| 379 | return 0; |
| 380 | } |
| 381 | |
| 382 | static struct platform_driver ep93xx_keypad_driver = { |
| 383 | .driver = { |
| 384 | .name = "ep93xx-keypad", |
| 385 | .owner = THIS_MODULE, |
| 386 | }, |
| 387 | .probe = ep93xx_keypad_probe, |
| 388 | .remove = __devexit_p(ep93xx_keypad_remove), |
| 389 | .suspend = ep93xx_keypad_suspend, |
| 390 | .resume = ep93xx_keypad_resume, |
| 391 | }; |
| 392 | |
| 393 | static int __init ep93xx_keypad_init(void) |
| 394 | { |
| 395 | return platform_driver_register(&ep93xx_keypad_driver); |
| 396 | } |
| 397 | |
| 398 | static void __exit ep93xx_keypad_exit(void) |
| 399 | { |
| 400 | platform_driver_unregister(&ep93xx_keypad_driver); |
| 401 | } |
| 402 | |
| 403 | module_init(ep93xx_keypad_init); |
| 404 | module_exit(ep93xx_keypad_exit); |
| 405 | |
| 406 | MODULE_LICENSE("GPL"); |
| 407 | MODULE_AUTHOR("H Hartley Sweeten <hsweeten@visionengravers.com>"); |
| 408 | MODULE_DESCRIPTION("EP93xx Matrix Keypad Controller"); |
| 409 | MODULE_ALIAS("platform:ep93xx-keypad"); |