blob: 2bf7422fc866a6fabc17cfa479e2517faebf70fc [file] [log] [blame]
Sridhar Parasuram71ed5c72015-02-05 10:00:12 -08001/* Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
Aparna Mallavarapu31dea152014-09-24 11:50:36 +05302 *
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
30#include <regulator.h>
Sridhar Parasuram71ed5c72015-02-05 10:00:12 -080031#include <rpm-ipc.h>
Casey Piperd2af07b2015-04-01 18:01:58 -070032#include <bits.h>
33#include <debug.h>
Aparna Mallavarapu31dea152014-09-24 11:50:36 +053034
35static uint32_t ldo2[][11]=
36{
37 {
38 LDOA_RES_TYPE, 2,
39 KEY_SOFTWARE_ENABLE, 4, GENERIC_DISABLE,
Aparna Mallavarapu31dea152014-09-24 11:50:36 +053040 KEY_MICRO_VOLT, 4, 0,
Aparna Mallavarapu2944a872014-11-20 22:35:49 +053041 KEY_CURRENT, 4, 0,
Aparna Mallavarapu31dea152014-09-24 11:50:36 +053042 },
43
44 {
45 LDOA_RES_TYPE, 2,
46 KEY_SOFTWARE_ENABLE, 4, GENERIC_ENABLE,
Aparna Mallavarapu31dea152014-09-24 11:50:36 +053047 KEY_MICRO_VOLT, 4, 1250000,
Aparna Mallavarapu2944a872014-11-20 22:35:49 +053048 KEY_CURRENT, 4, 16,
Aparna Mallavarapu31dea152014-09-24 11:50:36 +053049 },
50};
51
52static uint32_t ldo12[][11]=
53{
54 {
55 LDOA_RES_TYPE, 12,
56 KEY_SOFTWARE_ENABLE, 4, GENERIC_DISABLE,
Aparna Mallavarapu31dea152014-09-24 11:50:36 +053057 KEY_MICRO_VOLT, 4, 0,
Aparna Mallavarapu2944a872014-11-20 22:35:49 +053058 KEY_CURRENT, 4, 0,
Aparna Mallavarapu31dea152014-09-24 11:50:36 +053059 },
60
61 {
62 LDOA_RES_TYPE, 12,
63 KEY_SOFTWARE_ENABLE, 4, GENERIC_ENABLE,
Aparna Mallavarapu31dea152014-09-24 11:50:36 +053064 KEY_MICRO_VOLT, 4, 1800000,
Aparna Mallavarapu2944a872014-11-20 22:35:49 +053065 KEY_CURRENT, 4, 11,
Aparna Mallavarapu31dea152014-09-24 11:50:36 +053066 },
67};
68
69static uint32_t ldo14[][11]=
70{
71 {
72 LDOA_RES_TYPE, 14,
73 KEY_SOFTWARE_ENABLE, 4, GENERIC_DISABLE,
Aparna Mallavarapu31dea152014-09-24 11:50:36 +053074 KEY_MICRO_VOLT, 4, 0,
Aparna Mallavarapu2944a872014-11-20 22:35:49 +053075 KEY_CURRENT, 4, 0,
Aparna Mallavarapu31dea152014-09-24 11:50:36 +053076 },
77
78 {
79 LDOA_RES_TYPE, 14,
80 KEY_SOFTWARE_ENABLE, 4, GENERIC_ENABLE,
Aparna Mallavarapu31dea152014-09-24 11:50:36 +053081 KEY_MICRO_VOLT, 4, 1800000,
Aparna Mallavarapu2944a872014-11-20 22:35:49 +053082 KEY_CURRENT, 4, 52,
Aparna Mallavarapu31dea152014-09-24 11:50:36 +053083 },
84};
85
Aparna Mallavarapu2944a872014-11-20 22:35:49 +053086static uint32_t ldo28[][14]=
Aparna Mallavarapu31dea152014-09-24 11:50:36 +053087{
88 {
89 LDOA_RES_TYPE, 28,
90 KEY_SOFTWARE_ENABLE, 4, GENERIC_DISABLE,
Aparna Mallavarapu31dea152014-09-24 11:50:36 +053091 KEY_MICRO_VOLT, 4, 0,
Aparna Mallavarapu2944a872014-11-20 22:35:49 +053092 KEY_CURRENT, 4, 0,
Aparna Mallavarapu31dea152014-09-24 11:50:36 +053093 },
94
95 {
96 LDOA_RES_TYPE, 28,
97 KEY_SOFTWARE_ENABLE, 4, GENERIC_ENABLE,
Aparna Mallavarapu31dea152014-09-24 11:50:36 +053098 KEY_MICRO_VOLT, 4, 1000000,
Aparna Mallavarapu2944a872014-11-20 22:35:49 +053099 KEY_CURRENT, 4, 72,
Aparna Mallavarapu31dea152014-09-24 11:50:36 +0530100 },
101
102};
103
Casey Piperd2af07b2015-04-01 18:01:58 -0700104void regulator_enable(uint32_t enable)
Aparna Mallavarapu31dea152014-09-24 11:50:36 +0530105{
Casey Piperd2af07b2015-04-01 18:01:58 -0700106 if (enable & REG_LDO2)
107 rpm_send_data(&ldo2[GENERIC_ENABLE][0], 36, RPM_REQUEST_TYPE);
Aparna Mallavarapu31dea152014-09-24 11:50:36 +0530108
Casey Piperd2af07b2015-04-01 18:01:58 -0700109 if (enable & REG_LDO12)
110 rpm_send_data(&ldo12[GENERIC_ENABLE][0], 36, RPM_REQUEST_TYPE);
Aparna Mallavarapu31dea152014-09-24 11:50:36 +0530111
Casey Piperd2af07b2015-04-01 18:01:58 -0700112 if (enable & REG_LDO14)
113 rpm_send_data(&ldo14[GENERIC_ENABLE][0], 36, RPM_REQUEST_TYPE);
Aparna Mallavarapu31dea152014-09-24 11:50:36 +0530114
Casey Piperd2af07b2015-04-01 18:01:58 -0700115 if (enable & REG_LDO28)
116 rpm_send_data(&ldo28[GENERIC_ENABLE][0], 36, RPM_REQUEST_TYPE);
Aparna Mallavarapu31dea152014-09-24 11:50:36 +0530117}
118
Casey Piperd2af07b2015-04-01 18:01:58 -0700119void regulator_disable(uint32_t enable)
Aparna Mallavarapu31dea152014-09-24 11:50:36 +0530120{
Casey Piperd2af07b2015-04-01 18:01:58 -0700121 if (enable & REG_LDO2)
122 rpm_send_data(&ldo2[GENERIC_DISABLE][0], 36, RPM_REQUEST_TYPE);
Aparna Mallavarapu31dea152014-09-24 11:50:36 +0530123
Casey Piperd2af07b2015-04-01 18:01:58 -0700124 if (enable & REG_LDO12)
125 rpm_send_data(&ldo12[GENERIC_DISABLE][0], 36, RPM_REQUEST_TYPE);
126
127 if (enable & REG_LDO14)
128 rpm_send_data(&ldo14[GENERIC_DISABLE][0], 36, RPM_REQUEST_TYPE);
129
130 if (enable & REG_LDO28)
131 rpm_send_data(&ldo28[GENERIC_DISABLE][0], 36, RPM_REQUEST_TYPE);
Aparna Mallavarapu31dea152014-09-24 11:50:36 +0530132}