From patchwork Sat Dec 18 21:49:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 526191 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 8ADDCC433EF for ; Sat, 18 Dec 2021 21:50:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232363AbhLRVuJ (ORCPT ); Sat, 18 Dec 2021 16:50:09 -0500 Received: from mail-mw2nam10on2096.outbound.protection.outlook.com ([40.107.94.96]:43520 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231545AbhLRVuJ (ORCPT ); Sat, 18 Dec 2021 16:50:09 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=izlP/ks8OAarp3To14n76fyNJ3zXuMzgxI0F8fB3ASxCdk3y7LmsR7vhkZSt0JDVWV8IE5oDxNvrLd4IPS9+0TrouTF2cOoI5G3Bx065O88q3NxOFvf/XkIEuVxvOE6z1qDPmpsVyWvXYocyZc46jS0HXAzIu92MTYxiLaCySIulEzohuAZumBvNkiXw0YTPxf8xhlJKNjr4cziP7TwrQJJtkkxyNd+LdbIYq1y0PPQarBagvgHKgyzIm40cmEvlTQ5COiLEA/cSn5MNr4g0rf9LbmoN/EPLGajLSlrK+9Iv2EuOo9k0GJ4NILJL8xb6Fxgi1SZZqT/R1dbN/IQlrA== 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=DvRm/Wk5tMUlCJqRVSrJ8dVEshWv2C49TAT8UbhlNYA=; b=Y2XcCGtkaapziYUXJAn1sem6H6kbz7453zgPBmMSWZkm7k5dMvAvK0BkzWfraVfgXO6qYrwg/lPiGG2C6v5haudAjZnIUHuZzCJArzvK/mMEJdN2dI7S11Jtk/H9j5K2Hm04gs6/utCIXcEvvVcQsyq0fhR2CnTSDJ0iZBq66h5nuU+GyFw8fC0IjjHBZ05L8kALb7hBviyqzC2UAnn2T5qEuq+wddfgRn5HAdosLIEpV3t2nATaLXbEs7C1xglBV1/ReIpxPVV0mfBs5Pnc4h8kzwIXH997015xcUQtStVga4XIA2bpIoCmjVflR8qmVpzur1eqbMtKmBR4ydHBeg== 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=DvRm/Wk5tMUlCJqRVSrJ8dVEshWv2C49TAT8UbhlNYA=; b=SrN8Jy+qA52WNYjEhqdb8kypokGoVRjybA6xh5Yc60vHOsJeAAu6NApYIHSDJQwZ258J7mm3mPxHmf7hv2jszeZglVDzHPeCJgoShOAoSS2vTgLfX/zN3GlECIlHLmEqMZ/iEsylGzz+H/eqAUEqNOLjgbuPq9fQvLQ4h6FcCZQ= 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:07 +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:07 +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 02/13] mfd: ocelot: offer an interface for MFD children to get regmaps Date: Sat, 18 Dec 2021 13:49:43 -0800 Message-Id: <20211218214954.109755-3-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: 772ee936-3acf-487c-3865-08d9c2705af6 X-MS-TrafficTypeDiagnostic: CO6PR10MB5633:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +yLKPA4maNdFxCQFWXcO0eWWuz4ueriambPuFrr6RMFz2o9bFJP77HQ4HvbHV2fW9PI8TSXWpRWVvVVnbw0so1Xm49cZWojq5lHE9yP0zzBtBuSlUH5XYBjEmXjqGZLkLVJoOb/CyxvSZK6370BFhnIlMRSqz2XPXBKdyhjgaRSDdzSy0C0q/TrsRDQhVk4H4620E0kwrVcWy8hAMgvPF+u1UseB4J5e1WXjVWfEr5VSNRgSjJgqxbw8j7CtLmG8V7etGVbrIuyuxPJYMQwdp9Id7Q6i6Ha5vZGJx+fy/2q/fbGzPxIRco+RmQYiG9oe4o+44WdAg2eVoJqMbEIDdM6mYXr730I+zNgtwdA3wmunDFUWOSBIxoPi2Ig+YttmmhaN0bEC7cdzT77fJY667yQTXndedyyPyf7Y8EnOyuA4YuUfNEwNCqsslBqpEjHJR2e1RN9X2cSEeJW/sOwj/NEdLYZuaC35IP6xXBMBqQ19qdRrqB2HzvJCkZ1AI3ppm6BD+GrA35jrCrWEcBfEwrkEXmKnnUOx6ViXBFuwsucr6LAssEONpeJ/+gPaedH1GJq2eW7zEWaBWp+DRW6W17OeX5MC0eDgFD6VOrtW+ObA9G6C9D4/HOCCXqWZknk/bKJQaZNlKVeOBnrOSJKv8jI2tML22A/o12etTyskXIW/0rPk95KTMJ7jIwTKyYS4AqwO7qJ1ge69E/Vc1jIFjQ== 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)(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: 52kJGgRmiFBqxxPtct9OzlUAtMtU/w98dVLsO8JYZ62vGpgWv4tFxpkPlYcBh8bCnv2bpyDo8Xwz32M3/nub1LhCEjnTcguoefGaOk6mXe2NDxN3ijFD2UrCg1x9/i9JeyjlzYk4NxuZYU7dUJGaetsjf9Kl4ANpQwAn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dp+r3HBxgujcOh3e9naJRrD0oAoll1PhpoGk6yOolfPBqBy6N2FP4Lb97CG9LPKHqC3rFU0NgKcvxOaUadt8CDoBnXfmLUf28n3oWu2P9cIOe2WwNNe5esdVWpV986NQmizfH2cWEOxqRoAqNW3ap96Bmo3SnxW7rtlsarMFkyBYO4PKdHk9MQT1RPNLquSI3bNFP69fXN1yVYUK/9XRzS3j5g22FBnwy/82m91CqCeD0tO9fy+yHJRpJmkIdfcZuxf756jUgpXi/Ye67Rp6cyQx10fcsk8gvjpWJA8fXY9zCSOu8WSBVFUBM/gMmCizKGaKX7NrzMYz6FVaxmKCiT+8rOVqbGmRNAz9AR63Hu5cvWydBgF9N+kvuREsk1E4TNsZEOUuN0RKqFEadnsLehY8vuK82kmIe+YjVC1uAoznXfRIjMiR83t9b3FX3w== X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 772ee936-3acf-487c-3865-08d9c2705af6 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:06.9722 (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: BG6jh2hUQq6un17S0uaJCCputh9awEm/lGvaGYsYonNh2AYXqDCqKUswJj+I/tue3FBNLnnNHQDdpH9A0p9OzqmURVW17LLizrVCuZ8kyZU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR10MB5633 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Child devices need to get a regmap from a resource struct, specifically from the MFD parent. The MFD parent has the interface to the hardware layer, which could be I2C, SPI, PCIe, etc. This is somewhat a hack... ideally child devices would interface with the struct device* directly, by way of a function like devm_get_regmap_from_resource which would be akin to devm_get_and_ioremap_resource. A less ideal option would be to interface directly with MFD to get a regmap from the parent. This solution is even less ideal than both of the two suggestions, so is intentionally left in a separate commit after the initial MFD addition. Signed-off-by: Colin Foster --- drivers/mfd/ocelot-core.c | 9 +++++++++ include/soc/mscc/ocelot.h | 12 ++++++++++++ 2 files changed, 21 insertions(+) diff --git a/drivers/mfd/ocelot-core.c b/drivers/mfd/ocelot-core.c index a65619a8190b..09132ea52760 100644 --- a/drivers/mfd/ocelot-core.c +++ b/drivers/mfd/ocelot-core.c @@ -94,6 +94,15 @@ static struct regmap *ocelot_mfd_regmap_init(struct ocelot_mfd_core *core, return regmap; } +struct regmap *ocelot_mfd_get_regmap_from_resource(struct device *dev, + const struct resource *res) +{ + struct ocelot_mfd_core *core = dev_get_drvdata(dev); + + return ocelot_mfd_regmap_init(core, res); +} +EXPORT_SYMBOL(ocelot_mfd_get_regmap_from_resource); + int ocelot_mfd_init(struct ocelot_mfd_config *config) { struct device *dev = config->dev; diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index 3e9454b00562..a641c9cc6f3f 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -968,4 +968,16 @@ ocelot_mrp_del_ring_role(struct ocelot *ocelot, int port, } #endif +#if IS_ENABLED(CONFIG_MFD_OCELOT_CORE) +struct regmap *ocelot_mfd_get_regmap_from_resource(struct device *dev, + const struct resource *res); +#else +static inline regmap * +ocelot_mfd_get_regmap_from_resource(struct device *dev, + const struct resource *res) +{ + return NULL; +} +#endif + #endif