]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/arm/at91/at91sam9g45.c
MFV r331407: 9213 zfs: sytem typo
[FreeBSD/FreeBSD.git] / sys / arm / at91 / at91sam9g45.c
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3  *
4  * Copyright (c) 2005 Olivier Houchard.  All rights reserved.
5  * Copyright (c) 2010 Greg Ansley.  All rights reserved.
6  * Copyright (c) 2012 Andrew Turner.  All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  */
29
30 #include <sys/cdefs.h>
31 __FBSDID("$FreeBSD$");
32
33 #include <sys/param.h>
34 #include <sys/systm.h>
35 #include <sys/bus.h>
36 #include <sys/kernel.h>
37 #include <sys/malloc.h>
38 #include <sys/module.h>
39
40 #define _ARM32_BUS_DMA_PRIVATE
41 #include <machine/bus.h>
42
43 #include <arm/at91/at91var.h>
44 #include <arm/at91/at91reg.h>
45 #include <arm/at91/at91soc.h>
46 #include <arm/at91/at91_aicreg.h>
47 #include <arm/at91/at91sam9g45reg.h>
48 #include <arm/at91/at91_pitreg.h>
49 #include <arm/at91/at91_pmcreg.h>
50 #include <arm/at91/at91_pmcvar.h>
51 #include <arm/at91/at91_rstreg.h>
52
53 /*
54  * Standard priority levels for the system.  0 is lowest and 7 is highest.
55  * These values are the ones Atmel uses for its Linux port
56  */
57 static const int at91_irq_prio[32] =
58 {
59         7,      /* Advanced Interrupt Controller */
60         7,      /* System Peripherals */
61         1,      /* Parallel IO Controller A */
62         1,      /* Parallel IO Controller B */
63         1,      /* Parallel IO Controller C */
64         1,      /* Parallel IO Controller D and E */
65         0,
66         5,      /* USART 0 */
67         5,      /* USART 1 */
68         5,      /* USART 2 */
69         5,      /* USART 3 */
70         0,      /* Multimedia Card Interface 0 */
71         6,      /* Two-Wire Interface 0 */
72         6,      /* Two-Wire Interface 1 */
73         5,      /* Serial Peripheral Interface 0 */
74         5,      /* Serial Peripheral Interface 1 */
75         4,      /* Serial Synchronous Controller 0 */
76         4,      /* Serial Synchronous Controller 1 */
77         0,      /* Timer Counter 0, 1, 2, 3, 4 and 5 */
78         0,      /* Pulse Width Modulation Controller */
79         0,      /* Touch Screen Controller */
80         0,      /* DMA Controller */
81         2,      /* USB Host High Speed port */
82         3,      /* LCD Controller */
83         5,      /* AC97 Controller */
84         3,      /* Ethernet */
85         0,      /* Image Sensor Interface */
86         2,      /* USB Device High Speed port */
87         0,      /* (reserved) */
88         0,      /* Multimedia Card Interface 1 */
89         0,      /* (reserved) */
90         0,      /* Advanced Interrupt Controller IRQ0 */
91 };
92
93 static const uint32_t at91_pio_base[] = {
94         AT91SAM9G45_PIOA_BASE,
95         AT91SAM9G45_PIOB_BASE,
96         AT91SAM9G45_PIOC_BASE,
97         AT91SAM9G45_PIOD_BASE,
98         AT91SAM9G45_PIOE_BASE,
99 };
100
101 #define DEVICE(_name, _id, _unit)               \
102         {                                       \
103                 _name, _unit,                   \
104                 AT91SAM9G45_ ## _id ##_BASE,    \
105                 AT91SAM9G45_ ## _id ## _SIZE,   \
106                 AT91SAM9G45_IRQ_ ## _id         \
107         }
108
109 static const struct cpu_devs at91_devs[] =
110 {
111         DEVICE("at91_pmc", PMC,  0),
112         DEVICE("at91_wdt", WDT,  0),
113         DEVICE("at91_rst", RSTC, 0),
114         DEVICE("at91_pit", PIT,  0),
115         DEVICE("at91_pio", PIOA, 0),
116         DEVICE("at91_pio", PIOB, 1),
117         DEVICE("at91_pio", PIOC, 2),
118         DEVICE("at91_pio", PIOD, 3),
119         DEVICE("at91_pio", PIOE, 4),
120         DEVICE("at91_twi", TWI0, 0),
121         DEVICE("at91_twi", TWI1, 1),
122         DEVICE("at91_mci", HSMCI0, 0),
123         DEVICE("at91_mci", HSMCI1, 1),
124         DEVICE("uart", DBGU,   0),
125         DEVICE("uart", USART0, 1),
126         DEVICE("uart", USART1, 2),
127         DEVICE("uart", USART2, 3),
128         DEVICE("uart", USART3, 4),
129         DEVICE("spi",  SPI0,   0),
130         DEVICE("spi",  SPI1,   1),
131         DEVICE("ate",  EMAC,   0),
132         DEVICE("macb", EMAC,   0),
133         DEVICE("nand", NAND,   0),
134         DEVICE("ohci", OHCI,   0),
135         { 0, 0, 0, 0, 0 }
136 };
137
138 static void
139 at91_clock_init(void)
140 {
141         struct at91_pmc_clock *clk;
142
143         /* Update USB host port clock info */
144         clk = at91_pmc_clock_ref("uhpck");
145         clk->pmc_mask  = PMC_SCER_UHP_SAM9;
146         at91_pmc_clock_deref(clk);
147
148         /* Each SOC has different PLL contraints */
149         clk = at91_pmc_clock_ref("plla");
150         clk->pll_min_in    = SAM9G45_PLL_A_MIN_IN_FREQ;         /*   2 MHz */
151         clk->pll_max_in    = SAM9G45_PLL_A_MAX_IN_FREQ;         /*  32 MHz */
152         clk->pll_min_out   = SAM9G45_PLL_A_MIN_OUT_FREQ;        /* 400 MHz */
153         clk->pll_max_out   = SAM9G45_PLL_A_MAX_OUT_FREQ;        /* 800 MHz */
154         clk->pll_mul_shift = SAM9G45_PLL_A_MUL_SHIFT;
155         clk->pll_mul_mask  = SAM9G45_PLL_A_MUL_MASK;
156         clk->pll_div_shift = SAM9G45_PLL_A_DIV_SHIFT;
157         clk->pll_div_mask  = SAM9G45_PLL_A_DIV_MASK;
158         clk->set_outb      = at91_pmc_800mhz_plla_outb;
159         at91_pmc_clock_deref(clk);
160 }
161
162 static struct at91_soc_data soc_data = {
163         .soc_delay = at91_pit_delay,
164         .soc_reset = at91_rst_cpu_reset,
165         .soc_clock_init = at91_clock_init,
166         .soc_irq_prio = at91_irq_prio,
167         .soc_children = at91_devs,
168         .soc_pio_base = at91_pio_base,
169         .soc_pio_count = nitems(at91_pio_base),
170 };
171
172 AT91_SOC(AT91_T_SAM9G45, &soc_data);