xref: /freebsd/sys/arm/mv/mvvar.h (revision 7aa65846327fe5bc7e5961c2f7fd0c61f2ec0b01)
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 #include <vm/vm.h>
45 #include <vm/pmap.h>
46 #include <machine/pmap.h>
47 #include <machine/vm.h>
48 
49 #define	MV_TYPE_PCI		0
50 #define	MV_TYPE_PCIE		1
51 
52 struct gpio_config {
53 	int		gc_gpio;	/* GPIO number */
54 	uint32_t	gc_flags;	/* GPIO flags */
55 	int		gc_output;	/* GPIO output value */
56 };
57 
58 struct decode_win {
59 	int		target;		/* Mbus unit ID */
60 	int		attr;		/* Attributes of the target interface */
61 	vm_paddr_t	base;		/* Physical base addr */
62 	uint32_t	size;
63 	int		remap;
64 };
65 
66 extern const struct pmap_devmap pmap_devmap[];
67 extern const struct gpio_config mv_gpio_config[];
68 extern const struct decode_win *idma_wins;
69 extern const struct decode_win *xor_wins;
70 extern int idma_wins_no;
71 extern int xor_wins_no;
72 
73 /* Function prototypes */
74 int mv_gpio_setup_intrhandler(const char *name, driver_filter_t *filt,
75     void (*hand)(void *), void *arg, int pin, int flags, void **cookiep);
76 void mv_gpio_intr_mask(int pin);
77 void mv_gpio_intr_unmask(int pin);
78 void mv_gpio_out(uint32_t pin, uint8_t val, uint8_t enable);
79 uint8_t mv_gpio_in(uint32_t pin);
80 int platform_gpio_init(void);
81 
82 int soc_decode_win(void);
83 void soc_id(uint32_t *dev, uint32_t *rev);
84 void soc_dump_decode_win(void);
85 uint32_t soc_power_ctrl_get(uint32_t mask);
86 void soc_power_ctrl_set(uint32_t mask);
87 
88 int decode_win_cpu_set(int target, int attr, vm_paddr_t base, uint32_t size,
89     int remap);
90 int decode_win_overlap(int, int, const struct decode_win *);
91 int win_cpu_can_remap(int);
92 
93 int ddr_is_active(int i);
94 uint32_t ddr_base(int i);
95 uint32_t ddr_size(int i);
96 uint32_t ddr_attr(int i);
97 uint32_t ddr_target(int i);
98 
99 uint32_t cpu_extra_feat(void);
100 uint32_t get_tclk(void);
101 uint32_t read_cpu_ctrl(uint32_t);
102 void write_cpu_ctrl(uint32_t, uint32_t);
103 
104 #endif /* _MVVAR_H_ */
105