2 * ADM5120 specific board support for LZMA decompressor
4 * Copyright (C) 2007-2008 OpenWrt.org
5 * Copyright (C) 2007-2008 Gabor Juhos <juhosg@openwrt.org>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #define READREG(r) *(volatile unsigned int *)(r)
26 #define WRITEREG(r,v) *(volatile unsigned int *)(r) = v
31 #define INTC_BASE 0xB2200000
34 #define INTC_REG_IRQ_DISABLE 0x0C
39 #define UART0_BASE 0xB2600000
40 #define UART1_BASE 0xB2800000
42 #define UART_REG_DATA 0x00 /* Data register */
43 #define UART_REG_ECR 0x04 /* Error Clear register */
44 #define UART_REG_LCRH 0x08 /* Line Control High register */
45 #define UART_REG_LCRM 0x0C /* Line Control Middle register */
46 #define UART_REG_LCRL 0x10 /* Line Control Low register */
47 #define UART_REG_CTRL 0x14 /* Control register */
48 #define UART_REG_FLAG 0x18 /* Flag register */
50 /* Control register bits */
51 #define UART_CTRL_EN ( 1 << 0 ) /* UART enable */
53 /* Line Control High register bits */
54 #define UART_LCRH_FEN ( 1 << 4 ) /* FIFO enable */
56 /* Flag register bits */
57 #define UART_FLAG_CTS ( 1 << 0 )
58 #define UART_FLAG_DSR ( 1 << 1 )
59 #define UART_FLAG_DCD ( 1 << 2 )
60 #define UART_FLAG_BUSY ( 1 << 3 )
61 #define UART_FLAG_RXFE ( 1 << 4 ) /* RX FIFO empty */
62 #define UART_FLAG_TXFF ( 1 << 5 ) /* TX FIFO full */
63 #define UART_FLAG_RXFF ( 1 << 6 ) /* RX FIFO full */
64 #define UART_FLAG_TXFE ( 1 << 7 ) /* TX FIFO empty */
69 #define SWITCH_BASE 0xB2000000
71 #define SWITCH_REG_CPUP_CONF 0x0024
72 #define SWITCH_REG_PORT_CONF0 0x0028
74 #define SWITCH_REG_GPIO_CONF0 0x00B8
75 #define SWITCH_REG_GPIO_CONF2 0x00BC
77 #define SWITCH_REG_PORT0_LED 0x0100
78 #define SWITCH_REG_PORT1_LED 0x0104
79 #define SWITCH_REG_PORT2_LED 0x0108
80 #define SWITCH_REG_PORT3_LED 0x010C
81 #define SWITCH_REG_PORT4_LED 0x0110
83 #define SWITCH_PORTS_HW 0x3F /* Hardware Ports */
85 /* CPUP_CONF register bits */
86 #define CPUP_CONF_DCPUP ( 1 << 0 ) /* Disable CPU port */
88 /* PORT_CONF0 register bits */
89 #define PORT_CONF0_DP_SHIFT 0 /* disable port shift*/
96 #if defined(CONFIG_USE_UART0)
97 # define UART_READ(r) READREG(UART0_BASE+(r))
98 # define UART_WRITE(r,v) WRITEREG(UART0_BASE+(r),(v))
100 # define UART_READ(r) READREG(UART1_BASE+(r))
101 # define UART_WRITE(r,v) WRITEREG(UART1_BASE+(r),(v))
104 static void uart_init(void)
110 UART_WRITE(UART_REG_CTRL
, 0);
112 /* keep current baud rate */
113 t
= UART_READ(UART_REG_LCRM
);
114 UART_WRITE(UART_REG_LCRM
, t
);
115 t
= UART_READ(UART_REG_LCRL
);
116 UART_WRITE(UART_REG_LCRL
, t
);
118 /* keep data, stop, and parity bits, but disable FIFO */
119 t
= UART_READ(UART_REG_LCRH
);
120 t
&= ~(UART_LCRH_FEN
);
121 UART_WRITE(UART_REG_LCRH
, t
);
123 /* clear error bits */
124 UART_WRITE(UART_REG_ECR
, 0xFF);
126 /* enable uart, and disable interrupts */
127 UART_WRITE(UART_REG_CTRL
, UART_CTRL_EN
);
135 #define INTC_READ(r) READREG(INTC_BASE+(r))
136 #define INTC_WRITE(r,v) WRITEREG(INTC_BASE+(r),v)
138 static void intc_init(void)
140 INTC_WRITE(INTC_REG_IRQ_DISABLE
, 0xFFFFFFFF);
147 #define SWITCH_READ(r) READREG(SWITCH_BASE+(r))
148 #define SWITCH_WRITE(r,v) WRITEREG(SWITCH_BASE+(r),v)
150 static void switch_init(void)
152 /* disable PHYS ports */
153 SWITCH_WRITE(SWITCH_REG_PORT_CONF0
,
154 (SWITCH_PORTS_HW
<< PORT_CONF0_DP_SHIFT
));
156 /* disable CPU port */
157 SWITCH_WRITE(SWITCH_REG_CPUP_CONF
, CPUP_CONF_DCPUP
);
159 /* disable GPIO lines */
160 SWITCH_WRITE(SWITCH_REG_GPIO_CONF0
, 0);
161 SWITCH_WRITE(SWITCH_REG_GPIO_CONF2
, 0);
163 /* disable LED lines */
164 SWITCH_WRITE(SWITCH_REG_PORT0_LED
, 0);
165 SWITCH_WRITE(SWITCH_REG_PORT1_LED
, 0);
166 SWITCH_WRITE(SWITCH_REG_PORT2_LED
, 0);
167 SWITCH_WRITE(SWITCH_REG_PORT3_LED
, 0);
168 SWITCH_WRITE(SWITCH_REG_PORT4_LED
, 0);
171 void board_putc(int ch
)
173 while ((UART_READ(UART_REG_FLAG
) & UART_FLAG_TXFE
) == 0);
175 UART_WRITE(UART_REG_DATA
, ch
);
177 while ((UART_READ(UART_REG_FLAG
) & UART_FLAG_TXFE
) == 0);
180 void board_init(void)
This page took 0.062389 seconds and 5 git commands to generate.