^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) //
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) // extcon-max77693.c - MAX77693 extcon driver to support MAX77693 MUIC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) //
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) // Copyright (C) 2012 Samsung Electrnoics
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) // Chanwoo Choi <cw00.choi@samsung.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/i2c.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/input.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/err.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/mfd/max77693.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/mfd/max77693-common.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/mfd/max77693-private.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/extcon-provider.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/regmap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/irqdomain.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #define DEV_NAME "max77693-muic"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #define DELAY_MS_DEFAULT 20000 /* unit: millisecond */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * Default value of MAX77693 register to bring up MUIC device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * If user don't set some initial value for MUIC device through platform data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * extcon-max77693 driver use 'default_init_data' to bring up base operation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * of MAX77693 MUIC device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) static struct max77693_reg_data default_init_data[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) /* STATUS2 - [3]ChgDetRun */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) .addr = MAX77693_MUIC_REG_STATUS2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) .data = MAX77693_STATUS2_CHGDETRUN_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) }, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) /* INTMASK1 - Unmask [3]ADC1KM,[0]ADCM */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) .addr = MAX77693_MUIC_REG_INTMASK1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) .data = INTMASK1_ADC1K_MASK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) | INTMASK1_ADC_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) }, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) /* INTMASK2 - Unmask [0]ChgTypM */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) .addr = MAX77693_MUIC_REG_INTMASK2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) .data = INTMASK2_CHGTYP_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) }, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) /* INTMASK3 - Mask all of interrupts */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) .addr = MAX77693_MUIC_REG_INTMASK3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) .data = 0x0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) }, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) /* CDETCTRL2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) .addr = MAX77693_MUIC_REG_CDETCTRL2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) .data = CDETCTRL2_VIDRMEN_MASK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) | CDETCTRL2_DXOVPEN_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) enum max77693_muic_adc_debounce_time {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) ADC_DEBOUNCE_TIME_5MS = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) ADC_DEBOUNCE_TIME_10MS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) ADC_DEBOUNCE_TIME_25MS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) ADC_DEBOUNCE_TIME_38_62MS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) struct max77693_muic_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) struct device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) struct max77693_dev *max77693;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) struct extcon_dev *edev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) int prev_cable_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) int prev_cable_type_gnd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) int prev_chg_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) int prev_button_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) u8 status[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) int irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) struct work_struct irq_work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) struct mutex mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) * Use delayed workqueue to detect cable state and then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) * notify cable state to notifiee/platform through uevent.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) * After completing the booting of platform, the extcon provider
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) * driver should notify cable state to upper layer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) struct delayed_work wq_detcable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) /* Button of dock device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) struct input_dev *dock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) * Default usb/uart path whether UART/USB or AUX_UART/AUX_USB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) * h/w path of COMP2/COMN1 on CONTROL1 register.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) int path_usb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) int path_uart;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) enum max77693_muic_cable_group {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) MAX77693_CABLE_GROUP_ADC = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) MAX77693_CABLE_GROUP_ADC_GND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) MAX77693_CABLE_GROUP_CHG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) MAX77693_CABLE_GROUP_VBVOLT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) enum max77693_muic_charger_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) MAX77693_CHARGER_TYPE_NONE = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) MAX77693_CHARGER_TYPE_USB,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) MAX77693_CHARGER_TYPE_DOWNSTREAM_PORT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) MAX77693_CHARGER_TYPE_DEDICATED_CHG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) MAX77693_CHARGER_TYPE_APPLE_500MA,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) MAX77693_CHARGER_TYPE_APPLE_1A_2A,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) MAX77693_CHARGER_TYPE_DEAD_BATTERY = 7,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) * struct max77693_muic_irq
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) * @irq: the index of irq list of MUIC device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) * @name: the name of irq.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) * @virq: the virtual irq to use irq domain
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) struct max77693_muic_irq {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) unsigned int irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) const char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) unsigned int virq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) static struct max77693_muic_irq muic_irqs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) { MAX77693_MUIC_IRQ_INT1_ADC, "muic-ADC" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) { MAX77693_MUIC_IRQ_INT1_ADC_LOW, "muic-ADCLOW" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) { MAX77693_MUIC_IRQ_INT1_ADC_ERR, "muic-ADCError" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) { MAX77693_MUIC_IRQ_INT1_ADC1K, "muic-ADC1K" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) { MAX77693_MUIC_IRQ_INT2_CHGTYP, "muic-CHGTYP" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) { MAX77693_MUIC_IRQ_INT2_CHGDETREUN, "muic-CHGDETREUN" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) { MAX77693_MUIC_IRQ_INT2_DCDTMR, "muic-DCDTMR" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) { MAX77693_MUIC_IRQ_INT2_DXOVP, "muic-DXOVP" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) { MAX77693_MUIC_IRQ_INT2_VBVOLT, "muic-VBVOLT" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) { MAX77693_MUIC_IRQ_INT2_VIDRM, "muic-VIDRM" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) { MAX77693_MUIC_IRQ_INT3_EOC, "muic-EOC" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) { MAX77693_MUIC_IRQ_INT3_CGMBC, "muic-CGMBC" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) { MAX77693_MUIC_IRQ_INT3_OVP, "muic-OVP" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) { MAX77693_MUIC_IRQ_INT3_MBCCHG_ERR, "muic-MBCCHG_ERR" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) { MAX77693_MUIC_IRQ_INT3_CHG_ENABLED, "muic-CHG_ENABLED" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) { MAX77693_MUIC_IRQ_INT3_BAT_DET, "muic-BAT_DET" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) /* Define supported accessory type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) enum max77693_muic_acc_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) MAX77693_MUIC_ADC_GROUND = 0x0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) MAX77693_MUIC_ADC_SEND_END_BUTTON,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) MAX77693_MUIC_ADC_REMOTE_S1_BUTTON,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) MAX77693_MUIC_ADC_REMOTE_S2_BUTTON,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) MAX77693_MUIC_ADC_REMOTE_S3_BUTTON,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) MAX77693_MUIC_ADC_REMOTE_S4_BUTTON,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) MAX77693_MUIC_ADC_REMOTE_S5_BUTTON,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) MAX77693_MUIC_ADC_REMOTE_S6_BUTTON,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) MAX77693_MUIC_ADC_REMOTE_S7_BUTTON,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) MAX77693_MUIC_ADC_REMOTE_S8_BUTTON,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) MAX77693_MUIC_ADC_REMOTE_S9_BUTTON,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) MAX77693_MUIC_ADC_REMOTE_S10_BUTTON,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) MAX77693_MUIC_ADC_REMOTE_S11_BUTTON,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) MAX77693_MUIC_ADC_REMOTE_S12_BUTTON,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) MAX77693_MUIC_ADC_RESERVED_ACC_1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) MAX77693_MUIC_ADC_RESERVED_ACC_2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) MAX77693_MUIC_ADC_RESERVED_ACC_3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) MAX77693_MUIC_ADC_RESERVED_ACC_4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) MAX77693_MUIC_ADC_RESERVED_ACC_5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) MAX77693_MUIC_ADC_CEA936_AUDIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) MAX77693_MUIC_ADC_PHONE_POWERED_DEV,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) MAX77693_MUIC_ADC_TTY_CONVERTER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) MAX77693_MUIC_ADC_UART_CABLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) MAX77693_MUIC_ADC_CEA936A_TYPE1_CHG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) MAX77693_MUIC_ADC_FACTORY_MODE_USB_OFF,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) MAX77693_MUIC_ADC_FACTORY_MODE_USB_ON,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) MAX77693_MUIC_ADC_AV_CABLE_NOLOAD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) MAX77693_MUIC_ADC_CEA936A_TYPE2_CHG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) MAX77693_MUIC_ADC_FACTORY_MODE_UART_OFF,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) MAX77693_MUIC_ADC_FACTORY_MODE_UART_ON,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) MAX77693_MUIC_ADC_AUDIO_MODE_REMOTE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) MAX77693_MUIC_ADC_OPEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) * The below accessories have same ADC value so ADCLow and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) * ADC1K bit is used to separate specific accessory.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) /* ADC|VBVolot|ADCLow|ADC1K| */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) MAX77693_MUIC_GND_USB_HOST = 0x100, /* 0x0| 0| 0| 0| */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) MAX77693_MUIC_GND_USB_HOST_VB = 0x104, /* 0x0| 1| 0| 0| */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) MAX77693_MUIC_GND_AV_CABLE_LOAD = 0x102,/* 0x0| 0| 1| 0| */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) MAX77693_MUIC_GND_MHL = 0x103, /* 0x0| 0| 1| 1| */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) MAX77693_MUIC_GND_MHL_VB = 0x107, /* 0x0| 1| 1| 1| */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) * MAX77693 MUIC device support below list of accessories(external connector)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) static const unsigned int max77693_extcon_cable[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) EXTCON_USB,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) EXTCON_USB_HOST,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) EXTCON_CHG_USB_SDP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) EXTCON_CHG_USB_DCP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) EXTCON_CHG_USB_FAST,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) EXTCON_CHG_USB_SLOW,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) EXTCON_CHG_USB_CDP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) EXTCON_DISP_MHL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) EXTCON_JIG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) EXTCON_DOCK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) EXTCON_NONE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) * max77693_muic_set_debounce_time - Set the debounce time of ADC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) * @info: the instance including private data of max77693 MUIC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) * @time: the debounce time of ADC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) static int max77693_muic_set_debounce_time(struct max77693_muic_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) enum max77693_muic_adc_debounce_time time)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) switch (time) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) case ADC_DEBOUNCE_TIME_5MS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) case ADC_DEBOUNCE_TIME_10MS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) case ADC_DEBOUNCE_TIME_25MS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) case ADC_DEBOUNCE_TIME_38_62MS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) * Don't touch BTLDset, JIGset when you want to change adc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) * debounce time. If it writes other than 0 to BTLDset, JIGset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) * muic device will be reset and loose current state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) ret = regmap_write(info->max77693->regmap_muic,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) MAX77693_MUIC_REG_CTRL3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) time << MAX77693_CONTROL3_ADCDBSET_SHIFT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) dev_err(info->dev, "failed to set ADC debounce time\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) dev_err(info->dev, "invalid ADC debounce time\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) * max77693_muic_set_path - Set hardware line according to attached cable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) * @info: the instance including private data of max77693 MUIC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) * @value: the path according to attached cable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) * @attached: the state of cable (true:attached, false:detached)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) * The max77693 MUIC device share outside H/W line among a varity of cables
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) * so, this function set internal path of H/W line according to the type of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) * attached cable.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) static int max77693_muic_set_path(struct max77693_muic_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) u8 val, bool attached)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) unsigned int ctrl1, ctrl2 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) if (attached)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) ctrl1 = val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) ctrl1 = MAX77693_CONTROL1_SW_OPEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) ret = regmap_update_bits(info->max77693->regmap_muic,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) MAX77693_MUIC_REG_CTRL1, COMP_SW_MASK, ctrl1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) dev_err(info->dev, "failed to update MUIC register\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) if (attached)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) ctrl2 |= MAX77693_CONTROL2_CPEN_MASK; /* LowPwr=0, CPEn=1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) ctrl2 |= MAX77693_CONTROL2_LOWPWR_MASK; /* LowPwr=1, CPEn=0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) ret = regmap_update_bits(info->max77693->regmap_muic,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) MAX77693_MUIC_REG_CTRL2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) MAX77693_CONTROL2_LOWPWR_MASK | MAX77693_CONTROL2_CPEN_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) ctrl2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) dev_err(info->dev, "failed to update MUIC register\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) dev_info(info->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) "CONTROL1 : 0x%02x, CONTROL2 : 0x%02x, state : %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) ctrl1, ctrl2, attached ? "attached" : "detached");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) * max77693_muic_get_cable_type - Return cable type and check cable state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) * @info: the instance including private data of max77693 MUIC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) * @group: the path according to attached cable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) * @attached: store cable state and return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) * This function check the cable state either attached or detached,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) * and then divide precise type of cable according to cable group.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) * - MAX77693_CABLE_GROUP_ADC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) * - MAX77693_CABLE_GROUP_ADC_GND
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) * - MAX77693_CABLE_GROUP_CHG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) * - MAX77693_CABLE_GROUP_VBVOLT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) static int max77693_muic_get_cable_type(struct max77693_muic_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) enum max77693_muic_cable_group group, bool *attached)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) int cable_type = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) int adc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) int adc1k;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) int adclow;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) int vbvolt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) int chg_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) switch (group) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) case MAX77693_CABLE_GROUP_ADC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) * Read ADC value to check cable type and decide cable state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) * according to cable type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) adc = info->status[0] & MAX77693_STATUS1_ADC_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) adc >>= MAX77693_STATUS1_ADC_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) * Check current cable state/cable type and store cable type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) * (info->prev_cable_type) for handling cable when cable is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) * detached.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) if (adc == MAX77693_MUIC_ADC_OPEN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) *attached = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) cable_type = info->prev_cable_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) info->prev_cable_type = MAX77693_MUIC_ADC_OPEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) *attached = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) cable_type = info->prev_cable_type = adc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) case MAX77693_CABLE_GROUP_ADC_GND:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) * Read ADC value to check cable type and decide cable state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) * according to cable type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) adc = info->status[0] & MAX77693_STATUS1_ADC_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) adc >>= MAX77693_STATUS1_ADC_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) * Check current cable state/cable type and store cable type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) * (info->prev_cable_type/_gnd) for handling cable when cable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) * is detached.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) if (adc == MAX77693_MUIC_ADC_OPEN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) *attached = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) cable_type = info->prev_cable_type_gnd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) info->prev_cable_type_gnd = MAX77693_MUIC_ADC_OPEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) *attached = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) adclow = info->status[0] & MAX77693_STATUS1_ADCLOW_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) adclow >>= MAX77693_STATUS1_ADCLOW_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) adc1k = info->status[0] & MAX77693_STATUS1_ADC1K_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) adc1k >>= MAX77693_STATUS1_ADC1K_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) vbvolt = info->status[1] & MAX77693_STATUS2_VBVOLT_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) vbvolt >>= MAX77693_STATUS2_VBVOLT_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) * [0x1|VBVolt|ADCLow|ADC1K]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) * [0x1| 0| 0| 0] USB_HOST
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) * [0x1| 1| 0| 0] USB_HSOT_VB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) * [0x1| 0| 1| 0] Audio Video cable with load
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) * [0x1| 0| 1| 1] MHL without charging cable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) * [0x1| 1| 1| 1] MHL with charging cable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) cable_type = ((0x1 << 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) | (vbvolt << 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) | (adclow << 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) | adc1k);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) info->prev_cable_type = adc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) info->prev_cable_type_gnd = cable_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) case MAX77693_CABLE_GROUP_CHG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) * Read charger type to check cable type and decide cable state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) * according to type of charger cable.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) chg_type = info->status[1] & MAX77693_STATUS2_CHGTYP_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) chg_type >>= MAX77693_STATUS2_CHGTYP_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) if (chg_type == MAX77693_CHARGER_TYPE_NONE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) *attached = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) cable_type = info->prev_chg_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) info->prev_chg_type = MAX77693_CHARGER_TYPE_NONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) *attached = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) * Check current cable state/cable type and store cable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) * type(info->prev_chg_type) for handling cable when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) * charger cable is detached.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) cable_type = info->prev_chg_type = chg_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) case MAX77693_CABLE_GROUP_VBVOLT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) * Read ADC value to check cable type and decide cable state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) * according to cable type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) adc = info->status[0] & MAX77693_STATUS1_ADC_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) adc >>= MAX77693_STATUS1_ADC_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) chg_type = info->status[1] & MAX77693_STATUS2_CHGTYP_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) chg_type >>= MAX77693_STATUS2_CHGTYP_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) if (adc == MAX77693_MUIC_ADC_OPEN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) && chg_type == MAX77693_CHARGER_TYPE_NONE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) *attached = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) *attached = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) * Read vbvolt field, if vbvolt is 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) * this cable is used for charging.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) vbvolt = info->status[1] & MAX77693_STATUS2_VBVOLT_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) vbvolt >>= MAX77693_STATUS2_VBVOLT_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) cable_type = vbvolt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) dev_err(info->dev, "Unknown cable group (%d)\n", group);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) cable_type = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) return cable_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) static int max77693_muic_dock_handler(struct max77693_muic_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) int cable_type, bool attached)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) int vbvolt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) bool cable_attached;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) unsigned int dock_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) dev_info(info->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) "external connector is %s (adc:0x%02x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) attached ? "attached" : "detached", cable_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) switch (cable_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) case MAX77693_MUIC_ADC_RESERVED_ACC_3: /* Dock-Smart */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) * Check power cable whether attached or detached state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) * The Dock-Smart device need surely external power supply.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) * If power cable(USB/TA) isn't connected to Dock device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) * user can't use Dock-Smart for desktop mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) vbvolt = max77693_muic_get_cable_type(info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) MAX77693_CABLE_GROUP_VBVOLT, &cable_attached);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) if (attached && !vbvolt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) dev_warn(info->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) "Cannot detect external power supply\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) * Notify Dock/MHL state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) * - Dock device include three type of cable which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) * are HDMI, USB for mouse/keyboard and micro-usb port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) * for USB/TA cable. Dock device need always exteranl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) * power supply(USB/TA cable through micro-usb cable). Dock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) * device support screen output of target to separate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) * monitor and mouse/keyboard for desktop mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) * Features of 'USB/TA cable with Dock device'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) * - Support MHL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) * - Support external output feature of audio
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) * - Support charging through micro-usb port without data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) * connection if TA cable is connected to target.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) * - Support charging and data connection through micro-usb port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) * if USB cable is connected between target and host
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) * device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) * - Support OTG(On-The-Go) device (Ex: Mouse/Keyboard)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) ret = max77693_muic_set_path(info, info->path_usb, attached);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) extcon_set_state_sync(info->edev, EXTCON_DOCK, attached);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) extcon_set_state_sync(info->edev, EXTCON_DISP_MHL, attached);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) case MAX77693_MUIC_ADC_AUDIO_MODE_REMOTE: /* Dock-Desk */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) dock_id = EXTCON_DOCK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) case MAX77693_MUIC_ADC_AV_CABLE_NOLOAD: /* Dock-Audio */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) dock_id = EXTCON_DOCK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) if (!attached) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) extcon_set_state_sync(info->edev, EXTCON_USB, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) extcon_set_state_sync(info->edev, EXTCON_CHG_USB_SDP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) dev_err(info->dev, "failed to detect %s dock device\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) attached ? "attached" : "detached");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) /* Dock-Car/Desk/Audio, PATH:AUDIO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) ret = max77693_muic_set_path(info, MAX77693_CONTROL1_SW_AUDIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) attached);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) extcon_set_state_sync(info->edev, dock_id, attached);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) static int max77693_muic_dock_button_handler(struct max77693_muic_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) int button_type, bool attached)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) struct input_dev *dock = info->dock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) unsigned int code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) switch (button_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) case MAX77693_MUIC_ADC_REMOTE_S3_BUTTON-1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) ... MAX77693_MUIC_ADC_REMOTE_S3_BUTTON+1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) /* DOCK_KEY_PREV */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) code = KEY_PREVIOUSSONG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) case MAX77693_MUIC_ADC_REMOTE_S7_BUTTON-1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) ... MAX77693_MUIC_ADC_REMOTE_S7_BUTTON+1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) /* DOCK_KEY_NEXT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) code = KEY_NEXTSONG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) case MAX77693_MUIC_ADC_REMOTE_S9_BUTTON:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) /* DOCK_VOL_DOWN */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) code = KEY_VOLUMEDOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) case MAX77693_MUIC_ADC_REMOTE_S10_BUTTON:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) /* DOCK_VOL_UP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) code = KEY_VOLUMEUP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) case MAX77693_MUIC_ADC_REMOTE_S12_BUTTON-1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) ... MAX77693_MUIC_ADC_REMOTE_S12_BUTTON+1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) /* DOCK_KEY_PLAY_PAUSE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) code = KEY_PLAYPAUSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) dev_err(info->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) "failed to detect %s key (adc:0x%x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) attached ? "pressed" : "released", button_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) input_event(dock, EV_KEY, code, attached);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) input_sync(dock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) static int max77693_muic_adc_ground_handler(struct max77693_muic_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) int cable_type_gnd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) bool attached;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) cable_type_gnd = max77693_muic_get_cable_type(info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) MAX77693_CABLE_GROUP_ADC_GND, &attached);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) switch (cable_type_gnd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) case MAX77693_MUIC_GND_USB_HOST:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) case MAX77693_MUIC_GND_USB_HOST_VB:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) /* USB_HOST, PATH: AP_USB */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) ret = max77693_muic_set_path(info, MAX77693_CONTROL1_SW_USB,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) attached);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) extcon_set_state_sync(info->edev, EXTCON_USB_HOST, attached);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) case MAX77693_MUIC_GND_AV_CABLE_LOAD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) /* Audio Video Cable with load, PATH:AUDIO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) ret = max77693_muic_set_path(info, MAX77693_CONTROL1_SW_AUDIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) attached);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) extcon_set_state_sync(info->edev, EXTCON_USB, attached);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) extcon_set_state_sync(info->edev, EXTCON_CHG_USB_SDP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) attached);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) case MAX77693_MUIC_GND_MHL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) case MAX77693_MUIC_GND_MHL_VB:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) /* MHL or MHL with USB/TA cable */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) extcon_set_state_sync(info->edev, EXTCON_DISP_MHL, attached);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) dev_err(info->dev, "failed to detect %s cable of gnd type\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) attached ? "attached" : "detached");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) static int max77693_muic_jig_handler(struct max77693_muic_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) int cable_type, bool attached)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) u8 path = MAX77693_CONTROL1_SW_OPEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) dev_info(info->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) "external connector is %s (adc:0x%02x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) attached ? "attached" : "detached", cable_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) switch (cable_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) case MAX77693_MUIC_ADC_FACTORY_MODE_USB_OFF: /* ADC_JIG_USB_OFF */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) case MAX77693_MUIC_ADC_FACTORY_MODE_USB_ON: /* ADC_JIG_USB_ON */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) /* PATH:AP_USB */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) path = MAX77693_CONTROL1_SW_USB;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) case MAX77693_MUIC_ADC_FACTORY_MODE_UART_OFF: /* ADC_JIG_UART_OFF */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) case MAX77693_MUIC_ADC_FACTORY_MODE_UART_ON: /* ADC_JIG_UART_ON */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) /* PATH:AP_UART */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) path = MAX77693_CONTROL1_SW_UART;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) dev_err(info->dev, "failed to detect %s jig cable\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) attached ? "attached" : "detached");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) ret = max77693_muic_set_path(info, path, attached);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) extcon_set_state_sync(info->edev, EXTCON_JIG, attached);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) static int max77693_muic_adc_handler(struct max77693_muic_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) int cable_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) int button_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) bool attached;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) /* Check accessory state which is either detached or attached */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) cable_type = max77693_muic_get_cable_type(info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) MAX77693_CABLE_GROUP_ADC, &attached);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) dev_info(info->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) "external connector is %s (adc:0x%02x, prev_adc:0x%x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) attached ? "attached" : "detached", cable_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) info->prev_cable_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) switch (cable_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) case MAX77693_MUIC_ADC_GROUND:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) /* USB_HOST/MHL/Audio */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) max77693_muic_adc_ground_handler(info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) case MAX77693_MUIC_ADC_FACTORY_MODE_USB_OFF:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) case MAX77693_MUIC_ADC_FACTORY_MODE_USB_ON:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) case MAX77693_MUIC_ADC_FACTORY_MODE_UART_OFF:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) case MAX77693_MUIC_ADC_FACTORY_MODE_UART_ON:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) /* JIG */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) ret = max77693_muic_jig_handler(info, cable_type, attached);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) case MAX77693_MUIC_ADC_RESERVED_ACC_3: /* Dock-Smart */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) case MAX77693_MUIC_ADC_AUDIO_MODE_REMOTE: /* Dock-Desk */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) case MAX77693_MUIC_ADC_AV_CABLE_NOLOAD: /* Dock-Audio */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) * DOCK device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) * The MAX77693 MUIC device can detect total 34 cable type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) * except of charger cable and MUIC device didn't define
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) * specfic role of cable in the range of from 0x01 to 0x12
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) * of ADC value. So, can use/define cable with no role according
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) * to schema of hardware board.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) ret = max77693_muic_dock_handler(info, cable_type, attached);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) case MAX77693_MUIC_ADC_REMOTE_S3_BUTTON: /* DOCK_KEY_PREV */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) case MAX77693_MUIC_ADC_REMOTE_S7_BUTTON: /* DOCK_KEY_NEXT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) case MAX77693_MUIC_ADC_REMOTE_S9_BUTTON: /* DOCK_VOL_DOWN */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) case MAX77693_MUIC_ADC_REMOTE_S10_BUTTON: /* DOCK_VOL_UP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) case MAX77693_MUIC_ADC_REMOTE_S12_BUTTON: /* DOCK_KEY_PLAY_PAUSE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) * Button of DOCK device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) * - the Prev/Next/Volume Up/Volume Down/Play-Pause button
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) * The MAX77693 MUIC device can detect total 34 cable type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) * except of charger cable and MUIC device didn't define
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) * specfic role of cable in the range of from 0x01 to 0x12
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) * of ADC value. So, can use/define cable with no role according
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) * to schema of hardware board.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) if (attached)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) button_type = info->prev_button_type = cable_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) button_type = info->prev_button_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) ret = max77693_muic_dock_button_handler(info, button_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) attached);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) case MAX77693_MUIC_ADC_SEND_END_BUTTON:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) case MAX77693_MUIC_ADC_REMOTE_S1_BUTTON:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) case MAX77693_MUIC_ADC_REMOTE_S2_BUTTON:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) case MAX77693_MUIC_ADC_REMOTE_S4_BUTTON:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) case MAX77693_MUIC_ADC_REMOTE_S5_BUTTON:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) case MAX77693_MUIC_ADC_REMOTE_S6_BUTTON:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) case MAX77693_MUIC_ADC_REMOTE_S8_BUTTON:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) case MAX77693_MUIC_ADC_REMOTE_S11_BUTTON:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) case MAX77693_MUIC_ADC_RESERVED_ACC_1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) case MAX77693_MUIC_ADC_RESERVED_ACC_2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) case MAX77693_MUIC_ADC_RESERVED_ACC_4:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) case MAX77693_MUIC_ADC_RESERVED_ACC_5:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) case MAX77693_MUIC_ADC_CEA936_AUDIO:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) case MAX77693_MUIC_ADC_PHONE_POWERED_DEV:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) case MAX77693_MUIC_ADC_TTY_CONVERTER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) case MAX77693_MUIC_ADC_UART_CABLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) case MAX77693_MUIC_ADC_CEA936A_TYPE1_CHG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) case MAX77693_MUIC_ADC_CEA936A_TYPE2_CHG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) * This accessory isn't used in general case if it is specially
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) * needed to detect additional accessory, should implement
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) * proper operation when this accessory is attached/detached.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) dev_info(info->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) "accessory is %s but it isn't used (adc:0x%x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) attached ? "attached" : "detached", cable_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) return -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) dev_err(info->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) "failed to detect %s accessory (adc:0x%x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) attached ? "attached" : "detached", cable_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) static int max77693_muic_chg_handler(struct max77693_muic_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) int chg_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) int cable_type_gnd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) int cable_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) bool attached;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) bool cable_attached;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) chg_type = max77693_muic_get_cable_type(info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) MAX77693_CABLE_GROUP_CHG, &attached);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) dev_info(info->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) "external connector is %s(chg_type:0x%x, prev_chg_type:0x%x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) attached ? "attached" : "detached",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) chg_type, info->prev_chg_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) switch (chg_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) case MAX77693_CHARGER_TYPE_USB:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) case MAX77693_CHARGER_TYPE_DEDICATED_CHG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) case MAX77693_CHARGER_TYPE_NONE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) /* Check MAX77693_CABLE_GROUP_ADC_GND type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) cable_type_gnd = max77693_muic_get_cable_type(info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) MAX77693_CABLE_GROUP_ADC_GND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) &cable_attached);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) switch (cable_type_gnd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) case MAX77693_MUIC_GND_MHL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) case MAX77693_MUIC_GND_MHL_VB:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) * MHL cable with USB/TA cable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) * - MHL cable include two port(HDMI line and separate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) * micro-usb port. When the target connect MHL cable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) * extcon driver check whether USB/TA cable is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) * connected. If USB/TA cable is connected, extcon
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) * driver notify state to notifiee for charging battery.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) * Features of 'USB/TA with MHL cable'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) * - Support MHL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) * - Support charging through micro-usb port without
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) * data connection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) extcon_set_state_sync(info->edev, EXTCON_CHG_USB_DCP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) attached);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) extcon_set_state_sync(info->edev, EXTCON_DISP_MHL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) cable_attached);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) /* Check MAX77693_CABLE_GROUP_ADC type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) cable_type = max77693_muic_get_cable_type(info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) MAX77693_CABLE_GROUP_ADC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) &cable_attached);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) switch (cable_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) case MAX77693_MUIC_ADC_AV_CABLE_NOLOAD: /* Dock-Audio */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) * Dock-Audio device with USB/TA cable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) * - Dock device include two port(Dock-Audio and micro-
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) * usb port). When the target connect Dock-Audio device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) * extcon driver check whether USB/TA cable is connected
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) * or not. If USB/TA cable is connected, extcon driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) * notify state to notifiee for charging battery.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) * Features of 'USB/TA cable with Dock-Audio device'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) * - Support external output feature of audio.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) * - Support charging through micro-usb port without
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) * data connection.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) extcon_set_state_sync(info->edev, EXTCON_USB,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) attached);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) extcon_set_state_sync(info->edev, EXTCON_CHG_USB_SDP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) attached);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) if (!cable_attached)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) extcon_set_state_sync(info->edev, EXTCON_DOCK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) cable_attached);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) case MAX77693_MUIC_ADC_RESERVED_ACC_3: /* Dock-Smart */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) * Dock-Smart device with USB/TA cable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) * - Dock-Desk device include three type of cable which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) * are HDMI, USB for mouse/keyboard and micro-usb port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) * for USB/TA cable. Dock-Smart device need always
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) * exteranl power supply(USB/TA cable through micro-usb
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) * cable). Dock-Smart device support screen output of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) * target to separate monitor and mouse/keyboard for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) * desktop mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) * Features of 'USB/TA cable with Dock-Smart device'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) * - Support MHL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) * - Support external output feature of audio
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) * - Support charging through micro-usb port without
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) * data connection if TA cable is connected to target.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) * - Support charging and data connection through micro-
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) * usb port if USB cable is connected between target
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) * and host device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) * - Support OTG(On-The-Go) device (Ex: Mouse/Keyboard)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) ret = max77693_muic_set_path(info, info->path_usb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) attached);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) extcon_set_state_sync(info->edev, EXTCON_DOCK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) attached);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) extcon_set_state_sync(info->edev, EXTCON_DISP_MHL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) attached);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) /* Check MAX77693_CABLE_GROUP_CHG type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) switch (chg_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) case MAX77693_CHARGER_TYPE_NONE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) * When MHL(with USB/TA cable) or Dock-Audio with USB/TA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875) * cable is attached, muic device happen below two irq.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) * - 'MAX77693_MUIC_IRQ_INT1_ADC' for detecting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) * MHL/Dock-Audio.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) * - 'MAX77693_MUIC_IRQ_INT2_CHGTYP' for detecting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) * USB/TA cable connected to MHL or Dock-Audio.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) * Always, happen eariler MAX77693_MUIC_IRQ_INT1_ADC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) * irq than MAX77693_MUIC_IRQ_INT2_CHGTYP irq.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) * If user attach MHL (with USB/TA cable and immediately
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) * detach MHL with USB/TA cable before MAX77693_MUIC_IRQ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885) * _INT2_CHGTYP irq is happened, USB/TA cable remain
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) * connected state to target. But USB/TA cable isn't
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) * connected to target. The user be face with unusual
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) * action. So, driver should check this situation in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) * spite of, that previous charger type is N/A.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) case MAX77693_CHARGER_TYPE_USB:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) /* Only USB cable, PATH:AP_USB */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894) ret = max77693_muic_set_path(info, info->path_usb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) attached);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) extcon_set_state_sync(info->edev, EXTCON_USB,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) attached);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) extcon_set_state_sync(info->edev, EXTCON_CHG_USB_SDP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902) attached);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904) case MAX77693_CHARGER_TYPE_DEDICATED_CHG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) /* Only TA cable */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) extcon_set_state_sync(info->edev, EXTCON_CHG_USB_DCP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) attached);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911) case MAX77693_CHARGER_TYPE_DOWNSTREAM_PORT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) extcon_set_state_sync(info->edev, EXTCON_CHG_USB_CDP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) attached);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915) case MAX77693_CHARGER_TYPE_APPLE_500MA:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916) extcon_set_state_sync(info->edev, EXTCON_CHG_USB_SLOW,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917) attached);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) case MAX77693_CHARGER_TYPE_APPLE_1A_2A:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920) extcon_set_state_sync(info->edev, EXTCON_CHG_USB_FAST,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921) attached);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923) case MAX77693_CHARGER_TYPE_DEAD_BATTERY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926) dev_err(info->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) "failed to detect %s accessory (chg_type:0x%x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928) attached ? "attached" : "detached", chg_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935) static void max77693_muic_irq_work(struct work_struct *work)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937) struct max77693_muic_info *info = container_of(work,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938) struct max77693_muic_info, irq_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939) int irq_type = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940) int i, ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942) if (!info->edev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945) mutex_lock(&info->mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947) for (i = 0; i < ARRAY_SIZE(muic_irqs); i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948) if (info->irq == muic_irqs[i].virq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949) irq_type = muic_irqs[i].irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951) ret = regmap_bulk_read(info->max77693->regmap_muic,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952) MAX77693_MUIC_REG_STATUS1, info->status, 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954) dev_err(info->dev, "failed to read MUIC register\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 955) mutex_unlock(&info->mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 956) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 957) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 958)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959) switch (irq_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960) case MAX77693_MUIC_IRQ_INT1_ADC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961) case MAX77693_MUIC_IRQ_INT1_ADC_LOW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962) case MAX77693_MUIC_IRQ_INT1_ADC_ERR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963) case MAX77693_MUIC_IRQ_INT1_ADC1K:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965) * Handle all of accessory except for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966) * type of charger accessory.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 967) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 968) ret = max77693_muic_adc_handler(info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 969) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 970) case MAX77693_MUIC_IRQ_INT2_CHGTYP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 971) case MAX77693_MUIC_IRQ_INT2_CHGDETREUN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 972) case MAX77693_MUIC_IRQ_INT2_DCDTMR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 973) case MAX77693_MUIC_IRQ_INT2_DXOVP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 974) case MAX77693_MUIC_IRQ_INT2_VBVOLT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 975) case MAX77693_MUIC_IRQ_INT2_VIDRM:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 976) /* Handle charger accessory */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 977) ret = max77693_muic_chg_handler(info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 978) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 979) case MAX77693_MUIC_IRQ_INT3_EOC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 980) case MAX77693_MUIC_IRQ_INT3_CGMBC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 981) case MAX77693_MUIC_IRQ_INT3_OVP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 982) case MAX77693_MUIC_IRQ_INT3_MBCCHG_ERR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 983) case MAX77693_MUIC_IRQ_INT3_CHG_ENABLED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 984) case MAX77693_MUIC_IRQ_INT3_BAT_DET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 985) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 986) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 987) dev_err(info->dev, "muic interrupt: irq %d occurred\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 988) irq_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 989) mutex_unlock(&info->mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 990) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 991) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 992)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 993) if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 994) dev_err(info->dev, "failed to handle MUIC interrupt\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 995)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 996) mutex_unlock(&info->mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 997) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 998)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 999) static irqreturn_t max77693_muic_irq_handler(int irq, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) struct max77693_muic_info *info = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) info->irq = irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) schedule_work(&info->irq_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) static const struct regmap_config max77693_muic_regmap_config = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) .reg_bits = 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) .val_bits = 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) static int max77693_muic_detect_accessory(struct max77693_muic_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) int adc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) int chg_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) bool attached;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) mutex_lock(&info->mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) /* Read STATUSx register to detect accessory */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) ret = regmap_bulk_read(info->max77693->regmap_muic,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) MAX77693_MUIC_REG_STATUS1, info->status, 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) dev_err(info->dev, "failed to read MUIC register\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) mutex_unlock(&info->mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) adc = max77693_muic_get_cable_type(info, MAX77693_CABLE_GROUP_ADC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) &attached);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) if (attached && adc != MAX77693_MUIC_ADC_OPEN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) ret = max77693_muic_adc_handler(info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) dev_err(info->dev, "Cannot detect accessory\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) mutex_unlock(&info->mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) chg_type = max77693_muic_get_cable_type(info, MAX77693_CABLE_GROUP_CHG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) &attached);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) if (attached && chg_type != MAX77693_CHARGER_TYPE_NONE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) ret = max77693_muic_chg_handler(info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) dev_err(info->dev, "Cannot detect charger accessory\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) mutex_unlock(&info->mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) mutex_unlock(&info->mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) static void max77693_muic_detect_cable_wq(struct work_struct *work)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) struct max77693_muic_info *info = container_of(to_delayed_work(work),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) struct max77693_muic_info, wq_detcable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) max77693_muic_detect_accessory(info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) static int max77693_muic_probe(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) struct max77693_dev *max77693 = dev_get_drvdata(pdev->dev.parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) struct max77693_platform_data *pdata = dev_get_platdata(max77693->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) struct max77693_muic_info *info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) struct max77693_reg_data *init_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) int num_init_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) int delay_jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) int cable_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) bool attached;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) unsigned int id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) info = devm_kzalloc(&pdev->dev, sizeof(struct max77693_muic_info),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) if (!info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) info->dev = &pdev->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) info->max77693 = max77693;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) if (info->max77693->regmap_muic) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) dev_dbg(&pdev->dev, "allocate register map\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) info->max77693->regmap_muic = devm_regmap_init_i2c(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) info->max77693->i2c_muic,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) &max77693_muic_regmap_config);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) if (IS_ERR(info->max77693->regmap_muic)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) ret = PTR_ERR(info->max77693->regmap_muic);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) dev_err(max77693->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) "failed to allocate register map: %d\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) /* Register input device for button of dock device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) info->dock = devm_input_allocate_device(&pdev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) if (!info->dock) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) dev_err(&pdev->dev, "%s: failed to allocate input\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) info->dock->name = "max77693-muic/dock";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) info->dock->phys = "max77693-muic/extcon";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) info->dock->dev.parent = &pdev->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) __set_bit(EV_REP, info->dock->evbit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) input_set_capability(info->dock, EV_KEY, KEY_VOLUMEUP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) input_set_capability(info->dock, EV_KEY, KEY_VOLUMEDOWN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) input_set_capability(info->dock, EV_KEY, KEY_PLAYPAUSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) input_set_capability(info->dock, EV_KEY, KEY_PREVIOUSSONG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) input_set_capability(info->dock, EV_KEY, KEY_NEXTSONG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) ret = input_register_device(info->dock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) dev_err(&pdev->dev, "Cannot register input device error(%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) platform_set_drvdata(pdev, info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) mutex_init(&info->mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) INIT_WORK(&info->irq_work, max77693_muic_irq_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) /* Support irq domain for MAX77693 MUIC device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) for (i = 0; i < ARRAY_SIZE(muic_irqs); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) struct max77693_muic_irq *muic_irq = &muic_irqs[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) int virq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) virq = regmap_irq_get_virq(max77693->irq_data_muic,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) muic_irq->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) if (virq <= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) muic_irq->virq = virq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) ret = devm_request_threaded_irq(&pdev->dev, virq, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) max77693_muic_irq_handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) IRQF_NO_SUSPEND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) muic_irq->name, info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) dev_err(&pdev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) "failed: irq request (IRQ: %d, error :%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) muic_irq->irq, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) /* Initialize extcon device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) info->edev = devm_extcon_dev_allocate(&pdev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) max77693_extcon_cable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) if (IS_ERR(info->edev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) dev_err(&pdev->dev, "failed to allocate memory for extcon\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160) return PTR_ERR(info->edev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) ret = devm_extcon_dev_register(&pdev->dev, info->edev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) dev_err(&pdev->dev, "failed to register extcon device\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) /* Initialize MUIC register by using platform data or default data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) if (pdata && pdata->muic_data) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) init_data = pdata->muic_data->init_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) num_init_data = pdata->muic_data->num_init_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) init_data = default_init_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) num_init_data = ARRAY_SIZE(default_init_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) for (i = 0; i < num_init_data; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) regmap_write(info->max77693->regmap_muic,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) init_data[i].addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) init_data[i].data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184) if (pdata && pdata->muic_data) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) struct max77693_muic_platform_data *muic_pdata
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) = pdata->muic_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189) * Default usb/uart path whether UART/USB or AUX_UART/AUX_USB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) * h/w path of COMP2/COMN1 on CONTROL1 register.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) if (muic_pdata->path_uart)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) info->path_uart = muic_pdata->path_uart;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) info->path_uart = MAX77693_CONTROL1_SW_UART;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) if (muic_pdata->path_usb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) info->path_usb = muic_pdata->path_usb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) info->path_usb = MAX77693_CONTROL1_SW_USB;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) * Default delay time for detecting cable state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) * after certain time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) if (muic_pdata->detcable_delay_ms)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207) delay_jiffies =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) msecs_to_jiffies(muic_pdata->detcable_delay_ms);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) delay_jiffies = msecs_to_jiffies(DELAY_MS_DEFAULT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) info->path_usb = MAX77693_CONTROL1_SW_USB;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) info->path_uart = MAX77693_CONTROL1_SW_UART;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) delay_jiffies = msecs_to_jiffies(DELAY_MS_DEFAULT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) /* Set initial path for UART when JIG is connected to get serial logs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) ret = regmap_bulk_read(info->max77693->regmap_muic,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219) MAX77693_MUIC_REG_STATUS1, info->status, 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) dev_err(info->dev, "failed to read MUIC register\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) cable_type = max77693_muic_get_cable_type(info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) MAX77693_CABLE_GROUP_ADC, &attached);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) if (attached && (cable_type == MAX77693_MUIC_ADC_FACTORY_MODE_UART_ON ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227) cable_type == MAX77693_MUIC_ADC_FACTORY_MODE_UART_OFF))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) max77693_muic_set_path(info, info->path_uart, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) /* Check revision number of MUIC device*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) ret = regmap_read(info->max77693->regmap_muic,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) MAX77693_MUIC_REG_ID, &id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) dev_err(&pdev->dev, "failed to read revision number\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) dev_info(info->dev, "device ID : 0x%x\n", id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239) /* Set ADC debounce time */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240) max77693_muic_set_debounce_time(info, ADC_DEBOUNCE_TIME_25MS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) * Detect accessory after completing the initialization of platform
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) * - Use delayed workqueue to detect cable state and then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) * notify cable state to notifiee/platform through uevent.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247) * After completing the booting of platform, the extcon provider
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) * driver should notify cable state to upper layer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) INIT_DELAYED_WORK(&info->wq_detcable, max77693_muic_detect_cable_wq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251) queue_delayed_work(system_power_efficient_wq, &info->wq_detcable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) delay_jiffies);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) static int max77693_muic_remove(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) struct max77693_muic_info *info = platform_get_drvdata(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261) cancel_work_sync(&info->irq_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) input_unregister_device(info->dock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) static struct platform_driver max77693_muic_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268) .driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) .name = DEV_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271) .probe = max77693_muic_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) .remove = max77693_muic_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) module_platform_driver(max77693_muic_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277) MODULE_DESCRIPTION("Maxim MAX77693 Extcon driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278) MODULE_AUTHOR("Chanwoo Choi <cw00.choi@samsung.com>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) MODULE_ALIAS("platform:max77693-muic");