mvvar.h revision 239277
1183840Sraj/*-
2183840Sraj * Copyright (c) 2002, 2003 Wasabi Systems, Inc.
3183840Sraj * All rights reserved.
4183840Sraj *
5183840Sraj * Written by Jason R. Thorpe for Wasabi Systems, Inc.
6183840Sraj *
7183840Sraj * Redistribution and use in source and binary forms, with or without
8183840Sraj * modification, are permitted provided that the following conditions
9183840Sraj * are met:
10183840Sraj * 1. Redistributions of source code must retain the above copyright
11183840Sraj *    notice, this list of conditions and the following disclaimer.
12183840Sraj * 2. Redistributions in binary form must reproduce the above copyright
13183840Sraj *    notice, this list of conditions and the following disclaimer in the
14183840Sraj *    documentation and/or other materials provided with the distribution.
15183840Sraj * 3. All advertising materials mentioning features or use of this software
16183840Sraj *    must display the following acknowledgement:
17183840Sraj *	This product includes software developed for the NetBSD Project by
18183840Sraj *	Wasabi Systems, Inc.
19183840Sraj * 4. The name of Wasabi Systems, Inc. may not be used to endorse
20183840Sraj *    or promote products derived from this software without specific prior
21183840Sraj *    written permission.
22183840Sraj *
23183840Sraj * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
24183840Sraj * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25183840Sraj * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26183840Sraj * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
27183840Sraj * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28183840Sraj * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29183840Sraj * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30183840Sraj * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31183840Sraj * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32183840Sraj * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33183840Sraj * POSSIBILITY OF SUCH DAMAGE.
34183840Sraj *
35183840Sraj * from: FreeBSD: //depot/projects/arm/src/sys/arm/xscale/pxa2x0/pxa2x0var.h, rev 1
36183840Sraj *
37183840Sraj * $FreeBSD: head/sys/arm/mv/mvvar.h 239277 2012-08-15 05:15:49Z gonzo $
38183840Sraj */
39183840Sraj
40183840Sraj#ifndef _MVVAR_H_
41183840Sraj#define _MVVAR_H_
42183840Sraj
43183840Sraj#include <sys/rman.h>
44239277Sgonzo#include <machine/bus.h>
45196531Sraj#include <vm/vm.h>
46196531Sraj#include <vm/pmap.h>
47196531Sraj#include <machine/pmap.h>
48196531Sraj#include <machine/vm.h>
49183840Sraj
50185089Sraj#define	MV_TYPE_PCI		0
51185089Sraj#define	MV_TYPE_PCIE		1
52185089Sraj
53239277Sgonzo#define MV_MODE_ENDPOINT	0
54239277Sgonzo#define MV_MODE_ROOT		1
55239277Sgonzo
56186909Srajstruct gpio_config {
57186909Sraj	int		gc_gpio;	/* GPIO number */
58186909Sraj	uint32_t	gc_flags;	/* GPIO flags */
59186909Sraj	int		gc_output;	/* GPIO output value */
60186909Sraj};
61186909Sraj
62183840Srajstruct decode_win {
63183840Sraj	int		target;		/* Mbus unit ID */
64183840Sraj	int		attr;		/* Attributes of the target interface */
65183840Sraj	vm_paddr_t	base;		/* Physical base addr */
66183840Sraj	uint32_t	size;
67239277Sgonzo	vm_paddr_t	remap;
68183840Sraj};
69183840Sraj
70196531Srajextern const struct pmap_devmap pmap_devmap[];
71186909Srajextern const struct gpio_config mv_gpio_config[];
72239277Sgonzoextern const struct decode_win *cpu_wins;
73185092Srajextern const struct decode_win *idma_wins;
74186909Srajextern const struct decode_win *xor_wins;
75185092Srajextern int idma_wins_no;
76186909Srajextern int xor_wins_no;
77183840Sraj
78183840Sraj/* Function prototypes */
79185092Srajint mv_gpio_setup_intrhandler(const char *name, driver_filter_t *filt,
80183840Sraj    void (*hand)(void *), void *arg, int pin, int flags, void **cookiep);
81185092Srajvoid mv_gpio_intr_mask(int pin);
82185092Srajvoid mv_gpio_intr_unmask(int pin);
83185092Srajvoid mv_gpio_out(uint32_t pin, uint8_t val, uint8_t enable);
84185092Srajuint8_t mv_gpio_in(uint32_t pin);
85209131Srajint platform_gpio_init(void);
86183840Sraj
87185092Srajint soc_decode_win(void);
88185092Srajvoid soc_id(uint32_t *dev, uint32_t *rev);
89185092Srajvoid soc_dump_decode_win(void);
90183840Srajuint32_t soc_power_ctrl_get(uint32_t mask);
91196532Srajvoid soc_power_ctrl_set(uint32_t mask);
92183840Sraj
93185089Srajint decode_win_cpu_set(int target, int attr, vm_paddr_t base, uint32_t size,
94239277Sgonzo    vm_paddr_t remap);
95183840Srajint decode_win_overlap(int, int, const struct decode_win *);
96183840Srajint win_cpu_can_remap(int);
97239277Sgonzovoid decode_win_pcie_setup(u_long);
98183840Sraj
99185092Srajint ddr_is_active(int i);
100185092Srajuint32_t ddr_base(int i);
101185092Srajuint32_t ddr_size(int i);
102185092Srajuint32_t ddr_attr(int i);
103185092Srajuint32_t ddr_target(int i);
104183840Sraj
105185092Srajuint32_t cpu_extra_feat(void);
106185092Srajuint32_t get_tclk(void);
107239277Sgonzouint32_t get_l2clk(void);
108185092Srajuint32_t read_cpu_ctrl(uint32_t);
109185092Srajvoid write_cpu_ctrl(uint32_t, uint32_t);
110183840Sraj
111239277Sgonzoint mv_pcib_bar_win_set(device_t dev, uint32_t base, uint32_t size,
112239277Sgonzo    uint32_t remap, int winno, int busno);
113239277Sgonzoint mv_pcib_cpu_win_remap(device_t dev, uint32_t remap, uint32_t size);
114239277Sgonzo
115239277Sgonzovoid mv_mask_endpoint_irq(uintptr_t nb, int unit);
116239277Sgonzovoid mv_unmask_endpoint_irq(uintptr_t nb, int unit);
117239277Sgonzo
118239277Sgonzoint	mv_drbl_get_next_irq(int dir, int unit);
119239277Sgonzovoid	mv_drbl_mask_all(int unit);
120239277Sgonzovoid	mv_drbl_mask_irq(uint32_t irq, int dir, int unit);
121239277Sgonzovoid	mv_drbl_unmask_irq(uint32_t irq, int dir, int unit);
122239277Sgonzovoid	mv_drbl_set_mask(uint32_t val, int dir, int unit);
123239277Sgonzouint32_t mv_drbl_get_mask(int dir, int unit);
124239277Sgonzovoid	mv_drbl_set_cause(uint32_t val, int dir, int unit);
125239277Sgonzouint32_t mv_drbl_get_cause(int dir, int unit);
126239277Sgonzovoid	mv_drbl_set_msg(uint32_t val, int mnr, int dir, int unit);
127239277Sgonzouint32_t mv_drbl_get_msg(int mnr, int dir, int unit);
128239277Sgonzo
129183840Sraj#endif /* _MVVAR_H_ */
130