Received: by 10.223.185.116 with SMTP id b49csp2283943wrg; Mon, 12 Feb 2018 07:19:35 -0800 (PST) X-Google-Smtp-Source: AH8x227PFLjSqKuBWFHYAVb8oF9IMe2rNu7Ur/AatkQ09qxCtpFt7SXhDyO3rFRH6I/kxzkGgk1s X-Received: by 10.99.4.66 with SMTP id 63mr4844856pge.93.1518448775530; Mon, 12 Feb 2018 07:19:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518448775; cv=none; d=google.com; s=arc-20160816; b=eH+ENdVW/eG41aNwIKanc9CHyD0e+n5vR1JYf108WslkQp4spZywAAN3s2b+2iO1tB TtQEVB72JUSvVqZq5Q5uc6UdiOf/0JvCOu5SmIrwNHBv+p1iEQEM1xQ6h1hi8tuNat1h VkO9oF2R7Cueo2N9QpqUAluk6Zenln1X2DB6Lvy3sNjXrqdMgt574gsVLysW+CI/fZD2 nyYv8hkVf+04xV0VsueY32cNvLbT6i/+e+7OweZx4cnIZDwJueRuh2bs3D6y+E+cValv zNc5omX9lfvvrKuUj5YyeES5QzXphKzWtoFHkSYCoxwfNc9WIUet6iGPrZdjmiayXE3R fLPw== 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 :organization:references:in-reply-to:date:cc:to:from:subject :message-id:arc-authentication-results; bh=Q2/ClR5bYrNx2qcMjZM3X1qYua7xtKZtDLyrrF6F6NM=; b=yevj3sIinFemqWapzbHAisSNPA/jKLdQjxYQR5csTX6CEygk0o5dQ/o64qOuf/TDKH kTgp3KxR9QVUZM4/tLjrYJGKLctK/k0+FSJXEdO9+LURR4y7Nz3q1sQTC0u3oRoWbZrk DC1xUj5VYwEyt2BK+X2s5mapp5SVl1bOJZxBTDqQOAIVPqIDsNxTJWlsK5zBGEtfEKtS DH3QlR1ozzw7ppvQdbMwiOVMRfjHYvR+cggHT//XUvoaGSbGGFwFLZOQTq3CVCKa5di4 lEvQ6Ac1julzGEm3kg152VBG1789JOfsyQ2BqFgIU/4nbYZoKrBoAsUnj1EnCMrDX+Sj ruJA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f84si825059pfh.363.2018.02.12.07.19.20; Mon, 12 Feb 2018 07:19:35 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752563AbeBLPNk (ORCPT + 99 others); Mon, 12 Feb 2018 10:13:40 -0500 Received: from mga11.intel.com ([192.55.52.93]:22211 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751176AbeBLPNh (ORCPT ); Mon, 12 Feb 2018 10:13:37 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Feb 2018 07:13:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,501,1511856000"; d="scan'208";a="203430329" Received: from smile.fi.intel.com (HELO smile) ([10.237.72.86]) by fmsmga005.fm.intel.com with ESMTP; 12 Feb 2018 07:13:31 -0800 Message-ID: <1518448411.22495.286.camel@linux.intel.com> Subject: Re: [PATCH 02/21] regulator: fixed: Convert to use GPIO descriptor only From: Andy Shevchenko To: Linus Walleij , Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Alexander Shiyan , Haojian Zhuang , Aaro Koskinen , Tony Lindgren , Mike Rapoport , Robert Jarzmik , Philipp Zabel , Daniel Mack , Marc Zyngier , Geert Uytterhoeven Date: Mon, 12 Feb 2018 17:13:31 +0200 In-Reply-To: <20180212131717.27193-3-linus.walleij@linaro.org> References: <20180212131717.27193-1-linus.walleij@linaro.org> <20180212131717.27193-3-linus.walleij@linaro.org> Organization: Intel Finland Oy Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.26.3-1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2018-02-12 at 14:16 +0100, Linus Walleij wrote: > As we augmented the regulator core to accept a GPIO descriptor instead > of a GPIO number, we can augment the fixed GPIO regulator to look up > and pass that descriptor directly from device tree or board GPIO > descriptor look up tables. > > Some boards just auto-enumerate their fixed regulator platform devices > and I have assumed they get names like "fixed-regulator.0" but it's > pretty hard to guess this. I need some testing from board maintainers > to > be sure. Other boards are straight forward, using just plain > "fixed-regulator" (ID -1) or "fixed-regulator.1" hammering down the > device ID. > > The OMAP didn't have proper label names on its GPIO chips so I have > fixed > this with a separate patch to the GPIO tree. > > It seems the da9055 and da9211 has never got around to actually > passing > any enable gpio into its platform data (not the in-tree code anyway) > so we > can just decide to simply pass a descriptor instead. > > The fixed GPIO-controlled regulator in mach-pxa/ezx.c was confusingly > named > "*_dummy_supply_device" while it is a very real device backed by a > GPIO > line. There is nothing dummy about it at all, so I renamed it with the > infix *_regulator_* as part of this patch set. > > For the patch hunk hitting arch/blackfin I would say I do not expect > testing, review or ACKs anymore so if it works, it works. > > The hunk hitting the x86 BCM43xx driver is especially tricky as the > number > comes out of SFI which is a mystery to me. I definately need someone > to > look at this. (Hi Andy.) Hi, Linus! Nice patch, though I have comments below. > --- a/arch/x86/platform/intel-mid/device_libs/platform_bcm43xx.c > +++ b/arch/x86/platform/intel-mid/device_libs/platform_bcm43xx.c > @@ -43,7 +43,6 @@ static struct fixed_voltage_config bcm43xx_vmmc = { > * real voltage and signaling are still 1.8V. > */ > .microvolts = 2000000, /* 1.8V > */ > - .gpio = -EINVAL, > .startup_delay = 250 * 1000, /* > 250ms */ > .enable_high = 1, /* > active high */ > .enabled_at_boot = 0, /* > disabled at boot */ > @@ -58,11 +57,25 @@ static struct platform_device > bcm43xx_vmmc_regulator = { > }, > }; > > +static struct gpiod_lookup_table bcm43xx_vmmc_gpio_table = { > + .dev_id = "reg-fixed-voltage.0", I'm not sure this will be always like this. We have DEVID_AUTO, which theoretically can be anything. Okay, it looks like we have only one static regulator for now for Intel MID. Though it's fragile if anything will change in the future (quite unlikely). > + .table = { > + /* CHECKME: is this the correct PCI address for the > GPIO controller? */ Yes. > + GPIO_LOOKUP("0000:00:0c.0", -1, "enable", > GPIO_ACTIVE_LOW), > + { }, Terminator should terminate even at compile time, right? Simple {} looks better to me. > + }, > +}; > + > static int __init bcm43xx_regulator_register(void) > { > + struct gpiod_lookup_table *table = &bcm43xx_vmmc_gpio_table; > + struct gpiod_lookup *lookup = table->table; > int ret; > > - bcm43xx_vmmc.gpio = > get_gpio_by_name(WLAN_SFI_GPIO_ENABLE_NAME); > + /* FIXME: convert SFI layer to use GPIO descriptors > internally */ We already discussed this few years ago and decide not to do anything WRT SFI. It should just die. > + lookup[0].chip_hwnum = > get_gpio_by_name(WLAN_SFI_GPIO_ENABLE_NAME); > + gpiod_add_lookup_table(table); > --- a/drivers/regulator/fixed.c > +++ b/drivers/regulator/fixed.c > cfg.ena_gpio_invert = !config->enable_high; > if (config->enabled_at_boot) { > if (config->enable_high) > - cfg.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH; > + gflags = GPIOD_OUT_HIGH; > else > - cfg.ena_gpio_flags |= GPIOF_OUT_INIT_LOW; > + gflags = GPIOD_OUT_LOW; > } else { > if (config->enable_high) > - cfg.ena_gpio_flags |= GPIOF_OUT_INIT_LOW; > + gflags = GPIOD_OUT_LOW; > else > - cfg.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH; > + gflags = GPIOD_OUT_HIGH; > } Just a side note: It might make sense to split this to some kind of generic helper, like: static inline enum gpiod_flags gpiod_flags_output(bool value, bool invert) { ... } > + if (config->gpio_is_open_drain) { > + if (gflags == GPIOD_OUT_HIGH) > + gflags = GPIOD_OUT_HIGH_OPEN_DRAIN; > + else > + gflags = GPIOD_OUT_LOW_OPEN_DRAIN; > + } > + > + cfg.ena_gpiod = devm_gpiod_get_optional(&pdev->dev, NULL, > gflags); Shouldn't we be a little bit more stricter here, i.e. require "enable" name? > + if (IS_ERR(cfg.ena_gpiod)) > + return PTR_ERR(cfg.ena_gpiod); -- Andy Shevchenko Intel Finland Oy