167ca7330SBjoern A. Zeeb /*- 267ca7330SBjoern A. Zeeb * Copyright (c) 2017 Ilya Bakulin. All rights reserved. 367ca7330SBjoern A. Zeeb * Copyright (c) 2018-2019 The FreeBSD Foundation 467ca7330SBjoern A. Zeeb * 567ca7330SBjoern A. Zeeb * Portions of this software were developed by Björn Zeeb 667ca7330SBjoern A. Zeeb * under sponsorship from the FreeBSD Foundation. 767ca7330SBjoern A. Zeeb * 867ca7330SBjoern A. Zeeb * Redistribution and use in source and binary forms, with or without 967ca7330SBjoern A. Zeeb * modification, are permitted provided that the following conditions 1067ca7330SBjoern A. Zeeb * are met: 1167ca7330SBjoern A. Zeeb * 1. Redistributions of source code must retain the above copyright 1267ca7330SBjoern A. Zeeb * notice, this list of conditions and the following disclaimer. 1367ca7330SBjoern A. Zeeb * 2. Redistributions in binary form must reproduce the above copyright 1467ca7330SBjoern A. Zeeb * notice, this list of conditions and the following disclaimer in the 1567ca7330SBjoern A. Zeeb * documentation and/or other materials provided with the distribution. 1667ca7330SBjoern A. Zeeb * 1767ca7330SBjoern A. Zeeb * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1867ca7330SBjoern A. Zeeb * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1967ca7330SBjoern A. Zeeb * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 2067ca7330SBjoern A. Zeeb * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 2167ca7330SBjoern A. Zeeb * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2267ca7330SBjoern A. Zeeb * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2367ca7330SBjoern A. Zeeb * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2467ca7330SBjoern A. Zeeb * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2567ca7330SBjoern A. Zeeb * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2667ca7330SBjoern A. Zeeb * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2767ca7330SBjoern A. Zeeb * 2867ca7330SBjoern A. Zeeb * 2967ca7330SBjoern A. Zeeb * Portions of this software may have been developed with reference to 3067ca7330SBjoern A. Zeeb * the SD Simplified Specification. The following disclaimer may apply: 3167ca7330SBjoern A. Zeeb * 3267ca7330SBjoern A. Zeeb * The following conditions apply to the release of the simplified 3367ca7330SBjoern A. Zeeb * specification ("Simplified Specification") by the SD Card Association and 3467ca7330SBjoern A. Zeeb * the SD Group. The Simplified Specification is a subset of the complete SD 3567ca7330SBjoern A. Zeeb * Specification which is owned by the SD Card Association and the SD 3667ca7330SBjoern A. Zeeb * Group. This Simplified Specification is provided on a non-confidential 3767ca7330SBjoern A. Zeeb * basis subject to the disclaimers below. Any implementation of the 3867ca7330SBjoern A. Zeeb * Simplified Specification may require a license from the SD Card 3967ca7330SBjoern A. Zeeb * Association, SD Group, SD-3C LLC or other third parties. 4067ca7330SBjoern A. Zeeb * 4167ca7330SBjoern A. Zeeb * Disclaimers: 4267ca7330SBjoern A. Zeeb * 4367ca7330SBjoern A. Zeeb * The information contained in the Simplified Specification is presented only 4467ca7330SBjoern A. Zeeb * as a standard specification for SD Cards and SD Host/Ancillary products and 4567ca7330SBjoern A. Zeeb * is provided "AS-IS" without any representations or warranties of any 4667ca7330SBjoern A. Zeeb * kind. No responsibility is assumed by the SD Group, SD-3C LLC or the SD 4767ca7330SBjoern A. Zeeb * Card Association for any damages, any infringements of patents or other 4867ca7330SBjoern A. Zeeb * right of the SD Group, SD-3C LLC, the SD Card Association or any third 4967ca7330SBjoern A. Zeeb * parties, which may result from its use. No license is granted by 5067ca7330SBjoern A. Zeeb * implication, estoppel or otherwise under any patent or other rights of the 5167ca7330SBjoern A. Zeeb * SD Group, SD-3C LLC, the SD Card Association or any third party. Nothing 5267ca7330SBjoern A. Zeeb * herein shall be construed as an obligation by the SD Group, the SD-3C LLC 5367ca7330SBjoern A. Zeeb * or the SD Card Association to disclose or distribute any technical 5467ca7330SBjoern A. Zeeb * information, know-how or other confidential information to any third party. 5567ca7330SBjoern A. Zeeb * 5667ca7330SBjoern A. Zeeb */ 5767ca7330SBjoern A. Zeeb 5867ca7330SBjoern A. Zeeb #ifndef _SDIO_SUBR_H_ 5967ca7330SBjoern A. Zeeb #define _SDIO_SUBR_H_ 6067ca7330SBjoern A. Zeeb 6167ca7330SBjoern A. Zeeb /* 6267ca7330SBjoern A. Zeeb * This file contains structures and functions to work with SDIO cards. 6367ca7330SBjoern A. Zeeb */ 6467ca7330SBjoern A. Zeeb 6567ca7330SBjoern A. Zeeb struct sdio_func { 6667ca7330SBjoern A. Zeeb device_t dev; /* The device to talk to CAM. */ 6767ca7330SBjoern A. Zeeb uintptr_t drvdata; /* Driver specific data. */ 6867ca7330SBjoern A. Zeeb 6967ca7330SBjoern A. Zeeb uint8_t fn; /* Function number. */ 7067ca7330SBjoern A. Zeeb 7167ca7330SBjoern A. Zeeb uint8_t class; /* Class of function. */ 7267ca7330SBjoern A. Zeeb uint16_t vendor; /* Manufacturer ID. */ 7367ca7330SBjoern A. Zeeb uint16_t device; /* Card ID. */ 7467ca7330SBjoern A. Zeeb 7567ca7330SBjoern A. Zeeb uint16_t max_blksize; /* Maximum block size of function. */ 7667ca7330SBjoern A. Zeeb uint16_t cur_blksize; /* Current block size of function. */ 7767ca7330SBjoern A. Zeeb 7867ca7330SBjoern A. Zeeb uint16_t retries; /* Retires for CAM operations. */ 7967ca7330SBjoern A. Zeeb uint32_t timeout; /* Timeout. */ 8067ca7330SBjoern A. Zeeb }; 8167ca7330SBjoern A. Zeeb 8267ca7330SBjoern A. Zeeb struct card_info { 8367ca7330SBjoern A. Zeeb struct sdio_func f[8]; 8467ca7330SBjoern A. Zeeb 8567ca7330SBjoern A. Zeeb /* Compared to R4 Number of I/O Functions we DO count F0 here. */ 8667ca7330SBjoern A. Zeeb uint8_t num_funcs; 8767ca7330SBjoern A. Zeeb 8867ca7330SBjoern A. Zeeb bool support_multiblk; /* Support Multiple Block Transfer */ 8967ca7330SBjoern A. Zeeb }; 9067ca7330SBjoern A. Zeeb 9167ca7330SBjoern A. Zeeb #ifdef _KERNEL 9267ca7330SBjoern A. Zeeb int sdio_enable_func(struct sdio_func *); 9367ca7330SBjoern A. Zeeb int sdio_disable_func(struct sdio_func *); 9467ca7330SBjoern A. Zeeb int sdio_set_block_size(struct sdio_func *, uint16_t); 9567ca7330SBjoern A. Zeeb 96*b9db5e0aSEmmanuel Vadot uint8_t sdio_read_1(struct sdio_func *, uint32_t, int *); 97*b9db5e0aSEmmanuel Vadot void sdio_write_1(struct sdio_func *, uint32_t, uint8_t, int *); 98*b9db5e0aSEmmanuel Vadot uint32_t sdio_read_4(struct sdio_func *, uint32_t, int *); 99*b9db5e0aSEmmanuel Vadot void sdio_write_4(struct sdio_func *, uint32_t, uint32_t, int *); 10067ca7330SBjoern A. Zeeb 101*b9db5e0aSEmmanuel Vadot uint8_t sdio_f0_read_1(struct sdio_func *, uint32_t, int *); 102*b9db5e0aSEmmanuel Vadot void sdio_f0_write_1(struct sdio_func *, uint32_t, uint8_t, int *); 10367ca7330SBjoern A. Zeeb #endif /* _KERNEL */ 10467ca7330SBjoern A. Zeeb 10567ca7330SBjoern A. Zeeb #endif /* _SDIO_SUBR_H_ */ 106