.. | .. |
---|
1 | | -/* |
---|
2 | | - * extcon-max77843.c - Maxim MAX77843 extcon driver to support |
---|
3 | | - * MUIC(Micro USB Interface Controller) |
---|
4 | | - * |
---|
5 | | - * Copyright (C) 2015 Samsung Electronics |
---|
6 | | - * Author: Jaewon Kim <jaewon02.kim@samsung.com> |
---|
7 | | - * |
---|
8 | | - * This program is free software; you can redistribute it and/or modify |
---|
9 | | - * it under the terms of the GNU General Public License as published by |
---|
10 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
11 | | - * (at your option) any later version. |
---|
12 | | - */ |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0+ |
---|
| 2 | +// |
---|
| 3 | +// extcon-max77843.c - Maxim MAX77843 extcon driver to support |
---|
| 4 | +// MUIC(Micro USB Interface Controller) |
---|
| 5 | +// |
---|
| 6 | +// Copyright (C) 2015 Samsung Electronics |
---|
| 7 | +// Author: Jaewon Kim <jaewon02.kim@samsung.com> |
---|
13 | 8 | |
---|
14 | 9 | #include <linux/extcon-provider.h> |
---|
15 | 10 | #include <linux/i2c.h> |
---|
.. | .. |
---|
779 | 774 | { |
---|
780 | 775 | int ret; |
---|
781 | 776 | |
---|
782 | | - max77843->i2c_muic = i2c_new_dummy(max77843->i2c->adapter, |
---|
| 777 | + max77843->i2c_muic = i2c_new_dummy_device(max77843->i2c->adapter, |
---|
783 | 778 | I2C_ADDR_MUIC); |
---|
784 | | - if (!max77843->i2c_muic) { |
---|
| 779 | + if (IS_ERR(max77843->i2c_muic)) { |
---|
785 | 780 | dev_err(&max77843->i2c->dev, |
---|
786 | 781 | "Cannot allocate I2C device for MUIC\n"); |
---|
787 | | - return -ENOMEM; |
---|
| 782 | + return PTR_ERR(max77843->i2c_muic); |
---|
788 | 783 | } |
---|
789 | 784 | |
---|
790 | 785 | i2c_set_clientdata(max77843->i2c_muic, max77843); |
---|
.. | .. |
---|
817 | 812 | struct max77693_dev *max77843 = dev_get_drvdata(pdev->dev.parent); |
---|
818 | 813 | struct max77843_muic_info *info; |
---|
819 | 814 | unsigned int id; |
---|
| 815 | + int cable_type; |
---|
| 816 | + bool attached; |
---|
820 | 817 | int i, ret; |
---|
821 | 818 | |
---|
822 | 819 | info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); |
---|
.. | .. |
---|
848 | 845 | max77843_extcon_cable); |
---|
849 | 846 | if (IS_ERR(info->edev)) { |
---|
850 | 847 | dev_err(&pdev->dev, "Failed to allocate memory for extcon\n"); |
---|
851 | | - ret = -ENODEV; |
---|
| 848 | + ret = PTR_ERR(info->edev); |
---|
852 | 849 | goto err_muic_irq; |
---|
853 | 850 | } |
---|
854 | 851 | |
---|
.. | .. |
---|
861 | 858 | /* Set ADC debounce time */ |
---|
862 | 859 | max77843_muic_set_debounce_time(info, MAX77843_DEBOUNCE_TIME_25MS); |
---|
863 | 860 | |
---|
864 | | - /* Set initial path for UART */ |
---|
865 | | - max77843_muic_set_path(info, MAX77843_MUIC_CONTROL1_SW_UART, true, |
---|
866 | | - false); |
---|
| 861 | + /* Set initial path for UART when JIG is connected to get serial logs */ |
---|
| 862 | + ret = regmap_bulk_read(max77843->regmap_muic, |
---|
| 863 | + MAX77843_MUIC_REG_STATUS1, info->status, |
---|
| 864 | + MAX77843_MUIC_STATUS_NUM); |
---|
| 865 | + if (ret) { |
---|
| 866 | + dev_err(info->dev, "Cannot read STATUS registers\n"); |
---|
| 867 | + goto err_muic_irq; |
---|
| 868 | + } |
---|
| 869 | + cable_type = max77843_muic_get_cable_type(info, MAX77843_CABLE_GROUP_ADC, |
---|
| 870 | + &attached); |
---|
| 871 | + if (attached && cable_type == MAX77843_MUIC_ADC_FACTORY_MODE_UART_OFF) |
---|
| 872 | + max77843_muic_set_path(info, MAX77843_MUIC_CONTROL1_SW_UART, |
---|
| 873 | + true, false); |
---|
867 | 874 | |
---|
868 | 875 | /* Check revision number of MUIC device */ |
---|
869 | 876 | ret = regmap_read(max77843->regmap_muic, MAX77843_MUIC_REG_ID, &id); |
---|