Skip to contentSkip to conversation

ARM: sunxi: Add support for consumer infrared devices

PATCH Applied Alexander Bersenev 2 participants 9 messages Jun 8, 2014 – Jun 16, 2014

Subsystems (4)

v9 of 10 Applied Latest is v10 →

lore
Share & tools
lore
#0 lore raw

v9 cover ARM: sunxi: Add support for consumer infrared devices

This patch introduces Consumer IR(CIR) support for sunxi boards.

This is based on Alexsey Shestacov's work based on the original driver supplied by Allwinner.

---
Changes since version 1:
- Fix timer memory leaks
- Fix race condition when driver unloads while interrupt handler is active
- Support Cubieboard 2(need testing)

Changes since version 2:
- More reliable keydown events
- Documentation fixes
- Rename registers accurding to A20 user manual
- Remove some includes, order includes alphabetically
- Use BIT macro
- Typo fixes

Changes since version 3:
- Split the patch on smaller parts
- More documentation fixes
- Add clock-names in DT
- Use devm_clk_get function to get the clocks
- Removed gpios property from ir's DT
- Changed compatible from allwinner,sunxi-ir to allwinner,sun7i-a20-ir in DT
- Use spin_lock_irq instead spin_lock_irqsave in interrupt handler
- Add myself in the copyright ;)
- Coding style and indentation fixes

Changes since version 4:
- Try to fix indentation errors by sending patches with git send-mail

Changes since version 5:
- More indentation fixes
- Make patches pass checkpatch with --strict option
- Replaced magic numbers with defines(patch by Priit Laes)
- Fixed oops on loading(patch by Hans de Goede)

Changes since version 6:
- Removed constants from code
- Better errrors handling on loading
- Renamed sunxi-ir.c to sunxi-cir.c
- Changed description of second commit
- Order entries in dts and dtsi by register address
- Code style fixes

Changes since version 7:
- Removed a couple of blank lines in code
- Delay interrupts init until we are ready to handle them
- Increased the reported duration of each pulse by one
- Refactored defines

Changes since version 8:
- Split the DT patch to three
- Code style fixes

Alexander Bersenev (5):
ARM: sunxi: Add documentation for sunxi consumer infrared devices [media] rc: add sunxi-ir driver
ARM: sunxi: Add pins for IR controller on A20 to dtsi
ARM: sunxi: Add IR controllers on A20 to dtsi
ARM: sunxi: Enable IR controller on cubieboard 2 and cubietruck in dts

 .../devicetree/bindings/media/sunxi-ir.txt         |  23 ++
 arch/arm/boot/dts/sun7i-a20-cubieboard2.dts        |   6 +
 arch/arm/boot/dts/sun7i-a20-cubietruck.dts         |   6 +
 arch/arm/boot/dts/sun7i-a20.dtsi                   |  32 +++
 drivers/media/rc/Kconfig                           |  10 +
 drivers/media/rc/Makefile                          |   1 +
 drivers/media/rc/sunxi-cir.c                       | 318 +++++++++++++++++++++
 7 files changed, 396 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/sunxi-ir.txt
 create mode 100644 drivers/media/rc/sunxi-cir.c
Signature · 1 line
1.9.3
#1 lore raw

PATCH v9 1/5 ARM: sunxi: Add documentation for sunxi consumer infrared devices

This patch adds documentation for Device-Tree bindings for sunxi IR controller.

---
 .../devicetree/bindings/media/sunxi-ir.txt         | 23 ++++++++++++++++++++++
 1 file changed, 23 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/sunxi-ir.txt
Documentation/devicetree/bindings/media/sunxi-ir.txt new file +23 -0
new file mode 100644
index 0000000..014dd8b
@@ -0,0 +1,23 @@
+Device-Tree bindings for SUNXI IR controller found in sunXi SoC family
+
+Required properties:
+- compatible	    : should be "allwinner,sun7i-a20-ir";
+- clocks	    : list of clock specifiers, corresponding to
+		      entries in clock-names property;
+- clock-names	    : should contain "apb" and "ir" entries;
+- interrupts	    : should contain IR IRQ number;
+- reg		    : should contain IO map address for IR.
+
+Optional properties:
+- linux,rc-map-name : Remote control map name.
+
+Example:
+
+ir0: ir at 01c21800 {
+	compatible = "allwinner,sun7i-a20-ir";
+	clocks = <&apb0_gates 6>, <&ir0_clk>;
+	clock-names = "apb", "ir";
+	interrupts = <0 5 1>;
+	reg = <0x01C21800 0x40>;
+	linux,rc-map-name = "rc-rc6-mce";
+};
Signature · 1 line
1.9.3
#2 lore raw

PATCH v9 2/5 rc: add sunxi-ir driver

In reply to Alexander Bersenev

This patch adds driver for sunxi IR controller.
It is based on Alexsey Shestacov's work based on the original driver supplied by Allwinner.

---
 drivers/media/rc/Kconfig     |  10 ++
 drivers/media/rc/Makefile    |   1 +
 drivers/media/rc/sunxi-cir.c | 318 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 329 insertions(+)
 create mode 100644 drivers/media/rc/sunxi-cir.c
drivers/media/rc/Kconfig +10 -0
index 8fbd377..9427fad 100644
@@ -343,4 +343,14 @@ config RC_ST
 
 	 If you're not sure, select N here.
 
+config IR_SUNXI
+    tristate "SUNXI IR remote control"
+    depends on RC_CORE
+    depends on ARCH_SUNXI
+    ---help---
+      Say Y if you want to use sunXi internal IR Controller
+
+      To compile this driver as a module, choose M here: the module will
+      be called sunxi-ir.
+
 endif #RC_DEVICES
drivers/media/rc/Makefile +1 -0
index f8b54ff..9ee9ee7 100644
@@ -32,4 +32,5 @@ obj-$(CONFIG_IR_GPIO_CIR) += gpio-ir-recv.o
 obj-$(CONFIG_IR_IGUANA) += iguanair.o
 obj-$(CONFIG_IR_TTUSBIR) += ttusbir.o
 obj-$(CONFIG_RC_ST) += st_rc.o
+obj-$(CONFIG_IR_SUNXI) += sunxi-cir.o
 obj-$(CONFIG_IR_IMG) += img-ir/
drivers/media/rc/sunxi-cir.c new file +318 -0

318 lines not on this page · raw message

Signature · 1 line
1.9.3
#3 lore raw

PATCH v9 3/5 ARM: sunxi: Add pins for IR controller on A20 to dtsi

In reply to Alexander Bersenev

This patch adds pins for two IR controllers on A20

---
 arch/arm/boot/dts/sun7i-a20.dtsi | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
arch/arm/boot/dts/sun7i-a20.dtsi +14 -0
index 0ae2b77..c057c3e 100644
@@ -724,6 +724,20 @@
 				allwinner,drive = <2>;
 				allwinner,pull = <0>;
 			};
+
+			ir0_pins_a: ir0 at 0 {
+				    allwinner,pins = "PB3","PB4";
+				    allwinner,function = "ir0";
+				    allwinner,drive = <0>;
+				    allwinner,pull = <0>;
+			};
+
+			ir1_pins_a: ir1 at 0 {
+				    allwinner,pins = "PB22","PB23";
+				    allwinner,function = "ir1";
+				    allwinner,drive = <0>;
+				    allwinner,pull = <0>;
+			};
 		};
 
 		timer at 01c20c00 {
Signature · 1 line
1.9.3
#4 lore raw

Re: [PATCH v9 3/5] ARM: sunxi: Add pins for IR controller on A20 to dtsi

Hi,

Quoted 4 lines · Alexander Bersenev

This patch adds pins for two IR controllers on A20

Applied, thanks.

Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140616/fc6dfbe5/attachment.sig>
#5 lore raw

PATCH v9 4/5 ARM: sunxi: Add IR controllers on A20 to dtsi

In reply to Alexander Bersenev

This patch adds records for two IR controllers on A20

---
 arch/arm/boot/dts/sun7i-a20.dtsi | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
arch/arm/boot/dts/sun7i-a20.dtsi +18 -0
index c057c3e..fe1f8ff 100644
@@ -763,6 +763,24 @@
 			interrupts = <0 24 4>;
 		};
 
+		ir0: ir at 01c21800 {
+			compatible = "allwinner,sun7i-a20-ir";
+			clocks = <&apb0_gates 6>, <&ir0_clk>;
+			clock-names = "apb", "ir";
+			interrupts = <0 5 4>;
+			reg = <0x01c21800 0x40>;
+			status = "disabled";
+		};
+
+		ir1: ir at 01c21c00 {
+			compatible = "allwinner,sun7i-a20-ir";
+			clocks = <&apb0_gates 7>, <&ir1_clk>;
+			clock-names = "apb", "ir";
+			interrupts = <0 6 4>;
+			reg = <0x01c21c00 0x40>;
+			status = "disabled";
+		};
+
 		lradc: lradc at 01c22800 {
 			compatible = "allwinner,sun4i-lradc-keys";
 			reg = <0x01c22800 0x100>;
Signature · 1 line
1.9.3
#6 lore raw

Re: [PATCH v9 4/5] ARM: sunxi: Add IR controllers on A20 to dtsi

Hi,

Quoted 27 lines · Alexander Bersenev

This patch adds records for two IR controllers on A20

---
 arch/arm/boot/dts/sun7i-a20.dtsi | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
arch/arm/boot/dts/sun7i-a20.dtsi +11 -0
index c057c3e..fe1f8ff 100644
@@ -763,6 +763,24 @@
 			interrupts = <0 24 4>;
 		};
 
+		ir0: ir at 01c21800 {
+			compatible = "allwinner,sun7i-a20-ir";
+			clocks = <&apb0_gates 6>, <&ir0_clk>;
+			clock-names = "apb", "ir";
+			interrupts = <0 5 4>;
+			reg = <0x01c21800 0x40>;
+			status = "disabled";
+		};
+
+		ir1: ir at 01c21c00 {
+			compatible = "allwinner,sun7i-a20-ir";

arch/arm/boot/dts/sun7i-a20.dtsi line 786

Quoted 10 lines
arch/arm/boot/dts/sun7i-a20.dtsi +7 -0
+			clocks = <&apb0_gates 7>, <&ir1_clk>;
+			clock-names = "apb", "ir";
+			interrupts = <0 6 4>;
+			reg = <0x01c21c00 0x40>;
+			status = "disabled";
+		};
+
 		lradc: lradc at 01c22800 {
 			compatible = "allwinner,sun4i-lradc-keys";
 			reg = <0x01c22800 0x100>;

I'm fine with this patch, but it doesn't apply, since the above node doesn't exist. Please rebase on top of v3.16-rc1 and resend the patch.

Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140616/2a8c3068/attachment.sig>
#7 lore raw

PATCH v9 5/5 ARM: sunxi: Enable IR controller on cubieboard 2 and cubietruck in dts

In reply to Alexander Bersenev

This patch enables two IR devices in dts:
- One IR device physically found on Cubieboard 2
- One IR device physically found on Cubietruck

---
 arch/arm/boot/dts/sun7i-a20-cubieboard2.dts | 6 ++++++
 arch/arm/boot/dts/sun7i-a20-cubietruck.dts  | 6 ++++++
 2 files changed, 12 insertions(+)
arch/arm/boot/dts/sun7i-a20-cubieboard2.dts +6 -0
index feeff64..b44d61b 100644
@@ -65,6 +65,12 @@
 			};
 		};
 
+		ir0: ir at 01c21800 {
+			pinctrl-names = "default";
+			pinctrl-0 = <&ir0_pins_a>;
+			status = "okay";
+		};
+
 		uart0: serial at 01c28000 {
 			pinctrl-names = "default";
 			pinctrl-0 = <&uart0_pins_a>;
arch/arm/boot/dts/sun7i-a20-cubietruck.dts +6 -0
index e288562..5f5c31d 100644
@@ -121,6 +121,12 @@
 			};
 		};
 
+		ir0: ir at 01c21800 {
+			pinctrl-names = "default";
+			pinctrl-0 = <&ir0_pins_a>;
+			status = "okay";
+		};
+
 		uart0: serial at 01c28000 {
 			pinctrl-names = "default";
 			pinctrl-0 = <&uart0_pins_a>;
Signature · 1 line
1.9.3
#8 lore raw

Re: [PATCH v9 5/5] ARM: sunxi: Enable IR controller on cubieboard 2 and cubietruck in dts

Quoted 6 lines · Alexander Bersenev

This patch enables two IR devices in dts:
- One IR device physically found on Cubieboard 2
- One IR device physically found on Cubietruck

Applied, thanks.

Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140616/1e3832e0/attachment.sig>