Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4377151pxu; Wed, 9 Dec 2020 15:55:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJwbhZ7twjkLsH5L64NHmquENJWPZdLpTrJMIhm3rhyRc/GQ1TH+y15CV7QDIjG1RFQtKtS4 X-Received: by 2002:a50:85c6:: with SMTP id q6mr4448370edh.126.1607558151265; Wed, 09 Dec 2020 15:55:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607558151; cv=none; d=google.com; s=arc-20160816; b=wW9YiucwmdN2BsXWE6Z/az/6aGIS6lvp/oKOQK1arrt8UYpLppl9px2L16i53r01Di 5SypBRBQlKSC7juYtk0idXOGbyiLQc+sel1aDR7az7WO6wD9wXqs9Jsf82s1mferm/5k eSLSd6zO4pA0emcOlkdlQ3/vAg6CGT3oyzSSCprhaxJ4dY5TV61ci8o/fWfV59Rxnn7K CZ3R6YS06UHnlLN9QEJqxl9qigGaIFR1DPyvAE4ng6YZDjaMwqd3MuMgJ+V2pKDVUDas 6xk+1Zg4bbSUNuYXEmzzcZSdsTF8RsEIGiUFPy3eoVSzi9EqawZzxl84M0AoCYy50CXt bRhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=FMO74Hau3qL0zw1EsJlNy+Kf0E35Zr9dtC9lm7X7hVs=; b=DqMyUw5j8loewQyebJjJKFF3yfgFMX264PWGKruIv2krPza421zNSZi9M7FBRhDp3V GGo3x65mXEN+PAdsAGPkDpMwUBXzuLrXzJAZhEjRNjAd3LuQezs+OPsnVwvNIiwqnpUq GphbdaEw2yrySMxVmvkD20lMkaOplnluXypXLRFxcsnnbBxgS6MUPFWnA1Feu7KfbIO4 T6vVXtQX1tL96bZ30yBe28Mm+zFNU6DtUz9TP4N9zh0THhj97ViziZrLMM1MOpD0cjZi WCpilD+WQ8YrMfwABR0u9aFny15Wpo6P4P28vsLKQqhedbsBrS1GvyLMlmE0XFNnjYvh /Ikw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=RuTn6HCi; 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=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hs7si1978761ejc.125.2020.12.09.15.55.28; Wed, 09 Dec 2020 15:55:51 -0800 (PST) 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=@chromium.org header.s=google header.b=RuTn6HCi; 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=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387873AbgLIXEv (ORCPT + 99 others); Wed, 9 Dec 2020 18:04:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727899AbgLIXEv (ORCPT ); Wed, 9 Dec 2020 18:04:51 -0500 Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5864C0613D6 for ; Wed, 9 Dec 2020 15:04:10 -0800 (PST) Received: by mail-lj1-x243.google.com with SMTP id y16so4496319ljk.1 for ; Wed, 09 Dec 2020 15:04:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=FMO74Hau3qL0zw1EsJlNy+Kf0E35Zr9dtC9lm7X7hVs=; b=RuTn6HCiV9nNg4HIQMkZc4/Qu4UsvOhRfwgqizxlXSto+yYPbP8PLgrAl0ZzDQCf8t dxarwTv0ijUCm6uugEAW7/IeTe3opsFB+6KzhTA6r8maxSDRrX5ui6ZbnsPzGDu8nWvz UsjXrsT9uvsY2yC/soUD60lQo4t5m9SKfRsE8= 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=FMO74Hau3qL0zw1EsJlNy+Kf0E35Zr9dtC9lm7X7hVs=; b=WGLx3EaXBmFKn7y80BV7w3kzF8yvczCpMGf9yym3OTQ9eqrWBFtuRwCtVLHBs01tSe 7vajcCxOYcVNCrrec3XYXh620SyMZrx0EXxKACc8QJduyPRTvASU5U9lHP2mGbqdzI/v Mpnu3oX2BpZ3dRx204l1rxACqDW6R8Ib+y/GIxmGPfaJmeZnk2Wv5w8QSbe8jjZbPVPt gCBOmVh74i9tftJLJvgU7TWXzEwyW+znY4LZLrcVF8jtQnfQSbbQhT8ZPqUV1nt+8bAp ATUXwZTAmT3DjjIld+Wx3NeTsfZj6IvudbdoNgkCH2EQXEy7X8Si+NelXUMgmkUODdmv seRQ== X-Gm-Message-State: AOAM533Vt7D4+XcqDWwthjHc5fw97Stv60KyVWuCjJz0W2J4zYOM7etG HkXQyJfUVFVTPxBtg7/mCNYftGDrKKhy9Q== X-Received: by 2002:a2e:98d9:: with SMTP id s25mr1804696ljj.476.1607555048465; Wed, 09 Dec 2020 15:04:08 -0800 (PST) Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com. [209.85.167.43]) by smtp.gmail.com with ESMTPSA id h22sm306150lfj.302.2020.12.09.15.04.07 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 09 Dec 2020 15:04:08 -0800 (PST) Received: by mail-lf1-f43.google.com with SMTP id a8so5467760lfb.3 for ; Wed, 09 Dec 2020 15:04:07 -0800 (PST) X-Received: by 2002:a19:488:: with SMTP id 130mr1622914lfe.124.1607555046503; Wed, 09 Dec 2020 15:04:06 -0800 (PST) MIME-Version: 1.0 References: <20201118234025.376412-1-evgreen@chromium.org> <20201118153951.RESEND.v3.2.Idef164c23d326f5e5edecfc5d3eb2a68fcf18be1@changeid> In-Reply-To: From: Evan Green Date: Wed, 9 Dec 2020 15:03:29 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RESEND PATCH v3 2/2] i2c: i2c-mux-gpio: Enable this driver in ACPI land To: Andy Shevchenko Cc: Peter Rosin , Wolfram Sang , Randy Dunlap , Peter Korsgaard , linux-i2c , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Very sorry to ping. Is there anything I can do to help get this reviewed? -Evan On Mon, Nov 30, 2020 at 11:11 AM Evan Green wrote: > > Hi Andy, Peter, > > On Fri, Nov 20, 2020 at 10:59 AM Evan Green wrote: > > > > On Thu, Nov 19, 2020 at 7:24 AM Andy Shevchenko > > wrote: > > > > > > On Thu, Nov 19, 2020 at 1:40 AM Evan Green wrote: > > > > > > > > Enable i2c-mux-gpio devices to be defined via ACPI. The idle-state > > > > property translates directly to a fwnode_property_*() call. The child > > > > reg property translates naturally into _ADR in ACPI. > > > > > > > > The i2c-parent binding is a relic from the days when the bindings > > > > dictated that all direct children of an I2C controller had to be I2C > > > > devices. These days that's no longer required. The i2c-mux can sit as a > > > > direct child of its parent controller, which is where it makes the most > > > > sense from a hardware description perspective. For the ACPI > > > > implementation we'll assume that's always how the i2c-mux-gpio is > > > > instantiated. > > > > > > ... > > > > > > > +#ifdef CONFIG_ACPI > > > > + > > > > +static int i2c_mux_gpio_get_acpi_adr(struct device *dev, > > > > + struct fwnode_handle *fwdev, > > > > + unsigned int *adr) > > > > + > > > > +{ > > > > + unsigned long long adr64; > > > > + acpi_status status; > > > > + > > > > + status = acpi_evaluate_integer(ACPI_HANDLE_FWNODE(fwdev), > > > > + METHOD_NAME__ADR, > > > > + NULL, &adr64); > > > > + > > > > + if (!ACPI_SUCCESS(status)) { > > > > + dev_err(dev, "Cannot get address\n"); > > > > + return -EINVAL; > > > > + } > > > > + > > > > + *adr = adr64; > > > > + if (*adr != adr64) { > > > > + dev_err(dev, "Address out of range\n"); > > > > + return -ERANGE; > > > > + } > > > > + > > > > + return 0; > > > > +} > > > > + > > > > +#else > > > > + > > > > +static int i2c_mux_gpio_get_acpi_adr(struct device *dev, > > > > + struct fwnode_handle *fwdev, > > > > + unsigned int *adr) > > > > +{ > > > > + return -EINVAL; > > > > +} > > > > + > > > > +#endif > > > > > > I'm wondering if you may use acpi_find_child_device() here. > > > Or is it a complementary function? > > > > I think it's complementary. The code above is "I have a device, I want > > its _ADR". whereas acpi_find_child_device() is "I have an _ADR, I want > > its device". I could flip things around to use this, but it would turn > > the code from linear into quadratic. I'd have to scan each possible > > address and call acpi_find_child_device() with that _ADR to see if > > there's a child device there. > > > > > > > > ... > > > > > > > + device_for_each_child_node(dev, child) { > > > > + if (is_of_node(child)) { > > > > + fwnode_property_read_u32(child, "reg", values + i); > > > > + > > > > + } else if (is_acpi_node(child)) { > > > > + rc = i2c_mux_gpio_get_acpi_adr(dev, child, values + i); > > > > + if (rc) > > > > + return rc; > > > > + } > > > > + > > > > i++; > > > > } > > > > > > And for this I already told in two different threads with similar code > > > that perhaps we need common helper that will check reg followed by > > > _ADR. > > > > Oh, I'm not aware of those threads. I'd need some advice: I guess a > > new fwnode_* API would make sense for this, but I had trouble coming > > up with a generic interface. _ADR is just a blobbo 64 bit int, but > > DT's "reg" is a little more flexible, having a length, and potentially > > being an array. I suppose it would have to be something like: > > > > int fwnode_property_read_reg(const struct fwnode_handle *fwnode, > > size_t index, uint64_t *addr, uint64_t *len); > > > > But then ACPI would always return 0 for length, and only index 0 would > > ever work? I'm worried I'm designing an API that's only useful to me. > > > > I tried to look around for other examples of this specific pattern of > > _ADR then "reg", but struggled to turn up much. > > Any thoughts on this? > > > -Evan > > > > > > > > -- > > > With Best Regards, > > > Andy Shevchenko