[linux-sunxi] Re: Infrared Remote Control (sunxi-ir)

2015-01-11 Thread Александр Берсенев
Hello, I remember the code in 3.4. Authors do decoding manually instead of 
using kernel decoders. I think it is possible to use them. I've made some 
effort to push sunxi ir driver into mainline linux kernel, here is the main 
file: 
https://github.com/torvalds/linux/blob/master/drivers/media/rc/sunxi-cir.c.

I think it is possible to backport the changes, but I am outside of my 
country for 3 mounts.

Best,
Alexander Bersenev

суббота, 10 января 2015 г., 7:12:32 UTC+5 пользователь tkg написал:
>
> I think the current sunxi-ir driver only decodes the NEC protocol. 
>
> In my case I have one of the dual core android tv player device similar 
> to: 
> http://linux-sunxi.org/YBKJ_A20 
>
> I have made a debian linux sd card using the 3.4 sunxi kernel 
> and I had success reading the original remote that came with the box and 
> also various cheap remotes usually found in car players. 
> See for instance the remote from here: 
> http://docs.cubieboard.org/tutorials/cb1/customization/wireless_music_box 
>
> If the driver is loaded properly you should be able to find an eventX link 
> for it in /dev/input/eventX where X varies but it should be similar to what 
> you had in the dmesg log. 
>
> A simple test to see if you have any keys recognized you could run: 
> cat /dev/input/eventX | hexdump 
> and start pressing keys from your remote. 
>   
> If you do not get any output then either your remote is not using the NEC 
> protocol or the decoder might be listening on the wrong pins. 
>
> I saw you have "ir0_rx = port:PB04<2>" in your 
> "script.fex" file but have you actually converted that file to a binary one 
> and made it available so that the U-boot loader can load it? 
> Again, in my case, I needed the script.bin file generated for my debian 
> build as mentioned in here: 
> http://linux-sunxi.org/Manual_build_howto 
>
> All the best, 
> tkg 
>
>
>
>

-- 
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.


[linux-sunxi] Re: [PULL patches for 3.17]: 2 gspca patches + sunxi cir support

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

any news with this patch?

Best,
Alexander Bersenev



2014-06-30 19:57 GMT+06:00 Hans de Goede :

> Hi Mauro,
>
> Please pull from my tree for 2 gspca patches + sunxi cir support
> (I'm a sunxi Linux support contributor and have reviewed and tested
> the cir driver on various a10 and a20 SoC boards).
>
> The following changes since commit
> b5b620584b9c4644b85e932895a742e0c192d66c:
>
>   [media] technisat-sub2: Fix stream curruption on high bitrate
> (2014-06-26 09:20:18 -0300)
>
> are available in the git repository at:
>
>   git://linuxtv.org/hgoede/gspca.git media-for_v3.17
>
> for you to fetch changes up to c6c223d3bb3f0a8a0e7d07b71961737954d2e325:
>
>   rc: add sunxi-ir driver (2014-06-30 15:48:40 +0200)
>
> 
> Alexander Bersenev (2):
>   dt: bindings: Add binding documentation for sunxi IR controller.
>   rc: add sunxi-ir driver
>
> Antonio Ospite (2):
>   gspca: provide a mechanism to select a specific transfer endpoint
>   gspca_kinect: add support for the depth stream
>
>  .../devicetree/bindings/media/sunxi-ir.txt |  23 ++
>  drivers/media/rc/Kconfig   |  10 +
>  drivers/media/rc/Makefile  |   1 +
>  drivers/media/rc/sunxi-cir.c   | 318
> +
>  drivers/media/usb/gspca/gspca.c|  20 +-
>  drivers/media/usb/gspca/gspca.h|   1 +
>  drivers/media/usb/gspca/kinect.c   |  98 ++-
>  7 files changed, 454 insertions(+), 17 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/media/sunxi-ir.txt
>  create mode 100644 drivers/media/rc/sunxi-cir.c
>
> Thanks & 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.


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

2014-06-23 Thread Александр Берсенев
Thanks,

Should I send applied patches in the further versions of this patch set?

Best,
Alexander Bersenev

понедельник, 23 июня 2014 г., 19:10:45 UTC+6 пользователь Maxime Ripard 
написал:
>
> On Sat, Jun 21, 2014 at 05:04:05PM +0600, Alexander Bersenev wrote: 
> > This patch adds records for two IR controllers on A20 
> > 
> > Signed-off-by: Alexander Bersenev > 
> > Signed-off-by: Alexsey Shestacov > 
>
>
> Applied, thanks. 
>
> Maxime 
> -- 
> Maxime Ripard, Free Electrons 
> Embedded Linux, Kernel and Android engineering 
> http://free-electrons.com 
>

-- 
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] Hans 3.15 kernel and Cubietruck wifi

2014-06-14 Thread Александр Берсенев
Just tested on 
Linux Cubian 3.14.0-rc8+ #118 SMP Fri Apr 18 16:10:07 YEKT 2014 armv7l 
GNU/Linux

and with other microcd-card, all is the same.

Best,
Alexander Bersenev

суббота, 14 июня 2014 г., 18:47:33 UTC+6 пользователь Александр Берсенев 
написал:
>
> Hi,
>
> I have wifi working on cubietruck, but after several minutes of operation 
> it stops work. The kernel was compiled from the latest sunxi-devel branch 
> of linux-sunxi repo.
>
> Ifconfig says that wlan1 is running, but all operation fails by timeout.
>
> # iwlist wlan1 scan
> wlan1 Interface doesn't support scanning : Connection timed out
>
> # time iwconfig wlan1
> wlan1 IEEE 802.11bgn  ESSID:off/any  
>   Mode:Managed  Access Point: Not-Associated   
>   Retry short limit:7   RTS thr:off   Fragment thr:off
>   Encryption key:off
>   Power Management:off
>   
> real0m4.999s
> user0m0.000s
> sys 0m0.010s
>
>
> Each second two messages appears in dmesg:
> brcmfmac: brcmf_sdiod_regrw_helper: failed to read data F1@0x0a020, err: 
> -110
> brcmfmac: brcmf_sdio_dpc: failed backplane access over SDIO, halting 
> operation 
>
> More related messages:
> brcmfmac: brcmf_sdio_bus_rxctl: resumed on timeout
> brcmfmac: brcmf_fil_cmd_data: Failed err=-110
> brcmfmac: brcmf_cfg80211_get_tx_power: error (-110)
> brcmfmac: brcmf_do_escan: error (-110)
> brcmfmac: brcmf_cfg80211_scan: scan error (-110)
>
> The command rmmod brcmfmac never finishes.
>
> Also, when wifi stops work, mmc error messages repeat in dmesg:
> [  245.780430] sunxi-mmc 1c12000.mmc: smc 1 err, cmd 53, RD SBE !!
> [  245.780489] sunxi-mmc 1c12000.mmc: data error, sending stop command
> [  245.780550] brcmfmac: brcmf_sdio_readframes: RXHEADER FAILED: -110
> [  245.780561] brcmfmac: brcmf_sdio_rxfail: abort command, terminate 
> frame, send NAK
> [  245.784798] brcmfmac: brcmf_sdiod_regrw_helper: failed to write data 
> F1@0x0a040, err: -5
> [  245.784912] brcmfmac: brcmf_sdio_hdparse: seq 4: sequence number error, 
> expect 5
> [  246.122616] sunxi-mmc 1c12000.mmc: smc 1 err, cmd 53, RD DTO !!
> [  246.122672] sunxi-mmc 1c12000.mmc: data error, sending stop command
> [  246.460309] sunxi-mmc 1c12000.mmc: smc 1 err, cmd 53, RD DTO !!
> [  246.460354] sunxi-mmc 1c12000.mmc: data error, sending stop command
> [  246.797996] sunxi-mmc 1c12000.mmc: smc 1 err, cmd 53, RD DTO !!
> [  246.798043] sunxi-mmc 1c12000.mmc: data error, sending stop command
> [  246.798085] brcmfmac: brcmf_sdiod_regrw_helper: failed to read data 
> F1@0x0a020, err: -110
> [  246.798115] brcmfmac: brcmf_sdio_dpc: failed backplane access over 
> SDIO, halting operation
> [  247.133900] sunxi-mmc 1c12000.mmc: smc 1 err, cmd 53, RD DTO !!
> [  247.133947] sunxi-mmc 1c12000.mmc: data error, sending stop command
> [  247.471573] sunxi-mmc 1c12000.mmc: smc 1 err, cmd 53, RD DTO !!
> [  247.471613] sunxi-mmc 1c12000.mmc: data error, sending stop command
> [  247.809240] sunxi-mmc 1c12000.mmc: smc 1 err, cmd 53, RD DTO !!
> [  247.809283] sunxi-mmc 1c12000.mmc: data error, sending stop command
> [  247.809323] brcmfmac: brcmf_sdiod_regrw_helper: failed to read data 
> F1@0x0a020, err: -110
> [  247.809354] brcmfmac: brcmf_sdio_dpc: failed backplane access over 
> SDIO, halting operation
>
> When wifi module is unloaded there are not any mmc errors.
>
> I use dd if=/dev/zero bs=64k command via ssh to test wifi.
>
> I can also check other versions of kernel.
>
> Best,
> Alexander Bersenev
>
> пятница, 13 июня 2014 г., 2:26:56 UTC+6 пользователь Hans de Goede написал:
>>
>> Hi, 
>>
>> On 06/12/2014 03:21 PM, jons...@gmail.com wrote: 
>> > I added the ap6210.txt file. Now I get... 
>> > 
>> > root@linaro-developer:~# dmesg | grep brcm 
>> > [   14.656712] brcmfmac: F1 signature read @0x1800=0x1591a962 
>> > [   15.123388] brcmfmac: brcmf_c_preinit_dcmds: Firmware version = 
>> > wl0: Apr 22 2013 14:50:00 version 5.90.195.89.6 FWID 01-b30a427d 
>> > [   15.208407] brcmfmac: brcmf_fil_cmd_data: Failed err=-23 
>> > [   15.259285] brcmfmac: brcmf_fil_cmd_data: Failed err=-23 
>> > [   15.290611] brcmfmac: brcmf_fil_cmd_data: Failed err=-23 
>> > [   15.330720] brcmfmac: brcmf_fil_cmd_data: Failed err=-23 
>> > [   15.345610] brcmfmac: brcmf_fil_cmd_data: Failed err=-23 
>> > [   15.396557] brcmfmac: brcmf_fil_cmd_data: Failed err=-23 
>> > [   15.440398] usbcore: registered new interface driver brcmfmac 
>>
>> Those are "normal" this is the brcmfmac driver trying to enable some 
>> features which are not supported on this model wifi chip. 
>>
>> 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] Hans 3.15 kernel and Cubietruck wifi

2014-06-14 Thread Александр Берсенев
Hi,

I have wifi working on cubietruck, but after several minutes of operation 
it stops work. The kernel was compiled from the latest sunxi-devel branch 
of linux-sunxi repo.

Ifconfig says that wlan1 is running, but all operation fails by timeout.

# iwlist wlan1 scan
wlan1 Interface doesn't support scanning : Connection timed out

# time iwconfig wlan1
wlan1 IEEE 802.11bgn  ESSID:off/any  
  Mode:Managed  Access Point: Not-Associated   
  Retry short limit:7   RTS thr:off   Fragment thr:off
  Encryption key:off
  Power Management:off
  
real0m4.999s
user0m0.000s
sys 0m0.010s


Each second two messages appears in dmesg:
brcmfmac: brcmf_sdiod_regrw_helper: failed to read data F1@0x0a020, err: 
-110
brcmfmac: brcmf_sdio_dpc: failed backplane access over SDIO, halting 
operation 

More related messages:
brcmfmac: brcmf_sdio_bus_rxctl: resumed on timeout
brcmfmac: brcmf_fil_cmd_data: Failed err=-110
brcmfmac: brcmf_cfg80211_get_tx_power: error (-110)
brcmfmac: brcmf_do_escan: error (-110)
brcmfmac: brcmf_cfg80211_scan: scan error (-110)

The command rmmod brcmfmac never finishes.

Also, when wifi stops work, mmc error messages repeat in dmesg:
[  245.780430] sunxi-mmc 1c12000.mmc: smc 1 err, cmd 53, RD SBE !!
[  245.780489] sunxi-mmc 1c12000.mmc: data error, sending stop command
[  245.780550] brcmfmac: brcmf_sdio_readframes: RXHEADER FAILED: -110
[  245.780561] brcmfmac: brcmf_sdio_rxfail: abort command, terminate frame, 
send NAK
[  245.784798] brcmfmac: brcmf_sdiod_regrw_helper: failed to write data 
F1@0x0a040, err: -5
[  245.784912] brcmfmac: brcmf_sdio_hdparse: seq 4: sequence number error, 
expect 5
[  246.122616] sunxi-mmc 1c12000.mmc: smc 1 err, cmd 53, RD DTO !!
[  246.122672] sunxi-mmc 1c12000.mmc: data error, sending stop command
[  246.460309] sunxi-mmc 1c12000.mmc: smc 1 err, cmd 53, RD DTO !!
[  246.460354] sunxi-mmc 1c12000.mmc: data error, sending stop command
[  246.797996] sunxi-mmc 1c12000.mmc: smc 1 err, cmd 53, RD DTO !!
[  246.798043] sunxi-mmc 1c12000.mmc: data error, sending stop command
[  246.798085] brcmfmac: brcmf_sdiod_regrw_helper: failed to read data 
F1@0x0a020, err: -110
[  246.798115] brcmfmac: brcmf_sdio_dpc: failed backplane access over SDIO, 
halting operation
[  247.133900] sunxi-mmc 1c12000.mmc: smc 1 err, cmd 53, RD DTO !!
[  247.133947] sunxi-mmc 1c12000.mmc: data error, sending stop command
[  247.471573] sunxi-mmc 1c12000.mmc: smc 1 err, cmd 53, RD DTO !!
[  247.471613] sunxi-mmc 1c12000.mmc: data error, sending stop command
[  247.809240] sunxi-mmc 1c12000.mmc: smc 1 err, cmd 53, RD DTO !!
[  247.809283] sunxi-mmc 1c12000.mmc: data error, sending stop command
[  247.809323] brcmfmac: brcmf_sdiod_regrw_helper: failed to read data 
F1@0x0a020, err: -110
[  247.809354] brcmfmac: brcmf_sdio_dpc: failed backplane access over SDIO, 
halting operation

When wifi module is unloaded there are not any mmc errors.

I use dd if=/dev/zero bs=64k command via ssh to test wifi.

I can also check other versions of kernel.

Best,
Alexander Bersenev

пятница, 13 июня 2014 г., 2:26:56 UTC+6 пользователь Hans de Goede написал:
>
> Hi, 
>
> On 06/12/2014 03:21 PM, jons...@gmail.com  wrote: 
> > I added the ap6210.txt file. Now I get... 
> > 
> > root@linaro-developer:~# dmesg | grep brcm 
> > [   14.656712] brcmfmac: F1 signature read @0x1800=0x1591a962 
> > [   15.123388] brcmfmac: brcmf_c_preinit_dcmds: Firmware version = 
> > wl0: Apr 22 2013 14:50:00 version 5.90.195.89.6 FWID 01-b30a427d 
> > [   15.208407] brcmfmac: brcmf_fil_cmd_data: Failed err=-23 
> > [   15.259285] brcmfmac: brcmf_fil_cmd_data: Failed err=-23 
> > [   15.290611] brcmfmac: brcmf_fil_cmd_data: Failed err=-23 
> > [   15.330720] brcmfmac: brcmf_fil_cmd_data: Failed err=-23 
> > [   15.345610] brcmfmac: brcmf_fil_cmd_data: Failed err=-23 
> > [   15.396557] brcmfmac: brcmf_fil_cmd_data: Failed err=-23 
> > [   15.440398] usbcore: registered new interface driver brcmfmac 
>
> Those are "normal" this is the brcmfmac driver trying to enable some 
> features which are not supported on this model wifi chip. 
>
> 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.


[linux-sunxi] Re: [PATCH v6 3/3] ARM: sunxi: Add IR controller support in DT on A20

2014-05-14 Thread Александр Берсенев
Sending two changes as the patch. 
I am not using ir1_pins_a because cubietruck has only one ir port, but 
other A20 devices may have up to 2 ir ports.

Signed-off-by: Alexander Bersenev 

diff --git a/arch/arm/boot/dts/sun7i-a20.dtsi 
b/arch/arm/boot/dts/sun7i-a20.dtsi
index 40ded74..53a9ab1 100644
--- a/arch/arm/boot/dts/sun7i-a20.dtsi
+++ b/arch/arm/boot/dts/sun7i-a20.dtsi
@@ -731,6 +731,7 @@
allwinner,drive = <0>;
allwinner,pull = <0>;
};
+
ir1_pins_a: ir1@0 {
allwinner,pins = "PB22","PB23";
allwinner,function = "ir1";
@@ -965,7 +966,7 @@
clocks = <&apb0_gates 7>, <&ir1_clk>;
clock-names = "apb", "ir";
interrupts = <0 6 4>;
-   reg = <0x01C21c00 0x40>;
+   reg = <0x01c21c00 0x40>;
status = "disabled";
};
};


среда, 14 мая 2014 г., 13:50:17 UTC+6 пользователь Maxime Ripard написал:
>
> On Wed, May 14, 2014 at 12:39:02AM +0600, Alexander Bersenev wrote: 
> > This patch adds IR controller in A20 Device-Tree: 
> > - Two IR devices found in A20 user manual 
> > - Pins for two devices 
> > - One IR device physically found on Cubieboard 2 
> > - One IR device physically found on Cubietruck 
> > 
> > Signed-off-by: Alexander Bersenev > 
> > Signed-off-by: Alexsey Shestacov > 
>
> > --- 
> >  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| 31 
> + 
> >  3 files changed, 43 insertions(+) 
> > 
> > diff --git a/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts 
> b/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts 
> > index feeff64..2564e8c 100644 
> > --- a/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts 
> > +++ b/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts 
> > @@ -164,6 +164,12 @@ 
> >  reg = <1>; 
> >  }; 
> >  }; 
> > + 
> > +ir0: ir@01c21800 { 
> > +pinctrl-names = "default"; 
> > +pinctrl-0 = <&ir0_pins_a>; 
> > +status = "okay"; 
> > +}; 
> >  }; 
> >   
> >  leds { 
> > diff --git a/arch/arm/boot/dts/sun7i-a20-cubietruck.dts 
> b/arch/arm/boot/dts/sun7i-a20-cubietruck.dts 
> > index e288562..e375e89 100644 
> > --- a/arch/arm/boot/dts/sun7i-a20-cubietruck.dts 
> > +++ b/arch/arm/boot/dts/sun7i-a20-cubietruck.dts 
> > @@ -232,6 +232,12 @@ 
> >  reg = <1>; 
> >  }; 
> >  }; 
> > + 
> > +ir0: ir@01c21800 { 
> > +pinctrl-names = "default"; 
> > +pinctrl-0 = <&ir0_pins_a>; 
> > +status = "okay"; 
> > +}; 
> >  }; 
> >   
> >  leds { 
>
> Please make these two changes a separate patch. 
>
> > diff --git a/arch/arm/boot/dts/sun7i-a20.dtsi 
> b/arch/arm/boot/dts/sun7i-a20.dtsi 
> > index 0ae2b77..40ded74 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>; 
> > +}; 
>
> Extra line 
>
> > +ir1_pins_a: ir1@0 { 
> > +allwinner,pins = "PB22","PB23"; 
> > +allwinner,function = "ir1"; 
> > +allwinner,drive = <0>; 
> > +allwinner,pull = <0>; 
> > +}; 
> >  }; 
>
> Do you use ir1_pins_a at all? 
>
> I also prefer whenever such additions are in a patch of their own. 
>
> >  timer@01c20c00 { 
> > @@ -937,5 +950,23 @@ 
> >  #interrupt-cells = <3>; 
> >  interrupts = <1 9 0xf04>; 
> >  }; 
> > + 
> > +ir0: ir@01c21800 { 
> > +compatible = "allwinner,sun7i-a20-ir"; 
> > +clocks = <&apb0_gates 6>, <&ir0_clk>; 
> > +clock-names = "apb", "ir"; 
> > +interrupts = <0 5 4>; 
> > +reg = <0x01c2180

[linux-sunxi] Re: [PATCH v4 03/03] ARM: sunxi: Add IR controller support in DT on A20

2014-04-30 Thread Александр Берсенев
This patch adds IR controller in A20 Device-Tree:
- Two IR devices found in A20 user manual
- Pins for two devices
- One IR device physically found on Cubieboard 2 
- One IR device physically found on Cubietruck 

Signed-off-by: Alexander Bersenev 
Signed-off-by: Alexsey Shestacov 

diff --git a/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts 
b/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts
index feeff64..2564e8c 100644
--- a/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts
+++ b/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts
@@ -164,6 +164,12 @@
  reg = <1>;
  };
  };
+
+ ir0: ir@01c21800 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&ir0_pins_a>;
+ status = "okay";
+ };
  };
 
  leds {
diff --git a/arch/arm/boot/dts/sun7i-a20-cubietruck.dts 
b/arch/arm/boot/dts/sun7i-a20-cubietruck.dts
index e288562..e375e89 100644
--- a/arch/arm/boot/dts/sun7i-a20-cubietruck.dts
+++ b/arch/arm/boot/dts/sun7i-a20-cubietruck.dts
@@ -232,6 +232,12 @@
  reg = <1>;
  };
  };
+
+ ir0: ir@01c21800 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&ir0_pins_a>;
+ status = "okay";
+ };
  };
 
  leds {
diff --git a/arch/arm/boot/dts/sun7i-a20.dtsi 
b/arch/arm/boot/dts/sun7i-a20.dtsi
index 0ae2b77..bb655a5 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,23 @@
  #interrupt-cells = <3>;
  interrupts = <1 9 0xf04>;
  };
+
+   ir0: ir@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@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";
+ };
  };
 };


среда, 30 апреля 2014 г., 16:51:12 UTC+6 пользователь Александр Берсенев 
написал:
>
> 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.
>
>

-- 
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.


[linux-sunxi] Re: [PATCH v4 02/03] ARM: sunxi: Add driver for sunxi IR controller

2014-04-30 Thread Александр Берсенев
gned long tmp = 0;
+
+ struct device *dev = &pdev->dev;
+ struct device_node *dn = dev->of_node;
+ struct resource *res;
+ struct sunxi_ir *ir;
+
+ ir = devm_kzalloc(dev, sizeof(struct sunxi_ir), GFP_KERNEL);
+ if (!ir)
+ return -ENOMEM;
+
+ /* Clock */
+ ir->apb_clk = devm_clk_get(dev, "apb");
+ if (IS_ERR(ir->apb_clk)) {
+ dev_err(dev, "failed to get a apb clock.\n");
+ return -EINVAL;
+ }
+ ir->clk = devm_clk_get(dev, "ir");
+ if (IS_ERR(ir->clk)) {
+ dev_err(dev, "failed to get a ir clock.\n");
+ return -EINVAL;
+ }
+
+ ret = clk_set_rate(ir->clk, SUNXI_IR_BASE_CLK);
+ if (ret) {
+ dev_err(dev, "set ir base clock failed!\n");
+ return -EINVAL;
+ }
+
+ if (clk_prepare_enable(ir->apb_clk)) {
+ dev_err(dev, "try to enable apb_ir_clk failed\n");
+ return -EINVAL;
+ }
+
+ if (clk_prepare_enable(ir->clk)) {
+ dev_err(dev, "try to enable ir_clk failed\n");
+ ret = -EINVAL;
+ goto exit_clkdisable_apb_clk;
+ }
+
+ /* IO */
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+
+ ir->base = devm_ioremap_resource(dev, res);
+ if (IS_ERR(ir->base)) {
+ dev_err(dev, "failed to map registers\n");
+ ret = -ENOMEM;
+ goto exit_clkdisable_clk;
+ }
+
+ /* IRQ */
+ ir->irq = platform_get_irq(pdev, 0);
+ if (ir->irq < 0) {
+ dev_err(dev, "no irq resource\n");
+ ret = -EINVAL;
+ goto exit_clkdisable_clk;
+ }
+
+ ret = devm_request_irq(dev, ir->irq, sunxi_ir_irq, 0, SUNXI_IR_DEV, ir);
+ if (ret) {
+ dev_err(dev, "failed request irq\n");
+ ret = -EINVAL;
+ goto exit_clkdisable_clk;
+ }
+
+ ir->rc = rc_allocate_device();
+
+ if (!ir->rc) {
+ dev_err(dev, "failed to allocate device\n");
+ ret = -ENOMEM;
+ goto exit_clkdisable_clk;
+ }
+
+ ir->rc->priv = ir;
+ ir->rc->input_name = SUNXI_IR_DEV;
+ ir->rc->input_phys = "sunxi-ir/input0";
+ ir->rc->input_id.bustype = BUS_HOST;
+ ir->rc->input_id.vendor = 0x0001;
+ ir->rc->input_id.product = 0x0001;
+ ir->rc->input_id.version = 0x0100;
+ ir->map_name = of_get_property(dn, "linux,rc-map-name", NULL);
+ ir->rc->map_name = ir->map_name ?: RC_MAP_EMPTY;
+ ir->rc->dev.parent = dev;
+ ir->rc->driver_type = RC_DRIVER_IR_RAW;
+ rc_set_allowed_protocols(ir->rc, RC_BIT_ALL);
+ ir->rc->rx_resolution = SUNXI_IR_SAMPLE;
+ ir->rc->timeout = MS_TO_NS(SUNXI_IR_TIMEOUT);
+ ir->rc->driver_name = SUNXI_IR_DEV;
+
+ ret = rc_register_device(ir->rc);
+ if (ret) {
+ dev_err(dev, "failed to register rc device\n");
+ ret = -EINVAL;
+ goto exit_free_dev;
+ }
+
+ platform_set_drvdata(pdev, ir);
+
+ /* Enable CIR Mode */
+ writel(0x3 << 4, ir->base+SUNXI_IR_CTL_REG);
+
+ /* Config IR Sample Register */
+ /* Fsample = clk */
+ tmp = 0;
+ /* Set Filter Threshold */
+ tmp |= (SUNXI_IR_RXFILT & 0x3f) << 2;
+ /* Set Idle Threshold */
+ tmp |= (SUNXI_IR_RXIDLE & 0xff) << 8;
+ writel(tmp, ir->base + SUNXI_IR_CIR_REG);
+
+ /* Invert Input Signal */
+ writel(0x1 << 2, ir->base + SUNXI_IR_RXCTL_REG);
+
+ /* Clear All Rx Interrupt Status */
+ writel(0xff, ir->base + SUNXI_IR_RXSTA_REG);
+
+ /* Enable IRQ on data, overflow, packed end */
+ tmp = (0x1 << 4) | 0x3;
+
+ /* Rx FIFO Threshold */
+ tmp |= (SUNXI_IR_FIFO_TRIG - 1) << 8;
+
+ writel(tmp, ir->base + SUNXI_IR_RXINT_REG);
+
+ /* Enable IR Module */
+ tmp = readl(ir->base + SUNXI_IR_CTL_REG);
+
+ writel(tmp | 0x3, ir->base + SUNXI_IR_CTL_REG);
+
+ dev_info(dev, "initialized sunXi IR driver\n");
+ return 0;
+
+exit_free_dev:
+ rc_free_device(ir->rc);
+exit_clkdisable_clk:
+ clk_disable_unprepare(ir->clk);
+exit_clkdisable_apb_clk:
+ clk_disable_unprepare(ir->apb_clk);
+
+ return ret;
+}
+
+static int sunxi_ir_remove(struct platform_device *pdev)
+{
+ unsigned long flags;
+ struct sunxi_ir *ir = platform_get_drvdata(pdev);
+
+ clk_disable_unprepare(ir->clk);
+ clk_disable_unprepare(ir->apb_clk);
+
+ spin_lock_irqsave(&ir->ir_lock, flags);
+ /* disable IR IRQ */
+ writel(0, ir->base + SUNXI_IR_RXINT_REG);
+ /* clear All Rx Interrupt Status */
+ writel(0xff, ir->base + SUNXI_IR_RXSTA_REG);
+ /* disable IR */
+ writel(0, ir->base + SUNXI_IR_CTL_REG);
+ spin_unlock_irqrestore(&ir->ir_lock, flags);
+
+ rc_unregister_device(ir->rc);
+ return 0;
+}
+
+static const struct of_device_id sunxi_ir_match[] = {
+ { .compatible = "allwinner,sun7i-a20-ir", },
+ {},
+};
+
+static struct platform_driver sunxi_ir_driver = {
+ .probe  = sunxi_ir_probe,
+ .remove = sunxi_ir_remove,
+ .driver = {
+ .name = SUNXI_IR_DEV,
+ .owner = THIS_MODULE,
+ .of_match_table = sunxi_ir_match,
+ },
+};
+
+module_platform_driver(sunxi_ir_driver);
+
+MODULE_DESCRIPTION("Allwinner sunXi IR controller driver");
+MODULE_AUTHOR("Alexsey Shestacov ");
+MODULE_LICENSE("G

[linux-sunxi] Re: [PATCH v4 01/03] ARM: sunxi: Add documentation for sunxi consumer infrared devices

2014-04-30 Thread Александр Берсенев
[PATCH v4 01/03] ARM: sunxi: Add documentation for sunxi consumer infrared 
devices

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

Signed-off-by: Alexander Bersenev 
Signed-off-by: Alexsey Shestacov 

diff --git a/Documentation/devicetree/bindings/media/sunxi-ir.txt 
b/Documentation/devicetree/bindings/media/sunxi-ir.txt
new file mode 100644
index 000..d502cf4
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/sunxi-ir.txt
@@ -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 "apb0_ir0" and "ir0" 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@01c21800 {
+   compatible = "allwinner,sun7i-a20-ir";
+   clocks = <&apb0_gates 6>, <&ir0_clk>;
+   clock-names = "apb0_ir0", "ir0";
+   interrupts = <0 5 1>;
+   reg = <0x01C21800 0x40>;
+   linux,rc-map-name = "rc-rc6-mce";
+};


среда, 30 апреля 2014 г., 16:51:12 UTC+6 пользователь Александр Берсенев 
написал:
>
> 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.
>

-- 
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.


[linux-sunxi] [PATCH v4 00/03] ARM: sunxi: Add support for consumer infrared devices

2014-04-30 Thread Александр Берсенев
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.

Signed-off-by: Alexander Bersenev 
Signed-off-by: Alexsey Shestacov 

---
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

-- 
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.


[linux-sunxi] Re: [PATCH] sunxi: make gate clock getable by name

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

You are right, adding clock-names works for me and it seems to be a good 
way to work with the clocks. This patch is not nessesary for me anymore, it 
may be applied just for consistency with other timers, which are searchabe 
via devm_clk_get(NULL, clockname).

Best,
Alexander Bersenev, Institute of Mathematics and Mechanics

среда, 30 апреля 2014 г., 14:25:47 UTC+6 пользователь Александр Берсенев 
написал:
>
> This patch enables to use devm_clk_get function to get gate clocks by name.
> 
> Signed-off-by: Alexander Bersenev 
>
> diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c
> index 31584ee..3617681 100644
> --- a/drivers/clk/sunxi/clk-sunxi.c
> +++ b/drivers/clk/sunxi/clk-sunxi.c
> @@ -1048,6 +1048,8 @@ static void __init sunxi_gates_clk_setup(struct 
> device_node *node,
>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++;
>   }
>
>

-- 
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.


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

2014-04-30 Thread Александр Берсенев
Thanks for comments.

The IR controllers in A10 and A20 are very similar but not same. The only 
difference I found is a FIFO size.
I'll try to use devm_clk_get to get the time, but now it's not possible to 
add gate clock by name. I've just sent a patch to this mailing list to add 
this possibility.
Also setting clock-frequency via DT is not implenented yet for sunxi 
clocks. I can try to add this functionality too.

The rest are fixed and will be available in the next version of the patch. 
I'll try to split in on smaller patches.

Best,
Alexander Bersenev, Institute of Mathematics and Mechanics

среда, 30 апреля 2014 г., 3:51:31 UTC+6 пользователь Александр Берсенев 
написал:
>
> 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
>
> Signed-off-by: Alexander Bersenev  
> Signed-off-by: Alexsey Shestacov   
>
> diff --git a/Documentation/devicetree/bindings/media/sunxi-ir.txt 
> b/Documentation/devicetree/bindings/media/sunxi-ir.txt
> new file mode 100644
> index 000..0d416f4
> --- /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 contain SoC gate for IR clock.
> + Second should contain IR feed clock itself.
> +   - 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@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-cubieboard2.dts 
> b/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts
> index feeff64..01b519c 100644
> --- a/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts
> +++ b/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts
> @@ -164,6 +164,13 @@
>   reg = <1>;
>   };
>   };
> +
> + ir0: ir@01c21800 {
> + pinctrl-names = "default";
> + pinctrl-0 = <&ir0_pins_a>;
> + gpios = <&pio 1 4 0>;
> + status = "okay";
> + };
>   };
>  
>   leds {
> diff --git a/arch/arm/boot/dts/sun7i-a20-cubietruck.dts 
> b/arch/arm/boot/dts/sun7i-a20-cubietruck.dts
> index e288562..683090f 100644
> --- a/arch/arm/boot/dts/sun7i-a20-cubietruck.dts
> +++ b/arch/arm/boot/dts/sun7i-a20-cubietruck.dts
> @@ -232,6 +232,13 @@
>   reg = <1>;
>   };
>   };
> +
> + ir0: ir@01c21800 {
> + pinctrl-names = "default";
> + pinctrl-0 = <&ir0_pins_a>;
> + gpios = <&pio 1 4 0>;
> + status = "okay";
> + };
>   };
>  
>   leds {
> 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";
> + };
> +
> +

[linux-sunxi] [PATCH] sunxi: make gate clock getable by name

2014-04-30 Thread Александр Берсенев
This patch enables to use devm_clk_get function to get gate clocks by name.

Signed-off-by: Alexander Bersenev 

diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c
index 31584ee..3617681 100644
--- a/drivers/clk/sunxi/clk-sunxi.c
+++ b/drivers/clk/sunxi/clk-sunxi.c
@@ -1048,6 +1048,8 @@ static void __init sunxi_gates_clk_setup(struct 
device_node *node,
   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++;
  }

-- 
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.


[linux-sunxi] [PATCH v3] sunxi: Add support for consumer infrared devices

2014-04-29 Thread Александр Берсенев
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

Signed-off-by: Alexander Bersenev  
Signed-off-by: Alexsey Shestacov   

diff --git a/Documentation/devicetree/bindings/media/sunxi-ir.txt 
b/Documentation/devicetree/bindings/media/sunxi-ir.txt
new file mode 100644
index 000..0d416f4
--- /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 contain SoC gate for IR clock.
+ Second should contain IR feed clock itself.
+   - 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@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-cubieboard2.dts 
b/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts
index feeff64..01b519c 100644
--- a/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts
+++ b/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts
@@ -164,6 +164,13 @@
  reg = <1>;
  };
  };
+
+ ir0: ir@01c21800 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&ir0_pins_a>;
+ gpios = <&pio 1 4 0>;
+ status = "okay";
+ };
  };
 
  leds {
diff --git a/arch/arm/boot/dts/sun7i-a20-cubietruck.dts 
b/arch/arm/boot/dts/sun7i-a20-cubietruck.dts
index e288562..683090f 100644
--- a/arch/arm/boot/dts/sun7i-a20-cubietruck.dts
+++ b/arch/arm/boot/dts/sun7i-a20-cubietruck.dts
@@ -232,6 +232,13 @@
  reg = <1>;
  };
  };
+
+ ir0: ir@01c21800 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&ir0_pins_a>;
+ gpios = <&pio 1 4 0>;
+ status = "okay";
+ };
  };
 
  leds {
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..9b5639e
--- /dev/null
+++ b/drivers/media/rc/sunxi-ir.c
@@ -0,0 +1,314 @@
+/*
+ * Driver for Allwinner sunXi IR controller
+ *
+ * Copyright (C) 2014 Alexsey Shestacov 
+ *
+ * Based on sun5i-ir.c:
+ * Copyright (C) 2007-2012 Daniel Wang
+ * Allwinner Technology Co., Ltd. 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published b

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

2014-04-29 Thread Александр Берсенев
The problem with timeouts is with the 
function ir_raw_event_store_with_filter which automerges samples of same 
type. When the packet ends, there is 21504us space(no pulse) in it and this 
function waits for more data to merge. New data arives only when next 
button pressed on ir remote. Function ir_raw_event_store_with_filter has a 
timeout for waiting, but this timeout checked on each call of this 
function(on each interrupt), if user doesn't press buttons, the 
ir-interrups don't occur. 

среда, 30 апреля 2014 г., 0:42:25 UTC+6 пользователь Александр Берсенев 
написал:
>
> Thank you for comments, fixes will be in the next version of the patch.
>
> About:
> #ifdef CONFIG_ARCH_SUN5I 
> #define IR_FIFO_SIZE(64)/* 64Bytes */ 
> #else 
> #define IR_FIFO_SIZE(16)/* 16Bytes */ 
> #endif 
>
> In sun5i datasheet at 
> http://dl.linux-sunxi.org/A13/A13%20User%20Manual%20-%20v1.2%20%282013-01-08%29.pdfsaid
>  that sun5i and sun4i has 16 bytes fifo each and sun7i has 64 bytes 
> fifo. All sunxi'es should work well with 16 bytes fifo, but 64 bytes fifos 
> should be little faster on sun7i.
>
> I hit some unexpected behavior of rc-core logic - if I press buttons very 
> quickly(about 10 times per seconds) the latest pressing not shows until I 
> press any another button. If I set ir->rc->timeout to very low value this 
> problem disappears. I set it to 100 msec like in other ir-drivers instead 
> 120, but this not fixes problem fully. May be it is because I don't use 
> keys mapping and keyup events not generated.  
>
> Also there is a small memory leak during module loading/unloading.
>
> вторник, 29 апреля 2014 г., 10:56:32 UTC+6 пользователь Priit Laes написал:
>>
>> Ühel kenal päeval, E, 28.04.2014 kell 12:57, kirjutas Александр 
>> Берсенев: 
>> > 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. 
>>
>> You need to also CC people/lists in charge of certian parts of the 
>> kernel tree this patch touches. There's get_maintainer.pl under scripts 
>> directory in kernel tree. 
>>
>> > Changes since version 1: 
>> >  - Fix timer memory leaks 
>> >  - Fix race condition when driver unloads while interrupt handler is 
>> > active 
>> >  - Support Cubieboard 2(need testing) 
>> > 
>> > 
>> > Signed-off-by: Alexander Bersenev  
>> > CC: wing...@linux-sunxi.org 
>> > 
>> > 
>> > 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. 
>> missing before second. 
>>
>> > +   - interrupts: Should constain IR IRQ number. 
>> > +   -reg: Should constain IO map address for IR. 
>> s/constain/contain 
>>
>> > + 
>> > +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-cubieboard2.dts 
>> > b/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts 
>> > index feeff64..01b519c 100644 
>> > --- a/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts 
>> > +++ b/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts 
>> > @@ -164,6 +164,13 @@ 
>> >   reg = <1>; 
>> >   }; 
>> >   }; 
>> > + 
>> > + ir0: ir@01c21800 { 
>> > + pinctrl-names = "default"; 
>> > + pinctrl-0 = <&ir0_pins_a>; 
>> > + gpios = <&pio 1 4 0>; 
>> > + status = "okay"

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

2014-04-29 Thread Александр Берсенев
Thank you for comments, fixes will be in the next version of the patch.

About:
#ifdef CONFIG_ARCH_SUN5I 
#define IR_FIFO_SIZE(64)/* 64Bytes */ 
#else 
#define IR_FIFO_SIZE(16)/* 16Bytes */ 
#endif 

In sun5i datasheet 
at 
http://dl.linux-sunxi.org/A13/A13%20User%20Manual%20-%20v1.2%20%282013-01-08%29.pdf
 
said that sun5i and sun4i has 16 bytes fifo each and sun7i has 64 bytes 
fifo. All sunxi'es should work well with 16 bytes fifo, but 64 bytes fifos 
should be little faster on sun7i.

I hit some unexpected behavior of rc-core logic - if I press buttons very 
quickly(about 10 times per seconds) the latest pressing not shows until I 
press any another button. If I set ir->rc->timeout to very low value this 
problem disappears. I set it to 100 msec like in other ir-drivers instead 
120, but this not fixes problem fully. May be it is because I don't use 
keys mapping and keyup events not generated.  

Also there is a small memory leak during module loading/unloading.

вторник, 29 апреля 2014 г., 10:56:32 UTC+6 пользователь Priit Laes написал:
>
> Ühel kenal päeval, E, 28.04.2014 kell 12:57, kirjutas Александр 
> Берсенев: 
> > 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. 
>
> You need to also CC people/lists in charge of certian parts of the 
> kernel tree this patch touches. There's get_maintainer.pl under scripts 
> directory in kernel tree. 
>
> > Changes since version 1: 
> >  - Fix timer memory leaks 
> >  - Fix race condition when driver unloads while interrupt handler is 
> > active 
> >  - Support Cubieboard 2(need testing) 
> > 
> > 
> > Signed-off-by: Alexander Bersenev > 
> > CC: wing...@linux-sunxi.org  
> > 
> > 
> > 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. 
> missing before second. 
>
> > +   - interrupts: Should constain IR IRQ number. 
> > +   -reg: Should constain IO map address for IR. 
> s/constain/contain 
>
> > + 
> > +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-cubieboard2.dts 
> > b/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts 
> > index feeff64..01b519c 100644 
> > --- a/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts 
> > +++ b/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts 
> > @@ -164,6 +164,13 @@ 
> >   reg = <1>; 
> >   }; 
> >   }; 
> > + 
> > + ir0: ir@01c21800 { 
> > + pinctrl-names = "default"; 
> > + pinctrl-0 = <&ir0_pins_a>; 
> > + gpios = <&pio 1 4 0>; 
> > + status = "okay"; 
> > + }; 
> >   }; 
> >   
> >   leds { 
> > diff --git a/arch/arm/boot/dts/sun7i-a20-cubietruck.dts 
> > b/arch/arm/boot/dts/sun7i-a20-cubietruck.dts 
> > index e288562..683090f 100644 
> > --- a/arch/arm/boot/dts/sun7i-a20-cubietruck.dts 
> > +++ b/arch/arm/boot/dts/sun7i-a20-cubietruck.dts 
> > @@ -232,6 +232,13 @@ 
> >   reg = <1>; 
> >   }; 
> >   }; 
> > + 
> > + ir0: ir@01c21800 { 
> > + pinctrl-names = "default"; 
> > + pinctrl-0 = <&ir0_pins_a>; 
> > + gpios = <&pio 1 4 0>; 
> > + status = "okay"; 
> > + }; 
> >   }; 
> >   
> >   leds { 
> > 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 
> &g

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

2014-04-28 Thread Александр Берсенев
I connected with wingrime, it seems we are graduated from the same 
university, it was very surprising for me :). He said he had ir driver 
almost-ready last summer, but he hasn't much free time now.

Also I checked the patch with checkpatch.pl and all is ok:
total: 0 errors, 0 warnings, 430 lines checked

ir.patch has no obvious style problems and is ready for submission.

The patch needs testing on cubieboard 2. If it will work, I'll split it on 
two patches and resubmit.

Best,
Alexander Bersenev, Institute of Mathematics and Mechanics, Russia

вторник, 29 апреля 2014 г., 1:57:05 UTC+6 пользователь Александр Берсенев 
написал:
>
> 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)
>
> Signed-off-by: Alexander Bersenev 
> CC: wingr...@linux-sunxi.org
>
> 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-cubieboard2.dts 
> b/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts
> index feeff64..01b519c 100644
> --- a/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts
> +++ b/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts
> @@ -164,6 +164,13 @@
>   reg = <1>;
>   };
>   };
> +
> + ir0: ir@01c21800 {
> + pinctrl-names = "default";
> + pinctrl-0 = <&ir0_pins_a>;
> + gpios = <&pio 1 4 0>;
> + status = "okay";
> + };
>   };
>  
>   leds {
> diff --git a/arch/arm/boot/dts/sun7i-a20-cubietruck.dts 
> b/arch/arm/boot/dts/sun7i-a20-cubietruck.dts
> index e288562..683090f 100644
> --- a/arch/arm/boot/dts/sun7i-a20-cubietruck.dts
> +++ b/arch/arm/boot/dts/sun7i-a20-cubietruck.dts
> @@ -232,6 +232,13 @@
>   reg = <1>;
>   };
>   };
> +
> + ir0: ir@01c21800 {
> + pinctrl-names = "default";
> + pinctrl-0 = <&ir0_pins_a>;
> + gpios = <&pio 1 4 0>;
> + status = "okay";
> + };
>   };
>  
>   leds {
> 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/drive

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

2014-04-28 Thread Александр Берсенев
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)

Signed-off-by: Alexander Bersenev 
CC: wingr...@linux-sunxi.org

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-cubieboard2.dts 
b/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts
index feeff64..01b519c 100644
--- a/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts
+++ b/arch/arm/boot/dts/sun7i-a20-cubieboard2.dts
@@ -164,6 +164,13 @@
  reg = <1>;
  };
  };
+
+ ir0: ir@01c21800 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&ir0_pins_a>;
+ gpios = <&pio 1 4 0>;
+ status = "okay";
+ };
  };
 
  leds {
diff --git a/arch/arm/boot/dts/sun7i-a20-cubietruck.dts 
b/arch/arm/boot/dts/sun7i-a20-cubietruck.dts
index e288562..683090f 100644
--- a/arch/arm/boot/dts/sun7i-a20-cubietruck.dts
+++ b/arch/arm/boot/dts/sun7i-a20-cubietruck.dts
@@ -232,6 +232,13 @@
  reg = <1>;
  };
  };
+
+ ir0: ir@01c21800 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&ir0_pins_a>;
+ gpios = <&pio 1 4 0>;
+ status = "okay";
+ };
  };
 
  leds {
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..e1f1ab3
--- /dev/null
+++ b/drivers/media/rc/sunxi-ir.c
@@ -0,0 +1,324 @@
+/*
+ * Driver for Allwinner sunXi IR controller
+ *
+ * Copyright (C) 2014 Alexsey Shestacov 
+ *
+ * Based on sun5i-ir.c:
+ * Copyright (C) 2007-2012 Daniel Wang
+ * Allwinner Technology Co., Ltd. 
+ *
+ * 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 implie

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

2014-04-27 Thread Александр Берсенев
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.

Best,
Alexander Bersenev, Institute of Mathematics and Mechanics, Russia

понедельник, 28 апреля 2014 г., 11:10:18 UTC+6 пользователь Александр 
Берсенев написал:
>
> 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
>
>

-- 
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 Александр Берсенев
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 
>
> 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 {
> @@ -

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 

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 
+ *
+ * Based on sun5i-ir.c:
+ * Copyright (C) 2007-2012 Daniel Wang
+ * Allwinner Technology Co., Ltd. 
+ *
+ * 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 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#incl