Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

extcon: max77843: Avoid forcing UART path on drive probe

Driver unconditionally forces UART path during probe, probably to ensure
that one can get kernel serial log as soon as possible.

This approach causes some issues, especially when board is booted with
non-UART cable connected to micro-USB port. For example, when USB cable is
connected, UART TX/RX lines are unconditionally short-circuited to USB
D+/D- lines. This is in turn recognized by a series of serial BREAK
signals and some random characters when USB host tries to perform
enumeration procedure.

To solve the above issue and keep UART console operational as early as
possible, set UART path only when USB ID reports UART capable cable.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>

authored by

Marek Szyprowski and committed by
Chanwoo Choi
d9204acb 65102238

+15 -3
+15 -3
drivers/extcon/extcon-max77843.c
··· 812 812 struct max77693_dev *max77843 = dev_get_drvdata(pdev->dev.parent); 813 813 struct max77843_muic_info *info; 814 814 unsigned int id; 815 + int cable_type; 816 + bool attached; 815 817 int i, ret; 816 818 817 819 info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); ··· 858 856 /* Set ADC debounce time */ 859 857 max77843_muic_set_debounce_time(info, MAX77843_DEBOUNCE_TIME_25MS); 860 858 861 - /* Set initial path for UART */ 862 - max77843_muic_set_path(info, MAX77843_MUIC_CONTROL1_SW_UART, true, 863 - false); 859 + /* Set initial path for UART when JIG is connected to get serial logs */ 860 + ret = regmap_bulk_read(max77843->regmap_muic, 861 + MAX77843_MUIC_REG_STATUS1, info->status, 862 + MAX77843_MUIC_STATUS_NUM); 863 + if (ret) { 864 + dev_err(info->dev, "Cannot read STATUS registers\n"); 865 + goto err_muic_irq; 866 + } 867 + cable_type = max77843_muic_get_cable_type(info, MAX77843_CABLE_GROUP_ADC, 868 + &attached); 869 + if (attached && cable_type == MAX77843_MUIC_ADC_FACTORY_MODE_UART_OFF) 870 + max77843_muic_set_path(info, MAX77843_MUIC_CONTROL1_SW_UART, 871 + true, false); 864 872 865 873 /* Check revision number of MUIC device */ 866 874 ret = regmap_read(max77843->regmap_muic, MAX77843_MUIC_REG_ID, &id);