blob: 3ccf6919877ca80cf7e92d9eed10fc942b96c78c [file] [log] [blame]
Pierre Ossman46f555f2007-05-27 12:57:15 +02001/*
2 * linux/drivers/mmc/core/sdio_io.c
3 *
Pierre Ossmanad3868b2008-06-28 12:52:45 +02004 * Copyright 2007-2008 Pierre Ossman
Pierre Ossman46f555f2007-05-27 12:57:15 +02005 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or (at
9 * your option) any later version.
10 */
11
12#include <linux/mmc/host.h>
13#include <linux/mmc/card.h>
Pierre Ossmanfa64efa2007-05-27 14:22:37 +020014#include <linux/mmc/sdio.h>
Pierre Ossman46f555f2007-05-27 12:57:15 +020015#include <linux/mmc/sdio_func.h>
16
17#include "sdio_ops.h"
18
19/**
20 * sdio_claim_host - exclusively claim a bus for a certain SDIO function
21 * @func: SDIO function that will be accessed
22 *
23 * Claim a bus for a set of operations. The SDIO function given
24 * is used to figure out which bus is relevant.
25 */
26void sdio_claim_host(struct sdio_func *func)
27{
28 BUG_ON(!func);
29 BUG_ON(!func->card);
30
31 mmc_claim_host(func->card->host);
32}
33EXPORT_SYMBOL_GPL(sdio_claim_host);
34
35/**
36 * sdio_release_host - release a bus for a certain SDIO function
37 * @func: SDIO function that was accessed
38 *
39 * Release a bus, allowing others to claim the bus for their
40 * operations.
41 */
42void sdio_release_host(struct sdio_func *func)
43{
44 BUG_ON(!func);
45 BUG_ON(!func->card);
46
47 mmc_release_host(func->card->host);
48}
49EXPORT_SYMBOL_GPL(sdio_release_host);
50
51/**
Pierre Ossmanfa64efa2007-05-27 14:22:37 +020052 * sdio_enable_func - enables a SDIO function for usage
53 * @func: SDIO function to enable
54 *
55 * Powers up and activates a SDIO function so that register
56 * access is possible.
57 */
58int sdio_enable_func(struct sdio_func *func)
59{
60 int ret;
61 unsigned char reg;
62 unsigned long timeout;
63
64 BUG_ON(!func);
65 BUG_ON(!func->card);
66
67 pr_debug("SDIO: Enabling device %s...\n", sdio_func_id(func));
68
69 ret = mmc_io_rw_direct(func->card, 0, 0, SDIO_CCCR_IOEx, 0, &reg);
70 if (ret)
71 goto err;
72
73 reg |= 1 << func->num;
74
75 ret = mmc_io_rw_direct(func->card, 1, 0, SDIO_CCCR_IOEx, reg, NULL);
76 if (ret)
77 goto err;
78
79 /*
80 * FIXME: This should timeout based on information in the CIS,
81 * but we don't have card to parse that yet.
82 */
83 timeout = jiffies + HZ;
84
85 while (1) {
86 ret = mmc_io_rw_direct(func->card, 0, 0, SDIO_CCCR_IORx, 0, &reg);
87 if (ret)
88 goto err;
89 if (reg & (1 << func->num))
90 break;
91 ret = -ETIME;
92 if (time_after(jiffies, timeout))
93 goto err;
94 }
95
96 pr_debug("SDIO: Enabled device %s\n", sdio_func_id(func));
97
98 return 0;
99
100err:
101 pr_debug("SDIO: Failed to enable device %s\n", sdio_func_id(func));
102 return ret;
103}
104EXPORT_SYMBOL_GPL(sdio_enable_func);
105
106/**
107 * sdio_disable_func - disable a SDIO function
108 * @func: SDIO function to disable
109 *
110 * Powers down and deactivates a SDIO function. Register access
111 * to this function will fail until the function is reenabled.
112 */
113int sdio_disable_func(struct sdio_func *func)
114{
115 int ret;
116 unsigned char reg;
117
118 BUG_ON(!func);
119 BUG_ON(!func->card);
120
121 pr_debug("SDIO: Disabling device %s...\n", sdio_func_id(func));
122
123 ret = mmc_io_rw_direct(func->card, 0, 0, SDIO_CCCR_IOEx, 0, &reg);
124 if (ret)
125 goto err;
126
127 reg &= ~(1 << func->num);
128
129 ret = mmc_io_rw_direct(func->card, 1, 0, SDIO_CCCR_IOEx, reg, NULL);
130 if (ret)
131 goto err;
132
133 pr_debug("SDIO: Disabled device %s\n", sdio_func_id(func));
134
135 return 0;
136
137err:
138 pr_debug("SDIO: Failed to disable device %s\n", sdio_func_id(func));
139 return -EIO;
140}
141EXPORT_SYMBOL_GPL(sdio_disable_func);
142
143/**
David Vrabel9a08f822007-08-08 14:23:48 +0100144 * sdio_set_block_size - set the block size of an SDIO function
145 * @func: SDIO function to change
146 * @blksz: new block size or 0 to use the default.
147 *
148 * The default block size is the largest supported by both the function
149 * and the host, with a maximum of 512 to ensure that arbitrarily sized
150 * data transfer use the optimal (least) number of commands.
151 *
152 * A driver may call this to override the default block size set by the
153 * core. This can be used to set a block size greater than the maximum
154 * that reported by the card; it is the driver's responsibility to ensure
155 * it uses a value that the card supports.
156 *
157 * Returns 0 on success, -EINVAL if the host does not support the
158 * requested block size, or -EIO (etc.) if one of the resultant FBR block
159 * size register writes failed.
160 *
161 */
162int sdio_set_block_size(struct sdio_func *func, unsigned blksz)
163{
164 int ret;
165
166 if (blksz > func->card->host->max_blk_size)
167 return -EINVAL;
168
169 if (blksz == 0) {
Tomas Winkler6d373332008-06-30 10:50:24 +0300170 blksz = min(func->max_blksize, func->card->host->max_blk_size);
171 blksz = min(blksz, 512u);
David Vrabel9a08f822007-08-08 14:23:48 +0100172 }
173
174 ret = mmc_io_rw_direct(func->card, 1, 0,
175 SDIO_FBR_BASE(func->num) + SDIO_FBR_BLKSIZE,
176 blksz & 0xff, NULL);
177 if (ret)
178 return ret;
179 ret = mmc_io_rw_direct(func->card, 1, 0,
180 SDIO_FBR_BASE(func->num) + SDIO_FBR_BLKSIZE + 1,
181 (blksz >> 8) & 0xff, NULL);
182 if (ret)
183 return ret;
184 func->cur_blksize = blksz;
185 return 0;
186}
David Vrabel9a08f822007-08-08 14:23:48 +0100187EXPORT_SYMBOL_GPL(sdio_set_block_size);
188
Pierre Ossmaneea0f582008-06-28 13:22:40 +0200189/*
190 * Calculate the maximum byte mode transfer size
191 */
192static inline unsigned int sdio_max_byte_size(struct sdio_func *func)
193{
194 return min(min(min(
195 func->card->host->max_seg_size,
196 func->card->host->max_blk_size),
197 func->max_blksize),
198 512u); /* maximum size for byte mode */
199}
200
Pierre Ossmanad3868b2008-06-28 12:52:45 +0200201/**
202 * sdio_align_size - pads a transfer size to a more optimal value
203 * @func: SDIO function
204 * @sz: original transfer size
205 *
206 * Pads the original data size with a number of extra bytes in
207 * order to avoid controller bugs and/or performance hits
208 * (e.g. some controllers revert to PIO for certain sizes).
209 *
210 * If possible, it will also adjust the size so that it can be
211 * handled in just a single request.
212 *
213 * Returns the improved size, which might be unmodified.
214 */
215unsigned int sdio_align_size(struct sdio_func *func, unsigned int sz)
216{
217 unsigned int orig_sz;
218 unsigned int blk_sz, byte_sz;
219 unsigned chunk_sz;
220
221 orig_sz = sz;
222
223 /*
224 * Do a first check with the controller, in case it
225 * wants to increase the size up to a point where it
226 * might need more than one block.
227 */
228 sz = mmc_align_data_size(func->card, sz);
229
230 /*
231 * If we can still do this with just a byte transfer, then
232 * we're done.
233 */
Pierre Ossmaneea0f582008-06-28 13:22:40 +0200234 if (sz <= sdio_max_byte_size(func))
Pierre Ossmanad3868b2008-06-28 12:52:45 +0200235 return sz;
236
237 if (func->card->cccr.multi_block) {
238 /*
239 * Check if the transfer is already block aligned
240 */
241 if ((sz % func->cur_blksize) == 0)
242 return sz;
243
244 /*
245 * Realign it so that it can be done with one request,
246 * and recheck if the controller still likes it.
247 */
248 blk_sz = ((sz + func->cur_blksize - 1) /
249 func->cur_blksize) * func->cur_blksize;
250 blk_sz = mmc_align_data_size(func->card, blk_sz);
251
252 /*
253 * This value is only good if it is still just
254 * one request.
255 */
256 if ((blk_sz % func->cur_blksize) == 0)
257 return blk_sz;
258
259 /*
260 * We failed to do one request, but at least try to
261 * pad the remainder properly.
262 */
263 byte_sz = mmc_align_data_size(func->card,
264 sz % func->cur_blksize);
Pierre Ossmaneea0f582008-06-28 13:22:40 +0200265 if (byte_sz <= sdio_max_byte_size(func)) {
Pierre Ossmanad3868b2008-06-28 12:52:45 +0200266 blk_sz = sz / func->cur_blksize;
267 return blk_sz * func->cur_blksize + byte_sz;
268 }
269 } else {
270 /*
271 * We need multiple requests, so first check that the
272 * controller can handle the chunk size;
273 */
274 chunk_sz = mmc_align_data_size(func->card,
Pierre Ossmaneea0f582008-06-28 13:22:40 +0200275 sdio_max_byte_size(func));
276 if (chunk_sz == sdio_max_byte_size(func)) {
Pierre Ossmanad3868b2008-06-28 12:52:45 +0200277 /*
278 * Fix up the size of the remainder (if any)
279 */
280 byte_sz = orig_sz % chunk_sz;
281 if (byte_sz) {
282 byte_sz = mmc_align_data_size(func->card,
283 byte_sz);
284 }
285
286 return (orig_sz / chunk_sz) * chunk_sz + byte_sz;
287 }
288 }
289
290 /*
291 * The controller is simply incapable of transferring the size
292 * we want in decent manner, so just return the original size.
293 */
294 return orig_sz;
295}
296EXPORT_SYMBOL_GPL(sdio_align_size);
297
David Vrabeleb659462007-08-08 14:24:21 +0100298/* Split an arbitrarily sized data transfer into several
299 * IO_RW_EXTENDED commands. */
300static int sdio_io_rw_ext_helper(struct sdio_func *func, int write,
301 unsigned addr, int incr_addr, u8 *buf, unsigned size)
302{
303 unsigned remainder = size;
304 unsigned max_blocks;
305 int ret;
306
307 /* Do the bulk of the transfer using block mode (if supported). */
Pierre Ossmaneea0f582008-06-28 13:22:40 +0200308 if (func->card->cccr.multi_block && (size > sdio_max_byte_size(func))) {
David Vrabeleb659462007-08-08 14:24:21 +0100309 /* Blocks per command is limited by host count, host transfer
310 * size (we only use a single sg entry) and the maximum for
311 * IO_RW_EXTENDED of 511 blocks. */
Tomas Winkler6d373332008-06-30 10:50:24 +0300312 max_blocks = min(func->card->host->max_blk_count,
313 func->card->host->max_seg_size / func->cur_blksize);
314 max_blocks = min(max_blocks, 511u);
David Vrabeleb659462007-08-08 14:24:21 +0100315
316 while (remainder > func->cur_blksize) {
317 unsigned blocks;
318
319 blocks = remainder / func->cur_blksize;
320 if (blocks > max_blocks)
321 blocks = max_blocks;
322 size = blocks * func->cur_blksize;
323
324 ret = mmc_io_rw_extended(func->card, write,
325 func->num, addr, incr_addr, buf,
326 blocks, func->cur_blksize);
327 if (ret)
328 return ret;
329
330 remainder -= size;
331 buf += size;
332 if (incr_addr)
333 addr += size;
334 }
335 }
336
337 /* Write the remainder using byte mode. */
338 while (remainder > 0) {
Pierre Ossmaneea0f582008-06-28 13:22:40 +0200339 size = min(remainder, sdio_max_byte_size(func));
David Vrabeleb659462007-08-08 14:24:21 +0100340
341 ret = mmc_io_rw_extended(func->card, write, func->num, addr,
342 incr_addr, buf, 1, size);
343 if (ret)
344 return ret;
345
346 remainder -= size;
347 buf += size;
348 if (incr_addr)
349 addr += size;
350 }
351 return 0;
352}
353
David Vrabel9a08f822007-08-08 14:23:48 +0100354/**
Pierre Ossman46f555f2007-05-27 12:57:15 +0200355 * sdio_readb - read a single byte from a SDIO function
356 * @func: SDIO function to access
357 * @addr: address to read
358 * @err_ret: optional status value from transfer
359 *
360 * Reads a single byte from the address space of a given SDIO
361 * function. If there is a problem reading the address, 0xff
362 * is returned and @err_ret will contain the error code.
363 */
Tomas Winkler6d373332008-06-30 10:50:24 +0300364u8 sdio_readb(struct sdio_func *func, unsigned int addr, int *err_ret)
Pierre Ossman46f555f2007-05-27 12:57:15 +0200365{
366 int ret;
Tomas Winkler6d373332008-06-30 10:50:24 +0300367 u8 val;
Pierre Ossman46f555f2007-05-27 12:57:15 +0200368
369 BUG_ON(!func);
370
371 if (err_ret)
372 *err_ret = 0;
373
374 ret = mmc_io_rw_direct(func->card, 0, func->num, addr, 0, &val);
375 if (ret) {
376 if (err_ret)
377 *err_ret = ret;
378 return 0xFF;
379 }
380
381 return val;
382}
383EXPORT_SYMBOL_GPL(sdio_readb);
384
385/**
386 * sdio_writeb - write a single byte to a SDIO function
387 * @func: SDIO function to access
388 * @b: byte to write
389 * @addr: address to write to
390 * @err_ret: optional status value from transfer
391 *
392 * Writes a single byte to the address space of a given SDIO
393 * function. @err_ret will contain the status of the actual
394 * transfer.
395 */
Tomas Winkler6d373332008-06-30 10:50:24 +0300396void sdio_writeb(struct sdio_func *func, u8 b, unsigned int addr, int *err_ret)
Pierre Ossman46f555f2007-05-27 12:57:15 +0200397{
398 int ret;
399
400 BUG_ON(!func);
401
402 ret = mmc_io_rw_direct(func->card, 1, func->num, addr, b, NULL);
403 if (err_ret)
404 *err_ret = ret;
405}
406EXPORT_SYMBOL_GPL(sdio_writeb);
407
Pierre Ossman112c9db2007-07-06 13:35:01 +0200408/**
409 * sdio_memcpy_fromio - read a chunk of memory from a SDIO function
410 * @func: SDIO function to access
411 * @dst: buffer to store the data
412 * @addr: address to begin reading from
413 * @count: number of bytes to read
414 *
David Vrabeleb659462007-08-08 14:24:21 +0100415 * Reads from the address space of a given SDIO function. Return
416 * value indicates if the transfer succeeded or not.
Pierre Ossman112c9db2007-07-06 13:35:01 +0200417 */
418int sdio_memcpy_fromio(struct sdio_func *func, void *dst,
419 unsigned int addr, int count)
420{
David Vrabeleb659462007-08-08 14:24:21 +0100421 return sdio_io_rw_ext_helper(func, 0, addr, 1, dst, count);
Pierre Ossman112c9db2007-07-06 13:35:01 +0200422}
423EXPORT_SYMBOL_GPL(sdio_memcpy_fromio);
424
425/**
426 * sdio_memcpy_toio - write a chunk of memory to a SDIO function
427 * @func: SDIO function to access
428 * @addr: address to start writing to
429 * @src: buffer that contains the data to write
430 * @count: number of bytes to write
431 *
David Vrabeleb659462007-08-08 14:24:21 +0100432 * Writes to the address space of a given SDIO function. Return
433 * value indicates if the transfer succeeded or not.
Pierre Ossman112c9db2007-07-06 13:35:01 +0200434 */
435int sdio_memcpy_toio(struct sdio_func *func, unsigned int addr,
436 void *src, int count)
437{
David Vrabeleb659462007-08-08 14:24:21 +0100438 return sdio_io_rw_ext_helper(func, 1, addr, 1, src, count);
Pierre Ossman112c9db2007-07-06 13:35:01 +0200439}
440EXPORT_SYMBOL_GPL(sdio_memcpy_toio);
441
442/**
443 * sdio_readsb - read from a FIFO on a SDIO function
444 * @func: SDIO function to access
445 * @dst: buffer to store the data
446 * @addr: address of (single byte) FIFO
447 * @count: number of bytes to read
448 *
David Vrabeleb659462007-08-08 14:24:21 +0100449 * Reads from the specified FIFO of a given SDIO function. Return
450 * value indicates if the transfer succeeded or not.
Pierre Ossman112c9db2007-07-06 13:35:01 +0200451 */
452int sdio_readsb(struct sdio_func *func, void *dst, unsigned int addr,
453 int count)
454{
David Vrabeleb659462007-08-08 14:24:21 +0100455 return sdio_io_rw_ext_helper(func, 0, addr, 0, dst, count);
Pierre Ossman112c9db2007-07-06 13:35:01 +0200456}
Pierre Ossman112c9db2007-07-06 13:35:01 +0200457EXPORT_SYMBOL_GPL(sdio_readsb);
458
459/**
460 * sdio_writesb - write to a FIFO of a SDIO function
461 * @func: SDIO function to access
462 * @addr: address of (single byte) FIFO
463 * @src: buffer that contains the data to write
464 * @count: number of bytes to write
465 *
David Vrabeleb659462007-08-08 14:24:21 +0100466 * Writes to the specified FIFO of a given SDIO function. Return
467 * value indicates if the transfer succeeded or not.
Pierre Ossman112c9db2007-07-06 13:35:01 +0200468 */
469int sdio_writesb(struct sdio_func *func, unsigned int addr, void *src,
470 int count)
471{
David Vrabeleb659462007-08-08 14:24:21 +0100472 return sdio_io_rw_ext_helper(func, 1, addr, 0, src, count);
Pierre Ossman112c9db2007-07-06 13:35:01 +0200473}
474EXPORT_SYMBOL_GPL(sdio_writesb);
475
476/**
477 * sdio_readw - read a 16 bit integer from a SDIO function
478 * @func: SDIO function to access
479 * @addr: address to read
480 * @err_ret: optional status value from transfer
481 *
482 * Reads a 16 bit integer from the address space of a given SDIO
483 * function. If there is a problem reading the address, 0xffff
484 * is returned and @err_ret will contain the error code.
485 */
Tomas Winkler6d373332008-06-30 10:50:24 +0300486u16 sdio_readw(struct sdio_func *func, unsigned int addr, int *err_ret)
Pierre Ossman112c9db2007-07-06 13:35:01 +0200487{
488 int ret;
489
490 if (err_ret)
491 *err_ret = 0;
492
493 ret = sdio_memcpy_fromio(func, func->tmpbuf, addr, 2);
494 if (ret) {
495 if (err_ret)
496 *err_ret = ret;
497 return 0xFFFF;
498 }
499
Tomas Winkler6d373332008-06-30 10:50:24 +0300500 return le16_to_cpup((__le16 *)func->tmpbuf);
Pierre Ossman112c9db2007-07-06 13:35:01 +0200501}
502EXPORT_SYMBOL_GPL(sdio_readw);
503
504/**
505 * sdio_writew - write a 16 bit integer to a SDIO function
506 * @func: SDIO function to access
507 * @b: integer to write
508 * @addr: address to write to
509 * @err_ret: optional status value from transfer
510 *
511 * Writes a 16 bit integer to the address space of a given SDIO
512 * function. @err_ret will contain the status of the actual
513 * transfer.
514 */
Tomas Winkler6d373332008-06-30 10:50:24 +0300515void sdio_writew(struct sdio_func *func, u16 b, unsigned int addr, int *err_ret)
Pierre Ossman112c9db2007-07-06 13:35:01 +0200516{
517 int ret;
518
Tomas Winkler6d373332008-06-30 10:50:24 +0300519 *(__le16 *)func->tmpbuf = cpu_to_le16(b);
Pierre Ossman112c9db2007-07-06 13:35:01 +0200520
521 ret = sdio_memcpy_toio(func, addr, func->tmpbuf, 2);
522 if (err_ret)
523 *err_ret = ret;
524}
525EXPORT_SYMBOL_GPL(sdio_writew);
526
527/**
528 * sdio_readl - read a 32 bit integer from a SDIO function
529 * @func: SDIO function to access
530 * @addr: address to read
531 * @err_ret: optional status value from transfer
532 *
533 * Reads a 32 bit integer from the address space of a given SDIO
534 * function. If there is a problem reading the address,
535 * 0xffffffff is returned and @err_ret will contain the error
536 * code.
537 */
Tomas Winkler6d373332008-06-30 10:50:24 +0300538u32 sdio_readl(struct sdio_func *func, unsigned int addr, int *err_ret)
Pierre Ossman112c9db2007-07-06 13:35:01 +0200539{
540 int ret;
541
542 if (err_ret)
543 *err_ret = 0;
544
545 ret = sdio_memcpy_fromio(func, func->tmpbuf, addr, 4);
546 if (ret) {
547 if (err_ret)
548 *err_ret = ret;
549 return 0xFFFFFFFF;
550 }
551
Tomas Winkler6d373332008-06-30 10:50:24 +0300552 return le32_to_cpup((__le32 *)func->tmpbuf);
Pierre Ossman112c9db2007-07-06 13:35:01 +0200553}
554EXPORT_SYMBOL_GPL(sdio_readl);
555
556/**
557 * sdio_writel - write a 32 bit integer to a SDIO function
558 * @func: SDIO function to access
559 * @b: integer to write
560 * @addr: address to write to
561 * @err_ret: optional status value from transfer
562 *
563 * Writes a 32 bit integer to the address space of a given SDIO
564 * function. @err_ret will contain the status of the actual
565 * transfer.
566 */
Tomas Winkler6d373332008-06-30 10:50:24 +0300567void sdio_writel(struct sdio_func *func, u32 b, unsigned int addr, int *err_ret)
Pierre Ossman112c9db2007-07-06 13:35:01 +0200568{
569 int ret;
570
Tomas Winkler6d373332008-06-30 10:50:24 +0300571 *(__le32 *)func->tmpbuf = cpu_to_le32(b);
Pierre Ossman112c9db2007-07-06 13:35:01 +0200572
573 ret = sdio_memcpy_toio(func, addr, func->tmpbuf, 4);
574 if (err_ret)
575 *err_ret = ret;
576}
577EXPORT_SYMBOL_GPL(sdio_writel);
578
David Vrabel7806cdb2007-08-10 13:29:46 +0100579/**
580 * sdio_f0_readb - read a single byte from SDIO function 0
581 * @func: an SDIO function of the card
582 * @addr: address to read
583 * @err_ret: optional status value from transfer
584 *
585 * Reads a single byte from the address space of SDIO function 0.
586 * If there is a problem reading the address, 0xff is returned
587 * and @err_ret will contain the error code.
588 */
589unsigned char sdio_f0_readb(struct sdio_func *func, unsigned int addr,
590 int *err_ret)
591{
592 int ret;
593 unsigned char val;
594
595 BUG_ON(!func);
596
597 if (err_ret)
598 *err_ret = 0;
599
600 ret = mmc_io_rw_direct(func->card, 0, 0, addr, 0, &val);
601 if (ret) {
602 if (err_ret)
603 *err_ret = ret;
604 return 0xFF;
605 }
606
607 return val;
608}
609EXPORT_SYMBOL_GPL(sdio_f0_readb);
610
611/**
612 * sdio_f0_writeb - write a single byte to SDIO function 0
613 * @func: an SDIO function of the card
614 * @b: byte to write
615 * @addr: address to write to
616 * @err_ret: optional status value from transfer
617 *
618 * Writes a single byte to the address space of SDIO function 0.
619 * @err_ret will contain the status of the actual transfer.
620 *
621 * Only writes to the vendor specific CCCR registers (0xF0 -
622 * 0xFF) are permiited; @err_ret will be set to -EINVAL for *
623 * writes outside this range.
624 */
625void sdio_f0_writeb(struct sdio_func *func, unsigned char b, unsigned int addr,
626 int *err_ret)
627{
628 int ret;
629
630 BUG_ON(!func);
631
632 if (addr < 0xF0 || addr > 0xFF) {
633 if (err_ret)
634 *err_ret = -EINVAL;
635 return;
636 }
637
638 ret = mmc_io_rw_direct(func->card, 1, 0, addr, b, NULL);
639 if (err_ret)
640 *err_ret = ret;
641}
642EXPORT_SYMBOL_GPL(sdio_f0_writeb);