Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] rc: sunxi-cir: Add support for the larger fifo found on sun5i and sun6i

Add support for the larger fifo found on sun5i and sun6i, having a separate
compatible for the ir found on sun5i & sun6i also is useful if we ever want
to add ir transmit support, because the sun5i & sun6i version do not have
transmit support.

Note this commits also adds checking for the end-of-packet interrupt flag
(which was already enabled), as the fifo-data-available interrupt flag only
gets set when the trigger-level is exceeded. So far we've been getting away
with not doing this because of the low trigger-level, but this is something
which we should have done since day one.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

authored by

Hans de Goede and committed by
Mauro Carvalho Chehab
a4bca4c7 44f8af68

+13 -10
+1 -1
Documentation/devicetree/bindings/media/sunxi-ir.txt
··· 1 1 Device-Tree bindings for SUNXI IR controller found in sunXi SoC family 2 2 3 3 Required properties: 4 - - compatible : should be "allwinner,sun4i-a10-ir"; 4 + - compatible : "allwinner,sun4i-a10-ir" or "allwinner,sun5i-a13-ir" 5 5 - clocks : list of clock specifiers, corresponding to 6 6 entries in clock-names property; 7 7 - clock-names : should contain "apb" and "ir" entries;
+12 -9
drivers/media/rc/sunxi-cir.c
··· 56 56 #define REG_RXINT_RAI_EN BIT(4) 57 57 58 58 /* Rx FIFO available byte level */ 59 - #define REG_RXINT_RAL(val) (((val) << 8) & (GENMASK(11, 8))) 59 + #define REG_RXINT_RAL(val) ((val) << 8) 60 60 61 61 /* Rx Interrupt Status */ 62 62 #define SUNXI_IR_RXSTA_REG 0x30 63 63 /* RX FIFO Get Available Counter */ 64 - #define REG_RXSTA_GET_AC(val) (((val) >> 8) & (GENMASK(5, 0))) 64 + #define REG_RXSTA_GET_AC(val) (((val) >> 8) & (ir->fifo_size * 2 - 1)) 65 65 /* Clear all interrupt status value */ 66 66 #define REG_RXSTA_CLEARALL 0xff 67 67 ··· 72 72 /* CIR_REG register idle threshold */ 73 73 #define REG_CIR_ITHR(val) (((val) << 8) & (GENMASK(15, 8))) 74 74 75 - /* Hardware supported fifo size */ 76 - #define SUNXI_IR_FIFO_SIZE 16 77 - /* How many messages in FIFO trigger IRQ */ 78 - #define TRIGGER_LEVEL 8 79 75 /* Required frequency for IR0 or IR1 clock in CIR mode */ 80 76 #define SUNXI_IR_BASE_CLK 8000000 81 77 /* Frequency after IR internal divider */ ··· 90 94 struct rc_dev *rc; 91 95 void __iomem *base; 92 96 int irq; 97 + int fifo_size; 93 98 struct clk *clk; 94 99 struct clk *apb_clk; 95 100 struct reset_control *rst; ··· 112 115 /* clean all pending statuses */ 113 116 writel(status | REG_RXSTA_CLEARALL, ir->base + SUNXI_IR_RXSTA_REG); 114 117 115 - if (status & REG_RXINT_RAI_EN) { 118 + if (status & (REG_RXINT_RAI_EN | REG_RXINT_RPEI_EN)) { 116 119 /* How many messages in fifo */ 117 120 rc = REG_RXSTA_GET_AC(status); 118 121 /* Sanity check */ 119 - rc = rc > SUNXI_IR_FIFO_SIZE ? SUNXI_IR_FIFO_SIZE : rc; 122 + rc = rc > ir->fifo_size ? ir->fifo_size : rc; 120 123 /* If we have data */ 121 124 for (cnt = 0; cnt < rc; cnt++) { 122 125 /* for each bit in fifo */ ··· 152 155 ir = devm_kzalloc(dev, sizeof(struct sunxi_ir), GFP_KERNEL); 153 156 if (!ir) 154 157 return -ENOMEM; 158 + 159 + if (of_device_is_compatible(dn, "allwinner,sun5i-a13-ir")) 160 + ir->fifo_size = 64; 161 + else 162 + ir->fifo_size = 16; 155 163 156 164 /* Clock */ 157 165 ir->apb_clk = devm_clk_get(dev, "apb"); ··· 273 271 * level 274 272 */ 275 273 writel(REG_RXINT_ROI_EN | REG_RXINT_RPEI_EN | 276 - REG_RXINT_RAI_EN | REG_RXINT_RAL(TRIGGER_LEVEL - 1), 274 + REG_RXINT_RAI_EN | REG_RXINT_RAL(ir->fifo_size / 2 - 1), 277 275 ir->base + SUNXI_IR_RXINT_REG); 278 276 279 277 /* Enable IR Module */ ··· 321 319 322 320 static const struct of_device_id sunxi_ir_match[] = { 323 321 { .compatible = "allwinner,sun4i-a10-ir", }, 322 + { .compatible = "allwinner,sun5i-a13-ir", }, 324 323 {}, 325 324 }; 326 325