From patchwork Tue Nov 16 06:23:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12692696 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2B90C433EF for ; Tue, 16 Nov 2021 06:42:23 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8F49B6328F for ; Tue, 16 Nov 2021 06:42:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8F49B6328F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=in-advantage.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=CEToHHONAvbcVGxBq2crCbAehbyVFoEBi0TXV2ToDRc=; b=4ZX/eJxff81h5Y nx9aTBZyYpR2vJXpZ28dIB/A8h6n8oRLSCvAg19903IFkJvIm/aByJoAB8hIxPmd/dK9SrN3uU0Ru +RWhUEpiJRlKOOCZ1cSc67GjIpOxCVC9O07h/4XQWpPKQNG4X7Z82ljzV9fYNwf9Dn3aWOb4VTk1t ZCdRSV//xb7+H0PwWXP9OYe6UVFemIyHCjGSFUAL3i0Oh7R1MNLf5bSF3NsJOrDEPVjl8MIyUqAPM atS4Xh9ZDpSFgaMQk9kuu4xR28LdHBPkBLfU8gWURtRG72UJC/YhZmsNI/dhrF7C93F+u1G7Tv8We N5eWpI25mLnWrqonWCKQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mms70-000S26-At; Tue, 16 Nov 2021 06:38:37 +0000 Received: from mail-dm6nam10on2097.outbound.protection.outlook.com ([40.107.93.97] helo=NAM10-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mmrt0-000Ns5-0r for linux-arm-kernel@lists.infradead.org; Tue, 16 Nov 2021 06:24:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DtZwll/dLcSz+95bR61kzFvhjgKr8ySxM7kOn5e3ub1cKbJEuijKl+tHk2yiHCR4iM2SjgQ/A1YJnaczA1HiNSge/OWytSD6AfMsf0W9neOKpNWKsFRN3SdMEIgl5L1pBewH3pgkPtmgiUVHMo8zTOipcz4OjEWGStLLP8GnWXHgGLUsTxoL+P/7Cf46e7dh8CLckbBwLU9Ze0ukUhBid3iN6sgBmw/SSCmm6biz5QYy1Zhwt2ITWRvfKY8sCF2+Dn60+R2QLOPEDVt2ksPiGeV4+oKGduZWIRXPVYxAjNj0l2bcDYESpyc9IBcY+8BJqEpyPuwAQ+1bJf0dkFc52g== 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=zWV4Upnmxwx/szBkLrr9MPQtQbkM2sq/JfT0exYhS/I=; b=n2W7o4j8M+SibLlXlB/BO/O1Eei5Swbrkq1d1X49ICH0k+IDQbhRvPzWHSuhHwEoPcOMC7ASbImzyFzFArnSPpN6yMHzpIuLO57ORowTD51wMvz7SIFd05tjKTzNsiMs6p9kfCsfsDoRyXr8g1rGvPiFwjRqQisX3SC1LL3p4aIrJOSfKpyB4fegG7zpLxWnvt3yiEDDc2GgmAb4ZOuQv+fnhCIAUZ0gOL/MGE6vXqA0pHxrbM89a42nv0GX9QzQWbxbOn3yw6MfSJNUyL0I4hJLep7W1diAHHeGcIq4Cia8Zv/USDbCDYCYBmQEplYbYzdr9u1j5x+6wUEb4K2Gbw== 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=zWV4Upnmxwx/szBkLrr9MPQtQbkM2sq/JfT0exYhS/I=; b=x8Ak4PN7NRKlmCadBLeVsjIOGPYeHTHHirUMOUlY1B/EfM0Saf4/cNH6qIECeaPkbsDp58JZ0DeNvA2xPQeIVJi4jHxf147++yXeENgbIbNZFmZdi7l9KrXIL1DVJ5MBG7gN5YZef6RPXj2gWYn+chHZD6jq0vSyxwni8Wt4MYA= 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 CO1PR10MB4722.namprd10.prod.outlook.com (2603:10b6:303:9e::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.27; Tue, 16 Nov 2021 06:23:55 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::6430:b20:8805:cd9f]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::6430:b20:8805:cd9f%5]) with mapi id 15.20.4690.026; Tue, 16 Nov 2021 06:23:55 +0000 From: Colin Foster To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Vladimir Oltean , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Andrew Lunn , Vivien Didelot , Florian Fainelli , "David S. Miller" , Jakub Kicinski , Ioana Ciornei , Heiner Kallweit , Russell King , Lars Povlsen , Steen Hegelund , Linus Walleij , Philipp Zabel , Heikki Krogerus , Andy Shevchenko Subject: [RFC PATCH v4 net-next 17/23] pinctrl: microchip-sgpio: expose microchip_sgpio_core_probe interface Date: Mon, 15 Nov 2021 22:23:22 -0800 Message-Id: <20211116062328.1949151-18-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211116062328.1949151-1-colin.foster@in-advantage.com> References: <20211116062328.1949151-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MWHPR11CA0028.namprd11.prod.outlook.com (2603:10b6:300:115::14) To MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) MIME-Version: 1.0 Received: from localhost.localdomain (67.185.175.147) by MWHPR11CA0028.namprd11.prod.outlook.com (2603:10b6:300:115::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.26 via Frontend Transport; Tue, 16 Nov 2021 06:23:55 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1ad762ad-df57-4e9e-b8f0-08d9a8c9aab9 X-MS-TrafficTypeDiagnostic: CO1PR10MB4722: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:849; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kS45hXHanBSlrfzYedCDAM6T4juGP2HJc2eopBxckGMye7Kka86o/iSW7kicCtTDgvD4gvWZkt3+ZMdVIUPQV441jgReRZxRIn6SQdNGj+F5oSvZu4wS0L1c1+HzfrBkXFwkCyfTzwSldcPpG3uk6Vs6bvNj3I/Ni1ilsA+hY65GUWAUwnZrNEruJtLl78RCVyptUzBTOdFTPJvNQEdZ6gVr7kGJV/LLk5Rt/M9CCNNyLVhk1anzUapuA0BJHmJGI7e6BLMCUxOxkn+9PW8UT+5GdONqsnCYPzoMwWxHgU7KMgTaVTmTAKY+1HOqUT9bhDxtlsWjg1LRKK2lfNZOcgMSul7GIYA6YcAlAMLFzQM8Lg6DmrSKioJ+sm0sXr1iFGJhM8xhOcLp66hat3VDhbh3rUPlgg+jFVi/R9ODhy3ymrgMhlO36PBeU4q2dGm9+N1M+2GGmKwtTwjqRI5k82P4O64FlZnqxdTkphCoO2FWHDqUbEpKjloMRSIKlIemo3PGYn7KP2cd4EYmGD68/PqdAIObZEpOVmNMt3YvkAmTS7ms0PE55gpSRYStTxcDih5p6YhZ/gtH8riMuYG4VOq3SUw4zF/kTQATr/fZyWxnm4HYjjWNGg/4mvTOOcKiAfEK40z+Zdq6vthRMhZodnAEOiMotPs43pUPSWfQgYNcfnrSRl/bXsPTeZAjSwqMLTKsDLA0HQxmcIZimFs9Rg== 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:(376002)(136003)(366004)(396003)(39840400004)(346002)(83380400001)(6666004)(54906003)(5660300002)(2906002)(7416002)(6486002)(44832011)(956004)(86362001)(2616005)(4326008)(316002)(508600001)(8676002)(186003)(6512007)(38100700002)(38350700002)(1076003)(8936002)(52116002)(26005)(6506007)(36756003)(66556008)(66476007)(66946007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSp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51gGQoQr9VajPYtQviMwkQcONtPXc/lM75Rw05DSoqgpwP9CLA807Oq5mQTW5d7qUehXYrWZq+KeGWTBhSoIr0WRxcmbYC2rJDayU/oVqoWx5iI7PLEATW/dzlFtCYgCRHsDUFcowxRg7EvCJT5dvTr2GZigZOKfYNYSxaGWCOgRqMyqvqAj04buJc/XCdqSWqyV/E3jSbD5LdOmm+Jfd1hVpKiaA3Hb3v/OJqUhUhRFJY7hZUwQn82nMt6J2vxMrowqGXnscbFJIz9uXsI7O+W5P/JdAYsGHcH3bkUDRJDb53OnlNx1xUIXsmkhetrhPonFTZ5nWLoD0qG2LUvja5iStIXKFTxVjSobxy5WwwN6fPEKUgvLezWHibEKxM/ybvXhw73Z7sZ5UcVSmG5t0SBIBEj0lHIfxzWujibD3qEyl/ZgkB/9gjJ8iKEeiTWUqoRbSXDwFpNQBa24QqQ+aAJWQv71R6osPAgbr0bEn5+jUURU4SfRad8CttyHXWP2le4zcSpHFsonNqc1vUb7/c7AF4vt+cRD7or2zGfrI1fUHgXQfx64Kt8KKvDgyrNUlmzqWTKAlAgwUANmTFabsTP13l+waPYUfvA6GkLhxIn4gmKkmW1+0NifKWoBV7kQEwjmf6t+L2Vf575wwzff3w= X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1ad762ad-df57-4e9e-b8f0-08d9a8c9aab9 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2021 06:23:55.7515 (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: MxeY9zuyQ1XCkUDoXbK+zm5lWwLpvZxR7jB/BYE0c6m3cZeapaVdbc9SvJJw1lwaKSWeBniOGzu2mjoC/p40hWg6KUilgA0kaMxmVF2aeSs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4722 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211115_222406_096072_3BD84B35 X-CRM114-Status: GOOD ( 16.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Allow external drivers to hook into microchip_sgpio with custom regmaps. In the case where the sgpio is part of an external chip like a VSC7512 controlled over SPI, a pre-existing SPI regmap can be used. Signed-off-by: Colin Foster --- drivers/pinctrl/pinctrl-microchip-sgpio.c | 46 ++++++++++++++--------- include/soc/mscc/ocelot.h | 11 ++++++ 2 files changed, 40 insertions(+), 17 deletions(-) diff --git a/drivers/pinctrl/pinctrl-microchip-sgpio.c b/drivers/pinctrl/pinctrl-microchip-sgpio.c index 10736ef5c6ca..2ddee50707d0 100644 --- a/drivers/pinctrl/pinctrl-microchip-sgpio.c +++ b/drivers/pinctrl/pinctrl-microchip-sgpio.c @@ -835,22 +835,15 @@ static struct sgpio_properties return NULL; } -static int microchip_sgpio_probe(struct platform_device *pdev) +int microchip_sgpio_core_probe(struct device *dev, struct device_node *node, + struct regmap *regmap, u32 offset) { int div_clock = 0, ret, port, i, nbanks; - struct device *dev = &pdev->dev; - struct device_node *node = dev_of_node(dev); struct fwnode_handle *child, *fwnode; struct reset_control *reset; struct sgpio_priv *priv; struct clk *clk; - u32 __iomem *regs; u32 val; - struct regmap_config regmap_config = { - .reg_bits = 32, - .val_bits = 32, - .reg_stride = 4, - }; priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) @@ -878,18 +871,14 @@ static int microchip_sgpio_probe(struct platform_device *pdev) return -EINVAL; } - regs = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(regs)) - return PTR_ERR(regs); - - priv->regs = devm_regmap_init_mmio(dev, regs, ®map_config); - if (IS_ERR(priv->regs)) - return PTR_ERR(priv->regs); - + priv->regs = regmap; priv->regs_offset = 0; priv->properties = microchip_sgpio_match_from_node(node); priv->in.is_input = true; + if (!priv->properties) + return dev_err_probe(dev, -EINVAL, "No property match found\n"); + /* Get rest of device properties */ ret = microchip_sgpio_get_ports(priv); if (ret) @@ -926,6 +915,29 @@ static int microchip_sgpio_probe(struct platform_device *pdev) return 0; } +EXPORT_SYMBOL(microchip_sgpio_core_probe); + +static int microchip_sgpio_probe(struct platform_device *pdev) +{ + struct regmap_config regmap_config = {0}; + struct device *dev = &pdev->dev; + struct regmap *regmap; + u32 __iomem *regs; + + regmap_config.reg_bits = 32; + regmap_config.val_bits = 32; + regmap_config.reg_stride = 4; + + regs = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(regs)) + return PTR_ERR(regs); + + regmap = devm_regmap_init_mmio(dev, regs, ®map_config); + if (IS_ERR(regmap)) + return PTR_ERR(regmap); + + return microchip_sgpio_core_probe(dev, dev->of_node, regmap, 0); +} static struct platform_driver microchip_sgpio_pinctrl_driver = { .driver = { diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index 14acfe82d0a4..8c27f8f79fff 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -930,4 +930,15 @@ int ocelot_pinctrl_core_probe(struct device *dev, } #endif +#if IS_ENABLED(CONFIG_PINCTRL_MICROCHIP_SGPIO) +int microchip_sgpio_core_probe(struct device *dev, struct device_node *node, + struct regmap *regmap, u32 offset); +#else +int microchip_sgpio_core_probe(struct device *dev, struct device_node *node, + struct regmap *regmap, u32 offset) +{ + return -EOPNOTSUPP; +} +#endif + #endif