Home | History | Annotate | Line # | Download | only in sdmmc
sdmmcchip.h revision 1.2.2.2
      1  1.2.2.2  matt /*	$NetBSD: sdmmcchip.h,v 1.2.2.2 2010/04/21 00:27:52 matt Exp $	*/
      2  1.2.2.2  matt /*	$OpenBSD: sdmmcchip.h,v 1.3 2007/05/31 10:09:01 uwe Exp $	*/
      3  1.2.2.2  matt 
      4  1.2.2.2  matt /*
      5  1.2.2.2  matt  * Copyright (c) 2006 Uwe Stuehler <uwe (at) openbsd.org>
      6  1.2.2.2  matt  *
      7  1.2.2.2  matt  * Permission to use, copy, modify, and distribute this software for any
      8  1.2.2.2  matt  * purpose with or without fee is hereby granted, provided that the above
      9  1.2.2.2  matt  * copyright notice and this permission notice appear in all copies.
     10  1.2.2.2  matt  *
     11  1.2.2.2  matt  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
     12  1.2.2.2  matt  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     13  1.2.2.2  matt  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
     14  1.2.2.2  matt  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     15  1.2.2.2  matt  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
     16  1.2.2.2  matt  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
     17  1.2.2.2  matt  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     18  1.2.2.2  matt  */
     19  1.2.2.2  matt 
     20  1.2.2.2  matt #ifndef	_SDMMC_CHIP_H_
     21  1.2.2.2  matt #define	_SDMMC_CHIP_H_
     22  1.2.2.2  matt 
     23  1.2.2.2  matt #include <sys/device.h>
     24  1.2.2.2  matt 
     25  1.2.2.2  matt #include <machine/bus.h>
     26  1.2.2.2  matt 
     27  1.2.2.2  matt struct sdmmc_command;
     28  1.2.2.2  matt 
     29  1.2.2.2  matt typedef struct sdmmc_chip_functions *sdmmc_chipset_tag_t;
     30  1.2.2.2  matt typedef void *sdmmc_chipset_handle_t;
     31  1.2.2.2  matt 
     32  1.2.2.2  matt struct sdmmc_chip_functions {
     33  1.2.2.2  matt 	/* host controller reset */
     34  1.2.2.2  matt 	int		(*host_reset)(sdmmc_chipset_handle_t);
     35  1.2.2.2  matt 
     36  1.2.2.2  matt 	/* host capabilities */
     37  1.2.2.2  matt 	uint32_t	(*host_ocr)(sdmmc_chipset_handle_t);
     38  1.2.2.2  matt 	int		(*host_maxblklen)(sdmmc_chipset_handle_t);
     39  1.2.2.2  matt 
     40  1.2.2.2  matt 	/* card detection */
     41  1.2.2.2  matt 	int		(*card_detect)(sdmmc_chipset_handle_t);
     42  1.2.2.2  matt 
     43  1.2.2.2  matt 	/* write protect */
     44  1.2.2.2  matt 	int		(*write_protect)(sdmmc_chipset_handle_t);
     45  1.2.2.2  matt 
     46  1.2.2.2  matt 	/* bus power, clock frequency and width */
     47  1.2.2.2  matt 	int		(*bus_power)(sdmmc_chipset_handle_t, uint32_t);
     48  1.2.2.2  matt 	int		(*bus_clock)(sdmmc_chipset_handle_t, int);
     49  1.2.2.2  matt 	int		(*bus_width)(sdmmc_chipset_handle_t, int);
     50  1.2.2.2  matt 
     51  1.2.2.2  matt 	/* command execution */
     52  1.2.2.2  matt 	void		(*exec_command)(sdmmc_chipset_handle_t,
     53  1.2.2.2  matt 			    struct sdmmc_command *);
     54  1.2.2.2  matt 
     55  1.2.2.2  matt 	/* card interrupt */
     56  1.2.2.2  matt 	void		(*card_enable_intr)(sdmmc_chipset_handle_t, int);
     57  1.2.2.2  matt 	void		(*card_intr_ack)(sdmmc_chipset_handle_t);
     58  1.2.2.2  matt };
     59  1.2.2.2  matt 
     60  1.2.2.2  matt /* host controller reset */
     61  1.2.2.2  matt #define sdmmc_chip_host_reset(tag, handle)				\
     62  1.2.2.2  matt 	((tag)->host_reset((handle)))
     63  1.2.2.2  matt /* host capabilities */
     64  1.2.2.2  matt #define sdmmc_chip_host_ocr(tag, handle)				\
     65  1.2.2.2  matt 	((tag)->host_ocr((handle)))
     66  1.2.2.2  matt #define sdmmc_chip_host_maxblklen(tag, handle)				\
     67  1.2.2.2  matt 	((tag)->host_maxblklen((handle)))
     68  1.2.2.2  matt /* card detection */
     69  1.2.2.2  matt #define sdmmc_chip_card_detect(tag, handle)				\
     70  1.2.2.2  matt 	((tag)->card_detect((handle)))
     71  1.2.2.2  matt /* write protect */
     72  1.2.2.2  matt #define sdmmc_chip_write_protect(tag, handle)				\
     73  1.2.2.2  matt 	((tag)->write_protect((handle)))
     74  1.2.2.2  matt /* bus power, clock frequency and width */
     75  1.2.2.2  matt #define sdmmc_chip_bus_power(tag, handle, ocr)				\
     76  1.2.2.2  matt 	((tag)->bus_power((handle), (ocr)))
     77  1.2.2.2  matt #define sdmmc_chip_bus_clock(tag, handle, freq)				\
     78  1.2.2.2  matt 	((tag)->bus_clock((handle), (freq)))
     79  1.2.2.2  matt #define sdmmc_chip_bus_width(tag, handle, width)			\
     80  1.2.2.2  matt 	((tag)->bus_width((handle), (width)))
     81  1.2.2.2  matt /* command execution */
     82  1.2.2.2  matt #define sdmmc_chip_exec_command(tag, handle, cmdp)			\
     83  1.2.2.2  matt 	((tag)->exec_command((handle), (cmdp)))
     84  1.2.2.2  matt /* card interrupt */
     85  1.2.2.2  matt #define sdmmc_chip_card_enable_intr(tag, handle, enable)		\
     86  1.2.2.2  matt 	((tag)->card_enable_intr((handle), (enable)))
     87  1.2.2.2  matt #define sdmmc_chip_card_intr_ack(tag, handle)				\
     88  1.2.2.2  matt 	((tag)->card_intr_ack((handle)))
     89  1.2.2.2  matt 
     90  1.2.2.2  matt /* clock frequencies for sdmmc_chip_bus_clock() */
     91  1.2.2.2  matt #define SDMMC_SDCLK_OFF		0
     92  1.2.2.2  matt #define SDMMC_SDCLK_400K	400
     93  1.2.2.2  matt 
     94  1.2.2.2  matt struct sdmmcbus_attach_args {
     95  1.2.2.2  matt 	const char		*saa_busname;
     96  1.2.2.2  matt 	sdmmc_chipset_tag_t	saa_sct;
     97  1.2.2.2  matt 	sdmmc_chipset_handle_t	saa_sch;
     98  1.2.2.2  matt 	bus_dma_tag_t		saa_dmat;
     99  1.2.2.2  matt 	u_int			saa_clkmin;
    100  1.2.2.2  matt 	u_int			saa_clkmax;
    101  1.2.2.2  matt 	uint32_t		saa_caps;	/* see sdmmc_softc.sc_caps */
    102  1.2.2.2  matt };
    103  1.2.2.2  matt 
    104  1.2.2.2  matt void	sdmmc_needs_discover(device_t);
    105  1.2.2.2  matt void	sdmmc_card_intr(device_t);
    106  1.2.2.2  matt void	sdmmc_delay(u_int);
    107  1.2.2.2  matt 
    108  1.2.2.2  matt #endif	/* _SDMMC_CHIP_H_ */
    109