board_ethernut5.c revision 235348
1185573Srwatson/*-
2185573Srwatson * Copyright (c) 2012 Marius Strobl <marius@FreeBSD.org>
3155131Srwatson * All rights reserved.
4155131Srwatson *
5155131Srwatson * Redistribution and use in source and binary forms, with or without
6155131Srwatson * modification, are permitted provided that the following conditions
7155131Srwatson * are met:
8155131Srwatson * 1. Redistributions of source code must retain the above copyright
9155131Srwatson *    notice, this list of conditions and the following disclaimer.
10155131Srwatson * 2. Redistributions in binary form must reproduce the above copyright
11155131Srwatson *    notice, this list of conditions and the following disclaimer in the
12155131Srwatson *    documentation and/or other materials provided with the distribution.
13155131Srwatson *
14185573Srwatson * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15155131Srwatson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16155131Srwatson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17155131Srwatson * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18155131Srwatson * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19155131Srwatson * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20155131Srwatson * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21155131Srwatson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22155131Srwatson * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23155131Srwatson * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24155131Srwatson * SUCH DAMAGE.
25155131Srwatson */
26155131Srwatson
27155131Srwatson/*
28155131Srwatson * Ethernut 5 board support
29155131Srwatson */
30186647Srwatson
31155131Srwatson#include <sys/cdefs.h>
32155131Srwatson__FBSDID("$FreeBSD: head/sys/arm/at91/board_ethernut5.c 235348 2012-05-12 18:11:26Z marius $");
33155131Srwatson
34156283Srwatson#include <sys/param.h>
35156283Srwatson#include <sys/systm.h>
36156283Srwatson#include <arm/at91/at91_pioreg.h>
37155131Srwatson#include <arm/at91/at91_piovar.h>
38156283Srwatson#include <arm/at91/at91board.h>
39156283Srwatson#include <arm/at91/at91sam9260reg.h>
40156283Srwatson
41155131Srwatsonlong
42155131Srwatsonboard_init(void)
43155131Srwatson{
44186647Srwatson
45155131Srwatson	/*
46186647Srwatson	 * DBGU
47155131Srwatson	 */
48155131Srwatson	/* DRXD */
49155131Srwatson	at91_pio_use_periph_a(AT91SAM9260_PIOB_BASE, AT91C_PIO_PB14, 0);
50155131Srwatson	/* DTXD */
51186647Srwatson	at91_pio_use_periph_a(AT91SAM9260_PIOB_BASE, AT91C_PIO_PB15, 1);
52155131Srwatson
53186647Srwatson	/*
54155131Srwatson	 * EMAC
55155131Srwatson	 */
56155131Srwatson	/* ETX0 */
57155131Srwatson	at91_pio_use_periph_a(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA12, 0);
58155131Srwatson	/* ETX1 */
59155131Srwatson	at91_pio_use_periph_a(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA13, 0);
60155131Srwatson	/* ERX0 */
61155131Srwatson	at91_pio_use_periph_a(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA14, 0);
62155131Srwatson	/* ERX1 */
63155131Srwatson	at91_pio_use_periph_a(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA15, 0);
64155131Srwatson	/* ETXEN */
65155131Srwatson	at91_pio_use_periph_a(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA16, 0);
66155131Srwatson	/* ERXDV */
67155131Srwatson	at91_pio_use_periph_a(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA17, 0);
68155131Srwatson	/* ERXER */
69155131Srwatson	at91_pio_use_periph_a(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA18, 0);
70155131Srwatson	/* ETXCK */
71155131Srwatson	at91_pio_use_periph_a(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA19, 0);
72155131Srwatson	/* EMDC */
73155131Srwatson	at91_pio_use_periph_a(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA20, 0);
74155131Srwatson	/* EMDIO */
75155131Srwatson	at91_pio_use_periph_a(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA21, 0);
76155131Srwatson
77155131Srwatson	/*
78155131Srwatson	 * MMC
79155131Srwatson	 */
80155131Srwatson	/* MCDA0 */
81155131Srwatson	at91_pio_use_periph_a(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA6, 1);
82155131Srwatson	/* MCCDA */
83155131Srwatson	at91_pio_use_periph_a(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA7, 1);
84155131Srwatson	/* MCCK */
85155131Srwatson	at91_pio_use_periph_a(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA8, 1);
86155131Srwatson	/* MCDA1 */
87155131Srwatson	at91_pio_use_periph_a(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA9, 1);
88155131Srwatson	/* MCDA2 */
89155131Srwatson	at91_pio_use_periph_a(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA10, 1);
90155131Srwatson	/* MCDA3 */
91155131Srwatson	at91_pio_use_periph_a(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA11, 1);
92155131Srwatson
93155131Srwatson	/*
94155131Srwatson	 * SPI0
95155131Srwatson	 */
96155131Srwatson	/* MISO */
97155131Srwatson	at91_pio_use_periph_a(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA0, 0);
98155131Srwatson	/* MOSI */
99155131Srwatson	at91_pio_use_periph_a(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA1, 0);
100155131Srwatson	/* SPCK */
101155131Srwatson	at91_pio_use_periph_a(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA2, 0);
102155131Srwatson	/* NPCS0 */
103155131Srwatson	at91_pio_use_periph_a(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA3, 0);
104155131Srwatson
105155131Srwatson	/*
106155131Srwatson	 * TWI
107155131Srwatson	 */
108155131Srwatson	/* TWD */
109155131Srwatson	at91_pio_use_periph_a(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA23, 1);
110155131Srwatson	/* TWCK */
111155131Srwatson	at91_pio_use_periph_a(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA24, 1);
112155131Srwatson
113155131Srwatson	/*
114155131Srwatson	 * USART0
115155131Srwatson	 */
116155131Srwatson	/* TXD0 */
117155131Srwatson	at91_pio_use_periph_a(AT91SAM9260_PIOB_BASE, AT91C_PIO_PB4, 1);
118155131Srwatson	/* RXD0 */
119155131Srwatson	at91_pio_use_periph_a(AT91SAM9260_PIOB_BASE, AT91C_PIO_PB5, 0);
120155131Srwatson	/* DSR0 */
121155131Srwatson	at91_pio_use_periph_a(AT91SAM9260_PIOB_BASE, AT91C_PIO_PB22, 0);
122155131Srwatson	/* DCD0 */
123155131Srwatson	at91_pio_use_periph_a(AT91SAM9260_PIOB_BASE, AT91C_PIO_PB23, 0);
124155131Srwatson	/* DTR0 */
125155131Srwatson	at91_pio_use_periph_a(AT91SAM9260_PIOB_BASE, AT91C_PIO_PB24, 1);
126155131Srwatson	/* RI0 */
127155131Srwatson	at91_pio_use_periph_a(AT91SAM9260_PIOB_BASE, AT91C_PIO_PB25, 0);
128155131Srwatson	/* RTS0 */
129155131Srwatson	at91_pio_use_periph_a(AT91SAM9260_PIOB_BASE, AT91C_PIO_PB26, 1);
130155131Srwatson	/* CTS0 */
131155131Srwatson	at91_pio_use_periph_a(AT91SAM9260_PIOB_BASE, AT91C_PIO_PB27, 0);
132155131Srwatson
133155131Srwatson	/*
134155131Srwatson	 * USART2
135155131Srwatson	 */
136155131Srwatson	/* RTS2 */
137155131Srwatson	at91_pio_use_periph_a(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA4, 1);
138155131Srwatson	/* CTS2 */
139155131Srwatson	at91_pio_use_periph_a(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA5, 0);
140155131Srwatson	/* TXD2 */
141155131Srwatson	at91_pio_use_periph_a(AT91SAM9260_PIOB_BASE, AT91C_PIO_PB8, 1);
142155131Srwatson	/* RXD2 */
143155131Srwatson	at91_pio_use_periph_a(AT91SAM9260_PIOB_BASE, AT91C_PIO_PB9, 0);
144155131Srwatson
145155131Srwatson	return (at91_ramsize());
146155131Srwatson}
147155131Srwatson