tll6527m.c 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008
  1. /* File: arch/blackfin/mach-bf527/boards/tll6527m.c
  2. * Based on: arch/blackfin/mach-bf527/boards/ezkit.c
  3. * Author: Ashish Gupta
  4. *
  5. * Copyright: 2010 - The Learning Labs Inc.
  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/i2c.h>
  17. #include <linux/irq.h>
  18. #include <linux/interrupt.h>
  19. #include <linux/usb/musb.h>
  20. #include <linux/leds.h>
  21. #include <linux/input.h>
  22. #include <asm/dma.h>
  23. #include <asm/bfin5xx_spi.h>
  24. #include <asm/reboot.h>
  25. #include <asm/nand.h>
  26. #include <asm/portmux.h>
  27. #include <asm/dpmc.h>
  28. #if defined(CONFIG_TOUCHSCREEN_AD7879) \
  29. || defined(CONFIG_TOUCHSCREEN_AD7879_MODULE)
  30. #include <linux/spi/ad7879.h>
  31. #define LCD_BACKLIGHT_GPIO 0x40
  32. /* TLL6527M uses TLL7UIQ35 / ADI LCD EZ Extender. AD7879 AUX GPIO is used for
  33. * LCD Backlight Enable
  34. */
  35. #endif
  36. /*
  37. * Name the Board for the /proc/cpuinfo
  38. */
  39. const char bfin_board_name[] = "TLL6527M";
  40. /*
  41. * Driver needs to know address, irq and flag pin.
  42. */
  43. #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
  44. static struct resource musb_resources[] = {
  45. [0] = {
  46. .start = 0xffc03800,
  47. .end = 0xffc03cff,
  48. .flags = IORESOURCE_MEM,
  49. },
  50. [1] = { /* general IRQ */
  51. .start = IRQ_USB_INT0,
  52. .end = IRQ_USB_INT0,
  53. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  54. },
  55. [2] = { /* DMA IRQ */
  56. .start = IRQ_USB_DMA,
  57. .end = IRQ_USB_DMA,
  58. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  59. },
  60. };
  61. static struct musb_hdrc_config musb_config = {
  62. .multipoint = 0,
  63. .dyn_fifo = 0,
  64. .soft_con = 1,
  65. .dma = 1,
  66. .num_eps = 8,
  67. .dma_channels = 8,
  68. /*.gpio_vrsel = GPIO_PG13,*/
  69. /* Some custom boards need to be active low, just set it to "0"
  70. * if it is the case.
  71. */
  72. .gpio_vrsel_active = 1,
  73. };
  74. static struct musb_hdrc_platform_data musb_plat = {
  75. #if defined(CONFIG_USB_MUSB_OTG)
  76. .mode = MUSB_OTG,
  77. #elif defined(CONFIG_USB_MUSB_HDRC_HCD)
  78. .mode = MUSB_HOST,
  79. #elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
  80. .mode = MUSB_PERIPHERAL,
  81. #endif
  82. .config = &musb_config,
  83. };
  84. static u64 musb_dmamask = ~(u32)0;
  85. static struct platform_device musb_device = {
  86. .name = "musb-blackfin",
  87. .id = 0,
  88. .dev = {
  89. .dma_mask = &musb_dmamask,
  90. .coherent_dma_mask = 0xffffffff,
  91. .platform_data = &musb_plat,
  92. },
  93. .num_resources = ARRAY_SIZE(musb_resources),
  94. .resource = musb_resources,
  95. };
  96. #endif
  97. #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
  98. #include <asm/bfin-lq035q1.h>
  99. static struct bfin_lq035q1fb_disp_info bfin_lq035q1_data = {
  100. .mode = LQ035_NORM | LQ035_RGB | LQ035_RL | LQ035_TB,
  101. .ppi_mode = USE_RGB565_16_BIT_PPI,
  102. .use_bl = 1,
  103. .gpio_bl = LCD_BACKLIGHT_GPIO,
  104. };
  105. static struct resource bfin_lq035q1_resources[] = {
  106. {
  107. .start = IRQ_PPI_ERROR,
  108. .end = IRQ_PPI_ERROR,
  109. .flags = IORESOURCE_IRQ,
  110. },
  111. };
  112. static struct platform_device bfin_lq035q1_device = {
  113. .name = "bfin-lq035q1",
  114. .id = -1,
  115. .num_resources = ARRAY_SIZE(bfin_lq035q1_resources),
  116. .resource = bfin_lq035q1_resources,
  117. .dev = {
  118. .platform_data = &bfin_lq035q1_data,
  119. },
  120. };
  121. #endif
  122. #if defined(CONFIG_MTD_GPIO_ADDR) || defined(CONFIG_MTD_GPIO_ADDR_MODULE)
  123. static struct mtd_partition tll6527m_partitions[] = {
  124. {
  125. .name = "bootloader(nor)",
  126. .size = 0xA0000,
  127. .offset = 0,
  128. }, {
  129. .name = "linux kernel(nor)",
  130. .size = 0xD00000,
  131. .offset = MTDPART_OFS_APPEND,
  132. }, {
  133. .name = "file system(nor)",
  134. .size = MTDPART_SIZ_FULL,
  135. .offset = MTDPART_OFS_APPEND,
  136. }
  137. };
  138. static struct physmap_flash_data tll6527m_flash_data = {
  139. .width = 2,
  140. .parts = tll6527m_partitions,
  141. .nr_parts = ARRAY_SIZE(tll6527m_partitions),
  142. };
  143. static unsigned tll6527m_flash_gpios[] = { GPIO_PG11, GPIO_PH11, GPIO_PH12 };
  144. static struct resource tll6527m_flash_resource[] = {
  145. {
  146. .name = "cfi_probe",
  147. .start = 0x20000000,
  148. .end = 0x201fffff,
  149. .flags = IORESOURCE_MEM,
  150. }, {
  151. .start = (unsigned long)tll6527m_flash_gpios,
  152. .end = ARRAY_SIZE(tll6527m_flash_gpios),
  153. .flags = IORESOURCE_IRQ,
  154. }
  155. };
  156. static struct platform_device tll6527m_flash_device = {
  157. .name = "gpio-addr-flash",
  158. .id = 0,
  159. .dev = {
  160. .platform_data = &tll6527m_flash_data,
  161. },
  162. .num_resources = ARRAY_SIZE(tll6527m_flash_resource),
  163. .resource = tll6527m_flash_resource,
  164. };
  165. #endif
  166. #if defined(CONFIG_GPIO_DECODER) || defined(CONFIG_GPIO_DECODER_MODULE)
  167. /* An SN74LVC138A 3:8 decoder chip has been used to generate 7 augmented
  168. * outputs used as SPI CS lines for all SPI SLAVE devices on TLL6527v1-0.
  169. * EXP_GPIO_SPISEL_BASE is the base number for the expanded outputs being
  170. * used as SPI CS lines, this should be > MAX_BLACKFIN_GPIOS
  171. */
  172. #include <linux/gpio-decoder.h>
  173. #define EXP_GPIO_SPISEL_BASE 0x64
  174. static unsigned gpio_addr_inputs[] = {
  175. GPIO_PG1, GPIO_PH9, GPIO_PH10
  176. };
  177. static struct gpio_decoder_platform_data spi_decoded_cs = {
  178. .base = EXP_GPIO_SPISEL_BASE,
  179. .input_addrs = gpio_addr_inputs,
  180. .nr_input_addrs = ARRAY_SIZE(gpio_addr_inputs),
  181. .default_output = 0,
  182. /* .default_output = (1 << ARRAY_SIZE(gpio_addr_inputs)) - 1 */
  183. };
  184. static struct platform_device spi_decoded_gpio = {
  185. .name = "gpio-decoder",
  186. .id = 0,
  187. .dev = {
  188. .platform_data = &spi_decoded_cs,
  189. },
  190. };
  191. #else
  192. #define EXP_GPIO_SPISEL_BASE 0x0
  193. #endif
  194. #if defined(CONFIG_INPUT_ADXL34X) || defined(CONFIG_INPUT_ADXL34X_MODULE)
  195. #include <linux/input/adxl34x.h>
  196. static const struct adxl34x_platform_data adxl345_info = {
  197. .x_axis_offset = 0,
  198. .y_axis_offset = 0,
  199. .z_axis_offset = 0,
  200. .tap_threshold = 0x31,
  201. .tap_duration = 0x10,
  202. .tap_latency = 0x60,
  203. .tap_window = 0xF0,
  204. .tap_axis_control = ADXL_TAP_X_EN | ADXL_TAP_Y_EN | ADXL_TAP_Z_EN,
  205. .act_axis_control = 0xFF,
  206. .activity_threshold = 5,
  207. .inactivity_threshold = 2,
  208. .inactivity_time = 2,
  209. .free_fall_threshold = 0x7,
  210. .free_fall_time = 0x20,
  211. .data_rate = 0x8,
  212. .data_range = ADXL_FULL_RES,
  213. .ev_type = EV_ABS,
  214. .ev_code_x = ABS_X, /* EV_REL */
  215. .ev_code_y = ABS_Y, /* EV_REL */
  216. .ev_code_z = ABS_Z, /* EV_REL */
  217. .ev_code_tap = {BTN_TOUCH, BTN_TOUCH, BTN_TOUCH}, /* EV_KEY x,y,z */
  218. /* .ev_code_ff = KEY_F,*/ /* EV_KEY */
  219. .ev_code_act_inactivity = KEY_A, /* EV_KEY */
  220. .use_int2 = 1,
  221. .power_mode = ADXL_AUTO_SLEEP | ADXL_LINK,
  222. .fifo_mode = ADXL_FIFO_STREAM,
  223. };
  224. #endif
  225. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  226. static struct platform_device rtc_device = {
  227. .name = "rtc-bfin",
  228. .id = -1,
  229. };
  230. #endif
  231. #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
  232. #include <linux/bfin_mac.h>
  233. static const unsigned short bfin_mac_peripherals[] = P_RMII0;
  234. static struct bfin_phydev_platform_data bfin_phydev_data[] = {
  235. {
  236. .addr = 1,
  237. .irq = IRQ_MAC_PHYINT,
  238. },
  239. };
  240. static struct bfin_mii_bus_platform_data bfin_mii_bus_data = {
  241. .phydev_number = 1,
  242. .phydev_data = bfin_phydev_data,
  243. .phy_mode = PHY_INTERFACE_MODE_RMII,
  244. .mac_peripherals = bfin_mac_peripherals,
  245. };
  246. static struct platform_device bfin_mii_bus = {
  247. .name = "bfin_mii_bus",
  248. .dev = {
  249. .platform_data = &bfin_mii_bus_data,
  250. }
  251. };
  252. static struct platform_device bfin_mac_device = {
  253. .name = "bfin_mac",
  254. .dev = {
  255. .platform_data = &bfin_mii_bus,
  256. }
  257. };
  258. #endif
  259. #if defined(CONFIG_MTD_M25P80) \
  260. || defined(CONFIG_MTD_M25P80_MODULE)
  261. static struct mtd_partition bfin_spi_flash_partitions[] = {
  262. {
  263. .name = "bootloader(spi)",
  264. .size = 0x00040000,
  265. .offset = 0,
  266. .mask_flags = MTD_CAP_ROM
  267. }, {
  268. .name = "linux kernel(spi)",
  269. .size = MTDPART_SIZ_FULL,
  270. .offset = MTDPART_OFS_APPEND,
  271. }
  272. };
  273. static struct flash_platform_data bfin_spi_flash_data = {
  274. .name = "m25p80",
  275. .parts = bfin_spi_flash_partitions,
  276. .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
  277. .type = "m25p16",
  278. };
  279. /* SPI flash chip (m25p64) */
  280. static struct bfin5xx_spi_chip spi_flash_chip_info = {
  281. .enable_dma = 0, /* use dma transfer with this chip*/
  282. .bits_per_word = 8,
  283. };
  284. #endif
  285. #if defined(CONFIG_BFIN_SPI_ADC) \
  286. || defined(CONFIG_BFIN_SPI_ADC_MODULE)
  287. /* SPI ADC chip */
  288. static struct bfin5xx_spi_chip spi_adc_chip_info = {
  289. .enable_dma = 0, /* use dma transfer with this chip*/
  290. /*
  291. * tll6527m V1.0 does not support native spi slave selects
  292. * hence DMA mode will not be useful since the ADC needs
  293. * CS to toggle for each sample and cs_change_per_word
  294. * seems to be removed from spi_bfin5xx.c
  295. */
  296. .bits_per_word = 16,
  297. };
  298. #endif
  299. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  300. static struct bfin5xx_spi_chip mmc_spi_chip_info = {
  301. .enable_dma = 0,
  302. .bits_per_word = 8,
  303. };
  304. #endif
  305. #if defined(CONFIG_TOUCHSCREEN_AD7879) \
  306. || defined(CONFIG_TOUCHSCREEN_AD7879_MODULE)
  307. static const struct ad7879_platform_data bfin_ad7879_ts_info = {
  308. .model = 7879, /* Model = AD7879 */
  309. .x_plate_ohms = 620, /* 620 Ohm from the touch datasheet */
  310. .pressure_max = 10000,
  311. .pressure_min = 0,
  312. .first_conversion_delay = 3,
  313. /* wait 512us before do a first conversion */
  314. .acquisition_time = 1, /* 4us acquisition time per sample */
  315. .median = 2, /* do 8 measurements */
  316. .averaging = 1,
  317. /* take the average of 4 middle samples */
  318. .pen_down_acc_interval = 255, /* 9.4 ms */
  319. .gpio_export = 1, /* configure AUX as GPIO output*/
  320. .gpio_base = LCD_BACKLIGHT_GPIO,
  321. };
  322. #endif
  323. #if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) \
  324. || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE)
  325. static struct bfin5xx_spi_chip spi_ad7879_chip_info = {
  326. .enable_dma = 0,
  327. .bits_per_word = 16,
  328. };
  329. #endif
  330. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  331. static struct bfin5xx_spi_chip spidev_chip_info = {
  332. .enable_dma = 0,
  333. .bits_per_word = 8,
  334. };
  335. #endif
  336. #if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)
  337. static struct platform_device bfin_i2s = {
  338. .name = "bfin-i2s",
  339. .id = CONFIG_SND_BF5XX_SPORT_NUM,
  340. /* TODO: add platform data here */
  341. };
  342. #endif
  343. #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
  344. static struct bfin5xx_spi_chip lq035q1_spi_chip_info = {
  345. .enable_dma = 0,
  346. .bits_per_word = 8,
  347. };
  348. #endif
  349. #if defined(CONFIG_GPIO_MCP23S08) || defined(CONFIG_GPIO_MCP23S08_MODULE)
  350. static struct bfin5xx_spi_chip spi_mcp23s08_sys_chip_info = {
  351. .enable_dma = 0,
  352. .bits_per_word = 8,
  353. };
  354. static struct bfin5xx_spi_chip spi_mcp23s08_usr_chip_info = {
  355. .enable_dma = 0,
  356. .bits_per_word = 8,
  357. };
  358. #include <linux/spi/mcp23s08.h>
  359. static const struct mcp23s08_platform_data bfin_mcp23s08_sys_gpio_info = {
  360. .chip[0].is_present = true,
  361. .base = 0x30,
  362. };
  363. static const struct mcp23s08_platform_data bfin_mcp23s08_usr_gpio_info = {
  364. .chip[2].is_present = true,
  365. .base = 0x38,
  366. };
  367. #endif
  368. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  369. #if defined(CONFIG_MTD_M25P80) \
  370. || defined(CONFIG_MTD_M25P80_MODULE)
  371. {
  372. /* the modalias must be the same as spi device driver name */
  373. .modalias = "m25p80", /* Name of spi_driver for this device */
  374. .max_speed_hz = 25000000,
  375. /* max spi clock (SCK) speed in HZ */
  376. .bus_num = 0, /* Framework bus number */
  377. .chip_select = EXP_GPIO_SPISEL_BASE + 0x04 + MAX_CTRL_CS,
  378. /* Can be connected to TLL6527M GPIO connector */
  379. /* Either SPI_ADC or M25P80 FLASH can be installed at a time */
  380. .platform_data = &bfin_spi_flash_data,
  381. .controller_data = &spi_flash_chip_info,
  382. .mode = SPI_MODE_3,
  383. },
  384. #endif
  385. #if defined(CONFIG_BFIN_SPI_ADC)
  386. || defined(CONFIG_BFIN_SPI_ADC_MODULE)
  387. {
  388. .modalias = "bfin_spi_adc",
  389. /* Name of spi_driver for this device */
  390. .max_speed_hz = 10000000,
  391. /* max spi clock (SCK) speed in HZ */
  392. .bus_num = 0, /* Framework bus number */
  393. .chip_select = EXP_GPIO_SPISEL_BASE + 0x04 + MAX_CTRL_CS,
  394. /* Framework chip select. */
  395. .platform_data = NULL, /* No spi_driver specific config */
  396. .controller_data = &spi_adc_chip_info,
  397. .mode = SPI_MODE_0,
  398. },
  399. #endif
  400. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  401. {
  402. .modalias = "mmc_spi",
  403. /*
  404. * TLL6527M V1.0 does not support SD Card at SPI Clock > 10 MHz due to
  405. * SPI buffer limitations
  406. */
  407. .max_speed_hz = 10000000,
  408. /* max spi clock (SCK) speed in HZ */
  409. .bus_num = 0,
  410. .chip_select = EXP_GPIO_SPISEL_BASE + 0x05 + MAX_CTRL_CS,
  411. .controller_data = &mmc_spi_chip_info,
  412. .mode = SPI_MODE_0,
  413. },
  414. #endif
  415. #if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) \
  416. || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE)
  417. {
  418. .modalias = "ad7879",
  419. .platform_data = &bfin_ad7879_ts_info,
  420. .irq = IRQ_PH14,
  421. .max_speed_hz = 5000000,
  422. /* max spi clock (SCK) speed in HZ */
  423. .bus_num = 0,
  424. .chip_select = EXP_GPIO_SPISEL_BASE + 0x07 + MAX_CTRL_CS,
  425. .controller_data = &spi_ad7879_chip_info,
  426. .mode = SPI_CPHA | SPI_CPOL,
  427. },
  428. #endif
  429. #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
  430. {
  431. .modalias = "spidev",
  432. .max_speed_hz = 10000000,
  433. /* TLL6527Mv1-0 supports max spi clock (SCK) speed = 10 MHz */
  434. .bus_num = 0,
  435. .chip_select = EXP_GPIO_SPISEL_BASE + 0x03 + MAX_CTRL_CS,
  436. .mode = SPI_CPHA | SPI_CPOL,
  437. .controller_data = &spidev_chip_info,
  438. },
  439. #endif
  440. #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
  441. {
  442. .modalias = "bfin-lq035q1-spi",
  443. .max_speed_hz = 20000000,
  444. .bus_num = 0,
  445. .chip_select = EXP_GPIO_SPISEL_BASE + 0x06 + MAX_CTRL_CS,
  446. .controller_data = &lq035q1_spi_chip_info,
  447. .mode = SPI_CPHA | SPI_CPOL,
  448. },
  449. #endif
  450. #if defined(CONFIG_GPIO_MCP23S08) || defined(CONFIG_GPIO_MCP23S08_MODULE)
  451. {
  452. .modalias = "mcp23s08",
  453. .platform_data = &bfin_mcp23s08_sys_gpio_info,
  454. .max_speed_hz = 5000000, /* max spi clock (SCK) speed in HZ */
  455. .bus_num = 0,
  456. .chip_select = EXP_GPIO_SPISEL_BASE + 0x01 + MAX_CTRL_CS,
  457. .controller_data = &spi_mcp23s08_sys_chip_info,
  458. .mode = SPI_CPHA | SPI_CPOL,
  459. },
  460. {
  461. .modalias = "mcp23s08",
  462. .platform_data = &bfin_mcp23s08_usr_gpio_info,
  463. .max_speed_hz = 5000000, /* max spi clock (SCK) speed in HZ */
  464. .bus_num = 0,
  465. .chip_select = EXP_GPIO_SPISEL_BASE + 0x02 + MAX_CTRL_CS,
  466. .controller_data = &spi_mcp23s08_usr_chip_info,
  467. .mode = SPI_CPHA | SPI_CPOL,
  468. },
  469. #endif
  470. };
  471. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  472. /* SPI controller data */
  473. static struct bfin5xx_spi_master bfin_spi0_info = {
  474. .num_chipselect = EXP_GPIO_SPISEL_BASE + 8 + MAX_CTRL_CS,
  475. /* EXP_GPIO_SPISEL_BASE will be > MAX_BLACKFIN_GPIOS */
  476. .enable_dma = 1, /* master has the ability to do dma transfer */
  477. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  478. };
  479. /* SPI (0) */
  480. static struct resource bfin_spi0_resource[] = {
  481. [0] = {
  482. .start = SPI0_REGBASE,
  483. .end = SPI0_REGBASE + 0xFF,
  484. .flags = IORESOURCE_MEM,
  485. },
  486. [1] = {
  487. .start = CH_SPI,
  488. .end = CH_SPI,
  489. .flags = IORESOURCE_DMA,
  490. },
  491. [2] = {
  492. .start = IRQ_SPI,
  493. .end = IRQ_SPI,
  494. .flags = IORESOURCE_IRQ,
  495. },
  496. };
  497. static struct platform_device bfin_spi0_device = {
  498. .name = "bfin-spi",
  499. .id = 0, /* Bus number */
  500. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  501. .resource = bfin_spi0_resource,
  502. .dev = {
  503. .platform_data = &bfin_spi0_info, /* Passed to driver */
  504. },
  505. };
  506. #endif /* spi master and devices */
  507. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  508. #ifdef CONFIG_SERIAL_BFIN_UART0
  509. static struct resource bfin_uart0_resources[] = {
  510. {
  511. .start = UART0_THR,
  512. .end = UART0_GCTL+2,
  513. .flags = IORESOURCE_MEM,
  514. },
  515. {
  516. .start = IRQ_UART0_RX,
  517. .end = IRQ_UART0_RX+1,
  518. .flags = IORESOURCE_IRQ,
  519. },
  520. {
  521. .start = IRQ_UART0_ERROR,
  522. .end = IRQ_UART0_ERROR,
  523. .flags = IORESOURCE_IRQ,
  524. },
  525. {
  526. .start = CH_UART0_TX,
  527. .end = CH_UART0_TX,
  528. .flags = IORESOURCE_DMA,
  529. },
  530. {
  531. .start = CH_UART0_RX,
  532. .end = CH_UART0_RX,
  533. .flags = IORESOURCE_DMA,
  534. },
  535. };
  536. static unsigned short bfin_uart0_peripherals[] = {
  537. P_UART0_TX, P_UART0_RX, 0
  538. };
  539. static struct platform_device bfin_uart0_device = {
  540. .name = "bfin-uart",
  541. .id = 0,
  542. .num_resources = ARRAY_SIZE(bfin_uart0_resources),
  543. .resource = bfin_uart0_resources,
  544. .dev = {
  545. .platform_data = &bfin_uart0_peripherals,
  546. /* Passed to driver */
  547. },
  548. };
  549. #endif
  550. #ifdef CONFIG_SERIAL_BFIN_UART1
  551. static struct resource bfin_uart1_resources[] = {
  552. {
  553. .start = UART1_THR,
  554. .end = UART1_GCTL+2,
  555. .flags = IORESOURCE_MEM,
  556. },
  557. {
  558. .start = IRQ_UART1_RX,
  559. .end = IRQ_UART1_RX+1,
  560. .flags = IORESOURCE_IRQ,
  561. },
  562. {
  563. .start = IRQ_UART1_ERROR,
  564. .end = IRQ_UART1_ERROR,
  565. .flags = IORESOURCE_IRQ,
  566. },
  567. {
  568. .start = CH_UART1_TX,
  569. .end = CH_UART1_TX,
  570. .flags = IORESOURCE_DMA,
  571. },
  572. {
  573. .start = CH_UART1_RX,
  574. .end = CH_UART1_RX,
  575. .flags = IORESOURCE_DMA,
  576. },
  577. #ifdef CONFIG_BFIN_UART1_CTSRTS
  578. { /* CTS pin */
  579. .start = GPIO_PF9,
  580. .end = GPIO_PF9,
  581. .flags = IORESOURCE_IO,
  582. },
  583. { /* RTS pin */
  584. .start = GPIO_PF10,
  585. .end = GPIO_PF10,
  586. .flags = IORESOURCE_IO,
  587. },
  588. #endif
  589. };
  590. static unsigned short bfin_uart1_peripherals[] = {
  591. P_UART1_TX, P_UART1_RX, 0
  592. };
  593. static struct platform_device bfin_uart1_device = {
  594. .name = "bfin-uart",
  595. .id = 1,
  596. .num_resources = ARRAY_SIZE(bfin_uart1_resources),
  597. .resource = bfin_uart1_resources,
  598. .dev = {
  599. .platform_data = &bfin_uart1_peripherals,
  600. /* Passed to driver */
  601. },
  602. };
  603. #endif
  604. #endif
  605. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  606. #ifdef CONFIG_BFIN_SIR0
  607. static struct resource bfin_sir0_resources[] = {
  608. {
  609. .start = 0xFFC00400,
  610. .end = 0xFFC004FF,
  611. .flags = IORESOURCE_MEM,
  612. },
  613. {
  614. .start = IRQ_UART0_RX,
  615. .end = IRQ_UART0_RX+1,
  616. .flags = IORESOURCE_IRQ,
  617. },
  618. {
  619. .start = CH_UART0_RX,
  620. .end = CH_UART0_RX+1,
  621. .flags = IORESOURCE_DMA,
  622. },
  623. };
  624. static struct platform_device bfin_sir0_device = {
  625. .name = "bfin_sir",
  626. .id = 0,
  627. .num_resources = ARRAY_SIZE(bfin_sir0_resources),
  628. .resource = bfin_sir0_resources,
  629. };
  630. #endif
  631. #ifdef CONFIG_BFIN_SIR1
  632. static struct resource bfin_sir1_resources[] = {
  633. {
  634. .start = 0xFFC02000,
  635. .end = 0xFFC020FF,
  636. .flags = IORESOURCE_MEM,
  637. },
  638. {
  639. .start = IRQ_UART1_RX,
  640. .end = IRQ_UART1_RX+1,
  641. .flags = IORESOURCE_IRQ,
  642. },
  643. {
  644. .start = CH_UART1_RX,
  645. .end = CH_UART1_RX+1,
  646. .flags = IORESOURCE_DMA,
  647. },
  648. };
  649. static struct platform_device bfin_sir1_device = {
  650. .name = "bfin_sir",
  651. .id = 1,
  652. .num_resources = ARRAY_SIZE(bfin_sir1_resources),
  653. .resource = bfin_sir1_resources,
  654. };
  655. #endif
  656. #endif
  657. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  658. static struct resource bfin_twi0_resource[] = {
  659. [0] = {
  660. .start = TWI0_REGBASE,
  661. .end = TWI0_REGBASE,
  662. .flags = IORESOURCE_MEM,
  663. },
  664. [1] = {
  665. .start = IRQ_TWI,
  666. .end = IRQ_TWI,
  667. .flags = IORESOURCE_IRQ,
  668. },
  669. };
  670. static struct platform_device i2c_bfin_twi_device = {
  671. .name = "i2c-bfin-twi",
  672. .id = 0,
  673. .num_resources = ARRAY_SIZE(bfin_twi0_resource),
  674. .resource = bfin_twi0_resource,
  675. };
  676. #endif
  677. static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
  678. #if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE)
  679. {
  680. I2C_BOARD_INFO("pcf8574_lcd", 0x22),
  681. },
  682. #endif
  683. #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
  684. {
  685. I2C_BOARD_INFO("bfin-adv7393", 0x2B),
  686. },
  687. #endif
  688. #if defined(CONFIG_TOUCHSCREEN_AD7879_I2C) \
  689. || defined(CONFIG_TOUCHSCREEN_AD7879_I2C_MODULE)
  690. {
  691. I2C_BOARD_INFO("ad7879", 0x2C),
  692. .irq = IRQ_PH14,
  693. .platform_data = (void *)&bfin_ad7879_ts_info,
  694. },
  695. #endif
  696. #if defined(CONFIG_SND_SOC_SSM2602) || defined(CONFIG_SND_SOC_SSM2602_MODULE)
  697. {
  698. I2C_BOARD_INFO("ssm2602", 0x1b),
  699. },
  700. #endif
  701. {
  702. I2C_BOARD_INFO("adm1192", 0x2e),
  703. },
  704. {
  705. I2C_BOARD_INFO("ltc3576", 0x09),
  706. },
  707. #if defined(CONFIG_INPUT_ADXL34X_I2C) \
  708. || defined(CONFIG_INPUT_ADXL34X_I2C_MODULE)
  709. {
  710. I2C_BOARD_INFO("adxl34x", 0x53),
  711. .irq = IRQ_PH13,
  712. .platform_data = (void *)&adxl345_info,
  713. },
  714. #endif
  715. };
  716. #if defined(CONFIG_SERIAL_BFIN_SPORT) \
  717. || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  718. #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
  719. static struct resource bfin_sport0_uart_resources[] = {
  720. {
  721. .start = SPORT0_TCR1,
  722. .end = SPORT0_MRCS3+4,
  723. .flags = IORESOURCE_MEM,
  724. },
  725. {
  726. .start = IRQ_SPORT0_RX,
  727. .end = IRQ_SPORT0_RX+1,
  728. .flags = IORESOURCE_IRQ,
  729. },
  730. {
  731. .start = IRQ_SPORT0_ERROR,
  732. .end = IRQ_SPORT0_ERROR,
  733. .flags = IORESOURCE_IRQ,
  734. },
  735. };
  736. static unsigned short bfin_sport0_peripherals[] = {
  737. P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS,
  738. P_SPORT0_DRPRI, P_SPORT0_RSCLK, 0
  739. };
  740. static struct platform_device bfin_sport0_uart_device = {
  741. .name = "bfin-sport-uart",
  742. .id = 0,
  743. .num_resources = ARRAY_SIZE(bfin_sport0_uart_resources),
  744. .resource = bfin_sport0_uart_resources,
  745. .dev = {
  746. .platform_data = &bfin_sport0_peripherals,
  747. /* Passed to driver */
  748. },
  749. };
  750. #endif
  751. #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
  752. static struct resource bfin_sport1_uart_resources[] = {
  753. {
  754. .start = SPORT1_TCR1,
  755. .end = SPORT1_MRCS3+4,
  756. .flags = IORESOURCE_MEM,
  757. },
  758. {
  759. .start = IRQ_SPORT1_RX,
  760. .end = IRQ_SPORT1_RX+1,
  761. .flags = IORESOURCE_IRQ,
  762. },
  763. {
  764. .start = IRQ_SPORT1_ERROR,
  765. .end = IRQ_SPORT1_ERROR,
  766. .flags = IORESOURCE_IRQ,
  767. },
  768. };
  769. static unsigned short bfin_sport1_peripherals[] = {
  770. P_SPORT1_TFS, P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS,
  771. P_SPORT1_DRPRI, P_SPORT1_RSCLK, 0
  772. };
  773. static struct platform_device bfin_sport1_uart_device = {
  774. .name = "bfin-sport-uart",
  775. .id = 1,
  776. .num_resources = ARRAY_SIZE(bfin_sport1_uart_resources),
  777. .resource = bfin_sport1_uart_resources,
  778. .dev = {
  779. .platform_data = &bfin_sport1_peripherals,
  780. /* Passed to driver */
  781. },
  782. };
  783. #endif
  784. #endif
  785. static const unsigned int cclk_vlev_datasheet[] = {
  786. VRPAIR(VLEV_100, 400000000),
  787. VRPAIR(VLEV_105, 426000000),
  788. VRPAIR(VLEV_110, 500000000),
  789. VRPAIR(VLEV_115, 533000000),
  790. VRPAIR(VLEV_120, 600000000),
  791. };
  792. static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
  793. .tuple_tab = cclk_vlev_datasheet,
  794. .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
  795. .vr_settling_time = 25 /* us */,
  796. };
  797. static struct platform_device bfin_dpmc = {
  798. .name = "bfin dpmc",
  799. .dev = {
  800. .platform_data = &bfin_dmpc_vreg_data,
  801. },
  802. };
  803. static struct platform_device *tll6527m_devices[] __initdata = {
  804. &bfin_dpmc,
  805. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  806. &rtc_device,
  807. #endif
  808. #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
  809. &musb_device,
  810. #endif
  811. #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
  812. &bfin_mii_bus,
  813. &bfin_mac_device,
  814. #endif
  815. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  816. &bfin_spi0_device,
  817. #endif
  818. #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
  819. &bfin_lq035q1_device,
  820. #endif
  821. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  822. #ifdef CONFIG_SERIAL_BFIN_UART0
  823. &bfin_uart0_device,
  824. #endif
  825. #ifdef CONFIG_SERIAL_BFIN_UART1
  826. &bfin_uart1_device,
  827. #endif
  828. #endif
  829. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  830. #ifdef CONFIG_BFIN_SIR0
  831. &bfin_sir0_device,
  832. #endif
  833. #ifdef CONFIG_BFIN_SIR1
  834. &bfin_sir1_device,
  835. #endif
  836. #endif
  837. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  838. &i2c_bfin_twi_device,
  839. #endif
  840. #if defined(CONFIG_SERIAL_BFIN_SPORT) \
  841. || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  842. #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
  843. &bfin_sport0_uart_device,
  844. #endif
  845. #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
  846. &bfin_sport1_uart_device,
  847. #endif
  848. #endif
  849. #if defined(CONFIG_MTD_GPIO_ADDR) || defined(CONFIG_MTD_GPIO_ADDR_MODULE)
  850. &tll6527m_flash_device,
  851. #endif
  852. #if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)
  853. &bfin_i2s,
  854. #endif
  855. #if defined(CONFIG_GPIO_DECODER) || defined(CONFIG_GPIO_DECODER_MODULE)
  856. &spi_decoded_gpio,
  857. #endif
  858. };
  859. static int __init tll6527m_init(void)
  860. {
  861. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  862. i2c_register_board_info(0, bfin_i2c_board_info,
  863. ARRAY_SIZE(bfin_i2c_board_info));
  864. platform_add_devices(tll6527m_devices, ARRAY_SIZE(tll6527m_devices));
  865. spi_register_board_info(bfin_spi_board_info,
  866. ARRAY_SIZE(bfin_spi_board_info));
  867. return 0;
  868. }
  869. arch_initcall(tll6527m_init);
  870. static struct platform_device *tll6527m_early_devices[] __initdata = {
  871. #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
  872. #ifdef CONFIG_SERIAL_BFIN_UART0
  873. &bfin_uart0_device,
  874. #endif
  875. #ifdef CONFIG_SERIAL_BFIN_UART1
  876. &bfin_uart1_device,
  877. #endif
  878. #endif
  879. #if defined(CONFIG_SERIAL_BFIN_SPORT_CONSOLE)
  880. #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
  881. &bfin_sport0_uart_device,
  882. #endif
  883. #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
  884. &bfin_sport1_uart_device,
  885. #endif
  886. #endif
  887. };
  888. void __init native_machine_early_platform_add_devices(void)
  889. {
  890. printk(KERN_INFO "register early platform devices\n");
  891. early_platform_add_devices(tll6527m_early_devices,
  892. ARRAY_SIZE(tll6527m_early_devices));
  893. }
  894. void native_machine_restart(char *cmd)
  895. {
  896. /* workaround reboot hang when booting from SPI */
  897. if ((bfin_read_SYSCR() & 0x7) == 0x3)
  898. bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS);
  899. }
  900. void bfin_get_ether_addr(char *addr)
  901. {
  902. /* the MAC is stored in OTP memory page 0xDF */
  903. u32 ret;
  904. u64 otp_mac;
  905. u32 (*otp_read)(u32 page, u32 flags,
  906. u64 *page_content) = (void *)0xEF00001A;
  907. ret = otp_read(0xDF, 0x00, &otp_mac);
  908. if (!(ret & 0x1)) {
  909. char *otp_mac_p = (char *)&otp_mac;
  910. for (ret = 0; ret < 6; ++ret)
  911. addr[ret] = otp_mac_p[5 - ret];
  912. }
  913. }
  914. EXPORT_SYMBOL(bfin_get_ether_addr);