2019-06-04 10:11:33 +02:00
// SPDX-License-Identifier: GPL-2.0-only
2013-06-25 12:15:10 +01:00
/*
* arch / arm / mach - sti / platsmp . c
*
* Copyright ( C ) 2013 STMicroelectronics ( R & D ) Limited .
* http : //www.st.com
*
* Cloned from linux / arch / arm / mach - vexpress / platsmp . c
*
* Copyright ( C ) 2002 ARM Ltd .
* All Rights Reserved
*/
# include <linux/init.h>
# include <linux/errno.h>
# include <linux/delay.h>
# include <linux/smp.h>
# include <linux/io.h>
# include <linux/of.h>
# include <linux/of_address.h>
2015-06-09 15:33:00 +02:00
# include <linux/memblock.h>
2013-06-25 12:15:10 +01:00
# include <asm/cacheflush.h>
# include <asm/smp_plat.h>
# include <asm/smp_scu.h>
# include "smp.h"
2018-12-20 14:32:15 +01:00
static u32 __iomem * cpu_strt_ptr ;
2013-06-25 12:15:10 +01:00
2014-06-24 17:13:48 +05:30
static int sti_boot_secondary ( unsigned int cpu , struct task_struct * idle )
2013-06-25 12:15:10 +01:00
{
2018-12-20 14:32:15 +01:00
unsigned long entry_pa = __pa_symbol ( secondary_startup ) ;
2013-06-25 12:15:10 +01:00
/*
2018-12-20 14:32:15 +01:00
* Secondary CPU is initialised and started by a U - BOOTROM firmware .
* Secondary CPU is spinning and waiting for a write at cpu_strt_ptr .
* Writing secondary_startup address at cpu_strt_ptr makes it to
* jump directly to secondary_startup ( ) .
2013-06-25 12:15:10 +01:00
*/
2018-12-20 14:32:15 +01:00
__raw_writel ( entry_pa , cpu_strt_ptr ) ;
2013-06-25 12:15:10 +01:00
2018-12-20 14:32:15 +01:00
/* wmb so that data is actually written before cache flush is done */
smp_wmb ( ) ;
sync_cache_w ( cpu_strt_ptr ) ;
2013-06-25 12:15:10 +01:00
2018-12-20 14:32:15 +01:00
return 0 ;
2013-06-25 12:15:10 +01:00
}
2014-06-24 17:13:48 +05:30
static void __init sti_smp_prepare_cpus ( unsigned int max_cpus )
2013-06-25 12:15:10 +01:00
{
2015-06-09 15:33:00 +02:00
struct device_node * np ;
void __iomem * scu_base ;
u32 release_phys ;
int cpu ;
np = of_find_compatible_node ( NULL , NULL , " arm,cortex-a9-scu " ) ;
2013-06-25 12:15:10 +01:00
if ( np ) {
scu_base = of_iomap ( np , 0 ) ;
scu_enable ( scu_base ) ;
of_node_put ( np ) ;
}
2015-06-09 15:33:00 +02:00
if ( max_cpus < = 1 )
return ;
for_each_possible_cpu ( cpu ) {
np = of_get_cpu_node ( cpu , NULL ) ;
if ( ! np )
continue ;
if ( of_property_read_u32 ( np , " cpu-release-addr " ,
& release_phys ) ) {
pr_err ( " CPU %d: missing or invalid cpu-release-addr "
" property \n " , cpu ) ;
continue ;
}
/*
2018-12-20 14:32:15 +01:00
* cpu - release - addr is usually configured in SBC DMEM but can
* also be in RAM .
2015-06-09 15:33:00 +02:00
*/
if ( ! memblock_is_memory ( release_phys ) )
cpu_strt_ptr =
ioremap ( release_phys , sizeof ( release_phys ) ) ;
else
cpu_strt_ptr =
( u32 __iomem * ) phys_to_virt ( release_phys ) ;
2018-12-20 14:32:15 +01:00
set_cpu_possible ( cpu , true ) ;
2015-06-09 15:33:00 +02:00
}
2013-06-25 12:15:10 +01:00
}
2015-11-15 10:39:53 +09:00
const struct smp_operations sti_smp_ops __initconst = {
2013-06-25 12:15:10 +01:00
. smp_prepare_cpus = sti_smp_prepare_cpus ,
. smp_boot_secondary = sti_boot_secondary ,
} ;