diff options
Diffstat (limited to 'include/linux/mfd/max8997.h')
-rw-r--r-- | include/linux/mfd/max8997.h | 244 |
1 files changed, 188 insertions, 56 deletions
diff --git a/include/linux/mfd/max8997.h b/include/linux/mfd/max8997.h index 60931d0..0658eba 100644 --- a/include/linux/mfd/max8997.h +++ b/include/linux/mfd/max8997.h @@ -1,8 +1,9 @@ /* - * max8997.h - Driver for the Maxim 8997/8966 + * max8997.h - Voltage regulator driver for the Maxim 8997 * * Copyright (C) 2009-2010 Samsung Electrnoics - * MyungJoo Ham <myungjoo.ham@samsung.com> + * + * based on max8998.h * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,24 +18,19 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * This driver is based on max8998.h - * - * MAX8997 has PMIC, MUIC, HAPTIC, RTC, FLASH, and Fuel Gauge devices. - * Except Fuel Gauge, every device shares the same I2C bus and included in - * this mfd driver. Although the fuel gauge is included in the chip, it is - * excluded from the driver because a) it has a different I2C bus from - * others and b) it can be enabled simply by using MAX17042 driver. */ -#ifndef __LINUX_MFD_MAX8998_H -#define __LINUX_MFD_MAX8998_H +#ifndef __LINUX_MFD_MAX8997_H +#define __LINUX_MFD_MAX8997_H -#include <linux/regulator/consumer.h> +#include <linux/regulator/machine.h> +#if defined(CONFIG_MACH_Q1_BD) || defined(CONFIG_MACH_U1_NA_USCC) +#define MAX8997_SUPPORT_TORCH +#endif /* CONFIG_MACH_Q1_BD */ -/* MAX8997/8966 regulator IDs */ -enum max8998_regulators { - MAX8997_LDO1 = 0, +/* MAX 8997 regulator ids */ +enum { + MAX8997_LDO1 = 1, MAX8997_LDO2, MAX8997_LDO3, MAX8997_LDO4, @@ -65,53 +61,189 @@ enum max8998_regulators { MAX8997_ENVICHG, MAX8997_ESAFEOUT1, MAX8997_ESAFEOUT2, - MAX8997_CHARGER_CV, /* control MBCCV of MBCCTRL3 */ - MAX8997_CHARGER, /* charger current, MBCCTRL4 */ - MAX8997_CHARGER_TOPOFF, /* MBCCTRL5 */ + MAX8997_FLASH_CUR, + MAX8997_MOVIE_CUR, +#ifdef MAX8997_SUPPORT_TORCH + MAX8997_FLASH_TORCH, +#endif /* MAX8997_SUPPORT_TORCH */ MAX8997_REG_MAX, }; +/** + * max8997_regulator_data - regulator data + * @id: regulator id + * @initdata: regulator init data (contraints, supplies, ...) + */ struct max8997_regulator_data { - int id; - struct regulator_init_data *initdata; + int id; + struct regulator_init_data *initdata; + int (*is_valid_regulator)(int, struct regulator_init_data*); +}; + +struct max8997_power_data { + int (*set_charger)(int); + int (*topoff_cb) (void); + unsigned batt_detect:1; + unsigned topoff_threshold:2; + unsigned fast_charge:3; /* charge current */ +}; + +#ifdef CONFIG_VIBETONZ +#define MAX8997_MOTOR_REG_CONFIG2 0x2 +#define MOTOR_LRA (1<<7) +#define MOTOR_EN (1<<6) +#define EXT_PWM (0<<5) +#define DIVIDER_128 (1<<1) +#define DIVIDER_256 (1<<0 | 1<<1) + +struct max8997_motor_data { + u16 max_timeout; + u16 duty; + u16 period; + u16 reg2; + void (*init_hw)(void); + void (*motor_en)(bool); + unsigned int pwm_id; +}; +#endif + +enum { + MAX8997_MUIC_DETACHED = 0, + MAX8997_MUIC_ATTACHED +}; + +enum { + AP_USB_MODE = 0, + CP_USB_MODE, + AUDIO_MODE, +}; + +enum { + UART_PATH_CP = 0, + UART_PATH_AP, }; +enum { + USB_SEL_IF = 0, + USB_SEL_CP, +}; + +enum muic_acc_type { + MUIC_ACC_TYPE_NONE = 0, + MUIC_ACC_TYPE_OTG, + MUIC_ACC_TYPE_MHL, + MUIC_ACC_TYPE_STATION, + MUIC_ACC_TYPE_JIG_USB_OFF, + MUIC_ACC_TYPE_JIG_USB_ON, + MUIC_ACC_TYPE_DESKDOCK, + MUIC_ACC_TYPE_JIG_UART_OFF, + MUIC_ACC_TYPE_JIG_UART_ON, + MUIC_ACC_TYPE_CARDOCK, + MUIC_ACC_TYPE_TA, + MUIC_ACC_TYPE_USB, + MUIC_ACC_TYPE_UNKNOWN +}; + +enum muic_chg_type { + MUIC_CHG_TYPE_NONE = 0, + MUIC_CHG_TYPE_USB, + MUIC_CHG_TYPE_TA, + MUIC_CHG_TYPE_MHL_VB, + MUIC_CHG_TYPE_UNKNOWN +}; + +enum cable_type { + CABLE_TYPE_NONE = 0, + CABLE_TYPE_USB, + CABLE_TYPE_OTG, + CABLE_TYPE_TA, + CABLE_TYPE_DESKDOCK, + CABLE_TYPE_CARDOCK, + CABLE_TYPE_STATION, + CABLE_TYPE_JIG_UART_OFF, + CABLE_TYPE_JIG_UART_OFF_VB, /* VBUS enabled */ + CABLE_TYPE_JIG_UART_ON, + CABLE_TYPE_JIG_USB_OFF, + CABLE_TYPE_JIG_USB_ON, + CABLE_TYPE_MHL, + CABLE_TYPE_MHL_VB, + CABLE_TYPE_UNKNOWN +}; + +struct max8997_muic_data { + void (*usb_cb) (u8 attached); + void (*uart_cb) (u8 attached); + int (*charger_cb) (int cable_type); + void (*deskdock_cb) (bool attached); + void (*cardock_cb) (bool attached); + void (*mhl_cb) (int attached); + void (*init_cb) (void); + int (*set_safeout) (int path); + bool (*is_mhl_attached) (void); + int (*cfg_uart_gpio) (void); + void (*jig_uart_cb) (int path); + int (*host_notify_cb) (int enable); + int gpio_usb_sel; + int gpio_uart_sel; + int usb_path; + int uart_path; +}; + +struct max8997_buck1_dvs_funcs { + int (*set_buck1_dvs_table)(struct max8997_buck1_dvs_funcs *ptr, + unsigned int *voltage_table, int arr_size); + int (*get_buck1_dvs_table)(struct max8997_buck1_dvs_funcs *ptr, + unsigned int *voltage_table); +}; + +#define BUCK1_TABLE_SIZE 7 + +/** + * struct max8997_board - packages regulator init data + * @regulators: array of defined regulators + * @num_regulators: number of regultors used + * @irq_base: base IRQ number for max8997, required for IRQs + * @ono: power onoff IRQ number for max8997 + * @wakeup: configure the irq as a wake-up source + * @buck1_gpiodvs: enable/disable GPIO DVS for BUCK1 + * @buck1_voltages: BUCK1 supported voltage list for GPIO DVS(uV) + * it must have descending order. + * @buck1_max_vol: maximun voltage for BUCK1 (B1_TV_1) + * @buck2_max_vol: maximun voltage for BUCK2 (B2_TV_1) + * @buck5_max_vol: maximun voltage for BUCK5 (B5_TV_1) + * @buck_set1: BUCK gpio pin 1 to set output voltage + * @buck_set2: BUCK gpio pin 2 to set output voltage + * @buck_set3: BUCK gpio pin 3 to set output voltage + * @buck_ramp_en: enable BUCKx RAMP + * @buck_ramp_delay: ramp delay(usec) BUCK RAMP register(0x15) + * @flash_cntl_val: value of MAX8997_REG_FLASH_CNTL register + * @mr_debounce_time: manual reset debounce time (sec), (default 7sec) + */ struct max8997_platform_data { - /* IRQ */ - int irq_base; - int ono; - int wakeup; - - /* ---- PMIC ---- */ - struct max8997_regulator_data *regulators; - int num_regulators; - - /* - * SET1~3 DVS GPIOs control Buck1, 2, and 5 simultaneously. Therefore, - * With buckx_gpiodvs enabled, the buckx cannot be controlled - * independently. To control buckx (of 1, 2, and 5) independently, - * disable buckx_gpiodvs and control with BUCKxDVS1 register. - * - * When buckx_gpiodvs and bucky_gpiodvs are both enabled, set_voltage - * on buckx will change the voltage of bucky at the same time. - * - */ - bool ignore_gpiodvs_side_effect; - int buck125_gpios[3]; /* GPIO of [0]SET1, [1]SET2, [2]SET3 */ - int buck125_default_idx; /* Default value of SET1, 2, 3 */ - unsigned int buck1_voltage[8]; /* buckx_voltage in uV */ - bool buck1_gpiodvs; - unsigned int buck2_voltage[8]; - bool buck2_gpiodvs; - unsigned int buck5_voltage[8]; - bool buck5_gpiodvs; - - /* MUIC: Not implemented */ - /* HAPTIC: Not implemented */ - /* RTC: Not implemented */ - /* Flash: Not implemented */ - /* Charger control: Not implemented */ + struct max8997_regulator_data *regulators; + int num_regulators; + int irq_base; + int ono; + int wakeup; + bool buck1_gpiodvs; + unsigned int buck1_max_vol; + unsigned int buck2_max_vol; + unsigned int buck5_max_vol; + unsigned int buck1_voltages[BUCK1_TABLE_SIZE]; + int buck_set1; + int buck_set2; + int buck_set3; + bool buck_ramp_en; + int buck_ramp_delay; + int flash_cntl_val; + int mr_debounce_time; + struct max8997_power_data *power; + struct max8997_muic_data *muic; +#ifdef CONFIG_VIBETONZ + struct max8997_motor_data *motor; +#endif + void (*register_buck1_dvs_funcs)(struct max8997_buck1_dvs_funcs *ptr); }; -#endif /* __LINUX_MFD_MAX8998_H */ +#endif /* __LINUX_MFD_MAX8997_H */ |