History

Input: pxa27x-keypad - drop support for platform data

There are no in-kernel users of pxa27x_keypad_platform_data in the kernel, and the driver supports configuration via device tree, so drop support of static platform data and move properties parsing from OF-specific methods to generic ones.

Dmitry Torokhov committed 1 year ago

Commit ca734f51 parent 770f82c2 files · +121 −330Browse files

Unified · Split

2 files
  1. drivers/input/keyboard/pxa27x_keypad.c +121 −257
  2. include/linux/platform_data/keypad-pxa27x.h +0 −73
drivers/input/keyboard/pxa27x_keypad.c+121−257
@@ -21,13 +21,13 @@ · 20 unmodified lines
2121 #include <linux/io.h>
2222 #include <linux/device.h>
2323 #include <linux/platform_device.h>
24+#include <linux/property.h>
2425 #include <linux/clk.h>
2526 #include <linux/err.h>
2627 #include <linux/input/matrix_keypad.h>
2728 #include <linux/slab.h>
2829 #include <linux/of.h>
2930
30−#include <linux/platform_data/keypad-pxa27x.h>
3131 /*
3232 * Keypad Controller registers
3333 */
@@ -100,54 +100,69 @@ · 66 unmodified lines
100100 #define keypad_readl(off) __raw_readl(keypad->mmio_base + (off))
101101 #define keypad_writel(off, v) __raw_writel((v), keypad->mmio_base + (off))
102102
103+#define MAX_MATRIX_KEY_ROWS 8
104+#define MAX_MATRIX_KEY_COLS 8
105+#define MAX_DIRECT_KEY_NUM 8
106+#define MAX_ROTARY_ENCODERS 2
107+
103108 #define MAX_MATRIX_KEY_NUM (MAX_MATRIX_KEY_ROWS * MAX_MATRIX_KEY_COLS)
104109 #define MAX_KEYPAD_KEYS (MAX_MATRIX_KEY_NUM + MAX_DIRECT_KEY_NUM)
105110
106−struct pxa27x_keypad {
107− const struct pxa27x_keypad_platform_data *pdata;
111+struct pxa27x_keypad_rotary {
112+ unsigned short *key_codes;
113+ int rel_code;
114+ bool enabled;
115+};
108116
117+struct pxa27x_keypad {
109118 struct clk *clk;
110119 struct input_dev *input_dev;
111120 void __iomem *mmio_base;
112121
113122 int irq;
114123
115− unsigned short keycodes[MAX_KEYPAD_KEYS];
116− int rotary_rel_code[2];
117−
124+ unsigned int matrix_key_rows;
125+ unsigned int matrix_key_cols;
118126 unsigned int row_shift;
119127
128+ unsigned int direct_key_num;
129+ unsigned int direct_key_mask;
130+ bool direct_key_low_active;
131+
132+ /* key debounce interval */
133+ unsigned int debounce_interval;
134+
135+ unsigned short keycodes[MAX_KEYPAD_KEYS];
136+
120137 /* state row bits of each column scan */
121138 u32 matrix_key_state[MAX_MATRIX_KEY_COLS];
122139 u32 direct_key_state;
123140
124− unsigned int direct_key_mask;
141+ struct pxa27x_keypad_rotary rotary[MAX_ROTARY_ENCODERS];
125142 };
126143
127−#ifdef CONFIG_OF
128−static int pxa27x_keypad_matrix_key_parse_dt(struct pxa27x_keypad *keypad,
129− struct pxa27x_keypad_platform_data *pdata)
144+static int pxa27x_keypad_matrix_key_parse(struct pxa27x_keypad *keypad)
130145 {
131146 struct input_dev *input_dev = keypad->input_dev;
132147 struct device *dev = input_dev->dev.parent;
133− u32 rows, cols;
134148 int error;
135149
136− error = matrix_keypad_parse_properties(dev, &rows, &cols);
150+ error = matrix_keypad_parse_properties(dev, &keypad->matrix_key_rows,
151+ &keypad->matrix_key_cols);
137152 if (error)
138153 return error;
139154
140− if (rows > MAX_MATRIX_KEY_ROWS || cols > MAX_MATRIX_KEY_COLS) {
155+ if (keypad->matrix_key_rows > MAX_MATRIX_KEY_ROWS ||
156+ keypad->matrix_key_cols > MAX_MATRIX_KEY_COLS) {
141157 dev_err(dev, "rows or cols exceeds maximum value\n");
142158 return -EINVAL;
143159 }
144160
145− pdata->matrix_key_rows = rows;
146− pdata->matrix_key_cols = cols;
161+ keypad->row_shift = get_count_order(keypad->matrix_key_cols);
147162
148163 error = matrix_keypad_build_keymap(NULL, NULL,
149− pdata->matrix_key_rows,
150− pdata->matrix_key_cols,
164+ keypad->matrix_key_rows,
165+ keypad->matrix_key_cols,
151166 keypad->keycodes, input_dev);
152167 if (error)
153168 return error;
@@ -155,20 +170,17 @@ static int pxa27x_keypad_matrix_key_parse_dt(struct pxa27x_keypad *keypad, · 1 unmodified line
155170 return 0;
156171 }
157172
158−static int pxa27x_keypad_direct_key_parse_dt(struct pxa27x_keypad *keypad,
159− struct pxa27x_keypad_platform_data *pdata)
173+static int pxa27x_keypad_direct_key_parse(struct pxa27x_keypad *keypad)
160174 {
161175 struct input_dev *input_dev = keypad->input_dev;
162176 struct device *dev = input_dev->dev.parent;
163− struct device_node *np = dev->of_node;
164− const __be16 *prop;
165177 unsigned short code;
166− unsigned int proplen, size;
178+ int count;
167179 int i;
168180 int error;
169181
170− error = of_property_read_u32(np, "marvell,direct-key-count",
171− &pdata->direct_key_num);
182+ error = device_property_read_u32(dev, "marvell,direct-key-count",
183+ &keypad->direct_key_num);
172184 if (error) {
173185 /*
174186 * If do not have marvel,direct-key-count defined,
@@ -177,151 +189,121 @@ static int pxa27x_keypad_direct_key_parse_dt(struct pxa27x_keypad *keypad, · 2 unmodified lines
177189 return error == -EINVAL ? 0 : error;
178190 }
179191
180− error = of_property_read_u32(np, "marvell,direct-key-mask",
181− &pdata->direct_key_mask);
192+ error = device_property_read_u32(dev, "marvell,direct-key-mask",
193+ &keypad->direct_key_mask);
182194 if (error) {
183195 if (error != -EINVAL)
184196 return error;
185197
186198 /*
187199 * If marvell,direct-key-mask is not defined, driver will use
188− * default value. Default value is set when configure the keypad.
200+ * a default value based on number of direct keys set up.
201+ * The default value is calculated in pxa27x_keypad_config().
189202 */
190− pdata->direct_key_mask = 0;
203+ keypad->direct_key_mask = 0;
191204 }
192205
193− pdata->direct_key_low_active = of_property_read_bool(np,
194− "marvell,direct-key-low-active");
195−
196− prop = of_get_property(np, "marvell,direct-key-map", &proplen);
197− if (!prop)
198− return -EINVAL;
206+ keypad->direct_key_low_active =
207+ device_property_read_bool(dev, "marvell,direct-key-low-active");
199208
200− if (proplen % sizeof(u16))
209+ count = device_property_count_u16(dev, "marvell,direct-key-map");
210+ if (count <= 0 || count > MAX_DIRECT_KEY_NUM)
201211 return -EINVAL;
202212
203− size = proplen / sizeof(u16);
204−
205− /* Only MAX_DIRECT_KEY_NUM is accepted.*/
206− if (size > MAX_DIRECT_KEY_NUM)
207− return -EINVAL;
213+ error = device_property_read_u16_array(dev, "marvell,direct-key-map",
214+ &keypad->keycodes[MAX_MATRIX_KEY_NUM],
215+ count);
208216
209− for (i = 0; i < size; i++) {
210− code = be16_to_cpup(prop + i);
211− keypad->keycodes[MAX_MATRIX_KEY_NUM + i] = code;
217+ for (i = 0; i < count; i++) {
218+ code = keypad->keycodes[MAX_MATRIX_KEY_NUM + i];
212219 __set_bit(code, input_dev->keybit);
213220 }
214221
215222 return 0;
216223 }
217224
218−static int pxa27x_keypad_rotary_parse_dt(struct pxa27x_keypad *keypad,
219− struct pxa27x_keypad_platform_data *pdata)
225+static int pxa27x_keypad_rotary_parse(struct pxa27x_keypad *keypad)
220226 {
221− const __be32 *prop;
222− int i, relkey_ret;
223− unsigned int code, proplen;
224− const char *rotaryname[2] = {
225− "marvell,rotary0", "marvell,rotary1"};
226− const char relkeyname[] = {"marvell,rotary-rel-key"};
227+ static const char * const rotaryname[] = { "marvell,rotary0", "marvell,rotary1" };
227228 struct input_dev *input_dev = keypad->input_dev;
228229 struct device *dev = input_dev->dev.parent;
229− struct device_node *np = dev->of_node;
230−
231− relkey_ret = of_property_read_u32(np, relkeyname, &code);
232− /* if can read correct rotary key-code, we do not need this. */
233− if (relkey_ret == 0) {
234− unsigned short relcode;
230+ struct pxa27x_keypad_rotary *encoder;
231+ unsigned int code;
232+ int i;
233+ int error;
235234
236− /* rotary0 taks lower half, rotary1 taks upper half. */
237− relcode = code & 0xffff;
238− pdata->rotary0_rel_code = (code & 0xffff);
239− __set_bit(relcode, input_dev->relbit);
235+ error = device_property_read_u32(dev, "marvell,rotary-rel-key", &code);
236+ if (!error) {
237+ for (i = 0; i < MAX_ROTARY_ENCODERS; i++, code >>= 16) {
238+ encoder = &keypad->rotary[i];
239+ encoder->enabled = true;
240+ encoder->rel_code = code & 0xffff;
241+ input_set_capability(input_dev, EV_REL, encoder->rel_code);
242+ }
240243
241− relcode = code >> 16;
242− pdata->rotary1_rel_code = relcode;
243− __set_bit(relcode, input_dev->relbit);
244+ return 0;
244245 }
245246
246− for (i = 0; i < 2; i++) {
247− prop = of_get_property(np, rotaryname[i], &proplen);
247+ for (i = 0; i < MAX_ROTARY_ENCODERS; i++) {
248+ encoder = &keypad->rotary[i];
249+
248250 /*
249251 * If the prop is not set, it means keypad does not need
250252 * initialize the rotaryX.
251253 */
252− if (!prop)
254+ if (!device_property_present(dev, rotaryname[i]))
253255 continue;
254256
255− code = be32_to_cpup(prop);
257+ error = device_property_read_u32(dev, rotaryname[i], &code);
258+ if (error)
259+ return error;
260+
256261 /*
257262 * Not all up/down key code are valid.
258263 * Now we depends on direct-rel-code.
259264 */
260− if ((!(code & 0xffff) || !(code >> 16)) && relkey_ret) {
261− return relkey_ret;
262− } else {
263− unsigned int n = MAX_MATRIX_KEY_NUM + (i << 1);
264− unsigned short keycode;
265−
266− keycode = code & 0xffff;
267− keypad->keycodes[n] = keycode;
268− __set_bit(keycode, input_dev->keybit);
269−
270− keycode = code >> 16;
271− keypad->keycodes[n + 1] = keycode;
272− __set_bit(keycode, input_dev->keybit);
273−
274− if (i == 0)
275− pdata->rotary0_rel_code = -1;
276− else
277− pdata->rotary1_rel_code = -1;
278− }
279− if (i == 0)
280− pdata->enable_rotary0 = 1;
281− else
282− pdata->enable_rotary1 = 1;
283− }
265+ if (!(code & 0xffff) || !(code >> 16))
266+ return -EINVAL;
267+
268+ encoder->enabled = true;
269+ encoder->rel_code = -1;
270+ encoder->key_codes = &keypad->keycodes[MAX_MATRIX_KEY_NUM + i * 2];
271+ encoder->key_codes[0] = code & 0xffff;
272+ encoder->key_codes[1] = code >> 16;
284273
285− keypad->rotary_rel_code[0] = pdata->rotary0_rel_code;
286− keypad->rotary_rel_code[1] = pdata->rotary1_rel_code;
274+ input_set_capability(input_dev, EV_KEY, encoder->key_codes[0]);
275+ input_set_capability(input_dev, EV_KEY, encoder->key_codes[1]);
276+ }
287277
288278 return 0;
289279 }
290280
291−static int pxa27x_keypad_build_keycode_from_dt(struct pxa27x_keypad *keypad)
281+static int pxa27x_keypad_parse_properties(struct pxa27x_keypad *keypad)
292282 {
293283 struct input_dev *input_dev = keypad->input_dev;
294284 struct device *dev = input_dev->dev.parent;
295− struct device_node *np = dev->of_node;
296− struct pxa27x_keypad_platform_data *pdata;
297285 int error;
298286
299− pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
300− if (!pdata) {
301− dev_err(dev, "failed to allocate memory for pdata\n");
302− return -ENOMEM;
303− }
304−
305− error = pxa27x_keypad_matrix_key_parse_dt(keypad, pdata);
287+ error = pxa27x_keypad_matrix_key_parse(keypad);
306288 if (error) {
307289 dev_err(dev, "failed to parse matrix key\n");
308290 return error;
309291 }
310292
311− error = pxa27x_keypad_direct_key_parse_dt(keypad, pdata);
293+ error = pxa27x_keypad_direct_key_parse(keypad);
312294 if (error) {
313295 dev_err(dev, "failed to parse direct key\n");
314296 return error;
315297 }
316298
317− error = pxa27x_keypad_rotary_parse_dt(keypad, pdata);
299+ error = pxa27x_keypad_rotary_parse(keypad);
318300 if (error) {
319301 dev_err(dev, "failed to parse rotary key\n");
320302 return error;
321303 }
322304
323− error = of_property_read_u32(np, "marvell,debounce-interval",
324− &pdata->debounce_interval);
305+ error = device_property_read_u32(dev, "marvell,debounce-interval",
306+ &keypad->debounce_interval);
325307 if (error) {
326308 dev_err(dev, "failed to parse debounce-interval\n");
327309 return error;
@@ -333,91 +315,11 @@ static int pxa27x_keypad_build_keycode_from_dt(struct pxa27x_keypad *keypad) · 5 unmodified lines
333315 */
334316 input_dev->keycodemax = ARRAY_SIZE(keypad->keycodes);
335317
336− keypad->pdata = pdata;
337− return 0;
338−}
339−
340−#else
341−
342−static int pxa27x_keypad_build_keycode_from_dt(struct pxa27x_keypad *keypad)
343−{
344− dev_info(keypad->input_dev->dev.parent, "missing platform data\n");
345−
346− return -EINVAL;
347−}
348−
349−#endif
350−
351−static int pxa27x_keypad_build_keycode(struct pxa27x_keypad *keypad)
352−{
353− const struct pxa27x_keypad_platform_data *pdata = keypad->pdata;
354− struct input_dev *input_dev = keypad->input_dev;
355− unsigned short keycode;
356− int i;
357− int error;
358−
359− error = matrix_keypad_build_keymap(pdata->matrix_keymap_data, NULL,
360− pdata->matrix_key_rows,
361− pdata->matrix_key_cols,
362− keypad->keycodes, input_dev);
363− if (error)
364− return error;
365−
366− /*
367− * The keycodes may not only include matrix keys but also the direct
368− * or rotary keys.
369− */
370− input_dev->keycodemax = ARRAY_SIZE(keypad->keycodes);
371−
372− /* For direct keys. */
373− for (i = 0; i < pdata->direct_key_num; i++) {
374− keycode = pdata->direct_key_map[i];
375− keypad->keycodes[MAX_MATRIX_KEY_NUM + i] = keycode;
376− __set_bit(keycode, input_dev->keybit);
377− }
378−
379− if (pdata->enable_rotary0) {
380− if (pdata->rotary0_up_key && pdata->rotary0_down_key) {
381− keycode = pdata->rotary0_up_key;
382− keypad->keycodes[MAX_MATRIX_KEY_NUM + 0] = keycode;
383− __set_bit(keycode, input_dev->keybit);
384−
385− keycode = pdata->rotary0_down_key;
386− keypad->keycodes[MAX_MATRIX_KEY_NUM + 1] = keycode;
387− __set_bit(keycode, input_dev->keybit);
388−
389− keypad->rotary_rel_code[0] = -1;
390− } else {
391− keypad->rotary_rel_code[0] = pdata->rotary0_rel_code;
392− __set_bit(pdata->rotary0_rel_code, input_dev->relbit);
393− }
394− }
395−
396− if (pdata->enable_rotary1) {
397− if (pdata->rotary1_up_key && pdata->rotary1_down_key) {
398− keycode = pdata->rotary1_up_key;
399− keypad->keycodes[MAX_MATRIX_KEY_NUM + 2] = keycode;
400− __set_bit(keycode, input_dev->keybit);
401−
402− keycode = pdata->rotary1_down_key;
403− keypad->keycodes[MAX_MATRIX_KEY_NUM + 3] = keycode;
404− __set_bit(keycode, input_dev->keybit);
405−
406− keypad->rotary_rel_code[1] = -1;
407− } else {
408− keypad->rotary_rel_code[1] = pdata->rotary1_rel_code;
409− __set_bit(pdata->rotary1_rel_code, input_dev->relbit);
410− }
411− }
412−
413− __clear_bit(KEY_RESERVED, input_dev->keybit);
414−
415318 return 0;
416319 }
417320
418321 static void pxa27x_keypad_scan_matrix(struct pxa27x_keypad *keypad)
419322 {
420− const struct pxa27x_keypad_platform_data *pdata = keypad->pdata;
421323 struct input_dev *input_dev = keypad->input_dev;
422324 int row, col, num_keys_pressed = 0;
423325 u32 new_state[MAX_MATRIX_KEY_COLS];
@@ -435,8 +337,8 @@ static void pxa27x_keypad_scan_matrix(struct pxa27x_keypad *keypad) · 11 unmodified lines
435337 row = KPAS_RP(kpas);
436338
437339 /* if invalid row/col, treat as no key pressed */
438− if (col >= pdata->matrix_key_cols ||
439− row >= pdata->matrix_key_rows)
340+ if (col >= keypad->matrix_key_cols ||
341+ row >= keypad->matrix_key_rows)
440342 goto scan;
441343
442344 new_state[col] = BIT(row);
@@ -459,7 +361,7 @@ static void pxa27x_keypad_scan_matrix(struct pxa27x_keypad *keypad) · 16 unmodified lines
459361 new_state[7] = (kpasmkp3 >> 16) & KPASMKP_MKC_MASK;
460362 }
461363 scan:
462− for (col = 0; col < pdata->matrix_key_cols; col++) {
364+ for (col = 0; col < keypad->matrix_key_cols; col++) {
463365 u32 bits_changed;
464366 int code;
465367
@@ -467,7 +369,7 @@ scan: · 1 unmodified line
467369 if (bits_changed == 0)
468370 continue;
469371
470− for (row = 0; row < pdata->matrix_key_rows; row++) {
372+ for (row = 0; row < keypad->matrix_key_rows; row++) {
471373 if ((bits_changed & BIT(row)) == 0)
472374 continue;
473375
@@ -496,14 +398,16 @@ static inline int rotary_delta(u32 kprec) · 22 unmodified lines
496398
497399 static void report_rotary_event(struct pxa27x_keypad *keypad, int r, int delta)
498400 {
401+ struct pxa27x_keypad_rotary *encoder = &keypad->rotary[r];
499402 struct input_dev *dev = keypad->input_dev;
500403
501− if (delta == 0)
404+ if (!encoder->enabled || delta == 0)
502405 return;
503406
504− if (keypad->rotary_rel_code[r] == -1) {
505− int code = MAX_MATRIX_KEY_NUM + 2 * r + (delta > 0 ? 0 : 1);
506− unsigned char keycode = keypad->keycodes[code];
407+ if (encoder->rel_code == -1) {
408+ int idx = delta > 0 ? 0 : 1;
409+ int code = MAX_MATRIX_KEY_NUM + 2 * r + idx;
410+ unsigned char keycode = encoder->key_codes[idx];
507411
508412 /* simulate a press-n-release */
509413 input_event(dev, EV_MSC, MSC_SCAN, code);
@@ -513,30 +417,28 @@ static void report_rotary_event(struct pxa27x_keypad *keypad, int r, int delta) · 3 unmodified lines
513417 input_report_key(dev, keycode, 0);
514418 input_sync(dev);
515419 } else {
516− input_report_rel(dev, keypad->rotary_rel_code[r], delta);
420+ input_report_rel(dev, encoder->rel_code, delta);
517421 input_sync(dev);
518422 }
519423 }
520424
521425 static void pxa27x_keypad_scan_rotary(struct pxa27x_keypad *keypad)
522426 {
523− const struct pxa27x_keypad_platform_data *pdata = keypad->pdata;
524427 u32 kprec;
428+ int i;
525429
526430 /* read and reset to default count value */
527431 kprec = keypad_readl(KPREC);
528432 keypad_writel(KPREC, DEFAULT_KPREC);
529433
530− if (pdata->enable_rotary0)
434+ for (i = 0; i < MAX_ROTARY_ENCODERS; i++) {
531435 report_rotary_event(keypad, 0, rotary_delta(kprec));
532−
533− if (pdata->enable_rotary1)
534− report_rotary_event(keypad, 1, rotary_delta(kprec >> 16));
436+ kprec >>= 16;
437+ }
535438 }
536439
537440 static void pxa27x_keypad_scan_direct(struct pxa27x_keypad *keypad)
538441 {
539− const struct pxa27x_keypad_platform_data *pdata = keypad->pdata;
540442 struct input_dev *input_dev = keypad->input_dev;
541443 unsigned int new_state;
542444 u32 kpdk, bits_changed;
@@ -544,14 +446,14 @@ static void pxa27x_keypad_scan_direct(struct pxa27x_keypad *keypad) · 1 unmodified line
544446
545447 kpdk = keypad_readl(KPDK);
546448
547− if (pdata->enable_rotary0 || pdata->enable_rotary1)
449+ if (keypad->rotary[0].enabled || keypad->rotary[1].enabled)
548450 pxa27x_keypad_scan_rotary(keypad);
549451
550452 /*
551453 * The KPDR_DK only output the key pin level, so it relates to board,
552454 * and low level may be active.
553455 */
554− if (pdata->direct_key_low_active)
456+ if (keypad->direct_key_low_active)
555457 new_state = ~KPDK_DK(kpdk) & keypad->direct_key_mask;
556458 else
557459 new_state = KPDK_DK(kpdk) & keypad->direct_key_mask;
@@ -561,7 +463,7 @@ static void pxa27x_keypad_scan_direct(struct pxa27x_keypad *keypad) · 3 unmodified lines
561463 if (bits_changed == 0)
562464 return;
563465
564− for (i = 0; i < pdata->direct_key_num; i++) {
466+ for (i = 0; i < keypad->direct_key_num; i++) {
565467 if (bits_changed & BIT(i)) {
566468 int code = MAX_MATRIX_KEY_NUM + i;
567469
@@ -574,21 +476,11 @@ static void pxa27x_keypad_scan_direct(struct pxa27x_keypad *keypad) · 6 unmodified lines
574476 keypad->direct_key_state = new_state;
575477 }
576478
577−static void clear_wakeup_event(struct pxa27x_keypad *keypad)
578−{
579− const struct pxa27x_keypad_platform_data *pdata = keypad->pdata;
580−
581− if (pdata->clear_wakeup_event)
582− (pdata->clear_wakeup_event)();
583−}
584−
585479 static irqreturn_t pxa27x_keypad_irq_handler(int irq, void *dev_id)
586480 {
587481 struct pxa27x_keypad *keypad = dev_id;
588482 unsigned long kpc = keypad_readl(KPC);
589483
590− clear_wakeup_event(keypad);
591−
592484 if (kpc & KPC_DI)
593485 pxa27x_keypad_scan_direct(keypad);
594486
@@ -600,7 +492,6 @@ static irqreturn_t pxa27x_keypad_irq_handler(int irq, void *dev_id) · 5 unmodified lines
600492
601493 static void pxa27x_keypad_config(struct pxa27x_keypad *keypad)
602494 {
603− const struct pxa27x_keypad_platform_data *pdata = keypad->pdata;
604495 unsigned int mask = 0, direct_key_num = 0;
605496 unsigned long kpc = 0;
606497
@@ -608,35 +499,33 @@ static void pxa27x_keypad_config(struct pxa27x_keypad *keypad) · 1 unmodified line
608499 keypad_readl(KPC);
609500
610501 /* enable matrix keys with automatic scan */
611− if (pdata->matrix_key_rows && pdata->matrix_key_cols) {
502+ if (keypad->matrix_key_rows && keypad->matrix_key_cols) {
612503 kpc |= KPC_ASACT | KPC_MIE | KPC_ME | KPC_MS_ALL;
613− kpc |= KPC_MKRN(pdata->matrix_key_rows) |
614− KPC_MKCN(pdata->matrix_key_cols);
504+ kpc |= KPC_MKRN(keypad->matrix_key_rows) |
505+ KPC_MKCN(keypad->matrix_key_cols);
615506 }
616507
617508 /* enable rotary key, debounce interval same as direct keys */
618− if (pdata->enable_rotary0) {
509+ if (keypad->rotary[0].enabled) {
619510 mask |= 0x03;
620511 direct_key_num = 2;
621512 kpc |= KPC_REE0;
622513 }
623514
624− if (pdata->enable_rotary1) {
515+ if (keypad->rotary[1].enabled) {
625516 mask |= 0x0c;
626517 direct_key_num = 4;
627518 kpc |= KPC_REE1;
628519 }
629520
630− if (pdata->direct_key_num > direct_key_num)
631− direct_key_num = pdata->direct_key_num;
521+ if (keypad->direct_key_num > direct_key_num)
522+ direct_key_num = keypad->direct_key_num;
632523
633524 /*
634525 * Direct keys usage may not start from KP_DKIN0, check the platfrom
635526 * mask data to config the specific.
636527 */
637− if (pdata->direct_key_mask)
638− keypad->direct_key_mask = pdata->direct_key_mask;
639− else
528+ if (!keypad->direct_key_mask)
640529 keypad->direct_key_mask = GENMASK(direct_key_num - 1, 0) & ~mask;
641530
642531 /* enable direct key */
@@ -645,7 +534,7 @@ static void pxa27x_keypad_config(struct pxa27x_keypad *keypad) · 2 unmodified lines
645534
646535 keypad_writel(KPC, kpc | KPC_RE_ZERO_DEB);
647536 keypad_writel(KPREC, DEFAULT_KPREC);
648− keypad_writel(KPKDI, pdata->debounce_interval);
537+ keypad_writel(KPKDI, keypad->debounce_interval);
649538 }
650539
651540 static int pxa27x_keypad_open(struct input_dev *dev)
@@ -719,19 +608,12 @@ static int pxa27x_keypad_resume(struct device *dev) · 67 unmodified lines
719608 static DEFINE_SIMPLE_DEV_PM_OPS(pxa27x_keypad_pm_ops,
720609 pxa27x_keypad_suspend, pxa27x_keypad_resume);
721610
722−
723611 static int pxa27x_keypad_probe(struct platform_device *pdev)
724612 {
725− const struct pxa27x_keypad_platform_data *pdata =
726− dev_get_platdata(&pdev->dev);
727− struct device_node *np = pdev->dev.of_node;
728613 struct pxa27x_keypad *keypad;
729614 struct input_dev *input_dev;
730− int irq, error;
731−
732− /* Driver need build keycode from device tree or pdata */
733− if (!np && !pdata)
734− return -EINVAL;
615+ int irq;
616+ int error;
735617
736618 irq = platform_get_irq(pdev, 0);
737619 if (irq < 0)
@@ -746,7 +628,6 @@ static int pxa27x_keypad_probe(struct platform_device *pdev) · 8 unmodified lines
746628 if (!input_dev)
747629 return -ENOMEM;
748630
749− keypad->pdata = pdata;
750631 keypad->input_dev = input_dev;
751632 keypad->irq = irq;
752633
@@ -775,29 +656,12 @@ static int pxa27x_keypad_probe(struct platform_device *pdev) · 22 unmodified lines
775656 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP);
776657 input_set_capability(input_dev, EV_MSC, MSC_SCAN);
777658
778− if (pdata) {
779− error = pxa27x_keypad_build_keycode(keypad);
780− } else {
781− error = pxa27x_keypad_build_keycode_from_dt(keypad);
782− /*
783− * Data that we get from DT resides in dynamically
784− * allocated memory so we need to update our pdata
785− * pointer.
786− */
787− pdata = keypad->pdata;
788− }
659+ error = pxa27x_keypad_parse_properties(keypad);
789660 if (error) {
790− dev_err(&pdev->dev, "failed to build keycode\n");
661+ dev_err(&pdev->dev, "failed to parse keypad properties\n");
791662 return error;
792663 }
793664
794− keypad->row_shift = get_count_order(pdata->matrix_key_cols);
795−
796− if ((pdata->enable_rotary0 && keypad->rotary_rel_code[0] != -1) ||
797− (pdata->enable_rotary1 && keypad->rotary_rel_code[1] != -1)) {
798− input_dev->evbit[0] |= BIT_MASK(EV_REL);
799− }
800−
801665 error = devm_request_irq(&pdev->dev, irq, pxa27x_keypad_irq_handler,
802666 0, pdev->name, keypad);
803667 if (error) {
include/linux/platform_data/keypad-pxa27x.h+0−73
@@ -1,73 +0,0 @@
1−/* SPDX-License-Identifier: GPL-2.0 */
2−#ifndef __ASM_ARCH_PXA27x_KEYPAD_H
3−#define __ASM_ARCH_PXA27x_KEYPAD_H
4−
5−#include <linux/input.h>
6−#include <linux/input/matrix_keypad.h>
7−
8−#define MAX_MATRIX_KEY_ROWS (8)
9−#define MAX_MATRIX_KEY_COLS (8)
10−#define MATRIX_ROW_SHIFT (3)
11−#define MAX_DIRECT_KEY_NUM (8)
12−
13−/* pxa3xx keypad platform specific parameters
14− *
15− * NOTE:
16− * 1. direct_key_num indicates the number of keys in the direct keypad
17− * _plus_ the number of rotary-encoder sensor inputs, this can be
18− * left as 0 if only rotary encoders are enabled, the driver will
19− * automatically calculate this
20− *
21− * 2. direct_key_map is the key code map for the direct keys, if rotary
22− * encoder(s) are enabled, direct key 0/1(2/3) will be ignored
23− *
24− * 3. rotary can be either interpreted as a relative input event (e.g.
25− * REL_WHEEL/REL_HWHEEL) or specific keys (e.g. UP/DOWN/LEFT/RIGHT)
26− *
27− * 4. matrix key and direct key will use the same debounce_interval by
28− * default, which should be sufficient in most cases
29− *
30− * pxa168 keypad platform specific parameter
31− *
32− * NOTE:
33− * clear_wakeup_event callback is a workaround required to clear the
34− * keypad interrupt. The keypad wake must be cleared in addition to
35− * reading the MI/DI bits in the KPC register.
36− */
37−struct pxa27x_keypad_platform_data {
38−
39− /* code map for the matrix keys */
40− const struct matrix_keymap_data *matrix_keymap_data;
41− unsigned int matrix_key_rows;
42− unsigned int matrix_key_cols;
43−
44− /* direct keys */
45− int direct_key_num;
46− unsigned int direct_key_map[MAX_DIRECT_KEY_NUM];
47− /* the key output may be low active */
48− int direct_key_low_active;
49− /* give board a chance to choose the start direct key */
50− unsigned int direct_key_mask;
51−
52− /* rotary encoders 0 */
53− int enable_rotary0;
54− int rotary0_rel_code;
55− int rotary0_up_key;
56− int rotary0_down_key;
57−
58− /* rotary encoders 1 */
59− int enable_rotary1;
60− int rotary1_rel_code;
61− int rotary1_up_key;
62− int rotary1_down_key;
63−
64− /* key debounce interval */
65− unsigned int debounce_interval;
66−
67− /* clear wakeup event requirement for pxa168 */
68− void (*clear_wakeup_event)(void);
69−};
70−
71−extern void pxa_set_keypad_info(struct pxa27x_keypad_platform_data *info);
72−
73−#endif /* __ASM_ARCH_PXA27x_KEYPAD_H */