board_bwct.c revision 185307
142660Smarkm/*- 293139Sru * Copyright (c) 2005-2008 Olivier Houchard. All rights reserved. 321495Sjmacd * Copyright (c) 2005-2008 Warner Losh. All rights reserved. 493139Sru * 521495Sjmacd * Redistribution and use in source and binary forms, with or without 621495Sjmacd * modification, are permitted provided that the following conditions 721495Sjmacd * are met: 821495Sjmacd * 1. Redistributions of source code must retain the above copyright 921495Sjmacd * notice, this list of conditions and the following disclaimer. 1021495Sjmacd * 2. Redistributions in binary form must reproduce the above copyright 1121495Sjmacd * notice, this list of conditions and the following disclaimer in the 1221495Sjmacd * documentation and/or other materials provided with the distribution. 1321495Sjmacd * 1421495Sjmacd * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1521495Sjmacd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1621495Sjmacd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1721495Sjmacd * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 1893139Sru * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1993139Sru * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2093139Sru * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2121495Sjmacd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2242660Smarkm * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2356160Sru * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2421495Sjmacd * SUCH DAMAGE. 2593139Sru */ 2621495Sjmacd 2742660Smarkm#include <sys/cdefs.h> 2821495Sjmacd__FBSDID("$FreeBSD: head/sys/arm/at91/board_bwct.c 185307 2008-11-25 19:05:46Z imp $"); 2921495Sjmacd#include <sys/param.h> 3021495Sjmacd#include <sys/systm.h> 3121495Sjmacd 3221495Sjmacd#include <arm/at91/at91board.h> 3321495Sjmacd#include <arm/at91/at91rm92reg.h> 3421495Sjmacd#include <arm/at91/at91_piovar.h> 3521495Sjmacd#include <arm/at91/at91_pio_rm9200.h> 3621495Sjmacd 3721495Sjmacdlong 3821495Sjmacdboard_init(void) 3921495Sjmacd{ 4021495Sjmacd /* 4121495Sjmacd * Since the USART supports RS-485 multidrop mode, it allows the 4221495Sjmacd * TX pins to float. However, for RS-232 operations, we don't want 4321495Sjmacd * these pins to float. Instead, they should be pulled up to avoid 4421495Sjmacd * mismatches. Linux does something similar when it configures the 4542660Smarkm * TX lines. This implies that we also allow the RX lines to float 4621495Sjmacd * rather than be in the state they are left in by the boot loader. 4721495Sjmacd * Since they are input pins, I think that this is the right thing 4821495Sjmacd * to do. 4921495Sjmacd */ 5021495Sjmacd 5121495Sjmacd /* PIOA's A periph: Turn USART 0 and 2's TX/RX pins */ 5221495Sjmacd at91_pio_use_periph_a(AT91RM92_PIOA_BASE, 5321495Sjmacd AT91C_PA18_RXD0 | AT91C_PA22_RXD2, 0); 5421495Sjmacd at91_pio_use_periph_a(AT91RM92_PIOA_BASE, 5521495Sjmacd AT91C_PA17_TXD0 | AT91C_PA23_TXD2, 1); 5621495Sjmacd /* PIOA's B periph: Turn USART 3's TX/RX pins */ 5721495Sjmacd at91_pio_use_periph_b(AT91RM92_PIOA_BASE, AT91C_PA6_RXD3, 0); 5856160Sru at91_pio_use_periph_b(AT91RM92_PIOA_BASE, AT91C_PA5_TXD3, 1); 5921495Sjmacd /* PIOB's A periph: Turn USART 1's TX/RX pins */ 6021495Sjmacd at91_pio_use_periph_a(AT91RM92_PIOB_BASE, AT91C_PB21_RXD1, 0); 6121495Sjmacd at91_pio_use_periph_a(AT91RM92_PIOB_BASE, AT91C_PB20_TXD1, 1); 6221495Sjmacd 6342660Smarkm /* Pin assignment */ 6421495Sjmacd 6521495Sjmacd return (at91_ramsize()); 6621495Sjmacd} 6721495Sjmacd