* [PATCH] i2c: meson: add configurable divider factors
@ 2019-03-22 13:49 ` Guillaume La Roque
0 siblings, 0 replies; 4+ messages in thread
From: glaroque @ 2019-03-22 13:49 UTC (permalink / raw)
To: hs, narmstrong, u-boot-amlogic, u-boot
This patch 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.
backport from linux:
931b18e92cd0 ("2c: meson: add configurable divider factors")
Signed-off-by: Guillaume La Roque <glaroque@baylibre.com>
---
drivers/i2c/meson_i2c.c | 30 +++++++++++++++++++++++++-----
1 file changed, 25 insertions(+), 5 deletions(-)
diff --git a/drivers/i2c/meson_i2c.c b/drivers/i2c/meson_i2c.c
index 7d06d95cf3..ee59bac123 100644
--- a/drivers/i2c/meson_i2c.c
+++ b/drivers/i2c/meson_i2c.c
@@ -41,7 +41,12 @@ struct i2c_regs {
u32 tok_rdata1;
};
+struct meson_i2c_data {
+ unsigned char div_factor;
+};
+
struct meson_i2c {
+ const struct meson_i2c_data *data;
struct clk clk;
struct i2c_regs *regs;
struct i2c_msg *msg; /* Current I2C message */
@@ -229,7 +234,7 @@ static int meson_i2c_set_bus_speed(struct udevice *bus, unsigned int speed)
if (IS_ERR_VALUE(clk_rate))
return -EINVAL;
- div = DIV_ROUND_UP(clk_rate, speed * 4);
+ div = DIV_ROUND_UP(clk_rate, speed * i2c->data->div_factor);
/* clock divider has 12 bits */
if (div >= (1 << 12)) {
@@ -253,6 +258,8 @@ static int meson_i2c_probe(struct udevice *bus)
struct meson_i2c *i2c = dev_get_priv(bus);
int ret;
+ i2c->data = (const struct meson_i2c_data *)dev_get_driver_data(bus);
+
ret = clk_get_by_index(bus, 0, &i2c->clk);
if (ret < 0)
return ret;
@@ -272,11 +279,24 @@ static const struct dm_i2c_ops meson_i2c_ops = {
.set_bus_speed = meson_i2c_set_bus_speed,
};
+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 udevice_id meson_i2c_ids[] = {
- { .compatible = "amlogic,meson6-i2c" },
- { .compatible = "amlogic,meson-gx-i2c" },
- { .compatible = "amlogic,meson-gxbb-i2c" },
- { }
+ {.compatible = "amlogic,meson6-i2c", .data = (ulong)&i2c_meson6_data},
+ {.compatible = "amlogic,meson-gx-i2c", .data = (ulong)&i2c_gxbb_data},
+ {.compatible = "amlogic,meson-gxbb-i2c", .data = (ulong)&i2c_gxbb_data},
+ {.compatible = "amlogic,meson-axg-i2c", .data = (ulong)&i2c_axg_data},
+ {}
};
U_BOOT_DRIVER(i2c_meson) = {
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* [U-Boot] [PATCH] i2c: meson: add configurable divider factors
@ 2019-03-22 13:49 ` Guillaume La Roque
0 siblings, 0 replies; 4+ messages in thread
From: Guillaume La Roque @ 2019-03-22 13:49 UTC (permalink / raw)
To: u-boot
This patch 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.
backport from linux:
931b18e92cd0 ("2c: meson: add configurable divider factors")
Signed-off-by: Guillaume La Roque <glaroque@baylibre.com>
---
drivers/i2c/meson_i2c.c | 30 +++++++++++++++++++++++++-----
1 file changed, 25 insertions(+), 5 deletions(-)
diff --git a/drivers/i2c/meson_i2c.c b/drivers/i2c/meson_i2c.c
index 7d06d95cf3..ee59bac123 100644
--- a/drivers/i2c/meson_i2c.c
+++ b/drivers/i2c/meson_i2c.c
@@ -41,7 +41,12 @@ struct i2c_regs {
u32 tok_rdata1;
};
+struct meson_i2c_data {
+ unsigned char div_factor;
+};
+
struct meson_i2c {
+ const struct meson_i2c_data *data;
struct clk clk;
struct i2c_regs *regs;
struct i2c_msg *msg; /* Current I2C message */
@@ -229,7 +234,7 @@ static int meson_i2c_set_bus_speed(struct udevice *bus, unsigned int speed)
if (IS_ERR_VALUE(clk_rate))
return -EINVAL;
- div = DIV_ROUND_UP(clk_rate, speed * 4);
+ div = DIV_ROUND_UP(clk_rate, speed * i2c->data->div_factor);
/* clock divider has 12 bits */
if (div >= (1 << 12)) {
@@ -253,6 +258,8 @@ static int meson_i2c_probe(struct udevice *bus)
struct meson_i2c *i2c = dev_get_priv(bus);
int ret;
+ i2c->data = (const struct meson_i2c_data *)dev_get_driver_data(bus);
+
ret = clk_get_by_index(bus, 0, &i2c->clk);
if (ret < 0)
return ret;
@@ -272,11 +279,24 @@ static const struct dm_i2c_ops meson_i2c_ops = {
.set_bus_speed = meson_i2c_set_bus_speed,
};
+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 udevice_id meson_i2c_ids[] = {
- { .compatible = "amlogic,meson6-i2c" },
- { .compatible = "amlogic,meson-gx-i2c" },
- { .compatible = "amlogic,meson-gxbb-i2c" },
- { }
+ {.compatible = "amlogic,meson6-i2c", .data = (ulong)&i2c_meson6_data},
+ {.compatible = "amlogic,meson-gx-i2c", .data = (ulong)&i2c_gxbb_data},
+ {.compatible = "amlogic,meson-gxbb-i2c", .data = (ulong)&i2c_gxbb_data},
+ {.compatible = "amlogic,meson-axg-i2c", .data = (ulong)&i2c_axg_data},
+ {}
};
U_BOOT_DRIVER(i2c_meson) = {
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] i2c: meson: add configurable divider factors
2019-03-22 13:49 ` [U-Boot] " Guillaume La Roque
@ 2019-04-10 14:50 ` Neil Armstrong
-1 siblings, 0 replies; 4+ messages in thread
From: Neil Armstrong @ 2019-04-10 14:50 UTC (permalink / raw)
To: Guillaume La Roque, hs, u-boot-amlogic, u-boot
On 22/03/2019 14:49, Guillaume La Roque wrote:
> This patch 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.
>
> backport from linux:
> 931b18e92cd0 ("2c: meson: add configurable divider factors")
>
> Signed-off-by: Guillaume La Roque <glaroque@baylibre.com>
> ---
> drivers/i2c/meson_i2c.c | 30 +++++++++++++++++++++++++-----
> 1 file changed, 25 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/i2c/meson_i2c.c b/drivers/i2c/meson_i2c.c
> index 7d06d95cf3..ee59bac123 100644
> --- a/drivers/i2c/meson_i2c.c
> +++ b/drivers/i2c/meson_i2c.c
> @@ -41,7 +41,12 @@ struct i2c_regs {
> u32 tok_rdata1;
> };
>
> +struct meson_i2c_data {
> + unsigned char div_factor;
> +};
> +
> struct meson_i2c {
> + const struct meson_i2c_data *data;
> struct clk clk;
> struct i2c_regs *regs;
> struct i2c_msg *msg; /* Current I2C message */
> @@ -229,7 +234,7 @@ static int meson_i2c_set_bus_speed(struct udevice *bus, unsigned int speed)
> if (IS_ERR_VALUE(clk_rate))
> return -EINVAL;
>
> - div = DIV_ROUND_UP(clk_rate, speed * 4);
> + div = DIV_ROUND_UP(clk_rate, speed * i2c->data->div_factor);
>
> /* clock divider has 12 bits */
> if (div >= (1 << 12)) {
> @@ -253,6 +258,8 @@ static int meson_i2c_probe(struct udevice *bus)
> struct meson_i2c *i2c = dev_get_priv(bus);
> int ret;
>
> + i2c->data = (const struct meson_i2c_data *)dev_get_driver_data(bus);
> +
> ret = clk_get_by_index(bus, 0, &i2c->clk);
> if (ret < 0)
> return ret;
> @@ -272,11 +279,24 @@ static const struct dm_i2c_ops meson_i2c_ops = {
> .set_bus_speed = meson_i2c_set_bus_speed,
> };
>
> +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 udevice_id meson_i2c_ids[] = {
> - { .compatible = "amlogic,meson6-i2c" },
> - { .compatible = "amlogic,meson-gx-i2c" },
> - { .compatible = "amlogic,meson-gxbb-i2c" },
> - { }
> + {.compatible = "amlogic,meson6-i2c", .data = (ulong)&i2c_meson6_data},
> + {.compatible = "amlogic,meson-gx-i2c", .data = (ulong)&i2c_gxbb_data},
> + {.compatible = "amlogic,meson-gxbb-i2c", .data = (ulong)&i2c_gxbb_data},
> + {.compatible = "amlogic,meson-axg-i2c", .data = (ulong)&i2c_axg_data},
> + {}
> };
>
> U_BOOT_DRIVER(i2c_meson) = {
>
Applied to u-boot-amlogic
Thanks
^ permalink raw reply [flat|nested] 4+ messages in thread* [U-Boot] [PATCH] i2c: meson: add configurable divider factors
@ 2019-04-10 14:50 ` Neil Armstrong
0 siblings, 0 replies; 4+ messages in thread
From: Neil Armstrong @ 2019-04-10 14:50 UTC (permalink / raw)
To: u-boot
On 22/03/2019 14:49, Guillaume La Roque wrote:
> This patch 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.
>
> backport from linux:
> 931b18e92cd0 ("2c: meson: add configurable divider factors")
>
> Signed-off-by: Guillaume La Roque <glaroque@baylibre.com>
> ---
> drivers/i2c/meson_i2c.c | 30 +++++++++++++++++++++++++-----
> 1 file changed, 25 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/i2c/meson_i2c.c b/drivers/i2c/meson_i2c.c
> index 7d06d95cf3..ee59bac123 100644
> --- a/drivers/i2c/meson_i2c.c
> +++ b/drivers/i2c/meson_i2c.c
> @@ -41,7 +41,12 @@ struct i2c_regs {
> u32 tok_rdata1;
> };
>
> +struct meson_i2c_data {
> + unsigned char div_factor;
> +};
> +
> struct meson_i2c {
> + const struct meson_i2c_data *data;
> struct clk clk;
> struct i2c_regs *regs;
> struct i2c_msg *msg; /* Current I2C message */
> @@ -229,7 +234,7 @@ static int meson_i2c_set_bus_speed(struct udevice *bus, unsigned int speed)
> if (IS_ERR_VALUE(clk_rate))
> return -EINVAL;
>
> - div = DIV_ROUND_UP(clk_rate, speed * 4);
> + div = DIV_ROUND_UP(clk_rate, speed * i2c->data->div_factor);
>
> /* clock divider has 12 bits */
> if (div >= (1 << 12)) {
> @@ -253,6 +258,8 @@ static int meson_i2c_probe(struct udevice *bus)
> struct meson_i2c *i2c = dev_get_priv(bus);
> int ret;
>
> + i2c->data = (const struct meson_i2c_data *)dev_get_driver_data(bus);
> +
> ret = clk_get_by_index(bus, 0, &i2c->clk);
> if (ret < 0)
> return ret;
> @@ -272,11 +279,24 @@ static const struct dm_i2c_ops meson_i2c_ops = {
> .set_bus_speed = meson_i2c_set_bus_speed,
> };
>
> +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 udevice_id meson_i2c_ids[] = {
> - { .compatible = "amlogic,meson6-i2c" },
> - { .compatible = "amlogic,meson-gx-i2c" },
> - { .compatible = "amlogic,meson-gxbb-i2c" },
> - { }
> + {.compatible = "amlogic,meson6-i2c", .data = (ulong)&i2c_meson6_data},
> + {.compatible = "amlogic,meson-gx-i2c", .data = (ulong)&i2c_gxbb_data},
> + {.compatible = "amlogic,meson-gxbb-i2c", .data = (ulong)&i2c_gxbb_data},
> + {.compatible = "amlogic,meson-axg-i2c", .data = (ulong)&i2c_axg_data},
> + {}
> };
>
> U_BOOT_DRIVER(i2c_meson) = {
>
Applied to u-boot-amlogic
Thanks
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-04-10 14:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-22 13:49 [PATCH] i2c: meson: add configurable divider factors glaroque
2019-03-22 13:49 ` [U-Boot] " Guillaume La Roque
2019-04-10 14:50 ` Neil Armstrong
2019-04-10 14:50 ` [U-Boot] " Neil Armstrong
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.