Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2909896ybk; Mon, 18 May 2020 10:54:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyz5zN9KT52pAlrHxK0fjU6wW6ZWds/MHMMI2vL27LydcqnONbAXFGlQ77Gtr+TLc1eAwmG X-Received: by 2002:a17:906:2e4a:: with SMTP id r10mr15618522eji.116.1589824478197; Mon, 18 May 2020 10:54:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589824478; cv=none; d=google.com; s=arc-20160816; b=ZbpbhI8VpEvydCOyoU0fRC8BZvHIoJ+PDZACz2JqYC5GKj4KplLsaObjKO3MwBffbo eTB+bsnWxv/1ke6h5nn4G6KC7Bj2incCHEs+SgqCngFkrD7kOxlZq2SchFE9NgD63kVp ZVTIItzdXUwy45LLRBpKamekTgipBl+wisKWfkJJ4ASa4PWIAXPfOQC8WFrCA4HLhQDm j03yMWI2qsK07fU0s/qdVFjxqTgLLmjrKFmgvrVWGONKQJ4xLs7lrcTJeGQPz4iocBeo kQK+n+fRF11iYBjwF9f8eb71Ev3D5wHrXLS5IzMadTqq9qhAHYjQ9CgvZK3foo6mnF6u 74SA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=tJ3DKY7Zr9PGXQiFNc8d9vTcSjgnnAbCq5O6/G8CCg4=; b=dKvmtc4vn6PjzLuqMUQuQ7P1fVvahTwygxuPZMdk745MTshqFc/ZPbvTX0iGE2HG9m OVDo9BmMAgJF3uYMEGMiOSiXHJAP8vkso31GbRzb/4X+iZGbyw2nRk1gcrk0Oxf6CJs6 diRapNwIbfK0jZOHY8GwTU7O7YziFGZnBU7pPehPScojIsoVR3n/q05oZ8vNM6lqYgGx iWquh9bOr1HO3yvzdCbZlMQO/MpmbysTPh7aLMjR17HWQVNbJYLapOmnP73tfrJ+jgfO oVM002YxMIC71pmVeIEFuF7UNlW0Ac+bqLNUD5ufWL1xXs8JQdCyrJPIeM/7GGn7xBcJ hmDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TE8I8dQ8; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f18si6914585ejf.50.2020.05.18.10.54.14; Mon, 18 May 2020 10:54:38 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TE8I8dQ8; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730709AbgERRvp (ORCPT + 99 others); Mon, 18 May 2020 13:51:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730892AbgERRvn (ORCPT ); Mon, 18 May 2020 13:51:43 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EDCAC061A0C; Mon, 18 May 2020 10:51:43 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id m7so4531902plt.5; Mon, 18 May 2020 10:51:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=tJ3DKY7Zr9PGXQiFNc8d9vTcSjgnnAbCq5O6/G8CCg4=; b=TE8I8dQ8Wqs7x5u+poBX2PYL7VHczF4L9tZyWg6xg3w7P79g+iqBbReWmXghjCoR01 LYy5qDvCnk8MectVa5opXCkC11SatAw583tfW8J6jU1W/RzPyC/AeYqMB5rvfjK90zeP PCy8cphadcqrBHoIzn8l7Pg8DKAan7BYZH2XSGT1V05mEQTEAA8SQgXH8alQwL96qiaC L6Wv++5GBfGLoEey0OvOFDKd6QiDjTs175byY+ygjaFO5Za76iUzblYpAZKZNq3z4Zyx ImH/tR0GZLtvnrlJdaHAdCRbssVr1pIAUX97DeL9UEFZamk+StjYrPMkJYqjBH/ySkld dM0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=tJ3DKY7Zr9PGXQiFNc8d9vTcSjgnnAbCq5O6/G8CCg4=; b=m8MAY0rZl23B+/3P5WqOnzFliQpTA7ahlyWU7r3YcodRhRCgl6WumvVa8AFTF6/Ub0 Pa+HPG2V6XUHOYpJD4ScOhc+T/0dm8ESuRAcKR68JUSMnBcTnEf4PdVPzrtuFtoUraNI yMw+LYgC/4f+hBruXA7gnzzFBe5jk/OfTuSM8pFTVVeFhBzm7MLSOzKBHMlnZzNEpGmE YBgcWyl9hPMhB59k689DDsYlzrHl0FTmsDSMyOKNzLKJ1hv22zk5lTvYKswFHqlnRJ4U hpK39GPjwzCUsMiHGqTb9a0ywkjLX1o11Yni546rfczyX9JlQgr7KUS5Pf5V/DtuVL7l LTow== X-Gm-Message-State: AOAM532s+A3BaXH5uDlKidSyCDXIDE89D8r8kfHpAB/KzN5t5bKvtQGp u0sKHztd0b+NIbspV53WJv7MUwOdWPsonLE8Ozo= X-Received: by 2002:a17:902:930c:: with SMTP id bc12mr17510090plb.255.1589824301578; Mon, 18 May 2020 10:51:41 -0700 (PDT) MIME-Version: 1.0 References: <20200518133645.19127-1-jonathan.albrieux@gmail.com> <20200518133645.19127-4-jonathan.albrieux@gmail.com> <20200518160120.GA21361@ict14-OptiPlex-980> <20200518164317.GL1634618@smile.fi.intel.com> <20200518174335.GA6392@jonathan-N53SV> In-Reply-To: <20200518174335.GA6392@jonathan-N53SV> From: Andy Shevchenko Date: Mon, 18 May 2020 20:51:29 +0300 Message-ID: Subject: Re: [PATCH 3/3] iio: magnetometer: ak8975: Add gpio reset support To: Jonathan Albrieux Cc: Linux Kernel Mailing List , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Greg Kroah-Hartman , Hartmut Knaack , Jonathan Cameron , Lars-Peter Clausen , Linus Walleij , "open list:IIO SUBSYSTEM AND DRIVERS" , Peter Meerwald-Stadler , Steve Winslow , Thomas Gleixner , Jonathan Cameron Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 18, 2020 at 8:43 PM Jonathan Albrieux wrote: > > On Mon, May 18, 2020 at 07:43:17PM +0300, Andy Shevchenko wrote: > > On Mon, May 18, 2020 at 06:01:20PM +0200, Jonathan Albrieux wrote: > > > On Mon, May 18, 2020 at 05:55:51PM +0300, Andy Shevchenko wrote: > > > > On Mon, May 18, 2020 at 4:38 PM Jonathan Albrieux > > > > wrote: > > > > > > > > > + gpiod_set_value_cansleep(data->reset_gpiod, 1); > > > > > > > > (1) > > > > > > > > ... > > > > > > > > > + /* > > > > > + * If reset pin is provided then will be set to high on power on > > > > > + * and to low on power off according to AK09911 datasheet > > > > > + */ > > > > > > > > Wording is confusing, perhaps you have to use 'asserted / deasserted'. > > > > > > Thank you for the suggestion, I'll be working on rewording as soon as > > > possible. > > > > > > > Btw, in (1) it's also "high" (asserted). I barely understand how it's > > > > supposed to work in all cases? > > > > > > > > > + reset_gpiod = devm_gpiod_get_optional(&client->dev, > > > > > + "reset", GPIOD_OUT_HIGH); > > > > > + if (IS_ERR(reset_gpiod)) > > > > > + return PTR_ERR(reset_gpiod); > > > > > > > > > > I'm sorry but I'm not sure about what you mean by saying all cases. > > > Currently I'm testing this driver on a msm8916 device having AK09911 > > > magnetometer. At the current stage the driver is failing on probe > > > because reset pin is not connected to VID (as datasheet requires in case > > > of pin not being used). In case of reset pin not asserted, register's > > > reset is triggered resulting in empty registers, leading to probe fail. > > > For this reason pin is asserted during power on in order to have > > > informations in registers and deasserted before power off triggering > > > a reset. > > > > > > A workaround that gets AK09911 working on device is by setting the > > > reset pin always high on device tree. This way registers gets reset by > > > a Power On Reset circuit autonomously and reset pin never triggers the > > > reset. > > > > You need to distinguish electrical level from logical (GPIO flag defines > > logical). So, I'm talking about active-high vs. active-low case. > > > > Now I re-read above, and see that here you assert the reset signal. But where > > is desertion? > > Oh I see, I'll try explaining by points the proposed approach: > - reset pin is active low > - during power on gpio is set to 0 so the reset pin is high, thus no reset deasserted > - during power off gpio is set to 1 so the reset pin becomes low, thus resetting asserted > this is a possible solution but maybe there are other ways to achieve that, > do you have suggestions on how to get a better approach for solving this issue? I see now, that at requesting reset you wanted to chip be in reset state (asserted) till driver calls power_on(). Seems everything you done is correct. Just correct terminology, please. -- With Best Regards, Andy Shevchenko