| .. | .. |
|---|
| 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> |
|---|
| 17 | 7 | |
|---|
| 18 | 8 | #include <linux/kernel.h> |
|---|
| 19 | 9 | #include <linux/module.h> |
|---|
| .. | .. |
|---|
| 1082 | 1072 | struct max77693_reg_data *init_data; |
|---|
| 1083 | 1073 | int num_init_data; |
|---|
| 1084 | 1074 | int delay_jiffies; |
|---|
| 1075 | + int cable_type; |
|---|
| 1076 | + bool attached; |
|---|
| 1085 | 1077 | int ret; |
|---|
| 1086 | 1078 | int i; |
|---|
| 1087 | 1079 | unsigned int id; |
|---|
| .. | .. |
|---|
| 1165 | 1157 | max77693_extcon_cable); |
|---|
| 1166 | 1158 | if (IS_ERR(info->edev)) { |
|---|
| 1167 | 1159 | dev_err(&pdev->dev, "failed to allocate memory for extcon\n"); |
|---|
| 1168 | | - return -ENOMEM; |
|---|
| 1160 | + return PTR_ERR(info->edev); |
|---|
| 1169 | 1161 | } |
|---|
| 1170 | 1162 | |
|---|
| 1171 | 1163 | ret = devm_extcon_dev_register(&pdev->dev, info->edev); |
|---|
| .. | .. |
|---|
| 1222 | 1214 | delay_jiffies = msecs_to_jiffies(DELAY_MS_DEFAULT); |
|---|
| 1223 | 1215 | } |
|---|
| 1224 | 1216 | |
|---|
| 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); |
|---|
| 1227 | 1229 | |
|---|
| 1228 | 1230 | /* Check revision number of MUIC device*/ |
|---|
| 1229 | 1231 | ret = regmap_read(info->max77693->regmap_muic, |
|---|