more
Change-Id: Ibb68fdf0538a2b62c4fe1832b63fa74f39c826b2
diff --git a/system/dev/block/hi3660-sdhci/hi3660-sdhci.c b/system/dev/block/hi3660-sdhci/hi3660-sdhci.c
index 0648c05..98c5b3b 100644
--- a/system/dev/block/hi3660-sdhci/hi3660-sdhci.c
+++ b/system/dev/block/hi3660-sdhci/hi3660-sdhci.c
@@ -50,7 +50,7 @@
}
static zx_paddr_t hisi_sdhci_get_dma_offset(void* ctx) {
- return 0;
+ return 0x200;
}
static uint64_t hisi_sdhci_get_quirks(void* ctx) {
@@ -120,6 +120,19 @@
writel(1, pinmux + 4); // SD_DATA2
writel(1, pinmux + 5); // SD_DATA3
+#define SDMMC_CDTHRCTL 0x100
+#define SDMMC_SET_THLD(v, x) (((v) & 0xFFF) << 16 | (x))
+#define SDMMC_CARD_RD_THR_EN (1 << 0)
+#define SDCARD_RD_THRESHOLD (512)
+#define SDMMC_VERID 0x06c
+
+ volatile uint32_t* cdthrctl = dev->mmio.vaddr + SDMMC_CDTHRCTL;
+ volatile uint32_t* verid = dev->mmio.vaddr + SDMMC_VERID;
+
+printf("try to read version\n");
+ printf("SDMMC_VERID %04x\n", readl(verid));
+ writel(SDMMC_SET_THLD(SDCARD_RD_THRESHOLD, SDMMC_CARD_RD_THR_EN), cdthrctl);
+
device_add_args_t args = {
.version = DEVICE_ADD_ARGS_VERSION,
.name = "hi3660-sdhci",
diff --git a/system/dev/block/sdhci/sdhci.c b/system/dev/block/sdhci/sdhci.c
index 4b4002b..613fff3 100644
--- a/system/dev/block/sdhci/sdhci.c
+++ b/system/dev/block/sdhci/sdhci.c
@@ -934,6 +934,11 @@
dev->pending_completion = COMPLETION_INIT;
dev->parent = parent;
+uint32_t* regs = (uint32_t *)dev->regs;
+for (unsigned i = 0; i < sizeof(sdhci_regs_t) / 4; i++) {
+printf("%02X: %08X\n", i, regs[i]);
+}
+
// Ensure that we're SDv3.
const uint16_t vrsn = (dev->regs->slotirqversion >> 16) & 0xff;
if (vrsn != SDHCI_VERSION_3) {
diff --git a/system/dev/soc/hi3660/hi3660.c b/system/dev/soc/hi3660/hi3660.c
index d6bc9d2..8762943 100644
--- a/system/dev/soc/hi3660/hi3660.c
+++ b/system/dev/soc/hi3660/hi3660.c
@@ -53,24 +53,43 @@
goto fail;
}
+/*
+[ 3.067721] CCC clk_prepare_enable biu_clk
+[ 3.067733] CCC clkgate_separated_enable 40000000 ffffff8008005000
+[ 3.067746] CCC clk_prepare_enable ciu_clk
+[ 3.067755] CCC clkgate_separated_enable 20000 ffffff8008005040
+[ 3.067843] CCC dw_mci_hs_set_timing 0 -1
+[ 3.095964] CCC dw_mci_hs_set_timing 0 -1
+[ 3.117050] CCC clk_prepare_enable biu_clk
+[ 3.117061] CCC clkgate_separated_enable 200000 ffffff8008005000
+[ 3.117073] CCC clk_prepare_enable ciu_clk
+[ 3.117083] CCC clkgate_separated_enable 80000 ffffff8008005040
+*/
+
// SD card
volatile void* peri_crg = io_buffer_virt(&hi3660->peri_crg);
uint32_t temp;
- temp = readl(peri_crg + 0x40 + 8);
- printf("HI3660_CLK_GATE_SD status %x\n", temp);
- // enable HI3660_CLK_GATE_SD
- writel(1 << 17, peri_crg + 0x40);
- temp = readl(peri_crg + 0x40 + 8);
- printf("HI3660_CLK_GATE_SD status %x\n", temp);
+
+ writel(0x40000, peri_crg + 0x94);
+ usleep(50);
+ writel(0x40000, peri_crg + 0x94 + 4);
+
temp = readl(peri_crg + 0 + 8);
printf("HI3660_HCLK_GATE_SD status %x\n", temp);
// enable HI3660_HCLK_GATE_SD
- writel(1 << 30, peri_crg + 0);
+ writel(0x40000000, peri_crg + 0);
temp = readl(peri_crg + 0 + 8);
printf("HI3660_HCLK_GATE_SD status %x\n", temp);
+ temp = readl(peri_crg + 0x40 + 8);
+ printf("HI3660_CLK_GATE_SD status %x\n", temp);
+ // enable HI3660_CLK_GATE_SD
+ writel(0x20000, peri_crg + 0x40);
+ temp = readl(peri_crg + 0x40 + 8);
+ printf("HI3660_CLK_GATE_SD status %x\n", temp);
+
*out = hi3660;
return ZX_OK;