Lines Matching refs:func
88 enum sdio_func_num func, in sdio_io_rw_direct() argument
97 cmd.arg = (func << SDIO_CMD_ARG_FUNC_NUM_SHIFT) | in sdio_io_rw_direct()
126 enum sdio_func_num func, in sdio_io_rw_extended() argument
137 cmd.arg = (func << SDIO_CMD_ARG_FUNC_NUM_SHIFT) | in sdio_io_rw_extended()
163 static int sdio_io_rw_extended_helper(struct sdio_func *func, in sdio_io_rw_extended_helper() argument
174 if (func->num > SDIO_MAX_IO_NUMS) { in sdio_io_rw_extended_helper()
178 if ((func->card->cccr_flags & SDIO_SUPPORT_MULTIBLOCK) && in sdio_io_rw_extended_helper()
179 ((len > func->block_size))) { in sdio_io_rw_extended_helper()
181 while (remaining >= func->block_size) { in sdio_io_rw_extended_helper()
182 blocks = remaining / func->block_size; in sdio_io_rw_extended_helper()
183 size = blocks * func->block_size; in sdio_io_rw_extended_helper()
184 ret = sdio_io_rw_extended(func->card, direction, in sdio_io_rw_extended_helper()
185 func->num, reg_addr, increment, buf, blocks, in sdio_io_rw_extended_helper()
186 func->block_size); in sdio_io_rw_extended_helper()
200 size = MIN(remaining, func->cis.max_blk_size); in sdio_io_rw_extended_helper()
202 ret = sdio_io_rw_extended(func->card, direction, func->num, in sdio_io_rw_extended_helper()
304 static void sdio_decode_cis(struct sdio_cis *cis, enum sdio_func_num func, in sdio_decode_cis() argument
316 if (func == 0) { in sdio_decode_cis()
334 static int sdio_read_cis(struct sdio_func *func, in sdio_read_cis() argument
339 char *data = func->card->card_buffer; in sdio_read_cis()
344 memset(&func->cis, 0, sizeof(struct sdio_cis)); in sdio_read_cis()
347 ret = sdio_io_rw_direct(func->card, SDIO_IO_READ, SDIO_FUNC_NUM_0, in sdio_read_cis()
348 SDIO_FBR_BASE(func->num) + SDIO_FBR_CIS + i, 0, data); in sdio_read_cis()
357 ret = sdio_io_rw_direct(func->card, SDIO_IO_READ, SDIO_FUNC_NUM_0, in sdio_read_cis()
371 ret = sdio_io_rw_direct(func->card, SDIO_IO_READ, SDIO_FUNC_NUM_0, in sdio_read_cis()
391 ret = sdio_io_rw_direct(func->card, SDIO_IO_READ, in sdio_read_cis()
400 sdio_decode_cis(&func->cis, func->num, data, in sdio_read_cis()
407 LOG_DBG("SDIO CIS max block size for func %d: %d", func->num, in sdio_read_cis()
408 func->cis.max_blk_size); in sdio_read_cis()
685 int sdio_init_func(struct sd_card *card, struct sdio_func *func, in sdio_init_func() argument
689 func->num = num; in sdio_init_func()
690 func->card = card; in sdio_init_func()
691 func->block_size = 0; in sdio_init_func()
693 return sdio_read_cis(func, cis_tuples, ARRAY_SIZE(cis_tuples)); in sdio_init_func()
708 int sdio_enable_func(struct sdio_func *func) in sdio_enable_func() argument
715 ret = sdio_io_rw_direct(func->card, SDIO_IO_READ, SDIO_FUNC_NUM_0, in sdio_enable_func()
720 reg |= BIT(func->num); in sdio_enable_func()
721 ret = sdio_io_rw_direct(func->card, SDIO_IO_WRITE, SDIO_FUNC_NUM_0, in sdio_enable_func()
727 if (func->cis.rdy_timeout) { in sdio_enable_func()
732 sd_delay(((uint32_t)func->cis.rdy_timeout) * 10U); in sdio_enable_func()
733 ret = sdio_io_rw_direct(func->card, SDIO_IO_READ, in sdio_enable_func()
738 if (reg & BIT(func->num)) { in sdio_enable_func()
756 int sdio_set_block_size(struct sdio_func *func, uint16_t bsize) in sdio_set_block_size() argument
761 if (func->cis.max_blk_size < bsize) { in sdio_set_block_size()
766 ret = sdio_io_rw_direct(func->card, SDIO_IO_WRITE, SDIO_FUNC_NUM_0, in sdio_set_block_size()
767 SDIO_FBR_BASE(func->num) + SDIO_FBR_BLK_SIZE + i, reg, NULL); in sdio_set_block_size()
772 func->block_size = bsize; in sdio_set_block_size()
788 int sdio_read_byte(struct sdio_func *func, uint32_t reg, uint8_t *val) in sdio_read_byte() argument
792 if ((func->card->type != CARD_SDIO) && (func->card->type != CARD_COMBO)) { in sdio_read_byte()
796 ret = k_mutex_lock(&func->card->lock, K_MSEC(CONFIG_SD_DATA_TIMEOUT)); in sdio_read_byte()
801 ret = sdio_io_rw_direct(func->card, SDIO_IO_READ, func->num, reg, 0, val); in sdio_read_byte()
802 k_mutex_unlock(&func->card->lock); in sdio_read_byte()
818 int sdio_write_byte(struct sdio_func *func, uint32_t reg, uint8_t write_val) in sdio_write_byte() argument
822 if ((func->card->type != CARD_SDIO) && (func->card->type != CARD_COMBO)) { in sdio_write_byte()
826 ret = k_mutex_lock(&func->card->lock, K_MSEC(CONFIG_SD_DATA_TIMEOUT)); in sdio_write_byte()
831 ret = sdio_io_rw_direct(func->card, SDIO_IO_WRITE, func->num, reg, in sdio_write_byte()
833 k_mutex_unlock(&func->card->lock); in sdio_write_byte()
850 int sdio_rw_byte(struct sdio_func *func, uint32_t reg, uint8_t write_val, in sdio_rw_byte() argument
855 if ((func->card->type != CARD_SDIO) && (func->card->type != CARD_COMBO)) { in sdio_rw_byte()
859 ret = k_mutex_lock(&func->card->lock, K_MSEC(CONFIG_SD_DATA_TIMEOUT)); in sdio_rw_byte()
864 ret = sdio_io_rw_direct(func->card, SDIO_IO_WRITE, func->num, reg, in sdio_rw_byte()
866 k_mutex_unlock(&func->card->lock); in sdio_rw_byte()
884 int sdio_read_fifo(struct sdio_func *func, uint32_t reg, uint8_t *data, in sdio_read_fifo() argument
889 if ((func->card->type != CARD_SDIO) && (func->card->type != CARD_COMBO)) { in sdio_read_fifo()
893 ret = k_mutex_lock(&func->card->lock, K_MSEC(CONFIG_SD_DATA_TIMEOUT)); in sdio_read_fifo()
898 ret = sdio_io_rw_extended_helper(func, SDIO_IO_READ, reg, false, in sdio_read_fifo()
900 k_mutex_unlock(&func->card->lock); in sdio_read_fifo()
918 int sdio_write_fifo(struct sdio_func *func, uint32_t reg, uint8_t *data, in sdio_write_fifo() argument
923 if ((func->card->type != CARD_SDIO) && (func->card->type != CARD_COMBO)) { in sdio_write_fifo()
927 ret = k_mutex_lock(&func->card->lock, K_MSEC(CONFIG_SD_DATA_TIMEOUT)); in sdio_write_fifo()
932 ret = sdio_io_rw_extended_helper(func, SDIO_IO_WRITE, reg, false, in sdio_write_fifo()
934 k_mutex_unlock(&func->card->lock); in sdio_write_fifo()
952 int sdio_read_blocks_fifo(struct sdio_func *func, uint32_t reg, uint8_t *data, in sdio_read_blocks_fifo() argument
957 if ((func->card->type != CARD_SDIO) && (func->card->type != CARD_COMBO)) { in sdio_read_blocks_fifo()
961 ret = k_mutex_lock(&func->card->lock, K_MSEC(CONFIG_SD_DATA_TIMEOUT)); in sdio_read_blocks_fifo()
966 ret = sdio_io_rw_extended(func->card, SDIO_IO_READ, func->num, reg, in sdio_read_blocks_fifo()
967 false, data, blocks, func->block_size); in sdio_read_blocks_fifo()
968 k_mutex_unlock(&func->card->lock); in sdio_read_blocks_fifo()
986 int sdio_write_blocks_fifo(struct sdio_func *func, uint32_t reg, uint8_t *data, in sdio_write_blocks_fifo() argument
991 if ((func->card->type != CARD_SDIO) && (func->card->type != CARD_COMBO)) { in sdio_write_blocks_fifo()
995 ret = k_mutex_lock(&func->card->lock, K_MSEC(CONFIG_SD_DATA_TIMEOUT)); in sdio_write_blocks_fifo()
1000 ret = sdio_io_rw_extended(func->card, SDIO_IO_WRITE, func->num, reg, in sdio_write_blocks_fifo()
1001 false, data, blocks, func->block_size); in sdio_write_blocks_fifo()
1002 k_mutex_unlock(&func->card->lock); in sdio_write_blocks_fifo()
1019 int sdio_read_addr(struct sdio_func *func, uint32_t reg, uint8_t *data, in sdio_read_addr() argument
1024 if ((func->card->type != CARD_SDIO) && (func->card->type != CARD_COMBO)) { in sdio_read_addr()
1028 ret = k_mutex_lock(&func->card->lock, K_MSEC(CONFIG_SD_DATA_TIMEOUT)); in sdio_read_addr()
1033 ret = sdio_io_rw_extended_helper(func, SDIO_IO_READ, reg, true, in sdio_read_addr()
1035 k_mutex_unlock(&func->card->lock); in sdio_read_addr()
1053 int sdio_write_addr(struct sdio_func *func, uint32_t reg, uint8_t *data, in sdio_write_addr() argument
1058 if ((func->card->type != CARD_SDIO) && (func->card->type != CARD_COMBO)) { in sdio_write_addr()
1062 ret = k_mutex_lock(&func->card->lock, K_MSEC(CONFIG_SD_DATA_TIMEOUT)); in sdio_write_addr()
1067 ret = sdio_io_rw_extended_helper(func, SDIO_IO_WRITE, reg, true, in sdio_write_addr()
1069 k_mutex_unlock(&func->card->lock); in sdio_write_addr()