Jayachandran C | 65040e2 | 2011-11-16 00:21:28 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2003-2011 NetLogic Microsystems, Inc. (NetLogic). All rights |
| 3 | * reserved. |
| 4 | * |
| 5 | * This software is available to you under a choice of one of two |
| 6 | * licenses. You may choose to be licensed under the terms of the GNU |
| 7 | * General Public License (GPL) Version 2, available from the file |
| 8 | * COPYING in the main directory of this source tree, or the NetLogic |
| 9 | * license below: |
| 10 | * |
| 11 | * Redistribution and use in source and binary forms, with or without |
| 12 | * modification, are permitted provided that the following conditions |
| 13 | * are met: |
| 14 | * |
| 15 | * 1. Redistributions of source code must retain the above copyright |
| 16 | * notice, this list of conditions and the following disclaimer. |
| 17 | * 2. Redistributions in binary form must reproduce the above copyright |
| 18 | * notice, this list of conditions and the following disclaimer in |
| 19 | * the documentation and/or other materials provided with the |
| 20 | * distribution. |
| 21 | * |
| 22 | * THIS SOFTWARE IS PROVIDED BY NETLOGIC ``AS IS'' AND ANY EXPRESS OR |
| 23 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 24 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 25 | * ARE DISCLAIMED. IN NO EVENT SHALL NETLOGIC OR CONTRIBUTORS BE LIABLE |
| 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 29 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 30 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| 31 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 32 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 33 | */ |
| 34 | |
| 35 | #include <linux/types.h> |
| 36 | #include <linux/kernel.h> |
| 37 | #include <linux/mm.h> |
| 38 | #include <linux/delay.h> |
| 39 | |
| 40 | #include <asm/mipsregs.h> |
| 41 | #include <asm/time.h> |
| 42 | |
Jayachandran C | 77ae798 | 2012-10-31 12:01:39 +0000 | [diff] [blame] | 43 | #include <asm/netlogic/common.h> |
Jayachandran C | 65040e2 | 2011-11-16 00:21:28 +0000 | [diff] [blame] | 44 | #include <asm/netlogic/haldefs.h> |
| 45 | #include <asm/netlogic/xlp-hal/iomap.h> |
| 46 | #include <asm/netlogic/xlp-hal/xlp.h> |
Jayachandran C | a2ba6cd | 2013-08-21 19:31:29 +0530 | [diff] [blame] | 47 | #include <asm/netlogic/xlp-hal/bridge.h> |
Jayachandran C | 65040e2 | 2011-11-16 00:21:28 +0000 | [diff] [blame] | 48 | #include <asm/netlogic/xlp-hal/pic.h> |
| 49 | #include <asm/netlogic/xlp-hal/sys.h> |
| 50 | |
Jayachandran C | 65040e2 | 2011-11-16 00:21:28 +0000 | [diff] [blame] | 51 | /* Main initialization */ |
Jayachandran C | 77ae798 | 2012-10-31 12:01:39 +0000 | [diff] [blame] | 52 | void nlm_node_init(int node) |
Jayachandran C | 65040e2 | 2011-11-16 00:21:28 +0000 | [diff] [blame] | 53 | { |
Jayachandran C | 77ae798 | 2012-10-31 12:01:39 +0000 | [diff] [blame] | 54 | struct nlm_soc_info *nodep; |
| 55 | |
| 56 | nodep = nlm_get_node(node); |
Jayachandran C | 3e46856 | 2014-04-29 20:07:42 +0530 | [diff] [blame^] | 57 | if (node == 0) |
| 58 | nodep->coremask = 1; /* node 0, boot cpu */ |
Jayachandran C | 77ae798 | 2012-10-31 12:01:39 +0000 | [diff] [blame] | 59 | nodep->sysbase = nlm_get_sys_regbase(node); |
| 60 | nodep->picbase = nlm_get_pic_regbase(node); |
| 61 | nodep->ebase = read_c0_ebase() & (~((1 << 12) - 1)); |
Jayachandran C | 5513c76 | 2013-12-21 16:52:21 +0530 | [diff] [blame] | 62 | if (cpu_is_xlp9xx()) |
| 63 | nodep->socbus = xlp9xx_get_socbus(node); |
| 64 | else |
| 65 | nodep->socbus = 0; |
Jayachandran C | 77ae798 | 2012-10-31 12:01:39 +0000 | [diff] [blame] | 66 | spin_lock_init(&nodep->piclock); |
Jayachandran C | 65040e2 | 2011-11-16 00:21:28 +0000 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | int nlm_irq_to_irt(int irq) |
| 70 | { |
Jayachandran C | 3c0553e | 2013-03-23 17:27:56 +0000 | [diff] [blame] | 71 | uint64_t pcibase; |
| 72 | int devoff, irt; |
Jayachandran C | 65040e2 | 2011-11-16 00:21:28 +0000 | [diff] [blame] | 73 | |
Jayachandran C | d150cef | 2013-12-21 16:52:22 +0530 | [diff] [blame] | 74 | /* bypass for 9xx */ |
| 75 | if (cpu_is_xlp9xx()) { |
| 76 | switch (irq) { |
Ganesan Ramalingam | 3262b21 | 2013-12-21 16:52:28 +0530 | [diff] [blame] | 77 | case PIC_9XX_XHCI_0_IRQ: |
| 78 | return 114; |
| 79 | case PIC_9XX_XHCI_1_IRQ: |
| 80 | return 115; |
Jayachandran C | d150cef | 2013-12-21 16:52:22 +0530 | [diff] [blame] | 81 | case PIC_UART_0_IRQ: |
| 82 | return 133; |
| 83 | case PIC_UART_1_IRQ: |
| 84 | return 134; |
Jayachandran C | b6ba1c5 | 2013-12-21 16:52:27 +0530 | [diff] [blame] | 85 | case PIC_PCIE_LINK_LEGACY_IRQ(0): |
| 86 | case PIC_PCIE_LINK_LEGACY_IRQ(1): |
| 87 | case PIC_PCIE_LINK_LEGACY_IRQ(2): |
| 88 | case PIC_PCIE_LINK_LEGACY_IRQ(3): |
| 89 | return 191 + irq - PIC_PCIE_LINK_LEGACY_IRQ_BASE; |
Jayachandran C | d150cef | 2013-12-21 16:52:22 +0530 | [diff] [blame] | 90 | } |
| 91 | return -1; |
| 92 | } |
| 93 | |
Ganesan Ramalingam | 9eac359 | 2013-08-21 19:32:41 +0530 | [diff] [blame] | 94 | devoff = 0; |
Jayachandran C | 65040e2 | 2011-11-16 00:21:28 +0000 | [diff] [blame] | 95 | switch (irq) { |
| 96 | case PIC_UART_0_IRQ: |
Jayachandran C | 3c0553e | 2013-03-23 17:27:56 +0000 | [diff] [blame] | 97 | devoff = XLP_IO_UART0_OFFSET(0); |
| 98 | break; |
Jayachandran C | 65040e2 | 2011-11-16 00:21:28 +0000 | [diff] [blame] | 99 | case PIC_UART_1_IRQ: |
Jayachandran C | 3c0553e | 2013-03-23 17:27:56 +0000 | [diff] [blame] | 100 | devoff = XLP_IO_UART1_OFFSET(0); |
| 101 | break; |
Jayachandran C | 57d7cdb | 2012-07-24 17:28:54 +0200 | [diff] [blame] | 102 | case PIC_MMC_IRQ: |
Jayachandran C | 3c0553e | 2013-03-23 17:27:56 +0000 | [diff] [blame] | 103 | devoff = XLP_IO_SD_OFFSET(0); |
| 104 | break; |
Ganesan Ramalingam | e5be1fd | 2013-08-11 14:43:58 +0530 | [diff] [blame] | 105 | case PIC_I2C_0_IRQ: /* I2C will be fixed up */ |
Jayachandran C | 57d7cdb | 2012-07-24 17:28:54 +0200 | [diff] [blame] | 106 | case PIC_I2C_1_IRQ: |
Ganesan Ramalingam | e5be1fd | 2013-08-11 14:43:58 +0530 | [diff] [blame] | 107 | case PIC_I2C_2_IRQ: |
| 108 | case PIC_I2C_3_IRQ: |
| 109 | if (cpu_is_xlpii()) |
| 110 | devoff = XLP2XX_IO_I2C_OFFSET(0); |
| 111 | else |
| 112 | devoff = XLP_IO_I2C0_OFFSET(0); |
Jayachandran C | 3c0553e | 2013-03-23 17:27:56 +0000 | [diff] [blame] | 113 | break; |
Jayachandran C | 65040e2 | 2011-11-16 00:21:28 +0000 | [diff] [blame] | 114 | default: |
Ganesan Ramalingam | 9eac359 | 2013-08-21 19:32:41 +0530 | [diff] [blame] | 115 | if (cpu_is_xlpii()) { |
| 116 | switch (irq) { |
| 117 | /* XLP2XX has three XHCI USB controller */ |
| 118 | case PIC_2XX_XHCI_0_IRQ: |
| 119 | devoff = XLP2XX_IO_USB_XHCI0_OFFSET(0); |
| 120 | break; |
| 121 | case PIC_2XX_XHCI_1_IRQ: |
| 122 | devoff = XLP2XX_IO_USB_XHCI1_OFFSET(0); |
| 123 | break; |
| 124 | case PIC_2XX_XHCI_2_IRQ: |
| 125 | devoff = XLP2XX_IO_USB_XHCI2_OFFSET(0); |
| 126 | break; |
| 127 | } |
| 128 | } else { |
| 129 | switch (irq) { |
| 130 | case PIC_EHCI_0_IRQ: |
| 131 | devoff = XLP_IO_USB_EHCI0_OFFSET(0); |
| 132 | break; |
| 133 | case PIC_EHCI_1_IRQ: |
| 134 | devoff = XLP_IO_USB_EHCI1_OFFSET(0); |
| 135 | break; |
| 136 | case PIC_OHCI_0_IRQ: |
| 137 | devoff = XLP_IO_USB_OHCI0_OFFSET(0); |
| 138 | break; |
| 139 | case PIC_OHCI_1_IRQ: |
| 140 | devoff = XLP_IO_USB_OHCI1_OFFSET(0); |
| 141 | break; |
| 142 | case PIC_OHCI_2_IRQ: |
| 143 | devoff = XLP_IO_USB_OHCI2_OFFSET(0); |
| 144 | break; |
| 145 | case PIC_OHCI_3_IRQ: |
| 146 | devoff = XLP_IO_USB_OHCI3_OFFSET(0); |
| 147 | break; |
| 148 | } |
| 149 | } |
Jayachandran C | 65040e2 | 2011-11-16 00:21:28 +0000 | [diff] [blame] | 150 | } |
Jayachandran C | 3c0553e | 2013-03-23 17:27:56 +0000 | [diff] [blame] | 151 | |
| 152 | if (devoff != 0) { |
| 153 | pcibase = nlm_pcicfg_base(devoff); |
| 154 | irt = nlm_read_reg(pcibase, XLP_PCI_IRTINFO_REG) & 0xffff; |
Ganesan Ramalingam | e5be1fd | 2013-08-11 14:43:58 +0530 | [diff] [blame] | 155 | /* HW weirdness, I2C IRT entry has to be fixed up */ |
| 156 | switch (irq) { |
| 157 | case PIC_I2C_1_IRQ: |
| 158 | irt = irt + 1; break; |
| 159 | case PIC_I2C_2_IRQ: |
| 160 | irt = irt + 2; break; |
| 161 | case PIC_I2C_3_IRQ: |
| 162 | irt = irt + 3; break; |
| 163 | } |
Jayachandran C | c24a8a7 | 2013-12-21 16:52:13 +0530 | [diff] [blame] | 164 | } else if (irq >= PIC_PCIE_LINK_LEGACY_IRQ(0) && |
| 165 | irq <= PIC_PCIE_LINK_LEGACY_IRQ(3)) { |
Jayachandran C | 3c0553e | 2013-03-23 17:27:56 +0000 | [diff] [blame] | 166 | /* HW bug, PCI IRT entries are bad on early silicon, fix */ |
Jayachandran C | c24a8a7 | 2013-12-21 16:52:13 +0530 | [diff] [blame] | 167 | irt = PIC_IRT_PCIE_LINK_INDEX(irq - |
| 168 | PIC_PCIE_LINK_LEGACY_IRQ_BASE); |
| 169 | } else if (irq >= PIC_PCIE_LINK_MSI_IRQ(0) && |
| 170 | irq <= PIC_PCIE_LINK_MSI_IRQ(3)) { |
| 171 | irt = -2; |
| 172 | } else if (irq >= PIC_PCIE_MSIX_IRQ(0) && |
| 173 | irq <= PIC_PCIE_MSIX_IRQ(3)) { |
| 174 | irt = -2; |
Jayachandran C | 3c0553e | 2013-03-23 17:27:56 +0000 | [diff] [blame] | 175 | } else { |
| 176 | irt = -1; |
| 177 | } |
| 178 | return irt; |
Jayachandran C | 65040e2 | 2011-11-16 00:21:28 +0000 | [diff] [blame] | 179 | } |
| 180 | |
Jayachandran C | 77ae798 | 2012-10-31 12:01:39 +0000 | [diff] [blame] | 181 | unsigned int nlm_get_core_frequency(int node, int core) |
Jayachandran C | 65040e2 | 2011-11-16 00:21:28 +0000 | [diff] [blame] | 182 | { |
Jayachandran C | 2aa54b2 | 2011-11-16 00:21:29 +0000 | [diff] [blame] | 183 | unsigned int pll_divf, pll_divr, dfs_div, ext_div; |
| 184 | unsigned int rstval, dfsval, denom; |
Jayachandran C | 77ae798 | 2012-10-31 12:01:39 +0000 | [diff] [blame] | 185 | uint64_t num, sysbase; |
Jayachandran C | 65040e2 | 2011-11-16 00:21:28 +0000 | [diff] [blame] | 186 | |
Jayachandran C | 77ae798 | 2012-10-31 12:01:39 +0000 | [diff] [blame] | 187 | sysbase = nlm_get_node(node)->sysbase; |
Jayachandran C | 861c056 | 2013-12-21 16:52:23 +0530 | [diff] [blame] | 188 | if (cpu_is_xlp9xx()) |
| 189 | rstval = nlm_read_sys_reg(sysbase, SYS_9XX_POWER_ON_RESET_CFG); |
| 190 | else |
| 191 | rstval = nlm_read_sys_reg(sysbase, SYS_POWER_ON_RESET_CFG); |
Ganesan Ramalingam | 57ceb4b | 2013-08-11 14:43:56 +0530 | [diff] [blame] | 192 | if (cpu_is_xlpii()) { |
| 193 | num = 1000000ULL * (400 * 3 + 100 * (rstval >> 26)); |
| 194 | denom = 3; |
| 195 | } else { |
| 196 | dfsval = nlm_read_sys_reg(sysbase, SYS_CORE_DFS_DIV_VALUE); |
| 197 | pll_divf = ((rstval >> 10) & 0x7f) + 1; |
| 198 | pll_divr = ((rstval >> 8) & 0x3) + 1; |
| 199 | ext_div = ((rstval >> 30) & 0x3) + 1; |
| 200 | dfs_div = ((dfsval >> (core * 4)) & 0xf) + 1; |
Jayachandran C | 65040e2 | 2011-11-16 00:21:28 +0000 | [diff] [blame] | 201 | |
Ganesan Ramalingam | 57ceb4b | 2013-08-11 14:43:56 +0530 | [diff] [blame] | 202 | num = 800000000ULL * pll_divf; |
| 203 | denom = 3 * pll_divr * ext_div * dfs_div; |
| 204 | } |
Jayachandran C | 65040e2 | 2011-11-16 00:21:28 +0000 | [diff] [blame] | 205 | do_div(num, denom); |
| 206 | return (unsigned int)num; |
| 207 | } |
Jayachandran C | 2aa54b2 | 2011-11-16 00:21:29 +0000 | [diff] [blame] | 208 | |
Ganesan Ramalingam | 57ceb4b | 2013-08-11 14:43:56 +0530 | [diff] [blame] | 209 | /* Calculate Frequency to the PIC from PLL. |
| 210 | * freq_out = ( ref_freq/2 * (6 + ctrl2[7:0]) + ctrl2[20:8]/2^13 ) / |
| 211 | * ((2^ctrl0[7:5]) * Table(ctrl0[26:24])) |
| 212 | */ |
| 213 | static unsigned int nlm_2xx_get_pic_frequency(int node) |
| 214 | { |
| 215 | u32 ctrl_val0, ctrl_val2, vco_post_div, pll_post_div; |
| 216 | u32 mdiv, fdiv, pll_out_freq_den, reg_select, ref_div, pic_div; |
| 217 | u64 ref_clk, sysbase, pll_out_freq_num, ref_clk_select; |
| 218 | |
| 219 | sysbase = nlm_get_node(node)->sysbase; |
| 220 | |
| 221 | /* Find ref_clk_base */ |
| 222 | ref_clk_select = |
| 223 | (nlm_read_sys_reg(sysbase, SYS_POWER_ON_RESET_CFG) >> 18) & 0x3; |
| 224 | switch (ref_clk_select) { |
| 225 | case 0: |
| 226 | ref_clk = 200000000ULL; |
| 227 | ref_div = 3; |
| 228 | break; |
| 229 | case 1: |
| 230 | ref_clk = 100000000ULL; |
| 231 | ref_div = 1; |
| 232 | break; |
| 233 | case 2: |
| 234 | ref_clk = 125000000ULL; |
| 235 | ref_div = 1; |
| 236 | break; |
| 237 | case 3: |
| 238 | ref_clk = 400000000ULL; |
| 239 | ref_div = 3; |
| 240 | break; |
| 241 | } |
| 242 | |
| 243 | /* Find the clock source PLL device for PIC */ |
| 244 | reg_select = (nlm_read_sys_reg(sysbase, SYS_CLK_DEV_SEL) >> 22) & 0x3; |
| 245 | switch (reg_select) { |
| 246 | case 0: |
| 247 | ctrl_val0 = nlm_read_sys_reg(sysbase, SYS_PLL_CTRL0); |
| 248 | ctrl_val2 = nlm_read_sys_reg(sysbase, SYS_PLL_CTRL2); |
| 249 | break; |
| 250 | case 1: |
| 251 | ctrl_val0 = nlm_read_sys_reg(sysbase, SYS_PLL_CTRL0_DEVX(0)); |
| 252 | ctrl_val2 = nlm_read_sys_reg(sysbase, SYS_PLL_CTRL2_DEVX(0)); |
| 253 | break; |
| 254 | case 2: |
| 255 | ctrl_val0 = nlm_read_sys_reg(sysbase, SYS_PLL_CTRL0_DEVX(1)); |
| 256 | ctrl_val2 = nlm_read_sys_reg(sysbase, SYS_PLL_CTRL2_DEVX(1)); |
| 257 | break; |
| 258 | case 3: |
| 259 | ctrl_val0 = nlm_read_sys_reg(sysbase, SYS_PLL_CTRL0_DEVX(2)); |
| 260 | ctrl_val2 = nlm_read_sys_reg(sysbase, SYS_PLL_CTRL2_DEVX(2)); |
| 261 | break; |
| 262 | } |
| 263 | |
| 264 | vco_post_div = (ctrl_val0 >> 5) & 0x7; |
| 265 | pll_post_div = (ctrl_val0 >> 24) & 0x7; |
| 266 | mdiv = ctrl_val2 & 0xff; |
| 267 | fdiv = (ctrl_val2 >> 8) & 0xfff; |
| 268 | |
| 269 | /* Find PLL post divider value */ |
| 270 | switch (pll_post_div) { |
| 271 | case 1: |
| 272 | pll_post_div = 2; |
| 273 | break; |
| 274 | case 3: |
| 275 | pll_post_div = 4; |
| 276 | break; |
| 277 | case 7: |
| 278 | pll_post_div = 8; |
| 279 | break; |
| 280 | case 6: |
| 281 | pll_post_div = 16; |
| 282 | break; |
| 283 | case 0: |
| 284 | default: |
| 285 | pll_post_div = 1; |
| 286 | break; |
| 287 | } |
| 288 | |
| 289 | fdiv = fdiv/(1 << 13); |
| 290 | pll_out_freq_num = ((ref_clk >> 1) * (6 + mdiv)) + fdiv; |
| 291 | pll_out_freq_den = (1 << vco_post_div) * pll_post_div * 3; |
| 292 | |
| 293 | if (pll_out_freq_den > 0) |
| 294 | do_div(pll_out_freq_num, pll_out_freq_den); |
| 295 | |
| 296 | /* PIC post divider, which happens after PLL */ |
| 297 | pic_div = (nlm_read_sys_reg(sysbase, SYS_CLK_DEV_DIV) >> 22) & 0x3; |
| 298 | do_div(pll_out_freq_num, 1 << pic_div); |
| 299 | |
| 300 | return pll_out_freq_num; |
| 301 | } |
| 302 | |
| 303 | unsigned int nlm_get_pic_frequency(int node) |
| 304 | { |
Jayachandran C | d150cef | 2013-12-21 16:52:22 +0530 | [diff] [blame] | 305 | /* TODO Has to calculate freq as like 2xx */ |
| 306 | if (cpu_is_xlp9xx()) |
| 307 | return 250000000; |
| 308 | |
Ganesan Ramalingam | 57ceb4b | 2013-08-11 14:43:56 +0530 | [diff] [blame] | 309 | if (cpu_is_xlpii()) |
| 310 | return nlm_2xx_get_pic_frequency(node); |
| 311 | else |
| 312 | return 133333333; |
| 313 | } |
| 314 | |
Jayachandran C | 2aa54b2 | 2011-11-16 00:21:29 +0000 | [diff] [blame] | 315 | unsigned int nlm_get_cpu_frequency(void) |
| 316 | { |
Jayachandran C | 77ae798 | 2012-10-31 12:01:39 +0000 | [diff] [blame] | 317 | return nlm_get_core_frequency(0, 0); |
Jayachandran C | 2aa54b2 | 2011-11-16 00:21:29 +0000 | [diff] [blame] | 318 | } |
Jayachandran C | a2ba6cd | 2013-08-21 19:31:29 +0530 | [diff] [blame] | 319 | |
| 320 | /* |
| 321 | * Fills upto 8 pairs of entries containing the DRAM map of a node |
| 322 | * if n < 0, get dram map for all nodes |
| 323 | */ |
| 324 | int xlp_get_dram_map(int n, uint64_t *dram_map) |
| 325 | { |
| 326 | uint64_t bridgebase, base, lim; |
| 327 | uint32_t val; |
Jayachandran C | e7aa6c6 | 2013-12-21 16:52:25 +0530 | [diff] [blame] | 328 | unsigned int barreg, limreg, xlatreg; |
Jayachandran C | a2ba6cd | 2013-08-21 19:31:29 +0530 | [diff] [blame] | 329 | int i, node, rv; |
| 330 | |
| 331 | /* Look only at mapping on Node 0, we don't handle crazy configs */ |
| 332 | bridgebase = nlm_get_bridge_regbase(0); |
| 333 | rv = 0; |
| 334 | for (i = 0; i < 8; i++) { |
Jayachandran C | e7aa6c6 | 2013-12-21 16:52:25 +0530 | [diff] [blame] | 335 | if (cpu_is_xlp9xx()) { |
| 336 | barreg = BRIDGE_9XX_DRAM_BAR(i); |
| 337 | limreg = BRIDGE_9XX_DRAM_LIMIT(i); |
| 338 | xlatreg = BRIDGE_9XX_DRAM_NODE_TRANSLN(i); |
| 339 | } else { |
| 340 | barreg = BRIDGE_DRAM_BAR(i); |
| 341 | limreg = BRIDGE_DRAM_LIMIT(i); |
| 342 | xlatreg = BRIDGE_DRAM_NODE_TRANSLN(i); |
| 343 | } |
| 344 | if (n >= 0) { |
| 345 | /* node specified, get node mapping of BAR */ |
| 346 | val = nlm_read_bridge_reg(bridgebase, xlatreg); |
| 347 | node = (val >> 1) & 0x3; |
| 348 | if (n != node) |
| 349 | continue; |
| 350 | } |
| 351 | val = nlm_read_bridge_reg(bridgebase, barreg); |
Jayachandran C | a2ba6cd | 2013-08-21 19:31:29 +0530 | [diff] [blame] | 352 | val = (val >> 12) & 0xfffff; |
| 353 | base = (uint64_t) val << 20; |
Jayachandran C | e7aa6c6 | 2013-12-21 16:52:25 +0530 | [diff] [blame] | 354 | val = nlm_read_bridge_reg(bridgebase, limreg); |
Jayachandran C | a2ba6cd | 2013-08-21 19:31:29 +0530 | [diff] [blame] | 355 | val = (val >> 12) & 0xfffff; |
| 356 | if (val == 0) /* BAR not used */ |
| 357 | continue; |
| 358 | lim = ((uint64_t)val + 1) << 20; |
| 359 | dram_map[rv] = base; |
| 360 | dram_map[rv + 1] = lim; |
| 361 | rv += 2; |
| 362 | } |
| 363 | return rv; |
| 364 | } |