66 *
77 * Based on the pxa27x matrix keypad controller by Rodolfo Giometti.
88 *
9- * NOTE:
10- *
11- * The 3-key reset is triggered by pressing the 3 keys in
12- * Row 0, Columns 2, 4, and 7 at the same time. This action can
13- * be disabled by setting the EP93XX_KEYPAD_DISABLE_3_KEY flag.
14- *
15- * Normal operation for the matrix does not autorepeat the key press.
16- * This action can be enabled by setting the EP93XX_KEYPAD_AUTOREPEAT
17- * flag.
189 */
1910
2011#include <linux/bits.h>
12+ #include <linux/mod_devicetable.h>
2113#include <linux/module.h>
2214#include <linux/platform_device.h>
15+ #include <linux/property.h>
2316#include <linux/interrupt.h>
2417#include <linux/clk.h>
2518#include <linux/io.h>
2619#include <linux/input.h>
2720#include <linux/input/matrix_keypad.h>
2821#include <linux/slab.h>
2922#include <linux/soc/cirrus/ep93xx.h>
30- #include <linux/platform_data/keypad-ep93xx.h>
3123#include <linux/pm_wakeirq.h>
3224
3325/*
6153#define KEY_REG_KEY1_MASK GENMASK(5, 0)
6254#define KEY_REG_KEY1_SHIFT 0
6355
56+ #define EP93XX_MATRIX_ROWS (8)
57+ #define EP93XX_MATRIX_COLS (8)
58+
6459#define EP93XX_MATRIX_SIZE (EP93XX_MATRIX_ROWS * EP93XX_MATRIX_COLS)
6560
6661struct ep93xx_keypad {
67- struct ep93xx_keypad_platform_data * pdata ;
6862 struct input_dev * input_dev ;
6963 struct clk * clk ;
64+ unsigned int debounce ;
65+ u16 prescale ;
7066
7167 void __iomem * mmio_base ;
7268
@@ -133,23 +129,11 @@ static irqreturn_t ep93xx_keypad_irq_handler(int irq, void *dev_id)
133129
134130static void ep93xx_keypad_config (struct ep93xx_keypad * keypad )
135131{
136- struct ep93xx_keypad_platform_data * pdata = keypad -> pdata ;
137132 unsigned int val = 0 ;
138133
139- clk_set_rate (keypad -> clk , pdata -> clk_rate );
140-
141- if (pdata -> flags & EP93XX_KEYPAD_DISABLE_3_KEY )
142- val |= KEY_INIT_DIS3KY ;
143- if (pdata -> flags & EP93XX_KEYPAD_DIAG_MODE )
144- val |= KEY_INIT_DIAG ;
145- if (pdata -> flags & EP93XX_KEYPAD_BACK_DRIVE )
146- val |= KEY_INIT_BACK ;
147- if (pdata -> flags & EP93XX_KEYPAD_TEST_MODE )
148- val |= KEY_INIT_T2 ;
149-
150- val |= ((pdata -> debounce << KEY_INIT_DBNC_SHIFT ) & KEY_INIT_DBNC_MASK );
134+ val |= (keypad -> debounce << KEY_INIT_DBNC_SHIFT ) & KEY_INIT_DBNC_MASK ;
151135
152- val |= (( pdata -> prescale << KEY_INIT_PRSCL_SHIFT ) & KEY_INIT_PRSCL_MASK ) ;
136+ val |= (keypad -> prescale << KEY_INIT_PRSCL_SHIFT ) & KEY_INIT_PRSCL_MASK ;
153137
154138 __raw_writel (val , keypad -> mmio_base + KEY_INIT );
155139}
@@ -220,32 +204,17 @@ static int ep93xx_keypad_resume(struct device *dev)
220204static DEFINE_SIMPLE_DEV_PM_OPS (ep93xx_keypad_pm_ops ,
221205 ep93xx_keypad_suspend , ep93xx_keypad_resume ) ;
222206
223- static void ep93xx_keypad_release_gpio_action (void * _pdev )
224- {
225- struct platform_device * pdev = _pdev ;
226-
227- ep93xx_keypad_release_gpio (pdev );
228- }
229-
230207static int ep93xx_keypad_probe (struct platform_device * pdev )
231208{
209+ struct device * dev = & pdev -> dev ;
232210 struct ep93xx_keypad * keypad ;
233- const struct matrix_keymap_data * keymap_data ;
234211 struct input_dev * input_dev ;
235212 int err ;
236213
237214 keypad = devm_kzalloc (& pdev -> dev , sizeof (* keypad ), GFP_KERNEL );
238215 if (!keypad )
239216 return - ENOMEM ;
240217
241- keypad -> pdata = dev_get_platdata (& pdev -> dev );
242- if (!keypad -> pdata )
243- return - EINVAL ;
244-
245- keymap_data = keypad -> pdata -> keymap_data ;
246- if (!keymap_data )
247- return - EINVAL ;
248-
249218 keypad -> irq = platform_get_irq (pdev , 0 );
250219 if (keypad -> irq < 0 )
251220 return keypad -> irq ;
@@ -254,19 +223,13 @@ static int ep93xx_keypad_probe(struct platform_device *pdev)
254223 if (IS_ERR (keypad -> mmio_base ))
255224 return PTR_ERR (keypad -> mmio_base );
256225
257- err = ep93xx_keypad_acquire_gpio (pdev );
258- if (err )
259- return err ;
260-
261- err = devm_add_action_or_reset (& pdev -> dev ,
262- ep93xx_keypad_release_gpio_action , pdev );
263- if (err )
264- return err ;
265-
266226 keypad -> clk = devm_clk_get (& pdev -> dev , NULL );
267227 if (IS_ERR (keypad -> clk ))
268228 return PTR_ERR (keypad -> clk );
269229
230+ device_property_read_u32 (dev , "debounce-delay-ms" , & keypad -> debounce );
231+ device_property_read_u16 (dev , "cirrus,prescale" , & keypad -> prescale );
232+
270233 input_dev = devm_input_allocate_device (& pdev -> dev );
271234 if (!input_dev )
272235 return - ENOMEM ;
@@ -278,13 +241,13 @@ static int ep93xx_keypad_probe(struct platform_device *pdev)
278241 input_dev -> open = ep93xx_keypad_open ;
279242 input_dev -> close = ep93xx_keypad_close ;
280243
281- err = matrix_keypad_build_keymap (keymap_data , NULL ,
244+ err = matrix_keypad_build_keymap (NULL , NULL ,
282245 EP93XX_MATRIX_ROWS , EP93XX_MATRIX_COLS ,
283246 keypad -> keycodes , input_dev );
284247 if (err )
285248 return err ;
286249
287- if (keypad -> pdata -> flags & EP93XX_KEYPAD_AUTOREPEAT )
250+ if (device_property_read_bool ( & pdev -> dev , "autorepeat" ) )
288251 __set_bit (EV_REP , input_dev -> evbit );
289252 input_set_drvdata (input_dev , keypad );
290253
@@ -313,10 +276,17 @@ static void ep93xx_keypad_remove(struct platform_device *pdev)
313276 dev_pm_clear_wake_irq (& pdev -> dev );
314277}
315278
279+ static const struct of_device_id ep93xx_keypad_of_ids [] = {
280+ { .compatible = "cirrus,ep9307-keypad" },
281+ { /* sentinel */ }
282+ };
283+ MODULE_DEVICE_TABLE (of , ep93xx_keypad_of_ids );
284+
316285static struct platform_driver ep93xx_keypad_driver = {
317286 .driver = {
318287 .name = "ep93xx-keypad" ,
319288 .pm = pm_sleep_ptr (& ep93xx_keypad_pm_ops ),
289+ .of_match_table = ep93xx_keypad_of_ids ,
320290 },
321291 .probe = ep93xx_keypad_probe ,
322292 .remove_new = ep93xx_keypad_remove ,
0 commit comments