qi_lb60.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * Authors: Xiangfu Liu <xiangfu@sharism.cc>
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version
  7. * 3 of the License, or (at your option) any later version.
  8. */
  9. #include <common.h>
  10. #include <asm/io.h>
  11. #include <asm/jz4740.h>
  12. DECLARE_GLOBAL_DATA_PTR;
  13. static void gpio_init(void)
  14. {
  15. unsigned int i;
  16. /* Initialize NAND Flash Pins */
  17. __gpio_as_nand();
  18. /* Initialize SDRAM pins */
  19. __gpio_as_sdram_16bit_4720();
  20. /* Initialize LCD pins */
  21. __gpio_as_lcd_18bit();
  22. /* Initialize MSC pins */
  23. __gpio_as_msc();
  24. /* Initialize Other pins */
  25. for (i = 0; i < 7; i++) {
  26. __gpio_as_input(GPIO_KEYIN_BASE + i);
  27. __gpio_enable_pull(GPIO_KEYIN_BASE + i);
  28. }
  29. for (i = 0; i < 8; i++) {
  30. __gpio_as_output(GPIO_KEYOUT_BASE + i);
  31. __gpio_clear_pin(GPIO_KEYOUT_BASE + i);
  32. }
  33. __gpio_as_input(GPIO_KEYIN_8);
  34. __gpio_enable_pull(GPIO_KEYIN_8);
  35. /* enable the TP4, TP5 as UART0 */
  36. __gpio_jtag_to_uart0();
  37. __gpio_as_output(GPIO_AUDIO_POP);
  38. __gpio_set_pin(GPIO_AUDIO_POP);
  39. __gpio_as_output(GPIO_LCD_CS);
  40. __gpio_clear_pin(GPIO_LCD_CS);
  41. __gpio_as_output(GPIO_AMP_EN);
  42. __gpio_clear_pin(GPIO_AMP_EN);
  43. __gpio_as_output(GPIO_SDPW_EN);
  44. __gpio_disable_pull(GPIO_SDPW_EN);
  45. __gpio_clear_pin(GPIO_SDPW_EN);
  46. __gpio_as_input(GPIO_SD_DETECT);
  47. __gpio_disable_pull(GPIO_SD_DETECT);
  48. __gpio_as_input(GPIO_USB_DETECT);
  49. __gpio_enable_pull(GPIO_USB_DETECT);
  50. }
  51. static void cpm_init(void)
  52. {
  53. struct jz4740_cpm *cpm = (struct jz4740_cpm *)JZ4740_CPM_BASE;
  54. uint32_t reg = readl(&cpm->clkgr);
  55. reg |= CPM_CLKGR_IPU |
  56. CPM_CLKGR_CIM |
  57. CPM_CLKGR_I2C |
  58. CPM_CLKGR_SSI |
  59. CPM_CLKGR_UART1 |
  60. CPM_CLKGR_SADC |
  61. CPM_CLKGR_UHC |
  62. CPM_CLKGR_UDC |
  63. CPM_CLKGR_AIC1;
  64. writel(reg, &cpm->clkgr);
  65. }
  66. int board_early_init_f(void)
  67. {
  68. gpio_init();
  69. cpm_init();
  70. calc_clocks(); /* calc the clocks */
  71. rtc_init(); /* init rtc on any reset */
  72. return 0;
  73. }
  74. /* U-Boot common routines */
  75. int checkboard(void)
  76. {
  77. printf("Board: Qi LB60 (Ingenic XBurst Jz4740 SoC, Speed %ld MHz)\n",
  78. gd->cpu_clk / 1000000);
  79. return 0;
  80. }