blob: 4266048981c678f8aa2531701b37f23fa84304c8 [file] [log] [blame]
wdenk2d24a3a2004-06-09 21:50:45 +00001/*
2 * board/mx1ads/mx1ads.c
wdenk49822e22004-06-19 21:19:10 +00003 *
wdenk2d24a3a2004-06-09 21:50:45 +00004 * (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 Denk1a459662013-07-08 09:37:19 +020010 * SPDX-License-Identifier: GPL-2.0+
wdenk2d24a3a2004-06-09 21:50:45 +000011 */
12
wdenk2d24a3a2004-06-09 21:50:45 +000013#include <common.h>
Ben Warrenb1c0eaa2009-08-25 13:09:37 -070014#include <netdev.h>
wdenk281e00a2004-08-01 22:48:16 +000015/*#include <mc9328.h>*/
wdenk86c98882005-04-03 14:26:46 +000016#include <asm/arch/imx-regs.h>
Anatolij Gustschin5076c7a2011-11-19 13:12:17 +000017#include <asm/io.h>
wdenk2d24a3a2004-06-09 21:50:45 +000018
Wolfgang Denkd87080b2006-03-31 18:32:53 +020019DECLARE_GLOBAL_DATA_PTR;
wdenk2d24a3a2004-06-09 21:50:45 +000020
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 Denkd87080b2006-03-31 18:32:53 +020047static inline void delay (unsigned long loops)
48{
wdenk2d24a3a2004-06-09 21:50:45 +000049 __asm__ volatile ("1:\n"
Wolfgang Denkd87080b2006-03-31 18:32:53 +020050 "subs %0, %1, #1\n"
51 "bne 1b":"=r" (loops):"0" (loops));
wdenk2d24a3a2004-06-09 21:50:45 +000052}
53
wdenk49822e22004-06-19 21:19:10 +000054#endif
wdenk2d24a3a2004-06-09 21:50:45 +000055
56/*
57 * Miscellaneous platform dependent initialisations
58 */
59
Wolfgang Denkd87080b2006-03-31 18:32:53 +020060void 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");
wdenk2d24a3a2004-06-09 21:50:45 +000065}
wdenk49822e22004-06-19 21:19:10 +000066
wdenk2d24a3a2004-06-09 21:50:45 +000067static u32 mc9328sid;
68
Fabio Estevame845f902011-06-11 15:16:32 +000069int board_early_init_f(void)
Wolfgang Denkd87080b2006-03-31 18:32:53 +020070{
Wolfgang Denkd87080b2006-03-31 18:32:53 +020071 mc9328sid = SIDR;
wdenk2d24a3a2004-06-09 21:50:45 +000072
Wolfgang Denkd87080b2006-03-31 18:32:53 +020073 GPCR = 0x000003AB; /* I/O pad driving strength */
wdenk2d24a3a2004-06-09 21:50:45 +000074
Wolfgang Denk53677ef2008-05-20 16:00:29 +020075 /* MX1_CS1U = 0x00000A00; */ /* SRAM initialization */
76/* MX1_CS1L = 0x11110601; */
wdenk2d24a3a2004-06-09 21:50:45 +000077
Wolfgang Denkd87080b2006-03-31 18:32:53 +020078 MPCTL0 = 0x04632410; /* setting for 150 MHz MCU PLL CLK */
wdenk2d24a3a2004-06-09 21:50:45 +000079
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 Denkd87080b2006-03-31 18:32:53 +020083 CSCR = 0xAF000403;
wdenk2d24a3a2004-06-09 21:50:45 +000084
Wolfgang Denkd87080b2006-03-31 18:32:53 +020085 CSCR |= 0x00200000; /* Trigger the restart bit(bit 21) */
86 CSCR &= 0xFFFF7FFF; /* Program PRESC bit(bit 15) to 0 to divide-by-1 */
wdenk2d24a3a2004-06-09 21:50:45 +000087
88/* setup cs4 for cs8900 ethernet */
wdenk49822e22004-06-19 21:19:10 +000089
Wolfgang Denkd87080b2006-03-31 18:32:53 +020090 CS4U = 0x00000F00; /* Initialize CS4 for CS8900 ethernet */
91 CS4L = 0x00001501;
wdenk49822e22004-06-19 21:19:10 +000092
Wolfgang Denkd87080b2006-03-31 18:32:53 +020093 GIUS (0) &= 0xFF3FFFFF;
94 GPR (0) &= 0xFF3FFFFF;
wdenk49822e22004-06-19 21:19:10 +000095
Anatolij Gustschin5076c7a2011-11-19 13:12:17 +000096 readl(0x1500000C);
97 readl(0x1500000C);
wdenk2d24a3a2004-06-09 21:50:45 +000098
Wolfgang Denkd87080b2006-03-31 18:32:53 +020099 SetAsynchMode ();
wdenk2d24a3a2004-06-09 21:50:45 +0000100
Wolfgang Denkd87080b2006-03-31 18:32:53 +0200101 icache_enable ();
102 dcache_enable ();
wdenk2d24a3a2004-06-09 21:50:45 +0000103
104/* set PERCLKs */
Wolfgang Denkd87080b2006-03-31 18:32:53 +0200105 PCDR = 0x00000055; /* set PERCLKS */
wdenk49822e22004-06-19 21:19:10 +0000106
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
wdenk2d24a3a2004-06-09 21:50:45 +0000109 * all sources selected as normal interrupt
110 */
wdenk2d24a3a2004-06-09 21:50:45 +0000111
wdenk281e00a2004-08-01 22:48:16 +0000112/* MX1_INTTYPEH = 0;
113 MX1_INTTYPEL = 0;
114*/
wdenk2d24a3a2004-06-09 21:50:45 +0000115 return 0;
116}
117
Fabio Estevame845f902011-06-11 15:16:32 +0000118int 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 Denkd87080b2006-03-31 18:32:53 +0200127int board_late_init (void)
128{
wdenk2d24a3a2004-06-09 21:50:45 +0000129
Wolfgang Denkd87080b2006-03-31 18:32:53 +0200130 setenv ("stdout", "serial");
131 setenv ("stderr", "serial");
wdenk2d24a3a2004-06-09 21:50:45 +0000132
Wolfgang Denkd87080b2006-03-31 18:32:53 +0200133 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;
wdenk2d24a3a2004-06-09 21:50:45 +0000146
Wolfgang Denkd87080b2006-03-31 18:32:53 +0200147 default:
148 printf ("MX1ADS board with UNKNOWN MC9328 cpu, Silicon ID 0x%08x \n",
149 mc9328sid);
150 break;
wdenk2d24a3a2004-06-09 21:50:45 +0000151 }
wdenk2d24a3a2004-06-09 21:50:45 +0000152 return 0;
wdenk49822e22004-06-19 21:19:10 +0000153}
154
Fabio Estevame845f902011-06-11 15:16:32 +0000155int dram_init(void)
156{
157 /* dram_init must store complete ramsize in gd->ram_size */
Albert ARIBAUDa55d23c2011-07-03 05:55:33 +0000158 gd->ram_size = get_ram_size((void *)PHYS_SDRAM_1,
Fabio Estevame845f902011-06-11 15:16:32 +0000159 PHYS_SDRAM_1_SIZE);
160 return 0;
161}
162
163void dram_init_banksize(void)
Wolfgang Denkd87080b2006-03-31 18:32:53 +0200164{
wdenk2d24a3a2004-06-09 21:50:45 +0000165 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
Wolfgang Denkd87080b2006-03-31 18:32:53 +0200166 gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
wdenk2d24a3a2004-06-09 21:50:45 +0000167}
Ben Warrenb1c0eaa2009-08-25 13:09:37 -0700168
169#ifdef CONFIG_CMD_NET
170int 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