Skip to content

Commit b3ab578

Browse files
maquefelarndb
authored andcommitted
input: keypad: ep93xx: add DT support for Cirrus EP93xx
- drop flags, they were not used anyway - add OF ID match table - process "autorepeat", "debounce-delay-ms", prescale from device tree - drop platform data usage and it's header - keymap goes from device tree now on Signed-off-by: Nikita Shubin <[email protected]> Acked-by: Dmitry Torokhov <[email protected]> Acked-by: Vinod Koul <[email protected]> Signed-off-by: Arnd Bergmann <[email protected]>
1 parent 9cefdd1 commit b3ab578

File tree

3 files changed

+22
-102
lines changed

3 files changed

+22
-102
lines changed

arch/arm/mach-ep93xx/core.c

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -697,52 +697,6 @@ void __init ep93xx_register_keypad(struct ep93xx_keypad_platform_data *data)
697697
platform_device_register(&ep93xx_keypad_device);
698698
}
699699

700-
int ep93xx_keypad_acquire_gpio(struct platform_device *pdev)
701-
{
702-
int err;
703-
int i;
704-
705-
for (i = 0; i < 8; i++) {
706-
err = gpio_request(EP93XX_GPIO_LINE_C(i), dev_name(&pdev->dev));
707-
if (err)
708-
goto fail_gpio_c;
709-
err = gpio_request(EP93XX_GPIO_LINE_D(i), dev_name(&pdev->dev));
710-
if (err)
711-
goto fail_gpio_d;
712-
}
713-
714-
/* Enable the keypad controller; GPIO ports C and D used for keypad */
715-
ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_KEYS |
716-
EP93XX_SYSCON_DEVCFG_GONK);
717-
718-
return 0;
719-
720-
fail_gpio_d:
721-
gpio_free(EP93XX_GPIO_LINE_C(i));
722-
fail_gpio_c:
723-
for (--i; i >= 0; --i) {
724-
gpio_free(EP93XX_GPIO_LINE_C(i));
725-
gpio_free(EP93XX_GPIO_LINE_D(i));
726-
}
727-
return err;
728-
}
729-
EXPORT_SYMBOL(ep93xx_keypad_acquire_gpio);
730-
731-
void ep93xx_keypad_release_gpio(struct platform_device *pdev)
732-
{
733-
int i;
734-
735-
for (i = 0; i < 8; i++) {
736-
gpio_free(EP93XX_GPIO_LINE_C(i));
737-
gpio_free(EP93XX_GPIO_LINE_D(i));
738-
}
739-
740-
/* Disable the keypad controller; GPIO ports C and D used for GPIO */
741-
ep93xx_devcfg_set_bits(EP93XX_SYSCON_DEVCFG_KEYS |
742-
EP93XX_SYSCON_DEVCFG_GONK);
743-
}
744-
EXPORT_SYMBOL(ep93xx_keypad_release_gpio);
745-
746700
/*************************************************************************
747701
* EP93xx I2S audio peripheral handling
748702
*************************************************************************/

drivers/input/keyboard/ep93xx_keypad.c

Lines changed: 22 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,20 @@
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
/*
@@ -61,12 +53,16 @@
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

6661
struct 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

134130
static 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)
220204
static 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-
230207
static 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+
316285
static 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,

include/linux/soc/cirrus/ep93xx.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ int ep93xx_pwm_acquire_gpio(struct platform_device *pdev);
4141
void ep93xx_pwm_release_gpio(struct platform_device *pdev);
4242
int ep93xx_ide_acquire_gpio(struct platform_device *pdev);
4343
void ep93xx_ide_release_gpio(struct platform_device *pdev);
44-
int ep93xx_keypad_acquire_gpio(struct platform_device *pdev);
45-
void ep93xx_keypad_release_gpio(struct platform_device *pdev);
4644
int ep93xx_i2s_acquire(void);
4745
void ep93xx_i2s_release(void);
4846
unsigned int ep93xx_chip_revision(void);
@@ -52,8 +50,6 @@ static inline int ep93xx_pwm_acquire_gpio(struct platform_device *pdev) { return
5250
static inline void ep93xx_pwm_release_gpio(struct platform_device *pdev) {}
5351
static inline int ep93xx_ide_acquire_gpio(struct platform_device *pdev) { return 0; }
5452
static inline void ep93xx_ide_release_gpio(struct platform_device *pdev) {}
55-
static inline int ep93xx_keypad_acquire_gpio(struct platform_device *pdev) { return 0; }
56-
static inline void ep93xx_keypad_release_gpio(struct platform_device *pdev) {}
5753
static inline int ep93xx_i2s_acquire(void) { return 0; }
5854
static inline void ep93xx_i2s_release(void) {}
5955
static inline unsigned int ep93xx_chip_revision(void) { return 0; }

0 commit comments

Comments
 (0)