hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/extcon/extcon-max77693.c
....@@ -1,19 +1,9 @@
1
-/*
2
- * extcon-max77693.c - MAX77693 extcon driver to support MAX77693 MUIC
3
- *
4
- * Copyright (C) 2012 Samsung Electrnoics
5
- * Chanwoo Choi <cw00.choi@samsung.com>
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License as published by
9
- * the Free Software Foundation; either version 2 of the License, or
10
- * (at your option) any later version.
11
- *
12
- * This program is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- * GNU General Public License for more details.
16
- */
1
+// SPDX-License-Identifier: GPL-2.0+
2
+//
3
+// extcon-max77693.c - MAX77693 extcon driver to support MAX77693 MUIC
4
+//
5
+// Copyright (C) 2012 Samsung Electrnoics
6
+// Chanwoo Choi <cw00.choi@samsung.com>
177
188 #include <linux/kernel.h>
199 #include <linux/module.h>
....@@ -1082,6 +1072,8 @@
10821072 struct max77693_reg_data *init_data;
10831073 int num_init_data;
10841074 int delay_jiffies;
1075
+ int cable_type;
1076
+ bool attached;
10851077 int ret;
10861078 int i;
10871079 unsigned int id;
....@@ -1165,7 +1157,7 @@
11651157 max77693_extcon_cable);
11661158 if (IS_ERR(info->edev)) {
11671159 dev_err(&pdev->dev, "failed to allocate memory for extcon\n");
1168
- return -ENOMEM;
1160
+ return PTR_ERR(info->edev);
11691161 }
11701162
11711163 ret = devm_extcon_dev_register(&pdev->dev, info->edev);
....@@ -1222,8 +1214,18 @@
12221214 delay_jiffies = msecs_to_jiffies(DELAY_MS_DEFAULT);
12231215 }
12241216
1225
- /* Set initial path for UART */
1226
- max77693_muic_set_path(info, info->path_uart, true);
1217
+ /* Set initial path for UART when JIG is connected to get serial logs */
1218
+ ret = regmap_bulk_read(info->max77693->regmap_muic,
1219
+ MAX77693_MUIC_REG_STATUS1, info->status, 2);
1220
+ if (ret) {
1221
+ dev_err(info->dev, "failed to read MUIC register\n");
1222
+ return ret;
1223
+ }
1224
+ cable_type = max77693_muic_get_cable_type(info,
1225
+ MAX77693_CABLE_GROUP_ADC, &attached);
1226
+ if (attached && (cable_type == MAX77693_MUIC_ADC_FACTORY_MODE_UART_ON ||
1227
+ cable_type == MAX77693_MUIC_ADC_FACTORY_MODE_UART_OFF))
1228
+ max77693_muic_set_path(info, info->path_uart, true);
12271229
12281230 /* Check revision number of MUIC device*/
12291231 ret = regmap_read(info->max77693->regmap_muic,