All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Vrabel <david.vrabel@csr.com>
To: linux-kernel@vger.kernel.org
Cc: Pierre Ossman <drzeus-list@drzeus.cx>,
	Marcel Holtmann <marcel@holtmann.org>
Subject: [patch 5/5] sdio: add sdio_f0_readb() and sdio_f0_writeb()
Date: Fri, 10 Aug 2007 13:29:46 +0100	[thread overview]
Message-ID: <46BC5A3A.2030301@csr.com> (raw)
In-Reply-To: <46BC58E8.50300@csr.com>

[-- Attachment #1: Type: text/plain, Size: 152 bytes --]

-- 
David Vrabel, Software Engineer, Drivers group  Tel: +44 (0)1223 692562
CSR plc, Churchill House, Cambridge Business Park, Cowley Road, CB4 0WZ


.

[-- Attachment #2: sdio-f0-read-write.patch --]
[-- Type: text/x-patch, Size: 2781 bytes --]

sdio: add sdio_f0_readb() and sdio_f0_writeb()

Add sdio_f0_readb() and sdio_f0_writeb() functions to reading and
writing function 0 registers.  Writes outside the vendor specific CCCR
registers (0xF0 - 0xFF) are not permitted.

Signed-off-by: David Vrabel <david.vrabel@csr.com>
---
Index: mmc/drivers/mmc/core/sdio_io.c
===================================================================
--- mmc.orig/drivers/mmc/core/sdio_io.c	2007-08-10 01:15:54.000000000 +0100
+++ mmc/drivers/mmc/core/sdio_io.c	2007-08-10 01:20:24.000000000 +0100
@@ -493,3 +493,69 @@
 
 EXPORT_SYMBOL_GPL(sdio_writel);
 
+/**
+ *	sdio_f0_readb - read a single byte from SDIO function 0
+ *	@func: an SDIO function of the card
+ *	@addr: address to read
+ *	@err_ret: optional status value from transfer
+ *
+ *	Reads a single byte from the address space of SDIO function 0.
+ *	If there is a problem reading the address, 0xff is returned
+ *	and @err_ret will contain the error code.
+ */
+unsigned char sdio_f0_readb(struct sdio_func *func, unsigned int addr,
+	int *err_ret)
+{
+	int ret;
+	unsigned char val;
+
+	BUG_ON(!func);
+
+	if (err_ret)
+		*err_ret = 0;
+
+	ret = mmc_io_rw_direct(func->card, 0, 0, addr, 0, &val);
+	if (ret) {
+		if (err_ret)
+			*err_ret = ret;
+		return 0xFF;
+	}
+
+	return val;
+}
+
+EXPORT_SYMBOL_GPL(sdio_f0_readb);
+
+/**
+ *	sdio_f0_writeb - write a single byte to SDIO function 0
+ *	@func: an SDIO function of the card
+ *	@b: byte to write
+ *	@addr: address to write to
+ *	@err_ret: optional status value from transfer
+ *
+ *	Writes a single byte to the address space of SDIO function 0.
+ *	@err_ret will contain the status of the actual transfer.
+ *
+ *	Only writes to the vendor specific CCCR registers (0xF0 -
+ *	0xFF) are permiited; @err_ret will be set to -EINVAL for *
+ *	writes outside this range.
+ */
+void sdio_f0_writeb(struct sdio_func *func, unsigned char b, unsigned int addr,
+	int *err_ret)
+{
+	int ret;
+
+	BUG_ON(!func);
+
+	if (addr < 0xF0 || addr > 0xFF) {
+		if (err_ret)
+			*err_ret = -EINVAL;
+		return;
+	}
+
+	ret = mmc_io_rw_direct(func->card, 1, 0, addr, b, NULL);
+	if (err_ret)
+		*err_ret = ret;
+}
+
+EXPORT_SYMBOL_GPL(sdio_f0_writeb);
Index: mmc/include/linux/mmc/sdio_func.h
===================================================================
--- mmc.orig/include/linux/mmc/sdio_func.h	2007-08-10 01:15:54.000000000 +0100
+++ mmc/include/linux/mmc/sdio_func.h	2007-08-10 01:16:09.000000000 +0100
@@ -141,5 +141,10 @@
 extern int sdio_writesb(struct sdio_func *func, unsigned int addr,
 	void *src, int count);
 
+extern unsigned char sdio_f0_readb(struct sdio_func *func,
+	unsigned int addr, int *err_ret);
+extern void sdio_f0_writeb(struct sdio_func *func, unsigned char b,
+	unsigned int addr, int *err_ret);
+
 #endif
 

  parent reply	other threads:[~2007-08-10 12:32 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-10 12:24 [patch 0/5] sdio: various bug fixes and CSR specific support David Vrabel
2007-08-10 12:25 ` mmc: ignore bad max block size in sdhci David Vrabel
2007-08-10 13:34   ` Pierre Ossman
2007-08-10 12:27 ` sdio: set host bus width David Vrabel
2007-08-10 13:35   ` Pierre Ossman
2007-08-10 13:46     ` David Vrabel
2007-08-10 12:28 ` sdio: add <linux/mmc/sdio_csr.h> for CSR specific CCCR registers David Vrabel
2007-08-10 12:59   ` Marcel Holtmann
2007-08-10 13:00     ` David Vrabel
2007-08-10 13:37   ` Pierre Ossman
2007-08-10 12:28 ` sdio: add CSR vendor/device IDs David Vrabel
2007-08-10 13:37   ` Pierre Ossman
2007-08-10 12:29 ` David Vrabel [this message]
2007-08-10 13:38   ` [patch 5/5] sdio: add sdio_f0_readb() and sdio_f0_writeb() Pierre Ossman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=46BC5A3A.2030301@csr.com \
    --to=david.vrabel@csr.com \
    --cc=drzeus-list@drzeus.cx \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcel@holtmann.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.