]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/arm/at91/board_hl201.c
MFV r329793, r329795:
[FreeBSD/FreeBSD.git] / sys / arm / at91 / board_hl201.c
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3  *
4  * Copyright (c) 2005-2008 Olivier Houchard.  All rights reserved.
5  * Copyright (c) 2005-2008 Warner Losh.  All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  */
28
29 #include <sys/cdefs.h>
30 __FBSDID("$FreeBSD$");
31 #include <sys/param.h>
32 #include <sys/systm.h>
33
34 #include <machine/board.h>
35 #include <arm/at91/at91board.h>
36 #include <arm/at91/at91sam9g20reg.h>
37 #include <arm/at91/at91_piovar.h>
38 #include <arm/at91/at91_pio_sam9g20.h>
39 #include <arm/at91/at91_smc.h>
40 #include <arm/at91/at91_gpio.h>
41 #include <dev/nand/nfc_at91.h>
42
43 static struct at91_smc_init nand_smc = {
44         .ncs_rd_setup           = 0,
45         .nrd_setup              = 2,
46         .ncs_wr_setup           = 0,
47         .nwe_setup              = 2,
48
49         .ncs_rd_pulse           = 4,
50         .nrd_pulse              = 4,
51         .ncs_wr_pulse           = 4,
52         .nwe_pulse              = 4,
53
54         .nrd_cycle              = 7,
55         .nwe_cycle              = 7,
56
57         .mode                   = SMC_MODE_READ | SMC_MODE_WRITE | SMC_MODE_EXNW_DISABLED,
58         .tdf_cycles             = 3,
59 };
60
61 static struct at91_nand_params nand_param = {
62         .ale                    = 1u << 21,
63         .cle                    = 1u << 22,
64         .width                  = 8,
65         .rnb_pin                = AT91_PIN_PC13,        /* Note: These pins not confirmed */
66         .nce_pin                = AT91_PIN_PC14,
67         .cs                     = 3,
68 };
69
70 BOARD_INIT long
71 board_init(void)
72 {
73         /* Setup Ethernet Pins */
74         at91_pio_use_periph_a(AT91SAM9G20_PIOA_BASE, 1<<7, 0);
75
76         at91_pio_gpio_input(AT91SAM9G20_PIOA_BASE, 1<<7);
77         at91_pio_gpio_set_deglitch(AT91SAM9G20_PIOA_BASE, 1<<7, 1);
78
79         at91_pio_use_periph_a(AT91SAM9G20_PIOA_BASE, AT91C_PIO_PA19, 0);        /* ETXCK_EREFCK */
80         at91_pio_use_periph_a(AT91SAM9G20_PIOA_BASE, AT91C_PIO_PA17, 0);        /* ERXDV */
81         at91_pio_use_periph_a(AT91SAM9G20_PIOA_BASE, AT91C_PIO_PA14, 0);        /* ERX0 */
82         at91_pio_use_periph_a(AT91SAM9G20_PIOA_BASE, AT91C_PIO_PA15, 0);        /* ERX1 */
83         at91_pio_use_periph_a(AT91SAM9G20_PIOA_BASE, AT91C_PIO_PA18, 0);        /* ERXER */
84         at91_pio_use_periph_a(AT91SAM9G20_PIOA_BASE, AT91C_PIO_PA16, 0);        /* ETXEN */
85         at91_pio_use_periph_a(AT91SAM9G20_PIOA_BASE, AT91C_PIO_PA12, 0);        /* ETX0 */
86         at91_pio_use_periph_a(AT91SAM9G20_PIOA_BASE, AT91C_PIO_PA13, 0);        /* ETX1 */
87         at91_pio_use_periph_a(AT91SAM9G20_PIOA_BASE, AT91C_PIO_PA21, 0);        /* EMDIO */
88         at91_pio_use_periph_a(AT91SAM9G20_PIOA_BASE, AT91C_PIO_PA20, 0);        /* EMDC */
89
90         at91_pio_use_periph_b(AT91SAM9G20_PIOA_BASE, AT91C_PIO_PA28, 0);        /* ECRS */
91         at91_pio_use_periph_b(AT91SAM9G20_PIOA_BASE, AT91C_PIO_PA29, 0);        /* ECOL */
92         at91_pio_use_periph_b(AT91SAM9G20_PIOA_BASE, AT91C_PIO_PA25, 0);        /* ERX2 */
93         at91_pio_use_periph_b(AT91SAM9G20_PIOA_BASE, AT91C_PIO_PA26, 0);        /* ERX3 */
94         at91_pio_use_periph_b(AT91SAM9G20_PIOA_BASE, AT91C_PIO_PA27, 0);        /* ERXCK */
95         at91_pio_use_periph_b(AT91SAM9G20_PIOA_BASE, AT91C_PIO_PA23, 0);        /* ETX2 */
96         at91_pio_use_periph_b(AT91SAM9G20_PIOA_BASE, AT91C_PIO_PA24, 0);        /* ETX3 */
97         at91_pio_use_periph_b(AT91SAM9G20_PIOA_BASE, AT91C_PIO_PA22, 0);        /* ETXER */
98
99         /* Setup Static Memory Controller */
100         at91_smc_setup(0, 3, &nand_smc);
101         at91_enable_nand(&nand_param);
102
103         /*
104          * This assumes
105          *  - RNB is on pin PC13
106          *  - CE is on pin PC14
107          *
108          * Nothing actually uses RNB right now.
109          *
110          * For CE, this currently asserts it during board setup and leaves it
111          * that way forever.
112          *
113          * All this can go away when the gpio pin-renumbering happens...
114          */
115         at91_pio_use_gpio(AT91SAM9G20_PIOC_BASE, AT91C_PIO_PC13 | AT91C_PIO_PC14);
116         at91_pio_gpio_input(AT91SAM9G20_PIOC_BASE, AT91C_PIO_PC13);     /* RNB */
117         at91_pio_gpio_output(AT91SAM9G20_PIOC_BASE, AT91C_PIO_PC14, 0); /* nCS */
118         at91_pio_gpio_clear(AT91SAM9G20_PIOC_BASE, AT91C_PIO_PC14);     /* Assert nCS */
119
120         return (at91_ramsize());
121 }
122
123 ARM_BOARD(NONE, "HOTe 201");