Lines Matching refs:ir
61 #define REG_RXSTA_GET_AC(val) (((val) >> 8) & (ir->fifo_size * 2 - 1))
104 struct sunxi_ir *ir = dev_id; in sunxi_ir_irq() local
107 status = readl(ir->base + SUNXI_IR_RXSTA_REG); in sunxi_ir_irq()
110 writel(status | REG_RXSTA_CLEARALL, ir->base + SUNXI_IR_RXSTA_REG); in sunxi_ir_irq()
116 rc = rc > ir->fifo_size ? ir->fifo_size : rc; in sunxi_ir_irq()
120 dt = readb(ir->base + SUNXI_IR_RXFIFO_REG); in sunxi_ir_irq()
123 ir->rc->rx_resolution; in sunxi_ir_irq()
124 ir_raw_event_store_with_filter(ir->rc, &rawir); in sunxi_ir_irq()
129 ir_raw_event_overflow(ir->rc); in sunxi_ir_irq()
131 ir_raw_event_set_idle(ir->rc, true); in sunxi_ir_irq()
132 ir_raw_event_handle(ir->rc); in sunxi_ir_irq()
134 ir_raw_event_handle(ir->rc); in sunxi_ir_irq()
156 struct sunxi_ir *ir = rc_dev->priv; in sunxi_ir_set_timeout() local
157 unsigned int base_clk = clk_get_rate(ir->clk); in sunxi_ir_set_timeout()
165 ir->base + SUNXI_IR_CIR_REG); in sunxi_ir_set_timeout()
174 struct sunxi_ir *ir = dev_get_drvdata(dev); in sunxi_ir_hw_init() local
178 ret = reset_control_deassert(ir->rst); in sunxi_ir_hw_init()
182 ret = clk_prepare_enable(ir->apb_clk); in sunxi_ir_hw_init()
188 ret = clk_prepare_enable(ir->clk); in sunxi_ir_hw_init()
195 writel(REG_CTL_MD, ir->base + SUNXI_IR_CTL_REG); in sunxi_ir_hw_init()
198 sunxi_ir_set_timeout(ir->rc, ir->rc->timeout); in sunxi_ir_hw_init()
201 writel(REG_RXCTL_RPPI, ir->base + SUNXI_IR_RXCTL_REG); in sunxi_ir_hw_init()
204 writel(REG_RXSTA_CLEARALL, ir->base + SUNXI_IR_RXSTA_REG); in sunxi_ir_hw_init()
211 REG_RXINT_RAI_EN | REG_RXINT_RAL(ir->fifo_size / 2 - 1), in sunxi_ir_hw_init()
212 ir->base + SUNXI_IR_RXINT_REG); in sunxi_ir_hw_init()
215 tmp = readl(ir->base + SUNXI_IR_CTL_REG); in sunxi_ir_hw_init()
216 writel(tmp | REG_CTL_GEN | REG_CTL_RXEN, ir->base + SUNXI_IR_CTL_REG); in sunxi_ir_hw_init()
221 clk_disable_unprepare(ir->apb_clk); in sunxi_ir_hw_init()
223 reset_control_assert(ir->rst); in sunxi_ir_hw_init()
230 struct sunxi_ir *ir = dev_get_drvdata(dev); in sunxi_ir_hw_exit() local
232 clk_disable_unprepare(ir->clk); in sunxi_ir_hw_exit()
233 clk_disable_unprepare(ir->apb_clk); in sunxi_ir_hw_exit()
234 reset_control_assert(ir->rst); in sunxi_ir_hw_exit()
258 struct sunxi_ir *ir; in sunxi_ir_probe() local
261 ir = devm_kzalloc(dev, sizeof(struct sunxi_ir), GFP_KERNEL); in sunxi_ir_probe()
262 if (!ir) in sunxi_ir_probe()
271 ir->fifo_size = quirks->fifo_size; in sunxi_ir_probe()
274 ir->apb_clk = devm_clk_get(dev, "apb"); in sunxi_ir_probe()
275 if (IS_ERR(ir->apb_clk)) { in sunxi_ir_probe()
277 return PTR_ERR(ir->apb_clk); in sunxi_ir_probe()
279 ir->clk = devm_clk_get(dev, "ir"); in sunxi_ir_probe()
280 if (IS_ERR(ir->clk)) { in sunxi_ir_probe()
282 return PTR_ERR(ir->clk); in sunxi_ir_probe()
290 ir->rst = devm_reset_control_get_exclusive(dev, NULL); in sunxi_ir_probe()
291 if (IS_ERR(ir->rst)) in sunxi_ir_probe()
292 return PTR_ERR(ir->rst); in sunxi_ir_probe()
295 ret = clk_set_rate(ir->clk, b_clk_freq); in sunxi_ir_probe()
303 ir->base = devm_platform_ioremap_resource(pdev, 0); in sunxi_ir_probe()
304 if (IS_ERR(ir->base)) { in sunxi_ir_probe()
305 return PTR_ERR(ir->base); in sunxi_ir_probe()
308 ir->rc = rc_allocate_device(RC_DRIVER_IR_RAW); in sunxi_ir_probe()
309 if (!ir->rc) { in sunxi_ir_probe()
314 ir->rc->priv = ir; in sunxi_ir_probe()
315 ir->rc->device_name = SUNXI_IR_DEV; in sunxi_ir_probe()
316 ir->rc->input_phys = "sunxi-ir/input0"; in sunxi_ir_probe()
317 ir->rc->input_id.bustype = BUS_HOST; in sunxi_ir_probe()
318 ir->rc->input_id.vendor = 0x0001; in sunxi_ir_probe()
319 ir->rc->input_id.product = 0x0001; in sunxi_ir_probe()
320 ir->rc->input_id.version = 0x0100; in sunxi_ir_probe()
321 ir->map_name = of_get_property(dn, "linux,rc-map-name", NULL); in sunxi_ir_probe()
322 ir->rc->map_name = ir->map_name ?: RC_MAP_EMPTY; in sunxi_ir_probe()
323 ir->rc->dev.parent = dev; in sunxi_ir_probe()
324 ir->rc->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER; in sunxi_ir_probe()
326 ir->rc->rx_resolution = (USEC_PER_SEC / (b_clk_freq / 64)); in sunxi_ir_probe()
327 ir->rc->timeout = IR_DEFAULT_TIMEOUT; in sunxi_ir_probe()
328 ir->rc->min_timeout = sunxi_ithr_to_usec(b_clk_freq, 0); in sunxi_ir_probe()
329 ir->rc->max_timeout = sunxi_ithr_to_usec(b_clk_freq, 255); in sunxi_ir_probe()
330 ir->rc->s_timeout = sunxi_ir_set_timeout; in sunxi_ir_probe()
331 ir->rc->driver_name = SUNXI_IR_DEV; in sunxi_ir_probe()
333 ret = rc_register_device(ir->rc); in sunxi_ir_probe()
339 platform_set_drvdata(pdev, ir); in sunxi_ir_probe()
342 ir->irq = platform_get_irq(pdev, 0); in sunxi_ir_probe()
343 if (ir->irq < 0) { in sunxi_ir_probe()
344 ret = ir->irq; in sunxi_ir_probe()
348 ret = devm_request_irq(dev, ir->irq, sunxi_ir_irq, 0, SUNXI_IR_DEV, ir); in sunxi_ir_probe()
362 rc_free_device(ir->rc); in sunxi_ir_probe()
369 struct sunxi_ir *ir = platform_get_drvdata(pdev); in sunxi_ir_remove() local
371 rc_unregister_device(ir->rc); in sunxi_ir_remove()