[PATCH 6/7] SD Card : Changes over the initial commit for SD
Mudit Jain
muditjain18011995 at gmail.com
Sun Aug 28 07:25:11 UTC 2016
---
freebsd/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c | 19 +++++++++++++++++
freebsd/sys/dev/sdhci/sdhci.c | 19 +++++++++++++++++
freebsd/sys/dev/sdhci/sdhci.h | 5 +++++
libbsd_waf.py | 1 +
rtemsbsd/include/bsp/nexus-devices.h | 3 +++
rtemsbsd/include/machine/rtems-bsd-nexus-bus.h | 26 ++++++++++++++++++++++++
6 files changed, 73 insertions(+)
diff --git a/freebsd/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c b/freebsd/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c
index 4844f19..2e8290a 100644
--- a/freebsd/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c
+++ b/freebsd/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c
@@ -43,9 +43,11 @@ __FBSDID("$FreeBSD$");
#include <machine/bus.h>
+#ifndef __rtems__
#include <dev/fdt/fdt_common.h>
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
+#endif /* __rtems__ */
#include <dev/mmc/bridge.h>
#include <dev/mmc/mmcreg.h>
@@ -55,7 +57,9 @@ __FBSDID("$FreeBSD$");
#include <rtems/bsd/local/sdhci_if.h>
#include "bcm2835_dma.h"
+#ifndef __rtems__
#include <arm/broadcom/bcm2835/bcm2835_mbox_prop.h>
+#endif /* __rtems__ */
#include "bcm2835_vcbus.h"
#define BCM2835_DEFAULT_SDHCI_FREQ 50
@@ -125,11 +129,13 @@ static int
bcm_sdhci_probe(device_t dev)
{
+#ifndef __rtems__
if (!ofw_bus_status_okay(dev))
return (ENXIO);
if (!ofw_bus_is_compatible(dev, "broadcom,bcm2835-sdhci"))
return (ENXIO);
+#endif /* __rtems__ */
device_set_desc(dev, "Broadcom 2708 SDHCI controller");
return (BUS_PROBE_DEFAULT);
@@ -140,13 +146,17 @@ bcm_sdhci_attach(device_t dev)
{
struct bcm_sdhci_softc *sc = device_get_softc(dev);
int rid, err;
+#ifndef __rtems__
phandle_t node;
pcell_t cell;
+#endif /* __rtems__ */
+
u_int default_freq;
sc->sc_dev = dev;
sc->sc_req = NULL;
+#ifndef __rtems__
err = bcm2835_mbox_set_power_state(BCM2835_MBOX_POWER_ID_EMMC,
TRUE);
if (err != 0) {
@@ -168,6 +178,7 @@ bcm_sdhci_attach(device_t dev)
sizeof(cell))) > 0)
default_freq = cell / 1000000;
}
+#endif /* __rtems__ */
if (default_freq == 0)
default_freq = BCM2835_DEFAULT_SDHCI_FREQ;
@@ -216,6 +227,7 @@ bcm_sdhci_attach(device_t dev)
sdhci_init_slot(dev, &sc->sc_slot, 0);
+#ifndef __rtems__
sc->sc_dma_ch = bcm_dma_allocate(BCM_DMA_CH_ANY);
if (sc->sc_dma_ch == BCM_DMA_CH_INVALID)
goto fail;
@@ -243,6 +255,7 @@ bcm_sdhci_attach(device_t dev)
sc->sc_sdhci_buffer_phys = BUS_SPACE_PHYSADDR(sc->sc_mem_res,
SDHCI_BUFFER);
+#endif /* __rtems__ */
bus_generic_probe(dev);
bus_generic_attach(dev);
@@ -671,7 +684,13 @@ static driver_t bcm_sdhci_driver = {
sizeof(struct bcm_sdhci_softc),
};
+#ifndef __rtems__
DRIVER_MODULE(sdhci_bcm, simplebus, bcm_sdhci_driver, bcm_sdhci_devclass, 0, 0);
MODULE_DEPEND(sdhci_bcm, sdhci, 1, 1, 1);
+#else /* __rtems__ */
+DRIVER_MODULE(sdhci_bcm, nexus, bcm_sdhci_driver, bcm_sdhci_devclass, 0, 0);
+MODULE_DEPEND(sdhci_bcm, sdhci, 1, 1, 1);
DRIVER_MODULE(mmc, sdhci_bcm, mmc_driver, mmc_devclass, NULL, NULL);
MODULE_DEPEND(sdhci_bcm, mmc, 1, 1, 1);
+#endif /* __rtems__ */
+
diff --git a/freebsd/sys/dev/sdhci/sdhci.c b/freebsd/sys/dev/sdhci/sdhci.c
index 6ba9777..1ad7d5d 100644
--- a/freebsd/sys/dev/sdhci/sdhci.c
+++ b/freebsd/sys/dev/sdhci/sdhci.c
@@ -482,7 +482,11 @@ sdhci_card_delay(void *arg)
{
struct sdhci_slot *slot = arg;
+#ifndef __rtems__
taskqueue_enqueue(taskqueue_swi_giant, &slot->card_task);
+#else /* __rtems__ */
+ taskqueue_enqueue(slot->sdhci_tq, &slot->card_task);
+#endif /* __rtems__ */
}
static void
@@ -602,7 +606,11 @@ sdhci_init_slot(device_t dev, struct sdhci_slot *slot, int num)
slot->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;
}
+#ifndef __rtems__
slot->host.f_min = SDHCI_MIN_FREQ(slot->bus, slot);
+#else /* __rtems__ */
+ slot->host.f_min = 400000;
+#endif /* __rtems__ */
slot->host.f_max = slot->max_clk;
slot->host.host_ocr = 0;
if (caps & SDHCI_CAN_VDD_330)
@@ -650,10 +658,12 @@ sdhci_init_slot(device_t dev, struct sdhci_slot *slot, int num)
}
slot->timeout = 10;
+#ifndef __rtems__
SYSCTL_ADD_INT(device_get_sysctl_ctx(slot->bus),
SYSCTL_CHILDREN(device_get_sysctl_tree(slot->bus)), OID_AUTO,
"timeout", CTLFLAG_RW, &slot->timeout, 0,
"Maximum timeout for SDHCI transfers (in secs)");
+#endif
TASK_INIT(&slot->card_task, 0, sdhci_card_task, slot);
callout_init(&slot->card_callout, 1);
callout_init_mtx(&slot->timeout_callout, &slot->mtx, 0);
@@ -674,7 +684,11 @@ sdhci_cleanup_slot(struct sdhci_slot *slot)
callout_drain(&slot->timeout_callout);
callout_drain(&slot->card_callout);
+#ifndef __rtems__
taskqueue_drain(taskqueue_swi_giant, &slot->card_task);
+#else /* __rtems__ */
+ taskqueue_drain(slot->sdhci_tq, &slot->card_task);
+#endif /* __rtems__ */
SDHCI_LOCK(slot);
d = slot->dev;
@@ -1332,8 +1346,13 @@ sdhci_generic_intr(struct sdhci_slot *slot)
if (bootverbose || sdhci_debug)
slot_printf(slot, "Card removed\n");
callout_stop(&slot->card_callout);
+#ifndef __rtems__
taskqueue_enqueue(taskqueue_swi_giant,
&slot->card_task);
+#else /* __rtems__ */
+ taskqueue_enqueue(slot->sdhci_tq,
+ &slot->card_task);
+#endif /* __rtems__ */
}
if (intmask & SDHCI_INT_CARD_INSERT) {
if (bootverbose || sdhci_debug)
diff --git a/freebsd/sys/dev/sdhci/sdhci.h b/freebsd/sys/dev/sdhci/sdhci.h
index 2638b4f..b63cf7d 100644
--- a/freebsd/sys/dev/sdhci/sdhci.h
+++ b/freebsd/sys/dev/sdhci/sdhci.h
@@ -273,7 +273,11 @@ struct sdhci_slot {
device_t dev; /* Slot device */
u_char num; /* Slot number */
u_char opt; /* Slot options */
+#ifndef __rtems__
#define SDHCI_HAVE_DMA 1
+#else /* rtems */
+#define SDHCI_HAVE_DMA 0
+#endif /* __rtems__ */
#define SDHCI_PLATFORM_TRANSFER 2
u_char version;
int timeout; /* Transfer timeout */
@@ -284,6 +288,7 @@ struct sdhci_slot {
u_char *dmamem;
bus_addr_t paddr; /* DMA buffer address */
struct task card_task; /* Card presence check task */
+ struct taskqueue *sdhci_tq;
struct callout card_callout; /* Card insert delay callout */
struct callout timeout_callout;/* Card command/data response timeout */
struct mmc_host host; /* Host parameters */
diff --git a/libbsd_waf.py b/libbsd_waf.py
index 63cf7d2..f6aee63 100644
--- a/libbsd_waf.py
+++ b/libbsd_waf.py
@@ -1047,6 +1047,7 @@ def build(bld):
'rtemsbsd/local/mmcbus_if.c',
'rtemsbsd/local/pci_if.c',
'rtemsbsd/local/pcib_if.c',
+ 'rtemsbsd/local/sdhci_if.c',
'rtemsbsd/local/usb_if.c',
'rtemsbsd/mdns/mdns-hostname-default.c',
'rtemsbsd/mdns/mdns.c',
diff --git a/rtemsbsd/include/bsp/nexus-devices.h b/rtemsbsd/include/bsp/nexus-devices.h
index cbffcf6..3040c5b 100644
--- a/rtemsbsd/include/bsp/nexus-devices.h
+++ b/rtemsbsd/include/bsp/nexus-devices.h
@@ -100,6 +100,9 @@ RTEMS_BSD_DRIVER_TSEC(0xffeb0000,
#include <bsp/raspberrypi.h>
#include <bsp/irq.h>
+RTEMS_BSD_DRIVER_BCM2835_SD((unsigned long)BCM2835_EMMC_BASE, 62);
+RTEMS_BSD_DRIVER_BCM2835_SDHCI;
+RTEMS_BSD_DRIVER_MMC;
RTEMS_BSD_DRIVER_BCM2835_DMA((unsigned long)0x20007000, 16);
#endif
diff --git a/rtemsbsd/include/machine/rtems-bsd-nexus-bus.h b/rtemsbsd/include/machine/rtems-bsd-nexus-bus.h
index 25688a0..d92f68a 100644
--- a/rtemsbsd/include/machine/rtems-bsd-nexus-bus.h
+++ b/rtemsbsd/include/machine/rtems-bsd-nexus-bus.h
@@ -172,6 +172,32 @@ extern "C" {
#endif /* RTEMS_BSD_DRIVER_MMC */
/*
+ * [BCM2835] Raspberry Pi Arasan SDHCI Controller
+ */
+#if !defined(RTEMS_BSD_DRIVER_BCM2835_SDHCI)
+ #define RTEMS_BSD_DRIVER_BCM2835_SDHCI \
+ SYSINIT_DRIVER_REFERENCE(mmc, sdhci_bcm)
+#endif
+
+#if !defined(RTEMS_BSD_DRIVER_BCM2835_SD)
+ #define RTEMS_BSD_DRIVER_BCM2835_SD(_base, _irq) \
+ static const rtems_bsd_device_resource rpi_emmc_res[] = { \
+ { \
+ .type = RTEMS_BSD_RES_MEMORY, \
+ .start_request = 0, \
+ .start_actual = (_base) \
+ }, { \
+ .type = RTEMS_BSD_RES_IRQ, \
+ .start_request = 0, \
+ .start_actual = (_irq) \
+ } \
+ }; \
+ RTEMS_BSD_DEFINE_NEXUS_DEVICE(sdhci_bcm, 0, \
+ RTEMS_ARRAY_SIZE(rpi_emmc_res),\
+ &rpi_emmc_res[0])
+#endif /* RTEMS_BSD_DRIVER_BCM2835_SD */
+
+/*
* [BCM2835] Raspberry Pi DMA Controller
*/
#if !defined(RTEMS_BSD_DRIVER_BCM2835_DMA)
--
2.1.4
More information about the devel
mailing list