pxa27x_keypad.c (b0010911d52dc7836a78c9f5c3b32ce4ac05b3c3) | pxa27x_keypad.c (bd96f37895197563bc1d6d6f7c012b3ae7df1c45) |
---|---|
1/* 2 * linux/drivers/input/keyboard/pxa27x_keypad.c 3 * 4 * Driver for the pxa27x matrix keyboard controller. 5 * 6 * Created: Feb 22, 2007 7 * Author: Rodolfo Giometti <giometti@linux.it> 8 * --- 18 unchanged lines hidden (view full) --- 27#include <linux/err.h> 28#include <linux/input/matrix_keypad.h> 29 30#include <asm/mach/arch.h> 31#include <asm/mach/map.h> 32 33#include <mach/hardware.h> 34#include <mach/pxa27x_keypad.h> | 1/* 2 * linux/drivers/input/keyboard/pxa27x_keypad.c 3 * 4 * Driver for the pxa27x matrix keyboard controller. 5 * 6 * Created: Feb 22, 2007 7 * Author: Rodolfo Giometti <giometti@linux.it> 8 * --- 18 unchanged lines hidden (view full) --- 27#include <linux/err.h> 28#include <linux/input/matrix_keypad.h> 29 30#include <asm/mach/arch.h> 31#include <asm/mach/map.h> 32 33#include <mach/hardware.h> 34#include <mach/pxa27x_keypad.h> |
35 | |
36/* 37 * Keypad Controller registers 38 */ 39#define KPC 0x0000 /* Keypad Control register */ 40#define KPDK 0x0008 /* Keypad Direct Key register */ 41#define KPREC 0x0010 /* Keypad Rotary Encoder register */ 42#define KPMK 0x0018 /* Keypad Matrix Key register */ 43#define KPAS 0x0020 /* Keypad Automatic Scan register */ --- 47 unchanged lines hidden (view full) --- 91#define KPAS_RP(n) (((n) >> 4) & 0xf) 92#define KPAS_CP(n) ((n) & 0xf) 93 94#define KPASMKP_MKC_MASK (0xff) 95 96#define keypad_readl(off) __raw_readl(keypad->mmio_base + (off)) 97#define keypad_writel(off, v) __raw_writel((v), keypad->mmio_base + (off)) 98 | 35/* 36 * Keypad Controller registers 37 */ 38#define KPC 0x0000 /* Keypad Control register */ 39#define KPDK 0x0008 /* Keypad Direct Key register */ 40#define KPREC 0x0010 /* Keypad Rotary Encoder register */ 41#define KPMK 0x0018 /* Keypad Matrix Key register */ 42#define KPAS 0x0020 /* Keypad Automatic Scan register */ --- 47 unchanged lines hidden (view full) --- 90#define KPAS_RP(n) (((n) >> 4) & 0xf) 91#define KPAS_CP(n) ((n) & 0xf) 92 93#define KPASMKP_MKC_MASK (0xff) 94 95#define keypad_readl(off) __raw_readl(keypad->mmio_base + (off)) 96#define keypad_writel(off, v) __raw_writel((v), keypad->mmio_base + (off)) 97 |
99#define MAX_MATRIX_KEY_NUM (8 * 8) | 98#define MAX_MATRIX_KEY_NUM (MAX_MATRIX_KEY_ROWS * MAX_MATRIX_KEY_COLS) 99#define MAX_KEYPAD_KEYS (MAX_MATRIX_KEY_NUM + MAX_DIRECT_KEY_NUM) |
100 101struct pxa27x_keypad { 102 struct pxa27x_keypad_platform_data *pdata; 103 104 struct clk *clk; 105 struct input_dev *input_dev; 106 void __iomem *mmio_base; 107 108 int irq; 109 | 100 101struct pxa27x_keypad { 102 struct pxa27x_keypad_platform_data *pdata; 103 104 struct clk *clk; 105 struct input_dev *input_dev; 106 void __iomem *mmio_base; 107 108 int irq; 109 |
110 /* matrix key code map */ 111 unsigned short matrix_keycodes[MAX_MATRIX_KEY_NUM]; | 110 unsigned short keycodes[MAX_KEYPAD_KEYS]; 111 int rotary_rel_code[2]; |
112 113 /* state row bits of each column scan */ 114 uint32_t matrix_key_state[MAX_MATRIX_KEY_COLS]; 115 uint32_t direct_key_state; 116 117 unsigned int direct_key_mask; | 112 113 /* state row bits of each column scan */ 114 uint32_t matrix_key_state[MAX_MATRIX_KEY_COLS]; 115 uint32_t direct_key_state; 116 117 unsigned int direct_key_mask; |
118 119 int rotary_rel_code[2]; 120 int rotary_up_key[2]; 121 int rotary_down_key[2]; | |
122}; 123 124static void pxa27x_keypad_build_keycode(struct pxa27x_keypad *keypad) 125{ 126 struct pxa27x_keypad_platform_data *pdata = keypad->pdata; 127 struct input_dev *input_dev = keypad->input_dev; | 118}; 119 120static void pxa27x_keypad_build_keycode(struct pxa27x_keypad *keypad) 121{ 122 struct pxa27x_keypad_platform_data *pdata = keypad->pdata; 123 struct input_dev *input_dev = keypad->input_dev; |
124 unsigned short keycode; |
|
128 int i; 129 130 for (i = 0; i < pdata->matrix_key_map_size; i++) { 131 unsigned int key = pdata->matrix_key_map[i]; 132 unsigned int row = KEY_ROW(key); 133 unsigned int col = KEY_COL(key); | 125 int i; 126 127 for (i = 0; i < pdata->matrix_key_map_size; i++) { 128 unsigned int key = pdata->matrix_key_map[i]; 129 unsigned int row = KEY_ROW(key); 130 unsigned int col = KEY_COL(key); |
134 unsigned short code = KEY_VAL(key); | 131 unsigned int scancode = MATRIX_SCAN_CODE(row, col, 132 MATRIX_ROW_SHIFT); |
135 | 133 |
136 keypad->matrix_keycodes[(row << 3) + col] = code; 137 __set_bit(code, input_dev->keybit); | 134 keycode = KEY_VAL(key); 135 keypad->keycodes[scancode] = keycode; 136 __set_bit(keycode, input_dev->keybit); |
138 } | 137 } |
139 __clear_bit(KEY_RESERVED, input_dev->keybit); | |
140 | 138 |
141 for (i = 0; i < pdata->direct_key_num; i++) 142 __set_bit(pdata->direct_key_map[i], input_dev->keybit); | 139 for (i = 0; i < pdata->direct_key_num; i++) { 140 keycode = pdata->direct_key_map[i]; 141 keypad->keycodes[MAX_MATRIX_KEY_NUM + i] = keycode; 142 __set_bit(keycode, input_dev->keybit); 143 } |
143 | 144 |
144 keypad->rotary_up_key[0] = pdata->rotary0_up_key; 145 keypad->rotary_up_key[1] = pdata->rotary1_up_key; 146 keypad->rotary_down_key[0] = pdata->rotary0_down_key; 147 keypad->rotary_down_key[1] = pdata->rotary1_down_key; 148 keypad->rotary_rel_code[0] = pdata->rotary0_rel_code; 149 keypad->rotary_rel_code[1] = pdata->rotary1_rel_code; 150 | |
151 if (pdata->enable_rotary0) { 152 if (pdata->rotary0_up_key && pdata->rotary0_down_key) { | 145 if (pdata->enable_rotary0) { 146 if (pdata->rotary0_up_key && pdata->rotary0_down_key) { |
153 __set_bit(pdata->rotary0_up_key, input_dev->keybit); 154 __set_bit(pdata->rotary0_down_key, input_dev->keybit); 155 } else | 147 keycode = pdata->rotary0_up_key; 148 keypad->keycodes[MAX_MATRIX_KEY_NUM + 0] = keycode; 149 __set_bit(keycode, input_dev->keybit); 150 151 keycode = pdata->rotary0_down_key; 152 keypad->keycodes[MAX_MATRIX_KEY_NUM + 1] = keycode; 153 __set_bit(keycode, input_dev->keybit); 154 155 keypad->rotary_rel_code[0] = -1; 156 } else { 157 keypad->rotary_rel_code[0] = pdata->rotary0_rel_code; |
156 __set_bit(pdata->rotary0_rel_code, input_dev->relbit); | 158 __set_bit(pdata->rotary0_rel_code, input_dev->relbit); |
159 } |
|
157 } 158 159 if (pdata->enable_rotary1) { 160 if (pdata->rotary1_up_key && pdata->rotary1_down_key) { | 160 } 161 162 if (pdata->enable_rotary1) { 163 if (pdata->rotary1_up_key && pdata->rotary1_down_key) { |
161 __set_bit(pdata->rotary1_up_key, input_dev->keybit); 162 __set_bit(pdata->rotary1_down_key, input_dev->keybit); 163 } else | 164 keycode = pdata->rotary1_up_key; 165 keypad->keycodes[MAX_MATRIX_KEY_NUM + 2] = keycode; 166 __set_bit(keycode, input_dev->keybit); 167 168 keycode = pdata->rotary1_down_key; 169 keypad->keycodes[MAX_MATRIX_KEY_NUM + 3] = keycode; 170 __set_bit(keycode, input_dev->keybit); 171 172 keypad->rotary_rel_code[1] = -1; 173 } else { 174 keypad->rotary_rel_code[1] = pdata->rotary1_rel_code; |
164 __set_bit(pdata->rotary1_rel_code, input_dev->relbit); | 175 __set_bit(pdata->rotary1_rel_code, input_dev->relbit); |
176 } |
|
165 } | 177 } |
166} | |
167 | 178 |
168static inline unsigned int lookup_matrix_keycode( 169 struct pxa27x_keypad *keypad, int row, int col) 170{ 171 return keypad->matrix_keycodes[(row << 3) + col]; | 179 __clear_bit(KEY_RESERVED, input_dev->keybit); |
172} 173 174static void pxa27x_keypad_scan_matrix(struct pxa27x_keypad *keypad) 175{ 176 struct pxa27x_keypad_platform_data *pdata = keypad->pdata; | 180} 181 182static void pxa27x_keypad_scan_matrix(struct pxa27x_keypad *keypad) 183{ 184 struct pxa27x_keypad_platform_data *pdata = keypad->pdata; |
185 struct input_dev *input_dev = keypad->input_dev; |
|
177 int row, col, num_keys_pressed = 0; 178 uint32_t new_state[MAX_MATRIX_KEY_COLS]; 179 uint32_t kpas = keypad_readl(KPAS); 180 181 num_keys_pressed = KPAS_MUKP(kpas); 182 183 memset(new_state, 0, sizeof(new_state)); 184 --- 26 unchanged lines hidden (view full) --- 211 new_state[4] = kpasmkp2 & KPASMKP_MKC_MASK; 212 new_state[5] = (kpasmkp2 >> 16) & KPASMKP_MKC_MASK; 213 new_state[6] = kpasmkp3 & KPASMKP_MKC_MASK; 214 new_state[7] = (kpasmkp3 >> 16) & KPASMKP_MKC_MASK; 215 } 216scan: 217 for (col = 0; col < pdata->matrix_key_cols; col++) { 218 uint32_t bits_changed; | 186 int row, col, num_keys_pressed = 0; 187 uint32_t new_state[MAX_MATRIX_KEY_COLS]; 188 uint32_t kpas = keypad_readl(KPAS); 189 190 num_keys_pressed = KPAS_MUKP(kpas); 191 192 memset(new_state, 0, sizeof(new_state)); 193 --- 26 unchanged lines hidden (view full) --- 220 new_state[4] = kpasmkp2 & KPASMKP_MKC_MASK; 221 new_state[5] = (kpasmkp2 >> 16) & KPASMKP_MKC_MASK; 222 new_state[6] = kpasmkp3 & KPASMKP_MKC_MASK; 223 new_state[7] = (kpasmkp3 >> 16) & KPASMKP_MKC_MASK; 224 } 225scan: 226 for (col = 0; col < pdata->matrix_key_cols; col++) { 227 uint32_t bits_changed; |
228 int code; |
|
219 220 bits_changed = keypad->matrix_key_state[col] ^ new_state[col]; 221 if (bits_changed == 0) 222 continue; 223 224 for (row = 0; row < pdata->matrix_key_rows; row++) { 225 if ((bits_changed & (1 << row)) == 0) 226 continue; 227 | 229 230 bits_changed = keypad->matrix_key_state[col] ^ new_state[col]; 231 if (bits_changed == 0) 232 continue; 233 234 for (row = 0; row < pdata->matrix_key_rows; row++) { 235 if ((bits_changed & (1 << row)) == 0) 236 continue; 237 |
228 input_report_key(keypad->input_dev, 229 lookup_matrix_keycode(keypad, row, col), 230 new_state[col] & (1 << row)); | 238 code = MATRIX_SCAN_CODE(row, col, MATRIX_ROW_SHIFT); 239 input_event(input_dev, EV_MSC, MSC_SCAN, code); 240 input_report_key(input_dev, keypad->keycodes[code], 241 new_state[col] & (1 << row)); |
231 } 232 } | 242 } 243 } |
233 input_sync(keypad->input_dev); | 244 input_sync(input_dev); |
234 memcpy(keypad->matrix_key_state, new_state, sizeof(new_state)); 235} 236 237#define DEFAULT_KPREC (0x007f007f) 238 239static inline int rotary_delta(uint32_t kprec) 240{ 241 if (kprec & KPREC_OF0) --- 6 unchanged lines hidden (view full) --- 248 249static void report_rotary_event(struct pxa27x_keypad *keypad, int r, int delta) 250{ 251 struct input_dev *dev = keypad->input_dev; 252 253 if (delta == 0) 254 return; 255 | 245 memcpy(keypad->matrix_key_state, new_state, sizeof(new_state)); 246} 247 248#define DEFAULT_KPREC (0x007f007f) 249 250static inline int rotary_delta(uint32_t kprec) 251{ 252 if (kprec & KPREC_OF0) --- 6 unchanged lines hidden (view full) --- 259 260static void report_rotary_event(struct pxa27x_keypad *keypad, int r, int delta) 261{ 262 struct input_dev *dev = keypad->input_dev; 263 264 if (delta == 0) 265 return; 266 |
256 if (keypad->rotary_up_key[r] && keypad->rotary_down_key[r]) { 257 int keycode = (delta > 0) ? keypad->rotary_up_key[r] : 258 keypad->rotary_down_key[r]; | 267 if (keypad->rotary_rel_code[r] == -1) { 268 int code = MAX_MATRIX_KEY_NUM + 2 * r + (delta > 0 ? 0 : 1); 269 unsigned char keycode = keypad->keycodes[code]; |
259 260 /* simulate a press-n-release */ | 270 271 /* simulate a press-n-release */ |
272 input_event(dev, EV_MSC, MSC_SCAN, code); |
|
261 input_report_key(dev, keycode, 1); 262 input_sync(dev); | 273 input_report_key(dev, keycode, 1); 274 input_sync(dev); |
275 input_event(dev, EV_MSC, MSC_SCAN, code); |
|
263 input_report_key(dev, keycode, 0); 264 input_sync(dev); 265 } else { 266 input_report_rel(dev, keypad->rotary_rel_code[r], delta); 267 input_sync(dev); 268 } 269} 270 --- 11 unchanged lines hidden (view full) --- 282 283 if (pdata->enable_rotary1) 284 report_rotary_event(keypad, 1, rotary_delta(kprec >> 16)); 285} 286 287static void pxa27x_keypad_scan_direct(struct pxa27x_keypad *keypad) 288{ 289 struct pxa27x_keypad_platform_data *pdata = keypad->pdata; | 276 input_report_key(dev, keycode, 0); 277 input_sync(dev); 278 } else { 279 input_report_rel(dev, keypad->rotary_rel_code[r], delta); 280 input_sync(dev); 281 } 282} 283 --- 11 unchanged lines hidden (view full) --- 295 296 if (pdata->enable_rotary1) 297 report_rotary_event(keypad, 1, rotary_delta(kprec >> 16)); 298} 299 300static void pxa27x_keypad_scan_direct(struct pxa27x_keypad *keypad) 301{ 302 struct pxa27x_keypad_platform_data *pdata = keypad->pdata; |
303 struct input_dev *input_dev = keypad->input_dev; |
|
290 unsigned int new_state; 291 uint32_t kpdk, bits_changed; 292 int i; 293 294 kpdk = keypad_readl(KPDK); 295 296 if (pdata->enable_rotary0 || pdata->enable_rotary1) 297 pxa27x_keypad_scan_rotary(keypad); 298 | 304 unsigned int new_state; 305 uint32_t kpdk, bits_changed; 306 int i; 307 308 kpdk = keypad_readl(KPDK); 309 310 if (pdata->enable_rotary0 || pdata->enable_rotary1) 311 pxa27x_keypad_scan_rotary(keypad); 312 |
299 if (pdata->direct_key_map == NULL) 300 return; 301 | |
302 new_state = KPDK_DK(kpdk) & keypad->direct_key_mask; 303 bits_changed = keypad->direct_key_state ^ new_state; 304 305 if (bits_changed == 0) 306 return; 307 308 for (i = 0; i < pdata->direct_key_num; i++) { | 313 new_state = KPDK_DK(kpdk) & keypad->direct_key_mask; 314 bits_changed = keypad->direct_key_state ^ new_state; 315 316 if (bits_changed == 0) 317 return; 318 319 for (i = 0; i < pdata->direct_key_num; i++) { |
309 if (bits_changed & (1 << i)) 310 input_report_key(keypad->input_dev, 311 pdata->direct_key_map[i], 312 (new_state & (1 << i))); | 320 if (bits_changed & (1 << i)) { 321 int code = MAX_MATRIX_KEY_NUM + i; 322 323 input_event(input_dev, EV_MSC, MSC_SCAN, code); 324 input_report_key(input_dev, keypad->keycodes[code], 325 new_state & (1 << i)); 326 } |
313 } | 327 } |
314 input_sync(keypad->input_dev); | 328 input_sync(input_dev); |
315 keypad->direct_key_state = new_state; 316} 317 318static irqreturn_t pxa27x_keypad_irq_handler(int irq, void *dev_id) 319{ 320 struct pxa27x_keypad *keypad = dev_id; 321 unsigned long kpc = keypad_readl(KPC); 322 --- 104 unchanged lines hidden (view full) --- 427static const struct dev_pm_ops pxa27x_keypad_pm_ops = { 428 .suspend = pxa27x_keypad_suspend, 429 .resume = pxa27x_keypad_resume, 430}; 431#endif 432 433static int __devinit pxa27x_keypad_probe(struct platform_device *pdev) 434{ | 329 keypad->direct_key_state = new_state; 330} 331 332static irqreturn_t pxa27x_keypad_irq_handler(int irq, void *dev_id) 333{ 334 struct pxa27x_keypad *keypad = dev_id; 335 unsigned long kpc = keypad_readl(KPC); 336 --- 104 unchanged lines hidden (view full) --- 441static const struct dev_pm_ops pxa27x_keypad_pm_ops = { 442 .suspend = pxa27x_keypad_suspend, 443 .resume = pxa27x_keypad_resume, 444}; 445#endif 446 447static int __devinit pxa27x_keypad_probe(struct platform_device *pdev) 448{ |
449 struct pxa27x_keypad_platform_data *pdata = pdev->dev.platform_data; |
|
435 struct pxa27x_keypad *keypad; 436 struct input_dev *input_dev; 437 struct resource *res; 438 int irq, error; 439 | 450 struct pxa27x_keypad *keypad; 451 struct input_dev *input_dev; 452 struct resource *res; 453 int irq, error; 454 |
440 keypad = kzalloc(sizeof(struct pxa27x_keypad), GFP_KERNEL); 441 if (keypad == NULL) { 442 dev_err(&pdev->dev, "failed to allocate driver data\n"); 443 return -ENOMEM; 444 } 445 446 keypad->pdata = pdev->dev.platform_data; 447 if (keypad->pdata == NULL) { | 455 if (pdata == NULL) { |
448 dev_err(&pdev->dev, "no platform data defined\n"); | 456 dev_err(&pdev->dev, "no platform data defined\n"); |
449 error = -EINVAL; 450 goto failed_free; | 457 return -EINVAL; |
451 } 452 453 irq = platform_get_irq(pdev, 0); 454 if (irq < 0) { 455 dev_err(&pdev->dev, "failed to get keypad irq\n"); | 458 } 459 460 irq = platform_get_irq(pdev, 0); 461 if (irq < 0) { 462 dev_err(&pdev->dev, "failed to get keypad irq\n"); |
456 error = -ENXIO; 457 goto failed_free; | 463 return -ENXIO; |
458 } 459 460 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 461 if (res == NULL) { 462 dev_err(&pdev->dev, "failed to get I/O memory\n"); | 464 } 465 466 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 467 if (res == NULL) { 468 dev_err(&pdev->dev, "failed to get I/O memory\n"); |
463 error = -ENXIO; | 469 return -ENXIO; 470 } 471 472 keypad = kzalloc(sizeof(struct pxa27x_keypad), GFP_KERNEL); 473 input_dev = input_allocate_device(); 474 if (!keypad || !input_dev) { 475 dev_err(&pdev->dev, "failed to allocate memory\n"); 476 error = -ENOMEM; |
464 goto failed_free; 465 } 466 | 477 goto failed_free; 478 } 479 |
480 keypad->pdata = pdata; 481 keypad->input_dev = input_dev; 482 keypad->irq = irq; 483 |
|
467 res = request_mem_region(res->start, resource_size(res), pdev->name); 468 if (res == NULL) { 469 dev_err(&pdev->dev, "failed to request I/O memory\n"); 470 error = -EBUSY; 471 goto failed_free; 472 } 473 474 keypad->mmio_base = ioremap(res->start, resource_size(res)); --- 5 unchanged lines hidden (view full) --- 480 481 keypad->clk = clk_get(&pdev->dev, NULL); 482 if (IS_ERR(keypad->clk)) { 483 dev_err(&pdev->dev, "failed to get keypad clock\n"); 484 error = PTR_ERR(keypad->clk); 485 goto failed_free_io; 486 } 487 | 484 res = request_mem_region(res->start, resource_size(res), pdev->name); 485 if (res == NULL) { 486 dev_err(&pdev->dev, "failed to request I/O memory\n"); 487 error = -EBUSY; 488 goto failed_free; 489 } 490 491 keypad->mmio_base = ioremap(res->start, resource_size(res)); --- 5 unchanged lines hidden (view full) --- 497 498 keypad->clk = clk_get(&pdev->dev, NULL); 499 if (IS_ERR(keypad->clk)) { 500 dev_err(&pdev->dev, "failed to get keypad clock\n"); 501 error = PTR_ERR(keypad->clk); 502 goto failed_free_io; 503 } 504 |
488 /* Create and register the input driver. */ 489 input_dev = input_allocate_device(); 490 if (!input_dev) { 491 dev_err(&pdev->dev, "failed to allocate input device\n"); 492 error = -ENOMEM; 493 goto failed_put_clk; 494 } 495 | |
496 input_dev->name = pdev->name; 497 input_dev->id.bustype = BUS_HOST; 498 input_dev->open = pxa27x_keypad_open; 499 input_dev->close = pxa27x_keypad_close; 500 input_dev->dev.parent = &pdev->dev; 501 | 505 input_dev->name = pdev->name; 506 input_dev->id.bustype = BUS_HOST; 507 input_dev->open = pxa27x_keypad_open; 508 input_dev->close = pxa27x_keypad_close; 509 input_dev->dev.parent = &pdev->dev; 510 |
502 keypad->input_dev = input_dev; | 511 input_dev->keycode = keypad->keycodes; 512 input_dev->keycodesize = sizeof(keypad->keycodes[0]); 513 input_dev->keycodemax = ARRAY_SIZE(keypad->keycodes); 514 |
503 input_set_drvdata(input_dev, keypad); 504 505 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP); | 515 input_set_drvdata(input_dev, keypad); 516 517 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP); |
506 if ((keypad->pdata->enable_rotary0 && 507 keypad->pdata->rotary0_rel_code) || 508 (keypad->pdata->enable_rotary1 && 509 keypad->pdata->rotary1_rel_code)) { 510 input_dev->evbit[0] |= BIT_MASK(EV_REL); 511 } | 518 input_set_capability(input_dev, EV_MSC, MSC_SCAN); |
512 513 pxa27x_keypad_build_keycode(keypad); | 519 520 pxa27x_keypad_build_keycode(keypad); |
514 platform_set_drvdata(pdev, keypad); | |
515 | 521 |
522 if ((pdata->enable_rotary0 && keypad->rotary_rel_code[0] != -1) || 523 (pdata->enable_rotary1 && keypad->rotary_rel_code[1] != -1)) { 524 input_dev->evbit[0] |= BIT_MASK(EV_REL); 525 } 526 |
|
516 error = request_irq(irq, pxa27x_keypad_irq_handler, IRQF_DISABLED, 517 pdev->name, keypad); 518 if (error) { 519 dev_err(&pdev->dev, "failed to request IRQ\n"); | 527 error = request_irq(irq, pxa27x_keypad_irq_handler, IRQF_DISABLED, 528 pdev->name, keypad); 529 if (error) { 530 dev_err(&pdev->dev, "failed to request IRQ\n"); |
520 goto failed_free_dev; | 531 goto failed_put_clk; |
521 } 522 | 532 } 533 |
523 keypad->irq = irq; 524 | |
525 /* Register the input device */ 526 error = input_register_device(input_dev); 527 if (error) { 528 dev_err(&pdev->dev, "failed to register input device\n"); 529 goto failed_free_irq; 530 } 531 | 534 /* Register the input device */ 535 error = input_register_device(input_dev); 536 if (error) { 537 dev_err(&pdev->dev, "failed to register input device\n"); 538 goto failed_free_irq; 539 } 540 |
541 platform_set_drvdata(pdev, keypad); |
|
532 device_init_wakeup(&pdev->dev, 1); 533 534 return 0; 535 536failed_free_irq: 537 free_irq(irq, pdev); | 542 device_init_wakeup(&pdev->dev, 1); 543 544 return 0; 545 546failed_free_irq: 547 free_irq(irq, pdev); |
538 platform_set_drvdata(pdev, NULL); 539failed_free_dev: 540 input_free_device(input_dev); | |
541failed_put_clk: 542 clk_put(keypad->clk); 543failed_free_io: 544 iounmap(keypad->mmio_base); 545failed_free_mem: 546 release_mem_region(res->start, resource_size(res)); 547failed_free: | 548failed_put_clk: 549 clk_put(keypad->clk); 550failed_free_io: 551 iounmap(keypad->mmio_base); 552failed_free_mem: 553 release_mem_region(res->start, resource_size(res)); 554failed_free: |
555 input_free_device(input_dev); |
|
548 kfree(keypad); 549 return error; 550} 551 552static int __devexit pxa27x_keypad_remove(struct platform_device *pdev) 553{ 554 struct pxa27x_keypad *keypad = platform_get_drvdata(pdev); 555 struct resource *res; --- 6 unchanged lines hidden (view full) --- 562 563 iounmap(keypad->mmio_base); 564 565 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 566 release_mem_region(res->start, resource_size(res)); 567 568 platform_set_drvdata(pdev, NULL); 569 kfree(keypad); | 556 kfree(keypad); 557 return error; 558} 559 560static int __devexit pxa27x_keypad_remove(struct platform_device *pdev) 561{ 562 struct pxa27x_keypad *keypad = platform_get_drvdata(pdev); 563 struct resource *res; --- 6 unchanged lines hidden (view full) --- 570 571 iounmap(keypad->mmio_base); 572 573 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 574 release_mem_region(res->start, resource_size(res)); 575 576 platform_set_drvdata(pdev, NULL); 577 kfree(keypad); |
578 |
|
570 return 0; 571} 572 573/* work with hotplug and coldplug */ 574MODULE_ALIAS("platform:pxa27x-keypad"); 575 576static struct platform_driver pxa27x_keypad_driver = { 577 .probe = pxa27x_keypad_probe, --- 25 unchanged lines hidden --- | 579 return 0; 580} 581 582/* work with hotplug and coldplug */ 583MODULE_ALIAS("platform:pxa27x-keypad"); 584 585static struct platform_driver pxa27x_keypad_driver = { 586 .probe = pxa27x_keypad_probe, --- 25 unchanged lines hidden --- |