public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy@kernel.org>
To: Binbin Zhou <zhoubinbin@loongson.cn>
Cc: Wolfram Sang <wsa@kernel.org>,
	Wolfram Sang <wsa+renesas@sang-engineering.com>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	linux-i2c@vger.kernel.org, loongarch@lists.linux.dev,
	devicetree@vger.kernel.org, Huacai Chen <chenhuacai@loongson.cn>,
	WANG Xuerui <kernel@xen0n.name>, Arnd Bergmann <arnd@arndb.de>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Jianmin Lv <lvjianmin@loongson.cn>
Subject: Re: [PATCH V6 1/4] i2c: gpio: Add support on ACPI-based system
Date: Tue, 13 Dec 2022 16:42:42 +0200	[thread overview]
Message-ID: <Y5iPYiZJP4A26NMm@smile.fi.intel.com> (raw)
In-Reply-To: <de51467e355b4bae2f8aa18f833f30f9fe50de12.1670897253.git.zhoubinbin@loongson.cn>

On Tue, Dec 13, 2022 at 04:26:55PM +0800, Binbin Zhou wrote:
> Add support for the ACPI-based device registration, so that the driver
> can be also enabled through ACPI table.

LGTM now,
Reviewed-by: Andy Shevchenko <andy@kernel.org>

> Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
> ---
>  drivers/i2c/busses/i2c-gpio.c | 28 ++++++++++++++++++----------
>  1 file changed, 18 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c
> index 0e4385a9bcf7..680936234ef8 100644
> --- a/drivers/i2c/busses/i2c-gpio.c
> +++ b/drivers/i2c/busses/i2c-gpio.c
> @@ -13,9 +13,9 @@
>  #include <linux/init.h>
>  #include <linux/interrupt.h>
>  #include <linux/module.h>
> -#include <linux/of.h>
>  #include <linux/platform_data/i2c-gpio.h>
>  #include <linux/platform_device.h>
> +#include <linux/property.h>
>  #include <linux/slab.h>
>  
>  struct i2c_gpio_private_data {
> @@ -300,22 +300,23 @@ static inline void i2c_gpio_fault_injector_init(struct platform_device *pdev) {}
>  static inline void i2c_gpio_fault_injector_exit(struct platform_device *pdev) {}
>  #endif /* CONFIG_I2C_GPIO_FAULT_INJECTOR*/
>  
> -static void of_i2c_gpio_get_props(struct device_node *np,
> -				  struct i2c_gpio_platform_data *pdata)
> +/* Get i2c-gpio properties from DT or ACPI table */
> +static void i2c_gpio_get_properties(struct device *dev,
> +				     struct i2c_gpio_platform_data *pdata)
>  {
>  	u32 reg;
>  
> -	of_property_read_u32(np, "i2c-gpio,delay-us", &pdata->udelay);
> +	device_property_read_u32(dev, "i2c-gpio,delay-us", &pdata->udelay);
>  
> -	if (!of_property_read_u32(np, "i2c-gpio,timeout-ms", &reg))
> +	if (!device_property_read_u32(dev, "i2c-gpio,timeout-ms", &reg))
>  		pdata->timeout = msecs_to_jiffies(reg);
>  
>  	pdata->sda_is_open_drain =
> -		of_property_read_bool(np, "i2c-gpio,sda-open-drain");
> +		device_property_read_bool(dev, "i2c-gpio,sda-open-drain");
>  	pdata->scl_is_open_drain =
> -		of_property_read_bool(np, "i2c-gpio,scl-open-drain");
> +		device_property_read_bool(dev, "i2c-gpio,scl-open-drain");
>  	pdata->scl_is_output_only =
> -		of_property_read_bool(np, "i2c-gpio,scl-output-only");
> +		device_property_read_bool(dev, "i2c-gpio,scl-output-only");
>  }
>  
>  static struct gpio_desc *i2c_gpio_get_desc(struct device *dev,
> @@ -373,8 +374,8 @@ static int i2c_gpio_probe(struct platform_device *pdev)
>  	bit_data = &priv->bit_data;
>  	pdata = &priv->pdata;
>  
> -	if (np) {
> -		of_i2c_gpio_get_props(np, pdata);
> +	if (dev_fwnode(dev)) {
> +		i2c_gpio_get_properties(dev, pdata);
>  	} else {
>  		/*
>  		 * If all platform data settings are zero it is OK
> @@ -489,10 +490,17 @@ static const struct of_device_id i2c_gpio_dt_ids[] = {
>  
>  MODULE_DEVICE_TABLE(of, i2c_gpio_dt_ids);
>  
> +static const struct acpi_device_id i2c_gpio_acpi_match[] = {
> +	{ "LOON0005" }, /* LoongArch */
> +	{ }
> +};
> +MODULE_DEVICE_TABLE(acpi, i2c_gpio_acpi_match);
> +
>  static struct platform_driver i2c_gpio_driver = {
>  	.driver		= {
>  		.name	= "i2c-gpio",
>  		.of_match_table	= i2c_gpio_dt_ids,
> +		.acpi_match_table = i2c_gpio_acpi_match,
>  	},
>  	.probe		= i2c_gpio_probe,
>  	.remove		= i2c_gpio_remove,
> -- 
> 2.31.1
> 

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2022-12-13 14:43 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-13  8:26 [PATCH V6 0/4] i2c: ls2x: Add support for the Loongson-2K/LS7A I2C controller Binbin Zhou
2022-12-13  8:26 ` [PATCH V6 1/4] i2c: gpio: Add support on ACPI-based system Binbin Zhou
2022-12-13 14:42   ` Andy Shevchenko [this message]
2022-12-13  8:26 ` [PATCH V6 2/4] dt-bindings: i2c: add Loongson LS2X I2C controller Binbin Zhou
2022-12-13  8:26 ` [PATCH V6 3/4] i2c: ls2x: Add driver for Loongson-2K/LS7A " Binbin Zhou
2022-12-13 14:58   ` Andy Shevchenko
2022-12-14  9:45     ` Binbin Zhou
2022-12-13  8:27 ` [PATCH V6 4/4] LoongArch: Enable LS2X I2C in loongson3_defconfig Binbin Zhou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y5iPYiZJP4A26NMm@smile.fi.intel.com \
    --to=andy@kernel.org \
    --cc=arnd@arndb.de \
    --cc=chenhuacai@loongson.cn \
    --cc=devicetree@vger.kernel.org \
    --cc=kernel@xen0n.name \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=loongarch@lists.linux.dev \
    --cc=lvjianmin@loongson.cn \
    --cc=mika.westerberg@linux.intel.com \
    --cc=robh+dt@kernel.org \
    --cc=wsa+renesas@sang-engineering.com \
    --cc=wsa@kernel.org \
    --cc=zhoubinbin@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox