2 * Ralink SoC GPIO button support
4 * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation.
11 #include "linux/init.h"
12 #include <linux/platform_device.h>
13 #include <linux/slab.h>
15 #include <asm/mach-ralink/dev-gpio-buttons.h>
17 void __init ramips_register_gpio_buttons(int id,
18 unsigned poll_interval,
20 struct gpio_keys_button *buttons)
22 struct platform_device *pdev;
23 struct gpio_keys_platform_data pdata;
24 struct gpio_keys_button *p;
27 p = kmalloc(nbuttons * sizeof(*p), GFP_KERNEL);
31 memcpy(p, buttons, nbuttons * sizeof(*p));
33 pdev = platform_device_alloc("gpio-keys-polled", id);
35 goto err_free_buttons;
37 memset(&pdata, 0, sizeof(pdata));
38 pdata.poll_interval = poll_interval;
39 pdata.nbuttons = nbuttons;
42 err = platform_device_add_data(pdev, &pdata, sizeof(pdata));
46 err = platform_device_add(pdev);
53 platform_device_put(pdev);