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>
14 #include <asm/mach-ralink/dev-gpio-buttons.h>
16 void __init ramips_register_gpio_buttons(int id,
17 unsigned poll_interval,
19 struct gpio_button *buttons)
21 struct platform_device *pdev;
22 struct gpio_buttons_platform_data pdata;
23 struct gpio_button *p;
26 p = kmalloc(nbuttons * sizeof(*p), GFP_KERNEL);
30 memcpy(p, buttons, nbuttons * sizeof(*p));
32 pdev = platform_device_alloc("gpio-buttons", id);
34 goto err_free_buttons;
36 memset(&pdata, 0, sizeof(pdata));
37 pdata.poll_interval = poll_interval;
38 pdata.nbuttons = nbuttons;
41 err = platform_device_add_data(pdev, &pdata, sizeof(pdata));
46 err = platform_device_add(pdev);
53 platform_device_put(pdev);