blob: 2d2d67b6a3932d3eefafb650cb7d0688980074fa [file] [log] [blame]
MyungJoo Ham527e7e92011-03-04 15:50:26 +09001/*
2 * max8997.h - Driver for the Maxim 8997/8966
3 *
4 * Copyright (C) 2009-2010 Samsung Electrnoics
5 * MyungJoo Ham <myungjoo.ham@samsung.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 * This driver is based on max8998.h
22 *
23 * MAX8997 has PMIC, MUIC, HAPTIC, RTC, FLASH, and Fuel Gauge devices.
24 * Except Fuel Gauge, every device shares the same I2C bus and included in
25 * this mfd driver. Although the fuel gauge is included in the chip, it is
26 * excluded from the driver because a) it has a different I2C bus from
27 * others and b) it can be enabled simply by using MAX17042 driver.
28 */
29
30#ifndef __LINUX_MFD_MAX8998_H
31#define __LINUX_MFD_MAX8998_H
32
33#include <linux/regulator/consumer.h>
34
35/* MAX8997/8966 regulator IDs */
36enum max8998_regulators {
37 MAX8997_LDO1 = 0,
38 MAX8997_LDO2,
39 MAX8997_LDO3,
40 MAX8997_LDO4,
41 MAX8997_LDO5,
42 MAX8997_LDO6,
43 MAX8997_LDO7,
44 MAX8997_LDO8,
45 MAX8997_LDO9,
46 MAX8997_LDO10,
47 MAX8997_LDO11,
48 MAX8997_LDO12,
49 MAX8997_LDO13,
50 MAX8997_LDO14,
51 MAX8997_LDO15,
52 MAX8997_LDO16,
53 MAX8997_LDO17,
54 MAX8997_LDO18,
55 MAX8997_LDO21,
56 MAX8997_BUCK1,
57 MAX8997_BUCK2,
58 MAX8997_BUCK3,
59 MAX8997_BUCK4,
60 MAX8997_BUCK5,
61 MAX8997_BUCK6,
62 MAX8997_BUCK7,
63 MAX8997_EN32KHZ_AP,
64 MAX8997_EN32KHZ_CP,
65 MAX8997_ENVICHG,
66 MAX8997_ESAFEOUT1,
67 MAX8997_ESAFEOUT2,
68 MAX8997_CHARGER_CV, /* control MBCCV of MBCCTRL3 */
69 MAX8997_CHARGER, /* charger current, MBCCTRL4 */
70 MAX8997_CHARGER_TOPOFF, /* MBCCTRL5 */
MyungJoo Hambd6ca2c2011-03-11 11:34:44 +090071
72 MAX8997_REG_MAX,
MyungJoo Ham527e7e92011-03-04 15:50:26 +090073};
74
75struct max8997_regulator_data {
76 int id;
77 struct regulator_init_data *initdata;
Thomas Abraham77b71b32012-11-27 14:04:32 +053078 struct device_node *reg_node;
MyungJoo Ham527e7e92011-03-04 15:50:26 +090079};
80
Donggeun Kim2439d972011-11-24 18:12:17 +090081struct max8997_muic_reg_data {
82 u8 addr;
83 u8 data;
84};
85
86/**
87 * struct max8997_muic_platform_data
Donggeun Kim2439d972011-11-24 18:12:17 +090088 * @init_data: array of max8997_muic_reg_data
89 * used for initializing registers of MAX8997 MUIC device
90 * @num_init_data: array size of init_data
91 */
92struct max8997_muic_platform_data {
Donggeun Kim2439d972011-11-24 18:12:17 +090093 struct max8997_muic_reg_data *init_data;
94 int num_init_data;
Chanwoo Choi685dc9a2013-02-13 15:04:15 +090095
96 /*
97 * Default usb/uart path whether UART/USB or AUX_UART/AUX_USB
98 * h/w path of COMP2/COMN1 on CONTROL1 register.
99 */
100 int path_usb;
101 int path_uart;
Donggeun Kim2439d972011-11-24 18:12:17 +0900102};
103
Donggeun Kim104594b02012-03-16 12:28:22 -0700104enum max8997_haptic_motor_type {
105 MAX8997_HAPTIC_ERM,
106 MAX8997_HAPTIC_LRA,
107};
108
109enum max8997_haptic_pulse_mode {
110 MAX8997_EXTERNAL_MODE,
111 MAX8997_INTERNAL_MODE,
112};
113
114enum max8997_haptic_pwm_divisor {
115 MAX8997_PWM_DIVISOR_32,
116 MAX8997_PWM_DIVISOR_64,
117 MAX8997_PWM_DIVISOR_128,
118 MAX8997_PWM_DIVISOR_256,
119};
120
121/**
122 * max8997_haptic_platform_data
123 * @pwm_channel_id: channel number of PWM device
124 * valid for MAX8997_EXTERNAL_MODE
125 * @pwm_period: period in nano second for PWM device
126 * valid for MAX8997_EXTERNAL_MODE
127 * @type: motor type
128 * @mode: pulse mode
129 * MAX8997_EXTERNAL_MODE: external PWM device is used to control motor
130 * MAX8997_INTERNAL_MODE: internal pulse generator is used to control motor
131 * @pwm_divisor: divisor for external PWM device
132 * @internal_mode_pattern: internal mode pattern for internal mode
133 * [0 - 3]: valid pattern number
134 * @pattern_cycle: the number of cycles of the waveform
135 * for the internal mode pattern
136 * [0 - 15]: available cycles
137 * @pattern_signal_period: period of the waveform for the internal mode pattern
138 * [0 - 255]: available period
139 */
140struct max8997_haptic_platform_data {
141 unsigned int pwm_channel_id;
142 unsigned int pwm_period;
143
144 enum max8997_haptic_motor_type type;
145 enum max8997_haptic_pulse_mode mode;
146 enum max8997_haptic_pwm_divisor pwm_divisor;
147
148 unsigned int internal_mode_pattern;
149 unsigned int pattern_cycle;
150 unsigned int pattern_signal_period;
151};
152
Donggeun Kimf6dd2db2011-12-14 18:23:55 +0900153enum max8997_led_mode {
154 MAX8997_NONE,
155 MAX8997_FLASH_MODE,
156 MAX8997_MOVIE_MODE,
157 MAX8997_FLASH_PIN_CONTROL_MODE,
158 MAX8997_MOVIE_PIN_CONTROL_MODE,
159};
160
161/**
162 * struct max8997_led_platform_data
163 * The number of LED devices for MAX8997 is two
164 * @mode: LED mode for each LED device
165 * @brightness: initial brightness for each LED device
166 * range:
167 * [0 - 31]: MAX8997_FLASH_MODE and MAX8997_FLASH_PIN_CONTROL_MODE
168 * [0 - 15]: MAX8997_MOVIE_MODE and MAX8997_MOVIE_PIN_CONTROL_MODE
169 */
170struct max8997_led_platform_data {
171 enum max8997_led_mode mode[2];
172 u8 brightness[2];
173};
174
MyungJoo Ham527e7e92011-03-04 15:50:26 +0900175struct max8997_platform_data {
MyungJoo Ham8de6bc72011-03-24 15:54:45 +0900176 /* IRQ */
MyungJoo Ham8de6bc72011-03-24 15:54:45 +0900177 int ono;
178 int wakeup;
179
MyungJoo Hambd6ca2c2011-03-11 11:34:44 +0900180 /* ---- PMIC ---- */
181 struct max8997_regulator_data *regulators;
182 int num_regulators;
183
184 /*
185 * SET1~3 DVS GPIOs control Buck1, 2, and 5 simultaneously. Therefore,
186 * With buckx_gpiodvs enabled, the buckx cannot be controlled
187 * independently. To control buckx (of 1, 2, and 5) independently,
188 * disable buckx_gpiodvs and control with BUCKxDVS1 register.
189 *
190 * When buckx_gpiodvs and bucky_gpiodvs are both enabled, set_voltage
191 * on buckx will change the voltage of bucky at the same time.
192 *
193 */
194 bool ignore_gpiodvs_side_effect;
195 int buck125_gpios[3]; /* GPIO of [0]SET1, [1]SET2, [2]SET3 */
196 int buck125_default_idx; /* Default value of SET1, 2, 3 */
197 unsigned int buck1_voltage[8]; /* buckx_voltage in uV */
198 bool buck1_gpiodvs;
199 unsigned int buck2_voltage[8];
200 bool buck2_gpiodvs;
201 unsigned int buck5_voltage[8];
202 bool buck5_gpiodvs;
203
Donggeun Kim149c0772011-06-22 19:40:06 +0900204 /* ---- Charger control ---- */
205 /* eoc stands for 'end of charge' */
206 int eoc_mA; /* 50 ~ 200mA by 10mA step */
207 /* charge Full Timeout */
208 int timeout; /* 0 (no timeout), 5, 6, 7 hours */
209
Donggeun Kim2439d972011-11-24 18:12:17 +0900210 /* ---- MUIC ---- */
211 struct max8997_muic_platform_data *muic_pdata;
212
Donggeun Kim104594b02012-03-16 12:28:22 -0700213 /* ---- HAPTIC ---- */
214 struct max8997_haptic_platform_data *haptic_pdata;
215
MyungJoo Ham527e7e92011-03-04 15:50:26 +0900216 /* RTC: Not implemented */
Donggeun Kimf6dd2db2011-12-14 18:23:55 +0900217 /* ---- LED ---- */
218 struct max8997_led_platform_data *led_pdata;
MyungJoo Ham527e7e92011-03-04 15:50:26 +0900219};
220
221#endif /* __LINUX_MFD_MAX8998_H */