* [U-Boot] [PATCH 1/2] i2c-mux: pca954x: support pca9646 i2c switch
@ 2018-07-17 12:38 Peng Fan
2018-07-17 12:38 ` [U-Boot] [PATCH 2/2] i2c: imx_lpi2c: add uclass api support Peng Fan
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Peng Fan @ 2018-07-17 12:38 UTC (permalink / raw)
To: u-boot
Add the PCA9646 support, which is 2-wire bus switch and buffered 4-channel.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/i2c/muxes/pca954x.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/i2c/muxes/pca954x.c b/drivers/i2c/muxes/pca954x.c
index 4debc03957..ab8b4000af 100644
--- a/drivers/i2c/muxes/pca954x.c
+++ b/drivers/i2c/muxes/pca954x.c
@@ -17,7 +17,8 @@ DECLARE_GLOBAL_DATA_PTR;
enum pca_type {
PCA9544,
PCA9547,
- PCA9548
+ PCA9548,
+ PCA9646
};
struct chip_desc {
@@ -51,6 +52,11 @@ static const struct chip_desc chips[] = {
.muxtype = pca954x_isswi,
.width = 8,
},
+ [PCA9646] = {
+ .enable = 0x0,
+ .muxtype = pca954x_isswi,
+ .width = 4,
+ },
};
static int pca954x_deselect(struct udevice *mux, struct udevice *bus,
@@ -86,6 +92,7 @@ static const struct udevice_id pca954x_ids[] = {
{ .compatible = "nxp,pca9544", .data = PCA9544 },
{ .compatible = "nxp,pca9547", .data = PCA9547 },
{ .compatible = "nxp,pca9548", .data = PCA9548 },
+ { .compatible = "nxp,pca9646", .data = PCA9646 },
{ }
};
--
2.14.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH 2/2] i2c: imx_lpi2c: add uclass api support
2018-07-17 12:38 [U-Boot] [PATCH 1/2] i2c-mux: pca954x: support pca9646 i2c switch Peng Fan
@ 2018-07-17 12:38 ` Peng Fan
2018-08-06 12:18 ` Anatolij Gustschin
2018-08-06 12:40 ` Anatolij Gustschin
2018-08-06 9:30 ` [U-Boot] [PATCH 1/2] i2c-mux: pca954x: support pca9646 i2c switch Peng Fan
` (2 subsequent siblings)
3 siblings, 2 replies; 7+ messages in thread
From: Peng Fan @ 2018-07-17 12:38 UTC (permalink / raw)
To: u-boot
Use uclass clk api to get per clk when CONFIG_CLK enabled.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/i2c/imx_lpi2c.c | 47 ++++++++++++++++++++++++++++++++++++++++-------
include/imx_lpi2c.h | 3 +++
2 files changed, 43 insertions(+), 7 deletions(-)
diff --git a/drivers/i2c/imx_lpi2c.c b/drivers/i2c/imx_lpi2c.c
index ff07ca34aa..6c343072fb 100644
--- a/drivers/i2c/imx_lpi2c.c
+++ b/drivers/i2c/imx_lpi2c.c
@@ -261,8 +261,14 @@ static int bus_i2c_write(struct udevice *bus, u32 chip, u8 *buf, int len)
}
+u32 __weak imx_get_i2cclk(u32 i2c_num)
+{
+ return 0;
+}
+
static int bus_i2c_set_bus_speed(struct udevice *bus, int speed)
{
+ struct imx_lpi2c_bus *i2c_bus = dev_get_priv(bus);
struct imx_lpi2c_reg *regs;
u32 val;
u32 preescale = 0, best_pre = 0, clkhi = 0;
@@ -273,9 +279,18 @@ static int bus_i2c_set_bus_speed(struct udevice *bus, int speed)
int i;
regs = (struct imx_lpi2c_reg *)devfdt_get_addr(bus);
- clock_rate = imx_get_i2cclk(bus->seq);
- if (!clock_rate)
- return -EPERM;
+
+ if (IS_ENABLED(CONFIG_CLK)) {
+ clock_rate = clk_get_rate(&i2c_bus->per_clk);
+ if (clock_rate <= 0) {
+ dev_err(bus, "Failed to get i2c clk: %d\n", clock_rate);
+ return clock_rate;
+ }
+ } else {
+ clock_rate = imx_get_i2cclk(bus->seq);
+ if (!clock_rate)
+ return -EPERM;
+ }
mode = (readl(®s->mcr) & LPI2C_MCR_MEN_MASK) >> LPI2C_MCR_MEN_SHIFT;
/* disable master mode */
@@ -417,6 +432,11 @@ static int imx_lpi2c_set_bus_speed(struct udevice *bus, unsigned int speed)
return bus_i2c_set_bus_speed(bus, speed);
}
+__weak int enable_i2c_clk(unsigned char enable, unsigned int i2c_num)
+{
+ return 0;
+}
+
static int imx_lpi2c_probe(struct udevice *bus)
{
struct imx_lpi2c_bus *i2c_bus = dev_get_priv(bus);
@@ -440,10 +460,23 @@ static int imx_lpi2c_probe(struct udevice *bus)
return ret;
}
- /* To i.MX7ULP, only i2c4-7 can be handled by A7 core */
- ret = enable_i2c_clk(1, bus->seq);
- if (ret < 0)
- return ret;
+ if (IS_ENABLED(CONFIG_CLK)) {
+ ret = clk_get_by_name(bus, "per", &i2c_bus->per_clk);
+ if (ret) {
+ dev_err(bus, "Failed to get per clk\n");
+ return ret;
+ }
+ ret = clk_enable(&i2c_bus->per_clk);
+ if (ret) {
+ dev_err(bus, "Failed to enable per clk\n");
+ return ret;
+ }
+ } else {
+ /* To i.MX7ULP, only i2c4-7 can be handled by A7 core */
+ ret = enable_i2c_clk(1, bus->seq);
+ if (ret < 0)
+ return ret;
+ }
ret = bus_i2c_init(bus, 100000);
if (ret < 0)
diff --git a/include/imx_lpi2c.h b/include/imx_lpi2c.h
index 3fbb40bdd1..2700e5f876 100644
--- a/include/imx_lpi2c.h
+++ b/include/imx_lpi2c.h
@@ -8,6 +8,8 @@
#ifndef __IMX_LPI2C_H__
#define __IMX_LPI2C_H__
+#include <clk.h>
+
struct imx_lpi2c_bus {
int index;
ulong base;
@@ -15,6 +17,7 @@ struct imx_lpi2c_bus {
int speed;
struct i2c_pads_info *pads_info;
struct udevice *bus;
+ struct clk per_clk;
};
struct imx_lpi2c_reg {
--
2.14.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH 1/2] i2c-mux: pca954x: support pca9646 i2c switch
2018-07-17 12:38 [U-Boot] [PATCH 1/2] i2c-mux: pca954x: support pca9646 i2c switch Peng Fan
2018-07-17 12:38 ` [U-Boot] [PATCH 2/2] i2c: imx_lpi2c: add uclass api support Peng Fan
@ 2018-08-06 9:30 ` Peng Fan
2018-08-06 12:08 ` Anatolij Gustschin
2018-08-06 12:40 ` Anatolij Gustschin
3 siblings, 0 replies; 7+ messages in thread
From: Peng Fan @ 2018-08-06 9:30 UTC (permalink / raw)
To: u-boot
Hi,
Ping.
> -----Original Message-----
> From: Peng Fan
> Sent: 2018年7月17日 20:39
> To: hs at denx.de
> Cc: u-boot at lists.denx.de; Peng Fan <peng.fan@nxp.com>
> Subject: [PATCH 1/2] i2c-mux: pca954x: support pca9646 i2c switch
>
> Add the PCA9646 support, which is 2-wire bus switch and buffered 4-channel.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
> drivers/i2c/muxes/pca954x.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/muxes/pca954x.c b/drivers/i2c/muxes/pca954x.c index
> 4debc03957..ab8b4000af 100644
> --- a/drivers/i2c/muxes/pca954x.c
> +++ b/drivers/i2c/muxes/pca954x.c
> @@ -17,7 +17,8 @@ DECLARE_GLOBAL_DATA_PTR; enum pca_type {
> PCA9544,
> PCA9547,
> - PCA9548
> + PCA9548,
> + PCA9646
> };
>
> struct chip_desc {
> @@ -51,6 +52,11 @@ static const struct chip_desc chips[] = {
> .muxtype = pca954x_isswi,
> .width = 8,
> },
> + [PCA9646] = {
> + .enable = 0x0,
> + .muxtype = pca954x_isswi,
> + .width = 4,
> + },
> };
>
> static int pca954x_deselect(struct udevice *mux, struct udevice *bus, @@
> -86,6 +92,7 @@ static const struct udevice_id pca954x_ids[] = {
> { .compatible = "nxp,pca9544", .data = PCA9544 },
> { .compatible = "nxp,pca9547", .data = PCA9547 },
> { .compatible = "nxp,pca9548", .data = PCA9548 },
> + { .compatible = "nxp,pca9646", .data = PCA9646 },
> { }
> };
>
> --
> 2.14.1
Thanks,
Peng
^ permalink raw reply [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH 1/2] i2c-mux: pca954x: support pca9646 i2c switch
2018-07-17 12:38 [U-Boot] [PATCH 1/2] i2c-mux: pca954x: support pca9646 i2c switch Peng Fan
2018-07-17 12:38 ` [U-Boot] [PATCH 2/2] i2c: imx_lpi2c: add uclass api support Peng Fan
2018-08-06 9:30 ` [U-Boot] [PATCH 1/2] i2c-mux: pca954x: support pca9646 i2c switch Peng Fan
@ 2018-08-06 12:08 ` Anatolij Gustschin
2018-08-06 12:40 ` Anatolij Gustschin
3 siblings, 0 replies; 7+ messages in thread
From: Anatolij Gustschin @ 2018-08-06 12:08 UTC (permalink / raw)
To: u-boot
On Tue, 17 Jul 2018 20:38:32 +0800
Peng Fan peng.fan at nxp.com wrote:
> Add the PCA9646 support, which is 2-wire bus switch and buffered 4-channel.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Anatolij Gustschin <agust@denx.de>
--
Anatolij
^ permalink raw reply [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH 2/2] i2c: imx_lpi2c: add uclass api support
2018-07-17 12:38 ` [U-Boot] [PATCH 2/2] i2c: imx_lpi2c: add uclass api support Peng Fan
@ 2018-08-06 12:18 ` Anatolij Gustschin
2018-08-06 12:40 ` Anatolij Gustschin
1 sibling, 0 replies; 7+ messages in thread
From: Anatolij Gustschin @ 2018-08-06 12:18 UTC (permalink / raw)
To: u-boot
On Tue, 17 Jul 2018 20:38:33 +0800
Peng Fan peng.fan at nxp.com wrote:
> Use uclass clk api to get per clk when CONFIG_CLK enabled.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
> drivers/i2c/imx_lpi2c.c | 47 ++++++++++++++++++++++++++++++++++++++++-------
> include/imx_lpi2c.h | 3 +++
> 2 files changed, 43 insertions(+), 7 deletions(-)
Reviewed-by: Anatolij Gustschin <agust@denx.de>
--
Anatolij
^ permalink raw reply [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH 1/2] i2c-mux: pca954x: support pca9646 i2c switch
2018-07-17 12:38 [U-Boot] [PATCH 1/2] i2c-mux: pca954x: support pca9646 i2c switch Peng Fan
` (2 preceding siblings ...)
2018-08-06 12:08 ` Anatolij Gustschin
@ 2018-08-06 12:40 ` Anatolij Gustschin
3 siblings, 0 replies; 7+ messages in thread
From: Anatolij Gustschin @ 2018-08-06 12:40 UTC (permalink / raw)
To: u-boot
On Tue, 17 Jul 2018 20:38:32 +0800
Peng Fan peng.fan at nxp.com wrote:
> Add the PCA9646 support, which is 2-wire bus switch and buffered 4-channel.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
> drivers/i2c/muxes/pca954x.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
Applied to u-boot-staging/agust at denx.de, thanks!
--
Anatolij
^ permalink raw reply [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH 2/2] i2c: imx_lpi2c: add uclass api support
2018-07-17 12:38 ` [U-Boot] [PATCH 2/2] i2c: imx_lpi2c: add uclass api support Peng Fan
2018-08-06 12:18 ` Anatolij Gustschin
@ 2018-08-06 12:40 ` Anatolij Gustschin
1 sibling, 0 replies; 7+ messages in thread
From: Anatolij Gustschin @ 2018-08-06 12:40 UTC (permalink / raw)
To: u-boot
On Tue, 17 Jul 2018 20:38:33 +0800
Peng Fan peng.fan at nxp.com wrote:
> Use uclass clk api to get per clk when CONFIG_CLK enabled.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
> drivers/i2c/imx_lpi2c.c | 47 ++++++++++++++++++++++++++++++++++++++++-------
> include/imx_lpi2c.h | 3 +++
> 2 files changed, 43 insertions(+), 7 deletions(-)
Applied to u-boot-staging/agust at denx.de, thanks!
--
Anatolij
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2018-08-06 12:40 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-17 12:38 [U-Boot] [PATCH 1/2] i2c-mux: pca954x: support pca9646 i2c switch Peng Fan
2018-07-17 12:38 ` [U-Boot] [PATCH 2/2] i2c: imx_lpi2c: add uclass api support Peng Fan
2018-08-06 12:18 ` Anatolij Gustschin
2018-08-06 12:40 ` Anatolij Gustschin
2018-08-06 9:30 ` [U-Boot] [PATCH 1/2] i2c-mux: pca954x: support pca9646 i2c switch Peng Fan
2018-08-06 12:08 ` Anatolij Gustschin
2018-08-06 12:40 ` Anatolij Gustschin
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.