stamp.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  1. /*
  2. * File: arch/blackfin/mach-bf533/stamp.c
  3. * Based on: arch/blackfin/mach-bf533/ezkit.c
  4. * Author: Aidan Williams <aidan@nicta.com.au>
  5. *
  6. * Created: 2005
  7. * Description: Board Info File for the BF533-STAMP
  8. *
  9. * Modified:
  10. * Copyright 2005 National ICT Australia (NICTA)
  11. * Copyright 2004-2006 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/mtd/physmap.h>
  35. #include <linux/spi/spi.h>
  36. #include <linux/spi/flash.h>
  37. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  38. #include <linux/usb/isp1362.h>
  39. #endif
  40. #include <linux/ata_platform.h>
  41. #include <linux/irq.h>
  42. #include <asm/dma.h>
  43. #include <asm/bfin5xx_spi.h>
  44. #include <asm/reboot.h>
  45. #include <asm/portmux.h>
  46. /*
  47. * Name the Board for the /proc/cpuinfo
  48. */
  49. const char bfin_board_name[] = "ADDS-BF533-STAMP";
  50. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  51. static struct platform_device rtc_device = {
  52. .name = "rtc-bfin",
  53. .id = -1,
  54. };
  55. #endif
  56. /*
  57. * Driver needs to know address, irq and flag pin.
  58. */
  59. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  60. static struct resource smc91x_resources[] = {
  61. {
  62. .name = "smc91x-regs",
  63. .start = 0x20300300,
  64. .end = 0x20300300 + 16,
  65. .flags = IORESOURCE_MEM,
  66. }, {
  67. .start = IRQ_PF7,
  68. .end = IRQ_PF7,
  69. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  70. },
  71. };
  72. static struct platform_device smc91x_device = {
  73. .name = "smc91x",
  74. .id = 0,
  75. .num_resources = ARRAY_SIZE(smc91x_resources),
  76. .resource = smc91x_resources,
  77. };
  78. #endif
  79. #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
  80. static struct platform_device bfin_fb_adv7393_device = {
  81. .name = "bfin-adv7393",
  82. };
  83. #endif
  84. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  85. static struct resource net2272_bfin_resources[] = {
  86. {
  87. .start = 0x20300000,
  88. .end = 0x20300000 + 0x100,
  89. .flags = IORESOURCE_MEM,
  90. }, {
  91. .start = IRQ_PF10,
  92. .end = IRQ_PF10,
  93. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  94. },
  95. };
  96. static struct platform_device net2272_bfin_device = {
  97. .name = "net2272",
  98. .id = -1,
  99. .num_resources = ARRAY_SIZE(net2272_bfin_resources),
  100. .resource = net2272_bfin_resources,
  101. };
  102. #endif
  103. static struct mtd_partition stamp_partitions[] = {
  104. {
  105. .name = "Bootloader",
  106. .size = 0x40000,
  107. .offset = 0,
  108. }, {
  109. .name = "Kernel",
  110. .size = 0xE0000,
  111. .offset = MTDPART_OFS_APPEND,
  112. }, {
  113. .name = "RootFS",
  114. .size = MTDPART_SIZ_FULL,
  115. .offset = MTDPART_OFS_APPEND,
  116. }
  117. };
  118. static struct physmap_flash_data stamp_flash_data = {
  119. .width = 2,
  120. .parts = stamp_partitions,
  121. .nr_parts = ARRAY_SIZE(stamp_partitions),
  122. };
  123. static struct resource stamp_flash_resource[] = {
  124. {
  125. .name = "cfi_probe",
  126. .start = 0x20000000,
  127. .end = 0x203fffff,
  128. .flags = IORESOURCE_MEM,
  129. }, {
  130. .start = CONFIG_ENET_FLASH_PIN,
  131. .flags = IORESOURCE_IRQ,
  132. }
  133. };
  134. static struct platform_device stamp_flash_device = {
  135. .name = "BF5xx-Flash",
  136. .id = 0,
  137. .dev = {
  138. .platform_data = &stamp_flash_data,
  139. },
  140. .num_resources = ARRAY_SIZE(stamp_flash_resource),
  141. .resource = stamp_flash_resource,
  142. };
  143. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  144. /* all SPI peripherals info goes here */
  145. #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
  146. static struct mtd_partition bfin_spi_flash_partitions[] = {
  147. {
  148. .name = "bootloader",
  149. .size = 0x00040000,
  150. .offset = 0,
  151. .mask_flags = MTD_CAP_ROM
  152. }, {
  153. .name = "kernel",
  154. .size = 0xe0000,
  155. .offset = MTDPART_OFS_APPEND,
  156. }, {
  157. .name = "file system",
  158. .size = MTDPART_SIZ_FULL,
  159. .offset = MTDPART_OFS_APPEND,
  160. }
  161. };
  162. static struct flash_platform_data bfin_spi_flash_data = {
  163. .name = "m25p80",
  164. .parts = bfin_spi_flash_partitions,
  165. .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
  166. .type = "m25p64",
  167. };
  168. /* SPI flash chip (m25p64) */
  169. static struct bfin5xx_spi_chip spi_flash_chip_info = {
  170. .enable_dma = 0, /* use dma transfer with this chip*/
  171. .bits_per_word = 8,
  172. };
  173. #endif
  174. #if defined(CONFIG_SPI_ADC_BF533) || defined(CONFIG_SPI_ADC_BF533_MODULE)
  175. /* SPI ADC chip */
  176. static struct bfin5xx_spi_chip spi_adc_chip_info = {
  177. .enable_dma = 1, /* use dma transfer with this chip*/
  178. .bits_per_word = 16,
  179. };
  180. #endif
  181. #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  182. static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
  183. .enable_dma = 0,
  184. .bits_per_word = 16,
  185. };
  186. #endif
  187. #if defined(CONFIG_PBX)
  188. static struct bfin5xx_spi_chip spi_si3xxx_chip_info = {
  189. .ctl_reg = 0x4, /* send zero */
  190. .enable_dma = 0,
  191. .bits_per_word = 8,
  192. .cs_change_per_word = 1,
  193. };
  194. #endif
  195. #if defined(CONFIG_AD5304) || defined(CONFIG_AD5304_MODULE)
  196. static struct bfin5xx_spi_chip ad5304_chip_info = {
  197. .enable_dma = 0,
  198. .bits_per_word = 16,
  199. };
  200. #endif
  201. #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
  202. static struct bfin5xx_spi_chip spi_mmc_chip_info = {
  203. .enable_dma = 1,
  204. .bits_per_word = 8,
  205. };
  206. #endif
  207. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  208. static struct bfin5xx_spi_chip spidev_chip_info = {
  209. .enable_dma = 0,
  210. .bits_per_word = 8,
  211. };
  212. #endif
  213. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  214. #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
  215. {
  216. /* the modalias must be the same as spi device driver name */
  217. .modalias = "m25p80", /* Name of spi_driver for this device */
  218. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  219. .bus_num = 0, /* Framework bus number */
  220. .chip_select = 2, /* Framework chip select. On STAMP537 it is SPISSEL2*/
  221. .platform_data = &bfin_spi_flash_data,
  222. .controller_data = &spi_flash_chip_info,
  223. .mode = SPI_MODE_3,
  224. },
  225. #endif
  226. #if defined(CONFIG_SPI_ADC_BF533) || defined(CONFIG_SPI_ADC_BF533_MODULE)
  227. {
  228. .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
  229. .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
  230. .bus_num = 0, /* Framework bus number */
  231. .chip_select = 1, /* Framework chip select. */
  232. .platform_data = NULL, /* No spi_driver specific config */
  233. .controller_data = &spi_adc_chip_info,
  234. },
  235. #endif
  236. #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  237. {
  238. .modalias = "ad1836-spi",
  239. .max_speed_hz = 31250000, /* max spi clock (SCK) speed in HZ */
  240. .bus_num = 0,
  241. .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
  242. .controller_data = &ad1836_spi_chip_info,
  243. },
  244. #endif
  245. #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
  246. {
  247. .modalias = "spi_mmc_dummy",
  248. .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
  249. .bus_num = 0,
  250. .chip_select = 0,
  251. .platform_data = NULL,
  252. .controller_data = &spi_mmc_chip_info,
  253. .mode = SPI_MODE_3,
  254. },
  255. {
  256. .modalias = "spi_mmc",
  257. .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
  258. .bus_num = 0,
  259. .chip_select = CONFIG_SPI_MMC_CS_CHAN,
  260. .platform_data = NULL,
  261. .controller_data = &spi_mmc_chip_info,
  262. .mode = SPI_MODE_3,
  263. },
  264. #endif
  265. #if defined(CONFIG_PBX)
  266. {
  267. .modalias = "fxs-spi",
  268. .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
  269. .bus_num = 0,
  270. .chip_select = 8 - CONFIG_J11_JUMPER,
  271. .controller_data = &spi_si3xxx_chip_info,
  272. .mode = SPI_MODE_3,
  273. },
  274. {
  275. .modalias = "fxo-spi",
  276. .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
  277. .bus_num = 0,
  278. .chip_select = 8 - CONFIG_J19_JUMPER,
  279. .controller_data = &spi_si3xxx_chip_info,
  280. .mode = SPI_MODE_3,
  281. },
  282. #endif
  283. #if defined(CONFIG_AD5304) || defined(CONFIG_AD5304_MODULE)
  284. {
  285. .modalias = "ad5304_spi",
  286. .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */
  287. .bus_num = 0,
  288. .chip_select = 2,
  289. .platform_data = NULL,
  290. .controller_data = &ad5304_chip_info,
  291. .mode = SPI_MODE_2,
  292. },
  293. #endif
  294. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  295. {
  296. .modalias = "spidev",
  297. .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
  298. .bus_num = 0,
  299. .chip_select = 1,
  300. .controller_data = &spidev_chip_info,
  301. },
  302. #endif
  303. };
  304. /* SPI (0) */
  305. static struct resource bfin_spi0_resource[] = {
  306. [0] = {
  307. .start = SPI0_REGBASE,
  308. .end = SPI0_REGBASE + 0xFF,
  309. .flags = IORESOURCE_MEM,
  310. },
  311. [1] = {
  312. .start = CH_SPI,
  313. .end = CH_SPI,
  314. .flags = IORESOURCE_IRQ,
  315. }
  316. };
  317. /* SPI controller data */
  318. static struct bfin5xx_spi_master bfin_spi0_info = {
  319. .num_chipselect = 8,
  320. .enable_dma = 1, /* master has the ability to do dma transfer */
  321. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  322. };
  323. static struct platform_device bfin_spi0_device = {
  324. .name = "bfin-spi",
  325. .id = 0, /* Bus number */
  326. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  327. .resource = bfin_spi0_resource,
  328. .dev = {
  329. .platform_data = &bfin_spi0_info, /* Passed to driver */
  330. },
  331. };
  332. #endif /* spi master and devices */
  333. #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
  334. static struct platform_device bfin_fb_device = {
  335. .name = "bf537-fb",
  336. };
  337. #endif
  338. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  339. static struct resource bfin_uart_resources[] = {
  340. {
  341. .start = 0xFFC00400,
  342. .end = 0xFFC004FF,
  343. .flags = IORESOURCE_MEM,
  344. },
  345. };
  346. static struct platform_device bfin_uart_device = {
  347. .name = "bfin-uart",
  348. .id = 1,
  349. .num_resources = ARRAY_SIZE(bfin_uart_resources),
  350. .resource = bfin_uart_resources,
  351. };
  352. #endif
  353. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  354. static struct platform_device bfin_sport0_uart_device = {
  355. .name = "bfin-sport-uart",
  356. .id = 0,
  357. };
  358. static struct platform_device bfin_sport1_uart_device = {
  359. .name = "bfin-sport-uart",
  360. .id = 1,
  361. };
  362. #endif
  363. #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
  364. #define PATA_INT 55
  365. static struct pata_platform_info bfin_pata_platform_data = {
  366. .ioport_shift = 1,
  367. .irq_type = IRQF_TRIGGER_HIGH | IRQF_DISABLED,
  368. };
  369. static struct resource bfin_pata_resources[] = {
  370. {
  371. .start = 0x20314020,
  372. .end = 0x2031403F,
  373. .flags = IORESOURCE_MEM,
  374. },
  375. {
  376. .start = 0x2031401C,
  377. .end = 0x2031401F,
  378. .flags = IORESOURCE_MEM,
  379. },
  380. {
  381. .start = PATA_INT,
  382. .end = PATA_INT,
  383. .flags = IORESOURCE_IRQ,
  384. },
  385. };
  386. static struct platform_device bfin_pata_device = {
  387. .name = "pata_platform",
  388. .id = -1,
  389. .num_resources = ARRAY_SIZE(bfin_pata_resources),
  390. .resource = bfin_pata_resources,
  391. .dev = {
  392. .platform_data = &bfin_pata_platform_data,
  393. }
  394. };
  395. #endif
  396. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  397. #include <linux/input.h>
  398. #include <linux/gpio_keys.h>
  399. static struct gpio_keys_button bfin_gpio_keys_table[] = {
  400. {BTN_0, GPIO_PF5, 0, "gpio-keys: BTN0"},
  401. {BTN_1, GPIO_PF6, 0, "gpio-keys: BTN1"},
  402. {BTN_2, GPIO_PF8, 0, "gpio-keys: BTN2"},
  403. };
  404. static struct gpio_keys_platform_data bfin_gpio_keys_data = {
  405. .buttons = bfin_gpio_keys_table,
  406. .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
  407. };
  408. static struct platform_device bfin_device_gpiokeys = {
  409. .name = "gpio-keys",
  410. .dev = {
  411. .platform_data = &bfin_gpio_keys_data,
  412. },
  413. };
  414. #endif
  415. static struct resource bfin_gpios_resources = {
  416. .start = 0,
  417. .end = MAX_BLACKFIN_GPIOS - 1,
  418. .flags = IORESOURCE_IRQ,
  419. };
  420. static struct platform_device bfin_gpios_device = {
  421. .name = "simple-gpio",
  422. .id = -1,
  423. .num_resources = 1,
  424. .resource = &bfin_gpios_resources,
  425. };
  426. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  427. #include <linux/i2c-gpio.h>
  428. static struct i2c_gpio_platform_data i2c_gpio_data = {
  429. .sda_pin = 2,
  430. .scl_pin = 3,
  431. .sda_is_open_drain = 0,
  432. .scl_is_open_drain = 0,
  433. .udelay = 40,
  434. };
  435. static struct platform_device i2c_gpio_device = {
  436. .name = "i2c-gpio",
  437. .id = 0,
  438. .dev = {
  439. .platform_data = &i2c_gpio_data,
  440. },
  441. };
  442. #endif
  443. static struct platform_device *stamp_devices[] __initdata = {
  444. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  445. &rtc_device,
  446. #endif
  447. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  448. &smc91x_device,
  449. #endif
  450. #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
  451. &bfin_fb_adv7393_device,
  452. #endif
  453. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  454. &net2272_bfin_device,
  455. #endif
  456. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  457. &bfin_spi0_device,
  458. #endif
  459. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  460. &bfin_uart_device,
  461. #endif
  462. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  463. &bfin_sport0_uart_device,
  464. &bfin_sport1_uart_device,
  465. #endif
  466. #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
  467. &bfin_pata_device,
  468. #endif
  469. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  470. &bfin_device_gpiokeys,
  471. #endif
  472. #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
  473. &i2c_gpio_device,
  474. #endif
  475. &bfin_gpios_device,
  476. &stamp_flash_device,
  477. };
  478. static int __init stamp_init(void)
  479. {
  480. int ret;
  481. printk(KERN_INFO "%s(): registering device resources\n", __FUNCTION__);
  482. ret = platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
  483. if (ret < 0)
  484. return ret;
  485. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  486. /* setup BF533_STAMP CPLD to route AMS3 to Ethernet MAC */
  487. bfin_write_FIO_DIR(bfin_read_FIO_DIR() | (1 << CONFIG_ENET_FLASH_PIN));
  488. bfin_write_FIO_FLAG_S(1 << CONFIG_ENET_FLASH_PIN);
  489. SSYNC();
  490. #endif
  491. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  492. spi_register_board_info(bfin_spi_board_info,
  493. ARRAY_SIZE(bfin_spi_board_info));
  494. #endif
  495. #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
  496. irq_desc[PATA_INT].status |= IRQ_NOAUTOEN;
  497. #endif
  498. return 0;
  499. }
  500. arch_initcall(stamp_init);
  501. void native_machine_restart(char *cmd)
  502. {
  503. #define BIT_TO_SET (1 << CONFIG_ENET_FLASH_PIN)
  504. bfin_write_FIO_INEN(~BIT_TO_SET);
  505. bfin_write_FIO_DIR(BIT_TO_SET);
  506. bfin_write_FIO_FLAG_C(BIT_TO_SET);
  507. }