[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-arm] [PATCH v5 16/31] sdhci: add v3 capabilities
From: |
Philippe Mathieu-Daudé |
Subject: |
[Qemu-arm] [PATCH v5 16/31] sdhci: add v3 capabilities |
Date: |
Mon, 8 Jan 2018 12:42:48 -0300 |
Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
---
hw/sd/sdhci-internal.h | 21 +++++++++++++++++++++
include/hw/sd/sdhci.h | 2 ++
hw/sd/sdhci.c | 21 +++++++++++++++++++--
3 files changed, 42 insertions(+), 2 deletions(-)
diff --git a/hw/sd/sdhci-internal.h b/hw/sd/sdhci-internal.h
index affbe4015c..1da91a27b4 100644
--- a/hw/sd/sdhci-internal.h
+++ b/hw/sd/sdhci-internal.h
@@ -43,6 +43,7 @@
#define SDHC_TRNS_DMA 0x0001
#define SDHC_TRNS_BLK_CNT_EN 0x0002
#define SDHC_TRNS_ACMD12 0x0004
+#define SDHC_TRNS_ACMD23 0x0008 /* since v3 */
#define SDHC_TRNS_READ 0x0010
#define SDHC_TRNS_MULTI 0x0020
#define SDHC_TRNMOD_MASK 0x0037
@@ -183,12 +184,23 @@ FIELD(SDHC_ACMD12ERRSTS, TIMEOUT_ERR, 1, 1);
FIELD(SDHC_ACMD12ERRSTS, CRC_ERR, 2, 1);
FIELD(SDHC_ACMD12ERRSTS, INDEX_ERR, 4, 1);
+/* Host Control Register 2 (since v3) */
+#define SDHC_HOSTCTL2 0x3E
+FIELD(SDHC_HOSTCTL2, UHS_MODE_SEL, 0, 3);
+FIELD(SDHC_HOSTCTL2, V18_ENA, 3, 1); /* UHS-I only */
+FIELD(SDHC_HOSTCTL2, DRIVER_STRENGTH, 4, 2); /* UHS-I only */
+FIELD(SDHC_HOSTCTL2, EXECUTE_TUNING, 6, 1); /* UHS-I only */
+FIELD(SDHC_HOSTCTL2, SAMPLING_CLKSEL, 7, 1); /* UHS-I only */
+FIELD(SDHC_HOSTCTL2, ASYNC_INT, 14, 1);
+FIELD(SDHC_HOSTCTL2, PRESET_ENA, 15, 1);
+
/* HWInit Capabilities Register 0x05E80080 */
#define SDHC_CAPAB 0x40
FIELD(SDHC_CAPAB, TOCLKFREQ, 0, 6);
FIELD(SDHC_CAPAB, TOUNIT, 7, 1);
FIELD(SDHC_CAPAB, BASECLKFREQ, 8, 8);
FIELD(SDHC_CAPAB, MAXBLOCKLENGTH, 16, 2);
+FIELD(SDHC_CAPAB, EMBEDDED_8BIT, 18, 1); /* since v3 */
FIELD(SDHC_CAPAB, ADMA2, 19, 1); /* since v2 */
FIELD(SDHC_CAPAB, ADMA1, 20, 1); /* v1 only? */
FIELD(SDHC_CAPAB, HIGHSPEED, 21, 1);
@@ -198,6 +210,15 @@ FIELD(SDHC_CAPAB, V33, 24, 1);
FIELD(SDHC_CAPAB, V30, 25, 1);
FIELD(SDHC_CAPAB, V18, 26, 1);
FIELD(SDHC_CAPAB, BUS64BIT, 28, 1); /* since v2 */
+FIELD(SDHC_CAPAB, ASYNC_INT, 29, 1); /* since v3 */
+FIELD(SDHC_CAPAB, SLOT_TYPE, 30, 2); /* since v3 */
+FIELD(SDHC_CAPAB, BUS_SPEED, 32, 3); /* since v3 */
+FIELD(SDHC_CAPAB, DRIVER_STRENGTH, 36, 3); /* since v3 */
+FIELD(SDHC_CAPAB, DRIVER_TYPE_A, 36, 1); /* since v3 */
+FIELD(SDHC_CAPAB, DRIVER_TYPE_C, 37, 1); /* since v3 */
+FIELD(SDHC_CAPAB, DRIVER_TYPE_D, 38, 1); /* since v3 */
+FIELD(SDHC_CAPAB, TIMER_RETUNNING, 40, 4); /* since v3 */
+FIELD(SDHC_CAPAB, SDR50_TUNNING, 45, 1); /* since v3 */
/* HWInit Maximum Current Capabilities Register 0x0 */
#define SDHC_MAXCURR 0x48
diff --git a/include/hw/sd/sdhci.h b/include/hw/sd/sdhci.h
index a80b7c0424..c0098fc920 100644
--- a/include/hw/sd/sdhci.h
+++ b/include/hw/sd/sdhci.h
@@ -114,6 +114,8 @@ typedef struct SDHCIState {
/* v2 */
bool adma1, adma2;
bool bus64;
+ /* v3 */
+ uint8_t slot_type, sdr, strength;
} cap;
} SDHCIState;
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
index 83b027a3b6..3f5e0760f6 100644
--- a/hw/sd/sdhci.c
+++ b/hw/sd/sdhci.c
@@ -62,6 +62,17 @@ static void sdhci_init_capareg(SDHCIState *s, Error **errp)
uint32_t val;
switch (s->spec_version) {
+ case 3:
+ val = FIELD_EX64(capareg, SDHC_CAPAB, SLOT_TYPE);
+ if (val) {
+ error_setg(errp, "slot-type not supported");
+ return;
+ }
+ capareg = FIELD_DP64(capareg, SDHC_CAPAB, SLOT_TYPE, val);
+ capareg = FIELD_DP64(capareg, SDHC_CAPAB, BUS_SPEED, s->cap.sdr);
+ capareg = FIELD_DP64(capareg, SDHC_CAPAB, DRIVER_STRENGTH,
+ s->cap.strength);
+
/* fallback */
case 2:
capareg = FIELD_DP64(capareg, SDHC_CAPAB, ADMA1, s->cap.adma1);
@@ -1174,8 +1185,11 @@ static inline unsigned int sdhci_get_fifolen(SDHCIState
*s)
static void sdhci_init_readonly_registers(SDHCIState *s, Error **errp)
{
- if (s->spec_version != 2) {
- error_setg(errp, "Only Spec v2 is supported");
+ switch (s->spec_version) {
+ case 2 ... 3:
+ break;
+ default:
+ error_setg(errp, "Only Spec v2/v3 are supported");
return;
}
s->version = (SDHC_HCVER_VENDOR << 8) | (s->spec_version - 1);
@@ -1327,6 +1341,9 @@ static Property sdhci_properties[] = {
DEFINE_PROP_BOOL("1v8", SDHCIState, cap.v18, false),
DEFINE_PROP_BOOL("64bit", SDHCIState, cap.bus64, false),
+ DEFINE_PROP_UINT8("slot-type", SDHCIState, cap.slot_type, 0),
+ DEFINE_PROP_UINT8("bus-speed", SDHCIState, cap.sdr, 0),
+ DEFINE_PROP_UINT8("driver-strength", SDHCIState, cap.strength, 0),
/* capareg: deprecated */
DEFINE_PROP_UINT64("capareg", SDHCIState, capareg, UINT64_MAX),
--
2.15.1
- [Qemu-arm] [PATCH v5 09/31] sdhci: add a common class, (continued)
- [Qemu-arm] [PATCH v5 09/31] sdhci: add a common class, Philippe Mathieu-Daudé, 2018/01/08
- [Qemu-arm] [PATCH v5 10/31] sdhci: add a Designware/Samsung host controller, Philippe Mathieu-Daudé, 2018/01/08
- [Qemu-arm] [PATCH v5 11/31] hw/arm/exynos4210: use the "samsung, exynos4210-dw-mshc" device, Philippe Mathieu-Daudé, 2018/01/08
- [Qemu-arm] [PATCH v5 12/31] sdhci: add the generic Arasan SDHCI 4.9a PHY controller, Philippe Mathieu-Daudé, 2018/01/08
- [Qemu-arm] [PATCH v5 13/31] hw/arm/xilinx_zynq: use the "arasan, sdhci-4.9a" device, Philippe Mathieu-Daudé, 2018/01/08
- [Qemu-arm] [PATCH v5 14/31] sdhci: add qtest to check the SD Spec version, Philippe Mathieu-Daudé, 2018/01/08
- [Qemu-arm] [PATCH v5 15/31] sdhci: check Spec v2 capabilities qtest, Philippe Mathieu-Daudé, 2018/01/08
- [Qemu-arm] [PATCH v5 16/31] sdhci: add v3 capabilities,
Philippe Mathieu-Daudé <=
- [Qemu-arm] [PATCH v5 17/31] sdhci: rename the hostctl1 register, Philippe Mathieu-Daudé, 2018/01/08
- [Qemu-arm] [PATCH v5 18/31] sdhci: add the Broadcom BCM2835 SDHCI controller, Philippe Mathieu-Daudé, 2018/01/08
- [Qemu-arm] [PATCH v5 19/31] hw/arm/bcm2835_peripherals: use the "brcm, bcm2835-sdhci" device, Philippe Mathieu-Daudé, 2018/01/08
- [Qemu-arm] [PATCH v5 20/31] sdhci: add the Freescale controller for i.MX, Philippe Mathieu-Daudé, 2018/01/08
- [Qemu-arm] [PATCH v5 21/31] hw/arm/fsl-imx6: use the "fsl, imx6q-usdhc" controller, Philippe Mathieu-Daudé, 2018/01/08
- [Qemu-arm] [PATCH v5 22/31] sdhci: add the generic Arasan SDHCI 8.9a PHY, Philippe Mathieu-Daudé, 2018/01/08
- [Qemu-arm] [PATCH v5 23/31] hw/arm/xilinx_zynqmp: use the "arasan, sdhci-8.9a" device, Philippe Mathieu-Daudé, 2018/01/08
- [Qemu-arm] [PATCH v5 24/31] sdhci: let the SYSBUS_SDHCI type be abstract, Philippe Mathieu-Daudé, 2018/01/08
- [Qemu-arm] [PATCH v5 25/31] sdhci: check Spec v3 capabilities qtest, Philippe Mathieu-Daudé, 2018/01/08