wdenk | 935ecca | 2002-08-06 20:46:37 +0000 | [diff] [blame] | 1 | /*----------------------------------------------------------------------------+ |
Josh Boyer | 3177349 | 2009-08-07 13:53:20 -0400 | [diff] [blame] | 2 | | This source code is dual-licensed. You may use it under the terms of |
| 3 | | the GNU General Public License version 2, or under the license below. |
wdenk | 935ecca | 2002-08-06 20:46:37 +0000 | [diff] [blame] | 4 | | |
| 5 | | This source code has been made available to you by IBM on an AS-IS |
| 6 | | basis. Anyone receiving this source is licensed under IBM |
| 7 | | copyrights to use it in any way he or she deems fit, including |
| 8 | | copying it, modifying it, compiling it, and redistributing it either |
| 9 | | with or without modifications. No license under IBM patents or |
| 10 | | patent applications is to be implied by the copyright license. |
| 11 | | |
| 12 | | Any user of this software should understand that IBM cannot provide |
| 13 | | technical support for this software and will not be responsible for |
| 14 | | any consequences resulting from the use of this software. |
| 15 | | |
| 16 | | Any person who transfers this source code or any derivative work |
| 17 | | must include the IBM copyright notice, this paragraph, and the |
| 18 | | preceding two paragraphs in the transferred software. |
| 19 | | |
| 20 | | COPYRIGHT I B M CORPORATION 1999 |
| 21 | | LICENSED MATERIAL - PROGRAM PROPERTY OF I B M |
| 22 | +----------------------------------------------------------------------------*/ |
| 23 | |
| 24 | #ifndef __PPC4XX_H__ |
| 25 | #define __PPC4XX_H__ |
| 26 | |
Stefan Roese | 36ea16f | 2008-06-02 14:57:41 +0200 | [diff] [blame] | 27 | /* |
| 28 | * Configure which SDRAM/DDR/DDR2 controller is equipped |
| 29 | */ |
| 30 | #if defined(CONFIG_405GP) || defined(CONFIG_405CR) || defined(CONFIG_405EP) || \ |
| 31 | defined(CONFIG_AP1000) || defined(CONFIG_ML2) |
| 32 | #define CONFIG_SDRAM_PPC4xx_IBM_SDRAM /* IBM SDRAM controller */ |
| 33 | #endif |
| 34 | |
| 35 | #if defined(CONFIG_440GP) || defined(CONFIG_440GX) || \ |
| 36 | defined(CONFIG_440EP) || defined(CONFIG_440GR) |
| 37 | #define CONFIG_SDRAM_PPC4xx_IBM_DDR /* IBM DDR controller */ |
| 38 | #endif |
| 39 | |
| 40 | #if defined(CONFIG_440EPX) || defined(CONFIG_440GRX) |
| 41 | #define CONFIG_SDRAM_PPC4xx_DENALI_DDR2 /* Denali DDR(2) controller */ |
| 42 | #endif |
| 43 | |
| 44 | #if defined(CONFIG_405EX) || \ |
| 45 | defined(CONFIG_440SP) || defined(CONFIG_440SPE) || \ |
Feng Kan | 96e5fc0 | 2008-07-08 22:48:07 -0700 | [diff] [blame] | 46 | defined(CONFIG_460EX) || defined(CONFIG_460GT) || \ |
| 47 | defined(CONFIG_460SX) |
Stefan Roese | 36ea16f | 2008-06-02 14:57:41 +0200 | [diff] [blame] | 48 | #define CONFIG_SDRAM_PPC4xx_IBM_DDR2 /* IBM DDR(2) controller */ |
| 49 | #endif |
| 50 | |
Stefan Roese | 5d841fa | 2009-05-20 10:58:01 +0200 | [diff] [blame] | 51 | #if defined(CONFIG_440EP) || defined(CONFIG_440GR) || \ |
| 52 | defined(CONFIG_440EPX) || defined(CONFIG_440GRX) || \ |
| 53 | defined(CONFIG_405EZ) || defined(CONFIG_405EX) || \ |
| 54 | defined(CONFIG_460EX) || defined(CONFIG_460GT) |
| 55 | #define CONFIG_NAND_NDFC |
| 56 | #endif |
| 57 | |
Prodyut Hazarika | 079589b | 2008-08-20 09:38:51 -0700 | [diff] [blame] | 58 | /* PLB4 CrossBar Arbiter Core supported across PPC4xx families */ |
| 59 | #if defined(CONFIG_405EX) || \ |
| 60 | defined(CONFIG_440EP) || defined(CONFIG_440EPX) || \ |
| 61 | defined(CONFIG_440GR) || defined(CONFIG_440GRX) || \ |
| 62 | defined(CONFIG_440SP) || defined(CONFIG_440SPE) || \ |
| 63 | defined(CONFIG_460EX) || defined(CONFIG_460GT) || \ |
| 64 | defined(CONFIG_460SX) |
| 65 | |
| 66 | #define PLB_ARBITER_BASE 0x80 |
| 67 | |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 68 | #define PLB0_ACR (PLB_ARBITER_BASE + 0x01) |
| 69 | #define PLB0_ACR_PPM_MASK 0xF0000000 |
| 70 | #define PLB0_ACR_PPM_FIXED 0x00000000 |
| 71 | #define PLB0_ACR_PPM_FAIR 0xD0000000 |
| 72 | #define PLB0_ACR_HBU_MASK 0x08000000 |
| 73 | #define PLB0_ACR_HBU_DISABLED 0x00000000 |
| 74 | #define PLB0_ACR_HBU_ENABLED 0x08000000 |
| 75 | #define PLB0_ACR_RDP_MASK 0x06000000 |
| 76 | #define PLB0_ACR_RDP_DISABLED 0x00000000 |
| 77 | #define PLB0_ACR_RDP_2DEEP 0x02000000 |
| 78 | #define PLB0_ACR_RDP_3DEEP 0x04000000 |
| 79 | #define PLB0_ACR_RDP_4DEEP 0x06000000 |
| 80 | #define PLB0_ACR_WRP_MASK 0x01000000 |
| 81 | #define PLB0_ACR_WRP_DISABLED 0x00000000 |
| 82 | #define PLB0_ACR_WRP_2DEEP 0x01000000 |
Prodyut Hazarika | 079589b | 2008-08-20 09:38:51 -0700 | [diff] [blame] | 83 | |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 84 | #define PLB1_ACR (PLB_ARBITER_BASE + 0x09) |
| 85 | #define PLB1_ACR_PPM_MASK 0xF0000000 |
| 86 | #define PLB1_ACR_PPM_FIXED 0x00000000 |
| 87 | #define PLB1_ACR_PPM_FAIR 0xD0000000 |
| 88 | #define PLB1_ACR_HBU_MASK 0x08000000 |
| 89 | #define PLB1_ACR_HBU_DISABLED 0x00000000 |
| 90 | #define PLB1_ACR_HBU_ENABLED 0x08000000 |
| 91 | #define PLB1_ACR_RDP_MASK 0x06000000 |
| 92 | #define PLB1_ACR_RDP_DISABLED 0x00000000 |
| 93 | #define PLB1_ACR_RDP_2DEEP 0x02000000 |
| 94 | #define PLB1_ACR_RDP_3DEEP 0x04000000 |
| 95 | #define PLB1_ACR_RDP_4DEEP 0x06000000 |
| 96 | #define PLB1_ACR_WRP_MASK 0x01000000 |
| 97 | #define PLB1_ACR_WRP_DISABLED 0x00000000 |
| 98 | #define PLB1_ACR_WRP_2DEEP 0x01000000 |
Prodyut Hazarika | 079589b | 2008-08-20 09:38:51 -0700 | [diff] [blame] | 99 | |
| 100 | #endif /* 440EP/EPX 440GR/GRX 440SP/SPE 460EX/GT/SX 405EX*/ |
| 101 | |
wdenk | 935ecca | 2002-08-06 20:46:37 +0000 | [diff] [blame] | 102 | #if defined(CONFIG_440) |
Stefan Roese | f2302d4 | 2008-08-06 14:05:38 +0200 | [diff] [blame] | 103 | /* |
| 104 | * Enable long long (%ll ...) printf format on 440 PPC's since most of |
| 105 | * them support 36bit physical addressing |
| 106 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 107 | #define CONFIG_SYS_64BIT_VSPRINTF |
| 108 | #define CONFIG_SYS_64BIT_STRTOUL |
wdenk | 935ecca | 2002-08-06 20:46:37 +0000 | [diff] [blame] | 109 | #include <ppc440.h> |
| 110 | #else |
| 111 | #include <ppc405.h> |
| 112 | #endif |
| 113 | |
Stefan Roese | 36ea16f | 2008-06-02 14:57:41 +0200 | [diff] [blame] | 114 | #include <asm/ppc4xx-sdram.h> |
Stefan Roese | 7ee2619 | 2008-06-24 17:18:50 +0200 | [diff] [blame] | 115 | #include <asm/ppc4xx-ebc.h> |
Ricardo Ribalda Delgado | d865fd0 | 2008-07-17 11:44:12 +0200 | [diff] [blame] | 116 | #if !defined(CONFIG_XILINX_440) |
Stefan Roese | 4fb25a3 | 2008-06-25 10:59:22 +0200 | [diff] [blame] | 117 | #include <asm/ppc4xx-uic.h> |
Ricardo Ribalda Delgado | d865fd0 | 2008-07-17 11:44:12 +0200 | [diff] [blame] | 118 | #endif |
Stefan Roese | 36ea16f | 2008-06-02 14:57:41 +0200 | [diff] [blame] | 119 | |
Stefan Roese | 087dfdb | 2007-10-21 08:12:41 +0200 | [diff] [blame] | 120 | /* |
Grant Erickson | c821b5f | 2008-05-22 14:44:14 -0700 | [diff] [blame] | 121 | * Macro for generating register field mnemonics |
| 122 | */ |
| 123 | #define PPC_REG_BITS 32 |
| 124 | #define PPC_REG_VAL(bit, value) ((value) << ((PPC_REG_BITS - 1) - (bit))) |
| 125 | |
| 126 | /* |
| 127 | * Elide casts when assembling register mnemonics |
| 128 | */ |
| 129 | #ifndef __ASSEMBLY__ |
| 130 | #define static_cast(type, val) (type)(val) |
| 131 | #else |
| 132 | #define static_cast(type, val) (val) |
| 133 | #endif |
| 134 | |
| 135 | /* |
Stefan Roese | 087dfdb | 2007-10-21 08:12:41 +0200 | [diff] [blame] | 136 | * Common stuff for 4xx (405 and 440) |
| 137 | */ |
| 138 | |
| 139 | #define EXC_OFF_SYS_RESET 0x0100 /* System reset */ |
| 140 | #define _START_OFFSET (EXC_OFF_SYS_RESET + 0x2000) |
| 141 | |
| 142 | #define RESET_VECTOR 0xfffffffc |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 143 | #define CACHELINE_MASK (CONFIG_SYS_CACHELINE_SIZE - 1) /* Address mask for cache |
Stefan Roese | 087dfdb | 2007-10-21 08:12:41 +0200 | [diff] [blame] | 144 | line aligned data. */ |
| 145 | |
| 146 | #define CPR0_DCR_BASE 0x0C |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 147 | #define CPR0_CFGADDR (CPR0_DCR_BASE + 0x0) |
| 148 | #define CPR0_CFGDATA (CPR0_DCR_BASE + 0x1) |
Stefan Roese | 087dfdb | 2007-10-21 08:12:41 +0200 | [diff] [blame] | 149 | |
| 150 | #define SDR_DCR_BASE 0x0E |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 151 | #define SDR0_CFGADDR (SDR_DCR_BASE + 0x0) |
| 152 | #define SDR0_CFGDATA (SDR_DCR_BASE + 0x1) |
Stefan Roese | 087dfdb | 2007-10-21 08:12:41 +0200 | [diff] [blame] | 153 | |
| 154 | #define SDRAM_DCR_BASE 0x10 |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 155 | #define SDRAM0_CFGADDR (SDRAM_DCR_BASE + 0x0) |
| 156 | #define SDRAM0_CFGDATA (SDRAM_DCR_BASE + 0x1) |
Stefan Roese | 087dfdb | 2007-10-21 08:12:41 +0200 | [diff] [blame] | 157 | |
| 158 | #define EBC_DCR_BASE 0x12 |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 159 | #define EBC0_CFGADDR (EBC_DCR_BASE + 0x0) |
| 160 | #define EBC0_CFGDATA (EBC_DCR_BASE + 0x1) |
Stefan Roese | 087dfdb | 2007-10-21 08:12:41 +0200 | [diff] [blame] | 161 | |
| 162 | /* |
| 163 | * Macros for indirect DCR access |
| 164 | */ |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 165 | #define mtcpr(reg, d) do { mtdcr(CPR0_CFGADDR,reg);mtdcr(CPR0_CFGDATA,d); } while (0) |
| 166 | #define mfcpr(reg, d) do { mtdcr(CPR0_CFGADDR,reg);d = mfdcr(CPR0_CFGDATA); } while (0) |
Stefan Roese | 087dfdb | 2007-10-21 08:12:41 +0200 | [diff] [blame] | 167 | |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 168 | #define mtebc(reg, d) do { mtdcr(EBC0_CFGADDR,reg);mtdcr(EBC0_CFGDATA,d); } while (0) |
| 169 | #define mfebc(reg, d) do { mtdcr(EBC0_CFGADDR,reg);d = mfdcr(EBC0_CFGDATA); } while (0) |
Stefan Roese | 087dfdb | 2007-10-21 08:12:41 +0200 | [diff] [blame] | 170 | |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 171 | #define mtsdram(reg, d) do { mtdcr(SDRAM0_CFGADDR,reg);mtdcr(SDRAM0_CFGDATA,d); } while (0) |
| 172 | #define mfsdram(reg, d) do { mtdcr(SDRAM0_CFGADDR,reg);d = mfdcr(SDRAM0_CFGDATA); } while (0) |
Stefan Roese | 087dfdb | 2007-10-21 08:12:41 +0200 | [diff] [blame] | 173 | |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 174 | #define mtsdr(reg, d) do { mtdcr(SDR0_CFGADDR,reg);mtdcr(SDR0_CFGDATA,d); } while (0) |
| 175 | #define mfsdr(reg, d) do { mtdcr(SDR0_CFGADDR,reg);d = mfdcr(SDR0_CFGDATA); } while (0) |
Stefan Roese | 087dfdb | 2007-10-21 08:12:41 +0200 | [diff] [blame] | 176 | |
| 177 | #ifndef __ASSEMBLY__ |
| 178 | |
| 179 | typedef struct |
| 180 | { |
| 181 | unsigned long freqDDR; |
| 182 | unsigned long freqEBC; |
| 183 | unsigned long freqOPB; |
| 184 | unsigned long freqPCI; |
| 185 | unsigned long freqPLB; |
| 186 | unsigned long freqTmrClk; |
| 187 | unsigned long freqUART; |
| 188 | unsigned long freqProcessor; |
| 189 | unsigned long freqVCOHz; |
| 190 | unsigned long freqVCOMhz; /* in MHz */ |
| 191 | unsigned long pciClkSync; /* PCI clock is synchronous */ |
| 192 | unsigned long pciIntArbEn; /* Internal PCI arbiter is enabled */ |
| 193 | unsigned long pllExtBusDiv; |
| 194 | unsigned long pllFbkDiv; |
| 195 | unsigned long pllFwdDiv; |
| 196 | unsigned long pllFwdDivA; |
| 197 | unsigned long pllFwdDivB; |
| 198 | unsigned long pllOpbDiv; |
| 199 | unsigned long pllPciDiv; |
| 200 | unsigned long pllPlbDiv; |
| 201 | } PPC4xx_SYS_INFO; |
| 202 | |
Adam Graham | f6b6c45 | 2008-09-03 12:26:59 -0700 | [diff] [blame] | 203 | static inline u32 get_mcsr(void) |
| 204 | { |
| 205 | u32 val; |
| 206 | |
| 207 | asm volatile("mfspr %0, 0x23c" : "=r" (val) :); |
| 208 | return val; |
| 209 | } |
| 210 | |
| 211 | static inline void set_mcsr(u32 val) |
| 212 | { |
| 213 | asm volatile("mtspr 0x23c, %0" : "=r" (val) :); |
| 214 | } |
| 215 | |
Stefan Roese | 087dfdb | 2007-10-21 08:12:41 +0200 | [diff] [blame] | 216 | #endif /* __ASSEMBLY__ */ |
| 217 | |
Adam Graham | c9c11d7 | 2008-10-08 10:13:19 -0700 | [diff] [blame] | 218 | /* for multi-cpu support */ |
| 219 | #define NA_OR_UNKNOWN_CPU -1 |
| 220 | |
wdenk | 935ecca | 2002-08-06 20:46:37 +0000 | [diff] [blame] | 221 | #endif /* __PPC4XX_H__ */ |