at91var.h revision 236080
1234285Sdim/*-
2234285Sdim * Copyright (c) 2005 Olivier Houchard.  All rights reserved.
3234285Sdim *
4234285Sdim * Redistribution and use in source and binary forms, with or without
5234285Sdim * modification, are permitted provided that the following conditions
6234285Sdim * are met:
7234285Sdim * 1. Redistributions of source code must retain the above copyright
8234285Sdim *    notice, this list of conditions and the following disclaimer.
9234285Sdim * 2. Redistributions in binary form must reproduce the above copyright
10234285Sdim *    notice, this list of conditions and the following disclaimer in the
11234285Sdim *    documentation and/or other materials provided with the distribution.
12234285Sdim *
13234285Sdim * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14234285Sdim * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15234285Sdim * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16234285Sdim * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
17234285Sdim * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18234285Sdim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19234285Sdim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20234285Sdim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21234285Sdim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22263508Sdim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23234285Sdim * SUCH DAMAGE.
24234285Sdim */
25263508Sdim
26234285Sdim/* $FreeBSD: stable/9/sys/arm/at91/at91var.h 236080 2012-05-26 09:03:14Z marius $ */
27234285Sdim
28234285Sdim#ifndef _AT91VAR_H_
29234285Sdim#define _AT91VAR_H_
30234285Sdim
31234285Sdim#include <sys/bus.h>
32263508Sdim#include <sys/rman.h>
33234285Sdim
34234285Sdim#include <arm/at91/at91reg.h>
35234285Sdim
36263508Sdimstruct at91_softc {
37234285Sdim	device_t dev;
38234285Sdim	bus_space_tag_t sc_st;
39234285Sdim	bus_space_handle_t sc_sh;
40234285Sdim	bus_space_handle_t sc_aic_sh;
41234285Sdim	struct rman sc_irq_rman;
42234285Sdim	struct rman sc_mem_rman;
43234285Sdim	uint32_t sc_irq_system;
44234285Sdim};
45234285Sdim
46234285Sdimstruct at91_ivar {
47234285Sdim	struct resource_list resources;
48234285Sdim};
49234285Sdim
50234285Sdimstruct cpu_devs
51234285Sdim{
52234285Sdim	const char *name;
53234285Sdim	int unit;
54234285Sdim	bus_addr_t mem_base;
55234285Sdim	bus_size_t mem_len;
56234285Sdim	int irq0;
57234285Sdim	int irq1;
58234285Sdim	int irq2;
59234285Sdim	const char *parent_clk;
60239462Sdim};
61263508Sdim
62234285Sdimextern uint32_t at91_chip_id;
63234285Sdim
64234285Sdimstatic inline int at91_is_rm92(void);
65234285Sdimstatic inline int at91_is_sam9(void);
66239462Sdimstatic inline int at91_cpu_is(u_int cpu);
67234285Sdim
68239462Sdimstatic inline int
69239462Sdimat91_is_rm92(void)
70234285Sdim{
71239462Sdim
72239462Sdim	return (AT91_ARCH(at91_chip_id) == AT91_ARCH_RM92);
73234285Sdim}
74239462Sdim
75234285Sdimstatic inline int
76239462Sdimat91_is_sam9(void)
77234285Sdim{
78239462Sdim
79234285Sdim	return (AT91_ARCH(at91_chip_id) == AT91_ARCH_SAM9);
80239462Sdim}
81234285Sdim
82239462Sdimstatic inline int
83234285Sdimat91_cpu_is(u_int cpu)
84234285Sdim{
85234285Sdim
86234285Sdim	return (AT91_CPU(at91_chip_id) == cpu);
87234285Sdim}
88249423Sdim
89234285Sdimextern uint32_t at91_irq_system;
90234285Sdimextern uint32_t at91_master_clock;
91234285Sdim
92234285Sdim#endif /* _AT91VAR_H_ */
93234285Sdim