From patchwork Wed Oct 18 09:56:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 116257 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp5868284qgn; Wed, 18 Oct 2017 02:56:43 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBc7E2OdqsA4VGVamvsxC/4z+yf2sD4ruHXiTMddU3Lq1306ObCYLz0pMTEMruvs8eT/ekG X-Received: by 10.101.73.7 with SMTP id p7mr13603447pgs.106.1508320603592; Wed, 18 Oct 2017 02:56:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508320603; cv=none; d=google.com; s=arc-20160816; b=wHI7OIHwGjC6Q1Lz5GYFxe+yi2mFS3yZ2D20eUOoPWzXPFw4YNQn7TkS+vOAbh0VRd 8N6EEBrHUrqxQZmOlKoVvunobGPlOMctQgBBKX2FBt/DH3XlcSmwpkAOh5FeCvx8K0kp Pg3VHOfdqhvG2lp+J49d0n0Je1LrVCohYVA7lc6IeiaGErJnJadmvo0TNcFN4yHhejTG tVT/bnuTRmZZD3uz3GnG/VJpwyZDc5ezUHUj/3gl1MyjTbBsWN2sPvJ5lX1XlnyWeLFT ZU0PS5qPzKkV6tccH6fjmADIglpG42TE0o2JqyzEPQmv/gfgk7o4INkK9kusFdI/LOzp 7f5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=YIhDoDMORVDAePZoEiSHSilkGssCiEaYI3fBHwLnVSM=; b=YGdNO9xEkL57sUIRe8nOh0ZbFcgvQkrHX7CiSoNJgCeUV4aYKtMfQB2IYVLxUHATiW eyVicxrE8Tz1CWTliXaQwBunlpSgpfg2ixbbWOYR+EB8K2FHv7Icpm/1B1EA60qk3ff+ NO9vzPtlLsIbad0WbP1zFNcIjSBUEsJtcBJhBBwQ/P7yAO6fpdxyJ1NJWxx2CRouMYe/ DXM/cJ367oFwMAHnZOrenVbz10+2SA6wM2M01EbWWmci87A247l4P54ibXiMeHRZC9zl rJzSflIumHYboDPoSdL5IBv0gXlnZnFjUUFaydOvNjJflIAkNvzSvImeJDZaL7uywZ3k hCvg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k73si7179423pfk.428.2017.10.18.02.56.43; Wed, 18 Oct 2017 02:56:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967330AbdJRJ4l (ORCPT + 27 others); Wed, 18 Oct 2017 05:56:41 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:44391 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936400AbdJRJ4e (ORCPT ); Wed, 18 Oct 2017 05:56:34 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20171018095632euoutp01f3b23d5423130e3486afaaf79303b1b0~uoZZRvNSN1277012770euoutp01f; Wed, 18 Oct 2017 09:56:32 +0000 (GMT) Received: from eusmges1.samsung.com (unknown [203.254.199.239]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20171018095631eucas1p205aebe33751f9961754f9ebc968e4deb~uoZYo2WIw2177521775eucas1p2J; Wed, 18 Oct 2017 09:56:31 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1.samsung.com (EUCPMTA) with SMTP id F2.28.12576.F4527E95; Wed, 18 Oct 2017 10:56:31 +0100 (BST) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20171018095630eucas1p263041d2da8d87aef67162fc13a01affb~uoZX9j0On2177021770eucas1p2F; Wed, 18 Oct 2017 09:56:30 +0000 (GMT) X-AuditID: cbfec7ef-f79ee6d000003120-c7-59e7254fb157 Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 40.73.18832.E4527E95; Wed, 18 Oct 2017 10:56:30 +0100 (BST) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OY000HN0JM2IH80@eusync3.samsung.com>; Wed, 18 Oct 2017 10:56:30 +0100 (BST) From: Marek Szyprowski To: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: Marek Szyprowski , MyungJoo Ham , Chanwoo Choi , Lee Jones , Bartlomiej Zolnierkiewicz Subject: [PATCH v2 1/2] extcon: max77843: Add OTG power control to the MUIC driver Date: Wed, 18 Oct 2017 11:56:21 +0200 Message-id: <20171018095622.23738-2-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.14.2 In-reply-to: <20171018095622.23738-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrCIsWRmVeSWpSXmKPExsWy7djP87r+qs8jDTY94LHYOGM9q8X1L89Z Le5/PcpocXnXHDaLGef3MVmsPXKX3eJ24wo2B3aPO9f2sHn0bVnF6PF5k1wAcxSXTUpqTmZZ apG+XQJXxvdny5gLLopWz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ZFjF KJJaWpybnltsqFecmFtcmpeul5yfu4kRGEDbjv3cvIPx0sbgQ4wCHIxKPLwBKs8ihVgTy4or cw8xSnAwK4nwMn8ECvGmJFZWpRblxxeV5qQWH2KU5mBREuft3bM6UkggPbEkNTs1tSC1CCbL xMEp1cCodsTz3/WTH7r3XOZgmp/Qp5W61Ig74WzIHi4O2V9Tt2Z9iwt8nbzxdHLItMa9yf3F O1mWfHrnbPGypkWBfyH71ptCYXVN5WfDr+h5F1r1Ks7et9nzqcImtX2pD27tuTgh87bS7kW8 fqFr1oi1bF9g5LS+9KfaosKH287xqsYvb9DheBakMrlGiaU4I9FQi7moOBEAXA8N+xwCAAA= X-CMS-MailID: 20171018095630eucas1p263041d2da8d87aef67162fc13a01affb X-Msg-Generator: CA X-Sender-IP: 182.198.249.179 X-Local-Sender: =?utf-8?q?Marek_Szyprowski=1BSRPOL-Kernel_=28TP=29=1B?= =?utf-8?b?7IK87ISx7KCE7J6QG1NlbmlvciBTb2Z0d2FyZSBFbmdpbmVlcg==?= X-Global-Sender: =?utf-8?q?Marek_Szyprowski=1BSRPOL-Kernel_=28TP=29=1BSam?= =?utf-8?q?sung_Electronics=1BSenior_Software_Engineer?= X-Sender-Code: =?utf-8?q?C10=1BEHQ=1BC10CD02CD027392?= CMS-TYPE: 201P X-CMS-RootMailID: 20171018095630eucas1p263041d2da8d87aef67162fc13a01affb X-RootMTR: 20171018095630eucas1p263041d2da8d87aef67162fc13a01affb References: <20171018095622.23738-1-m.szyprowski@samsung.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Enabling power on VBUS micro-usb pin is required only when passive OTG cable is connected. Initially OTG VBUS power control was planned to be done in charger driver. However such information is not really available from the extcon notifications, so VBUS power control has to be done directly in MUIC driver, which has all information about the attached accessory. For example SmartDock is externally powered accessory, provides OTG (USB HOST) functionality and use VBUS pin for charging a device battery, so the VBUS charging pump should be disabled in such case. Signed-off-by: Marek Szyprowski Acked-by: Chanwoo Choi --- drivers/extcon/extcon-max77843.c | 16 ++++++++++++++++ include/linux/mfd/max77843-private.h | 3 +++ 2 files changed, 19 insertions(+) -- 2.14.2 diff --git a/drivers/extcon/extcon-max77843.c b/drivers/extcon/extcon-max77843.c index 6e722d552cf1..217c743405f8 100644 --- a/drivers/extcon/extcon-max77843.c +++ b/drivers/extcon/extcon-max77843.c @@ -240,6 +240,21 @@ static int max77843_muic_set_path(struct max77843_muic_info *info, return 0; } +static void max77843_charger_set_otg_vbus(struct max77843_muic_info *info, + bool on) +{ + struct max77693_dev *max77843 = info->max77843; + unsigned int cnfg00; + + if (on) + cnfg00 = MAX77843_CHG_OTG_MASK | MAX77843_CHG_BOOST_MASK; + else + cnfg00 = MAX77843_CHG_ENABLE | MAX77843_CHG_BUCK_MASK; + + regmap_update_bits(max77843->regmap_chg, MAX77843_CHG_REG_CHG_CNFG_00, + MAX77843_CHG_MODE_MASK, cnfg00); +} + static int max77843_muic_get_cable_type(struct max77843_muic_info *info, enum max77843_muic_cable_group group, bool *attached) { @@ -355,6 +370,7 @@ static int max77843_muic_adc_gnd_handler(struct max77843_muic_info *info) return ret; extcon_set_state_sync(info->edev, EXTCON_USB_HOST, attached); + max77843_charger_set_otg_vbus(info, attached); break; case MAX77843_MUIC_GND_MHL_VB: case MAX77843_MUIC_GND_MHL: diff --git a/include/linux/mfd/max77843-private.h b/include/linux/mfd/max77843-private.h index c19303b0ccfd..0223cd5941c8 100644 --- a/include/linux/mfd/max77843-private.h +++ b/include/linux/mfd/max77843-private.h @@ -245,10 +245,13 @@ enum max77843_irq_muic { #define MAX77843_CHG_OVER_CURRENT_BAT (0x06 << 4) /* MAX77843 CHG_CNFG_00 register */ +#define MAX77843_CHG_MODE_MASK 0x0f #define MAX77843_CHG_DISABLE 0x00 #define MAX77843_CHG_ENABLE 0x05 #define MAX77843_CHG_MASK 0x01 +#define MAX77843_CHG_OTG_MASK 0x02 #define MAX77843_CHG_BUCK_MASK 0x04 +#define MAX77843_CHG_BOOST_MASK 0x08 /* MAX77843 CHG_CNFG_01 register */ #define MAX77843_CHG_RESTART_THRESHOLD_100 0x00 From patchwork Wed Oct 18 09:56:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 116258 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp5868412qgn; Wed, 18 Oct 2017 02:56:53 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBns4iMs1T04qxvBh9/KJCK+JVS24VBpFKevt+e3mXgFyGWmdP/xD5NVDJX3rHOfPry7XiX X-Received: by 10.98.32.206 with SMTP id m75mr14650045pfj.231.1508320613510; Wed, 18 Oct 2017 02:56:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508320613; cv=none; d=google.com; s=arc-20160816; b=EOUC/SBftzn954sc5v0Cxcs+bKbFZ4Qroxc/nadITLwNEQBMf+UY9SJB0UnwrdNV1F OOsjTcALbo0BgpS6e9CnUdplp5ZHdz8JuZQEjAaMHkO6RmgWLTkNbkSzYCVROuMw6QCb W+LIuaV6TZh3hDMHoGIhwcS5LLE0dVRGw6DelwOx4w+Mas6TGp1ZVlTM1UsjSEMojjOl HgTSZSke+bV6ThcWsz9NRz3c1vgwDLv9UXiS7TUKpIwWiuCV8Grnsh1nNho8ODiKaPNF oi2gRlJXA4Sapl+KkNL8Ngsy+Be0fbPrYDCCziU9/QxoN+VLPEMHxQauSdIiyup1U6pl Rt8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=uBmAslzpZS7E+Ku7sg6SgkK8LzTF6DETndUuYCjz22k=; b=o3+W/UJS40TQ7P4vZPFvbBm2khvOft0/PCEKt6W+zLkZNdFsBJ8CNRIipFLPjerhOl /0loaOdupvg+wKephgPW7Lask13kDzdsV+pWP/Cg5bLrD97gf1/OZ+8cXm1bgRjEQ6zH yNNRSlbyU5axL8egydieG2tCqQVwiapmOF44KMIWnwWAzEfl+HQDMXYccFpLMB553hYm KrecOdC4pDDgjqk85/XvIFUk1tG4miz3IQbGCpwhgBtnmE5rlv33NaaOnhpuHnBqO7Me WRsbEsOPjAq7l+Ef4mVYA6D7W57mJgZ951x5mSDvxkKIdWQZ4SHzT/xKG7YATkF5FYCD Fdqw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k73si7179423pfk.428.2017.10.18.02.56.53; Wed, 18 Oct 2017 02:56:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965212AbdJRJ4j (ORCPT + 27 others); Wed, 18 Oct 2017 05:56:39 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:44392 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936526AbdJRJ4e (ORCPT ); Wed, 18 Oct 2017 05:56:34 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20171018095632euoutp015da96fdd42dae3f8c45b3e803edb8dde~uoZZrSH8s1302513025euoutp01h; Wed, 18 Oct 2017 09:56:32 +0000 (GMT) Received: from eusmges5.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20171018095631eucas1p1b6d9ef987d3f0144d449cc5b939ecb53~uoZY86XRN2904229042eucas1p1D; Wed, 18 Oct 2017 09:56:31 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges5.samsung.com (EUCPMTA) with SMTP id BC.E9.12743.F4527E95; Wed, 18 Oct 2017 10:56:31 +0100 (BST) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20171018095631eucas1p1238fdd6c4180f5c753fa20c4aac7b821~uoZYUgvnE2112721127eucas1p12; Wed, 18 Oct 2017 09:56:31 +0000 (GMT) X-AuditID: cbfec7f5-f79d06d0000031c7-89-59e7254f5cfa Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id B8.A6.20118.F4527E95; Wed, 18 Oct 2017 10:56:31 +0100 (BST) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OY000HN0JM2IH80@eusync3.samsung.com>; Wed, 18 Oct 2017 10:56:31 +0100 (BST) From: Marek Szyprowski To: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: Marek Szyprowski , MyungJoo Ham , Chanwoo Choi , Lee Jones , Bartlomiej Zolnierkiewicz Subject: [PATCH v2 2/2] extcon: max77843: Add support for SmartDock accessory Date: Wed, 18 Oct 2017 11:56:22 +0200 Message-id: <20171018095622.23738-3-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.14.2 In-reply-to: <20171018095622.23738-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrCIsWRmVeSWpSXmKPExsWy7djPc7r+qs8jDSa9UbbYOGM9q8X1L89Z Le5/PcpocX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tjF2MHBzCAr4Sv3qC QWpYBFQlVnx5AbaAV8BWYt+cp8wQy+Ql3i+4zwhicwrYSXw/cwFqsa3EguvHWScw8i5gZFjF KJJaWpybnltspFecmFtcmpeul5yfu4kRGD7bjv3csoOx613wIUYBDkYlHt4AlWeRQqyJZcWV uYcYJTiYlUR4mT8ChXhTEiurUovy44tKc1KLDzFKc7AoifP27lkdKSSQnliSmp2aWpBaBJNl 4uCUamAUvKymGqet4qouF7+57vcrDs3/rGbrJzlvWtq2z/ZuF4NDnNyLNI0pClOiDpif5y6I Oy4Zq3uY6+2aqeZSHOudTnoa7JSLVIxezWirFde8PdnP49jeiuRLuR9XXzmwY+PDp8U7V6Wy iT2KyyplLXT4H1Cn+f/ftwrh0MK63k9PX91ybdpy5JUSS3FGoqEWc1FxIgA9KcUyGwIAAA== X-CMS-MailID: 20171018095631eucas1p1238fdd6c4180f5c753fa20c4aac7b821 X-Msg-Generator: CA X-Sender-IP: 182.198.249.180 X-Local-Sender: =?utf-8?q?Marek_Szyprowski=1BSRPOL-Kernel_=28TP=29=1B?= =?utf-8?b?7IK87ISx7KCE7J6QG1NlbmlvciBTb2Z0d2FyZSBFbmdpbmVlcg==?= X-Global-Sender: =?utf-8?q?Marek_Szyprowski=1BSRPOL-Kernel_=28TP=29=1BSam?= =?utf-8?q?sung_Electronics=1BSenior_Software_Engineer?= X-Sender-Code: =?utf-8?q?C10=1BEHQ=1BC10CD02CD027392?= CMS-TYPE: 201P X-CMS-RootMailID: 20171018095631eucas1p1238fdd6c4180f5c753fa20c4aac7b821 X-RootMTR: 20171018095631eucas1p1238fdd6c4180f5c753fa20c4aac7b821 References: <20171018095622.23738-1-m.szyprowski@samsung.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org SmartDock uses ADC_RESERVED_ACC_3 (0x10) ADC ID type and provides following features: 1. USB host with embedded USB hub (2-4 ports) for mice, keyboard, etc, 2. MHL for video output, 3. charging. Tested with Unitek Y-2165 MHL+OTG Hub Smart Phone Dock. Signed-off-by: Marek Szyprowski Acked-by: Chanwoo Choi --- drivers/extcon/extcon-max77843.c | 77 +++++++++++++++++++++++++++++------- include/linux/mfd/max77843-private.h | 2 + 2 files changed, 65 insertions(+), 14 deletions(-) -- 2.14.2 diff --git a/drivers/extcon/extcon-max77843.c b/drivers/extcon/extcon-max77843.c index 217c743405f8..cc28d2622ae7 100644 --- a/drivers/extcon/extcon-max77843.c +++ b/drivers/extcon/extcon-max77843.c @@ -80,7 +80,7 @@ enum max77843_muic_accessory_type { MAX77843_MUIC_ADC_REMOTE_S12_BUTTON, MAX77843_MUIC_ADC_RESERVED_ACC_1, MAX77843_MUIC_ADC_RESERVED_ACC_2, - MAX77843_MUIC_ADC_RESERVED_ACC_3, + MAX77843_MUIC_ADC_RESERVED_ACC_3, /* SmartDock */ MAX77843_MUIC_ADC_RESERVED_ACC_4, MAX77843_MUIC_ADC_RESERVED_ACC_5, MAX77843_MUIC_ADC_AUDIO_DEVICE_TYPE2, @@ -119,6 +119,7 @@ enum max77843_muic_charger_type { MAX77843_MUIC_CHG_SPECIAL_BIAS, MAX77843_MUIC_CHG_RESERVED, MAX77843_MUIC_CHG_GND, + MAX77843_MUIC_CHG_DOCK, }; static const unsigned int max77843_extcon_cable[] = { @@ -130,6 +131,7 @@ static const unsigned int max77843_extcon_cable[] = { EXTCON_CHG_USB_FAST, EXTCON_CHG_USB_SLOW, EXTCON_DISP_MHL, + EXTCON_DOCK, EXTCON_JIG, EXTCON_NONE, }; @@ -200,7 +202,7 @@ static const struct regmap_irq_chip max77843_muic_irq_chip = { }; static int max77843_muic_set_path(struct max77843_muic_info *info, - u8 val, bool attached) + u8 val, bool attached, bool nobccomp) { struct max77693_dev *max77843 = info->max77843; int ret = 0; @@ -210,10 +212,16 @@ static int max77843_muic_set_path(struct max77843_muic_info *info, ctrl1 = val; else ctrl1 = MAX77843_MUIC_CONTROL1_SW_OPEN; + if (nobccomp) { + /* Disable BC1.2 protocol and force manual switch control */ + ctrl1 |= MAX77843_MUIC_CONTROL1_NOBCCOMP_MASK; + } ret = regmap_update_bits(max77843->regmap_muic, MAX77843_MUIC_REG_CONTROL1, - MAX77843_MUIC_CONTROL1_COM_SW, ctrl1); + MAX77843_MUIC_CONTROL1_COM_SW | + MAX77843_MUIC_CONTROL1_NOBCCOMP_MASK, + ctrl1); if (ret < 0) { dev_err(info->dev, "Cannot switch MUIC port\n"); return ret; @@ -303,6 +311,19 @@ static int max77843_muic_get_cable_type(struct max77843_muic_info *info, break; } + if (adc == MAX77843_MUIC_ADC_RESERVED_ACC_3) { /* SmartDock */ + if (chg_type == MAX77843_MUIC_CHG_NONE) { + *attached = false; + cable_type = info->prev_chg_type; + info->prev_chg_type = MAX77843_MUIC_CHG_NONE; + } else { + *attached = true; + cable_type = MAX77843_MUIC_CHG_DOCK; + info->prev_chg_type = MAX77843_MUIC_CHG_DOCK; + } + break; + } + if (chg_type == MAX77843_MUIC_CHG_NONE) { *attached = false; cable_type = info->prev_chg_type; @@ -365,7 +386,7 @@ static int max77843_muic_adc_gnd_handler(struct max77843_muic_info *info) case MAX77843_MUIC_GND_USB_HOST_VB: ret = max77843_muic_set_path(info, MAX77843_MUIC_CONTROL1_SW_USB, - attached); + attached, false); if (ret < 0) return ret; @@ -376,7 +397,7 @@ static int max77843_muic_adc_gnd_handler(struct max77843_muic_info *info) case MAX77843_MUIC_GND_MHL: ret = max77843_muic_set_path(info, MAX77843_MUIC_CONTROL1_SW_OPEN, - attached); + attached, false); if (ret < 0) return ret; @@ -412,7 +433,7 @@ static int max77843_muic_jig_handler(struct max77843_muic_info *info, return -EINVAL; } - ret = max77843_muic_set_path(info, path, attached); + ret = max77843_muic_set_path(info, path, attached, false); if (ret < 0) return ret; @@ -421,6 +442,26 @@ static int max77843_muic_jig_handler(struct max77843_muic_info *info, return 0; } +static int max77843_muic_dock_handler(struct max77843_muic_info *info, + bool attached) +{ + int ret; + + dev_dbg(info->dev, "external connector is %s (adc: 0x10)\n", + attached ? "attached" : "detached"); + + ret = max77843_muic_set_path(info, MAX77843_MUIC_CONTROL1_SW_USB, + attached, attached); + if (ret < 0) + return ret; + + extcon_set_state_sync(info->edev, EXTCON_DISP_MHL, attached); + extcon_set_state_sync(info->edev, EXTCON_USB_HOST, attached); + extcon_set_state_sync(info->edev, EXTCON_DOCK, attached); + + return 0; +} + static int max77843_muic_adc_handler(struct max77843_muic_info *info) { int ret, cable_type; @@ -435,6 +476,11 @@ static int max77843_muic_adc_handler(struct max77843_muic_info *info) info->prev_cable_type); switch (cable_type) { + case MAX77843_MUIC_ADC_RESERVED_ACC_3: /* SmartDock */ + ret = max77843_muic_dock_handler(info, attached); + if (ret < 0) + return ret; + break; case MAX77843_MUIC_ADC_GROUND: ret = max77843_muic_adc_gnd_handler(info); if (ret < 0) @@ -462,7 +508,6 @@ static int max77843_muic_adc_handler(struct max77843_muic_info *info) case MAX77843_MUIC_ADC_REMOTE_S12_BUTTON: case MAX77843_MUIC_ADC_RESERVED_ACC_1: case MAX77843_MUIC_ADC_RESERVED_ACC_2: - case MAX77843_MUIC_ADC_RESERVED_ACC_3: case MAX77843_MUIC_ADC_RESERVED_ACC_4: case MAX77843_MUIC_ADC_RESERVED_ACC_5: case MAX77843_MUIC_ADC_AUDIO_DEVICE_TYPE2: @@ -506,7 +551,7 @@ static int max77843_muic_chg_handler(struct max77843_muic_info *info) case MAX77843_MUIC_CHG_USB: ret = max77843_muic_set_path(info, MAX77843_MUIC_CONTROL1_SW_USB, - attached); + attached, false); if (ret < 0) return ret; @@ -517,7 +562,7 @@ static int max77843_muic_chg_handler(struct max77843_muic_info *info) case MAX77843_MUIC_CHG_DOWNSTREAM: ret = max77843_muic_set_path(info, MAX77843_MUIC_CONTROL1_SW_OPEN, - attached); + attached, false); if (ret < 0) return ret; @@ -527,7 +572,7 @@ static int max77843_muic_chg_handler(struct max77843_muic_info *info) case MAX77843_MUIC_CHG_DEDICATED: ret = max77843_muic_set_path(info, MAX77843_MUIC_CONTROL1_SW_OPEN, - attached); + attached, false); if (ret < 0) return ret; @@ -537,7 +582,7 @@ static int max77843_muic_chg_handler(struct max77843_muic_info *info) case MAX77843_MUIC_CHG_SPECIAL_500MA: ret = max77843_muic_set_path(info, MAX77843_MUIC_CONTROL1_SW_OPEN, - attached); + attached, false); if (ret < 0) return ret; @@ -547,7 +592,7 @@ static int max77843_muic_chg_handler(struct max77843_muic_info *info) case MAX77843_MUIC_CHG_SPECIAL_1A: ret = max77843_muic_set_path(info, MAX77843_MUIC_CONTROL1_SW_OPEN, - attached); + attached, false); if (ret < 0) return ret; @@ -566,6 +611,9 @@ static int max77843_muic_chg_handler(struct max77843_muic_info *info) extcon_set_state_sync(info->edev, EXTCON_CHG_USB_DCP, false); break; + case MAX77843_MUIC_CHG_DOCK: + extcon_set_state_sync(info->edev, EXTCON_CHG_USB_DCP, attached); + break; case MAX77843_MUIC_CHG_NONE: break; default: @@ -574,7 +622,7 @@ static int max77843_muic_chg_handler(struct max77843_muic_info *info) attached ? "attached" : "detached", chg_type); max77843_muic_set_path(info, MAX77843_MUIC_CONTROL1_SW_OPEN, - attached); + attached, false); return -EINVAL; } @@ -814,7 +862,8 @@ static int max77843_muic_probe(struct platform_device *pdev) 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); + 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); diff --git a/include/linux/mfd/max77843-private.h b/include/linux/mfd/max77843-private.h index 0223cd5941c8..b8908bf8d315 100644 --- a/include/linux/mfd/max77843-private.h +++ b/include/linux/mfd/max77843-private.h @@ -350,6 +350,7 @@ enum max77843_irq_muic { /* MAX77843 CONTROL register */ #define MAX77843_MUIC_CONTROL1_COMP1SW_SHIFT 0 #define MAX77843_MUIC_CONTROL1_COMP2SW_SHIFT 3 +#define MAX77843_MUIC_CONTROL1_NOBCCOMP_SHIFT 6 #define MAX77843_MUIC_CONTROL1_IDBEN_SHIFT 7 #define MAX77843_MUIC_CONTROL2_LOWPWR_SHIFT 0 #define MAX77843_MUIC_CONTROL2_ADCEN_SHIFT 1 @@ -366,6 +367,7 @@ enum max77843_irq_muic { #define MAX77843_MUIC_CONTROL1_COMP1SW_MASK (0x7 << MAX77843_MUIC_CONTROL1_COMP1SW_SHIFT) #define MAX77843_MUIC_CONTROL1_COMP2SW_MASK (0x7 << MAX77843_MUIC_CONTROL1_COMP2SW_SHIFT) #define MAX77843_MUIC_CONTROL1_IDBEN_MASK BIT(MAX77843_MUIC_CONTROL1_IDBEN_SHIFT) +#define MAX77843_MUIC_CONTROL1_NOBCCOMP_MASK BIT(MAX77843_MUIC_CONTROL1_NOBCCOMP_SHIFT) #define MAX77843_MUIC_CONTROL2_LOWPWR_MASK BIT(MAX77843_MUIC_CONTROL2_LOWPWR_SHIFT) #define MAX77843_MUIC_CONTROL2_ADCEN_MASK BIT(MAX77843_MUIC_CONTROL2_ADCEN_SHIFT) #define MAX77843_MUIC_CONTROL2_CPEN_MASK BIT(MAX77843_MUIC_CONTROL2_CPEN_SHIFT)