1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0+ */ 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun * max8997.h - Driver for the Maxim 8997/8966 4*4882a593Smuzhiyun * 5*4882a593Smuzhiyun * Copyright (C) 2009-2010 Samsung Electrnoics 6*4882a593Smuzhiyun * MyungJoo Ham <myungjoo.ham@samsung.com> 7*4882a593Smuzhiyun * 8*4882a593Smuzhiyun * This driver is based on max8998.h 9*4882a593Smuzhiyun * 10*4882a593Smuzhiyun * MAX8997 has PMIC, MUIC, HAPTIC, RTC, FLASH, and Fuel Gauge devices. 11*4882a593Smuzhiyun * Except Fuel Gauge, every device shares the same I2C bus and included in 12*4882a593Smuzhiyun * this mfd driver. Although the fuel gauge is included in the chip, it is 13*4882a593Smuzhiyun * excluded from the driver because a) it has a different I2C bus from 14*4882a593Smuzhiyun * others and b) it can be enabled simply by using MAX17042 driver. 15*4882a593Smuzhiyun */ 16*4882a593Smuzhiyun 17*4882a593Smuzhiyun #ifndef __LINUX_MFD_MAX8998_H 18*4882a593Smuzhiyun #define __LINUX_MFD_MAX8998_H 19*4882a593Smuzhiyun 20*4882a593Smuzhiyun #include <linux/regulator/consumer.h> 21*4882a593Smuzhiyun 22*4882a593Smuzhiyun /* MAX8997/8966 regulator IDs */ 23*4882a593Smuzhiyun enum max8998_regulators { 24*4882a593Smuzhiyun MAX8997_LDO1 = 0, 25*4882a593Smuzhiyun MAX8997_LDO2, 26*4882a593Smuzhiyun MAX8997_LDO3, 27*4882a593Smuzhiyun MAX8997_LDO4, 28*4882a593Smuzhiyun MAX8997_LDO5, 29*4882a593Smuzhiyun MAX8997_LDO6, 30*4882a593Smuzhiyun MAX8997_LDO7, 31*4882a593Smuzhiyun MAX8997_LDO8, 32*4882a593Smuzhiyun MAX8997_LDO9, 33*4882a593Smuzhiyun MAX8997_LDO10, 34*4882a593Smuzhiyun MAX8997_LDO11, 35*4882a593Smuzhiyun MAX8997_LDO12, 36*4882a593Smuzhiyun MAX8997_LDO13, 37*4882a593Smuzhiyun MAX8997_LDO14, 38*4882a593Smuzhiyun MAX8997_LDO15, 39*4882a593Smuzhiyun MAX8997_LDO16, 40*4882a593Smuzhiyun MAX8997_LDO17, 41*4882a593Smuzhiyun MAX8997_LDO18, 42*4882a593Smuzhiyun MAX8997_LDO21, 43*4882a593Smuzhiyun MAX8997_BUCK1, 44*4882a593Smuzhiyun MAX8997_BUCK2, 45*4882a593Smuzhiyun MAX8997_BUCK3, 46*4882a593Smuzhiyun MAX8997_BUCK4, 47*4882a593Smuzhiyun MAX8997_BUCK5, 48*4882a593Smuzhiyun MAX8997_BUCK6, 49*4882a593Smuzhiyun MAX8997_BUCK7, 50*4882a593Smuzhiyun MAX8997_EN32KHZ_AP, 51*4882a593Smuzhiyun MAX8997_EN32KHZ_CP, 52*4882a593Smuzhiyun MAX8997_ENVICHG, 53*4882a593Smuzhiyun MAX8997_ESAFEOUT1, 54*4882a593Smuzhiyun MAX8997_ESAFEOUT2, 55*4882a593Smuzhiyun MAX8997_CHARGER_CV, /* control MBCCV of MBCCTRL3 */ 56*4882a593Smuzhiyun MAX8997_CHARGER, /* charger current, MBCCTRL4 */ 57*4882a593Smuzhiyun MAX8997_CHARGER_TOPOFF, /* MBCCTRL5 */ 58*4882a593Smuzhiyun 59*4882a593Smuzhiyun MAX8997_REG_MAX, 60*4882a593Smuzhiyun }; 61*4882a593Smuzhiyun 62*4882a593Smuzhiyun struct max8997_regulator_data { 63*4882a593Smuzhiyun int id; 64*4882a593Smuzhiyun struct regulator_init_data *initdata; 65*4882a593Smuzhiyun struct device_node *reg_node; 66*4882a593Smuzhiyun }; 67*4882a593Smuzhiyun 68*4882a593Smuzhiyun struct max8997_muic_reg_data { 69*4882a593Smuzhiyun u8 addr; 70*4882a593Smuzhiyun u8 data; 71*4882a593Smuzhiyun }; 72*4882a593Smuzhiyun 73*4882a593Smuzhiyun /** 74*4882a593Smuzhiyun * struct max8997_muic_platform_data 75*4882a593Smuzhiyun * @init_data: array of max8997_muic_reg_data 76*4882a593Smuzhiyun * used for initializing registers of MAX8997 MUIC device 77*4882a593Smuzhiyun * @num_init_data: array size of init_data 78*4882a593Smuzhiyun */ 79*4882a593Smuzhiyun struct max8997_muic_platform_data { 80*4882a593Smuzhiyun struct max8997_muic_reg_data *init_data; 81*4882a593Smuzhiyun int num_init_data; 82*4882a593Smuzhiyun 83*4882a593Smuzhiyun /* Check cable state after certain delay */ 84*4882a593Smuzhiyun int detcable_delay_ms; 85*4882a593Smuzhiyun 86*4882a593Smuzhiyun /* 87*4882a593Smuzhiyun * Default usb/uart path whether UART/USB or AUX_UART/AUX_USB 88*4882a593Smuzhiyun * h/w path of COMP2/COMN1 on CONTROL1 register. 89*4882a593Smuzhiyun */ 90*4882a593Smuzhiyun int path_usb; 91*4882a593Smuzhiyun int path_uart; 92*4882a593Smuzhiyun }; 93*4882a593Smuzhiyun 94*4882a593Smuzhiyun enum max8997_haptic_motor_type { 95*4882a593Smuzhiyun MAX8997_HAPTIC_ERM, 96*4882a593Smuzhiyun MAX8997_HAPTIC_LRA, 97*4882a593Smuzhiyun }; 98*4882a593Smuzhiyun 99*4882a593Smuzhiyun enum max8997_haptic_pulse_mode { 100*4882a593Smuzhiyun MAX8997_EXTERNAL_MODE, 101*4882a593Smuzhiyun MAX8997_INTERNAL_MODE, 102*4882a593Smuzhiyun }; 103*4882a593Smuzhiyun 104*4882a593Smuzhiyun enum max8997_haptic_pwm_divisor { 105*4882a593Smuzhiyun MAX8997_PWM_DIVISOR_32, 106*4882a593Smuzhiyun MAX8997_PWM_DIVISOR_64, 107*4882a593Smuzhiyun MAX8997_PWM_DIVISOR_128, 108*4882a593Smuzhiyun MAX8997_PWM_DIVISOR_256, 109*4882a593Smuzhiyun }; 110*4882a593Smuzhiyun 111*4882a593Smuzhiyun /** 112*4882a593Smuzhiyun * max8997_haptic_platform_data 113*4882a593Smuzhiyun * @pwm_channel_id: channel number of PWM device 114*4882a593Smuzhiyun * valid for MAX8997_EXTERNAL_MODE 115*4882a593Smuzhiyun * @pwm_period: period in nano second for PWM device 116*4882a593Smuzhiyun * valid for MAX8997_EXTERNAL_MODE 117*4882a593Smuzhiyun * @type: motor type 118*4882a593Smuzhiyun * @mode: pulse mode 119*4882a593Smuzhiyun * MAX8997_EXTERNAL_MODE: external PWM device is used to control motor 120*4882a593Smuzhiyun * MAX8997_INTERNAL_MODE: internal pulse generator is used to control motor 121*4882a593Smuzhiyun * @pwm_divisor: divisor for external PWM device 122*4882a593Smuzhiyun * @internal_mode_pattern: internal mode pattern for internal mode 123*4882a593Smuzhiyun * [0 - 3]: valid pattern number 124*4882a593Smuzhiyun * @pattern_cycle: the number of cycles of the waveform 125*4882a593Smuzhiyun * for the internal mode pattern 126*4882a593Smuzhiyun * [0 - 15]: available cycles 127*4882a593Smuzhiyun * @pattern_signal_period: period of the waveform for the internal mode pattern 128*4882a593Smuzhiyun * [0 - 255]: available period 129*4882a593Smuzhiyun */ 130*4882a593Smuzhiyun struct max8997_haptic_platform_data { 131*4882a593Smuzhiyun unsigned int pwm_channel_id; 132*4882a593Smuzhiyun unsigned int pwm_period; 133*4882a593Smuzhiyun 134*4882a593Smuzhiyun enum max8997_haptic_motor_type type; 135*4882a593Smuzhiyun enum max8997_haptic_pulse_mode mode; 136*4882a593Smuzhiyun enum max8997_haptic_pwm_divisor pwm_divisor; 137*4882a593Smuzhiyun 138*4882a593Smuzhiyun unsigned int internal_mode_pattern; 139*4882a593Smuzhiyun unsigned int pattern_cycle; 140*4882a593Smuzhiyun unsigned int pattern_signal_period; 141*4882a593Smuzhiyun }; 142*4882a593Smuzhiyun 143*4882a593Smuzhiyun enum max8997_led_mode { 144*4882a593Smuzhiyun MAX8997_NONE, 145*4882a593Smuzhiyun MAX8997_FLASH_MODE, 146*4882a593Smuzhiyun MAX8997_MOVIE_MODE, 147*4882a593Smuzhiyun MAX8997_FLASH_PIN_CONTROL_MODE, 148*4882a593Smuzhiyun MAX8997_MOVIE_PIN_CONTROL_MODE, 149*4882a593Smuzhiyun }; 150*4882a593Smuzhiyun 151*4882a593Smuzhiyun /** 152*4882a593Smuzhiyun * struct max8997_led_platform_data 153*4882a593Smuzhiyun * The number of LED devices for MAX8997 is two 154*4882a593Smuzhiyun * @mode: LED mode for each LED device 155*4882a593Smuzhiyun * @brightness: initial brightness for each LED device 156*4882a593Smuzhiyun * range: 157*4882a593Smuzhiyun * [0 - 31]: MAX8997_FLASH_MODE and MAX8997_FLASH_PIN_CONTROL_MODE 158*4882a593Smuzhiyun * [0 - 15]: MAX8997_MOVIE_MODE and MAX8997_MOVIE_PIN_CONTROL_MODE 159*4882a593Smuzhiyun */ 160*4882a593Smuzhiyun struct max8997_led_platform_data { 161*4882a593Smuzhiyun enum max8997_led_mode mode[2]; 162*4882a593Smuzhiyun u8 brightness[2]; 163*4882a593Smuzhiyun }; 164*4882a593Smuzhiyun 165*4882a593Smuzhiyun struct max8997_platform_data { 166*4882a593Smuzhiyun /* IRQ */ 167*4882a593Smuzhiyun int ono; 168*4882a593Smuzhiyun 169*4882a593Smuzhiyun /* ---- PMIC ---- */ 170*4882a593Smuzhiyun struct max8997_regulator_data *regulators; 171*4882a593Smuzhiyun int num_regulators; 172*4882a593Smuzhiyun 173*4882a593Smuzhiyun /* 174*4882a593Smuzhiyun * SET1~3 DVS GPIOs control Buck1, 2, and 5 simultaneously. Therefore, 175*4882a593Smuzhiyun * With buckx_gpiodvs enabled, the buckx cannot be controlled 176*4882a593Smuzhiyun * independently. To control buckx (of 1, 2, and 5) independently, 177*4882a593Smuzhiyun * disable buckx_gpiodvs and control with BUCKxDVS1 register. 178*4882a593Smuzhiyun * 179*4882a593Smuzhiyun * When buckx_gpiodvs and bucky_gpiodvs are both enabled, set_voltage 180*4882a593Smuzhiyun * on buckx will change the voltage of bucky at the same time. 181*4882a593Smuzhiyun * 182*4882a593Smuzhiyun */ 183*4882a593Smuzhiyun bool ignore_gpiodvs_side_effect; 184*4882a593Smuzhiyun int buck125_gpios[3]; /* GPIO of [0]SET1, [1]SET2, [2]SET3 */ 185*4882a593Smuzhiyun int buck125_default_idx; /* Default value of SET1, 2, 3 */ 186*4882a593Smuzhiyun unsigned int buck1_voltage[8]; /* buckx_voltage in uV */ 187*4882a593Smuzhiyun bool buck1_gpiodvs; 188*4882a593Smuzhiyun unsigned int buck2_voltage[8]; 189*4882a593Smuzhiyun bool buck2_gpiodvs; 190*4882a593Smuzhiyun unsigned int buck5_voltage[8]; 191*4882a593Smuzhiyun bool buck5_gpiodvs; 192*4882a593Smuzhiyun 193*4882a593Smuzhiyun /* ---- Charger control ---- */ 194*4882a593Smuzhiyun /* eoc stands for 'end of charge' */ 195*4882a593Smuzhiyun int eoc_mA; /* 50 ~ 200mA by 10mA step */ 196*4882a593Smuzhiyun /* charge Full Timeout */ 197*4882a593Smuzhiyun int timeout; /* 0 (no timeout), 5, 6, 7 hours */ 198*4882a593Smuzhiyun 199*4882a593Smuzhiyun /* ---- MUIC ---- */ 200*4882a593Smuzhiyun struct max8997_muic_platform_data *muic_pdata; 201*4882a593Smuzhiyun 202*4882a593Smuzhiyun /* ---- HAPTIC ---- */ 203*4882a593Smuzhiyun struct max8997_haptic_platform_data *haptic_pdata; 204*4882a593Smuzhiyun 205*4882a593Smuzhiyun /* RTC: Not implemented */ 206*4882a593Smuzhiyun /* ---- LED ---- */ 207*4882a593Smuzhiyun struct max8997_led_platform_data *led_pdata; 208*4882a593Smuzhiyun }; 209*4882a593Smuzhiyun 210*4882a593Smuzhiyun #endif /* __LINUX_MFD_MAX8998_H */ 211