| /* |
| * s2mu106-muic-hv.h - MUIC for the Samsung s2mu004 |
| * |
| * Copyright (C) 2020 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 __S2MU106_MUIC_HV_H__ |
| #define __S2MU106_MUIC_HV_H__ |
| |
| #define MUIC_HV_DEV_NAME "muic-s2mu106-hv" |
| |
| /* S2MU106 AFC INT MASK register(0x08) */ |
| #define INTMASK_VBADC_SHIFT 0 |
| #define INTMASK_VDNMON_SHIFT 1 |
| #define INTMASK_DNRES_SHIFT 2 |
| #define INTMASK_MPNACK_SHIFT 3 |
| #define INTMASK_MRXBUFOW_SHIFT 4 |
| #define INTMASK_MRXTRF_SHIFT 5 |
| #define INTMASK_MRXPERR_SHIFT 6 |
| #define INTMASK_MRXRDY_SHIFT 7 |
| |
| #define INTMASK_VBADC_MASK (0x1 << INTMASK_VBADC_SHIFT) |
| #define INTMASK_VDNMON_MASK (0x1 << INTMASK_VDNMON_SHIFT) |
| #define INTMASK_DNRES_MASK (0x1 << INTMASK_DNRES_SHIFT) |
| #define INTMASK_MPNACK_MASK (0x1 << INTMASK_MPNACK_SHIFT) |
| #define INTMASK_MRXBUFOW_MASK (0x1 << INTMASK_MRXBUFOW_SHIFT) |
| #define INTMASK_MRXTRF_MASK (0x1 << INTMASK_MRXTRF_SHIFT) |
| #define INTMASK_MRXPERR_MASK (0x1 << INTMASK_MRXPERR_SHIFT) |
| #define INTMASK_MRXRDY_MASK (0x1 << INTMASK_MRXRDY_SHIFT) |
| |
| /* S2MU106 AFC STATUS register(0x10) */ |
| #define STATUS_VBADC_SHIFT 0 |
| #define STATUS_VDNMON_SHIFT 4 |
| #define STATUS_DNRES_SHIFT 5 |
| #define STATUS_MPNACK_SHIFT 6 |
| #define STATUS_ADCEOC_SHIFT 7 |
| |
| #define STATUS_VBADC_MASK (0xf << STATUS_VBADC_SHIFT) |
| #define STATUS_VDNMON_MASK (0x1 << STATUS_VDNMON_SHIFT) |
| #define STATUS_DNRES_MASK (0x1 << STATUS_DNRES_SHIFT) |
| #define STATUS_MPNACK_MASK (0x1 << STATUS_MPNACK_SHIFT) |
| #define STATUS_ADCEOC_MASK (0x1 << STATUS_ADCEOC_SHIFT) |
| |
| /* S2MU106 AFC CONTROL 1 register(0x2B) */ |
| #define AFCCTRL1_DPDNVDEN_SHIFT 0 |
| #define AFCCTRL1_DNVD_SHIFT 1 |
| #define AFCCTRL1_DPVD_SHIFT 3 |
| #define AFCCTRL1_VBUSADCEN_SHIFT 5 |
| #define AFCCTRL1_CTRLIDMON_SHIFT 6 |
| #define AFCCTRL1_AFCEN_SHIFT 7 |
| |
| #define AFCCTRL1_DPDNVDEN_MASK (0x1 << AFCCTRL1_DPDNVDEN_SHIFT) |
| #define AFCCTRL1_DNVD_MASK (0x3 << AFCCTRL1_DNVD_SHIFT) |
| #define AFCCTRL1_DPVD_MASK (0x3 << AFCCTRL1_DPVD_SHIFT) |
| #define AFCCTRL1_VBUSADCEN_MASK (0x1 << AFCCTRL1_VBUSADCEN_SHIFT) |
| #define AFCCTRL1_CTRLIDMON_MASK (0x1 << AFCCTRL1_CTRLIDMON_SHIFT) |
| #define AFCCTRL1_AFCEN_MASK (0x1 << AFCCTRL1_AFCEN_SHIFT) |
| |
| #define DPDN_HIZ (0x0) |
| #define DPDN_GND (0x1) |
| #define DPDN_0p6V (0x2) |
| #define DPDN_3p3V (0x3) |
| #define DP_HIZ_MASK (DPDN_HIZ << AFCCTRL1_DPVD_SHIFT) |
| #define DP_GND_MASK (DPDN_GND << AFCCTRL1_DPVD_SHIFT) |
| #define DP_0p6V_MASK (DPDN_0p6V << AFCCTRL1_DPVD_SHIFT) |
| #define DP_3p3V_MASK (DPDN_3p3V << AFCCTRL1_DPVD_SHIFT) |
| #define DN_HIZ_MASK (DPDN_HIZ << AFCCTRL1_DNVD_SHIFT) |
| #define DN_GND_MASK (DPDN_GND << AFCCTRL1_DNVD_SHIFT) |
| #define DN_0p6V_MASK (DPDN_0p6V << AFCCTRL1_DNVD_SHIFT) |
| #define DN_3p3V_MASK (DPDN_3p3V << AFCCTRL1_DNVD_SHIFT) |
| |
| /* S2MU106 AFC CONTROL 2 register(0x2C) */ |
| #define AFCCTRL2_DP06EN_SHIFT 1 |
| #define AFCCTRL2_DNRESEN_SHIFT 2 |
| #define AFCCTRL2_MTXEN_SHIFT 3 |
| #define AFCCTRL2_MPING_SHIFT 4 |
| #define AFCCTRL2_RSTDM100UI_SHIFT 7 |
| |
| #define AFCCTRL2_DP06EN_MASK (0x1 << AFCCTRL2_DP06EN_SHIFT) |
| #define AFCCTRL2_DNRESEN_MASK (0x1 << AFCCTRL2_DNRESEN_SHIFT) |
| #define AFCCTRL2_MTXEN_MASK (0x1 << AFCCTRL2_MTXEN_SHIFT) |
| #define AFCCTRL2_MPING_MASK (0x1 << AFCCTRL2_MPING_SHIFT) |
| #define AFCCTRL2_RSTDM100UI_MASK (0x1 << AFCCTRL2_RSTDM100UI_SHIFT) |
| |
| /* S2MU106 AFC OTP 6 register(0x2C) */ |
| #define AFCOTP6_CTRL_IDM_ON_REG_SEL_SHIFT 6 |
| |
| #define AFCOTP6_CTRL_IDM_ON_REG_SEL_MASK (0x1 << AFCOTP6_CTRL_IDM_ON_REG_SEL_SHIFT) |
| |
| /* S2MU106 AFC TX BYTE DATA */ |
| #define AFCTXBYTE_VOL_SHIFT 4 |
| #define AFCTXBYTE_VOL_MASK (0xf << AFCTXBYTE_VOL_SHIFT) |
| #define AFCTXBYTE_CUR_SHIFT 0 |
| #define AFCTXBYTE_CUR_MASK (0xf << AFCTXBYTE_CUR_SHIFT) |
| |
| #define AFCTXBYTE_5V 0x0 |
| #define AFCTXBYTE_6V 0x1 |
| #define AFCTXBYTE_7V 0x2 |
| #define AFCTXBYTE_8V 0x3 |
| #define AFCTXBYTE_9V 0x4 |
| #define AFCTXBYTE_10V 0x5 |
| #define AFCTXBYTE_11V 0x6 |
| #define AFCTXBYTE_12V 0x7 |
| #define AFCTXBYTE_13V 0x8 |
| #define AFCTXBYTE_14V 0x9 |
| #define AFCTXBYTE_15V 0xA |
| #define AFCTXBYTE_16V 0xB |
| #define AFCTXBYTE_17V 0xC |
| #define AFCTXBYTE_18V 0xD |
| #define AFCTXBYTE_19V 0xE |
| #define AFCTXBYTE_20V 0xF |
| |
| #define AFCTXBYTE_0p75A 0x0 |
| #define AFCTXBYTE_0p90A 0x1 |
| #define AFCTXBYTE_1p05A 0x2 |
| #define AFCTXBYTE_1p20A 0x3 |
| #define AFCTXBYTE_1p35A 0x4 |
| #define AFCTXBYTE_1p50A 0x5 |
| #define AFCTXBYTE_1p65A 0x6 |
| #define AFCTXBYTE_1p80A 0x7 |
| #define AFCTXBYTE_1p95A 0x8 |
| #define AFCTXBYTE_2p10A 0x9 |
| #define AFCTXBYTE_2p25A 0xA |
| #define AFCTXBYTE_2p40A 0xB |
| #define AFCTXBYTE_2p55A 0xC |
| #define AFCTXBYTE_2p70A 0xD |
| #define AFCTXBYTE_2p85A 0xE |
| #define AFCTXBYTE_3p00A 0xF |
| |
| /* S2MU004 HVRXBYTE register */ |
| #define HVRXBYTE_MAX 16 |
| |
| /* S2MU004 AFC charger W/A Check NUM */ |
| #define AFC_CHARGER_WA_PING 5 |
| |
| /* S2MU004 MPing miss SW Workaround - delay time */ |
| #define MPING_MISS_WA_TIME 2000 |
| |
| #define AFC_MRXRDY_CNT_LIMIT (3) |
| #define AFC_MPING_RETRY_CNT_LIMIT (20) |
| #define AFC_QC_RETRY_CNT_LIMIT (3) |
| #define VCHGIN_CHECK_CNT_LIMIT (3) |
| #define AFC_QC_RETRY_WAIT_CNT_LIMIT (3) |
| |
| #define IS_VCHGIN_9V(x) ((8000 <= x) && (x <= 10300)) |
| #define IS_VCHGIN_5V(x) ((4000 <= x) && (x <= 6000)) |
| |
| typedef enum { |
| MU106_IRQ_VDNMON = 1, |
| MU106_IRQ_DNRES, |
| MU106_IRQ_MPNACK, |
| MU106_IRQ_MRXBUFOW, |
| MU106_IRQ_MRXTRF, |
| MU106_IRQ_MRXPERR, |
| MU106_IRQ_MRXRDY = 7, |
| MU106_IRQ_VCHGIN = 8, |
| } afc_int_t; |
| |
| typedef enum { |
| MU106_NOT_MASK = 0, |
| MU106_MASK = 1, |
| } int_mask_t; |
| |
| typedef enum { |
| MU106_QC_PROTOCOL, |
| MU106_AFC_PROTOCOL, |
| } protocol_sw_t; |
| |
| typedef enum { |
| QC_UNKHOWN, |
| QC_5V, |
| QC_9V, |
| QC_12V, |
| } qc_2p0_type_t; |
| |
| typedef enum { |
| VDNMON_LOW = 0x00, |
| VDNMON_HIGH = (0x1 << STATUS_VDNMON_SHIFT), |
| |
| VDNMON_DONTCARE = 0xff, |
| } vdnmon_t; |
| |
| /* MUIC afc irq type */ |
| typedef enum { |
| MUIC_AFC_IRQ_VDNMON = 0, |
| MUIC_AFC_IRQ_MRXRDY, |
| MUIC_AFC_IRQ_VBADC, |
| MUIC_AFC_IRQ_MPNACK, |
| MUIC_AFC_IRQ_DONTCARE = 0xff, |
| } muic_afc_irq_t; |
| |
| typedef enum tx_data{ |
| MUIC_HV_5V = 0, |
| MUIC_HV_9V, |
| } muic_afc_txdata_t; |
| |
| struct s2mu106_muic_data; |
| extern int s2mu106_hv_muic_init(struct s2mu106_muic_data *muic_data); |
| extern void s2mu106_hv_muic_remove(struct s2mu106_muic_data *muic_data); |
| extern muic_attached_dev_t hv_muic_check_id_err(struct s2mu106_muic_data *muic_data, |
| muic_attached_dev_t new_dev); |
| #ifdef CONFIG_HV_MUIC_VOLTAGE_CTRL |
| extern int s2mu106_muic_afc_set_voltage(int vol); |
| extern int s2mu106_muic_afc_get_voltage(void); |
| #endif |
| #endif /* __S2MU106_MUIC_HV_H__ */ |