blob: bbd2a046d7c1cee568a581ee63c074ece6c7903b [file] [log] [blame]
Roy Huang24a07a12007-07-12 22:41:45 +08001/*
2 * File: arch/blackfin/mach-bf548/boards/ezkit.c
3 * Based on: arch/blackfin/mach-bf537/boards/ezkit.c
4 * Author: Aidan Williams <aidan@nicta.com.au>
5 *
6 * Created:
7 * Description:
8 *
9 * Modified:
10 * Copyright 2005 National ICT Australia (NICTA)
11 * Copyright 2004-2007 Analog Devices Inc.
12 *
13 * Bugs: Enter bugs at http://blackfin.uclinux.org/
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, see the file COPYING, or write
27 * to the Free Software Foundation, Inc.,
28 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 */
30
31#include <linux/device.h>
32#include <linux/platform_device.h>
33#include <linux/mtd/mtd.h>
34#include <linux/mtd/partitions.h>
35#include <linux/spi/spi.h>
36#include <linux/spi/flash.h>
Mike Frysinger1f83b8f2007-07-12 22:58:21 +080037#include <linux/irq.h>
Roy Huang24a07a12007-07-12 22:41:45 +080038#include <linux/interrupt.h>
Bryan Wuc6c4d7b2007-10-11 01:20:06 +080039#include <linux/usb/musb.h>
Roy Huang24a07a12007-07-12 22:41:45 +080040#include <asm/bfin5xx_spi.h>
Bryan Wuc6c4d7b2007-10-11 01:20:06 +080041#include <asm/cplb.h>
42#include <asm/dma.h>
43#include <asm/gpio.h>
44#include <asm/nand.h>
Bryan Wu5d448dd2007-11-12 23:24:42 +080045#include <asm/portmux.h>
Bryan Wuc6c4d7b2007-10-11 01:20:06 +080046#include <asm/mach/bf54x_keys.h>
47#include <linux/input.h>
48#include <linux/spi/ad7877.h>
Roy Huang24a07a12007-07-12 22:41:45 +080049
50/*
51 * Name the Board for the /proc/cpuinfo
52 */
Mike Frysinger066954a2007-10-21 22:36:06 +080053const char bfin_board_name[] = "ADSP-BF548-EZKIT";
Roy Huang24a07a12007-07-12 22:41:45 +080054
55/*
56 * Driver needs to know address, irq and flag pin.
57 */
58
Bryan Wuc6c4d7b2007-10-11 01:20:06 +080059#if defined(CONFIG_FB_BF54X_LQ043) || defined(CONFIG_FB_BF54X_LQ043_MODULE)
60
61#include <asm/mach/bf54x-lq043.h>
62
63static struct bfin_bf54xfb_mach_info bf54x_lq043_data = {
64 .width = 480,
65 .height = 272,
66 .xres = {480, 480, 480},
67 .yres = {272, 272, 272},
68 .bpp = {24, 24, 24},
69 .disp = GPIO_PE3,
70};
71
72static struct resource bf54x_lq043_resources[] = {
73 {
74 .start = IRQ_EPPI0_ERR,
75 .end = IRQ_EPPI0_ERR,
76 .flags = IORESOURCE_IRQ,
77 },
78};
79
80static struct platform_device bf54x_lq043_device = {
81 .name = "bf54x-lq043",
82 .id = -1,
83 .num_resources = ARRAY_SIZE(bf54x_lq043_resources),
84 .resource = bf54x_lq043_resources,
85 .dev = {
86 .platform_data = &bf54x_lq043_data,
87 },
88};
89#endif
90
91#if defined(CONFIG_KEYBOARD_BFIN) || defined(CONFIG_KEYBOARD_BFIN_MODULE)
Michael Hennerich8f740ef2007-10-13 00:36:46 -040092static const unsigned int bf548_keymap[] = {
Bryan Wuc6c4d7b2007-10-11 01:20:06 +080093 KEYVAL(0, 0, KEY_ENTER),
94 KEYVAL(0, 1, KEY_HELP),
95 KEYVAL(0, 2, KEY_0),
96 KEYVAL(0, 3, KEY_BACKSPACE),
97 KEYVAL(1, 0, KEY_TAB),
98 KEYVAL(1, 1, KEY_9),
99 KEYVAL(1, 2, KEY_8),
100 KEYVAL(1, 3, KEY_7),
101 KEYVAL(2, 0, KEY_DOWN),
102 KEYVAL(2, 1, KEY_6),
103 KEYVAL(2, 2, KEY_5),
104 KEYVAL(2, 3, KEY_4),
105 KEYVAL(3, 0, KEY_UP),
106 KEYVAL(3, 1, KEY_3),
107 KEYVAL(3, 2, KEY_2),
108 KEYVAL(3, 3, KEY_1),
109};
110
111static struct bfin_kpad_platform_data bf54x_kpad_data = {
112 .rows = 4,
113 .cols = 4,
Michael Hennerich8f740ef2007-10-13 00:36:46 -0400114 .keymap = bf548_keymap,
115 .keymapsize = ARRAY_SIZE(bf548_keymap),
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800116 .repeat = 0,
117 .debounce_time = 5000, /* ns (5ms) */
118 .coldrive_time = 1000, /* ns (1ms) */
119 .keyup_test_interval = 50, /* ms (50ms) */
120};
121
122static struct resource bf54x_kpad_resources[] = {
123 {
124 .start = IRQ_KEY,
125 .end = IRQ_KEY,
126 .flags = IORESOURCE_IRQ,
127 },
128};
129
130static struct platform_device bf54x_kpad_device = {
131 .name = "bf54x-keys",
132 .id = -1,
133 .num_resources = ARRAY_SIZE(bf54x_kpad_resources),
134 .resource = bf54x_kpad_resources,
135 .dev = {
136 .platform_data = &bf54x_kpad_data,
137 },
138};
139#endif
140
Roy Huang24a07a12007-07-12 22:41:45 +0800141#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
142static struct platform_device rtc_device = {
143 .name = "rtc-bfin",
144 .id = -1,
145};
146#endif
147
148#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
149static struct resource bfin_uart_resources[] = {
150#ifdef CONFIG_SERIAL_BFIN_UART0
151 {
152 .start = 0xFFC00400,
153 .end = 0xFFC004FF,
154 .flags = IORESOURCE_MEM,
155 },
156#endif
157#ifdef CONFIG_SERIAL_BFIN_UART1
158 {
159 .start = 0xFFC02000,
160 .end = 0xFFC020FF,
161 .flags = IORESOURCE_MEM,
162 },
163#endif
164#ifdef CONFIG_SERIAL_BFIN_UART2
165 {
166 .start = 0xFFC02100,
167 .end = 0xFFC021FF,
168 .flags = IORESOURCE_MEM,
169 },
170#endif
171#ifdef CONFIG_SERIAL_BFIN_UART3
172 {
173 .start = 0xFFC03100,
174 .end = 0xFFC031FF,
175 },
176#endif
177};
178
179static struct platform_device bfin_uart_device = {
180 .name = "bfin-uart",
181 .id = 1,
182 .num_resources = ARRAY_SIZE(bfin_uart_resources),
183 .resource = bfin_uart_resources,
184};
185#endif
186
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800187#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
188static struct resource smsc911x_resources[] = {
189 {
190 .name = "smsc911x-memory",
191 .start = 0x24000000,
192 .end = 0x24000000 + 0xFF,
193 .flags = IORESOURCE_MEM,
194 },
195 {
196 .start = IRQ_PE8,
197 .end = IRQ_PE8,
198 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
199 },
200};
201static struct platform_device smsc911x_device = {
202 .name = "smsc911x",
203 .id = 0,
204 .num_resources = ARRAY_SIZE(smsc911x_resources),
205 .resource = smsc911x_resources,
206};
207#endif
208
209#if defined(CONFIG_USB_BF54x_HCD) || defined(CONFIG_USB_BF54x_HCD_MODULE)
210static struct resource bf54x_hcd_resources[] = {
211 {
212 .start = 0xFFC03C00,
213 .end = 0xFFC040FF,
214 .flags = IORESOURCE_MEM,
215 },
216};
217
218static struct platform_device bf54x_hcd = {
219 .name = "bf54x-hcd",
220 .id = 0,
221 .num_resources = ARRAY_SIZE(bf54x_hcd_resources),
222 .resource = bf54x_hcd_resources,
223};
224#endif
225
226#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
227static struct resource musb_resources[] = {
228 [0] = {
229 .start = 0xFFC03C00,
230 .end = 0xFFC040FF,
231 .flags = IORESOURCE_MEM,
232 },
233 [1] = { /* general IRQ */
234 .start = IRQ_USB_INT0,
235 .end = IRQ_USB_INT0,
236 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
237 },
238 [2] = { /* DMA IRQ */
239 .start = IRQ_USB_DMA,
240 .end = IRQ_USB_DMA,
241 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
242 },
243};
244
245static struct musb_hdrc_platform_data musb_plat = {
246#ifdef CONFIG_USB_MUSB_OTG
247 .mode = MUSB_OTG,
248#elif CONFIG_USB_MUSB_HDRC_HCD
249 .mode = MUSB_HOST,
250#elif CONFIG_USB_GADGET_MUSB_HDRC
251 .mode = MUSB_PERIPHERAL,
252#endif
253 .multipoint = 1,
254};
255
256static u64 musb_dmamask = ~(u32)0;
257
258static struct platform_device musb_device = {
259 .name = "musb_hdrc",
260 .id = 0,
261 .dev = {
262 .dma_mask = &musb_dmamask,
263 .coherent_dma_mask = 0xffffffff,
264 .platform_data = &musb_plat,
265 },
266 .num_resources = ARRAY_SIZE(musb_resources),
267 .resource = musb_resources,
268};
269#endif
270
271#if defined(CONFIG_PATA_BF54X) || defined(CONFIG_PATA_BF54X_MODULE)
272static struct resource bfin_atapi_resources[] = {
273 {
274 .start = 0xFFC03800,
275 .end = 0xFFC0386F,
276 .flags = IORESOURCE_MEM,
277 },
278 {
279 .start = IRQ_ATAPI_ERR,
280 .end = IRQ_ATAPI_ERR,
281 .flags = IORESOURCE_IRQ,
282 },
283};
284
285static struct platform_device bfin_atapi_device = {
286 .name = "pata-bf54x",
287 .id = -1,
288 .num_resources = ARRAY_SIZE(bfin_atapi_resources),
289 .resource = bfin_atapi_resources,
290};
291#endif
292
293#if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
294static struct mtd_partition partition_info[] = {
295 {
296 .name = "Linux Kernel",
297 .offset = 0,
298 .size = 4 * SIZE_1M,
299 },
300 {
301 .name = "File System",
302 .offset = 4 * SIZE_1M,
303 .size = (256 - 4) * SIZE_1M,
304 },
305};
306
307static struct bf5xx_nand_platform bf5xx_nand_platform = {
308 .page_size = NFC_PG_SIZE_256,
309 .data_width = NFC_NWIDTH_8,
310 .partitions = partition_info,
311 .nr_partitions = ARRAY_SIZE(partition_info),
312 .rd_dly = 3,
313 .wr_dly = 3,
314};
315
316static struct resource bf5xx_nand_resources[] = {
317 {
318 .start = 0xFFC03B00,
319 .end = 0xFFC03B4F,
320 .flags = IORESOURCE_MEM,
321 },
322 {
323 .start = CH_NFC,
324 .end = CH_NFC,
325 .flags = IORESOURCE_IRQ,
326 },
327};
328
329static struct platform_device bf5xx_nand_device = {
330 .name = "bf5xx-nand",
331 .id = 0,
332 .num_resources = ARRAY_SIZE(bf5xx_nand_resources),
333 .resource = bf5xx_nand_resources,
334 .dev = {
335 .platform_data = &bf5xx_nand_platform,
336 },
337};
338#endif
339
340#if defined(CONFIG_SDH_BFIN) || defined(CONFIG_SDH_BFIN)
341static struct platform_device bf54x_sdh_device = {
342 .name = "bfin-sdh",
343 .id = 0,
344};
345#endif
346
347#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
348/* all SPI peripherals info goes here */
349#if defined(CONFIG_MTD_M25P80) \
350 || defined(CONFIG_MTD_M25P80_MODULE)
351/* SPI flash chip (m25p16) */
352static struct mtd_partition bfin_spi_flash_partitions[] = {
353 {
354 .name = "bootloader",
355 .size = 0x00040000,
356 .offset = 0,
357 .mask_flags = MTD_CAP_ROM
358 }, {
359 .name = "linux kernel",
360 .size = 0x1c0000,
361 .offset = 0x40000
362 }
363};
364
365static struct flash_platform_data bfin_spi_flash_data = {
366 .name = "m25p80",
367 .parts = bfin_spi_flash_partitions,
368 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
369 .type = "m25p16",
370};
371
372static struct bfin5xx_spi_chip spi_flash_chip_info = {
373 .enable_dma = 0, /* use dma transfer with this chip*/
374 .bits_per_word = 8,
375 .cs_change_per_word = 0,
376};
377#endif
378
379#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
380static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
Michael Hennerichc7d48962007-11-15 21:33:31 +0800381 .cs_change_per_word = 0,
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800382 .enable_dma = 0,
383 .bits_per_word = 16,
384};
385
386static const struct ad7877_platform_data bfin_ad7877_ts_info = {
387 .model = 7877,
388 .vref_delay_usecs = 50, /* internal, no capacitor */
389 .x_plate_ohms = 419,
390 .y_plate_ohms = 486,
391 .pressure_max = 1000,
392 .pressure_min = 0,
393 .stopacq_polarity = 1,
394 .first_conversion_delay = 3,
395 .acquisition_time = 1,
396 .averaging = 1,
397 .pen_down_acc_interval = 1,
398};
399#endif
400
401static struct spi_board_info bf54x_spi_board_info[] __initdata = {
402#if defined(CONFIG_MTD_M25P80) \
403 || defined(CONFIG_MTD_M25P80_MODULE)
404 {
405 /* the modalias must be the same as spi device driver name */
406 .modalias = "m25p80", /* Name of spi_driver for this device */
407 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
408 .bus_num = 0, /* Framework bus number */
409 .chip_select = 1, /* SPI_SSEL1*/
410 .platform_data = &bfin_spi_flash_data,
411 .controller_data = &spi_flash_chip_info,
412 .mode = SPI_MODE_3,
413 },
414#endif
415#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
416{
417 .modalias = "ad7877",
418 .platform_data = &bfin_ad7877_ts_info,
419 .irq = IRQ_PJ11,
420 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
421 .bus_num = 0,
422 .chip_select = 2,
423 .controller_data = &spi_ad7877_chip_info,
424},
425#endif
426};
427
428/* SPI (0) */
429static struct resource bfin_spi0_resource[] = {
430 [0] = {
431 .start = SPI0_REGBASE,
432 .end = SPI0_REGBASE + 0xFF,
433 .flags = IORESOURCE_MEM,
434 },
435 [1] = {
436 .start = CH_SPI0,
437 .end = CH_SPI0,
438 .flags = IORESOURCE_IRQ,
439 }
440};
441
442/* SPI (1) */
443static struct resource bfin_spi1_resource[] = {
444 [0] = {
445 .start = SPI1_REGBASE,
446 .end = SPI1_REGBASE + 0xFF,
447 .flags = IORESOURCE_MEM,
448 },
449 [1] = {
450 .start = CH_SPI1,
451 .end = CH_SPI1,
452 .flags = IORESOURCE_IRQ,
453 }
454};
455
456/* SPI controller data */
Bryan Wu5d448dd2007-11-12 23:24:42 +0800457static struct bfin5xx_spi_master bf54x_spi_master_info0 = {
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800458 .num_chipselect = 8,
459 .enable_dma = 1, /* master has the ability to do dma transfer */
Bryan Wu5d448dd2007-11-12 23:24:42 +0800460 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800461};
462
463static struct platform_device bf54x_spi_master0 = {
464 .name = "bfin-spi",
465 .id = 0, /* Bus number */
466 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
467 .resource = bfin_spi0_resource,
468 .dev = {
Bryan Wu5d448dd2007-11-12 23:24:42 +0800469 .platform_data = &bf54x_spi_master_info0, /* Passed to driver */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800470 },
471};
472
Bryan Wu5d448dd2007-11-12 23:24:42 +0800473static struct bfin5xx_spi_master bf54x_spi_master_info1 = {
474 .num_chipselect = 8,
475 .enable_dma = 1, /* master has the ability to do dma transfer */
476 .pin_req = {P_SPI1_SCK, P_SPI1_MISO, P_SPI1_MOSI, 0},
477};
478
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800479static struct platform_device bf54x_spi_master1 = {
480 .name = "bfin-spi",
481 .id = 1, /* Bus number */
482 .num_resources = ARRAY_SIZE(bfin_spi1_resource),
483 .resource = bfin_spi1_resource,
484 .dev = {
Bryan Wu5d448dd2007-11-12 23:24:42 +0800485 .platform_data = &bf54x_spi_master_info1, /* Passed to driver */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800486 },
487};
488#endif /* spi master and devices */
489
490#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
491static struct resource bfin_twi0_resource[] = {
492 [0] = {
493 .start = TWI0_REGBASE,
494 .end = TWI0_REGBASE + 0xFF,
495 .flags = IORESOURCE_MEM,
496 },
497 [1] = {
498 .start = IRQ_TWI0,
499 .end = IRQ_TWI0,
500 .flags = IORESOURCE_IRQ,
501 },
502};
503
504static struct platform_device i2c_bfin_twi0_device = {
505 .name = "i2c-bfin-twi",
506 .id = 0,
507 .num_resources = ARRAY_SIZE(bfin_twi0_resource),
508 .resource = bfin_twi0_resource,
509};
510
511static struct resource bfin_twi1_resource[] = {
512 [0] = {
513 .start = TWI1_REGBASE,
514 .end = TWI1_REGBASE + 0xFF,
515 .flags = IORESOURCE_MEM,
516 },
517 [1] = {
518 .start = IRQ_TWI1,
519 .end = IRQ_TWI1,
520 .flags = IORESOURCE_IRQ,
521 },
522};
523
524static struct platform_device i2c_bfin_twi1_device = {
525 .name = "i2c-bfin-twi",
526 .id = 1,
527 .num_resources = ARRAY_SIZE(bfin_twi1_resource),
528 .resource = bfin_twi1_resource,
529};
530#endif
531
Roy Huang24a07a12007-07-12 22:41:45 +0800532static struct platform_device *ezkit_devices[] __initdata = {
533#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
534 &rtc_device,
535#endif
536
537#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
538 &bfin_uart_device,
539#endif
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800540
541#if defined(CONFIG_FB_BF54X_LQ043) || defined(CONFIG_FB_BF54X_LQ043_MODULE)
542 &bf54x_lq043_device,
543#endif
544
545#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
546 &smsc911x_device,
547#endif
548
549#if defined(CONFIG_USB_BF54x_HCD) || defined(CONFIG_USB_BF54x_HCD_MODULE)
550 &bf54x_hcd,
551#endif
552
553#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
554 &musb_device,
555#endif
556
557#if defined(CONFIG_PATA_BF54X) || defined(CONFIG_PATA_BF54X_MODULE)
558 &bfin_atapi_device,
559#endif
560
561#if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
562 &bf5xx_nand_device,
563#endif
564
565#if defined(CONFIG_SDH_BFIN) || defined(CONFIG_SDH_BFIN)
566 &bf54x_sdh_device,
567#endif
568
569#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
570 &bf54x_spi_master0,
Bryan Wud4b1d272007-10-21 17:03:55 +0800571 &bf54x_spi_master1,
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800572#endif
573
574#if defined(CONFIG_KEYBOARD_BFIN) || defined(CONFIG_KEYBOARD_BFIN_MODULE)
575 &bf54x_kpad_device,
576#endif
577
578#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
579 &i2c_bfin_twi0_device,
580 &i2c_bfin_twi1_device,
581#endif
Roy Huang24a07a12007-07-12 22:41:45 +0800582};
583
584static int __init stamp_init(void)
585{
586 printk(KERN_INFO "%s(): registering device resources\n", __FUNCTION__);
587 platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices));
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800588
589#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
590 spi_register_board_info(bf54x_spi_board_info,
591 ARRAY_SIZE(bf54x_spi_board_info));
592#endif
593
Roy Huang24a07a12007-07-12 22:41:45 +0800594 return 0;
595}
596
597arch_initcall(stamp_init);