From: Heiko Schocher <hs@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH V3+] I2C: mxc_i2c rework
Date: Thu, 14 Jul 2011 11:04:39 +0200 [thread overview]
Message-ID: <4E1EB127.3040505@denx.de> (raw)
In-Reply-To: <1310594283-19819-1-git-send-email-marek.vasut@gmail.com>
Hello Marek,
Marek Vasut wrote:
> Rewrite the mxc_i2c driver.
> * This version is much closer to Linux implementation.
> * Fixes IPG_PERCLK being incorrectly used as clock source
> * Fixes behaviour of the driver on iMX51
> * Clean up coding style a bit ;-)
>
> Based on commit: e39428d53d080ad2615b772d7f99d2a70c2aaab2
> Date: Mon Jun 21 09:27:05 2010 +0200
> i2c-imx: do not allow interruptions when waiting for I2C to complete
>
> Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
> ---
> drivers/i2c/mxc_i2c.c | 424 +++++++++++++++++++++++++++++++++----------------
> 1 files changed, 290 insertions(+), 134 deletions(-)
>
> V2: Convert register access to struct mxc_i2c_regs.
>
> V3: Update licensing info
>
> V3+: Add commit ID into commit message
checkpatch says:
ERROR: trailing statements should be on next line
#143: FILE: drivers/i2c/mxc_i2c.c:130:
+ for (i = 0; i2c_clk_div[i][0] < div; i++);
total: 1 errors, 0 warnings, 526 lines checked
Can you fix this?
> diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c
> index 89d1973..03e2448 100644
> --- a/drivers/i2c/mxc_i2c.c
> +++ b/drivers/i2c/mxc_i2c.c
[...]
> @@ -68,218 +78,364 @@
> #endif
>
> #define I2C_MAX_TIMEOUT 10000
> -#define I2C_MAX_RETRIES 3
>
> -static u16 div[] = { 30, 32, 36, 42, 48, 52, 60, 72, 80, 88, 104, 128, 144,
> - 160, 192, 240, 288, 320, 384, 480, 576, 640, 768, 960,
> - 1152, 1280, 1536, 1920, 2304, 2560, 3072, 3840};
> +static u16 i2c_clk_div[50][2] = {
> + { 22, 0x20 }, { 24, 0x21 }, { 26, 0x22 }, { 28, 0x23 },
> + { 30, 0x00 }, { 32, 0x24 }, { 36, 0x25 }, { 40, 0x26 },
> + { 42, 0x03 }, { 44, 0x27 }, { 48, 0x28 }, { 52, 0x05 },
> + { 56, 0x29 }, { 60, 0x06 }, { 64, 0x2A }, { 72, 0x2B },
> + { 80, 0x2C }, { 88, 0x09 }, { 96, 0x2D }, { 104, 0x0A },
> + { 112, 0x2E }, { 128, 0x2F }, { 144, 0x0C }, { 160, 0x30 },
> + { 192, 0x31 }, { 224, 0x32 }, { 240, 0x0F }, { 256, 0x33 },
> + { 288, 0x10 }, { 320, 0x34 }, { 384, 0x35 }, { 448, 0x36 },
> + { 480, 0x13 }, { 512, 0x37 }, { 576, 0x14 }, { 640, 0x38 },
> + { 768, 0x39 }, { 896, 0x3A }, { 960, 0x17 }, { 1024, 0x3B },
> + { 1152, 0x18 }, { 1280, 0x3C }, { 1536, 0x3D }, { 1792, 0x3E },
> + { 1920, 0x1B }, { 2048, 0x3F }, { 2304, 0x1C }, { 2560, 0x1D },
> + { 3072, 0x1E }, { 3840, 0x1F }
> +};
> +
> +static u8 clk_idx;
>
> -static inline void i2c_reset(void)
> -{
> - writew(0, I2C_BASE + I2CR); /* Reset module */
> - writew(0, I2C_BASE + I2SR);
> - writew(I2CR_IEN, I2C_BASE + I2CR);
> -}
> -
> -void i2c_init(int speed, int unused)
> +/*
> + * Calculate and set proper clock divider
> + *
> + * FIXME: remove #ifdefs !
> + */
As Stefano just posted a patch for this, see here:
http://patchwork.ozlabs.org/patch/104642/
Can you fix this please?
Thanks!
> +static void i2c_imx_set_clk(unsigned int rate)
> {
> - int freq;
> + struct mxc_i2c_regs *i2c_regs = (struct mxc_i2c_regs *)I2C_BASE;
> + unsigned int i2c_clk_rate;
> + unsigned int div;
> int i;
>
> + /* Divider value calculation */
> #if defined(CONFIG_MX31)
> struct clock_control_regs *sc_regs =
> (struct clock_control_regs *)CCM_BASE;
>
> - freq = mx31_get_ipg_clk();
> + i2c_clk_rate = mx31_get_ipg_clk();
> /* start the required I2C clock */
> writel(readl(&sc_regs->cgr0) | (3 << I2C_CLK_OFFSET),
> &sc_regs->cgr0);
> #else
> - freq = mxc_get_clock(MXC_IPG_PERCLK);
> + i2c_clk_rate = mxc_get_clock(MXC_IPG_CLK);
> #endif
[...]
bye,
Heiko
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
next prev parent reply other threads:[~2011-07-14 9:04 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-13 21:58 [U-Boot] [PATCH V3+] I2C: mxc_i2c rework Marek Vasut
2011-07-14 9:04 ` Heiko Schocher [this message]
2011-07-28 14:29 ` Wolfgang Denk
2011-07-14 13:55 ` Albert ARIBAUD
2011-07-14 14:35 ` Marek Vasut
2011-07-14 14:45 ` Albert ARIBAUD
2011-07-29 6:55 ` Jason Hui
2011-07-29 9:35 ` Marek Vasut
2011-07-29 9:42 ` Stefano Babic
2011-09-14 19:39 ` Marek Vasut
2011-09-15 1:43 ` Jason Hui
2011-09-15 2:07 ` Marek Vasut
2011-09-15 2:26 ` Jason Hui
2011-09-15 4:07 ` Marek Vasut
2011-08-30 10:48 ` Stefano Babic
-- strict thread matches above, loose matches on Subject: below --
2011-07-13 21:05 [U-Boot] [PATCH V3] " Marek Vasut
2011-07-13 21:34 ` Wolfgang Denk
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=4E1EB127.3040505@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox