Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus

Pull MIPS updates from Ralf Baechle:
"This is the main pull request for 3.17. It contains:

- misc Cavium Octeon, BCM47xx, BCM63xx and Alchemy updates
- MIPS ptrace updates and cleanups
- various fixes that will also go to -stable
- a number of cleanups and small non-critical fixes.
- NUMA support for the Loongson 3.
- more support for MSA
- support for MAAR
- various FP enhancements and fixes"

* 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus: (139 commits)
MIPS: jz4740: remove unnecessary null test before debugfs_remove
MIPS: Octeon: remove unnecessary null test before debugfs_remove_recursive
MIPS: ZBOOT: implement stack protector in compressed boot phase
MIPS: mipsreg: remove duplicate MIPS_CONF4_FTLBSETS_SHIFT
MIPS: Bonito64: remove a duplicate define
MIPS: Malta: initialise MAARs
MIPS: Initialise MAARs
MIPS: detect presence of MAARs
MIPS: define MAAR register accessors & bits
MIPS: mark MSA experimental
MIPS: Don't build MSA support unless it can be used
MIPS: consistently clear MSA flags when starting & copying threads
MIPS: 16 byte align MSA vector context
MIPS: disable preemption whilst initialising MSA
MIPS: ensure MSA gets disabled during boot
MIPS: fix read_msa_* & write_msa_* functions on non-MSA toolchains
MIPS: fix MSA context for tasks which don't use FP first
MIPS: init upper 64b of vector registers when MSA is first used
MIPS: save/disable MSA in lose_fpu
MIPS: preserve scalar FP CSR when switching vector context
...

+5487 -3037
+6
Documentation/kernel-parameters.txt
··· 571 571 trust validation. 572 572 format: { id:<keyid> | builtin } 573 573 574 + cca= [MIPS] Override the kernel pages' cache coherency 575 + algorithm. Accepted values range from 0 to 7 576 + inclusive. See arch/mips/include/asm/pgtable-bits.h 577 + for platform specific values (SB1, Loongson3 and 578 + others). 579 + 574 580 ccw_timeout_log [S390] 575 581 See Documentation/s390/CommonIO for details. 576 582
+7 -2
arch/mips/Kconfig
··· 71 71 select SYS_SUPPORTS_APM_EMULATION 72 72 select ARCH_REQUIRE_GPIOLIB 73 73 select SYS_SUPPORTS_ZBOOT 74 + select COMMON_CLK 74 75 75 76 config AR7 76 77 bool "Texas Instruments AR7" ··· 130 129 select SYS_SUPPORTS_MIPS16 131 130 select SYS_HAS_EARLY_PRINTK 132 131 select USE_GENERIC_EARLY_PRINTK_8250 132 + select GPIOLIB 133 + select LEDS_GPIO_REGISTER 133 134 help 134 135 Support for BCM47XX based boards 135 136 ··· 140 137 select BOOT_RAW 141 138 select CEVT_R4K 142 139 select CSRC_R4K 140 + select SYNC_R4K 143 141 select DMA_NONCOHERENT 144 142 select IRQ_CPU 145 143 select SYS_SUPPORTS_32BIT_KERNEL ··· 2060 2056 support is unavailable. 2061 2057 2062 2058 config MIPS_CPS_PM 2059 + select MIPS_CPC 2063 2060 bool 2064 2061 2065 2062 config MIPS_GIC_IPI ··· 2114 2109 microMIPS ISA 2115 2110 2116 2111 config CPU_HAS_MSA 2117 - bool "Support for the MIPS SIMD Architecture" 2112 + bool "Support for the MIPS SIMD Architecture (EXPERIMENTAL)" 2118 2113 depends on CPU_SUPPORTS_MSA 2119 - default y 2114 + depends on 64BIT || MIPS_O32_FP64_SUPPORT 2120 2115 help 2121 2116 MIPS SIMD Architecture (MSA) introduces 128 bit wide vector registers 2122 2117 and a set of SIMD instructions to operate on them. When this option
+3 -1
arch/mips/Makefile
··· 151 151 -Wa,--trap 152 152 cflags-$(CONFIG_CPU_RM7000) += $(call cc-option,-march=rm7000,-march=r5000) \ 153 153 -Wa,--trap 154 - cflags-$(CONFIG_CPU_SB1) += $(call cc-option,-march=sb1 -mno-mdmx -mno-mips3d,-march=r5000) \ 154 + cflags-$(CONFIG_CPU_SB1) += $(call cc-option,-march=sb1,-march=r5000) \ 155 155 -Wa,--trap 156 + cflags-$(CONFIG_CPU_SB1) += $(call cc-option,-mno-mdmx) 157 + cflags-$(CONFIG_CPU_SB1) += $(call cc-option,-mno-mips3d) 156 158 cflags-$(CONFIG_CPU_R8000) += -march=r8000 -Wa,--trap 157 159 cflags-$(CONFIG_CPU_R10000) += $(call cc-option,-march=r10000,-march=r8000) \ 158 160 -Wa,--trap
+2 -2
arch/mips/alchemy/board-mtx1.c
··· 85 85 #endif /* IS_ENABLED(CONFIG_USB_OHCI_HCD) */ 86 86 87 87 /* Initialize sys_pinfunc */ 88 - au_writel(SYS_PF_NI2, SYS_PINFUNC); 88 + alchemy_wrsys(SYS_PF_NI2, AU1000_SYS_PINFUNC); 89 89 90 90 /* Initialize GPIO */ 91 - au_writel(~0, KSEG1ADDR(AU1000_SYS_PHYS_ADDR) + SYS_TRIOUTCLR); 91 + alchemy_wrsys(~0, AU1000_SYS_TRIOUTCLR); 92 92 alchemy_gpio_direction_output(0, 0); /* Disable M66EN (PCI 66MHz) */ 93 93 alchemy_gpio_direction_output(3, 1); /* Disable PCI CLKRUN# */ 94 94 alchemy_gpio_direction_output(1, 1); /* Enable EXT_IO3 */
+2 -2
arch/mips/alchemy/board-xxs1500.c
··· 87 87 alchemy_gpio2_enable(); 88 88 89 89 /* Set multiple use pins (UART3/GPIO) to UART (it's used as UART too) */ 90 - pin_func = au_readl(SYS_PINFUNC) & ~SYS_PF_UR3; 90 + pin_func = alchemy_rdsys(AU1000_SYS_PINFUNC) & ~SYS_PF_UR3; 91 91 pin_func |= SYS_PF_UR3; 92 - au_writel(pin_func, SYS_PINFUNC); 92 + alchemy_wrsys(pin_func, AU1000_SYS_PINFUNC); 93 93 94 94 /* Enable UART */ 95 95 alchemy_uart_enable(AU1000_UART3_PHYS_ADDR);
+2 -2
arch/mips/alchemy/common/Makefile
··· 5 5 # Makefile for the Alchemy Au1xx0 CPUs, generic files. 6 6 # 7 7 8 - obj-y += prom.o time.o clocks.o platform.o power.o setup.o \ 9 - sleeper.o dma.o dbdma.o vss.o irq.o usb.o 8 + obj-y += prom.o time.o clock.o platform.o power.o \ 9 + setup.o sleeper.o dma.o dbdma.o vss.o irq.o usb.o 10 10 11 11 # optional gpiolib support 12 12 ifeq ($(CONFIG_ALCHEMY_GPIO_INDIRECT),)
+1094
arch/mips/alchemy/common/clock.c
··· 1 + /* 2 + * Alchemy clocks. 3 + * 4 + * Exposes all configurable internal clock sources to the clk framework. 5 + * 6 + * We have: 7 + * - Root source, usually 12MHz supplied by an external crystal 8 + * - 3 PLLs which generate multiples of root rate [AUX, CPU, AUX2] 9 + * 10 + * Dividers: 11 + * - 6 clock dividers with: 12 + * * selectable source [one of the PLLs], 13 + * * output divided between [2 .. 512 in steps of 2] (!Au1300) 14 + * or [1 .. 256 in steps of 1] (Au1300), 15 + * * can be enabled individually. 16 + * 17 + * - up to 6 "internal" (fixed) consumers which: 18 + * * take either AUXPLL or one of the above 6 dividers as input, 19 + * * divide this input by 1, 2, or 4 (and 3 on Au1300). 20 + * * can be disabled separately. 21 + * 22 + * Misc clocks: 23 + * - sysbus clock: CPU core clock (CPUPLL) divided by 2, 3 or 4. 24 + * depends on board design and should be set by bootloader, read-only. 25 + * - peripheral clock: half the rate of sysbus clock, source for a lot 26 + * of peripheral blocks, read-only. 27 + * - memory clock: clk rate to main memory chips, depends on board 28 + * design and is read-only, 29 + * - lrclk: the static bus clock signal for synchronous operation. 30 + * depends on board design, must be set by bootloader, 31 + * but may be required to correctly configure devices attached to 32 + * the static bus. The Au1000/1500/1100 manuals call it LCLK, on 33 + * later models it's called RCLK. 34 + */ 35 + 36 + #include <linux/init.h> 37 + #include <linux/io.h> 38 + #include <linux/clk-provider.h> 39 + #include <linux/clkdev.h> 40 + #include <linux/clk-private.h> 41 + #include <linux/slab.h> 42 + #include <linux/spinlock.h> 43 + #include <linux/types.h> 44 + #include <asm/mach-au1x00/au1000.h> 45 + 46 + /* Base clock: 12MHz is the default in all databooks, and I haven't 47 + * found any board yet which uses a different rate. 48 + */ 49 + #define ALCHEMY_ROOTCLK_RATE 12000000 50 + 51 + /* 52 + * the internal sources which can be driven by the PLLs and dividers. 53 + * Names taken from the databooks, refer to them for more information, 54 + * especially which ones are share a clock line. 55 + */ 56 + static const char * const alchemy_au1300_intclknames[] = { 57 + "lcd_intclk", "gpemgp_clk", "maempe_clk", "maebsa_clk", 58 + "EXTCLK0", "EXTCLK1" 59 + }; 60 + 61 + static const char * const alchemy_au1200_intclknames[] = { 62 + "lcd_intclk", NULL, NULL, NULL, "EXTCLK0", "EXTCLK1" 63 + }; 64 + 65 + static const char * const alchemy_au1550_intclknames[] = { 66 + "usb_clk", "psc0_intclk", "psc1_intclk", "pci_clko", 67 + "EXTCLK0", "EXTCLK1" 68 + }; 69 + 70 + static const char * const alchemy_au1100_intclknames[] = { 71 + "usb_clk", "lcd_intclk", NULL, "i2s_clk", "EXTCLK0", "EXTCLK1" 72 + }; 73 + 74 + static const char * const alchemy_au1500_intclknames[] = { 75 + NULL, "usbd_clk", "usbh_clk", "pci_clko", "EXTCLK0", "EXTCLK1" 76 + }; 77 + 78 + static const char * const alchemy_au1000_intclknames[] = { 79 + "irda_clk", "usbd_clk", "usbh_clk", "i2s_clk", "EXTCLK0", 80 + "EXTCLK1" 81 + }; 82 + 83 + /* aliases for a few on-chip sources which are either shared 84 + * or have gone through name changes. 85 + */ 86 + static struct clk_aliastable { 87 + char *alias; 88 + char *base; 89 + int cputype; 90 + } alchemy_clk_aliases[] __initdata = { 91 + { "usbh_clk", "usb_clk", ALCHEMY_CPU_AU1100 }, 92 + { "usbd_clk", "usb_clk", ALCHEMY_CPU_AU1100 }, 93 + { "irda_clk", "usb_clk", ALCHEMY_CPU_AU1100 }, 94 + { "usbh_clk", "usb_clk", ALCHEMY_CPU_AU1550 }, 95 + { "usbd_clk", "usb_clk", ALCHEMY_CPU_AU1550 }, 96 + { "psc2_intclk", "usb_clk", ALCHEMY_CPU_AU1550 }, 97 + { "psc3_intclk", "EXTCLK0", ALCHEMY_CPU_AU1550 }, 98 + { "psc0_intclk", "EXTCLK0", ALCHEMY_CPU_AU1200 }, 99 + { "psc1_intclk", "EXTCLK1", ALCHEMY_CPU_AU1200 }, 100 + { "psc0_intclk", "EXTCLK0", ALCHEMY_CPU_AU1300 }, 101 + { "psc2_intclk", "EXTCLK0", ALCHEMY_CPU_AU1300 }, 102 + { "psc1_intclk", "EXTCLK1", ALCHEMY_CPU_AU1300 }, 103 + { "psc3_intclk", "EXTCLK1", ALCHEMY_CPU_AU1300 }, 104 + 105 + { NULL, NULL, 0 }, 106 + }; 107 + 108 + #define IOMEM(x) ((void __iomem *)(KSEG1ADDR(CPHYSADDR(x)))) 109 + 110 + /* access locks to SYS_FREQCTRL0/1 and SYS_CLKSRC registers */ 111 + static spinlock_t alchemy_clk_fg0_lock; 112 + static spinlock_t alchemy_clk_fg1_lock; 113 + static spinlock_t alchemy_clk_csrc_lock; 114 + 115 + /* CPU Core clock *****************************************************/ 116 + 117 + static unsigned long alchemy_clk_cpu_recalc(struct clk_hw *hw, 118 + unsigned long parent_rate) 119 + { 120 + unsigned long t; 121 + 122 + /* 123 + * On early Au1000, sys_cpupll was write-only. Since these 124 + * silicon versions of Au1000 are not sold, we don't bend 125 + * over backwards trying to determine the frequency. 126 + */ 127 + if (unlikely(au1xxx_cpu_has_pll_wo())) 128 + t = 396000000; 129 + else { 130 + t = alchemy_rdsys(AU1000_SYS_CPUPLL) & 0x7f; 131 + t *= parent_rate; 132 + } 133 + 134 + return t; 135 + } 136 + 137 + static struct clk_ops alchemy_clkops_cpu = { 138 + .recalc_rate = alchemy_clk_cpu_recalc, 139 + }; 140 + 141 + static struct clk __init *alchemy_clk_setup_cpu(const char *parent_name, 142 + int ctype) 143 + { 144 + struct clk_init_data id; 145 + struct clk_hw *h; 146 + 147 + h = kzalloc(sizeof(*h), GFP_KERNEL); 148 + if (!h) 149 + return ERR_PTR(-ENOMEM); 150 + 151 + id.name = ALCHEMY_CPU_CLK; 152 + id.parent_names = &parent_name; 153 + id.num_parents = 1; 154 + id.flags = CLK_IS_BASIC; 155 + id.ops = &alchemy_clkops_cpu; 156 + h->init = &id; 157 + 158 + return clk_register(NULL, h); 159 + } 160 + 161 + /* AUXPLLs ************************************************************/ 162 + 163 + struct alchemy_auxpll_clk { 164 + struct clk_hw hw; 165 + unsigned long reg; /* au1300 has also AUXPLL2 */ 166 + int maxmult; /* max multiplier */ 167 + }; 168 + #define to_auxpll_clk(x) container_of(x, struct alchemy_auxpll_clk, hw) 169 + 170 + static unsigned long alchemy_clk_aux_recalc(struct clk_hw *hw, 171 + unsigned long parent_rate) 172 + { 173 + struct alchemy_auxpll_clk *a = to_auxpll_clk(hw); 174 + 175 + return (alchemy_rdsys(a->reg) & 0xff) * parent_rate; 176 + } 177 + 178 + static int alchemy_clk_aux_setr(struct clk_hw *hw, 179 + unsigned long rate, 180 + unsigned long parent_rate) 181 + { 182 + struct alchemy_auxpll_clk *a = to_auxpll_clk(hw); 183 + unsigned long d = rate; 184 + 185 + if (rate) 186 + d /= parent_rate; 187 + else 188 + d = 0; 189 + 190 + /* minimum is 84MHz, max is 756-1032 depending on variant */ 191 + if (((d < 7) && (d != 0)) || (d > a->maxmult)) 192 + return -EINVAL; 193 + 194 + alchemy_wrsys(d, a->reg); 195 + return 0; 196 + } 197 + 198 + static long alchemy_clk_aux_roundr(struct clk_hw *hw, 199 + unsigned long rate, 200 + unsigned long *parent_rate) 201 + { 202 + struct alchemy_auxpll_clk *a = to_auxpll_clk(hw); 203 + unsigned long mult; 204 + 205 + if (!rate || !*parent_rate) 206 + return 0; 207 + 208 + mult = rate / (*parent_rate); 209 + 210 + if (mult && (mult < 7)) 211 + mult = 7; 212 + if (mult > a->maxmult) 213 + mult = a->maxmult; 214 + 215 + return (*parent_rate) * mult; 216 + } 217 + 218 + static struct clk_ops alchemy_clkops_aux = { 219 + .recalc_rate = alchemy_clk_aux_recalc, 220 + .set_rate = alchemy_clk_aux_setr, 221 + .round_rate = alchemy_clk_aux_roundr, 222 + }; 223 + 224 + static struct clk __init *alchemy_clk_setup_aux(const char *parent_name, 225 + char *name, int maxmult, 226 + unsigned long reg) 227 + { 228 + struct clk_init_data id; 229 + struct clk *c; 230 + struct alchemy_auxpll_clk *a; 231 + 232 + a = kzalloc(sizeof(*a), GFP_KERNEL); 233 + if (!a) 234 + return ERR_PTR(-ENOMEM); 235 + 236 + id.name = name; 237 + id.parent_names = &parent_name; 238 + id.num_parents = 1; 239 + id.flags = CLK_GET_RATE_NOCACHE; 240 + id.ops = &alchemy_clkops_aux; 241 + 242 + a->reg = reg; 243 + a->maxmult = maxmult; 244 + a->hw.init = &id; 245 + 246 + c = clk_register(NULL, &a->hw); 247 + if (!IS_ERR(c)) 248 + clk_register_clkdev(c, name, NULL); 249 + else 250 + kfree(a); 251 + 252 + return c; 253 + } 254 + 255 + /* sysbus_clk *********************************************************/ 256 + 257 + static struct clk __init *alchemy_clk_setup_sysbus(const char *pn) 258 + { 259 + unsigned long v = (alchemy_rdsys(AU1000_SYS_POWERCTRL) & 3) + 2; 260 + struct clk *c; 261 + 262 + c = clk_register_fixed_factor(NULL, ALCHEMY_SYSBUS_CLK, 263 + pn, 0, 1, v); 264 + if (!IS_ERR(c)) 265 + clk_register_clkdev(c, ALCHEMY_SYSBUS_CLK, NULL); 266 + return c; 267 + } 268 + 269 + /* Peripheral Clock ***************************************************/ 270 + 271 + static struct clk __init *alchemy_clk_setup_periph(const char *pn) 272 + { 273 + /* Peripheral clock runs at half the rate of sysbus clk */ 274 + struct clk *c; 275 + 276 + c = clk_register_fixed_factor(NULL, ALCHEMY_PERIPH_CLK, 277 + pn, 0, 1, 2); 278 + if (!IS_ERR(c)) 279 + clk_register_clkdev(c, ALCHEMY_PERIPH_CLK, NULL); 280 + return c; 281 + } 282 + 283 + /* mem clock **********************************************************/ 284 + 285 + static struct clk __init *alchemy_clk_setup_mem(const char *pn, int ct) 286 + { 287 + void __iomem *addr = IOMEM(AU1000_MEM_PHYS_ADDR); 288 + unsigned long v; 289 + struct clk *c; 290 + int div; 291 + 292 + switch (ct) { 293 + case ALCHEMY_CPU_AU1550: 294 + case ALCHEMY_CPU_AU1200: 295 + v = __raw_readl(addr + AU1550_MEM_SDCONFIGB); 296 + div = (v & (1 << 15)) ? 1 : 2; 297 + break; 298 + case ALCHEMY_CPU_AU1300: 299 + v = __raw_readl(addr + AU1550_MEM_SDCONFIGB); 300 + div = (v & (1 << 31)) ? 1 : 2; 301 + break; 302 + case ALCHEMY_CPU_AU1000: 303 + case ALCHEMY_CPU_AU1500: 304 + case ALCHEMY_CPU_AU1100: 305 + default: 306 + div = 2; 307 + break; 308 + } 309 + 310 + c = clk_register_fixed_factor(NULL, ALCHEMY_MEM_CLK, pn, 311 + 0, 1, div); 312 + if (!IS_ERR(c)) 313 + clk_register_clkdev(c, ALCHEMY_MEM_CLK, NULL); 314 + return c; 315 + } 316 + 317 + /* lrclk: external synchronous static bus clock ***********************/ 318 + 319 + static struct clk __init *alchemy_clk_setup_lrclk(const char *pn) 320 + { 321 + /* MEM_STCFG0[15:13] = divisor. 322 + * L/RCLK = periph_clk / (divisor + 1) 323 + * On Au1000, Au1500, Au1100 it's called LCLK, 324 + * on later models it's called RCLK, but it's the same thing. 325 + */ 326 + struct clk *c; 327 + unsigned long v = alchemy_rdsmem(AU1000_MEM_STCFG0) >> 13; 328 + 329 + v = (v & 7) + 1; 330 + c = clk_register_fixed_factor(NULL, ALCHEMY_LR_CLK, 331 + pn, 0, 1, v); 332 + if (!IS_ERR(c)) 333 + clk_register_clkdev(c, ALCHEMY_LR_CLK, NULL); 334 + return c; 335 + } 336 + 337 + /* Clock dividers and muxes *******************************************/ 338 + 339 + /* data for fgen and csrc mux-dividers */ 340 + struct alchemy_fgcs_clk { 341 + struct clk_hw hw; 342 + spinlock_t *reglock; /* register lock */ 343 + unsigned long reg; /* SYS_FREQCTRL0/1 */ 344 + int shift; /* offset in register */ 345 + int parent; /* parent before disable [Au1300] */ 346 + int isen; /* is it enabled? */ 347 + int *dt; /* dividertable for csrc */ 348 + }; 349 + #define to_fgcs_clk(x) container_of(x, struct alchemy_fgcs_clk, hw) 350 + 351 + static long alchemy_calc_div(unsigned long rate, unsigned long prate, 352 + int scale, int maxdiv, unsigned long *rv) 353 + { 354 + long div1, div2; 355 + 356 + div1 = prate / rate; 357 + if ((prate / div1) > rate) 358 + div1++; 359 + 360 + if (scale == 2) { /* only div-by-multiple-of-2 possible */ 361 + if (div1 & 1) 362 + div1++; /* stay <=prate */ 363 + } 364 + 365 + div2 = (div1 / scale) - 1; /* value to write to register */ 366 + 367 + if (div2 > maxdiv) 368 + div2 = maxdiv; 369 + if (rv) 370 + *rv = div2; 371 + 372 + div1 = ((div2 + 1) * scale); 373 + return div1; 374 + } 375 + 376 + static long alchemy_clk_fgcs_detr(struct clk_hw *hw, unsigned long rate, 377 + unsigned long *best_parent_rate, 378 + struct clk **best_parent_clk, 379 + int scale, int maxdiv) 380 + { 381 + struct clk *pc, *bpc, *free; 382 + long tdv, tpr, pr, nr, br, bpr, diff, lastdiff; 383 + int j; 384 + 385 + lastdiff = INT_MAX; 386 + bpr = 0; 387 + bpc = NULL; 388 + br = -EINVAL; 389 + free = NULL; 390 + 391 + /* look at the rates each enabled parent supplies and select 392 + * the one that gets closest to but not over the requested rate. 393 + */ 394 + for (j = 0; j < 7; j++) { 395 + pc = clk_get_parent_by_index(hw->clk, j); 396 + if (!pc) 397 + break; 398 + 399 + /* if this parent is currently unused, remember it. 400 + * XXX: I know it's a layering violation, but it works 401 + * so well.. (if (!clk_has_active_children(pc)) ) 402 + */ 403 + if (pc->prepare_count == 0) { 404 + if (!free) 405 + free = pc; 406 + } 407 + 408 + pr = clk_get_rate(pc); 409 + if (pr < rate) 410 + continue; 411 + 412 + /* what can hardware actually provide */ 413 + tdv = alchemy_calc_div(rate, pr, scale, maxdiv, NULL); 414 + nr = pr / tdv; 415 + diff = rate - nr; 416 + if (nr > rate) 417 + continue; 418 + 419 + if (diff < lastdiff) { 420 + lastdiff = diff; 421 + bpr = pr; 422 + bpc = pc; 423 + br = nr; 424 + } 425 + if (diff == 0) 426 + break; 427 + } 428 + 429 + /* if we couldn't get the exact rate we wanted from the enabled 430 + * parents, maybe we can tell an available disabled/inactive one 431 + * to give us a rate we can divide down to the requested rate. 432 + */ 433 + if (lastdiff && free) { 434 + for (j = (maxdiv == 4) ? 1 : scale; j <= maxdiv; j += scale) { 435 + tpr = rate * j; 436 + if (tpr < 0) 437 + break; 438 + pr = clk_round_rate(free, tpr); 439 + 440 + tdv = alchemy_calc_div(rate, pr, scale, maxdiv, NULL); 441 + nr = pr / tdv; 442 + diff = rate - nr; 443 + if (nr > rate) 444 + continue; 445 + if (diff < lastdiff) { 446 + lastdiff = diff; 447 + bpr = pr; 448 + bpc = free; 449 + br = nr; 450 + } 451 + if (diff == 0) 452 + break; 453 + } 454 + } 455 + 456 + *best_parent_rate = bpr; 457 + *best_parent_clk = bpc; 458 + return br; 459 + } 460 + 461 + static int alchemy_clk_fgv1_en(struct clk_hw *hw) 462 + { 463 + struct alchemy_fgcs_clk *c = to_fgcs_clk(hw); 464 + unsigned long v, flags; 465 + 466 + spin_lock_irqsave(c->reglock, flags); 467 + v = alchemy_rdsys(c->reg); 468 + v |= (1 << 1) << c->shift; 469 + alchemy_wrsys(v, c->reg); 470 + spin_unlock_irqrestore(c->reglock, flags); 471 + 472 + return 0; 473 + } 474 + 475 + static int alchemy_clk_fgv1_isen(struct clk_hw *hw) 476 + { 477 + struct alchemy_fgcs_clk *c = to_fgcs_clk(hw); 478 + unsigned long v = alchemy_rdsys(c->reg) >> (c->shift + 1); 479 + 480 + return v & 1; 481 + } 482 + 483 + static void alchemy_clk_fgv1_dis(struct clk_hw *hw) 484 + { 485 + struct alchemy_fgcs_clk *c = to_fgcs_clk(hw); 486 + unsigned long v, flags; 487 + 488 + spin_lock_irqsave(c->reglock, flags); 489 + v = alchemy_rdsys(c->reg); 490 + v &= ~((1 << 1) << c->shift); 491 + alchemy_wrsys(v, c->reg); 492 + spin_unlock_irqrestore(c->reglock, flags); 493 + } 494 + 495 + static int alchemy_clk_fgv1_setp(struct clk_hw *hw, u8 index) 496 + { 497 + struct alchemy_fgcs_clk *c = to_fgcs_clk(hw); 498 + unsigned long v, flags; 499 + 500 + spin_lock_irqsave(c->reglock, flags); 501 + v = alchemy_rdsys(c->reg); 502 + if (index) 503 + v |= (1 << c->shift); 504 + else 505 + v &= ~(1 << c->shift); 506 + alchemy_wrsys(v, c->reg); 507 + spin_unlock_irqrestore(c->reglock, flags); 508 + 509 + return 0; 510 + } 511 + 512 + static u8 alchemy_clk_fgv1_getp(struct clk_hw *hw) 513 + { 514 + struct alchemy_fgcs_clk *c = to_fgcs_clk(hw); 515 + 516 + return (alchemy_rdsys(c->reg) >> c->shift) & 1; 517 + } 518 + 519 + static int alchemy_clk_fgv1_setr(struct clk_hw *hw, unsigned long rate, 520 + unsigned long parent_rate) 521 + { 522 + struct alchemy_fgcs_clk *c = to_fgcs_clk(hw); 523 + unsigned long div, v, flags, ret; 524 + int sh = c->shift + 2; 525 + 526 + if (!rate || !parent_rate || rate > (parent_rate / 2)) 527 + return -EINVAL; 528 + ret = alchemy_calc_div(rate, parent_rate, 2, 512, &div); 529 + spin_lock_irqsave(c->reglock, flags); 530 + v = alchemy_rdsys(c->reg); 531 + v &= ~(0xff << sh); 532 + v |= div << sh; 533 + alchemy_wrsys(v, c->reg); 534 + spin_unlock_irqrestore(c->reglock, flags); 535 + 536 + return 0; 537 + } 538 + 539 + static unsigned long alchemy_clk_fgv1_recalc(struct clk_hw *hw, 540 + unsigned long parent_rate) 541 + { 542 + struct alchemy_fgcs_clk *c = to_fgcs_clk(hw); 543 + unsigned long v = alchemy_rdsys(c->reg) >> (c->shift + 2); 544 + 545 + v = ((v & 0xff) + 1) * 2; 546 + return parent_rate / v; 547 + } 548 + 549 + static long alchemy_clk_fgv1_detr(struct clk_hw *hw, unsigned long rate, 550 + unsigned long *best_parent_rate, 551 + struct clk **best_parent_clk) 552 + { 553 + return alchemy_clk_fgcs_detr(hw, rate, best_parent_rate, 554 + best_parent_clk, 2, 512); 555 + } 556 + 557 + /* Au1000, Au1100, Au15x0, Au12x0 */ 558 + static struct clk_ops alchemy_clkops_fgenv1 = { 559 + .recalc_rate = alchemy_clk_fgv1_recalc, 560 + .determine_rate = alchemy_clk_fgv1_detr, 561 + .set_rate = alchemy_clk_fgv1_setr, 562 + .set_parent = alchemy_clk_fgv1_setp, 563 + .get_parent = alchemy_clk_fgv1_getp, 564 + .enable = alchemy_clk_fgv1_en, 565 + .disable = alchemy_clk_fgv1_dis, 566 + .is_enabled = alchemy_clk_fgv1_isen, 567 + }; 568 + 569 + static void __alchemy_clk_fgv2_en(struct alchemy_fgcs_clk *c) 570 + { 571 + unsigned long v = alchemy_rdsys(c->reg); 572 + 573 + v &= ~(3 << c->shift); 574 + v |= (c->parent & 3) << c->shift; 575 + alchemy_wrsys(v, c->reg); 576 + c->isen = 1; 577 + } 578 + 579 + static int alchemy_clk_fgv2_en(struct clk_hw *hw) 580 + { 581 + struct alchemy_fgcs_clk *c = to_fgcs_clk(hw); 582 + unsigned long flags; 583 + 584 + /* enable by setting the previous parent clock */ 585 + spin_lock_irqsave(c->reglock, flags); 586 + __alchemy_clk_fgv2_en(c); 587 + spin_unlock_irqrestore(c->reglock, flags); 588 + 589 + return 0; 590 + } 591 + 592 + static int alchemy_clk_fgv2_isen(struct clk_hw *hw) 593 + { 594 + struct alchemy_fgcs_clk *c = to_fgcs_clk(hw); 595 + 596 + return ((alchemy_rdsys(c->reg) >> c->shift) & 3) != 0; 597 + } 598 + 599 + static void alchemy_clk_fgv2_dis(struct clk_hw *hw) 600 + { 601 + struct alchemy_fgcs_clk *c = to_fgcs_clk(hw); 602 + unsigned long v, flags; 603 + 604 + spin_lock_irqsave(c->reglock, flags); 605 + v = alchemy_rdsys(c->reg); 606 + v &= ~(3 << c->shift); /* set input mux to "disabled" state */ 607 + alchemy_wrsys(v, c->reg); 608 + c->isen = 0; 609 + spin_unlock_irqrestore(c->reglock, flags); 610 + } 611 + 612 + static int alchemy_clk_fgv2_setp(struct clk_hw *hw, u8 index) 613 + { 614 + struct alchemy_fgcs_clk *c = to_fgcs_clk(hw); 615 + unsigned long flags; 616 + 617 + spin_lock_irqsave(c->reglock, flags); 618 + c->parent = index + 1; /* value to write to register */ 619 + if (c->isen) 620 + __alchemy_clk_fgv2_en(c); 621 + spin_unlock_irqrestore(c->reglock, flags); 622 + 623 + return 0; 624 + } 625 + 626 + static u8 alchemy_clk_fgv2_getp(struct clk_hw *hw) 627 + { 628 + struct alchemy_fgcs_clk *c = to_fgcs_clk(hw); 629 + unsigned long flags, v; 630 + 631 + spin_lock_irqsave(c->reglock, flags); 632 + v = c->parent - 1; 633 + spin_unlock_irqrestore(c->reglock, flags); 634 + return v; 635 + } 636 + 637 + /* fg0-2 and fg4-6 share a "scale"-bit. With this bit cleared, the 638 + * dividers behave exactly as on previous models (dividers are multiples 639 + * of 2); with the bit set, dividers are multiples of 1, halving their 640 + * range, but making them also much more flexible. 641 + */ 642 + static int alchemy_clk_fgv2_setr(struct clk_hw *hw, unsigned long rate, 643 + unsigned long parent_rate) 644 + { 645 + struct alchemy_fgcs_clk *c = to_fgcs_clk(hw); 646 + int sh = c->shift + 2; 647 + unsigned long div, v, flags, ret; 648 + 649 + if (!rate || !parent_rate || rate > parent_rate) 650 + return -EINVAL; 651 + 652 + v = alchemy_rdsys(c->reg) & (1 << 30); /* test "scale" bit */ 653 + ret = alchemy_calc_div(rate, parent_rate, v ? 1 : 2, 654 + v ? 256 : 512, &div); 655 + 656 + spin_lock_irqsave(c->reglock, flags); 657 + v = alchemy_rdsys(c->reg); 658 + v &= ~(0xff << sh); 659 + v |= (div & 0xff) << sh; 660 + alchemy_wrsys(v, c->reg); 661 + spin_unlock_irqrestore(c->reglock, flags); 662 + 663 + return 0; 664 + } 665 + 666 + static unsigned long alchemy_clk_fgv2_recalc(struct clk_hw *hw, 667 + unsigned long parent_rate) 668 + { 669 + struct alchemy_fgcs_clk *c = to_fgcs_clk(hw); 670 + int sh = c->shift + 2; 671 + unsigned long v, t; 672 + 673 + v = alchemy_rdsys(c->reg); 674 + t = parent_rate / (((v >> sh) & 0xff) + 1); 675 + if ((v & (1 << 30)) == 0) /* test scale bit */ 676 + t /= 2; 677 + 678 + return t; 679 + } 680 + 681 + static long alchemy_clk_fgv2_detr(struct clk_hw *hw, unsigned long rate, 682 + unsigned long *best_parent_rate, 683 + struct clk **best_parent_clk) 684 + { 685 + struct alchemy_fgcs_clk *c = to_fgcs_clk(hw); 686 + int scale, maxdiv; 687 + 688 + if (alchemy_rdsys(c->reg) & (1 << 30)) { 689 + scale = 1; 690 + maxdiv = 256; 691 + } else { 692 + scale = 2; 693 + maxdiv = 512; 694 + } 695 + 696 + return alchemy_clk_fgcs_detr(hw, rate, best_parent_rate, 697 + best_parent_clk, scale, maxdiv); 698 + } 699 + 700 + /* Au1300 larger input mux, no separate disable bit, flexible divider */ 701 + static struct clk_ops alchemy_clkops_fgenv2 = { 702 + .recalc_rate = alchemy_clk_fgv2_recalc, 703 + .determine_rate = alchemy_clk_fgv2_detr, 704 + .set_rate = alchemy_clk_fgv2_setr, 705 + .set_parent = alchemy_clk_fgv2_setp, 706 + .get_parent = alchemy_clk_fgv2_getp, 707 + .enable = alchemy_clk_fgv2_en, 708 + .disable = alchemy_clk_fgv2_dis, 709 + .is_enabled = alchemy_clk_fgv2_isen, 710 + }; 711 + 712 + static const char * const alchemy_clk_fgv1_parents[] = { 713 + ALCHEMY_CPU_CLK, ALCHEMY_AUXPLL_CLK 714 + }; 715 + 716 + static const char * const alchemy_clk_fgv2_parents[] = { 717 + ALCHEMY_AUXPLL2_CLK, ALCHEMY_CPU_CLK, ALCHEMY_AUXPLL_CLK 718 + }; 719 + 720 + static const char * const alchemy_clk_fgen_names[] = { 721 + ALCHEMY_FG0_CLK, ALCHEMY_FG1_CLK, ALCHEMY_FG2_CLK, 722 + ALCHEMY_FG3_CLK, ALCHEMY_FG4_CLK, ALCHEMY_FG5_CLK }; 723 + 724 + static int __init alchemy_clk_init_fgens(int ctype) 725 + { 726 + struct clk *c; 727 + struct clk_init_data id; 728 + struct alchemy_fgcs_clk *a; 729 + unsigned long v; 730 + int i, ret; 731 + 732 + switch (ctype) { 733 + case ALCHEMY_CPU_AU1000...ALCHEMY_CPU_AU1200: 734 + id.ops = &alchemy_clkops_fgenv1; 735 + id.parent_names = (const char **)alchemy_clk_fgv1_parents; 736 + id.num_parents = 2; 737 + break; 738 + case ALCHEMY_CPU_AU1300: 739 + id.ops = &alchemy_clkops_fgenv2; 740 + id.parent_names = (const char **)alchemy_clk_fgv2_parents; 741 + id.num_parents = 3; 742 + break; 743 + default: 744 + return -ENODEV; 745 + } 746 + id.flags = CLK_SET_RATE_PARENT | CLK_GET_RATE_NOCACHE; 747 + 748 + a = kzalloc((sizeof(*a)) * 6, GFP_KERNEL); 749 + if (!a) 750 + return -ENOMEM; 751 + 752 + spin_lock_init(&alchemy_clk_fg0_lock); 753 + spin_lock_init(&alchemy_clk_fg1_lock); 754 + ret = 0; 755 + for (i = 0; i < 6; i++) { 756 + id.name = alchemy_clk_fgen_names[i]; 757 + a->shift = 10 * (i < 3 ? i : i - 3); 758 + if (i > 2) { 759 + a->reg = AU1000_SYS_FREQCTRL1; 760 + a->reglock = &alchemy_clk_fg1_lock; 761 + } else { 762 + a->reg = AU1000_SYS_FREQCTRL0; 763 + a->reglock = &alchemy_clk_fg0_lock; 764 + } 765 + 766 + /* default to first parent if bootloader has set 767 + * the mux to disabled state. 768 + */ 769 + if (ctype == ALCHEMY_CPU_AU1300) { 770 + v = alchemy_rdsys(a->reg); 771 + a->parent = (v >> a->shift) & 3; 772 + if (!a->parent) { 773 + a->parent = 1; 774 + a->isen = 0; 775 + } else 776 + a->isen = 1; 777 + } 778 + 779 + a->hw.init = &id; 780 + c = clk_register(NULL, &a->hw); 781 + if (IS_ERR(c)) 782 + ret++; 783 + else 784 + clk_register_clkdev(c, id.name, NULL); 785 + a++; 786 + } 787 + 788 + return ret; 789 + } 790 + 791 + /* internal sources muxes *********************************************/ 792 + 793 + static int alchemy_clk_csrc_isen(struct clk_hw *hw) 794 + { 795 + struct alchemy_fgcs_clk *c = to_fgcs_clk(hw); 796 + unsigned long v = alchemy_rdsys(c->reg); 797 + 798 + return (((v >> c->shift) >> 2) & 7) != 0; 799 + } 800 + 801 + static void __alchemy_clk_csrc_en(struct alchemy_fgcs_clk *c) 802 + { 803 + unsigned long v = alchemy_rdsys(c->reg); 804 + 805 + v &= ~((7 << 2) << c->shift); 806 + v |= ((c->parent & 7) << 2) << c->shift; 807 + alchemy_wrsys(v, c->reg); 808 + c->isen = 1; 809 + } 810 + 811 + static int alchemy_clk_csrc_en(struct clk_hw *hw) 812 + { 813 + struct alchemy_fgcs_clk *c = to_fgcs_clk(hw); 814 + unsigned long flags; 815 + 816 + /* enable by setting the previous parent clock */ 817 + spin_lock_irqsave(c->reglock, flags); 818 + __alchemy_clk_csrc_en(c); 819 + spin_unlock_irqrestore(c->reglock, flags); 820 + 821 + return 0; 822 + } 823 + 824 + static void alchemy_clk_csrc_dis(struct clk_hw *hw) 825 + { 826 + struct alchemy_fgcs_clk *c = to_fgcs_clk(hw); 827 + unsigned long v, flags; 828 + 829 + spin_lock_irqsave(c->reglock, flags); 830 + v = alchemy_rdsys(c->reg); 831 + v &= ~((3 << 2) << c->shift); /* mux to "disabled" state */ 832 + alchemy_wrsys(v, c->reg); 833 + c->isen = 0; 834 + spin_unlock_irqrestore(c->reglock, flags); 835 + } 836 + 837 + static int alchemy_clk_csrc_setp(struct clk_hw *hw, u8 index) 838 + { 839 + struct alchemy_fgcs_clk *c = to_fgcs_clk(hw); 840 + unsigned long flags; 841 + 842 + spin_lock_irqsave(c->reglock, flags); 843 + c->parent = index + 1; /* value to write to register */ 844 + if (c->isen) 845 + __alchemy_clk_csrc_en(c); 846 + spin_unlock_irqrestore(c->reglock, flags); 847 + 848 + return 0; 849 + } 850 + 851 + static u8 alchemy_clk_csrc_getp(struct clk_hw *hw) 852 + { 853 + struct alchemy_fgcs_clk *c = to_fgcs_clk(hw); 854 + 855 + return c->parent - 1; 856 + } 857 + 858 + static unsigned long alchemy_clk_csrc_recalc(struct clk_hw *hw, 859 + unsigned long parent_rate) 860 + { 861 + struct alchemy_fgcs_clk *c = to_fgcs_clk(hw); 862 + unsigned long v = (alchemy_rdsys(c->reg) >> c->shift) & 3; 863 + 864 + return parent_rate / c->dt[v]; 865 + } 866 + 867 + static int alchemy_clk_csrc_setr(struct clk_hw *hw, unsigned long rate, 868 + unsigned long parent_rate) 869 + { 870 + struct alchemy_fgcs_clk *c = to_fgcs_clk(hw); 871 + unsigned long d, v, flags; 872 + int i; 873 + 874 + if (!rate || !parent_rate || rate > parent_rate) 875 + return -EINVAL; 876 + 877 + d = (parent_rate + (rate / 2)) / rate; 878 + if (d > 4) 879 + return -EINVAL; 880 + if ((d == 3) && (c->dt[2] != 3)) 881 + d = 4; 882 + 883 + for (i = 0; i < 4; i++) 884 + if (c->dt[i] == d) 885 + break; 886 + 887 + if (i >= 4) 888 + return -EINVAL; /* oops */ 889 + 890 + spin_lock_irqsave(c->reglock, flags); 891 + v = alchemy_rdsys(c->reg); 892 + v &= ~(3 << c->shift); 893 + v |= (i & 3) << c->shift; 894 + alchemy_wrsys(v, c->reg); 895 + spin_unlock_irqrestore(c->reglock, flags); 896 + 897 + return 0; 898 + } 899 + 900 + static long alchemy_clk_csrc_detr(struct clk_hw *hw, unsigned long rate, 901 + unsigned long *best_parent_rate, 902 + struct clk **best_parent_clk) 903 + { 904 + struct alchemy_fgcs_clk *c = to_fgcs_clk(hw); 905 + int scale = c->dt[2] == 3 ? 1 : 2; /* au1300 check */ 906 + 907 + return alchemy_clk_fgcs_detr(hw, rate, best_parent_rate, 908 + best_parent_clk, scale, 4); 909 + } 910 + 911 + static struct clk_ops alchemy_clkops_csrc = { 912 + .recalc_rate = alchemy_clk_csrc_recalc, 913 + .determine_rate = alchemy_clk_csrc_detr, 914 + .set_rate = alchemy_clk_csrc_setr, 915 + .set_parent = alchemy_clk_csrc_setp, 916 + .get_parent = alchemy_clk_csrc_getp, 917 + .enable = alchemy_clk_csrc_en, 918 + .disable = alchemy_clk_csrc_dis, 919 + .is_enabled = alchemy_clk_csrc_isen, 920 + }; 921 + 922 + static const char * const alchemy_clk_csrc_parents[] = { 923 + /* disabled at index 0 */ ALCHEMY_AUXPLL_CLK, 924 + ALCHEMY_FG0_CLK, ALCHEMY_FG1_CLK, ALCHEMY_FG2_CLK, 925 + ALCHEMY_FG3_CLK, ALCHEMY_FG4_CLK, ALCHEMY_FG5_CLK 926 + }; 927 + 928 + /* divider tables */ 929 + static int alchemy_csrc_dt1[] = { 1, 4, 1, 2 }; /* rest */ 930 + static int alchemy_csrc_dt2[] = { 1, 4, 3, 2 }; /* Au1300 */ 931 + 932 + static int __init alchemy_clk_setup_imux(int ctype) 933 + { 934 + struct alchemy_fgcs_clk *a; 935 + const char * const *names; 936 + struct clk_init_data id; 937 + unsigned long v; 938 + int i, ret, *dt; 939 + struct clk *c; 940 + 941 + id.ops = &alchemy_clkops_csrc; 942 + id.parent_names = (const char **)alchemy_clk_csrc_parents; 943 + id.num_parents = 7; 944 + id.flags = CLK_SET_RATE_PARENT | CLK_GET_RATE_NOCACHE; 945 + 946 + dt = alchemy_csrc_dt1; 947 + switch (ctype) { 948 + case ALCHEMY_CPU_AU1000: 949 + names = alchemy_au1000_intclknames; 950 + break; 951 + case ALCHEMY_CPU_AU1500: 952 + names = alchemy_au1500_intclknames; 953 + break; 954 + case ALCHEMY_CPU_AU1100: 955 + names = alchemy_au1100_intclknames; 956 + break; 957 + case ALCHEMY_CPU_AU1550: 958 + names = alchemy_au1550_intclknames; 959 + break; 960 + case ALCHEMY_CPU_AU1200: 961 + names = alchemy_au1200_intclknames; 962 + break; 963 + case ALCHEMY_CPU_AU1300: 964 + dt = alchemy_csrc_dt2; 965 + names = alchemy_au1300_intclknames; 966 + break; 967 + default: 968 + return -ENODEV; 969 + } 970 + 971 + a = kzalloc((sizeof(*a)) * 6, GFP_KERNEL); 972 + if (!a) 973 + return -ENOMEM; 974 + 975 + spin_lock_init(&alchemy_clk_csrc_lock); 976 + ret = 0; 977 + 978 + for (i = 0; i < 6; i++) { 979 + id.name = names[i]; 980 + if (!id.name) 981 + goto next; 982 + 983 + a->shift = i * 5; 984 + a->reg = AU1000_SYS_CLKSRC; 985 + a->reglock = &alchemy_clk_csrc_lock; 986 + a->dt = dt; 987 + 988 + /* default to first parent clock if mux is initially 989 + * set to disabled state. 990 + */ 991 + v = alchemy_rdsys(a->reg); 992 + a->parent = ((v >> a->shift) >> 2) & 7; 993 + if (!a->parent) { 994 + a->parent = 1; 995 + a->isen = 0; 996 + } else 997 + a->isen = 1; 998 + 999 + a->hw.init = &id; 1000 + c = clk_register(NULL, &a->hw); 1001 + if (IS_ERR(c)) 1002 + ret++; 1003 + else 1004 + clk_register_clkdev(c, id.name, NULL); 1005 + next: 1006 + a++; 1007 + } 1008 + 1009 + return ret; 1010 + } 1011 + 1012 + 1013 + /**********************************************************************/ 1014 + 1015 + 1016 + #define ERRCK(x) \ 1017 + if (IS_ERR(x)) { \ 1018 + ret = PTR_ERR(x); \ 1019 + goto out; \ 1020 + } 1021 + 1022 + static int __init alchemy_clk_init(void) 1023 + { 1024 + int ctype = alchemy_get_cputype(), ret, i; 1025 + struct clk_aliastable *t = alchemy_clk_aliases; 1026 + struct clk *c; 1027 + 1028 + /* Root of the Alchemy clock tree: external 12MHz crystal osc */ 1029 + c = clk_register_fixed_rate(NULL, ALCHEMY_ROOT_CLK, NULL, 1030 + CLK_IS_ROOT, 1031 + ALCHEMY_ROOTCLK_RATE); 1032 + ERRCK(c) 1033 + 1034 + /* CPU core clock */ 1035 + c = alchemy_clk_setup_cpu(ALCHEMY_ROOT_CLK, ctype); 1036 + ERRCK(c) 1037 + 1038 + /* AUXPLLs: max 1GHz on Au1300, 748MHz on older models */ 1039 + i = (ctype == ALCHEMY_CPU_AU1300) ? 84 : 63; 1040 + c = alchemy_clk_setup_aux(ALCHEMY_ROOT_CLK, ALCHEMY_AUXPLL_CLK, 1041 + i, AU1000_SYS_AUXPLL); 1042 + ERRCK(c) 1043 + 1044 + if (ctype == ALCHEMY_CPU_AU1300) { 1045 + c = alchemy_clk_setup_aux(ALCHEMY_ROOT_CLK, 1046 + ALCHEMY_AUXPLL2_CLK, i, 1047 + AU1300_SYS_AUXPLL2); 1048 + ERRCK(c) 1049 + } 1050 + 1051 + /* sysbus clock: cpu core clock divided by 2, 3 or 4 */ 1052 + c = alchemy_clk_setup_sysbus(ALCHEMY_CPU_CLK); 1053 + ERRCK(c) 1054 + 1055 + /* peripheral clock: runs at half rate of sysbus clk */ 1056 + c = alchemy_clk_setup_periph(ALCHEMY_SYSBUS_CLK); 1057 + ERRCK(c) 1058 + 1059 + /* SDR/DDR memory clock */ 1060 + c = alchemy_clk_setup_mem(ALCHEMY_SYSBUS_CLK, ctype); 1061 + ERRCK(c) 1062 + 1063 + /* L/RCLK: external static bus clock for synchronous mode */ 1064 + c = alchemy_clk_setup_lrclk(ALCHEMY_PERIPH_CLK); 1065 + ERRCK(c) 1066 + 1067 + /* Frequency dividers 0-5 */ 1068 + ret = alchemy_clk_init_fgens(ctype); 1069 + if (ret) { 1070 + ret = -ENODEV; 1071 + goto out; 1072 + } 1073 + 1074 + /* diving muxes for internal sources */ 1075 + ret = alchemy_clk_setup_imux(ctype); 1076 + if (ret) { 1077 + ret = -ENODEV; 1078 + goto out; 1079 + } 1080 + 1081 + /* set up aliases drivers might look for */ 1082 + while (t->base) { 1083 + if (t->cputype == ctype) 1084 + clk_add_alias(t->alias, NULL, t->base, NULL); 1085 + t++; 1086 + } 1087 + 1088 + pr_info("Alchemy clocktree installed\n"); 1089 + return 0; 1090 + 1091 + out: 1092 + return ret; 1093 + } 1094 + postcore_initcall(alchemy_clk_init);
-105
arch/mips/alchemy/common/clocks.c
··· 1 - /* 2 - * BRIEF MODULE DESCRIPTION 3 - * Simple Au1xx0 clocks routines. 4 - * 5 - * Copyright 2001, 2008 MontaVista Software Inc. 6 - * Author: MontaVista Software, Inc. <source@mvista.com> 7 - * 8 - * This program is free software; you can redistribute it and/or modify it 9 - * under the terms of the GNU General Public License as published by the 10 - * Free Software Foundation; either version 2 of the License, or (at your 11 - * option) any later version. 12 - * 13 - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 14 - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 15 - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN 16 - * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 17 - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 18 - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 19 - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 20 - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 22 - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 - * 24 - * You should have received a copy of the GNU General Public License along 25 - * with this program; if not, write to the Free Software Foundation, Inc., 26 - * 675 Mass Ave, Cambridge, MA 02139, USA. 27 - */ 28 - 29 - #include <linux/module.h> 30 - #include <linux/spinlock.h> 31 - #include <asm/time.h> 32 - #include <asm/mach-au1x00/au1000.h> 33 - 34 - /* 35 - * I haven't found anyone that doesn't use a 12 MHz source clock, 36 - * but just in case..... 37 - */ 38 - #define AU1000_SRC_CLK 12000000 39 - 40 - static unsigned int au1x00_clock; /* Hz */ 41 - static unsigned long uart_baud_base; 42 - 43 - /* 44 - * Set the au1000_clock 45 - */ 46 - void set_au1x00_speed(unsigned int new_freq) 47 - { 48 - au1x00_clock = new_freq; 49 - } 50 - 51 - unsigned int get_au1x00_speed(void) 52 - { 53 - return au1x00_clock; 54 - } 55 - EXPORT_SYMBOL(get_au1x00_speed); 56 - 57 - /* 58 - * The UART baud base is not known at compile time ... if 59 - * we want to be able to use the same code on different 60 - * speed CPUs. 61 - */ 62 - unsigned long get_au1x00_uart_baud_base(void) 63 - { 64 - return uart_baud_base; 65 - } 66 - 67 - void set_au1x00_uart_baud_base(unsigned long new_baud_base) 68 - { 69 - uart_baud_base = new_baud_base; 70 - } 71 - 72 - /* 73 - * We read the real processor speed from the PLL. This is important 74 - * because it is more accurate than computing it from the 32 KHz 75 - * counter, if it exists. If we don't have an accurate processor 76 - * speed, all of the peripherals that derive their clocks based on 77 - * this advertised speed will introduce error and sometimes not work 78 - * properly. This function is further convoluted to still allow configurations 79 - * to do that in case they have really, really old silicon with a 80 - * write-only PLL register. -- Dan 81 - */ 82 - unsigned long au1xxx_calc_clock(void) 83 - { 84 - unsigned long cpu_speed; 85 - 86 - /* 87 - * On early Au1000, sys_cpupll was write-only. Since these 88 - * silicon versions of Au1000 are not sold by AMD, we don't bend 89 - * over backwards trying to determine the frequency. 90 - */ 91 - if (au1xxx_cpu_has_pll_wo()) 92 - cpu_speed = 396000000; 93 - else 94 - cpu_speed = (au_readl(SYS_CPUPLL) & 0x0000003f) * AU1000_SRC_CLK; 95 - 96 - /* On Alchemy CPU:counter ratio is 1:1 */ 97 - mips_hpt_frequency = cpu_speed; 98 - /* Equation: Baudrate = CPU / (SD * 2 * CLKDIV * 16) */ 99 - set_au1x00_uart_baud_base(cpu_speed / (2 * ((int)(au_readl(SYS_POWERCTRL) 100 - & 0x03) + 2) * 16)); 101 - 102 - set_au1x00_speed(cpu_speed); 103 - 104 - return cpu_speed; 105 - }
+11 -11
arch/mips/alchemy/common/dbdma.c
··· 341 341 (dtp->dev_flags & DEV_FLAGS_SYNC)) 342 342 i |= DDMA_CFG_SYNC; 343 343 cp->ddma_cfg = i; 344 - au_sync(); 344 + wmb(); /* drain writebuffer */ 345 345 346 346 /* 347 347 * Return a non-zero value that can be used to find the channel ··· 631 631 */ 632 632 dma_cache_wback_inv((unsigned long)buf, nbytes); 633 633 dp->dscr_cmd0 |= DSCR_CMD0_V; /* Let it rip */ 634 - au_sync(); 634 + wmb(); /* drain writebuffer */ 635 635 dma_cache_wback_inv((unsigned long)dp, sizeof(*dp)); 636 636 ctp->chan_ptr->ddma_dbell = 0; 637 637 ··· 693 693 */ 694 694 dma_cache_inv((unsigned long)buf, nbytes); 695 695 dp->dscr_cmd0 |= DSCR_CMD0_V; /* Let it rip */ 696 - au_sync(); 696 + wmb(); /* drain writebuffer */ 697 697 dma_cache_wback_inv((unsigned long)dp, sizeof(*dp)); 698 698 ctp->chan_ptr->ddma_dbell = 0; 699 699 ··· 760 760 761 761 cp = ctp->chan_ptr; 762 762 cp->ddma_cfg &= ~DDMA_CFG_EN; /* Disable channel */ 763 - au_sync(); 763 + wmb(); /* drain writebuffer */ 764 764 while (!(cp->ddma_stat & DDMA_STAT_H)) { 765 765 udelay(1); 766 766 halt_timeout++; ··· 771 771 } 772 772 /* clear current desc valid and doorbell */ 773 773 cp->ddma_stat |= (DDMA_STAT_DB | DDMA_STAT_V); 774 - au_sync(); 774 + wmb(); /* drain writebuffer */ 775 775 } 776 776 EXPORT_SYMBOL(au1xxx_dbdma_stop); 777 777 ··· 789 789 cp = ctp->chan_ptr; 790 790 cp->ddma_desptr = virt_to_phys(ctp->cur_ptr); 791 791 cp->ddma_cfg |= DDMA_CFG_EN; /* Enable channel */ 792 - au_sync(); 792 + wmb(); /* drain writebuffer */ 793 793 cp->ddma_dbell = 0; 794 - au_sync(); 794 + wmb(); /* drain writebuffer */ 795 795 } 796 796 EXPORT_SYMBOL(au1xxx_dbdma_start); 797 797 ··· 832 832 833 833 /* This is only valid if the channel is stopped. */ 834 834 rv = cp->ddma_bytecnt; 835 - au_sync(); 835 + wmb(); /* drain writebuffer */ 836 836 837 837 return rv; 838 838 } ··· 868 868 au1x_dma_chan_t *cp; 869 869 870 870 intstat = dbdma_gptr->ddma_intstat; 871 - au_sync(); 871 + wmb(); /* drain writebuffer */ 872 872 chan_index = __ffs(intstat); 873 873 874 874 ctp = chan_tab_ptr[chan_index]; ··· 877 877 878 878 /* Reset interrupt. */ 879 879 cp->ddma_irq = 0; 880 - au_sync(); 880 + wmb(); /* drain writebuffer */ 881 881 882 882 if (ctp->chan_callback) 883 883 ctp->chan_callback(irq, ctp->chan_callparam); ··· 1061 1061 dbdma_gptr->ddma_config = 0; 1062 1062 dbdma_gptr->ddma_throttle = 0; 1063 1063 dbdma_gptr->ddma_inten = 0xffff; 1064 - au_sync(); 1064 + wmb(); /* drain writebuffer */ 1065 1065 1066 1066 ret = request_irq(irq, dbdma_interrupt, 0, "dbdma", (void *)dbdma_gptr); 1067 1067 if (ret)
+8 -7
arch/mips/alchemy/common/dma.c
··· 141 141 142 142 printk(KERN_INFO "Au1000 DMA%d Register Dump:\n", dmanr); 143 143 printk(KERN_INFO " mode = 0x%08x\n", 144 - au_readl(chan->io + DMA_MODE_SET)); 144 + __raw_readl(chan->io + DMA_MODE_SET)); 145 145 printk(KERN_INFO " addr = 0x%08x\n", 146 - au_readl(chan->io + DMA_PERIPHERAL_ADDR)); 146 + __raw_readl(chan->io + DMA_PERIPHERAL_ADDR)); 147 147 printk(KERN_INFO " start0 = 0x%08x\n", 148 - au_readl(chan->io + DMA_BUFFER0_START)); 148 + __raw_readl(chan->io + DMA_BUFFER0_START)); 149 149 printk(KERN_INFO " start1 = 0x%08x\n", 150 - au_readl(chan->io + DMA_BUFFER1_START)); 150 + __raw_readl(chan->io + DMA_BUFFER1_START)); 151 151 printk(KERN_INFO " count0 = 0x%08x\n", 152 - au_readl(chan->io + DMA_BUFFER0_COUNT)); 152 + __raw_readl(chan->io + DMA_BUFFER0_COUNT)); 153 153 printk(KERN_INFO " count1 = 0x%08x\n", 154 - au_readl(chan->io + DMA_BUFFER1_COUNT)); 154 + __raw_readl(chan->io + DMA_BUFFER1_COUNT)); 155 155 } 156 156 157 157 /* ··· 204 204 } 205 205 206 206 /* fill it in */ 207 - chan->io = KSEG1ADDR(AU1000_DMA_PHYS_ADDR) + i * DMA_CHANNEL_LEN; 207 + chan->io = (void __iomem *)(KSEG1ADDR(AU1000_DMA_PHYS_ADDR) + 208 + i * DMA_CHANNEL_LEN); 208 209 chan->dev_id = dev_id; 209 210 chan->dev_str = dev_str; 210 211 chan->fifo_addr = dev->fifo_addr;
+2 -3
arch/mips/alchemy/common/irq.c
··· 389 389 return -EINVAL; 390 390 391 391 local_irq_save(flags); 392 - wakemsk = __raw_readl((void __iomem *)SYS_WAKEMSK); 392 + wakemsk = alchemy_rdsys(AU1000_SYS_WAKEMSK); 393 393 if (on) 394 394 wakemsk |= 1 << bit; 395 395 else 396 396 wakemsk &= ~(1 << bit); 397 - __raw_writel(wakemsk, (void __iomem *)SYS_WAKEMSK); 398 - wmb(); 397 + alchemy_wrsys(wakemsk, AU1000_SYS_WAKEMSK); 399 398 local_irq_restore(flags); 400 399 401 400 return 0;
+13 -2
arch/mips/alchemy/common/platform.c
··· 11 11 * warranty of any kind, whether express or implied. 12 12 */ 13 13 14 + #include <linux/clk.h> 14 15 #include <linux/dma-mapping.h> 15 16 #include <linux/etherdevice.h> 16 17 #include <linux/init.h> ··· 100 99 101 100 static void __init alchemy_setup_uarts(int ctype) 102 101 { 103 - unsigned int uartclk = get_au1x00_uart_baud_base() * 16; 102 + long uartclk; 104 103 int s = sizeof(struct plat_serial8250_port); 105 104 int c = alchemy_get_uarts(ctype); 106 105 struct plat_serial8250_port *ports; 106 + struct clk *clk = clk_get(NULL, ALCHEMY_PERIPH_CLK); 107 + 108 + if (IS_ERR(clk)) 109 + return; 110 + if (clk_prepare_enable(clk)) { 111 + clk_put(clk); 112 + return; 113 + } 114 + uartclk = clk_get_rate(clk); 115 + clk_put(clk); 107 116 108 117 ports = kzalloc(s * (c + 1), GFP_KERNEL); 109 118 if (!ports) { ··· 431 420 memcpy(au1xxx_eth1_platform_data.mac, ethaddr, 6); 432 421 433 422 /* Register second MAC if enabled in pinfunc */ 434 - if (!(au_readl(SYS_PINFUNC) & (u32)SYS_PF_NI2)) { 423 + if (!(alchemy_rdsys(AU1000_SYS_PINFUNC) & SYS_PF_NI2)) { 435 424 ret = platform_device_register(&au1xxx_eth1_device); 436 425 if (ret) 437 426 printk(KERN_INFO "Alchemy: failed to register MAC1\n");
+36 -38
arch/mips/alchemy/common/power.c
··· 54 54 static void save_core_regs(void) 55 55 { 56 56 /* Clocks and PLLs. */ 57 - sleep_sys_clocks[0] = au_readl(SYS_FREQCTRL0); 58 - sleep_sys_clocks[1] = au_readl(SYS_FREQCTRL1); 59 - sleep_sys_clocks[2] = au_readl(SYS_CLKSRC); 60 - sleep_sys_clocks[3] = au_readl(SYS_CPUPLL); 61 - sleep_sys_clocks[4] = au_readl(SYS_AUXPLL); 57 + sleep_sys_clocks[0] = alchemy_rdsys(AU1000_SYS_FREQCTRL0); 58 + sleep_sys_clocks[1] = alchemy_rdsys(AU1000_SYS_FREQCTRL1); 59 + sleep_sys_clocks[2] = alchemy_rdsys(AU1000_SYS_CLKSRC); 60 + sleep_sys_clocks[3] = alchemy_rdsys(AU1000_SYS_CPUPLL); 61 + sleep_sys_clocks[4] = alchemy_rdsys(AU1000_SYS_AUXPLL); 62 62 63 63 /* pin mux config */ 64 - sleep_sys_pinfunc = au_readl(SYS_PINFUNC); 64 + sleep_sys_pinfunc = alchemy_rdsys(AU1000_SYS_PINFUNC); 65 65 66 66 /* Save the static memory controller configuration. */ 67 - sleep_static_memctlr[0][0] = au_readl(MEM_STCFG0); 68 - sleep_static_memctlr[0][1] = au_readl(MEM_STTIME0); 69 - sleep_static_memctlr[0][2] = au_readl(MEM_STADDR0); 70 - sleep_static_memctlr[1][0] = au_readl(MEM_STCFG1); 71 - sleep_static_memctlr[1][1] = au_readl(MEM_STTIME1); 72 - sleep_static_memctlr[1][2] = au_readl(MEM_STADDR1); 73 - sleep_static_memctlr[2][0] = au_readl(MEM_STCFG2); 74 - sleep_static_memctlr[2][1] = au_readl(MEM_STTIME2); 75 - sleep_static_memctlr[2][2] = au_readl(MEM_STADDR2); 76 - sleep_static_memctlr[3][0] = au_readl(MEM_STCFG3); 77 - sleep_static_memctlr[3][1] = au_readl(MEM_STTIME3); 78 - sleep_static_memctlr[3][2] = au_readl(MEM_STADDR3); 67 + sleep_static_memctlr[0][0] = alchemy_rdsmem(AU1000_MEM_STCFG0); 68 + sleep_static_memctlr[0][1] = alchemy_rdsmem(AU1000_MEM_STTIME0); 69 + sleep_static_memctlr[0][2] = alchemy_rdsmem(AU1000_MEM_STADDR0); 70 + sleep_static_memctlr[1][0] = alchemy_rdsmem(AU1000_MEM_STCFG1); 71 + sleep_static_memctlr[1][1] = alchemy_rdsmem(AU1000_MEM_STTIME1); 72 + sleep_static_memctlr[1][2] = alchemy_rdsmem(AU1000_MEM_STADDR1); 73 + sleep_static_memctlr[2][0] = alchemy_rdsmem(AU1000_MEM_STCFG2); 74 + sleep_static_memctlr[2][1] = alchemy_rdsmem(AU1000_MEM_STTIME2); 75 + sleep_static_memctlr[2][2] = alchemy_rdsmem(AU1000_MEM_STADDR2); 76 + sleep_static_memctlr[3][0] = alchemy_rdsmem(AU1000_MEM_STCFG3); 77 + sleep_static_memctlr[3][1] = alchemy_rdsmem(AU1000_MEM_STTIME3); 78 + sleep_static_memctlr[3][2] = alchemy_rdsmem(AU1000_MEM_STADDR3); 79 79 } 80 80 81 81 static void restore_core_regs(void) ··· 85 85 * one of those Au1000 with a write-only PLL, where we dont 86 86 * have a valid value) 87 87 */ 88 - au_writel(sleep_sys_clocks[0], SYS_FREQCTRL0); 89 - au_writel(sleep_sys_clocks[1], SYS_FREQCTRL1); 90 - au_writel(sleep_sys_clocks[2], SYS_CLKSRC); 91 - au_writel(sleep_sys_clocks[4], SYS_AUXPLL); 88 + alchemy_wrsys(sleep_sys_clocks[0], AU1000_SYS_FREQCTRL0); 89 + alchemy_wrsys(sleep_sys_clocks[1], AU1000_SYS_FREQCTRL1); 90 + alchemy_wrsys(sleep_sys_clocks[2], AU1000_SYS_CLKSRC); 91 + alchemy_wrsys(sleep_sys_clocks[4], AU1000_SYS_AUXPLL); 92 92 if (!au1xxx_cpu_has_pll_wo()) 93 - au_writel(sleep_sys_clocks[3], SYS_CPUPLL); 94 - au_sync(); 93 + alchemy_wrsys(sleep_sys_clocks[3], AU1000_SYS_CPUPLL); 95 94 96 - au_writel(sleep_sys_pinfunc, SYS_PINFUNC); 97 - au_sync(); 95 + alchemy_wrsys(sleep_sys_pinfunc, AU1000_SYS_PINFUNC); 98 96 99 97 /* Restore the static memory controller configuration. */ 100 - au_writel(sleep_static_memctlr[0][0], MEM_STCFG0); 101 - au_writel(sleep_static_memctlr[0][1], MEM_STTIME0); 102 - au_writel(sleep_static_memctlr[0][2], MEM_STADDR0); 103 - au_writel(sleep_static_memctlr[1][0], MEM_STCFG1); 104 - au_writel(sleep_static_memctlr[1][1], MEM_STTIME1); 105 - au_writel(sleep_static_memctlr[1][2], MEM_STADDR1); 106 - au_writel(sleep_static_memctlr[2][0], MEM_STCFG2); 107 - au_writel(sleep_static_memctlr[2][1], MEM_STTIME2); 108 - au_writel(sleep_static_memctlr[2][2], MEM_STADDR2); 109 - au_writel(sleep_static_memctlr[3][0], MEM_STCFG3); 110 - au_writel(sleep_static_memctlr[3][1], MEM_STTIME3); 111 - au_writel(sleep_static_memctlr[3][2], MEM_STADDR3); 98 + alchemy_wrsmem(sleep_static_memctlr[0][0], AU1000_MEM_STCFG0); 99 + alchemy_wrsmem(sleep_static_memctlr[0][1], AU1000_MEM_STTIME0); 100 + alchemy_wrsmem(sleep_static_memctlr[0][2], AU1000_MEM_STADDR0); 101 + alchemy_wrsmem(sleep_static_memctlr[1][0], AU1000_MEM_STCFG1); 102 + alchemy_wrsmem(sleep_static_memctlr[1][1], AU1000_MEM_STTIME1); 103 + alchemy_wrsmem(sleep_static_memctlr[1][2], AU1000_MEM_STADDR1); 104 + alchemy_wrsmem(sleep_static_memctlr[2][0], AU1000_MEM_STCFG2); 105 + alchemy_wrsmem(sleep_static_memctlr[2][1], AU1000_MEM_STTIME2); 106 + alchemy_wrsmem(sleep_static_memctlr[2][2], AU1000_MEM_STADDR2); 107 + alchemy_wrsmem(sleep_static_memctlr[3][0], AU1000_MEM_STCFG3); 108 + alchemy_wrsmem(sleep_static_memctlr[3][1], AU1000_MEM_STTIME3); 109 + alchemy_wrsmem(sleep_static_memctlr[3][2], AU1000_MEM_STADDR3); 112 110 } 113 111 114 112 void au_sleep(void)
-15
arch/mips/alchemy/common/setup.c
··· 27 27 28 28 #include <linux/init.h> 29 29 #include <linux/ioport.h> 30 - #include <linux/jiffies.h> 31 - #include <linux/module.h> 32 30 33 31 #include <asm/dma-coherence.h> 34 32 #include <asm/mipsregs.h> 35 - #include <asm/time.h> 36 33 37 34 #include <au1000.h> 38 35 ··· 38 41 39 42 void __init plat_mem_setup(void) 40 43 { 41 - unsigned long est_freq; 42 - 43 - /* determine core clock */ 44 - est_freq = au1xxx_calc_clock(); 45 - est_freq += 5000; /* round */ 46 - est_freq -= est_freq % 10000; 47 - printk(KERN_INFO "(PRId %08x) @ %lu.%02lu MHz\n", read_c0_prid(), 48 - est_freq / 1000000, ((est_freq % 1000000) * 100) / 1000000); 49 - 50 - /* this is faster than wasting cycles trying to approximate it */ 51 - preset_lpj = (est_freq >> 1) / HZ; 52 - 53 44 if (au1xxx_cpu_needs_config_od()) 54 45 /* Various early Au1xx0 errata corrected by this */ 55 46 set_c0_config(1 << 19); /* Set Config[OD] */
+10 -13
arch/mips/alchemy/common/time.c
··· 46 46 47 47 static cycle_t au1x_counter1_read(struct clocksource *cs) 48 48 { 49 - return au_readl(SYS_RTCREAD); 49 + return alchemy_rdsys(AU1000_SYS_RTCREAD); 50 50 } 51 51 52 52 static struct clocksource au1x_counter1_clocksource = { ··· 60 60 static int au1x_rtcmatch2_set_next_event(unsigned long delta, 61 61 struct clock_event_device *cd) 62 62 { 63 - delta += au_readl(SYS_RTCREAD); 63 + delta += alchemy_rdsys(AU1000_SYS_RTCREAD); 64 64 /* wait for register access */ 65 - while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_M21) 65 + while (alchemy_rdsys(AU1000_SYS_CNTRCTRL) & SYS_CNTRL_M21) 66 66 ; 67 - au_writel(delta, SYS_RTCMATCH2); 68 - au_sync(); 67 + alchemy_wrsys(delta, AU1000_SYS_RTCMATCH2); 69 68 70 69 return 0; 71 70 } ··· 111 112 * (the 32S bit seems to be stuck set to 1 once a single clock- 112 113 * edge is detected, hence the timeouts). 113 114 */ 114 - if (CNTR_OK != (au_readl(SYS_COUNTER_CNTRL) & CNTR_OK)) 115 + if (CNTR_OK != (alchemy_rdsys(AU1000_SYS_CNTRCTRL) & CNTR_OK)) 115 116 goto cntr_err; 116 117 117 118 /* 118 119 * setup counter 1 (RTC) to tick at full speed 119 120 */ 120 121 t = 0xffffff; 121 - while ((au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_T1S) && --t) 122 + while ((alchemy_rdsys(AU1000_SYS_CNTRCTRL) & SYS_CNTRL_T1S) && --t) 122 123 asm volatile ("nop"); 123 124 if (!t) 124 125 goto cntr_err; 125 126 126 - au_writel(0, SYS_RTCTRIM); /* 32.768 kHz */ 127 - au_sync(); 127 + alchemy_wrsys(0, AU1000_SYS_RTCTRIM); /* 32.768 kHz */ 128 128 129 129 t = 0xffffff; 130 - while ((au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_C1S) && --t) 130 + while ((alchemy_rdsys(AU1000_SYS_CNTRCTRL) & SYS_CNTRL_C1S) && --t) 131 131 asm volatile ("nop"); 132 132 if (!t) 133 133 goto cntr_err; 134 - au_writel(0, SYS_RTCWRITE); 135 - au_sync(); 134 + alchemy_wrsys(0, AU1000_SYS_RTCWRITE); 136 135 137 136 t = 0xffffff; 138 - while ((au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_C1S) && --t) 137 + while ((alchemy_rdsys(AU1000_SYS_CNTRCTRL) & SYS_CNTRL_C1S) && --t) 139 138 asm volatile ("nop"); 140 139 if (!t) 141 140 goto cntr_err;
+40 -7
arch/mips/alchemy/common/usb.c
··· 9 9 * 10 10 */ 11 11 12 + #include <linux/clk.h> 12 13 #include <linux/init.h> 13 14 #include <linux/io.h> 14 15 #include <linux/module.h> ··· 388 387 udelay(1000); 389 388 } 390 389 391 - static inline void au1000_usb_init(unsigned long rb, int reg) 390 + static inline int au1000_usb_init(unsigned long rb, int reg) 392 391 { 393 392 void __iomem *base = (void __iomem *)KSEG1ADDR(rb + reg); 394 393 unsigned long r = __raw_readl(base); 394 + struct clk *c; 395 + 396 + /* 48MHz check. Don't init if no one can provide it */ 397 + c = clk_get(NULL, "usbh_clk"); 398 + if (IS_ERR(c)) 399 + return -ENODEV; 400 + if (clk_round_rate(c, 48000000) != 48000000) { 401 + clk_put(c); 402 + return -ENODEV; 403 + } 404 + if (clk_set_rate(c, 48000000)) { 405 + clk_put(c); 406 + return -ENODEV; 407 + } 408 + clk_put(c); 395 409 396 410 #if defined(__BIG_ENDIAN) 397 411 r |= USBHEN_BE; ··· 416 400 __raw_writel(r, base); 417 401 wmb(); 418 402 udelay(1000); 403 + 404 + return 0; 419 405 } 420 406 421 407 ··· 425 407 { 426 408 void __iomem *base = (void __iomem *)KSEG1ADDR(rb); 427 409 unsigned long r = __raw_readl(base + creg); 410 + struct clk *c = clk_get(NULL, "usbh_clk"); 411 + 412 + if (IS_ERR(c)) 413 + return; 428 414 429 415 if (enable) { 416 + if (clk_prepare_enable(c)) 417 + goto out; 418 + 430 419 __raw_writel(r | USBHEN_CE, base + creg); 431 420 wmb(); 432 421 udelay(1000); ··· 448 423 } else { 449 424 __raw_writel(r & ~(USBHEN_CE | USBHEN_E), base + creg); 450 425 wmb(); 426 + clk_disable_unprepare(c); 451 427 } 428 + out: 429 + clk_put(c); 452 430 } 453 431 454 432 static inline int au1000_usb_control(int block, int enable, unsigned long rb, ··· 485 457 case ALCHEMY_CPU_AU1500: 486 458 case ALCHEMY_CPU_AU1100: 487 459 ret = au1000_usb_control(block, enable, 488 - AU1000_USB_OHCI_PHYS_ADDR, AU1000_OHCICFG); 460 + AU1000_USB_OHCI_PHYS_ADDR, AU1000_OHCICFG); 489 461 break; 490 462 case ALCHEMY_CPU_AU1550: 491 463 ret = au1000_usb_control(block, enable, 492 - AU1550_USB_OHCI_PHYS_ADDR, AU1550_OHCICFG); 464 + AU1550_USB_OHCI_PHYS_ADDR, AU1550_OHCICFG); 493 465 break; 494 466 case ALCHEMY_CPU_AU1200: 495 467 ret = au1200_usb_control(block, enable); ··· 597 569 598 570 static int __init alchemy_usb_init(void) 599 571 { 572 + int ret = 0; 573 + 600 574 switch (alchemy_get_cputype()) { 601 575 case ALCHEMY_CPU_AU1000: 602 576 case ALCHEMY_CPU_AU1500: 603 577 case ALCHEMY_CPU_AU1100: 604 - au1000_usb_init(AU1000_USB_OHCI_PHYS_ADDR, AU1000_OHCICFG); 578 + ret = au1000_usb_init(AU1000_USB_OHCI_PHYS_ADDR, 579 + AU1000_OHCICFG); 605 580 break; 606 581 case ALCHEMY_CPU_AU1550: 607 - au1000_usb_init(AU1550_USB_OHCI_PHYS_ADDR, AU1550_OHCICFG); 582 + ret = au1000_usb_init(AU1550_USB_OHCI_PHYS_ADDR, 583 + AU1550_OHCICFG); 608 584 break; 609 585 case ALCHEMY_CPU_AU1200: 610 586 au1200_usb_init(); ··· 618 586 break; 619 587 } 620 588 621 - register_syscore_ops(&alchemy_usb_pm_ops); 589 + if (!ret) 590 + register_syscore_ops(&alchemy_usb_pm_ops); 622 591 623 - return 0; 592 + return ret; 624 593 } 625 594 arch_initcall(alchemy_usb_init);
+16 -3
arch/mips/alchemy/devboards/db1000.c
··· 19 19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 20 */ 21 21 22 + #include <linux/clk.h> 22 23 #include <linux/dma-mapping.h> 23 24 #include <linux/gpio.h> 24 25 #include <linux/init.h> ··· 497 496 int board = BCSR_WHOAMI_BOARD(bcsr_read(BCSR_WHOAMI)); 498 497 int c0, c1, d0, d1, s0, s1, flashsize = 32, twosocks = 1; 499 498 unsigned long pfc; 499 + struct clk *c, *p; 500 500 501 501 if (board == BCSR_WHOAMI_DB1500) { 502 502 c0 = AU1500_GPIO2_INT; ··· 520 518 gpio_direction_input(20); /* sd1 cd# */ 521 519 522 520 /* spi_gpio on SSI0 pins */ 523 - pfc = __raw_readl((void __iomem *)SYS_PINFUNC); 521 + pfc = alchemy_rdsys(AU1000_SYS_PINFUNC); 524 522 pfc |= (1 << 0); /* SSI0 pins as GPIOs */ 525 - __raw_writel(pfc, (void __iomem *)SYS_PINFUNC); 526 - wmb(); 523 + alchemy_wrsys(pfc, AU1000_SYS_PINFUNC); 527 524 528 525 spi_register_board_info(db1100_spi_info, 529 526 ARRAY_SIZE(db1100_spi_info)); 527 + 528 + /* link LCD clock to AUXPLL */ 529 + p = clk_get(NULL, "auxpll_clk"); 530 + c = clk_get(NULL, "lcd_intclk"); 531 + if (!IS_ERR(c) && !IS_ERR(p)) { 532 + clk_set_parent(c, p); 533 + clk_set_rate(c, clk_get_rate(p)); 534 + } 535 + if (!IS_ERR(c)) 536 + clk_put(c); 537 + if (!IS_ERR(p)) 538 + clk_put(p); 530 539 531 540 platform_add_devices(db1100_devs, ARRAY_SIZE(db1100_devs)); 532 541 platform_device_register(&db1100_spi_dev);
+28 -33
arch/mips/alchemy/devboards/db1200.c
··· 18 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 19 */ 20 20 21 + #include <linux/clk.h> 21 22 #include <linux/dma-mapping.h> 22 23 #include <linux/gpio.h> 23 24 #include <linux/i2c.h> ··· 130 129 131 130 int __init db1200_board_setup(void) 132 131 { 133 - unsigned long freq0, clksrc, div, pfc; 134 132 unsigned short whoami; 135 133 136 134 if (db1200_detect_board()) ··· 148 148 printk(KERN_INFO "Alchemy/AMD/RMI %s Board, CPLD Rev %d" 149 149 " Board-ID %d Daughtercard ID %d\n", get_system_type(), 150 150 (whoami >> 4) & 0xf, (whoami >> 8) & 0xf, whoami & 0xf); 151 - 152 - /* SMBus/SPI on PSC0, Audio on PSC1 */ 153 - pfc = __raw_readl((void __iomem *)SYS_PINFUNC); 154 - pfc &= ~(SYS_PINFUNC_P0A | SYS_PINFUNC_P0B); 155 - pfc &= ~(SYS_PINFUNC_P1A | SYS_PINFUNC_P1B | SYS_PINFUNC_FS3); 156 - pfc |= SYS_PINFUNC_P1C; /* SPI is configured later */ 157 - __raw_writel(pfc, (void __iomem *)SYS_PINFUNC); 158 - wmb(); 159 - 160 - /* Clock configurations: PSC0: ~50MHz via Clkgen0, derived from 161 - * CPU clock; all other clock generators off/unused. 162 - */ 163 - div = (get_au1x00_speed() + 25000000) / 50000000; 164 - if (div & 1) 165 - div++; 166 - div = ((div >> 1) - 1) & 0xff; 167 - 168 - freq0 = div << SYS_FC_FRDIV0_BIT; 169 - __raw_writel(freq0, (void __iomem *)SYS_FREQCTRL0); 170 - wmb(); 171 - freq0 |= SYS_FC_FE0; /* enable F0 */ 172 - __raw_writel(freq0, (void __iomem *)SYS_FREQCTRL0); 173 - wmb(); 174 - 175 - /* psc0_intclk comes 1:1 from F0 */ 176 - clksrc = SYS_CS_MUX_FQ0 << SYS_CS_ME0_BIT; 177 - __raw_writel(clksrc, (void __iomem *)SYS_CLKSRC); 178 - wmb(); 179 151 180 152 return 0; 181 153 } ··· 222 250 223 251 static int au1200_nand_device_ready(struct mtd_info *mtd) 224 252 { 225 - return __raw_readl((void __iomem *)MEM_STSTAT) & 1; 253 + return alchemy_rdsmem(AU1000_MEM_STSTAT) & 1; 226 254 } 227 255 228 256 static struct mtd_partition db1200_nand_parts[] = { ··· 819 847 unsigned long pfc; 820 848 unsigned short sw; 821 849 int swapped, bid; 850 + struct clk *c; 822 851 823 852 bid = BCSR_WHOAMI_BOARD(bcsr_read(BCSR_WHOAMI)); 824 853 if ((bid == BCSR_WHOAMI_PB1200_DDR1) || ··· 831 858 /* GPIO7 is low-level triggered CPLD cascade */ 832 859 irq_set_irq_type(AU1200_GPIO7_INT, IRQ_TYPE_LEVEL_LOW); 833 860 bcsr_init_irq(DB1200_INT_BEGIN, DB1200_INT_END, AU1200_GPIO7_INT); 861 + 862 + /* SMBus/SPI on PSC0, Audio on PSC1 */ 863 + pfc = alchemy_rdsys(AU1000_SYS_PINFUNC); 864 + pfc &= ~(SYS_PINFUNC_P0A | SYS_PINFUNC_P0B); 865 + pfc &= ~(SYS_PINFUNC_P1A | SYS_PINFUNC_P1B | SYS_PINFUNC_FS3); 866 + pfc |= SYS_PINFUNC_P1C; /* SPI is configured later */ 867 + alchemy_wrsys(pfc, AU1000_SYS_PINFUNC); 868 + 869 + /* get 50MHz for I2C driver on PSC0 */ 870 + c = clk_get(NULL, "psc0_intclk"); 871 + if (!IS_ERR(c)) { 872 + pfc = clk_round_rate(c, 50000000); 873 + if ((pfc < 1) || (abs(50000000 - pfc) > 2500000)) 874 + pr_warn("DB1200: cant get I2C close to 50MHz\n"); 875 + else 876 + clk_set_rate(c, pfc); 877 + clk_put(c); 878 + } 834 879 835 880 /* insert/eject pairs: one of both is always screaming. To avoid 836 881 * issues they must not be automatically enabled when initially ··· 877 886 * As a result, in SPI mode, OTG simply won't work (PSC0 uses 878 887 * it as an input pin which is pulled high on the boards). 879 888 */ 880 - pfc = __raw_readl((void __iomem *)SYS_PINFUNC) & ~SYS_PINFUNC_P0A; 889 + pfc = alchemy_rdsys(AU1000_SYS_PINFUNC) & ~SYS_PINFUNC_P0A; 881 890 882 891 /* switch off OTG VBUS supply */ 883 892 gpio_request(215, "otg-vbus"); ··· 903 912 printk(KERN_INFO " S6.8 ON : PSC0 mode SPI\n"); 904 913 printk(KERN_INFO " OTG port VBUS supply disabled\n"); 905 914 } 906 - __raw_writel(pfc, (void __iomem *)SYS_PINFUNC); 907 - wmb(); 915 + alchemy_wrsys(pfc, AU1000_SYS_PINFUNC); 908 916 909 917 /* Audio: DIP7 selects I2S(0)/AC97(1), but need I2C for I2S! 910 918 * so: DIP7=1 || DIP8=0 => AC97, DIP7=0 && DIP8=1 => I2S ··· 922 932 } 923 933 924 934 /* Audio PSC clock is supplied externally. (FIXME: platdata!!) */ 935 + c = clk_get(NULL, "psc1_intclk"); 936 + if (!IS_ERR(c)) { 937 + clk_prepare_enable(c); 938 + clk_put(c); 939 + } 925 940 __raw_writel(PSC_SEL_CLK_SERCLK, 926 941 (void __iomem *)KSEG1ADDR(AU1550_PSC1_PHYS_ADDR) + PSC_SEL_OFFSET); 927 942 wmb();
+8 -1
arch/mips/alchemy/devboards/db1300.c
··· 4 4 * (c) 2009 Manuel Lauss <manuel.lauss@googlemail.com> 5 5 */ 6 6 7 + #include <linux/clk.h> 7 8 #include <linux/dma-mapping.h> 8 9 #include <linux/gpio.h> 9 10 #include <linux/gpio_keys.h> ··· 170 169 171 170 static int au1300_nand_device_ready(struct mtd_info *mtd) 172 171 { 173 - return __raw_readl((void __iomem *)MEM_STSTAT) & 1; 172 + return alchemy_rdsmem(AU1000_MEM_STSTAT) & 1; 174 173 } 175 174 176 175 static struct mtd_partition db1300_nand_parts[] = { ··· 732 731 int __init db1300_dev_setup(void) 733 732 { 734 733 int swapped, cpldirq; 734 + struct clk *c; 735 735 736 736 /* setup CPLD IRQ muxer */ 737 737 cpldirq = au1300_gpio_to_irq(AU1300_PIN_EXTCLK1); ··· 763 761 (void __iomem *)KSEG1ADDR(AU1300_PSC2_PHYS_ADDR) + PSC_SEL_OFFSET); 764 762 wmb(); 765 763 /* I2C uses internal 48MHz EXTCLK1 */ 764 + c = clk_get(NULL, "psc3_intclk"); 765 + if (!IS_ERR(c)) { 766 + clk_prepare_enable(c); 767 + clk_put(c); 768 + } 766 769 __raw_writel(PSC_SEL_CLK_INTCLK, 767 770 (void __iomem *)KSEG1ADDR(AU1300_PSC3_PHYS_ADDR) + PSC_SEL_OFFSET); 768 771 wmb();
+20 -7
arch/mips/alchemy/devboards/db1550.c
··· 4 4 * (c) 2011 Manuel Lauss <manuel.lauss@googlemail.com> 5 5 */ 6 6 7 + #include <linux/clk.h> 7 8 #include <linux/dma-mapping.h> 8 9 #include <linux/gpio.h> 9 10 #include <linux/i2c.h> ··· 32 31 static void __init db1550_hw_setup(void) 33 32 { 34 33 void __iomem *base; 34 + unsigned long v; 35 35 36 36 /* complete SPI setup: link psc0_intclk to a 48MHz source, 37 37 * and assign GPIO16 to PSC0_SYNC1 (SPI cs# line) as well as PSC1_SYNC 38 38 * for AC97 on PB1550. 39 39 */ 40 - base = (void __iomem *)SYS_CLKSRC; 41 - __raw_writel(__raw_readl(base) | 0x000001e0, base); 42 - base = (void __iomem *)SYS_PINFUNC; 43 - __raw_writel(__raw_readl(base) | 1 | SYS_PF_PSC1_S1, base); 44 - wmb(); 40 + v = alchemy_rdsys(AU1000_SYS_CLKSRC); 41 + alchemy_wrsys(v | 0x000001e0, AU1000_SYS_CLKSRC); 42 + v = alchemy_rdsys(AU1000_SYS_PINFUNC); 43 + alchemy_wrsys(v | 1 | SYS_PF_PSC1_S1, AU1000_SYS_PINFUNC); 45 44 46 45 /* reset the AC97 codec now, the reset time in the psc-ac97 driver 47 46 * is apparently too short although it's ridiculous as it is. ··· 152 151 153 152 static int au1550_nand_device_ready(struct mtd_info *mtd) 154 153 { 155 - return __raw_readl((void __iomem *)MEM_STSTAT) & 1; 154 + return alchemy_rdsmem(AU1000_MEM_STSTAT) & 1; 156 155 } 157 156 158 157 static struct mtd_partition db1550_nand_parts[] = { ··· 218 217 219 218 static void __init pb1550_nand_setup(void) 220 219 { 221 - int boot_swapboot = (au_readl(MEM_STSTAT) & (0x7 << 1)) | 220 + int boot_swapboot = (alchemy_rdsmem(AU1000_MEM_STSTAT) & (0x7 << 1)) | 222 221 ((bcsr_read(BCSR_STATUS) >> 6) & 0x1); 223 222 224 223 gpio_direction_input(206); /* de-assert NAND CS# */ ··· 575 574 int __init db1550_dev_setup(void) 576 575 { 577 576 int swapped, id; 577 + struct clk *c; 578 578 579 579 id = (BCSR_WHOAMI_BOARD(bcsr_read(BCSR_WHOAMI)) != BCSR_WHOAMI_DB1550); 580 580 ··· 583 581 ARRAY_SIZE(db1550_i2c_devs)); 584 582 spi_register_board_info(db1550_spi_devs, 585 583 ARRAY_SIZE(db1550_i2c_devs)); 584 + 585 + c = clk_get(NULL, "psc0_intclk"); 586 + if (!IS_ERR(c)) { 587 + clk_prepare_enable(c); 588 + clk_put(c); 589 + } 590 + c = clk_get(NULL, "psc2_intclk"); 591 + if (!IS_ERR(c)) { 592 + clk_prepare_enable(c); 593 + clk_put(c); 594 + } 586 595 587 596 /* Audio PSC clock is supplied by codecs (PSC1, 3) FIXME: platdata!! */ 588 597 __raw_writel(PSC_SEL_CLK_SERCLK,
+15 -24
arch/mips/alchemy/devboards/pm.c
··· 45 45 alchemy_gpio1_input_enable(); 46 46 47 47 /* clear and setup wake cause and source */ 48 - au_writel(0, SYS_WAKEMSK); 49 - au_sync(); 50 - au_writel(0, SYS_WAKESRC); 51 - au_sync(); 48 + alchemy_wrsys(0, AU1000_SYS_WAKEMSK); 49 + alchemy_wrsys(0, AU1000_SYS_WAKESRC); 52 50 53 - au_writel(db1x_pm_wakemsk, SYS_WAKEMSK); 54 - au_sync(); 51 + alchemy_wrsys(db1x_pm_wakemsk, AU1000_SYS_WAKEMSK); 55 52 56 53 /* setup 1Hz-timer-based wakeup: wait for reg access */ 57 - while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_M20) 54 + while (alchemy_rdsys(AU1000_SYS_CNTRCTRL) & SYS_CNTRL_M20) 58 55 asm volatile ("nop"); 59 56 60 - au_writel(au_readl(SYS_TOYREAD) + db1x_pm_sleep_secs, SYS_TOYMATCH2); 61 - au_sync(); 57 + alchemy_wrsys(alchemy_rdsys(AU1000_SYS_TOYREAD) + db1x_pm_sleep_secs, 58 + AU1000_SYS_TOYMATCH2); 62 59 63 60 /* wait for value to really hit the register */ 64 - while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_M20) 61 + while (alchemy_rdsys(AU1000_SYS_CNTRCTRL) & SYS_CNTRL_M20) 65 62 asm volatile ("nop"); 66 63 67 64 /* ...and now the sandman can come! */ ··· 99 102 /* read and store wakeup source, the clear the register. To 100 103 * be able to clear it, WAKEMSK must be cleared first. 101 104 */ 102 - db1x_pm_last_wakesrc = au_readl(SYS_WAKESRC); 105 + db1x_pm_last_wakesrc = alchemy_rdsys(AU1000_SYS_WAKESRC); 103 106 104 - au_writel(0, SYS_WAKEMSK); 105 - au_writel(0, SYS_WAKESRC); 106 - au_sync(); 107 - 107 + alchemy_wrsys(0, AU1000_SYS_WAKEMSK); 108 + alchemy_wrsys(0, AU1000_SYS_WAKESRC); 108 109 } 109 110 110 111 static const struct platform_suspend_ops db1x_pm_ops = { ··· 237 242 * for confirmation since there's plenty of time from here to 238 243 * the next suspend cycle. 239 244 */ 240 - if (au_readl(SYS_TOYTRIM) != 32767) { 241 - au_writel(32767, SYS_TOYTRIM); 242 - au_sync(); 243 - } 245 + if (alchemy_rdsys(AU1000_SYS_TOYTRIM) != 32767) 246 + alchemy_wrsys(32767, AU1000_SYS_TOYTRIM); 244 247 245 - db1x_pm_last_wakesrc = au_readl(SYS_WAKESRC); 248 + db1x_pm_last_wakesrc = alchemy_rdsys(AU1000_SYS_WAKESRC); 246 249 247 - au_writel(0, SYS_WAKESRC); 248 - au_sync(); 249 - au_writel(0, SYS_WAKEMSK); 250 - au_sync(); 250 + alchemy_wrsys(0, AU1000_SYS_WAKESRC); 251 + alchemy_wrsys(0, AU1000_SYS_WAKEMSK); 251 252 252 253 suspend_set_ops(&db1x_pm_ops); 253 254
+1 -4
arch/mips/bcm47xx/Kconfig
··· 11 11 select SSB_DRIVER_PCICORE if PCI 12 12 select SSB_PCICORE_HOSTMODE if PCI 13 13 select SSB_DRIVER_GPIO 14 - select GPIOLIB 15 - select LEDS_GPIO_REGISTER 16 14 default y 17 15 help 18 16 Add support for old Broadcom BCM47xx boards with Sonics Silicon Backplane support. ··· 20 22 config BCM47XX_BCMA 21 23 bool "BCMA Support for Broadcom BCM47XX" 22 24 select SYS_HAS_CPU_MIPS32_R2 25 + select SYS_SUPPORTS_HIGHMEM 23 26 select CPU_MIPSR2_IRQ_VI 24 27 select BCMA 25 28 select BCMA_HOST_SOC ··· 28 29 select BCMA_HOST_PCI if PCI 29 30 select BCMA_DRIVER_PCI_HOSTMODE if PCI 30 31 select BCMA_DRIVER_GPIO 31 - select GPIOLIB 32 - select LEDS_GPIO_REGISTER 33 32 default y 34 33 help 35 34 Add support for new Broadcom BCM47xx boards with Broadcom specific Advanced Microcontroller Bus.
+3
arch/mips/bcm47xx/bcm47xx_private.h
··· 3 3 4 4 #include <linux/kernel.h> 5 5 6 + /* prom.c */ 7 + void __init bcm47xx_prom_highmem_init(void); 8 + 6 9 /* buttons.c */ 7 10 int __init bcm47xx_buttons_register(void); 8 11
+22 -4
arch/mips/bcm47xx/board.c
··· 58 58 static const 59 59 struct bcm47xx_board_type_list1 bcm47xx_board_list_hardware_version[] __initconst = { 60 60 {{BCM47XX_BOARD_ASUS_RTN10U, "Asus RT-N10U"}, "RTN10U"}, 61 + {{BCM47XX_BOARD_ASUS_RTN10D, "Asus RT-N10D"}, "RTN10D"}, 61 62 {{BCM47XX_BOARD_ASUS_RTN12, "Asus RT-N12"}, "RT-N12"}, 62 63 {{BCM47XX_BOARD_ASUS_RTN12B1, "Asus RT-N12B1"}, "RTN12B1"}, 63 64 {{BCM47XX_BOARD_ASUS_RTN12C1, "Asus RT-N12C1"}, "RTN12C1"}, ··· 81 80 { {0}, NULL}, 82 81 }; 83 82 83 + /* hardware_version, boardnum */ 84 + static const 85 + struct bcm47xx_board_type_list2 bcm47xx_board_list_hw_version_num[] __initconst = { 86 + {{BCM47XX_BOARD_MICROSOFT_MN700, "Microsoft MN-700"}, "WL500-", "mn700"}, 87 + {{BCM47XX_BOARD_ASUS_WL500G, "Asus WL500G"}, "WL500-", "asusX"}, 88 + { {0}, NULL}, 89 + }; 90 + 84 91 /* productid */ 85 92 static const 86 93 struct bcm47xx_board_type_list1 bcm47xx_board_list_productid[] __initconst = { ··· 107 98 /* ModelId */ 108 99 static const 109 100 struct bcm47xx_board_type_list1 bcm47xx_board_list_ModelId[] __initconst = { 110 - {{BCM47XX_BOARD_DELL_TM2300, "Dell WX-5565"}, "WX-5565"}, 101 + {{BCM47XX_BOARD_DELL_TM2300, "Dell TrueMobile 2300"}, "WX-5565"}, 111 102 {{BCM47XX_BOARD_MOTOROLA_WE800G, "Motorola WE800G"}, "WE800G"}, 112 103 {{BCM47XX_BOARD_MOTOROLA_WR850GP, "Motorola WR850GP"}, "WR850GP"}, 113 104 {{BCM47XX_BOARD_MOTOROLA_WR850GV2V3, "Motorola WR850G"}, "WR850G"}, ··· 189 180 {{BCM47XX_BOARD_PHICOMM_M1, "Phicomm M1"}, "0x0590", "80", "0x1104"}, 190 181 {{BCM47XX_BOARD_ZTE_H218N, "ZTE H218N"}, "0x053d", "1234", "0x1305"}, 191 182 {{BCM47XX_BOARD_NETGEAR_WNR3500L, "Netgear WNR3500L"}, "0x04CF", "3500", "02"}, 192 - {{BCM47XX_BOARD_LINKSYS_WRT54G, "Linksys WRT54G/GS/GL"}, "0x0101", "42", "0x10"}, 193 - {{BCM47XX_BOARD_LINKSYS_WRT54G, "Linksys WRT54G/GS/GL"}, "0x0467", "42", "0x10"}, 194 - {{BCM47XX_BOARD_LINKSYS_WRT54G, "Linksys WRT54G/GS/GL"}, "0x0708", "42", "0x10"}, 183 + {{BCM47XX_BOARD_LINKSYS_WRT54G_TYPE_0101, "Linksys WRT54G/GS/GL"}, "0x0101", "42", "0x10"}, 184 + {{BCM47XX_BOARD_LINKSYS_WRT54G_TYPE_0467, "Linksys WRT54G/GS/GL"}, "0x0467", "42", "0x10"}, 185 + {{BCM47XX_BOARD_LINKSYS_WRT54G_TYPE_0708, "Linksys WRT54G/GS/GL"}, "0x0708", "42", "0x10"}, 195 186 { {0}, NULL}, 196 187 }; 197 188 ··· 243 234 for (e1 = bcm47xx_board_list_hardware_version; e1->value1; e1++) { 244 235 if (strstarts(buf1, e1->value1)) 245 236 return &e1->board; 237 + } 238 + } 239 + 240 + if (bcm47xx_nvram_getenv("hardware_version", buf1, sizeof(buf1)) >= 0 && 241 + bcm47xx_nvram_getenv("boardtype", buf2, sizeof(buf2)) >= 0) { 242 + for (e2 = bcm47xx_board_list_boot_hw; e2->value1; e2++) { 243 + if (!strstarts(buf1, e2->value1) && 244 + !strcmp(buf2, e2->value2)) 245 + return &e2->board; 246 246 } 247 247 } 248 248
+34 -4
arch/mips/bcm47xx/buttons.c
··· 56 56 }; 57 57 58 58 static const struct gpio_keys_button 59 + bcm47xx_buttons_asus_wl500g[] __initconst = { 60 + BCM47XX_GPIO_KEY(6, KEY_RESTART), 61 + }; 62 + 63 + static const struct gpio_keys_button 59 64 bcm47xx_buttons_asus_wl500gd[] __initconst = { 60 65 BCM47XX_GPIO_KEY(6, KEY_RESTART), 61 66 }; ··· 270 265 }; 271 266 272 267 static const struct gpio_keys_button 273 - bcm47xx_buttons_linksys_wrt54gsv1[] __initconst = { 268 + bcm47xx_buttons_linksys_wrt54g_generic[] __initconst = { 274 269 BCM47XX_GPIO_KEY(4, KEY_WPS_BUTTON), 275 270 BCM47XX_GPIO_KEY(6, KEY_RESTART), 276 271 }; ··· 291 286 bcm47xx_buttons_linksys_wrtsl54gs[] __initconst = { 292 287 BCM47XX_GPIO_KEY(4, KEY_WPS_BUTTON), 293 288 BCM47XX_GPIO_KEY(6, KEY_RESTART), 289 + }; 290 + 291 + /* Microsoft */ 292 + 293 + static const struct gpio_keys_button 294 + bcm47xx_buttons_microsoft_nm700[] __initconst = { 295 + BCM47XX_GPIO_KEY(7, KEY_RESTART), 294 296 }; 295 297 296 298 /* Motorola */ ··· 338 326 BCM47XX_GPIO_KEY(4, KEY_WPS_BUTTON), 339 327 BCM47XX_GPIO_KEY(5, KEY_RFKILL), 340 328 BCM47XX_GPIO_KEY(6, KEY_RESTART), 329 + }; 330 + 331 + static const struct gpio_keys_button 332 + bcm47xx_buttons_netgear_wnr3500lv1[] __initconst = { 333 + BCM47XX_GPIO_KEY(4, KEY_RESTART), 334 + BCM47XX_GPIO_KEY(6, KEY_WPS_BUTTON), 341 335 }; 342 336 343 337 static const struct gpio_keys_button ··· 412 394 break; 413 395 case BCM47XX_BOARD_ASUS_WL330GE: 414 396 err = bcm47xx_copy_bdata(bcm47xx_buttons_asus_wl330ge); 397 + break; 398 + case BCM47XX_BOARD_ASUS_WL500G: 399 + err = bcm47xx_copy_bdata(bcm47xx_buttons_asus_wl500g); 415 400 break; 416 401 case BCM47XX_BOARD_ASUS_WL500GD: 417 402 err = bcm47xx_copy_bdata(bcm47xx_buttons_asus_wl500gd); ··· 522 501 case BCM47XX_BOARD_LINKSYS_WRT310NV1: 523 502 err = bcm47xx_copy_bdata(bcm47xx_buttons_linksys_wrt310nv1); 524 503 break; 525 - case BCM47XX_BOARD_LINKSYS_WRT54G: 526 - err = bcm47xx_copy_bdata(bcm47xx_buttons_linksys_wrt54gsv1); 527 - break; 528 504 case BCM47XX_BOARD_LINKSYS_WRT54G3GV2: 529 505 err = bcm47xx_copy_bdata(bcm47xx_buttons_linksys_wrt54g3gv2); 506 + break; 507 + case BCM47XX_BOARD_LINKSYS_WRT54G_TYPE_0101: 508 + case BCM47XX_BOARD_LINKSYS_WRT54G_TYPE_0467: 509 + case BCM47XX_BOARD_LINKSYS_WRT54G_TYPE_0708: 510 + err = bcm47xx_copy_bdata(bcm47xx_buttons_linksys_wrt54g_generic); 530 511 break; 531 512 case BCM47XX_BOARD_LINKSYS_WRT610NV1: 532 513 err = bcm47xx_copy_bdata(bcm47xx_buttons_linksys_wrt610nv1); ··· 538 515 break; 539 516 case BCM47XX_BOARD_LINKSYS_WRTSL54GS: 540 517 err = bcm47xx_copy_bdata(bcm47xx_buttons_linksys_wrtsl54gs); 518 + break; 519 + 520 + case BCM47XX_BOARD_MICROSOFT_MN700: 521 + err = bcm47xx_copy_bdata(bcm47xx_buttons_microsoft_nm700); 541 522 break; 542 523 543 524 case BCM47XX_BOARD_MOTOROLA_WE800G: ··· 562 535 break; 563 536 case BCM47XX_BOARD_NETGEAR_WNDR4500V1: 564 537 err = bcm47xx_copy_bdata(bcm47xx_buttons_netgear_wndr4500v1); 538 + break; 539 + case BCM47XX_BOARD_NETGEAR_WNR3500L: 540 + err = bcm47xx_copy_bdata(bcm47xx_buttons_netgear_wnr3500lv1); 565 541 break; 566 542 case BCM47XX_BOARD_NETGEAR_WNR834BV2: 567 543 err = bcm47xx_copy_bdata(bcm47xx_buttons_netgear_wnr834bv2);
+79 -13
arch/mips/bcm47xx/leds.c
··· 35 35 }; 36 36 37 37 static const struct gpio_led 38 + bcm47xx_leds_asus_rtn15u[] __initconst = { 39 + /* TODO: Add "wlan" LED */ 40 + BCM47XX_GPIO_LED(3, "blue", "wan", 1, LEDS_GPIO_DEFSTATE_OFF), 41 + BCM47XX_GPIO_LED(4, "blue", "lan", 1, LEDS_GPIO_DEFSTATE_OFF), 42 + BCM47XX_GPIO_LED(6, "blue", "power", 1, LEDS_GPIO_DEFSTATE_ON), 43 + BCM47XX_GPIO_LED(9, "blue", "usb", 0, LEDS_GPIO_DEFSTATE_OFF), 44 + }; 45 + 46 + static const struct gpio_led 38 47 bcm47xx_leds_asus_rtn16[] __initconst = { 39 48 BCM47XX_GPIO_LED(1, "blue", "power", 1, LEDS_GPIO_DEFSTATE_ON), 40 49 BCM47XX_GPIO_LED(7, "blue", "wlan", 0, LEDS_GPIO_DEFSTATE_OFF), ··· 51 42 52 43 static const struct gpio_led 53 44 bcm47xx_leds_asus_rtn66u[] __initconst = { 54 - BCM47XX_GPIO_LED(12, "unk", "power", 1, LEDS_GPIO_DEFSTATE_ON), 55 - BCM47XX_GPIO_LED(15, "unk", "usb", 1, LEDS_GPIO_DEFSTATE_OFF), 45 + BCM47XX_GPIO_LED(12, "blue", "power", 1, LEDS_GPIO_DEFSTATE_ON), 46 + BCM47XX_GPIO_LED(15, "blue", "usb", 1, LEDS_GPIO_DEFSTATE_OFF), 56 47 }; 57 48 58 49 static const struct gpio_led ··· 69 60 70 61 static const struct gpio_led 71 62 bcm47xx_leds_asus_wl330ge[] __initconst = { 63 + BCM47XX_GPIO_LED(0, "unk", "power", 1, LEDS_GPIO_DEFSTATE_ON), 64 + }; 65 + 66 + static const struct gpio_led 67 + bcm47xx_leds_asus_wl500g[] __initconst = { 72 68 BCM47XX_GPIO_LED(0, "unk", "power", 1, LEDS_GPIO_DEFSTATE_ON), 73 69 }; 74 70 ··· 230 216 231 217 static const struct gpio_led 232 218 bcm47xx_leds_linksys_e1000v21[] __initconst = { 233 - BCM47XX_GPIO_LED(5, "unk", "wlan", 0, LEDS_GPIO_DEFSTATE_OFF), 234 - BCM47XX_GPIO_LED(6, "unk", "power", 1, LEDS_GPIO_DEFSTATE_ON), 219 + BCM47XX_GPIO_LED(5, "blue", "wlan", 0, LEDS_GPIO_DEFSTATE_OFF), 220 + BCM47XX_GPIO_LED(6, "blue", "power", 1, LEDS_GPIO_DEFSTATE_ON), 235 221 BCM47XX_GPIO_LED(7, "amber", "wps", 0, LEDS_GPIO_DEFSTATE_OFF), 236 222 BCM47XX_GPIO_LED(8, "blue", "wps", 0, LEDS_GPIO_DEFSTATE_OFF), 237 223 }; ··· 306 292 }; 307 293 308 294 static const struct gpio_led 309 - bcm47xx_leds_linksys_wrt54gsv1[] __initconst = { 295 + bcm47xx_leds_linksys_wrt54g_generic[] __initconst = { 310 296 BCM47XX_GPIO_LED(0, "unk", "dmz", 1, LEDS_GPIO_DEFSTATE_OFF), 311 297 BCM47XX_GPIO_LED(1, "unk", "power", 0, LEDS_GPIO_DEFSTATE_ON), 312 298 BCM47XX_GPIO_LED(5, "white", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), ··· 318 304 BCM47XX_GPIO_LED(1, "unk", "power", 0, LEDS_GPIO_DEFSTATE_ON), 319 305 BCM47XX_GPIO_LED(2, "green", "3g", 0, LEDS_GPIO_DEFSTATE_OFF), 320 306 BCM47XX_GPIO_LED(3, "blue", "3g", 0, LEDS_GPIO_DEFSTATE_OFF), 307 + }; 308 + 309 + /* Verified on: WRT54GS V1.0 */ 310 + static const struct gpio_led 311 + bcm47xx_leds_linksys_wrt54g_type_0101[] __initconst = { 312 + BCM47XX_GPIO_LED(0, "green", "wlan", 0, LEDS_GPIO_DEFSTATE_OFF), 313 + BCM47XX_GPIO_LED(1, "green", "power", 0, LEDS_GPIO_DEFSTATE_ON), 314 + BCM47XX_GPIO_LED(7, "green", "dmz", 1, LEDS_GPIO_DEFSTATE_OFF), 315 + }; 316 + 317 + /* Verified on: WRT54GL V1.1 */ 318 + static const struct gpio_led 319 + bcm47xx_leds_linksys_wrt54g_type_0467[] __initconst = { 320 + BCM47XX_GPIO_LED(0, "green", "wlan", 1, LEDS_GPIO_DEFSTATE_OFF), 321 + BCM47XX_GPIO_LED(1, "green", "power", 0, LEDS_GPIO_DEFSTATE_ON), 322 + BCM47XX_GPIO_LED(2, "white", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 323 + BCM47XX_GPIO_LED(3, "orange", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 324 + BCM47XX_GPIO_LED(7, "green", "dmz", 1, LEDS_GPIO_DEFSTATE_OFF), 321 325 }; 322 326 323 327 static const struct gpio_led ··· 357 325 358 326 static const struct gpio_led 359 327 bcm47xx_leds_linksys_wrtsl54gs[] __initconst = { 360 - BCM47XX_GPIO_LED(0, "unk", "wlan", 1, LEDS_GPIO_DEFSTATE_OFF), 361 - BCM47XX_GPIO_LED(1, "unk", "power", 0, LEDS_GPIO_DEFSTATE_ON), 362 - BCM47XX_GPIO_LED(2, "white", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 363 - BCM47XX_GPIO_LED(3, "orange", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 364 - BCM47XX_GPIO_LED(7, "unk", "dmz", 1, LEDS_GPIO_DEFSTATE_OFF), 328 + BCM47XX_GPIO_LED(0, "green", "dmz", 1, LEDS_GPIO_DEFSTATE_OFF), 329 + BCM47XX_GPIO_LED(1, "green", "power", 0, LEDS_GPIO_DEFSTATE_ON), 330 + BCM47XX_GPIO_LED(5, "white", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 331 + BCM47XX_GPIO_LED(7, "orange", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 332 + }; 333 + 334 + /* Microsoft */ 335 + 336 + static const struct gpio_led 337 + bcm47xx_leds_microsoft_nm700[] __initconst = { 338 + BCM47XX_GPIO_LED(6, "unk", "power", 0, LEDS_GPIO_DEFSTATE_ON), 365 339 }; 366 340 367 341 /* Motorola */ ··· 415 377 }; 416 378 417 379 static const struct gpio_led 380 + bcm47xx_leds_netgear_wnr3500lv1[] __initconst = { 381 + BCM47XX_GPIO_LED(0, "blue", "wlan", 1, LEDS_GPIO_DEFSTATE_OFF), 382 + BCM47XX_GPIO_LED(1, "green", "wps", 1, LEDS_GPIO_DEFSTATE_OFF), 383 + BCM47XX_GPIO_LED(2, "green", "wan", 1, LEDS_GPIO_DEFSTATE_OFF), 384 + BCM47XX_GPIO_LED(3, "green", "power", 0, LEDS_GPIO_DEFSTATE_ON), 385 + BCM47XX_GPIO_LED(7, "amber", "power", 0, LEDS_GPIO_DEFSTATE_OFF), 386 + }; 387 + 388 + static const struct gpio_led 418 389 bcm47xx_leds_netgear_wnr834bv2[] __initconst = { 419 390 BCM47XX_GPIO_LED(2, "green", "power", 0, LEDS_GPIO_DEFSTATE_ON), 420 391 BCM47XX_GPIO_LED(3, "amber", "power", 0, LEDS_GPIO_DEFSTATE_OFF), ··· 464 417 case BCM47XX_BOARD_ASUS_RTN12: 465 418 bcm47xx_set_pdata(bcm47xx_leds_asus_rtn12); 466 419 break; 420 + case BCM47XX_BOARD_ASUS_RTN15U: 421 + bcm47xx_set_pdata(bcm47xx_leds_asus_rtn15u); 422 + break; 467 423 case BCM47XX_BOARD_ASUS_RTN16: 468 424 bcm47xx_set_pdata(bcm47xx_leds_asus_rtn16); 469 425 break; ··· 481 431 break; 482 432 case BCM47XX_BOARD_ASUS_WL330GE: 483 433 bcm47xx_set_pdata(bcm47xx_leds_asus_wl330ge); 434 + break; 435 + case BCM47XX_BOARD_ASUS_WL500G: 436 + bcm47xx_set_pdata(bcm47xx_leds_asus_wl500g); 484 437 break; 485 438 case BCM47XX_BOARD_ASUS_WL500GD: 486 439 bcm47xx_set_pdata(bcm47xx_leds_asus_wl500gd); ··· 591 538 case BCM47XX_BOARD_LINKSYS_WRT310NV1: 592 539 bcm47xx_set_pdata(bcm47xx_leds_linksys_wrt310nv1); 593 540 break; 594 - case BCM47XX_BOARD_LINKSYS_WRT54G: 595 - bcm47xx_set_pdata(bcm47xx_leds_linksys_wrt54gsv1); 596 - break; 597 541 case BCM47XX_BOARD_LINKSYS_WRT54G3GV2: 598 542 bcm47xx_set_pdata(bcm47xx_leds_linksys_wrt54g3gv2); 543 + break; 544 + case BCM47XX_BOARD_LINKSYS_WRT54G_TYPE_0101: 545 + bcm47xx_set_pdata(bcm47xx_leds_linksys_wrt54g_type_0101); 546 + break; 547 + case BCM47XX_BOARD_LINKSYS_WRT54G_TYPE_0467: 548 + bcm47xx_set_pdata(bcm47xx_leds_linksys_wrt54g_type_0467); 549 + break; 550 + case BCM47XX_BOARD_LINKSYS_WRT54G_TYPE_0708: 551 + bcm47xx_set_pdata(bcm47xx_leds_linksys_wrt54g_generic); 599 552 break; 600 553 case BCM47XX_BOARD_LINKSYS_WRT610NV1: 601 554 bcm47xx_set_pdata(bcm47xx_leds_linksys_wrt610nv1); ··· 611 552 break; 612 553 case BCM47XX_BOARD_LINKSYS_WRTSL54GS: 613 554 bcm47xx_set_pdata(bcm47xx_leds_linksys_wrtsl54gs); 555 + break; 556 + 557 + case BCM47XX_BOARD_MICROSOFT_MN700: 558 + bcm47xx_set_pdata(bcm47xx_leds_microsoft_nm700); 614 559 break; 615 560 616 561 case BCM47XX_BOARD_MOTOROLA_WE800G: ··· 632 569 break; 633 570 case BCM47XX_BOARD_NETGEAR_WNDR4500V1: 634 571 bcm47xx_set_pdata(bcm47xx_leds_netgear_wndr4500v1); 572 + break; 573 + case BCM47XX_BOARD_NETGEAR_WNR3500L: 574 + bcm47xx_set_pdata(bcm47xx_leds_netgear_wnr3500lv1); 635 575 break; 636 576 case BCM47XX_BOARD_NETGEAR_WNR834BV2: 637 577 bcm47xx_set_pdata(bcm47xx_leds_netgear_wnr834bv2);
+67 -1
arch/mips/bcm47xx/prom.c
··· 51 51 chip_id); 52 52 } 53 53 54 + static unsigned long lowmem __initdata; 55 + 54 56 static __init void prom_init_mem(void) 55 57 { 56 58 unsigned long mem; ··· 89 87 if (!memcmp(prom_init, prom_init + mem, 32)) 90 88 break; 91 89 } 90 + lowmem = mem; 92 91 93 92 /* Ignoring the last page when ddr size is 128M. Cached 94 93 * accesses to last page is causing the processor to prefetch ··· 98 95 */ 99 96 if (c->cputype == CPU_74K && (mem == (128 << 20))) 100 97 mem -= 0x1000; 101 - 102 98 add_memory_region(0, mem, BOOT_MEM_RAM); 103 99 } 104 100 ··· 116 114 void __init prom_free_prom_memory(void) 117 115 { 118 116 } 117 + 118 + #if defined(CONFIG_BCM47XX_BCMA) && defined(CONFIG_HIGHMEM) 119 + 120 + #define EXTVBASE 0xc0000000 121 + #define ENTRYLO(x) ((pte_val(pfn_pte((x) >> _PFN_SHIFT, PAGE_KERNEL_UNCACHED)) >> 6) | 1) 122 + 123 + #include <asm/tlbflush.h> 124 + 125 + /* Stripped version of tlb_init, with the call to build_tlb_refill_handler 126 + * dropped. Calling it at this stage causes a hang. 127 + */ 128 + void __cpuinit early_tlb_init(void) 129 + { 130 + write_c0_pagemask(PM_DEFAULT_MASK); 131 + write_c0_wired(0); 132 + temp_tlb_entry = current_cpu_data.tlbsize - 1; 133 + local_flush_tlb_all(); 134 + } 135 + 136 + void __init bcm47xx_prom_highmem_init(void) 137 + { 138 + unsigned long off = (unsigned long)prom_init; 139 + unsigned long extmem = 0; 140 + bool highmem_region = false; 141 + 142 + if (WARN_ON(bcm47xx_bus_type != BCM47XX_BUS_TYPE_BCMA)) 143 + return; 144 + 145 + if (bcm47xx_bus.bcma.bus.chipinfo.id == BCMA_CHIP_ID_BCM4706) 146 + highmem_region = true; 147 + 148 + if (lowmem != 128 << 20 || !highmem_region) 149 + return; 150 + 151 + early_tlb_init(); 152 + 153 + /* Add one temporary TLB entry to map SDRAM Region 2. 154 + * Physical Virtual 155 + * 0x80000000 0xc0000000 (1st: 256MB) 156 + * 0x90000000 0xd0000000 (2nd: 256MB) 157 + */ 158 + add_temporary_entry(ENTRYLO(0x80000000), 159 + ENTRYLO(0x80000000 + (256 << 20)), 160 + EXTVBASE, PM_256M); 161 + 162 + off = EXTVBASE + __pa(off); 163 + for (extmem = 128 << 20; extmem < 512 << 20; extmem <<= 1) { 164 + if (!memcmp(prom_init, (void *)(off + extmem), 16)) 165 + break; 166 + } 167 + extmem -= lowmem; 168 + 169 + early_tlb_init(); 170 + 171 + if (!extmem) 172 + return; 173 + 174 + pr_warn("Found %lu MiB of extra memory, but highmem is unsupported yet!\n", 175 + extmem >> 20); 176 + 177 + /* TODO: Register extra memory */ 178 + } 179 + 180 + #endif /* defined(CONFIG_BCM47XX_BCMA) && defined(CONFIG_HIGHMEM) */
+5 -2
arch/mips/bcm47xx/setup.c
··· 59 59 switch (bcm47xx_bus_type) { 60 60 #ifdef CONFIG_BCM47XX_SSB 61 61 case BCM47XX_BUS_TYPE_SSB: 62 - ssb_watchdog_timer_set(&bcm47xx_bus.ssb, 1); 62 + ssb_watchdog_timer_set(&bcm47xx_bus.ssb, 3); 63 63 break; 64 64 #endif 65 65 #ifdef CONFIG_BCM47XX_BCMA 66 66 case BCM47XX_BUS_TYPE_BCMA: 67 - bcma_chipco_watchdog_timer_set(&bcm47xx_bus.bcma.bus.drv_cc, 1); 67 + bcma_chipco_watchdog_timer_set(&bcm47xx_bus.bcma.bus.drv_cc, 3); 68 68 break; 69 69 #endif 70 70 } ··· 218 218 bcm47xx_bus_type = BCM47XX_BUS_TYPE_BCMA; 219 219 bcm47xx_register_bcma(); 220 220 bcm47xx_set_system_type(bcm47xx_bus.bcma.bus.chipinfo.id); 221 + #ifdef CONFIG_HIGHMEM 222 + bcm47xx_prom_highmem_init(); 223 + #endif 221 224 #endif 222 225 } else { 223 226 printk(KERN_INFO "bcm47xx: using ssb bus\n");
+48
arch/mips/bcm47xx/sprom.c
··· 28 28 29 29 #include <bcm47xx.h> 30 30 #include <bcm47xx_nvram.h> 31 + #include <linux/if_ether.h> 32 + #include <linux/etherdevice.h> 31 33 32 34 static void create_key(const char *prefix, const char *postfix, 33 35 const char *name, char *buf, int len) ··· 633 631 } 634 632 } 635 633 634 + static bool bcm47xx_is_valid_mac(u8 *mac) 635 + { 636 + return mac && !(mac[0] == 0x00 && mac[1] == 0x90 && mac[2] == 0x4c); 637 + } 638 + 639 + static int bcm47xx_increase_mac_addr(u8 *mac, u8 num) 640 + { 641 + u8 *oui = mac + ETH_ALEN/2 - 1; 642 + u8 *p = mac + ETH_ALEN - 1; 643 + 644 + do { 645 + (*p) += num; 646 + if (*p > num) 647 + break; 648 + p--; 649 + num = 1; 650 + } while (p != oui); 651 + 652 + if (p == oui) { 653 + pr_err("unable to fetch mac address\n"); 654 + return -ENOENT; 655 + } 656 + return 0; 657 + } 658 + 659 + static int mac_addr_used = 2; 660 + 636 661 static void bcm47xx_fill_sprom_ethernet(struct ssb_sprom *sprom, 637 662 const char *prefix, bool fallback) 638 663 { ··· 677 648 678 649 nvram_read_macaddr(prefix, "macaddr", sprom->il0mac, fallback); 679 650 nvram_read_macaddr(prefix, "il0macaddr", sprom->il0mac, fallback); 651 + 652 + /* The address prefix 00:90:4C is used by Broadcom in their initial 653 + configuration. When a mac address with the prefix 00:90:4C is used 654 + all devices from the same series are sharing the same mac address. 655 + To prevent mac address collisions we replace them with a mac address 656 + based on the base address. */ 657 + if (!bcm47xx_is_valid_mac(sprom->il0mac)) { 658 + u8 mac[6]; 659 + 660 + nvram_read_macaddr(NULL, "et0macaddr", mac, false); 661 + if (bcm47xx_is_valid_mac(mac)) { 662 + int err = bcm47xx_increase_mac_addr(mac, mac_addr_used); 663 + 664 + if (!err) { 665 + ether_addr_copy(sprom->il0mac, mac); 666 + mac_addr_used++; 667 + } 668 + } 669 + } 680 670 } 681 671 682 672 static void bcm47xx_fill_board_data(struct ssb_sprom *sprom, const char *prefix,
+3 -8
arch/mips/bcm63xx/cpu.c
··· 24 24 const int *bcm63xx_irqs; 25 25 EXPORT_SYMBOL(bcm63xx_irqs); 26 26 27 - static u16 bcm63xx_cpu_id; 27 + u16 bcm63xx_cpu_id __read_mostly; 28 + EXPORT_SYMBOL(bcm63xx_cpu_id); 29 + 28 30 static u8 bcm63xx_cpu_rev; 29 31 static unsigned int bcm63xx_cpu_freq; 30 32 static unsigned int bcm63xx_memory_size; ··· 98 96 __GEN_CPU_IRQ_TABLE(6368) 99 97 100 98 }; 101 - 102 - u16 __bcm63xx_get_cpu_id(void) 103 - { 104 - return bcm63xx_cpu_id; 105 - } 106 - 107 - EXPORT_SYMBOL(__bcm63xx_get_cpu_id); 108 99 109 100 u8 bcm63xx_get_cpu_rev(void) 110 101 {
-4
arch/mips/bcm63xx/dev-enet.c
··· 14 14 #include <bcm63xx_io.h> 15 15 #include <bcm63xx_regs.h> 16 16 17 - #ifdef BCMCPU_RUNTIME_DETECT 18 17 static const unsigned long bcm6348_regs_enetdmac[] = { 19 18 [ENETDMAC_CHANCFG] = ENETDMAC_CHANCFG_REG, 20 19 [ENETDMAC_IR] = ENETDMAC_IR_REG, ··· 42 43 else 43 44 bcm63xx_regs_enetdmac = bcm6348_regs_enetdmac; 44 45 } 45 - #else 46 - static __init void bcm63xx_enetdmac_regs_init(void) { } 47 - #endif 48 46 49 47 static struct resource shared_res[] = { 50 48 {
-4
arch/mips/bcm63xx/dev-spi.c
··· 18 18 #include <bcm63xx_dev_spi.h> 19 19 #include <bcm63xx_regs.h> 20 20 21 - #ifdef BCMCPU_RUNTIME_DETECT 22 21 /* 23 22 * register offsets 24 23 */ ··· 40 41 BCMCPU_IS_6362() || BCMCPU_IS_6368()) 41 42 bcm63xx_regs_spi = bcm6358_regs_spi; 42 43 } 43 - #else 44 - static __init void bcm63xx_spi_regs_init(void) { } 45 - #endif 46 44 47 45 static struct resource spi_resources[] = { 48 46 {
-14
arch/mips/bcm63xx/gpio.c
··· 18 18 #include <bcm63xx_io.h> 19 19 #include <bcm63xx_regs.h> 20 20 21 - #ifndef BCMCPU_RUNTIME_DETECT 22 - #define gpio_out_low_reg GPIO_DATA_LO_REG 23 - #ifdef CONFIG_BCM63XX_CPU_6345 24 - #ifdef gpio_out_low_reg 25 - #undef gpio_out_low_reg 26 - #define gpio_out_low_reg GPIO_DATA_LO_REG_6345 27 - #endif /* gpio_out_low_reg */ 28 - #endif /* CONFIG_BCM63XX_CPU_6345 */ 29 - 30 - static inline void bcm63xx_gpio_out_low_reg_init(void) 31 - { 32 - } 33 - #else /* ! BCMCPU_RUNTIME_DETECT */ 34 21 static u32 gpio_out_low_reg; 35 22 36 23 static void bcm63xx_gpio_out_low_reg_init(void) ··· 31 44 break; 32 45 } 33 46 } 34 - #endif /* ! BCMCPU_RUNTIME_DETECT */ 35 47 36 48 static DEFINE_SPINLOCK(bcm63xx_gpio_lock); 37 49 static u32 gpio_out_low, gpio_out_high;
+269 -289
arch/mips/bcm63xx/irq.c
··· 12 12 #include <linux/interrupt.h> 13 13 #include <linux/module.h> 14 14 #include <linux/irq.h> 15 + #include <linux/spinlock.h> 15 16 #include <asm/irq_cpu.h> 16 17 #include <asm/mipsregs.h> 17 18 #include <bcm63xx_cpu.h> ··· 20 19 #include <bcm63xx_io.h> 21 20 #include <bcm63xx_irq.h> 22 21 23 - static void __dispatch_internal(void) __maybe_unused; 24 - static void __dispatch_internal_64(void) __maybe_unused; 25 - static void __internal_irq_mask_32(unsigned int irq) __maybe_unused; 26 - static void __internal_irq_mask_64(unsigned int irq) __maybe_unused; 27 - static void __internal_irq_unmask_32(unsigned int irq) __maybe_unused; 28 - static void __internal_irq_unmask_64(unsigned int irq) __maybe_unused; 29 22 30 - #ifndef BCMCPU_RUNTIME_DETECT 31 - #ifdef CONFIG_BCM63XX_CPU_3368 32 - #define irq_stat_reg PERF_IRQSTAT_3368_REG 33 - #define irq_mask_reg PERF_IRQMASK_3368_REG 34 - #define irq_bits 32 35 - #define is_ext_irq_cascaded 0 36 - #define ext_irq_start 0 37 - #define ext_irq_end 0 38 - #define ext_irq_count 4 39 - #define ext_irq_cfg_reg1 PERF_EXTIRQ_CFG_REG_3368 40 - #define ext_irq_cfg_reg2 0 41 - #endif 42 - #ifdef CONFIG_BCM63XX_CPU_6328 43 - #define irq_stat_reg PERF_IRQSTAT_6328_REG 44 - #define irq_mask_reg PERF_IRQMASK_6328_REG 45 - #define irq_bits 64 46 - #define is_ext_irq_cascaded 1 47 - #define ext_irq_start (BCM_6328_EXT_IRQ0 - IRQ_INTERNAL_BASE) 48 - #define ext_irq_end (BCM_6328_EXT_IRQ3 - IRQ_INTERNAL_BASE) 49 - #define ext_irq_count 4 50 - #define ext_irq_cfg_reg1 PERF_EXTIRQ_CFG_REG_6328 51 - #define ext_irq_cfg_reg2 0 52 - #endif 53 - #ifdef CONFIG_BCM63XX_CPU_6338 54 - #define irq_stat_reg PERF_IRQSTAT_6338_REG 55 - #define irq_mask_reg PERF_IRQMASK_6338_REG 56 - #define irq_bits 32 57 - #define is_ext_irq_cascaded 0 58 - #define ext_irq_start 0 59 - #define ext_irq_end 0 60 - #define ext_irq_count 4 61 - #define ext_irq_cfg_reg1 PERF_EXTIRQ_CFG_REG_6338 62 - #define ext_irq_cfg_reg2 0 63 - #endif 64 - #ifdef CONFIG_BCM63XX_CPU_6345 65 - #define irq_stat_reg PERF_IRQSTAT_6345_REG 66 - #define irq_mask_reg PERF_IRQMASK_6345_REG 67 - #define irq_bits 32 68 - #define is_ext_irq_cascaded 0 69 - #define ext_irq_start 0 70 - #define ext_irq_end 0 71 - #define ext_irq_count 4 72 - #define ext_irq_cfg_reg1 PERF_EXTIRQ_CFG_REG_6345 73 - #define ext_irq_cfg_reg2 0 74 - #endif 75 - #ifdef CONFIG_BCM63XX_CPU_6348 76 - #define irq_stat_reg PERF_IRQSTAT_6348_REG 77 - #define irq_mask_reg PERF_IRQMASK_6348_REG 78 - #define irq_bits 32 79 - #define is_ext_irq_cascaded 0 80 - #define ext_irq_start 0 81 - #define ext_irq_end 0 82 - #define ext_irq_count 4 83 - #define ext_irq_cfg_reg1 PERF_EXTIRQ_CFG_REG_6348 84 - #define ext_irq_cfg_reg2 0 85 - #endif 86 - #ifdef CONFIG_BCM63XX_CPU_6358 87 - #define irq_stat_reg PERF_IRQSTAT_6358_REG 88 - #define irq_mask_reg PERF_IRQMASK_6358_REG 89 - #define irq_bits 32 90 - #define is_ext_irq_cascaded 1 91 - #define ext_irq_start (BCM_6358_EXT_IRQ0 - IRQ_INTERNAL_BASE) 92 - #define ext_irq_end (BCM_6358_EXT_IRQ3 - IRQ_INTERNAL_BASE) 93 - #define ext_irq_count 4 94 - #define ext_irq_cfg_reg1 PERF_EXTIRQ_CFG_REG_6358 95 - #define ext_irq_cfg_reg2 0 96 - #endif 97 - #ifdef CONFIG_BCM63XX_CPU_6362 98 - #define irq_stat_reg PERF_IRQSTAT_6362_REG 99 - #define irq_mask_reg PERF_IRQMASK_6362_REG 100 - #define irq_bits 64 101 - #define is_ext_irq_cascaded 1 102 - #define ext_irq_start (BCM_6362_EXT_IRQ0 - IRQ_INTERNAL_BASE) 103 - #define ext_irq_end (BCM_6362_EXT_IRQ3 - IRQ_INTERNAL_BASE) 104 - #define ext_irq_count 4 105 - #define ext_irq_cfg_reg1 PERF_EXTIRQ_CFG_REG_6362 106 - #define ext_irq_cfg_reg2 0 107 - #endif 108 - #ifdef CONFIG_BCM63XX_CPU_6368 109 - #define irq_stat_reg PERF_IRQSTAT_6368_REG 110 - #define irq_mask_reg PERF_IRQMASK_6368_REG 111 - #define irq_bits 64 112 - #define is_ext_irq_cascaded 1 113 - #define ext_irq_start (BCM_6368_EXT_IRQ0 - IRQ_INTERNAL_BASE) 114 - #define ext_irq_end (BCM_6368_EXT_IRQ5 - IRQ_INTERNAL_BASE) 115 - #define ext_irq_count 6 116 - #define ext_irq_cfg_reg1 PERF_EXTIRQ_CFG_REG_6368 117 - #define ext_irq_cfg_reg2 PERF_EXTIRQ_CFG_REG2_6368 118 - #endif 23 + static DEFINE_SPINLOCK(ipic_lock); 24 + static DEFINE_SPINLOCK(epic_lock); 119 25 120 - #if irq_bits == 32 121 - #define dispatch_internal __dispatch_internal 122 - #define internal_irq_mask __internal_irq_mask_32 123 - #define internal_irq_unmask __internal_irq_unmask_32 124 - #else 125 - #define dispatch_internal __dispatch_internal_64 126 - #define internal_irq_mask __internal_irq_mask_64 127 - #define internal_irq_unmask __internal_irq_unmask_64 128 - #endif 129 - 130 - #define irq_stat_addr (bcm63xx_regset_address(RSET_PERF) + irq_stat_reg) 131 - #define irq_mask_addr (bcm63xx_regset_address(RSET_PERF) + irq_mask_reg) 132 - 133 - static inline void bcm63xx_init_irq(void) 134 - { 135 - } 136 - #else /* ! BCMCPU_RUNTIME_DETECT */ 137 - 138 - static u32 irq_stat_addr, irq_mask_addr; 139 - static void (*dispatch_internal)(void); 26 + static u32 irq_stat_addr[2]; 27 + static u32 irq_mask_addr[2]; 28 + static void (*dispatch_internal)(int cpu); 140 29 static int is_ext_irq_cascaded; 141 30 static unsigned int ext_irq_count; 142 31 static unsigned int ext_irq_start, ext_irq_end; 143 32 static unsigned int ext_irq_cfg_reg1, ext_irq_cfg_reg2; 144 - static void (*internal_irq_mask)(unsigned int irq); 145 - static void (*internal_irq_unmask)(unsigned int irq); 33 + static void (*internal_irq_mask)(struct irq_data *d); 34 + static void (*internal_irq_unmask)(struct irq_data *d, const struct cpumask *m); 146 35 147 - static void bcm63xx_init_irq(void) 148 - { 149 - int irq_bits; 150 - 151 - irq_stat_addr = bcm63xx_regset_address(RSET_PERF); 152 - irq_mask_addr = bcm63xx_regset_address(RSET_PERF); 153 - 154 - switch (bcm63xx_get_cpu_id()) { 155 - case BCM3368_CPU_ID: 156 - irq_stat_addr += PERF_IRQSTAT_3368_REG; 157 - irq_mask_addr += PERF_IRQMASK_3368_REG; 158 - irq_bits = 32; 159 - ext_irq_count = 4; 160 - ext_irq_cfg_reg1 = PERF_EXTIRQ_CFG_REG_3368; 161 - break; 162 - case BCM6328_CPU_ID: 163 - irq_stat_addr += PERF_IRQSTAT_6328_REG; 164 - irq_mask_addr += PERF_IRQMASK_6328_REG; 165 - irq_bits = 64; 166 - ext_irq_count = 4; 167 - is_ext_irq_cascaded = 1; 168 - ext_irq_start = BCM_6328_EXT_IRQ0 - IRQ_INTERNAL_BASE; 169 - ext_irq_end = BCM_6328_EXT_IRQ3 - IRQ_INTERNAL_BASE; 170 - ext_irq_cfg_reg1 = PERF_EXTIRQ_CFG_REG_6328; 171 - break; 172 - case BCM6338_CPU_ID: 173 - irq_stat_addr += PERF_IRQSTAT_6338_REG; 174 - irq_mask_addr += PERF_IRQMASK_6338_REG; 175 - irq_bits = 32; 176 - ext_irq_count = 4; 177 - ext_irq_cfg_reg1 = PERF_EXTIRQ_CFG_REG_6338; 178 - break; 179 - case BCM6345_CPU_ID: 180 - irq_stat_addr += PERF_IRQSTAT_6345_REG; 181 - irq_mask_addr += PERF_IRQMASK_6345_REG; 182 - irq_bits = 32; 183 - ext_irq_count = 4; 184 - ext_irq_cfg_reg1 = PERF_EXTIRQ_CFG_REG_6345; 185 - break; 186 - case BCM6348_CPU_ID: 187 - irq_stat_addr += PERF_IRQSTAT_6348_REG; 188 - irq_mask_addr += PERF_IRQMASK_6348_REG; 189 - irq_bits = 32; 190 - ext_irq_count = 4; 191 - ext_irq_cfg_reg1 = PERF_EXTIRQ_CFG_REG_6348; 192 - break; 193 - case BCM6358_CPU_ID: 194 - irq_stat_addr += PERF_IRQSTAT_6358_REG; 195 - irq_mask_addr += PERF_IRQMASK_6358_REG; 196 - irq_bits = 32; 197 - ext_irq_count = 4; 198 - is_ext_irq_cascaded = 1; 199 - ext_irq_start = BCM_6358_EXT_IRQ0 - IRQ_INTERNAL_BASE; 200 - ext_irq_end = BCM_6358_EXT_IRQ3 - IRQ_INTERNAL_BASE; 201 - ext_irq_cfg_reg1 = PERF_EXTIRQ_CFG_REG_6358; 202 - break; 203 - case BCM6362_CPU_ID: 204 - irq_stat_addr += PERF_IRQSTAT_6362_REG; 205 - irq_mask_addr += PERF_IRQMASK_6362_REG; 206 - irq_bits = 64; 207 - ext_irq_count = 4; 208 - is_ext_irq_cascaded = 1; 209 - ext_irq_start = BCM_6362_EXT_IRQ0 - IRQ_INTERNAL_BASE; 210 - ext_irq_end = BCM_6362_EXT_IRQ3 - IRQ_INTERNAL_BASE; 211 - ext_irq_cfg_reg1 = PERF_EXTIRQ_CFG_REG_6362; 212 - break; 213 - case BCM6368_CPU_ID: 214 - irq_stat_addr += PERF_IRQSTAT_6368_REG; 215 - irq_mask_addr += PERF_IRQMASK_6368_REG; 216 - irq_bits = 64; 217 - ext_irq_count = 6; 218 - is_ext_irq_cascaded = 1; 219 - ext_irq_start = BCM_6368_EXT_IRQ0 - IRQ_INTERNAL_BASE; 220 - ext_irq_end = BCM_6368_EXT_IRQ5 - IRQ_INTERNAL_BASE; 221 - ext_irq_cfg_reg1 = PERF_EXTIRQ_CFG_REG_6368; 222 - ext_irq_cfg_reg2 = PERF_EXTIRQ_CFG_REG2_6368; 223 - break; 224 - default: 225 - BUG(); 226 - } 227 - 228 - if (irq_bits == 32) { 229 - dispatch_internal = __dispatch_internal; 230 - internal_irq_mask = __internal_irq_mask_32; 231 - internal_irq_unmask = __internal_irq_unmask_32; 232 - } else { 233 - dispatch_internal = __dispatch_internal_64; 234 - internal_irq_mask = __internal_irq_mask_64; 235 - internal_irq_unmask = __internal_irq_unmask_64; 236 - } 237 - } 238 - #endif /* ! BCMCPU_RUNTIME_DETECT */ 239 36 240 37 static inline u32 get_ext_irq_perf_reg(int irq) 241 38 { ··· 51 252 do_IRQ(intbit + IRQ_INTERNAL_BASE); 52 253 } 53 254 255 + static inline int enable_irq_for_cpu(int cpu, struct irq_data *d, 256 + const struct cpumask *m) 257 + { 258 + bool enable = cpu_online(cpu); 259 + 260 + #ifdef CONFIG_SMP 261 + if (m) 262 + enable &= cpu_isset(cpu, *m); 263 + else if (irqd_affinity_was_set(d)) 264 + enable &= cpu_isset(cpu, *d->affinity); 265 + #endif 266 + return enable; 267 + } 268 + 54 269 /* 55 270 * dispatch internal devices IRQ (uart, enet, watchdog, ...). do not 56 271 * prioritize any interrupt relatively to another. the static counter 57 272 * will resume the loop where it ended the last time we left this 58 273 * function. 59 274 */ 60 - static void __dispatch_internal(void) 61 - { 62 - u32 pending; 63 - static int i; 64 275 65 - pending = bcm_readl(irq_stat_addr) & bcm_readl(irq_mask_addr); 66 - 67 - if (!pending) 68 - return ; 69 - 70 - while (1) { 71 - int to_call = i; 72 - 73 - i = (i + 1) & 0x1f; 74 - if (pending & (1 << to_call)) { 75 - handle_internal(to_call); 76 - break; 77 - } 78 - } 276 + #define BUILD_IPIC_INTERNAL(width) \ 277 + void __dispatch_internal_##width(int cpu) \ 278 + { \ 279 + u32 pending[width / 32]; \ 280 + unsigned int src, tgt; \ 281 + bool irqs_pending = false; \ 282 + static unsigned int i[2]; \ 283 + unsigned int *next = &i[cpu]; \ 284 + unsigned long flags; \ 285 + \ 286 + /* read registers in reverse order */ \ 287 + spin_lock_irqsave(&ipic_lock, flags); \ 288 + for (src = 0, tgt = (width / 32); src < (width / 32); src++) { \ 289 + u32 val; \ 290 + \ 291 + val = bcm_readl(irq_stat_addr[cpu] + src * sizeof(u32)); \ 292 + val &= bcm_readl(irq_mask_addr[cpu] + src * sizeof(u32)); \ 293 + pending[--tgt] = val; \ 294 + \ 295 + if (val) \ 296 + irqs_pending = true; \ 297 + } \ 298 + spin_unlock_irqrestore(&ipic_lock, flags); \ 299 + \ 300 + if (!irqs_pending) \ 301 + return; \ 302 + \ 303 + while (1) { \ 304 + unsigned int to_call = *next; \ 305 + \ 306 + *next = (*next + 1) & (width - 1); \ 307 + if (pending[to_call / 32] & (1 << (to_call & 0x1f))) { \ 308 + handle_internal(to_call); \ 309 + break; \ 310 + } \ 311 + } \ 312 + } \ 313 + \ 314 + static void __internal_irq_mask_##width(struct irq_data *d) \ 315 + { \ 316 + u32 val; \ 317 + unsigned irq = d->irq - IRQ_INTERNAL_BASE; \ 318 + unsigned reg = (irq / 32) ^ (width/32 - 1); \ 319 + unsigned bit = irq & 0x1f; \ 320 + unsigned long flags; \ 321 + int cpu; \ 322 + \ 323 + spin_lock_irqsave(&ipic_lock, flags); \ 324 + for_each_present_cpu(cpu) { \ 325 + if (!irq_mask_addr[cpu]) \ 326 + break; \ 327 + \ 328 + val = bcm_readl(irq_mask_addr[cpu] + reg * sizeof(u32));\ 329 + val &= ~(1 << bit); \ 330 + bcm_writel(val, irq_mask_addr[cpu] + reg * sizeof(u32));\ 331 + } \ 332 + spin_unlock_irqrestore(&ipic_lock, flags); \ 333 + } \ 334 + \ 335 + static void __internal_irq_unmask_##width(struct irq_data *d, \ 336 + const struct cpumask *m) \ 337 + { \ 338 + u32 val; \ 339 + unsigned irq = d->irq - IRQ_INTERNAL_BASE; \ 340 + unsigned reg = (irq / 32) ^ (width/32 - 1); \ 341 + unsigned bit = irq & 0x1f; \ 342 + unsigned long flags; \ 343 + int cpu; \ 344 + \ 345 + spin_lock_irqsave(&ipic_lock, flags); \ 346 + for_each_present_cpu(cpu) { \ 347 + if (!irq_mask_addr[cpu]) \ 348 + break; \ 349 + \ 350 + val = bcm_readl(irq_mask_addr[cpu] + reg * sizeof(u32));\ 351 + if (enable_irq_for_cpu(cpu, d, m)) \ 352 + val |= (1 << bit); \ 353 + else \ 354 + val &= ~(1 << bit); \ 355 + bcm_writel(val, irq_mask_addr[cpu] + reg * sizeof(u32));\ 356 + } \ 357 + spin_unlock_irqrestore(&ipic_lock, flags); \ 79 358 } 80 359 81 - static void __dispatch_internal_64(void) 82 - { 83 - u64 pending; 84 - static int i; 85 - 86 - pending = bcm_readq(irq_stat_addr) & bcm_readq(irq_mask_addr); 87 - 88 - if (!pending) 89 - return ; 90 - 91 - while (1) { 92 - int to_call = i; 93 - 94 - i = (i + 1) & 0x3f; 95 - if (pending & (1ull << to_call)) { 96 - handle_internal(to_call); 97 - break; 98 - } 99 - } 100 - } 360 + BUILD_IPIC_INTERNAL(32); 361 + BUILD_IPIC_INTERNAL(64); 101 362 102 363 asmlinkage void plat_irq_dispatch(void) 103 364 { ··· 176 317 if (cause & CAUSEF_IP1) 177 318 do_IRQ(1); 178 319 if (cause & CAUSEF_IP2) 179 - dispatch_internal(); 180 - if (!is_ext_irq_cascaded) { 320 + dispatch_internal(0); 321 + if (is_ext_irq_cascaded) { 322 + if (cause & CAUSEF_IP3) 323 + dispatch_internal(1); 324 + } else { 181 325 if (cause & CAUSEF_IP3) 182 326 do_IRQ(IRQ_EXT_0); 183 327 if (cause & CAUSEF_IP4) ··· 197 335 * internal IRQs operations: only mask/unmask on PERF irq mask 198 336 * register. 199 337 */ 200 - static void __internal_irq_mask_32(unsigned int irq) 201 - { 202 - u32 mask; 203 - 204 - mask = bcm_readl(irq_mask_addr); 205 - mask &= ~(1 << irq); 206 - bcm_writel(mask, irq_mask_addr); 207 - } 208 - 209 - static void __internal_irq_mask_64(unsigned int irq) 210 - { 211 - u64 mask; 212 - 213 - mask = bcm_readq(irq_mask_addr); 214 - mask &= ~(1ull << irq); 215 - bcm_writeq(mask, irq_mask_addr); 216 - } 217 - 218 - static void __internal_irq_unmask_32(unsigned int irq) 219 - { 220 - u32 mask; 221 - 222 - mask = bcm_readl(irq_mask_addr); 223 - mask |= (1 << irq); 224 - bcm_writel(mask, irq_mask_addr); 225 - } 226 - 227 - static void __internal_irq_unmask_64(unsigned int irq) 228 - { 229 - u64 mask; 230 - 231 - mask = bcm_readq(irq_mask_addr); 232 - mask |= (1ull << irq); 233 - bcm_writeq(mask, irq_mask_addr); 234 - } 235 - 236 338 static void bcm63xx_internal_irq_mask(struct irq_data *d) 237 339 { 238 - internal_irq_mask(d->irq - IRQ_INTERNAL_BASE); 340 + internal_irq_mask(d); 239 341 } 240 342 241 343 static void bcm63xx_internal_irq_unmask(struct irq_data *d) 242 344 { 243 - internal_irq_unmask(d->irq - IRQ_INTERNAL_BASE); 345 + internal_irq_unmask(d, NULL); 244 346 } 245 347 246 348 /* ··· 215 389 { 216 390 unsigned int irq = d->irq - IRQ_EXTERNAL_BASE; 217 391 u32 reg, regaddr; 392 + unsigned long flags; 218 393 219 394 regaddr = get_ext_irq_perf_reg(irq); 395 + spin_lock_irqsave(&epic_lock, flags); 220 396 reg = bcm_perf_readl(regaddr); 221 397 222 398 if (BCMCPU_IS_6348()) ··· 227 399 reg &= ~EXTIRQ_CFG_MASK(irq % 4); 228 400 229 401 bcm_perf_writel(reg, regaddr); 402 + spin_unlock_irqrestore(&epic_lock, flags); 403 + 230 404 if (is_ext_irq_cascaded) 231 - internal_irq_mask(irq + ext_irq_start); 405 + internal_irq_mask(irq_get_irq_data(irq + ext_irq_start)); 232 406 } 233 407 234 408 static void bcm63xx_external_irq_unmask(struct irq_data *d) 235 409 { 236 410 unsigned int irq = d->irq - IRQ_EXTERNAL_BASE; 237 411 u32 reg, regaddr; 412 + unsigned long flags; 238 413 239 414 regaddr = get_ext_irq_perf_reg(irq); 415 + spin_lock_irqsave(&epic_lock, flags); 240 416 reg = bcm_perf_readl(regaddr); 241 417 242 418 if (BCMCPU_IS_6348()) ··· 249 417 reg |= EXTIRQ_CFG_MASK(irq % 4); 250 418 251 419 bcm_perf_writel(reg, regaddr); 420 + spin_unlock_irqrestore(&epic_lock, flags); 252 421 253 422 if (is_ext_irq_cascaded) 254 - internal_irq_unmask(irq + ext_irq_start); 423 + internal_irq_unmask(irq_get_irq_data(irq + ext_irq_start), 424 + NULL); 255 425 } 256 426 257 427 static void bcm63xx_external_irq_clear(struct irq_data *d) 258 428 { 259 429 unsigned int irq = d->irq - IRQ_EXTERNAL_BASE; 260 430 u32 reg, regaddr; 431 + unsigned long flags; 261 432 262 433 regaddr = get_ext_irq_perf_reg(irq); 434 + spin_lock_irqsave(&epic_lock, flags); 263 435 reg = bcm_perf_readl(regaddr); 264 436 265 437 if (BCMCPU_IS_6348()) ··· 272 436 reg |= EXTIRQ_CFG_CLEAR(irq % 4); 273 437 274 438 bcm_perf_writel(reg, regaddr); 439 + spin_unlock_irqrestore(&epic_lock, flags); 275 440 } 276 441 277 442 static int bcm63xx_external_irq_set_type(struct irq_data *d, ··· 281 444 unsigned int irq = d->irq - IRQ_EXTERNAL_BASE; 282 445 u32 reg, regaddr; 283 446 int levelsense, sense, bothedge; 447 + unsigned long flags; 284 448 285 449 flow_type &= IRQ_TYPE_SENSE_MASK; 286 450 ··· 316 478 } 317 479 318 480 regaddr = get_ext_irq_perf_reg(irq); 481 + spin_lock_irqsave(&epic_lock, flags); 319 482 reg = bcm_perf_readl(regaddr); 320 483 irq %= 4; 321 484 ··· 361 522 } 362 523 363 524 bcm_perf_writel(reg, regaddr); 525 + spin_unlock_irqrestore(&epic_lock, flags); 364 526 365 527 irqd_set_trigger_type(d, flow_type); 366 528 if (flow_type & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH)) ··· 371 531 372 532 return IRQ_SET_MASK_OK_NOCOPY; 373 533 } 534 + 535 + #ifdef CONFIG_SMP 536 + static int bcm63xx_internal_set_affinity(struct irq_data *data, 537 + const struct cpumask *dest, 538 + bool force) 539 + { 540 + if (!irqd_irq_disabled(data)) 541 + internal_irq_unmask(data, dest); 542 + 543 + return 0; 544 + } 545 + #endif 374 546 375 547 static struct irq_chip bcm63xx_internal_irq_chip = { 376 548 .name = "bcm63xx_ipic", ··· 406 554 .flags = IRQF_NO_THREAD, 407 555 }; 408 556 557 + #ifdef CONFIG_SMP 558 + static struct irqaction cpu_ip3_cascade_action = { 559 + .handler = no_action, 560 + .name = "cascade_ip3", 561 + .flags = IRQF_NO_THREAD, 562 + }; 563 + #endif 564 + 409 565 static struct irqaction cpu_ext_cascade_action = { 410 566 .handler = no_action, 411 567 .name = "cascade_extirq", 412 568 .flags = IRQF_NO_THREAD, 413 569 }; 570 + 571 + static void bcm63xx_init_irq(void) 572 + { 573 + int irq_bits; 574 + 575 + irq_stat_addr[0] = bcm63xx_regset_address(RSET_PERF); 576 + irq_mask_addr[0] = bcm63xx_regset_address(RSET_PERF); 577 + irq_stat_addr[1] = bcm63xx_regset_address(RSET_PERF); 578 + irq_mask_addr[1] = bcm63xx_regset_address(RSET_PERF); 579 + 580 + switch (bcm63xx_get_cpu_id()) { 581 + case BCM3368_CPU_ID: 582 + irq_stat_addr[0] += PERF_IRQSTAT_3368_REG; 583 + irq_mask_addr[0] += PERF_IRQMASK_3368_REG; 584 + irq_stat_addr[1] = 0; 585 + irq_stat_addr[1] = 0; 586 + irq_bits = 32; 587 + ext_irq_count = 4; 588 + ext_irq_cfg_reg1 = PERF_EXTIRQ_CFG_REG_3368; 589 + break; 590 + case BCM6328_CPU_ID: 591 + irq_stat_addr[0] += PERF_IRQSTAT_6328_REG(0); 592 + irq_mask_addr[0] += PERF_IRQMASK_6328_REG(0); 593 + irq_stat_addr[1] += PERF_IRQSTAT_6328_REG(1); 594 + irq_stat_addr[1] += PERF_IRQMASK_6328_REG(1); 595 + irq_bits = 64; 596 + ext_irq_count = 4; 597 + is_ext_irq_cascaded = 1; 598 + ext_irq_start = BCM_6328_EXT_IRQ0 - IRQ_INTERNAL_BASE; 599 + ext_irq_end = BCM_6328_EXT_IRQ3 - IRQ_INTERNAL_BASE; 600 + ext_irq_cfg_reg1 = PERF_EXTIRQ_CFG_REG_6328; 601 + break; 602 + case BCM6338_CPU_ID: 603 + irq_stat_addr[0] += PERF_IRQSTAT_6338_REG; 604 + irq_mask_addr[0] += PERF_IRQMASK_6338_REG; 605 + irq_stat_addr[1] = 0; 606 + irq_mask_addr[1] = 0; 607 + irq_bits = 32; 608 + ext_irq_count = 4; 609 + ext_irq_cfg_reg1 = PERF_EXTIRQ_CFG_REG_6338; 610 + break; 611 + case BCM6345_CPU_ID: 612 + irq_stat_addr[0] += PERF_IRQSTAT_6345_REG; 613 + irq_mask_addr[0] += PERF_IRQMASK_6345_REG; 614 + irq_stat_addr[1] = 0; 615 + irq_mask_addr[1] = 0; 616 + irq_bits = 32; 617 + ext_irq_count = 4; 618 + ext_irq_cfg_reg1 = PERF_EXTIRQ_CFG_REG_6345; 619 + break; 620 + case BCM6348_CPU_ID: 621 + irq_stat_addr[0] += PERF_IRQSTAT_6348_REG; 622 + irq_mask_addr[0] += PERF_IRQMASK_6348_REG; 623 + irq_stat_addr[1] = 0; 624 + irq_mask_addr[1] = 0; 625 + irq_bits = 32; 626 + ext_irq_count = 4; 627 + ext_irq_cfg_reg1 = PERF_EXTIRQ_CFG_REG_6348; 628 + break; 629 + case BCM6358_CPU_ID: 630 + irq_stat_addr[0] += PERF_IRQSTAT_6358_REG(0); 631 + irq_mask_addr[0] += PERF_IRQMASK_6358_REG(0); 632 + irq_stat_addr[1] += PERF_IRQSTAT_6358_REG(1); 633 + irq_mask_addr[1] += PERF_IRQMASK_6358_REG(1); 634 + irq_bits = 32; 635 + ext_irq_count = 4; 636 + is_ext_irq_cascaded = 1; 637 + ext_irq_start = BCM_6358_EXT_IRQ0 - IRQ_INTERNAL_BASE; 638 + ext_irq_end = BCM_6358_EXT_IRQ3 - IRQ_INTERNAL_BASE; 639 + ext_irq_cfg_reg1 = PERF_EXTIRQ_CFG_REG_6358; 640 + break; 641 + case BCM6362_CPU_ID: 642 + irq_stat_addr[0] += PERF_IRQSTAT_6362_REG(0); 643 + irq_mask_addr[0] += PERF_IRQMASK_6362_REG(0); 644 + irq_stat_addr[1] += PERF_IRQSTAT_6362_REG(1); 645 + irq_mask_addr[1] += PERF_IRQMASK_6362_REG(1); 646 + irq_bits = 64; 647 + ext_irq_count = 4; 648 + is_ext_irq_cascaded = 1; 649 + ext_irq_start = BCM_6362_EXT_IRQ0 - IRQ_INTERNAL_BASE; 650 + ext_irq_end = BCM_6362_EXT_IRQ3 - IRQ_INTERNAL_BASE; 651 + ext_irq_cfg_reg1 = PERF_EXTIRQ_CFG_REG_6362; 652 + break; 653 + case BCM6368_CPU_ID: 654 + irq_stat_addr[0] += PERF_IRQSTAT_6368_REG(0); 655 + irq_mask_addr[0] += PERF_IRQMASK_6368_REG(0); 656 + irq_stat_addr[1] += PERF_IRQSTAT_6368_REG(1); 657 + irq_mask_addr[1] += PERF_IRQMASK_6368_REG(1); 658 + irq_bits = 64; 659 + ext_irq_count = 6; 660 + is_ext_irq_cascaded = 1; 661 + ext_irq_start = BCM_6368_EXT_IRQ0 - IRQ_INTERNAL_BASE; 662 + ext_irq_end = BCM_6368_EXT_IRQ5 - IRQ_INTERNAL_BASE; 663 + ext_irq_cfg_reg1 = PERF_EXTIRQ_CFG_REG_6368; 664 + ext_irq_cfg_reg2 = PERF_EXTIRQ_CFG_REG2_6368; 665 + break; 666 + default: 667 + BUG(); 668 + } 669 + 670 + if (irq_bits == 32) { 671 + dispatch_internal = __dispatch_internal_32; 672 + internal_irq_mask = __internal_irq_mask_32; 673 + internal_irq_unmask = __internal_irq_unmask_32; 674 + } else { 675 + dispatch_internal = __dispatch_internal_64; 676 + internal_irq_mask = __internal_irq_mask_64; 677 + internal_irq_unmask = __internal_irq_unmask_64; 678 + } 679 + } 414 680 415 681 void __init arch_init_irq(void) 416 682 { ··· 550 580 } 551 581 552 582 setup_irq(MIPS_CPU_IRQ_BASE + 2, &cpu_ip2_cascade_action); 583 + #ifdef CONFIG_SMP 584 + if (is_ext_irq_cascaded) { 585 + setup_irq(MIPS_CPU_IRQ_BASE + 3, &cpu_ip3_cascade_action); 586 + bcm63xx_internal_irq_chip.irq_set_affinity = 587 + bcm63xx_internal_set_affinity; 588 + 589 + cpumask_clear(irq_default_affinity); 590 + cpumask_set_cpu(smp_processor_id(), irq_default_affinity); 591 + } 592 + #endif 553 593 }
-60
arch/mips/bcm63xx/reset.c
··· 125 125 #define BCM6368_RESET_PCIE 0 126 126 #define BCM6368_RESET_PCIE_EXT 0 127 127 128 - #ifdef BCMCPU_RUNTIME_DETECT 129 - 130 128 /* 131 129 * core reset bits 132 130 */ ··· 186 188 187 189 return 0; 188 190 } 189 - #else 190 - 191 - #ifdef CONFIG_BCM63XX_CPU_3368 192 - static const u32 bcm63xx_reset_bits[] = { 193 - __GEN_RESET_BITS_TABLE(3368) 194 - }; 195 - #define reset_reg PERF_SOFTRESET_6358_REG 196 - #endif 197 - 198 - #ifdef CONFIG_BCM63XX_CPU_6328 199 - static const u32 bcm63xx_reset_bits[] = { 200 - __GEN_RESET_BITS_TABLE(6328) 201 - }; 202 - #define reset_reg PERF_SOFTRESET_6328_REG 203 - #endif 204 - 205 - #ifdef CONFIG_BCM63XX_CPU_6338 206 - static const u32 bcm63xx_reset_bits[] = { 207 - __GEN_RESET_BITS_TABLE(6338) 208 - }; 209 - #define reset_reg PERF_SOFTRESET_REG 210 - #endif 211 - 212 - #ifdef CONFIG_BCM63XX_CPU_6345 213 - static const u32 bcm63xx_reset_bits[] = { }; 214 - #define reset_reg 0 215 - #endif 216 - 217 - #ifdef CONFIG_BCM63XX_CPU_6348 218 - static const u32 bcm63xx_reset_bits[] = { 219 - __GEN_RESET_BITS_TABLE(6348) 220 - }; 221 - #define reset_reg PERF_SOFTRESET_REG 222 - #endif 223 - 224 - #ifdef CONFIG_BCM63XX_CPU_6358 225 - static const u32 bcm63xx_reset_bits[] = { 226 - __GEN_RESET_BITS_TABLE(6358) 227 - }; 228 - #define reset_reg PERF_SOFTRESET_6358_REG 229 - #endif 230 - 231 - #ifdef CONFIG_BCM63XX_CPU_6362 232 - static const u32 bcm63xx_reset_bits[] = { 233 - __GEN_RESET_BITS_TABLE(6362) 234 - }; 235 - #define reset_reg PERF_SOFTRESET_6362_REG 236 - #endif 237 - 238 - #ifdef CONFIG_BCM63XX_CPU_6368 239 - static const u32 bcm63xx_reset_bits[] = { 240 - __GEN_RESET_BITS_TABLE(6368) 241 - }; 242 - #define reset_reg PERF_SOFTRESET_6368_REG 243 - #endif 244 - 245 - static int __init bcm63xx_reset_bits_init(void) { return 0; } 246 - #endif 247 191 248 192 static DEFINE_SPINLOCK(reset_mutex); 249 193
+14
arch/mips/boot/compressed/decompress.c
··· 67 67 #include "../../../../lib/decompress_unxz.c" 68 68 #endif 69 69 70 + unsigned long __stack_chk_guard; 71 + 72 + void __stack_chk_guard_setup(void) 73 + { 74 + __stack_chk_guard = 0x000a0dff; 75 + } 76 + 77 + void __stack_chk_fail(void) 78 + { 79 + error("stack-protector: Kernel stack is corrupted\n"); 80 + } 81 + 70 82 void decompress_kernel(unsigned long boot_heap_start) 71 83 { 72 84 unsigned long zimage_start, zimage_size; 85 + 86 + __stack_chk_guard_setup(); 73 87 74 88 zimage_start = (unsigned long)(&__image_begin); 75 89 zimage_size = (unsigned long)(&__image_end) -
+22
arch/mips/cavium-octeon/executive/cvmx-helper-board.c
··· 186 186 return 7 - ipd_port; 187 187 else 188 188 return -1; 189 + case CVMX_BOARD_TYPE_CUST_DSR1000N: 190 + /* 191 + * Port 2 connects to Broadcom PHY (B5081). Other ports (0-1) 192 + * connect to a switch (BCM53115). 193 + */ 194 + if (ipd_port == 2) 195 + return 8; 196 + else 197 + return -1; 189 198 } 190 199 191 200 /* Some unknown board. Somebody forgot to update this function... */ ··· 281 272 result.s.full_duplex = 1; 282 273 result.s.speed = 1000; 283 274 return result; 275 + } 276 + break; 277 + case CVMX_BOARD_TYPE_CUST_DSR1000N: 278 + if (ipd_port == 0 || ipd_port == 1) { 279 + /* Ports 0 and 1 connect to a switch (BCM53115). */ 280 + result.s.link_up = 1; 281 + result.s.full_duplex = 1; 282 + result.s.speed = 1000; 283 + return result; 284 + } else { 285 + /* Port 2 uses a Broadcom PHY (B5081). */ 286 + is_broadcom_phy = 1; 284 287 } 285 288 break; 286 289 } ··· 759 738 case CVMX_BOARD_TYPE_LANAI2_G: 760 739 case CVMX_BOARD_TYPE_NIC10E_66: 761 740 case CVMX_BOARD_TYPE_UBNT_E100: 741 + case CVMX_BOARD_TYPE_CUST_DSR1000N: 762 742 return USB_CLOCK_TYPE_CRYSTAL_12; 763 743 case CVMX_BOARD_TYPE_NIC10E: 764 744 return USB_CLOCK_TYPE_REF_12;
+1 -2
arch/mips/cavium-octeon/oct_ilm.c
··· 194 194 static __exit void oct_ilm_module_exit(void) 195 195 { 196 196 disable_timer(TIMER_NUM); 197 - if (dir) 198 - debugfs_remove_recursive(dir); 197 + debugfs_remove_recursive(dir); 199 198 free_irq(OCTEON_IRQ_TIMER0 + TIMER_NUM, 0); 200 199 } 201 200
+12 -11
arch/mips/cavium-octeon/smp.c
··· 84 84 #ifdef CONFIG_HOTPLUG_CPU 85 85 struct linux_app_boot_info *labi; 86 86 87 + if (!setup_max_cpus) 88 + return; 89 + 87 90 labi = (struct linux_app_boot_info *)PHYS_TO_XKSEG_CACHED(LABI_ADDR_IN_BOOTLOADER); 88 - if (labi->labi_signature != LABI_SIGNATURE) 89 - panic("The bootloader version on this board is incorrect."); 91 + if (labi->labi_signature != LABI_SIGNATURE) { 92 + pr_info("The bootloader on this board does not support HOTPLUG_CPU."); 93 + return; 94 + } 90 95 91 96 octeon_bootloader_entry_addr = labi->InitTLBStart_addr; 92 97 #endif ··· 134 129 * will assign CPU numbers for possible cores as well. Cores 135 130 * are always consecutively numberd from 0. 136 131 */ 137 - for (id = 0; id < num_cores && id < NR_CPUS; id++) { 132 + for (id = 0; setup_max_cpus && octeon_bootloader_entry_addr && 133 + id < num_cores && id < NR_CPUS; id++) { 138 134 if (!(core_mask & (1 << id))) { 139 135 set_cpu_possible(cpus, true); 140 136 __cpu_number_map[id] = cpus; ··· 198 192 */ 199 193 void octeon_prepare_cpus(unsigned int max_cpus) 200 194 { 201 - #ifdef CONFIG_HOTPLUG_CPU 202 - struct linux_app_boot_info *labi; 203 - 204 - labi = (struct linux_app_boot_info *)PHYS_TO_XKSEG_CACHED(LABI_ADDR_IN_BOOTLOADER); 205 - 206 - if (labi->labi_signature != LABI_SIGNATURE) 207 - panic("The bootloader version on this board is incorrect."); 208 - #endif 209 195 /* 210 196 * Only the low order mailbox bits are used for IPIs, leave 211 197 * the other bits alone. ··· 234 236 235 237 if (cpu == 0) 236 238 return -EBUSY; 239 + 240 + if (!octeon_bootloader_entry_addr) 241 + return -ENOTSUPP; 237 242 238 243 set_cpu_online(cpu, false); 239 244 cpu_clear(cpu, cpu_callin_map);
+1 -1
arch/mips/configs/loongson3_defconfig
··· 1 1 CONFIG_MACH_LOONGSON=y 2 2 CONFIG_SWIOTLB=y 3 - CONFIG_LEMOTE_MACH3A=y 3 + CONFIG_LOONGSON_MACH3X=y 4 4 CONFIG_CPU_LOONGSON3=y 5 5 CONFIG_64BIT=y 6 6 CONFIG_PAGE_SIZE_16KB=y
+1
arch/mips/include/asm/Kbuild
··· 15 15 generic-y += serial.h 16 16 generic-y += trace_clock.h 17 17 generic-y += ucontext.h 18 + generic-y += user.h 18 19 generic-y += xor.h
+1 -1
arch/mips/include/asm/addrspace.h
··· 52 52 */ 53 53 #define CPHYSADDR(a) ((_ACAST32_(a)) & 0x1fffffff) 54 54 #define XPHYSADDR(a) ((_ACAST64_(a)) & \ 55 - _CONST64_(0x000000ffffffffff)) 55 + _CONST64_(0x0000ffffffffffff)) 56 56 57 57 #ifdef CONFIG_64BIT 58 58
+31
arch/mips/include/asm/asmmacro.h
··· 10 10 11 11 #include <asm/hazards.h> 12 12 #include <asm/asm-offsets.h> 13 + #include <asm/msa.h> 13 14 14 15 #ifdef CONFIG_32BIT 15 16 #include <asm/asmmacro-32.h> ··· 379 378 st_d 29, THREAD_FPR29, \thread 380 379 st_d 30, THREAD_FPR30, \thread 381 380 st_d 31, THREAD_FPR31, \thread 381 + .set push 382 + .set noat 383 + cfcmsa $1, MSA_CSR 384 + sw $1, THREAD_MSA_CSR(\thread) 385 + .set pop 382 386 .endm 383 387 384 388 .macro msa_restore_all thread 389 + .set push 390 + .set noat 391 + lw $1, THREAD_MSA_CSR(\thread) 392 + ctcmsa MSA_CSR, $1 393 + .set pop 385 394 ld_d 0, THREAD_FPR0, \thread 386 395 ld_d 1, THREAD_FPR1, \thread 387 396 ld_d 2, THREAD_FPR2, \thread ··· 424 413 ld_d 29, THREAD_FPR29, \thread 425 414 ld_d 30, THREAD_FPR30, \thread 426 415 ld_d 31, THREAD_FPR31, \thread 416 + .endm 417 + 418 + .macro msa_init_upper wd 419 + #ifdef CONFIG_64BIT 420 + insert_d \wd, 1 421 + #else 422 + insert_w \wd, 2 423 + insert_w \wd, 3 424 + #endif 425 + .if 31-\wd 426 + msa_init_upper (\wd+1) 427 + .endif 428 + .endm 429 + 430 + .macro msa_init_all_upper 431 + .set push 432 + .set noat 433 + not $1, zero 434 + msa_init_upper 0 435 + .set pop 427 436 .endm 428 437 429 438 #endif /* _ASM_ASMMACRO_H */
+7 -1
arch/mips/include/asm/bitops.h
··· 559 559 int r; 560 560 561 561 if (__builtin_constant_p(cpu_has_clo_clz) && cpu_has_clo_clz) { 562 - __asm__("clz %0, %1" : "=r" (x) : "r" (x)); 562 + __asm__( 563 + " .set push \n" 564 + " .set mips32 \n" 565 + " clz %0, %1 \n" 566 + " .set pop \n" 567 + : "=r" (x) 568 + : "r" (x)); 563 569 564 570 return 32 - x; 565 571 }
+8
arch/mips/include/asm/cop2.h
··· 32 32 #define cop2_present 1 33 33 #define cop2_lazy_restore 0 34 34 35 + #elif defined(CONFIG_CPU_LOONGSON3) 36 + 37 + #define cop2_save(r) 38 + #define cop2_restore(r) 39 + 40 + #define cop2_present 1 41 + #define cop2_lazy_restore 1 42 + 35 43 #else 36 44 37 45 #define cop2_present 0
+9
arch/mips/include/asm/cpu-features.h
··· 29 29 #ifndef cpu_has_eva 30 30 #define cpu_has_eva (cpu_data[0].options & MIPS_CPU_EVA) 31 31 #endif 32 + #ifndef cpu_has_htw 33 + #define cpu_has_htw (cpu_data[0].options & MIPS_CPU_HTW) 34 + #endif 35 + #ifndef cpu_has_rixiex 36 + #define cpu_has_rixiex (cpu_data[0].options & MIPS_CPU_RIXIEX) 37 + #endif 38 + #ifndef cpu_has_maar 39 + #define cpu_has_maar (cpu_data[0].options & MIPS_CPU_MAAR) 40 + #endif 32 41 33 42 /* 34 43 * For the moment we don't consider R6000 and R8000 so we can assume that
+3 -2
arch/mips/include/asm/cpu-info.h
··· 44 44 /* 45 45 * Capability and feature descriptor structure for MIPS CPU 46 46 */ 47 - unsigned long options; 48 47 unsigned long ases; 48 + unsigned long long options; 49 49 unsigned int udelay_val; 50 50 unsigned int processor_id; 51 51 unsigned int fpu_id; ··· 61 61 struct cache_desc scache; /* Secondary cache */ 62 62 struct cache_desc tcache; /* Tertiary/split secondary cache */ 63 63 int srsets; /* Shadow register sets */ 64 + int package;/* physical package number */ 64 65 int core; /* physical core number */ 65 66 #ifdef CONFIG_64BIT 66 67 int vmbits; /* Virtual memory size in bits */ ··· 116 115 #ifdef CONFIG_MIPS_MT_SMP 117 116 # define cpu_vpe_id(cpuinfo) ((cpuinfo)->vpe_id) 118 117 #else 119 - # define cpu_vpe_id(cpuinfo) 0 118 + # define cpu_vpe_id(cpuinfo) ({ (void)cpuinfo; 0; }) 120 119 #endif 121 120 122 121 #endif /* __ASM_CPU_INFO_H */
+33 -28
arch/mips/include/asm/cpu.h
··· 233 233 #define PRID_REV_LOONGSON2E 0x0002 234 234 #define PRID_REV_LOONGSON2F 0x0003 235 235 #define PRID_REV_LOONGSON3A 0x0005 236 + #define PRID_REV_LOONGSON3B_R1 0x0006 237 + #define PRID_REV_LOONGSON3B_R2 0x0007 236 238 237 239 /* 238 240 * Older processors used to encode processor version and revision in two ··· 337 335 /* 338 336 * CPU Option encodings 339 337 */ 340 - #define MIPS_CPU_TLB 0x00000001 /* CPU has TLB */ 341 - #define MIPS_CPU_4KEX 0x00000002 /* "R4K" exception model */ 342 - #define MIPS_CPU_3K_CACHE 0x00000004 /* R3000-style caches */ 343 - #define MIPS_CPU_4K_CACHE 0x00000008 /* R4000-style caches */ 344 - #define MIPS_CPU_TX39_CACHE 0x00000010 /* TX3900-style caches */ 345 - #define MIPS_CPU_FPU 0x00000020 /* CPU has FPU */ 346 - #define MIPS_CPU_32FPR 0x00000040 /* 32 dbl. prec. FP registers */ 347 - #define MIPS_CPU_COUNTER 0x00000080 /* Cycle count/compare */ 348 - #define MIPS_CPU_WATCH 0x00000100 /* watchpoint registers */ 349 - #define MIPS_CPU_DIVEC 0x00000200 /* dedicated interrupt vector */ 350 - #define MIPS_CPU_VCE 0x00000400 /* virt. coherence conflict possible */ 351 - #define MIPS_CPU_CACHE_CDEX_P 0x00000800 /* Create_Dirty_Exclusive CACHE op */ 352 - #define MIPS_CPU_CACHE_CDEX_S 0x00001000 /* ... same for seconary cache ... */ 353 - #define MIPS_CPU_MCHECK 0x00002000 /* Machine check exception */ 354 - #define MIPS_CPU_EJTAG 0x00004000 /* EJTAG exception */ 355 - #define MIPS_CPU_NOFPUEX 0x00008000 /* no FPU exception */ 356 - #define MIPS_CPU_LLSC 0x00010000 /* CPU has ll/sc instructions */ 357 - #define MIPS_CPU_INCLUSIVE_CACHES 0x00020000 /* P-cache subset enforced */ 358 - #define MIPS_CPU_PREFETCH 0x00040000 /* CPU has usable prefetch */ 359 - #define MIPS_CPU_VINT 0x00080000 /* CPU supports MIPSR2 vectored interrupts */ 360 - #define MIPS_CPU_VEIC 0x00100000 /* CPU supports MIPSR2 external interrupt controller mode */ 361 - #define MIPS_CPU_ULRI 0x00200000 /* CPU has ULRI feature */ 362 - #define MIPS_CPU_PCI 0x00400000 /* CPU has Perf Ctr Int indicator */ 363 - #define MIPS_CPU_RIXI 0x00800000 /* CPU has TLB Read/eXec Inhibit */ 364 - #define MIPS_CPU_MICROMIPS 0x01000000 /* CPU has microMIPS capability */ 365 - #define MIPS_CPU_TLBINV 0x02000000 /* CPU supports TLBINV/F */ 366 - #define MIPS_CPU_SEGMENTS 0x04000000 /* CPU supports Segmentation Control registers */ 367 - #define MIPS_CPU_EVA 0x80000000 /* CPU supports Enhanced Virtual Addressing */ 338 + #define MIPS_CPU_TLB 0x00000001ull /* CPU has TLB */ 339 + #define MIPS_CPU_4KEX 0x00000002ull /* "R4K" exception model */ 340 + #define MIPS_CPU_3K_CACHE 0x00000004ull /* R3000-style caches */ 341 + #define MIPS_CPU_4K_CACHE 0x00000008ull /* R4000-style caches */ 342 + #define MIPS_CPU_TX39_CACHE 0x00000010ull /* TX3900-style caches */ 343 + #define MIPS_CPU_FPU 0x00000020ull /* CPU has FPU */ 344 + #define MIPS_CPU_32FPR 0x00000040ull /* 32 dbl. prec. FP registers */ 345 + #define MIPS_CPU_COUNTER 0x00000080ull /* Cycle count/compare */ 346 + #define MIPS_CPU_WATCH 0x00000100ull /* watchpoint registers */ 347 + #define MIPS_CPU_DIVEC 0x00000200ull /* dedicated interrupt vector */ 348 + #define MIPS_CPU_VCE 0x00000400ull /* virt. coherence conflict possible */ 349 + #define MIPS_CPU_CACHE_CDEX_P 0x00000800ull /* Create_Dirty_Exclusive CACHE op */ 350 + #define MIPS_CPU_CACHE_CDEX_S 0x00001000ull /* ... same for seconary cache ... */ 351 + #define MIPS_CPU_MCHECK 0x00002000ull /* Machine check exception */ 352 + #define MIPS_CPU_EJTAG 0x00004000ull /* EJTAG exception */ 353 + #define MIPS_CPU_NOFPUEX 0x00008000ull /* no FPU exception */ 354 + #define MIPS_CPU_LLSC 0x00010000ull /* CPU has ll/sc instructions */ 355 + #define MIPS_CPU_INCLUSIVE_CACHES 0x00020000ull /* P-cache subset enforced */ 356 + #define MIPS_CPU_PREFETCH 0x00040000ull /* CPU has usable prefetch */ 357 + #define MIPS_CPU_VINT 0x00080000ull /* CPU supports MIPSR2 vectored interrupts */ 358 + #define MIPS_CPU_VEIC 0x00100000ull /* CPU supports MIPSR2 external interrupt controller mode */ 359 + #define MIPS_CPU_ULRI 0x00200000ull /* CPU has ULRI feature */ 360 + #define MIPS_CPU_PCI 0x00400000ull /* CPU has Perf Ctr Int indicator */ 361 + #define MIPS_CPU_RIXI 0x00800000ull /* CPU has TLB Read/eXec Inhibit */ 362 + #define MIPS_CPU_MICROMIPS 0x01000000ull /* CPU has microMIPS capability */ 363 + #define MIPS_CPU_TLBINV 0x02000000ull /* CPU supports TLBINV/F */ 364 + #define MIPS_CPU_SEGMENTS 0x04000000ull /* CPU supports Segmentation Control registers */ 365 + #define MIPS_CPU_EVA 0x80000000ull /* CPU supports Enhanced Virtual Addressing */ 366 + #define MIPS_CPU_HTW 0x100000000ull /* CPU support Hardware Page Table Walker */ 367 + #define MIPS_CPU_RIXIEX 0x200000000ull /* CPU has unique exception codes for {Read, Execute}-Inhibit exceptions */ 368 + #define MIPS_CPU_MAAR 0x400000000ull /* MAAR(I) registers are present */ 368 369 369 370 /* 370 371 * CPU ASE encodings
-17
arch/mips/include/asm/elf.h
··· 339 339 340 340 #endif /* CONFIG_64BIT */ 341 341 342 - struct pt_regs; 343 - struct task_struct; 344 - 345 - extern void elf_dump_regs(elf_greg_t *, struct pt_regs *regs); 346 - extern int dump_task_regs(struct task_struct *, elf_gregset_t *); 347 - extern int dump_task_fpu(struct task_struct *, elf_fpregset_t *); 348 - 349 - #ifndef ELF_CORE_COPY_REGS 350 - #define ELF_CORE_COPY_REGS(elf_regs, regs) \ 351 - elf_dump_regs((elf_greg_t *)&(elf_regs), regs); 352 - #endif 353 - #ifndef ELF_CORE_COPY_TASK_REGS 354 - #define ELF_CORE_COPY_TASK_REGS(tsk, elf_regs) dump_task_regs(tsk, elf_regs) 355 - #endif 356 - #define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs) \ 357 - dump_task_fpu(tsk, elf_fpregs) 358 - 359 342 #define CORE_DUMP_USE_REGSET 360 343 #define ELF_EXEC_PAGESIZE PAGE_SIZE 361 344
+12 -7
arch/mips/include/asm/fpu.h
··· 21 21 #include <asm/hazards.h> 22 22 #include <asm/processor.h> 23 23 #include <asm/current.h> 24 + #include <asm/msa.h> 24 25 25 26 #ifdef CONFIG_MIPS_MT_FPAFF 26 27 #include <asm/mips_mt.h> ··· 142 141 static inline void lose_fpu(int save) 143 142 { 144 143 preempt_disable(); 145 - if (is_fpu_owner()) { 144 + if (is_msa_enabled()) { 145 + if (save) { 146 + save_msa(current); 147 + asm volatile("cfc1 %0, $31" 148 + : "=r"(current->thread.fpu.fcr31)); 149 + } 150 + disable_msa(); 151 + clear_thread_flag(TIF_USEDMSA); 152 + } else if (is_fpu_owner()) { 146 153 if (save) 147 154 _save_fp(current); 148 - KSTK_STATUS(current) &= ~ST0_CU1; 149 - clear_thread_flag(TIF_USEDFPU); 150 155 __disable_fpu(); 151 156 } 157 + KSTK_STATUS(current) &= ~ST0_CU1; 158 + clear_thread_flag(TIF_USEDFPU); 152 159 preempt_enable(); 153 160 } 154 161 ··· 164 155 { 165 156 int ret = 0; 166 157 167 - preempt_disable(); 168 - 169 158 if (cpu_has_fpu) { 170 159 ret = __own_fpu(); 171 160 if (!ret) 172 161 _init_fpu(); 173 162 } else 174 163 fpu_emulator_init_fpu(); 175 - 176 - preempt_enable(); 177 164 178 165 return ret; 179 166 }
+15 -26
arch/mips/include/asm/gic.h
··· 14 14 #include <linux/bitmap.h> 15 15 #include <linux/threads.h> 16 16 17 + #include <irq.h> 18 + 17 19 #undef GICISBYTELITTLEENDIAN 18 20 19 21 /* Constants */ ··· 23 21 #define GIC_POL_NEG 0 24 22 #define GIC_TRIG_EDGE 1 25 23 #define GIC_TRIG_LEVEL 0 26 - 27 - #define GIC_NUM_INTRS (24 + NR_CPUS * 2) 28 24 29 25 #define MSK(n) ((1 << (n)) - 1) 30 26 #define REG32(addr) (*(volatile unsigned int *) (addr)) ··· 43 43 #ifdef GICISBYTELITTLEENDIAN 44 44 #define GICREAD(reg, data) ((data) = (reg), (data) = le32_to_cpu(data)) 45 45 #define GICWRITE(reg, data) ((reg) = cpu_to_le32(data)) 46 - #define GICBIS(reg, bits) \ 47 - ({unsigned int data; \ 48 - GICREAD(reg, data); \ 49 - data |= bits; \ 50 - GICWRITE(reg, data); \ 51 - }) 52 - 53 46 #else 54 47 #define GICREAD(reg, data) ((data) = (reg)) 55 48 #define GICWRITE(reg, data) ((reg) = (data)) 56 - #define GICBIS(reg, bits) ((reg) |= (bits)) 57 49 #endif 50 + #define GICBIS(reg, mask, bits) \ 51 + do { u32 data; \ 52 + GICREAD((reg), data); \ 53 + data &= ~(mask); \ 54 + data |= ((bits) & (mask)); \ 55 + GICWRITE((reg), data); \ 56 + } while (0) 58 57 59 58 60 59 /* GIC Address Space */ ··· 169 170 #define GIC_SH_SET_POLARITY_OFS 0x0100 170 171 #define GIC_SET_POLARITY(intr, pol) \ 171 172 GICBIS(GIC_REG_ADDR(SHARED, GIC_SH_SET_POLARITY_OFS + \ 172 - GIC_INTR_OFS(intr)), (pol) << GIC_INTR_BIT(intr)) 173 + GIC_INTR_OFS(intr)), (1 << GIC_INTR_BIT(intr)), \ 174 + (pol) << GIC_INTR_BIT(intr)) 173 175 174 176 /* Triggering : Reset Value is always 0 */ 175 177 #define GIC_SH_SET_TRIGGER_OFS 0x0180 176 178 #define GIC_SET_TRIGGER(intr, trig) \ 177 179 GICBIS(GIC_REG_ADDR(SHARED, GIC_SH_SET_TRIGGER_OFS + \ 178 - GIC_INTR_OFS(intr)), (trig) << GIC_INTR_BIT(intr)) 180 + GIC_INTR_OFS(intr)), (1 << GIC_INTR_BIT(intr)), \ 181 + (trig) << GIC_INTR_BIT(intr)) 179 182 180 183 /* Mask manipulation */ 181 184 #define GIC_SH_SMASK_OFS 0x0380 ··· 307 306 GICWRITE(GIC_REG_ADDR(SHARED, GIC_SH_MAP_TO_VPE_REG_OFF(intr, vpe)), \ 308 307 GIC_SH_MAP_TO_VPE_REG_BIT(vpe)) 309 308 310 - struct gic_pcpu_mask { 311 - DECLARE_BITMAP(pcpu_mask, GIC_NUM_INTRS); 312 - }; 313 - 314 - struct gic_pending_regs { 315 - DECLARE_BITMAP(pending, GIC_NUM_INTRS); 316 - }; 317 - 318 - struct gic_intrmask_regs { 319 - DECLARE_BITMAP(intrmask, GIC_NUM_INTRS); 320 - }; 321 - 322 309 /* 323 310 * Interrupt Meta-data specification. The ipiflag helps 324 311 * in building ipi_map. ··· 318 329 unsigned int polarity; /* Polarity : +/- */ 319 330 unsigned int trigtype; /* Trigger : Edge/Levl */ 320 331 unsigned int flags; /* Misc flags */ 321 - #define GIC_FLAG_IPI 0x01 322 - #define GIC_FLAG_TRANSPARENT 0x02 332 + #define GIC_FLAG_TRANSPARENT 0x01 323 333 }; 324 334 325 335 /* ··· 374 386 extern unsigned int plat_ipi_resched_int_xlate(unsigned int); 375 387 extern void gic_bind_eic_interrupt(int irq, int set); 376 388 extern unsigned int gic_get_timer_pending(void); 389 + extern void gic_get_int_mask(unsigned long *dst, const unsigned long *src); 377 390 extern unsigned int gic_get_int(void); 378 391 extern void gic_enable_interrupt(int irq_vec); 379 392 extern void gic_disable_interrupt(int irq_vec);
+109
arch/mips/include/asm/maar.h
··· 1 + /* 2 + * Copyright (C) 2014 Imagination Technologies 3 + * Author: Paul Burton <paul.burton@imgtec.com> 4 + * 5 + * This program is free software; you can redistribute it and/or modify it 6 + * under the terms of the GNU General Public License as published by the 7 + * Free Software Foundation; either version 2 of the License, or (at your 8 + * option) any later version. 9 + */ 10 + 11 + #ifndef __MIPS_ASM_MIPS_MAAR_H__ 12 + #define __MIPS_ASM_MIPS_MAAR_H__ 13 + 14 + #include <asm/hazards.h> 15 + #include <asm/mipsregs.h> 16 + 17 + /** 18 + * platform_maar_init() - perform platform-level MAAR configuration 19 + * @num_pairs: The number of MAAR pairs present in the system. 20 + * 21 + * Platforms should implement this function such that it configures as many 22 + * MAAR pairs as required, from 0 up to the maximum of num_pairs-1, and returns 23 + * the number that were used. Any further MAARs will be configured to be 24 + * invalid. The default implementation of this function will simply indicate 25 + * that it has configured 0 MAAR pairs. 26 + * 27 + * Return: The number of MAAR pairs configured. 28 + */ 29 + unsigned __weak platform_maar_init(unsigned num_pairs); 30 + 31 + /** 32 + * write_maar_pair() - write to a pair of MAARs 33 + * @idx: The index of the pair (ie. use MAARs idx*2 & (idx*2)+1). 34 + * @lower: The lowest address that the MAAR pair will affect. Must be 35 + * aligned to a 2^16 byte boundary. 36 + * @upper: The highest address that the MAAR pair will affect. Must be 37 + * aligned to one byte before a 2^16 byte boundary. 38 + * @attrs: The accessibility attributes to program, eg. MIPS_MAAR_S. The 39 + * MIPS_MAAR_V attribute will automatically be set. 40 + * 41 + * Program the pair of MAAR registers specified by idx to apply the attributes 42 + * specified by attrs to the range of addresses from lower to higher. 43 + */ 44 + static inline void write_maar_pair(unsigned idx, phys_addr_t lower, 45 + phys_addr_t upper, unsigned attrs) 46 + { 47 + /* Addresses begin at bit 16, but are shifted right 4 bits */ 48 + BUG_ON(lower & (0xffff | ~(MIPS_MAAR_ADDR << 4))); 49 + BUG_ON(((upper & 0xffff) != 0xffff) 50 + || ((upper & ~0xffffull) & ~(MIPS_MAAR_ADDR << 4))); 51 + 52 + /* Automatically set MIPS_MAAR_V */ 53 + attrs |= MIPS_MAAR_V; 54 + 55 + /* Write the upper address & attributes (only MIPS_MAAR_V matters) */ 56 + write_c0_maari(idx << 1); 57 + back_to_back_c0_hazard(); 58 + write_c0_maar(((upper >> 4) & MIPS_MAAR_ADDR) | attrs); 59 + back_to_back_c0_hazard(); 60 + 61 + /* Write the lower address & attributes */ 62 + write_c0_maari((idx << 1) | 0x1); 63 + back_to_back_c0_hazard(); 64 + write_c0_maar((lower >> 4) | attrs); 65 + back_to_back_c0_hazard(); 66 + } 67 + 68 + /** 69 + * struct maar_config - MAAR configuration data 70 + * @lower: The lowest address that the MAAR pair will affect. Must be 71 + * aligned to a 2^16 byte boundary. 72 + * @upper: The highest address that the MAAR pair will affect. Must be 73 + * aligned to one byte before a 2^16 byte boundary. 74 + * @attrs: The accessibility attributes to program, eg. MIPS_MAAR_S. The 75 + * MIPS_MAAR_V attribute will automatically be set. 76 + * 77 + * Describes the configuration of a pair of Memory Accessibility Attribute 78 + * Registers - applying attributes from attrs to the range of physical 79 + * addresses from lower to upper inclusive. 80 + */ 81 + struct maar_config { 82 + phys_addr_t lower; 83 + phys_addr_t upper; 84 + unsigned attrs; 85 + }; 86 + 87 + /** 88 + * maar_config() - configure MAARs according to provided data 89 + * @cfg: Pointer to an array of struct maar_config. 90 + * @num_cfg: The number of structs in the cfg array. 91 + * @num_pairs: The number of MAAR pairs present in the system. 92 + * 93 + * Configures as many MAARs as are present and specified in the cfg 94 + * array with the values taken from the cfg array. 95 + * 96 + * Return: The number of MAAR pairs configured. 97 + */ 98 + static inline unsigned maar_config(const struct maar_config *cfg, 99 + unsigned num_cfg, unsigned num_pairs) 100 + { 101 + unsigned i; 102 + 103 + for (i = 0; i < min(num_cfg, num_pairs); i++) 104 + write_maar_pair(i, cfg[i].lower, cfg[i].upper, cfg[i].attrs); 105 + 106 + return i; 107 + } 108 + 109 + #endif /* __MIPS_ASM_MIPS_MAAR_H__ */
+592 -943
arch/mips/include/asm/mach-au1x00/au1000.h
··· 34 34 #ifndef _AU1000_H_ 35 35 #define _AU1000_H_ 36 36 37 + /* SOC Interrupt numbers */ 38 + /* Au1000-style (IC0/1): 2 controllers with 32 sources each */ 39 + #define AU1000_INTC0_INT_BASE (MIPS_CPU_IRQ_BASE + 8) 40 + #define AU1000_INTC0_INT_LAST (AU1000_INTC0_INT_BASE + 31) 41 + #define AU1000_INTC1_INT_BASE (AU1000_INTC0_INT_LAST + 1) 42 + #define AU1000_INTC1_INT_LAST (AU1000_INTC1_INT_BASE + 31) 43 + #define AU1000_MAX_INTR AU1000_INTC1_INT_LAST 44 + 45 + /* Au1300-style (GPIC): 1 controller with up to 128 sources */ 46 + #define ALCHEMY_GPIC_INT_BASE (MIPS_CPU_IRQ_BASE + 8) 47 + #define ALCHEMY_GPIC_INT_NUM 128 48 + #define ALCHEMY_GPIC_INT_LAST (ALCHEMY_GPIC_INT_BASE + ALCHEMY_GPIC_INT_NUM - 1) 49 + 50 + /* common clock names, shared among all variants. AUXPLL2 is Au1300 */ 51 + #define ALCHEMY_ROOT_CLK "root_clk" 52 + #define ALCHEMY_CPU_CLK "cpu_clk" 53 + #define ALCHEMY_AUXPLL_CLK "auxpll_clk" 54 + #define ALCHEMY_AUXPLL2_CLK "auxpll2_clk" 55 + #define ALCHEMY_SYSBUS_CLK "sysbus_clk" 56 + #define ALCHEMY_PERIPH_CLK "periph_clk" 57 + #define ALCHEMY_MEM_CLK "mem_clk" 58 + #define ALCHEMY_LR_CLK "lr_clk" 59 + #define ALCHEMY_FG0_CLK "fg0_clk" 60 + #define ALCHEMY_FG1_CLK "fg1_clk" 61 + #define ALCHEMY_FG2_CLK "fg2_clk" 62 + #define ALCHEMY_FG3_CLK "fg3_clk" 63 + #define ALCHEMY_FG4_CLK "fg4_clk" 64 + #define ALCHEMY_FG5_CLK "fg5_clk" 65 + 66 + /* Au1300 peripheral interrupt numbers */ 67 + #define AU1300_FIRST_INT (ALCHEMY_GPIC_INT_BASE) 68 + #define AU1300_UART1_INT (AU1300_FIRST_INT + 17) 69 + #define AU1300_UART2_INT (AU1300_FIRST_INT + 25) 70 + #define AU1300_UART3_INT (AU1300_FIRST_INT + 27) 71 + #define AU1300_SD1_INT (AU1300_FIRST_INT + 32) 72 + #define AU1300_SD2_INT (AU1300_FIRST_INT + 38) 73 + #define AU1300_PSC0_INT (AU1300_FIRST_INT + 48) 74 + #define AU1300_PSC1_INT (AU1300_FIRST_INT + 52) 75 + #define AU1300_PSC2_INT (AU1300_FIRST_INT + 56) 76 + #define AU1300_PSC3_INT (AU1300_FIRST_INT + 60) 77 + #define AU1300_NAND_INT (AU1300_FIRST_INT + 62) 78 + #define AU1300_DDMA_INT (AU1300_FIRST_INT + 75) 79 + #define AU1300_MMU_INT (AU1300_FIRST_INT + 76) 80 + #define AU1300_MPU_INT (AU1300_FIRST_INT + 77) 81 + #define AU1300_GPU_INT (AU1300_FIRST_INT + 78) 82 + #define AU1300_UDMA_INT (AU1300_FIRST_INT + 79) 83 + #define AU1300_TOY_INT (AU1300_FIRST_INT + 80) 84 + #define AU1300_TOY_MATCH0_INT (AU1300_FIRST_INT + 81) 85 + #define AU1300_TOY_MATCH1_INT (AU1300_FIRST_INT + 82) 86 + #define AU1300_TOY_MATCH2_INT (AU1300_FIRST_INT + 83) 87 + #define AU1300_RTC_INT (AU1300_FIRST_INT + 84) 88 + #define AU1300_RTC_MATCH0_INT (AU1300_FIRST_INT + 85) 89 + #define AU1300_RTC_MATCH1_INT (AU1300_FIRST_INT + 86) 90 + #define AU1300_RTC_MATCH2_INT (AU1300_FIRST_INT + 87) 91 + #define AU1300_UART0_INT (AU1300_FIRST_INT + 88) 92 + #define AU1300_SD0_INT (AU1300_FIRST_INT + 89) 93 + #define AU1300_USB_INT (AU1300_FIRST_INT + 90) 94 + #define AU1300_LCD_INT (AU1300_FIRST_INT + 91) 95 + #define AU1300_BSA_INT (AU1300_FIRST_INT + 92) 96 + #define AU1300_MPE_INT (AU1300_FIRST_INT + 93) 97 + #define AU1300_ITE_INT (AU1300_FIRST_INT + 94) 98 + #define AU1300_AES_INT (AU1300_FIRST_INT + 95) 99 + #define AU1300_CIM_INT (AU1300_FIRST_INT + 96) 100 + 101 + /**********************************************************************/ 102 + 103 + /* 104 + * Physical base addresses for integrated peripherals 105 + * 0..au1000 1..au1500 2..au1100 3..au1550 4..au1200 5..au1300 106 + */ 107 + 108 + #define AU1000_AC97_PHYS_ADDR 0x10000000 /* 012 */ 109 + #define AU1300_ROM_PHYS_ADDR 0x10000000 /* 5 */ 110 + #define AU1300_OTP_PHYS_ADDR 0x10002000 /* 5 */ 111 + #define AU1300_VSS_PHYS_ADDR 0x10003000 /* 5 */ 112 + #define AU1300_UART0_PHYS_ADDR 0x10100000 /* 5 */ 113 + #define AU1300_UART1_PHYS_ADDR 0x10101000 /* 5 */ 114 + #define AU1300_UART2_PHYS_ADDR 0x10102000 /* 5 */ 115 + #define AU1300_UART3_PHYS_ADDR 0x10103000 /* 5 */ 116 + #define AU1000_USB_OHCI_PHYS_ADDR 0x10100000 /* 012 */ 117 + #define AU1000_USB_UDC_PHYS_ADDR 0x10200000 /* 0123 */ 118 + #define AU1300_GPIC_PHYS_ADDR 0x10200000 /* 5 */ 119 + #define AU1000_IRDA_PHYS_ADDR 0x10300000 /* 02 */ 120 + #define AU1200_AES_PHYS_ADDR 0x10300000 /* 45 */ 121 + #define AU1000_IC0_PHYS_ADDR 0x10400000 /* 01234 */ 122 + #define AU1300_GPU_PHYS_ADDR 0x10500000 /* 5 */ 123 + #define AU1000_MAC0_PHYS_ADDR 0x10500000 /* 023 */ 124 + #define AU1000_MAC1_PHYS_ADDR 0x10510000 /* 023 */ 125 + #define AU1000_MACEN_PHYS_ADDR 0x10520000 /* 023 */ 126 + #define AU1100_SD0_PHYS_ADDR 0x10600000 /* 245 */ 127 + #define AU1300_SD1_PHYS_ADDR 0x10601000 /* 5 */ 128 + #define AU1300_SD2_PHYS_ADDR 0x10602000 /* 5 */ 129 + #define AU1100_SD1_PHYS_ADDR 0x10680000 /* 24 */ 130 + #define AU1300_SYS_PHYS_ADDR 0x10900000 /* 5 */ 131 + #define AU1550_PSC2_PHYS_ADDR 0x10A00000 /* 3 */ 132 + #define AU1550_PSC3_PHYS_ADDR 0x10B00000 /* 3 */ 133 + #define AU1300_PSC0_PHYS_ADDR 0x10A00000 /* 5 */ 134 + #define AU1300_PSC1_PHYS_ADDR 0x10A01000 /* 5 */ 135 + #define AU1300_PSC2_PHYS_ADDR 0x10A02000 /* 5 */ 136 + #define AU1300_PSC3_PHYS_ADDR 0x10A03000 /* 5 */ 137 + #define AU1000_I2S_PHYS_ADDR 0x11000000 /* 02 */ 138 + #define AU1500_MAC0_PHYS_ADDR 0x11500000 /* 1 */ 139 + #define AU1500_MAC1_PHYS_ADDR 0x11510000 /* 1 */ 140 + #define AU1500_MACEN_PHYS_ADDR 0x11520000 /* 1 */ 141 + #define AU1000_UART0_PHYS_ADDR 0x11100000 /* 01234 */ 142 + #define AU1200_SWCNT_PHYS_ADDR 0x1110010C /* 4 */ 143 + #define AU1000_UART1_PHYS_ADDR 0x11200000 /* 0234 */ 144 + #define AU1000_UART2_PHYS_ADDR 0x11300000 /* 0 */ 145 + #define AU1000_UART3_PHYS_ADDR 0x11400000 /* 0123 */ 146 + #define AU1000_SSI0_PHYS_ADDR 0x11600000 /* 02 */ 147 + #define AU1000_SSI1_PHYS_ADDR 0x11680000 /* 02 */ 148 + #define AU1500_GPIO2_PHYS_ADDR 0x11700000 /* 1234 */ 149 + #define AU1000_IC1_PHYS_ADDR 0x11800000 /* 01234 */ 150 + #define AU1000_SYS_PHYS_ADDR 0x11900000 /* 012345 */ 151 + #define AU1550_PSC0_PHYS_ADDR 0x11A00000 /* 34 */ 152 + #define AU1550_PSC1_PHYS_ADDR 0x11B00000 /* 34 */ 153 + #define AU1000_MEM_PHYS_ADDR 0x14000000 /* 01234 */ 154 + #define AU1000_STATIC_MEM_PHYS_ADDR 0x14001000 /* 01234 */ 155 + #define AU1300_UDMA_PHYS_ADDR 0x14001800 /* 5 */ 156 + #define AU1000_DMA_PHYS_ADDR 0x14002000 /* 012 */ 157 + #define AU1550_DBDMA_PHYS_ADDR 0x14002000 /* 345 */ 158 + #define AU1550_DBDMA_CONF_PHYS_ADDR 0x14003000 /* 345 */ 159 + #define AU1000_MACDMA0_PHYS_ADDR 0x14004000 /* 0123 */ 160 + #define AU1000_MACDMA1_PHYS_ADDR 0x14004200 /* 0123 */ 161 + #define AU1200_CIM_PHYS_ADDR 0x14004000 /* 45 */ 162 + #define AU1500_PCI_PHYS_ADDR 0x14005000 /* 13 */ 163 + #define AU1550_PE_PHYS_ADDR 0x14008000 /* 3 */ 164 + #define AU1200_MAEBE_PHYS_ADDR 0x14010000 /* 4 */ 165 + #define AU1200_MAEFE_PHYS_ADDR 0x14012000 /* 4 */ 166 + #define AU1300_MAEITE_PHYS_ADDR 0x14010000 /* 5 */ 167 + #define AU1300_MAEMPE_PHYS_ADDR 0x14014000 /* 5 */ 168 + #define AU1550_USB_OHCI_PHYS_ADDR 0x14020000 /* 3 */ 169 + #define AU1200_USB_CTL_PHYS_ADDR 0x14020000 /* 4 */ 170 + #define AU1200_USB_OTG_PHYS_ADDR 0x14020020 /* 4 */ 171 + #define AU1200_USB_OHCI_PHYS_ADDR 0x14020100 /* 4 */ 172 + #define AU1200_USB_EHCI_PHYS_ADDR 0x14020200 /* 4 */ 173 + #define AU1200_USB_UDC_PHYS_ADDR 0x14022000 /* 4 */ 174 + #define AU1300_USB_EHCI_PHYS_ADDR 0x14020000 /* 5 */ 175 + #define AU1300_USB_OHCI0_PHYS_ADDR 0x14020400 /* 5 */ 176 + #define AU1300_USB_OHCI1_PHYS_ADDR 0x14020800 /* 5 */ 177 + #define AU1300_USB_CTL_PHYS_ADDR 0x14021000 /* 5 */ 178 + #define AU1300_USB_OTG_PHYS_ADDR 0x14022000 /* 5 */ 179 + #define AU1300_MAEBSA_PHYS_ADDR 0x14030000 /* 5 */ 180 + #define AU1100_LCD_PHYS_ADDR 0x15000000 /* 2 */ 181 + #define AU1200_LCD_PHYS_ADDR 0x15000000 /* 45 */ 182 + #define AU1500_PCI_MEM_PHYS_ADDR 0x400000000ULL /* 13 */ 183 + #define AU1500_PCI_IO_PHYS_ADDR 0x500000000ULL /* 13 */ 184 + #define AU1500_PCI_CONFIG0_PHYS_ADDR 0x600000000ULL /* 13 */ 185 + #define AU1500_PCI_CONFIG1_PHYS_ADDR 0x680000000ULL /* 13 */ 186 + #define AU1000_PCMCIA_IO_PHYS_ADDR 0xF00000000ULL /* 012345 */ 187 + #define AU1000_PCMCIA_ATTR_PHYS_ADDR 0xF40000000ULL /* 012345 */ 188 + #define AU1000_PCMCIA_MEM_PHYS_ADDR 0xF80000000ULL /* 012345 */ 189 + 190 + /**********************************************************************/ 191 + 192 + 193 + /* 194 + * Au1300 GPIO+INT controller (GPIC) register offsets and bits 195 + * Registers are 128bits (0x10 bytes), divided into 4 "banks". 196 + */ 197 + #define AU1300_GPIC_PINVAL 0x0000 198 + #define AU1300_GPIC_PINVALCLR 0x0010 199 + #define AU1300_GPIC_IPEND 0x0020 200 + #define AU1300_GPIC_PRIENC 0x0030 201 + #define AU1300_GPIC_IEN 0x0040 /* int_mask in manual */ 202 + #define AU1300_GPIC_IDIS 0x0050 /* int_maskclr in manual */ 203 + #define AU1300_GPIC_DMASEL 0x0060 204 + #define AU1300_GPIC_DEVSEL 0x0080 205 + #define AU1300_GPIC_DEVCLR 0x0090 206 + #define AU1300_GPIC_RSTVAL 0x00a0 207 + /* pin configuration space. one 32bit register for up to 128 IRQs */ 208 + #define AU1300_GPIC_PINCFG 0x1000 209 + 210 + #define GPIC_GPIO_TO_BIT(gpio) \ 211 + (1 << ((gpio) & 0x1f)) 212 + 213 + #define GPIC_GPIO_BANKOFF(gpio) \ 214 + (((gpio) >> 5) * 4) 215 + 216 + /* Pin Control bits: who owns the pin, what does it do */ 217 + #define GPIC_CFG_PC_GPIN 0 218 + #define GPIC_CFG_PC_DEV 1 219 + #define GPIC_CFG_PC_GPOLOW 2 220 + #define GPIC_CFG_PC_GPOHIGH 3 221 + #define GPIC_CFG_PC_MASK 3 222 + 223 + /* assign pin to MIPS IRQ line */ 224 + #define GPIC_CFG_IL_SET(x) (((x) & 3) << 2) 225 + #define GPIC_CFG_IL_MASK (3 << 2) 226 + 227 + /* pin interrupt type setup */ 228 + #define GPIC_CFG_IC_OFF (0 << 4) 229 + #define GPIC_CFG_IC_LEVEL_LOW (1 << 4) 230 + #define GPIC_CFG_IC_LEVEL_HIGH (2 << 4) 231 + #define GPIC_CFG_IC_EDGE_FALL (5 << 4) 232 + #define GPIC_CFG_IC_EDGE_RISE (6 << 4) 233 + #define GPIC_CFG_IC_EDGE_BOTH (7 << 4) 234 + #define GPIC_CFG_IC_MASK (7 << 4) 235 + 236 + /* allow interrupt to wake cpu from 'wait' */ 237 + #define GPIC_CFG_IDLEWAKE (1 << 7) 238 + 239 + /***********************************************************************/ 240 + 241 + /* Au1000 SDRAM memory controller register offsets */ 242 + #define AU1000_MEM_SDMODE0 0x0000 243 + #define AU1000_MEM_SDMODE1 0x0004 244 + #define AU1000_MEM_SDMODE2 0x0008 245 + #define AU1000_MEM_SDADDR0 0x000C 246 + #define AU1000_MEM_SDADDR1 0x0010 247 + #define AU1000_MEM_SDADDR2 0x0014 248 + #define AU1000_MEM_SDREFCFG 0x0018 249 + #define AU1000_MEM_SDPRECMD 0x001C 250 + #define AU1000_MEM_SDAUTOREF 0x0020 251 + #define AU1000_MEM_SDWRMD0 0x0024 252 + #define AU1000_MEM_SDWRMD1 0x0028 253 + #define AU1000_MEM_SDWRMD2 0x002C 254 + #define AU1000_MEM_SDSLEEP 0x0030 255 + #define AU1000_MEM_SDSMCKE 0x0034 256 + 257 + /* MEM_SDMODE register content definitions */ 258 + #define MEM_SDMODE_F (1 << 22) 259 + #define MEM_SDMODE_SR (1 << 21) 260 + #define MEM_SDMODE_BS (1 << 20) 261 + #define MEM_SDMODE_RS (3 << 18) 262 + #define MEM_SDMODE_CS (7 << 15) 263 + #define MEM_SDMODE_TRAS (15 << 11) 264 + #define MEM_SDMODE_TMRD (3 << 9) 265 + #define MEM_SDMODE_TWR (3 << 7) 266 + #define MEM_SDMODE_TRP (3 << 5) 267 + #define MEM_SDMODE_TRCD (3 << 3) 268 + #define MEM_SDMODE_TCL (7 << 0) 269 + 270 + #define MEM_SDMODE_BS_2Bank (0 << 20) 271 + #define MEM_SDMODE_BS_4Bank (1 << 20) 272 + #define MEM_SDMODE_RS_11Row (0 << 18) 273 + #define MEM_SDMODE_RS_12Row (1 << 18) 274 + #define MEM_SDMODE_RS_13Row (2 << 18) 275 + #define MEM_SDMODE_RS_N(N) ((N) << 18) 276 + #define MEM_SDMODE_CS_7Col (0 << 15) 277 + #define MEM_SDMODE_CS_8Col (1 << 15) 278 + #define MEM_SDMODE_CS_9Col (2 << 15) 279 + #define MEM_SDMODE_CS_10Col (3 << 15) 280 + #define MEM_SDMODE_CS_11Col (4 << 15) 281 + #define MEM_SDMODE_CS_N(N) ((N) << 15) 282 + #define MEM_SDMODE_TRAS_N(N) ((N) << 11) 283 + #define MEM_SDMODE_TMRD_N(N) ((N) << 9) 284 + #define MEM_SDMODE_TWR_N(N) ((N) << 7) 285 + #define MEM_SDMODE_TRP_N(N) ((N) << 5) 286 + #define MEM_SDMODE_TRCD_N(N) ((N) << 3) 287 + #define MEM_SDMODE_TCL_N(N) ((N) << 0) 288 + 289 + /* MEM_SDADDR register contents definitions */ 290 + #define MEM_SDADDR_E (1 << 20) 291 + #define MEM_SDADDR_CSBA (0x03FF << 10) 292 + #define MEM_SDADDR_CSMASK (0x03FF << 0) 293 + #define MEM_SDADDR_CSBA_N(N) ((N) & (0x03FF << 22) >> 12) 294 + #define MEM_SDADDR_CSMASK_N(N) ((N)&(0x03FF << 22) >> 22) 295 + 296 + /* MEM_SDREFCFG register content definitions */ 297 + #define MEM_SDREFCFG_TRC (15 << 28) 298 + #define MEM_SDREFCFG_TRPM (3 << 26) 299 + #define MEM_SDREFCFG_E (1 << 25) 300 + #define MEM_SDREFCFG_RE (0x1ffffff << 0) 301 + #define MEM_SDREFCFG_TRC_N(N) ((N) << MEM_SDREFCFG_TRC) 302 + #define MEM_SDREFCFG_TRPM_N(N) ((N) << MEM_SDREFCFG_TRPM) 303 + #define MEM_SDREFCFG_REF_N(N) (N) 304 + 305 + /* Au1550 SDRAM Register Offsets */ 306 + #define AU1550_MEM_SDMODE0 0x0800 307 + #define AU1550_MEM_SDMODE1 0x0808 308 + #define AU1550_MEM_SDMODE2 0x0810 309 + #define AU1550_MEM_SDADDR0 0x0820 310 + #define AU1550_MEM_SDADDR1 0x0828 311 + #define AU1550_MEM_SDADDR2 0x0830 312 + #define AU1550_MEM_SDCONFIGA 0x0840 313 + #define AU1550_MEM_SDCONFIGB 0x0848 314 + #define AU1550_MEM_SDSTAT 0x0850 315 + #define AU1550_MEM_SDERRADDR 0x0858 316 + #define AU1550_MEM_SDSTRIDE0 0x0860 317 + #define AU1550_MEM_SDSTRIDE1 0x0868 318 + #define AU1550_MEM_SDSTRIDE2 0x0870 319 + #define AU1550_MEM_SDWRMD0 0x0880 320 + #define AU1550_MEM_SDWRMD1 0x0888 321 + #define AU1550_MEM_SDWRMD2 0x0890 322 + #define AU1550_MEM_SDPRECMD 0x08C0 323 + #define AU1550_MEM_SDAUTOREF 0x08C8 324 + #define AU1550_MEM_SDSREF 0x08D0 325 + #define AU1550_MEM_SDSLEEP MEM_SDSREF 326 + 327 + /* Static Bus Controller register offsets */ 328 + #define AU1000_MEM_STCFG0 0x000 329 + #define AU1000_MEM_STTIME0 0x004 330 + #define AU1000_MEM_STADDR0 0x008 331 + #define AU1000_MEM_STCFG1 0x010 332 + #define AU1000_MEM_STTIME1 0x014 333 + #define AU1000_MEM_STADDR1 0x018 334 + #define AU1000_MEM_STCFG2 0x020 335 + #define AU1000_MEM_STTIME2 0x024 336 + #define AU1000_MEM_STADDR2 0x028 337 + #define AU1000_MEM_STCFG3 0x030 338 + #define AU1000_MEM_STTIME3 0x034 339 + #define AU1000_MEM_STADDR3 0x038 340 + #define AU1000_MEM_STNDCTL 0x100 341 + #define AU1000_MEM_STSTAT 0x104 342 + 343 + #define MEM_STNAND_CMD 0x0 344 + #define MEM_STNAND_ADDR 0x4 345 + #define MEM_STNAND_DATA 0x20 346 + 347 + 348 + /* Programmable Counters 0 and 1 */ 349 + #define AU1000_SYS_CNTRCTRL 0x14 350 + # define SYS_CNTRL_E1S (1 << 23) 351 + # define SYS_CNTRL_T1S (1 << 20) 352 + # define SYS_CNTRL_M21 (1 << 19) 353 + # define SYS_CNTRL_M11 (1 << 18) 354 + # define SYS_CNTRL_M01 (1 << 17) 355 + # define SYS_CNTRL_C1S (1 << 16) 356 + # define SYS_CNTRL_BP (1 << 14) 357 + # define SYS_CNTRL_EN1 (1 << 13) 358 + # define SYS_CNTRL_BT1 (1 << 12) 359 + # define SYS_CNTRL_EN0 (1 << 11) 360 + # define SYS_CNTRL_BT0 (1 << 10) 361 + # define SYS_CNTRL_E0 (1 << 8) 362 + # define SYS_CNTRL_E0S (1 << 7) 363 + # define SYS_CNTRL_32S (1 << 5) 364 + # define SYS_CNTRL_T0S (1 << 4) 365 + # define SYS_CNTRL_M20 (1 << 3) 366 + # define SYS_CNTRL_M10 (1 << 2) 367 + # define SYS_CNTRL_M00 (1 << 1) 368 + # define SYS_CNTRL_C0S (1 << 0) 369 + 370 + /* Programmable Counter 0 Registers */ 371 + #define AU1000_SYS_TOYTRIM 0x00 372 + #define AU1000_SYS_TOYWRITE 0x04 373 + #define AU1000_SYS_TOYMATCH0 0x08 374 + #define AU1000_SYS_TOYMATCH1 0x0c 375 + #define AU1000_SYS_TOYMATCH2 0x10 376 + #define AU1000_SYS_TOYREAD 0x40 377 + 378 + /* Programmable Counter 1 Registers */ 379 + #define AU1000_SYS_RTCTRIM 0x44 380 + #define AU1000_SYS_RTCWRITE 0x48 381 + #define AU1000_SYS_RTCMATCH0 0x4c 382 + #define AU1000_SYS_RTCMATCH1 0x50 383 + #define AU1000_SYS_RTCMATCH2 0x54 384 + #define AU1000_SYS_RTCREAD 0x58 385 + 386 + 387 + /* GPIO */ 388 + #define AU1000_SYS_PINFUNC 0x2C 389 + # define SYS_PF_USB (1 << 15) /* 2nd USB device/host */ 390 + # define SYS_PF_U3 (1 << 14) /* GPIO23/U3TXD */ 391 + # define SYS_PF_U2 (1 << 13) /* GPIO22/U2TXD */ 392 + # define SYS_PF_U1 (1 << 12) /* GPIO21/U1TXD */ 393 + # define SYS_PF_SRC (1 << 11) /* GPIO6/SROMCKE */ 394 + # define SYS_PF_CK5 (1 << 10) /* GPIO3/CLK5 */ 395 + # define SYS_PF_CK4 (1 << 9) /* GPIO2/CLK4 */ 396 + # define SYS_PF_IRF (1 << 8) /* GPIO15/IRFIRSEL */ 397 + # define SYS_PF_UR3 (1 << 7) /* GPIO[14:9]/UART3 */ 398 + # define SYS_PF_I2D (1 << 6) /* GPIO8/I2SDI */ 399 + # define SYS_PF_I2S (1 << 5) /* I2S/GPIO[29:31] */ 400 + # define SYS_PF_NI2 (1 << 4) /* NI2/GPIO[24:28] */ 401 + # define SYS_PF_U0 (1 << 3) /* U0TXD/GPIO20 */ 402 + # define SYS_PF_RD (1 << 2) /* IRTXD/GPIO19 */ 403 + # define SYS_PF_A97 (1 << 1) /* AC97/SSL1 */ 404 + # define SYS_PF_S0 (1 << 0) /* SSI_0/GPIO[16:18] */ 405 + 406 + /* Au1100 only */ 407 + # define SYS_PF_PC (1 << 18) /* PCMCIA/GPIO[207:204] */ 408 + # define SYS_PF_LCD (1 << 17) /* extern lcd/GPIO[203:200] */ 409 + # define SYS_PF_CS (1 << 16) /* EXTCLK0/32KHz to gpio2 */ 410 + # define SYS_PF_EX0 (1 << 9) /* GPIO2/clock */ 411 + 412 + /* Au1550 only. Redefines lots of pins */ 413 + # define SYS_PF_PSC2_MASK (7 << 17) 414 + # define SYS_PF_PSC2_AC97 0 415 + # define SYS_PF_PSC2_SPI 0 416 + # define SYS_PF_PSC2_I2S (1 << 17) 417 + # define SYS_PF_PSC2_SMBUS (3 << 17) 418 + # define SYS_PF_PSC2_GPIO (7 << 17) 419 + # define SYS_PF_PSC3_MASK (7 << 20) 420 + # define SYS_PF_PSC3_AC97 0 421 + # define SYS_PF_PSC3_SPI 0 422 + # define SYS_PF_PSC3_I2S (1 << 20) 423 + # define SYS_PF_PSC3_SMBUS (3 << 20) 424 + # define SYS_PF_PSC3_GPIO (7 << 20) 425 + # define SYS_PF_PSC1_S1 (1 << 1) 426 + # define SYS_PF_MUST_BE_SET ((1 << 5) | (1 << 2)) 427 + 428 + /* Au1200 only */ 429 + #define SYS_PINFUNC_DMA (1 << 31) 430 + #define SYS_PINFUNC_S0A (1 << 30) 431 + #define SYS_PINFUNC_S1A (1 << 29) 432 + #define SYS_PINFUNC_LP0 (1 << 28) 433 + #define SYS_PINFUNC_LP1 (1 << 27) 434 + #define SYS_PINFUNC_LD16 (1 << 26) 435 + #define SYS_PINFUNC_LD8 (1 << 25) 436 + #define SYS_PINFUNC_LD1 (1 << 24) 437 + #define SYS_PINFUNC_LD0 (1 << 23) 438 + #define SYS_PINFUNC_P1A (3 << 21) 439 + #define SYS_PINFUNC_P1B (1 << 20) 440 + #define SYS_PINFUNC_FS3 (1 << 19) 441 + #define SYS_PINFUNC_P0A (3 << 17) 442 + #define SYS_PINFUNC_CS (1 << 16) 443 + #define SYS_PINFUNC_CIM (1 << 15) 444 + #define SYS_PINFUNC_P1C (1 << 14) 445 + #define SYS_PINFUNC_U1T (1 << 12) 446 + #define SYS_PINFUNC_U1R (1 << 11) 447 + #define SYS_PINFUNC_EX1 (1 << 10) 448 + #define SYS_PINFUNC_EX0 (1 << 9) 449 + #define SYS_PINFUNC_U0R (1 << 8) 450 + #define SYS_PINFUNC_MC (1 << 7) 451 + #define SYS_PINFUNC_S0B (1 << 6) 452 + #define SYS_PINFUNC_S0C (1 << 5) 453 + #define SYS_PINFUNC_P0B (1 << 4) 454 + #define SYS_PINFUNC_U0T (1 << 3) 455 + #define SYS_PINFUNC_S1B (1 << 2) 456 + 457 + /* Power Management */ 458 + #define AU1000_SYS_SCRATCH0 0x18 459 + #define AU1000_SYS_SCRATCH1 0x1c 460 + #define AU1000_SYS_WAKEMSK 0x34 461 + #define AU1000_SYS_ENDIAN 0x38 462 + #define AU1000_SYS_POWERCTRL 0x3c 463 + #define AU1000_SYS_WAKESRC 0x5c 464 + #define AU1000_SYS_SLPPWR 0x78 465 + #define AU1000_SYS_SLEEP 0x7c 466 + 467 + #define SYS_WAKEMSK_D2 (1 << 9) 468 + #define SYS_WAKEMSK_M2 (1 << 8) 469 + #define SYS_WAKEMSK_GPIO(x) (1 << (x)) 470 + 471 + /* Clock Controller */ 472 + #define AU1000_SYS_FREQCTRL0 0x20 473 + #define AU1000_SYS_FREQCTRL1 0x24 474 + #define AU1000_SYS_CLKSRC 0x28 475 + #define AU1000_SYS_CPUPLL 0x60 476 + #define AU1000_SYS_AUXPLL 0x64 477 + #define AU1300_SYS_AUXPLL2 0x68 478 + 479 + 480 + /**********************************************************************/ 481 + 482 + 483 + /* The PCI chip selects are outside the 32bit space, and since we can't 484 + * just program the 36bit addresses into BARs, we have to take a chunk 485 + * out of the 32bit space and reserve it for PCI. When these addresses 486 + * are ioremap()ed, they'll be fixed up to the real 36bit address before 487 + * being passed to the real ioremap function. 488 + */ 489 + #define ALCHEMY_PCI_MEMWIN_START (AU1500_PCI_MEM_PHYS_ADDR >> 4) 490 + #define ALCHEMY_PCI_MEMWIN_END (ALCHEMY_PCI_MEMWIN_START + 0x0FFFFFFF) 491 + 492 + /* for PCI IO it's simpler because we get to do the ioremap ourselves and then 493 + * adjust the device's resources. 494 + */ 495 + #define ALCHEMY_PCI_IOWIN_START 0x00001000 496 + #define ALCHEMY_PCI_IOWIN_END 0x0000FFFF 497 + 498 + #ifdef CONFIG_PCI 499 + 500 + #define IOPORT_RESOURCE_START 0x00001000 /* skip legacy probing */ 501 + #define IOPORT_RESOURCE_END 0xffffffff 502 + #define IOMEM_RESOURCE_START 0x10000000 503 + #define IOMEM_RESOURCE_END 0xfffffffffULL 504 + 505 + #else 506 + 507 + /* Don't allow any legacy ports probing */ 508 + #define IOPORT_RESOURCE_START 0x10000000 509 + #define IOPORT_RESOURCE_END 0xffffffff 510 + #define IOMEM_RESOURCE_START 0x10000000 511 + #define IOMEM_RESOURCE_END 0xfffffffffULL 512 + 513 + #endif 514 + 515 + /* PCI controller block register offsets */ 516 + #define PCI_REG_CMEM 0x0000 517 + #define PCI_REG_CONFIG 0x0004 518 + #define PCI_REG_B2BMASK_CCH 0x0008 519 + #define PCI_REG_B2BBASE0_VID 0x000C 520 + #define PCI_REG_B2BBASE1_SID 0x0010 521 + #define PCI_REG_MWMASK_DEV 0x0014 522 + #define PCI_REG_MWBASE_REV_CCL 0x0018 523 + #define PCI_REG_ERR_ADDR 0x001C 524 + #define PCI_REG_SPEC_INTACK 0x0020 525 + #define PCI_REG_ID 0x0100 526 + #define PCI_REG_STATCMD 0x0104 527 + #define PCI_REG_CLASSREV 0x0108 528 + #define PCI_REG_PARAM 0x010C 529 + #define PCI_REG_MBAR 0x0110 530 + #define PCI_REG_TIMEOUT 0x0140 531 + 532 + /* PCI controller block register bits */ 533 + #define PCI_CMEM_E (1 << 28) /* enable cacheable memory */ 534 + #define PCI_CMEM_CMBASE(x) (((x) & 0x3fff) << 14) 535 + #define PCI_CMEM_CMMASK(x) ((x) & 0x3fff) 536 + #define PCI_CONFIG_ERD (1 << 27) /* pci error during R/W */ 537 + #define PCI_CONFIG_ET (1 << 26) /* error in target mode */ 538 + #define PCI_CONFIG_EF (1 << 25) /* fatal error */ 539 + #define PCI_CONFIG_EP (1 << 24) /* parity error */ 540 + #define PCI_CONFIG_EM (1 << 23) /* multiple errors */ 541 + #define PCI_CONFIG_BM (1 << 22) /* bad master error */ 542 + #define PCI_CONFIG_PD (1 << 20) /* PCI Disable */ 543 + #define PCI_CONFIG_BME (1 << 19) /* Byte Mask Enable for reads */ 544 + #define PCI_CONFIG_NC (1 << 16) /* mark mem access non-coherent */ 545 + #define PCI_CONFIG_IA (1 << 15) /* INTA# enabled (target mode) */ 546 + #define PCI_CONFIG_IP (1 << 13) /* int on PCI_PERR# */ 547 + #define PCI_CONFIG_IS (1 << 12) /* int on PCI_SERR# */ 548 + #define PCI_CONFIG_IMM (1 << 11) /* int on master abort */ 549 + #define PCI_CONFIG_ITM (1 << 10) /* int on target abort (as master) */ 550 + #define PCI_CONFIG_ITT (1 << 9) /* int on target abort (as target) */ 551 + #define PCI_CONFIG_IPB (1 << 8) /* int on PERR# in bus master acc */ 552 + #define PCI_CONFIG_SIC_NO (0 << 6) /* no byte mask changes */ 553 + #define PCI_CONFIG_SIC_BA_ADR (1 << 6) /* on byte/hw acc, invert adr bits */ 554 + #define PCI_CONFIG_SIC_HWA_DAT (2 << 6) /* on halfword acc, swap data */ 555 + #define PCI_CONFIG_SIC_ALL (3 << 6) /* swap data bytes on all accesses */ 556 + #define PCI_CONFIG_ST (1 << 5) /* swap data by target transactions */ 557 + #define PCI_CONFIG_SM (1 << 4) /* swap data from PCI ctl */ 558 + #define PCI_CONFIG_AEN (1 << 3) /* enable internal arbiter */ 559 + #define PCI_CONFIG_R2H (1 << 2) /* REQ2# to hi-prio arbiter */ 560 + #define PCI_CONFIG_R1H (1 << 1) /* REQ1# to hi-prio arbiter */ 561 + #define PCI_CONFIG_CH (1 << 0) /* PCI ctl to hi-prio arbiter */ 562 + #define PCI_B2BMASK_B2BMASK(x) (((x) & 0xffff) << 16) 563 + #define PCI_B2BMASK_CCH(x) ((x) & 0xffff) /* 16 upper bits of class code */ 564 + #define PCI_B2BBASE0_VID_B0(x) (((x) & 0xffff) << 16) 565 + #define PCI_B2BBASE0_VID_SV(x) ((x) & 0xffff) 566 + #define PCI_B2BBASE1_SID_B1(x) (((x) & 0xffff) << 16) 567 + #define PCI_B2BBASE1_SID_SI(x) ((x) & 0xffff) 568 + #define PCI_MWMASKDEV_MWMASK(x) (((x) & 0xffff) << 16) 569 + #define PCI_MWMASKDEV_DEVID(x) ((x) & 0xffff) 570 + #define PCI_MWBASEREVCCL_BASE(x) (((x) & 0xffff) << 16) 571 + #define PCI_MWBASEREVCCL_REV(x) (((x) & 0xff) << 8) 572 + #define PCI_MWBASEREVCCL_CCL(x) ((x) & 0xff) 573 + #define PCI_ID_DID(x) (((x) & 0xffff) << 16) 574 + #define PCI_ID_VID(x) ((x) & 0xffff) 575 + #define PCI_STATCMD_STATUS(x) (((x) & 0xffff) << 16) 576 + #define PCI_STATCMD_CMD(x) ((x) & 0xffff) 577 + #define PCI_CLASSREV_CLASS(x) (((x) & 0x00ffffff) << 8) 578 + #define PCI_CLASSREV_REV(x) ((x) & 0xff) 579 + #define PCI_PARAM_BIST(x) (((x) & 0xff) << 24) 580 + #define PCI_PARAM_HT(x) (((x) & 0xff) << 16) 581 + #define PCI_PARAM_LT(x) (((x) & 0xff) << 8) 582 + #define PCI_PARAM_CLS(x) ((x) & 0xff) 583 + #define PCI_TIMEOUT_RETRIES(x) (((x) & 0xff) << 8) /* max retries */ 584 + #define PCI_TIMEOUT_TO(x) ((x) & 0xff) /* target ready timeout */ 585 + 586 + 587 + /**********************************************************************/ 588 + 37 589 38 590 #ifndef _LANGUAGE_ASSEMBLY 39 591 ··· 597 45 598 46 #include <asm/cpu.h> 599 47 600 - /* cpu pipeline flush */ 601 - void static inline au_sync(void) 48 + /* helpers to access the SYS_* registers */ 49 + static inline unsigned long alchemy_rdsys(int regofs) 602 50 { 603 - __asm__ volatile ("sync"); 51 + void __iomem *b = (void __iomem *)KSEG1ADDR(AU1000_SYS_PHYS_ADDR); 52 + 53 + return __raw_readl(b + regofs); 604 54 } 605 55 606 - void static inline au_sync_udelay(int us) 56 + static inline void alchemy_wrsys(unsigned long v, int regofs) 607 57 { 608 - __asm__ volatile ("sync"); 609 - udelay(us); 58 + void __iomem *b = (void __iomem *)KSEG1ADDR(AU1000_SYS_PHYS_ADDR); 59 + 60 + __raw_writel(v, b + regofs); 61 + wmb(); /* drain writebuffer */ 610 62 } 611 63 612 - void static inline au_sync_delay(int ms) 64 + /* helpers to access static memctrl registers */ 65 + static inline unsigned long alchemy_rdsmem(int regofs) 613 66 { 614 - __asm__ volatile ("sync"); 615 - mdelay(ms); 67 + void __iomem *b = (void __iomem *)KSEG1ADDR(AU1000_STATIC_MEM_PHYS_ADDR); 68 + 69 + return __raw_readl(b + regofs); 616 70 } 617 71 618 - void static inline au_writeb(u8 val, unsigned long reg) 72 + static inline void alchemy_wrsmem(unsigned long v, int regofs) 619 73 { 620 - *(volatile u8 *)reg = val; 621 - } 74 + void __iomem *b = (void __iomem *)KSEG1ADDR(AU1000_STATIC_MEM_PHYS_ADDR); 622 75 623 - void static inline au_writew(u16 val, unsigned long reg) 624 - { 625 - *(volatile u16 *)reg = val; 626 - } 627 - 628 - void static inline au_writel(u32 val, unsigned long reg) 629 - { 630 - *(volatile u32 *)reg = val; 631 - } 632 - 633 - static inline u8 au_readb(unsigned long reg) 634 - { 635 - return *(volatile u8 *)reg; 636 - } 637 - 638 - static inline u16 au_readw(unsigned long reg) 639 - { 640 - return *(volatile u16 *)reg; 641 - } 642 - 643 - static inline u32 au_readl(unsigned long reg) 644 - { 645 - return *(volatile u32 *)reg; 76 + __raw_writel(v, b + regofs); 77 + wmb(); /* drain writebuffer */ 646 78 } 647 79 648 80 /* Early Au1000 have a write-only SYS_CPUPLL register. */ ··· 728 192 /* reset, enable clock, deassert reset */ 729 193 if ((__raw_readl(addr + 0x100) & 3) != 3) { 730 194 __raw_writel(0, addr + 0x100); 731 - wmb(); 195 + wmb(); /* drain writebuffer */ 732 196 __raw_writel(1, addr + 0x100); 733 - wmb(); 197 + wmb(); /* drain writebuffer */ 734 198 } 735 199 __raw_writel(3, addr + 0x100); 736 - wmb(); 200 + wmb(); /* drain writebuffer */ 737 201 } 738 202 739 203 static inline void alchemy_uart_disable(u32 uart_phys) 740 204 { 741 205 void __iomem *addr = (void __iomem *)KSEG1ADDR(uart_phys); 206 + 742 207 __raw_writel(0, addr + 0x100); /* UART_MOD_CNTRL */ 743 - wmb(); 208 + wmb(); /* drain writebuffer */ 744 209 } 745 210 746 211 static inline void alchemy_uart_putchar(u32 uart_phys, u8 c) ··· 760 223 } while (--timeout); 761 224 762 225 __raw_writel(c, base + 0x04); /* tx */ 763 - wmb(); 226 + wmb(); /* drain writebuffer */ 764 227 } 765 228 766 229 /* return number of ethernet MACs on a given cputype */ ··· 777 240 return 0; 778 241 } 779 242 780 - /* arch/mips/au1000/common/clocks.c */ 781 - extern void set_au1x00_speed(unsigned int new_freq); 782 - extern unsigned int get_au1x00_speed(void); 783 - extern void set_au1x00_uart_baud_base(unsigned long new_baud_base); 784 - extern unsigned long get_au1x00_uart_baud_base(void); 785 - extern unsigned long au1xxx_calc_clock(void); 786 - 787 243 /* PM: arch/mips/alchemy/common/sleeper.S, power.c, irq.c */ 788 244 void alchemy_sleep_au1000(void); 789 245 void alchemy_sleep_au1550(void); 790 246 void alchemy_sleep_au1300(void); 791 247 void au_sleep(void); 792 248 793 - /* USB: drivers/usb/host/alchemy-common.c */ 249 + /* USB: arch/mips/alchemy/common/usb.c */ 794 250 enum alchemy_usb_block { 795 251 ALCHEMY_USB_OHCI0, 796 252 ALCHEMY_USB_UDC0, ··· 801 271 unsigned long pci_cfg_set; 802 272 unsigned long pci_cfg_clr; 803 273 }; 274 + 275 + /* The IrDA peripheral has an IRFIRSEL pin, but on the DB/PB boards it's 276 + * not used to select FIR/SIR mode on the transceiver but as a GPIO. 277 + * Instead a CPLD has to be told about the mode. The driver calls the 278 + * set_phy_mode() function in addition to driving the IRFIRSEL pin. 279 + */ 280 + #define AU1000_IRDA_PHY_MODE_OFF 0 281 + #define AU1000_IRDA_PHY_MODE_SIR 1 282 + #define AU1000_IRDA_PHY_MODE_FIR 2 283 + 284 + struct au1k_irda_platform_data { 285 + void (*set_phy_mode)(int mode); 286 + }; 287 + 804 288 805 289 /* Multifunction pins: Each of these pins can either be assigned to the 806 290 * GPIO controller or a on-chip peripheral. ··· 887 343 }; 888 344 889 345 extern void au1300_vss_block_control(int block, int enable); 890 - 891 - 892 - /* SOC Interrupt numbers */ 893 - /* Au1000-style (IC0/1): 2 controllers with 32 sources each */ 894 - #define AU1000_INTC0_INT_BASE (MIPS_CPU_IRQ_BASE + 8) 895 - #define AU1000_INTC0_INT_LAST (AU1000_INTC0_INT_BASE + 31) 896 - #define AU1000_INTC1_INT_BASE (AU1000_INTC0_INT_LAST + 1) 897 - #define AU1000_INTC1_INT_LAST (AU1000_INTC1_INT_BASE + 31) 898 - #define AU1000_MAX_INTR AU1000_INTC1_INT_LAST 899 - 900 - /* Au1300-style (GPIC): 1 controller with up to 128 sources */ 901 - #define ALCHEMY_GPIC_INT_BASE (MIPS_CPU_IRQ_BASE + 8) 902 - #define ALCHEMY_GPIC_INT_NUM 128 903 - #define ALCHEMY_GPIC_INT_LAST (ALCHEMY_GPIC_INT_BASE + ALCHEMY_GPIC_INT_NUM - 1) 904 346 905 347 enum soc_au1000_ints { 906 348 AU1000_FIRST_INT = AU1000_INTC0_INT_BASE, ··· 1207 677 }; 1208 678 1209 679 #endif /* !defined (_LANGUAGE_ASSEMBLY) */ 1210 - 1211 - /* Au1300 peripheral interrupt numbers */ 1212 - #define AU1300_FIRST_INT (ALCHEMY_GPIC_INT_BASE) 1213 - #define AU1300_UART1_INT (AU1300_FIRST_INT + 17) 1214 - #define AU1300_UART2_INT (AU1300_FIRST_INT + 25) 1215 - #define AU1300_UART3_INT (AU1300_FIRST_INT + 27) 1216 - #define AU1300_SD1_INT (AU1300_FIRST_INT + 32) 1217 - #define AU1300_SD2_INT (AU1300_FIRST_INT + 38) 1218 - #define AU1300_PSC0_INT (AU1300_FIRST_INT + 48) 1219 - #define AU1300_PSC1_INT (AU1300_FIRST_INT + 52) 1220 - #define AU1300_PSC2_INT (AU1300_FIRST_INT + 56) 1221 - #define AU1300_PSC3_INT (AU1300_FIRST_INT + 60) 1222 - #define AU1300_NAND_INT (AU1300_FIRST_INT + 62) 1223 - #define AU1300_DDMA_INT (AU1300_FIRST_INT + 75) 1224 - #define AU1300_MMU_INT (AU1300_FIRST_INT + 76) 1225 - #define AU1300_MPU_INT (AU1300_FIRST_INT + 77) 1226 - #define AU1300_GPU_INT (AU1300_FIRST_INT + 78) 1227 - #define AU1300_UDMA_INT (AU1300_FIRST_INT + 79) 1228 - #define AU1300_TOY_INT (AU1300_FIRST_INT + 80) 1229 - #define AU1300_TOY_MATCH0_INT (AU1300_FIRST_INT + 81) 1230 - #define AU1300_TOY_MATCH1_INT (AU1300_FIRST_INT + 82) 1231 - #define AU1300_TOY_MATCH2_INT (AU1300_FIRST_INT + 83) 1232 - #define AU1300_RTC_INT (AU1300_FIRST_INT + 84) 1233 - #define AU1300_RTC_MATCH0_INT (AU1300_FIRST_INT + 85) 1234 - #define AU1300_RTC_MATCH1_INT (AU1300_FIRST_INT + 86) 1235 - #define AU1300_RTC_MATCH2_INT (AU1300_FIRST_INT + 87) 1236 - #define AU1300_UART0_INT (AU1300_FIRST_INT + 88) 1237 - #define AU1300_SD0_INT (AU1300_FIRST_INT + 89) 1238 - #define AU1300_USB_INT (AU1300_FIRST_INT + 90) 1239 - #define AU1300_LCD_INT (AU1300_FIRST_INT + 91) 1240 - #define AU1300_BSA_INT (AU1300_FIRST_INT + 92) 1241 - #define AU1300_MPE_INT (AU1300_FIRST_INT + 93) 1242 - #define AU1300_ITE_INT (AU1300_FIRST_INT + 94) 1243 - #define AU1300_AES_INT (AU1300_FIRST_INT + 95) 1244 - #define AU1300_CIM_INT (AU1300_FIRST_INT + 96) 1245 - 1246 - /**********************************************************************/ 1247 - 1248 - /* 1249 - * Physical base addresses for integrated peripherals 1250 - * 0..au1000 1..au1500 2..au1100 3..au1550 4..au1200 5..au1300 1251 - */ 1252 - 1253 - #define AU1000_AC97_PHYS_ADDR 0x10000000 /* 012 */ 1254 - #define AU1300_ROM_PHYS_ADDR 0x10000000 /* 5 */ 1255 - #define AU1300_OTP_PHYS_ADDR 0x10002000 /* 5 */ 1256 - #define AU1300_VSS_PHYS_ADDR 0x10003000 /* 5 */ 1257 - #define AU1300_UART0_PHYS_ADDR 0x10100000 /* 5 */ 1258 - #define AU1300_UART1_PHYS_ADDR 0x10101000 /* 5 */ 1259 - #define AU1300_UART2_PHYS_ADDR 0x10102000 /* 5 */ 1260 - #define AU1300_UART3_PHYS_ADDR 0x10103000 /* 5 */ 1261 - #define AU1000_USB_OHCI_PHYS_ADDR 0x10100000 /* 012 */ 1262 - #define AU1000_USB_UDC_PHYS_ADDR 0x10200000 /* 0123 */ 1263 - #define AU1300_GPIC_PHYS_ADDR 0x10200000 /* 5 */ 1264 - #define AU1000_IRDA_PHYS_ADDR 0x10300000 /* 02 */ 1265 - #define AU1200_AES_PHYS_ADDR 0x10300000 /* 45 */ 1266 - #define AU1000_IC0_PHYS_ADDR 0x10400000 /* 01234 */ 1267 - #define AU1300_GPU_PHYS_ADDR 0x10500000 /* 5 */ 1268 - #define AU1000_MAC0_PHYS_ADDR 0x10500000 /* 023 */ 1269 - #define AU1000_MAC1_PHYS_ADDR 0x10510000 /* 023 */ 1270 - #define AU1000_MACEN_PHYS_ADDR 0x10520000 /* 023 */ 1271 - #define AU1100_SD0_PHYS_ADDR 0x10600000 /* 245 */ 1272 - #define AU1300_SD1_PHYS_ADDR 0x10601000 /* 5 */ 1273 - #define AU1300_SD2_PHYS_ADDR 0x10602000 /* 5 */ 1274 - #define AU1100_SD1_PHYS_ADDR 0x10680000 /* 24 */ 1275 - #define AU1300_SYS_PHYS_ADDR 0x10900000 /* 5 */ 1276 - #define AU1550_PSC2_PHYS_ADDR 0x10A00000 /* 3 */ 1277 - #define AU1550_PSC3_PHYS_ADDR 0x10B00000 /* 3 */ 1278 - #define AU1300_PSC0_PHYS_ADDR 0x10A00000 /* 5 */ 1279 - #define AU1300_PSC1_PHYS_ADDR 0x10A01000 /* 5 */ 1280 - #define AU1300_PSC2_PHYS_ADDR 0x10A02000 /* 5 */ 1281 - #define AU1300_PSC3_PHYS_ADDR 0x10A03000 /* 5 */ 1282 - #define AU1000_I2S_PHYS_ADDR 0x11000000 /* 02 */ 1283 - #define AU1500_MAC0_PHYS_ADDR 0x11500000 /* 1 */ 1284 - #define AU1500_MAC1_PHYS_ADDR 0x11510000 /* 1 */ 1285 - #define AU1500_MACEN_PHYS_ADDR 0x11520000 /* 1 */ 1286 - #define AU1000_UART0_PHYS_ADDR 0x11100000 /* 01234 */ 1287 - #define AU1200_SWCNT_PHYS_ADDR 0x1110010C /* 4 */ 1288 - #define AU1000_UART1_PHYS_ADDR 0x11200000 /* 0234 */ 1289 - #define AU1000_UART2_PHYS_ADDR 0x11300000 /* 0 */ 1290 - #define AU1000_UART3_PHYS_ADDR 0x11400000 /* 0123 */ 1291 - #define AU1000_SSI0_PHYS_ADDR 0x11600000 /* 02 */ 1292 - #define AU1000_SSI1_PHYS_ADDR 0x11680000 /* 02 */ 1293 - #define AU1500_GPIO2_PHYS_ADDR 0x11700000 /* 1234 */ 1294 - #define AU1000_IC1_PHYS_ADDR 0x11800000 /* 01234 */ 1295 - #define AU1000_SYS_PHYS_ADDR 0x11900000 /* 012345 */ 1296 - #define AU1550_PSC0_PHYS_ADDR 0x11A00000 /* 34 */ 1297 - #define AU1550_PSC1_PHYS_ADDR 0x11B00000 /* 34 */ 1298 - #define AU1000_MEM_PHYS_ADDR 0x14000000 /* 01234 */ 1299 - #define AU1000_STATIC_MEM_PHYS_ADDR 0x14001000 /* 01234 */ 1300 - #define AU1300_UDMA_PHYS_ADDR 0x14001800 /* 5 */ 1301 - #define AU1000_DMA_PHYS_ADDR 0x14002000 /* 012 */ 1302 - #define AU1550_DBDMA_PHYS_ADDR 0x14002000 /* 345 */ 1303 - #define AU1550_DBDMA_CONF_PHYS_ADDR 0x14003000 /* 345 */ 1304 - #define AU1000_MACDMA0_PHYS_ADDR 0x14004000 /* 0123 */ 1305 - #define AU1000_MACDMA1_PHYS_ADDR 0x14004200 /* 0123 */ 1306 - #define AU1200_CIM_PHYS_ADDR 0x14004000 /* 45 */ 1307 - #define AU1500_PCI_PHYS_ADDR 0x14005000 /* 13 */ 1308 - #define AU1550_PE_PHYS_ADDR 0x14008000 /* 3 */ 1309 - #define AU1200_MAEBE_PHYS_ADDR 0x14010000 /* 4 */ 1310 - #define AU1200_MAEFE_PHYS_ADDR 0x14012000 /* 4 */ 1311 - #define AU1300_MAEITE_PHYS_ADDR 0x14010000 /* 5 */ 1312 - #define AU1300_MAEMPE_PHYS_ADDR 0x14014000 /* 5 */ 1313 - #define AU1550_USB_OHCI_PHYS_ADDR 0x14020000 /* 3 */ 1314 - #define AU1200_USB_CTL_PHYS_ADDR 0x14020000 /* 4 */ 1315 - #define AU1200_USB_OTG_PHYS_ADDR 0x14020020 /* 4 */ 1316 - #define AU1200_USB_OHCI_PHYS_ADDR 0x14020100 /* 4 */ 1317 - #define AU1200_USB_EHCI_PHYS_ADDR 0x14020200 /* 4 */ 1318 - #define AU1200_USB_UDC_PHYS_ADDR 0x14022000 /* 4 */ 1319 - #define AU1300_USB_EHCI_PHYS_ADDR 0x14020000 /* 5 */ 1320 - #define AU1300_USB_OHCI0_PHYS_ADDR 0x14020400 /* 5 */ 1321 - #define AU1300_USB_OHCI1_PHYS_ADDR 0x14020800 /* 5 */ 1322 - #define AU1300_USB_CTL_PHYS_ADDR 0x14021000 /* 5 */ 1323 - #define AU1300_USB_OTG_PHYS_ADDR 0x14022000 /* 5 */ 1324 - #define AU1300_MAEBSA_PHYS_ADDR 0x14030000 /* 5 */ 1325 - #define AU1100_LCD_PHYS_ADDR 0x15000000 /* 2 */ 1326 - #define AU1200_LCD_PHYS_ADDR 0x15000000 /* 45 */ 1327 - #define AU1500_PCI_MEM_PHYS_ADDR 0x400000000ULL /* 13 */ 1328 - #define AU1500_PCI_IO_PHYS_ADDR 0x500000000ULL /* 13 */ 1329 - #define AU1500_PCI_CONFIG0_PHYS_ADDR 0x600000000ULL /* 13 */ 1330 - #define AU1500_PCI_CONFIG1_PHYS_ADDR 0x680000000ULL /* 13 */ 1331 - #define AU1000_PCMCIA_IO_PHYS_ADDR 0xF00000000ULL /* 012345 */ 1332 - #define AU1000_PCMCIA_ATTR_PHYS_ADDR 0xF40000000ULL /* 012345 */ 1333 - #define AU1000_PCMCIA_MEM_PHYS_ADDR 0xF80000000ULL /* 012345 */ 1334 - 1335 - /**********************************************************************/ 1336 - 1337 - 1338 - /* 1339 - * Au1300 GPIO+INT controller (GPIC) register offsets and bits 1340 - * Registers are 128bits (0x10 bytes), divided into 4 "banks". 1341 - */ 1342 - #define AU1300_GPIC_PINVAL 0x0000 1343 - #define AU1300_GPIC_PINVALCLR 0x0010 1344 - #define AU1300_GPIC_IPEND 0x0020 1345 - #define AU1300_GPIC_PRIENC 0x0030 1346 - #define AU1300_GPIC_IEN 0x0040 /* int_mask in manual */ 1347 - #define AU1300_GPIC_IDIS 0x0050 /* int_maskclr in manual */ 1348 - #define AU1300_GPIC_DMASEL 0x0060 1349 - #define AU1300_GPIC_DEVSEL 0x0080 1350 - #define AU1300_GPIC_DEVCLR 0x0090 1351 - #define AU1300_GPIC_RSTVAL 0x00a0 1352 - /* pin configuration space. one 32bit register for up to 128 IRQs */ 1353 - #define AU1300_GPIC_PINCFG 0x1000 1354 - 1355 - #define GPIC_GPIO_TO_BIT(gpio) \ 1356 - (1 << ((gpio) & 0x1f)) 1357 - 1358 - #define GPIC_GPIO_BANKOFF(gpio) \ 1359 - (((gpio) >> 5) * 4) 1360 - 1361 - /* Pin Control bits: who owns the pin, what does it do */ 1362 - #define GPIC_CFG_PC_GPIN 0 1363 - #define GPIC_CFG_PC_DEV 1 1364 - #define GPIC_CFG_PC_GPOLOW 2 1365 - #define GPIC_CFG_PC_GPOHIGH 3 1366 - #define GPIC_CFG_PC_MASK 3 1367 - 1368 - /* assign pin to MIPS IRQ line */ 1369 - #define GPIC_CFG_IL_SET(x) (((x) & 3) << 2) 1370 - #define GPIC_CFG_IL_MASK (3 << 2) 1371 - 1372 - /* pin interrupt type setup */ 1373 - #define GPIC_CFG_IC_OFF (0 << 4) 1374 - #define GPIC_CFG_IC_LEVEL_LOW (1 << 4) 1375 - #define GPIC_CFG_IC_LEVEL_HIGH (2 << 4) 1376 - #define GPIC_CFG_IC_EDGE_FALL (5 << 4) 1377 - #define GPIC_CFG_IC_EDGE_RISE (6 << 4) 1378 - #define GPIC_CFG_IC_EDGE_BOTH (7 << 4) 1379 - #define GPIC_CFG_IC_MASK (7 << 4) 1380 - 1381 - /* allow interrupt to wake cpu from 'wait' */ 1382 - #define GPIC_CFG_IDLEWAKE (1 << 7) 1383 - 1384 - /***********************************************************************/ 1385 - 1386 - /* Au1000 SDRAM memory controller register offsets */ 1387 - #define AU1000_MEM_SDMODE0 0x0000 1388 - #define AU1000_MEM_SDMODE1 0x0004 1389 - #define AU1000_MEM_SDMODE2 0x0008 1390 - #define AU1000_MEM_SDADDR0 0x000C 1391 - #define AU1000_MEM_SDADDR1 0x0010 1392 - #define AU1000_MEM_SDADDR2 0x0014 1393 - #define AU1000_MEM_SDREFCFG 0x0018 1394 - #define AU1000_MEM_SDPRECMD 0x001C 1395 - #define AU1000_MEM_SDAUTOREF 0x0020 1396 - #define AU1000_MEM_SDWRMD0 0x0024 1397 - #define AU1000_MEM_SDWRMD1 0x0028 1398 - #define AU1000_MEM_SDWRMD2 0x002C 1399 - #define AU1000_MEM_SDSLEEP 0x0030 1400 - #define AU1000_MEM_SDSMCKE 0x0034 1401 - 1402 - /* MEM_SDMODE register content definitions */ 1403 - #define MEM_SDMODE_F (1 << 22) 1404 - #define MEM_SDMODE_SR (1 << 21) 1405 - #define MEM_SDMODE_BS (1 << 20) 1406 - #define MEM_SDMODE_RS (3 << 18) 1407 - #define MEM_SDMODE_CS (7 << 15) 1408 - #define MEM_SDMODE_TRAS (15 << 11) 1409 - #define MEM_SDMODE_TMRD (3 << 9) 1410 - #define MEM_SDMODE_TWR (3 << 7) 1411 - #define MEM_SDMODE_TRP (3 << 5) 1412 - #define MEM_SDMODE_TRCD (3 << 3) 1413 - #define MEM_SDMODE_TCL (7 << 0) 1414 - 1415 - #define MEM_SDMODE_BS_2Bank (0 << 20) 1416 - #define MEM_SDMODE_BS_4Bank (1 << 20) 1417 - #define MEM_SDMODE_RS_11Row (0 << 18) 1418 - #define MEM_SDMODE_RS_12Row (1 << 18) 1419 - #define MEM_SDMODE_RS_13Row (2 << 18) 1420 - #define MEM_SDMODE_RS_N(N) ((N) << 18) 1421 - #define MEM_SDMODE_CS_7Col (0 << 15) 1422 - #define MEM_SDMODE_CS_8Col (1 << 15) 1423 - #define MEM_SDMODE_CS_9Col (2 << 15) 1424 - #define MEM_SDMODE_CS_10Col (3 << 15) 1425 - #define MEM_SDMODE_CS_11Col (4 << 15) 1426 - #define MEM_SDMODE_CS_N(N) ((N) << 15) 1427 - #define MEM_SDMODE_TRAS_N(N) ((N) << 11) 1428 - #define MEM_SDMODE_TMRD_N(N) ((N) << 9) 1429 - #define MEM_SDMODE_TWR_N(N) ((N) << 7) 1430 - #define MEM_SDMODE_TRP_N(N) ((N) << 5) 1431 - #define MEM_SDMODE_TRCD_N(N) ((N) << 3) 1432 - #define MEM_SDMODE_TCL_N(N) ((N) << 0) 1433 - 1434 - /* MEM_SDADDR register contents definitions */ 1435 - #define MEM_SDADDR_E (1 << 20) 1436 - #define MEM_SDADDR_CSBA (0x03FF << 10) 1437 - #define MEM_SDADDR_CSMASK (0x03FF << 0) 1438 - #define MEM_SDADDR_CSBA_N(N) ((N) & (0x03FF << 22) >> 12) 1439 - #define MEM_SDADDR_CSMASK_N(N) ((N)&(0x03FF << 22) >> 22) 1440 - 1441 - /* MEM_SDREFCFG register content definitions */ 1442 - #define MEM_SDREFCFG_TRC (15 << 28) 1443 - #define MEM_SDREFCFG_TRPM (3 << 26) 1444 - #define MEM_SDREFCFG_E (1 << 25) 1445 - #define MEM_SDREFCFG_RE (0x1ffffff << 0) 1446 - #define MEM_SDREFCFG_TRC_N(N) ((N) << MEM_SDREFCFG_TRC) 1447 - #define MEM_SDREFCFG_TRPM_N(N) ((N) << MEM_SDREFCFG_TRPM) 1448 - #define MEM_SDREFCFG_REF_N(N) (N) 1449 - 1450 - /* Au1550 SDRAM Register Offsets */ 1451 - #define AU1550_MEM_SDMODE0 0x0800 1452 - #define AU1550_MEM_SDMODE1 0x0808 1453 - #define AU1550_MEM_SDMODE2 0x0810 1454 - #define AU1550_MEM_SDADDR0 0x0820 1455 - #define AU1550_MEM_SDADDR1 0x0828 1456 - #define AU1550_MEM_SDADDR2 0x0830 1457 - #define AU1550_MEM_SDCONFIGA 0x0840 1458 - #define AU1550_MEM_SDCONFIGB 0x0848 1459 - #define AU1550_MEM_SDSTAT 0x0850 1460 - #define AU1550_MEM_SDERRADDR 0x0858 1461 - #define AU1550_MEM_SDSTRIDE0 0x0860 1462 - #define AU1550_MEM_SDSTRIDE1 0x0868 1463 - #define AU1550_MEM_SDSTRIDE2 0x0870 1464 - #define AU1550_MEM_SDWRMD0 0x0880 1465 - #define AU1550_MEM_SDWRMD1 0x0888 1466 - #define AU1550_MEM_SDWRMD2 0x0890 1467 - #define AU1550_MEM_SDPRECMD 0x08C0 1468 - #define AU1550_MEM_SDAUTOREF 0x08C8 1469 - #define AU1550_MEM_SDSREF 0x08D0 1470 - #define AU1550_MEM_SDSLEEP MEM_SDSREF 1471 - 1472 - /* Static Bus Controller */ 1473 - #define MEM_STCFG0 0xB4001000 1474 - #define MEM_STTIME0 0xB4001004 1475 - #define MEM_STADDR0 0xB4001008 1476 - 1477 - #define MEM_STCFG1 0xB4001010 1478 - #define MEM_STTIME1 0xB4001014 1479 - #define MEM_STADDR1 0xB4001018 1480 - 1481 - #define MEM_STCFG2 0xB4001020 1482 - #define MEM_STTIME2 0xB4001024 1483 - #define MEM_STADDR2 0xB4001028 1484 - 1485 - #define MEM_STCFG3 0xB4001030 1486 - #define MEM_STTIME3 0xB4001034 1487 - #define MEM_STADDR3 0xB4001038 1488 - 1489 - #define MEM_STNDCTL 0xB4001100 1490 - #define MEM_STSTAT 0xB4001104 1491 - 1492 - #define MEM_STNAND_CMD 0x0 1493 - #define MEM_STNAND_ADDR 0x4 1494 - #define MEM_STNAND_DATA 0x20 1495 - 1496 - 1497 - /* Programmable Counters 0 and 1 */ 1498 - #define SYS_BASE 0xB1900000 1499 - #define SYS_COUNTER_CNTRL (SYS_BASE + 0x14) 1500 - # define SYS_CNTRL_E1S (1 << 23) 1501 - # define SYS_CNTRL_T1S (1 << 20) 1502 - # define SYS_CNTRL_M21 (1 << 19) 1503 - # define SYS_CNTRL_M11 (1 << 18) 1504 - # define SYS_CNTRL_M01 (1 << 17) 1505 - # define SYS_CNTRL_C1S (1 << 16) 1506 - # define SYS_CNTRL_BP (1 << 14) 1507 - # define SYS_CNTRL_EN1 (1 << 13) 1508 - # define SYS_CNTRL_BT1 (1 << 12) 1509 - # define SYS_CNTRL_EN0 (1 << 11) 1510 - # define SYS_CNTRL_BT0 (1 << 10) 1511 - # define SYS_CNTRL_E0 (1 << 8) 1512 - # define SYS_CNTRL_E0S (1 << 7) 1513 - # define SYS_CNTRL_32S (1 << 5) 1514 - # define SYS_CNTRL_T0S (1 << 4) 1515 - # define SYS_CNTRL_M20 (1 << 3) 1516 - # define SYS_CNTRL_M10 (1 << 2) 1517 - # define SYS_CNTRL_M00 (1 << 1) 1518 - # define SYS_CNTRL_C0S (1 << 0) 1519 - 1520 - /* Programmable Counter 0 Registers */ 1521 - #define SYS_TOYTRIM (SYS_BASE + 0) 1522 - #define SYS_TOYWRITE (SYS_BASE + 4) 1523 - #define SYS_TOYMATCH0 (SYS_BASE + 8) 1524 - #define SYS_TOYMATCH1 (SYS_BASE + 0xC) 1525 - #define SYS_TOYMATCH2 (SYS_BASE + 0x10) 1526 - #define SYS_TOYREAD (SYS_BASE + 0x40) 1527 - 1528 - /* Programmable Counter 1 Registers */ 1529 - #define SYS_RTCTRIM (SYS_BASE + 0x44) 1530 - #define SYS_RTCWRITE (SYS_BASE + 0x48) 1531 - #define SYS_RTCMATCH0 (SYS_BASE + 0x4C) 1532 - #define SYS_RTCMATCH1 (SYS_BASE + 0x50) 1533 - #define SYS_RTCMATCH2 (SYS_BASE + 0x54) 1534 - #define SYS_RTCREAD (SYS_BASE + 0x58) 1535 - 1536 - /* I2S Controller */ 1537 - #define I2S_DATA 0xB1000000 1538 - # define I2S_DATA_MASK 0xffffff 1539 - #define I2S_CONFIG 0xB1000004 1540 - # define I2S_CONFIG_XU (1 << 25) 1541 - # define I2S_CONFIG_XO (1 << 24) 1542 - # define I2S_CONFIG_RU (1 << 23) 1543 - # define I2S_CONFIG_RO (1 << 22) 1544 - # define I2S_CONFIG_TR (1 << 21) 1545 - # define I2S_CONFIG_TE (1 << 20) 1546 - # define I2S_CONFIG_TF (1 << 19) 1547 - # define I2S_CONFIG_RR (1 << 18) 1548 - # define I2S_CONFIG_RE (1 << 17) 1549 - # define I2S_CONFIG_RF (1 << 16) 1550 - # define I2S_CONFIG_PD (1 << 11) 1551 - # define I2S_CONFIG_LB (1 << 10) 1552 - # define I2S_CONFIG_IC (1 << 9) 1553 - # define I2S_CONFIG_FM_BIT 7 1554 - # define I2S_CONFIG_FM_MASK (0x3 << I2S_CONFIG_FM_BIT) 1555 - # define I2S_CONFIG_FM_I2S (0x0 << I2S_CONFIG_FM_BIT) 1556 - # define I2S_CONFIG_FM_LJ (0x1 << I2S_CONFIG_FM_BIT) 1557 - # define I2S_CONFIG_FM_RJ (0x2 << I2S_CONFIG_FM_BIT) 1558 - # define I2S_CONFIG_TN (1 << 6) 1559 - # define I2S_CONFIG_RN (1 << 5) 1560 - # define I2S_CONFIG_SZ_BIT 0 1561 - # define I2S_CONFIG_SZ_MASK (0x1F << I2S_CONFIG_SZ_BIT) 1562 - 1563 - #define I2S_CONTROL 0xB1000008 1564 - # define I2S_CONTROL_D (1 << 1) 1565 - # define I2S_CONTROL_CE (1 << 0) 1566 - 1567 - 1568 - /* Ethernet Controllers */ 1569 - 1570 - /* 4 byte offsets from AU1000_ETH_BASE */ 1571 - #define MAC_CONTROL 0x0 1572 - # define MAC_RX_ENABLE (1 << 2) 1573 - # define MAC_TX_ENABLE (1 << 3) 1574 - # define MAC_DEF_CHECK (1 << 5) 1575 - # define MAC_SET_BL(X) (((X) & 0x3) << 6) 1576 - # define MAC_AUTO_PAD (1 << 8) 1577 - # define MAC_DISABLE_RETRY (1 << 10) 1578 - # define MAC_DISABLE_BCAST (1 << 11) 1579 - # define MAC_LATE_COL (1 << 12) 1580 - # define MAC_HASH_MODE (1 << 13) 1581 - # define MAC_HASH_ONLY (1 << 15) 1582 - # define MAC_PASS_ALL (1 << 16) 1583 - # define MAC_INVERSE_FILTER (1 << 17) 1584 - # define MAC_PROMISCUOUS (1 << 18) 1585 - # define MAC_PASS_ALL_MULTI (1 << 19) 1586 - # define MAC_FULL_DUPLEX (1 << 20) 1587 - # define MAC_NORMAL_MODE 0 1588 - # define MAC_INT_LOOPBACK (1 << 21) 1589 - # define MAC_EXT_LOOPBACK (1 << 22) 1590 - # define MAC_DISABLE_RX_OWN (1 << 23) 1591 - # define MAC_BIG_ENDIAN (1 << 30) 1592 - # define MAC_RX_ALL (1 << 31) 1593 - #define MAC_ADDRESS_HIGH 0x4 1594 - #define MAC_ADDRESS_LOW 0x8 1595 - #define MAC_MCAST_HIGH 0xC 1596 - #define MAC_MCAST_LOW 0x10 1597 - #define MAC_MII_CNTRL 0x14 1598 - # define MAC_MII_BUSY (1 << 0) 1599 - # define MAC_MII_READ 0 1600 - # define MAC_MII_WRITE (1 << 1) 1601 - # define MAC_SET_MII_SELECT_REG(X) (((X) & 0x1f) << 6) 1602 - # define MAC_SET_MII_SELECT_PHY(X) (((X) & 0x1f) << 11) 1603 - #define MAC_MII_DATA 0x18 1604 - #define MAC_FLOW_CNTRL 0x1C 1605 - # define MAC_FLOW_CNTRL_BUSY (1 << 0) 1606 - # define MAC_FLOW_CNTRL_ENABLE (1 << 1) 1607 - # define MAC_PASS_CONTROL (1 << 2) 1608 - # define MAC_SET_PAUSE(X) (((X) & 0xffff) << 16) 1609 - #define MAC_VLAN1_TAG 0x20 1610 - #define MAC_VLAN2_TAG 0x24 1611 - 1612 - /* Ethernet Controller Enable */ 1613 - 1614 - # define MAC_EN_CLOCK_ENABLE (1 << 0) 1615 - # define MAC_EN_RESET0 (1 << 1) 1616 - # define MAC_EN_TOSS (0 << 2) 1617 - # define MAC_EN_CACHEABLE (1 << 3) 1618 - # define MAC_EN_RESET1 (1 << 4) 1619 - # define MAC_EN_RESET2 (1 << 5) 1620 - # define MAC_DMA_RESET (1 << 6) 1621 - 1622 - /* Ethernet Controller DMA Channels */ 1623 - 1624 - #define MAC0_TX_DMA_ADDR 0xB4004000 1625 - #define MAC1_TX_DMA_ADDR 0xB4004200 1626 - /* offsets from MAC_TX_RING_ADDR address */ 1627 - #define MAC_TX_BUFF0_STATUS 0x0 1628 - # define TX_FRAME_ABORTED (1 << 0) 1629 - # define TX_JAB_TIMEOUT (1 << 1) 1630 - # define TX_NO_CARRIER (1 << 2) 1631 - # define TX_LOSS_CARRIER (1 << 3) 1632 - # define TX_EXC_DEF (1 << 4) 1633 - # define TX_LATE_COLL_ABORT (1 << 5) 1634 - # define TX_EXC_COLL (1 << 6) 1635 - # define TX_UNDERRUN (1 << 7) 1636 - # define TX_DEFERRED (1 << 8) 1637 - # define TX_LATE_COLL (1 << 9) 1638 - # define TX_COLL_CNT_MASK (0xF << 10) 1639 - # define TX_PKT_RETRY (1 << 31) 1640 - #define MAC_TX_BUFF0_ADDR 0x4 1641 - # define TX_DMA_ENABLE (1 << 0) 1642 - # define TX_T_DONE (1 << 1) 1643 - # define TX_GET_DMA_BUFFER(X) (((X) >> 2) & 0x3) 1644 - #define MAC_TX_BUFF0_LEN 0x8 1645 - #define MAC_TX_BUFF1_STATUS 0x10 1646 - #define MAC_TX_BUFF1_ADDR 0x14 1647 - #define MAC_TX_BUFF1_LEN 0x18 1648 - #define MAC_TX_BUFF2_STATUS 0x20 1649 - #define MAC_TX_BUFF2_ADDR 0x24 1650 - #define MAC_TX_BUFF2_LEN 0x28 1651 - #define MAC_TX_BUFF3_STATUS 0x30 1652 - #define MAC_TX_BUFF3_ADDR 0x34 1653 - #define MAC_TX_BUFF3_LEN 0x38 1654 - 1655 - #define MAC0_RX_DMA_ADDR 0xB4004100 1656 - #define MAC1_RX_DMA_ADDR 0xB4004300 1657 - /* offsets from MAC_RX_RING_ADDR */ 1658 - #define MAC_RX_BUFF0_STATUS 0x0 1659 - # define RX_FRAME_LEN_MASK 0x3fff 1660 - # define RX_WDOG_TIMER (1 << 14) 1661 - # define RX_RUNT (1 << 15) 1662 - # define RX_OVERLEN (1 << 16) 1663 - # define RX_COLL (1 << 17) 1664 - # define RX_ETHER (1 << 18) 1665 - # define RX_MII_ERROR (1 << 19) 1666 - # define RX_DRIBBLING (1 << 20) 1667 - # define RX_CRC_ERROR (1 << 21) 1668 - # define RX_VLAN1 (1 << 22) 1669 - # define RX_VLAN2 (1 << 23) 1670 - # define RX_LEN_ERROR (1 << 24) 1671 - # define RX_CNTRL_FRAME (1 << 25) 1672 - # define RX_U_CNTRL_FRAME (1 << 26) 1673 - # define RX_MCAST_FRAME (1 << 27) 1674 - # define RX_BCAST_FRAME (1 << 28) 1675 - # define RX_FILTER_FAIL (1 << 29) 1676 - # define RX_PACKET_FILTER (1 << 30) 1677 - # define RX_MISSED_FRAME (1 << 31) 1678 - 1679 - # define RX_ERROR (RX_WDOG_TIMER | RX_RUNT | RX_OVERLEN | \ 1680 - RX_COLL | RX_MII_ERROR | RX_CRC_ERROR | \ 1681 - RX_LEN_ERROR | RX_U_CNTRL_FRAME | RX_MISSED_FRAME) 1682 - #define MAC_RX_BUFF0_ADDR 0x4 1683 - # define RX_DMA_ENABLE (1 << 0) 1684 - # define RX_T_DONE (1 << 1) 1685 - # define RX_GET_DMA_BUFFER(X) (((X) >> 2) & 0x3) 1686 - # define RX_SET_BUFF_ADDR(X) ((X) & 0xffffffc0) 1687 - #define MAC_RX_BUFF1_STATUS 0x10 1688 - #define MAC_RX_BUFF1_ADDR 0x14 1689 - #define MAC_RX_BUFF2_STATUS 0x20 1690 - #define MAC_RX_BUFF2_ADDR 0x24 1691 - #define MAC_RX_BUFF3_STATUS 0x30 1692 - #define MAC_RX_BUFF3_ADDR 0x34 1693 - 1694 - /* SSIO */ 1695 - #define SSI0_STATUS 0xB1600000 1696 - # define SSI_STATUS_BF (1 << 4) 1697 - # define SSI_STATUS_OF (1 << 3) 1698 - # define SSI_STATUS_UF (1 << 2) 1699 - # define SSI_STATUS_D (1 << 1) 1700 - # define SSI_STATUS_B (1 << 0) 1701 - #define SSI0_INT 0xB1600004 1702 - # define SSI_INT_OI (1 << 3) 1703 - # define SSI_INT_UI (1 << 2) 1704 - # define SSI_INT_DI (1 << 1) 1705 - #define SSI0_INT_ENABLE 0xB1600008 1706 - # define SSI_INTE_OIE (1 << 3) 1707 - # define SSI_INTE_UIE (1 << 2) 1708 - # define SSI_INTE_DIE (1 << 1) 1709 - #define SSI0_CONFIG 0xB1600020 1710 - # define SSI_CONFIG_AO (1 << 24) 1711 - # define SSI_CONFIG_DO (1 << 23) 1712 - # define SSI_CONFIG_ALEN_BIT 20 1713 - # define SSI_CONFIG_ALEN_MASK (0x7 << 20) 1714 - # define SSI_CONFIG_DLEN_BIT 16 1715 - # define SSI_CONFIG_DLEN_MASK (0x7 << 16) 1716 - # define SSI_CONFIG_DD (1 << 11) 1717 - # define SSI_CONFIG_AD (1 << 10) 1718 - # define SSI_CONFIG_BM_BIT 8 1719 - # define SSI_CONFIG_BM_MASK (0x3 << 8) 1720 - # define SSI_CONFIG_CE (1 << 7) 1721 - # define SSI_CONFIG_DP (1 << 6) 1722 - # define SSI_CONFIG_DL (1 << 5) 1723 - # define SSI_CONFIG_EP (1 << 4) 1724 - #define SSI0_ADATA 0xB1600024 1725 - # define SSI_AD_D (1 << 24) 1726 - # define SSI_AD_ADDR_BIT 16 1727 - # define SSI_AD_ADDR_MASK (0xff << 16) 1728 - # define SSI_AD_DATA_BIT 0 1729 - # define SSI_AD_DATA_MASK (0xfff << 0) 1730 - #define SSI0_CLKDIV 0xB1600028 1731 - #define SSI0_CONTROL 0xB1600100 1732 - # define SSI_CONTROL_CD (1 << 1) 1733 - # define SSI_CONTROL_E (1 << 0) 1734 - 1735 - /* SSI1 */ 1736 - #define SSI1_STATUS 0xB1680000 1737 - #define SSI1_INT 0xB1680004 1738 - #define SSI1_INT_ENABLE 0xB1680008 1739 - #define SSI1_CONFIG 0xB1680020 1740 - #define SSI1_ADATA 0xB1680024 1741 - #define SSI1_CLKDIV 0xB1680028 1742 - #define SSI1_ENABLE 0xB1680100 1743 - 1744 - /* 1745 - * Register content definitions 1746 - */ 1747 - #define SSI_STATUS_BF (1 << 4) 1748 - #define SSI_STATUS_OF (1 << 3) 1749 - #define SSI_STATUS_UF (1 << 2) 1750 - #define SSI_STATUS_D (1 << 1) 1751 - #define SSI_STATUS_B (1 << 0) 1752 - 1753 - /* SSI_INT */ 1754 - #define SSI_INT_OI (1 << 3) 1755 - #define SSI_INT_UI (1 << 2) 1756 - #define SSI_INT_DI (1 << 1) 1757 - 1758 - /* SSI_INTEN */ 1759 - #define SSI_INTEN_OIE (1 << 3) 1760 - #define SSI_INTEN_UIE (1 << 2) 1761 - #define SSI_INTEN_DIE (1 << 1) 1762 - 1763 - #define SSI_CONFIG_AO (1 << 24) 1764 - #define SSI_CONFIG_DO (1 << 23) 1765 - #define SSI_CONFIG_ALEN (7 << 20) 1766 - #define SSI_CONFIG_DLEN (15 << 16) 1767 - #define SSI_CONFIG_DD (1 << 11) 1768 - #define SSI_CONFIG_AD (1 << 10) 1769 - #define SSI_CONFIG_BM (3 << 8) 1770 - #define SSI_CONFIG_CE (1 << 7) 1771 - #define SSI_CONFIG_DP (1 << 6) 1772 - #define SSI_CONFIG_DL (1 << 5) 1773 - #define SSI_CONFIG_EP (1 << 4) 1774 - #define SSI_CONFIG_ALEN_N(N) ((N-1) << 20) 1775 - #define SSI_CONFIG_DLEN_N(N) ((N-1) << 16) 1776 - #define SSI_CONFIG_BM_HI (0 << 8) 1777 - #define SSI_CONFIG_BM_LO (1 << 8) 1778 - #define SSI_CONFIG_BM_CY (2 << 8) 1779 - 1780 - #define SSI_ADATA_D (1 << 24) 1781 - #define SSI_ADATA_ADDR (0xFF << 16) 1782 - #define SSI_ADATA_DATA 0x0FFF 1783 - #define SSI_ADATA_ADDR_N(N) (N << 16) 1784 - 1785 - #define SSI_ENABLE_CD (1 << 1) 1786 - #define SSI_ENABLE_E (1 << 0) 1787 - 1788 - 1789 - /* 1790 - * The IrDA peripheral has an IRFIRSEL pin, but on the DB/PB boards it's not 1791 - * used to select FIR/SIR mode on the transceiver but as a GPIO. Instead a 1792 - * CPLD has to be told about the mode. 1793 - */ 1794 - #define AU1000_IRDA_PHY_MODE_OFF 0 1795 - #define AU1000_IRDA_PHY_MODE_SIR 1 1796 - #define AU1000_IRDA_PHY_MODE_FIR 2 1797 - 1798 - struct au1k_irda_platform_data { 1799 - void(*set_phy_mode)(int mode); 1800 - }; 1801 - 1802 - 1803 - /* GPIO */ 1804 - #define SYS_PINFUNC 0xB190002C 1805 - # define SYS_PF_USB (1 << 15) /* 2nd USB device/host */ 1806 - # define SYS_PF_U3 (1 << 14) /* GPIO23/U3TXD */ 1807 - # define SYS_PF_U2 (1 << 13) /* GPIO22/U2TXD */ 1808 - # define SYS_PF_U1 (1 << 12) /* GPIO21/U1TXD */ 1809 - # define SYS_PF_SRC (1 << 11) /* GPIO6/SROMCKE */ 1810 - # define SYS_PF_CK5 (1 << 10) /* GPIO3/CLK5 */ 1811 - # define SYS_PF_CK4 (1 << 9) /* GPIO2/CLK4 */ 1812 - # define SYS_PF_IRF (1 << 8) /* GPIO15/IRFIRSEL */ 1813 - # define SYS_PF_UR3 (1 << 7) /* GPIO[14:9]/UART3 */ 1814 - # define SYS_PF_I2D (1 << 6) /* GPIO8/I2SDI */ 1815 - # define SYS_PF_I2S (1 << 5) /* I2S/GPIO[29:31] */ 1816 - # define SYS_PF_NI2 (1 << 4) /* NI2/GPIO[24:28] */ 1817 - # define SYS_PF_U0 (1 << 3) /* U0TXD/GPIO20 */ 1818 - # define SYS_PF_RD (1 << 2) /* IRTXD/GPIO19 */ 1819 - # define SYS_PF_A97 (1 << 1) /* AC97/SSL1 */ 1820 - # define SYS_PF_S0 (1 << 0) /* SSI_0/GPIO[16:18] */ 1821 - 1822 - /* Au1100 only */ 1823 - # define SYS_PF_PC (1 << 18) /* PCMCIA/GPIO[207:204] */ 1824 - # define SYS_PF_LCD (1 << 17) /* extern lcd/GPIO[203:200] */ 1825 - # define SYS_PF_CS (1 << 16) /* EXTCLK0/32KHz to gpio2 */ 1826 - # define SYS_PF_EX0 (1 << 9) /* GPIO2/clock */ 1827 - 1828 - /* Au1550 only. Redefines lots of pins */ 1829 - # define SYS_PF_PSC2_MASK (7 << 17) 1830 - # define SYS_PF_PSC2_AC97 0 1831 - # define SYS_PF_PSC2_SPI 0 1832 - # define SYS_PF_PSC2_I2S (1 << 17) 1833 - # define SYS_PF_PSC2_SMBUS (3 << 17) 1834 - # define SYS_PF_PSC2_GPIO (7 << 17) 1835 - # define SYS_PF_PSC3_MASK (7 << 20) 1836 - # define SYS_PF_PSC3_AC97 0 1837 - # define SYS_PF_PSC3_SPI 0 1838 - # define SYS_PF_PSC3_I2S (1 << 20) 1839 - # define SYS_PF_PSC3_SMBUS (3 << 20) 1840 - # define SYS_PF_PSC3_GPIO (7 << 20) 1841 - # define SYS_PF_PSC1_S1 (1 << 1) 1842 - # define SYS_PF_MUST_BE_SET ((1 << 5) | (1 << 2)) 1843 - 1844 - /* Au1200 only */ 1845 - #define SYS_PINFUNC_DMA (1 << 31) 1846 - #define SYS_PINFUNC_S0A (1 << 30) 1847 - #define SYS_PINFUNC_S1A (1 << 29) 1848 - #define SYS_PINFUNC_LP0 (1 << 28) 1849 - #define SYS_PINFUNC_LP1 (1 << 27) 1850 - #define SYS_PINFUNC_LD16 (1 << 26) 1851 - #define SYS_PINFUNC_LD8 (1 << 25) 1852 - #define SYS_PINFUNC_LD1 (1 << 24) 1853 - #define SYS_PINFUNC_LD0 (1 << 23) 1854 - #define SYS_PINFUNC_P1A (3 << 21) 1855 - #define SYS_PINFUNC_P1B (1 << 20) 1856 - #define SYS_PINFUNC_FS3 (1 << 19) 1857 - #define SYS_PINFUNC_P0A (3 << 17) 1858 - #define SYS_PINFUNC_CS (1 << 16) 1859 - #define SYS_PINFUNC_CIM (1 << 15) 1860 - #define SYS_PINFUNC_P1C (1 << 14) 1861 - #define SYS_PINFUNC_U1T (1 << 12) 1862 - #define SYS_PINFUNC_U1R (1 << 11) 1863 - #define SYS_PINFUNC_EX1 (1 << 10) 1864 - #define SYS_PINFUNC_EX0 (1 << 9) 1865 - #define SYS_PINFUNC_U0R (1 << 8) 1866 - #define SYS_PINFUNC_MC (1 << 7) 1867 - #define SYS_PINFUNC_S0B (1 << 6) 1868 - #define SYS_PINFUNC_S0C (1 << 5) 1869 - #define SYS_PINFUNC_P0B (1 << 4) 1870 - #define SYS_PINFUNC_U0T (1 << 3) 1871 - #define SYS_PINFUNC_S1B (1 << 2) 1872 - 1873 - /* Power Management */ 1874 - #define SYS_SCRATCH0 0xB1900018 1875 - #define SYS_SCRATCH1 0xB190001C 1876 - #define SYS_WAKEMSK 0xB1900034 1877 - #define SYS_ENDIAN 0xB1900038 1878 - #define SYS_POWERCTRL 0xB190003C 1879 - #define SYS_WAKESRC 0xB190005C 1880 - #define SYS_SLPPWR 0xB1900078 1881 - #define SYS_SLEEP 0xB190007C 1882 - 1883 - #define SYS_WAKEMSK_D2 (1 << 9) 1884 - #define SYS_WAKEMSK_M2 (1 << 8) 1885 - #define SYS_WAKEMSK_GPIO(x) (1 << (x)) 1886 - 1887 - /* Clock Controller */ 1888 - #define SYS_FREQCTRL0 0xB1900020 1889 - # define SYS_FC_FRDIV2_BIT 22 1890 - # define SYS_FC_FRDIV2_MASK (0xff << SYS_FC_FRDIV2_BIT) 1891 - # define SYS_FC_FE2 (1 << 21) 1892 - # define SYS_FC_FS2 (1 << 20) 1893 - # define SYS_FC_FRDIV1_BIT 12 1894 - # define SYS_FC_FRDIV1_MASK (0xff << SYS_FC_FRDIV1_BIT) 1895 - # define SYS_FC_FE1 (1 << 11) 1896 - # define SYS_FC_FS1 (1 << 10) 1897 - # define SYS_FC_FRDIV0_BIT 2 1898 - # define SYS_FC_FRDIV0_MASK (0xff << SYS_FC_FRDIV0_BIT) 1899 - # define SYS_FC_FE0 (1 << 1) 1900 - # define SYS_FC_FS0 (1 << 0) 1901 - #define SYS_FREQCTRL1 0xB1900024 1902 - # define SYS_FC_FRDIV5_BIT 22 1903 - # define SYS_FC_FRDIV5_MASK (0xff << SYS_FC_FRDIV5_BIT) 1904 - # define SYS_FC_FE5 (1 << 21) 1905 - # define SYS_FC_FS5 (1 << 20) 1906 - # define SYS_FC_FRDIV4_BIT 12 1907 - # define SYS_FC_FRDIV4_MASK (0xff << SYS_FC_FRDIV4_BIT) 1908 - # define SYS_FC_FE4 (1 << 11) 1909 - # define SYS_FC_FS4 (1 << 10) 1910 - # define SYS_FC_FRDIV3_BIT 2 1911 - # define SYS_FC_FRDIV3_MASK (0xff << SYS_FC_FRDIV3_BIT) 1912 - # define SYS_FC_FE3 (1 << 1) 1913 - # define SYS_FC_FS3 (1 << 0) 1914 - #define SYS_CLKSRC 0xB1900028 1915 - # define SYS_CS_ME1_BIT 27 1916 - # define SYS_CS_ME1_MASK (0x7 << SYS_CS_ME1_BIT) 1917 - # define SYS_CS_DE1 (1 << 26) 1918 - # define SYS_CS_CE1 (1 << 25) 1919 - # define SYS_CS_ME0_BIT 22 1920 - # define SYS_CS_ME0_MASK (0x7 << SYS_CS_ME0_BIT) 1921 - # define SYS_CS_DE0 (1 << 21) 1922 - # define SYS_CS_CE0 (1 << 20) 1923 - # define SYS_CS_MI2_BIT 17 1924 - # define SYS_CS_MI2_MASK (0x7 << SYS_CS_MI2_BIT) 1925 - # define SYS_CS_DI2 (1 << 16) 1926 - # define SYS_CS_CI2 (1 << 15) 1927 - 1928 - # define SYS_CS_ML_BIT 7 1929 - # define SYS_CS_ML_MASK (0x7 << SYS_CS_ML_BIT) 1930 - # define SYS_CS_DL (1 << 6) 1931 - # define SYS_CS_CL (1 << 5) 1932 - 1933 - # define SYS_CS_MUH_BIT 12 1934 - # define SYS_CS_MUH_MASK (0x7 << SYS_CS_MUH_BIT) 1935 - # define SYS_CS_DUH (1 << 11) 1936 - # define SYS_CS_CUH (1 << 10) 1937 - # define SYS_CS_MUD_BIT 7 1938 - # define SYS_CS_MUD_MASK (0x7 << SYS_CS_MUD_BIT) 1939 - # define SYS_CS_DUD (1 << 6) 1940 - # define SYS_CS_CUD (1 << 5) 1941 - 1942 - # define SYS_CS_MIR_BIT 2 1943 - # define SYS_CS_MIR_MASK (0x7 << SYS_CS_MIR_BIT) 1944 - # define SYS_CS_DIR (1 << 1) 1945 - # define SYS_CS_CIR (1 << 0) 1946 - 1947 - # define SYS_CS_MUX_AUX 0x1 1948 - # define SYS_CS_MUX_FQ0 0x2 1949 - # define SYS_CS_MUX_FQ1 0x3 1950 - # define SYS_CS_MUX_FQ2 0x4 1951 - # define SYS_CS_MUX_FQ3 0x5 1952 - # define SYS_CS_MUX_FQ4 0x6 1953 - # define SYS_CS_MUX_FQ5 0x7 1954 - #define SYS_CPUPLL 0xB1900060 1955 - #define SYS_AUXPLL 0xB1900064 1956 - 1957 - /* AC97 Controller */ 1958 - #define AC97C_CONFIG 0xB0000000 1959 - # define AC97C_RECV_SLOTS_BIT 13 1960 - # define AC97C_RECV_SLOTS_MASK (0x3ff << AC97C_RECV_SLOTS_BIT) 1961 - # define AC97C_XMIT_SLOTS_BIT 3 1962 - # define AC97C_XMIT_SLOTS_MASK (0x3ff << AC97C_XMIT_SLOTS_BIT) 1963 - # define AC97C_SG (1 << 2) 1964 - # define AC97C_SYNC (1 << 1) 1965 - # define AC97C_RESET (1 << 0) 1966 - #define AC97C_STATUS 0xB0000004 1967 - # define AC97C_XU (1 << 11) 1968 - # define AC97C_XO (1 << 10) 1969 - # define AC97C_RU (1 << 9) 1970 - # define AC97C_RO (1 << 8) 1971 - # define AC97C_READY (1 << 7) 1972 - # define AC97C_CP (1 << 6) 1973 - # define AC97C_TR (1 << 5) 1974 - # define AC97C_TE (1 << 4) 1975 - # define AC97C_TF (1 << 3) 1976 - # define AC97C_RR (1 << 2) 1977 - # define AC97C_RE (1 << 1) 1978 - # define AC97C_RF (1 << 0) 1979 - #define AC97C_DATA 0xB0000008 1980 - #define AC97C_CMD 0xB000000C 1981 - # define AC97C_WD_BIT 16 1982 - # define AC97C_READ (1 << 7) 1983 - # define AC97C_INDEX_MASK 0x7f 1984 - #define AC97C_CNTRL 0xB0000010 1985 - # define AC97C_RS (1 << 1) 1986 - # define AC97C_CE (1 << 0) 1987 - 1988 - 1989 - /* The PCI chip selects are outside the 32bit space, and since we can't 1990 - * just program the 36bit addresses into BARs, we have to take a chunk 1991 - * out of the 32bit space and reserve it for PCI. When these addresses 1992 - * are ioremap()ed, they'll be fixed up to the real 36bit address before 1993 - * being passed to the real ioremap function. 1994 - */ 1995 - #define ALCHEMY_PCI_MEMWIN_START (AU1500_PCI_MEM_PHYS_ADDR >> 4) 1996 - #define ALCHEMY_PCI_MEMWIN_END (ALCHEMY_PCI_MEMWIN_START + 0x0FFFFFFF) 1997 - 1998 - /* for PCI IO it's simpler because we get to do the ioremap ourselves and then 1999 - * adjust the device's resources. 2000 - */ 2001 - #define ALCHEMY_PCI_IOWIN_START 0x00001000 2002 - #define ALCHEMY_PCI_IOWIN_END 0x0000FFFF 2003 - 2004 - #ifdef CONFIG_PCI 2005 - 2006 - #define IOPORT_RESOURCE_START 0x00001000 /* skip legacy probing */ 2007 - #define IOPORT_RESOURCE_END 0xffffffff 2008 - #define IOMEM_RESOURCE_START 0x10000000 2009 - #define IOMEM_RESOURCE_END 0xfffffffffULL 2010 - 2011 - #else 2012 - 2013 - /* Don't allow any legacy ports probing */ 2014 - #define IOPORT_RESOURCE_START 0x10000000 2015 - #define IOPORT_RESOURCE_END 0xffffffff 2016 - #define IOMEM_RESOURCE_START 0x10000000 2017 - #define IOMEM_RESOURCE_END 0xfffffffffULL 2018 - 2019 - #endif 2020 - 2021 - /* PCI controller block register offsets */ 2022 - #define PCI_REG_CMEM 0x0000 2023 - #define PCI_REG_CONFIG 0x0004 2024 - #define PCI_REG_B2BMASK_CCH 0x0008 2025 - #define PCI_REG_B2BBASE0_VID 0x000C 2026 - #define PCI_REG_B2BBASE1_SID 0x0010 2027 - #define PCI_REG_MWMASK_DEV 0x0014 2028 - #define PCI_REG_MWBASE_REV_CCL 0x0018 2029 - #define PCI_REG_ERR_ADDR 0x001C 2030 - #define PCI_REG_SPEC_INTACK 0x0020 2031 - #define PCI_REG_ID 0x0100 2032 - #define PCI_REG_STATCMD 0x0104 2033 - #define PCI_REG_CLASSREV 0x0108 2034 - #define PCI_REG_PARAM 0x010C 2035 - #define PCI_REG_MBAR 0x0110 2036 - #define PCI_REG_TIMEOUT 0x0140 2037 - 2038 - /* PCI controller block register bits */ 2039 - #define PCI_CMEM_E (1 << 28) /* enable cacheable memory */ 2040 - #define PCI_CMEM_CMBASE(x) (((x) & 0x3fff) << 14) 2041 - #define PCI_CMEM_CMMASK(x) ((x) & 0x3fff) 2042 - #define PCI_CONFIG_ERD (1 << 27) /* pci error during R/W */ 2043 - #define PCI_CONFIG_ET (1 << 26) /* error in target mode */ 2044 - #define PCI_CONFIG_EF (1 << 25) /* fatal error */ 2045 - #define PCI_CONFIG_EP (1 << 24) /* parity error */ 2046 - #define PCI_CONFIG_EM (1 << 23) /* multiple errors */ 2047 - #define PCI_CONFIG_BM (1 << 22) /* bad master error */ 2048 - #define PCI_CONFIG_PD (1 << 20) /* PCI Disable */ 2049 - #define PCI_CONFIG_BME (1 << 19) /* Byte Mask Enable for reads */ 2050 - #define PCI_CONFIG_NC (1 << 16) /* mark mem access non-coherent */ 2051 - #define PCI_CONFIG_IA (1 << 15) /* INTA# enabled (target mode) */ 2052 - #define PCI_CONFIG_IP (1 << 13) /* int on PCI_PERR# */ 2053 - #define PCI_CONFIG_IS (1 << 12) /* int on PCI_SERR# */ 2054 - #define PCI_CONFIG_IMM (1 << 11) /* int on master abort */ 2055 - #define PCI_CONFIG_ITM (1 << 10) /* int on target abort (as master) */ 2056 - #define PCI_CONFIG_ITT (1 << 9) /* int on target abort (as target) */ 2057 - #define PCI_CONFIG_IPB (1 << 8) /* int on PERR# in bus master acc */ 2058 - #define PCI_CONFIG_SIC_NO (0 << 6) /* no byte mask changes */ 2059 - #define PCI_CONFIG_SIC_BA_ADR (1 << 6) /* on byte/hw acc, invert adr bits */ 2060 - #define PCI_CONFIG_SIC_HWA_DAT (2 << 6) /* on halfword acc, swap data */ 2061 - #define PCI_CONFIG_SIC_ALL (3 << 6) /* swap data bytes on all accesses */ 2062 - #define PCI_CONFIG_ST (1 << 5) /* swap data by target transactions */ 2063 - #define PCI_CONFIG_SM (1 << 4) /* swap data from PCI ctl */ 2064 - #define PCI_CONFIG_AEN (1 << 3) /* enable internal arbiter */ 2065 - #define PCI_CONFIG_R2H (1 << 2) /* REQ2# to hi-prio arbiter */ 2066 - #define PCI_CONFIG_R1H (1 << 1) /* REQ1# to hi-prio arbiter */ 2067 - #define PCI_CONFIG_CH (1 << 0) /* PCI ctl to hi-prio arbiter */ 2068 - #define PCI_B2BMASK_B2BMASK(x) (((x) & 0xffff) << 16) 2069 - #define PCI_B2BMASK_CCH(x) ((x) & 0xffff) /* 16 upper bits of class code */ 2070 - #define PCI_B2BBASE0_VID_B0(x) (((x) & 0xffff) << 16) 2071 - #define PCI_B2BBASE0_VID_SV(x) ((x) & 0xffff) 2072 - #define PCI_B2BBASE1_SID_B1(x) (((x) & 0xffff) << 16) 2073 - #define PCI_B2BBASE1_SID_SI(x) ((x) & 0xffff) 2074 - #define PCI_MWMASKDEV_MWMASK(x) (((x) & 0xffff) << 16) 2075 - #define PCI_MWMASKDEV_DEVID(x) ((x) & 0xffff) 2076 - #define PCI_MWBASEREVCCL_BASE(x) (((x) & 0xffff) << 16) 2077 - #define PCI_MWBASEREVCCL_REV(x) (((x) & 0xff) << 8) 2078 - #define PCI_MWBASEREVCCL_CCL(x) ((x) & 0xff) 2079 - #define PCI_ID_DID(x) (((x) & 0xffff) << 16) 2080 - #define PCI_ID_VID(x) ((x) & 0xffff) 2081 - #define PCI_STATCMD_STATUS(x) (((x) & 0xffff) << 16) 2082 - #define PCI_STATCMD_CMD(x) ((x) & 0xffff) 2083 - #define PCI_CLASSREV_CLASS(x) (((x) & 0x00ffffff) << 8) 2084 - #define PCI_CLASSREV_REV(x) ((x) & 0xff) 2085 - #define PCI_PARAM_BIST(x) (((x) & 0xff) << 24) 2086 - #define PCI_PARAM_HT(x) (((x) & 0xff) << 16) 2087 - #define PCI_PARAM_LT(x) (((x) & 0xff) << 8) 2088 - #define PCI_PARAM_CLS(x) ((x) & 0xff) 2089 - #define PCI_TIMEOUT_RETRIES(x) (((x) & 0xff) << 8) /* max retries */ 2090 - #define PCI_TIMEOUT_TO(x) ((x) & 0xff) /* target ready timeout */ 2091 680 2092 681 #endif
+25 -25
arch/mips/include/asm/mach-au1x00/au1000_dma.h
··· 106 106 struct dma_chan { 107 107 int dev_id; /* this channel is allocated if >= 0, */ 108 108 /* free otherwise */ 109 - unsigned int io; 109 + void __iomem *io; 110 110 const char *dev_str; 111 111 int irq; 112 112 void *irq_dev; ··· 157 157 158 158 if (!chan) 159 159 return; 160 - au_writel(DMA_BE0, chan->io + DMA_MODE_SET); 160 + __raw_writel(DMA_BE0, chan->io + DMA_MODE_SET); 161 161 } 162 162 163 163 static inline void enable_dma_buffer1(unsigned int dmanr) ··· 166 166 167 167 if (!chan) 168 168 return; 169 - au_writel(DMA_BE1, chan->io + DMA_MODE_SET); 169 + __raw_writel(DMA_BE1, chan->io + DMA_MODE_SET); 170 170 } 171 171 static inline void enable_dma_buffers(unsigned int dmanr) 172 172 { ··· 174 174 175 175 if (!chan) 176 176 return; 177 - au_writel(DMA_BE0 | DMA_BE1, chan->io + DMA_MODE_SET); 177 + __raw_writel(DMA_BE0 | DMA_BE1, chan->io + DMA_MODE_SET); 178 178 } 179 179 180 180 static inline void start_dma(unsigned int dmanr) ··· 183 183 184 184 if (!chan) 185 185 return; 186 - au_writel(DMA_GO, chan->io + DMA_MODE_SET); 186 + __raw_writel(DMA_GO, chan->io + DMA_MODE_SET); 187 187 } 188 188 189 189 #define DMA_HALT_POLL 0x5000 ··· 195 195 196 196 if (!chan) 197 197 return; 198 - au_writel(DMA_GO, chan->io + DMA_MODE_CLEAR); 198 + __raw_writel(DMA_GO, chan->io + DMA_MODE_CLEAR); 199 199 200 200 /* Poll the halt bit */ 201 201 for (i = 0; i < DMA_HALT_POLL; i++) 202 - if (au_readl(chan->io + DMA_MODE_READ) & DMA_HALT) 202 + if (__raw_readl(chan->io + DMA_MODE_READ) & DMA_HALT) 203 203 break; 204 204 if (i == DMA_HALT_POLL) 205 205 printk(KERN_INFO "halt_dma: HALT poll expired!\n"); ··· 215 215 halt_dma(dmanr); 216 216 217 217 /* Now we can disable the buffers */ 218 - au_writel(~DMA_GO, chan->io + DMA_MODE_CLEAR); 218 + __raw_writel(~DMA_GO, chan->io + DMA_MODE_CLEAR); 219 219 } 220 220 221 221 static inline int dma_halted(unsigned int dmanr) ··· 224 224 225 225 if (!chan) 226 226 return 1; 227 - return (au_readl(chan->io + DMA_MODE_READ) & DMA_HALT) ? 1 : 0; 227 + return (__raw_readl(chan->io + DMA_MODE_READ) & DMA_HALT) ? 1 : 0; 228 228 } 229 229 230 230 /* Initialize a DMA channel. */ ··· 239 239 disable_dma(dmanr); 240 240 241 241 /* Set device FIFO address */ 242 - au_writel(CPHYSADDR(chan->fifo_addr), chan->io + DMA_PERIPHERAL_ADDR); 242 + __raw_writel(CPHYSADDR(chan->fifo_addr), chan->io + DMA_PERIPHERAL_ADDR); 243 243 244 244 mode = chan->mode | (chan->dev_id << DMA_DID_BIT); 245 245 if (chan->irq) 246 246 mode |= DMA_IE; 247 247 248 - au_writel(~mode, chan->io + DMA_MODE_CLEAR); 249 - au_writel(mode, chan->io + DMA_MODE_SET); 248 + __raw_writel(~mode, chan->io + DMA_MODE_CLEAR); 249 + __raw_writel(mode, chan->io + DMA_MODE_SET); 250 250 } 251 251 252 252 /* ··· 283 283 284 284 if (!chan) 285 285 return -1; 286 - return (au_readl(chan->io + DMA_MODE_READ) & DMA_AB) ? 1 : 0; 286 + return (__raw_readl(chan->io + DMA_MODE_READ) & DMA_AB) ? 1 : 0; 287 287 } 288 288 289 289 /* ··· 304 304 if (chan->dev_id != DMA_ID_GP04 && chan->dev_id != DMA_ID_GP05) 305 305 return; 306 306 307 - au_writel(CPHYSADDR(a), chan->io + DMA_PERIPHERAL_ADDR); 307 + __raw_writel(CPHYSADDR(a), chan->io + DMA_PERIPHERAL_ADDR); 308 308 } 309 309 310 310 /* ··· 316 316 317 317 if (!chan) 318 318 return; 319 - au_writel(DMA_D0, chan->io + DMA_MODE_CLEAR); 319 + __raw_writel(DMA_D0, chan->io + DMA_MODE_CLEAR); 320 320 } 321 321 322 322 static inline void clear_dma_done1(unsigned int dmanr) ··· 325 325 326 326 if (!chan) 327 327 return; 328 - au_writel(DMA_D1, chan->io + DMA_MODE_CLEAR); 328 + __raw_writel(DMA_D1, chan->io + DMA_MODE_CLEAR); 329 329 } 330 330 331 331 /* ··· 344 344 345 345 if (!chan) 346 346 return; 347 - au_writel(a, chan->io + DMA_BUFFER0_START); 347 + __raw_writel(a, chan->io + DMA_BUFFER0_START); 348 348 } 349 349 350 350 /* ··· 356 356 357 357 if (!chan) 358 358 return; 359 - au_writel(a, chan->io + DMA_BUFFER1_START); 359 + __raw_writel(a, chan->io + DMA_BUFFER1_START); 360 360 } 361 361 362 362 ··· 370 370 if (!chan) 371 371 return; 372 372 count &= DMA_COUNT_MASK; 373 - au_writel(count, chan->io + DMA_BUFFER0_COUNT); 373 + __raw_writel(count, chan->io + DMA_BUFFER0_COUNT); 374 374 } 375 375 376 376 /* ··· 383 383 if (!chan) 384 384 return; 385 385 count &= DMA_COUNT_MASK; 386 - au_writel(count, chan->io + DMA_BUFFER1_COUNT); 386 + __raw_writel(count, chan->io + DMA_BUFFER1_COUNT); 387 387 } 388 388 389 389 /* ··· 396 396 if (!chan) 397 397 return; 398 398 count &= DMA_COUNT_MASK; 399 - au_writel(count, chan->io + DMA_BUFFER0_COUNT); 400 - au_writel(count, chan->io + DMA_BUFFER1_COUNT); 399 + __raw_writel(count, chan->io + DMA_BUFFER0_COUNT); 400 + __raw_writel(count, chan->io + DMA_BUFFER1_COUNT); 401 401 } 402 402 403 403 /* ··· 410 410 411 411 if (!chan) 412 412 return 0; 413 - return au_readl(chan->io + DMA_MODE_READ) & (DMA_D0 | DMA_D1); 413 + return __raw_readl(chan->io + DMA_MODE_READ) & (DMA_D0 | DMA_D1); 414 414 } 415 415 416 416 ··· 437 437 if (!chan) 438 438 return 0; 439 439 440 - curBufCntReg = (au_readl(chan->io + DMA_MODE_READ) & DMA_AB) ? 440 + curBufCntReg = (__raw_readl(chan->io + DMA_MODE_READ) & DMA_AB) ? 441 441 DMA_BUFFER1_COUNT : DMA_BUFFER0_COUNT; 442 442 443 - count = au_readl(chan->io + curBufCntReg) & DMA_COUNT_MASK; 443 + count = __raw_readl(chan->io + curBufCntReg) & DMA_COUNT_MASK; 444 444 445 445 if ((chan->mode & DMA_DW_MASK) == DMA_DW16) 446 446 count <<= 1;
+26 -30
arch/mips/include/asm/mach-au1x00/gpio-au1000.h
··· 25 25 #define MAKE_IRQ(intc, off) (AU1000_INTC##intc##_INT_BASE + (off)) 26 26 27 27 /* GPIO1 registers within SYS_ area */ 28 - #define SYS_TRIOUTRD 0x100 29 - #define SYS_TRIOUTCLR 0x100 30 - #define SYS_OUTPUTRD 0x108 31 - #define SYS_OUTPUTSET 0x108 32 - #define SYS_OUTPUTCLR 0x10C 33 - #define SYS_PINSTATERD 0x110 34 - #define SYS_PININPUTEN 0x110 28 + #define AU1000_SYS_TRIOUTRD 0x100 29 + #define AU1000_SYS_TRIOUTCLR 0x100 30 + #define AU1000_SYS_OUTPUTRD 0x108 31 + #define AU1000_SYS_OUTPUTSET 0x108 32 + #define AU1000_SYS_OUTPUTCLR 0x10C 33 + #define AU1000_SYS_PINSTATERD 0x110 34 + #define AU1000_SYS_PININPUTEN 0x110 35 35 36 36 /* register offsets within GPIO2 block */ 37 - #define GPIO2_DIR 0x00 38 - #define GPIO2_OUTPUT 0x08 39 - #define GPIO2_PINSTATE 0x0C 40 - #define GPIO2_INTENABLE 0x10 41 - #define GPIO2_ENABLE 0x14 37 + #define AU1000_GPIO2_DIR 0x00 38 + #define AU1000_GPIO2_OUTPUT 0x08 39 + #define AU1000_GPIO2_PINSTATE 0x0C 40 + #define AU1000_GPIO2_INTENABLE 0x10 41 + #define AU1000_GPIO2_ENABLE 0x14 42 42 43 43 struct gpio; 44 44 ··· 217 217 */ 218 218 static inline void alchemy_gpio1_set_value(int gpio, int v) 219 219 { 220 - void __iomem *base = (void __iomem *)KSEG1ADDR(AU1000_SYS_PHYS_ADDR); 221 220 unsigned long mask = 1 << (gpio - ALCHEMY_GPIO1_BASE); 222 - unsigned long r = v ? SYS_OUTPUTSET : SYS_OUTPUTCLR; 223 - __raw_writel(mask, base + r); 224 - wmb(); 221 + unsigned long r = v ? AU1000_SYS_OUTPUTSET : AU1000_SYS_OUTPUTCLR; 222 + alchemy_wrsys(mask, r); 225 223 } 226 224 227 225 static inline int alchemy_gpio1_get_value(int gpio) 228 226 { 229 - void __iomem *base = (void __iomem *)KSEG1ADDR(AU1000_SYS_PHYS_ADDR); 230 227 unsigned long mask = 1 << (gpio - ALCHEMY_GPIO1_BASE); 231 - return __raw_readl(base + SYS_PINSTATERD) & mask; 228 + return alchemy_rdsys(AU1000_SYS_PINSTATERD) & mask; 232 229 } 233 230 234 231 static inline int alchemy_gpio1_direction_input(int gpio) 235 232 { 236 - void __iomem *base = (void __iomem *)KSEG1ADDR(AU1000_SYS_PHYS_ADDR); 237 233 unsigned long mask = 1 << (gpio - ALCHEMY_GPIO1_BASE); 238 - __raw_writel(mask, base + SYS_TRIOUTCLR); 239 - wmb(); 234 + alchemy_wrsys(mask, AU1000_SYS_TRIOUTCLR); 240 235 return 0; 241 236 } 242 237 ··· 274 279 { 275 280 void __iomem *base = (void __iomem *)KSEG1ADDR(AU1500_GPIO2_PHYS_ADDR); 276 281 unsigned long mask = 1 << (gpio - ALCHEMY_GPIO2_BASE); 277 - unsigned long d = __raw_readl(base + GPIO2_DIR); 282 + unsigned long d = __raw_readl(base + AU1000_GPIO2_DIR); 278 283 279 284 if (to_out) 280 285 d |= mask; 281 286 else 282 287 d &= ~mask; 283 - __raw_writel(d, base + GPIO2_DIR); 288 + __raw_writel(d, base + AU1000_GPIO2_DIR); 284 289 wmb(); 285 290 } 286 291 ··· 289 294 void __iomem *base = (void __iomem *)KSEG1ADDR(AU1500_GPIO2_PHYS_ADDR); 290 295 unsigned long mask; 291 296 mask = ((v) ? 0x00010001 : 0x00010000) << (gpio - ALCHEMY_GPIO2_BASE); 292 - __raw_writel(mask, base + GPIO2_OUTPUT); 297 + __raw_writel(mask, base + AU1000_GPIO2_OUTPUT); 293 298 wmb(); 294 299 } 295 300 296 301 static inline int alchemy_gpio2_get_value(int gpio) 297 302 { 298 303 void __iomem *base = (void __iomem *)KSEG1ADDR(AU1500_GPIO2_PHYS_ADDR); 299 - return __raw_readl(base + GPIO2_PINSTATE) & (1 << (gpio - ALCHEMY_GPIO2_BASE)); 304 + return __raw_readl(base + AU1000_GPIO2_PINSTATE) & 305 + (1 << (gpio - ALCHEMY_GPIO2_BASE)); 300 306 } 301 307 302 308 static inline int alchemy_gpio2_direction_input(int gpio) ··· 348 352 static inline void __alchemy_gpio2_mod_int(int gpio2, int en) 349 353 { 350 354 void __iomem *base = (void __iomem *)KSEG1ADDR(AU1500_GPIO2_PHYS_ADDR); 351 - unsigned long r = __raw_readl(base + GPIO2_INTENABLE); 355 + unsigned long r = __raw_readl(base + AU1000_GPIO2_INTENABLE); 352 356 if (en) 353 357 r |= 1 << gpio2; 354 358 else 355 359 r &= ~(1 << gpio2); 356 - __raw_writel(r, base + GPIO2_INTENABLE); 360 + __raw_writel(r, base + AU1000_GPIO2_INTENABLE); 357 361 wmb(); 358 362 } 359 363 ··· 430 434 static inline void alchemy_gpio2_enable(void) 431 435 { 432 436 void __iomem *base = (void __iomem *)KSEG1ADDR(AU1500_GPIO2_PHYS_ADDR); 433 - __raw_writel(3, base + GPIO2_ENABLE); /* reset, clock enabled */ 437 + __raw_writel(3, base + AU1000_GPIO2_ENABLE); /* reset, clock enabled */ 434 438 wmb(); 435 - __raw_writel(1, base + GPIO2_ENABLE); /* clock enabled */ 439 + __raw_writel(1, base + AU1000_GPIO2_ENABLE); /* clock enabled */ 436 440 wmb(); 437 441 } 438 442 ··· 444 448 static inline void alchemy_gpio2_disable(void) 445 449 { 446 450 void __iomem *base = (void __iomem *)KSEG1ADDR(AU1500_GPIO2_PHYS_ADDR); 447 - __raw_writel(2, base + GPIO2_ENABLE); /* reset, clock disabled */ 451 + __raw_writel(2, base + AU1000_GPIO2_ENABLE); /* reset, clock disabled */ 448 452 wmb(); 449 453 } 450 454
+6 -1
arch/mips/include/asm/mach-bcm47xx/bcm47xx_board.h
··· 18 18 BCM47XX_BOARD_ASUS_WL300G, 19 19 BCM47XX_BOARD_ASUS_WL320GE, 20 20 BCM47XX_BOARD_ASUS_WL330GE, 21 + BCM47XX_BOARD_ASUS_WL500G, 21 22 BCM47XX_BOARD_ASUS_WL500GD, 22 23 BCM47XX_BOARD_ASUS_WL500GPV1, 23 24 BCM47XX_BOARD_ASUS_WL500GPV2, ··· 71 70 BCM47XX_BOARD_LINKSYS_WRT310NV1, 72 71 BCM47XX_BOARD_LINKSYS_WRT310NV2, 73 72 BCM47XX_BOARD_LINKSYS_WRT54G3GV2, 74 - BCM47XX_BOARD_LINKSYS_WRT54G, 73 + BCM47XX_BOARD_LINKSYS_WRT54G_TYPE_0101, 74 + BCM47XX_BOARD_LINKSYS_WRT54G_TYPE_0467, 75 + BCM47XX_BOARD_LINKSYS_WRT54G_TYPE_0708, 75 76 BCM47XX_BOARD_LINKSYS_WRT610NV1, 76 77 BCM47XX_BOARD_LINKSYS_WRT610NV2, 77 78 BCM47XX_BOARD_LINKSYS_WRTSL54GS, 79 + 80 + BCM47XX_BOARD_MICROSOFT_MN700, 78 81 79 82 BCM47XX_BOARD_MOTOROLA_WE800G, 80 83 BCM47XX_BOARD_MOTOROLA_WR850GP,
+35 -163
arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h
··· 19 19 #define BCM6368_CPU_ID 0x6368 20 20 21 21 void __init bcm63xx_cpu_init(void); 22 - u16 __bcm63xx_get_cpu_id(void); 23 22 u8 bcm63xx_get_cpu_rev(void); 24 23 unsigned int bcm63xx_get_cpu_freq(void); 25 24 25 + static inline u16 __pure __bcm63xx_get_cpu_id(const u16 cpu_id) 26 + { 27 + switch (cpu_id) { 26 28 #ifdef CONFIG_BCM63XX_CPU_3368 27 - # ifdef bcm63xx_get_cpu_id 28 - # undef bcm63xx_get_cpu_id 29 - # define bcm63xx_get_cpu_id() __bcm63xx_get_cpu_id() 30 - # define BCMCPU_RUNTIME_DETECT 31 - # else 32 - # define bcm63xx_get_cpu_id() BCM3368_CPU_ID 33 - # endif 34 - # define BCMCPU_IS_3368() (bcm63xx_get_cpu_id() == BCM3368_CPU_ID) 35 - #else 36 - # define BCMCPU_IS_3368() (0) 29 + case BCM3368_CPU_ID: 37 30 #endif 38 31 39 32 #ifdef CONFIG_BCM63XX_CPU_6328 40 - # ifdef bcm63xx_get_cpu_id 41 - # undef bcm63xx_get_cpu_id 42 - # define bcm63xx_get_cpu_id() __bcm63xx_get_cpu_id() 43 - # define BCMCPU_RUNTIME_DETECT 44 - # else 45 - # define bcm63xx_get_cpu_id() BCM6328_CPU_ID 46 - # endif 47 - # define BCMCPU_IS_6328() (bcm63xx_get_cpu_id() == BCM6328_CPU_ID) 48 - #else 49 - # define BCMCPU_IS_6328() (0) 33 + case BCM6328_CPU_ID: 50 34 #endif 51 35 52 36 #ifdef CONFIG_BCM63XX_CPU_6338 53 - # ifdef bcm63xx_get_cpu_id 54 - # undef bcm63xx_get_cpu_id 55 - # define bcm63xx_get_cpu_id() __bcm63xx_get_cpu_id() 56 - # define BCMCPU_RUNTIME_DETECT 57 - # else 58 - # define bcm63xx_get_cpu_id() BCM6338_CPU_ID 59 - # endif 60 - # define BCMCPU_IS_6338() (bcm63xx_get_cpu_id() == BCM6338_CPU_ID) 61 - #else 62 - # define BCMCPU_IS_6338() (0) 37 + case BCM6338_CPU_ID: 63 38 #endif 64 39 65 40 #ifdef CONFIG_BCM63XX_CPU_6345 66 - # ifdef bcm63xx_get_cpu_id 67 - # undef bcm63xx_get_cpu_id 68 - # define bcm63xx_get_cpu_id() __bcm63xx_get_cpu_id() 69 - # define BCMCPU_RUNTIME_DETECT 70 - # else 71 - # define bcm63xx_get_cpu_id() BCM6345_CPU_ID 72 - # endif 73 - # define BCMCPU_IS_6345() (bcm63xx_get_cpu_id() == BCM6345_CPU_ID) 74 - #else 75 - # define BCMCPU_IS_6345() (0) 41 + case BCM6345_CPU_ID: 76 42 #endif 77 43 78 44 #ifdef CONFIG_BCM63XX_CPU_6348 79 - # ifdef bcm63xx_get_cpu_id 80 - # undef bcm63xx_get_cpu_id 81 - # define bcm63xx_get_cpu_id() __bcm63xx_get_cpu_id() 82 - # define BCMCPU_RUNTIME_DETECT 83 - # else 84 - # define bcm63xx_get_cpu_id() BCM6348_CPU_ID 85 - # endif 86 - # define BCMCPU_IS_6348() (bcm63xx_get_cpu_id() == BCM6348_CPU_ID) 87 - #else 88 - # define BCMCPU_IS_6348() (0) 45 + case BCM6348_CPU_ID: 89 46 #endif 90 47 91 48 #ifdef CONFIG_BCM63XX_CPU_6358 92 - # ifdef bcm63xx_get_cpu_id 93 - # undef bcm63xx_get_cpu_id 94 - # define bcm63xx_get_cpu_id() __bcm63xx_get_cpu_id() 95 - # define BCMCPU_RUNTIME_DETECT 96 - # else 97 - # define bcm63xx_get_cpu_id() BCM6358_CPU_ID 98 - # endif 99 - # define BCMCPU_IS_6358() (bcm63xx_get_cpu_id() == BCM6358_CPU_ID) 100 - #else 101 - # define BCMCPU_IS_6358() (0) 49 + case BCM6358_CPU_ID: 102 50 #endif 103 51 104 52 #ifdef CONFIG_BCM63XX_CPU_6362 105 - # ifdef bcm63xx_get_cpu_id 106 - # undef bcm63xx_get_cpu_id 107 - # define bcm63xx_get_cpu_id() __bcm63xx_get_cpu_id() 108 - # define BCMCPU_RUNTIME_DETECT 109 - # else 110 - # define bcm63xx_get_cpu_id() BCM6362_CPU_ID 111 - # endif 112 - # define BCMCPU_IS_6362() (bcm63xx_get_cpu_id() == BCM6362_CPU_ID) 113 - #else 114 - # define BCMCPU_IS_6362() (0) 53 + case BCM6362_CPU_ID: 115 54 #endif 116 - 117 55 118 56 #ifdef CONFIG_BCM63XX_CPU_6368 119 - # ifdef bcm63xx_get_cpu_id 120 - # undef bcm63xx_get_cpu_id 121 - # define bcm63xx_get_cpu_id() __bcm63xx_get_cpu_id() 122 - # define BCMCPU_RUNTIME_DETECT 123 - # else 124 - # define bcm63xx_get_cpu_id() BCM6368_CPU_ID 125 - # endif 126 - # define BCMCPU_IS_6368() (bcm63xx_get_cpu_id() == BCM6368_CPU_ID) 127 - #else 128 - # define BCMCPU_IS_6368() (0) 57 + case BCM6368_CPU_ID: 129 58 #endif 59 + break; 60 + default: 61 + unreachable(); 62 + } 130 63 131 - #ifndef bcm63xx_get_cpu_id 132 - #error "No CPU support configured" 133 - #endif 64 + return cpu_id; 65 + } 66 + 67 + extern u16 bcm63xx_cpu_id; 68 + 69 + static inline u16 __pure bcm63xx_get_cpu_id(void) 70 + { 71 + const u16 cpu_id = bcm63xx_cpu_id; 72 + 73 + return __bcm63xx_get_cpu_id(cpu_id); 74 + } 75 + 76 + #define BCMCPU_IS_3368() (bcm63xx_get_cpu_id() == BCM3368_CPU_ID) 77 + #define BCMCPU_IS_6328() (bcm63xx_get_cpu_id() == BCM6328_CPU_ID) 78 + #define BCMCPU_IS_6338() (bcm63xx_get_cpu_id() == BCM6338_CPU_ID) 79 + #define BCMCPU_IS_6345() (bcm63xx_get_cpu_id() == BCM6345_CPU_ID) 80 + #define BCMCPU_IS_6348() (bcm63xx_get_cpu_id() == BCM6348_CPU_ID) 81 + #define BCMCPU_IS_6358() (bcm63xx_get_cpu_id() == BCM6358_CPU_ID) 82 + #define BCMCPU_IS_6362() (bcm63xx_get_cpu_id() == BCM6362_CPU_ID) 83 + #define BCMCPU_IS_6368() (bcm63xx_get_cpu_id() == BCM6368_CPU_ID) 134 84 135 85 /* 136 86 * While registers sets are (mostly) the same across 63xx CPU, base ··· 548 598 549 599 extern const unsigned long *bcm63xx_regs_base; 550 600 551 - #define __GEN_RSET_BASE(__cpu, __rset) \ 552 - case RSET_## __rset : \ 553 - return BCM_## __cpu ##_## __rset ##_BASE; 554 - 555 - #define __GEN_RSET(__cpu) \ 556 - switch (set) { \ 557 - __GEN_RSET_BASE(__cpu, DSL_LMEM) \ 558 - __GEN_RSET_BASE(__cpu, PERF) \ 559 - __GEN_RSET_BASE(__cpu, TIMER) \ 560 - __GEN_RSET_BASE(__cpu, WDT) \ 561 - __GEN_RSET_BASE(__cpu, UART0) \ 562 - __GEN_RSET_BASE(__cpu, UART1) \ 563 - __GEN_RSET_BASE(__cpu, GPIO) \ 564 - __GEN_RSET_BASE(__cpu, SPI) \ 565 - __GEN_RSET_BASE(__cpu, HSSPI) \ 566 - __GEN_RSET_BASE(__cpu, UDC0) \ 567 - __GEN_RSET_BASE(__cpu, OHCI0) \ 568 - __GEN_RSET_BASE(__cpu, OHCI_PRIV) \ 569 - __GEN_RSET_BASE(__cpu, USBH_PRIV) \ 570 - __GEN_RSET_BASE(__cpu, USBD) \ 571 - __GEN_RSET_BASE(__cpu, USBDMA) \ 572 - __GEN_RSET_BASE(__cpu, MPI) \ 573 - __GEN_RSET_BASE(__cpu, PCMCIA) \ 574 - __GEN_RSET_BASE(__cpu, PCIE) \ 575 - __GEN_RSET_BASE(__cpu, DSL) \ 576 - __GEN_RSET_BASE(__cpu, ENET0) \ 577 - __GEN_RSET_BASE(__cpu, ENET1) \ 578 - __GEN_RSET_BASE(__cpu, ENETDMA) \ 579 - __GEN_RSET_BASE(__cpu, ENETDMAC) \ 580 - __GEN_RSET_BASE(__cpu, ENETDMAS) \ 581 - __GEN_RSET_BASE(__cpu, ENETSW) \ 582 - __GEN_RSET_BASE(__cpu, EHCI0) \ 583 - __GEN_RSET_BASE(__cpu, SDRAM) \ 584 - __GEN_RSET_BASE(__cpu, MEMC) \ 585 - __GEN_RSET_BASE(__cpu, DDR) \ 586 - __GEN_RSET_BASE(__cpu, M2M) \ 587 - __GEN_RSET_BASE(__cpu, ATM) \ 588 - __GEN_RSET_BASE(__cpu, XTM) \ 589 - __GEN_RSET_BASE(__cpu, XTMDMA) \ 590 - __GEN_RSET_BASE(__cpu, XTMDMAC) \ 591 - __GEN_RSET_BASE(__cpu, XTMDMAS) \ 592 - __GEN_RSET_BASE(__cpu, PCM) \ 593 - __GEN_RSET_BASE(__cpu, PCMDMA) \ 594 - __GEN_RSET_BASE(__cpu, PCMDMAC) \ 595 - __GEN_RSET_BASE(__cpu, PCMDMAS) \ 596 - __GEN_RSET_BASE(__cpu, RNG) \ 597 - __GEN_RSET_BASE(__cpu, MISC) \ 598 - } 599 - 600 601 #define __GEN_CPU_REGS_TABLE(__cpu) \ 601 602 [RSET_DSL_LMEM] = BCM_## __cpu ##_DSL_LMEM_BASE, \ 602 603 [RSET_PERF] = BCM_## __cpu ##_PERF_BASE, \ ··· 594 693 595 694 static inline unsigned long bcm63xx_regset_address(enum bcm63xx_regs_set set) 596 695 { 597 - #ifdef BCMCPU_RUNTIME_DETECT 598 696 return bcm63xx_regs_base[set]; 599 - #else 600 - #ifdef CONFIG_BCM63XX_CPU_3368 601 - __GEN_RSET(3368) 602 - #endif 603 - #ifdef CONFIG_BCM63XX_CPU_6328 604 - __GEN_RSET(6328) 605 - #endif 606 - #ifdef CONFIG_BCM63XX_CPU_6338 607 - __GEN_RSET(6338) 608 - #endif 609 - #ifdef CONFIG_BCM63XX_CPU_6345 610 - __GEN_RSET(6345) 611 - #endif 612 - #ifdef CONFIG_BCM63XX_CPU_6348 613 - __GEN_RSET(6348) 614 - #endif 615 - #ifdef CONFIG_BCM63XX_CPU_6358 616 - __GEN_RSET(6358) 617 - #endif 618 - #ifdef CONFIG_BCM63XX_CPU_6362 619 - __GEN_RSET(6362) 620 - #endif 621 - #ifdef CONFIG_BCM63XX_CPU_6368 622 - __GEN_RSET(6368) 623 - #endif 624 - #endif 625 - /* unreached */ 626 - return 0; 627 697 } 628 698 629 699 /*
-46
arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_enet.h
··· 112 112 113 113 static inline unsigned long bcm63xx_enetdmacreg(enum bcm63xx_regs_enetdmac reg) 114 114 { 115 - #ifdef BCMCPU_RUNTIME_DETECT 116 115 extern const unsigned long *bcm63xx_regs_enetdmac; 117 116 118 117 return bcm63xx_regs_enetdmac[reg]; 119 - #else 120 - #ifdef CONFIG_BCM63XX_CPU_6345 121 - switch (reg) { 122 - case ENETDMAC_CHANCFG: 123 - return ENETDMA_6345_CHANCFG_REG; 124 - case ENETDMAC_IR: 125 - return ENETDMA_6345_IR_REG; 126 - case ENETDMAC_IRMASK: 127 - return ENETDMA_6345_IRMASK_REG; 128 - case ENETDMAC_MAXBURST: 129 - return ENETDMA_6345_MAXBURST_REG; 130 - case ENETDMAC_BUFALLOC: 131 - return ENETDMA_6345_BUFALLOC_REG; 132 - case ENETDMAC_RSTART: 133 - return ENETDMA_6345_RSTART_REG; 134 - case ENETDMAC_FC: 135 - return ENETDMA_6345_FC_REG; 136 - case ENETDMAC_LEN: 137 - return ENETDMA_6345_LEN_REG; 138 - } 139 - #endif 140 - #if defined(CONFIG_BCM63XX_CPU_6328) || \ 141 - defined(CONFIG_BCM63XX_CPU_6338) || \ 142 - defined(CONFIG_BCM63XX_CPU_6348) || \ 143 - defined(CONFIG_BCM63XX_CPU_6358) || \ 144 - defined(CONFIG_BCM63XX_CPU_6362) || \ 145 - defined(CONFIG_BCM63XX_CPU_6368) 146 - switch (reg) { 147 - case ENETDMAC_CHANCFG: 148 - return ENETDMAC_CHANCFG_REG; 149 - case ENETDMAC_IR: 150 - return ENETDMAC_IR_REG; 151 - case ENETDMAC_IRMASK: 152 - return ENETDMAC_IRMASK_REG; 153 - case ENETDMAC_MAXBURST: 154 - return ENETDMAC_MAXBURST_REG; 155 - case ENETDMAC_BUFALLOC: 156 - case ENETDMAC_RSTART: 157 - case ENETDMAC_FC: 158 - case ENETDMAC_LEN: 159 - return 0; 160 - } 161 - #endif 162 - #endif 163 - return 0; 164 118 } 165 119 166 120
-31
arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_spi.h
··· 30 30 SPI_RX_DATA, 31 31 }; 32 32 33 - #define __GEN_SPI_RSET_BASE(__cpu, __rset) \ 34 - case SPI_## __rset: \ 35 - return SPI_## __cpu ##_## __rset; 36 - 37 - #define __GEN_SPI_RSET(__cpu) \ 38 - switch (reg) { \ 39 - __GEN_SPI_RSET_BASE(__cpu, CMD) \ 40 - __GEN_SPI_RSET_BASE(__cpu, INT_STATUS) \ 41 - __GEN_SPI_RSET_BASE(__cpu, INT_MASK_ST) \ 42 - __GEN_SPI_RSET_BASE(__cpu, INT_MASK) \ 43 - __GEN_SPI_RSET_BASE(__cpu, ST) \ 44 - __GEN_SPI_RSET_BASE(__cpu, CLK_CFG) \ 45 - __GEN_SPI_RSET_BASE(__cpu, FILL_BYTE) \ 46 - __GEN_SPI_RSET_BASE(__cpu, MSG_TAIL) \ 47 - __GEN_SPI_RSET_BASE(__cpu, RX_TAIL) \ 48 - __GEN_SPI_RSET_BASE(__cpu, MSG_CTL) \ 49 - __GEN_SPI_RSET_BASE(__cpu, MSG_DATA) \ 50 - __GEN_SPI_RSET_BASE(__cpu, RX_DATA) \ 51 - } 52 - 53 33 #define __GEN_SPI_REGS_TABLE(__cpu) \ 54 34 [SPI_CMD] = SPI_## __cpu ##_CMD, \ 55 35 [SPI_INT_STATUS] = SPI_## __cpu ##_INT_STATUS, \ ··· 46 66 47 67 static inline unsigned long bcm63xx_spireg(enum bcm63xx_regs_spi reg) 48 68 { 49 - #ifdef BCMCPU_RUNTIME_DETECT 50 69 extern const unsigned long *bcm63xx_regs_spi; 51 70 52 71 return bcm63xx_regs_spi[reg]; 53 - #else 54 - #if defined(CONFIG_BCM63XX_CPU_6338) || defined(CONFIG_BCM63XX_CPU_6348) 55 - __GEN_SPI_RSET(6348) 56 - #endif 57 - #if defined(CONFIG_BCM63XX_CPU_6358) || defined(CONFIG_BCM63XX_CPU_6362) || \ 58 - defined(CONFIG_BCM63XX_CPU_6368) 59 - __GEN_SPI_RSET(6358) 60 - #endif 61 - #endif 62 - return 0; 63 72 } 64 73 65 74 #endif /* BCM63XX_DEV_SPI_H */
+8 -8
arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h
··· 215 215 216 216 /* Interrupt Mask register */ 217 217 #define PERF_IRQMASK_3368_REG 0xc 218 - #define PERF_IRQMASK_6328_REG 0x20 218 + #define PERF_IRQMASK_6328_REG(x) (0x20 + (x) * 0x10) 219 219 #define PERF_IRQMASK_6338_REG 0xc 220 220 #define PERF_IRQMASK_6345_REG 0xc 221 221 #define PERF_IRQMASK_6348_REG 0xc 222 - #define PERF_IRQMASK_6358_REG 0xc 223 - #define PERF_IRQMASK_6362_REG 0x20 224 - #define PERF_IRQMASK_6368_REG 0x20 222 + #define PERF_IRQMASK_6358_REG(x) (0xc + (x) * 0x2c) 223 + #define PERF_IRQMASK_6362_REG(x) (0x20 + (x) * 0x10) 224 + #define PERF_IRQMASK_6368_REG(x) (0x20 + (x) * 0x10) 225 225 226 226 /* Interrupt Status register */ 227 227 #define PERF_IRQSTAT_3368_REG 0x10 228 - #define PERF_IRQSTAT_6328_REG 0x28 228 + #define PERF_IRQSTAT_6328_REG(x) (0x28 + (x) * 0x10) 229 229 #define PERF_IRQSTAT_6338_REG 0x10 230 230 #define PERF_IRQSTAT_6345_REG 0x10 231 231 #define PERF_IRQSTAT_6348_REG 0x10 232 - #define PERF_IRQSTAT_6358_REG 0x10 233 - #define PERF_IRQSTAT_6362_REG 0x28 234 - #define PERF_IRQSTAT_6368_REG 0x28 232 + #define PERF_IRQSTAT_6358_REG(x) (0x10 + (x) * 0x2c) 233 + #define PERF_IRQSTAT_6362_REG(x) (0x28 + (x) * 0x10) 234 + #define PERF_IRQSTAT_6368_REG(x) (0x28 + (x) * 0x10) 235 235 236 236 /* External Interrupt Configuration register */ 237 237 #define PERF_EXTIRQ_CFG_REG_3368 0x14
+1 -1
arch/mips/include/asm/mach-bcm63xx/cpu-feature-overrides.h
··· 24 24 #define cpu_has_smartmips 0 25 25 #define cpu_has_vtag_icache 0 26 26 27 - #if !defined(BCMCPU_RUNTIME_DETECT) && (defined(CONFIG_BCM63XX_CPU_6348) || defined(CONFIG_BCM63XX_CPU_6345) || defined(CONFIG_BCM63XX_CPU_6338)) 27 + #if !defined(CONFIG_SYS_HAS_CPU_BMIPS4350) 28 28 #define cpu_has_dc_aliases 0 29 29 #endif 30 30
+4
arch/mips/include/asm/mach-loongson/boot_param.h
··· 146 146 147 147 struct loongson_system_configuration { 148 148 u32 nr_cpus; 149 + u32 nr_nodes; 150 + int cores_per_node; 151 + int cores_per_package; 149 152 enum loongson_cpu_type cputype; 150 153 u64 ht_control_base; 151 154 u64 pci_mem_start_addr; ··· 163 160 164 161 extern struct efi_memory_map_loongson *loongson_memmap; 165 162 extern struct loongson_system_configuration loongson_sysconf; 163 + extern int cpuhotplug_workaround; 166 164 #endif
+52
arch/mips/include/asm/mach-loongson/kernel-entry-init.h
··· 1 + /* 2 + * This file is subject to the terms and conditions of the GNU General Public 3 + * License. See the file "COPYING" in the main directory of this archive 4 + * for more details. 5 + * 6 + * Copyright (C) 2005 Embedded Alley Solutions, Inc 7 + * Copyright (C) 2005 Ralf Baechle (ralf@linux-mips.org) 8 + * Copyright (C) 2009 Jiajie Chen (chenjiajie@cse.buaa.edu.cn) 9 + * Copyright (C) 2012 Huacai Chen (chenhc@lemote.com) 10 + */ 11 + #ifndef __ASM_MACH_LOONGSON_KERNEL_ENTRY_H 12 + #define __ASM_MACH_LOONGSON_KERNEL_ENTRY_H 13 + 14 + /* 15 + * Override macros used in arch/mips/kernel/head.S. 16 + */ 17 + .macro kernel_entry_setup 18 + #ifdef CONFIG_CPU_LOONGSON3 19 + .set push 20 + .set mips64 21 + /* Set LPA on LOONGSON3 config3 */ 22 + mfc0 t0, $16, 3 23 + or t0, (0x1 << 7) 24 + mtc0 t0, $16, 3 25 + /* Set ELPA on LOONGSON3 pagegrain */ 26 + li t0, (0x1 << 29) 27 + mtc0 t0, $5, 1 28 + _ehb 29 + .set pop 30 + #endif 31 + .endm 32 + 33 + /* 34 + * Do SMP slave processor setup. 35 + */ 36 + .macro smp_slave_setup 37 + #ifdef CONFIG_CPU_LOONGSON3 38 + .set push 39 + .set mips64 40 + /* Set LPA on LOONGSON3 config3 */ 41 + mfc0 t0, $16, 3 42 + or t0, (0x1 << 7) 43 + mtc0 t0, $16, 3 44 + /* Set ELPA on LOONGSON3 pagegrain */ 45 + li t0, (0x1 << 29) 46 + mtc0 t0, $5, 1 47 + _ehb 48 + .set pop 49 + #endif 50 + .endm 51 + 52 + #endif /* __ASM_MACH_LOONGSON_KERNEL_ENTRY_H */
+9 -2
arch/mips/include/asm/mach-loongson/loongson.h
··· 249 249 #define LOONGSON_PXARB_CFG LOONGSON_REG(LOONGSON_REGBASE + 0x68) 250 250 #define LOONGSON_PXARB_STATUS LOONGSON_REG(LOONGSON_REGBASE + 0x6c) 251 251 252 - /* Chip Config */ 253 - #define LOONGSON_CHIPCFG0 LOONGSON_REG(LOONGSON_REGBASE + 0x80) 252 + #define MAX_PACKAGES 4 253 + 254 + /* Chip Config registor of each physical cpu package, PRid >= Loongson-2F */ 255 + extern u64 loongson_chipcfg[MAX_PACKAGES]; 256 + #define LOONGSON_CHIPCFG(id) (*(volatile u32 *)(loongson_chipcfg[id])) 257 + 258 + /* Freq Control register of each physical cpu package, PRid >= Loongson-3B */ 259 + extern u64 loongson_freqctrl[MAX_PACKAGES]; 260 + #define LOONGSON_FREQCTRL(id) (*(volatile u32 *)(loongson_freqctrl[id])) 254 261 255 262 /* pcimap */ 256 263
+2 -2
arch/mips/include/asm/mach-loongson/machine.h
··· 24 24 25 25 #endif 26 26 27 - #ifdef CONFIG_LEMOTE_MACH3A 27 + #ifdef CONFIG_LOONGSON_MACH3X 28 28 29 29 #define LOONGSON_MACHTYPE MACH_LEMOTE_A1101 30 30 31 - #endif /* CONFIG_LEMOTE_MACH3A */ 31 + #endif /* CONFIG_LOONGSON_MACH3X */ 32 32 33 33 #endif /* __ASM_MACH_LOONGSON_MACHINE_H */
+53
arch/mips/include/asm/mach-loongson/mmzone.h
··· 1 + /* 2 + * Copyright (C) 2010 Loongson Inc. & Lemote Inc. & 3 + * Insititute of Computing Technology 4 + * Author: Xiang Gao, gaoxiang@ict.ac.cn 5 + * Huacai Chen, chenhc@lemote.com 6 + * Xiaofu Meng, Shuangshuang Zhang 7 + * 8 + * This program is free software; you can redistribute it and/or modify it 9 + * under the terms of the GNU General Public License as published by the 10 + * Free Software Foundation; either version 2 of the License, or (at your 11 + * option) any later version. 12 + */ 13 + #ifndef _ASM_MACH_MMZONE_H 14 + #define _ASM_MACH_MMZONE_H 15 + 16 + #include <boot_param.h> 17 + #define NODE_ADDRSPACE_SHIFT 44 18 + #define NODE0_ADDRSPACE_OFFSET 0x000000000000UL 19 + #define NODE1_ADDRSPACE_OFFSET 0x100000000000UL 20 + #define NODE2_ADDRSPACE_OFFSET 0x200000000000UL 21 + #define NODE3_ADDRSPACE_OFFSET 0x300000000000UL 22 + 23 + #define pa_to_nid(addr) (((addr) & 0xf00000000000) >> NODE_ADDRSPACE_SHIFT) 24 + 25 + #define LEVELS_PER_SLICE 128 26 + 27 + struct slice_data { 28 + unsigned long irq_enable_mask[2]; 29 + int level_to_irq[LEVELS_PER_SLICE]; 30 + }; 31 + 32 + struct hub_data { 33 + cpumask_t h_cpus; 34 + unsigned long slice_map; 35 + unsigned long irq_alloc_mask[2]; 36 + struct slice_data slice[2]; 37 + }; 38 + 39 + struct node_data { 40 + struct pglist_data pglist; 41 + struct hub_data hub; 42 + cpumask_t cpumask; 43 + }; 44 + 45 + extern struct node_data *__node_data[]; 46 + 47 + #define NODE_DATA(n) (&__node_data[(n)]->pglist) 48 + #define hub_data(n) (&__node_data[(n)]->hub) 49 + 50 + extern void setup_zero_pages(void); 51 + extern void __init prom_init_numa_memory(void); 52 + 53 + #endif /* _ASM_MACH_MMZONE_H */
+23
arch/mips/include/asm/mach-loongson/topology.h
··· 1 + #ifndef _ASM_MACH_TOPOLOGY_H 2 + #define _ASM_MACH_TOPOLOGY_H 3 + 4 + #ifdef CONFIG_NUMA 5 + 6 + #define cpu_to_node(cpu) ((cpu) >> 2) 7 + #define parent_node(node) (node) 8 + #define cpumask_of_node(node) (&__node_data[(node)]->cpumask) 9 + 10 + struct pci_bus; 11 + extern int pcibus_to_node(struct pci_bus *); 12 + 13 + #define cpumask_of_pcibus(bus) (cpu_online_mask) 14 + 15 + extern unsigned char __node_distances[MAX_NUMNODES][MAX_NUMNODES]; 16 + 17 + #define node_distance(from, to) (__node_distances[(from)][(to)]) 18 + 19 + #endif 20 + 21 + #include <asm-generic/topology.h> 22 + 23 + #endif /* _ASM_MACH_TOPOLOGY_H */
+1
arch/mips/include/asm/mach-malta/irq.h
··· 2 2 #define __ASM_MACH_MIPS_IRQ_H 3 3 4 4 5 + #define GIC_NUM_INTRS (24 + NR_CPUS * 2) 5 6 #define NR_IRQS 256 6 7 7 8 #include_next <irq.h>
+1
arch/mips/include/asm/mach-sead3/irq.h
··· 1 1 #ifndef __ASM_MACH_MIPS_IRQ_H 2 2 #define __ASM_MACH_MIPS_IRQ_H 3 3 4 + #define GIC_NUM_INTRS (24 + NR_CPUS * 2) 4 5 #define NR_IRQS 256 5 6 6 7
-1
arch/mips/include/asm/mips-boards/bonito64.h
··· 414 414 415 415 416 416 #define BONITO_PCIMEMBASECFG_ADDRMASK(WIN, CFG) ((((CFG) & BONITO_PCIMEMBASECFG_MEMBASE##WIN##_MASK) >> BONITO_PCIMEMBASECFG_MEMBASE##WIN##_MASK_SHIFT) << BONITO_PCIMEMBASECFG_ASHIFT) 417 - #define BONITO_PCIMEMBASECFG_ADDRMASK(WIN, CFG) ((((CFG) & BONITO_PCIMEMBASECFG_MEMBASE##WIN##_MASK) >> BONITO_PCIMEMBASECFG_MEMBASE##WIN##_MASK_SHIFT) << BONITO_PCIMEMBASECFG_ASHIFT) 418 417 #define BONITO_PCIMEMBASECFG_ADDRTRANS(WIN, CFG) ((((CFG) & BONITO_PCIMEMBASECFG_MEMBASE##WIN##_TRANS) >> BONITO_PCIMEMBASECFG_MEMBASE##WIN##_TRANS_SHIFT) << BONITO_PCIMEMBASECFG_ASHIFT) 419 418 420 419 #define BONITO_PCITOPHYS(WIN, ADDR, CFG) ( \
+57 -1
arch/mips/include/asm/mipsregs.h
··· 265 265 #define PG_XIE (_ULCAST_(1) << 30) 266 266 #define PG_ELPA (_ULCAST_(1) << 29) 267 267 #define PG_ESP (_ULCAST_(1) << 28) 268 + #define PG_IEC (_ULCAST_(1) << 27) 268 269 269 270 /* 270 271 * R4x00 interrupt enable / cause bits ··· 631 630 #define MIPS_CONF4_MMUSIZEEXT_SHIFT (0) 632 631 #define MIPS_CONF4_MMUSIZEEXT (_ULCAST_(255) << 0) 633 632 #define MIPS_CONF4_FTLBSETS_SHIFT (0) 634 - #define MIPS_CONF4_FTLBSETS_SHIFT (0) 635 633 #define MIPS_CONF4_FTLBSETS (_ULCAST_(15) << MIPS_CONF4_FTLBSETS_SHIFT) 636 634 #define MIPS_CONF4_FTLBWAYS_SHIFT (4) 637 635 #define MIPS_CONF4_FTLBWAYS (_ULCAST_(15) << MIPS_CONF4_FTLBWAYS_SHIFT) ··· 652 652 653 653 #define MIPS_CONF5_NF (_ULCAST_(1) << 0) 654 654 #define MIPS_CONF5_UFR (_ULCAST_(1) << 2) 655 + #define MIPS_CONF5_MRP (_ULCAST_(1) << 3) 655 656 #define MIPS_CONF5_MSAEN (_ULCAST_(1) << 27) 656 657 #define MIPS_CONF5_EVA (_ULCAST_(1) << 28) 657 658 #define MIPS_CONF5_CV (_ULCAST_(1) << 29) ··· 668 667 669 668 #define MIPS_CONF7_IAR (_ULCAST_(1) << 10) 670 669 #define MIPS_CONF7_AR (_ULCAST_(1) << 16) 670 + 671 + /* MAAR bit definitions */ 672 + #define MIPS_MAAR_ADDR ((BIT_ULL(BITS_PER_LONG - 12) - 1) << 12) 673 + #define MIPS_MAAR_ADDR_SHIFT 12 674 + #define MIPS_MAAR_S (_ULCAST_(1) << 1) 675 + #define MIPS_MAAR_V (_ULCAST_(1) << 0) 671 676 672 677 /* EntryHI bit definition */ 673 678 #define MIPS_ENTRYHI_EHINV (_ULCAST_(1) << 10) ··· 712 705 #define MIPS_SEGCFG_MSK _ULCAST_(2) 713 706 #define MIPS_SEGCFG_MK _ULCAST_(1) 714 707 #define MIPS_SEGCFG_UK _ULCAST_(0) 708 + 709 + #define MIPS_PWFIELD_GDI_SHIFT 24 710 + #define MIPS_PWFIELD_GDI_MASK 0x3f000000 711 + #define MIPS_PWFIELD_UDI_SHIFT 18 712 + #define MIPS_PWFIELD_UDI_MASK 0x00fc0000 713 + #define MIPS_PWFIELD_MDI_SHIFT 12 714 + #define MIPS_PWFIELD_MDI_MASK 0x0003f000 715 + #define MIPS_PWFIELD_PTI_SHIFT 6 716 + #define MIPS_PWFIELD_PTI_MASK 0x00000fc0 717 + #define MIPS_PWFIELD_PTEI_SHIFT 0 718 + #define MIPS_PWFIELD_PTEI_MASK 0x0000003f 719 + 720 + #define MIPS_PWSIZE_GDW_SHIFT 24 721 + #define MIPS_PWSIZE_GDW_MASK 0x3f000000 722 + #define MIPS_PWSIZE_UDW_SHIFT 18 723 + #define MIPS_PWSIZE_UDW_MASK 0x00fc0000 724 + #define MIPS_PWSIZE_MDW_SHIFT 12 725 + #define MIPS_PWSIZE_MDW_MASK 0x0003f000 726 + #define MIPS_PWSIZE_PTW_SHIFT 6 727 + #define MIPS_PWSIZE_PTW_MASK 0x00000fc0 728 + #define MIPS_PWSIZE_PTEW_SHIFT 0 729 + #define MIPS_PWSIZE_PTEW_MASK 0x0000003f 730 + 731 + #define MIPS_PWCTL_PWEN_SHIFT 31 732 + #define MIPS_PWCTL_PWEN_MASK 0x80000000 733 + #define MIPS_PWCTL_DPH_SHIFT 7 734 + #define MIPS_PWCTL_DPH_MASK 0x00000080 735 + #define MIPS_PWCTL_HUGEPG_SHIFT 6 736 + #define MIPS_PWCTL_HUGEPG_MASK 0x00000060 737 + #define MIPS_PWCTL_PSN_SHIFT 0 738 + #define MIPS_PWCTL_PSN_MASK 0x0000003f 715 739 716 740 #ifndef __ASSEMBLY__ 717 741 ··· 1082 1044 #define write_c0_config6(val) __write_32bit_c0_register($16, 6, val) 1083 1045 #define write_c0_config7(val) __write_32bit_c0_register($16, 7, val) 1084 1046 1047 + #define read_c0_maar() __read_ulong_c0_register($17, 1) 1048 + #define write_c0_maar(val) __write_ulong_c0_register($17, 1, val) 1049 + #define read_c0_maari() __read_32bit_c0_register($17, 2) 1050 + #define write_c0_maari(val) __write_32bit_c0_register($17, 2, val) 1051 + 1085 1052 /* 1086 1053 * The WatchLo register. There may be up to 8 of them. 1087 1054 */ ··· 1243 1200 1244 1201 #define read_c0_segctl2() __read_32bit_c0_register($5, 4) 1245 1202 #define write_c0_segctl2(val) __write_32bit_c0_register($5, 4, val) 1203 + 1204 + /* Hardware Page Table Walker */ 1205 + #define read_c0_pwbase() __read_ulong_c0_register($5, 5) 1206 + #define write_c0_pwbase(val) __write_ulong_c0_register($5, 5, val) 1207 + 1208 + #define read_c0_pwfield() __read_ulong_c0_register($5, 6) 1209 + #define write_c0_pwfield(val) __write_ulong_c0_register($5, 6, val) 1210 + 1211 + #define read_c0_pwsize() __read_ulong_c0_register($5, 7) 1212 + #define write_c0_pwsize(val) __write_ulong_c0_register($5, 7, val) 1213 + 1214 + #define read_c0_pwctl() __read_32bit_c0_register($6, 6) 1215 + #define write_c0_pwctl(val) __write_32bit_c0_register($6, 6, val) 1246 1216 1247 1217 /* Cavium OCTEON (cnMIPS) */ 1248 1218 #define read_c0_cvmcount() __read_ulong_c0_register($9, 6)
+10
arch/mips/include/asm/mmu_context.h
··· 20 20 #include <asm/tlbflush.h> 21 21 #include <asm-generic/mm_hooks.h> 22 22 23 + #define htw_set_pwbase(pgd) \ 24 + do { \ 25 + if (cpu_has_htw) { \ 26 + write_c0_pwbase(pgd); \ 27 + back_to_back_c0_hazard(); \ 28 + htw_reset(); \ 29 + } \ 30 + } while (0) 31 + 23 32 #define TLBMISS_HANDLER_SETUP_PGD(pgd) \ 24 33 do { \ 25 34 extern void tlbmiss_handler_setup_pgd(unsigned long); \ 26 35 tlbmiss_handler_setup_pgd((unsigned long)(pgd)); \ 36 + htw_set_pwbase((unsigned long)pgd); \ 27 37 } while (0) 28 38 29 39 #ifdef CONFIG_MIPS_PGD_C0_CONTEXT
+18 -13
arch/mips/include/asm/msa.h
··· 12 12 13 13 #include <asm/mipsregs.h> 14 14 15 + #ifndef __ASSEMBLY__ 16 + 15 17 extern void _save_msa(struct task_struct *); 16 18 extern void _restore_msa(struct task_struct *); 19 + extern void _init_msa_upper(void); 17 20 18 21 static inline void enable_msa(void) 19 22 { ··· 115 112 " .set push\n" \ 116 113 " .set noat\n" \ 117 114 " .insn\n" \ 118 - " .word #CFC_MSA_INSN | (" #cs " << 11)\n" \ 115 + " .word %1 | (" #cs " << 11)\n" \ 119 116 " move %0, $1\n" \ 120 117 " .set pop\n" \ 121 - : "=r"(reg)); \ 118 + : "=r"(reg) : "i"(CFC_MSA_INSN)); \ 122 119 return reg; \ 123 120 } \ 124 121 \ ··· 129 126 " .set noat\n" \ 130 127 " move $1, %0\n" \ 131 128 " .insn\n" \ 132 - " .word #CTC_MSA_INSN | (" #cs " << 6)\n" \ 129 + " .word %1 | (" #cs " << 6)\n" \ 133 130 " .set pop\n" \ 134 - : : "r"(val)); \ 131 + : : "r"(val), "i"(CTC_MSA_INSN)); \ 135 132 } 136 133 137 134 #endif /* !TOOLCHAIN_SUPPORTS_MSA */ 138 - 139 - #define MSA_IR 0 140 - #define MSA_CSR 1 141 - #define MSA_ACCESS 2 142 - #define MSA_SAVE 3 143 - #define MSA_MODIFY 4 144 - #define MSA_REQUEST 5 145 - #define MSA_MAP 6 146 - #define MSA_UNMAP 7 147 135 148 136 __BUILD_MSA_CTL_REG(ir, 0) 149 137 __BUILD_MSA_CTL_REG(csr, 1) ··· 144 150 __BUILD_MSA_CTL_REG(request, 5) 145 151 __BUILD_MSA_CTL_REG(map, 6) 146 152 __BUILD_MSA_CTL_REG(unmap, 7) 153 + 154 + #endif /* !__ASSEMBLY__ */ 155 + 156 + #define MSA_IR 0 157 + #define MSA_CSR 1 158 + #define MSA_ACCESS 2 159 + #define MSA_SAVE 3 160 + #define MSA_MODIFY 4 161 + #define MSA_REQUEST 5 162 + #define MSA_MAP 6 163 + #define MSA_UNMAP 7 147 164 148 165 /* MSA Implementation Register (MSAIR) */ 149 166 #define MSA_IR_REVB 0
+2
arch/mips/include/asm/octeon/cvmx-bootinfo.h
··· 228 228 */ 229 229 CVMX_BOARD_TYPE_CUST_PRIVATE_MIN = 20001, 230 230 CVMX_BOARD_TYPE_UBNT_E100 = 20002, 231 + CVMX_BOARD_TYPE_CUST_DSR1000N = 20006, 231 232 CVMX_BOARD_TYPE_CUST_PRIVATE_MAX = 30000, 232 233 233 234 /* The remaining range is reserved for future use. */ ··· 328 327 /* Customer private range */ 329 328 ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_PRIVATE_MIN) 330 329 ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_UBNT_E100) 330 + ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_DSR1000N) 331 331 ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_PRIVATE_MAX) 332 332 } 333 333 return "Unsupported Board";
+12
arch/mips/include/asm/pgtable-32.h
··· 18 18 19 19 #include <asm-generic/pgtable-nopmd.h> 20 20 21 + extern int temp_tlb_entry __cpuinitdata; 22 + 23 + /* 24 + * - add_temporary_entry() add a temporary TLB entry. We use TLB entries 25 + * starting at the top and working down. This is for populating the 26 + * TLB before trap_init() puts the TLB miss handler in place. It 27 + * should be used only for entries matching the actual page tables, 28 + * to prevent inconsistencies. 29 + */ 30 + extern int add_temporary_entry(unsigned long entrylo0, unsigned long entrylo1, 31 + unsigned long entryhi, unsigned long pagemask); 32 + 21 33 /* 22 34 * Basically we have the same two-level (which is the logical three level 23 35 * Linux page table layout folded) page tables as the i386. Some day
+27
arch/mips/include/asm/pgtable.h
··· 97 97 98 98 #define pmd_page_vaddr(pmd) pmd_val(pmd) 99 99 100 + #define htw_stop() \ 101 + do { \ 102 + if (cpu_has_htw) \ 103 + write_c0_pwctl(read_c0_pwctl() & \ 104 + ~(1 << MIPS_PWCTL_PWEN_SHIFT)); \ 105 + } while(0) 106 + 107 + #define htw_start() \ 108 + do { \ 109 + if (cpu_has_htw) \ 110 + write_c0_pwctl(read_c0_pwctl() | \ 111 + (1 << MIPS_PWCTL_PWEN_SHIFT)); \ 112 + } while(0) 113 + 114 + 115 + #define htw_reset() \ 116 + do { \ 117 + if (cpu_has_htw) { \ 118 + htw_stop(); \ 119 + back_to_back_c0_hazard(); \ 120 + htw_start(); \ 121 + back_to_back_c0_hazard(); \ 122 + } \ 123 + } while(0) 124 + 100 125 #if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32) 101 126 102 127 #define pte_none(pte) (!(((pte).pte_low | (pte).pte_high) & ~_PAGE_GLOBAL)) ··· 156 131 null.pte_low = null.pte_high = _PAGE_GLOBAL; 157 132 158 133 set_pte_at(mm, addr, ptep, null); 134 + htw_reset(); 159 135 } 160 136 #else 161 137 ··· 194 168 else 195 169 #endif 196 170 set_pte_at(mm, addr, ptep, __pte(0)); 171 + htw_reset(); 197 172 } 198 173 #endif 199 174
+8 -2
arch/mips/include/asm/processor.h
··· 238 238 unsigned long seg; 239 239 } mm_segment_t; 240 240 241 - #define ARCH_MIN_TASKALIGN 8 241 + #ifdef CONFIG_CPU_HAS_MSA 242 + # define ARCH_MIN_TASKALIGN 16 243 + # define FPU_ALIGN __aligned(16) 244 + #else 245 + # define ARCH_MIN_TASKALIGN 8 246 + # define FPU_ALIGN 247 + #endif 242 248 243 249 struct mips_abi; 244 250 ··· 261 255 unsigned long cp0_status; 262 256 263 257 /* Saved fpu/fpu emulator stuff. */ 264 - struct mips_fpu_struct fpu; 258 + struct mips_fpu_struct fpu FPU_ALIGN; 265 259 #ifdef CONFIG_MIPS_MT_FPAFF 266 260 /* Emulated instruction count */ 267 261 unsigned long emulated_fp;
+5 -3
arch/mips/include/asm/ptrace.h
··· 23 23 struct pt_regs { 24 24 #ifdef CONFIG_32BIT 25 25 /* Pad bytes for argument save space on the stack. */ 26 - unsigned long pad0[6]; 26 + unsigned long pad0[8]; 27 27 #endif 28 28 29 29 /* Saved main processor registers. */ ··· 47 47 48 48 struct task_struct; 49 49 50 - extern int ptrace_getregs(struct task_struct *child, __s64 __user *data); 51 - extern int ptrace_setregs(struct task_struct *child, __s64 __user *data); 50 + extern int ptrace_getregs(struct task_struct *child, 51 + struct user_pt_regs __user *data); 52 + extern int ptrace_setregs(struct task_struct *child, 53 + struct user_pt_regs __user *data); 52 54 53 55 extern int ptrace_getfpregs(struct task_struct *child, __u32 __user *data); 54 56 extern int ptrace_setfpregs(struct task_struct *child, __u32 __user *data);
+1 -128
arch/mips/include/asm/reg.h
··· 1 - /* 2 - * Various register offset definitions for debuggers, core file 3 - * examiners and whatnot. 4 - * 5 - * This file is subject to the terms and conditions of the GNU General Public 6 - * License. See the file "COPYING" in the main directory of this archive 7 - * for more details. 8 - * 9 - * Copyright (C) 1995, 1999 Ralf Baechle 10 - * Copyright (C) 1995, 1999 Silicon Graphics 11 - */ 12 - #ifndef __ASM_MIPS_REG_H 13 - #define __ASM_MIPS_REG_H 14 - 15 - 16 - #if defined(CONFIG_32BIT) || defined(WANT_COMPAT_REG_H) 17 - 18 - #define EF_R0 6 19 - #define EF_R1 7 20 - #define EF_R2 8 21 - #define EF_R3 9 22 - #define EF_R4 10 23 - #define EF_R5 11 24 - #define EF_R6 12 25 - #define EF_R7 13 26 - #define EF_R8 14 27 - #define EF_R9 15 28 - #define EF_R10 16 29 - #define EF_R11 17 30 - #define EF_R12 18 31 - #define EF_R13 19 32 - #define EF_R14 20 33 - #define EF_R15 21 34 - #define EF_R16 22 35 - #define EF_R17 23 36 - #define EF_R18 24 37 - #define EF_R19 25 38 - #define EF_R20 26 39 - #define EF_R21 27 40 - #define EF_R22 28 41 - #define EF_R23 29 42 - #define EF_R24 30 43 - #define EF_R25 31 44 - 45 - /* 46 - * k0/k1 unsaved 47 - */ 48 - #define EF_R26 32 49 - #define EF_R27 33 50 - 51 - #define EF_R28 34 52 - #define EF_R29 35 53 - #define EF_R30 36 54 - #define EF_R31 37 55 - 56 - /* 57 - * Saved special registers 58 - */ 59 - #define EF_LO 38 60 - #define EF_HI 39 61 - 62 - #define EF_CP0_EPC 40 63 - #define EF_CP0_BADVADDR 41 64 - #define EF_CP0_STATUS 42 65 - #define EF_CP0_CAUSE 43 66 - #define EF_UNUSED0 44 67 - 68 - #define EF_SIZE 180 69 - 70 - #endif 71 - 72 - #if defined(CONFIG_64BIT) && !defined(WANT_COMPAT_REG_H) 73 - 74 - #define EF_R0 0 75 - #define EF_R1 1 76 - #define EF_R2 2 77 - #define EF_R3 3 78 - #define EF_R4 4 79 - #define EF_R5 5 80 - #define EF_R6 6 81 - #define EF_R7 7 82 - #define EF_R8 8 83 - #define EF_R9 9 84 - #define EF_R10 10 85 - #define EF_R11 11 86 - #define EF_R12 12 87 - #define EF_R13 13 88 - #define EF_R14 14 89 - #define EF_R15 15 90 - #define EF_R16 16 91 - #define EF_R17 17 92 - #define EF_R18 18 93 - #define EF_R19 19 94 - #define EF_R20 20 95 - #define EF_R21 21 96 - #define EF_R22 22 97 - #define EF_R23 23 98 - #define EF_R24 24 99 - #define EF_R25 25 100 - 101 - /* 102 - * k0/k1 unsaved 103 - */ 104 - #define EF_R26 26 105 - #define EF_R27 27 106 - 107 - 108 - #define EF_R28 28 109 - #define EF_R29 29 110 - #define EF_R30 30 111 - #define EF_R31 31 112 - 113 - /* 114 - * Saved special registers 115 - */ 116 - #define EF_LO 32 117 - #define EF_HI 33 118 - 119 - #define EF_CP0_EPC 34 120 - #define EF_CP0_BADVADDR 35 121 - #define EF_CP0_STATUS 36 122 - #define EF_CP0_CAUSE 37 123 - 124 - #define EF_SIZE 304 /* size in bytes */ 125 - 126 - #endif /* CONFIG_64BIT */ 127 - 128 - #endif /* __ASM_MIPS_REG_H */ 1 + #include <uapi/asm/reg.h>
+10 -2
arch/mips/include/asm/smp-cps.h
··· 31 31 32 32 extern struct vpe_boot_config *mips_cps_boot_vpes(void); 33 33 34 - extern bool mips_cps_smp_in_use(void); 35 - 36 34 extern void mips_cps_pm_save(void); 37 35 extern void mips_cps_pm_restore(void); 36 + 37 + #ifdef CONFIG_MIPS_CPS 38 + 39 + extern bool mips_cps_smp_in_use(void); 40 + 41 + #else /* !CONFIG_MIPS_CPS */ 42 + 43 + static inline bool mips_cps_smp_in_use(void) { return false; } 44 + 45 + #endif /* !CONFIG_MIPS_CPS */ 38 46 39 47 #else /* __ASSEMBLY__ */ 40 48
+6
arch/mips/include/asm/smp.h
··· 22 22 23 23 extern int smp_num_siblings; 24 24 extern cpumask_t cpu_sibling_map[]; 25 + extern cpumask_t cpu_core_map[]; 25 26 26 27 #define raw_smp_processor_id() (current_thread_info()->cpu) 27 28 ··· 36 35 #define cpu_logical_map(cpu) __cpu_logical_map[cpu] 37 36 38 37 #define NO_PROC_ID (-1) 38 + 39 + #define topology_physical_package_id(cpu) (cpu_data[cpu].package) 40 + #define topology_core_id(cpu) (cpu_data[cpu].core) 41 + #define topology_core_cpumask(cpu) (&cpu_core_map[cpu]) 42 + #define topology_thread_cpumask(cpu) (&cpu_sibling_map[cpu]) 39 43 40 44 #define SMP_RESCHEDULE_YOURSELF 0x1 /* XXX braindead */ 41 45 #define SMP_CALL_FUNCTION 0x2
+1 -1
arch/mips/include/asm/sparsemem.h
··· 11 11 #else 12 12 # define SECTION_SIZE_BITS 28 13 13 #endif 14 - #define MAX_PHYSMEM_BITS 35 14 + #define MAX_PHYSMEM_BITS 48 15 15 16 16 #endif /* CONFIG_SPARSEMEM */ 17 17 #endif /* _MIPS_SPARSEMEM_H */
-58
arch/mips/include/asm/user.h
··· 1 - /* 2 - * This file is subject to the terms and conditions of the GNU General Public 3 - * License. See the file "COPYING" in the main directory of this archive 4 - * for more details. 5 - * 6 - * Copyright (C) 1994, 1995, 1996, 1999 by Ralf Baechle 7 - */ 8 - #ifndef _ASM_USER_H 9 - #define _ASM_USER_H 10 - 11 - #include <asm/page.h> 12 - #include <asm/reg.h> 13 - 14 - /* 15 - * Core file format: The core file is written in such a way that gdb 16 - * can understand it and provide useful information to the user (under 17 - * linux we use the `trad-core' bfd, NOT the irix-core). The file 18 - * contents are as follows: 19 - * 20 - * upage: 1 page consisting of a user struct that tells gdb 21 - * what is present in the file. Directly after this is a 22 - * copy of the task_struct, which is currently not used by gdb, 23 - * but it may come in handy at some point. All of the registers 24 - * are stored as part of the upage. The upage should always be 25 - * only one page long. 26 - * data: The data segment follows next. We use current->end_text to 27 - * current->brk to pick up all of the user variables, plus any memory 28 - * that may have been sbrk'ed. No attempt is made to determine if a 29 - * page is demand-zero or if a page is totally unused, we just cover 30 - * the entire range. All of the addresses are rounded in such a way 31 - * that an integral number of pages is written. 32 - * stack: We need the stack information in order to get a meaningful 33 - * backtrace. We need to write the data from usp to 34 - * current->start_stack, so we round each of these in order to be able 35 - * to write an integer number of pages. 36 - */ 37 - struct user { 38 - unsigned long regs[EF_SIZE / /* integer and fp regs */ 39 - sizeof(unsigned long) + 64]; 40 - size_t u_tsize; /* text size (pages) */ 41 - size_t u_dsize; /* data size (pages) */ 42 - size_t u_ssize; /* stack size (pages) */ 43 - unsigned long start_code; /* text starting address */ 44 - unsigned long start_data; /* data starting address */ 45 - unsigned long start_stack; /* stack starting address */ 46 - long int signal; /* signal causing core dump */ 47 - unsigned long u_ar0; /* help gdb find registers */ 48 - unsigned long magic; /* identifies a core file */ 49 - char u_comm[32]; /* user command name */ 50 - }; 51 - 52 - #define NBPG PAGE_SIZE 53 - #define UPAGES 1 54 - #define HOST_TEXT_START_ADDR (u.start_code) 55 - #define HOST_DATA_START_ADDR (u.start_data) 56 - #define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG) 57 - 58 - #endif /* _ASM_USER_H */
+14 -11
arch/mips/include/uapi/asm/ptrace.h
··· 22 22 #define DSP_CONTROL 77 23 23 #define ACX 78 24 24 25 - #ifndef __KERNEL__ 26 25 /* 27 - * This struct defines the way the registers are stored on the stack during a 28 - * system call/exception. As usual the registers k0/k1 aren't being saved. 26 + * This struct defines the registers as used by PTRACE_{GET,SET}REGS. The 27 + * format is the same for both 32- and 64-bit processes. Registers for 32-bit 28 + * processes are sign extended. 29 29 */ 30 + #ifdef __KERNEL__ 31 + struct user_pt_regs { 32 + #else 30 33 struct pt_regs { 34 + #endif 31 35 /* Saved main processor registers. */ 32 - unsigned long regs[32]; 36 + __u64 regs[32]; 33 37 34 38 /* Saved special registers. */ 35 - unsigned long cp0_status; 36 - unsigned long hi; 37 - unsigned long lo; 38 - unsigned long cp0_badvaddr; 39 - unsigned long cp0_cause; 40 - unsigned long cp0_epc; 39 + __u64 lo; 40 + __u64 hi; 41 + __u64 cp0_epc; 42 + __u64 cp0_badvaddr; 43 + __u64 cp0_status; 44 + __u64 cp0_cause; 41 45 } __attribute__ ((aligned (8))); 42 - #endif /* __KERNEL__ */ 43 46 44 47 /* Arbitrarily choose the same ptrace numbers as used by the Sparc code. */ 45 48 #define PTRACE_GETREGS 12
+206
arch/mips/include/uapi/asm/reg.h
··· 1 + /* 2 + * Various register offset definitions for debuggers, core file 3 + * examiners and whatnot. 4 + * 5 + * This file is subject to the terms and conditions of the GNU General Public 6 + * License. See the file "COPYING" in the main directory of this archive 7 + * for more details. 8 + * 9 + * Copyright (C) 1995, 1999 Ralf Baechle 10 + * Copyright (C) 1995, 1999 Silicon Graphics 11 + */ 12 + #ifndef __UAPI_ASM_MIPS_REG_H 13 + #define __UAPI_ASM_MIPS_REG_H 14 + 15 + #define MIPS32_EF_R0 6 16 + #define MIPS32_EF_R1 7 17 + #define MIPS32_EF_R2 8 18 + #define MIPS32_EF_R3 9 19 + #define MIPS32_EF_R4 10 20 + #define MIPS32_EF_R5 11 21 + #define MIPS32_EF_R6 12 22 + #define MIPS32_EF_R7 13 23 + #define MIPS32_EF_R8 14 24 + #define MIPS32_EF_R9 15 25 + #define MIPS32_EF_R10 16 26 + #define MIPS32_EF_R11 17 27 + #define MIPS32_EF_R12 18 28 + #define MIPS32_EF_R13 19 29 + #define MIPS32_EF_R14 20 30 + #define MIPS32_EF_R15 21 31 + #define MIPS32_EF_R16 22 32 + #define MIPS32_EF_R17 23 33 + #define MIPS32_EF_R18 24 34 + #define MIPS32_EF_R19 25 35 + #define MIPS32_EF_R20 26 36 + #define MIPS32_EF_R21 27 37 + #define MIPS32_EF_R22 28 38 + #define MIPS32_EF_R23 29 39 + #define MIPS32_EF_R24 30 40 + #define MIPS32_EF_R25 31 41 + 42 + /* 43 + * k0/k1 unsaved 44 + */ 45 + #define MIPS32_EF_R26 32 46 + #define MIPS32_EF_R27 33 47 + 48 + #define MIPS32_EF_R28 34 49 + #define MIPS32_EF_R29 35 50 + #define MIPS32_EF_R30 36 51 + #define MIPS32_EF_R31 37 52 + 53 + /* 54 + * Saved special registers 55 + */ 56 + #define MIPS32_EF_LO 38 57 + #define MIPS32_EF_HI 39 58 + 59 + #define MIPS32_EF_CP0_EPC 40 60 + #define MIPS32_EF_CP0_BADVADDR 41 61 + #define MIPS32_EF_CP0_STATUS 42 62 + #define MIPS32_EF_CP0_CAUSE 43 63 + #define MIPS32_EF_UNUSED0 44 64 + 65 + #define MIPS32_EF_SIZE 180 66 + 67 + #define MIPS64_EF_R0 0 68 + #define MIPS64_EF_R1 1 69 + #define MIPS64_EF_R2 2 70 + #define MIPS64_EF_R3 3 71 + #define MIPS64_EF_R4 4 72 + #define MIPS64_EF_R5 5 73 + #define MIPS64_EF_R6 6 74 + #define MIPS64_EF_R7 7 75 + #define MIPS64_EF_R8 8 76 + #define MIPS64_EF_R9 9 77 + #define MIPS64_EF_R10 10 78 + #define MIPS64_EF_R11 11 79 + #define MIPS64_EF_R12 12 80 + #define MIPS64_EF_R13 13 81 + #define MIPS64_EF_R14 14 82 + #define MIPS64_EF_R15 15 83 + #define MIPS64_EF_R16 16 84 + #define MIPS64_EF_R17 17 85 + #define MIPS64_EF_R18 18 86 + #define MIPS64_EF_R19 19 87 + #define MIPS64_EF_R20 20 88 + #define MIPS64_EF_R21 21 89 + #define MIPS64_EF_R22 22 90 + #define MIPS64_EF_R23 23 91 + #define MIPS64_EF_R24 24 92 + #define MIPS64_EF_R25 25 93 + 94 + /* 95 + * k0/k1 unsaved 96 + */ 97 + #define MIPS64_EF_R26 26 98 + #define MIPS64_EF_R27 27 99 + 100 + 101 + #define MIPS64_EF_R28 28 102 + #define MIPS64_EF_R29 29 103 + #define MIPS64_EF_R30 30 104 + #define MIPS64_EF_R31 31 105 + 106 + /* 107 + * Saved special registers 108 + */ 109 + #define MIPS64_EF_LO 32 110 + #define MIPS64_EF_HI 33 111 + 112 + #define MIPS64_EF_CP0_EPC 34 113 + #define MIPS64_EF_CP0_BADVADDR 35 114 + #define MIPS64_EF_CP0_STATUS 36 115 + #define MIPS64_EF_CP0_CAUSE 37 116 + 117 + #define MIPS64_EF_SIZE 304 /* size in bytes */ 118 + 119 + #if _MIPS_SIM == _MIPS_SIM_ABI32 120 + 121 + #define EF_R0 MIPS32_EF_R0 122 + #define EF_R1 MIPS32_EF_R1 123 + #define EF_R2 MIPS32_EF_R2 124 + #define EF_R3 MIPS32_EF_R3 125 + #define EF_R4 MIPS32_EF_R4 126 + #define EF_R5 MIPS32_EF_R5 127 + #define EF_R6 MIPS32_EF_R6 128 + #define EF_R7 MIPS32_EF_R7 129 + #define EF_R8 MIPS32_EF_R8 130 + #define EF_R9 MIPS32_EF_R9 131 + #define EF_R10 MIPS32_EF_R10 132 + #define EF_R11 MIPS32_EF_R11 133 + #define EF_R12 MIPS32_EF_R12 134 + #define EF_R13 MIPS32_EF_R13 135 + #define EF_R14 MIPS32_EF_R14 136 + #define EF_R15 MIPS32_EF_R15 137 + #define EF_R16 MIPS32_EF_R16 138 + #define EF_R17 MIPS32_EF_R17 139 + #define EF_R18 MIPS32_EF_R18 140 + #define EF_R19 MIPS32_EF_R19 141 + #define EF_R20 MIPS32_EF_R20 142 + #define EF_R21 MIPS32_EF_R21 143 + #define EF_R22 MIPS32_EF_R22 144 + #define EF_R23 MIPS32_EF_R23 145 + #define EF_R24 MIPS32_EF_R24 146 + #define EF_R25 MIPS32_EF_R25 147 + #define EF_R26 MIPS32_EF_R26 148 + #define EF_R27 MIPS32_EF_R27 149 + #define EF_R28 MIPS32_EF_R28 150 + #define EF_R29 MIPS32_EF_R29 151 + #define EF_R30 MIPS32_EF_R30 152 + #define EF_R31 MIPS32_EF_R31 153 + #define EF_LO MIPS32_EF_LO 154 + #define EF_HI MIPS32_EF_HI 155 + #define EF_CP0_EPC MIPS32_EF_CP0_EPC 156 + #define EF_CP0_BADVADDR MIPS32_EF_CP0_BADVADDR 157 + #define EF_CP0_STATUS MIPS32_EF_CP0_STATUS 158 + #define EF_CP0_CAUSE MIPS32_EF_CP0_CAUSE 159 + #define EF_UNUSED0 MIPS32_EF_UNUSED0 160 + #define EF_SIZE MIPS32_EF_SIZE 161 + 162 + #elif _MIPS_SIM == _MIPS_SIM_ABI64 || _MIPS_SIM == _MIPS_SIM_NABI32 163 + 164 + #define EF_R0 MIPS64_EF_R0 165 + #define EF_R1 MIPS64_EF_R1 166 + #define EF_R2 MIPS64_EF_R2 167 + #define EF_R3 MIPS64_EF_R3 168 + #define EF_R4 MIPS64_EF_R4 169 + #define EF_R5 MIPS64_EF_R5 170 + #define EF_R6 MIPS64_EF_R6 171 + #define EF_R7 MIPS64_EF_R7 172 + #define EF_R8 MIPS64_EF_R8 173 + #define EF_R9 MIPS64_EF_R9 174 + #define EF_R10 MIPS64_EF_R10 175 + #define EF_R11 MIPS64_EF_R11 176 + #define EF_R12 MIPS64_EF_R12 177 + #define EF_R13 MIPS64_EF_R13 178 + #define EF_R14 MIPS64_EF_R14 179 + #define EF_R15 MIPS64_EF_R15 180 + #define EF_R16 MIPS64_EF_R16 181 + #define EF_R17 MIPS64_EF_R17 182 + #define EF_R18 MIPS64_EF_R18 183 + #define EF_R19 MIPS64_EF_R19 184 + #define EF_R20 MIPS64_EF_R20 185 + #define EF_R21 MIPS64_EF_R21 186 + #define EF_R22 MIPS64_EF_R22 187 + #define EF_R23 MIPS64_EF_R23 188 + #define EF_R24 MIPS64_EF_R24 189 + #define EF_R25 MIPS64_EF_R25 190 + #define EF_R26 MIPS64_EF_R26 191 + #define EF_R27 MIPS64_EF_R27 192 + #define EF_R28 MIPS64_EF_R28 193 + #define EF_R29 MIPS64_EF_R29 194 + #define EF_R30 MIPS64_EF_R30 195 + #define EF_R31 MIPS64_EF_R31 196 + #define EF_LO MIPS64_EF_LO 197 + #define EF_HI MIPS64_EF_HI 198 + #define EF_CP0_EPC MIPS64_EF_CP0_EPC 199 + #define EF_CP0_BADVADDR MIPS64_EF_CP0_BADVADDR 200 + #define EF_CP0_STATUS MIPS64_EF_CP0_STATUS 201 + #define EF_CP0_CAUSE MIPS64_EF_CP0_CAUSE 202 + #define EF_SIZE MIPS64_EF_SIZE 203 + 204 + #endif /* _MIPS_SIM == _MIPS_SIM_ABI64 || _MIPS_SIM == _MIPS_SIM_NABI32 */ 205 + 206 + #endif /* __UAPI_ASM_MIPS_REG_H */
+1 -2
arch/mips/jz4740/clock-debugfs.c
··· 87 87 /* TODO: Locking */ 88 88 void jz4740_clock_debugfs_update_parent(struct clk *clk) 89 89 { 90 - if (clk->debugfs_parent_entry) 91 - debugfs_remove(clk->debugfs_parent_entry); 90 + debugfs_remove(clk->debugfs_parent_entry); 92 91 93 92 if (clk->parent) { 94 93 char parent_path[100];
+1 -1
arch/mips/jz4740/platform.c
··· 59 59 60 60 /* USB Device Controller */ 61 61 struct platform_device jz4740_udc_xceiv_device = { 62 - .name = "usb_phy_gen_xceiv", 62 + .name = "usb_phy_generic", 63 63 .id = 0, 64 64 }; 65 65
+1
arch/mips/kernel/asm-offsets.c
··· 234 234 thread.fpu.fpr[31].val64[FPR_IDX(64, 0)]); 235 235 236 236 OFFSET(THREAD_FCR31, task_struct, thread.fpu.fcr31); 237 + OFFSET(THREAD_MSA_CSR, task_struct, thread.fpu.msacsr); 237 238 BLANK(); 238 239 } 239 240
-38
arch/mips/kernel/binfmt_elfo32.c
··· 72 72 73 73 #include <asm/processor.h> 74 74 75 - /* 76 - * When this file is selected, we are definitely running a 64bit kernel. 77 - * So using the right regs define in asm/reg.h 78 - */ 79 - #define WANT_COMPAT_REG_H 80 - 81 - /* These MUST be defined before elf.h gets included */ 82 - extern void elf32_core_copy_regs(elf_gregset_t grp, struct pt_regs *regs); 83 - #define ELF_CORE_COPY_REGS(_dest, _regs) elf32_core_copy_regs(_dest, _regs); 84 - #define ELF_CORE_COPY_TASK_REGS(_tsk, _dest) \ 85 - ({ \ 86 - int __res = 1; \ 87 - elf32_core_copy_regs(*(_dest), task_pt_regs(_tsk)); \ 88 - __res; \ 89 - }) 90 - 91 75 #include <linux/module.h> 92 76 #include <linux/elfcore.h> 93 77 #include <linux/compat.h> ··· 127 143 u32 rem; 128 144 value->tv_sec = div_u64_rem(nsec, NSEC_PER_SEC, &rem); 129 145 value->tv_usec = rem / NSEC_PER_USEC; 130 - } 131 - 132 - void elf32_core_copy_regs(elf_gregset_t grp, struct pt_regs *regs) 133 - { 134 - int i; 135 - 136 - for (i = 0; i < EF_R0; i++) 137 - grp[i] = 0; 138 - grp[EF_R0] = 0; 139 - for (i = 1; i <= 31; i++) 140 - grp[EF_R0 + i] = (elf_greg_t) regs->regs[i]; 141 - grp[EF_R26] = 0; 142 - grp[EF_R27] = 0; 143 - grp[EF_LO] = (elf_greg_t) regs->lo; 144 - grp[EF_HI] = (elf_greg_t) regs->hi; 145 - grp[EF_CP0_EPC] = (elf_greg_t) regs->cp0_epc; 146 - grp[EF_CP0_BADVADDR] = (elf_greg_t) regs->cp0_badvaddr; 147 - grp[EF_CP0_STATUS] = (elf_greg_t) regs->cp0_status; 148 - grp[EF_CP0_CAUSE] = (elf_greg_t) regs->cp0_cause; 149 - #ifdef EF_UNUSED0 150 - grp[EF_UNUSED0] = 0; 151 - #endif 152 146 } 153 147 154 148 MODULE_DESCRIPTION("Binary format loader for compatibility with o32 Linux/MIPS binaries");
+42 -3
arch/mips/kernel/cpu-probe.c
··· 54 54 55 55 __setup("nodsp", dsp_disable); 56 56 57 + static int mips_htw_disabled; 58 + 59 + static int __init htw_disable(char *s) 60 + { 61 + mips_htw_disabled = 1; 62 + cpu_data[0].options &= ~MIPS_CPU_HTW; 63 + write_c0_pwctl(read_c0_pwctl() & 64 + ~(1 << MIPS_PWCTL_PWEN_SHIFT)); 65 + 66 + return 1; 67 + } 68 + 69 + __setup("nohtw", htw_disable); 70 + 57 71 static inline void check_errata(void) 58 72 { 59 73 struct cpuinfo_mips *c = &current_cpu_data; ··· 144 130 145 131 static inline unsigned long cpu_get_msa_id(void) 146 132 { 147 - unsigned long status, conf5, msa_id; 133 + unsigned long status, msa_id; 148 134 149 135 status = read_c0_status(); 150 136 __enable_fpu(FPU_64BIT); 151 - conf5 = read_c0_config5(); 152 137 enable_msa(); 153 138 msa_id = read_msa_ir(); 154 - write_c0_config5(conf5); 139 + disable_msa(); 155 140 write_c0_status(status); 156 141 return msa_id; 157 142 } ··· 334 321 c->options |= MIPS_CPU_SEGMENTS; 335 322 if (config3 & MIPS_CONF3_MSA) 336 323 c->ases |= MIPS_ASE_MSA; 324 + /* Only tested on 32-bit cores */ 325 + if ((config3 & MIPS_CONF3_PW) && config_enabled(CONFIG_32BIT)) 326 + c->options |= MIPS_CPU_HTW; 337 327 338 328 return config3 & MIPS_CONF_M; 339 329 } ··· 405 389 406 390 if (config5 & MIPS_CONF5_EVA) 407 391 c->options |= MIPS_CPU_EVA; 392 + if (config5 & MIPS_CONF5_MRP) 393 + c->options |= MIPS_CPU_MAAR; 408 394 409 395 return config5 & MIPS_CONF_M; 410 396 } ··· 438 420 ok = decode_config5(c); 439 421 440 422 mips_probe_watch_registers(c); 423 + 424 + if (cpu_has_rixi) { 425 + /* Enable the RIXI exceptions */ 426 + write_c0_pagegrain(read_c0_pagegrain() | PG_IEC); 427 + back_to_back_c0_hazard(); 428 + /* Verify the IEC bit is set */ 429 + if (read_c0_pagegrain() & PG_IEC) 430 + c->options |= MIPS_CPU_RIXIEX; 431 + } 441 432 442 433 #ifndef CONFIG_MIPS_CPS 443 434 if (cpu_has_mips_r2) { ··· 766 739 c->cputype = CPU_LOONGSON3; 767 740 __cpu_name[cpu] = "ICT Loongson-3"; 768 741 set_elf_platform(cpu, "loongson3a"); 742 + break; 743 + case PRID_REV_LOONGSON3B_R1: 744 + case PRID_REV_LOONGSON3B_R2: 745 + c->cputype = CPU_LOONGSON3; 746 + __cpu_name[cpu] = "ICT Loongson-3"; 747 + set_elf_platform(cpu, "loongson3b"); 769 748 break; 770 749 } 771 750 ··· 1219 1186 1220 1187 if (mips_dsp_disabled) 1221 1188 c->ases &= ~(MIPS_ASE_DSP | MIPS_ASE_DSP2P); 1189 + 1190 + if (mips_htw_disabled) { 1191 + c->options &= ~MIPS_CPU_HTW; 1192 + write_c0_pwctl(read_c0_pwctl() & 1193 + ~(1 << MIPS_PWCTL_PWEN_SHIFT)); 1194 + } 1222 1195 1223 1196 if (c->options & MIPS_CPU_FPU) { 1224 1197 c->fpu_id = cpu_get_fpu_id();
+47 -9
arch/mips/kernel/ftrace.c
··· 63 63 ((unsigned int)(JAL | (((addr) >> 2) & ADDR_MASK))) 64 64 65 65 static unsigned int insn_jal_ftrace_caller __read_mostly; 66 - static unsigned int insn_lui_v1_hi16_mcount __read_mostly; 66 + static unsigned int insn_la_mcount[2] __read_mostly; 67 67 static unsigned int insn_j_ftrace_graph_caller __maybe_unused __read_mostly; 68 68 69 69 static inline void ftrace_dyn_arch_init_insns(void) ··· 71 71 u32 *buf; 72 72 unsigned int v1; 73 73 74 - /* lui v1, hi16_mcount */ 74 + /* la v1, _mcount */ 75 75 v1 = 3; 76 - buf = (u32 *)&insn_lui_v1_hi16_mcount; 77 - UASM_i_LA_mostly(&buf, v1, MCOUNT_ADDR); 76 + buf = (u32 *)&insn_la_mcount[0]; 77 + UASM_i_LA(&buf, v1, MCOUNT_ADDR); 78 78 79 79 /* jal (ftrace_caller + 8), jump over the first two instruction */ 80 80 buf = (u32 *)&insn_jal_ftrace_caller; ··· 111 111 unsigned int new_code2) 112 112 { 113 113 int faulted; 114 + mm_segment_t old_fs; 114 115 115 116 safe_store_code(new_code1, ip, faulted); 116 117 if (unlikely(faulted)) 117 118 return -EFAULT; 118 - safe_store_code(new_code2, ip + 4, faulted); 119 + 120 + ip += 4; 121 + safe_store_code(new_code2, ip, faulted); 119 122 if (unlikely(faulted)) 120 123 return -EFAULT; 124 + 125 + ip -= 4; 126 + old_fs = get_fs(); 127 + set_fs(get_ds()); 121 128 flush_icache_range(ip, ip + 8); 129 + set_fs(old_fs); 130 + 131 + return 0; 132 + } 133 + 134 + static int ftrace_modify_code_2r(unsigned long ip, unsigned int new_code1, 135 + unsigned int new_code2) 136 + { 137 + int faulted; 138 + mm_segment_t old_fs; 139 + 140 + ip += 4; 141 + safe_store_code(new_code2, ip, faulted); 142 + if (unlikely(faulted)) 143 + return -EFAULT; 144 + 145 + ip -= 4; 146 + safe_store_code(new_code1, ip, faulted); 147 + if (unlikely(faulted)) 148 + return -EFAULT; 149 + 150 + old_fs = get_fs(); 151 + set_fs(get_ds()); 152 + flush_icache_range(ip, ip + 8); 153 + set_fs(old_fs); 154 + 122 155 return 0; 123 156 } 124 157 #endif ··· 163 130 * 164 131 * move at, ra 165 132 * jal _mcount --> nop 133 + * sub sp, sp, 8 --> nop (CONFIG_32BIT) 166 134 * 167 135 * 2. For modules: 168 136 * 169 137 * 2.1 For KBUILD_MCOUNT_RA_ADDRESS and CONFIG_32BIT 170 138 * 171 139 * lui v1, hi_16bit_of_mcount --> b 1f (0x10000005) 172 - * addiu v1, v1, low_16bit_of_mcount 140 + * addiu v1, v1, low_16bit_of_mcount --> nop (CONFIG_32BIT) 173 141 * move at, ra 174 142 * move $12, ra_address 175 143 * jalr v1 ··· 179 145 * 2.2 For the Other situations 180 146 * 181 147 * lui v1, hi_16bit_of_mcount --> b 1f (0x10000004) 182 - * addiu v1, v1, low_16bit_of_mcount 148 + * addiu v1, v1, low_16bit_of_mcount --> nop (CONFIG_32BIT) 183 149 * move at, ra 184 150 * jalr v1 185 151 * nop | move $12, ra_address | sub sp, sp, 8 ··· 218 184 unsigned int new; 219 185 unsigned long ip = rec->ip; 220 186 221 - new = in_kernel_space(ip) ? insn_jal_ftrace_caller : 222 - insn_lui_v1_hi16_mcount; 187 + new = in_kernel_space(ip) ? insn_jal_ftrace_caller : insn_la_mcount[0]; 223 188 189 + #ifdef CONFIG_64BIT 224 190 return ftrace_modify_code(ip, new); 191 + #else 192 + return ftrace_modify_code_2r(ip, new, in_kernel_space(ip) ? 193 + INSN_NOP : insn_la_mcount[1]); 194 + #endif 225 195 } 226 196 227 197 #define FTRACE_CALL_IP ((unsigned long)(&ftrace_call))
+30 -8
arch/mips/kernel/irq-gic.c
··· 28 28 /* The index into this array is the vector # of the interrupt. */ 29 29 struct gic_shared_intr_map gic_shared_intr_map[GIC_NUM_INTRS]; 30 30 31 + struct gic_pcpu_mask { 32 + DECLARE_BITMAP(pcpu_mask, GIC_NUM_INTRS); 33 + }; 34 + 35 + struct gic_pending_regs { 36 + DECLARE_BITMAP(pending, GIC_NUM_INTRS); 37 + }; 38 + 39 + struct gic_intrmask_regs { 40 + DECLARE_BITMAP(intrmask, GIC_NUM_INTRS); 41 + }; 42 + 31 43 static struct gic_pcpu_mask pcpu_masks[NR_CPUS]; 32 44 static struct gic_pending_regs pending_regs[NR_CPUS]; 33 45 static struct gic_intrmask_regs intrmask_regs[NR_CPUS]; ··· 189 177 return 0; 190 178 } 191 179 192 - unsigned int gic_get_int(void) 180 + void gic_get_int_mask(unsigned long *dst, const unsigned long *src) 193 181 { 194 182 unsigned int i; 195 183 unsigned long *pending, *intrmask, *pcpu_mask; ··· 214 202 215 203 bitmap_and(pending, pending, intrmask, GIC_NUM_INTRS); 216 204 bitmap_and(pending, pending, pcpu_mask, GIC_NUM_INTRS); 205 + bitmap_and(dst, src, pending, GIC_NUM_INTRS); 206 + } 217 207 218 - return find_first_bit(pending, GIC_NUM_INTRS); 208 + unsigned int gic_get_int(void) 209 + { 210 + DECLARE_BITMAP(interrupts, GIC_NUM_INTRS); 211 + 212 + bitmap_fill(interrupts, GIC_NUM_INTRS); 213 + gic_get_int_mask(interrupts, interrupts); 214 + 215 + return find_first_bit(interrupts, GIC_NUM_INTRS); 219 216 } 220 217 221 218 static void gic_mask_irq(struct irq_data *d) ··· 290 269 291 270 /* Setup Intr to Pin mapping */ 292 271 if (pin & GIC_MAP_TO_NMI_MSK) { 272 + int i; 273 + 293 274 GICWRITE(GIC_REG_ADDR(SHARED, GIC_SH_MAP_TO_PIN(intr)), pin); 294 275 /* FIXME: hack to route NMI to all cpu's */ 295 - for (cpu = 0; cpu < NR_CPUS; cpu += 32) { 276 + for (i = 0; i < NR_CPUS; i += 32) { 296 277 GICWRITE(GIC_REG_ADDR(SHARED, 297 - GIC_SH_MAP_TO_VPE_REG_OFF(intr, cpu)), 278 + GIC_SH_MAP_TO_VPE_REG_OFF(intr, i)), 298 279 0xffffffff); 299 280 } 300 281 } else { ··· 322 299 323 300 /* Init Intr Masks */ 324 301 GIC_CLR_INTR_MASK(intr); 302 + 325 303 /* Initialise per-cpu Interrupt software masks */ 326 - if (flags & GIC_FLAG_IPI) 327 - set_bit(intr, pcpu_masks[cpu].pcpu_mask); 304 + set_bit(intr, pcpu_masks[cpu].pcpu_mask); 305 + 328 306 if ((flags & GIC_FLAG_TRANSPARENT) && (cpu_has_veic == 0)) 329 307 GIC_SET_INTR_MASK(intr); 330 308 if (trigtype == GIC_TRIG_EDGE) ··· 363 339 for (i = 0; i < mapsize; i++) { 364 340 cpu = intrmap[i].cpunum; 365 341 if (cpu == GIC_UNUSED) 366 - continue; 367 - if (cpu == 0 && i != 0 && intrmap[i].flags == 0) 368 342 continue; 369 343 gic_setup_intr(i, 370 344 intrmap[i].cpunum,
+13
arch/mips/kernel/mcount.S
··· 80 80 #endif 81 81 82 82 PTR_SUBU a0, ra, 8 /* arg1: self address */ 83 + PTR_LA t1, _stext 84 + sltu t2, a0, t1 /* t2 = (a0 < _stext) */ 85 + PTR_LA t1, _etext 86 + sltu t3, t1, a0 /* t3 = (a0 > _etext) */ 87 + or t1, t2, t3 88 + beqz t1, ftrace_call 89 + nop 90 + #if defined(KBUILD_MCOUNT_RA_ADDRESS) && defined(CONFIG_32BIT) 91 + PTR_SUBU a0, a0, 16 /* arg1: adjust to module's recorded callsite */ 92 + #else 93 + PTR_SUBU a0, a0, 12 94 + #endif 95 + 83 96 .globl ftrace_call 84 97 ftrace_call: 85 98 nop /* a placeholder for the call to a real tracing function */
+34 -8
arch/mips/kernel/perf_event_mipsxx.c
··· 1386 1386 /* proAptiv */ 1387 1387 #define IS_BOTH_COUNTERS_PROAPTIV_EVENT(b) \ 1388 1388 ((b) == 0 || (b) == 1) 1389 + /* P5600 */ 1390 + #define IS_BOTH_COUNTERS_P5600_EVENT(b) \ 1391 + ((b) == 0 || (b) == 1) 1389 1392 1390 1393 /* 1004K */ 1391 1394 #define IS_BOTH_COUNTERS_1004K_EVENT(b) \ ··· 1423 1420 1424 1421 1425 1422 /* 1426 - * User can use 0-255 raw events, where 0-127 for the events of even 1427 - * counters, and 128-255 for odd counters. Note that bit 7 is used to 1428 - * indicate the parity. So, for example, when user wants to take the 1429 - * Event Num of 15 for odd counters (by referring to the user manual), 1430 - * then 128 needs to be added to 15 as the input for the event config, 1431 - * i.e., 143 (0x8F) to be used. 1423 + * For most cores the user can use 0-255 raw events, where 0-127 for the events 1424 + * of even counters, and 128-255 for odd counters. Note that bit 7 is used to 1425 + * indicate the even/odd bank selector. So, for example, when user wants to take 1426 + * the Event Num of 15 for odd counters (by referring to the user manual), then 1427 + * 128 needs to be added to 15 as the input for the event config, i.e., 143 (0x8F) 1428 + * to be used. 1429 + * 1430 + * Some newer cores have even more events, in which case the user can use raw 1431 + * events 0-511, where 0-255 are for the events of even counters, and 256-511 1432 + * are for odd counters, so bit 8 is used to indicate the even/odd bank selector. 1432 1433 */ 1433 1434 static const struct mips_perf_event *mipsxx_pmu_map_raw_event(u64 config) 1434 1435 { 1436 + /* currently most cores have 7-bit event numbers */ 1435 1437 unsigned int raw_id = config & 0xff; 1436 1438 unsigned int base_id = raw_id & 0x7f; 1437 - 1438 - raw_event.event_id = base_id; 1439 1439 1440 1440 switch (current_cpu_type()) { 1441 1441 case CPU_24K: ··· 1491 1485 raw_event.range = P; 1492 1486 #endif 1493 1487 break; 1488 + case CPU_P5600: 1489 + /* 8-bit event numbers */ 1490 + raw_id = config & 0x1ff; 1491 + base_id = raw_id & 0xff; 1492 + if (IS_BOTH_COUNTERS_P5600_EVENT(base_id)) 1493 + raw_event.cntr_mask = CNTR_EVEN | CNTR_ODD; 1494 + else 1495 + raw_event.cntr_mask = 1496 + raw_id > 255 ? CNTR_ODD : CNTR_EVEN; 1497 + #ifdef CONFIG_MIPS_MT_SMP 1498 + raw_event.range = P; 1499 + #endif 1500 + break; 1494 1501 case CPU_1004K: 1495 1502 if (IS_BOTH_COUNTERS_1004K_EVENT(base_id)) 1496 1503 raw_event.cntr_mask = CNTR_EVEN | CNTR_ODD; ··· 1541 1522 raw_event.cntr_mask = 1542 1523 raw_id > 127 ? CNTR_ODD : CNTR_EVEN; 1543 1524 } 1525 + 1526 + raw_event.event_id = base_id; 1544 1527 1545 1528 return &raw_event; 1546 1529 } ··· 1651 1630 break; 1652 1631 case CPU_PROAPTIV: 1653 1632 mipspmu.name = "mips/proAptiv"; 1633 + mipspmu.general_event_map = &mipsxxcore_event_map2; 1634 + mipspmu.cache_event_map = &mipsxxcore_cache_map2; 1635 + break; 1636 + case CPU_P5600: 1637 + mipspmu.name = "mips/P5600"; 1654 1638 mipspmu.general_event_map = &mipsxxcore_event_map2; 1655 1639 mipspmu.cache_event_map = &mipsxxcore_cache_map2; 1656 1640 break;
+9 -1
arch/mips/kernel/pm-cps.c
··· 149 149 150 150 /* Setup the VPE to run mips_cps_pm_restore when started again */ 151 151 if (config_enabled(CONFIG_CPU_PM) && state == CPS_PM_POWER_GATED) { 152 + /* Power gating relies upon CPS SMP */ 153 + if (!mips_cps_smp_in_use()) 154 + return -EINVAL; 155 + 152 156 core_cfg = &mips_cps_core_bootcfg[core]; 153 - vpe_cfg = &core_cfg->vpe_config[current_cpu_data.vpe_id]; 157 + vpe_cfg = &core_cfg->vpe_config[cpu_vpe_id(&current_cpu_data)]; 154 158 vpe_cfg->pc = (unsigned long)mips_cps_pm_restore; 155 159 vpe_cfg->gp = (unsigned long)current_thread_info(); 156 160 vpe_cfg->sp = 0; ··· 380 376 memset(relocs, 0, sizeof(relocs)); 381 377 382 378 if (config_enabled(CONFIG_CPU_PM) && state == CPS_PM_POWER_GATED) { 379 + /* Power gating relies upon CPS SMP */ 380 + if (!mips_cps_smp_in_use()) 381 + goto out_err; 382 + 383 383 /* 384 384 * Save CPU state. Note the non-standard calling convention 385 385 * with the return address placed in v0 to avoid clobbering
+2
arch/mips/kernel/proc.c
··· 113 113 if (cpu_has_vz) seq_printf(m, "%s", " vz"); 114 114 if (cpu_has_msa) seq_printf(m, "%s", " msa"); 115 115 if (cpu_has_eva) seq_printf(m, "%s", " eva"); 116 + if (cpu_has_htw) seq_printf(m, "%s", " htw"); 116 117 seq_printf(m, "\n"); 117 118 118 119 if (cpu_has_mmips) { ··· 124 123 cpu_data[n].srsets); 125 124 seq_printf(m, "kscratch registers\t: %d\n", 126 125 hweight8(cpu_data[n].kscratch_mask)); 126 + seq_printf(m, "package\t\t\t: %d\n", cpu_data[n].package); 127 127 seq_printf(m, "core\t\t\t: %d\n", cpu_data[n].core); 128 128 129 129 sprintf(fmt, "VCE%%c exceptions\t\t: %s\n",
+4 -56
arch/mips/kernel/process.c
··· 21 21 #include <linux/mman.h> 22 22 #include <linux/personality.h> 23 23 #include <linux/sys.h> 24 - #include <linux/user.h> 25 24 #include <linux/init.h> 26 25 #include <linux/completion.h> 27 26 #include <linux/kallsyms.h> ··· 35 36 #include <asm/pgtable.h> 36 37 #include <asm/mipsregs.h> 37 38 #include <asm/processor.h> 39 + #include <asm/reg.h> 38 40 #include <asm/uaccess.h> 39 41 #include <asm/io.h> 40 42 #include <asm/elf.h> ··· 66 66 clear_used_math(); 67 67 clear_fpu_owner(); 68 68 init_dsp(); 69 + clear_thread_flag(TIF_USEDMSA); 69 70 clear_thread_flag(TIF_MSA_CTX_LIVE); 70 71 disable_msa(); 71 72 regs->cp0_epc = pc; ··· 142 141 childregs->cp0_status &= ~(ST0_CU2|ST0_CU1); 143 142 144 143 clear_tsk_thread_flag(p, TIF_USEDFPU); 144 + clear_tsk_thread_flag(p, TIF_USEDMSA); 145 + clear_tsk_thread_flag(p, TIF_MSA_CTX_LIVE); 145 146 146 147 #ifdef CONFIG_MIPS_MT_FPAFF 147 148 clear_tsk_thread_flag(p, TIF_FPUBOUND); ··· 153 150 ti->tp_value = regs->regs[7]; 154 151 155 152 return 0; 156 - } 157 - 158 - /* Fill in the fpu structure for a core dump.. */ 159 - int dump_fpu(struct pt_regs *regs, elf_fpregset_t *r) 160 - { 161 - int i; 162 - 163 - for (i = 0; i < NUM_FPU_REGS; i++) 164 - memcpy(&r[i], &current->thread.fpu.fpr[i], sizeof(*r)); 165 - 166 - memcpy(&r[NUM_FPU_REGS], &current->thread.fpu.fcr31, 167 - sizeof(current->thread.fpu.fcr31)); 168 - 169 - return 1; 170 - } 171 - 172 - void elf_dump_regs(elf_greg_t *gp, struct pt_regs *regs) 173 - { 174 - int i; 175 - 176 - for (i = 0; i < EF_R0; i++) 177 - gp[i] = 0; 178 - gp[EF_R0] = 0; 179 - for (i = 1; i <= 31; i++) 180 - gp[EF_R0 + i] = regs->regs[i]; 181 - gp[EF_R26] = 0; 182 - gp[EF_R27] = 0; 183 - gp[EF_LO] = regs->lo; 184 - gp[EF_HI] = regs->hi; 185 - gp[EF_CP0_EPC] = regs->cp0_epc; 186 - gp[EF_CP0_BADVADDR] = regs->cp0_badvaddr; 187 - gp[EF_CP0_STATUS] = regs->cp0_status; 188 - gp[EF_CP0_CAUSE] = regs->cp0_cause; 189 - #ifdef EF_UNUSED0 190 - gp[EF_UNUSED0] = 0; 191 - #endif 192 - } 193 - 194 - int dump_task_regs(struct task_struct *tsk, elf_gregset_t *regs) 195 - { 196 - elf_dump_regs(*regs, task_pt_regs(tsk)); 197 - return 1; 198 - } 199 - 200 - int dump_task_fpu(struct task_struct *t, elf_fpregset_t *fpr) 201 - { 202 - int i; 203 - 204 - for (i = 0; i < NUM_FPU_REGS; i++) 205 - memcpy(&fpr[i], &t->thread.fpu.fpr[i], sizeof(*fpr)); 206 - 207 - memcpy(&fpr[NUM_FPU_REGS], &t->thread.fpu.fcr31, 208 - sizeof(t->thread.fpu.fcr31)); 209 - 210 - return 1; 211 153 } 212 154 213 155 #ifdef CONFIG_CC_STACKPROTECTOR
+177 -46
arch/mips/kernel/ptrace.c
··· 24 24 #include <linux/ptrace.h> 25 25 #include <linux/regset.h> 26 26 #include <linux/smp.h> 27 - #include <linux/user.h> 28 27 #include <linux/security.h> 29 28 #include <linux/tracehook.h> 30 29 #include <linux/audit.h> ··· 62 63 * for 32-bit kernels and for 32-bit processes on a 64-bit kernel. 63 64 * Registers are sign extended to fill the available space. 64 65 */ 65 - int ptrace_getregs(struct task_struct *child, __s64 __user *data) 66 + int ptrace_getregs(struct task_struct *child, struct user_pt_regs __user *data) 66 67 { 67 68 struct pt_regs *regs; 68 69 int i; ··· 73 74 regs = task_pt_regs(child); 74 75 75 76 for (i = 0; i < 32; i++) 76 - __put_user((long)regs->regs[i], data + i); 77 - __put_user((long)regs->lo, data + EF_LO - EF_R0); 78 - __put_user((long)regs->hi, data + EF_HI - EF_R0); 79 - __put_user((long)regs->cp0_epc, data + EF_CP0_EPC - EF_R0); 80 - __put_user((long)regs->cp0_badvaddr, data + EF_CP0_BADVADDR - EF_R0); 81 - __put_user((long)regs->cp0_status, data + EF_CP0_STATUS - EF_R0); 82 - __put_user((long)regs->cp0_cause, data + EF_CP0_CAUSE - EF_R0); 77 + __put_user((long)regs->regs[i], (__s64 __user *)&data->regs[i]); 78 + __put_user((long)regs->lo, (__s64 __user *)&data->lo); 79 + __put_user((long)regs->hi, (__s64 __user *)&data->hi); 80 + __put_user((long)regs->cp0_epc, (__s64 __user *)&data->cp0_epc); 81 + __put_user((long)regs->cp0_badvaddr, (__s64 __user *)&data->cp0_badvaddr); 82 + __put_user((long)regs->cp0_status, (__s64 __user *)&data->cp0_status); 83 + __put_user((long)regs->cp0_cause, (__s64 __user *)&data->cp0_cause); 83 84 84 85 return 0; 85 86 } ··· 89 90 * the 64-bit format. On a 32-bit kernel only the lower order half 90 91 * (according to endianness) will be used. 91 92 */ 92 - int ptrace_setregs(struct task_struct *child, __s64 __user *data) 93 + int ptrace_setregs(struct task_struct *child, struct user_pt_regs __user *data) 93 94 { 94 95 struct pt_regs *regs; 95 96 int i; ··· 100 101 regs = task_pt_regs(child); 101 102 102 103 for (i = 0; i < 32; i++) 103 - __get_user(regs->regs[i], data + i); 104 - __get_user(regs->lo, data + EF_LO - EF_R0); 105 - __get_user(regs->hi, data + EF_HI - EF_R0); 106 - __get_user(regs->cp0_epc, data + EF_CP0_EPC - EF_R0); 104 + __get_user(regs->regs[i], (__s64 __user *)&data->regs[i]); 105 + __get_user(regs->lo, (__s64 __user *)&data->lo); 106 + __get_user(regs->hi, (__s64 __user *)&data->hi); 107 + __get_user(regs->cp0_epc, (__s64 __user *)&data->cp0_epc); 107 108 108 109 /* badvaddr, status, and cause may not be written. */ 109 110 ··· 128 129 } 129 130 130 131 __put_user(child->thread.fpu.fcr31, data + 64); 131 - __put_user(current_cpu_data.fpu_id, data + 65); 132 + __put_user(boot_cpu_data.fpu_id, data + 65); 132 133 133 134 return 0; 134 135 } ··· 150 151 } 151 152 152 153 __get_user(child->thread.fpu.fcr31, data + 64); 154 + child->thread.fpu.fcr31 &= ~FPU_CSR_ALL_X; 153 155 154 156 /* FIR may not be written. */ 155 157 ··· 246 246 247 247 /* regset get/set implementations */ 248 248 249 - static int gpr_get(struct task_struct *target, 250 - const struct user_regset *regset, 251 - unsigned int pos, unsigned int count, 252 - void *kbuf, void __user *ubuf) 249 + #if defined(CONFIG_32BIT) || defined(CONFIG_MIPS32_O32) 250 + 251 + static int gpr32_get(struct task_struct *target, 252 + const struct user_regset *regset, 253 + unsigned int pos, unsigned int count, 254 + void *kbuf, void __user *ubuf) 253 255 { 254 256 struct pt_regs *regs = task_pt_regs(target); 257 + u32 uregs[ELF_NGREG] = {}; 258 + unsigned i; 255 259 256 - return user_regset_copyout(&pos, &count, &kbuf, &ubuf, 257 - regs, 0, sizeof(*regs)); 260 + for (i = MIPS32_EF_R1; i <= MIPS32_EF_R31; i++) { 261 + /* k0/k1 are copied as zero. */ 262 + if (i == MIPS32_EF_R26 || i == MIPS32_EF_R27) 263 + continue; 264 + 265 + uregs[i] = regs->regs[i - MIPS32_EF_R0]; 266 + } 267 + 268 + uregs[MIPS32_EF_LO] = regs->lo; 269 + uregs[MIPS32_EF_HI] = regs->hi; 270 + uregs[MIPS32_EF_CP0_EPC] = regs->cp0_epc; 271 + uregs[MIPS32_EF_CP0_BADVADDR] = regs->cp0_badvaddr; 272 + uregs[MIPS32_EF_CP0_STATUS] = regs->cp0_status; 273 + uregs[MIPS32_EF_CP0_CAUSE] = regs->cp0_cause; 274 + 275 + return user_regset_copyout(&pos, &count, &kbuf, &ubuf, uregs, 0, 276 + sizeof(uregs)); 258 277 } 259 278 260 - static int gpr_set(struct task_struct *target, 261 - const struct user_regset *regset, 262 - unsigned int pos, unsigned int count, 263 - const void *kbuf, const void __user *ubuf) 279 + static int gpr32_set(struct task_struct *target, 280 + const struct user_regset *regset, 281 + unsigned int pos, unsigned int count, 282 + const void *kbuf, const void __user *ubuf) 264 283 { 265 - struct pt_regs newregs; 266 - int ret; 284 + struct pt_regs *regs = task_pt_regs(target); 285 + u32 uregs[ELF_NGREG]; 286 + unsigned start, num_regs, i; 287 + int err; 267 288 268 - ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, 269 - &newregs, 270 - 0, sizeof(newregs)); 271 - if (ret) 272 - return ret; 289 + start = pos / sizeof(u32); 290 + num_regs = count / sizeof(u32); 273 291 274 - *task_pt_regs(target) = newregs; 292 + if (start + num_regs > ELF_NGREG) 293 + return -EIO; 294 + 295 + err = user_regset_copyin(&pos, &count, &kbuf, &ubuf, uregs, 0, 296 + sizeof(uregs)); 297 + if (err) 298 + return err; 299 + 300 + for (i = start; i < num_regs; i++) { 301 + /* 302 + * Cast all values to signed here so that if this is a 64-bit 303 + * kernel, the supplied 32-bit values will be sign extended. 304 + */ 305 + switch (i) { 306 + case MIPS32_EF_R1 ... MIPS32_EF_R25: 307 + /* k0/k1 are ignored. */ 308 + case MIPS32_EF_R28 ... MIPS32_EF_R31: 309 + regs->regs[i - MIPS32_EF_R0] = (s32)uregs[i]; 310 + break; 311 + case MIPS32_EF_LO: 312 + regs->lo = (s32)uregs[i]; 313 + break; 314 + case MIPS32_EF_HI: 315 + regs->hi = (s32)uregs[i]; 316 + break; 317 + case MIPS32_EF_CP0_EPC: 318 + regs->cp0_epc = (s32)uregs[i]; 319 + break; 320 + } 321 + } 275 322 276 323 return 0; 277 324 } 325 + 326 + #endif /* CONFIG_32BIT || CONFIG_MIPS32_O32 */ 327 + 328 + #ifdef CONFIG_64BIT 329 + 330 + static int gpr64_get(struct task_struct *target, 331 + const struct user_regset *regset, 332 + unsigned int pos, unsigned int count, 333 + void *kbuf, void __user *ubuf) 334 + { 335 + struct pt_regs *regs = task_pt_regs(target); 336 + u64 uregs[ELF_NGREG] = {}; 337 + unsigned i; 338 + 339 + for (i = MIPS64_EF_R1; i <= MIPS64_EF_R31; i++) { 340 + /* k0/k1 are copied as zero. */ 341 + if (i == MIPS64_EF_R26 || i == MIPS64_EF_R27) 342 + continue; 343 + 344 + uregs[i] = regs->regs[i - MIPS64_EF_R0]; 345 + } 346 + 347 + uregs[MIPS64_EF_LO] = regs->lo; 348 + uregs[MIPS64_EF_HI] = regs->hi; 349 + uregs[MIPS64_EF_CP0_EPC] = regs->cp0_epc; 350 + uregs[MIPS64_EF_CP0_BADVADDR] = regs->cp0_badvaddr; 351 + uregs[MIPS64_EF_CP0_STATUS] = regs->cp0_status; 352 + uregs[MIPS64_EF_CP0_CAUSE] = regs->cp0_cause; 353 + 354 + return user_regset_copyout(&pos, &count, &kbuf, &ubuf, uregs, 0, 355 + sizeof(uregs)); 356 + } 357 + 358 + static int gpr64_set(struct task_struct *target, 359 + const struct user_regset *regset, 360 + unsigned int pos, unsigned int count, 361 + const void *kbuf, const void __user *ubuf) 362 + { 363 + struct pt_regs *regs = task_pt_regs(target); 364 + u64 uregs[ELF_NGREG]; 365 + unsigned start, num_regs, i; 366 + int err; 367 + 368 + start = pos / sizeof(u64); 369 + num_regs = count / sizeof(u64); 370 + 371 + if (start + num_regs > ELF_NGREG) 372 + return -EIO; 373 + 374 + err = user_regset_copyin(&pos, &count, &kbuf, &ubuf, uregs, 0, 375 + sizeof(uregs)); 376 + if (err) 377 + return err; 378 + 379 + for (i = start; i < num_regs; i++) { 380 + switch (i) { 381 + case MIPS64_EF_R1 ... MIPS64_EF_R25: 382 + /* k0/k1 are ignored. */ 383 + case MIPS64_EF_R28 ... MIPS64_EF_R31: 384 + regs->regs[i - MIPS64_EF_R0] = uregs[i]; 385 + break; 386 + case MIPS64_EF_LO: 387 + regs->lo = uregs[i]; 388 + break; 389 + case MIPS64_EF_HI: 390 + regs->hi = uregs[i]; 391 + break; 392 + case MIPS64_EF_CP0_EPC: 393 + regs->cp0_epc = uregs[i]; 394 + break; 395 + } 396 + } 397 + 398 + return 0; 399 + } 400 + 401 + #endif /* CONFIG_64BIT */ 278 402 279 403 static int fpr_get(struct task_struct *target, 280 404 const struct user_regset *regset, ··· 461 337 REGSET_FPR, 462 338 }; 463 339 340 + #if defined(CONFIG_32BIT) || defined(CONFIG_MIPS32_O32) 341 + 464 342 static const struct user_regset mips_regsets[] = { 465 343 [REGSET_GPR] = { 466 344 .core_note_type = NT_PRSTATUS, 467 345 .n = ELF_NGREG, 468 346 .size = sizeof(unsigned int), 469 347 .align = sizeof(unsigned int), 470 - .get = gpr_get, 471 - .set = gpr_set, 348 + .get = gpr32_get, 349 + .set = gpr32_set, 472 350 }, 473 351 [REGSET_FPR] = { 474 352 .core_note_type = NT_PRFPREG, ··· 490 364 .n = ARRAY_SIZE(mips_regsets), 491 365 }; 492 366 367 + #endif /* CONFIG_32BIT || CONFIG_MIPS32_O32 */ 368 + 369 + #ifdef CONFIG_64BIT 370 + 493 371 static const struct user_regset mips64_regsets[] = { 494 372 [REGSET_GPR] = { 495 373 .core_note_type = NT_PRSTATUS, 496 374 .n = ELF_NGREG, 497 375 .size = sizeof(unsigned long), 498 376 .align = sizeof(unsigned long), 499 - .get = gpr_get, 500 - .set = gpr_set, 377 + .get = gpr64_get, 378 + .set = gpr64_set, 501 379 }, 502 380 [REGSET_FPR] = { 503 381 .core_note_type = NT_PRFPREG, ··· 514 384 }; 515 385 516 386 static const struct user_regset_view user_mips64_view = { 517 - .name = "mips", 387 + .name = "mips64", 518 388 .e_machine = ELF_ARCH, 519 389 .ei_osabi = ELF_OSABI, 520 390 .regsets = mips64_regsets, 521 - .n = ARRAY_SIZE(mips_regsets), 391 + .n = ARRAY_SIZE(mips64_regsets), 522 392 }; 393 + 394 + #endif /* CONFIG_64BIT */ 523 395 524 396 const struct user_regset_view *task_user_regset_view(struct task_struct *task) 525 397 { 526 398 #ifdef CONFIG_32BIT 527 399 return &user_mips_view; 528 - #endif 529 - 400 + #else 530 401 #ifdef CONFIG_MIPS32_O32 531 - if (test_thread_flag(TIF_32BIT_REGS)) 532 - return &user_mips_view; 402 + if (test_tsk_thread_flag(task, TIF_32BIT_REGS)) 403 + return &user_mips_view; 533 404 #endif 534 - 535 405 return &user_mips64_view; 406 + #endif 536 407 } 537 408 538 409 long arch_ptrace(struct task_struct *child, long request, ··· 611 480 break; 612 481 case FPC_EIR: 613 482 /* implementation / version register */ 614 - tmp = current_cpu_data.fpu_id; 483 + tmp = boot_cpu_data.fpu_id; 615 484 break; 616 485 case DSP_BASE ... DSP_BASE + 5: { 617 486 dspreg_t *dregs; ··· 696 565 break; 697 566 #endif 698 567 case FPC_CSR: 699 - child->thread.fpu.fcr31 = data; 568 + child->thread.fpu.fcr31 = data & ~FPU_CSR_ALL_X; 700 569 break; 701 570 case DSP_BASE ... DSP_BASE + 5: { 702 571 dspreg_t *dregs;
+6 -4
arch/mips/kernel/ptrace32.c
··· 22 22 #include <linux/errno.h> 23 23 #include <linux/ptrace.h> 24 24 #include <linux/smp.h> 25 - #include <linux/user.h> 26 25 #include <linux/security.h> 27 26 28 27 #include <asm/cpu.h> ··· 31 32 #include <asm/mipsmtregs.h> 32 33 #include <asm/pgtable.h> 33 34 #include <asm/page.h> 35 + #include <asm/reg.h> 34 36 #include <asm/uaccess.h> 35 37 #include <asm/bootinfo.h> 36 38 ··· 129 129 break; 130 130 case FPC_EIR: 131 131 /* implementation / version register */ 132 - tmp = current_cpu_data.fpu_id; 132 + tmp = boot_cpu_data.fpu_id; 133 133 break; 134 134 case DSP_BASE ... DSP_BASE + 5: { 135 135 dspreg_t *dregs; ··· 256 256 } 257 257 258 258 case PTRACE_GETREGS: 259 - ret = ptrace_getregs(child, (__s64 __user *) (__u64) data); 259 + ret = ptrace_getregs(child, 260 + (struct user_pt_regs __user *) (__u64) data); 260 261 break; 261 262 262 263 case PTRACE_SETREGS: 263 - ret = ptrace_setregs(child, (__s64 __user *) (__u64) data); 264 + ret = ptrace_setregs(child, 265 + (struct user_pt_regs __user *) (__u64) data); 264 266 break; 265 267 266 268 case PTRACE_GETFPREGS:
+8 -1
arch/mips/kernel/r4k_switch.S
··· 64 64 /* Check whether we're saving scalar or vector context. */ 65 65 bgtz a3, 1f 66 66 67 - /* Save 128b MSA vector context. */ 67 + /* Save 128b MSA vector context + scalar FP control & status. */ 68 + cfc1 t1, fcr31 68 69 msa_save_all a0 70 + sw t1, THREAD_FCR31(a0) 69 71 b 2f 70 72 71 73 1: /* Save 32b/64b scalar FP context. */ ··· 143 141 msa_restore_all a0 144 142 jr ra 145 143 END(_restore_msa) 144 + 145 + LEAF(_init_msa_upper) 146 + msa_init_all_upper 147 + jr ra 148 + END(_init_msa_upper) 146 149 147 150 #endif 148 151
+3
arch/mips/kernel/rtlx-cmp.c
··· 77 77 dev = device_create(mt_class, NULL, MKDEV(major, i), NULL, 78 78 "%s%d", RTLX_MODULE_NAME, i); 79 79 if (IS_ERR(dev)) { 80 + while (i--) 81 + device_destroy(mt_class, MKDEV(major, i)); 82 + 80 83 err = PTR_ERR(dev); 81 84 goto out_chrdev; 82 85 }
+3
arch/mips/kernel/rtlx-mt.c
··· 103 103 dev = device_create(mt_class, NULL, MKDEV(major, i), NULL, 104 104 "%s%d", RTLX_MODULE_NAME, i); 105 105 if (IS_ERR(dev)) { 106 + while (i--) 107 + device_destroy(mt_class, MKDEV(major, i)); 108 + 106 109 err = PTR_ERR(dev); 107 110 goto out_chrdev; 108 111 }
+2 -4
arch/mips/kernel/scall32-o32.S
··· 67 67 68 68 /* 69 69 * Ok, copy the args from the luser stack to the kernel stack. 70 - * t3 is the precomputed number of instruction bytes needed to 71 - * load or store arguments 6-8. 72 70 */ 73 71 74 72 .set push ··· 493 495 PTR sys_tgkill 494 496 PTR sys_utimes 495 497 PTR sys_mbind 496 - PTR sys_ni_syscall /* sys_get_mempolicy */ 497 - PTR sys_ni_syscall /* 4270 sys_set_mempolicy */ 498 + PTR sys_get_mempolicy 499 + PTR sys_set_mempolicy /* 4270 */ 498 500 PTR sys_mq_open 499 501 PTR sys_mq_unlink 500 502 PTR sys_mq_timedsend
+2 -2
arch/mips/kernel/scall64-64.S
··· 347 347 PTR sys_tgkill /* 5225 */ 348 348 PTR sys_utimes 349 349 PTR sys_mbind 350 - PTR sys_ni_syscall /* sys_get_mempolicy */ 351 - PTR sys_ni_syscall /* sys_set_mempolicy */ 350 + PTR sys_get_mempolicy 351 + PTR sys_set_mempolicy 352 352 PTR sys_mq_open /* 5230 */ 353 353 PTR sys_mq_unlink 354 354 PTR sys_mq_timedsend
+6 -6
arch/mips/kernel/scall64-n32.S
··· 162 162 PTR sys_getpeername 163 163 PTR sys_socketpair 164 164 PTR compat_sys_setsockopt 165 - PTR sys_getsockopt 165 + PTR compat_sys_getsockopt 166 166 PTR __sys_clone /* 6055 */ 167 167 PTR __sys_fork 168 168 PTR compat_sys_execve ··· 339 339 PTR compat_sys_clock_nanosleep 340 340 PTR sys_tgkill 341 341 PTR compat_sys_utimes /* 6230 */ 342 - PTR sys_ni_syscall /* sys_mbind */ 343 - PTR sys_ni_syscall /* sys_get_mempolicy */ 344 - PTR sys_ni_syscall /* sys_set_mempolicy */ 342 + PTR compat_sys_mbind 343 + PTR compat_sys_get_mempolicy 344 + PTR compat_sys_set_mempolicy 345 345 PTR compat_sys_mq_open 346 346 PTR sys_mq_unlink /* 6235 */ 347 347 PTR compat_sys_mq_timedsend ··· 358 358 PTR sys_inotify_init 359 359 PTR sys_inotify_add_watch 360 360 PTR sys_inotify_rm_watch 361 - PTR sys_migrate_pages /* 6250 */ 361 + PTR compat_sys_migrate_pages /* 6250 */ 362 362 PTR sys_openat 363 363 PTR sys_mkdirat 364 364 PTR sys_mknodat ··· 379 379 PTR sys_sync_file_range 380 380 PTR sys_tee 381 381 PTR compat_sys_vmsplice /* 6270 */ 382 - PTR sys_move_pages 382 + PTR compat_sys_move_pages 383 383 PTR compat_sys_set_robust_list 384 384 PTR compat_sys_get_robust_list 385 385 PTR compat_sys_kexec_load
+4 -4
arch/mips/kernel/scall64-o32.S
··· 473 473 PTR compat_sys_clock_nanosleep /* 4265 */ 474 474 PTR sys_tgkill 475 475 PTR compat_sys_utimes 476 - PTR sys_ni_syscall /* sys_mbind */ 477 - PTR sys_ni_syscall /* sys_get_mempolicy */ 478 - PTR sys_ni_syscall /* 4270 sys_set_mempolicy */ 476 + PTR compat_sys_mbind 477 + PTR compat_sys_get_mempolicy 478 + PTR compat_sys_set_mempolicy /* 4270 */ 479 479 PTR compat_sys_mq_open 480 480 PTR sys_mq_unlink 481 481 PTR compat_sys_mq_timedsend ··· 492 492 PTR sys_inotify_init 493 493 PTR sys_inotify_add_watch /* 4285 */ 494 494 PTR sys_inotify_rm_watch 495 - PTR sys_migrate_pages 495 + PTR compat_sys_migrate_pages 496 496 PTR compat_sys_openat 497 497 PTR sys_mkdirat 498 498 PTR sys_mknodat /* 4290 */
+21 -1
arch/mips/kernel/setup.c
··· 282 282 * Initialize the bootmem allocator. It also setup initrd related data 283 283 * if needed. 284 284 */ 285 - #ifdef CONFIG_SGI_IP27 285 + #if defined(CONFIG_SGI_IP27) || (defined(CONFIG_CPU_LOONGSON3) && defined(CONFIG_NUMA)) 286 286 287 287 static void __init bootmem_init(void) 288 288 { ··· 729 729 } 730 730 } 731 731 732 + #ifdef CONFIG_SMP 733 + static void __init prefill_possible_map(void) 734 + { 735 + int i, possible = num_possible_cpus(); 736 + 737 + if (possible > nr_cpu_ids) 738 + possible = nr_cpu_ids; 739 + 740 + for (i = 0; i < possible; i++) 741 + set_cpu_possible(i, true); 742 + for (; i < NR_CPUS; i++) 743 + set_cpu_possible(i, false); 744 + 745 + nr_cpu_ids = possible; 746 + } 747 + #else 748 + static inline void prefill_possible_map(void) {} 749 + #endif 750 + 732 751 void __init setup_arch(char **cmdline_p) 733 752 { 734 753 cpu_probe(); ··· 771 752 772 753 resource_init(); 773 754 plat_smp_setup(); 755 + prefill_possible_map(); 774 756 775 757 cpu_cache_init(); 776 758 }
+8 -4
arch/mips/kernel/smp-cps.c
··· 14 14 #include <linux/smp.h> 15 15 #include <linux/types.h> 16 16 17 - #include <asm/cacheflush.h> 17 + #include <asm/bcache.h> 18 18 #include <asm/gic.h> 19 19 #include <asm/mips-cm.h> 20 20 #include <asm/mips-cpc.h> 21 21 #include <asm/mips_mt.h> 22 22 #include <asm/mipsregs.h> 23 23 #include <asm/pm-cps.h> 24 + #include <asm/r4kcache.h> 24 25 #include <asm/smp-cps.h> 25 26 #include <asm/time.h> 26 27 #include <asm/uasm.h> ··· 133 132 entry_code = (u32 *)&mips_cps_core_entry; 134 133 UASM_i_LA(&entry_code, 3, (long)mips_cm_base); 135 134 uasm_i_addiu(&entry_code, 16, 0, cca); 136 - dma_cache_wback_inv((unsigned long)&mips_cps_core_entry, 137 - (void *)entry_code - (void *)&mips_cps_core_entry); 135 + blast_dcache_range((unsigned long)&mips_cps_core_entry, 136 + (unsigned long)entry_code); 137 + bc_wback_inv((unsigned long)&mips_cps_core_entry, 138 + (void *)entry_code - (void *)&mips_cps_core_entry); 139 + __sync(); 138 140 139 141 /* Allocate core boot configuration structs */ 140 142 mips_cps_core_bootcfg = kcalloc(ncores, sizeof(*mips_cps_core_bootcfg), ··· 364 360 static void wait_for_sibling_halt(void *ptr_cpu) 365 361 { 366 362 unsigned cpu = (unsigned)ptr_cpu; 367 - unsigned vpe_id = cpu_data[cpu].vpe_id; 363 + unsigned vpe_id = cpu_vpe_id(&cpu_data[cpu]); 368 364 unsigned halted; 369 365 unsigned long flags; 370 366
+2
arch/mips/kernel/smp-mt.c
··· 288 288 .prepare_cpus = vsmp_prepare_cpus, 289 289 }; 290 290 291 + #ifdef CONFIG_PROC_FS 291 292 static int proc_cpuinfo_chain_call(struct notifier_block *nfb, 292 293 unsigned long action_unused, void *data) 293 294 { ··· 310 309 } 311 310 312 311 subsys_initcall(proc_cpuinfo_notifier_init); 312 + #endif
+25 -1
arch/mips/kernel/smp.c
··· 59 59 cpumask_t cpu_sibling_map[NR_CPUS] __read_mostly; 60 60 EXPORT_SYMBOL(cpu_sibling_map); 61 61 62 + /* representing the core map of multi-core chips of each logical CPU */ 63 + cpumask_t cpu_core_map[NR_CPUS] __read_mostly; 64 + EXPORT_SYMBOL(cpu_core_map); 65 + 62 66 /* representing cpus for which sibling maps can be computed */ 63 67 static cpumask_t cpu_sibling_setup_map; 68 + 69 + /* representing cpus for which core maps can be computed */ 70 + static cpumask_t cpu_core_setup_map; 64 71 65 72 cpumask_t cpu_coherent_mask; 66 73 ··· 79 72 80 73 if (smp_num_siblings > 1) { 81 74 for_each_cpu_mask(i, cpu_sibling_setup_map) { 82 - if (cpu_data[cpu].core == cpu_data[i].core) { 75 + if (cpu_data[cpu].package == cpu_data[i].package && 76 + cpu_data[cpu].core == cpu_data[i].core) { 83 77 cpu_set(i, cpu_sibling_map[cpu]); 84 78 cpu_set(cpu, cpu_sibling_map[i]); 85 79 } 86 80 } 87 81 } else 88 82 cpu_set(cpu, cpu_sibling_map[cpu]); 83 + } 84 + 85 + static inline void set_cpu_core_map(int cpu) 86 + { 87 + int i; 88 + 89 + cpu_set(cpu, cpu_core_setup_map); 90 + 91 + for_each_cpu_mask(i, cpu_core_setup_map) { 92 + if (cpu_data[cpu].package == cpu_data[i].package) { 93 + cpu_set(i, cpu_core_map[cpu]); 94 + cpu_set(cpu, cpu_core_map[i]); 95 + } 96 + } 89 97 } 90 98 91 99 struct plat_smp_ops *mp_ops; ··· 144 122 set_cpu_online(cpu, true); 145 123 146 124 set_cpu_sibling_map(cpu); 125 + set_cpu_core_map(cpu); 147 126 148 127 cpu_set(cpu, cpu_callin_map); 149 128 ··· 198 175 current_thread_info()->cpu = 0; 199 176 mp_ops->prepare_cpus(max_cpus); 200 177 set_cpu_sibling_map(0); 178 + set_cpu_core_map(0); 201 179 #ifndef CONFIG_HOTPLUG_CPU 202 180 init_cpu_present(cpu_possible_mask); 203 181 #endif
+52 -9
arch/mips/kernel/traps.c
··· 90 90 extern asmlinkage void handle_dsp(void); 91 91 extern asmlinkage void handle_mcheck(void); 92 92 extern asmlinkage void handle_reserved(void); 93 + extern void tlb_do_page_fault_0(void); 93 94 94 95 void (*board_be_init)(void); 95 96 int (*board_be_handler)(struct pt_regs *regs, int is_fixup); ··· 1089 1088 1090 1089 static int enable_restore_fp_context(int msa) 1091 1090 { 1092 - int err, was_fpu_owner; 1091 + int err, was_fpu_owner, prior_msa; 1093 1092 1094 1093 if (!used_math()) { 1095 1094 /* First time FP context user. */ 1095 + preempt_disable(); 1096 1096 err = init_fpu(); 1097 - if (msa && !err) 1097 + if (msa && !err) { 1098 1098 enable_msa(); 1099 + _init_msa_upper(); 1100 + set_thread_flag(TIF_USEDMSA); 1101 + set_thread_flag(TIF_MSA_CTX_LIVE); 1102 + } 1103 + preempt_enable(); 1099 1104 if (!err) 1100 1105 set_used_math(); 1101 1106 return err; ··· 1141 1134 * This task is using or has previously used MSA. Thus we require 1142 1135 * that Status.FR == 1. 1143 1136 */ 1137 + preempt_disable(); 1144 1138 was_fpu_owner = is_fpu_owner(); 1145 - err = own_fpu(0); 1139 + err = own_fpu_inatomic(0); 1146 1140 if (err) 1147 - return err; 1141 + goto out; 1148 1142 1149 1143 enable_msa(); 1150 1144 write_msa_csr(current->thread.fpu.msacsr); ··· 1154 1146 /* 1155 1147 * If this is the first time that the task is using MSA and it has 1156 1148 * previously used scalar FP in this time slice then we already nave 1157 - * FP context which we shouldn't clobber. 1149 + * FP context which we shouldn't clobber. We do however need to clear 1150 + * the upper 64b of each vector register so that this task has no 1151 + * opportunity to see data left behind by another. 1158 1152 */ 1159 - if (!test_and_set_thread_flag(TIF_MSA_CTX_LIVE) && was_fpu_owner) 1160 - return 0; 1153 + prior_msa = test_and_set_thread_flag(TIF_MSA_CTX_LIVE); 1154 + if (!prior_msa && was_fpu_owner) { 1155 + _init_msa_upper(); 1161 1156 1162 - /* We need to restore the vector context. */ 1163 - restore_msa(current); 1157 + goto out; 1158 + } 1159 + 1160 + if (!prior_msa) { 1161 + /* 1162 + * Restore the least significant 64b of each vector register 1163 + * from the existing scalar FP context. 1164 + */ 1165 + _restore_fp(current); 1166 + 1167 + /* 1168 + * The task has not formerly used MSA, so clear the upper 64b 1169 + * of each vector register such that it cannot see data left 1170 + * behind by another task. 1171 + */ 1172 + _init_msa_upper(); 1173 + } else { 1174 + /* We need to restore the vector context. */ 1175 + restore_msa(current); 1176 + 1177 + /* Restore the scalar FP control & status register */ 1178 + if (!was_fpu_owner) 1179 + asm volatile("ctc1 %0, $31" : : "r"(current->thread.fpu.fcr31)); 1180 + } 1181 + 1182 + out: 1183 + preempt_enable(); 1184 + 1164 1185 return 0; 1165 1186 } 1166 1187 ··· 2151 2114 set_except_vector(15, handle_fpe); 2152 2115 2153 2116 set_except_vector(16, handle_ftlb); 2117 + 2118 + if (cpu_has_rixiex) { 2119 + set_except_vector(19, tlb_do_page_fault_0); 2120 + set_except_vector(20, tlb_do_page_fault_0); 2121 + } 2122 + 2154 2123 set_except_vector(21, handle_msa); 2155 2124 set_except_vector(22, handle_mdmx); 2156 2125
-1
arch/mips/kernel/unaligned.c
··· 690 690 case sdc1_op: 691 691 die_if_kernel("Unaligned FP access in kernel code", regs); 692 692 BUG_ON(!used_math()); 693 - BUG_ON(!is_fpu_owner()); 694 693 695 694 lose_fpu(1); /* Save FPU state for the emulator. */ 696 695 res = fpu_emulator_cop1Handler(regs, &current->thread.fpu, 1,
+5 -4
arch/mips/loongson/Kconfig
··· 60 60 These family machines include fuloong2f mini PC, yeeloong2f notebook, 61 61 LingLoong allinone PC and so forth. 62 62 63 - config LEMOTE_MACH3A 64 - bool "Lemote Loongson 3A family machines" 63 + config LOONGSON_MACH3X 64 + bool "Generic Loongson 3 family machines" 65 65 select ARCH_SPARSEMEM_ENABLE 66 66 select GENERIC_ISA_DMA_SUPPORT_BROKEN 67 67 select BOOT_ELF32 ··· 79 79 select SYS_HAS_EARLY_PRINTK 80 80 select SYS_SUPPORTS_SMP 81 81 select SYS_SUPPORTS_HOTPLUG_CPU 82 + select SYS_SUPPORTS_NUMA 82 83 select SYS_SUPPORTS_64BIT_KERNEL 83 84 select SYS_SUPPORTS_HIGHMEM 84 85 select SYS_SUPPORTS_LITTLE_ENDIAN ··· 87 86 select ZONE_DMA32 88 87 select LEFI_FIRMWARE_INTERFACE 89 88 help 90 - Lemote Loongson 3A family machines utilize the 3A revision of 91 - Loongson processor and RS780/SBX00 chipset. 89 + Generic Loongson 3 family machines utilize the 3A/3B revision 90 + of Loongson processor and RS780/SBX00 chipset. 92 91 endchoice 93 92 94 93 config CS5536
+1 -1
arch/mips/loongson/Platform
··· 30 30 cflags-$(CONFIG_MACH_LOONGSON) += -I$(srctree)/arch/mips/include/asm/mach-loongson -mno-branch-likely 31 31 load-$(CONFIG_LEMOTE_FULOONG2E) += 0xffffffff80100000 32 32 load-$(CONFIG_LEMOTE_MACH2F) += 0xffffffff80200000 33 - load-$(CONFIG_CPU_LOONGSON3) += 0xffffffff80200000 33 + load-$(CONFIG_LOONGSON_MACH3X) += 0xffffffff80200000
+48 -1
arch/mips/loongson/common/env.c
··· 27 27 struct efi_memory_map_loongson *loongson_memmap; 28 28 struct loongson_system_configuration loongson_sysconf; 29 29 30 + u64 loongson_chipcfg[MAX_PACKAGES] = {0xffffffffbfc00180}; 31 + u64 loongson_freqctrl[MAX_PACKAGES]; 32 + 33 + unsigned long long smp_group[4]; 34 + int cpuhotplug_workaround = 0; 35 + 30 36 #define parse_even_earlier(res, option, p) \ 31 37 do { \ 32 38 unsigned int tmp __maybe_unused; \ ··· 83 77 84 78 cpu_clock_freq = ecpu->cpu_clock_freq; 85 79 loongson_sysconf.cputype = ecpu->cputype; 80 + if (ecpu->cputype == Loongson_3A) { 81 + loongson_sysconf.cores_per_node = 4; 82 + loongson_sysconf.cores_per_package = 4; 83 + smp_group[0] = 0x900000003ff01000; 84 + smp_group[1] = 0x900010003ff01000; 85 + smp_group[2] = 0x900020003ff01000; 86 + smp_group[3] = 0x900030003ff01000; 87 + loongson_chipcfg[0] = 0x900000001fe00180; 88 + loongson_chipcfg[1] = 0x900010001fe00180; 89 + loongson_chipcfg[2] = 0x900020001fe00180; 90 + loongson_chipcfg[3] = 0x900030001fe00180; 91 + loongson_sysconf.ht_control_base = 0x90000EFDFB000000; 92 + } else if (ecpu->cputype == Loongson_3B) { 93 + loongson_sysconf.cores_per_node = 4; /* One chip has 2 nodes */ 94 + loongson_sysconf.cores_per_package = 8; 95 + smp_group[0] = 0x900000003ff01000; 96 + smp_group[1] = 0x900010003ff05000; 97 + smp_group[2] = 0x900020003ff09000; 98 + smp_group[3] = 0x900030003ff0d000; 99 + loongson_chipcfg[0] = 0x900000001fe00180; 100 + loongson_chipcfg[1] = 0x900020001fe00180; 101 + loongson_chipcfg[2] = 0x900040001fe00180; 102 + loongson_chipcfg[3] = 0x900060001fe00180; 103 + loongson_freqctrl[0] = 0x900000001fe001d0; 104 + loongson_freqctrl[1] = 0x900020001fe001d0; 105 + loongson_freqctrl[2] = 0x900040001fe001d0; 106 + loongson_freqctrl[3] = 0x900060001fe001d0; 107 + loongson_sysconf.ht_control_base = 0x90001EFDFB000000; 108 + cpuhotplug_workaround = 1; 109 + } else { 110 + loongson_sysconf.cores_per_node = 1; 111 + loongson_sysconf.cores_per_package = 1; 112 + loongson_chipcfg[0] = 0x900000001fe00180; 113 + } 114 + 86 115 loongson_sysconf.nr_cpus = ecpu->nr_cpus; 87 116 if (ecpu->nr_cpus > NR_CPUS || ecpu->nr_cpus == 0) 88 117 loongson_sysconf.nr_cpus = NR_CPUS; 118 + loongson_sysconf.nr_nodes = (loongson_sysconf.nr_cpus + 119 + loongson_sysconf.cores_per_node - 1) / 120 + loongson_sysconf.cores_per_node; 89 121 90 122 loongson_sysconf.pci_mem_start_addr = eirq_source->pci_mem_start_addr; 91 123 loongson_sysconf.pci_mem_end_addr = eirq_source->pci_mem_end_addr; ··· 137 93 loongson_sysconf.poweroff_addr = boot_p->reset_system.Shutdown; 138 94 loongson_sysconf.suspend_addr = boot_p->reset_system.DoSuspend; 139 95 140 - loongson_sysconf.ht_control_base = 0x90000EFDFB000000; 141 96 loongson_sysconf.vgabios_addr = boot_p->efi.smbios.vga_bios; 142 97 pr_debug("Shutdown Addr: %llx, Restart Addr: %llx, VBIOS Addr: %llx\n", 143 98 loongson_sysconf.poweroff_addr, loongson_sysconf.restart_addr, ··· 153 110 break; 154 111 case PRID_REV_LOONGSON3A: 155 112 cpu_clock_freq = 900000000; 113 + break; 114 + case PRID_REV_LOONGSON3B_R1: 115 + case PRID_REV_LOONGSON3B_R2: 116 + cpu_clock_freq = 1000000000; 156 117 break; 157 118 default: 158 119 cpu_clock_freq = 100000000;
+4
arch/mips/loongson/common/init.c
··· 30 30 set_io_port_base((unsigned long) 31 31 ioremap(LOONGSON_PCIIO_BASE, LOONGSON_PCIIO_SIZE)); 32 32 33 + #ifdef CONFIG_NUMA 34 + prom_init_numa_memory(); 35 + #else 33 36 prom_init_memory(); 37 + #endif 34 38 35 39 /*init the uart base address */ 36 40 prom_init_uart_base();
+4 -4
arch/mips/loongson/common/pm.c
··· 79 79 static void wait_for_wakeup_events(void) 80 80 { 81 81 while (!wakeup_loongson()) 82 - LOONGSON_CHIPCFG0 &= ~0x7; 82 + LOONGSON_CHIPCFG(0) &= ~0x7; 83 83 } 84 84 85 85 /* ··· 102 102 103 103 stop_perf_counters(); 104 104 105 - cached_cpu_freq = LOONGSON_CHIPCFG0; 105 + cached_cpu_freq = LOONGSON_CHIPCFG(0); 106 106 107 107 /* Put CPU into wait mode */ 108 - LOONGSON_CHIPCFG0 &= ~0x7; 108 + LOONGSON_CHIPCFG(0) &= ~0x7; 109 109 110 110 /* wait for the given events to wakeup cpu from wait mode */ 111 111 wait_for_wakeup_events(); 112 112 113 - LOONGSON_CHIPCFG0 = cached_cpu_freq; 113 + LOONGSON_CHIPCFG(0) = cached_cpu_freq; 114 114 mmiowb(); 115 115 } 116 116
+2 -2
arch/mips/loongson/lemote-2f/clock.c
··· 114 114 115 115 clk->rate = rate; 116 116 117 - regval = LOONGSON_CHIPCFG0; 117 + regval = LOONGSON_CHIPCFG(0); 118 118 regval = (regval & ~0x7) | (pos->driver_data - 1); 119 - LOONGSON_CHIPCFG0 = regval; 119 + LOONGSON_CHIPCFG(0) = regval; 120 120 121 121 return ret; 122 122 }
+1 -1
arch/mips/loongson/lemote-2f/reset.c
··· 28 28 * reset cpu to full speed, this is needed when enabling cpu frequency 29 29 * scalling 30 30 */ 31 - LOONGSON_CHIPCFG0 |= 0x7; 31 + LOONGSON_CHIPCFG(0) |= 0x7; 32 32 } 33 33 34 34 /* reset support for fuloong2f */
+3 -1
arch/mips/loongson/loongson-3/Makefile
··· 1 1 # 2 2 # Makefile for Loongson-3 family machines 3 3 # 4 - obj-y += irq.o 4 + obj-y += irq.o cop2-ex.o 5 5 6 6 obj-$(CONFIG_SMP) += smp.o 7 + 8 + obj-$(CONFIG_NUMA) += numa.o
+63
arch/mips/loongson/loongson-3/cop2-ex.c
··· 1 + /* 2 + * This file is subject to the terms and conditions of the GNU General Public 3 + * License. See the file "COPYING" in the main directory of this archive 4 + * for more details. 5 + * 6 + * Copyright (C) 2014 Lemote Corporation. 7 + * written by Huacai Chen <chenhc@lemote.com> 8 + * 9 + * based on arch/mips/cavium-octeon/cpu.c 10 + * Copyright (C) 2009 Wind River Systems, 11 + * written by Ralf Baechle <ralf@linux-mips.org> 12 + */ 13 + #include <linux/init.h> 14 + #include <linux/sched.h> 15 + #include <linux/notifier.h> 16 + 17 + #include <asm/fpu.h> 18 + #include <asm/cop2.h> 19 + #include <asm/current.h> 20 + #include <asm/mipsregs.h> 21 + 22 + static int loongson_cu2_call(struct notifier_block *nfb, unsigned long action, 23 + void *data) 24 + { 25 + int fpu_enabled; 26 + int fr = !test_thread_flag(TIF_32BIT_FPREGS); 27 + 28 + switch (action) { 29 + case CU2_EXCEPTION: 30 + preempt_disable(); 31 + fpu_enabled = read_c0_status() & ST0_CU1; 32 + if (!fr) 33 + set_c0_status(ST0_CU1 | ST0_CU2); 34 + else 35 + set_c0_status(ST0_CU1 | ST0_CU2 | ST0_FR); 36 + enable_fpu_hazard(); 37 + KSTK_STATUS(current) |= (ST0_CU1 | ST0_CU2); 38 + if (fr) 39 + KSTK_STATUS(current) |= ST0_FR; 40 + else 41 + KSTK_STATUS(current) &= ~ST0_FR; 42 + /* If FPU is enabled, we needn't init or restore fp */ 43 + if(!fpu_enabled) { 44 + set_thread_flag(TIF_USEDFPU); 45 + if (!used_math()) { 46 + _init_fpu(); 47 + set_used_math(); 48 + } else 49 + _restore_fp(current); 50 + } 51 + preempt_enable(); 52 + 53 + return NOTIFY_STOP; /* Don't call default notifier */ 54 + } 55 + 56 + return NOTIFY_OK; /* Let default notifier send signals */ 57 + } 58 + 59 + static int __init loongson_cu2_setup(void) 60 + { 61 + return cu2_notifier(loongson_cu2_call, 0); 62 + } 63 + early_initcall(loongson_cu2_setup);
+18 -4
arch/mips/loongson/loongson-3/irq.c
··· 7 7 #include <asm/i8259.h> 8 8 #include <asm/mipsregs.h> 9 9 10 + #include "smp.h" 11 + 10 12 unsigned int ht_irq[] = {1, 3, 4, 5, 6, 7, 8, 12, 14, 15}; 11 13 12 14 static void ht_irqdispatch(void) ··· 55 53 /* Workaround: UART IRQ may deliver to any core */ 56 54 if (d->irq == LOONGSON_UART_IRQ) { 57 55 int cpu = smp_processor_id(); 56 + int node_id = cpu / loongson_sysconf.cores_per_node; 57 + int core_id = cpu % loongson_sysconf.cores_per_node; 58 + u64 intenclr_addr = smp_group[node_id] | 59 + (u64)(&LOONGSON_INT_ROUTER_INTENCLR); 60 + u64 introuter_lpc_addr = smp_group[node_id] | 61 + (u64)(&LOONGSON_INT_ROUTER_LPC); 58 62 59 - LOONGSON_INT_ROUTER_INTENCLR = 1 << 10; 60 - LOONGSON_INT_ROUTER_LPC = 0x10 + (1<<cpu); 63 + *(volatile u32 *)intenclr_addr = 1 << 10; 64 + *(volatile u8 *)introuter_lpc_addr = 0x10 + (1<<core_id); 61 65 } 62 66 } 63 67 ··· 72 64 /* Workaround: UART IRQ may deliver to any core */ 73 65 if (d->irq == LOONGSON_UART_IRQ) { 74 66 int cpu = smp_processor_id(); 67 + int node_id = cpu / loongson_sysconf.cores_per_node; 68 + int core_id = cpu % loongson_sysconf.cores_per_node; 69 + u64 intenset_addr = smp_group[node_id] | 70 + (u64)(&LOONGSON_INT_ROUTER_INTENSET); 71 + u64 introuter_lpc_addr = smp_group[node_id] | 72 + (u64)(&LOONGSON_INT_ROUTER_LPC); 75 73 76 - LOONGSON_INT_ROUTER_INTENSET = 1 << 10; 77 - LOONGSON_INT_ROUTER_LPC = 0x10 + (1<<cpu); 74 + *(volatile u32 *)intenset_addr = 1 << 10; 75 + *(volatile u8 *)introuter_lpc_addr = 0x10 + (1<<core_id); 78 76 } 79 77 80 78 set_c0_status(0x100 << (d->irq - MIPS_CPU_IRQ_BASE));
+291
arch/mips/loongson/loongson-3/numa.c
··· 1 + /* 2 + * Copyright (C) 2010 Loongson Inc. & Lemote Inc. & 3 + * Insititute of Computing Technology 4 + * Author: Xiang Gao, gaoxiang@ict.ac.cn 5 + * Huacai Chen, chenhc@lemote.com 6 + * Xiaofu Meng, Shuangshuang Zhang 7 + * 8 + * This program is free software; you can redistribute it and/or modify it 9 + * under the terms of the GNU General Public License as published by the 10 + * Free Software Foundation; either version 2 of the License, or (at your 11 + * option) any later version. 12 + */ 13 + #include <linux/init.h> 14 + #include <linux/kernel.h> 15 + #include <linux/mm.h> 16 + #include <linux/mmzone.h> 17 + #include <linux/module.h> 18 + #include <linux/nodemask.h> 19 + #include <linux/swap.h> 20 + #include <linux/memblock.h> 21 + #include <linux/bootmem.h> 22 + #include <linux/pfn.h> 23 + #include <linux/highmem.h> 24 + #include <asm/page.h> 25 + #include <asm/pgalloc.h> 26 + #include <asm/sections.h> 27 + #include <linux/bootmem.h> 28 + #include <linux/init.h> 29 + #include <linux/irq.h> 30 + #include <asm/bootinfo.h> 31 + #include <asm/mc146818-time.h> 32 + #include <asm/time.h> 33 + #include <asm/wbflush.h> 34 + #include <boot_param.h> 35 + 36 + static struct node_data prealloc__node_data[MAX_NUMNODES]; 37 + unsigned char __node_distances[MAX_NUMNODES][MAX_NUMNODES]; 38 + struct node_data *__node_data[MAX_NUMNODES]; 39 + EXPORT_SYMBOL(__node_data); 40 + 41 + static void enable_lpa(void) 42 + { 43 + unsigned long value; 44 + 45 + value = __read_32bit_c0_register($16, 3); 46 + value |= 0x00000080; 47 + __write_32bit_c0_register($16, 3, value); 48 + value = __read_32bit_c0_register($16, 3); 49 + pr_info("CP0_Config3: CP0 16.3 (0x%lx)\n", value); 50 + 51 + value = __read_32bit_c0_register($5, 1); 52 + value |= 0x20000000; 53 + __write_32bit_c0_register($5, 1, value); 54 + value = __read_32bit_c0_register($5, 1); 55 + pr_info("CP0_PageGrain: CP0 5.1 (0x%lx)\n", value); 56 + } 57 + 58 + static void cpu_node_probe(void) 59 + { 60 + int i; 61 + 62 + nodes_clear(node_possible_map); 63 + nodes_clear(node_online_map); 64 + for (i = 0; i < loongson_sysconf.nr_nodes; i++) { 65 + node_set_state(num_online_nodes(), N_POSSIBLE); 66 + node_set_online(num_online_nodes()); 67 + } 68 + 69 + pr_info("NUMA: Discovered %d cpus on %d nodes\n", 70 + loongson_sysconf.nr_cpus, num_online_nodes()); 71 + } 72 + 73 + static int __init compute_node_distance(int row, int col) 74 + { 75 + int package_row = row * loongson_sysconf.cores_per_node / 76 + loongson_sysconf.cores_per_package; 77 + int package_col = col * loongson_sysconf.cores_per_node / 78 + loongson_sysconf.cores_per_package; 79 + 80 + if (col == row) 81 + return 0; 82 + else if (package_row == package_col) 83 + return 40; 84 + else 85 + return 100; 86 + } 87 + 88 + static void __init init_topology_matrix(void) 89 + { 90 + int row, col; 91 + 92 + for (row = 0; row < MAX_NUMNODES; row++) 93 + for (col = 0; col < MAX_NUMNODES; col++) 94 + __node_distances[row][col] = -1; 95 + 96 + for_each_online_node(row) { 97 + for_each_online_node(col) { 98 + __node_distances[row][col] = 99 + compute_node_distance(row, col); 100 + } 101 + } 102 + } 103 + 104 + static unsigned long nid_to_addroffset(unsigned int nid) 105 + { 106 + unsigned long result; 107 + switch (nid) { 108 + case 0: 109 + default: 110 + result = NODE0_ADDRSPACE_OFFSET; 111 + break; 112 + case 1: 113 + result = NODE1_ADDRSPACE_OFFSET; 114 + break; 115 + case 2: 116 + result = NODE2_ADDRSPACE_OFFSET; 117 + break; 118 + case 3: 119 + result = NODE3_ADDRSPACE_OFFSET; 120 + break; 121 + } 122 + return result; 123 + } 124 + 125 + static void __init szmem(unsigned int node) 126 + { 127 + u32 i, mem_type; 128 + static unsigned long num_physpages = 0; 129 + u64 node_id, node_psize, start_pfn, end_pfn, mem_start, mem_size; 130 + 131 + /* Parse memory information and activate */ 132 + for (i = 0; i < loongson_memmap->nr_map; i++) { 133 + node_id = loongson_memmap->map[i].node_id; 134 + if (node_id != node) 135 + continue; 136 + 137 + mem_type = loongson_memmap->map[i].mem_type; 138 + mem_size = loongson_memmap->map[i].mem_size; 139 + mem_start = loongson_memmap->map[i].mem_start; 140 + 141 + switch (mem_type) { 142 + case SYSTEM_RAM_LOW: 143 + start_pfn = ((node_id << 44) + mem_start) >> PAGE_SHIFT; 144 + node_psize = (mem_size << 20) >> PAGE_SHIFT; 145 + end_pfn = start_pfn + node_psize; 146 + num_physpages += node_psize; 147 + pr_info("Node%d: mem_type:%d, mem_start:0x%llx, mem_size:0x%llx MB\n", 148 + (u32)node_id, mem_type, mem_start, mem_size); 149 + pr_info(" start_pfn:0x%llx, end_pfn:0x%llx, num_physpages:0x%lx\n", 150 + start_pfn, end_pfn, num_physpages); 151 + add_memory_region((node_id << 44) + mem_start, 152 + (u64)mem_size << 20, BOOT_MEM_RAM); 153 + memblock_add_node(PFN_PHYS(start_pfn), 154 + PFN_PHYS(end_pfn - start_pfn), node); 155 + break; 156 + case SYSTEM_RAM_HIGH: 157 + start_pfn = ((node_id << 44) + mem_start) >> PAGE_SHIFT; 158 + node_psize = (mem_size << 20) >> PAGE_SHIFT; 159 + end_pfn = start_pfn + node_psize; 160 + num_physpages += node_psize; 161 + pr_info("Node%d: mem_type:%d, mem_start:0x%llx, mem_size:0x%llx MB\n", 162 + (u32)node_id, mem_type, mem_start, mem_size); 163 + pr_info(" start_pfn:0x%llx, end_pfn:0x%llx, num_physpages:0x%lx\n", 164 + start_pfn, end_pfn, num_physpages); 165 + add_memory_region((node_id << 44) + mem_start, 166 + (u64)mem_size << 20, BOOT_MEM_RAM); 167 + memblock_add_node(PFN_PHYS(start_pfn), 168 + PFN_PHYS(end_pfn - start_pfn), node); 169 + break; 170 + case MEM_RESERVED: 171 + pr_info("Node%d: mem_type:%d, mem_start:0x%llx, mem_size:0x%llx MB\n", 172 + (u32)node_id, mem_type, mem_start, mem_size); 173 + add_memory_region((node_id << 44) + mem_start, 174 + (u64)mem_size << 20, BOOT_MEM_RESERVED); 175 + memblock_reserve(((node_id << 44) + mem_start), 176 + mem_size << 20); 177 + break; 178 + } 179 + } 180 + } 181 + 182 + static void __init node_mem_init(unsigned int node) 183 + { 184 + unsigned long bootmap_size; 185 + unsigned long node_addrspace_offset; 186 + unsigned long start_pfn, end_pfn, freepfn; 187 + 188 + node_addrspace_offset = nid_to_addroffset(node); 189 + pr_info("Node%d's addrspace_offset is 0x%lx\n", 190 + node, node_addrspace_offset); 191 + 192 + get_pfn_range_for_nid(node, &start_pfn, &end_pfn); 193 + freepfn = start_pfn; 194 + if (node == 0) 195 + freepfn = PFN_UP(__pa_symbol(&_end)); /* kernel end address */ 196 + pr_info("Node%d: start_pfn=0x%lx, end_pfn=0x%lx, freepfn=0x%lx\n", 197 + node, start_pfn, end_pfn, freepfn); 198 + 199 + __node_data[node] = prealloc__node_data + node; 200 + 201 + NODE_DATA(node)->bdata = &bootmem_node_data[node]; 202 + NODE_DATA(node)->node_start_pfn = start_pfn; 203 + NODE_DATA(node)->node_spanned_pages = end_pfn - start_pfn; 204 + 205 + bootmap_size = init_bootmem_node(NODE_DATA(node), freepfn, 206 + start_pfn, end_pfn); 207 + free_bootmem_with_active_regions(node, end_pfn); 208 + if (node == 0) /* used by finalize_initrd() */ 209 + max_low_pfn = end_pfn; 210 + 211 + /* This is reserved for the kernel and bdata->node_bootmem_map */ 212 + reserve_bootmem_node(NODE_DATA(node), start_pfn << PAGE_SHIFT, 213 + ((freepfn - start_pfn) << PAGE_SHIFT) + bootmap_size, 214 + BOOTMEM_DEFAULT); 215 + 216 + if (node == 0 && node_end_pfn(0) >= (0xffffffff >> PAGE_SHIFT)) { 217 + /* Reserve 0xff800000~0xffffffff for RS780E integrated GPU */ 218 + reserve_bootmem_node(NODE_DATA(node), 219 + (node_addrspace_offset | 0xff800000), 220 + 8 << 20, BOOTMEM_DEFAULT); 221 + } 222 + 223 + sparse_memory_present_with_active_regions(node); 224 + } 225 + 226 + static __init void prom_meminit(void) 227 + { 228 + unsigned int node, cpu; 229 + 230 + cpu_node_probe(); 231 + init_topology_matrix(); 232 + 233 + for (node = 0; node < loongson_sysconf.nr_nodes; node++) { 234 + if (node_online(node)) { 235 + szmem(node); 236 + node_mem_init(node); 237 + cpus_clear(__node_data[(node)]->cpumask); 238 + } 239 + } 240 + for (cpu = 0; cpu < loongson_sysconf.nr_cpus; cpu++) { 241 + node = cpu / loongson_sysconf.cores_per_node; 242 + if (node >= num_online_nodes()) 243 + node = 0; 244 + pr_info("NUMA: set cpumask cpu %d on node %d\n", cpu, node); 245 + cpu_set(cpu, __node_data[(node)]->cpumask); 246 + } 247 + } 248 + 249 + void __init paging_init(void) 250 + { 251 + unsigned node; 252 + unsigned long zones_size[MAX_NR_ZONES] = {0, }; 253 + 254 + pagetable_init(); 255 + 256 + for_each_online_node(node) { 257 + unsigned long start_pfn, end_pfn; 258 + 259 + get_pfn_range_for_nid(node, &start_pfn, &end_pfn); 260 + 261 + if (end_pfn > max_low_pfn) 262 + max_low_pfn = end_pfn; 263 + } 264 + #ifdef CONFIG_ZONE_DMA32 265 + zones_size[ZONE_DMA32] = MAX_DMA32_PFN; 266 + #endif 267 + zones_size[ZONE_NORMAL] = max_low_pfn; 268 + free_area_init_nodes(zones_size); 269 + } 270 + 271 + void __init mem_init(void) 272 + { 273 + high_memory = (void *) __va(get_num_physpages() << PAGE_SHIFT); 274 + free_all_bootmem(); 275 + setup_zero_pages(); /* This comes from node 0 */ 276 + mem_init_print_info(NULL); 277 + } 278 + 279 + /* All PCI device belongs to logical Node-0 */ 280 + int pcibus_to_node(struct pci_bus *bus) 281 + { 282 + return 0; 283 + } 284 + EXPORT_SYMBOL(pcibus_to_node); 285 + 286 + void __init prom_init_numa_memory(void) 287 + { 288 + enable_lpa(); 289 + prom_meminit(); 290 + } 291 + EXPORT_SYMBOL(prom_init_numa_memory);
+292 -95
arch/mips/loongson/loongson-3/smp.c
··· 31 31 DEFINE_PER_CPU(int, cpu_state); 32 32 DEFINE_PER_CPU(uint32_t, core0_c0count); 33 33 34 + static void *ipi_set0_regs[16]; 35 + static void *ipi_clear0_regs[16]; 36 + static void *ipi_status0_regs[16]; 37 + static void *ipi_en0_regs[16]; 38 + static void *ipi_mailbox_buf[16]; 39 + 34 40 /* read a 32bit value from ipi register */ 35 41 #define loongson3_ipi_read32(addr) readl(addr) 36 42 /* read a 64bit value from ipi register */ ··· 54 48 __wbflush(); \ 55 49 } while (0) 56 50 57 - static void *ipi_set0_regs[] = { 58 - (void *)(SMP_CORE_GROUP0_BASE + SMP_CORE0_OFFSET + SET0), 59 - (void *)(SMP_CORE_GROUP0_BASE + SMP_CORE1_OFFSET + SET0), 60 - (void *)(SMP_CORE_GROUP0_BASE + SMP_CORE2_OFFSET + SET0), 61 - (void *)(SMP_CORE_GROUP0_BASE + SMP_CORE3_OFFSET + SET0), 62 - (void *)(SMP_CORE_GROUP1_BASE + SMP_CORE0_OFFSET + SET0), 63 - (void *)(SMP_CORE_GROUP1_BASE + SMP_CORE1_OFFSET + SET0), 64 - (void *)(SMP_CORE_GROUP1_BASE + SMP_CORE2_OFFSET + SET0), 65 - (void *)(SMP_CORE_GROUP1_BASE + SMP_CORE3_OFFSET + SET0), 66 - (void *)(SMP_CORE_GROUP2_BASE + SMP_CORE0_OFFSET + SET0), 67 - (void *)(SMP_CORE_GROUP2_BASE + SMP_CORE1_OFFSET + SET0), 68 - (void *)(SMP_CORE_GROUP2_BASE + SMP_CORE2_OFFSET + SET0), 69 - (void *)(SMP_CORE_GROUP2_BASE + SMP_CORE3_OFFSET + SET0), 70 - (void *)(SMP_CORE_GROUP3_BASE + SMP_CORE0_OFFSET + SET0), 71 - (void *)(SMP_CORE_GROUP3_BASE + SMP_CORE1_OFFSET + SET0), 72 - (void *)(SMP_CORE_GROUP3_BASE + SMP_CORE2_OFFSET + SET0), 73 - (void *)(SMP_CORE_GROUP3_BASE + SMP_CORE3_OFFSET + SET0), 74 - }; 51 + static void ipi_set0_regs_init(void) 52 + { 53 + ipi_set0_regs[0] = (void *) 54 + (SMP_CORE_GROUP0_BASE + SMP_CORE0_OFFSET + SET0); 55 + ipi_set0_regs[1] = (void *) 56 + (SMP_CORE_GROUP0_BASE + SMP_CORE1_OFFSET + SET0); 57 + ipi_set0_regs[2] = (void *) 58 + (SMP_CORE_GROUP0_BASE + SMP_CORE2_OFFSET + SET0); 59 + ipi_set0_regs[3] = (void *) 60 + (SMP_CORE_GROUP0_BASE + SMP_CORE3_OFFSET + SET0); 61 + ipi_set0_regs[4] = (void *) 62 + (SMP_CORE_GROUP1_BASE + SMP_CORE0_OFFSET + SET0); 63 + ipi_set0_regs[5] = (void *) 64 + (SMP_CORE_GROUP1_BASE + SMP_CORE1_OFFSET + SET0); 65 + ipi_set0_regs[6] = (void *) 66 + (SMP_CORE_GROUP1_BASE + SMP_CORE2_OFFSET + SET0); 67 + ipi_set0_regs[7] = (void *) 68 + (SMP_CORE_GROUP1_BASE + SMP_CORE3_OFFSET + SET0); 69 + ipi_set0_regs[8] = (void *) 70 + (SMP_CORE_GROUP2_BASE + SMP_CORE0_OFFSET + SET0); 71 + ipi_set0_regs[9] = (void *) 72 + (SMP_CORE_GROUP2_BASE + SMP_CORE1_OFFSET + SET0); 73 + ipi_set0_regs[10] = (void *) 74 + (SMP_CORE_GROUP2_BASE + SMP_CORE2_OFFSET + SET0); 75 + ipi_set0_regs[11] = (void *) 76 + (SMP_CORE_GROUP2_BASE + SMP_CORE3_OFFSET + SET0); 77 + ipi_set0_regs[12] = (void *) 78 + (SMP_CORE_GROUP3_BASE + SMP_CORE0_OFFSET + SET0); 79 + ipi_set0_regs[13] = (void *) 80 + (SMP_CORE_GROUP3_BASE + SMP_CORE1_OFFSET + SET0); 81 + ipi_set0_regs[14] = (void *) 82 + (SMP_CORE_GROUP3_BASE + SMP_CORE2_OFFSET + SET0); 83 + ipi_set0_regs[15] = (void *) 84 + (SMP_CORE_GROUP3_BASE + SMP_CORE3_OFFSET + SET0); 85 + } 75 86 76 - static void *ipi_clear0_regs[] = { 77 - (void *)(SMP_CORE_GROUP0_BASE + SMP_CORE0_OFFSET + CLEAR0), 78 - (void *)(SMP_CORE_GROUP0_BASE + SMP_CORE1_OFFSET + CLEAR0), 79 - (void *)(SMP_CORE_GROUP0_BASE + SMP_CORE2_OFFSET + CLEAR0), 80 - (void *)(SMP_CORE_GROUP0_BASE + SMP_CORE3_OFFSET + CLEAR0), 81 - (void *)(SMP_CORE_GROUP1_BASE + SMP_CORE0_OFFSET + CLEAR0), 82 - (void *)(SMP_CORE_GROUP1_BASE + SMP_CORE1_OFFSET + CLEAR0), 83 - (void *)(SMP_CORE_GROUP1_BASE + SMP_CORE2_OFFSET + CLEAR0), 84 - (void *)(SMP_CORE_GROUP1_BASE + SMP_CORE3_OFFSET + CLEAR0), 85 - (void *)(SMP_CORE_GROUP2_BASE + SMP_CORE0_OFFSET + CLEAR0), 86 - (void *)(SMP_CORE_GROUP2_BASE + SMP_CORE1_OFFSET + CLEAR0), 87 - (void *)(SMP_CORE_GROUP2_BASE + SMP_CORE2_OFFSET + CLEAR0), 88 - (void *)(SMP_CORE_GROUP2_BASE + SMP_CORE3_OFFSET + CLEAR0), 89 - (void *)(SMP_CORE_GROUP3_BASE + SMP_CORE0_OFFSET + CLEAR0), 90 - (void *)(SMP_CORE_GROUP3_BASE + SMP_CORE1_OFFSET + CLEAR0), 91 - (void *)(SMP_CORE_GROUP3_BASE + SMP_CORE2_OFFSET + CLEAR0), 92 - (void *)(SMP_CORE_GROUP3_BASE + SMP_CORE3_OFFSET + CLEAR0), 93 - }; 87 + static void ipi_clear0_regs_init(void) 88 + { 89 + ipi_clear0_regs[0] = (void *) 90 + (SMP_CORE_GROUP0_BASE + SMP_CORE0_OFFSET + CLEAR0); 91 + ipi_clear0_regs[1] = (void *) 92 + (SMP_CORE_GROUP0_BASE + SMP_CORE1_OFFSET + CLEAR0); 93 + ipi_clear0_regs[2] = (void *) 94 + (SMP_CORE_GROUP0_BASE + SMP_CORE2_OFFSET + CLEAR0); 95 + ipi_clear0_regs[3] = (void *) 96 + (SMP_CORE_GROUP0_BASE + SMP_CORE3_OFFSET + CLEAR0); 97 + ipi_clear0_regs[4] = (void *) 98 + (SMP_CORE_GROUP1_BASE + SMP_CORE0_OFFSET + CLEAR0); 99 + ipi_clear0_regs[5] = (void *) 100 + (SMP_CORE_GROUP1_BASE + SMP_CORE1_OFFSET + CLEAR0); 101 + ipi_clear0_regs[6] = (void *) 102 + (SMP_CORE_GROUP1_BASE + SMP_CORE2_OFFSET + CLEAR0); 103 + ipi_clear0_regs[7] = (void *) 104 + (SMP_CORE_GROUP1_BASE + SMP_CORE3_OFFSET + CLEAR0); 105 + ipi_clear0_regs[8] = (void *) 106 + (SMP_CORE_GROUP2_BASE + SMP_CORE0_OFFSET + CLEAR0); 107 + ipi_clear0_regs[9] = (void *) 108 + (SMP_CORE_GROUP2_BASE + SMP_CORE1_OFFSET + CLEAR0); 109 + ipi_clear0_regs[10] = (void *) 110 + (SMP_CORE_GROUP2_BASE + SMP_CORE2_OFFSET + CLEAR0); 111 + ipi_clear0_regs[11] = (void *) 112 + (SMP_CORE_GROUP2_BASE + SMP_CORE3_OFFSET + CLEAR0); 113 + ipi_clear0_regs[12] = (void *) 114 + (SMP_CORE_GROUP3_BASE + SMP_CORE0_OFFSET + CLEAR0); 115 + ipi_clear0_regs[13] = (void *) 116 + (SMP_CORE_GROUP3_BASE + SMP_CORE1_OFFSET + CLEAR0); 117 + ipi_clear0_regs[14] = (void *) 118 + (SMP_CORE_GROUP3_BASE + SMP_CORE2_OFFSET + CLEAR0); 119 + ipi_clear0_regs[15] = (void *) 120 + (SMP_CORE_GROUP3_BASE + SMP_CORE3_OFFSET + CLEAR0); 121 + } 94 122 95 - static void *ipi_status0_regs[] = { 96 - (void *)(SMP_CORE_GROUP0_BASE + SMP_CORE0_OFFSET + STATUS0), 97 - (void *)(SMP_CORE_GROUP0_BASE + SMP_CORE1_OFFSET + STATUS0), 98 - (void *)(SMP_CORE_GROUP0_BASE + SMP_CORE2_OFFSET + STATUS0), 99 - (void *)(SMP_CORE_GROUP0_BASE + SMP_CORE3_OFFSET + STATUS0), 100 - (void *)(SMP_CORE_GROUP1_BASE + SMP_CORE0_OFFSET + STATUS0), 101 - (void *)(SMP_CORE_GROUP1_BASE + SMP_CORE1_OFFSET + STATUS0), 102 - (void *)(SMP_CORE_GROUP1_BASE + SMP_CORE2_OFFSET + STATUS0), 103 - (void *)(SMP_CORE_GROUP1_BASE + SMP_CORE3_OFFSET + STATUS0), 104 - (void *)(SMP_CORE_GROUP2_BASE + SMP_CORE0_OFFSET + STATUS0), 105 - (void *)(SMP_CORE_GROUP2_BASE + SMP_CORE1_OFFSET + STATUS0), 106 - (void *)(SMP_CORE_GROUP2_BASE + SMP_CORE2_OFFSET + STATUS0), 107 - (void *)(SMP_CORE_GROUP2_BASE + SMP_CORE3_OFFSET + STATUS0), 108 - (void *)(SMP_CORE_GROUP3_BASE + SMP_CORE0_OFFSET + STATUS0), 109 - (void *)(SMP_CORE_GROUP3_BASE + SMP_CORE1_OFFSET + STATUS0), 110 - (void *)(SMP_CORE_GROUP3_BASE + SMP_CORE2_OFFSET + STATUS0), 111 - (void *)(SMP_CORE_GROUP3_BASE + SMP_CORE3_OFFSET + STATUS0), 112 - }; 123 + static void ipi_status0_regs_init(void) 124 + { 125 + ipi_status0_regs[0] = (void *) 126 + (SMP_CORE_GROUP0_BASE + SMP_CORE0_OFFSET + STATUS0); 127 + ipi_status0_regs[1] = (void *) 128 + (SMP_CORE_GROUP0_BASE + SMP_CORE1_OFFSET + STATUS0); 129 + ipi_status0_regs[2] = (void *) 130 + (SMP_CORE_GROUP0_BASE + SMP_CORE2_OFFSET + STATUS0); 131 + ipi_status0_regs[3] = (void *) 132 + (SMP_CORE_GROUP0_BASE + SMP_CORE3_OFFSET + STATUS0); 133 + ipi_status0_regs[4] = (void *) 134 + (SMP_CORE_GROUP1_BASE + SMP_CORE0_OFFSET + STATUS0); 135 + ipi_status0_regs[5] = (void *) 136 + (SMP_CORE_GROUP1_BASE + SMP_CORE1_OFFSET + STATUS0); 137 + ipi_status0_regs[6] = (void *) 138 + (SMP_CORE_GROUP1_BASE + SMP_CORE2_OFFSET + STATUS0); 139 + ipi_status0_regs[7] = (void *) 140 + (SMP_CORE_GROUP1_BASE + SMP_CORE3_OFFSET + STATUS0); 141 + ipi_status0_regs[8] = (void *) 142 + (SMP_CORE_GROUP2_BASE + SMP_CORE0_OFFSET + STATUS0); 143 + ipi_status0_regs[9] = (void *) 144 + (SMP_CORE_GROUP2_BASE + SMP_CORE1_OFFSET + STATUS0); 145 + ipi_status0_regs[10] = (void *) 146 + (SMP_CORE_GROUP2_BASE + SMP_CORE2_OFFSET + STATUS0); 147 + ipi_status0_regs[11] = (void *) 148 + (SMP_CORE_GROUP2_BASE + SMP_CORE3_OFFSET + STATUS0); 149 + ipi_status0_regs[12] = (void *) 150 + (SMP_CORE_GROUP3_BASE + SMP_CORE0_OFFSET + STATUS0); 151 + ipi_status0_regs[13] = (void *) 152 + (SMP_CORE_GROUP3_BASE + SMP_CORE1_OFFSET + STATUS0); 153 + ipi_status0_regs[14] = (void *) 154 + (SMP_CORE_GROUP3_BASE + SMP_CORE2_OFFSET + STATUS0); 155 + ipi_status0_regs[15] = (void *) 156 + (SMP_CORE_GROUP3_BASE + SMP_CORE3_OFFSET + STATUS0); 157 + } 113 158 114 - static void *ipi_en0_regs[] = { 115 - (void *)(SMP_CORE_GROUP0_BASE + SMP_CORE0_OFFSET + EN0), 116 - (void *)(SMP_CORE_GROUP0_BASE + SMP_CORE1_OFFSET + EN0), 117 - (void *)(SMP_CORE_GROUP0_BASE + SMP_CORE2_OFFSET + EN0), 118 - (void *)(SMP_CORE_GROUP0_BASE + SMP_CORE3_OFFSET + EN0), 119 - (void *)(SMP_CORE_GROUP1_BASE + SMP_CORE0_OFFSET + EN0), 120 - (void *)(SMP_CORE_GROUP1_BASE + SMP_CORE1_OFFSET + EN0), 121 - (void *)(SMP_CORE_GROUP1_BASE + SMP_CORE2_OFFSET + EN0), 122 - (void *)(SMP_CORE_GROUP1_BASE + SMP_CORE3_OFFSET + EN0), 123 - (void *)(SMP_CORE_GROUP2_BASE + SMP_CORE0_OFFSET + EN0), 124 - (void *)(SMP_CORE_GROUP2_BASE + SMP_CORE1_OFFSET + EN0), 125 - (void *)(SMP_CORE_GROUP2_BASE + SMP_CORE2_OFFSET + EN0), 126 - (void *)(SMP_CORE_GROUP2_BASE + SMP_CORE3_OFFSET + EN0), 127 - (void *)(SMP_CORE_GROUP3_BASE + SMP_CORE0_OFFSET + EN0), 128 - (void *)(SMP_CORE_GROUP3_BASE + SMP_CORE1_OFFSET + EN0), 129 - (void *)(SMP_CORE_GROUP3_BASE + SMP_CORE2_OFFSET + EN0), 130 - (void *)(SMP_CORE_GROUP3_BASE + SMP_CORE3_OFFSET + EN0), 131 - }; 159 + static void ipi_en0_regs_init(void) 160 + { 161 + ipi_en0_regs[0] = (void *) 162 + (SMP_CORE_GROUP0_BASE + SMP_CORE0_OFFSET + EN0); 163 + ipi_en0_regs[1] = (void *) 164 + (SMP_CORE_GROUP0_BASE + SMP_CORE1_OFFSET + EN0); 165 + ipi_en0_regs[2] = (void *) 166 + (SMP_CORE_GROUP0_BASE + SMP_CORE2_OFFSET + EN0); 167 + ipi_en0_regs[3] = (void *) 168 + (SMP_CORE_GROUP0_BASE + SMP_CORE3_OFFSET + EN0); 169 + ipi_en0_regs[4] = (void *) 170 + (SMP_CORE_GROUP1_BASE + SMP_CORE0_OFFSET + EN0); 171 + ipi_en0_regs[5] = (void *) 172 + (SMP_CORE_GROUP1_BASE + SMP_CORE1_OFFSET + EN0); 173 + ipi_en0_regs[6] = (void *) 174 + (SMP_CORE_GROUP1_BASE + SMP_CORE2_OFFSET + EN0); 175 + ipi_en0_regs[7] = (void *) 176 + (SMP_CORE_GROUP1_BASE + SMP_CORE3_OFFSET + EN0); 177 + ipi_en0_regs[8] = (void *) 178 + (SMP_CORE_GROUP2_BASE + SMP_CORE0_OFFSET + EN0); 179 + ipi_en0_regs[9] = (void *) 180 + (SMP_CORE_GROUP2_BASE + SMP_CORE1_OFFSET + EN0); 181 + ipi_en0_regs[10] = (void *) 182 + (SMP_CORE_GROUP2_BASE + SMP_CORE2_OFFSET + EN0); 183 + ipi_en0_regs[11] = (void *) 184 + (SMP_CORE_GROUP2_BASE + SMP_CORE3_OFFSET + EN0); 185 + ipi_en0_regs[12] = (void *) 186 + (SMP_CORE_GROUP3_BASE + SMP_CORE0_OFFSET + EN0); 187 + ipi_en0_regs[13] = (void *) 188 + (SMP_CORE_GROUP3_BASE + SMP_CORE1_OFFSET + EN0); 189 + ipi_en0_regs[14] = (void *) 190 + (SMP_CORE_GROUP3_BASE + SMP_CORE2_OFFSET + EN0); 191 + ipi_en0_regs[15] = (void *) 192 + (SMP_CORE_GROUP3_BASE + SMP_CORE3_OFFSET + EN0); 193 + } 132 194 133 - static void *ipi_mailbox_buf[] = { 134 - (void *)(SMP_CORE_GROUP0_BASE + SMP_CORE0_OFFSET + BUF), 135 - (void *)(SMP_CORE_GROUP0_BASE + SMP_CORE1_OFFSET + BUF), 136 - (void *)(SMP_CORE_GROUP0_BASE + SMP_CORE2_OFFSET + BUF), 137 - (void *)(SMP_CORE_GROUP0_BASE + SMP_CORE3_OFFSET + BUF), 138 - (void *)(SMP_CORE_GROUP1_BASE + SMP_CORE0_OFFSET + BUF), 139 - (void *)(SMP_CORE_GROUP1_BASE + SMP_CORE1_OFFSET + BUF), 140 - (void *)(SMP_CORE_GROUP1_BASE + SMP_CORE2_OFFSET + BUF), 141 - (void *)(SMP_CORE_GROUP1_BASE + SMP_CORE3_OFFSET + BUF), 142 - (void *)(SMP_CORE_GROUP2_BASE + SMP_CORE0_OFFSET + BUF), 143 - (void *)(SMP_CORE_GROUP2_BASE + SMP_CORE1_OFFSET + BUF), 144 - (void *)(SMP_CORE_GROUP2_BASE + SMP_CORE2_OFFSET + BUF), 145 - (void *)(SMP_CORE_GROUP2_BASE + SMP_CORE3_OFFSET + BUF), 146 - (void *)(SMP_CORE_GROUP3_BASE + SMP_CORE0_OFFSET + BUF), 147 - (void *)(SMP_CORE_GROUP3_BASE + SMP_CORE1_OFFSET + BUF), 148 - (void *)(SMP_CORE_GROUP3_BASE + SMP_CORE2_OFFSET + BUF), 149 - (void *)(SMP_CORE_GROUP3_BASE + SMP_CORE3_OFFSET + BUF), 150 - }; 195 + static void ipi_mailbox_buf_init(void) 196 + { 197 + ipi_mailbox_buf[0] = (void *) 198 + (SMP_CORE_GROUP0_BASE + SMP_CORE0_OFFSET + BUF); 199 + ipi_mailbox_buf[1] = (void *) 200 + (SMP_CORE_GROUP0_BASE + SMP_CORE1_OFFSET + BUF); 201 + ipi_mailbox_buf[2] = (void *) 202 + (SMP_CORE_GROUP0_BASE + SMP_CORE2_OFFSET + BUF); 203 + ipi_mailbox_buf[3] = (void *) 204 + (SMP_CORE_GROUP0_BASE + SMP_CORE3_OFFSET + BUF); 205 + ipi_mailbox_buf[4] = (void *) 206 + (SMP_CORE_GROUP1_BASE + SMP_CORE0_OFFSET + BUF); 207 + ipi_mailbox_buf[5] = (void *) 208 + (SMP_CORE_GROUP1_BASE + SMP_CORE1_OFFSET + BUF); 209 + ipi_mailbox_buf[6] = (void *) 210 + (SMP_CORE_GROUP1_BASE + SMP_CORE2_OFFSET + BUF); 211 + ipi_mailbox_buf[7] = (void *) 212 + (SMP_CORE_GROUP1_BASE + SMP_CORE3_OFFSET + BUF); 213 + ipi_mailbox_buf[8] = (void *) 214 + (SMP_CORE_GROUP2_BASE + SMP_CORE0_OFFSET + BUF); 215 + ipi_mailbox_buf[9] = (void *) 216 + (SMP_CORE_GROUP2_BASE + SMP_CORE1_OFFSET + BUF); 217 + ipi_mailbox_buf[10] = (void *) 218 + (SMP_CORE_GROUP2_BASE + SMP_CORE2_OFFSET + BUF); 219 + ipi_mailbox_buf[11] = (void *) 220 + (SMP_CORE_GROUP2_BASE + SMP_CORE3_OFFSET + BUF); 221 + ipi_mailbox_buf[12] = (void *) 222 + (SMP_CORE_GROUP3_BASE + SMP_CORE0_OFFSET + BUF); 223 + ipi_mailbox_buf[13] = (void *) 224 + (SMP_CORE_GROUP3_BASE + SMP_CORE1_OFFSET + BUF); 225 + ipi_mailbox_buf[14] = (void *) 226 + (SMP_CORE_GROUP3_BASE + SMP_CORE2_OFFSET + BUF); 227 + ipi_mailbox_buf[15] = (void *) 228 + (SMP_CORE_GROUP3_BASE + SMP_CORE3_OFFSET + BUF); 229 + } 151 230 152 231 /* 153 232 * Simple enough, just poke the appropriate ipi register ··· 294 203 for (i = 0; i < loongson_sysconf.nr_cpus; i++) 295 204 loongson3_ipi_write32(0xffffffff, ipi_en0_regs[i]); 296 205 206 + cpu_data[cpu].package = cpu / loongson_sysconf.cores_per_package; 207 + cpu_data[cpu].core = cpu % loongson_sysconf.cores_per_package; 297 208 per_cpu(cpu_state, cpu) = CPU_ONLINE; 298 209 299 210 i = 0; ··· 339 246 __cpu_number_map[i] = ++num; 340 247 __cpu_logical_map[num] = i; 341 248 } 249 + ipi_set0_regs_init(); 250 + ipi_clear0_regs_init(); 251 + ipi_status0_regs_init(); 252 + ipi_en0_regs_init(); 253 + ipi_mailbox_buf_init(); 342 254 pr_info("Detected %i available secondary CPU(s)\n", num); 343 255 } 344 256 ··· 411 313 * flush all L1 entries at first. Then, another core (usually Core 0) can 412 314 * safely disable the clock of the target core. loongson3_play_dead() is 413 315 * called via CKSEG1 (uncached and unmmaped) */ 414 - static void loongson3_play_dead(int *state_addr) 316 + static void loongson3a_play_dead(int *state_addr) 415 317 { 416 318 register int val; 417 319 register long cpuid, core, node, count; ··· 473 375 : "a1"); 474 376 } 475 377 378 + static void loongson3b_play_dead(int *state_addr) 379 + { 380 + register int val; 381 + register long cpuid, core, node, count; 382 + register void *addr, *base, *initfunc; 383 + 384 + __asm__ __volatile__( 385 + " .set push \n" 386 + " .set noreorder \n" 387 + " li %[addr], 0x80000000 \n" /* KSEG0 */ 388 + "1: cache 0, 0(%[addr]) \n" /* flush L1 ICache */ 389 + " cache 0, 1(%[addr]) \n" 390 + " cache 0, 2(%[addr]) \n" 391 + " cache 0, 3(%[addr]) \n" 392 + " cache 1, 0(%[addr]) \n" /* flush L1 DCache */ 393 + " cache 1, 1(%[addr]) \n" 394 + " cache 1, 2(%[addr]) \n" 395 + " cache 1, 3(%[addr]) \n" 396 + " addiu %[sets], %[sets], -1 \n" 397 + " bnez %[sets], 1b \n" 398 + " addiu %[addr], %[addr], 0x20 \n" 399 + " li %[val], 0x7 \n" /* *state_addr = CPU_DEAD; */ 400 + " sw %[val], (%[state_addr]) \n" 401 + " sync \n" 402 + " cache 21, (%[state_addr]) \n" /* flush entry of *state_addr */ 403 + " .set pop \n" 404 + : [addr] "=&r" (addr), [val] "=&r" (val) 405 + : [state_addr] "r" (state_addr), 406 + [sets] "r" (cpu_data[smp_processor_id()].dcache.sets)); 407 + 408 + __asm__ __volatile__( 409 + " .set push \n" 410 + " .set noreorder \n" 411 + " .set mips64 \n" 412 + " mfc0 %[cpuid], $15, 1 \n" 413 + " andi %[cpuid], 0x3ff \n" 414 + " dli %[base], 0x900000003ff01000 \n" 415 + " andi %[core], %[cpuid], 0x3 \n" 416 + " sll %[core], 8 \n" /* get core id */ 417 + " or %[base], %[base], %[core] \n" 418 + " andi %[node], %[cpuid], 0xc \n" 419 + " dsll %[node], 42 \n" /* get node id */ 420 + " or %[base], %[base], %[node] \n" 421 + " dsrl %[node], 30 \n" /* 15:14 */ 422 + " or %[base], %[base], %[node] \n" 423 + "1: li %[count], 0x100 \n" /* wait for init loop */ 424 + "2: bnez %[count], 2b \n" /* limit mailbox access */ 425 + " addiu %[count], -1 \n" 426 + " ld %[initfunc], 0x20(%[base]) \n" /* get PC via mailbox */ 427 + " beqz %[initfunc], 1b \n" 428 + " nop \n" 429 + " ld $sp, 0x28(%[base]) \n" /* get SP via mailbox */ 430 + " ld $gp, 0x30(%[base]) \n" /* get GP via mailbox */ 431 + " ld $a1, 0x38(%[base]) \n" 432 + " jr %[initfunc] \n" /* jump to initial PC */ 433 + " nop \n" 434 + " .set pop \n" 435 + : [core] "=&r" (core), [node] "=&r" (node), 436 + [base] "=&r" (base), [cpuid] "=&r" (cpuid), 437 + [count] "=&r" (count), [initfunc] "=&r" (initfunc) 438 + : /* No Input */ 439 + : "a1"); 440 + } 441 + 476 442 void play_dead(void) 477 443 { 478 444 int *state_addr; ··· 544 382 void (*play_dead_at_ckseg1)(int *); 545 383 546 384 idle_task_exit(); 547 - play_dead_at_ckseg1 = 548 - (void *)CKSEG1ADDR((unsigned long)loongson3_play_dead); 385 + switch (loongson_sysconf.cputype) { 386 + case Loongson_3A: 387 + default: 388 + play_dead_at_ckseg1 = 389 + (void *)CKSEG1ADDR((unsigned long)loongson3a_play_dead); 390 + break; 391 + case Loongson_3B: 392 + play_dead_at_ckseg1 = 393 + (void *)CKSEG1ADDR((unsigned long)loongson3b_play_dead); 394 + break; 395 + } 549 396 state_addr = &per_cpu(cpu_state, cpu); 550 397 mb(); 551 398 play_dead_at_ckseg1(state_addr); 399 + } 400 + 401 + void loongson3_disable_clock(int cpu) 402 + { 403 + uint64_t core_id = cpu_data[cpu].core; 404 + uint64_t package_id = cpu_data[cpu].package; 405 + 406 + if (loongson_sysconf.cputype == Loongson_3A) { 407 + LOONGSON_CHIPCFG(package_id) &= ~(1 << (12 + core_id)); 408 + } else if (loongson_sysconf.cputype == Loongson_3B) { 409 + if (!cpuhotplug_workaround) 410 + LOONGSON_FREQCTRL(package_id) &= ~(1 << (core_id * 4 + 3)); 411 + } 412 + } 413 + 414 + void loongson3_enable_clock(int cpu) 415 + { 416 + uint64_t core_id = cpu_data[cpu].core; 417 + uint64_t package_id = cpu_data[cpu].package; 418 + 419 + if (loongson_sysconf.cputype == Loongson_3A) { 420 + LOONGSON_CHIPCFG(package_id) |= 1 << (12 + core_id); 421 + } else if (loongson_sysconf.cputype == Loongson_3B) { 422 + if (!cpuhotplug_workaround) 423 + LOONGSON_FREQCTRL(package_id) |= 1 << (core_id * 4 + 3); 424 + } 552 425 } 553 426 554 427 #define CPU_POST_DEAD_FROZEN (CPU_POST_DEAD | CPU_TASKS_FROZEN) ··· 596 399 case CPU_POST_DEAD: 597 400 case CPU_POST_DEAD_FROZEN: 598 401 pr_info("Disable clock for CPU#%d\n", cpu); 599 - LOONGSON_CHIPCFG0 &= ~(1 << (12 + cpu)); 402 + loongson3_disable_clock(cpu); 600 403 break; 601 404 case CPU_UP_PREPARE: 602 405 case CPU_UP_PREPARE_FROZEN: 603 406 pr_info("Enable clock for CPU#%d\n", cpu); 604 - LOONGSON_CHIPCFG0 |= 1 << (12 + cpu); 407 + loongson3_enable_clock(cpu); 605 408 break; 606 409 } 607 410
+19 -18
arch/mips/loongson/loongson-3/smp.h
··· 1 1 #ifndef __LOONGSON_SMP_H_ 2 2 #define __LOONGSON_SMP_H_ 3 3 4 - /* for Loongson-3A smp support */ 4 + /* for Loongson-3 smp support */ 5 + extern unsigned long long smp_group[4]; 5 6 6 7 /* 4 groups(nodes) in maximum in numa case */ 7 - #define SMP_CORE_GROUP0_BASE 0x900000003ff01000 8 - #define SMP_CORE_GROUP1_BASE 0x900010003ff01000 9 - #define SMP_CORE_GROUP2_BASE 0x900020003ff01000 10 - #define SMP_CORE_GROUP3_BASE 0x900030003ff01000 8 + #define SMP_CORE_GROUP0_BASE (smp_group[0]) 9 + #define SMP_CORE_GROUP1_BASE (smp_group[1]) 10 + #define SMP_CORE_GROUP2_BASE (smp_group[2]) 11 + #define SMP_CORE_GROUP3_BASE (smp_group[3]) 11 12 12 13 /* 4 cores in each group(node) */ 13 - #define SMP_CORE0_OFFSET 0x000 14 - #define SMP_CORE1_OFFSET 0x100 15 - #define SMP_CORE2_OFFSET 0x200 16 - #define SMP_CORE3_OFFSET 0x300 14 + #define SMP_CORE0_OFFSET 0x000 15 + #define SMP_CORE1_OFFSET 0x100 16 + #define SMP_CORE2_OFFSET 0x200 17 + #define SMP_CORE3_OFFSET 0x300 17 18 18 19 /* ipi registers offsets */ 19 - #define STATUS0 0x00 20 - #define EN0 0x04 21 - #define SET0 0x08 22 - #define CLEAR0 0x0c 23 - #define STATUS1 0x10 24 - #define MASK1 0x14 25 - #define SET1 0x18 26 - #define CLEAR1 0x1c 27 - #define BUF 0x20 20 + #define STATUS0 0x00 21 + #define EN0 0x04 22 + #define SET0 0x08 23 + #define CLEAR0 0x0c 24 + #define STATUS1 0x10 25 + #define MASK1 0x14 26 + #define SET1 0x18 27 + #define CLEAR1 0x1c 28 + #define BUF 0x20 28 29 29 30 #endif
+1 -1
arch/mips/math-emu/cp1emu.c
··· 1827 1827 case -1: 1828 1828 1829 1829 if (cpu_has_mips_4_5_r) 1830 - cbit = fpucondbit[MIPSInst_RT(ir) >> 2]; 1830 + cbit = fpucondbit[MIPSInst_FD(ir) >> 2]; 1831 1831 else 1832 1832 cbit = FPU_CSR_COND; 1833 1833 if (rv.w)
+4 -4
arch/mips/mm/c-r4k.c
··· 1230 1230 case CPU_R14000: 1231 1231 break; 1232 1232 1233 + case CPU_74K: 1234 + case CPU_1074K: 1235 + alias_74k_erratum(c); 1236 + /* Fall through. */ 1233 1237 case CPU_M14KC: 1234 1238 case CPU_M14KEC: 1235 1239 case CPU_24K: 1236 1240 case CPU_34K: 1237 - case CPU_74K: 1238 1241 case CPU_1004K: 1239 - case CPU_1074K: 1240 1242 case CPU_INTERAPTIV: 1241 1243 case CPU_P5600: 1242 1244 case CPU_PROAPTIV: 1243 1245 case CPU_M5150: 1244 - if ((c->cputype == CPU_74K) || (c->cputype == CPU_1074K)) 1245 - alias_74k_erratum(c); 1246 1246 if (!(read_c0_config7() & MIPS_CONF7_IAR) && 1247 1247 (c->icache.waysize > PAGE_SIZE)) 1248 1248 c->icache.flags |= MIPS_CACHE_ALIASES;
+33
arch/mips/mm/init.c
··· 325 325 #endif 326 326 } 327 327 328 + unsigned __weak platform_maar_init(unsigned num_maars) 329 + { 330 + return 0; 331 + } 332 + 333 + static void maar_init(void) 334 + { 335 + unsigned num_maars, used, i; 336 + 337 + if (!cpu_has_maar) 338 + return; 339 + 340 + /* Detect the number of MAARs */ 341 + write_c0_maari(~0); 342 + back_to_back_c0_hazard(); 343 + num_maars = read_c0_maari() + 1; 344 + 345 + /* MAARs should be in pairs */ 346 + WARN_ON(num_maars % 2); 347 + 348 + /* Configure the required MAARs */ 349 + used = platform_maar_init(num_maars / 2); 350 + 351 + /* Disable any further MAARs */ 352 + for (i = (used * 2); i < num_maars; i++) { 353 + write_c0_maari(i); 354 + back_to_back_c0_hazard(); 355 + write_c0_maar(0); 356 + back_to_back_c0_hazard(); 357 + } 358 + } 359 + 328 360 void __init mem_init(void) 329 361 { 330 362 #ifdef CONFIG_HIGHMEM ··· 369 337 #endif 370 338 high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT); 371 339 340 + maar_init(); 372 341 free_all_bootmem(); 373 342 setup_zero_pages(); /* Setup zeroed pages. */ 374 343 mem_init_free_highmem();
+1 -1
arch/mips/mm/tlb-r3k.c
··· 158 158 { 159 159 int cpu = smp_processor_id(); 160 160 161 - if (!vma || cpu_context(cpu, vma->vm_mm) != 0) { 161 + if (cpu_context(cpu, vma->vm_mm) != 0) { 162 162 unsigned long flags; 163 163 int oldpid, newpid, idx; 164 164
+59
arch/mips/mm/tlb-r4k.c
··· 57 57 local_irq_save(flags); 58 58 /* Save old context and create impossible VPN2 value */ 59 59 old_ctx = read_c0_entryhi(); 60 + htw_stop(); 60 61 write_c0_entrylo0(0); 61 62 write_c0_entrylo1(0); 62 63 ··· 91 90 } 92 91 tlbw_use_hazard(); 93 92 write_c0_entryhi(old_ctx); 93 + htw_start(); 94 94 flush_itlb(); 95 95 local_irq_restore(flags); 96 96 } ··· 133 131 int oldpid = read_c0_entryhi(); 134 132 int newpid = cpu_asid(cpu, mm); 135 133 134 + htw_stop(); 136 135 while (start < end) { 137 136 int idx; 138 137 ··· 154 151 } 155 152 tlbw_use_hazard(); 156 153 write_c0_entryhi(oldpid); 154 + htw_start(); 157 155 } else { 158 156 drop_mmu_context(mm, cpu); 159 157 } ··· 178 174 start &= (PAGE_MASK << 1); 179 175 end += ((PAGE_SIZE << 1) - 1); 180 176 end &= (PAGE_MASK << 1); 177 + htw_stop(); 181 178 182 179 while (start < end) { 183 180 int idx; ··· 200 195 } 201 196 tlbw_use_hazard(); 202 197 write_c0_entryhi(pid); 198 + htw_start(); 203 199 } else { 204 200 local_flush_tlb_all(); 205 201 } ··· 220 214 page &= (PAGE_MASK << 1); 221 215 local_irq_save(flags); 222 216 oldpid = read_c0_entryhi(); 217 + htw_stop(); 223 218 write_c0_entryhi(page | newpid); 224 219 mtc0_tlbw_hazard(); 225 220 tlb_probe(); ··· 238 231 239 232 finish: 240 233 write_c0_entryhi(oldpid); 234 + htw_start(); 241 235 flush_itlb_vm(vma); 242 236 local_irq_restore(flags); 243 237 } ··· 255 247 256 248 local_irq_save(flags); 257 249 oldpid = read_c0_entryhi(); 250 + htw_stop(); 258 251 page &= (PAGE_MASK << 1); 259 252 write_c0_entryhi(page); 260 253 mtc0_tlbw_hazard(); ··· 272 263 tlbw_use_hazard(); 273 264 } 274 265 write_c0_entryhi(oldpid); 266 + htw_start(); 275 267 flush_itlb(); 276 268 local_irq_restore(flags); 277 269 } ··· 361 351 local_irq_save(flags); 362 352 /* Save old context and create impossible VPN2 value */ 363 353 old_ctx = read_c0_entryhi(); 354 + htw_stop(); 364 355 old_pagemask = read_c0_pagemask(); 365 356 wired = read_c0_wired(); 366 357 write_c0_wired(wired + 1); ··· 377 366 378 367 write_c0_entryhi(old_ctx); 379 368 tlbw_use_hazard(); /* What is the hazard here? */ 369 + htw_start(); 380 370 write_c0_pagemask(old_pagemask); 381 371 local_flush_tlb_all(); 382 372 local_irq_restore(flags); ··· 402 390 } 403 391 404 392 #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ 393 + 394 + /* 395 + * Used for loading TLB entries before trap_init() has started, when we 396 + * don't actually want to add a wired entry which remains throughout the 397 + * lifetime of the system 398 + */ 399 + 400 + int temp_tlb_entry __cpuinitdata; 401 + 402 + __init int add_temporary_entry(unsigned long entrylo0, unsigned long entrylo1, 403 + unsigned long entryhi, unsigned long pagemask) 404 + { 405 + int ret = 0; 406 + unsigned long flags; 407 + unsigned long wired; 408 + unsigned long old_pagemask; 409 + unsigned long old_ctx; 410 + 411 + local_irq_save(flags); 412 + /* Save old context and create impossible VPN2 value */ 413 + old_ctx = read_c0_entryhi(); 414 + old_pagemask = read_c0_pagemask(); 415 + wired = read_c0_wired(); 416 + if (--temp_tlb_entry < wired) { 417 + printk(KERN_WARNING 418 + "No TLB space left for add_temporary_entry\n"); 419 + ret = -ENOSPC; 420 + goto out; 421 + } 422 + 423 + write_c0_index(temp_tlb_entry); 424 + write_c0_pagemask(pagemask); 425 + write_c0_entryhi(entryhi); 426 + write_c0_entrylo0(entrylo0); 427 + write_c0_entrylo1(entrylo1); 428 + mtc0_tlbw_hazard(); 429 + tlb_write_indexed(); 430 + tlbw_use_hazard(); 431 + 432 + write_c0_entryhi(old_ctx); 433 + write_c0_pagemask(old_pagemask); 434 + out: 435 + local_irq_restore(flags); 436 + return ret; 437 + } 405 438 406 439 static int ntlb; 407 440 static int __init set_ntlb(char *str) ··· 487 430 #endif 488 431 write_c0_pagegrain(pg); 489 432 } 433 + 434 + temp_tlb_entry = current_cpu_data.tlbsize - 1; 490 435 491 436 /* From this point on the ARC firmware is dead. */ 492 437 local_flush_tlb_all();
+96 -2
arch/mips/mm/tlbex.c
··· 429 429 (unsigned int)(p - tlb_handler)); 430 430 431 431 memcpy((void *)ebase, tlb_handler, 0x80); 432 + local_flush_icache_range(ebase, ebase + 0x80); 432 433 433 434 dump_handler("r3000_tlb_refill", (u32 *)ebase, 32); 434 435 } ··· 1300 1299 } 1301 1300 #ifdef CONFIG_MIPS_HUGE_TLB_SUPPORT 1302 1301 uasm_l_tlb_huge_update(&l, p); 1302 + UASM_i_LW(&p, K0, 0, K1); 1303 1303 build_huge_update_entries(&p, htlb_info.huge_pte, K1); 1304 1304 build_huge_tlb_write_entry(&p, &l, &r, K0, tlb_random, 1305 1305 htlb_info.restore_scratch); ··· 1417 1415 final_len); 1418 1416 1419 1417 memcpy((void *)ebase, final_handler, 0x100); 1418 + local_flush_icache_range(ebase, ebase + 0x100); 1420 1419 1421 1420 dump_handler("r4000_tlb_refill", (u32 *)ebase, 64); 1422 1421 } ··· 1922 1919 if (m4kc_tlbp_war()) 1923 1920 build_tlb_probe_entry(&p); 1924 1921 1925 - if (cpu_has_rixi) { 1922 + if (cpu_has_rixi && !cpu_has_rixiex) { 1926 1923 /* 1927 1924 * If the page is not _PAGE_VALID, RI or XI could not 1928 1925 * have triggered it. Skip the expensive test.. ··· 1989 1986 build_pte_present(&p, &r, wr.r1, wr.r2, wr.r3, label_nopage_tlbl); 1990 1987 build_tlb_probe_entry(&p); 1991 1988 1992 - if (cpu_has_rixi) { 1989 + if (cpu_has_rixi && !cpu_has_rixiex) { 1993 1990 /* 1994 1991 * If the page is not _PAGE_VALID, RI or XI could not 1995 1992 * have triggered it. Skip the expensive test.. ··· 2197 2194 (unsigned long)tlbmiss_handler_setup_pgd_end); 2198 2195 } 2199 2196 2197 + static void print_htw_config(void) 2198 + { 2199 + unsigned long config; 2200 + unsigned int pwctl; 2201 + const int field = 2 * sizeof(unsigned long); 2202 + 2203 + config = read_c0_pwfield(); 2204 + pr_debug("PWField (0x%0*lx): GDI: 0x%02lx UDI: 0x%02lx MDI: 0x%02lx PTI: 0x%02lx PTEI: 0x%02lx\n", 2205 + field, config, 2206 + (config & MIPS_PWFIELD_GDI_MASK) >> MIPS_PWFIELD_GDI_SHIFT, 2207 + (config & MIPS_PWFIELD_UDI_MASK) >> MIPS_PWFIELD_UDI_SHIFT, 2208 + (config & MIPS_PWFIELD_MDI_MASK) >> MIPS_PWFIELD_MDI_SHIFT, 2209 + (config & MIPS_PWFIELD_PTI_MASK) >> MIPS_PWFIELD_PTI_SHIFT, 2210 + (config & MIPS_PWFIELD_PTEI_MASK) >> MIPS_PWFIELD_PTEI_SHIFT); 2211 + 2212 + config = read_c0_pwsize(); 2213 + pr_debug("PWSize (0x%0*lx): GDW: 0x%02lx UDW: 0x%02lx MDW: 0x%02lx PTW: 0x%02lx PTEW: 0x%02lx\n", 2214 + field, config, 2215 + (config & MIPS_PWSIZE_GDW_MASK) >> MIPS_PWSIZE_GDW_SHIFT, 2216 + (config & MIPS_PWSIZE_UDW_MASK) >> MIPS_PWSIZE_UDW_SHIFT, 2217 + (config & MIPS_PWSIZE_MDW_MASK) >> MIPS_PWSIZE_MDW_SHIFT, 2218 + (config & MIPS_PWSIZE_PTW_MASK) >> MIPS_PWSIZE_PTW_SHIFT, 2219 + (config & MIPS_PWSIZE_PTEW_MASK) >> MIPS_PWSIZE_PTEW_SHIFT); 2220 + 2221 + pwctl = read_c0_pwctl(); 2222 + pr_debug("PWCtl (0x%x): PWEn: 0x%x DPH: 0x%x HugePg: 0x%x Psn: 0x%x\n", 2223 + pwctl, 2224 + (pwctl & MIPS_PWCTL_PWEN_MASK) >> MIPS_PWCTL_PWEN_SHIFT, 2225 + (pwctl & MIPS_PWCTL_DPH_MASK) >> MIPS_PWCTL_DPH_SHIFT, 2226 + (pwctl & MIPS_PWCTL_HUGEPG_MASK) >> MIPS_PWCTL_HUGEPG_SHIFT, 2227 + (pwctl & MIPS_PWCTL_PSN_MASK) >> MIPS_PWCTL_PSN_SHIFT); 2228 + } 2229 + 2230 + static void config_htw_params(void) 2231 + { 2232 + unsigned long pwfield, pwsize, ptei; 2233 + unsigned int config; 2234 + 2235 + /* 2236 + * We are using 2-level page tables, so we only need to 2237 + * setup GDW and PTW appropriately. UDW and MDW will remain 0. 2238 + * The default value of GDI/UDI/MDI/PTI is 0xc. It is illegal to 2239 + * write values less than 0xc in these fields because the entire 2240 + * write will be dropped. As a result of which, we must preserve 2241 + * the original reset values and overwrite only what we really want. 2242 + */ 2243 + 2244 + pwfield = read_c0_pwfield(); 2245 + /* re-initialize the GDI field */ 2246 + pwfield &= ~MIPS_PWFIELD_GDI_MASK; 2247 + pwfield |= PGDIR_SHIFT << MIPS_PWFIELD_GDI_SHIFT; 2248 + /* re-initialize the PTI field including the even/odd bit */ 2249 + pwfield &= ~MIPS_PWFIELD_PTI_MASK; 2250 + pwfield |= PAGE_SHIFT << MIPS_PWFIELD_PTI_SHIFT; 2251 + /* Set the PTEI right shift */ 2252 + ptei = _PAGE_GLOBAL_SHIFT << MIPS_PWFIELD_PTEI_SHIFT; 2253 + pwfield |= ptei; 2254 + write_c0_pwfield(pwfield); 2255 + /* Check whether the PTEI value is supported */ 2256 + back_to_back_c0_hazard(); 2257 + pwfield = read_c0_pwfield(); 2258 + if (((pwfield & MIPS_PWFIELD_PTEI_MASK) << MIPS_PWFIELD_PTEI_SHIFT) 2259 + != ptei) { 2260 + pr_warn("Unsupported PTEI field value: 0x%lx. HTW will not be enabled", 2261 + ptei); 2262 + /* 2263 + * Drop option to avoid HTW being enabled via another path 2264 + * (eg htw_reset()) 2265 + */ 2266 + current_cpu_data.options &= ~MIPS_CPU_HTW; 2267 + return; 2268 + } 2269 + 2270 + pwsize = ilog2(PTRS_PER_PGD) << MIPS_PWSIZE_GDW_SHIFT; 2271 + pwsize |= ilog2(PTRS_PER_PTE) << MIPS_PWSIZE_PTW_SHIFT; 2272 + write_c0_pwsize(pwsize); 2273 + 2274 + /* Make sure everything is set before we enable the HTW */ 2275 + back_to_back_c0_hazard(); 2276 + 2277 + /* Enable HTW and disable the rest of the pwctl fields */ 2278 + config = 1 << MIPS_PWCTL_PWEN_SHIFT; 2279 + write_c0_pwctl(config); 2280 + pr_info("Hardware Page Table Walker enabled\n"); 2281 + 2282 + print_htw_config(); 2283 + } 2284 + 2200 2285 void build_tlb_refill_handler(void) 2201 2286 { 2202 2287 /* ··· 2349 2258 } 2350 2259 if (cpu_has_local_ebase) 2351 2260 build_r4000_tlb_refill_handler(); 2261 + if (cpu_has_htw) 2262 + config_htw_params(); 2263 + 2352 2264 } 2353 2265 }
+19 -8
arch/mips/mti-malta/malta-int.c
··· 42 42 43 43 static DEFINE_RAW_SPINLOCK(mips_irq_lock); 44 44 45 + #ifdef CONFIG_MIPS_GIC_IPI 46 + DECLARE_BITMAP(ipi_ints, GIC_NUM_INTRS); 47 + #endif 48 + 45 49 static inline int mips_pcibios_iack(void) 46 50 { 47 51 int irq; ··· 129 125 130 126 static void malta_ipi_irqdispatch(void) 131 127 { 132 - int irq; 128 + #ifdef CONFIG_MIPS_GIC_IPI 129 + unsigned long irq; 130 + DECLARE_BITMAP(pending, GIC_NUM_INTRS); 133 131 132 + gic_get_int_mask(pending, ipi_ints); 133 + 134 + irq = find_first_bit(pending, GIC_NUM_INTRS); 135 + 136 + while (irq < GIC_NUM_INTRS) { 137 + do_IRQ(MIPS_GIC_IRQ_BASE + irq); 138 + 139 + irq = find_next_bit(pending, GIC_NUM_INTRS, irq + 1); 140 + } 141 + #endif 134 142 if (gic_compare_int()) 135 143 do_IRQ(MIPS_GIC_IRQ_BASE); 136 - 137 - irq = gic_get_int(); 138 - if (irq < 0) 139 - return; /* interrupt has already been cleared */ 140 - 141 - do_IRQ(MIPS_GIC_IRQ_BASE + irq); 142 144 } 143 145 144 146 static void corehi_irqdispatch(void) ··· 437 427 gic_intr_map[intr].pin = cpupin; 438 428 gic_intr_map[intr].polarity = GIC_POL_POS; 439 429 gic_intr_map[intr].trigtype = GIC_TRIG_EDGE; 440 - gic_intr_map[intr].flags = GIC_FLAG_IPI; 430 + gic_intr_map[intr].flags = 0; 441 431 ipi_map[cpu] |= (1 << (cpupin + 2)); 432 + bitmap_set(ipi_ints, intr, 1); 442 433 } 443 434 444 435 static void __init fill_ipi_map(void)
+26
arch/mips/mti-malta/malta-memory.c
··· 16 16 #include <linux/string.h> 17 17 18 18 #include <asm/bootinfo.h> 19 + #include <asm/maar.h> 19 20 #include <asm/sections.h> 20 21 #include <asm/fw/fw.h> 21 22 ··· 164 163 free_init_pages("YAMON memory", 165 164 addr, addr + boot_mem_map.map[i].size); 166 165 } 166 + } 167 + 168 + unsigned platform_maar_init(unsigned num_pairs) 169 + { 170 + phys_addr_t mem_end = (physical_memsize & ~0xffffull) - 1; 171 + struct maar_config cfg[] = { 172 + /* DRAM preceding I/O */ 173 + { 0x00000000, 0x0fffffff, MIPS_MAAR_S }, 174 + 175 + /* DRAM following I/O */ 176 + { 0x20000000, mem_end, MIPS_MAAR_S }, 177 + 178 + /* DRAM alias in upper half of physical */ 179 + { 0x80000000, 0x80000000 + mem_end, MIPS_MAAR_S }, 180 + }; 181 + unsigned i, num_cfg = ARRAY_SIZE(cfg); 182 + 183 + /* If DRAM fits before I/O, drop the region following it */ 184 + if (physical_memsize <= 0x10000000) { 185 + num_cfg--; 186 + for (i = 1; i < num_cfg; i++) 187 + cfg[i] = cfg[i + 1]; 188 + } 189 + 190 + return maar_config(cfg, num_cfg, num_pairs); 167 191 }
+1 -1
arch/mips/pci/Makefile
··· 29 29 obj-$(CONFIG_MIPS_COBALT) += fixup-cobalt.o 30 30 obj-$(CONFIG_LEMOTE_FULOONG2E) += fixup-fuloong2e.o ops-loongson2.o 31 31 obj-$(CONFIG_LEMOTE_MACH2F) += fixup-lemote2f.o ops-loongson2.o 32 - obj-$(CONFIG_LEMOTE_MACH3A) += fixup-loongson3.o ops-loongson3.o 32 + obj-$(CONFIG_LOONGSON_MACH3X) += fixup-loongson3.o ops-loongson3.o 33 33 obj-$(CONFIG_MIPS_MALTA) += fixup-malta.o pci-malta.o 34 34 obj-$(CONFIG_PMC_MSP7120_GW) += fixup-pmcmsp.o ops-pmcmsp.o 35 35 obj-$(CONFIG_PMC_MSP7120_EVAL) += fixup-pmcmsp.o ops-pmcmsp.o
-2
arch/mips/pci/ops-tx4927.c
··· 199 199 200 200 char *tx4927_pcibios_setup(char *str) 201 201 { 202 - unsigned long val; 203 - 204 202 if (!strncmp(str, "trdyto=", 7)) { 205 203 u8 val = 0; 206 204 if (kstrtou8(str + 7, 0, &val) == 0)
+23 -1
arch/mips/pci/pci-alchemy.c
··· 7 7 * Support for all devices (greater than 16) added by David Gathright. 8 8 */ 9 9 10 + #include <linux/clk.h> 10 11 #include <linux/export.h> 11 12 #include <linux/types.h> 12 13 #include <linux/pci.h> ··· 365 364 void __iomem *virt_io; 366 365 unsigned long val; 367 366 struct resource *r; 367 + struct clk *c; 368 368 int ret; 369 369 370 370 /* need at least PCI IRQ mapping table */ ··· 395 393 goto out1; 396 394 } 397 395 396 + c = clk_get(&pdev->dev, "pci_clko"); 397 + if (IS_ERR(c)) { 398 + dev_err(&pdev->dev, "unable to find PCI clock\n"); 399 + ret = PTR_ERR(c); 400 + goto out2; 401 + } 402 + 403 + ret = clk_prepare_enable(c); 404 + if (ret) { 405 + dev_err(&pdev->dev, "cannot enable PCI clock\n"); 406 + goto out6; 407 + } 408 + 398 409 ctx->regs = ioremap_nocache(r->start, resource_size(r)); 399 410 if (!ctx->regs) { 400 411 dev_err(&pdev->dev, "cannot map pci regs\n"); 401 412 ret = -ENODEV; 402 - goto out2; 413 + goto out5; 403 414 } 404 415 405 416 /* map parts of the PCI IO area */ ··· 480 465 register_syscore_ops(&alchemy_pci_pmops); 481 466 register_pci_controller(&ctx->alchemy_pci_ctrl); 482 467 468 + dev_info(&pdev->dev, "PCI controller at %ld MHz\n", 469 + clk_get_rate(c) / 1000000); 470 + 483 471 return 0; 484 472 485 473 out4: 486 474 iounmap(virt_io); 487 475 out3: 488 476 iounmap(ctx->regs); 477 + out5: 478 + clk_disable_unprepare(c); 479 + out6: 480 + clk_put(c); 489 481 out2: 490 482 release_mem_region(r->start, resource_size(r)); 491 483 out1:
+1 -1
arch/mips/ralink/of.c
··· 81 81 panic("device tree not present"); 82 82 83 83 strlcpy(of_ids[0].compatible, soc_info.compatible, len); 84 - strncpy(of_ids[1].compatible, "palmbus", len); 84 + strlcpy(of_ids[1].compatible, "palmbus", len); 85 85 86 86 if (of_platform_populate(NULL, of_ids, NULL, NULL)) 87 87 panic("failed to populate DT");
+5 -23
arch/mips/rb532/devices.c
··· 223 223 224 224 static struct plat_serial8250_port rb532_uart_res[] = { 225 225 { 226 + .type = PORT_16550A, 226 227 .membase = (char *)KSEG1ADDR(REGBASE + UART0BASE), 227 228 .irq = UART0_IRQ, 228 229 .regshift = 2, ··· 250 249 &rb532_uart, 251 250 &rb532_wdt 252 251 }; 253 - 254 - static void __init parse_mac_addr(char *macstr) 255 - { 256 - int i, h, l; 257 - 258 - for (i = 0; i < 6; i++) { 259 - if (i != 5 && *(macstr + 2) != ':') 260 - return; 261 - 262 - h = hex_to_bin(*macstr++); 263 - if (h == -1) 264 - return; 265 - 266 - l = hex_to_bin(*macstr++); 267 - if (l == -1) 268 - return; 269 - 270 - macstr++; 271 - korina_dev0_data.mac[i] = (h << 4) + l; 272 - } 273 - } 274 - 275 252 276 253 /* NAND definitions */ 277 254 #define NAND_CHIP_DELAY 25 ··· 312 333 static int __init setup_kmac(char *s) 313 334 { 314 335 printk(KERN_INFO "korina mac = %s\n", s); 315 - parse_mac_addr(s); 336 + if (!mac_pton(s, korina_dev0_data.mac)) { 337 + printk(KERN_ERR "Invalid mac\n"); 338 + return -EINVAL; 339 + } 316 340 return 0; 317 341 } 318 342
+9 -1
arch/mips/sgi-ip22/ip22-gio.c
··· 27 27 { .name = "SGI GR2/GR3", .id = 0x7f }, 28 28 }; 29 29 30 + static void gio_bus_release(struct device *dev) 31 + { 32 + kfree(dev); 33 + } 34 + 30 35 static struct device gio_bus = { 31 36 .init_name = "gio", 37 + .release = &gio_bus_release, 32 38 }; 33 39 34 40 /** ··· 419 413 int ret; 420 414 421 415 ret = device_register(&gio_bus); 422 - if (ret) 416 + if (ret) { 417 + put_device(&gio_bus); 423 418 return ret; 419 + } 424 420 425 421 ret = bus_register(&gio_bus_type); 426 422 if (!ret) {
+11 -3
arch/mips/txx9/generic/7segled.c
··· 83 83 .dev_name = "7segled", 84 84 }; 85 85 86 + static void tx_7segled_release(struct device *dev) 87 + { 88 + kfree(dev); 89 + } 90 + 86 91 static int __init tx_7segled_init_sysfs(void) 87 92 { 88 93 int error, i; ··· 108 103 } 109 104 dev->id = i; 110 105 dev->bus = &tx_7segled_subsys; 106 + dev->release = &tx_7segled_release; 111 107 error = device_register(dev); 112 - if (!error) { 113 - device_create_file(dev, &dev_attr_ascii); 114 - device_create_file(dev, &dev_attr_raw); 108 + if (error) { 109 + put_device(dev); 110 + return error; 115 111 } 112 + device_create_file(dev, &dev_attr_ascii); 113 + device_create_file(dev, &dev_attr_raw); 116 114 } 117 115 return error; 118 116 }
+2 -2
arch/mips/txx9/generic/pci.c
··· 268 268 return err; 269 269 } 270 270 271 - static void quirk_slc90e66_bridge(struct pci_dev *dev) 271 + static void __init_refok quirk_slc90e66_bridge(struct pci_dev *dev) 272 272 { 273 273 int irq; /* PCI/ISA Bridge interrupt */ 274 274 u8 reg_64; ··· 331 331 * !!! DO NOT REMOVE THIS COMMENT IT IS REQUIRED BY SMSC !!! 332 332 */ 333 333 dat |= 0x01; 334 - pci_write_config_byte(dev, regs[i], dat); 334 + pci_write_config_byte(dev, 0x5c, dat); 335 335 pci_read_config_byte(dev, 0x5c, &dat); 336 336 printk(KERN_CONT " REG5C %02x", dat); 337 337 printk(KERN_CONT "\n");
+19 -10
arch/mips/txx9/generic/setup.c
··· 937 937 return size; 938 938 } 939 939 940 + static void txx9_device_release(struct device *dev) 941 + { 942 + struct txx9_sramc_dev *tdev; 943 + 944 + tdev = container_of(dev, struct txx9_sramc_dev, dev); 945 + kfree(tdev); 946 + } 947 + 940 948 void __init txx9_sramc_init(struct resource *r) 941 949 { 942 950 struct txx9_sramc_dev *dev; ··· 959 951 return; 960 952 size = resource_size(r); 961 953 dev->base = ioremap(r->start, size); 962 - if (!dev->base) 963 - goto exit; 954 + if (!dev->base) { 955 + kfree(dev); 956 + return; 957 + } 958 + dev->dev.release = &txx9_device_release; 964 959 dev->dev.bus = &txx9_sramc_subsys; 965 960 sysfs_bin_attr_init(&dev->bindata_attr); 966 961 dev->bindata_attr.attr.name = "bindata"; ··· 974 963 dev->bindata_attr.private = dev; 975 964 err = device_register(&dev->dev); 976 965 if (err) 977 - goto exit; 966 + goto exit_put; 978 967 err = sysfs_create_bin_file(&dev->dev.kobj, &dev->bindata_attr); 979 968 if (err) { 980 969 device_unregister(&dev->dev); 981 - goto exit; 982 - } 983 - return; 984 - exit: 985 - if (dev) { 986 - if (dev->base) 987 - iounmap(dev->base); 970 + iounmap(dev->base); 988 971 kfree(dev); 989 972 } 973 + return; 974 + exit_put: 975 + put_device(&dev->dev); 976 + return; 990 977 }
+3 -3
drivers/cpufreq/loongson2_cpufreq.c
··· 148 148 u32 cpu_freq; 149 149 150 150 spin_lock_irqsave(&loongson2_wait_lock, flags); 151 - cpu_freq = LOONGSON_CHIPCFG0; 152 - LOONGSON_CHIPCFG0 &= ~0x7; /* Put CPU into wait mode */ 153 - LOONGSON_CHIPCFG0 = cpu_freq; /* Restore CPU state */ 151 + cpu_freq = LOONGSON_CHIPCFG(0); 152 + LOONGSON_CHIPCFG(0) &= ~0x7; /* Put CPU into wait mode */ 153 + LOONGSON_CHIPCFG(0) = cpu_freq; /* Restore CPU state */ 154 154 spin_unlock_irqrestore(&loongson2_wait_lock, flags); 155 155 local_irq_enable(); 156 156 }
+107 -91
drivers/mmc/host/au1xmmc.c
··· 32 32 * (the low to high transition will not occur). 33 33 */ 34 34 35 + #include <linux/clk.h> 35 36 #include <linux/module.h> 36 37 #include <linux/init.h> 37 38 #include <linux/platform_device.h> ··· 91 90 struct mmc_request *mrq; 92 91 93 92 u32 flags; 94 - u32 iobase; 93 + void __iomem *iobase; 95 94 u32 clock; 96 95 u32 bus_width; 97 96 u32 power_mode; ··· 119 118 struct au1xmmc_platform_data *platdata; 120 119 struct platform_device *pdev; 121 120 struct resource *ioarea; 121 + struct clk *clk; 122 122 }; 123 123 124 124 /* Status flags used by the host structure */ ··· 164 162 165 163 static inline void IRQ_ON(struct au1xmmc_host *host, u32 mask) 166 164 { 167 - u32 val = au_readl(HOST_CONFIG(host)); 165 + u32 val = __raw_readl(HOST_CONFIG(host)); 168 166 val |= mask; 169 - au_writel(val, HOST_CONFIG(host)); 170 - au_sync(); 167 + __raw_writel(val, HOST_CONFIG(host)); 168 + wmb(); /* drain writebuffer */ 171 169 } 172 170 173 171 static inline void FLUSH_FIFO(struct au1xmmc_host *host) 174 172 { 175 - u32 val = au_readl(HOST_CONFIG2(host)); 173 + u32 val = __raw_readl(HOST_CONFIG2(host)); 176 174 177 - au_writel(val | SD_CONFIG2_FF, HOST_CONFIG2(host)); 178 - au_sync_delay(1); 175 + __raw_writel(val | SD_CONFIG2_FF, HOST_CONFIG2(host)); 176 + wmb(); /* drain writebuffer */ 177 + mdelay(1); 179 178 180 179 /* SEND_STOP will turn off clock control - this re-enables it */ 181 180 val &= ~SD_CONFIG2_DF; 182 181 183 - au_writel(val, HOST_CONFIG2(host)); 184 - au_sync(); 182 + __raw_writel(val, HOST_CONFIG2(host)); 183 + wmb(); /* drain writebuffer */ 185 184 } 186 185 187 186 static inline void IRQ_OFF(struct au1xmmc_host *host, u32 mask) 188 187 { 189 - u32 val = au_readl(HOST_CONFIG(host)); 188 + u32 val = __raw_readl(HOST_CONFIG(host)); 190 189 val &= ~mask; 191 - au_writel(val, HOST_CONFIG(host)); 192 - au_sync(); 190 + __raw_writel(val, HOST_CONFIG(host)); 191 + wmb(); /* drain writebuffer */ 193 192 } 194 193 195 194 static inline void SEND_STOP(struct au1xmmc_host *host) ··· 200 197 WARN_ON(host->status != HOST_S_DATA); 201 198 host->status = HOST_S_STOP; 202 199 203 - config2 = au_readl(HOST_CONFIG2(host)); 204 - au_writel(config2 | SD_CONFIG2_DF, HOST_CONFIG2(host)); 205 - au_sync(); 200 + config2 = __raw_readl(HOST_CONFIG2(host)); 201 + __raw_writel(config2 | SD_CONFIG2_DF, HOST_CONFIG2(host)); 202 + wmb(); /* drain writebuffer */ 206 203 207 204 /* Send the stop command */ 208 - au_writel(STOP_CMD, HOST_CMD(host)); 205 + __raw_writel(STOP_CMD, HOST_CMD(host)); 206 + wmb(); /* drain writebuffer */ 209 207 } 210 208 211 209 static void au1xmmc_set_power(struct au1xmmc_host *host, int state) ··· 300 296 } 301 297 } 302 298 303 - au_writel(cmd->arg, HOST_CMDARG(host)); 304 - au_sync(); 299 + __raw_writel(cmd->arg, HOST_CMDARG(host)); 300 + wmb(); /* drain writebuffer */ 305 301 306 302 if (wait) 307 303 IRQ_OFF(host, SD_CONFIG_CR); 308 304 309 - au_writel((mmccmd | SD_CMD_GO), HOST_CMD(host)); 310 - au_sync(); 305 + __raw_writel((mmccmd | SD_CMD_GO), HOST_CMD(host)); 306 + wmb(); /* drain writebuffer */ 311 307 312 308 /* Wait for the command to go on the line */ 313 - while (au_readl(HOST_CMD(host)) & SD_CMD_GO) 309 + while (__raw_readl(HOST_CMD(host)) & SD_CMD_GO) 314 310 /* nop */; 315 311 316 312 /* Wait for the command to come back */ 317 313 if (wait) { 318 - u32 status = au_readl(HOST_STATUS(host)); 314 + u32 status = __raw_readl(HOST_STATUS(host)); 319 315 320 316 while (!(status & SD_STATUS_CR)) 321 - status = au_readl(HOST_STATUS(host)); 317 + status = __raw_readl(HOST_STATUS(host)); 322 318 323 319 /* Clear the CR status */ 324 - au_writel(SD_STATUS_CR, HOST_STATUS(host)); 320 + __raw_writel(SD_STATUS_CR, HOST_STATUS(host)); 325 321 326 322 IRQ_ON(host, SD_CONFIG_CR); 327 323 } ··· 343 339 data = mrq->cmd->data; 344 340 345 341 if (status == 0) 346 - status = au_readl(HOST_STATUS(host)); 342 + status = __raw_readl(HOST_STATUS(host)); 347 343 348 344 /* The transaction is really over when the SD_STATUS_DB bit is clear */ 349 345 while ((host->flags & HOST_F_XMIT) && (status & SD_STATUS_DB)) 350 - status = au_readl(HOST_STATUS(host)); 346 + status = __raw_readl(HOST_STATUS(host)); 351 347 352 348 data->error = 0; 353 349 dma_unmap_sg(mmc_dev(host->mmc), data->sg, data->sg_len, host->dma.dir); ··· 361 357 data->error = -EILSEQ; 362 358 363 359 /* Clear the CRC bits */ 364 - au_writel(SD_STATUS_WC | SD_STATUS_RC, HOST_STATUS(host)); 360 + __raw_writel(SD_STATUS_WC | SD_STATUS_RC, HOST_STATUS(host)); 365 361 366 362 data->bytes_xfered = 0; 367 363 ··· 384 380 { 385 381 struct au1xmmc_host *host = (struct au1xmmc_host *)param; 386 382 387 - u32 status = au_readl(HOST_STATUS(host)); 383 + u32 status = __raw_readl(HOST_STATUS(host)); 388 384 au1xmmc_data_complete(host, status); 389 385 } 390 386 ··· 416 412 max = AU1XMMC_MAX_TRANSFER; 417 413 418 414 for (count = 0; count < max; count++) { 419 - status = au_readl(HOST_STATUS(host)); 415 + status = __raw_readl(HOST_STATUS(host)); 420 416 421 417 if (!(status & SD_STATUS_TH)) 422 418 break; 423 419 424 420 val = *sg_ptr++; 425 421 426 - au_writel((unsigned long)val, HOST_TXPORT(host)); 427 - au_sync(); 422 + __raw_writel((unsigned long)val, HOST_TXPORT(host)); 423 + wmb(); /* drain writebuffer */ 428 424 } 429 425 430 426 host->pio.len -= count; ··· 476 472 max = AU1XMMC_MAX_TRANSFER; 477 473 478 474 for (count = 0; count < max; count++) { 479 - status = au_readl(HOST_STATUS(host)); 475 + status = __raw_readl(HOST_STATUS(host)); 480 476 481 477 if (!(status & SD_STATUS_NE)) 482 478 break; ··· 498 494 break; 499 495 } 500 496 501 - val = au_readl(HOST_RXPORT(host)); 497 + val = __raw_readl(HOST_RXPORT(host)); 502 498 503 499 if (sg_ptr) 504 500 *sg_ptr++ = (unsigned char)(val & 0xFF); ··· 541 537 542 538 if (cmd->flags & MMC_RSP_PRESENT) { 543 539 if (cmd->flags & MMC_RSP_136) { 544 - r[0] = au_readl(host->iobase + SD_RESP3); 545 - r[1] = au_readl(host->iobase + SD_RESP2); 546 - r[2] = au_readl(host->iobase + SD_RESP1); 547 - r[3] = au_readl(host->iobase + SD_RESP0); 540 + r[0] = __raw_readl(host->iobase + SD_RESP3); 541 + r[1] = __raw_readl(host->iobase + SD_RESP2); 542 + r[2] = __raw_readl(host->iobase + SD_RESP1); 543 + r[3] = __raw_readl(host->iobase + SD_RESP0); 548 544 549 545 /* The CRC is omitted from the response, so really 550 546 * we only got 120 bytes, but the engine expects ··· 563 559 * that means that the OSR data starts at bit 31, 564 560 * so we can just read RESP0 and return that. 565 561 */ 566 - cmd->resp[0] = au_readl(host->iobase + SD_RESP0); 562 + cmd->resp[0] = __raw_readl(host->iobase + SD_RESP0); 567 563 } 568 564 } 569 565 ··· 590 586 u32 mask = SD_STATUS_DB | SD_STATUS_NE; 591 587 592 588 while((status & mask) != mask) 593 - status = au_readl(HOST_STATUS(host)); 589 + status = __raw_readl(HOST_STATUS(host)); 594 590 } 595 591 596 592 au1xxx_dbdma_start(channel); ··· 599 595 600 596 static void au1xmmc_set_clock(struct au1xmmc_host *host, int rate) 601 597 { 602 - unsigned int pbus = get_au1x00_speed(); 603 - unsigned int divisor; 598 + unsigned int pbus = clk_get_rate(host->clk); 599 + unsigned int divisor = ((pbus / rate) / 2) - 1; 604 600 u32 config; 605 601 606 - /* From databook: 607 - * divisor = ((((cpuclock / sbus_divisor) / 2) / mmcclock) / 2) - 1 608 - */ 609 - pbus /= ((au_readl(SYS_POWERCTRL) & 0x3) + 2); 610 - pbus /= 2; 611 - divisor = ((pbus / rate) / 2) - 1; 612 - 613 - config = au_readl(HOST_CONFIG(host)); 602 + config = __raw_readl(HOST_CONFIG(host)); 614 603 615 604 config &= ~(SD_CONFIG_DIV); 616 605 config |= (divisor & SD_CONFIG_DIV) | SD_CONFIG_DE; 617 606 618 - au_writel(config, HOST_CONFIG(host)); 619 - au_sync(); 607 + __raw_writel(config, HOST_CONFIG(host)); 608 + wmb(); /* drain writebuffer */ 620 609 } 621 610 622 611 static int au1xmmc_prepare_data(struct au1xmmc_host *host, ··· 633 636 if (host->dma.len == 0) 634 637 return -ETIMEDOUT; 635 638 636 - au_writel(data->blksz - 1, HOST_BLKSIZE(host)); 639 + __raw_writel(data->blksz - 1, HOST_BLKSIZE(host)); 637 640 638 641 if (host->flags & (HOST_F_DMA | HOST_F_DBDMA)) { 639 642 int i; ··· 720 723 static void au1xmmc_reset_controller(struct au1xmmc_host *host) 721 724 { 722 725 /* Apply the clock */ 723 - au_writel(SD_ENABLE_CE, HOST_ENABLE(host)); 724 - au_sync_delay(1); 726 + __raw_writel(SD_ENABLE_CE, HOST_ENABLE(host)); 727 + wmb(); /* drain writebuffer */ 728 + mdelay(1); 725 729 726 - au_writel(SD_ENABLE_R | SD_ENABLE_CE, HOST_ENABLE(host)); 727 - au_sync_delay(5); 730 + __raw_writel(SD_ENABLE_R | SD_ENABLE_CE, HOST_ENABLE(host)); 731 + wmb(); /* drain writebuffer */ 732 + mdelay(5); 728 733 729 - au_writel(~0, HOST_STATUS(host)); 730 - au_sync(); 734 + __raw_writel(~0, HOST_STATUS(host)); 735 + wmb(); /* drain writebuffer */ 731 736 732 - au_writel(0, HOST_BLKSIZE(host)); 733 - au_writel(0x001fffff, HOST_TIMEOUT(host)); 734 - au_sync(); 737 + __raw_writel(0, HOST_BLKSIZE(host)); 738 + __raw_writel(0x001fffff, HOST_TIMEOUT(host)); 739 + wmb(); /* drain writebuffer */ 735 740 736 - au_writel(SD_CONFIG2_EN, HOST_CONFIG2(host)); 737 - au_sync(); 741 + __raw_writel(SD_CONFIG2_EN, HOST_CONFIG2(host)); 742 + wmb(); /* drain writebuffer */ 738 743 739 - au_writel(SD_CONFIG2_EN | SD_CONFIG2_FF, HOST_CONFIG2(host)); 740 - au_sync_delay(1); 744 + __raw_writel(SD_CONFIG2_EN | SD_CONFIG2_FF, HOST_CONFIG2(host)); 745 + wmb(); /* drain writebuffer */ 746 + mdelay(1); 741 747 742 - au_writel(SD_CONFIG2_EN, HOST_CONFIG2(host)); 743 - au_sync(); 748 + __raw_writel(SD_CONFIG2_EN, HOST_CONFIG2(host)); 749 + wmb(); /* drain writebuffer */ 744 750 745 751 /* Configure interrupts */ 746 - au_writel(AU1XMMC_INTERRUPTS, HOST_CONFIG(host)); 747 - au_sync(); 752 + __raw_writel(AU1XMMC_INTERRUPTS, HOST_CONFIG(host)); 753 + wmb(); /* drain writebuffer */ 748 754 } 749 755 750 756 ··· 767 767 host->clock = ios->clock; 768 768 } 769 769 770 - config2 = au_readl(HOST_CONFIG2(host)); 770 + config2 = __raw_readl(HOST_CONFIG2(host)); 771 771 switch (ios->bus_width) { 772 772 case MMC_BUS_WIDTH_8: 773 773 config2 |= SD_CONFIG2_BB; ··· 780 780 config2 &= ~(SD_CONFIG2_WB | SD_CONFIG2_BB); 781 781 break; 782 782 } 783 - au_writel(config2, HOST_CONFIG2(host)); 784 - au_sync(); 783 + __raw_writel(config2, HOST_CONFIG2(host)); 784 + wmb(); /* drain writebuffer */ 785 785 } 786 786 787 787 #define STATUS_TIMEOUT (SD_STATUS_RAT | SD_STATUS_DT) ··· 793 793 struct au1xmmc_host *host = dev_id; 794 794 u32 status; 795 795 796 - status = au_readl(HOST_STATUS(host)); 796 + status = __raw_readl(HOST_STATUS(host)); 797 797 798 798 if (!(status & SD_STATUS_I)) 799 799 return IRQ_NONE; /* not ours */ ··· 839 839 status); 840 840 } 841 841 842 - au_writel(status, HOST_STATUS(host)); 843 - au_sync(); 842 + __raw_writel(status, HOST_STATUS(host)); 843 + wmb(); /* drain writebuffer */ 844 844 845 845 return IRQ_HANDLED; 846 846 } ··· 976 976 goto out1; 977 977 } 978 978 979 - host->iobase = (unsigned long)ioremap(r->start, 0x3c); 979 + host->iobase = ioremap(r->start, 0x3c); 980 980 if (!host->iobase) { 981 981 dev_err(&pdev->dev, "cannot remap mmio\n"); 982 982 goto out2; ··· 1023 1023 if (ret) { 1024 1024 dev_err(&pdev->dev, "cannot grab IRQ\n"); 1025 1025 goto out3; 1026 + } 1027 + 1028 + host->clk = clk_get(&pdev->dev, ALCHEMY_PERIPH_CLK); 1029 + if (IS_ERR(host->clk)) { 1030 + dev_err(&pdev->dev, "cannot find clock\n"); 1031 + goto out_irq; 1032 + } 1033 + if (clk_prepare_enable(host->clk)) { 1034 + dev_err(&pdev->dev, "cannot enable clock\n"); 1035 + goto out_clk; 1026 1036 } 1027 1037 1028 1038 host->status = HOST_S_IDLE; ··· 1085 1075 1086 1076 platform_set_drvdata(pdev, host); 1087 1077 1088 - pr_info(DRIVER_NAME ": MMC Controller %d set up at %8.8X" 1078 + pr_info(DRIVER_NAME ": MMC Controller %d set up at %p" 1089 1079 " (mode=%s)\n", pdev->id, host->iobase, 1090 1080 host->flags & HOST_F_DMA ? "dma" : "pio"); 1091 1081 ··· 1097 1087 led_classdev_unregister(host->platdata->led); 1098 1088 out5: 1099 1089 #endif 1100 - au_writel(0, HOST_ENABLE(host)); 1101 - au_writel(0, HOST_CONFIG(host)); 1102 - au_writel(0, HOST_CONFIG2(host)); 1103 - au_sync(); 1090 + __raw_writel(0, HOST_ENABLE(host)); 1091 + __raw_writel(0, HOST_CONFIG(host)); 1092 + __raw_writel(0, HOST_CONFIG2(host)); 1093 + wmb(); /* drain writebuffer */ 1104 1094 1105 1095 if (host->flags & HOST_F_DBDMA) 1106 1096 au1xmmc_dbdma_shutdown(host); ··· 1111 1101 if (host->platdata && host->platdata->cd_setup && 1112 1102 !(mmc->caps & MMC_CAP_NEEDS_POLL)) 1113 1103 host->platdata->cd_setup(mmc, 0); 1114 - 1104 + out_clk: 1105 + clk_disable_unprepare(host->clk); 1106 + clk_put(host->clk); 1107 + out_irq: 1115 1108 free_irq(host->irq, host); 1116 1109 out3: 1117 1110 iounmap((void *)host->iobase); ··· 1143 1130 !(host->mmc->caps & MMC_CAP_NEEDS_POLL)) 1144 1131 host->platdata->cd_setup(host->mmc, 0); 1145 1132 1146 - au_writel(0, HOST_ENABLE(host)); 1147 - au_writel(0, HOST_CONFIG(host)); 1148 - au_writel(0, HOST_CONFIG2(host)); 1149 - au_sync(); 1133 + __raw_writel(0, HOST_ENABLE(host)); 1134 + __raw_writel(0, HOST_CONFIG(host)); 1135 + __raw_writel(0, HOST_CONFIG2(host)); 1136 + wmb(); /* drain writebuffer */ 1150 1137 1151 1138 tasklet_kill(&host->data_task); 1152 1139 tasklet_kill(&host->finish_task); ··· 1155 1142 au1xmmc_dbdma_shutdown(host); 1156 1143 1157 1144 au1xmmc_set_power(host, 0); 1145 + 1146 + clk_disable_unprepare(host->clk); 1147 + clk_put(host->clk); 1158 1148 1159 1149 free_irq(host->irq, host); 1160 1150 iounmap((void *)host->iobase); ··· 1174 1158 { 1175 1159 struct au1xmmc_host *host = platform_get_drvdata(pdev); 1176 1160 1177 - au_writel(0, HOST_CONFIG2(host)); 1178 - au_writel(0, HOST_CONFIG(host)); 1179 - au_writel(0xffffffff, HOST_STATUS(host)); 1180 - au_writel(0, HOST_ENABLE(host)); 1181 - au_sync(); 1161 + __raw_writel(0, HOST_CONFIG2(host)); 1162 + __raw_writel(0, HOST_CONFIG(host)); 1163 + __raw_writel(0xffffffff, HOST_STATUS(host)); 1164 + __raw_writel(0, HOST_ENABLE(host)); 1165 + wmb(); /* drain writebuffer */ 1182 1166 1183 1167 return 0; 1184 1168 }
+13 -16
drivers/mtd/nand/au1550nd.c
··· 41 41 { 42 42 struct nand_chip *this = mtd->priv; 43 43 u_char ret = readb(this->IO_ADDR_R); 44 - au_sync(); 44 + wmb(); /* drain writebuffer */ 45 45 return ret; 46 46 } 47 47 ··· 56 56 { 57 57 struct nand_chip *this = mtd->priv; 58 58 writeb(byte, this->IO_ADDR_W); 59 - au_sync(); 59 + wmb(); /* drain writebuffer */ 60 60 } 61 61 62 62 /** ··· 69 69 { 70 70 struct nand_chip *this = mtd->priv; 71 71 u_char ret = (u_char) cpu_to_le16(readw(this->IO_ADDR_R)); 72 - au_sync(); 72 + wmb(); /* drain writebuffer */ 73 73 return ret; 74 74 } 75 75 ··· 84 84 { 85 85 struct nand_chip *this = mtd->priv; 86 86 writew(le16_to_cpu((u16) byte), this->IO_ADDR_W); 87 - au_sync(); 87 + wmb(); /* drain writebuffer */ 88 88 } 89 89 90 90 /** ··· 97 97 { 98 98 struct nand_chip *this = mtd->priv; 99 99 u16 ret = readw(this->IO_ADDR_R); 100 - au_sync(); 100 + wmb(); /* drain writebuffer */ 101 101 return ret; 102 102 } 103 103 ··· 116 116 117 117 for (i = 0; i < len; i++) { 118 118 writeb(buf[i], this->IO_ADDR_W); 119 - au_sync(); 119 + wmb(); /* drain writebuffer */ 120 120 } 121 121 } 122 122 ··· 135 135 136 136 for (i = 0; i < len; i++) { 137 137 buf[i] = readb(this->IO_ADDR_R); 138 - au_sync(); 138 + wmb(); /* drain writebuffer */ 139 139 } 140 140 } 141 141 ··· 156 156 157 157 for (i = 0; i < len; i++) { 158 158 writew(p[i], this->IO_ADDR_W); 159 - au_sync(); 159 + wmb(); /* drain writebuffer */ 160 160 } 161 161 162 162 } ··· 178 178 179 179 for (i = 0; i < len; i++) { 180 180 p[i] = readw(this->IO_ADDR_R); 181 - au_sync(); 181 + wmb(); /* drain writebuffer */ 182 182 } 183 183 } 184 184 ··· 223 223 224 224 case NAND_CTL_SETNCE: 225 225 /* assert (force assert) chip enable */ 226 - au_writel((1 << (4 + ctx->cs)), MEM_STNDCTL); 226 + alchemy_wrsmem((1 << (4 + ctx->cs)), AU1000_MEM_STNDCTL); 227 227 break; 228 228 229 229 case NAND_CTL_CLRNCE: 230 230 /* deassert chip enable */ 231 - au_writel(0, MEM_STNDCTL); 231 + alchemy_wrsmem(0, AU1000_MEM_STNDCTL); 232 232 break; 233 233 } 234 234 235 235 this->IO_ADDR_R = this->IO_ADDR_W; 236 236 237 - /* Drain the writebuffer */ 238 - au_sync(); 237 + wmb(); /* Drain the writebuffer */ 239 238 } 240 239 241 240 int au1550_device_ready(struct mtd_info *mtd) 242 241 { 243 - int ret = (au_readl(MEM_STSTAT) & 0x1) ? 1 : 0; 244 - au_sync(); 245 - return ret; 242 + return (alchemy_rdsmem(AU1000_MEM_STSTAT) & 0x1) ? 1 : 0; 246 243 } 247 244 248 245 /**
+137 -12
drivers/net/ethernet/amd/au1000_eth.c
··· 89 89 MODULE_LICENSE("GPL"); 90 90 MODULE_VERSION(DRV_VERSION); 91 91 92 + /* AU1000 MAC registers and bits */ 93 + #define MAC_CONTROL 0x0 94 + # define MAC_RX_ENABLE (1 << 2) 95 + # define MAC_TX_ENABLE (1 << 3) 96 + # define MAC_DEF_CHECK (1 << 5) 97 + # define MAC_SET_BL(X) (((X) & 0x3) << 6) 98 + # define MAC_AUTO_PAD (1 << 8) 99 + # define MAC_DISABLE_RETRY (1 << 10) 100 + # define MAC_DISABLE_BCAST (1 << 11) 101 + # define MAC_LATE_COL (1 << 12) 102 + # define MAC_HASH_MODE (1 << 13) 103 + # define MAC_HASH_ONLY (1 << 15) 104 + # define MAC_PASS_ALL (1 << 16) 105 + # define MAC_INVERSE_FILTER (1 << 17) 106 + # define MAC_PROMISCUOUS (1 << 18) 107 + # define MAC_PASS_ALL_MULTI (1 << 19) 108 + # define MAC_FULL_DUPLEX (1 << 20) 109 + # define MAC_NORMAL_MODE 0 110 + # define MAC_INT_LOOPBACK (1 << 21) 111 + # define MAC_EXT_LOOPBACK (1 << 22) 112 + # define MAC_DISABLE_RX_OWN (1 << 23) 113 + # define MAC_BIG_ENDIAN (1 << 30) 114 + # define MAC_RX_ALL (1 << 31) 115 + #define MAC_ADDRESS_HIGH 0x4 116 + #define MAC_ADDRESS_LOW 0x8 117 + #define MAC_MCAST_HIGH 0xC 118 + #define MAC_MCAST_LOW 0x10 119 + #define MAC_MII_CNTRL 0x14 120 + # define MAC_MII_BUSY (1 << 0) 121 + # define MAC_MII_READ 0 122 + # define MAC_MII_WRITE (1 << 1) 123 + # define MAC_SET_MII_SELECT_REG(X) (((X) & 0x1f) << 6) 124 + # define MAC_SET_MII_SELECT_PHY(X) (((X) & 0x1f) << 11) 125 + #define MAC_MII_DATA 0x18 126 + #define MAC_FLOW_CNTRL 0x1C 127 + # define MAC_FLOW_CNTRL_BUSY (1 << 0) 128 + # define MAC_FLOW_CNTRL_ENABLE (1 << 1) 129 + # define MAC_PASS_CONTROL (1 << 2) 130 + # define MAC_SET_PAUSE(X) (((X) & 0xffff) << 16) 131 + #define MAC_VLAN1_TAG 0x20 132 + #define MAC_VLAN2_TAG 0x24 133 + 134 + /* Ethernet Controller Enable */ 135 + # define MAC_EN_CLOCK_ENABLE (1 << 0) 136 + # define MAC_EN_RESET0 (1 << 1) 137 + # define MAC_EN_TOSS (0 << 2) 138 + # define MAC_EN_CACHEABLE (1 << 3) 139 + # define MAC_EN_RESET1 (1 << 4) 140 + # define MAC_EN_RESET2 (1 << 5) 141 + # define MAC_DMA_RESET (1 << 6) 142 + 143 + /* Ethernet Controller DMA Channels */ 144 + /* offsets from MAC_TX_RING_ADDR address */ 145 + #define MAC_TX_BUFF0_STATUS 0x0 146 + # define TX_FRAME_ABORTED (1 << 0) 147 + # define TX_JAB_TIMEOUT (1 << 1) 148 + # define TX_NO_CARRIER (1 << 2) 149 + # define TX_LOSS_CARRIER (1 << 3) 150 + # define TX_EXC_DEF (1 << 4) 151 + # define TX_LATE_COLL_ABORT (1 << 5) 152 + # define TX_EXC_COLL (1 << 6) 153 + # define TX_UNDERRUN (1 << 7) 154 + # define TX_DEFERRED (1 << 8) 155 + # define TX_LATE_COLL (1 << 9) 156 + # define TX_COLL_CNT_MASK (0xF << 10) 157 + # define TX_PKT_RETRY (1 << 31) 158 + #define MAC_TX_BUFF0_ADDR 0x4 159 + # define TX_DMA_ENABLE (1 << 0) 160 + # define TX_T_DONE (1 << 1) 161 + # define TX_GET_DMA_BUFFER(X) (((X) >> 2) & 0x3) 162 + #define MAC_TX_BUFF0_LEN 0x8 163 + #define MAC_TX_BUFF1_STATUS 0x10 164 + #define MAC_TX_BUFF1_ADDR 0x14 165 + #define MAC_TX_BUFF1_LEN 0x18 166 + #define MAC_TX_BUFF2_STATUS 0x20 167 + #define MAC_TX_BUFF2_ADDR 0x24 168 + #define MAC_TX_BUFF2_LEN 0x28 169 + #define MAC_TX_BUFF3_STATUS 0x30 170 + #define MAC_TX_BUFF3_ADDR 0x34 171 + #define MAC_TX_BUFF3_LEN 0x38 172 + 173 + /* offsets from MAC_RX_RING_ADDR */ 174 + #define MAC_RX_BUFF0_STATUS 0x0 175 + # define RX_FRAME_LEN_MASK 0x3fff 176 + # define RX_WDOG_TIMER (1 << 14) 177 + # define RX_RUNT (1 << 15) 178 + # define RX_OVERLEN (1 << 16) 179 + # define RX_COLL (1 << 17) 180 + # define RX_ETHER (1 << 18) 181 + # define RX_MII_ERROR (1 << 19) 182 + # define RX_DRIBBLING (1 << 20) 183 + # define RX_CRC_ERROR (1 << 21) 184 + # define RX_VLAN1 (1 << 22) 185 + # define RX_VLAN2 (1 << 23) 186 + # define RX_LEN_ERROR (1 << 24) 187 + # define RX_CNTRL_FRAME (1 << 25) 188 + # define RX_U_CNTRL_FRAME (1 << 26) 189 + # define RX_MCAST_FRAME (1 << 27) 190 + # define RX_BCAST_FRAME (1 << 28) 191 + # define RX_FILTER_FAIL (1 << 29) 192 + # define RX_PACKET_FILTER (1 << 30) 193 + # define RX_MISSED_FRAME (1 << 31) 194 + 195 + # define RX_ERROR (RX_WDOG_TIMER | RX_RUNT | RX_OVERLEN | \ 196 + RX_COLL | RX_MII_ERROR | RX_CRC_ERROR | \ 197 + RX_LEN_ERROR | RX_U_CNTRL_FRAME | RX_MISSED_FRAME) 198 + #define MAC_RX_BUFF0_ADDR 0x4 199 + # define RX_DMA_ENABLE (1 << 0) 200 + # define RX_T_DONE (1 << 1) 201 + # define RX_GET_DMA_BUFFER(X) (((X) >> 2) & 0x3) 202 + # define RX_SET_BUFF_ADDR(X) ((X) & 0xffffffc0) 203 + #define MAC_RX_BUFF1_STATUS 0x10 204 + #define MAC_RX_BUFF1_ADDR 0x14 205 + #define MAC_RX_BUFF2_STATUS 0x20 206 + #define MAC_RX_BUFF2_ADDR 0x24 207 + #define MAC_RX_BUFF3_STATUS 0x30 208 + #define MAC_RX_BUFF3_ADDR 0x34 209 + 92 210 /* 93 211 * Theory of operation 94 212 * ··· 270 152 271 153 if (force_reset || (!aup->mac_enabled)) { 272 154 writel(MAC_EN_CLOCK_ENABLE, aup->enable); 273 - au_sync_delay(2); 155 + wmb(); /* drain writebuffer */ 156 + mdelay(2); 274 157 writel((MAC_EN_RESET0 | MAC_EN_RESET1 | MAC_EN_RESET2 275 158 | MAC_EN_CLOCK_ENABLE), aup->enable); 276 - au_sync_delay(2); 159 + wmb(); /* drain writebuffer */ 160 + mdelay(2); 277 161 278 162 aup->mac_enabled = 1; 279 163 } ··· 393 273 reg = readl(&aup->mac->control); 394 274 reg &= ~(MAC_RX_ENABLE | MAC_TX_ENABLE); 395 275 writel(reg, &aup->mac->control); 396 - au_sync_delay(10); 276 + wmb(); /* drain writebuffer */ 277 + mdelay(10); 397 278 } 398 279 399 280 static void au1000_enable_rx_tx(struct net_device *dev) ··· 407 286 reg = readl(&aup->mac->control); 408 287 reg |= (MAC_RX_ENABLE | MAC_TX_ENABLE); 409 288 writel(reg, &aup->mac->control); 410 - au_sync_delay(10); 289 + wmb(); /* drain writebuffer */ 290 + mdelay(10); 411 291 } 412 292 413 293 static void ··· 458 336 reg |= MAC_DISABLE_RX_OWN; 459 337 } 460 338 writel(reg, &aup->mac->control); 461 - au_sync_delay(1); 339 + wmb(); /* drain writebuffer */ 340 + mdelay(1); 462 341 463 342 au1000_enable_rx_tx(dev); 464 343 aup->old_duplex = phydev->duplex; ··· 623 500 au1000_hard_stop(dev); 624 501 625 502 writel(MAC_EN_CLOCK_ENABLE, aup->enable); 626 - au_sync_delay(2); 503 + wmb(); /* drain writebuffer */ 504 + mdelay(2); 627 505 writel(0, aup->enable); 628 - au_sync_delay(2); 506 + wmb(); /* drain writebuffer */ 507 + mdelay(2); 629 508 630 509 aup->tx_full = 0; 631 510 for (i = 0; i < NUM_RX_DMA; i++) { ··· 777 652 for (i = 0; i < NUM_RX_DMA; i++) 778 653 aup->rx_dma_ring[i]->buff_stat |= RX_DMA_ENABLE; 779 654 780 - au_sync(); 655 + wmb(); /* drain writebuffer */ 781 656 782 657 control = MAC_RX_ENABLE | MAC_TX_ENABLE; 783 658 #ifndef CONFIG_CPU_LITTLE_ENDIAN ··· 794 669 795 670 writel(control, &aup->mac->control); 796 671 writel(0x8100, &aup->mac->vlan1_tag); /* activate vlan support */ 797 - au_sync(); 672 + wmb(); /* drain writebuffer */ 798 673 799 674 spin_unlock_irqrestore(&aup->lock, flags); 800 675 return 0; ··· 885 760 } 886 761 prxd->buff_stat = (u32)(pDB->dma_addr | RX_DMA_ENABLE); 887 762 aup->rx_head = (aup->rx_head + 1) & (NUM_RX_DMA - 1); 888 - au_sync(); 763 + wmb(); /* drain writebuffer */ 889 764 890 765 /* next descriptor */ 891 766 prxd = aup->rx_dma_ring[aup->rx_head]; ··· 933 808 au1000_update_tx_stats(dev, ptxd->status); 934 809 ptxd->buff_stat &= ~TX_T_DONE; 935 810 ptxd->len = 0; 936 - au_sync(); 811 + wmb(); /* drain writebuffer */ 937 812 938 813 aup->tx_tail = (aup->tx_tail + 1) & (NUM_TX_DMA - 1); 939 814 ptxd = aup->tx_dma_ring[aup->tx_tail]; ··· 1064 939 ps->tx_bytes += ptxd->len; 1065 940 1066 941 ptxd->buff_stat = pDB->dma_addr | TX_DMA_ENABLE; 1067 - au_sync(); 942 + wmb(); /* drain writebuffer */ 1068 943 dev_kfree_skb(skb); 1069 944 aup->tx_head = (aup->tx_head + 1) & (NUM_TX_DMA - 1); 1070 945 return NETDEV_TX_OK;
+46 -2
drivers/net/irda/au1k_ir.c
··· 18 18 * with this program; if not, see <http://www.gnu.org/licenses/>. 19 19 */ 20 20 21 + #include <linux/clk.h> 21 22 #include <linux/module.h> 22 23 #include <linux/netdevice.h> 23 24 #include <linux/interrupt.h> ··· 176 175 177 176 struct resource *ioarea; 178 177 struct au1k_irda_platform_data *platdata; 178 + struct clk *irda_clk; 179 179 }; 180 180 181 181 static int qos_mtt_bits = 0x07; /* 1 ms or more */ ··· 516 514 static int au1k_init(struct net_device *dev) 517 515 { 518 516 struct au1k_private *aup = netdev_priv(dev); 519 - u32 enable, ring_address; 517 + u32 enable, ring_address, phyck; 518 + struct clk *c; 520 519 int i; 520 + 521 + c = clk_get(NULL, "irda_clk"); 522 + if (IS_ERR(c)) 523 + return PTR_ERR(c); 524 + i = clk_prepare_enable(c); 525 + if (i) { 526 + clk_put(c); 527 + return i; 528 + } 529 + 530 + switch (clk_get_rate(c)) { 531 + case 40000000: 532 + phyck = IR_PHYCLK_40MHZ; 533 + break; 534 + case 48000000: 535 + phyck = IR_PHYCLK_48MHZ; 536 + break; 537 + case 56000000: 538 + phyck = IR_PHYCLK_56MHZ; 539 + break; 540 + case 64000000: 541 + phyck = IR_PHYCLK_64MHZ; 542 + break; 543 + default: 544 + clk_disable_unprepare(c); 545 + clk_put(c); 546 + return -EINVAL; 547 + } 548 + aup->irda_clk = c; 521 549 522 550 enable = IR_HC | IR_CE | IR_C; 523 551 #ifndef CONFIG_CPU_LITTLE_ENDIAN ··· 577 545 irda_write(aup, IR_RING_SIZE, 578 546 (RING_SIZE_64 << 8) | (RING_SIZE_64 << 12)); 579 547 580 - irda_write(aup, IR_CONFIG_2, IR_PHYCLK_48MHZ | IR_ONE_PIN); 548 + irda_write(aup, IR_CONFIG_2, phyck | IR_ONE_PIN); 581 549 irda_write(aup, IR_RING_ADDR_CMPR, 0); 582 550 583 551 au1k_irda_set_speed(dev, 9600); ··· 650 618 /* disable the interrupt */ 651 619 free_irq(aup->irq_tx, dev); 652 620 free_irq(aup->irq_rx, dev); 621 + 622 + clk_disable_unprepare(aup->irda_clk); 623 + clk_put(aup->irda_clk); 653 624 654 625 return 0; 655 626 } ··· 888 853 struct au1k_private *aup; 889 854 struct net_device *dev; 890 855 struct resource *r; 856 + struct clk *c; 891 857 int err; 892 858 893 859 dev = alloc_irdadev(sizeof(struct au1k_private)); ··· 921 885 pdev->name); 922 886 if (!aup->ioarea) 923 887 goto out; 888 + 889 + /* bail out early if clock doesn't exist */ 890 + c = clk_get(NULL, "irda_clk"); 891 + if (IS_ERR(c)) { 892 + err = PTR_ERR(c); 893 + goto out; 894 + } 895 + clk_put(c); 924 896 925 897 aup->iobase = ioremap_nocache(r->start, resource_size(r)); 926 898 if (!aup->iobase)
+8 -10
drivers/rtc/rtc-au1xxx.c
··· 32 32 { 33 33 unsigned long t; 34 34 35 - t = au_readl(SYS_TOYREAD); 35 + t = alchemy_rdsys(AU1000_SYS_TOYREAD); 36 36 37 37 rtc_time_to_tm(t, tm); 38 38 ··· 45 45 46 46 rtc_tm_to_time(tm, &t); 47 47 48 - au_writel(t, SYS_TOYWRITE); 49 - au_sync(); 48 + alchemy_wrsys(t, AU1000_SYS_TOYWRITE); 50 49 51 50 /* wait for the pending register write to succeed. This can 52 51 * take up to 6 seconds... 53 52 */ 54 - while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_C0S) 53 + while (alchemy_rdsys(AU1000_SYS_CNTRCTRL) & SYS_CNTRL_C0S) 55 54 msleep(1); 56 55 57 56 return 0; ··· 67 68 unsigned long t; 68 69 int ret; 69 70 70 - t = au_readl(SYS_COUNTER_CNTRL); 71 + t = alchemy_rdsys(AU1000_SYS_CNTRCTRL); 71 72 if (!(t & CNTR_OK)) { 72 73 dev_err(&pdev->dev, "counters not working; aborting.\n"); 73 74 ret = -ENODEV; ··· 77 78 ret = -ETIMEDOUT; 78 79 79 80 /* set counter0 tickrate to 1Hz if necessary */ 80 - if (au_readl(SYS_TOYTRIM) != 32767) { 81 + if (alchemy_rdsys(AU1000_SYS_TOYTRIM) != 32767) { 81 82 /* wait until hardware gives access to TRIM register */ 82 83 t = 0x00100000; 83 - while ((au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_T0S) && --t) 84 + while ((alchemy_rdsys(AU1000_SYS_CNTRCTRL) & SYS_CNTRL_T0S) && --t) 84 85 msleep(1); 85 86 86 87 if (!t) { ··· 92 93 } 93 94 94 95 /* set 1Hz TOY tick rate */ 95 - au_writel(32767, SYS_TOYTRIM); 96 - au_sync(); 96 + alchemy_wrsys(32767, AU1000_SYS_TOYTRIM); 97 97 } 98 98 99 99 /* wait until the hardware allows writes to the counter reg */ 100 - while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_C0S) 100 + while (alchemy_rdsys(AU1000_SYS_CNTRCTRL) & SYS_CNTRL_C0S) 101 101 msleep(1); 102 102 103 103 rtcdev = devm_rtc_device_register(&pdev->dev, "rtc-au1xxx",
+33 -33
drivers/spi/spi-au1550.c
··· 141 141 PSC_SPIMSK_MM | PSC_SPIMSK_RR | PSC_SPIMSK_RO 142 142 | PSC_SPIMSK_RU | PSC_SPIMSK_TR | PSC_SPIMSK_TO 143 143 | PSC_SPIMSK_TU | PSC_SPIMSK_SD | PSC_SPIMSK_MD; 144 - au_sync(); 144 + wmb(); /* drain writebuffer */ 145 145 146 146 hw->regs->psc_spievent = 147 147 PSC_SPIEVNT_MM | PSC_SPIEVNT_RR | PSC_SPIEVNT_RO 148 148 | PSC_SPIEVNT_RU | PSC_SPIEVNT_TR | PSC_SPIEVNT_TO 149 149 | PSC_SPIEVNT_TU | PSC_SPIEVNT_SD | PSC_SPIEVNT_MD; 150 - au_sync(); 150 + wmb(); /* drain writebuffer */ 151 151 } 152 152 153 153 static void au1550_spi_reset_fifos(struct au1550_spi *hw) ··· 155 155 u32 pcr; 156 156 157 157 hw->regs->psc_spipcr = PSC_SPIPCR_RC | PSC_SPIPCR_TC; 158 - au_sync(); 158 + wmb(); /* drain writebuffer */ 159 159 do { 160 160 pcr = hw->regs->psc_spipcr; 161 - au_sync(); 161 + wmb(); /* drain writebuffer */ 162 162 } while (pcr != 0); 163 163 } 164 164 ··· 188 188 au1550_spi_bits_handlers_set(hw, spi->bits_per_word); 189 189 190 190 cfg = hw->regs->psc_spicfg; 191 - au_sync(); 191 + wmb(); /* drain writebuffer */ 192 192 hw->regs->psc_spicfg = cfg & ~PSC_SPICFG_DE_ENABLE; 193 - au_sync(); 193 + wmb(); /* drain writebuffer */ 194 194 195 195 if (spi->mode & SPI_CPOL) 196 196 cfg |= PSC_SPICFG_BI; ··· 218 218 cfg |= au1550_spi_baudcfg(hw, spi->max_speed_hz); 219 219 220 220 hw->regs->psc_spicfg = cfg | PSC_SPICFG_DE_ENABLE; 221 - au_sync(); 221 + wmb(); /* drain writebuffer */ 222 222 do { 223 223 stat = hw->regs->psc_spistat; 224 - au_sync(); 224 + wmb(); /* drain writebuffer */ 225 225 } while ((stat & PSC_SPISTAT_DR) == 0); 226 226 227 227 if (hw->pdata->activate_cs) ··· 252 252 au1550_spi_bits_handlers_set(hw, spi->bits_per_word); 253 253 254 254 cfg = hw->regs->psc_spicfg; 255 - au_sync(); 255 + wmb(); /* drain writebuffer */ 256 256 hw->regs->psc_spicfg = cfg & ~PSC_SPICFG_DE_ENABLE; 257 - au_sync(); 257 + wmb(); /* drain writebuffer */ 258 258 259 259 if (hw->usedma && bpw <= 8) 260 260 cfg &= ~PSC_SPICFG_DD_DISABLE; ··· 268 268 cfg |= au1550_spi_baudcfg(hw, hz); 269 269 270 270 hw->regs->psc_spicfg = cfg; 271 - au_sync(); 271 + wmb(); /* drain writebuffer */ 272 272 273 273 if (cfg & PSC_SPICFG_DE_ENABLE) { 274 274 do { 275 275 stat = hw->regs->psc_spistat; 276 - au_sync(); 276 + wmb(); /* drain writebuffer */ 277 277 } while ((stat & PSC_SPISTAT_DR) == 0); 278 278 } 279 279 ··· 396 396 397 397 /* by default enable nearly all events interrupt */ 398 398 hw->regs->psc_spimsk = PSC_SPIMSK_SD; 399 - au_sync(); 399 + wmb(); /* drain writebuffer */ 400 400 401 401 /* start the transfer */ 402 402 hw->regs->psc_spipcr = PSC_SPIPCR_MS; 403 - au_sync(); 403 + wmb(); /* drain writebuffer */ 404 404 405 405 wait_for_completion(&hw->master_done); 406 406 ··· 429 429 430 430 stat = hw->regs->psc_spistat; 431 431 evnt = hw->regs->psc_spievent; 432 - au_sync(); 432 + wmb(); /* drain writebuffer */ 433 433 if ((stat & PSC_SPISTAT_DI) == 0) { 434 434 dev_err(hw->dev, "Unexpected IRQ!\n"); 435 435 return IRQ_NONE; ··· 484 484 static void au1550_spi_rx_word_##size(struct au1550_spi *hw) \ 485 485 { \ 486 486 u32 fifoword = hw->regs->psc_spitxrx & (u32)(mask); \ 487 - au_sync(); \ 487 + wmb(); /* drain writebuffer */ \ 488 488 if (hw->rx) { \ 489 489 *(u##size *)hw->rx = (u##size)fifoword; \ 490 490 hw->rx += (size) / 8; \ ··· 504 504 if (hw->tx_count >= hw->len) \ 505 505 fifoword |= PSC_SPITXRX_LC; \ 506 506 hw->regs->psc_spitxrx = fifoword; \ 507 - au_sync(); \ 507 + wmb(); /* drain writebuffer */ \ 508 508 } 509 509 510 510 AU1550_SPI_RX_WORD(8,0xff) ··· 539 539 } 540 540 541 541 stat = hw->regs->psc_spistat; 542 - au_sync(); 542 + wmb(); /* drain writebuffer */ 543 543 if (stat & PSC_SPISTAT_TF) 544 544 break; 545 545 } 546 546 547 547 /* enable event interrupts */ 548 548 hw->regs->psc_spimsk = mask; 549 - au_sync(); 549 + wmb(); /* drain writebuffer */ 550 550 551 551 /* start the transfer */ 552 552 hw->regs->psc_spipcr = PSC_SPIPCR_MS; 553 - au_sync(); 553 + wmb(); /* drain writebuffer */ 554 554 555 555 wait_for_completion(&hw->master_done); 556 556 ··· 564 564 565 565 stat = hw->regs->psc_spistat; 566 566 evnt = hw->regs->psc_spievent; 567 - au_sync(); 567 + wmb(); /* drain writebuffer */ 568 568 if ((stat & PSC_SPISTAT_DI) == 0) { 569 569 dev_err(hw->dev, "Unexpected IRQ!\n"); 570 570 return IRQ_NONE; ··· 594 594 do { 595 595 busy = 0; 596 596 stat = hw->regs->psc_spistat; 597 - au_sync(); 597 + wmb(); /* drain writebuffer */ 598 598 599 599 /* 600 600 * Take care to not let the Rx FIFO overflow. ··· 615 615 } while (busy); 616 616 617 617 hw->regs->psc_spievent = PSC_SPIEVNT_RR | PSC_SPIEVNT_TR; 618 - au_sync(); 618 + wmb(); /* drain writebuffer */ 619 619 620 620 /* 621 621 * Restart the SPI transmission in case of a transmit underflow. ··· 634 634 */ 635 635 if (evnt & PSC_SPIEVNT_TU) { 636 636 hw->regs->psc_spievent = PSC_SPIEVNT_TU | PSC_SPIEVNT_MD; 637 - au_sync(); 637 + wmb(); /* drain writebuffer */ 638 638 hw->regs->psc_spipcr = PSC_SPIPCR_MS; 639 - au_sync(); 639 + wmb(); /* drain writebuffer */ 640 640 } 641 641 642 642 if (hw->rx_count >= hw->len) { ··· 690 690 691 691 /* set up the PSC for SPI mode */ 692 692 hw->regs->psc_ctrl = PSC_CTRL_DISABLE; 693 - au_sync(); 693 + wmb(); /* drain writebuffer */ 694 694 hw->regs->psc_sel = PSC_SEL_PS_SPIMODE; 695 - au_sync(); 695 + wmb(); /* drain writebuffer */ 696 696 697 697 hw->regs->psc_spicfg = 0; 698 - au_sync(); 698 + wmb(); /* drain writebuffer */ 699 699 700 700 hw->regs->psc_ctrl = PSC_CTRL_ENABLE; 701 - au_sync(); 701 + wmb(); /* drain writebuffer */ 702 702 703 703 do { 704 704 stat = hw->regs->psc_spistat; 705 - au_sync(); 705 + wmb(); /* drain writebuffer */ 706 706 } while ((stat & PSC_SPISTAT_SR) == 0); 707 707 708 708 ··· 717 717 #endif 718 718 719 719 hw->regs->psc_spicfg = cfg; 720 - au_sync(); 720 + wmb(); /* drain writebuffer */ 721 721 722 722 au1550_spi_mask_ack_all(hw); 723 723 724 724 hw->regs->psc_spicfg |= PSC_SPICFG_DE_ENABLE; 725 - au_sync(); 725 + wmb(); /* drain writebuffer */ 726 726 727 727 do { 728 728 stat = hw->regs->psc_spistat; 729 - au_sync(); 729 + wmb(); /* drain writebuffer */ 730 730 } while ((stat & PSC_SPISTAT_DR) == 0); 731 731 732 732 au1550_spi_reset_fifos(hw);
+24 -15
drivers/video/fbdev/au1100fb.c
··· 41 41 * with this program; if not, write to the Free Software Foundation, Inc., 42 42 * 675 Mass Ave, Cambridge, MA 02139, USA. 43 43 */ 44 + #include <linux/clk.h> 44 45 #include <linux/module.h> 45 46 #include <linux/kernel.h> 46 47 #include <linux/errno.h> ··· 114 113 case VESA_NO_BLANKING: 115 114 /* Turn on panel */ 116 115 fbdev->regs->lcd_control |= LCD_CONTROL_GO; 117 - au_sync(); 116 + wmb(); /* drain writebuffer */ 118 117 break; 119 118 120 119 case VESA_VSYNC_SUSPEND: ··· 122 121 case VESA_POWERDOWN: 123 122 /* Turn off panel */ 124 123 fbdev->regs->lcd_control &= ~LCD_CONTROL_GO; 125 - au_sync(); 124 + wmb(); /* drain writebuffer */ 126 125 break; 127 126 default: 128 127 break; ··· 435 434 struct au1100fb_device *fbdev = NULL; 436 435 struct resource *regs_res; 437 436 unsigned long page; 438 - u32 sys_clksrc; 437 + struct clk *c; 439 438 440 439 /* Allocate new device private */ 441 440 fbdev = devm_kzalloc(&dev->dev, sizeof(struct au1100fb_device), ··· 474 473 print_dbg("Register memory map at %p", fbdev->regs); 475 474 print_dbg("phys=0x%08x, size=%d", fbdev->regs_phys, fbdev->regs_len); 476 475 476 + c = clk_get(NULL, "lcd_intclk"); 477 + if (!IS_ERR(c)) { 478 + fbdev->lcdclk = c; 479 + clk_set_rate(c, 48000000); 480 + clk_prepare_enable(c); 481 + } 482 + 477 483 /* Allocate the framebuffer to the maximum screen size * nbr of video buffers */ 478 484 fbdev->fb_len = fbdev->panel->xres * fbdev->panel->yres * 479 485 (fbdev->panel->bpp >> 3) * AU1100FB_NBR_VIDEO_BUFFERS; ··· 513 505 514 506 print_dbg("Framebuffer memory map at %p", fbdev->fb_mem); 515 507 print_dbg("phys=0x%08x, size=%dK", fbdev->fb_phys, fbdev->fb_len / 1024); 516 - 517 - /* Setup LCD clock to AUX (48 MHz) */ 518 - sys_clksrc = au_readl(SYS_CLKSRC) & ~(SYS_CS_ML_MASK | SYS_CS_DL | SYS_CS_CL); 519 - au_writel((sys_clksrc | (1 << SYS_CS_ML_BIT)), SYS_CLKSRC); 520 508 521 509 /* load the panel info into the var struct */ 522 510 au1100fb_var.bits_per_pixel = fbdev->panel->bpp; ··· 550 546 return 0; 551 547 552 548 failed: 549 + if (fbdev->lcdclk) { 550 + clk_disable_unprepare(fbdev->lcdclk); 551 + clk_put(fbdev->lcdclk); 552 + } 553 553 if (fbdev->fb_mem) { 554 554 dma_free_noncoherent(&dev->dev, fbdev->fb_len, fbdev->fb_mem, 555 555 fbdev->fb_phys); ··· 584 576 585 577 fb_dealloc_cmap(&fbdev->info.cmap); 586 578 579 + if (fbdev->lcdclk) { 580 + clk_disable_unprepare(fbdev->lcdclk); 581 + clk_put(fbdev->lcdclk); 582 + } 583 + 587 584 return 0; 588 585 } 589 586 590 587 #ifdef CONFIG_PM 591 - static u32 sys_clksrc; 592 588 static struct au1100fb_regs fbregs; 593 589 594 590 int au1100fb_drv_suspend(struct platform_device *dev, pm_message_t state) ··· 602 590 if (!fbdev) 603 591 return 0; 604 592 605 - /* Save the clock source state */ 606 - sys_clksrc = au_readl(SYS_CLKSRC); 607 - 608 593 /* Blank the LCD */ 609 594 au1100fb_fb_blank(VESA_POWERDOWN, &fbdev->info); 610 595 611 - /* Stop LCD clocking */ 612 - au_writel(sys_clksrc & ~SYS_CS_ML_MASK, SYS_CLKSRC); 596 + if (fbdev->lcdclk) 597 + clk_disable(fbdev->lcdclk); 613 598 614 599 memcpy(&fbregs, fbdev->regs, sizeof(struct au1100fb_regs)); 615 600 ··· 622 613 623 614 memcpy(fbdev->regs, &fbregs, sizeof(struct au1100fb_regs)); 624 615 625 - /* Restart LCD clocking */ 626 - au_writel(sys_clksrc, SYS_CLKSRC); 616 + if (fbdev->lcdclk) 617 + clk_enable(fbdev->lcdclk); 627 618 628 619 /* Unblank the LCD */ 629 620 au1100fb_fb_blank(VESA_NO_BLANKING, &fbdev->info);
+1
drivers/video/fbdev/au1100fb.h
··· 109 109 size_t fb_len; 110 110 dma_addr_t fb_phys; 111 111 int panel_idx; 112 + struct clk *lcdclk; 112 113 }; 113 114 114 115 /********************************************************************/
+38 -43
drivers/video/fbdev/au1200fb.c
··· 30 30 * 675 Mass Ave, Cambridge, MA 02139, USA. 31 31 */ 32 32 33 + #include <linux/clk.h> 33 34 #include <linux/module.h> 34 35 #include <linux/platform_device.h> 35 36 #include <linux/kernel.h> ··· 331 330 uint32 mode_pwmhi; 332 331 uint32 mode_outmask; 333 332 uint32 mode_fifoctrl; 334 - uint32 mode_toyclksrc; 335 333 uint32 mode_backlight; 336 - uint32 mode_auxpll; 334 + uint32 lcdclk; 337 335 #define Xres min_xres 338 336 #define Yres min_yres 339 337 u32 min_xres; /* Minimum horizontal resolution */ ··· 379 379 .mode_pwmhi = 0x00000000, 380 380 .mode_outmask = 0x00FFFFFF, 381 381 .mode_fifoctrl = 0x2f2f2f2f, 382 - .mode_toyclksrc = 0x00000004, /* AUXPLL directly */ 383 382 .mode_backlight = 0x00000000, 384 - .mode_auxpll = 8, /* 96MHz AUXPLL */ 383 + .lcdclk = 96, 385 384 320, 320, 386 385 240, 240, 387 386 }, ··· 406 407 .mode_pwmhi = 0x00000000, 407 408 .mode_outmask = 0x00FFFFFF, 408 409 .mode_fifoctrl = 0x2f2f2f2f, 409 - .mode_toyclksrc = 0x00000004, /* AUXPLL directly */ 410 410 .mode_backlight = 0x00000000, 411 - .mode_auxpll = 8, /* 96MHz AUXPLL */ 411 + .lcdclk = 96, 412 412 640, 480, 413 413 640, 480, 414 414 }, ··· 433 435 .mode_pwmhi = 0x00000000, 434 436 .mode_outmask = 0x00FFFFFF, 435 437 .mode_fifoctrl = 0x2f2f2f2f, 436 - .mode_toyclksrc = 0x00000004, /* AUXPLL directly */ 437 438 .mode_backlight = 0x00000000, 438 - .mode_auxpll = 8, /* 96MHz AUXPLL */ 439 + .lcdclk = 96, 439 440 800, 800, 440 441 600, 600, 441 442 }, ··· 460 463 .mode_pwmhi = 0x00000000, 461 464 .mode_outmask = 0x00FFFFFF, 462 465 .mode_fifoctrl = 0x2f2f2f2f, 463 - .mode_toyclksrc = 0x00000004, /* AUXPLL directly */ 464 466 .mode_backlight = 0x00000000, 465 - .mode_auxpll = 6, /* 72MHz AUXPLL */ 467 + .lcdclk = 72, 466 468 1024, 1024, 467 469 768, 768, 468 470 }, ··· 487 491 .mode_pwmhi = 0x00000000, 488 492 .mode_outmask = 0x00FFFFFF, 489 493 .mode_fifoctrl = 0x2f2f2f2f, 490 - .mode_toyclksrc = 0x00000004, /* AUXPLL directly */ 491 494 .mode_backlight = 0x00000000, 492 - .mode_auxpll = 10, /* 120MHz AUXPLL */ 495 + .lcdclk = 120, 493 496 1280, 1280, 494 497 1024, 1024, 495 498 }, ··· 514 519 .mode_pwmhi = 0x03400000, /* SCB 0x0 */ 515 520 .mode_outmask = 0x00FFFFFF, 516 521 .mode_fifoctrl = 0x2f2f2f2f, 517 - .mode_toyclksrc = 0x00000004, /* AUXPLL directly */ 518 522 .mode_backlight = 0x00000000, 519 - .mode_auxpll = 8, /* 96MHz AUXPLL */ 523 + .lcdclk = 96, 520 524 1024, 1024, 521 525 768, 768, 522 526 }, ··· 544 550 .mode_pwmhi = 0x03400000, 545 551 .mode_outmask = 0x00fcfcfc, 546 552 .mode_fifoctrl = 0x2f2f2f2f, 547 - .mode_toyclksrc = 0x00000004, /* AUXPLL directly */ 548 553 .mode_backlight = 0x00000000, 549 - .mode_auxpll = 8, /* 96MHz AUXPLL */ 554 + .lcdclk = 96, 550 555 640, 480, 551 556 640, 480, 552 557 }, ··· 574 581 .mode_pwmhi = 0x03400000, 575 582 .mode_outmask = 0x00fcfcfc, 576 583 .mode_fifoctrl = 0x2f2f2f2f, 577 - .mode_toyclksrc = 0x00000004, /* AUXPLL directly */ 578 584 .mode_backlight = 0x00000000, 579 - .mode_auxpll = 8, /* 96MHz AUXPLL */ 585 + .lcdclk = 96, /* 96MHz AUXPLL */ 580 586 320, 320, 581 587 240, 240, 582 588 }, ··· 604 612 .mode_pwmhi = 0x03400000, 605 613 .mode_outmask = 0x00fcfcfc, 606 614 .mode_fifoctrl = 0x2f2f2f2f, 607 - .mode_toyclksrc = 0x00000004, /* AUXPLL directly */ 608 615 .mode_backlight = 0x00000000, 609 - .mode_auxpll = 8, /* 96MHz AUXPLL */ 616 + .lcdclk = 96, 610 617 856, 856, 611 618 480, 480, 612 619 }, ··· 637 646 .mode_pwmhi = 0x00000000, 638 647 .mode_outmask = 0x00FFFFFF, 639 648 .mode_fifoctrl = 0x2f2f2f2f, 640 - .mode_toyclksrc = 0x00000004, /* AUXPLL directly */ 641 649 .mode_backlight = 0x00000000, 642 - .mode_auxpll = (48/12) * 2, 650 + .lcdclk = 96, 643 651 800, 800, 644 652 480, 480, 645 653 }, ··· 754 764 755 765 /* Disable the window while making changes, then restore WINEN */ 756 766 winenable = lcd->winenable & (1 << plane); 757 - au_sync(); 767 + wmb(); /* drain writebuffer */ 758 768 lcd->winenable &= ~(1 << plane); 759 769 lcd->window[plane].winctrl0 = winctrl0; 760 770 lcd->window[plane].winctrl1 = winctrl1; ··· 762 772 lcd->window[plane].winbuf1 = fbdev->fb_phys; 763 773 lcd->window[plane].winbufctrl = 0; /* select winbuf0 */ 764 774 lcd->winenable |= winenable; 765 - au_sync(); 775 + wmb(); /* drain writebuffer */ 766 776 767 777 return 0; 768 778 } ··· 778 788 /* Make sure all windows disabled */ 779 789 winenable = lcd->winenable; 780 790 lcd->winenable = 0; 781 - au_sync(); 791 + wmb(); /* drain writebuffer */ 782 792 /* 783 793 * Ensure everything is disabled before reconfiguring 784 794 */ 785 795 if (lcd->screen & LCD_SCREEN_SEN) { 786 796 /* Wait for vertical sync period */ 787 797 lcd->intstatus = LCD_INT_SS; 788 - while ((lcd->intstatus & LCD_INT_SS) == 0) { 789 - au_sync(); 790 - } 798 + while ((lcd->intstatus & LCD_INT_SS) == 0) 799 + ; 791 800 792 801 lcd->screen &= ~LCD_SCREEN_SEN; /*disable the controller*/ 793 802 794 803 do { 795 804 lcd->intstatus = lcd->intstatus; /*clear interrupts*/ 796 - au_sync(); 805 + wmb(); /* drain writebuffer */ 797 806 /*wait for controller to shut down*/ 798 807 } while ((lcd->intstatus & LCD_INT_SD) == 0); 799 808 ··· 818 829 */ 819 830 if (!(panel->mode_clkcontrol & LCD_CLKCONTROL_EXT)) 820 831 { 821 - uint32 sys_clksrc; 822 - au_writel(panel->mode_auxpll, SYS_AUXPLL); 823 - sys_clksrc = au_readl(SYS_CLKSRC) & ~0x0000001f; 824 - sys_clksrc |= panel->mode_toyclksrc; 825 - au_writel(sys_clksrc, SYS_CLKSRC); 832 + struct clk *c = clk_get(NULL, "lcd_intclk"); 833 + long r, pc = panel->lcdclk * 1000000; 834 + 835 + if (!IS_ERR(c)) { 836 + r = clk_round_rate(c, pc); 837 + if ((pc - r) < (pc / 10)) { /* 10% slack */ 838 + clk_set_rate(c, r); 839 + clk_prepare_enable(c); 840 + } 841 + clk_put(c); 842 + } 826 843 } 827 844 828 845 /* ··· 842 847 lcd->pwmhi = panel->mode_pwmhi; 843 848 lcd->outmask = panel->mode_outmask; 844 849 lcd->fifoctrl = panel->mode_fifoctrl; 845 - au_sync(); 850 + wmb(); /* drain writebuffer */ 846 851 847 852 /* fixme: Check window settings to make sure still valid 848 853 * for new geometry */ ··· 858 863 * Re-enable screen now that it is configured 859 864 */ 860 865 lcd->screen |= LCD_SCREEN_SEN; 861 - au_sync(); 866 + wmb(); /* drain writebuffer */ 862 867 863 868 /* Call init of panel */ 864 869 if (pd->panel_init) ··· 951 956 | LCD_WINCTRL2_SCY_1 952 957 ) ; 953 958 lcd->winenable |= win->w[plane].mode_winenable; 954 - au_sync(); 959 + wmb(); /* drain writebuffer */ 955 960 } 956 961 957 962 ··· 1265 1270 1266 1271 if (pdata->flags & SCREEN_MASK) 1267 1272 lcd->colorkeymsk = pdata->mask; 1268 - au_sync(); 1273 + wmb(); /* drain writebuffer */ 1269 1274 } 1270 1275 1271 1276 static void get_global(u_int cmd, struct au1200_lcd_global_regs_t *pdata) ··· 1283 1288 hi1 = (lcd->pwmhi >> 16) + 1; 1284 1289 divider = (lcd->pwmdiv & 0x3FFFF) + 1; 1285 1290 pdata->brightness = ((hi1 << 8) / divider) - 1; 1286 - au_sync(); 1291 + wmb(); /* drain writebuffer */ 1287 1292 } 1288 1293 1289 1294 static void set_window(unsigned int plane, ··· 1382 1387 val |= (pdata->enable & 1) << plane; 1383 1388 lcd->winenable = val; 1384 1389 } 1385 - au_sync(); 1390 + wmb(); /* drain writebuffer */ 1386 1391 } 1387 1392 1388 1393 static void get_window(unsigned int plane, ··· 1409 1414 pdata->ram_array_mode = (lcd->window[plane].winctrl2 & LCD_WINCTRL2_RAM) >> 21; 1410 1415 1411 1416 pdata->enable = (lcd->winenable >> plane) & 1; 1412 - au_sync(); 1417 + wmb(); /* drain writebuffer */ 1413 1418 } 1414 1419 1415 1420 static int au1200fb_ioctl(struct fb_info *info, unsigned int cmd, ··· 1506 1511 { 1507 1512 /* Nothing to do for now, just clear any pending interrupt */ 1508 1513 lcd->intstatus = lcd->intstatus; 1509 - au_sync(); 1514 + wmb(); /* drain writebuffer */ 1510 1515 1511 1516 return IRQ_HANDLED; 1512 1517 } ··· 1804 1809 au1200_setpanel(NULL, pd); 1805 1810 1806 1811 lcd->outmask = 0; 1807 - au_sync(); 1812 + wmb(); /* drain writebuffer */ 1808 1813 1809 1814 return 0; 1810 1815 }
+34 -28
drivers/watchdog/octeon-wdt-main.c
··· 145 145 146 146 uasm_i_mfc0(&p, K0, C0_STATUS); 147 147 #ifdef CONFIG_HOTPLUG_CPU 148 - uasm_il_bbit0(&p, &r, K0, ilog2(ST0_NMI), label_enter_bootloader); 148 + if (octeon_bootloader_entry_addr) 149 + uasm_il_bbit0(&p, &r, K0, ilog2(ST0_NMI), 150 + label_enter_bootloader); 149 151 #endif 150 152 /* Force 64-bit addressing enabled */ 151 153 uasm_i_ori(&p, K0, K0, ST0_UX | ST0_SX | ST0_KX); 152 154 uasm_i_mtc0(&p, K0, C0_STATUS); 153 155 154 156 #ifdef CONFIG_HOTPLUG_CPU 155 - uasm_i_mfc0(&p, K0, C0_EBASE); 156 - /* Coreid number in K0 */ 157 - uasm_i_andi(&p, K0, K0, 0xf); 158 - /* 8 * coreid in bits 16-31 */ 159 - uasm_i_dsll_safe(&p, K0, K0, 3 + 16); 160 - uasm_i_ori(&p, K0, K0, 0x8001); 161 - uasm_i_dsll_safe(&p, K0, K0, 16); 162 - uasm_i_ori(&p, K0, K0, 0x0700); 163 - uasm_i_drotr_safe(&p, K0, K0, 32); 164 - /* 165 - * Should result in: 0x8001,0700,0000,8*coreid which is 166 - * CVMX_CIU_WDOGX(coreid) - 0x0500 167 - * 168 - * Now ld K0, CVMX_CIU_WDOGX(coreid) 169 - */ 170 - uasm_i_ld(&p, K0, 0x500, K0); 171 - /* 172 - * If bit one set handle the NMI as a watchdog event. 173 - * otherwise transfer control to bootloader. 174 - */ 175 - uasm_il_bbit0(&p, &r, K0, 1, label_enter_bootloader); 176 - uasm_i_nop(&p); 157 + if (octeon_bootloader_entry_addr) { 158 + uasm_i_mfc0(&p, K0, C0_EBASE); 159 + /* Coreid number in K0 */ 160 + uasm_i_andi(&p, K0, K0, 0xf); 161 + /* 8 * coreid in bits 16-31 */ 162 + uasm_i_dsll_safe(&p, K0, K0, 3 + 16); 163 + uasm_i_ori(&p, K0, K0, 0x8001); 164 + uasm_i_dsll_safe(&p, K0, K0, 16); 165 + uasm_i_ori(&p, K0, K0, 0x0700); 166 + uasm_i_drotr_safe(&p, K0, K0, 32); 167 + /* 168 + * Should result in: 0x8001,0700,0000,8*coreid which is 169 + * CVMX_CIU_WDOGX(coreid) - 0x0500 170 + * 171 + * Now ld K0, CVMX_CIU_WDOGX(coreid) 172 + */ 173 + uasm_i_ld(&p, K0, 0x500, K0); 174 + /* 175 + * If bit one set handle the NMI as a watchdog event. 176 + * otherwise transfer control to bootloader. 177 + */ 178 + uasm_il_bbit0(&p, &r, K0, 1, label_enter_bootloader); 179 + uasm_i_nop(&p); 180 + } 177 181 #endif 178 182 179 183 /* Clear Dcache so cvmseg works right. */ ··· 198 194 uasm_i_dmfc0(&p, K0, C0_DESAVE); 199 195 200 196 #ifdef CONFIG_HOTPLUG_CPU 201 - uasm_build_label(&l, p, label_enter_bootloader); 202 - /* Jump to the bootloader and restore K0 */ 203 - UASM_i_LA(&p, K0, (long)octeon_bootloader_entry_addr); 204 - uasm_i_jr(&p, K0); 205 - uasm_i_dmfc0(&p, K0, C0_DESAVE); 197 + if (octeon_bootloader_entry_addr) { 198 + uasm_build_label(&l, p, label_enter_bootloader); 199 + /* Jump to the bootloader and restore K0 */ 200 + UASM_i_LA(&p, K0, (long)octeon_bootloader_entry_addr); 201 + uasm_i_jr(&p, K0); 202 + uasm_i_dmfc0(&p, K0, C0_DESAVE); 203 + } 206 204 #endif 207 205 uasm_resolve_relocs(relocs, labels); 208 206
+70 -70
sound/soc/au1x/psc-ac97.c
··· 79 79 unsigned short retry, tmo; 80 80 unsigned long data; 81 81 82 - au_writel(PSC_AC97EVNT_CD, AC97_EVNT(pscdata)); 83 - au_sync(); 82 + __raw_writel(PSC_AC97EVNT_CD, AC97_EVNT(pscdata)); 83 + wmb(); /* drain writebuffer */ 84 84 85 85 retry = AC97_RW_RETRIES; 86 86 do { 87 87 mutex_lock(&pscdata->lock); 88 88 89 - au_writel(PSC_AC97CDC_RD | PSC_AC97CDC_INDX(reg), 89 + __raw_writel(PSC_AC97CDC_RD | PSC_AC97CDC_INDX(reg), 90 90 AC97_CDC(pscdata)); 91 - au_sync(); 91 + wmb(); /* drain writebuffer */ 92 92 93 93 tmo = 20; 94 94 do { 95 95 udelay(21); 96 - if (au_readl(AC97_EVNT(pscdata)) & PSC_AC97EVNT_CD) 96 + if (__raw_readl(AC97_EVNT(pscdata)) & PSC_AC97EVNT_CD) 97 97 break; 98 98 } while (--tmo); 99 99 100 - data = au_readl(AC97_CDC(pscdata)); 100 + data = __raw_readl(AC97_CDC(pscdata)); 101 101 102 - au_writel(PSC_AC97EVNT_CD, AC97_EVNT(pscdata)); 103 - au_sync(); 102 + __raw_writel(PSC_AC97EVNT_CD, AC97_EVNT(pscdata)); 103 + wmb(); /* drain writebuffer */ 104 104 105 105 mutex_unlock(&pscdata->lock); 106 106 ··· 119 119 struct au1xpsc_audio_data *pscdata = ac97_to_pscdata(ac97); 120 120 unsigned int tmo, retry; 121 121 122 - au_writel(PSC_AC97EVNT_CD, AC97_EVNT(pscdata)); 123 - au_sync(); 122 + __raw_writel(PSC_AC97EVNT_CD, AC97_EVNT(pscdata)); 123 + wmb(); /* drain writebuffer */ 124 124 125 125 retry = AC97_RW_RETRIES; 126 126 do { 127 127 mutex_lock(&pscdata->lock); 128 128 129 - au_writel(PSC_AC97CDC_INDX(reg) | (val & 0xffff), 129 + __raw_writel(PSC_AC97CDC_INDX(reg) | (val & 0xffff), 130 130 AC97_CDC(pscdata)); 131 - au_sync(); 131 + wmb(); /* drain writebuffer */ 132 132 133 133 tmo = 20; 134 134 do { 135 135 udelay(21); 136 - if (au_readl(AC97_EVNT(pscdata)) & PSC_AC97EVNT_CD) 136 + if (__raw_readl(AC97_EVNT(pscdata)) & PSC_AC97EVNT_CD) 137 137 break; 138 138 } while (--tmo); 139 139 140 - au_writel(PSC_AC97EVNT_CD, AC97_EVNT(pscdata)); 141 - au_sync(); 140 + __raw_writel(PSC_AC97EVNT_CD, AC97_EVNT(pscdata)); 141 + wmb(); /* drain writebuffer */ 142 142 143 143 mutex_unlock(&pscdata->lock); 144 144 } while (--retry && !tmo); ··· 149 149 { 150 150 struct au1xpsc_audio_data *pscdata = ac97_to_pscdata(ac97); 151 151 152 - au_writel(PSC_AC97RST_SNC, AC97_RST(pscdata)); 153 - au_sync(); 152 + __raw_writel(PSC_AC97RST_SNC, AC97_RST(pscdata)); 153 + wmb(); /* drain writebuffer */ 154 154 msleep(10); 155 - au_writel(0, AC97_RST(pscdata)); 156 - au_sync(); 155 + __raw_writel(0, AC97_RST(pscdata)); 156 + wmb(); /* drain writebuffer */ 157 157 } 158 158 159 159 static void au1xpsc_ac97_cold_reset(struct snd_ac97 *ac97) ··· 162 162 int i; 163 163 164 164 /* disable PSC during cold reset */ 165 - au_writel(0, AC97_CFG(au1xpsc_ac97_workdata)); 166 - au_sync(); 167 - au_writel(PSC_CTRL_DISABLE, PSC_CTRL(pscdata)); 168 - au_sync(); 165 + __raw_writel(0, AC97_CFG(au1xpsc_ac97_workdata)); 166 + wmb(); /* drain writebuffer */ 167 + __raw_writel(PSC_CTRL_DISABLE, PSC_CTRL(pscdata)); 168 + wmb(); /* drain writebuffer */ 169 169 170 170 /* issue cold reset */ 171 - au_writel(PSC_AC97RST_RST, AC97_RST(pscdata)); 172 - au_sync(); 171 + __raw_writel(PSC_AC97RST_RST, AC97_RST(pscdata)); 172 + wmb(); /* drain writebuffer */ 173 173 msleep(500); 174 - au_writel(0, AC97_RST(pscdata)); 175 - au_sync(); 174 + __raw_writel(0, AC97_RST(pscdata)); 175 + wmb(); /* drain writebuffer */ 176 176 177 177 /* enable PSC */ 178 - au_writel(PSC_CTRL_ENABLE, PSC_CTRL(pscdata)); 179 - au_sync(); 178 + __raw_writel(PSC_CTRL_ENABLE, PSC_CTRL(pscdata)); 179 + wmb(); /* drain writebuffer */ 180 180 181 181 /* wait for PSC to indicate it's ready */ 182 182 i = 1000; 183 - while (!((au_readl(AC97_STAT(pscdata)) & PSC_AC97STAT_SR)) && (--i)) 183 + while (!((__raw_readl(AC97_STAT(pscdata)) & PSC_AC97STAT_SR)) && (--i)) 184 184 msleep(1); 185 185 186 186 if (i == 0) { ··· 189 189 } 190 190 191 191 /* enable the ac97 function */ 192 - au_writel(pscdata->cfg | PSC_AC97CFG_DE_ENABLE, AC97_CFG(pscdata)); 193 - au_sync(); 192 + __raw_writel(pscdata->cfg | PSC_AC97CFG_DE_ENABLE, AC97_CFG(pscdata)); 193 + wmb(); /* drain writebuffer */ 194 194 195 195 /* wait for AC97 core to become ready */ 196 196 i = 1000; 197 - while (!((au_readl(AC97_STAT(pscdata)) & PSC_AC97STAT_DR)) && (--i)) 197 + while (!((__raw_readl(AC97_STAT(pscdata)) & PSC_AC97STAT_DR)) && (--i)) 198 198 msleep(1); 199 199 if (i == 0) 200 200 printk(KERN_ERR "au1xpsc-ac97: AC97 ctrl not ready\n"); ··· 218 218 219 219 chans = params_channels(params); 220 220 221 - r = ro = au_readl(AC97_CFG(pscdata)); 222 - stat = au_readl(AC97_STAT(pscdata)); 221 + r = ro = __raw_readl(AC97_CFG(pscdata)); 222 + stat = __raw_readl(AC97_STAT(pscdata)); 223 223 224 224 /* already active? */ 225 225 if (stat & (PSC_AC97STAT_TB | PSC_AC97STAT_RB)) { ··· 252 252 mutex_lock(&pscdata->lock); 253 253 254 254 /* disable AC97 device controller first... */ 255 - au_writel(r & ~PSC_AC97CFG_DE_ENABLE, AC97_CFG(pscdata)); 256 - au_sync(); 255 + __raw_writel(r & ~PSC_AC97CFG_DE_ENABLE, AC97_CFG(pscdata)); 256 + wmb(); /* drain writebuffer */ 257 257 258 258 /* ...wait for it... */ 259 259 t = 100; 260 - while ((au_readl(AC97_STAT(pscdata)) & PSC_AC97STAT_DR) && --t) 260 + while ((__raw_readl(AC97_STAT(pscdata)) & PSC_AC97STAT_DR) && --t) 261 261 msleep(1); 262 262 263 263 if (!t) 264 264 printk(KERN_ERR "PSC-AC97: can't disable!\n"); 265 265 266 266 /* ...write config... */ 267 - au_writel(r, AC97_CFG(pscdata)); 268 - au_sync(); 267 + __raw_writel(r, AC97_CFG(pscdata)); 268 + wmb(); /* drain writebuffer */ 269 269 270 270 /* ...enable the AC97 controller again... */ 271 - au_writel(r | PSC_AC97CFG_DE_ENABLE, AC97_CFG(pscdata)); 272 - au_sync(); 271 + __raw_writel(r | PSC_AC97CFG_DE_ENABLE, AC97_CFG(pscdata)); 272 + wmb(); /* drain writebuffer */ 273 273 274 274 /* ...and wait for ready bit */ 275 275 t = 100; 276 - while ((!(au_readl(AC97_STAT(pscdata)) & PSC_AC97STAT_DR)) && --t) 276 + while ((!(__raw_readl(AC97_STAT(pscdata)) & PSC_AC97STAT_DR)) && --t) 277 277 msleep(1); 278 278 279 279 if (!t) ··· 300 300 switch (cmd) { 301 301 case SNDRV_PCM_TRIGGER_START: 302 302 case SNDRV_PCM_TRIGGER_RESUME: 303 - au_writel(AC97PCR_CLRFIFO(stype), AC97_PCR(pscdata)); 304 - au_sync(); 305 - au_writel(AC97PCR_START(stype), AC97_PCR(pscdata)); 306 - au_sync(); 303 + __raw_writel(AC97PCR_CLRFIFO(stype), AC97_PCR(pscdata)); 304 + wmb(); /* drain writebuffer */ 305 + __raw_writel(AC97PCR_START(stype), AC97_PCR(pscdata)); 306 + wmb(); /* drain writebuffer */ 307 307 break; 308 308 case SNDRV_PCM_TRIGGER_STOP: 309 309 case SNDRV_PCM_TRIGGER_SUSPEND: 310 - au_writel(AC97PCR_STOP(stype), AC97_PCR(pscdata)); 311 - au_sync(); 310 + __raw_writel(AC97PCR_STOP(stype), AC97_PCR(pscdata)); 311 + wmb(); /* drain writebuffer */ 312 312 313 - while (au_readl(AC97_STAT(pscdata)) & AC97STAT_BUSY(stype)) 313 + while (__raw_readl(AC97_STAT(pscdata)) & AC97STAT_BUSY(stype)) 314 314 asm volatile ("nop"); 315 315 316 - au_writel(AC97PCR_CLRFIFO(stype), AC97_PCR(pscdata)); 317 - au_sync(); 316 + __raw_writel(AC97PCR_CLRFIFO(stype), AC97_PCR(pscdata)); 317 + wmb(); /* drain writebuffer */ 318 318 319 319 break; 320 320 default: ··· 398 398 PSC_AC97CFG_DE_ENABLE; 399 399 400 400 /* preserve PSC clock source set up by platform */ 401 - sel = au_readl(PSC_SEL(wd)) & PSC_SEL_CLK_MASK; 402 - au_writel(PSC_CTRL_DISABLE, PSC_CTRL(wd)); 403 - au_sync(); 404 - au_writel(0, PSC_SEL(wd)); 405 - au_sync(); 406 - au_writel(PSC_SEL_PS_AC97MODE | sel, PSC_SEL(wd)); 407 - au_sync(); 401 + sel = __raw_readl(PSC_SEL(wd)) & PSC_SEL_CLK_MASK; 402 + __raw_writel(PSC_CTRL_DISABLE, PSC_CTRL(wd)); 403 + wmb(); /* drain writebuffer */ 404 + __raw_writel(0, PSC_SEL(wd)); 405 + wmb(); /* drain writebuffer */ 406 + __raw_writel(PSC_SEL_PS_AC97MODE | sel, PSC_SEL(wd)); 407 + wmb(); /* drain writebuffer */ 408 408 409 409 /* name the DAI like this device instance ("au1xpsc-ac97.PSCINDEX") */ 410 410 memcpy(&wd->dai_drv, &au1xpsc_ac97_dai_template, ··· 433 433 snd_soc_unregister_component(&pdev->dev); 434 434 435 435 /* disable PSC completely */ 436 - au_writel(0, AC97_CFG(wd)); 437 - au_sync(); 438 - au_writel(PSC_CTRL_DISABLE, PSC_CTRL(wd)); 439 - au_sync(); 436 + __raw_writel(0, AC97_CFG(wd)); 437 + wmb(); /* drain writebuffer */ 438 + __raw_writel(PSC_CTRL_DISABLE, PSC_CTRL(wd)); 439 + wmb(); /* drain writebuffer */ 440 440 441 441 au1xpsc_ac97_workdata = NULL; /* MDEV */ 442 442 ··· 449 449 struct au1xpsc_audio_data *wd = dev_get_drvdata(dev); 450 450 451 451 /* save interesting registers and disable PSC */ 452 - wd->pm[0] = au_readl(PSC_SEL(wd)); 452 + wd->pm[0] = __raw_readl(PSC_SEL(wd)); 453 453 454 - au_writel(0, AC97_CFG(wd)); 455 - au_sync(); 456 - au_writel(PSC_CTRL_DISABLE, PSC_CTRL(wd)); 457 - au_sync(); 454 + __raw_writel(0, AC97_CFG(wd)); 455 + wmb(); /* drain writebuffer */ 456 + __raw_writel(PSC_CTRL_DISABLE, PSC_CTRL(wd)); 457 + wmb(); /* drain writebuffer */ 458 458 459 459 return 0; 460 460 } ··· 464 464 struct au1xpsc_audio_data *wd = dev_get_drvdata(dev); 465 465 466 466 /* restore PSC clock config */ 467 - au_writel(wd->pm[0] | PSC_SEL_PS_AC97MODE, PSC_SEL(wd)); 468 - au_sync(); 467 + __raw_writel(wd->pm[0] | PSC_SEL_PS_AC97MODE, PSC_SEL(wd)); 468 + wmb(); /* drain writebuffer */ 469 469 470 470 /* after this point the ac97 core will cold-reset the codec. 471 471 * During cold-reset the PSC is reinitialized and the last
+50 -50
sound/soc/au1x/psc-i2s.c
··· 120 120 unsigned long stat; 121 121 122 122 /* check if the PSC is already streaming data */ 123 - stat = au_readl(I2S_STAT(pscdata)); 123 + stat = __raw_readl(I2S_STAT(pscdata)); 124 124 if (stat & (PSC_I2SSTAT_TB | PSC_I2SSTAT_RB)) { 125 125 /* reject parameters not currently set up in hardware */ 126 - cfgbits = au_readl(I2S_CFG(pscdata)); 126 + cfgbits = __raw_readl(I2S_CFG(pscdata)); 127 127 if ((PSC_I2SCFG_GET_LEN(cfgbits) != params->msbits) || 128 128 (params_rate(params) != pscdata->rate)) 129 129 return -EINVAL; ··· 149 149 unsigned long tmo; 150 150 151 151 /* bring PSC out of sleep, and configure I2S unit */ 152 - au_writel(PSC_CTRL_ENABLE, PSC_CTRL(pscdata)); 153 - au_sync(); 152 + __raw_writel(PSC_CTRL_ENABLE, PSC_CTRL(pscdata)); 153 + wmb(); /* drain writebuffer */ 154 154 155 155 tmo = 1000000; 156 - while (!(au_readl(I2S_STAT(pscdata)) & PSC_I2SSTAT_SR) && tmo) 156 + while (!(__raw_readl(I2S_STAT(pscdata)) & PSC_I2SSTAT_SR) && tmo) 157 157 tmo--; 158 158 159 159 if (!tmo) 160 160 goto psc_err; 161 161 162 - au_writel(0, I2S_CFG(pscdata)); 163 - au_sync(); 164 - au_writel(pscdata->cfg | PSC_I2SCFG_DE_ENABLE, I2S_CFG(pscdata)); 165 - au_sync(); 162 + __raw_writel(0, I2S_CFG(pscdata)); 163 + wmb(); /* drain writebuffer */ 164 + __raw_writel(pscdata->cfg | PSC_I2SCFG_DE_ENABLE, I2S_CFG(pscdata)); 165 + wmb(); /* drain writebuffer */ 166 166 167 167 /* wait for I2S controller to become ready */ 168 168 tmo = 1000000; 169 - while (!(au_readl(I2S_STAT(pscdata)) & PSC_I2SSTAT_DR) && tmo) 169 + while (!(__raw_readl(I2S_STAT(pscdata)) & PSC_I2SSTAT_DR) && tmo) 170 170 tmo--; 171 171 172 172 if (tmo) 173 173 return 0; 174 174 175 175 psc_err: 176 - au_writel(0, I2S_CFG(pscdata)); 177 - au_writel(PSC_CTRL_SUSPEND, PSC_CTRL(pscdata)); 178 - au_sync(); 176 + __raw_writel(0, I2S_CFG(pscdata)); 177 + __raw_writel(PSC_CTRL_SUSPEND, PSC_CTRL(pscdata)); 178 + wmb(); /* drain writebuffer */ 179 179 return -ETIMEDOUT; 180 180 } 181 181 ··· 187 187 ret = 0; 188 188 189 189 /* if both TX and RX are idle, configure the PSC */ 190 - stat = au_readl(I2S_STAT(pscdata)); 190 + stat = __raw_readl(I2S_STAT(pscdata)); 191 191 if (!(stat & (PSC_I2SSTAT_TB | PSC_I2SSTAT_RB))) { 192 192 ret = au1xpsc_i2s_configure(pscdata); 193 193 if (ret) 194 194 goto out; 195 195 } 196 196 197 - au_writel(I2SPCR_CLRFIFO(stype), I2S_PCR(pscdata)); 198 - au_sync(); 199 - au_writel(I2SPCR_START(stype), I2S_PCR(pscdata)); 200 - au_sync(); 197 + __raw_writel(I2SPCR_CLRFIFO(stype), I2S_PCR(pscdata)); 198 + wmb(); /* drain writebuffer */ 199 + __raw_writel(I2SPCR_START(stype), I2S_PCR(pscdata)); 200 + wmb(); /* drain writebuffer */ 201 201 202 202 /* wait for start confirmation */ 203 203 tmo = 1000000; 204 - while (!(au_readl(I2S_STAT(pscdata)) & I2SSTAT_BUSY(stype)) && tmo) 204 + while (!(__raw_readl(I2S_STAT(pscdata)) & I2SSTAT_BUSY(stype)) && tmo) 205 205 tmo--; 206 206 207 207 if (!tmo) { 208 - au_writel(I2SPCR_STOP(stype), I2S_PCR(pscdata)); 209 - au_sync(); 208 + __raw_writel(I2SPCR_STOP(stype), I2S_PCR(pscdata)); 209 + wmb(); /* drain writebuffer */ 210 210 ret = -ETIMEDOUT; 211 211 } 212 212 out: ··· 217 217 { 218 218 unsigned long tmo, stat; 219 219 220 - au_writel(I2SPCR_STOP(stype), I2S_PCR(pscdata)); 221 - au_sync(); 220 + __raw_writel(I2SPCR_STOP(stype), I2S_PCR(pscdata)); 221 + wmb(); /* drain writebuffer */ 222 222 223 223 /* wait for stop confirmation */ 224 224 tmo = 1000000; 225 - while ((au_readl(I2S_STAT(pscdata)) & I2SSTAT_BUSY(stype)) && tmo) 225 + while ((__raw_readl(I2S_STAT(pscdata)) & I2SSTAT_BUSY(stype)) && tmo) 226 226 tmo--; 227 227 228 228 /* if both TX and RX are idle, disable PSC */ 229 - stat = au_readl(I2S_STAT(pscdata)); 229 + stat = __raw_readl(I2S_STAT(pscdata)); 230 230 if (!(stat & (PSC_I2SSTAT_TB | PSC_I2SSTAT_RB))) { 231 - au_writel(0, I2S_CFG(pscdata)); 232 - au_sync(); 233 - au_writel(PSC_CTRL_SUSPEND, PSC_CTRL(pscdata)); 234 - au_sync(); 231 + __raw_writel(0, I2S_CFG(pscdata)); 232 + wmb(); /* drain writebuffer */ 233 + __raw_writel(PSC_CTRL_SUSPEND, PSC_CTRL(pscdata)); 234 + wmb(); /* drain writebuffer */ 235 235 } 236 236 return 0; 237 237 } ··· 332 332 /* preserve PSC clock source set up by platform (dev.platform_data 333 333 * is already occupied by soc layer) 334 334 */ 335 - sel = au_readl(PSC_SEL(wd)) & PSC_SEL_CLK_MASK; 336 - au_writel(PSC_CTRL_DISABLE, PSC_CTRL(wd)); 337 - au_sync(); 338 - au_writel(PSC_SEL_PS_I2SMODE | sel, PSC_SEL(wd)); 339 - au_writel(0, I2S_CFG(wd)); 340 - au_sync(); 335 + sel = __raw_readl(PSC_SEL(wd)) & PSC_SEL_CLK_MASK; 336 + __raw_writel(PSC_CTRL_DISABLE, PSC_CTRL(wd)); 337 + wmb(); /* drain writebuffer */ 338 + __raw_writel(PSC_SEL_PS_I2SMODE | sel, PSC_SEL(wd)); 339 + __raw_writel(0, I2S_CFG(wd)); 340 + wmb(); /* drain writebuffer */ 341 341 342 342 /* preconfigure: set max rx/tx fifo depths */ 343 343 wd->cfg |= PSC_I2SCFG_RT_FIFO8 | PSC_I2SCFG_TT_FIFO8; ··· 364 364 365 365 snd_soc_unregister_component(&pdev->dev); 366 366 367 - au_writel(0, I2S_CFG(wd)); 368 - au_sync(); 369 - au_writel(PSC_CTRL_DISABLE, PSC_CTRL(wd)); 370 - au_sync(); 367 + __raw_writel(0, I2S_CFG(wd)); 368 + wmb(); /* drain writebuffer */ 369 + __raw_writel(PSC_CTRL_DISABLE, PSC_CTRL(wd)); 370 + wmb(); /* drain writebuffer */ 371 371 372 372 return 0; 373 373 } ··· 378 378 struct au1xpsc_audio_data *wd = dev_get_drvdata(dev); 379 379 380 380 /* save interesting register and disable PSC */ 381 - wd->pm[0] = au_readl(PSC_SEL(wd)); 381 + wd->pm[0] = __raw_readl(PSC_SEL(wd)); 382 382 383 - au_writel(0, I2S_CFG(wd)); 384 - au_sync(); 385 - au_writel(PSC_CTRL_DISABLE, PSC_CTRL(wd)); 386 - au_sync(); 383 + __raw_writel(0, I2S_CFG(wd)); 384 + wmb(); /* drain writebuffer */ 385 + __raw_writel(PSC_CTRL_DISABLE, PSC_CTRL(wd)); 386 + wmb(); /* drain writebuffer */ 387 387 388 388 return 0; 389 389 } ··· 393 393 struct au1xpsc_audio_data *wd = dev_get_drvdata(dev); 394 394 395 395 /* select I2S mode and PSC clock */ 396 - au_writel(PSC_CTRL_DISABLE, PSC_CTRL(wd)); 397 - au_sync(); 398 - au_writel(0, PSC_SEL(wd)); 399 - au_sync(); 400 - au_writel(wd->pm[0], PSC_SEL(wd)); 401 - au_sync(); 396 + __raw_writel(PSC_CTRL_DISABLE, PSC_CTRL(wd)); 397 + wmb(); /* drain writebuffer */ 398 + __raw_writel(0, PSC_SEL(wd)); 399 + wmb(); /* drain writebuffer */ 400 + __raw_writel(wd->pm[0], PSC_SEL(wd)); 401 + wmb(); /* drain writebuffer */ 402 402 403 403 return 0; 404 404 }
+11 -11
sound/soc/au1x/psc.h
··· 27 27 }; 28 28 29 29 /* easy access macros */ 30 - #define PSC_CTRL(x) ((unsigned long)((x)->mmio) + PSC_CTRL_OFFSET) 31 - #define PSC_SEL(x) ((unsigned long)((x)->mmio) + PSC_SEL_OFFSET) 32 - #define I2S_STAT(x) ((unsigned long)((x)->mmio) + PSC_I2SSTAT_OFFSET) 33 - #define I2S_CFG(x) ((unsigned long)((x)->mmio) + PSC_I2SCFG_OFFSET) 34 - #define I2S_PCR(x) ((unsigned long)((x)->mmio) + PSC_I2SPCR_OFFSET) 35 - #define AC97_CFG(x) ((unsigned long)((x)->mmio) + PSC_AC97CFG_OFFSET) 36 - #define AC97_CDC(x) ((unsigned long)((x)->mmio) + PSC_AC97CDC_OFFSET) 37 - #define AC97_EVNT(x) ((unsigned long)((x)->mmio) + PSC_AC97EVNT_OFFSET) 38 - #define AC97_PCR(x) ((unsigned long)((x)->mmio) + PSC_AC97PCR_OFFSET) 39 - #define AC97_RST(x) ((unsigned long)((x)->mmio) + PSC_AC97RST_OFFSET) 40 - #define AC97_STAT(x) ((unsigned long)((x)->mmio) + PSC_AC97STAT_OFFSET) 30 + #define PSC_CTRL(x) ((x)->mmio + PSC_CTRL_OFFSET) 31 + #define PSC_SEL(x) ((x)->mmio + PSC_SEL_OFFSET) 32 + #define I2S_STAT(x) ((x)->mmio + PSC_I2SSTAT_OFFSET) 33 + #define I2S_CFG(x) ((x)->mmio + PSC_I2SCFG_OFFSET) 34 + #define I2S_PCR(x) ((x)->mmio + PSC_I2SPCR_OFFSET) 35 + #define AC97_CFG(x) ((x)->mmio + PSC_AC97CFG_OFFSET) 36 + #define AC97_CDC(x) ((x)->mmio + PSC_AC97CDC_OFFSET) 37 + #define AC97_EVNT(x) ((x)->mmio + PSC_AC97EVNT_OFFSET) 38 + #define AC97_PCR(x) ((x)->mmio + PSC_AC97PCR_OFFSET) 39 + #define AC97_RST(x) ((x)->mmio + PSC_AC97RST_OFFSET) 40 + #define AC97_STAT(x) ((x)->mmio + PSC_AC97STAT_OFFSET) 41 41 42 42 #endif