If the ACPI flag "non-removable" is present and true for an SD/MMC

slot, then set a new flag on that slot to indicate that the media
is non-removable.  Make sdhc_card_detect always return true for a
slot if its non-removable media flag is set.

This change lets the kernel automatically configure the
permanently-installed MMC slot on the NXP LX2160-based HoneyComb
LX2 board.
This commit is contained in:
dyoung 2024-05-09 01:33:12 +00:00
parent 5499b93eb2
commit 0d209957b5
3 changed files with 18 additions and 5 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: sdhc_acpi.c,v 1.20 2022/02/06 15:52:20 jmcneill Exp $ */
/* $NetBSD: sdhc_acpi.c,v 1.21 2024/05/09 01:33:12 dyoung Exp $ */
/*
* Copyright (c) 2016 Kimihiro Nonaka <nonaka@NetBSD.org>
@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sdhc_acpi.c,v 1.20 2022/02/06 15:52:20 jmcneill Exp $");
__KERNEL_RCSID(0, "$NetBSD: sdhc_acpi.c,v 1.21 2024/05/09 01:33:12 dyoung Exp $");
#include <sys/param.h>
#include <sys/device.h>
@ -166,6 +166,7 @@ sdhc_acpi_attach(device_t parent, device_t self, void *opaque)
ACPI_INTEGER clock_freq;
ACPI_INTEGER caps, caps_mask;
ACPI_INTEGER funcs;
bool non_removable;
sc->sc.sc_dev = self;
sc->sc.sc_dmat = aa->aa_dmat;
@ -234,6 +235,11 @@ sdhc_acpi_attach(device_t parent, device_t self, void *opaque)
/* Enable DMA transfer */
sc->sc.sc_flags |= SDHC_FLAG_USE_DMA;
rv = acpi_dsd_bool(aa->aa_node->ad_handle, "non-removable",
&non_removable);
if (ACPI_SUCCESS(rv) && non_removable)
sc->sc.sc_flags |= SDHC_FLAG_NON_REMOVABLE;
/* Read clock frequency from device properties */
rv = acpi_dsd_integer(aa->aa_node->ad_handle, "clock-frequency",
&clock_freq);

View File

@ -1,4 +1,4 @@
/* $NetBSD: sdhc.c,v 1.118 2024/01/20 00:22:11 jmcneill Exp $ */
/* $NetBSD: sdhc.c,v 1.119 2024/05/09 01:33:13 dyoung Exp $ */
/* $OpenBSD: sdhc.c,v 1.25 2009/01/13 19:44:20 grange Exp $ */
/*
@ -23,7 +23,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sdhc.c,v 1.118 2024/01/20 00:22:11 jmcneill Exp $");
__KERNEL_RCSID(0, "$NetBSD: sdhc.c,v 1.119 2024/05/09 01:33:13 dyoung Exp $");
#ifdef _KERNEL_OPT
#include "opt_sdmmc.h"
@ -897,6 +897,9 @@ sdhc_card_detect(sdmmc_chipset_handle_t sch)
struct sdhc_host *hp = (struct sdhc_host *)sch;
int r;
if (ISSET(hp->sc->sc_flags, SDHC_FLAG_NON_REMOVABLE))
return 1;
if (hp->sc->sc_vendor_card_detect)
return (*hp->sc->sc_vendor_card_detect)(hp->sc);

View File

@ -1,4 +1,4 @@
/* $NetBSD: sdhcvar.h,v 1.34 2024/01/20 00:22:11 jmcneill Exp $ */
/* $NetBSD: sdhcvar.h,v 1.35 2024/05/09 01:33:13 dyoung Exp $ */
/* $OpenBSD: sdhcvar.h,v 1.3 2007/09/06 08:01:01 jsg Exp $ */
/*
@ -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_NON_REMOVABLE \
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 */