1caab277bSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 2cd1aebf5SMark Rutland /* 3cd1aebf5SMark Rutland * Copyright (C) 2013 ARM Ltd. 4cd1aebf5SMark Rutland */ 5cd1aebf5SMark Rutland #ifndef __ASM_CPU_OPS_H 6cd1aebf5SMark Rutland #define __ASM_CPU_OPS_H 7cd1aebf5SMark Rutland 8cd1aebf5SMark Rutland #include <linux/init.h> 9cd1aebf5SMark Rutland #include <linux/threads.h> 10cd1aebf5SMark Rutland 11652af899SMark Rutland /** 12652af899SMark Rutland * struct cpu_operations - Callback operations for hotplugging CPUs. 13652af899SMark Rutland * 14652af899SMark Rutland * @name: Name of the property as appears in a devicetree cpu node's 15819a8826SLorenzo Pieralisi * enable-method property. On systems booting with ACPI, @name 16819a8826SLorenzo Pieralisi * identifies the struct cpu_operations entry corresponding to 17819a8826SLorenzo Pieralisi * the boot protocol specified in the ACPI MADT table. 18819a8826SLorenzo Pieralisi * @cpu_init: Reads any data necessary for a specific enable-method for a 19819a8826SLorenzo Pieralisi * proposed logical id. 20652af899SMark Rutland * @cpu_prepare: Early one-time preparation step for a cpu. If there is a 21652af899SMark Rutland * mechanism for doing so, tests whether it is possible to boot 22652af899SMark Rutland * the given CPU. 23652af899SMark Rutland * @cpu_boot: Boots a cpu into the kernel. 24652af899SMark Rutland * @cpu_postboot: Optionally, perform any post-boot cleanup or necesary 25652af899SMark Rutland * synchronisation. Called from the cpu being booted. 26*d55c5f28SSudeep Holla * @cpu_can_disable: Determines whether a CPU can be disabled based on 27*d55c5f28SSudeep Holla * mechanism-specific information. 289327e2c6SMark Rutland * @cpu_disable: Prepares a cpu to die. May fail for some mechanism-specific 299327e2c6SMark Rutland * reason, which will cause the hot unplug to be aborted. Called 309327e2c6SMark Rutland * from the cpu to be killed. 319327e2c6SMark Rutland * @cpu_die: Makes a cpu leave the kernel. Must not fail. Called from the 329327e2c6SMark Rutland * cpu being killed. 33c814ca02SAshwin Chaugule * @cpu_kill: Ensures a cpu has left the kernel. Called from another cpu. 34819a8826SLorenzo Pieralisi * @cpu_init_idle: Reads any data necessary to initialize CPU idle states for 35819a8826SLorenzo Pieralisi * a proposed logical id. 3695322526SLorenzo Pieralisi * @cpu_suspend: Suspends a cpu and saves the required context. May fail owing 3795322526SLorenzo Pieralisi * to wrong parameters or error conditions. Called from the 3895322526SLorenzo Pieralisi * CPU being suspended. Must be called with IRQs disabled. 39652af899SMark Rutland */ 40cd1aebf5SMark Rutland struct cpu_operations { 41cd1aebf5SMark Rutland const char *name; 42819a8826SLorenzo Pieralisi int (*cpu_init)(unsigned int); 43cd1aebf5SMark Rutland int (*cpu_prepare)(unsigned int); 44652af899SMark Rutland int (*cpu_boot)(unsigned int); 45652af899SMark Rutland void (*cpu_postboot)(void); 469327e2c6SMark Rutland #ifdef CONFIG_HOTPLUG_CPU 47*d55c5f28SSudeep Holla bool (*cpu_can_disable)(unsigned int cpu); 489327e2c6SMark Rutland int (*cpu_disable)(unsigned int cpu); 499327e2c6SMark Rutland void (*cpu_die)(unsigned int cpu); 50c814ca02SAshwin Chaugule int (*cpu_kill)(unsigned int cpu); 519327e2c6SMark Rutland #endif 52af3cfdbfSLorenzo Pieralisi #ifdef CONFIG_CPU_IDLE 53819a8826SLorenzo Pieralisi int (*cpu_init_idle)(unsigned int); 5495322526SLorenzo Pieralisi int (*cpu_suspend)(unsigned long); 5595322526SLorenzo Pieralisi #endif 56cd1aebf5SMark Rutland }; 57cd1aebf5SMark Rutland 58cd1aebf5SMark Rutland extern const struct cpu_operations *cpu_ops[NR_CPUS]; 59819a8826SLorenzo Pieralisi int __init cpu_read_ops(int cpu); 60cd1aebf5SMark Rutland 61819a8826SLorenzo Pieralisi static inline void __init cpu_read_bootcpu_ops(void) 62819a8826SLorenzo Pieralisi { 63819a8826SLorenzo Pieralisi cpu_read_ops(0); 64819a8826SLorenzo Pieralisi } 65819a8826SLorenzo Pieralisi 66cd1aebf5SMark Rutland #endif /* ifndef __ASM_CPU_OPS_H */ 67