Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/arm/omap Support 8-bit eMMC for TI AM335x. On my Be...



details:   https://anonhg.NetBSD.org/src/rev/b37e7489e9de
branches:  trunk
changeset: 811514:b37e7489e9de
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Mon Nov 02 22:21:01 2015 +0000

description:
Support 8-bit eMMC for TI AM335x. On my BeagleBone Black,

Before: 134217728 bytes transferred in 9.410 secs (14263307 bytes/sec)
After:  134217728 bytes transferred in 7.518 secs (17852850 bytes/sec)

diffstat:

 sys/arch/arm/omap/omap3_sdhc.c |  64 ++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 62 insertions(+), 2 deletions(-)

diffs (120 lines):

diff -r 9267583ab1c7 -r b37e7489e9de sys/arch/arm/omap/omap3_sdhc.c
--- a/sys/arch/arm/omap/omap3_sdhc.c    Mon Nov 02 22:18:45 2015 +0000
+++ b/sys/arch/arm/omap/omap3_sdhc.c    Mon Nov 02 22:21:01 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: omap3_sdhc.c,v 1.18 2015/11/01 23:33:05 jmcneill Exp $ */
+/*     $NetBSD: omap3_sdhc.c,v 1.19 2015/11/02 22:21:01 jmcneill Exp $ */
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: omap3_sdhc.c,v 1.18 2015/11/01 23:33:05 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: omap3_sdhc.c,v 1.19 2015/11/02 22:21:01 jmcneill Exp $");
 
 #include "opt_omap.h"
 #include "edma.h"
@@ -51,6 +51,8 @@
 #ifdef TI_AM335X
 #  include <arm/omap/am335x_prcm.h>
 #  include <arm/omap/omap2_prcm.h>
+#  include <arm/omap/sitara_cm.h>
+#  include <arm/omap/sitara_cmreg.h>
 #endif
 
 #if NEDMA > 0
@@ -84,6 +86,7 @@
 static void obiosdhc_attach(device_t, device_t, void *);
 static int obiosdhc_detach(device_t, int);
 
+static int obiosdhc_bus_width(struct sdhc_softc *, int);
 static int obiosdhc_bus_clock(struct sdhc_softc *, int);
 static int obiosdhc_rod(struct sdhc_softc *, int);
 static int obiosdhc_write_protect(struct sdhc_softc *);
@@ -132,6 +135,24 @@
        { "MMC1",   SDMMC2_BASE_TIAM335X, 28, { AM335X_PRCM_CM_PER, 0xf4 } },
        { "MMCHS2", SDMMC3_BASE_TIAM335X, 29, { AM335X_PRCM_CM_WKUP, 0xf8 } },
 };
+
+struct am335x_padconf {
+       const char *padname;
+       const char *padmode;
+};
+const struct am335x_padconf am335x_padconf_mmc1[] = {
+       { "GPMC_CSn1", "mmc1_clk" },
+       { "GPMC_CSn2", "mmc1_cmd" },
+       { "GPMC_AD0", "mmc1_dat0" },
+       { "GPMC_AD1", "mmc1_dat1" },
+       { "GPMC_AD2", "mmc1_dat2" },
+       { "GPMC_AD3", "mmc1_dat3" },
+       { "GPMC_AD4", "mmc1_dat4" },
+       { "GPMC_AD5", "mmc1_dat5" },
+       { "GPMC_AD6", "mmc1_dat6" },
+       { "GPMC_AD7", "mmc1_dat7" },
+       { NULL, NULL }
+};
 #endif
 
 CFATTACH_DECL_NEW(obiosdhc, sizeof(struct obiosdhc_softc),
@@ -216,6 +237,7 @@
        sc->sc.sc_vendor_write_protect = obiosdhc_write_protect;
        sc->sc.sc_vendor_card_detect = obiosdhc_card_detect;
        sc->sc.sc_vendor_bus_clock = obiosdhc_bus_clock;
+       sc->sc.sc_vendor_bus_width = obiosdhc_bus_width;
        sc->sc_bst = oa->obio_iot;
 
        clksft = ffs(sc->sc.sc_clkmsk) - 1;
@@ -261,6 +283,27 @@
                        break;
                }
        KASSERT(i < __arraycount(am335x_sdhc));
+
+       if (oa->obio_addr == SDMMC2_BASE_TIAM335X) {
+               const char *mode;
+               u_int state;
+               
+               const struct am335x_padconf *padconf = am335x_padconf_mmc1;
+               for (i = 0; padconf[i].padname; i++) {
+                       const char *padname = padconf[i].padname;
+                       const char *padmode = padconf[i].padmode;
+                       if (sitara_cm_padconf_get(padname, &mode, &state) == 0) {
+                               aprint_debug_dev(self, "%s mode %s state %d\n",
+                                   padname, mode, state);
+                       }
+                       if (sitara_cm_padconf_set(padname, padmode,
+                           (1 << 4) | (1 << 5)) != 0) {
+                               aprint_error_dev(self, "can't switch %s pad from %s to %s\n",
+                                   padname, mode, padmode);
+                               return;
+                       }
+               }
+       }
 #endif
 
        /* XXXXXX: Turn-on regulator via I2C. */
@@ -422,6 +465,23 @@
 }
 
 static int
+obiosdhc_bus_width(struct sdhc_softc *sc, int width)
+{
+       struct obiosdhc_softc *osc = (struct obiosdhc_softc *)sc;
+       uint32_t con;
+
+       con = bus_space_read_4(osc->sc_bst, osc->sc_bsh, MMCHS_CON);
+       if (width == 8) {
+               con |= CON_DW8;
+       } else {
+               con &= ~CON_DW8;
+       }
+       bus_space_write_4(osc->sc_bst, osc->sc_bsh, MMCHS_CON, con);
+
+       return 0;
+}
+
+static int
 obiosdhc_bus_clock(struct sdhc_softc *sc, int clk)
 {
        struct obiosdhc_softc *osc = (struct obiosdhc_softc *)sc;



Home | Main Index | Thread Index | Old Index