board-m3skt.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. /*
  2. *
  3. * arch/arm/mach-meson/meson.c
  4. *
  5. * Copyright (C) 2010 AMLOGIC, INC.
  6. *
  7. * License terms: GNU General Public License (GPL) version 2
  8. * Platform machine definition.
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/init.h>
  12. #include <linux/mm.h>
  13. #include <linux/sched.h>
  14. #include <linux/interrupt.h>
  15. #include <linux/ioport.h>
  16. #include <linux/platform_device.h>
  17. #include <linux/io.h>
  18. #include <linux/dma-mapping.h>
  19. #include <linux/mtd/mtd.h>
  20. #include <linux/mtd/nand.h>
  21. #include <linux/mtd/nand_ecc.h>
  22. #include <linux/mtd/partitions.h>
  23. #include <linux/device.h>
  24. #include <linux/spi/flash.h>
  25. #include <linux/i2c.h>
  26. #include <linux/delay.h>
  27. #include <linux/clk.h>
  28. #include <asm/mach-types.h>
  29. #include <asm/mach/arch.h>
  30. #include <asm/setup.h>
  31. #include <asm/memory.h>
  32. #include <asm/mach/map.h>
  33. #include <plat/platform_data.h>
  34. #include <plat/platform.h>
  35. #include <plat/plat_dev.h>
  36. #include <plat/lm.h>
  37. #include <mach/am_regs.h>
  38. #include <mach/i2c_aml.h>
  39. #include <mach/usbclock.h>
  40. #include "board-m3ref.h"
  41. #include <mach/map.h>
  42. #ifdef CONFIG_CACHE_L2X0
  43. #include <asm/hardware/cache-l2x0.h>
  44. #endif
  45. //#ifdef CONFIG_AM_UART
  46. #include <linux/uart-aml.h>
  47. //#endif
  48. #include <mach/pinmux.h>
  49. #include <mach/gpio.h>
  50. #ifdef CONFIG_USB_DWC_OTG_HCD
  51. #define USB_CONTROLLER_ENABLE
  52. #endif
  53. #include "board-m3skt-pinmux.h"
  54. #if 0
  55. static pinmux_item_t (*cur_board_pinmux)[MAX_DEVICE_NUMBER][MAX_PIN_ITEM_NUM];
  56. static struct aml_uart_platform __initdata aml_uart_plat = {
  57. .uart_line[0] = UART_AO,
  58. .uart_line[1] = UART_A,
  59. .uart_line[2] = UART_B,
  60. .uart_line[3] = UART_C,
  61. };
  62. #endif
  63. //#endif
  64. static struct aml_i2c_platform_a __initdata aml_i2c_data_a={
  65. .udelay = 8,
  66. .timeout =10 ,
  67. .resource ={
  68. .start = MESON_I2C_1_START,
  69. .end = MESON_I2C_1_END,
  70. .flags = IORESOURCE_MEM,
  71. }
  72. } ;
  73. static struct aml_i2c_platform_b __initdata aml_i2c_data_b={
  74. .freq= 3,
  75. .wait=7,
  76. .resource ={
  77. .start = MESON_I2C_2_START,
  78. .end = MESON_I2C_2_END,
  79. .flags = IORESOURCE_MEM,
  80. }
  81. };
  82. #ifdef USB_CONTROLLER_ENABLE
  83. static void set_usb_a_vbus_power(char is_power_on)
  84. {
  85. #if 0
  86. #define USB_A_POW_GPIO PREG_EGPIO
  87. #define USB_A_POW_GPIO_BIT 3
  88. #define USB_A_POW_GPIO_BIT_ON 1
  89. #define USB_A_POW_GPIO_BIT_OFF 0
  90. if(is_power_on){
  91. printk(KERN_INFO "set usb port power on (board gpio %d)!\n",USB_A_POW_GPIO_BIT);
  92. set_gpio_mode(USB_A_POW_GPIO,USB_A_POW_GPIO_BIT,GPIO_OUTPUT_MODE);
  93. set_gpio_val(USB_A_POW_GPIO,USB_A_POW_GPIO_BIT,USB_A_POW_GPIO_BIT_ON);
  94. }
  95. else {
  96. printk(KERN_INFO "set usb port power off (board gpio %d)!\n",USB_A_POW_GPIO_BIT);
  97. set_gpio_mode(USB_A_POW_GPIO,USB_A_POW_GPIO_BIT,GPIO_OUTPUT_MODE);
  98. set_gpio_val(USB_A_POW_GPIO,USB_A_POW_GPIO_BIT,USB_A_POW_GPIO_BIT_OFF);
  99. }
  100. #endif
  101. }
  102. //usb_a is OTG port
  103. static struct lm_device usb_ld_a = {
  104. .type = LM_DEVICE_TYPE_USB,
  105. .id = 0,
  106. .irq = INT_USB_A,
  107. .resource.start = IO_USB_A_BASE,
  108. .resource.end = SZ_256K,
  109. .dma_mask_room = DMA_BIT_MASK(32),
  110. .clock.sel = USB_PHY_CLK_SEL_XTAL_DIV_2,
  111. .clock.div = 0,
  112. .clock.src = 24000000,
  113. .param.usb.port_type = USB_PORT_TYPE_OTG,
  114. .param.usb.port_speed = USB_PORT_SPEED_DEFAULT,
  115. .param.usb.dma_config = USB_DMA_BURST_DEFAULT,
  116. .param.usb.set_vbus_power = set_usb_a_vbus_power,
  117. };
  118. static struct resource meson_fb_resource[] = {
  119. [0] = {
  120. .start = OSD1_ADDR_START,
  121. .end = OSD1_ADDR_END,
  122. .flags = IORESOURCE_MEM,
  123. },
  124. [1] = {
  125. .start = OSD2_ADDR_START,
  126. .end = OSD2_ADDR_END,
  127. .flags = IORESOURCE_MEM,
  128. },
  129. };
  130. static struct resource meson_codec_resource[] = {
  131. [0] = {
  132. .start = CODEC_ADDR_START,
  133. .end = CODEC_ADDR_END,
  134. .flags = IORESOURCE_MEM,
  135. },
  136. [1] = {
  137. .start = STREAMBUF_ADDR_START,
  138. .end = STREAMBUF_ADDR_END,
  139. .flags = IORESOURCE_MEM,
  140. },
  141. };
  142. //usb_b is HOST only port
  143. static struct lm_device usb_ld_b = {
  144. .type = LM_DEVICE_TYPE_USB,
  145. .id = 1,
  146. .irq = INT_USB_B,
  147. .resource.start = IO_USB_B_BASE,
  148. .resource.end = -1,
  149. .resource.end = SZ_256K,
  150. .dma_mask_room = DMA_BIT_MASK(32),
  151. .clock.sel = USB_PHY_CLK_SEL_XTAL_DIV_2,
  152. .clock.div = 0,
  153. .clock.src = 24000000,
  154. .param.usb.port_type = USB_PORT_TYPE_HOST,
  155. .param.usb.port_speed = USB_PORT_SPEED_DEFAULT,
  156. .param.usb.dma_config = USB_DMA_BURST_DEFAULT,
  157. .param.usb.set_vbus_power = 0,
  158. };
  159. #endif
  160. static struct platform_device *platform_devs[] = {
  161. /// &meson_device_uart,
  162. &meson_device_fb,
  163. };
  164. static int __init setup_devices_resource(void)
  165. {
  166. setup_fb_resource(meson_fb_resource, ARRAY_SIZE(meson_fb_resource));
  167. setup_codec_resource(meson_codec_resource,ARRAY_SIZE(meson_codec_resource));
  168. return 0;
  169. }
  170. static int __init setup_i2c_devices(void)
  171. {
  172. //just a sample
  173. meson_i2c1_set_platdata(&aml_i2c_data_a,sizeof(struct aml_i2c_platform_a ));
  174. meson_i2c2_set_platdata(&aml_i2c_data_b,sizeof(struct aml_i2c_platform_b ));
  175. return 0;
  176. }
  177. static int __init setup_uart_devices(void)
  178. {
  179. #if 0
  180. static pinmux_set_t temp;
  181. //#if defined(CONFIG_AM_UART)
  182. aml_uart_plat.public.pinmux_cfg.setup=NULL; //NULL repsent use defaut pinmux_set.
  183. aml_uart_plat.public.pinmux_cfg.clear=NULL;
  184. aml_uart_plat.public.clk_src=clk_get_sys("clk81", NULL);
  185. temp.pinmux=cur_board_pinmux[DEVICE_PIN_ITEM_UART];
  186. aml_uart_plat.public.pinmux_set.pinmux=cur_board_pinmux[DEVICE_PIN_ITEM_UART];
  187. aml_uart_plat.pinmux_uart[0]=&temp;
  188. meson_uart_set_platdata(&aml_uart_plat,sizeof(struct aml_uart_platform));
  189. #endif
  190. return 0;
  191. //#endif
  192. }
  193. static void __init device_pinmux_init(void)
  194. {
  195. #if 0 ///@todo Jerry Yu, Compile break , enable it later
  196. clearall_pinmux();
  197. /*other deivce power on*/
  198. uart_set_pinmux(UART_PORT_AO, UART_AO_GPIO_AO0_AO1_STD);
  199. /*pinmux of eth*/
  200. eth_pinmux_init();
  201. set_audio_pinmux(AUDIO_IN_JTAG); // for MIC input
  202. set_audio_pinmux(AUDIO_OUT_TEST_N); //External AUDIO DAC
  203. set_audio_pinmux(SPDIF_OUT_GPIOA); //SPDIF GPIOA_6
  204. #endif
  205. }
  206. static void __init device_clk_setting(void)
  207. {
  208. #if 0 ///@todo Jerry Yu, Compile break , enable it later
  209. /*Configurate the ethernet clock*/
  210. eth_clk_set(ETH_CLKSRC_MISC_CLK, get_misc_pll_clk(), (50 * CLK_1M), 0);
  211. #endif
  212. }
  213. static void disable_unused_model(void)
  214. {
  215. #if 0 ///@todo Jerry Yu, Compile break , enable it later
  216. CLK_GATE_OFF(VIDEO_IN);
  217. CLK_GATE_OFF(BT656_IN);
  218. #endif
  219. }
  220. static void __init meson_cache_init(void)
  221. {
  222. #ifdef CONFIG_CACHE_L2X0
  223. /*
  224. * Early BRESP, I/D prefetch enabled
  225. * Non-secure enabled
  226. * 128kb (16KB/way),
  227. * 8-way associativity,
  228. * evmon/parity/share disabled
  229. * Full Line of Zero enabled
  230. * Bits: .111 .... .100 0010 0000 .... .... ...1
  231. */
  232. l2x0_init((void __iomem *)IO_PL310_BASE, 0x7c420001, 0xff800fff);
  233. #endif
  234. }
  235. static void __init backup_board_pinmux(void)
  236. {//devices_pins in __initdata section ,it will be released .
  237. #if 0
  238. cur_board_pinmux=kmemdup(devices_pins, sizeof(devices_pins), GFP_KERNEL);
  239. printk(KERN_INFO " cur_board_pinmux=%p",cur_board_pinmux[0]);
  240. printk(KERN_INFO " cur_board_pinmux=%p",&(cur_board_pinmux[0]));
  241. printk(KERN_INFO " cur_board_pinmux=%x",cur_board_pinmux[0][0]);
  242. printk(KERN_INFO " cur_board_pinmux=%x",cur_board_pinmux[0][0]->reg);
  243. #endif
  244. }
  245. static pinmux_item_t __initdata uart_pins[]={
  246. {
  247. .reg=PINMUX_REG(AO),
  248. .clrmask=3<<16,
  249. .setmask=3<<11
  250. },
  251. PINMUX_END_ITEM
  252. };
  253. static pinmux_set_t __initdata aml_uart_ao={
  254. .chip_select=NULL,
  255. .pinmux=&uart_pins[0]
  256. };
  257. static struct aml_uart_platform __initdata aml_uart_plat = {
  258. .uart_line[0] = UART_AO,
  259. .uart_line[1] = UART_A,
  260. .uart_line[2] = UART_B,
  261. .uart_line[3] = UART_C,
  262. .pinmux_uart[0] = (void*)&aml_uart_ao,
  263. .pinmux_uart[1] = NULL,
  264. .pinmux_uart[2] = NULL,
  265. .pinmux_uart[3] = NULL,
  266. };
  267. static struct platform_device aml_uart_device = {
  268. .name = "mesonuart",
  269. .id = -1,
  270. .num_resources = 0,
  271. .resource = NULL,
  272. .dev = {
  273. .platform_data = &aml_uart_plat,
  274. },
  275. };
  276. static __init void meson_init_machine(void)
  277. {
  278. backup_board_pinmux();
  279. meson_cache_init();
  280. setup_devices_resource();
  281. ///setup_i2c_devices();
  282. ///setup_uart_devices();
  283. device_clk_setting();
  284. device_pinmux_init();
  285. platform_device_register(&aml_uart_device);
  286. /// platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs));
  287. #ifdef USB_CONTROLLER_ENABLE
  288. lm_device_register(&usb_ld_a);
  289. lm_device_register(&usb_ld_b);
  290. #endif
  291. #if defined(CONFIG_TOUCHSCREEN_ADS7846)
  292. ads7846_init_gpio();
  293. spi_register_board_info(spi_board_info_list, ARRAY_SIZE(spi_board_info_list));
  294. #endif
  295. disable_unused_model();
  296. }
  297. /***********************************************************************
  298. * IO Mapping
  299. **********************************************************************/
  300. static __initdata struct map_desc meson_io_desc[] = {
  301. {
  302. .virtual = IO_CBUS_BASE,
  303. .pfn = __phys_to_pfn(IO_CBUS_PHY_BASE),
  304. .length = SZ_2M,
  305. .type = MT_DEVICE,
  306. } , {
  307. .virtual = IO_AXI_BUS_BASE,
  308. .pfn = __phys_to_pfn(IO_AXI_BUS_PHY_BASE),
  309. .length = SZ_1M,
  310. .type = MT_DEVICE,
  311. } , {
  312. .virtual = IO_PL310_BASE,
  313. .pfn = __phys_to_pfn(IO_PL310_PHY_BASE),
  314. .length = SZ_4K,
  315. .type = MT_DEVICE,
  316. } , {
  317. .virtual = IO_PERIPH_BASE,
  318. .pfn = __phys_to_pfn(IO_PERIPH_PHY_BASE),
  319. .length = SZ_4K,
  320. .type = MT_DEVICE,
  321. } , {
  322. .virtual = IO_APB_BUS_BASE,
  323. .pfn = __phys_to_pfn(IO_APB_BUS_PHY_BASE),
  324. .length = SZ_512K,
  325. .type = MT_DEVICE,
  326. } , {
  327. .virtual = IO_AOBUS_BASE,
  328. .pfn = __phys_to_pfn(IO_AOBUS_PHY_BASE),
  329. .length = SZ_1M,
  330. .type = MT_DEVICE,
  331. } , {
  332. .virtual = IO_AHB_BUS_BASE,
  333. .pfn = __phys_to_pfn(IO_AHB_BUS_PHY_BASE),
  334. .length = SZ_16M,
  335. .type = MT_DEVICE,
  336. } , {
  337. .virtual = IO_APB2_BUS_BASE,
  338. .pfn = __phys_to_pfn(IO_APB2_BUS_PHY_BASE),
  339. .length = SZ_512K,
  340. .type = MT_DEVICE,
  341. }, {
  342. .virtual = PAGE_ALIGN(__phys_to_virt(RESERVED_MEM_START)),
  343. .pfn = __phys_to_pfn(RESERVED_MEM_START),
  344. .length = RESERVED_MEM_END - RESERVED_MEM_START + 1,
  345. .type = MT_DEVICE,
  346. },
  347. #ifdef CONFIG_MESON_SUSPEND
  348. {
  349. .virtual = PAGE_ALIGN(0xdff00000),
  350. .pfn = __phys_to_pfn(0x1ff00000),
  351. .length = SZ_1M,
  352. .type = MT_MEMORY,
  353. },
  354. #endif
  355. };
  356. static void __init meson_map_io(void)
  357. {
  358. iotable_init(meson_io_desc, ARRAY_SIZE(meson_io_desc));
  359. }
  360. static __init void m3_irq_init(void)
  361. {
  362. meson_init_irq();
  363. }
  364. static __init void m3_fixup(struct machine_desc *mach, struct tag *tag, char **cmdline, struct meminfo *m)
  365. {
  366. /**
  367. * @todo Jerry Yu , Compile break, Enable it later
  368. */
  369. struct membank *pbank;
  370. m->nr_banks = 0;
  371. pbank = &m->bank[m->nr_banks];
  372. pbank->start = PAGE_ALIGN(PHYS_MEM_START);
  373. pbank->size = SZ_64M & PAGE_MASK;
  374. ///pbank->node = PHYS_TO_NID(PHYS_MEM_START);
  375. m->nr_banks++;
  376. pbank = &m->bank[m->nr_banks];
  377. pbank->start = PAGE_ALIGN(RESERVED_MEM_END + 1);
  378. pbank->size = (PHYS_MEM_END - RESERVED_MEM_END) & PAGE_MASK;
  379. /// pbank->node = PHYS_TO_NID(RESERVED_MEM_END + 1);
  380. m->nr_banks++;
  381. }
  382. MACHINE_START(M3_SKT, "Meson 3 socket board")
  383. .boot_params = BOOT_PARAMS_OFFSET,
  384. .map_io = meson_map_io,
  385. .init_irq = m3_irq_init,
  386. .timer = &meson_sys_timer,
  387. .init_machine = meson_init_machine,
  388. .fixup = m3_fixup,
  389. .video_start = RESERVED_MEM_START,
  390. .video_end = RESERVED_MEM_END,
  391. MACHINE_END