Amol Jadi | f2f4560 | 2011-05-24 15:46:01 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2011, Code Aurora Forum. All rights reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions are |
| 6 | * met: |
| 7 | * * Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * * Redistributions in binary form must reproduce the above |
| 10 | * copyright notice, this list of conditions and the following |
| 11 | * disclaimer in the documentation and/or other materials provided |
| 12 | * with the distribution. |
| 13 | * * Neither the name of Code Aurora Forum, Inc. nor the names of its |
| 14 | * contributors may be used to endorse or promote products derived |
| 15 | * from this software without specific prior written permission. |
| 16 | * |
| 17 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED |
| 18 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT |
| 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS |
| 21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 24 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 25 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| 26 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 27 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | */ |
| 29 | #ifndef __DEV_PM8921_H |
| 30 | #define __DEV_PM8921_H |
| 31 | |
| 32 | #include <sys/types.h> |
| 33 | |
Amol Jadi | 3570f9d | 2011-05-27 13:57:44 -0700 | [diff] [blame] | 34 | |
| 35 | #define PM_GPIO_DIR_OUT 0x01 |
| 36 | #define PM_GPIO_DIR_IN 0x02 |
| 37 | #define PM_GPIO_DIR_BOTH (PM_GPIO_DIR_OUT | PM_GPIO_DIR_IN) |
| 38 | |
Kinson Chik | e5c9343 | 2011-06-17 09:10:29 -0700 | [diff] [blame] | 39 | //TODO: Rename these variables |
| 40 | #define PM_GPIO_PULL_UP0 0 |
Amol Jadi | 3570f9d | 2011-05-27 13:57:44 -0700 | [diff] [blame] | 41 | #define PM_GPIO_PULL_UP1 2 |
| 42 | #define PM_GPIO_PULL_UP2 3 |
| 43 | #define PM_GPIO_PULL_DN 4 |
| 44 | #define PM_GPIO_PULL_NO 5 |
| 45 | |
| 46 | #define PM_GPIO_STRENGTH_NO 0 |
| 47 | #define PM_GPIO_STRENGTH_HIGH 1 |
| 48 | #define PM_GPIO_STRENGTH_MED 2 |
| 49 | #define PM_GPIO_STRENGTH_LOW 3 |
| 50 | |
| 51 | #define PM_GPIO_FUNC_NORMAL 0 |
| 52 | #define PM_GPIO_FUNC_PAIRED 1 |
| 53 | #define PM_GPIO_FUNC_1 2 |
| 54 | #define PM_GPIO_FUNC_2 3 |
| 55 | |
Kinson Chik | 1ac45ce | 2011-05-29 22:01:34 -0700 | [diff] [blame] | 56 | /* GPIO24 for backlight_pwm which is 23 (index start at 0) */ |
| 57 | #define GPIO_24 23 |
Kinson Chik | e5c9343 | 2011-06-17 09:10:29 -0700 | [diff] [blame] | 58 | #define GPIO_43 42 |
Kinson Chik | 1ac45ce | 2011-05-29 22:01:34 -0700 | [diff] [blame] | 59 | |
Amol Jadi | 60a5597 | 2011-06-10 18:50:47 -0700 | [diff] [blame] | 60 | /* LDO define values */ |
| 61 | #define LDO_P_MASK (1 << 7) |
| 62 | |
| 63 | #define LDO_2 (2) |
| 64 | #define LDO_8 (8 | LDO_P_MASK) |
| 65 | #define LDO_23 (23 | LDO_P_MASK) |
| 66 | |
| 67 | enum |
| 68 | { |
| 69 | LDO_VOLTAGE_1_2V = 0, |
| 70 | LDO_VOLTAGE_1_8V = 1, |
| 71 | LDO_VOLTAGE_3_0V = 2, |
| 72 | LDO_VOLTAGE_ENTRIES |
| 73 | }; |
| 74 | |
Greg Grisco | d2471ef | 2011-07-14 13:00:42 -0700 | [diff] [blame^] | 75 | typedef int (*pm8921_read_func)(uint8_t *data, uint32_t length, uint32_t addr); |
| 76 | typedef int (*pm8921_write_func)(uint8_t *data, uint32_t length, uint32_t addr); |
| 77 | |
Amol Jadi | f2f4560 | 2011-05-24 15:46:01 -0700 | [diff] [blame] | 78 | typedef struct |
| 79 | { |
| 80 | uint32_t initialized; |
| 81 | |
Greg Grisco | d2471ef | 2011-07-14 13:00:42 -0700 | [diff] [blame^] | 82 | pm8921_read_func read; |
| 83 | pm8921_write_func write; |
Amol Jadi | f2f4560 | 2011-05-24 15:46:01 -0700 | [diff] [blame] | 84 | |
| 85 | } pm8921_dev_t; |
| 86 | |
| 87 | |
Amol Jadi | 3570f9d | 2011-05-27 13:57:44 -0700 | [diff] [blame] | 88 | struct pm8921_gpio { |
| 89 | int direction; |
| 90 | int output_buffer; |
| 91 | int output_value; |
| 92 | int pull; |
| 93 | int vin_sel; |
| 94 | int out_strength; |
| 95 | int function; |
| 96 | int inv_int_pol; |
| 97 | int disable_pin; |
| 98 | }; |
| 99 | |
Amol Jadi | f2f4560 | 2011-05-24 15:46:01 -0700 | [diff] [blame] | 100 | void pm8921_init(pm8921_dev_t *); |
Amol Jadi | 3570f9d | 2011-05-27 13:57:44 -0700 | [diff] [blame] | 101 | int pm8921_gpio_config(int gpio, struct pm8921_gpio *param); |
Amol Jadi | f2f4560 | 2011-05-24 15:46:01 -0700 | [diff] [blame] | 102 | void pm8921_boot_done(void); |
Amol Jadi | 60a5597 | 2011-06-10 18:50:47 -0700 | [diff] [blame] | 103 | int pm8921_ldo_set_voltage(uint32_t ldo_id, uint32_t voltage); |
Shashank Mittal | 3950326 | 2011-07-19 11:41:35 -0700 | [diff] [blame] | 104 | int pm8921_config_reset_pwr_off(unsigned reset); |
Amol Jadi | f2f4560 | 2011-05-24 15:46:01 -0700 | [diff] [blame] | 105 | |
| 106 | #endif |