blob: bfc47e0b4e52f4657827c1e42be7eae4f74184b7 [file] [log] [blame]
wdenkcd0a9de2004-02-23 20:48:38 +00001/*
2 * (C) Copyright 2004
3 * Tolunay Orkun, Nextio Inc., torkun@nextio.com
4 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
wdenkcd0a9de2004-02-23 20:48:38 +00006 */
7
wdenkcd0a9de2004-02-23 20:48:38 +00008#include <common.h>
wdenk4d13cba2004-03-14 14:09:05 +00009#include <asm/processor.h>
wdenkcd0a9de2004-02-23 20:48:38 +000010#include <i2c.h>
11#include <miiphy.h>
Stefan Roeseb36df562010-09-09 19:18:00 +020012#include <asm/ppc4xx-emac.h>
wdenkcd0a9de2004-02-23 20:48:38 +000013
Stefan Roesebbeff302008-06-02 17:37:28 +020014void sdram_init(void);
15
wdenkcd0a9de2004-02-23 20:48:38 +000016/*
17 * Configuration data for AMIS FS6377-01 Programmable 3-PLL Clock Generator
18 *
19 * CLKA output => Epson LCD Controller
20 * CLKB output => Not Connected
21 * CLKC output => Ethernet
22 * CLKD output => UART external clock
23 *
24 * Note: these values are obtained from device after init by micromonitor
25*/
26uchar pll_fs6377_regs[16] = {
27 0x28, 0xef, 0x53, 0x03, 0x4b, 0x80, 0x32, 0x80,
28 0x94, 0x32, 0x80, 0xd4, 0x56, 0xf6, 0xf6, 0xe0 };
29
30/*
31 * pll_init: Initialize AMIS IC FS6377-01 PLL
32 *
33 * PLL supplies Epson LCD Clock, Ethernet Clock and UART external clock
34 *
35 */
36int pll_init(void)
37{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020038 i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
wdenkcd0a9de2004-02-23 20:48:38 +000039
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020040 return i2c_write(CONFIG_SYS_I2C_PLL_ADDR, 0, 1,
wdenkcd0a9de2004-02-23 20:48:38 +000041 (uchar *) pll_fs6377_regs, sizeof(pll_fs6377_regs));
42}
43
44/*
wdenk4d13cba2004-03-14 14:09:05 +000045 * board_early_init_f: do early board initialization
wdenkcd0a9de2004-02-23 20:48:38 +000046 *
47 */
wdenk4d13cba2004-03-14 14:09:05 +000048int board_early_init_f(void)
wdenkcd0a9de2004-02-23 20:48:38 +000049{
50 /* initialize PLL so UART, LCD, Ethernet clocked at correctly */
51 (void) get_clocks();
52 pll_init();
53
54 /*-------------------------------------------------------------------------+
55 | Interrupt controller setup for the Walnut board.
56 | Note: IRQ 0-15 405GP internally generated; active high; level sensitive
57 | IRQ 16 405GP internally generated; active low; level sensitive
58 | IRQ 17-24 RESERVED
59 | IRQ 25 (EXT IRQ 0) FPGA; active high; level sensitive
60 | IRQ 26 (EXT IRQ 1) SMI; active high; level sensitive
61 | IRQ 27 (EXT IRQ 2) Not Used
62 | IRQ 28 (EXT IRQ 3) PCI SLOT 3; active low; level sensitive
63 | IRQ 29 (EXT IRQ 4) PCI SLOT 2; active low; level sensitive
64 | IRQ 30 (EXT IRQ 5) PCI SLOT 1; active low; level sensitive
65 | IRQ 31 (EXT IRQ 6) PCI SLOT 0; active low; level sensitive
66 | Note for Walnut board:
67 | An interrupt taken for the FPGA (IRQ 25) indicates that either
68 | the Mouse, Keyboard, IRDA, or External Expansion caused the
69 | interrupt. The FPGA must be read to determine which device
70 | caused the interrupt. The default setting of the FPGA clears
71 |
72 +-------------------------------------------------------------------------*/
73
Stefan Roese952e7762009-09-24 09:55:50 +020074 mtdcr (UIC0SR, 0xFFFFFFFF); /* clear all ints */
75 mtdcr (UIC0ER, 0x00000000); /* disable all ints */
76 mtdcr (UIC0CR, 0x00000000); /* set all to be non-critical */
77 mtdcr (UIC0PR, 0xFFFFFF83); /* set int polarities */
78 mtdcr (UIC0TR, 0x10000000); /* set int trigger levels */
79 mtdcr (UIC0VCR, 0x00000001); /* set vect base=0,INT0 highest priority */
80 mtdcr (UIC0SR, 0xFFFFFFFF); /* clear all ints */
wdenkcd0a9de2004-02-23 20:48:38 +000081
Stefan Roesed1c3b272009-09-09 16:25:29 +020082 mtebc (EBC0_CFG, 0xa8400000); /* EBC always driven */
wdenkcd0a9de2004-02-23 20:48:38 +000083
84 return 0; /* success */
85}
86
87/*
88 * checkboard: identify/verify the board we are running
89 *
90 * Remark: we just assume it is correct board here!
91 *
92 */
93int checkboard(void)
94{
95 printf("BOARD: Cogent CSB272\n");
96
97 return 0; /* success */
98}
99
100/*
101 * initram: Determine the size of mounted DRAM
102 *
103 * Size is determined by reading SDRAM configuration registers as
104 * configured by initialization code
105 *
106 */
Becky Bruce9973e3c2008-06-09 16:03:40 -0500107phys_size_t initdram (int board_type)
wdenkcd0a9de2004-02-23 20:48:38 +0000108{
109 ulong tot_size;
110 ulong bank_size;
111 ulong tmp;
112
Stefan Roesebbeff302008-06-02 17:37:28 +0200113 /*
114 * ToDo: Move the asm init routine sdram_init() to this C file,
115 * or even better use some common ppc4xx code available
Stefan Roesea47a12b2010-04-15 16:07:28 +0200116 * in arch/powerpc/cpu/ppc4xx
Stefan Roesebbeff302008-06-02 17:37:28 +0200117 */
118 sdram_init();
119
wdenkcd0a9de2004-02-23 20:48:38 +0000120 tot_size = 0;
121
Stefan Roese95b602b2009-09-24 13:59:57 +0200122 mtdcr (SDRAM0_CFGADDR, SDRAM0_B0CR);
Stefan Roesed1c3b272009-09-09 16:25:29 +0200123 tmp = mfdcr (SDRAM0_CFGDATA);
wdenkcd0a9de2004-02-23 20:48:38 +0000124 if (tmp & 0x00000001) {
125 bank_size = 0x00400000 << ((tmp >> 17) & 0x7);
126 tot_size += bank_size;
127 }
128
Stefan Roese95b602b2009-09-24 13:59:57 +0200129 mtdcr (SDRAM0_CFGADDR, SDRAM0_B1CR);
Stefan Roesed1c3b272009-09-09 16:25:29 +0200130 tmp = mfdcr (SDRAM0_CFGDATA);
wdenkcd0a9de2004-02-23 20:48:38 +0000131 if (tmp & 0x00000001) {
132 bank_size = 0x00400000 << ((tmp >> 17) & 0x7);
133 tot_size += bank_size;
134 }
135
Stefan Roese95b602b2009-09-24 13:59:57 +0200136 mtdcr (SDRAM0_CFGADDR, SDRAM0_B2CR);
Stefan Roesed1c3b272009-09-09 16:25:29 +0200137 tmp = mfdcr (SDRAM0_CFGDATA);
wdenkcd0a9de2004-02-23 20:48:38 +0000138 if (tmp & 0x00000001) {
139 bank_size = 0x00400000 << ((tmp >> 17) & 0x7);
140 tot_size += bank_size;
141 }
142
Stefan Roese95b602b2009-09-24 13:59:57 +0200143 mtdcr (SDRAM0_CFGADDR, SDRAM0_B3CR);
Stefan Roesed1c3b272009-09-09 16:25:29 +0200144 tmp = mfdcr (SDRAM0_CFGDATA);
wdenkcd0a9de2004-02-23 20:48:38 +0000145 if (tmp & 0x00000001) {
146 bank_size = 0x00400000 << ((tmp >> 17) & 0x7);
147 tot_size += bank_size;
148 }
149
150 return tot_size;
151}
152
153/*
154 * last_stage_init: final configurations (such as PHY etc)
155 *
156 */
157int last_stage_init(void)
158{
159 /* initialize the PHY */
Marian Balakowicz63ff0042005-10-28 22:30:33 +0200160 miiphy_reset("ppc_4xx_eth0", CONFIG_PHY_ADDR);
161
162 /* AUTO neg */
Mike Frysinger8ef583a2010-12-23 15:40:12 -0500163 miiphy_write("ppc_4xx_eth0", CONFIG_PHY_ADDR, MII_BMCR,
164 BMCR_ANENABLE | BMCR_ANRESTART);
Marian Balakowicz63ff0042005-10-28 22:30:33 +0200165
166 /* LEDs */
Mike Frysinger8ef583a2010-12-23 15:40:12 -0500167 miiphy_write("ppc_4xx_eth0", CONFIG_PHY_ADDR, MII_NWAYTEST, 0x0d08);
Marian Balakowicz63ff0042005-10-28 22:30:33 +0200168
wdenkcd0a9de2004-02-23 20:48:38 +0000169
170 return 0; /* success */
171}