From: Kevin Hilman <khilman@deeprootsystems.com>
To: "Högander Jouni" <jouni.hogander@nokia.com>
Cc: ext chandra shekhar <x0044955@ti.com>, linux-omap@vger.kernel.org
Subject: Re: [PATCH 04/12] I2C re-init for every cmd
Date: Tue, 16 Sep 2008 12:25:44 +0300 [thread overview]
Message-ID: <87d4j4moh3.fsf@deeprootsystems.com> (raw)
In-Reply-To: <877i9h7qjw.fsf@trdhcp146196.ntc.nokia.com> ("Högander Jouni"'s message of "Fri\, 12 Sep 2008 10\:48\:35 +0300")
jouni.hogander@nokia.com (Högander Jouni) writes:
> "ext chandra shekhar" <x0044955@ti.com> writes:
>
>> agreed..but i guess it will not compile for 2430 and prev. platforms.
>> omap3_i2c_save_context and restore definition is under macro
>> while call is not. let me know if i am missing something.
>>
>> also is SYSC register restore needed??
>
> Here is the second version. Does it look any better to you?
>
> diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
> index 3778735..0a11621 100644
> --- a/drivers/i2c/busses/i2c-omap.c
> +++ b/drivers/i2c/busses/i2c-omap.c
> @@ -147,6 +147,12 @@ struct omap_i2c_dev {
> unsigned b_hw:1; /* bad h/w fixes */
> unsigned idle:1;
> u16 iestate; /* Saved interrupt register */
> +#ifdef CONFIG_ARCH_OMAP34XX
> + u16 pscstate;
> + u16 scllstate;
> + u16 sclhstate;
> + u16 bufstate;
> +#endif
> };
>
> static inline void omap_i2c_write_reg(struct omap_i2c_dev *i2c_dev,
> @@ -209,16 +215,21 @@ static void omap_i2c_unidle(struct omap_i2c_dev *dev)
> if (dev->iclk != NULL)
> clk_enable(dev->iclk);
> clk_enable(dev->fclk);
> +
> +#ifdef CONFIG_ARCH_OMAP34XX
> + omap_i2c_write_reg(dev, OMAP_I2C_PSC_REG, dev->pscstate);
> + omap_i2c_write_reg(dev, OMAP_I2C_SCLL_REG, dev->scllstate);
> + omap_i2c_write_reg(dev, OMAP_I2C_SCLH_REG, dev->sclhstate);
> + omap_i2c_write_reg(dev, OMAP_I2C_BUF_REG, dev->bufstate);
> +#endif
The above should also be inside an if cpu_is_omap34xx() block so
it works correctly on multi-omap kernels.
Kevin
> dev->idle = 0;
> - if (dev->iestate)
> - omap_i2c_write_reg(dev, OMAP_I2C_IE_REG, dev->iestate);
> + omap_i2c_write_reg(dev, OMAP_I2C_IE_REG, dev->iestate);
> }
>
> static void omap_i2c_idle(struct omap_i2c_dev *dev)
> {
> u16 iv;
>
> - dev->iestate = omap_i2c_read_reg(dev, OMAP_I2C_IE_REG);
> omap_i2c_write_reg(dev, OMAP_I2C_IE_REG, 0);
> if (dev->rev1)
> iv = omap_i2c_read_reg(dev, OMAP_I2C_IV_REG);
> @@ -238,7 +249,7 @@ static void omap_i2c_idle(struct omap_i2c_dev *dev)
>
> static int omap_i2c_init(struct omap_i2c_dev *dev)
> {
> - u16 psc = 0, scll = 0, sclh = 0;
> + u16 psc = 0, scll = 0, sclh = 0, buf = 0;
> u16 fsscll = 0, fssclh = 0, hsscll = 0, hssclh = 0;
> unsigned long fclk_rate = 12000000;
> unsigned long timeout;
> @@ -327,23 +338,30 @@ static int omap_i2c_init(struct omap_i2c_dev *dev)
> omap_i2c_write_reg(dev, OMAP_I2C_SCLL_REG, scll);
> omap_i2c_write_reg(dev, OMAP_I2C_SCLH_REG, sclh);
>
> - if (dev->fifo_size)
> - /* Note: setup required fifo size - 1 */
> - omap_i2c_write_reg(dev, OMAP_I2C_BUF_REG,
> - (dev->fifo_size - 1) << 8 | /* RTRSH */
> - OMAP_I2C_BUF_RXFIF_CLR |
> - (dev->fifo_size - 1) | /* XTRSH */
> - OMAP_I2C_BUF_TXFIF_CLR);
> + if (dev->fifo_size) {
> + /* Note: setup required fifo size - 1. RTRSH and XTRSH */
> + buf = (dev->fifo_size - 1) << 8 | OMAP_I2C_BUF_RXFIF_CLR |
> + (dev->fifo_size - 1) | OMAP_I2C_BUF_TXFIF_CLR;
> + omap_i2c_write_reg(dev, OMAP_I2C_BUF_REG, buf);
> + }
>
> /* Take the I2C module out of reset: */
> omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, OMAP_I2C_CON_EN);
>
> /* Enable interrupts */
> - omap_i2c_write_reg(dev, OMAP_I2C_IE_REG,
> - (OMAP_I2C_IE_XRDY | OMAP_I2C_IE_RRDY |
> + dev->iestate = (OMAP_I2C_IE_XRDY | OMAP_I2C_IE_RRDY |
> OMAP_I2C_IE_ARDY | OMAP_I2C_IE_NACK |
> OMAP_I2C_IE_AL) | ((dev->fifo_size) ?
> - (OMAP_I2C_IE_RDR | OMAP_I2C_IE_XDR) : 0));
> + (OMAP_I2C_IE_RDR | OMAP_I2C_IE_XDR) : 0);
> + omap_i2c_write_reg(dev, OMAP_I2C_IE_REG, dev->iestate);
> +
> +#ifdef CONFIG_ARCH_OMAP34XX
> + dev->pscstate = psc;
> + dev->scllstate = scll;
> + dev->sclhstate = sclh;
> + dev->bufstate = buf;
> +#endif
> +
> return 0;
> }
>
> @@ -496,8 +514,6 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
>
> omap_i2c_unidle(dev);
>
> - omap_i2c_init(dev);
> -
> if ((r = omap_i2c_wait_for_bb(dev)) < 0)
> goto out;
>
> --
> Jouni Högander
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2008-09-16 9:25 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-11 15:55 [PATCH 04/12] I2C re-init for every cmd chandra shekhar
2008-09-12 7:48 ` Högander Jouni
2008-09-15 6:57 ` shekhar, chandra
2008-09-16 9:25 ` Kevin Hilman [this message]
2008-09-16 10:13 ` Högander Jouni
2008-09-17 9:45 ` [PATCH PM-0] OMAP3: I2C: Implement i2c save/restore Jouni Hogander
2008-09-17 11:18 ` Kevin Hilman
2008-09-17 11:25 ` Felipe Balbi
-- strict thread matches above, loose matches on Subject: below --
2008-09-01 13:38 [PATCH 04/12] I2C re-init for every cmd Rajendra Nayak
2008-09-11 10:04 ` Högander Jouni
2008-09-11 10:33 ` shekhar, chandra
2008-09-11 11:01 ` Högander Jouni
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=87d4j4moh3.fsf@deeprootsystems.com \
--to=khilman@deeprootsystems.com \
--cc=jouni.hogander@nokia.com \
--cc=linux-omap@vger.kernel.org \
--cc=x0044955@ti.com \
/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.