.. | .. |
---|
1 | | -/* |
---|
2 | | - * extcon-max8997.c - MAX8997 extcon driver to support MAX8997 MUIC |
---|
3 | | - * |
---|
4 | | - * Copyright (C) 2012 Samsung Electronics |
---|
5 | | - * Donggeun Kim <dg77.kim@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-max8997.c - MAX8997 extcon driver to support MAX8997 MUIC |
---|
| 4 | +// |
---|
| 5 | +// Copyright (C) 2012 Samsung Electronics |
---|
| 6 | +// Donggeun Kim <dg77.kim@samsung.com> |
---|
17 | 7 | |
---|
18 | 8 | #include <linux/kernel.h> |
---|
19 | 9 | #include <linux/module.h> |
---|
.. | .. |
---|
640 | 630 | struct max8997_platform_data *pdata = dev_get_platdata(max8997->dev); |
---|
641 | 631 | struct max8997_muic_info *info; |
---|
642 | 632 | int delay_jiffies; |
---|
| 633 | + int cable_type; |
---|
| 634 | + bool attached; |
---|
643 | 635 | int ret, i; |
---|
644 | 636 | |
---|
645 | 637 | info = devm_kzalloc(&pdev->dev, sizeof(struct max8997_muic_info), |
---|
.. | .. |
---|
682 | 674 | info->edev = devm_extcon_dev_allocate(&pdev->dev, max8997_extcon_cable); |
---|
683 | 675 | if (IS_ERR(info->edev)) { |
---|
684 | 676 | dev_err(&pdev->dev, "failed to allocate memory for extcon\n"); |
---|
685 | | - ret = -ENOMEM; |
---|
| 677 | + ret = PTR_ERR(info->edev); |
---|
686 | 678 | goto err_irq; |
---|
687 | 679 | } |
---|
688 | 680 | |
---|
.. | .. |
---|
732 | 724 | delay_jiffies = msecs_to_jiffies(DELAY_MS_DEFAULT); |
---|
733 | 725 | } |
---|
734 | 726 | |
---|
735 | | - /* Set initial path for UART */ |
---|
736 | | - max8997_muic_set_path(info, info->path_uart, true); |
---|
| 727 | + /* Set initial path for UART when JIG is connected to get serial logs */ |
---|
| 728 | + ret = max8997_bulk_read(info->muic, MAX8997_MUIC_REG_STATUS1, |
---|
| 729 | + 2, info->status); |
---|
| 730 | + if (ret) { |
---|
| 731 | + dev_err(info->dev, "failed to read MUIC register\n"); |
---|
| 732 | + goto err_irq; |
---|
| 733 | + } |
---|
| 734 | + cable_type = max8997_muic_get_cable_type(info, |
---|
| 735 | + MAX8997_CABLE_GROUP_ADC, &attached); |
---|
| 736 | + if (attached && cable_type == MAX8997_MUIC_ADC_FACTORY_MODE_UART_OFF) |
---|
| 737 | + max8997_muic_set_path(info, info->path_uart, true); |
---|
737 | 738 | |
---|
738 | 739 | /* Set ADC debounce time */ |
---|
739 | 740 | max8997_muic_set_debounce_time(info, ADC_DEBOUNCE_TIME_25MS); |
---|