board-8726m-refc03.c 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. /*
  2. * arch/arm/mach-meson/board-8726m-dvbc.c
  3. *
  4. * Copyright (C) 2010 AMLOGIC, INC.
  5. *
  6. * License terms: GNU General Public License (GPL) version 2
  7. * Platform machine definition.
  8. */
  9. #include <linux/kernel.h>
  10. #include <linux/init.h>
  11. #include <linux/mm.h>
  12. #include <linux/sched.h>
  13. #include <linux/interrupt.h>
  14. #include <linux/ioport.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/io.h>
  17. #include <linux/dma-mapping.h>
  18. #include <linux/mtd/mtd.h>
  19. #include <linux/mtd/partitions.h>
  20. #include <linux/device.h>
  21. #include <linux/spi/flash.h>
  22. #include <linux/delay.h>
  23. #include <asm/mach-types.h>
  24. #include <asm/mach/arch.h>
  25. #include <asm/setup.h>
  26. #include <asm/memory.h>
  27. #include <asm/mach/map.h>
  28. #include <plat/platform.h>
  29. #include <plat/plat_dev.h>
  30. #include <plat/lm.h>
  31. #include <mach/power_gate.h>
  32. #include <mach/memory.h>
  33. #include <mach/hardware.h>
  34. #include <mach/clock.h>
  35. #include <mach/pinmux.h>
  36. #include <mach/clk_set.h>
  37. #include <mach/gpio.h>
  38. #ifdef CONFIG_AM_UART
  39. #include <linux/uart-aml.h>
  40. #endif
  41. #ifdef CONFIG_AM_ETHERNET
  42. #include <mach/am_regs.h>
  43. #include <mach/am_eth_reg.h>
  44. #include <mach/am_eth_pinmux.h>
  45. #endif
  46. #include "board-8726m-refc03.h"
  47. #ifdef CONFIG_AM_UART
  48. static pinmux_item_t uart_pins[] = {
  49. {
  50. .reg = PINMUX_REG(2),
  51. .clrmask = 0,
  52. .setmask = (1 << 11) | (1 << 15),
  53. },
  54. PINMUX_END_ITEM
  55. };
  56. static pinmux_set_t aml_uart_a = {
  57. .chip_select = NULL,
  58. .pinmux = &uart_pins[0],
  59. };
  60. static struct aml_uart_platform aml_uart_plat = {
  61. .uart_line[0] = UART_A,
  62. .uart_line[1] = UART_B,
  63. .pinmux_uart[0] = (void *)&aml_uart_a,
  64. .pinmux_uart[1] = NULL,
  65. };
  66. static struct platform_device aml_uart_device = {
  67. .name = "mesonuart",
  68. .id = -1,
  69. .num_resources = 0,
  70. .resource = NULL,
  71. .dev = {
  72. .platform_data = &aml_uart_plat,
  73. },
  74. };
  75. #endif
  76. #ifdef CONFIG_AM_ETHERNET
  77. static void aml_eth_reset(void)
  78. {
  79. #define DELAY_TIME 500
  80. int i;
  81. //eth_set_pinmux(ETH_BANK2_GPIOD15_D23, ETH_CLK_OUT_GPIOD24_REG5_1, 0);
  82. CLEAR_CBUS_REG_MASK(PREG_ETHERNET_ADDR0, 1);
  83. SET_CBUS_REG_MASK(PREG_ETHERNET_ADDR0, (1 << 1));
  84. SET_CBUS_REG_MASK(PREG_ETHERNET_ADDR0, 1);
  85. for (i = 0; i < DELAY_TIME; i++)
  86. udelay(100);
  87. /*reset*/
  88. ///GPIOC19/NA nRst;
  89. set_gpio_mode(PREG_GGPIO,12,GPIO_OUTPUT_MODE);
  90. set_gpio_val(PREG_GGPIO,12,0);
  91. udelay(100); //waiting reset end;
  92. set_gpio_val(PREG_GGPIO,12,1);
  93. udelay(10); //waiting reset end;
  94. }
  95. static void aml_eth_clock_enable(void)
  96. {
  97. printk(KERN_INFO "****** aml_eth_clock_enable() ******\n");
  98. eth_clk_set(ETH_CLKSRC_APLL_CLK, 400*CLK_1M, 50*CLK_1M);
  99. }
  100. static void aml_eth_clock_disable(void)
  101. {
  102. printk(KERN_INFO "****** aml_eth_clock_disable() ******\n");
  103. eth_clk_set(ETH_CLKSRC_APLL_CLK, 0, 0);
  104. }
  105. static pinmux_item_t aml_eth_pins[] = {
  106. /* RMII pin-mux */
  107. {
  108. .reg = PINMUX_REG(ETH_BANK2_REG1),
  109. .clrmask = 0,
  110. .setmask = ETH_BANK2_REG1_VAL,
  111. },
  112. /* RMII CLK50 in-out */
  113. {
  114. .reg = PINMUX_REG(5),
  115. .clrmask = 0,
  116. .setmask = 1 << 1,
  117. },
  118. PINMUX_END_ITEM
  119. };
  120. static struct aml_eth_platdata aml_eth_pdata __initdata = {
  121. .pinmux_items = aml_eth_pins,
  122. .clock_enable = aml_eth_clock_enable,
  123. .clock_disable = aml_eth_clock_disable,
  124. .reset = aml_eth_reset,
  125. };
  126. static void __init setup_eth_device(void)
  127. {
  128. meson_eth_set_platdata(&aml_eth_pdata);
  129. }
  130. #endif
  131. #ifdef CONFIG_AM_REMOTE
  132. static pinmux_item_t aml_remote_pins[] = {
  133. {
  134. .reg = PINMUX_REG(5),
  135. .clrmask = 0,
  136. .setmask = 1 << 31,
  137. },
  138. PINMUX_END_ITEM
  139. };
  140. static struct aml_remote_platdata aml_remote_pdata __initdata = {
  141. .pinmux_items = aml_remote_pins,
  142. .ao_baseaddr = P_IR_DEC_LDR_ACTIVE,
  143. };
  144. static void __init setup_remote_device(void)
  145. {
  146. meson_remote_set_platdata(&aml_remote_pdata);
  147. }
  148. #endif
  149. #ifdef CONFIG_FB_AM
  150. static struct resource meson_fb_resource[] = {
  151. [0] = {
  152. .start = OSD1_ADDR_START,
  153. .end = OSD1_ADDR_END,
  154. .flags = IORESOURCE_MEM,
  155. },
  156. [1] = {
  157. .start = OSD2_ADDR_START,
  158. .end = OSD2_ADDR_END,
  159. .flags = IORESOURCE_MEM,
  160. },
  161. };
  162. #endif
  163. #ifdef CONFIG_AM_STREAMING
  164. static struct resource meson_codec_resource[] = {
  165. [0] = {
  166. .start = CODEC_ADDR_START,
  167. .end = CODEC_ADDR_END,
  168. .flags = IORESOURCE_MEM,
  169. },
  170. [1] = {
  171. .start = STREAMBUF_ADDR_START,
  172. .end = STREAMBUF_ADDR_END,
  173. .flags = IORESOURCE_MEM,
  174. },
  175. };
  176. #endif
  177. static int __init setup_devices_resource(void)
  178. {
  179. #ifdef CONFIG_FB_AM
  180. setup_fb_resource(meson_fb_resource, ARRAY_SIZE(meson_fb_resource));
  181. #endif
  182. #ifdef CONFIG_AM_STREAMING
  183. setup_codec_resource(meson_codec_resource,ARRAY_SIZE(meson_codec_resource));
  184. #endif
  185. return 0;
  186. }
  187. static void __init device_clk_setting(void)
  188. {
  189. /*Demod CLK for eth and sata*/
  190. //demod_apll_setting(0, 1200*CLK_1M);
  191. /*eth clk*/
  192. //eth_clk_set(ETH_CLKSRC_SYS_D3,900*CLK_1M/3,50*CLK_1M);
  193. //eth_clk_set(ETH_CLKSRC_APLL_CLK, 400*CLK_1M, 50*CLK_1M);
  194. }
  195. static void disable_unused_model(void)
  196. {
  197. }
  198. static struct platform_device __initdata *platform_devs[] = {
  199. #ifdef CONFIG_AM_UART
  200. &aml_uart_device,
  201. #endif
  202. #ifdef CONFIG_AM_ETHERNET
  203. &meson_device_eth,
  204. #endif
  205. #ifdef CONFIG_AM_REMOTE
  206. &meson_device_remote,
  207. #endif
  208. #ifdef CONFIG_AM_TV_OUTPUT
  209. &meson_device_vout,
  210. #endif
  211. #ifdef CONFIG_FB_AM
  212. &meson_device_fb,
  213. #endif
  214. #ifdef CONFIG_AM_STREAMING
  215. &meson_device_codec,
  216. #endif
  217. };
  218. static __init void m1_init_machine(void)
  219. {
  220. device_clk_setting();
  221. #ifdef CONFIG_AM_ETHERNET
  222. setup_eth_device();
  223. #endif
  224. #ifdef CONFIG_AM_REMOTE
  225. setup_remote_device();
  226. #endif
  227. setup_devices_resource();
  228. platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs));
  229. disable_unused_model();
  230. }
  231. /***********************************************************************
  232. * IO Mapping
  233. **********************************************************************/
  234. static __initdata struct map_desc meson_io_desc[] = {
  235. {
  236. .virtual = IO_CBUS_BASE,
  237. .pfn = __phys_to_pfn(IO_CBUS_PHY_BASE),
  238. .length = SZ_2M,
  239. .type = MT_DEVICE,
  240. } , {
  241. .virtual = IO_AXI_BUS_BASE,
  242. .pfn = __phys_to_pfn(IO_AXI_BUS_PHY_BASE),
  243. .length = SZ_1M,
  244. .type = MT_DEVICE,
  245. } , {
  246. .virtual = IO_PL310_BASE,
  247. .pfn = __phys_to_pfn(IO_PL310_PHY_BASE),
  248. .length = SZ_4K,
  249. .type = MT_DEVICE,
  250. } , {
  251. .virtual = IO_AHB_BUS_BASE,
  252. .pfn = __phys_to_pfn(IO_AHB_BUS_PHY_BASE),
  253. .length = SZ_16M,
  254. .type = MT_DEVICE,
  255. } , {
  256. .virtual = IO_APB_BUS_BASE,
  257. .pfn = __phys_to_pfn(IO_APB_BUS_PHY_BASE),
  258. .length = SZ_512K,
  259. .type = MT_DEVICE,
  260. }
  261. };
  262. /*VIDEO MEMORY MAPING*/
  263. static __initdata struct map_desc meson_video_mem_desc[] = {
  264. {
  265. .virtual = PAGE_ALIGN(__phys_to_virt(RESERVED_MEM_START)),
  266. .pfn = __phys_to_pfn(RESERVED_MEM_START),
  267. .length = RESERVED_MEM_END-RESERVED_MEM_START+1,
  268. .type = MT_DEVICE,
  269. },
  270. };
  271. static __init void m1_map_io(void)
  272. {
  273. iotable_init(meson_io_desc, ARRAY_SIZE(meson_io_desc));
  274. iotable_init(meson_video_mem_desc, ARRAY_SIZE(meson_video_mem_desc));
  275. }
  276. static __init void m1_irq_init(void)
  277. {
  278. meson_init_irq();
  279. }
  280. static __init void m1_fixup(struct machine_desc *mach, struct tag *tag, char **cmdline, struct meminfo *m)
  281. {
  282. struct membank *pbank;
  283. m->nr_banks = 0;
  284. pbank=&m->bank[m->nr_banks];
  285. pbank->start = PAGE_ALIGN(PHYS_MEM_START);
  286. pbank->size = SZ_64M & PAGE_MASK;
  287. m->nr_banks++;
  288. pbank=&m->bank[m->nr_banks];
  289. pbank->start = PAGE_ALIGN(RESERVED_MEM_END+1);
  290. pbank->size = (PHYS_MEM_END-RESERVED_MEM_END) & PAGE_MASK;
  291. m->nr_banks++;
  292. }
  293. MACHINE_START(MESON, "AMLOGIC MESON-M1 8726M DVBC")
  294. .boot_params = BOOT_PARAMS_OFFSET,
  295. .map_io = m1_map_io,
  296. .init_irq = m1_irq_init,
  297. .timer = &meson_sys_timer,
  298. .init_machine = m1_init_machine,
  299. .fixup = m1_fixup,
  300. .video_start = RESERVED_MEM_START,
  301. .video_end = RESERVED_MEM_END,
  302. MACHINE_END