Home | History | Annotate | Line # | Download | only in xscale
      1 /*	$NetBSD: pxa2x0_mci.h,v 1.2 2012/01/21 19:44:28 nonaka Exp $	*/
      2 
      3 /*-
      4  * Copyright (C) 2006 NONAKA Kimihiro <nonaka (at) netbsd.org>
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  *
     16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     18  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     19  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     21  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     25  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     26  */
     27 
     28 #ifndef	_PXA2X0_MCI_H_
     29 #define	_PXA2X0_MCI_H_
     30 
     31 #include <sys/bus.h>
     32 #include <sys/device.h>
     33 #include <sys/mutex.h>
     34 #include <sys/condvar.h>
     35 
     36 #include <arm/xscale/pxa2x0_dmac.h>
     37 
     38 struct pxamci_tag {
     39 	void		*cookie;
     40 
     41 	uint32_t	(*get_ocr)(void *);
     42 	int		(*set_power)(void *, uint32_t);
     43 	int		(*card_detect)(void *);
     44 	int		(*write_protect)(void *);
     45 };
     46 
     47 struct pxamci_softc {
     48 	device_t		sc_dev;
     49 	bus_space_tag_t		sc_iot;
     50 	bus_space_handle_t	sc_ioh;
     51 	void			*sc_ih;
     52 	device_t		sc_sdmmc;
     53 
     54 	struct dmac_xfer	*sc_rxdx;
     55 	bus_dma_segment_t	sc_rxdr;	/* read descriptor */
     56 	struct dmac_xfer	*sc_txdx;
     57 	bus_dma_segment_t	sc_txdr;	/* write descriptor */
     58 
     59 	struct pxamci_tag	sc_tag;
     60 
     61 	u_int			sc_caps;
     62 #define	PMC_CAPS_4BIT	(1U << 0)
     63 #define	PMC_CAPS_NO_DMA	(1U << 1)
     64 
     65 	u_int			sc_flags;
     66 #define	PMF_CARDINITED	(1U << 0)
     67 
     68 	struct sdmmc_command * volatile sc_cmd;	/* command in progress */
     69 
     70 	uint32_t sc_imask;
     71 
     72 	uint32_t sc_ocr;			/* selected OCR */
     73 	int sc_maxblklen;			/* maximum block length */
     74 	int sc_buswidth;			/* current bus width */
     75 
     76 	u_int sc_clkmin;
     77 	u_int sc_clkmax;
     78 	u_int sc_clkbase;
     79 	uint32_t sc_clkrt;
     80 };
     81 
     82 int	pxamci_attach_sub(device_t, struct pxaip_attach_args *);
     83 void	pxamci_card_detect_event(struct pxamci_softc *);
     84 
     85 #endif	/* _PXA2X0_MCI_H_ */
     86