Lines Matching refs:func
26 void sdio_claim_host(struct sdio_func *func) in sdio_claim_host() argument
28 BUG_ON(!func); in sdio_claim_host()
29 BUG_ON(!func->card); in sdio_claim_host()
31 mmc_claim_host(func->card->host); in sdio_claim_host()
42 void sdio_release_host(struct sdio_func *func) in sdio_release_host() argument
44 BUG_ON(!func); in sdio_release_host()
45 BUG_ON(!func->card); in sdio_release_host()
47 mmc_release_host(func->card->host); in sdio_release_host()
58 int sdio_enable_func(struct sdio_func *func) in sdio_enable_func() argument
64 BUG_ON(!func); in sdio_enable_func()
65 BUG_ON(!func->card); in sdio_enable_func()
67 pr_debug("SDIO: Enabling device %s...\n", sdio_func_id(func)); in sdio_enable_func()
69 ret = mmc_io_rw_direct(func->card, 0, 0, SDIO_CCCR_IOEx, 0, ®); in sdio_enable_func()
73 reg |= 1 << func->num; in sdio_enable_func()
75 ret = mmc_io_rw_direct(func->card, 1, 0, SDIO_CCCR_IOEx, reg, NULL); in sdio_enable_func()
79 timeout = jiffies + msecs_to_jiffies(func->enable_timeout); in sdio_enable_func()
82 ret = mmc_io_rw_direct(func->card, 0, 0, SDIO_CCCR_IORx, 0, ®); in sdio_enable_func()
85 if (reg & (1 << func->num)) in sdio_enable_func()
92 pr_debug("SDIO: Enabled device %s\n", sdio_func_id(func)); in sdio_enable_func()
97 pr_debug("SDIO: Failed to enable device %s\n", sdio_func_id(func)); in sdio_enable_func()
109 int sdio_disable_func(struct sdio_func *func) in sdio_disable_func() argument
114 BUG_ON(!func); in sdio_disable_func()
115 BUG_ON(!func->card); in sdio_disable_func()
117 pr_debug("SDIO: Disabling device %s...\n", sdio_func_id(func)); in sdio_disable_func()
119 ret = mmc_io_rw_direct(func->card, 0, 0, SDIO_CCCR_IOEx, 0, ®); in sdio_disable_func()
123 reg &= ~(1 << func->num); in sdio_disable_func()
125 ret = mmc_io_rw_direct(func->card, 1, 0, SDIO_CCCR_IOEx, reg, NULL); in sdio_disable_func()
129 pr_debug("SDIO: Disabled device %s\n", sdio_func_id(func)); in sdio_disable_func()
134 pr_debug("SDIO: Failed to disable device %s\n", sdio_func_id(func)); in sdio_disable_func()
158 int sdio_set_block_size(struct sdio_func *func, unsigned blksz) in sdio_set_block_size() argument
162 if (blksz > func->card->host->max_blk_size) in sdio_set_block_size()
166 blksz = min(func->max_blksize, func->card->host->max_blk_size); in sdio_set_block_size()
170 ret = mmc_io_rw_direct(func->card, 1, 0, in sdio_set_block_size()
171 SDIO_FBR_BASE(func->num) + SDIO_FBR_BLKSIZE, in sdio_set_block_size()
175 ret = mmc_io_rw_direct(func->card, 1, 0, in sdio_set_block_size()
176 SDIO_FBR_BASE(func->num) + SDIO_FBR_BLKSIZE + 1, in sdio_set_block_size()
180 func->cur_blksize = blksz; in sdio_set_block_size()
188 static inline unsigned int sdio_max_byte_size(struct sdio_func *func) in sdio_max_byte_size() argument
190 unsigned mval = min(func->card->host->max_seg_size, in sdio_max_byte_size()
191 func->card->host->max_blk_size); in sdio_max_byte_size()
192 mval = min(mval, func->max_blksize); in sdio_max_byte_size()
210 unsigned int sdio_align_size(struct sdio_func *func, unsigned int sz) in sdio_align_size() argument
223 sz = mmc_align_data_size(func->card, sz); in sdio_align_size()
229 if (sz <= sdio_max_byte_size(func)) in sdio_align_size()
232 if (func->card->cccr.multi_block) { in sdio_align_size()
236 if ((sz % func->cur_blksize) == 0) in sdio_align_size()
243 blk_sz = ((sz + func->cur_blksize - 1) / in sdio_align_size()
244 func->cur_blksize) * func->cur_blksize; in sdio_align_size()
245 blk_sz = mmc_align_data_size(func->card, blk_sz); in sdio_align_size()
251 if ((blk_sz % func->cur_blksize) == 0) in sdio_align_size()
258 byte_sz = mmc_align_data_size(func->card, in sdio_align_size()
259 sz % func->cur_blksize); in sdio_align_size()
260 if (byte_sz <= sdio_max_byte_size(func)) { in sdio_align_size()
261 blk_sz = sz / func->cur_blksize; in sdio_align_size()
262 return blk_sz * func->cur_blksize + byte_sz; in sdio_align_size()
269 chunk_sz = mmc_align_data_size(func->card, in sdio_align_size()
270 sdio_max_byte_size(func)); in sdio_align_size()
271 if (chunk_sz == sdio_max_byte_size(func)) { in sdio_align_size()
277 byte_sz = mmc_align_data_size(func->card, in sdio_align_size()
295 static int sdio_io_rw_ext_helper(struct sdio_func *func, int write, in sdio_io_rw_ext_helper() argument
303 if (func->card->cccr.multi_block && (size > sdio_max_byte_size(func))) { in sdio_io_rw_ext_helper()
307 max_blocks = min(func->card->host->max_blk_count, in sdio_io_rw_ext_helper()
308 func->card->host->max_seg_size / func->cur_blksize); in sdio_io_rw_ext_helper()
311 while (remainder > func->cur_blksize) { in sdio_io_rw_ext_helper()
314 blocks = remainder / func->cur_blksize; in sdio_io_rw_ext_helper()
317 size = blocks * func->cur_blksize; in sdio_io_rw_ext_helper()
319 ret = mmc_io_rw_extended(func->card, write, in sdio_io_rw_ext_helper()
320 func->num, addr, incr_addr, buf, in sdio_io_rw_ext_helper()
321 blocks, func->cur_blksize); in sdio_io_rw_ext_helper()
334 size = min(remainder, sdio_max_byte_size(func)); in sdio_io_rw_ext_helper()
336 ret = mmc_io_rw_extended(func->card, write, func->num, addr, in sdio_io_rw_ext_helper()
359 u8 sdio_readb(struct sdio_func *func, unsigned int addr, int *err_ret) in sdio_readb() argument
364 BUG_ON(!func); in sdio_readb()
369 ret = mmc_io_rw_direct(func->card, 0, func->num, addr, 0, &val); in sdio_readb()
391 unsigned char sdio_readb_ext(struct sdio_func *func, unsigned int addr, in sdio_readb_ext() argument
397 BUG_ON(!func); in sdio_readb_ext()
402 ret = mmc_io_rw_direct(func->card, 0, func->num, addr, (u8)in, &val); in sdio_readb_ext()
424 void sdio_writeb(struct sdio_func *func, u8 b, unsigned int addr, int *err_ret) in sdio_writeb() argument
428 BUG_ON(!func); in sdio_writeb()
430 ret = mmc_io_rw_direct(func->card, 1, func->num, addr, b, NULL); in sdio_writeb()
446 int sdio_memcpy_fromio(struct sdio_func *func, void *dst, in sdio_memcpy_fromio() argument
449 return sdio_io_rw_ext_helper(func, 0, addr, 1, dst, count); in sdio_memcpy_fromio()
463 int sdio_memcpy_toio(struct sdio_func *func, unsigned int addr, in sdio_memcpy_toio() argument
466 return sdio_io_rw_ext_helper(func, 1, addr, 1, src, count); in sdio_memcpy_toio()
480 int sdio_readsb(struct sdio_func *func, void *dst, unsigned int addr, in sdio_readsb() argument
483 return sdio_io_rw_ext_helper(func, 0, addr, 0, dst, count); in sdio_readsb()
497 int sdio_writesb(struct sdio_func *func, unsigned int addr, void *src, in sdio_writesb() argument
500 return sdio_io_rw_ext_helper(func, 1, addr, 0, src, count); in sdio_writesb()
514 u16 sdio_readw(struct sdio_func *func, unsigned int addr, int *err_ret) in sdio_readw() argument
521 ret = sdio_memcpy_fromio(func, func->tmpbuf, addr, 2); in sdio_readw()
528 return le16_to_cpup((__le16 *)func->tmpbuf); in sdio_readw()
543 void sdio_writew(struct sdio_func *func, u16 b, unsigned int addr, int *err_ret) in sdio_writew() argument
547 *(__le16 *)func->tmpbuf = cpu_to_le16(b); in sdio_writew()
549 ret = sdio_memcpy_toio(func, addr, func->tmpbuf, 2); in sdio_writew()
566 u32 sdio_readl(struct sdio_func *func, unsigned int addr, int *err_ret) in sdio_readl() argument
573 ret = sdio_memcpy_fromio(func, func->tmpbuf, addr, 4); in sdio_readl()
580 return le32_to_cpup((__le32 *)func->tmpbuf); in sdio_readl()
595 void sdio_writel(struct sdio_func *func, u32 b, unsigned int addr, int *err_ret) in sdio_writel() argument
599 *(__le32 *)func->tmpbuf = cpu_to_le32(b); in sdio_writel()
601 ret = sdio_memcpy_toio(func, addr, func->tmpbuf, 4); in sdio_writel()
617 unsigned char sdio_f0_readb(struct sdio_func *func, unsigned int addr, in sdio_f0_readb() argument
623 BUG_ON(!func); in sdio_f0_readb()
628 ret = mmc_io_rw_direct(func->card, 0, 0, addr, 0, &val); in sdio_f0_readb()
653 void sdio_f0_writeb(struct sdio_func *func, unsigned char b, unsigned int addr, in sdio_f0_writeb() argument
658 BUG_ON(!func); in sdio_f0_writeb()
666 ret = mmc_io_rw_direct(func->card, 1, 0, addr, b, NULL); in sdio_f0_writeb()