44
44
#define S5PV210_KEYIFSTSCLR_R_INT_OFFSET 16
45
45
46
46
/* SAMSUNG_KEYIFCOL */
47
- #define SAMSUNG_KEYIFCOL_MASK (0xff << 0)
48
- #define S5PV210_KEYIFCOLEN_MASK (0xff << 8)
47
+ #define SAMSUNG_KEYIFCOL_MASK 0xff
49
48
50
49
/* SAMSUNG_KEYIFROW */
51
50
#define SAMSUNG_KEYIFROW_MASK (0xff << 0)
54
53
/* SAMSUNG_KEYIFFC */
55
54
#define SAMSUNG_KEYIFFC_MASK (0x3ff << 0)
56
55
57
- enum samsung_keypad_type {
58
- KEYPAD_TYPE_SAMSUNG ,
59
- KEYPAD_TYPE_S5PV210 ,
56
+ struct samsung_chip_info {
57
+ unsigned int column_shift ;
60
58
};
61
59
62
60
struct samsung_keypad {
61
+ const struct samsung_chip_info * chip ;
63
62
struct input_dev * input_dev ;
64
63
struct platform_device * pdev ;
65
64
struct clk * clk ;
@@ -68,7 +67,6 @@ struct samsung_keypad {
68
67
bool stopped ;
69
68
bool wake_enabled ;
70
69
int irq ;
71
- enum samsung_keypad_type type ;
72
70
unsigned int row_shift ;
73
71
unsigned int rows ;
74
72
unsigned int cols ;
@@ -83,13 +81,8 @@ static void samsung_keypad_scan(struct samsung_keypad *keypad,
83
81
unsigned int val ;
84
82
85
83
for (col = 0 ; col < keypad -> cols ; col ++ ) {
86
- if (keypad -> type == KEYPAD_TYPE_S5PV210 ) {
87
- val = S5PV210_KEYIFCOLEN_MASK ;
88
- val &= ~(1 << col ) << 8 ;
89
- } else {
90
- val = SAMSUNG_KEYIFCOL_MASK ;
91
- val &= ~(1 << col );
92
- }
84
+ val = SAMSUNG_KEYIFCOL_MASK & ~(1 << col );
85
+ val <<= keypad -> chip -> column_shift ;
93
86
94
87
writel (val , keypad -> base + SAMSUNG_KEYIFCOL );
95
88
mdelay (1 );
@@ -314,6 +307,7 @@ static int samsung_keypad_probe(struct platform_device *pdev)
314
307
{
315
308
const struct samsung_keypad_platdata * pdata ;
316
309
const struct matrix_keymap_data * keymap_data ;
310
+ const struct platform_device_id * id ;
317
311
struct samsung_keypad * keypad ;
318
312
struct resource * res ;
319
313
struct input_dev * input_dev ;
@@ -378,11 +372,17 @@ static int samsung_keypad_probe(struct platform_device *pdev)
378
372
keypad -> stopped = true;
379
373
init_waitqueue_head (& keypad -> wait );
380
374
381
- if (pdev -> dev .of_node )
382
- keypad -> type = of_device_is_compatible (pdev -> dev .of_node ,
383
- "samsung,s5pv210-keypad" );
384
- else
385
- keypad -> type = platform_get_device_id (pdev )-> driver_data ;
375
+ keypad -> chip = device_get_match_data (& pdev -> dev );
376
+ if (!keypad -> chip ) {
377
+ id = platform_get_device_id (pdev );
378
+ if (id )
379
+ keypad -> chip = (const void * )id -> driver_data ;
380
+ }
381
+
382
+ if (!keypad -> chip ) {
383
+ dev_err (& pdev -> dev , "Unable to determine chip type" );
384
+ return - EINVAL ;
385
+ }
386
386
387
387
input_dev -> name = pdev -> name ;
388
388
input_dev -> id .bustype = BUS_HOST ;
@@ -542,24 +542,37 @@ static const struct dev_pm_ops samsung_keypad_pm_ops = {
542
542
samsung_keypad_runtime_resume , NULL )
543
543
};
544
544
545
+ static const struct samsung_chip_info samsung_s3c6410_chip_info = {
546
+ .column_shift = 0 ,
547
+ };
548
+
549
+ static const struct samsung_chip_info samsung_s5pv210_chip_info = {
550
+ .column_shift = 8 ,
551
+ };
552
+
545
553
#ifdef CONFIG_OF
546
554
static const struct of_device_id samsung_keypad_dt_match [] = {
547
- { .compatible = "samsung,s3c6410-keypad" },
548
- { .compatible = "samsung,s5pv210-keypad" },
549
- {},
555
+ {
556
+ .compatible = "samsung,s3c6410-keypad" ,
557
+ .data = & samsung_s3c6410_chip_info ,
558
+ }, {
559
+ .compatible = "samsung,s5pv210-keypad" ,
560
+ .data = & samsung_s5pv210_chip_info ,
561
+ },
562
+ { }
550
563
};
551
564
MODULE_DEVICE_TABLE (of , samsung_keypad_dt_match );
552
565
#endif
553
566
554
567
static const struct platform_device_id samsung_keypad_driver_ids [] = {
555
568
{
556
569
.name = "samsung-keypad" ,
557
- .driver_data = KEYPAD_TYPE_SAMSUNG ,
570
+ .driver_data = ( kernel_ulong_t ) & samsung_s3c6410_chip_info ,
558
571
}, {
559
572
.name = "s5pv210-keypad" ,
560
- .driver_data = KEYPAD_TYPE_S5PV210 ,
573
+ .driver_data = ( kernel_ulong_t ) & samsung_s5pv210_chip_info ,
561
574
},
562
- { },
575
+ { }
563
576
};
564
577
MODULE_DEVICE_TABLE (platform , samsung_keypad_driver_ids );
565
578
0 commit comments