[PATCH] MFD: twl-core: Fix chip ID for the twl6030-pwm module

2012-10-31 Thread Peter Ujfalusi
The correct chip id is 1 since the PWM module is on address 0x49. With the
current TWL6030_MODULE_ID1 the kernel will crash early since:
#define TWL6030_MODULE_ID1 0x0E
and
static struct twl_client twl_modules[4];

Down in the stack we try to get the module by:
struct twl_client   *twl = twl_modules[chip];

Which obviously going to do nasty things.

Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
Hi Samuel,

Can you push this patch to 3.7?
Without this if the user enables the twl6030-pwm driver the kernel will not
going to boot on OMAP4.

Thank you,
Peter

 drivers/mfd/twl-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index 2624668..d7577cb 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -672,7 +672,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned 
irq_base,
}
 
if (IS_ENABLED(CONFIG_PWM_TWL6030)  twl_class_is_6030()) {
-   child = add_child(TWL6030_MODULE_ID1, twl6030-pwm, NULL, 0,
+   child = add_child(SUB_CHIP_ID1, twl6030-pwm, NULL, 0,
  false, 0, 0);
if (IS_ERR(child))
return PTR_ERR(child);
-- 
1.7.12.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: linux-next: build failure after merge of the sound and sound-asoc trees

2012-09-24 Thread Peter Ujfalusi
On 09/24/2012 10:48 AM, Takashi Iwai wrote:
 At Mon, 24 Sep 2012 13:39:23 +1000,
 Stephen Rothwell wrote:

 Hi all,

 After merging the sound tree, today's linux-next build (powerpc
 ppc64_defconfig) failed like this:

 In file included from include/linux/skbuff.h:31:0,
  from include/linux/if_ether.h:135,
  from include/linux/netdevice.h:29,
  from arch/powerpc/net/bpf_jit_comp.c:14:
 include/linux/dmaengine.h: In function 'dmaengine_prep_dma_cyclic':
 include/linux/dmaengine.h:659:24: error: 'flags' undeclared (first use in 
 this function)

 and lots more similar.

 Caused by commit ec8b5e48c037 (dmaengine: Pass flags via
 device_prep_dma_cyclic() callback).  Was this version of this patch
 build tested at all?

 I have used the sound and sound-asoc trees from next-20120921 for today.
 
 Ugh, sorry.  I skipped the ppc and arm build tests at the previous
 merge due to the remote work.
 
 I can fix up but it'd be better to get a proper fix from Peter.
 Peter, could you submit the fix ASAP?

I already have the series to fix it.
The reason for the build breakage is that the following commit from my series
got lost somewhere:
dmaengine: Add flags parameter to dmaengine_prep_dma_cyclic()

I also noticed that arch/arm/plat-samsung/dma-ops.c calls
dmaengine_prep_dma_cyclic(), which was unexpected for me. So I have two patch
for linux-next/sound to fix the issue.

Will send them in a minute.

-- 
Péter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/2] dmaengine: Fix compillation issues in device_prep_dma_cyclic()

2012-09-24 Thread Peter Ujfalusi
Hello,

The reason for the breakage is the patch 1 got lost somewhere in the process.
I also greped the whole tree for device_prep_dma_cyclic() and the second patch
is the result of that.

PS: I did build tested the series on ARM (OMAP), x86_32, x86_64 but not for ppc
for sure.

Regards,
Peter
---
Peter Ujfalusi (2):
  dmaengine: Add flags parameter to dmaengine_prep_dma_cyclic()
  ARM: SAMSUNG: dma-ops: Fix dmaengine_prep_dma_cyclic() parameter list

 arch/arm/plat-samsung/dma-ops.c | 3 ++-
 include/linux/dmaengine.h   | 3 ++-
 sound/soc/soc-dmaengine-pcm.c   | 6 +-
 3 files changed, 9 insertions(+), 3 deletions(-)

-- 
1.7.12

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/2] dmaengine: Add flags parameter to dmaengine_prep_dma_cyclic()

2012-09-24 Thread Peter Ujfalusi
With this parameter added to dmaengine_prep_dma_cyclic() the API will be in
sync with other dmaengine_prep_*() functions.
The dmaengine_prep_dma_cyclic() function primarily used by audio for cyclic
transfer required by ALSA, we use the from audio to ask dma drivers to
suppress interrupts (if DMA_PREP_INTERRUPT is cleared) when it is supported
on the platform.

Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
CC: Lars-Peter Clausen l...@metafoo.de
---
 include/linux/dmaengine.h | 3 ++-
 sound/soc/soc-dmaengine-pcm.c | 6 +-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index 09da4e5..d3201e4 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -653,7 +653,8 @@ static inline struct dma_async_tx_descriptor 
*dmaengine_prep_rio_sg(
 
 static inline struct dma_async_tx_descriptor *dmaengine_prep_dma_cyclic(
struct dma_chan *chan, dma_addr_t buf_addr, size_t buf_len,
-   size_t period_len, enum dma_transfer_direction dir)
+   size_t period_len, enum dma_transfer_direction dir,
+   unsigned long flags)
 {
return chan-device-device_prep_dma_cyclic(chan, buf_addr, buf_len,
period_len, dir, flags, NULL);
diff --git a/sound/soc/soc-dmaengine-pcm.c b/sound/soc/soc-dmaengine-pcm.c
index 5df529e..bbc1257 100644
--- a/sound/soc/soc-dmaengine-pcm.c
+++ b/sound/soc/soc-dmaengine-pcm.c
@@ -140,14 +140,18 @@ static int dmaengine_pcm_prepare_and_submit(struct 
snd_pcm_substream *substream)
struct dma_chan *chan = prtd-dma_chan;
struct dma_async_tx_descriptor *desc;
enum dma_transfer_direction direction;
+   unsigned long flags = DMA_CTRL_ACK;
 
direction = snd_pcm_substream_to_dma_direction(substream);
 
+   if (!substream-runtime-no_period_wakeup)
+   flags |= DMA_PREP_INTERRUPT;
+
prtd-pos = 0;
desc = dmaengine_prep_dma_cyclic(chan,
substream-runtime-dma_addr,
snd_pcm_lib_buffer_bytes(substream),
-   snd_pcm_lib_period_bytes(substream), direction);
+   snd_pcm_lib_period_bytes(substream), direction, flags);
 
if (!desc)
return -ENOMEM;
-- 
1.7.12

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2] ARM: SAMSUNG: dma-ops: Fix dmaengine_prep_dma_cyclic() parameter list

2012-09-24 Thread Peter Ujfalusi
There is a new flags parameter for the function.

Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
 arch/arm/plat-samsung/dma-ops.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm/plat-samsung/dma-ops.c b/arch/arm/plat-samsung/dma-ops.c
index c38d754..d088afa 100644
--- a/arch/arm/plat-samsung/dma-ops.c
+++ b/arch/arm/plat-samsung/dma-ops.c
@@ -91,7 +91,8 @@ static int samsung_dmadev_prepare(unsigned ch,
break;
case DMA_CYCLIC:
desc = dmaengine_prep_dma_cyclic(chan, param-buf,
-   param-len, param-period, param-direction);
+   param-len, param-period, param-direction,
+   DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
break;
default:
dev_err(chan-dev-device, unsupported format\n);
-- 
1.7.12

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: CMA broken in next-20120926

2012-09-28 Thread Peter Ujfalusi
On 09/28/2012 08:43 AM, Minchan Kim wrote:
 From 24a547855fa2bd4212a779cc73997837148310b3 Mon Sep 17 00:00:00 2001
 From: Minchan Kim minc...@kernel.org
 Date: Fri, 28 Sep 2012 14:28:32 +0900
 Subject: [PATCH] revert mm: compaction: iron out isolate_freepages_block()
  and isolate_freepages_range()
 
 [1] made bug on CMA.
 The nr_scanned should be never equal to total_isolated for successful CMA.
 This patch reverts part of the patch.
 
 [1] mm: compaction: iron out isolate_freepages_block() and 
 isolate_freepages_range()

With this patch applied on top of today's linux-next CMA enabled kernel works
fine on OMAP platforms (without the patch audio was not working because
dma_alloc_writecombine() was failing, probably other things were broken as 
well).
Thank you for the quick fix!

Tested-by: Peter Ujfalusi peter.ujfal...@ti.com

 
 Cc: Mel Gorman mgor...@suse.de
 Signed-off-by: Minchan Kim minc...@kernel.org
 ---
  mm/compaction.c |   29 -
  1 file changed, 16 insertions(+), 13 deletions(-)
 
 diff --git a/mm/compaction.c b/mm/compaction.c
 index 5037399..7721197 100644
 --- a/mm/compaction.c
 +++ b/mm/compaction.c
 @@ -269,13 +269,14 @@ static unsigned long isolate_freepages_block(struct 
 compact_control *cc,
   int isolated, i;
   struct page *page = cursor;
  
 - nr_scanned++;
   if (!pfn_valid_within(blockpfn))
 - continue;
 + goto strict_check;
 + nr_scanned++;
 +
   if (!valid_page)
   valid_page = page;
   if (!PageBuddy(page))
 - continue;
 + goto strict_check;
  
   /*
* The zone lock must be held to isolate freepages.
 @@ -296,12 +297,12 @@ static unsigned long isolate_freepages_block(struct 
 compact_control *cc,
  
   /* Recheck this is a buddy page under lock */
   if (!PageBuddy(page))
 - continue;
 + goto strict_check;
  
   /* Found a free page, break it into order-0 pages */
   isolated = split_free_page(page);
   if (!isolated  strict)
 - break;
 + goto strict_check;
   total_isolated += isolated;
   for (i = 0; i  isolated; i++) {
   list_add(page-lru, freelist);
 @@ -313,18 +314,20 @@ static unsigned long isolate_freepages_block(struct 
 compact_control *cc,
   blockpfn += isolated - 1;
   cursor += isolated - 1;
   }
 +
 + continue;
 +
 +strict_check:
 + /* Abort isolation if the caller requested strict isolation */
 + if (strict) {
 + total_isolated = 0;
 + goto out;
 + }
   }
  
   trace_mm_compaction_isolate_freepages(nr_scanned, total_isolated);
  
 - /*
 -  * If strict isolation is requested by CMA then check that all the
 -  * pages scanned were isolated. If there were any failures, 0 is
 -  * returned and CMA will fail.
 -  */
 - if (strict  nr_scanned != total_isolated)
 - total_isolated = 0;
 -
 +out:
   if (locked)
   spin_unlock_irqrestore(cc-zone-lock, flags);
  
 


-- 
Péter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 3.7-rc1] omap zoom2.c: Fix compile error by including correct header files

2012-10-03 Thread Peter Ujfalusi
On 10/03/2012 05:31 PM, Tim Gardner wrote:
 Cc: Peter Ujfalusi peter.ujfal...@ti.com
 Cc: Jarkko Nikula jarkko.nik...@bitmer.com
 Cc: Liam Girdwood l...@ti.com
 Cc: Mark Brown broo...@opensource.wolfsonmicro.com
 Cc: Jaroslav Kysela pe...@perex.cz
 Cc: Takashi Iwai ti...@suse.de
 Cc: linux-o...@vger.kernel.org
 Cc: alsa-de...@alsa-project.org
 Signed-off-by: Tim Gardner tim.gard...@canonical.com
 ---
  sound/soc/omap/zoom2.c |3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
 
 diff --git a/sound/soc/omap/zoom2.c b/sound/soc/omap/zoom2.c
 index 23de2b2..d0a8c92 100644
 --- a/sound/soc/omap/zoom2.c
 +++ b/sound/soc/omap/zoom2.c
 @@ -27,9 +27,10 @@
  
  #include asm/mach-types.h
  #include mach/hardware.h
 -#include mach/gpio.h
 +#include linux/gpio.h
  #include mach/board-zoom.h
  #include linux/platform_data/asoc-ti-mcbsp.h
 +#include linux/platform_data/gpio-omap.h
  
  /* Register descriptions for twl4030 codec part */
  #include linux/mfd/twl4030-audio.h
 

I have the same patch stashed away for the same issue. Was waiting for rc1 to
send it.

Acked-by: Peter Ujfalusi peter.ujfal...@ti.com
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] leds: leds-pwm: Convert to use devm_get_pwm

2012-11-07 Thread Peter Ujfalusi
Update the driver to use the new API for requesting pwm so we can take
advantage of the pwm_lookup table to find the correct pwm to be used for the
LED functionality.
If the devm_get_pwm fails we fall back to legacy mode to try to get the pwm.

Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
 drivers/leds/leds-pwm.c | 16 ++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c
index f2e44c7..6bf9445 100644
--- a/drivers/leds/leds-pwm.c
+++ b/drivers/leds/leds-pwm.c
@@ -47,6 +47,19 @@ static void led_pwm_set(struct led_classdev *led_cdev,
}
 }
 
+static struct pwm_device *led_pwm_request_pwm(struct platform_device *pdev,
+ struct led_pwm *cur_led)
+{
+   struct pwm_device *pwm;
+
+   pwm = devm_pwm_get(pdev-dev, cur_led-name);
+   if (IS_ERR(pwm)) {
+   dev_err(pdev-dev, unable to request PWM, trying legacy 
API\n);
+   pwm = pwm_request(cur_led-pwm_id, cur_led-name);
+   }
+   return pwm;
+}
+
 static int led_pwm_probe(struct platform_device *pdev)
 {
struct led_pwm_platform_data *pdata = pdev-dev.platform_data;
@@ -67,8 +80,7 @@ static int led_pwm_probe(struct platform_device *pdev)
cur_led = pdata-leds[i];
led_dat = leds_data[i];
 
-   led_dat-pwm = pwm_request(cur_led-pwm_id,
-   cur_led-name);
+   led_dat-pwm = led_pwm_request_pwm(pdev, cur_led);
if (IS_ERR(led_dat-pwm)) {
ret = PTR_ERR(led_dat-pwm);
dev_err(pdev-dev, unable to request PWM %d\n,
-- 
1.8.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/3] pwm: Drivers for twl4030/6030 PWMs and LEDs

2012-11-07 Thread Peter Ujfalusi
Hello,

The currently available pwm-twl6030.c driver only supports TWL6030's Charging
indication LED.
Remove this driver and add two new ones which implements support for all PWM
driven outputs:
pwm-twl driver supports twl4030 (PWM 0/1) and twl6030 (PWM 1/2) instances
pwm-twl-led driver supports twl4030 (PWM driven LED A/B ports) and twl6030's
Charging indication LED (PWM driven).

Regards,
Peter
---
Peter Ujfalusi (3):
  pwm: Remove pwm-twl6030 driver
  pwm: New driver to support PWMs on TWL4030/6030 series of PMICs
  pwm: New driver to support PWM driven LEDs on TWL4030/6030 series of
PMICs

 drivers/pwm/Kconfig   |  19 ++-
 drivers/pwm/Makefile  |   3 +-
 drivers/pwm/pwm-twl-led.c | 287 +++
 drivers/pwm/pwm-twl.c | 304 ++
 drivers/pwm/pwm-twl6030.c | 184 
 5 files changed, 608 insertions(+), 189 deletions(-)
 create mode 100644 drivers/pwm/pwm-twl-led.c
 create mode 100644 drivers/pwm/pwm-twl.c
 delete mode 100644 drivers/pwm/pwm-twl6030.c

-- 
1.8.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/3] pwm: New driver to support PWMs on TWL4030/6030 series of PMICs

2012-11-07 Thread Peter Ujfalusi
The driver supports the following PWM outputs:
TWL4030 PWM0 and PWM1
TWL6030 PWM1 and PWM2

On TWL4030 the PWM signals are muxed. Upon requesting the PWM the driver
will select the correct mux so the PWM can be used. When the PWM has been
freed the original configuration going to be restored.

Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
 drivers/pwm/Kconfig   |  10 ++
 drivers/pwm/Makefile  |   1 +
 drivers/pwm/pwm-twl.c | 304 ++
 3 files changed, 315 insertions(+)
 create mode 100644 drivers/pwm/pwm-twl.c

diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
index e678005..c577db9 100644
--- a/drivers/pwm/Kconfig
+++ b/drivers/pwm/Kconfig
@@ -142,6 +142,16 @@ config  PWM_TIEHRPWM
  To compile this driver as a module, choose M here: the module
  will be called pwm-tiehrpwm.
 
+config PWM_TWL
+   tristate TWL4030/6030 PWM support
+   select HAVE_PWM
+   depends on TWL4030_CORE
+   help
+ Generic PWM framework driver for TWL4030/6030.
+
+ To compile this driver as a module, choose M here: the module
+ will be called pwm-twl.
+
 config PWM_VT8500
tristate vt8500 pwm support
depends on ARCH_VT8500
diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile
index 29cf57e..3324c06 100644
--- a/drivers/pwm/Makefile
+++ b/drivers/pwm/Makefile
@@ -11,4 +11,5 @@ obj-$(CONFIG_PWM_SAMSUNG) += pwm-samsung.o
 obj-$(CONFIG_PWM_TEGRA)+= pwm-tegra.o
 obj-$(CONFIG_PWM_TIECAP)   += pwm-tiecap.o
 obj-$(CONFIG_PWM_TIEHRPWM) += pwm-tiehrpwm.o
+obj-$(CONFIG_PWM_TWL)  += pwm-twl.o
 obj-$(CONFIG_PWM_VT8500)   += pwm-vt8500.o
diff --git a/drivers/pwm/pwm-twl.c b/drivers/pwm/pwm-twl.c
new file mode 100644
index 000..0821ffe
--- /dev/null
+++ b/drivers/pwm/pwm-twl.c
@@ -0,0 +1,304 @@
+/*
+ * Driver for TWL4030/6030 Generic Pulse Width Modulator
+ *
+ * Copyright (C) 2012 Texas Instruments
+ * Author: Peter Ujfalusi peter.ujfal...@ti.com
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see http://www.gnu.org/licenses/.
+ */
+
+#include linux/module.h
+#include linux/platform_device.h
+#include linux/pwm.h
+#include linux/i2c/twl.h
+#include linux/slab.h
+
+#define TWL_PWM_MAX0x7f
+
+/* Registers, bits and macro for TWL4030 */
+#define TWL4030_GPBR1_REG  0x0c
+#define TWL4030_PMBR1_REG  0x0d
+
+/* GPBR1 register bits */
+#define TWL4030_PWMXCLK_ENABLE (1  0)
+#define TWL4030_PWMX_ENABLE(1  2)
+#define TWL4030_PWMX_BITS  (TWL4030_PWMX_ENABLE | TWL4030_PWMXCLK_ENABLE)
+#define TWL4030_PWM_TOGGLE(pwm, x) ((x)  (pwm))
+
+/* PMBR1 register bits */
+#define TWL4030_GPIO6_PWM0_MUTE_MASK   (0x03  2)
+#define TWL4030_GPIO6_PWM0_MUTE_PWM0   (0x01  2)
+#define TWL4030_GPIO7_VIBRASYNC_PWM1_MASK  (0x03  4)
+#define TWL4030_GPIO7_VIBRASYNC_PWM1_PWM1  (0x03  4)
+
+/* Register, bits and macro for TWL6030 */
+#define TWL6030_TOGGLE3_REG0x92
+
+#define TWL6030_PWMXR  (1  0)
+#define TWL6030_PWMXS  (1  1)
+#define TWL6030_PWMXEN (1  2)
+#define TWL6030_PWM_TOGGLE(pwm, x) ((x)  (pwm * 3))
+
+struct twl_pwm_chip {
+   struct pwm_chip chip;
+   u8 twl6030_toggle3;
+   u8 twl4030_pwm_mux;
+};
+
+static int twl_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
+ int duty_ns, int period_ns)
+{
+   int duty_cycle = (duty_ns * TWL_PWM_MAX) / period_ns;
+   u8 on_time;
+   u8 pwm_config[2];
+   int base, ret;
+
+   if (duty_cycle = TWL_PWM_MAX)
+   on_time = TWL_PWM_MAX;
+   else if (!duty_cycle)
+   on_time = TWL_PWM_MAX - 1;
+   else
+   on_time = TWL_PWM_MAX - duty_cycle;
+
+   base = pwm-hwpwm * 3;
+
+   pwm_config[0] = on_time;
+   pwm_config[1] = TWL_PWM_MAX;
+
+   ret = twl_i2c_write(TWL_MODULE_PWM, pwm_config, base, 2);
+   if (ret  0)
+   dev_err(chip-dev, %s: Failed to configure PWM\n, pwm-label);
+
+   return ret;
+}
+
+static int twl4030_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
+{
+   int ret;
+   u8 val;
+
+   ret = twl_i2c_read_u8(TWL4030_MODULE_INTBR, val, TWL4030_GPBR1_REG);
+   if (ret  0) {
+   dev_err(chip-dev, %s: Failed to read GPBR1\n, pwm-label);
+   return ret;
+   }
+
+   val |= TWL4030_PWM_TOGGLE(pwm-hwpwm, TWL4030_PWMX_BITS);
+
+   ret = twl_i2c_write_u8

[PATCH 3/3] pwm: New driver to support PWM driven LEDs on TWL4030/6030 series of PMICs

2012-11-07 Thread Peter Ujfalusi
The driver supports the following LED outputs as generic PWM driver:
TWL4030 LEDA and LEDB (PWMA and PWMB)
TWL6030 Charging indicator LED (PWM LED)

On TWL6030 when the PWM requested LED is configured to be controlled by SW.
In this case the user can enable/disable and set the duty period freely.
When the PWM has been freed, the LED driver is put back to HW control.

Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
 drivers/pwm/Kconfig   |  10 ++
 drivers/pwm/Makefile  |   1 +
 drivers/pwm/pwm-twl-led.c | 287 ++
 3 files changed, 298 insertions(+)
 create mode 100644 drivers/pwm/pwm-twl-led.c

diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
index c577db9..49c2082 100644
--- a/drivers/pwm/Kconfig
+++ b/drivers/pwm/Kconfig
@@ -152,6 +152,16 @@ config PWM_TWL
  To compile this driver as a module, choose M here: the module
  will be called pwm-twl.
 
+config PWM_TWL_LED
+   tristate TWL4030/6030 PWM support for LED drivers
+   select HAVE_PWM
+   depends on TWL4030_CORE
+   help
+ Generic PWM framework driver for TWL4030/6030 LED.
+
+ To compile this driver as a module, choose M here: the module
+ will be called pwm-twl-led.
+
 config PWM_VT8500
tristate vt8500 pwm support
depends on ARCH_VT8500
diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile
index 3324c06..5f26134 100644
--- a/drivers/pwm/Makefile
+++ b/drivers/pwm/Makefile
@@ -12,4 +12,5 @@ obj-$(CONFIG_PWM_TEGRA)   += pwm-tegra.o
 obj-$(CONFIG_PWM_TIECAP)   += pwm-tiecap.o
 obj-$(CONFIG_PWM_TIEHRPWM) += pwm-tiehrpwm.o
 obj-$(CONFIG_PWM_TWL)  += pwm-twl.o
+obj-$(CONFIG_PWM_TWL_LED)  += pwm-twl-led.o
 obj-$(CONFIG_PWM_VT8500)   += pwm-vt8500.o
diff --git a/drivers/pwm/pwm-twl-led.c b/drivers/pwm/pwm-twl-led.c
new file mode 100644
index 000..4d6ddc9
--- /dev/null
+++ b/drivers/pwm/pwm-twl-led.c
@@ -0,0 +1,287 @@
+/*
+ * Driver for TWL4030/6030 Pulse Width Modulator used as LED driver
+ *
+ * Copyright (C) 2012 Texas Instruments
+ * Author: Peter Ujfalusi peter.ujfal...@ti.com
+ *
+ * This driver is a complete rewrite of the former pwm-twl6030.c authorded by:
+ * Hemanth V heman...@ti.com
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see http://www.gnu.org/licenses/.
+ */
+
+#include linux/module.h
+#include linux/platform_device.h
+#include linux/pwm.h
+#include linux/i2c/twl.h
+#include linux/slab.h
+
+#define TWL4030_LED_MAX0x7f
+#define TWL6030_LED_MAX0xff
+
+/* Registers, bits and macro for TWL4030 */
+#define TWL4030_LEDEN_REG  0x00
+#define TWL4030_PWMA_REG   0x01
+
+#define TWL4030_LEDXON (1  0)
+#define TWL4030_LEDXPWM(1  4)
+#define TWL4030_LED_PINS   (TWL4030_LEDXON | TWL4030_LEDXPWM)
+#define TWL4030_LED_TOGGLE(led, x) ((x)  (led))
+
+/* Register, bits and macro for TWL6030 */
+#define TWL6030_LED_PWM_CTRL1  0xf4
+#define TWL6030_LED_PWM_CTRL2  0xf5
+
+#define TWL6040_LED_MODE_HW0x00
+#define TWL6040_LED_MODE_ON0x01
+#define TWL6040_LED_MODE_OFF   0x02
+#define TWL6040_LED_MODE_MASK  0x03
+
+struct twl_pwmled_chip {
+   struct pwm_chip chip;
+};
+
+static int twl4030_pwmled_config(struct pwm_chip *chip, struct pwm_device *pwm,
+ int duty_ns, int period_ns)
+{
+   int duty_cycle = (duty_ns * TWL4030_LED_MAX) / period_ns;
+   u8 on_time;
+   u8 pwm_config[2];
+   int base, ret;
+
+   if (duty_cycle = TWL4030_LED_MAX)
+   on_time = TWL4030_LED_MAX;
+   else if (!duty_cycle)
+   on_time = TWL4030_LED_MAX - 1;
+   else
+   on_time = TWL4030_LED_MAX - duty_cycle;
+
+   base = pwm-hwpwm * 2 + TWL4030_PWMA_REG;
+
+   pwm_config[0] = on_time;
+   pwm_config[1] = TWL4030_LED_MAX;
+
+   ret = twl_i2c_write(TWL4030_MODULE_LED, pwm_config, base, 2);
+   if (ret  0)
+   dev_err(chip-dev, %s: Failed to configure PWM\n, pwm-label);
+
+   return ret;
+}
+
+static int twl4030_pwmled_enable(struct pwm_chip *chip, struct pwm_device *pwm)
+{
+   int ret;
+   u8 val;
+
+   ret = twl_i2c_read_u8(TWL4030_MODULE_LED, val, TWL4030_LEDEN_REG);
+   if (ret  0) {
+   dev_err(chip-dev, %s: Failed to read LEDEN\n, pwm-label);
+   return ret;
+   }
+
+   val |= TWL4030_LED_TOGGLE(pwm-hwpwm, TWL4030_LED_PINS);
+
+   ret

[PATCH 1/3] pwm: Remove pwm-twl6030 driver

2012-11-07 Thread Peter Ujfalusi
This driver only supported the Charging indicator LED.
New set of drivers going to provide support for both PWMs and LEDs for twl4030
and twl6030 series of PMICs.

Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
 drivers/pwm/Kconfig   |   9 ---
 drivers/pwm/Makefile  |   1 -
 drivers/pwm/pwm-twl6030.c | 184 --
 3 files changed, 194 deletions(-)
 delete mode 100644 drivers/pwm/pwm-twl6030.c

diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
index ed81720..e678005 100644
--- a/drivers/pwm/Kconfig
+++ b/drivers/pwm/Kconfig
@@ -142,15 +142,6 @@ config  PWM_TIEHRPWM
  To compile this driver as a module, choose M here: the module
  will be called pwm-tiehrpwm.
 
-config PWM_TWL6030
-   tristate TWL6030 PWM support
-   depends on TWL4030_CORE
-   help
- Generic PWM framework driver for TWL6030.
-
- To compile this driver as a module, choose M here: the module
- will be called pwm-twl6030.
-
 config PWM_VT8500
tristate vt8500 pwm support
depends on ARCH_VT8500
diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile
index acfe482..29cf57e 100644
--- a/drivers/pwm/Makefile
+++ b/drivers/pwm/Makefile
@@ -11,5 +11,4 @@ obj-$(CONFIG_PWM_SAMSUNG) += pwm-samsung.o
 obj-$(CONFIG_PWM_TEGRA)+= pwm-tegra.o
 obj-$(CONFIG_PWM_TIECAP)   += pwm-tiecap.o
 obj-$(CONFIG_PWM_TIEHRPWM) += pwm-tiehrpwm.o
-obj-$(CONFIG_PWM_TWL6030)  += pwm-twl6030.o
 obj-$(CONFIG_PWM_VT8500)   += pwm-vt8500.o
diff --git a/drivers/pwm/pwm-twl6030.c b/drivers/pwm/pwm-twl6030.c
deleted file mode 100644
index 8e63878..000
--- a/drivers/pwm/pwm-twl6030.c
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * twl6030_pwm.c
- * Driver for PHOENIX (TWL6030) Pulse Width Modulator
- *
- * Copyright (C) 2010 Texas Instruments
- * Author: Hemanth V heman...@ti.com
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published by
- * the Free Software Foundation.
- *
- * 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.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program.  If not, see http://www.gnu.org/licenses/.
- */
-
-#include linux/module.h
-#include linux/platform_device.h
-#include linux/pwm.h
-#include linux/i2c/twl.h
-#include linux/slab.h
-
-#define LED_PWM_CTRL1  0xF4
-#define LED_PWM_CTRL2  0xF5
-
-/* Max value for CTRL1 register */
-#define PWM_CTRL1_MAX  255
-
-/* Pull down disable */
-#define PWM_CTRL2_DIS_PD   (1  6)
-
-/* Current control 2.5 milli Amps */
-#define PWM_CTRL2_CURR_02  (2  4)
-
-/* LED supply source */
-#define PWM_CTRL2_SRC_VAC  (1  2)
-
-/* LED modes */
-#define PWM_CTRL2_MODE_HW  (0  0)
-#define PWM_CTRL2_MODE_SW  (1  0)
-#define PWM_CTRL2_MODE_DIS (2  0)
-
-#define PWM_CTRL2_MODE_MASK0x3
-
-struct twl6030_pwm_chip {
-   struct pwm_chip chip;
-};
-
-static int twl6030_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
-{
-   int ret;
-   u8 val;
-
-   /* Configure PWM */
-   val = PWM_CTRL2_DIS_PD | PWM_CTRL2_CURR_02 | PWM_CTRL2_SRC_VAC |
- PWM_CTRL2_MODE_HW;
-
-   ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, val, LED_PWM_CTRL2);
-   if (ret  0) {
-   dev_err(chip-dev, %s: Failed to configure PWM, Error %d\n,
-   pwm-label, ret);
-   return ret;
-   }
-
-   return 0;
-}
-
-static int twl6030_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
- int duty_ns, int period_ns)
-{
-   u8 duty_cycle = (duty_ns * PWM_CTRL1_MAX) / period_ns;
-   int ret;
-
-   ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, duty_cycle, LED_PWM_CTRL1);
-   if (ret  0) {
-   pr_err(%s: Failed to configure PWM, Error %d\n,
-   pwm-label, ret);
-   return ret;
-   }
-
-   return 0;
-}
-
-static int twl6030_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
-{
-   int ret;
-   u8 val;
-
-   ret = twl_i2c_read_u8(TWL6030_MODULE_ID1, val, LED_PWM_CTRL2);
-   if (ret  0) {
-   dev_err(chip-dev, %s: Failed to enable PWM, Error %d\n,
-   pwm-label, ret);
-   return ret;
-   }
-
-   /* Change mode to software control */
-   val = ~PWM_CTRL2_MODE_MASK;
-   val |= PWM_CTRL2_MODE_SW;
-
-   ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, val, LED_PWM_CTRL2);
-   if (ret  0) {
-   dev_err(chip-dev, %s: Failed to enable PWM, Error %d\n,
-   pwm-label, ret);
-   return ret;
-   }
-
-   twl_i2c_read_u8(TWL6030_MODULE_ID1, val

[PATCH v2 1/3] pwm: Remove pwm-twl6030 driver

2012-11-08 Thread Peter Ujfalusi
This driver only supported the Charging indicator LED.
New set of drivers going to provide support for both PWMs and LEDs for twl4030
and twl6030 series of PMICs.

Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
 drivers/pwm/Kconfig   |   9 ---
 drivers/pwm/Makefile  |   1 -
 drivers/pwm/pwm-twl6030.c | 184 --
 3 files changed, 194 deletions(-)
 delete mode 100644 drivers/pwm/pwm-twl6030.c

diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
index ed81720..e678005 100644
--- a/drivers/pwm/Kconfig
+++ b/drivers/pwm/Kconfig
@@ -142,15 +142,6 @@ config  PWM_TIEHRPWM
  To compile this driver as a module, choose M here: the module
  will be called pwm-tiehrpwm.
 
-config PWM_TWL6030
-   tristate TWL6030 PWM support
-   depends on TWL4030_CORE
-   help
- Generic PWM framework driver for TWL6030.
-
- To compile this driver as a module, choose M here: the module
- will be called pwm-twl6030.
-
 config PWM_VT8500
tristate vt8500 pwm support
depends on ARCH_VT8500
diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile
index acfe482..29cf57e 100644
--- a/drivers/pwm/Makefile
+++ b/drivers/pwm/Makefile
@@ -11,5 +11,4 @@ obj-$(CONFIG_PWM_SAMSUNG) += pwm-samsung.o
 obj-$(CONFIG_PWM_TEGRA)+= pwm-tegra.o
 obj-$(CONFIG_PWM_TIECAP)   += pwm-tiecap.o
 obj-$(CONFIG_PWM_TIEHRPWM) += pwm-tiehrpwm.o
-obj-$(CONFIG_PWM_TWL6030)  += pwm-twl6030.o
 obj-$(CONFIG_PWM_VT8500)   += pwm-vt8500.o
diff --git a/drivers/pwm/pwm-twl6030.c b/drivers/pwm/pwm-twl6030.c
deleted file mode 100644
index 8e63878..000
--- a/drivers/pwm/pwm-twl6030.c
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * twl6030_pwm.c
- * Driver for PHOENIX (TWL6030) Pulse Width Modulator
- *
- * Copyright (C) 2010 Texas Instruments
- * Author: Hemanth V heman...@ti.com
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published by
- * the Free Software Foundation.
- *
- * 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.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program.  If not, see http://www.gnu.org/licenses/.
- */
-
-#include linux/module.h
-#include linux/platform_device.h
-#include linux/pwm.h
-#include linux/i2c/twl.h
-#include linux/slab.h
-
-#define LED_PWM_CTRL1  0xF4
-#define LED_PWM_CTRL2  0xF5
-
-/* Max value for CTRL1 register */
-#define PWM_CTRL1_MAX  255
-
-/* Pull down disable */
-#define PWM_CTRL2_DIS_PD   (1  6)
-
-/* Current control 2.5 milli Amps */
-#define PWM_CTRL2_CURR_02  (2  4)
-
-/* LED supply source */
-#define PWM_CTRL2_SRC_VAC  (1  2)
-
-/* LED modes */
-#define PWM_CTRL2_MODE_HW  (0  0)
-#define PWM_CTRL2_MODE_SW  (1  0)
-#define PWM_CTRL2_MODE_DIS (2  0)
-
-#define PWM_CTRL2_MODE_MASK0x3
-
-struct twl6030_pwm_chip {
-   struct pwm_chip chip;
-};
-
-static int twl6030_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
-{
-   int ret;
-   u8 val;
-
-   /* Configure PWM */
-   val = PWM_CTRL2_DIS_PD | PWM_CTRL2_CURR_02 | PWM_CTRL2_SRC_VAC |
- PWM_CTRL2_MODE_HW;
-
-   ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, val, LED_PWM_CTRL2);
-   if (ret  0) {
-   dev_err(chip-dev, %s: Failed to configure PWM, Error %d\n,
-   pwm-label, ret);
-   return ret;
-   }
-
-   return 0;
-}
-
-static int twl6030_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
- int duty_ns, int period_ns)
-{
-   u8 duty_cycle = (duty_ns * PWM_CTRL1_MAX) / period_ns;
-   int ret;
-
-   ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, duty_cycle, LED_PWM_CTRL1);
-   if (ret  0) {
-   pr_err(%s: Failed to configure PWM, Error %d\n,
-   pwm-label, ret);
-   return ret;
-   }
-
-   return 0;
-}
-
-static int twl6030_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
-{
-   int ret;
-   u8 val;
-
-   ret = twl_i2c_read_u8(TWL6030_MODULE_ID1, val, LED_PWM_CTRL2);
-   if (ret  0) {
-   dev_err(chip-dev, %s: Failed to enable PWM, Error %d\n,
-   pwm-label, ret);
-   return ret;
-   }
-
-   /* Change mode to software control */
-   val = ~PWM_CTRL2_MODE_MASK;
-   val |= PWM_CTRL2_MODE_SW;
-
-   ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, val, LED_PWM_CTRL2);
-   if (ret  0) {
-   dev_err(chip-dev, %s: Failed to enable PWM, Error %d\n,
-   pwm-label, ret);
-   return ret;
-   }
-
-   twl_i2c_read_u8(TWL6030_MODULE_ID1, val

[PATCH v2 3/3] pwm: New driver to support PWM driven LEDs on TWL4030/6030 series of PMICs

2012-11-08 Thread Peter Ujfalusi
The driver supports the following LED outputs as generic PWM driver:
TWL4030 LEDA and LEDB (PWMA and PWMB)
TWL6030 Charging indicator LED (PWM LED)

On TWL6030 when the PWM requested LED is configured to be controlled by SW.
In this case the user can enable/disable and set the duty period freely.
When the PWM has been freed, the LED driver is put back to HW control.

Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
 drivers/pwm/Kconfig   |  10 ++
 drivers/pwm/Makefile  |   1 +
 drivers/pwm/pwm-twl-led.c | 295 ++
 3 files changed, 306 insertions(+)
 create mode 100644 drivers/pwm/pwm-twl-led.c

diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
index c577db9..49c2082 100644
--- a/drivers/pwm/Kconfig
+++ b/drivers/pwm/Kconfig
@@ -152,6 +152,16 @@ config PWM_TWL
  To compile this driver as a module, choose M here: the module
  will be called pwm-twl.
 
+config PWM_TWL_LED
+   tristate TWL4030/6030 PWM support for LED drivers
+   select HAVE_PWM
+   depends on TWL4030_CORE
+   help
+ Generic PWM framework driver for TWL4030/6030 LED.
+
+ To compile this driver as a module, choose M here: the module
+ will be called pwm-twl-led.
+
 config PWM_VT8500
tristate vt8500 pwm support
depends on ARCH_VT8500
diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile
index 3324c06..5f26134 100644
--- a/drivers/pwm/Makefile
+++ b/drivers/pwm/Makefile
@@ -12,4 +12,5 @@ obj-$(CONFIG_PWM_TEGRA)   += pwm-tegra.o
 obj-$(CONFIG_PWM_TIECAP)   += pwm-tiecap.o
 obj-$(CONFIG_PWM_TIEHRPWM) += pwm-tiehrpwm.o
 obj-$(CONFIG_PWM_TWL)  += pwm-twl.o
+obj-$(CONFIG_PWM_TWL_LED)  += pwm-twl-led.o
 obj-$(CONFIG_PWM_VT8500)   += pwm-vt8500.o
diff --git a/drivers/pwm/pwm-twl-led.c b/drivers/pwm/pwm-twl-led.c
new file mode 100644
index 000..a9cadd8
--- /dev/null
+++ b/drivers/pwm/pwm-twl-led.c
@@ -0,0 +1,295 @@
+/*
+ * Driver for TWL4030/6030 Pulse Width Modulator used as LED driver
+ *
+ * Copyright (C) 2012 Texas Instruments
+ * Author: Peter Ujfalusi peter.ujfal...@ti.com
+ *
+ * This driver is a complete rewrite of the former pwm-twl6030.c authorded by:
+ * Hemanth V heman...@ti.com
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see http://www.gnu.org/licenses/.
+ */
+
+#include linux/module.h
+#include linux/platform_device.h
+#include linux/pwm.h
+#include linux/i2c/twl.h
+#include linux/slab.h
+
+/*
+ * This driver handles the PWM driven LED terminals of TWL4030 and TWL6030.
+ * To generate the signal on TWL4030:
+ *  - LEDA uses PWMA
+ *  - LEDB uses PWMB
+ * TWL6030 has one LED pin with dedicated LEDPWM
+ */
+
+#define TWL4030_LED_MAX0x7f
+#define TWL6030_LED_MAX0xff
+
+/* Registers, bits and macro for TWL4030 */
+#define TWL4030_LEDEN_REG  0x00
+#define TWL4030_PWMA_REG   0x01
+
+#define TWL4030_LEDXON (1  0)
+#define TWL4030_LEDXPWM(1  4)
+#define TWL4030_LED_PINS   (TWL4030_LEDXON | TWL4030_LEDXPWM)
+#define TWL4030_LED_TOGGLE(led, x) ((x)  (led))
+
+/* Register, bits and macro for TWL6030 */
+#define TWL6030_LED_PWM_CTRL1  0xf4
+#define TWL6030_LED_PWM_CTRL2  0xf5
+
+#define TWL6040_LED_MODE_HW0x00
+#define TWL6040_LED_MODE_ON0x01
+#define TWL6040_LED_MODE_OFF   0x02
+#define TWL6040_LED_MODE_MASK  0x03
+
+struct twl_pwmled_chip {
+   struct pwm_chip chip;
+};
+
+static int twl4030_pwmled_config(struct pwm_chip *chip, struct pwm_device *pwm,
+ int duty_ns, int period_ns)
+{
+   int duty_cycle = (duty_ns * TWL4030_LED_MAX) / period_ns;
+   u8 on_time;
+   u8 pwm_config[2];
+   int base, ret;
+
+   if (duty_cycle = TWL4030_LED_MAX)
+   on_time = TWL4030_LED_MAX;
+   else if (!duty_cycle)
+   on_time = TWL4030_LED_MAX - 1;
+   else
+   on_time = TWL4030_LED_MAX - duty_cycle;
+
+   base = pwm-hwpwm * 2 + TWL4030_PWMA_REG;
+
+   pwm_config[0] = on_time;
+   pwm_config[1] = TWL4030_LED_MAX;
+
+   ret = twl_i2c_write(TWL4030_MODULE_LED, pwm_config, base, 2);
+   if (ret  0)
+   dev_err(chip-dev, %s: Failed to configure PWM\n, pwm-label);
+
+   return ret;
+}
+
+static int twl4030_pwmled_enable(struct pwm_chip *chip, struct pwm_device *pwm)
+{
+   int ret;
+   u8 val;
+
+   ret = twl_i2c_read_u8(TWL4030_MODULE_LED, val, TWL4030_LEDEN_REG

[PATCH v2 0/3] pwm: Drivers for twl4030/6030 PWMs and LEDs

2012-11-08 Thread Peter Ujfalusi
Hello,

Changes cince v1:
- The turn on/off sequence has been corrected for twl4030 PWMs as suggested by
  Grazvydas Ignotas
- Comment section added to the new drivers to describe what they are controlling

The series has been tested (with additional, pending patches):
Zoom2 for twl4030 PWM0 (keypad light), PWM1 (LCD backlight)
BeagleBoard for twl4030 LEDB (PWMB - pmu_stat led)
OMAP4 Blaze (SDP4430) for twl6030 PWM1 (keypad light), PWM2 (LCD backlight) and
LED (charging indication led).

Intro mail from v1:

The currently available pwm-twl6030.c driver only supports TWL6030's Charging
indication LED.
Remove this driver and add two new ones which implements support for all PWM
driven outputs:
pwm-twl driver supports twl4030 (PWM 0/1) and twl6030 (PWM 1/2) instances
pwm-twl-led driver supports twl4030 (PWM driven LED A/B ports) and twl6030's
Charging indication LED (PWM driven).

Regards,
Peter
---
Peter Ujfalusi (3):
  pwm: Remove pwm-twl6030 driver
  pwm: New driver to support PWMs on TWL4030/6030 series of PMICs
  pwm: New driver to support PWM driven LEDs on TWL4030/6030 series of
PMICs

 drivers/pwm/Kconfig   |  19 ++-
 drivers/pwm/Makefile  |   3 +-
 drivers/pwm/pwm-twl-led.c | 295 ++
 drivers/pwm/pwm-twl.c | 322 ++
 drivers/pwm/pwm-twl6030.c | 184 --
 5 files changed, 634 insertions(+), 189 deletions(-)
 create mode 100644 drivers/pwm/pwm-twl-led.c
 create mode 100644 drivers/pwm/pwm-twl.c
 delete mode 100644 drivers/pwm/pwm-twl6030.c

-- 
1.8.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 2/3] pwm: New driver to support PWMs on TWL4030/6030 series of PMICs

2012-11-08 Thread Peter Ujfalusi
The driver supports the following PWM outputs:
TWL4030 PWM0 and PWM1
TWL6030 PWM1 and PWM2

On TWL4030 the PWM signals are muxed. Upon requesting the PWM the driver
will select the correct mux so the PWM can be used. When the PWM has been
freed the original configuration going to be restored.

Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
 drivers/pwm/Kconfig   |  10 ++
 drivers/pwm/Makefile  |   1 +
 drivers/pwm/pwm-twl.c | 322 ++
 3 files changed, 333 insertions(+)
 create mode 100644 drivers/pwm/pwm-twl.c

diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
index e678005..c577db9 100644
--- a/drivers/pwm/Kconfig
+++ b/drivers/pwm/Kconfig
@@ -142,6 +142,16 @@ config  PWM_TIEHRPWM
  To compile this driver as a module, choose M here: the module
  will be called pwm-tiehrpwm.
 
+config PWM_TWL
+   tristate TWL4030/6030 PWM support
+   select HAVE_PWM
+   depends on TWL4030_CORE
+   help
+ Generic PWM framework driver for TWL4030/6030.
+
+ To compile this driver as a module, choose M here: the module
+ will be called pwm-twl.
+
 config PWM_VT8500
tristate vt8500 pwm support
depends on ARCH_VT8500
diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile
index 29cf57e..3324c06 100644
--- a/drivers/pwm/Makefile
+++ b/drivers/pwm/Makefile
@@ -11,4 +11,5 @@ obj-$(CONFIG_PWM_SAMSUNG) += pwm-samsung.o
 obj-$(CONFIG_PWM_TEGRA)+= pwm-tegra.o
 obj-$(CONFIG_PWM_TIECAP)   += pwm-tiecap.o
 obj-$(CONFIG_PWM_TIEHRPWM) += pwm-tiehrpwm.o
+obj-$(CONFIG_PWM_TWL)  += pwm-twl.o
 obj-$(CONFIG_PWM_VT8500)   += pwm-vt8500.o
diff --git a/drivers/pwm/pwm-twl.c b/drivers/pwm/pwm-twl.c
new file mode 100644
index 000..26e57e9
--- /dev/null
+++ b/drivers/pwm/pwm-twl.c
@@ -0,0 +1,322 @@
+/*
+ * Driver for TWL4030/6030 Generic Pulse Width Modulator
+ *
+ * Copyright (C) 2012 Texas Instruments
+ * Author: Peter Ujfalusi peter.ujfal...@ti.com
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see http://www.gnu.org/licenses/.
+ */
+
+#include linux/module.h
+#include linux/platform_device.h
+#include linux/pwm.h
+#include linux/i2c/twl.h
+#include linux/slab.h
+
+/*
+ * This driver handles the PWMs of TWL4030 and TWL6030.
+ * The TRM names for the PWMs on TWL4030 are: PWM0, PWM1
+ * TWL6030 also have two PWMs named in the TRM as PWM1, PWM2
+ */
+
+#define TWL_PWM_MAX0x7f
+
+/* Registers, bits and macro for TWL4030 */
+#define TWL4030_GPBR1_REG  0x0c
+#define TWL4030_PMBR1_REG  0x0d
+
+/* GPBR1 register bits */
+#define TWL4030_PWMXCLK_ENABLE (1  0)
+#define TWL4030_PWMX_ENABLE(1  2)
+#define TWL4030_PWMX_BITS  (TWL4030_PWMX_ENABLE | TWL4030_PWMXCLK_ENABLE)
+#define TWL4030_PWM_TOGGLE(pwm, x) ((x)  (pwm))
+
+/* PMBR1 register bits */
+#define TWL4030_GPIO6_PWM0_MUTE_MASK   (0x03  2)
+#define TWL4030_GPIO6_PWM0_MUTE_PWM0   (0x01  2)
+#define TWL4030_GPIO7_VIBRASYNC_PWM1_MASK  (0x03  4)
+#define TWL4030_GPIO7_VIBRASYNC_PWM1_PWM1  (0x03  4)
+
+/* Register, bits and macro for TWL6030 */
+#define TWL6030_TOGGLE3_REG0x92
+
+#define TWL6030_PWMXR  (1  0)
+#define TWL6030_PWMXS  (1  1)
+#define TWL6030_PWMXEN (1  2)
+#define TWL6030_PWM_TOGGLE(pwm, x) ((x)  (pwm * 3))
+
+struct twl_pwm_chip {
+   struct pwm_chip chip;
+   u8 twl6030_toggle3;
+   u8 twl4030_pwm_mux;
+};
+
+static int twl_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
+ int duty_ns, int period_ns)
+{
+   int duty_cycle = (duty_ns * TWL_PWM_MAX) / period_ns;
+   u8 on_time;
+   u8 pwm_config[2];
+   int base, ret;
+
+   if (duty_cycle = TWL_PWM_MAX)
+   on_time = TWL_PWM_MAX;
+   else if (!duty_cycle)
+   on_time = TWL_PWM_MAX - 1;
+   else
+   on_time = TWL_PWM_MAX - duty_cycle;
+
+   base = pwm-hwpwm * 3;
+
+   pwm_config[0] = on_time;
+   pwm_config[1] = TWL_PWM_MAX;
+
+   ret = twl_i2c_write(TWL_MODULE_PWM, pwm_config, base, 2);
+   if (ret  0)
+   dev_err(chip-dev, %s: Failed to configure PWM\n, pwm-label);
+
+   return ret;
+}
+
+static int twl4030_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
+{
+   int ret;
+   u8 val;
+
+   ret = twl_i2c_read_u8(TWL4030_MODULE_INTBR, val, TWL4030_GPBR1_REG);
+   if (ret  0) {
+   dev_err(chip-dev

[PATCH 2/6] MFD: twl6040: Remove unused parameter for twl6040_power_up_completion()

2012-10-11 Thread Peter Ujfalusi
naudint parameter has not been used, remove it.

Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
 drivers/mfd/twl6040-core.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/mfd/twl6040-core.c b/drivers/mfd/twl6040-core.c
index b220aa2..a46d987 100644
--- a/drivers/mfd/twl6040-core.c
+++ b/drivers/mfd/twl6040-core.c
@@ -218,8 +218,7 @@ static irqreturn_t twl6040_naudint_handler(int irq, void 
*data)
return IRQ_HANDLED;
 }
 
-static int twl6040_power_up_completion(struct twl6040 *twl6040,
-  int naudint)
+static int twl6040_power_up_completion(struct twl6040 *twl6040)
 {
int time_left;
u8 intid;
@@ -241,7 +240,6 @@ static int twl6040_power_up_completion(struct twl6040 
*twl6040,
 int twl6040_power(struct twl6040 *twl6040, int on)
 {
int audpwron = twl6040-audpwron;
-   int naudint = twl6040-irq;
int ret = 0;
 
mutex_lock(twl6040-mutex);
@@ -255,7 +253,7 @@ int twl6040_power(struct twl6040 *twl6040, int on)
/* use AUDPWRON line */
gpio_set_value(audpwron, 1);
/* wait for power-up completion */
-   ret = twl6040_power_up_completion(twl6040, naudint);
+   ret = twl6040_power_up_completion(twl6040);
if (ret) {
dev_err(twl6040-dev,
automatic power-up failed\n);
-- 
1.7.12

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 6/6] MFD: twl6040: Rename the core driver

2012-10-11 Thread Peter Ujfalusi
After the regmap_irq conversion there is no need to call the driver
as twl6040-core.c since there is only one c file remained.

Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
 drivers/mfd/Makefile  | 2 +-
 drivers/mfd/{twl6040-core.c = twl6040.c} | 0
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename drivers/mfd/{twl6040-core.c = twl6040.c} (100%)

diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 360233f..8c8331b 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -63,7 +63,7 @@ obj-$(CONFIG_TWL4030_CORE)+= twl-core.o twl4030-irq.o 
twl6030-irq.o
 obj-$(CONFIG_TWL4030_MADC)  += twl4030-madc.o
 obj-$(CONFIG_TWL4030_POWER)+= twl4030-power.o
 obj-$(CONFIG_MFD_TWL4030_AUDIO)+= twl4030-audio.o
-obj-$(CONFIG_TWL6040_CORE) += twl6040-core.o
+obj-$(CONFIG_TWL6040_CORE) += twl6040.o
 
 obj-$(CONFIG_MFD_MC13XXX)  += mc13xxx-core.o
 obj-$(CONFIG_MFD_MC13XXX_SPI)  += mc13xxx-spi.o
diff --git a/drivers/mfd/twl6040-core.c b/drivers/mfd/twl6040.c
similarity index 100%
rename from drivers/mfd/twl6040-core.c
rename to drivers/mfd/twl6040.c
-- 
1.7.12

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/6] MFD: twl6040: Conversion to use regmap_irq

2012-10-11 Thread Peter Ujfalusi
Hello,

This series will convert the twl6040 MFD core driver to use regmap_irq instead
of the custom interrupt code it used. In this way considerable amount of code
can be removed and we are going to use common, well tested code for the 
interrupt
dispatch.

The series is for 3.8.

Regards,
Peter
---
Peter Ujfalusi (6):
  MFD: twl6040: Fix typo for power on failure
  MFD: twl6040: Remove unused parameter for
twl6040_power_up_completion()
  MFD: twl6040: Restructure power up and down code
  MFD: twl6040: Correct Ready and Thermal interrupt handling
  MFD: twl6040: Convert to use regmap_irq
  MFD: twl6040: Rename the core driver

 drivers/mfd/Kconfig   |   4 +-
 drivers/mfd/Makefile  |   2 +-
 drivers/mfd/twl6040-irq.c | 205 --
 drivers/mfd/{twl6040-core.c = twl6040.c} | 137 
 include/linux/mfd/twl6040.h   |  10 +-
 5 files changed, 92 insertions(+), 266 deletions(-)
 delete mode 100644 drivers/mfd/twl6040-irq.c
 rename drivers/mfd/{twl6040-core.c = twl6040.c} (84%)

-- 
1.7.12

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/6] MFD: twl6040: Fix typo for power on failure

2012-10-11 Thread Peter Ujfalusi
Fix old copy paste bug:
automatic power-down failed - automatic power-up failed

Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
 drivers/mfd/twl6040-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mfd/twl6040-core.c b/drivers/mfd/twl6040-core.c
index 3f2a1cf..b220aa2 100644
--- a/drivers/mfd/twl6040-core.c
+++ b/drivers/mfd/twl6040-core.c
@@ -258,7 +258,7 @@ int twl6040_power(struct twl6040 *twl6040, int on)
ret = twl6040_power_up_completion(twl6040, naudint);
if (ret) {
dev_err(twl6040-dev,
-   automatic power-down failed\n);
+   automatic power-up failed\n);
twl6040-power_count = 0;
goto out;
}
-- 
1.7.12

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 5/6] MFD: twl6040: Convert to use regmap_irq

2012-10-11 Thread Peter Ujfalusi
With regmap_irq it is possibole to remove the twl6040-irq.c file and
simplify the code.

Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
 drivers/mfd/Kconfig |   4 +-
 drivers/mfd/Makefile|   2 +-
 drivers/mfd/twl6040-core.c  |  55 
 drivers/mfd/twl6040-irq.c   | 205 
 include/linux/mfd/twl6040.h |  10 +--
 5 files changed, 48 insertions(+), 228 deletions(-)
 delete mode 100644 drivers/mfd/twl6040-irq.c

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index acab3ef..a0d0758 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -300,10 +300,10 @@ config MFD_TWL4030_AUDIO
 
 config TWL6040_CORE
bool Support for TWL6040 audio codec
-   depends on I2C=y  GENERIC_HARDIRQS
+   depends on I2C=y
select MFD_CORE
select REGMAP_I2C
-   select IRQ_DOMAIN
+   select REGMAP_IRQ
default n
help
  Say yes here if you want support for Texas Instruments TWL6040 audio
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index d8ccb63..360233f 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -63,7 +63,7 @@ obj-$(CONFIG_TWL4030_CORE)+= twl-core.o twl4030-irq.o 
twl6030-irq.o
 obj-$(CONFIG_TWL4030_MADC)  += twl4030-madc.o
 obj-$(CONFIG_TWL4030_POWER)+= twl4030-power.o
 obj-$(CONFIG_MFD_TWL4030_AUDIO)+= twl4030-audio.o
-obj-$(CONFIG_TWL6040_CORE) += twl6040-core.o twl6040-irq.o
+obj-$(CONFIG_TWL6040_CORE) += twl6040-core.o
 
 obj-$(CONFIG_MFD_MC13XXX)  += mc13xxx-core.o
 obj-$(CONFIG_MFD_MC13XXX_SPI)  += mc13xxx-spi.o
diff --git a/drivers/mfd/twl6040-core.c b/drivers/mfd/twl6040-core.c
index 5817bc6..e5f7b79 100644
--- a/drivers/mfd/twl6040-core.c
+++ b/drivers/mfd/twl6040-core.c
@@ -499,6 +499,25 @@ static struct regmap_config twl6040_regmap_config = {
.readable_reg = twl6040_readable_reg,
 };
 
+static const struct regmap_irq twl6040_irqs[] = {
+   { .reg_offset = 0, .mask = TWL6040_THINT, },
+   { .reg_offset = 0, .mask = TWL6040_PLUGINT | TWL6040_UNPLUGINT, },
+   { .reg_offset = 0, .mask = TWL6040_HOOKINT, },
+   { .reg_offset = 0, .mask = TWL6040_HFINT, },
+   { .reg_offset = 0, .mask = TWL6040_VIBINT, },
+   { .reg_offset = 0, .mask = TWL6040_READYINT, },
+};
+
+static struct regmap_irq_chip twl6040_irq_chip = {
+   .name = twl6040,
+   .irqs = twl6040_irqs,
+   .num_irqs = ARRAY_SIZE(twl6040_irqs),
+
+   .num_regs = 1,
+   .status_base = TWL6040_REG_INTID,
+   .mask_base = TWL6040_REG_INTMR,
+};
+
 static int __devinit twl6040_probe(struct i2c_client *client,
 const struct i2c_device_id *id)
 {
@@ -574,21 +593,27 @@ static int __devinit twl6040_probe(struct i2c_client 
*client,
goto gpio_err;
}
 
-   /* codec interrupt */
-   ret = twl6040_irq_init(twl6040);
-   if (ret)
+   ret = regmap_add_irq_chip(twl6040-regmap, twl6040-irq,
+   IRQF_ONESHOT, 0, twl6040_irq_chip,
+   twl6040-irq_data);
+   if (ret  0)
goto irq_init_err;
 
-   ret = request_threaded_irq(twl6040-irq_base + TWL6040_IRQ_READY,
-  NULL, twl6040_readyint_handler, IRQF_ONESHOT,
+   twl6040-irq_ready = regmap_irq_get_virq(twl6040-irq_data,
+  TWL6040_IRQ_READY);
+   twl6040-irq_th = regmap_irq_get_virq(twl6040-irq_data,
+  TWL6040_IRQ_TH);
+
+   ret = request_threaded_irq(twl6040-irq_ready, NULL,
+  twl6040_readyint_handler, IRQF_ONESHOT,
   twl6040_irq_ready, twl6040);
if (ret) {
dev_err(twl6040-dev, READY IRQ request failed: %d\n, ret);
goto readyirq_err;
}
 
-   ret = request_threaded_irq(twl6040-irq_base + TWL6040_IRQ_TH,
-  NULL, twl6040_thint_handler, IRQF_ONESHOT,
+   ret = request_threaded_irq(twl6040-irq_th, NULL,
+  twl6040_thint_handler, IRQF_ONESHOT,
   twl6040_irq_th, twl6040);
if (ret) {
dev_err(twl6040-dev, Thermal IRQ request failed: %d\n, ret);
@@ -604,7 +629,7 @@ static int __devinit twl6040_probe(struct i2c_client 
*client,
 * The ASoC codec can work without pdata, pass the platform_data only if
 * it has been provided.
 */
-   irq = twl6040-irq_base + TWL6040_IRQ_PLUG;
+   irq = regmap_irq_get_virq(twl6040-irq_data, TWL6040_IRQ_PLUG);
cell = twl6040-cells[children];
cell-name = twl6040-codec;
twl6040_codec_rsrc[0].start = irq;
@@ -618,7 +643,7 @@ static int __devinit twl6040_probe(struct i2c_client 
*client,
children++;
 
if (twl6040_has_vibra(pdata, node)) {
-   irq = twl6040-irq_base

[PATCH 4/6] MFD: twl6040: Correct Ready and Thermal interrupt handling

2012-10-11 Thread Peter Ujfalusi
Create new irq handler for thermal events in order to be able to handle the
event and clean up the code regarding to interrupt handling:
Use proper function names for the irq handlers
No need to read the INTD register anymore.

Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
 drivers/mfd/twl6040-core.c | 52 +++---
 1 file changed, 31 insertions(+), 21 deletions(-)

diff --git a/drivers/mfd/twl6040-core.c b/drivers/mfd/twl6040-core.c
index 6d9db27..5817bc6 100644
--- a/drivers/mfd/twl6040-core.c
+++ b/drivers/mfd/twl6040-core.c
@@ -193,27 +193,27 @@ static void twl6040_power_down_manual(struct twl6040 
*twl6040)
twl6040_reg_write(twl6040, TWL6040_REG_LDOCTL, ldoctl);
 }
 
-static irqreturn_t twl6040_naudint_handler(int irq, void *data)
+static irqreturn_t twl6040_readyint_handler(int irq, void *data)
 {
struct twl6040 *twl6040 = data;
-   u8 intid, status;
 
-   intid = twl6040_reg_read(twl6040, TWL6040_REG_INTID);
+   complete(twl6040-ready);
 
-   if (intid  TWL6040_READYINT)
-   complete(twl6040-ready);
+   return IRQ_HANDLED;
+}
 
-   if (intid  TWL6040_THINT) {
-   status = twl6040_reg_read(twl6040, TWL6040_REG_STATUS);
-   if (status  TWL6040_TSHUTDET) {
-   dev_warn(twl6040-dev,
-Thermal shutdown, powering-off);
-   twl6040_power(twl6040, 0);
-   } else {
-   dev_warn(twl6040-dev,
-Leaving thermal shutdown, powering-on);
-   twl6040_power(twl6040, 1);
-   }
+static irqreturn_t twl6040_thint_handler(int irq, void *data)
+{
+   struct twl6040 *twl6040 = data;
+   u8 status;
+
+   status = twl6040_reg_read(twl6040, TWL6040_REG_STATUS);
+   if (status  TWL6040_TSHUTDET) {
+   dev_warn(twl6040-dev, Thermal shutdown, powering-off);
+   twl6040_power(twl6040, 0);
+   } else {
+   dev_warn(twl6040-dev, Leaving thermal shutdown, powering-on);
+   twl6040_power(twl6040, 1);
}
 
return IRQ_HANDLED;
@@ -580,12 +580,19 @@ static int __devinit twl6040_probe(struct i2c_client 
*client,
goto irq_init_err;
 
ret = request_threaded_irq(twl6040-irq_base + TWL6040_IRQ_READY,
-  NULL, twl6040_naudint_handler, IRQF_ONESHOT,
+  NULL, twl6040_readyint_handler, IRQF_ONESHOT,
   twl6040_irq_ready, twl6040);
if (ret) {
-   dev_err(twl6040-dev, READY IRQ request failed: %d\n,
-   ret);
-   goto irq_err;
+   dev_err(twl6040-dev, READY IRQ request failed: %d\n, ret);
+   goto readyirq_err;
+   }
+
+   ret = request_threaded_irq(twl6040-irq_base + TWL6040_IRQ_TH,
+  NULL, twl6040_thint_handler, IRQF_ONESHOT,
+  twl6040_irq_th, twl6040);
+   if (ret) {
+   dev_err(twl6040-dev, Thermal IRQ request failed: %d\n, ret);
+   goto thirq_err;
}
 
/* dual-access registers controlled by I2C only */
@@ -650,8 +657,10 @@ static int __devinit twl6040_probe(struct i2c_client 
*client,
return 0;
 
 mfd_err:
+   free_irq(twl6040-irq_base + TWL6040_IRQ_TH, twl6040);
+thirq_err:
free_irq(twl6040-irq_base + TWL6040_IRQ_READY, twl6040);
-irq_err:
+readyirq_err:
twl6040_irq_exit(twl6040);
 irq_init_err:
if (gpio_is_valid(twl6040-audpwron))
@@ -677,6 +686,7 @@ static int __devexit twl6040_remove(struct i2c_client 
*client)
gpio_free(twl6040-audpwron);
 
free_irq(twl6040-irq_base + TWL6040_IRQ_READY, twl6040);
+   free_irq(twl6040-irq_base + TWL6040_IRQ_TH, twl6040);
twl6040_irq_exit(twl6040);
 
mfd_remove_devices(client-dev);
-- 
1.7.12

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/6] MFD: twl6040: Restructure power up and down code

2012-10-11 Thread Peter Ujfalusi
Rearrange the code path for power up and down sequence.

Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
 drivers/mfd/twl6040-core.c | 38 ++
 1 file changed, 18 insertions(+), 20 deletions(-)

diff --git a/drivers/mfd/twl6040-core.c b/drivers/mfd/twl6040-core.c
index a46d987..6d9db27 100644
--- a/drivers/mfd/twl6040-core.c
+++ b/drivers/mfd/twl6040-core.c
@@ -104,7 +104,7 @@ int twl6040_clear_bits(struct twl6040 *twl6040, unsigned 
int reg, u8 mask)
 EXPORT_SYMBOL(twl6040_clear_bits);
 
 /* twl6040 codec manual power-up sequence */
-static int twl6040_power_up(struct twl6040 *twl6040)
+static int twl6040_power_up_manual(struct twl6040 *twl6040)
 {
u8 ldoctl, ncpctl, lppllctl;
int ret;
@@ -158,11 +158,12 @@ ncp_err:
ldoctl = ~(TWL6040_HSLDOENA | TWL6040_REFENA | TWL6040_OSCENA);
twl6040_reg_write(twl6040, TWL6040_REG_LDOCTL, ldoctl);
 
+   dev_err(twl6040-dev, manual power-up failed\n);
return ret;
 }
 
 /* twl6040 manual power-down sequence */
-static void twl6040_power_down(struct twl6040 *twl6040)
+static void twl6040_power_down_manual(struct twl6040 *twl6040)
 {
u8 ncpctl, ldoctl, lppllctl;
 
@@ -218,18 +219,22 @@ static irqreturn_t twl6040_naudint_handler(int irq, void 
*data)
return IRQ_HANDLED;
 }
 
-static int twl6040_power_up_completion(struct twl6040 *twl6040)
+static int twl6040_power_up_automatic(struct twl6040 *twl6040)
 {
int time_left;
-   u8 intid;
+
+   gpio_set_value(twl6040-audpwron, 1);
 
time_left = wait_for_completion_timeout(twl6040-ready,
msecs_to_jiffies(144));
if (!time_left) {
+   u8 intid;
+
+   dev_warn(twl6040-dev, timeout waiting for READYINT\n);
intid = twl6040_reg_read(twl6040, TWL6040_REG_INTID);
if (!(intid  TWL6040_READYINT)) {
-   dev_err(twl6040-dev,
-   timeout waiting for READYINT\n);
+   dev_err(twl6040-dev, automatic power-up failed\n);
+   gpio_set_value(twl6040-audpwron, 0);
return -ETIMEDOUT;
}
}
@@ -239,7 +244,6 @@ static int twl6040_power_up_completion(struct twl6040 
*twl6040)
 
 int twl6040_power(struct twl6040 *twl6040, int on)
 {
-   int audpwron = twl6040-audpwron;
int ret = 0;
 
mutex_lock(twl6040-mutex);
@@ -249,23 +253,17 @@ int twl6040_power(struct twl6040 *twl6040, int on)
if (twl6040-power_count++)
goto out;
 
-   if (gpio_is_valid(audpwron)) {
-   /* use AUDPWRON line */
-   gpio_set_value(audpwron, 1);
-   /* wait for power-up completion */
-   ret = twl6040_power_up_completion(twl6040);
+   if (gpio_is_valid(twl6040-audpwron)) {
+   /* use automatic power-up sequence */
+   ret = twl6040_power_up_automatic(twl6040);
if (ret) {
-   dev_err(twl6040-dev,
-   automatic power-up failed\n);
twl6040-power_count = 0;
goto out;
}
} else {
/* use manual power-up sequence */
-   ret = twl6040_power_up(twl6040);
+   ret = twl6040_power_up_manual(twl6040);
if (ret) {
-   dev_err(twl6040-dev,
-   manual power-up failed\n);
twl6040-power_count = 0;
goto out;
}
@@ -286,15 +284,15 @@ int twl6040_power(struct twl6040 *twl6040, int on)
if (--twl6040-power_count)
goto out;
 
-   if (gpio_is_valid(audpwron)) {
+   if (gpio_is_valid(twl6040-audpwron)) {
/* use AUDPWRON line */
-   gpio_set_value(audpwron, 0);
+   gpio_set_value(twl6040-audpwron, 0);
 
/* power-down sequence latency */
usleep_range(500, 700);
} else {
/* use manual power-down sequence */
-   twl6040_power_down(twl6040);
+   twl6040_power_down_manual(twl6040);
}
twl6040-sysclk = 0;
twl6040-mclk = 0;
-- 
1.7.12

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] MFD: twl-core: Register twl4030-madc child only for twl4030 class

2012-10-29 Thread Peter Ujfalusi
twl4030-madc driver can only handle twl4030 class MADC. The newer revisions
of twl does not have MADC, instead they have different IP called GPADC which
is not backward compatible.

Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
Hi Samuel,

When building the kernel to support OMAP3/4/5 we should only register the MADC
driver when we boot it on OMAP3 since twl60xx does not have MADC.

Regards,
Peter

 drivers/mfd/twl-core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index 4ae6423..2624668 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -646,7 +646,8 @@ add_children(struct twl4030_platform_data *pdata, unsigned 
irq_base,
return PTR_ERR(child);
}
 
-   if (IS_ENABLED(CONFIG_TWL4030_MADC)  pdata-madc) {
+   if (IS_ENABLED(CONFIG_TWL4030_MADC)  pdata-madc 
+   twl_class_is_4030()) {
child = add_child(2, twl4030_madc,
pdata-madc, sizeof(*pdata-madc),
true, irq_base + MADC_INTR_OFFSET, 0);
-- 
1.7.12.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 3/3] leds: leds-pwm: Add device tree bindings

2012-11-12 Thread Peter Ujfalusi
Support for device tree booted kernel.
When the kernel is booted with DeviceTree blob we support one led per
leds-pwm device to have cleaner integration with the PWM subsystem.

For usage see:
Documentation/devicetree/bindings/leds/leds-pwm.txt

Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
 .../devicetree/bindings/leds/leds-pwm.txt  |  34 ++
 drivers/leds/leds-pwm.c| 125 +++--
 2 files changed, 127 insertions(+), 32 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/leds/leds-pwm.txt

diff --git a/Documentation/devicetree/bindings/leds/leds-pwm.txt 
b/Documentation/devicetree/bindings/leds/leds-pwm.txt
new file mode 100644
index 000..9fe3040
--- /dev/null
+++ b/Documentation/devicetree/bindings/leds/leds-pwm.txt
@@ -0,0 +1,34 @@
+LED connected to PWM
+
+Required properties:
+- compatible : should be pwm-leds.
+- pwms : PWM property, please refer to: 
+  Documentation/devicetree/bindings/pwm/pwm.txt
+- pwm-names : (optional) Name to be used by the PWM subsystem for the PWM 
device
+- label : (optional) The label for this LED.  If omitted, the label is
+  taken from the node name (excluding the unit address).
+- max-brightness : Maximum brightness possible for the LED
+- linux,default-trigger :  (optional) This parameter, if present, is a
+  string defining the trigger assigned to the LED.  Current triggers are:
+backlight - LED will act as a back-light, controlled by the framebuffer
+ system
+default-on - LED will turn on, but see default-state below
+heartbeat - LED double flashes at a load average based rate
+ide-disk - LED indicates disk activity
+timer - LED flashes at a fixed, configurable rate
+
+Example:
+
+twl_pwm: pwm {
+   compatible = ti,twl6030-pwm;
+   #pwm-cells = 2;
+};
+
+pwmled_keypad {
+   compatible = pwm-leds;
+   pwms = twl_pwm 0 7812500;
+   pwm-names = Keypad LED;
+
+   label = omap4::keypad;
+   max-brightness = 127;
+};
diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c
index b219ea9..333c942 100644
--- a/drivers/leds/leds-pwm.c
+++ b/drivers/leds/leds-pwm.c
@@ -16,6 +16,7 @@
 #include linux/kernel.h
 #include linux/init.h
 #include linux/platform_device.h
+#include linux/of_platform.h
 #include linux/fb.h
 #include linux/leds.h
 #include linux/err.h
@@ -58,46 +59,98 @@ static inline int sizeof_pwm_leds_priv(int num_leds)
  (sizeof(struct led_pwm_data) * num_leds);
 }
 
+static struct led_pwm_priv *led_pwm_create_of(struct platform_device *pdev)
+{
+   struct device_node *node = pdev-dev.of_node;
+   struct led_pwm_priv *priv;
+   struct led_pwm_data *led_dat;
+   int ret;
+
+   /* With DT boot we support one LED per leds-pwm device */
+   priv = devm_kzalloc(pdev-dev, sizeof_pwm_leds_priv(1),
+   GFP_KERNEL);
+   if (!priv)
+   return NULL;
+
+   led_dat = priv-leds[priv-num_leds];
+   led_dat-cdev.name = of_get_property(node, label, NULL) ? : 
node-name;
+   led_dat-pwm = devm_pwm_get(pdev-dev, NULL);
+   if (IS_ERR(led_dat-pwm)) {
+   dev_err(pdev-dev, unable to request PWM for %s\n,
+   led_dat-cdev.name);
+   return NULL;
+   }
+   /* Get the period from PWM core when n*/
+   led_dat-period = pwm_get_period(led_dat-pwm);
+
+   led_dat-cdev.default_trigger = of_get_property(node,
+   linux,default-trigger,
+   NULL);
+   of_property_read_u32(node, max-brightness,
+led_dat-cdev.max_brightness);
+
+   led_dat-cdev.brightness_set = led_pwm_set;
+   led_dat-cdev.brightness = LED_OFF;
+   led_dat-cdev.flags |= LED_CORE_SUSPENDRESUME;
+
+   ret = led_classdev_register(pdev-dev, led_dat-cdev);
+   if (ret  0) {
+   dev_err(pdev-dev, failed to register for %s\n,
+   led_dat-cdev.name);
+   of_node_put(node);
+   return NULL;
+   }
+
+   priv-num_leds = 1;
+
+   return priv;
+}
+
 static int led_pwm_probe(struct platform_device *pdev)
 {
struct led_pwm_platform_data *pdata = pdev-dev.platform_data;
struct led_pwm_priv *priv;
int i, ret = 0;
 
-   if (!pdata)
-   return -EBUSY;
-
-   priv = devm_kzalloc(pdev-dev, sizeof_pwm_leds_priv(pdata-num_leds),
-   GFP_KERNEL);
-   if (!priv)
-   return -ENOMEM;
-
-   for (i = 0; i  pdata-num_leds; i++) {
-   struct led_pwm *cur_led = pdata-leds[i];
-   struct led_pwm_data *led_dat = priv-leds[i];
-
-   led_dat-pwm = devm_pwm_get(pdev-dev, cur_led-name);
-   if (IS_ERR(led_dat-pwm)) {
-   ret = PTR_ERR(led_dat-pwm);
-   dev_err(pdev-dev

[PATCH v2 0/3] leds: leds-pwm: Device tree support

2012-11-12 Thread Peter Ujfalusi
Hello,

The patch:
https://lkml.org/lkml/2012/11/7/187
grown to be a series to add DeviceTree support for the leds-pwm driver.

Changes since v1:
- As suggested by Bryan Wu: the legacy pwm_request() has been removed from
  patch 1
- Device tree bindings added for leds-pwm driver.

When we boot with Device tree we handle one LED per device to be more aligned
with PWM core's DT implementation.
An example of the DT usage is provided in the new DT binding documentation for
leds-pwm.

Tested on OMAP4 Blaze (SDP) with legacy and DT boot.

Regards,
Peter
---
Peter Ujfalusi (3):
  leds: leds-pwm: Convert to use devm_get_pwm
  leds: leds-pwm: Preparing the driver for device tree support
  leds: leds-pwm: Add device tree bindings

 .../devicetree/bindings/leds/leds-pwm.txt  |  34 +
 drivers/leds/leds-pwm.c| 161 ++---
 include/linux/leds_pwm.h   |   2 +-
 3 files changed, 146 insertions(+), 51 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/leds/leds-pwm.txt

-- 
1.8.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 2/3] leds: leds-pwm: Preparing the driver for device tree support

2012-11-12 Thread Peter Ujfalusi
In order to be able to add device tree support for leds-pwm driver we need
to rearrange the data structures used by the drivers.

Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
 drivers/leds/leds-pwm.c | 39 +++
 1 file changed, 23 insertions(+), 16 deletions(-)

diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c
index c953c75..b219ea9 100644
--- a/drivers/leds/leds-pwm.c
+++ b/drivers/leds/leds-pwm.c
@@ -30,6 +30,11 @@ struct led_pwm_data {
unsigned intperiod;
 };
 
+struct led_pwm_priv {
+   int num_leds;
+   struct led_pwm_data leds[];
+};
+
 static void led_pwm_set(struct led_classdev *led_cdev,
enum led_brightness brightness)
 {
@@ -47,25 +52,29 @@ static void led_pwm_set(struct led_classdev *led_cdev,
}
 }
 
+static inline int sizeof_pwm_leds_priv(int num_leds)
+{
+   return sizeof(struct led_pwm_priv) +
+ (sizeof(struct led_pwm_data) * num_leds);
+}
+
 static int led_pwm_probe(struct platform_device *pdev)
 {
struct led_pwm_platform_data *pdata = pdev-dev.platform_data;
-   struct led_pwm *cur_led;
-   struct led_pwm_data *leds_data, *led_dat;
+   struct led_pwm_priv *priv;
int i, ret = 0;
 
if (!pdata)
return -EBUSY;
 
-   leds_data = devm_kzalloc(pdev-dev,
-   sizeof(struct led_pwm_data) * pdata-num_leds,
-   GFP_KERNEL);
-   if (!leds_data)
+   priv = devm_kzalloc(pdev-dev, sizeof_pwm_leds_priv(pdata-num_leds),
+   GFP_KERNEL);
+   if (!priv)
return -ENOMEM;
 
for (i = 0; i  pdata-num_leds; i++) {
-   cur_led = pdata-leds[i];
-   led_dat = leds_data[i];
+   struct led_pwm *cur_led = pdata-leds[i];
+   struct led_pwm_data *led_dat = priv-leds[i];
 
led_dat-pwm = devm_pwm_get(pdev-dev, cur_led-name);
if (IS_ERR(led_dat-pwm)) {
@@ -88,15 +97,16 @@ static int led_pwm_probe(struct platform_device *pdev)
if (ret  0)
goto err;
}
+   priv-num_leds = pdata-num_leds;
 
-   platform_set_drvdata(pdev, leds_data);
+   platform_set_drvdata(pdev, priv);
 
return 0;
 
 err:
if (i  0) {
for (i = i - 1; i = 0; i--)
-   led_classdev_unregister(leds_data[i].cdev);
+   led_classdev_unregister(priv-leds[i].cdev);
}
 
return ret;
@@ -104,14 +114,11 @@ err:
 
 static int __devexit led_pwm_remove(struct platform_device *pdev)
 {
+   struct led_pwm_priv *priv = platform_get_drvdata(pdev);
int i;
-   struct led_pwm_platform_data *pdata = pdev-dev.platform_data;
-   struct led_pwm_data *leds_data;
-
-   leds_data = platform_get_drvdata(pdev);
 
-   for (i = 0; i  pdata-num_leds; i++)
-   led_classdev_unregister(leds_data[i].cdev);
+   for (i = 0; i  priv-num_leds; i++)
+   led_classdev_unregister(priv-leds[i].cdev);
 
return 0;
 }
-- 
1.8.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 1/3] leds: leds-pwm: Convert to use devm_get_pwm

2012-11-12 Thread Peter Ujfalusi
Update the driver to use the new API for requesting pwm so we can take
advantage of the pwm_lookup table to find the correct pwm to be used for the
LED functionality.
If the devm_get_pwm fails we fall back to legacy mode to try to get the pwm.

Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
 drivers/leds/leds-pwm.c  | 19 ++-
 include/linux/leds_pwm.h |  2 +-
 2 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c
index f2e44c7..c953c75 100644
--- a/drivers/leds/leds-pwm.c
+++ b/drivers/leds/leds-pwm.c
@@ -67,12 +67,11 @@ static int led_pwm_probe(struct platform_device *pdev)
cur_led = pdata-leds[i];
led_dat = leds_data[i];
 
-   led_dat-pwm = pwm_request(cur_led-pwm_id,
-   cur_led-name);
+   led_dat-pwm = devm_pwm_get(pdev-dev, cur_led-name);
if (IS_ERR(led_dat-pwm)) {
ret = PTR_ERR(led_dat-pwm);
-   dev_err(pdev-dev, unable to request PWM %d\n,
-   cur_led-pwm_id);
+   dev_err(pdev-dev, unable to request PWM for %s\n,
+   cur_led-name);
goto err;
}
 
@@ -86,10 +85,8 @@ static int led_pwm_probe(struct platform_device *pdev)
led_dat-cdev.flags |= LED_CORE_SUSPENDRESUME;
 
ret = led_classdev_register(pdev-dev, led_dat-cdev);
-   if (ret  0) {
-   pwm_free(led_dat-pwm);
+   if (ret  0)
goto err;
-   }
}
 
platform_set_drvdata(pdev, leds_data);
@@ -98,10 +95,8 @@ static int led_pwm_probe(struct platform_device *pdev)
 
 err:
if (i  0) {
-   for (i = i - 1; i = 0; i--) {
+   for (i = i - 1; i = 0; i--)
led_classdev_unregister(leds_data[i].cdev);
-   pwm_free(leds_data[i].pwm);
-   }
}
 
return ret;
@@ -115,10 +110,8 @@ static int __devexit led_pwm_remove(struct platform_device 
*pdev)
 
leds_data = platform_get_drvdata(pdev);
 
-   for (i = 0; i  pdata-num_leds; i++) {
+   for (i = 0; i  pdata-num_leds; i++)
led_classdev_unregister(leds_data[i].cdev);
-   pwm_free(leds_data[i].pwm);
-   }
 
return 0;
 }
diff --git a/include/linux/leds_pwm.h b/include/linux/leds_pwm.h
index 33a0711..a65e964 100644
--- a/include/linux/leds_pwm.h
+++ b/include/linux/leds_pwm.h
@@ -7,7 +7,7 @@
 struct led_pwm {
const char  *name;
const char  *default_trigger;
-   unsignedpwm_id;
+   unsignedpwm_id __deprecated;
u8  active_low;
unsignedmax_brightness;
unsignedpwm_period_ns;
-- 
1.8.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] MFD: twl-core: Fix chip ID for the twl6030-pwm module

2012-11-12 Thread Peter Ujfalusi
Hi Samuel,

On 11/01/2012 10:09 AM, Tero Kristo wrote:
 Acked-by: Tero Kristo t-kri...@ti.com

Can you take this patch for 3.7?

Thank you,
Péter

 
 On Wed, 2012-10-31 at 15:54 +0100, Peter Ujfalusi wrote:
 The correct chip id is 1 since the PWM module is on address 0x49. With the
 current TWL6030_MODULE_ID1 the kernel will crash early since:
 #define TWL6030_MODULE_ID1 0x0E
 and
 static struct twl_client twl_modules[4];

 Down in the stack we try to get the module by:
 struct twl_client*twl = twl_modules[chip];

 Which obviously going to do nasty things.

 Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
 ---
 Hi Samuel,

 Can you push this patch to 3.7?
 Without this if the user enables the twl6030-pwm driver the kernel will not
 going to boot on OMAP4.

 Thank you,
 Peter

  drivers/mfd/twl-core.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
 index 2624668..d7577cb 100644
 --- a/drivers/mfd/twl-core.c
 +++ b/drivers/mfd/twl-core.c
 @@ -672,7 +672,7 @@ add_children(struct twl4030_platform_data *pdata, 
 unsigned irq_base,
  }
  
  if (IS_ENABLED(CONFIG_PWM_TWL6030)  twl_class_is_6030()) {
 -child = add_child(TWL6030_MODULE_ID1, twl6030-pwm, NULL, 0,
 +child = add_child(SUB_CHIP_ID1, twl6030-pwm, NULL, 0,
false, 0, 0);
  if (IS_ERR(child))
  return PTR_ERR(child);
 
 

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 0/6] MFD: twl6040: Conversion to use regmap_irq

2012-11-12 Thread Peter Ujfalusi
Hi Samuel,

On 10/11/2012 01:55 PM, Peter Ujfalusi wrote:
 Hello,
 
 This series will convert the twl6040 MFD core driver to use regmap_irq instead
 of the custom interrupt code it used. In this way considerable amount of code
 can be removed and we are going to use common, well tested code for the 
 interrupt
 dispatch.
 
 The series is for 3.8.

Did you had time to look at this series?
I can resend it if it is better for you.

Regards,
Péter

 
 Regards,
 Peter
 ---
 Peter Ujfalusi (6):
   MFD: twl6040: Fix typo for power on failure
   MFD: twl6040: Remove unused parameter for
 twl6040_power_up_completion()
   MFD: twl6040: Restructure power up and down code
   MFD: twl6040: Correct Ready and Thermal interrupt handling
   MFD: twl6040: Convert to use regmap_irq
   MFD: twl6040: Rename the core driver
 
  drivers/mfd/Kconfig   |   4 +-
  drivers/mfd/Makefile  |   2 +-
  drivers/mfd/twl6040-irq.c | 205 
 --
  drivers/mfd/{twl6040-core.c = twl6040.c} | 137 
  include/linux/mfd/twl6040.h   |  10 +-
  5 files changed, 92 insertions(+), 266 deletions(-)
  delete mode 100644 drivers/mfd/twl6040-irq.c
  rename drivers/mfd/{twl6040-core.c = twl6040.c} (84%)
 
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 01/13] MFD: twl-core: Register twl4030-madc child only for twl4030 class

2012-11-13 Thread Peter Ujfalusi
twl4030-madc driver can only handle twl4030 class MADC. The newer revisions
of twl does not have MADC, instead they have different IP called GPADC which
is not backward compatible.

Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
 drivers/mfd/twl-core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index a071a86..d7577cb 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -646,7 +646,8 @@ add_children(struct twl4030_platform_data *pdata, unsigned 
irq_base,
return PTR_ERR(child);
}
 
-   if (IS_ENABLED(CONFIG_TWL4030_MADC)  pdata-madc) {
+   if (IS_ENABLED(CONFIG_TWL4030_MADC)  pdata-madc 
+   twl_class_is_4030()) {
child = add_child(2, twl4030_madc,
pdata-madc, sizeof(*pdata-madc),
true, irq_base + MADC_INTR_OFFSET, 0);
-- 
1.8.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 07/13] mfd: twl: Convert module id definitions to enums

2012-11-13 Thread Peter Ujfalusi
Use enum list for the module definitions (TWL4030_MODULE_*) which will ease
up future work with the IDs.
At the same time group the IDs in block of five so it is easier to find the
ID we are looking for (to count the number they stand for).

At the same time define TWL_MODULE_LED so client drivers can switch to use
it as soon as it is possible.

Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
 drivers/mfd/twl-core.c  |  9 +++
 include/linux/i2c/twl.h | 65 +
 2 files changed, 36 insertions(+), 38 deletions(-)

diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index d666c9d..bb33b52 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -66,9 +66,6 @@
 
 /* Triton Core internal information (BEGIN) */
 
-/* Last - for index max*/
-#define TWL4030_MODULE_LASTTWL4030_MODULE_SECURED_REG
-
 #define TWL_NUM_SLAVES 4
 
 #define SUB_CHIP_ID0 0
@@ -184,7 +181,7 @@ struct twl_mapping {
 };
 static struct twl_mapping *twl_map;
 
-static struct twl_mapping twl4030_map[TWL4030_MODULE_LAST + 1] = {
+static struct twl_mapping twl4030_map[] = {
/*
 * NOTE:  don't change this table without updating the
 * linux/i2c/twl.h defines for TWL4030_MODULE_*
@@ -327,7 +324,7 @@ int twl_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned 
num_bytes)
int sid;
struct twl_client *twl;
 
-   if (unlikely(mod_no  TWL_MODULE_LAST)) {
+   if (unlikely(mod_no = TWL_MODULE_LAST)) {
pr_err(%s: invalid module number %d\n, DRIVER_NAME, mod_no);
return -EPERM;
}
@@ -369,7 +366,7 @@ int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned 
num_bytes)
int sid;
struct twl_client *twl;
 
-   if (unlikely(mod_no  TWL_MODULE_LAST)) {
+   if (unlikely(mod_no = TWL_MODULE_LAST)) {
pr_err(%s: invalid module number %d\n, DRIVER_NAME, mod_no);
return -EPERM;
}
diff --git a/include/linux/i2c/twl.h b/include/linux/i2c/twl.h
index 7278c72..b1c44cc 100644
--- a/include/linux/i2c/twl.h
+++ b/include/linux/i2c/twl.h
@@ -39,39 +39,39 @@
  * address each module uses within a given i2c slave.
  */
 
-/* Slave 0 (i2c address 0x48) */
-#define TWL4030_MODULE_USB 0x00
-
-/* Slave 1 (i2c address 0x49) */
-#define TWL4030_MODULE_AUDIO_VOICE 0x01
-#define TWL4030_MODULE_GPIO0x02
-#define TWL4030_MODULE_INTBR   0x03
-#define TWL4030_MODULE_PIH 0x04
-#define TWL4030_MODULE_TEST0x05
-
-/* Slave 2 (i2c address 0x4a) */
-#define TWL4030_MODULE_KEYPAD  0x06
-#define TWL4030_MODULE_MADC0x07
-#define TWL4030_MODULE_INTERRUPTS  0x08
-#define TWL4030_MODULE_LED 0x09
-#define TWL4030_MODULE_MAIN_CHARGE 0x0A
-#define TWL4030_MODULE_PRECHARGE   0x0B
-#define TWL4030_MODULE_PWM00x0C
-#define TWL4030_MODULE_PWM10x0D
-#define TWL4030_MODULE_PWMA0x0E
-#define TWL4030_MODULE_PWMB0x0F
-
-#define TWL5031_MODULE_ACCESSORY   0x10
-#define TWL5031_MODULE_INTERRUPTS  0x11
-
-/* Slave 3 (i2c address 0x4b) */
-#define TWL4030_MODULE_BACKUP  0x12
-#define TWL4030_MODULE_INT 0x13
-#define TWL4030_MODULE_PM_MASTER   0x14
-#define TWL4030_MODULE_PM_RECEIVER 0x15
-#define TWL4030_MODULE_RTC 0x16
-#define TWL4030_MODULE_SECURED_REG 0x17
+enum twl4030_module_ids {
+   TWL4030_MODULE_USB = 0, /* Slave 0 (i2c address 0x48) */
+   TWL4030_MODULE_AUDIO_VOICE, /* Slave 1 (i2c address 0x49) */
+   TWL4030_MODULE_GPIO,
+   TWL4030_MODULE_INTBR,
+   TWL4030_MODULE_PIH,
+
+   TWL4030_MODULE_TEST,
+   TWL4030_MODULE_KEYPAD,  /* Slave 2 (i2c address 0x4a) */
+   TWL4030_MODULE_MADC,
+   TWL4030_MODULE_INTERRUPTS,
+   TWL4030_MODULE_LED,
+
+   TWL4030_MODULE_MAIN_CHARGE,
+   TWL4030_MODULE_PRECHARGE,
+   TWL4030_MODULE_PWM0,
+   TWL4030_MODULE_PWM1,
+   TWL4030_MODULE_PWMA,
+
+   TWL4030_MODULE_PWMB,
+   TWL5031_MODULE_ACCESSORY,
+   TWL5031_MODULE_INTERRUPTS,
+   TWL4030_MODULE_BACKUP,  /* Slave 3 (i2c address 0x4b) */
+   TWL4030_MODULE_INT,
+
+   TWL4030_MODULE_PM_MASTER,
+   TWL4030_MODULE_PM_RECEIVER,
+   TWL4030_MODULE_RTC,
+   TWL4030_MODULE_SECURED_REG,
+   TWL4030_MODULE_LAST,
+};
 
+/* Similar functionalities implemented in TWL4030/6030 */
 #define TWL_MODULE_USB TWL4030_MODULE_USB
 #define TWL_MODULE_PIH TWL4030_MODULE_PIH
 #define TWL_MODULE_MAIN_CHARGE TWL4030_MODULE_MAIN_CHARGE
@@ -79,6 +79,7 @@
 #define TWL_MODULE_PM_RECEIVER TWL4030_MODULE_PM_RECEIVER
 #define TWL_MODULE_RTC TWL4030_MODULE_RTC
 #define TWL_MODULE_PWM TWL4030_MODULE_PWM0
+#define TWL_MODULE_LED TWL4030_MODULE_LED
 
 #define TWL6030_MODULE_ID0 0x0D
 #define TWL6030_MODULE_ID1 0x0E
-- 
1.8.0

--
To unsubscribe from

[PATCH 11/13] mfd: twl4030-power: Change TWL4030_MODULE_* ids to TWL_MODULE_*

2012-11-13 Thread Peter Ujfalusi
To facilitate upcoming cleanup in twl stack.
No functional changes.

Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
 drivers/mfd/twl4030-power.c | 124 ++--
 1 file changed, 51 insertions(+), 73 deletions(-)

diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
index 79ca33d..4fda77c 100644
--- a/drivers/mfd/twl4030-power.c
+++ b/drivers/mfd/twl4030-power.c
@@ -128,12 +128,10 @@ static int __devinit twl4030_write_script_byte(u8 
address, u8 byte)
 {
int err;
 
-   err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address,
-   R_MEMORY_ADDRESS);
+   err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, address, R_MEMORY_ADDRESS);
if (err)
goto out;
-   err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, byte,
-   R_MEMORY_DATA);
+   err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, byte, R_MEMORY_DATA);
 out:
return err;
 }
@@ -189,19 +187,16 @@ static int __devinit twl4030_config_wakeup3_sequence(u8 
address)
u8 data;
 
/* Set SLEEP to ACTIVE SEQ address for P3 */
-   err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address,
-   R_SEQ_ADD_S2A3);
+   err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, address, R_SEQ_ADD_S2A3);
if (err)
goto out;
 
/* P3 LVL_WAKEUP should be on LEVEL */
-   err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, data,
-   R_P3_SW_EVENTS);
+   err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, data, R_P3_SW_EVENTS);
if (err)
goto out;
data |= LVL_WAKEUP;
-   err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, data,
-   R_P3_SW_EVENTS);
+   err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, data, R_P3_SW_EVENTS);
 out:
if (err)
pr_err(TWL4030 wakeup sequence for P3 config error\n);
@@ -214,43 +209,38 @@ static int __devinit twl4030_config_wakeup12_sequence(u8 
address)
u8 data;
 
/* Set SLEEP to ACTIVE SEQ address for P1 and P2 */
-   err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address,
-   R_SEQ_ADD_S2A12);
+   err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, address, R_SEQ_ADD_S2A12);
if (err)
goto out;
 
/* P1/P2 LVL_WAKEUP should be on LEVEL */
-   err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, data,
-   R_P1_SW_EVENTS);
+   err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, data, R_P1_SW_EVENTS);
if (err)
goto out;
 
data |= LVL_WAKEUP;
-   err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, data,
-   R_P1_SW_EVENTS);
+   err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, data, R_P1_SW_EVENTS);
if (err)
goto out;
 
-   err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, data,
-   R_P2_SW_EVENTS);
+   err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, data, R_P2_SW_EVENTS);
if (err)
goto out;
 
data |= LVL_WAKEUP;
-   err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, data,
-   R_P2_SW_EVENTS);
+   err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, data, R_P2_SW_EVENTS);
if (err)
goto out;
 
if (machine_is_omap_3430sdp() || machine_is_omap_ldp()) {
/* Disabling AC charger effect on sleep-active transitions */
-   err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, data,
-   R_CFG_P1_TRANSITION);
+   err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, data,
+ R_CFG_P1_TRANSITION);
if (err)
goto out;
data = ~(11);
-   err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, data ,
-   R_CFG_P1_TRANSITION);
+   err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, data,
+  R_CFG_P1_TRANSITION);
if (err)
goto out;
}
@@ -267,8 +257,7 @@ static int __devinit twl4030_config_sleep_sequence(u8 
address)
int err;
 
/* Set ACTIVE to SLEEP SEQ address in T2 memory*/
-   err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address,
-   R_SEQ_ADD_A2S);
+   err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, address, R_SEQ_ADD_A2S);
 
if (err)
pr_err(TWL4030 sleep sequence config error\n);
@@ -282,42 +271,35 @@ static int __devinit twl4030_config_warmreset_sequence(u8 
address)
u8 rd_data;
 
/* Set WARM RESET SEQ address for P1 */
-   err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address,
-   R_SEQ_ADD_WARM);
+   err = twl_i2c_write_u8

[PATCH 04/13] MFD/rtc/gpio: twl: No need to allocate bigger buffer for write

2012-11-13 Thread Peter Ujfalusi
Since the twl-core has been converted to use regmap it is no longer needed
to allocate bigger buffer for data when writing to twl.

CC: Grant Likely grant.lik...@secretlab.ca
CC: Linus Walleij linus.wall...@linaro.org
CC: Alessandro Zummo a.zu...@towertech.it
Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
 drivers/gpio/gpio-twl4030.c | 12 ++--
 drivers/mfd/twl-core.c  |  9 ++---
 drivers/mfd/twl4030-irq.c   |  6 +++---
 drivers/mfd/twl6030-irq.c   |  4 ++--
 drivers/rtc/rtc-twl.c   | 32 
 5 files changed, 29 insertions(+), 34 deletions(-)

diff --git a/drivers/gpio/gpio-twl4030.c b/drivers/gpio/gpio-twl4030.c
index c5f8ca2..88829c3 100644
--- a/drivers/gpio/gpio-twl4030.c
+++ b/drivers/gpio/gpio-twl4030.c
@@ -354,13 +354,13 @@ static struct gpio_chip twl_gpiochip = {
 
 static int __devinit gpio_twl4030_pulls(u32 ups, u32 downs)
 {
-   u8  message[6];
+   u8  message[5];
unsignedi, gpio_bit;
 
/* For most pins, a pulldown was enabled by default.
 * We should have data that's specific to this board.
 */
-   for (gpio_bit = 1, i = 1; i  6; i++) {
+   for (gpio_bit = 1, i = 0; i  5; i++) {
u8  bit_mask;
unsignedj;
 
@@ -379,16 +379,16 @@ static int __devinit gpio_twl4030_pulls(u32 ups, u32 
downs)
 
 static int __devinit gpio_twl4030_debounce(u32 debounce, u8 mmc_cd)
 {
-   u8  message[4];
+   u8  message[3];
 
/* 30 msec of debouncing is always used for MMC card detect,
 * and is optional for everything else.
 */
-   message[1] = (debounce  0xff) | (mmc_cd  0x03);
+   message[0] = (debounce  0xff) | (mmc_cd  0x03);
debounce = 8;
-   message[2] = (debounce  0xff);
+   message[1] = (debounce  0xff);
debounce = 8;
-   message[3] = (debounce  0x03);
+   message[2] = (debounce  0x03);
 
return twl_i2c_write(TWL4030_MODULE_GPIO, message,
REG_GPIO_DEBEN1, 3);
diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index 5043f505a..a55ab15 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -344,7 +344,7 @@ int twl_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned 
num_bytes)
twl = twl_modules[sid];
 
ret = regmap_bulk_write(twl-regmap, twl_map[mod_no].base + reg,
-   value[1], num_bytes);
+   value, num_bytes);
 
if (ret)
pr_err(%s: Write failed (mod %d, reg 0x%02x count %d)\n,
@@ -406,12 +406,7 @@ EXPORT_SYMBOL(twl_i2c_read);
  */
 int twl_i2c_write_u8(u8 mod_no, u8 value, u8 reg)
 {
-
-   /* 2 bytes offset 1 contains the data offset 0 is used by i2c_write */
-   u8 temp_buffer[2] = { 0 };
-   /* offset 1 contains the data */
-   temp_buffer[1] = value;
-   return twl_i2c_write(mod_no, temp_buffer, reg, 1);
+   return twl_i2c_write(mod_no, value, reg, 1);
 }
 EXPORT_SYMBOL(twl_i2c_write_u8);
 
diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
index ad733d7..e900402 100644
--- a/drivers/mfd/twl4030-irq.c
+++ b/drivers/mfd/twl4030-irq.c
@@ -501,7 +501,7 @@ static void twl4030_sih_bus_sync_unlock(struct irq_data 
*data)
} imr;
 
/* byte[0] gets overwritten as we write ... */
-   imr.word = cpu_to_le32(agent-imr  8);
+   imr.word = cpu_to_le32(agent-imr);
agent-imr_change_pending = false;
 
/* write the whole mask ... simpler than subsetting it */
@@ -526,7 +526,7 @@ static void twl4030_sih_bus_sync_unlock(struct irq_data 
*data)
 * any processor on the other IRQ line, EDR registers are
 * shared.
 */
-   status = twl_i2c_read(sih-module, bytes + 1,
+   status = twl_i2c_read(sih-module, bytes,
sih-edr_offset, sih-bytes_edr);
if (status) {
pr_err(twl4030: %s, %s -- %d\n, __func__,
@@ -538,7 +538,7 @@ static void twl4030_sih_bus_sync_unlock(struct irq_data 
*data)
while (edge_change) {
int i = fls(edge_change) - 1;
struct irq_data *idata;
-   int byte = 1 + (i  2);
+   int byte = i  2;
int off = (i  0x3) * 2;
unsigned inttype;
 
diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
index b76902f..277a8db 100644
--- a/drivers/mfd/twl6030-irq.c
+++ b/drivers/mfd/twl6030-irq.c
@@ -355,7 +355,7 @@ int twl6030_init_irq(struct device *dev, int irq_num)
static struct irq_chip  twl6030_irq_chip;
int status = 0;
int i;
-   u8

[PATCH 03/13] MFD: twl-core: Convert to use regmap for I/O

2012-11-13 Thread Peter Ujfalusi
Remove the custom code to do I/O and replace it with standard regmap calls.

CC: Mark Brown broo...@opensource.wolfsonmicro.com
Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
 drivers/mfd/twl-core.c | 147 +++--
 1 file changed, 80 insertions(+), 67 deletions(-)

diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index 1dfd583..5043f505a 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -32,6 +32,7 @@
 #include linux/mutex.h
 #include linux/module.h
 #include linux/platform_device.h
+#include linux/regmap.h
 #include linux/clk.h
 #include linux/err.h
 #include linux/device.h
@@ -171,13 +172,7 @@ EXPORT_SYMBOL(twl_rev);
 /* Structure for each TWL4030/TWL6030 Slave */
 struct twl_client {
struct i2c_client *client;
-   u8 address;
-
-   /* max numb of i2c_msg required is for read =2 */
-   struct i2c_msg xfer_msg[2];
-
-   /* To lock access to xfer_msg */
-   struct mutex xfer_lock;
+   struct regmap *regmap;
 };
 
 static struct twl_client twl_modules[TWL_NUM_SLAVES];
@@ -225,6 +220,33 @@ static struct twl_mapping twl4030_map[TWL4030_MODULE_LAST 
+ 1] = {
{ 3, TWL4030_BASEADD_SECURED_REG },
 };
 
+static struct regmap_config twl4030_regmap_config[4] = {
+   {
+   /* Address 0x48 */
+   .reg_bits = 8,
+   .val_bits = 8,
+   .max_register = 0xff,
+   },
+   {
+   /* Address 0x49 */
+   .reg_bits = 8,
+   .val_bits = 8,
+   .max_register = 0xff,
+   },
+   {
+   /* Address 0x4a */
+   .reg_bits = 8,
+   .val_bits = 8,
+   .max_register = 0xff,
+   },
+   {
+   /* Address 0x4b */
+   .reg_bits = 8,
+   .val_bits = 8,
+   .max_register = 0xff,
+   },
+};
+
 static struct twl_mapping twl6030_map[] = {
/*
 * NOTE:  don't change this table without updating the
@@ -262,6 +284,27 @@ static struct twl_mapping twl6030_map[] = {
{ SUB_CHIP_ID1, TWL6025_BASEADD_CHARGER },
 };
 
+static struct regmap_config twl6030_regmap_config[3] = {
+   {
+   /* Address 0x48 */
+   .reg_bits = 8,
+   .val_bits = 8,
+   .max_register = 0xff,
+   },
+   {
+   /* Address 0x49 */
+   .reg_bits = 8,
+   .val_bits = 8,
+   .max_register = 0xff,
+   },
+   {
+   /* Address 0x4a */
+   .reg_bits = 8,
+   .val_bits = 8,
+   .max_register = 0xff,
+   },
+};
+
 /*--*/
 
 /* Exported Functions */
@@ -283,7 +326,6 @@ int twl_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned 
num_bytes)
int ret;
int sid;
struct twl_client *twl;
-   struct i2c_msg *msg;
 
if (unlikely(mod_no  TWL_MODULE_LAST)) {
pr_err(%s: invalid module number %d\n, DRIVER_NAME, mod_no);
@@ -301,32 +343,14 @@ int twl_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned 
num_bytes)
}
twl = twl_modules[sid];
 
-   mutex_lock(twl-xfer_lock);
-   /*
-* [MSG1]: fill the register address data
-* fill the data Tx buffer
-*/
-   msg = twl-xfer_msg[0];
-   msg-addr = twl-address;
-   msg-len = num_bytes + 1;
-   msg-flags = 0;
-   msg-buf = value;
-   /* over write the first byte of buffer with the register address */
-   *value = twl_map[mod_no].base + reg;
-   ret = i2c_transfer(twl-client-adapter, twl-xfer_msg, 1);
-   mutex_unlock(twl-xfer_lock);
-
-   /* i2c_transfer returns number of messages transferred */
-   if (ret != 1) {
-   pr_err(%s: i2c_write failed to transfer all messages\n,
-   DRIVER_NAME);
-   if (ret  0)
-   return ret;
-   else
-   return -EIO;
-   } else {
-   return 0;
-   }
+   ret = regmap_bulk_write(twl-regmap, twl_map[mod_no].base + reg,
+   value[1], num_bytes);
+
+   if (ret)
+   pr_err(%s: Write failed (mod %d, reg 0x%02x count %d)\n,
+  DRIVER_NAME, mod_no, reg, num_bytes);
+
+   return ret;
 }
 EXPORT_SYMBOL(twl_i2c_write);
 
@@ -342,10 +366,8 @@ EXPORT_SYMBOL(twl_i2c_write);
 int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
 {
int ret;
-   u8 val;
int sid;
struct twl_client *twl;
-   struct i2c_msg *msg;
 
if (unlikely(mod_no  TWL_MODULE_LAST)) {
pr_err(%s: invalid module number %d\n, DRIVER_NAME, mod_no);
@@ -363,34 +385,14 @@ int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned 
num_bytes)
}
twl = twl_modules[sid];
 
-   mutex_lock(twl-xfer_lock

[PATCH 08/13] mfd: twl: Use decimal numbers for TWL6030_MODULE_IDs

2012-11-13 Thread Peter Ujfalusi
It is easier fro humans to understand decimal numbers than hexadecimals when
they are used as indexes.

Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
 include/linux/i2c/twl.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/linux/i2c/twl.h b/include/linux/i2c/twl.h
index b1c44cc..1ff54b1 100644
--- a/include/linux/i2c/twl.h
+++ b/include/linux/i2c/twl.h
@@ -81,9 +81,9 @@ enum twl4030_module_ids {
 #define TWL_MODULE_PWM TWL4030_MODULE_PWM0
 #define TWL_MODULE_LED TWL4030_MODULE_LED
 
-#define TWL6030_MODULE_ID0 0x0D
-#define TWL6030_MODULE_ID1 0x0E
-#define TWL6030_MODULE_ID2 0x0F
+#define TWL6030_MODULE_ID0 13
+#define TWL6030_MODULE_ID1 14
+#define TWL6030_MODULE_ID2 15
 
 #define GPIO_INTR_OFFSET   0
 #define KEYPAD_INTR_OFFSET 1
-- 
1.8.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 13/13] mfd: twl-core: Change TWL4030_MODULE_* ids to TWL_MODULE_*

2012-11-13 Thread Peter Ujfalusi
To facilitate upcoming cleanup in twl stack.
No functional changes.

Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
 drivers/mfd/twl-core.c | 14 ++
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index f857097..43c7b4c 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -1077,8 +1077,8 @@ static inline int __init protect_pm_master(void)
 {
int e = 0;
 
-   e = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0,
-   TWL4030_PM_MASTER_PROTECT_KEY);
+   e = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, 0,
+TWL4030_PM_MASTER_PROTECT_KEY);
return e;
 }
 
@@ -1086,12 +1086,10 @@ static inline int __init unprotect_pm_master(void)
 {
int e = 0;
 
-   e |= twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER,
-   TWL4030_PM_MASTER_KEY_CFG1,
-   TWL4030_PM_MASTER_PROTECT_KEY);
-   e |= twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER,
-   TWL4030_PM_MASTER_KEY_CFG2,
-   TWL4030_PM_MASTER_PROTECT_KEY);
+   e |= twl_i2c_write_u8(TWL_MODULE_PM_MASTER, TWL4030_PM_MASTER_KEY_CFG1,
+ TWL4030_PM_MASTER_PROTECT_KEY);
+   e |= twl_i2c_write_u8(TWL_MODULE_PM_MASTER, TWL4030_PM_MASTER_KEY_CFG2,
+ TWL4030_PM_MASTER_PROTECT_KEY);
 
return e;
 }
-- 
1.8.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 12/13] mfd: twl4030-irq: Change TWL4030_MODULE_* ids to TWL_MODULE_*

2012-11-13 Thread Peter Ujfalusi
To facilitate upcoming cleanup in twl stack.
No functional changes.

Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
 drivers/mfd/twl4030-irq.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
index e900402..518da0c 100644
--- a/drivers/mfd/twl4030-irq.c
+++ b/drivers/mfd/twl4030-irq.c
@@ -295,8 +295,8 @@ static irqreturn_t handle_twl4030_pih(int irq, void *devid)
irqreturn_t ret;
u8  pih_isr;
 
-   ret = twl_i2c_read_u8(TWL4030_MODULE_PIH, pih_isr,
-   REG_PIH_ISR_P1);
+   ret = twl_i2c_read_u8(TWL_MODULE_PIH, pih_isr,
+ REG_PIH_ISR_P1);
if (ret) {
pr_warning(twl4030: I2C error %d reading PIH ISR\n, ret);
return IRQ_NONE;
-- 
1.8.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 10/13] mfd: twl4030-madc: Change TWL4030_MODULE_* ids to TWL_MODULE_*

2012-11-13 Thread Peter Ujfalusi
To facilitate upcoming cleanup in twl stack.
No functional changes.

Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
 drivers/mfd/twl4030-madc.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/mfd/twl4030-madc.c b/drivers/mfd/twl4030-madc.c
index 456ecb5..2baabaa 100644
--- a/drivers/mfd/twl4030-madc.c
+++ b/drivers/mfd/twl4030-madc.c
@@ -173,7 +173,7 @@ static int twl4030battery_temperature(int raw_volt)
 
volt = (raw_volt * TEMP_STEP_SIZE) / TEMP_PSR_R;
/* Getting and calculating the supply current in micro ampers */
-   ret = twl_i2c_read_u8(TWL4030_MODULE_MAIN_CHARGE, val,
+   ret = twl_i2c_read_u8(TWL_MODULE_MAIN_CHARGE, val,
REG_BCICTL2);
if (ret  0)
return ret;
@@ -196,7 +196,7 @@ static int twl4030battery_current(int raw_volt)
int ret;
u8 val;
 
-   ret = twl_i2c_read_u8(TWL4030_MODULE_MAIN_CHARGE, val,
+   ret = twl_i2c_read_u8(TWL_MODULE_MAIN_CHARGE, val,
TWL4030_BCI_BCICTL1);
if (ret)
return ret;
@@ -635,7 +635,7 @@ static int twl4030_madc_set_current_generator(struct 
twl4030_madc_data *madc,
int ret;
u8 regval;
 
-   ret = twl_i2c_read_u8(TWL4030_MODULE_MAIN_CHARGE,
+   ret = twl_i2c_read_u8(TWL_MODULE_MAIN_CHARGE,
  regval, TWL4030_BCI_BCICTL1);
if (ret) {
dev_err(madc-dev, unable to read BCICTL1 reg 0x%X,
@@ -646,7 +646,7 @@ static int twl4030_madc_set_current_generator(struct 
twl4030_madc_data *madc,
regval |= chan ? TWL4030_BCI_ITHEN : TWL4030_BCI_TYPEN;
else
regval = chan ? ~TWL4030_BCI_ITHEN : ~TWL4030_BCI_TYPEN;
-   ret = twl_i2c_write_u8(TWL4030_MODULE_MAIN_CHARGE,
+   ret = twl_i2c_write_u8(TWL_MODULE_MAIN_CHARGE,
   regval, TWL4030_BCI_BCICTL1);
if (ret) {
dev_err(madc-dev, unable to write BCICTL1 reg 0x%X\n,
@@ -668,7 +668,7 @@ static int twl4030_madc_set_power(struct twl4030_madc_data 
*madc, int on)
u8 regval;
int ret;
 
-   ret = twl_i2c_read_u8(TWL4030_MODULE_MAIN_CHARGE,
+   ret = twl_i2c_read_u8(TWL_MODULE_MAIN_CHARGE,
  regval, TWL4030_MADC_CTRL1);
if (ret) {
dev_err(madc-dev, unable to read madc ctrl1 reg 0x%X\n,
@@ -725,7 +725,7 @@ static int __devinit twl4030_madc_probe(struct 
platform_device *pdev)
if (ret  0)
goto err_current_generator;
 
-   ret = twl_i2c_read_u8(TWL4030_MODULE_MAIN_CHARGE,
+   ret = twl_i2c_read_u8(TWL_MODULE_MAIN_CHARGE,
  regval, TWL4030_BCI_BCICTL1);
if (ret) {
dev_err(pdev-dev, unable to read reg BCI CTL1 0x%X\n,
@@ -733,7 +733,7 @@ static int __devinit twl4030_madc_probe(struct 
platform_device *pdev)
goto err_i2c;
}
regval |= TWL4030_BCI_MESBAT;
-   ret = twl_i2c_write_u8(TWL4030_MODULE_MAIN_CHARGE,
+   ret = twl_i2c_write_u8(TWL_MODULE_MAIN_CHARGE,
   regval, TWL4030_BCI_BCICTL1);
if (ret) {
dev_err(pdev-dev, unable to write reg BCI Ctl1 0x%X\n,
-- 
1.8.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 09/13] MFD: twl-core: re-group the twl_mapping table for easier reading

2012-11-13 Thread Peter Ujfalusi
Group the twl_mapping table in 5 lines chunks so it is more easier to find
the row we are looking for (if we need to).

Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
 drivers/mfd/twl-core.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index bb33b52..f857097 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -189,28 +189,29 @@ static struct twl_mapping twl4030_map[] = {
 */
 
{ 0, TWL4030_BASEADD_USB },
-
{ 1, TWL4030_BASEADD_AUDIO_VOICE },
{ 1, TWL4030_BASEADD_GPIO },
{ 1, TWL4030_BASEADD_INTBR },
{ 1, TWL4030_BASEADD_PIH },
-   { 1, TWL4030_BASEADD_TEST },
 
+   { 1, TWL4030_BASEADD_TEST },
{ 2, TWL4030_BASEADD_KEYPAD },
{ 2, TWL4030_BASEADD_MADC },
{ 2, TWL4030_BASEADD_INTERRUPTS },
{ 2, TWL4030_BASEADD_LED },
+
{ 2, TWL4030_BASEADD_MAIN_CHARGE },
{ 2, TWL4030_BASEADD_PRECHARGE },
{ 2, TWL4030_BASEADD_PWM0 },
{ 2, TWL4030_BASEADD_PWM1 },
{ 2, TWL4030_BASEADD_PWMA },
+
{ 2, TWL4030_BASEADD_PWMB },
{ 2, TWL5031_BASEADD_ACCESSORY },
{ 2, TWL5031_BASEADD_INTERRUPTS },
-
{ 3, TWL4030_BASEADD_BACKUP },
{ 3, TWL4030_BASEADD_INT },
+
{ 3, TWL4030_BASEADD_PM_MASTER },
{ 3, TWL4030_BASEADD_PM_RECEIVER },
{ 3, TWL4030_BASEADD_RTC },
@@ -273,9 +274,9 @@ static struct twl_mapping twl6030_map[] = {
{ SUB_CHIP_ID2, TWL6030_BASEADD_RSV },
{ SUB_CHIP_ID2, TWL6030_BASEADD_RSV },
{ SUB_CHIP_ID2, TWL6030_BASEADD_RSV },
+
{ SUB_CHIP_ID0, TWL6030_BASEADD_PM_MASTER },
{ SUB_CHIP_ID0, TWL6030_BASEADD_PM_SLAVE_MISC },
-
{ SUB_CHIP_ID0, TWL6030_BASEADD_RTC },
{ SUB_CHIP_ID0, TWL6030_BASEADD_MEM },
{ SUB_CHIP_ID1, TWL6025_BASEADD_CHARGER },
-- 
1.8.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 00/13] MFD: twl drivers: Convert to regmap IO and cleanups

2012-11-13 Thread Peter Ujfalusi
Hello,

This series converts the twl-core to use regmap for IO towards the chip.
With the conversion to regmap IO we no longer need to allocate bigger buffer for
writes.
I have appended patches to this series to make some cleanups which will help in
the future to further clean up the twl stack.

The series depends on a regression fix patch for the twl-core:
https://patchwork.kernel.org/patch/1679421/

Regards,
Peter
---
Peter Ujfalusi (13):
  MFD: twl-core: Register twl4030-madc child only for twl4030 class
  MFD: twl-core: Support for proper PWM drivers
  MFD: twl-core: Convert to use regmap for I/O
  MFD/rtc/gpio: twl: No need to allocate bigger buffer for write
  MFD: twl-core: Clean up and correct child registration
  mfd: twl: Remove unused TWL_MODULE definitions
  mfd: twl: Convert module id definitions to enums
  mfd: twl: Use decimal numbers for TWL6030_MODULE_IDs
  MFD: twl-core: re-group the twl_mapping table for easier reading
  mfd: twl4030-madc: Change TWL4030_MODULE_* ids to TWL_MODULE_*
  mfd: twl4030-power: Change TWL4030_MODULE_* ids to TWL_MODULE_*
  mfd: twl4030-irq: Change TWL4030_MODULE_* ids to TWL_MODULE_*
  mfd: twl-core: Change TWL4030_MODULE_* ids to TWL_MODULE_*

 drivers/gpio/gpio-twl4030.c |  12 +--
 drivers/mfd/twl-core.c  | 227 +++-
 drivers/mfd/twl4030-irq.c   |  10 +-
 drivers/mfd/twl4030-madc.c  |  14 +--
 drivers/mfd/twl4030-power.c | 124 ++--
 drivers/mfd/twl6030-irq.c   |   4 +-
 drivers/rtc/rtc-twl.c   |  32 +++
 include/linux/i2c/twl.h |  73 +++---
 8 files changed, 241 insertions(+), 255 deletions(-)

-- 
1.8.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 05/13] MFD: twl-core: Clean up and correct child registration

2012-11-13 Thread Peter Ujfalusi
Make the twl child registration calls a bit more uniform by always using the
SUB_CHIP_ID* define instead of the mixed use of the define and magic number.

At the same time correct the following devices so they are registered for the
correct parent device (i2c slave):
twl4030_wdt is accessible on 0x4b address and not 0x48
twl4030_pwrbutton is accessible on 0x4b address and not 0x49
twl4030-audio is on 0x49 all the time

Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
 drivers/mfd/twl-core.c | 27 ---
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index a55ab15..d666c9d 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -645,7 +645,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned 
irq_base,
 
if (IS_ENABLED(CONFIG_TWL4030_MADC)  pdata-madc 
twl_class_is_4030()) {
-   child = add_child(2, twl4030_madc,
+   child = add_child(SUB_CHIP_ID2, twl4030_madc,
pdata-madc, sizeof(*pdata-madc),
true, irq_base + MADC_INTR_OFFSET, 0);
if (IS_ERR(child))
@@ -661,8 +661,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned 
irq_base,
 * HW security concerns, and least privilege.
 */
sub_chip_id = twl_map[TWL_MODULE_RTC].sid;
-   child = add_child(sub_chip_id, twl_rtc,
-   NULL, 0,
+   child = add_child(sub_chip_id, twl_rtc, NULL, 0,
true, irq_base + RTC_INTR_OFFSET, 0);
if (IS_ERR(child))
return PTR_ERR(child);
@@ -728,9 +727,8 @@ add_children(struct twl4030_platform_data *pdata, unsigned 
irq_base,
 
}
 
-   child = add_child(0, twl4030_usb,
-   pdata-usb, sizeof(*pdata-usb),
-   true,
+   child = add_child(SUB_CHIP_ID0, twl4030_usb,
+   pdata-usb, sizeof(*pdata-usb), true,
/* irq0 = USB_PRES, irq1 = USB */
irq_base + USB_PRES_INTR_OFFSET,
irq_base + USB_INTR_OFFSET);
@@ -778,9 +776,8 @@ add_children(struct twl4030_platform_data *pdata, unsigned 
irq_base,
 
pdata-usb-features = features;
 
-   child = add_child(0, twl6030_usb,
-   pdata-usb, sizeof(*pdata-usb),
-   true,
+   child = add_child(SUB_CHIP_ID0, twl6030_usb,
+   pdata-usb, sizeof(*pdata-usb), true,
/* irq1 = VBUS_PRES, irq0 = USB ID */
irq_base + USBOTG_INTR_OFFSET,
irq_base + USB_PRES_INTR_OFFSET);
@@ -804,22 +801,22 @@ add_children(struct twl4030_platform_data *pdata, 
unsigned irq_base,
}
 
if (IS_ENABLED(CONFIG_TWL4030_WATCHDOG)  twl_class_is_4030()) {
-   child = add_child(0, twl4030_wdt, NULL, 0, false, 0, 0);
+   child = add_child(SUB_CHIP_ID3, twl4030_wdt, NULL, 0,
+ false, 0, 0);
if (IS_ERR(child))
return PTR_ERR(child);
}
 
if (IS_ENABLED(CONFIG_INPUT_TWL4030_PWRBUTTON)  twl_class_is_4030()) {
-   child = add_child(1, twl4030_pwrbutton,
-   NULL, 0, true, irq_base + 8 + 0, 0);
+   child = add_child(SUB_CHIP_ID3, twl4030_pwrbutton, NULL, 0,
+ true, irq_base + 8 + 0, 0);
if (IS_ERR(child))
return PTR_ERR(child);
}
 
if (IS_ENABLED(CONFIG_MFD_TWL4030_AUDIO)  pdata-audio 
twl_class_is_4030()) {
-   sub_chip_id = twl_map[TWL_MODULE_AUDIO_VOICE].sid;
-   child = add_child(sub_chip_id, twl4030-audio,
+   child = add_child(SUB_CHIP_ID1, twl4030-audio,
pdata-audio, sizeof(*pdata-audio),
false, 0, 0);
if (IS_ERR(child))
@@ -1059,7 +1056,7 @@ add_children(struct twl4030_platform_data *pdata, 
unsigned irq_base,
 
if (IS_ENABLED(CONFIG_CHARGER_TWL4030)  pdata-bci 
!(features  (TPS_SUBSET | TWL5031))) {
-   child = add_child(3, twl4030_bci,
+   child = add_child(SUB_CHIP_ID3, twl4030_bci,
pdata-bci, sizeof(*pdata-bci), false,
/* irq0 = CHG_PRES, irq1 = BCI */
irq_base + BCI_PRES_INTR_OFFSET,
-- 
1.8.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ

[PATCH 06/13] mfd: twl: Remove unused TWL_MODULE definitions

2012-11-13 Thread Peter Ujfalusi
AUDIO and MADC only available on twl4030 series and the TWL_MODULE_* mapping
is not needed.

Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
 include/linux/i2c/twl.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/include/linux/i2c/twl.h b/include/linux/i2c/twl.h
index 9a5e284..7278c72 100644
--- a/include/linux/i2c/twl.h
+++ b/include/linux/i2c/twl.h
@@ -73,9 +73,7 @@
 #define TWL4030_MODULE_SECURED_REG 0x17
 
 #define TWL_MODULE_USB TWL4030_MODULE_USB
-#define TWL_MODULE_AUDIO_VOICE TWL4030_MODULE_AUDIO_VOICE
 #define TWL_MODULE_PIH TWL4030_MODULE_PIH
-#define TWL_MODULE_MADCTWL4030_MODULE_MADC
 #define TWL_MODULE_MAIN_CHARGE TWL4030_MODULE_MAIN_CHARGE
 #define TWL_MODULE_PM_MASTER   TWL4030_MODULE_PM_MASTER
 #define TWL_MODULE_PM_RECEIVER TWL4030_MODULE_PM_RECEIVER
-- 
1.8.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 02/13] MFD: twl-core: Support for proper PWM drivers

2012-11-13 Thread Peter Ujfalusi
The twl6030-pwm driver is going to be deleted since it was only able to
control the Charging indicator LED on the twl6030 PMIC.
The new set of drivers are going to provide support for both PWMs and PWM
driven LED outputs on TWL4030 and TWL6030 PMICs.
The twl-pwm driver will handle the PWMs (2 instance) while the twl-pwmled
driver is to control the two LED instance on TWL4030 and to charging
indicator LED (1 instance) on TWL6030.

Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
 drivers/mfd/twl-core.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index d7577cb..1dfd583 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -671,8 +671,15 @@ add_children(struct twl4030_platform_data *pdata, unsigned 
irq_base,
return PTR_ERR(child);
}
 
-   if (IS_ENABLED(CONFIG_PWM_TWL6030)  twl_class_is_6030()) {
-   child = add_child(SUB_CHIP_ID1, twl6030-pwm, NULL, 0,
+   if (IS_ENABLED(CONFIG_PWM_TWL)) {
+   child = add_child(SUB_CHIP_ID1, twl-pwm, NULL, 0,
+ false, 0, 0);
+   if (IS_ERR(child))
+   return PTR_ERR(child);
+   }
+
+   if (IS_ENABLED(CONFIG_PWM_TWL_LED)) {
+   child = add_child(SUB_CHIP_ID1, twl-pwmled, NULL, 0,
  false, 0, 0);
if (IS_ERR(child))
return PTR_ERR(child);
-- 
1.8.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] gpio: twl4030: Use only TWL4030_MODULE_LED for LED configuration

2012-11-13 Thread Peter Ujfalusi
Avoid using the TWL4030_MODULE_PWMA/B as module ID. The LEDEN, PWMA ON/OFF
and PWMB ON/OFF registers are in a continuous range starting from LED base.
This is going to be helpful for further cleanup in the twl stack.

No functional changes.

Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
 drivers/gpio/gpio-twl4030.c | 35 ++-
 1 file changed, 18 insertions(+), 17 deletions(-)

diff --git a/drivers/gpio/gpio-twl4030.c b/drivers/gpio/gpio-twl4030.c
index c5f8ca2..d2138b0 100644
--- a/drivers/gpio/gpio-twl4030.c
+++ b/drivers/gpio/gpio-twl4030.c
@@ -88,11 +88,15 @@ static inline int gpio_twl4030_write(u8 address, u8 data)
 /*--*/
 
 /*
- * LED register offsets (use TWL4030_MODULE_{LED,PWMA,PWMB}))
+ * LED register offsets from TWL_MODULE_LED base
  * PWMs A and B are dedicated to LEDs A and B, respectively.
  */
 
-#define TWL4030_LED_LEDEN  0x0
+#define TWL4030_LED_LEDEN_REG  0x00
+#define TWL4030_PWMAON_REG 0x01
+#define TWL4030_PWMAOFF_REG0x02
+#define TWL4030_PWMBON_REG 0x03
+#define TWL4030_PWMBOFF_REG0x04
 
 /* LEDEN bits */
 #define LEDEN_LEDAON   BIT(0)
@@ -104,9 +108,6 @@ static inline int gpio_twl4030_write(u8 address, u8 data)
 #define LEDEN_PWM_LENGTHA  BIT(6)
 #define LEDEN_PWM_LENGTHB  BIT(7)
 
-#define TWL4030_PWMx_PWMxON0x0
-#define TWL4030_PWMx_PWMxOFF   0x1
-
 #define PWMxON_LENGTH  BIT(7)
 
 /*--*/
@@ -145,7 +146,7 @@ static void twl4030_led_set_value(int led, int value)
else
cached_leden |= mask;
status = twl_i2c_write_u8(TWL4030_MODULE_LED, cached_leden,
-   TWL4030_LED_LEDEN);
+ TWL4030_LED_LEDEN_REG);
mutex_unlock(gpio_lock);
 }
 
@@ -216,33 +217,33 @@ static int twl_request(struct gpio_chip *chip, unsigned 
offset)
if (offset = TWL4030_GPIO_MAX) {
u8  ledclr_mask = LEDEN_LEDAON | LEDEN_LEDAEXT
| LEDEN_LEDAPWM | LEDEN_PWM_LENGTHA;
-   u8  module = TWL4030_MODULE_PWMA;
+   u8  reg = TWL4030_PWMAON_REG;
 
offset -= TWL4030_GPIO_MAX;
if (offset) {
ledclr_mask = 1;
-   module = TWL4030_MODULE_PWMB;
+   reg = TWL4030_PWMBON_REG;
}
 
/* initialize PWM to always-drive */
-   status = twl_i2c_write_u8(module, 0x7f,
-   TWL4030_PWMx_PWMxOFF);
+   /* Configure PWM OFF register first */
+   status = twl_i2c_write_u8(TWL4030_MODULE_LED, 0x7f, reg + 1);
if (status  0)
goto done;
-   status = twl_i2c_write_u8(module, 0x7f,
-   TWL4030_PWMx_PWMxON);
+
+   /* Followed by PWM ON register */
+   status = twl_i2c_write_u8(TWL4030_MODULE_LED, 0x7f, reg);
if (status  0)
goto done;
 
/* init LED to not-driven (high) */
-   module = TWL4030_MODULE_LED;
-   status = twl_i2c_read_u8(module, cached_leden,
-   TWL4030_LED_LEDEN);
+   status = twl_i2c_read_u8(TWL4030_MODULE_LED, cached_leden,
+TWL4030_LED_LEDEN_REG);
if (status  0)
goto done;
cached_leden = ~ledclr_mask;
-   status = twl_i2c_write_u8(module, cached_leden,
-   TWL4030_LED_LEDEN);
+   status = twl_i2c_write_u8(TWL4030_MODULE_LED, cached_leden,
+ TWL4030_LED_LEDEN_REG);
if (status  0)
goto done;
 
-- 
1.8.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] input: twl4030-pwrbutton: Change TWL4030_MODULE_PM_MASTER to TWL_MODULE_PM_MASTER

2012-11-13 Thread Peter Ujfalusi
To facilitate upcoming cleanup in twl stack.
No functional changes.

Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
 drivers/input/misc/twl4030-pwrbutton.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/input/misc/twl4030-pwrbutton.c 
b/drivers/input/misc/twl4030-pwrbutton.c
index b3dd96d..27c2bc8 100644
--- a/drivers/input/misc/twl4030-pwrbutton.c
+++ b/drivers/input/misc/twl4030-pwrbutton.c
@@ -39,8 +39,7 @@ static irqreturn_t powerbutton_irq(int irq, void *_pwr)
int err;
u8 value;
 
-   err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, value,
-   STS_HW_CONDITIONS);
+   err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, value, STS_HW_CONDITIONS);
if (!err)  {
pm_wakeup_event(pwr-dev.parent, 0);
input_report_key(pwr, KEY_POWER, value  PWR_PWRON_IRQ);
-- 
1.8.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] wdt: twl4030: Change TWL4030_MODULE_PM_RECEIVER to TWL_MODULE_PM_RECEIVER

2012-11-13 Thread Peter Ujfalusi
To facilitate upcoming cleanup in twl stack.
No functional changes.

Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
 drivers/watchdog/twl4030_wdt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/watchdog/twl4030_wdt.c b/drivers/watchdog/twl4030_wdt.c
index 249f113..0501638 100644
--- a/drivers/watchdog/twl4030_wdt.c
+++ b/drivers/watchdog/twl4030_wdt.c
@@ -49,8 +49,8 @@ MODULE_PARM_DESC(nowayout, Watchdog cannot be stopped once 
started 
 
 static int twl4030_wdt_write(unsigned char val)
 {
-   return twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, val,
-   TWL4030_WATCHDOG_CFG_REG_OFFS);
+   return twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, val,
+   TWL4030_WATCHDOG_CFG_REG_OFFS);
 }
 
 static int twl4030_wdt_enable(struct twl4030_wdt *wdt)
-- 
1.8.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] power: twl4030_charger: Change TWL4030_MODULE_* ids to TWL_MODULE_*

2012-11-13 Thread Peter Ujfalusi
To facilitate upcoming cleanup in twl stack.
No functional changes.

Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
 drivers/power/twl4030_charger.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/power/twl4030_charger.c b/drivers/power/twl4030_charger.c
index f9e70cf..a69d0d1 100644
--- a/drivers/power/twl4030_charger.c
+++ b/drivers/power/twl4030_charger.c
@@ -114,12 +114,12 @@ static int twl4030_clear_set(u8 mod_no, u8 clear, u8 set, 
u8 reg)
 
 static int twl4030_bci_read(u8 reg, u8 *val)
 {
-   return twl_i2c_read_u8(TWL4030_MODULE_MAIN_CHARGE, val, reg);
+   return twl_i2c_read_u8(TWL_MODULE_MAIN_CHARGE, val, reg);
 }
 
 static int twl4030_clear_set_boot_bci(u8 clear, u8 set)
 {
-   return twl4030_clear_set(TWL4030_MODULE_PM_MASTER, clear,
+   return twl4030_clear_set(TWL_MODULE_PM_MASTER, clear,
TWL4030_CONFIG_DONE | TWL4030_BCIAUTOWEN | set,
TWL4030_PM_MASTER_BOOT_BCI);
 }
@@ -152,7 +152,7 @@ static int twl4030_bci_have_vbus(struct twl4030_bci *bci)
int ret;
u8 hwsts;
 
-   ret = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, hwsts,
+   ret = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, hwsts,
  TWL4030_PM_MASTER_STS_HW_CONDITIONS);
if (ret  0)
return 0;
@@ -199,7 +199,7 @@ static int twl4030_charger_enable_usb(struct twl4030_bci 
*bci, bool enable)
return ret;
 
/* forcing USBFASTMCHG(BCIMFSTS4[2]) to 1 */
-   ret = twl4030_clear_set(TWL4030_MODULE_MAIN_CHARGE, 0,
+   ret = twl4030_clear_set(TWL_MODULE_MAIN_CHARGE, 0,
TWL4030_USBFASTMCHG, TWL4030_BCIMFSTS4);
} else {
ret = twl4030_clear_set_boot_bci(TWL4030_BCIAUTOUSB, 0);
@@ -238,7 +238,7 @@ static int twl4030_charger_enable_backup(int uvolt, int 
uamp)
if (uvolt  250 ||
uamp  25) {
/* disable charging of backup battery */
-   ret = twl4030_clear_set(TWL4030_MODULE_PM_RECEIVER,
+   ret = twl4030_clear_set(TWL_MODULE_PM_RECEIVER,
TWL4030_BBCHEN, 0, TWL4030_BB_CFG);
return ret;
}
@@ -262,7 +262,7 @@ static int twl4030_charger_enable_backup(int uvolt, int 
uamp)
else
flags |= TWL4030_BBISEL_25uA;
 
-   ret = twl4030_clear_set(TWL4030_MODULE_PM_RECEIVER,
+   ret = twl4030_clear_set(TWL_MODULE_PM_RECEIVER,
TWL4030_BBSEL_MASK | TWL4030_BBISEL_MASK,
flags,
TWL4030_BB_CFG);
-- 
1.8.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] usb: otg: twl4030: Change TWL4030_MODULE_* ids to TWL_MODULE_*

2012-11-13 Thread Peter Ujfalusi
To facilitate upcoming cleanup in twl stack.
No functional changes.

Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
 drivers/usb/otg/twl4030-usb.c | 46 ---
 1 file changed, 21 insertions(+), 25 deletions(-)

diff --git a/drivers/usb/otg/twl4030-usb.c b/drivers/usb/otg/twl4030-usb.c
index f0d2e75..11b2a12 100644
--- a/drivers/usb/otg/twl4030-usb.c
+++ b/drivers/usb/otg/twl4030-usb.c
@@ -123,10 +123,10 @@
 #define PHY_CLK_CTRL_STS   0xFF
 #define PHY_DPLL_CLK   (1  0)
 
-/* In module TWL4030_MODULE_PM_MASTER */
+/* In module TWL_MODULE_PM_MASTER */
 #define STS_HW_CONDITIONS  0x0F
 
-/* In module TWL4030_MODULE_PM_RECEIVER */
+/* In module TWL_MODULE_PM_RECEIVER */
 #define VUSB_DEDICATED10x7D
 #define VUSB_DEDICATED20x7E
 #define VUSB1V5_DEV_GRP0x71
@@ -195,14 +195,14 @@ static int twl4030_i2c_write_u8_verify(struct twl4030_usb 
*twl,
 }
 
 #define twl4030_usb_write_verify(twl, address, data)   \
-   twl4030_i2c_write_u8_verify(twl, TWL4030_MODULE_USB, (data), (address))
+   twl4030_i2c_write_u8_verify(twl, TWL_MODULE_USB, (data), (address))
 
 static inline int twl4030_usb_write(struct twl4030_usb *twl,
u8 address, u8 data)
 {
int ret = 0;
 
-   ret = twl_i2c_write_u8(TWL4030_MODULE_USB, data, address);
+   ret = twl_i2c_write_u8(TWL_MODULE_USB, data, address);
if (ret  0)
dev_dbg(twl-dev,
TWL4030:USB:Write[0x%x] Error %d\n, address, ret);
@@ -227,7 +227,7 @@ static inline int twl4030_readb(struct twl4030_usb *twl, u8 
module, u8 address)
 
 static inline int twl4030_usb_read(struct twl4030_usb *twl, u8 address)
 {
-   return twl4030_readb(twl, TWL4030_MODULE_USB, address);
+   return twl4030_readb(twl, TWL_MODULE_USB, address);
 }
 
 /*-*/
@@ -264,8 +264,7 @@ static enum omap_musb_vbus_id_status
 * signal is active, the OTG module is activated, and
 * its interrupt may be raised (may wake the system).
 */
-   status = twl4030_readb(twl, TWL4030_MODULE_PM_MASTER,
-   STS_HW_CONDITIONS);
+   status = twl4030_readb(twl, TWL_MODULE_PM_MASTER, STS_HW_CONDITIONS);
if (status  0)
dev_err(twl-dev, USB link status err %d\n, status);
else if (status  (BIT(7) | BIT(2))) {
@@ -372,8 +371,7 @@ static void twl4030_phy_power(struct twl4030_usb *twl, int 
on)
 * SLEEP. We work around this by clearing the bit after usv3v1
 * is re-activated. This ensures that VUSB3V1 is really active.
 */
-   twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0,
-   VUSB_DEDICATED2);
+   twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB_DEDICATED2);
regulator_enable(twl-usb1v5);
__twl4030_phy_power(twl, 1);
twl4030_usb_write(twl, PHY_CLK_CTRL,
@@ -419,50 +417,48 @@ static void twl4030_phy_resume(struct twl4030_usb *twl)
 static int twl4030_usb_ldo_init(struct twl4030_usb *twl)
 {
/* Enable writing to power configuration registers */
-   twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER,
-   TWL4030_PM_MASTER_KEY_CFG1,
-   TWL4030_PM_MASTER_PROTECT_KEY);
+   twl_i2c_write_u8(TWL_MODULE_PM_MASTER, TWL4030_PM_MASTER_KEY_CFG1,
+TWL4030_PM_MASTER_PROTECT_KEY);
 
-   twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER,
-   TWL4030_PM_MASTER_KEY_CFG2,
-   TWL4030_PM_MASTER_PROTECT_KEY);
+   twl_i2c_write_u8(TWL_MODULE_PM_MASTER, TWL4030_PM_MASTER_KEY_CFG2,
+TWL4030_PM_MASTER_PROTECT_KEY);
 
/* Keep VUSB3V1 LDO in sleep state until VBUS/ID change detected*/
-   /*twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB_DEDICATED2);*/
+   /*twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB_DEDICATED2);*/
 
/* input to VUSB3V1 LDO is from VBAT, not VBUS */
-   twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0x14, VUSB_DEDICATED1);
+   twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0x14, VUSB_DEDICATED1);
 
/* Initialize 3.1V regulator */
-   twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB3V1_DEV_GRP);
+   twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB3V1_DEV_GRP);
 
twl-usb3v1 = regulator_get(twl-dev, usb3v1);
if (IS_ERR(twl-usb3v1))
return -ENODEV;
 
-   twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB3V1_TYPE);
+   twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB3V1_TYPE);
 
/* Initialize 1.5V regulator */
-   twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB1V5_DEV_GRP);
+   twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB1V5_DEV_GRP

Re: [PATCH] usb: otg: twl4030: Change TWL4030_MODULE_* ids to TWL_MODULE_*

2012-11-13 Thread Peter Ujfalusi
Hi Felipe,

On 11/13/2012 10:47 AM, Felipe Balbi wrote:
 On Tue, Nov 13, 2012 at 10:43:38AM +0100, Peter Ujfalusi wrote:
 To facilitate upcoming cleanup in twl stack.
 No functional changes.

 Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
 
 I guess this one must go together with the rest of your series...

I made the split between the patches and they are good to go in their separate
ways to avoid cross tree hassle.
All of the defines were in place originally but they were used in non
consistent ways.
All of these will help in the future to clean up the twl core without breaking
the child drivers.

-- 
Péter

 Acked-by: Felipe Balbi ba...@ti.com
 
 ---
  drivers/usb/otg/twl4030-usb.c | 46 
 ---
  1 file changed, 21 insertions(+), 25 deletions(-)

 diff --git a/drivers/usb/otg/twl4030-usb.c b/drivers/usb/otg/twl4030-usb.c
 index f0d2e75..11b2a12 100644
 --- a/drivers/usb/otg/twl4030-usb.c
 +++ b/drivers/usb/otg/twl4030-usb.c
 @@ -123,10 +123,10 @@
  #define PHY_CLK_CTRL_STS0xFF
  #define PHY_DPLL_CLK(1  0)
  
 -/* In module TWL4030_MODULE_PM_MASTER */
 +/* In module TWL_MODULE_PM_MASTER */
  #define STS_HW_CONDITIONS   0x0F
  
 -/* In module TWL4030_MODULE_PM_RECEIVER */
 +/* In module TWL_MODULE_PM_RECEIVER */
  #define VUSB_DEDICATED1 0x7D
  #define VUSB_DEDICATED2 0x7E
  #define VUSB1V5_DEV_GRP 0x71
 @@ -195,14 +195,14 @@ static int twl4030_i2c_write_u8_verify(struct 
 twl4030_usb *twl,
  }
  
  #define twl4030_usb_write_verify(twl, address, data)\
 -twl4030_i2c_write_u8_verify(twl, TWL4030_MODULE_USB, (data), (address))
 +twl4030_i2c_write_u8_verify(twl, TWL_MODULE_USB, (data), (address))
  
  static inline int twl4030_usb_write(struct twl4030_usb *twl,
  u8 address, u8 data)
  {
  int ret = 0;
  
 -ret = twl_i2c_write_u8(TWL4030_MODULE_USB, data, address);
 +ret = twl_i2c_write_u8(TWL_MODULE_USB, data, address);
  if (ret  0)
  dev_dbg(twl-dev,
  TWL4030:USB:Write[0x%x] Error %d\n, address, ret);
 @@ -227,7 +227,7 @@ static inline int twl4030_readb(struct twl4030_usb *twl, 
 u8 module, u8 address)
  
  static inline int twl4030_usb_read(struct twl4030_usb *twl, u8 address)
  {
 -return twl4030_readb(twl, TWL4030_MODULE_USB, address);
 +return twl4030_readb(twl, TWL_MODULE_USB, address);
  }
  
  
 /*-*/
 @@ -264,8 +264,7 @@ static enum omap_musb_vbus_id_status
   * signal is active, the OTG module is activated, and
   * its interrupt may be raised (may wake the system).
   */
 -status = twl4030_readb(twl, TWL4030_MODULE_PM_MASTER,
 -STS_HW_CONDITIONS);
 +status = twl4030_readb(twl, TWL_MODULE_PM_MASTER, STS_HW_CONDITIONS);
  if (status  0)
  dev_err(twl-dev, USB link status err %d\n, status);
  else if (status  (BIT(7) | BIT(2))) {
 @@ -372,8 +371,7 @@ static void twl4030_phy_power(struct twl4030_usb *twl, 
 int on)
   * SLEEP. We work around this by clearing the bit after usv3v1
   * is re-activated. This ensures that VUSB3V1 is really active.
   */
 -twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0,
 -VUSB_DEDICATED2);
 +twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB_DEDICATED2);
  regulator_enable(twl-usb1v5);
  __twl4030_phy_power(twl, 1);
  twl4030_usb_write(twl, PHY_CLK_CTRL,
 @@ -419,50 +417,48 @@ static void twl4030_phy_resume(struct twl4030_usb *twl)
  static int twl4030_usb_ldo_init(struct twl4030_usb *twl)
  {
  /* Enable writing to power configuration registers */
 -twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER,
 -TWL4030_PM_MASTER_KEY_CFG1,
 -TWL4030_PM_MASTER_PROTECT_KEY);
 +twl_i2c_write_u8(TWL_MODULE_PM_MASTER, TWL4030_PM_MASTER_KEY_CFG1,
 + TWL4030_PM_MASTER_PROTECT_KEY);
  
 -twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER,
 -TWL4030_PM_MASTER_KEY_CFG2,
 -TWL4030_PM_MASTER_PROTECT_KEY);
 +twl_i2c_write_u8(TWL_MODULE_PM_MASTER, TWL4030_PM_MASTER_KEY_CFG2,
 + TWL4030_PM_MASTER_PROTECT_KEY);
  
  /* Keep VUSB3V1 LDO in sleep state until VBUS/ID change detected*/
 -/*twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB_DEDICATED2);*/
 +/*twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB_DEDICATED2);*/
  
  /* input to VUSB3V1 LDO is from VBAT, not VBUS */
 -twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0x14, VUSB_DEDICATED1);
 +twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0x14, VUSB_DEDICATED1);
  
  /* Initialize 3.1V regulator */
 -twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB3V1_DEV_GRP);
 +twl_i2c_write_u8

Re: [PATCH] usb: otg: twl4030: Change TWL4030_MODULE_* ids to TWL_MODULE_*

2012-11-13 Thread Peter Ujfalusi
On 11/13/2012 11:37 AM, Felipe Balbi wrote:
 ok good. Unfortunately I have already sent this merge window's pull
 request to Greg so I'd have to delay this until v3.9. If that's ok with
 you, I can take it through my tree.

I hoped that this can go with 3.8 since in 3.9 I'm planning to remove all of
these TWL4030_MODULE_* defines which have TWL_MODULE_* counterpart.
In this case I will introduce dummy defines to point to the correct place for
the USB in 3.9 and we can get rid of the rest of these in 3.10. Oh well. This
is going to take a bit longer than I have anticipated.
I can't think of any other subsytem this can go through...

-- 
Péter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 1/3] leds: leds-pwm: Convert to use devm_get_pwm

2012-11-13 Thread Peter Ujfalusi
Hi Bryan,

On 11/14/2012 02:14 AM, Bryan Wu wrote:
 diff --git a/include/linux/leds_pwm.h b/include/linux/leds_pwm.h
 index 33a0711..a65e964 100644
 --- a/include/linux/leds_pwm.h
 +++ b/include/linux/leds_pwm.h
 @@ -7,7 +7,7 @@
  struct led_pwm {
 const char  *name;
 const char  *default_trigger;
 -   unsignedpwm_id;
 +   unsignedpwm_id __deprecated;
 
 I suggest we remove this later, we can provide patches from this from
 platform data of board file. And I think this patch is good for me to
 merge, will do it soon.

Yes, we can remove it in 3.9. I marked it as deprecated for now to avoid
breakage - if any - in 3.8.

Thank you,
Péter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] backlight: pandora_bl: Change TWL4030_MODULE_PWM0 to TWL_MODULE_PWM

2012-11-14 Thread Peter Ujfalusi
TWL_MODULE_PWM is defined as:
#define TWL_MODULE_PWM  TWL4030_MODULE_PWM0

Use the common module ID define here which will facilitate the upcoming
twl-core cleanup.

Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
 drivers/video/backlight/pandora_bl.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/video/backlight/pandora_bl.c 
b/drivers/video/backlight/pandora_bl.c
index 4ec3074..633b0a2 100644
--- a/drivers/video/backlight/pandora_bl.c
+++ b/drivers/video/backlight/pandora_bl.c
@@ -71,8 +71,7 @@ static int pandora_backlight_update_status(struct 
backlight_device *bl)
 * set PWM duty cycle to max. TPS61161 seems to use this
 * to calibrate it's PWM sensitivity when it starts.
 */
-   twl_i2c_write_u8(TWL4030_MODULE_PWM0, MAX_VALUE,
-   TWL_PWM0_OFF);
+   twl_i2c_write_u8(TWL_MODULE_PWM, MAX_VALUE, TWL_PWM0_OFF);
 
/* first enable clock, then PWM0 out */
twl_i2c_read_u8(TWL4030_MODULE_INTBR, r, TWL_INTBR_GPBR1);
@@ -90,8 +89,7 @@ static int pandora_backlight_update_status(struct 
backlight_device *bl)
usleep_range(2000, 1);
}
 
-   twl_i2c_write_u8(TWL4030_MODULE_PWM0, MIN_VALUE + brightness,
-   TWL_PWM0_OFF);
+   twl_i2c_write_u8(TWL_MODULE_PWM, MIN_VALUE + brightness, TWL_PWM0_OFF);
 
 done:
if (brightness != 0)
@@ -132,7 +130,7 @@ static int pandora_backlight_probe(struct platform_device 
*pdev)
platform_set_drvdata(pdev, bl);
 
/* 64 cycle period, ON position 0 */
-   twl_i2c_write_u8(TWL4030_MODULE_PWM0, 0x80, TWL_PWM0_ON);
+   twl_i2c_write_u8(TWL_MODULE_PWM, 0x80, TWL_PWM0_ON);
 
bl-props.state |= PANDORABL_WAS_OFF;
bl-props.brightness = MAX_USER_VALUE;
-- 
1.8.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] OMAPDSS: Correct check for the callback pointer in dss_dsi_disable_pads()

2012-10-16 Thread Peter Ujfalusi
Appear to be a copy-paste bug: the code was checking board_data-dsi_enable_pads
while calling board_data-dsi_disable_pads.


Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---

Hi Tomi,

not sure if this need to be included to 3.7

Regards,
Peter

 drivers/video/omap2/dss/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/video/omap2/dss/core.c b/drivers/video/omap2/dss/core.c
index b2af72d..7afaf61 100644
--- a/drivers/video/omap2/dss/core.c
+++ b/drivers/video/omap2/dss/core.c
@@ -122,7 +122,7 @@ void dss_dsi_disable_pads(int dsi_id, unsigned lane_mask)
 {
struct omap_dss_board_info *board_data = core.pdev-dev.platform_data;
 
-   if (!board_data-dsi_enable_pads)
+   if (!board_data-dsi_disable_pads)
return;
 
return board_data-dsi_disable_pads(dsi_id, lane_mask);
-- 
1.7.12.3

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/2] MFD: twl6040: Version support fixes, additions

2012-07-16 Thread Peter Ujfalusi
Hello,

The following series fixes the revision information for twl6040 and adds support
for twl6041.

While the first patch is changing a driver in sound/soc/codecs the series can go
via MFD since we do not have pending patches for twl6040 audio part for 3.6.

Regards,
Peter
---
Peter Ujfalusi (2):
  MFD: twl6040: Fix revision information
  MFD: twl6040: Add support for twl6041

 Documentation/devicetree/bindings/mfd/twl6040.txt |2 +-
 drivers/mfd/twl6040-core.c|1 +
 include/linux/mfd/twl6040.h   |5 +++--
 sound/soc/codecs/twl6040.c|2 +-
 4 files changed, 6 insertions(+), 4 deletions(-)

-- 
1.7.8.6

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/2] MFD: twl6040: Fix revision information

2012-07-16 Thread Peter Ujfalusi
twl6040 ES1.1 and ES1.2 have the same revid (0x01).
ES1.3 of twl6040 REVID is 0x02.

Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
 include/linux/mfd/twl6040.h |4 ++--
 sound/soc/codecs/twl6040.c  |2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/linux/mfd/twl6040.h b/include/linux/mfd/twl6040.h
index 6659487..e002097 100644
--- a/include/linux/mfd/twl6040.h
+++ b/include/linux/mfd/twl6040.h
@@ -161,8 +161,8 @@
 #define TWL6040_CELLS  2
 
 #define TWL6040_REV_ES1_0  0x00
-#define TWL6040_REV_ES1_1  0x01
-#define TWL6040_REV_ES1_2  0x02
+#define TWL6040_REV_ES1_1  0x01 /* Rev ES1.1 and ES1.2 */
+#define TWL6040_REV_ES1_3  0x02
 
 #define TWL6040_IRQ_TH 0
 #define TWL6040_IRQ_PLUG   1
diff --git a/sound/soc/codecs/twl6040.c b/sound/soc/codecs/twl6040.c
index a36e9fc..2786de2 100644
--- a/sound/soc/codecs/twl6040.c
+++ b/sound/soc/codecs/twl6040.c
@@ -653,7 +653,7 @@ int twl6040_get_hs_step_size(struct snd_soc_codec *codec)
 {
struct twl6040 *twl6040 = codec-control_data;
 
-   if (twl6040_get_revid(twl6040)  TWL6040_REV_ES1_2)
+   if (twl6040_get_revid(twl6040)  TWL6040_REV_ES1_3)
/* For ES under ES_1.3 HS step is 2 mV */
return 2;
else
-- 
1.7.8.6

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2] MFD: twl6040: Add support for twl6041

2012-07-16 Thread Peter Ujfalusi
The delta between twl6040 and twl6041 is small, the main difference is in
the number of GPOs (3 on twl6040, 1 on twl6041).

Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
 Documentation/devicetree/bindings/mfd/twl6040.txt |2 +-
 drivers/mfd/twl6040-core.c|1 +
 include/linux/mfd/twl6040.h   |1 +
 3 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/Documentation/devicetree/bindings/mfd/twl6040.txt 
b/Documentation/devicetree/bindings/mfd/twl6040.txt
index bc67c6f..c855240 100644
--- a/Documentation/devicetree/bindings/mfd/twl6040.txt
+++ b/Documentation/devicetree/bindings/mfd/twl6040.txt
@@ -6,7 +6,7 @@ They are connected ot the host processor via i2c for commands, 
McPDM for audio
 data and commands.
 
 Required properties:
-- compatible : Must be ti,twl6040;
+- compatible : ti,twl6040 for twl6040, ti,twl6041 for twl6041
 - reg: must be 0x4b for i2c address
 - interrupts: twl6040 has one interrupt line connecteded to the main SoC
 - interrupt-parent: The parent interrupt controller
diff --git a/drivers/mfd/twl6040-core.c b/drivers/mfd/twl6040-core.c
index 4ded9e7..8b4c03b 100644
--- a/drivers/mfd/twl6040-core.c
+++ b/drivers/mfd/twl6040-core.c
@@ -696,6 +696,7 @@ static int __devexit twl6040_remove(struct i2c_client 
*client)
 
 static const struct i2c_device_id twl6040_i2c_id[] = {
{ twl6040, 0, },
+   { twl6041, 0, },
{ },
 };
 MODULE_DEVICE_TABLE(i2c, twl6040_i2c_id);
diff --git a/include/linux/mfd/twl6040.h b/include/linux/mfd/twl6040.h
index e002097..761c99c 100644
--- a/include/linux/mfd/twl6040.h
+++ b/include/linux/mfd/twl6040.h
@@ -163,6 +163,7 @@
 #define TWL6040_REV_ES1_0  0x00
 #define TWL6040_REV_ES1_1  0x01 /* Rev ES1.1 and ES1.2 */
 #define TWL6040_REV_ES1_3  0x02
+#define TWL6041_REV_ES2_0  0x10
 
 #define TWL6040_IRQ_TH 0
 #define TWL6040_IRQ_PLUG   1
-- 
1.7.8.6

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [alsa-devel] [PATCH 1/2] MFD: twl6040: Fix revision information

2012-07-17 Thread Peter Ujfalusi
On 07/17/2012 08:39 AM, Rajeev kumar wrote:
   #define TWL6040_REV_ES1_00x00
 -#define TWL6040_REV_ES1_10x01
 -#define TWL6040_REV_ES1_20x02
 +#define TWL6040_REV_ES1_10x01 /* Rev ES1.1 and ES1.2 */
 +#define TWL6040_REV_ES1_30x02

   #define TWL6040_IRQ_TH0
   #define TWL6040_IRQ_PLUG1
 diff --git a/sound/soc/codecs/twl6040.c b/sound/soc/codecs/twl6040.c
 index a36e9fc..2786de2 100644
 --- a/sound/soc/codecs/twl6040.c
 +++ b/sound/soc/codecs/twl6040.c
 @@ -653,7 +653,7 @@ int twl6040_get_hs_step_size(struct snd_soc_codec *codec)
   {
   struct twl6040 *twl6040 = codec-control_data;

 -if (twl6040_get_revid(twl6040)  TWL6040_REV_ES1_2)
 +if (twl6040_get_revid(twl6040)  TWL6040_REV_ES1_3)
 
 
 Instead of doing this change why not you take a #define for revision and  do
 if (twl6040_get_revid(twl6040)  TWL6040_REV)

ES1.1, ES1.2 of twl6040 have 2mV HS step. Newer revisions (ES1.3 of twl6040
and twl6041) have 1mV HS step.
Here the comment was correct, but the define name was incorrect.

 
 ~Rajeev
 
   /* For ES under ES_1.3 HS step is 2 mV */
   return 2;
   else
 


-- 
Péter


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/3] MFD/GPIO: Add twl6040 GPO driver

2012-07-18 Thread Peter Ujfalusi
Hello,

The following series adds support for the GPO (General Purpose Output) on the
twl6040/41 audio chip.
The series has been tested on SDP4430, compile tested for x86_64 and x86_32 bit
to be sure it does not introduce build breakage.

The series depends on pending changes going through the MFD tree (twl6040
revision fixes, twl6041 support).

Linus, Grant, Samuel: Would it be possible to queue this series via the MFD tree
to avoid merge issues? It applies cleanly on top of gpio-next I believe it will
not cause problems via MFD.

Regards,
Peter
---
Peter Ujfalusi (3):
  mfd: twl6040: Fix GPO mask
  mfd: twl6040: Add twl6040-gpio child
  gpio: Add basic support for TWL6040 GPOs

 Documentation/devicetree/bindings/mfd/twl6040.txt |4 +
 drivers/gpio/Kconfig  |7 +
 drivers/gpio/Makefile |1 +
 drivers/gpio/gpio-twl6040.c   |  137 +
 drivers/mfd/twl6040-core.c|   27 
 include/linux/mfd/twl6040.h   |   11 ++-
 6 files changed, 185 insertions(+), 2 deletions(-)
 create mode 100644 drivers/gpio/gpio-twl6040.c

-- 
1.7.8.6

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/3] gpio: Add basic support for TWL6040 GPOs

2012-07-18 Thread Peter Ujfalusi
TWL6040 provides GPO lines to be used for controlling external devices.The 
number
of lines different between versions: twl6040 have 3 GPO while TWL6041 have 1.

Signed-off-by: Sergio Aguirre saagui...@ti.com
Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
 drivers/gpio/Kconfig|7 ++
 drivers/gpio/Makefile   |1 +
 drivers/gpio/gpio-twl6040.c |  137 +++
 3 files changed, 145 insertions(+), 0 deletions(-)
 create mode 100644 drivers/gpio/gpio-twl6040.c

diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 542f0c0..4ea54a2 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -396,6 +396,13 @@ config GPIO_TWL4030
  Say yes here to access the GPIO signals of various multi-function
  power management chips from Texas Instruments.
 
+config GPIO_TWL6040
+   tristate TWL6040 GPO
+   depends on TWL6040_CORE
+   help
+ Say yes here to access the GPO signals of twl6040
+ audio chip from Texas Instruments.
+
 config GPIO_WM831X
tristate WM831x GPIOs
depends on MFD_WM831X
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index 0f55662..d20f903 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -64,6 +64,7 @@ obj-$(CONFIG_ARCH_DAVINCI_TNETV107X) += gpio-tnetv107x.o
 obj-$(CONFIG_GPIO_TPS65910)+= gpio-tps65910.o
 obj-$(CONFIG_GPIO_TPS65912)+= gpio-tps65912.o
 obj-$(CONFIG_GPIO_TWL4030) += gpio-twl4030.o
+obj-$(CONFIG_GPIO_TWL6040) += gpio-twl6040.o
 obj-$(CONFIG_GPIO_UCB1400) += gpio-ucb1400.o
 obj-$(CONFIG_GPIO_VR41XX)  += gpio-vr41xx.o
 obj-$(CONFIG_GPIO_VX855)   += gpio-vx855.o
diff --git a/drivers/gpio/gpio-twl6040.c b/drivers/gpio/gpio-twl6040.c
new file mode 100644
index 000..f0b2703
--- /dev/null
+++ b/drivers/gpio/gpio-twl6040.c
@@ -0,0 +1,137 @@
+/*
+ * Access to GPOs on TWL6040 chip
+ *
+ * Copyright (C) 2012 Texas Instruments, Inc.
+ *
+ * Authors:
+ * Sergio Aguirre saagui...@ti.com
+ * Peter Ujfalusi peter.ujfal...@ti.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.
+ *
+ * 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/module.h
+#include linux/init.h
+#include linux/kthread.h
+#include linux/irq.h
+#include linux/gpio.h
+#include linux/platform_device.h
+#include linux/of.h
+
+#include linux/mfd/twl6040.h
+
+static struct gpio_chip twl6040gpo_chip;
+
+static int twl6040gpo_get(struct gpio_chip *chip, unsigned offset)
+{
+   struct twl6040 *twl6040 = dev_get_drvdata(chip-dev-parent);
+   int ret = 0;
+
+   ret = twl6040_reg_read(twl6040, TWL6040_REG_GPOCTL);
+   if (ret  0)
+   return ret;
+
+   return (ret  offset)  1;
+}
+
+static int twl6040gpo_direction_out(struct gpio_chip *chip, unsigned offset,
+   int value)
+{
+   /* This only drives GPOs, and can't change direction */
+   return 0;
+}
+
+static void twl6040gpo_set(struct gpio_chip *chip, unsigned offset, int value)
+{
+   struct twl6040 *twl6040 = dev_get_drvdata(chip-dev-parent);
+   int ret;
+   u8 gpoctl;
+
+   ret = twl6040_reg_read(twl6040, TWL6040_REG_GPOCTL);
+   if (ret  0)
+   return;
+
+   if (value)
+   gpoctl = ret | (1  offset);
+   else
+   gpoctl = ret  ~(1  offset);
+
+   twl6040_reg_write(twl6040, TWL6040_REG_GPOCTL, gpoctl);
+}
+
+static struct gpio_chip twl6040gpo_chip = {
+   .label  = twl6040,
+   .owner  = THIS_MODULE,
+   .get= twl6040gpo_get,
+   .direction_output   = twl6040gpo_direction_out,
+   .set= twl6040gpo_set,
+   .can_sleep  = 1,
+};
+
+/*--*/
+
+static int __devinit gpo_twl6040_probe(struct platform_device *pdev)
+{
+   struct twl6040_gpo_data *pdata = pdev-dev.platform_data;
+   struct device *twl6040_core_dev = pdev-dev.parent;
+   struct twl6040 *twl6040 = dev_get_drvdata(twl6040_core_dev);
+   int ret;
+
+   if (pdata)
+   twl6040gpo_chip.base = pdata-gpio_base;
+   else
+   twl6040gpo_chip.base = -1;
+
+   if (twl6040_get_revid(twl6040)  TWL6041_REV_ES2_0)
+   twl6040gpo_chip.ngpio

[PATCH 2/3] mfd: twl6040: Add twl6040-gpio child

2012-07-18 Thread Peter Ujfalusi
Add needed platform data structure and code to be able to load
the GPO child of twl6040.
Update the devicetree binding documentation at the same time.

Signed-off-by: Sergio Aguirre saagui...@ti.com
Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
 Documentation/devicetree/bindings/mfd/twl6040.txt |4 +++
 drivers/mfd/twl6040-core.c|   27 +
 include/linux/mfd/twl6040.h   |9 ++-
 3 files changed, 39 insertions(+), 1 deletions(-)

diff --git a/Documentation/devicetree/bindings/mfd/twl6040.txt 
b/Documentation/devicetree/bindings/mfd/twl6040.txt
index c855240..2a3d55c 100644
--- a/Documentation/devicetree/bindings/mfd/twl6040.txt
+++ b/Documentation/devicetree/bindings/mfd/twl6040.txt
@@ -10,6 +10,8 @@ Required properties:
 - reg: must be 0x4b for i2c address
 - interrupts: twl6040 has one interrupt line connecteded to the main SoC
 - interrupt-parent: The parent interrupt controller
+- gpio-controller:
+- #gpio-cells = 1: twl6040 provides GPO lines.
 - twl6040,audpwron-gpio: Power on GPIO line for the twl6040
 
 - vio-supply: Regulator for the twl6040 VIO supply
@@ -29,6 +31,8 @@ Required properties:
 - ti,viblmotor-res: Resistance parameter for left motor
 - ti,viblmotor-res: Resistance parameter for right motor
 
+- ti,use-gpo: Set it to 1 if the GPO functionality is in use
+
 Optional properties within vibra { } section:
 - vddvibl_uV: If the vddvibl default voltage need to be changed
 - vddvibr_uV: If the vddvibr default voltage need to be changed
diff --git a/drivers/mfd/twl6040-core.c b/drivers/mfd/twl6040-core.c
index b0fad0f..8ea5b9e 100644
--- a/drivers/mfd/twl6040-core.c
+++ b/drivers/mfd/twl6040-core.c
@@ -59,6 +59,22 @@ static bool twl6040_has_vibra(struct twl6040_platform_data 
*pdata,
return false;
 }
 
+static bool twl6040_has_gpo(struct twl6040_platform_data *pdata,
+ struct device_node *node)
+{
+   int use_gpo;
+
+   if (pdata  pdata-gpo)
+   return true;
+
+#ifdef CONFIG_OF
+   if (!of_property_read_u32(node, ti,use-gpo, use_gpo)  use_gpo)
+   return true;
+#endif
+
+   return false;
+}
+
 int twl6040_reg_read(struct twl6040 *twl6040, unsigned int reg)
 {
int ret;
@@ -631,6 +647,17 @@ static int __devinit twl6040_probe(struct i2c_client 
*client,
children++;
}
 
+   if (twl6040_has_gpo(pdata, node)) {
+   cell = twl6040-cells[children];
+   cell-name = twl6040-gpo;
+
+   if (pdata  pdata-gpo) {
+   cell-platform_data = pdata-gpo;
+   cell-pdata_size = sizeof(*pdata-gpo);
+   }
+   children++;
+   }
+
ret = mfd_add_devices(client-dev, -1, twl6040-cells, children,
  NULL, 0);
if (ret)
diff --git a/include/linux/mfd/twl6040.h b/include/linux/mfd/twl6040.h
index 269b706..8991532 100644
--- a/include/linux/mfd/twl6040.h
+++ b/include/linux/mfd/twl6040.h
@@ -158,7 +158,7 @@
 #define TWL6040_VIBROCDET  0x20
 #define TWL6040_TSHUTDET0x40
 
-#define TWL6040_CELLS  2
+#define TWL6040_CELLS  3
 
 #define TWL6040_REV_ES1_0  0x00
 #define TWL6040_REV_ES1_1  0x01 /* Rev ES1.1 and ES1.2 */
@@ -176,6 +176,8 @@
 #define TWL6040_SYSCLK_SEL_LPPLL   0
 #define TWL6040_SYSCLK_SEL_HPPLL   1
 
+#define TWL6040_GPO_MAX3
+
 struct twl6040_codec_data {
u16 hs_left_step;
u16 hs_right_step;
@@ -192,12 +194,17 @@ struct twl6040_vibra_data {
int vddvibr_uV; /* VDDVIBR volt, set 0 for fixed reg */
 };
 
+struct twl6040_gpo_data {
+   int gpio_base;
+};
+
 struct twl6040_platform_data {
int audpwron_gpio;  /* audio power-on gpio */
unsigned int irq_base;
 
struct twl6040_codec_data *codec;
struct twl6040_vibra_data *vibra;
+   struct twl6040_gpo_data *gpo;
 };
 
 struct regmap;
-- 
1.7.8.6

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/3] mfd: twl6040: Fix GPO mask

2012-07-18 Thread Peter Ujfalusi
Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
 include/linux/mfd/twl6040.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/include/linux/mfd/twl6040.h b/include/linux/mfd/twl6040.h
index eaad49f..269b706 100644
--- a/include/linux/mfd/twl6040.h
+++ b/include/linux/mfd/twl6040.h
@@ -143,7 +143,7 @@
 
 #define TWL6040_GPO1   0x01
 #define TWL6040_GPO2   0x02
-#define TWL6040_GPO3   0x03
+#define TWL6040_GPO3   0x04
 
 /* ACCCTL (0x2D) fields */
 
-- 
1.7.8.6

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] RTC: rtc-twl: Convert to module_platform_driver() and relocate reg_map init

2013-04-16 Thread Peter Ujfalusi
Convert the driver to use module_platform_driver() to register the platform
driver and relocate the rtc_reg_map initialization to platform driver's
probe function.
In this way we can make sure that the twl-core has been already probed since
the core driver will create the device at the end of it's probe function.

Reported-by: Christoph Fritz chf.fr...@googlemail.com
Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
Hi Tony, Alessandro, Christoph,

I think this patch is the correct solution for the issue Christoph reported:
http://www.spinics.net/lists/linux-omap/msg89980.html

We can make sure that the twl-core has been already probed and initialized when
the RTC driver tries to pick the correct register map.

Regards,
Peter

 drivers/rtc/rtc-twl.c | 23 +++
 1 file changed, 7 insertions(+), 16 deletions(-)

diff --git a/drivers/rtc/rtc-twl.c b/drivers/rtc/rtc-twl.c
index 8bc6c80..22b2fd6 100644
--- a/drivers/rtc/rtc-twl.c
+++ b/drivers/rtc/rtc-twl.c
@@ -469,6 +469,12 @@ static int twl_rtc_probe(struct platform_device *pdev)
if (irq = 0)
goto out1;
 
+   /* Initialize the register map */
+   if (twl_class_is_4030())
+   rtc_reg_map = (u8 *)twl4030_rtc_reg_map;
+   else
+   rtc_reg_map = (u8 *)twl6030_rtc_reg_map;
+
ret = twl_rtc_read_u8(rd_reg, REG_RTC_STATUS_REG);
if (ret  0)
goto out1;
@@ -612,22 +618,7 @@ static struct platform_driver twl4030rtc_driver = {
},
 };
 
-static int __init twl_rtc_init(void)
-{
-   if (twl_class_is_4030())
-   rtc_reg_map = (u8 *) twl4030_rtc_reg_map;
-   else
-   rtc_reg_map = (u8 *) twl6030_rtc_reg_map;
-
-   return platform_driver_register(twl4030rtc_driver);
-}
-module_init(twl_rtc_init);
-
-static void __exit twl_rtc_exit(void)
-{
-   platform_driver_unregister(twl4030rtc_driver);
-}
-module_exit(twl_rtc_exit);
+module_platform_driver(twl4030rtc_driver);
 
 MODULE_AUTHOR(Texas Instruments, MontaVista Software);
 MODULE_LICENSE(GPL);
-- 
1.8.1.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] RTC: rtc-twl: Convert to module_platform_driver() and relocate reg_map init

2013-04-16 Thread Peter Ujfalusi
Hi Tomi,

On 04/16/2013 10:10 AM, Tomi Valkeinen wrote:
 Hi,
 
 On 2013-04-16 10:44, Peter Ujfalusi wrote:
 Convert the driver to use module_platform_driver() to register the platform
 driver and relocate the rtc_reg_map initialization to platform driver's
 probe function.
 In this way we can make sure that the twl-core has been already probed since
 the core driver will create the device at the end of it's probe function.

 Reported-by: Christoph Fritz chf.fr...@googlemail.com
 Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
 
 I think there are two distinct things here. The actual fix for the
 regmap, and a module_platform_driver cleanup. I would suggest having
 them in separate patches.
 
 And even if these are combined, I think the patch subject and
 description should talk about fixing the regmap bug. Now it's rather
 unclear that an actual bug is being fixed.

Good point. My thinking was that when I convert the driver to
module_platform_driver() the reg map init must be moved to platform_driver's
probe anyways.
I'll separate the patch and write a bit better commit message for the first.

-- 
Péter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 2/2] RTC: rtc-twl: Cleanup with module_platform_driver() conversion

2013-04-16 Thread Peter Ujfalusi
Use module_platform_driver() to register the platform driver.

Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
 drivers/rtc/rtc-twl.c | 12 +---
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/rtc/rtc-twl.c b/drivers/rtc/rtc-twl.c
index c385e9b..22b2fd6 100644
--- a/drivers/rtc/rtc-twl.c
+++ b/drivers/rtc/rtc-twl.c
@@ -618,17 +618,7 @@ static struct platform_driver twl4030rtc_driver = {
},
 };
 
-static int __init twl_rtc_init(void)
-{
-   return platform_driver_register(twl4030rtc_driver);
-}
-module_init(twl_rtc_init);
-
-static void __exit twl_rtc_exit(void)
-{
-   platform_driver_unregister(twl4030rtc_driver);
-}
-module_exit(twl_rtc_exit);
+module_platform_driver(twl4030rtc_driver);
 
 MODULE_AUTHOR(Texas Instruments, MontaVista Software);
 MODULE_LICENSE(GPL);
-- 
1.8.1.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 1/2] RTC: rtc-twl: Fix rtc_reg_map initialization

2013-04-16 Thread Peter Ujfalusi
Initialize the rtc_reg_map in platform_driver's probe function instead at
module_init time. This way we can make sure that the twl-core has been already
probed and initialized (twl_priv-twl_id is valid) since the platform device
for the RTC driver will be created by the twl-core after it finished it's
init.

Reported-by: Christoph Fritz chf.fr...@googlemail.com
Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
Hi,

As Tomi commented on the first version:
www.spinics.net/lists/linux-omap/msg90064.html
www.spinics.net/lists/linux-omap/msg90066.html

I have separated the actual fix from the module_platform_driver() conversion.

Regards,
Peter

 drivers/rtc/rtc-twl.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/rtc/rtc-twl.c b/drivers/rtc/rtc-twl.c
index 8bc6c80..c385e9b 100644
--- a/drivers/rtc/rtc-twl.c
+++ b/drivers/rtc/rtc-twl.c
@@ -469,6 +469,12 @@ static int twl_rtc_probe(struct platform_device *pdev)
if (irq = 0)
goto out1;
 
+   /* Initialize the register map */
+   if (twl_class_is_4030())
+   rtc_reg_map = (u8 *)twl4030_rtc_reg_map;
+   else
+   rtc_reg_map = (u8 *)twl6030_rtc_reg_map;
+
ret = twl_rtc_read_u8(rd_reg, REG_RTC_STATUS_REG);
if (ret  0)
goto out1;
@@ -614,11 +620,6 @@ static struct platform_driver twl4030rtc_driver = {
 
 static int __init twl_rtc_init(void)
 {
-   if (twl_class_is_4030())
-   rtc_reg_map = (u8 *) twl4030_rtc_reg_map;
-   else
-   rtc_reg_map = (u8 *) twl6030_rtc_reg_map;
-
return platform_driver_register(twl4030rtc_driver);
 }
 module_init(twl_rtc_init);
-- 
1.8.1.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC v2] dmaengine: omap-dma: Start DMA without delay for cyclic channels

2013-04-08 Thread Peter Ujfalusi
Russell,

On 04/03/2013 01:17 PM, Peter Ujfalusi wrote:
 cyclic DMA is only used by audio which needs DMA to be started without a
 delay.
 If the DMA for audio is started using the tasklet we experience random
 channel switch (to be more precise: channel shift).
 
 Reported-by: Peter Meerwald pme...@pmeerw.net
 Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
 ---
 Hi Russell,
 
 Instead of removing the tasklet we can identify the DMA channel used by audio
 based on the cyclic flag of the channel.
 I think this can be used as a short term solution to fix the audio channel 
 shift
 issue and later when we have the dynamic DMA channel allocation we can adjust
 the code.

Could you, please look at this patch?

Thank you,
Péter

 Regards,
 Peter
 
  drivers/dma/omap-dma.c | 20 ++--
  1 file changed, 14 insertions(+), 6 deletions(-)
 
 diff --git a/drivers/dma/omap-dma.c b/drivers/dma/omap-dma.c
 index 2ea3d7e..ec3fc4f 100644
 --- a/drivers/dma/omap-dma.c
 +++ b/drivers/dma/omap-dma.c
 @@ -282,12 +282,20 @@ static void omap_dma_issue_pending(struct dma_chan 
 *chan)
  
   spin_lock_irqsave(c-vc.lock, flags);
   if (vchan_issue_pending(c-vc)  !c-desc) {
 - struct omap_dmadev *d = to_omap_dma_dev(chan-device);
 - spin_lock(d-lock);
 - if (list_empty(c-node))
 - list_add_tail(c-node, d-pending);
 - spin_unlock(d-lock);
 - tasklet_schedule(d-task);
 + /*
 +  * c-cyclic is used only by audio and in this case the DMA need
 +  * to be started without delay.
 +  */
 + if (!c-cyclic) {
 + struct omap_dmadev *d = to_omap_dma_dev(chan-device);
 + spin_lock(d-lock);
 + if (list_empty(c-node))
 + list_add_tail(c-node, d-pending);
 + spin_unlock(d-lock);
 + tasklet_schedule(d-task);
 + } else {
 + omap_dma_start_desc(c);
 + }
   }
   spin_unlock_irqrestore(c-vc.lock, flags);
  }
 

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC v2] dmaengine: omap-dma: Start DMA without delay for cyclic channels

2013-04-09 Thread Peter Ujfalusi
On 04/09/2013 08:52 AM, Santosh Shilimkar wrote:
 I suggest Peter resend the patch with also Grant + Linus W cc:d so
 they can queue it unless there are other related patches pending
 somewhere else.

 Am curious on your suggestion. DMA engine patches are going via Vinod
 Koul's tree so I think the $subject patch should follow the same
 tree, No ?

AFAIK Vinod should be the correct person to pick it up, but I can CC Grant and
Linus W as well.

 Peter, if you plan to re-send, feel free to add my ack.

I'll figure out which stable release should have this applied and will resend.

-- 
Péter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC v2] dmaengine: omap-dma: Start DMA without delay for cyclic channels

2013-04-09 Thread Peter Ujfalusi
On 04/08/2013 07:09 PM, Russell King - ARM Linux wrote:
 Now that I'm back from a short 4 day break, then yes, and the answer is
 that it's fine.  Who's handling the patch?

Thank you,
Péter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC v2] dmaengine: omap-dma: Start DMA without delay for cyclic channels

2013-04-09 Thread Peter Ujfalusi
Russell,

On 04/09/2013 09:19 AM, Peter Ujfalusi wrote:
 On 04/08/2013 07:09 PM, Russell King - ARM Linux wrote:
 Now that I'm back from a short 4 day break, then yes, and the answer is
 that it's fine.  Who's handling the patch?
 
 Thank you,
 Péter

Can I add you acked-by to the patch?

-- 
Péter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC v2] dmaengine: omap-dma: Start DMA without delay for cyclic channels

2013-04-09 Thread Peter Ujfalusi
On 04/09/2013 09:26 AM, Vinod Koul wrote:
 Yes it should go thru dmaengine tree, sorry was travelling hence the delay, 
 pls
 resend the patch and I will do the needful

I already have the patch rebased on today's linux-next, just waiting for
Russell to confirm that I can add his Acked-by to the patch.
I take this from Russell as ACK: Now that I'm back from a short 4 day break,
then yes, and the answer is that it's fine.  Who's handling the patch?

But I want to be sure I can add that line...

-- 
Péter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] dmaengine: omap-dma: Start DMA without delay for cyclic channels

2013-04-09 Thread Peter Ujfalusi
cyclic DMA is only used by audio which needs DMA to be started without a
delay.
If the DMA for audio is started using the tasklet we experience random
channel switch (to be more precise: channel shift).

Reported-by: Peter Meerwald pme...@pmeerw.net
CC: sta...@vger.kernel.org  # v3.7+
Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
Acked-by: Santosh Shilimkar santosh.shilim...@ti.com
Acked-by: Russell King rmk+ker...@arm.linux.org.uk
---
Hi Vinod,

Would it be possible to send this patch for 3.9. The channel shift (or switch)
issue in audio has been noticed recently and it turns out that it has been
present since 3.7 kernel.
It would be great if 3.9 kernel could work correctly out of box...

Changes since RFCv2:
- added Acked-by from Santosh and Russell

Thank you,
Peter

 drivers/dma/omap-dma.c | 20 ++--
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/dma/omap-dma.c b/drivers/dma/omap-dma.c
index 2ea3d7e..ec3fc4f 100644
--- a/drivers/dma/omap-dma.c
+++ b/drivers/dma/omap-dma.c
@@ -282,12 +282,20 @@ static void omap_dma_issue_pending(struct dma_chan *chan)
 
spin_lock_irqsave(c-vc.lock, flags);
if (vchan_issue_pending(c-vc)  !c-desc) {
-   struct omap_dmadev *d = to_omap_dma_dev(chan-device);
-   spin_lock(d-lock);
-   if (list_empty(c-node))
-   list_add_tail(c-node, d-pending);
-   spin_unlock(d-lock);
-   tasklet_schedule(d-task);
+   /*
+* c-cyclic is used only by audio and in this case the DMA need
+* to be started without delay.
+*/
+   if (!c-cyclic) {
+   struct omap_dmadev *d = to_omap_dma_dev(chan-device);
+   spin_lock(d-lock);
+   if (list_empty(c-node))
+   list_add_tail(c-node, d-pending);
+   spin_unlock(d-lock);
+   tasklet_schedule(d-task);
+   } else {
+   omap_dma_start_desc(c);
+   }
}
spin_unlock_irqrestore(c-vc.lock, flags);
 }
-- 
1.8.1.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC] dmaengine: omap-dma: Start DMA without delay

2013-03-29 Thread Peter Ujfalusi
Remove the use of a tasklet to start the DMA channel when issue_pending is
called.
The use of tasklet delays the DMA start which can cause issues at drivers,
for example the audio drivers expect that the DMA is started right away.

Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
Hi Russell,

I know you are against removing the tasklet since you have planed to move the
omap-dma to use runtime/dynamic DMA channel use.
I have looked at the amba-pl08x.c driver which is doing that exactly (as you
pointed out that to me). AMBA did not use tasklet either and I'm sure we can
change the omap-dma driver to do the same in a same way as we could have done it
with the tasklet use.

I have tested the patch on OMAP3/4 devices and have not seen any ill effects of
this patch.

Currently OMAP audio is affected by the taskelt: we have random channel 
switch/shift
when starting audio. This is because the DMA is started after (because of the 
tasklet)
the audio IPs.

We probably need to backport this patch to 3.7 and 3.8 as well after the review
rounds.

Regards,
Peter

 drivers/dma/omap-dma.c | 51 ++
 1 file changed, 2 insertions(+), 49 deletions(-)

diff --git a/drivers/dma/omap-dma.c b/drivers/dma/omap-dma.c
index c4b4fd2..d6a1dc0 100644
--- a/drivers/dma/omap-dma.c
+++ b/drivers/dma/omap-dma.c
@@ -22,13 +22,10 @@
 struct omap_dmadev {
struct dma_device ddev;
spinlock_t lock;
-   struct tasklet_struct task;
-   struct list_head pending;
 };
 
 struct omap_chan {
struct virt_dma_chan vc;
-   struct list_head node;
 
struct dma_slave_config cfg;
unsigned dma_sig;
@@ -153,33 +150,6 @@ static void omap_dma_callback(int ch, u16 status, void 
*data)
spin_unlock_irqrestore(c-vc.lock, flags);
 }
 
-/*
- * This callback schedules all pending channels.  We could be more
- * clever here by postponing allocation of the real DMA channels to
- * this point, and freeing them when our virtual channel becomes idle.
- *
- * We would then need to deal with 'all channels in-use'
- */
-static void omap_dma_sched(unsigned long data)
-{
-   struct omap_dmadev *d = (struct omap_dmadev *)data;
-   LIST_HEAD(head);
-
-   spin_lock_irq(d-lock);
-   list_splice_tail_init(d-pending, head);
-   spin_unlock_irq(d-lock);
-
-   while (!list_empty(head)) {
-   struct omap_chan *c = list_first_entry(head,
-   struct omap_chan, node);
-
-   spin_lock_irq(c-vc.lock);
-   list_del_init(c-node);
-   omap_dma_start_desc(c);
-   spin_unlock_irq(c-vc.lock);
-   }
-}
-
 static int omap_dma_alloc_chan_resources(struct dma_chan *chan)
 {
struct omap_chan *c = to_omap_dma_chan(chan);
@@ -275,14 +245,8 @@ static void omap_dma_issue_pending(struct dma_chan *chan)
unsigned long flags;
 
spin_lock_irqsave(c-vc.lock, flags);
-   if (vchan_issue_pending(c-vc)  !c-desc) {
-   struct omap_dmadev *d = to_omap_dma_dev(chan-device);
-   spin_lock(d-lock);
-   if (list_empty(c-node))
-   list_add_tail(c-node, d-pending);
-   spin_unlock(d-lock);
-   tasklet_schedule(d-task);
-   }
+   if (vchan_issue_pending(c-vc)  !c-desc)
+   omap_dma_start_desc(c);
spin_unlock_irqrestore(c-vc.lock, flags);
 }
 
@@ -456,17 +420,11 @@ static int omap_dma_slave_config(struct omap_chan *c, 
struct dma_slave_config *c
 
 static int omap_dma_terminate_all(struct omap_chan *c)
 {
-   struct omap_dmadev *d = to_omap_dma_dev(c-vc.chan.device);
unsigned long flags;
LIST_HEAD(head);
 
spin_lock_irqsave(c-vc.lock, flags);
 
-   /* Prevent this channel being scheduled */
-   spin_lock(d-lock);
-   list_del_init(c-node);
-   spin_unlock(d-lock);
-
/*
 * Stop DMA activity: we assume the callback will not be called
 * after omap_stop_dma() returns (even if it does, it will see
@@ -562,7 +520,6 @@ static int omap_dma_chan_init(struct omap_dmadev *od, int 
dma_sig)
c-dma_sig = dma_sig;
c-vc.desc_free = omap_dma_desc_free;
vchan_init(c-vc, od-ddev);
-   INIT_LIST_HEAD(c-node);
 
od-ddev.chancnt++;
 
@@ -571,7 +528,6 @@ static int omap_dma_chan_init(struct omap_dmadev *od, int 
dma_sig)
 
 static void omap_dma_free(struct omap_dmadev *od)
 {
-   tasklet_kill(od-task);
while (!list_empty(od-ddev.channels)) {
struct omap_chan *c = list_first_entry(od-ddev.channels,
struct omap_chan, vc.chan.device_node);
@@ -603,11 +559,8 @@ static int omap_dma_probe(struct platform_device *pdev)
od-ddev.device_control = omap_dma_control;
od-ddev.dev = pdev-dev;
INIT_LIST_HEAD(od-ddev.channels);
-   INIT_LIST_HEAD(od-pending);
spin_lock_init(od-lock);
 
-   tasklet_init(od-task

Re: [PATCH] pwm: twl: Return proper error if twl6030_pwm_enable() fails

2013-04-02 Thread Peter Ujfalusi
On 03/31/2013 05:07 PM, Axel Lin wrote:
 Return proper error instead of 0 if twl6030_pwm_enable() fails.
 
 Signed-off-by: Axel Lin axel@ingics.com

Acked-by: Peter Ujfalusi peter.ujfal...@ti.com

 ---
  drivers/pwm/pwm-twl.c |2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/drivers/pwm/pwm-twl.c b/drivers/pwm/pwm-twl.c
 index ee7fa5d..2782001 100644
 --- a/drivers/pwm/pwm-twl.c
 +++ b/drivers/pwm/pwm-twl.c
 @@ -248,7 +248,7 @@ static int twl6030_pwm_enable(struct pwm_chip *chip, 
 struct pwm_device *pwm)
   twl-twl6030_toggle3 = val;
  out:
   mutex_unlock(twl-mutex);
 - return 0;
 + return ret;
  }
  
  static void twl6030_pwm_disable(struct pwm_chip *chip, struct pwm_device 
 *pwm)
 


-- 
Péter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 3/4] pwm: twl-led: Add .owner to struct pwm_ops

2013-04-02 Thread Peter Ujfalusi
On 03/31/2013 05:16 AM, Axel Lin wrote:
 Add missing .owner of struct pwm_ops. This prevents the module from being
 removed from underneath its users.
 
 Signed-off-by: Axel Lin axel@ingics.com

Acked-by: Peter Ujfalusi peter.ujfal...@ti.com

 ---
  drivers/pwm/pwm-twl-led.c |2 ++
  1 file changed, 2 insertions(+)
 
 diff --git a/drivers/pwm/pwm-twl-led.c b/drivers/pwm/pwm-twl-led.c
 index 83e25d4..f912e87 100644
 --- a/drivers/pwm/pwm-twl-led.c
 +++ b/drivers/pwm/pwm-twl-led.c
 @@ -271,6 +271,7 @@ static const struct pwm_ops twl4030_pwmled_ops = {
   .enable = twl4030_pwmled_enable,
   .disable = twl4030_pwmled_disable,
   .config = twl4030_pwmled_config,
 + .owner = THIS_MODULE,
  };
  
  static const struct pwm_ops twl6030_pwmled_ops = {
 @@ -279,6 +280,7 @@ static const struct pwm_ops twl6030_pwmled_ops = {
   .config = twl6030_pwmled_config,
   .request = twl6030_pwmled_request,
   .free = twl6030_pwmled_free,
 + .owner = THIS_MODULE,
  };
  
  static int twl_pwmled_probe(struct platform_device *pdev)
 


-- 
Péter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 4/4] pwm: twl: Add .owner to struct pwm_ops

2013-04-02 Thread Peter Ujfalusi
On 03/31/2013 05:17 AM, Axel Lin wrote:
 Add missing .owner of struct pwm_ops. This prevents the module from being
 removed from underneath its users.
 
 Signed-off-by: Axel Lin axel@ingics.com

Acked-by: Peter Ujfalusi peter.ujfal...@ti.com

 ---
  drivers/pwm/pwm-twl.c |2 ++
  1 file changed, 2 insertions(+)
 
 diff --git a/drivers/pwm/pwm-twl.c b/drivers/pwm/pwm-twl.c
 index bf3fda2..ee7fa5d 100644
 --- a/drivers/pwm/pwm-twl.c
 +++ b/drivers/pwm/pwm-twl.c
 @@ -287,12 +287,14 @@ static const struct pwm_ops twl4030_pwm_ops = {
   .disable = twl4030_pwm_disable,
   .request = twl4030_pwm_request,
   .free = twl4030_pwm_free,
 + .owner = THIS_MODULE,
  };
  
  static const struct pwm_ops twl6030_pwm_ops = {
   .config = twl_pwm_config,
   .enable = twl6030_pwm_enable,
   .disable = twl6030_pwm_disable,
 + .owner = THIS_MODULE,
  };
  
  static int twl_pwm_probe(struct platform_device *pdev)
 


-- 
Péter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC] dmaengine: omap-dma: Start DMA without delay

2013-04-02 Thread Peter Ujfalusi
Russell,

On 03/29/2013 06:31 PM, Russell King - ARM Linux wrote:
 On Fri, Mar 29, 2013 at 03:12:03PM +0100, Peter Ujfalusi wrote:
 Remove the use of a tasklet to start the DMA channel when issue_pending is
 called.
 The use of tasklet delays the DMA start which can cause issues at drivers,
 for example the audio drivers expect that the DMA is started right away.

 Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
 ---
 Hi Russell,

 I know you are against removing the tasklet since you have planed to move the
 omap-dma to use runtime/dynamic DMA channel use.
 I have looked at the amba-pl08x.c driver which is doing that exactly (as you
 pointed out that to me). AMBA did not use tasklet either and I'm sure we can
 change the omap-dma driver to do the same in a same way as we could have 
 done it
 with the tasklet use.
 
 It's rather sad that you're ignoring what I'm saying, and going by what
 another DMA engine driver - which is self contained - is doing, rather
 than listening to my arguments against that approach.

The reason I send this as RFC to start a discussion to find out how we should
handle this. I were to ignore what you were saying I would have just sent a
PATCH instead.

I don't think that the tasklet is the solution for the runtime DMA channel
selection. We can do it in a same way as AMBA has been doing. In this way we
can handle all cases with the same code.
The pre-allocating of channels and starting the DMA right away is different 
issue.

What need to be done anyway is to convert the remaining drivers to use 
dmaengine:
drivers/usb/musb/tusb6010_omap.c
drivers/usb/gadget/omap_udc.c
drivers/mtd/onenand/omap2.c
drivers/media/platform/omap3isp/isphist.c
drivers/media/platform/soc_camera/omap1_camera.c
drivers/media/platform/omap/omap_vout_vrfb.c

When that is done we can remove the arch/arm/plat-omap/dma.c and migrate the
code under dmaengine to restructure it and finally we can have runtime channel
allocation.

-- 
Péter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC v2] dmaengine: omap-dma: Start DMA without delay for cyclic channels

2013-04-03 Thread Peter Ujfalusi
cyclic DMA is only used by audio which needs DMA to be started without a
delay.
If the DMA for audio is started using the tasklet we experience random
channel switch (to be more precise: channel shift).

Reported-by: Peter Meerwald pme...@pmeerw.net
Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
Hi Russell,

Instead of removing the tasklet we can identify the DMA channel used by audio
based on the cyclic flag of the channel.
I think this can be used as a short term solution to fix the audio channel shift
issue and later when we have the dynamic DMA channel allocation we can adjust
the code.

Regards,
Peter

 drivers/dma/omap-dma.c | 20 ++--
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/dma/omap-dma.c b/drivers/dma/omap-dma.c
index 2ea3d7e..ec3fc4f 100644
--- a/drivers/dma/omap-dma.c
+++ b/drivers/dma/omap-dma.c
@@ -282,12 +282,20 @@ static void omap_dma_issue_pending(struct dma_chan *chan)
 
spin_lock_irqsave(c-vc.lock, flags);
if (vchan_issue_pending(c-vc)  !c-desc) {
-   struct omap_dmadev *d = to_omap_dma_dev(chan-device);
-   spin_lock(d-lock);
-   if (list_empty(c-node))
-   list_add_tail(c-node, d-pending);
-   spin_unlock(d-lock);
-   tasklet_schedule(d-task);
+   /*
+* c-cyclic is used only by audio and in this case the DMA need
+* to be started without delay.
+*/
+   if (!c-cyclic) {
+   struct omap_dmadev *d = to_omap_dma_dev(chan-device);
+   spin_lock(d-lock);
+   if (list_empty(c-node))
+   list_add_tail(c-node, d-pending);
+   spin_unlock(d-lock);
+   tasklet_schedule(d-task);
+   } else {
+   omap_dma_start_desc(c);
+   }
}
spin_unlock_irqrestore(c-vc.lock, flags);
 }
-- 
1.8.1.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC v2] dmaengine: omap-dma: Start DMA without delay for cyclic channels

2013-04-03 Thread Peter Ujfalusi
On 04/03/2013 01:24 PM, Santosh Shilimkar wrote:
 On Wednesday 03 April 2013 04:47 PM, Peter Ujfalusi wrote:
 cyclic DMA is only used by audio which needs DMA to be started without a
 delay.
 If the DMA for audio is started using the tasklet we experience random
 channel switch (to be more precise: channel shift).

 Reported-by: Peter Meerwald pme...@pmeerw.net
 Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
 ---
 Hi Russell,

 Instead of removing the tasklet we can identify the DMA channel used by audio
 based on the cyclic flag of the channel.
 I think this can be used as a short term solution to fix the audio channel 
 shift
 issue and later when we have the dynamic DMA channel allocation we can adjust
 the code.

 Regards,
 Peter

  drivers/dma/omap-dma.c | 20 ++--
  1 file changed, 14 insertions(+), 6 deletions(-)

 diff --git a/drivers/dma/omap-dma.c b/drivers/dma/omap-dma.c
 index 2ea3d7e..ec3fc4f 100644
 --- a/drivers/dma/omap-dma.c
 +++ b/drivers/dma/omap-dma.c
 @@ -282,12 +282,20 @@ static void omap_dma_issue_pending(struct dma_chan 
 *chan)
  
  spin_lock_irqsave(c-vc.lock, flags);
  if (vchan_issue_pending(c-vc)  !c-desc) {
 If you add !c-cyclic in above if then you can avoid
 indentation change and just have else for cyclic case.

It can not be embedded there because of the existing tests. How would we
handle the case when c-desc is _not_ NULL and c-cyclic is false? We would
need to test again in else, but we can not do this for the
vchan_issue_pending(c-vc).

 
 -struct omap_dmadev *d = to_omap_dma_dev(chan-device);
 -spin_lock(d-lock);
 -if (list_empty(c-node))
 -list_add_tail(c-node, d-pending);
 -spin_unlock(d-lock);
 -tasklet_schedule(d-task);
 +/*
 + * c-cyclic is used only by audio and in this case the DMA need
 + * to be started without delay.
 + */
 +if (!c-cyclic) {
 +struct omap_dmadev *d = to_omap_dma_dev(chan-device);
 +spin_lock(d-lock);
 +if (list_empty(c-node))
 +list_add_tail(c-node, d-pending);
 +spin_unlock(d-lock);
 +tasklet_schedule(d-task);
 +} else {
 +omap_dma_start_desc(c);
 +}
  }
  spin_unlock_irqrestore(c-vc.lock, flags);
  }

 


-- 
Péter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] omap: convert to devm_ioremap_resource()

2013-03-12 Thread Peter Ujfalusi
Hi,

On 03/11/2013 04:58 PM, Silviu-Mihai Popescu wrote:
 Convert all uses of devm_request_and_ioremap() to the newly introduced
 devm_ioremap_resource() which provides more consistent error handling.
 
 devm_ioremap_resource() provides its own error messages so all explicit
 error messages can be removed from the failure code paths.

I believe both of the drivers has been patched for this:
omap-mcbpdm:
http://mailman.alsa-project.org/pipermail/alsa-devel/2013-February/059484.html
http://mailman.alsa-project.org/pipermail/alsa-devel/2013-February/059427.html

omap-dmic:
http://mailman.alsa-project.org/pipermail/alsa-devel/2013-February/059485.html

and they should be already queued for next.

-- 
Péter

 
 Signed-off-by: Silviu-Mihai Popescu silviupopescu1...@gmail.com
 ---
  sound/soc/omap/omap-dmic.c  |9 +++--
  sound/soc/omap/omap-mcpdm.c |8 +++-
  2 files changed, 6 insertions(+), 11 deletions(-)
 
 diff --git a/sound/soc/omap/omap-dmic.c b/sound/soc/omap/omap-dmic.c
 index 77e9e7e..8ebaf11 100644
 --- a/sound/soc/omap/omap-dmic.c
 +++ b/sound/soc/omap/omap-dmic.c
 @@ -493,12 +493,9 @@ static int asoc_dmic_probe(struct platform_device *pdev)
   goto err_put_clk;
   }
  
 - dmic-io_base = devm_request_and_ioremap(pdev-dev, res);
 - if (!dmic-io_base) {
 - dev_err(pdev-dev, cannot remap\n);
 - ret = -ENOMEM;
 - goto err_put_clk;
 - }
 + dmic-io_base = devm_ioremap_resource(pdev-dev, res);
 + if (IS_ERR(dmic-io_base))
 + return PTR_ERR(dmic-io_base);
  
   ret = snd_soc_register_dai(pdev-dev, omap_dmic_dai);
   if (ret)
 diff --git a/sound/soc/omap/omap-mcpdm.c b/sound/soc/omap/omap-mcpdm.c
 index 079f277..ddfcc18 100644
 --- a/sound/soc/omap/omap-mcpdm.c
 +++ b/sound/soc/omap/omap-mcpdm.c
 @@ -464,11 +464,9 @@ static int asoc_mcpdm_probe(struct platform_device *pdev)
   if (res == NULL)
   return -ENOMEM;
  
 - mcpdm-io_base = devm_request_and_ioremap(pdev-dev, res);
 - if (!mcpdm-io_base) {
 - dev_err(pdev-dev, cannot remap\n);
 - return -ENOMEM;
 - }
 + mcpdm-io_base = devm_ioremap_resource(pdev-dev, res);
 + if (IS_ERR(mcpdm-io_base))
 + return PTR_ERR(mcpdm-io_base);
  
   mcpdm-irq = platform_get_irq(pdev, 0);
   if (mcpdm-irq  0)
 

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] omap: convert to devm_ioremap_resource()

2013-03-12 Thread Peter Ujfalusi
On 03/12/2013 09:24 AM, Silviu Popescu wrote:
 As far as I can tell from the mails that you have provided, those
 patches replace devm_request_mem_region(), followed by devm_ioremap()
 with devm_request_and_ioremap().
 What this patch attempts to do is replace devm_request_and_ioremap()
 with the newly introduced devm_ioremap_resource(), for the reasons
 expressed in the patch body.

Ah, true.

-- 
Péter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] omap: convert to devm_ioremap_resource()

2013-03-12 Thread Peter Ujfalusi
On 03/11/2013 04:58 PM, Silviu-Mihai Popescu wrote:
 Convert all uses of devm_request_and_ioremap() to the newly introduced
 devm_ioremap_resource() which provides more consistent error handling.
 
 devm_ioremap_resource() provides its own error messages so all explicit
 error messages can be removed from the failure code paths.

Acked-by: Peter Ujfalusi peter.ujfal...@ti.com

 
 Signed-off-by: Silviu-Mihai Popescu silviupopescu1...@gmail.com
 ---
  sound/soc/omap/omap-dmic.c  |9 +++--
  sound/soc/omap/omap-mcpdm.c |8 +++-
  2 files changed, 6 insertions(+), 11 deletions(-)
 
 diff --git a/sound/soc/omap/omap-dmic.c b/sound/soc/omap/omap-dmic.c
 index 77e9e7e..8ebaf11 100644
 --- a/sound/soc/omap/omap-dmic.c
 +++ b/sound/soc/omap/omap-dmic.c
 @@ -493,12 +493,9 @@ static int asoc_dmic_probe(struct platform_device *pdev)
   goto err_put_clk;
   }
  
 - dmic-io_base = devm_request_and_ioremap(pdev-dev, res);
 - if (!dmic-io_base) {
 - dev_err(pdev-dev, cannot remap\n);
 - ret = -ENOMEM;
 - goto err_put_clk;
 - }
 + dmic-io_base = devm_ioremap_resource(pdev-dev, res);
 + if (IS_ERR(dmic-io_base))
 + return PTR_ERR(dmic-io_base);
  
   ret = snd_soc_register_dai(pdev-dev, omap_dmic_dai);
   if (ret)
 diff --git a/sound/soc/omap/omap-mcpdm.c b/sound/soc/omap/omap-mcpdm.c
 index 079f277..ddfcc18 100644
 --- a/sound/soc/omap/omap-mcpdm.c
 +++ b/sound/soc/omap/omap-mcpdm.c
 @@ -464,11 +464,9 @@ static int asoc_mcpdm_probe(struct platform_device *pdev)
   if (res == NULL)
   return -ENOMEM;
  
 - mcpdm-io_base = devm_request_and_ioremap(pdev-dev, res);
 - if (!mcpdm-io_base) {
 - dev_err(pdev-dev, cannot remap\n);
 - return -ENOMEM;
 - }
 + mcpdm-io_base = devm_ioremap_resource(pdev-dev, res);
 + if (IS_ERR(mcpdm-io_base))
 + return PTR_ERR(mcpdm-io_base);
  
   mcpdm-irq = platform_get_irq(pdev, 0);
   if (mcpdm-irq  0)
 


-- 
Péter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/8] usb: phy: nop: Add some parameters to platform data

2013-03-13 Thread Peter Ujfalusi
On 03/12/2013 04:20 PM, Roger Quadros wrote:
 Adding Peter to the loop. I faintly remember him mentioning this issue before
 for beagle. We really need the deferred probe mechanism or we need to resort
 to device registering order.

Yes, BeagleBoard is a good example. Long story short: we have external
dependency and the correct way to handle that is via deferred probe.

As of now we are not ready to kill the legacy support but over time we should
move as much as we can to DT only mode.

 The first user for needs_vcc flag will be the beagleboard file. I just didn't
 implement it in this patch [1].
 
 On second thoughts, since [1] does work on beagleboard without requiring the
 needs_vcc flag, I think we can just live without it.

The BeagleBoard works because the bootloader happen to enable the PWM
generator which is used as a GPIO for the external HUB enable port. As soon as
the bootloader stops doing this we are going to be in trouble.

 
 Felipe, Peter, what do you think?
 
 cheers,
 -roger
 
 [1] https://lkml.org/lkml/2013/3/12/244
 


-- 
Péter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] gpio: New driver for GPO emulation using PWM generators

2012-11-29 Thread Peter Ujfalusi
On 11/28/2012 08:30 PM, Thierry Reding wrote:
 I must say I'm not terribly thrilled to integrate something like this
 into the PWM subsystem.

I agree. I would not really want to add my name to something like this either...

 I wish hardware engineers wouldn't come up with such designs.

I have checked and rechecked the schematics and datasheets. Still can not
understand how anyone would come to this HW solution (when the twl4030 have at
least 4 unused GPIO line left unconnected).

 But since this seems to be a real use-case, if we want to
 support it we should try and find the right solution.
 
 Reading the above sounds overly complicated. Couldn't we, instead of
 instantiating an extra driver, just register a GPIO chip if a chip wants
 to support this functionality? Where the GPIO chip's request callback
 requests the given PWM so that it cannot be used elsewhere? The
 direction_input callback would need to always fail and the set callback
 can configure the PWM either to 0% or 100% duty-cycle depending on the
 desired output value.

The original driver was doing exactly this. Basically I have added a GPO chip
(which was just a translator from PWM to GPO). In DT it looked like this:

twl_pwm: pwm {
compatible = ti,twl4030-pwmled;
#pwm-cells = 2;
};

pwm_gpo1: gpo1 {
compatible = pwm-gpo;
#gpio-cells = 1;
gpio-controller;
pwms = twl_pwm 0 7812500;
pwm-names = nUSBHOST_PWR_EN;
};

user@1 {
compatible = example,testuser;
gpios = pwm_gpo1 0;
};

When we boot with DT the pwm_get() needs pwms phandle from the device you are
calling it in order to find the PWM in question. If we do not have DT entry
for the GPO driver, we need to build up a pwm_lookup table to ensure that the
pwm_get() will find the PWM we want to handle.

We could implement the GPIO related code under for example
drivers/pwm/pwm-as-gpo.c
But then I should merge the code from drivers/gpio/gpio-pwm.c inside.
This is not nice either since we will have a GPIO driver living under pwm/
directory and I'm not sure how this would use the pwm API when the GPO
functionality is requested.

-- 
Péter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] gpio: New driver for GPO emulation using PWM generators

2012-11-30 Thread Peter Ujfalusi
On 11/30/2012 11:20 AM, Grant Likely wrote:
 Umm, I agree with you on duty cycle, but that's got nothing to do with
 period. 100% duty cycle looks exactly the same whether the period is
 10ns or 100s.

Yes this is true. But some PWM hw can select it's clock based on the period_ns
provided.
In most cases we could hardwire 1 as period_ns but there might be HW which
checks this and only allow the use of supported frequencies.

 Unless you're proposing to not include that in the PWM core but rather
 in individual drivers. Then I suppose the driver could choose some
 sensible default.
 
 Mostly I'm asking questions because I'm not familiar with the subsystem.
 If the property is needed then I have no objections, but at the moment
 it doesn't make any sense to me.
 
 One other problem is that some PWM devices cannot be setup to achieve a
 0% or 100% duty-cycle but instead will toggle for at least one period.
 This would be another argument in favour of moving the functionality to
 the individual drivers, perhaps with some functionality provided by the
 core to do the gpio_chip registration (a period could be passed to that
 function at registration time), which will likely be the same for all
 hardware that can and wants to support this feature.
 
 It is a bit of an oddball case where if the hardware engineer wires up a
 PWM to use as a GPIO, then he better be sure that it is actually fit for
 the purpose.

If we inspect the situation from a different angle: a standard GPIO is a PWM
with either turned off state or with full duty cycle (where the duty cycle
means nothing since the signal on the line is constantly high).

 That doesn't prevent the PWM core having some
 gpio-emulation helper functionality, but do need to be careful about it.

If you give designers a way to take short cuts, they will take it whenever
they can. Even if it makes no sense. IMHO. But the BeagleBoard has been
designed before we had any indication from the SW that we could handle this
case. I guess the thinking was that in the bootloader the SW will configure
the PWM to always on and forget about it in the running code.

As a note: I noticed this during my cleanup work around the twl-core. If you
take a look at the kernel code there are other drivers configuring the PWMs of
twl in various places to handle them.
I wrote the pwm-twl and pwm-twl-led drivers so we can get rid of this whole 
mess:
- the gpio-twl4030 extends itself to handle the PWMA/B (LEDA/B) as GPIO. So
drivers are doing OMAP_MAX_GPIO + TWL_NUM_GPIO + 1/2 to control the PWMA/B.
- mach-omap2/board-zoom-display.c have custom code to control the same thing
and the list goes.

-- 
Péter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] gpio: New driver for GPO emulation using PWM generators

2012-11-30 Thread Peter Ujfalusi
On 11/29/2012 05:10 PM, Grant Likely wrote:
  /* Enable GPIO us of the PWMs */
  gpio-controller = 1;
 
 This line should be simply (the property shouldn't have any data):
   gpio-controller;

Yes I know. It is like this already in my code. I just mixed up things while
hacking it together.

 
  #gpio-cells = 2;
  pwm,period_ns = 7812500;
 
 Nit: property names should use '-' instead of '_'.

Yes, true.

  of_property_read_u32(chip-dev-of_node, pwm,period_ns, period_ns);
  if (!period_ns) {
  dev_err(chip-dev,
  period_ns is not specified for GPIO use\n);
  return;
  }
 
 This property name seems ambiguous. What do you need to encode here? It
 looks like there is a specific PWM period used for the 'on' state. What
 about the 'off' state? Would different pwm outputs have different
 frequencies required for GPIO usage.
 
 Actually, I'm a bit surprised here that a period value is needed at all.
 I would expect if a PWM is used as a GPIO then the driver would already
 know how to set it up that way.

Some PWM hw can select between different frequencies. They do that based on
the period_ns.
We can not just pass random non 0 number to them since they might fail with
the check for supported frequencies.

 Ugh, yeah this isn't the way to go. Don't register a new platform_device
 for the gpio functionality. It should be inline with the rest of the PWM
 setup and should trigger the registration of a gpio_chip directly.

We also need to take care of the non DT booted cases as well.
What we could do:
this driver with removed DT support for legacy booted systems.
GPO layer implementation within drivers/pwm/ to handle DT boot.

When we boot without DT we need to tell back to the machine driver about the
GPIO start of the gpio chip we just allocated.

Hrm, we could do this from the pwm-twl* drivers as well by adding an optional
callback and flag to the pwm core to register the gpio chip.
In this case we can move the whole whole gpio-pwm code under drivers/pwm, add
the 'struct gpio_chip' to struct pwm_chip{}
and register the gpio chip from within the pwm core.
We still have to provide the period_ns in same way to the PWM instance used as
GPIO, probably via platform data. Not sure about it right now.

-- 
Péter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 1/3] leds: leds-pwm: Convert to use devm_get_pwm

2012-12-03 Thread Peter Ujfalusi
Hi Bryan,

On 11/14/2012 02:14 AM, Bryan Wu wrote:
 On Mon, Nov 12, 2012 at 6:41 AM, Peter Ujfalusi peter.ujfal...@ti.com wrote:
 Update the driver to use the new API for requesting pwm so we can take
 advantage of the pwm_lookup table to find the correct pwm to be used for the
 LED functionality.
 If the devm_get_pwm fails we fall back to legacy mode to try to get the pwm.

 Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
 ---
  drivers/leds/leds-pwm.c  | 19 ++-
  include/linux/leds_pwm.h |  2 +-
  2 files changed, 7 insertions(+), 14 deletions(-)

 diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c
 index f2e44c7..c953c75 100644
 --- a/drivers/leds/leds-pwm.c
 +++ b/drivers/leds/leds-pwm.c
 @@ -67,12 +67,11 @@ static int led_pwm_probe(struct platform_device *pdev)
 cur_led = pdata-leds[i];
 led_dat = leds_data[i];

 -   led_dat-pwm = pwm_request(cur_led-pwm_id,
 -   cur_led-name);
 +   led_dat-pwm = devm_pwm_get(pdev-dev, cur_led-name);
 if (IS_ERR(led_dat-pwm)) {
 ret = PTR_ERR(led_dat-pwm);
 -   dev_err(pdev-dev, unable to request PWM %d\n,
 -   cur_led-pwm_id);
 +   dev_err(pdev-dev, unable to request PWM for %s\n,
 +   cur_led-name);
 goto err;
 }

 @@ -86,10 +85,8 @@ static int led_pwm_probe(struct platform_device *pdev)
 led_dat-cdev.flags |= LED_CORE_SUSPENDRESUME;

 ret = led_classdev_register(pdev-dev, led_dat-cdev);
 -   if (ret  0) {
 -   pwm_free(led_dat-pwm);
 +   if (ret  0)
 goto err;
 -   }
 }

 platform_set_drvdata(pdev, leds_data);
 @@ -98,10 +95,8 @@ static int led_pwm_probe(struct platform_device *pdev)

  err:
 if (i  0) {
 -   for (i = i - 1; i = 0; i--) {
 +   for (i = i - 1; i = 0; i--)
 led_classdev_unregister(leds_data[i].cdev);
 -   pwm_free(leds_data[i].pwm);
 -   }
 }

 return ret;
 @@ -115,10 +110,8 @@ static int __devexit led_pwm_remove(struct 
 platform_device *pdev)

 leds_data = platform_get_drvdata(pdev);

 -   for (i = 0; i  pdata-num_leds; i++) {
 +   for (i = 0; i  pdata-num_leds; i++)
 led_classdev_unregister(leds_data[i].cdev);
 -   pwm_free(leds_data[i].pwm);
 -   }

 return 0;
  }
 diff --git a/include/linux/leds_pwm.h b/include/linux/leds_pwm.h
 index 33a0711..a65e964 100644
 --- a/include/linux/leds_pwm.h
 +++ b/include/linux/leds_pwm.h
 @@ -7,7 +7,7 @@
  struct led_pwm {
 const char  *name;
 const char  *default_trigger;
 -   unsignedpwm_id;
 +   unsignedpwm_id __deprecated;
 
 I suggest we remove this later, we can provide patches from this from
 platform data of board file. And I think this patch is good for me to
 merge, will do it soon.

I have marked the pwm_id as deprecated for now to allow one kernel cycle for
external (?) drivers to adopt. We can remove it for 3.9 I think.

I just checked linux-next today and this series is still not there. Do you
want me to resend it for you? I can rebase the patches on top of linux-next or
if you have preference on which tree should I use please let me know.

 
 Thanks,
 -Bryan
 
 u8  active_low;
 unsignedmax_brightness;
 unsignedpwm_period_ns;
 --
 1.8.0



Thanks,
Péter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 1/3] leds: leds-pwm: Convert to use devm_get_pwm

2012-12-04 Thread Peter Ujfalusi
Hi Bryan,

On 12/03/2012 07:32 PM, Bryan Wu wrote:
 On Mon, Dec 3, 2012 at 6:13 AM, Peter Ujfalusi peter.ujfal...@ti.com wrote:
 Actually, I'm waiting for some feedback from DT maintainers about this
 new binding. But it looks find to me.

Would it be possible to have the first (or even better the first two) patch
going for 3.8 and we can leave the DT bindings for 3.9?
I would like to clean up, fix some of the OMAP related board files for 3.9
which would need the patches for the leds-pwm driver itself.

Thank you,
Péter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] gpio: twl4030: Correct status reporting when the GPIO is used as output

2012-12-05 Thread Peter Ujfalusi
When the GPIO is configured as output we need to read the GPIODATAOUT*
register to get correct information. When the GPIO is output the GPIODATAIN*
registers report 0 all the time (no feedback from output path).

Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
 drivers/gpio/gpio-twl4030.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-twl4030.c b/drivers/gpio/gpio-twl4030.c
index 55b4fe4..e7aa620 100644
--- a/drivers/gpio/gpio-twl4030.c
+++ b/drivers/gpio/gpio-twl4030.c
@@ -191,13 +191,19 @@ static int twl4030_get_gpio_datain(int gpio)
u8 d_bnk = gpio  3;
u8 d_off = gpio  0x7;
u8 base = 0;
+   int direction;
int ret = 0;
 
if (unlikely((gpio = TWL4030_GPIO_MAX)
|| !(gpio_usage_count  BIT(gpio
return -EPERM;
 
-   base = REG_GPIODATAIN1 + d_bnk;
+   direction = gpio_twl4030_read(REG_GPIODATADIR1 + d_bnk);
+   if (direction  0  (direction  d_off)  0x1)
+   base = REG_SETGPIODATAOUT1 + d_bnk;
+   else
+   base = REG_GPIODATAIN1 + d_bnk;
+
ret = gpio_twl4030_read(base);
if (ret  0)
ret = (ret  d_off)  0x1;
-- 
1.8.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 1/3] leds: leds-pwm: Convert to use devm_get_pwm

2012-12-05 Thread Peter Ujfalusi
On 12/04/2012 06:34 PM, Bryan Wu wrote:
 What's best thing I can do is I can merge these patchset into my
 -devel branch, after 3.8 merge window close I will move this -devel
 branch to my for-next branch for 3.9 merge window.
 
 Does this make sense to you?

Not sure if I can get changes related to leds-pwm through linux-omap in this
way. The practice is that l-o should be 'in a working condition' alone -
without linux-next.

But I'll find something else while waiting for 3.10 to clean up the omap board
files related to this.

-- 
Péter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 09/11] mfd: twl-core: Collect global variables behind one private structure (global)

2013-02-08 Thread Peter Ujfalusi
On 02/08/2013 07:56 PM, Jon Hunter wrote:
  /**
   * twl_i2c_write - Writes a n bit register in TWL4030/TWL5030/TWL60X0
   * @mod_no: module number
 @@ -322,16 +323,17 @@ int twl_i2c_write(u8 mod_no, u8 *value, u8 reg, 
 unsigned num_bytes)
  pr_err(%s: invalid module number %d\n, DRIVER_NAME, mod_no);
  return -EPERM;
  }
 -if (unlikely(!inuse)) {
 +if (unlikely(!twl_priv-ready)) {
 
 This is causing the kernel to panic on all my omap2 boards when booting 
 linux-next
 because twl_priv is not initialised yet.

Good catch.
I just wonder from where the twl_* call is coming on OMAP2. AFAIK the twl code
is for OMAP3/4, for OMAP2 Menelaus is the one which is used.
I'm currently working on to remove all those twl_* calls from random places in
the kernel so we will only access twl via the MFD stack.

 
  pr_err(%s: not initialized\n, DRIVER_NAME);
  return -EPERM;
  }
  
 -sid = twl_map[mod_no].sid;
 -twl = twl_modules[sid];
 +sid = twl_priv-twl_map[mod_no].sid;
 +twl = twl_priv-twl_modules[sid];
  
 -ret = regmap_bulk_write(twl-regmap, twl_map[mod_no].base + reg,
 -value, num_bytes);
 +ret = regmap_bulk_write(twl-regmap,
 +twl_priv-twl_map[mod_no].base + reg, value,
 +num_bytes);
  
  if (ret)
  pr_err(%s: Write failed (mod %d, reg 0x%02x count %d)\n,
 @@ -360,16 +362,17 @@ int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, 
 unsigned num_bytes)
  pr_err(%s: invalid module number %d\n, DRIVER_NAME, mod_no);
  return -EPERM;
  }
 -if (unlikely(!inuse)) {
 +if (unlikely(!twl_priv-ready)) {
 
 Same problem here. 
 
 Here is a fix ...
 
 From 141fcbbdee6bdc14d5a444ff20fad6b3440215dc Mon Sep 17 00:00:00 2001
 From: Jon Hunter jon-hun...@ti.com
 Date: Fri, 8 Feb 2013 12:42:20 -0600
 Subject: [PATCH] ARM: OMAP2+: Fix kernel panic on boot
 
 Commit 8a6aaa3 (mfd: twl-core: Collect global variables behind one
 private structure (global)) removed the variable inuse that is used
 to determine if the device has been initialised and now use the
 twl_priv structure instead. This is causing the kernel to panic on all
 OMAP2+ devices, because we try to access the twl_priv-ready member
 before checking if twl_priv is initialised. Fix this and move this test
 to the beginning of the twl_i2c_read/write function because
 twl_get_last_module() also uses the twl_priv structure.
 
 Signed-off-by: Jon Hunter jon-hun...@ti.com

Acked-by: Peter Ujfalusi peter.ujfal...@ti.com

 ---
  drivers/mfd/twl-core.c |   16 
  1 file changed, 8 insertions(+), 8 deletions(-)
 
 diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
 index 557f9ee..89ab4d9 100644
 --- a/drivers/mfd/twl-core.c
 +++ b/drivers/mfd/twl-core.c
 @@ -316,12 +316,12 @@ int twl_i2c_write(u8 mod_no, u8 *value, u8 reg, 
 unsigned num_bytes)
   int sid;
   struct twl_client *twl;
  
 - if (unlikely(mod_no = twl_get_last_module())) {
 - pr_err(%s: invalid module number %d\n, DRIVER_NAME, mod_no);
 + if (unlikely(!twl_priv || !twl_priv-ready)) {
 + pr_err(%s: not initialized\n, DRIVER_NAME);
   return -EPERM;
   }
 - if (unlikely(!twl_priv-ready)) {
 - pr_err(%s: not initialized\n, DRIVER_NAME);
 + if (unlikely(mod_no = twl_get_last_module())) {
 + pr_err(%s: invalid module number %d\n, DRIVER_NAME, mod_no);
   return -EPERM;
   }
  
 @@ -355,12 +355,12 @@ int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned 
 num_bytes)
   int sid;
   struct twl_client *twl;
  
 - if (unlikely(mod_no = twl_get_last_module())) {
 - pr_err(%s: invalid module number %d\n, DRIVER_NAME, mod_no);
 + if (unlikely(!twl_priv || !twl_priv-ready)) {
 + pr_err(%s: not initialized\n, DRIVER_NAME);
   return -EPERM;
   }
 - if (unlikely(!twl_priv-ready)) {
 - pr_err(%s: not initialized\n, DRIVER_NAME);
 + if (unlikely(mod_no = twl_get_last_module())) {
 + pr_err(%s: invalid module number %d\n, DRIVER_NAME, mod_no);
   return -EPERM;
   }
  
 


-- 
Péter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Sound record on Devkit8000 with DT boot issue

2013-02-11 Thread Peter Ujfalusi
On 02/10/2013 04:21 PM, Anil Kumar wrote:
 Hi All,
 
 I am working on Devkit8000 and adding DT support for that. I am trying
 to add sound DT node support for this boards.
 I have nearly done with this but facing issue on record. I do not have
 much knowledge of twl4030 audio codec but with
 small Hack[1] (as MainMic connected to the input jack)  i am able to
 record sound on Devkit8000.
 I do not know that MICBIAS1_EN can be enable by amixer commands.
 Could you please help me to get out of this ?

You need to pass the routing information via DT for Devkit8000. This is not
done for the BeagleBoard since it works without it (no need for MICBIAS for
example)

 
 
 1) Hack [1]
 
 diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c
 index 63b280b..6780681 100644
 --- a/sound/soc/codecs/twl4030.c
 +++ b/sound/soc/codecs/twl4030.c
 @@ -1473,7 +1473,7 @@ static const struct snd_soc_dapm_widget
 twl4030_dapm_widgets[] = {
 SND_SOC_DAPM_SUPPLY(micbias2 select, TWL4030_REG_MICBIAS_CTL, 6, 0,
 NULL, 0),
 
 -   SND_SOC_DAPM_MICBIAS(Mic Bias 1, TWL4030_REG_MICBIAS_CTL, 0, 0),
 +   SND_SOC_DAPM_MICBIAS(Mic Bias 1, TWL4030_REG_MICBIAS_CTL, 0, 1),

Yes, this is HACK and it is wrong at the same time.

 SND_SOC_DAPM_MICBIAS(Mic Bias 2, TWL4030_REG_MICBIAS_CTL, 1, 0),
 SND_SOC_DAPM_MICBIAS(Headset Mic Bias, TWL4030_REG_MICBIAS_CTL, 2, 
 0),
 
 
 2) Sound DT node patch for Devkit8000
 
 diff --git a/arch/arm/boot/dts/omap3-
 devkit8000.dts b/arch/arm/boot/dts/omap3-devkit8000.dts
 index dc59272..5f3eec0 100644
 --- a/arch/arm/boot/dts/omap3-devkit8000.dts
 +++ b/arch/arm/boot/dts/omap3-devkit8000.dts
 @@ -44,11 +44,22 @@
  };
 
 };
 +
 +   sound {
 +   compatible = ti,omap-twl4030;
 +   ti,model = devkit8000;
 +
 +   ti,mcbsp = mcbsp2;
 +   ti,codec = twl_audio;

Here you should have something like:
ti,audio-routing =
Ext Spk, PREDRIVEL,
Ext Spk, PREDRIVER,
MAINMIC, Main Mic,
Main Mic, Mic Bias 1;

So you connect the MicBias1 to Main Mic. When you start playback MicBias1 will
be turned on for you.

 +   };
  };
 
  omap3_pmx_core {
 pinctrl-names = default;
 -   pinctrl-0 = i2c1_pins;
 +   pinctrl-0 = 
 +   i2c1_pins
 +   mcbsp2_pins
 +   ;
 
 leds_pins: pinmux_led_pins {
 pinctrl-single,pins = 
 @@ -65,6 +76,21 @@
 0x18c 0x118 /* I2C1_SDA */
  ;
 };
 +
 +   mcbsp2_pins: pinmux_mcbsp2_pins {
 +pinctrl-single,pins = 
 +   /*
 +* MCBSP2_FSX, OMAP_MUX_MODE0 | OMAP_PIN_INPUT,
 +* MCBSP2_CLKX, OMAP_MUX_MODE0 | OMAP_PIN_INPUT
 +*/
 +   0x10c 0x01000100
 +   /*
 +* MCBSP2_DR, OMAP_MUX_MODE0 | OMAP_PIN_INPUT,
 +* MCBSP2_DX, OMAP_MUX_MODE0 | OMAP_PIN_OUTPUT
 +*/
 +   0x110 0x0100
 +   ;
 +   };
  };
 
  i2c1 {
 @@ -74,6 +100,14 @@
 reg = 0x48;
 interrupts = 7;   /* SYS_NIRQ cascaded to intc */
 interrupt-parent = intc;
 +
 +   twl_audio: audio {
 +   compatible = ti,twl4030-audio;
 +   codec {
 +   ti,ramp_delay_value = 3;
 +   ti,offset_cncl_path = 0x31;
 +   };
 +   };
 };
  };
 
 3) Playback amixer commands
amixer set 'PredriveR Mixer AudioR2' on
amixer set 'PredriveL Mixer AudioL2' on
amixer set PreDriv 100 unmute
amixer set 'DAC2 Digital Fine' 100
 
 Thanks,
 Anil
 


-- 
Péter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Sound record on Devkit8000 with DT boot issue

2013-02-11 Thread Peter Ujfalusi
Hi,

On 02/11/2013 06:58 PM, Anil Kumar wrote:
 Here you should have something like:
 ti,audio-routing =
 Ext Spk, PREDRIVEL,
 Ext Spk, PREDRIVER,
 MAINMIC, Main Mic,
 Main Mic, Mic Bias 1;

 So you connect the MicBias1 to Main Mic. When you start playback MicBias1 
 will
 be turned on for you.
 
 I tried with this routing (next-20130211 tag kernel). But it is not
 working for me.
 So i have gone through other board and found snd_soc_dapm_route for
 
 1) zoom2.c
{MAINMIC, NULL, Mic Bias 1},
{Mic Bias 1, NULL, Ext Mic},
 
 2) omap3pandora.c
 {MAINMIC, NULL, Mic Bias 1},
 {Mic Bias 1, NULL, Mic (internal)},
 
 But for omap-twl4030.c it is
 {MAINMIC, NULL, Main Mic},
 {Main Mic, NULL, Mic Bias 1},
 
  It Should will be as ?
 {MAINMIC, NULL, Mic Bias 1},
 {Mic Bias 1, NULL, Main Mic},
 
 Because with this i am able to get audio on Devkit8000 as
  ti,audio-routing =
 Ext Spk, PREDRIVEL,
 Ext Spk, PREDRIVER,
 MAINMIC, Mic Bias 1,
 Mic Bias 1, Main Mic;

In 3.9 this should not work...

linux-next should not have zoom2 at least and I converted the machine drivers
as well in regards to micbias handling:
e04d6e5 ASoC: twl4030: Convert MICBIAS to SUPPLY widget
57d61b9 ASoC: OMAP: Remove obsolete machine drivers for Zoom2 and SDP3430

-- 
Péter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 09/11] mfd: twl-core: Collect global variables behind one private structure (global)

2013-02-11 Thread Peter Ujfalusi
On 02/11/2013 09:22 PM, Jon Hunter wrote:
 Good point. I just noticed that none of my omap2+ board were booting and
 on omap3/4 I was the panic in the twl code. I can't say that I checked
 the panic on omap2, so may be that was another problem?

Do you have insights on the code path leading to a crash on OMAP3/4? I have
been running this code on several boards (BeagleBoard, Zoom2, PandaBoard,
Blaze) and have not seen a crash.
But the fix is valid.

-- 
Péter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 09/11] mfd: twl-core: Collect global variables behind one private structure (global)

2013-02-13 Thread Peter Ujfalusi
Hi Jon,

On 02/12/2013 05:15 PM, Jon Hunter wrote:
 
 On 02/12/2013 01:26 AM, Peter Ujfalusi wrote:
 On 02/11/2013 09:22 PM, Jon Hunter wrote:
 Good point. I just noticed that none of my omap2+ board were booting and
 on omap3/4 I was the panic in the twl code. I can't say that I checked
 the panic on omap2, so may be that was another problem?

 Do you have insights on the code path leading to a crash on OMAP3/4? I have
 been running this code on several boards (BeagleBoard, Zoom2, PandaBoard,
 Blaze) and have not seen a crash.
 
 Here is the panic log ...

Thanks.

 
 [2.286132] Unable to handle kernel NULL pointer dereference at virtual 
 address 
 [2.294738] pgd = c0004000
 [2.297576] [] *pgd=
 [2.301361] Internal error: Oops: 5 [#1] SMP ARM
 [2.306243] Modules linked in:
 [2.309448] CPU: 0Not tainted  (3.8.0-rc6-next-20130207-00016-g735c237 
 #35)
 [2.317169] PC is at twl_i2c_read+0x3c/0xec
 [2.321563] LR is at twl_i2c_read+0x1c/0xec
 [2.325988] pc : [c0333950]lr : [c0333930]psr: 8153
 [2.325988] sp : c702fed0  ip :   fp : 
 [2.338043] r10: c702e000  r9 : c06e84e8  r8 : c06e51c8
 [2.343536] r7 : 0001  r6 : 0006  r5 : c702fef6  r4 : 0004
 [2.350402] r3 : c129508c  r2 : 0006  r1 : c702fef6  r0 : 000e
 [2.357269] Flags: Nzcv  IRQs on  FIQs off  Mode SVC_32  ISA ARM  Segment 
 kernel
 [2.365051] Control: 10c5387d  Table: 80004019  DAC: 0017
 [2.371093] Process swapper/0 (pid: 1, stack limit = 0xc702e240)
 [2.377410] Stack: (0xc702fed0 to 0xc703)
 [2.382019] fec0: c0d42180 c0d429d0 
 c70a7640 c07354c4
 [2.390624] fee0: 0001 c0719798 c0d42180 c06f2cc0 c04e76cc c06ee1ac 
  c07354c4
 [2.399230] ff00: 0007 c06f2d64 0017 c06fb308  c06f07a4 
 c0cb8580 c06edee0
 [2.407836] ff20: c06eded4 c06e8504 c0d42180 c0008768 009e c00611b4 
 0001 
 [2.416442] ff40: c061994c c06b7548 0007 0007  c07354c4 
 0007 c0719798
 [2.425048] ff60: c0d42180 c06e51c8 c07197a0 009e  c06e590c 
 0007 0007
 [2.433654] ff80: c06e51c8   c04d26ec   
  
 [2.442260] ffa0:  c04d26f4  c00137b0   
  
 [2.450866] ffc0:       
  
 [2.459472] ffe0:     0013  
 80fb6c10 71bbcd20
 [2.468078] [c0333950] (twl_i2c_read+0x3c/0xec) from [c06f2cc0] 
 (omap3_twl_set_sr_bit+0x3c/0xb4)
 [2.477722] [c06f2cc0] (omap3_twl_set_sr_bit+0x3c/0xb4) from 
 [c06f2d64] (omap3_twl_init+0x2c/0x70)
 [2.487518] [c06f2d64] (omap3_twl_init+0x2c/0x70) from [c06fb308] 
 (omap_pmic_late_init+0x18/0x24)
 [2.497222] [c06fb308] (omap_pmic_late_init+0x18/0x24) from [c06f07a4] 
 (omap2_common_pm_late_init+0x18/0xd0)
 [2.507934] [c06f07a4] (omap2_common_pm_late_init+0x18/0xd0) from 
 [c06edee0] (omap3_init_late+0xc/0x18)
 [2.518188] [c06edee0] (omap3_init_late+0xc/0x18) from [c06e8504] 
 (init_machine_late+0x1c/0x28)
 [2.527740] [c06e8504] (init_machine_late+0x1c/0x28) from [c0008768] 
 (do_one_initcall+0x100/0x16c)
 [2.537536] [c0008768] (do_one_initcall+0x100/0x16c) from [c06e590c] 
 (kernel_init_freeable+0xfc/0x1c8)
 [2.547698] [c06e590c] (kernel_init_freeable+0xfc/0x1c8) from 
 [c04d26f4] (kernel_init+0x8/0xe4)
 [2.557250] [c04d26f4] (kernel_init+0x8/0xe4) from [c00137b0] 
 (ret_from_fork+0x14/0x24)

This is exactly the sort of thing which should not ever existed in the first
place...
The code in omap_twl.c, especially the omap3_twl_set_sr_bit() function is
executed in .init_late of the board. If the twl stack is not up by then we are
going to have issues.
Right now I don't see how to solve this (the call chain is related to
smartreflex) but IMHO we should not have these 'random' twl_write calls spread
across the kernel without integrating them to the twl stack in a proper
manner. What I mean is that we should only have twl_* calls from drivers,
which has been created by the twl-core MFD core.

-- 
Péter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/4] pwm_backlight: Fix PWM levels support in non DT case

2013-01-29 Thread Peter Ujfalusi
On 01/29/2013 11:17 AM, Thierry Reding wrote:
 On Tue, Jan 29, 2013 at 09:17:04AM +0100, Peter Ujfalusi wrote:
 On 01/28/2013 10:01 PM, Thierry Reding wrote:
 On Tue, Jan 22, 2013 at 02:39:53PM +0100, Peter Ujfalusi wrote:
 It is expected that board files would have:
 static unsigned int bl_levels[] = { 0, 50, 100, 150, 200, 250, };

 static struct platform_pwm_backlight_data bl_data = {
.levels = bl_levels,
.max_brightness = ARRAY_SIZE(bl_levels),
.dft_brightness = 4,
.pwm_period_ns = 7812500,
 };

 In this case the max_brightness would be out of range in the levels array.
 Decrement the received max_brightness in every case (DT or non DT) when the
 levels has been provided.

 What's wrong with specifying .max_brightness = ARRAY_SIZE(bl_levels) - 1
 instead?

 There is nothing wrong with that either but IMHO it is more natural for board
 files to use just ARRAY_SIZE(bl_levels). In this way the handling of
 data-max_brightness among non DT and DT booted kernel is more uniform in the
 driver itself.
 
 The .max_brightness field is defined to be the maximum value that you
 can set the brightness to. If you use .levels and set .max_brightness to
 ARRAY_SIZE() then that's no longer true because the maximum value for
 the brightness will actually be ARRAY_SIZE() - 1.

Yes, in conjunction with .levels it would be better to have .nr_levels instead
reusing the max_brightness.

 The reason why in the DT case we decrement .max_brightness is that it is
 used as a temporary variable to keep the number of levels, which
 corresponds to ARRAY_SIZE() in your example, and adjust it later on to
 match the definition. That's an implementation detail.
 
 Platform data content should be encoded properly without knowledge of
 the internal implementation.
 
 Right now all board files are using only the .max_brightness to specify the
 maximum value, I could not find any users of .levels in the kernel.
 
 Yes. But this is the legacy mode which should be considered deprecated.
 The reason why the concept of brightness-levels was introduced back when
 the DT bindings were created was that pretty much no hardware in
 existence actually works that way. This was a topic of discussion at the
 time when I first proposed these changes, see for example:
 
   
 http://www.mail-archive.com/devicetree-discuss@lists.ozlabs.org/msg09472.html

Right. Now I know the background.
However I do not agree with the conclusion. Probably it is fine in some cases
to limit the number of configurable duty cycles to have only distinct steps.
To not go too far, on my laptop I have:
# cat /sys/class/backlight/acpi_video0/max_brightness
15
# cat /sys/class/backlight/intel_backlight/max_brightness
93

In this case I would be more happier if the user space would use the
intel_backlight than the acpi_video0. I'm fine if user space decides to allow
me only 15 distinct steps on the intel_backlight but I would expect it to do
so in a way when I change the brightness in the UI it would step down or up to
the next user configurable level. Right now it uses the acpi_video0 to control
the levels which means that I have (ugly) jumps in the backlight every time I
adjust it.

In my phone and tablet all transitions between backlight levels are smooth.
This is not a case in my laptop (with exception when the backlight is set to
auto, FW controlled).

The perceived brightness change depends on the surrounding environment, you
can not say that in high level you would need less steps or you need to have
less steps in low brightness. If you in a dark room the low changes can be
observed, while the same change when you are outside in a sunny day would not
reflect the same.

Sure we could do the ramps in driver, but what are the parameters? how many
step between the two level? What is the time between the steps?

If you are about to make a product you will end up specifying all the possible
steps to provide the best user experience. So if the PWM have 127 duty cycle
you will have levels from 0, 1, 2, 3, , 125, 126, 127.

-- 
Péter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/4] pwm_backlight: Fix PWM levels support in non DT case

2013-01-29 Thread Peter Ujfalusi
On 01/29/2013 01:30 PM, Thierry Reding wrote:
 Right. Now I know the background.
 However I do not agree with the conclusion. Probably it is fine in some cases
 to limit the number of configurable duty cycles to have only distinct steps.
 To not go too far, on my laptop I have:
 # cat /sys/class/backlight/acpi_video0/max_brightness
 15
 # cat /sys/class/backlight/intel_backlight/max_brightness
 93
 
 FWIW, I have hardware with an Intel chipset that has max_brightness
 13666. That doesn't mean all of these are necessarily valid or useful.

For sure this range is overkill, but if you reduce it to let's say 15 would it
be better? I don't think. It is up to the userspace to decide how to use it.
User should have full control over the HW in hand. In this particular case I
would expect userspace to give you around 20 steps to change brightness and
when you change it would step between those so you will have nice, smooth
changes and not big jumps.

 That's not true. The duty-cycle merely defines a percentage of how long
 the PWM signal will be high. You can choose an arbitrary number of
 subdivisions.

Sure all HW has limitation. The HW I have either have 127 or 255 time slots.
Probably the best thing way to deal with the backlight is to have a range of 0
- 100% Nothing else.
We should have an API to PWMs so user drivers could get the duty cycle from
the HW drivers. In this way backlight would only expose percentage and the
backlight driver would get the number of time slots from the PWM core to
calculate the actual value for the selected percentage.

 Since the brightness of a display isn't linearly proportional to the
 duty cycle of the PWM driving it, representing that brightness by a
 linear range is misleading. Furthermore some panels have regions where
 the backlight isn't lit at all or where changes in the PWM duty-cycle
 don't make any difference.

and all of this also depend on the surrounding light conditions as well. If
the same device is used in low light condition you care about the lower light
ranges more compared to when the same device is used in bright environment. In
these case the user space has to be adopted to the conditions and one should
not need to recompile the kernel/dtb just because the device is used in
different environment.

-- 
Péter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] USB: musb: Correct Kconfig in order to avoid non compilable selection

2013-01-31 Thread Peter Ujfalusi
Currently it is possible to have:
USB_MUSB_OMAP2PLUS=m
TWL4030_USB=y

which would result compile time error due to missing symbols.

With this change USB_MUSB_OMAP2PLUS and TWL4030_USB will be in sync.

Reported-by: Vincent Stehle v-ste...@ti.com
Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
---
Hi Felipe,

I have also noticed that we have similar issue around USB_MUSB_HDRC,
CONFIG_USB_MUSB_TUSB6010 and CONFIG_USB_TUSB_OMAP_DMA. You can easily have a
combination of y/m of these to have non compilable kernel.
I have tried to fix it but my Kconfig skills are not adequate for it ;)

Regards,
Peter

 drivers/usb/musb/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index 23a0b7f..a3fa19c 100644
--- a/drivers/usb/musb/Kconfig
+++ b/drivers/usb/musb/Kconfig
@@ -9,8 +9,6 @@ config USB_MUSB_HDRC
depends on USB  USB_GADGET
select NOP_USB_XCEIV if (ARCH_DAVINCI || MACH_OMAP3EVM || BLACKFIN)
select NOP_USB_XCEIV if (SOC_TI81XX || SOC_AM33XX)
-   select TWL4030_USB if MACH_OMAP_3430SDP
-   select TWL6030_USB if MACH_OMAP_4430SDP || MACH_OMAP4_PANDA
select USB_OTG_UTILS
help
  Say Y here if your system has a dual role high speed USB
@@ -49,6 +47,8 @@ config USB_MUSB_TUSB6010
 config USB_MUSB_OMAP2PLUS
tristate OMAP2430 and onwards
depends on ARCH_OMAP2PLUS
+   select TWL4030_USB if MACH_OMAP_3430SDP
+   select TWL6030_USB if MACH_OMAP_4430SDP || MACH_OMAP4_PANDA
 
 config USB_MUSB_AM35X
tristate AM35x
-- 
1.8.1.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/4] pwm_backlight: Validate dft_brightness in main probe function

2013-01-31 Thread Peter Ujfalusi
Hi Thierry,

On 01/22/2013 02:39 PM, Peter Ujfalusi wrote:
 Move the dft_brightness validity check from the DT parsing function to the
 main probe. In this way we can validate it in case we are booting with or
 without DT.

Based on the discussion the rest of the series is going to be dropped, but
what about this single patch?
I think it is still addresses a valid issue, which is that in non DT boot we
do not check if the dft_brightness is within valid range.

I can resend this patch alone since it is not going to apply on mainline as it 
is.

-- 
Péter

 
 Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
 ---
  drivers/video/backlight/pwm_bl.c | 12 ++--
  1 file changed, 6 insertions(+), 6 deletions(-)
 
 diff --git a/drivers/video/backlight/pwm_bl.c 
 b/drivers/video/backlight/pwm_bl.c
 index f0d6854..2a81c24 100644
 --- a/drivers/video/backlight/pwm_bl.c
 +++ b/drivers/video/backlight/pwm_bl.c
 @@ -135,12 +135,6 @@ static int pwm_backlight_parse_dt(struct device *dev,
   if (ret  0)
   return ret;
  
 - if (value = data-max_brightness) {
 - dev_warn(dev, invalid default brightness level: %u, 
 using %u\n,
 -  value, data-max_brightness - 1);
 - value = data-max_brightness - 1;
 - }
 -
   data-dft_brightness = value;
   }
  
 @@ -249,6 +243,12 @@ static int pwm_backlight_probe(struct platform_device 
 *pdev)
   goto err_alloc;
   }
  
 + if (data-dft_brightness  data-max_brightness) {
 + dev_warn(pdev-dev,
 +  invalid default brightness level: %u, using %u\n,
 +  data-dft_brightness, data-max_brightness);
 + data-dft_brightness = data-max_brightness;
 + }
   bl-props.brightness = data-dft_brightness;
   backlight_update_status(bl);
  
 
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] mfd: twl4030-audio: Fix argument type for twl4030_audio_disable_resource()

2013-03-02 Thread Peter Ujfalusi
On 03/02/2013 08:30 AM, Mark Brown wrote:
 Looks like the conversion to enum was missed for the definition of this
 function, the declaration has been updated.

Acked-by: Peter Ujfalusi peter.ujfal...@ti.com

 
 Signed-off-by: Mark Brown broo...@opensource.wolfsonmicro.com
 ---
  drivers/mfd/twl4030-audio.c |2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/drivers/mfd/twl4030-audio.c b/drivers/mfd/twl4030-audio.c
 index e16edca..d2ab222 100644
 --- a/drivers/mfd/twl4030-audio.c
 +++ b/drivers/mfd/twl4030-audio.c
 @@ -118,7 +118,7 @@ EXPORT_SYMBOL_GPL(twl4030_audio_enable_resource);
   * Disable the resource.
   * The function returns with error or the content of the register
   */
 -int twl4030_audio_disable_resource(unsigned id)
 +int twl4030_audio_disable_resource(enum twl4030_audio_res id)
  {
   struct twl4030_audio *audio = platform_get_drvdata(twl4030_audio_dev);
   int val;
 


-- 
Péter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


  1   2   3   4   5   6   7   8   9   10   >