1 /* $OpenBSD: sdmmcchip.h,v 1.4 2009/02/20 19:16:35 miod Exp $ */ 2 3 /* 4 * Copyright (c) 2006 Uwe Stuehler <uwe@openbsd.org> 5 * 6 * Permission to use, copy, modify, and distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the above 8 * copyright notice and this permission notice appear in all copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 #ifndef _SDMMC_CHIP_H_ 20 #define _SDMMC_CHIP_H_ 21 22 struct sdmmc_command; 23 24 typedef struct sdmmc_chip_functions *sdmmc_chipset_tag_t; 25 typedef void *sdmmc_chipset_handle_t; 26 27 struct sdmmc_chip_functions { 28 /* host controller reset */ 29 int (*host_reset)(sdmmc_chipset_handle_t); 30 /* host capabilities */ 31 u_int32_t (*host_ocr)(sdmmc_chipset_handle_t); 32 int (*host_maxblklen)(sdmmc_chipset_handle_t); 33 /* card detection */ 34 int (*card_detect)(sdmmc_chipset_handle_t); 35 /* bus power and clock frequency */ 36 int (*bus_power)(sdmmc_chipset_handle_t, u_int32_t); 37 int (*bus_clock)(sdmmc_chipset_handle_t, int); 38 /* command execution */ 39 void (*exec_command)(sdmmc_chipset_handle_t, 40 struct sdmmc_command *); 41 /* card interrupt */ 42 void (*card_intr_mask)(sdmmc_chipset_handle_t, int); 43 void (*card_intr_ack)(sdmmc_chipset_handle_t); 44 }; 45 46 /* host controller reset */ 47 #define sdmmc_chip_host_reset(tag, handle) \ 48 ((tag)->host_reset((handle))) 49 /* host capabilities */ 50 #define sdmmc_chip_host_ocr(tag, handle) \ 51 ((tag)->host_ocr((handle))) 52 #define sdmmc_chip_host_maxblklen(tag, handle) \ 53 ((tag)->host_maxblklen((handle))) 54 /* card detection */ 55 #define sdmmc_chip_card_detect(tag, handle) \ 56 ((tag)->card_detect((handle))) 57 /* bus power and clock frequency */ 58 #define sdmmc_chip_bus_power(tag, handle, ocr) \ 59 ((tag)->bus_power((handle), (ocr))) 60 #define sdmmc_chip_bus_clock(tag, handle, freq) \ 61 ((tag)->bus_clock((handle), (freq))) 62 /* command execution */ 63 #define sdmmc_chip_exec_command(tag, handle, cmdp) \ 64 ((tag)->exec_command((handle), (cmdp))) 65 /* card interrupt */ 66 #define sdmmc_chip_card_intr_mask(tag, handle, enable) \ 67 ((tag)->card_intr_mask((handle), (enable))) 68 #define sdmmc_chip_card_intr_ack(tag, handle) \ 69 ((tag)->card_intr_ack((handle))) 70 71 /* clock frequencies for sdmmc_chip_bus_clock() */ 72 #define SDMMC_SDCLK_OFF 0 73 #define SDMMC_SDCLK_400KHZ 400 74 #define SDMMC_SDCLK_25MHZ 25000 75 76 struct sdmmcbus_attach_args { 77 const char *saa_busname; 78 sdmmc_chipset_tag_t sct; 79 sdmmc_chipset_handle_t sch; 80 int flags; 81 long max_xfer; 82 }; 83 84 void sdmmc_needs_discover(struct device *); 85 void sdmmc_card_intr(struct device *); 86 void sdmmc_delay(u_int); 87 88 #endif 89