From patchwork Thu Nov 8 13:45:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 10674227 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1BE5514BD for ; Thu, 8 Nov 2018 13:46:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B2242DAEB for ; Thu, 8 Nov 2018 13:46:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F3B532DAFA; Thu, 8 Nov 2018 13:46:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F1332DAE4 for ; Thu, 8 Nov 2018 13:46:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727257AbeKHXVc (ORCPT ); Thu, 8 Nov 2018 18:21:32 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:55119 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726469AbeKHXVa (ORCPT ); Thu, 8 Nov 2018 18:21:30 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20181108134555euoutp01a0dfea03ef25b92004ecb5651e807f81~lKh3fVK6X0612206122euoutp01A; Thu, 8 Nov 2018 13:45:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20181108134555euoutp01a0dfea03ef25b92004ecb5651e807f81~lKh3fVK6X0612206122euoutp01A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1541684755; bh=qvh3V9PLthjx6o4AmMgdFWNv2iBqoQahmEOZ2QTJhmI=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=MJbOXuUP+xdlJOZRUyqeeDkytNzLqQVuMFJLKGqRvYstUmteyXJI10QPc7TwDSeDI XewTGwr9pO+v2XcPVPXuXgFXOKy4ALkxxfGf42oj2qxugB2vnLFTb7IIm06cYJGd5b 4E1uKrqSKMHqcJvXiwOza5TUSQQ0X+9kJbNmC2FY= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20181108134554eucas1p1c21490dc498a1c5eed4a8c653bbffdf3~lKh3Ee1Ii0883408834eucas1p1i; Thu, 8 Nov 2018 13:45:54 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 6B.7A.04806.21E34EB5; Thu, 8 Nov 2018 13:45:54 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20181108134554eucas1p20df6cef615670df482e1f6c8ac4b86de~lKh2fC9XO1374713747eucas1p2I; Thu, 8 Nov 2018 13:45:54 +0000 (GMT) X-AuditID: cbfec7f5-367ff700000012c6-b4-5be43e124df1 Received: from eusync1.samsung.com ( [203.254.199.211]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 76.70.04284.21E34EB5; Thu, 8 Nov 2018 13:45:54 +0000 (GMT) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0PHV00GNNNKETS20@eusync1.samsung.com>; Thu, 08 Nov 2018 13:45:54 +0000 (GMT) From: Marek Szyprowski To: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: Marek Szyprowski , MyungJoo Ham , Chanwoo Choi , Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz Subject: [PATCH 1/4] extcon: max77843: Avoid forcing UART path on drive probe Date: Thu, 08 Nov 2018 14:45:45 +0100 Message-id: <20181108134548.31140-2-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-reply-to: <20181108134548.31140-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprHIsWRmVeSWpSXmKPExsWy7djP87pCdk+iDTYfUbTYOGM9q8X1L89Z Lc6f38BucXnXHDaLGef3MVmsPXKX3eJ24wo2B3aPTas62Tz6tqxi9Pi8SS6AOYrLJiU1J7Ms tUjfLoEro2FLbcEZoYrnW/kbGI/ydzFyckgImEjsXzGftYuRi0NIYAWjRNPv/1DOZ0aJ6Wu3 MHUxcoBVPV6bBxFfxijxqHs2G4TTwCTx8Od2dpBRbAKGEl1vu9hAbBEBZ4nbH76xgNjMAg8Z JbZcVQCxhQX8JQ5P3gBWzyKgKrFqwhZWEJtXwFZi94GLrBAnyUus3nCAGcTmFLCTuPbuC9gy CYGvrBLrJjWwQBS5SHR0L4CyhSVeHd/CDmHLSHR2HGSCaGhmlGifMYsdwulhlNg6ZwcbRJW1 xOHjEOuYBfgkJm2bzgzxJ69ER5sQRImHxKEjx5kh3pzIKHGjZTX7BEbJBYwMqxjFU0uLc9NT i43zUsv1ihNzi0vz0vWS83M3MQJj7fS/4193MO77k3SIUYCDUYmHV0LxcbQQa2JZcWXuIUYJ DmYlEd5NOk+ihXhTEiurUovy44tKc1KLDzFKc7AoifNWMzyIFhJITyxJzU5NLUgtgskycXBK NTAeZpselNLkJaB30eZZyAb3nX6e7wSz3AxcN7b/kFTrPWPY+eHGrX28JqpuZY4f0r86CJtl pdiEBd3pr7wnzXl80r73uW+WG+zOlE27dSZWgm3hwTmJeb/idnWVP/IXaphkcaZO8W/Aq5n7 fYs6bTLdG15FXnwgvfbek3VR6ZxJwe/ut00on6TEUpyRaKjFXFScCAAPG5XBsQIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrFJMWRmVeSWpSXmKPExsVy+t/xy7pCdk+iDSZsZLPYOGM9q8X1L89Z Lc6f38BucXnXHDaLGef3MVmsPXKX3eJ24wo2B3aPTas62Tz6tqxi9Pi8SS6AOYrLJiU1J7Ms tUjfLoEro2FLbcEZoYrnW/kbGI/ydzFycEgImEg8XpvXxcjFISSwhFHi5YzbTBBOE5PE2saH rF2MnBxsAoYSXW+72EBsEQFnidsfvrGAFDELPGSUeLXlCCNIQljAV+LAst9gNouAqsSqCVvA mnkFbCV2H7gIZksIyEus3nCAGcTmFLCTuPbuCxvIFUJANcuvck1g5FnAyLCKUSS1tDg3PbfY UK84Mbe4NC9dLzk/dxMjMES2Hfu5eQfjpY3BhxgFOBiVeHgPyD2OFmJNLCuuzD3EKMHBrCTC u0nnSbQQb0piZVVqUX58UWlOavEhRmkOFiVx3vMGlVFCAumJJanZqakFqUUwWSYOTqkGRhvH zs9Hdj7Yo8jOLPI/0bHQ96got3JLXPNyOe3dK3tbl7/65cn39MoTOa/Mv3HHzX9P+/fEWit/ c5guPw+3+JfG017xvwtVtQReRt4NbGV8ItqxKJaT7dLRrpm7inikAva+mj6bfe7E5ZI7962W K7wzhf3wbROxHRfdDJgW3+kP2WYtL7QyWomlOCPRUIu5qDgRAOSI3YkNAgAA X-CMS-MailID: 20181108134554eucas1p20df6cef615670df482e1f6c8ac4b86de X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20181108134554eucas1p20df6cef615670df482e1f6c8ac4b86de References: <20181108134548.31140-1-m.szyprowski@samsung.com> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- drivers/extcon/extcon-max77843.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/extcon/extcon-max77843.c b/drivers/extcon/extcon-max77843.c index b98cbd0362f5..a343a6ef3506 100644 --- a/drivers/extcon/extcon-max77843.c +++ b/drivers/extcon/extcon-max77843.c @@ -812,6 +812,8 @@ static int max77843_muic_probe(struct platform_device *pdev) struct max77693_dev *max77843 = dev_get_drvdata(pdev->dev.parent); struct max77843_muic_info *info; unsigned int id; + int cable_type; + bool attached; int i, ret; info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); @@ -856,9 +858,19 @@ static int max77843_muic_probe(struct platform_device *pdev) /* Set ADC debounce time */ max77843_muic_set_debounce_time(info, MAX77843_DEBOUNCE_TIME_25MS); - /* Set initial path for UART */ - max77843_muic_set_path(info, MAX77843_MUIC_CONTROL1_SW_UART, true, - false); + /* Set initial path for UART when JIG is connected to get serial logs */ + ret = regmap_bulk_read(max77843->regmap_muic, + MAX77843_MUIC_REG_STATUS1, info->status, + MAX77843_MUIC_STATUS_NUM); + if (ret) { + dev_err(info->dev, "Cannot read STATUS registers\n"); + goto err_muic_irq; + } + cable_type = max77843_muic_get_cable_type(info, MAX77843_CABLE_GROUP_ADC, + &attached); + if (attached && cable_type == MAX77843_MUIC_ADC_FACTORY_MODE_UART_OFF) + max77843_muic_set_path(info, MAX77843_MUIC_CONTROL1_SW_UART, + true, false); /* Check revision number of MUIC device */ ret = regmap_read(max77843->regmap_muic, MAX77843_MUIC_REG_ID, &id); From patchwork Thu Nov 8 13:45:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 10674233 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A9494109C for ; Thu, 8 Nov 2018 13:46:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 996A62DAE4 for ; Thu, 8 Nov 2018 13:46:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8DD3C2DB00; Thu, 8 Nov 2018 13:46:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 337C32DAE4 for ; Thu, 8 Nov 2018 13:46:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727184AbeKHXVc (ORCPT ); Thu, 8 Nov 2018 18:21:32 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:55131 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727037AbeKHXVa (ORCPT ); Thu, 8 Nov 2018 18:21:30 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20181108134556euoutp014c1dad8f96abe970313edf63c44124de~lKh4QO4SC0572605726euoutp01D; Thu, 8 Nov 2018 13:45:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20181108134556euoutp014c1dad8f96abe970313edf63c44124de~lKh4QO4SC0572605726euoutp01D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1541684756; bh=vRpUWpQL+tggvTY5uMit27WYvn6NjSQbU3SoxcMmhMA=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=sPGO5TEaWGS65WWnORrv8vwIWlYuf6YovvZZjg3voUximi3INeeaUxUa4DdC/YoZN lJD7S7S1po/A1s9SR6Xhuk3dt9+to4q5qrSbZplm5jOaQXW5Gd/61tMpjCDk2/n5hZ 6Dv5ymKrdL00scSTySm4zdTTkW0k1UJ3ItiMCPUI= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20181108134555eucas1p221e4522e83bc10dce198b20ee9272a2f~lKh3rz2TY1373213732eucas1p29; Thu, 8 Nov 2018 13:45:55 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id EB.7A.04806.31E34EB5; Thu, 8 Nov 2018 13:45:55 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20181108134554eucas1p12694abede1bf0ce633d4890e2297b685~lKh2y1f4b1720217202eucas1p1t; Thu, 8 Nov 2018 13:45:54 +0000 (GMT) X-AuditID: cbfec7f5-34dff700000012c6-b5-5be43e134e02 Received: from eusync1.samsung.com ( [203.254.199.211]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 69.F3.04128.21E34EB5; Thu, 8 Nov 2018 13:45:54 +0000 (GMT) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0PHV00GNNNKETS20@eusync1.samsung.com>; Thu, 08 Nov 2018 13:45:54 +0000 (GMT) From: Marek Szyprowski To: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: Marek Szyprowski , MyungJoo Ham , Chanwoo Choi , Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz Subject: [PATCH 2/4] extcon: max77693: Avoid forcing UART path on drive probe Date: Thu, 08 Nov 2018 14:45:46 +0100 Message-id: <20181108134548.31140-3-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-reply-to: <20181108134548.31140-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprPIsWRmVeSWpSXmKPExsWy7djP87rCdk+iDX4d4bbYOGM9q8X1L89Z Lc6f38BucXnXHDaLGef3MVmsPXKX3eJ24wo2B3aPTas62Tz6tqxi9Pi8SS6AOYrLJiU1J7Ms tUjfLoEr49bly6wF8wQrnj86zdLAuImvi5GTQ0LAROL6zXXMILaQwApGiftT+LsYuYDsz4wS J1vbmWGKlh9sZIVILGOUmHN5CZTTwCTx8Od2dpAqNgFDia63XWwgtoiAs8TtD99YQGxmgYeM EluuKnQxcnAIC/hLPJ2ZBxJmEVCVaG2czghi8wrYSvxct4kFYpm8xOoNB8AWcwrYSVx794UN ZJeEwE9Wicd/QK4AKXKRuPDwGFSDsMSr41vYIWwZicuTu1kgGpoZJdpnzGKHcHoYJbbO2cEG UWUtcfj4RVaI6/gkJm2bzgxynYQAr0RHmxBEiYfE1bndUF9OZJQ49qGZfQKj5AJGhlWM4qml xbnpqcXGeanlesWJucWleel6yfm5mxiB0Xb63/GvOxj3/Uk6xCjAwajEwyuh+DhaiDWxrLgy 9xCjBAezkgjvJp0n0UK8KYmVValF+fFFpTmpxYcYpTlYlMR5qxkeRAsJpCeWpGanphakFsFk mTg4pRoYVxX+nlpV6K2a8CPwXuFjiegNVh2r29z3/tLRD+fuZYhyeNNgobOL28rWeKK54DRO y86uxZYP/oguufVddv9euwzd33bc6hMfhsqkbf3x9fozz1Nth/b3r27UTP0xwUfL7Lm0dWFP 6LEzqyb/PVVqGWv09c4zt5tqXFfE3zFNepBzuCnYavZuJZbijERDLeai4kQAKxap3LICAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrLJMWRmVeSWpSXmKPExsVy+t/xy7pCdk+iDa6skbHYOGM9q8X1L89Z Lc6f38BucXnXHDaLGef3MVmsPXKX3eJ24wo2B3aPTas62Tz6tqxi9Pi8SS6AOYrLJiU1J7Ms tUjfLoEr49bly6wF8wQrnj86zdLAuImvi5GTQ0LARGL5wUbWLkYuDiGBJYwSU28/hHKamCTW NoI4nBxsAoYSXW+72EBsEQFnidsfvrGAFDELPGSUeLXlCCNIQljAV+L+rRPsIDaLgKpEa+N0 sDivgK3Ez3WbWCDWyUus3nCAGcTmFLCTuPbuC9BQDqBtthLLr3JNYORZwMiwilEktbQ4Nz23 2EivODG3uDQvXS85P3cTIzBQth37uWUHY9e74EOMAhyMSjy8B+QeRwuxJpYVV+YeYpTgYFYS 4d2k8yRaiDclsbIqtSg/vqg0J7X4EKM0B4uSOO95g8ooIYH0xJLU7NTUgtQimCwTB6dUA2Od fI8CN0P/nC+//rQFbfi4n3m1zJtOfu3P8Wo9pekb3n16U7BU9snvfCu/hocVXRn3VTnEth5b u5GBa9HDuMq3l1+GfhOzFF5udDEuVfCggQEPg+NuOz63RxXHvxvLL91k+26BraGzxZKTwTrl Rx6FNCZziBUcTl4V9il0SdpzCY/TUzI25CuxFGckGmoxFxUnAgA+m6CCEAIAAA== X-CMS-MailID: 20181108134554eucas1p12694abede1bf0ce633d4890e2297b685 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20181108134554eucas1p12694abede1bf0ce633d4890e2297b685 References: <20181108134548.31140-1-m.szyprowski@samsung.com> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- drivers/extcon/extcon-max77693.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/extcon/extcon-max77693.c b/drivers/extcon/extcon-max77693.c index a79537ebb671..32fc5a66ffa9 100644 --- a/drivers/extcon/extcon-max77693.c +++ b/drivers/extcon/extcon-max77693.c @@ -1072,6 +1072,8 @@ static int max77693_muic_probe(struct platform_device *pdev) struct max77693_reg_data *init_data; int num_init_data; int delay_jiffies; + int cable_type; + bool attached; int ret; int i; unsigned int id; @@ -1212,8 +1214,18 @@ static int max77693_muic_probe(struct platform_device *pdev) delay_jiffies = msecs_to_jiffies(DELAY_MS_DEFAULT); } - /* Set initial path for UART */ - max77693_muic_set_path(info, info->path_uart, true); + /* Set initial path for UART when JIG is connected to get serial logs */ + ret = regmap_bulk_read(info->max77693->regmap_muic, + MAX77693_MUIC_REG_STATUS1, info->status, 2); + if (ret) { + dev_err(info->dev, "failed to read MUIC register\n"); + return ret; + } + cable_type = max77693_muic_get_cable_type(info, + MAX77693_CABLE_GROUP_ADC, &attached); + if (attached && (cable_type == MAX77693_MUIC_ADC_FACTORY_MODE_UART_ON || + cable_type == MAX77693_MUIC_ADC_FACTORY_MODE_UART_OFF)) + max77693_muic_set_path(info, info->path_uart, true); /* Check revision number of MUIC device*/ ret = regmap_read(info->max77693->regmap_muic, From patchwork Thu Nov 8 13:45:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 10674231 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E6C3714BD for ; Thu, 8 Nov 2018 13:46:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D4E7F2DAFA for ; Thu, 8 Nov 2018 13:46:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C9B732DAE4; Thu, 8 Nov 2018 13:46:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 543122DAEB for ; Thu, 8 Nov 2018 13:46:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727232AbeKHXVc (ORCPT ); Thu, 8 Nov 2018 18:21:32 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:55129 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727028AbeKHXVa (ORCPT ); Thu, 8 Nov 2018 18:21:30 -0500 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20181108134556euoutp01bca31f16902bbc0331d97b2159239642~lKh4OwcLf0570905709euoutp01J; Thu, 8 Nov 2018 13:45:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20181108134556euoutp01bca31f16902bbc0331d97b2159239642~lKh4OwcLf0570905709euoutp01J DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1541684756; bh=bFujyy0o4H8gCi49hkwnl6cUPt+eOaf+xnWYuyuPuT0=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=MpwfSApe8DTJd+rQxywpYzY7F83E0jrhRg7YHes/3SyJrd8rIz3uIw5f/26dNDY11 XSgcG6AzQneZPy34e6M/1tyk+r4U2ZfmJkVZs2Pt23/TLmqN9+VoINAZwu5lY23/tY e/Hb7wJKGSiOnIAUqDKfumhH3FopUwm/TY74ubVI= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20181108134555eucas1p1734d251d6854d0bbc67a7ed70e07b54e~lKh32ZQvg0883808838eucas1p1d; Thu, 8 Nov 2018 13:45:55 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 6C.7A.04806.31E34EB5; Thu, 8 Nov 2018 13:45:55 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20181108134554eucas1p26363910951ef941a3b80f47a1c0006c2~lKh3JD2b11557415574eucas1p20; Thu, 8 Nov 2018 13:45:54 +0000 (GMT) X-AuditID: cbfec7f5-367ff700000012c6-b6-5be43e1384e6 Received: from eusync1.samsung.com ( [203.254.199.211]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 47.70.04284.21E34EB5; Thu, 8 Nov 2018 13:45:54 +0000 (GMT) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0PHV00GNNNKETS20@eusync1.samsung.com>; Thu, 08 Nov 2018 13:45:54 +0000 (GMT) From: Marek Szyprowski To: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: Marek Szyprowski , MyungJoo Ham , Chanwoo Choi , Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz Subject: [PATCH 3/4] extcon: max14577: Avoid forcing UART path on drive probe Date: Thu, 08 Nov 2018 14:45:47 +0100 Message-id: <20181108134548.31140-4-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-reply-to: <20181108134548.31140-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprPIsWRmVeSWpSXmKPExsWy7djP87rCdk+iDRb95rfYOGM9q8X1L89Z Lc6f38BucXnXHDaLGef3MVmsPXKX3eJ24wo2B3aPTas62Tz6tqxi9Pi8SS6AOYrLJiU1J7Ms tUjfLoEr4/6eVraCCYIVa68eZm9gXMfXxcjJISFgInF53SGWLkYuDiGBFYwSe1c/Z4NwPjNK PDr+nAWm6ufkSawQiWWMEuem3GGCcBqYJB7+3M4OUsUmYCjR9baLDcQWEXCWuP3hG1g3s8BD RoktVxVAbGEBf4krj9+zgtgsAqoSz/6vA6vhFbCVmPtpC9Q2eYnVGw4wg9icAnYS1959ATtJ QuAnq8Tk6a+BNnMAOS4Scz9UQNQLS7w6voUdwpaR6Ow4yARR38wo0T5jFjuE08MosXXODjaI KmuJw8cvskJcxycxadt0ZoihvBIdbUIQpofExXtyEE9OZJRo2XmLfQKj5AJGhlWM4qmlxbnp qcXGeanlesWJucWleel6yfm5mxiB0Xb63/GvOxj3/Uk6xCjAwajEwyuh+DhaiDWxrLgy9xCj BAezkgjvJp0n0UK8KYmVValF+fFFpTmpxYcYpTlYlMR5qxkeRAsJpCeWpGanphakFsFkmTg4 pRoY989s3qm1M341q6LW8tM6/7sfN4ZuOu/30OWkw5LbtzJE7TV9TQTEd8yL/T/Dxcr+sebD gvwnMVpvcu4zrr9j/UhmRvB/C80HR5Y722Tz2F9Q1DCIuj9piWzIe54dxg8+HWqR+ZS2mpt/ 48r7NdllGx6EKu+YNcfU5JHitGdFSeqpjpaWpxRmK7EUZyQaajEXFScCAOb1FYiyAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrLJMWRmVeSWpSXmKPExsVy+t/xy7pCdk+iDW5+MLLYOGM9q8X1L89Z Lc6f38BucXnXHDaLGef3MVmsPXKX3eJ24wo2B3aPTas62Tz6tqxi9Pi8SS6AOYrLJiU1J7Ms tUjfLoEr4/6eVraCCYIVa68eZm9gXMfXxcjJISFgIvFz8iTWLkYuDiGBJYwSXzc9g3KamCTW Nj5kBaliEzCU6HrbxQZiiwg4S9z+8I0FpIhZ4CGjxKstRxhBEsICvhL9Ly4yg9gsAqoSz/6v YwGxeQVsJeZ+2sICsU5eYvWGA2A1nAJ2EtfefQEaygG0zVZi+VWuCYw8CxgZVjGKpJYW56bn FhvqFSfmFpfmpesl5+duYgQGyrZjPzfvYLy0MfgQowAHoxIP7wG5x9FCrIllxZW5hxglOJiV RHg36TyJFuJNSaysSi3Kjy8qzUktPsQozcGiJM573qAySkggPbEkNTs1tSC1CCbLxMEp1cDI u18nVaIlQnx7xd9fr29XWOXtSGsIWu2yV/d35n3Bzw/7I9fds+F1TJh5xsL59qOMo8dvTyoL Lpr1jke+9Rav4S9zedfeh+tnv+IoaW3SNLNblGi+bEvn5Gs7tlkyO2/K3SF9eFI454sXrSXG TipP5oVrPzZZKz5pxo/06wFzxPr99UKMtrMpsRRnJBpqMRcVJwIAHcIfJhACAAA= X-CMS-MailID: 20181108134554eucas1p26363910951ef941a3b80f47a1c0006c2 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20181108134554eucas1p26363910951ef941a3b80f47a1c0006c2 References: <20181108134548.31140-1-m.szyprowski@samsung.com> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- drivers/extcon/extcon-max14577.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/extcon/extcon-max14577.c b/drivers/extcon/extcon-max14577.c index 22d2feb1f8bc..32f663436e6e 100644 --- a/drivers/extcon/extcon-max14577.c +++ b/drivers/extcon/extcon-max14577.c @@ -657,6 +657,8 @@ static int max14577_muic_probe(struct platform_device *pdev) struct max14577 *max14577 = dev_get_drvdata(pdev->dev.parent); struct max14577_muic_info *info; int delay_jiffies; + int cable_type; + bool attached; int ret; int i; u8 id; @@ -725,8 +727,17 @@ static int max14577_muic_probe(struct platform_device *pdev) info->path_uart = CTRL1_SW_UART; delay_jiffies = msecs_to_jiffies(DELAY_MS_DEFAULT); - /* Set initial path for UART */ - max14577_muic_set_path(info, info->path_uart, true); + /* Set initial path for UART when JIG is connected to get serial logs */ + ret = max14577_bulk_read(info->max14577->regmap, + MAX14577_MUIC_REG_STATUS1, info->status, 2); + if (ret) { + dev_err(info->dev, "Cannot read STATUS registers\n"); + return ret; + } + cable_type = max14577_muic_get_cable_type(info, MAX14577_CABLE_GROUP_ADC, + &attached); + if (attached && cable_type == MAX14577_MUIC_ADC_FACTORY_MODE_UART_OFF) + max14577_muic_set_path(info, info->path_uart, true); /* Check revision number of MUIC device*/ ret = max14577_read_reg(info->max14577->regmap, From patchwork Thu Nov 8 13:45:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 10674229 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 52A1614BD for ; Thu, 8 Nov 2018 13:46:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 410692D9BE for ; Thu, 8 Nov 2018 13:46:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3505C2DA8C; Thu, 8 Nov 2018 13:46:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C48222D9BE for ; Thu, 8 Nov 2018 13:46:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727047AbeKHXVc (ORCPT ); Thu, 8 Nov 2018 18:21:32 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:54478 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727042AbeKHXVb (ORCPT ); Thu, 8 Nov 2018 18:21:31 -0500 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20181108134556euoutp028d97dae99fa13e9c8e861907da0a8765~lKh4aMS2h2165821658euoutp02H; Thu, 8 Nov 2018 13:45:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20181108134556euoutp028d97dae99fa13e9c8e861907da0a8765~lKh4aMS2h2165821658euoutp02H DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1541684756; bh=SpTUG4XNSxiy49yB/2ovPC56gqyCOSPQBOPdlQJuoeM=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=dVKAD9XmEF3+d3kxShl01HghVsn1twQ6FGoPYol8LeBHjdHnw3xlA8amM8NTVpGVk oO2KIvLQPQjtGLZ1AokDnce/KEcPWkQNtPhArhhy4KRec8ajp7cCQQ8PuWUv2DxZoy 2HgBfJ8lXaI4aBPbYPe+aFZVAf2rAaFY8NBG05Ng= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20181108134555eucas1p21c794ef065f61e18ad16fdba54a9d58b~lKh4CydKR1373213732eucas1p2-; Thu, 8 Nov 2018 13:45:55 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id FC.7A.04806.31E34EB5; Thu, 8 Nov 2018 13:45:55 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20181108134555eucas1p10f126bdad7538c224d97be4f7e31e4bb~lKh3ibjE21719217192eucas1p1B; Thu, 8 Nov 2018 13:45:55 +0000 (GMT) X-AuditID: cbfec7f5-34dff700000012c6-b9-5be43e13fa88 Received: from eusync1.samsung.com ( [203.254.199.211]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 2A.F3.04128.31E34EB5; Thu, 8 Nov 2018 13:45:55 +0000 (GMT) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0PHV00GNNNKETS20@eusync1.samsung.com>; Thu, 08 Nov 2018 13:45:55 +0000 (GMT) From: Marek Szyprowski To: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: Marek Szyprowski , MyungJoo Ham , Chanwoo Choi , Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz Subject: [PATCH 4/4] extcon: max8997: Avoid forcing UART path on drive probe Date: Thu, 08 Nov 2018 14:45:48 +0100 Message-id: <20181108134548.31140-5-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-reply-to: <20181108134548.31140-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprHIsWRmVeSWpSXmKPExsWy7djPc7rCdk+iDRZNULPYOGM9q8X1L89Z Lc6f38BucXnXHDaLGef3MVmsPXKX3eJ24wo2B3aPTas62Tz6tqxi9Pi8SS6AOYrLJiU1J7Ms tUjfLoErY8bxhIKZghXvdlo2MG7m62Lk5JAQMJF4/W0rSxcjF4eQwApGidurHkM5nxklrk2c ywpTteXuMqjEMkaJSb/msUE4DUwSBzpms4NUsQkYSnS97WIDsUUEnCVuf/jGAmIzCzxklNhy VQHEFhbwkXjUPZERxGYRUJXomb+ECcTmFbCV6Dm8lRlim7zE6g0HwGxOATuJa+++gC2TEPjK KjF3xjKoIheJPxuPskDYwhKvjm9hh7BlJC5P7maBaGhmlGifMYsdwulhlNg6ZwcbRJW1xOHj F1khzuOTmLRtOtBUDqA4r0RHmxBEiYfEzrsbwC4VEpjIKDFtee0ERskFjAyrGMVTS4tz01OL jfNSy/WKE3OLS/PS9ZLzczcxAmPt9L/jX3cw7vuTdIhRgINRiYdXQvFxtBBrYllxZe4hRgkO ZiUR3k06T6KFeFMSK6tSi/Lji0pzUosPMUpzsCiJ81YzPIgWEkhPLEnNTk0tSC2CyTJxcEo1 MMbp3BFZ+v9ippEXF98VdZbau2FH1qfpFU2vt3TlKd8/b3n0lc+zL2WkTvOImnbo0cU0t6Y0 qSXm6mceronamLRzX/+tD8xT0xd0cuxg+7Jb2tWb4VGE9NKgvPLMPU2xB034z3ysuJK886lD a2eTu/3dve8jS3cVKR2vvhrlueqFhtl89xVVx5VYijMSDbWYi4oTAYImvq2xAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrNJMWRmVeSWpSXmKPExsVy+t/xy7rCdk+iDc7v47HYOGM9q8X1L89Z Lc6f38BucXnXHDaLGef3MVmsPXKX3eJ24wo2B3aPTas62Tz6tqxi9Pi8SS6AOYrLJiU1J7Ms tUjfLoErY8bxhIKZghXvdlo2MG7m62Lk5JAQMJHYcncZSxcjF4eQwBJGibctG9ghnCYmiRuf DrGCVLEJGEp0ve1iA7FFBJwlbn/4BtbBLPCQUeLVliOMIAlhAR+JR90TwWwWAVWJnvlLmEBs XgFbiZ7DW5kh1slLrN5wAMzmFLCTuPbuC9BQDqBtthLLr3JNYORZwMiwilEktbQ4Nz232Eiv ODG3uDQvXS85P3cTIzBIth37uWUHY9e74EOMAhyMSjy8B+QeRwuxJpYVV+YeYpTgYFYS4d2k 8yRaiDclsbIqtSg/vqg0J7X4EKM0B4uSOO95g8ooIYH0xJLU7NTUgtQimCwTB6dUA+OhKbFx Lg+Y/Hq7P79LLptsx7FWlru68t6Xp6de7ytP8Pi2duo2uYTrM7q+G1xgUi7ecS+fPXz91Ssz T51utM7gkzjdaGG0j90xbWfe5N8Xheal16wXt7nHkCnqFDPtl56g3tcLzQUXGren7Lx/9fRs NqGMFWbVer5X/sXbpOev+/uU6UuikY0SS3FGoqEWc1FxIgB4o9G1DgIAAA== X-CMS-MailID: 20181108134555eucas1p10f126bdad7538c224d97be4f7e31e4bb X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20181108134555eucas1p10f126bdad7538c224d97be4f7e31e4bb References: <20181108134548.31140-1-m.szyprowski@samsung.com> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- drivers/extcon/extcon-max8997.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/extcon/extcon-max8997.c b/drivers/extcon/extcon-max8997.c index bdabb2479e0d..632192d027bf 100644 --- a/drivers/extcon/extcon-max8997.c +++ b/drivers/extcon/extcon-max8997.c @@ -632,6 +632,8 @@ static int max8997_muic_probe(struct platform_device *pdev) struct max8997_platform_data *pdata = dev_get_platdata(max8997->dev); struct max8997_muic_info *info; int delay_jiffies; + int cable_type; + bool attached; int ret, i; info = devm_kzalloc(&pdev->dev, sizeof(struct max8997_muic_info), @@ -724,8 +726,17 @@ static int max8997_muic_probe(struct platform_device *pdev) delay_jiffies = msecs_to_jiffies(DELAY_MS_DEFAULT); } - /* Set initial path for UART */ - max8997_muic_set_path(info, info->path_uart, true); + /* Set initial path for UART when JIG is connected to get serial logs */ + ret = max8997_bulk_read(info->muic, MAX8997_MUIC_REG_STATUS1, + 2, info->status); + if (ret) { + dev_err(info->dev, "failed to read MUIC register\n"); + return ret; + } + cable_type = max8997_muic_get_cable_type(info, + MAX8997_CABLE_GROUP_ADC, &attached); + if (attached && cable_type == MAX8997_MUIC_ADC_FACTORY_MODE_UART_OFF) + max8997_muic_set_path(info, info->path_uart, true); /* Set ADC debounce time */ max8997_muic_set_debounce_time(info, ADC_DEBOUNCE_TIME_25MS);