wdenk | 9f664dd | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 1 | /* |
| 2 | * board/mx1ads/mx1ads.c |
wdenk | 9e930b6 | 2004-06-19 21:19:10 +0000 | [diff] [blame] | 3 | * |
wdenk | 9f664dd | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 4 | * (c) Copyright 2004 |
| 5 | * Techware Information Technology, Inc. |
| 6 | * http://www.techware.com.tw/ |
| 7 | * |
| 8 | * Ming-Len Wu <minglen_wu@techware.com.tw> |
| 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 | |
wdenk | 9f664dd | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 26 | #include <common.h> |
wdenk | 7ac1610 | 2004-08-01 22:48:16 +0000 | [diff] [blame] | 27 | /*#include <mc9328.h>*/ |
| 28 | #include <asm/arch-arm920t/imx-regs.h> |
wdenk | 9f664dd | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 29 | |
| 30 | /* ------------------------------------------------------------------------- */ |
| 31 | |
| 32 | #define FCLK_SPEED 1 |
| 33 | |
| 34 | #if FCLK_SPEED==0 /* Fout = 203MHz, Fin = 12MHz for Audio */ |
| 35 | #define M_MDIV 0xC3 |
| 36 | #define M_PDIV 0x4 |
| 37 | #define M_SDIV 0x1 |
| 38 | #elif FCLK_SPEED==1 /* Fout = 202.8MHz */ |
| 39 | #define M_MDIV 0xA1 |
| 40 | #define M_PDIV 0x3 |
| 41 | #define M_SDIV 0x1 |
| 42 | #endif |
| 43 | |
| 44 | #define USB_CLOCK 1 |
| 45 | |
| 46 | #if USB_CLOCK==0 |
| 47 | #define U_M_MDIV 0xA1 |
| 48 | #define U_M_PDIV 0x3 |
| 49 | #define U_M_SDIV 0x1 |
| 50 | #elif USB_CLOCK==1 |
| 51 | #define U_M_MDIV 0x48 |
| 52 | #define U_M_PDIV 0x3 |
| 53 | #define U_M_SDIV 0x2 |
| 54 | #endif |
| 55 | |
| 56 | #if 0 |
| 57 | |
| 58 | static inline void delay (unsigned long loops) { |
| 59 | __asm__ volatile ("1:\n" |
| 60 | "subs %0, %1, #1\n" |
| 61 | "bne 1b":"=r" (loops):"0" (loops)); |
| 62 | } |
| 63 | |
wdenk | 9e930b6 | 2004-06-19 21:19:10 +0000 | [diff] [blame] | 64 | #endif |
wdenk | 9f664dd | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 65 | |
| 66 | /* |
| 67 | * Miscellaneous platform dependent initialisations |
| 68 | */ |
| 69 | |
wdenk | 9f664dd | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 70 | void SetAsynchMode(void) { |
| 71 | __asm__ ( |
| 72 | "mrc p15,0,r0,c1,c0,0 \n" |
| 73 | "mov r2, #0xC0000000 \n" |
| 74 | "orr r0,r2,r0 \n" |
| 75 | "mcr p15,0,r0,c1,c0,0 \n" |
| 76 | ); |
| 77 | } |
wdenk | 9e930b6 | 2004-06-19 21:19:10 +0000 | [diff] [blame] | 78 | |
wdenk | 9f664dd | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 79 | static u32 mc9328sid; |
| 80 | |
| 81 | int board_init (void) { |
| 82 | |
| 83 | DECLARE_GLOBAL_DATA_PTR; |
| 84 | |
| 85 | volatile unsigned int tmp; |
| 86 | |
wdenk | 7ac1610 | 2004-08-01 22:48:16 +0000 | [diff] [blame] | 87 | mc9328sid = SIDR; |
wdenk | 9f664dd | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 88 | |
wdenk | 7ac1610 | 2004-08-01 22:48:16 +0000 | [diff] [blame] | 89 | GPCR = 0x000003AB; /* I/O pad driving strength */ |
wdenk | 9e930b6 | 2004-06-19 21:19:10 +0000 | [diff] [blame] | 90 | |
wdenk | 9f664dd | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 91 | /* MX1_CS1U = 0x00000A00; */ /* SRAM initialization */ |
| 92 | /* MX1_CS1L = 0x11110601; */ |
wdenk | 9f664dd | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 93 | |
wdenk | 7ac1610 | 2004-08-01 22:48:16 +0000 | [diff] [blame] | 94 | MPCTL0 = 0x04632410; /* setting for 150 MHz MCU PLL CLK */ |
wdenk | 9f664dd | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 95 | |
| 96 | /* set FCLK divider 1 (i.e. FCLK to MCU PLL CLK) and |
| 97 | * BCLK divider to 2 (i.e. BCLK to 48 MHz) |
| 98 | */ |
wdenk | 7ac1610 | 2004-08-01 22:48:16 +0000 | [diff] [blame] | 99 | CSCR = 0xAF000403; |
wdenk | 9f664dd | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 100 | |
wdenk | 7ac1610 | 2004-08-01 22:48:16 +0000 | [diff] [blame] | 101 | CSCR |= 0x00200000; /* Trigger the restart bit(bit 21) */ |
| 102 | CSCR &= 0xFFFF7FFF; /* Program PRESC bit(bit 15) to 0 to divide-by-1 */ |
wdenk | 9f664dd | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 103 | |
| 104 | /* setup cs4 for cs8900 ethernet */ |
wdenk | 9e930b6 | 2004-06-19 21:19:10 +0000 | [diff] [blame] | 105 | |
wdenk | 7ac1610 | 2004-08-01 22:48:16 +0000 | [diff] [blame] | 106 | CS4U = 0x00000F00; /* Initialize CS4 for CS8900 ethernet */ |
| 107 | CS4L = 0x00001501; |
wdenk | 9e930b6 | 2004-06-19 21:19:10 +0000 | [diff] [blame] | 108 | |
wdenk | 7ac1610 | 2004-08-01 22:48:16 +0000 | [diff] [blame] | 109 | GIUS(0) &= 0xFF3FFFFF; |
| 110 | GPR(0) &= 0xFF3FFFFF; |
wdenk | 9e930b6 | 2004-06-19 21:19:10 +0000 | [diff] [blame] | 111 | |
wdenk | 9f664dd | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 112 | tmp = *(unsigned int *)(0x1500000C); |
| 113 | tmp = *(unsigned int *)(0x1500000C); |
| 114 | |
wdenk | 9f664dd | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 115 | SetAsynchMode(); |
| 116 | |
wdenk | 767fbd4 | 2004-10-10 18:41:04 +0000 | [diff] [blame] | 117 | gd->bd->bi_arch_number = MACH_TYPE_MX1ADS; |
wdenk | 9f664dd | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 118 | |
| 119 | gd->bd->bi_boot_params = 0x08000100; /* adress of boot parameters */ |
| 120 | |
| 121 | icache_enable(); |
| 122 | dcache_enable(); |
| 123 | |
| 124 | /* set PERCLKs */ |
wdenk | 7ac1610 | 2004-08-01 22:48:16 +0000 | [diff] [blame] | 125 | PCDR = 0x00000055; /* set PERCLKS */ |
wdenk | 9e930b6 | 2004-06-19 21:19:10 +0000 | [diff] [blame] | 126 | |
| 127 | /* PERCLK3 is only used by SSI so the SSI driver can set it any value it likes |
| 128 | * PERCLK1 and PERCLK2 are shared so DO NOT change it in any other place |
wdenk | 9f664dd | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 129 | * all sources selected as normal interrupt |
| 130 | */ |
wdenk | 9f664dd | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 131 | |
wdenk | 7ac1610 | 2004-08-01 22:48:16 +0000 | [diff] [blame] | 132 | /* MX1_INTTYPEH = 0; |
| 133 | MX1_INTTYPEL = 0; |
| 134 | */ |
wdenk | 9f664dd | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 135 | return 0; |
| 136 | } |
| 137 | |
wdenk | 9f664dd | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 138 | int board_late_init(void) { |
| 139 | |
| 140 | setenv("stdout", "serial"); |
| 141 | setenv("stderr", "serial"); |
| 142 | |
| 143 | switch (mc9328sid) { |
| 144 | case 0x0005901d : |
wdenk | 9e930b6 | 2004-06-19 21:19:10 +0000 | [diff] [blame] | 145 | printf ("MX1ADS board with MC9328 MX1 (0L44N), Silicon ID 0x%08x \n\n",mc9328sid); |
wdenk | 9f664dd | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 146 | break; |
| 147 | case 0x04d4c01d : |
wdenk | 9e930b6 | 2004-06-19 21:19:10 +0000 | [diff] [blame] | 148 | printf ("MX1ADS board with MC9328 MXL (1L45N), Silicon ID 0x%08x \n\n",mc9328sid); |
wdenk | 9f664dd | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 149 | break; |
| 150 | case 0x00d4c01d : |
wdenk | 9e930b6 | 2004-06-19 21:19:10 +0000 | [diff] [blame] | 151 | printf ("MX1ADS board with MC9328 MXL (2L45N), Silicon ID 0x%08x \n\n",mc9328sid); |
wdenk | 9f664dd | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 152 | break; |
| 153 | |
| 154 | default : |
wdenk | 9e930b6 | 2004-06-19 21:19:10 +0000 | [diff] [blame] | 155 | printf ("MX1ADS board with UNKNOWN MC9328 cpu, Silicon ID 0x%08x \n",mc9328sid); |
wdenk | 9f664dd | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 156 | break; |
wdenk | 9f664dd | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 157 | } |
wdenk | 9f664dd | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 158 | return 0; |
wdenk | 9e930b6 | 2004-06-19 21:19:10 +0000 | [diff] [blame] | 159 | } |
| 160 | |
wdenk | 9f664dd | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 161 | int dram_init (void) { |
| 162 | DECLARE_GLOBAL_DATA_PTR; |
| 163 | |
| 164 | gd->bd->bi_dram[0].start = PHYS_SDRAM_1; |
| 165 | gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE; |
| 166 | |
| 167 | return 0; |
| 168 | } |