Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F115439888
D35594.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D35594.diff
View Options
Index: sys/arm/allwinner/aw_mmc.c
===================================================================
--- sys/arm/allwinner/aw_mmc.c
+++ sys/arm/allwinner/aw_mmc.c
@@ -79,6 +79,7 @@
#define AW_MMC_RESSZ 2
#define AW_MMC_DMA_SEGS (PAGE_SIZE / sizeof(struct aw_mmc_dma_desc))
#define AW_MMC_DMA_DESC_SIZE (sizeof(struct aw_mmc_dma_desc) * AW_MMC_DMA_SEGS)
+#define AW_MMC_DMA_DES1_ALIGN 4
#define AW_MMC_DMA_FTRGLEVEL 0x20070008
#define AW_MMC_RESET_RETRY 1000
@@ -87,6 +88,7 @@
struct aw_mmc_conf {
uint32_t dma_xferlen;
+ uint32_t dma_desc_shift;
bool mask_data0;
bool can_calibrate;
bool new_timing;
@@ -112,10 +114,19 @@
.can_calibrate = true,
};
+static const struct aw_mmc_conf d1_mmc_conf = {
+ .dma_xferlen = 0x1FFC,
+ .dma_desc_shift = 2,
+ .mask_data0 = true,
+ .can_calibrate = true,
+ .new_timing = true,
+};
+
static struct ofw_compat_data compat_data[] = {
{"allwinner,sun4i-a10-mmc", (uintptr_t)&a10_mmc_conf},
{"allwinner,sun5i-a13-mmc", (uintptr_t)&a13_mmc_conf},
{"allwinner,sun7i-a20-mmc", (uintptr_t)&a13_mmc_conf},
+ {"allwinner,sun20i-d1-mmc", (uintptr_t)&d1_mmc_conf},
{"allwinner,sun50i-a64-mmc", (uintptr_t)&a64_mmc_conf},
{"allwinner,sun50i-a64-emmc", (uintptr_t)&a64_emmc_conf},
{NULL, 0}
@@ -194,7 +205,7 @@
SYSCTL_NODE(_hw, OID_AUTO, aw_mmc, CTLFLAG_RD | CTLFLAG_MPSAFE, 0,
"aw_mmc driver");
-static int aw_mmc_debug = 0;
+static int aw_mmc_debug = 0xF;
SYSCTL_INT(_hw_aw_mmc, OID_AUTO, debug, CTLFLAG_RWTUN, &aw_mmc_debug, 0,
"Debug level bit0=card changes bit1=ios changes, bit2=interrupts, bit3=commands");
#define AW_MMC_DEBUG_CARD 0x1
@@ -619,16 +630,14 @@
dma_desc = sc->aw_dma_desc;
for (i = 0; i < nsegs; i++) {
- if (segs[i].ds_len == sc->aw_mmc_conf->dma_xferlen)
- dma_desc[i].buf_size = 0; /* Size of 0 indicate max len */
- else
- dma_desc[i].buf_size = segs[i].ds_len;
- dma_desc[i].buf_addr = segs[i].ds_addr;
+ dma_desc[i].buf_size = roundup2(segs[i].ds_len, 4);
+ dma_desc[i].buf_addr = segs[i].ds_addr >>
+ sc->aw_mmc_conf->dma_desc_shift;
dma_desc[i].config = AW_MMC_DMA_CONFIG_CH |
- AW_MMC_DMA_CONFIG_OWN | AW_MMC_DMA_CONFIG_DIC;
-
- dma_desc[i].next = sc->aw_dma_desc_phys +
- ((i + 1) * sizeof(struct aw_mmc_dma_desc));
+ AW_MMC_DMA_CONFIG_OWN | AW_MMC_DMA_CONFIG_DIC;
+ dma_desc[i].next = (sc->aw_dma_desc_phys +
+ (i + 1) * sizeof(struct aw_mmc_dma_desc)) >>
+ sc->aw_mmc_conf->dma_desc_shift;
}
dma_desc[0].config |= AW_MMC_DMA_CONFIG_FD;
@@ -690,7 +699,8 @@
AW_MMC_WRITE_4(sc, AW_MMC_IDIE, val);
/* Set DMA descritptor list address */
- AW_MMC_WRITE_4(sc, AW_MMC_DLBA, sc->aw_dma_desc_phys);
+ AW_MMC_WRITE_4(sc, AW_MMC_DLBA, sc->aw_dma_desc_phys >>
+ sc->aw_mmc_conf->dma_desc_shift);
/* FIFO trigger level */
AW_MMC_WRITE_4(sc, AW_MMC_FWLR, AW_MMC_DMA_FTRGLEVEL);
Index: sys/dev/mmc/mmc_fdt_helpers.c
===================================================================
--- sys/dev/mmc/mmc_fdt_helpers.c
+++ sys/dev/mmc/mmc_fdt_helpers.c
@@ -315,7 +315,7 @@
if (helper->cd_disabled)
return (true);
if (helper->cd_pin == NULL)
- return (false);
+ return (true);
gpio_pin_is_active(helper->cd_pin, &pinstate);
Index: sys/riscv/allwinner/files.allwinner
===================================================================
--- sys/riscv/allwinner/files.allwinner
+++ sys/riscv/allwinner/files.allwinner
@@ -1,6 +1,7 @@
# $FreeBSD$
arm/allwinner/aw_gpio.c optional gpio aw_gpio fdt
+arm/allwinner/aw_mmc.c optional aw_mmc
arm/allwinner/aw_rtc.c optional aw_rtc fdt
arm/allwinner/aw_wdog.c optional aw_wdog
arm/allwinner/clkng/aw_ccung.c optional aw_ccu fdt
Index: sys/riscv/conf/GENERIC
===================================================================
--- sys/riscv/conf/GENERIC
+++ sys/riscv/conf/GENERIC
@@ -87,11 +87,17 @@
# pseudo devices
device clk
device hwreset
+device phy
device regulator
device syscon
device syscon_power
device riscv_syscon
+# MMC/SD/SDIO Card slot support
+device mmc # MMC/SD bus
+device mmcsd # MMC/SD flash cards
+device sdhci # SD controller
+
# Bus drivers
device pci
@@ -151,6 +157,9 @@
device miibus # MII bus support
device xae # Xilinx AXI Ethernet MAC
+# Pinmux
+device fdt_pinctrl
+
# DMA support
device xdma # DMA interface
device axidma # Xilinx AXI DMA Controller
@@ -226,3 +235,6 @@
device sifive_gpio
device sifive_spi
include "../sifive/std.sifive"
+
+# SOC-specific modules
+makeoptions MODULES_EXTRA+="allwinner/aw_mmc"
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Apr 24, 8:42 PM (18 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
17766380
Default Alt Text
D35594.diff (4 KB)
Attached To
Mode
D35594: riscv: support Allwinner D1 MMC controller
Attached
Detach File
Event Timeline
Log In to Comment