Always sector size is treated as 512 bytes.
This commit is contained in:
parent
7404b55630
commit
c6e1f64d7a
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: ld_sdmmc.c,v 1.3 2009/05/29 22:27:40 nonaka Exp $ */
|
/* $NetBSD: ld_sdmmc.c,v 1.4 2009/11/28 10:00:24 nonaka Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 KIYOHARA Takashi
|
* Copyright (c) 2008 KIYOHARA Takashi
|
||||||
@ -28,7 +28,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: ld_sdmmc.c,v 1.3 2009/05/29 22:27:40 nonaka Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: ld_sdmmc.c,v 1.4 2009/11/28 10:00:24 nonaka Exp $");
|
||||||
|
|
||||||
#include "rnd.h"
|
#include "rnd.h"
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ ld_sdmmc_attach(device_t parent, device_t self, void *aux)
|
|||||||
|
|
||||||
ld->sc_flags = LDF_ENABLED;
|
ld->sc_flags = LDF_ENABLED;
|
||||||
ld->sc_secperunit = sc->sc_sf->csd.capacity;
|
ld->sc_secperunit = sc->sc_sf->csd.capacity;
|
||||||
ld->sc_secsize = sc->sc_sf->csd.sector_size;
|
ld->sc_secsize = SDMMC_SECTOR_SIZE;
|
||||||
ld->sc_maxxfer = MAXPHYS;
|
ld->sc_maxxfer = MAXPHYS;
|
||||||
ld->sc_maxqueuecnt = 1;
|
ld->sc_maxqueuecnt = 1;
|
||||||
ld->sc_dump = ld_sdmmc_dump;
|
ld->sc_dump = ld_sdmmc_dump;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: sdmmc_mem.c,v 1.2 2009/05/24 12:59:54 nonaka Exp $ */
|
/* $NetBSD: sdmmc_mem.c,v 1.3 2009/11/28 10:00:24 nonaka Exp $ */
|
||||||
/* $OpenBSD: sdmmc_mem.c,v 1.10 2009/01/09 10:55:22 jsg Exp $ */
|
/* $OpenBSD: sdmmc_mem.c,v 1.10 2009/01/09 10:55:22 jsg Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -46,7 +46,7 @@
|
|||||||
/* Routines for SD/MMC memory cards. */
|
/* Routines for SD/MMC memory cards. */
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: sdmmc_mem.c,v 1.2 2009/05/24 12:59:54 nonaka Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: sdmmc_mem.c,v 1.3 2009/11/28 10:00:24 nonaka Exp $");
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/kernel.h>
|
#include <sys/kernel.h>
|
||||||
@ -343,11 +343,8 @@ sdmmc_decode_csd(struct sdmmc_softc *sc, sdmmc_response resp,
|
|||||||
m = MMC_CSD_TRAN_SPEED_MANT(resp);
|
m = MMC_CSD_TRAN_SPEED_MANT(resp);
|
||||||
csd->tran_speed = speed_exponent[e] * speed_mantissa[m] / 10;
|
csd->tran_speed = speed_exponent[e] * speed_mantissa[m] / 10;
|
||||||
}
|
}
|
||||||
csd->sector_size = MIN((1 << csd->read_bl_len),
|
if ((1 << csd->read_bl_len) > SDMMC_SECTOR_SIZE)
|
||||||
sdmmc_chip_host_maxblklen(sc->sc_sct, sc->sc_sch));
|
csd->capacity *= (1 << csd->read_bl_len) / SDMMC_SECTOR_SIZE;
|
||||||
if (csd->sector_size < (1 << csd->read_bl_len))
|
|
||||||
csd->capacity *= (1 << csd->read_bl_len) / csd->sector_size;
|
|
||||||
csd->sector_size_sb = ffs(csd->sector_size) - 1;
|
|
||||||
|
|
||||||
if (sc->sc_busclk > csd->tran_speed)
|
if (sc->sc_busclk > csd->tran_speed)
|
||||||
sc->sc_busclk = csd->tran_speed;
|
sc->sc_busclk = csd->tran_speed;
|
||||||
@ -420,7 +417,6 @@ sdmmc_print_csd(sdmmc_response resp, struct sdmmc_csd *csd)
|
|||||||
printf("write_cl_len = %d\n", csd->write_bl_len);
|
printf("write_cl_len = %d\n", csd->write_bl_len);
|
||||||
printf("r2w_factor = %d\n", csd->r2w_factor);
|
printf("r2w_factor = %d\n", csd->r2w_factor);
|
||||||
printf("tran_speed = %d\n", csd->tran_speed);
|
printf("tran_speed = %d\n", csd->tran_speed);
|
||||||
printf("sector_size = %d\n", csd->sector_size);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -526,13 +522,13 @@ sdmmc_mem_set_blocklen(struct sdmmc_softc *sc, struct sdmmc_function *sf)
|
|||||||
|
|
||||||
memset(&cmd, 0, sizeof(cmd));
|
memset(&cmd, 0, sizeof(cmd));
|
||||||
cmd.c_opcode = MMC_SET_BLOCKLEN;
|
cmd.c_opcode = MMC_SET_BLOCKLEN;
|
||||||
cmd.c_arg = sf->csd.sector_size;
|
cmd.c_arg = SDMMC_SECTOR_SIZE;
|
||||||
cmd.c_flags = SCF_CMD_AC | SCF_RSP_R1;
|
cmd.c_flags = SCF_CMD_AC | SCF_RSP_R1;
|
||||||
|
|
||||||
error = sdmmc_mmc_command(sc, &cmd);
|
error = sdmmc_mmc_command(sc, &cmd);
|
||||||
|
|
||||||
DPRINTF(("%s: sdmmc_mem_set_blocklen: read_bl_len=%d sector_size=%d\n",
|
DPRINTF(("%s: sdmmc_mem_set_blocklen: read_bl_len=%d sector_size=%d\n",
|
||||||
SDMMCDEVNAME(sc), 1 << sf->csd.read_bl_len, sf->csd.sector_size));
|
SDMMCDEVNAME(sc), 1 << sf->csd.read_bl_len, SDMMC_SECTOR_SIZE));
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
@ -552,12 +548,12 @@ sdmmc_mem_read_block_subr(struct sdmmc_function *sf, uint32_t blkno,
|
|||||||
memset(&cmd, 0, sizeof(cmd));
|
memset(&cmd, 0, sizeof(cmd));
|
||||||
cmd.c_data = data;
|
cmd.c_data = data;
|
||||||
cmd.c_datalen = datalen;
|
cmd.c_datalen = datalen;
|
||||||
cmd.c_blklen = sf->csd.sector_size;
|
cmd.c_blklen = SDMMC_SECTOR_SIZE;
|
||||||
cmd.c_opcode = (cmd.c_datalen / cmd.c_blklen) > 1 ?
|
cmd.c_opcode = (cmd.c_datalen / cmd.c_blklen) > 1 ?
|
||||||
MMC_READ_BLOCK_MULTIPLE : MMC_READ_BLOCK_SINGLE;
|
MMC_READ_BLOCK_MULTIPLE : MMC_READ_BLOCK_SINGLE;
|
||||||
cmd.c_arg = blkno;
|
cmd.c_arg = blkno;
|
||||||
if (!ISSET(sf->flags, SFF_SDHC))
|
if (!ISSET(sf->flags, SFF_SDHC))
|
||||||
cmd.c_arg <<= sf->csd.sector_size_sb;
|
cmd.c_arg <<= SDMMC_SECTOR_SIZE_SB;
|
||||||
cmd.c_flags = SCF_CMD_ADTC | SCF_CMD_READ | SCF_RSP_R1;
|
cmd.c_flags = SCF_CMD_ADTC | SCF_CMD_READ | SCF_RSP_R1;
|
||||||
if (ISSET(sc->sc_caps, SMC_CAPS_DMA))
|
if (ISSET(sc->sc_caps, SMC_CAPS_DMA))
|
||||||
cmd.c_dmamap = sc->sc_dmap;
|
cmd.c_dmamap = sc->sc_dmap;
|
||||||
@ -646,12 +642,12 @@ sdmmc_mem_write_block_subr(struct sdmmc_function *sf, uint32_t blkno,
|
|||||||
memset(&cmd, 0, sizeof(cmd));
|
memset(&cmd, 0, sizeof(cmd));
|
||||||
cmd.c_data = data;
|
cmd.c_data = data;
|
||||||
cmd.c_datalen = datalen;
|
cmd.c_datalen = datalen;
|
||||||
cmd.c_blklen = sf->csd.sector_size;
|
cmd.c_blklen = SDMMC_SECTOR_SIZE;
|
||||||
cmd.c_opcode = (cmd.c_datalen / cmd.c_blklen) > 1 ?
|
cmd.c_opcode = (cmd.c_datalen / cmd.c_blklen) > 1 ?
|
||||||
MMC_WRITE_BLOCK_MULTIPLE : MMC_WRITE_BLOCK_SINGLE;
|
MMC_WRITE_BLOCK_MULTIPLE : MMC_WRITE_BLOCK_SINGLE;
|
||||||
cmd.c_arg = blkno;
|
cmd.c_arg = blkno;
|
||||||
if (!ISSET(sf->flags, SFF_SDHC))
|
if (!ISSET(sf->flags, SFF_SDHC))
|
||||||
cmd.c_arg <<= sf->csd.sector_size_sb;
|
cmd.c_arg <<= SDMMC_SECTOR_SIZE_SB;
|
||||||
cmd.c_flags = SCF_CMD_ADTC | SCF_RSP_R1;
|
cmd.c_flags = SCF_CMD_ADTC | SCF_RSP_R1;
|
||||||
if (ISSET(sc->sc_caps, SMC_CAPS_DMA))
|
if (ISSET(sc->sc_caps, SMC_CAPS_DMA))
|
||||||
cmd.c_dmamap = sc->sc_dmap;
|
cmd.c_dmamap = sc->sc_dmap;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: sdmmcvar.h,v 1.1 2009/04/21 03:00:31 nonaka Exp $ */
|
/* $NetBSD: sdmmcvar.h,v 1.2 2009/11/28 10:00:24 nonaka Exp $ */
|
||||||
/* $OpenBSD: sdmmcvar.h,v 1.13 2009/01/09 10:55:22 jsg Exp $ */
|
/* $OpenBSD: sdmmcvar.h,v 1.13 2009/01/09 10:55:22 jsg Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -28,12 +28,13 @@
|
|||||||
#include <dev/sdmmc/sdmmcchip.h>
|
#include <dev/sdmmc/sdmmcchip.h>
|
||||||
#include <dev/sdmmc/sdmmcreg.h>
|
#include <dev/sdmmc/sdmmcreg.h>
|
||||||
|
|
||||||
|
#define SDMMC_SECTOR_SIZE_SB 9
|
||||||
|
#define SDMMC_SECTOR_SIZE (1 << SDMMC_SECTOR_SIZE_SB) /* =512 */
|
||||||
|
|
||||||
struct sdmmc_csd {
|
struct sdmmc_csd {
|
||||||
int csdver; /* CSD structure format */
|
int csdver; /* CSD structure format */
|
||||||
u_int mmcver; /* MMC version (for CID format) */
|
u_int mmcver; /* MMC version (for CID format) */
|
||||||
int capacity; /* total number of sectors */
|
int capacity; /* total number of sectors */
|
||||||
int sector_size; /* sector size in bytes */
|
|
||||||
int sector_size_sb; /* sector size in shift bit */
|
|
||||||
int read_bl_len; /* block length for reads */
|
int read_bl_len; /* block length for reads */
|
||||||
int write_bl_len; /* block length for writes */
|
int write_bl_len; /* block length for writes */
|
||||||
int r2w_factor;
|
int r2w_factor;
|
||||||
|
Loading…
Reference in New Issue
Block a user