Florian Fainelli | 26c288f | 2007-10-23 18:55:55 +0200 | [diff] [blame] | 1 | /* |
| 2 | * MTX-1 platform devices registration |
| 3 | * |
Florian Fainelli | a1b021d | 2009-08-01 23:51:20 +0200 | [diff] [blame] | 4 | * Copyright (C) 2007-2009, Florian Fainelli <florian@openwrt.org> |
Florian Fainelli | 26c288f | 2007-10-23 18:55:55 +0200 | [diff] [blame] | 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 | */ |
| 20 | |
| 21 | #include <linux/init.h> |
Florian Fainelli | 26c288f | 2007-10-23 18:55:55 +0200 | [diff] [blame] | 22 | #include <linux/platform_device.h> |
| 23 | #include <linux/leds.h> |
Sergei Shtylyov | 1ff1a78 | 2008-04-30 23:30:12 +0400 | [diff] [blame] | 24 | #include <linux/gpio.h> |
Florian Fainelli | f6ed10a | 2008-01-07 19:00:46 +0100 | [diff] [blame] | 25 | #include <linux/gpio_keys.h> |
| 26 | #include <linux/input.h> |
Yoichi Yuasa | 9528356 | 2008-07-11 22:34:48 +0900 | [diff] [blame] | 27 | #include <linux/mtd/partitions.h> |
| 28 | #include <linux/mtd/physmap.h> |
| 29 | #include <mtd/mtd-abi.h> |
Florian Fainelli | 26c288f | 2007-10-23 18:55:55 +0200 | [diff] [blame] | 30 | |
Florian Fainelli | bf3a1eb | 2011-02-27 19:53:53 +0100 | [diff] [blame] | 31 | #include <asm/mach-au1x00/au1xxx_eth.h> |
| 32 | |
Florian Fainelli | f6ed10a | 2008-01-07 19:00:46 +0100 | [diff] [blame] | 33 | static struct gpio_keys_button mtx1_gpio_button[] = { |
| 34 | { |
| 35 | .gpio = 207, |
| 36 | .code = BTN_0, |
| 37 | .desc = "System button", |
| 38 | } |
| 39 | }; |
| 40 | |
| 41 | static struct gpio_keys_platform_data mtx1_buttons_data = { |
| 42 | .buttons = mtx1_gpio_button, |
| 43 | .nbuttons = ARRAY_SIZE(mtx1_gpio_button), |
| 44 | }; |
| 45 | |
| 46 | static struct platform_device mtx1_button = { |
| 47 | .name = "gpio-keys", |
| 48 | .id = -1, |
| 49 | .dev = { |
| 50 | .platform_data = &mtx1_buttons_data, |
| 51 | } |
| 52 | }; |
| 53 | |
Florian Fainelli | 26c288f | 2007-10-23 18:55:55 +0200 | [diff] [blame] | 54 | static struct resource mtx1_wdt_res[] = { |
| 55 | [0] = { |
Manuel Lauss | b7f720d | 2011-05-08 10:42:20 +0200 | [diff] [blame^] | 56 | .start = 215, |
| 57 | .end = 215, |
Florian Fainelli | 26c288f | 2007-10-23 18:55:55 +0200 | [diff] [blame] | 58 | .name = "mtx1-wdt-gpio", |
| 59 | .flags = IORESOURCE_IRQ, |
| 60 | } |
| 61 | }; |
| 62 | |
Florian Fainelli | 26c288f | 2007-10-23 18:55:55 +0200 | [diff] [blame] | 63 | static struct platform_device mtx1_wdt = { |
| 64 | .name = "mtx1-wdt", |
| 65 | .id = 0, |
| 66 | .num_resources = ARRAY_SIZE(mtx1_wdt_res), |
| 67 | .resource = mtx1_wdt_res, |
| 68 | }; |
| 69 | |
| 70 | static struct gpio_led default_leds[] = { |
| 71 | { |
| 72 | .name = "mtx1:green", |
| 73 | .gpio = 211, |
| 74 | }, { |
| 75 | .name = "mtx1:red", |
| 76 | .gpio = 212, |
| 77 | }, |
| 78 | }; |
| 79 | |
| 80 | static struct gpio_led_platform_data mtx1_led_data = { |
| 81 | .num_leds = ARRAY_SIZE(default_leds), |
| 82 | .leds = default_leds, |
| 83 | }; |
| 84 | |
| 85 | static struct platform_device mtx1_gpio_leds = { |
| 86 | .name = "leds-gpio", |
| 87 | .id = -1, |
| 88 | .dev = { |
| 89 | .platform_data = &mtx1_led_data, |
| 90 | } |
| 91 | }; |
| 92 | |
Yoichi Yuasa | 9528356 | 2008-07-11 22:34:48 +0900 | [diff] [blame] | 93 | static struct mtd_partition mtx1_mtd_partitions[] = { |
| 94 | { |
| 95 | .name = "filesystem", |
| 96 | .size = 0x01C00000, |
| 97 | .offset = 0, |
| 98 | }, |
| 99 | { |
| 100 | .name = "yamon", |
| 101 | .size = 0x00100000, |
| 102 | .offset = MTDPART_OFS_APPEND, |
| 103 | .mask_flags = MTD_WRITEABLE, |
| 104 | }, |
| 105 | { |
| 106 | .name = "kernel", |
| 107 | .size = 0x002c0000, |
| 108 | .offset = MTDPART_OFS_APPEND, |
| 109 | }, |
| 110 | { |
| 111 | .name = "yamon env", |
| 112 | .size = 0x00040000, |
| 113 | .offset = MTDPART_OFS_APPEND, |
| 114 | }, |
| 115 | }; |
| 116 | |
| 117 | static struct physmap_flash_data mtx1_flash_data = { |
| 118 | .width = 4, |
| 119 | .nr_parts = 4, |
| 120 | .parts = mtx1_mtd_partitions, |
| 121 | }; |
| 122 | |
| 123 | static struct resource mtx1_mtd_resource = { |
| 124 | .start = 0x1e000000, |
| 125 | .end = 0x1fffffff, |
| 126 | .flags = IORESOURCE_MEM, |
| 127 | }; |
| 128 | |
| 129 | static struct platform_device mtx1_mtd = { |
| 130 | .name = "physmap-flash", |
| 131 | .dev = { |
| 132 | .platform_data = &mtx1_flash_data, |
| 133 | }, |
| 134 | .num_resources = 1, |
| 135 | .resource = &mtx1_mtd_resource, |
| 136 | }; |
| 137 | |
Florian Fainelli | 26c288f | 2007-10-23 18:55:55 +0200 | [diff] [blame] | 138 | static struct __initdata platform_device * mtx1_devs[] = { |
| 139 | &mtx1_gpio_leds, |
Florian Fainelli | f6ed10a | 2008-01-07 19:00:46 +0100 | [diff] [blame] | 140 | &mtx1_wdt, |
Yoichi Yuasa | 9528356 | 2008-07-11 22:34:48 +0900 | [diff] [blame] | 141 | &mtx1_button, |
| 142 | &mtx1_mtd, |
Florian Fainelli | 26c288f | 2007-10-23 18:55:55 +0200 | [diff] [blame] | 143 | }; |
| 144 | |
Florian Fainelli | bf3a1eb | 2011-02-27 19:53:53 +0100 | [diff] [blame] | 145 | static struct au1000_eth_platform_data mtx1_au1000_eth0_pdata = { |
| 146 | .phy_search_highest_addr = 1, |
| 147 | .phy1_search_mac0 = 1, |
| 148 | }; |
| 149 | |
Florian Fainelli | 26c288f | 2007-10-23 18:55:55 +0200 | [diff] [blame] | 150 | static int __init mtx1_register_devices(void) |
| 151 | { |
Florian Fainelli | a1b021d | 2009-08-01 23:51:20 +0200 | [diff] [blame] | 152 | int rc; |
| 153 | |
Florian Fainelli | bf3a1eb | 2011-02-27 19:53:53 +0100 | [diff] [blame] | 154 | au1xxx_override_eth_cfg(0, &mtx1_au1000_eth0_pdata); |
| 155 | |
Florian Fainelli | a1b021d | 2009-08-01 23:51:20 +0200 | [diff] [blame] | 156 | rc = gpio_request(mtx1_gpio_button[0].gpio, |
| 157 | mtx1_gpio_button[0].desc); |
| 158 | if (rc < 0) { |
| 159 | printk(KERN_INFO "mtx1: failed to request %d\n", |
| 160 | mtx1_gpio_button[0].gpio); |
| 161 | goto out; |
| 162 | } |
| 163 | gpio_direction_input(mtx1_gpio_button[0].gpio); |
| 164 | out: |
Florian Fainelli | 26c288f | 2007-10-23 18:55:55 +0200 | [diff] [blame] | 165 | return platform_add_devices(mtx1_devs, ARRAY_SIZE(mtx1_devs)); |
| 166 | } |
| 167 | |
| 168 | arch_initcall(mtx1_register_devices); |