Sridhar Parasuram | 71ed5c7 | 2015-02-05 10:00:12 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2014-2015, The Linux Foundation. All rights reserved. |
Aparna Mallavarapu | 31dea15 | 2014-09-24 11:50:36 +0530 | [diff] [blame] | 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 | |
| 30 | #include <regulator.h> |
Sridhar Parasuram | 71ed5c7 | 2015-02-05 10:00:12 -0800 | [diff] [blame] | 31 | #include <rpm-ipc.h> |
Casey Piper | d2af07b | 2015-04-01 18:01:58 -0700 | [diff] [blame] | 32 | #include <bits.h> |
| 33 | #include <debug.h> |
Aparna Mallavarapu | 31dea15 | 2014-09-24 11:50:36 +0530 | [diff] [blame] | 34 | |
| 35 | static uint32_t ldo2[][11]= |
| 36 | { |
| 37 | { |
| 38 | LDOA_RES_TYPE, 2, |
| 39 | KEY_SOFTWARE_ENABLE, 4, GENERIC_DISABLE, |
Aparna Mallavarapu | 31dea15 | 2014-09-24 11:50:36 +0530 | [diff] [blame] | 40 | KEY_MICRO_VOLT, 4, 0, |
Aparna Mallavarapu | 2944a87 | 2014-11-20 22:35:49 +0530 | [diff] [blame] | 41 | KEY_CURRENT, 4, 0, |
Aparna Mallavarapu | 31dea15 | 2014-09-24 11:50:36 +0530 | [diff] [blame] | 42 | }, |
| 43 | |
| 44 | { |
| 45 | LDOA_RES_TYPE, 2, |
| 46 | KEY_SOFTWARE_ENABLE, 4, GENERIC_ENABLE, |
Aparna Mallavarapu | 31dea15 | 2014-09-24 11:50:36 +0530 | [diff] [blame] | 47 | KEY_MICRO_VOLT, 4, 1250000, |
Aparna Mallavarapu | 2944a87 | 2014-11-20 22:35:49 +0530 | [diff] [blame] | 48 | KEY_CURRENT, 4, 16, |
Aparna Mallavarapu | 31dea15 | 2014-09-24 11:50:36 +0530 | [diff] [blame] | 49 | }, |
| 50 | }; |
| 51 | |
| 52 | static uint32_t ldo12[][11]= |
| 53 | { |
| 54 | { |
| 55 | LDOA_RES_TYPE, 12, |
| 56 | KEY_SOFTWARE_ENABLE, 4, GENERIC_DISABLE, |
Aparna Mallavarapu | 31dea15 | 2014-09-24 11:50:36 +0530 | [diff] [blame] | 57 | KEY_MICRO_VOLT, 4, 0, |
Aparna Mallavarapu | 2944a87 | 2014-11-20 22:35:49 +0530 | [diff] [blame] | 58 | KEY_CURRENT, 4, 0, |
Aparna Mallavarapu | 31dea15 | 2014-09-24 11:50:36 +0530 | [diff] [blame] | 59 | }, |
| 60 | |
| 61 | { |
| 62 | LDOA_RES_TYPE, 12, |
| 63 | KEY_SOFTWARE_ENABLE, 4, GENERIC_ENABLE, |
Aparna Mallavarapu | 31dea15 | 2014-09-24 11:50:36 +0530 | [diff] [blame] | 64 | KEY_MICRO_VOLT, 4, 1800000, |
Aparna Mallavarapu | 2944a87 | 2014-11-20 22:35:49 +0530 | [diff] [blame] | 65 | KEY_CURRENT, 4, 11, |
Aparna Mallavarapu | 31dea15 | 2014-09-24 11:50:36 +0530 | [diff] [blame] | 66 | }, |
| 67 | }; |
| 68 | |
| 69 | static uint32_t ldo14[][11]= |
| 70 | { |
| 71 | { |
| 72 | LDOA_RES_TYPE, 14, |
| 73 | KEY_SOFTWARE_ENABLE, 4, GENERIC_DISABLE, |
Aparna Mallavarapu | 31dea15 | 2014-09-24 11:50:36 +0530 | [diff] [blame] | 74 | KEY_MICRO_VOLT, 4, 0, |
Aparna Mallavarapu | 2944a87 | 2014-11-20 22:35:49 +0530 | [diff] [blame] | 75 | KEY_CURRENT, 4, 0, |
Aparna Mallavarapu | 31dea15 | 2014-09-24 11:50:36 +0530 | [diff] [blame] | 76 | }, |
| 77 | |
| 78 | { |
| 79 | LDOA_RES_TYPE, 14, |
| 80 | KEY_SOFTWARE_ENABLE, 4, GENERIC_ENABLE, |
Aparna Mallavarapu | 31dea15 | 2014-09-24 11:50:36 +0530 | [diff] [blame] | 81 | KEY_MICRO_VOLT, 4, 1800000, |
Aparna Mallavarapu | 2944a87 | 2014-11-20 22:35:49 +0530 | [diff] [blame] | 82 | KEY_CURRENT, 4, 52, |
Aparna Mallavarapu | 31dea15 | 2014-09-24 11:50:36 +0530 | [diff] [blame] | 83 | }, |
| 84 | }; |
| 85 | |
Aparna Mallavarapu | 2944a87 | 2014-11-20 22:35:49 +0530 | [diff] [blame] | 86 | static uint32_t ldo28[][14]= |
Aparna Mallavarapu | 31dea15 | 2014-09-24 11:50:36 +0530 | [diff] [blame] | 87 | { |
| 88 | { |
| 89 | LDOA_RES_TYPE, 28, |
| 90 | KEY_SOFTWARE_ENABLE, 4, GENERIC_DISABLE, |
Aparna Mallavarapu | 31dea15 | 2014-09-24 11:50:36 +0530 | [diff] [blame] | 91 | KEY_MICRO_VOLT, 4, 0, |
Aparna Mallavarapu | 2944a87 | 2014-11-20 22:35:49 +0530 | [diff] [blame] | 92 | KEY_CURRENT, 4, 0, |
Aparna Mallavarapu | 31dea15 | 2014-09-24 11:50:36 +0530 | [diff] [blame] | 93 | }, |
| 94 | |
| 95 | { |
| 96 | LDOA_RES_TYPE, 28, |
| 97 | KEY_SOFTWARE_ENABLE, 4, GENERIC_ENABLE, |
Aparna Mallavarapu | 31dea15 | 2014-09-24 11:50:36 +0530 | [diff] [blame] | 98 | KEY_MICRO_VOLT, 4, 1000000, |
Aparna Mallavarapu | 2944a87 | 2014-11-20 22:35:49 +0530 | [diff] [blame] | 99 | KEY_CURRENT, 4, 72, |
Aparna Mallavarapu | 31dea15 | 2014-09-24 11:50:36 +0530 | [diff] [blame] | 100 | }, |
| 101 | |
| 102 | }; |
| 103 | |
Casey Piper | d2af07b | 2015-04-01 18:01:58 -0700 | [diff] [blame] | 104 | void regulator_enable(uint32_t enable) |
Aparna Mallavarapu | 31dea15 | 2014-09-24 11:50:36 +0530 | [diff] [blame] | 105 | { |
Casey Piper | d2af07b | 2015-04-01 18:01:58 -0700 | [diff] [blame] | 106 | if (enable & REG_LDO2) |
| 107 | rpm_send_data(&ldo2[GENERIC_ENABLE][0], 36, RPM_REQUEST_TYPE); |
Aparna Mallavarapu | 31dea15 | 2014-09-24 11:50:36 +0530 | [diff] [blame] | 108 | |
Casey Piper | d2af07b | 2015-04-01 18:01:58 -0700 | [diff] [blame] | 109 | if (enable & REG_LDO12) |
| 110 | rpm_send_data(&ldo12[GENERIC_ENABLE][0], 36, RPM_REQUEST_TYPE); |
Aparna Mallavarapu | 31dea15 | 2014-09-24 11:50:36 +0530 | [diff] [blame] | 111 | |
Casey Piper | d2af07b | 2015-04-01 18:01:58 -0700 | [diff] [blame] | 112 | if (enable & REG_LDO14) |
| 113 | rpm_send_data(&ldo14[GENERIC_ENABLE][0], 36, RPM_REQUEST_TYPE); |
Aparna Mallavarapu | 31dea15 | 2014-09-24 11:50:36 +0530 | [diff] [blame] | 114 | |
Casey Piper | d2af07b | 2015-04-01 18:01:58 -0700 | [diff] [blame] | 115 | if (enable & REG_LDO28) |
| 116 | rpm_send_data(&ldo28[GENERIC_ENABLE][0], 36, RPM_REQUEST_TYPE); |
Aparna Mallavarapu | 31dea15 | 2014-09-24 11:50:36 +0530 | [diff] [blame] | 117 | } |
| 118 | |
Casey Piper | d2af07b | 2015-04-01 18:01:58 -0700 | [diff] [blame] | 119 | void regulator_disable(uint32_t enable) |
Aparna Mallavarapu | 31dea15 | 2014-09-24 11:50:36 +0530 | [diff] [blame] | 120 | { |
Casey Piper | d2af07b | 2015-04-01 18:01:58 -0700 | [diff] [blame] | 121 | if (enable & REG_LDO2) |
| 122 | rpm_send_data(&ldo2[GENERIC_DISABLE][0], 36, RPM_REQUEST_TYPE); |
Aparna Mallavarapu | 31dea15 | 2014-09-24 11:50:36 +0530 | [diff] [blame] | 123 | |
Casey Piper | d2af07b | 2015-04-01 18:01:58 -0700 | [diff] [blame] | 124 | 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 Mallavarapu | 31dea15 | 2014-09-24 11:50:36 +0530 | [diff] [blame] | 132 | } |