diff options
| author | Robby Cai <R63905@freescale.com> | 2013-08-13 22:14:26 -0400 |
|---|---|---|
| committer | Nitin Garg <nitin.garg@freescale.com> | 2014-04-16 09:01:34 -0400 |
| commit | 204ee4b0312a3dcfa84e196f3981d10a9017e462 (patch) | |
| tree | fbfdec23f813858b4fd784eee2e786fd133e6c9e /include/linux | |
| parent | 3133b6cfb31b202805d31d449bfa70383e5e1c75 (diff) | |
ENGR00276832-1 pmic: max17135: port driver codes to 3.10 kernel
It's ported from v3.5.7 kernel, which contains a sensor driver
and regulator driver. It's used for E-Ink panel.
add a parameter for mfd_add_devices() due to the propotype change.
use IS_ERR() to check the return value for devm_regulator_get().
Signed-off-by: Robby Cai <R63905@freescale.com>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/mfd/max17135.h | 220 | ||||
| -rw-r--r-- | include/linux/pmic_status.h | 82 |
2 files changed, 302 insertions, 0 deletions
diff --git a/include/linux/mfd/max17135.h b/include/linux/mfd/max17135.h new file mode 100644 index 000000000000..99c797ae1d57 --- /dev/null +++ b/include/linux/mfd/max17135.h | |||
| @@ -0,0 +1,220 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2010-2013 Freescale Semiconductor, Inc. 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 as published by | ||
| 6 | * the Free Software Foundation; either version 2 of the License, or | ||
| 7 | * (at your option) any later version. | ||
| 8 | * | ||
| 9 | * This program is distributed in the hope that it will be useful, | ||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | * GNU General Public License for more details. | ||
| 13 | * | ||
| 14 | * You should have received a copy of the GNU General Public License | ||
| 15 | * along with this program; if not, write to the Free Software | ||
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 17 | * | ||
| 18 | */ | ||
| 19 | #ifndef __LINUX_REGULATOR_MAX17135_H_ | ||
| 20 | #define __LINUX_REGULATOR_MAX17135_H_ | ||
| 21 | |||
| 22 | /* | ||
| 23 | * PMIC Register Addresses | ||
| 24 | */ | ||
| 25 | enum { | ||
| 26 | REG_MAX17135_EXT_TEMP = 0x0, | ||
| 27 | REG_MAX17135_CONFIG, | ||
| 28 | REG_MAX17135_INT_TEMP = 0x4, | ||
| 29 | REG_MAX17135_STATUS, | ||
| 30 | REG_MAX17135_PRODUCT_REV, | ||
| 31 | REG_MAX17135_PRODUCT_ID, | ||
| 32 | REG_MAX17135_DVR, | ||
| 33 | REG_MAX17135_ENABLE, | ||
| 34 | REG_MAX17135_FAULT, /*0x0A*/ | ||
| 35 | REG_MAX17135_HVINP, | ||
| 36 | REG_MAX17135_PRGM_CTRL, | ||
| 37 | REG_MAX17135_TIMING1 = 0x10, /* Timing regs base address is 0x10 */ | ||
| 38 | REG_MAX17135_TIMING2, | ||
| 39 | REG_MAX17135_TIMING3, | ||
| 40 | REG_MAX17135_TIMING4, | ||
| 41 | REG_MAX17135_TIMING5, | ||
| 42 | REG_MAX17135_TIMING6, | ||
| 43 | REG_MAX17135_TIMING7, | ||
| 44 | REG_MAX17135_TIMING8, | ||
| 45 | }; | ||
| 46 | #define MAX17135_REG_NUM 21 | ||
| 47 | #define MAX17135_MAX_REGISTER 0xFF | ||
| 48 | |||
| 49 | /* | ||
| 50 | * Bitfield macros that use rely on bitfield width/shift information. | ||
| 51 | */ | ||
| 52 | #define BITFMASK(field) (((1U << (field ## _WID)) - 1) << (field ## _LSH)) | ||
| 53 | #define BITFVAL(field, val) ((val) << (field ## _LSH)) | ||
| 54 | #define BITFEXT(var, bit) ((var & BITFMASK(bit)) >> (bit ## _LSH)) | ||
| 55 | |||
| 56 | /* | ||
| 57 | * Shift and width values for each register bitfield | ||
| 58 | */ | ||
| 59 | #define EXT_TEMP_LSH 7 | ||
| 60 | #define EXT_TEMP_WID 9 | ||
| 61 | |||
| 62 | #define THERMAL_SHUTDOWN_LSH 0 | ||
| 63 | #define THERMAL_SHUTDOWN_WID 1 | ||
| 64 | |||
| 65 | #define INT_TEMP_LSH 7 | ||
| 66 | #define INT_TEMP_WID 9 | ||
| 67 | |||
| 68 | #define STAT_BUSY_LSH 0 | ||
| 69 | #define STAT_BUSY_WID 1 | ||
| 70 | #define STAT_OPEN_LSH 1 | ||
| 71 | #define STAT_OPEN_WID 1 | ||
| 72 | #define STAT_SHRT_LSH 2 | ||
| 73 | #define STAT_SHRT_WID 1 | ||
| 74 | |||
| 75 | #define PROD_REV_LSH 0 | ||
| 76 | #define PROD_REV_WID 8 | ||
| 77 | |||
| 78 | #define PROD_ID_LSH 0 | ||
| 79 | #define PROD_ID_WID 8 | ||
| 80 | |||
| 81 | #define DVR_LSH 0 | ||
| 82 | #define DVR_WID 8 | ||
| 83 | |||
| 84 | #define ENABLE_LSH 0 | ||
| 85 | #define ENABLE_WID 1 | ||
| 86 | #define VCOM_ENABLE_LSH 1 | ||
| 87 | #define VCOM_ENABLE_WID 1 | ||
| 88 | |||
| 89 | #define FAULT_FBPG_LSH 0 | ||
| 90 | #define FAULT_FBPG_WID 1 | ||
| 91 | #define FAULT_HVINP_LSH 1 | ||
| 92 | #define FAULT_HVINP_WID 1 | ||
| 93 | #define FAULT_HVINN_LSH 2 | ||
| 94 | #define FAULT_HVINN_WID 1 | ||
| 95 | #define FAULT_FBNG_LSH 3 | ||
| 96 | #define FAULT_FBNG_WID 1 | ||
| 97 | #define FAULT_HVINPSC_LSH 4 | ||
| 98 | #define FAULT_HVINPSC_WID 1 | ||
| 99 | #define FAULT_HVINNSC_LSH 5 | ||
| 100 | #define FAULT_HVINNSC_WID 1 | ||
| 101 | #define FAULT_OT_LSH 6 | ||
| 102 | #define FAULT_OT_WID 1 | ||
| 103 | #define FAULT_POK_LSH 7 | ||
| 104 | #define FAULT_POK_WID 1 | ||
| 105 | |||
| 106 | #define HVINP_LSH 0 | ||
| 107 | #define HVINP_WID 4 | ||
| 108 | |||
| 109 | #define CTRL_DVR_LSH 0 | ||
| 110 | #define CTRL_DVR_WID 1 | ||
| 111 | #define CTRL_TIMING_LSH 1 | ||
| 112 | #define CTRL_TIMING_WID 1 | ||
| 113 | |||
| 114 | #define TIMING1_LSH 0 | ||
| 115 | #define TIMING1_WID 8 | ||
| 116 | #define TIMING2_LSH 0 | ||
| 117 | #define TIMING2_WID 8 | ||
| 118 | #define TIMING3_LSH 0 | ||
| 119 | #define TIMING3_WID 8 | ||
| 120 | #define TIMING4_LSH 0 | ||
| 121 | #define TIMING4_WID 8 | ||
| 122 | #define TIMING5_LSH 0 | ||
| 123 | #define TIMING5_WID 8 | ||
| 124 | #define TIMING6_LSH 0 | ||
| 125 | #define TIMING6_WID 8 | ||
| 126 | #define TIMING7_LSH 0 | ||
| 127 | #define TIMING7_WID 8 | ||
| 128 | #define TIMING8_LSH 0 | ||
| 129 | #define TIMING8_WID 8 | ||
| 130 | |||
| 131 | struct max17135 { | ||
| 132 | /* chip revision */ | ||
| 133 | int rev; | ||
| 134 | |||
| 135 | struct device *dev; | ||
| 136 | struct max17135_platform_data *pdata; | ||
| 137 | |||
| 138 | /* Platform connection */ | ||
| 139 | struct i2c_client *i2c_client; | ||
| 140 | |||
| 141 | /* Timings */ | ||
| 142 | unsigned int gvee_pwrup; | ||
| 143 | unsigned int vneg_pwrup; | ||
| 144 | unsigned int vpos_pwrup; | ||
| 145 | unsigned int gvdd_pwrup; | ||
| 146 | unsigned int gvdd_pwrdn; | ||
| 147 | unsigned int vpos_pwrdn; | ||
| 148 | unsigned int vneg_pwrdn; | ||
| 149 | unsigned int gvee_pwrdn; | ||
| 150 | |||
| 151 | /* GPIOs */ | ||
| 152 | int gpio_pmic_pwrgood; | ||
| 153 | int gpio_pmic_vcom_ctrl; | ||
| 154 | int gpio_pmic_wakeup; | ||
| 155 | int gpio_pmic_v3p3; | ||
| 156 | int gpio_pmic_intr; | ||
| 157 | |||
| 158 | /* MAX17135 part variables */ | ||
| 159 | int pass_num; | ||
| 160 | int vcom_uV; | ||
| 161 | |||
| 162 | /* One-time VCOM setup marker */ | ||
| 163 | bool vcom_setup; | ||
| 164 | |||
| 165 | /* powerup/powerdown wait time */ | ||
| 166 | int max_wait; | ||
| 167 | }; | ||
| 168 | |||
| 169 | enum { | ||
| 170 | /* In alphabetical order */ | ||
| 171 | MAX17135_DISPLAY, /* virtual master enable */ | ||
| 172 | MAX17135_GVDD, | ||
| 173 | MAX17135_GVEE, | ||
| 174 | MAX17135_HVINN, | ||
| 175 | MAX17135_HVINP, | ||
| 176 | MAX17135_VCOM, | ||
| 177 | MAX17135_VNEG, | ||
| 178 | MAX17135_VPOS, | ||
| 179 | MAX17135_V3P3, | ||
| 180 | MAX17135_NUM_REGULATORS, | ||
| 181 | }; | ||
| 182 | |||
| 183 | /* | ||
| 184 | * Declarations | ||
| 185 | */ | ||
| 186 | struct regulator_init_data; | ||
| 187 | struct max17135_regulator_data; | ||
| 188 | |||
| 189 | struct max17135_platform_data { | ||
| 190 | unsigned int gvee_pwrup; | ||
| 191 | unsigned int vneg_pwrup; | ||
| 192 | unsigned int vpos_pwrup; | ||
| 193 | unsigned int gvdd_pwrup; | ||
| 194 | unsigned int gvdd_pwrdn; | ||
| 195 | unsigned int vpos_pwrdn; | ||
| 196 | unsigned int vneg_pwrdn; | ||
| 197 | unsigned int gvee_pwrdn; | ||
| 198 | int gpio_pmic_pwrgood; | ||
| 199 | int gpio_pmic_vcom_ctrl; | ||
| 200 | int gpio_pmic_wakeup; | ||
| 201 | int gpio_pmic_v3p3; | ||
| 202 | int gpio_pmic_intr; | ||
| 203 | int pass_num; | ||
| 204 | int vcom_uV; | ||
| 205 | |||
| 206 | /* PMIC */ | ||
| 207 | struct max17135_regulator_data *regulators; | ||
| 208 | int num_regulators; | ||
| 209 | }; | ||
| 210 | |||
| 211 | struct max17135_regulator_data { | ||
| 212 | int id; | ||
| 213 | struct regulator_init_data *initdata; | ||
| 214 | struct device_node *reg_node; | ||
| 215 | }; | ||
| 216 | |||
| 217 | int max17135_reg_read(int reg_num, unsigned int *reg_val); | ||
| 218 | int max17135_reg_write(int reg_num, const unsigned int reg_val); | ||
| 219 | |||
| 220 | #endif | ||
diff --git a/include/linux/pmic_status.h b/include/linux/pmic_status.h new file mode 100644 index 000000000000..7ba42f6221a3 --- /dev/null +++ b/include/linux/pmic_status.h | |||
| @@ -0,0 +1,82 @@ | |||
| 1 | /* | ||
| 2 | * Copyright 2004-2013 Freescale Semiconductor, Inc. All Rights Reserved. | ||
| 3 | */ | ||
| 4 | |||
| 5 | /* | ||
| 6 | * The code contained herein is licensed under the GNU Lesser General | ||
| 7 | * Public License. You may obtain a copy of the GNU Lesser General | ||
| 8 | * Public License Version 2.1 or later at the following locations: | ||
| 9 | * | ||
| 10 | * http://www.opensource.org/licenses/lgpl-license.html | ||
| 11 | * http://www.gnu.org/copyleft/lgpl.html | ||
| 12 | */ | ||
| 13 | #ifndef __ASM_ARCH_MXC_PMIC_STATUS_H__ | ||
| 14 | #define __ASM_ARCH_MXC_PMIC_STATUS_H__ | ||
| 15 | #include <asm-generic/errno-base.h> | ||
| 16 | #ifdef __KERNEL__ | ||
| 17 | #include <asm/uaccess.h> /* copy_{from,to}_user() */ | ||
| 18 | #endif | ||
| 19 | /*! | ||
| 20 | * @file arch-mxc/pmic_status.h | ||
| 21 | * @brief PMIC APIs return code definition. | ||
| 22 | * | ||
| 23 | * @ingroup PMIC_CORE | ||
| 24 | */ | ||
| 25 | |||
| 26 | /*! | ||
| 27 | * @enum PMIC_STATUS | ||
| 28 | * @brief Define return values for all PMIC APIs. | ||
| 29 | * | ||
| 30 | * These return values are used by all of the PMIC APIs. | ||
| 31 | * | ||
| 32 | * @ingroup PMIC | ||
| 33 | */ | ||
| 34 | typedef enum { | ||
| 35 | PMIC_SUCCESS = 0, /*!< The requested operation was successfully | ||
| 36 | completed. */ | ||
| 37 | PMIC_ERROR = -1, /*!< The requested operation could not be completed | ||
| 38 | due to an error. */ | ||
| 39 | PMIC_PARAMETER_ERROR = -2, /*!< The requested operation failed because | ||
| 40 | one or more of the parameters was | ||
| 41 | invalid. */ | ||
| 42 | PMIC_NOT_SUPPORTED = -3, /*!< The requested operation could not be | ||
| 43 | completed because the PMIC hardware | ||
| 44 | does not support it. */ | ||
| 45 | PMIC_SYSTEM_ERROR_EINTR = -EINTR, | ||
| 46 | |||
| 47 | PMIC_MALLOC_ERROR = -5, /*!< Error in malloc function */ | ||
| 48 | PMIC_UNSUBSCRIBE_ERROR = -6, /*!< Error in un-subscribe event */ | ||
| 49 | PMIC_EVENT_NOT_SUBSCRIBED = -7, /*!< Event occur and not subscribed */ | ||
| 50 | PMIC_EVENT_CALL_BACK = -8, /*!< Error - bad call back */ | ||
| 51 | PMIC_CLIENT_NBOVERFLOW = -9, /*!< The requested operation could not be | ||
| 52 | completed because there are too many | ||
| 53 | PMIC client requests */ | ||
| 54 | } PMIC_STATUS; | ||
| 55 | |||
| 56 | /* | ||
| 57 | * Bitfield macros that use rely on bitfield width/shift information. | ||
| 58 | */ | ||
| 59 | #define BITFMASK(field) (((1U << (field ## _WID)) - 1) << (field ## _LSH)) | ||
| 60 | #define BITFVAL(field, val) ((val) << (field ## _LSH)) | ||
| 61 | #define BITFEXT(var, bit) ((var & BITFMASK(bit)) >> (bit ## _LSH)) | ||
| 62 | |||
| 63 | /* | ||
| 64 | * Macros implementing error handling | ||
| 65 | */ | ||
| 66 | #define CHECK_ERROR(a) \ | ||
| 67 | do { \ | ||
| 68 | int ret = (a); \ | ||
| 69 | if (ret != PMIC_SUCCESS) \ | ||
| 70 | return ret; \ | ||
| 71 | } while (0) | ||
| 72 | |||
| 73 | #define CHECK_ERROR_KFREE(func, freeptrs) \ | ||
| 74 | do { \ | ||
| 75 | int ret = (func); \ | ||
| 76 | if (ret != PMIC_SUCCESS) { \ | ||
| 77 | freeptrs; \ | ||
| 78 | return ret; \ | ||
| 79 | } \ | ||
| 80 | } while (0); | ||
| 81 | |||
| 82 | #endif /* __ASM_ARCH_MXC_PMIC_STATUS_H__ */ | ||
