Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2011, Code Aurora Forum. All rights reserved. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License version 2 and |
| 6 | * only version 2 as published by the Free Software Foundation. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | */ |
| 13 | |
| 14 | #ifndef __MFD_PM8XXX_MISC_H__ |
| 15 | #define __MFD_PM8XXX_MISC_H__ |
| 16 | |
| 17 | #include <linux/err.h> |
| 18 | |
| 19 | #define PM8XXX_MISC_DEV_NAME "pm8xxx-misc" |
| 20 | |
| 21 | /** |
| 22 | * struct pm8xxx_misc_platform_data - PM8xxx misc driver platform data |
| 23 | * @priority: PMIC prority level in a multi-PMIC system. Lower value means |
| 24 | * greater priority. Actions are performed from highest to lowest |
| 25 | * priority PMIC. |
| 26 | */ |
| 27 | struct pm8xxx_misc_platform_data { |
| 28 | int priority; |
| 29 | }; |
| 30 | |
Anirudh Ghayal | 5213eb8 | 2011-10-24 14:44:58 +0530 | [diff] [blame] | 31 | enum pm8xxx_uart_path_sel { |
| 32 | UART_NONE, |
| 33 | UART_TX1_RX1, |
| 34 | UART_TX2_RX2, |
| 35 | UART_TX3_RX3, |
| 36 | }; |
| 37 | |
Anirudh Ghayal | 7b38229 | 2011-11-01 14:08:34 +0530 | [diff] [blame] | 38 | enum pm8xxx_coincell_chg_voltage { |
| 39 | PM8XXX_COINCELL_VOLTAGE_3p2V = 1, |
| 40 | PM8XXX_COINCELL_VOLTAGE_3p1V, |
| 41 | PM8XXX_COINCELL_VOLTAGE_3p0V, |
| 42 | PM8XXX_COINCELL_VOLTAGE_2p5V = 16 |
| 43 | }; |
| 44 | |
| 45 | enum pm8xxx_coincell_chg_resistor { |
| 46 | PM8XXX_COINCELL_RESISTOR_2100_OHMS, |
| 47 | PM8XXX_COINCELL_RESISTOR_1700_OHMS, |
| 48 | PM8XXX_COINCELL_RESISTOR_1200_OHMS, |
| 49 | PM8XXX_COINCELL_RESISTOR_800_OHMS |
| 50 | }; |
| 51 | |
| 52 | enum pm8xxx_coincell_chg_state { |
| 53 | PM8XXX_COINCELL_CHG_DISABLE, |
| 54 | PM8XXX_COINCELL_CHG_ENABLE |
| 55 | }; |
| 56 | |
| 57 | struct pm8xxx_coincell_chg { |
| 58 | enum pm8xxx_coincell_chg_state state; |
| 59 | enum pm8xxx_coincell_chg_voltage voltage; |
| 60 | enum pm8xxx_coincell_chg_resistor resistor; |
| 61 | }; |
| 62 | |
Anirudh Ghayal | bfbaf82 | 2011-11-01 14:28:34 +0530 | [diff] [blame] | 63 | enum pm8xxx_smpl_delay { |
| 64 | PM8XXX_SMPL_DELAY_0p5, |
| 65 | PM8XXX_SMPL_DELAY_1p0, |
| 66 | PM8XXX_SMPL_DELAY_1p5, |
| 67 | PM8XXX_SMPL_DELAY_2p0, |
| 68 | }; |
| 69 | |
Anirudh Ghayal | a4262a3 | 2011-11-10 00:02:18 +0530 | [diff] [blame] | 70 | enum pm8xxx_pon_config { |
| 71 | PM8XXX_DISABLE_HARD_RESET = 0, |
| 72 | PM8XXX_SHUTDOWN_ON_HARD_RESET, |
| 73 | PM8XXX_RESTART_ON_HARD_RESET, |
| 74 | }; |
| 75 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 76 | #if defined(CONFIG_MFD_PM8XXX_MISC) || defined(CONFIG_MFD_PM8XXX_MISC_MODULE) |
| 77 | |
| 78 | /** |
| 79 | * pm8xxx_reset_pwr_off - switch all PM8XXX PMIC chips attached to the system to |
| 80 | * either reset or shutdown when they are turned off |
| 81 | * @reset: 0 = shudown the PMICs, 1 = shutdown and then restart the PMICs |
| 82 | * |
| 83 | * RETURNS: an appropriate -ERRNO error value on error, or zero for success. |
| 84 | */ |
| 85 | int pm8xxx_reset_pwr_off(int reset); |
| 86 | |
Anirudh Ghayal | 5213eb8 | 2011-10-24 14:44:58 +0530 | [diff] [blame] | 87 | int pm8xxx_uart_gpio_mux_ctrl(enum pm8xxx_uart_path_sel uart_path_sel); |
| 88 | |
Anirudh Ghayal | 7b38229 | 2011-11-01 14:08:34 +0530 | [diff] [blame] | 89 | /** |
| 90 | * pm8xxx_coincell_chg_config - Disables or enables the coincell charger, and |
| 91 | * configures its voltage and resistor settings. |
| 92 | * @chg_config: Holds both voltage and resistor values, and a |
| 93 | * switch to change the state of charger. |
| 94 | * If state is to disable the charger then |
| 95 | * both voltage and resistor are disregarded. |
| 96 | * |
| 97 | * RETURNS: an appropriate -ERRNO error value on error, or zero for success. |
| 98 | */ |
| 99 | int pm8xxx_coincell_chg_config(struct pm8xxx_coincell_chg *chg_config); |
| 100 | |
Anirudh Ghayal | bfbaf82 | 2011-11-01 14:28:34 +0530 | [diff] [blame] | 101 | /** |
| 102 | * pm8xxx_smpl_control - enables/disables SMPL detection |
| 103 | * @enable: 0 = shutdown PMIC on power loss, 1 = reset PMIC on power loss |
| 104 | * |
| 105 | * This function enables or disables the Sudden Momentary Power Loss detection |
| 106 | * module. If SMPL detection is enabled, then when a sufficiently long power |
| 107 | * loss event occurs, the PMIC will automatically reset itself. If SMPL |
| 108 | * detection is disabled, then the PMIC will shutdown when power loss occurs. |
| 109 | * |
| 110 | * RETURNS: an appropriate -ERRNO error value on error, or zero for success. |
| 111 | */ |
| 112 | int pm8xxx_smpl_control(int enable); |
| 113 | |
| 114 | /** |
| 115 | * pm8xxx_smpl_set_delay - sets the SMPL detection time delay |
| 116 | * @delay: enum value corresponding to delay time |
| 117 | * |
| 118 | * This function sets the time delay of the SMPL detection module. If power |
| 119 | * is reapplied within this interval, then the PMIC reset automatically. The |
| 120 | * SMPL detection module must be enabled for this delay time to take effect. |
| 121 | * |
| 122 | * RETURNS: an appropriate -ERRNO error value on error, or zero for success. |
| 123 | */ |
| 124 | int pm8xxx_smpl_set_delay(enum pm8xxx_smpl_delay delay); |
| 125 | |
Anirudh Ghayal | a23c1ca | 2011-11-01 14:36:24 +0530 | [diff] [blame] | 126 | /** |
| 127 | * pm8xxx_watchdog_reset_control - enables/disables watchdog reset detection |
| 128 | * @enable: 0 = shutdown when PS_HOLD goes low, 1 = reset when PS_HOLD goes low |
| 129 | * |
| 130 | * This function enables or disables the PMIC watchdog reset detection feature. |
| 131 | * If watchdog reset detection is enabled, then the PMIC will reset itself |
| 132 | * when PS_HOLD goes low. If it is not enabled, then the PMIC will shutdown |
| 133 | * when PS_HOLD goes low. |
| 134 | * |
| 135 | * RETURNS: an appropriate -ERRNO error value on error, or zero for success. |
| 136 | */ |
| 137 | int pm8xxx_watchdog_reset_control(int enable); |
| 138 | |
Anirudh Ghayal | a4262a3 | 2011-11-10 00:02:18 +0530 | [diff] [blame] | 139 | /** |
| 140 | * pm8xxx_hard_reset_config - Allows different reset configurations |
| 141 | * |
| 142 | * config = DISABLE_HARD_RESET to disable hard reset |
| 143 | * = SHUTDOWN_ON_HARD_RESET to turn off the system on hard reset |
| 144 | * = RESTART_ON_HARD_RESET to restart the system on hard reset |
| 145 | * |
| 146 | * RETURNS: an appropriate -ERRNO error value on error, or zero for success. |
| 147 | */ |
| 148 | int pm8xxx_hard_reset_config(enum pm8xxx_pon_config config); |
| 149 | |
Anirudh Ghayal | 51e947f | 2011-11-01 14:49:45 +0530 | [diff] [blame] | 150 | /** |
| 151 | * pm8xxx_stay_on - enables stay_on feature |
| 152 | * |
| 153 | * PMIC stay-on feature allows PMIC to ignore MSM PS_HOLD=low |
| 154 | * signal so that some special functions like debugging could be |
| 155 | * performed. |
| 156 | * |
| 157 | * This feature should not be used in any product release. |
| 158 | * |
| 159 | * RETURNS: an appropriate -ERRNO error value on error, or zero for success. |
| 160 | */ |
| 161 | int pm8xxx_stay_on(void); |
| 162 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 163 | #else |
| 164 | |
| 165 | static inline int pm8xxx_reset_pwr_off(int reset) |
| 166 | { |
| 167 | return -ENODEV; |
| 168 | } |
Anirudh Ghayal | 5213eb8 | 2011-10-24 14:44:58 +0530 | [diff] [blame] | 169 | static inline int |
| 170 | pm8xxx_uart_gpio_mux_ctrl(enum pm8xxx_uart_path_sel uart_path_sel) |
| 171 | { |
| 172 | return -ENODEV; |
| 173 | } |
Anirudh Ghayal | 7b38229 | 2011-11-01 14:08:34 +0530 | [diff] [blame] | 174 | static inline int |
| 175 | pm8xxx_coincell_chg_config(struct pm8xxx_coincell_chg *chg_config) |
| 176 | { |
| 177 | return -ENODEV; |
| 178 | } |
Anirudh Ghayal | bfbaf82 | 2011-11-01 14:28:34 +0530 | [diff] [blame] | 179 | static inline int pm8xxx_smpl_set_delay(enum pm8xxx_smpl_delay delay) |
| 180 | { |
| 181 | return -ENODEV; |
| 182 | } |
| 183 | static inline int pm8xxx_smpl_control(int enable) |
| 184 | { |
| 185 | return -ENODEV; |
| 186 | } |
Anirudh Ghayal | a23c1ca | 2011-11-01 14:36:24 +0530 | [diff] [blame] | 187 | static inline int pm8xxx_watchdog_reset_control(int enable) |
| 188 | { |
| 189 | return -ENODEV; |
| 190 | } |
Anirudh Ghayal | a4262a3 | 2011-11-10 00:02:18 +0530 | [diff] [blame] | 191 | static inline int pm8xxx_hard_reset_config(enum pm8xxx_pon_config config) |
| 192 | { |
| 193 | return -ENODEV; |
| 194 | } |
Anirudh Ghayal | 51e947f | 2011-11-01 14:49:45 +0530 | [diff] [blame] | 195 | static inline int pm8xxx_stay_on(void) |
| 196 | { |
| 197 | return -ENODEV; |
| 198 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 199 | #endif |
| 200 | |
| 201 | #endif |