b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 1 | --- a/arch/mips/ath25/Makefile |
| 2 | +++ b/arch/mips/ath25/Makefile |
| 3 | @@ -8,7 +8,7 @@ |
| 4 | # Copyright (C) 2006-2009 Felix Fietkau <nbd@openwrt.org> |
| 5 | # |
| 6 | |
| 7 | -obj-y += board.o prom.o devices.o |
| 8 | +obj-y += board.o prom.o devices.o reset.o |
| 9 | |
| 10 | obj-$(CONFIG_EARLY_PRINTK) += early_printk.o |
| 11 | |
| 12 | --- /dev/null |
| 13 | +++ b/arch/mips/ath25/reset.c |
| 14 | @@ -0,0 +1,57 @@ |
| 15 | +#include <linux/init.h> |
| 16 | +#include <linux/slab.h> |
| 17 | +#include <linux/platform_device.h> |
| 18 | +#include <linux/gpio_keys.h> |
| 19 | +#include <linux/input.h> |
| 20 | +#include <ath25_platform.h> |
| 21 | +#include "devices.h" |
| 22 | + |
| 23 | +static int __init |
| 24 | +ar231x_init_reset(void) |
| 25 | +{ |
| 26 | + struct platform_device *pdev; |
| 27 | + struct gpio_keys_platform_data pdata; |
| 28 | + struct gpio_keys_button *p; |
| 29 | + int err; |
| 30 | + |
| 31 | + if (ath25_board.config->reset_config_gpio == 0xffff) |
| 32 | + return -ENODEV; |
| 33 | + |
| 34 | + p = kzalloc(sizeof(*p), GFP_KERNEL); |
| 35 | + if (!p) |
| 36 | + goto err; |
| 37 | + |
| 38 | + p->desc = "reset"; |
| 39 | + p->type = EV_KEY; |
| 40 | + p->code = KEY_RESTART; |
| 41 | + p->debounce_interval = 60; |
| 42 | + p->gpio = ath25_board.config->reset_config_gpio; |
| 43 | + |
| 44 | + memset(&pdata, 0, sizeof(pdata)); |
| 45 | + pdata.poll_interval = 20; |
| 46 | + pdata.buttons = p; |
| 47 | + pdata.nbuttons = 1; |
| 48 | + |
| 49 | + pdev = platform_device_alloc("gpio-keys-polled", 0); |
| 50 | + if (!pdev) |
| 51 | + goto err_free; |
| 52 | + |
| 53 | + err = platform_device_add_data(pdev, &pdata, sizeof(pdata)); |
| 54 | + if (err) |
| 55 | + goto err_put_pdev; |
| 56 | + |
| 57 | + err = platform_device_add(pdev); |
| 58 | + if (err) |
| 59 | + goto err_put_pdev; |
| 60 | + |
| 61 | + return 0; |
| 62 | + |
| 63 | +err_put_pdev: |
| 64 | + platform_device_put(pdev); |
| 65 | +err_free: |
| 66 | + kfree(p); |
| 67 | +err: |
| 68 | + return -ENOMEM; |
| 69 | +} |
| 70 | + |
| 71 | +device_initcall(ar231x_init_reset); |