Date: Fri, 29 Sep 2006 14:15:31 GMT From: Warner Losh <imp@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 106892 for review Message-ID: <200609291415.k8TEFVXR083052@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=106892 Change 106892 by imp@imp_lighthouse on 2006/09/29 14:15:25 checkpoint cid/csd parsing. Affected files ... .. //depot/projects/arm/src/sys/dev/mmc/mmc.c#9 edit .. //depot/projects/arm/src/sys/dev/mmc/mmcreg.h#10 edit Differences ... ==== //depot/projects/arm/src/sys/dev/mmc/mmc.c#9 (text+ko) ==== @@ -46,6 +46,16 @@ struct intr_config_hook config_intrhook; }; +/* + * Per-card data + */ +struct mmc_ivars { + uint32_t raw_cid[4]; /* Raw bits of the CID */ + uint32_t raw_csd[4]; /* Raw bits of the CSD */ + struct mmc_cid cid; + struct mmc_csd csd; +}; + #define CMD_RETRIES 3 /* bus entry points */ @@ -300,6 +310,52 @@ } static void +mmc_decode_cid(int is_sd, uint32_t *raw_cid, struct mmc_cid *cid) +{ + memset(cid, 0, sizeof(*cid)); + if (is_sd) { + /* There's no version info, so we take it on faith */ + cid->mid = mmc_get_bits(raw_cid, 120, 8); + cid->oid = mmc_get_bits(raw_cid, 104, 16); + for (i = 0; i < 5; i++) + cid->pnm[i] = mmc_get_bits(raw_cid, 96 - i * 8, 8); + cid->prv = mmc_get_bits(raw_cid, 56, 8); + cid->psn = mmc_get_bits(raw_cid, 24, 32); + cid->mdt_year = mmc_get_bits(raw_cid, 12, 8) + 2001; + cid->mdt_month = mmc_get_bits(raw_cid, 8, 4); + } else { + // XXX write me + panic("write mmc cid decoder"); + } +} + +static void +mmc_decode_csd(int is_sd, uint32_t *raw_csd, struct mmc_csd *csd) +{ + int v; + + memset(csd, 0, sizeof(*csd)); + if (is_sd) { + csd->csd_structure = v = mmc_get_bits(raw_csd, 126, 2); + if (v == 0) { + m = mmc_get_bits(raw_csd, 115, 4); + e = mmc_get_bits(raw_csd, 112, 3); + csd->tacc = tacc_exp[e] * tacc_mant[m] + 9 / 10; + csd->nsac = mmc_get_bits(raw_csd, 104, 8) * 100; + m = mmc_get_bits(raw_csd, 99, 4); + e = mmc_get_bits(raw_csd, 96, 3); + csd->tran_speed = tran_exp[e] * tran_mant[m]; + + } else if (v == 1) { + panic("Write SDHC CSD parser"); + } else + pacic("unknown SD CSD version"); + } else { + panic("Write a MMC CSD parser"); + } +} + +static void mmc_discover_cards(struct mmc_softc *sc) { #if 0 // XXX XXX XXX ==== //depot/projects/arm/src/sys/dev/mmc/mmcreg.h#10 (text+ko) ==== @@ -274,4 +274,33 @@ #define MMC_OCR_CCS (1u << 30) /* Card Capacity status (SD vs SDHC) */ #define MMC_OCR_CARD_BUSY (1U << 31) /* Card Power up status */ +/* CSD -- decoded structure */ +struct mmc_cid { + uint32_t mid; + char pnm[8]; + uint32_t psn; + uint16_t oid; + uint16_t mdt_year; + uint8_t mdt_month; + uint8_t prv; + uint8_t fwrev; +}; + +struct mmc_csd +{ + uint8_t csd_structure; + uint16_t cmdclass; + uint16_t tacc; + uint32_t nsac_clks; + uint32_t r2w_factor; + uint32_t tran_speed; + uint32_t read_blkbits; + uint32_t write_blkbits; + uint32_t capacity; + unsigned int read_partial:1, + read_misalign:1, + write_partial:1, + write_misalign:1; +}; + #endif /* DEV_MMCREG_H */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200609291415.k8TEFVXR083052>