From patchwork Sat Dec 18 21:49:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 525603 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BAAE2C43217 for ; Sat, 18 Dec 2021 21:50:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234809AbhLRVu2 (ORCPT ); Sat, 18 Dec 2021 16:50:28 -0500 Received: from mail-mw2nam10on2118.outbound.protection.outlook.com ([40.107.94.118]:19424 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234657AbhLRVuS (ORCPT ); Sat, 18 Dec 2021 16:50:18 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZIAwaJAu2C4oEQPjAMsuNDj+st2L+uT591wIXZ1fccNqmXYBFwurfE6c45Pbpk51lH9K0AD4zNOsHJCvwdwlys5OY88UCh4dfhuEOgu9F6ZU3okV/UdRAfdSpET4NHYaWgnwZKgZQob6YrqB9LeNHONt1Uup4cjy2iQtm/XoBjrQzb7tR+DnmKP2UYdL3iaNFIu7qeGEoOkoE/+C434+ctBCUyFORtR5g4x8gsUu/u+wRN7LdPK7eEycK1dckjPpKe49R7d43oSqQ9qFPfXSIgsuhFUkyMDuCKxihmLqtVyZ29rh45AaOkFlSuyx4IbZpC1zkOhO2kPWXg9VaLjxdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/MDQpmpKE+PnRLCj55SwiesyejzuT/VnP0S6WITX204=; b=jHnv6336JcGMqPnMfz9ZdDzf1klhmq3LZGqR8yXZPdziJF2TX0k0/ButxlZFnKUlqWXtovCymVwkDamxQD4fKZPGkeMa1wyG1Zrn1cYfDJZ7/VENne0GfDVfqeNFr2mGTYoe0apHxvxaJiyGtCpYI0EMzUr9CkC6HjrlEgymsgIyUm22hNQwkOKTS3WFs6eyGJhsU1SzZc9HO2M/3f4sX8QQJTMWnUXdMJEB3QnLsair0gmoBTfe2xtjMSGyxylLqyrpvyQpdv0lYLtQ+aw1zw19+ynjRf3ooLzAYufn5zu8XflZSvq7qU3ghMB9gCJ4QJ5hrEDEtSUvJPX1k4Ddig== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=in-advantage.com; dmarc=pass action=none header.from=in-advantage.com; dkim=pass header.d=in-advantage.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inadvantage.onmicrosoft.com; s=selector2-inadvantage-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/MDQpmpKE+PnRLCj55SwiesyejzuT/VnP0S6WITX204=; b=N7+qRAI1vczepwu4QUXRPHSCWZL2f2RNgydu2ozZDYL2WehlcFi51/hD8o8BmVjtXRdga53A6H/DEMdImZOUm5u0rPiqYn68cZeGFtDwp9rzSUrWB7wayvgzygEdDq4c8E1tKvJ4UZUEH6HejJCPjtwVDL5YkQAbyQzO2xHGyA4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=in-advantage.com; Received: from MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) by CO6PR10MB5633.namprd10.prod.outlook.com (2603:10b6:303:148::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.17; Sat, 18 Dec 2021 21:50:15 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::2d52:2a96:7e6c:460f]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::2d52:2a96:7e6c:460f%4]) with mapi id 15.20.4801.017; Sat, 18 Dec 2021 21:50:15 +0000 From: Colin Foster To: linux-gpio@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Linus Walleij , Russell King , Heiner Kallweit , Jakub Kicinski , "David S. Miller" , Florian Fainelli , Vivien Didelot , Andrew Lunn , UNGLinuxDriver@microchip.com, Alexandre Belloni , Claudiu Manoil , Vladimir Oltean , Lee Jones Subject: [RFC v5 net-next 12/13] pinctrl: ocelot: add MFD functionality through ocelot-core Date: Sat, 18 Dec 2021 13:49:53 -0800 Message-Id: <20211218214954.109755-13-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211218214954.109755-1-colin.foster@in-advantage.com> References: <20211218214954.109755-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MWHPR02CA0011.namprd02.prod.outlook.com (2603:10b6:300:4b::21) To MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ee9a673e-7770-4807-88aa-08d9c2705fac X-MS-TrafficTypeDiagnostic: CO6PR10MB5633:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PexieaIh+t8htf+72eN5pr46eMC/GTffh/RnVRzfLZVN8U1ayebdgvc7Y8npbmJVCnTSiJtBhLlnXhUw2lgboWjwuckmSXU1JfJ6NabUzkNI45Qd2PTOvWGe/mWvzaMLTEboo1EeDHtq3btFG8WPxnJAdiD5kzJEkcEG0OI92HXo4/WsbCLpQ3xJiQFnNQ3744yEf2d4CUz+opMPOqk6fHM+tPhoSm2eBhY4NRDylTVFkxX7vaoL0LHDpLaa5mW//tS/7/OLvCGvfkPDJ1XDbQl7fNNORnjSqtJ8SrPLy6BHxeK3OqfKDSgvZnTZIVaf/ywHhU3rdCcR8uk+PDTTjnGSQxS45LDofxl/yDCodXPtN86bb3ohzA6wxslnGwwz3fZM2amW/NnszM11g/JjOZ7ywuDtv++EbFFq9+IAnnnorrOXsybw/a35vJlv/kNW3KTPDZzKsEEAkvF/SGHvRIkmuA43nUau6uJArS8knNI9yYwC5SRz9kW3Yfih//0dtdc8jGL5WeeNfoZNJyRoC2DU1CGdXOAGJBA/U7EK4u/aWBT0/ROq0Y925xCpKBa9GuCFkEaBkUds+m3goXy8wBAokhFwVtt2k3vnztegQmbZrWCN7mMtrKrueQK3YVCi06fgVEW6RIBZkgmQGQr284hEOcZRAHh2Tb+jQPann6BlX5LD43v3eaAY5K5XRt89m1Tv6vEfdqV+YYxBFoe9Zw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR1001MB2351.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39830400003)(396003)(366004)(346002)(376002)(136003)(6486002)(6506007)(7416002)(2906002)(36756003)(6512007)(26005)(86362001)(66556008)(66476007)(186003)(1076003)(6666004)(4326008)(83380400001)(66946007)(2616005)(44832011)(8936002)(8676002)(316002)(54906003)(38100700002)(5660300002)(508600001)(52116002)(38350700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ScATJNDFSwBsomcbiVNyjrnnOGkBbt9qKrww19zvM1ztn75wlpHIp9yLek2WIiZ+t1v54w6nJFToPzykPzihAw2Y6WB9srfxpSq5YQcKX1/CRmFtrXhLPxS+QKkCIxlYNUmkjN9RHG2Ym54TX0lKie244sFZukroUMm7fRldpTB/+D79s9IqPJkOGjW4Dcc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ppj2fbpg+8HfvxDYd6T/JRmo/GmB2Peqaz3niaVpcy1U3LyghlCCngEK7nzd74VKwC5uAnl275GUDMflkMUqgzttMO2pBtZdP36B88nBDt4E/nadP3sVQ8PGPRxA7TvRKDwN/cgJCUgJOOYb2bntNvp/y4bwEt5q8vbGYbABaWpnSlWCpBvyinl/OMvRH4mwAV8z896xpXxDmakgiUSFx4TstWiiWRsZrJJotH+Ay4LSHh60U4oIQg3HMpNSfikhbpH+OZ9kZnzWhU9UPRnvjx8x2RBUGlOV5PlVF9NVS0csHVt7BwB9g2naMCKbKHti6B0AxDTAi3h857mrStSjvLwOOaYwjrOIlnGaucrFErgwjlGIJ5wcbCn3ejR6mWjZScDr2NIYPNpy1GL9qWimk0b1JOWUvvwOcy6hC+kI2nkLiN3E/2GD9UZscQ= X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: ee9a673e-7770-4807-88aa-08d9c2705fac X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2021 21:50:14.8935 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 48e842ca-fbd8-4633-a79d-0c955a7d3aae X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: fbUrqt0xZ2cmT6tfWjb6snba2tFnUbmqFK+s/MKE7GAMMEHmfQrm0Sk33wQRSMxgN+G0JKnB0AfrOhd99VTy41GXgkkfWly7KxnKeWZKJ8Q= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR10MB5633 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org In the MFD case we need to requrest a regmap from the patern device instead of using mmio. This allows for the driver to be used in either case. Signed-off-by: Colin Foster --- drivers/pinctrl/pinctrl-ocelot.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/drivers/pinctrl/pinctrl-ocelot.c b/drivers/pinctrl/pinctrl-ocelot.c index 42aab9ba049a..d07ac7a0b487 100644 --- a/drivers/pinctrl/pinctrl-ocelot.c +++ b/drivers/pinctrl/pinctrl-ocelot.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -20,6 +21,7 @@ #include #include #include +#include #include "core.h" #include "pinconf.h" @@ -1123,6 +1125,9 @@ static int lan966x_pinmux_set_mux(struct pinctrl_dev *pctldev, return 0; } +#if defined(REG) +#undef REG +#endif #define REG(r, info, p) ((r) * (info)->stride + (4 * ((p) / 32))) static int ocelot_gpio_set_direction(struct pinctrl_dev *pctldev, @@ -1805,6 +1810,7 @@ static int ocelot_pinctrl_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct ocelot_pinctrl *info; struct regmap *pincfg; + struct resource *res; void __iomem *base; int ret; struct regmap_config regmap_config = { @@ -1819,16 +1825,28 @@ static int ocelot_pinctrl_probe(struct platform_device *pdev) info->desc = (struct pinctrl_desc *)device_get_match_data(dev); - base = devm_ioremap_resource(dev, - platform_get_resource(pdev, IORESOURCE_MEM, 0)); - if (IS_ERR(base)) - return PTR_ERR(base); + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (IS_ERR(res)) { + dev_err(dev, "Failed to get resource\n"); + return PTR_ERR(res); + } info->stride = 1 + (info->desc->npins - 1) / 32; - regmap_config.max_register = OCELOT_GPIO_SD_MAP * info->stride + 15 * 4; + if (!device_is_mfd(pdev)) { + base = devm_ioremap_resource(dev, res); + if (IS_ERR(base)) + return PTR_ERR(base); + + regmap_config.max_register = + OCELOT_GPIO_SD_MAP * info->stride + 15 * 4; + + info->map = devm_regmap_init_mmio(dev, base, ®map_config); + } else { + info->map = ocelot_mfd_get_regmap_from_resource(dev->parent, + res); + } - info->map = devm_regmap_init_mmio(dev, base, ®map_config); if (IS_ERR(info->map)) { dev_err(dev, "Failed to create regmap\n"); return PTR_ERR(info->map);