Lines Matching +full:cs +full:- +full:to +full:- +full:clk
1 // SPDX-License-Identifier: GPL-2.0
13 #include <linux/clk.h>
26 struct clocksource cs; member
37 tcnt = ioread16be(p->mapbase1 + TCNT) << 16; in read_tcnt32()
38 tcnt |= ioread16be(p->mapbase2 + TCNT); in read_tcnt32()
47 o1 = ioread8(p->mapbase1 + TSR) & TCFV; in tpu_get_counter()
55 o1 = ioread8(p->mapbase1 + TSR) & TCFV; in tpu_get_counter()
63 static inline struct tpu_priv *cs_to_priv(struct clocksource *cs) in cs_to_priv() argument
65 return container_of(cs, struct tpu_priv, cs); in cs_to_priv()
68 static u64 tpu_clocksource_read(struct clocksource *cs) in tpu_clocksource_read() argument
70 struct tpu_priv *p = cs_to_priv(cs); in tpu_clocksource_read()
74 raw_spin_lock_irqsave(&p->lock, flags); in tpu_clocksource_read()
77 raw_spin_unlock_irqrestore(&p->lock, flags); in tpu_clocksource_read()
82 static int tpu_clocksource_enable(struct clocksource *cs) in tpu_clocksource_enable() argument
84 struct tpu_priv *p = cs_to_priv(cs); in tpu_clocksource_enable()
86 WARN_ON(p->cs_enabled); in tpu_clocksource_enable()
88 iowrite16be(0, p->mapbase1 + TCNT); in tpu_clocksource_enable()
89 iowrite16be(0, p->mapbase2 + TCNT); in tpu_clocksource_enable()
90 iowrite8(0x0f, p->mapbase1 + TCR); in tpu_clocksource_enable()
91 iowrite8(0x03, p->mapbase2 + TCR); in tpu_clocksource_enable()
93 p->cs_enabled = true; in tpu_clocksource_enable()
97 static void tpu_clocksource_disable(struct clocksource *cs) in tpu_clocksource_disable() argument
99 struct tpu_priv *p = cs_to_priv(cs); in tpu_clocksource_disable()
101 WARN_ON(!p->cs_enabled); in tpu_clocksource_disable()
103 iowrite8(0, p->mapbase1 + TCR); in tpu_clocksource_disable()
104 iowrite8(0, p->mapbase2 + TCR); in tpu_clocksource_disable()
105 p->cs_enabled = false; in tpu_clocksource_disable()
109 .cs = {
126 struct clk *clk; in h8300_tpu_init() local
127 int ret = -ENXIO; in h8300_tpu_init()
129 clk = of_clk_get(node, 0); in h8300_tpu_init()
130 if (IS_ERR(clk)) { in h8300_tpu_init()
131 pr_err("failed to get clock for clocksource\n"); in h8300_tpu_init()
132 return PTR_ERR(clk); in h8300_tpu_init()
137 pr_err("failed to map registers for clocksource\n"); in h8300_tpu_init()
142 pr_err("failed to map registers for clocksource\n"); in h8300_tpu_init()
149 return clocksource_register_hz(&tpu_priv.cs, clk_get_rate(clk) / 64); in h8300_tpu_init()
154 clk_put(clk); in h8300_tpu_init()