amt630h.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #include <common.h>
  2. #include <dwmmc.h>
  3. #include <malloc.h>
  4. #include <asm/gpio.h>
  5. DECLARE_GLOBAL_DATA_PTR;
  6. #define AMT630H_UPDATE_MAGIC "ada7f0c6-7c86-11e9-8f9e-2a86e4085a59"
  7. #define rSYS_SOFT_RST *((volatile unsigned int *)(0x6000005c))
  8. #define rSYS_ANA_CFG *((volatile unsigned int *)(0x60000080))
  9. static void dwmci_select_pad(void)
  10. {
  11. }
  12. static void dwmci_reset(void)
  13. {
  14. }
  15. #define ARK_MMC_CLK 24000000
  16. int ark_dwmci_init(char *name,u32 regbase, int bus_width, int index)
  17. {
  18. struct dwmci_host *host = NULL;
  19. host = malloc(sizeof(struct dwmci_host));
  20. if (!host) {
  21. printf("dwmci_host malloc fail!\n");
  22. return 1;
  23. }
  24. memset(host, 0, sizeof(struct dwmci_host));
  25. dwmci_select_pad();
  26. dwmci_reset();
  27. host->name = name;
  28. host->ioaddr = (void *)regbase;
  29. host->buswidth = bus_width;
  30. host->dev_index = index;
  31. host->bus_hz = ARK_MMC_CLK;
  32. host->fifo_mode = 1;
  33. add_dwmci(host, host->bus_hz, 400000);
  34. return 0;
  35. }
  36. int board_mmc_init(bd_t *bis)
  37. {
  38. ark_dwmci_init("ARK_MMC0", 0x70400000, 4, 0);
  39. return 0;
  40. }
  41. int dram_init(void)
  42. {
  43. gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE,
  44. CONFIG_SYS_SDRAM_SIZE);
  45. return 0;
  46. }
  47. int board_init(void)
  48. {
  49. return 0;
  50. }
  51. int board_late_init(void)
  52. {
  53. /* set usb0 host mode */
  54. rSYS_ANA_CFG &= ~(1 << 25);
  55. rSYS_ANA_CFG |= (1 << 24);
  56. udelay(100);
  57. /* soft reset phy */
  58. rSYS_SOFT_RST &= ~(1 << 30);
  59. udelay(100);
  60. rSYS_SOFT_RST |= (1 << 30);
  61. udelay(1000);
  62. /* soft reset controller */
  63. rSYS_SOFT_RST &= ~(1 << 3);
  64. udelay(100);
  65. rSYS_SOFT_RST |= (1 << 3);
  66. udelay(100);
  67. #if 0
  68. char cmd[128];
  69. char *need_update;
  70. unsigned int loadaddr;
  71. run_command("sf probe", 0);
  72. gpio_direction_input(32);
  73. if (!gpio_get_value(32))
  74. env_set("need_update", "yes");
  75. need_update = env_get("need_update");
  76. if (!strcmp(need_update, "yes")) {
  77. sprintf(cmd, "fatload %s %s %s update-magic", env_get("update_dev"),
  78. env_get("dev_part"), env_get("loadaddr"));
  79. run_command(cmd, 0);
  80. loadaddr = env_get_hex("loadaddr", 0);
  81. if (loadaddr && memcmp((void*)loadaddr, ARKN141_UPDATE_MAGIC,
  82. strlen(ARKN141_UPDATE_MAGIC))) {
  83. printf("Wrong update magic, do not update.\n");
  84. env_set("need_update", "no");
  85. } else {
  86. run_command("sf erase usrdata 0", 0);
  87. run_command("env default -f -a", 0);
  88. }
  89. }
  90. #endif
  91. return 0;
  92. }