From owner-svn-src-all@FreeBSD.ORG Sat Oct 11 13:05:13 2008 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F0FD8106569E; Sat, 11 Oct 2008 13:05:13 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E0FC18FC13; Sat, 11 Oct 2008 13:05:13 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id m9BD5DxE018781; Sat, 11 Oct 2008 13:05:13 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9BD5DZs018778; Sat, 11 Oct 2008 13:05:13 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <200810111305.m9BD5DZs018778@svn.freebsd.org> From: Alexander Motin Date: Sat, 11 Oct 2008 13:05:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r183763 - head/sys/dev/mmc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 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: Sat, 11 Oct 2008 13:05:14 -0000 Author: mav Date: Sat Oct 11 13:05:13 2008 New Revision: 183763 URL: http://svn.freebsd.org/changeset/base/183763 Log: Give mmcsd driver a bit more information about card. It allows to reorganize log message in a way a bit more common for disk devices. Also it will allow mmcsd driver to use MMC/SD specific commands when needed. Modified: head/sys/dev/mmc/mmc.c head/sys/dev/mmc/mmcsd.c head/sys/dev/mmc/mmcvar.h Modified: head/sys/dev/mmc/mmc.c ============================================================================== --- head/sys/dev/mmc/mmc.c Sat Oct 11 12:10:23 2008 (r183762) +++ head/sys/dev/mmc/mmc.c Sat Oct 11 13:05:13 2008 (r183763) @@ -115,6 +115,7 @@ static int mmc_detach(device_t dev); #define MMC_ASSERT_LOCKED(_sc) mtx_assert(&_sc->sc_mtx, MA_OWNED); #define MMC_ASSERT_UNLOCKED(_sc) mtx_assert(&_sc->sc_mtx, MA_NOTOWNED); +static int mmc_calculate_clock(struct mmc_softc *sc); static void mmc_delayed_attach(void *); static void mmc_power_down(struct mmc_softc *sc); static int mmc_wait_for_cmd(struct mmc_softc *sc, struct mmc_command *cmd, @@ -122,7 +123,7 @@ static int mmc_wait_for_cmd(struct mmc_s static int mmc_wait_for_command(struct mmc_softc *sc, uint32_t opcode, uint32_t arg, uint32_t flags, uint32_t *resp, int retries); static int mmc_select_card(struct mmc_softc *sc, uint16_t rca); -static int mmc_set_bus_width(struct mmc_softc *sc, uint16_t rca, int width); +static int mmc_set_card_bus_width(struct mmc_softc *sc, uint16_t rca, int width); static int mmc_app_send_scr(struct mmc_softc *sc, uint16_t rca, uint32_t *rawscr); static void mmc_app_decode_scr(uint32_t *raw_scr, struct mmc_scr *scr); static int mmc_send_ext_csd(struct mmc_softc *sc, uint8_t *rawextcsd); @@ -215,11 +216,13 @@ mmc_acquire_bus(device_t busdev, device_ sc->last_rca = rca; /* Prepare bus width for the new card. */ ivar = device_get_ivars(dev); - device_printf(busdev, - "setting bus width to %d bits\n", - (ivar->bus_width == bus_width_4)?4: - (ivar->bus_width == bus_width_8)?8:1); - mmc_set_bus_width(sc, rca, ivar->bus_width); + if (bootverbose) { + device_printf(busdev, + "setting bus width to %d bits\n", + (ivar->bus_width == bus_width_4)?4: + (ivar->bus_width == bus_width_8)?8:1); + } + mmc_set_card_bus_width(sc, rca, ivar->bus_width); mmcbr_set_bus_width(busdev, ivar->bus_width); mmcbr_update_ios(busdev); } @@ -571,7 +574,7 @@ mmc_sd_switch(struct mmc_softc *sc, uint } static int -mmc_set_bus_width(struct mmc_softc *sc, uint16_t rca, int width) +mmc_set_card_bus_width(struct mmc_softc *sc, uint16_t rca, int width) { int err; @@ -1167,6 +1170,7 @@ mmc_go_discovery(struct mmc_softc *sc) mmcbr_set_bus_mode(dev, pushpull); mmcbr_update_ios(dev); + mmc_calculate_clock(sc); bus_generic_attach(dev); /* mmc_update_children_sysctl(dev);*/ } @@ -1208,9 +1212,11 @@ mmc_calculate_clock(struct mmc_softc *sc free(kids, M_TEMP); if (max_timing == bus_timing_hs) max_dtr = max_hs_dtr; - device_printf(sc->dev, "setting transfer rate to %d.%03dMHz%s\n", - max_dtr / 1000000, (max_dtr / 1000) % 1000, - (max_timing == bus_timing_hs)?" with high speed timing":""); + if (bootverbose) { + device_printf(sc->dev, "setting transfer rate to %d.%03dMHz%s\n", + max_dtr / 1000000, (max_dtr / 1000) % 1000, + (max_timing == bus_timing_hs)?" with high speed timing":""); + } mmcbr_set_timing(sc->dev, max_timing); mmcbr_set_clock(sc->dev, max_dtr); mmcbr_update_ios(sc->dev); @@ -1228,7 +1234,6 @@ mmc_scan(struct mmc_softc *sc) if (mmcbr_get_power_mode(dev) == power_on) mmc_rescan_cards(sc); mmc_go_discovery(sc); - mmc_calculate_clock(sc); mmc_release_bus(dev, dev); /* XXX probe/attach/detach children? */ @@ -1255,7 +1260,7 @@ mmc_read_ivar(device_t bus, device_t chi *(int *)result = MMC_SECTOR_SIZE; break; case MMC_IVAR_TRAN_SPEED: - *(int *)result = ivar->csd.tran_speed; + *(int *)result = mmcbr_get_clock(bus); break; case MMC_IVAR_READ_ONLY: *(int *)result = ivar->read_only; @@ -1263,6 +1268,12 @@ mmc_read_ivar(device_t bus, device_t chi case MMC_IVAR_HIGH_CAP: *(int *)result = ivar->high_cap; break; + case MMC_IVAR_CARD_TYPE: + *(int *)result = ivar->mode; + break; + case MMC_IVAR_BUS_WIDTH: + *(int *)result = ivar->bus_width; + break; } return (0); } Modified: head/sys/dev/mmc/mmcsd.c ============================================================================== --- head/sys/dev/mmc/mmcsd.c Sat Oct 11 12:10:23 2008 (r183762) +++ head/sys/dev/mmc/mmcsd.c Sat Oct 11 13:05:13 2008 (r183763) @@ -133,10 +133,15 @@ mmcsd_attach(device_t dev) mmc_get_sector_size(dev); sc->disk->d_unit = device_get_unit(dev); - device_printf(dev, "%juMB %s at %s\n", + device_printf(dev, "%juMB <%s Memory Card>%s at %s %dMHz/%dbit\n", sc->disk->d_mediasize / 1048576, + (mmc_get_card_type(dev) == mode_mmc)?"MMC": + (mmc_get_high_cap(dev)?"SDHC":"SD"), mmc_get_read_only(dev)?" (read-only)":"", - device_get_nameunit(device_get_parent(sc->dev))); + device_get_nameunit(device_get_parent(sc->dev)), + mmc_get_tran_speed(dev)/1000000, + (mmc_get_bus_width(dev) == bus_width_1)?1: + ((mmc_get_bus_width(dev) == bus_width_4)?4:8)); disk_create(sc->disk, DISK_VERSION); bioq_init(&sc->bio_queue); Modified: head/sys/dev/mmc/mmcvar.h ============================================================================== --- head/sys/dev/mmc/mmcvar.h Sat Oct 11 12:10:23 2008 (r183762) +++ head/sys/dev/mmc/mmcvar.h Sat Oct 11 13:05:13 2008 (r183763) @@ -55,6 +55,8 @@ #ifndef DEV_MMC_MMCVAR_H #define DEV_MMC_MMCVAR_H +#include + enum mmc_device_ivars { MMC_IVAR_DSR_IMP, MMC_IVAR_MEDIA_SIZE, @@ -63,6 +65,8 @@ enum mmc_device_ivars { MMC_IVAR_TRAN_SPEED, MMC_IVAR_READ_ONLY, MMC_IVAR_HIGH_CAP, + MMC_IVAR_CARD_TYPE, + MMC_IVAR_BUS_WIDTH, // MMC_IVAR_, }; @@ -79,5 +83,7 @@ MMC_ACCESSOR(sector_size, SECTOR_SIZE, i MMC_ACCESSOR(tran_speed, TRAN_SPEED, int) MMC_ACCESSOR(read_only, READ_ONLY, int) MMC_ACCESSOR(high_cap, HIGH_CAP, int) +MMC_ACCESSOR(card_type, CARD_TYPE, int) +MMC_ACCESSOR(bus_width, BUS_WIDTH, int) #endif /* DEV_MMC_MMCVAR_H */