From patchwork Tue Nov 16 06:23:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12692703 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 29287C433EF for ; Tue, 16 Nov 2021 06:52:11 +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 E27F661B71 for ; Tue, 16 Nov 2021 06:52:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E27F661B71 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=SXJ+DBaek4fAGjNMDKnzzbAD4AMlyX7U5fUNzxhrd2A=; b=mwwH2Rm8tN8mRV 6kSnDVVwx415PG35EedK7xwkGB5nNV8K2LxQHhHetJxaeRmWcvuAuMEE2CPbNMVHgyXUzRz59Xdid jCYPXsp1ez9B3bSLl8XIu7Qg8GebYw9dwaZln5PRJ+xIJG/BIDAwSznZOEfuQNsqrpZeC1fMh6J/u cCjxkyoAm+TT83ZirvYbaDaYHoRmLXz+n4EOzFJMM9OZV+TRJ3a37Dr28s2wV5KZC+k8ZitWIFZsX s8ryaKEOsziXn732j8zjptFy0JE225xj+KRA3HW9jyEyCg3dO1+CJQDtiT00myCsZjo0+Kx7+lb8i kH6z5xnzJI4nxw1W7Q8A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mms5X-000Rg1-NP; Tue, 16 Nov 2021 06:37:06 +0000 Received: from mail-bn8nam12on2108.outbound.protection.outlook.com ([40.107.237.108] helo=NAM12-BN8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mmrsz-000Npu-Af for linux-arm-kernel@lists.infradead.org; Tue, 16 Nov 2021 06:24:06 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lEDPE5DAz5dgjysi+kPvXjqcQILu4PTDKQWZ3ovEmpppv+Tl2K+JlutbMU2rzZXx3oywB50NG0E66wjFc+65z4x0o2sfYfH7z4xQO3z9cZMhdiZnogqgsMVEztAKokDKKmfYD4RU9IbwGKwGGdgCYJCQA7aBag/h8bCF965JBSnJqIKjyc6YFQfdX8wovsnBgvkQqMz6OsOGB+uoT8x86QHUmIr5wUJSool1AxQ8NUUp7XyhHlX4xpJRWm0MIJfdKYeOhbkLnyFD+PB4PPg2gaLaxaN0V/eSZ7iydDaPgQSEpWdYY1+AquoZE/UPLeB27YoKqCkBxIjnsWQ7dM7xIg== 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=P9JsKGSxS8228sE3prsCueXlIcq72l2sV5T89kpzo+w=; b=kEWI+CMbkiMDRoyPTRsRI/+wzP2AbxEFCdcgI5aqI10uze4vdAj0Uetr1arop5P/IGapzCKJtqa6Hc+SxzJSAP0l2w5GNCvGlVwYS4dsUnn9uhoLWPyR7fMbKxJonG65OBVG9LZ/2ZmscM9mNojaGEolkZZO5a84sTBEZUDmqfKT5QazSGz4LL19rulmJcqkHyxnLngHfuSzIj7qaTWgKAcG4q3Djc91wAuK7cdKP5jeRv3O/0N3miG29NHJvdnZmww5jUvcku/8rCFX7UK1gyhyCadibScr11owCuesa6GjPt2NnDeewr6h70k4CT53abmUQMULXwR415TfqA0ODA== 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=P9JsKGSxS8228sE3prsCueXlIcq72l2sV5T89kpzo+w=; b=e8a1pkmpXenm9UcerxYfZaEXrl4Lsb9j7n44p54hUCic9cwYVV+GyDnF141YchVNk6wYjbBzfPuL8Bj4Ia7McqIihjD11bnGUrVExRlp8/EVNe5q1s0JEdIf6GLOARa5D6LYGPW24Eh8GsyIudx5m9IgCOsgof0DAXi0GqHawxk= 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 16/23] pinctrl: microchip-sgpio: change device tree matches to use nodes instead of device Date: Mon, 15 Nov 2021 22:23:21 -0800 Message-Id: <20211116062328.1949151-17-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:54 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 31ebb60a-afb1-4c9c-dc01-08d9a8c9aa38 X-MS-TrafficTypeDiagnostic: CO1PR10MB4722: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:60; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7JxSQuGsUDBv9BfrPg0uFYGQfsmmA+Y5GFmT9iJLvjAj0I5vGKVA+yVn3ssSi1xnpUf/P7XfedX/filvg9ykXMZwsnqSrGpA4QeUa73v8gtW7KwxhL2BOiu8Oj1ixOZ/epaAsMj/ghIzjxeHqju9jaWFCGMMFtK+wOIR065NZMMpDanwvIik7u9/KOMFKaAchq1Tou4E3LI23w7daL4QkN2ZohPLFCIu22jX7mP3TAqdIAFH8w0B1mA5GGGNkv9wQGIYqvxFRLNRoJlyRqq4CLAy/p1jvXoBki4Uj0F2ab2BcRktEQr/w5npGrgLvXS7Zil//jgf/+RVBVqVavZAeqZ4IxS+H1/3GzJ2aUo0tsuSfYLnbQ+P6eyapyoog8fA2QaU4vvgZk7hzgJ9ft8JaENB65k74xCY4xxGfXtA2eF7Rzi6vzi/DawKdSLtlcNdJO5jlgBqAPFIgcriJkSGPl7vJowwb0HADeR7R08kqmYBQ+Gwc58RnaXo1DNGGDyO27rZwNJPWpe9vSM9XAeqhC7vaPwO7pqpaNsxsZU74nDmgnSkLHS5dLBB4frnJqsshZ57q3pnKyIIKLyEwlQGzB4uf/plaNmCE0SGhKyWEwzqNFr887LOTry2pQoYv547IkPrjAgKIasXuPURcMRgnCe14hybMMixGs+HefyvTW0wGgAQ8IosLmO1keIxSnRo450TJqz4MALhDnPnGFerwg== 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-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ovQ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Oaj6zUwbZJiMlb0bHl64inMobCDlyP2ycSmeXz8wQb9YlG/2xUbgPRbF0C9GCJoHdm8afbpz8tIoAcQLU4IKbft5DThvf5zH0y4Ft52npRqlfG5oyKSuVNe2ZDKdAMf5yPPrLNiFmsR9dDnlQE9c+RNYU29AC2ofkZNXPs1mbXb+VXL2YOrkWkzzKm8KTDHObuHf0FyNJJW1BcELIvY+S4lfiG/Dk9UAn256YKnJlARaY85OtaW2agFL2A9HRMIxaYgUG2tLaw46SPmzNEFEZUhuhOD2vvMOC1o7ZjPxrZRcm3H19GflwNTxZZ5BKL+M/KaJuY4g171RnmNshsXureFVTBCSdAZAQmaWECykoKiJJE/h1XFaSip06Q4UAA522C+xBZiWQrHX8co8l5LzKUnbvYErXN9lKihp2wh/omQjtFhL9UGekBgnQSwfyAH0gGdO6DZ384kIVDb9io75xFMs7arGC1/IPEcAn1iDtCQ/LFvqpE7dqC/J7h3uHp4oqFGQec3Esodc1HCeWZpKNGLh1tlk5Rk+JjJHp7TFEtZsv3gLWwATL1KJbMC44WYyMNuypiTPAuQTEzuRTM8Iu8q9K0+E56BaR6j8HRGLG9CZ38= X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 31ebb60a-afb1-4c9c-dc01-08d9a8c9aa38 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.0060 (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: Hkld14XiAxcTxehD+SDIA7KAN25w3nKSduh+wazbFn0lW/+TUb+xeAWPUxD2tqzePUUcmJmshxkCZQef1t3JNxJjWcj1qzjiozjIAeEHVyk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4722 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211115_222405_400131_B29CBF70 X-CRM114-Status: GOOD ( 20.22 ) 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 microchip-sgpio is being updated to support being a device of a device. As such, standard devicetree parsing functions (device_property_count_u32) are being changed to a lower level functions like fwnode_property_count_u32. Signed-off-by: Colin Foster --- drivers/pinctrl/pinctrl-microchip-sgpio.c | 72 +++++++++++++++-------- 1 file changed, 46 insertions(+), 26 deletions(-) diff --git a/drivers/pinctrl/pinctrl-microchip-sgpio.c b/drivers/pinctrl/pinctrl-microchip-sgpio.c index 762611f76438..10736ef5c6ca 100644 --- a/drivers/pinctrl/pinctrl-microchip-sgpio.c +++ b/drivers/pinctrl/pinctrl-microchip-sgpio.c @@ -109,6 +109,7 @@ struct sgpio_bank { struct sgpio_priv { struct device *dev; + struct device_node *dev_node; struct sgpio_bank in; struct sgpio_bank out; u32 bitcount; @@ -524,12 +525,16 @@ static int microchip_sgpio_of_xlate(struct gpio_chip *gc, static int microchip_sgpio_get_ports(struct sgpio_priv *priv) { const char *range_property_name = "microchip,sgpio-port-ranges"; + struct device_node *dev_node = priv->dev_node; + const struct fwnode_handle *fwnode_handle; struct device *dev = priv->dev; u32 range_params[64]; int i, nranges, ret; + fwnode_handle = of_fwnode_handle(dev_node); + /* Calculate port mask */ - nranges = device_property_count_u32(dev, range_property_name); + nranges = fwnode_property_count_u32(fwnode_handle, range_property_name); if (nranges < 2 || nranges % 2 || nranges > ARRAY_SIZE(range_params)) { dev_err(dev, "%s port range: '%s' property\n", nranges == -EINVAL ? "Missing" : "Invalid", @@ -537,7 +542,7 @@ static int microchip_sgpio_get_ports(struct sgpio_priv *priv) return -EINVAL; } - ret = device_property_read_u32_array(dev, range_property_name, + ret = fwnode_property_read_u32_array(fwnode_handle, range_property_name, range_params, nranges); if (ret) { dev_err(dev, "failed to parse '%s' property: %d\n", @@ -804,11 +809,38 @@ static int microchip_sgpio_register_bank(struct device *dev, return ret; } +static const struct of_device_id microchip_sgpio_gpio_of_match[] = { + { + .compatible = "microchip,sparx5-sgpio", + .data = &properties_sparx5, + }, { + .compatible = "mscc,luton-sgpio", + .data = &properties_luton, + }, { + .compatible = "mscc,ocelot-sgpio", + .data = &properties_ocelot, + }, { + /* sentinel */ + } +}; + +static struct sgpio_properties +*microchip_sgpio_match_from_node(struct device_node *node) +{ + const struct of_device_id *match; + + match = of_match_node(of_match_ptr(microchip_sgpio_gpio_of_match), node); + if (match) + return (struct sgpio_properties *)match->data; + return NULL; +} + static int microchip_sgpio_probe(struct platform_device *pdev) { int div_clock = 0, ret, port, i, nbanks; struct device *dev = &pdev->dev; - struct fwnode_handle *fwnode; + struct device_node *node = dev_of_node(dev); + struct fwnode_handle *child, *fwnode; struct reset_control *reset; struct sgpio_priv *priv; struct clk *clk; @@ -825,18 +857,21 @@ static int microchip_sgpio_probe(struct platform_device *pdev) return -ENOMEM; priv->dev = dev; + priv->dev_node = node; + + fwnode = of_fwnode_handle(node); - reset = devm_reset_control_get_optional_shared(&pdev->dev, "switch"); + reset = devm_reset_control_get_optional_shared(dev, "switch"); if (IS_ERR(reset)) return dev_err_probe(dev, PTR_ERR(reset), "Failed to get reset\n"); reset_control_reset(reset); - clk = devm_clk_get(dev, NULL); + clk = devm_get_clk_from_child(dev, node, NULL); if (IS_ERR(clk)) return dev_err_probe(dev, PTR_ERR(clk), "Failed to get clock\n"); div_clock = clk_get_rate(clk); - if (device_property_read_u32(dev, "bus-frequency", &priv->clock)) + if (fwnode_property_read_u32(fwnode, "bus-frequency", &priv->clock)) priv->clock = 12500000; if (priv->clock == 0 || priv->clock > (div_clock / 2)) { dev_err(dev, "Invalid frequency %d\n", priv->clock); @@ -852,7 +887,7 @@ static int microchip_sgpio_probe(struct platform_device *pdev) return PTR_ERR(priv->regs); priv->regs_offset = 0; - priv->properties = device_get_match_data(dev); + priv->properties = microchip_sgpio_match_from_node(node); priv->in.is_input = true; /* Get rest of device properties */ @@ -860,17 +895,17 @@ static int microchip_sgpio_probe(struct platform_device *pdev) if (ret) return ret; - nbanks = device_get_child_node_count(dev); + nbanks = fwnode_get_child_node_count(fwnode); if (nbanks != 2) { dev_err(dev, "Must have 2 banks (have %d)\n", nbanks); return -EINVAL; } i = 0; - device_for_each_child_node(dev, fwnode) { - ret = microchip_sgpio_register_bank(dev, priv, fwnode, i++); + fwnode_for_each_child_node(fwnode, child) { + ret = microchip_sgpio_register_bank(dev, priv, child, i++); if (ret) { - fwnode_handle_put(fwnode); + fwnode_handle_put(child); return ret; } } @@ -892,21 +927,6 @@ static int microchip_sgpio_probe(struct platform_device *pdev) return 0; } -static const struct of_device_id microchip_sgpio_gpio_of_match[] = { - { - .compatible = "microchip,sparx5-sgpio", - .data = &properties_sparx5, - }, { - .compatible = "mscc,luton-sgpio", - .data = &properties_luton, - }, { - .compatible = "mscc,ocelot-sgpio", - .data = &properties_ocelot, - }, { - /* sentinel */ - } -}; - static struct platform_driver microchip_sgpio_pinctrl_driver = { .driver = { .name = "pinctrl-microchip-sgpio",