board-neuros-osd2.c 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. /*
  2. * Neuros Technologies OSD2 board support
  3. *
  4. * Modified from original 644X-EVM board support.
  5. * 2008 (c) Neuros Technology, LLC.
  6. * 2009 (c) Jorge Luis Zapata Muga <jorgeluis.zapata@gmail.com>
  7. * 2009 (c) Andrey A. Porodko <Andrey.Porodko@gmail.com>
  8. *
  9. * The Neuros OSD 2.0 is the hardware component of the Neuros Open
  10. * Internet Television Platform. Hardware is very close to TI
  11. * DM644X-EVM board. It has:
  12. * DM6446M02 module with 256MB NAND, 256MB RAM, TLV320AIC32 AIC,
  13. * USB, Ethernet, SD/MMC, UART, THS8200, TVP7000 for video.
  14. * Additionaly realtime clock, IR remote control receiver,
  15. * IR Blaster based on MSP430 (firmware although is different
  16. * from used in DM644X-EVM), internal ATA-6 3.5” HDD drive
  17. * with PATA interface, two muxed red-green leds.
  18. *
  19. * For more information please refer to
  20. * http://wiki.neurostechnology.com/index.php/OSD_2.0_HD
  21. *
  22. * This file is licensed under the terms of the GNU General Public
  23. * License version 2. This program is licensed "as is" without any
  24. * warranty of any kind, whether express or implied.
  25. */
  26. #include <linux/platform_device.h>
  27. #include <linux/gpio.h>
  28. #include <linux/mtd/partitions.h>
  29. #include <asm/mach-types.h>
  30. #include <asm/mach/arch.h>
  31. #include <mach/dm644x.h>
  32. #include <mach/i2c.h>
  33. #include <mach/serial.h>
  34. #include <mach/mux.h>
  35. #include <mach/nand.h>
  36. #include <mach/mmc.h>
  37. #include <mach/usb.h>
  38. #define NEUROS_OSD2_PHY_MASK 0x2
  39. #define NEUROS_OSD2_MDIO_FREQUENCY 2200000 /* PHY bus frequency */
  40. #define DAVINCI_CFC_ATA_BASE 0x01C66000
  41. #define DAVINCI_ASYNC_EMIF_CONTROL_BASE 0x01e00000
  42. #define DAVINCI_ASYNC_EMIF_DATA_CE0_BASE 0x02000000
  43. #define LXT971_PHY_ID 0x001378e2
  44. #define LXT971_PHY_MASK 0xfffffff0
  45. #define NTOSD2_AUDIOSOC_I2C_ADDR 0x18
  46. #define NTOSD2_MSP430_I2C_ADDR 0x59
  47. #define NTOSD2_MSP430_IRQ 2
  48. /* Neuros OSD2 has a Samsung 256 MByte NAND flash (Dev ID of 0xAA,
  49. * 2048 blocks in the device, 64 pages per block, 2048 bytes per
  50. * page.
  51. */
  52. #define NAND_BLOCK_SIZE SZ_128K
  53. struct mtd_partition davinci_ntosd2_nandflash_partition[] = {
  54. {
  55. /* UBL (a few copies) plus U-Boot */
  56. .name = "bootloader",
  57. .offset = 0,
  58. .size = 15 * NAND_BLOCK_SIZE,
  59. .mask_flags = MTD_WRITEABLE, /* force read-only */
  60. }, {
  61. /* U-Boot environment */
  62. .name = "params",
  63. .offset = MTDPART_OFS_APPEND,
  64. .size = 1 * NAND_BLOCK_SIZE,
  65. .mask_flags = 0,
  66. }, {
  67. /* Kernel */
  68. .name = "kernel",
  69. .offset = MTDPART_OFS_APPEND,
  70. .size = SZ_4M,
  71. .mask_flags = 0,
  72. }, {
  73. /* File System */
  74. .name = "filesystem",
  75. .offset = MTDPART_OFS_APPEND,
  76. .size = MTDPART_SIZ_FULL,
  77. .mask_flags = 0,
  78. }
  79. /* A few blocks at end hold a flash Bad Block Table. */
  80. };
  81. static struct davinci_nand_pdata davinci_ntosd2_nandflash_data = {
  82. .parts = davinci_ntosd2_nandflash_partition,
  83. .nr_parts = ARRAY_SIZE(davinci_ntosd2_nandflash_partition),
  84. .ecc_mode = NAND_ECC_HW,
  85. .options = NAND_USE_FLASH_BBT,
  86. };
  87. static struct resource davinci_ntosd2_nandflash_resource[] = {
  88. {
  89. .start = DAVINCI_ASYNC_EMIF_DATA_CE0_BASE,
  90. .end = DAVINCI_ASYNC_EMIF_DATA_CE0_BASE + SZ_16M - 1,
  91. .flags = IORESOURCE_MEM,
  92. }, {
  93. .start = DAVINCI_ASYNC_EMIF_CONTROL_BASE,
  94. .end = DAVINCI_ASYNC_EMIF_CONTROL_BASE + SZ_4K - 1,
  95. .flags = IORESOURCE_MEM,
  96. },
  97. };
  98. static struct platform_device davinci_ntosd2_nandflash_device = {
  99. .name = "davinci_nand",
  100. .id = 0,
  101. .dev = {
  102. .platform_data = &davinci_ntosd2_nandflash_data,
  103. },
  104. .num_resources = ARRAY_SIZE(davinci_ntosd2_nandflash_resource),
  105. .resource = davinci_ntosd2_nandflash_resource,
  106. };
  107. static u64 davinci_fb_dma_mask = DMA_BIT_MASK(32);
  108. static struct platform_device davinci_fb_device = {
  109. .name = "davincifb",
  110. .id = -1,
  111. .dev = {
  112. .dma_mask = &davinci_fb_dma_mask,
  113. .coherent_dma_mask = DMA_BIT_MASK(32),
  114. },
  115. .num_resources = 0,
  116. };
  117. static struct resource ide_resources[] = {
  118. {
  119. .start = DAVINCI_CFC_ATA_BASE,
  120. .end = DAVINCI_CFC_ATA_BASE + 0x7ff,
  121. .flags = IORESOURCE_MEM,
  122. },
  123. {
  124. .start = IRQ_IDE,
  125. .end = IRQ_IDE,
  126. .flags = IORESOURCE_IRQ,
  127. },
  128. };
  129. static u64 ide_dma_mask = DMA_BIT_MASK(32);
  130. static struct platform_device ide_dev = {
  131. .name = "palm_bk3710",
  132. .id = -1,
  133. .resource = ide_resources,
  134. .num_resources = ARRAY_SIZE(ide_resources),
  135. .dev = {
  136. .dma_mask = &ide_dma_mask,
  137. .coherent_dma_mask = DMA_BIT_MASK(32),
  138. },
  139. };
  140. static struct snd_platform_data dm644x_ntosd2_snd_data;
  141. static struct gpio_led ntosd2_leds[] = {
  142. { .name = "led1_green", .gpio = GPIO(10), },
  143. { .name = "led1_red", .gpio = GPIO(11), },
  144. { .name = "led2_green", .gpio = GPIO(12), },
  145. { .name = "led2_red", .gpio = GPIO(13), },
  146. };
  147. static struct gpio_led_platform_data ntosd2_leds_data = {
  148. .num_leds = ARRAY_SIZE(ntosd2_leds),
  149. .leds = ntosd2_leds,
  150. };
  151. static struct platform_device ntosd2_leds_dev = {
  152. .name = "leds-gpio",
  153. .id = -1,
  154. .dev = {
  155. .platform_data = &ntosd2_leds_data,
  156. },
  157. };
  158. static struct platform_device *davinci_ntosd2_devices[] __initdata = {
  159. &davinci_fb_device,
  160. &ntosd2_leds_dev,
  161. };
  162. static struct davinci_uart_config uart_config __initdata = {
  163. .enabled_uarts = (1 << 0),
  164. };
  165. static void __init davinci_ntosd2_map_io(void)
  166. {
  167. dm644x_init();
  168. }
  169. /*
  170. I2C initialization
  171. */
  172. static struct davinci_i2c_platform_data ntosd2_i2c_pdata = {
  173. .bus_freq = 20 /* kHz */,
  174. .bus_delay = 100 /* usec */,
  175. };
  176. static struct i2c_board_info __initdata ntosd2_i2c_info[] = {
  177. };
  178. static int ntosd2_init_i2c(void)
  179. {
  180. int status;
  181. davinci_init_i2c(&ntosd2_i2c_pdata);
  182. status = gpio_request(NTOSD2_MSP430_IRQ, ntosd2_i2c_info[0].type);
  183. if (status == 0) {
  184. status = gpio_direction_input(NTOSD2_MSP430_IRQ);
  185. if (status == 0) {
  186. status = gpio_to_irq(NTOSD2_MSP430_IRQ);
  187. if (status > 0) {
  188. ntosd2_i2c_info[0].irq = status;
  189. i2c_register_board_info(1,
  190. ntosd2_i2c_info,
  191. ARRAY_SIZE(ntosd2_i2c_info));
  192. }
  193. }
  194. }
  195. return status;
  196. }
  197. static struct davinci_mmc_config davinci_ntosd2_mmc_config = {
  198. .wires = 4,
  199. .version = MMC_CTLR_VERSION_1
  200. };
  201. #if defined(CONFIG_BLK_DEV_PALMCHIP_BK3710) || \
  202. defined(CONFIG_BLK_DEV_PALMCHIP_BK3710_MODULE)
  203. #define HAS_ATA 1
  204. #else
  205. #define HAS_ATA 0
  206. #endif
  207. #if defined(CONFIG_MTD_NAND_DAVINCI) || \
  208. defined(CONFIG_MTD_NAND_DAVINCI_MODULE)
  209. #define HAS_NAND 1
  210. #else
  211. #define HAS_NAND 0
  212. #endif
  213. static __init void davinci_ntosd2_init(void)
  214. {
  215. struct clk *aemif_clk;
  216. struct davinci_soc_info *soc_info = &davinci_soc_info;
  217. int status;
  218. aemif_clk = clk_get(NULL, "aemif");
  219. clk_enable(aemif_clk);
  220. if (HAS_ATA) {
  221. if (HAS_NAND)
  222. pr_warning("WARNING: both IDE and Flash are "
  223. "enabled, but they share AEMIF pins.\n"
  224. "\tDisable IDE for NAND/NOR support.\n");
  225. davinci_cfg_reg(DM644X_HPIEN_DISABLE);
  226. davinci_cfg_reg(DM644X_ATAEN);
  227. davinci_cfg_reg(DM644X_HDIREN);
  228. platform_device_register(&ide_dev);
  229. } else if (HAS_NAND) {
  230. davinci_cfg_reg(DM644X_HPIEN_DISABLE);
  231. davinci_cfg_reg(DM644X_ATAEN_DISABLE);
  232. /* only one device will be jumpered and detected */
  233. if (HAS_NAND)
  234. platform_device_register(
  235. &davinci_ntosd2_nandflash_device);
  236. }
  237. platform_add_devices(davinci_ntosd2_devices,
  238. ARRAY_SIZE(davinci_ntosd2_devices));
  239. /* Initialize I2C interface specific for this board */
  240. status = ntosd2_init_i2c();
  241. if (status < 0)
  242. pr_warning("davinci_ntosd2_init: msp430 irq setup failed:"
  243. " %d\n", status);
  244. davinci_serial_init(&uart_config);
  245. dm644x_init_asp(&dm644x_ntosd2_snd_data);
  246. soc_info->emac_pdata->phy_mask = NEUROS_OSD2_PHY_MASK;
  247. soc_info->emac_pdata->mdio_max_freq = NEUROS_OSD2_MDIO_FREQUENCY;
  248. davinci_setup_usb(1000, 8);
  249. /*
  250. * Mux the pins to be GPIOs, VLYNQEN is already done at startup.
  251. * The AEAWx are five new AEAW pins that can be muxed by separately.
  252. * They are a bitmask for GPIO management. According TI
  253. * documentation (http://www.ti.com/lit/gpn/tms320dm6446) to employ
  254. * gpio(10,11,12,13) for leds any combination of bits works except
  255. * four last. So we are to reset all five.
  256. */
  257. davinci_cfg_reg(DM644X_AEAW0);
  258. davinci_cfg_reg(DM644X_AEAW1);
  259. davinci_cfg_reg(DM644X_AEAW2);
  260. davinci_cfg_reg(DM644X_AEAW3);
  261. davinci_cfg_reg(DM644X_AEAW4);
  262. davinci_setup_mmc(0, &davinci_ntosd2_mmc_config);
  263. }
  264. static __init void davinci_ntosd2_irq_init(void)
  265. {
  266. davinci_irq_init();
  267. }
  268. MACHINE_START(NEUROS_OSD2, "Neuros OSD2")
  269. /* Maintainer: Neuros Technologies <neuros@groups.google.com> */
  270. .phys_io = IO_PHYS,
  271. .io_pg_offst = (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc,
  272. .boot_params = (DAVINCI_DDR_BASE + 0x100),
  273. .map_io = davinci_ntosd2_map_io,
  274. .init_irq = davinci_ntosd2_irq_init,
  275. .timer = &davinci_timer,
  276. .init_machine = davinci_ntosd2_init,
  277. MACHINE_END