Add samsung specific changes

This commit is contained in:
2025-08-11 14:29:00 +02:00
parent c66122e619
commit 4d134a1294
2688 changed files with 1127995 additions and 11475 deletions

View File

@@ -0,0 +1,431 @@
/*
* max77775-private.h - Voltage regulator driver for the Maxim 77775
*
* Copyright (C) 2016 Samsung Electrnoics
* Insun Choi <insun77.choi@samsung.com>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __LINUX_MFD_MAX77775_PRIV_H
#define __LINUX_MFD_MAX77775_PRIV_H
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/irq.h>
#include <linux/gpio.h>
#include <linux/delay.h>
#include <linux/i2c.h>
#include <linux/usb/typec/maxim/max77775.h>
#include <linux/mfd/max77775_log.h>
/* To Do : Customer Definition for product id */
#define MAX77775_USBC_PRODUCT_ID (0x75)
#define MAX77775_REG_INVALID (0xff)
#define MAX77775_IRQSRC_CHG (1 << 0)
#define MAX77775_IRQSRC_TOP (1 << 1)
#define MAX77775_IRQSRC_FG (1 << 2)
#define MAX77775_IRQSRC_USBC (1 << 3)
#define MAX77775_ELRN (1 << 0)
#define MAX77775_FILT_EMPTY (1 << 2)
enum max77775_hw_rev {
MAX77775_PASS1 = 0x1,
MAX77775_PASS2 = 0x2,
MAX77775_PASS3 = 0x3,
MAX77775_PASS4 = 0x4,
MAX77775_PASS5 = 0x5,
};
enum max77775_reg {
/* Slave addr = 0xCC */
/* PMIC Top-Level Registers */
MAX77775_PMIC_REG_PMICID = 0x00,
MAX77775_PMIC_REG_PMICREV = 0x01,
MAX77775_PMIC_REG_MAINCTRL1 = 0x02,
MAX77775_PMIC_REG_INTSRC = 0x22,
MAX77775_PMIC_REG_INTSRC_MASK = 0x23,
MAX77775_PMIC_REG_SYSTEM_INT = 0x24,
MAX77775_PMIC_REG_SYSTEM_INT_MASK = 0x26,
MAX77775_PMIC_REG_SW_RESET = 0x50,
MAX77775_CHG_REG_INT = 0xB0,
MAX77775_CHG_REG_INT_MASK = 0xB1,
MAX77775_CHG_REG_INT_OK = 0xB2,
MAX77775_CHG_REG_DETAILS_00 = 0xB3,
MAX77775_CHG_REG_DETAILS_01 = 0xB4,
MAX77775_CHG_REG_DETAILS_02 = 0xB5,
MAX77775_CHG_REG_CNFG_00 = 0xB7,
MAX77775_CHG_REG_CNFG_01 = 0xB8,
MAX77775_CHG_REG_CNFG_02 = 0xB9,
MAX77775_CHG_REG_CNFG_03 = 0xBA,
MAX77775_CHG_REG_CNFG_04 = 0xBB,
MAX77775_CHG_REG_CNFG_05 = 0xBC,
MAX77775_CHG_REG_CNFG_06 = 0xBD,
MAX77775_CHG_REG_CNFG_07 = 0xBE,
MAX77775_CHG_REG_CNFG_08 = 0xBF,
MAX77775_CHG_REG_CNFG_09 = 0xC0,
MAX77775_CHG_REG_CNFG_10 = 0xC1,
MAX77775_CHG_REG_CNFG_11 = 0xC2,
MAX77775_CHG_REG_CNFG_12 = 0xC3,
MAX77775_CHG_REG_CNFG_13 = 0xC4,
MAX77775_CHG_REG_CNFG_14 = 0xC5,
MAX77775_CHG_REG_CNFG_16 = 0xC7,
MAX77775_CHG_REG_CNFG_17 = 0xC8,
MAX77775_PMIC_REG_END,
};
/* Slave addr = 0x6C : Fuelgauge */
enum max77775_fuelgauge_reg {
MAX77775_FG_REG_STATUS = 0x00,
MAX77775_FG_REG_VALRTTH = 0x01,
MAX77775_FG_REG_TALRTTH = 0x02,
MAX77775_FG_REG_SALRTTH = 0x03,
MAX77775_FG_REG_REPCAP = 0x05,
MAX77775_FG_REG_REPSOC = 0x06,
MAX77775_FG_REG_TEMP = 0x08,
MAX77775_FG_REG_VCELL = 0x09,
MAX77775_FG_REG_CURRENT = 0x0A,
MAX77775_FG_REG_AVGCURRENT = 0x0B,
MAX77775_FG_REG_AVSOC = 0x0E,
MAX77775_FG_REG_MIXCAP = 0x0F,
MAX77775_FG_REG_FULLCAP = 0x10,
MAX77775_FG_QRTABLE00 = 0x12,
MAX77775_FG_REG_FULLSOCTHR = 0x13,
MAX77775_FG_REG_CYCLES = 0x17,
MAX77775_FG_REG_DESIGNCAP = 0x18,
MAX77775_FG_REG_AVGVCELL = 0x19,
MAX77775_FG_REG_CONFIG = 0x1D,
MAX77775_FG_REG_ICHGTERM = 0x1E,
MAX77775_FG_REG_REMCAPAV = 0x1F,
MAX77775_FG_QRTABLE10 = 0x22,
MAX77775_FG_REG_FULLCAPNOM = 0x23,
MAX77775_FG_REG_LEARNCFG = 0x28,
MAX77775_FG_REG_FILTERCFG = 0x29,
MAX77775_FG_REG_MISCCFG = 0x2B,
MAX77775_FG_REG_CGAIN = 0x2E,
MAX77775_FG_REG_COFF = 0x2F,
MAX77775_FG_QRTABLE20 = 0x32,
MAX77775_FG_REG_FULLCAPREP = 0x35,
MAX77775_FG_REG_RCOMP0 = 0x38,
MAX77775_FG_REG_TEMPCO = 0x39,
MAX77775_FG_REG_VEMPTY = 0x3A,
MAX77775_FG_QRTABLE30 = 0x42,
MAX77775_FG_REG_ISYS = 0x43,
MAX77775_FG_REG_DQACC = 0x45,
MAX77775_FG_REG_DPACC = 0x46,
MAX77775_FG_REG_AVGISYS = 0x4B,
MAX77775_FG_REG_QH = 0x4D,
MAX77775_FG_REG_VSYS = 0xB1,
MAX77775_FG_REG_TALRTTH2 = 0xB2,
/* "not used REG(0xB2)" is for checking fuelgague init result. */
MAX77775_FG_INIT_RESULT_REG = MAX77775_FG_REG_TALRTTH2,
MAX77775_FG_REG_VBYP = 0xB3,
MAX77775_FG_REG_CONFIG2 = 0xBB,
MAX77775_FG_REG_IIN = 0xD0,
MAX77775_FG_REG_VFOCV = 0xFB,
MAX77775_FG_REG_VFSOC = 0xFF,
MAX77775_FG_REG_END
};
#define MAX77775_REG_MAINCTRL1_BIASEN (1 << 7)
/* Slave addr = 0x4A: USBC */
enum max77775_usbc_reg {
MAX77775_USBC_REG_PRODUCT_ID = 0x10, /* replaced address */
MAX77775_USBC_REG_UIC_FW_REV = 0x01,
MAX77775_USBC_REG_UIC_INT = 0x02,
MAX77775_USBC_REG_CC_INT = 0x03,
MAX77775_USBC_REG_PD_INT = 0x04,
MAX77775_USBC_REG_VDM_INT = 0x05,
MAX77775_USBC_REG_SPARE_INT = 0x06,
MAX77775_USBC_REG_USBC_STATUS1 = 0x08,
MAX77775_USBC_REG_USBC_STATUS2 = 0x09,
MAX77775_USBC_REG_BC_STATUS = 0x0A,
MAX77775_USBC_REG_UIC_FW_REV2 = 0x0B,
MAX77775_USBC_REG_CC_STATUS1 = 0x0C,
MAX77775_USBC_REG_CC_STATUS2 = 0x0D,
MAX77775_USBC_REG_PD_STATUS1 = 0x0E,
MAX77775_USBC_REG_PD_STATUS2 = 0x0F,
MAX77775_USBC_REG_SPARE_STATUS1 = 0x11,
MAX77775_USBC_REG_UIC_INT_M = 0x12,
MAX77775_USBC_REG_CC_INT_M = 0x13,
MAX77775_USBC_REG_PD_INT_M = 0x14,
MAX77775_USBC_REG_VDM_INT_M = 0x15,
MAX77775_USBC_REG_SPARE_INT_M = 0x16,
MAX77775_USBC_REG_AP_DATAOUT_M1 = 0x20,
MAX77775_USBC_REG_AP_DATAOUT0 = 0x21,
MAX77775_USBC_REG_AP_DATAOUT1 = 0x22,
MAX77775_USBC_REG_AP_DATAOUT2 = 0x23,
MAX77775_USBC_REG_AP_DATAOUT3 = 0x24,
MAX77775_USBC_REG_AP_DATAOUT4 = 0x25,
MAX77775_USBC_REG_AP_DATAOUT5 = 0x26,
MAX77775_USBC_REG_AP_DATAOUT6 = 0x27,
MAX77775_USBC_REG_AP_DATAOUT7 = 0x28,
MAX77775_USBC_REG_AP_DATAOUT8 = 0x29,
MAX77775_USBC_REG_AP_DATAOUT9 = 0x2a,
MAX77775_USBC_REG_AP_DATAOUT10 = 0x2b,
MAX77775_USBC_REG_AP_DATAOUT11 = 0x2c,
MAX77775_USBC_REG_AP_DATAOUT12 = 0x2d,
MAX77775_USBC_REG_AP_DATAOUT13 = 0x2e,
MAX77775_USBC_REG_AP_DATAOUT14 = 0x2f,
MAX77775_USBC_REG_AP_DATAOUT15 = 0x30,
MAX77775_USBC_REG_AP_DATAOUT16 = 0x31,
MAX77775_USBC_REG_AP_DATAOUT17 = 0x32,
MAX77775_USBC_REG_AP_DATAOUT18 = 0x33,
MAX77775_USBC_REG_AP_DATAOUT19 = 0x34,
MAX77775_USBC_REG_AP_DATAOUT20 = 0x35,
MAX77775_USBC_REG_AP_DATAOUT21 = 0x36,
MAX77775_USBC_REG_AP_DATAOUT22 = 0x37,
MAX77775_USBC_REG_AP_DATAOUT23 = 0x38,
MAX77775_USBC_REG_AP_DATAOUT24 = 0x39,
MAX77775_USBC_REG_AP_DATAOUT25 = 0x3a,
MAX77775_USBC_REG_AP_DATAOUT26 = 0x3b,
MAX77775_USBC_REG_AP_DATAOUT27 = 0x3c,
MAX77775_USBC_REG_AP_DATAOUT28 = 0x3d,
MAX77775_USBC_REG_AP_DATAOUT29 = 0x3e,
MAX77775_USBC_REG_AP_DATAOUT30 = 0x3f,
MAX77775_USBC_REG_AP_DATAOUT31 = 0x40,
MAX77775_USBC_REG_AP_DATAOUT32 = 0x41,
MAX77775_USBC_REG_AP_DATAIN_M1 = 0x50,
MAX77775_USBC_REG_AP_DATAIN0 = 0x51,
MAX77775_USBC_REG_AP_DATAIN1 = 0x52,
MAX77775_USBC_REG_AP_DATAIN2 = 0x53,
MAX77775_USBC_REG_AP_DATAIN3 = 0x54,
MAX77775_USBC_REG_AP_DATAIN4 = 0x55,
MAX77775_USBC_REG_AP_DATAIN5 = 0x56,
MAX77775_USBC_REG_AP_DATAIN6 = 0x57,
MAX77775_USBC_REG_AP_DATAIN7 = 0x58,
MAX77775_USBC_REG_AP_DATAIN8 = 0x59,
MAX77775_USBC_REG_AP_DATAIN9 = 0x5a,
MAX77775_USBC_REG_AP_DATAIN10 = 0x5b,
MAX77775_USBC_REG_AP_DATAIN11 = 0x5c,
MAX77775_USBC_REG_AP_DATAIN12 = 0x5d,
MAX77775_USBC_REG_AP_DATAIN13 = 0x5e,
MAX77775_USBC_REG_AP_DATAIN14 = 0x5f,
MAX77775_USBC_REG_AP_DATAIN15 = 0x60,
MAX77775_USBC_REG_AP_DATAIN16 = 0x61,
MAX77775_USBC_REG_AP_DATAIN17 = 0x62,
MAX77775_USBC_REG_AP_DATAIN18 = 0x63,
MAX77775_USBC_REG_AP_DATAIN19 = 0x64,
MAX77775_USBC_REG_AP_DATAIN20 = 0x65,
MAX77775_USBC_REG_AP_DATAIN21 = 0x66,
MAX77775_USBC_REG_AP_DATAIN22 = 0x67,
MAX77775_USBC_REG_AP_DATAIN23 = 0x68,
MAX77775_USBC_REG_AP_DATAIN24 = 0x69,
MAX77775_USBC_REG_AP_DATAIN25 = 0x6a,
MAX77775_USBC_REG_AP_DATAIN26 = 0x6b,
MAX77775_USBC_REG_AP_DATAIN27 = 0x6c,
MAX77775_USBC_REG_AP_DATAIN28 = 0x6d,
MAX77775_USBC_REG_AP_DATAIN29 = 0x6e,
MAX77775_USBC_REG_AP_DATAIN30 = 0x6f,
MAX77775_USBC_REG_AP_DATAIN31 = 0x70,
MAX77775_USBC_REG_AP_DATAIN32 = 0x71,
MAX77775_USBC_REG_UIC_SWRST = 0x80,
MAX77775_USBC_REG_END,
};
enum max77775_irq_source {
SYS_INT = 0,
CHG_INT,
FUEL_INT,
USBC_INT,
CC_INT,
PD_INT,
VDM_INT,
SPARE_INT,
VIR_INT,
MAX77775_IRQ_GROUP_NR,
};
enum max77775_irq {
/* PMIC; TOPSYS */
MAX77775_SYSTEM_IRQ_SYSUVLO_INT,
MAX77775_SYSTEM_IRQ_SYSOVLO_INT,
MAX77775_SYSTEM_IRQ_TSHDN_INT,
MAX77775_SYSTEM_IRQ_SCP_INT,
/* PMIC; Charger */
MAX77775_CHG_IRQ_BYP_I,
MAX77775_CHG_IRQ_BATP_I,
MAX77775_CHG_IRQ_BAT_I,
MAX77775_CHG_IRQ_CHG_I,
MAX77775_CHG_IRQ_WCIN_I,
MAX77775_CHG_IRQ_CHGIN_I,
MAX77775_CHG_IRQ_AICL_I,
/* Fuelgauge */
MAX77775_FG_IRQ_ALERT,
/* USBC */
MAX77775_USBC_IRQ_APC_INT,
/* CC */
MAX77775_CC_IRQ_VCONNCOP_INT,
MAX77775_CC_IRQ_VSAFE0V_INT,
MAX77775_CC_IRQ_DETABRT_INT,
MAX77775_CC_IRQ_VCONNSC_INT,
MAX77775_CC_IRQ_CCPINSTAT_INT,
MAX77775_CC_IRQ_CCISTAT_INT,
MAX77775_CC_IRQ_CCVCNSTAT_INT,
MAX77775_CC_IRQ_CCSTAT_INT,
MAX77775_USBC_IRQ_VBUS_INT,
MAX77775_USBC_IRQ_VBADC_INT,
MAX77775_USBC_IRQ_DCD_INT,
MAX77775_USBC_IRQ_STOPMODE_INT,
MAX77775_USBC_IRQ_CHGT_INT,
MAX77775_USBC_IRQ_UIDADC_INT,
/*
* USBC: SYSMSG INT should be after CC INT
* because of 2 times of CC Sync INT at WDT reset
*/
MAX77775_USBC_IRQ_SYSM_INT,
/* PD */
MAX77775_PD_IRQ_PDMSG_INT,
MAX77775_PD_IRQ_PS_RDY_INT,
MAX77775_PD_IRQ_DATAROLE_INT,
MAX77775_PD_IRQ_SSACCI_INT,
MAX77775_PD_IRQ_FCTIDI_INT,
/* VDM */
MAX77775_IRQ_VDM_DISCOVER_ID_INT,
MAX77775_IRQ_VDM_DISCOVER_SVIDS_INT,
MAX77775_IRQ_VDM_DISCOVER_MODES_INT,
MAX77775_IRQ_VDM_ENTER_MODE_INT,
MAX77775_IRQ_VDM_DP_STATUS_UPDATE_INT,
MAX77775_IRQ_VDM_DP_CONFIGURE_INT,
MAX77775_IRQ_VDM_ATTENTION_INT,
/* SPARE */
MAX77775_IRQ_USBID_INT,
MAX77775_IRQ_TACONN_INT,
/* VIRTUAL */
MAX77775_VIR_IRQ_ALTERROR_INT,
MAX77775_IRQ_NR,
};
struct max77775_dev {
struct device *dev;
struct i2c_client *i2c; /* 0xCC; PMIC */
struct i2c_client *charger; /* 0xD2; Charger */
struct i2c_client *fuelgauge; /* 0x6C; Fuelgauge */
struct i2c_client *muic; /* 0x4A; MUIC */
struct i2c_client *testsid; /* 0xC4; TestSID */
struct mutex i2c_lock;
struct wakeup_source ws;
int type;
int irq;
int irq_base;
int irq_gpio;
bool blocking_waterevent;
u32 required_hw_rev;
u32 required_fw_pid;
struct mutex irqlock;
int irq_masks_cur[MAX77775_IRQ_GROUP_NR];
int irq_masks_cache[MAX77775_IRQ_GROUP_NR];
u8 FW_Revision;
u8 FW_Minor_Revision;
u8 FW_Product_ID;
u8 FW_Revision_bin;
u8 FW_Minor_Revision_bin;
u8 FW_Product_ID_bin;
struct work_struct fw_work;
struct workqueue_struct *fw_workqueue;
struct completion fw_completion;
int fw_update_state;
int fw_size;
/* For hibernation */
u8 reg_pmic_dump[MAX77775_PMIC_REG_END];
u8 reg_muic_dump[MAX77775_USBC_REG_END];
u8 pmic_id; /* pmic id. 0x75 */
u8 pmic_rev; /* pmic Rev */
u8 cc_booting_complete;
int set_altmode_en;
int enable_nested_irq;
u8 usbc_irq;
bool shutdown;
bool suspended;
wait_queue_head_t suspend_wait;
void (*check_pdmsg)(void *data, u8 pdmsg);
void *usbc_data;
struct max77775_platform_data *pdata;
};
enum max77775_types {
TYPE_MAX77775,
};
extern int max77775_irq_init(struct max77775_dev *max77775);
extern void max77775_irq_exit(struct max77775_dev *max77775);
/* MAX77775 shared i2c API function */
extern int max77775_read_reg(struct i2c_client *i2c, u8 reg, u8 *dest);
extern int max77775_bulk_read(struct i2c_client *i2c, u8 reg, int count,
u8 *buf);
extern int max77775_write_reg(struct i2c_client *i2c, u8 reg, u8 value);
extern int max77775_write_reg_nolock(struct i2c_client *i2c, u8 reg, u8 value);
extern int max77775_bulk_write(struct i2c_client *i2c, u8 reg, int count,
u8 *buf);
extern int max77775_write_word(struct i2c_client *i2c, u8 reg, u16 value);
extern int max77775_read_word(struct i2c_client *i2c, u8 reg);
extern int max77775_update_reg(struct i2c_client *i2c, u8 reg, u8 val, u8 mask);
/* MAX77775 check muic path function */
extern bool is_muic_usb_path_ap_usb(void);
extern bool is_muic_usb_path_cp_usb(void);
/* for charger api */
extern void max77775_hv_muic_charger_init(void);
extern int max77775_usbc_fw_update(struct max77775_dev *max77775, const u8 *fw_bin, int fw_bin_len, int enforce_do);
extern int max77775_usbc_fw_setting(struct max77775_dev *max77775, int enforce_do);
extern void max77775_register_pdmsg_func(struct max77775_dev *max77775,
void (*check_pdmsg)(void *, u8), void *data);
#define MAX77775_DEBUG_ENABLED
#ifdef MAX77775_DEBUG_ENABLED
#define msg_maxim(format, args...) \
md75_info_usb("max77775: %s: " format "\n", __func__, ## args)
#define err_maxim(format, args...) \
md75_err_usb("max77775: %s: " format "\n", __func__, ## args)
#else
#define msg_maxim(format, args...)
#define err_maxim(format, args...)
#endif // MAX77775_DEBUG_ENABLED
#endif /* __LINUX_MFD_MAX77775_PRIV_H */

View File

@@ -0,0 +1,121 @@
/*
* max77775.h - Driver for the Maxim 77775
*
* Copyright (C) 2016 Samsung Electrnoics
* Insun Choi <insun77.choi@samsung.com>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* This driver is based on max8997.h
*
* MAX77775 has Flash LED, SVC LED, Haptic, MUIC devices.
* The devices share the same I2C bus and included in
* this mfd driver.
*/
#ifndef __MAX77775_H__
#define __MAX77775_H__
#include <linux/platform_device.h>
#include <linux/regmap.h>
#define MFD_DEV_NAME "max77775"
#define M2SH(m) ((m) & 0x0F ? ((m) & 0x03 ? ((m) & 0x01 ? 0 : 1) : ((m) & 0x04 ? 2 : 3)) : \
((m) & 0x30 ? ((m) & 0x10 ? 4 : 5) : ((m) & 0x40 ? 6 : 7)))
struct max77775_vibrator_pdata {
int gpio;
char *regulator_name;
struct pwm_device *pwm;
const char *motor_type;
int freq;
/* for multi-frequency */
int freq_nums;
u32 *freq_array;
u32 *ratio_array; /* not used now */
int normal_ratio;
int overdrive_ratio;
int high_temp_ratio;
int high_temp_ref;
int fold_open_ratio;
int fold_close_ratio;
#if defined(CONFIG_SEC_VIBRATOR)
bool calibration;
int steps;
int *intensities;
int *haptic_intensities;
#endif
};
struct max77775_regulator_data {
int id;
struct regulator_init_data *initdata;
struct device_node *reg_node;
};
struct max77775_platform_data {
/* IRQ */
int irq_base;
int irq_gpio;
bool wakeup;
bool blocking_waterevent;
bool extra_fw_enable;
int wpc_en;
u32 rev;
u32 fw_product_id;
u32 fg_resistor;
struct muic_platform_data *muic_pdata;
int num_regulators;
struct max77775_regulator_data *regulators;
struct max77775_vibrator_pdata *vibrator_data;
struct mfd_cell *sub_devices;
int num_subdevs;
bool support_audio;
char *wireless_charger_name;
};
struct max77775 {
struct regmap *regmap;
};
typedef struct {
u32 magic; /* magic number */
u8 major; /* major version */
u8 minor; /* minor version */
u8 id; /* id */
u8 rev; /* rev */
} max77775_fw_header;
#define MAX77775_SIGN 0xCEF166C1
enum {
FW_UPDATE_START = 0x00,
FW_UPDATE_WAIT_RESP_START,
FW_UPDATE_WAIT_RESP_STOP,
FW_UPDATE_DOING,
FW_UPDATE_END,
};
enum {
FW_UPDATE_FAIL = 0xF0,
FW_UPDATE_I2C_FAIL,
FW_UPDATE_TIMEOUT_FAIL,
FW_UPDATE_VERIFY_FAIL,
FW_UPDATE_CMD_FAIL,
FW_UPDATE_MAX_LENGTH_FAIL,
FW_UPDATE_ERR_CODE_FAIL,
};
#endif /* __MAX77775_H__ */

View File

@@ -0,0 +1,35 @@
/*
* max77775_log.h - Driver for the Maxim 77775
*
*/
#ifndef __MAX77775_LOG_H__
#define __MAX77775_LOG_H__
#ifdef CONFIG_USB_NOTIFY_PROC_LOG
#include <linux/usblog_proc_notify.h>
#endif
#ifdef CONFIG_USB_USING_ADVANCED_USBLOG
#define md75_info_usb(fmt, ...) \
({ \
pr_info(fmt, ##__VA_ARGS__); \
printk_usb(NOTIFY_PRINTK_USB_NORMAL, fmt, ##__VA_ARGS__); \
})
#define md75_err_usb(fmt, ...) \
({ \
pr_err(fmt, ##__VA_ARGS__); \
printk_usb(NOTIFY_PRINTK_USB_NORMAL, fmt, ##__VA_ARGS__); \
})
#else
#define md75_info_usb(fmt, ...) \
({ \
pr_info(fmt, ##__VA_ARGS__); \
})
#define md75_err_usb(fmt, ...) \
({ \
pr_err(fmt, ##__VA_ARGS__); \
})
#endif
#endif /* __MAX77775_LOG_H__ */

View File

@@ -0,0 +1,134 @@
/*
* s2mpb02-regulator.h - Voltage regulator driver for the Samsung s2mpb02
*
* Copyright (C) 2014 Samsung Electrnoics
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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
*/
#ifndef __LINUX_MFD_S2MPB02_REGULATOR_H
#define __LINUX_MFD_S2MPB02_REGULATOR_H
/* S2MPB02 registers */
enum s2mpb02_reg {
S2MPB02_REG_ID,
S2MPB02_REG_INT1,
S2MPB02_REG_INT1M,
S2MPB02_REG_ST1,
S2MPB02_REG_CTRL,
S2MPB02_REG_RSVD5,
S2MPB02_REG_RSVD6,
S2MPB02_REG_RSVD7,
S2MPB02_REG_RSVD8,
S2MPB02_REG_BBEN_DBT,
S2MPB02_REG_RSVDA,
S2MPB02_REG_B1CTRL1,
S2MPB02_REG_B1CTRL2,
S2MPB02_REG_B2CTRL1,
S2MPB02_REG_B2CTRL2,
S2MPB02_REG_BB1CTRL1,
S2MPB02_REG_BB1CTRL2,
S2MPB02_REG_BUCK_RAMP,
S2MPB02_REG_FLED_CTRL1,
S2MPB02_REG_FLED_CTRL2,
S2MPB02_REG_FLED_CUR1,
S2MPB02_REG_FLED_TIME1,
S2MPB02_REG_FLED_CUR2,
S2MPB02_REG_FLED_TIME2,
S2MPB02_REG_FLED_IRON1,
S2MPB02_REG_FLED_IRON2,
S2MPB02_REG_FLED_IRD1,
S2MPB02_REG_FLED_IRD2,
S2MPB02_REG_BST_CTRL1,
S2MPB02_REG_BST_CTRL2,
S2MPB02_REG_L1CTRL,
S2MPB02_REG_L2CTRL,
S2MPB02_REG_L3CTRL,
S2MPB02_REG_L4CTRL,
S2MPB02_REG_L5CTRL,
S2MPB02_REG_L6CTRL,
S2MPB02_REG_L7CTRL,
S2MPB02_REG_L8CTRL,
S2MPB02_REG_L9CTRL,
S2MPB02_REG_L10CTRL,
S2MPB02_REG_L11CTRL,
S2MPB02_REG_L12CTRL,
S2MPB02_REG_L13CTRL,
S2MPB02_REG_L14CTRL,
S2MPB02_REG_L15CTRL,
S2MPB02_REG_L16CTRL,
S2MPB02_REG_L17CTRL,
S2MPB02_REG_L18CTRL,
S2MPB02_REG_LDO_DSCH1,
S2MPB02_REG_LDO_DSCH2,
S2MPB02_REG_LDO_DSCH3,
};
/* S2MPB02 regulator ids */
enum S2MPB02_regulators {
S2MPB02_LDO1,
S2MPB02_LDO2,
S2MPB02_LDO3,
S2MPB02_LDO4,
S2MPB02_LDO5,
S2MPB02_LDO6,
S2MPB02_LDO7,
S2MPB02_LDO8,
S2MPB02_LDO9,
S2MPB02_LDO10,
S2MPB02_LDO11,
S2MPB02_LDO12,
S2MPB02_LDO13,
S2MPB02_LDO14,
S2MPB02_LDO15,
S2MPB02_LDO16,
S2MPB02_LDO17,
S2MPB02_LDO18,
S2MPB02_BUCK1,
S2MPB02_BUCK2,
S2MPB02_BB1,
S2MPB02_REG_MAX,
};
#define S2MPB02_BUCK_MIN1 400000
#define S2MPB02_BUCK_MIN2 2600000
#define S2MPB02_LDO_MIN1 600000
#define S2MPB02_BUCK_STEP1 6250
#define S2MPB02_BUCK_STEP2 12500
#define S2MPB02_LDO_STEP1 12500
#define S2MPB02_LDO_STEP2 25000
#define S2MPB02_LDO_VSEL_MASK 0x7F
#define S2MPB02_BUCK_VSEL_MASK 0xFF
#define S2MPB02_BUCK_ENABLE_MASK 0xC0
#define S2MPB02_LDO_ENABLE_MASK 0x80
#define S2MPB02_RAMP_DELAY 12000
#define S2MPB02_ENABLE_TIME_LDO 180
#define S2MPB02_ENABLE_TIME_BUCK 100
#define S2MPB02_ENABLE_TIME_BB 210
#define S2MPB02_BUCK_ENABLE_SHIFT 0x06
#define S2MPB02_LDO_ENABLE_SHIFT 0x07
#define S2MPB02_LDO_N_VOLTAGES (S2MPB02_LDO_VSEL_MASK + 1)
#define S2MPB02_BUCK_N_VOLTAGES (S2MPB02_BUCK_VSEL_MASK + 1)
#define S2MPB02_REGULATOR_MAX (S2MPB02_REG_MAX)
#define DVS_DEFAULT_VALUE (0x90)
#endif /* __LINUX_MFD_S2MPB02_PRIV_H */

View File

@@ -0,0 +1,121 @@
/*
* s2mpb02.h - Driver for the Samsung s2mpb02
*
* Copyright (C) 2014 Samsung Electrnoics
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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
*
*
* S2MPB02 has Flash LED devices.
* The devices share the same I2C bus and included in
* this mfd driver.
*/
#ifndef __S2MPB02_H__
#define __S2MPB02_H__
#include <linux/i2c.h>
#define MFD_DEV_NAME "s2mpb02"
#define S2MPB02_I2C_ADDR (0xB2 >> 1)
#define S2MPB02_REG_INVALID (0xff)
#define S2MPB02_PMIC_REV(iodev) (iodev)->rev_num
enum s2mpb02_types {
TYPE_S2MPB02,
};
enum s2mpb02_reg_types {
TYPE_S2MPB02_REG_MAIN = 0,
TYPE_S2MPB02_REG_SUB,
TYPE_S2MPB02_REG_MAX
};
enum s2mpb02_irq_source {
LED_INT = 0,
S2MPB02_IRQ_GROUP_NR,
};
enum s2mpb02_irq {
/* FLASH */
S2MPB02_LED_IRQ_IRLED_END,
S2MPB02_IRQ_NR,
};
struct s2mpb02_dev {
struct device *dev;
struct i2c_client *i2c; /* 0xB2; PMIC, Flash LED */
struct mutex i2c_lock;
int type;
u8 rev_num; /* pmic Rev */
int irq;
int irq_base;
int irq_gpio;
bool wakeup;
struct mutex irqlock;
int irq_masks_cur[S2MPB02_IRQ_GROUP_NR];
int irq_masks_cache[S2MPB02_IRQ_GROUP_NR];
struct s2mpb02_platform_data *pdata;
};
#ifdef CONFIG_LEDS_S2MPB02
struct s2mpb02_led_platform_data;
#endif
struct s2mpb02_regulator_data {
int id;
struct regulator_init_data *initdata;
struct device_node *reg_node;
};
struct s2mpb02_platform_data {
/* IRQ */
int irq_base;
int irq_gpio;
bool wakeup;
bool need_recovery;;
int num_regulators;
int num_rdata;
struct s2mpb02_regulator_data *regulators;
#ifdef CONFIG_LEDS_S2MPB02
/* led (flash/torch) data */
struct s2mpb02_led_platform_data *led_data;
#endif
int devs_num;
struct mfd_cell *devs;
};
extern int s2mpb02_irq_init(struct s2mpb02_dev *s2mpb02);
extern void s2mpb02_irq_exit(struct s2mpb02_dev *s2mpb02);
extern int s2mpb02_irq_resume(struct s2mpb02_dev *s2mpb02);
/* S2MPB02 shared i2c API function */
extern int s2mpb02_read_reg(struct i2c_client *i2c, u8 reg, u8 *dest);
extern int s2mpb02_bulk_read(struct i2c_client *i2c, u8 reg, int count,
u8 *buf);
extern int s2mpb02_write_reg(struct i2c_client *i2c, u8 reg, u8 value);
extern int s2mpb02_bulk_write(struct i2c_client *i2c, u8 reg, int count,
u8 *buf);
extern int s2mpb02_update_reg(struct i2c_client *i2c, u8 reg, u8 val, u8 mask);
#endif /* __S2MPB02_H__ */

43
include/linux/mfd/sec_ap_pmic.h Executable file
View File

@@ -0,0 +1,43 @@
#ifndef __SEC_AP_PMIC_H__
#define __SEC_AP_PMIC_H__
#define SEC_PON_KEY_CNT 2
struct sec_ap_pmic_info {
struct device *dev;
struct notifier_block sec_pm_debug_nb;
struct delayed_work ws_work;
unsigned int ws_log_period;
/* ocp warn */
int ocp_warn_gpio;
int ocp_warn_irq;
int ocpw_cnt;
int ocpw_cnt_reset_offset;
ktime_t ocpw_start_time;
int ocpw_time; /* accumulated */
int ocpw_time_reset_offset;
};
enum sec_pon_type {
SEC_PON_KPDPWR = 0,
SEC_PON_RESIN,
SEC_PON_KPDPWR_RESIN,
};
/* for enable/disable manual reset, from retail group's request */
extern int sec_get_s2_reset(enum sec_pon_type type);
extern int sec_set_pm_key_wk_init(enum sec_pon_type type, int en);
extern int sec_get_pm_key_wk_init(enum sec_pon_type type);
extern void msm_gpio_print_enabled(void);
extern void pmic_gpio_sec_dbg_enabled(void);
#if IS_ENABLED(CONFIG_SEC_GPIO_DUMP)
extern void sec_ap_gpio_debug_print(void);
extern void sec_pmic_gpio_debug_print(void);
static bool gpio_dump_enabled;
#endif
#endif /* __SEC_AP_PMIC_H__ */