cm_bf527.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932
  1. /*
  2. * Copyright 2004-2009 Analog Devices Inc.
  3. * 2008-2009 Bluetechnix
  4. * 2005 National ICT Australia (NICTA)
  5. * Aidan Williams <aidan@nicta.com.au>
  6. *
  7. * Licensed under the GPL-2 or later.
  8. */
  9. #include <linux/device.h>
  10. #include <linux/platform_device.h>
  11. #include <linux/mtd/mtd.h>
  12. #include <linux/mtd/partitions.h>
  13. #include <linux/mtd/physmap.h>
  14. #include <linux/spi/spi.h>
  15. #include <linux/spi/flash.h>
  16. #include <linux/etherdevice.h>
  17. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  18. #include <linux/usb/isp1362.h>
  19. #endif
  20. #include <linux/i2c.h>
  21. #include <linux/irq.h>
  22. #include <linux/interrupt.h>
  23. #include <linux/usb/sl811.h>
  24. #include <linux/usb/musb.h>
  25. #include <asm/dma.h>
  26. #include <asm/bfin5xx_spi.h>
  27. #include <asm/reboot.h>
  28. #include <asm/nand.h>
  29. #include <asm/portmux.h>
  30. #include <asm/dpmc.h>
  31. #include <linux/spi/ad7877.h>
  32. /*
  33. * Name the Board for the /proc/cpuinfo
  34. */
  35. const char bfin_board_name[] = "Bluetechnix CM-BF527";
  36. /*
  37. * Driver needs to know address, irq and flag pin.
  38. */
  39. #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
  40. #include <linux/usb/isp1760.h>
  41. static struct resource bfin_isp1760_resources[] = {
  42. [0] = {
  43. .start = 0x203C0000,
  44. .end = 0x203C0000 + 0x000fffff,
  45. .flags = IORESOURCE_MEM,
  46. },
  47. [1] = {
  48. .start = IRQ_PF7,
  49. .end = IRQ_PF7,
  50. .flags = IORESOURCE_IRQ,
  51. },
  52. };
  53. static struct isp1760_platform_data isp1760_priv = {
  54. .is_isp1761 = 0,
  55. .bus_width_16 = 1,
  56. .port1_otg = 0,
  57. .analog_oc = 0,
  58. .dack_polarity_high = 0,
  59. .dreq_polarity_high = 0,
  60. };
  61. static struct platform_device bfin_isp1760_device = {
  62. .name = "isp1760-hcd",
  63. .id = 0,
  64. .dev = {
  65. .platform_data = &isp1760_priv,
  66. },
  67. .num_resources = ARRAY_SIZE(bfin_isp1760_resources),
  68. .resource = bfin_isp1760_resources,
  69. };
  70. #endif
  71. #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
  72. static struct resource musb_resources[] = {
  73. [0] = {
  74. .start = 0xffc03800,
  75. .end = 0xffc03cff,
  76. .flags = IORESOURCE_MEM,
  77. },
  78. [1] = { /* general IRQ */
  79. .start = IRQ_USB_INT0,
  80. .end = IRQ_USB_INT0,
  81. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  82. },
  83. [2] = { /* DMA IRQ */
  84. .start = IRQ_USB_DMA,
  85. .end = IRQ_USB_DMA,
  86. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  87. },
  88. };
  89. static struct musb_hdrc_config musb_config = {
  90. .multipoint = 0,
  91. .dyn_fifo = 0,
  92. .soft_con = 1,
  93. .dma = 1,
  94. .num_eps = 8,
  95. .dma_channels = 8,
  96. .gpio_vrsel = GPIO_PF11,
  97. };
  98. static struct musb_hdrc_platform_data musb_plat = {
  99. #if defined(CONFIG_USB_MUSB_OTG)
  100. .mode = MUSB_OTG,
  101. #elif defined(CONFIG_USB_MUSB_HDRC_HCD)
  102. .mode = MUSB_HOST,
  103. #elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
  104. .mode = MUSB_PERIPHERAL,
  105. #endif
  106. .config = &musb_config,
  107. };
  108. static u64 musb_dmamask = ~(u32)0;
  109. static struct platform_device musb_device = {
  110. .name = "musb_hdrc",
  111. .id = 0,
  112. .dev = {
  113. .dma_mask = &musb_dmamask,
  114. .coherent_dma_mask = 0xffffffff,
  115. .platform_data = &musb_plat,
  116. },
  117. .num_resources = ARRAY_SIZE(musb_resources),
  118. .resource = musb_resources,
  119. };
  120. #endif
  121. #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
  122. static struct mtd_partition partition_info[] = {
  123. {
  124. .name = "linux kernel(nand)",
  125. .offset = 0,
  126. .size = 4 * 1024 * 1024,
  127. },
  128. {
  129. .name = "file system(nand)",
  130. .offset = MTDPART_OFS_APPEND,
  131. .size = MTDPART_SIZ_FULL,
  132. },
  133. };
  134. static struct bf5xx_nand_platform bf5xx_nand_platform = {
  135. .page_size = NFC_PG_SIZE_256,
  136. .data_width = NFC_NWIDTH_8,
  137. .partitions = partition_info,
  138. .nr_partitions = ARRAY_SIZE(partition_info),
  139. .rd_dly = 3,
  140. .wr_dly = 3,
  141. };
  142. static struct resource bf5xx_nand_resources[] = {
  143. {
  144. .start = NFC_CTL,
  145. .end = NFC_DATA_RD + 2,
  146. .flags = IORESOURCE_MEM,
  147. },
  148. {
  149. .start = CH_NFC,
  150. .end = CH_NFC,
  151. .flags = IORESOURCE_IRQ,
  152. },
  153. };
  154. static struct platform_device bf5xx_nand_device = {
  155. .name = "bf5xx-nand",
  156. .id = 0,
  157. .num_resources = ARRAY_SIZE(bf5xx_nand_resources),
  158. .resource = bf5xx_nand_resources,
  159. .dev = {
  160. .platform_data = &bf5xx_nand_platform,
  161. },
  162. };
  163. #endif
  164. #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
  165. static struct resource bfin_pcmcia_cf_resources[] = {
  166. {
  167. .start = 0x20310000, /* IO PORT */
  168. .end = 0x20312000,
  169. .flags = IORESOURCE_MEM,
  170. }, {
  171. .start = 0x20311000, /* Attribute Memory */
  172. .end = 0x20311FFF,
  173. .flags = IORESOURCE_MEM,
  174. }, {
  175. .start = IRQ_PF4,
  176. .end = IRQ_PF4,
  177. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  178. }, {
  179. .start = 6, /* Card Detect PF6 */
  180. .end = 6,
  181. .flags = IORESOURCE_IRQ,
  182. },
  183. };
  184. static struct platform_device bfin_pcmcia_cf_device = {
  185. .name = "bfin_cf_pcmcia",
  186. .id = -1,
  187. .num_resources = ARRAY_SIZE(bfin_pcmcia_cf_resources),
  188. .resource = bfin_pcmcia_cf_resources,
  189. };
  190. #endif
  191. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  192. static struct platform_device rtc_device = {
  193. .name = "rtc-bfin",
  194. .id = -1,
  195. };
  196. #endif
  197. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  198. #include <linux/smc91x.h>
  199. static struct smc91x_platdata smc91x_info = {
  200. .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
  201. .leda = RPC_LED_100_10,
  202. .ledb = RPC_LED_TX_RX,
  203. };
  204. static struct resource smc91x_resources[] = {
  205. {
  206. .name = "smc91x-regs",
  207. .start = 0x20300300,
  208. .end = 0x20300300 + 16,
  209. .flags = IORESOURCE_MEM,
  210. }, {
  211. .start = IRQ_PF7,
  212. .end = IRQ_PF7,
  213. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  214. },
  215. };
  216. static struct platform_device smc91x_device = {
  217. .name = "smc91x",
  218. .id = 0,
  219. .num_resources = ARRAY_SIZE(smc91x_resources),
  220. .resource = smc91x_resources,
  221. .dev = {
  222. .platform_data = &smc91x_info,
  223. },
  224. };
  225. #endif
  226. #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
  227. static struct resource dm9000_resources[] = {
  228. [0] = {
  229. .start = 0x203FB800,
  230. .end = 0x203FB800 + 1,
  231. .flags = IORESOURCE_MEM,
  232. },
  233. [1] = {
  234. .start = 0x203FB804,
  235. .end = 0x203FB804 + 1,
  236. .flags = IORESOURCE_MEM,
  237. },
  238. [2] = {
  239. .start = IRQ_PF9,
  240. .end = IRQ_PF9,
  241. .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE),
  242. },
  243. };
  244. static struct platform_device dm9000_device = {
  245. .name = "dm9000",
  246. .id = -1,
  247. .num_resources = ARRAY_SIZE(dm9000_resources),
  248. .resource = dm9000_resources,
  249. };
  250. #endif
  251. #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
  252. static struct resource sl811_hcd_resources[] = {
  253. {
  254. .start = 0x20340000,
  255. .end = 0x20340000,
  256. .flags = IORESOURCE_MEM,
  257. }, {
  258. .start = 0x20340004,
  259. .end = 0x20340004,
  260. .flags = IORESOURCE_MEM,
  261. }, {
  262. .start = CONFIG_USB_SL811_BFIN_IRQ,
  263. .end = CONFIG_USB_SL811_BFIN_IRQ,
  264. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  265. },
  266. };
  267. #if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
  268. void sl811_port_power(struct device *dev, int is_on)
  269. {
  270. gpio_request(CONFIG_USB_SL811_BFIN_GPIO_VBUS, "usb:SL811_VBUS");
  271. gpio_direction_output(CONFIG_USB_SL811_BFIN_GPIO_VBUS, is_on);
  272. }
  273. #endif
  274. static struct sl811_platform_data sl811_priv = {
  275. .potpg = 10,
  276. .power = 250, /* == 500mA */
  277. #if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
  278. .port_power = &sl811_port_power,
  279. #endif
  280. };
  281. static struct platform_device sl811_hcd_device = {
  282. .name = "sl811-hcd",
  283. .id = 0,
  284. .dev = {
  285. .platform_data = &sl811_priv,
  286. },
  287. .num_resources = ARRAY_SIZE(sl811_hcd_resources),
  288. .resource = sl811_hcd_resources,
  289. };
  290. #endif
  291. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  292. static struct resource isp1362_hcd_resources[] = {
  293. {
  294. .start = 0x20360000,
  295. .end = 0x20360000,
  296. .flags = IORESOURCE_MEM,
  297. }, {
  298. .start = 0x20360004,
  299. .end = 0x20360004,
  300. .flags = IORESOURCE_MEM,
  301. }, {
  302. .start = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
  303. .end = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
  304. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  305. },
  306. };
  307. static struct isp1362_platform_data isp1362_priv = {
  308. .sel15Kres = 1,
  309. .clknotstop = 0,
  310. .oc_enable = 0,
  311. .int_act_high = 0,
  312. .int_edge_triggered = 0,
  313. .remote_wakeup_connected = 0,
  314. .no_power_switching = 1,
  315. .power_switching_mode = 0,
  316. };
  317. static struct platform_device isp1362_hcd_device = {
  318. .name = "isp1362-hcd",
  319. .id = 0,
  320. .dev = {
  321. .platform_data = &isp1362_priv,
  322. },
  323. .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
  324. .resource = isp1362_hcd_resources,
  325. };
  326. #endif
  327. #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
  328. static struct platform_device bfin_mii_bus = {
  329. .name = "bfin_mii_bus",
  330. };
  331. static struct platform_device bfin_mac_device = {
  332. .name = "bfin_mac",
  333. .dev.platform_data = &bfin_mii_bus,
  334. };
  335. #endif
  336. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  337. static struct resource net2272_bfin_resources[] = {
  338. {
  339. .start = 0x20300000,
  340. .end = 0x20300000 + 0x100,
  341. .flags = IORESOURCE_MEM,
  342. }, {
  343. .start = IRQ_PF7,
  344. .end = IRQ_PF7,
  345. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  346. },
  347. };
  348. static struct platform_device net2272_bfin_device = {
  349. .name = "net2272",
  350. .id = -1,
  351. .num_resources = ARRAY_SIZE(net2272_bfin_resources),
  352. .resource = net2272_bfin_resources,
  353. };
  354. #endif
  355. #if defined(CONFIG_MTD_M25P80) \
  356. || defined(CONFIG_MTD_M25P80_MODULE)
  357. static struct mtd_partition bfin_spi_flash_partitions[] = {
  358. {
  359. .name = "bootloader(spi)",
  360. .size = 0x00040000,
  361. .offset = 0,
  362. .mask_flags = MTD_CAP_ROM
  363. }, {
  364. .name = "linux kernel(spi)",
  365. .size = MTDPART_SIZ_FULL,
  366. .offset = MTDPART_OFS_APPEND,
  367. }
  368. };
  369. static struct flash_platform_data bfin_spi_flash_data = {
  370. .name = "m25p80",
  371. .parts = bfin_spi_flash_partitions,
  372. .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
  373. .type = "m25p16",
  374. };
  375. /* SPI flash chip (m25p64) */
  376. static struct bfin5xx_spi_chip spi_flash_chip_info = {
  377. .enable_dma = 0, /* use dma transfer with this chip*/
  378. .bits_per_word = 8,
  379. };
  380. #endif
  381. #if defined(CONFIG_BFIN_SPI_ADC) \
  382. || defined(CONFIG_BFIN_SPI_ADC_MODULE)
  383. /* SPI ADC chip */
  384. static struct bfin5xx_spi_chip spi_adc_chip_info = {
  385. .enable_dma = 1, /* use dma transfer with this chip*/
  386. .bits_per_word = 16,
  387. };
  388. #endif
  389. #if defined(CONFIG_SND_BLACKFIN_AD1836) \
  390. || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  391. static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
  392. .enable_dma = 0,
  393. .bits_per_word = 16,
  394. };
  395. #endif
  396. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  397. static struct bfin5xx_spi_chip mmc_spi_chip_info = {
  398. .enable_dma = 0,
  399. .bits_per_word = 8,
  400. };
  401. #endif
  402. #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
  403. static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
  404. .enable_dma = 0,
  405. .bits_per_word = 16,
  406. };
  407. static const struct ad7877_platform_data bfin_ad7877_ts_info = {
  408. .model = 7877,
  409. .vref_delay_usecs = 50, /* internal, no capacitor */
  410. .x_plate_ohms = 419,
  411. .y_plate_ohms = 486,
  412. .pressure_max = 1000,
  413. .pressure_min = 0,
  414. .stopacq_polarity = 1,
  415. .first_conversion_delay = 3,
  416. .acquisition_time = 1,
  417. .averaging = 1,
  418. .pen_down_acc_interval = 1,
  419. };
  420. #endif
  421. #if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
  422. && defined(CONFIG_SND_SOC_WM8731_SPI)
  423. static struct bfin5xx_spi_chip spi_wm8731_chip_info = {
  424. .enable_dma = 0,
  425. .bits_per_word = 16,
  426. };
  427. #endif
  428. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  429. static struct bfin5xx_spi_chip spidev_chip_info = {
  430. .enable_dma = 0,
  431. .bits_per_word = 8,
  432. };
  433. #endif
  434. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  435. #if defined(CONFIG_MTD_M25P80) \
  436. || defined(CONFIG_MTD_M25P80_MODULE)
  437. {
  438. /* the modalias must be the same as spi device driver name */
  439. .modalias = "m25p80", /* Name of spi_driver for this device */
  440. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  441. .bus_num = 0, /* Framework bus number */
  442. .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
  443. .platform_data = &bfin_spi_flash_data,
  444. .controller_data = &spi_flash_chip_info,
  445. .mode = SPI_MODE_3,
  446. },
  447. #endif
  448. #if defined(CONFIG_BFIN_SPI_ADC) \
  449. || defined(CONFIG_BFIN_SPI_ADC_MODULE)
  450. {
  451. .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
  452. .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
  453. .bus_num = 0, /* Framework bus number */
  454. .chip_select = 1, /* Framework chip select. */
  455. .platform_data = NULL, /* No spi_driver specific config */
  456. .controller_data = &spi_adc_chip_info,
  457. },
  458. #endif
  459. #if defined(CONFIG_SND_BLACKFIN_AD1836) \
  460. || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  461. {
  462. .modalias = "ad1836",
  463. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  464. .bus_num = 0,
  465. .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
  466. .controller_data = &ad1836_spi_chip_info,
  467. },
  468. #endif
  469. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  470. {
  471. .modalias = "mmc_spi",
  472. .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
  473. .bus_num = 0,
  474. .chip_select = 5,
  475. .controller_data = &mmc_spi_chip_info,
  476. .mode = SPI_MODE_3,
  477. },
  478. #endif
  479. #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
  480. {
  481. .modalias = "ad7877",
  482. .platform_data = &bfin_ad7877_ts_info,
  483. .irq = IRQ_PF8,
  484. .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
  485. .bus_num = 0,
  486. .chip_select = 2,
  487. .controller_data = &spi_ad7877_chip_info,
  488. },
  489. #endif
  490. #if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
  491. && defined(CONFIG_SND_SOC_WM8731_SPI)
  492. {
  493. .modalias = "wm8731",
  494. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  495. .bus_num = 0,
  496. .chip_select = 5,
  497. .controller_data = &spi_wm8731_chip_info,
  498. .mode = SPI_MODE_0,
  499. },
  500. #endif
  501. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  502. {
  503. .modalias = "spidev",
  504. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  505. .bus_num = 0,
  506. .chip_select = 1,
  507. .controller_data = &spidev_chip_info,
  508. },
  509. #endif
  510. };
  511. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  512. /* SPI controller data */
  513. static struct bfin5xx_spi_master bfin_spi0_info = {
  514. .num_chipselect = 8,
  515. .enable_dma = 1, /* master has the ability to do dma transfer */
  516. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  517. };
  518. /* SPI (0) */
  519. static struct resource bfin_spi0_resource[] = {
  520. [0] = {
  521. .start = SPI0_REGBASE,
  522. .end = SPI0_REGBASE + 0xFF,
  523. .flags = IORESOURCE_MEM,
  524. },
  525. [1] = {
  526. .start = CH_SPI,
  527. .end = CH_SPI,
  528. .flags = IORESOURCE_DMA,
  529. },
  530. [2] = {
  531. .start = IRQ_SPI,
  532. .end = IRQ_SPI,
  533. .flags = IORESOURCE_IRQ,
  534. },
  535. };
  536. static struct platform_device bfin_spi0_device = {
  537. .name = "bfin-spi",
  538. .id = 0, /* Bus number */
  539. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  540. .resource = bfin_spi0_resource,
  541. .dev = {
  542. .platform_data = &bfin_spi0_info, /* Passed to driver */
  543. },
  544. };
  545. #endif /* spi master and devices */
  546. #if defined(CONFIG_MTD_GPIO_ADDR) || defined(CONFIG_MTD_GPIO_ADDR_MODULE)
  547. static struct mtd_partition cm_partitions[] = {
  548. {
  549. .name = "bootloader(nor)",
  550. .size = 0x40000,
  551. .offset = 0,
  552. }, {
  553. .name = "linux kernel(nor)",
  554. .size = 0x100000,
  555. .offset = MTDPART_OFS_APPEND,
  556. }, {
  557. .name = "file system(nor)",
  558. .size = MTDPART_SIZ_FULL,
  559. .offset = MTDPART_OFS_APPEND,
  560. }
  561. };
  562. static struct physmap_flash_data cm_flash_data = {
  563. .width = 2,
  564. .parts = cm_partitions,
  565. .nr_parts = ARRAY_SIZE(cm_partitions),
  566. };
  567. static unsigned cm_flash_gpios[] = { GPIO_PH9, GPIO_PG11 };
  568. static struct resource cm_flash_resource[] = {
  569. {
  570. .name = "cfi_probe",
  571. .start = 0x20000000,
  572. .end = 0x201fffff,
  573. .flags = IORESOURCE_MEM,
  574. }, {
  575. .start = (unsigned long)cm_flash_gpios,
  576. .end = ARRAY_SIZE(cm_flash_gpios),
  577. .flags = IORESOURCE_IRQ,
  578. }
  579. };
  580. static struct platform_device cm_flash_device = {
  581. .name = "gpio-addr-flash",
  582. .id = 0,
  583. .dev = {
  584. .platform_data = &cm_flash_data,
  585. },
  586. .num_resources = ARRAY_SIZE(cm_flash_resource),
  587. .resource = cm_flash_resource,
  588. };
  589. #endif
  590. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  591. static struct resource bfin_uart_resources[] = {
  592. #ifdef CONFIG_SERIAL_BFIN_UART0
  593. {
  594. .start = 0xFFC00400,
  595. .end = 0xFFC004FF,
  596. .flags = IORESOURCE_MEM,
  597. },
  598. #endif
  599. #ifdef CONFIG_SERIAL_BFIN_UART1
  600. {
  601. .start = 0xFFC02000,
  602. .end = 0xFFC020FF,
  603. .flags = IORESOURCE_MEM,
  604. },
  605. #endif
  606. };
  607. static struct platform_device bfin_uart_device = {
  608. .name = "bfin-uart",
  609. .id = 1,
  610. .num_resources = ARRAY_SIZE(bfin_uart_resources),
  611. .resource = bfin_uart_resources,
  612. };
  613. #endif
  614. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  615. #ifdef CONFIG_BFIN_SIR0
  616. static struct resource bfin_sir0_resources[] = {
  617. {
  618. .start = 0xFFC00400,
  619. .end = 0xFFC004FF,
  620. .flags = IORESOURCE_MEM,
  621. },
  622. {
  623. .start = IRQ_UART0_RX,
  624. .end = IRQ_UART0_RX+1,
  625. .flags = IORESOURCE_IRQ,
  626. },
  627. {
  628. .start = CH_UART0_RX,
  629. .end = CH_UART0_RX+1,
  630. .flags = IORESOURCE_DMA,
  631. },
  632. };
  633. static struct platform_device bfin_sir0_device = {
  634. .name = "bfin_sir",
  635. .id = 0,
  636. .num_resources = ARRAY_SIZE(bfin_sir0_resources),
  637. .resource = bfin_sir0_resources,
  638. };
  639. #endif
  640. #ifdef CONFIG_BFIN_SIR1
  641. static struct resource bfin_sir1_resources[] = {
  642. {
  643. .start = 0xFFC02000,
  644. .end = 0xFFC020FF,
  645. .flags = IORESOURCE_MEM,
  646. },
  647. {
  648. .start = IRQ_UART1_RX,
  649. .end = IRQ_UART1_RX+1,
  650. .flags = IORESOURCE_IRQ,
  651. },
  652. {
  653. .start = CH_UART1_RX,
  654. .end = CH_UART1_RX+1,
  655. .flags = IORESOURCE_DMA,
  656. },
  657. };
  658. static struct platform_device bfin_sir1_device = {
  659. .name = "bfin_sir",
  660. .id = 1,
  661. .num_resources = ARRAY_SIZE(bfin_sir1_resources),
  662. .resource = bfin_sir1_resources,
  663. };
  664. #endif
  665. #endif
  666. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  667. static struct resource bfin_twi0_resource[] = {
  668. [0] = {
  669. .start = TWI0_REGBASE,
  670. .end = TWI0_REGBASE,
  671. .flags = IORESOURCE_MEM,
  672. },
  673. [1] = {
  674. .start = IRQ_TWI,
  675. .end = IRQ_TWI,
  676. .flags = IORESOURCE_IRQ,
  677. },
  678. };
  679. static struct platform_device i2c_bfin_twi_device = {
  680. .name = "i2c-bfin-twi",
  681. .id = 0,
  682. .num_resources = ARRAY_SIZE(bfin_twi0_resource),
  683. .resource = bfin_twi0_resource,
  684. };
  685. #endif
  686. static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
  687. #if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE)
  688. {
  689. I2C_BOARD_INFO("pcf8574_lcd", 0x22),
  690. },
  691. #endif
  692. #if defined(CONFIG_INPUT_PCF8574) || defined(CONFIG_INPUT_PCF8574_MODULE)
  693. {
  694. I2C_BOARD_INFO("pcf8574_keypad", 0x27),
  695. .irq = IRQ_PF8,
  696. },
  697. #endif
  698. #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
  699. {
  700. I2C_BOARD_INFO("bfin-adv7393", 0x2B),
  701. },
  702. #endif
  703. };
  704. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  705. static struct platform_device bfin_sport0_uart_device = {
  706. .name = "bfin-sport-uart",
  707. .id = 0,
  708. };
  709. static struct platform_device bfin_sport1_uart_device = {
  710. .name = "bfin-sport-uart",
  711. .id = 1,
  712. };
  713. #endif
  714. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  715. #include <linux/input.h>
  716. #include <linux/gpio_keys.h>
  717. static struct gpio_keys_button bfin_gpio_keys_table[] = {
  718. {BTN_0, GPIO_PF14, 1, "gpio-keys: BTN0"},
  719. };
  720. static struct gpio_keys_platform_data bfin_gpio_keys_data = {
  721. .buttons = bfin_gpio_keys_table,
  722. .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
  723. };
  724. static struct platform_device bfin_device_gpiokeys = {
  725. .name = "gpio-keys",
  726. .dev = {
  727. .platform_data = &bfin_gpio_keys_data,
  728. },
  729. };
  730. #endif
  731. static const unsigned int cclk_vlev_datasheet[] =
  732. {
  733. VRPAIR(VLEV_100, 400000000),
  734. VRPAIR(VLEV_105, 426000000),
  735. VRPAIR(VLEV_110, 500000000),
  736. VRPAIR(VLEV_115, 533000000),
  737. VRPAIR(VLEV_120, 600000000),
  738. };
  739. static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
  740. .tuple_tab = cclk_vlev_datasheet,
  741. .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
  742. .vr_settling_time = 25 /* us */,
  743. };
  744. static struct platform_device bfin_dpmc = {
  745. .name = "bfin dpmc",
  746. .dev = {
  747. .platform_data = &bfin_dmpc_vreg_data,
  748. },
  749. };
  750. static struct platform_device *cmbf527_devices[] __initdata = {
  751. &bfin_dpmc,
  752. #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
  753. &bf5xx_nand_device,
  754. #endif
  755. #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
  756. &bfin_pcmcia_cf_device,
  757. #endif
  758. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  759. &rtc_device,
  760. #endif
  761. #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
  762. &sl811_hcd_device,
  763. #endif
  764. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  765. &isp1362_hcd_device,
  766. #endif
  767. #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
  768. &bfin_isp1760_device,
  769. #endif
  770. #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
  771. &musb_device,
  772. #endif
  773. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  774. &smc91x_device,
  775. #endif
  776. #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
  777. &dm9000_device,
  778. #endif
  779. #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
  780. &bfin_mii_bus,
  781. &bfin_mac_device,
  782. #endif
  783. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  784. &net2272_bfin_device,
  785. #endif
  786. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  787. &bfin_spi0_device,
  788. #endif
  789. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  790. &bfin_uart_device,
  791. #endif
  792. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  793. #ifdef CONFIG_BFIN_SIR0
  794. &bfin_sir0_device,
  795. #endif
  796. #ifdef CONFIG_BFIN_SIR1
  797. &bfin_sir1_device,
  798. #endif
  799. #endif
  800. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  801. &i2c_bfin_twi_device,
  802. #endif
  803. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  804. &bfin_sport0_uart_device,
  805. &bfin_sport1_uart_device,
  806. #endif
  807. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  808. &bfin_device_gpiokeys,
  809. #endif
  810. #if defined(CONFIG_MTD_GPIO_ADDR) || defined(CONFIG_MTD_GPIO_ADDR_MODULE)
  811. &cm_flash_device,
  812. #endif
  813. };
  814. static int __init cm_init(void)
  815. {
  816. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  817. i2c_register_board_info(0, bfin_i2c_board_info,
  818. ARRAY_SIZE(bfin_i2c_board_info));
  819. platform_add_devices(cmbf527_devices, ARRAY_SIZE(cmbf527_devices));
  820. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  821. return 0;
  822. }
  823. arch_initcall(cm_init);
  824. void native_machine_restart(char *cmd)
  825. {
  826. /* workaround reboot hang when booting from SPI */
  827. if ((bfin_read_SYSCR() & 0x7) == 0x3)
  828. bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS);
  829. }
  830. void bfin_get_ether_addr(char *addr)
  831. {
  832. random_ether_addr(addr);
  833. printk(KERN_WARNING "%s:%s: Setting Ethernet MAC to a random one\n", __FILE__, __func__);
  834. }
  835. EXPORT_SYMBOL(bfin_get_ether_addr);