* [U-Boot] [PATCH v2] i2c: mxc: add CONFIG_CLK support
@ 2019-08-08 1:43 Peng Fan
2019-08-13 8:05 ` Peng Fan
2019-08-27 9:55 ` Peng Fan
0 siblings, 2 replies; 6+ messages in thread
From: Peng Fan @ 2019-08-08 1:43 UTC (permalink / raw)
To: u-boot
When CONFIG_CLK enabled, use CLK UCLASS for clk related settings.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
V2:
use clk_get_rate when getting i2c per clk rate with CLK UCLASS
arch/arm/include/asm/mach-imx/mxc_i2c.h | 6 ++++++
drivers/i2c/mxc_i2c.c | 22 ++++++++++++++++++++++
2 files changed, 28 insertions(+)
diff --git a/arch/arm/include/asm/mach-imx/mxc_i2c.h b/arch/arm/include/asm/mach-imx/mxc_i2c.h
index 8e1ea9af19..81fd981444 100644
--- a/arch/arm/include/asm/mach-imx/mxc_i2c.h
+++ b/arch/arm/include/asm/mach-imx/mxc_i2c.h
@@ -6,6 +6,9 @@
#define __ASM_ARCH_MXC_MXC_I2C_H__
#include <asm-generic/gpio.h>
#include <asm/mach-imx/iomux-v3.h>
+#if CONFIG_IS_ENABLED(CLK)
+#include <clk.h>
+#endif
struct i2c_pin_ctrl {
iomux_v3_cfg_t i2c_mode;
@@ -47,6 +50,9 @@ struct mxc_i2c_bus {
ulong driver_data;
int speed;
struct i2c_pads_info *pads_info;
+#if CONFIG_IS_ENABLED(CLK)
+ struct clk per_clk;
+#endif
#ifndef CONFIG_DM_I2C
int (*idle_bus_fn)(void *p);
void *idle_bus_data;
diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c
index 23119cce65..8d6b4650ff 100644
--- a/drivers/i2c/mxc_i2c.c
+++ b/drivers/i2c/mxc_i2c.c
@@ -149,7 +149,12 @@ static uint8_t i2c_imx_get_clk(struct mxc_i2c_bus *i2c_bus, unsigned int rate)
#endif
/* Divider value calculation */
+#if CONFIG_IS_ENABLED(CLK)
+ i2c_clk_rate = clk_get_rate(&i2c_bus->per_clk);
+#else
i2c_clk_rate = mxc_get_clock(MXC_I2C_CLK);
+#endif
+
div = (i2c_clk_rate + rate - 1) / rate;
if (div < i2c_clk_div[0][0])
clk_div = 0;
@@ -890,9 +895,22 @@ static int mxc_i2c_probe(struct udevice *bus)
i2c_bus->bus = bus;
/* Enable clk */
+#if CONFIG_IS_ENABLED(CLK)
+ ret = clk_get_by_index(bus, 0, &i2c_bus->per_clk);
+ if (ret) {
+ printf("Failed to get i2c clk\n");
+ return ret;
+ }
+ ret = clk_enable(&i2c_bus->per_clk);
+ if (ret) {
+ printf("Failed to enable i2c clk\n");
+ return ret;
+ }
+#else
ret = enable_i2c_clk(1, bus->seq);
if (ret < 0)
return ret;
+#endif
/*
* See Documentation/devicetree/bindings/i2c/i2c-imx.txt
@@ -919,7 +937,11 @@ static int mxc_i2c_probe(struct udevice *bus)
ret = i2c_idle_bus(i2c_bus);
if (ret < 0) {
/* Disable clk */
+#if CONFIG_IS_ENABLED(CLK)
+ clk_disable(&i2c_bus->per_clk);
+#else
enable_i2c_clk(0, bus->seq);
+#endif
return ret;
}
--
2.16.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH v2] i2c: mxc: add CONFIG_CLK support
2019-08-08 1:43 [U-Boot] [PATCH v2] i2c: mxc: add CONFIG_CLK support Peng Fan
@ 2019-08-13 8:05 ` Peng Fan
2019-08-14 10:08 ` Schrempf Frieder
2019-08-27 9:55 ` Peng Fan
1 sibling, 1 reply; 6+ messages in thread
From: Peng Fan @ 2019-08-13 8:05 UTC (permalink / raw)
To: u-boot
Hi Frieder
> Subject: [PATCH v2] i2c: mxc: add CONFIG_CLK support
>
> When CONFIG_CLK enabled, use CLK UCLASS for clk related settings.
Are you fine with this patch?
Thanks,
Peng.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>
> V2:
> use clk_get_rate when getting i2c per clk rate with CLK UCLASS
>
> arch/arm/include/asm/mach-imx/mxc_i2c.h | 6 ++++++
> drivers/i2c/mxc_i2c.c | 22
> ++++++++++++++++++++++
> 2 files changed, 28 insertions(+)
>
> diff --git a/arch/arm/include/asm/mach-imx/mxc_i2c.h
> b/arch/arm/include/asm/mach-imx/mxc_i2c.h
> index 8e1ea9af19..81fd981444 100644
> --- a/arch/arm/include/asm/mach-imx/mxc_i2c.h
> +++ b/arch/arm/include/asm/mach-imx/mxc_i2c.h
> @@ -6,6 +6,9 @@
> #define __ASM_ARCH_MXC_MXC_I2C_H__
> #include <asm-generic/gpio.h>
> #include <asm/mach-imx/iomux-v3.h>
> +#if CONFIG_IS_ENABLED(CLK)
> +#include <clk.h>
> +#endif
>
> struct i2c_pin_ctrl {
> iomux_v3_cfg_t i2c_mode;
> @@ -47,6 +50,9 @@ struct mxc_i2c_bus {
> ulong driver_data;
> int speed;
> struct i2c_pads_info *pads_info;
> +#if CONFIG_IS_ENABLED(CLK)
> + struct clk per_clk;
> +#endif
> #ifndef CONFIG_DM_I2C
> int (*idle_bus_fn)(void *p);
> void *idle_bus_data;
> diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c index
> 23119cce65..8d6b4650ff 100644
> --- a/drivers/i2c/mxc_i2c.c
> +++ b/drivers/i2c/mxc_i2c.c
> @@ -149,7 +149,12 @@ static uint8_t i2c_imx_get_clk(struct mxc_i2c_bus
> *i2c_bus, unsigned int rate) #endif
>
> /* Divider value calculation */
> +#if CONFIG_IS_ENABLED(CLK)
> + i2c_clk_rate = clk_get_rate(&i2c_bus->per_clk); #else
> i2c_clk_rate = mxc_get_clock(MXC_I2C_CLK);
> +#endif
> +
> div = (i2c_clk_rate + rate - 1) / rate;
> if (div < i2c_clk_div[0][0])
> clk_div = 0;
> @@ -890,9 +895,22 @@ static int mxc_i2c_probe(struct udevice *bus)
> i2c_bus->bus = bus;
>
> /* Enable clk */
> +#if CONFIG_IS_ENABLED(CLK)
> + ret = clk_get_by_index(bus, 0, &i2c_bus->per_clk);
> + if (ret) {
> + printf("Failed to get i2c clk\n");
> + return ret;
> + }
> + ret = clk_enable(&i2c_bus->per_clk);
> + if (ret) {
> + printf("Failed to enable i2c clk\n");
> + return ret;
> + }
> +#else
> ret = enable_i2c_clk(1, bus->seq);
> if (ret < 0)
> return ret;
> +#endif
>
> /*
> * See Documentation/devicetree/bindings/i2c/i2c-imx.txt
> @@ -919,7 +937,11 @@ static int mxc_i2c_probe(struct udevice *bus)
> ret = i2c_idle_bus(i2c_bus);
> if (ret < 0) {
> /* Disable clk */
> +#if CONFIG_IS_ENABLED(CLK)
> + clk_disable(&i2c_bus->per_clk);
> +#else
> enable_i2c_clk(0, bus->seq);
> +#endif
> return ret;
> }
>
> --
> 2.16.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH v2] i2c: mxc: add CONFIG_CLK support
2019-08-13 8:05 ` Peng Fan
@ 2019-08-14 10:08 ` Schrempf Frieder
0 siblings, 0 replies; 6+ messages in thread
From: Schrempf Frieder @ 2019-08-14 10:08 UTC (permalink / raw)
To: u-boot
On 13.08.19 10:05, Peng Fan wrote:
> Hi Frieder
>
>> Subject: [PATCH v2] i2c: mxc: add CONFIG_CLK support
>>
>> When CONFIG_CLK enabled, use CLK UCLASS for clk related settings.
>
> Are you fine with this patch?
Yes!
Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de>
Tested-by: Frieder Schrempf <frieder.schrempf@kontron.de>
>
> Thanks,
> Peng.
>
>>
>> Signed-off-by: Peng Fan <peng.fan@nxp.com>
>> ---
>>
>> V2:
>> use clk_get_rate when getting i2c per clk rate with CLK UCLASS
>>
>> arch/arm/include/asm/mach-imx/mxc_i2c.h | 6 ++++++
>> drivers/i2c/mxc_i2c.c | 22
>> ++++++++++++++++++++++
>> 2 files changed, 28 insertions(+)
>>
>> diff --git a/arch/arm/include/asm/mach-imx/mxc_i2c.h
>> b/arch/arm/include/asm/mach-imx/mxc_i2c.h
>> index 8e1ea9af19..81fd981444 100644
>> --- a/arch/arm/include/asm/mach-imx/mxc_i2c.h
>> +++ b/arch/arm/include/asm/mach-imx/mxc_i2c.h
>> @@ -6,6 +6,9 @@
>> #define __ASM_ARCH_MXC_MXC_I2C_H__
>> #include <asm-generic/gpio.h>
>> #include <asm/mach-imx/iomux-v3.h>
>> +#if CONFIG_IS_ENABLED(CLK)
>> +#include <clk.h>
>> +#endif
>>
>> struct i2c_pin_ctrl {
>> iomux_v3_cfg_t i2c_mode;
>> @@ -47,6 +50,9 @@ struct mxc_i2c_bus {
>> ulong driver_data;
>> int speed;
>> struct i2c_pads_info *pads_info;
>> +#if CONFIG_IS_ENABLED(CLK)
>> + struct clk per_clk;
>> +#endif
>> #ifndef CONFIG_DM_I2C
>> int (*idle_bus_fn)(void *p);
>> void *idle_bus_data;
>> diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c index
>> 23119cce65..8d6b4650ff 100644
>> --- a/drivers/i2c/mxc_i2c.c
>> +++ b/drivers/i2c/mxc_i2c.c
>> @@ -149,7 +149,12 @@ static uint8_t i2c_imx_get_clk(struct mxc_i2c_bus
>> *i2c_bus, unsigned int rate) #endif
>>
>> /* Divider value calculation */
>> +#if CONFIG_IS_ENABLED(CLK)
>> + i2c_clk_rate = clk_get_rate(&i2c_bus->per_clk); #else
>> i2c_clk_rate = mxc_get_clock(MXC_I2C_CLK);
>> +#endif
>> +
>> div = (i2c_clk_rate + rate - 1) / rate;
>> if (div < i2c_clk_div[0][0])
>> clk_div = 0;
>> @@ -890,9 +895,22 @@ static int mxc_i2c_probe(struct udevice *bus)
>> i2c_bus->bus = bus;
>>
>> /* Enable clk */
>> +#if CONFIG_IS_ENABLED(CLK)
>> + ret = clk_get_by_index(bus, 0, &i2c_bus->per_clk);
>> + if (ret) {
>> + printf("Failed to get i2c clk\n");
>> + return ret;
>> + }
>> + ret = clk_enable(&i2c_bus->per_clk);
>> + if (ret) {
>> + printf("Failed to enable i2c clk\n");
>> + return ret;
>> + }
>> +#else
>> ret = enable_i2c_clk(1, bus->seq);
>> if (ret < 0)
>> return ret;
>> +#endif
>>
>> /*
>> * See Documentation/devicetree/bindings/i2c/i2c-imx.txt
>> @@ -919,7 +937,11 @@ static int mxc_i2c_probe(struct udevice *bus)
>> ret = i2c_idle_bus(i2c_bus);
>> if (ret < 0) {
>> /* Disable clk */
>> +#if CONFIG_IS_ENABLED(CLK)
>> + clk_disable(&i2c_bus->per_clk);
>> +#else
>> enable_i2c_clk(0, bus->seq);
>> +#endif
>> return ret;
>> }
>>
>> --
>> 2.16.4
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH v2] i2c: mxc: add CONFIG_CLK support
2019-08-08 1:43 [U-Boot] [PATCH v2] i2c: mxc: add CONFIG_CLK support Peng Fan
2019-08-13 8:05 ` Peng Fan
@ 2019-08-27 9:55 ` Peng Fan
2019-08-27 10:00 ` Heiko Schocher
2019-09-02 9:25 ` Heiko Schocher
1 sibling, 2 replies; 6+ messages in thread
From: Peng Fan @ 2019-08-27 9:55 UTC (permalink / raw)
To: u-boot
Hi Heiko,
> Subject: [PATCH v2] i2c: mxc: add CONFIG_CLK support
Would you pick up this patch?
Thanks,
Peng.
>
> When CONFIG_CLK enabled, use CLK UCLASS for clk related settings.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>
> V2:
> use clk_get_rate when getting i2c per clk rate with CLK UCLASS
>
> arch/arm/include/asm/mach-imx/mxc_i2c.h | 6 ++++++
> drivers/i2c/mxc_i2c.c | 22
> ++++++++++++++++++++++
> 2 files changed, 28 insertions(+)
>
> diff --git a/arch/arm/include/asm/mach-imx/mxc_i2c.h
> b/arch/arm/include/asm/mach-imx/mxc_i2c.h
> index 8e1ea9af19..81fd981444 100644
> --- a/arch/arm/include/asm/mach-imx/mxc_i2c.h
> +++ b/arch/arm/include/asm/mach-imx/mxc_i2c.h
> @@ -6,6 +6,9 @@
> #define __ASM_ARCH_MXC_MXC_I2C_H__
> #include <asm-generic/gpio.h>
> #include <asm/mach-imx/iomux-v3.h>
> +#if CONFIG_IS_ENABLED(CLK)
> +#include <clk.h>
> +#endif
>
> struct i2c_pin_ctrl {
> iomux_v3_cfg_t i2c_mode;
> @@ -47,6 +50,9 @@ struct mxc_i2c_bus {
> ulong driver_data;
> int speed;
> struct i2c_pads_info *pads_info;
> +#if CONFIG_IS_ENABLED(CLK)
> + struct clk per_clk;
> +#endif
> #ifndef CONFIG_DM_I2C
> int (*idle_bus_fn)(void *p);
> void *idle_bus_data;
> diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c index
> 23119cce65..8d6b4650ff 100644
> --- a/drivers/i2c/mxc_i2c.c
> +++ b/drivers/i2c/mxc_i2c.c
> @@ -149,7 +149,12 @@ static uint8_t i2c_imx_get_clk(struct mxc_i2c_bus
> *i2c_bus, unsigned int rate) #endif
>
> /* Divider value calculation */
> +#if CONFIG_IS_ENABLED(CLK)
> + i2c_clk_rate = clk_get_rate(&i2c_bus->per_clk); #else
> i2c_clk_rate = mxc_get_clock(MXC_I2C_CLK);
> +#endif
> +
> div = (i2c_clk_rate + rate - 1) / rate;
> if (div < i2c_clk_div[0][0])
> clk_div = 0;
> @@ -890,9 +895,22 @@ static int mxc_i2c_probe(struct udevice *bus)
> i2c_bus->bus = bus;
>
> /* Enable clk */
> +#if CONFIG_IS_ENABLED(CLK)
> + ret = clk_get_by_index(bus, 0, &i2c_bus->per_clk);
> + if (ret) {
> + printf("Failed to get i2c clk\n");
> + return ret;
> + }
> + ret = clk_enable(&i2c_bus->per_clk);
> + if (ret) {
> + printf("Failed to enable i2c clk\n");
> + return ret;
> + }
> +#else
> ret = enable_i2c_clk(1, bus->seq);
> if (ret < 0)
> return ret;
> +#endif
>
> /*
> * See Documentation/devicetree/bindings/i2c/i2c-imx.txt
> @@ -919,7 +937,11 @@ static int mxc_i2c_probe(struct udevice *bus)
> ret = i2c_idle_bus(i2c_bus);
> if (ret < 0) {
> /* Disable clk */
> +#if CONFIG_IS_ENABLED(CLK)
> + clk_disable(&i2c_bus->per_clk);
> +#else
> enable_i2c_clk(0, bus->seq);
> +#endif
> return ret;
> }
>
> --
> 2.16.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH v2] i2c: mxc: add CONFIG_CLK support
2019-08-27 9:55 ` Peng Fan
@ 2019-08-27 10:00 ` Heiko Schocher
2019-09-02 9:25 ` Heiko Schocher
1 sibling, 0 replies; 6+ messages in thread
From: Heiko Schocher @ 2019-08-27 10:00 UTC (permalink / raw)
To: u-boot
Hello Peng,
Am 27.08.2019 um 11:55 schrieb Peng Fan:
> Hi Heiko,
>
>> Subject: [PATCH v2] i2c: mxc: add CONFIG_CLK support
>
> Would you pick up this patch?
Huh, seems I missed this patch ... now it is in my patchwork ToDo
list... patch looks good to me.... so:
If Stefano has no objections I can pick it up for 2019.10
bye,
Heiko
>
> Thanks,
> Peng.
>
>>
>> When CONFIG_CLK enabled, use CLK UCLASS for clk related settings.
>>
>> Signed-off-by: Peng Fan <peng.fan@nxp.com>
>> ---
>>
>> V2:
>> use clk_get_rate when getting i2c per clk rate with CLK UCLASS
>>
>> arch/arm/include/asm/mach-imx/mxc_i2c.h | 6 ++++++
>> drivers/i2c/mxc_i2c.c | 22
>> ++++++++++++++++++++++
>> 2 files changed, 28 insertions(+)
>>
>> diff --git a/arch/arm/include/asm/mach-imx/mxc_i2c.h
>> b/arch/arm/include/asm/mach-imx/mxc_i2c.h
>> index 8e1ea9af19..81fd981444 100644
>> --- a/arch/arm/include/asm/mach-imx/mxc_i2c.h
>> +++ b/arch/arm/include/asm/mach-imx/mxc_i2c.h
>> @@ -6,6 +6,9 @@
>> #define __ASM_ARCH_MXC_MXC_I2C_H__
>> #include <asm-generic/gpio.h>
>> #include <asm/mach-imx/iomux-v3.h>
>> +#if CONFIG_IS_ENABLED(CLK)
>> +#include <clk.h>
>> +#endif
>>
>> struct i2c_pin_ctrl {
>> iomux_v3_cfg_t i2c_mode;
>> @@ -47,6 +50,9 @@ struct mxc_i2c_bus {
>> ulong driver_data;
>> int speed;
>> struct i2c_pads_info *pads_info;
>> +#if CONFIG_IS_ENABLED(CLK)
>> + struct clk per_clk;
>> +#endif
>> #ifndef CONFIG_DM_I2C
>> int (*idle_bus_fn)(void *p);
>> void *idle_bus_data;
>> diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c index
>> 23119cce65..8d6b4650ff 100644
>> --- a/drivers/i2c/mxc_i2c.c
>> +++ b/drivers/i2c/mxc_i2c.c
>> @@ -149,7 +149,12 @@ static uint8_t i2c_imx_get_clk(struct mxc_i2c_bus
>> *i2c_bus, unsigned int rate) #endif
>>
>> /* Divider value calculation */
>> +#if CONFIG_IS_ENABLED(CLK)
>> + i2c_clk_rate = clk_get_rate(&i2c_bus->per_clk); #else
>> i2c_clk_rate = mxc_get_clock(MXC_I2C_CLK);
>> +#endif
>> +
>> div = (i2c_clk_rate + rate - 1) / rate;
>> if (div < i2c_clk_div[0][0])
>> clk_div = 0;
>> @@ -890,9 +895,22 @@ static int mxc_i2c_probe(struct udevice *bus)
>> i2c_bus->bus = bus;
>>
>> /* Enable clk */
>> +#if CONFIG_IS_ENABLED(CLK)
>> + ret = clk_get_by_index(bus, 0, &i2c_bus->per_clk);
>> + if (ret) {
>> + printf("Failed to get i2c clk\n");
>> + return ret;
>> + }
>> + ret = clk_enable(&i2c_bus->per_clk);
>> + if (ret) {
>> + printf("Failed to enable i2c clk\n");
>> + return ret;
>> + }
>> +#else
>> ret = enable_i2c_clk(1, bus->seq);
>> if (ret < 0)
>> return ret;
>> +#endif
>>
>> /*
>> * See Documentation/devicetree/bindings/i2c/i2c-imx.txt
>> @@ -919,7 +937,11 @@ static int mxc_i2c_probe(struct udevice *bus)
>> ret = i2c_idle_bus(i2c_bus);
>> if (ret < 0) {
>> /* Disable clk */
>> +#if CONFIG_IS_ENABLED(CLK)
>> + clk_disable(&i2c_bus->per_clk);
>> +#else
>> enable_i2c_clk(0, bus->seq);
>> +#endif
>> return ret;
>> }
>>
>> --
>> 2.16.4
>
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs at denx.de
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH v2] i2c: mxc: add CONFIG_CLK support
2019-08-27 9:55 ` Peng Fan
2019-08-27 10:00 ` Heiko Schocher
@ 2019-09-02 9:25 ` Heiko Schocher
1 sibling, 0 replies; 6+ messages in thread
From: Heiko Schocher @ 2019-09-02 9:25 UTC (permalink / raw)
To: u-boot
Hello Peng,
Am 27.08.2019 um 11:55 schrieb Peng Fan:
> Hi Heiko,
>
>> Subject: [PATCH v2] i2c: mxc: add CONFIG_CLK support
>
> Would you pick up this patch?
>
> Thanks,
> Peng.
>
>>
>> When CONFIG_CLK enabled, use CLK UCLASS for clk related settings.
>>
>> Signed-off-by: Peng Fan <peng.fan@nxp.com>
>> ---
>>
>> V2:
>> use clk_get_rate when getting i2c per clk rate with CLK UCLASS
>>
>> arch/arm/include/asm/mach-imx/mxc_i2c.h | 6 ++++++
>> drivers/i2c/mxc_i2c.c | 22
>> ++++++++++++++++++++++
>> 2 files changed, 28 insertions(+)
Applied to u-boot-i2c.git:
https://gitlab.denx.de/u-boot/custodians/u-boot-i2c/commit/6dba0864ece3f4006abae8ff9e2ad74f4374359d
Travis builds fine, pull request follows soon.
bye,
Heiko
>>
>> diff --git a/arch/arm/include/asm/mach-imx/mxc_i2c.h
>> b/arch/arm/include/asm/mach-imx/mxc_i2c.h
>> index 8e1ea9af19..81fd981444 100644
>> --- a/arch/arm/include/asm/mach-imx/mxc_i2c.h
>> +++ b/arch/arm/include/asm/mach-imx/mxc_i2c.h
>> @@ -6,6 +6,9 @@
>> #define __ASM_ARCH_MXC_MXC_I2C_H__
>> #include <asm-generic/gpio.h>
>> #include <asm/mach-imx/iomux-v3.h>
>> +#if CONFIG_IS_ENABLED(CLK)
>> +#include <clk.h>
>> +#endif
>>
>> struct i2c_pin_ctrl {
>> iomux_v3_cfg_t i2c_mode;
>> @@ -47,6 +50,9 @@ struct mxc_i2c_bus {
>> ulong driver_data;
>> int speed;
>> struct i2c_pads_info *pads_info;
>> +#if CONFIG_IS_ENABLED(CLK)
>> + struct clk per_clk;
>> +#endif
>> #ifndef CONFIG_DM_I2C
>> int (*idle_bus_fn)(void *p);
>> void *idle_bus_data;
>> diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c index
>> 23119cce65..8d6b4650ff 100644
>> --- a/drivers/i2c/mxc_i2c.c
>> +++ b/drivers/i2c/mxc_i2c.c
>> @@ -149,7 +149,12 @@ static uint8_t i2c_imx_get_clk(struct mxc_i2c_bus
>> *i2c_bus, unsigned int rate) #endif
>>
>> /* Divider value calculation */
>> +#if CONFIG_IS_ENABLED(CLK)
>> + i2c_clk_rate = clk_get_rate(&i2c_bus->per_clk); #else
>> i2c_clk_rate = mxc_get_clock(MXC_I2C_CLK);
>> +#endif
>> +
>> div = (i2c_clk_rate + rate - 1) / rate;
>> if (div < i2c_clk_div[0][0])
>> clk_div = 0;
>> @@ -890,9 +895,22 @@ static int mxc_i2c_probe(struct udevice *bus)
>> i2c_bus->bus = bus;
>>
>> /* Enable clk */
>> +#if CONFIG_IS_ENABLED(CLK)
>> + ret = clk_get_by_index(bus, 0, &i2c_bus->per_clk);
>> + if (ret) {
>> + printf("Failed to get i2c clk\n");
>> + return ret;
>> + }
>> + ret = clk_enable(&i2c_bus->per_clk);
>> + if (ret) {
>> + printf("Failed to enable i2c clk\n");
>> + return ret;
>> + }
>> +#else
>> ret = enable_i2c_clk(1, bus->seq);
>> if (ret < 0)
>> return ret;
>> +#endif
>>
>> /*
>> * See Documentation/devicetree/bindings/i2c/i2c-imx.txt
>> @@ -919,7 +937,11 @@ static int mxc_i2c_probe(struct udevice *bus)
>> ret = i2c_idle_bus(i2c_bus);
>> if (ret < 0) {
>> /* Disable clk */
>> +#if CONFIG_IS_ENABLED(CLK)
>> + clk_disable(&i2c_bus->per_clk);
>> +#else
>> enable_i2c_clk(0, bus->seq);
>> +#endif
>> return ret;
>> }
>>
>> --
>> 2.16.4
>
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs at denx.de
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-09-02 9:25 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-08 1:43 [U-Boot] [PATCH v2] i2c: mxc: add CONFIG_CLK support Peng Fan
2019-08-13 8:05 ` Peng Fan
2019-08-14 10:08 ` Schrempf Frieder
2019-08-27 9:55 ` Peng Fan
2019-08-27 10:00 ` Heiko Schocher
2019-09-02 9:25 ` Heiko Schocher
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.