Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <nikita.shubin@maquefel.me>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Acked-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

authored by

Nikita Shubin and committed by
Arnd Bergmann
b3ab5787 9cefdd1a

+22 -102
-46
arch/arm/mach-ep93xx/core.c
··· 697 697 platform_device_register(&ep93xx_keypad_device); 698 698 } 699 699 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 - 746 700 /************************************************************************* 747 701 * EP93xx I2S audio peripheral handling 748 702 *************************************************************************/
+22 -52
drivers/input/keyboard/ep93xx_keypad.c
··· 6 6 * 7 7 * Based on the pxa27x matrix keypad controller by Rodolfo Giometti. 8 8 * 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. 18 9 */ 19 10 20 11 #include <linux/bits.h> 12 + #include <linux/mod_devicetable.h> 21 13 #include <linux/module.h> 22 14 #include <linux/platform_device.h> 15 + #include <linux/property.h> 23 16 #include <linux/interrupt.h> 24 17 #include <linux/clk.h> 25 18 #include <linux/io.h> ··· 20 27 #include <linux/input/matrix_keypad.h> 21 28 #include <linux/slab.h> 22 29 #include <linux/soc/cirrus/ep93xx.h> 23 - #include <linux/platform_data/keypad-ep93xx.h> 24 30 #include <linux/pm_wakeirq.h> 25 31 26 32 /* ··· 53 61 #define KEY_REG_KEY1_MASK GENMASK(5, 0) 54 62 #define KEY_REG_KEY1_SHIFT 0 55 63 64 + #define EP93XX_MATRIX_ROWS (8) 65 + #define EP93XX_MATRIX_COLS (8) 66 + 56 67 #define EP93XX_MATRIX_SIZE (EP93XX_MATRIX_ROWS * EP93XX_MATRIX_COLS) 57 68 58 69 struct ep93xx_keypad { 59 - struct ep93xx_keypad_platform_data *pdata; 60 70 struct input_dev *input_dev; 61 71 struct clk *clk; 72 + unsigned int debounce; 73 + u16 prescale; 62 74 63 75 void __iomem *mmio_base; 64 76 ··· 129 133 130 134 static void ep93xx_keypad_config(struct ep93xx_keypad *keypad) 131 135 { 132 - struct ep93xx_keypad_platform_data *pdata = keypad->pdata; 133 136 unsigned int val = 0; 134 137 135 - clk_set_rate(keypad->clk, pdata->clk_rate); 138 + val |= (keypad->debounce << KEY_INIT_DBNC_SHIFT) & KEY_INIT_DBNC_MASK; 136 139 137 - if (pdata->flags & EP93XX_KEYPAD_DISABLE_3_KEY) 138 - val |= KEY_INIT_DIS3KY; 139 - if (pdata->flags & EP93XX_KEYPAD_DIAG_MODE) 140 - val |= KEY_INIT_DIAG; 141 - if (pdata->flags & EP93XX_KEYPAD_BACK_DRIVE) 142 - val |= KEY_INIT_BACK; 143 - if (pdata->flags & EP93XX_KEYPAD_TEST_MODE) 144 - val |= KEY_INIT_T2; 145 - 146 - val |= ((pdata->debounce << KEY_INIT_DBNC_SHIFT) & KEY_INIT_DBNC_MASK); 147 - 148 - val |= ((pdata->prescale << KEY_INIT_PRSCL_SHIFT) & KEY_INIT_PRSCL_MASK); 140 + val |= (keypad->prescale << KEY_INIT_PRSCL_SHIFT) & KEY_INIT_PRSCL_MASK; 149 141 150 142 __raw_writel(val, keypad->mmio_base + KEY_INIT); 151 143 } ··· 204 220 static DEFINE_SIMPLE_DEV_PM_OPS(ep93xx_keypad_pm_ops, 205 221 ep93xx_keypad_suspend, ep93xx_keypad_resume); 206 222 207 - static void ep93xx_keypad_release_gpio_action(void *_pdev) 208 - { 209 - struct platform_device *pdev = _pdev; 210 - 211 - ep93xx_keypad_release_gpio(pdev); 212 - } 213 - 214 223 static int ep93xx_keypad_probe(struct platform_device *pdev) 215 224 { 225 + struct device *dev = &pdev->dev; 216 226 struct ep93xx_keypad *keypad; 217 - const struct matrix_keymap_data *keymap_data; 218 227 struct input_dev *input_dev; 219 228 int err; 220 229 221 230 keypad = devm_kzalloc(&pdev->dev, sizeof(*keypad), GFP_KERNEL); 222 231 if (!keypad) 223 232 return -ENOMEM; 224 - 225 - keypad->pdata = dev_get_platdata(&pdev->dev); 226 - if (!keypad->pdata) 227 - return -EINVAL; 228 - 229 - keymap_data = keypad->pdata->keymap_data; 230 - if (!keymap_data) 231 - return -EINVAL; 232 233 233 234 keypad->irq = platform_get_irq(pdev, 0); 234 235 if (keypad->irq < 0) ··· 223 254 if (IS_ERR(keypad->mmio_base)) 224 255 return PTR_ERR(keypad->mmio_base); 225 256 226 - err = ep93xx_keypad_acquire_gpio(pdev); 227 - if (err) 228 - return err; 229 - 230 - err = devm_add_action_or_reset(&pdev->dev, 231 - ep93xx_keypad_release_gpio_action, pdev); 232 - if (err) 233 - return err; 234 - 235 257 keypad->clk = devm_clk_get(&pdev->dev, NULL); 236 258 if (IS_ERR(keypad->clk)) 237 259 return PTR_ERR(keypad->clk); 260 + 261 + device_property_read_u32(dev, "debounce-delay-ms", &keypad->debounce); 262 + device_property_read_u16(dev, "cirrus,prescale", &keypad->prescale); 238 263 239 264 input_dev = devm_input_allocate_device(&pdev->dev); 240 265 if (!input_dev) ··· 241 278 input_dev->open = ep93xx_keypad_open; 242 279 input_dev->close = ep93xx_keypad_close; 243 280 244 - err = matrix_keypad_build_keymap(keymap_data, NULL, 281 + err = matrix_keypad_build_keymap(NULL, NULL, 245 282 EP93XX_MATRIX_ROWS, EP93XX_MATRIX_COLS, 246 283 keypad->keycodes, input_dev); 247 284 if (err) 248 285 return err; 249 286 250 - if (keypad->pdata->flags & EP93XX_KEYPAD_AUTOREPEAT) 287 + if (device_property_read_bool(&pdev->dev, "autorepeat")) 251 288 __set_bit(EV_REP, input_dev->evbit); 252 289 input_set_drvdata(input_dev, keypad); 253 290 ··· 276 313 dev_pm_clear_wake_irq(&pdev->dev); 277 314 } 278 315 316 + static const struct of_device_id ep93xx_keypad_of_ids[] = { 317 + { .compatible = "cirrus,ep9307-keypad" }, 318 + { /* sentinel */ } 319 + }; 320 + MODULE_DEVICE_TABLE(of, ep93xx_keypad_of_ids); 321 + 279 322 static struct platform_driver ep93xx_keypad_driver = { 280 323 .driver = { 281 324 .name = "ep93xx-keypad", 282 325 .pm = pm_sleep_ptr(&ep93xx_keypad_pm_ops), 326 + .of_match_table = ep93xx_keypad_of_ids, 283 327 }, 284 328 .probe = ep93xx_keypad_probe, 285 329 .remove_new = ep93xx_keypad_remove,
-4
include/linux/soc/cirrus/ep93xx.h
··· 41 41 void ep93xx_pwm_release_gpio(struct platform_device *pdev); 42 42 int ep93xx_ide_acquire_gpio(struct platform_device *pdev); 43 43 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); 46 44 int ep93xx_i2s_acquire(void); 47 45 void ep93xx_i2s_release(void); 48 46 unsigned int ep93xx_chip_revision(void); ··· 50 52 static inline void ep93xx_pwm_release_gpio(struct platform_device *pdev) {} 51 53 static inline int ep93xx_ide_acquire_gpio(struct platform_device *pdev) { return 0; } 52 54 static inline void ep93xx_ide_release_gpio(struct platform_device *pdev) {} 53 - static inline int ep93xx_keypad_acquire_gpio(struct platform_device *pdev) { return 0; } 54 - static inline void ep93xx_keypad_release_gpio(struct platform_device *pdev) {} 55 55 static inline int ep93xx_i2s_acquire(void) { return 0; } 56 56 static inline void ep93xx_i2s_release(void) {} 57 57 static inline unsigned int ep93xx_chip_revision(void) { return 0; }