aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2014-11-20 10:10:47 -0500
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2015-01-29 15:26:31 -0500
commita4bca4c7ad36a4cdafc87d1dce3758cdccef1ca7 (patch)
tree57f288efe59227906e53463052d6b70374f14022
parent44f8af68469a9a7c8507fade3e4ca4bba58c2ff1 (diff)
[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>
-rw-r--r--Documentation/devicetree/bindings/media/sunxi-ir.txt2
-rw-r--r--drivers/media/rc/sunxi-cir.c21
2 files changed, 13 insertions, 10 deletions
diff --git a/Documentation/devicetree/bindings/media/sunxi-ir.txt b/Documentation/devicetree/bindings/media/sunxi-ir.txt
index 6b70b9b47b7d..1811a067c72c 100644
--- a/Documentation/devicetree/bindings/media/sunxi-ir.txt
+++ b/Documentation/devicetree/bindings/media/sunxi-ir.txt
@@ -1,7 +1,7 @@
1Device-Tree bindings for SUNXI IR controller found in sunXi SoC family 1Device-Tree bindings for SUNXI IR controller found in sunXi SoC family
2 2
3Required properties: 3Required properties:
4- compatible : should be "allwinner,sun4i-a10-ir"; 4- compatible : "allwinner,sun4i-a10-ir" or "allwinner,sun5i-a13-ir"
5- clocks : list of clock specifiers, corresponding to 5- clocks : list of clock specifiers, corresponding to
6 entries in clock-names property; 6 entries in clock-names property;
7- clock-names : should contain "apb" and "ir" entries; 7- clock-names : should contain "apb" and "ir" entries;
diff --git a/drivers/media/rc/sunxi-cir.c b/drivers/media/rc/sunxi-cir.c
index 06170e01a5e9..7830aef3db45 100644
--- a/drivers/media/rc/sunxi-cir.c
+++ b/drivers/media/rc/sunxi-cir.c
@@ -56,12 +56,12 @@
56#define REG_RXINT_RAI_EN BIT(4) 56#define REG_RXINT_RAI_EN BIT(4)
57 57
58/* Rx FIFO available byte level */ 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/* Rx Interrupt Status */ 61/* Rx Interrupt Status */
62#define SUNXI_IR_RXSTA_REG 0x30 62#define SUNXI_IR_RXSTA_REG 0x30
63/* RX FIFO Get Available Counter */ 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/* Clear all interrupt status value */ 65/* Clear all interrupt status value */
66#define REG_RXSTA_CLEARALL 0xff 66#define REG_RXSTA_CLEARALL 0xff
67 67
@@ -72,10 +72,6 @@
72/* CIR_REG register idle threshold */ 72/* CIR_REG register idle threshold */
73#define REG_CIR_ITHR(val) (((val) << 8) & (GENMASK(15, 8))) 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/* Required frequency for IR0 or IR1 clock in CIR mode */ 75/* Required frequency for IR0 or IR1 clock in CIR mode */
80#define SUNXI_IR_BASE_CLK 8000000 76#define SUNXI_IR_BASE_CLK 8000000
81/* Frequency after IR internal divider */ 77/* Frequency after IR internal divider */
@@ -94,6 +90,7 @@ struct sunxi_ir {
94 struct rc_dev *rc; 90 struct rc_dev *rc;
95 void __iomem *base; 91 void __iomem *base;
96 int irq; 92 int irq;
93 int fifo_size;
97 struct clk *clk; 94 struct clk *clk;
98 struct clk *apb_clk; 95 struct clk *apb_clk;
99 struct reset_control *rst; 96 struct reset_control *rst;
@@ -115,11 +112,11 @@ static irqreturn_t sunxi_ir_irq(int irqno, void *dev_id)
115 /* clean all pending statuses */ 112 /* clean all pending statuses */
116 writel(status | REG_RXSTA_CLEARALL, ir->base + SUNXI_IR_RXSTA_REG); 113 writel(status | REG_RXSTA_CLEARALL, ir->base + SUNXI_IR_RXSTA_REG);
117 114
118 if (status & REG_RXINT_RAI_EN) { 115 if (status & (REG_RXINT_RAI_EN | REG_RXINT_RPEI_EN)) {
119 /* How many messages in fifo */ 116 /* How many messages in fifo */
120 rc = REG_RXSTA_GET_AC(status); 117 rc = REG_RXSTA_GET_AC(status);
121 /* Sanity check */ 118 /* Sanity check */
122 rc = rc > SUNXI_IR_FIFO_SIZE ? SUNXI_IR_FIFO_SIZE : rc; 119 rc = rc > ir->fifo_size ? ir->fifo_size : rc;
123 /* If we have data */ 120 /* If we have data */
124 for (cnt = 0; cnt < rc; cnt++) { 121 for (cnt = 0; cnt < rc; cnt++) {
125 /* for each bit in fifo */ 122 /* for each bit in fifo */
@@ -156,6 +153,11 @@ static int sunxi_ir_probe(struct platform_device *pdev)
156 if (!ir) 153 if (!ir)
157 return -ENOMEM; 154 return -ENOMEM;
158 155
156 if (of_device_is_compatible(dn, "allwinner,sun5i-a13-ir"))
157 ir->fifo_size = 64;
158 else
159 ir->fifo_size = 16;
160
159 /* Clock */ 161 /* Clock */
160 ir->apb_clk = devm_clk_get(dev, "apb"); 162 ir->apb_clk = devm_clk_get(dev, "apb");
161 if (IS_ERR(ir->apb_clk)) { 163 if (IS_ERR(ir->apb_clk)) {
@@ -271,7 +273,7 @@ static int sunxi_ir_probe(struct platform_device *pdev)
271 * level 273 * level
272 */ 274 */
273 writel(REG_RXINT_ROI_EN | REG_RXINT_RPEI_EN | 275 writel(REG_RXINT_ROI_EN | REG_RXINT_RPEI_EN |
274 REG_RXINT_RAI_EN | REG_RXINT_RAL(TRIGGER_LEVEL - 1), 276 REG_RXINT_RAI_EN | REG_RXINT_RAL(ir->fifo_size / 2 - 1),
275 ir->base + SUNXI_IR_RXINT_REG); 277 ir->base + SUNXI_IR_RXINT_REG);
276 278
277 /* Enable IR Module */ 279 /* Enable IR Module */
@@ -319,6 +321,7 @@ static int sunxi_ir_remove(struct platform_device *pdev)
319 321
320static const struct of_device_id sunxi_ir_match[] = { 322static const struct of_device_id sunxi_ir_match[] = {
321 { .compatible = "allwinner,sun4i-a10-ir", }, 323 { .compatible = "allwinner,sun4i-a10-ir", },
324 { .compatible = "allwinner,sun5i-a13-ir", },
322 {}, 325 {},
323}; 326};
324 327