Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp557942imp; Wed, 20 Feb 2019 05:09:36 -0800 (PST) X-Google-Smtp-Source: AHgI3IYoWLFd/So5/z37/VxeTd019SQrhT670Zs1EQeWoCtz/oc3mmY+xYCLcqf6iolJ0vLGW9QG X-Received: by 2002:a17:902:6b8c:: with SMTP id p12mr2894992plk.282.1550668176037; Wed, 20 Feb 2019 05:09:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550668176; cv=none; d=google.com; s=arc-20160816; b=VCHoYzOmgXCIAjbRokB05UDFclaUF9aGc2bDBZNj8v93H3dKM7/GcdcFhB2pB7uYcx 0o4r4TVW/MMEgnGJCVsDeAi9lP3TbM/PF+ryz6aagtz/pcoq4dAhzJdHgv7D3pJOqD1N SYjh6vKc7BRncIV70SHugz7bRTtk6NOHb9btYrAH0Iuh1SggQLBCHHQjzZ1zvudUNsZu gFHsxA4qBt12YOFBTWOkcGJDEdSmUznixtlr/pTtdlbx7vQSJXoBJqOAhDrvQV+dMQHF LNQUuGSR1d0yJsKP2OyWSTpAeUVuiBJR/pVhd2dGr10DbUn0ohv4fr/lue0A5qYjxmxZ 39Jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=hDdi0hSubE8GZ0HZ3beUsLcnJ4Do1/C5gOxyarCaOG0=; b=HINBADwkezd4gbs4SJregvax7NsV89/KHl1Th9f/E0ytzelHJKYh8LhZnXRBJKh0oF N/isG7iIK5JnwodICofQIfGiXAnlaN0ESRwSTuybA4D/XgdNn96Km9NKZT+x3HmOwB6g lJlDlyZXprtdxPMSTS6ovN+8M/eLfRPw5Zf/dzo14TDVxOHqlT+CLpRL0Ef6w7XGE+qt 9v7Uhg9TXpFMaos6Fx81YjqOxocViQ5t3OBZOvxaiasnG4wmzTdLG0gfvkT/rzD4uh07 WVD/xX1WLeiPQbJ90uNUTGtRJN8Nzzewa787U49eV1ODC9VqxW6ognDgGZUl0m4nmejH Q1FA== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1si9023223pgu.300.2019.02.20.05.09.19; Wed, 20 Feb 2019 05:09:36 -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; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727828AbfBTNI5 (ORCPT + 99 others); Wed, 20 Feb 2019 08:08:57 -0500 Received: from mga02.intel.com ([134.134.136.20]:50328 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726455AbfBTNI5 (ORCPT ); Wed, 20 Feb 2019 08:08:57 -0500 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Feb 2019 05:08:56 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,391,1544515200"; d="scan'208";a="135749175" Received: from smile.fi.intel.com (HELO smile) ([10.237.72.86]) by orsmga002.jf.intel.com with ESMTP; 20 Feb 2019 05:08:54 -0800 Received: from andy by smile with local (Exim 4.92-RC6) (envelope-from ) id 1gwRcL-0003t2-TX; Wed, 20 Feb 2019 15:08:53 +0200 Date: Wed, 20 Feb 2019 15:08:53 +0200 From: Andy Shevchenko To: Yauhen Kharuzhy Cc: linux-kernel@vger.kernel.org, MyungJoo Ham , Chanwoo Choi , Hans de Goede Subject: Re: [PATCH v2 2/2] extcon intel-cht-wc: Enable external charger Message-ID: <20190220130853.GQ9224@smile.fi.intel.com> References: <20190219212441.19391-1-jekhor@gmail.com> <20190219212441.19391-3-jekhor@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190219212441.19391-3-jekhor@gmail.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 20, 2019 at 12:24:41AM +0300, Yauhen Kharuzhy wrote: > In some configuration external charger "#charge enable" signal is > connected to PMIC. Enable it at device probing to allow charging. > > Save CHGRCTRL0 and CHGDISCTR registers at driver probing and restore > them at driver unbind to re-enable hardware charging control if it was > enabled before. > > Tested at Lenovo Yoga Book (YB1-X91L). My comments below. After addressing them, Reviewed-by: Andy Shevchenko > +#define CHT_WC_CHGDISCTRL_OUTPUT BIT(0) Simple _OUT as per documentation. > +/* 0 - open drain, 1 - regular output */ Regular means push-pull. > +#define CHT_WC_CHGDISCTRL_DRV_OD_DIS BIT(4) _DRV as per documentation. > +#define CHT_WC_CHGDISCTRL_MODE_HW BIT(6) _FN as per documentation. > +static void cht_wc_extcon_enable_charging(struct cht_wc_extcon_data *ext, > + bool enable) > +{ > + unsigned int val; > + int ret; > + > + val = enable ? 0 : CHT_WC_CHGDISCTRL_OUTPUT; Can be assigned in definition block. > + ret = regmap_update_bits(ext->regmap, CHT_WC_CHGDISCTRL, > + CHT_WC_CHGDISCTRL_OUTPUT, val); > + if (ret) > + dev_err(ext->dev, "Error updating CHGDISCTRL reg: %d\n", ret); > +} > + val = enable ? 0 : CHT_WC_CHGDISCTRL_MODE_HW; > + ret = regmap_update_bits(ext->regmap, CHT_WC_CHGDISCTRL, > + CHT_WC_CHGDISCTRL_MODE_HW, val); Indentation. > + if (ret) > + dev_err(ext->dev, > + "Error setting sw control for charger enable: %d\n", > + ret); > +static int cht_wc_save_initial_state(struct cht_wc_extcon_data *ext) > +{ > + int ret; > + > + /* > + * Save the external charger control output state for restoring it at > + * driver unbinding You may move "at" to the next line and add a period at the end. > + */ > + ret = regmap_read(ext->regmap, CHT_WC_CHGDISCTRL, > + &ext->chgdisctrl_saved); > + if (ret) { > + dev_err(ext->dev, "Error reading CHGDISCTRL: %d\n", > + ret); > + return ret; > + } > + > + ret = regmap_read(ext->regmap, CHT_WC_CHGRCTRL0, > + &ext->chgrctrl0_saved); > + if (ret) { > + dev_err(ext->dev, "Error reading CHGRCTRL0: %d\n", > + ret); > + return ret; > + } > + > + return 0; > +} -- With Best Regards, Andy Shevchenko