xref: /freebsd/sys/arm/mv/mvvar.h (revision a9148abd9da5db2f1c682fb17bed791845fc41c9)
1 /*-
2  * Copyright (c) 2002, 2003 Wasabi Systems, Inc.
3  * All rights reserved.
4  *
5  * Written by Jason R. Thorpe for Wasabi Systems, Inc.
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  * 3. All advertising materials mentioning features or use of this software
16  *    must display the following acknowledgement:
17  *	This product includes software developed for the NetBSD Project by
18  *	Wasabi Systems, Inc.
19  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
20  *    or promote products derived from this software without specific prior
21  *    written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
27  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  *
35  * from: FreeBSD: //depot/projects/arm/src/sys/arm/xscale/pxa2x0/pxa2x0var.h, rev 1
36  *
37  * $FreeBSD$
38  */
39 
40 #ifndef _MVVAR_H_
41 #define _MVVAR_H_
42 
43 #include <sys/rman.h>
44 
45 struct obio_softc {
46 	bus_space_tag_t obio_bst;	/* bus space tag */
47 	struct rman	obio_mem;
48 	struct rman	obio_irq;
49 	struct rman	obio_gpio;
50 };
51 
52 struct obio_device {
53 	const char	*od_name;
54 	u_long		od_base;
55 	u_long		od_size;
56 	u_int		od_irqs[7 + 1];	/* keep additional entry for -1 sentinel */
57 	u_int		od_gpio[2 + 1]; /* as above for IRQ */
58 	u_int		od_pwr_mask;
59 	struct resource_list od_resources;
60 };
61 
62 struct decode_win {
63 	int		target;		/* Mbus unit ID */
64 	int		attr;		/* Attributes of the target interface */
65 	vm_paddr_t	base;		/* Physical base addr */
66 	uint32_t	size;
67 	int		remap;
68 };
69 
70 extern bus_space_tag_t		obio_tag;
71 extern struct obio_device	obio_devices[];
72 extern const struct decode_win	*cpu_wins;
73 extern const struct decode_win	*idma_wins;
74 extern int	cpu_wins_no;
75 extern int	idma_wins_no;
76 
77 /* Function prototypes */
78 int	mv_gpio_setup_intrhandler(const char *name, driver_filter_t *filt,
79     void (*hand)(void *), void *arg, int pin, int flags, void **cookiep);
80 void	mv_gpio_intr_mask(int pin);
81 void	mv_gpio_intr_unmask(int pin);
82 int	mv_gpio_configure(uint32_t pin, uint32_t flags, uint32_t mask);
83 void	mv_gpio_out(uint32_t pin, uint8_t val, uint8_t enable);
84 uint8_t	mv_gpio_in(uint32_t pin);
85 
86 int	platform_pmap_init(void);
87 int	soc_decode_win(void);
88 void	soc_id(uint32_t *dev, uint32_t *rev);
89 void	soc_identify(void);
90 void	soc_dump_decode_win(void);
91 uint32_t soc_power_ctrl_get(uint32_t mask);
92 
93 int decode_win_overlap(int, int, const struct decode_win *);
94 int win_cpu_can_remap(int);
95 
96 void	decode_win_idma_dump(void);
97 void	decode_win_idma_setup(void);
98 int	decode_win_idma_valid(void);
99 
100 int		ddr_is_active(int i);
101 uint32_t	ddr_base(int i);
102 uint32_t	ddr_size(int i);
103 uint32_t	ddr_attr(int i);
104 uint32_t	ddr_target(int i);
105 
106 uint32_t	cpu_extra_feat(void);
107 uint32_t	get_tclk(void);
108 uint32_t	read_cpu_ctrl(uint32_t);
109 void		write_cpu_ctrl(uint32_t, uint32_t);
110 
111 enum mbus_device_ivars {
112 	MBUS_IVAR_BASE,
113 };
114 
115 #define	MBUS_ACCESSOR(var, ivar, type)	\
116 	__BUS_ACCESSOR(mbus, var, MBUS, ivar, type)
117 
118 MBUS_ACCESSOR(base,	BASE,	u_long)
119 
120 #undef	MBUS_ACCESSOR
121 
122 #endif /* _MVVAR_H_ */
123