Ajay Singh Parmar | 47252ac | 2015-02-14 13:16:15 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2014-2016, The Linux Foundation. All rights reserved. |
Sridhar Parasuram | d75ade5 | 2015-03-09 15:45:16 -0700 | [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 | #include <stdlib.h> |
| 30 | #include <regulator.h> |
| 31 | #include <rpm-ipc.h> |
| 32 | #include <bits.h> |
| 33 | |
| 34 | static 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 | |
Ajay Singh Parmar | 47252ac | 2015-02-14 13:16:15 -0800 | [diff] [blame] | 51 | static uint32_t ldo12[][11]= |
| 52 | { |
| 53 | { |
| 54 | LDOA_RES_TYPE, 12, |
| 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, 12, |
| 62 | KEY_SOFTWARE_ENABLE, 4, GENERIC_ENABLE, |
| 63 | KEY_MICRO_VOLT, 4, 1800000, |
| 64 | KEY_CURRENT, 4, 11, |
| 65 | }, |
| 66 | }; |
| 67 | |
Sridhar Parasuram | d75ade5 | 2015-03-09 15:45:16 -0700 | [diff] [blame] | 68 | static uint32_t ldo14[][11]= |
| 69 | { |
| 70 | { |
| 71 | LDOA_RES_TYPE, 14, |
| 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, 14, |
| 79 | KEY_SOFTWARE_ENABLE, 4, GENERIC_ENABLE, |
| 80 | KEY_MICRO_VOLT, 4, 1800000, |
| 81 | KEY_CURRENT, 4, 52, |
| 82 | }, |
| 83 | }; |
| 84 | |
| 85 | static uint32_t ldo28[][14]= |
| 86 | { |
| 87 | { |
| 88 | LDOA_RES_TYPE, 28, |
| 89 | KEY_SOFTWARE_ENABLE, 4, GENERIC_DISABLE, |
| 90 | KEY_MICRO_VOLT, 4, 0, |
| 91 | KEY_CURRENT, 4, 0, |
| 92 | }, |
| 93 | |
| 94 | { |
| 95 | LDOA_RES_TYPE, 28, |
| 96 | KEY_SOFTWARE_ENABLE, 4, GENERIC_ENABLE, |
| 97 | KEY_MICRO_VOLT, 4, 1000000, |
| 98 | KEY_CURRENT, 4, 72, |
| 99 | }, |
| 100 | |
| 101 | }; |
| 102 | |
| 103 | void regulator_enable(uint32_t enable) |
| 104 | { |
| 105 | if (enable & REG_LDO2) |
| 106 | rpm_send_data(&ldo2[GENERIC_ENABLE][0], 36, RPM_REQUEST_TYPE); |
| 107 | |
Ajay Singh Parmar | 47252ac | 2015-02-14 13:16:15 -0800 | [diff] [blame] | 108 | if (enable & REG_LDO12) |
| 109 | rpm_send_data(&ldo12[GENERIC_ENABLE][0], 36, RPM_REQUEST_TYPE); |
| 110 | |
Sridhar Parasuram | d75ade5 | 2015-03-09 15:45:16 -0700 | [diff] [blame] | 111 | if (enable & REG_LDO14) |
| 112 | rpm_send_data(&ldo14[GENERIC_ENABLE][0], 36, RPM_REQUEST_TYPE); |
| 113 | |
| 114 | if (enable & REG_LDO28) |
| 115 | rpm_send_data(&ldo28[GENERIC_ENABLE][0], 36, RPM_REQUEST_TYPE); |
| 116 | } |
| 117 | |
| 118 | void regulator_disable(uint32_t enable) |
| 119 | { |
| 120 | if (enable & REG_LDO2) |
| 121 | rpm_send_data(&ldo2[GENERIC_DISABLE][0], 36, RPM_REQUEST_TYPE); |
| 122 | |
Ajay Singh Parmar | 47252ac | 2015-02-14 13:16:15 -0800 | [diff] [blame] | 123 | if (enable & REG_LDO12) |
| 124 | rpm_send_data(&ldo12[GENERIC_DISABLE][0], 36, RPM_REQUEST_TYPE); |
| 125 | |
Sridhar Parasuram | d75ade5 | 2015-03-09 15:45:16 -0700 | [diff] [blame] | 126 | if (enable & REG_LDO14) |
| 127 | rpm_send_data(&ldo14[GENERIC_DISABLE][0], 36, RPM_REQUEST_TYPE); |
| 128 | |
| 129 | if (enable & REG_LDO28) |
| 130 | rpm_send_data(&ldo28[GENERIC_DISABLE][0], 36, RPM_REQUEST_TYPE); |
| 131 | } |