From: Jarkko Nikula <jhnikula@gmail.com>
To: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
Cc: Tony Lindgren <tony@atomide.com>,
"linux-omap@vger.kernel.org" <linux-omap@vger.kernel.org>
Subject: Re: [RFC][PATCH v2] OMAP: McBSP: Use register cache
Date: Thu, 26 Nov 2009 10:00:00 +0200 [thread overview]
Message-ID: <20091126100000.add50e72.jhnikula@gmail.com> (raw)
In-Reply-To: <200911241231.18333.jkrzyszt@tis.icnet.pl>
Hi
On Tue, 24 Nov 2009 12:31:16 +0100
Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> wrote:
> -#define OMAP_MCBSP_READ(base, reg) \
> - omap_mcbsp_read(base, OMAP_MCBSP_REG_##reg)
> -#define OMAP_MCBSP_WRITE(base, reg, val) \
> - omap_mcbsp_write(base, OMAP_MCBSP_REG_##reg, val)
> +#define OMAP_MCBSP_READ(mcbsp, reg) \
> + omap_mcbsp_read(mcbsp->io_base, OMAP_MCBSP_REG_##reg)
> +#define OMAP_MCBSP_WRITE(mcbsp, reg, val) \
> + omap_mcbsp_write(mcbsp->io_base, OMAP_MCBSP_REG_##reg, val)
> +
> +#define OMAP_MCBSP_CREAD(mcbsp, reg) \
> + (mcbsp->reg_cache[OMAP_MCBSP_REG_##reg / OMAP_MCBSP_REG_DRR1])
> +#define OMAP_MCBSP_CWRITE(mcbsp, reg, val) \
> + omap_mcbsp_write(mcbsp->io_base, OMAP_MCBSP_REG_##reg, \
> + mcbsp->reg_cache[OMAP_MCBSP_REG_##reg / OMAP_MCBSP_REG_DRR1] \
> + = val)
> +
Have rather single write writing both the cache and actual register.
I.e. keep the OMAP_MCBSP_WRITE since writes should always go to hw and
makes the patch smaller. I also found the OMAP_MCBSP_CREAD a little
unclear so I suggest to name is as OMAP_MCBSP_READ_CACHE.
> +#define OMAP_MCBSP_BREAD(mcbsp, reg) \
> + (mcbsp->reg_cache[OMAP_MCBSP_REG_##reg / OMAP_MCBSP_REG_DRR1] \
> + = OMAP_MCBSP_READ(mcbsp->io_base, reg))
>
Why is this? There is nothing eating this :-)
> dev_dbg(mcbsp->dev, "DRR2: 0x%04x\n",
> - OMAP_MCBSP_READ(mcbsp->io_base, DRR2));
> + OMAP_MCBSP_READ(mcbsp, DRR2));
These changes are worth to send as a separate cleanup patch. Will make
the actual cache patch smaller and easier to follow.
> @@ -93,15 +104,15 @@ static irqreturn_t omap_mcbsp_tx_irq_han
> struct omap_mcbsp *mcbsp_tx = dev_id;
> u16 irqst_spcr2;
>
> - irqst_spcr2 = OMAP_MCBSP_READ(mcbsp_tx->io_base, SPCR2);
> + irqst_spcr2 = OMAP_MCBSP_READ(mcbsp_tx, SPCR2);
> dev_dbg(mcbsp_tx->dev, "TX IRQ callback : 0x%x\n", irqst_spcr2);
>
> if (irqst_spcr2 & XSYNC_ERR) {
> dev_err(mcbsp_tx->dev, "TX Frame Sync Error! : 0x%x\n",
> irqst_spcr2);
> /* Writing zero to XSYNC_ERR clears the IRQ */
> - OMAP_MCBSP_WRITE(mcbsp_tx->io_base, SPCR2,
> - irqst_spcr2 & ~(XSYNC_ERR));
> + OMAP_MCBSP_CWRITE(mcbsp_tx, SPCR2,
> + OMAP_MCBSP_CREAD(mcbsp_tx, SPCR2) & ~(XSYNC_ERR));
I was thinking that should these read+read_cache changes be a separate
patch for fixing the 1510 issues since no other OMAPs are known to
corrupt registers and plain hw read is enough for them.
> @@ -612,7 +612,6 @@ EXPORT_SYMBOL(omap_mcbsp_stop);
> int omap_mcbsp_pollwrite(unsigned int id, u16 buf)
> {
> struct omap_mcbsp *mcbsp;
> - void __iomem *base;
>
> if (!omap_mcbsp_check_valid_id(id)) {
> printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
> @@ -620,28 +619,27 @@ int omap_mcbsp_pollwrite(unsigned int id
> }
>
> mcbsp = id_to_mcbsp_ptr(id);
> - base = mcbsp->io_base;
>
> - writew(buf, base + OMAP_MCBSP_REG_DXR1);
> + OMAP_MCBSP_WRITE(mcbsp, DXR1, buf);
> /* if frame sync error - clear the error */
> - if (readw(base + OMAP_MCBSP_REG_SPCR2) & XSYNC_ERR) {
> + if (OMAP_MCBSP_READ(mcbsp, SPCR2) & XSYNC_ERR) {
These looks also that these are better to cover with its own separate
cleanup patch.
---
I'm not completely sure are there any code path expecting to read reset
default values from the cache or are there always explicit write or
read before it? I was thinking would it be necessary to initialize the
cache by issuing dummy reads for all registers. IRCC the OMAP2420 has
fewer registers than 2430 or OMAP3 so that should be took into account
if there is a need to do so.
--
Jarkko
next prev parent reply other threads:[~2009-11-26 7:58 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-12 10:39 [RFC][PATCH] ARM: OMAP: McBSP: Use register cache Janusz Krzysztofik
2009-08-28 11:26 ` Janusz Krzysztofik
2009-11-14 2:06 ` Janusz Krzysztofik
2009-11-23 20:42 ` Janusz Krzysztofik
2009-11-23 23:53 ` Tony Lindgren
2009-11-24 7:59 ` Jarkko Nikula
2009-11-24 11:31 ` [RFC][PATCH v2] " Janusz Krzysztofik
2009-11-26 8:00 ` Jarkko Nikula [this message]
2009-11-26 13:25 ` Janusz Krzysztofik
2009-11-28 16:14 ` Jarkko Nikula
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=20091126100000.add50e72.jhnikula@gmail.com \
--to=jhnikula@gmail.com \
--cc=jkrzyszt@tis.icnet.pl \
--cc=linux-omap@vger.kernel.org \
--cc=tony@atomide.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox