Date: Fri, 29 Sep 2006 03:46:42 GMT From: Warner Losh <imp@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 106862 for review Message-ID: <200609290346.k8T3kgw5003692@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=106862 Change 106862 by imp@imp_lighthouse on 2006/09/29 03:46:00 continue writing the code to probe for cards. Getting close to needing to write the flash driver itself... Affected files ... .. //depot/projects/arm/src/sys/arm/at91/at91_mci.c#12 edit .. //depot/projects/arm/src/sys/dev/mmc/bridge.h#5 edit .. //depot/projects/arm/src/sys/dev/mmc/mmc.c#8 edit Differences ... ==== //depot/projects/arm/src/sys/arm/at91/at91_mci.c#12 (text+ko) ==== @@ -56,6 +56,7 @@ #include <arm/at91/at91_pdcreg.h> #include <dev/mmc/bridge.h> #include <dev/mmc/mmcreg.h> +#include <dev/mmc/mmcbrvar.h> #include "mmcbr_if.h" @@ -337,10 +338,8 @@ #endif if (cmd->opcode == MMC_STOP_TRANSMISSION) cmdr |= MCI_CMDR_TRCMD_STOP; -#if 0 - if (??? == opendrain) + if (sc->host.ios.bus_mode == opendrain) cmdr |= MCI_CMDR_OPDCMD; -#endif if (!cmd->data) { at91_mci_pdc_disable(sc); WR4(sc, MCI_ARGR, cmd->arg); @@ -432,32 +431,7 @@ return (0); } -static device_method_t at91_mci_methods[] = { - /* device_if */ - DEVMETHOD(device_probe, at91_mci_probe), - DEVMETHOD(device_attach, at91_mci_attach), - DEVMETHOD(device_detach, at91_mci_detach), - - /* mmcbr_if */ - DEVMETHOD(mmcbr_update_ios, at91_mci_update_ios), - DEVMETHOD(mmcbr_request, at91_mci_request), - DEVMETHOD(mmcbr_get_ro, at91_mci_get_ro), - DEVMETHOD(mmcbr_acquire_host, at91_mci_acquire_host), - DEVMETHOD(mmcbr_release_host, at91_mci_release_host), - - {0, 0}, -}; -static driver_t at91_mci_driver = { - "at91_mci", - at91_mci_methods, - sizeof(struct at91_mci_softc), -}; -static devclass_t at91_mci_devclass; - - -DRIVER_MODULE(at91_mci, atmelarm, at91_mci_driver, at91_mci_devclass, 0, 0); - static void at91_mci_intr(void *arg) { @@ -523,10 +497,129 @@ } } if (done) { - if (cmd != NULL) - for (i = 0; i < 4; i++) - cmd->resp[i] = RD4(sc, MCI_RSPR + (i << 2)); + if (cmd != NULL) { + for (i = 0; i < ((cmd->flags & MMC_RSP_136) ? 4 : 1); + i++) { + cmd->resp[i] = RD4(sc, MCI_RSPR + i * 4); + printf("RSPR[%d] = %x\n", i, cmd->resp[i]); + } + } at91_mci_start(sc); } AT91_MCI_UNLOCK(sc); } + +static int +at91_mci_read_ivar(device_t bus, device_t child, int which, u_char *result) +{ + struct at91_mci_softc *sc = device_get_softc(bus); + + switch (which) { + default: + return (EINVAL); + case MMCBR_IVAR_BUS_MODE: + *(int *)result = sc->host.ios.bus_mode; + break; + case MMCBR_IVAR_BUS_WIDTH: + *(int *)result = sc->host.ios.bus_width; + break; + case MMCBR_IVAR_CHIP_SELECT: + *(int *)result = sc->host.ios.chip_select; + break; + case MMCBR_IVAR_CLOCK: + *(int *)result = sc->host.ios.clock; + break; + case MMCBR_IVAR_F_MIN: + *(int *)result = sc->host.f_min; + break; + case MMCBR_IVAR_F_MAX: + *(int *)result = sc->host.f_max; + break; + case MMCBR_IVAR_HOST_OCR: + *(int *)result = sc->host.host_ocr; + break; + case MMCBR_IVAR_MODE: + *(int *)result = sc->host.mode; + break; + case MMCBR_IVAR_OCR: + *(int *)result = sc->host.ocr; + break; + case MMCBR_IVAR_POWER_MODE: + *(int *)result = sc->host.ios.power_mode; + break; + case MMCBR_IVAR_VDD: + *(int *)result = sc->host.ios.vdd; + break; + } + return (0); +} + +static int +at91_mci_write_ivar(device_t bus, device_t child, int which, uintptr_t value) +{ + struct at91_mci_softc *sc = device_get_softc(bus); + + switch (which) { + default: + return (EINVAL); + case MMCBR_IVAR_BUS_MODE: + sc->host.ios.bus_mode = value; + break; + case MMCBR_IVAR_BUS_WIDTH: + sc->host.ios.bus_width = value; + break; + case MMCBR_IVAR_CHIP_SELECT: + sc->host.ios.chip_select = value; + break; + case MMCBR_IVAR_CLOCK: + sc->host.ios.clock = value; + break; + case MMCBR_IVAR_MODE: + sc->host.mode = value; + break; + case MMCBR_IVAR_OCR: + sc->host.ocr = value; + break; + case MMCBR_IVAR_POWER_MODE: + sc->host.ios.power_mode = value; + break; + case MMCBR_IVAR_VDD: + sc->host.ios.vdd = value; + break; + case MMCBR_IVAR_HOST_OCR: + case MMCBR_IVAR_F_MIN: + case MMCBR_IVAR_F_MAX: + return (EINVAL); + } + return (0); +} + +static device_method_t at91_mci_methods[] = { + /* device_if */ + DEVMETHOD(device_probe, at91_mci_probe), + DEVMETHOD(device_attach, at91_mci_attach), + DEVMETHOD(device_detach, at91_mci_detach), + + /* Bus interface */ + DEVMETHOD(bus_read_ivar, at91_mci_read_ivar), + DEVMETHOD(bus_write_ivar, at91_mci_write_ivar), + + /* mmcbr_if */ + DEVMETHOD(mmcbr_update_ios, at91_mci_update_ios), + DEVMETHOD(mmcbr_request, at91_mci_request), + DEVMETHOD(mmcbr_get_ro, at91_mci_get_ro), + DEVMETHOD(mmcbr_acquire_host, at91_mci_acquire_host), + DEVMETHOD(mmcbr_release_host, at91_mci_release_host), + + {0, 0}, +}; + +static driver_t at91_mci_driver = { + "at91_mci", + at91_mci_methods, + sizeof(struct at91_mci_softc), +}; +static devclass_t at91_mci_devclass; + + +DRIVER_MODULE(at91_mci, atmelarm, at91_mci_driver, at91_mci_devclass, 0, 0); ==== //depot/projects/arm/src/sys/dev/mmc/bridge.h#5 (text+ko) ==== @@ -59,7 +59,7 @@ vdd_330, vdd_340, vdd_350, vdd_360 }; -enum mmc_poewr_mode { +enum mmc_power_mode { power_off = 0, power_up, power_on }; @@ -81,6 +81,7 @@ enum mmc_bus_mode bus_mode; enum mmc_chip_select chip_select; enum mmc_bus_width bus_width; + enum mmc_power_mode power_mode; }; enum mmc_card_mode { @@ -91,6 +92,7 @@ int f_min; int f_max; uint32_t host_ocr; + uint32_t ocr; uint32_t caps; #define MMC_CAP_4_BIT_DATA (1 << 0) /* Can do 4-bit data transfers */ #define MMC_CAP_8_BIT_DATA (1 << 1) /* Can do 8-bit data transfers */ ==== //depot/projects/arm/src/sys/dev/mmc/mmc.c#8 (text+ko) ==== @@ -126,6 +126,8 @@ static uint32_t mmc_select_vdd(struct mmc_softc *sc, uint32_t ocr) { + // XXX + return ocr; } static int @@ -237,6 +239,7 @@ for (i = 0; i < 100; i++) { err = mmc_wait_for_app_cmd(sc, 0, &cmd, CMD_RETRIES); + printf("err is %x busy is %x\n", err, cmd.resp[0]); if (err != MMC_ERR_NONE) break; if ((cmd.resp[0] & MMC_OCR_CARD_BUSY) || ocr == 0) @@ -246,6 +249,7 @@ } if (rocr && err == MMC_ERR_NONE) *rocr = cmd.resp[0]; + printf("app op sayz %x\n", cmd.resp[0]); return err; } @@ -298,6 +302,29 @@ static void mmc_discover_cards(struct mmc_softc *sc) { +#if 0 // XXX XXX XXX + while (1) { + err = mmc_all_send_cid(sc, &rca); + if (err == MMC_ERR_TIMEOUT) { + err = MMC_ERR_NONE; + break; + } + if (err != MMC_ERR_NONE) { + printf("Error reading CID %d\n", err); + break; + } + card = find_card(sc, rca); + if (host->mode == MMC_MODE_SD) { + mmc_card_set_sd(card); + mmc_send_relative_addr(sc, 0); + card->rca = cmd.resp[0] >> 16; + // RO check + break; + } + // MMC XXX card detection + // set relative addr + } +#endif } static void @@ -322,12 +349,13 @@ mmcbr_set_mode(dev, mode_sd); mmc_power_up(sc); mmc_idle_cards(sc); - if (mmc_send_app_op_cond(sc, 0, &ocr)) { + if (mmc_send_app_op_cond(sc, 0, &ocr) != MMC_ERR_NONE) { // Failed, try MMC mmcbr_set_mode(dev, mode_mmc); - if (mmc_send_op_cond(sc, 0, &ocr)) + if (mmc_send_op_cond(sc, 0, &ocr) != MMC_ERR_NONE) return; // Failed both, punt! XXX power down? } + printf("OCR IS %x\n", ocr); mmcbr_set_ocr(dev, mmc_select_vdd(sc, ocr)); if (mmcbr_get_ocr(dev) != 0) mmc_idle_cards(sc); @@ -341,8 +369,9 @@ * Make sure that we have a mutually agreeable voltage to at least * one card on the bus. */ - if (mmcbr_get_ocr(dev) == 0) - return; + printf("Oink %x!\n", mmcbr_get_ocr(dev)); +// if (mmcbr_get_ocr(dev) == 0) +// return; /* XXX Linux re-sends op_cond command here */ mmc_discover_cards(sc);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200609290346.k8T3kgw5003692>