From patchwork Tue May 30 14:55:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 688028 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 E710EC7EE2F for ; Tue, 30 May 2023 14:58:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231268AbjE3O6k (ORCPT ); Tue, 30 May 2023 10:58:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232465AbjE3O6a (ORCPT ); Tue, 30 May 2023 10:58:30 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C5C1A7; Tue, 30 May 2023 07:58:09 -0700 (PDT) Received: from lhrpeml500005.china.huawei.com (unknown [172.18.147.206]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4QVwSW1tFNz6DB8r; Tue, 30 May 2023 22:55:55 +0800 (CST) Received: from SecurePC-101-06.china.huawei.com (10.122.247.231) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 30 May 2023 15:58:01 +0100 From: Jonathan Cameron To: CC: Wolfram Sang , Niyas Sait , Klaus Jensen , Andy Shevchenko , , Jeremy Kerr , Matt Johnston , Shesha Bhushan Sreenivasamurthy , , , "Viacheslav A . Dubeyko" Subject: [RFC PATCH v2 4/6] i2c: aspeed: switch to generic fw properties. Date: Tue, 30 May 2023 15:55:59 +0100 Message-ID: <20230530145601.2592-5-Jonathan.Cameron@huawei.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230530145601.2592-1-Jonathan.Cameron@huawei.com> References: <20230530145601.2592-1-Jonathan.Cameron@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.122.247.231] X-ClientProxiedBy: lhrpeml100001.china.huawei.com (7.191.160.183) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Moving over to generic firmware properties allows this driver to get closer to working out of the box with both device tree and other firmware options, such as ACPI via PRP0001. Tested only via QEMU emulation. Signed-off-by: Jonathan Cameron --- v2: - Added a proper patch description. - Updated to reflect optional nature of bus-frequency. --- drivers/i2c/busses/i2c-aspeed.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c index 4363bfe06f9b..353834d7ffd5 100644 --- a/drivers/i2c/busses/i2c-aspeed.c +++ b/drivers/i2c/busses/i2c-aspeed.c @@ -18,9 +18,8 @@ #include #include #include -#include -#include #include +#include #include #include @@ -975,7 +974,6 @@ MODULE_DEVICE_TABLE(of, aspeed_i2c_bus_of_table); static int aspeed_i2c_probe_bus(struct platform_device *pdev) { - const struct of_device_id *match; struct aspeed_i2c_bus *bus; struct clk *parent_clk; int irq, ret; @@ -1004,15 +1002,13 @@ static int aspeed_i2c_probe_bus(struct platform_device *pdev) reset_control_deassert(bus->rst); bus->bus_frequency = I2C_MAX_STANDARD_MODE_FREQ; - of_property_read_u32(pdev->dev.of_node, - "bus-frequency", &bus->bus_frequency); + device_property_read_u32(&pdev->dev, + "bus-frequency", &bus->bus_frequency); - match = of_match_node(aspeed_i2c_bus_of_table, pdev->dev.of_node); - if (!match) + bus->get_clk_reg_val = (u32 (*)(struct device *, u32)) + device_get_match_data(&pdev->dev); + if (!bus->get_clk_reg_val) bus->get_clk_reg_val = aspeed_i2c_24xx_get_clk_reg_val; - else - bus->get_clk_reg_val = (u32 (*)(struct device *, u32)) - match->data; /* Initialize the I2C adapter */ spin_lock_init(&bus->lock);