Commit 7b5611cdd12ca0cc33f994f0d4a4454788fc3124
Committed by
Wolfgang Denk
1 parent
04e11cf383
Exists in
master
and in
54 other branches
inka4x0: Add hardware diagnosis functions for inka4x0
This patch adds advanced diagnosis functions for the inka4x0 board. Signed-off-by: Andreas Pfefferle <ap@denx.de> Signed-off-by: Detlev Zundel <dzu@denx.de>
Showing 5 changed files with 546 additions and 4 deletions Inline Diff
board/inka4x0/Makefile
1 | # | 1 | # |
2 | # (C) Copyright 2003-2006 | 2 | # (C) Copyright 2003-2009 |
3 | # Wolfgang Denk, DENX Software Engineering, wd@denx.de. | 3 | # Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
4 | # | 4 | # |
5 | # See file CREDITS for list of people who contributed to this | 5 | # See file CREDITS for list of people who contributed to this |
6 | # project. | 6 | # project. |
7 | # | 7 | # |
8 | # This program is free software; you can redistribute it and/or | 8 | # This program is free software; you can redistribute it and/or |
9 | # modify it under the terms of the GNU General Public License as | 9 | # modify it under the terms of the GNU General Public License as |
10 | # published by the Free Software Foundation; either version 2 of | 10 | # published by the Free Software Foundation; either version 2 of |
11 | # the License, or (at your option) any later version. | 11 | # the License, or (at your option) any later version. |
12 | # | 12 | # |
13 | # This program is distributed in the hope that it will be useful, | 13 | # This program is distributed in the hope that it will be useful, |
14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | # GNU General Public License for more details. | 16 | # GNU General Public License for more details. |
17 | # | 17 | # |
18 | # You should have received a copy of the GNU General Public License | 18 | # You should have received a copy of the GNU General Public License |
19 | # along with this program; if not, write to the Free Software | 19 | # along with this program; if not, write to the Free Software |
20 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, | 20 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
21 | # MA 02111-1307 USA | 21 | # MA 02111-1307 USA |
22 | # | 22 | # |
23 | 23 | ||
24 | include $(TOPDIR)/config.mk | 24 | include $(TOPDIR)/config.mk |
25 | 25 | ||
26 | LIB = $(obj)lib$(BOARD).a | 26 | LIB = $(obj)lib$(BOARD).a |
27 | 27 | ||
28 | COBJS := $(BOARD).o | 28 | COBJS := $(BOARD).o inkadiag.o |
29 | 29 | ||
30 | SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) | 30 | SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) |
31 | OBJS := $(addprefix $(obj),$(COBJS)) | 31 | OBJS := $(addprefix $(obj),$(COBJS)) |
32 | SOBJS := $(addprefix $(obj),$(SOBJS)) | 32 | SOBJS := $(addprefix $(obj),$(SOBJS)) |
33 | 33 | ||
34 | $(LIB): $(obj).depend $(OBJS) | 34 | $(LIB): $(obj).depend $(OBJS) |
35 | $(AR) $(ARFLAGS) $@ $(OBJS) | 35 | $(AR) $(ARFLAGS) $@ $(OBJS) |
36 | 36 | ||
37 | clean: | 37 | clean: |
38 | rm -f $(SOBJS) $(OBJS) | 38 | rm -f $(SOBJS) $(OBJS) |
39 | 39 | ||
40 | distclean: clean | 40 | distclean: clean |
41 | rm -f $(LIB) core *.bak $(obj).depend | 41 | rm -f $(LIB) core *.bak $(obj).depend |
42 | 42 | ||
43 | ######################################################################### | 43 | ######################################################################### |
44 | 44 | ||
45 | # defines $(obj).depend target | 45 | # defines $(obj).depend target |
46 | include $(SRCTREE)/rules.mk | 46 | include $(SRCTREE)/rules.mk |
47 | 47 | ||
48 | sinclude $(obj).depend | 48 | sinclude $(obj).depend |
49 | 49 | ||
50 | ######################################################################### | 50 | ######################################################################### |
51 | 51 |
board/inka4x0/inka4x0.c
1 | /* | 1 | /* |
2 | * (C) Copyright 2003-2004 | 2 | * (C) Copyright 2008-2009 |
3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. | 3 | * Andreas Pfefferle, DENX Software Engineering, ap@denx.de. |
4 | * | 4 | * |
5 | * (C) Copyright 2009 | ||
6 | * Detlev Zundel, DENX Software Engineering, dzu@denx.de. | ||
7 | * | ||
5 | * (C) Copyright 2004 | 8 | * (C) Copyright 2004 |
6 | * Mark Jonas, Freescale Semiconductor, mark.jonas@motorola.com. | 9 | * Mark Jonas, Freescale Semiconductor, mark.jonas@motorola.com. |
7 | * | 10 | * |
8 | * (C) Copyright 2004 | 11 | * (C) Copyright 2004 |
9 | * Martin Krause, TQ-Systems GmbH, martin.krause@tqs.de | 12 | * Martin Krause, TQ-Systems GmbH, martin.krause@tqs.de |
10 | * | 13 | * |
14 | * (C) Copyright 2003-2004 | ||
15 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. | ||
16 | * | ||
11 | * See file CREDITS for list of people who contributed to this | 17 | * See file CREDITS for list of people who contributed to this |
12 | * project. | 18 | * project. |
13 | * | 19 | * |
14 | * This program is free software; you can redistribute it and/or | 20 | * This program is free software; you can redistribute it and/or |
15 | * modify it under the terms of the GNU General Public License as | 21 | * modify it under the terms of the GNU General Public License as |
16 | * published by the Free Software Foundation; either version 2 of | 22 | * published by the Free Software Foundation; either version 2 of |
17 | * the License, or (at your option) any later version. | 23 | * the License, or (at your option) any later version. |
18 | * | 24 | * |
19 | * This program is distributed in the hope that it will be useful, | 25 | * This program is distributed in the hope that it will be useful, |
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 26 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 27 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22 | * GNU General Public License for more details. | 28 | * GNU General Public License for more details. |
23 | * | 29 | * |
24 | * You should have received a copy of the GNU General Public License | 30 | * You should have received a copy of the GNU General Public License |
25 | * along with this program; if not, write to the Free Software | 31 | * along with this program; if not, write to the Free Software |
26 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | 32 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
27 | * MA 02111-1307 USA | 33 | * MA 02111-1307 USA |
28 | */ | 34 | */ |
29 | 35 | ||
30 | #include <common.h> | 36 | #include <common.h> |
31 | #include <mpc5xxx.h> | 37 | #include <mpc5xxx.h> |
32 | #include <pci.h> | 38 | #include <pci.h> |
33 | 39 | ||
34 | #if defined(CONFIG_DDR_MT46V16M16) | 40 | #if defined(CONFIG_DDR_MT46V16M16) |
35 | #include "mt46v16m16-75.h" | 41 | #include "mt46v16m16-75.h" |
36 | #elif defined(CONFIG_SDR_MT48LC16M16A2) | 42 | #elif defined(CONFIG_SDR_MT48LC16M16A2) |
37 | #include "mt48lc16m16a2-75.h" | 43 | #include "mt48lc16m16a2-75.h" |
38 | #elif defined(CONFIG_DDR_MT46V32M16) | 44 | #elif defined(CONFIG_DDR_MT46V32M16) |
39 | #include "mt46v32m16.h" | 45 | #include "mt46v32m16.h" |
40 | #elif defined(CONFIG_DDR_HYB25D512160BF) | 46 | #elif defined(CONFIG_DDR_HYB25D512160BF) |
41 | #include "hyb25d512160bf.h" | 47 | #include "hyb25d512160bf.h" |
42 | #elif defined(CONFIG_DDR_K4H511638C) | 48 | #elif defined(CONFIG_DDR_K4H511638C) |
43 | #include "k4h511638c.h" | 49 | #include "k4h511638c.h" |
44 | #else | 50 | #else |
45 | #error "INKA4x0 SDRAM: invalid chip type specified!" | 51 | #error "INKA4x0 SDRAM: invalid chip type specified!" |
46 | #endif | 52 | #endif |
47 | 53 | ||
48 | #ifndef CONFIG_SYS_RAMBOOT | 54 | #ifndef CONFIG_SYS_RAMBOOT |
49 | static void sdram_start (int hi_addr) | 55 | static void sdram_start (int hi_addr) |
50 | { | 56 | { |
51 | long hi_addr_bit = hi_addr ? 0x01000000 : 0; | 57 | long hi_addr_bit = hi_addr ? 0x01000000 : 0; |
52 | 58 | ||
53 | /* unlock mode register */ | 59 | /* unlock mode register */ |
54 | *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000000 | hi_addr_bit; | 60 | *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000000 | hi_addr_bit; |
55 | __asm__ volatile ("sync"); | 61 | __asm__ volatile ("sync"); |
56 | 62 | ||
57 | /* precharge all banks */ | 63 | /* precharge all banks */ |
58 | *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000002 | hi_addr_bit; | 64 | *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000002 | hi_addr_bit; |
59 | __asm__ volatile ("sync"); | 65 | __asm__ volatile ("sync"); |
60 | 66 | ||
61 | #if SDRAM_DDR | 67 | #if SDRAM_DDR |
62 | /* set mode register: extended mode */ | 68 | /* set mode register: extended mode */ |
63 | *(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_EMODE; | 69 | *(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_EMODE; |
64 | __asm__ volatile ("sync"); | 70 | __asm__ volatile ("sync"); |
65 | 71 | ||
66 | /* set mode register: reset DLL */ | 72 | /* set mode register: reset DLL */ |
67 | *(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_MODE | 0x04000000; | 73 | *(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_MODE | 0x04000000; |
68 | __asm__ volatile ("sync"); | 74 | __asm__ volatile ("sync"); |
69 | #endif | 75 | #endif |
70 | 76 | ||
71 | /* precharge all banks */ | 77 | /* precharge all banks */ |
72 | *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000002 | hi_addr_bit; | 78 | *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000002 | hi_addr_bit; |
73 | __asm__ volatile ("sync"); | 79 | __asm__ volatile ("sync"); |
74 | 80 | ||
75 | /* auto refresh */ | 81 | /* auto refresh */ |
76 | *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000004 | hi_addr_bit; | 82 | *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000004 | hi_addr_bit; |
77 | __asm__ volatile ("sync"); | 83 | __asm__ volatile ("sync"); |
78 | 84 | ||
79 | /* set mode register */ | 85 | /* set mode register */ |
80 | *(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_MODE; | 86 | *(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_MODE; |
81 | __asm__ volatile ("sync"); | 87 | __asm__ volatile ("sync"); |
82 | 88 | ||
83 | /* normal operation */ | 89 | /* normal operation */ |
84 | *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | hi_addr_bit; | 90 | *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | hi_addr_bit; |
85 | __asm__ volatile ("sync"); | 91 | __asm__ volatile ("sync"); |
86 | } | 92 | } |
87 | #endif | 93 | #endif |
88 | 94 | ||
89 | /* | 95 | /* |
90 | * ATTENTION: Although partially referenced initdram does NOT make real use | 96 | * ATTENTION: Although partially referenced initdram does NOT make real use |
91 | * use of CONFIG_SYS_SDRAM_BASE. The code does not work if CONFIG_SYS_SDRAM_BASE | 97 | * use of CONFIG_SYS_SDRAM_BASE. The code does not work if CONFIG_SYS_SDRAM_BASE |
92 | * is something else than 0x00000000. | 98 | * is something else than 0x00000000. |
93 | */ | 99 | */ |
94 | 100 | ||
95 | phys_size_t initdram (int board_type) | 101 | phys_size_t initdram (int board_type) |
96 | { | 102 | { |
97 | ulong dramsize = 0; | 103 | ulong dramsize = 0; |
98 | #ifndef CONFIG_SYS_RAMBOOT | 104 | #ifndef CONFIG_SYS_RAMBOOT |
99 | long test1, test2; | 105 | long test1, test2; |
100 | 106 | ||
101 | /* setup SDRAM chip selects */ | 107 | /* setup SDRAM chip selects */ |
102 | *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x0000001c; /* 512MB at 0x0 */ | 108 | *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x0000001c; /* 512MB at 0x0 */ |
103 | *(vu_long *)MPC5XXX_SDRAM_CS1CFG = 0x40000000; /* disabled */ | 109 | *(vu_long *)MPC5XXX_SDRAM_CS1CFG = 0x40000000; /* disabled */ |
104 | __asm__ volatile ("sync"); | 110 | __asm__ volatile ("sync"); |
105 | 111 | ||
106 | /* setup config registers */ | 112 | /* setup config registers */ |
107 | *(vu_long *)MPC5XXX_SDRAM_CONFIG1 = SDRAM_CONFIG1; | 113 | *(vu_long *)MPC5XXX_SDRAM_CONFIG1 = SDRAM_CONFIG1; |
108 | *(vu_long *)MPC5XXX_SDRAM_CONFIG2 = SDRAM_CONFIG2; | 114 | *(vu_long *)MPC5XXX_SDRAM_CONFIG2 = SDRAM_CONFIG2; |
109 | __asm__ volatile ("sync"); | 115 | __asm__ volatile ("sync"); |
110 | 116 | ||
111 | #if SDRAM_DDR | 117 | #if SDRAM_DDR |
112 | /* set tap delay */ | 118 | /* set tap delay */ |
113 | *(vu_long *)MPC5XXX_CDM_PORCFG = SDRAM_TAPDELAY; | 119 | *(vu_long *)MPC5XXX_CDM_PORCFG = SDRAM_TAPDELAY; |
114 | __asm__ volatile ("sync"); | 120 | __asm__ volatile ("sync"); |
115 | #endif | 121 | #endif |
116 | 122 | ||
117 | /* find RAM size using SDRAM CS0 only */ | 123 | /* find RAM size using SDRAM CS0 only */ |
118 | sdram_start(0); | 124 | sdram_start(0); |
119 | test1 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x20000000); | 125 | test1 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x20000000); |
120 | sdram_start(1); | 126 | sdram_start(1); |
121 | test2 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x20000000); | 127 | test2 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x20000000); |
122 | if (test1 > test2) { | 128 | if (test1 > test2) { |
123 | sdram_start(0); | 129 | sdram_start(0); |
124 | dramsize = test1; | 130 | dramsize = test1; |
125 | } else { | 131 | } else { |
126 | dramsize = test2; | 132 | dramsize = test2; |
127 | } | 133 | } |
128 | 134 | ||
129 | /* memory smaller than 1MB is impossible */ | 135 | /* memory smaller than 1MB is impossible */ |
130 | if (dramsize < (1 << 20)) { | 136 | if (dramsize < (1 << 20)) { |
131 | dramsize = 0; | 137 | dramsize = 0; |
132 | } | 138 | } |
133 | 139 | ||
134 | /* set SDRAM CS0 size according to the amount of RAM found */ | 140 | /* set SDRAM CS0 size according to the amount of RAM found */ |
135 | if (dramsize > 0) { | 141 | if (dramsize > 0) { |
136 | *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x13 + | 142 | *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x13 + |
137 | __builtin_ffs(dramsize >> 20) - 1; | 143 | __builtin_ffs(dramsize >> 20) - 1; |
138 | } else { | 144 | } else { |
139 | *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0; /* disabled */ | 145 | *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0; /* disabled */ |
140 | } | 146 | } |
141 | 147 | ||
142 | *(vu_long *)MPC5XXX_SDRAM_CS1CFG = dramsize; /* disabled */ | 148 | *(vu_long *)MPC5XXX_SDRAM_CS1CFG = dramsize; /* disabled */ |
143 | #else /* CONFIG_SYS_RAMBOOT */ | 149 | #else /* CONFIG_SYS_RAMBOOT */ |
144 | 150 | ||
145 | /* retrieve size of memory connected to SDRAM CS0 */ | 151 | /* retrieve size of memory connected to SDRAM CS0 */ |
146 | dramsize = *(vu_long *)MPC5XXX_SDRAM_CS0CFG & 0xFF; | 152 | dramsize = *(vu_long *)MPC5XXX_SDRAM_CS0CFG & 0xFF; |
147 | if (dramsize >= 0x13) { | 153 | if (dramsize >= 0x13) { |
148 | dramsize = (1 << (dramsize - 0x13)) << 20; | 154 | dramsize = (1 << (dramsize - 0x13)) << 20; |
149 | } else { | 155 | } else { |
150 | dramsize = 0; | 156 | dramsize = 0; |
151 | } | 157 | } |
152 | #endif /* CONFIG_SYS_RAMBOOT */ | 158 | #endif /* CONFIG_SYS_RAMBOOT */ |
153 | 159 | ||
154 | return dramsize; | 160 | return dramsize; |
155 | } | 161 | } |
156 | 162 | ||
157 | int checkboard (void) | 163 | int checkboard (void) |
158 | { | 164 | { |
159 | puts ("Board: INKA 4X0\n"); | 165 | puts ("Board: INKA 4X0\n"); |
160 | return 0; | 166 | return 0; |
161 | } | 167 | } |
162 | 168 | ||
163 | void flash_preinit(void) | 169 | void flash_preinit(void) |
164 | { | 170 | { |
165 | /* | 171 | /* |
166 | * Now, when we are in RAM, enable flash write | 172 | * Now, when we are in RAM, enable flash write |
167 | * access for detection process. | 173 | * access for detection process. |
168 | * Note that CS_BOOT cannot be cleared when | 174 | * Note that CS_BOOT cannot be cleared when |
169 | * executing in flash. | 175 | * executing in flash. |
170 | */ | 176 | */ |
171 | *(vu_long *)MPC5XXX_BOOTCS_CFG &= ~0x1; /* clear RO */ | 177 | *(vu_long *)MPC5XXX_BOOTCS_CFG &= ~0x1; /* clear RO */ |
178 | } | ||
179 | |||
180 | int misc_init_r (void) { | ||
181 | extern int inkadiag_init_r (void); | ||
182 | |||
183 | /* | ||
184 | * The command table used for the subcommands of inkadiag | ||
185 | * needs to be relocated manually. | ||
186 | */ | ||
187 | return inkadiag_init_r(); | ||
172 | } | 188 | } |
173 | 189 | ||
174 | int misc_init_f (void) | 190 | int misc_init_f (void) |
175 | { | 191 | { |
176 | char tmp[10]; | 192 | char tmp[10]; |
177 | int i, br; | 193 | int i, br; |
178 | 194 | ||
179 | i = getenv_r("brightness", tmp, sizeof(tmp)); | 195 | i = getenv_r("brightness", tmp, sizeof(tmp)); |
180 | br = (i > 0) | 196 | br = (i > 0) |
181 | ? (int) simple_strtoul (tmp, NULL, 10) | 197 | ? (int) simple_strtoul (tmp, NULL, 10) |
182 | : CONFIG_SYS_BRIGHTNESS; | 198 | : CONFIG_SYS_BRIGHTNESS; |
183 | if (br > 255) | 199 | if (br > 255) |
184 | br = 255; | 200 | br = 255; |
185 | 201 | ||
186 | /* Initialize GPIO output pins. | 202 | /* Initialize GPIO output pins. |
187 | */ | 203 | */ |
188 | /* Configure GPT as GPIO output (and set them as they control low-active LEDs */ | 204 | /* Configure GPT as GPIO output (and set them as they control low-active LEDs */ |
189 | *(vu_long *)MPC5XXX_GPT0_ENABLE = | 205 | *(vu_long *)MPC5XXX_GPT0_ENABLE = |
190 | *(vu_long *)MPC5XXX_GPT1_ENABLE = | 206 | *(vu_long *)MPC5XXX_GPT1_ENABLE = |
191 | *(vu_long *)MPC5XXX_GPT2_ENABLE = | 207 | *(vu_long *)MPC5XXX_GPT2_ENABLE = |
192 | *(vu_long *)MPC5XXX_GPT3_ENABLE = | 208 | *(vu_long *)MPC5XXX_GPT3_ENABLE = |
193 | *(vu_long *)MPC5XXX_GPT4_ENABLE = | 209 | *(vu_long *)MPC5XXX_GPT4_ENABLE = |
194 | *(vu_long *)MPC5XXX_GPT5_ENABLE = 0x34; | 210 | *(vu_long *)MPC5XXX_GPT5_ENABLE = 0x34; |
195 | 211 | ||
196 | /* Configure GPT7 as PWM timer, 1kHz, no ints. */ | 212 | /* Configure GPT7 as PWM timer, 1kHz, no ints. */ |
197 | *(vu_long *)MPC5XXX_GPT7_ENABLE = 0;/* Disable */ | 213 | *(vu_long *)MPC5XXX_GPT7_ENABLE = 0;/* Disable */ |
198 | *(vu_long *)MPC5XXX_GPT7_COUNTER = 0x020000fe; | 214 | *(vu_long *)MPC5XXX_GPT7_COUNTER = 0x020000fe; |
199 | *(vu_long *)MPC5XXX_GPT7_PWMCFG = (br << 16); | 215 | *(vu_long *)MPC5XXX_GPT7_PWMCFG = (br << 16); |
200 | *(vu_long *)MPC5XXX_GPT7_ENABLE = 0x3;/* Enable PWM mode and start */ | 216 | *(vu_long *)MPC5XXX_GPT7_ENABLE = 0x3;/* Enable PWM mode and start */ |
201 | 217 | ||
202 | /* Configure PSC3_6,7 as GPIO output */ | 218 | /* Configure PSC3_6,7 as GPIO output */ |
203 | *(vu_long *)MPC5XXX_GPIO_ENABLE |= 0x00003000; | 219 | *(vu_long *)MPC5XXX_GPIO_ENABLE |= 0x00003000; |
204 | *(vu_long *)MPC5XXX_GPIO_DIR |= 0x00003000; | 220 | *(vu_long *)MPC5XXX_GPIO_DIR |= 0x00003000; |
205 | 221 | ||
206 | /* Configure PSC3_8 as GPIO output, no interrupt */ | 222 | /* Configure PSC3_8 as GPIO output, no interrupt */ |
207 | *(vu_long *)MPC5XXX_GPIO_SI_ENABLE |= 0x04000000; | 223 | *(vu_long *)MPC5XXX_GPIO_SI_ENABLE |= 0x04000000; |
208 | *(vu_long *)MPC5XXX_GPIO_SI_DIR |= 0x04000000; | 224 | *(vu_long *)MPC5XXX_GPIO_SI_DIR |= 0x04000000; |
209 | *(vu_long *)MPC5XXX_GPIO_SI_IEN &= ~0x04000000; | 225 | *(vu_long *)MPC5XXX_GPIO_SI_IEN &= ~0x04000000; |
210 | 226 | ||
211 | /* Configure PSC3_9 and GPIO_WKUP6,7 as GPIO output */ | 227 | /* Configure PSC3_9 and GPIO_WKUP6,7 as GPIO output */ |
212 | *(vu_long *)MPC5XXX_WU_GPIO_ENABLE |= 0xc4000000; | 228 | *(vu_long *)MPC5XXX_WU_GPIO_ENABLE |= 0xc4000000; |
213 | *(vu_long *)MPC5XXX_WU_GPIO_DIR |= 0xc4000000; | 229 | *(vu_long *)MPC5XXX_WU_GPIO_DIR |= 0xc4000000; |
214 | 230 | ||
215 | /* Set LR mirror bit because it is low-active */ | 231 | /* Set LR mirror bit because it is low-active */ |
216 | *(vu_long *) MPC5XXX_WU_GPIO_DATA_O |= GPIO_WKUP_7; | 232 | *(vu_long *) MPC5XXX_WU_GPIO_DATA_O |= GPIO_WKUP_7; |
217 | /* | 233 | /* |
218 | * Reset Coral-P graphics controller | 234 | * Reset Coral-P graphics controller |
219 | */ | 235 | */ |
220 | *(vu_long *) MPC5XXX_WU_GPIO_ENABLE |= GPIO_PSC3_9; | 236 | *(vu_long *) MPC5XXX_WU_GPIO_ENABLE |= GPIO_PSC3_9; |
221 | *(vu_long *) MPC5XXX_WU_GPIO_DIR |= GPIO_PSC3_9; | 237 | *(vu_long *) MPC5XXX_WU_GPIO_DIR |= GPIO_PSC3_9; |
222 | *(vu_long *) MPC5XXX_WU_GPIO_DATA_O |= GPIO_PSC3_9; | 238 | *(vu_long *) MPC5XXX_WU_GPIO_DATA_O |= GPIO_PSC3_9; |
223 | return 0; | 239 | return 0; |
224 | } | 240 | } |
225 | 241 | ||
226 | #ifdef CONFIG_PCI | 242 | #ifdef CONFIG_PCI |
227 | static struct pci_controller hose; | 243 | static struct pci_controller hose; |
228 | 244 | ||
229 | extern void pci_mpc5xxx_init(struct pci_controller *); | 245 | extern void pci_mpc5xxx_init(struct pci_controller *); |
230 | 246 | ||
231 | void pci_init_board(void) | 247 | void pci_init_board(void) |
232 | { | 248 | { |
233 | pci_mpc5xxx_init(&hose); | 249 | pci_mpc5xxx_init(&hose); |
234 | } | 250 | } |
235 | #endif | 251 | #endif |
236 | 252 | ||
237 | #if defined(CONFIG_CMD_IDE) && defined(CONFIG_IDE_RESET) | 253 | #if defined(CONFIG_CMD_IDE) && defined(CONFIG_IDE_RESET) |
238 | 254 | ||
239 | void init_ide_reset (void) | 255 | void init_ide_reset (void) |
240 | { | 256 | { |
241 | debug ("init_ide_reset\n"); | 257 | debug ("init_ide_reset\n"); |
242 | 258 | ||
243 | /* Configure PSC1_4 as GPIO output for ATA reset */ | 259 | /* Configure PSC1_4 as GPIO output for ATA reset */ |
244 | *(vu_long *) MPC5XXX_WU_GPIO_ENABLE |= GPIO_PSC1_4; | 260 | *(vu_long *) MPC5XXX_WU_GPIO_ENABLE |= GPIO_PSC1_4; |
245 | *(vu_long *) MPC5XXX_WU_GPIO_DIR |= GPIO_PSC1_4; | 261 | *(vu_long *) MPC5XXX_WU_GPIO_DIR |= GPIO_PSC1_4; |
246 | /* Deassert reset */ | 262 | /* Deassert reset */ |
247 | *(vu_long *) MPC5XXX_WU_GPIO_DATA_O |= GPIO_PSC1_4; | 263 | *(vu_long *) MPC5XXX_WU_GPIO_DATA_O |= GPIO_PSC1_4; |
248 | } | 264 | } |
249 | 265 | ||
250 | void ide_set_reset (int idereset) | 266 | void ide_set_reset (int idereset) |
251 | { | 267 | { |
252 | debug ("ide_reset(%d)\n", idereset); | 268 | debug ("ide_reset(%d)\n", idereset); |
253 | 269 | ||
254 | if (idereset) { | 270 | if (idereset) { |
255 | *(vu_long *) MPC5XXX_WU_GPIO_DATA_O &= ~GPIO_PSC1_4; | 271 | *(vu_long *) MPC5XXX_WU_GPIO_DATA_O &= ~GPIO_PSC1_4; |
256 | /* Make a delay. MPC5200 spec says 25 usec min */ | 272 | /* Make a delay. MPC5200 spec says 25 usec min */ |
257 | udelay(500000); | 273 | udelay(500000); |
258 | } else { | 274 | } else { |
259 | *(vu_long *) MPC5XXX_WU_GPIO_DATA_O |= GPIO_PSC1_4; | 275 | *(vu_long *) MPC5XXX_WU_GPIO_DATA_O |= GPIO_PSC1_4; |
260 | } | 276 | } |
261 | } | 277 | } |
262 | #endif | 278 | #endif |
263 | 279 |
board/inka4x0/inkadiag.c
File was created | 1 | /* | |
2 | * (C) Copyright 2008, 2009 Andreas Pfefferle, | ||
3 | * DENX Software Engineering, ap@denx.de. | ||
4 | * (C) Copyright 2009 Detlev Zundel, | ||
5 | * DENX Software Engineering, dzu@denx.de. | ||
6 | * | ||
7 | * See file CREDITS for list of people who contributed to this | ||
8 | * project. | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or | ||
11 | * modify it under the terms of the GNU General Public License as | ||
12 | * published by the Free Software Foundation; either version 2 of | ||
13 | * the License, or (at your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with this program; if not, write to the Free Software | ||
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | ||
23 | * MA 02111-1307 USA | ||
24 | */ | ||
25 | |||
26 | #include <asm/io.h> | ||
27 | #include <common.h> | ||
28 | #include <config.h> | ||
29 | #include <mpc5xxx.h> | ||
30 | #include <pci.h> | ||
31 | |||
32 | #include <command.h> | ||
33 | |||
34 | /* This is needed for the includes in ns16550.h */ | ||
35 | #define CONFIG_SYS_NS16550_REG_SIZE 1 | ||
36 | #include <ns16550.h> | ||
37 | |||
38 | #define GPIO_BASE ((u_char *)CONFIG_SYS_CS3_START) | ||
39 | |||
40 | #define DIGIN_TOUCHSCR_MASK 0x00003000 /* Inputs 12-13 */ | ||
41 | #define DIGIN_KEYB_MASK 0x00010000 /* Input 16 */ | ||
42 | |||
43 | #define DIGIN_DRAWER_SW1 0x00400000 /* Input 22 */ | ||
44 | #define DIGIN_DRAWER_SW2 0x00800000 /* Input 23 */ | ||
45 | |||
46 | #define DIGIO_LED0 0x00000001 /* Output 0 */ | ||
47 | #define DIGIO_LED1 0x00000002 /* Output 1 */ | ||
48 | #define DIGIO_LED2 0x00000004 /* Output 2 */ | ||
49 | #define DIGIO_LED3 0x00000008 /* Output 3 */ | ||
50 | #define DIGIO_LED4 0x00000010 /* Output 4 */ | ||
51 | #define DIGIO_LED5 0x00000020 /* Output 5 */ | ||
52 | |||
53 | #define DIGIO_DRAWER1 0x00000100 /* Output 8 */ | ||
54 | #define DIGIO_DRAWER2 0x00000200 /* Output 9 */ | ||
55 | |||
56 | #define SERIAL_PORT_BASE ((u_char *)CONFIG_SYS_CS2_START) | ||
57 | |||
58 | #define PSC_OP1_RTS 0x01 | ||
59 | #define PSC_OP0_RTS 0x01 | ||
60 | |||
61 | /* | ||
62 | * Table with supported baudrates (defined in inka4x0.h) | ||
63 | */ | ||
64 | static const unsigned long baudrate_table[] = CONFIG_SYS_BAUDRATE_TABLE; | ||
65 | #define N_BAUDRATES (sizeof(baudrate_table) / sizeof(baudrate_table[0])) | ||
66 | |||
67 | static unsigned int inka_digin_get_input(void) | ||
68 | { | ||
69 | return in_8(GPIO_BASE + 0) << 0 | in_8(GPIO_BASE + 1) << 8 | | ||
70 | in_8(GPIO_BASE + 2) << 16 | in_8(GPIO_BASE + 3) << 24; | ||
71 | } | ||
72 | |||
73 | #define LED_HIGH(NUM) \ | ||
74 | do { \ | ||
75 | setbits_be32((unsigned *)MPC5XXX_GPT##NUM##_ENABLE, 0x10); \ | ||
76 | } while (0) | ||
77 | |||
78 | #define LED_LOW(NUM) \ | ||
79 | do { \ | ||
80 | clrbits_be32((unsigned *)MPC5XXX_GPT##NUM##_ENABLE, 0x10); \ | ||
81 | } while (0) | ||
82 | |||
83 | #define CHECK_LED(NUM) \ | ||
84 | do { \ | ||
85 | if (state & (1 << NUM)) { \ | ||
86 | LED_HIGH(NUM); \ | ||
87 | } else { \ | ||
88 | LED_LOW(NUM); \ | ||
89 | } \ | ||
90 | } while (0) | ||
91 | |||
92 | static void inka_digio_set_output(unsigned int state, int which) | ||
93 | { | ||
94 | volatile struct mpc5xxx_gpio *gpio = (struct mpc5xxx_gpio *)MPC5XXX_GPIO; | ||
95 | |||
96 | if (which == 0) { | ||
97 | /* other */ | ||
98 | CHECK_LED(0); | ||
99 | CHECK_LED(1); | ||
100 | CHECK_LED(2); | ||
101 | CHECK_LED(3); | ||
102 | CHECK_LED(4); | ||
103 | CHECK_LED(5); | ||
104 | } else { | ||
105 | if (which == 1) { | ||
106 | /* drawer1 */ | ||
107 | if (state) { | ||
108 | clrbits_be32(&gpio->simple_dvo, 0x1000); | ||
109 | udelay(1); | ||
110 | setbits_be32(&gpio->simple_dvo, 0x1000); | ||
111 | } else { | ||
112 | setbits_be32(&gpio->simple_dvo, 0x1000); | ||
113 | udelay(1); | ||
114 | clrbits_be32(&gpio->simple_dvo, 0x1000); | ||
115 | } | ||
116 | } | ||
117 | if (which == 2) { | ||
118 | /* drawer 2 */ | ||
119 | if (state) { | ||
120 | clrbits_be32(&gpio->simple_dvo, 0x2000); | ||
121 | udelay(1); | ||
122 | setbits_be32(&gpio->simple_dvo, 0x2000); | ||
123 | } else { | ||
124 | setbits_be32(&gpio->simple_dvo, 0x2000); | ||
125 | udelay(1); | ||
126 | clrbits_be32(&gpio->simple_dvo, 0x2000); | ||
127 | } | ||
128 | } | ||
129 | } | ||
130 | udelay(1); | ||
131 | } | ||
132 | |||
133 | static int do_inkadiag_io(cmd_tbl_t *cmdtp, int flag, int argc, | ||
134 | char *argv[]) { | ||
135 | unsigned int state, val; | ||
136 | |||
137 | switch (argc) { | ||
138 | case 3: | ||
139 | /* Write a value */ | ||
140 | val = simple_strtol(argv[2], NULL, 16); | ||
141 | |||
142 | if (strcmp(argv[1], "drawer1") == 0) { | ||
143 | inka_digio_set_output(val, 1); | ||
144 | } else if (strcmp(argv[1], "drawer2") == 0) { | ||
145 | inka_digio_set_output(val, 2); | ||
146 | } else if (strcmp(argv[1], "other") == 0) | ||
147 | inka_digio_set_output(val, 0); | ||
148 | else { | ||
149 | printf("Invalid argument: %s\n", argv[1]); | ||
150 | return -1; | ||
151 | } | ||
152 | /* fall through */ | ||
153 | case 2: | ||
154 | /* Read a value */ | ||
155 | state = inka_digin_get_input(); | ||
156 | |||
157 | if (strcmp(argv[1], "drawer1") == 0) { | ||
158 | val = (state & DIGIN_DRAWER_SW1) >> (ffs(DIGIN_DRAWER_SW1) - 1); | ||
159 | } else if (strcmp(argv[1], "drawer2") == 0) { | ||
160 | val = (state & DIGIN_DRAWER_SW2) >> (ffs(DIGIN_DRAWER_SW2) - 1); | ||
161 | } else if (strcmp(argv[1], "other") == 0) { | ||
162 | val = ((state & DIGIN_KEYB_MASK) >> (ffs(DIGIN_KEYB_MASK) - 1)) | ||
163 | | (state & DIGIN_TOUCHSCR_MASK) >> (ffs(DIGIN_TOUCHSCR_MASK) - 2); | ||
164 | } else { | ||
165 | printf("Invalid argument: %s\n", argv[1]); | ||
166 | return -1; | ||
167 | } | ||
168 | printf("exit code: 0x%X\n", val); | ||
169 | return 0; | ||
170 | default: | ||
171 | cmd_usage(cmdtp); | ||
172 | break; | ||
173 | } | ||
174 | |||
175 | return -1; | ||
176 | } | ||
177 | |||
178 | DECLARE_GLOBAL_DATA_PTR; | ||
179 | |||
180 | static int ser_init(volatile struct mpc5xxx_psc *psc, int baudrate) | ||
181 | { | ||
182 | unsigned long baseclk; | ||
183 | int div; | ||
184 | |||
185 | /* reset PSC */ | ||
186 | out_8(&psc->command, PSC_SEL_MODE_REG_1); | ||
187 | |||
188 | /* select clock sources */ | ||
189 | |||
190 | out_be16(&psc->psc_clock_select, 0); | ||
191 | baseclk = (gd->ipb_clk + 16) / 32; | ||
192 | |||
193 | /* switch to UART mode */ | ||
194 | out_be32(&psc->sicr, 0); | ||
195 | |||
196 | /* configure parity, bit length and so on */ | ||
197 | |||
198 | out_8(&psc->mode, PSC_MODE_8_BITS | PSC_MODE_PARNONE); | ||
199 | out_8(&psc->mode, PSC_MODE_ONE_STOP); | ||
200 | |||
201 | /* set up UART divisor */ | ||
202 | div = (baseclk + (baudrate / 2)) / baudrate; | ||
203 | out_8(&psc->ctur, (div >> 8) & 0xff); | ||
204 | out_8(&psc->ctlr, div & 0xff); | ||
205 | |||
206 | /* disable all interrupts */ | ||
207 | out_be16(&psc->psc_imr, 0); | ||
208 | |||
209 | /* reset and enable Rx/Tx */ | ||
210 | out_8(&psc->command, PSC_RST_RX); | ||
211 | out_8(&psc->command, PSC_RST_TX); | ||
212 | out_8(&psc->command, PSC_RX_ENABLE | PSC_TX_ENABLE); | ||
213 | |||
214 | return 0; | ||
215 | } | ||
216 | |||
217 | static void ser_putc(volatile struct mpc5xxx_psc *psc, const char c) | ||
218 | { | ||
219 | /* Wait 1 second for last character to go. */ | ||
220 | int i = 0; | ||
221 | |||
222 | while (!(psc->psc_status & PSC_SR_TXEMP) && (i++ < 1000000/10)) | ||
223 | udelay(10); | ||
224 | psc->psc_buffer_8 = c; | ||
225 | |||
226 | } | ||
227 | |||
228 | static int ser_getc(volatile struct mpc5xxx_psc *psc) | ||
229 | { | ||
230 | /* Wait for a character to arrive. */ | ||
231 | int i = 0; | ||
232 | |||
233 | while (!(in_be16(&psc->psc_status) & PSC_SR_RXRDY) && (i++ < 1000000/10)) | ||
234 | udelay(10); | ||
235 | |||
236 | return in_8(&psc->psc_buffer_8); | ||
237 | } | ||
238 | |||
239 | static int do_inkadiag_serial(cmd_tbl_t *cmdtp, int flag, int argc, | ||
240 | char *argv[]) { | ||
241 | volatile struct NS16550 *uart; | ||
242 | volatile struct mpc5xxx_psc *psc; | ||
243 | unsigned int num, mode; | ||
244 | int combrd, baudrate, i, j, len; | ||
245 | int address; | ||
246 | |||
247 | if (argc < 5) { | ||
248 | cmd_usage(cmdtp); | ||
249 | return 1; | ||
250 | } | ||
251 | |||
252 | argc--; | ||
253 | argv++; | ||
254 | |||
255 | num = simple_strtol(argv[0], NULL, 0); | ||
256 | if (num < 0 || num > 11) { | ||
257 | printf("invalid argument for num: %d\n", num); | ||
258 | return -1; | ||
259 | } | ||
260 | |||
261 | mode = simple_strtol(argv[1], NULL, 0); | ||
262 | |||
263 | combrd = 0; | ||
264 | baudrate = simple_strtoul(argv[2], NULL, 10); | ||
265 | for (i=0; i<N_BAUDRATES; ++i) { | ||
266 | if (baudrate == baudrate_table[i]) | ||
267 | break; | ||
268 | } | ||
269 | if (i == N_BAUDRATES) { | ||
270 | printf("## Baudrate %d bps not supported\n", | ||
271 | baudrate); | ||
272 | return 1; | ||
273 | } | ||
274 | combrd = 115200 / baudrate; | ||
275 | |||
276 | uart = (struct NS16550 *)(SERIAL_PORT_BASE + (num << 3)); | ||
277 | |||
278 | printf("Testing uart %d.\n\n", num); | ||
279 | |||
280 | if ((num >= 0) && (num <= 7)) { | ||
281 | if (mode & 1) { | ||
282 | /* turn on 'loopback' mode */ | ||
283 | out_8(&uart->mcr, MCR_LOOP); | ||
284 | } else { | ||
285 | /* | ||
286 | * establish the UART's operational parameters | ||
287 | * set DLAB=1, so rbr accesses DLL | ||
288 | */ | ||
289 | out_8(&uart->lcr, LCR_DLAB); | ||
290 | /* set baudrate */ | ||
291 | out_8(&uart->rbr, combrd); | ||
292 | /* set data-format: 8-N-1 */ | ||
293 | out_8(&uart->lcr, LCR_WLS_8); | ||
294 | } | ||
295 | |||
296 | if (mode & 2) { | ||
297 | /* set request to send */ | ||
298 | out_8(&uart->mcr, MCR_RTS); | ||
299 | udelay(10); | ||
300 | /* check clear to send */ | ||
301 | if ((in_8(&uart->msr) & MSR_CTS) == 0x00) | ||
302 | return -1; | ||
303 | } | ||
304 | if (mode & 4) { | ||
305 | /* set data terminal ready */ | ||
306 | out_8(&uart->mcr, MCR_DTR); | ||
307 | udelay(10); | ||
308 | /* check data set ready and carrier detect */ | ||
309 | if ((in_8(&uart->msr) & (MSR_DSR | MSR_DCD)) | ||
310 | != (MSR_DSR | MSR_DCD)) | ||
311 | return -1; | ||
312 | } | ||
313 | |||
314 | /* write each message-character, read it back, and display it */ | ||
315 | for (i = 0, len = strlen(argv[3]); i < len; ++i) { | ||
316 | j = 0; | ||
317 | while ((in_8(&uart->lsr) & LSR_THRE) == 0x00) { | ||
318 | if (j++ > CONFIG_SYS_HZ) | ||
319 | break; | ||
320 | udelay(10); | ||
321 | } | ||
322 | out_8(&uart->rbr, argv[3][i]); | ||
323 | j = 0; | ||
324 | while ((in_8(&uart->lsr) & LSR_DR) == 0x00) { | ||
325 | if (j++ > CONFIG_SYS_HZ) | ||
326 | break; | ||
327 | udelay(10); | ||
328 | } | ||
329 | printf("%c", in_8(&uart->rbr)); | ||
330 | } | ||
331 | printf("\n\n"); | ||
332 | out_8(&uart->mcr, 0x00); | ||
333 | } else { | ||
334 | address = 0; | ||
335 | |||
336 | switch (num) { | ||
337 | case 8: | ||
338 | address = MPC5XXX_PSC6; | ||
339 | break; | ||
340 | case 9: | ||
341 | address = MPC5XXX_PSC3; | ||
342 | break; | ||
343 | case 10: | ||
344 | address = MPC5XXX_PSC2; | ||
345 | break; | ||
346 | case 11: | ||
347 | address = MPC5XXX_PSC1; | ||
348 | break; | ||
349 | } | ||
350 | psc = (struct mpc5xxx_psc *)address; | ||
351 | ser_init(psc, simple_strtol(argv[2], NULL, 0)); | ||
352 | if (mode & 2) { | ||
353 | /* set request to send */ | ||
354 | out_8(&psc->op0, PSC_OP0_RTS); | ||
355 | udelay(10); | ||
356 | /* check clear to send */ | ||
357 | if ((in_8(&psc->ip) & PSC_IPCR_CTS) == 0) | ||
358 | return -1; | ||
359 | } | ||
360 | len = strlen(argv[3]); | ||
361 | for (i = 0; i < len; ++i) { | ||
362 | ser_putc(psc, argv[3][i]); | ||
363 | printf("%c", ser_getc(psc)); | ||
364 | } | ||
365 | printf("\n\n"); | ||
366 | } | ||
367 | return 0; | ||
368 | } | ||
369 | |||
370 | #define BUZZER_GPT (MPC5XXX_GPT + 0x60) /* GPT6 */ | ||
371 | static void buzzer_turn_on(unsigned int freq) | ||
372 | { | ||
373 | volatile struct mpc5xxx_gpt *gpt = (struct mpc5xxx_gpt *)(BUZZER_GPT); | ||
374 | |||
375 | const u32 prescale = gd->ipb_clk / freq / 128; | ||
376 | const u32 count = 128; | ||
377 | const u32 width = 64; | ||
378 | |||
379 | gpt->cir = (prescale << 16) | count; | ||
380 | gpt->pwmcr = width << 16; | ||
381 | gpt->emsr = 3; /* Timer enabled for PWM */ | ||
382 | } | ||
383 | |||
384 | static void buzzer_turn_off(void) | ||
385 | { | ||
386 | volatile struct mpc5xxx_gpt *gpt = (struct mpc5xxx_gpt *)(BUZZER_GPT); | ||
387 | |||
388 | gpt->emsr = 0; | ||
389 | } | ||
390 | |||
391 | static int do_inkadiag_buzzer(cmd_tbl_t *cmdtp, int flag, int argc, | ||
392 | char *argv[]) { | ||
393 | |||
394 | unsigned int period, freq; | ||
395 | int prev, i; | ||
396 | |||
397 | if (argc != 3) { | ||
398 | cmd_usage(cmdtp); | ||
399 | return 1; | ||
400 | } | ||
401 | |||
402 | argc--; | ||
403 | argv++; | ||
404 | |||
405 | period = simple_strtol(argv[0], NULL, 0); | ||
406 | if (!period) | ||
407 | printf("Zero period is senseless\n"); | ||
408 | argc--; | ||
409 | argv++; | ||
410 | |||
411 | freq = simple_strtol(argv[0], NULL, 0); | ||
412 | /* avoid zero prescale in buzzer_turn_on() */ | ||
413 | if (freq > gd->ipb_clk / 128) { | ||
414 | printf("%dHz exceeds maximum (%ldHz)\n", freq, | ||
415 | gd->ipb_clk / 128); | ||
416 | } else if (!freq) | ||
417 | printf("Zero frequency is senseless\n"); | ||
418 | else | ||
419 | buzzer_turn_on(freq); | ||
420 | |||
421 | clear_ctrlc(); | ||
422 | prev = disable_ctrlc(0); | ||
423 | |||
424 | printf("Buzzing for %d ms. Type ^C to abort!\n\n", period); | ||
425 | |||
426 | i = 0; | ||
427 | while (!ctrlc() && (i++ < CONFIG_SYS_HZ)) | ||
428 | udelay(period); | ||
429 | |||
430 | clear_ctrlc(); | ||
431 | disable_ctrlc(prev); | ||
432 | |||
433 | buzzer_turn_off(); | ||
434 | |||
435 | return 0; | ||
436 | } | ||
437 | |||
438 | static int do_inkadiag_help(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); | ||
439 | |||
440 | cmd_tbl_t cmd_inkadiag_sub[] = { | ||
441 | U_BOOT_CMD_MKENT(io, 1, 1, do_inkadiag_io, "read digital input", | ||
442 | "<drawer1|drawer2|other> [value] - get or set specified signal\n"), | ||
443 | U_BOOT_CMD_MKENT(serial, 4, 1, do_inkadiag_serial, "test serial port", | ||
444 | "<num> <mode> <baudrate> <msg> - test uart num [0..11] in mode\n" | ||
445 | "and baudrate with msg\n"), | ||
446 | U_BOOT_CMD_MKENT(buzzer, 2, 1, do_inkadiag_buzzer, "activate buzzer", | ||
447 | "<period> <freq> - turn buzzer on for period ms with freq hz\n"), | ||
448 | U_BOOT_CMD_MKENT(help, 4, 1, do_inkadiag_help, "get help", | ||
449 | "[command] - get help for command\n"), | ||
450 | }; | ||
451 | |||
452 | static int do_inkadiag_help(cmd_tbl_t *cmdtp, int flag, | ||
453 | int argc, char *argv[]) { | ||
454 | extern int _do_help (cmd_tbl_t *cmd_start, int cmd_items, | ||
455 | cmd_tbl_t *cmdtp, int flag, | ||
456 | int argc, char *argv[]); | ||
457 | /* do_help prints command name - we prepend inkadiag to our subcommands! */ | ||
458 | #ifdef CONFIG_SYS_LONGHELP | ||
459 | puts ("inkadiag "); | ||
460 | #endif | ||
461 | return _do_help(&cmd_inkadiag_sub[0], | ||
462 | ARRAY_SIZE(cmd_inkadiag_sub), cmdtp, flag, argc, argv); | ||
463 | } | ||
464 | |||
465 | static int do_inkadiag(cmd_tbl_t *cmdtp, int flag, int argc, | ||
466 | char *argv[]) { | ||
467 | cmd_tbl_t *c; | ||
468 | |||
469 | c = find_cmd_tbl(argv[1], &cmd_inkadiag_sub[0], ARRAY_SIZE(cmd_inkadiag_sub)); | ||
470 | |||
471 | if (c) { | ||
472 | argc--; | ||
473 | argv++; | ||
474 | return c->cmd(c, flag, argc, argv); | ||
475 | } else { | ||
476 | /* Unrecognized command */ | ||
477 | cmd_usage(cmdtp); | ||
478 | return 1; | ||
479 | } | ||
480 | } | ||
481 | |||
482 | U_BOOT_CMD(inkadiag, 6, 1, do_inkadiag, | ||
483 | "inkadiag - inka diagnosis\n", | ||
484 | "[inkadiag what ...]\n" | ||
485 | " - perform a diagnosis on inka hardware\n" | ||
486 | "'inkadiag' performs hardware tests.\n\n"); | ||
487 | |||
488 | /* Relocate the command table function pointers when running in RAM */ | ||
489 | int inkadiag_init_r (void) { | ||
490 | cmd_tbl_t *cmdtp; | ||
491 | |||
492 | for (cmdtp = &cmd_inkadiag_sub[0]; cmdtp != | ||
493 | &cmd_inkadiag_sub[ARRAY_SIZE(cmd_inkadiag_sub)]; cmdtp++) { | ||
494 | ulong addr; | ||
495 | |||
496 | addr = (ulong) (cmdtp->cmd) + gd->reloc_off; | ||
497 | cmdtp->cmd = (int (*)(struct cmd_tbl_s *, int, int, char *[]))addr; | ||
498 | |||
499 | addr = (ulong)(cmdtp->name) + gd->reloc_off; | ||
500 | cmdtp->name = (char *)addr; | ||
501 | |||
502 | if (cmdtp->usage) { | ||
503 | addr = (ulong)(cmdtp->usage) + gd->reloc_off; | ||
504 | cmdtp->usage = (char *)addr; | ||
505 | } | ||
506 | #ifdef CONFIG_SYS_LONGHELP | ||
507 | if (cmdtp->help) { | ||
508 | addr = (ulong)(cmdtp->help) + gd->reloc_off; | ||
509 | cmdtp->help = (char *)addr; | ||
510 | } | ||
511 | #endif | ||
512 | } | ||
513 | return 0; | ||
514 | } | ||
515 |
include/configs/inka4x0.h
1 | /* | 1 | /* |
2 | * (C) Copyright 2003-2005 | 2 | * (C) Copyright 2003-2005 |
3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. | 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
4 | * | 4 | * |
5 | * See file CREDITS for list of people who contributed to this | 5 | * See file CREDITS for list of people who contributed to this |
6 | * project. | 6 | * project. |
7 | * | 7 | * |
8 | * This program is free software; you can redistribute it and/or | 8 | * This program is free software; you can redistribute it and/or |
9 | * modify it under the terms of the GNU General Public License as | 9 | * modify it under the terms of the GNU General Public License as |
10 | * published by the Free Software Foundation; either version 2 of | 10 | * published by the Free Software Foundation; either version 2 of |
11 | * the License, or (at your option) any later version. | 11 | * the License, or (at your option) any later version. |
12 | * | 12 | * |
13 | * This program is distributed in the hope that it will be useful, | 13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. | 16 | * GNU General Public License for more details. |
17 | * | 17 | * |
18 | * You should have received a copy of the GNU General Public License | 18 | * You should have received a copy of the GNU General Public License |
19 | * along with this program; if not, write to the Free Software | 19 | * along with this program; if not, write to the Free Software |
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
21 | * MA 02111-1307 USA | 21 | * MA 02111-1307 USA |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #ifndef __CONFIG_H | 24 | #ifndef __CONFIG_H |
25 | #define __CONFIG_H | 25 | #define __CONFIG_H |
26 | 26 | ||
27 | /* | 27 | /* |
28 | * High Level Configuration Options | 28 | * High Level Configuration Options |
29 | * (easy to change) | 29 | * (easy to change) |
30 | */ | 30 | */ |
31 | 31 | ||
32 | #define CONFIG_MPC5xxx 1 /* This is an MPC5xxx CPU */ | 32 | #define CONFIG_MPC5xxx 1 /* This is an MPC5xxx CPU */ |
33 | #define CONFIG_MPC5200 1 /* (more precisely an MPC5200 CPU) */ | 33 | #define CONFIG_MPC5200 1 /* (more precisely an MPC5200 CPU) */ |
34 | #define CONFIG_INKA4X0 1 /* INKA4x0 board */ | 34 | #define CONFIG_INKA4X0 1 /* INKA4x0 board */ |
35 | 35 | ||
36 | #define CONFIG_SYS_MPC5XXX_CLKIN 33000000 /* ... running at 33.000000MHz */ | 36 | #define CONFIG_SYS_MPC5XXX_CLKIN 33000000 /* ... running at 33.000000MHz */ |
37 | 37 | ||
38 | #define BOOTFLAG_COLD 0x01 /* Normal Power-On: Boot from FLASH */ | 38 | #define BOOTFLAG_COLD 0x01 /* Normal Power-On: Boot from FLASH */ |
39 | #define BOOTFLAG_WARM 0x02 /* Software reboot */ | 39 | #define BOOTFLAG_WARM 0x02 /* Software reboot */ |
40 | 40 | ||
41 | #define CONFIG_MISC_INIT_F 1 /* Use misc_init_f() */ | 41 | #define CONFIG_MISC_INIT_F 1 /* Use misc_init_f() */ |
42 | #define CONFIG_MISC_INIT_R 1 /* Use misc_init_r() */ | ||
42 | 43 | ||
43 | #define CONFIG_HIGH_BATS 1 /* High BATs supported */ | 44 | #define CONFIG_HIGH_BATS 1 /* High BATs supported */ |
44 | 45 | ||
45 | /* | 46 | /* |
46 | * Serial console configuration | 47 | * Serial console configuration |
47 | */ | 48 | */ |
48 | #define CONFIG_PSC_CONSOLE 1 /* console is on PSC1 */ | 49 | #define CONFIG_PSC_CONSOLE 1 /* console is on PSC1 */ |
49 | #define CONFIG_BAUDRATE 115200 /* ... at 115200 bps */ | 50 | #define CONFIG_BAUDRATE 115200 /* ... at 115200 bps */ |
50 | #define CONFIG_SYS_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200, 230400 } | 51 | #define CONFIG_SYS_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200, 230400 } |
51 | 52 | ||
52 | /* | 53 | /* |
53 | * PCI Mapping: | 54 | * PCI Mapping: |
54 | * 0x40000000 - 0x4fffffff - PCI Memory | 55 | * 0x40000000 - 0x4fffffff - PCI Memory |
55 | * 0x50000000 - 0x50ffffff - PCI IO Space | 56 | * 0x50000000 - 0x50ffffff - PCI IO Space |
56 | */ | 57 | */ |
57 | #define CONFIG_PCI 1 | 58 | #define CONFIG_PCI 1 |
58 | #define CONFIG_PCI_PNP 1 | 59 | #define CONFIG_PCI_PNP 1 |
59 | #define CONFIG_PCI_SCAN_SHOW 1 | 60 | #define CONFIG_PCI_SCAN_SHOW 1 |
60 | #define CONFIG_PCIAUTO_SKIP_HOST_BRIDGE 1 | 61 | #define CONFIG_PCIAUTO_SKIP_HOST_BRIDGE 1 |
61 | 62 | ||
62 | #define CONFIG_PCI_MEM_BUS 0x40000000 | 63 | #define CONFIG_PCI_MEM_BUS 0x40000000 |
63 | #define CONFIG_PCI_MEM_PHYS CONFIG_PCI_MEM_BUS | 64 | #define CONFIG_PCI_MEM_PHYS CONFIG_PCI_MEM_BUS |
64 | #define CONFIG_PCI_MEM_SIZE 0x10000000 | 65 | #define CONFIG_PCI_MEM_SIZE 0x10000000 |
65 | 66 | ||
66 | #define CONFIG_PCI_IO_BUS 0x50000000 | 67 | #define CONFIG_PCI_IO_BUS 0x50000000 |
67 | #define CONFIG_PCI_IO_PHYS CONFIG_PCI_IO_BUS | 68 | #define CONFIG_PCI_IO_PHYS CONFIG_PCI_IO_BUS |
68 | #define CONFIG_PCI_IO_SIZE 0x01000000 | 69 | #define CONFIG_PCI_IO_SIZE 0x01000000 |
69 | 70 | ||
70 | #define CONFIG_SYS_XLB_PIPELINING 1 | 71 | #define CONFIG_SYS_XLB_PIPELINING 1 |
71 | 72 | ||
72 | /* Partitions */ | 73 | /* Partitions */ |
73 | #define CONFIG_MAC_PARTITION | 74 | #define CONFIG_MAC_PARTITION |
74 | #define CONFIG_DOS_PARTITION | 75 | #define CONFIG_DOS_PARTITION |
75 | #define CONFIG_ISO_PARTITION | 76 | #define CONFIG_ISO_PARTITION |
76 | 77 | ||
77 | 78 | ||
78 | /* | 79 | /* |
79 | * BOOTP options | 80 | * BOOTP options |
80 | */ | 81 | */ |
81 | #define CONFIG_BOOTP_BOOTFILESIZE | 82 | #define CONFIG_BOOTP_BOOTFILESIZE |
82 | #define CONFIG_BOOTP_BOOTPATH | 83 | #define CONFIG_BOOTP_BOOTPATH |
83 | #define CONFIG_BOOTP_GATEWAY | 84 | #define CONFIG_BOOTP_GATEWAY |
84 | #define CONFIG_BOOTP_HOSTNAME | 85 | #define CONFIG_BOOTP_HOSTNAME |
85 | 86 | ||
86 | 87 | ||
87 | /* | 88 | /* |
88 | * Command line configuration. | 89 | * Command line configuration. |
89 | */ | 90 | */ |
90 | #include <config_cmd_default.h> | 91 | #include <config_cmd_default.h> |
91 | 92 | ||
92 | #define CONFIG_CMD_DHCP | 93 | #define CONFIG_CMD_DHCP |
93 | #define CONFIG_CMD_EXT2 | 94 | #define CONFIG_CMD_EXT2 |
94 | #define CONFIG_CMD_FAT | 95 | #define CONFIG_CMD_FAT |
95 | #define CONFIG_CMD_IDE | 96 | #define CONFIG_CMD_IDE |
96 | #define CONFIG_CMD_NFS | 97 | #define CONFIG_CMD_NFS |
97 | #define CONFIG_CMD_PCI | 98 | #define CONFIG_CMD_PCI |
98 | #define CONFIG_CMD_SNTP | 99 | #define CONFIG_CMD_SNTP |
99 | #define CONFIG_CMD_USB | 100 | #define CONFIG_CMD_USB |
100 | 101 | ||
101 | 102 | ||
102 | #define CONFIG_TIMESTAMP 1 /* Print image info with timestamp */ | 103 | #define CONFIG_TIMESTAMP 1 /* Print image info with timestamp */ |
103 | 104 | ||
104 | #if (TEXT_BASE == 0xFFE00000) /* Boot low */ | 105 | #if (TEXT_BASE == 0xFFE00000) /* Boot low */ |
105 | # define CONFIG_SYS_LOWBOOT 1 | 106 | # define CONFIG_SYS_LOWBOOT 1 |
106 | #endif | 107 | #endif |
107 | 108 | ||
108 | /* | 109 | /* |
109 | * Autobooting | 110 | * Autobooting |
110 | */ | 111 | */ |
111 | #define CONFIG_BOOTDELAY 1 /* autoboot after 1 second */ | 112 | #define CONFIG_BOOTDELAY 1 /* autoboot after 1 second */ |
112 | 113 | ||
113 | #define CONFIG_PREBOOT "echo;" \ | 114 | #define CONFIG_PREBOOT "echo;" \ |
114 | "echo Type \\\"run flash_nfs\\\" to mount root filesystem over NFS;" \ | 115 | "echo Type \\\"run flash_nfs\\\" to mount root filesystem over NFS;" \ |
115 | "echo" | 116 | "echo" |
116 | 117 | ||
117 | #undef CONFIG_BOOTARGS | 118 | #undef CONFIG_BOOTARGS |
118 | 119 | ||
119 | #define CONFIG_ETHADDR 00:a0:a4:03:00:00 | 120 | #define CONFIG_ETHADDR 00:a0:a4:03:00:00 |
120 | #define CONFIG_OVERWRITE_ETHADDR_ONCE | 121 | #define CONFIG_OVERWRITE_ETHADDR_ONCE |
121 | 122 | ||
122 | #define CONFIG_IPADDR 192.168.100.2 | 123 | #define CONFIG_IPADDR 192.168.100.2 |
123 | #define CONFIG_SERVERIP 192.168.100.1 | 124 | #define CONFIG_SERVERIP 192.168.100.1 |
124 | #define CONFIG_NETMASK 255.255.255.0 | 125 | #define CONFIG_NETMASK 255.255.255.0 |
125 | #define HOSTNAME inka4x0 | 126 | #define HOSTNAME inka4x0 |
126 | #define CONFIG_BOOTFILE /tftpboot/inka4x0/uImage | 127 | #define CONFIG_BOOTFILE /tftpboot/inka4x0/uImage |
127 | #define CONFIG_ROOTPATH /opt/eldk/ppc_6xx | 128 | #define CONFIG_ROOTPATH /opt/eldk/ppc_6xx |
128 | 129 | ||
129 | #define CONFIG_EXTRA_ENV_SETTINGS \ | 130 | #define CONFIG_EXTRA_ENV_SETTINGS \ |
130 | "netdev=eth0\0" \ | 131 | "netdev=eth0\0" \ |
131 | "nfsargs=setenv bootargs root=/dev/nfs rw " \ | 132 | "nfsargs=setenv bootargs root=/dev/nfs rw " \ |
132 | "nfsroot=${serverip}:${rootpath}\0" \ | 133 | "nfsroot=${serverip}:${rootpath}\0" \ |
133 | "ramargs=setenv bootargs root=/dev/ram rw\0" \ | 134 | "ramargs=setenv bootargs root=/dev/ram rw\0" \ |
134 | "addip=setenv bootargs ${bootargs} " \ | 135 | "addip=setenv bootargs ${bootargs} " \ |
135 | "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}" \ | 136 | "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}" \ |
136 | ":${hostname}:${netdev}:off panic=1\0" \ | 137 | ":${hostname}:${netdev}:off panic=1\0" \ |
137 | "addcons=setenv bootargs ${bootargs} " \ | 138 | "addcons=setenv bootargs ${bootargs} " \ |
138 | "console=ttyS0,${baudrate}\0" \ | 139 | "console=ttyS0,${baudrate}\0" \ |
139 | "flash_nfs=run nfsargs addip addcons;" \ | 140 | "flash_nfs=run nfsargs addip addcons;" \ |
140 | "bootm ${kernel_addr}\0" \ | 141 | "bootm ${kernel_addr}\0" \ |
141 | "net_nfs=tftp 200000 ${bootfile};" \ | 142 | "net_nfs=tftp 200000 ${bootfile};" \ |
142 | "run nfsargs addip addcons;bootm\0" \ | 143 | "run nfsargs addip addcons;bootm\0" \ |
143 | "enable_disp=mw.l 100000 04000000 1;" \ | 144 | "enable_disp=mw.l 100000 04000000 1;" \ |
144 | "cp.l 100000 f0000b20 1;" \ | 145 | "cp.l 100000 f0000b20 1;" \ |
145 | "cp.l 100000 f0000b28 1\0" \ | 146 | "cp.l 100000 f0000b28 1\0" \ |
146 | "ideargs=setenv bootargs root=/dev/hda1 rw\0" \ | 147 | "ideargs=setenv bootargs root=/dev/hda1 rw\0" \ |
147 | "ide_boot=ext2load ide 0:1 200000 uImage;" \ | 148 | "ide_boot=ext2load ide 0:1 200000 uImage;" \ |
148 | "run ideargs addip addcons enable_disp;bootm\0" \ | 149 | "run ideargs addip addcons enable_disp;bootm\0" \ |
149 | "brightness=255\0" \ | 150 | "brightness=255\0" \ |
150 | "" | 151 | "" |
151 | 152 | ||
152 | #define CONFIG_BOOTCOMMAND "run ide_boot" | 153 | #define CONFIG_BOOTCOMMAND "run ide_boot" |
153 | 154 | ||
154 | /* | 155 | /* |
155 | * IPB Bus clocking configuration. | 156 | * IPB Bus clocking configuration. |
156 | */ | 157 | */ |
157 | #define CONFIG_SYS_IPBCLK_EQUALS_XLBCLK /* define for 133MHz speed */ | 158 | #define CONFIG_SYS_IPBCLK_EQUALS_XLBCLK /* define for 133MHz speed */ |
158 | 159 | ||
159 | /* | 160 | /* |
160 | * Flash configuration | 161 | * Flash configuration |
161 | */ | 162 | */ |
162 | #define CONFIG_SYS_FLASH_CFI 1 /* Flash is CFI conformant */ | 163 | #define CONFIG_SYS_FLASH_CFI 1 /* Flash is CFI conformant */ |
163 | #define CONFIG_FLASH_CFI_DRIVER 1 | 164 | #define CONFIG_FLASH_CFI_DRIVER 1 |
164 | #define CONFIG_SYS_FLASH_BASE 0xffe00000 | 165 | #define CONFIG_SYS_FLASH_BASE 0xffe00000 |
165 | #define CONFIG_SYS_FLASH_SIZE 0x00200000 | 166 | #define CONFIG_SYS_FLASH_SIZE 0x00200000 |
166 | #define CONFIG_SYS_MAX_FLASH_BANKS 1 /* max num of memory banks */ | 167 | #define CONFIG_SYS_MAX_FLASH_BANKS 1 /* max num of memory banks */ |
167 | #define CONFIG_SYS_FLASH_BANKS_LIST { CONFIG_SYS_FLASH_BASE } | 168 | #define CONFIG_SYS_FLASH_BANKS_LIST { CONFIG_SYS_FLASH_BASE } |
168 | #define CONFIG_SYS_MAX_FLASH_SECT 128 /* max num of sects on one chip */ | 169 | #define CONFIG_SYS_MAX_FLASH_SECT 128 /* max num of sects on one chip */ |
169 | #define CONFIG_SYS_FLASH_USE_BUFFER_WRITE 1 /* use buffered writes (20x faster) */ | 170 | #define CONFIG_SYS_FLASH_USE_BUFFER_WRITE 1 /* use buffered writes (20x faster) */ |
170 | 171 | ||
171 | /* | 172 | /* |
172 | * Environment settings | 173 | * Environment settings |
173 | */ | 174 | */ |
174 | #define CONFIG_ENV_IS_IN_FLASH 1 | 175 | #define CONFIG_ENV_IS_IN_FLASH 1 |
175 | #define CONFIG_ENV_ADDR (CONFIG_SYS_FLASH_BASE + 0x4000) | 176 | #define CONFIG_ENV_ADDR (CONFIG_SYS_FLASH_BASE + 0x4000) |
176 | #define CONFIG_ENV_SIZE 0x2000 | 177 | #define CONFIG_ENV_SIZE 0x2000 |
177 | #define CONFIG_ENV_SECT_SIZE 0x2000 | 178 | #define CONFIG_ENV_SECT_SIZE 0x2000 |
178 | #define CONFIG_ENV_OVERWRITE 1 | 179 | #define CONFIG_ENV_OVERWRITE 1 |
179 | #define CONFIG_SYS_USE_PPCENV /* Environment embedded in sect .ppcenv */ | 180 | #define CONFIG_SYS_USE_PPCENV /* Environment embedded in sect .ppcenv */ |
180 | 181 | ||
181 | /* | 182 | /* |
182 | * Memory map | 183 | * Memory map |
183 | */ | 184 | */ |
184 | #define CONFIG_SYS_MBAR 0xF0000000 | 185 | #define CONFIG_SYS_MBAR 0xF0000000 |
185 | #define CONFIG_SYS_SDRAM_BASE 0x00000000 | 186 | #define CONFIG_SYS_SDRAM_BASE 0x00000000 |
186 | #define CONFIG_SYS_DEFAULT_MBAR 0x80000000 | 187 | #define CONFIG_SYS_DEFAULT_MBAR 0x80000000 |
187 | 188 | ||
188 | /* | 189 | /* |
189 | * SDRAM controller configuration | 190 | * SDRAM controller configuration |
190 | */ | 191 | */ |
191 | #undef CONFIG_SDR_MT48LC16M16A2 | 192 | #undef CONFIG_SDR_MT48LC16M16A2 |
192 | #undef CONFIG_DDR_MT46V16M16 | 193 | #undef CONFIG_DDR_MT46V16M16 |
193 | #undef CONFIG_DDR_MT46V32M16 | 194 | #undef CONFIG_DDR_MT46V32M16 |
194 | #undef CONFIG_DDR_HYB25D512160BF | 195 | #undef CONFIG_DDR_HYB25D512160BF |
195 | #define CONFIG_DDR_K4H511638C | 196 | #define CONFIG_DDR_K4H511638C |
196 | 197 | ||
197 | /* Use ON-Chip SRAM until RAM will be available */ | 198 | /* Use ON-Chip SRAM until RAM will be available */ |
198 | #define CONFIG_SYS_INIT_RAM_ADDR MPC5XXX_SRAM | 199 | #define CONFIG_SYS_INIT_RAM_ADDR MPC5XXX_SRAM |
199 | #ifdef CONFIG_POST | 200 | #ifdef CONFIG_POST |
200 | /* preserve space for the post_word at end of on-chip SRAM */ | 201 | /* preserve space for the post_word at end of on-chip SRAM */ |
201 | #define CONFIG_SYS_INIT_RAM_END MPC5XXX_SRAM_POST_SIZE | 202 | #define CONFIG_SYS_INIT_RAM_END MPC5XXX_SRAM_POST_SIZE |
202 | #else | 203 | #else |
203 | #define CONFIG_SYS_INIT_RAM_END MPC5XXX_SRAM_SIZE | 204 | #define CONFIG_SYS_INIT_RAM_END MPC5XXX_SRAM_SIZE |
204 | #endif | 205 | #endif |
205 | 206 | ||
206 | 207 | ||
207 | #define CONFIG_SYS_GBL_DATA_SIZE 128 /* size in bytes reserved for initial data */ | 208 | #define CONFIG_SYS_GBL_DATA_SIZE 128 /* size in bytes reserved for initial data */ |
208 | #define CONFIG_SYS_GBL_DATA_OFFSET (CONFIG_SYS_INIT_RAM_END - CONFIG_SYS_GBL_DATA_SIZE) | 209 | #define CONFIG_SYS_GBL_DATA_OFFSET (CONFIG_SYS_INIT_RAM_END - CONFIG_SYS_GBL_DATA_SIZE) |
209 | #define CONFIG_SYS_INIT_SP_OFFSET CONFIG_SYS_GBL_DATA_OFFSET | 210 | #define CONFIG_SYS_INIT_SP_OFFSET CONFIG_SYS_GBL_DATA_OFFSET |
210 | 211 | ||
211 | #define CONFIG_SYS_MONITOR_BASE TEXT_BASE | 212 | #define CONFIG_SYS_MONITOR_BASE TEXT_BASE |
212 | #if (CONFIG_SYS_MONITOR_BASE < CONFIG_SYS_FLASH_BASE) | 213 | #if (CONFIG_SYS_MONITOR_BASE < CONFIG_SYS_FLASH_BASE) |
213 | # define CONFIG_SYS_RAMBOOT 1 | 214 | # define CONFIG_SYS_RAMBOOT 1 |
214 | #endif | 215 | #endif |
215 | 216 | ||
216 | #define CONFIG_SYS_MONITOR_LEN (256 << 10) /* Reserve 256 kB for Monitor */ | 217 | #define CONFIG_SYS_MONITOR_LEN (256 << 10) /* Reserve 256 kB for Monitor */ |
217 | #define CONFIG_SYS_MALLOC_LEN (128 << 10) /* Reserve 128 kB for malloc() */ | 218 | #define CONFIG_SYS_MALLOC_LEN (128 << 10) /* Reserve 128 kB for malloc() */ |
218 | #define CONFIG_SYS_BOOTMAPSZ (8 << 20) /* Initial Memory map for Linux */ | 219 | #define CONFIG_SYS_BOOTMAPSZ (8 << 20) /* Initial Memory map for Linux */ |
219 | 220 | ||
220 | /* | 221 | /* |
221 | * Ethernet configuration | 222 | * Ethernet configuration |
222 | */ | 223 | */ |
223 | #define CONFIG_MPC5xxx_FEC 1 | 224 | #define CONFIG_MPC5xxx_FEC 1 |
224 | #define CONFIG_MPC5xxx_FEC_MII100 | 225 | #define CONFIG_MPC5xxx_FEC_MII100 |
225 | /* | 226 | /* |
226 | * Define CONFIG_MPC5xxx_FEC_MII10 to force FEC at 10Mb | 227 | * Define CONFIG_MPC5xxx_FEC_MII10 to force FEC at 10Mb |
227 | */ | 228 | */ |
228 | /* #define CONFIG_MPC5xxx_FEC_MII10 */ | 229 | /* #define CONFIG_MPC5xxx_FEC_MII10 */ |
229 | #define CONFIG_PHY_ADDR 0x00 | 230 | #define CONFIG_PHY_ADDR 0x00 |
230 | #define CONFIG_MII | 231 | #define CONFIG_MII |
231 | 232 | ||
232 | /* | 233 | /* |
233 | * GPIO configuration | 234 | * GPIO configuration |
234 | * | 235 | * |
235 | * use CS1 as gpio_wkup_6 output | 236 | * use CS1 as gpio_wkup_6 output |
236 | * Bit 0 (mask: 0x80000000): 0 | 237 | * Bit 0 (mask: 0x80000000): 0 |
237 | * use ALT CAN position: Bits 2-3 (mask: 0x30000000): | 238 | * use ALT CAN position: Bits 2-3 (mask: 0x30000000): |
238 | * 00 -> No Alternatives, I2C1 is used for onboard EEPROM | 239 | * 00 -> No Alternatives, I2C1 is used for onboard EEPROM |
239 | * 01 -> CAN1 on I2C1, CAN2 on Tmr0/1 do not use on TQM5200 with onboard | 240 | * 01 -> CAN1 on I2C1, CAN2 on Tmr0/1 do not use on TQM5200 with onboard |
240 | * EEPROM | 241 | * EEPROM |
241 | * use PSC1 as UART: Bits 28-31 (mask: 0x00000007): 0100 | 242 | * use PSC1 as UART: Bits 28-31 (mask: 0x00000007): 0100 |
242 | * use PSC6_1 and PSC6_3 as GPIO: Bits 9:11 (mask: 0x07000000): | 243 | * use PSC6_1 and PSC6_3 as GPIO: Bits 9:11 (mask: 0x07000000): |
243 | * 011 -> PSC6 could not be used as UART or CODEC. IrDA still possible. | 244 | * 011 -> PSC6 could not be used as UART or CODEC. IrDA still possible. |
244 | */ | 245 | */ |
245 | #define CONFIG_SYS_GPS_PORT_CONFIG 0x01001004 | 246 | #define CONFIG_SYS_GPS_PORT_CONFIG 0x01001004 |
246 | 247 | ||
247 | /* | 248 | /* |
248 | * RTC configuration | 249 | * RTC configuration |
249 | */ | 250 | */ |
250 | #define CONFIG_RTC_MPC5200 1 /* use internal MPC5200 RTC */ | 251 | #define CONFIG_RTC_MPC5200 1 /* use internal MPC5200 RTC */ |
251 | 252 | ||
252 | /* | 253 | /* |
253 | * Miscellaneous configurable options | 254 | * Miscellaneous configurable options |
254 | */ | 255 | */ |
255 | #define CONFIG_SYS_LONGHELP /* undef to save memory */ | 256 | #define CONFIG_SYS_LONGHELP /* undef to save memory */ |
256 | #define CONFIG_SYS_PROMPT "=> " /* Monitor Command Prompt */ | 257 | #define CONFIG_SYS_PROMPT "=> " /* Monitor Command Prompt */ |
257 | #if defined(CONFIG_CMD_KGDB) | 258 | #if defined(CONFIG_CMD_KGDB) |
258 | #define CONFIG_SYS_CBSIZE 1024 /* Console I/O Buffer Size */ | 259 | #define CONFIG_SYS_CBSIZE 1024 /* Console I/O Buffer Size */ |
259 | #else | 260 | #else |
260 | #define CONFIG_SYS_CBSIZE 256 /* Console I/O Buffer Size */ | 261 | #define CONFIG_SYS_CBSIZE 256 /* Console I/O Buffer Size */ |
261 | #endif | 262 | #endif |
262 | #define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE+sizeof(CONFIG_SYS_PROMPT)+16) /* Print Buffer Size */ | 263 | #define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE+sizeof(CONFIG_SYS_PROMPT)+16) /* Print Buffer Size */ |
263 | #define CONFIG_SYS_MAXARGS 16 /* max number of command args */ | 264 | #define CONFIG_SYS_MAXARGS 16 /* max number of command args */ |
264 | #define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE /* Boot Argument Buffer Size */ | 265 | #define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE /* Boot Argument Buffer Size */ |
265 | 266 | ||
266 | #define CONFIG_SYS_CACHELINE_SIZE 32 /* For MPC5xxx CPUs */ | 267 | #define CONFIG_SYS_CACHELINE_SIZE 32 /* For MPC5xxx CPUs */ |
267 | #if defined(CONFIG_CMD_KGDB) | 268 | #if defined(CONFIG_CMD_KGDB) |
268 | # define CONFIG_SYS_CACHELINE_SHIFT 5 /* log base 2 of the above value */ | 269 | # define CONFIG_SYS_CACHELINE_SHIFT 5 /* log base 2 of the above value */ |
269 | #endif | 270 | #endif |
270 | 271 | ||
271 | /* Enable an alternate, more extensive memory test */ | 272 | /* Enable an alternate, more extensive memory test */ |
272 | #define CONFIG_SYS_ALT_MEMTEST | 273 | #define CONFIG_SYS_ALT_MEMTEST |
273 | 274 | ||
274 | #define CONFIG_SYS_MEMTEST_START 0x00100000 /* memtest works on */ | 275 | #define CONFIG_SYS_MEMTEST_START 0x00100000 /* memtest works on */ |
275 | #define CONFIG_SYS_MEMTEST_END 0x00f00000 /* 1 ... 15 MB in DRAM */ | 276 | #define CONFIG_SYS_MEMTEST_END 0x00f00000 /* 1 ... 15 MB in DRAM */ |
276 | 277 | ||
277 | #define CONFIG_SYS_LOAD_ADDR 0x100000 /* default load address */ | 278 | #define CONFIG_SYS_LOAD_ADDR 0x100000 /* default load address */ |
278 | 279 | ||
279 | #define CONFIG_SYS_HZ 1000 /* decrementer freq: 1 ms ticks */ | 280 | #define CONFIG_SYS_HZ 1000 /* decrementer freq: 1 ms ticks */ |
280 | 281 | ||
281 | /* | 282 | /* |
282 | * Enable loopw command. | 283 | * Enable loopw command. |
283 | */ | 284 | */ |
284 | #define CONFIG_LOOPW | 285 | #define CONFIG_LOOPW |
285 | 286 | ||
286 | /* | 287 | /* |
287 | * Various low-level settings | 288 | * Various low-level settings |
288 | */ | 289 | */ |
289 | #if defined(CONFIG_MPC5200) | 290 | #if defined(CONFIG_MPC5200) |
290 | #define CONFIG_SYS_HID0_INIT HID0_ICE | HID0_ICFI | 291 | #define CONFIG_SYS_HID0_INIT HID0_ICE | HID0_ICFI |
291 | #define CONFIG_SYS_HID0_FINAL HID0_ICE | 292 | #define CONFIG_SYS_HID0_FINAL HID0_ICE |
292 | #else | 293 | #else |
293 | #define CONFIG_SYS_HID0_INIT 0 | 294 | #define CONFIG_SYS_HID0_INIT 0 |
294 | #define CONFIG_SYS_HID0_FINAL 0 | 295 | #define CONFIG_SYS_HID0_FINAL 0 |
295 | #endif | 296 | #endif |
296 | 297 | ||
297 | #define CONFIG_SYS_BOOTCS_START CONFIG_SYS_FLASH_BASE | 298 | #define CONFIG_SYS_BOOTCS_START CONFIG_SYS_FLASH_BASE |
298 | #define CONFIG_SYS_BOOTCS_SIZE CONFIG_SYS_FLASH_SIZE | 299 | #define CONFIG_SYS_BOOTCS_SIZE CONFIG_SYS_FLASH_SIZE |
299 | #define CONFIG_SYS_BOOTCS_CFG 0x00087800 /* for pci_clk = 66 MHz */ | 300 | #define CONFIG_SYS_BOOTCS_CFG 0x00087800 /* for pci_clk = 66 MHz */ |
300 | #define CONFIG_SYS_CS0_START CONFIG_SYS_FLASH_BASE | 301 | #define CONFIG_SYS_CS0_START CONFIG_SYS_FLASH_BASE |
301 | #define CONFIG_SYS_CS0_SIZE CONFIG_SYS_FLASH_SIZE | 302 | #define CONFIG_SYS_CS0_SIZE CONFIG_SYS_FLASH_SIZE |
302 | 303 | ||
303 | /* 32Mbit SRAM @0x30000000 */ | 304 | /* 32Mbit SRAM @0x30000000 */ |
304 | #define CONFIG_SYS_CS1_START 0x30000000 | 305 | #define CONFIG_SYS_CS1_START 0x30000000 |
305 | #define CONFIG_SYS_CS1_SIZE 0x00400000 | 306 | #define CONFIG_SYS_CS1_SIZE 0x00400000 |
306 | #define CONFIG_SYS_CS1_CFG 0x31800 /* for pci_clk = 33 MHz */ | 307 | #define CONFIG_SYS_CS1_CFG 0x31800 /* for pci_clk = 33 MHz */ |
307 | 308 | ||
308 | /* 2 quad UART @0x80000000 (MBAR is relocated to 0xF0000000) */ | 309 | /* 2 quad UART @0x80000000 (MBAR is relocated to 0xF0000000) */ |
309 | #define CONFIG_SYS_CS2_START 0x80000000 | 310 | #define CONFIG_SYS_CS2_START 0x80000000 |
310 | #define CONFIG_SYS_CS2_SIZE 0x0001000 | 311 | #define CONFIG_SYS_CS2_SIZE 0x0001000 |
311 | #define CONFIG_SYS_CS2_CFG 0x21800 /* for pci_clk = 33 MHz */ | 312 | #define CONFIG_SYS_CS2_CFG 0x21800 /* for pci_clk = 33 MHz */ |
312 | 313 | ||
313 | /* GPIO in @0x30400000 */ | 314 | /* GPIO in @0x30400000 */ |
314 | #define CONFIG_SYS_CS3_START 0x30400000 | 315 | #define CONFIG_SYS_CS3_START 0x30400000 |
315 | #define CONFIG_SYS_CS3_SIZE 0x00100000 | 316 | #define CONFIG_SYS_CS3_SIZE 0x00100000 |
316 | #define CONFIG_SYS_CS3_CFG 0x31800 /* for pci_clk = 33 MHz */ | 317 | #define CONFIG_SYS_CS3_CFG 0x31800 /* for pci_clk = 33 MHz */ |
317 | 318 | ||
318 | #define CONFIG_SYS_CS_BURST 0x00000000 | 319 | #define CONFIG_SYS_CS_BURST 0x00000000 |
319 | #define CONFIG_SYS_CS_DEADCYCLE 0x33333333 | 320 | #define CONFIG_SYS_CS_DEADCYCLE 0x33333333 |
320 | 321 | ||
321 | /*----------------------------------------------------------------------- | 322 | /*----------------------------------------------------------------------- |
322 | * USB stuff | 323 | * USB stuff |
323 | *----------------------------------------------------------------------- | 324 | *----------------------------------------------------------------------- |
324 | */ | 325 | */ |
325 | #define CONFIG_USB_OHCI | 326 | #define CONFIG_USB_OHCI |
326 | #define CONFIG_USB_CLOCK 0x00015555 | 327 | #define CONFIG_USB_CLOCK 0x00015555 |
327 | #define CONFIG_USB_CONFIG 0x00001000 | 328 | #define CONFIG_USB_CONFIG 0x00001000 |
328 | #define CONFIG_USB_STORAGE | 329 | #define CONFIG_USB_STORAGE |
329 | 330 | ||
330 | /*----------------------------------------------------------------------- | 331 | /*----------------------------------------------------------------------- |
331 | * IDE/ATA stuff Supports IDE harddisk | 332 | * IDE/ATA stuff Supports IDE harddisk |
332 | *----------------------------------------------------------------------- | 333 | *----------------------------------------------------------------------- |
333 | */ | 334 | */ |
334 | 335 | ||
335 | #undef CONFIG_IDE_8xx_PCCARD /* Use IDE with PC Card Adapter */ | 336 | #undef CONFIG_IDE_8xx_PCCARD /* Use IDE with PC Card Adapter */ |
336 | 337 | ||
337 | #undef CONFIG_IDE_8xx_DIRECT /* Direct IDE not supported */ | 338 | #undef CONFIG_IDE_8xx_DIRECT /* Direct IDE not supported */ |
338 | #undef CONFIG_IDE_LED /* LED for ide not supported */ | 339 | #undef CONFIG_IDE_LED /* LED for ide not supported */ |
339 | 340 | ||
340 | #define CONFIG_IDE_RESET /* reset for ide supported */ | 341 | #define CONFIG_IDE_RESET /* reset for ide supported */ |
341 | #define CONFIG_IDE_PREINIT | 342 | #define CONFIG_IDE_PREINIT |
342 | 343 | ||
343 | #define CONFIG_SYS_IDE_MAXBUS 1 /* max. 1 IDE bus */ | 344 | #define CONFIG_SYS_IDE_MAXBUS 1 /* max. 1 IDE bus */ |
344 | #define CONFIG_SYS_IDE_MAXDEVICE 2 /* max. 1 drive per IDE bus */ | 345 | #define CONFIG_SYS_IDE_MAXDEVICE 2 /* max. 1 drive per IDE bus */ |
345 | 346 | ||
346 | #define CONFIG_SYS_ATA_IDE0_OFFSET 0x0000 | 347 | #define CONFIG_SYS_ATA_IDE0_OFFSET 0x0000 |
347 | #define CONFIG_SYS_ATA_BASE_ADDR MPC5XXX_ATA | 348 | #define CONFIG_SYS_ATA_BASE_ADDR MPC5XXX_ATA |
348 | #define CONFIG_SYS_ATA_DATA_OFFSET 0x0060 /* Offset for data I/O */ | 349 | #define CONFIG_SYS_ATA_DATA_OFFSET 0x0060 /* Offset for data I/O */ |
349 | #define CONFIG_SYS_ATA_REG_OFFSET (CONFIG_SYS_ATA_DATA_OFFSET) /* Offset for normal register accesses */ | 350 | #define CONFIG_SYS_ATA_REG_OFFSET (CONFIG_SYS_ATA_DATA_OFFSET) /* Offset for normal register accesses */ |
350 | #define CONFIG_SYS_ATA_ALT_OFFSET 0x005C /* Offset for alternate registers */ | 351 | #define CONFIG_SYS_ATA_ALT_OFFSET 0x005C /* Offset for alternate registers */ |
351 | #define CONFIG_SYS_ATA_STRIDE 4 /* Interval between registers */ | 352 | #define CONFIG_SYS_ATA_STRIDE 4 /* Interval between registers */ |
352 | 353 | ||
353 | #define CONFIG_ATAPI 1 | 354 | #define CONFIG_ATAPI 1 |
354 | 355 | ||
355 | #define CONFIG_SYS_BRIGHTNESS 0xFF /* LCD Default Brightness (255 = off) */ | 356 | #define CONFIG_SYS_BRIGHTNESS 0xFF /* LCD Default Brightness (255 = off) */ |
356 | 357 | ||
357 | #endif /* __CONFIG_H */ | 358 | #endif /* __CONFIG_H */ |
358 | 359 |
include/ns16550.h
1 | /* | 1 | /* |
2 | * NS16550 Serial Port | 2 | * NS16550 Serial Port |
3 | * originally from linux source (arch/ppc/boot/ns16550.h) | 3 | * originally from linux source (arch/ppc/boot/ns16550.h) |
4 | * modified slightly to | 4 | * modified slightly to |
5 | * have addresses as offsets from CONFIG_SYS_ISA_BASE | 5 | * have addresses as offsets from CONFIG_SYS_ISA_BASE |
6 | * added a few more definitions | 6 | * added a few more definitions |
7 | * added prototypes for ns16550.c | 7 | * added prototypes for ns16550.c |
8 | * reduced no of com ports to 2 | 8 | * reduced no of com ports to 2 |
9 | * modifications (c) Rob Taylor, Flying Pig Systems. 2000. | 9 | * modifications (c) Rob Taylor, Flying Pig Systems. 2000. |
10 | * | 10 | * |
11 | * added support for port on 64-bit bus | 11 | * added support for port on 64-bit bus |
12 | * by Richard Danter (richard.danter@windriver.com), (C) 2005 Wind River Systems | 12 | * by Richard Danter (richard.danter@windriver.com), (C) 2005 Wind River Systems |
13 | */ | 13 | */ |
14 | 14 | ||
15 | #if (CONFIG_SYS_NS16550_REG_SIZE == 1) | 15 | #if (CONFIG_SYS_NS16550_REG_SIZE == 1) |
16 | struct NS16550 { | 16 | struct NS16550 { |
17 | unsigned char rbr; /* 0 */ | 17 | unsigned char rbr; /* 0 */ |
18 | unsigned char ier; /* 1 */ | 18 | unsigned char ier; /* 1 */ |
19 | unsigned char fcr; /* 2 */ | 19 | unsigned char fcr; /* 2 */ |
20 | unsigned char lcr; /* 3 */ | 20 | unsigned char lcr; /* 3 */ |
21 | unsigned char mcr; /* 4 */ | 21 | unsigned char mcr; /* 4 */ |
22 | unsigned char lsr; /* 5 */ | 22 | unsigned char lsr; /* 5 */ |
23 | unsigned char msr; /* 6 */ | 23 | unsigned char msr; /* 6 */ |
24 | unsigned char scr; /* 7 */ | 24 | unsigned char scr; /* 7 */ |
25 | #if defined(CONFIG_OMAP730) | 25 | #if defined(CONFIG_OMAP730) |
26 | unsigned char mdr1; /* 8 */ | 26 | unsigned char mdr1; /* 8 */ |
27 | unsigned char reg9; /* 9 */ | 27 | unsigned char reg9; /* 9 */ |
28 | unsigned char regA; /* A */ | 28 | unsigned char regA; /* A */ |
29 | unsigned char regB; /* B */ | 29 | unsigned char regB; /* B */ |
30 | unsigned char regC; /* C */ | 30 | unsigned char regC; /* C */ |
31 | unsigned char regD; /* D */ | 31 | unsigned char regD; /* D */ |
32 | unsigned char regE; /* E */ | 32 | unsigned char regE; /* E */ |
33 | unsigned char regF; /* F */ | 33 | unsigned char regF; /* F */ |
34 | unsigned char reg10; /* 10 */ | 34 | unsigned char reg10; /* 10 */ |
35 | unsigned char ssr; /* 11*/ | 35 | unsigned char ssr; /* 11*/ |
36 | #endif | 36 | #endif |
37 | } __attribute__ ((packed)); | 37 | } __attribute__ ((packed)); |
38 | #elif (CONFIG_SYS_NS16550_REG_SIZE == 2) | 38 | #elif (CONFIG_SYS_NS16550_REG_SIZE == 2) |
39 | struct NS16550 { | 39 | struct NS16550 { |
40 | unsigned short rbr; /* 0 */ | 40 | unsigned short rbr; /* 0 */ |
41 | unsigned short ier; /* 1 */ | 41 | unsigned short ier; /* 1 */ |
42 | unsigned short fcr; /* 2 */ | 42 | unsigned short fcr; /* 2 */ |
43 | unsigned short lcr; /* 3 */ | 43 | unsigned short lcr; /* 3 */ |
44 | unsigned short mcr; /* 4 */ | 44 | unsigned short mcr; /* 4 */ |
45 | unsigned short lsr; /* 5 */ | 45 | unsigned short lsr; /* 5 */ |
46 | unsigned short msr; /* 6 */ | 46 | unsigned short msr; /* 6 */ |
47 | unsigned short scr; /* 7 */ | 47 | unsigned short scr; /* 7 */ |
48 | } __attribute__ ((packed)); | 48 | } __attribute__ ((packed)); |
49 | #elif (CONFIG_SYS_NS16550_REG_SIZE == 4) | 49 | #elif (CONFIG_SYS_NS16550_REG_SIZE == 4) |
50 | struct NS16550 { | 50 | struct NS16550 { |
51 | unsigned long rbr; /* 0 r */ | 51 | unsigned long rbr; /* 0 r */ |
52 | unsigned long ier; /* 1 rw */ | 52 | unsigned long ier; /* 1 rw */ |
53 | unsigned long fcr; /* 2 w */ | 53 | unsigned long fcr; /* 2 w */ |
54 | unsigned long lcr; /* 3 rw */ | 54 | unsigned long lcr; /* 3 rw */ |
55 | unsigned long mcr; /* 4 rw */ | 55 | unsigned long mcr; /* 4 rw */ |
56 | unsigned long lsr; /* 5 r */ | 56 | unsigned long lsr; /* 5 r */ |
57 | unsigned long msr; /* 6 r */ | 57 | unsigned long msr; /* 6 r */ |
58 | unsigned long scr; /* 7 rw */ | 58 | unsigned long scr; /* 7 rw */ |
59 | }; /* No need to pack an already aligned struct */ | 59 | }; /* No need to pack an already aligned struct */ |
60 | #elif (CONFIG_SYS_NS16550_REG_SIZE == -4) | 60 | #elif (CONFIG_SYS_NS16550_REG_SIZE == -4) |
61 | struct NS16550 { | 61 | struct NS16550 { |
62 | unsigned char rbr; /* 0 */ | 62 | unsigned char rbr; /* 0 */ |
63 | int pad1:24; | 63 | int pad1:24; |
64 | unsigned char ier; /* 1 */ | 64 | unsigned char ier; /* 1 */ |
65 | int pad2:24; | 65 | int pad2:24; |
66 | unsigned char fcr; /* 2 */ | 66 | unsigned char fcr; /* 2 */ |
67 | int pad3:24; | 67 | int pad3:24; |
68 | unsigned char lcr; /* 3 */ | 68 | unsigned char lcr; /* 3 */ |
69 | int pad4:24; | 69 | int pad4:24; |
70 | unsigned char mcr; /* 4 */ | 70 | unsigned char mcr; /* 4 */ |
71 | int pad5:24; | 71 | int pad5:24; |
72 | unsigned char lsr; /* 5 */ | 72 | unsigned char lsr; /* 5 */ |
73 | int pad6:24; | 73 | int pad6:24; |
74 | unsigned char msr; /* 6 */ | 74 | unsigned char msr; /* 6 */ |
75 | int pad7:24; | 75 | int pad7:24; |
76 | unsigned char scr; /* 7 */ | 76 | unsigned char scr; /* 7 */ |
77 | int pad8:24; | 77 | int pad8:24; |
78 | #if defined(CONFIG_OMAP) | 78 | #if defined(CONFIG_OMAP) |
79 | unsigned char mdr1; /* mode select reset TL16C750*/ | 79 | unsigned char mdr1; /* mode select reset TL16C750*/ |
80 | #endif | 80 | #endif |
81 | #ifdef CONFIG_OMAP1510 | 81 | #ifdef CONFIG_OMAP1510 |
82 | int pad9:24; | 82 | int pad9:24; |
83 | unsigned long pad[10]; | 83 | unsigned long pad[10]; |
84 | unsigned char osc_12m_sel; | 84 | unsigned char osc_12m_sel; |
85 | int pad10:24; | 85 | int pad10:24; |
86 | #endif | 86 | #endif |
87 | } __attribute__ ((packed)); | 87 | } __attribute__ ((packed)); |
88 | #elif (CONFIG_SYS_NS16550_REG_SIZE == -8) | 88 | #elif (CONFIG_SYS_NS16550_REG_SIZE == -8) |
89 | struct NS16550 { | 89 | struct NS16550 { |
90 | unsigned char rbr; /* 0 */ | 90 | unsigned char rbr; /* 0 */ |
91 | unsigned char pad0[7]; | 91 | unsigned char pad0[7]; |
92 | unsigned char ier; /* 1 */ | 92 | unsigned char ier; /* 1 */ |
93 | unsigned char pad1[7]; | 93 | unsigned char pad1[7]; |
94 | unsigned char fcr; /* 2 */ | 94 | unsigned char fcr; /* 2 */ |
95 | unsigned char pad2[7]; | 95 | unsigned char pad2[7]; |
96 | unsigned char lcr; /* 3 */ | 96 | unsigned char lcr; /* 3 */ |
97 | unsigned char pad3[7]; | 97 | unsigned char pad3[7]; |
98 | unsigned char mcr; /* 4 */ | 98 | unsigned char mcr; /* 4 */ |
99 | unsigned char pad4[7]; | 99 | unsigned char pad4[7]; |
100 | unsigned char lsr; /* 5 */ | 100 | unsigned char lsr; /* 5 */ |
101 | unsigned char pad5[7]; | 101 | unsigned char pad5[7]; |
102 | unsigned char msr; /* 6 */ | 102 | unsigned char msr; /* 6 */ |
103 | unsigned char pad6[7]; | 103 | unsigned char pad6[7]; |
104 | unsigned char scr; /* 7 */ | 104 | unsigned char scr; /* 7 */ |
105 | unsigned char pad7[7]; | 105 | unsigned char pad7[7]; |
106 | } __attribute__ ((packed)); | 106 | } __attribute__ ((packed)); |
107 | #else | 107 | #else |
108 | #error "Please define NS16550 registers size." | 108 | #error "Please define NS16550 registers size." |
109 | #endif | 109 | #endif |
110 | 110 | ||
111 | #define thr rbr | 111 | #define thr rbr |
112 | #define iir fcr | 112 | #define iir fcr |
113 | #define dll rbr | 113 | #define dll rbr |
114 | #define dlm ier | 114 | #define dlm ier |
115 | 115 | ||
116 | typedef volatile struct NS16550 *NS16550_t; | 116 | typedef volatile struct NS16550 *NS16550_t; |
117 | 117 | ||
118 | #define FCR_FIFO_EN 0x01 /* Fifo enable */ | 118 | #define FCR_FIFO_EN 0x01 /* Fifo enable */ |
119 | #define FCR_RXSR 0x02 /* Receiver soft reset */ | 119 | #define FCR_RXSR 0x02 /* Receiver soft reset */ |
120 | #define FCR_TXSR 0x04 /* Transmitter soft reset */ | 120 | #define FCR_TXSR 0x04 /* Transmitter soft reset */ |
121 | 121 | ||
122 | #define MCR_DTR 0x01 | 122 | #define MCR_DTR 0x01 |
123 | #define MCR_RTS 0x02 | 123 | #define MCR_RTS 0x02 |
124 | #define MCR_DMA_EN 0x04 | 124 | #define MCR_DMA_EN 0x04 |
125 | #define MCR_TX_DFR 0x08 | 125 | #define MCR_TX_DFR 0x08 |
126 | #define MCR_LOOP 0x10 /* Enable loopback test mode */ | ||
126 | 127 | ||
127 | #define LCR_WLS_MSK 0x03 /* character length select mask */ | 128 | #define LCR_WLS_MSK 0x03 /* character length select mask */ |
128 | #define LCR_WLS_5 0x00 /* 5 bit character length */ | 129 | #define LCR_WLS_5 0x00 /* 5 bit character length */ |
129 | #define LCR_WLS_6 0x01 /* 6 bit character length */ | 130 | #define LCR_WLS_6 0x01 /* 6 bit character length */ |
130 | #define LCR_WLS_7 0x02 /* 7 bit character length */ | 131 | #define LCR_WLS_7 0x02 /* 7 bit character length */ |
131 | #define LCR_WLS_8 0x03 /* 8 bit character length */ | 132 | #define LCR_WLS_8 0x03 /* 8 bit character length */ |
132 | #define LCR_STB 0x04 /* Number of stop Bits, off = 1, on = 1.5 or 2) */ | 133 | #define LCR_STB 0x04 /* Number of stop Bits, off = 1, on = 1.5 or 2) */ |
133 | #define LCR_PEN 0x08 /* Parity eneble */ | 134 | #define LCR_PEN 0x08 /* Parity eneble */ |
134 | #define LCR_EPS 0x10 /* Even Parity Select */ | 135 | #define LCR_EPS 0x10 /* Even Parity Select */ |
135 | #define LCR_STKP 0x20 /* Stick Parity */ | 136 | #define LCR_STKP 0x20 /* Stick Parity */ |
136 | #define LCR_SBRK 0x40 /* Set Break */ | 137 | #define LCR_SBRK 0x40 /* Set Break */ |
137 | #define LCR_BKSE 0x80 /* Bank select enable */ | 138 | #define LCR_BKSE 0x80 /* Bank select enable */ |
139 | #define LCR_DLAB 0x80 /* Divisor latch access bit */ | ||
138 | 140 | ||
139 | #define LSR_DR 0x01 /* Data ready */ | 141 | #define LSR_DR 0x01 /* Data ready */ |
140 | #define LSR_OE 0x02 /* Overrun */ | 142 | #define LSR_OE 0x02 /* Overrun */ |
141 | #define LSR_PE 0x04 /* Parity error */ | 143 | #define LSR_PE 0x04 /* Parity error */ |
142 | #define LSR_FE 0x08 /* Framing error */ | 144 | #define LSR_FE 0x08 /* Framing error */ |
143 | #define LSR_BI 0x10 /* Break */ | 145 | #define LSR_BI 0x10 /* Break */ |
144 | #define LSR_THRE 0x20 /* Xmit holding register empty */ | 146 | #define LSR_THRE 0x20 /* Xmit holding register empty */ |
145 | #define LSR_TEMT 0x40 /* Xmitter empty */ | 147 | #define LSR_TEMT 0x40 /* Xmitter empty */ |
146 | #define LSR_ERR 0x80 /* Error */ | 148 | #define LSR_ERR 0x80 /* Error */ |
149 | |||
150 | #define MSR_DCD 0x80 /* Data Carrier Detect */ | ||
151 | #define MSR_RI 0x40 /* Ring Indicator */ | ||
152 | #define MSR_DSR 0x20 /* Data Set Ready */ | ||
153 | #define MSR_CTS 0x10 /* Clear to Send */ | ||
154 | #define MSR_DDCD 0x08 /* Delta DCD */ | ||
155 | #define MSR_TERI 0x04 /* Trailing edge ring indicator */ | ||
156 | #define MSR_DDSR 0x02 /* Delta DSR */ | ||
157 | #define MSR_DCTS 0x01 /* Delta CTS */ | ||
147 | 158 | ||
148 | #ifdef CONFIG_OMAP1510 | 159 | #ifdef CONFIG_OMAP1510 |
149 | #define OSC_12M_SEL 0x01 /* selects 6.5 * current clk div */ | 160 | #define OSC_12M_SEL 0x01 /* selects 6.5 * current clk div */ |
150 | #endif | 161 | #endif |
151 | 162 | ||
152 | /* useful defaults for LCR */ | 163 | /* useful defaults for LCR */ |
153 | #define LCR_8N1 0x03 | 164 | #define LCR_8N1 0x03 |
154 | 165 | ||
155 | void NS16550_init (NS16550_t com_port, int baud_divisor); | 166 | void NS16550_init (NS16550_t com_port, int baud_divisor); |
156 | void NS16550_putc (NS16550_t com_port, char c); | 167 | void NS16550_putc (NS16550_t com_port, char c); |
157 | char NS16550_getc (NS16550_t com_port); | 168 | char NS16550_getc (NS16550_t com_port); |
158 | int NS16550_tstc (NS16550_t com_port); | 169 | int NS16550_tstc (NS16550_t com_port); |
159 | void NS16550_reinit (NS16550_t com_port, int baud_divisor); | 170 | void NS16550_reinit (NS16550_t com_port, int baud_divisor); |
160 | 171 |