2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2017 Ilya Bakulin
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 #include <sys/cdefs.h>
32 __FBSDID("$FreeBSD$");
34 #include <sys/ioctl.h>
35 #include <sys/stdint.h>
36 #include <sys/types.h>
38 #include <sys/endian.h>
55 #include <cam/cam_debug.h>
56 #include <cam/cam_ccb.h>
57 #include <cam/mmc/mmc_all.h>
63 uint16_t max_block_size;
66 int sdio_rw_direct(struct cam_device *dev,
73 sdio_rw_extended(struct cam_device *dev,
77 caddr_t data, size_t datalen,
80 uint8_t sdio_read_1(struct cam_device *dev, uint8_t func_number, uint32_t addr, int *ret);
81 int sdio_write_1(struct cam_device *dev, uint8_t func_number, uint32_t addr, uint8_t val);
82 uint16_t sdio_read_2(struct cam_device *dev, uint8_t func_number, uint32_t addr, int *ret);
83 int sdio_write_2(struct cam_device *dev, uint8_t func_number, uint32_t addr, uint16_t val);
84 uint32_t sdio_read_4(struct cam_device *dev, uint8_t func_number, uint32_t addr, int *ret);
85 int sdio_write_4(struct cam_device *dev, uint8_t func_number, uint32_t addr, uint32_t val);
86 int sdio_read_bool_for_func(struct cam_device *dev, uint32_t addr, uint8_t func_number, uint8_t *is_enab);
87 int sdio_set_bool_for_func(struct cam_device *dev, uint32_t addr, uint8_t func_number, int enable);
88 int sdio_is_func_ready(struct cam_device *dev, uint8_t func_number, uint8_t *is_enab);
89 int sdio_is_func_enabled(struct cam_device *dev, uint8_t func_number, uint8_t *is_enab);
90 int sdio_func_enable(struct cam_device *dev, uint8_t func_number, int enable);
91 int sdio_is_func_intr_enabled(struct cam_device *dev, uint8_t func_number, uint8_t *is_enab);
92 int sdio_func_intr_enable(struct cam_device *dev, uint8_t func_number, int enable);
93 void sdio_card_reset(struct cam_device *dev);
94 uint32_t sdio_get_common_cis_addr(struct cam_device *dev);
95 int sdio_func_read_cis(struct cam_device *dev, uint8_t func_number,
96 uint32_t cis_addr, struct cis_info *info);
97 int sdio_card_set_bus_width(struct cam_device *dev, enum mmc_bus_width bw);