Advertisement
Guest User

linux-4.0.0-rc4-sun7i-smp.diff

a guest
Mar 23rd, 2015
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 4.30 KB | None | 0 0
  1. diff --git a/arch/arm/boot/dts/sun7i-a20.dtsi b/arch/arm/boot/dts/sun7i-a20.dtsi
  2. index 3a8530b..502a94b 100644
  3. --- a/arch/arm/boot/dts/sun7i-a20.dtsi
  4. +++ b/arch/arm/boot/dts/sun7i-a20.dtsi
  5. @@ -94,6 +94,7 @@
  6.         };
  7.  
  8.         cpus {
  9. +               enable-method = "allwinner,sun7i-a20";
  10.                 #address-cells = <1>;
  11.                 #size-cells = <0>;
  12.  
  13. @@ -536,6 +537,11 @@
  14.                         interrupts = <GIC_SPI 0 IRQ_TYPE_LEVEL_HIGH>;
  15.                 };
  16.  
  17. +               cpucfg@01f01c00 {
  18. +                       compatible = "allwinner,sun7i-a20-cpuconfig";
  19. +                       reg = <0x01c25c00 0x302>;
  20. +               };
  21. +
  22.                 dma: dma-controller@01c02000 {
  23.                         compatible = "allwinner,sun4i-a10-dma";
  24.                         reg = <0x01c02000 0x1000>;
  25. diff --git a/arch/arm/mach-sunxi/platsmp.c b/arch/arm/mach-sunxi/platsmp.c
  26. index 587b046..c809b57 100644
  27. --- a/arch/arm/mach-sunxi/platsmp.c
  28. +++ b/arch/arm/mach-sunxi/platsmp.c
  29. @@ -28,12 +28,16 @@
  30.  #define CPUCFG_GEN_CTRL_REG                    0x184
  31.  #define CPUCFG_PRIVATE0_REG                    0x1a4
  32.  #define CPUCFG_PRIVATE1_REG                    0x1a8
  33. +#define CPUCFG_PWR_CLAMP_REG(cpu)              0x1b0   /* FIXME: This is probably only correct for CPU1 */
  34. +#define CPUCFG_PWROFF_REG                      0x1b4   /* FIXME: This is probably only correct for CPU1 */
  35.  #define CPUCFG_DBG_CTL0_REG                    0x1e0
  36.  #define CPUCFG_DBG_CTL1_REG                    0x1e4
  37.  
  38.  #define PRCM_CPU_PWROFF_REG                    0x100
  39.  #define PRCM_CPU_PWR_CLAMP_REG(cpu)            (((cpu) * 4) + 0x140)
  40.  
  41. +extern void sun7i_secondary_startup(void);
  42. +
  43.  static void __iomem *cpucfg_membase;
  44.  static void __iomem *prcm_membase;
  45.  
  46. @@ -121,3 +125,72 @@ static struct smp_operations sun6i_smp_ops __initdata = {
  47.         .smp_boot_secondary     = sun6i_smp_boot_secondary,
  48.  };
  49.  CPU_METHOD_OF_DECLARE(sun6i_a31_smp, "allwinner,sun6i-a31", &sun6i_smp_ops);
  50. +
  51. +static void __init sun7i_smp_prepare_cpus(unsigned int max_cpus)
  52. +{
  53. +       struct device_node *node;
  54. +
  55. +       node = of_find_compatible_node(NULL, NULL,
  56. +                                      "allwinner,sun7i-a20-cpuconfig");
  57. +       if (!node) {
  58. +               pr_err("Missing A20 CPU config node in the device tree\n");
  59. +               return;
  60. +       }
  61. +       cpucfg_membase = of_iomap(node, 0);
  62. +       if (!cpucfg_membase)
  63. +               pr_err("Couldn't map A20 CPU config registers\n");
  64. +}
  65. +
  66. +static int sun7i_smp_boot_secondary(unsigned int cpu,
  67. +                                   struct task_struct *idle)
  68. +{
  69. +       u32 reg;
  70. +       int i;
  71. +
  72. +       if (!cpucfg_membase)
  73. +               return -EFAULT;
  74. +
  75. +       spin_lock(&cpu_lock);
  76. +
  77. +       /* Set CPU boot address */
  78. +       writel(virt_to_phys(secondary_startup),
  79. +              cpucfg_membase + CPUCFG_PRIVATE0_REG);
  80. +
  81. +       /* Assert the CPU core in reset */
  82. +       writel(0, cpucfg_membase + CPUCFG_CPU_RST_CTRL_REG(cpu));
  83. +
  84. +       /* Assert the L1 cache in reset */
  85. +       reg = readl(cpucfg_membase + CPUCFG_GEN_CTRL_REG);
  86. +       writel(reg & ~BIT(cpu), cpucfg_membase + CPUCFG_GEN_CTRL_REG);
  87. +
  88. +       /* Disable external debug access */
  89. +       reg = readl(cpucfg_membase + CPUCFG_DBG_CTL1_REG);
  90. +       writel(reg & ~BIT(cpu), cpucfg_membase + CPUCFG_DBG_CTL1_REG);
  91. +
  92. +       /* Power up the CPU */
  93. +       for (i = 0; i <= 8; i++)
  94. +               writel(0xff >> i, cpucfg_membase + CPUCFG_PWR_CLAMP_REG(cpu));
  95. +       mdelay(10);
  96. +
  97. +       /* Clear CPU power-off gating */
  98. +       reg = readl(cpucfg_membase + CPUCFG_PWROFF_REG);
  99. +       writel(reg & ~1, cpucfg_membase + CPUCFG_PWROFF_REG);
  100. +       mdelay(1);
  101. +
  102. +       /* Deassert the CPU core reset */
  103. +       writel(3, cpucfg_membase + CPUCFG_CPU_RST_CTRL_REG(cpu));
  104. +
  105. +       /* Enable back the external debug accesses */
  106. +       reg = readl(cpucfg_membase + CPUCFG_DBG_CTL1_REG);
  107. +       writel(reg | BIT(cpu), cpucfg_membase + CPUCFG_DBG_CTL1_REG);
  108. +
  109. +       spin_unlock(&cpu_lock);
  110. +
  111. +       return 0;
  112. +}
  113. +
  114. +static struct smp_operations sun7i_smp_ops __initdata = {
  115. +       .smp_prepare_cpus       = sun7i_smp_prepare_cpus,
  116. +       .smp_boot_secondary     = sun7i_smp_boot_secondary,
  117. +};
  118. +CPU_METHOD_OF_DECLARE(sun7i_a20_smp, "allwinner,sun7i-a20", &sun7i_smp_ops);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement