Skip to contentSkip to conversation

Standard SD host controller model

PATCH In review Peter A. G. Crosthwaite 2 participants 8 messages Jun 14, 2012 – Jun 21, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Standard SD host controller model

[Original cover by Igor]
First patch introduces standard SD host controller model. This is accumulated version of my previous patch I sent a while ago and a recent SDHCI patch by Peter A. G. Crosthwaite. Second patch introduces Exynos4210-specific SDHCI built on top of standard SDHCI model.

[New]
Third patch changes the -sd command line argument to be repeatable, to support multiple SD controllers in one system. Fourth patch adds 2x SDHCI controllers to the Xilinx Zynq machine

This revision is typo fixes and rebasing only.

Changelog:
Changed from v3:
Rebased for new Makefile system
Fixed include guard in sdhci.h
Typos in commit messages
Changed from v2:
corrected typo errors in ADMA1 support
added patches 3-4
v1->v2
PATCH1:
add support for ADMA1 (I havn't tested it though).
fixed s->prnsts <-> s->pwrcon typo (thanks to Peter, strange that it even worked before).
PATCH2:
change header prefix from "target-arm" to "exynos4210".

Igor Mitsyanko (2):
hw: introduce standard SD host controller
exynos4210: Added SD host controller model

Peter A. G. Crosthwaite (2):
vl.c: allow for repeated -sd arguments
xilinx_zynq: Added SD controllers

 default-configs/arm-softmmu.mak |    1 +
 hw/Makefile.objs                |    1 +
 hw/arm/Makefile.objs            |    1 +
 hw/exynos4210.c                 |   20 +
 hw/exynos4210_sdhci.c           |  438 +++++++++++++
 hw/sdhci.c                      | 1306 +++++++++++++++++++++++++++++++++++++++
 hw/sdhci.h                      |  310 +++++++++
 hw/xilinx_zynq.c                |   12 +
 vl.c                            |    2 +-
 9 files changed, 2090 insertions(+), 1 deletions(-)
 create mode 100644 hw/exynos4210_sdhci.c
 create mode 100644 hw/sdhci.c
 create mode 100644 hw/sdhci.h
Signature · 1 line
1.7.3.2
#1 lore raw

PATCH 1/4 hw: introduce standard SD host controller

From: Igor Mitsyanko <[email protected]>

Device model for standard SD Host Controller Interface (SDHCI) compliant with version 2.00 of SD association specification.

---
changed from v1:
Fixed include guard (Andreas review)
Rebased for new Makefile system
changed from v2:
Typographical fixes for adma implementation:
-dscr->attr = (uint8_t)(adma2 & 0x3F);
+dscr->attr = (uint8_t)(adma1 & 0x3F);
-#define SDHC_CTRL_ADMA1_32 0x01
+#define SDHC_CTRL_ADMA1_32 0x08

 default-configs/arm-softmmu.mak |    1 +
 hw/Makefile.objs                |    1 +
 hw/sdhci.c                      | 1306 +++++++++++++++++++++++++++++++++++++++
 hw/sdhci.h                      |  310 +++++++++
 4 files changed, 1618 insertions(+), 0 deletions(-)
 create mode 100644 hw/sdhci.c
 create mode 100644 hw/sdhci.h
default-configs/arm-softmmu.mak +1 -0
index e542b4f..314784b 100644
@@ -27,3 +27,4 @@ CONFIG_SMC91C111=y
 CONFIG_DS1338=y
 CONFIG_PFLASH_CFI01=y
 CONFIG_PFLASH_CFI02=y
+CONFIG_SDHCI=y
hw/Makefile.objs +1 -0
index 7e17504..5d7fe5b 100644
@@ -35,6 +35,7 @@ hw-obj-$(CONFIG_APPLESMC) += applesmc.o
 hw-obj-$(CONFIG_SMARTCARD) += ccid-card-passthru.o
 hw-obj-$(CONFIG_SMARTCARD_NSS) += ccid-card-emulated.o
 hw-obj-$(CONFIG_I8259) += i8259_common.o i8259.o
+hw-obj-$(CONFIG_SDHCI) += sdhci.o
 
 # PPC devices
 hw-obj-$(CONFIG_PREP_PCI) += prep_pci.o
hw/sdhci.c new file +1306 -0

1,306 lines not on this page · raw message

hw/sdhci.h new file +310 -0

310 lines not on this page · raw message

Signature · 1 line
1.7.3.2
#2 lore raw

PATCH 2/4 exynos4210: Added SD host controller model

In reply to Peter A. G. Crosthwaite

From: Igor Mitsyanko <[email protected]>

Custom Exynos4210 SD/MMC host controller, based on SD association standard host controller ver. 2.00.

---
changed from v3:
rebased for new Makefile system
fixed commit msg typo (Andreas review)

 hw/arm/Makefile.objs  |    1 +
 hw/exynos4210.c       |   20 +++
 hw/exynos4210_sdhci.c |  438 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 459 insertions(+), 0 deletions(-)
 create mode 100644 hw/exynos4210_sdhci.c
hw/arm/Makefile.objs +1 -0
index a0ff6a6..0aeabf9 100644
@@ -11,6 +11,7 @@ obj-y += realview_gic.o realview.o arm_sysctl.o arm11mpcore.o a9mpcore.o
 obj-y += exynos4210_gic.o exynos4210_combiner.o exynos4210.o
 obj-y += exynos4_boards.o exynos4210_uart.o exynos4210_pwm.o
 obj-y += exynos4210_pmu.o exynos4210_mct.o exynos4210_fimd.o
+obj-y += exynos4210_sdhci.o
 obj-y += arm_l2x0.o
 obj-y += arm_mptimer.o a15mpcore.o
 obj-y += armv7m.o armv7m_nvic.o stellaris.o pl022.o stellaris_enet.o
hw/exynos4210.c +20 -0
index dd14d01..345aa0b 100644
@@ -56,6 +56,12 @@
 #define EXYNOS4210_EXT_COMBINER_BASE_ADDR   0x10440000
 #define EXYNOS4210_INT_COMBINER_BASE_ADDR   0x10448000
 
+/* SD/MMC host controllers SFR base addresses */
+#define EXYNOS4210_SDHC0_BASE_ADDR          0x12510000
+#define EXYNOS4210_SDHC1_BASE_ADDR          0x12520000
+#define EXYNOS4210_SDHC2_BASE_ADDR          0x12530000
+#define EXYNOS4210_SDHC3_BASE_ADDR          0x12540000
+
 /* PMU SFR base address */
 #define EXYNOS4210_PMU_BASE_ADDR            0x10020000
 
@@ -290,6 +296,20 @@ Exynos4210State *exynos4210_init(MemoryRegion *system_mem,
                            EXYNOS4210_UART3_FIFO_SIZE, 3, NULL,
                   s->irq_table[exynos4210_get_irq(EXYNOS4210_UART_INT_GRP, 3)]);
 
+    /*** SD/MMC host controllers ***/
+
+    sysbus_create_simple("exynos4210.sdhci", EXYNOS4210_SDHC0_BASE_ADDR,
+            s->irq_table[exynos4210_get_irq(29, 0)]);
+
+    sysbus_create_simple("exynos4210.sdhci", EXYNOS4210_SDHC1_BASE_ADDR,
+            s->irq_table[exynos4210_get_irq(29, 1)]);
+
+    sysbus_create_simple("exynos4210.sdhci", EXYNOS4210_SDHC2_BASE_ADDR,
+            s->irq_table[exynos4210_get_irq(29, 2)]);
+
+    sysbus_create_simple("exynos4210.sdhci", EXYNOS4210_SDHC3_BASE_ADDR,
+            s->irq_table[exynos4210_get_irq(29, 3)]);
+
     /*** Display controller (FIMD) ***/
     sysbus_create_varargs("exynos4210.fimd", EXYNOS4210_FIMD0_BASE_ADDR,
             s->irq_table[exynos4210_get_irq(11, 0)],
hw/exynos4210_sdhci.c new file +438 -0

438 lines not on this page · raw message

Signature · 1 line
1.7.3.2
#3 lore raw

PATCH 3/4 vl.c: allow for repeated -sd arguments

In reply to Peter A. G. Crosthwaite

Allows for repeating of -sd arugments in the same way as -pflash and -mtdblock.

---
changed from v3:
fixed commit msg typo

 vl.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
vl.c +1 -1
index 204d85b..b6d624b 100644
@@ -2431,7 +2431,7 @@ int main(int argc, char **argv, char **envp)
                 drive_add(IF_MTD, -1, optarg, MTD_OPTS);
                 break;
             case QEMU_OPTION_sd:
-                drive_add(IF_SD, 0, optarg, SD_OPTS);
+                drive_add(IF_SD, -1, optarg, SD_OPTS);
                 break;
             case QEMU_OPTION_pflash:
                 drive_add(IF_PFLASH, -1, optarg, PFLASH_OPTS);
Signature · 1 line
1.7.3.2
Acked-by on v1 3/4
#4 lore raw

Re: [Qemu-devel] [PATCH v1 3/4] vl.c: allow for repeated -sd arguments

Quoted 15 lines · Peter A. G. Crosthwaite

Allows for repeating of -sd arugments in the same way as -pflash and -mtdblock.

---
changed from v3:
fixed commit msg typo

  vl.c |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
vl.c +0 -0
index 204d85b..b6d624b 100644

vl.c int main(int argc, char **argv, char **envp) · line 2437

Quoted 8 lines
vl.c +1 -1
@@ -2431,7 +2431,7 @@ int main(int argc, char **argv, char **envp)
                  drive_add(IF_MTD, -1, optarg, MTD_OPTS);
                  break;
              case QEMU_OPTION_sd:
-                drive_add(IF_SD, 0, optarg, SD_OPTS);
+                drive_add(IF_SD, -1, optarg, SD_OPTS);
                  break;
              case QEMU_OPTION_pflash:
                  drive_add(IF_PFLASH, -1, optarg, PFLASH_OPTS);

Nice. Sometimes its really annoying to type full "-drive .." command

#5 lore raw

PATCH 4/4 xilinx_zynq: Added SD controllers

In reply to Peter A. G. Crosthwaite

The Xilinx Zynq device has two SDHCI controllers. Added to the machine model.

---
changed from v3:
fixed indentation
tweaked commit msg

 hw/xilinx_zynq.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
hw/xilinx_zynq.c +12 -0
index 7e6c273..e684832 100644
@@ -130,6 +130,18 @@ static void zynq_init(ram_addr_t ram_size, const char *boot_device,
         }
     }
 
+    {
+        dev = qdev_create(NULL, "sdhci");
+        qdev_init_nofail(dev);
+        sysbus_mmio_map(sysbus_from_qdev(dev), 0, 0xE0100000);
+        sysbus_connect_irq(sysbus_from_qdev(dev), 0, pic[56-IRQ_OFFSET]);
+
+        dev = qdev_create(NULL, "sdhci");
+        qdev_init_nofail(dev);
+        sysbus_mmio_map(sysbus_from_qdev(dev), 0, 0xE0101000);
+        sysbus_connect_irq(sysbus_from_qdev(dev), 0, pic[79-IRQ_OFFSET]);
+    }
+
     zynq_binfo.ram_size = ram_size;
     zynq_binfo.kernel_filename = kernel_filename;
     zynq_binfo.kernel_cmdline = kernel_cmdline;
Signature · 1 line
1.7.3.2
#6 lore raw
In reply to Peter A. G. Crosthwaite

ergh,

series version number is incorrect, this is v4.

Quoted 50 lines · Peter A. G. Crosthwaite

[Original cover by Igor]
First patch introduces standard SD host controller model. This is accumulated version of my previous patch I sent a while ago and a recent SDHCI patch by Peter A. G. Crosthwaite. Second patch introduces Exynos4210-specific SDHCI built on top of standard SDHCI model.

[New]
Third patch changes the -sd command line argument to be repeatable, to support multiple SD controllers in one system. Fourth patch adds 2x SDHCI controllers to the Xilinx Zynq machine

This revision is typo fixes and rebasing only.

Changelog:
Changed from v3:
Rebased for new Makefile system
Fixed include guard in sdhci.h
Typos in commit messages
Changed from v2:
corrected typo errors in ADMA1 support
added patches 3-4
v1->v2
 PATCH1:
 add support for ADMA1 (I havn't tested it though).
 fixed s->prnsts <-> s->pwrcon typo (thanks to Peter, strange that it even worked before).
 PATCH2:
 change header prefix from "target-arm" to "exynos4210".

Igor Mitsyanko (2):
 hw: introduce standard SD host controller
 exynos4210: Added SD host controller model

Peter A. G. Crosthwaite (2):
 vl.c: allow for repeated -sd arguments
 xilinx_zynq: Added SD controllers

 default-configs/arm-softmmu.mak |    1 +
 hw/Makefile.objs                |    1 +
 hw/arm/Makefile.objs            |    1 +
 hw/exynos4210.c                 |   20 +
 hw/exynos4210_sdhci.c           |  438 +++++++++++++
 hw/sdhci.c                      | 1306 +++++++++++++++++++++++++++++++++++++++ hw/sdhci.h                      |  310 +++++++++
 hw/xilinx_zynq.c                |   12 +
 vl.c                            |    2 +-

 9 files changed, 2090 insertions(+), 1 deletions(-)

 create mode 100644 hw/exynos4210_sdhci.c
 create mode 100644 hw/sdhci.c
 create mode 100644 hw/sdhci.h

--
1.7.3.2

#7 lore raw

Ping!

We good to go on this one? Whose queue should this go in or should I PULL?

Quoted 56 lines · Peter Crosthwaite

ergh,

series version number is incorrect, this is v4.

Quoted 50 lines · Peter A. G. Crosthwaite

[Original cover by Igor]
First patch introduces standard SD host controller model. This is accumulated version of my previous patch I sent a while ago and a recent SDHCI patch by Peter A. G. Crosthwaite. Second patch introduces Exynos4210-specific SDHCI built on top of standard SDHCI model.

[New]
Third patch changes the -sd command line argument to be repeatable, to support multiple SD controllers in one system. Fourth patch adds 2x SDHCI controllers to the Xilinx Zynq machine

This revision is typo fixes and rebasing only.

Changelog:
Changed from v3:
Rebased for new Makefile system
Fixed include guard in sdhci.h
Typos in commit messages
Changed from v2:
corrected typo errors in ADMA1 support
added patches 3-4
v1->v2
 PATCH1:
 add support for ADMA1 (I havn't tested it though).
 fixed s->prnsts <-> s->pwrcon typo (thanks to Peter, strange that it even worked before).
 PATCH2:
 change header prefix from "target-arm" to "exynos4210".

Igor Mitsyanko (2):
 hw: introduce standard SD host controller
 exynos4210: Added SD host controller model

Peter A. G. Crosthwaite (2):
 vl.c: allow for repeated -sd arguments
 xilinx_zynq: Added SD controllers

 default-configs/arm-softmmu.mak |    1 +
 hw/Makefile.objs                |    1 +
 hw/arm/Makefile.objs            |    1 +
 hw/exynos4210.c                 |   20 +
 hw/exynos4210_sdhci.c           |  438 +++++++++++++
 hw/sdhci.c                      | 1306 +++++++++++++++++++++++++++++++++++++++ hw/sdhci.h                      |  310 +++++++++
 hw/xilinx_zynq.c                |   12 +
 vl.c                            |    2 +-

 9 files changed, 2090 insertions(+), 1 deletions(-)

 create mode 100644 hw/exynos4210_sdhci.c
 create mode 100644 hw/sdhci.c
 create mode 100644 hw/sdhci.h

--
1.7.3.2