| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * MTX-1 platform devices registration (Au1500) |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2007-2009, Florian Fainelli <florian@openwrt.org> |
|---|
| 5 | | - * |
|---|
| 6 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 7 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 8 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 9 | | - * (at your option) any later version. |
|---|
| 10 | | - * |
|---|
| 11 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 12 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 14 | | - * GNU General Public License for more details. |
|---|
| 15 | | - * |
|---|
| 16 | | - * You should have received a copy of the GNU General Public License |
|---|
| 17 | | - * along with this program; if not, write to the Free Software |
|---|
| 18 | | - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|---|
| 19 | 6 | */ |
|---|
| 20 | 7 | |
|---|
| 21 | 8 | #include <linux/init.h> |
|---|
| .. | .. |
|---|
| 24 | 11 | #include <linux/platform_device.h> |
|---|
| 25 | 12 | #include <linux/leds.h> |
|---|
| 26 | 13 | #include <linux/gpio.h> |
|---|
| 14 | +#include <linux/gpio/machine.h> |
|---|
| 27 | 15 | #include <linux/gpio_keys.h> |
|---|
| 28 | 16 | #include <linux/input.h> |
|---|
| 29 | 17 | #include <linux/mtd/partitions.h> |
|---|
| .. | .. |
|---|
| 40 | 28 | const char *get_system_type(void) |
|---|
| 41 | 29 | { |
|---|
| 42 | 30 | return "MTX-1"; |
|---|
| 43 | | -} |
|---|
| 44 | | - |
|---|
| 45 | | -void __init prom_init(void) |
|---|
| 46 | | -{ |
|---|
| 47 | | - unsigned char *memsize_str; |
|---|
| 48 | | - unsigned long memsize; |
|---|
| 49 | | - |
|---|
| 50 | | - prom_argc = fw_arg0; |
|---|
| 51 | | - prom_argv = (char **)fw_arg1; |
|---|
| 52 | | - prom_envp = (char **)fw_arg2; |
|---|
| 53 | | - |
|---|
| 54 | | - prom_init_cmdline(); |
|---|
| 55 | | - |
|---|
| 56 | | - memsize_str = prom_getenv("memsize"); |
|---|
| 57 | | - if (!memsize_str || kstrtoul(memsize_str, 0, &memsize)) |
|---|
| 58 | | - memsize = 0x04000000; |
|---|
| 59 | | - add_memory_region(0, memsize, BOOT_MEM_RAM); |
|---|
| 60 | 31 | } |
|---|
| 61 | 32 | |
|---|
| 62 | 33 | void prom_putchar(char c) |
|---|
| .. | .. |
|---|
| 130 | 101 | } |
|---|
| 131 | 102 | }; |
|---|
| 132 | 103 | |
|---|
| 133 | | -static struct resource mtx1_wdt_res[] = { |
|---|
| 134 | | - [0] = { |
|---|
| 135 | | - .start = 215, |
|---|
| 136 | | - .end = 215, |
|---|
| 137 | | - .name = "mtx1-wdt-gpio", |
|---|
| 138 | | - .flags = IORESOURCE_IRQ, |
|---|
| 139 | | - } |
|---|
| 104 | +static struct gpiod_lookup_table mtx1_wdt_gpio_table = { |
|---|
| 105 | + .dev_id = "mtx1-wdt.0", |
|---|
| 106 | + .table = { |
|---|
| 107 | + /* Global number 215 is offset 15 on Alchemy GPIO 2 */ |
|---|
| 108 | + GPIO_LOOKUP("alchemy-gpio2", 15, NULL, GPIO_ACTIVE_HIGH), |
|---|
| 109 | + { }, |
|---|
| 110 | + }, |
|---|
| 140 | 111 | }; |
|---|
| 141 | 112 | |
|---|
| 142 | 113 | static struct platform_device mtx1_wdt = { |
|---|
| 143 | 114 | .name = "mtx1-wdt", |
|---|
| 144 | 115 | .id = 0, |
|---|
| 145 | | - .num_resources = ARRAY_SIZE(mtx1_wdt_res), |
|---|
| 146 | | - .resource = mtx1_wdt_res, |
|---|
| 147 | 116 | }; |
|---|
| 148 | 117 | |
|---|
| 149 | 118 | static const struct gpio_led default_leds[] = { |
|---|
| .. | .. |
|---|
| 310 | 279 | } |
|---|
| 311 | 280 | gpio_direction_input(mtx1_gpio_button[0].gpio); |
|---|
| 312 | 281 | out: |
|---|
| 282 | + gpiod_add_lookup_table(&mtx1_wdt_gpio_table); |
|---|
| 313 | 283 | return platform_add_devices(mtx1_devs, ARRAY_SIZE(mtx1_devs)); |
|---|
| 314 | 284 | } |
|---|
| 315 | 285 | arch_initcall(mtx1_register_devices); |
|---|