Re: [linux-sunxi] [PATCH] Add support for consumer infrared devices on A20

2014-04-28 Thread Hans de Goede
Hi,

On 04/28/2014 07:55 AM, Julian Calaby wrote:
 Hi Alexander,
 
 On Mon, Apr 28, 2014 at 3:35 PM, Александр Берсенев b...@hackerdom.ru wrote:
 I fixed all known kernel oopses by placing spinlock in interrupt handler and
 changing driver initialization order.

 Left to do:
 1) deal with timers
 2) support and testing on other platforms

 I am going away for few days for not being too noisy.
 
 There's nothing wrong with being too noisy.

Absolutely, thank you for working on this.

 
 If you have the time, please keep testing and working on this and
 reporting what you find.
 
 Oh, and a couple of administrative points:
 1. Seriously think about splitting this up. It won't make it upstream
 without doing that and collecting approval from all the relevant
 subsystems. - that said, this can wait until you've dealt with the
 timer issues and added support (where relevant) for other boards.
 2. You need to work a bit more on the non-code parts of your patch
 submissions, you need a short description at the very least.
 3. You should start versioning your patches.
 4. You also need to keep an eye open for any extra lines you add.
 5. It's better to resubmit entire patches instead of small incremental
 patches on top of existing ones.
 
 Your next patch submission should look something like this: (Assuming
 what I've said is accurate)
 
 Subject: [PATCH v2] sunxi: Add support for consumer infrared devices
 
 Body:
 
 This patch introduces Consumer IR(CIR) support for sunxi boards.
 
 This is based on Alex Allss' work based on the original driver
 supplied by Allwinner.
 
 Signed-off-by: Alexander.
 CC: wingrime@

+1 on all of the above.

Since this is based on wingrime's work it really should have
a Signed-off-by: Using wingrim's real name. Or maybe Wingrime wants to
submit this himself, please coordinate with him, at a minimum you need
a mail from him with this Signed-off-by (after which you can just copy that
one line from the email to your patch commit message).

Regards,

Hans

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] [PATCH] Add support for consumer infrared devices on A20

2014-04-28 Thread Code Kipper
 
  I am going away for few days for not being too noisy.
 
  There's nothing wrong with being too noisy.

 Absolutely, thank you for working on this.

+1 on that. I was thinking about contacting Wingrime about taking on this
driver as I thought it would be quite a nice one to start mainlining effort
with. I've got LIRC set up on my 3.4 setup so if required I can help with
ack-ing this on a A10 setup.

 
  If you have the time, please keep testing and working on this and
  reporting what you find.
 
  Oh, and a couple of administrative points:
  1. Seriously think about splitting this up. It won't make it upstream
  without doing that and collecting approval from all the relevant
  subsystems. - that said, this can wait until you've dealt with the
  timer issues and added support (where relevant) for other boards.
  2. You need to work a bit more on the non-code parts of your patch
  submissions, you need a short description at the very least.
  3. You should start versioning your patches.
  4. You also need to keep an eye open for any extra lines you add.
  5. It's better to resubmit entire patches instead of small incremental
  patches on top of existing ones.
 
  Your next patch submission should look something like this: (Assuming
  what I've said is accurate)
 
  Subject: [PATCH v2] sunxi: Add support for consumer infrared devices
 
  Body:
 
  This patch introduces Consumer IR(CIR) support for sunxi boards.
 
  This is based on Alex Allss' work based on the original driver
  supplied by Allwinner.
 
  Signed-off-by: Alexander.
  CC: wingrime@

 +1 on all of the above.

Could you also run this through checkpatch to ensure clean delivery. I've
noticed
a few 'magic numbers' in the patch, could you convert these to relevant
defines?,
it shows a greater understanding of the hardware.


 Since this is based on wingrime's work it really should have
 a Signed-off-by: Using wingrim's real name. Or maybe Wingrime wants to
 submit this himself, please coordinate with him, at a minimum you need
 a mail from him with this Signed-off-by (after which you can just copy that
 one line from the email to your patch commit message).

 Regards,

 Hans

Thanks for the effort. Much appreciated,
CK



 --
 You received this message because you are subscribed to the Google Groups
 linux-sunxi group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to linux-sunxi+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] [PATCH] Add support for consumer infrared devices on A20

2014-04-27 Thread Александр Берсенев
Hello,

Thank you for your replies. I decided to use Wingrime's patch as a base for 
my patch to not doing the same work twice. I've changed code a bit, 
espectially in initialization and finalisation part. Now it not freezes a 
system after insmod/rmmod/insmod.

This patch applies on Hans de Goede's sunxi-devel branch(3.15-rc2). It 
works only on cubietruck, but it seems that only changes in *.dts and 
*.idts files are required to add the new platform.

Here is the patch:
Signed-off-by: Alexander Bersenev b...@hackerdom.ru

diff --git a/Documentation/devicetree/bindings/media/sunxi-ir.txt 
b/Documentation/devicetree/bindings/media/sunxi-ir.txt
new file mode 100644
index 000..8181efc
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/sunxi-ir.txt
@@ -0,0 +1,21 @@
+Device-Tree bindings for SUNXI IR controller found in sunXi SoC family
+
+Required properties:
+   - compatible: Should be allwinner,sunxi-ir.
+   - clocks: First clock should constain SoC gate for IR clock
+   second should constain IR feed clock itself.
+   - interrupts: Should constain IR IRQ number.
+   -reg: Should constain IO map address for IR.
+
+Optional properties:
+   - linux,rc-map-name: Remote control map name.
+
+Example:
+
+   ir0: ir@01c21800 {
+compatible = allwinner,sunxi-ir;
+clocks = apb0_gates 6, ir0_clk;
+interrupts = 0 5 1;
+reg = 0x01C21800 0x40;
+linux,rc-map-name = rc-rc6-mce;
+   };
diff --git a/arch/arm/boot/dts/sun7i-a20-cubietruck.dts 
b/arch/arm/boot/dts/sun7i-a20-cubietruck.dts
index e288562..294c115 100644
--- a/arch/arm/boot/dts/sun7i-a20-cubietruck.dts
+++ b/arch/arm/boot/dts/sun7i-a20-cubietruck.dts
@@ -121,6 +121,13 @@
  };
  };
 
+ ir0: ir@01c21800 {
+ pinctrl-names = default;
+ pinctrl-0 = ir0_pins_a;
+ gpios = pio 1 4 0;
+ status = okay;
+ };
+
  uart0: serial@01c28000 {
  pinctrl-names = default;
  pinctrl-0 = uart0_pins_a;
diff --git a/arch/arm/boot/dts/sun7i-a20.dtsi 
b/arch/arm/boot/dts/sun7i-a20.dtsi
index 0ae2b77..4597731 100644
--- a/arch/arm/boot/dts/sun7i-a20.dtsi
+++ b/arch/arm/boot/dts/sun7i-a20.dtsi
@@ -724,6 +724,19 @@
  allwinner,drive = 2;
  allwinner,pull = 0;
  };
+
+ ir0_pins_a: ir0@0 {
+allwinner,pins = PB3,PB4;
+allwinner,function = ir0;
+allwinner,drive = 0;
+allwinner,pull = 0;
+ };
+ ir1_pins_a: ir1@0 {
+allwinner,pins = PB22,PB23;
+allwinner,function = ir1;
+allwinner,drive = 0;
+allwinner,pull = 0;
+ };
  };
 
  timer@01c20c00 {
@@ -937,5 +950,21 @@
  #interrupt-cells = 3;
  interrupts = 1 9 0xf04;
  };
+
+   ir0: ir@01c21800 {
+ compatible = allwinner,sunxi-ir;
+ clocks = apb0_gates 6, ir0_clk;
+ interrupts = 0 5 4;
+ reg = 0x01C21800 0x40;
+ status = disabled;
+ };
+
+   ir1: ir@01c21c00 {
+ compatible = allwinner,sunxi-ir;
+ clocks = apb0_gates 7, ir1_clk;
+ interrupts = 0 6 4;
+ reg = 0x01C21c00 0x40;
+ status = disabled;
+ };
  };
 };
diff --git a/drivers/media/rc/Kconfig b/drivers/media/rc/Kconfig
index 8fbd377..9427fad 100644
--- a/drivers/media/rc/Kconfig
+++ b/drivers/media/rc/Kconfig
@@ -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
diff --git a/drivers/media/rc/Makefile b/drivers/media/rc/Makefile
index f8b54ff..93cdbe9 100644
--- a/drivers/media/rc/Makefile
+++ b/drivers/media/rc/Makefile
@@ -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-ir.o
 obj-$(CONFIG_IR_IMG) += img-ir/
diff --git a/drivers/media/rc/sunxi-ir.c b/drivers/media/rc/sunxi-ir.c
new file mode 100644
index 000..e9622f9
--- /dev/null
+++ b/drivers/media/rc/sunxi-ir.c
@@ -0,0 +1,308 @@
+/*
+ * Driver for Allwinner sunXi IR controller
+ *
+ * Copyright (C) 2014 Alexsey Shestacov wingr...@linux-sunxi.org
+ *
+ * Based on sun5i-ir.c:
+ * Copyright (C) 2007-2012 Daniel Wang
+ * Allwinner Technology Co., Ltd. www.allwinnertech.com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include linux/module.h
+#include linux/clk.h
+#include linux/delay.h
+#include linux/module.h
+#include linux/init.h
+#include linux/input.h

Re: [linux-sunxi] [PATCH] Add support for consumer infrared devices on A20

2014-04-27 Thread Александр Берсенев
I did 300 000 insmod/rmmod cycles and all was ok, but the memory 
consumption increased from 23MB to 36MB. I think, it is because of timers. 
As Hans de Goede said, it is better to use devm_clk_get to get the clock. I 
use this function in my first patch, but I not found a way to get apb0_ir0 
clock, because it is not registered. I forced registering with this part of 
first patch:

diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c
index 3be8846..83a20fa 100644
--- a/drivers/clk/sunxi/clk-sunxi.c
+++ b/drivers/clk/sunxi/clk-sunxi.c
@@ -1036,11 +1036,17 @@ static void __init sunxi_gates_clk_setup(struct 
device_node *node,
  /* No driver claims this clock, but it should remain gated */
  ignore = !strcmp(ahb_sdram, clk_name) ? CLK_IGNORE_UNUSED : 0;
 
+
  clk_data-clks[i] = clk_register_gate(NULL, clk_name,
clk_parent, ignore,
reg + 4 * (i/32), i % 32,
0, clk_lock);
  WARN_ON(IS_ERR(clk_data-clks[i]));
+ 
+ if(!IS_ERR(clk_data-clks[i])) {
+ clk_register_clkdev(clk_data-clks[i], clk_name, NULL);
+ }
+

I am looking for sane way to do same without 
patching drivers/clk/sunxi/clk-sunxi.c.

Also I've tested parallel module load/unload. I executed folowwing commands:
while true; do echo bay; rmmod sunxi-ir; insmod /sunxi-ir.ko; done 
while true; do echo bay; rmmod sunxi-ir; insmod /sunxi-ir.ko; done 
... 20 times ...

It runs ok, but when I press buttons on my IR remote controller in the 
process, I got a kernel OOPS(null pointer dereference) sometimes. I am 
fixing this.

Best,
Alexander Bersenev, Institute of Mathematics and Mechanics, Russia
понедельник, 28 апреля 2014 г., 2:11:19 UTC+6 пользователь Александр 
Берсенев написал:

 Hello,

 Thank you for your replies. I decided to use Wingrime's patch as a base 
 for my patch to not doing the same work twice. I've changed code a bit, 
 espectially in initialization and finalisation part. Now it not freezes a 
 system after insmod/rmmod/insmod.

 This patch applies on Hans de Goede's sunxi-devel branch(3.15-rc2). It 
 works only on cubietruck, but it seems that only changes in *.dts and 
 *.idts files are required to add the new platform.

 Here is the patch:
 Signed-off-by: Alexander Bersenev b...@hackerdom.ru

 diff --git a/Documentation/devicetree/bindings/media/sunxi-ir.txt 
 b/Documentation/devicetree/bindings/media/sunxi-ir.txt
 new file mode 100644
 index 000..8181efc
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/media/sunxi-ir.txt
 @@ -0,0 +1,21 @@
 +Device-Tree bindings for SUNXI IR controller found in sunXi SoC family
 +
 +Required properties:
 +   - compatible: Should be allwinner,sunxi-ir.
 +   - clocks: First clock should constain SoC gate for IR clock
 +   second should constain IR feed clock itself.
 +   - interrupts: Should constain IR IRQ number.
 +   -reg: Should constain IO map address for IR.
 +
 +Optional properties:
 +   - linux,rc-map-name: Remote control map name.
 +
 +Example:
 +
 +   ir0: ir@01c21800 {
 +compatible = allwinner,sunxi-ir;
 +clocks = apb0_gates 6, ir0_clk;
 +interrupts = 0 5 1;
 +reg = 0x01C21800 0x40;
 +linux,rc-map-name = rc-rc6-mce;
 +   };
 diff --git a/arch/arm/boot/dts/sun7i-a20-cubietruck.dts 
 b/arch/arm/boot/dts/sun7i-a20-cubietruck.dts
 index e288562..294c115 100644
 --- a/arch/arm/boot/dts/sun7i-a20-cubietruck.dts
 +++ b/arch/arm/boot/dts/sun7i-a20-cubietruck.dts
 @@ -121,6 +121,13 @@
   };
   };
  
 + ir0: ir@01c21800 {
 + pinctrl-names = default;
 + pinctrl-0 = ir0_pins_a;
 + gpios = pio 1 4 0;
 + status = okay;
 + };
 +
   uart0: serial@01c28000 {
   pinctrl-names = default;
   pinctrl-0 = uart0_pins_a;
 diff --git a/arch/arm/boot/dts/sun7i-a20.dtsi 
 b/arch/arm/boot/dts/sun7i-a20.dtsi
 index 0ae2b77..4597731 100644
 --- a/arch/arm/boot/dts/sun7i-a20.dtsi
 +++ b/arch/arm/boot/dts/sun7i-a20.dtsi
 @@ -724,6 +724,19 @@
   allwinner,drive = 2;
   allwinner,pull = 0;
   };
 +
 + ir0_pins_a: ir0@0 {
 +allwinner,pins = PB3,PB4;
 +allwinner,function = ir0;
 +allwinner,drive = 0;
 +allwinner,pull = 0;
 + };
 + ir1_pins_a: ir1@0 {
 +allwinner,pins = PB22,PB23;
 +allwinner,function = ir1;
 +allwinner,drive = 0;
 +allwinner,pull = 0;
 + };
   };
  
   timer@01c20c00 {
 @@ -937,5 +950,21 @@
   #interrupt-cells = 3;
   interrupts = 1 9 0xf04;
   };
 +
 +   ir0: ir@01c21800 {
 + compatible = allwinner,sunxi-ir;
 + clocks = apb0_gates 6, ir0_clk;
 + interrupts = 0 5 4;
 + reg = 0x01C21800 0x40;
 + status = disabled;
 + };
 +
 +   ir1: ir@01c21c00 {
 + compatible = allwinner,sunxi-ir;
 + clocks = apb0_gates 7, ir1_clk;
 + interrupts = 0 6 4;
 + reg = 0x01C21c00 0x40;
 + status = disabled;
 + };
   };
  };
 diff --git a/drivers/media/rc/Kconfig b/drivers/media/rc/Kconfig
 index 8fbd377..9427fad 100644
 --- a/drivers/media/rc/Kconfig
 +++ b/drivers/media/rc/Kconfig
 @@ -343,4 +343,14 @@ config RC_ST
  
   If you're not sure, 

Re: [linux-sunxi] [PATCH] Add support for consumer infrared devices on A20

2014-04-27 Thread Julian Calaby
Hi Alexander,

On Mon, Apr 28, 2014 at 3:35 PM, Александр Берсенев b...@hackerdom.ru wrote:
 I fixed all known kernel oopses by placing spinlock in interrupt handler and
 changing driver initialization order.

 Left to do:
 1) deal with timers
 2) support and testing on other platforms

 I am going away for few days for not being too noisy.

There's nothing wrong with being too noisy.

If you have the time, please keep testing and working on this and
reporting what you find.

Oh, and a couple of administrative points:
1. Seriously think about splitting this up. It won't make it upstream
without doing that and collecting approval from all the relevant
subsystems. - that said, this can wait until you've dealt with the
timer issues and added support (where relevant) for other boards.
2. You need to work a bit more on the non-code parts of your patch
submissions, you need a short description at the very least.
3. You should start versioning your patches.
4. You also need to keep an eye open for any extra lines you add.
5. It's better to resubmit entire patches instead of small incremental
patches on top of existing ones.

Your next patch submission should look something like this: (Assuming
what I've said is accurate)

Subject: [PATCH v2] sunxi: Add support for consumer infrared devices

Body:

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

This is based on Alex Allss' work based on the original driver
supplied by Allwinner.

Signed-off-by: Alexander.
CC: wingrime@

---

Changes since version 1:
 - Fix timer memory leaks
 - Tidy up code

Etc.

Thanks,

-- 
Julian Calaby

Email: julian.cal...@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/
.Plan: http://sites.google.com/site/juliancalaby/

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] [PATCH] Add support for consumer infrared devices on A20

2014-04-26 Thread Julian Calaby
Hi Александр,

(Gmail seems to have messed up the indentation, so I apologise for that.)

First things first:

You should really split this into a few patches:

1. Make any modifications unrelated to the driver itself
2. Add / amend the documentation for the device tree bindings.
3. Add the driver.
4. Add the base device tree stuff (in .dtsi files)
5. Update board files to use that.

Some of these changes have to be ACKed by different people, (e.g. the
device tree people care about the device tree stuff, but not the
driver itself) and it also makes it easier to review.

That said, maybe wait a couple of days for any other feedback before
splitting and re-sending this.

Also, you really need to run checkpatch over your patches.

If you're expecting this to go upstream, you're going to need to send
it to the relevant mailing lists, _and_ linux-sunxi.

I.e. as this is an input driver, you need to CC it to the linux-input
list, and the input maintainer. The device tree stuff will have to be
CC'd to the device tree maintainer and list also.

Other nits and stuff below.

On Fri, Apr 25, 2014 at 7:38 PM, Александр Берсенев b...@hackerdom.ru wrote:
 This patch introduces Consumer IR(CIR) support for cubietruck. It was ported
 from sunxi linux 3.4 and supports only NEC protocol.

 Changes from the original driver:
 - moved kernel's Input Subsystem API
 - initialization code was rewritten
 - using devm_ functions to simplify cleanup
 - moved gpio and timers initialization to *.dts and *.dtsi files
 - using sun7i_ir_data struct to hold driver state instead of global vars
 - obtain mmio adresses dynamicly instead of using fixed adresses like
 0xf1c200b0

 It was tested on 20 A20 boards. Now it only works on Cubietrucks, but I
 believe
 it is not hard to make it work on other sunxi architectures.

 Alexander Bersenev, Institute of Mathematics and Mechanics, Russia

 Signed-off-by: Alexander Bersenev b...@hackerdom.ru

This should be more like:

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

This patch introduces Consumer IR(CIR) support for cubietruck. It
supports only NEC protocol.

It's ported from the original open source driver supplied by Allwinner.

Changes from original driver:
- .
- .
- .

Signed-off-by: 

---

It was tested

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

Nobody other than us really care if it's only been tested on some
chipsets / boards. That said, if you've only tested it on an A20
board, you should probably restrict it to only build on that, then
other people (or you) will provide updates as it gets tested
elsewhere.


 diff --git a/arch/arm/boot/dts/sun7i-a20-cubietruck.dts
 b/arch/arm/boot/dts/sun7i-a20-cubietruck.dts
 index ebf6a2f..42e79a9 100644
 --- a/arch/arm/boot/dts/sun7i-a20-cubietruck.dts
 +++ b/arch/arm/boot/dts/sun7i-a20-cubietruck.dts
 @@ -121,6 +121,13 @@
   };
   };

 + ir: ir@01c21800 {
 + pinctrl-names = default;

default?

 + pinctrl-0 = ir_pin_cubietruck;
 + gpios = pio 1 4 0;
 + };
 +
 +

Only one blank line here.

   uart0: serial@01c28000 {
   pinctrl-names = default;
   pinctrl-0 = uart0_pins_a;
 diff --git a/arch/arm/boot/dts/sun7i-a20.dtsi
 b/arch/arm/boot/dts/sun7i-a20.dtsi
 index 15ea85e..c0202c6 100644
 --- a/arch/arm/boot/dts/sun7i-a20.dtsi
 +++ b/arch/arm/boot/dts/sun7i-a20.dtsi
 @@ -85,6 +85,14 @@
   clock-output-names = pll1;
   };

 + pll3: clk@01c20010 {
 + #clock-cells = 0;
 + compatible = allwinner,sun4i-a10-pll1-clk;
 + reg = 0x01c20010 0x4;
 + clocks = osc24M;
 + clock-output-names = pll3;
 + }
 +
   pll4: clk@01c20018 {
   #clock-cells = 0;
   compatible = allwinner,sun4i-a10-pll1-clk;
 @@ -302,6 +310,7 @@
   compatible = allwinner,sun4i-a10-mod0-clk;
   reg = 0x01c200b0 0x4;
   clocks = osc24M, pll6 1, pll5 1;
 + clock-frequency = 300;

Are you sure this is right?

   clock-output-names = ir0;
   };

 @@ -591,6 +600,13 @@
   allwinner,pull = 0;
   };

 + ir_pin_cubietruck: ir_pin@0 {
 + allwinner,pins = PB4;
 + allwinner,function = ir0;
 + allwinner,drive = 0;
 + allwinner,pull = 0;
 + };
 +
   uart2_pins_a: uart2@0 {
   allwinner,pins = PI16, PI17, PI18, PI19;
   allwinner,function = uart2;
 @@ -750,6 +766,14 @@
   status = disabled;
   };

 + ir: ir@01c21800 {
 + compatible = allwinner,sun7i-a20-ir;
 + reg = 0x01c21800 0x100;
 + interrupts = 0 5 4;
 + clocks = apb0_gates 6, ir0_clk;
 + };
 +
 +

Another extra blank line.

   sid: eeprom@01c23800 {
   compatible = allwinner,sun7i-a20-sid;
   reg = 0x01c23800 0x200;
 @@ -931,5 +955,14 @@
   #interrupt-cells = 3;
   interrupts = 1 9 0xf04;
   };
 +
 +timer {
 +   compatible =arm,armv7-timer;
 +   interrupts = 1 13 0x308,
 +1 14 0x308,
 +1 11 0x308,
 +1 10 0x308;
 +   clock-frequency = 2400;
 +   };

Is this used?

   };
  };
 diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c
 index 3be8846..83a20fa 100644
 --- 

Re: [linux-sunxi] [PATCH] Add support for consumer infrared devices on A20

2014-04-26 Thread Rudi

On 25.04.2014 11:38, Александр Берсенев wrote:

This patch introduces Consumer IR(CIR) support for cubietruck. It was ported
from sunxi linux 3.4 and supports only NEC protocol.


What happened to the CIR driver by Alexandr Shutko ? This driver was written for
the A10 quite a while ago but wasn't merged for some reason. I'm asking, because
this driver hooks into the rc-core subsystem and therefore works with any 
protocol
driver present in the kernel. Not just NEC.



--

Ruediger Rudi Ihle



--
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] [PATCH] Add support for consumer infrared devices on A20

2014-04-26 Thread Hans de Goede
Hi,
On 04/25/2014 11:38 AM, Александр Берсенев wrote:
 This patch introduces Consumer IR(CIR) support for cubietruck. It was 
 ported 
 from sunxi linux 3.4 and supports only NEC protocol.
 
 Changes from the original driver:
 - moved kernel's Input Subsystem API
 - initialization code was rewritten
 - using devm_ functions to simplify cleanup
 - moved gpio and timers initialization to *.dts and *.dtsi files
 - using sun7i_ir_data struct to hold driver state instead of global vars
 - obtain mmio adresses dynamicly instead of using fixed adresses like 
 0xf1c200b0
 
 It was tested on 20 A20 boards. Now it only works on Cubietrucks, but I 
 believe
 it is not hard to make it work on other sunxi architectures.
 
 Alexander Bersenev, Institute of Mathematics and Mechanics, Russia
 
 Signed-off-by: Alexander Bersenev b...@hackerdom.ru 

First of all many thanks for working on this!

Besides all the very useful remarks Julian has already made, I've one
very important remark. The original allwinner code uses its own ir
protocol decoding code, and I see that your version uses this too.

This is not acceptable for upstream kernel inclusion. You should modify
the code to use the existing in kernel ir decoders instead, this should
also give you support for more protocols then just the nec protocol.

For an example of a driver using the existing in kernel ir decoders see:
http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/media/rc/st_rc.c

Note your new driver should probably also live under drivers/media/rc
and as such should be send upstream through the linux-media mailinglist.

One last remark, you use raw printk in several places, please use
dev_err, dev_err, etc. instead.

Regards,

Hans

 
 diff --git a/arch/arm/boot/dts/sun7i-a20-cubietruck.dts 
 b/arch/arm/boot/dts/sun7i-a20-cubietruck.dts
 index ebf6a2f..42e79a9 100644
 --- a/arch/arm/boot/dts/sun7i-a20-cubietruck.dts
 +++ b/arch/arm/boot/dts/sun7i-a20-cubietruck.dts
 @@ -121,6 +121,13 @@
   };
   };
  
 + ir: ir@01c21800 {
 + pinctrl-names = default;
 + pinctrl-0 = ir_pin_cubietruck;
 + gpios = pio 1 4 0;
 + };
 +
 +
   uart0: serial@01c28000 {
   pinctrl-names = default;
   pinctrl-0 = uart0_pins_a;
 diff --git a/arch/arm/boot/dts/sun7i-a20.dtsi 
 b/arch/arm/boot/dts/sun7i-a20.dtsi
 index 15ea85e..c0202c6 100644
 --- a/arch/arm/boot/dts/sun7i-a20.dtsi
 +++ b/arch/arm/boot/dts/sun7i-a20.dtsi
 @@ -85,6 +85,14 @@
   clock-output-names = pll1;
   };
  
 + pll3: clk@01c20010 {
 + #clock-cells = 0;
 + compatible = allwinner,sun4i-a10-pll1-clk;
 + reg = 0x01c20010 0x4;
 + clocks = osc24M;
 + clock-output-names = pll3;
 + }; 
 +
   pll4: clk@01c20018 {
   #clock-cells = 0;
   compatible = allwinner,sun4i-a10-pll1-clk;
 @@ -302,6 +310,7 @@
   compatible = allwinner,sun4i-a10-mod0-clk;
   reg = 0x01c200b0 0x4;
   clocks = osc24M, pll6 1, pll5 1;
 + clock-frequency = 300;
   clock-output-names = ir0;
   };
  
 @@ -591,6 +600,13 @@
   allwinner,pull = 0;
   };
  
 + ir_pin_cubietruck: ir_pin@0 {
 + allwinner,pins = PB4;
 + allwinner,function = ir0;
 + allwinner,drive = 0;
 + allwinner,pull = 0;
 + };
 +
   uart2_pins_a: uart2@0 {
   allwinner,pins = PI16, PI17, PI18, PI19;
   allwinner,function = uart2;
 @@ -750,6 +766,14 @@
   status = disabled;
   };
  
 + ir: ir@01c21800 {
 + compatible = allwinner,sun7i-a20-ir;
 + reg = 0x01c21800 0x100;
 + interrupts = 0 5 4;
 + clocks = apb0_gates 6, ir0_clk;
 + };
 +
 +
   sid: eeprom@01c23800 {
   compatible = allwinner,sun7i-a20-sid;
   reg = 0x01c23800 0x200;
 @@ -931,5 +955,14 @@
   #interrupt-cells = 3;
   interrupts = 1 9 0xf04;
   };
 +
 +timer {
 +   compatible =arm,armv7-timer;
 +   interrupts = 1 13 0x308,
 +1 14 0x308,
 +1 11 0x308,
 +1 10 0x308;
 +   clock-frequency = 2400;
 +   };
   };
  };
 diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c
 index 3be8846..83a20fa 100644
 --- a/drivers/clk/sunxi/clk-sunxi.c
 +++ b/drivers/clk/sunxi/clk-sunxi.c
 @@ -1036,11 +1036,17 @@ static void __init sunxi_gates_clk_setup(struct 
 device_node *node,
   /* No driver claims this clock, but it should remain gated */
   ignore = !strcmp(ahb_sdram, clk_name) ? CLK_IGNORE_UNUSED : 0;
  
 +
   clk_data-clks[i] = clk_register_gate(NULL, clk_name,
clk_parent, ignore,
reg + 4 * (i/32), i % 32,
0, clk_lock);
   WARN_ON(IS_ERR(clk_data-clks[i]));
 + 
 + if(!IS_ERR(clk_data-clks[i])) {
 + clk_register_clkdev(clk_data-clks[i], clk_name, NULL);
 + }
 +
  
   j++;
   }
 diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
 index d8a51cd..53d778f 100644
 --- a/drivers/input/keyboard/Kconfig
 +++ b/drivers/input/keyboard/Kconfig
 @@ -662,4 +662,10 @@ config KEYBOARD_CROS_EC
To compile this driver as a module, choose M here: the
module will be called cros_ec_keyb.
  
 +config IR_SUNXI
 +tristate sunxi IR support
 +
  endif
 +
 +

Re: [linux-sunxi] [PATCH] Add support for consumer infrared devices on A20

2014-04-26 Thread Hans de Goede
Hi,

On 04/26/2014 05:01 PM, Rudi wrote:
 On 25.04.2014 11:38, Александр Берсенев wrote:
 This patch introduces Consumer IR(CIR) support for cubietruck. It was ported
 from sunxi linux 3.4 and supports only NEC protocol.
 
 What happened to the CIR driver by Alexandr Shutko ? This driver was written 
 for
 the A10 quite a while ago but wasn't merged for some reason. I'm asking, 
 because
 this driver hooks into the rc-core subsystem and therefore works with any 
 protocol
 driver present in the kernel. Not just NEC.

Ah I just send a mail about the need to use the rc-core subsys myself, I did not
know we already had a driver using that. Do you have a link to the old posting 
of
that driver ? That would be a great starting point for Alexander to get 
something
ready for the mainline (iirc the cir driver was against 3.4 ?)

Regards,

Hans

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] [PATCH] Add support for consumer infrared devices on A20

2014-04-26 Thread Rudi

Hi,


Ah I just send a mail about the need to use the rc-core subsys myself, I did not
know we already had a driver using that. Do you have a link to the old posting 
of
that driver ? That would be a great starting point for Alexander to get 
something
ready for the mainline (iirc the cir driver was against 3.4 ?)


I carefully put it aside ;-). Find a patch that hooks it into 3.4.79 here:

https://github.com/OpenBricks/openbricks/blob/master/config/platforms/arm/a10/packages/linux/patches/0002-ir-core-support.diff



--

Ruediger Rudi Ihle


--
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] [PATCH] Add support for consumer infrared devices on A20

2014-04-26 Thread alex allss
I have patch almost ready for mainline, but  I still have some bug with
module reloading.

Also, my old RFC in linux-sunxi mailist.
26 апр. 2014 г. 21:11 пользователь Rudi r.i...@s-t.de написал:

 Hi,

  Ah I just send a mail about the need to use the rc-core subsys myself, I
 did not
 know we already had a driver using that. Do you have a link to the old
 posting of
 that driver ? That would be a great starting point for Alexander to get
 something
 ready for the mainline (iirc the cir driver was against 3.4 ?)


 I carefully put it aside ;-). Find a patch that hooks it into 3.4.79 here:

 https://github.com/OpenBricks/openbricks/blob/master/config/
 platforms/arm/a10/packages/linux/patches/0002-ir-core-support.diff



 --

 Ruediger Rudi Ihle


 --
 You received this message because you are subscribed to the Google Groups
 linux-sunxi group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to linux-sunxi+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] [PATCH] Add support for consumer infrared devices on A20

2014-04-26 Thread Hans de Goede
Hi,

On 04/26/2014 05:19 PM, alex allss wrote:
 I have patch almost ready for mainline, but  I still have some bug with
 module reloading.

Perhaps you can post / or push it somewhere ? Then maybe someone else will be
able to figure out what is causing the module reloading problem.

I assume the problem is that things no longer work after an rmmod + insmod ?

Regards,

Hans

 
 Also, my old RFC in linux-sunxi mailist.
 26 апр. 2014 г. 21:11 пользователь Rudi r.i...@s-t.de написал:
 
 Hi,

  Ah I just send a mail about the need to use the rc-core subsys myself, I
 did not
 know we already had a driver using that. Do you have a link to the old
 posting of
 that driver ? That would be a great starting point for Alexander to get
 something
 ready for the mainline (iirc the cir driver was against 3.4 ?)


 I carefully put it aside ;-). Find a patch that hooks it into 3.4.79 here:

 https://github.com/OpenBricks/openbricks/blob/master/config/
 platforms/arm/a10/packages/linux/patches/0002-ir-core-support.diff



 --

 Ruediger Rudi Ihle


 --
 You received this message because you are subscribed to the Google Groups
 linux-sunxi group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to linux-sunxi+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

 

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] [PATCH] Add support for consumer infrared devices on A20

2014-04-26 Thread alex allss
Hans:
you can take a look recent:

http://paste.debian.net/95872/

I need rebase it aganist current mainline


drvier are checked with LIRC frontend

yes, problem with OPS after serval reloads



2014-04-26 21:21 GMT+06:00 Hans de Goede hdego...@redhat.com:

 Hi,

 On 04/26/2014 05:19 PM, alex allss wrote:
  I have patch almost ready for mainline, but  I still have some bug with
  module reloading.

 Perhaps you can post / or push it somewhere ? Then maybe someone else will
 be
 able to figure out what is causing the module reloading problem.

 I assume the problem is that things no longer work after an rmmod + insmod
 ?

 Regards,

 Hans

 
  Also, my old RFC in linux-sunxi mailist.
  26 апр. 2014 г. 21:11 пользователь Rudi r.i...@s-t.de написал:
 
  Hi,
 
   Ah I just send a mail about the need to use the rc-core subsys myself,
 I
  did not
  know we already had a driver using that. Do you have a link to the old
  posting of
  that driver ? That would be a great starting point for Alexander to get
  something
  ready for the mainline (iirc the cir driver was against 3.4 ?)
 
 
  I carefully put it aside ;-). Find a patch that hooks it into 3.4.79
 here:
 
  https://github.com/OpenBricks/openbricks/blob/master/config/
  platforms/arm/a10/packages/linux/patches/0002-ir-core-support.diff
 
 
 
  --
 
  Ruediger Rudi Ihle
 
 
  --
  You received this message because you are subscribed to the Google
 Groups
  linux-sunxi group.
  To unsubscribe from this group and stop receiving emails from it, send
 an
  email to linux-sunxi+unsubscr...@googlegroups.com.
  For more options, visit https://groups.google.com/d/optout.
 
 

 --
 You received this message because you are subscribed to the Google Groups
 linux-sunxi group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to linux-sunxi+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] [PATCH] Add support for consumer infrared devices on A20

2014-04-26 Thread alex allss
Big thanks Hans, I apply you suggests, and test again
26 апр. 2014 г. 21:44 пользователь Hans de Goede hdego...@redhat.com
написал:

 Hi,

 On 04/26/2014 05:24 PM, alex allss wrote:
  Hans:
  you can take a look recent:
 
  http://paste.debian.net/95872/

 Cool, very good work, thanks for working on this, the
 big hurdle to take here was hooking up the rc-core and
 you seem to have tackled that nicely. So now we just need
 to clean it up a bit and then it can go upstream.

 WRT the load / unload problem, one thing which immediately
 stood out to me is this bit:

 +static int sunxi_ir_remove(struct platform_device *pdev)

 ...

 +   rc_unregister_device(ir-rc);
 +   rc_free_device(ir-rc);

 rc_unregister_device already frees the device, so you're
 freeing it twice. rc_free_device is only there to free
 the device if things fail before it is registered (or
 if rc_register_device itself fails).

 Note btw that you're never calling rc_free_device in the
 error handling paths of probe where you should actually
 call it :)

 Also you're not calling clk_put on the clocks you
 of_clk_get. The best thing to do would be to stop using
 of_clk_get altogether, and instead use clock-names in the
 dts and devm_clk_get.

 Likewise you are not unmapping the io mem you map, please
 switch to devm_ioremap_resource which will do this
 automatically for you on probe failure and on driver unbind
 (rmmod).

 Similar please use devm_request_irq.

 If you use devm everywhere were possible, then the only thing
 you need to do on probe error is rc_free_device.

 Regards,

 Hans





 
  I need rebase it aganist current mainline
 
 
  drvier are checked with LIRC frontend
 
  yes, problem with OPS after serval reloads
 
 
 
  2014-04-26 21:21 GMT+06:00 Hans de Goede hdego...@redhat.com:
 
  Hi,
 
  On 04/26/2014 05:19 PM, alex allss wrote:
  I have patch almost ready for mainline, but  I still have some bug with
  module reloading.
 
  Perhaps you can post / or push it somewhere ? Then maybe someone else
 will
  be
  able to figure out what is causing the module reloading problem.
 
  I assume the problem is that things no longer work after an rmmod +
 insmod
  ?
 
  Regards,
 
  Hans
 
 
  Also, my old RFC in linux-sunxi mailist.
  26 апр. 2014 г. 21:11 пользователь Rudi r.i...@s-t.de написал:
 
  Hi,
 
   Ah I just send a mail about the need to use the rc-core subsys
 myself,
  I
  did not
  know we already had a driver using that. Do you have a link to the
 old
  posting of
  that driver ? That would be a great starting point for Alexander to
 get
  something
  ready for the mainline (iirc the cir driver was against 3.4 ?)
 
 
  I carefully put it aside ;-). Find a patch that hooks it into 3.4.79
  here:
 
  https://github.com/OpenBricks/openbricks/blob/master/config/
  platforms/arm/a10/packages/linux/patches/0002-ir-core-support.diff
 
 
 
  --
 
  Ruediger Rudi Ihle
 
 
  --
  You received this message because you are subscribed to the Google
  Groups
  linux-sunxi group.
  To unsubscribe from this group and stop receiving emails from it, send
  an
  email to linux-sunxi+unsubscr...@googlegroups.com.
  For more options, visit https://groups.google.com/d/optout.
 
 
 
  --
  You received this message because you are subscribed to the Google
 Groups
  linux-sunxi group.
  To unsubscribe from this group and stop receiving emails from it, send
 an
  email to linux-sunxi+unsubscr...@googlegroups.com.
  For more options, visit https://groups.google.com/d/optout.
 
 

 --
 You received this message because you are subscribed to the Google Groups
 linux-sunxi group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to linux-sunxi+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] [PATCH] Add support for consumer infrared devices on A20

2014-04-26 Thread Alejandro Mery



On 26/04/14 17:11, Rudi wrote:

Hi,


Ah I just send a mail about the need to use the rc-core subsys myself,
I did not
know we already had a driver using that. Do you have a link to the old
posting of
that driver ? That would be a great starting point for Alexander to
get something
ready for the mainline (iirc the cir driver was against 3.4 ?)


I carefully put it aside ;-). Find a patch that hooks it into 3.4.79 here:

https://github.com/OpenBricks/openbricks/blob/master/config/platforms/arm/a10/packages/linux/patches/0002-ir-core-support.diff


can you resubmit it here as a proper patch for the 3.4 tree?

Thanks,
Alejandro Mery

--
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.