Padmanabhan Komanduru | dbd2fb0 | 2016-12-02 15:18:49 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2016-2017, The Linux Foundation. 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 | |
| 15 | #ifndef _DSI_PWR_H_ |
| 16 | #define _DSI_PWR_H_ |
| 17 | |
| 18 | #include <linux/device.h> |
| 19 | #include <linux/platform_device.h> |
| 20 | #include <linux/types.h> |
| 21 | #include <linux/regulator/consumer.h> |
| 22 | |
| 23 | /** |
| 24 | * struct dsi_vreg - regulator information for DSI regulators |
| 25 | * @vreg: Handle to the regulator. |
| 26 | * @vreg_name: Regulator name. |
| 27 | * @min_voltage: Minimum voltage in uV. |
| 28 | * @max_voltage: Maximum voltage in uV. |
| 29 | * @enable_load: Load, in uA, when enabled. |
| 30 | * @disable_load: Load, in uA, when disabled. |
| 31 | * @pre_on_sleep: Sleep, in ms, before enabling the regulator. |
| 32 | * @post_on_sleep: Sleep, in ms, after enabling the regulator. |
| 33 | * @pre_off_sleep: Sleep, in ms, before disabling the regulator. |
| 34 | * @post_off_sleep: Sleep, in ms, after disabling the regulator. |
| 35 | */ |
| 36 | struct dsi_vreg { |
| 37 | struct regulator *vreg; |
| 38 | char vreg_name[32]; |
| 39 | u32 min_voltage; |
| 40 | u32 max_voltage; |
| 41 | u32 enable_load; |
| 42 | u32 disable_load; |
| 43 | u32 pre_on_sleep; |
| 44 | u32 post_on_sleep; |
| 45 | u32 pre_off_sleep; |
| 46 | u32 post_off_sleep; |
| 47 | }; |
| 48 | |
| 49 | /** |
| 50 | * struct dsi_regulator_info - set of vregs that are turned on/off together. |
| 51 | * @vregs: Array of dsi_vreg structures. |
| 52 | * @count: Number of vregs. |
| 53 | * @refcount: Reference counting for enabling. |
| 54 | */ |
| 55 | struct dsi_regulator_info { |
| 56 | struct dsi_vreg *vregs; |
| 57 | u32 count; |
| 58 | u32 refcount; |
| 59 | }; |
| 60 | |
| 61 | /** |
| 62 | * dsi_pwr_of_get_vreg_data - parse regulator supply information |
| 63 | * @of_node: Device of node to parse for supply information. |
| 64 | * @regs: Pointer where regulator information will be copied to. |
| 65 | * @supply_name: Name of the supply node. |
| 66 | * |
| 67 | * return: error code in case of failure or 0 for success. |
| 68 | */ |
| 69 | int dsi_pwr_of_get_vreg_data(struct device_node *of_node, |
| 70 | struct dsi_regulator_info *regs, |
| 71 | char *supply_name); |
| 72 | |
| 73 | /** |
| 74 | * dsi_pwr_get_dt_vreg_data - parse regulator supply information |
| 75 | * @dev: Device whose of_node needs to be parsed. |
| 76 | * @regs: Pointer where regulator information will be copied to. |
| 77 | * @supply_name: Name of the supply node. |
| 78 | * |
| 79 | * return: error code in case of failure or 0 for success. |
| 80 | */ |
| 81 | int dsi_pwr_get_dt_vreg_data(struct device *dev, |
| 82 | struct dsi_regulator_info *regs, |
| 83 | char *supply_name); |
| 84 | |
| 85 | /** |
| 86 | * dsi_pwr_enable_regulator() - enable a set of regulators |
| 87 | * @regs: Pointer to set of regulators to enable or disable. |
| 88 | * @enable: Enable/Disable regulators. |
| 89 | * |
| 90 | * return: error code in case of failure or 0 for success. |
| 91 | */ |
| 92 | int dsi_pwr_enable_regulator(struct dsi_regulator_info *regs, bool enable); |
| 93 | #endif /* _DSI_PWR_H_ */ |