Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 372269
b: refs/heads/master
c: 587acb3
h: refs/heads/master
i:
  372267: c0478f4
v: v3
  • Loading branch information
Magnus Damm authored and Simon Horman committed Mar 12, 2013
1 parent c26f256 commit 75bfe8d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 37 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: adccc69e7ad1815ce79b073830b244a803776bbd
refs/heads/master: 587acb3dd5cf387de1325309e831fd0f560d1bf6
66 changes: 30 additions & 36 deletions trunk/drivers/clocksource/sh_cmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,44 +56,46 @@ struct sh_cmt_priv {
bool cs_enabled;
};

static DEFINE_RAW_SPINLOCK(sh_cmt_lock);
static inline unsigned long sh_cmt_read16(void __iomem *base,
unsigned long offs)
{
return ioread16(base + (offs << 1));
}

static inline void sh_cmt_write16(void __iomem *base, unsigned long offs,
unsigned long value)
{
iowrite16(value, base + (offs << 1));
}

#define CMSTR -1 /* shared register */
#define CMCSR 0 /* channel register */
#define CMCNT 1 /* channel register */
#define CMCOR 2 /* channel register */

static inline unsigned long sh_cmt_read(struct sh_cmt_priv *p, int reg_nr)
{
struct sh_timer_config *cfg = p->pdev->dev.platform_data;
void __iomem *base = p->mapbase;
unsigned long offs;

if (reg_nr == CMSTR) {
offs = 0;
base -= cfg->channel_offset;
} else
offs = reg_nr;
unsigned long offs = reg_nr;

if (p->width == 16)
if (p->width == 16) {
offs <<= 1;
else {
return ioread16(base + offs);
} else {
offs <<= 2;
if ((reg_nr == CMCNT) || (reg_nr == CMCOR))
return ioread32(base + offs);
return ioread32(base + offs);
}

return ioread16(base + offs);
}

static inline unsigned long sh_cmt_read_cmstr(struct sh_cmt_priv *p)
{
return sh_cmt_read(p, CMSTR);
struct sh_timer_config *cfg = p->pdev->dev.platform_data;

return sh_cmt_read16(p->mapbase - cfg->channel_offset, 0);
}

static inline unsigned long sh_cmt_read_cmcsr(struct sh_cmt_priv *p)
{
return sh_cmt_read(p, CMCSR);
return sh_cmt_read16(p->mapbase, CMCSR);
}

static inline unsigned long sh_cmt_read_cmcnt(struct sh_cmt_priv *p)
Expand All @@ -104,39 +106,30 @@ static inline unsigned long sh_cmt_read_cmcnt(struct sh_cmt_priv *p)
static inline void sh_cmt_write(struct sh_cmt_priv *p, int reg_nr,
unsigned long value)
{
struct sh_timer_config *cfg = p->pdev->dev.platform_data;
void __iomem *base = p->mapbase;
unsigned long offs;
unsigned long offs = reg_nr;

if (reg_nr == CMSTR) {
offs = 0;
base -= cfg->channel_offset;
} else
offs = reg_nr;

if (p->width == 16)
if (p->width == 16) {
offs <<= 1;
else {
iowrite16(value, base + offs);
} else {
offs <<= 2;
if ((reg_nr == CMCNT) || (reg_nr == CMCOR)) {
iowrite32(value, base + offs);
return;
}
iowrite32(value, base + offs);
}

iowrite16(value, base + offs);
}

static inline void sh_cmt_write_cmstr(struct sh_cmt_priv *p,
unsigned long value)
{
sh_cmt_write(p, CMSTR, value);
struct sh_timer_config *cfg = p->pdev->dev.platform_data;

sh_cmt_write16(p->mapbase - cfg->channel_offset, 0, value);
}

static inline void sh_cmt_write_cmcsr(struct sh_cmt_priv *p,
unsigned long value)
{
sh_cmt_write(p, CMCSR, value);
sh_cmt_write16(p->mapbase, CMCSR, value);
}

static inline void sh_cmt_write_cmcnt(struct sh_cmt_priv *p,
Expand Down Expand Up @@ -173,6 +166,7 @@ static unsigned long sh_cmt_get_counter(struct sh_cmt_priv *p,
return v2;
}

static DEFINE_RAW_SPINLOCK(sh_cmt_lock);

static void sh_cmt_start_stop_ch(struct sh_cmt_priv *p, int start)
{
Expand Down

0 comments on commit 75bfe8d

Please sign in to comment.