ezkit.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  1. /*
  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. #include <linux/device.h>
  31. #include <linux/platform_device.h>
  32. #include <linux/mtd/mtd.h>
  33. #include <linux/mtd/partitions.h>
  34. #include <linux/spi/spi.h>
  35. #include <linux/spi/flash.h>
  36. #include <linux/irq.h>
  37. #include <linux/interrupt.h>
  38. #include <linux/usb/musb.h>
  39. #include <asm/bfin5xx_spi.h>
  40. #include <asm/cplb.h>
  41. #include <asm/dma.h>
  42. #include <asm/gpio.h>
  43. #include <asm/nand.h>
  44. #include <asm/mach/bf54x_keys.h>
  45. #include <linux/input.h>
  46. #include <linux/spi/ad7877.h>
  47. /*
  48. * Name the Board for the /proc/cpuinfo
  49. */
  50. char *bfin_board_name = "ADSP-BF548-EZKIT";
  51. /*
  52. * Driver needs to know address, irq and flag pin.
  53. */
  54. #if defined(CONFIG_FB_BF54X_LQ043) || defined(CONFIG_FB_BF54X_LQ043_MODULE)
  55. #include <asm/mach/bf54x-lq043.h>
  56. static struct bfin_bf54xfb_mach_info bf54x_lq043_data = {
  57. .width = 480,
  58. .height = 272,
  59. .xres = {480, 480, 480},
  60. .yres = {272, 272, 272},
  61. .bpp = {24, 24, 24},
  62. .disp = GPIO_PE3,
  63. };
  64. static struct resource bf54x_lq043_resources[] = {
  65. {
  66. .start = IRQ_EPPI0_ERR,
  67. .end = IRQ_EPPI0_ERR,
  68. .flags = IORESOURCE_IRQ,
  69. },
  70. };
  71. static struct platform_device bf54x_lq043_device = {
  72. .name = "bf54x-lq043",
  73. .id = -1,
  74. .num_resources = ARRAY_SIZE(bf54x_lq043_resources),
  75. .resource = bf54x_lq043_resources,
  76. .dev = {
  77. .platform_data = &bf54x_lq043_data,
  78. },
  79. };
  80. #endif
  81. #if defined(CONFIG_KEYBOARD_BFIN) || defined(CONFIG_KEYBOARD_BFIN_MODULE)
  82. static const unsigned int bf548_keymap[] = {
  83. KEYVAL(0, 0, KEY_ENTER),
  84. KEYVAL(0, 1, KEY_HELP),
  85. KEYVAL(0, 2, KEY_0),
  86. KEYVAL(0, 3, KEY_BACKSPACE),
  87. KEYVAL(1, 0, KEY_TAB),
  88. KEYVAL(1, 1, KEY_9),
  89. KEYVAL(1, 2, KEY_8),
  90. KEYVAL(1, 3, KEY_7),
  91. KEYVAL(2, 0, KEY_DOWN),
  92. KEYVAL(2, 1, KEY_6),
  93. KEYVAL(2, 2, KEY_5),
  94. KEYVAL(2, 3, KEY_4),
  95. KEYVAL(3, 0, KEY_UP),
  96. KEYVAL(3, 1, KEY_3),
  97. KEYVAL(3, 2, KEY_2),
  98. KEYVAL(3, 3, KEY_1),
  99. };
  100. static struct bfin_kpad_platform_data bf54x_kpad_data = {
  101. .rows = 4,
  102. .cols = 4,
  103. .keymap = bf548_keymap,
  104. .keymapsize = ARRAY_SIZE(bf548_keymap),
  105. .repeat = 0,
  106. .debounce_time = 5000, /* ns (5ms) */
  107. .coldrive_time = 1000, /* ns (1ms) */
  108. .keyup_test_interval = 50, /* ms (50ms) */
  109. };
  110. static struct resource bf54x_kpad_resources[] = {
  111. {
  112. .start = IRQ_KEY,
  113. .end = IRQ_KEY,
  114. .flags = IORESOURCE_IRQ,
  115. },
  116. };
  117. static struct platform_device bf54x_kpad_device = {
  118. .name = "bf54x-keys",
  119. .id = -1,
  120. .num_resources = ARRAY_SIZE(bf54x_kpad_resources),
  121. .resource = bf54x_kpad_resources,
  122. .dev = {
  123. .platform_data = &bf54x_kpad_data,
  124. },
  125. };
  126. #endif
  127. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  128. static struct platform_device rtc_device = {
  129. .name = "rtc-bfin",
  130. .id = -1,
  131. };
  132. #endif
  133. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  134. static struct resource bfin_uart_resources[] = {
  135. #ifdef CONFIG_SERIAL_BFIN_UART0
  136. {
  137. .start = 0xFFC00400,
  138. .end = 0xFFC004FF,
  139. .flags = IORESOURCE_MEM,
  140. },
  141. #endif
  142. #ifdef CONFIG_SERIAL_BFIN_UART1
  143. {
  144. .start = 0xFFC02000,
  145. .end = 0xFFC020FF,
  146. .flags = IORESOURCE_MEM,
  147. },
  148. #endif
  149. #ifdef CONFIG_SERIAL_BFIN_UART2
  150. {
  151. .start = 0xFFC02100,
  152. .end = 0xFFC021FF,
  153. .flags = IORESOURCE_MEM,
  154. },
  155. #endif
  156. #ifdef CONFIG_SERIAL_BFIN_UART3
  157. {
  158. .start = 0xFFC03100,
  159. .end = 0xFFC031FF,
  160. },
  161. #endif
  162. };
  163. static struct platform_device bfin_uart_device = {
  164. .name = "bfin-uart",
  165. .id = 1,
  166. .num_resources = ARRAY_SIZE(bfin_uart_resources),
  167. .resource = bfin_uart_resources,
  168. };
  169. #endif
  170. #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
  171. static struct resource smsc911x_resources[] = {
  172. {
  173. .name = "smsc911x-memory",
  174. .start = 0x24000000,
  175. .end = 0x24000000 + 0xFF,
  176. .flags = IORESOURCE_MEM,
  177. },
  178. {
  179. .start = IRQ_PE8,
  180. .end = IRQ_PE8,
  181. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  182. },
  183. };
  184. static struct platform_device smsc911x_device = {
  185. .name = "smsc911x",
  186. .id = 0,
  187. .num_resources = ARRAY_SIZE(smsc911x_resources),
  188. .resource = smsc911x_resources,
  189. };
  190. #endif
  191. #if defined(CONFIG_USB_BF54x_HCD) || defined(CONFIG_USB_BF54x_HCD_MODULE)
  192. static struct resource bf54x_hcd_resources[] = {
  193. {
  194. .start = 0xFFC03C00,
  195. .end = 0xFFC040FF,
  196. .flags = IORESOURCE_MEM,
  197. },
  198. };
  199. static struct platform_device bf54x_hcd = {
  200. .name = "bf54x-hcd",
  201. .id = 0,
  202. .num_resources = ARRAY_SIZE(bf54x_hcd_resources),
  203. .resource = bf54x_hcd_resources,
  204. };
  205. #endif
  206. #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
  207. static struct resource musb_resources[] = {
  208. [0] = {
  209. .start = 0xFFC03C00,
  210. .end = 0xFFC040FF,
  211. .flags = IORESOURCE_MEM,
  212. },
  213. [1] = { /* general IRQ */
  214. .start = IRQ_USB_INT0,
  215. .end = IRQ_USB_INT0,
  216. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  217. },
  218. [2] = { /* DMA IRQ */
  219. .start = IRQ_USB_DMA,
  220. .end = IRQ_USB_DMA,
  221. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  222. },
  223. };
  224. static struct musb_hdrc_platform_data musb_plat = {
  225. #ifdef CONFIG_USB_MUSB_OTG
  226. .mode = MUSB_OTG,
  227. #elif CONFIG_USB_MUSB_HDRC_HCD
  228. .mode = MUSB_HOST,
  229. #elif CONFIG_USB_GADGET_MUSB_HDRC
  230. .mode = MUSB_PERIPHERAL,
  231. #endif
  232. .multipoint = 1,
  233. };
  234. static u64 musb_dmamask = ~(u32)0;
  235. static struct platform_device musb_device = {
  236. .name = "musb_hdrc",
  237. .id = 0,
  238. .dev = {
  239. .dma_mask = &musb_dmamask,
  240. .coherent_dma_mask = 0xffffffff,
  241. .platform_data = &musb_plat,
  242. },
  243. .num_resources = ARRAY_SIZE(musb_resources),
  244. .resource = musb_resources,
  245. };
  246. #endif
  247. #if defined(CONFIG_PATA_BF54X) || defined(CONFIG_PATA_BF54X_MODULE)
  248. static struct resource bfin_atapi_resources[] = {
  249. {
  250. .start = 0xFFC03800,
  251. .end = 0xFFC0386F,
  252. .flags = IORESOURCE_MEM,
  253. },
  254. {
  255. .start = IRQ_ATAPI_ERR,
  256. .end = IRQ_ATAPI_ERR,
  257. .flags = IORESOURCE_IRQ,
  258. },
  259. };
  260. static struct platform_device bfin_atapi_device = {
  261. .name = "pata-bf54x",
  262. .id = -1,
  263. .num_resources = ARRAY_SIZE(bfin_atapi_resources),
  264. .resource = bfin_atapi_resources,
  265. };
  266. #endif
  267. #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
  268. static struct mtd_partition partition_info[] = {
  269. {
  270. .name = "Linux Kernel",
  271. .offset = 0,
  272. .size = 4 * SIZE_1M,
  273. },
  274. {
  275. .name = "File System",
  276. .offset = 4 * SIZE_1M,
  277. .size = (256 - 4) * SIZE_1M,
  278. },
  279. };
  280. static struct bf5xx_nand_platform bf5xx_nand_platform = {
  281. .page_size = NFC_PG_SIZE_256,
  282. .data_width = NFC_NWIDTH_8,
  283. .partitions = partition_info,
  284. .nr_partitions = ARRAY_SIZE(partition_info),
  285. .rd_dly = 3,
  286. .wr_dly = 3,
  287. };
  288. static struct resource bf5xx_nand_resources[] = {
  289. {
  290. .start = 0xFFC03B00,
  291. .end = 0xFFC03B4F,
  292. .flags = IORESOURCE_MEM,
  293. },
  294. {
  295. .start = CH_NFC,
  296. .end = CH_NFC,
  297. .flags = IORESOURCE_IRQ,
  298. },
  299. };
  300. static struct platform_device bf5xx_nand_device = {
  301. .name = "bf5xx-nand",
  302. .id = 0,
  303. .num_resources = ARRAY_SIZE(bf5xx_nand_resources),
  304. .resource = bf5xx_nand_resources,
  305. .dev = {
  306. .platform_data = &bf5xx_nand_platform,
  307. },
  308. };
  309. #endif
  310. #if defined(CONFIG_SDH_BFIN) || defined(CONFIG_SDH_BFIN)
  311. static struct platform_device bf54x_sdh_device = {
  312. .name = "bfin-sdh",
  313. .id = 0,
  314. };
  315. #endif
  316. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  317. /* all SPI peripherals info goes here */
  318. #if defined(CONFIG_MTD_M25P80) \
  319. || defined(CONFIG_MTD_M25P80_MODULE)
  320. /* SPI flash chip (m25p16) */
  321. static struct mtd_partition bfin_spi_flash_partitions[] = {
  322. {
  323. .name = "bootloader",
  324. .size = 0x00040000,
  325. .offset = 0,
  326. .mask_flags = MTD_CAP_ROM
  327. }, {
  328. .name = "linux kernel",
  329. .size = 0x1c0000,
  330. .offset = 0x40000
  331. }
  332. };
  333. static struct flash_platform_data bfin_spi_flash_data = {
  334. .name = "m25p80",
  335. .parts = bfin_spi_flash_partitions,
  336. .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
  337. .type = "m25p16",
  338. };
  339. static struct bfin5xx_spi_chip spi_flash_chip_info = {
  340. .enable_dma = 0, /* use dma transfer with this chip*/
  341. .bits_per_word = 8,
  342. .cs_change_per_word = 0,
  343. };
  344. #endif
  345. #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
  346. static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
  347. .cs_change_per_word = 1,
  348. .enable_dma = 0,
  349. .bits_per_word = 16,
  350. };
  351. static const struct ad7877_platform_data bfin_ad7877_ts_info = {
  352. .model = 7877,
  353. .vref_delay_usecs = 50, /* internal, no capacitor */
  354. .x_plate_ohms = 419,
  355. .y_plate_ohms = 486,
  356. .pressure_max = 1000,
  357. .pressure_min = 0,
  358. .stopacq_polarity = 1,
  359. .first_conversion_delay = 3,
  360. .acquisition_time = 1,
  361. .averaging = 1,
  362. .pen_down_acc_interval = 1,
  363. };
  364. #endif
  365. static struct spi_board_info bf54x_spi_board_info[] __initdata = {
  366. #if defined(CONFIG_MTD_M25P80) \
  367. || defined(CONFIG_MTD_M25P80_MODULE)
  368. {
  369. /* the modalias must be the same as spi device driver name */
  370. .modalias = "m25p80", /* Name of spi_driver for this device */
  371. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  372. .bus_num = 0, /* Framework bus number */
  373. .chip_select = 1, /* SPI_SSEL1*/
  374. .platform_data = &bfin_spi_flash_data,
  375. .controller_data = &spi_flash_chip_info,
  376. .mode = SPI_MODE_3,
  377. },
  378. #endif
  379. #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
  380. {
  381. .modalias = "ad7877",
  382. .platform_data = &bfin_ad7877_ts_info,
  383. .irq = IRQ_PJ11,
  384. .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
  385. .bus_num = 0,
  386. .chip_select = 2,
  387. .controller_data = &spi_ad7877_chip_info,
  388. },
  389. #endif
  390. };
  391. /* SPI (0) */
  392. static struct resource bfin_spi0_resource[] = {
  393. [0] = {
  394. .start = SPI0_REGBASE,
  395. .end = SPI0_REGBASE + 0xFF,
  396. .flags = IORESOURCE_MEM,
  397. },
  398. [1] = {
  399. .start = CH_SPI0,
  400. .end = CH_SPI0,
  401. .flags = IORESOURCE_IRQ,
  402. }
  403. };
  404. /* SPI (1) */
  405. static struct resource bfin_spi1_resource[] = {
  406. [0] = {
  407. .start = SPI1_REGBASE,
  408. .end = SPI1_REGBASE + 0xFF,
  409. .flags = IORESOURCE_MEM,
  410. },
  411. [1] = {
  412. .start = CH_SPI1,
  413. .end = CH_SPI1,
  414. .flags = IORESOURCE_IRQ,
  415. }
  416. };
  417. /* SPI controller data */
  418. static struct bfin5xx_spi_master bf54x_spi_master_info = {
  419. .num_chipselect = 8,
  420. .enable_dma = 1, /* master has the ability to do dma transfer */
  421. };
  422. static struct platform_device bf54x_spi_master0 = {
  423. .name = "bfin-spi",
  424. .id = 0, /* Bus number */
  425. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  426. .resource = bfin_spi0_resource,
  427. .dev = {
  428. .platform_data = &bf54x_spi_master_info, /* Passed to driver */
  429. },
  430. };
  431. static struct platform_device bf54x_spi_master1 = {
  432. .name = "bfin-spi",
  433. .id = 1, /* Bus number */
  434. .num_resources = ARRAY_SIZE(bfin_spi1_resource),
  435. .resource = bfin_spi1_resource,
  436. .dev = {
  437. .platform_data = &bf54x_spi_master_info, /* Passed to driver */
  438. },
  439. };
  440. #endif /* spi master and devices */
  441. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  442. static struct resource bfin_twi0_resource[] = {
  443. [0] = {
  444. .start = TWI0_REGBASE,
  445. .end = TWI0_REGBASE + 0xFF,
  446. .flags = IORESOURCE_MEM,
  447. },
  448. [1] = {
  449. .start = IRQ_TWI0,
  450. .end = IRQ_TWI0,
  451. .flags = IORESOURCE_IRQ,
  452. },
  453. };
  454. static struct platform_device i2c_bfin_twi0_device = {
  455. .name = "i2c-bfin-twi",
  456. .id = 0,
  457. .num_resources = ARRAY_SIZE(bfin_twi0_resource),
  458. .resource = bfin_twi0_resource,
  459. };
  460. static struct resource bfin_twi1_resource[] = {
  461. [0] = {
  462. .start = TWI1_REGBASE,
  463. .end = TWI1_REGBASE + 0xFF,
  464. .flags = IORESOURCE_MEM,
  465. },
  466. [1] = {
  467. .start = IRQ_TWI1,
  468. .end = IRQ_TWI1,
  469. .flags = IORESOURCE_IRQ,
  470. },
  471. };
  472. static struct platform_device i2c_bfin_twi1_device = {
  473. .name = "i2c-bfin-twi",
  474. .id = 1,
  475. .num_resources = ARRAY_SIZE(bfin_twi1_resource),
  476. .resource = bfin_twi1_resource,
  477. };
  478. #endif
  479. static struct platform_device *ezkit_devices[] __initdata = {
  480. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  481. &rtc_device,
  482. #endif
  483. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  484. &bfin_uart_device,
  485. #endif
  486. #if defined(CONFIG_FB_BF54X_LQ043) || defined(CONFIG_FB_BF54X_LQ043_MODULE)
  487. &bf54x_lq043_device,
  488. #endif
  489. #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
  490. &smsc911x_device,
  491. #endif
  492. #if defined(CONFIG_USB_BF54x_HCD) || defined(CONFIG_USB_BF54x_HCD_MODULE)
  493. &bf54x_hcd,
  494. #endif
  495. #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
  496. &musb_device,
  497. #endif
  498. #if defined(CONFIG_PATA_BF54X) || defined(CONFIG_PATA_BF54X_MODULE)
  499. &bfin_atapi_device,
  500. #endif
  501. #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
  502. &bf5xx_nand_device,
  503. #endif
  504. #if defined(CONFIG_SDH_BFIN) || defined(CONFIG_SDH_BFIN)
  505. &bf54x_sdh_device,
  506. #endif
  507. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  508. &bf54x_spi_master0,
  509. /* &bf54x_spi_master1,*/
  510. #endif
  511. #if defined(CONFIG_KEYBOARD_BFIN) || defined(CONFIG_KEYBOARD_BFIN_MODULE)
  512. &bf54x_kpad_device,
  513. #endif
  514. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  515. &i2c_bfin_twi0_device,
  516. &i2c_bfin_twi1_device,
  517. #endif
  518. };
  519. static int __init stamp_init(void)
  520. {
  521. printk(KERN_INFO "%s(): registering device resources\n", __FUNCTION__);
  522. platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices));
  523. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  524. spi_register_board_info(bf54x_spi_board_info,
  525. ARRAY_SIZE(bf54x_spi_board_info));
  526. #endif
  527. return 0;
  528. }
  529. arch_initcall(stamp_init);