Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp361163pxb; Fri, 3 Sep 2021 03:58:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwdCi3AL6qrTEz80oCh9ZKzbkggr8lbGaDAzrqI9t7Am8+lxWMu17HJWzAQcUbIKgDfx1k X-Received: by 2002:aa7:c945:: with SMTP id h5mr3330623edt.350.1630666721653; Fri, 03 Sep 2021 03:58:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630666721; cv=none; d=google.com; s=arc-20160816; b=ESbftA8KTAmTBxJLPP8YDwiX2U1SVjIl7HtaWKZddvS9bPmhnOk8AL1krpSa3CAGIk InofsO+V1aD/FHAHsuTIe/nLDnWT8IFW6MVV4ztIO1kqQTl9YZzAdAFZWyvW0VoyBJGu gr6zkx3/ZFA/CoPYbdZ9Pw3t2aDfTtsoW58xak44QAGoun+wVxDCQutIFYb2x4yte4hx UongIT/qV5TmeBP90jpU7E/Zyr2Sa2+Z6+RfuIV21zzJfsUtwq87mFpDt10mMGpcLWtx t3KcoimLwikUbRUX4dVV1GSFupF9sHNyWp5k3AszKALb80Iyoci9Mua9QSNpMj1iur7K Cfyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=JVIv4+eci6v8DpfGSWmvYEaT+vfz2Ch23tN7eDuUq7A=; b=UVkJFyfrxvj4lqJZfdnLpgV5yQdFhtxKf41RSLbgAxCEty8VFUgu13Mu/tSpAmtguB fDyq046hgmN2JFEZ3uNutG9TxRh2S6r+lfaiqhXsXQDS7s5DFvE1isBCf4lgb05e5D5n TTf3gFGbUX3AAvVZODoloTz9ge4h3MsDIsuEFF91TPmeLTSHj6kIQTzcvkBsnFyYvvQz 3+JxQYpnb/dYUcC+z5aJXin0ekJ4/43SrX1EmZkqv5lGRmaFqfp87I8b3OhpgaQs8ejK kkLvxmY6GoHsaJ8yQ5w/bXBjVDydgPsWMgkwKolMNxX66ke1GGH8eH/XcTZoYWYLMNM7 CNkw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id dp11si5025820ejc.397.2021.09.03.03.58.18; Fri, 03 Sep 2021 03:58:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1348680AbhICJVX (ORCPT + 99 others); Fri, 3 Sep 2021 05:21:23 -0400 Received: from mga07.intel.com ([134.134.136.100]:3320 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234912AbhICJVW (ORCPT ); Fri, 3 Sep 2021 05:21:22 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10095"; a="283079580" X-IronPort-AV: E=Sophos;i="5.85,264,1624345200"; d="scan'208";a="283079580" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Sep 2021 02:20:23 -0700 X-IronPort-AV: E=Sophos;i="5.85,264,1624345200"; d="scan'208";a="467868530" Received: from pstarove-mobl4.ger.corp.intel.com (HELO [10.251.212.94]) ([10.251.212.94]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Sep 2021 02:20:20 -0700 Subject: Re: [PATCH v3 1/2] ASoC: max98927: Handle reset gpio when probing i2c To: Alejandro , Liam Girdwood , Mark Brown , Andy Shevchenko Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Takashi Iwai , Rob Herring References: <04a18f4115539752429da55fb857834cea0944e5.1630632805.git.atafalla@dnyon.com> From: =?UTF-8?Q?P=c3=a9ter_Ujfalusi?= Message-ID: <80973391-4579-e14b-6def-ed81f367a4a5@linux.intel.com> Date: Fri, 3 Sep 2021 12:20:37 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <04a18f4115539752429da55fb857834cea0944e5.1630632805.git.atafalla@dnyon.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/09/2021 04:49, Alejandro wrote: > From: Alejandro Tafalla > > Drive the reset gpio if defined in the DTS node. > > Signed-off-by: Alejandro Tafalla > --- > sound/soc/codecs/max98927.c | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/sound/soc/codecs/max98927.c b/sound/soc/codecs/max98927.c > index 8b206ee77709..daf06b503433 100644 > --- a/sound/soc/codecs/max98927.c > +++ b/sound/soc/codecs/max98927.c > @@ -868,6 +868,7 @@ static int max98927_i2c_probe(struct i2c_client *i2c, > int ret = 0, value; > int reg = 0; > struct max98927_priv *max98927 = NULL; > + struct gpio_desc *reset_gpio; > > max98927 = devm_kzalloc(&i2c->dev, > sizeof(*max98927), GFP_KERNEL); > @@ -898,6 +899,19 @@ static int max98927_i2c_probe(struct i2c_client *i2c, > return ret; > } > > + reset_gpio > + = devm_gpiod_get_optional(&i2c->dev, "reset", GPIOD_OUT_LOW); If this is a 'reset' pin then it's ACTIVE state is when it places the device to _reset_. GPIOD_OUT_LOW == Deasserted state of the GPIO line. If the reset pin should be pulled low for reset (GPIO_ACTIVE_LOW) and you want the device initially in reset then you need GPIOD_OUT_HIGH, because: GPIOD_OUT_HIGH == Asserted state of the GPIO line. Same goes for the gpiod_set_value_cansleep(): 0 - deasserted 1 = asserted and this all depends on how the gpio is defined in DT (GPIO_ACTIVE_LOW/HIGH), which depends on how the documentation refers to the pin... reset pin: low to keep the device in reset, high to release it from reset: GPIO_ACTIVE_LOW gpiod_set_value_cansleep(0) to enable gpiod_set_value_cansleep(1) to disable enable pin: high to enable the part, low to disable GPIO_ACTIVE_HIGH gpiod_set_value_cansleep(1) to enable gpiod_set_value_cansleep(0) to disable In both cases electrical 0: reset/disable electrical 1: enable > + if (IS_ERR(reset_gpio)) { > + ret = PTR_ERR(reset_gpio); > + return dev_err_probe(&i2c->dev, ret, "failed to request GPIO reset pin"); > + } > + > + if (reset_gpio) { > + usleep_range(8000, 10000); > + gpiod_set_value_cansleep(reset_gpio, 1); > + usleep_range(1000, 5000); > + } > + You might want to put the device to reset on remove at minimum. > /* Check Revision ID */ > ret = regmap_read(max98927->regmap, > MAX98927_R01FF_REV_ID, ®); > -- Péter