| .. | .. |
|---|
| 1 | | -/* |
|---|
| 2 | | - * extcon-max14577.c - MAX14577/77836 extcon driver to support MUIC |
|---|
| 3 | | - * |
|---|
| 4 | | - * Copyright (C) 2013,2014 Samsung Electronics |
|---|
| 5 | | - * Chanwoo Choi <cw00.choi@samsung.com> |
|---|
| 6 | | - * Krzysztof Kozlowski <krzk@kernel.org> |
|---|
| 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 | | - * |
|---|
| 13 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 14 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 15 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 16 | | - * GNU General Public License for more details. |
|---|
| 17 | | - */ |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0+ |
|---|
| 2 | +// |
|---|
| 3 | +// extcon-max14577.c - MAX14577/77836 extcon driver to support MUIC |
|---|
| 4 | +// |
|---|
| 5 | +// Copyright (C) 2013,2014 Samsung Electronics |
|---|
| 6 | +// Chanwoo Choi <cw00.choi@samsung.com> |
|---|
| 7 | +// Krzysztof Kozlowski <krzk@kernel.org> |
|---|
| 18 | 8 | |
|---|
| 19 | 9 | #include <linux/kernel.h> |
|---|
| 20 | 10 | #include <linux/module.h> |
|---|
| .. | .. |
|---|
| 667 | 657 | struct max14577 *max14577 = dev_get_drvdata(pdev->dev.parent); |
|---|
| 668 | 658 | struct max14577_muic_info *info; |
|---|
| 669 | 659 | int delay_jiffies; |
|---|
| 660 | + int cable_type; |
|---|
| 661 | + bool attached; |
|---|
| 670 | 662 | int ret; |
|---|
| 671 | 663 | int i; |
|---|
| 672 | 664 | u8 id; |
|---|
| .. | .. |
|---|
| 721 | 713 | max14577_extcon_cable); |
|---|
| 722 | 714 | if (IS_ERR(info->edev)) { |
|---|
| 723 | 715 | dev_err(&pdev->dev, "failed to allocate memory for extcon\n"); |
|---|
| 724 | | - return -ENOMEM; |
|---|
| 716 | + return PTR_ERR(info->edev); |
|---|
| 725 | 717 | } |
|---|
| 726 | 718 | |
|---|
| 727 | 719 | ret = devm_extcon_dev_register(&pdev->dev, info->edev); |
|---|
| .. | .. |
|---|
| 735 | 727 | info->path_uart = CTRL1_SW_UART; |
|---|
| 736 | 728 | delay_jiffies = msecs_to_jiffies(DELAY_MS_DEFAULT); |
|---|
| 737 | 729 | |
|---|
| 738 | | - /* Set initial path for UART */ |
|---|
| 739 | | - max14577_muic_set_path(info, info->path_uart, true); |
|---|
| 730 | + /* Set initial path for UART when JIG is connected to get serial logs */ |
|---|
| 731 | + ret = max14577_bulk_read(info->max14577->regmap, |
|---|
| 732 | + MAX14577_MUIC_REG_STATUS1, info->status, 2); |
|---|
| 733 | + if (ret) { |
|---|
| 734 | + dev_err(info->dev, "Cannot read STATUS registers\n"); |
|---|
| 735 | + return ret; |
|---|
| 736 | + } |
|---|
| 737 | + cable_type = max14577_muic_get_cable_type(info, MAX14577_CABLE_GROUP_ADC, |
|---|
| 738 | + &attached); |
|---|
| 739 | + if (attached && cable_type == MAX14577_MUIC_ADC_FACTORY_MODE_UART_OFF) |
|---|
| 740 | + max14577_muic_set_path(info, info->path_uart, true); |
|---|
| 740 | 741 | |
|---|
| 741 | 742 | /* Check revision number of MUIC device*/ |
|---|
| 742 | 743 | ret = max14577_read_reg(info->max14577->regmap, |
|---|
| .. | .. |
|---|
| 781 | 782 | }; |
|---|
| 782 | 783 | MODULE_DEVICE_TABLE(platform, max14577_muic_id); |
|---|
| 783 | 784 | |
|---|
| 785 | +static const struct of_device_id of_max14577_muic_dt_match[] = { |
|---|
| 786 | + { .compatible = "maxim,max14577-muic", |
|---|
| 787 | + .data = (void *)MAXIM_DEVICE_TYPE_MAX14577, }, |
|---|
| 788 | + { .compatible = "maxim,max77836-muic", |
|---|
| 789 | + .data = (void *)MAXIM_DEVICE_TYPE_MAX77836, }, |
|---|
| 790 | + { }, |
|---|
| 791 | +}; |
|---|
| 792 | +MODULE_DEVICE_TABLE(of, of_max14577_muic_dt_match); |
|---|
| 793 | + |
|---|
| 784 | 794 | static struct platform_driver max14577_muic_driver = { |
|---|
| 785 | 795 | .driver = { |
|---|
| 786 | 796 | .name = "max14577-muic", |
|---|
| 797 | + .of_match_table = of_max14577_muic_dt_match, |
|---|
| 787 | 798 | }, |
|---|
| 788 | 799 | .probe = max14577_muic_probe, |
|---|
| 789 | 800 | .remove = max14577_muic_remove, |
|---|