board_bwct.c revision 185305
1155324Simp/*-
2185305Simp * Copyright (c) 2005-2008 Olivier Houchard.  All rights reserved.
3185305Simp * Copyright (c) 2005-2008 Warner Losh.  All rights reserved.
4155324Simp *
5155324Simp * Redistribution and use in source and binary forms, with or without
6155324Simp * modification, are permitted provided that the following conditions
7155324Simp * are met:
8155324Simp * 1. Redistributions of source code must retain the above copyright
9155324Simp *    notice, this list of conditions and the following disclaimer.
10155324Simp * 2. Redistributions in binary form must reproduce the above copyright
11155324Simp *    notice, this list of conditions and the following disclaimer in the
12155324Simp *    documentation and/or other materials provided with the distribution.
13155324Simp *
14185305Simp * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15185305Simp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16185305Simp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17185305Simp * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
18185305Simp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19185305Simp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20185305Simp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21155324Simp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22155324Simp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23155324Simp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24155324Simp * SUCH DAMAGE.
25155324Simp */
26155324Simp
27160363Simp#include "opt_at91.h"
28155324Simp
29155324Simp#include <sys/cdefs.h>
30155324Simp__FBSDID("$FreeBSD: head/sys/arm/at91/board_kb920x.c 185305 2008-11-25 18:40:40Z imp $");
31155324Simp#include <sys/param.h>
32155324Simp#include <sys/systm.h>
33155324Simp
34185305Simp#include <arm/at91/at91board.h>
35155324Simp#include <arm/at91/at91rm92reg.h>
36160363Simp#include <arm/at91/at91_piovar.h>
37160363Simp#include <arm/at91/at91_pio_rm9200.h>
38155324Simp
39185305Simplong
40160363Simpboard_init(void)
41160363Simp{
42160363Simp	/*
43174880Sstas	 * Since the USART supports RS-485 multidrop mode, it allows the
44160363Simp	 * TX pins to float.  However, for RS-232 operations, we don't want
45160363Simp	 * these pins to float.  Instead, they should be pulled up to avoid
46160363Simp	 * mismatches.  Linux does something similar when it configures the
47160363Simp	 * TX lines.  This implies that we also allow the RX lines to float
48160363Simp	 * rather than be in the state they are left in by the boot loader.
49160363Simp	 * Since they are input pins, I think that this is the right thing
50160363Simp	 * to do.
51160363Simp	 */
52160363Simp
53160363Simp	/* PIOA's A periph: Turn USART 0 and 2's TX/RX pins */
54160363Simp	at91_pio_use_periph_a(AT91RM92_PIOA_BASE,
55160363Simp	    AT91C_PA18_RXD0 | AT91C_PA22_RXD2, 0);
56160363Simp	at91_pio_use_periph_a(AT91RM92_PIOA_BASE,
57160363Simp	    AT91C_PA17_TXD0 | AT91C_PA23_TXD2, 1);
58160363Simp	/* PIOA's B periph: Turn USART 3's TX/RX pins */
59160363Simp	at91_pio_use_periph_b(AT91RM92_PIOA_BASE, AT91C_PA6_RXD3, 0);
60160363Simp	at91_pio_use_periph_b(AT91RM92_PIOA_BASE, AT91C_PA5_TXD3, 1);
61160453Scognet#ifdef AT91_TSC
62160363Simp	/* We're using TC0's A1 and A2 input */
63160363Simp	at91_pio_use_periph_b(AT91RM92_PIOA_BASE,
64160363Simp	    AT91C_PA19_TIOA1 | AT91C_PA21_TIOA2, 0);
65160363Simp#endif
66160363Simp	/* PIOB's A periph: Turn USART 1's TX/RX pins */
67160363Simp	at91_pio_use_periph_a(AT91RM92_PIOB_BASE, AT91C_PB21_RXD1, 0);
68160363Simp	at91_pio_use_periph_a(AT91RM92_PIOB_BASE, AT91C_PB20_TXD1, 1);
69160363Simp
70160363Simp	/* Pin assignment */
71160453Scognet#ifdef AT91_TSC
72160363Simp	/* Assert PA24 low -- talk to rubidium */
73160363Simp	at91_pio_use_gpio(AT91RM92_PIOA_BASE, AT91C_PIO_PA24);
74160363Simp	at91_pio_gpio_output(AT91RM92_PIOA_BASE, AT91C_PIO_PA24, 0);
75160363Simp	at91_pio_gpio_clear(AT91RM92_PIOA_BASE, AT91C_PIO_PA24);
76163521Simp	at91_pio_use_gpio(AT91RM92_PIOB_BASE,
77163521Simp	    AT91C_PIO_PB16 | AT91C_PIO_PB17 | AT91C_PIO_PB18 | AT91C_PIO_PB19);
78160363Simp#endif
79160363Simp
80185305Simp	return (at91_ramsize());
81160363Simp}
82