blob: 5be7a2824810c9ca94cac5d7547a4a243446e7b4 [file] [log] [blame]
Deepak Katragadda575a45f2016-10-11 15:06:56 -07001/*
2 * Copyright (c) 2016, The Linux Foundation. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and
6 * only version 2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13
14#ifndef __DRIVERS_CLK_QCOM_VDD_LEVEL_COBALT_H
15#define __DRIVERS_CLK_QCOM_VDD_LEVEL_COBALT_H
16
17#include <linux/regulator/consumer.h>
18#include <dt-bindings/regulator/qcom,rpmh-regulator.h>
19
20#define VDD_CX_FMAX_MAP1(l1, f1) \
21 .vdd_class = &vdd_cx, \
22 .rate_max = (unsigned long[VDD_CX_NUM]) { \
23 [VDD_CX_##l1] = (f1), \
24 }, \
25 .num_rate_max = VDD_CX_NUM
26
27#define VDD_CX_FMAX_MAP2(l1, f1, l2, f2) \
28 .vdd_class = &vdd_cx, \
29 .rate_max = (unsigned long[VDD_CX_NUM]) { \
30 [VDD_CX_##l1] = (f1), \
31 [VDD_CX_##l2] = (f2), \
32 }, \
33 .num_rate_max = VDD_CX_NUM
34
35#define VDD_CX_FMAX_MAP3(l1, f1, l2, f2, l3, f3) \
36 .vdd_class = &vdd_cx, \
37 .rate_max = (unsigned long[VDD_CX_NUM]) { \
38 [VDD_CX_##l1] = (f1), \
39 [VDD_CX_##l2] = (f2), \
40 [VDD_CX_##l3] = (f3), \
41 }, \
42 .num_rate_max = VDD_CX_NUM
43
44#define VDD_CX_FMAX_MAP4(l1, f1, l2, f2, l3, f3, l4, f4) \
45 .vdd_class = &vdd_cx, \
46 .rate_max = (unsigned long[VDD_CX_NUM]) { \
47 [VDD_CX_##l1] = (f1), \
48 [VDD_CX_##l2] = (f2), \
49 [VDD_CX_##l3] = (f3), \
50 [VDD_CX_##l4] = (f4), \
51 }, \
52 .num_rate_max = VDD_CX_NUM
53
54#define VDD_CX_FMAX_MAP5(l1, f1, l2, f2, l3, f3, l4, f4, l5, f5) \
55 .vdd_class = &vdd_cx, \
56 .rate_max = (unsigned long[VDD_CX_NUM]) { \
57 [VDD_CX_##l1] = (f1), \
58 [VDD_CX_##l2] = (f2), \
59 [VDD_CX_##l3] = (f3), \
60 [VDD_CX_##l4] = (f4), \
61 [VDD_CX_##l5] = (f5), \
62 }, \
63 .num_rate_max = VDD_CX_NUM
64
65#define VDD_CX_FMAX_MAP6(l1, f1, l2, f2, l3, f3, l4, f4, l5, f5, l6, f6) \
66 .vdd_class = &vdd_cx, \
67 .rate_max = (unsigned long[VDD_CX_NUM]) { \
68 [VDD_CX_##l1] = (f1), \
69 [VDD_CX_##l2] = (f2), \
70 [VDD_CX_##l3] = (f3), \
71 [VDD_CX_##l4] = (f4), \
72 [VDD_CX_##l5] = (f5), \
73 [VDD_CX_##l6] = (f6), \
74 }, \
75 .num_rate_max = VDD_CX_NUM
76
77#define VDD_CX_FMAX_MAP1_AO(l1, f1) \
78 .vdd_class = &vdd_cx_ao, \
79 .rate_max = (unsigned long[VDD_CX_NUM]) { \
80 [VDD_CX_##l1] = (f1), \
81 }, \
82 .num_rate_max = VDD_CX_NUM
83
84#define VDD_CX_FMAX_MAP3_AO(l1, f1, l2, f2, l3, f3) \
85 .vdd_class = &vdd_cx_ao, \
86 .rate_max = (unsigned long[VDD_CX_NUM]) { \
87 [VDD_CX_##l1] = (f1), \
88 [VDD_CX_##l2] = (f2), \
89 [VDD_CX_##l3] = (f3), \
90 }, \
91 .num_rate_max = VDD_CX_NUM
92
93
94enum vdd_cx_levels {
95 VDD_CX_NONE,
96 VDD_CX_MIN, /* MIN SVS */
97 VDD_CX_LOWER, /* SVS2 */
98 VDD_CX_LOW, /* SVS */
99 VDD_CX_LOW_L1, /* SVSL1 */
100 VDD_CX_NOMINAL, /* NOM */
101 VDD_CX_HIGH, /* TURBO */
102 VDD_CX_NUM,
103};
104
105/* Need to use the correct VI/VL mappings */
106static int vdd_corner[] = {
107 RPMH_REGULATOR_LEVEL_OFF, /* VDD_CX_NONE */
108 RPMH_REGULATOR_LEVEL_MIN_SVS, /* VDD_CX_MIN */
109 RPMH_REGULATOR_LEVEL_LOW_SVS, /* VDD_CX_LOWER */
110 RPMH_REGULATOR_LEVEL_SVS, /* VDD_CX_LOW */
111 RPMH_REGULATOR_LEVEL_SVS_L1, /* VDD_CX_LOW_L1 */
112 RPMH_REGULATOR_LEVEL_NOM, /* VDD_CX_NOMINAL */
113 RPMH_REGULATOR_LEVEL_TURBO, /* VDD_CX_HIGH */
114};
115
116#endif