Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp136853pxf; Wed, 10 Mar 2021 02:29:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJwkjB/8WVywnFz+9oGyC2qDRlQbgl+KXvQh4HnFku2ZNuM1DEny3FiWch0RGzEslmCurwgu X-Received: by 2002:a05:6402:181a:: with SMTP id g26mr2429669edy.225.1615372140849; Wed, 10 Mar 2021 02:29:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615372140; cv=none; d=google.com; s=arc-20160816; b=Vib9zgaaUI1854U6qqU4HRiyH6JNYy1TkFw8W3wrHUSgIP20XZjWSQPkIHtadNG7Ln bOk4AosdHGYV+k3wA+qCxDDSzLE7tVl3xbyE08QS1ir3k3vxtxOQObRcd9zo7WkGa0Jl zwVlnI91uHs2/vWypx2ocuOBvENHVDtCFlzfEQPUXPIYJEeVMxXG6qD3mbQNEdk1eB31 Fz71iX1DBv5mOZFaRIP41iWeVv7MMaKFIrRZA3l8NsnU+WacjtfTvcobvN1uj+fo6bQd XZDQaGHWFBzvQ0iUXB/LYULA9O2lAAVHxmPFqmovqMPgHo9T/0LxE8ZUq/PMi1ML65U+ X3Zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Kptfrvu/Fb55Ii8aAQJW9aAPQICxkOK8F9AK/ZdQ2Fw=; b=gBvgZq8lkgQVCuhsH7oJuOcS03DP/5m2dS8miUAz+7hLDbtfF9d4QOzp+AmfZttiVx mo0M+wrrvQB1dOZgFNodVFKuZrz1FEITIibWczvWlVl9TSmLAdTMzdW4O42Eu5B2cL1q RFv3NUbPnxqqlEk3DXVXrTAUEMFFgsHciw1OkmjrE2qoqt/T9ZxvoGJFMpH/2bzELZX2 rEQ9zEhMFPJHOq4DbguKvxeMgoHlvNmZaFs/2zpp94/CXZY3q3E38ZnJBspPoNSNVz9n LtCghUNbGGYyBYJaz40lg8OawiWmMs6J6W7FRkG1YtwmdV5EIzgANQQ4RqzF8Ekj8tMC wZ4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mW8WRTrJ; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u12si13632111eda.121.2021.03.10.02.28.38; Wed, 10 Mar 2021 02:29:00 -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=@linaro.org header.s=google header.b=mW8WRTrJ; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231908AbhCJK1p (ORCPT + 99 others); Wed, 10 Mar 2021 05:27:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229657AbhCJK1V (ORCPT ); Wed, 10 Mar 2021 05:27:21 -0500 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A635C06174A for ; Wed, 10 Mar 2021 02:27:20 -0800 (PST) Received: by mail-wr1-x42f.google.com with SMTP id u14so22699132wri.3 for ; Wed, 10 Mar 2021 02:27:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=Kptfrvu/Fb55Ii8aAQJW9aAPQICxkOK8F9AK/ZdQ2Fw=; b=mW8WRTrJtBe2h2nWOnSf9jX0FJEijKlVoT7LfXXNq9vEuWpDJW6SoXlq8JOnjc3k2Q k7wmmhIdMZU5/qRpQJzkMrgm41tzNsmXbeib2TTTdp816tA8o6minWSH76zjQhwQPgis 7rKGutUp2aai8ZZHDMxdNyNaf1u4/xgIzUEQ1hOJ33uCCsDsdeLpr8b+Ayge18G0zV2k f6caWhdaDJoygStuwQ73cUzlj18nJ0amZ97UU8Q++J55TGO3/N+cw/2uj47bZzGG+s8A 1MMBIS9rogUx89mWOMwziuG8BsT4BX1i3+VqxMyKmYuozuWtUuso9PE9dnjhdYbYJbkR B2zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=Kptfrvu/Fb55Ii8aAQJW9aAPQICxkOK8F9AK/ZdQ2Fw=; b=ujeUddCZ84eWr56pdhxwbVLc6VYVub6QYzEGnxn0IuG0ua+uJGaQuFnnLF1+w+k8a6 OUG7vJ5SyCuiT4sQxy09L+lpaKlDd1wxlKijCWWwFvEPCFsfPrR0EUotab4dcjMdHWk2 Uzs+BeoBkOxg63VlKufPd95tl7X+9apaQHaxAPNJGwsDwvE0VP1LrOMr1ubtLqy9nG/h 286t9HdLm2hi2KdGqM1wfn2dSRoRO910N+DnZwJqN9CX44VQCLydkOJQhzOxMtwmyIIU c5a4sP6tAIfsU/z+Sg26SRseDZwMuglUYNUiDHos310uG3509LPDc1hXEwebnhC21tMM 1trA== X-Gm-Message-State: AOAM530+yxGP5KPg3ME7xUYcmAPBhAYVXfLIOA9MohTFTEwkzJsD6H3c W0jAvYpw29JSasiCiVqSY2bQiA== X-Received: by 2002:a5d:61c9:: with SMTP id q9mr2690991wrv.219.1615372039013; Wed, 10 Mar 2021 02:27:19 -0800 (PST) Received: from dell ([91.110.221.204]) by smtp.gmail.com with ESMTPSA id j12sm28611919wrx.59.2021.03.10.02.27.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 02:27:18 -0800 (PST) Date: Wed, 10 Mar 2021 10:27:16 +0000 From: Lee Jones To: Andy Shevchenko , gregkh@linuxfoundation.org Cc: Wolfram Sang , Jean Delvare , Tan Jui Nee , Jim Quinlan , Jonathan Yong , Bjorn Helgaas , linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-pci@vger.kernel.org, Jean Delvare , Peter Tyser , hdegoede@redhat.com, henning.schild@siemens.com Subject: Re: [PATCH v1 6/7] mfd: lpc_ich: Add support for pinctrl in non-ACPI system Message-ID: <20210310102716.GD701493@dell> References: <20210308122020.57071-1-andriy.shevchenko@linux.intel.com> <20210308122020.57071-7-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210308122020.57071-7-andriy.shevchenko@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 08 Mar 2021, Andy Shevchenko wrote: > From: Tan Jui Nee > > Add support for non-ACPI systems, such as system that uses > Advanced Boot Loader (ABL) whereby a platform device has to be created > in order to bind with pin control and GPIO. > > At the moment, Intel Apollo Lake In-Vehicle Infotainment (IVI) system > requires a driver to hide and unhide P2SB to lookup P2SB BAR and pass > the PCI BAR address to GPIO. > > Signed-off-by: Tan Jui Nee > Signed-off-by: Andy Shevchenko > --- > drivers/mfd/lpc_ich.c | 100 +++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 99 insertions(+), 1 deletion(-) > > diff --git a/drivers/mfd/lpc_ich.c b/drivers/mfd/lpc_ich.c > index 8e9bd6813287..959247b6987a 100644 > --- a/drivers/mfd/lpc_ich.c > +++ b/drivers/mfd/lpc_ich.c > @@ -8,7 +8,8 @@ > * Configuration Registers. > * > * This driver is derived from lpc_sch. > - > + * > + * Copyright (C) 2017, 2021 Intel Corporation Big C or little c? Please be consistent. > * Copyright (c) 2011 Extreme Engineering Solution, Inc. > * Author: Aaron Sierra > * > @@ -43,6 +44,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -140,6 +142,73 @@ static struct mfd_cell lpc_ich_gpio_cell = { > .ignore_resource_conflicts = true, > }; > > +/* Offset data for Apollo Lake GPIO controllers */ > +#define APL_GPIO_SOUTHWEST_OFFSET 0xc00000 > +#define APL_GPIO_SOUTHWEST_SIZE 0x654 > +#define APL_GPIO_NORTHWEST_OFFSET 0xc40000 > +#define APL_GPIO_NORTHWEST_SIZE 0x764 > +#define APL_GPIO_NORTH_OFFSET 0xc50000 > +#define APL_GPIO_NORTH_SIZE 0x76c > +#define APL_GPIO_WEST_OFFSET 0xc70000 > +#define APL_GPIO_WEST_SIZE 0x674 > + > +#define APL_GPIO_NR_DEVICES 4 > +#define APL_GPIO_IRQ 14 > + > +static struct resource apl_gpio_resources[APL_GPIO_NR_DEVICES][2] = { > + { > + DEFINE_RES_MEM(APL_GPIO_NORTH_OFFSET, APL_GPIO_NORTH_SIZE), > + DEFINE_RES_IRQ(APL_GPIO_IRQ), > + }, > + { > + DEFINE_RES_MEM(APL_GPIO_NORTHWEST_OFFSET, APL_GPIO_NORTHWEST_SIZE), > + DEFINE_RES_IRQ(APL_GPIO_IRQ), > + }, > + { > + DEFINE_RES_MEM(APL_GPIO_WEST_OFFSET, APL_GPIO_WEST_SIZE), > + DEFINE_RES_IRQ(APL_GPIO_IRQ), > + }, > + { > + DEFINE_RES_MEM(APL_GPIO_SOUTHWEST_OFFSET, APL_GPIO_SOUTHWEST_SIZE), > + DEFINE_RES_IRQ(APL_GPIO_IRQ), > + }, > +}; > + > +/* The order must be in sync with apl_pinctrl_soc_data */ > +static const struct mfd_cell apl_gpio_devices[APL_GPIO_NR_DEVICES] = { > + { > + /* North */ > + .name = "apollolake-pinctrl", > + .id = 0, Do these have to be hard-coded? > + .num_resources = ARRAY_SIZE(apl_gpio_resources[0]), > + .resources = apl_gpio_resources[0], You can make this less fragile by defining the index and using: [DEFINE_X_Y_Z] = { /* resource */ }, /* etc */ ... above. > + .ignore_resource_conflicts = true, > + }, > + { > + /* NorthWest */ > + .name = "apollolake-pinctrl", > + .id = 1, > + .num_resources = ARRAY_SIZE(apl_gpio_resources[1]), > + .resources = apl_gpio_resources[1], > + .ignore_resource_conflicts = true, > + }, > + { > + /* West */ > + .name = "apollolake-pinctrl", > + .id = 2, > + .num_resources = ARRAY_SIZE(apl_gpio_resources[2]), > + .resources = apl_gpio_resources[2], > + .ignore_resource_conflicts = true, > + }, > + { > + /* SouthWest */ > + .name = "apollolake-pinctrl", > + .id = 3, > + .num_resources = ARRAY_SIZE(apl_gpio_resources[3]), > + .resources = apl_gpio_resources[3], > + .ignore_resource_conflicts = true, > + }, > +}; > > static struct mfd_cell lpc_ich_spi_cell = { > .name = "intel-spi", > @@ -1082,6 +1151,29 @@ static int lpc_ich_init_wdt(struct pci_dev *dev) > return ret; > } > > +static int lpc_ich_init_pinctrl(struct pci_dev *dev) > +{ > + struct resource base; > + unsigned int i; > + int ret; > + > + ret = pci_p2sb_bar(dev, PCI_DEVFN(13, 0), &base); What is 13 and 0? Should these be defined? > + if (ret) > + return ret; > + > + for (i = 0; i < ARRAY_SIZE(apl_gpio_devices); i++) { > + struct resource *mem = &apl_gpio_resources[i][0]; > + > + /* Fill MEM resource */ > + mem->start += base.start; > + mem->end += base.start; > + mem->flags = base.flags; > + } So you're converting PCI devices to platform devices. I'm not sure how 'okay' that is. Adding Greg to see if he has an opinion. > + return mfd_add_devices(&dev->dev, 0, apl_gpio_devices, Please use the defines, rather than 0. > + ARRAY_SIZE(apl_gpio_devices), NULL, 0, NULL); > +} > + > static void lpc_ich_test_spi_write(struct pci_dev *dev, unsigned int devfn, > struct intel_spi_boardinfo *info) > { > @@ -1198,6 +1290,12 @@ static int lpc_ich_probe(struct pci_dev *dev, > cell_added = true; > } > > + if (priv->chipset == LPC_APL) { > + ret = lpc_ich_init_pinctrl(dev); > + if (!ret) > + cell_added = true; > + } > + > if (lpc_chipset_info[priv->chipset].spi_type) { > ret = lpc_ich_init_spi(dev); > if (!ret) -- Lee Jones [李琼斯] Senior Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog