Lines Matching refs:func

22  *	@func: SDIO function that will be accessed
27 void sdio_claim_host(struct sdio_func *func)
29 if (WARN_ON(!func))
32 mmc_claim_host(func->card->host);
38 * @func: SDIO function that was accessed
43 void sdio_release_host(struct sdio_func *func)
45 if (WARN_ON(!func))
48 mmc_release_host(func->card->host);
54 * @func: SDIO function to enable
59 int sdio_enable_func(struct sdio_func *func)
65 if (!func)
68 pr_debug("SDIO: Enabling device %s...\n", sdio_func_id(func));
70 ret = mmc_io_rw_direct(func->card, 0, 0, SDIO_CCCR_IOEx, 0, &reg);
74 reg |= 1 << func->num;
76 ret = mmc_io_rw_direct(func->card, 1, 0, SDIO_CCCR_IOEx, reg, NULL);
80 timeout = jiffies + msecs_to_jiffies(func->enable_timeout);
83 ret = mmc_io_rw_direct(func->card, 0, 0, SDIO_CCCR_IORx, 0, &reg);
86 if (reg & (1 << func->num))
93 pr_debug("SDIO: Enabled device %s\n", sdio_func_id(func));
98 pr_debug("SDIO: Failed to enable device %s\n", sdio_func_id(func));
105 * @func: SDIO function to disable
110 int sdio_disable_func(struct sdio_func *func)
115 if (!func)
118 pr_debug("SDIO: Disabling device %s...\n", sdio_func_id(func));
120 ret = mmc_io_rw_direct(func->card, 0, 0, SDIO_CCCR_IOEx, 0, &reg);
124 reg &= ~(1 << func->num);
126 ret = mmc_io_rw_direct(func->card, 1, 0, SDIO_CCCR_IOEx, reg, NULL);
130 pr_debug("SDIO: Disabled device %s\n", sdio_func_id(func));
135 pr_debug("SDIO: Failed to disable device %s\n", sdio_func_id(func));
142 * @func: SDIO function to change
159 int sdio_set_block_size(struct sdio_func *func, unsigned blksz)
163 if (blksz > func->card->host->max_blk_size)
167 blksz = min(func->max_blksize, func->card->host->max_blk_size);
171 ret = mmc_io_rw_direct(func->card, 1, 0,
172 SDIO_FBR_BASE(func->num) + SDIO_FBR_BLKSIZE,
176 ret = mmc_io_rw_direct(func->card, 1, 0,
177 SDIO_FBR_BASE(func->num) + SDIO_FBR_BLKSIZE + 1,
181 func->cur_blksize = blksz;
189 static inline unsigned int sdio_max_byte_size(struct sdio_func *func)
191 unsigned mval = func->card->host->max_blk_size;
193 if (mmc_blksz_for_byte_mode(func->card))
194 mval = min(mval, func->cur_blksize);
196 mval = min(mval, func->max_blksize);
198 if (mmc_card_broken_byte_mode_512(func->card))
206 * to take into account the properties of the host, as to enable the SDIO func
221 * @func: SDIO function
233 unsigned int sdio_align_size(struct sdio_func *func, unsigned int sz)
252 if (sz <= sdio_max_byte_size(func))
255 if (func->card->cccr.multi_block) {
259 if ((sz % func->cur_blksize) == 0)
266 blk_sz = ((sz + func->cur_blksize - 1) /
267 func->cur_blksize) * func->cur_blksize;
274 if ((blk_sz % func->cur_blksize) == 0)
281 byte_sz = _sdio_align_size(sz % func->cur_blksize);
282 if (byte_sz <= sdio_max_byte_size(func)) {
283 blk_sz = sz / func->cur_blksize;
284 return blk_sz * func->cur_blksize + byte_sz;
291 chunk_sz = _sdio_align_size(sdio_max_byte_size(func));
292 if (chunk_sz == sdio_max_byte_size(func)) {
315 static int sdio_io_rw_ext_helper(struct sdio_func *func, int write,
322 if (!func || (func->num > 7))
326 if (func->card->cccr.multi_block && (size > sdio_max_byte_size(func))) {
329 max_blocks = min(func->card->host->max_blk_count, 511u);
331 while (remainder >= func->cur_blksize) {
334 blocks = remainder / func->cur_blksize;
337 size = blocks * func->cur_blksize;
339 ret = mmc_io_rw_extended(func->card, write,
340 func->num, addr, incr_addr, buf,
341 blocks, func->cur_blksize);
354 size = min(remainder, sdio_max_byte_size(func));
357 ret = mmc_io_rw_extended(func->card, write, func->num, addr,
372 * @func: SDIO function to access
380 u8 sdio_readb(struct sdio_func *func, unsigned int addr, int *err_ret)
385 if (!func) {
391 ret = mmc_io_rw_direct(func->card, 0, func->num, addr, 0, &val);
403 * @func: SDIO function to access
412 void sdio_writeb(struct sdio_func *func, u8 b, unsigned int addr, int *err_ret)
416 if (!func) {
422 ret = mmc_io_rw_direct(func->card, 1, func->num, addr, b, NULL);
430 * @func: SDIO function to access
441 u8 sdio_writeb_readb(struct sdio_func *func, u8 write_byte,
447 ret = mmc_io_rw_direct(func->card, 1, func->num, addr,
460 * @func: SDIO function to access
468 int sdio_memcpy_fromio(struct sdio_func *func, void *dst,
471 return sdio_io_rw_ext_helper(func, 0, addr, 1, dst, count);
477 * @func: SDIO function to access
485 int sdio_memcpy_toio(struct sdio_func *func, unsigned int addr,
488 return sdio_io_rw_ext_helper(func, 1, addr, 1, src, count);
494 * @func: SDIO function to access
502 int sdio_readsb(struct sdio_func *func, void *dst, unsigned int addr,
505 return sdio_io_rw_ext_helper(func, 0, addr, 0, dst, count);
511 * @func: SDIO function to access
519 int sdio_writesb(struct sdio_func *func, unsigned int addr, void *src,
522 return sdio_io_rw_ext_helper(func, 1, addr, 0, src, count);
528 * @func: SDIO function to access
536 u16 sdio_readw(struct sdio_func *func, unsigned int addr, int *err_ret)
540 ret = sdio_memcpy_fromio(func, func->tmpbuf, addr, 2);
546 return le16_to_cpup((__le16 *)func->tmpbuf);
552 * @func: SDIO function to access
561 void sdio_writew(struct sdio_func *func, u16 b, unsigned int addr, int *err_ret)
565 *(__le16 *)func->tmpbuf = cpu_to_le16(b);
567 ret = sdio_memcpy_toio(func, addr, func->tmpbuf, 2);
575 * @func: SDIO function to access
584 u32 sdio_readl(struct sdio_func *func, unsigned int addr, int *err_ret)
588 ret = sdio_memcpy_fromio(func, func->tmpbuf, addr, 4);
594 return le32_to_cpup((__le32 *)func->tmpbuf);
600 * @func: SDIO function to access
609 void sdio_writel(struct sdio_func *func, u32 b, unsigned int addr, int *err_ret)
613 *(__le32 *)func->tmpbuf = cpu_to_le32(b);
615 ret = sdio_memcpy_toio(func, addr, func->tmpbuf, 4);
623 * @func: an SDIO function of the card
631 unsigned char sdio_f0_readb(struct sdio_func *func, unsigned int addr,
637 if (!func) {
643 ret = mmc_io_rw_direct(func->card, 0, 0, addr, 0, &val);
655 * @func: an SDIO function of the card
667 void sdio_f0_writeb(struct sdio_func *func, unsigned char b, unsigned int addr,
672 if (!func) {
678 if ((addr < 0xF0 || addr > 0xFF) && (!mmc_card_lenient_fn0(func->card))) {
684 ret = mmc_io_rw_direct(func->card, 1, 0, addr, b, NULL);
692 * @func: SDIO function attached to host
700 mmc_pm_flag_t sdio_get_host_pm_caps(struct sdio_func *func)
702 if (!func)
705 return func->card->host->pm_caps;
711 * @func: SDIO function attached to host
722 int sdio_set_host_pm_flags(struct sdio_func *func, mmc_pm_flag_t flags)
726 if (!func)
729 host = func->card->host;
742 * @func: SDIO function attached to host
759 void sdio_retune_crc_disable(struct sdio_func *func)
761 func->card->host->retune_crc_disable = true;
767 * @func: SDIO function attached to host
771 void sdio_retune_crc_enable(struct sdio_func *func)
773 func->card->host->retune_crc_disable = false;
779 * @func: SDIO function attached to host
794 void sdio_retune_hold_now(struct sdio_func *func)
796 mmc_retune_hold_now(func->card->host);
802 * @func: SDIO function attached to host
810 void sdio_retune_release(struct sdio_func *func)
812 mmc_retune_release(func->card->host);