ezkit.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  1. /*
  2. * File: arch/blackfin/mach-bf538/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-2008 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 <asm/bfin5xx_spi.h>
  39. #include <asm/dma.h>
  40. #include <asm/gpio.h>
  41. #include <asm/nand.h>
  42. #include <asm/portmux.h>
  43. #include <asm/dpmc.h>
  44. #include <linux/input.h>
  45. /*
  46. * Name the Board for the /proc/cpuinfo
  47. */
  48. const char bfin_board_name[] = "ADI BF538-EZKIT";
  49. /*
  50. * Driver needs to know address, irq and flag pin.
  51. */
  52. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  53. static struct platform_device rtc_device = {
  54. .name = "rtc-bfin",
  55. .id = -1,
  56. };
  57. #endif
  58. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  59. static struct resource bfin_uart_resources[] = {
  60. #ifdef CONFIG_SERIAL_BFIN_UART0
  61. {
  62. .start = 0xFFC00400,
  63. .end = 0xFFC004FF,
  64. .flags = IORESOURCE_MEM,
  65. },
  66. #endif
  67. #ifdef CONFIG_SERIAL_BFIN_UART1
  68. {
  69. .start = 0xFFC02000,
  70. .end = 0xFFC020FF,
  71. .flags = IORESOURCE_MEM,
  72. },
  73. #endif
  74. #ifdef CONFIG_SERIAL_BFIN_UART2
  75. {
  76. .start = 0xFFC02100,
  77. .end = 0xFFC021FF,
  78. .flags = IORESOURCE_MEM,
  79. },
  80. #endif
  81. };
  82. static struct platform_device bfin_uart_device = {
  83. .name = "bfin-uart",
  84. .id = 1,
  85. .num_resources = ARRAY_SIZE(bfin_uart_resources),
  86. .resource = bfin_uart_resources,
  87. };
  88. #endif
  89. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  90. static struct resource bfin_sir_resources[] = {
  91. #ifdef CONFIG_BFIN_SIR0
  92. {
  93. .start = 0xFFC00400,
  94. .end = 0xFFC004FF,
  95. .flags = IORESOURCE_MEM,
  96. },
  97. #endif
  98. #ifdef CONFIG_BFIN_SIR1
  99. {
  100. .start = 0xFFC02000,
  101. .end = 0xFFC020FF,
  102. .flags = IORESOURCE_MEM,
  103. },
  104. #endif
  105. #ifdef CONFIG_BFIN_SIR2
  106. {
  107. .start = 0xFFC02100,
  108. .end = 0xFFC021FF,
  109. .flags = IORESOURCE_MEM,
  110. },
  111. #endif
  112. };
  113. static struct platform_device bfin_sir_device = {
  114. .name = "bfin_sir",
  115. .id = 0,
  116. .num_resources = ARRAY_SIZE(bfin_sir_resources),
  117. .resource = bfin_sir_resources,
  118. };
  119. #endif
  120. /*
  121. * USB-LAN EzExtender board
  122. * Driver needs to know address, irq and flag pin.
  123. */
  124. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  125. static struct resource smc91x_resources[] = {
  126. {
  127. .name = "smc91x-regs",
  128. .start = 0x20310300,
  129. .end = 0x20310300 + 16,
  130. .flags = IORESOURCE_MEM,
  131. }, {
  132. .start = IRQ_PF0,
  133. .end = IRQ_PF0,
  134. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  135. },
  136. };
  137. static struct platform_device smc91x_device = {
  138. .name = "smc91x",
  139. .id = 0,
  140. .num_resources = ARRAY_SIZE(smc91x_resources),
  141. .resource = smc91x_resources,
  142. };
  143. #endif
  144. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  145. /* all SPI peripherals info goes here */
  146. #if defined(CONFIG_MTD_M25P80) \
  147. || defined(CONFIG_MTD_M25P80_MODULE)
  148. /* SPI flash chip (m25p16) */
  149. static struct mtd_partition bfin_spi_flash_partitions[] = {
  150. {
  151. .name = "bootloader(spi)",
  152. .size = 0x00040000,
  153. .offset = 0,
  154. .mask_flags = MTD_CAP_ROM
  155. }, {
  156. .name = "linux kernel(spi)",
  157. .size = 0x1c0000,
  158. .offset = 0x40000
  159. }
  160. };
  161. static struct flash_platform_data bfin_spi_flash_data = {
  162. .name = "m25p80",
  163. .parts = bfin_spi_flash_partitions,
  164. .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
  165. .type = "m25p16",
  166. };
  167. static struct bfin5xx_spi_chip spi_flash_chip_info = {
  168. .enable_dma = 0, /* use dma transfer with this chip*/
  169. .bits_per_word = 8,
  170. .cs_change_per_word = 0,
  171. };
  172. #endif
  173. #if defined(CONFIG_TOUCHSCREEN_AD7879) || defined(CONFIG_TOUCHSCREEN_AD7879_MODULE)
  174. #include <linux/spi/ad7879.h>
  175. static const struct ad7879_platform_data bfin_ad7879_ts_info = {
  176. .model = 7879, /* Model = AD7879 */
  177. .x_plate_ohms = 620, /* 620 Ohm from the touch datasheet */
  178. .pressure_max = 10000,
  179. .pressure_min = 0,
  180. .first_conversion_delay = 3, /* wait 512us before do a first conversion */
  181. .acquisition_time = 1, /* 4us acquisition time per sample */
  182. .median = 2, /* do 8 measurements */
  183. .averaging = 1, /* take the average of 4 middle samples */
  184. .pen_down_acc_interval = 255, /* 9.4 ms */
  185. .gpio_output = 1, /* configure AUX/VBAT/GPIO as GPIO output */
  186. .gpio_default = 1, /* During initialization set GPIO = HIGH */
  187. };
  188. #endif
  189. #if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE)
  190. static struct bfin5xx_spi_chip spi_ad7879_chip_info = {
  191. .enable_dma = 0,
  192. .bits_per_word = 16,
  193. };
  194. #endif
  195. #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
  196. #include <asm/bfin-lq035q1.h>
  197. static struct bfin_lq035q1fb_disp_info bfin_lq035q1_data = {
  198. .mode = LQ035_NORM | LQ035_RGB | LQ035_RL | LQ035_TB,
  199. .use_bl = 0, /* let something else control the LCD Blacklight */
  200. .gpio_bl = GPIO_PF7,
  201. };
  202. static struct resource bfin_lq035q1_resources[] = {
  203. {
  204. .start = IRQ_PPI_ERROR,
  205. .end = IRQ_PPI_ERROR,
  206. .flags = IORESOURCE_IRQ,
  207. },
  208. };
  209. static struct platform_device bfin_lq035q1_device = {
  210. .name = "bfin-lq035q1",
  211. .id = -1,
  212. .num_resources = ARRAY_SIZE(bfin_lq035q1_resources),
  213. .resource = bfin_lq035q1_resources,
  214. .dev = {
  215. .platform_data = &bfin_lq035q1_data,
  216. },
  217. };
  218. #endif
  219. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  220. static struct bfin5xx_spi_chip spidev_chip_info = {
  221. .enable_dma = 0,
  222. .bits_per_word = 8,
  223. };
  224. #endif
  225. #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
  226. static struct bfin5xx_spi_chip lq035q1_spi_chip_info = {
  227. .enable_dma = 0,
  228. .bits_per_word = 8,
  229. };
  230. #endif
  231. static struct spi_board_info bf538_spi_board_info[] __initdata = {
  232. #if defined(CONFIG_MTD_M25P80) \
  233. || defined(CONFIG_MTD_M25P80_MODULE)
  234. {
  235. /* the modalias must be the same as spi device driver name */
  236. .modalias = "m25p80", /* Name of spi_driver for this device */
  237. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  238. .bus_num = 0, /* Framework bus number */
  239. .chip_select = 1, /* SPI_SSEL1*/
  240. .platform_data = &bfin_spi_flash_data,
  241. .controller_data = &spi_flash_chip_info,
  242. .mode = SPI_MODE_3,
  243. },
  244. #endif
  245. #if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE)
  246. {
  247. .modalias = "ad7879",
  248. .platform_data = &bfin_ad7879_ts_info,
  249. .irq = IRQ_PF3,
  250. .max_speed_hz = 5000000, /* max spi clock (SCK) speed in HZ */
  251. .bus_num = 0,
  252. .chip_select = 1,
  253. .controller_data = &spi_ad7879_chip_info,
  254. .mode = SPI_CPHA | SPI_CPOL,
  255. },
  256. #endif
  257. #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
  258. {
  259. .modalias = "bfin-lq035q1-spi",
  260. .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
  261. .bus_num = 0,
  262. .chip_select = 2,
  263. .controller_data = &lq035q1_spi_chip_info,
  264. .mode = SPI_CPHA | SPI_CPOL,
  265. },
  266. #endif
  267. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  268. {
  269. .modalias = "spidev",
  270. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  271. .bus_num = 0,
  272. .chip_select = 1,
  273. .controller_data = &spidev_chip_info,
  274. },
  275. #endif
  276. };
  277. /* SPI (0) */
  278. static struct resource bfin_spi0_resource[] = {
  279. [0] = {
  280. .start = SPI0_REGBASE,
  281. .end = SPI0_REGBASE + 0xFF,
  282. .flags = IORESOURCE_MEM,
  283. },
  284. [1] = {
  285. .start = CH_SPI0,
  286. .end = CH_SPI0,
  287. .flags = IORESOURCE_IRQ,
  288. }
  289. };
  290. /* SPI (1) */
  291. static struct resource bfin_spi1_resource[] = {
  292. [0] = {
  293. .start = SPI1_REGBASE,
  294. .end = SPI1_REGBASE + 0xFF,
  295. .flags = IORESOURCE_MEM,
  296. },
  297. [1] = {
  298. .start = CH_SPI1,
  299. .end = CH_SPI1,
  300. .flags = IORESOURCE_IRQ,
  301. }
  302. };
  303. /* SPI (2) */
  304. static struct resource bfin_spi2_resource[] = {
  305. [0] = {
  306. .start = SPI2_REGBASE,
  307. .end = SPI2_REGBASE + 0xFF,
  308. .flags = IORESOURCE_MEM,
  309. },
  310. [1] = {
  311. .start = CH_SPI2,
  312. .end = CH_SPI2,
  313. .flags = IORESOURCE_IRQ,
  314. }
  315. };
  316. /* SPI controller data */
  317. static struct bfin5xx_spi_master bf538_spi_master_info0 = {
  318. .num_chipselect = 8,
  319. .enable_dma = 1, /* master has the ability to do dma transfer */
  320. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  321. };
  322. static struct platform_device bf538_spi_master0 = {
  323. .name = "bfin-spi",
  324. .id = 0, /* Bus number */
  325. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  326. .resource = bfin_spi0_resource,
  327. .dev = {
  328. .platform_data = &bf538_spi_master_info0, /* Passed to driver */
  329. },
  330. };
  331. static struct bfin5xx_spi_master bf538_spi_master_info1 = {
  332. .num_chipselect = 8,
  333. .enable_dma = 1, /* master has the ability to do dma transfer */
  334. .pin_req = {P_SPI1_SCK, P_SPI1_MISO, P_SPI1_MOSI, 0},
  335. };
  336. static struct platform_device bf538_spi_master1 = {
  337. .name = "bfin-spi",
  338. .id = 1, /* Bus number */
  339. .num_resources = ARRAY_SIZE(bfin_spi1_resource),
  340. .resource = bfin_spi1_resource,
  341. .dev = {
  342. .platform_data = &bf538_spi_master_info1, /* Passed to driver */
  343. },
  344. };
  345. static struct bfin5xx_spi_master bf538_spi_master_info2 = {
  346. .num_chipselect = 8,
  347. .enable_dma = 1, /* master has the ability to do dma transfer */
  348. .pin_req = {P_SPI2_SCK, P_SPI2_MISO, P_SPI2_MOSI, 0},
  349. };
  350. static struct platform_device bf538_spi_master2 = {
  351. .name = "bfin-spi",
  352. .id = 2, /* Bus number */
  353. .num_resources = ARRAY_SIZE(bfin_spi2_resource),
  354. .resource = bfin_spi2_resource,
  355. .dev = {
  356. .platform_data = &bf538_spi_master_info2, /* Passed to driver */
  357. },
  358. };
  359. #endif /* spi master and devices */
  360. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  361. static struct resource bfin_twi0_resource[] = {
  362. [0] = {
  363. .start = TWI0_REGBASE,
  364. .end = TWI0_REGBASE + 0xFF,
  365. .flags = IORESOURCE_MEM,
  366. },
  367. [1] = {
  368. .start = IRQ_TWI0,
  369. .end = IRQ_TWI0,
  370. .flags = IORESOURCE_IRQ,
  371. },
  372. };
  373. static struct platform_device i2c_bfin_twi0_device = {
  374. .name = "i2c-bfin-twi",
  375. .id = 0,
  376. .num_resources = ARRAY_SIZE(bfin_twi0_resource),
  377. .resource = bfin_twi0_resource,
  378. };
  379. #if !defined(CONFIG_BF542) /* The BF542 only has 1 TWI */
  380. static struct resource bfin_twi1_resource[] = {
  381. [0] = {
  382. .start = TWI1_REGBASE,
  383. .end = TWI1_REGBASE + 0xFF,
  384. .flags = IORESOURCE_MEM,
  385. },
  386. [1] = {
  387. .start = IRQ_TWI1,
  388. .end = IRQ_TWI1,
  389. .flags = IORESOURCE_IRQ,
  390. },
  391. };
  392. static struct platform_device i2c_bfin_twi1_device = {
  393. .name = "i2c-bfin-twi",
  394. .id = 1,
  395. .num_resources = ARRAY_SIZE(bfin_twi1_resource),
  396. .resource = bfin_twi1_resource,
  397. };
  398. #endif
  399. #endif
  400. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  401. #include <linux/gpio_keys.h>
  402. static struct gpio_keys_button bfin_gpio_keys_table[] = {
  403. {BTN_0, GPIO_PC7, 1, "gpio-keys: BTN0"},
  404. };
  405. static struct gpio_keys_platform_data bfin_gpio_keys_data = {
  406. .buttons = bfin_gpio_keys_table,
  407. .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
  408. };
  409. static struct platform_device bfin_device_gpiokeys = {
  410. .name = "gpio-keys",
  411. .dev = {
  412. .platform_data = &bfin_gpio_keys_data,
  413. },
  414. };
  415. #endif
  416. static const unsigned int cclk_vlev_datasheet[] =
  417. {
  418. /*
  419. * Internal VLEV BF538SBBC1533
  420. ****temporarily using these values until data sheet is updated
  421. */
  422. VRPAIR(VLEV_100, 150000000),
  423. VRPAIR(VLEV_100, 250000000),
  424. VRPAIR(VLEV_110, 276000000),
  425. VRPAIR(VLEV_115, 301000000),
  426. VRPAIR(VLEV_120, 525000000),
  427. VRPAIR(VLEV_125, 550000000),
  428. VRPAIR(VLEV_130, 600000000),
  429. };
  430. static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
  431. .tuple_tab = cclk_vlev_datasheet,
  432. .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
  433. .vr_settling_time = 25 /* us */,
  434. };
  435. static struct platform_device bfin_dpmc = {
  436. .name = "bfin dpmc",
  437. .dev = {
  438. .platform_data = &bfin_dmpc_vreg_data,
  439. },
  440. };
  441. static struct platform_device *cm_bf538_devices[] __initdata = {
  442. &bfin_dpmc,
  443. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  444. &rtc_device,
  445. #endif
  446. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  447. &bfin_uart_device,
  448. #endif
  449. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  450. &bf538_spi_master0,
  451. &bf538_spi_master1,
  452. &bf538_spi_master2,
  453. #endif
  454. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  455. &i2c_bfin_twi0_device,
  456. &i2c_bfin_twi1_device,
  457. #endif
  458. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  459. &bfin_sir_device,
  460. #endif
  461. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  462. &smc91x_device,
  463. #endif
  464. #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
  465. &bfin_lq035q1_device,
  466. #endif
  467. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  468. &bfin_device_gpiokeys,
  469. #endif
  470. };
  471. static int __init ezkit_init(void)
  472. {
  473. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  474. platform_add_devices(cm_bf538_devices, ARRAY_SIZE(cm_bf538_devices));
  475. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  476. spi_register_board_info(bf538_spi_board_info,
  477. ARRAY_SIZE(bf538_spi_board_info));
  478. #endif
  479. return 0;
  480. }
  481. arch_initcall(ezkit_init);