blob: 0d74b7d99209e7460c5af87f9926d9ea1c32c32e [file] [log] [blame]
Bryan Wu1394f032007-05-06 14:50:22 -07001/*
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>
Mike Frysingerde8c43f2008-01-24 17:14:04 +080032#include <linux/mtd/mtd.h>
33#include <linux/mtd/partitions.h>
34#include <linux/mtd/physmap.h>
Bryan Wu1394f032007-05-06 14:50:22 -070035#include <linux/spi/spi.h>
Michael Hennerich140a9ae2007-05-21 18:09:13 +080036#include <linux/irq.h>
Mike Frysinger1f83b8f2007-07-12 22:58:21 +080037#include <linux/interrupt.h>
Jeff Garzik0a87e3e2008-02-01 18:02:30 -050038#include <linux/ata_platform.h>
Bryan Wuc6c4d7b2007-10-11 01:20:06 +080039#include <asm/dma.h>
Mike Frysinger1f83b8f2007-07-12 22:58:21 +080040#include <asm/bfin5xx_spi.h>
Bryan Wu5d448dd2007-11-12 23:24:42 +080041#include <asm/portmux.h>
Bryan Wu1394f032007-05-06 14:50:22 -070042
43/*
44 * Name the Board for the /proc/cpuinfo
45 */
Mike Frysinger066954a2007-10-21 22:36:06 +080046const char bfin_board_name[] = "ADDS-BF561-EZKIT";
Bryan Wu1394f032007-05-06 14:50:22 -070047
Michael Hennerich140a9ae2007-05-21 18:09:13 +080048#define ISP1761_BASE 0x2C0F0000
49#define ISP1761_IRQ IRQ_PF10
50
51#if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
52static struct resource bfin_isp1761_resources[] = {
Mike Frysinger1f83b8f2007-07-12 22:58:21 +080053 {
Michael Hennerich140a9ae2007-05-21 18:09:13 +080054 .name = "isp1761-regs",
55 .start = ISP1761_BASE + 0x00000000,
56 .end = ISP1761_BASE + 0x000fffff,
57 .flags = IORESOURCE_MEM,
58 },
Mike Frysinger1f83b8f2007-07-12 22:58:21 +080059 {
Michael Hennerich140a9ae2007-05-21 18:09:13 +080060 .start = ISP1761_IRQ,
61 .end = ISP1761_IRQ,
62 .flags = IORESOURCE_IRQ,
63 },
64};
65
66static struct platform_device bfin_isp1761_device = {
67 .name = "isp1761",
68 .id = 0,
69 .num_resources = ARRAY_SIZE(bfin_isp1761_resources),
70 .resource = bfin_isp1761_resources,
71};
72
73static struct platform_device *bfin_isp1761_devices[] = {
74 &bfin_isp1761_device,
75};
76
77int __init bfin_isp1761_init(void)
78{
Mike Frysinger1f83b8f2007-07-12 22:58:21 +080079 unsigned int num_devices = ARRAY_SIZE(bfin_isp1761_devices);
Michael Hennerich140a9ae2007-05-21 18:09:13 +080080
Harvey Harrisonb85d8582008-04-23 09:39:01 +080081 printk(KERN_INFO "%s(): registering device resources\n", __func__);
Michael Hennerich140a9ae2007-05-21 18:09:13 +080082 set_irq_type(ISP1761_IRQ, IRQF_TRIGGER_FALLING);
83
84 return platform_add_devices(bfin_isp1761_devices, num_devices);
85}
86
87void __exit bfin_isp1761_exit(void)
88{
89 platform_device_unregister(&bfin_isp1761_device);
90}
91
92arch_initcall(bfin_isp1761_init);
93#endif
94
Michael Henneriche9d76c22008-02-02 14:55:28 +080095#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
96#include <linux/usb/isp1362.h>
97
98static struct resource isp1362_hcd_resources[] = {
99 {
100 .start = 0x2c060000,
101 .end = 0x2c060000,
102 .flags = IORESOURCE_MEM,
103 }, {
104 .start = 0x2c060004,
105 .end = 0x2c060004,
106 .flags = IORESOURCE_MEM,
107 }, {
108 .start = IRQ_PF8,
109 .end = IRQ_PF8,
110 .flags = IORESOURCE_IRQ,
111 },
112};
113
114static struct isp1362_platform_data isp1362_priv = {
115 .sel15Kres = 1,
116 .clknotstop = 0,
117 .oc_enable = 0,
118 .int_act_high = 0,
119 .int_edge_triggered = 0,
120 .remote_wakeup_connected = 0,
121 .no_power_switching = 1,
122 .power_switching_mode = 0,
123};
124
125static struct platform_device isp1362_hcd_device = {
126 .name = "isp1362-hcd",
127 .id = 0,
128 .dev = {
129 .platform_data = &isp1362_priv,
130 },
131 .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
132 .resource = isp1362_hcd_resources,
133};
134#endif
135
Michael Hennerich83d9cde2008-02-02 16:25:17 +0800136#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
137static struct resource net2272_bfin_resources[] = {
138 {
139 .start = 0x2C000000,
140 .end = 0x2C000000 + 0x7F,
141 .flags = IORESOURCE_MEM,
142 }, {
143 .start = IRQ_PF10,
144 .end = IRQ_PF10,
145 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
146 },
147};
148
149static struct platform_device net2272_bfin_device = {
150 .name = "net2272",
151 .id = -1,
152 .num_resources = ARRAY_SIZE(net2272_bfin_resources),
153 .resource = net2272_bfin_resources,
154};
155#endif
156
Bryan Wu1394f032007-05-06 14:50:22 -0700157/*
158 * USB-LAN EzExtender board
159 * Driver needs to know address, irq and flag pin.
160 */
161#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
162static struct resource smc91x_resources[] = {
163 {
164 .name = "smc91x-regs",
165 .start = 0x2C010300,
166 .end = 0x2C010300 + 16,
167 .flags = IORESOURCE_MEM,
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800168 }, {
Bryan Wu1394f032007-05-06 14:50:22 -0700169
170 .start = IRQ_PF9,
171 .end = IRQ_PF9,
172 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
173 },
174};
175
176static struct platform_device smc91x_device = {
177 .name = "smc91x",
178 .id = 0,
179 .num_resources = ARRAY_SIZE(smc91x_resources),
180 .resource = smc91x_resources,
181};
182#endif
183
Michael Hennerich561cc182007-11-17 23:56:08 +0800184#if defined(CONFIG_AX88180) || defined(CONFIG_AX88180_MODULE)
185static struct resource ax88180_resources[] = {
186 [0] = {
187 .start = 0x2c000000,
188 .end = 0x2c000000 + 0x8000,
189 .flags = IORESOURCE_MEM,
190 },
191 [1] = {
192 .start = IRQ_PF10,
193 .end = IRQ_PF10,
194 .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL),
195 },
196};
197
198static struct platform_device ax88180_device = {
199 .name = "ax88180",
200 .id = -1,
201 .num_resources = ARRAY_SIZE(ax88180_resources),
202 .resource = ax88180_resources,
203};
204#endif
205
Bryan Wu1394f032007-05-06 14:50:22 -0700206#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
207static struct resource bfin_uart_resources[] = {
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800208 {
209 .start = 0xFFC00400,
210 .end = 0xFFC004FF,
211 .flags = IORESOURCE_MEM,
212 },
Bryan Wu1394f032007-05-06 14:50:22 -0700213};
214
215static struct platform_device bfin_uart_device = {
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800216 .name = "bfin-uart",
217 .id = 1,
218 .num_resources = ARRAY_SIZE(bfin_uart_resources),
219 .resource = bfin_uart_resources,
Bryan Wu1394f032007-05-06 14:50:22 -0700220};
221#endif
222
Graf Yang5be36d22008-04-25 03:09:15 +0800223#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
224static struct resource bfin_sir_resources[] = {
225#ifdef CONFIG_BFIN_SIR0
226 {
227 .start = 0xFFC00400,
228 .end = 0xFFC004FF,
229 .flags = IORESOURCE_MEM,
230 },
231#endif
232};
233
234static struct platform_device bfin_sir_device = {
235 .name = "bfin_sir",
236 .id = 0,
237 .num_resources = ARRAY_SIZE(bfin_sir_resources),
238 .resource = bfin_sir_resources,
239};
240#endif
241
Mike Frysinger793dc272008-03-26 08:09:12 +0800242#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
Mike Frysingerde8c43f2008-01-24 17:14:04 +0800243static struct mtd_partition ezkit_partitions[] = {
244 {
245 .name = "Bootloader",
Mike Frysingeredf05642008-02-25 11:38:11 +0800246 .size = 0x40000,
Mike Frysingerde8c43f2008-01-24 17:14:04 +0800247 .offset = 0,
248 }, {
249 .name = "Kernel",
Grace Panac76d882008-04-24 06:33:56 +0800250 .size = 0x1C0000,
Mike Frysingerde8c43f2008-01-24 17:14:04 +0800251 .offset = MTDPART_OFS_APPEND,
252 }, {
253 .name = "RootFS",
254 .size = MTDPART_SIZ_FULL,
255 .offset = MTDPART_OFS_APPEND,
256 }
257};
258
259static struct physmap_flash_data ezkit_flash_data = {
260 .width = 2,
261 .parts = ezkit_partitions,
262 .nr_parts = ARRAY_SIZE(ezkit_partitions),
263};
264
265static struct resource ezkit_flash_resource = {
266 .start = 0x20000000,
267 .end = 0x207fffff,
268 .flags = IORESOURCE_MEM,
269};
270
271static struct platform_device ezkit_flash_device = {
272 .name = "physmap-flash",
273 .id = 0,
274 .dev = {
275 .platform_data = &ezkit_flash_data,
276 },
277 .num_resources = 1,
278 .resource = &ezkit_flash_resource,
279};
Mike Frysinger793dc272008-03-26 08:09:12 +0800280#endif
Mike Frysingerde8c43f2008-01-24 17:14:04 +0800281
Bryan Wu1394f032007-05-06 14:50:22 -0700282#ifdef CONFIG_SPI_BFIN
283#if defined(CONFIG_SND_BLACKFIN_AD1836) \
284 || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
285static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
286 .enable_dma = 0,
287 .bits_per_word = 16,
288};
289#endif
Michael Hennerich6e668932008-02-09 01:54:09 +0800290
291#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
292static struct bfin5xx_spi_chip spidev_chip_info = {
293 .enable_dma = 0,
294 .bits_per_word = 8,
295};
296#endif
Bryan Wu1394f032007-05-06 14:50:22 -0700297#endif
298
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800299/* SPI (0) */
300static struct resource bfin_spi0_resource[] = {
301 [0] = {
302 .start = SPI0_REGBASE,
303 .end = SPI0_REGBASE + 0xFF,
304 .flags = IORESOURCE_MEM,
305 },
306 [1] = {
307 .start = CH_SPI,
308 .end = CH_SPI,
309 .flags = IORESOURCE_IRQ,
310 }
311};
312
Bryan Wu1394f032007-05-06 14:50:22 -0700313/* SPI controller data */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800314static struct bfin5xx_spi_master bfin_spi0_info = {
Bryan Wu1394f032007-05-06 14:50:22 -0700315 .num_chipselect = 8,
316 .enable_dma = 1, /* master has the ability to do dma transfer */
Bryan Wu5d448dd2007-11-12 23:24:42 +0800317 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
Bryan Wu1394f032007-05-06 14:50:22 -0700318};
319
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800320static struct platform_device bfin_spi0_device = {
321 .name = "bfin-spi",
322 .id = 0, /* Bus number */
323 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
324 .resource = bfin_spi0_resource,
Bryan Wu1394f032007-05-06 14:50:22 -0700325 .dev = {
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800326 .platform_data = &bfin_spi0_info, /* Passed to driver */
Bryan Wu1394f032007-05-06 14:50:22 -0700327 },
328};
329
330static struct spi_board_info bfin_spi_board_info[] __initdata = {
331#if defined(CONFIG_SND_BLACKFIN_AD1836) \
332 || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
333 {
334 .modalias = "ad1836-spi",
335 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800336 .bus_num = 0,
Bryan Wu1394f032007-05-06 14:50:22 -0700337 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
338 .controller_data = &ad1836_spi_chip_info,
339 },
340#endif
Michael Hennerich6e668932008-02-09 01:54:09 +0800341#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
342 {
343 .modalias = "spidev",
344 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
345 .bus_num = 0,
346 .chip_select = 1,
347 .controller_data = &spidev_chip_info,
348 },
349#endif
Bryan Wu1394f032007-05-06 14:50:22 -0700350};
351
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800352#if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
353#define PATA_INT 55
354
355static struct pata_platform_info bfin_pata_platform_data = {
356 .ioport_shift = 1,
357 .irq_type = IRQF_TRIGGER_HIGH | IRQF_DISABLED,
358};
359
360static struct resource bfin_pata_resources[] = {
361 {
362 .start = 0x20314020,
363 .end = 0x2031403F,
364 .flags = IORESOURCE_MEM,
365 },
366 {
367 .start = 0x2031401C,
368 .end = 0x2031401F,
369 .flags = IORESOURCE_MEM,
370 },
371 {
372 .start = PATA_INT,
373 .end = PATA_INT,
374 .flags = IORESOURCE_IRQ,
375 },
376};
377
378static struct platform_device bfin_pata_device = {
379 .name = "pata_platform",
380 .id = -1,
381 .num_resources = ARRAY_SIZE(bfin_pata_resources),
382 .resource = bfin_pata_resources,
383 .dev = {
384 .platform_data = &bfin_pata_platform_data,
385 }
386};
387#endif
388
Michael Hennerich2463ef22008-01-27 16:49:48 +0800389#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
390#include <linux/input.h>
391#include <linux/gpio_keys.h>
392
393static struct gpio_keys_button bfin_gpio_keys_table[] = {
394 {BTN_0, GPIO_PF5, 1, "gpio-keys: BTN0"},
395 {BTN_1, GPIO_PF6, 1, "gpio-keys: BTN1"},
396 {BTN_2, GPIO_PF7, 1, "gpio-keys: BTN2"},
397 {BTN_3, GPIO_PF8, 1, "gpio-keys: BTN3"},
398};
399
400static struct gpio_keys_platform_data bfin_gpio_keys_data = {
401 .buttons = bfin_gpio_keys_table,
402 .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
403};
404
405static struct platform_device bfin_device_gpiokeys = {
406 .name = "gpio-keys",
407 .dev = {
408 .platform_data = &bfin_gpio_keys_data,
409 },
410};
411#endif
412
Mike Frysingercad2ab62008-02-22 17:01:31 +0800413static struct resource bfin_gpios_resources = {
414 .start = 0,
415 .end = MAX_BLACKFIN_GPIOS - 1,
416 .flags = IORESOURCE_IRQ,
417};
418
419static struct platform_device bfin_gpios_device = {
420 .name = "simple-gpio",
421 .id = -1,
422 .num_resources = 1,
423 .resource = &bfin_gpios_resources,
424};
425
Bryan Wue3163952008-01-24 16:19:15 +0800426#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
427#include <linux/i2c-gpio.h>
428
429static struct i2c_gpio_platform_data i2c_gpio_data = {
430 .sda_pin = 1,
431 .scl_pin = 0,
432 .sda_is_open_drain = 0,
433 .scl_is_open_drain = 0,
434 .udelay = 40,
435};
436
437static struct platform_device i2c_gpio_device = {
438 .name = "i2c-gpio",
439 .id = 0,
440 .dev = {
441 .platform_data = &i2c_gpio_data,
442 },
443};
444#endif
445
Bryan Wu1394f032007-05-06 14:50:22 -0700446static struct platform_device *ezkit_devices[] __initdata = {
447#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
448 &smc91x_device,
449#endif
Michael Hennerich561cc182007-11-17 23:56:08 +0800450
451#if defined(CONFIG_AX88180) || defined(CONFIG_AX88180_MODULE)
452 &ax88180_device,
453#endif
454
Michael Hennerich83d9cde2008-02-02 16:25:17 +0800455#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
456 &net2272_bfin_device,
457#endif
458
Bryan Wu1394f032007-05-06 14:50:22 -0700459#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800460 &bfin_spi0_device,
Bryan Wu1394f032007-05-06 14:50:22 -0700461#endif
Michael Hennerich2463ef22008-01-27 16:49:48 +0800462
Bryan Wu1394f032007-05-06 14:50:22 -0700463#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800464 &bfin_uart_device,
Bryan Wu1394f032007-05-06 14:50:22 -0700465#endif
Michael Hennerich2463ef22008-01-27 16:49:48 +0800466
Graf Yang5be36d22008-04-25 03:09:15 +0800467#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
468 &bfin_sir_device,
469#endif
470
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800471#if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
472 &bfin_pata_device,
473#endif
Michael Hennerich2463ef22008-01-27 16:49:48 +0800474
475#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
476 &bfin_device_gpiokeys,
477#endif
Bryan Wue3163952008-01-24 16:19:15 +0800478
479#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
480 &i2c_gpio_device,
481#endif
Michael Henneriche9d76c22008-02-02 14:55:28 +0800482
483#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
484 &isp1362_hcd_device,
485#endif
486
Mike Frysingercad2ab62008-02-22 17:01:31 +0800487 &bfin_gpios_device,
Mike Frysinger793dc272008-03-26 08:09:12 +0800488
489#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
Mike Frysingerde8c43f2008-01-24 17:14:04 +0800490 &ezkit_flash_device,
Mike Frysinger793dc272008-03-26 08:09:12 +0800491#endif
Bryan Wu1394f032007-05-06 14:50:22 -0700492};
493
494static int __init ezkit_init(void)
495{
496 int ret;
497
Mike Frysingerc0fc5252007-05-21 18:09:25 +0800498 printk(KERN_INFO "%s(): registering device resources\n", __func__);
499
500 ret = platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices));
Bryan Wu1394f032007-05-06 14:50:22 -0700501 if (ret < 0)
502 return ret;
Mike Frysingerc0fc5252007-05-21 18:09:25 +0800503
504#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
505 bfin_write_FIO0_DIR(bfin_read_FIO0_DIR() | (1 << 12));
506 SSYNC();
507#endif
508
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800509#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
510 spi_register_board_info(bfin_spi_board_info,
511 ARRAY_SIZE(bfin_spi_board_info));
512#endif
513
514#if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
515 irq_desc[PATA_INT].status |= IRQ_NOAUTOEN;
516#endif
517 return 0;
Bryan Wu1394f032007-05-06 14:50:22 -0700518}
519
520arch_initcall(ezkit_init);