Skip to content

Commit 685dc9a

Browse files
committed
extcon: max8997: Set default UART/USB path on probe
This patch set default H/W line path according to platfomr data. The MAX8997 MUIC device can possibly set UART/USB or UART_AUX /USB_AUX to internal H/W line path of MUIC device. Namely, only one H/W line is used for two operation. For example, if H/W line path of MAX8997 device set UART/USB, micro usb cable is connected to AP(Application Processor) and if H/W line path set UART_AUX/USB_AUX, micro usb cable is connected to CP(Coprocessor). Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com>
1 parent f73f623 commit 685dc9a

2 files changed

Lines changed: 33 additions & 2 deletions

File tree

‎drivers/extcon/extcon-max8997.c‎

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,13 @@ struct max8997_muic_info {
127127

128128
struct max8997_muic_platform_data *muic_pdata;
129129
enum max8997_muic_charger_type pre_charger_type;
130+
131+
/*
132+
* Default usb/uart path whether UART/USB or AUX_UART/AUX_USB
133+
* h/w path of COMP2/COMN1 on CONTROL1 register.
134+
*/
135+
int path_usb;
136+
int path_uart;
130137
};
131138

132139
enum {
@@ -322,7 +329,7 @@ static int max8997_muic_handle_usb(struct max8997_muic_info *info,
322329
int ret = 0;
323330

324331
if (usb_type == MAX8997_USB_HOST) {
325-
ret = max8997_muic_set_path(info, CONTROL1_SW_USB, attached);
332+
ret = max8997_muic_set_path(info, info->path_usb, attached);
326333
if (ret < 0) {
327334
dev_err(info->dev, "failed to update muic register\n");
328335
return ret;
@@ -378,7 +385,7 @@ static int max8997_muic_handle_jig_uart(struct max8997_muic_info *info,
378385
int ret = 0;
379386

380387
/* switch to UART */
381-
ret = max8997_muic_set_path(info, CONTROL1_SW_UART, attached);
388+
ret = max8997_muic_set_path(info, info->path_uart, attached);
382389
if (ret) {
383390
dev_err(info->dev, "failed to update muic register\n");
384391
return -EINVAL;
@@ -694,6 +701,23 @@ static int max8997_muic_probe(struct platform_device *pdev)
694701
}
695702
}
696703

704+
/*
705+
* Default usb/uart path whether UART/USB or AUX_UART/AUX_USB
706+
* h/w path of COMP2/COMN1 on CONTROL1 register.
707+
*/
708+
if (pdata->muic_pdata->path_uart)
709+
info->path_uart = pdata->muic_pdata->path_uart;
710+
else
711+
info->path_uart = CONTROL1_SW_UART;
712+
713+
if (pdata->muic_pdata->path_usb)
714+
info->path_usb = pdata->muic_pdata->path_usb;
715+
else
716+
info->path_usb = CONTROL1_SW_USB;
717+
718+
/* Set initial path for UART */
719+
max8997_muic_set_path(info, info->path_uart, true);
720+
697721
/* Set ADC debounce time */
698722
max8997_muic_set_debounce_time(info, ADC_DEBOUNCE_TIME_25MS);
699723

‎include/linux/mfd/max8997.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,13 @@ struct max8997_muic_reg_data {
9292
struct max8997_muic_platform_data {
9393
struct max8997_muic_reg_data *init_data;
9494
int num_init_data;
95+
96+
/*
97+
* Default usb/uart path whether UART/USB or AUX_UART/AUX_USB
98+
* h/w path of COMP2/COMN1 on CONTROL1 register.
99+
*/
100+
int path_usb;
101+
int path_uart;
95102
};
96103

97104
enum max8997_haptic_motor_type {

0 commit comments

Comments
 (0)