-/* $OpenBSD: sdmmc_io.c,v 1.30 2017/10/12 11:54:37 patrick Exp $ */
+/* $OpenBSD: sdmmc_io.c,v 1.31 2018/02/11 20:57:57 patrick Exp $ */
/*
* Copyright (c) 2006 Uwe Stuehler <uwe@openbsd.org>
SD_ARG_CMD53_WRITE);
}
+int
+sdmmc_io_read_region_1(struct sdmmc_function *sf, int reg, u_char *data,
+ int datalen)
+{
+ int error;
+
+ rw_assert_wrlock(&sf->sc->sc_lock);
+
+ while (datalen > SD_ARG_CMD53_LENGTH_MAX) {
+ error = sdmmc_io_rw_extended(sf->sc, sf, reg, data,
+ SD_ARG_CMD53_LENGTH_MAX, SD_ARG_CMD53_READ |
+ SD_ARG_CMD53_INCREMENT);
+ if (error)
+ return error;
+ reg += SD_ARG_CMD53_LENGTH_MAX;
+ data += SD_ARG_CMD53_LENGTH_MAX;
+ datalen -= SD_ARG_CMD53_LENGTH_MAX;
+ }
+
+ return sdmmc_io_rw_extended(sf->sc, sf, reg, data, datalen,
+ SD_ARG_CMD53_READ | SD_ARG_CMD53_INCREMENT);
+}
+
+int
+sdmmc_io_write_region_1(struct sdmmc_function *sf, int reg, u_char *data,
+ int datalen)
+{
+ int error;
+
+ rw_assert_wrlock(&sf->sc->sc_lock);
+
+ while (datalen > SD_ARG_CMD53_LENGTH_MAX) {
+ error = sdmmc_io_rw_extended(sf->sc, sf, reg, data,
+ SD_ARG_CMD53_LENGTH_MAX, SD_ARG_CMD53_WRITE |
+ SD_ARG_CMD53_INCREMENT);
+ if (error)
+ return error;
+ reg += SD_ARG_CMD53_LENGTH_MAX;
+ data += SD_ARG_CMD53_LENGTH_MAX;
+ datalen -= SD_ARG_CMD53_LENGTH_MAX;
+ }
+
+ return sdmmc_io_rw_extended(sf->sc, sf, reg, data, datalen,
+ SD_ARG_CMD53_WRITE | SD_ARG_CMD53_INCREMENT);
+}
+
int
sdmmc_io_xchg(struct sdmmc_softc *sc, struct sdmmc_function *sf,
int reg, u_char *datap)
-/* $OpenBSD: sdmmcvar.h,v 1.26 2016/05/05 11:01:08 kettenis Exp $ */
+/* $OpenBSD: sdmmcvar.h,v 1.27 2018/02/11 20:57:57 patrick Exp $ */
/*
* Copyright (c) 2006 Uwe Stuehler <uwe@openbsd.org>
u_int16_t sdmmc_io_read_2(struct sdmmc_function *, int);
u_int32_t sdmmc_io_read_4(struct sdmmc_function *, int);
int sdmmc_io_read_multi_1(struct sdmmc_function *, int, u_char *, int);
+int sdmmc_io_read_region_1(struct sdmmc_function *, int, u_char *, int);
void sdmmc_io_write_1(struct sdmmc_function *, int, u_int8_t);
void sdmmc_io_write_2(struct sdmmc_function *, int, u_int16_t);
void sdmmc_io_write_4(struct sdmmc_function *, int, u_int32_t);
int sdmmc_io_write_multi_1(struct sdmmc_function *, int, u_char *, int);
+int sdmmc_io_write_region_1(struct sdmmc_function *, int, u_char *, int);
int sdmmc_io_function_ready(struct sdmmc_function *);
int sdmmc_io_function_enable(struct sdmmc_function *);
void sdmmc_io_function_disable(struct sdmmc_function *);