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