From: Heiko Schocher <hs@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 3/4] sunxi: i2c: Add support for DM I2C
Date: Fri, 28 Apr 2017 05:43:41 +0200 [thread overview]
Message-ID: <5902BA6D.3040100@denx.de> (raw)
In-Reply-To: <20170426220337.13136-4-jernej.skrabec@siol.net>
Hello Jernej,
Am 27.04.2017 um 00:03 schrieb Jernej Skrabec:
> This commit adds support for DM I2C on sunxi platform. It can coexist
> with old style sunxi I2C driver, because it is still used in SPL and
> by some SoCs.
>
> Because sunxi platform doesn't yet support DM clk, reset and pinctrl
> driver, workaround is needed to enable clocks and set resets and
> pinctrls. This is done by calling i2c_init_board() in board_init().
> This means that CONFIG_I2Cx_ENABLE options needs to be correctly set
> in order to use needed I2C controller.
>
> Commit is based on the previous patch made by Philipp Tomsich
>
> Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
> ---
>
> arch/arm/mach-sunxi/board.c | 2 ++
> board/sunxi/board.c | 8 ++++++++
> drivers/i2c/mvtwsi.c | 9 +++++++++
> include/configs/sunxi-common.h | 4 +++-
> 4 files changed, 22 insertions(+), 1 deletion(-)
Reviewed-by: Heiko Schocher <hs@denx.de>
bye,
Heiko
>
> diff --git a/arch/arm/mach-sunxi/board.c b/arch/arm/mach-sunxi/board.c
> index 4507279cc5..65b1ebd837 100644
> --- a/arch/arm/mach-sunxi/board.c
> +++ b/arch/arm/mach-sunxi/board.c
> @@ -204,7 +204,9 @@ void s_init(void)
> clock_init();
> timer_init();
> gpio_init();
> +#ifndef CONFIG_DM_I2C
> i2c_init_board();
> +#endif
> eth_init_board();
> }
>
> diff --git a/board/sunxi/board.c b/board/sunxi/board.c
> index f903a5d0a0..01de42d031 100644
> --- a/board/sunxi/board.c
> +++ b/board/sunxi/board.c
> @@ -222,6 +222,14 @@ int board_init(void)
> gpio_direction_output(macpwr_pin, 1);
> #endif
>
> +#ifdef CONFIG_DM_I2C
> + /*
> + * Temporary workaround for enabling I2C clocks until proper sunxi DM
> + * clk, reset and pinctrl drivers land.
> + */
> + i2c_init_board();
> +#endif
> +
> /* Uses dm gpio code so do this here and not in i2c_init_board() */
> return soft_i2c_board_init();
> }
> diff --git a/drivers/i2c/mvtwsi.c b/drivers/i2c/mvtwsi.c
> index 648a96eeb4..3703519aa5 100644
> --- a/drivers/i2c/mvtwsi.c
> +++ b/drivers/i2c/mvtwsi.c
> @@ -37,6 +37,14 @@ DECLARE_GLOBAL_DATA_PTR;
> #endif /* CONFIG_DM_I2C */
>
> /*
> + * On SUNXI, we get CONFIG_SYS_TCLK from this include, so we want to
> + * always have it.
> + */
> +#if defined(CONFIG_DM_I2C) && defined(CONFIG_ARCH_SUNXI)
> +#include <asm/arch/i2c.h>
> +#endif
> +
> +/*
> * TWSI register structure
> */
>
> @@ -831,6 +839,7 @@ static const struct dm_i2c_ops mvtwsi_i2c_ops = {
> static const struct udevice_id mvtwsi_i2c_ids[] = {
> { .compatible = "marvell,mv64xxx-i2c", },
> { .compatible = "marvell,mv78230-i2c", },
> + { .compatible = "allwinner,sun6i-a31-i2c", },
> { /* sentinel */ }
> };
>
> diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
> index a56b45fa2f..997a92c8be 100644
> --- a/include/configs/sunxi-common.h
> +++ b/include/configs/sunxi-common.h
> @@ -211,11 +211,13 @@
> #if defined CONFIG_I2C0_ENABLE || defined CONFIG_I2C1_ENABLE || \
> defined CONFIG_I2C2_ENABLE || defined CONFIG_I2C3_ENABLE || \
> defined CONFIG_I2C4_ENABLE || defined CONFIG_R_I2C_ENABLE
> -#define CONFIG_SYS_I2C
> #define CONFIG_SYS_I2C_MVTWSI
> +#ifndef CONFIG_DM_I2C
> +#define CONFIG_SYS_I2C
> #define CONFIG_SYS_I2C_SPEED 400000
> #define CONFIG_SYS_I2C_SLAVE 0x7f
> #endif
> +#endif
>
> #if defined CONFIG_VIDEO_LCD_PANEL_I2C && !(defined CONFIG_SPL_BUILD)
> #define CONFIG_SYS_I2C_SOFT
>
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
next prev parent reply other threads:[~2017-04-28 3:43 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-26 22:03 [U-Boot] [PATCH 0/4] sunxi: i2c: Add DM I2C support for A64/H3/H5 Jernej Skrabec
2017-04-26 22:03 ` [U-Boot] [PATCH 1/4] sunxi: power: Compile sy8106a driver only during SPL build Jernej Skrabec
2017-04-28 3:42 ` Heiko Schocher
2017-04-26 22:03 ` [U-Boot] [PATCH 2/4] sunxi: Move function for later convenience Jernej Skrabec
2017-04-28 3:43 ` Heiko Schocher
2017-04-26 22:03 ` [U-Boot] [PATCH 3/4] sunxi: i2c: Add support for DM I2C Jernej Skrabec
2017-04-28 3:43 ` Heiko Schocher [this message]
2017-04-29 0:28 ` Simon Glass
2017-04-26 22:03 ` [U-Boot] [PATCH 4/4] sunxi: Enable DM_I2C for A64/H3/H5 Jernej Skrabec
2017-04-28 3:44 ` Heiko Schocher
2017-04-27 7:44 ` [U-Boot] [PATCH 0/4] sunxi: i2c: Add DM I2C support " Maxime Ripard
2017-04-28 3:46 ` Heiko Schocher
2017-04-28 6:44 ` Maxime Ripard
2017-04-28 6:53 ` Heiko Schocher invitel
2017-04-28 7:27 ` Maxime Ripard
2017-04-28 10:04 ` Heiko Schocher
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=5902BA6D.3040100@denx.de \
--to=hs@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 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.