Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1884186imj; Sun, 10 Feb 2019 12:37:56 -0800 (PST) X-Google-Smtp-Source: AHgI3Ibkfh98Md95g7s+tJ2bRMH2o21DDEJ33996rER66UGsMPNsUWXLnKan0UUvTK7jxyF4tus1 X-Received: by 2002:aa7:80c6:: with SMTP id a6mr5996474pfn.40.1549831076610; Sun, 10 Feb 2019 12:37:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549831076; cv=none; d=google.com; s=arc-20160816; b=ViOLOFoHAoOi82tdfALFheYVw1YWcgQZkBGDD7hDmLkSfWs6QEk9hLPiml/VDVKZNH 4qB+kXEXGAzp/xA8v7F8el+LO0AFcMSAuoDdgN1LfZXGrsNtweuZPWK+9Wiy3B+DnDng Pt/GmBOhiZ9vI8DelAiD6uGpu9qqMkphMiGQVh6CHc5UmeBAIbckThChg6uT8oHT2Chn Tkf5O3ssnNR1bXRRbDUx2OOY7+H37oJ4Ir+SG+gdwm87Gipz6QsvfaMRoC5BrI6kRAaF kJgd7a6kHpzLvd/8JZXSVHRkLmAf5hsKrbnY64lKQRj/Y4MX8leAOQDINiqnmb4WyaN/ sPQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xsc7sT2oAgde6LqGy3t3st5opYIOWy/LQC1wcatRq98=; b=HLCTNSzmh02gLUR+t46JWPXea7i7aiGLmilLR9fi80fE8g1iTSIOtnokNMEGz5Q2iU QkOZUioNbpQCptH1i4Af1DnPYAnjUw/2Q+v8nSw7+Xu6sxa9vJSY+7130S6Hw6/VHpwO tJ1c8MS+jBe14XGEdX7QfTD0a6ilePMwuLabvev1DKzQM8WQMMyXvtU7oBJAM5BDBg0C aATAYngVHVgW5eXfXk23bLUNiLWCuhq28iBjbI+nUX9xs/t0zm5+3fR5esyRfeMESH9K SBamgjaNC2kgpA4q2uxEFClQ7WK754OXC9JK+rvfHu6FhDaNL/XWiQWcy5bk9Yiu+2U6 e+bQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iBXDcRrr; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g10si8317009plq.371.2019.02.10.12.37.40; Sun, 10 Feb 2019 12:37:56 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iBXDcRrr; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726847AbfBJUhI (ORCPT + 99 others); Sun, 10 Feb 2019 15:37:08 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:38682 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726663AbfBJUhF (ORCPT ); Sun, 10 Feb 2019 15:37:05 -0500 Received: by mail-wm1-f67.google.com with SMTP id v26so13061783wmh.3 for ; Sun, 10 Feb 2019 12:37:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xsc7sT2oAgde6LqGy3t3st5opYIOWy/LQC1wcatRq98=; b=iBXDcRrrV4DVZQNAyYwit+dC1A5uce18FzvmMmFeD3K/RGRp/oHheleOi7uAPoj0/K XO7/4pMeRep6bUk55BofC+P7GmIWEZtJQLsI5FzeWa09qi8kKKkAUbObv2zW6qMjBGk3 e3izTKA6zwCahDAmmEgGP6k1CdYWwsxqc+x4ubluO6dku/NB02pq1aeCZqjR6wS8sDTE HDdU9MUERiXTx/Yrl+1NcbytauJAB7ssDD8pt6VX8OGwDV77YF+6E1JhSZudh8hMI4oD XscNJBt+/AIF3nt/5WdOd+flIe2UO0ddZ8ktAOYdgtTEB6Pgs8d1RMczokU4DQwuGDev VhnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xsc7sT2oAgde6LqGy3t3st5opYIOWy/LQC1wcatRq98=; b=GwxENcH5hPJIgH+N+yGBF+/ps/1n2gMUzkKlZLJIlNb7UP56tYBv7pikUDWXhwVXqw XzLI442PvHoAPUMhTUUlQv/+6zF1H+zisYgIxd6/Dq9Sadytif6F+9jqqJxIIT3xtN1h VyzkQd89wcH+8GeL42slKZDjsdH+81JZJy2HhMGIcp4yMb2zppwlDRowmjD4tzYwaNaJ uDatp/dH57vzVUUIqNyNOMpSiLvtRZVXwmMf1qLCz2HUcfDRnWjmvZAC3rxZarJK3Sp2 d1m9bPHTTDGzcO62bklAUlcWqwfA2oOT8Y9vdKsBKGqTpcjPvtjufHp7zeKfux8MwrvP p2Pg== X-Gm-Message-State: AHQUAubzYcPdLp0qHi2L8oHCP1i9kDPFlA431UjBAoyUmxmXgBAd+i9h 1U4/A0n5xdI4ApERdkm6H3I21UGx X-Received: by 2002:adf:c54d:: with SMTP id s13mr1456871wrf.169.1549831023456; Sun, 10 Feb 2019 12:37:03 -0800 (PST) Received: from localhost.localdomain ([46.216.193.115]) by smtp.gmail.com with ESMTPSA id i10sm6148654wrx.54.2019.02.10.12.37.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 10 Feb 2019 12:37:02 -0800 (PST) Received: from jek by localhost.localdomain with local (Exim 4.92-RC4) (envelope-from ) id 1gsvqS-0005el-8y; Sun, 10 Feb 2019 23:36:56 +0300 From: Yauhen Kharuzhy To: linux-kernel@vger.kernel.org Cc: MyungJoo Ham , Andy Shevchenko , Hans de Goede , Yauhen Kharuzhy Subject: [PATCH 2/2] extcon intel-cht-wc: Enable external charger Date: Sun, 10 Feb 2019 23:36:49 +0300 Message-Id: <20190210203649.21691-3-jekhor@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190210203649.21691-1-jekhor@gmail.com> References: <20190210203649.21691-1-jekhor@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In some configuration external charge "#charge enable" signal is connected to PMIC. Enable it at device probing to allow charging. Tested at Lenovo Yoga Book (YB1-X91L). Signed-off-by: Yauhen Kharuzhy --- drivers/extcon/extcon-intel-cht-wc.c | 33 ++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/drivers/extcon/extcon-intel-cht-wc.c b/drivers/extcon/extcon-intel-cht-wc.c index 4f6ba249bc30..00cb3084955e 100644 --- a/drivers/extcon/extcon-intel-cht-wc.c +++ b/drivers/extcon/extcon-intel-cht-wc.c @@ -57,6 +57,11 @@ #define CHT_WC_USBSRC_TYPE_OTHER 8 #define CHT_WC_USBSRC_TYPE_DCP_EXTPHY 9 +#define CHT_WC_CHGDISCTRL 0x5e2f +#define CHT_WC_CHGDISCTRL_CCSM_DIS 0x11 +#define CHT_WC_CHGDISCTRL_CCSM_EN 0x00 +#define CHT_WC_CHGDISCTRL_CCSM_MASK 0x51 + #define CHT_WC_PWRSRC_IRQ 0x6e03 #define CHT_WC_PWRSRC_IRQ_MASK 0x6e0f #define CHT_WC_PWRSRC_STS 0x6e1e @@ -230,6 +235,31 @@ static void cht_wc_extcon_set_otgmode(struct cht_wc_extcon_data *ext, "Error writing CHGRCTRL1 OTG mode bit: %d\n", ret); } +static void cht_wc_extcon_enable_charging(struct cht_wc_extcon_data *ext, + bool enable) +{ + unsigned int chgdisctrl; + int ret; + + ret = regmap_read(ext->regmap, CHT_WC_CHGDISCTRL, &chgdisctrl); + if (ret) { + dev_err(ext->dev, "Error reading CHGDISCTRL reg: %d\n", ret); + return; + } + + chgdisctrl &= CHT_WC_CHGDISCTRL_CCSM_MASK; + + if (enable) + chgdisctrl |= CHT_WC_CHGDISCTRL_CCSM_EN; + else + chgdisctrl |= CHT_WC_CHGDISCTRL_CCSM_DIS; + + dev_dbg(ext->dev, "Writing CHGDISCTRL: 0x%02x\n", chgdisctrl); + ret = regmap_write(ext->regmap, CHT_WC_CHGDISCTRL, chgdisctrl); + if (ret) + dev_err(ext->dev, "Error writing CHGDISCTRL: %d\n", ret); +} + /* Small helper to sync EXTCON_CHG_USB_SDP and EXTCON_USB state */ static void cht_wc_extcon_set_state(struct cht_wc_extcon_data *ext, unsigned int cable, bool state) @@ -362,6 +392,9 @@ static int cht_wc_extcon_probe(struct platform_device *pdev) */ cht_wc_extcon_set_5v_boost(ext, false); + /* Allow charging by external battery charger*/ + cht_wc_extcon_enable_charging(ext, true); + /* Enable sw control */ ret = cht_wc_extcon_sw_control(ext, true); if (ret) -- 2.20.1