Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1 | /* |
| 2 | * File: arch/blackfin/mach-bf561/ezkit.c |
| 3 | * Based on: |
| 4 | * Author: |
| 5 | * |
| 6 | * Created: |
| 7 | * Description: |
| 8 | * |
| 9 | * Modified: |
| 10 | * Copyright 2004-2006 Analog Devices Inc. |
| 11 | * |
| 12 | * Bugs: Enter bugs at http://blackfin.uclinux.org/ |
| 13 | * |
| 14 | * This program is free software; you can redistribute it and/or modify |
| 15 | * it under the terms of the GNU General Public License as published by |
| 16 | * the Free Software Foundation; either version 2 of the License, or |
| 17 | * (at your option) any later version. |
| 18 | * |
| 19 | * This program is distributed in the hope that it will be useful, |
| 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 | * GNU General Public License for more details. |
| 23 | * |
| 24 | * You should have received a copy of the GNU General Public License |
| 25 | * along with this program; if not, see the file COPYING, or write |
| 26 | * to the Free Software Foundation, Inc., |
| 27 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 28 | */ |
| 29 | |
| 30 | #include <linux/device.h> |
| 31 | #include <linux/platform_device.h> |
| 32 | #include <linux/spi/spi.h> |
Michael Hennerich | 140a9ae | 2007-05-21 18:09:13 +0800 | [diff] [blame] | 33 | #include <linux/irq.h> |
Mike Frysinger | 1f83b8f | 2007-07-12 22:58:21 +0800 | [diff] [blame] | 34 | #include <linux/interrupt.h> |
Bryan Wu | c6c4d7b | 2007-10-11 01:20:06 +0800 | [diff] [blame] | 35 | #include <linux/pata_platform.h> |
| 36 | #include <asm/dma.h> |
Mike Frysinger | 1f83b8f | 2007-07-12 22:58:21 +0800 | [diff] [blame] | 37 | #include <asm/bfin5xx_spi.h> |
Bryan Wu | 5d448dd | 2007-11-12 23:24:42 +0800 | [diff] [blame] | 38 | #include <asm/portmux.h> |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 39 | |
| 40 | /* |
| 41 | * Name the Board for the /proc/cpuinfo |
| 42 | */ |
Mike Frysinger | 066954a | 2007-10-21 22:36:06 +0800 | [diff] [blame] | 43 | const char bfin_board_name[] = "ADDS-BF561-EZKIT"; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 44 | |
Michael Hennerich | 140a9ae | 2007-05-21 18:09:13 +0800 | [diff] [blame] | 45 | #define ISP1761_BASE 0x2C0F0000 |
| 46 | #define ISP1761_IRQ IRQ_PF10 |
| 47 | |
| 48 | #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE) |
| 49 | static struct resource bfin_isp1761_resources[] = { |
Mike Frysinger | 1f83b8f | 2007-07-12 22:58:21 +0800 | [diff] [blame] | 50 | { |
Michael Hennerich | 140a9ae | 2007-05-21 18:09:13 +0800 | [diff] [blame] | 51 | .name = "isp1761-regs", |
| 52 | .start = ISP1761_BASE + 0x00000000, |
| 53 | .end = ISP1761_BASE + 0x000fffff, |
| 54 | .flags = IORESOURCE_MEM, |
| 55 | }, |
Mike Frysinger | 1f83b8f | 2007-07-12 22:58:21 +0800 | [diff] [blame] | 56 | { |
Michael Hennerich | 140a9ae | 2007-05-21 18:09:13 +0800 | [diff] [blame] | 57 | .start = ISP1761_IRQ, |
| 58 | .end = ISP1761_IRQ, |
| 59 | .flags = IORESOURCE_IRQ, |
| 60 | }, |
| 61 | }; |
| 62 | |
| 63 | static struct platform_device bfin_isp1761_device = { |
| 64 | .name = "isp1761", |
| 65 | .id = 0, |
| 66 | .num_resources = ARRAY_SIZE(bfin_isp1761_resources), |
| 67 | .resource = bfin_isp1761_resources, |
| 68 | }; |
| 69 | |
| 70 | static struct platform_device *bfin_isp1761_devices[] = { |
| 71 | &bfin_isp1761_device, |
| 72 | }; |
| 73 | |
| 74 | int __init bfin_isp1761_init(void) |
| 75 | { |
Mike Frysinger | 1f83b8f | 2007-07-12 22:58:21 +0800 | [diff] [blame] | 76 | unsigned int num_devices = ARRAY_SIZE(bfin_isp1761_devices); |
Michael Hennerich | 140a9ae | 2007-05-21 18:09:13 +0800 | [diff] [blame] | 77 | |
| 78 | printk(KERN_INFO "%s(): registering device resources\n", __FUNCTION__); |
| 79 | set_irq_type(ISP1761_IRQ, IRQF_TRIGGER_FALLING); |
| 80 | |
| 81 | return platform_add_devices(bfin_isp1761_devices, num_devices); |
| 82 | } |
| 83 | |
| 84 | void __exit bfin_isp1761_exit(void) |
| 85 | { |
| 86 | platform_device_unregister(&bfin_isp1761_device); |
| 87 | } |
| 88 | |
| 89 | arch_initcall(bfin_isp1761_init); |
| 90 | #endif |
| 91 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 92 | /* |
| 93 | * USB-LAN EzExtender board |
| 94 | * Driver needs to know address, irq and flag pin. |
| 95 | */ |
| 96 | #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE) |
| 97 | static struct resource smc91x_resources[] = { |
| 98 | { |
| 99 | .name = "smc91x-regs", |
| 100 | .start = 0x2C010300, |
| 101 | .end = 0x2C010300 + 16, |
| 102 | .flags = IORESOURCE_MEM, |
Mike Frysinger | 1f83b8f | 2007-07-12 22:58:21 +0800 | [diff] [blame] | 103 | }, { |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 104 | |
| 105 | .start = IRQ_PF9, |
| 106 | .end = IRQ_PF9, |
| 107 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL, |
| 108 | }, |
| 109 | }; |
| 110 | |
| 111 | static struct platform_device smc91x_device = { |
| 112 | .name = "smc91x", |
| 113 | .id = 0, |
| 114 | .num_resources = ARRAY_SIZE(smc91x_resources), |
| 115 | .resource = smc91x_resources, |
| 116 | }; |
| 117 | #endif |
| 118 | |
Michael Hennerich | 561cc18 | 2007-11-17 23:56:08 +0800 | [diff] [blame] | 119 | #if defined(CONFIG_AX88180) || defined(CONFIG_AX88180_MODULE) |
| 120 | static struct resource ax88180_resources[] = { |
| 121 | [0] = { |
| 122 | .start = 0x2c000000, |
| 123 | .end = 0x2c000000 + 0x8000, |
| 124 | .flags = IORESOURCE_MEM, |
| 125 | }, |
| 126 | [1] = { |
| 127 | .start = IRQ_PF10, |
| 128 | .end = IRQ_PF10, |
| 129 | .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL), |
| 130 | }, |
| 131 | }; |
| 132 | |
| 133 | static struct platform_device ax88180_device = { |
| 134 | .name = "ax88180", |
| 135 | .id = -1, |
| 136 | .num_resources = ARRAY_SIZE(ax88180_resources), |
| 137 | .resource = ax88180_resources, |
| 138 | }; |
| 139 | #endif |
| 140 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 141 | #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) |
| 142 | static struct resource bfin_uart_resources[] = { |
Mike Frysinger | 1f83b8f | 2007-07-12 22:58:21 +0800 | [diff] [blame] | 143 | { |
| 144 | .start = 0xFFC00400, |
| 145 | .end = 0xFFC004FF, |
| 146 | .flags = IORESOURCE_MEM, |
| 147 | }, |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 148 | }; |
| 149 | |
| 150 | static struct platform_device bfin_uart_device = { |
Mike Frysinger | 1f83b8f | 2007-07-12 22:58:21 +0800 | [diff] [blame] | 151 | .name = "bfin-uart", |
| 152 | .id = 1, |
| 153 | .num_resources = ARRAY_SIZE(bfin_uart_resources), |
| 154 | .resource = bfin_uart_resources, |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 155 | }; |
| 156 | #endif |
| 157 | |
| 158 | #ifdef CONFIG_SPI_BFIN |
| 159 | #if defined(CONFIG_SND_BLACKFIN_AD1836) \ |
| 160 | || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE) |
| 161 | static struct bfin5xx_spi_chip ad1836_spi_chip_info = { |
| 162 | .enable_dma = 0, |
| 163 | .bits_per_word = 16, |
| 164 | }; |
| 165 | #endif |
| 166 | #endif |
| 167 | |
Bryan Wu | c6c4d7b | 2007-10-11 01:20:06 +0800 | [diff] [blame] | 168 | /* SPI (0) */ |
| 169 | static struct resource bfin_spi0_resource[] = { |
| 170 | [0] = { |
| 171 | .start = SPI0_REGBASE, |
| 172 | .end = SPI0_REGBASE + 0xFF, |
| 173 | .flags = IORESOURCE_MEM, |
| 174 | }, |
| 175 | [1] = { |
| 176 | .start = CH_SPI, |
| 177 | .end = CH_SPI, |
| 178 | .flags = IORESOURCE_IRQ, |
| 179 | } |
| 180 | }; |
| 181 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 182 | /* SPI controller data */ |
Bryan Wu | c6c4d7b | 2007-10-11 01:20:06 +0800 | [diff] [blame] | 183 | static struct bfin5xx_spi_master bfin_spi0_info = { |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 184 | .num_chipselect = 8, |
| 185 | .enable_dma = 1, /* master has the ability to do dma transfer */ |
Bryan Wu | 5d448dd | 2007-11-12 23:24:42 +0800 | [diff] [blame] | 186 | .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0}, |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 187 | }; |
| 188 | |
Bryan Wu | c6c4d7b | 2007-10-11 01:20:06 +0800 | [diff] [blame] | 189 | static struct platform_device bfin_spi0_device = { |
| 190 | .name = "bfin-spi", |
| 191 | .id = 0, /* Bus number */ |
| 192 | .num_resources = ARRAY_SIZE(bfin_spi0_resource), |
| 193 | .resource = bfin_spi0_resource, |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 194 | .dev = { |
Bryan Wu | c6c4d7b | 2007-10-11 01:20:06 +0800 | [diff] [blame] | 195 | .platform_data = &bfin_spi0_info, /* Passed to driver */ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 196 | }, |
| 197 | }; |
| 198 | |
| 199 | static struct spi_board_info bfin_spi_board_info[] __initdata = { |
| 200 | #if defined(CONFIG_SND_BLACKFIN_AD1836) \ |
| 201 | || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE) |
| 202 | { |
| 203 | .modalias = "ad1836-spi", |
| 204 | .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ |
Bryan Wu | c6c4d7b | 2007-10-11 01:20:06 +0800 | [diff] [blame] | 205 | .bus_num = 0, |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 206 | .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT, |
| 207 | .controller_data = &ad1836_spi_chip_info, |
| 208 | }, |
| 209 | #endif |
| 210 | }; |
| 211 | |
Bryan Wu | c6c4d7b | 2007-10-11 01:20:06 +0800 | [diff] [blame] | 212 | #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE) |
| 213 | #define PATA_INT 55 |
| 214 | |
| 215 | static struct pata_platform_info bfin_pata_platform_data = { |
| 216 | .ioport_shift = 1, |
| 217 | .irq_type = IRQF_TRIGGER_HIGH | IRQF_DISABLED, |
| 218 | }; |
| 219 | |
| 220 | static struct resource bfin_pata_resources[] = { |
| 221 | { |
| 222 | .start = 0x20314020, |
| 223 | .end = 0x2031403F, |
| 224 | .flags = IORESOURCE_MEM, |
| 225 | }, |
| 226 | { |
| 227 | .start = 0x2031401C, |
| 228 | .end = 0x2031401F, |
| 229 | .flags = IORESOURCE_MEM, |
| 230 | }, |
| 231 | { |
| 232 | .start = PATA_INT, |
| 233 | .end = PATA_INT, |
| 234 | .flags = IORESOURCE_IRQ, |
| 235 | }, |
| 236 | }; |
| 237 | |
| 238 | static struct platform_device bfin_pata_device = { |
| 239 | .name = "pata_platform", |
| 240 | .id = -1, |
| 241 | .num_resources = ARRAY_SIZE(bfin_pata_resources), |
| 242 | .resource = bfin_pata_resources, |
| 243 | .dev = { |
| 244 | .platform_data = &bfin_pata_platform_data, |
| 245 | } |
| 246 | }; |
| 247 | #endif |
| 248 | |
Michael Hennerich | 2463ef2 | 2008-01-27 16:49:48 +0800 | [diff] [blame^] | 249 | #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) |
| 250 | #include <linux/input.h> |
| 251 | #include <linux/gpio_keys.h> |
| 252 | |
| 253 | static struct gpio_keys_button bfin_gpio_keys_table[] = { |
| 254 | {BTN_0, GPIO_PF5, 1, "gpio-keys: BTN0"}, |
| 255 | {BTN_1, GPIO_PF6, 1, "gpio-keys: BTN1"}, |
| 256 | {BTN_2, GPIO_PF7, 1, "gpio-keys: BTN2"}, |
| 257 | {BTN_3, GPIO_PF8, 1, "gpio-keys: BTN3"}, |
| 258 | }; |
| 259 | |
| 260 | static struct gpio_keys_platform_data bfin_gpio_keys_data = { |
| 261 | .buttons = bfin_gpio_keys_table, |
| 262 | .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table), |
| 263 | }; |
| 264 | |
| 265 | static struct platform_device bfin_device_gpiokeys = { |
| 266 | .name = "gpio-keys", |
| 267 | .dev = { |
| 268 | .platform_data = &bfin_gpio_keys_data, |
| 269 | }, |
| 270 | }; |
| 271 | #endif |
| 272 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 273 | static struct platform_device *ezkit_devices[] __initdata = { |
| 274 | #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE) |
| 275 | &smc91x_device, |
| 276 | #endif |
Michael Hennerich | 561cc18 | 2007-11-17 23:56:08 +0800 | [diff] [blame] | 277 | |
| 278 | #if defined(CONFIG_AX88180) || defined(CONFIG_AX88180_MODULE) |
| 279 | &ax88180_device, |
| 280 | #endif |
| 281 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 282 | #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE) |
Bryan Wu | c6c4d7b | 2007-10-11 01:20:06 +0800 | [diff] [blame] | 283 | &bfin_spi0_device, |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 284 | #endif |
Michael Hennerich | 2463ef2 | 2008-01-27 16:49:48 +0800 | [diff] [blame^] | 285 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 286 | #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) |
Mike Frysinger | 1f83b8f | 2007-07-12 22:58:21 +0800 | [diff] [blame] | 287 | &bfin_uart_device, |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 288 | #endif |
Michael Hennerich | 2463ef2 | 2008-01-27 16:49:48 +0800 | [diff] [blame^] | 289 | |
Bryan Wu | c6c4d7b | 2007-10-11 01:20:06 +0800 | [diff] [blame] | 290 | #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE) |
| 291 | &bfin_pata_device, |
| 292 | #endif |
Michael Hennerich | 2463ef2 | 2008-01-27 16:49:48 +0800 | [diff] [blame^] | 293 | |
| 294 | #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) |
| 295 | &bfin_device_gpiokeys, |
| 296 | #endif |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 297 | }; |
| 298 | |
| 299 | static int __init ezkit_init(void) |
| 300 | { |
| 301 | int ret; |
| 302 | |
Mike Frysinger | c0fc525 | 2007-05-21 18:09:25 +0800 | [diff] [blame] | 303 | printk(KERN_INFO "%s(): registering device resources\n", __func__); |
| 304 | |
| 305 | ret = platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices)); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 306 | if (ret < 0) |
| 307 | return ret; |
Mike Frysinger | c0fc525 | 2007-05-21 18:09:25 +0800 | [diff] [blame] | 308 | |
| 309 | #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE) |
| 310 | bfin_write_FIO0_DIR(bfin_read_FIO0_DIR() | (1 << 12)); |
| 311 | SSYNC(); |
| 312 | #endif |
| 313 | |
Bryan Wu | c6c4d7b | 2007-10-11 01:20:06 +0800 | [diff] [blame] | 314 | #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE) |
| 315 | spi_register_board_info(bfin_spi_board_info, |
| 316 | ARRAY_SIZE(bfin_spi_board_info)); |
| 317 | #endif |
| 318 | |
| 319 | #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE) |
| 320 | irq_desc[PATA_INT].status |= IRQ_NOAUTOEN; |
| 321 | #endif |
| 322 | return 0; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 323 | } |
| 324 | |
| 325 | arch_initcall(ezkit_init); |