1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Author: Xianghua Xiao <x.xiao@freescale.com>
4 * Zhang Wei <wei.zhang@freescale.com>
6 * Copyright 2006 Freescale Semiconductor Inc.
9 #include <linux/stddef.h>
10 #include <linux/kernel.h>
11 #include <linux/init.h>
12 #include <linux/delay.h>
13 #include <linux/pgtable.h>
15 #include <asm/code-patching.h>
17 #include <asm/pci-bridge.h>
19 #include <asm/cacheflush.h>
22 #include <sysdev/fsl_soc.h>
26 extern void __secondary_start_mpc86xx(void);
28 #define MCM_PORT_CONFIG_OFFSET 0x10
30 /* Offset from CCSRBAR */
31 #define MPC86xx_MCM_OFFSET (0x1000)
32 #define MPC86xx_MCM_SIZE (0x1000)
35 smp_86xx_release_core(int nr)
37 __be32 __iomem *mcm_vaddr;
40 if (nr < 0 || nr >= NR_CPUS)
46 mcm_vaddr = ioremap(get_immrbase() + MPC86xx_MCM_OFFSET,
48 pcr = in_be32(mcm_vaddr + (MCM_PORT_CONFIG_OFFSET >> 2));
49 pcr |= 1 << (nr + 24);
50 out_be32(mcm_vaddr + (MCM_PORT_CONFIG_OFFSET >> 2), pcr);
57 smp_86xx_kick_cpu(int nr)
59 unsigned int save_vector;
60 unsigned long target, flags;
62 unsigned int *vector = (unsigned int *)(KERNELBASE + 0x100);
64 if (nr < 0 || nr >= NR_CPUS)
67 pr_debug("smp_86xx_kick_cpu: kick CPU #%d\n", nr);
69 local_irq_save(flags);
71 /* Save reset vector */
72 save_vector = *vector;
74 /* Setup fake reset vector to call __secondary_start_mpc86xx. */
75 target = (unsigned long) __secondary_start_mpc86xx;
76 patch_branch((struct ppc_inst *)vector, target, BRANCH_SET_LINK);
79 smp_86xx_release_core(nr);
81 /* Wait a bit for the CPU to take the exception. */
82 while ((__secondary_hold_acknowledge != nr) && (n++, n < 1000))
85 /* Restore the exception vector */
86 patch_instruction((struct ppc_inst *)vector, ppc_inst(save_vector));
88 local_irq_restore(flags);
90 pr_debug("wait CPU #%d for %d msecs.\n", nr, n);
97 smp_86xx_setup_cpu(int cpu_nr)
99 mpic_setup_this_cpu();
103 struct smp_ops_t smp_86xx_ops = {
104 .cause_nmi_ipi = NULL,
105 .message_pass = smp_mpic_message_pass,
106 .probe = smp_mpic_probe,
107 .kick_cpu = smp_86xx_kick_cpu,
108 .setup_cpu = smp_86xx_setup_cpu,
109 .take_timebase = smp_generic_take_timebase,
110 .give_timebase = smp_generic_give_timebase,
115 mpc86xx_smp_init(void)
117 smp_ops = &smp_86xx_ops;