board-neuros-osd2.c 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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. * Additionally 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/leds.h>
  29. #include <linux/mtd/partitions.h>
  30. #include <linux/platform_data/gpio-davinci.h>
  31. #include <linux/platform_data/i2c-davinci.h>
  32. #include <linux/platform_data/mmc-davinci.h>
  33. #include <linux/platform_data/mtd-davinci.h>
  34. #include <linux/platform_data/usb-davinci.h>
  35. #include <asm/mach-types.h>
  36. #include <asm/mach/arch.h>
  37. #include <mach/common.h>
  38. #include <mach/serial.h>
  39. #include <mach/mux.h>
  40. #include "davinci.h"
  41. #define NEUROS_OSD2_PHY_ID "davinci_mdio-0:01"
  42. #define LXT971_PHY_ID 0x001378e2
  43. #define LXT971_PHY_MASK 0xfffffff0
  44. #define NTOSD2_AUDIOSOC_I2C_ADDR 0x18
  45. #define NTOSD2_MSP430_I2C_ADDR 0x59
  46. #define NTOSD2_MSP430_IRQ 2
  47. /* Neuros OSD2 has a Samsung 256 MByte NAND flash (Dev ID of 0xAA,
  48. * 2048 blocks in the device, 64 pages per block, 2048 bytes per
  49. * page.
  50. */
  51. #define NAND_BLOCK_SIZE SZ_128K
  52. static struct mtd_partition davinci_ntosd2_nandflash_partition[] = {
  53. {
  54. /* UBL (a few copies) plus U-Boot */
  55. .name = "bootloader",
  56. .offset = 0,
  57. .size = 15 * NAND_BLOCK_SIZE,
  58. .mask_flags = MTD_WRITEABLE, /* force read-only */
  59. }, {
  60. /* U-Boot environment */
  61. .name = "params",
  62. .offset = MTDPART_OFS_APPEND,
  63. .size = 1 * NAND_BLOCK_SIZE,
  64. .mask_flags = 0,
  65. }, {
  66. /* Kernel */
  67. .name = "kernel",
  68. .offset = MTDPART_OFS_APPEND,
  69. .size = SZ_4M,
  70. .mask_flags = 0,
  71. }, {
  72. /* File System */
  73. .name = "filesystem",
  74. .offset = MTDPART_OFS_APPEND,
  75. .size = MTDPART_SIZ_FULL,
  76. .mask_flags = 0,
  77. }
  78. /* A few blocks at end hold a flash Bad Block Table. */
  79. };
  80. static struct davinci_nand_pdata davinci_ntosd2_nandflash_data = {
  81. .core_chipsel = 0,
  82. .parts = davinci_ntosd2_nandflash_partition,
  83. .nr_parts = ARRAY_SIZE(davinci_ntosd2_nandflash_partition),
  84. .ecc_mode = NAND_ECC_HW,
  85. .ecc_bits = 1,
  86. .bbt_options = NAND_BBT_USE_FLASH,
  87. };
  88. static struct resource davinci_ntosd2_nandflash_resource[] = {
  89. {
  90. .start = DM644X_ASYNC_EMIF_DATA_CE0_BASE,
  91. .end = DM644X_ASYNC_EMIF_DATA_CE0_BASE + SZ_16M - 1,
  92. .flags = IORESOURCE_MEM,
  93. }, {
  94. .start = DM644X_ASYNC_EMIF_CONTROL_BASE,
  95. .end = DM644X_ASYNC_EMIF_CONTROL_BASE + SZ_4K - 1,
  96. .flags = IORESOURCE_MEM,
  97. },
  98. };
  99. static struct platform_device davinci_ntosd2_nandflash_device = {
  100. .name = "davinci_nand",
  101. .id = 0,
  102. .dev = {
  103. .platform_data = &davinci_ntosd2_nandflash_data,
  104. },
  105. .num_resources = ARRAY_SIZE(davinci_ntosd2_nandflash_resource),
  106. .resource = davinci_ntosd2_nandflash_resource,
  107. };
  108. static u64 davinci_fb_dma_mask = DMA_BIT_MASK(32);
  109. static struct platform_device davinci_fb_device = {
  110. .name = "davincifb",
  111. .id = -1,
  112. .dev = {
  113. .dma_mask = &davinci_fb_dma_mask,
  114. .coherent_dma_mask = DMA_BIT_MASK(32),
  115. },
  116. .num_resources = 0,
  117. };
  118. static const struct gpio_led ntosd2_leds[] = {
  119. { .name = "led1_green", .gpio = GPIO(10), },
  120. { .name = "led1_red", .gpio = GPIO(11), },
  121. { .name = "led2_green", .gpio = GPIO(12), },
  122. { .name = "led2_red", .gpio = GPIO(13), },
  123. };
  124. static struct gpio_led_platform_data ntosd2_leds_data = {
  125. .num_leds = ARRAY_SIZE(ntosd2_leds),
  126. .leds = ntosd2_leds,
  127. };
  128. static struct platform_device ntosd2_leds_dev = {
  129. .name = "leds-gpio",
  130. .id = -1,
  131. .dev = {
  132. .platform_data = &ntosd2_leds_data,
  133. },
  134. };
  135. static struct platform_device *davinci_ntosd2_devices[] __initdata = {
  136. &davinci_fb_device,
  137. &ntosd2_leds_dev,
  138. };
  139. static void __init davinci_ntosd2_map_io(void)
  140. {
  141. dm644x_init();
  142. }
  143. static struct davinci_mmc_config davinci_ntosd2_mmc_config = {
  144. .wires = 4,
  145. };
  146. #define HAS_ATA (IS_ENABLED(CONFIG_BLK_DEV_PALMCHIP_BK3710) || \
  147. IS_ENABLED(CONFIG_PATA_BK3710))
  148. #define HAS_NAND IS_ENABLED(CONFIG_MTD_NAND_DAVINCI)
  149. static __init void davinci_ntosd2_init(void)
  150. {
  151. int ret;
  152. struct clk *aemif_clk;
  153. struct davinci_soc_info *soc_info = &davinci_soc_info;
  154. dm644x_register_clocks();
  155. dm644x_init_devices();
  156. ret = dm644x_gpio_register();
  157. if (ret)
  158. pr_warn("%s: GPIO init failed: %d\n", __func__, ret);
  159. aemif_clk = clk_get(NULL, "aemif");
  160. clk_prepare_enable(aemif_clk);
  161. if (HAS_ATA) {
  162. if (HAS_NAND)
  163. pr_warn("WARNING: both IDE and Flash are enabled, but they share AEMIF pins\n"
  164. "\tDisable IDE for NAND/NOR support\n");
  165. davinci_init_ide();
  166. } else if (HAS_NAND) {
  167. davinci_cfg_reg(DM644X_HPIEN_DISABLE);
  168. davinci_cfg_reg(DM644X_ATAEN_DISABLE);
  169. /* only one device will be jumpered and detected */
  170. if (HAS_NAND)
  171. platform_device_register(
  172. &davinci_ntosd2_nandflash_device);
  173. }
  174. platform_add_devices(davinci_ntosd2_devices,
  175. ARRAY_SIZE(davinci_ntosd2_devices));
  176. davinci_serial_init(dm644x_serial_device);
  177. dm644x_init_asp();
  178. soc_info->emac_pdata->phy_id = NEUROS_OSD2_PHY_ID;
  179. davinci_setup_usb(1000, 8);
  180. /*
  181. * Mux the pins to be GPIOs, VLYNQEN is already done at startup.
  182. * The AEAWx are five new AEAW pins that can be muxed by separately.
  183. * They are a bitmask for GPIO management. According TI
  184. * documentation (http://www.ti.com/lit/gpn/tms320dm6446) to employ
  185. * gpio(10,11,12,13) for leds any combination of bits works except
  186. * four last. So we are to reset all five.
  187. */
  188. davinci_cfg_reg(DM644X_AEAW0);
  189. davinci_cfg_reg(DM644X_AEAW1);
  190. davinci_cfg_reg(DM644X_AEAW2);
  191. davinci_cfg_reg(DM644X_AEAW3);
  192. davinci_cfg_reg(DM644X_AEAW4);
  193. davinci_setup_mmc(0, &davinci_ntosd2_mmc_config);
  194. }
  195. MACHINE_START(NEUROS_OSD2, "Neuros OSD2")
  196. /* Maintainer: Neuros Technologies <neuros@groups.google.com> */
  197. .atag_offset = 0x100,
  198. .map_io = davinci_ntosd2_map_io,
  199. .init_irq = davinci_irq_init,
  200. .init_time = dm644x_init_time,
  201. .init_machine = davinci_ntosd2_init,
  202. .init_late = davinci_init_late,
  203. .dma_zone_size = SZ_128M,
  204. MACHINE_END