blob: 909082d4c0210968f6831dafa4eb3e7e5e135abc [file] [log] [blame]
Sridhar Parasuramd75ade52015-03-09 15:45:16 -07001/* Copyright (c) 2014-2015, 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 Fundation, Inc. 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#include <stdlib.h>
30#include <regulator.h>
31#include <rpm-ipc.h>
32#include <bits.h>
33
34static uint32_t ldo2[][11]=
35{
36 {
37 LDOA_RES_TYPE, 2,
38 KEY_SOFTWARE_ENABLE, 4, GENERIC_DISABLE,
39 KEY_MICRO_VOLT, 4, 0,
40 KEY_CURRENT, 4, 0,
41 },
42
43 {
44 LDOA_RES_TYPE, 2,
45 KEY_SOFTWARE_ENABLE, 4, GENERIC_ENABLE,
46 KEY_MICRO_VOLT, 4, 1250000,
47 KEY_CURRENT, 4, 16,
48 },
49};
50
51static uint32_t ldo14[][11]=
52{
53 {
54 LDOA_RES_TYPE, 14,
55 KEY_SOFTWARE_ENABLE, 4, GENERIC_DISABLE,
56 KEY_MICRO_VOLT, 4, 0,
57 KEY_CURRENT, 4, 0,
58 },
59
60 {
61 LDOA_RES_TYPE, 14,
62 KEY_SOFTWARE_ENABLE, 4, GENERIC_ENABLE,
63 KEY_MICRO_VOLT, 4, 1800000,
64 KEY_CURRENT, 4, 52,
65 },
66};
67
68static uint32_t ldo28[][14]=
69{
70 {
71 LDOA_RES_TYPE, 28,
72 KEY_SOFTWARE_ENABLE, 4, GENERIC_DISABLE,
73 KEY_MICRO_VOLT, 4, 0,
74 KEY_CURRENT, 4, 0,
75 },
76
77 {
78 LDOA_RES_TYPE, 28,
79 KEY_SOFTWARE_ENABLE, 4, GENERIC_ENABLE,
80 KEY_MICRO_VOLT, 4, 1000000,
81 KEY_CURRENT, 4, 72,
82 },
83
84};
85
86void regulator_enable(uint32_t enable)
87{
88 if (enable & REG_LDO2)
89 rpm_send_data(&ldo2[GENERIC_ENABLE][0], 36, RPM_REQUEST_TYPE);
90
91 if (enable & REG_LDO14)
92 rpm_send_data(&ldo14[GENERIC_ENABLE][0], 36, RPM_REQUEST_TYPE);
93
94 if (enable & REG_LDO28)
95 rpm_send_data(&ldo28[GENERIC_ENABLE][0], 36, RPM_REQUEST_TYPE);
96}
97
98void regulator_disable(uint32_t enable)
99{
100 if (enable & REG_LDO2)
101 rpm_send_data(&ldo2[GENERIC_DISABLE][0], 36, RPM_REQUEST_TYPE);
102
103 if (enable & REG_LDO14)
104 rpm_send_data(&ldo14[GENERIC_DISABLE][0], 36, RPM_REQUEST_TYPE);
105
106 if (enable & REG_LDO28)
107 rpm_send_data(&ldo28[GENERIC_DISABLE][0], 36, RPM_REQUEST_TYPE);
108}