wdenk | 2d24a3a | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 1 | /* |
| 2 | * board/mx1ads/mx1ads.c |
wdenk | 49822e2 | 2004-06-19 21:19:10 +0000 | [diff] [blame] | 3 | * |
wdenk | 2d24a3a | 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 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 10 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | 2d24a3a | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 11 | */ |
| 12 | |
wdenk | 2d24a3a | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 13 | #include <common.h> |
Ben Warren | b1c0eaa | 2009-08-25 13:09:37 -0700 | [diff] [blame] | 14 | #include <netdev.h> |
wdenk | 281e00a | 2004-08-01 22:48:16 +0000 | [diff] [blame] | 15 | /*#include <mc9328.h>*/ |
wdenk | 86c9888 | 2005-04-03 14:26:46 +0000 | [diff] [blame] | 16 | #include <asm/arch/imx-regs.h> |
Anatolij Gustschin | 5076c7a | 2011-11-19 13:12:17 +0000 | [diff] [blame] | 17 | #include <asm/io.h> |
wdenk | 2d24a3a | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 18 | |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 19 | DECLARE_GLOBAL_DATA_PTR; |
wdenk | 2d24a3a | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 20 | |
| 21 | #define FCLK_SPEED 1 |
| 22 | |
| 23 | #if FCLK_SPEED==0 /* Fout = 203MHz, Fin = 12MHz for Audio */ |
| 24 | #define M_MDIV 0xC3 |
| 25 | #define M_PDIV 0x4 |
| 26 | #define M_SDIV 0x1 |
| 27 | #elif FCLK_SPEED==1 /* Fout = 202.8MHz */ |
| 28 | #define M_MDIV 0xA1 |
| 29 | #define M_PDIV 0x3 |
| 30 | #define M_SDIV 0x1 |
| 31 | #endif |
| 32 | |
| 33 | #define USB_CLOCK 1 |
| 34 | |
| 35 | #if USB_CLOCK==0 |
| 36 | #define U_M_MDIV 0xA1 |
| 37 | #define U_M_PDIV 0x3 |
| 38 | #define U_M_SDIV 0x1 |
| 39 | #elif USB_CLOCK==1 |
| 40 | #define U_M_MDIV 0x48 |
| 41 | #define U_M_PDIV 0x3 |
| 42 | #define U_M_SDIV 0x2 |
| 43 | #endif |
| 44 | |
| 45 | #if 0 |
| 46 | |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 47 | static inline void delay (unsigned long loops) |
| 48 | { |
wdenk | 2d24a3a | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 49 | __asm__ volatile ("1:\n" |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 50 | "subs %0, %1, #1\n" |
| 51 | "bne 1b":"=r" (loops):"0" (loops)); |
wdenk | 2d24a3a | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 52 | } |
| 53 | |
wdenk | 49822e2 | 2004-06-19 21:19:10 +0000 | [diff] [blame] | 54 | #endif |
wdenk | 2d24a3a | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 55 | |
| 56 | /* |
| 57 | * Miscellaneous platform dependent initialisations |
| 58 | */ |
| 59 | |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 60 | void SetAsynchMode (void) |
| 61 | { |
| 62 | __asm__ ("mrc p15,0,r0,c1,c0,0 \n" |
| 63 | "mov r2, #0xC0000000 \n" |
| 64 | "orr r0,r2,r0 \n" "mcr p15,0,r0,c1,c0,0 \n"); |
wdenk | 2d24a3a | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 65 | } |
wdenk | 49822e2 | 2004-06-19 21:19:10 +0000 | [diff] [blame] | 66 | |
wdenk | 2d24a3a | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 67 | static u32 mc9328sid; |
| 68 | |
Fabio Estevam | e845f90 | 2011-06-11 15:16:32 +0000 | [diff] [blame] | 69 | int board_early_init_f(void) |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 70 | { |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 71 | mc9328sid = SIDR; |
wdenk | 2d24a3a | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 72 | |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 73 | GPCR = 0x000003AB; /* I/O pad driving strength */ |
wdenk | 2d24a3a | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 74 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 75 | /* MX1_CS1U = 0x00000A00; */ /* SRAM initialization */ |
| 76 | /* MX1_CS1L = 0x11110601; */ |
wdenk | 2d24a3a | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 77 | |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 78 | MPCTL0 = 0x04632410; /* setting for 150 MHz MCU PLL CLK */ |
wdenk | 2d24a3a | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 79 | |
| 80 | /* set FCLK divider 1 (i.e. FCLK to MCU PLL CLK) and |
| 81 | * BCLK divider to 2 (i.e. BCLK to 48 MHz) |
| 82 | */ |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 83 | CSCR = 0xAF000403; |
wdenk | 2d24a3a | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 84 | |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 85 | CSCR |= 0x00200000; /* Trigger the restart bit(bit 21) */ |
| 86 | CSCR &= 0xFFFF7FFF; /* Program PRESC bit(bit 15) to 0 to divide-by-1 */ |
wdenk | 2d24a3a | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 87 | |
| 88 | /* setup cs4 for cs8900 ethernet */ |
wdenk | 49822e2 | 2004-06-19 21:19:10 +0000 | [diff] [blame] | 89 | |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 90 | CS4U = 0x00000F00; /* Initialize CS4 for CS8900 ethernet */ |
| 91 | CS4L = 0x00001501; |
wdenk | 49822e2 | 2004-06-19 21:19:10 +0000 | [diff] [blame] | 92 | |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 93 | GIUS (0) &= 0xFF3FFFFF; |
| 94 | GPR (0) &= 0xFF3FFFFF; |
wdenk | 49822e2 | 2004-06-19 21:19:10 +0000 | [diff] [blame] | 95 | |
Anatolij Gustschin | 5076c7a | 2011-11-19 13:12:17 +0000 | [diff] [blame] | 96 | readl(0x1500000C); |
| 97 | readl(0x1500000C); |
wdenk | 2d24a3a | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 98 | |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 99 | SetAsynchMode (); |
wdenk | 2d24a3a | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 100 | |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 101 | icache_enable (); |
| 102 | dcache_enable (); |
wdenk | 2d24a3a | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 103 | |
| 104 | /* set PERCLKs */ |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 105 | PCDR = 0x00000055; /* set PERCLKS */ |
wdenk | 49822e2 | 2004-06-19 21:19:10 +0000 | [diff] [blame] | 106 | |
| 107 | /* PERCLK3 is only used by SSI so the SSI driver can set it any value it likes |
| 108 | * PERCLK1 and PERCLK2 are shared so DO NOT change it in any other place |
wdenk | 2d24a3a | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 109 | * all sources selected as normal interrupt |
| 110 | */ |
wdenk | 2d24a3a | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 111 | |
wdenk | 281e00a | 2004-08-01 22:48:16 +0000 | [diff] [blame] | 112 | /* MX1_INTTYPEH = 0; |
| 113 | MX1_INTTYPEL = 0; |
| 114 | */ |
wdenk | 2d24a3a | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 115 | return 0; |
| 116 | } |
| 117 | |
Fabio Estevam | e845f90 | 2011-06-11 15:16:32 +0000 | [diff] [blame] | 118 | int board_init(void) |
| 119 | { |
| 120 | gd->bd->bi_arch_number = MACH_TYPE_MX1ADS; |
| 121 | |
| 122 | gd->bd->bi_boot_params = 0x08000100; /* adress of boot parameters */ |
| 123 | |
| 124 | return 0; |
| 125 | } |
| 126 | |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 127 | int board_late_init (void) |
| 128 | { |
wdenk | 2d24a3a | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 129 | |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 130 | setenv ("stdout", "serial"); |
| 131 | setenv ("stderr", "serial"); |
wdenk | 2d24a3a | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 132 | |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 133 | switch (mc9328sid) { |
| 134 | case 0x0005901d: |
| 135 | printf ("MX1ADS board with MC9328 MX1 (0L44N), Silicon ID 0x%08x \n\n", |
| 136 | mc9328sid); |
| 137 | break; |
| 138 | case 0x04d4c01d: |
| 139 | printf ("MX1ADS board with MC9328 MXL (1L45N), Silicon ID 0x%08x \n\n", |
| 140 | mc9328sid); |
| 141 | break; |
| 142 | case 0x00d4c01d: |
| 143 | printf ("MX1ADS board with MC9328 MXL (2L45N), Silicon ID 0x%08x \n\n", |
| 144 | mc9328sid); |
| 145 | break; |
wdenk | 2d24a3a | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 146 | |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 147 | default: |
| 148 | printf ("MX1ADS board with UNKNOWN MC9328 cpu, Silicon ID 0x%08x \n", |
| 149 | mc9328sid); |
| 150 | break; |
wdenk | 2d24a3a | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 151 | } |
wdenk | 2d24a3a | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 152 | return 0; |
wdenk | 49822e2 | 2004-06-19 21:19:10 +0000 | [diff] [blame] | 153 | } |
| 154 | |
Fabio Estevam | e845f90 | 2011-06-11 15:16:32 +0000 | [diff] [blame] | 155 | int dram_init(void) |
| 156 | { |
| 157 | /* dram_init must store complete ramsize in gd->ram_size */ |
Albert ARIBAUD | a55d23c | 2011-07-03 05:55:33 +0000 | [diff] [blame] | 158 | gd->ram_size = get_ram_size((void *)PHYS_SDRAM_1, |
Fabio Estevam | e845f90 | 2011-06-11 15:16:32 +0000 | [diff] [blame] | 159 | PHYS_SDRAM_1_SIZE); |
| 160 | return 0; |
| 161 | } |
| 162 | |
| 163 | void dram_init_banksize(void) |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 164 | { |
wdenk | 2d24a3a | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 165 | gd->bd->bi_dram[0].start = PHYS_SDRAM_1; |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 166 | gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE; |
wdenk | 2d24a3a | 2004-06-09 21:50:45 +0000 | [diff] [blame] | 167 | } |
Ben Warren | b1c0eaa | 2009-08-25 13:09:37 -0700 | [diff] [blame] | 168 | |
| 169 | #ifdef CONFIG_CMD_NET |
| 170 | int board_eth_init(bd_t *bis) |
| 171 | { |
| 172 | int rc = 0; |
| 173 | #ifdef CONFIG_CS8900 |
| 174 | rc = cs8900_initialize(0, CONFIG_CS8900_BASE); |
| 175 | #endif |
| 176 | return rc; |
| 177 | } |
| 178 | #endif |