blob: ccdce0b4560e2d4f45600be66f145c976dd054fd [file] [log] [blame]
Jayant Shekhar81d3b652016-01-19 12:49:30 +05301/* Copyright (c) 2016, The Linux Foundation. All rights reserved.
2 *
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are
5 * met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above
9 * copyright notice, this list of conditions and the following
10 * disclaimer in the documentation and/or other materials provided
11 * with the distribution.
12 * * Neither the name of The Linux Foundation nor the names of its
13 * contributors may be used to endorse or promote products derived
14 * from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 */
29
30#include <regulator.h>
31#include <rpm-smd.h>
32#include <bits.h>
33#include <debug.h>
34#include <platform.h>
35
36
37static uint32_t smps3[][11]=
38{
39 {
40 SMPS_RES_TYPE, 3,
41 KEY_SOFTWARE_ENABLE, 4, GENERIC_DISABLE,
42 KEY_MICRO_VOLT, 4, 0,
43 KEY_CURRENT, 4, 0,
44 },
45
46 {
47 SMPS_RES_TYPE, 3,
48 KEY_SOFTWARE_ENABLE, 4, GENERIC_ENABLE,
49 KEY_MICRO_VOLT, 4, 1225000,
50 KEY_CURRENT, 4, 19,
51 },
52};
53
54static uint32_t ldo3[][11]=
55{
56 {
57 LDOA_RES_TYPE, 3,
58 KEY_SOFTWARE_ENABLE, 4, GENERIC_DISABLE,
59 KEY_MICRO_VOLT, 4, 0,
60 KEY_CURRENT, 4, 0,
61 },
62
63 {
64 LDOA_RES_TYPE, 3,
65 KEY_SOFTWARE_ENABLE, 4, GENERIC_ENABLE,
66 KEY_MICRO_VOLT, 4, 925000,
67 KEY_CURRENT, 4, 17,
68 },
69};
70
71static uint32_t ldo6[][11]=
72{
73 {
74 LDOA_RES_TYPE, 6,
75 KEY_SOFTWARE_ENABLE, 4, GENERIC_DISABLE,
76 KEY_MICRO_VOLT, 4, 0,
77 KEY_CURRENT, 4, 0,
78 },
79
80 {
81 LDOA_RES_TYPE, 6,
82 KEY_SOFTWARE_ENABLE, 4, GENERIC_ENABLE,
83 KEY_MICRO_VOLT, 4, 1800000,
84 KEY_CURRENT, 4, 100,
85 },
86};
87
88
89static uint32_t ldo17[][11]=
90{
91 {
92 LDOA_RES_TYPE, 17,
93 KEY_SOFTWARE_ENABLE, 4, GENERIC_DISABLE,
94 KEY_MICRO_VOLT, 4, 0,
95 KEY_CURRENT, 4, 0,
96 },
97
98 {
99 LDOA_RES_TYPE, 17,
100 KEY_SOFTWARE_ENABLE, 4, GENERIC_ENABLE,
101 KEY_MICRO_VOLT, 4, 2850000,
102 KEY_CURRENT, 4, 100,
103 },
104};
105
106void regulator_enable(uint32_t enable)
107{
108 if (enable & REG_LDO3)
109 rpm_send_data(&ldo3[GENERIC_ENABLE][0], 36, RPM_REQUEST_TYPE);
110
111 if (enable & REG_LDO17)
112 rpm_send_data(&ldo17[GENERIC_ENABLE][0], 36, RPM_REQUEST_TYPE);
113
114 if (enable & REG_LDO6)
115 rpm_send_data(&ldo6[GENERIC_ENABLE][0], 36, RPM_REQUEST_TYPE);
116
117 if (enable & REG_SMPS3)
118 rpm_send_data(&smps3[GENERIC_ENABLE][0], 36, RPM_REQUEST_TYPE);
119}
120
121void regulator_disable(uint32_t enable)
122{
123 if (enable & REG_LDO3)
124 rpm_send_data(&ldo3[GENERIC_DISABLE][0], 36, RPM_REQUEST_TYPE);
125
126 if (enable & REG_LDO17)
127 rpm_send_data(&ldo17[GENERIC_DISABLE][0], 36, RPM_REQUEST_TYPE);
128
129 if (enable & REG_LDO6)
130 rpm_send_data(&ldo6[GENERIC_DISABLE][0], 36, RPM_REQUEST_TYPE);
131
132 if (enable & REG_SMPS3)
133 rpm_send_data(&smps3[GENERIC_DISABLE][0], 36, RPM_REQUEST_TYPE);
134}