linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/7] ir-rx51 driver fixes
@ 2016-05-07 15:21 Ivaylo Dimitrov
  2016-05-07 15:21 ` [PATCH 1/7] ir-rx51: Fix build after multiarch changes broke it Ivaylo Dimitrov
                   ` (7 more replies)
  0 siblings, 8 replies; 28+ messages in thread
From: Ivaylo Dimitrov @ 2016-05-07 15:21 UTC (permalink / raw)
  To: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	thierry.reding, bcousson, tony, linux, mchehab
  Cc: devicetree, linux-kernel, linux-pwm, linux-omap,
	linux-arm-kernel, linux-media, sre, pali.rohar, Ivaylo Dimitrov

ir-rx51 is a driver for Nokia N900 IR transmitter. The current series
fixes the remaining problems in the driver:

 - replace GP timer 9 with PWM framework usage
 - replace pulse width timer dmtimer usage with hrtimer
 - add DT support to the driver
 - add driver to the board DTS

Pathes 2 and 5 are needed so the driver to function correctly, without
those PWM either refuses to set the needed carrier frequency (patch 2)
or there are such a delays in the PWM framework, code that transmission
duration raises to ~5s instead of half a second.

Ivaylo Dimitrov (6):
  pwm: omap-dmtimer: Allow for setting dmtimer clock source
  [media] ir-rx51: use PWM framework instead of OMAP dmtimer
  [media] ir-rx51: add DT support to driver
  ARM: OMAP: dmtimer: Do not call PM runtime functions when not needed.
  [media] ir-rx51: use hrtimer instead of dmtimer
  ARM: dts: n900: enable lirc-rx51 driver

Tony Lindgren (1):
  ir-rx51: Fix build after multiarch changes broke it

 .../devicetree/bindings/media/nokia,lirc-rx51      |  19 ++
 .../devicetree/bindings/pwm/pwm-omap-dmtimer.txt   |   4 +
 arch/arm/boot/dts/omap3-n900.dts                   |  12 ++
 arch/arm/mach-omap2/board-rx51-peripherals.c       |   5 -
 arch/arm/mach-omap2/pdata-quirks.c                 |  10 +-
 arch/arm/plat-omap/dmtimer.c                       |   9 +-
 arch/arm/plat-omap/include/plat/dmtimer.h          |   1 +
 drivers/media/rc/Kconfig                           |   2 +-
 drivers/media/rc/ir-rx51.c                         | 229 +++++++--------------
 drivers/pwm/pwm-omap-dmtimer.c                     |  12 +-
 include/linux/platform_data/media/ir-rx51.h        |   3 -
 11 files changed, 131 insertions(+), 175 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/nokia,lirc-rx51

-- 
1.9.1

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 1/7] ir-rx51: Fix build after multiarch changes broke it
  2016-05-07 15:21 [PATCH 0/7] ir-rx51 driver fixes Ivaylo Dimitrov
@ 2016-05-07 15:21 ` Ivaylo Dimitrov
  2016-05-07 15:21 ` [PATCH 2/7] pwm: omap-dmtimer: Allow for setting dmtimer clock source Ivaylo Dimitrov
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 28+ messages in thread
From: Ivaylo Dimitrov @ 2016-05-07 15:21 UTC (permalink / raw)
  To: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	thierry.reding, bcousson, tony, linux, mchehab
  Cc: devicetree, linux-kernel, linux-pwm, linux-omap,
	linux-arm-kernel, linux-media, sre, pali.rohar, Neil Armstrong

From: Tony Lindgren <tony@atomide.com>

The ir-rx51 driver for n900 has been disabled since the multiarch
changes as plat include directory no longer is SoC specific.

Let's fix it with minimal changes to pass the dmtimer calls in
pdata. Then the following changes can be done while things can
be tested to be working for each change:

1. Change the non-pwm dmtimer to use just hrtimer if possible

2. Change the pwm dmtimer to use Linux PWM API with the new
   drivers/pwm/pwm-omap-dmtimer.c and remove the direct calls
   to dmtimer functions

3. Parse configuration from device tree and drop the pdata

Note compilation of this depends on the previous patch
"ARM: OMAP2+: Add more functions to pwm pdata for ir-rx51".

Cc: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Cc: Neil Armstrong <narmstrong@baylibre.com>
Cc: linux-media@vger.kernel.org
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 drivers/media/rc/Kconfig   |  2 +-
 drivers/media/rc/ir-rx51.c | 99 +++++++++++++++++++++++++---------------------
 2 files changed, 54 insertions(+), 47 deletions(-)

diff --git a/drivers/media/rc/Kconfig b/drivers/media/rc/Kconfig
index bd4d685..370e16e 100644
--- a/drivers/media/rc/Kconfig
+++ b/drivers/media/rc/Kconfig
@@ -336,7 +336,7 @@ config IR_TTUSBIR
 
 config IR_RX51
 	tristate "Nokia N900 IR transmitter diode"
-	depends on OMAP_DM_TIMER && ARCH_OMAP2PLUS && LIRC && !ARCH_MULTIPLATFORM
+	depends on OMAP_DM_TIMER && PWM_OMAP_DMTIMER && ARCH_OMAP2PLUS && LIRC
 	---help---
 	   Say Y or M here if you want to enable support for the IR
 	   transmitter diode built in the Nokia N900 (RX51) device.
diff --git a/drivers/media/rc/ir-rx51.c b/drivers/media/rc/ir-rx51.c
index 4e1711a..da839c3 100644
--- a/drivers/media/rc/ir-rx51.c
+++ b/drivers/media/rc/ir-rx51.c
@@ -19,6 +19,7 @@
  *
  */
 
+#include <linux/clk.h>
 #include <linux/module.h>
 #include <linux/interrupt.h>
 #include <linux/uaccess.h>
@@ -26,11 +27,9 @@
 #include <linux/sched.h>
 #include <linux/wait.h>
 
-#include <plat/dmtimer.h>
-#include <plat/clock.h>
-
 #include <media/lirc.h>
 #include <media/lirc_dev.h>
+#include <linux/platform_data/pwm_omap_dmtimer.h>
 #include <linux/platform_data/media/ir-rx51.h>
 
 #define LIRC_RX51_DRIVER_FEATURES (LIRC_CAN_SET_SEND_DUTY_CYCLE |	\
@@ -44,8 +43,9 @@
 #define TIMER_MAX_VALUE 0xffffffff
 
 struct lirc_rx51 {
-	struct omap_dm_timer *pwm_timer;
-	struct omap_dm_timer *pulse_timer;
+	pwm_omap_dmtimer *pwm_timer;
+	pwm_omap_dmtimer *pulse_timer;
+	struct pwm_omap_dmtimer_pdata *dmtimer;
 	struct device	     *dev;
 	struct lirc_rx51_platform_data *pdata;
 	wait_queue_head_t     wqueue;
@@ -63,14 +63,14 @@ struct lirc_rx51 {
 
 static void lirc_rx51_on(struct lirc_rx51 *lirc_rx51)
 {
-	omap_dm_timer_set_pwm(lirc_rx51->pwm_timer, 0, 1,
-			      OMAP_TIMER_TRIGGER_OVERFLOW_AND_COMPARE);
+	lirc_rx51->dmtimer->set_pwm(lirc_rx51->pwm_timer, 0, 1,
+				PWM_OMAP_DMTIMER_TRIGGER_OVERFLOW_AND_COMPARE);
 }
 
 static void lirc_rx51_off(struct lirc_rx51 *lirc_rx51)
 {
-	omap_dm_timer_set_pwm(lirc_rx51->pwm_timer, 0, 1,
-			      OMAP_TIMER_TRIGGER_NONE);
+	lirc_rx51->dmtimer->set_pwm(lirc_rx51->pwm_timer, 0, 1,
+				    PWM_OMAP_DMTIMER_TRIGGER_NONE);
 }
 
 static int init_timing_params(struct lirc_rx51 *lirc_rx51)
@@ -79,12 +79,12 @@ static int init_timing_params(struct lirc_rx51 *lirc_rx51)
 
 	load = -(lirc_rx51->fclk_khz * 1000 / lirc_rx51->freq);
 	match = -(lirc_rx51->duty_cycle * -load / 100);
-	omap_dm_timer_set_load(lirc_rx51->pwm_timer, 1, load);
-	omap_dm_timer_set_match(lirc_rx51->pwm_timer, 1, match);
-	omap_dm_timer_write_counter(lirc_rx51->pwm_timer, TIMER_MAX_VALUE - 2);
-	omap_dm_timer_start(lirc_rx51->pwm_timer);
-	omap_dm_timer_set_int_enable(lirc_rx51->pulse_timer, 0);
-	omap_dm_timer_start(lirc_rx51->pulse_timer);
+	lirc_rx51->dmtimer->set_load(lirc_rx51->pwm_timer, 1, load);
+	lirc_rx51->dmtimer->set_match(lirc_rx51->pwm_timer, 1, match);
+	lirc_rx51->dmtimer->write_counter(lirc_rx51->pwm_timer, TIMER_MAX_VALUE - 2);
+	lirc_rx51->dmtimer->start(lirc_rx51->pwm_timer);
+	lirc_rx51->dmtimer->set_int_enable(lirc_rx51->pulse_timer, 0);
+	lirc_rx51->dmtimer->start(lirc_rx51->pulse_timer);
 
 	lirc_rx51->match = 0;
 
@@ -100,15 +100,15 @@ static int pulse_timer_set_timeout(struct lirc_rx51 *lirc_rx51, int usec)
 	BUG_ON(usec < 0);
 
 	if (lirc_rx51->match == 0)
-		counter = omap_dm_timer_read_counter(lirc_rx51->pulse_timer);
+		counter = lirc_rx51->dmtimer->read_counter(lirc_rx51->pulse_timer);
 	else
 		counter = lirc_rx51->match;
 
 	counter += (u32)(lirc_rx51->fclk_khz * usec / (1000));
-	omap_dm_timer_set_match(lirc_rx51->pulse_timer, 1, counter);
-	omap_dm_timer_set_int_enable(lirc_rx51->pulse_timer,
-				     OMAP_TIMER_INT_MATCH);
-	if (tics_after(omap_dm_timer_read_counter(lirc_rx51->pulse_timer),
+	lirc_rx51->dmtimer->set_match(lirc_rx51->pulse_timer, 1, counter);
+	lirc_rx51->dmtimer->set_int_enable(lirc_rx51->pulse_timer,
+					   PWM_OMAP_DMTIMER_INT_MATCH);
+	if (tics_after(lirc_rx51->dmtimer->read_counter(lirc_rx51->pulse_timer),
 		       counter)) {
 		return 1;
 	}
@@ -120,18 +120,18 @@ static irqreturn_t lirc_rx51_interrupt_handler(int irq, void *ptr)
 	unsigned int retval;
 	struct lirc_rx51 *lirc_rx51 = ptr;
 
-	retval = omap_dm_timer_read_status(lirc_rx51->pulse_timer);
+	retval = lirc_rx51->dmtimer->read_status(lirc_rx51->pulse_timer);
 	if (!retval)
 		return IRQ_NONE;
 
-	if (retval & ~OMAP_TIMER_INT_MATCH)
+	if (retval & ~PWM_OMAP_DMTIMER_INT_MATCH)
 		dev_err_ratelimited(lirc_rx51->dev,
 				": Unexpected interrupt source: %x\n", retval);
 
-	omap_dm_timer_write_status(lirc_rx51->pulse_timer,
-				OMAP_TIMER_INT_MATCH	|
-				OMAP_TIMER_INT_OVERFLOW	|
-				OMAP_TIMER_INT_CAPTURE);
+	lirc_rx51->dmtimer->write_status(lirc_rx51->pulse_timer,
+					 PWM_OMAP_DMTIMER_INT_MATCH |
+					 PWM_OMAP_DMTIMER_INT_OVERFLOW |
+					 PWM_OMAP_DMTIMER_INT_CAPTURE);
 	if (lirc_rx51->wbuf_index < 0) {
 		dev_err_ratelimited(lirc_rx51->dev,
 				": BUG wbuf_index has value of %i\n",
@@ -165,9 +165,9 @@ end:
 	/* Stop TX here */
 	lirc_rx51_off(lirc_rx51);
 	lirc_rx51->wbuf_index = -1;
-	omap_dm_timer_stop(lirc_rx51->pwm_timer);
-	omap_dm_timer_stop(lirc_rx51->pulse_timer);
-	omap_dm_timer_set_int_enable(lirc_rx51->pulse_timer, 0);
+	lirc_rx51->dmtimer->stop(lirc_rx51->pwm_timer);
+	lirc_rx51->dmtimer->stop(lirc_rx51->pulse_timer);
+	lirc_rx51->dmtimer->set_int_enable(lirc_rx51->pulse_timer, 0);
 	wake_up_interruptible(&lirc_rx51->wqueue);
 
 	return IRQ_HANDLED;
@@ -178,28 +178,29 @@ static int lirc_rx51_init_port(struct lirc_rx51 *lirc_rx51)
 	struct clk *clk_fclk;
 	int retval, pwm_timer = lirc_rx51->pwm_timer_num;
 
-	lirc_rx51->pwm_timer = omap_dm_timer_request_specific(pwm_timer);
+	lirc_rx51->pwm_timer = lirc_rx51->dmtimer->request_specific(pwm_timer);
 	if (lirc_rx51->pwm_timer == NULL) {
 		dev_err(lirc_rx51->dev, ": Error requesting GPT%d timer\n",
 			pwm_timer);
 		return -EBUSY;
 	}
 
-	lirc_rx51->pulse_timer = omap_dm_timer_request();
+	lirc_rx51->pulse_timer = lirc_rx51->dmtimer->request();
 	if (lirc_rx51->pulse_timer == NULL) {
 		dev_err(lirc_rx51->dev, ": Error requesting pulse timer\n");
 		retval = -EBUSY;
 		goto err1;
 	}
 
-	omap_dm_timer_set_source(lirc_rx51->pwm_timer, OMAP_TIMER_SRC_SYS_CLK);
-	omap_dm_timer_set_source(lirc_rx51->pulse_timer,
-				OMAP_TIMER_SRC_SYS_CLK);
+	lirc_rx51->dmtimer->set_source(lirc_rx51->pwm_timer,
+				       PWM_OMAP_DMTIMER_SRC_SYS_CLK);
+	lirc_rx51->dmtimer->set_source(lirc_rx51->pulse_timer,
+				       PWM_OMAP_DMTIMER_SRC_SYS_CLK);
 
-	omap_dm_timer_enable(lirc_rx51->pwm_timer);
-	omap_dm_timer_enable(lirc_rx51->pulse_timer);
+	lirc_rx51->dmtimer->enable(lirc_rx51->pwm_timer);
+	lirc_rx51->dmtimer->enable(lirc_rx51->pulse_timer);
 
-	lirc_rx51->irq_num = omap_dm_timer_get_irq(lirc_rx51->pulse_timer);
+	lirc_rx51->irq_num = lirc_rx51->dmtimer->get_irq(lirc_rx51->pulse_timer);
 	retval = request_irq(lirc_rx51->irq_num, lirc_rx51_interrupt_handler,
 			     IRQF_SHARED, "lirc_pulse_timer", lirc_rx51);
 	if (retval) {
@@ -207,28 +208,28 @@ static int lirc_rx51_init_port(struct lirc_rx51 *lirc_rx51)
 		goto err2;
 	}
 
-	clk_fclk = omap_dm_timer_get_fclk(lirc_rx51->pwm_timer);
-	lirc_rx51->fclk_khz = clk_fclk->rate / 1000;
+	clk_fclk = lirc_rx51->dmtimer->get_fclk(lirc_rx51->pwm_timer);
+	lirc_rx51->fclk_khz = clk_get_rate(clk_fclk) / 1000;
 
 	return 0;
 
 err2:
-	omap_dm_timer_free(lirc_rx51->pulse_timer);
+	lirc_rx51->dmtimer->free(lirc_rx51->pulse_timer);
 err1:
-	omap_dm_timer_free(lirc_rx51->pwm_timer);
+	lirc_rx51->dmtimer->free(lirc_rx51->pwm_timer);
 
 	return retval;
 }
 
 static int lirc_rx51_free_port(struct lirc_rx51 *lirc_rx51)
 {
-	omap_dm_timer_set_int_enable(lirc_rx51->pulse_timer, 0);
+	lirc_rx51->dmtimer->set_int_enable(lirc_rx51->pulse_timer, 0);
 	free_irq(lirc_rx51->irq_num, lirc_rx51);
 	lirc_rx51_off(lirc_rx51);
-	omap_dm_timer_disable(lirc_rx51->pwm_timer);
-	omap_dm_timer_disable(lirc_rx51->pulse_timer);
-	omap_dm_timer_free(lirc_rx51->pwm_timer);
-	omap_dm_timer_free(lirc_rx51->pulse_timer);
+	lirc_rx51->dmtimer->disable(lirc_rx51->pwm_timer);
+	lirc_rx51->dmtimer->disable(lirc_rx51->pulse_timer);
+	lirc_rx51->dmtimer->free(lirc_rx51->pwm_timer);
+	lirc_rx51->dmtimer->free(lirc_rx51->pulse_timer);
 	lirc_rx51->wbuf_index = -1;
 
 	return 0;
@@ -446,7 +447,13 @@ static int lirc_rx51_probe(struct platform_device *dev)
 {
 	lirc_rx51_driver.features = LIRC_RX51_DRIVER_FEATURES;
 	lirc_rx51.pdata = dev->dev.platform_data;
+	if (!lirc_rx51.pdata->dmtimer) {
+		dev_err(&dev->dev, "no dmtimer?\n");
+		return -ENODEV;
+	}
+
 	lirc_rx51.pwm_timer_num = lirc_rx51.pdata->pwm_timer;
+	lirc_rx51.dmtimer = lirc_rx51.pdata->dmtimer;
 	lirc_rx51.dev = &dev->dev;
 	lirc_rx51_driver.dev = &dev->dev;
 	lirc_rx51_driver.minor = lirc_register_driver(&lirc_rx51_driver);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 2/7] pwm: omap-dmtimer: Allow for setting dmtimer clock source
  2016-05-07 15:21 [PATCH 0/7] ir-rx51 driver fixes Ivaylo Dimitrov
  2016-05-07 15:21 ` [PATCH 1/7] ir-rx51: Fix build after multiarch changes broke it Ivaylo Dimitrov
@ 2016-05-07 15:21 ` Ivaylo Dimitrov
  2016-05-09 20:01   ` Rob Herring
  2016-05-07 15:21 ` [PATCH 3/7] [media] ir-rx51: use PWM framework instead of OMAP dmtimer Ivaylo Dimitrov
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 28+ messages in thread
From: Ivaylo Dimitrov @ 2016-05-07 15:21 UTC (permalink / raw)
  To: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	thierry.reding, bcousson, tony, linux, mchehab
  Cc: devicetree, linux-kernel, linux-pwm, linux-omap,
	linux-arm-kernel, linux-media, sre, pali.rohar, Ivaylo Dimitrov

OMAP GP timers can have different input clocks that allow different PWM
frequencies. However, there is no other way of setting the clock source but
through clocks or clock-names properties of the timer itself. This limits
PWM functionality to only the frequencies allowed by the particular clock
source. Allowing setting the clock source by PWM rather than by timer
allows different PWMs to have different ranges by not hard-wiring the clock
source to the timer.

Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
---
 Documentation/devicetree/bindings/pwm/pwm-omap-dmtimer.txt |  4 ++++
 drivers/pwm/pwm-omap-dmtimer.c                             | 12 +++++++-----
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/Documentation/devicetree/bindings/pwm/pwm-omap-dmtimer.txt b/Documentation/devicetree/bindings/pwm/pwm-omap-dmtimer.txt
index 5befb53..2e53324 100644
--- a/Documentation/devicetree/bindings/pwm/pwm-omap-dmtimer.txt
+++ b/Documentation/devicetree/bindings/pwm/pwm-omap-dmtimer.txt
@@ -9,6 +9,10 @@ Required properties:
 
 Optional properties:
 - ti,prescaler: Should be a value between 0 and 7, see the timers datasheet
+- ti,clock-source: Set dmtimer parent clock, values between 0 and 2:
+  - 0x00 - high-frequency system clock (timer_sys_ck)
+  - 0x01 - 32-kHz always-on clock (timer_32k_ck)
+  - 0x02 - external clock (timer_ext_ck, OMAP2 only)
 
 Example:
 	pwm9: dmtimer-pwm@9 {
diff --git a/drivers/pwm/pwm-omap-dmtimer.c b/drivers/pwm/pwm-omap-dmtimer.c
index b7e6ecb..95964c6 100644
--- a/drivers/pwm/pwm-omap-dmtimer.c
+++ b/drivers/pwm/pwm-omap-dmtimer.c
@@ -245,7 +245,7 @@ static int pwm_omap_dmtimer_probe(struct platform_device *pdev)
 	struct pwm_omap_dmtimer_chip *omap;
 	struct pwm_omap_dmtimer_pdata *pdata;
 	pwm_omap_dmtimer *dm_timer;
-	u32 prescaler;
+	u32 v;
 	int status;
 
 	pdata = dev_get_platdata(&pdev->dev);
@@ -306,10 +306,12 @@ static int pwm_omap_dmtimer_probe(struct platform_device *pdev)
 	if (pm_runtime_active(&omap->dm_timer_pdev->dev))
 		omap->pdata->stop(omap->dm_timer);
 
-	/* setup dmtimer prescaler */
-	if (!of_property_read_u32(pdev->dev.of_node, "ti,prescaler",
-				&prescaler))
-		omap->pdata->set_prescaler(omap->dm_timer, prescaler);
+	if (!of_property_read_u32(pdev->dev.of_node, "ti,prescaler", &v))
+		omap->pdata->set_prescaler(omap->dm_timer, v);
+
+	/* setup dmtimer clock source */
+	if (!of_property_read_u32(pdev->dev.of_node, "ti,clock-source", &v))
+		omap->pdata->set_source(omap->dm_timer, v);
 
 	omap->chip.dev = &pdev->dev;
 	omap->chip.ops = &pwm_omap_dmtimer_ops;
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 3/7] [media] ir-rx51: use PWM framework instead of OMAP dmtimer
  2016-05-07 15:21 [PATCH 0/7] ir-rx51 driver fixes Ivaylo Dimitrov
  2016-05-07 15:21 ` [PATCH 1/7] ir-rx51: Fix build after multiarch changes broke it Ivaylo Dimitrov
  2016-05-07 15:21 ` [PATCH 2/7] pwm: omap-dmtimer: Allow for setting dmtimer clock source Ivaylo Dimitrov
@ 2016-05-07 15:21 ` Ivaylo Dimitrov
  2016-05-07 15:21 ` [PATCH 4/7] [media] ir-rx51: add DT support to driver Ivaylo Dimitrov
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 28+ messages in thread
From: Ivaylo Dimitrov @ 2016-05-07 15:21 UTC (permalink / raw)
  To: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	thierry.reding, bcousson, tony, linux, mchehab
  Cc: devicetree, linux-kernel, linux-pwm, linux-omap,
	linux-arm-kernel, linux-media, sre, pali.rohar, Ivaylo Dimitrov

Convert driver to use PWM framework instead of calling dmtimer functions
directly for PWM timer. Remove paragraph about writing to the Free Software
Foundation's mailing address while at it.

Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
---
 arch/arm/mach-omap2/board-rx51-peripherals.c |  1 -
 arch/arm/mach-omap2/pdata-quirks.c           |  1 -
 drivers/media/rc/ir-rx51.c                   | 85 ++++++++++++++--------------
 include/linux/platform_data/media/ir-rx51.h  |  2 -
 4 files changed, 44 insertions(+), 45 deletions(-)

diff --git a/arch/arm/mach-omap2/board-rx51-peripherals.c b/arch/arm/mach-omap2/board-rx51-peripherals.c
index 9a70739..e487575 100644
--- a/arch/arm/mach-omap2/board-rx51-peripherals.c
+++ b/arch/arm/mach-omap2/board-rx51-peripherals.c
@@ -1242,7 +1242,6 @@ static struct pwm_omap_dmtimer_pdata __maybe_unused pwm_dmtimer_pdata = {
 #if defined(CONFIG_IR_RX51) || defined(CONFIG_IR_RX51_MODULE)
 static struct lirc_rx51_platform_data rx51_lirc_data = {
 	.set_max_mpu_wakeup_lat = omap_pm_set_max_mpu_wakeup_lat,
-	.pwm_timer = 9, /* Use GPT 9 for CIR */
 #if IS_ENABLED(CONFIG_OMAP_DM_TIMER)
 	.dmtimer = &pwm_dmtimer_pdata,
 #endif
diff --git a/arch/arm/mach-omap2/pdata-quirks.c b/arch/arm/mach-omap2/pdata-quirks.c
index ea3a7d5..af65781 100644
--- a/arch/arm/mach-omap2/pdata-quirks.c
+++ b/arch/arm/mach-omap2/pdata-quirks.c
@@ -491,7 +491,6 @@ static struct pwm_omap_dmtimer_pdata pwm_dmtimer_pdata = {
 
 static struct lirc_rx51_platform_data __maybe_unused rx51_lirc_data = {
 	.set_max_mpu_wakeup_lat = omap_pm_set_max_mpu_wakeup_lat,
-	.pwm_timer = 9, /* Use GPT 9 for CIR */
 #if IS_ENABLED(CONFIG_OMAP_DM_TIMER)
 	.dmtimer = &pwm_dmtimer_pdata,
 #endif
diff --git a/drivers/media/rc/ir-rx51.c b/drivers/media/rc/ir-rx51.c
index da839c3..5096ef3 100644
--- a/drivers/media/rc/ir-rx51.c
+++ b/drivers/media/rc/ir-rx51.c
@@ -12,13 +12,7 @@
  *  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.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
  */
-
 #include <linux/clk.h>
 #include <linux/module.h>
 #include <linux/interrupt.h>
@@ -26,6 +20,7 @@
 #include <linux/platform_device.h>
 #include <linux/sched.h>
 #include <linux/wait.h>
+#include <linux/pwm.h>
 
 #include <media/lirc.h>
 #include <media/lirc_dev.h>
@@ -43,7 +38,7 @@
 #define TIMER_MAX_VALUE 0xffffffff
 
 struct lirc_rx51 {
-	pwm_omap_dmtimer *pwm_timer;
+	struct pwm_device *pwm;
 	pwm_omap_dmtimer *pulse_timer;
 	struct pwm_omap_dmtimer_pdata *dmtimer;
 	struct device	     *dev;
@@ -58,32 +53,28 @@ struct lirc_rx51 {
 	int		wbuf[WBUF_LEN];
 	int		wbuf_index;
 	unsigned long	device_is_open;
-	int		pwm_timer_num;
 };
 
 static void lirc_rx51_on(struct lirc_rx51 *lirc_rx51)
 {
-	lirc_rx51->dmtimer->set_pwm(lirc_rx51->pwm_timer, 0, 1,
-				PWM_OMAP_DMTIMER_TRIGGER_OVERFLOW_AND_COMPARE);
+	pwm_enable(lirc_rx51->pwm);
 }
 
 static void lirc_rx51_off(struct lirc_rx51 *lirc_rx51)
 {
-	lirc_rx51->dmtimer->set_pwm(lirc_rx51->pwm_timer, 0, 1,
-				    PWM_OMAP_DMTIMER_TRIGGER_NONE);
+	pwm_disable(lirc_rx51->pwm);
 }
 
 static int init_timing_params(struct lirc_rx51 *lirc_rx51)
 {
-	u32 load, match;
-
-	load = -(lirc_rx51->fclk_khz * 1000 / lirc_rx51->freq);
-	match = -(lirc_rx51->duty_cycle * -load / 100);
-	lirc_rx51->dmtimer->set_load(lirc_rx51->pwm_timer, 1, load);
-	lirc_rx51->dmtimer->set_match(lirc_rx51->pwm_timer, 1, match);
-	lirc_rx51->dmtimer->write_counter(lirc_rx51->pwm_timer, TIMER_MAX_VALUE - 2);
-	lirc_rx51->dmtimer->start(lirc_rx51->pwm_timer);
+	struct pwm_device *pwm = lirc_rx51->pwm;
+	int duty, period = DIV_ROUND_CLOSEST(NSEC_PER_SEC, lirc_rx51->freq);
+
+	duty = DIV_ROUND_CLOSEST(lirc_rx51->duty_cycle * period, 100);
 	lirc_rx51->dmtimer->set_int_enable(lirc_rx51->pulse_timer, 0);
+
+	pwm_config(pwm, duty, period);
+
 	lirc_rx51->dmtimer->start(lirc_rx51->pulse_timer);
 
 	lirc_rx51->match = 0;
@@ -165,7 +156,7 @@ end:
 	/* Stop TX here */
 	lirc_rx51_off(lirc_rx51);
 	lirc_rx51->wbuf_index = -1;
-	lirc_rx51->dmtimer->stop(lirc_rx51->pwm_timer);
+
 	lirc_rx51->dmtimer->stop(lirc_rx51->pulse_timer);
 	lirc_rx51->dmtimer->set_int_enable(lirc_rx51->pulse_timer, 0);
 	wake_up_interruptible(&lirc_rx51->wqueue);
@@ -176,13 +167,13 @@ end:
 static int lirc_rx51_init_port(struct lirc_rx51 *lirc_rx51)
 {
 	struct clk *clk_fclk;
-	int retval, pwm_timer = lirc_rx51->pwm_timer_num;
+	int retval;
 
-	lirc_rx51->pwm_timer = lirc_rx51->dmtimer->request_specific(pwm_timer);
-	if (lirc_rx51->pwm_timer == NULL) {
-		dev_err(lirc_rx51->dev, ": Error requesting GPT%d timer\n",
-			pwm_timer);
-		return -EBUSY;
+	lirc_rx51->pwm = pwm_get(lirc_rx51->dev, NULL);
+	if (IS_ERR(lirc_rx51->pwm)) {
+		retval = PTR_ERR(lirc_rx51->pwm);
+		dev_err(lirc_rx51->dev, ": pwm_get failed: %d\n", retval);
+		return retval;
 	}
 
 	lirc_rx51->pulse_timer = lirc_rx51->dmtimer->request();
@@ -192,15 +183,11 @@ static int lirc_rx51_init_port(struct lirc_rx51 *lirc_rx51)
 		goto err1;
 	}
 
-	lirc_rx51->dmtimer->set_source(lirc_rx51->pwm_timer,
-				       PWM_OMAP_DMTIMER_SRC_SYS_CLK);
 	lirc_rx51->dmtimer->set_source(lirc_rx51->pulse_timer,
 				       PWM_OMAP_DMTIMER_SRC_SYS_CLK);
-
-	lirc_rx51->dmtimer->enable(lirc_rx51->pwm_timer);
 	lirc_rx51->dmtimer->enable(lirc_rx51->pulse_timer);
-
-	lirc_rx51->irq_num = lirc_rx51->dmtimer->get_irq(lirc_rx51->pulse_timer);
+	lirc_rx51->irq_num =
+			lirc_rx51->dmtimer->get_irq(lirc_rx51->pulse_timer);
 	retval = request_irq(lirc_rx51->irq_num, lirc_rx51_interrupt_handler,
 			     IRQF_SHARED, "lirc_pulse_timer", lirc_rx51);
 	if (retval) {
@@ -208,7 +195,7 @@ static int lirc_rx51_init_port(struct lirc_rx51 *lirc_rx51)
 		goto err2;
 	}
 
-	clk_fclk = lirc_rx51->dmtimer->get_fclk(lirc_rx51->pwm_timer);
+	clk_fclk = lirc_rx51->dmtimer->get_fclk(lirc_rx51->pulse_timer);
 	lirc_rx51->fclk_khz = clk_get_rate(clk_fclk) / 1000;
 
 	return 0;
@@ -216,7 +203,7 @@ static int lirc_rx51_init_port(struct lirc_rx51 *lirc_rx51)
 err2:
 	lirc_rx51->dmtimer->free(lirc_rx51->pulse_timer);
 err1:
-	lirc_rx51->dmtimer->free(lirc_rx51->pwm_timer);
+	pwm_put(lirc_rx51->pwm);
 
 	return retval;
 }
@@ -226,11 +213,10 @@ static int lirc_rx51_free_port(struct lirc_rx51 *lirc_rx51)
 	lirc_rx51->dmtimer->set_int_enable(lirc_rx51->pulse_timer, 0);
 	free_irq(lirc_rx51->irq_num, lirc_rx51);
 	lirc_rx51_off(lirc_rx51);
-	lirc_rx51->dmtimer->disable(lirc_rx51->pwm_timer);
 	lirc_rx51->dmtimer->disable(lirc_rx51->pulse_timer);
-	lirc_rx51->dmtimer->free(lirc_rx51->pwm_timer);
 	lirc_rx51->dmtimer->free(lirc_rx51->pulse_timer);
 	lirc_rx51->wbuf_index = -1;
+	pwm_put(lirc_rx51->pwm);
 
 	return 0;
 }
@@ -387,7 +373,6 @@ static int lirc_rx51_release(struct inode *inode, struct file *file)
 }
 
 static struct lirc_rx51 lirc_rx51 = {
-	.freq		= 38000,
 	.duty_cycle	= 50,
 	.wbuf_index	= -1,
 };
@@ -445,14 +430,34 @@ static int lirc_rx51_resume(struct platform_device *dev)
 
 static int lirc_rx51_probe(struct platform_device *dev)
 {
+	struct pwm_device *pwm;
+
 	lirc_rx51_driver.features = LIRC_RX51_DRIVER_FEATURES;
 	lirc_rx51.pdata = dev->dev.platform_data;
+
+	if (!lirc_rx51.pdata) {
+		dev_err(&dev->dev, "Platform Data is missing\n");
+		return -ENXIO;
+	}
+
 	if (!lirc_rx51.pdata->dmtimer) {
 		dev_err(&dev->dev, "no dmtimer?\n");
 		return -ENODEV;
 	}
 
-	lirc_rx51.pwm_timer_num = lirc_rx51.pdata->pwm_timer;
+	pwm = pwm_get(&dev->dev, NULL);
+	if (IS_ERR(pwm)) {
+		int err = PTR_ERR(pwm);
+
+		if (err != -EPROBE_DEFER)
+			dev_err(&dev->dev, "pwm_get failed: %d\n", err);
+		return err;
+	}
+
+	/* Use default, in case userspace does not set the carrier */
+	lirc_rx51.freq = DIV_ROUND_CLOSEST(pwm_get_period(pwm), NSEC_PER_SEC);
+	pwm_put(pwm);
+
 	lirc_rx51.dmtimer = lirc_rx51.pdata->dmtimer;
 	lirc_rx51.dev = &dev->dev;
 	lirc_rx51_driver.dev = &dev->dev;
@@ -464,8 +469,6 @@ static int lirc_rx51_probe(struct platform_device *dev)
 		       lirc_rx51_driver.minor);
 		return lirc_rx51_driver.minor;
 	}
-	dev_info(lirc_rx51.dev, "registration ok, minor: %d, pwm: %d\n",
-		 lirc_rx51_driver.minor, lirc_rx51.pwm_timer_num);
 
 	return 0;
 }
diff --git a/include/linux/platform_data/media/ir-rx51.h b/include/linux/platform_data/media/ir-rx51.h
index 3038120..6acf22d 100644
--- a/include/linux/platform_data/media/ir-rx51.h
+++ b/include/linux/platform_data/media/ir-rx51.h
@@ -2,8 +2,6 @@
 #define _LIRC_RX51_H
 
 struct lirc_rx51_platform_data {
-	int pwm_timer;
-
 	int(*set_max_mpu_wakeup_lat)(struct device *dev, long t);
 	struct pwm_omap_dmtimer_pdata *dmtimer;
 };
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 4/7] [media] ir-rx51: add DT support to driver
  2016-05-07 15:21 [PATCH 0/7] ir-rx51 driver fixes Ivaylo Dimitrov
                   ` (2 preceding siblings ...)
  2016-05-07 15:21 ` [PATCH 3/7] [media] ir-rx51: use PWM framework instead of OMAP dmtimer Ivaylo Dimitrov
@ 2016-05-07 15:21 ` Ivaylo Dimitrov
  2016-05-09 20:06   ` Rob Herring
  2016-05-07 15:21 ` [PATCH 5/7] ARM: OMAP: dmtimer: Do not call PM runtime functions when not needed Ivaylo Dimitrov
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 28+ messages in thread
From: Ivaylo Dimitrov @ 2016-05-07 15:21 UTC (permalink / raw)
  To: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	thierry.reding, bcousson, tony, linux, mchehab
  Cc: devicetree, linux-kernel, linux-pwm, linux-omap,
	linux-arm-kernel, linux-media, sre, pali.rohar, Ivaylo Dimitrov

With the upcoming removal of legacy boot, lets add support to one of the
last N900 drivers remaining without it. As the driver still uses omap
dmtimer, add auxdata as well.

Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
---
 .../devicetree/bindings/media/nokia,lirc-rx51         | 19 +++++++++++++++++++
 arch/arm/mach-omap2/pdata-quirks.c                    |  6 +-----
 drivers/media/rc/ir-rx51.c                            | 11 ++++++++++-
 3 files changed, 30 insertions(+), 6 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/nokia,lirc-rx51

diff --git a/Documentation/devicetree/bindings/media/nokia,lirc-rx51 b/Documentation/devicetree/bindings/media/nokia,lirc-rx51
new file mode 100644
index 0000000..5b3081e
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/nokia,lirc-rx51
@@ -0,0 +1,19 @@
+Device-Tree bindings for LIRC TX driver for Nokia N900(RX51)
+
+Required properties:
+	- compatible: should be "nokia,lirc-rx51".
+	- pwms: specifies PWM used for IR signal transmission.
+
+Example node:
+
+	pwm9: dmtimer-pwm@9 {
+		compatible = "ti,omap-dmtimer-pwm";
+		ti,timers = <&timer9>;
+		#pwm-cells = <3>;
+	};
+
+	ir: lirc-rx51 {
+		compatible = "nokia,lirc-rx51";
+
+		pwms = <&pwm9 0 26316 0>; /* 38000 Hz */
+	};
diff --git a/arch/arm/mach-omap2/pdata-quirks.c b/arch/arm/mach-omap2/pdata-quirks.c
index af65781..c15ccac 100644
--- a/arch/arm/mach-omap2/pdata-quirks.c
+++ b/arch/arm/mach-omap2/pdata-quirks.c
@@ -273,8 +273,6 @@ static struct platform_device omap3_rom_rng_device = {
 	},
 };
 
-static struct platform_device rx51_lirc_device;
-
 static void __init nokia_n900_legacy_init(void)
 {
 	hsmmc2_internal_input_clk();
@@ -293,10 +291,7 @@ static void __init nokia_n900_legacy_init(void)
 
 		pr_info("RX-51: Registering OMAP3 HWRNG device\n");
 		platform_device_register(&omap3_rom_rng_device);
-
 	}
-
-	platform_device_register(&rx51_lirc_device);
 }
 
 static void __init omap3_tao3530_legacy_init(void)
@@ -534,6 +529,7 @@ static struct of_dev_auxdata omap_auxdata_lookup[] __initdata = {
 		       &omap3_iommu_pdata),
 	OF_DEV_AUXDATA("ti,omap3-hsmmc", 0x4809c000, "4809c000.mmc", &mmc_pdata[0]),
 	OF_DEV_AUXDATA("ti,omap3-hsmmc", 0x480b4000, "480b4000.mmc", &mmc_pdata[1]),
+	OF_DEV_AUXDATA("nokia,lirc-rx51", 0, "lirc-rx51", &rx51_lirc_data),
 	/* Only on am3517 */
 	OF_DEV_AUXDATA("ti,davinci_mdio", 0x5c030000, "davinci_mdio.0", NULL),
 	OF_DEV_AUXDATA("ti,am3517-emac", 0x5c000000, "davinci_emac.0",
diff --git a/drivers/media/rc/ir-rx51.c b/drivers/media/rc/ir-rx51.c
index 5096ef3..7a329d8 100644
--- a/drivers/media/rc/ir-rx51.c
+++ b/drivers/media/rc/ir-rx51.c
@@ -21,6 +21,7 @@
 #include <linux/sched.h>
 #include <linux/wait.h>
 #include <linux/pwm.h>
+#include <linux/of.h>
 
 #include <media/lirc.h>
 #include <media/lirc_dev.h>
@@ -478,6 +479,14 @@ static int lirc_rx51_remove(struct platform_device *dev)
 	return lirc_unregister_driver(lirc_rx51_driver.minor);
 }
 
+static const struct of_device_id lirc_rx51_match[] = {
+	{
+		.compatible = "nokia,lirc-rx51",
+	},
+	{},
+};
+MODULE_DEVICE_TABLE(of, lirc_rx51_match);
+
 struct platform_driver lirc_rx51_platform_driver = {
 	.probe		= lirc_rx51_probe,
 	.remove		= lirc_rx51_remove,
@@ -485,7 +494,7 @@ struct platform_driver lirc_rx51_platform_driver = {
 	.resume		= lirc_rx51_resume,
 	.driver		= {
 		.name	= DRIVER_NAME,
-		.owner	= THIS_MODULE,
+		.of_match_table = of_match_ptr(lirc_rx51_match),
 	},
 };
 module_platform_driver(lirc_rx51_platform_driver);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 5/7] ARM: OMAP: dmtimer: Do not call PM runtime functions when not needed.
  2016-05-07 15:21 [PATCH 0/7] ir-rx51 driver fixes Ivaylo Dimitrov
                   ` (3 preceding siblings ...)
  2016-05-07 15:21 ` [PATCH 4/7] [media] ir-rx51: add DT support to driver Ivaylo Dimitrov
@ 2016-05-07 15:21 ` Ivaylo Dimitrov
  2016-05-09 19:36   ` Tony Lindgren
  2016-05-07 15:21 ` [PATCH 6/7] [media] ir-rx51: use hrtimer instead of dmtimer Ivaylo Dimitrov
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 28+ messages in thread
From: Ivaylo Dimitrov @ 2016-05-07 15:21 UTC (permalink / raw)
  To: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	thierry.reding, bcousson, tony, linux, mchehab
  Cc: devicetree, linux-kernel, linux-pwm, linux-omap,
	linux-arm-kernel, linux-media, sre, pali.rohar, Ivaylo Dimitrov

once omap_dm_timer_start() is called, which calls omap_dm_timer_enable()
and thus pm_runtime_get_sync(), it doesn't make sense to call PM runtime
functions again before omap_dm_timer_stop is called(). Otherwise PM runtime
functions called in omap_dm_timer_enable/disable lead to long and unneeded
delays.

Fix that by implementing an "enabled" counter, so the PM runtime functions
get called only when really needed.

Without that patch Nokia N900 IR TX driver (ir-rx51) does not function.

Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
---
 arch/arm/plat-omap/dmtimer.c              | 9 ++++++++-
 arch/arm/plat-omap/include/plat/dmtimer.h | 1 +
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c
index 7a327bd..f35a78c 100644
--- a/arch/arm/plat-omap/dmtimer.c
+++ b/arch/arm/plat-omap/dmtimer.c
@@ -365,6 +365,9 @@ void omap_dm_timer_enable(struct omap_dm_timer *timer)
 {
 	int c;
 
+	if (timer->enabled++)
+		return;
+
 	pm_runtime_get_sync(&timer->pdev->dev);
 
 	if (!(timer->capability & OMAP_TIMER_ALWON)) {
@@ -383,7 +386,11 @@ EXPORT_SYMBOL_GPL(omap_dm_timer_enable);
 
 void omap_dm_timer_disable(struct omap_dm_timer *timer)
 {
-	pm_runtime_put_sync(&timer->pdev->dev);
+	if (timer->enabled == 1)
+		pm_runtime_put_sync(&timer->pdev->dev);
+
+	if (timer->enabled)
+		timer->enabled--;
 }
 EXPORT_SYMBOL_GPL(omap_dm_timer_disable);
 
diff --git a/arch/arm/plat-omap/include/plat/dmtimer.h b/arch/arm/plat-omap/include/plat/dmtimer.h
index dd79f30..fc984e1 100644
--- a/arch/arm/plat-omap/include/plat/dmtimer.h
+++ b/arch/arm/plat-omap/include/plat/dmtimer.h
@@ -114,6 +114,7 @@ struct omap_dm_timer {
 	unsigned long rate;
 	unsigned reserved:1;
 	unsigned posted:1;
+	u32 enabled;
 	struct timer_regs context;
 	int (*get_context_loss_count)(struct device *);
 	int ctx_loss_count;
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 6/7] [media] ir-rx51: use hrtimer instead of dmtimer
  2016-05-07 15:21 [PATCH 0/7] ir-rx51 driver fixes Ivaylo Dimitrov
                   ` (4 preceding siblings ...)
  2016-05-07 15:21 ` [PATCH 5/7] ARM: OMAP: dmtimer: Do not call PM runtime functions when not needed Ivaylo Dimitrov
@ 2016-05-07 15:21 ` Ivaylo Dimitrov
  2016-05-07 15:21 ` [PATCH 7/7] ARM: dts: n900: enable lirc-rx51 driver Ivaylo Dimitrov
  2016-06-13 18:17 ` [PATCH 0/7] ir-rx51 driver fixes Pali Rohár
  7 siblings, 0 replies; 28+ messages in thread
From: Ivaylo Dimitrov @ 2016-05-07 15:21 UTC (permalink / raw)
  To: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	thierry.reding, bcousson, tony, linux, mchehab
  Cc: devicetree, linux-kernel, linux-pwm, linux-omap,
	linux-arm-kernel, linux-media, sre, pali.rohar, Ivaylo Dimitrov

Drop dmtimer usage for pulse timer in favor of hrtimer. That allows
removing PWM dmitimer platform data usage.

Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
---
 arch/arm/mach-omap2/board-rx51-peripherals.c |   4 -
 arch/arm/mach-omap2/pdata-quirks.c           |   3 -
 drivers/media/rc/ir-rx51.c                   | 166 ++++++---------------------
 include/linux/platform_data/media/ir-rx51.h  |   1 -
 4 files changed, 37 insertions(+), 137 deletions(-)

diff --git a/arch/arm/mach-omap2/board-rx51-peripherals.c b/arch/arm/mach-omap2/board-rx51-peripherals.c
index e487575..a5ab712 100644
--- a/arch/arm/mach-omap2/board-rx51-peripherals.c
+++ b/arch/arm/mach-omap2/board-rx51-peripherals.c
@@ -1242,10 +1242,6 @@ static struct pwm_omap_dmtimer_pdata __maybe_unused pwm_dmtimer_pdata = {
 #if defined(CONFIG_IR_RX51) || defined(CONFIG_IR_RX51_MODULE)
 static struct lirc_rx51_platform_data rx51_lirc_data = {
 	.set_max_mpu_wakeup_lat = omap_pm_set_max_mpu_wakeup_lat,
-#if IS_ENABLED(CONFIG_OMAP_DM_TIMER)
-	.dmtimer = &pwm_dmtimer_pdata,
-#endif
-
 };
 
 static struct platform_device rx51_lirc_device = {
diff --git a/arch/arm/mach-omap2/pdata-quirks.c b/arch/arm/mach-omap2/pdata-quirks.c
index c15ccac..8936ffc 100644
--- a/arch/arm/mach-omap2/pdata-quirks.c
+++ b/arch/arm/mach-omap2/pdata-quirks.c
@@ -486,9 +486,6 @@ static struct pwm_omap_dmtimer_pdata pwm_dmtimer_pdata = {
 
 static struct lirc_rx51_platform_data __maybe_unused rx51_lirc_data = {
 	.set_max_mpu_wakeup_lat = omap_pm_set_max_mpu_wakeup_lat,
-#if IS_ENABLED(CONFIG_OMAP_DM_TIMER)
-	.dmtimer = &pwm_dmtimer_pdata,
-#endif
 };
 
 static struct platform_device __maybe_unused rx51_lirc_device = {
diff --git a/drivers/media/rc/ir-rx51.c b/drivers/media/rc/ir-rx51.c
index 7a329d8..9dbe0a4 100644
--- a/drivers/media/rc/ir-rx51.c
+++ b/drivers/media/rc/ir-rx51.c
@@ -22,10 +22,10 @@
 #include <linux/wait.h>
 #include <linux/pwm.h>
 #include <linux/of.h>
+#include <linux/hrtimer.h>
 
 #include <media/lirc.h>
 #include <media/lirc_dev.h>
-#include <linux/platform_data/pwm_omap_dmtimer.h>
 #include <linux/platform_data/media/ir-rx51.h>
 
 #define LIRC_RX51_DRIVER_FEATURES (LIRC_CAN_SET_SEND_DUTY_CYCLE |	\
@@ -36,32 +36,26 @@
 
 #define WBUF_LEN 256
 
-#define TIMER_MAX_VALUE 0xffffffff
-
 struct lirc_rx51 {
 	struct pwm_device *pwm;
-	pwm_omap_dmtimer *pulse_timer;
-	struct pwm_omap_dmtimer_pdata *dmtimer;
+	struct hrtimer timer;
 	struct device	     *dev;
 	struct lirc_rx51_platform_data *pdata;
 	wait_queue_head_t     wqueue;
 
-	unsigned long	fclk_khz;
 	unsigned int	freq;		/* carrier frequency */
 	unsigned int	duty_cycle;	/* carrier duty cycle */
-	unsigned int	irq_num;
-	unsigned int	match;
 	int		wbuf[WBUF_LEN];
 	int		wbuf_index;
 	unsigned long	device_is_open;
 };
 
-static void lirc_rx51_on(struct lirc_rx51 *lirc_rx51)
+static inline void lirc_rx51_on(struct lirc_rx51 *lirc_rx51)
 {
 	pwm_enable(lirc_rx51->pwm);
 }
 
-static void lirc_rx51_off(struct lirc_rx51 *lirc_rx51)
+static inline void lirc_rx51_off(struct lirc_rx51 *lirc_rx51)
 {
 	pwm_disable(lirc_rx51->pwm);
 }
@@ -72,61 +66,21 @@ static int init_timing_params(struct lirc_rx51 *lirc_rx51)
 	int duty, period = DIV_ROUND_CLOSEST(NSEC_PER_SEC, lirc_rx51->freq);
 
 	duty = DIV_ROUND_CLOSEST(lirc_rx51->duty_cycle * period, 100);
-	lirc_rx51->dmtimer->set_int_enable(lirc_rx51->pulse_timer, 0);
 
 	pwm_config(pwm, duty, period);
 
-	lirc_rx51->dmtimer->start(lirc_rx51->pulse_timer);
-
-	lirc_rx51->match = 0;
-
 	return 0;
 }
 
-#define tics_after(a, b) ((long)(b) - (long)(a) < 0)
-
-static int pulse_timer_set_timeout(struct lirc_rx51 *lirc_rx51, int usec)
+static enum hrtimer_restart lirc_rx51_timer_cb(struct hrtimer *timer)
 {
-	int counter;
-
-	BUG_ON(usec < 0);
-
-	if (lirc_rx51->match == 0)
-		counter = lirc_rx51->dmtimer->read_counter(lirc_rx51->pulse_timer);
-	else
-		counter = lirc_rx51->match;
-
-	counter += (u32)(lirc_rx51->fclk_khz * usec / (1000));
-	lirc_rx51->dmtimer->set_match(lirc_rx51->pulse_timer, 1, counter);
-	lirc_rx51->dmtimer->set_int_enable(lirc_rx51->pulse_timer,
-					   PWM_OMAP_DMTIMER_INT_MATCH);
-	if (tics_after(lirc_rx51->dmtimer->read_counter(lirc_rx51->pulse_timer),
-		       counter)) {
-		return 1;
-	}
-	return 0;
-}
+	struct lirc_rx51 *lirc_rx51 =
+			container_of(timer, struct lirc_rx51, timer);
+	ktime_t now;
 
-static irqreturn_t lirc_rx51_interrupt_handler(int irq, void *ptr)
-{
-	unsigned int retval;
-	struct lirc_rx51 *lirc_rx51 = ptr;
-
-	retval = lirc_rx51->dmtimer->read_status(lirc_rx51->pulse_timer);
-	if (!retval)
-		return IRQ_NONE;
-
-	if (retval & ~PWM_OMAP_DMTIMER_INT_MATCH)
-		dev_err_ratelimited(lirc_rx51->dev,
-				": Unexpected interrupt source: %x\n", retval);
-
-	lirc_rx51->dmtimer->write_status(lirc_rx51->pulse_timer,
-					 PWM_OMAP_DMTIMER_INT_MATCH |
-					 PWM_OMAP_DMTIMER_INT_OVERFLOW |
-					 PWM_OMAP_DMTIMER_INT_CAPTURE);
 	if (lirc_rx51->wbuf_index < 0) {
 		dev_err_ratelimited(lirc_rx51->dev,
-				": BUG wbuf_index has value of %i\n",
+				"BUG wbuf_index has value of %i\n",
 				lirc_rx51->wbuf_index);
 		goto end;
 	}
@@ -136,6 +90,8 @@ static irqreturn_t lirc_rx51_interrupt_handler(int irq, void *ptr)
 	 * pulses until we catch up.
 	 */
 	do {
+		u64 ns;
+
 		if (lirc_rx51->wbuf_index >= WBUF_LEN)
 			goto end;
 		if (lirc_rx51->wbuf[lirc_rx51->wbuf_index] == -1)
@@ -146,80 +102,24 @@ static irqreturn_t lirc_rx51_interrupt_handler(int irq, void *ptr)
 		else
 			lirc_rx51_on(lirc_rx51);
 
-		retval = pulse_timer_set_timeout(lirc_rx51,
-					lirc_rx51->wbuf[lirc_rx51->wbuf_index]);
+		ns = 1000 * lirc_rx51->wbuf[lirc_rx51->wbuf_index];
+		hrtimer_add_expires_ns(timer, ns);
+
 		lirc_rx51->wbuf_index++;
 
-	} while (retval);
+		now = timer->base->get_time();
+
+	} while (hrtimer_get_expires_tv64(timer) < now.tv64);
 
-	return IRQ_HANDLED;
+	return HRTIMER_RESTART;
 end:
 	/* Stop TX here */
 	lirc_rx51_off(lirc_rx51);
 	lirc_rx51->wbuf_index = -1;
 
-	lirc_rx51->dmtimer->stop(lirc_rx51->pulse_timer);
-	lirc_rx51->dmtimer->set_int_enable(lirc_rx51->pulse_timer, 0);
 	wake_up_interruptible(&lirc_rx51->wqueue);
 
-	return IRQ_HANDLED;
-}
-
-static int lirc_rx51_init_port(struct lirc_rx51 *lirc_rx51)
-{
-	struct clk *clk_fclk;
-	int retval;
-
-	lirc_rx51->pwm = pwm_get(lirc_rx51->dev, NULL);
-	if (IS_ERR(lirc_rx51->pwm)) {
-		retval = PTR_ERR(lirc_rx51->pwm);
-		dev_err(lirc_rx51->dev, ": pwm_get failed: %d\n", retval);
-		return retval;
-	}
-
-	lirc_rx51->pulse_timer = lirc_rx51->dmtimer->request();
-	if (lirc_rx51->pulse_timer == NULL) {
-		dev_err(lirc_rx51->dev, ": Error requesting pulse timer\n");
-		retval = -EBUSY;
-		goto err1;
-	}
-
-	lirc_rx51->dmtimer->set_source(lirc_rx51->pulse_timer,
-				       PWM_OMAP_DMTIMER_SRC_SYS_CLK);
-	lirc_rx51->dmtimer->enable(lirc_rx51->pulse_timer);
-	lirc_rx51->irq_num =
-			lirc_rx51->dmtimer->get_irq(lirc_rx51->pulse_timer);
-	retval = request_irq(lirc_rx51->irq_num, lirc_rx51_interrupt_handler,
-			     IRQF_SHARED, "lirc_pulse_timer", lirc_rx51);
-	if (retval) {
-		dev_err(lirc_rx51->dev, ": Failed to request interrupt line\n");
-		goto err2;
-	}
-
-	clk_fclk = lirc_rx51->dmtimer->get_fclk(lirc_rx51->pulse_timer);
-	lirc_rx51->fclk_khz = clk_get_rate(clk_fclk) / 1000;
-
-	return 0;
-
-err2:
-	lirc_rx51->dmtimer->free(lirc_rx51->pulse_timer);
-err1:
-	pwm_put(lirc_rx51->pwm);
-
-	return retval;
-}
-
-static int lirc_rx51_free_port(struct lirc_rx51 *lirc_rx51)
-{
-	lirc_rx51->dmtimer->set_int_enable(lirc_rx51->pulse_timer, 0);
-	free_irq(lirc_rx51->irq_num, lirc_rx51);
-	lirc_rx51_off(lirc_rx51);
-	lirc_rx51->dmtimer->disable(lirc_rx51->pulse_timer);
-	lirc_rx51->dmtimer->free(lirc_rx51->pulse_timer);
-	lirc_rx51->wbuf_index = -1;
-	pwm_put(lirc_rx51->pwm);
-
-	return 0;
+	return HRTIMER_NORESTART;
 }
 
 static ssize_t lirc_rx51_write(struct file *file, const char *buf,
@@ -258,8 +158,9 @@ static ssize_t lirc_rx51_write(struct file *file, const char *buf,
 
 	lirc_rx51_on(lirc_rx51);
 	lirc_rx51->wbuf_index = 1;
-	pulse_timer_set_timeout(lirc_rx51, lirc_rx51->wbuf[0]);
-
+	hrtimer_start(&lirc_rx51->timer,
+		      ns_to_ktime(1000 * lirc_rx51->wbuf[0]),
+		      HRTIMER_MODE_REL);
 	/*
 	 * Don't return back to the userspace until the transfer has
 	 * finished
@@ -359,14 +260,24 @@ static int lirc_rx51_open(struct inode *inode, struct file *file)
 	if (test_and_set_bit(1, &lirc_rx51->device_is_open))
 		return -EBUSY;
 
-	return lirc_rx51_init_port(lirc_rx51);
+	lirc_rx51->pwm = pwm_get(lirc_rx51->dev, NULL);
+	if (IS_ERR(lirc_rx51->pwm)) {
+		int res = PTR_ERR(lirc_rx51->pwm);
+
+		dev_err(lirc_rx51->dev, "pwm_get failed: %d\n", res);
+		return res;
+	}
+
+	return 0;
 }
 
 static int lirc_rx51_release(struct inode *inode, struct file *file)
 {
 	struct lirc_rx51 *lirc_rx51 = file->private_data;
 
-	lirc_rx51_free_port(lirc_rx51);
+	hrtimer_cancel(&lirc_rx51->timer);
+	lirc_rx51_off(lirc_rx51);
+	pwm_put(lirc_rx51->pwm);
 
 	clear_bit(1, &lirc_rx51->device_is_open);
 
@@ -441,11 +352,6 @@ static int lirc_rx51_probe(struct platform_device *dev)
 		return -ENXIO;
 	}
 
-	if (!lirc_rx51.pdata->dmtimer) {
-		dev_err(&dev->dev, "no dmtimer?\n");
-		return -ENODEV;
-	}
-
 	pwm = pwm_get(&dev->dev, NULL);
 	if (IS_ERR(pwm)) {
 		int err = PTR_ERR(pwm);
@@ -459,7 +365,9 @@ static int lirc_rx51_probe(struct platform_device *dev)
 	lirc_rx51.freq = DIV_ROUND_CLOSEST(pwm_get_period(pwm), NSEC_PER_SEC);
 	pwm_put(pwm);
 
-	lirc_rx51.dmtimer = lirc_rx51.pdata->dmtimer;
+	hrtimer_init(&lirc_rx51.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+	lirc_rx51.timer.function = lirc_rx51_timer_cb;
+
 	lirc_rx51.dev = &dev->dev;
 	lirc_rx51_driver.dev = &dev->dev;
 	lirc_rx51_driver.minor = lirc_register_driver(&lirc_rx51_driver);
diff --git a/include/linux/platform_data/media/ir-rx51.h b/include/linux/platform_data/media/ir-rx51.h
index 6acf22d..812d873 100644
--- a/include/linux/platform_data/media/ir-rx51.h
+++ b/include/linux/platform_data/media/ir-rx51.h
@@ -3,7 +3,6 @@
 
 struct lirc_rx51_platform_data {
 	int(*set_max_mpu_wakeup_lat)(struct device *dev, long t);
-	struct pwm_omap_dmtimer_pdata *dmtimer;
 };
 
 #endif
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 7/7] ARM: dts: n900: enable lirc-rx51 driver
  2016-05-07 15:21 [PATCH 0/7] ir-rx51 driver fixes Ivaylo Dimitrov
                   ` (5 preceding siblings ...)
  2016-05-07 15:21 ` [PATCH 6/7] [media] ir-rx51: use hrtimer instead of dmtimer Ivaylo Dimitrov
@ 2016-05-07 15:21 ` Ivaylo Dimitrov
  2016-06-10 10:20   ` Tony Lindgren
  2016-06-13 18:17 ` [PATCH 0/7] ir-rx51 driver fixes Pali Rohár
  7 siblings, 1 reply; 28+ messages in thread
From: Ivaylo Dimitrov @ 2016-05-07 15:21 UTC (permalink / raw)
  To: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	thierry.reding, bcousson, tony, linux, mchehab
  Cc: devicetree, linux-kernel, linux-pwm, linux-omap,
	linux-arm-kernel, linux-media, sre, pali.rohar, Ivaylo Dimitrov

Add the needed DT data to enable IR TX driver

Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
---
 arch/arm/boot/dts/omap3-n900.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/omap3-n900.dts b/arch/arm/boot/dts/omap3-n900.dts
index b3c26a9..3d1e23e 100644
--- a/arch/arm/boot/dts/omap3-n900.dts
+++ b/arch/arm/boot/dts/omap3-n900.dts
@@ -143,6 +143,18 @@
 		io-channels = <&twl_madc 0>, <&twl_madc 4>, <&twl_madc 12>;
 		io-channel-names = "temp", "bsi", "vbat";
 	};
+
+	pwm9: dmtimer-pwm@9 {
+		compatible = "ti,omap-dmtimer-pwm";
+		#pwm-cells = <3>;
+		ti,timers = <&timer9>;
+		ti,clock-source = <0x00>; /* timer_sys_ck */
+	};
+
+	ir: lirc-rx51 {
+		compatible = "nokia,lirc-rx51";
+		pwms = <&pwm9 0 26316 0>; /* 38000 Hz */
+	};
 };
 
 &omap3_pmx_core {
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* Re: [PATCH 5/7] ARM: OMAP: dmtimer: Do not call PM runtime functions when not needed.
  2016-05-07 15:21 ` [PATCH 5/7] ARM: OMAP: dmtimer: Do not call PM runtime functions when not needed Ivaylo Dimitrov
@ 2016-05-09 19:36   ` Tony Lindgren
  2016-05-09 20:51     ` Ivaylo Dimitrov
  0 siblings, 1 reply; 28+ messages in thread
From: Tony Lindgren @ 2016-05-09 19:36 UTC (permalink / raw)
  To: Ivaylo Dimitrov
  Cc: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	thierry.reding, bcousson, linux, mchehab, devicetree,
	linux-kernel, linux-pwm, linux-omap, linux-arm-kernel,
	linux-media, sre, pali.rohar

* Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com> [160507 08:24]:
> once omap_dm_timer_start() is called, which calls omap_dm_timer_enable()
> and thus pm_runtime_get_sync(), it doesn't make sense to call PM runtime
> functions again before omap_dm_timer_stop is called(). Otherwise PM runtime
> functions called in omap_dm_timer_enable/disable lead to long and unneeded
> delays.
> 
> Fix that by implementing an "enabled" counter, so the PM runtime functions
> get called only when really needed.
> 
> Without that patch Nokia N900 IR TX driver (ir-rx51) does not function.

We should use pm_runtime for the refcounting though and call PM runtime
unconditionally. Can you try to follow the standard PM runtime usage
like this:

init:
pm_runtime_use_autosuspend(&timer->pdev->dev);
pm_runtime_set_autosuspend_delay(&timer->pdev->dev, 200);
pm_runtime_enable(&timer->pdev->dev);
...
enable:
pm_runtime_get_sync(&timer->pdev->dev);
...
disable:
pm_runtime_mark_last_busy(&timer->pdev->dev);
pm_runtime_put_autosuspend(&timer->pdev->dev);
...
exit:
pm_runtime_dont_use_autosuspend(&timer->pdev->dev);
pm_runtime_put_sync(&timer->pdev->dev);
pm_runtime_disable(&timer->pdev->dev);

No idea what the timeout should be, maybe less than 200 ms. Also we need
to test that off idle still works with timer1, that might need special
handling.

Regards,

Tony

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 2/7] pwm: omap-dmtimer: Allow for setting dmtimer clock source
  2016-05-07 15:21 ` [PATCH 2/7] pwm: omap-dmtimer: Allow for setting dmtimer clock source Ivaylo Dimitrov
@ 2016-05-09 20:01   ` Rob Herring
  0 siblings, 0 replies; 28+ messages in thread
From: Rob Herring @ 2016-05-09 20:01 UTC (permalink / raw)
  To: Ivaylo Dimitrov
  Cc: pawel.moll, mark.rutland, ijc+devicetree, galak, thierry.reding,
	bcousson, tony, linux, mchehab, devicetree, linux-kernel,
	linux-pwm, linux-omap, linux-arm-kernel, linux-media, sre,
	pali.rohar

On Sat, May 07, 2016 at 06:21:43PM +0300, Ivaylo Dimitrov wrote:
> OMAP GP timers can have different input clocks that allow different PWM
> frequencies. However, there is no other way of setting the clock source but
> through clocks or clock-names properties of the timer itself. This limits
> PWM functionality to only the frequencies allowed by the particular clock
> source. Allowing setting the clock source by PWM rather than by timer
> allows different PWMs to have different ranges by not hard-wiring the clock
> source to the timer.
> 
> Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
> ---
>  Documentation/devicetree/bindings/pwm/pwm-omap-dmtimer.txt |  4 ++++
>  drivers/pwm/pwm-omap-dmtimer.c                             | 12 +++++++-----
>  2 files changed, 11 insertions(+), 5 deletions(-)

Acked-by: Rob Herring <robh@kernel.org>

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 4/7] [media] ir-rx51: add DT support to driver
  2016-05-07 15:21 ` [PATCH 4/7] [media] ir-rx51: add DT support to driver Ivaylo Dimitrov
@ 2016-05-09 20:06   ` Rob Herring
  2016-05-09 20:53     ` Ivaylo Dimitrov
  0 siblings, 1 reply; 28+ messages in thread
From: Rob Herring @ 2016-05-09 20:06 UTC (permalink / raw)
  To: Ivaylo Dimitrov
  Cc: pawel.moll, mark.rutland, ijc+devicetree, galak, thierry.reding,
	bcousson, tony, linux, mchehab, devicetree, linux-kernel,
	linux-pwm, linux-omap, linux-arm-kernel, linux-media, sre,
	pali.rohar

On Sat, May 07, 2016 at 06:21:45PM +0300, Ivaylo Dimitrov wrote:
> With the upcoming removal of legacy boot, lets add support to one of the
> last N900 drivers remaining without it. As the driver still uses omap
> dmtimer, add auxdata as well.
> 
> Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
> ---
>  .../devicetree/bindings/media/nokia,lirc-rx51         | 19 +++++++++++++++++++
>  arch/arm/mach-omap2/pdata-quirks.c                    |  6 +-----
>  drivers/media/rc/ir-rx51.c                            | 11 ++++++++++-
>  3 files changed, 30 insertions(+), 6 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/media/nokia,lirc-rx51
> 
> diff --git a/Documentation/devicetree/bindings/media/nokia,lirc-rx51 b/Documentation/devicetree/bindings/media/nokia,lirc-rx51
> new file mode 100644
> index 0000000..5b3081e
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/media/nokia,lirc-rx51
> @@ -0,0 +1,19 @@
> +Device-Tree bindings for LIRC TX driver for Nokia N900(RX51)
> +
> +Required properties:
> +	- compatible: should be "nokia,lirc-rx51".

lirc is a Linux term. Also, nokia,rx51-... would be conventional 
ordering.

Is this anything more than a PWM LED?

> +	- pwms: specifies PWM used for IR signal transmission.
> +
> +Example node:
> +
> +	pwm9: dmtimer-pwm@9 {
> +		compatible = "ti,omap-dmtimer-pwm";
> +		ti,timers = <&timer9>;
> +		#pwm-cells = <3>;
> +	};
> +
> +	ir: lirc-rx51 {
> +		compatible = "nokia,lirc-rx51";
> +
> +		pwms = <&pwm9 0 26316 0>; /* 38000 Hz */
> +	};

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 5/7] ARM: OMAP: dmtimer: Do not call PM runtime functions when not needed.
  2016-05-09 19:36   ` Tony Lindgren
@ 2016-05-09 20:51     ` Ivaylo Dimitrov
  2016-06-10 10:22       ` Tony Lindgren
  0 siblings, 1 reply; 28+ messages in thread
From: Ivaylo Dimitrov @ 2016-05-09 20:51 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	thierry.reding, bcousson, linux, mchehab, devicetree,
	linux-kernel, linux-pwm, linux-omap, linux-arm-kernel,
	linux-media, sre, pali.rohar

Hi,

On  9.05.2016 22:36, Tony Lindgren wrote:
> * Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com> [160507 08:24]:
>> once omap_dm_timer_start() is called, which calls omap_dm_timer_enable()
>> and thus pm_runtime_get_sync(), it doesn't make sense to call PM runtime
>> functions again before omap_dm_timer_stop is called(). Otherwise PM runtime
>> functions called in omap_dm_timer_enable/disable lead to long and unneeded
>> delays.
>>
>> Fix that by implementing an "enabled" counter, so the PM runtime functions
>> get called only when really needed.
>>
>> Without that patch Nokia N900 IR TX driver (ir-rx51) does not function.
>

Well, I just tested again, with the $subject patch reverted and 
contradictory to my own words, it worked just fine. I believe the reason 
is that I did hrtimer "migration" after I did the $subject patch. I was 
thinking the reason for the slow transmission was PWM dmtimer, but now 
it turns out it has been the "pulse" dmtimer. So, I think the $subject 
patch should be dropped.

> We should use pm_runtime for the refcounting though and call PM runtime
> unconditionally. Can you try to follow the standard PM runtime usage
> like this:
>

It works without that, but on the other hand, I finally have some 
reference on how PM runtime API should be called :).

> init:
> pm_runtime_use_autosuspend(&timer->pdev->dev);
> pm_runtime_set_autosuspend_delay(&timer->pdev->dev, 200);
> pm_runtime_enable(&timer->pdev->dev);
> ...
> enable:
> pm_runtime_get_sync(&timer->pdev->dev);
> ...
> disable:
> pm_runtime_mark_last_busy(&timer->pdev->dev);
> pm_runtime_put_autosuspend(&timer->pdev->dev);
> ...
> exit:
> pm_runtime_dont_use_autosuspend(&timer->pdev->dev);
> pm_runtime_put_sync(&timer->pdev->dev);
> pm_runtime_disable(&timer->pdev->dev);
>
> No idea what the timeout should be, maybe less than 200 ms. Also we need
> to test that off idle still works with timer1, that might need special
> handling.
>

Thanks,
Ivo

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 4/7] [media] ir-rx51: add DT support to driver
  2016-05-09 20:06   ` Rob Herring
@ 2016-05-09 20:53     ` Ivaylo Dimitrov
  2016-05-09 21:07       ` Rob Herring
  0 siblings, 1 reply; 28+ messages in thread
From: Ivaylo Dimitrov @ 2016-05-09 20:53 UTC (permalink / raw)
  To: Rob Herring
  Cc: pawel.moll, mark.rutland, ijc+devicetree, galak, thierry.reding,
	bcousson, tony, linux, mchehab, devicetree, linux-kernel,
	linux-pwm, linux-omap, linux-arm-kernel, linux-media, sre,
	pali.rohar

Hi,

On  9.05.2016 23:06, Rob Herring wrote:
> On Sat, May 07, 2016 at 06:21:45PM +0300, Ivaylo Dimitrov wrote:
>> With the upcoming removal of legacy boot, lets add support to one of the
>> last N900 drivers remaining without it. As the driver still uses omap
>> dmtimer, add auxdata as well.
>>
>> Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
>> ---
>>   .../devicetree/bindings/media/nokia,lirc-rx51         | 19 +++++++++++++++++++
>>   arch/arm/mach-omap2/pdata-quirks.c                    |  6 +-----
>>   drivers/media/rc/ir-rx51.c                            | 11 ++++++++++-
>>   3 files changed, 30 insertions(+), 6 deletions(-)
>>   create mode 100644 Documentation/devicetree/bindings/media/nokia,lirc-rx51
>>
>> diff --git a/Documentation/devicetree/bindings/media/nokia,lirc-rx51 b/Documentation/devicetree/bindings/media/nokia,lirc-rx51
>> new file mode 100644
>> index 0000000..5b3081e
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/media/nokia,lirc-rx51
>> @@ -0,0 +1,19 @@
>> +Device-Tree bindings for LIRC TX driver for Nokia N900(RX51)
>> +
>> +Required properties:
>> +	- compatible: should be "nokia,lirc-rx51".
>
> lirc is a Linux term. Also, nokia,rx51-... would be conventional
> ordering.
>

I used the driver name ("lirc_rx51") to not bring confusion. Also, it 
registers itself through lirc_register_driver() call, so having lirc in 
its name somehow makes sense.

I am not very good in inventing names, the best compatible I can think 
of is "nokia,rx51-ir". Is that ok?

> Is this anything more than a PWM LED?
>

It is an IR LED connected through a driver to McSPI2_SIMO pin of OMAP3, 
which pin can be configured as PWM or GPIO(there are other 
configurations, but they don't make sense). In theory it could be used 
for various things (like uni-directional serial TX, or stuff like that), 
but in practice it allows N900 to be act as an IR remote controller. I 
guess that fits in "nothing more than a PWM LED", more or less.

>> +	- pwms: specifies PWM used for IR signal transmission.
>> +
>> +Example node:
>> +
>> +	pwm9: dmtimer-pwm@9 {
>> +		compatible = "ti,omap-dmtimer-pwm";
>> +		ti,timers = <&timer9>;
>> +		#pwm-cells = <3>;
>> +	};
>> +
>> +	ir: lirc-rx51 {
>> +		compatible = "nokia,lirc-rx51";
>> +
>> +		pwms = <&pwm9 0 26316 0>; /* 38000 Hz */
>> +	};

Thanks,
Ivo

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 4/7] [media] ir-rx51: add DT support to driver
  2016-05-09 20:53     ` Ivaylo Dimitrov
@ 2016-05-09 21:07       ` Rob Herring
  2016-05-09 22:06         ` Ivaylo Dimitrov
  2016-05-10  2:18         ` Sebastian Reichel
  0 siblings, 2 replies; 28+ messages in thread
From: Rob Herring @ 2016-05-09 21:07 UTC (permalink / raw)
  To: Ivaylo Dimitrov
  Cc: Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Thierry Reding, Benoit Cousson, Tony Lindgren,
	Russell King - ARM Linux, Mauro Carvalho Chehab, devicetree,
	linux-kernel, Linux PWM List, linux-omap, linux-arm-kernel,
	linux-media, Sebastian Reichel, Pali Rohár

On Mon, May 9, 2016 at 3:53 PM, Ivaylo Dimitrov
<ivo.g.dimitrov.75@gmail.com> wrote:
> Hi,
>
> On  9.05.2016 23:06, Rob Herring wrote:
>>
>> On Sat, May 07, 2016 at 06:21:45PM +0300, Ivaylo Dimitrov wrote:
>>>
>>> With the upcoming removal of legacy boot, lets add support to one of the
>>> last N900 drivers remaining without it. As the driver still uses omap
>>> dmtimer, add auxdata as well.
>>>
>>> Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
>>> ---
>>>   .../devicetree/bindings/media/nokia,lirc-rx51         | 19
>>> +++++++++++++++++++
>>>   arch/arm/mach-omap2/pdata-quirks.c                    |  6 +-----
>>>   drivers/media/rc/ir-rx51.c                            | 11 ++++++++++-
>>>   3 files changed, 30 insertions(+), 6 deletions(-)
>>>   create mode 100644
>>> Documentation/devicetree/bindings/media/nokia,lirc-rx51
>>>
>>> diff --git a/Documentation/devicetree/bindings/media/nokia,lirc-rx51
>>> b/Documentation/devicetree/bindings/media/nokia,lirc-rx51
>>> new file mode 100644
>>> index 0000000..5b3081e
>>> --- /dev/null
>>> +++ b/Documentation/devicetree/bindings/media/nokia,lirc-rx51
>>> @@ -0,0 +1,19 @@
>>> +Device-Tree bindings for LIRC TX driver for Nokia N900(RX51)
>>> +
>>> +Required properties:
>>> +       - compatible: should be "nokia,lirc-rx51".
>>
>>
>> lirc is a Linux term. Also, nokia,rx51-... would be conventional
>> ordering.
>>
>
> I used the driver name ("lirc_rx51") to not bring confusion. Also, it
> registers itself through lirc_register_driver() call, so having lirc in its
> name somehow makes sense.
>
> I am not very good in inventing names, the best compatible I can think of is
> "nokia,rx51-ir". Is that ok?

Sure, but...

>> Is this anything more than a PWM LED?
>>
>
> It is an IR LED connected through a driver to McSPI2_SIMO pin of OMAP3,
> which pin can be configured as PWM or GPIO(there are other configurations,
> but they don't make sense). In theory it could be used for various things
> (like uni-directional serial TX, or stuff like that), but in practice it
> allows N900 to be act as an IR remote controller. I guess that fits in
> "nothing more than a PWM LED", more or less.

There's already a pwm-led binding that can be used. Though there may
be missing consumer IR to LED subsystem support in the kernel. You
could list both compatibles, use the rx51 IR driver now, and then move
to pwm-led driver in the future.

Rob

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 4/7] [media] ir-rx51: add DT support to driver
  2016-05-09 21:07       ` Rob Herring
@ 2016-05-09 22:06         ` Ivaylo Dimitrov
  2016-05-10  2:18         ` Sebastian Reichel
  1 sibling, 0 replies; 28+ messages in thread
From: Ivaylo Dimitrov @ 2016-05-09 22:06 UTC (permalink / raw)
  To: Rob Herring
  Cc: Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Thierry Reding, Benoit Cousson, Tony Lindgren,
	Russell King - ARM Linux, Mauro Carvalho Chehab, devicetree,
	linux-kernel, Linux PWM List, linux-omap, linux-arm-kernel,
	linux-media, Sebastian Reichel, Pali Rohár



On 10.05.2016 00:07, Rob Herring wrote:
> On Mon, May 9, 2016 at 3:53 PM, Ivaylo Dimitrov
> <ivo.g.dimitrov.75@gmail.com> wrote:
>> Hi,
>>
>> On  9.05.2016 23:06, Rob Herring wrote:
>>>
>>> On Sat, May 07, 2016 at 06:21:45PM +0300, Ivaylo Dimitrov wrote:
>>>>
>>>> With the upcoming removal of legacy boot, lets add support to one of the
>>>> last N900 drivers remaining without it. As the driver still uses omap
>>>> dmtimer, add auxdata as well.
>>>>
>>>> Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
>>>> ---
>>>>    .../devicetree/bindings/media/nokia,lirc-rx51         | 19
>>>> +++++++++++++++++++
>>>>    arch/arm/mach-omap2/pdata-quirks.c                    |  6 +-----
>>>>    drivers/media/rc/ir-rx51.c                            | 11 ++++++++++-
>>>>    3 files changed, 30 insertions(+), 6 deletions(-)
>>>>    create mode 100644
>>>> Documentation/devicetree/bindings/media/nokia,lirc-rx51
>>>>
>>>> diff --git a/Documentation/devicetree/bindings/media/nokia,lirc-rx51
>>>> b/Documentation/devicetree/bindings/media/nokia,lirc-rx51
>>>> new file mode 100644
>>>> index 0000000..5b3081e
>>>> --- /dev/null
>>>> +++ b/Documentation/devicetree/bindings/media/nokia,lirc-rx51
>>>> @@ -0,0 +1,19 @@
>>>> +Device-Tree bindings for LIRC TX driver for Nokia N900(RX51)
>>>> +
>>>> +Required properties:
>>>> +       - compatible: should be "nokia,lirc-rx51".
>>>
>>>
>>> lirc is a Linux term. Also, nokia,rx51-... would be conventional
>>> ordering.
>>>
>>
>> I used the driver name ("lirc_rx51") to not bring confusion. Also, it
>> registers itself through lirc_register_driver() call, so having lirc in its
>> name somehow makes sense.
>>
>> I am not very good in inventing names, the best compatible I can think of is
>> "nokia,rx51-ir". Is that ok?
>
> Sure, but...
>
>>> Is this anything more than a PWM LED?
>>>
>>
>> It is an IR LED connected through a driver to McSPI2_SIMO pin of OMAP3,
>> which pin can be configured as PWM or GPIO(there are other configurations,
>> but they don't make sense). In theory it could be used for various things
>> (like uni-directional serial TX, or stuff like that), but in practice it
>> allows N900 to be act as an IR remote controller. I guess that fits in
>> "nothing more than a PWM LED", more or less.
>
> There's already a pwm-led binding that can be used. Though there may
> be missing consumer IR to LED subsystem support in the kernel. You
> could list both compatibles, use the rx51 IR driver now, and then move
> to pwm-led driver in the future.
>

I looked at the pwm-leds (and related) code and couldn't see how it will 
do the job of controlling IR TX LED as a remote controller. So yeah, it 
seems CIR support in LEDS subsystem is non existent.

Could you elaborate on "list both compatibles", I don't really 
understand what I should do.

Ivo

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 4/7] [media] ir-rx51: add DT support to driver
  2016-05-09 21:07       ` Rob Herring
  2016-05-09 22:06         ` Ivaylo Dimitrov
@ 2016-05-10  2:18         ` Sebastian Reichel
  2016-05-11 14:14           ` Rob Herring
  1 sibling, 1 reply; 28+ messages in thread
From: Sebastian Reichel @ 2016-05-10  2:18 UTC (permalink / raw)
  To: Rob Herring
  Cc: Ivaylo Dimitrov, Pawel Moll, Mark Rutland, Ian Campbell,
	Kumar Gala, Thierry Reding, Benoit Cousson, Tony Lindgren,
	Russell King - ARM Linux, Mauro Carvalho Chehab, devicetree,
	linux-kernel, Linux PWM List, linux-omap, linux-arm-kernel,
	linux-media, Pali Rohár

[-- Attachment #1: Type: text/plain, Size: 883 bytes --]

Hi,

On Mon, May 09, 2016 at 04:07:35PM -0500, Rob Herring wrote:
> There's already a pwm-led binding that can be used. Though there
> may be missing consumer IR to LED subsystem support in the kernel.
> You could list both compatibles, use the rx51 IR driver now, and
> then move to pwm-led driver in the future.

Well from a purely HW point of view it's a PWM connected led. The
usage is completely different though. Usually PWM is used to control
the LED's brightness via the duty cycle (basic concept: enabling led
only 50% of time reduces brightness to 50%).

In the IR led's case the aim is generating a specific serial pattern
instead. For this task it uses a dmtimer in PWM mode and a second
one to reconfigure the pwm timer.

I don't know about a good name, but rx51 should be replaced with
n900 in the compatible string. So maybe "nokia,n900-infrared-diode".

-- Sebastian

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 4/7] [media] ir-rx51: add DT support to driver
  2016-05-10  2:18         ` Sebastian Reichel
@ 2016-05-11 14:14           ` Rob Herring
  2016-05-13  6:15             ` Ivaylo Dimitrov
  0 siblings, 1 reply; 28+ messages in thread
From: Rob Herring @ 2016-05-11 14:14 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Ivaylo Dimitrov, Pawel Moll, Mark Rutland, Ian Campbell,
	Kumar Gala, Thierry Reding, Benoit Cousson, Tony Lindgren,
	Russell King - ARM Linux, Mauro Carvalho Chehab, devicetree,
	linux-kernel, Linux PWM List, linux-omap, linux-arm-kernel,
	linux-media, Pali Rohár

On Tue, May 10, 2016 at 04:18:27AM +0200, Sebastian Reichel wrote:
> Hi,
> 
> On Mon, May 09, 2016 at 04:07:35PM -0500, Rob Herring wrote:
> > There's already a pwm-led binding that can be used. Though there
> > may be missing consumer IR to LED subsystem support in the kernel.
> > You could list both compatibles, use the rx51 IR driver now, and
> > then move to pwm-led driver in the future.
> 
> Well from a purely HW point of view it's a PWM connected led. The
> usage is completely different though. Usually PWM is used to control
> the LED's brightness via the duty cycle (basic concept: enabling led
> only 50% of time reduces brightness to 50%).
> 
> In the IR led's case the aim is generating a specific serial pattern
> instead. For this task it uses a dmtimer in PWM mode and a second
> one to reconfigure the pwm timer.

In that case, it will probably never be a generic driver.

> I don't know about a good name, but rx51 should be replaced with
> n900 in the compatible string. So maybe "nokia,n900-infrared-diode".

That's fine, but the shorter '-ir' was too.

Rob

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 4/7] [media] ir-rx51: add DT support to driver
  2016-05-11 14:14           ` Rob Herring
@ 2016-05-13  6:15             ` Ivaylo Dimitrov
  2016-05-13 14:01               ` Sebastian Reichel
  0 siblings, 1 reply; 28+ messages in thread
From: Ivaylo Dimitrov @ 2016-05-13  6:15 UTC (permalink / raw)
  To: Rob Herring, Sebastian Reichel
  Cc: Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Thierry Reding, Benoit Cousson, Tony Lindgren,
	Russell King - ARM Linux, Mauro Carvalho Chehab, devicetree,
	linux-kernel, Linux PWM List, linux-omap, linux-arm-kernel,
	linux-media, Pali Rohár

Hi,

On 11.05.2016 17:14, Rob Herring wrote:
> On Tue, May 10, 2016 at 04:18:27AM +0200, Sebastian Reichel wrote:
>> Hi,
>>
>> On Mon, May 09, 2016 at 04:07:35PM -0500, Rob Herring wrote:
>>> There's already a pwm-led binding that can be used. Though there
>>> may be missing consumer IR to LED subsystem support in the kernel.
>>> You could list both compatibles, use the rx51 IR driver now, and
>>> then move to pwm-led driver in the future.
>>
>> Well from a purely HW point of view it's a PWM connected led. The
>> usage is completely different though. Usually PWM is used to control
>> the LED's brightness via the duty cycle (basic concept: enabling led
>> only 50% of time reduces brightness to 50%).
>>
>> In the IR led's case the aim is generating a specific serial pattern
>> instead. For this task it uses a dmtimer in PWM mode and a second
>> one to reconfigure the pwm timer.
>
> In that case, it will probably never be a generic driver.
>
>> I don't know about a good name, but rx51 should be replaced with
>> n900 in the compatible string. So maybe "nokia,n900-infrared-diode".
>
> That's fine, but the shorter '-ir' was too.
>

I prefer the shorter "nokia,n900-ir", will resend the series with it 
used, unless someone has concerns about it.

Ivo

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 4/7] [media] ir-rx51: add DT support to driver
  2016-05-13  6:15             ` Ivaylo Dimitrov
@ 2016-05-13 14:01               ` Sebastian Reichel
  0 siblings, 0 replies; 28+ messages in thread
From: Sebastian Reichel @ 2016-05-13 14:01 UTC (permalink / raw)
  To: Ivaylo Dimitrov
  Cc: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Thierry Reding, Benoit Cousson, Tony Lindgren,
	Russell King - ARM Linux, Mauro Carvalho Chehab, devicetree,
	linux-kernel, Linux PWM List, linux-omap, linux-arm-kernel,
	linux-media, Pali Rohár

[-- Attachment #1: Type: text/plain, Size: 221 bytes --]

Hi,

On Fri, May 13, 2016 at 09:15:38AM +0300, Ivaylo Dimitrov wrote:
> I prefer the shorter "nokia,n900-ir", will resend the series with
> it used, unless someone has concerns about it.

Sounds fine to me.

-- Sebastian

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 7/7] ARM: dts: n900: enable lirc-rx51 driver
  2016-05-07 15:21 ` [PATCH 7/7] ARM: dts: n900: enable lirc-rx51 driver Ivaylo Dimitrov
@ 2016-06-10 10:20   ` Tony Lindgren
  0 siblings, 0 replies; 28+ messages in thread
From: Tony Lindgren @ 2016-06-10 10:20 UTC (permalink / raw)
  To: Ivaylo Dimitrov
  Cc: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	thierry.reding, bcousson, linux, mchehab, devicetree,
	linux-kernel, linux-pwm, linux-omap, linux-arm-kernel,
	linux-media, sre, pali.rohar

* Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com> [160507 08:24]:
> Add the needed DT data to enable IR TX driver

Applying this patch into omap-for-v4.8/dt thanks.

Regards,

Tony

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 5/7] ARM: OMAP: dmtimer: Do not call PM runtime functions when not needed.
  2016-05-09 20:51     ` Ivaylo Dimitrov
@ 2016-06-10 10:22       ` Tony Lindgren
  2016-06-10 21:21         ` Ivaylo Dimitrov
  0 siblings, 1 reply; 28+ messages in thread
From: Tony Lindgren @ 2016-06-10 10:22 UTC (permalink / raw)
  To: Ivaylo Dimitrov
  Cc: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	thierry.reding, bcousson, linux, mchehab, devicetree,
	linux-kernel, linux-pwm, linux-omap, linux-arm-kernel,
	linux-media, sre, pali.rohar

* Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com> [160509 13:52]:
> Hi,
> 
> On  9.05.2016 22:36, Tony Lindgren wrote:
> > * Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com> [160507 08:24]:
> > > once omap_dm_timer_start() is called, which calls omap_dm_timer_enable()
> > > and thus pm_runtime_get_sync(), it doesn't make sense to call PM runtime
> > > functions again before omap_dm_timer_stop is called(). Otherwise PM runtime
> > > functions called in omap_dm_timer_enable/disable lead to long and unneeded
> > > delays.
> > > 
> > > Fix that by implementing an "enabled" counter, so the PM runtime functions
> > > get called only when really needed.
> > > 
> > > Without that patch Nokia N900 IR TX driver (ir-rx51) does not function.
> > 
> 
> Well, I just tested again, with the $subject patch reverted and
> contradictory to my own words, it worked just fine. I believe the reason is
> that I did hrtimer "migration" after I did the $subject patch. I was
> thinking the reason for the slow transmission was PWM dmtimer, but now it
> turns out it has been the "pulse" dmtimer. So, I think the $subject patch
> should be dropped.
> 
> > We should use pm_runtime for the refcounting though and call PM runtime
> > unconditionally. Can you try to follow the standard PM runtime usage
> > like this:
> > 
> 
> It works without that, but on the other hand, I finally have some reference
> on how PM runtime API should be called :).

OK. And I just applied the related dts changes. Please repost the driver
changes and DT binding doc with Rob's ack to the driver maintainers to
apply.

Regards,

Tony

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 5/7] ARM: OMAP: dmtimer: Do not call PM runtime functions when not needed.
  2016-06-10 10:22       ` Tony Lindgren
@ 2016-06-10 21:21         ` Ivaylo Dimitrov
  2016-06-13  7:10           ` Tony Lindgren
  0 siblings, 1 reply; 28+ messages in thread
From: Ivaylo Dimitrov @ 2016-06-10 21:21 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	thierry.reding, bcousson, linux, mchehab, devicetree,
	linux-kernel, linux-pwm, linux-omap, linux-arm-kernel,
	linux-media, sre, pali.rohar


On 10.06.2016 13:22, Tony Lindgren wrote:
>
> OK. And I just applied the related dts changes. Please repost the driver
> changes and DT binding doc with Rob's ack to the driver maintainers to
> apply.
>

Already did, see https://lkml.org/lkml/2016/5/16/429

Shall I do anything else?

Thanks,
Ivo

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 5/7] ARM: OMAP: dmtimer: Do not call PM runtime functions when not needed.
  2016-06-10 21:21         ` Ivaylo Dimitrov
@ 2016-06-13  7:10           ` Tony Lindgren
  2016-06-13  7:39             ` Tony Lindgren
  2016-06-13 18:58             ` Ivaylo Dimitrov
  0 siblings, 2 replies; 28+ messages in thread
From: Tony Lindgren @ 2016-06-13  7:10 UTC (permalink / raw)
  To: Ivaylo Dimitrov
  Cc: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	thierry.reding, bcousson, linux, mchehab, devicetree,
	linux-kernel, linux-pwm, linux-omap, linux-arm-kernel,
	linux-media, sre, pali.rohar

* Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com> [160610 14:23]:
> 
> On 10.06.2016 13:22, Tony Lindgren wrote:
> > 
> > OK. And I just applied the related dts changes. Please repost the driver
> > changes and DT binding doc with Rob's ack to the driver maintainers to
> > apply.
> > 
> 
> Already did, see https://lkml.org/lkml/2016/5/16/429
> 
> Shall I do anything else?

Probably good idea to repost just the driver changes to the
subsystem maintainers. With v4.7 out any pre v4.7 patchsets
easily get forgotten.

Regards,

Tony

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 5/7] ARM: OMAP: dmtimer: Do not call PM runtime functions when not needed.
  2016-06-13  7:10           ` Tony Lindgren
@ 2016-06-13  7:39             ` Tony Lindgren
  2016-06-13 18:58             ` Ivaylo Dimitrov
  1 sibling, 0 replies; 28+ messages in thread
From: Tony Lindgren @ 2016-06-13  7:39 UTC (permalink / raw)
  To: Ivaylo Dimitrov
  Cc: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	thierry.reding, bcousson, linux, mchehab, devicetree,
	linux-kernel, linux-pwm, linux-omap, linux-arm-kernel,
	linux-media, sre, pali.rohar

* Tony Lindgren <tony@atomide.com> [160613 00:10]:
> * Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com> [160610 14:23]:
> > 
> > On 10.06.2016 13:22, Tony Lindgren wrote:
> > > 
> > > OK. And I just applied the related dts changes. Please repost the driver
> > > changes and DT binding doc with Rob's ack to the driver maintainers to
> > > apply.
> > > 
> > 
> > Already did, see https://lkml.org/lkml/2016/5/16/429
> > 
> > Shall I do anything else?
> 
> Probably good idea to repost just the driver changes to the
> subsystem maintainers. With v4.7 out any pre v4.7 patchsets
> easily get forgotten.

Heh s/v4.7/v4.6/ :)

Tony

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 0/7] ir-rx51 driver fixes
  2016-05-07 15:21 [PATCH 0/7] ir-rx51 driver fixes Ivaylo Dimitrov
                   ` (6 preceding siblings ...)
  2016-05-07 15:21 ` [PATCH 7/7] ARM: dts: n900: enable lirc-rx51 driver Ivaylo Dimitrov
@ 2016-06-13 18:17 ` Pali Rohár
  2016-06-13 18:48   ` Ivaylo Dimitrov
  7 siblings, 1 reply; 28+ messages in thread
From: Pali Rohár @ 2016-06-13 18:17 UTC (permalink / raw)
  To: tony
  Cc: Ivaylo Dimitrov, robh+dt, pawel.moll, mark.rutland,
	ijc+devicetree, galak, thierry.reding, bcousson, linux, mchehab,
	devicetree, linux-kernel, linux-pwm, linux-omap,
	linux-arm-kernel, linux-media, sre

[-- Attachment #1: Type: Text/Plain, Size: 2053 bytes --]

On Saturday 07 May 2016 17:21:41 Ivaylo Dimitrov wrote:
> ir-rx51 is a driver for Nokia N900 IR transmitter. The current series
> fixes the remaining problems in the driver:
> 
>  - replace GP timer 9 with PWM framework usage
>  - replace pulse width timer dmtimer usage with hrtimer
>  - add DT support to the driver
>  - add driver to the board DTS
> 
> Pathes 2 and 5 are needed so the driver to function correctly,
> without those PWM either refuses to set the needed carrier frequency
> (patch 2) or there are such a delays in the PWM framework, code that
> transmission duration raises to ~5s instead of half a second.
> 
> Ivaylo Dimitrov (6):
>   pwm: omap-dmtimer: Allow for setting dmtimer clock source
>   [media] ir-rx51: use PWM framework instead of OMAP dmtimer
>   [media] ir-rx51: add DT support to driver
>   ARM: OMAP: dmtimer: Do not call PM runtime functions when not
> needed. [media] ir-rx51: use hrtimer instead of dmtimer
>   ARM: dts: n900: enable lirc-rx51 driver
> 
> Tony Lindgren (1):
>   ir-rx51: Fix build after multiarch changes broke it
> 
>  .../devicetree/bindings/media/nokia,lirc-rx51      |  19 ++
>  .../devicetree/bindings/pwm/pwm-omap-dmtimer.txt   |   4 +
>  arch/arm/boot/dts/omap3-n900.dts                   |  12 ++
>  arch/arm/mach-omap2/board-rx51-peripherals.c       |   5 -
>  arch/arm/mach-omap2/pdata-quirks.c                 |  10 +-
>  arch/arm/plat-omap/dmtimer.c                       |   9 +-
>  arch/arm/plat-omap/include/plat/dmtimer.h          |   1 +
>  drivers/media/rc/Kconfig                           |   2 +-
>  drivers/media/rc/ir-rx51.c                         | 229
> +++++++-------------- drivers/pwm/pwm-omap-dmtimer.c                
>     |  12 +- include/linux/platform_data/media/ir-rx51.h        |  
> 3 -
>  11 files changed, 131 insertions(+), 175 deletions(-)
>  create mode 100644
> Documentation/devicetree/bindings/media/nokia,lirc-rx51

Patch series looks good, you can add my Acked-by.

-- 
Pali Rohár
pali.rohar@gmail.com

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 0/7] ir-rx51 driver fixes
  2016-06-13 18:17 ` [PATCH 0/7] ir-rx51 driver fixes Pali Rohár
@ 2016-06-13 18:48   ` Ivaylo Dimitrov
  0 siblings, 0 replies; 28+ messages in thread
From: Ivaylo Dimitrov @ 2016-06-13 18:48 UTC (permalink / raw)
  To: Pali Rohár, tony
  Cc: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	thierry.reding, bcousson, linux, mchehab, devicetree,
	linux-kernel, linux-pwm, linux-omap, linux-arm-kernel,
	linux-media, sre

Hi,

On 13.06.2016 21:17, Pali Rohár wrote:
> On Saturday 07 May 2016 17:21:41 Ivaylo Dimitrov wrote:
>> ir-rx51 is a driver for Nokia N900 IR transmitter. The current series
>> fixes the remaining problems in the driver:
>>
>>   - replace GP timer 9 with PWM framework usage
>>   - replace pulse width timer dmtimer usage with hrtimer
>>   - add DT support to the driver
>>   - add driver to the board DTS
>>
>> Pathes 2 and 5 are needed so the driver to function correctly,
>> without those PWM either refuses to set the needed carrier frequency
>> (patch 2) or there are such a delays in the PWM framework, code that
>> transmission duration raises to ~5s instead of half a second.
>>
>> Ivaylo Dimitrov (6):
>>    pwm: omap-dmtimer: Allow for setting dmtimer clock source
>>    [media] ir-rx51: use PWM framework instead of OMAP dmtimer
>>    [media] ir-rx51: add DT support to driver
>>    ARM: OMAP: dmtimer: Do not call PM runtime functions when not
>> needed. [media] ir-rx51: use hrtimer instead of dmtimer
>>    ARM: dts: n900: enable lirc-rx51 driver
>>
>> Tony Lindgren (1):
>>    ir-rx51: Fix build after multiarch changes broke it
>>
>>   .../devicetree/bindings/media/nokia,lirc-rx51      |  19 ++
>>   .../devicetree/bindings/pwm/pwm-omap-dmtimer.txt   |   4 +
>>   arch/arm/boot/dts/omap3-n900.dts                   |  12 ++
>>   arch/arm/mach-omap2/board-rx51-peripherals.c       |   5 -
>>   arch/arm/mach-omap2/pdata-quirks.c                 |  10 +-
>>   arch/arm/plat-omap/dmtimer.c                       |   9 +-
>>   arch/arm/plat-omap/include/plat/dmtimer.h          |   1 +
>>   drivers/media/rc/Kconfig                           |   2 +-
>>   drivers/media/rc/ir-rx51.c                         | 229
>> +++++++-------------- drivers/pwm/pwm-omap-dmtimer.c
>>      |  12 +- include/linux/platform_data/media/ir-rx51.h        |
>> 3 -
>>   11 files changed, 131 insertions(+), 175 deletions(-)
>>   create mode 100644
>> Documentation/devicetree/bindings/media/nokia,lirc-rx51
>
> Patch series looks good, you can add my Acked-by.
>

There is a newer series, please look at https://lkml.org/lkml/2016/5/16/429

Ivo

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 5/7] ARM: OMAP: dmtimer: Do not call PM runtime functions when not needed.
  2016-06-13  7:10           ` Tony Lindgren
  2016-06-13  7:39             ` Tony Lindgren
@ 2016-06-13 18:58             ` Ivaylo Dimitrov
  2016-06-14  7:53               ` Tony Lindgren
  1 sibling, 1 reply; 28+ messages in thread
From: Ivaylo Dimitrov @ 2016-06-13 18:58 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	thierry.reding, bcousson, linux, mchehab, devicetree,
	linux-kernel, linux-pwm, linux-omap, linux-arm-kernel,
	linux-media, sre, pali.rohar

Hi,

On 13.06.2016 10:10, Tony Lindgren wrote:
> * Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com> [160610 14:23]:
>>
>> On 10.06.2016 13:22, Tony Lindgren wrote:
>>>
>>> OK. And I just applied the related dts changes. Please repost the driver
>>> changes and DT binding doc with Rob's ack to the driver maintainers to
>>> apply.
>>>
>>
>> Already did, see https://lkml.org/lkml/2016/5/16/429
>>
>> Shall I do anything else?
>
> Probably good idea to repost just the driver changes to the
> subsystem maintainers. With v4.7 out any pre v4.7 patchsets
> easily get forgotten.
>

Sorry for the maybe stupid question, but does this mean that I should 
send separate patches instead of series? Or the series without what 
you've already applied?

Thanks,
Ivo

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 5/7] ARM: OMAP: dmtimer: Do not call PM runtime functions when not needed.
  2016-06-13 18:58             ` Ivaylo Dimitrov
@ 2016-06-14  7:53               ` Tony Lindgren
  0 siblings, 0 replies; 28+ messages in thread
From: Tony Lindgren @ 2016-06-14  7:53 UTC (permalink / raw)
  To: Ivaylo Dimitrov
  Cc: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	thierry.reding, bcousson, linux, mchehab, devicetree,
	linux-kernel, linux-pwm, linux-omap, linux-arm-kernel,
	linux-media, sre, pali.rohar

* Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com> [160613 12:01]:
> Hi,
> 
> On 13.06.2016 10:10, Tony Lindgren wrote:
> > * Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com> [160610 14:23]:
> > > 
> > > On 10.06.2016 13:22, Tony Lindgren wrote:
> > > > 
> > > > OK. And I just applied the related dts changes. Please repost the driver
> > > > changes and DT binding doc with Rob's ack to the driver maintainers to
> > > > apply.
> > > > 
> > > 
> > > Already did, see https://lkml.org/lkml/2016/5/16/429
> > > 
> > > Shall I do anything else?
> > 
> > Probably good idea to repost just the driver changes to the
> > subsystem maintainers. With v4.7 out any pre v4.7 patchsets
> > easily get forgotten.
> > 
> 
> Sorry for the maybe stupid question, but does this mean that I should send
> separate patches instead of series? Or the series without what you've
> already applied?

Always leave out the patches that have been already applied.
Otherwise people will get confused. Just mention it in the
cover letter saying "patch xyz has been already applied into
foo tree, these patches are safe to apply separately into bar
tree" or something similar :)

Tony

^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2016-06-14  7:54 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-07 15:21 [PATCH 0/7] ir-rx51 driver fixes Ivaylo Dimitrov
2016-05-07 15:21 ` [PATCH 1/7] ir-rx51: Fix build after multiarch changes broke it Ivaylo Dimitrov
2016-05-07 15:21 ` [PATCH 2/7] pwm: omap-dmtimer: Allow for setting dmtimer clock source Ivaylo Dimitrov
2016-05-09 20:01   ` Rob Herring
2016-05-07 15:21 ` [PATCH 3/7] [media] ir-rx51: use PWM framework instead of OMAP dmtimer Ivaylo Dimitrov
2016-05-07 15:21 ` [PATCH 4/7] [media] ir-rx51: add DT support to driver Ivaylo Dimitrov
2016-05-09 20:06   ` Rob Herring
2016-05-09 20:53     ` Ivaylo Dimitrov
2016-05-09 21:07       ` Rob Herring
2016-05-09 22:06         ` Ivaylo Dimitrov
2016-05-10  2:18         ` Sebastian Reichel
2016-05-11 14:14           ` Rob Herring
2016-05-13  6:15             ` Ivaylo Dimitrov
2016-05-13 14:01               ` Sebastian Reichel
2016-05-07 15:21 ` [PATCH 5/7] ARM: OMAP: dmtimer: Do not call PM runtime functions when not needed Ivaylo Dimitrov
2016-05-09 19:36   ` Tony Lindgren
2016-05-09 20:51     ` Ivaylo Dimitrov
2016-06-10 10:22       ` Tony Lindgren
2016-06-10 21:21         ` Ivaylo Dimitrov
2016-06-13  7:10           ` Tony Lindgren
2016-06-13  7:39             ` Tony Lindgren
2016-06-13 18:58             ` Ivaylo Dimitrov
2016-06-14  7:53               ` Tony Lindgren
2016-05-07 15:21 ` [PATCH 6/7] [media] ir-rx51: use hrtimer instead of dmtimer Ivaylo Dimitrov
2016-05-07 15:21 ` [PATCH 7/7] ARM: dts: n900: enable lirc-rx51 driver Ivaylo Dimitrov
2016-06-10 10:20   ` Tony Lindgren
2016-06-13 18:17 ` [PATCH 0/7] ir-rx51 driver fixes Pali Rohár
2016-06-13 18:48   ` Ivaylo Dimitrov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).