blob: d6cd3c55e7ba610af7e1bad2d75d925b4d642b9d [file] [log] [blame]
Amol Jadif2f45602011-05-24 15:46:01 -07001/*
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 Jadi3570f9d2011-05-27 13:57:44 -070034
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 Chike5c93432011-06-17 09:10:29 -070039//TODO: Rename these variables
40#define PM_GPIO_PULL_UP0 0
Amol Jadi3570f9d2011-05-27 13:57:44 -070041#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 Chik1ac45ce2011-05-29 22:01:34 -070056/* GPIO24 for backlight_pwm which is 23 (index start at 0) */
57#define GPIO_24 23
Kinson Chike5c93432011-06-17 09:10:29 -070058#define GPIO_43 42
Kinson Chik1ac45ce2011-05-29 22:01:34 -070059
Amol Jadi60a55972011-06-10 18:50:47 -070060/* 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
67enum
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 Griscod2471ef2011-07-14 13:00:42 -070075typedef int (*pm8921_read_func)(uint8_t *data, uint32_t length, uint32_t addr);
76typedef int (*pm8921_write_func)(uint8_t *data, uint32_t length, uint32_t addr);
77
Amol Jadif2f45602011-05-24 15:46:01 -070078typedef struct
79{
80 uint32_t initialized;
81
Greg Griscod2471ef2011-07-14 13:00:42 -070082 pm8921_read_func read;
83 pm8921_write_func write;
Amol Jadif2f45602011-05-24 15:46:01 -070084
85} pm8921_dev_t;
86
87
Amol Jadi3570f9d2011-05-27 13:57:44 -070088struct 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 Jadif2f45602011-05-24 15:46:01 -0700100void pm8921_init(pm8921_dev_t *);
Amol Jadi3570f9d2011-05-27 13:57:44 -0700101int pm8921_gpio_config(int gpio, struct pm8921_gpio *param);
Amol Jadif2f45602011-05-24 15:46:01 -0700102void pm8921_boot_done(void);
Amol Jadi60a55972011-06-10 18:50:47 -0700103int pm8921_ldo_set_voltage(uint32_t ldo_id, uint32_t voltage);
Shashank Mittal39503262011-07-19 11:41:35 -0700104int pm8921_config_reset_pwr_off(unsigned reset);
Amol Jadif2f45602011-05-24 15:46:01 -0700105
106#endif