summaryrefstree
path: root/kernel/arch/arm64/mach-exynos/include/mach/exynos-powermode-smp.h
blob: 0ed79de5d056d7f4b2d3e1fe87bbafe090be98ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
 *		http://www.samsung.com/
 *
 * EXYNOS - PMU(Power Management Unit) support
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
*/

#ifndef __EXYNOS_POWERMODE_SMP_H
#define __EXYNOS_POWERMODE_SMP_H __FILE__

#include <asm/io.h>

enum sys_powerdown {
	SYS_AFTR,
	SYS_DSTOP,
	SYS_DSTOP_PSR,
	SYS_LPD,
	SYS_LPA,
	SYS_CP_CALL,
	SYS_SLEEP,
	NUM_SYS_POWERDOWN,
	/* Not used, only for compatiblity */
	SYS_ALPA,
};

struct exynos_pmu_conf {
	void __iomem *reg;
	unsigned int val[NUM_SYS_POWERDOWN];
};

/* power mode check flag */
#define EXYNOS_CHECK_SLEEP	0x00000BAD

#define MAX_NUM_REGS		20

struct hw_info {
	void __iomem *addr;
	unsigned int mask;
	unsigned int val;
};

#define HW_INFO_ALL(_addr, _mask, _val) \
{					\
	.addr = _addr,			\
	.mask = _mask,			\
	.val = _val,			\
}

#define HW_INFO_ADDR(_addr)		\
{					\
	.addr = _addr,			\
}

static inline void set_hw(struct hw_info *regs, int unsigned num)
{
	unsigned int tmp;

	while (num--) {
		tmp  = __raw_readl(regs[num].addr);
		tmp &= ~(regs[num].mask);
		tmp |= regs[num].val;
		__raw_writel(tmp, regs[num].addr);
	}
}

static inline void save_hw_status(struct hw_info *regs, unsigned int num)
{
	while (num--)
		regs[num].val = __raw_readl(regs[num].addr);
}

static inline void restore_hw_status(struct hw_info *regs, unsigned int num)
{
	while (num--)
		__raw_writel(regs[num].val, regs[num].addr);
}

static inline int check_hw_status(struct hw_info *regs, unsigned int num)
{
	while (num--)
		if (__raw_readl(regs[num].addr) & regs[num].mask)
			return -EBUSY;

	return 0;
}

#if defined(CONFIG_PWM_SAMSUNG)
extern int pwm_check_enable_cnt(void);
#else
static int pwm_check_enable_cnt(void)
{
	return 0;
}
#endif

#ifdef CONFIG_SERIAL_SAMSUNG
extern void s3c24xx_serial_fifo_wait(void);
#else
static void s3c24xx_serial_fifo_wait(void)
{
}
#endif

extern int determine_lpm(void);
extern int determine_cpd(int index, int c2_index, unsigned int cpu,
			 unsigned int target_residency);
extern void wakeup_from_c2(unsigned int cpu);

/* system power down function */
extern void exynos_prepare_sys_powerdown(enum sys_powerdown mode);
extern void exynos_wakeup_sys_powerdown(enum sys_powerdown mode,
					bool early_wakeup);
extern bool exynos_sys_powerdown_enabled(void);

#endif /* __EXYNOS_POWERMODE_SMP_H */