Re: [PATCH] rtc-twl: Switch to using threaded irq

2011-05-18 Thread Ilkka Koskinen

Hi,

Tony, would you mind taking the patch in your tree?

Btw, the nokia address doesn't work anymore, but
should probably still remain in s-o-b...

Cheers, Ilkka

13.5.2011 2:24, John Stultz kirjoitti:
 On Thu, 2011-05-05 at 07:51 +, ilkka.koski...@nokia.com wrote:
 Hi,

 Tony and John: What would be the appropriate path for this patch?
 
 I'd probably push it through omap maintainer path, as its hardware
 specific and can be better tested there.
 
 thanks
 -john
 
 
 On Apr 13, 2011 Krishnamoorthy, Balaji T  wrote:
 On Wed, Mar 16, 2011 at 9:37 PM, Ilkka Koskinen
 ilkka.koski...@nokia.com wrote:

 The driver is accessing to i2c bus in interrupt handler.
 Therefore, it should use threaded irq.

 Acked-by: Balaji T K balaj...@ti.com


 Signed-off-by: Ilkka Koskinen ilkka.koski...@nokia.com
 ---
  drivers/rtc/rtc-twl.c |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)

 diff --git a/drivers/rtc/rtc-twl.c b/drivers/rtc/rtc-twl.c
 index ed1b868..2715b96 100644
 --- a/drivers/rtc/rtc-twl.c
 +++ b/drivers/rtc/rtc-twl.c
 @@ -475,7 +475,7 @@ static int __devinit twl_rtc_probe(struct 
 platform_device *pdev)
if (ret  0)
goto out1;

 -   ret = request_irq(irq, twl_rtc_interrupt,
 +   ret = request_threaded_irq(irq, NULL, twl_rtc_interrupt,
IRQF_TRIGGER_RISING,
dev_name(rtc-dev), rtc);
if (ret  0) {
 --
 1.7.0.4

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


[PATCH 1/2] omap: Remove unnecessary twl4030_codec_audio settings from board files

2011-03-02 Thread Ilkka Koskinen
twl4030_codec_audio and twl4030_codec_vibra_data has unused field.
In order to remove it, corresponding settings needs to be removed
from board files.

Signed-off-by: Ilkka Koskinen ilkka.koski...@nokia.com
---
 arch/arm/mach-omap2/board-3430sdp.c  |4 +---
 arch/arm/mach-omap2/board-devkit8000.c   |4 +---
 arch/arm/mach-omap2/board-igep0020.c |4 +---
 arch/arm/mach-omap2/board-omap3beagle.c  |4 +---
 arch/arm/mach-omap2/board-omap3evm.c |4 +---
 arch/arm/mach-omap2/board-omap3pandora.c |4 +---
 arch/arm/mach-omap2/board-omap3stalker.c |4 +---
 arch/arm/mach-omap2/board-omap3touchbook.c   |4 +---
 arch/arm/mach-omap2/board-overo.c|4 +---
 arch/arm/mach-omap2/board-zoom-peripherals.c |4 +---
 10 files changed, 10 insertions(+), 30 deletions(-)

diff --git a/arch/arm/mach-omap2/board-3430sdp.c 
b/arch/arm/mach-omap2/board-3430sdp.c
index d4e41ef..4722ffa 100644
--- a/arch/arm/mach-omap2/board-3430sdp.c
+++ b/arch/arm/mach-omap2/board-3430sdp.c
@@ -567,9 +567,7 @@ static struct regulator_init_data sdp3430_vpll2 = {
.consumer_supplies  = sdp3430_vpll2_supplies,
 };
 
-static struct twl4030_codec_audio_data sdp3430_audio = {
-   .audio_mclk = 2600,
-};
+static struct twl4030_codec_audio_data sdp3430_audio;
 
 static struct twl4030_codec_data sdp3430_codec = {
.audio_mclk = 2600,
diff --git a/arch/arm/mach-omap2/board-devkit8000.c 
b/arch/arm/mach-omap2/board-devkit8000.c
index 00bb1fc..755f63a 100644
--- a/arch/arm/mach-omap2/board-devkit8000.c
+++ b/arch/arm/mach-omap2/board-devkit8000.c
@@ -346,9 +346,7 @@ static struct twl4030_usb_data devkit8000_usb_data = {
.usb_mode   = T2_USB_MODE_ULPI,
 };
 
-static struct twl4030_codec_audio_data devkit8000_audio_data = {
-   .audio_mclk = 2600,
-};
+static struct twl4030_codec_audio_data devkit8000_audio_data;
 
 static struct twl4030_codec_data devkit8000_codec_data = {
.audio_mclk = 2600,
diff --git a/arch/arm/mach-omap2/board-igep0020.c 
b/arch/arm/mach-omap2/board-igep0020.c
index 3be85a1..6022990 100644
--- a/arch/arm/mach-omap2/board-igep0020.c
+++ b/arch/arm/mach-omap2/board-igep0020.c
@@ -533,9 +533,7 @@ static void __init igep2_init_irq(void)
omap_init_irq();
 }
 
-static struct twl4030_codec_audio_data igep2_audio_data = {
-   .audio_mclk = 2600,
-};
+static struct twl4030_codec_audio_data igep2_audio_data;
 
 static struct twl4030_codec_data igep2_codec_data = {
.audio_mclk = 2600,
diff --git a/arch/arm/mach-omap2/board-omap3beagle.c 
b/arch/arm/mach-omap2/board-omap3beagle.c
index 46d814a..164b4c3 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -435,9 +435,7 @@ static struct twl4030_usb_data beagle_usb_data = {
.usb_mode   = T2_USB_MODE_ULPI,
 };
 
-static struct twl4030_codec_audio_data beagle_audio_data = {
-   .audio_mclk = 2600,
-};
+static struct twl4030_codec_audio_data beagle_audio_data;
 
 static struct twl4030_codec_data beagle_codec_data = {
.audio_mclk = 2600,
diff --git a/arch/arm/mach-omap2/board-omap3evm.c 
b/arch/arm/mach-omap2/board-omap3evm.c
index 323c380..db147d7 100644
--- a/arch/arm/mach-omap2/board-omap3evm.c
+++ b/arch/arm/mach-omap2/board-omap3evm.c
@@ -491,9 +491,7 @@ static struct twl4030_madc_platform_data omap3evm_madc_data 
= {
.irq_line   = 1,
 };
 
-static struct twl4030_codec_audio_data omap3evm_audio_data = {
-   .audio_mclk = 2600,
-};
+static struct twl4030_codec_audio_data omap3evm_audio_data;
 
 static struct twl4030_codec_data omap3evm_codec_data = {
.audio_mclk = 2600,
diff --git a/arch/arm/mach-omap2/board-omap3pandora.c 
b/arch/arm/mach-omap2/board-omap3pandora.c
index 0b34bed..51e8c20 100644
--- a/arch/arm/mach-omap2/board-omap3pandora.c
+++ b/arch/arm/mach-omap2/board-omap3pandora.c
@@ -524,9 +524,7 @@ static struct twl4030_usb_data omap3pandora_usb_data = {
.usb_mode   = T2_USB_MODE_ULPI,
 };
 
-static struct twl4030_codec_audio_data omap3pandora_audio_data = {
-   .audio_mclk = 2600,
-};
+static struct twl4030_codec_audio_data omap3pandora_audio_data;
 
 static struct twl4030_codec_data omap3pandora_codec_data = {
.audio_mclk = 2600,
diff --git a/arch/arm/mach-omap2/board-omap3stalker.c 
b/arch/arm/mach-omap2/board-omap3stalker.c
index 2a2dad4..2572f71 100644
--- a/arch/arm/mach-omap2/board-omap3stalker.c
+++ b/arch/arm/mach-omap2/board-omap3stalker.c
@@ -439,9 +439,7 @@ static struct twl4030_madc_platform_data 
omap3stalker_madc_data = {
.irq_line   = 1,
 };
 
-static struct twl4030_codec_audio_data omap3stalker_audio_data = {
-   .audio_mclk = 2600,
-};
+static struct twl4030_codec_audio_data omap3stalker_audio_data;
 
 static struct twl4030_codec_data omap3stalker_codec_data = {
.audio_mclk = 2600,
diff --git a/arch/arm/mach-omap2/board

[PATCH 2/2] mfd: twl4030_codec: Remove unused and duplicate audio_mclk fields

2011-03-02 Thread Ilkka Koskinen
audio_mclk can be queried from mfd driver. Therefore, it is not
needed in twl4030_codec_audio_data or in twl4030_codec_vibra_data
anymore.

Signed-off-by: Ilkka Koskinen ilkka.koski...@nokia.com
---
 include/linux/i2c/twl.h |2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/include/linux/i2c/twl.h b/include/linux/i2c/twl.h
index 61b9609..9d88b71 100644
--- a/include/linux/i2c/twl.h
+++ b/include/linux/i2c/twl.h
@@ -637,7 +637,6 @@ extern void twl4030_power_init(struct twl4030_power_data 
*triton2_scripts);
 extern int twl4030_remove_script(u8 flags);
 
 struct twl4030_codec_audio_data {
-   unsigned int audio_mclk; /* not used, will be removed */
unsigned int digimic_delay; /* in ms */
unsigned int ramp_delay_value;
unsigned int offset_cncl_path;
@@ -648,7 +647,6 @@ struct twl4030_codec_audio_data {
 };
 
 struct twl4030_codec_vibra_data {
-   unsigned intaudio_mclk;
unsigned intcoexist;
 };
 
-- 
1.7.0.4

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


[PATCH 0/2] twl4030_codec cleanup

2011-03-02 Thread Ilkka Koskinen
This series of patches removes duplicate audio_mclk fields from
twl4030_codec driver.

The patches have been compiled on sound-2.6/for-2.6.39 branch.
I haven't tested them on any target board though.

Ilkka Koskinen (2):
  omap: Remove unnecessary twl4030_codec_audio settings from board
files
  mfd: twl4030_codec: Remove unused and duplicate audio_mclk fields

 arch/arm/mach-omap2/board-3430sdp.c  |4 +---
 arch/arm/mach-omap2/board-devkit8000.c   |4 +---
 arch/arm/mach-omap2/board-igep0020.c |4 +---
 arch/arm/mach-omap2/board-omap3beagle.c  |4 +---
 arch/arm/mach-omap2/board-omap3evm.c |4 +---
 arch/arm/mach-omap2/board-omap3pandora.c |4 +---
 arch/arm/mach-omap2/board-omap3stalker.c |4 +---
 arch/arm/mach-omap2/board-omap3touchbook.c   |4 +---
 arch/arm/mach-omap2/board-overo.c|4 +---
 arch/arm/mach-omap2/board-zoom-peripherals.c |4 +---
 include/linux/i2c/twl.h  |2 --
 11 files changed, 10 insertions(+), 32 deletions(-)

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


[PATCH] omap: rx51: Add support for vibra

2011-02-25 Thread Ilkka Koskinen
Signed-off-by: Ilkka Koskinen ilkka.koski...@nokia.com
---
 arch/arm/mach-omap2/board-rx51-peripherals.c |9 +
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/board-rx51-peripherals.c 
b/arch/arm/mach-omap2/board-rx51-peripherals.c
index e75e240..dcd98fa 100644
--- a/arch/arm/mach-omap2/board-rx51-peripherals.c
+++ b/arch/arm/mach-omap2/board-rx51-peripherals.c
@@ -699,6 +699,14 @@ static struct twl4030_power_data rx51_t2scripts_data 
__initdata = {
.resource_config = twl4030_rconfig,
 };
 
+struct twl4030_codec_vibra_data rx51_vibra_data __initdata = {
+   .coexist= 0,
+};
+
+struct twl4030_codec_data rx51_codec_data __initdata = {
+   .audio_mclk = 2600,
+   .vibra  = rx51_vibra_data,
+};
 
 static struct twl4030_platform_data rx51_twldata __initdata = {
.irq_base   = TWL4030_IRQ_BASE,
@@ -710,6 +718,7 @@ static struct twl4030_platform_data rx51_twldata __initdata 
= {
.madc   = rx51_madc_data,
.usb= rx51_usb_data,
.power  = rx51_t2scripts_data,
+   .codec  = rx51_codec_data,
 
.vaux1  = rx51_vaux1,
.vaux2  = rx51_vaux2,
-- 
1.7.0.4

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


[PATCH] spi/omap2_mcspi: Verify TX reg is empty after TX only xfer with DMA

2010-10-19 Thread Ilkka Koskinen
In case of TX only with DMA, the driver assumes that the data
has been transferred once DMA callback in invoked. However,
SPI's shift register may still contain data. Thus, the driver
is supposed to verify that the register is empty and the end of
the SPI transfer has been reached.

Signed-off-by: Ilkka Koskinen ilkka.koski...@nokia.com
Tested-by: Tuomas Katila ext-tuomas.2.kat...@nokia.com
---
 drivers/spi/omap2_mcspi.c |   39 ++-
 1 files changed, 26 insertions(+), 13 deletions(-)

diff --git a/drivers/spi/omap2_mcspi.c b/drivers/spi/omap2_mcspi.c
index b3a94ca..a2e053c 100644
--- a/drivers/spi/omap2_mcspi.c
+++ b/drivers/spi/omap2_mcspi.c
@@ -296,6 +296,19 @@ static int omap2_mcspi_enable_clocks(struct omap2_mcspi 
*mcspi)
return 0;
 }
 
+static int mcspi_wait_for_reg_bit(void __iomem *reg, unsigned long bit)
+{
+   unsigned long timeout;
+
+   timeout = jiffies + msecs_to_jiffies(1000);
+   while (!(__raw_readl(reg)  bit)) {
+   if (time_after(jiffies, timeout))
+   return -1;
+   cpu_relax();
+   }
+   return 0;
+}
+
 static unsigned
 omap2_mcspi_txrx_dma(struct spi_device *spi, struct spi_transfer *xfer)
 {
@@ -309,11 +322,14 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct 
spi_transfer *xfer)
u32 l;
u8  * rx;
const u8* tx;
+   void __iomem*chstat_reg;
 
mcspi = spi_master_get_devdata(spi-master);
mcspi_dma = mcspi-dma_channels[spi-chip_select];
l = mcspi_cached_chconf0(spi);
 
+   chstat_reg = cs-base + OMAP2_MCSPI_CHSTAT0;
+
count = xfer-len;
c = count;
word_len = cs-word_len;
@@ -382,6 +398,16 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct 
spi_transfer *xfer)
if (tx != NULL) {
wait_for_completion(mcspi_dma-dma_tx_completion);
dma_unmap_single(NULL, xfer-tx_dma, count, DMA_TO_DEVICE);
+
+   /* for TX_ONLY mode, be sure all words have shifted out */
+   if (rx == NULL) {
+   if (mcspi_wait_for_reg_bit(chstat_reg,
+   OMAP2_MCSPI_CHSTAT_TXS)  0)
+   dev_err(spi-dev, TXS timed out\n);
+   else if (mcspi_wait_for_reg_bit(chstat_reg,
+   OMAP2_MCSPI_CHSTAT_EOT)  0)
+   dev_err(spi-dev, EOT timed out\n);
+   }
}
 
if (rx != NULL) {
@@ -435,19 +461,6 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct 
spi_transfer *xfer)
return count;
 }
 
-static int mcspi_wait_for_reg_bit(void __iomem *reg, unsigned long bit)
-{
-   unsigned long timeout;
-
-   timeout = jiffies + msecs_to_jiffies(1000);
-   while (!(__raw_readl(reg)  bit)) {
-   if (time_after(jiffies, timeout))
-   return -1;
-   cpu_relax();
-   }
-   return 0;
-}
-
 static unsigned
 omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer)
 {
-- 
1.6.0.4

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


[PATCH] mfd: twl5031: Rename sih modules

2010-05-20 Thread Ilkka Koskinen
Fix the names of twl5031 specific sih modules to match
the documentation.

Signed-off-by: Ilkka Koskinen ilkka.koski...@nokia.com
---
 drivers/mfd/twl4030-irq.c |   11 ++-
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
index 202bdd5..097f24d 100644
--- a/drivers/mfd/twl4030-irq.c
+++ b/drivers/mfd/twl4030-irq.c
@@ -232,10 +232,11 @@ static const struct sih sih_modules_twl5031[8] = {
},
[6] = {
/*
-* ACI doesn't use the same SIH organization.
-* For example, it supports only one interrupt line
+* ECI/DBI doesn't use the same SIH organization.
+* For example, it supports only one interrupt output line.
+* That is, the interrupts are seen on both INT1 and INT2 lines.
 */
-   .name   = aci,
+   .name   = eci_dbi,
.module = TWL5031_MODULE_ACCESSORY,
.bits   = 9,
.bytes_ixr  = 2,
@@ -247,8 +248,8 @@ static const struct sih sih_modules_twl5031[8] = {
 
},
[7] = {
-   /* Accessory */
-   .name   = acc,
+   /* Audio accessory */
+   .name   = audio,
.module = TWL5031_MODULE_ACCESSORY,
.control_offset = TWL5031_ACCSIHCTRL,
.bits   = 2,
-- 
1.6.0.4

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


[PATCHv5 2/2] ASoC: OMAP-McBSP: ASoC interface for McBSP sidetone

2010-02-22 Thread Ilkka Koskinen
Add ASoC interface for OMAP McBSP2 and McBSP3 sidetones.

Signed-off-by: Ilkka Koskinen ilkka.koski...@nokia.com
---
 sound/soc/omap/omap-mcbsp.c |  138 +++
 sound/soc/omap/omap-mcbsp.h |2 +
 2 files changed, 140 insertions(+), 0 deletions(-)

diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c
index c0039b3..8da14f5 100644
--- a/sound/soc/omap/omap-mcbsp.c
+++ b/sound/soc/omap/omap-mcbsp.c
@@ -39,6 +39,14 @@
 
 #define OMAP_MCBSP_RATES   (SNDRV_PCM_RATE_8000_96000)
 
+#define OMAP_MCBSP_SOC_SINGLE_S16_EXT(xname, xmin, xmax, \
+   xhandler_get, xhandler_put) \
+{  .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
+   .info = omap_mcbsp_st_info_volsw, \
+   .get = xhandler_get, .put = xhandler_put, \
+   .private_value = (unsigned long) (struct soc_mixer_control) \
+   {.min = xmin, .max = xmax} }
+
 struct omap_mcbsp_data {
unsigned intbus_id;
struct omap_mcbsp_reg_cfg   regs;
@@ -637,6 +645,136 @@ struct snd_soc_dai omap_mcbsp_dai[] = {
 
 EXPORT_SYMBOL_GPL(omap_mcbsp_dai);
 
+int omap_mcbsp_st_info_volsw(struct snd_kcontrol *kcontrol,
+   struct snd_ctl_elem_info *uinfo)
+{
+   struct soc_mixer_control *mc =
+   (struct soc_mixer_control *)kcontrol-private_value;
+   int max = mc-max;
+   int min = mc-min;
+
+   uinfo-type = SNDRV_CTL_ELEM_TYPE_INTEGER;
+   uinfo-count = 1;
+   uinfo-value.integer.min = min;
+   uinfo-value.integer.max = max;
+   return 0;
+}
+
+#define OMAP_MCBSP_ST_SET_CHANNEL_VOLUME(id, channel)  \
+static int \
+omap_mcbsp##id##_set_st_ch##channel##_volume(struct snd_kcontrol *kc,  \
+   struct snd_ctl_elem_value *uc)  \
+{  \
+   struct soc_mixer_control *mc =  \
+   (struct soc_mixer_control *)kc-private_value;  \
+   int max = mc-max;  \
+   int min = mc-min;  \
+   int val = uc-value.integer.value[0];   \
+   \
+   if (val  min || val  max) \
+   return -EINVAL; \
+   \
+   /* OMAP McBSP implementation uses index values 0..4 */  \
+   return omap_st_set_chgain((id)-1, channel, val);\
+}
+
+#define OMAP_MCBSP_ST_GET_CHANNEL_VOLUME(id, channel)  \
+static int \
+omap_mcbsp##id##_get_st_ch##channel##_volume(struct snd_kcontrol *kc,  \
+   struct snd_ctl_elem_value *uc)  \
+{  \
+   s16 chgain; \
+   \
+   if (omap_st_get_chgain((id)-1, channel, chgain))   \
+   return -EAGAIN; \
+   \
+   uc-value.integer.value[0] = chgain;\
+   return 0;   \
+}
+
+OMAP_MCBSP_ST_SET_CHANNEL_VOLUME(2, 0)
+OMAP_MCBSP_ST_SET_CHANNEL_VOLUME(2, 1)
+OMAP_MCBSP_ST_SET_CHANNEL_VOLUME(3, 0)
+OMAP_MCBSP_ST_SET_CHANNEL_VOLUME(3, 1)
+OMAP_MCBSP_ST_GET_CHANNEL_VOLUME(2, 0)
+OMAP_MCBSP_ST_GET_CHANNEL_VOLUME(2, 1)
+OMAP_MCBSP_ST_GET_CHANNEL_VOLUME(3, 0)
+OMAP_MCBSP_ST_GET_CHANNEL_VOLUME(3, 1)
+
+static int omap_mcbsp_st_put_mode(struct snd_kcontrol *kcontrol,
+   struct snd_ctl_elem_value *ucontrol)
+{
+   struct soc_mixer_control *mc =
+   (struct soc_mixer_control *)kcontrol-private_value;
+   u8 value = ucontrol-value.integer.value[0];
+
+   if (value == omap_st_is_enabled(mc-reg))
+   return 0;
+
+   if (value)
+   omap_st_enable(mc-reg);
+   else
+   omap_st_disable(mc-reg);
+
+   return 1;
+}
+
+static int omap_mcbsp_st_get_mode(struct snd_kcontrol *kcontrol,
+   struct snd_ctl_elem_value *ucontrol)
+{
+   struct soc_mixer_control *mc =
+   (struct soc_mixer_control *)kcontrol-private_value;
+
+   ucontrol-value.integer.value[0] = omap_st_is_enabled(mc-reg);
+   return 0;
+}
+
+static const struct snd_kcontrol_new omap_mcbsp2_st_controls[] = {
+   SOC_SINGLE_EXT(McBSP2 Sidetone Switch, 1, 0, 1, 0

[PATCHv5 1/2] McBSP: OMAP3: Add sidetone feature

2010-02-22 Thread Ilkka Koskinen
From: Eero Nurkkala ext-eero.nurkk...@nokia.com

Add sidetone feature to McBSP instances 2 and 3 on OMAP3 based devices.

Signed-off-by: Ilkka Koskinen ilkka.koski...@nokia.com
---
 arch/arm/mach-omap2/mcbsp.c |2 +
 arch/arm/plat-omap/include/plat/mcbsp.h |   60 +
 arch/arm/plat-omap/mcbsp.c  |  402 ++-
 3 files changed, 463 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap2/mcbsp.c b/arch/arm/mach-omap2/mcbsp.c
index d601f94..be8fce3 100644
--- a/arch/arm/mach-omap2/mcbsp.c
+++ b/arch/arm/mach-omap2/mcbsp.c
@@ -136,6 +136,7 @@ static struct omap_mcbsp_platform_data 
omap34xx_mcbsp_pdata[] = {
},
{
.phys_base  = OMAP34XX_MCBSP2_BASE,
+   .phys_base_st   = OMAP34XX_MCBSP2_ST_BASE,
.dma_rx_sync= OMAP24XX_DMA_MCBSP2_RX,
.dma_tx_sync= OMAP24XX_DMA_MCBSP2_TX,
.rx_irq = INT_24XX_MCBSP2_IRQ_RX,
@@ -145,6 +146,7 @@ static struct omap_mcbsp_platform_data 
omap34xx_mcbsp_pdata[] = {
},
{
.phys_base  = OMAP34XX_MCBSP3_BASE,
+   .phys_base_st   = OMAP34XX_MCBSP3_ST_BASE,
.dma_rx_sync= OMAP24XX_DMA_MCBSP3_RX,
.dma_tx_sync= OMAP24XX_DMA_MCBSP3_TX,
.rx_irq = INT_24XX_MCBSP3_IRQ_RX,
diff --git a/arch/arm/plat-omap/include/plat/mcbsp.h 
b/arch/arm/plat-omap/include/plat/mcbsp.h
index 4df957b..3974835 100644
--- a/arch/arm/plat-omap/include/plat/mcbsp.h
+++ b/arch/arm/plat-omap/include/plat/mcbsp.h
@@ -49,6 +49,9 @@
 
 #define OMAP34XX_MCBSP1_BASE   0x48074000
 #define OMAP34XX_MCBSP2_BASE   0x49022000
+#define OMAP34XX_MCBSP2_ST_BASE0x49028000
+#define OMAP34XX_MCBSP3_BASE   0x49024000
+#define OMAP34XX_MCBSP3_ST_BASE0x4902A000
 #define OMAP34XX_MCBSP3_BASE   0x49024000
 #define OMAP34XX_MCBSP4_BASE   0x49026000
 #define OMAP34XX_MCBSP5_BASE   0x48096000
@@ -146,6 +149,15 @@
 #define OMAP_MCBSP_REG_WAKEUPEN0xA8
 #define OMAP_MCBSP_REG_XCCR0xAC
 #define OMAP_MCBSP_REG_RCCR0xB0
+#define OMAP_MCBSP_REG_SSELCR  0xBC
+
+#define OMAP_ST_REG_REV0x00
+#define OMAP_ST_REG_SYSCONFIG  0x10
+#define OMAP_ST_REG_IRQSTATUS  0x18
+#define OMAP_ST_REG_IRQENABLE  0x1C
+#define OMAP_ST_REG_SGAINCR0x24
+#define OMAP_ST_REG_SFIRCR 0x28
+#define OMAP_ST_REG_SSELCR 0x2C
 
 #define AUDIO_MCBSP_DATAWRITE  (OMAP24XX_MCBSP2_BASE + OMAP_MCBSP_REG_DXR1)
 #define AUDIO_MCBSP_DATAREAD   (OMAP24XX_MCBSP2_BASE + OMAP_MCBSP_REG_DRR1)
@@ -264,6 +276,24 @@
 #define ENAWAKEUP  0x0004
 #define SOFTRST0x0002
 
+/** McBSP SSELCR bit definitions ***/
+#define SIDETONEEN 0x0400
+
+/** McBSP Sidetone SYSCONFIG bit definitions ***/
+#define ST_AUTOIDLE0x0001
+
+/** McBSP Sidetone SGAINCR bit definitions */
+#define ST_CH1GAIN(value)  ((value16))   /* Bits 16:31 */
+#define ST_CH0GAIN(value)  (value) /* Bits 0:15 */
+
+/** McBSP Sidetone SFIRCR bit definitions **/
+#define ST_FIRCOEFF(value) (value) /* Bits 0:15 */
+
+/** McBSP Sidetone SSELCR bit definitions **/
+#define ST_COEFFWRDONE 0x0004
+#define ST_COEFFWREN   0x0002
+#define ST_SIDETONEEN  0x0001
+
 /** McBSP DMA operating modes **/
 #define MCBSP_DMA_MODE_ELEMENT 0
 #define MCBSP_DMA_MODE_THRESHOLD   1
@@ -374,10 +404,22 @@ struct omap_mcbsp_platform_data {
u16 rx_irq, tx_irq;
struct omap_mcbsp_ops *ops;
 #ifdef CONFIG_ARCH_OMAP3
+   /* Sidetone block for McBSP 2 and 3 */
+   unsigned long phys_base_st;
u16 buffer_size;
 #endif
 };
 
+struct omap_mcbsp_st_data {
+   void __iomem *io_base_st;
+   bool running;
+   bool enabled;
+   s16 taps[128];  /* Sidetone filter coefficients */
+   int nr_taps;/* Number of filter coefficients in use */
+   s16 ch0gain;
+   s16 ch1gain;
+};
+
 struct omap_mcbsp {
struct device *dev;
unsigned long phys_base;
@@ -410,6 +452,7 @@ struct omap_mcbsp {
struct clk *iclk;
struct clk *fclk;
 #ifdef CONFIG_ARCH_OMAP3
+   struct omap_mcbsp_st_data *st_data;
int dma_op_mode;
u16 max_tx_thres;
u16 max_rx_thres;
@@ -459,4 +502,21 @@ int omap_mcbsp_pollread(unsigned int id, u16 * buf);
 int omap_mcbsp_pollwrite(unsigned int id, u16 buf);
 int omap_mcbsp_set_io_type(unsigned int id, omap_mcbsp_io_type_t io_type);
 
+#ifdef CONFIG_ARCH_OMAP3
+/* Sidetone specific API */
+int omap_st_set_chgain(unsigned int id, int channel, s16 chgain);
+int omap_st_get_chgain(unsigned int id, int channel, s16 *chgain);
+int omap_st_enable(unsigned int id);
+int omap_st_disable(unsigned int id);
+int

[PATCHv5 0/2] McBSP: OMAP3: Add sidetone feature

2010-02-22 Thread Ilkka Koskinen
The first patch implements McBSP sidetone feature on OMAP3 while the second
one provides ALSA interface for using it.

The patch set is based on the patch Eduardo Valentin sent to alsa-devel
mailing list in October 2009. Channel gain control and enabling the sidetone
have been moved to ALSA interface as suggested in comments. 

These patches apply on top of Janusz Krzysztofik's McBSP register cache
patches in linux-omap-2.6.git

Since the version 4, ASoC part has been modified to deal with McBSP ids
consistently (zero based indexing).

Eero Nurkkala (1):
  McBSP: OMAP3: Add sidetone feature

Ilkka Koskinen (1):
  ASoC: OMAP-McBSP: ASoC interface for McBSP sidetone

 arch/arm/mach-omap2/mcbsp.c |2 +
 arch/arm/plat-omap/include/plat/mcbsp.h |   60 +
 arch/arm/plat-omap/mcbsp.c  |  402 ++-
 sound/soc/omap/omap-mcbsp.c |  138 +++
 sound/soc/omap/omap-mcbsp.h |2 +
 5 files changed, 603 insertions(+), 1 deletions(-)

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


Re: [PATCHv4 0/2] McBSP: OMAP3: Add sidetone feature

2010-02-19 Thread Ilkka Koskinen



On Thu, 18 Feb 2010, ext Jarkko Nikula wrote:

On Thu, 18 Feb 2010 20:42:27 +0200
Ilkka Koskinen ilkka.koski...@nokia.com wrote:


The first patch implements McBSP sidetone feature on OMAP3 while the second
one provides ALSA interface for using it.

The patch set is based on the patch Eduardo Valentin sent to alsa-devel
mailing list in October 2009. Channel gain control and enabling the sidetone
have been moved to ALSA interface as suggested in comments.

These patches apply on top of Janusz Krzysztofik's McBSP register cache
patches in linux-omap-2.6.git

Since the version 3, the buggy channel gain control has been fixed. ASoC part
have been simplified resulting in removing a couple unnecessary functions.
Added a comment to ASoC part explaining McBSP port number vs. index values
used in OMAP McBSP implementation.


I still have two concern:

1. port number vs. index difference inside driver code is not enough

It's just confusing if a machine driver and internal API (mcbsp.c) has
to use different indexing. See:

omap_mcbsp_st_add_controls(codec, 2);
...
*(unsigned int *)omap3beagle_dai.cpu_dai-private_data = 1; /* McBSP2 */

and mcbsp-id use in mcbsp.c.


Ah, that's what you meant by it. Sure, I'll change it.


2. I cannot change the sidetone level with alsamixer

I think with the previous patch set, it was impossible to set the other 
channel's gain as Peter pointed out. But at least now that I try, i can 
change it with alsamixer.



Is this bug with the alsamixer? With amixer I'm able to set positive
values but not negative

amixer set -D hw:0 'McBSP2 Sidetone Channel 0' 32767


If you try to give negative values, you need to put '--' before the value.

Such as:

# amixer -Dhw:0 -- sset 'McBSP3 Sidetone Channel 0' -1
Simple mixer control 'McBSP3 Sidetone Channel 0',0
  Capabilities: volume volume-joined
  Playback channels: Mono
  Capture channels: Mono
  Limits: -32768 - 32767
  Mono: -1 [35%]



What I'm looking here, is that I can execute a test below with unit
impulse response tap filter, hear the sound and note that the volume is
changing as I'm changing the sidetone volume :-)

arecord -f dat /dev/null |aplay -f dat /dev/zero


As Peter said in the other mail, you need to have the taps also.

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


RE: [PATCHv4 2/2] ASoC: OMAP-McBSP: ASoC interface for McBSP sidetone

2010-02-19 Thread Ilkka Koskinen



On Fri, 19 Feb 2010, Nurkkala Eero.An (EXT-Offcode/Oulu) wrote:




+
+static const struct snd_kcontrol_new omap_mcbsp2_st_controls[] = {
+   SOC_SINGLE_EXT(McBSP2 Sidetone Switch, 1, 0, 1, 0,
+   omap_mcbsp_st_get_mode, omap_mcbsp_st_put_mode),
+   OMAP_MCBSP_SOC_SINGLE_S16_EXT(McBSP2 Sidetone Channel 0 Volume,
+ -32768, 32767,
+ omap_mcbsp2_get_st_ch0_volume,
+ omap_mcbsp2_set_st_ch0_volume),
+   OMAP_MCBSP_SOC_SINGLE_S16_EXT(McBSP2 Sidetone Channel 1 Volume,
+ -32768, 32767,
+ omap_mcbsp2_get_st_ch1_volume,
+ omap_mcbsp2_set_st_ch1_volume),
+};
+
+static const struct snd_kcontrol_new omap_mcbsp3_st_controls[] = {
+   SOC_SINGLE_EXT(McBSP3 Sidetone Switch, 2, 0, 1, 0,
+   omap_mcbsp_st_get_mode, omap_mcbsp_st_put_mode),
+   OMAP_MCBSP_SOC_SINGLE_S16_EXT(McBSP3 Sidetone Channel 0 Volume,
+ -32768, 32767,
+ omap_mcbsp3_get_st_ch0_volume,
+ omap_mcbsp3_set_st_ch0_volume),
+   OMAP_MCBSP_SOC_SINGLE_S16_EXT(McBSP3 Sidetone Channel 1 Volume,
+ -32768, 32767,
+ omap_mcbsp3_get_st_ch1_volume,
+ omap_mcbsp3_set_st_ch1_volume),
+};
+


Just a short note, Gain values are in the interval (-2..2) in Q1.14 
format, negative values are expressed in 2's complement.


So, from:
http://en.wikipedia.org/wiki/Q_(number_format)


The notation used is Qm.n, where:

   * Q designates that the number is in Q format notation — the Texas 
Instruments representation for signed fixed-point numbers.
   * m (optional; default=0) is the number of bits used to designate the 
two's complement integer portion of the number, exclusive of the sign 
bit.
   * n is the number of bits used to designate the two's complement 
fractional portion of the number, i.e. the number of bits to the right 
of the binary point. 


..so if you do tests, and find out the gains behave irrationally 
occasionally, you can't possibly claim it isn't working as expected ;)


I'm a bit confused. What do you mean by that?

AFAICS, Q1.14 defines values [-16384.0, +16383.5], which are mapped in the 
driver to integers [-32768, 32767], right? Moreover, those Q1.14 values in 
registers are mapped to [-2, 2] in HW. So is there a problem somewhere?


Cheers, Ilkka

Re: [PATCHv2 1/2] McBSP: OMAP3: Add sidetone feature

2010-02-18 Thread Ilkka Koskinen


Hi,

On Thu, 18 Feb 2010, ext Tony Lindgren wrote:

* Ilkka Koskinen ilkka.koski...@nokia.com [100217 06:41]:

From: Eero Nurkkala ext-eero.nurkk...@nokia.com

Add sidetone feature to McBSP instances 2 and 3 on OMAP3 based devices.

Signed-off-by: Ilkka Koskinen ilkka.koski...@nokia.com


This one looks good to me and can be merged via Alsa list along with
the other patch.

Acked-by: Tony Lindgren t...@atomide.com


Is that easiest way to do that? I mean, I'm afraid that the ALSA tree 
doesn't have Janusz Krzysztofik's McBSP register cache patches nor does it 
have your omap3: Replace ARCH_OMAP34XX with ARCH_OMAP3 patch either.


Anyway, I'll send the updated patches still today.

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


[PATCHv2 0/2] McBSP: OMAP3: Add sidetone feature

2010-02-18 Thread Ilkka Koskinen
The first patch implements McBSP sidetone feature on OMAP3 while the second one
provides ALSA interface for using it.

The patch set is based on the patch Eduardo Valentin sent to alsa-devel
mailing list in October 2009. Channel gain control and enabling the sidetone
have been moved to ALSA interface as suggested in comments. 

These patches apply on top of Janusz Krzysztofik's McBSP register cache patches
in linux-omap-2.6.git

Since previous review round, I have combined McBSP port specific
omap_mcbsp_st_set_mode() and omap_mcbsp_st_put_mode() functions to
corresponding ones as suggested by Peter Ujfalusi.

Eero Nurkkala (1):
  McBSP: OMAP3: Add sidetone feature

Ilkka Koskinen (1):
  ASoC: OMAP-McBSP: ASoC interface for McBSP sidetone

 arch/arm/mach-omap2/mcbsp.c |2 +
 arch/arm/plat-omap/include/plat/mcbsp.h |   63 +
 arch/arm/plat-omap/mcbsp.c  |  394 ++-
 sound/soc/omap/omap-mcbsp.c |  176 ++
 sound/soc/omap/omap-mcbsp.h |2 +
 5 files changed, 636 insertions(+), 1 deletions(-)

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


[PATCHv3 2/2] ASoC: OMAP-McBSP: ASoC interface for McBSP sidetone

2010-02-18 Thread Ilkka Koskinen
Add ASoC interface for OMAP McBSP2 and McBSP3 sidetones.

Signed-off-by: Ilkka Koskinen ilkka.koski...@nokia.com
---
 sound/soc/omap/omap-mcbsp.c |  157 +++
 sound/soc/omap/omap-mcbsp.h |2 +
 2 files changed, 159 insertions(+), 0 deletions(-)

diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c
index c0039b3..8c26a65 100644
--- a/sound/soc/omap/omap-mcbsp.c
+++ b/sound/soc/omap/omap-mcbsp.c
@@ -39,6 +39,14 @@
 
 #define OMAP_MCBSP_RATES   (SNDRV_PCM_RATE_8000_96000)
 
+#define OMAP_MCBSP_SOC_SINGLE_S16_EXT(xname, xmin, xmax, \
+   xhandler_get, xhandler_put) \
+{  .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
+   .info = omap_mcbsp_st_info_volsw, \
+   .get = xhandler_get, .put = xhandler_put, \
+   .private_value = (unsigned long) (struct soc_mixer_control) \
+   {.min = xmin, .max = xmax} }
+
 struct omap_mcbsp_data {
unsigned intbus_id;
struct omap_mcbsp_reg_cfg   regs;
@@ -637,6 +645,155 @@ struct snd_soc_dai omap_mcbsp_dai[] = {
 
 EXPORT_SYMBOL_GPL(omap_mcbsp_dai);
 
+int omap_mcbsp_st_info_volsw(struct snd_kcontrol *kcontrol,
+   struct snd_ctl_elem_info *uinfo)
+{
+   struct soc_mixer_control *mc =
+   (struct soc_mixer_control *)kcontrol-private_value;
+   int max = mc-max;
+   int min = mc-min;
+
+   uinfo-type = SNDRV_CTL_ELEM_TYPE_INTEGER;
+   uinfo-count = 1;
+   uinfo-value.integer.min = min;
+   uinfo-value.integer.max = max;
+   return 0;
+}
+
+static int omap_mcbsp_set_st_channel_vol(struct snd_kcontrol *kcontrol,
+   struct snd_ctl_elem_value *ucontrol,
+   int id, int channel)
+{
+   struct soc_mixer_control *mc =
+   (struct soc_mixer_control *)kcontrol-private_value;
+   int max = mc-max;
+   int min = mc-min;
+   int val = ucontrol-value.integer.value[0];
+
+   if (val  min || val  max)
+   return -EINVAL;
+
+   return omap_st_set_chgain((id)-1, val, 0, channel);
+}
+
+static int omap_mcbsp_get_st_channel_vol(struct snd_kcontrol *kcontrol,
+   struct snd_ctl_elem_value *ucontrol,
+   int id, int channel)
+{
+   s16 ch0gain, ch1gain;
+
+   if (omap_st_get_chgain((id)-1, ch0gain, ch1gain))
+   return -EAGAIN;
+
+   if (channel == OMAP_MCBSP_ST_CHANNEL_0)
+   ucontrol-value.integer.value[0] = ch0gain;
+   else if (channel == OMAP_MCBSP_ST_CHANNEL_1)
+   ucontrol-value.integer.value[0] = ch1gain;
+
+   return 0;
+}
+
+#define OMAP_MCBSP_ST_SET_CHANNEL_VOLUME(id, channel)  \
+static int \
+omap_mcbsp##id##_set_st_ch##channel##_volume(struct snd_kcontrol *kc,  \
+   struct snd_ctl_elem_value *uc)  \
+{  \
+   return omap_mcbsp_set_st_channel_vol(kc, uc, id,\
+   OMAP_MCBSP_ST_CHANNEL_##channel);   \
+}
+
+#define OMAP_MCBSP_ST_GET_CHANNEL_VOLUME(id, channel)  \
+static int \
+omap_mcbsp##id##_get_st_ch##channel##_volume(struct snd_kcontrol *kc,  \
+   struct snd_ctl_elem_value *uc)  \
+{  \
+   return omap_mcbsp_get_st_channel_vol(kc, uc, id,\
+   OMAP_MCBSP_ST_CHANNEL_##channel);   \
+}
+
+OMAP_MCBSP_ST_SET_CHANNEL_VOLUME(2, 0)
+OMAP_MCBSP_ST_SET_CHANNEL_VOLUME(2, 1)
+OMAP_MCBSP_ST_SET_CHANNEL_VOLUME(3, 0)
+OMAP_MCBSP_ST_SET_CHANNEL_VOLUME(3, 1)
+OMAP_MCBSP_ST_GET_CHANNEL_VOLUME(2, 0)
+OMAP_MCBSP_ST_GET_CHANNEL_VOLUME(2, 1)
+OMAP_MCBSP_ST_GET_CHANNEL_VOLUME(3, 0)
+OMAP_MCBSP_ST_GET_CHANNEL_VOLUME(3, 1)
+
+static int omap_mcbsp_st_put_mode(struct snd_kcontrol *kcontrol,
+   struct snd_ctl_elem_value *ucontrol)
+{
+   struct soc_mixer_control *mc =
+   (struct soc_mixer_control *)kcontrol-private_value;
+   u8 value = ucontrol-value.integer.value[0];
+
+   if (value == omap_st_is_enabled(mc-reg))
+   return 0;
+
+   if (value)
+   omap_st_enable(mc-reg);
+   else
+   omap_st_disable(mc-reg);
+
+   return 1;
+}
+
+static int omap_mcbsp_st_get_mode(struct snd_kcontrol *kcontrol,
+   struct snd_ctl_elem_value *ucontrol)
+{
+   struct soc_mixer_control *mc =
+   (struct soc_mixer_control *)kcontrol-private_value;
+
+   ucontrol-value.integer.value[0] = omap_st_is_enabled(mc-reg);
+   return 0;
+}
+
+static const struct snd_kcontrol_new

[PATCHv3 1/2] McBSP: OMAP3: Add sidetone feature

2010-02-18 Thread Ilkka Koskinen
From: Eero Nurkkala ext-eero.nurkk...@nokia.com

Add sidetone feature to McBSP instances 2 and 3 on OMAP3 based devices.

Signed-off-by: Ilkka Koskinen ilkka.koski...@nokia.com
Acked-by: Tony Lindgren t...@atomide.com
---
 arch/arm/mach-omap2/mcbsp.c |2 +
 arch/arm/plat-omap/include/plat/mcbsp.h |   63 +
 arch/arm/plat-omap/mcbsp.c  |  396 ++-
 3 files changed, 460 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap2/mcbsp.c b/arch/arm/mach-omap2/mcbsp.c
index d601f94..be8fce3 100644
--- a/arch/arm/mach-omap2/mcbsp.c
+++ b/arch/arm/mach-omap2/mcbsp.c
@@ -136,6 +136,7 @@ static struct omap_mcbsp_platform_data 
omap34xx_mcbsp_pdata[] = {
},
{
.phys_base  = OMAP34XX_MCBSP2_BASE,
+   .phys_base_st   = OMAP34XX_MCBSP2_ST_BASE,
.dma_rx_sync= OMAP24XX_DMA_MCBSP2_RX,
.dma_tx_sync= OMAP24XX_DMA_MCBSP2_TX,
.rx_irq = INT_24XX_MCBSP2_IRQ_RX,
@@ -145,6 +146,7 @@ static struct omap_mcbsp_platform_data 
omap34xx_mcbsp_pdata[] = {
},
{
.phys_base  = OMAP34XX_MCBSP3_BASE,
+   .phys_base_st   = OMAP34XX_MCBSP3_ST_BASE,
.dma_rx_sync= OMAP24XX_DMA_MCBSP3_RX,
.dma_tx_sync= OMAP24XX_DMA_MCBSP3_TX,
.rx_irq = INT_24XX_MCBSP3_IRQ_RX,
diff --git a/arch/arm/plat-omap/include/plat/mcbsp.h 
b/arch/arm/plat-omap/include/plat/mcbsp.h
index 4df957b..5db1653 100644
--- a/arch/arm/plat-omap/include/plat/mcbsp.h
+++ b/arch/arm/plat-omap/include/plat/mcbsp.h
@@ -49,6 +49,9 @@
 
 #define OMAP34XX_MCBSP1_BASE   0x48074000
 #define OMAP34XX_MCBSP2_BASE   0x49022000
+#define OMAP34XX_MCBSP2_ST_BASE0x49028000
+#define OMAP34XX_MCBSP3_BASE   0x49024000
+#define OMAP34XX_MCBSP3_ST_BASE0x4902A000
 #define OMAP34XX_MCBSP3_BASE   0x49024000
 #define OMAP34XX_MCBSP4_BASE   0x49026000
 #define OMAP34XX_MCBSP5_BASE   0x48096000
@@ -146,6 +149,15 @@
 #define OMAP_MCBSP_REG_WAKEUPEN0xA8
 #define OMAP_MCBSP_REG_XCCR0xAC
 #define OMAP_MCBSP_REG_RCCR0xB0
+#define OMAP_MCBSP_REG_SSELCR  0xBC
+
+#define OMAP_ST_REG_REV0x00
+#define OMAP_ST_REG_SYSCONFIG  0x10
+#define OMAP_ST_REG_IRQSTATUS  0x18
+#define OMAP_ST_REG_IRQENABLE  0x1C
+#define OMAP_ST_REG_SGAINCR0x24
+#define OMAP_ST_REG_SFIRCR 0x28
+#define OMAP_ST_REG_SSELCR 0x2C
 
 #define AUDIO_MCBSP_DATAWRITE  (OMAP24XX_MCBSP2_BASE + OMAP_MCBSP_REG_DXR1)
 #define AUDIO_MCBSP_DATAREAD   (OMAP24XX_MCBSP2_BASE + OMAP_MCBSP_REG_DRR1)
@@ -264,6 +276,24 @@
 #define ENAWAKEUP  0x0004
 #define SOFTRST0x0002
 
+/** McBSP SSELCR bit definitions ***/
+#define SIDETONEEN 0x0400
+
+/** McBSP Sidetone SYSCONFIG bit definitions ***/
+#define ST_AUTOIDLE0x0001
+
+/** McBSP Sidetone SGAINCR bit definitions */
+#define ST_CH1GAIN(value)  ((value16))   /* Bits 16:31 */
+#define ST_CH0GAIN(value)  (value) /* Bits 0:15 */
+
+/** McBSP Sidetone SFIRCR bit definitions **/
+#define ST_FIRCOEFF(value) (value) /* Bits 0:15 */
+
+/** McBSP Sidetone SSELCR bit definitions **/
+#define ST_COEFFWRDONE 0x0004
+#define ST_COEFFWREN   0x0002
+#define ST_SIDETONEEN  0x0001
+
 /** McBSP DMA operating modes **/
 #define MCBSP_DMA_MODE_ELEMENT 0
 #define MCBSP_DMA_MODE_THRESHOLD   1
@@ -374,10 +404,25 @@ struct omap_mcbsp_platform_data {
u16 rx_irq, tx_irq;
struct omap_mcbsp_ops *ops;
 #ifdef CONFIG_ARCH_OMAP3
+   /* Sidetone block for McBSP 2 and 3 */
+   unsigned long phys_base_st;
u16 buffer_size;
 #endif
 };
 
+#define OMAP_MCBSP_ST_CHANNEL_0 (1  0)
+#define OMAP_MCBSP_ST_CHANNEL_1 (1  1)
+
+struct omap_mcbsp_st_data {
+   void __iomem *io_base_st;
+   bool running;
+   bool enabled;
+   s16 taps[128];  /* Sidetone filter coefficients */
+   int nr_taps;/* Number of filter coefficients in use */
+   s16 ch0gain;
+   s16 ch1gain;
+};
+
 struct omap_mcbsp {
struct device *dev;
unsigned long phys_base;
@@ -410,6 +455,7 @@ struct omap_mcbsp {
struct clk *iclk;
struct clk *fclk;
 #ifdef CONFIG_ARCH_OMAP3
+   struct omap_mcbsp_st_data *st_data;
int dma_op_mode;
u16 max_tx_thres;
u16 max_rx_thres;
@@ -459,4 +505,21 @@ int omap_mcbsp_pollread(unsigned int id, u16 * buf);
 int omap_mcbsp_pollwrite(unsigned int id, u16 buf);
 int omap_mcbsp_set_io_type(unsigned int id, omap_mcbsp_io_type_t io_type);
 
+#ifdef CONFIG_ARCH_OMAP3
+/* Sidetone specific API */
+int omap_st_set_chgain(unsigned int id, s16 ch0gain, s16 ch1gain, int 
channels);
+int

Re: [alsa-devel] [PATCHv3 2/2] ASoC: OMAP-McBSP: ASoC interface for McBSP sidetone

2010-02-18 Thread Ilkka Koskinen



On Thu, 18 Feb 2010, Ujfalusi Peter (Nokia-D/Tampere) wrote:

On Thursday 18 February 2010 14:37:15 Koskinen Ilkka (Nokia-D/Tampere) wrote:

...


+static int omap_mcbsp_set_st_channel_vol(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol,
+ int id, int channel)
+{
+ struct soc_mixer_control *mc =
+ (struct soc_mixer_control *)kcontrol-private_value;
+ int max = mc-max;
+ int min = mc-min;
+ int val = ucontrol-value.integer.value[0];
+
+ if (val  min || val  max)
+ return -EINVAL;
+
+ return omap_st_set_chgain((id)-1, val, 0, channel);


So how do you actually set the ch1 gain to other than 0?

int omap_st_set_chgain(unsigned int id, s16 ch0gain, s16 ch1gain, int channels);

So in any cases you are calling with ch1gain = 0, and depending on the 
selected channel you put that to ch0gain. All in all, with this code you 
are only able to update ch0, and never the ch1.


Damn, it seems that I have messed up my trees :( That's obviously from the 
time I was just experimenting it, and I fixed it some time ago already.



Should than the omap_st_set_chgain have only one parameter for the gain, and the
channel parameter tells the code to which channel to put the gain?


+}
+
+static int omap_mcbsp_get_st_channel_vol(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol,
+ int id, int channel)
+{
+ s16 ch0gain, ch1gain;
+
+ if (omap_st_get_chgain((id)-1, ch0gain, ch1gain))
+ return -EAGAIN;


Than probably the omap_st_get_chgain should only retrieve the gain for one
channel also?


Yes, indeed.


Sorry for the confusion. I'll send the fixed patches soon.

Cheers, Ilkka


+
+ if (channel == OMAP_MCBSP_ST_CHANNEL_0)
+ ucontrol-value.integer.value[0] = ch0gain;
+ else if (channel == OMAP_MCBSP_ST_CHANNEL_1)
+ ucontrol-value.integer.value[0] = ch1gain;
+
+ return 0;
+}
+


--
Péter
___
Alsa-devel mailing list
alsa-de...@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel


[PATCHv4 1/2] McBSP: OMAP3: Add sidetone feature

2010-02-18 Thread Ilkka Koskinen
From: Eero Nurkkala ext-eero.nurkk...@nokia.com

Add sidetone feature to McBSP instances 2 and 3 on OMAP3 based devices.

Signed-off-by: Ilkka Koskinen ilkka.koski...@nokia.com
---
 arch/arm/mach-omap2/mcbsp.c |2 +
 arch/arm/plat-omap/include/plat/mcbsp.h |   60 +
 arch/arm/plat-omap/mcbsp.c  |  402 ++-
 3 files changed, 463 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap2/mcbsp.c b/arch/arm/mach-omap2/mcbsp.c
index d601f94..be8fce3 100644
--- a/arch/arm/mach-omap2/mcbsp.c
+++ b/arch/arm/mach-omap2/mcbsp.c
@@ -136,6 +136,7 @@ static struct omap_mcbsp_platform_data 
omap34xx_mcbsp_pdata[] = {
},
{
.phys_base  = OMAP34XX_MCBSP2_BASE,
+   .phys_base_st   = OMAP34XX_MCBSP2_ST_BASE,
.dma_rx_sync= OMAP24XX_DMA_MCBSP2_RX,
.dma_tx_sync= OMAP24XX_DMA_MCBSP2_TX,
.rx_irq = INT_24XX_MCBSP2_IRQ_RX,
@@ -145,6 +146,7 @@ static struct omap_mcbsp_platform_data 
omap34xx_mcbsp_pdata[] = {
},
{
.phys_base  = OMAP34XX_MCBSP3_BASE,
+   .phys_base_st   = OMAP34XX_MCBSP3_ST_BASE,
.dma_rx_sync= OMAP24XX_DMA_MCBSP3_RX,
.dma_tx_sync= OMAP24XX_DMA_MCBSP3_TX,
.rx_irq = INT_24XX_MCBSP3_IRQ_RX,
diff --git a/arch/arm/plat-omap/include/plat/mcbsp.h 
b/arch/arm/plat-omap/include/plat/mcbsp.h
index 4df957b..3974835 100644
--- a/arch/arm/plat-omap/include/plat/mcbsp.h
+++ b/arch/arm/plat-omap/include/plat/mcbsp.h
@@ -49,6 +49,9 @@
 
 #define OMAP34XX_MCBSP1_BASE   0x48074000
 #define OMAP34XX_MCBSP2_BASE   0x49022000
+#define OMAP34XX_MCBSP2_ST_BASE0x49028000
+#define OMAP34XX_MCBSP3_BASE   0x49024000
+#define OMAP34XX_MCBSP3_ST_BASE0x4902A000
 #define OMAP34XX_MCBSP3_BASE   0x49024000
 #define OMAP34XX_MCBSP4_BASE   0x49026000
 #define OMAP34XX_MCBSP5_BASE   0x48096000
@@ -146,6 +149,15 @@
 #define OMAP_MCBSP_REG_WAKEUPEN0xA8
 #define OMAP_MCBSP_REG_XCCR0xAC
 #define OMAP_MCBSP_REG_RCCR0xB0
+#define OMAP_MCBSP_REG_SSELCR  0xBC
+
+#define OMAP_ST_REG_REV0x00
+#define OMAP_ST_REG_SYSCONFIG  0x10
+#define OMAP_ST_REG_IRQSTATUS  0x18
+#define OMAP_ST_REG_IRQENABLE  0x1C
+#define OMAP_ST_REG_SGAINCR0x24
+#define OMAP_ST_REG_SFIRCR 0x28
+#define OMAP_ST_REG_SSELCR 0x2C
 
 #define AUDIO_MCBSP_DATAWRITE  (OMAP24XX_MCBSP2_BASE + OMAP_MCBSP_REG_DXR1)
 #define AUDIO_MCBSP_DATAREAD   (OMAP24XX_MCBSP2_BASE + OMAP_MCBSP_REG_DRR1)
@@ -264,6 +276,24 @@
 #define ENAWAKEUP  0x0004
 #define SOFTRST0x0002
 
+/** McBSP SSELCR bit definitions ***/
+#define SIDETONEEN 0x0400
+
+/** McBSP Sidetone SYSCONFIG bit definitions ***/
+#define ST_AUTOIDLE0x0001
+
+/** McBSP Sidetone SGAINCR bit definitions */
+#define ST_CH1GAIN(value)  ((value16))   /* Bits 16:31 */
+#define ST_CH0GAIN(value)  (value) /* Bits 0:15 */
+
+/** McBSP Sidetone SFIRCR bit definitions **/
+#define ST_FIRCOEFF(value) (value) /* Bits 0:15 */
+
+/** McBSP Sidetone SSELCR bit definitions **/
+#define ST_COEFFWRDONE 0x0004
+#define ST_COEFFWREN   0x0002
+#define ST_SIDETONEEN  0x0001
+
 /** McBSP DMA operating modes **/
 #define MCBSP_DMA_MODE_ELEMENT 0
 #define MCBSP_DMA_MODE_THRESHOLD   1
@@ -374,10 +404,22 @@ struct omap_mcbsp_platform_data {
u16 rx_irq, tx_irq;
struct omap_mcbsp_ops *ops;
 #ifdef CONFIG_ARCH_OMAP3
+   /* Sidetone block for McBSP 2 and 3 */
+   unsigned long phys_base_st;
u16 buffer_size;
 #endif
 };
 
+struct omap_mcbsp_st_data {
+   void __iomem *io_base_st;
+   bool running;
+   bool enabled;
+   s16 taps[128];  /* Sidetone filter coefficients */
+   int nr_taps;/* Number of filter coefficients in use */
+   s16 ch0gain;
+   s16 ch1gain;
+};
+
 struct omap_mcbsp {
struct device *dev;
unsigned long phys_base;
@@ -410,6 +452,7 @@ struct omap_mcbsp {
struct clk *iclk;
struct clk *fclk;
 #ifdef CONFIG_ARCH_OMAP3
+   struct omap_mcbsp_st_data *st_data;
int dma_op_mode;
u16 max_tx_thres;
u16 max_rx_thres;
@@ -459,4 +502,21 @@ int omap_mcbsp_pollread(unsigned int id, u16 * buf);
 int omap_mcbsp_pollwrite(unsigned int id, u16 buf);
 int omap_mcbsp_set_io_type(unsigned int id, omap_mcbsp_io_type_t io_type);
 
+#ifdef CONFIG_ARCH_OMAP3
+/* Sidetone specific API */
+int omap_st_set_chgain(unsigned int id, int channel, s16 chgain);
+int omap_st_get_chgain(unsigned int id, int channel, s16 *chgain);
+int omap_st_enable(unsigned int id);
+int omap_st_disable(unsigned int id);
+int

[PATCHv4 0/2] McBSP: OMAP3: Add sidetone feature

2010-02-18 Thread Ilkka Koskinen
The first patch implements McBSP sidetone feature on OMAP3 while the second
one provides ALSA interface for using it.

The patch set is based on the patch Eduardo Valentin sent to alsa-devel
mailing list in October 2009. Channel gain control and enabling the sidetone
have been moved to ALSA interface as suggested in comments. 

These patches apply on top of Janusz Krzysztofik's McBSP register cache
patches in linux-omap-2.6.git

Since the version 3, the buggy channel gain control has been fixed. ASoC part 
have been simplified resulting in removing a couple unnecessary functions.
Added a comment to ASoC part explaining McBSP port number vs. index values
used in OMAP McBSP implementation.

Eero Nurkkala (1):
  McBSP: OMAP3: Add sidetone feature

Ilkka Koskinen (1):
  ASoC: OMAP-McBSP: ASoC interface for McBSP sidetone

 arch/arm/mach-omap2/mcbsp.c |2 +
 arch/arm/plat-omap/include/plat/mcbsp.h |   60 +
 arch/arm/plat-omap/mcbsp.c  |  402 ++-
 sound/soc/omap/omap-mcbsp.c |  138 +++
 sound/soc/omap/omap-mcbsp.h |2 +
 5 files changed, 603 insertions(+), 1 deletions(-)

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


[PATCHv4 2/2] ASoC: OMAP-McBSP: ASoC interface for McBSP sidetone

2010-02-18 Thread Ilkka Koskinen
Add ASoC interface for OMAP McBSP2 and McBSP3 sidetones.

Signed-off-by: Ilkka Koskinen ilkka.koski...@nokia.com
---
 sound/soc/omap/omap-mcbsp.c |  138 +++
 sound/soc/omap/omap-mcbsp.h |2 +
 2 files changed, 140 insertions(+), 0 deletions(-)

diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c
index c0039b3..503c58d 100644
--- a/sound/soc/omap/omap-mcbsp.c
+++ b/sound/soc/omap/omap-mcbsp.c
@@ -39,6 +39,14 @@
 
 #define OMAP_MCBSP_RATES   (SNDRV_PCM_RATE_8000_96000)
 
+#define OMAP_MCBSP_SOC_SINGLE_S16_EXT(xname, xmin, xmax, \
+   xhandler_get, xhandler_put) \
+{  .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
+   .info = omap_mcbsp_st_info_volsw, \
+   .get = xhandler_get, .put = xhandler_put, \
+   .private_value = (unsigned long) (struct soc_mixer_control) \
+   {.min = xmin, .max = xmax} }
+
 struct omap_mcbsp_data {
unsigned intbus_id;
struct omap_mcbsp_reg_cfg   regs;
@@ -637,6 +645,136 @@ struct snd_soc_dai omap_mcbsp_dai[] = {
 
 EXPORT_SYMBOL_GPL(omap_mcbsp_dai);
 
+int omap_mcbsp_st_info_volsw(struct snd_kcontrol *kcontrol,
+   struct snd_ctl_elem_info *uinfo)
+{
+   struct soc_mixer_control *mc =
+   (struct soc_mixer_control *)kcontrol-private_value;
+   int max = mc-max;
+   int min = mc-min;
+
+   uinfo-type = SNDRV_CTL_ELEM_TYPE_INTEGER;
+   uinfo-count = 1;
+   uinfo-value.integer.min = min;
+   uinfo-value.integer.max = max;
+   return 0;
+}
+
+#define OMAP_MCBSP_ST_SET_CHANNEL_VOLUME(id, channel)  \
+static int \
+omap_mcbsp##id##_set_st_ch##channel##_volume(struct snd_kcontrol *kc,  \
+   struct snd_ctl_elem_value *uc)  \
+{  \
+   struct soc_mixer_control *mc =  \
+   (struct soc_mixer_control *)kc-private_value;  \
+   int max = mc-max;  \
+   int min = mc-min;  \
+   int val = uc-value.integer.value[0];   \
+   \
+   if (val  min || val  max) \
+   return -EINVAL; \
+   \
+   /* OMAP McBSP implementation uses index values 0..4 */  \
+   return omap_st_set_chgain((id)-1, channel, val);\
+}
+
+#define OMAP_MCBSP_ST_GET_CHANNEL_VOLUME(id, channel)  \
+static int \
+omap_mcbsp##id##_get_st_ch##channel##_volume(struct snd_kcontrol *kc,  \
+   struct snd_ctl_elem_value *uc)  \
+{  \
+   s16 chgain; \
+   \
+   if (omap_st_get_chgain((id)-1, channel, chgain))   \
+   return -EAGAIN; \
+   \
+   uc-value.integer.value[0] = chgain;\
+   return 0;   \
+}
+
+OMAP_MCBSP_ST_SET_CHANNEL_VOLUME(2, 0)
+OMAP_MCBSP_ST_SET_CHANNEL_VOLUME(2, 1)
+OMAP_MCBSP_ST_SET_CHANNEL_VOLUME(3, 0)
+OMAP_MCBSP_ST_SET_CHANNEL_VOLUME(3, 1)
+OMAP_MCBSP_ST_GET_CHANNEL_VOLUME(2, 0)
+OMAP_MCBSP_ST_GET_CHANNEL_VOLUME(2, 1)
+OMAP_MCBSP_ST_GET_CHANNEL_VOLUME(3, 0)
+OMAP_MCBSP_ST_GET_CHANNEL_VOLUME(3, 1)
+
+static int omap_mcbsp_st_put_mode(struct snd_kcontrol *kcontrol,
+   struct snd_ctl_elem_value *ucontrol)
+{
+   struct soc_mixer_control *mc =
+   (struct soc_mixer_control *)kcontrol-private_value;
+   u8 value = ucontrol-value.integer.value[0];
+
+   if (value == omap_st_is_enabled(mc-reg))
+   return 0;
+
+   if (value)
+   omap_st_enable(mc-reg);
+   else
+   omap_st_disable(mc-reg);
+
+   return 1;
+}
+
+static int omap_mcbsp_st_get_mode(struct snd_kcontrol *kcontrol,
+   struct snd_ctl_elem_value *ucontrol)
+{
+   struct soc_mixer_control *mc =
+   (struct soc_mixer_control *)kcontrol-private_value;
+
+   ucontrol-value.integer.value[0] = omap_st_is_enabled(mc-reg);
+   return 0;
+}
+
+static const struct snd_kcontrol_new omap_mcbsp2_st_controls[] = {
+   SOC_SINGLE_EXT(McBSP2 Sidetone Switch, 1, 0, 1, 0

[PATCHv2 1/2] McBSP: OMAP3: Add sidetone feature

2010-02-17 Thread Ilkka Koskinen
From: Eero Nurkkala ext-eero.nurkk...@nokia.com

Add sidetone feature to McBSP instances 2 and 3 on OMAP3 based devices.

Signed-off-by: Ilkka Koskinen ilkka.koski...@nokia.com
---
 arch/arm/mach-omap2/mcbsp.c |2 +
 arch/arm/plat-omap/include/plat/mcbsp.h |   63 +
 arch/arm/plat-omap/mcbsp.c  |  396 ++-
 3 files changed, 460 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap2/mcbsp.c b/arch/arm/mach-omap2/mcbsp.c
index d601f94..be8fce3 100644
--- a/arch/arm/mach-omap2/mcbsp.c
+++ b/arch/arm/mach-omap2/mcbsp.c
@@ -136,6 +136,7 @@ static struct omap_mcbsp_platform_data 
omap34xx_mcbsp_pdata[] = {
},
{
.phys_base  = OMAP34XX_MCBSP2_BASE,
+   .phys_base_st   = OMAP34XX_MCBSP2_ST_BASE,
.dma_rx_sync= OMAP24XX_DMA_MCBSP2_RX,
.dma_tx_sync= OMAP24XX_DMA_MCBSP2_TX,
.rx_irq = INT_24XX_MCBSP2_IRQ_RX,
@@ -145,6 +146,7 @@ static struct omap_mcbsp_platform_data 
omap34xx_mcbsp_pdata[] = {
},
{
.phys_base  = OMAP34XX_MCBSP3_BASE,
+   .phys_base_st   = OMAP34XX_MCBSP3_ST_BASE,
.dma_rx_sync= OMAP24XX_DMA_MCBSP3_RX,
.dma_tx_sync= OMAP24XX_DMA_MCBSP3_TX,
.rx_irq = INT_24XX_MCBSP3_IRQ_RX,
diff --git a/arch/arm/plat-omap/include/plat/mcbsp.h 
b/arch/arm/plat-omap/include/plat/mcbsp.h
index 4df957b..5db1653 100644
--- a/arch/arm/plat-omap/include/plat/mcbsp.h
+++ b/arch/arm/plat-omap/include/plat/mcbsp.h
@@ -49,6 +49,9 @@
 
 #define OMAP34XX_MCBSP1_BASE   0x48074000
 #define OMAP34XX_MCBSP2_BASE   0x49022000
+#define OMAP34XX_MCBSP2_ST_BASE0x49028000
+#define OMAP34XX_MCBSP3_BASE   0x49024000
+#define OMAP34XX_MCBSP3_ST_BASE0x4902A000
 #define OMAP34XX_MCBSP3_BASE   0x49024000
 #define OMAP34XX_MCBSP4_BASE   0x49026000
 #define OMAP34XX_MCBSP5_BASE   0x48096000
@@ -146,6 +149,15 @@
 #define OMAP_MCBSP_REG_WAKEUPEN0xA8
 #define OMAP_MCBSP_REG_XCCR0xAC
 #define OMAP_MCBSP_REG_RCCR0xB0
+#define OMAP_MCBSP_REG_SSELCR  0xBC
+
+#define OMAP_ST_REG_REV0x00
+#define OMAP_ST_REG_SYSCONFIG  0x10
+#define OMAP_ST_REG_IRQSTATUS  0x18
+#define OMAP_ST_REG_IRQENABLE  0x1C
+#define OMAP_ST_REG_SGAINCR0x24
+#define OMAP_ST_REG_SFIRCR 0x28
+#define OMAP_ST_REG_SSELCR 0x2C
 
 #define AUDIO_MCBSP_DATAWRITE  (OMAP24XX_MCBSP2_BASE + OMAP_MCBSP_REG_DXR1)
 #define AUDIO_MCBSP_DATAREAD   (OMAP24XX_MCBSP2_BASE + OMAP_MCBSP_REG_DRR1)
@@ -264,6 +276,24 @@
 #define ENAWAKEUP  0x0004
 #define SOFTRST0x0002
 
+/** McBSP SSELCR bit definitions ***/
+#define SIDETONEEN 0x0400
+
+/** McBSP Sidetone SYSCONFIG bit definitions ***/
+#define ST_AUTOIDLE0x0001
+
+/** McBSP Sidetone SGAINCR bit definitions */
+#define ST_CH1GAIN(value)  ((value16))   /* Bits 16:31 */
+#define ST_CH0GAIN(value)  (value) /* Bits 0:15 */
+
+/** McBSP Sidetone SFIRCR bit definitions **/
+#define ST_FIRCOEFF(value) (value) /* Bits 0:15 */
+
+/** McBSP Sidetone SSELCR bit definitions **/
+#define ST_COEFFWRDONE 0x0004
+#define ST_COEFFWREN   0x0002
+#define ST_SIDETONEEN  0x0001
+
 /** McBSP DMA operating modes **/
 #define MCBSP_DMA_MODE_ELEMENT 0
 #define MCBSP_DMA_MODE_THRESHOLD   1
@@ -374,10 +404,25 @@ struct omap_mcbsp_platform_data {
u16 rx_irq, tx_irq;
struct omap_mcbsp_ops *ops;
 #ifdef CONFIG_ARCH_OMAP3
+   /* Sidetone block for McBSP 2 and 3 */
+   unsigned long phys_base_st;
u16 buffer_size;
 #endif
 };
 
+#define OMAP_MCBSP_ST_CHANNEL_0 (1  0)
+#define OMAP_MCBSP_ST_CHANNEL_1 (1  1)
+
+struct omap_mcbsp_st_data {
+   void __iomem *io_base_st;
+   bool running;
+   bool enabled;
+   s16 taps[128];  /* Sidetone filter coefficients */
+   int nr_taps;/* Number of filter coefficients in use */
+   s16 ch0gain;
+   s16 ch1gain;
+};
+
 struct omap_mcbsp {
struct device *dev;
unsigned long phys_base;
@@ -410,6 +455,7 @@ struct omap_mcbsp {
struct clk *iclk;
struct clk *fclk;
 #ifdef CONFIG_ARCH_OMAP3
+   struct omap_mcbsp_st_data *st_data;
int dma_op_mode;
u16 max_tx_thres;
u16 max_rx_thres;
@@ -459,4 +505,21 @@ int omap_mcbsp_pollread(unsigned int id, u16 * buf);
 int omap_mcbsp_pollwrite(unsigned int id, u16 buf);
 int omap_mcbsp_set_io_type(unsigned int id, omap_mcbsp_io_type_t io_type);
 
+#ifdef CONFIG_ARCH_OMAP3
+/* Sidetone specific API */
+int omap_st_set_chgain(unsigned int id, s16 ch0gain, s16 ch1gain, int 
channels);
+int omap_st_get_chgain(unsigned int id, s16 *ch0gain, s16

Re: [PATCH 0/2] McBSP: OMAP3: Add sidetone feature

2010-01-29 Thread Ilkka Koskinen


Hi,

On Thu, 28 Jan 2010, ext Jarkko Nikula wrote:


On Thu, 28 Jan 2010 17:46:25 +0200
Ilkka Koskinen ilkka.koski...@nokia.com wrote:


The first patch implements McBSP sidetone feature on OMAP3 while the second one
provides ALSA interface for using it.

The patch set is based on the patch Eduardo Valentin sent to alsa-devel
mailing list in October 2009. Channel gain control and enabling the sidetone
have been moved to ALSA interface as suggested in comments.

Eero Nurkkala (1):
  McBSP: OMAP3: Add sidetone feature

Ilkka Koskinen (1):
  ASoC: OMAP-McBSP: ASoC interface for McBSP sidetone

 arch/arm/mach-omap2/mcbsp.c |2 +
 arch/arm/plat-omap/include/plat/mcbsp.h |   63 +
 arch/arm/plat-omap/mcbsp.c  |  402 ++-
 sound/soc/omap/omap-mcbsp.c |  187 ++
 sound/soc/omap/omap-mcbsp.h |2 +
 5 files changed, 655 insertions(+), 1 deletions(-)


For me the separation between arch/arm/plat-omap/mcbsp.c and
sound/soc/omap/omap-mcbsp.c and board specific control registration
function omap_mcbsp_st_add_controls looks ok.

Set applies well on top of vanilla but the patch 1 doesn't apply on
linux-omap due commit bcbb73c6fe8544bb50cddb8b5df0e2fcbb08b4b0.


I guess that's the case, since I just tested the patches on top 
linux-omap-2.6 master and sound tree...



I was thinking that it makes sense to base the patch 1 on top of McBSP
register cache patches from Janusz Krzysztofik after Tony applies
them (+ having cache for ST regs). That avoid conflicts in mainline
and makes the sidetone also ready for McBSP context save/restore
functionality.


I'm ok with that. So would you suggest me to prepare the cache patch for 
ST registers? If so, would it be possible to make it as follow-up patch?


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


[PATCH 0/2] McBSP: OMAP3: Add sidetone feature

2010-01-28 Thread Ilkka Koskinen
The first patch implements McBSP sidetone feature on OMAP3 while the second one
provides ALSA interface for using it.

The patch set is based on the patch Eduardo Valentin sent to alsa-devel
mailing list in October 2009. Channel gain control and enabling the sidetone
have been moved to ALSA interface as suggested in comments. 

Eero Nurkkala (1):
  McBSP: OMAP3: Add sidetone feature

Ilkka Koskinen (1):
  ASoC: OMAP-McBSP: ASoC interface for McBSP sidetone

 arch/arm/mach-omap2/mcbsp.c |2 +
 arch/arm/plat-omap/include/plat/mcbsp.h |   63 +
 arch/arm/plat-omap/mcbsp.c  |  402 ++-
 sound/soc/omap/omap-mcbsp.c |  187 ++
 sound/soc/omap/omap-mcbsp.h |2 +
 5 files changed, 655 insertions(+), 1 deletions(-)

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


[PATCH 1/2] McBSP: OMAP3: Add sidetone feature

2010-01-28 Thread Ilkka Koskinen
From: Eero Nurkkala ext-eero.nurkk...@nokia.com

Add sidetone feature to McBSP instances 2 and 3 on OMAP3 based devices.

Signed-off-by: Ilkka Koskinen ilkka.koski...@nokia.com
---
 arch/arm/mach-omap2/mcbsp.c |2 +
 arch/arm/plat-omap/include/plat/mcbsp.h |   63 +
 arch/arm/plat-omap/mcbsp.c  |  402 ++-
 3 files changed, 466 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap2/mcbsp.c b/arch/arm/mach-omap2/mcbsp.c
index baa4517..b6dbd65 100644
--- a/arch/arm/mach-omap2/mcbsp.c
+++ b/arch/arm/mach-omap2/mcbsp.c
@@ -132,6 +132,7 @@ static struct omap_mcbsp_platform_data 
omap34xx_mcbsp_pdata[] = {
},
{
.phys_base  = OMAP34XX_MCBSP2_BASE,
+   .phys_base_st   = OMAP34XX_MCBSP2_ST_BASE,
.dma_rx_sync= OMAP24XX_DMA_MCBSP2_RX,
.dma_tx_sync= OMAP24XX_DMA_MCBSP2_TX,
.rx_irq = INT_24XX_MCBSP2_IRQ_RX,
@@ -141,6 +142,7 @@ static struct omap_mcbsp_platform_data 
omap34xx_mcbsp_pdata[] = {
},
{
.phys_base  = OMAP34XX_MCBSP3_BASE,
+   .phys_base_st   = OMAP34XX_MCBSP3_ST_BASE,
.dma_rx_sync= OMAP24XX_DMA_MCBSP3_RX,
.dma_tx_sync= OMAP24XX_DMA_MCBSP3_TX,
.rx_irq = INT_24XX_MCBSP3_IRQ_RX,
diff --git a/arch/arm/plat-omap/include/plat/mcbsp.h 
b/arch/arm/plat-omap/include/plat/mcbsp.h
index 4f22e5b..563484a 100644
--- a/arch/arm/plat-omap/include/plat/mcbsp.h
+++ b/arch/arm/plat-omap/include/plat/mcbsp.h
@@ -49,6 +49,9 @@
 
 #define OMAP34XX_MCBSP1_BASE   0x48074000
 #define OMAP34XX_MCBSP2_BASE   0x49022000
+#define OMAP34XX_MCBSP2_ST_BASE0x49028000
+#define OMAP34XX_MCBSP3_BASE   0x49024000
+#define OMAP34XX_MCBSP3_ST_BASE0x4902A000
 #define OMAP34XX_MCBSP3_BASE   0x49024000
 #define OMAP34XX_MCBSP4_BASE   0x49026000
 #define OMAP34XX_MCBSP5_BASE   0x48096000
@@ -147,6 +150,15 @@
 #define OMAP_MCBSP_REG_WAKEUPEN0xA8
 #define OMAP_MCBSP_REG_XCCR0xAC
 #define OMAP_MCBSP_REG_RCCR0xB0
+#define OMAP_MCBSP_REG_SSELCR  0xBC
+
+#define OMAP_ST_REG_REV0x00
+#define OMAP_ST_REG_SYSCONFIG  0x10
+#define OMAP_ST_REG_IRQSTATUS  0x18
+#define OMAP_ST_REG_IRQENABLE  0x1C
+#define OMAP_ST_REG_SGAINCR0x24
+#define OMAP_ST_REG_SFIRCR 0x28
+#define OMAP_ST_REG_SSELCR 0x2C
 
 #define AUDIO_MCBSP_DATAWRITE  (OMAP24XX_MCBSP2_BASE + OMAP_MCBSP_REG_DXR1)
 #define AUDIO_MCBSP_DATAREAD   (OMAP24XX_MCBSP2_BASE + OMAP_MCBSP_REG_DRR1)
@@ -265,6 +277,24 @@
 #define ENAWAKEUP  0x0004
 #define SOFTRST0x0002
 
+/** McBSP SSELCR bit definitions ***/
+#define SIDETONEEN 0x0400
+
+/** McBSP Sidetone SYSCONFIG bit definitions ***/
+#define ST_AUTOIDLE0x0001
+
+/** McBSP Sidetone SGAINCR bit definitions */
+#define ST_CH1GAIN(value)  ((value16))   /* Bits 16:31 */
+#define ST_CH0GAIN(value)  (value) /* Bits 0:15 */
+
+/** McBSP Sidetone SFIRCR bit definitions **/
+#define ST_FIRCOEFF(value) (value) /* Bits 0:15 */
+
+/** McBSP Sidetone SSELCR bit definitions **/
+#define ST_COEFFWRDONE 0x0004
+#define ST_COEFFWREN   0x0002
+#define ST_SIDETONEEN  0x0001
+
 /** McBSP DMA operating modes **/
 #define MCBSP_DMA_MODE_ELEMENT 0
 #define MCBSP_DMA_MODE_THRESHOLD   1
@@ -375,10 +405,25 @@ struct omap_mcbsp_platform_data {
u16 rx_irq, tx_irq;
struct omap_mcbsp_ops *ops;
 #ifdef CONFIG_ARCH_OMAP34XX
+   /* Sidetone block for McBSP 2 and 3 */
+   unsigned long phys_base_st;
u16 buffer_size;
 #endif
 };
 
+#define OMAP_MCBSP_ST_CHANNEL_0 (1  0)
+#define OMAP_MCBSP_ST_CHANNEL_1 (1  1)
+
+struct omap_mcbsp_st_data {
+   void __iomem *io_base_st;
+   bool running;
+   bool enabled;
+   s16 taps[128];  /* Sidetone filter coefficients */
+   int nr_taps;/* Number of filter coefficients in use */
+   s16 ch0gain;
+   s16 ch1gain;
+};
+
 struct omap_mcbsp {
struct device *dev;
unsigned long phys_base;
@@ -411,6 +456,7 @@ struct omap_mcbsp {
struct clk *iclk;
struct clk *fclk;
 #ifdef CONFIG_ARCH_OMAP34XX
+   struct omap_mcbsp_st_data *st_data;
int dma_op_mode;
u16 max_tx_thres;
u16 max_rx_thres;
@@ -459,4 +505,21 @@ int omap_mcbsp_pollread(unsigned int id, u16 * buf);
 int omap_mcbsp_pollwrite(unsigned int id, u16 buf);
 int omap_mcbsp_set_io_type(unsigned int id, omap_mcbsp_io_type_t io_type);
 
+#ifdef CONFIG_ARCH_OMAP34XX
+/* Sidetone specific API */
+int omap_st_set_chgain(unsigned int id, s16 ch0gain, s16 ch1gain, int 
channels);
+int omap_st_get_chgain(unsigned int id, s16

[PATCH 2/2] ASoC: OMAP-McBSP: ASoC interface for McBSP sidetone

2010-01-28 Thread Ilkka Koskinen
Add ASoC interface for OMAP McBSP2 and McBSP3 sidetones.

Signed-off-by: Ilkka Koskinen ilkka.koski...@nokia.com
---
 sound/soc/omap/omap-mcbsp.c |  187 +++
 sound/soc/omap/omap-mcbsp.h |2 +
 2 files changed, 189 insertions(+), 0 deletions(-)

diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c
index 6bbbd2a..295620b 100644
--- a/sound/soc/omap/omap-mcbsp.c
+++ b/sound/soc/omap/omap-mcbsp.c
@@ -39,6 +39,14 @@
 
 #define OMAP_MCBSP_RATES   (SNDRV_PCM_RATE_8000_96000)
 
+#define OMAP_MCBSP_SOC_SINGLE_S16_EXT(xname, xmin, xmax, \
+   xhandler_get, xhandler_put) \
+{  .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
+   .info = omap_mcbsp_st_info_volsw, \
+   .get = xhandler_get, .put = xhandler_put, \
+   .private_value = (unsigned long) (struct soc_mixer_control) \
+   {.min = xmin, .max = xmax} }
+
 struct omap_mcbsp_data {
unsigned intbus_id;
struct omap_mcbsp_reg_cfg   regs;
@@ -637,6 +645,185 @@ struct snd_soc_dai omap_mcbsp_dai[] = {
 
 EXPORT_SYMBOL_GPL(omap_mcbsp_dai);
 
+int omap_mcbsp_st_info_volsw(struct snd_kcontrol *kcontrol,
+   struct snd_ctl_elem_info *uinfo)
+{
+   struct soc_mixer_control *mc =
+   (struct soc_mixer_control *)kcontrol-private_value;
+   int max = mc-max;
+   int min = mc-min;
+
+   uinfo-type = SNDRV_CTL_ELEM_TYPE_INTEGER;
+   uinfo-count = 1;
+   uinfo-value.integer.min = min;
+   uinfo-value.integer.max = max;
+   return 0;
+}
+
+static int omap_mcbsp_set_st_channel_vol(struct snd_kcontrol *kcontrol,
+   struct snd_ctl_elem_value *ucontrol,
+   int id, int channel)
+{
+   struct soc_mixer_control *mc =
+   (struct soc_mixer_control *)kcontrol-private_value;
+   int max = mc-max;
+   int min = mc-min;
+   int val = ucontrol-value.integer.value[0];
+
+   if (val  min || val  max)
+   return -EINVAL;
+
+   return omap_st_set_chgain((id)-1, val, 0, channel);
+}
+
+static int omap_mcbsp_get_st_channel_vol(struct snd_kcontrol *kcontrol,
+   struct snd_ctl_elem_value *ucontrol,
+   int id, int channel)
+{
+   s16 ch0gain, ch1gain;
+
+   if (omap_st_get_chgain((id)-1, ch0gain, ch1gain))
+   return -EAGAIN;
+
+   if (channel == OMAP_MCBSP_ST_CHANNEL_0)
+   ucontrol-value.integer.value[0] = ch0gain;
+   else if (channel == OMAP_MCBSP_ST_CHANNEL_1)
+   ucontrol-value.integer.value[0] = ch1gain;
+
+   return 0;
+}
+
+#define OMAP_MCBSP_ST_SET_CHANNEL_VOLUME(id, channel)  \
+static int \
+omap_mcbsp##id##_set_st_ch##channel##_volume(struct snd_kcontrol *kc,  \
+   struct snd_ctl_elem_value *uc)  \
+{  \
+   return omap_mcbsp_set_st_channel_vol(kc, uc, id,\
+   OMAP_MCBSP_ST_CHANNEL_##channel);   \
+}
+
+#define OMAP_MCBSP_ST_GET_CHANNEL_VOLUME(id, channel)  \
+static int \
+omap_mcbsp##id##_get_st_ch##channel##_volume(struct snd_kcontrol *kc,  \
+   struct snd_ctl_elem_value *uc)  \
+{  \
+   return omap_mcbsp_get_st_channel_vol(kc, uc, id,\
+   OMAP_MCBSP_ST_CHANNEL_##channel);   \
+}
+
+OMAP_MCBSP_ST_SET_CHANNEL_VOLUME(2, 0)
+OMAP_MCBSP_ST_SET_CHANNEL_VOLUME(2, 1)
+OMAP_MCBSP_ST_SET_CHANNEL_VOLUME(3, 0)
+OMAP_MCBSP_ST_SET_CHANNEL_VOLUME(3, 1)
+OMAP_MCBSP_ST_GET_CHANNEL_VOLUME(2, 0)
+OMAP_MCBSP_ST_GET_CHANNEL_VOLUME(2, 1)
+OMAP_MCBSP_ST_GET_CHANNEL_VOLUME(3, 0)
+OMAP_MCBSP_ST_GET_CHANNEL_VOLUME(3, 1)
+
+static int omap_mcbsp2_st_set_mode(struct snd_kcontrol *kcontrol,
+   struct snd_ctl_elem_value *ucontrol)
+{
+   u8 value = ucontrol-value.integer.value[0];
+
+   if (value == omap_st_is_enabled(1))
+   return 0;
+
+   if (value)
+   omap_st_enable(1);
+   else
+   omap_st_disable(1);
+
+   return 1;
+}
+
+static int omap_mcbsp2_st_get_mode(struct snd_kcontrol *kcontrol,
+   struct snd_ctl_elem_value *ucontrol)
+{
+   ucontrol-value.integer.value[0] = omap_st_is_enabled(1);
+   return 0;
+}
+
+static int omap_mcbsp3_st_set_mode(struct snd_kcontrol *kcontrol,
+   struct snd_ctl_elem_value *ucontrol)
+{
+   u8 value = ucontrol-value.integer.value[0];
+
+   if (value == omap_st_is_enabled(2))
+   return 0;
+
+   if (value

[PATCH v3] mfd: Initial support for twl5031

2009-11-10 Thread Ilkka Koskinen
TWL5031 introduces two new interrupts in PIH. Moreover, BCI
has changed remarkably and, thus, it's disabled when TWL5031
is in use.

Signed-off-by: Ilkka Koskinen ilkka.koski...@nokia.com
---
 drivers/mfd/twl4030-core.c  |   13 -
 drivers/mfd/twl4030-irq.c   |  131 +-
 include/linux/i2c/twl4030.h |   47 +--
 3 files changed, 180 insertions(+), 11 deletions(-)

diff --git a/drivers/mfd/twl4030-core.c b/drivers/mfd/twl4030-core.c
index 9b74f88..61c2bb7 100644
--- a/drivers/mfd/twl4030-core.c
+++ b/drivers/mfd/twl4030-core.c
@@ -152,6 +152,10 @@
 #define TWL4030_BASEADD_PWMB   0x00F1
 #define TWL4030_BASEADD_KEYPAD 0x00D2
 
+#define TWL5031_BASEADD_ACCESSORY  0x0074 /* Replaces Main Charge */
+#define TWL5031_BASEADD_INTERRUPTS 0x00B9 /* Different than TWL4030's
+ one */
+
 /* subchip/slave 3 - POWER ID */
 #define TWL4030_BASEADD_BACKUP 0x0014
 #define TWL4030_BASEADD_INT0x002E
@@ -183,6 +187,7 @@
 /* chip-specific feature flags, for i2c_device_id.driver_data */
 #define TWL4030_VAUX2  BIT(0)  /* pre-5030 voltage ranges */
 #define TPS_SUBSET BIT(1)  /* tps659[23]0 have fewer LDOs */
+#define TWL5031BIT(2)  /* twl5031 has different 
registers */
 
 /*--*/
 
@@ -235,6 +240,8 @@ static struct twl4030mapping 
twl4030_map[TWL4030_MODULE_LAST + 1] = {
{ 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 },
@@ -482,7 +489,8 @@ add_children(struct twl4030_platform_data *pdata, unsigned 
long features)
 {
struct device   *child;
 
-   if (twl_has_bci()  pdata-bci  !(features  TPS_SUBSET)) {
+   if (twl_has_bci()  pdata-bci 
+   !(features  (TPS_SUBSET | TWL5031))) {
child = add_child(3, twl4030_bci,
pdata-bci, sizeof(*pdata-bci),
false,
@@ -746,6 +754,7 @@ static void clocks_init(struct device *dev,
 
 int twl_init_irq(int irq_num, unsigned irq_base, unsigned irq_end);
 int twl_exit_irq(void);
+int twl_init_chip_irq(const char *chip);
 
 static int twl4030_remove(struct i2c_client *client)
 {
@@ -821,6 +830,7 @@ twl4030_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
if (client-irq
 pdata-irq_base
 pdata-irq_end  pdata-irq_base) {
+   twl_init_chip_irq(id-name);
status = twl_init_irq(client-irq, pdata-irq_base, 
pdata-irq_end);
if (status  0)
goto fail;
@@ -836,6 +846,7 @@ fail:
 static const struct i2c_device_id twl4030_ids[] = {
{ twl4030, TWL4030_VAUX2 },   /* Triton 2 */
{ twl5030, 0 },   /* T2 updated */
+   { twl5031, TWL5031 }, /* TWL5030 updated */
{ tps65950, 0 },  /* catalog version of twl5030 */
{ tps65930, TPS_SUBSET }, /* fewer LDOs and DACs; no charger */
{ tps65920, TPS_SUBSET }, /* fewer LDOs; no codec or charger */
diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
index fb194fe..0b73302 100644
--- a/drivers/mfd/twl4030-irq.c
+++ b/drivers/mfd/twl4030-irq.c
@@ -74,6 +74,8 @@ struct sih {
u8  edr_offset;
u8  bytes_edr;  /* bytelen of EDR */
 
+   u8  irq_lines;  /* number of supported irq lines */
+
/* SIR ignored -- set interrupt, for testing only */
struct irq_data {
u8  isr_offset;
@@ -82,6 +84,9 @@ struct sih {
/* + 2 bytes padding */
 };
 
+static const struct sih *sih_modules;
+static int nr_sih_modules;
+
 #define SIH_INITIALIZER(modname, nbits) \
.module = TWL4030_MODULE_ ## modname, \
.control_offset = TWL4030_ ## modname ## _SIH_CTRL, \
@@ -89,6 +94,7 @@ struct sih {
.bytes_ixr  = DIV_ROUND_UP(nbits, 8), \
.edr_offset = TWL4030_ ## modname ## _EDR, \
.bytes_edr  = DIV_ROUND_UP((2*(nbits)), 8), \
+   .irq_lines  = 2, \
.mask = { { \
.isr_offset = TWL4030_ ## modname ## _ISR1, \
.imr_offset = TWL4030_ ## modname ## _IMR1, \
@@ -107,7 +113,8 @@ struct sih {
 /* Order in this table matches order in PIH_ISR.  That is,
  * BIT(n) in PIH_ISR is sih_modules[n].
  */
-static const struct sih sih_modules[6] = {
+/* sih_modules_twl4030 is used both in twl4030 and twl5030 */
+static const struct sih sih_modules_twl4030[6] = {
[0] = {
.name   = gpio,
.module = TWL4030_MODULE_GPIO,
@@ -118,6 +125,7 @@ static const struct sih

Re: [PATCH v2] TWL4030: Initial support for TWL5031

2009-11-03 Thread Ilkka Koskinen


Hi Samuel,

On Fri, 16 Oct 2009, Koskinen Ilkka (Nokia-D/Tampere) wrote:

TWL5031 introduces two new interrupts in PIH. Moreover, BCI
has changed remarkably and, thus, it's disabled when TWL5031
is in use.

Signed-off-by: Ilkka Koskinen ilkka.koski...@nokia.com
---
drivers/mfd/twl4030-core.c  |   12 -
drivers/mfd/twl4030-irq.c   |  127 +--
include/linux/i2c/twl4030.h |   47 ++--
3 files changed, 173 insertions(+), 13 deletions(-)


Sorry to bothering you again, but I'd like to know the status
of this patch. Does it need more work or could you apply it
to your tree at some point?

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


Re: [Resend PATCH 2/2] twl4030: Enable low-power mode to 32kHz oscillator

2009-10-22 Thread Ilkka Koskinen


Hi Samuel,

On Thu, 22 Oct 2009, ext Samuel Ortiz wrote:

On Tue, Oct 20, 2009 at 04:22:53PM +0300, Ilkka Koskinen wrote:

+struct twl4030_clock_init_data {
+ int ck32k_lowpwr_enable;

I guess you could use a bool here ?


Good point. I'll change it.

Cheers, Ilkka


+};
+
 struct twl4030_bci_platform_data {
  int *battery_tmp_tbl;
  unsigned int tblsize;
@@ -403,6 +407,7 @@ extern void twl4030_power_init(struct twl4030_power_data 
*triton2_scripts);

 struct twl4030_platform_data {
  unsignedirq_base, irq_end;
+ struct twl4030_clock_init_data  *clock;
  struct twl4030_bci_platform_data*bci;
  struct twl4030_gpio_platform_data   *gpio;
  struct twl4030_madc_platform_data   *madc;
--
1.6.0.4



--
Intel Open Source Technology Centre
http://oss.intel.com/
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


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


[PATCH v2] twl4030: Enable low-power mode to 32kHz oscillator

2009-10-22 Thread Ilkka Koskinen
Allows TWL's 32kHz oscillator to go in low-power mode when
main battery voltage is running low.

Signed-off-by: Ilkka Koskinen ilkka.koski...@nokia.com
---
 drivers/mfd/twl4030-core.c  |9 +++--
 include/linux/i2c/twl4030.h |5 +
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/twl4030-core.c b/drivers/mfd/twl4030-core.c
index eee5af8..004a8be 100644
--- a/drivers/mfd/twl4030-core.c
+++ b/drivers/mfd/twl4030-core.c
@@ -177,6 +177,7 @@
 #define HFCLK_FREQ_26_MHZ  (2  0)
 #define HFCLK_FREQ_38p4_MHZ(3  0)
 #define HIGH_PERF_SQ   (1  3)
+#define CK32K_LOWPWR_EN(1  7)
 
 
 /* chip-specific feature flags, for i2c_device_id.driver_data */
@@ -681,7 +682,8 @@ static inline int __init unprotect_pm_master(void)
return e;
 }
 
-static void clocks_init(struct device *dev)
+static void clocks_init(struct device *dev,
+   struct twl4030_clock_init_data *clock)
 {
int e = 0;
struct clk *osc;
@@ -728,6 +730,9 @@ static void clocks_init(struct device *dev)
}
 
ctrl |= HIGH_PERF_SQ;
+   if (clock  clock-ck32k_lowpwr_enable)
+   ctrl |= CK32K_LOWPWR_EN;
+
e |= unprotect_pm_master();
/* effect-MADC+USB ck en */
e |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, ctrl, R_CFG_BOOT);
@@ -806,7 +811,7 @@ twl4030_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
inuse = true;
 
/* setup clock framework */
-   clocks_init(client-dev);
+   clocks_init(client-dev, pdata-clock);
 
/* load power event scripts */
if (twl_has_power()  pdata-power)
diff --git a/include/linux/i2c/twl4030.h b/include/linux/i2c/twl4030.h
index 4a2fb27..10e68cb 100644
--- a/include/linux/i2c/twl4030.h
+++ b/include/linux/i2c/twl4030.h
@@ -313,6 +313,10 @@ int twl4030_i2c_read(u8 mod_no, u8 *value, u8 reg, 
unsigned num_bytes);
 
 /*--*/
 
+struct twl4030_clock_init_data {
+   bool ck32k_lowpwr_enable;
+};
+
 struct twl4030_bci_platform_data {
int *battery_tmp_tbl;
unsigned int tblsize;
@@ -407,6 +411,7 @@ extern void twl4030_power_init(struct twl4030_power_data 
*triton2_scripts);
 
 struct twl4030_platform_data {
unsignedirq_base, irq_end;
+   struct twl4030_clock_init_data  *clock;
struct twl4030_bci_platform_data*bci;
struct twl4030_gpio_platform_data   *gpio;
struct twl4030_madc_platform_data   *madc;
-- 
1.6.0.4

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


[PATCH 1/2] twl4030: Do not dereference null pointer in error path

2009-09-30 Thread Ilkka Koskinen
Signed-off-by: Ilkka Koskinen ilkka.koski...@nokia.com
---
 drivers/mfd/twl4030-core.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/mfd/twl4030-core.c b/drivers/mfd/twl4030-core.c
index e424cf6..8cf0a02 100644
--- a/drivers/mfd/twl4030-core.c
+++ b/drivers/mfd/twl4030-core.c
@@ -792,7 +792,7 @@ twl4030_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
twl-client = i2c_new_dummy(client-adapter,
twl-address);
if (!twl-client) {
-   dev_err(twl-client-dev,
+   dev_err(client-dev,
can't attach client %d\n, i);
status = -ENOMEM;
goto fail;
-- 
1.6.0.4

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


[PATCH 2/2] twl4030: Enable low-power mode to 32KHz oscillator

2009-09-30 Thread Ilkka Koskinen
Allows TWL's 32KHz oscillator to go in low-power mode when
main battery voltage is running low.

Signed-off-by: Ilkka Koskinen ilkka.koski...@nokia.com
---
 drivers/mfd/twl4030-core.c  |9 +++--
 include/linux/i2c/twl4030.h |5 +
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/twl4030-core.c b/drivers/mfd/twl4030-core.c
index 8cf0a02..5596bb4 100644
--- a/drivers/mfd/twl4030-core.c
+++ b/drivers/mfd/twl4030-core.c
@@ -177,6 +177,7 @@
 #define HFCLK_FREQ_26_MHZ  (2  0)
 #define HFCLK_FREQ_38p4_MHZ(3  0)
 #define HIGH_PERF_SQ   (1  3)
+#define CK32K_LOWPWR_EN(1  7)
 
 
 /* chip-specific feature flags, for i2c_device_id.driver_data */
@@ -678,7 +679,8 @@ static inline int __init unprotect_pm_master(void)
return e;
 }
 
-static void clocks_init(struct device *dev)
+static void clocks_init(struct device *dev,
+   struct twl4030_clock_init_data *clock)
 {
int e = 0;
struct clk *osc;
@@ -725,6 +727,9 @@ static void clocks_init(struct device *dev)
}
 
ctrl |= HIGH_PERF_SQ;
+   if (clock  clock-ck32k_lowpwr_enable)
+   ctrl |= CK32K_LOWPWR_EN;
+
e |= unprotect_pm_master();
/* effect-MADC+USB ck en */
e |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, ctrl, R_CFG_BOOT);
@@ -805,7 +810,7 @@ twl4030_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
inuse = true;
 
/* setup clock framework */
-   clocks_init(client-dev);
+   clocks_init(client-dev, pdata-clock);
 
/* load power event scripts */
if (twl_has_power()  pdata-power)
diff --git a/include/linux/i2c/twl4030.h b/include/linux/i2c/twl4030.h
index 2d02dfd..612d0b7 100644
--- a/include/linux/i2c/twl4030.h
+++ b/include/linux/i2c/twl4030.h
@@ -312,6 +312,10 @@ int twl4030_i2c_read(u8 mod_no, u8 *value, u8 reg, 
unsigned num_bytes);
 
 /*--*/
 
+struct twl4030_clock_init_data {
+   int ck32k_lowpwr_enable;
+};
+
 struct twl4030_bci_platform_data {
int *battery_tmp_tbl;
unsigned int tblsize;
@@ -403,6 +407,7 @@ extern void twl4030_power_init(struct twl4030_power_data 
*triton2_scripts);
 
 struct twl4030_platform_data {
unsignedirq_base, irq_end;
+   struct twl4030_clock_init_data  *clock;
struct twl4030_bci_platform_data*bci;
struct twl4030_gpio_platform_data   *gpio;
struct twl4030_madc_platform_data   *madc;
-- 
1.6.0.4

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