Lines Matching refs:ir
64 #define REG_RXSTA_GET_AC(val) (((val) >> 8) & (ir->fifo_size * 2 - 1))
105 struct sunxi_ir *ir = dev_id; in sunxi_ir_irq() local
108 spin_lock(&ir->ir_lock); in sunxi_ir_irq()
110 status = readl(ir->base + SUNXI_IR_RXSTA_REG); in sunxi_ir_irq()
113 writel(status | REG_RXSTA_CLEARALL, ir->base + SUNXI_IR_RXSTA_REG); in sunxi_ir_irq()
119 rc = rc > ir->fifo_size ? ir->fifo_size : rc; in sunxi_ir_irq()
123 dt = readb(ir->base + SUNXI_IR_RXFIFO_REG); in sunxi_ir_irq()
126 ir_raw_event_store_with_filter(ir->rc, &rawir); in sunxi_ir_irq()
131 ir_raw_event_reset(ir->rc); in sunxi_ir_irq()
133 ir_raw_event_set_idle(ir->rc, true); in sunxi_ir_irq()
134 ir_raw_event_handle(ir->rc); in sunxi_ir_irq()
137 spin_unlock(&ir->ir_lock); in sunxi_ir_irq()
150 struct sunxi_ir *ir; in sunxi_ir_probe() local
152 ir = devm_kzalloc(dev, sizeof(struct sunxi_ir), GFP_KERNEL); in sunxi_ir_probe()
153 if (!ir) in sunxi_ir_probe()
156 spin_lock_init(&ir->ir_lock); in sunxi_ir_probe()
159 ir->fifo_size = 64; in sunxi_ir_probe()
161 ir->fifo_size = 16; in sunxi_ir_probe()
164 ir->apb_clk = devm_clk_get(dev, "apb"); in sunxi_ir_probe()
165 if (IS_ERR(ir->apb_clk)) { in sunxi_ir_probe()
167 return PTR_ERR(ir->apb_clk); in sunxi_ir_probe()
169 ir->clk = devm_clk_get(dev, "ir"); in sunxi_ir_probe()
170 if (IS_ERR(ir->clk)) { in sunxi_ir_probe()
172 return PTR_ERR(ir->clk); in sunxi_ir_probe()
176 ir->rst = devm_reset_control_get_optional(dev, NULL); in sunxi_ir_probe()
177 if (IS_ERR(ir->rst)) { in sunxi_ir_probe()
178 ret = PTR_ERR(ir->rst); in sunxi_ir_probe()
181 ir->rst = NULL; in sunxi_ir_probe()
183 ret = reset_control_deassert(ir->rst); in sunxi_ir_probe()
188 ret = clk_set_rate(ir->clk, SUNXI_IR_BASE_CLK); in sunxi_ir_probe()
194 if (clk_prepare_enable(ir->apb_clk)) { in sunxi_ir_probe()
200 if (clk_prepare_enable(ir->clk)) { in sunxi_ir_probe()
208 ir->base = devm_ioremap_resource(dev, res); in sunxi_ir_probe()
209 if (IS_ERR(ir->base)) { in sunxi_ir_probe()
211 ret = PTR_ERR(ir->base); in sunxi_ir_probe()
215 ir->rc = rc_allocate_device(); in sunxi_ir_probe()
216 if (!ir->rc) { in sunxi_ir_probe()
222 ir->rc->priv = ir; in sunxi_ir_probe()
223 ir->rc->input_name = SUNXI_IR_DEV; in sunxi_ir_probe()
224 ir->rc->input_phys = "sunxi-ir/input0"; in sunxi_ir_probe()
225 ir->rc->input_id.bustype = BUS_HOST; in sunxi_ir_probe()
226 ir->rc->input_id.vendor = 0x0001; in sunxi_ir_probe()
227 ir->rc->input_id.product = 0x0001; in sunxi_ir_probe()
228 ir->rc->input_id.version = 0x0100; in sunxi_ir_probe()
229 ir->map_name = of_get_property(dn, "linux,rc-map-name", NULL); in sunxi_ir_probe()
230 ir->rc->map_name = ir->map_name ?: RC_MAP_EMPTY; in sunxi_ir_probe()
231 ir->rc->dev.parent = dev; in sunxi_ir_probe()
232 ir->rc->driver_type = RC_DRIVER_IR_RAW; in sunxi_ir_probe()
233 ir->rc->allowed_protocols = RC_BIT_ALL; in sunxi_ir_probe()
234 ir->rc->rx_resolution = SUNXI_IR_SAMPLE; in sunxi_ir_probe()
235 ir->rc->timeout = MS_TO_NS(SUNXI_IR_TIMEOUT); in sunxi_ir_probe()
236 ir->rc->driver_name = SUNXI_IR_DEV; in sunxi_ir_probe()
238 ret = rc_register_device(ir->rc); in sunxi_ir_probe()
244 platform_set_drvdata(pdev, ir); in sunxi_ir_probe()
247 ir->irq = platform_get_irq(pdev, 0); in sunxi_ir_probe()
248 if (ir->irq < 0) { in sunxi_ir_probe()
250 ret = ir->irq; in sunxi_ir_probe()
254 ret = devm_request_irq(dev, ir->irq, sunxi_ir_irq, 0, SUNXI_IR_DEV, ir); in sunxi_ir_probe()
261 writel(REG_CTL_MD, ir->base+SUNXI_IR_CTL_REG); in sunxi_ir_probe()
265 ir->base + SUNXI_IR_CIR_REG); in sunxi_ir_probe()
268 writel(REG_RXCTL_RPPI, ir->base + SUNXI_IR_RXCTL_REG); in sunxi_ir_probe()
271 writel(REG_RXSTA_CLEARALL, ir->base + SUNXI_IR_RXSTA_REG); in sunxi_ir_probe()
278 REG_RXINT_RAI_EN | REG_RXINT_RAL(ir->fifo_size / 2 - 1), in sunxi_ir_probe()
279 ir->base + SUNXI_IR_RXINT_REG); in sunxi_ir_probe()
282 tmp = readl(ir->base + SUNXI_IR_CTL_REG); in sunxi_ir_probe()
283 writel(tmp | REG_CTL_GEN | REG_CTL_RXEN, ir->base + SUNXI_IR_CTL_REG); in sunxi_ir_probe()
289 rc_free_device(ir->rc); in sunxi_ir_probe()
291 clk_disable_unprepare(ir->clk); in sunxi_ir_probe()
293 clk_disable_unprepare(ir->apb_clk); in sunxi_ir_probe()
295 if (ir->rst) in sunxi_ir_probe()
296 reset_control_assert(ir->rst); in sunxi_ir_probe()
304 struct sunxi_ir *ir = platform_get_drvdata(pdev); in sunxi_ir_remove() local
306 clk_disable_unprepare(ir->clk); in sunxi_ir_remove()
307 clk_disable_unprepare(ir->apb_clk); in sunxi_ir_remove()
308 if (ir->rst) in sunxi_ir_remove()
309 reset_control_assert(ir->rst); in sunxi_ir_remove()
311 spin_lock_irqsave(&ir->ir_lock, flags); in sunxi_ir_remove()
313 writel(0, ir->base + SUNXI_IR_RXINT_REG); in sunxi_ir_remove()
315 writel(REG_RXSTA_CLEARALL, ir->base + SUNXI_IR_RXSTA_REG); in sunxi_ir_remove()
317 writel(0, ir->base + SUNXI_IR_CTL_REG); in sunxi_ir_remove()
318 spin_unlock_irqrestore(&ir->ir_lock, flags); in sunxi_ir_remove()
320 rc_unregister_device(ir->rc); in sunxi_ir_remove()