The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/arm/at91/board_sam9260ek.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 2012 Marius Strobl <marius@FreeBSD.org>
    3  * All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer.
   10  * 2. Redistributions in binary form must reproduce the above copyright
   11  *    notice, this list of conditions and the following disclaimer in the
   12  *    documentation and/or other materials provided with the distribution.
   13  *
   14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   24  * SUCH DAMAGE.
   25  */
   26 
   27 /*
   28  * Ethernut 5 board support
   29  */
   30 
   31 #include <sys/cdefs.h>
   32 __FBSDID("$FreeBSD$");
   33 
   34 #include <sys/param.h>
   35 #include <sys/systm.h>
   36 #include <machine/board.h>
   37 #include <arm/at91/at91_pioreg.h>
   38 #include <arm/at91/at91_piovar.h>
   39 #include <arm/at91/at91board.h>
   40 #include <arm/at91/at91sam9260reg.h>
   41 #include <arm/at91/at91_smc.h>
   42 #include <arm/at91/at91_gpio.h>
   43 #include <dev/nand/nfc_at91.h>
   44 
   45 static struct at91_smc_init nand_smc = {
   46         .ncs_rd_setup           = 0,
   47         .nrd_setup              = 1,
   48         .ncs_wr_setup           = 0,
   49         .nwe_setup              = 1,
   50 
   51         .ncs_rd_pulse           = 3,
   52         .nrd_pulse              = 3,
   53         .ncs_wr_pulse           = 3,
   54         .nwe_pulse              = 3,
   55 
   56         .nrd_cycle              = 5,
   57         .nwe_cycle              = 5,
   58 
   59         .mode                   = SMC_MODE_READ | SMC_MODE_WRITE | SMC_MODE_EXNW_DISABLED,
   60         .tdf_cycles             = 2,
   61 };
   62 
   63 static struct at91_nand_params nand_param = {
   64         .ale                    = 1u << 21,
   65         .cle                    = 1u << 22,
   66         .width                  = 8,
   67         .rnb_pin                = AT91_PIN_PC13,
   68         .nce_pin                = AT91_PIN_PC14,
   69         .cs                     = 3,
   70 };
   71 
   72 static void
   73 bi_dbgu(void)
   74 {
   75 
   76         /*
   77          * DBGU
   78          */
   79         /* DRXD */
   80         at91_pio_use_periph_a(AT91SAM9260_PIOB_BASE, AT91C_PIO_PB14, 0);
   81         /* DTXD */
   82         at91_pio_use_periph_a(AT91SAM9260_PIOB_BASE, AT91C_PIO_PB15, 1);
   83 }
   84 
   85 static void
   86 bi_emac(void)
   87 {
   88 
   89         /*
   90          * EMAC
   91          */
   92         /* ETX0 */
   93         at91_pio_use_periph_a(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA12, 0);
   94         /* ETX1 */
   95         at91_pio_use_periph_a(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA13, 0);
   96         /* ERX0 */
   97         at91_pio_use_periph_a(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA14, 0);
   98         /* ERX1 */
   99         at91_pio_use_periph_a(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA15, 0);
  100         /* ETXEN */
  101         at91_pio_use_periph_a(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA16, 0);
  102         /* ERXDV */
  103         at91_pio_use_periph_a(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA17, 0);
  104         /* ERXER */
  105         at91_pio_use_periph_a(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA18, 0);
  106         /* ETXCK */
  107         at91_pio_use_periph_a(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA19, 0);
  108         /* EMDC */
  109         at91_pio_use_periph_a(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA20, 0);
  110         /* EMDIO */
  111         at91_pio_use_periph_a(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA21, 0);
  112         /* Not RMII */
  113         /* ETX2 */
  114         at91_pio_use_periph_b(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA10, 0);
  115         /* ETX3 */
  116         at91_pio_use_periph_b(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA11, 0);
  117         /* ETXER */
  118         at91_pio_use_periph_b(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA22, 0);
  119         /* ERX2 */
  120         at91_pio_use_periph_b(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA25, 0);
  121         /* ERX3 */
  122         at91_pio_use_periph_b(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA26, 0);
  123         /* ERXCK */
  124         at91_pio_use_periph_b(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA27, 0);
  125         /* ECRS */
  126         at91_pio_use_periph_b(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA28, 0);
  127         /* ECOL */
  128         at91_pio_use_periph_b(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA29, 0);
  129 }
  130 
  131 static void
  132 bi_mmc(void)
  133 {
  134 
  135         /*
  136          * MMC, wired to socket B.
  137          */
  138         /* MCDB0 */
  139         at91_pio_use_periph_b(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA0, 1);
  140         /* MCCDB */
  141         at91_pio_use_periph_b(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA1, 1);
  142         /* MCDB3 */
  143         at91_pio_use_periph_b(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA3, 1);
  144         /* MCDB2 */
  145         at91_pio_use_periph_b(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA4, 1);
  146         /* MCDB1 */
  147         at91_pio_use_periph_b(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA5, 1);
  148         /* MCCK */
  149         at91_pio_use_periph_a(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA8, 1);
  150 
  151         /*
  152          * SPI0 and MMC are wired together, since we don't support sharing
  153          * don't support the dataflash.  But if you did, you'd have to
  154          * use CS0 and CS1.
  155          */
  156 }
  157 
  158 static void
  159 bi_iic(void)
  160 {
  161 
  162         /*
  163          * TWI.  Only one child on the iic bus, which we take care of
  164          * via hints.
  165          */
  166         /* TWD */
  167         at91_pio_use_periph_a(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA23, 1);
  168         /* TWCK */
  169         at91_pio_use_periph_a(AT91SAM9260_PIOA_BASE, AT91C_PIO_PA24, 1);
  170 }
  171 
  172 static void
  173 bi_usart0(void)
  174 {
  175 
  176         /*
  177          * USART0
  178          */
  179         /* TXD0 */
  180         at91_pio_use_periph_a(AT91SAM9260_PIOB_BASE, AT91C_PIO_PB4, 1);
  181         /* RXD0 */
  182         at91_pio_use_periph_a(AT91SAM9260_PIOB_BASE, AT91C_PIO_PB5, 0);
  183         /* DSR0 */
  184         at91_pio_use_periph_a(AT91SAM9260_PIOB_BASE, AT91C_PIO_PB22, 0);
  185         /* DCD0 */
  186         at91_pio_use_periph_a(AT91SAM9260_PIOB_BASE, AT91C_PIO_PB23, 0);
  187         /* DTR0 */
  188         at91_pio_use_periph_a(AT91SAM9260_PIOB_BASE, AT91C_PIO_PB24, 1);
  189         /* RI0 */
  190         at91_pio_use_periph_a(AT91SAM9260_PIOB_BASE, AT91C_PIO_PB25, 0);
  191         /* RTS0 */
  192         at91_pio_use_periph_a(AT91SAM9260_PIOB_BASE, AT91C_PIO_PB26, 1);
  193         /* CTS0 */
  194         at91_pio_use_periph_a(AT91SAM9260_PIOB_BASE, AT91C_PIO_PB27, 0);
  195 }
  196 
  197 static void
  198 bi_usart1(void)
  199 {
  200         /*
  201          * USART1
  202          */
  203         /* RTS1 */
  204         at91_pio_use_periph_a(AT91SAM9260_PIOB_BASE, AT91C_PIO_PB28, 1);
  205         /* CTS1 */
  206         at91_pio_use_periph_a(AT91SAM9260_PIOB_BASE, AT91C_PIO_PB29, 0);
  207         /* TXD1 */
  208         at91_pio_use_periph_a(AT91SAM9260_PIOB_BASE, AT91C_PIO_PB6, 1);
  209         /* RXD1 */
  210         at91_pio_use_periph_a(AT91SAM9260_PIOB_BASE, AT91C_PIO_PB7, 0);
  211 }
  212 
  213 static void
  214 bi_nand(void)
  215 {
  216         /* Samsung 256MB SLC Flash */
  217 
  218         /* Setup Static Memory Controller */
  219         at91_smc_setup(0, 3, &nand_smc);
  220         at91_enable_nand(&nand_param);
  221 
  222         /*
  223          * This assumes
  224          *  - RNB is on pin PC13
  225          *  - CE is on pin PC14
  226          *
  227          * Nothing actually uses RNB right now.
  228          *
  229          * For CE, this currently asserts it during board setup and leaves it
  230          * that way forever.
  231          *
  232          * All this can go away when the gpio pin-renumbering happens...
  233          */
  234         at91_pio_use_gpio(AT91SAM9260_PIOC_BASE, AT91C_PIO_PC13 | AT91C_PIO_PC14);
  235         at91_pio_gpio_input(AT91SAM9260_PIOC_BASE, AT91C_PIO_PC13);     /* RNB */
  236         at91_pio_gpio_output(AT91SAM9260_PIOC_BASE, AT91C_PIO_PC14, 0); /* nCS */
  237         at91_pio_gpio_clear(AT91SAM9260_PIOC_BASE, AT91C_PIO_PC14);     /* Assert nCS */
  238 }
  239 
  240 BOARD_INIT long
  241 board_init(void)
  242 {
  243         bi_dbgu();
  244         bi_emac();
  245         bi_mmc();
  246 
  247         /*
  248          * SPI1 is wired to a audio CODEC that we don't support, so
  249          * give it a pass.
  250          */
  251 
  252         bi_iic();
  253         bi_usart0();
  254         bi_usart1();
  255         /* USART2 - USART5 aren't wired up, except via PIO pins, ignore them. */
  256 
  257         bi_nand();
  258 
  259         return (at91_ramsize());
  260 }
  261 
  262 ARM_BOARD(AT91SAM9260EK, "Atmel SMA9260-EK")

Cache object: b03dcb945f17ae83bc224ec68f2d60d9


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.