Linux Audio

Check our new training course

Loading...
v5.9
  1// SPDX-License-Identifier: GPL-2.0-only
  2/*
  3 * Copyright 2010-2011 Calxeda, Inc.
  4 * Copyright 2012 Pavel Machek <pavel@denx.de>
  5 * Based on platsmp.c, Copyright (C) 2002 ARM Ltd.
  6 * Copyright (C) 2012 Altera Corporation
 
 
 
 
 
 
 
 
 
 
 
 
  7 */
  8#include <linux/delay.h>
  9#include <linux/init.h>
 10#include <linux/smp.h>
 11#include <linux/io.h>
 12#include <linux/of.h>
 13#include <linux/of_address.h>
 14
 15#include <asm/cacheflush.h>
 16#include <asm/smp_scu.h>
 17#include <asm/smp_plat.h>
 18
 19#include "core.h"
 20
 21static int socfpga_boot_secondary(unsigned int cpu, struct task_struct *idle)
 22{
 23	int trampoline_size = &secondary_trampoline_end - &secondary_trampoline;
 24
 25	if (socfpga_cpu1start_addr) {
 26		/* This will put CPU #1 into reset. */
 27		writel(RSTMGR_MPUMODRST_CPU1,
 28		       rst_manager_base_addr + SOCFPGA_RSTMGR_MODMPURST);
 29
 30		memcpy(phys_to_virt(0), &secondary_trampoline, trampoline_size);
 31
 32		writel(__pa_symbol(secondary_startup),
 33		       sys_manager_base_addr + (socfpga_cpu1start_addr & 0x000000ff));
 34
 35		flush_cache_all();
 36		smp_wmb();
 37		outer_clean_range(0, trampoline_size);
 38
 39		/* This will release CPU #1 out of reset. */
 40		writel(0, rst_manager_base_addr + SOCFPGA_RSTMGR_MODMPURST);
 41	}
 42
 43	return 0;
 44}
 45
 46static int socfpga_a10_boot_secondary(unsigned int cpu, struct task_struct *idle)
 
 
 
 
 47{
 48	int trampoline_size = &secondary_trampoline_end - &secondary_trampoline;
 49
 50	if (socfpga_cpu1start_addr) {
 51		writel(RSTMGR_MPUMODRST_CPU1, rst_manager_base_addr +
 52		       SOCFPGA_A10_RSTMGR_MODMPURST);
 53		memcpy(phys_to_virt(0), &secondary_trampoline, trampoline_size);
 54
 55		writel(__pa_symbol(secondary_startup),
 56		       sys_manager_base_addr + (socfpga_cpu1start_addr & 0x00000fff));
 57
 58		flush_cache_all();
 59		smp_wmb();
 60		outer_clean_range(0, trampoline_size);
 61
 62		/* This will release CPU #1 out of reset. */
 63		writel(0, rst_manager_base_addr + SOCFPGA_A10_RSTMGR_MODMPURST);
 64	}
 65
 66	return 0;
 
 67}
 68
 69static void __init socfpga_smp_prepare_cpus(unsigned int max_cpus)
 70{
 71	struct device_node *np;
 72	void __iomem *socfpga_scu_base_addr;
 73
 74	np = of_find_compatible_node(NULL, NULL, "arm,cortex-a9-scu");
 75	if (!np) {
 76		pr_err("%s: missing scu\n", __func__);
 77		return;
 78	}
 79
 80	socfpga_scu_base_addr = of_iomap(np, 0);
 81	if (!socfpga_scu_base_addr)
 82		return;
 83	scu_enable(socfpga_scu_base_addr);
 84}
 85
 86#ifdef CONFIG_HOTPLUG_CPU
 87/*
 88 * platform-specific code to shutdown a CPU
 89 *
 90 * Called with IRQs disabled
 91 */
 92static void socfpga_cpu_die(unsigned int cpu)
 93{
 94	/* Do WFI. If we wake up early, go back into WFI */
 95	while (1)
 96		cpu_do_idle();
 97}
 98
 99/*
100 * We need a dummy function so that platform_can_cpu_hotplug() knows
101 * we support CPU hotplug. However, the function does not need to do
102 * anything, because CPUs going offline just do WFI. We could reset
103 * the CPUs but it would increase power consumption.
104 */
105static int socfpga_cpu_kill(unsigned int cpu)
106{
107	return 1;
108}
109#endif
110
111static const struct smp_operations socfpga_smp_ops __initconst = {
 
112	.smp_prepare_cpus	= socfpga_smp_prepare_cpus,
113	.smp_boot_secondary	= socfpga_boot_secondary,
114#ifdef CONFIG_HOTPLUG_CPU
115	.cpu_die		= socfpga_cpu_die,
116	.cpu_kill		= socfpga_cpu_kill,
117#endif
118};
119
120static const struct smp_operations socfpga_a10_smp_ops __initconst = {
121	.smp_prepare_cpus	= socfpga_smp_prepare_cpus,
122	.smp_boot_secondary	= socfpga_a10_boot_secondary,
123#ifdef CONFIG_HOTPLUG_CPU
124	.cpu_die		= socfpga_cpu_die,
125	.cpu_kill		= socfpga_cpu_kill,
126#endif
127};
128
129CPU_METHOD_OF_DECLARE(socfpga_smp, "altr,socfpga-smp", &socfpga_smp_ops);
130CPU_METHOD_OF_DECLARE(socfpga_a10_smp, "altr,socfpga-a10-smp", &socfpga_a10_smp_ops);
v3.15
 
  1/*
  2 * Copyright 2010-2011 Calxeda, Inc.
  3 * Copyright 2012 Pavel Machek <pavel@denx.de>
  4 * Based on platsmp.c, Copyright (C) 2002 ARM Ltd.
  5 * Copyright (C) 2012 Altera Corporation
  6 *
  7 * This program is free software; you can redistribute it and/or modify it
  8 * under the terms and conditions of the GNU General Public License,
  9 * version 2, as published by the Free Software Foundation.
 10 *
 11 * This program is distributed in the hope it will be useful, but WITHOUT
 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 13 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 14 * more details.
 15 *
 16 * You should have received a copy of the GNU General Public License along with
 17 * this program.  If not, see <http://www.gnu.org/licenses/>.
 18 */
 19#include <linux/delay.h>
 20#include <linux/init.h>
 21#include <linux/smp.h>
 22#include <linux/io.h>
 23#include <linux/of.h>
 24#include <linux/of_address.h>
 25
 26#include <asm/cacheflush.h>
 27#include <asm/smp_scu.h>
 28#include <asm/smp_plat.h>
 29
 30#include "core.h"
 31
 32static int socfpga_boot_secondary(unsigned int cpu, struct task_struct *idle)
 33{
 34	int trampoline_size = &secondary_trampoline_end - &secondary_trampoline;
 35
 36	if (cpu1start_addr) {
 
 
 
 
 37		memcpy(phys_to_virt(0), &secondary_trampoline, trampoline_size);
 38
 39		__raw_writel(virt_to_phys(socfpga_secondary_startup),
 40			(sys_manager_base_addr + (cpu1start_addr & 0x000000ff)));
 41
 42		flush_cache_all();
 43		smp_wmb();
 44		outer_clean_range(0, trampoline_size);
 45
 46		/* This will release CPU #1 out of reset.*/
 47		__raw_writel(0, rst_manager_base_addr + 0x10);
 48	}
 49
 50	return 0;
 51}
 52
 53/*
 54 * Initialise the CPU possible map early - this describes the CPUs
 55 * which may be present or become present in the system.
 56 */
 57static void __init socfpga_smp_init_cpus(void)
 58{
 59	unsigned int i, ncores;
 60
 61	ncores = scu_get_core_count(socfpga_scu_base_addr);
 
 
 
 62
 63	for (i = 0; i < ncores; i++)
 64		set_cpu_possible(i, true);
 65
 66	/* sanity check */
 67	if (ncores > num_possible_cpus()) {
 68		pr_warn("socfpga: no. of cores (%d) greater than configured"
 69			"maximum of %d - clipping\n", ncores, num_possible_cpus());
 70		ncores = num_possible_cpus();
 
 71	}
 72
 73	for (i = 0; i < ncores; i++)
 74		set_cpu_possible(i, true);
 75}
 76
 77static void __init socfpga_smp_prepare_cpus(unsigned int max_cpus)
 78{
 
 
 
 
 
 
 
 
 
 
 
 
 79	scu_enable(socfpga_scu_base_addr);
 80}
 81
 
 82/*
 83 * platform-specific code to shutdown a CPU
 84 *
 85 * Called with IRQs disabled
 86 */
 87static void socfpga_cpu_die(unsigned int cpu)
 88{
 89	cpu_do_idle();
 
 
 
 90
 91	/* We should have never returned from idle */
 92	panic("cpu %d unexpectedly exit from shutdown\n", cpu);
 
 
 
 
 
 
 
 93}
 
 94
 95struct smp_operations socfpga_smp_ops __initdata = {
 96	.smp_init_cpus		= socfpga_smp_init_cpus,
 97	.smp_prepare_cpus	= socfpga_smp_prepare_cpus,
 98	.smp_boot_secondary	= socfpga_boot_secondary,
 99#ifdef CONFIG_HOTPLUG_CPU
100	.cpu_die		= socfpga_cpu_die,
 
101#endif
102};