Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch We have two SD controllers with different capabilit...
details: https://anonhg.NetBSD.org/src/rev/64ec2820271a
branches: trunk
changeset: 339757:64ec2820271a
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Sat Aug 08 14:01:44 2015 +0000
description:
We have two SD controllers with different capabilities. Use the fast "SDHC"
controller for the card that the bootloader marked as the boot device,
and the slower "SDIO" controller for the other card if present.
The controller to slot mappings can be wired down in the kernel config
with the "port" locator if necessary.
diffstat:
sys/arch/arm/amlogic/amlogic_io.c | 12 ++++--------
sys/arch/arm/amlogic/amlogic_sdhc.c | 33 +++++++++++++++++++++------------
sys/arch/arm/amlogic/amlogic_sdio.c | 33 +++++++++++++++++++++------------
sys/arch/evbarm/conf/ODROID-C1 | 12 +++++++-----
4 files changed, 53 insertions(+), 37 deletions(-)
diffs (221 lines):
diff -r 67752a1048e9 -r 64ec2820271a sys/arch/arm/amlogic/amlogic_io.c
--- a/sys/arch/arm/amlogic/amlogic_io.c Sat Aug 08 13:54:05 2015 +0000
+++ b/sys/arch/arm/amlogic/amlogic_io.c Sat Aug 08 14:01:44 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: amlogic_io.c,v 1.11 2015/04/25 14:41:33 jmcneill Exp $ */
+/* $NetBSD: amlogic_io.c,v 1.12 2015/08/08 14:01:44 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -29,7 +29,7 @@
#include "opt_amlogic.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: amlogic_io.c,v 1.11 2015/04/25 14:41:33 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amlogic_io.c,v 1.12 2015/08/08 14:01:44 jmcneill Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -76,13 +76,9 @@
{ "awge",
AMLOGIC_GMAC_OFFSET, AMLOGIC_GMAC_SIZE, NOPORT, AMLOGIC_INTR_GMAC },
{ "amlogicsdio",
- AMLOGIC_SDIO_OFFSET, AMLOGIC_SDIO_SIZE, 1, AMLOGIC_INTR_SDIO },
- { "amlogicsdio",
- AMLOGIC_SDIO_OFFSET, AMLOGIC_SDIO_SIZE, 2, AMLOGIC_INTR_SDIO },
+ AMLOGIC_SDIO_OFFSET, AMLOGIC_SDIO_SIZE, NOPORT, AMLOGIC_INTR_SDIO },
{ "amlogicsdhc",
- AMLOGIC_SDHC_OFFSET, AMLOGIC_SDHC_SIZE, 1, AMLOGIC_INTR_SDHC },
- { "amlogicsdhc",
- AMLOGIC_SDHC_OFFSET, AMLOGIC_SDHC_SIZE, 2, AMLOGIC_INTR_SDHC },
+ AMLOGIC_SDHC_OFFSET, AMLOGIC_SDHC_SIZE, NOPORT, AMLOGIC_INTR_SDHC },
{ "amlogicrtc",
AMLOGIC_RTC_OFFSET, AMLOGIC_RTC_SIZE, NOPORT, AMLOGIC_INTR_RTC },
};
diff -r 67752a1048e9 -r 64ec2820271a sys/arch/arm/amlogic/amlogic_sdhc.c
--- a/sys/arch/arm/amlogic/amlogic_sdhc.c Sat Aug 08 13:54:05 2015 +0000
+++ b/sys/arch/arm/amlogic/amlogic_sdhc.c Sat Aug 08 14:01:44 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: amlogic_sdhc.c,v 1.8 2015/08/08 10:51:50 jmcneill Exp $ */
+/* $NetBSD: amlogic_sdhc.c,v 1.9 2015/08/08 14:01:44 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -29,7 +29,7 @@
#include "locators.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: amlogic_sdhc.c,v 1.8 2015/08/08 10:51:50 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amlogic_sdhc.c,v 1.9 2015/08/08 14:01:44 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -69,7 +69,7 @@
bus_dma_segment_t sc_segs[1];
void *sc_bbuf;
- u_int sc_port;
+ int sc_port;
int sc_signal_voltage;
};
@@ -121,12 +121,6 @@
static int
amlogic_sdhc_match(device_t parent, cfdata_t cf, void *aux)
{
- struct amlogicio_attach_args * const aio = aux;
- const struct amlogic_locators * const loc = &aio->aio_loc;
-
- if (loc->loc_port == AMLOGICIOCF_PORT_DEFAULT)
- return 0;
-
return 1;
}
@@ -136,6 +130,8 @@
struct amlogic_sdhc_softc * const sc = device_private(self);
struct amlogicio_attach_args * const aio = aux;
const struct amlogic_locators * const loc = &aio->aio_loc;
+ prop_dictionary_t cfg = device_properties(self);
+ uint32_t boot_id;
sc->sc_dev = self;
sc->sc_bst = aio->aio_core_bst;
@@ -147,14 +143,27 @@
sc->sc_port = loc->loc_port;
sc->sc_signal_voltage = SDMMC_SIGNAL_VOLTAGE_330;
+ if (sc->sc_port == AMLOGICIOCF_PORT_DEFAULT) {
+ if (!prop_dictionary_get_uint32(cfg, "boot_id", &boot_id)) {
+ aprint_error(": no port selected\n");
+ return;
+ }
+ /* Booted device goes on SDHC controller */
+ if (boot_id == 0) {
+ sc->sc_port = AMLOGIC_SDHC_PORT_C; /* eMMC */
+ } else {
+ sc->sc_port = AMLOGIC_SDHC_PORT_B; /* SD card */
+ }
+ }
+
amlogic_sdhc_init();
- if (amlogic_sdhc_select_port(loc->loc_port) != 0) {
- aprint_error(": couldn't select port %d\n", loc->loc_port);
+ if (amlogic_sdhc_select_port(sc->sc_port) != 0) {
+ aprint_error(": couldn't select port %d\n", sc->sc_port);
return;
}
aprint_naive("\n");
- aprint_normal(": SDHC controller\n");
+ aprint_normal(": SDHC controller (port %c)\n", sc->sc_port + 'A');
sc->sc_ih = intr_establish(loc->loc_intr, IPL_BIO, IST_EDGE,
amlogic_sdhc_intr, sc);
diff -r 67752a1048e9 -r 64ec2820271a sys/arch/arm/amlogic/amlogic_sdio.c
--- a/sys/arch/arm/amlogic/amlogic_sdio.c Sat Aug 08 13:54:05 2015 +0000
+++ b/sys/arch/arm/amlogic/amlogic_sdio.c Sat Aug 08 14:01:44 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: amlogic_sdio.c,v 1.3 2015/08/08 10:55:14 jmcneill Exp $ */
+/* $NetBSD: amlogic_sdio.c,v 1.4 2015/08/08 14:01:44 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -29,7 +29,7 @@
#include "locators.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: amlogic_sdio.c,v 1.3 2015/08/08 10:55:14 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amlogic_sdio.c,v 1.4 2015/08/08 14:01:44 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -61,7 +61,7 @@
uint32_t sc_bus_freq;
u_int sc_cur_width;
- u_int sc_cur_port;
+ int sc_cur_port;
device_t sc_sdmmc_dev;
kmutex_t sc_intr_lock;
@@ -119,12 +119,6 @@
static int
amlogic_sdio_match(device_t parent, cfdata_t cf, void *aux)
{
- struct amlogicio_attach_args * const aio = aux;
- const struct amlogic_locators * const loc = &aio->aio_loc;
-
- if (loc->loc_port == AMLOGICIOCF_PORT_DEFAULT)
- return 0;
-
return 1;
}
@@ -134,6 +128,8 @@
struct amlogic_sdio_softc * const sc = device_private(self);
struct amlogicio_attach_args * const aio = aux;
const struct amlogic_locators * const loc = &aio->aio_loc;
+ prop_dictionary_t cfg = device_properties(self);
+ uint32_t boot_id;
sc->sc_dev = self;
sc->sc_bst = aio->aio_core_bst;
@@ -144,14 +140,27 @@
mutex_init(&sc->sc_intr_lock, MUTEX_DEFAULT, IPL_BIO);
cv_init(&sc->sc_intr_cv, "sdiointr");
+ if (sc->sc_cur_port == AMLOGICIOCF_PORT_DEFAULT) {
+ if (!prop_dictionary_get_uint32(cfg, "boot_id", &boot_id)) {
+ aprint_error(": no port selected\n");
+ return;
+ }
+ /* Non-booted device goes on SDIO controller */
+ if (boot_id == 0) {
+ sc->sc_cur_port = AMLOGIC_SDIO_PORT_B; /* SD card */
+ } else {
+ sc->sc_cur_port = AMLOGIC_SDIO_PORT_C; /* eMMC */
+ }
+ }
+
amlogic_sdio_init();
- if (amlogic_sdio_select_port(loc->loc_port) != 0) {
- aprint_error(": couldn't select port %d\n", loc->loc_port);
+ if (amlogic_sdio_select_port(sc->sc_cur_port) != 0) {
+ aprint_error(": couldn't select port %d\n", sc->sc_cur_port);
return;
}
aprint_naive("\n");
- aprint_normal(": SDIO controller\n");
+ aprint_normal(": SDIO controller (port %c)\n", sc->sc_cur_port + 'A');
sc->sc_ih = intr_establish(loc->loc_intr, IPL_BIO, IST_EDGE,
amlogic_sdio_intr, sc);
diff -r 67752a1048e9 -r 64ec2820271a sys/arch/evbarm/conf/ODROID-C1
--- a/sys/arch/evbarm/conf/ODROID-C1 Sat Aug 08 13:54:05 2015 +0000
+++ b/sys/arch/evbarm/conf/ODROID-C1 Sat Aug 08 14:01:44 2015 +0000
@@ -1,5 +1,5 @@
#
-# $NetBSD: ODROID-C1,v 1.19 2015/08/08 10:56:55 jmcneill Exp $
+# $NetBSD: ODROID-C1,v 1.20 2015/08/08 14:01:44 jmcneill Exp $
#
# Hardkernel ODROID-C1 (Amlogic S805) based SBC (Single Board Computer)
#
@@ -63,10 +63,12 @@
amlogicrtc0 at amlogicio0
# SDHC controller
-amlogicsdhc0 at amlogicio0 port 1
-sdmmc* at amlogicsdhc?
-amlogicsdio0 at amlogicio0 port 2
-sdmmc* at amlogicsdio?
+amlogicsdhc0 at amlogicio0
+amlogicsdio0 at amlogicio0
+sdmmc0 at amlogicsdhc0
+sdmmc1 at amlogicsdio0
+ld0 at sdmmc0
+ld1 at sdmmc1
ld* at sdmmc?
# Gigabit ethernet
Home |
Main Index |
Thread Index |
Old Index