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