Blame view

arch/arm/kernel/smp_scu.c 2.01 KB
a8cbcd92b   Russell King   [ARM] smp: separa...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
  /*
   *  linux/arch/arm/kernel/smp_scu.c
   *
   *  Copyright (C) 2002 ARM Ltd.
   *  All Rights Reserved
   *
   * This program is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License version 2 as
   * published by the Free Software Foundation.
   */
  #include <linux/init.h>
  #include <linux/io.h>
  
  #include <asm/smp_scu.h>
af73110d2   Catalin Marinas   [ARM] 5516/1: Flu...
15
  #include <asm/cacheflush.h>
f630c1bdf   Will Deacon   ARM: 7091/1: erra...
16
  #include <asm/cputype.h>
a8cbcd92b   Russell King   [ARM] smp: separa...
17
18
19
20
21
22
  
  #define SCU_CTRL		0x00
  #define SCU_CONFIG		0x04
  #define SCU_CPU_STATUS		0x08
  #define SCU_INVALIDATE		0x0c
  #define SCU_FPGA_REVISION	0x10
10cdc7e51   Rob Herring   ARM: 6960/1: allo...
23
  #ifdef CONFIG_SMP
a8cbcd92b   Russell King   [ARM] smp: separa...
24
25
26
27
28
29
30
31
32
33
34
35
  /*
   * Get the number of CPU cores from the SCU configuration
   */
  unsigned int __init scu_get_core_count(void __iomem *scu_base)
  {
  	unsigned int ncores = __raw_readl(scu_base + SCU_CONFIG);
  	return (ncores & 0x03) + 1;
  }
  
  /*
   * Enable the SCU
   */
26a527e69   Shawn Guo   ARM: 7100/1: smp_...
36
  void scu_enable(void __iomem *scu_base)
a8cbcd92b   Russell King   [ARM] smp: separa...
37
38
  {
  	u32 scu_ctrl;
f630c1bdf   Will Deacon   ARM: 7091/1: erra...
39
40
41
42
43
44
45
46
  #ifdef CONFIG_ARM_ERRATA_764369
  	/* Cortex-A9 only */
  	if ((read_cpuid(CPUID_ID) & 0xff0ffff0) == 0x410fc090) {
  		scu_ctrl = __raw_readl(scu_base + 0x30);
  		if (!(scu_ctrl & 1))
  			__raw_writel(scu_ctrl | 0x1, scu_base + 0x30);
  	}
  #endif
a8cbcd92b   Russell King   [ARM] smp: separa...
47
  	scu_ctrl = __raw_readl(scu_base + SCU_CTRL);
9b229fa09   Catalin Marinas   Check whether the...
48
49
50
  	/* already enabled? */
  	if (scu_ctrl & 1)
  		return;
a8cbcd92b   Russell King   [ARM] smp: separa...
51
52
  	scu_ctrl |= 1;
  	__raw_writel(scu_ctrl, scu_base + SCU_CTRL);
af73110d2   Catalin Marinas   [ARM] 5516/1: Flu...
53
54
55
56
57
58
  
  	/*
  	 * Ensure that the data accessed by CPU0 before the SCU was
  	 * initialised is visible to the other CPUs.
  	 */
  	flush_cache_all();
a8cbcd92b   Russell King   [ARM] smp: separa...
59
  }
10cdc7e51   Rob Herring   ARM: 6960/1: allo...
60
  #endif
292ec42af   Russell King   ARM: pm: add func...
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
  
  /*
   * Set the executing CPUs power mode as defined.  This will be in
   * preparation for it executing a WFI instruction.
   *
   * This function must be called with preemption disabled, and as it
   * has the side effect of disabling coherency, caches must have been
   * flushed.  Interrupts must also have been disabled.
   */
  int scu_power_mode(void __iomem *scu_base, unsigned int mode)
  {
  	unsigned int val;
  	int cpu = smp_processor_id();
  
  	if (mode > 3 || mode == 1 || cpu > 3)
  		return -EINVAL;
  
  	val = __raw_readb(scu_base + SCU_CPU_STATUS + cpu) & ~0x03;
  	val |= mode;
  	__raw_writeb(val, scu_base + SCU_CPU_STATUS + cpu);
  
  	return 0;
  }