From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756219AbdKQNC5 (ORCPT ); Fri, 17 Nov 2017 08:02:57 -0500 Received: from mail-wr0-f196.google.com ([209.85.128.196]:33739 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756177AbdKQNCt (ORCPT ); Fri, 17 Nov 2017 08:02:49 -0500 X-Google-Smtp-Source: AGs4zMYbJHH9xhGHxjfiycBO8SvElCEsN7qbTk0W7yo+tYZDr2mSDZXiJY0YncPT2VZSwSzQoF+4xw== Subject: Re: [PATCH 2/5] i2c: meson: add configurable divider factors To: Yixun Lan , Wolfram Sang , Rob Herring , Mark Rutland , linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, Kevin Hilman Cc: Jerome Brunet , Carlo Caione , Jian Hu , linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20171117080236.32504-1-yixun.lan@amlogic.com> <20171117080236.32504-3-yixun.lan@amlogic.com> From: Neil Armstrong Organization: Baylibre Message-ID: <4ad7bd82-7913-e064-71f4-285250942ab9@baylibre.com> Date: Fri, 17 Nov 2017 14:02:46 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <20171117080236.32504-3-yixun.lan@amlogic.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 17/11/2017 09:02, Yixun Lan wrote: > From: Jian Hu > > This patch try to add support for I2C controller in Meson-AXG SoC, > Due to the IP changes between I2C controller, we need to introduce > a compatible data to make the divider factor configurable. > > Signed-off-by: Jian Hu > Signed-off-by: Yixun Lan > --- > drivers/i2c/busses/i2c-meson.c | 32 ++++++++++++++++++++++++++++---- > 1 file changed, 28 insertions(+), 4 deletions(-) > > diff --git a/drivers/i2c/busses/i2c-meson.c b/drivers/i2c/busses/i2c-meson.c > index 88d15b92ec35..517f2cddeff3 100644 > --- a/drivers/i2c/busses/i2c-meson.c > +++ b/drivers/i2c/busses/i2c-meson.c > @@ -16,6 +16,7 @@ > #include > #include > #include > +#include > #include > #include > > @@ -57,6 +58,10 @@ enum { > STATE_WRITE, > }; > > +struct meson_i2c_data { > + unsigned char div_factor; > +}; > + > /** > * struct meson_i2c - Meson I2C device private data > * > @@ -93,6 +98,8 @@ struct meson_i2c { > struct completion done; > u32 tokens[2]; > int num_tokens; > + > + struct meson_i2c_data *data; > }; > > static void meson_i2c_set_mask(struct meson_i2c *i2c, int reg, u32 mask, > @@ -128,7 +135,7 @@ static void meson_i2c_set_clk_div(struct meson_i2c *i2c, unsigned int freq) > unsigned long clk_rate = clk_get_rate(i2c->clk); > unsigned int div; > > - div = DIV_ROUND_UP(clk_rate, freq * 4); > + div = DIV_ROUND_UP(clk_rate, freq * i2c->data->div_factor); > > /* clock divider has 12 bits */ > if (div >= (1 << 12)) { > @@ -376,6 +383,9 @@ static int meson_i2c_probe(struct platform_device *pdev) > spin_lock_init(&i2c->lock); > init_completion(&i2c->done); > > + i2c->data = (struct meson_i2c_data *) > + of_device_get_match_data(&pdev->dev); > + > i2c->clk = devm_clk_get(&pdev->dev, NULL); > if (IS_ERR(i2c->clk)) { > dev_err(&pdev->dev, "can't get device clock\n"); > @@ -440,11 +450,25 @@ static int meson_i2c_remove(struct platform_device *pdev) > return 0; > } > > +static const struct meson_i2c_data i2c_meson6_data = { > + .div_factor = 4, > +}; > + > +static const struct meson_i2c_data i2c_gxbb_data = { > + .div_factor = 4, > +}; > + > +static const struct meson_i2c_data i2c_axg_data = { > + .div_factor = 3, > +}; > + > static const struct of_device_id meson_i2c_match[] = { > - { .compatible = "amlogic,meson6-i2c" }, > - { .compatible = "amlogic,meson-gxbb-i2c" }, > - { }, > + { .compatible = "amlogic,meson6-i2c", .data = &i2c_meson6_data }, > + { .compatible = "amlogic,meson-gxbb-i2c", .data = &i2c_gxbb_data }, > + { .compatible = "amlogic,meson-axg-i2c", .data = &i2c_axg_data }, > + {}, > }; > + > MODULE_DEVICE_TABLE(of, meson_i2c_match); > > static struct platform_driver meson_i2c_driver = { > Reviewed-by: Neil Armstrong