2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2012 M. Warner Losh. All Rights Reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 #include <sys/cdefs.h>
29 __FBSDID("$FreeBSD$");
31 #include <sys/param.h>
32 #include <sys/systm.h>
34 #include <sys/kernel.h>
35 #include <sys/malloc.h>
36 #include <sys/module.h>
38 #define _ARM32_BUS_DMA_PRIVATE
39 #include <machine/bus.h>
41 #include <arm/at91/at91var.h>
42 #include <arm/at91/at91board.h>
43 #include <arm/at91/at91rm92reg.h>
44 #include <arm/at91/at91rm9200var.h>
45 #include <arm/at91/at91_pioreg.h>
46 #include <arm/at91/at91_piovar.h>
49 * The AT91RM9200 uses the same silicon for both the BGA and PQFP
50 * packages. There's no documented way to detect this at runtime,
51 * so we require the board code to register what type of SoC is on the
52 * board in question. The pinouts are not quite compatible, and we
53 * use this information to cope with the slight differences.
56 at91rm9200_set_subtype(enum at91_soc_subtype st)
60 case AT91_ST_RM9200_BGA:
61 case AT91_ST_RM9200_PQFP:
62 soc_info.subtype = st;
65 panic("Bad SoC subtype %d for at91rm9200_set_subtype.", st);
71 at91rm9200_config_uart(unsigned devid, unsigned unit, unsigned pinmask)
75 * Since the USART supports RS-485 multidrop mode, it allows the
76 * TX pins to float. However, for RS-232 operations, we don't want
77 * these pins to float. Instead, they should be pulled up to avoid
78 * mismatches. Linux does something similar when it configures the
79 * TX lines. This implies that we also allow the RX lines to float
80 * rather than be in the state they are left in by the boot loader.
81 * Since they are input pins, I think that this is the right thing
86 * Current boards supported don't need the extras, but they should be
87 * implemented. But that should wait until the new pin api goes in.
91 at91_pio_use_periph_a(AT91RM92_PIOA_BASE, AT91C_PIO_PA30, 0); /* DRXD */
92 at91_pio_use_periph_a(AT91RM92_PIOA_BASE, AT91C_PIO_PA31, 1); /* DTXD */
95 case AT91RM9200_ID_USART0:
96 at91_pio_use_periph_a(AT91RM92_PIOA_BASE, AT91C_PIO_PA17, 1); /* TXD0 */
97 at91_pio_use_periph_a(AT91RM92_PIOA_BASE, AT91C_PIO_PA18, 0); /* RXD0 */
99 /* RTS -- errata #39 PA21 */
102 case AT91RM9200_ID_USART1:
103 at91_pio_use_periph_a(AT91RM92_PIOB_BASE, AT91C_PIO_PB20, 1); /* TXD1 */
104 at91_pio_use_periph_a(AT91RM92_PIOB_BASE, AT91C_PIO_PB21, 0); /* RXD1 */
113 case AT91RM9200_ID_USART2:
114 at91_pio_use_periph_a(AT91RM92_PIOA_BASE, AT91C_PIO_PA22, 0); /* RXD2 */
115 at91_pio_use_periph_a(AT91RM92_PIOA_BASE, AT91C_PIO_PA23, 1); /* TXD2 */
116 /* CTS - PA30 B periph */
117 /* RTS - PA31 B periph */
120 case AT91RM9200_ID_USART3:
121 at91_pio_use_periph_b(AT91RM92_PIOA_BASE, AT91C_PIO_PA5, 1); /* TXD3 */
122 at91_pio_use_periph_b(AT91RM92_PIOA_BASE, AT91C_PIO_PA6, 0); /* RXD3 */
123 /* CTS - PB0 B periph */
124 /* RTS - PB1 B periph */
133 at91rm9200_config_mci(int has_4wire)
135 /* XXX TODO chip changed GPIO, other slots, etc */
136 at91_pio_use_periph_a(AT91RM92_PIOA_BASE, AT91C_PIO_PA27, 0); /* MCCK */
137 at91_pio_use_periph_a(AT91RM92_PIOA_BASE, AT91C_PIO_PA28, 1); /* MCCDA */
138 at91_pio_use_periph_a(AT91RM92_PIOA_BASE, AT91C_PIO_PA29, 1); /* MCDA0 */
140 at91_pio_use_periph_b(AT91RM92_PIOB_BASE, AT91C_PIO_PB3, 1); /* MCDA1 */
141 at91_pio_use_periph_b(AT91RM92_PIOB_BASE, AT91C_PIO_PB4, 1); /* MCDA2 */
142 at91_pio_use_periph_b(AT91RM92_PIOB_BASE, AT91C_PIO_PB5, 1); /* MCDA3 */