wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2000, 2001, 2002 |
| 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * Klaus Heydeck, Kieback & Peter GmbH & Co KG, heydeck@kieback-peter.de |
| 5 | * |
| 6 | * See file CREDITS for list of people who contributed to this |
| 7 | * project. |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or |
| 10 | * modify it under the terms of the GNU General Public License as |
| 11 | * published by the Free Software Foundation; either version 2 of |
| 12 | * the License, or (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program; if not, write to the Free Software |
| 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 22 | * MA 02111-1307 USA |
| 23 | */ |
| 24 | |
| 25 | #include <common.h> |
| 26 | #include <mpc8xx.h> |
| 27 | #ifdef CONFIG_KUP4K_LOGO |
| 28 | #include "s1d13706.h" |
| 29 | #endif |
| 30 | |
| 31 | |
| 32 | typedef struct |
| 33 | { |
| 34 | volatile unsigned char *VmemAddr; |
| 35 | volatile unsigned char *RegAddr; |
| 36 | }FB_INFO_S1D13xxx; |
| 37 | |
| 38 | /* ------------------------------------------------------------------------- */ |
| 39 | |
| 40 | #if 0 |
| 41 | static long int dram_size (long int, long int *, long int); |
| 42 | #endif |
| 43 | |
| 44 | #ifdef CONFIG_KUP4K_LOGO |
| 45 | void lcd_logo(bd_t *bd); |
| 46 | #endif |
| 47 | |
| 48 | /* ------------------------------------------------------------------------- */ |
| 49 | |
| 50 | #define _NOT_USED_ 0xFFFFFFFF |
| 51 | |
| 52 | const uint sdram_table[] = |
| 53 | { |
| 54 | /* |
| 55 | * Single Read. (Offset 0 in UPMA RAM) |
| 56 | */ |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 57 | 0x1F07FC04, 0xEEAEFC04, 0x11ADFC04, 0xEFBBBC00, |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 58 | 0x1FF77C47, /* last */ |
| 59 | |
| 60 | /* |
| 61 | * SDRAM Initialization (offset 5 in UPMA RAM) |
| 62 | * |
| 63 | * This is no UPM entry point. The following definition uses |
| 64 | * the remaining space to establish an initialization |
| 65 | * sequence, which is executed by a RUN command. |
| 66 | * |
| 67 | */ |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 68 | 0x1FF77C35, 0xEFEABC34, 0x1FB57C35, /* last */ |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 69 | |
| 70 | /* |
| 71 | * Burst Read. (Offset 8 in UPMA RAM) |
| 72 | */ |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 73 | 0x1F07FC04, 0xEEAEFC04, 0x10ADFC04, 0xF0AFFC00, |
| 74 | 0xF0AFFC00, 0xF1AFFC00, 0xEFBBBC00, 0x1FF77C47, /* last */ |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 75 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 76 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 77 | |
| 78 | /* |
| 79 | * Single Write. (Offset 18 in UPMA RAM) |
| 80 | */ |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 81 | 0x1F27FC04, 0xEEAEBC00, 0x01B93C04, 0x1FF77C47, /* last */ |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 82 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 83 | |
| 84 | /* |
| 85 | * Burst Write. (Offset 20 in UPMA RAM) |
| 86 | */ |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 87 | 0x1F07FC04, 0xEEAEBC00, 0x10AD7C00, 0xF0AFFC00, |
| 88 | 0xF0AFFC00, 0xE1BBBC04, 0x1FF77C47, /* last */ |
| 89 | _NOT_USED_, |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 90 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 91 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 92 | |
| 93 | /* |
| 94 | * Refresh (Offset 30 in UPMA RAM) |
| 95 | */ |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 96 | 0x1FF5FC84, 0xFFFFFC04, 0xFFFFFC04, 0xFFFFFC04, |
| 97 | 0xFFFFFC84, 0xFFFFFC07, /* last */ |
| 98 | _NOT_USED_, _NOT_USED_, |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 99 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 100 | |
| 101 | /* |
| 102 | * Exception. (Offset 3c in UPMA RAM) |
| 103 | */ |
| 104 | 0x7FFFFC07, /* last */ |
| 105 | _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 106 | }; |
| 107 | |
| 108 | /* ------------------------------------------------------------------------- */ |
| 109 | |
| 110 | |
| 111 | /* |
| 112 | * Check Board Identity: |
| 113 | */ |
| 114 | |
| 115 | int checkboard (void) |
| 116 | { |
| 117 | |
| 118 | printf ("### No HW ID - assuming KUP4K-Color\n"); |
| 119 | return (0); |
| 120 | } |
| 121 | |
| 122 | /* ------------------------------------------------------------------------- */ |
| 123 | |
| 124 | long int initdram (int board_type) |
| 125 | { |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 126 | volatile immap_t *immap = (immap_t *) CFG_IMMR; |
| 127 | volatile memctl8xx_t *memctl = &immap->im_memctl; |
| 128 | long int size_b0 = 0; |
| 129 | long int size_b1 = 0; |
| 130 | long int size_b2 = 0; |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 131 | |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 132 | upmconfig (UPMA, (uint *) sdram_table, |
| 133 | sizeof (sdram_table) / sizeof (uint)); |
| 134 | |
| 135 | /* |
| 136 | * Preliminary prescaler for refresh (depends on number of |
| 137 | * banks): This value is selected for four cycles every 62.4 us |
| 138 | * with two SDRAM banks or four cycles every 31.2 us with one |
| 139 | * bank. It will be adjusted after memory sizing. |
| 140 | */ |
| 141 | memctl->memc_mptpr = CFG_MPTPR; |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 142 | |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 143 | memctl->memc_mar = 0x00000088; |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 144 | |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 145 | /* |
| 146 | * Map controller banks 1 and 2 to the SDRAM banks 2 and 3 at |
| 147 | * preliminary addresses - these have to be modified after the |
| 148 | * SDRAM size has been determined. |
| 149 | */ |
| 150 | /* memctl->memc_or1 = CFG_OR1_PRELIM; */ |
| 151 | /* memctl->memc_br1 = CFG_BR1_PRELIM; */ |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 152 | |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 153 | /* memctl->memc_or2 = CFG_OR2_PRELIM; */ |
| 154 | /* memctl->memc_br2 = CFG_BR2_PRELIM; */ |
| 155 | |
| 156 | |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 157 | memctl->memc_mamr = CFG_MAMR & (~(MAMR_PTAE)); /* no refresh yet */ |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 158 | |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 159 | udelay (200); |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 160 | |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 161 | /* perform SDRAM initializsation sequence */ |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 162 | |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 163 | memctl->memc_mcr = 0x80002105; /* SDRAM bank 0 */ |
| 164 | udelay (1); |
| 165 | memctl->memc_mcr = 0x80002830; /* SDRAM bank 0 - execute twice */ |
| 166 | udelay (1); |
| 167 | memctl->memc_mcr = 0x80002106; /* SDRAM bank 0 - RUN MRS Pattern from loc 6 */ |
| 168 | udelay (1); |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 169 | |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 170 | memctl->memc_mcr = 0x80004105; /* SDRAM bank 1 */ |
| 171 | udelay (1); |
| 172 | memctl->memc_mcr = 0x80004830; /* SDRAM bank 1 - execute twice */ |
| 173 | udelay (1); |
| 174 | memctl->memc_mcr = 0x80004106; /* SDRAM bank 1 - RUN MRS Pattern from loc 6 */ |
| 175 | udelay (1); |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 176 | |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 177 | memctl->memc_mcr = 0x80006105; /* SDRAM bank 2 */ |
| 178 | udelay (1); |
| 179 | memctl->memc_mcr = 0x80006830; /* SDRAM bank 2 - execute twice */ |
| 180 | udelay (1); |
| 181 | memctl->memc_mcr = 0x80006106; /* SDRAM bank 2 - RUN MRS Pattern from loc 6 */ |
| 182 | udelay (1); |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 183 | |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 184 | memctl->memc_mamr |= MAMR_PTAE; /* enable refresh */ |
| 185 | udelay (1000); |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 186 | |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 187 | #if 0 /* 3 x 8MB */ |
| 188 | size_b0 = 0x00800000; |
| 189 | size_b1 = 0x00800000; |
| 190 | size_b2 = 0x00800000; |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 191 | memctl->memc_mptpr = CFG_MPTPR; |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 192 | udelay (1000); |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 193 | memctl->memc_or1 = 0xFF800A00; |
| 194 | memctl->memc_br1 = 0x00000081; |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 195 | memctl->memc_or2 = 0xFF000A00; |
| 196 | memctl->memc_br2 = 0x00800081; |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 197 | memctl->memc_or3 = 0xFE000A00; |
| 198 | memctl->memc_br3 = 0x01000081; |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 199 | #else /* 3 x 16 MB */ |
| 200 | size_b0 = 0x01000000; |
| 201 | size_b1 = 0x01000000; |
| 202 | size_b2 = 0x01000000; |
| 203 | memctl->memc_mptpr = CFG_MPTPR; |
| 204 | udelay (1000); |
| 205 | memctl->memc_or1 = 0xFF000A00; |
| 206 | memctl->memc_br1 = 0x00000081; |
| 207 | memctl->memc_or2 = 0xFE000A00; |
| 208 | memctl->memc_br2 = 0x01000081; |
| 209 | memctl->memc_or3 = 0xFC000A00; |
| 210 | memctl->memc_br3 = 0x02000081; |
| 211 | #endif |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 212 | |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 213 | udelay (10000); |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 214 | |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 215 | return (size_b0 + size_b1 + size_b2); |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 216 | } |
| 217 | |
| 218 | /* ------------------------------------------------------------------------- */ |
| 219 | |
| 220 | /* |
| 221 | * Check memory range for valid RAM. A simple memory test determines |
| 222 | * the actually available RAM size between addresses `base' and |
| 223 | * `base + maxsize'. Some (not all) hardware errors are detected: |
| 224 | * - short between address lines |
| 225 | * - short between data lines |
| 226 | */ |
| 227 | #if 0 |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 228 | static long int dram_size (long int mamr_value, long int *base, |
| 229 | long int maxsize) |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 230 | { |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 231 | volatile immap_t *immap = (immap_t *) CFG_IMMR; |
| 232 | volatile memctl8xx_t *memctl = &immap->im_memctl; |
| 233 | volatile long int *addr; |
| 234 | ulong cnt, val; |
| 235 | ulong save[32]; /* to make test non-destructive */ |
| 236 | unsigned char i = 0; |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 237 | |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 238 | memctl->memc_mamr = mamr_value; |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 239 | |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 240 | for (cnt = maxsize / sizeof (long); cnt > 0; cnt >>= 1) { |
| 241 | addr = base + cnt; /* pointer arith! */ |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 242 | |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 243 | save[i++] = *addr; |
| 244 | *addr = ~cnt; |
| 245 | } |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 246 | |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 247 | /* write 0 to base address */ |
| 248 | addr = base; |
| 249 | save[i] = *addr; |
| 250 | *addr = 0; |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 251 | |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 252 | /* check at base address */ |
| 253 | if ((val = *addr) != 0) { |
| 254 | *addr = save[i]; |
| 255 | return (0); |
| 256 | } |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 257 | |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 258 | for (cnt = 1; cnt <= maxsize / sizeof (long); cnt <<= 1) { |
| 259 | addr = base + cnt; /* pointer arith! */ |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 260 | |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 261 | val = *addr; |
| 262 | *addr = save[--i]; |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 263 | |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 264 | if (val != (~cnt)) { |
| 265 | return (cnt * sizeof (long)); |
| 266 | } |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 267 | } |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 268 | return (maxsize); |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 269 | } |
| 270 | #endif |
| 271 | |
| 272 | int misc_init_r (void) |
| 273 | { |
| 274 | DECLARE_GLOBAL_DATA_PTR; |
| 275 | |
wdenk | 90e7e42 | 2002-12-04 23:39:58 +0000 | [diff] [blame] | 276 | #ifdef CONFIG_STATUS_LED |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 277 | volatile immap_t *immap = (immap_t *) CFG_IMMR; |
wdenk | 90e7e42 | 2002-12-04 23:39:58 +0000 | [diff] [blame] | 278 | #endif |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 279 | #ifdef CONFIG_KUP4K_LOGO |
| 280 | bd_t *bd = gd->bd; |
| 281 | |
| 282 | |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 283 | lcd_logo (bd); |
| 284 | #endif /* CONFIG_KUP4K_LOGO */ |
wdenk | 90e7e42 | 2002-12-04 23:39:58 +0000 | [diff] [blame] | 285 | #ifdef CONFIG_IDE_LED |
| 286 | /* Configure PA8 as output port */ |
| 287 | immap->im_ioport.iop_padir |= 0x80; |
| 288 | immap->im_ioport.iop_paodr |= 0x80; |
| 289 | immap->im_ioport.iop_papar &= ~0x80; |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 290 | immap->im_ioport.iop_padat |= 0x80; /* turn it off */ |
wdenk | 90e7e42 | 2002-12-04 23:39:58 +0000 | [diff] [blame] | 291 | #endif |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 292 | return (0); |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 293 | } |
| 294 | |
| 295 | #ifdef CONFIG_KUP4K_LOGO |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 296 | |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 297 | |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 298 | #define PB_LCD_PWM ((uint)0x00004000) /* PB 17 */ |
| 299 | |
| 300 | void lcd_logo (bd_t * bd) |
| 301 | { |
| 302 | |
| 303 | |
| 304 | volatile immap_t *immap = (immap_t *) CFG_IMMR; |
| 305 | |
| 306 | |
| 307 | |
| 308 | FB_INFO_S1D13xxx fb_info; |
| 309 | S1D_INDEX s1dReg; |
| 310 | S1D_VALUE s1dValue; |
| 311 | volatile immap_t *immr = (immap_t *) CFG_IMMR; |
| 312 | volatile memctl8xx_t *memctl; |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 313 | ushort i; |
| 314 | uchar *fb; |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 315 | int rs, gs, bs; |
| 316 | int r = 8, g = 8, b = 4; |
| 317 | int r1, g1, b1; |
| 318 | |
| 319 | immr->im_cpm.cp_pbpar &= ~PB_LCD_PWM; |
| 320 | immr->im_cpm.cp_pbodr &= ~PB_LCD_PWM; |
| 321 | immr->im_cpm.cp_pbdat &= ~PB_LCD_PWM; /* set to 0 = enabled */ |
| 322 | immr->im_cpm.cp_pbdir |= PB_LCD_PWM; |
| 323 | |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 324 | |
| 325 | /*----------------------------------------------------------------------------- */ |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 326 | /**/ |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 327 | /* Initialize the chip and the frame buffer driver. */ |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 328 | /**/ |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 329 | /*----------------------------------------------------------------------------- */ |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 330 | memctl = &immr->im_memctl; |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 331 | /* memctl->memc_or5 = 0xFFC007F0; / * 4 MB 17 WS or externel TA */ |
| 332 | /* memctl->memc_br5 = 0x80000801; / * Start at 0x80000000 */ |
| 333 | |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 334 | memctl->memc_or5 = 0xFFC00708; /* 4 MB 17 WS or externel TA */ |
| 335 | memctl->memc_br5 = 0x80080801; /* Start at 0x80080000 */ |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 336 | |
| 337 | |
| 338 | |
| 339 | |
| 340 | |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 341 | fb_info.VmemAddr = (unsigned char *) (S1D_PHYSICAL_VMEM_ADDR); |
| 342 | fb_info.RegAddr = (unsigned char *) (S1D_PHYSICAL_REG_ADDR); |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 343 | |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 344 | if ((((S1D_VALUE *) fb_info.RegAddr)[0] != 0x28) |
| 345 | || (((S1D_VALUE *) fb_info.RegAddr)[1] != 0x14)) { |
| 346 | printf ("Warning:LCD Controller S1D13706 not found\n"); |
| 347 | return; |
| 348 | } |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 349 | |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 350 | /* init controller */ |
| 351 | for (i = 0; i < sizeof (aS1DRegs) / sizeof (aS1DRegs[0]); i++) { |
| 352 | s1dReg = aS1DRegs[i].Index; |
| 353 | s1dValue = aS1DRegs[i].Value; |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 354 | /* printf("sid1 Index: %02x Register: %02x Wert: %02x\n",i, aS1DRegs[i].Index, aS1DRegs[i].Value); */ |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 355 | ((S1D_VALUE *) fb_info.RegAddr)[s1dReg / sizeof (S1D_VALUE)] = |
| 356 | s1dValue; |
| 357 | } |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 358 | |
| 359 | #undef MONOCHROME |
| 360 | #ifdef MONOCHROME |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 361 | switch (bd->bi_busfreq) { |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 362 | #if 0 |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 363 | case 24000000: |
| 364 | ((S1D_VALUE *) fb_info.RegAddr)[0x05] = 0x32; |
| 365 | ((S1D_VALUE *) fb_info.RegAddr)[0x12] = 0x28; |
| 366 | break; |
| 367 | case 32000000: |
| 368 | ((S1D_VALUE *) fb_info.RegAddr)[0x05] = 0x32; |
| 369 | ((S1D_VALUE *) fb_info.RegAddr)[0x12] = 0x33; |
| 370 | break; |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 371 | #endif |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 372 | case 40000000: |
| 373 | ((S1D_VALUE *) fb_info.RegAddr)[0x05] = 0x32; |
| 374 | ((S1D_VALUE *) fb_info.RegAddr)[0x12] = 0x40; |
| 375 | break; |
| 376 | case 48000000: |
| 377 | ((S1D_VALUE *) fb_info.RegAddr)[0x05] = 0x32; |
| 378 | ((S1D_VALUE *) fb_info.RegAddr)[0x12] = 0x4C; |
| 379 | break; |
| 380 | default: |
| 381 | printf ("KUP4K S1D1: unknown busfrequency: %ld assuming 64 MHz\n", |
| 382 | bd->bi_busfreq); |
| 383 | case 64000000: |
| 384 | ((S1D_VALUE *) fb_info.RegAddr)[0x05] = 0x32; |
| 385 | ((S1D_VALUE *) fb_info.RegAddr)[0x12] = 0x69; |
| 386 | break; |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 387 | } |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 388 | ((S1D_VALUE *) fb_info.RegAddr)[0x10] = 0x00; |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 389 | #else |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 390 | switch (bd->bi_busfreq) { |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 391 | #if 0 |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 392 | case 24000000: |
| 393 | ((S1D_VALUE *) fb_info.RegAddr)[0x05] = 0x22; |
| 394 | ((S1D_VALUE *) fb_info.RegAddr)[0x12] = 0x34; |
| 395 | break; |
| 396 | case 32000000: |
| 397 | ((S1D_VALUE *) fb_info.RegAddr)[0x05] = 0x32; |
| 398 | ((S1D_VALUE *) fb_info.RegAddr)[0x12] = 0x34; |
| 399 | break; |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 400 | #endif |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 401 | case 40000000: |
| 402 | ((S1D_VALUE *) fb_info.RegAddr)[0x05] = 0x32; |
| 403 | ((S1D_VALUE *) fb_info.RegAddr)[0x12] = 0x41; |
| 404 | break; |
| 405 | case 48000000: |
| 406 | ((S1D_VALUE *) fb_info.RegAddr)[0x05] = 0x22; |
| 407 | ((S1D_VALUE *) fb_info.RegAddr)[0x12] = 0x34; |
| 408 | break; |
| 409 | default: |
| 410 | printf ("KUP4K S1D1: unknown busfrequency: %ld assuming 64 MHz\n", |
| 411 | bd->bi_busfreq); |
| 412 | case 64000000: |
| 413 | ((S1D_VALUE *) fb_info.RegAddr)[0x05] = 0x32; |
| 414 | ((S1D_VALUE *) fb_info.RegAddr)[0x12] = 0x66; |
| 415 | break; |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 416 | } |
| 417 | #endif |
| 418 | |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 419 | |
| 420 | /* create and set colormap */ |
| 421 | rs = 256 / (r - 1); |
| 422 | gs = 256 / (g - 1); |
| 423 | bs = 256 / (b - 1); |
| 424 | for (i = 0; i < 256; i++) { |
| 425 | r1 = (rs * ((i / (g * b)) % r)) * 255; |
| 426 | g1 = (gs * ((i / b) % g)) * 255; |
| 427 | b1 = (bs * ((i) % b)) * 255; |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 428 | /* printf("%d %04x %04x %04x\n",i,r1>>4,g1>>4,b1>>4); */ |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 429 | S1D_WRITE_PALETTE (fb_info.RegAddr, i, (r1 >> 4), (g1 >> 4), |
| 430 | (b1 >> 4)); |
| 431 | } |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 432 | |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 433 | /* copy bitmap */ |
| 434 | fb = (char *) (fb_info.VmemAddr); |
| 435 | memcpy (fb, (uchar *) CONFIG_KUP4K_LOGO, 320 * 240); |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 436 | } |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 437 | #endif /* CONFIG_KUP4K_LOGO */ |
wdenk | 56f94be | 2002-11-05 16:35:14 +0000 | [diff] [blame] | 438 | |
wdenk | 90e7e42 | 2002-12-04 23:39:58 +0000 | [diff] [blame] | 439 | #ifdef CONFIG_IDE_LED |
| 440 | void ide_led (uchar led, uchar status) |
| 441 | { |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 442 | volatile immap_t *immap = (immap_t *) CFG_IMMR; |
| 443 | |
wdenk | 90e7e42 | 2002-12-04 23:39:58 +0000 | [diff] [blame] | 444 | /* We have one led for both pcmcia slots */ |
wdenk | 4e112c1 | 2003-06-03 23:54:09 +0000 | [diff] [blame^] | 445 | if (status) { /* led on */ |
wdenk | 90e7e42 | 2002-12-04 23:39:58 +0000 | [diff] [blame] | 446 | immap->im_ioport.iop_padat &= ~0x80; |
| 447 | } else { |
| 448 | immap->im_ioport.iop_padat |= 0x80; |
| 449 | } |
| 450 | } |
| 451 | #endif |