Lines Matching refs:p

67 static unsigned long timer16_get_counter(struct timer16_priv *p)  in timer16_get_counter()  argument
72 o1 = ctrl_inb(p->mapcommon + TISRC) & p->ovf; in timer16_get_counter()
77 v1 = ctrl_inw(p->mapbase + TCNT); in timer16_get_counter()
78 v2 = ctrl_inw(p->mapbase + TCNT); in timer16_get_counter()
79 v3 = ctrl_inw(p->mapbase + TCNT); in timer16_get_counter()
80 o1 = ctrl_inb(p->mapcommon + TISRC) & p->ovf; in timer16_get_counter()
91 struct timer16_priv *p = (struct timer16_priv *)dev_id; in timer16_interrupt() local
93 ctrl_outb(ctrl_inb(p->mapcommon + TISRA) & ~p->imfa, in timer16_interrupt()
94 p->mapcommon + TISRA); in timer16_interrupt()
95 p->total_cycles += 0x10000; in timer16_interrupt()
107 struct timer16_priv *p = cs_to_priv(cs); in timer16_clocksource_read() local
111 raw_spin_lock_irqsave(&p->lock, flags); in timer16_clocksource_read()
112 value = p->total_cycles; in timer16_clocksource_read()
113 raw = timer16_get_counter(p); in timer16_clocksource_read()
114 raw_spin_unlock_irqrestore(&p->lock, flags); in timer16_clocksource_read()
121 struct timer16_priv *p = cs_to_priv(cs); in timer16_enable() local
123 WARN_ON(p->cs_enabled); in timer16_enable()
125 p->total_cycles = 0; in timer16_enable()
126 ctrl_outw(0x0000, p->mapbase + TCNT); in timer16_enable()
127 ctrl_outb(0x83, p->mapbase + TCR); in timer16_enable()
128 ctrl_outb(ctrl_inb(p->mapcommon + TSTR) | p->enb, in timer16_enable()
129 p->mapcommon + TSTR); in timer16_enable()
131 p->cs_enabled = true; in timer16_enable()
137 struct timer16_priv *p = cs_to_priv(cs); in timer16_disable() local
139 WARN_ON(!p->cs_enabled); in timer16_disable()
141 ctrl_outb(ctrl_inb(p->mapcommon + TSTR) & ~p->enb, in timer16_disable()
142 p->mapcommon + TSTR); in timer16_disable()
144 p->cs_enabled = false; in timer16_disable()
150 static int timer16_setup(struct timer16_priv *p, struct platform_device *pdev) in timer16_setup() argument
156 p->pdev = pdev; in timer16_setup()
158 res[REG_CH] = platform_get_resource(p->pdev, in timer16_setup()
160 res[REG_COMM] = platform_get_resource(p->pdev, in timer16_setup()
163 dev_err(&p->pdev->dev, "failed to get I/O memory\n"); in timer16_setup()
166 irq = platform_get_irq(p->pdev, 0); in timer16_setup()
168 dev_err(&p->pdev->dev, "failed to get irq\n"); in timer16_setup()
172 p->clk = clk_get(&p->pdev->dev, "fck"); in timer16_setup()
173 if (IS_ERR(p->clk)) { in timer16_setup()
174 dev_err(&p->pdev->dev, "can't get clk\n"); in timer16_setup()
175 return PTR_ERR(p->clk); in timer16_setup()
177 of_property_read_u32(p->pdev->dev.of_node, "renesas,channel", &ch); in timer16_setup()
179 p->pdev = pdev; in timer16_setup()
180 p->mapbase = res[REG_CH]->start; in timer16_setup()
181 p->mapcommon = res[REG_COMM]->start; in timer16_setup()
182 p->enb = 1 << ch; in timer16_setup()
183 p->imfa = 1 << ch; in timer16_setup()
184 p->imiea = 1 << (4 + ch); in timer16_setup()
185 p->cs.name = pdev->name; in timer16_setup()
186 p->cs.rating = 200; in timer16_setup()
187 p->cs.read = timer16_clocksource_read; in timer16_setup()
188 p->cs.enable = timer16_enable; in timer16_setup()
189 p->cs.disable = timer16_disable; in timer16_setup()
190 p->cs.mask = CLOCKSOURCE_MASK(sizeof(unsigned long) * 8); in timer16_setup()
191 p->cs.flags = CLOCK_SOURCE_IS_CONTINUOUS; in timer16_setup()
194 IRQF_TIMER, pdev->name, p); in timer16_setup()
196 dev_err(&p->pdev->dev, "failed to request irq %d\n", irq); in timer16_setup()
200 clocksource_register_hz(&p->cs, clk_get_rate(p->clk) / 8); in timer16_setup()
207 struct timer16_priv *p = platform_get_drvdata(pdev); in timer16_probe() local
209 if (p) { in timer16_probe()
214 p = devm_kzalloc(&pdev->dev, sizeof(*p), GFP_KERNEL); in timer16_probe()
215 if (!p) in timer16_probe()
218 return timer16_setup(p, pdev); in timer16_probe()