arkn141.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #include <common.h>
  2. #include <dwmmc.h>
  3. #include <malloc.h>
  4. #include <asm/gpio.h>
  5. DECLARE_GLOBAL_DATA_PTR;
  6. #define rSYS_AHB_CLK_EN *((volatile unsigned int *)(0x40408044))
  7. #define rSYS_SD_CLK_CFG *((volatile unsigned int *)(0x40408058))
  8. #define rSYS_SD1_CLK_CFG *((volatile unsigned int *)(0x4040805c))
  9. #define rSYS_SOFT_RSTNA *((volatile unsigned int *)(0x40408074))
  10. #define rSYS_PAD_CTRL03 *((volatile unsigned int *)(0x404081cc))
  11. #define rSYS_PAD_CTRL08 *((volatile unsigned int *)(0x404081e0))
  12. #define rSYS_PAD_CTRL09 *((volatile unsigned int *)(0x404081e4))
  13. static void dwmci_select_pad(void)
  14. {
  15. /* use sd/mmc 0 */
  16. rSYS_PAD_CTRL09 |= 0x7F;
  17. rSYS_SD_CLK_CFG = 0x00000420;
  18. /* use sd/mmc 1 pad sd1_0 */
  19. rSYS_PAD_CTRL09 |= (0x7F << 7);
  20. rSYS_SD1_CLK_CFG = 0x00000420;
  21. }
  22. static void dwmci_reset(void)
  23. {
  24. rSYS_AHB_CLK_EN &= ~((1 << 4) | (1 << 3));
  25. rSYS_SOFT_RSTNA &= ~((1 << 31) | (1 << 12));
  26. udelay(100);
  27. rSYS_SOFT_RSTNA |= ((1 << 31) | (1 << 12));
  28. rSYS_AHB_CLK_EN |= ((1 << 4) | (1 << 3));
  29. }
  30. #define ARK_MMC_CLK 24000000
  31. int ark_dwmci_init(char *name,u32 regbase, int bus_width, int index)
  32. {
  33. struct dwmci_host *host = NULL;
  34. host = malloc(sizeof(struct dwmci_host));
  35. if (!host) {
  36. printf("dwmci_host malloc fail!\n");
  37. return 1;
  38. }
  39. memset(host, 0, sizeof(struct dwmci_host));
  40. dwmci_select_pad();
  41. dwmci_reset();
  42. host->name = name;
  43. host->ioaddr = (void *)regbase;
  44. host->buswidth = bus_width;
  45. host->dev_index = index;
  46. host->bus_hz = ARK_MMC_CLK;
  47. host->fifo_mode = 1;
  48. add_dwmci(host, host->bus_hz, 400000);
  49. return 0;
  50. }
  51. int board_mmc_init(bd_t *bis)
  52. {
  53. ark_dwmci_init("ARK_MMC0", 0x60000000, 4, 0);
  54. ark_dwmci_init("ARK_MMC1", 0x68000000, 4, 0);
  55. return 0;
  56. }
  57. int dram_init(void)
  58. {
  59. gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE,
  60. CONFIG_SYS_SDRAM_SIZE);
  61. return 0;
  62. }
  63. int board_init(void)
  64. {
  65. unsigned int tmp;
  66. /* SPI pad enable */
  67. tmp = rSYS_PAD_CTRL08;
  68. tmp &= ~(0xFF << 16);
  69. tmp |= (0xA8 << 16);
  70. rSYS_PAD_CTRL08 = tmp;
  71. /* power GPIO31 high for sdio wifi module in shangqi carcorder project */
  72. rSYS_PAD_CTRL03 &= ~(0x7 << 3);
  73. gpio_direction_output(31, 1);
  74. return 0;
  75. }
  76. int board_late_init(void)
  77. {
  78. return 0;
  79. }