[linux-sunxi] Re: [PATCH 4/9] rc: sunxi-cir: Add support for an optional reset controller

2014-11-20 Thread Mauro Carvalho Chehab
Em Thu, 20 Nov 2014 16:55:23 +0100
Hans de Goede hdego...@redhat.com escreveu:

 On sun6i the cir block is attached to the reset controller, add support
 for de-asserting the reset if a reset controller is specified in dt.
 
 Signed-off-by: Hans de Goede hdego...@redhat.com

As this is meant to be merged via some other tree:

Acked-by: Mauro Carvalho Chehab mche...@osg.samsung.com


 ---
  drivers/media/rc/sunxi-cir.c | 25 +++--
  1 file changed, 23 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/media/rc/sunxi-cir.c b/drivers/media/rc/sunxi-cir.c
 index bcee8e1..895fb65 100644
 --- a/drivers/media/rc/sunxi-cir.c
 +++ b/drivers/media/rc/sunxi-cir.c
 @@ -23,6 +23,7 @@
  #include linux/interrupt.h
  #include linux/module.h
  #include linux/of_platform.h
 +#include linux/reset.h
  #include media/rc-core.h
  
  #define SUNXI_IR_DEV sunxi-ir
 @@ -95,6 +96,7 @@ struct sunxi_ir {
   int irq;
   struct clk  *clk;
   struct clk  *apb_clk;
 + struct reset_control *rst;
   const char  *map_name;
  };
  
 @@ -166,15 +168,29 @@ static int sunxi_ir_probe(struct platform_device *pdev)
   return PTR_ERR(ir-clk);
   }
  
 + /* Reset (optional) */
 + ir-rst = devm_reset_control_get_optional(dev, NULL);
 + if (IS_ERR(ir-rst)) {
 + ret = PTR_ERR(ir-rst);
 + if (ret == -EPROBE_DEFER)
 + return ret;
 + ir-rst = NULL;
 + } else {
 + ret = reset_control_deassert(ir-rst);
 + if (ret)
 + return ret;
 + }
 +
   ret = clk_set_rate(ir-clk, SUNXI_IR_BASE_CLK);
   if (ret) {
   dev_err(dev, set ir base clock failed!\n);
 - return ret;
 + goto exit_reset_assert;
   }
  
   if (clk_prepare_enable(ir-apb_clk)) {
   dev_err(dev, try to enable apb_ir_clk failed\n);
 - return -EINVAL;
 + ret = -EINVAL;
 + goto exit_reset_assert;
   }
  
   if (clk_prepare_enable(ir-clk)) {
 @@ -271,6 +287,9 @@ exit_clkdisable_clk:
   clk_disable_unprepare(ir-clk);
  exit_clkdisable_apb_clk:
   clk_disable_unprepare(ir-apb_clk);
 +exit_reset_assert:
 + if (ir-rst)
 + reset_control_assert(ir-rst);
  
   return ret;
  }
 @@ -282,6 +301,8 @@ static int sunxi_ir_remove(struct platform_device *pdev)
  
   clk_disable_unprepare(ir-clk);
   clk_disable_unprepare(ir-apb_clk);
 + if (ir-rst)
 + reset_control_assert(ir-rst);
  
   spin_lock_irqsave(ir-ir_lock, flags);
   /* disable IR IRQ */

-- 
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 5/9] rc: sunxi-cir: Add support for the larger fifo found on sun5i and sun6i

2014-11-20 Thread Mauro Carvalho Chehab
Em Thu, 20 Nov 2014 16:55:24 +0100
Hans de Goede hdego...@redhat.com escreveu:

 Add support for the larger fifo found on sun5i and sun6i, having a separate
 compatible for the ir found on sun5i  sun6i also is useful if we ever want
 to add ir transmit support, because the sun5i  sun6i version do not have
 transmit support.
 
 Note this commits also adds checking for the end-of-packet interrupt flag
 (which was already enabled), as the fifo-data-available interrupt flag only
 gets set when the trigger-level is exceeded. So far we've been getting away
 with not doing this because of the low trigger-level, but this is something
 which we should have done since day one.
 
 Signed-off-by: Hans de Goede hdego...@redhat.com

As this is meant to be merged via some other tree:

Acked-by: Mauro Carvalho Chehab mche...@osg.samsung.com


 ---
  .../devicetree/bindings/media/sunxi-ir.txt  |  2 +-
  drivers/media/rc/sunxi-cir.c| 21 
 -
  2 files changed, 13 insertions(+), 10 deletions(-)
 
 diff --git a/Documentation/devicetree/bindings/media/sunxi-ir.txt 
 b/Documentation/devicetree/bindings/media/sunxi-ir.txt
 index 23dd5ad..5767128 100644
 --- a/Documentation/devicetree/bindings/media/sunxi-ir.txt
 +++ b/Documentation/devicetree/bindings/media/sunxi-ir.txt
 @@ -1,7 +1,7 @@
  Device-Tree bindings for SUNXI IR controller found in sunXi SoC family
  
  Required properties:
 -- compatible : should be allwinner,sun4i-a10-ir;
 +- compatible : allwinner,sun4i-a10-ir or allwinner,sun5i-a13-ir
  - clocks : list of clock specifiers, corresponding to
 entries in clock-names property;
  - clock-names: should contain apb and ir entries;
 diff --git a/drivers/media/rc/sunxi-cir.c b/drivers/media/rc/sunxi-cir.c
 index 895fb65..559b0e3 100644
 --- a/drivers/media/rc/sunxi-cir.c
 +++ b/drivers/media/rc/sunxi-cir.c
 @@ -56,12 +56,12 @@
  #define REG_RXINT_RAI_EN BIT(4)
  
  /* Rx FIFO available byte level */
 -#define REG_RXINT_RAL(val)(((val)  8)  (GENMASK(11, 8)))
 +#define REG_RXINT_RAL(val)((val)  8)
  
  /* Rx Interrupt Status */
  #define SUNXI_IR_RXSTA_REG0x30
  /* RX FIFO Get Available Counter */
 -#define REG_RXSTA_GET_AC(val) (((val)  8)  (GENMASK(5, 0)))
 +#define REG_RXSTA_GET_AC(val) (((val)  8)  (ir-fifo_size * 2 - 1))
  /* Clear all interrupt status value */
  #define REG_RXSTA_CLEARALL0xff
  
 @@ -72,10 +72,6 @@
  /* CIR_REG register idle threshold */
  #define REG_CIR_ITHR(val)(((val)  8)  (GENMASK(15, 8)))
  
 -/* Hardware supported fifo size */
 -#define SUNXI_IR_FIFO_SIZE16
 -/* How many messages in FIFO trigger IRQ */
 -#define TRIGGER_LEVEL 8
  /* Required frequency for IR0 or IR1 clock in CIR mode */
  #define SUNXI_IR_BASE_CLK 800
  /* Frequency after IR internal divider  */
 @@ -94,6 +90,7 @@ struct sunxi_ir {
   struct rc_dev   *rc;
   void __iomem*base;
   int irq;
 + int fifo_size;
   struct clk  *clk;
   struct clk  *apb_clk;
   struct reset_control *rst;
 @@ -115,11 +112,11 @@ static irqreturn_t sunxi_ir_irq(int irqno, void *dev_id)
   /* clean all pending statuses */
   writel(status | REG_RXSTA_CLEARALL, ir-base + SUNXI_IR_RXSTA_REG);
  
 - if (status  REG_RXINT_RAI_EN) {
 + if (status  (REG_RXINT_RAI_EN | REG_RXINT_RPEI_EN)) {
   /* How many messages in fifo */
   rc  = REG_RXSTA_GET_AC(status);
   /* Sanity check */
 - rc = rc  SUNXI_IR_FIFO_SIZE ? SUNXI_IR_FIFO_SIZE : rc;
 + rc = rc  ir-fifo_size ? ir-fifo_size : rc;
   /* If we have data */
   for (cnt = 0; cnt  rc; cnt++) {
   /* for each bit in fifo */
 @@ -156,6 +153,11 @@ static int sunxi_ir_probe(struct platform_device *pdev)
   if (!ir)
   return -ENOMEM;
  
 + if (of_device_is_compatible(dn, allwinner,sun5i-a13-ir))
 + ir-fifo_size = 64;
 + else
 + ir-fifo_size = 16;
 +
   /* Clock */
   ir-apb_clk = devm_clk_get(dev, apb);
   if (IS_ERR(ir-apb_clk)) {
 @@ -271,7 +273,7 @@ static int sunxi_ir_probe(struct platform_device *pdev)
* level
*/
   writel(REG_RXINT_ROI_EN | REG_RXINT_RPEI_EN |
 -REG_RXINT_RAI_EN | REG_RXINT_RAL(TRIGGER_LEVEL - 1),
 +REG_RXINT_RAI_EN | REG_RXINT_RAL(ir-fifo_size / 2 - 1),
  ir-base + SUNXI_IR_RXINT_REG);
  
   /* Enable IR Module */
 @@ -319,6 +321,7 @@ static int sunxi_ir_remove(struct platform_device *pdev)
  
  static const struct of_device_id sunxi_ir_match[] = {
   { .compatible = allwinner,sun4i-a10-ir, },
 + { .compatible = allwinner,sun5i-a13-ir, },
   {},
  };
  

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

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

2014-04-30 Thread Mauro Carvalho Chehab
Em Tue, 29 Apr 2014 18:14:54 -0700
Maxime Ripard maxime.rip...@free-electrons.com escreveu:

 Hi,
 
 Thanks for contributing this patch.
 
 It seems like you're missing a few mailing lists / maintainers
 though. You should use the get_maintainer.pl script, and Cc every
 maintainer and mailing lists in there.
 
 On Tue, Apr 29, 2014 at 02:51:31PM -0700, Александр Берсенев wrote:
  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. 
 
 Your Signed-off-by should be here so that it stays in the commit log,
 and not discarded.
 
 Note that you can use git commit -s to make sure it's at the right
 place.
 
  --- 
  
  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 b...@hackerdom.ru 
  Signed-off-by: Alexsey Shestacov 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..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.
 
 We prefer to use allwinner,family-soc-device, with the soc and
 family being the one where it was first introduced. If this controller
 is the same in A10 and A20, it should be allwinner,sun4i-a10-ir, if
 it is a new controller in the A20, allwinner,sun7i-a20-ir.
 
  +   - clocks: First clock should contain SoC gate for IR clock.
  + Second should contain IR feed clock itself.
 
 Whenever there's several clocks, using clock-names is to be
 preferred. That way, you don't have to request any order, which is a
 lot less error prone.
 
  +   - 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;
 
 You don't seem to be using that gpios property anywhere.
 
 Plus, your indentation seems completely wrong. Please run
 checkpatch.pl on your patches before running it, and make sure there's
 no errors or warning.
 
  + 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;
 
 Same here.
 
  + 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;
 
 Please use lower-case for the address here.
 
  + status = disabled;
  + };
  +
  +   ir1: ir@01c21c00 {
  + compatible = allwinner,sunxi-ir;
  + clocks = apb0_gates 7, ir1_clk;
  + interrupts = 0 6 4;
  + reg = 0x01C21c00 0x40;
 
 ... or at least be consistent.
 
  + 

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

2014-04-30 Thread Mauro Carvalho Chehab
Em Wed, 30 Apr 2014 03:58:18 -0700 (PDT)
Александр Берсенев b...@hackerdom.ru escreveu:

 [PATCH v4 02/03] ARM: sunxi: Add driver for sunxi IR controller
 
 This patch adds driver for sunxi IR controller.
 It is based on Alexsey Shestacov's work based on the original driver 
 supplied by Allwinner.
 
 Signed-off-by: Alexander Bersenev b...@hackerdom.ru
 Signed-off-by: Alexsey Shestacov wingr...@linux-sunxi.org
 
 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..f051d94
 --- /dev/null
 +++ b/drivers/media/rc/sunxi-ir.c
 @@ -0,0 +1,303 @@
 +/*
 + * Driver for Allwinner sunXi IR controller
 + *
 + * Copyright (C) 2014 Alexsey Shestacov wingr...@linux-sunxi.org
 + * Copyright (C) 2014 Alexander Bersenev b...@hackerdom.ru
 + *
 + * 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/clk.h
 +#include linux/interrupt.h
 +#include linux/module.h
 +#include linux/of_platform.h
 +#include media/rc-core.h
 +
 +#define SUNXI_IR_DEV sunxi-ir
 +
 +/* Registers */
 +/* IR Control */
 +#define SUNXI_IR_CTL_REG  0x00
 +/* Rx Config */
 +#define SUNXI_IR_RXCTL_REG0x10
 +/* Rx Data */
 +#define SUNXI_IR_RXFIFO_REG   0x20
 +/* Rx Interrupt Enable */
 +#define SUNXI_IR_RXINT_REG0x2C
 +/* Rx Interrupt Status */
 +#define SUNXI_IR_RXSTA_REG0x30
 +/* IR Sample Config */
 +#define SUNXI_IR_CIR_REG  0x34
 +
 +/* Bit Definition of IR_RXINTS_REG Register */
 +#define SUNXI_IR_RXINTS_RXOF  BIT(0) /* Rx FIFO Overflow */
 +#define SUNXI_IR_RXINTS_RXPE  BIT(1) /* Rx Packet End */
 +#define SUNXI_IR_RXINTS_RXDA  BIT(4) /* Rx FIFO Data Available */
 +/* Hardware supported fifo size */
 +#define SUNXI_IR_FIFO_SIZE16
 +/* How much messages in fifo triggers IRQ */
 +#define SUNXI_IR_FIFO_TRIG8
 +/* Required frequency for IR0 or IR1 clock in CIR mode */
 +#define SUNXI_IR_BASE_CLK 800
 +/* Frequency after IR internal divider  */
 +#define SUNXI_IR_CLK  (SUNXI_IR_BASE_CLK / 64)
 +/* Sample period in ns */
 +#define SUNXI_IR_SAMPLE   (10ul / SUNXI_IR_CLK)
 +/* Filter threshold in samples  */
 +#define SUNXI_IR_RXFILT   1
 +/* Idle Threshold in samples */
 +#define SUNXI_IR_RXIDLE   20
 +/* Time after which device stops sending data in ms */
 +#define SUNXI_IR_TIMEOUT  120
 +
 +struct sunxi_ir {
 + spinlock_t  ir_lock;
 + struct rc_dev   *rc;
 + void __iomem*base;
 + int irq;
 + struct clk  *clk;
 + struct clk  *apb_clk;
 + const char  *map_name;
 +};

Still badly indented. Maybe your emailer is mangling whitespaces.

The best is to use git send-email to send the patches.

Also, please c/c linux-media ML for the entire patch series, as, in general,
we generally merge all patches via one tree (typically, the tree to where the
real driver will be merged - in this case, the media tree), after getting
the needed acks from DT and arm subarch maintainers (when applicable).

I'll do a better review after the whitespace fixups.

Regards,
Mauro

 +
 +static irqreturn_t sunxi_ir_irq(int irqno, void *dev_id)
 +{
 + unsigned long status;
 + unsigned char dt;
 + unsigned int cnt, rc;
 + struct sunxi_ir *ir = dev_id;
 + DEFINE_IR_RAW_EVENT(rawir);
 +
 + spin_lock_irq(ir-ir_lock);
 +
 + status = readl(ir-base + SUNXI_IR_RXSTA_REG);
 +
 + /* clean all pending statuses */
 + writel(status | 0xff, ir-base + SUNXI_IR_RXSTA_REG);
 +
 + if (status