Using MMC on HoneyComb LX2 (patch)

David Young <[email protected]>
Newsgroups gmane.os.netbsd.ports.arm
Message-ID <[email protected]>
The SolidRun HoneyComb LX2 has a 64 GB MMC built in.  NetBSD did not
attach the MMC until I patched sdhc@acpi.  See attachment.  Maybe
somebody else can try it out.  Does it look ok to apply?

David

-- 
David Young
[email protected]    Urbana, IL    (217) 721-9981
lx2160-sd-mmc.patch (text/x-diff, 2.7 KB)
Index: sys/dev/acpi/sdhc_acpi.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/sdhc_acpi.c,v
retrieving revision 1.20
diff -u -p -r1.20 sdhc_acpi.c
--- sys/dev/acpi/sdhc_acpi.c	6 Feb 2022 15:52:20 -0000	1.20
+++ sys/dev/acpi/sdhc_acpi.c	27 Mar 2024 01:23:34 -0000
@@ -104,7 +104,8 @@ static const struct sdhc_acpi_slot {
 	{ .hid = "NXP0003",  .uid = "0", .type = SLOT_TYPE_SD,
 					 .flags = SDHC_ESDHC_FLAGS },
 	{ .hid = "NXP0003",  .uid = "1", .type = SLOT_TYPE_EMMC,
-					 .flags = SDHC_ESDHC_FLAGS },
+					 .flags = SDHC_ESDHC_FLAGS |
+						  SDHC_FLAG_ALWAYS_PRESENT },
 	{ .hid = "RKCP0D40",		 .type = SLOT_TYPE_SD,
 					 .flags = SDHC_FLAG_32BIT_ACCESS |
 						  SDHC_FLAG_8BIT_MODE |
@@ -153,6 +154,13 @@ sdhc_acpi_match(device_t parent, cfdata_
 	return sdhc_acpi_find_slot(aa->aa_node->ad_devinfo) != NULL;
 }
 
+static int
+sdhc_acpi_card_detect_always(struct sdhc_softc *sc)
+{
+	(void)sc;
+	return 1;
+}
+
 static void
 sdhc_acpi_attach(device_t parent, device_t self, void *opaque)
 {
@@ -174,8 +182,10 @@ sdhc_acpi_attach(device_t parent, device
 	sc->sc_handle = aa->aa_node->ad_handle;
 
 	slot = sdhc_acpi_find_slot(aa->aa_node->ad_devinfo);
-	if (slot->type == SLOT_TYPE_EMMC)
+	if (slot != NULL && slot->type == SLOT_TYPE_EMMC)
 		sc->sc.sc_vendor_hw_reset = sdhc_acpi_intel_emmc_hw_reset;
+	if (slot != NULL && ISSET(slot->flags, SDHC_FLAG_ALWAYS_PRESENT))
+		sc->sc.sc_vendor_card_detect = sdhc_acpi_card_detect_always;
 
 	rv = acpi_dsm_query(sc->sc_handle, sdhc_acpi_rockchip_dsm_uuid, 
 	    ROCKCHIP_DSM_REV, &funcs);
Index: sys/dev/sdmmc/sdhcvar.h
===================================================================
RCS file: /cvsroot/src/sys/dev/sdmmc/sdhcvar.h,v
retrieving revision 1.34
diff -u -p -r1.34 sdhcvar.h
--- sys/dev/sdmmc/sdhcvar.h	20 Jan 2024 00:22:11 -0000	1.34
+++ sys/dev/sdmmc/sdhcvar.h	27 Mar 2024 01:23:34 -0000
@@ -52,6 +52,10 @@ struct sdhc_softc {
 #define	SDHC_FLAG_NO_HS_BIT	0x00002000 /* Don't set SDHC_HIGH_SPEED bit */
 #define	SDHC_FLAG_EXTERNAL_DMA	0x00004000
 #define	SDHC_FLAG_EXTDMA_DMAEN	0x00008000 /* ext. dma need SDHC_DMA_ENABLE */
+#define	SDHC_FLAG_ALWAYS_PRESENT \
+				0x00010000 /* slot has no card detect, behave
+					    * as if a card is always present
+					    */
 #define	SDHC_FLAG_NO_CLKBASE	0x00020000 /* ignore clkbase register */
 #define	SDHC_FLAG_SINGLE_POWER_WRITE 0x00040000
 #define	SDHC_FLAG_NO_TIMEOUT	0x00080000 /* ignore timeout interrupts */
@@ -66,6 +70,7 @@ struct sdhc_softc {
 						   * Can't 64K Byte data transfer
 						   */
 #define	SDHC_FLAG_NO_1_8_V	0x08000000 /* No 1.8V supply */
+
 #define	SDHC_FLAG_BROKEN_ADMA	0x10000000 /* ADMA engine does not work */
 
 	uint32_t		sc_clkbase;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.