From owner-svn-src-all@FreeBSD.ORG Fri Apr 4 00:59:41 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 46888254; Fri, 4 Apr 2014 00:59:41 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2D10730D; Fri, 4 Apr 2014 00:59:41 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s340xfiZ090439; Fri, 4 Apr 2014 00:59:41 GMT (envelope-from ian@svn.freebsd.org) Received: (from ian@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s340xeYk090436; Fri, 4 Apr 2014 00:59:40 GMT (envelope-from ian@svn.freebsd.org) Message-Id: <201404040059.s340xeYk090436@svn.freebsd.org> From: Ian Lepore Date: Fri, 4 Apr 2014 00:59:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r264096 - in head/sys: arm/ti boot/fdt/dts/arm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Apr 2014 00:59:41 -0000 Author: ian Date: Fri Apr 4 00:59:40 2014 New Revision: 264096 URL: http://svnweb.freebsd.org/changeset/base/264096 Log: Various fixes to the ti_sdhci driver, mostly to make it work on Pandaboard. - Don't allow high-speed mode on OMAP4 due to hardware erratum. - Check the proper bit in the status register when waiting for the controller to come out of reset. - Add handling for the "non-removable" fdt property by always returning "card is present" status. - Add the non-removable property for the MMC card on a Beaglebone Black. - Add the non-removable property for Pandaboard as a workaround. For Pandaboard the card detect pin is handled by the twl6030 fpga device which gets an interrupt on pin change and then has to query the fpga for the actual status. We don't have code to do that yet. Submitted by: Svatopluk Kraus Modified: head/sys/arm/ti/ti_sdhci.c head/sys/boot/fdt/dts/arm/beaglebone-black.dts head/sys/boot/fdt/dts/arm/pandaboard.dts Modified: head/sys/arm/ti/ti_sdhci.c ============================================================================== --- head/sys/arm/ti/ti_sdhci.c Fri Apr 4 00:16:46 2014 (r264095) +++ head/sys/arm/ti/ti_sdhci.c Fri Apr 4 00:59:40 2014 (r264096) @@ -72,6 +72,8 @@ struct ti_sdhci_softc { uint32_t wp_gpio_pin; uint32_t cmd_and_mode; uint32_t sdhci_clkdiv; + boolean_t disable_highspeed; + boolean_t force_card_present; }; /* @@ -105,6 +107,7 @@ static struct ofw_compat_data compat_dat #define MMCHS_SYSCONFIG 0x010 #define MMCHS_SYSCONFIG_RESET (1 << 1) #define MMCHS_SYSSTATUS 0x014 +#define MMCHS_SYSSTATUS_RESETDONE (1 << 0) #define MMCHS_CON 0x02C #define MMCHS_CON_DW8 (1 << 5) #define MMCHS_CON_DVAL_8_4MS (3 << 9) @@ -193,8 +196,24 @@ static uint32_t ti_sdhci_read_4(device_t dev, struct sdhci_slot *slot, bus_size_t off) { struct ti_sdhci_softc *sc = device_get_softc(dev); + uint32_t val32; + + val32 = RD4(sc, off); + + /* + * If we need to disallow highspeed mode due to the OMAP4 erratum, strip + * that flag from the returned capabilities. + */ + if (off == SDHCI_CAPABILITIES && sc->disable_highspeed) + val32 &= ~SDHCI_CAN_DO_HISPD; + + /* + * Force the card-present state if necessary. + */ + if (off == SDHCI_PRESENT_STATE && sc->force_card_present) + val32 |= SDHCI_CARD_PRESENT; - return (RD4(sc, off)); + return (val32); } static void @@ -358,7 +377,7 @@ ti_sdhci_hw_init(device_t dev) /* Issue a softreset to the controller */ ti_mmchs_write_4(sc, MMCHS_SYSCONFIG, MMCHS_SYSCONFIG_RESET); timeout = 1000; - while ((ti_mmchs_read_4(sc, MMCHS_SYSSTATUS) & MMCHS_SYSCONFIG_RESET)) { + while (!(ti_mmchs_read_4(sc, MMCHS_SYSSTATUS) & MMCHS_SYSSTATUS_RESETDONE)) { if (--timeout == 0) { device_printf(dev, "Error: Controller reset operation timed out\n"); break; @@ -458,12 +477,14 @@ ti_sdhci_attach(device_t dev) /* * Set the offset from the device's memory start to the MMCHS registers. + * Also for OMAP4 disable high speed mode due to erratum ID i626. */ if (ti_chip() == CHIP_OMAP_3) sc->mmchs_reg_off = OMAP3_MMCHS_REG_OFFSET; - else if (ti_chip() == CHIP_OMAP_4) + else if (ti_chip() == CHIP_OMAP_4) { sc->mmchs_reg_off = OMAP4_MMCHS_REG_OFFSET; - else if (ti_chip() == CHIP_AM335X) + sc->disable_highspeed = true; + } else if (ti_chip() == CHIP_AM335X) sc->mmchs_reg_off = AM335X_MMCHS_REG_OFFSET; else panic("Unknown OMAP device\n"); @@ -560,6 +581,14 @@ ti_sdhci_attach(device_t dev) } } + /* + * If the slot is flagged with the non-removable property, set our flag + * to always force the SDHCI_CARD_PRESENT bit on. + */ + node = ofw_bus_get_node(dev); + if (OF_hasprop(node, "non-removable")) + sc->force_card_present = true; + bus_generic_probe(dev); bus_generic_attach(dev); Modified: head/sys/boot/fdt/dts/arm/beaglebone-black.dts ============================================================================== --- head/sys/boot/fdt/dts/arm/beaglebone-black.dts Fri Apr 4 00:16:46 2014 (r264095) +++ head/sys/boot/fdt/dts/arm/beaglebone-black.dts Fri Apr 4 00:59:40 2014 (r264096) @@ -142,6 +142,7 @@ mmchs1@481D8000 { bus-width = <8>; status = "okay"; + non-removable; }; Modified: head/sys/boot/fdt/dts/arm/pandaboard.dts ============================================================================== --- head/sys/boot/fdt/dts/arm/pandaboard.dts Fri Apr 4 00:16:46 2014 (r264095) +++ head/sys/boot/fdt/dts/arm/pandaboard.dts Fri Apr 4 00:59:40 2014 (r264096) @@ -174,6 +174,7 @@ interrupts = <115>; interrupt-parent = <&GIC>; mmchs-device-id = <1>; + non-removable; /* XXX need real solution */ }; };