Lines Matching +full:ir +full:- +full:receiver
1 // SPDX-License-Identifier: GPL-2.0
3 * Driver for Amlogic Meson IR remote receiver
19 #include <media/rc-core.h>
21 #define DRIVER_NAME "meson-ir"
67 struct meson_ir *ir = dev_id; in meson_ir_irq() local
71 spin_lock(&ir->lock); in meson_ir_irq()
73 regmap_read(ir->reg, IR_DEC_REG1, &duration); in meson_ir_irq()
77 regmap_read(ir->reg, IR_DEC_STATUS, &status); in meson_ir_irq()
80 ir_raw_event_store_with_timeout(ir->rc, &rawir); in meson_ir_irq()
82 spin_unlock(&ir->lock); in meson_ir_irq()
89 struct device *dev = &pdev->dev; in meson_ir_probe()
90 struct device_node *node = dev->of_node; in meson_ir_probe()
93 struct meson_ir *ir; in meson_ir_probe() local
96 ir = devm_kzalloc(dev, sizeof(struct meson_ir), GFP_KERNEL); in meson_ir_probe()
97 if (!ir) in meson_ir_probe()
98 return -ENOMEM; in meson_ir_probe()
104 ir->reg = devm_regmap_init_mmio(&pdev->dev, res_start, in meson_ir_probe()
106 if (IS_ERR(ir->reg)) in meson_ir_probe()
107 return PTR_ERR(ir->reg); in meson_ir_probe()
113 ir->rc = devm_rc_allocate_device(dev, RC_DRIVER_IR_RAW); in meson_ir_probe()
114 if (!ir->rc) { in meson_ir_probe()
116 return -ENOMEM; in meson_ir_probe()
119 ir->rc->priv = ir; in meson_ir_probe()
120 ir->rc->device_name = DRIVER_NAME; in meson_ir_probe()
121 ir->rc->input_phys = DRIVER_NAME "/input0"; in meson_ir_probe()
122 ir->rc->input_id.bustype = BUS_HOST; in meson_ir_probe()
123 map_name = of_get_property(node, "linux,rc-map-name", NULL); in meson_ir_probe()
124 ir->rc->map_name = map_name ? map_name : RC_MAP_EMPTY; in meson_ir_probe()
125 ir->rc->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER; in meson_ir_probe()
126 ir->rc->rx_resolution = MESON_RAW_TRATE; in meson_ir_probe()
127 ir->rc->min_timeout = 1; in meson_ir_probe()
128 ir->rc->timeout = IR_DEFAULT_TIMEOUT; in meson_ir_probe()
129 ir->rc->max_timeout = 10 * IR_DEFAULT_TIMEOUT; in meson_ir_probe()
130 ir->rc->driver_name = DRIVER_NAME; in meson_ir_probe()
132 spin_lock_init(&ir->lock); in meson_ir_probe()
133 platform_set_drvdata(pdev, ir); in meson_ir_probe()
135 ret = devm_rc_register_device(dev, ir->rc); in meson_ir_probe()
141 ret = devm_request_irq(dev, irq, meson_ir_irq, 0, NULL, ir); in meson_ir_probe()
148 regmap_update_bits(ir->reg, IR_DEC_REG1, IR_DEC_REG1_RESET, in meson_ir_probe()
150 regmap_update_bits(ir->reg, IR_DEC_REG1, IR_DEC_REG1_RESET, 0); in meson_ir_probe()
153 if (of_device_is_compatible(node, "amlogic,meson6-ir")) in meson_ir_probe()
154 regmap_update_bits(ir->reg, IR_DEC_REG1, IR_DEC_REG1_MODE, in meson_ir_probe()
157 regmap_update_bits(ir->reg, IR_DEC_REG2, IR_DEC_REG2_MODE, in meson_ir_probe()
161 regmap_update_bits(ir->reg, IR_DEC_REG0, IR_DEC_REG0_BASE_TIME, in meson_ir_probe()
163 MESON_RAW_TRATE - 1)); in meson_ir_probe()
165 regmap_update_bits(ir->reg, IR_DEC_REG1, IR_DEC_REG1_IRQSEL, in meson_ir_probe()
168 regmap_update_bits(ir->reg, IR_DEC_REG1, IR_DEC_REG1_ENABLE, in meson_ir_probe()
171 dev_info(dev, "receiver initialized\n"); in meson_ir_probe()
178 struct meson_ir *ir = platform_get_drvdata(pdev); in meson_ir_remove() local
182 spin_lock_irqsave(&ir->lock, flags); in meson_ir_remove()
183 regmap_update_bits(ir->reg, IR_DEC_REG1, IR_DEC_REG1_ENABLE, 0); in meson_ir_remove()
184 spin_unlock_irqrestore(&ir->lock, flags); in meson_ir_remove()
189 struct device *dev = &pdev->dev; in meson_ir_shutdown()
190 struct device_node *node = dev->of_node; in meson_ir_shutdown()
191 struct meson_ir *ir = platform_get_drvdata(pdev); in meson_ir_shutdown() local
194 spin_lock_irqsave(&ir->lock, flags); in meson_ir_shutdown()
200 if (of_device_is_compatible(node, "amlogic,meson6-ir")) in meson_ir_shutdown()
201 regmap_update_bits(ir->reg, IR_DEC_REG1, IR_DEC_REG1_MODE, in meson_ir_shutdown()
204 regmap_update_bits(ir->reg, IR_DEC_REG2, IR_DEC_REG2_MODE, in meson_ir_shutdown()
208 regmap_update_bits(ir->reg, IR_DEC_REG0, IR_DEC_REG0_BASE_TIME, in meson_ir_shutdown()
210 MESON_HW_TRATE - 1)); in meson_ir_shutdown()
212 spin_unlock_irqrestore(&ir->lock, flags); in meson_ir_shutdown()
216 { .compatible = "amlogic,meson6-ir" },
217 { .compatible = "amlogic,meson8b-ir" },
218 { .compatible = "amlogic,meson-gxbb-ir" },
235 MODULE_DESCRIPTION("Amlogic Meson IR remote receiver driver");