Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0+ */
0002 /*
0003  * max8997.h - Driver for the Maxim 8997/8966
0004  *
0005  *  Copyright (C) 2009-2010 Samsung Electrnoics
0006  *  MyungJoo Ham <myungjoo.ham@samsung.com>
0007  *
0008  * This driver is based on max8998.h
0009  *
0010  * MAX8997 has PMIC, MUIC, HAPTIC, RTC, FLASH, and Fuel Gauge devices.
0011  * Except Fuel Gauge, every device shares the same I2C bus and included in
0012  * this mfd driver. Although the fuel gauge is included in the chip, it is
0013  * excluded from the driver because a) it has a different I2C bus from
0014  * others and b) it can be enabled simply by using MAX17042 driver.
0015  */
0016 
0017 #ifndef __LINUX_MFD_MAX8997_H
0018 #define __LINUX_MFD_MAX8997_H
0019 
0020 #include <linux/regulator/consumer.h>
0021 
0022 /* MAX8997/8966 regulator IDs */
0023 enum max8997_regulators {
0024     MAX8997_LDO1 = 0,
0025     MAX8997_LDO2,
0026     MAX8997_LDO3,
0027     MAX8997_LDO4,
0028     MAX8997_LDO5,
0029     MAX8997_LDO6,
0030     MAX8997_LDO7,
0031     MAX8997_LDO8,
0032     MAX8997_LDO9,
0033     MAX8997_LDO10,
0034     MAX8997_LDO11,
0035     MAX8997_LDO12,
0036     MAX8997_LDO13,
0037     MAX8997_LDO14,
0038     MAX8997_LDO15,
0039     MAX8997_LDO16,
0040     MAX8997_LDO17,
0041     MAX8997_LDO18,
0042     MAX8997_LDO21,
0043     MAX8997_BUCK1,
0044     MAX8997_BUCK2,
0045     MAX8997_BUCK3,
0046     MAX8997_BUCK4,
0047     MAX8997_BUCK5,
0048     MAX8997_BUCK6,
0049     MAX8997_BUCK7,
0050     MAX8997_EN32KHZ_AP,
0051     MAX8997_EN32KHZ_CP,
0052     MAX8997_ENVICHG,
0053     MAX8997_ESAFEOUT1,
0054     MAX8997_ESAFEOUT2,
0055     MAX8997_CHARGER_CV, /* control MBCCV of MBCCTRL3 */
0056     MAX8997_CHARGER, /* charger current, MBCCTRL4 */
0057     MAX8997_CHARGER_TOPOFF, /* MBCCTRL5 */
0058 
0059     MAX8997_REG_MAX,
0060 };
0061 
0062 struct max8997_regulator_data {
0063     int id;
0064     struct regulator_init_data *initdata;
0065     struct device_node *reg_node;
0066 };
0067 
0068 struct max8997_muic_reg_data {
0069     u8 addr;
0070     u8 data;
0071 };
0072 
0073 /**
0074  * struct max8997_muic_platform_data
0075  * @init_data: array of max8997_muic_reg_data
0076  *         used for initializing registers of MAX8997 MUIC device
0077  * @num_init_data: array size of init_data
0078  */
0079 struct max8997_muic_platform_data {
0080     struct max8997_muic_reg_data *init_data;
0081     int num_init_data;
0082 
0083     /* Check cable state after certain delay */
0084     int detcable_delay_ms;
0085 
0086     /*
0087      * Default usb/uart path whether UART/USB or AUX_UART/AUX_USB
0088      * h/w path of COMP2/COMN1 on CONTROL1 register.
0089      */
0090     int path_usb;
0091     int path_uart;
0092 };
0093 
0094 enum max8997_haptic_motor_type {
0095     MAX8997_HAPTIC_ERM,
0096     MAX8997_HAPTIC_LRA,
0097 };
0098 
0099 enum max8997_haptic_pulse_mode {
0100     MAX8997_EXTERNAL_MODE,
0101     MAX8997_INTERNAL_MODE,
0102 };
0103 
0104 enum max8997_haptic_pwm_divisor {
0105     MAX8997_PWM_DIVISOR_32,
0106     MAX8997_PWM_DIVISOR_64,
0107     MAX8997_PWM_DIVISOR_128,
0108     MAX8997_PWM_DIVISOR_256,
0109 };
0110 
0111 /**
0112  * max8997_haptic_platform_data
0113  * @pwm_channel_id: channel number of PWM device
0114  *          valid for MAX8997_EXTERNAL_MODE
0115  * @pwm_period: period in nano second for PWM device
0116  *      valid for MAX8997_EXTERNAL_MODE
0117  * @type: motor type
0118  * @mode: pulse mode
0119  *     MAX8997_EXTERNAL_MODE: external PWM device is used to control motor
0120  *     MAX8997_INTERNAL_MODE: internal pulse generator is used to control motor
0121  * @pwm_divisor: divisor for external PWM device
0122  * @internal_mode_pattern: internal mode pattern for internal mode
0123  *     [0 - 3]: valid pattern number
0124  * @pattern_cycle: the number of cycles of the waveform
0125  *         for the internal mode pattern
0126  *     [0 - 15]: available cycles
0127  * @pattern_signal_period: period of the waveform for the internal mode pattern
0128  *     [0 - 255]: available period
0129  */
0130 struct max8997_haptic_platform_data {
0131     unsigned int pwm_channel_id;
0132     unsigned int pwm_period;
0133 
0134     enum max8997_haptic_motor_type type;
0135     enum max8997_haptic_pulse_mode mode;
0136     enum max8997_haptic_pwm_divisor pwm_divisor;
0137 
0138     unsigned int internal_mode_pattern;
0139     unsigned int pattern_cycle;
0140     unsigned int pattern_signal_period;
0141 };
0142 
0143 enum max8997_led_mode {
0144     MAX8997_NONE,
0145     MAX8997_FLASH_MODE,
0146     MAX8997_MOVIE_MODE,
0147     MAX8997_FLASH_PIN_CONTROL_MODE,
0148     MAX8997_MOVIE_PIN_CONTROL_MODE,
0149 };
0150 
0151 /**
0152  *  struct max8997_led_platform_data
0153  *  The number of LED devices for MAX8997 is two
0154  *  @mode: LED mode for each LED device
0155  *  @brightness: initial brightness for each LED device
0156  *  range:
0157  *  [0 - 31]: MAX8997_FLASH_MODE and MAX8997_FLASH_PIN_CONTROL_MODE
0158  *  [0 - 15]: MAX8997_MOVIE_MODE and MAX8997_MOVIE_PIN_CONTROL_MODE
0159  */
0160 struct max8997_led_platform_data {
0161     enum max8997_led_mode mode[2];
0162     u8 brightness[2];
0163 };
0164 
0165 struct max8997_platform_data {
0166     /* IRQ */
0167     int ono;
0168 
0169     /* ---- PMIC ---- */
0170     struct max8997_regulator_data *regulators;
0171     int num_regulators;
0172 
0173     /*
0174      * SET1~3 DVS GPIOs control Buck1, 2, and 5 simultaneously. Therefore,
0175      * With buckx_gpiodvs enabled, the buckx cannot be controlled
0176      * independently. To control buckx (of 1, 2, and 5) independently,
0177      * disable buckx_gpiodvs and control with BUCKxDVS1 register.
0178      *
0179      * When buckx_gpiodvs and bucky_gpiodvs are both enabled, set_voltage
0180      * on buckx will change the voltage of bucky at the same time.
0181      *
0182      */
0183     bool ignore_gpiodvs_side_effect;
0184     int buck125_gpios[3]; /* GPIO of [0]SET1, [1]SET2, [2]SET3 */
0185     int buck125_default_idx; /* Default value of SET1, 2, 3 */
0186     unsigned int buck1_voltage[8]; /* buckx_voltage in uV */
0187     bool buck1_gpiodvs;
0188     unsigned int buck2_voltage[8];
0189     bool buck2_gpiodvs;
0190     unsigned int buck5_voltage[8];
0191     bool buck5_gpiodvs;
0192 
0193     /* ---- Charger control ---- */
0194     /* eoc stands for 'end of charge' */
0195     int eoc_mA; /* 50 ~ 200mA by 10mA step */
0196     /* charge Full Timeout */
0197     int timeout; /* 0 (no timeout), 5, 6, 7 hours */
0198 
0199     /* ---- MUIC ---- */
0200     struct max8997_muic_platform_data *muic_pdata;
0201 
0202     /* ---- HAPTIC ---- */
0203     struct max8997_haptic_platform_data *haptic_pdata;
0204 
0205     /* RTC: Not implemented */
0206     /* ---- LED ---- */
0207     struct max8997_led_platform_data *led_pdata;
0208 };
0209 
0210 #endif /* __LINUX_MFD_MAX8997_H */