U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Lukasz Majewski <lukma@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] i2c: mxc: add CONFIG_CLK support
Date: Thu, 8 Aug 2019 09:04:47 +0200	[thread overview]
Message-ID: <20190808090447.26f8a66f@jawa> (raw)
In-Reply-To: <20190806102445.9633-1-peng.fan@nxp.com>

On Tue, 6 Aug 2019 10:09:12 +0000
Peng Fan <peng.fan@nxp.com> wrote:

> When CONFIG_CLK enabled, use CLK UCLASS for clk related settings.
> 
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>  arch/arm/include/asm/mach-imx/mxc_i2c.h |  6 ++++++
>  drivers/i2c/mxc_i2c.c                   | 17 +++++++++++++++++
>  2 files changed, 23 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..2e157bca58 100644
> --- a/drivers/i2c/mxc_i2c.c
> +++ b/drivers/i2c/mxc_i2c.c
> @@ -890,9 +890,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 +932,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;
>  	}
>  

Reviewed-by: Lukasz Majewski <lukma@denx.de>


Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190808/5bdffc4d/attachment.sig>

  parent reply	other threads:[~2019-08-08  7:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-06 10:09 [U-Boot] [PATCH] i2c: mxc: add CONFIG_CLK support Peng Fan
2019-08-07 10:09 ` Ye Li
2019-08-07 13:49 ` Schrempf Frieder
2019-08-08  1:44   ` Peng Fan
2019-08-08  7:04 ` Lukasz Majewski [this message]
2019-08-08  7:05   ` Peng Fan

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=20190808090447.26f8a66f@jawa \
    --to=lukma@denx.de \
    --cc=u-boot@lists.denx.de \
    /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