aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc/core/sdio_io.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mmc/core/sdio_io.c')
-rw-r--r--drivers/mmc/core/sdio_io.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/drivers/mmc/core/sdio_io.c b/drivers/mmc/core/sdio_io.c
index 34b085d4024..625b92ce9ce 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);