Lines Matching refs:func
27 void sdio_claim_host(struct sdio_func *func) in sdio_claim_host() argument
29 BUG_ON(!func); in sdio_claim_host()
30 BUG_ON(!func->card); in sdio_claim_host()
32 mmc_claim_host(func->card->host); in sdio_claim_host()
43 void sdio_release_host(struct sdio_func *func) in sdio_release_host() argument
45 BUG_ON(!func); in sdio_release_host()
46 BUG_ON(!func->card); in sdio_release_host()
48 mmc_release_host(func->card->host); in sdio_release_host()
59 int sdio_enable_func(struct sdio_func *func) in sdio_enable_func() argument
65 BUG_ON(!func); in sdio_enable_func()
66 BUG_ON(!func->card); in sdio_enable_func()
68 pr_debug("SDIO: Enabling device %s...\n", sdio_func_id(func)); in sdio_enable_func()
70 ret = mmc_io_rw_direct(func->card, 0, 0, SDIO_CCCR_IOEx, 0, ®); in sdio_enable_func()
74 reg |= 1 << func->num; in sdio_enable_func()
76 ret = mmc_io_rw_direct(func->card, 1, 0, SDIO_CCCR_IOEx, reg, NULL); in sdio_enable_func()
80 timeout = jiffies + msecs_to_jiffies(func->enable_timeout); in sdio_enable_func()
83 ret = mmc_io_rw_direct(func->card, 0, 0, SDIO_CCCR_IORx, 0, ®); in sdio_enable_func()
86 if (reg & (1 << func->num)) in sdio_enable_func()
93 pr_debug("SDIO: Enabled device %s\n", sdio_func_id(func)); in sdio_enable_func()
98 pr_debug("SDIO: Failed to enable device %s\n", sdio_func_id(func)); in sdio_enable_func()
110 int sdio_disable_func(struct sdio_func *func) in sdio_disable_func() argument
115 BUG_ON(!func); in sdio_disable_func()
116 BUG_ON(!func->card); in sdio_disable_func()
118 pr_debug("SDIO: Disabling device %s...\n", sdio_func_id(func)); in sdio_disable_func()
120 ret = mmc_io_rw_direct(func->card, 0, 0, SDIO_CCCR_IOEx, 0, ®); in sdio_disable_func()
124 reg &= ~(1 << func->num); in sdio_disable_func()
126 ret = mmc_io_rw_direct(func->card, 1, 0, SDIO_CCCR_IOEx, reg, NULL); in sdio_disable_func()
130 pr_debug("SDIO: Disabled device %s\n", sdio_func_id(func)); in sdio_disable_func()
135 pr_debug("SDIO: Failed to disable device %s\n", sdio_func_id(func)); in sdio_disable_func()
159 int sdio_set_block_size(struct sdio_func *func, unsigned blksz) in sdio_set_block_size() argument
163 if (blksz > func->card->host->max_blk_size) in sdio_set_block_size()
167 blksz = min(func->max_blksize, func->card->host->max_blk_size); in sdio_set_block_size()
171 ret = mmc_io_rw_direct(func->card, 1, 0, in sdio_set_block_size()
172 SDIO_FBR_BASE(func->num) + SDIO_FBR_BLKSIZE, in sdio_set_block_size()
176 ret = mmc_io_rw_direct(func->card, 1, 0, in sdio_set_block_size()
177 SDIO_FBR_BASE(func->num) + SDIO_FBR_BLKSIZE + 1, in sdio_set_block_size()
181 func->cur_blksize = blksz; in sdio_set_block_size()
189 static inline unsigned int sdio_max_byte_size(struct sdio_func *func) in sdio_max_byte_size() argument
191 unsigned mval = func->card->host->max_blk_size; in sdio_max_byte_size()
193 if (mmc_blksz_for_byte_mode(func->card)) in sdio_max_byte_size()
194 mval = min(mval, func->cur_blksize); in sdio_max_byte_size()
196 mval = min(mval, func->max_blksize); in sdio_max_byte_size()
198 if (mmc_card_broken_byte_mode_512(func->card)) in sdio_max_byte_size()
218 unsigned int sdio_align_size(struct sdio_func *func, unsigned int sz) in sdio_align_size() argument
231 sz = mmc_align_data_size(func->card, sz); in sdio_align_size()
237 if (sz <= sdio_max_byte_size(func)) in sdio_align_size()
240 if (func->card->cccr.multi_block) { in sdio_align_size()
244 if ((sz % func->cur_blksize) == 0) in sdio_align_size()
251 blk_sz = ((sz + func->cur_blksize - 1) / in sdio_align_size()
252 func->cur_blksize) * func->cur_blksize; in sdio_align_size()
253 blk_sz = mmc_align_data_size(func->card, blk_sz); in sdio_align_size()
259 if ((blk_sz % func->cur_blksize) == 0) in sdio_align_size()
266 byte_sz = mmc_align_data_size(func->card, in sdio_align_size()
267 sz % func->cur_blksize); in sdio_align_size()
268 if (byte_sz <= sdio_max_byte_size(func)) { in sdio_align_size()
269 blk_sz = sz / func->cur_blksize; in sdio_align_size()
270 return blk_sz * func->cur_blksize + byte_sz; in sdio_align_size()
277 chunk_sz = mmc_align_data_size(func->card, in sdio_align_size()
278 sdio_max_byte_size(func)); in sdio_align_size()
279 if (chunk_sz == sdio_max_byte_size(func)) { in sdio_align_size()
285 byte_sz = mmc_align_data_size(func->card, in sdio_align_size()
303 static int sdio_io_rw_ext_helper(struct sdio_func *func, int write, in sdio_io_rw_ext_helper() argument
311 if (func->card->cccr.multi_block && (size > sdio_max_byte_size(func))) { in sdio_io_rw_ext_helper()
314 max_blocks = min(func->card->host->max_blk_count, 511u); in sdio_io_rw_ext_helper()
316 while (remainder >= func->cur_blksize) { in sdio_io_rw_ext_helper()
319 blocks = remainder / func->cur_blksize; in sdio_io_rw_ext_helper()
322 size = blocks * func->cur_blksize; in sdio_io_rw_ext_helper()
324 ret = mmc_io_rw_extended(func->card, write, in sdio_io_rw_ext_helper()
325 func->num, addr, incr_addr, buf, in sdio_io_rw_ext_helper()
326 blocks, func->cur_blksize); in sdio_io_rw_ext_helper()
339 size = min(remainder, sdio_max_byte_size(func)); in sdio_io_rw_ext_helper()
342 ret = mmc_io_rw_extended(func->card, write, func->num, addr, in sdio_io_rw_ext_helper()
365 u8 sdio_readb(struct sdio_func *func, unsigned int addr, int *err_ret) in sdio_readb() argument
370 BUG_ON(!func); in sdio_readb()
375 ret = mmc_io_rw_direct(func->card, 0, func->num, addr, 0, &val); in sdio_readb()
397 void sdio_writeb(struct sdio_func *func, u8 b, unsigned int addr, int *err_ret) in sdio_writeb() argument
401 BUG_ON(!func); in sdio_writeb()
403 ret = mmc_io_rw_direct(func->card, 1, func->num, addr, b, NULL); in sdio_writeb()
422 u8 sdio_writeb_readb(struct sdio_func *func, u8 write_byte, in sdio_writeb_readb() argument
428 ret = mmc_io_rw_direct(func->card, 1, func->num, addr, in sdio_writeb_readb()
449 int sdio_memcpy_fromio(struct sdio_func *func, void *dst, in sdio_memcpy_fromio() argument
452 return sdio_io_rw_ext_helper(func, 0, addr, 1, dst, count); in sdio_memcpy_fromio()
466 int sdio_memcpy_toio(struct sdio_func *func, unsigned int addr, in sdio_memcpy_toio() argument
469 return sdio_io_rw_ext_helper(func, 1, addr, 1, src, count); in sdio_memcpy_toio()
483 int sdio_readsb(struct sdio_func *func, void *dst, unsigned int addr, in sdio_readsb() argument
486 return sdio_io_rw_ext_helper(func, 0, addr, 0, dst, count); in sdio_readsb()
500 int sdio_writesb(struct sdio_func *func, unsigned int addr, void *src, in sdio_writesb() argument
503 return sdio_io_rw_ext_helper(func, 1, addr, 0, src, count); in sdio_writesb()
517 u16 sdio_readw(struct sdio_func *func, unsigned int addr, int *err_ret) in sdio_readw() argument
524 ret = sdio_memcpy_fromio(func, func->tmpbuf, addr, 2); in sdio_readw()
531 return le16_to_cpup((__le16 *)func->tmpbuf); in sdio_readw()
546 void sdio_writew(struct sdio_func *func, u16 b, unsigned int addr, int *err_ret) in sdio_writew() argument
550 *(__le16 *)func->tmpbuf = cpu_to_le16(b); in sdio_writew()
552 ret = sdio_memcpy_toio(func, addr, func->tmpbuf, 2); in sdio_writew()
569 u32 sdio_readl(struct sdio_func *func, unsigned int addr, int *err_ret) in sdio_readl() argument
576 ret = sdio_memcpy_fromio(func, func->tmpbuf, addr, 4); in sdio_readl()
583 return le32_to_cpup((__le32 *)func->tmpbuf); in sdio_readl()
598 void sdio_writel(struct sdio_func *func, u32 b, unsigned int addr, int *err_ret) in sdio_writel() argument
602 *(__le32 *)func->tmpbuf = cpu_to_le32(b); in sdio_writel()
604 ret = sdio_memcpy_toio(func, addr, func->tmpbuf, 4); in sdio_writel()
620 unsigned char sdio_f0_readb(struct sdio_func *func, unsigned int addr, in sdio_f0_readb() argument
626 BUG_ON(!func); in sdio_f0_readb()
631 ret = mmc_io_rw_direct(func->card, 0, 0, addr, 0, &val); in sdio_f0_readb()
656 void sdio_f0_writeb(struct sdio_func *func, unsigned char b, unsigned int addr, in sdio_f0_writeb() argument
661 BUG_ON(!func); in sdio_f0_writeb()
663 if ((addr < 0xF0 || addr > 0xFF) && (!mmc_card_lenient_fn0(func->card))) { in sdio_f0_writeb()
669 ret = mmc_io_rw_direct(func->card, 1, 0, addr, b, NULL); in sdio_f0_writeb()
685 mmc_pm_flag_t sdio_get_host_pm_caps(struct sdio_func *func) in sdio_get_host_pm_caps() argument
687 BUG_ON(!func); in sdio_get_host_pm_caps()
688 BUG_ON(!func->card); in sdio_get_host_pm_caps()
690 return func->card->host->pm_caps; in sdio_get_host_pm_caps()
706 int sdio_set_host_pm_flags(struct sdio_func *func, mmc_pm_flag_t flags) in sdio_set_host_pm_flags() argument
710 BUG_ON(!func); in sdio_set_host_pm_flags()
711 BUG_ON(!func->card); in sdio_set_host_pm_flags()
713 host = func->card->host; in sdio_set_host_pm_flags()