aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/mmc/core/sdio_io.c64
-rw-r--r--include/linux/mmc/sdio_func.h5
2 files changed, 69 insertions, 0 deletions
diff --git a/drivers/mmc/core/sdio_io.c b/drivers/mmc/core/sdio_io.c
index 34b085d4024a..625b92ce9cef 100644
--- a/drivers/mmc/core/sdio_io.c
+++ b/drivers/mmc/core/sdio_io.c
@@ -482,3 +482,67 @@ void sdio_writel(struct sdio_func *func, unsigned long b, unsigned int addr,
482} 482}
483EXPORT_SYMBOL_GPL(sdio_writel); 483EXPORT_SYMBOL_GPL(sdio_writel);
484 484
485/**
486 * sdio_f0_readb - read a single byte from SDIO function 0
487 * @func: an SDIO function of the card
488 * @addr: address to read
489 * @err_ret: optional status value from transfer
490 *
491 * Reads a single byte from the address space of SDIO function 0.
492 * If there is a problem reading the address, 0xff is returned
493 * and @err_ret will contain the error code.
494 */
495unsigned char sdio_f0_readb(struct sdio_func *func, unsigned int addr,
496 int *err_ret)
497{
498 int ret;
499 unsigned char val;
500
501 BUG_ON(!func);
502
503 if (err_ret)
504 *err_ret = 0;
505
506 ret = mmc_io_rw_direct(func->card, 0, 0, addr, 0, &val);
507 if (ret) {
508 if (err_ret)
509 *err_ret = ret;
510 return 0xFF;
511 }
512
513 return val;
514}
515EXPORT_SYMBOL_GPL(sdio_f0_readb);
516
517/**
518 * sdio_f0_writeb - write a single byte to SDIO function 0
519 * @func: an SDIO function of the card
520 * @b: byte to write
521 * @addr: address to write to
522 * @err_ret: optional status value from transfer
523 *
524 * Writes a single byte to the address space of SDIO function 0.
525 * @err_ret will contain the status of the actual transfer.
526 *
527 * Only writes to the vendor specific CCCR registers (0xF0 -
528 * 0xFF) are permiited; @err_ret will be set to -EINVAL for *
529 * writes outside this range.
530 */
531void sdio_f0_writeb(struct sdio_func *func, unsigned char b, unsigned int addr,
532 int *err_ret)
533{
534 int ret;
535
536 BUG_ON(!func);
537
538 if (addr < 0xF0 || addr > 0xFF) {
539 if (err_ret)
540 *err_ret = -EINVAL;
541 return;
542 }
543
544 ret = mmc_io_rw_direct(func->card, 1, 0, addr, b, NULL);
545 if (err_ret)
546 *err_ret = ret;
547}
548EXPORT_SYMBOL_GPL(sdio_f0_writeb);
diff --git a/include/linux/mmc/sdio_func.h b/include/linux/mmc/sdio_func.h
index f05757984e8d..da6a96c39776 100644
--- a/include/linux/mmc/sdio_func.h
+++ b/include/linux/mmc/sdio_func.h
@@ -141,5 +141,10 @@ extern int sdio_memcpy_toio(struct sdio_func *func, unsigned int addr,
141extern int sdio_writesb(struct sdio_func *func, unsigned int addr, 141extern int sdio_writesb(struct sdio_func *func, unsigned int addr,
142 void *src, int count); 142 void *src, int count);
143 143
144extern unsigned char sdio_f0_readb(struct sdio_func *func,
145 unsigned int addr, int *err_ret);
146extern void sdio_f0_writeb(struct sdio_func *func, unsigned char b,
147 unsigned int addr, int *err_ret);
148
144#endif 149#endif
145 150