wdenk | f70cbb2 | 2004-02-23 20:48:38 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2004 |
| 3 | * Tolunay Orkun, Nextio Inc., torkun@nextio.com |
| 4 | * |
Wolfgang Denk | bd8ec7e | 2013-10-07 13:07:26 +0200 | [diff] [blame^] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | f70cbb2 | 2004-02-23 20:48:38 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
wdenk | f70cbb2 | 2004-02-23 20:48:38 +0000 | [diff] [blame] | 8 | #include <common.h> |
wdenk | 369d43d | 2004-03-14 14:09:05 +0000 | [diff] [blame] | 9 | #include <asm/processor.h> |
wdenk | f70cbb2 | 2004-02-23 20:48:38 +0000 | [diff] [blame] | 10 | #include <i2c.h> |
| 11 | #include <miiphy.h> |
Stefan Roese | 247e9d7 | 2010-09-09 19:18:00 +0200 | [diff] [blame] | 12 | #include <asm/ppc4xx-emac.h> |
wdenk | f70cbb2 | 2004-02-23 20:48:38 +0000 | [diff] [blame] | 13 | |
Stefan Roese | cdb0470 | 2008-06-02 17:37:28 +0200 | [diff] [blame] | 14 | void sdram_init(void); |
| 15 | |
wdenk | f70cbb2 | 2004-02-23 20:48:38 +0000 | [diff] [blame] | 16 | /* |
| 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 | */ |
| 26 | uchar 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 | */ |
| 36 | int pll_init(void) |
| 37 | { |
Dirk Eibach | 42b204f | 2013-04-25 02:40:01 +0000 | [diff] [blame] | 38 | i2c_set_bus_num(0); |
wdenk | f70cbb2 | 2004-02-23 20:48:38 +0000 | [diff] [blame] | 39 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 40 | return i2c_write(CONFIG_SYS_I2C_PLL_ADDR, 0, 1, |
wdenk | f70cbb2 | 2004-02-23 20:48:38 +0000 | [diff] [blame] | 41 | (uchar *) pll_fs6377_regs, sizeof(pll_fs6377_regs)); |
| 42 | } |
| 43 | |
| 44 | /* |
wdenk | 369d43d | 2004-03-14 14:09:05 +0000 | [diff] [blame] | 45 | * board_early_init_f: do early board initialization |
wdenk | f70cbb2 | 2004-02-23 20:48:38 +0000 | [diff] [blame] | 46 | * |
| 47 | */ |
wdenk | 369d43d | 2004-03-14 14:09:05 +0000 | [diff] [blame] | 48 | int board_early_init_f(void) |
wdenk | f70cbb2 | 2004-02-23 20:48:38 +0000 | [diff] [blame] | 49 | { |
| 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 Roese | 707fd36 | 2009-09-24 09:55:50 +0200 | [diff] [blame] | 74 | 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 */ |
wdenk | f70cbb2 | 2004-02-23 20:48:38 +0000 | [diff] [blame] | 81 | |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 82 | mtebc (EBC0_CFG, 0xa8400000); /* EBC always driven */ |
wdenk | f70cbb2 | 2004-02-23 20:48:38 +0000 | [diff] [blame] | 83 | |
| 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 | */ |
| 93 | int 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 Bruce | bd99ae7 | 2008-06-09 16:03:40 -0500 | [diff] [blame] | 107 | phys_size_t initdram (int board_type) |
wdenk | f70cbb2 | 2004-02-23 20:48:38 +0000 | [diff] [blame] | 108 | { |
| 109 | ulong tot_size; |
| 110 | ulong bank_size; |
| 111 | ulong tmp; |
| 112 | |
Stefan Roese | cdb0470 | 2008-06-02 17:37:28 +0200 | [diff] [blame] | 113 | /* |
| 114 | * ToDo: Move the asm init routine sdram_init() to this C file, |
| 115 | * or even better use some common ppc4xx code available |
Stefan Roese | 88fbf93 | 2010-04-15 16:07:28 +0200 | [diff] [blame] | 116 | * in arch/powerpc/cpu/ppc4xx |
Stefan Roese | cdb0470 | 2008-06-02 17:37:28 +0200 | [diff] [blame] | 117 | */ |
| 118 | sdram_init(); |
| 119 | |
wdenk | f70cbb2 | 2004-02-23 20:48:38 +0000 | [diff] [blame] | 120 | tot_size = 0; |
| 121 | |
Stefan Roese | 6987e65 | 2009-09-24 13:59:57 +0200 | [diff] [blame] | 122 | mtdcr (SDRAM0_CFGADDR, SDRAM0_B0CR); |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 123 | tmp = mfdcr (SDRAM0_CFGDATA); |
wdenk | f70cbb2 | 2004-02-23 20:48:38 +0000 | [diff] [blame] | 124 | if (tmp & 0x00000001) { |
| 125 | bank_size = 0x00400000 << ((tmp >> 17) & 0x7); |
| 126 | tot_size += bank_size; |
| 127 | } |
| 128 | |
Stefan Roese | 6987e65 | 2009-09-24 13:59:57 +0200 | [diff] [blame] | 129 | mtdcr (SDRAM0_CFGADDR, SDRAM0_B1CR); |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 130 | tmp = mfdcr (SDRAM0_CFGDATA); |
wdenk | f70cbb2 | 2004-02-23 20:48:38 +0000 | [diff] [blame] | 131 | if (tmp & 0x00000001) { |
| 132 | bank_size = 0x00400000 << ((tmp >> 17) & 0x7); |
| 133 | tot_size += bank_size; |
| 134 | } |
| 135 | |
Stefan Roese | 6987e65 | 2009-09-24 13:59:57 +0200 | [diff] [blame] | 136 | mtdcr (SDRAM0_CFGADDR, SDRAM0_B2CR); |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 137 | tmp = mfdcr (SDRAM0_CFGDATA); |
wdenk | f70cbb2 | 2004-02-23 20:48:38 +0000 | [diff] [blame] | 138 | if (tmp & 0x00000001) { |
| 139 | bank_size = 0x00400000 << ((tmp >> 17) & 0x7); |
| 140 | tot_size += bank_size; |
| 141 | } |
| 142 | |
Stefan Roese | 6987e65 | 2009-09-24 13:59:57 +0200 | [diff] [blame] | 143 | mtdcr (SDRAM0_CFGADDR, SDRAM0_B3CR); |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 144 | tmp = mfdcr (SDRAM0_CFGDATA); |
wdenk | f70cbb2 | 2004-02-23 20:48:38 +0000 | [diff] [blame] | 145 | 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 | */ |
| 157 | int last_stage_init(void) |
| 158 | { |
| 159 | /* initialize the PHY */ |
Marian Balakowicz | aab8c49 | 2005-10-28 22:30:33 +0200 | [diff] [blame] | 160 | miiphy_reset("ppc_4xx_eth0", CONFIG_PHY_ADDR); |
| 161 | |
| 162 | /* AUTO neg */ |
Mike Frysinger | d63ee71 | 2010-12-23 15:40:12 -0500 | [diff] [blame] | 163 | miiphy_write("ppc_4xx_eth0", CONFIG_PHY_ADDR, MII_BMCR, |
| 164 | BMCR_ANENABLE | BMCR_ANRESTART); |
Marian Balakowicz | aab8c49 | 2005-10-28 22:30:33 +0200 | [diff] [blame] | 165 | |
| 166 | /* LEDs */ |
Mike Frysinger | d63ee71 | 2010-12-23 15:40:12 -0500 | [diff] [blame] | 167 | miiphy_write("ppc_4xx_eth0", CONFIG_PHY_ADDR, MII_NWAYTEST, 0x0d08); |
Marian Balakowicz | aab8c49 | 2005-10-28 22:30:33 +0200 | [diff] [blame] | 168 | |
wdenk | f70cbb2 | 2004-02-23 20:48:38 +0000 | [diff] [blame] | 169 | |
| 170 | return 0; /* success */ |
| 171 | } |