1*d2912cb1SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
21c33be57SNicolas Pitre /*
31c33be57SNicolas Pitre * arch/arm/include/asm/bL_switcher.h
41c33be57SNicolas Pitre *
51c33be57SNicolas Pitre * Created by: Nicolas Pitre, April 2012
61c33be57SNicolas Pitre * Copyright: (C) 2012-2013 Linaro Limited
71c33be57SNicolas Pitre */
81c33be57SNicolas Pitre
91c33be57SNicolas Pitre #ifndef ASM_BL_SWITCHER_H
101c33be57SNicolas Pitre #define ASM_BL_SWITCHER_H
111c33be57SNicolas Pitre
12491990e2SDave Martin #include <linux/compiler.h>
13491990e2SDave Martin #include <linux/types.h>
14491990e2SDave Martin
150577fee2SDave Martin typedef void (*bL_switch_completion_handler)(void *cookie);
160577fee2SDave Martin
170577fee2SDave Martin int bL_switch_request_cb(unsigned int cpu, unsigned int new_cluster_id,
180577fee2SDave Martin bL_switch_completion_handler completer,
190577fee2SDave Martin void *completer_cookie);
bL_switch_request(unsigned int cpu,unsigned int new_cluster_id)200577fee2SDave Martin static inline int bL_switch_request(unsigned int cpu, unsigned int new_cluster_id)
210577fee2SDave Martin {
220577fee2SDave Martin return bL_switch_request_cb(cpu, new_cluster_id, NULL, NULL);
230577fee2SDave Martin }
241c33be57SNicolas Pitre
25491990e2SDave Martin /*
26491990e2SDave Martin * Register here to be notified about runtime enabling/disabling of
27491990e2SDave Martin * the switcher.
28491990e2SDave Martin *
29491990e2SDave Martin * The notifier chain is called with the switcher activation lock held:
30491990e2SDave Martin * the switcher will not be enabled or disabled during callbacks.
31491990e2SDave Martin * Callbacks must not call bL_switcher_{get,put}_enabled().
32491990e2SDave Martin */
33491990e2SDave Martin #define BL_NOTIFY_PRE_ENABLE 0
34491990e2SDave Martin #define BL_NOTIFY_POST_ENABLE 1
35491990e2SDave Martin #define BL_NOTIFY_PRE_DISABLE 2
36491990e2SDave Martin #define BL_NOTIFY_POST_DISABLE 3
37491990e2SDave Martin
38491990e2SDave Martin #ifdef CONFIG_BL_SWITCHER
39491990e2SDave Martin
40491990e2SDave Martin int bL_switcher_register_notifier(struct notifier_block *nb);
41491990e2SDave Martin int bL_switcher_unregister_notifier(struct notifier_block *nb);
42491990e2SDave Martin
43491990e2SDave Martin /*
44491990e2SDave Martin * Use these functions to temporarily prevent enabling/disabling of
45491990e2SDave Martin * the switcher.
46491990e2SDave Martin * bL_switcher_get_enabled() returns true if the switcher is currently
47491990e2SDave Martin * enabled. Each call to bL_switcher_get_enabled() must be followed
48491990e2SDave Martin * by a call to bL_switcher_put_enabled(). These functions are not
49491990e2SDave Martin * recursive.
50491990e2SDave Martin */
51c0f43751SDave Martin bool bL_switcher_get_enabled(void);
52c0f43751SDave Martin void bL_switcher_put_enabled(void);
53c0f43751SDave Martin
5429064b88SDave Martin int bL_switcher_trace_trigger(void);
55d08e2e09SDave Martin int bL_switcher_get_logical_index(u32 mpidr);
5629064b88SDave Martin
57491990e2SDave Martin #else
bL_switcher_register_notifier(struct notifier_block * nb)58491990e2SDave Martin static inline int bL_switcher_register_notifier(struct notifier_block *nb)
59491990e2SDave Martin {
60491990e2SDave Martin return 0;
61491990e2SDave Martin }
62491990e2SDave Martin
bL_switcher_unregister_notifier(struct notifier_block * nb)63491990e2SDave Martin static inline int bL_switcher_unregister_notifier(struct notifier_block *nb)
64491990e2SDave Martin {
65491990e2SDave Martin return 0;
66491990e2SDave Martin }
67491990e2SDave Martin
bL_switcher_get_enabled(void)68491990e2SDave Martin static inline bool bL_switcher_get_enabled(void) { return false; }
bL_switcher_put_enabled(void)69491990e2SDave Martin static inline void bL_switcher_put_enabled(void) { }
bL_switcher_trace_trigger(void)7029064b88SDave Martin static inline int bL_switcher_trace_trigger(void) { return 0; }
bL_switcher_get_logical_index(u32 mpidr)71d08e2e09SDave Martin static inline int bL_switcher_get_logical_index(u32 mpidr) { return -EUNATCH; }
72491990e2SDave Martin #endif /* CONFIG_BL_SWITCHER */
73491990e2SDave Martin
741c33be57SNicolas Pitre #endif
75