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 Improved SDHC support for OMAP3.
details: https://anonhg.NetBSD.org/src/rev/d907a903e2c3
branches: trunk
changeset: 783255:d907a903e2c3
user: matt <matt%NetBSD.org@localhost>
date: Wed Dec 12 15:19:53 2012 +0000
description:
Improved SDHC support for OMAP3.
>From jmcneill.
diffstat:
sys/arch/arm/omap/omap3_sdhc.c | 31 +++++++++++++++++++++++++++----
sys/arch/arm/omap/omap3_sdmmcreg.h | 6 +++++-
2 files changed, 32 insertions(+), 5 deletions(-)
diffs (113 lines):
diff -r 09ed84ad1c08 -r d907a903e2c3 sys/arch/arm/omap/omap3_sdhc.c
--- a/sys/arch/arm/omap/omap3_sdhc.c Wed Dec 12 15:15:31 2012 +0000
+++ b/sys/arch/arm/omap/omap3_sdhc.c Wed Dec 12 15:19:53 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: omap3_sdhc.c,v 1.4 2012/12/11 19:26:40 riastradh Exp $ */
+/* $NetBSD: omap3_sdhc.c,v 1.5 2012/12/12 15:19:53 matt 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.4 2012/12/11 19:26:40 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: omap3_sdhc.c,v 1.5 2012/12/12 15:19:53 matt Exp $");
#include "opt_omap.h"
@@ -43,6 +43,7 @@
#include <sys/bus.h>
#include <arm/omap/omap2_obiovar.h>
+#include <arm/omap/omap2_reg.h>
#include <arm/omap/omap3_sdmmcreg.h>
#ifdef TI_AM335X
@@ -64,6 +65,7 @@
static void obiosdhc_attach(device_t, device_t, void *);
static int obiosdhc_detach(device_t, 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 *);
static int obiosdhc_card_detect(struct sdhc_softc *);
@@ -134,6 +136,7 @@
{
struct obiosdhc_softc * const sc = device_private(self);
struct obio_attach_args * const oa = aux;
+ prop_dictionary_t prop = device_properties(self);
uint32_t clkd, stat;
int error, timo, clksft, n;
#ifdef TI_AM335X
@@ -149,10 +152,12 @@
sc->sc.sc_flags |= SDHC_FLAG_SINGLE_ONLY;
sc->sc.sc_host = sc->sc_hosts;
sc->sc.sc_clkbase = 96000; /* 96MHZ */
- sc->sc.sc_clkmsk = 0x0000ffc0;
+ if (!prop_dictionary_get_uint32(prop, "clkmask", &sc->sc.sc_clkmsk))
+ sc->sc.sc_clkmsk = 0x0000ffc0;
sc->sc.sc_vendor_rod = obiosdhc_rod;
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_bst = oa->obio_iot;
clksft = ffs(sc->sc.sc_clkmsk) - 1;
@@ -198,7 +203,8 @@
if (timo == 0)
aprint_error_dev(self, "Soft reset timeout\n");
bus_space_write_4(sc->sc_bst, sc->sc_bsh, MMCHS_SYSCONFIG,
- SYSCONFIG_ENAWAKEUP | SYSCONFIG_AUTOIDLE);
+ SYSCONFIG_ENAWAKEUP | SYSCONFIG_AUTOIDLE | SYSCONFIG_SIDLEMODE_AUTO |
+ SYSCONFIG_CLOCKACTIVITY_FCLK | SYSCONFIG_CLOCKACTIVITY_ICLK);
sc->sc_ih = intr_establish(oa->obio_intr, IPL_VM, IST_LEVEL,
sdhc_intr, &sc->sc);
@@ -340,3 +346,20 @@
/* Maybe board dependent, using GPIO. Get GPIO-pin from prop? */
return 1; /* XXXXXXXX */
}
+
+static int
+obiosdhc_bus_clock(struct sdhc_softc *sc, int clk)
+{
+ struct obiosdhc_softc *osc = (struct obiosdhc_softc *)sc;
+ uint32_t ctl;
+
+ ctl = bus_space_read_4(osc->sc_bst, osc->sc_bsh, MMCHS_SYSCTL);
+ if (clk == 0) {
+ clk &= ~SYSCTL_CEN;
+ } else {
+ clk |= SYSCTL_CEN;
+ }
+ bus_space_write_4(osc->sc_bst, osc->sc_bsh, MMCHS_SYSCTL, ctl);
+
+ return 0;
+}
diff -r 09ed84ad1c08 -r d907a903e2c3 sys/arch/arm/omap/omap3_sdmmcreg.h
--- a/sys/arch/arm/omap/omap3_sdmmcreg.h Wed Dec 12 15:15:31 2012 +0000
+++ b/sys/arch/arm/omap/omap3_sdmmcreg.h Wed Dec 12 15:19:53 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: omap3_sdmmcreg.h,v 1.3 2012/12/11 01:54:43 khorben Exp $ */
+/* $NetBSD: omap3_sdmmcreg.h,v 1.4 2012/12/12 15:19:53 matt Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -46,6 +46,8 @@
# define SYSCONFIG_CLOCKACTIVITY_MASK (3 << 8)
# define SYSCONFIG_CLOCKACTIVITY_FCLK (2 << 8)
# define SYSCONFIG_CLOCKACTIVITY_ICLK (1 << 8)
+# define SYSCONFIG_SIDLEMODE_MASK (3 << 3)
+# define SYSCONFIG_SIDLEMODE_AUTO (2 << 3)
# define SYSCONFIG_ENAWAKEUP (1 << 2)
# define SYSCONFIG_SOFTRESET (1 << 1)
# define SYSCONFIG_AUTOIDLE (1 << 0)
@@ -74,5 +76,7 @@
# define CON_INIT (1 << 1) /* Send init stream */
# define CON_OD (1 << 0) /* Card open drain */
#define MMCHS_PWCNT 0x030 /* Power counter */
+#define MMCHS_SYSCTL 0x12c /* SD system control register */
+# define SYSCTL_CEN (1 << 2) /* Clock enable */
#endif
Home |
Main Index |
Thread Index |
Old Index