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

Input: spear-keyboard - add device tree bindings

This adds simple DT bindings for spear-keyboard controller.

Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>

authored by

Viresh Kumar and committed by
Dmitry Torokhov
829c4f96 b45c8f35

+56 -15
+56 -15
drivers/input/keyboard/spear-keyboard.c
··· 19 19 #include <linux/irq.h> 20 20 #include <linux/kernel.h> 21 21 #include <linux/module.h> 22 + #include <linux/of.h> 22 23 #include <linux/platform_device.h> 23 24 #include <linux/pm_wakeup.h> 24 25 #include <linux/slab.h> ··· 64 63 unsigned int mode; 65 64 unsigned short last_key; 66 65 unsigned short keycodes[NUM_ROWS * NUM_COLS]; 66 + bool rep; 67 67 }; 68 68 69 69 static irqreturn_t spear_kbd_interrupt(int irq, void *dev_id) ··· 140 138 kbd->last_key = KEY_RESERVED; 141 139 } 142 140 141 + #ifdef CONFIG_OF 142 + static int __devinit spear_kbd_parse_dt(struct platform_device *pdev, 143 + struct spear_kbd *kbd) 144 + { 145 + struct device_node *np = pdev->dev.of_node; 146 + int error; 147 + u32 val; 148 + 149 + if (!np) { 150 + dev_err(&pdev->dev, "Missing DT data\n"); 151 + return -EINVAL; 152 + } 153 + 154 + if (of_property_read_bool(np, "autorepeat")) 155 + kbd->rep = true; 156 + 157 + error = of_property_read_u32(np, "st,mode", &val); 158 + if (error) { 159 + dev_err(&pdev->dev, "DT: Invalid or missing mode\n"); 160 + return error; 161 + } 162 + 163 + kbd->mode = val; 164 + return 0; 165 + } 166 + #else 167 + static inline int spear_kbd_parse_dt(struct platform_device *pdev, 168 + struct spear_kbd *kbd) 169 + { 170 + return -ENOSYS; 171 + } 172 + #endif 173 + 143 174 static int __devinit spear_kbd_probe(struct platform_device *pdev) 144 175 { 145 - const struct kbd_platform_data *pdata = pdev->dev.platform_data; 146 - const struct matrix_keymap_data *keymap; 176 + struct kbd_platform_data *pdata = dev_get_platdata(&pdev->dev); 177 + const struct matrix_keymap_data *keymap = pdata ? pdata->keymap : NULL; 147 178 struct spear_kbd *kbd; 148 179 struct input_dev *input_dev; 149 180 struct resource *res; 150 181 int irq; 151 182 int error; 152 - 153 - if (!pdata) { 154 - dev_err(&pdev->dev, "Invalid platform data\n"); 155 - return -EINVAL; 156 - } 157 - 158 - keymap = pdata->keymap; 159 - if (!keymap) { 160 - dev_err(&pdev->dev, "no keymap defined\n"); 161 - return -EINVAL; 162 - } 163 183 164 184 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 165 185 if (!res) { ··· 205 181 206 182 kbd->input = input_dev; 207 183 kbd->irq = irq; 208 - kbd->mode = pdata->mode; 184 + 185 + if (!pdata) { 186 + error = spear_kbd_parse_dt(pdev, kbd); 187 + if (error) 188 + goto err_free_mem; 189 + } else { 190 + kbd->mode = pdata->mode; 191 + kbd->rep = pdata->rep; 192 + } 209 193 210 194 kbd->res = request_mem_region(res->start, resource_size(res), 211 195 pdev->name); ··· 253 221 goto err_put_clk; 254 222 } 255 223 256 - if (pdata->rep) 224 + if (kbd->rep) 257 225 __set_bit(EV_REP, input_dev->evbit); 258 226 input_set_capability(input_dev, EV_MSC, MSC_SCAN); 259 227 ··· 350 318 351 319 static SIMPLE_DEV_PM_OPS(spear_kbd_pm_ops, spear_kbd_suspend, spear_kbd_resume); 352 320 321 + #ifdef CONFIG_OF 322 + static const struct of_device_id spear_kbd_id_table[] = { 323 + { .compatible = "st,spear300-kbd" }, 324 + {} 325 + }; 326 + MODULE_DEVICE_TABLE(of, spear_kbd_id_table); 327 + #endif 328 + 353 329 static struct platform_driver spear_kbd_driver = { 354 330 .probe = spear_kbd_probe, 355 331 .remove = __devexit_p(spear_kbd_remove), ··· 365 325 .name = "keyboard", 366 326 .owner = THIS_MODULE, 367 327 .pm = &spear_kbd_pm_ops, 328 + .of_match_table = of_match_ptr(spear_kbd_id_table), 368 329 }, 369 330 }; 370 331 module_platform_driver(spear_kbd_driver);