[PATCH] TI DaVinci EMAC: Convert to dev_pm_ops

2010-03-11 Thread Chaithrika U S
Migrate from the legacy PM hooks to use dev_pm_ops structure.

Signed-off-by: Chaithrika U S chaithr...@ti.com
---

This patch applies to Linus' kernel tree.
The fixes provided in this patch[1] are needed for EMAC driver to build.
[1]http://patchwork.kernel.org/patch/84267/

 drivers/net/davinci_emac.c |   27 ---
 1 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/drivers/net/davinci_emac.c b/drivers/net/davinci_emac.c
index 2526a9b..eb67fa6 100644
--- a/drivers/net/davinci_emac.c
+++ b/drivers/net/davinci_emac.c
@@ -2829,31 +2829,37 @@ static int __devexit davinci_emac_remove(struct 
platform_device *pdev)
return 0;
 }
 
-static
-int davinci_emac_suspend(struct platform_device *pdev, pm_message_t state)
+static int davinci_emac_suspend(struct device *dev)
 {
-   struct net_device *dev = platform_get_drvdata(pdev);
+   struct platform_device *pdev = to_platform_device(dev);
+   struct net_device *ndev = platform_get_drvdata(pdev);
 
-   if (netif_running(dev))
-   emac_dev_stop(dev);
+   if (netif_running(ndev))
+   emac_dev_stop(ndev);
 
clk_disable(emac_clk);
 
return 0;
 }
 
-static int davinci_emac_resume(struct platform_device *pdev)
+static int davinci_emac_resume(struct device *dev)
 {
-   struct net_device *dev = platform_get_drvdata(pdev);
+   struct platform_device *pdev = to_platform_device(dev);
+   struct net_device *ndev = platform_get_drvdata(pdev);
 
clk_enable(emac_clk);
 
-   if (netif_running(dev))
-   emac_dev_open(dev);
+   if (netif_running(ndev))
+   emac_dev_open(ndev);
 
return 0;
 }
 
+static const struct dev_pm_ops davinci_emac_pm_ops = {
+   .suspend= davinci_emac_suspend,
+   .resume = davinci_emac_resume,
+};
+
 /**
  * davinci_emac_driver: EMAC platform driver structure
  */
@@ -2861,11 +2867,10 @@ static struct platform_driver davinci_emac_driver = {
.driver = {
.name= davinci_emac,
.owner   = THIS_MODULE,
+   .pm  = davinci_emac_pm_ops,
},
.probe = davinci_emac_probe,
.remove = __devexit_p(davinci_emac_remove),
-   .suspend = davinci_emac_suspend,
-   .resume = davinci_emac_resume,
 };
 
 /**
-- 
1.5.6

___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


[PATCH] ASoC: DaVinci: Add hw_param callback for S/PDIF DIT link

2010-03-10 Thread Chaithrika U S
On TI DM6467 EVM, S/PDIF DIT codec fails to open as it is unable to install
hardware params. This dummy codec has no set_fmt and set_sysclk implementations
and calls from the application to these functions cause errors. This patch adds
a new hardware params callback function for S/PDIF transciever codec.

Signed-off-by: Chaithrika U S chaithr...@ti.com
Tested-by: Anuj Aggarwal anuj.aggar...@ti.com
---
This patch has been re-worked upon based on the review comments for
http://mailman.alsa-project.org/pipermail/alsa-devel/2010-January/024621.html

Applies to ALSA GIT tree on branch topic/asoc at
http://git.kernel.org/?p=linux/kernel/git/tiwai/sound-2.6.git;a=shortlog;
h=topic/asoc

 sound/soc/davinci/davinci-evm.c |   16 +++-
 1 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/sound/soc/davinci/davinci-evm.c b/sound/soc/davinci/davinci-evm.c
index 7ccbe66..dba6651 100644
--- a/sound/soc/davinci/davinci-evm.c
+++ b/sound/soc/davinci/davinci-evm.c
@@ -81,10 +81,24 @@ static int evm_hw_params(struct snd_pcm_substream 
*substream,
return 0;
 }
 
+static int evm_spdif_hw_params(struct snd_pcm_substream *substream,
+   struct snd_pcm_hw_params *params)
+{
+   struct snd_soc_pcm_runtime *rtd = substream-private_data;
+   struct snd_soc_dai *cpu_dai = rtd-dai-cpu_dai;
+
+   /* set cpu DAI configuration */
+   return snd_soc_dai_set_fmt(cpu_dai, AUDIO_FORMAT);
+}
+
 static struct snd_soc_ops evm_ops = {
.hw_params = evm_hw_params,
 };
 
+static struct snd_soc_ops evm_spdif_ops = {
+   .hw_params = evm_spdif_hw_params,
+};
+
 /* davinci-evm machine dapm widgets */
 static const struct snd_soc_dapm_widget aic3x_dapm_widgets[] = {
SND_SOC_DAPM_HP(Headphone Jack, NULL),
@@ -165,7 +179,7 @@ static struct snd_soc_dai_link dm6467_evm_dai[] = {
.stream_name = spdif,
.cpu_dai = davinci_mcasp_dai[DAVINCI_MCASP_DIT_DAI],
.codec_dai = dit_stub_dai,
-   .ops = evm_ops,
+   .ops = evm_spdif_ops,
},
 };
 static struct snd_soc_dai_link da8xx_evm_dai = {
-- 
1.5.6

___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


[PATCH] ASoC: DaVinci: Updates to EVM hardware params callback

2010-01-20 Thread Chaithrika U S
For S/PDIF transciever codec to work on TI DM6467 EVM,
the codec ops pointer should be checked for in the params callback.
This dummy codec has no set_fmt or set_sysclk implementations.

Tested on TI DM6467 EVM.

Signed-off-by: Chaithrika U S chaithr...@ti.com
Tested-by: Anuj Aggarwal anuj.aggar...@ti.com
---
Applies to ALSA GIT tree on branch topic/asoc at
http://git.kernel.org/?p=linux/kernel/git/tiwai/sound-2.6.git;a=shortlog;
h=topic/asoc

 sound/soc/davinci/davinci-evm.c |   17 +++--
 1 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/sound/soc/davinci/davinci-evm.c b/sound/soc/davinci/davinci-evm.c
index 7ccbe66..1760354 100644
--- a/sound/soc/davinci/davinci-evm.c
+++ b/sound/soc/davinci/davinci-evm.c
@@ -64,9 +64,11 @@ static int evm_hw_params(struct snd_pcm_substream *substream,
return -EINVAL;
 
/* set codec DAI configuration */
-   ret = snd_soc_dai_set_fmt(codec_dai, AUDIO_FORMAT);
-   if (ret  0)
-   return ret;
+   if (codec_dai-ops-set_fmt) {
+   ret = snd_soc_dai_set_fmt(codec_dai, AUDIO_FORMAT);
+   if (ret  0)
+   return ret;
+   }
 
/* set cpu DAI configuration */
ret = snd_soc_dai_set_fmt(cpu_dai, AUDIO_FORMAT);
@@ -74,9 +76,12 @@ static int evm_hw_params(struct snd_pcm_substream *substream,
return ret;
 
/* set the codec system clock */
-   ret = snd_soc_dai_set_sysclk(codec_dai, 0, sysclk, SND_SOC_CLOCK_OUT);
-   if (ret  0)
-   return ret;
+   if (codec_dai-ops-set_sysclk) {
+   ret = snd_soc_dai_set_sysclk(codec_dai, 0, sysclk,
+   SND_SOC_CLOCK_OUT);
+   if (ret  0)
+   return ret;
+   }
 
return 0;
 }
-- 
1.5.6

___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


[PATCH] ASoC: DaVinci: Fix stream restart error

2010-01-20 Thread Chaithrika U S
Sometimes after a suspend-resume cycle, the ALSA application
restarts the stream when resume fails and McASP fails to work
as the clock is not enabled. This patch corrects this bug.

Testes on TI DA850/OMAP-L138 EVM.

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
Applies to ALSA GIT tree on branch topic/asoc at
http://git.kernel.org/?p=linux/kernel/git/tiwai/sound-2.6.git;a=shortlog;
h=topic/asoc

 sound/soc/davinci/davinci-mcasp.c |5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/sound/soc/davinci/davinci-mcasp.c 
b/sound/soc/davinci/davinci-mcasp.c
index a613bbb..ab6518d 100644
--- a/sound/soc/davinci/davinci-mcasp.c
+++ b/sound/soc/davinci/davinci-mcasp.c
@@ -768,13 +768,12 @@ static int davinci_mcasp_trigger(struct snd_pcm_substream 
*substream,
 
switch (cmd) {
case SNDRV_PCM_TRIGGER_RESUME:
+   case SNDRV_PCM_TRIGGER_START:
+   case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
if (!dev-clk_active) {
clk_enable(dev-clk);
dev-clk_active = 1;
}
-   /* Fall through */
-   case SNDRV_PCM_TRIGGER_START:
-   case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
davinci_mcasp_start(dev, substream-stream);
break;
 
-- 
1.5.6

___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


RE: [PATCH] ASoC: DaVinci: Fix stream restart error

2010-01-20 Thread Chaithrika U S
All,

Please ignore this patch, missed the 'To' address in the mail.
I have re-submitted this patch.

Regards, 
Chaithrika

On Wed, Jan 20, 2010 at 17:04:45, alsa-de...@alsa-project.org wrote:
 From: Chaithrika U S chaithr...@ti.com
 
 Sometimes after a suspend-resume cycle, the ALSA application
 restarts the stream when resume fails and McASP fails to work
 as the clock is not enabled. This patch corrects this bug.
 
 Testes on TI DA850/OMAP-L138 EVM.
 
 Signed-off-by: Chaithrika U S chaithr...@ti.com
 ---
 Applies to ALSA GIT tree on branch topic/asoc at
 http://git.kernel.org/?p=linux/kernel/git/tiwai/sound-2.6.git;a=shortlog;
 h=topic/asoc
 
  sound/soc/davinci/davinci-mcasp.c |5 ++---
  1 files changed, 2 insertions(+), 3 deletions(-)
 
 diff --git a/sound/soc/davinci/davinci-mcasp.c 
 b/sound/soc/davinci/davinci-mcasp.c
 index a613bbb..ab6518d 100644
 --- a/sound/soc/davinci/davinci-mcasp.c
 +++ b/sound/soc/davinci/davinci-mcasp.c
 @@ -768,13 +768,12 @@ static int davinci_mcasp_trigger(struct 
 snd_pcm_substream *substream,
  
   switch (cmd) {
   case SNDRV_PCM_TRIGGER_RESUME:
 + case SNDRV_PCM_TRIGGER_START:
 + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
   if (!dev-clk_active) {
   clk_enable(dev-clk);
   dev-clk_active = 1;
   }
 - /* Fall through */
 - case SNDRV_PCM_TRIGGER_START:
 - case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
   davinci_mcasp_start(dev, substream-stream);
   break;
  
 -- 
 1.5.6
 



___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


RE: [PATCH] serial: 8250: Add cpufreq support

2010-01-18 Thread Chaithrika U S
On Wed, Jan 13, 2010 at 19:14:45, Alan Cox wrote:
  +static int serial8250_cpufreq_transition(struct notifier_block *nb,
  +unsigned long val, void *data)
  +{
  +   struct uart_8250_port *p;
  +   struct uart_port *uport;
  +
  +   p = container_of(nb, struct uart_8250_port, freq_transition);
  +   uport = p-port;
  +
  +   if (IS_ERR(p-clk))
  +   goto cpu_freq_exit;
  +
  +   if (p-port.uartclk == clk_get_rate(p-clk))
  +   goto cpu_freq_exit;
  +
  +   p-port.uartclk = clk_get_rate(p-clk);
  +   if (val == CPUFREQ_POSTCHANGE) {
  +   struct ktermios *termios;
  +   struct tty_struct *tty;
  +   if (uport-state == NULL)
  +   goto cpu_freq_exit;
  +
  +   tty = uport-state-port.tty;
 
 Need locking on port-tty.
 
  +   if (tty == NULL)
  +   goto cpu_freq_exit;
  +
 
 Need locking on tty-termios
 
 I'd say this is also probably at the wrong level - why not do it at the
 uart_port level instead (ie move the code you have into serial_core using
 uart_port) - you've made it all nicely generic already.
 
 Alan
   

Thank you for the review comments.
I will submit an updated version of patch soon.

Regards, 
Chaithrika


___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


RE: [RFC] serial: 8250: Add cpufreq support

2010-01-13 Thread Chaithrika U S
On Tue, Jan 12, 2010 at 19:07:47, Sergei Shtylyov wrote:
 Hello.
 
 Chaithrika U S wrote:
 
   drivers/serial/8250.c   |   81 
  +++
   include/linux/serial_8250.h |1 +
   2 files changed, 82 insertions(+), 0 deletions(-)
 
  diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
  index c3e37c8..612e129 100644
  --- a/drivers/serial/8250.c
  +++ b/drivers/serial/8250.c
  @@ -38,6 +38,8 @@
   #include linux/serial_8250.h
   #include linux/nmi.h
   #include linux/mutex.h
  +#include linux/cpufreq.h
  +#include linux/clk.h
   
   #include asm/io.h
   #include asm/irq.h
  @@ -156,6 +158,10 @@ struct uart_8250_port {
 */
void(*pm)(struct uart_port *port,
  unsigned int state, unsigned int old);
  + struct clk  *uart_clk;
  +#ifdef CONFIG_CPU_FREQ
  + struct notifier_block   freq_transition;
  +#endif
   };
   
   struct irq_info {
  @@ -2931,6 +2937,70 @@ void serial8250_resume_port(int line)
uart_resume_port(serial8250_reg, up-port);
   }
   
  +#ifdef CONFIG_CPU_FREQ
  +static int serial8250_cpufreq_transition(struct notifier_block *nb,
  +  unsigned long val, void *data)
  +{
  + struct uart_8250_port *p;
  + struct uart_port *uport;
  +
  + p = container_of(nb, struct uart_8250_port, freq_transition);
  + uport = p-port;
  +
  + if(!p-port.uartclk)
  + goto cpu_freq_exit;

  Isn't it OK to have a zero value here if you're going to use
  clk_get_rate()?  or does uartclk == 0 have a special meaning here?  If
  so, should be commented.
 
  
 
  This is a mistake here! The if condition should check 'uart_clk' - the
  clock struct pointer. I will correct this and post the updated patch.

 
Perhaps this structure member should have another name, like just 
 'clk' or 'clocl' to make it more distinct from 'uartclk'...
 

Agree. I will update this and submit the patch soon.

Regards, 
Chaithrika

  Thanks  Regards, 
  Chaithrika

 
 WBR, Sergei
 




___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


[PATCH] serial: 8250: Add cpufreq support

2010-01-13 Thread Chaithrika U S
On DA850/OMAP-L138 SoC, the PLL which supplies the clock to CPU also feeds the
UART and the UART input frequency can change when the CPU frequency is scaled.

This patch adds cpufreq support for 8250 serial driver. A clk structure member
has been added to the platform and port data structures. This member is used by
the cpufreq notifier callback to get the updated clock rate. The implementation
is based on the cpufreq implementation for Samsung serial driver.

Tested on TI DA850/OMAP-L138 EVM.

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
Applies to Linus' kernel tree.

 drivers/serial/8250.c   |   79 +++
 include/linux/serial_8250.h |1 +
 2 files changed, 80 insertions(+), 0 deletions(-)

diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index c3e37c8..a64d1de 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -38,6 +38,8 @@
 #include linux/serial_8250.h
 #include linux/nmi.h
 #include linux/mutex.h
+#include linux/cpufreq.h
+#include linux/clk.h
 
 #include asm/io.h
 #include asm/irq.h
@@ -156,6 +158,10 @@ struct uart_8250_port {
 */
void(*pm)(struct uart_port *port,
  unsigned int state, unsigned int old);
+   struct clk  *clk;
+#ifdef CONFIG_CPU_FREQ
+   struct notifier_block   freq_transition;
+#endif
 };
 
 struct irq_info {
@@ -2931,6 +2937,70 @@ void serial8250_resume_port(int line)
uart_resume_port(serial8250_reg, up-port);
 }
 
+#ifdef CONFIG_CPU_FREQ
+static int serial8250_cpufreq_transition(struct notifier_block *nb,
+unsigned long val, void *data)
+{
+   struct uart_8250_port *p;
+   struct uart_port *uport;
+
+   p = container_of(nb, struct uart_8250_port, freq_transition);
+   uport = p-port;
+
+   if (IS_ERR(p-clk))
+   goto cpu_freq_exit;
+
+   if (p-port.uartclk == clk_get_rate(p-clk))
+   goto cpu_freq_exit;
+
+   p-port.uartclk = clk_get_rate(p-clk);
+   if (val == CPUFREQ_POSTCHANGE) {
+   struct ktermios *termios;
+   struct tty_struct *tty;
+   if (uport-state == NULL)
+   goto cpu_freq_exit;
+
+   tty = uport-state-port.tty;
+   if (tty == NULL)
+   goto cpu_freq_exit;
+
+   termios = tty-termios;
+   if (termios == NULL) {
+   printk(KERN_WARNING %s: no termios?\n, __func__);
+   goto cpu_freq_exit;
+   }
+
+   serial8250_set_termios(uport, termios, NULL);
+   }
+
+cpu_freq_exit:
+   return 0;
+}
+
+static inline int serial8250_cpufreq_register(struct uart_8250_port *p)
+{
+   p-freq_transition.notifier_call = serial8250_cpufreq_transition;
+
+   return cpufreq_register_notifier(p-freq_transition,
+CPUFREQ_TRANSITION_NOTIFIER);
+}
+
+static inline void serial8250_cpufreq_deregister(struct uart_8250_port *p)
+{
+   cpufreq_unregister_notifier(p-freq_transition,
+   CPUFREQ_TRANSITION_NOTIFIER);
+}
+#else
+static inline int serial8250_cpufreq_register(struct uart_8250_port *p)
+{
+   return 0;
+}
+
+static inline void serial8250_cpufreq_deregister(struct uart_8250_port *p)
+{
+}
+#endif
+
 /*
  * Register a set of serial devices attached to a platform device.  The
  * list is terminated with a zero flags entry, which means we expect
@@ -2964,6 +3034,9 @@ static int __devinit serial8250_probe(struct 
platform_device *dev)
port.serial_out = p-serial_out;
port.dev= dev-dev;
port.irqflags   |= irqflag;
+   if (p-clk)
+   serial8250_ports[i].clk = p-clk;
+
ret = serial8250_register_port(port);
if (ret  0) {
dev_err(dev-dev, unable to register port at index %d 

@@ -3133,6 +3206,11 @@ int serial8250_register_port(struct uart_port *port)
ret = uart_add_one_port(serial8250_reg, uart-port);
if (ret == 0)
ret = uart-port.line;
+
+   ret = serial8250_cpufreq_register(uart);
+   if (ret  0)
+   printk(KERN_ERR Failed to add cpufreq notifier\n);
+
}
mutex_unlock(serial_mutex);
 
@@ -3152,6 +3230,7 @@ void serial8250_unregister_port(int line)
struct uart_8250_port *uart = serial8250_ports[line];
 
mutex_lock(serial_mutex);
+   serial8250_cpufreq_deregister(uart);
uart_remove_one_port(serial8250_reg, uart-port);
if (serial8250_isa_devs) {
uart-port.flags = ~UPF_BOOT_AUTOCONF;
diff --git a/include/linux/serial_8250.h b/include/linux/serial_8250.h
index fb46aba..57d6e69 100644
--- a/include/linux/serial_8250.h
+++ b

RE: [RFC] serial: 8250: Add cpufreq support

2010-01-12 Thread Chaithrika U S
On Mon, Jan 11, 2010 at 21:23:48, Kevin Hilman wrote:
 Chaithrika U S chaithr...@ti.com writes:
 
  On DA850/OMAP-L138 SoC, the PLL which supplies the clock to CPU also feeds 
  the
  UART and the UART input frequency can change when the CPU frequency is 
  scaled.
 
  This patch adds cpufreq support for 8250 serial driver. A clk structure 
  member
  has been added to the platform and port data structure. This member is used 
  by
  the cpufreq notifier callback to get the updated clock rate. The 
  implementation
  is based on the cpufreq implementation for Samsung serial driver.
 
  This implementation has been tested on TI DA850/OMAP-L138 EVM.
 
  Signed-off-by: Chaithrika U S chaithr...@ti.com
  ---
  This patch is posted here for review and will be posted to LKML later.
 
 Some minor comments/questions below.  Otherwise, should be posted to
 linux-serial + LKML and Cc davinci list.
 
 Hopefully somebody (hopefully Andrew) will pick this up since the 8250 driver 
 has
 been orphaned for sometime.
   

I will post this patch to linux-serial and LKML lists soon.

 Kevin
 
 
   drivers/serial/8250.c   |   81 
  +++
   include/linux/serial_8250.h |1 +
   2 files changed, 82 insertions(+), 0 deletions(-)
 
  diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
  index c3e37c8..612e129 100644
  --- a/drivers/serial/8250.c
  +++ b/drivers/serial/8250.c
  @@ -38,6 +38,8 @@
   #include linux/serial_8250.h
   #include linux/nmi.h
   #include linux/mutex.h
  +#include linux/cpufreq.h
  +#include linux/clk.h
   
   #include asm/io.h
   #include asm/irq.h
  @@ -156,6 +158,10 @@ struct uart_8250_port {
   */
  void(*pm)(struct uart_port *port,
unsigned int state, unsigned int old);
  +   struct clk  *uart_clk;
  +#ifdef CONFIG_CPU_FREQ
  +   struct notifier_block   freq_transition;
  +#endif
   };
   
   struct irq_info {
  @@ -2931,6 +2937,70 @@ void serial8250_resume_port(int line)
  uart_resume_port(serial8250_reg, up-port);
   }
   
  +#ifdef CONFIG_CPU_FREQ
  +static int serial8250_cpufreq_transition(struct notifier_block *nb,
  +unsigned long val, void *data)
  +{
  +   struct uart_8250_port *p;
  +   struct uart_port *uport;
  +
  +   p = container_of(nb, struct uart_8250_port, freq_transition);
  +   uport = p-port;
  +
  +   if(!p-port.uartclk)
  +   goto cpu_freq_exit;
 
 Isn't it OK to have a zero value here if you're going to use
 clk_get_rate()?  or does uartclk == 0 have a special meaning here?  If
 so, should be commented.
 

This is a mistake here! The if condition should check 'uart_clk' - the
clock struct pointer. I will correct this and post the updated patch.

Thanks  Regards, 
Chaithrika


___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


[PATCH v3 1/2] davinci: MMC: Add a function to control reset state of the controller

2010-01-08 Thread Chaithrika U S
Add a helper function which will aid in changing the reset
status of the controller.

Signed-off-by: Chaithrika U S chaithr...@ti.com
Acked-by: Kevin Hilman khil...@deeprootsystems.com
---
Applies to Linus' kernel tree

 drivers/mmc/host/davinci_mmc.c |   37 -
 1 files changed, 16 insertions(+), 21 deletions(-)

diff --git a/drivers/mmc/host/davinci_mmc.c b/drivers/mmc/host/davinci_mmc.c
index dd45e7c..25645bf 100644
--- a/drivers/mmc/host/davinci_mmc.c
+++ b/drivers/mmc/host/davinci_mmc.c
@@ -884,19 +884,26 @@ static void mmc_davinci_cmd_done(struct mmc_davinci_host 
*host,
}
 }
 
-static void
-davinci_abort_data(struct mmc_davinci_host *host, struct mmc_data *data)
+static inline void mmc_davinci_reset_ctrl(struct mmc_davinci_host *host,
+   int val)
 {
u32 temp;
 
-   /* reset command and data state machines */
temp = readl(host-base + DAVINCI_MMCCTL);
-   writel(temp | MMCCTL_CMDRST | MMCCTL_DATRST,
-   host-base + DAVINCI_MMCCTL);
+   if (val)/* reset */
+   temp |= MMCCTL_CMDRST | MMCCTL_DATRST;
+   else/* enable */
+   temp = ~(MMCCTL_CMDRST | MMCCTL_DATRST);
 
-   temp = ~(MMCCTL_CMDRST | MMCCTL_DATRST);
-   udelay(10);
writel(temp, host-base + DAVINCI_MMCCTL);
+   udelay(10);
+}
+
+static void
+davinci_abort_data(struct mmc_davinci_host *host, struct mmc_data *data)
+{
+   mmc_davinci_reset_ctrl(host, 1);
+   mmc_davinci_reset_ctrl(host, 0);
 }
 
 static irqreturn_t mmc_davinci_irq(int irq, void *dev_id)
@@ -1100,15 +1107,8 @@ static inline void mmc_davinci_cpufreq_deregister(struct 
mmc_davinci_host *host)
 #endif
 static void __init init_mmcsd_host(struct mmc_davinci_host *host)
 {
-   /* DAT line portion is diabled and in reset state */
-   writel(readl(host-base + DAVINCI_MMCCTL) | MMCCTL_DATRST,
-   host-base + DAVINCI_MMCCTL);
-
-   /* CMD line portion is diabled and in reset state */
-   writel(readl(host-base + DAVINCI_MMCCTL) | MMCCTL_CMDRST,
-   host-base + DAVINCI_MMCCTL);
 
-   udelay(10);
+   mmc_davinci_reset_ctrl(host, 1);
 
writel(0, host-base + DAVINCI_MMCCLK);
writel(MMCCLK_CLKEN, host-base + DAVINCI_MMCCLK);
@@ -1116,12 +1116,7 @@ static void __init init_mmcsd_host(struct 
mmc_davinci_host *host)
writel(0x1FFF, host-base + DAVINCI_MMCTOR);
writel(0x, host-base + DAVINCI_MMCTOD);
 
-   writel(readl(host-base + DAVINCI_MMCCTL)  ~MMCCTL_DATRST,
-   host-base + DAVINCI_MMCCTL);
-   writel(readl(host-base + DAVINCI_MMCCTL)  ~MMCCTL_CMDRST,
-   host-base + DAVINCI_MMCCTL);
-
-   udelay(10);
+   mmc_davinci_reset_ctrl(host, 0);
 }
 
 static int __init davinci_mmcsd_probe(struct platform_device *pdev)
-- 
1.5.6

___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


[PATCH v3 2/2] davinci: MMC: updates to suspend/resume implementation

2010-01-08 Thread Chaithrika U S
Improve the suspend and resume callbacks in DaVinci MMC host controller driver.
Modify the reset status of the contorller and clock during suspend and resume.
Also migrate the power management callbacks from platform driver to dev_pm_ops
structure.

Tested on DA850/OMAP-L138 EVM. This testing requires patches
which add suspen-to-RAM support to DA850/OMAP-L138 SoC[1].

[1]http://linux.davincidsp.com/pipermail/davinci-linux-open-source/
2009-September/016118.html

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
Applies to Linus' kernel tree.
Since the previous version, patch description has been updated.

 drivers/mmc/host/davinci_mmc.c |   51 +--
 1 files changed, 43 insertions(+), 8 deletions(-)

diff --git a/drivers/mmc/host/davinci_mmc.c b/drivers/mmc/host/davinci_mmc.c
index 25645bf..d60f648 100644
--- a/drivers/mmc/host/davinci_mmc.c
+++ b/drivers/mmc/host/davinci_mmc.c
@@ -170,6 +170,7 @@ struct mmc_davinci_host {
 #define DAVINCI_MMC_DATADIR_READ   1
 #define DAVINCI_MMC_DATADIR_WRITE  2
unsigned char data_dir;
+   unsigned char suspended;
 
/* buffer is used during PIO of one scatterlist segment, and
 * is updated along with buffer_bytes_left.  bytes_left applies
@@ -1297,32 +1298,66 @@ static int __exit davinci_mmcsd_remove(struct 
platform_device *pdev)
 }
 
 #ifdef CONFIG_PM
-static int davinci_mmcsd_suspend(struct platform_device *pdev, pm_message_t 
msg)
+static int davinci_mmcsd_suspend(struct device *dev)
 {
+   struct platform_device *pdev = to_platform_device(dev);
struct mmc_davinci_host *host = platform_get_drvdata(pdev);
+   struct pm_message msg = { PM_EVENT_SUSPEND };
+   int ret;
 
-   return mmc_suspend_host(host-mmc, msg);
+   mmc_host_enable(host-mmc);
+   ret = mmc_suspend_host(host-mmc, msg);
+   if (!ret) {
+   writel(0, host-base + DAVINCI_MMCIM);
+   mmc_davinci_reset_ctrl(host, 1);
+   mmc_host_disable(host-mmc);
+   clk_disable(host-clk);
+   host-suspended = 1;
+   } else {
+   host-suspended = 0;
+   mmc_host_disable(host-mmc);
+   }
+
+   return ret;
 }
 
-static int davinci_mmcsd_resume(struct platform_device *pdev)
+static int davinci_mmcsd_resume(struct device *dev)
 {
+   struct platform_device *pdev = to_platform_device(dev);
struct mmc_davinci_host *host = platform_get_drvdata(pdev);
+   int ret;
 
-   return mmc_resume_host(host-mmc);
+   if (!host-suspended)
+   return 0;
+
+   clk_enable(host-clk);
+   mmc_host_enable(host-mmc);
+
+   mmc_davinci_reset_ctrl(host, 0);
+   ret = mmc_resume_host(host-mmc);
+   if (!ret)
+   host-suspended = 0;
+
+   return ret;
 }
+
+static struct dev_pm_ops davinci_mmcsd_pm = {
+   .suspend= davinci_mmcsd_suspend,
+   .resume = davinci_mmcsd_resume,
+};
+
+#define davinci_mmcsd_pm_ops (davinci_mmcsd_pm)
 #else
-#define davinci_mmcsd_suspend  NULL
-#define davinci_mmcsd_resume   NULL
+#define davinci_mmcsd_pm_ops NULL
 #endif
 
 static struct platform_driver davinci_mmcsd_driver = {
.driver = {
.name   = davinci_mmc,
.owner  = THIS_MODULE,
+   .pm = davinci_mmcsd_pm_ops,
},
.remove = __exit_p(davinci_mmcsd_remove),
-   .suspend= davinci_mmcsd_suspend,
-   .resume = davinci_mmcsd_resume,
 };
 
 static int __init davinci_mmcsd_init(void)
-- 
1.5.6

___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


[RFC] serial: 8250: Add cpufreq support

2010-01-08 Thread Chaithrika U S
On DA850/OMAP-L138 SoC, the PLL which supplies the clock to CPU also feeds the
UART and the UART input frequency can change when the CPU frequency is scaled.

This patch adds cpufreq support for 8250 serial driver. A clk structure member
has been added to the platform and port data structure. This member is used by
the cpufreq notifier callback to get the updated clock rate. The implementation
is based on the cpufreq implementation for Samsung serial driver.

This implementation has been tested on TI DA850/OMAP-L138 EVM.

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
This patch is posted here for review and will be posted to LKML later.

 drivers/serial/8250.c   |   81 +++
 include/linux/serial_8250.h |1 +
 2 files changed, 82 insertions(+), 0 deletions(-)

diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index c3e37c8..612e129 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -38,6 +38,8 @@
 #include linux/serial_8250.h
 #include linux/nmi.h
 #include linux/mutex.h
+#include linux/cpufreq.h
+#include linux/clk.h
 
 #include asm/io.h
 #include asm/irq.h
@@ -156,6 +158,10 @@ struct uart_8250_port {
 */
void(*pm)(struct uart_port *port,
  unsigned int state, unsigned int old);
+   struct clk  *uart_clk;
+#ifdef CONFIG_CPU_FREQ
+   struct notifier_block   freq_transition;
+#endif
 };
 
 struct irq_info {
@@ -2931,6 +2937,70 @@ void serial8250_resume_port(int line)
uart_resume_port(serial8250_reg, up-port);
 }
 
+#ifdef CONFIG_CPU_FREQ
+static int serial8250_cpufreq_transition(struct notifier_block *nb,
+unsigned long val, void *data)
+{
+   struct uart_8250_port *p;
+   struct uart_port *uport;
+
+   p = container_of(nb, struct uart_8250_port, freq_transition);
+   uport = p-port;
+
+   if(!p-port.uartclk)
+   goto cpu_freq_exit;
+
+   if (p-port.uartclk == clk_get_rate(p-uart_clk))
+   goto cpu_freq_exit;
+
+   p-port.uartclk = clk_get_rate(p-uart_clk);
+   if (val == CPUFREQ_POSTCHANGE) {
+   struct ktermios *termios;
+   struct tty_struct *tty;
+   if (uport-state == NULL)
+   goto cpu_freq_exit;
+
+   tty = uport-state-port.tty;
+   if (tty == NULL)
+   goto cpu_freq_exit;
+
+   termios = tty-termios;
+   if (termios == NULL) {
+   printk(KERN_WARNING %s: no termios?\n, __func__);
+   goto cpu_freq_exit;
+   }
+
+   serial8250_set_termios(uport, termios, NULL);
+   }
+
+cpu_freq_exit:
+   return 0;
+}
+
+static inline int serial8250_cpufreq_register(struct uart_8250_port *p)
+{
+   p-freq_transition.notifier_call = serial8250_cpufreq_transition;
+
+   return cpufreq_register_notifier(p-freq_transition,
+CPUFREQ_TRANSITION_NOTIFIER);
+}
+
+static inline void serial8250_cpufreq_deregister(struct uart_8250_port *p)
+{
+   cpufreq_unregister_notifier(p-freq_transition,
+   CPUFREQ_TRANSITION_NOTIFIER);
+}
+#else
+static inline int serial8250_cpufreq_register(struct uart_8250_port *p)
+{
+   return 0;
+}
+
+static inline void serial8250_cpufreq_deregister(struct uart_8250_port *p)
+{
+}
+#endif
+
 /*
  * Register a set of serial devices attached to a platform device.  The
  * list is terminated with a zero flags entry, which means we expect
@@ -3090,6 +3160,7 @@ static struct uart_8250_port 
*serial8250_find_match_or_unused(struct uart_port *
  */
 int serial8250_register_port(struct uart_port *port)
 {
+   struct plat_serial8250_port *p;
struct uart_8250_port *uart;
int ret = -ENOSPC;
 
@@ -3116,6 +3187,10 @@ int serial8250_register_port(struct uart_port *port)
if (port-dev)
uart-port.dev = port-dev;
 
+   p = port-dev-platform_data;
+   if (p-uart_clk)
+   uart-uart_clk = p-uart_clk;
+
if (port-flags  UPF_FIXED_TYPE) {
uart-port.type = port-type;
uart-port.fifosize = uart_config[port-type].fifo_size;
@@ -3133,6 +3208,11 @@ int serial8250_register_port(struct uart_port *port)
ret = uart_add_one_port(serial8250_reg, uart-port);
if (ret == 0)
ret = uart-port.line;
+
+   ret = serial8250_cpufreq_register(uart);
+   if (ret  0)
+   printk(KERN_ERR Failed to add cpufreq notifier\n);
+
}
mutex_unlock(serial_mutex);
 
@@ -3152,6 +3232,7 @@ void serial8250_unregister_port(int line)
struct uart_8250_port *uart = serial8250_ports[line];
 
mutex_lock(serial_mutex

[PATCH v3 0/4] i2c: davinci: Add power management features

2010-01-06 Thread Chaithrika U S
Add suspend/resume and cpufreq features to DaVinci I2C driver
All patches apply to Linus' kernel tree.
Testing of these features was done on DA850/OMAP-L138 EVM.

Chaithrika U S (4):
  i2c: davinci: Remove MOD_REG_BIT and IO_ADDRESS usage
  i2c: davinci: Add helper functions
  i2c: davinci: Add suspend/resume support
  i2c: davinci: Add cpufreq support

 drivers/i2c/busses/i2c-davinci.c |  228 -
 1 files changed, 172 insertions(+), 56 deletions(-)

In this version, the suspend/resume support patch has been updated to
use dev_pm_ops.
___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


[PATCH v2 2/4] i2c: davinci: Add helper functions

2010-01-06 Thread Chaithrika U S
Add i2c reset control and clock divider calculation functions
which will be useful for power management features.

Signed-off-by: Chaithrika U S chaithr...@ti.com
Signed-off-by: Kevin Hilman khil...@deeprootsystems.com
---
 drivers/i2c/busses/i2c-davinci.c |   56 +-
 1 files changed, 37 insertions(+), 19 deletions(-)

diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
index 44a3cb3..81c1049 100644
--- a/drivers/i2c/busses/i2c-davinci.c
+++ b/drivers/i2c/busses/i2c-davinci.c
@@ -124,12 +124,21 @@ static inline u16 davinci_i2c_read_reg(struct 
davinci_i2c_dev *i2c_dev, int reg)
return __raw_readw(i2c_dev-base + reg);
 }
 
-/*
- * This functions configures I2C and brings I2C out of reset.
- * This function is called during I2C init function. This function
- * also gets called if I2C encounters any errors.
- */
-static int i2c_davinci_init(struct davinci_i2c_dev *dev)
+static inline void davinci_i2c_reset_ctrl(struct davinci_i2c_dev *i2c_dev,
+   int val)
+{
+   u16 w;
+
+   w = davinci_i2c_read_reg(i2c_dev, DAVINCI_I2C_MDR_REG);
+   if (!val)   /* put I2C into reset */
+   w = ~DAVINCI_I2C_MDR_IRS;
+   else/* take I2C out of reset */
+   w |= DAVINCI_I2C_MDR_IRS;
+
+   davinci_i2c_write_reg(i2c_dev, DAVINCI_I2C_MDR_REG, w);
+}
+
+static void i2c_davinci_calc_clk_dividers(struct davinci_i2c_dev *dev)
 {
struct davinci_i2c_platform_data *pdata = dev-dev-platform_data;
u16 psc;
@@ -138,15 +147,6 @@ static int i2c_davinci_init(struct davinci_i2c_dev *dev)
u32 clkh;
u32 clkl;
u32 input_clock = clk_get_rate(dev-clk);
-   u16 w;
-
-   if (!pdata)
-   pdata = davinci_i2c_platform_data_default;
-
-   /* put I2C into reset */
-   w = davinci_i2c_read_reg(dev, DAVINCI_I2C_MDR_REG);
-   w = ~DAVINCI_I2C_MDR_IRS;
-   davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, w);
 
/* NOTE: I2C Clock divider programming info
 * As per I2C specs the following formulas provide prescaler
@@ -178,12 +178,32 @@ static int i2c_davinci_init(struct davinci_i2c_dev *dev)
davinci_i2c_write_reg(dev, DAVINCI_I2C_CLKH_REG, clkh);
davinci_i2c_write_reg(dev, DAVINCI_I2C_CLKL_REG, clkl);
 
+   dev_dbg(dev-dev, input_clock = %d, CLK = %d\n, input_clock, clk);
+}
+
+/*
+ * This function configures I2C and brings I2C out of reset.
+ * This function is called during I2C init function. This function
+ * also gets called if I2C encounters any errors.
+ */
+static int i2c_davinci_init(struct davinci_i2c_dev *dev)
+{
+   struct davinci_i2c_platform_data *pdata = dev-dev-platform_data;
+
+   if (!pdata)
+   pdata = davinci_i2c_platform_data_default;
+
+   /* put I2C into reset */
+   davinci_i2c_reset_ctrl(dev, 0);
+
+   /* compute clock dividers */
+   i2c_davinci_calc_clk_dividers(dev);
+
/* Respond at reserved SMBus Host slave address (and zero);
 * we seem to have no option to not respond...
 */
davinci_i2c_write_reg(dev, DAVINCI_I2C_OAR_REG, 0x08);
 
-   dev_dbg(dev-dev, input_clock = %d, CLK = %d\n, input_clock, clk);
dev_dbg(dev-dev, PSC  = %d\n,
davinci_i2c_read_reg(dev, DAVINCI_I2C_PSC_REG));
dev_dbg(dev-dev, CLKL = %d\n,
@@ -194,9 +214,7 @@ static int i2c_davinci_init(struct davinci_i2c_dev *dev)
pdata-bus_freq, pdata-bus_delay);
 
/* Take the I2C module out of reset: */
-   w = davinci_i2c_read_reg(dev, DAVINCI_I2C_MDR_REG);
-   w |= DAVINCI_I2C_MDR_IRS;
-   davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, w);
+   davinci_i2c_reset_ctrl(dev, 1);
 
/* Enable interrupts */
davinci_i2c_write_reg(dev, DAVINCI_I2C_IMR_REG, I2C_DAVINCI_INTR_ALL);
-- 
1.5.6

___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


[PATCH v2 1/4] i2c: davinci: Remove MOD_REG_BIT and IO_ADDRESS usage

2010-01-06 Thread Chaithrika U S
Cleanup the DaVinci I2C driver. Remove MOD_REG_BIT macro.
Also use ioremap instead of IO_ADDRESS macro.

Signed-off-by: Chaithrika U S chaithr...@ti.com
Signed-off-by: Kevin Hilman khil...@deeprootsystems.com
---
 drivers/i2c/busses/i2c-davinci.c |   77 +++---
 1 files changed, 38 insertions(+), 39 deletions(-)

diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
index c89687a..44a3cb3 100644
--- a/drivers/i2c/busses/i2c-davinci.c
+++ b/drivers/i2c/busses/i2c-davinci.c
@@ -37,7 +37,6 @@
 #include linux/io.h
 
 #include mach/hardware.h
-
 #include mach/i2c.h
 
 /* - global defines --- */
@@ -71,37 +70,29 @@
 #define DAVINCI_I2C_IVR_NACK   0x02
 #define DAVINCI_I2C_IVR_AL 0x01
 
-#define DAVINCI_I2C_STR_BB (1  12)
-#define DAVINCI_I2C_STR_RSFULL (1  11)
-#define DAVINCI_I2C_STR_SCD(1  5)
-#define DAVINCI_I2C_STR_ARDY   (1  2)
-#define DAVINCI_I2C_STR_NACK   (1  1)
-#define DAVINCI_I2C_STR_AL (1  0)
-
-#define DAVINCI_I2C_MDR_NACK   (1  15)
-#define DAVINCI_I2C_MDR_STT(1  13)
-#define DAVINCI_I2C_MDR_STP(1  11)
-#define DAVINCI_I2C_MDR_MST(1  10)
-#define DAVINCI_I2C_MDR_TRX(1  9)
-#define DAVINCI_I2C_MDR_XA (1  8)
-#define DAVINCI_I2C_MDR_RM (1  7)
-#define DAVINCI_I2C_MDR_IRS(1  5)
-
-#define DAVINCI_I2C_IMR_AAS(1  6)
-#define DAVINCI_I2C_IMR_SCD(1  5)
-#define DAVINCI_I2C_IMR_XRDY   (1  4)
-#define DAVINCI_I2C_IMR_RRDY   (1  3)
-#define DAVINCI_I2C_IMR_ARDY   (1  2)
-#define DAVINCI_I2C_IMR_NACK   (1  1)
-#define DAVINCI_I2C_IMR_AL (1  0)
-
-#define MOD_REG_BIT(val, mask, set) do { \
-   if (set) { \
-   val |= mask; \
-   } else { \
-   val = ~mask; \
-   } \
-} while (0)
+#define DAVINCI_I2C_STR_BB BIT(12)
+#define DAVINCI_I2C_STR_RSFULL BIT(11)
+#define DAVINCI_I2C_STR_SCDBIT(5)
+#define DAVINCI_I2C_STR_ARDY   BIT(2)
+#define DAVINCI_I2C_STR_NACK   BIT(1)
+#define DAVINCI_I2C_STR_AL BIT(0)
+
+#define DAVINCI_I2C_MDR_NACK   BIT(15)
+#define DAVINCI_I2C_MDR_STTBIT(13)
+#define DAVINCI_I2C_MDR_STPBIT(11)
+#define DAVINCI_I2C_MDR_MSTBIT(10)
+#define DAVINCI_I2C_MDR_TRXBIT(9)
+#define DAVINCI_I2C_MDR_XA BIT(8)
+#define DAVINCI_I2C_MDR_RM BIT(7)
+#define DAVINCI_I2C_MDR_IRSBIT(5)
+
+#define DAVINCI_I2C_IMR_AASBIT(6)
+#define DAVINCI_I2C_IMR_SCDBIT(5)
+#define DAVINCI_I2C_IMR_XRDY   BIT(4)
+#define DAVINCI_I2C_IMR_RRDY   BIT(3)
+#define DAVINCI_I2C_IMR_ARDY   BIT(2)
+#define DAVINCI_I2C_IMR_NACK   BIT(1)
+#define DAVINCI_I2C_IMR_AL BIT(0)
 
 struct davinci_i2c_dev {
struct device   *dev;
@@ -154,7 +145,7 @@ static int i2c_davinci_init(struct davinci_i2c_dev *dev)
 
/* put I2C into reset */
w = davinci_i2c_read_reg(dev, DAVINCI_I2C_MDR_REG);
-   MOD_REG_BIT(w, DAVINCI_I2C_MDR_IRS, 0);
+   w = ~DAVINCI_I2C_MDR_IRS;
davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, w);
 
/* NOTE: I2C Clock divider programming info
@@ -204,7 +195,7 @@ static int i2c_davinci_init(struct davinci_i2c_dev *dev)
 
/* Take the I2C module out of reset: */
w = davinci_i2c_read_reg(dev, DAVINCI_I2C_MDR_REG);
-   MOD_REG_BIT(w, DAVINCI_I2C_MDR_IRS, 1);
+   w |= DAVINCI_I2C_MDR_IRS;
davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, w);
 
/* Enable interrupts */
@@ -284,9 +275,9 @@ i2c_davinci_xfer_msg(struct i2c_adapter *adap, struct 
i2c_msg *msg, int stop)
/* Enable receive or transmit interrupts */
w = davinci_i2c_read_reg(dev, DAVINCI_I2C_IMR_REG);
if (msg-flags  I2C_M_RD)
-   MOD_REG_BIT(w, DAVINCI_I2C_IMR_RRDY, 1);
+   w |= DAVINCI_I2C_IMR_RRDY;
else
-   MOD_REG_BIT(w, DAVINCI_I2C_IMR_XRDY, 1);
+   w |= DAVINCI_I2C_IMR_XRDY;
davinci_i2c_write_reg(dev, DAVINCI_I2C_IMR_REG, w);
 
dev-terminate = 0;
@@ -333,7 +324,7 @@ i2c_davinci_xfer_msg(struct i2c_adapter *adap, struct 
i2c_msg *msg, int stop)
return msg-len;
if (stop) {
w = davinci_i2c_read_reg(dev, DAVINCI_I2C_MDR_REG);
-   MOD_REG_BIT(w, DAVINCI_I2C_MDR_STP, 1);
+   w |= DAVINCI_I2C_MDR_STP;
davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, w);
}
return -EREMOTEIO;
@@ -461,7 +452,7 @@ static irqreturn_t i2c_davinci_isr(int this_irq, void 
*dev_id)
 
w = davinci_i2c_read_reg(dev,
 DAVINCI_I2C_IMR_REG);
-   MOD_REG_BIT(w, DAVINCI_I2C_IMR_XRDY, 0);
+   w = ~DAVINCI_I2C_IMR_XRDY;
davinci_i2c_write_reg(dev,
  DAVINCI_I2C_IMR_REG

[PATCH v3 3/4] i2c: davinci: Add suspend/resume support

2010-01-06 Thread Chaithrika U S
Add suspend and resume callbacks to DaVinci I2C driver.
This has been tested on DA850/OMAP-L138 EVM. The SoC specific
suspend-to-RAM support patch series [1] is needed to test this feature.

[1] http://linux.davincidsp.com/pipermail/davinci-linux-open-source/
2009-November/016958.html

Signed-off-by: Chaithrika U S chaithr...@ti.com
Signed-off-by: Kevin Hilman khil...@deeprootsystems.com
---
 drivers/i2c/busses/i2c-davinci.c |   36 
 1 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
index 81c1049..d2a4844 100644
--- a/drivers/i2c/busses/i2c-davinci.c
+++ b/drivers/i2c/busses/i2c-davinci.c
@@ -622,6 +622,41 @@ static int davinci_i2c_remove(struct platform_device *pdev)
return 0;
 }
 
+#ifdef CONFIG_PM
+static int davinci_i2c_suspend(struct device *dev)
+{
+   struct platform_device *pdev = to_platform_device(dev);
+   struct davinci_i2c_dev *i2c_dev = platform_get_drvdata(pdev);
+
+   /* put I2C into reset */
+   davinci_i2c_reset_ctrl(i2c_dev, 0);
+   clk_disable(i2c_dev-clk);
+
+   return 0;
+}
+
+static int davinci_i2c_resume(struct device *dev)
+{
+   struct platform_device *pdev = to_platform_device(dev);
+   struct davinci_i2c_dev *i2c_dev = platform_get_drvdata(pdev);
+
+   clk_enable(i2c_dev-clk);
+   /* take I2C out of reset */
+   davinci_i2c_reset_ctrl(i2c_dev, 1);
+
+   return 0;
+}
+
+static struct dev_pm_ops davinci_i2c_pm = {
+   .suspend= davinci_i2c_suspend,
+   .resume = davinci_i2c_resume,
+};
+
+#define davinci_i2c_pm_ops (davinci_i2c_pm)
+#else
+#define davinci_i2c_pm_ops NULL
+#endif
+
 /* work with hotplug and coldplug */
 MODULE_ALIAS(platform:i2c_davinci);
 
@@ -631,6 +666,7 @@ static struct platform_driver davinci_i2c_driver = {
.driver = {
.name   = i2c_davinci,
.owner  = THIS_MODULE,
+   .pm = davinci_i2c_pm_ops,
},
 };
 
-- 
1.5.6

___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


[PATCH v2 4/4] i2c: davinci: Add cpufreq support

2010-01-06 Thread Chaithrika U S
Add cpufreq support for DaVinci I2C driver.
Tested on DA850/OMAP-L138 EVM. For the purpose of testing, the patches
which add cpufreq support [1] for this SoC are needed.

[1]http://linux.davincidsp.com/pipermail/davinci-linux-open-source/
2009-September/016118.html

Signed-off-by: Chaithrika U S chaithr...@ti.com
Signed-off-by: Kevin Hilman khil...@deeprootsystems.com
---
 drivers/i2c/busses/i2c-davinci.c |   63 ++
 1 files changed, 63 insertions(+), 0 deletions(-)

diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
index d2a4844..773cce5 100644
--- a/drivers/i2c/busses/i2c-davinci.c
+++ b/drivers/i2c/busses/i2c-davinci.c
@@ -35,6 +35,7 @@
 #include linux/interrupt.h
 #include linux/platform_device.h
 #include linux/io.h
+#include linux/cpufreq.h
 
 #include mach/hardware.h
 #include mach/i2c.h
@@ -105,6 +106,10 @@ struct davinci_i2c_dev {
int irq;
u8  terminate;
struct i2c_adapter  adapter;
+#ifdef CONFIG_CPU_FREQ
+   struct completion   xfr_complete;
+   struct notifier_block   freq_transition;
+#endif
 };
 
 /* default platform data to use if not supplied in the platform_device */
@@ -375,6 +380,11 @@ i2c_davinci_xfer(struct i2c_adapter *adap, struct i2c_msg 
msgs[], int num)
if (ret  0)
return ret;
}
+
+#ifdef CONFIG_CPU_FREQ
+   complete(dev-xfr_complete);
+#endif
+
return num;
 }
 
@@ -499,6 +509,48 @@ static irqreturn_t i2c_davinci_isr(int this_irq, void 
*dev_id)
return count ? IRQ_HANDLED : IRQ_NONE;
 }
 
+#ifdef CONFIG_CPU_FREQ
+static int i2c_davinci_cpufreq_transition(struct notifier_block *nb,
+unsigned long val, void *data)
+{
+   struct davinci_i2c_dev *dev;
+
+   dev = container_of(nb, struct davinci_i2c_dev, freq_transition);
+   if (val == CPUFREQ_PRECHANGE) {
+   wait_for_completion(dev-xfr_complete);
+   davinci_i2c_reset_ctrl(dev, 0);
+   } else if (val == CPUFREQ_POSTCHANGE) {
+   i2c_davinci_calc_clk_dividers(dev);
+   davinci_i2c_reset_ctrl(dev, 1);
+   }
+
+   return 0;
+}
+
+static inline int i2c_davinci_cpufreq_register(struct davinci_i2c_dev *dev)
+{
+   dev-freq_transition.notifier_call = i2c_davinci_cpufreq_transition;
+
+   return cpufreq_register_notifier(dev-freq_transition,
+CPUFREQ_TRANSITION_NOTIFIER);
+}
+
+static inline void i2c_davinci_cpufreq_deregister(struct davinci_i2c_dev *dev)
+{
+   cpufreq_unregister_notifier(dev-freq_transition,
+   CPUFREQ_TRANSITION_NOTIFIER);
+}
+#else
+static inline int i2c_davinci_cpufreq_register(struct davinci_i2c_dev *dev)
+{
+   return 0;
+}
+
+static inline void i2c_davinci_cpufreq_deregister(struct davinci_i2c_dev *dev)
+{
+}
+#endif
+
 static struct i2c_algorithm i2c_davinci_algo = {
.master_xfer= i2c_davinci_xfer,
.functionality  = i2c_davinci_func,
@@ -538,6 +590,9 @@ static int davinci_i2c_probe(struct platform_device *pdev)
}
 
init_completion(dev-cmd_complete);
+#ifdef CONFIG_CPU_FREQ
+   init_completion(dev-xfr_complete);
+#endif
dev-dev = get_device(pdev-dev);
dev-irq = irq-start;
platform_set_drvdata(pdev, dev);
@@ -563,6 +618,12 @@ static int davinci_i2c_probe(struct platform_device *pdev)
goto err_unuse_clocks;
}
 
+   r = i2c_davinci_cpufreq_register(dev);
+   if (r) {
+   dev_err(pdev-dev, failed to register cpufreq\n);
+   goto err_free_irq;
+   }
+
adap = dev-adapter;
i2c_set_adapdata(adap, dev);
adap-owner = THIS_MODULE;
@@ -604,6 +665,8 @@ static int davinci_i2c_remove(struct platform_device *pdev)
struct davinci_i2c_dev *dev = platform_get_drvdata(pdev);
struct resource *mem;
 
+   i2c_davinci_cpufreq_deregister(dev);
+
platform_set_drvdata(pdev, NULL);
i2c_del_adapter(dev-adapter);
put_device(pdev-dev);
-- 
1.5.6

___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


[PATCH v2 1/2] davinci: MMC: Add a function to control reset state of the controller

2010-01-06 Thread Chaithrika U S
Add a helper function which will aid in changing the reset
status of the controller.

Signed-off-by: Chaithrika U S chaithr...@ti.com
Signed-off-by: Kevin Hilman khil...@deeprootsystems.com
---
Applies to Linus' kernel tree

 drivers/mmc/host/davinci_mmc.c |   37 -
 1 files changed, 16 insertions(+), 21 deletions(-)

diff --git a/drivers/mmc/host/davinci_mmc.c b/drivers/mmc/host/davinci_mmc.c
index dd45e7c..25645bf 100644
--- a/drivers/mmc/host/davinci_mmc.c
+++ b/drivers/mmc/host/davinci_mmc.c
@@ -884,19 +884,26 @@ static void mmc_davinci_cmd_done(struct mmc_davinci_host 
*host,
}
 }
 
-static void
-davinci_abort_data(struct mmc_davinci_host *host, struct mmc_data *data)
+static inline void mmc_davinci_reset_ctrl(struct mmc_davinci_host *host,
+   int val)
 {
u32 temp;
 
-   /* reset command and data state machines */
temp = readl(host-base + DAVINCI_MMCCTL);
-   writel(temp | MMCCTL_CMDRST | MMCCTL_DATRST,
-   host-base + DAVINCI_MMCCTL);
+   if (val)/* reset */
+   temp |= MMCCTL_CMDRST | MMCCTL_DATRST;
+   else/* enable */
+   temp = ~(MMCCTL_CMDRST | MMCCTL_DATRST);
 
-   temp = ~(MMCCTL_CMDRST | MMCCTL_DATRST);
-   udelay(10);
writel(temp, host-base + DAVINCI_MMCCTL);
+   udelay(10);
+}
+
+static void
+davinci_abort_data(struct mmc_davinci_host *host, struct mmc_data *data)
+{
+   mmc_davinci_reset_ctrl(host, 1);
+   mmc_davinci_reset_ctrl(host, 0);
 }
 
 static irqreturn_t mmc_davinci_irq(int irq, void *dev_id)
@@ -1100,15 +1107,8 @@ static inline void mmc_davinci_cpufreq_deregister(struct 
mmc_davinci_host *host)
 #endif
 static void __init init_mmcsd_host(struct mmc_davinci_host *host)
 {
-   /* DAT line portion is diabled and in reset state */
-   writel(readl(host-base + DAVINCI_MMCCTL) | MMCCTL_DATRST,
-   host-base + DAVINCI_MMCCTL);
-
-   /* CMD line portion is diabled and in reset state */
-   writel(readl(host-base + DAVINCI_MMCCTL) | MMCCTL_CMDRST,
-   host-base + DAVINCI_MMCCTL);
 
-   udelay(10);
+   mmc_davinci_reset_ctrl(host, 1);
 
writel(0, host-base + DAVINCI_MMCCLK);
writel(MMCCLK_CLKEN, host-base + DAVINCI_MMCCLK);
@@ -1116,12 +1116,7 @@ static void __init init_mmcsd_host(struct 
mmc_davinci_host *host)
writel(0x1FFF, host-base + DAVINCI_MMCTOR);
writel(0x, host-base + DAVINCI_MMCTOD);
 
-   writel(readl(host-base + DAVINCI_MMCCTL)  ~MMCCTL_DATRST,
-   host-base + DAVINCI_MMCCTL);
-   writel(readl(host-base + DAVINCI_MMCCTL)  ~MMCCTL_CMDRST,
-   host-base + DAVINCI_MMCCTL);
-
-   udelay(10);
+   mmc_davinci_reset_ctrl(host, 0);
 }
 
 static int __init davinci_mmcsd_probe(struct platform_device *pdev)
-- 
1.5.6

___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


[PATCH v2 2/2] davinci: MMC: updates to suspend/resume implementation

2010-01-06 Thread Chaithrika U S
Improve the suspend and resume callbacks in DaVinci MMC
host controller driver.

Tested on DA850/OMAP-L138 EVM. This testing requires patches
which add suspen-to-RAM support to DA850/OMAP-L138 SoC[1].

[1]http://linux.davincidsp.com/pipermail/davinci-linux-open-source/
2009-September/016118.html

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
Applies to Linus' kernel tree.

 drivers/mmc/host/davinci_mmc.c |   51 +--
 1 files changed, 43 insertions(+), 8 deletions(-)

diff --git a/drivers/mmc/host/davinci_mmc.c b/drivers/mmc/host/davinci_mmc.c
index 25645bf..d60f648 100644
--- a/drivers/mmc/host/davinci_mmc.c
+++ b/drivers/mmc/host/davinci_mmc.c
@@ -170,6 +170,7 @@ struct mmc_davinci_host {
 #define DAVINCI_MMC_DATADIR_READ   1
 #define DAVINCI_MMC_DATADIR_WRITE  2
unsigned char data_dir;
+   unsigned char suspended;
 
/* buffer is used during PIO of one scatterlist segment, and
 * is updated along with buffer_bytes_left.  bytes_left applies
@@ -1297,32 +1298,66 @@ static int __exit davinci_mmcsd_remove(struct 
platform_device *pdev)
 }
 
 #ifdef CONFIG_PM
-static int davinci_mmcsd_suspend(struct platform_device *pdev, pm_message_t 
msg)
+static int davinci_mmcsd_suspend(struct device *dev)
 {
+   struct platform_device *pdev = to_platform_device(dev);
struct mmc_davinci_host *host = platform_get_drvdata(pdev);
+   struct pm_message msg = { PM_EVENT_SUSPEND };
+   int ret;
 
-   return mmc_suspend_host(host-mmc, msg);
+   mmc_host_enable(host-mmc);
+   ret = mmc_suspend_host(host-mmc, msg);
+   if (!ret) {
+   writel(0, host-base + DAVINCI_MMCIM);
+   mmc_davinci_reset_ctrl(host, 1);
+   mmc_host_disable(host-mmc);
+   clk_disable(host-clk);
+   host-suspended = 1;
+   } else {
+   host-suspended = 0;
+   mmc_host_disable(host-mmc);
+   }
+
+   return ret;
 }
 
-static int davinci_mmcsd_resume(struct platform_device *pdev)
+static int davinci_mmcsd_resume(struct device *dev)
 {
+   struct platform_device *pdev = to_platform_device(dev);
struct mmc_davinci_host *host = platform_get_drvdata(pdev);
+   int ret;
 
-   return mmc_resume_host(host-mmc);
+   if (!host-suspended)
+   return 0;
+
+   clk_enable(host-clk);
+   mmc_host_enable(host-mmc);
+
+   mmc_davinci_reset_ctrl(host, 0);
+   ret = mmc_resume_host(host-mmc);
+   if (!ret)
+   host-suspended = 0;
+
+   return ret;
 }
+
+static struct dev_pm_ops davinci_mmcsd_pm = {
+   .suspend= davinci_mmcsd_suspend,
+   .resume = davinci_mmcsd_resume,
+};
+
+#define davinci_mmcsd_pm_ops (davinci_mmcsd_pm)
 #else
-#define davinci_mmcsd_suspend  NULL
-#define davinci_mmcsd_resume   NULL
+#define davinci_mmcsd_pm_ops NULL
 #endif
 
 static struct platform_driver davinci_mmcsd_driver = {
.driver = {
.name   = davinci_mmc,
.owner  = THIS_MODULE,
+   .pm = davinci_mmcsd_pm_ops,
},
.remove = __exit_p(davinci_mmcsd_remove),
-   .suspend= davinci_mmcsd_suspend,
-   .resume = davinci_mmcsd_resume,
 };
 
 static int __init davinci_mmcsd_init(void)
-- 
1.5.6

___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


RE: [PATCH 2/2] davinci: MMC: updates to suspend/resume implementation

2010-01-05 Thread Chaithrika U S
On Wed, Jan 06, 2010 at 05:23:53, Kevin Hilman wrote:
 Janakiram Sistla janakiram.sis...@gmail.com writes:
 
  On 12/17/09, Chaithrika U S chaithr...@ti.com wrote:
  Improve the suspend and resume callbacks in DaVinci MMC
  host controller driver.
 
  [Ram] I came cross in the mailing some days back that direct
  .suspend and .resume calls will stop being supported.Is This
  true??This patch does require a migration then again.
 
 Yes, this patch (or an additional patch) will have to update the
 MMC driver to use dev_pm_ops.
 
 See this commit in Linus' tree where I converted the smc91x driver.
 Something like this will nee dto be done for this driver as well.

OK. I will submit an updated version of this patch soon.

Regards, 
Chaithrika

 
 Kevin
 
 commit 9f950f72e57fe4bf9b16ace67e4cc5ffcee79d00
 Author: Kevin Hilman khil...@deeprootsystems.com
 Date:   Tue Nov 24 12:57:47 2009 +
 
 NET: smc91x: convert to dev_pm_ops
 
 Convert smc91x driver from legacy PM hooks over to using dev_pm_ops.
 
 Tested on OMAP3 platform.
 
 Signed-off-by: Kevin Hilman khil...@deeprootsystems.com
 Acked-by: Nicolas Pitre n...@fluxnic.net
 Signed-off-by: David S. Miller da...@davemloft.net
 
  Tested on DA850/OMAP-L138 EVM. This testing requires patches
  which add suspend-to-RAM support to DA850/OMAP-L138 SoC[1].
 
  [1]http://linux.davincidsp.com/pipermail/davinci-linux-open-source/
  2009-September/016118.html
 
  Signed-off-by: Chaithrika U S chaithr...@ti.com
  ---
  Applies to Linus' kernel tree.
 
   drivers/mmc/host/davinci_mmc.c |   31 +--
   1 files changed, 29 insertions(+), 2 deletions(-)
 
  diff --git a/drivers/mmc/host/davinci_mmc.c 
  b/drivers/mmc/host/davinci_mmc.c
  index 25645bf..7d05cc1 100644
  --- a/drivers/mmc/host/davinci_mmc.c
  +++ b/drivers/mmc/host/davinci_mmc.c
  @@ -170,6 +170,7 @@ struct mmc_davinci_host {
   #define DAVINCI_MMC_DATADIR_READ   1
   #define DAVINCI_MMC_DATADIR_WRITE  2
 unsigned char data_dir;
  +   unsigned char suspended;
 
 /* buffer is used during PIO of one scatterlist segment, and
  * is updated along with buffer_bytes_left.  bytes_left applies
  @@ -1300,15 +1301,41 @@ static int __exit davinci_mmcsd_remove(struct 
  platform_device *pdev)
   static int davinci_mmcsd_suspend(struct platform_device *pdev, 
  pm_message_t msg)
   {
 struct mmc_davinci_host *host = platform_get_drvdata(pdev);
  +   int ret;
 
  -   return mmc_suspend_host(host-mmc, msg);
  +   mmc_host_enable(host-mmc);
  +   ret = mmc_suspend_host(host-mmc, msg);
  +   if (!ret) {
  +   writel(0, host-base + DAVINCI_MMCIM);
  +   mmc_davinci_reset_ctrl(host, 1);
  +   mmc_host_disable(host-mmc);
  +   clk_disable(host-clk);
  +   host-suspended = 1;
  +   } else {
  +   host-suspended = 0;
  +   mmc_host_disable(host-mmc);
  +   }
  +
  +   return ret;
   }
 
   static int davinci_mmcsd_resume(struct platform_device *pdev)
   {
 struct mmc_davinci_host *host = platform_get_drvdata(pdev);
  +   int ret;
 
  -   return mmc_resume_host(host-mmc);
  +   if (!host-suspended)
  +   return 0;
  +
  +   clk_enable(host-clk);
  +   mmc_host_enable(host-mmc);
  +
  +   mmc_davinci_reset_ctrl(host, 0);
  +   ret = mmc_resume_host(host-mmc);
  +   if (!ret)
  +   host-suspended = 0;
  +
  +   return ret;
   }
   #else
   #define davinci_mmcsd_suspend  NULL
  --
  1.5.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/
 
 


___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


RE: [PATCH v2 3/4] i2c: davinci: Add suspend/resume support

2010-01-05 Thread Chaithrika U S
On Wed, Jan 06, 2010 at 04:26:44, Kevin Hilman wrote:
 Chaithrika U S chaithr...@ti.com writes:
 
  Add suspend and resume callbacks to DaVinci I2C driver.
  This has been tested on DA850/OMAP-L138 EVM. The SoC specific
  suspend-to-RAM support patch series [1] is needed to test this feature.
 
  [1] http://linux.davincidsp.com/pipermail/davinci-linux-open-source/
  2009-November/016958.html
 
  Signed-off-by: Chaithrika U S chaithr...@ti.com
  ---
   drivers/i2c/busses/i2c-davinci.c |   32 
   1 files changed, 32 insertions(+), 0 deletions(-)
 
  diff --git a/drivers/i2c/busses/i2c-davinci.c 
  b/drivers/i2c/busses/i2c-davinci.c
  index 81c1049..c1c2909 100644
  --- a/drivers/i2c/busses/i2c-davinci.c
  +++ b/drivers/i2c/busses/i2c-davinci.c
  @@ -622,6 +622,36 @@ static int davinci_i2c_remove(struct platform_device 
  *pdev)
  return 0;
   }
   
  +#ifdef CONFIG_PM
  +static int davinci_i2c_suspend(struct platform_device *pdev, pm_message_t 
  state)
  +{
  +   struct davinci_i2c_dev *dev = platform_get_drvdata(pdev);
  +
  +   /* put I2C into reset */
  +   davinci_i2c_reset_ctrl(dev, 0);
  +
  +   clk_disable(dev-clk);
  +
  +   return 0;
  +}
  +
  +static int davinci_i2c_resume(struct platform_device *pdev)
  +{
  +   struct davinci_i2c_dev *dev = platform_get_drvdata(pdev);
  +
  +   clk_enable(dev-clk);
  +
  +   /* take I2C out of reset */
  +   davinci_i2c_reset_ctrl(dev, 1);
  +
  +   return 0;
  +}
  +
  +#else
  +#define davinci_i2c_suspend NULL
  +#define davinci_i2c_resume NULL
  +#endif
  +
   /* work with hotplug and coldplug */
   MODULE_ALIAS(platform:i2c_davinci);
   
  @@ -632,6 +662,8 @@ static struct platform_driver davinci_i2c_driver = {
  .name   = i2c_davinci,
  .owner  = THIS_MODULE,
  },
  +   .suspend= davinci_i2c_suspend,
  +   .resume = davinci_i2c_resume,
 
 Rather than adding these to the platform_driver, you should use dev_pm_ops.
 
 Something like the patch below on top of your PATCH 3/4 should work.
 
 Other than this, I'm OK with this series, feel free to add my signoff
 and resend to linux-i2c and LKML.  linux-i2c has had very slow
 response to embedded patches lately.
 
 Kevin
 

OK. I will post updated patches soon.

Thanks  Regards, 
Chaithrika


___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


RE: Audio quality with CPU frequency scaling

2009-12-18 Thread Chaithrika U S
Andrew,

Thank you for your inputs.

 Can you elaborate on your EDMA runs at a lower speed comment ? The 
 usual setup is to have McASP trigger EDMA transfer. An EDMA transfer 
 runs at CPU speed. It should be plenty fast enough at 96 MHz.
 

EDMA here runs at 48MHz and McASP triggers the EDMA transfer.

 In the past I have seen issues where the CPU cache updating has priority 
 over the McASP transfer in the EDMA sub-system. That can cause McASP 
 underruns. I would first check that the EDMA is configured so that the 
 McASP transfer has priority over everything else. I'm not an expert on 
 EDMA3, but I think that was one of the improvements they made over 
 regular EDMA.
 

McASP events have the highest priority in EDMA in case events arrive
simultaneously from various channels.

The audio clock is from the codec and will not be affected by frequency
scaling. Also when playback or record is running, CPU load is about 4%,
so this is not a bottleneck either. The only thing that is affected by
frequency scaling is EDMA. Based on these practical observations, it
seems that EDMA is not able to transfer data fast enough. Let me see if
I can check this theoretically too.

Regards, 
Chaithrika

 Cheers,
 Andrew
 
 Chaithrika U S wrote:
  Kevin,
 
  With the cpufreq support on DA850/OMAP-L138 SoC we are observing
  that audio does not function as expected at all sampling rates
  for various operating points. At a CPU frequency of 96MHz, audio
  works fine with a sampling frequency of 8kHz. For other sampling
  rates, there are lot of underrun/overrun errors. This is because
  of EDMA also runs at a lower speed and is not able to transfer
  data at the desired rate.
 
  To overcome the above, we can depend on the user to set the scaling
  min frequency to be the same as scaling max frequency (in this case
  300 MHz) before starting aplay/arecord or temporarily move to 
  performance governor so that the audio quality is not affected.
 
  Do you think this is the right approach to this problem? Any other
  solutions you suggest exploring?
 
  Regards,
  Chaithrika
 
 
 
  ___
  Davinci-linux-open-source mailing list
  Davinci-linux-open-source@linux.davincidsp.com
  http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source
 

 
 


___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


[PATCH 2/2] davinci: MMC: updates to suspend/resume implementation

2009-12-17 Thread Chaithrika U S
Improve the suspend and resume callbacks in DaVinci MMC
host controller driver.

Tested on DA850/OMAP-L138 EVM. This testing requires patches
which add suspend-to-RAM support to DA850/OMAP-L138 SoC[1].

[1]http://linux.davincidsp.com/pipermail/davinci-linux-open-source/
2009-September/016118.html

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
Applies to Linus' kernel tree.

 drivers/mmc/host/davinci_mmc.c |   31 +--
 1 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/davinci_mmc.c b/drivers/mmc/host/davinci_mmc.c
index 25645bf..7d05cc1 100644
--- a/drivers/mmc/host/davinci_mmc.c
+++ b/drivers/mmc/host/davinci_mmc.c
@@ -170,6 +170,7 @@ struct mmc_davinci_host {
 #define DAVINCI_MMC_DATADIR_READ   1
 #define DAVINCI_MMC_DATADIR_WRITE  2
unsigned char data_dir;
+   unsigned char suspended;
 
/* buffer is used during PIO of one scatterlist segment, and
 * is updated along with buffer_bytes_left.  bytes_left applies
@@ -1300,15 +1301,41 @@ static int __exit davinci_mmcsd_remove(struct 
platform_device *pdev)
 static int davinci_mmcsd_suspend(struct platform_device *pdev, pm_message_t 
msg)
 {
struct mmc_davinci_host *host = platform_get_drvdata(pdev);
+   int ret;
 
-   return mmc_suspend_host(host-mmc, msg);
+   mmc_host_enable(host-mmc);
+   ret = mmc_suspend_host(host-mmc, msg);
+   if (!ret) {
+   writel(0, host-base + DAVINCI_MMCIM);
+   mmc_davinci_reset_ctrl(host, 1);
+   mmc_host_disable(host-mmc);
+   clk_disable(host-clk);
+   host-suspended = 1;
+   } else {
+   host-suspended = 0;
+   mmc_host_disable(host-mmc);
+   }
+
+   return ret;
 }
 
 static int davinci_mmcsd_resume(struct platform_device *pdev)
 {
struct mmc_davinci_host *host = platform_get_drvdata(pdev);
+   int ret;
 
-   return mmc_resume_host(host-mmc);
+   if (!host-suspended)
+   return 0;
+
+   clk_enable(host-clk);
+   mmc_host_enable(host-mmc);
+
+   mmc_davinci_reset_ctrl(host, 0);
+   ret = mmc_resume_host(host-mmc);
+   if (!ret)
+   host-suspended = 0;
+
+   return ret;
 }
 #else
 #define davinci_mmcsd_suspend  NULL
-- 
1.5.6

___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


[PATCH 1/2] davinci: MMC: Add a function to control reset state of the controller

2009-12-17 Thread Chaithrika U S
Add a helper function which will aid in changing the reset
status of the controller.

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
Applies to Linus' kernel tree.

 drivers/mmc/host/davinci_mmc.c |   37 -
 1 files changed, 16 insertions(+), 21 deletions(-)

diff --git a/drivers/mmc/host/davinci_mmc.c b/drivers/mmc/host/davinci_mmc.c
index dd45e7c..25645bf 100644
--- a/drivers/mmc/host/davinci_mmc.c
+++ b/drivers/mmc/host/davinci_mmc.c
@@ -884,19 +884,26 @@ static void mmc_davinci_cmd_done(struct mmc_davinci_host 
*host,
}
 }
 
-static void
-davinci_abort_data(struct mmc_davinci_host *host, struct mmc_data *data)
+static inline void mmc_davinci_reset_ctrl(struct mmc_davinci_host *host,
+   int val)
 {
u32 temp;
 
-   /* reset command and data state machines */
temp = readl(host-base + DAVINCI_MMCCTL);
-   writel(temp | MMCCTL_CMDRST | MMCCTL_DATRST,
-   host-base + DAVINCI_MMCCTL);
+   if (val)/* reset */
+   temp |= MMCCTL_CMDRST | MMCCTL_DATRST;
+   else/* enable */
+   temp = ~(MMCCTL_CMDRST | MMCCTL_DATRST);
 
-   temp = ~(MMCCTL_CMDRST | MMCCTL_DATRST);
-   udelay(10);
writel(temp, host-base + DAVINCI_MMCCTL);
+   udelay(10);
+}
+
+static void
+davinci_abort_data(struct mmc_davinci_host *host, struct mmc_data *data)
+{
+   mmc_davinci_reset_ctrl(host, 1);
+   mmc_davinci_reset_ctrl(host, 0);
 }
 
 static irqreturn_t mmc_davinci_irq(int irq, void *dev_id)
@@ -1100,15 +1107,8 @@ static inline void mmc_davinci_cpufreq_deregister(struct 
mmc_davinci_host *host)
 #endif
 static void __init init_mmcsd_host(struct mmc_davinci_host *host)
 {
-   /* DAT line portion is diabled and in reset state */
-   writel(readl(host-base + DAVINCI_MMCCTL) | MMCCTL_DATRST,
-   host-base + DAVINCI_MMCCTL);
-
-   /* CMD line portion is diabled and in reset state */
-   writel(readl(host-base + DAVINCI_MMCCTL) | MMCCTL_CMDRST,
-   host-base + DAVINCI_MMCCTL);
 
-   udelay(10);
+   mmc_davinci_reset_ctrl(host, 1);
 
writel(0, host-base + DAVINCI_MMCCLK);
writel(MMCCLK_CLKEN, host-base + DAVINCI_MMCCLK);
@@ -1116,12 +1116,7 @@ static void __init init_mmcsd_host(struct 
mmc_davinci_host *host)
writel(0x1FFF, host-base + DAVINCI_MMCTOR);
writel(0x, host-base + DAVINCI_MMCTOD);
 
-   writel(readl(host-base + DAVINCI_MMCCTL)  ~MMCCTL_DATRST,
-   host-base + DAVINCI_MMCCTL);
-   writel(readl(host-base + DAVINCI_MMCCTL)  ~MMCCTL_CMDRST,
-   host-base + DAVINCI_MMCCTL);
-
-   udelay(10);
+   mmc_davinci_reset_ctrl(host, 0);
 }
 
 static int __init davinci_mmcsd_probe(struct platform_device *pdev)
-- 
1.5.6

___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


Audio quality with CPU frequency scaling

2009-12-16 Thread Chaithrika U S
Kevin,

With the cpufreq support on DA850/OMAP-L138 SoC we are observing
that audio does not function as expected at all sampling rates
for various operating points. At a CPU frequency of 96MHz, audio
works fine with a sampling frequency of 8kHz. For other sampling
rates, there are lot of underrun/overrun errors. This is because
of EDMA also runs at a lower speed and is not able to transfer
data at the desired rate.

To overcome the above, we can depend on the user to set the scaling
min frequency to be the same as scaling max frequency (in this case
300 MHz) before starting aplay/arecord or temporarily move to 
performance governor so that the audio quality is not affected.

Do you think this is the right approach to this problem? Any other
solutions you suggest exploring?

Regards,
Chaithrika



___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


[PATCH] davinci: clock: Check CLK_PSC flag before disabling PSC

2009-12-15 Thread Chaithrika U S
Some modules do not have PSC to control their clocks.
The 'lpsc' field in the clk structure is 0 for such clocks.

In the clock disable function check for CLK PSC flag before
disabling the PSC. If this is not taken care of then it may
so happen that module controlled by LPSC 0 is erroneously disabled.

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
 arch/arm/mach-davinci/clock.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-davinci/clock.c b/arch/arm/mach-davinci/clock.c
index e46a643..f097f8d 100644
--- a/arch/arm/mach-davinci/clock.c
+++ b/arch/arm/mach-davinci/clock.c
@@ -49,7 +49,8 @@ static void __clk_disable(struct clk *clk)
 {
if (WARN_ON(atomic_read(clk-usecount) == 0))
return;
-   if (atomic_dec_and_test(clk-usecount)  !(clk-flags  CLK_PLL))
+   if (atomic_dec_and_test(clk-usecount)  !(clk-flags  CLK_PLL)
+(clk-flags  CLK_PSC))
davinci_psc_config(psc_domain(clk), clk-gpsc, clk-lpsc, 0);
if (clk-parent)
__clk_disable(clk-parent);
-- 
1.5.6

___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


RE: [PATCH v2 0/4] i2c: davinci: Add power management features

2009-12-15 Thread Chaithrika U S
Hi All,

Do you have any review comments/suggestions for this
patch series?

Regards, 
Chaithrika

On Tue, Dec 08, 2009 at 15:43:34, Chaithrika U S wrote:
 Add suspend/resume and cpufreq features to DaVinci I2C driver
 All patches apply to Linus' kernel tree.
 Testing of these features was done on DA850/OMAP-L138 EVM.
 
 Chaithrika U S (4):
   i2c: davinci: Remove MOD_REG_BIT and IO_ADDRESS usage
   i2c: davinci: Add helper functions
   i2c: davinci: Add suspend/resume support
   i2c: davinci: Add cpufreq support
 
  drivers/i2c/busses/i2c-davinci.c |  224 
 --
  1 files changed, 168 insertions(+), 56 deletions(-)
 




___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


RE: [PATCH v2 2/4] i2c: davinci: Add helper functions

2009-12-10 Thread Chaithrika U S
On Tue, Dec 08, 2009 at 16:54:31, Sergei Shtylyov wrote:
 Hello.
 
 Chaithrika U S wrote:
 
  Add i2c reset control and clock divider calculation functions
  which will be useful for power management features.
 
  Signed-off-by: Chaithrika U S chaithr...@ti.com

 
 [...]
 
  @@ -138,15 +147,6 @@ static int i2c_davinci_init(struct davinci_i2c_dev 
  *dev)
  u32 clkh;
  u32 clkl;
  u32 input_clock = clk_get_rate(dev-clk);
  -   u16 w;
  -
  -   if (!pdata)
  -   pdata = davinci_i2c_platform_data_default;
  -
  -   /* put I2C into reset */
  -   w = davinci_i2c_read_reg(dev, DAVINCI_I2C_MDR_REG);
  -   w = ~DAVINCI_I2C_MDR_IRS;
  -   davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, w);
   
  /* NOTE: I2C Clock divider programming info
   * As per I2C specs the following formulas provide prescaler
  @@ -178,12 +178,32 @@ static int i2c_davinci_init(struct davinci_i2c_dev 
  *dev)
  davinci_i2c_write_reg(dev, DAVINCI_I2C_CLKH_REG, clkh);
  davinci_i2c_write_reg(dev, DAVINCI_I2C_CLKL_REG, clkl);
   
  +   dev_dbg(dev-dev, input_clock = %d, CLK = %d\n, input_clock, clk);
  +}
  +
  +/*
  + * This function configures I2C and brings I2C out of reset.
  + * This function is called during I2C init function. This function
  + * also gets called if I2C encounters any errors.
  + */
  +static int i2c_davinci_init(struct davinci_i2c_dev *dev)
  +{
  +   struct davinci_i2c_platform_data *pdata = dev-dev-platform_data;
  +
  +   if (!pdata)
  +   pdata = davinci_i2c_platform_data_default;

 
The very idea of default platform data seems doubtful. Could we 
 remove it?
 

This platform data is used to set the default parameters in case the 
platform is not specifying it. I am not too sure of why it is different
from other drivers where an error is raised if the platform data is missing.
May be this update can be made as a separate patch out of this series.

Regards, 
Chaithrika


___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


[PATCH v2 4/4] i2c: davinci: Add cpufreq support

2009-12-08 Thread Chaithrika U S
Add cpufreq support for DaVinci I2C driver.
Tested on DA850/OMAP-L138 EVM. For the purpose of testing, the patches
which add cpufreq support [1] for this SoC are needed.

[1]http://linux.davincidsp.com/pipermail/davinci-linux-open-source/
2009-September/016118.html

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
 drivers/i2c/busses/i2c-davinci.c |   63 ++
 1 files changed, 63 insertions(+), 0 deletions(-)

diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
index c1c2909..0eed4d6 100644
--- a/drivers/i2c/busses/i2c-davinci.c
+++ b/drivers/i2c/busses/i2c-davinci.c
@@ -35,6 +35,7 @@
 #include linux/interrupt.h
 #include linux/platform_device.h
 #include linux/io.h
+#include linux/cpufreq.h
 
 #include mach/hardware.h
 #include mach/i2c.h
@@ -105,6 +106,10 @@ struct davinci_i2c_dev {
int irq;
u8  terminate;
struct i2c_adapter  adapter;
+#ifdef CONFIG_CPU_FREQ
+   struct completion   xfr_complete;
+   struct notifier_block   freq_transition;
+#endif
 };
 
 /* default platform data to use if not supplied in the platform_device */
@@ -375,6 +380,11 @@ i2c_davinci_xfer(struct i2c_adapter *adap, struct i2c_msg 
msgs[], int num)
if (ret  0)
return ret;
}
+
+#ifdef CONFIG_CPU_FREQ
+   complete(dev-xfr_complete);
+#endif
+
return num;
 }
 
@@ -499,6 +509,48 @@ static irqreturn_t i2c_davinci_isr(int this_irq, void 
*dev_id)
return count ? IRQ_HANDLED : IRQ_NONE;
 }
 
+#ifdef CONFIG_CPU_FREQ
+static int i2c_davinci_cpufreq_transition(struct notifier_block *nb,
+unsigned long val, void *data)
+{
+   struct davinci_i2c_dev *dev;
+
+   dev = container_of(nb, struct davinci_i2c_dev, freq_transition);
+   if (val == CPUFREQ_PRECHANGE) {
+   wait_for_completion(dev-xfr_complete);
+   davinci_i2c_reset_ctrl(dev, 0);
+   } else if (val == CPUFREQ_POSTCHANGE) {
+   i2c_davinci_calc_clk_dividers(dev);
+   davinci_i2c_reset_ctrl(dev, 1);
+   }
+
+   return 0;
+}
+
+static inline int i2c_davinci_cpufreq_register(struct davinci_i2c_dev *dev)
+{
+   dev-freq_transition.notifier_call = i2c_davinci_cpufreq_transition;
+
+   return cpufreq_register_notifier(dev-freq_transition,
+CPUFREQ_TRANSITION_NOTIFIER);
+}
+
+static inline void i2c_davinci_cpufreq_deregister(struct davinci_i2c_dev *dev)
+{
+   cpufreq_unregister_notifier(dev-freq_transition,
+   CPUFREQ_TRANSITION_NOTIFIER);
+}
+#else
+static inline int i2c_davinci_cpufreq_register(struct davinci_i2c_dev *dev)
+{
+   return 0;
+}
+
+static inline void i2c_davinci_cpufreq_deregister(struct davinci_i2c_dev *dev)
+{
+}
+#endif
+
 static struct i2c_algorithm i2c_davinci_algo = {
.master_xfer= i2c_davinci_xfer,
.functionality  = i2c_davinci_func,
@@ -538,6 +590,9 @@ static int davinci_i2c_probe(struct platform_device *pdev)
}
 
init_completion(dev-cmd_complete);
+#ifdef CONFIG_CPU_FREQ
+   init_completion(dev-xfr_complete);
+#endif
dev-dev = get_device(pdev-dev);
dev-irq = irq-start;
platform_set_drvdata(pdev, dev);
@@ -563,6 +618,12 @@ static int davinci_i2c_probe(struct platform_device *pdev)
goto err_unuse_clocks;
}
 
+   r = i2c_davinci_cpufreq_register(dev);
+   if (r) {
+   dev_err(pdev-dev, failed to register cpufreq\n);
+   goto err_free_irq;
+   }
+
adap = dev-adapter;
i2c_set_adapdata(adap, dev);
adap-owner = THIS_MODULE;
@@ -604,6 +665,8 @@ static int davinci_i2c_remove(struct platform_device *pdev)
struct davinci_i2c_dev *dev = platform_get_drvdata(pdev);
struct resource *mem;
 
+   i2c_davinci_cpufreq_deregister(dev);
+
platform_set_drvdata(pdev, NULL);
i2c_del_adapter(dev-adapter);
put_device(pdev-dev);
-- 
1.5.6

___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


[PATCH v2 0/4] i2c: davinci: Add power management features

2009-12-08 Thread Chaithrika U S
Add suspend/resume and cpufreq features to DaVinci I2C driver
All patches apply to Linus' kernel tree.
Testing of these features was done on DA850/OMAP-L138 EVM.

Chaithrika U S (4):
  i2c: davinci: Remove MOD_REG_BIT and IO_ADDRESS usage
  i2c: davinci: Add helper functions
  i2c: davinci: Add suspend/resume support
  i2c: davinci: Add cpufreq support

 drivers/i2c/busses/i2c-davinci.c |  224 --
 1 files changed, 168 insertions(+), 56 deletions(-)

___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


[PATCH v2 1/4] i2c: davinci: Remove MOD_REG_BIT and IO_ADDRESS usage

2009-12-08 Thread Chaithrika U S
Cleanup the DaVinci I2C driver. Remove MOD_REG_BIT macro.
Also use ioremap instead of IO_ADDRESS macro.

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
 drivers/i2c/busses/i2c-davinci.c |   77 +++---
 1 files changed, 38 insertions(+), 39 deletions(-)

diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
index c89687a..44a3cb3 100644
--- a/drivers/i2c/busses/i2c-davinci.c
+++ b/drivers/i2c/busses/i2c-davinci.c
@@ -37,7 +37,6 @@
 #include linux/io.h
 
 #include mach/hardware.h
-
 #include mach/i2c.h
 
 /* - global defines --- */
@@ -71,37 +70,29 @@
 #define DAVINCI_I2C_IVR_NACK   0x02
 #define DAVINCI_I2C_IVR_AL 0x01
 
-#define DAVINCI_I2C_STR_BB (1  12)
-#define DAVINCI_I2C_STR_RSFULL (1  11)
-#define DAVINCI_I2C_STR_SCD(1  5)
-#define DAVINCI_I2C_STR_ARDY   (1  2)
-#define DAVINCI_I2C_STR_NACK   (1  1)
-#define DAVINCI_I2C_STR_AL (1  0)
-
-#define DAVINCI_I2C_MDR_NACK   (1  15)
-#define DAVINCI_I2C_MDR_STT(1  13)
-#define DAVINCI_I2C_MDR_STP(1  11)
-#define DAVINCI_I2C_MDR_MST(1  10)
-#define DAVINCI_I2C_MDR_TRX(1  9)
-#define DAVINCI_I2C_MDR_XA (1  8)
-#define DAVINCI_I2C_MDR_RM (1  7)
-#define DAVINCI_I2C_MDR_IRS(1  5)
-
-#define DAVINCI_I2C_IMR_AAS(1  6)
-#define DAVINCI_I2C_IMR_SCD(1  5)
-#define DAVINCI_I2C_IMR_XRDY   (1  4)
-#define DAVINCI_I2C_IMR_RRDY   (1  3)
-#define DAVINCI_I2C_IMR_ARDY   (1  2)
-#define DAVINCI_I2C_IMR_NACK   (1  1)
-#define DAVINCI_I2C_IMR_AL (1  0)
-
-#define MOD_REG_BIT(val, mask, set) do { \
-   if (set) { \
-   val |= mask; \
-   } else { \
-   val = ~mask; \
-   } \
-} while (0)
+#define DAVINCI_I2C_STR_BB BIT(12)
+#define DAVINCI_I2C_STR_RSFULL BIT(11)
+#define DAVINCI_I2C_STR_SCDBIT(5)
+#define DAVINCI_I2C_STR_ARDY   BIT(2)
+#define DAVINCI_I2C_STR_NACK   BIT(1)
+#define DAVINCI_I2C_STR_AL BIT(0)
+
+#define DAVINCI_I2C_MDR_NACK   BIT(15)
+#define DAVINCI_I2C_MDR_STTBIT(13)
+#define DAVINCI_I2C_MDR_STPBIT(11)
+#define DAVINCI_I2C_MDR_MSTBIT(10)
+#define DAVINCI_I2C_MDR_TRXBIT(9)
+#define DAVINCI_I2C_MDR_XA BIT(8)
+#define DAVINCI_I2C_MDR_RM BIT(7)
+#define DAVINCI_I2C_MDR_IRSBIT(5)
+
+#define DAVINCI_I2C_IMR_AASBIT(6)
+#define DAVINCI_I2C_IMR_SCDBIT(5)
+#define DAVINCI_I2C_IMR_XRDY   BIT(4)
+#define DAVINCI_I2C_IMR_RRDY   BIT(3)
+#define DAVINCI_I2C_IMR_ARDY   BIT(2)
+#define DAVINCI_I2C_IMR_NACK   BIT(1)
+#define DAVINCI_I2C_IMR_AL BIT(0)
 
 struct davinci_i2c_dev {
struct device   *dev;
@@ -154,7 +145,7 @@ static int i2c_davinci_init(struct davinci_i2c_dev *dev)
 
/* put I2C into reset */
w = davinci_i2c_read_reg(dev, DAVINCI_I2C_MDR_REG);
-   MOD_REG_BIT(w, DAVINCI_I2C_MDR_IRS, 0);
+   w = ~DAVINCI_I2C_MDR_IRS;
davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, w);
 
/* NOTE: I2C Clock divider programming info
@@ -204,7 +195,7 @@ static int i2c_davinci_init(struct davinci_i2c_dev *dev)
 
/* Take the I2C module out of reset: */
w = davinci_i2c_read_reg(dev, DAVINCI_I2C_MDR_REG);
-   MOD_REG_BIT(w, DAVINCI_I2C_MDR_IRS, 1);
+   w |= DAVINCI_I2C_MDR_IRS;
davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, w);
 
/* Enable interrupts */
@@ -284,9 +275,9 @@ i2c_davinci_xfer_msg(struct i2c_adapter *adap, struct 
i2c_msg *msg, int stop)
/* Enable receive or transmit interrupts */
w = davinci_i2c_read_reg(dev, DAVINCI_I2C_IMR_REG);
if (msg-flags  I2C_M_RD)
-   MOD_REG_BIT(w, DAVINCI_I2C_IMR_RRDY, 1);
+   w |= DAVINCI_I2C_IMR_RRDY;
else
-   MOD_REG_BIT(w, DAVINCI_I2C_IMR_XRDY, 1);
+   w |= DAVINCI_I2C_IMR_XRDY;
davinci_i2c_write_reg(dev, DAVINCI_I2C_IMR_REG, w);
 
dev-terminate = 0;
@@ -333,7 +324,7 @@ i2c_davinci_xfer_msg(struct i2c_adapter *adap, struct 
i2c_msg *msg, int stop)
return msg-len;
if (stop) {
w = davinci_i2c_read_reg(dev, DAVINCI_I2C_MDR_REG);
-   MOD_REG_BIT(w, DAVINCI_I2C_MDR_STP, 1);
+   w |= DAVINCI_I2C_MDR_STP;
davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, w);
}
return -EREMOTEIO;
@@ -461,7 +452,7 @@ static irqreturn_t i2c_davinci_isr(int this_irq, void 
*dev_id)
 
w = davinci_i2c_read_reg(dev,
 DAVINCI_I2C_IMR_REG);
-   MOD_REG_BIT(w, DAVINCI_I2C_IMR_XRDY, 0);
+   w = ~DAVINCI_I2C_IMR_XRDY;
davinci_i2c_write_reg(dev,
  DAVINCI_I2C_IMR_REG,
  w);
@@ -540,7 +531,12 @@ static int

[PATCH v2 2/4] i2c: davinci: Add helper functions

2009-12-08 Thread Chaithrika U S
Add i2c reset control and clock divider calculation functions
which will be useful for power management features.

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
 drivers/i2c/busses/i2c-davinci.c |   56 +-
 1 files changed, 37 insertions(+), 19 deletions(-)

diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
index 44a3cb3..81c1049 100644
--- a/drivers/i2c/busses/i2c-davinci.c
+++ b/drivers/i2c/busses/i2c-davinci.c
@@ -124,12 +124,21 @@ static inline u16 davinci_i2c_read_reg(struct 
davinci_i2c_dev *i2c_dev, int reg)
return __raw_readw(i2c_dev-base + reg);
 }
 
-/*
- * This functions configures I2C and brings I2C out of reset.
- * This function is called during I2C init function. This function
- * also gets called if I2C encounters any errors.
- */
-static int i2c_davinci_init(struct davinci_i2c_dev *dev)
+static inline void davinci_i2c_reset_ctrl(struct davinci_i2c_dev *i2c_dev,
+   int val)
+{
+   u16 w;
+
+   w = davinci_i2c_read_reg(i2c_dev, DAVINCI_I2C_MDR_REG);
+   if (!val)   /* put I2C into reset */
+   w = ~DAVINCI_I2C_MDR_IRS;
+   else/* take I2C out of reset */
+   w |= DAVINCI_I2C_MDR_IRS;
+
+   davinci_i2c_write_reg(i2c_dev, DAVINCI_I2C_MDR_REG, w);
+}
+
+static void i2c_davinci_calc_clk_dividers(struct davinci_i2c_dev *dev)
 {
struct davinci_i2c_platform_data *pdata = dev-dev-platform_data;
u16 psc;
@@ -138,15 +147,6 @@ static int i2c_davinci_init(struct davinci_i2c_dev *dev)
u32 clkh;
u32 clkl;
u32 input_clock = clk_get_rate(dev-clk);
-   u16 w;
-
-   if (!pdata)
-   pdata = davinci_i2c_platform_data_default;
-
-   /* put I2C into reset */
-   w = davinci_i2c_read_reg(dev, DAVINCI_I2C_MDR_REG);
-   w = ~DAVINCI_I2C_MDR_IRS;
-   davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, w);
 
/* NOTE: I2C Clock divider programming info
 * As per I2C specs the following formulas provide prescaler
@@ -178,12 +178,32 @@ static int i2c_davinci_init(struct davinci_i2c_dev *dev)
davinci_i2c_write_reg(dev, DAVINCI_I2C_CLKH_REG, clkh);
davinci_i2c_write_reg(dev, DAVINCI_I2C_CLKL_REG, clkl);
 
+   dev_dbg(dev-dev, input_clock = %d, CLK = %d\n, input_clock, clk);
+}
+
+/*
+ * This function configures I2C and brings I2C out of reset.
+ * This function is called during I2C init function. This function
+ * also gets called if I2C encounters any errors.
+ */
+static int i2c_davinci_init(struct davinci_i2c_dev *dev)
+{
+   struct davinci_i2c_platform_data *pdata = dev-dev-platform_data;
+
+   if (!pdata)
+   pdata = davinci_i2c_platform_data_default;
+
+   /* put I2C into reset */
+   davinci_i2c_reset_ctrl(dev, 0);
+
+   /* compute clock dividers */
+   i2c_davinci_calc_clk_dividers(dev);
+
/* Respond at reserved SMBus Host slave address (and zero);
 * we seem to have no option to not respond...
 */
davinci_i2c_write_reg(dev, DAVINCI_I2C_OAR_REG, 0x08);
 
-   dev_dbg(dev-dev, input_clock = %d, CLK = %d\n, input_clock, clk);
dev_dbg(dev-dev, PSC  = %d\n,
davinci_i2c_read_reg(dev, DAVINCI_I2C_PSC_REG));
dev_dbg(dev-dev, CLKL = %d\n,
@@ -194,9 +214,7 @@ static int i2c_davinci_init(struct davinci_i2c_dev *dev)
pdata-bus_freq, pdata-bus_delay);
 
/* Take the I2C module out of reset: */
-   w = davinci_i2c_read_reg(dev, DAVINCI_I2C_MDR_REG);
-   w |= DAVINCI_I2C_MDR_IRS;
-   davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, w);
+   davinci_i2c_reset_ctrl(dev, 1);
 
/* Enable interrupts */
davinci_i2c_write_reg(dev, DAVINCI_I2C_IMR_REG, I2C_DAVINCI_INTR_ALL);
-- 
1.5.6

___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


[PATCH v2 3/4] i2c: davinci: Add suspend/resume support

2009-12-08 Thread Chaithrika U S
Add suspend and resume callbacks to DaVinci I2C driver.
This has been tested on DA850/OMAP-L138 EVM. The SoC specific
suspend-to-RAM support patch series [1] is needed to test this feature.

[1] http://linux.davincidsp.com/pipermail/davinci-linux-open-source/
2009-November/016958.html

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
 drivers/i2c/busses/i2c-davinci.c |   32 
 1 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
index 81c1049..c1c2909 100644
--- a/drivers/i2c/busses/i2c-davinci.c
+++ b/drivers/i2c/busses/i2c-davinci.c
@@ -622,6 +622,36 @@ static int davinci_i2c_remove(struct platform_device *pdev)
return 0;
 }
 
+#ifdef CONFIG_PM
+static int davinci_i2c_suspend(struct platform_device *pdev, pm_message_t 
state)
+{
+   struct davinci_i2c_dev *dev = platform_get_drvdata(pdev);
+
+   /* put I2C into reset */
+   davinci_i2c_reset_ctrl(dev, 0);
+
+   clk_disable(dev-clk);
+
+   return 0;
+}
+
+static int davinci_i2c_resume(struct platform_device *pdev)
+{
+   struct davinci_i2c_dev *dev = platform_get_drvdata(pdev);
+
+   clk_enable(dev-clk);
+
+   /* take I2C out of reset */
+   davinci_i2c_reset_ctrl(dev, 1);
+
+   return 0;
+}
+
+#else
+#define davinci_i2c_suspend NULL
+#define davinci_i2c_resume NULL
+#endif
+
 /* work with hotplug and coldplug */
 MODULE_ALIAS(platform:i2c_davinci);
 
@@ -632,6 +662,8 @@ static struct platform_driver davinci_i2c_driver = {
.name   = i2c_davinci,
.owner  = THIS_MODULE,
},
+   .suspend= davinci_i2c_suspend,
+   .resume = davinci_i2c_resume,
 };
 
 /* I2C may be needed to bring up other drivers */
-- 
1.5.6

___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


[PATCH 3/3] i2c: davinci: Add cpufreq support

2009-12-07 Thread Chaithrika U S
Add cpufreq support for DaVinci I2C driver.
Tested on DA850/OMAP-L138 EVM. For the purpose of testing, the patches
which add cpufreq support [1] for this SoC are needed.

[1]http://linux.davincidsp.com/pipermail/davinci-linux-open-source/
2009-September/016118.html

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
 drivers/i2c/busses/i2c-davinci.c |   59 +-
 1 files changed, 58 insertions(+), 1 deletions(-)

diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
index 5f0888d..0f41da4 100644
--- a/drivers/i2c/busses/i2c-davinci.c
+++ b/drivers/i2c/busses/i2c-davinci.c
@@ -35,9 +35,9 @@
 #include linux/interrupt.h
 #include linux/platform_device.h
 #include linux/io.h
+#include linux/cpufreq.h
 
 #include mach/hardware.h
-
 #include mach/i2c.h
 
 /* - global defines --- */
@@ -114,6 +114,10 @@ struct davinci_i2c_dev {
int irq;
u8  terminate;
struct i2c_adapter  adapter;
+#ifdef CONFIG_CPU_FREQ
+   struct completion   xfr_complete;
+   struct notifier_block   freq_transition;
+#endif
 };
 
 /* default platform data to use if not supplied in the platform_device */
@@ -384,6 +388,11 @@ i2c_davinci_xfer(struct i2c_adapter *adap, struct i2c_msg 
msgs[], int num)
if (ret  0)
return ret;
}
+
+#ifdef CONFIG_CPU_FREQ
+   complete(dev-xfr_complete);
+#endif
+
return num;
 }
 
@@ -508,6 +517,39 @@ static irqreturn_t i2c_davinci_isr(int this_irq, void 
*dev_id)
return count ? IRQ_HANDLED : IRQ_NONE;
 }
 
+#ifdef CONFIG_CPU_FREQ
+static int i2c_davinci_cpufreq_transition(struct notifier_block *nb,
+unsigned long val, void *data)
+{
+   struct davinci_i2c_dev *dev;
+
+   dev = container_of(nb, struct davinci_i2c_dev, freq_transition);
+   if (val == CPUFREQ_PRECHANGE) {
+   wait_for_completion(dev-xfr_complete);
+   davinci_i2c_reset_ctrl(dev, 0);
+   } else if (val == CPUFREQ_POSTCHANGE) {
+   i2c_davinci_calc_clk_dividers(dev);
+   davinci_i2c_reset_ctrl(dev, 1);
+   }
+
+   return 0;
+}
+
+static inline int i2c_davinci_cpufreq_register(struct davinci_i2c_dev *dev)
+{
+   dev-freq_transition.notifier_call = i2c_davinci_cpufreq_transition;
+
+   return cpufreq_register_notifier(dev-freq_transition,
+CPUFREQ_TRANSITION_NOTIFIER);
+}
+
+static inline void i2c_davinci_cpufreq_deregister(struct davinci_i2c_dev *dev)
+{
+   cpufreq_unregister_notifier(dev-freq_transition,
+   CPUFREQ_TRANSITION_NOTIFIER);
+}
+#endif
+
 static struct i2c_algorithm i2c_davinci_algo = {
.master_xfer= i2c_davinci_xfer,
.functionality  = i2c_davinci_func,
@@ -547,6 +589,9 @@ static int davinci_i2c_probe(struct platform_device *pdev)
}
 
init_completion(dev-cmd_complete);
+#ifdef CONFIG_CPU_FREQ
+   init_completion(dev-xfr_complete);
+#endif
dev-dev = get_device(pdev-dev);
dev-irq = irq-start;
platform_set_drvdata(pdev, dev);
@@ -567,6 +612,14 @@ static int davinci_i2c_probe(struct platform_device *pdev)
goto err_unuse_clocks;
}
 
+#ifdef CONFIG_CPU_FREQ
+   r = i2c_davinci_cpufreq_register(dev);
+   if (r) {
+   dev_err(pdev-dev, failed to register cpufreq\n);
+   goto err_free_irq;
+   }
+#endif
+
adap = dev-adapter;
i2c_set_adapdata(adap, dev);
adap-owner = THIS_MODULE;
@@ -606,6 +659,10 @@ static int davinci_i2c_remove(struct platform_device *pdev)
struct davinci_i2c_dev *dev = platform_get_drvdata(pdev);
struct resource *mem;
 
+#ifdef CONFIG_CPU_FREQ
+   i2c_davinci_cpufreq_deregister(dev);
+#endif
+
platform_set_drvdata(pdev, NULL);
i2c_del_adapter(dev-adapter);
put_device(pdev-dev);
-- 
1.5.6

___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


[PATCH 0/3] i2c: davinci: Add power management features

2009-12-07 Thread Chaithrika U S
Add suspend/resume and cpufreq features to DaVinci I2C driver
All patches apply to Linus' kernel tree.
Testing of these features was done on DA850/OMAP-L138 EVM.

Chaithrika U S (3):
  i2c: davinci: Add helper functions
  i2c: davinci: Add suspend/resume support
  i2c: davinci: Add cpufreq support

 drivers/i2c/busses/i2c-davinci.c |  147 -
 1 files changed, 127 insertions(+), 20 deletions(-)

___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


[PATCH 2/3] i2c: davinci: Add suspend/resume support

2009-12-07 Thread Chaithrika U S
Add suspend and resume callbacks to DaVinci I2C driver.
This has been tested on DA850/OMAP-L138 EVM. The SoC specific
suspend-to-RAM support patch series [1] is needed to test this feature.

[1] http://linux.davincidsp.com/pipermail/davinci-linux-open-source/
2009-November/016958.html

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
 drivers/i2c/busses/i2c-davinci.c |   32 
 1 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
index 5f3838c..5f0888d 100644
--- a/drivers/i2c/busses/i2c-davinci.c
+++ b/drivers/i2c/busses/i2c-davinci.c
@@ -623,6 +623,36 @@ static int davinci_i2c_remove(struct platform_device *pdev)
return 0;
 }
 
+#ifdef CONFIG_PM
+static int davinci_i2c_suspend(struct platform_device *pdev, pm_message_t 
state)
+{
+   struct davinci_i2c_dev *dev = platform_get_drvdata(pdev);
+
+   /* put I2C into reset */
+   davinci_i2c_reset_ctrl(dev, 0);
+
+   clk_disable(dev-clk);
+
+   return 0;
+}
+
+static int davinci_i2c_resume(struct platform_device *pdev)
+{
+   struct davinci_i2c_dev *dev = platform_get_drvdata(pdev);
+
+   clk_enable(dev-clk);
+
+   /* take I2C out of reset */
+   davinci_i2c_reset_ctrl(dev, 1);
+
+   return 0;
+}
+
+#else
+#define davinci_i2c_suspend NULL
+#define davinci_i2c_resume NULL
+#endif
+
 /* work with hotplug and coldplug */
 MODULE_ALIAS(platform:i2c_davinci);
 
@@ -633,6 +663,8 @@ static struct platform_driver davinci_i2c_driver = {
.name   = i2c_davinci,
.owner  = THIS_MODULE,
},
+   .suspend= davinci_i2c_suspend,
+   .resume = davinci_i2c_resume,
 };
 
 /* I2C may be needed to bring up other drivers */
-- 
1.5.6

___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


RE: [PATCH 3/3] i2c: davinci: Add cpufreq support

2009-12-07 Thread Chaithrika U S
On Mon, Dec 07, 2009 at 16:30:14, Sergei Shtylyov wrote:
 Hello.
 
 Chaithrika U S wrote:
 
  Add cpufreq support for DaVinci I2C driver.
  Tested on DA850/OMAP-L138 EVM. For the purpose of testing, the patches
  which add cpufreq support [1] for this SoC are needed.
 
  [1]http://linux.davincidsp.com/pipermail/davinci-linux-open-source/
  2009-September/016118.html
 
  Signed-off-by: Chaithrika U S chaithr...@ti.com
  ---
   drivers/i2c/busses/i2c-davinci.c |   59 
  +-
   1 files changed, 58 insertions(+), 1 deletions(-)
 
  diff --git a/drivers/i2c/busses/i2c-davinci.c 
  b/drivers/i2c/busses/i2c-davinci.c
  index 5f0888d..0f41da4 100644
  --- a/drivers/i2c/busses/i2c-davinci.c
  +++ b/drivers/i2c/busses/i2c-davinci.c
 
 [...]
 
  @@ -508,6 +517,39 @@ static irqreturn_t i2c_davinci_isr(int this_irq, void 
  *dev_id)
  return count ? IRQ_HANDLED : IRQ_NONE;
   }
   
  +#ifdef CONFIG_CPU_FREQ
  +static int i2c_davinci_cpufreq_transition(struct notifier_block *nb,
  +unsigned long val, void *data)
  +{
  +   struct davinci_i2c_dev *dev;
  +
  +   dev = container_of(nb, struct davinci_i2c_dev, freq_transition);
  +   if (val == CPUFREQ_PRECHANGE) {
  +   wait_for_completion(dev-xfr_complete);
  +   davinci_i2c_reset_ctrl(dev, 0);
  +   } else if (val == CPUFREQ_POSTCHANGE) {
  +   i2c_davinci_calc_clk_dividers(dev);
  +   davinci_i2c_reset_ctrl(dev, 1);
  +   }
  +
  +   return 0;
  +}
  +
  +static inline int i2c_davinci_cpufreq_register(struct davinci_i2c_dev *dev)
  +{
  +   dev-freq_transition.notifier_call = i2c_davinci_cpufreq_transition;
  +
  +   return cpufreq_register_notifier(dev-freq_transition,
  +CPUFREQ_TRANSITION_NOTIFIER);
  +}
  +
  +static inline void i2c_davinci_cpufreq_deregister(struct davinci_i2c_dev 
  *dev)
  +{
  +   cpufreq_unregister_notifier(dev-freq_transition,
  +   CPUFREQ_TRANSITION_NOTIFIER);
  +}
  +#endif
  +
   static struct i2c_algorithm i2c_davinci_algo = {
  .master_xfer= i2c_davinci_xfer,
  .functionality  = i2c_davinci_func,
  @@ -547,6 +589,9 @@ static int davinci_i2c_probe(struct platform_device 
  *pdev)
  }
   
  init_completion(dev-cmd_complete);
  +#ifdef CONFIG_CPU_FREQ
  +   init_completion(dev-xfr_complete);
  +#endif
  dev-dev = get_device(pdev-dev);
  dev-irq = irq-start;
  platform_set_drvdata(pdev, dev);
  @@ -567,6 +612,14 @@ static int davinci_i2c_probe(struct platform_device 
  *pdev)
  goto err_unuse_clocks;
  }
   
  +#ifdef CONFIG_CPU_FREQ
  +   r = i2c_davinci_cpufreq_register(dev);
  +   if (r) {
  +   dev_err(pdev-dev, failed to register cpufreq\n);
  +   goto err_free_irq;
  +   }
  +#endif

 
You should instead define this function as just returning 0 in the 
 #else branch above, so that #ifdef here can be avoided...
 
  +
  adap = dev-adapter;
  i2c_set_adapdata(adap, dev);
  adap-owner = THIS_MODULE;
  @@ -606,6 +659,10 @@ static int davinci_i2c_remove(struct platform_device 
  *pdev)
  struct davinci_i2c_dev *dev = platform_get_drvdata(pdev);
  struct resource *mem;
   
  +#ifdef CONFIG_CPU_FREQ
  +   i2c_davinci_cpufreq_deregister(dev);
  +#endif
  +

 
Same comment here. #ifdef's in the function code are frowned upon
 

OK.I will post an updated version of this patch series soon.


Thanks and Regards, 
Chaithrika

 WBR, Sergei
 
 



___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


RE: [PATCH 1/3] i2c: davinci: Add helper functions

2009-12-07 Thread Chaithrika U S
On Mon, Dec 07, 2009 at 23:54:16, Troy Kisky wrote:
 Chaithrika U S wrote:
  Add i2c reset control and clock divider calculation functions
  which will be useful for power management features.
  
  Signed-off-by: Chaithrika U S chaithr...@ti.com
  ---
   drivers/i2c/busses/i2c-davinci.c |   56 
  +-
   1 files changed, 37 insertions(+), 19 deletions(-)
  
  diff --git a/drivers/i2c/busses/i2c-davinci.c 
  b/drivers/i2c/busses/i2c-davinci.c
  index c89687a..5f3838c 100644
  --- a/drivers/i2c/busses/i2c-davinci.c
  +++ b/drivers/i2c/busses/i2c-davinci.c
  @@ -133,12 +133,21 @@ static inline u16 davinci_i2c_read_reg(struct 
  davinci_i2c_dev *i2c_dev, int reg)
  return __raw_readw(i2c_dev-base + reg);
   }
   
  -/*
  - * This functions configures I2C and brings I2C out of reset.
  - * This function is called during I2C init function. This function
  - * also gets called if I2C encounters any errors.
  - */
  -static int i2c_davinci_init(struct davinci_i2c_dev *dev)
  +static inline void davinci_i2c_reset_ctrl(struct davinci_i2c_dev *i2c_dev,
  +   int val)
  +{
  +   u16 w;
  +
  +   w = davinci_i2c_read_reg(i2c_dev, DAVINCI_I2C_MDR_REG);
  +   if (!val)   /* put I2C into reset */
  +   MOD_REG_BIT(w, DAVINCI_I2C_MDR_IRS, 0);
  +   else/* take I2C out of reset */
  +   MOD_REG_BIT(w, DAVINCI_I2C_MDR_IRS, 1);
  +
 
 
 I dislike the MOD_REG_BIT macro. Maybe if you wrote
 MOD_REG_BIT(w, DAVINCI_I2C_MDR_IRS, val);
 
 it would be slightly better, but I still wouldn't like it.
 Please use w = ~DAVINCI_I2C_MDR_IRS and
  w |= DAVINCI_I2C_MDR_IRS directly.
 
 
 I know the code you're replacing uses this obfuscating macro
 but this is a good time to remove it.
 
 

Agree. Will include a patch to remove this macro in the next version of this
patch set.

Regards, 
Chaithrika

  +   davinci_i2c_write_reg(i2c_dev, DAVINCI_I2C_MDR_REG, w);
  +}
  +
  +static void i2c_davinci_calc_clk_dividers(struct davinci_i2c_dev *dev)
   {
  struct davinci_i2c_platform_data *pdata = dev-dev-platform_data;
  u16 psc;
  @@ -147,15 +156,6 @@ static int i2c_davinci_init(struct davinci_i2c_dev 
  *dev)
  u32 clkh;
  u32 clkl;
  u32 input_clock = clk_get_rate(dev-clk);
  -   u16 w;
  -
  -   if (!pdata)
  -   pdata = davinci_i2c_platform_data_default;
  -
  -   /* put I2C into reset */
  -   w = davinci_i2c_read_reg(dev, DAVINCI_I2C_MDR_REG);
  -   MOD_REG_BIT(w, DAVINCI_I2C_MDR_IRS, 0);
  -   davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, w);
   
  /* NOTE: I2C Clock divider programming info
   * As per I2C specs the following formulas provide prescaler
  @@ -187,12 +187,32 @@ static int i2c_davinci_init(struct davinci_i2c_dev 
  *dev)
  davinci_i2c_write_reg(dev, DAVINCI_I2C_CLKH_REG, clkh);
  davinci_i2c_write_reg(dev, DAVINCI_I2C_CLKL_REG, clkl);
   
  +   dev_dbg(dev-dev, input_clock = %d, CLK = %d\n, input_clock, clk);
  +}
  +
  +/*
  + * This functions configures I2C and brings I2C out of reset.
  + * This function is called during I2C init function. This function
  + * also gets called if I2C encounters any errors.
  + */
  +static int i2c_davinci_init(struct davinci_i2c_dev *dev)
  +{
  +   struct davinci_i2c_platform_data *pdata = dev-dev-platform_data;
  +
  +   if (!pdata)
  +   pdata = davinci_i2c_platform_data_default;
  +
  +   /* put I2C into reset */
  +   davinci_i2c_reset_ctrl(dev, 0);
  +
  +   /* compute clock dividers */
  +   i2c_davinci_calc_clk_dividers(dev);
  +
  /* Respond at reserved SMBus Host slave address (and zero);
   * we seem to have no option to not respond...
   */
  davinci_i2c_write_reg(dev, DAVINCI_I2C_OAR_REG, 0x08);
   
  -   dev_dbg(dev-dev, input_clock = %d, CLK = %d\n, input_clock, clk);
  dev_dbg(dev-dev, PSC  = %d\n,
  davinci_i2c_read_reg(dev, DAVINCI_I2C_PSC_REG));
  dev_dbg(dev-dev, CLKL = %d\n,
  @@ -203,9 +223,7 @@ static int i2c_davinci_init(struct davinci_i2c_dev *dev)
  pdata-bus_freq, pdata-bus_delay);
   
  /* Take the I2C module out of reset: */
  -   w = davinci_i2c_read_reg(dev, DAVINCI_I2C_MDR_REG);
  -   MOD_REG_BIT(w, DAVINCI_I2C_MDR_IRS, 1);
  -   davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, w);
  +   davinci_i2c_reset_ctrl(dev, 1);
   
  /* Enable interrupts */
  davinci_i2c_write_reg(dev, DAVINCI_I2C_IMR_REG, I2C_DAVINCI_INTR_ALL);
 


___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


RE: [alsa-devel] [PATCH] ASoC: DaVinci: Update suspend/resume support for McASP driver

2009-12-03 Thread Chaithrika U S
On Wed, Dec 02, 2009 at 14:56:31, Takashi Iwai wrote:
 At Wed,  2 Dec 2009 12:39:00 +0530,
 Chaithrika U S wrote:
  
  diff --git a/sound/soc/davinci/davinci-pcm.c 
  b/sound/soc/davinci/davinci-pcm.c
  index ad4d7f4..80c7fdf 100644
  --- a/sound/soc/davinci/davinci-pcm.c
  +++ b/sound/soc/davinci/davinci-pcm.c
  @@ -49,7 +49,7 @@ static void print_buf_info(int slot, char *name)
   static struct snd_pcm_hardware pcm_hardware_playback = {
  .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER |
   SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |
  -SNDRV_PCM_INFO_PAUSE),
  +SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME),
 
 Note that unless your driver supports the full resume,
 SNDRV_PCM_INFO_RESUME shouldn't be set.  Here, the full resume means
 that the hardware gets back to a completely sane state and the PCM
 streams are resumed without extra PCM prepare call at PM resume.
 If the PCM (or whatever) needs another re-initialization (like in many
 cases), don't set this flag.
 
 Just to be sure...
 
 
 Takashi
 

PCM prepare call is not needed in this case. Testing was done with audio
loopback and after a suspend/resume cycle the audio output was proper. Hope
my understanding is correct. Is this test sufficient to prove that driver
supports full resume?

Regards, 
Chaithrika


___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


RE: [alsa-devel] [PATCH] ASoC: DaVinci: Update suspend/resume support for McASP driver

2009-12-03 Thread Chaithrika U S
On Thu, Dec 03, 2009 at 18:57:17, Mark Brown wrote:
 On Thu, Dec 03, 2009 at 02:13:19PM +0100, Takashi Iwai wrote:
 
  Yeah, if it worked with an actual app, it's fine :)
  That was just a slight concern.
 
 Chaithrika, could you please fix the issue with the comment for
 fallthrough and resubmit?
 

Mark,

I will resubmit this patch soon.

Regards, 
Chaithrika


___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


[PATCH v2] ASoC: DaVinci: Update suspend/resume support for McASP driver

2009-12-03 Thread Chaithrika U S
Add clock enable and disable calls to resume and suspend respectively.
Also add a member to the audio device data structure which tracks the clock
status.

Tested on DA850/OMAP-L138 EVM. For the purpose of testing, the patches[1] which
add suspend-to-RAM support to DA850/OMAP-L138 SoC were applied.

[1] http://linux.davincidsp.com/pipermail/davinci-linux-open-source/
2009-November/016958.html

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
Applies to ALSA GIT tree on branch topic/asoc at
http://git.kernel.org/?p=linux/kernel/git/tiwai/sound-2.6.git;a=shortlog;
h=topic/asoc

 sound/soc/davinci/davinci-mcasp.c |   18 --
 sound/soc/davinci/davinci-mcasp.h |1 +
 sound/soc/davinci/davinci-pcm.c   |2 +-
 3 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/sound/soc/davinci/davinci-mcasp.c 
b/sound/soc/davinci/davinci-mcasp.c
index 0a302e1..a613bbb 100644
--- a/sound/soc/davinci/davinci-mcasp.c
+++ b/sound/soc/davinci/davinci-mcasp.c
@@ -767,14 +767,27 @@ static int davinci_mcasp_trigger(struct snd_pcm_substream 
*substream,
int ret = 0;
 
switch (cmd) {
-   case SNDRV_PCM_TRIGGER_START:
case SNDRV_PCM_TRIGGER_RESUME:
+   if (!dev-clk_active) {
+   clk_enable(dev-clk);
+   dev-clk_active = 1;
+   }
+   /* Fall through */
+   case SNDRV_PCM_TRIGGER_START:
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
davinci_mcasp_start(dev, substream-stream);
break;
 
-   case SNDRV_PCM_TRIGGER_STOP:
case SNDRV_PCM_TRIGGER_SUSPEND:
+   davinci_mcasp_stop(dev, substream-stream);
+   if (dev-clk_active) {
+   clk_disable(dev-clk);
+   dev-clk_active = 0;
+   }
+
+   break;
+
+   case SNDRV_PCM_TRIGGER_STOP:
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
davinci_mcasp_stop(dev, substream-stream);
break;
@@ -866,6 +879,7 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
}
 
clk_enable(dev-clk);
+   dev-clk_active = 1;
 
dev-base = (void __iomem *)IO_ADDRESS(mem-start);
dev-op_mode = pdata-op_mode;
diff --git a/sound/soc/davinci/davinci-mcasp.h 
b/sound/soc/davinci/davinci-mcasp.h
index 582c924..e755b51 100644
--- a/sound/soc/davinci/davinci-mcasp.h
+++ b/sound/soc/davinci/davinci-mcasp.h
@@ -44,6 +44,7 @@ struct davinci_audio_dev {
int sample_rate;
struct clk *clk;
unsigned int codec_fmt;
+   u8 clk_active;
 
/* McASP specific data */
int tdm_slots;
diff --git a/sound/soc/davinci/davinci-pcm.c b/sound/soc/davinci/davinci-pcm.c
index ad4d7f4..80c7fdf 100644
--- a/sound/soc/davinci/davinci-pcm.c
+++ b/sound/soc/davinci/davinci-pcm.c
@@ -49,7 +49,7 @@ static void print_buf_info(int slot, char *name)
 static struct snd_pcm_hardware pcm_hardware_playback = {
.info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER |
 SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |
-SNDRV_PCM_INFO_PAUSE),
+SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME),
.formats = (SNDRV_PCM_FMTBIT_S16_LE),
.rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_32000 |
-- 
1.5.6

___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


[PATCH] ASoC: DaVinci: Update suspend/resume support for McASP driver

2009-12-01 Thread Chaithrika U S
Add clock enable and disable calls to resume and suspend respectively.
Also add a member to the audio device data structure which tracks the clock
status.

Tested on DA850/OMAP-L138 EVM. For the purpose of testing, the patches[1] which 
add suspend-to-RAM support to DA850/OMAP-L138 SoC were applied.

[1] http://linux.davincidsp.com/pipermail/davinci-linux-open-source/
2009-November/016958.html

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
Applies to ALSA GIT tree on branch topic/asoc at
http://git.kernel.org/?p=linux/kernel/git/tiwai/sound-2.6.git;a=shortlog;
h=topic/asoc

 sound/soc/davinci/davinci-mcasp.c |   18 --
 sound/soc/davinci/davinci-mcasp.h |1 +
 sound/soc/davinci/davinci-pcm.c   |2 +-
 3 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/sound/soc/davinci/davinci-mcasp.c 
b/sound/soc/davinci/davinci-mcasp.c
index 0a302e1..0d263f1 100644
--- a/sound/soc/davinci/davinci-mcasp.c
+++ b/sound/soc/davinci/davinci-mcasp.c
@@ -767,14 +767,27 @@ static int davinci_mcasp_trigger(struct snd_pcm_substream 
*substream,
int ret = 0;
 
switch (cmd) {
-   case SNDRV_PCM_TRIGGER_START:
case SNDRV_PCM_TRIGGER_RESUME:
+   if (!dev-clk_active) {
+   clk_enable(dev-clk);
+   dev-clk_active = 1;
+   }
+
+   case SNDRV_PCM_TRIGGER_START:
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
davinci_mcasp_start(dev, substream-stream);
break;
 
-   case SNDRV_PCM_TRIGGER_STOP:
case SNDRV_PCM_TRIGGER_SUSPEND:
+   davinci_mcasp_stop(dev, substream-stream);
+   if (dev-clk_active) {
+   clk_disable(dev-clk);
+   dev-clk_active = 0;
+   }
+
+   break;
+
+   case SNDRV_PCM_TRIGGER_STOP:
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
davinci_mcasp_stop(dev, substream-stream);
break;
@@ -866,6 +879,7 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
}
 
clk_enable(dev-clk);
+   dev-clk_active = 1;
 
dev-base = (void __iomem *)IO_ADDRESS(mem-start);
dev-op_mode = pdata-op_mode;
diff --git a/sound/soc/davinci/davinci-mcasp.h 
b/sound/soc/davinci/davinci-mcasp.h
index 582c924..e755b51 100644
--- a/sound/soc/davinci/davinci-mcasp.h
+++ b/sound/soc/davinci/davinci-mcasp.h
@@ -44,6 +44,7 @@ struct davinci_audio_dev {
int sample_rate;
struct clk *clk;
unsigned int codec_fmt;
+   u8 clk_active;
 
/* McASP specific data */
int tdm_slots;
diff --git a/sound/soc/davinci/davinci-pcm.c b/sound/soc/davinci/davinci-pcm.c
index ad4d7f4..80c7fdf 100644
--- a/sound/soc/davinci/davinci-pcm.c
+++ b/sound/soc/davinci/davinci-pcm.c
@@ -49,7 +49,7 @@ static void print_buf_info(int slot, char *name)
 static struct snd_pcm_hardware pcm_hardware_playback = {
.info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER |
 SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |
-SNDRV_PCM_INFO_PAUSE),
+SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME),
.formats = (SNDRV_PCM_FMTBIT_S16_LE),
.rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_32000 |
-- 
1.5.6

___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


[PATCH 1/4] davinci: fb: Updates the driver in preparation for addition of power management features

2009-11-26 Thread Chaithrika U S
Add a helper function to enable raster. Also add one member in the
private data structure to track the current blank status, another
function pointer which takes in the platform specific callback function
to control panel power.

These updates will help in adding suspend/resume and frame buffer blank
operation features.

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
 drivers/video/da8xx-fb.c |   43 +++
 include/video/da8xx-fb.h |1 +
 2 files changed, 28 insertions(+), 16 deletions(-)

diff --git a/drivers/video/da8xx-fb.c b/drivers/video/da8xx-fb.c
index 67550e6..b3c22e1 100644
--- a/drivers/video/da8xx-fb.c
+++ b/drivers/video/da8xx-fb.c
@@ -115,9 +115,11 @@ struct da8xx_fb_par {
unsigned int databuf_sz;
unsigned int palette_sz;
unsigned int pxl_clk;
+   int blank;
 #ifdef CONFIG_CPU_FREQ
struct notifier_block   freq_transition;
 #endif
+   void (*panel_power_ctrl)(int);
 };
 
 /* Variable Screen Information */
@@ -195,8 +197,18 @@ static struct da8xx_panel known_lcd_panels[] = {
},
 };
 
+/* Enable the Raster Engine of the LCD Controller */
+static inline void lcd_enable_raster(void)
+{
+   u32 reg;
+
+   reg = lcdc_read(LCD_RASTER_CTRL_REG);
+   if (!(reg  LCD_RASTER_ENABLE))
+   lcdc_write(reg | LCD_RASTER_ENABLE, LCD_RASTER_CTRL_REG);
+}
+
 /* Disable the Raster Engine of the LCD Controller */
-static void lcd_disable_raster(struct da8xx_fb_par *par)
+static inline void lcd_disable_raster(void)
 {
u32 reg;
 
@@ -448,8 +460,7 @@ static int fb_setcolreg(unsigned regno, unsigned red, 
unsigned green,
 static void lcd_reset(struct da8xx_fb_par *par)
 {
/* Disable the Raster if previously Enabled */
-   if (lcdc_read(LCD_RASTER_CTRL_REG)  LCD_RASTER_ENABLE)
-   lcd_disable_raster(par);
+   lcd_disable_raster();
 
/* DMA has to be disabled */
lcdc_write(0, LCD_DMA_CTRL_REG);
@@ -529,13 +540,11 @@ static int lcd_init(struct da8xx_fb_par *par, const 
struct lcd_ctrl_config *cfg,
 static irqreturn_t lcdc_irq_handler(int irq, void *arg)
 {
u32 stat = lcdc_read(LCD_STAT_REG);
-   u32 reg;
 
if ((stat  LCD_SYNC_LOST)  (stat  LCD_FIFO_UNDERFLOW)) {
-   reg = lcdc_read(LCD_RASTER_CTRL_REG);
-   lcdc_write(reg  ~LCD_RASTER_ENABLE, LCD_RASTER_CTRL_REG);
+   lcd_disable_raster();
lcdc_write(stat, LCD_STAT_REG);
-   lcdc_write(reg | LCD_RASTER_ENABLE, LCD_RASTER_CTRL_REG);
+   lcd_enable_raster();
} else
lcdc_write(stat, LCD_STAT_REG);
 
@@ -595,16 +604,13 @@ static int lcd_da8xx_cpufreq_transition(struct 
notifier_block *nb,
 unsigned long val, void *data)
 {
struct da8xx_fb_par *par;
-   unsigned int reg;
 
par = container_of(nb, struct da8xx_fb_par, freq_transition);
if (val == CPUFREQ_PRECHANGE) {
-   reg = lcdc_read(LCD_RASTER_CTRL_REG);
-   lcdc_write(reg  ~LCD_RASTER_ENABLE, LCD_RASTER_CTRL_REG);
+   lcd_disable_raster();
} else if (val == CPUFREQ_POSTCHANGE) {
lcd_calc_clk_divider(par);
-   reg = lcdc_read(LCD_RASTER_CTRL_REG);
-   lcdc_write(reg | LCD_RASTER_ENABLE, LCD_RASTER_CTRL_REG);
+   lcd_enable_raster();
}
 
return 0;
@@ -635,8 +641,10 @@ static int __devexit fb_remove(struct platform_device *dev)
 #ifdef CONFIG_CPU_FREQ
lcd_da8xx_cpufreq_deregister(par);
 #endif
-   if (lcdc_read(LCD_RASTER_CTRL_REG)  LCD_RASTER_ENABLE)
-   lcd_disable_raster(par);
+   if (par-panel_power_ctrl)
+   par-panel_power_ctrl(0);
+
+   lcd_disable_raster();
lcdc_write(0, LCD_RASTER_CTRL_REG);
 
/* disable DMA  */
@@ -777,6 +785,10 @@ static int __init fb_probe(struct platform_device *device)
par = da8xx_fb_info-par;
par-lcdc_clk = fb_clk;
par-pxl_clk = lcdc_info-pxl_clk;
+   if (fb_pdata-panel_power_ctrl) {
+   par-panel_power_ctrl = fb_pdata-panel_power_ctrl;
+   par-panel_power_ctrl(1);
+   }
 
if (lcd_init(par, lcd_cfg, lcdc_info)  0) {
dev_err(device-dev, lcd_init failed\n);
@@ -877,8 +889,7 @@ static int __init fb_probe(struct platform_device *device)
 #endif
 
/* enable raster engine */
-   lcdc_write(lcdc_read(LCD_RASTER_CTRL_REG) |
-   LCD_RASTER_ENABLE, LCD_RASTER_CTRL_REG);
+   lcd_enable_raster();
 
return 0;
 
diff --git a/include/video/da8xx-fb.h b/include/video/da8xx-fb.h
index c051a50..89d43b3 100644
--- a/include/video/da8xx-fb.h
+++ b/include/video/da8xx-fb.h
@@ -38,6 +38,7 @@ struct da8xx_lcdc_platform_data {
const char manu_name[10];
void *controller_data;
const char type[25

[PATCH 2/4] da850/omap-l138: Add callback to control LCD panel power

2009-11-26 Thread Chaithrika U S
Add the platform specific callback to control LCD panel and
backlight power.

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
This patch applies to DaVinci GIT tree at
http://git.kernel.org/?p=linux/kernel/git/khilman/linux-davinci.git;a=summary

 arch/arm/mach-davinci/board-da850-evm.c |   24 ++--
 1 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-davinci/board-da850-evm.c 
b/arch/arm/mach-davinci/board-da850-evm.c
index 8e0722f..63a6301 100644
--- a/arch/arm/mach-davinci/board-da850-evm.c
+++ b/arch/arm/mach-davinci/board-da850-evm.c
@@ -351,6 +351,15 @@ static struct davinci_mmc_config da850_mmc_config = {
.version= MMC_CTLR_VERSION_2,
 };
 
+static void da850_panel_power_ctrl(int val)
+{
+   /* lcd backlight */
+   gpio_set_value(DA850_LCD_BL_PIN, val);
+
+   /* lcd power */
+   gpio_set_value(DA850_LCD_PWR_PIN, val);
+}
+
 static int da850_lcd_hw_init(void)
 {
int status;
@@ -368,17 +377,11 @@ static int da850_lcd_hw_init(void)
gpio_direction_output(DA850_LCD_BL_PIN, 0);
gpio_direction_output(DA850_LCD_PWR_PIN, 0);
 
-   /* disable lcd backlight */
-   gpio_set_value(DA850_LCD_BL_PIN, 0);
-
-   /* disable lcd power */
-   gpio_set_value(DA850_LCD_PWR_PIN, 0);
-
-   /* enable lcd power */
-   gpio_set_value(DA850_LCD_PWR_PIN, 1);
+   /* Switch off panel power and backlight */
+   da850_panel_power_ctrl(0);
 
-   /* enable lcd backlight */
-   gpio_set_value(DA850_LCD_BL_PIN, 1);
+   /* Switch on panel power and backlight */
+   da850_panel_power_ctrl(1);
 
return 0;
 }
@@ -686,6 +689,7 @@ static __init void da850_evm_init(void)
pr_warning(da850_evm_init: lcd initialization failed: %d\n,
ret);
 
+   sharp_lk043t1dg01_pdata.panel_power_ctrl = da850_panel_power_ctrl,
ret = da8xx_register_lcdc(sharp_lk043t1dg01_pdata);
if (ret)
pr_warning(da850_evm_init: lcdc registration failed: %d\n,
-- 
1.5.6

___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


[PATCH 4/4] davinci: fb: Add framebuffer blank operation

2009-11-26 Thread Chaithrika U S
Implement frame buffer blank operation feature for DA8xx/OMAP-L1xx
driver.

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
 drivers/video/da8xx-fb.c |   30 ++
 1 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/drivers/video/da8xx-fb.c b/drivers/video/da8xx-fb.c
index fcaa344..a2fcd92 100644
--- a/drivers/video/da8xx-fb.c
+++ b/drivers/video/da8xx-fb.c
@@ -702,6 +702,35 @@ static int fb_ioctl(struct fb_info *info, unsigned int cmd,
return 0;
 }
 
+static int cfb_blank(int blank, struct fb_info *info)
+{
+   struct da8xx_fb_par *par = info-par;
+   int ret = 0;
+
+   if (par-blank == blank)
+   return 0;
+
+   par-blank = blank;
+   switch (blank) {
+   case FB_BLANK_UNBLANK:
+   if (par-panel_power_ctrl)
+   par-panel_power_ctrl(1);
+
+   lcd_enable_raster();
+   break;
+   case FB_BLANK_POWERDOWN:
+   if (par-panel_power_ctrl)
+   par-panel_power_ctrl(0);
+
+   lcd_disable_raster();
+   break;
+   default:
+   ret = -EINVAL;
+   }
+
+   return ret;
+}
+
 static struct fb_ops da8xx_fb_ops = {
.owner = THIS_MODULE,
.fb_check_var = fb_check_var,
@@ -710,6 +739,7 @@ static struct fb_ops da8xx_fb_ops = {
.fb_fillrect = cfb_fillrect,
.fb_copyarea = cfb_copyarea,
.fb_imageblit = cfb_imageblit,
+   .fb_blank = cfb_blank,
 };
 
 static int __init fb_probe(struct platform_device *device)
-- 
1.5.6

___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


RE: [PATCH] davinci: MMC: add cpufreq support

2009-11-23 Thread Chaithrika U S
Andrew,

Can you please push this patch to mmotm tree as there are no review
comments for this patch.

Regards, 
Chaithrika

On Wed, Nov 04, 2009 at 09:52:16, Chaithrika U S wrote:
 Do you have any review comments or suggestions for this patch?
 
 Regards, 
 Chaithrika
 
 On Tue, Oct 20, 2009 at 17:40:10, Chaithrika U S wrote:
  Add cpufreq support to MMC driver. The clock divider value has to be
  modified according to the controller input frequency.
  
  Signed-off-by: Chaithrika U S chaithr...@ti.com
  ---
  This patch applies on top of the following two patches submitted to LKML
  http://patchwork.kernel.org/patch/54013/
  http://patchwork.kernel.org/patch/50914/
  
   drivers/mmc/host/davinci_mmc.c |  100 
  +--
   1 files changed, 84 insertions(+), 16 deletions(-)
  
  diff --git a/drivers/mmc/host/davinci_mmc.c b/drivers/mmc/host/davinci_mmc.c
  index fe8f613..b54c779 100644
  --- a/drivers/mmc/host/davinci_mmc.c
  +++ b/drivers/mmc/host/davinci_mmc.c
  @@ -25,6 +25,7 @@
   #include linux/platform_device.h
   #include linux/clk.h
   #include linux/err.h
  +#include linux/cpufreq.h
   #include linux/mmc/host.h
   #include linux/io.h
   #include linux/irq.h
  @@ -200,6 +201,9 @@ struct mmc_davinci_host {
  u8 version;
  /* for ns in one cycle calculation */
  unsigned ns_in_one_cycle;
  +#ifdef CONFIG_CPU_FREQ
  +   struct notifier_block   freq_transition;
  +#endif
   };
   
   
  @@ -739,27 +743,12 @@ static unsigned int calculate_freq_for_card(struct 
  mmc_davinci_host *host,
  return mmc_push_pull_divisor;
   }
   
  -static void mmc_davinci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
  +static void calculate_clk_divider(struct mmc_host *mmc, struct mmc_ios 
  *ios)
   {
  unsigned int open_drain_freq = 0, mmc_pclk = 0;
  unsigned int mmc_push_pull_freq = 0;
  struct mmc_davinci_host *host = mmc_priv(mmc);
   
  -   mmc_pclk = host-mmc_input_clk;
  -   dev_dbg(mmc_dev(host-mmc),
  -   clock %dHz busmode %d powermode %d Vdd %04x\n,
  -   ios-clock, ios-bus_mode, ios-power_mode,
  -   ios-vdd);
  -   if (ios-bus_width == MMC_BUS_WIDTH_4) {
  -   dev_dbg(mmc_dev(host-mmc), Enabling 4 bit mode\n);
  -   writel(readl(host-base + DAVINCI_MMCCTL) | MMCCTL_WIDTH_4_BIT,
  -   host-base + DAVINCI_MMCCTL);
  -   } else {
  -   dev_dbg(mmc_dev(host-mmc), Disabling 4 bit mode\n);
  -   writel(readl(host-base + DAVINCI_MMCCTL)  ~MMCCTL_WIDTH_4_BIT,
  -   host-base + DAVINCI_MMCCTL);
  -   }
  -
  if (ios-bus_mode == MMC_BUSMODE_OPENDRAIN) {
  u32 temp;
   
  @@ -798,6 +787,29 @@ static void mmc_davinci_set_ios(struct mmc_host *mmc, 
  struct mmc_ios *ios)
   
  udelay(10);
  }
  +}
  +
  +static void mmc_davinci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
  +{
  +   unsigned int mmc_pclk = 0;
  +   struct mmc_davinci_host *host = mmc_priv(mmc);
  +
  +   mmc_pclk = host-mmc_input_clk;
  +   dev_dbg(mmc_dev(host-mmc),
  +   clock %dHz busmode %d powermode %d Vdd %04x\n,
  +   ios-clock, ios-bus_mode, ios-power_mode,
  +   ios-vdd);
  +   if (ios-bus_width == MMC_BUS_WIDTH_4) {
  +   dev_dbg(mmc_dev(host-mmc), Enabling 4 bit mode\n);
  +   writel(readl(host-base + DAVINCI_MMCCTL) | MMCCTL_WIDTH_4_BIT,
  +   host-base + DAVINCI_MMCCTL);
  +   } else {
  +   dev_dbg(mmc_dev(host-mmc), Disabling 4 bit mode\n);
  +   writel(readl(host-base + DAVINCI_MMCCTL)  ~MMCCTL_WIDTH_4_BIT,
  +   host-base + DAVINCI_MMCCTL);
  +   }
  +
  +   calculate_clk_divider(mmc, ios);
   
  host-bus_mode = ios-bus_mode;
  if (ios-power_mode == MMC_POWER_UP) {
  @@ -1040,6 +1052,52 @@ static struct mmc_host_ops mmc_davinci_ops = {
   
   /*--*/
   
  +#ifdef CONFIG_CPU_FREQ
  +static int mmc_davinci_cpufreq_transition(struct notifier_block *nb,
  +unsigned long val, void *data)
  +{
  +   struct mmc_davinci_host *host;
  +   unsigned int mmc_pclk;
  +   struct mmc_host *mmc;
  +   unsigned long flags;
  +
  +   host = container_of(nb, struct mmc_davinci_host, freq_transition);
  +   mmc = host-mmc;
  +   mmc_pclk = clk_get_rate(host-clk);
  +
  +   if (val == CPUFREQ_POSTCHANGE) {
  +   spin_lock_irqsave(mmc-lock, flags);
  +   host-mmc_input_clk = mmc_pclk;
  +   calculate_clk_divider(mmc, mmc-ios);
  +   spin_unlock_irqrestore(mmc-lock, flags);
  +   }
  +
  +   return 0;
  +}
  +
  +static inline int mmc_davinci_cpufreq_register(struct mmc_davinci_host 
  *host)
  +{
  +   host-freq_transition.notifier_call = mmc_davinci_cpufreq_transition;
  +
  +   return cpufreq_register_notifier(host-freq_transition,
  +CPUFREQ_TRANSITION_NOTIFIER);
  +}
  +
  +static inline void

RE: [PATCH] davinci: fb: Calculate the clock divider from pixel clock info

2009-11-22 Thread Chaithrika U S
Andrew,

Can you please push this patch to mmotm tree. The patch
'davinci: fb: add cpufreq support'(which is already present
in mmotm tree) is dependent on this patch.

Regards, 
Chaithrika

On Fri, Oct 23, 2009 at 10:41:08, Chaithrika U S wrote:
 All,
 
 Any comments/suggestions on this patch?
 
 Regards,
 Chaithrika
 
 On Tue, Oct 20, 2009 at 15:48:07, Chaithrika U S wrote:
  The clock divider value can be calculated from the pixel clock value 
  for the panel. This gives more flexiblity to the driver to change the 
  divider value on the fly as in the case of cpufreq
  feature- support for which will be added shortly.
  
  Signed-off-by: Chaithrika U S chaithr...@ti.com
  ---
  This patch applies on Linus' kernel tree.
  Resending this patch as missed out marking fbdev list previously.
  
   drivers/video/da8xx-fb.c |   28 
   1 files changed, 20 insertions(+), 8 deletions(-)
  
  diff --git a/drivers/video/da8xx-fb.c b/drivers/video/da8xx-fb.c index 
  d065894..d9ab839 100644
  --- a/drivers/video/da8xx-fb.c
  +++ b/drivers/video/da8xx-fb.c
  @@ -113,6 +113,7 @@ struct da8xx_fb_par {
  unsigned short pseudo_palette[16];
  unsigned int databuf_sz;
  unsigned int palette_sz;
  +   unsigned int pxl_clk;
   };
   
   /* Variable Screen Information */
  @@ -155,7 +156,7 @@ struct da8xx_panel {
  int vfp;/* Vertical front porch */
  int vbp;/* Vertical back porch */
  int vsw;/* Vertical Sync Pulse Width */
  -   int pxl_clk;/* Pixel clock */
  +   unsigned intpxl_clk;/* Pixel clock */
  unsigned char   invert_pxl_clk; /* Invert Pixel clock */
   };
   
  @@ -171,7 +172,7 @@ static struct da8xx_panel known_lcd_panels[] = {
  .vfp = 2,
  .vbp = 2,
  .vsw = 0,
  -   .pxl_clk = 0x10,
  +   .pxl_clk = 4608000,
  .invert_pxl_clk = 1,
  },
  /* Sharp LK043T1DG01 */
  @@ -185,7 +186,7 @@ static struct da8xx_panel known_lcd_panels[] = {
  .vfp = 2,
  .vbp = 2,
  .vsw = 10,
  -   .pxl_clk = 0x12,
  +   .pxl_clk = 7833600,
  .invert_pxl_clk = 0,
  },
   };
  @@ -451,6 +452,18 @@ static void lcd_reset(struct da8xx_fb_par *par)
  lcdc_write(0, LCD_RASTER_CTRL_REG);
   }
   
  +static void lcd_calc_clk_divider(struct da8xx_fb_par *par) {
  +   unsigned int lcd_clk, div;
  +
  +   lcd_clk = clk_get_rate(par-lcdc_clk);
  +   div = lcd_clk / par-pxl_clk;
  +
  +   /* Configure the LCD clock divisor. */
  +   lcdc_write(LCD_CLK_DIVISOR(div) |
  +   (LCD_RASTER_MODE  0x1), LCD_CTRL_REG); }
  +
   static int lcd_init(struct da8xx_fb_par *par, const struct lcd_ctrl_config 
  *cfg,
  struct da8xx_panel *panel)
   {
  @@ -459,9 +472,8 @@ static int lcd_init(struct da8xx_fb_par *par, 
  const struct lcd_ctrl_config *cfg,
   
  lcd_reset(par);
   
  -   /* Configure the LCD clock divisor. */
  -   lcdc_write(LCD_CLK_DIVISOR(panel-pxl_clk) |
  -   (LCD_RASTER_MODE  0x1), LCD_CTRL_REG);
  +   /* Calculate the divider */
  +   lcd_calc_clk_divider(par);
   
  if (panel-invert_pxl_clk)
  lcdc_write((lcdc_read(LCD_RASTER_TIMING_2_REG) | @@ -721,6 
  +733,8 
  @@ static int __init fb_probe(struct platform_device *device)
  }
   
  par = da8xx_fb_info-par;
  +   par-lcdc_clk = fb_clk;
  +   par-pxl_clk = lcdc_info-pxl_clk;
   
  if (lcd_init(par, lcd_cfg, lcdc_info)  0) {
  dev_err(device-dev, lcd_init failed\n); @@ -753,8 +767,6 @@ 
  static int __init fb_probe(struct platform_device *device)
  da8xx_fb_fix.smem_len = par-databuf_sz - par-palette_sz;
  da8xx_fb_fix.line_length = (lcdc_info-width * lcd_cfg-bpp) / 8;
   
  -   par-lcdc_clk = fb_clk;
  -
  par-irq = platform_get_irq(device, 0);
  if (par-irq  0) {
  ret = -ENOENT;
  --
  1.5.6
  
 



___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


[PATCH] DA8xx/OMAP-L1xx: Add high speed SD/MMC capabilities

2009-11-03 Thread Chaithrika U S
Include high speed capabilities in MMC/SD platform data
for DA830/OMAP-L137 and DA850/OMAP-L138 EVMs.

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
 arch/arm/mach-davinci/board-da830-evm.c |2 ++
 arch/arm/mach-davinci/board-da850-evm.c |2 ++
 2 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-davinci/board-da830-evm.c 
b/arch/arm/mach-davinci/board-da830-evm.c
index d2159e7..ed93d2e 100644
--- a/arch/arm/mach-davinci/board-da830-evm.c
+++ b/arch/arm/mach-davinci/board-da830-evm.c
@@ -261,6 +261,8 @@ static int da830_evm_mmc_get_ro(int index)
 static struct davinci_mmc_config da830_evm_mmc_config = {
.get_ro = da830_evm_mmc_get_ro,
.wires  = 4,
+   .max_freq   = 5000,
+   .caps   = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
.version= MMC_CTLR_VERSION_2,
 };
 
diff --git a/arch/arm/mach-davinci/board-da850-evm.c 
b/arch/arm/mach-davinci/board-da850-evm.c
index 23e2024..489d641 100644
--- a/arch/arm/mach-davinci/board-da850-evm.c
+++ b/arch/arm/mach-davinci/board-da850-evm.c
@@ -280,6 +280,8 @@ static struct davinci_mmc_config da850_mmc_config = {
.get_ro = da850_evm_mmc_get_ro,
.get_cd = da850_evm_mmc_get_cd,
.wires  = 4,
+   .max_freq   = 5000,
+   .caps   = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
.version= MMC_CTLR_VERSION_2,
 };
 
-- 
1.5.6

___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


[PATCH v2] davinci: fb: Add cpufreq support

2009-11-03 Thread Chaithrika U S
Add cpufreq support for DA8xx/OMAP-L1xx frame buffer driver

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
This patch applies to Linus' kernel tree. In this version, a macro name
has been corrected. This patch is dependent on the 'davinci: fb:
Calculate the clock divider from pixel clock info' patch submitted earlier.

 drivers/video/da8xx-fb.c |   55 ++
 1 files changed, 55 insertions(+), 0 deletions(-)

diff --git a/drivers/video/da8xx-fb.c b/drivers/video/da8xx-fb.c
index d9ab839..93842c8 100644
--- a/drivers/video/da8xx-fb.c
+++ b/drivers/video/da8xx-fb.c
@@ -28,6 +28,7 @@
 #include linux/uaccess.h
 #include linux/interrupt.h
 #include linux/clk.h
+#include linux/cpufreq.h
 #include video/da8xx-fb.h
 
 #define DRIVER_NAME da8xx_lcdc
@@ -114,6 +115,9 @@ struct da8xx_fb_par {
unsigned int databuf_sz;
unsigned int palette_sz;
unsigned int pxl_clk;
+#ifdef CONFIG_CPU_FREQ
+   struct notifier_block   freq_transition;
+#endif
 };
 
 /* Variable Screen Information */
@@ -586,6 +590,41 @@ static int fb_check_var(struct fb_var_screeninfo *var,
return err;
 }
 
+#ifdef CONFIG_CPU_FREQ
+static int lcd_da8xx_cpufreq_transition(struct notifier_block *nb,
+unsigned long val, void *data)
+{
+   struct da8xx_fb_par *par;
+   unsigned int reg;
+
+   par = container_of(nb, struct da8xx_fb_par, freq_transition);
+   if (val == CPUFREQ_PRECHANGE) {
+   reg = lcdc_read(LCD_RASTER_CTRL_REG);
+   lcdc_write(reg  ~LCD_RASTER_ENABLE, LCD_RASTER_CTRL_REG);
+   } else if (val == CPUFREQ_POSTCHANGE) {
+   lcd_calc_clk_divider(par);
+   reg = lcdc_read(LCD_RASTER_CTRL_REG);
+   lcdc_write(reg | LCD_RASTER_ENABLE, LCD_RASTER_CTRL_REG);
+   }
+
+   return 0;
+}
+
+static inline int lcd_da8xx_cpufreq_register(struct da8xx_fb_par *par)
+{
+   par-freq_transition.notifier_call = lcd_da8xx_cpufreq_transition;
+
+   return cpufreq_register_notifier(par-freq_transition,
+CPUFREQ_TRANSITION_NOTIFIER);
+}
+
+static inline void lcd_da8xx_cpufreq_deregister(struct da8xx_fb_par *par)
+{
+   cpufreq_unregister_notifier(par-freq_transition,
+   CPUFREQ_TRANSITION_NOTIFIER);
+}
+#endif
+
 static int __devexit fb_remove(struct platform_device *dev)
 {
struct fb_info *info = dev_get_drvdata(dev-dev);
@@ -593,6 +632,9 @@ static int __devexit fb_remove(struct platform_device *dev)
if (info) {
struct da8xx_fb_par *par = info-par;
 
+#ifdef CONFIG_CPU_FREQ
+   lcd_da8xx_cpufreq_deregister(par);
+#endif
if (lcdc_read(LCD_RASTER_CTRL_REG)  LCD_RASTER_ENABLE)
lcd_disable_raster(par);
lcdc_write(0, LCD_RASTER_CTRL_REG);
@@ -823,12 +865,25 @@ static int __init fb_probe(struct platform_device *device)
goto err_dealloc_cmap;
}
 
+#ifdef CONFIG_CPU_FREQ
+   ret = lcd_da8xx_cpufreq_register(par);
+   if (ret) {
+   dev_err(device-dev, failed to register cpufreq\n);
+   goto err_cpu_freq;
+   }
+#endif
+
/* enable raster engine */
lcdc_write(lcdc_read(LCD_RASTER_CTRL_REG) |
LCD_RASTER_ENABLE, LCD_RASTER_CTRL_REG);
 
return 0;
 
+#ifdef CONFIG_CPU_FREQ
+err_cpu_freq:
+   unregister_framebuffer(da8xx_fb_info);
+#endif
+
 err_dealloc_cmap:
fb_dealloc_cmap(da8xx_fb_info-cmap);
 
-- 
1.5.6

___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


RE: [PATCH] davinci: MMC: add cpufreq support

2009-11-03 Thread Chaithrika U S
Do you have any review comments or suggestions for this patch?

Regards, 
Chaithrika

On Tue, Oct 20, 2009 at 17:40:10, Chaithrika U S wrote:
 Add cpufreq support to MMC driver. The clock divider value has to be
 modified according to the controller input frequency.
 
 Signed-off-by: Chaithrika U S chaithr...@ti.com
 ---
 This patch applies on top of the following two patches submitted to LKML
 http://patchwork.kernel.org/patch/54013/
 http://patchwork.kernel.org/patch/50914/
 
  drivers/mmc/host/davinci_mmc.c |  100 +--
  1 files changed, 84 insertions(+), 16 deletions(-)
 
 diff --git a/drivers/mmc/host/davinci_mmc.c b/drivers/mmc/host/davinci_mmc.c
 index fe8f613..b54c779 100644
 --- a/drivers/mmc/host/davinci_mmc.c
 +++ b/drivers/mmc/host/davinci_mmc.c
 @@ -25,6 +25,7 @@
  #include linux/platform_device.h
  #include linux/clk.h
  #include linux/err.h
 +#include linux/cpufreq.h
  #include linux/mmc/host.h
  #include linux/io.h
  #include linux/irq.h
 @@ -200,6 +201,9 @@ struct mmc_davinci_host {
   u8 version;
   /* for ns in one cycle calculation */
   unsigned ns_in_one_cycle;
 +#ifdef CONFIG_CPU_FREQ
 + struct notifier_block   freq_transition;
 +#endif
  };
  
  
 @@ -739,27 +743,12 @@ static unsigned int calculate_freq_for_card(struct 
 mmc_davinci_host *host,
   return mmc_push_pull_divisor;
  }
  
 -static void mmc_davinci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 +static void calculate_clk_divider(struct mmc_host *mmc, struct mmc_ios *ios)
  {
   unsigned int open_drain_freq = 0, mmc_pclk = 0;
   unsigned int mmc_push_pull_freq = 0;
   struct mmc_davinci_host *host = mmc_priv(mmc);
  
 - mmc_pclk = host-mmc_input_clk;
 - dev_dbg(mmc_dev(host-mmc),
 - clock %dHz busmode %d powermode %d Vdd %04x\n,
 - ios-clock, ios-bus_mode, ios-power_mode,
 - ios-vdd);
 - if (ios-bus_width == MMC_BUS_WIDTH_4) {
 - dev_dbg(mmc_dev(host-mmc), Enabling 4 bit mode\n);
 - writel(readl(host-base + DAVINCI_MMCCTL) | MMCCTL_WIDTH_4_BIT,
 - host-base + DAVINCI_MMCCTL);
 - } else {
 - dev_dbg(mmc_dev(host-mmc), Disabling 4 bit mode\n);
 - writel(readl(host-base + DAVINCI_MMCCTL)  ~MMCCTL_WIDTH_4_BIT,
 - host-base + DAVINCI_MMCCTL);
 - }
 -
   if (ios-bus_mode == MMC_BUSMODE_OPENDRAIN) {
   u32 temp;
  
 @@ -798,6 +787,29 @@ static void mmc_davinci_set_ios(struct mmc_host *mmc, 
 struct mmc_ios *ios)
  
   udelay(10);
   }
 +}
 +
 +static void mmc_davinci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 +{
 + unsigned int mmc_pclk = 0;
 + struct mmc_davinci_host *host = mmc_priv(mmc);
 +
 + mmc_pclk = host-mmc_input_clk;
 + dev_dbg(mmc_dev(host-mmc),
 + clock %dHz busmode %d powermode %d Vdd %04x\n,
 + ios-clock, ios-bus_mode, ios-power_mode,
 + ios-vdd);
 + if (ios-bus_width == MMC_BUS_WIDTH_4) {
 + dev_dbg(mmc_dev(host-mmc), Enabling 4 bit mode\n);
 + writel(readl(host-base + DAVINCI_MMCCTL) | MMCCTL_WIDTH_4_BIT,
 + host-base + DAVINCI_MMCCTL);
 + } else {
 + dev_dbg(mmc_dev(host-mmc), Disabling 4 bit mode\n);
 + writel(readl(host-base + DAVINCI_MMCCTL)  ~MMCCTL_WIDTH_4_BIT,
 + host-base + DAVINCI_MMCCTL);
 + }
 +
 + calculate_clk_divider(mmc, ios);
  
   host-bus_mode = ios-bus_mode;
   if (ios-power_mode == MMC_POWER_UP) {
 @@ -1040,6 +1052,52 @@ static struct mmc_host_ops mmc_davinci_ops = {
  
  /*--*/
  
 +#ifdef CONFIG_CPU_FREQ
 +static int mmc_davinci_cpufreq_transition(struct notifier_block *nb,
 +  unsigned long val, void *data)
 +{
 + struct mmc_davinci_host *host;
 + unsigned int mmc_pclk;
 + struct mmc_host *mmc;
 + unsigned long flags;
 +
 + host = container_of(nb, struct mmc_davinci_host, freq_transition);
 + mmc = host-mmc;
 + mmc_pclk = clk_get_rate(host-clk);
 +
 + if (val == CPUFREQ_POSTCHANGE) {
 + spin_lock_irqsave(mmc-lock, flags);
 + host-mmc_input_clk = mmc_pclk;
 + calculate_clk_divider(mmc, mmc-ios);
 + spin_unlock_irqrestore(mmc-lock, flags);
 + }
 +
 + return 0;
 +}
 +
 +static inline int mmc_davinci_cpufreq_register(struct mmc_davinci_host *host)
 +{
 + host-freq_transition.notifier_call = mmc_davinci_cpufreq_transition;
 +
 + return cpufreq_register_notifier(host-freq_transition,
 +  CPUFREQ_TRANSITION_NOTIFIER);
 +}
 +
 +static inline void mmc_davinci_cpufreq_deregister(struct mmc_davinci_host 
 *host)
 +{
 + cpufreq_unregister_notifier(host-freq_transition,
 + CPUFREQ_TRANSITION_NOTIFIER);
 +}
 +#else
 +static

RE: [PATCH] TI DaVinci EMAC: Minor macro related updates

2009-10-26 Thread Chaithrika U S
On Tue, Oct 27, 2009 at 03:37:22, Jean-Christophe PLAGNIOL-VILLARD wrote:
 On 16:25 Thu 01 Oct , Chaithrika U S wrote:
  Use BIT for macro definitions wherever possible, remove
  unused and redundant macros.
  
  Signed-off-by: Chaithrika U S chaithr...@ti.com
  ---
  Applies to Linus' kernel tree
 do you plan to send a new version soon?
 
 as the current DaVinci EMAC does not build on the v2.6.32-rc5
 
 Best Regards,
 J.
 

DaVinci EMAC builds and work fine on Linus' tree and DaVinci GIT tree.
Can you please provide more info regarding the errors you are seeing?

Regards, 
Chaithrika


___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


RE: [PATCH] davinci: fb: Calculate the clock divider from pixel clock info

2009-10-22 Thread Chaithrika U S
All,

Any comments/suggestions on this patch?

Regards, 
Chaithrika

On Tue, Oct 20, 2009 at 15:48:07, Chaithrika U S wrote:
 The clock divider value can be calculated from the pixel clock
 value for the panel. This gives more flexiblity to the driver
 to change the divider value on the fly as in the case of cpufreq
 feature- support for which will be added shortly.
 
 Signed-off-by: Chaithrika U S chaithr...@ti.com
 ---
 This patch applies on Linus' kernel tree.
 Resending this patch as missed out marking fbdev list previously.
 
  drivers/video/da8xx-fb.c |   28 
  1 files changed, 20 insertions(+), 8 deletions(-)
 
 diff --git a/drivers/video/da8xx-fb.c b/drivers/video/da8xx-fb.c
 index d065894..d9ab839 100644
 --- a/drivers/video/da8xx-fb.c
 +++ b/drivers/video/da8xx-fb.c
 @@ -113,6 +113,7 @@ struct da8xx_fb_par {
   unsigned short pseudo_palette[16];
   unsigned int databuf_sz;
   unsigned int palette_sz;
 + unsigned int pxl_clk;
  };
  
  /* Variable Screen Information */
 @@ -155,7 +156,7 @@ struct da8xx_panel {
   int vfp;/* Vertical front porch */
   int vbp;/* Vertical back porch */
   int vsw;/* Vertical Sync Pulse Width */
 - int pxl_clk;/* Pixel clock */
 + unsigned intpxl_clk;/* Pixel clock */
   unsigned char   invert_pxl_clk; /* Invert Pixel clock */
  };
  
 @@ -171,7 +172,7 @@ static struct da8xx_panel known_lcd_panels[] = {
   .vfp = 2,
   .vbp = 2,
   .vsw = 0,
 - .pxl_clk = 0x10,
 + .pxl_clk = 4608000,
   .invert_pxl_clk = 1,
   },
   /* Sharp LK043T1DG01 */
 @@ -185,7 +186,7 @@ static struct da8xx_panel known_lcd_panels[] = {
   .vfp = 2,
   .vbp = 2,
   .vsw = 10,
 - .pxl_clk = 0x12,
 + .pxl_clk = 7833600,
   .invert_pxl_clk = 0,
   },
  };
 @@ -451,6 +452,18 @@ static void lcd_reset(struct da8xx_fb_par *par)
   lcdc_write(0, LCD_RASTER_CTRL_REG);
  }
  
 +static void lcd_calc_clk_divider(struct da8xx_fb_par *par)
 +{
 + unsigned int lcd_clk, div;
 +
 + lcd_clk = clk_get_rate(par-lcdc_clk);
 + div = lcd_clk / par-pxl_clk;
 +
 + /* Configure the LCD clock divisor. */
 + lcdc_write(LCD_CLK_DIVISOR(div) |
 + (LCD_RASTER_MODE  0x1), LCD_CTRL_REG);
 +}
 +
  static int lcd_init(struct da8xx_fb_par *par, const struct lcd_ctrl_config 
 *cfg,
   struct da8xx_panel *panel)
  {
 @@ -459,9 +472,8 @@ static int lcd_init(struct da8xx_fb_par *par, const 
 struct lcd_ctrl_config *cfg,
  
   lcd_reset(par);
  
 - /* Configure the LCD clock divisor. */
 - lcdc_write(LCD_CLK_DIVISOR(panel-pxl_clk) |
 - (LCD_RASTER_MODE  0x1), LCD_CTRL_REG);
 + /* Calculate the divider */
 + lcd_calc_clk_divider(par);
  
   if (panel-invert_pxl_clk)
   lcdc_write((lcdc_read(LCD_RASTER_TIMING_2_REG) |
 @@ -721,6 +733,8 @@ static int __init fb_probe(struct platform_device *device)
   }
  
   par = da8xx_fb_info-par;
 + par-lcdc_clk = fb_clk;
 + par-pxl_clk = lcdc_info-pxl_clk;
  
   if (lcd_init(par, lcd_cfg, lcdc_info)  0) {
   dev_err(device-dev, lcd_init failed\n);
 @@ -753,8 +767,6 @@ static int __init fb_probe(struct platform_device *device)
   da8xx_fb_fix.smem_len = par-databuf_sz - par-palette_sz;
   da8xx_fb_fix.line_length = (lcdc_info-width * lcd_cfg-bpp) / 8;
  
 - par-lcdc_clk = fb_clk;
 -
   par-irq = platform_get_irq(device, 0);
   if (par-irq  0) {
   ret = -ENOENT;
 -- 
 1.5.6
 


___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


RE: [PATCH] davinci: MMC: add cpufreq support

2009-10-21 Thread Chaithrika U S
On Wed, Oct 21, 2009 at 03:44:51, Linus Walleij wrote:
 2009/10/20 Chaithrika U S chaithr...@ti.com:
 
  Add cpufreq support to MMC driver. The clock divider value has to be
  modified according to the controller input frequency.
  (...)
  @@ -1040,6 +1052,52 @@ static struct mmc_host_ops mmc_davinci_ops = {
 
   /*--*/
 
  +#ifdef CONFIG_CPU_FREQ
  +static int mmc_davinci_cpufreq_transition(struct notifier_block *nb,
  +                                    unsigned long val, void *data)
  +{
  +       struct mmc_davinci_host *host;
  +       unsigned int mmc_pclk;
  +       struct mmc_host *mmc;
  +       unsigned long flags;
  +
  +       host = container_of(nb, struct mmc_davinci_host, freq_transition);
  +       mmc = host-mmc;
  +       mmc_pclk = clk_get_rate(host-clk);
  +
  +       if (val == CPUFREQ_POSTCHANGE) {
  +               spin_lock_irqsave(mmc-lock, flags);
  +               host-mmc_input_clk = mmc_pclk;
  +               calculate_clk_divider(mmc, mmc-ios);
  +               spin_unlock_irqrestore(mmc-lock, flags);
  +       }
  +
  +       return 0;
  +}
 
 Now the way I understand it CPUfreq is about rising/lowering the
 frequency of the *CPU* when the load of the system goes up/down.
 
 I highly suspect that there is no general rule that davinci's host-clk
 will actually change just because the CPU changes frequency?
 

In this case, the PLL controller which supplies clock to the CPU also 
provides clock to the MMC/SD peripheral. Hence, the host-clk changes
with the CPU frequency changes.

 I don't know enough about davinci to tell but I suspect there are
 system-wide operating points hidden behind this and CPUfreq
 is being (ab)used for changing and notifying the system frequency
 overall. Some of these transitions include changing the MMC clock
 so if you simply broadcast them all?
 
 I really believe this is just masking the problem that the clk
 framework need support of real clk notifiers that can notify clk
 users pre/post a clk change. This is really what you want for a
 driver like this.
 
 Now I don't know the davinci consensus around these things,
 do you always use CPUfreq like this, for changing frequencies
 of clocks that are not CPU clocks at all?
 

In the case where the module clock is dependent on CPU clock, cpufreq 
is used to adjust the peripheral clock based on the CPU clock. Similar
implementation is present in Samsung S3C MCI driver too.

 I have similar code boiling for the MMCI/PL180 PrimeCell but
 I just cannot submit that because the PrimeCell is generic and
 there is no way I can implicitly correlate the CPU clk with the
 MMCI host clk like this, so I have to wait for real clock notifiers
 (or implement them myself...)
 
 Linus Walleij
 
 

Regards, 
Chaithrika


___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


[PATCH] davinci: fb: Calculate the clock divider from pixel clock info

2009-10-20 Thread Chaithrika U S
The clock divider value can be calculated from the pixel clock
value for the panel. This gives more flexiblity to the driver
to change the divider value on the fly as in the case of cpufreq
feature- support for which will be added shortly.

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
This patch applies on Linus' kernel tree.
Resending this patch as missed out marking fbdev list previously.

 drivers/video/da8xx-fb.c |   28 
 1 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/drivers/video/da8xx-fb.c b/drivers/video/da8xx-fb.c
index d065894..d9ab839 100644
--- a/drivers/video/da8xx-fb.c
+++ b/drivers/video/da8xx-fb.c
@@ -113,6 +113,7 @@ struct da8xx_fb_par {
unsigned short pseudo_palette[16];
unsigned int databuf_sz;
unsigned int palette_sz;
+   unsigned int pxl_clk;
 };
 
 /* Variable Screen Information */
@@ -155,7 +156,7 @@ struct da8xx_panel {
int vfp;/* Vertical front porch */
int vbp;/* Vertical back porch */
int vsw;/* Vertical Sync Pulse Width */
-   int pxl_clk;/* Pixel clock */
+   unsigned intpxl_clk;/* Pixel clock */
unsigned char   invert_pxl_clk; /* Invert Pixel clock */
 };
 
@@ -171,7 +172,7 @@ static struct da8xx_panel known_lcd_panels[] = {
.vfp = 2,
.vbp = 2,
.vsw = 0,
-   .pxl_clk = 0x10,
+   .pxl_clk = 4608000,
.invert_pxl_clk = 1,
},
/* Sharp LK043T1DG01 */
@@ -185,7 +186,7 @@ static struct da8xx_panel known_lcd_panels[] = {
.vfp = 2,
.vbp = 2,
.vsw = 10,
-   .pxl_clk = 0x12,
+   .pxl_clk = 7833600,
.invert_pxl_clk = 0,
},
 };
@@ -451,6 +452,18 @@ static void lcd_reset(struct da8xx_fb_par *par)
lcdc_write(0, LCD_RASTER_CTRL_REG);
 }
 
+static void lcd_calc_clk_divider(struct da8xx_fb_par *par)
+{
+   unsigned int lcd_clk, div;
+
+   lcd_clk = clk_get_rate(par-lcdc_clk);
+   div = lcd_clk / par-pxl_clk;
+
+   /* Configure the LCD clock divisor. */
+   lcdc_write(LCD_CLK_DIVISOR(div) |
+   (LCD_RASTER_MODE  0x1), LCD_CTRL_REG);
+}
+
 static int lcd_init(struct da8xx_fb_par *par, const struct lcd_ctrl_config 
*cfg,
struct da8xx_panel *panel)
 {
@@ -459,9 +472,8 @@ static int lcd_init(struct da8xx_fb_par *par, const struct 
lcd_ctrl_config *cfg,
 
lcd_reset(par);
 
-   /* Configure the LCD clock divisor. */
-   lcdc_write(LCD_CLK_DIVISOR(panel-pxl_clk) |
-   (LCD_RASTER_MODE  0x1), LCD_CTRL_REG);
+   /* Calculate the divider */
+   lcd_calc_clk_divider(par);
 
if (panel-invert_pxl_clk)
lcdc_write((lcdc_read(LCD_RASTER_TIMING_2_REG) |
@@ -721,6 +733,8 @@ static int __init fb_probe(struct platform_device *device)
}
 
par = da8xx_fb_info-par;
+   par-lcdc_clk = fb_clk;
+   par-pxl_clk = lcdc_info-pxl_clk;
 
if (lcd_init(par, lcd_cfg, lcdc_info)  0) {
dev_err(device-dev, lcd_init failed\n);
@@ -753,8 +767,6 @@ static int __init fb_probe(struct platform_device *device)
da8xx_fb_fix.smem_len = par-databuf_sz - par-palette_sz;
da8xx_fb_fix.line_length = (lcdc_info-width * lcd_cfg-bpp) / 8;
 
-   par-lcdc_clk = fb_clk;
-
par-irq = platform_get_irq(device, 0);
if (par-irq  0) {
ret = -ENOENT;
-- 
1.5.6

___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


[PATCH] davinci: fb: Add cpufreq support

2009-10-20 Thread Chaithrika U S
Add cpufreq support for DA8xx/OMAP-L1xx frame buffer driver.
Tested on DA850/OMAP-L138 EVM for Davinci GIT tree as cpufreq support is not
in the mainline yet.

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
This patch applies to Linus' kernel tree and is dependent on 'davinci: fb:
Calculate the clock divider from pixel clock info' patch submitted earlier.

 drivers/video/da8xx-fb.c |   55 ++
 1 files changed, 55 insertions(+), 0 deletions(-)

diff --git a/drivers/video/da8xx-fb.c b/drivers/video/da8xx-fb.c
index d9ab839..94d48c4 100644
--- a/drivers/video/da8xx-fb.c
+++ b/drivers/video/da8xx-fb.c
@@ -28,6 +28,7 @@
 #include linux/uaccess.h
 #include linux/interrupt.h
 #include linux/clk.h
+#include linux/cpufreq.h
 #include video/da8xx-fb.h
 
 #define DRIVER_NAME da8xx_lcdc
@@ -114,6 +115,9 @@ struct da8xx_fb_par {
unsigned int databuf_sz;
unsigned int palette_sz;
unsigned int pxl_clk;
+#ifdef CONFIG_CPU_FREQ
+   struct notifier_block   freq_transition;
+#endif
 };
 
 /* Variable Screen Information */
@@ -586,6 +590,41 @@ static int fb_check_var(struct fb_var_screeninfo *var,
return err;
 }
 
+#ifdef CONFIG_CPU_FREQ
+static int lcd_da8xx_cpufreq_transition(struct notifier_block *nb,
+unsigned long val, void *data)
+{
+   struct da8xx_fb_par *par;
+   unsigned int reg;
+
+   par = container_of(nb, struct da8xx_fb_par, freq_transition);
+   if (val == CPUFREQ_PRECHANGE) {
+   reg = lcdc_read(LCD_RASTER_CTRL_REG);
+   lcdc_write(reg  ~LCD_RASTER_ENABLE, LCD_RASTER_CTRL_REG);
+   } else if (val == CPUFREQ_POSTCHANGE) {
+   lcd_calc_clk_divider(par);
+   reg = lcdc_read(LCD_RASTER_CTRL_REG);
+   lcdc_write(reg | LCD_RASTER_ENABLE, LCD_RASTER_CTRL_REG);
+   }
+
+   return 0;
+}
+
+static inline int lcd_da8xx_cpufreq_register(struct da8xx_fb_par *par)
+{
+   par-freq_transition.notifier_call = lcd_da8xx_cpufreq_transition;
+
+   return cpufreq_register_notifier(par-freq_transition,
+CPUFREQ_TRANSITION_NOTIFIER);
+}
+
+static inline void lcd_da8xx_cpufreq_deregister(struct da8xx_fb_par *par)
+{
+   cpufreq_unregister_notifier(par-freq_transition,
+   CPUFREQ_TRANSITION_NOTIFIER);
+}
+#endif
+
 static int __devexit fb_remove(struct platform_device *dev)
 {
struct fb_info *info = dev_get_drvdata(dev-dev);
@@ -593,6 +632,9 @@ static int __devexit fb_remove(struct platform_device *dev)
if (info) {
struct da8xx_fb_par *par = info-par;
 
+#ifdef CONFIG_CPUFREQ
+   lcd_da8xx_cpufreq_deregister(par);
+#endif
if (lcdc_read(LCD_RASTER_CTRL_REG)  LCD_RASTER_ENABLE)
lcd_disable_raster(par);
lcdc_write(0, LCD_RASTER_CTRL_REG);
@@ -823,12 +865,25 @@ static int __init fb_probe(struct platform_device *device)
goto err_dealloc_cmap;
}
 
+#ifdef CONFIG_CPU_FREQ
+   ret = lcd_da8xx_cpufreq_register(par);
+   if (ret) {
+   dev_err(device-dev, failed to register cpufreq\n);
+   goto err_cpu_freq;
+   }
+#endif
+
/* enable raster engine */
lcdc_write(lcdc_read(LCD_RASTER_CTRL_REG) |
LCD_RASTER_ENABLE, LCD_RASTER_CTRL_REG);
 
return 0;
 
+#ifdef CONFIG_CPU_FREQ
+err_cpu_freq:
+   unregister_framebuffer(da8xx_fb_info);
+#endif
+
 err_dealloc_cmap:
fb_dealloc_cmap(da8xx_fb_info-cmap);
 
-- 
1.5.6

___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


[PATCH] davinci: MMC: add cpufreq support

2009-10-20 Thread Chaithrika U S
Add cpufreq support to MMC driver. The clock divider value has to be
modified according to the controller input frequency.

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
This patch applies on top of the following two patches submitted to LKML
http://patchwork.kernel.org/patch/54013/
http://patchwork.kernel.org/patch/50914/

 drivers/mmc/host/davinci_mmc.c |  100 +--
 1 files changed, 84 insertions(+), 16 deletions(-)

diff --git a/drivers/mmc/host/davinci_mmc.c b/drivers/mmc/host/davinci_mmc.c
index fe8f613..b54c779 100644
--- a/drivers/mmc/host/davinci_mmc.c
+++ b/drivers/mmc/host/davinci_mmc.c
@@ -25,6 +25,7 @@
 #include linux/platform_device.h
 #include linux/clk.h
 #include linux/err.h
+#include linux/cpufreq.h
 #include linux/mmc/host.h
 #include linux/io.h
 #include linux/irq.h
@@ -200,6 +201,9 @@ struct mmc_davinci_host {
u8 version;
/* for ns in one cycle calculation */
unsigned ns_in_one_cycle;
+#ifdef CONFIG_CPU_FREQ
+   struct notifier_block   freq_transition;
+#endif
 };
 
 
@@ -739,27 +743,12 @@ static unsigned int calculate_freq_for_card(struct 
mmc_davinci_host *host,
return mmc_push_pull_divisor;
 }
 
-static void mmc_davinci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
+static void calculate_clk_divider(struct mmc_host *mmc, struct mmc_ios *ios)
 {
unsigned int open_drain_freq = 0, mmc_pclk = 0;
unsigned int mmc_push_pull_freq = 0;
struct mmc_davinci_host *host = mmc_priv(mmc);
 
-   mmc_pclk = host-mmc_input_clk;
-   dev_dbg(mmc_dev(host-mmc),
-   clock %dHz busmode %d powermode %d Vdd %04x\n,
-   ios-clock, ios-bus_mode, ios-power_mode,
-   ios-vdd);
-   if (ios-bus_width == MMC_BUS_WIDTH_4) {
-   dev_dbg(mmc_dev(host-mmc), Enabling 4 bit mode\n);
-   writel(readl(host-base + DAVINCI_MMCCTL) | MMCCTL_WIDTH_4_BIT,
-   host-base + DAVINCI_MMCCTL);
-   } else {
-   dev_dbg(mmc_dev(host-mmc), Disabling 4 bit mode\n);
-   writel(readl(host-base + DAVINCI_MMCCTL)  ~MMCCTL_WIDTH_4_BIT,
-   host-base + DAVINCI_MMCCTL);
-   }
-
if (ios-bus_mode == MMC_BUSMODE_OPENDRAIN) {
u32 temp;
 
@@ -798,6 +787,29 @@ static void mmc_davinci_set_ios(struct mmc_host *mmc, 
struct mmc_ios *ios)
 
udelay(10);
}
+}
+
+static void mmc_davinci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
+{
+   unsigned int mmc_pclk = 0;
+   struct mmc_davinci_host *host = mmc_priv(mmc);
+
+   mmc_pclk = host-mmc_input_clk;
+   dev_dbg(mmc_dev(host-mmc),
+   clock %dHz busmode %d powermode %d Vdd %04x\n,
+   ios-clock, ios-bus_mode, ios-power_mode,
+   ios-vdd);
+   if (ios-bus_width == MMC_BUS_WIDTH_4) {
+   dev_dbg(mmc_dev(host-mmc), Enabling 4 bit mode\n);
+   writel(readl(host-base + DAVINCI_MMCCTL) | MMCCTL_WIDTH_4_BIT,
+   host-base + DAVINCI_MMCCTL);
+   } else {
+   dev_dbg(mmc_dev(host-mmc), Disabling 4 bit mode\n);
+   writel(readl(host-base + DAVINCI_MMCCTL)  ~MMCCTL_WIDTH_4_BIT,
+   host-base + DAVINCI_MMCCTL);
+   }
+
+   calculate_clk_divider(mmc, ios);
 
host-bus_mode = ios-bus_mode;
if (ios-power_mode == MMC_POWER_UP) {
@@ -1040,6 +1052,52 @@ static struct mmc_host_ops mmc_davinci_ops = {
 
 /*--*/
 
+#ifdef CONFIG_CPU_FREQ
+static int mmc_davinci_cpufreq_transition(struct notifier_block *nb,
+unsigned long val, void *data)
+{
+   struct mmc_davinci_host *host;
+   unsigned int mmc_pclk;
+   struct mmc_host *mmc;
+   unsigned long flags;
+
+   host = container_of(nb, struct mmc_davinci_host, freq_transition);
+   mmc = host-mmc;
+   mmc_pclk = clk_get_rate(host-clk);
+
+   if (val == CPUFREQ_POSTCHANGE) {
+   spin_lock_irqsave(mmc-lock, flags);
+   host-mmc_input_clk = mmc_pclk;
+   calculate_clk_divider(mmc, mmc-ios);
+   spin_unlock_irqrestore(mmc-lock, flags);
+   }
+
+   return 0;
+}
+
+static inline int mmc_davinci_cpufreq_register(struct mmc_davinci_host *host)
+{
+   host-freq_transition.notifier_call = mmc_davinci_cpufreq_transition;
+
+   return cpufreq_register_notifier(host-freq_transition,
+CPUFREQ_TRANSITION_NOTIFIER);
+}
+
+static inline void mmc_davinci_cpufreq_deregister(struct mmc_davinci_host 
*host)
+{
+   cpufreq_unregister_notifier(host-freq_transition,
+   CPUFREQ_TRANSITION_NOTIFIER);
+}
+#else
+static inline int mmc_davinci_cpufreq_register(struct mmc_davinci_host *host)
+{
+   return 0;
+}
+
+static inline void mmc_davinci_cpufreq_deregister(struct

[PATCH] davinci: fb: Calculate the clock divider from pixel clock info

2009-10-16 Thread Chaithrika U S
The clock divider value can be calculated from the pixel clock
value for the panel. This gives more flexiblity to the driver
to change the divider value on the fly as in the case of cpufreq
feature- support for which will be added shortly.

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
This patch applies to Linus' kernel tree

 drivers/video/da8xx-fb.c |   29 +
 1 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/drivers/video/da8xx-fb.c b/drivers/video/da8xx-fb.c
index d065894..7615939 100644
--- a/drivers/video/da8xx-fb.c
+++ b/drivers/video/da8xx-fb.c
@@ -113,6 +113,7 @@ struct da8xx_fb_par {
unsigned short pseudo_palette[16];
unsigned int databuf_sz;
unsigned int palette_sz;
+   unsigned int pxl_clk;
 };
 
 /* Variable Screen Information */
@@ -155,7 +156,7 @@ struct da8xx_panel {
int vfp;/* Vertical front porch */
int vbp;/* Vertical back porch */
int vsw;/* Vertical Sync Pulse Width */
-   int pxl_clk;/* Pixel clock */
+   unsigned intpxl_clk;/* Pixel clock */
unsigned char   invert_pxl_clk; /* Invert Pixel clock */
 };
 
@@ -171,7 +172,7 @@ static struct da8xx_panel known_lcd_panels[] = {
.vfp = 2,
.vbp = 2,
.vsw = 0,
-   .pxl_clk = 0x10,
+   .pxl_clk = 4608000,
.invert_pxl_clk = 1,
},
/* Sharp LK043T1DG01 */
@@ -185,7 +186,7 @@ static struct da8xx_panel known_lcd_panels[] = {
.vfp = 2,
.vbp = 2,
.vsw = 10,
-   .pxl_clk = 0x12,
+   .pxl_clk = 7833600,
.invert_pxl_clk = 0,
},
 };
@@ -451,17 +452,29 @@ static void lcd_reset(struct da8xx_fb_par *par)
lcdc_write(0, LCD_RASTER_CTRL_REG);
 }
 
+static void lcd_calc_clk_divider(struct da8xx_fb_par *par)
+{
+   unsigned int lcd_clk, div;
+
+   lcd_clk = clk_get_rate(par-lcdc_clk);
+   div = lcd_clk / par-pxl_clk;
+
+   /* Configure the LCD clock divisor. */
+   lcdc_write(LCD_CLK_DIVISOR(div) |
+   (LCD_RASTER_MODE  0x1), LCD_CTRL_REG);
+}
+
 static int lcd_init(struct da8xx_fb_par *par, const struct lcd_ctrl_config 
*cfg,
struct da8xx_panel *panel)
 {
u32 bpp;
int ret = 0;
+   unsigned int lcd_clk, div;
 
lcd_reset(par);
 
-   /* Configure the LCD clock divisor. */
-   lcdc_write(LCD_CLK_DIVISOR(panel-pxl_clk) |
-   (LCD_RASTER_MODE  0x1), LCD_CTRL_REG);
+   /* Calculate the divider */
+   lcd_calc_clk_divider(par);
 
if (panel-invert_pxl_clk)
lcdc_write((lcdc_read(LCD_RASTER_TIMING_2_REG) |
@@ -721,6 +734,8 @@ static int __init fb_probe(struct platform_device *device)
}
 
par = da8xx_fb_info-par;
+   par-lcdc_clk = fb_clk;
+   par-pxl_clk = lcdc_info-pxl_clk;
 
if (lcd_init(par, lcd_cfg, lcdc_info)  0) {
dev_err(device-dev, lcd_init failed\n);
@@ -753,8 +768,6 @@ static int __init fb_probe(struct platform_device *device)
da8xx_fb_fix.smem_len = par-databuf_sz - par-palette_sz;
da8xx_fb_fix.line_length = (lcdc_info-width * lcd_cfg-bpp) / 8;
 
-   par-lcdc_clk = fb_clk;
-
par-irq = platform_get_irq(device, 0);
if (par-irq  0) {
ret = -ENOENT;
-- 
1.5.6

___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


RE: [PATCH] davinci: fb: Calculate the clock divider from pixel clock info

2009-10-16 Thread Chaithrika U S
All,

Please ignore this patch, will post an updated version soon.

Regards, 
Chaithrika

On Fri, Oct 16, 2009 at 15:57:02, Chaithrika U S wrote:
 The clock divider value can be calculated from the pixel clock
 value for the panel. This gives more flexiblity to the driver
 to change the divider value on the fly as in the case of cpufreq
 feature- support for which will be added shortly.
 
 Signed-off-by: Chaithrika U S chaithr...@ti.com
 ---
 This patch applies to Linus' kernel tree
 
  drivers/video/da8xx-fb.c |   29 +
  1 files changed, 21 insertions(+), 8 deletions(-)
 
 diff --git a/drivers/video/da8xx-fb.c b/drivers/video/da8xx-fb.c
 index d065894..7615939 100644
 --- a/drivers/video/da8xx-fb.c
 +++ b/drivers/video/da8xx-fb.c
 @@ -113,6 +113,7 @@ struct da8xx_fb_par {
   unsigned short pseudo_palette[16];
   unsigned int databuf_sz;
   unsigned int palette_sz;
 + unsigned int pxl_clk;
  };
  
  /* Variable Screen Information */
 @@ -155,7 +156,7 @@ struct da8xx_panel {
   int vfp;/* Vertical front porch */
   int vbp;/* Vertical back porch */
   int vsw;/* Vertical Sync Pulse Width */
 - int pxl_clk;/* Pixel clock */
 + unsigned intpxl_clk;/* Pixel clock */
   unsigned char   invert_pxl_clk; /* Invert Pixel clock */
  };
  
 @@ -171,7 +172,7 @@ static struct da8xx_panel known_lcd_panels[] = {
   .vfp = 2,
   .vbp = 2,
   .vsw = 0,
 - .pxl_clk = 0x10,
 + .pxl_clk = 4608000,
   .invert_pxl_clk = 1,
   },
   /* Sharp LK043T1DG01 */
 @@ -185,7 +186,7 @@ static struct da8xx_panel known_lcd_panels[] = {
   .vfp = 2,
   .vbp = 2,
   .vsw = 10,
 - .pxl_clk = 0x12,
 + .pxl_clk = 7833600,
   .invert_pxl_clk = 0,
   },
  };
 @@ -451,17 +452,29 @@ static void lcd_reset(struct da8xx_fb_par *par)
   lcdc_write(0, LCD_RASTER_CTRL_REG);
  }
  
 +static void lcd_calc_clk_divider(struct da8xx_fb_par *par)
 +{
 + unsigned int lcd_clk, div;
 +
 + lcd_clk = clk_get_rate(par-lcdc_clk);
 + div = lcd_clk / par-pxl_clk;
 +
 + /* Configure the LCD clock divisor. */
 + lcdc_write(LCD_CLK_DIVISOR(div) |
 + (LCD_RASTER_MODE  0x1), LCD_CTRL_REG);
 +}
 +
  static int lcd_init(struct da8xx_fb_par *par, const struct lcd_ctrl_config 
 *cfg,
   struct da8xx_panel *panel)
  {
   u32 bpp;
   int ret = 0;
 + unsigned int lcd_clk, div;
  
   lcd_reset(par);
  
 - /* Configure the LCD clock divisor. */
 - lcdc_write(LCD_CLK_DIVISOR(panel-pxl_clk) |
 - (LCD_RASTER_MODE  0x1), LCD_CTRL_REG);
 + /* Calculate the divider */
 + lcd_calc_clk_divider(par);
  
   if (panel-invert_pxl_clk)
   lcdc_write((lcdc_read(LCD_RASTER_TIMING_2_REG) |
 @@ -721,6 +734,8 @@ static int __init fb_probe(struct platform_device *device)
   }
  
   par = da8xx_fb_info-par;
 + par-lcdc_clk = fb_clk;
 + par-pxl_clk = lcdc_info-pxl_clk;
  
   if (lcd_init(par, lcd_cfg, lcdc_info)  0) {
   dev_err(device-dev, lcd_init failed\n);
 @@ -753,8 +768,6 @@ static int __init fb_probe(struct platform_device *device)
   da8xx_fb_fix.smem_len = par-databuf_sz - par-palette_sz;
   da8xx_fb_fix.line_length = (lcdc_info-width * lcd_cfg-bpp) / 8;
  
 - par-lcdc_clk = fb_clk;
 -
   par-irq = platform_get_irq(device, 0);
   if (par-irq  0) {
   ret = -ENOENT;
 -- 
 1.5.6
 




___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


[PATCH] davinci: fb: Calculate the clock divider from pixel clock info

2009-10-16 Thread Chaithrika U S
The clock divider value can be calculated from the pixel clock
value for the panel. This gives more flexiblity to the driver
to change the divider value on the fly as in the case of cpufreq
feature- support for which will be added shortly.

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
This patch applies on Linus' kernel tree.

 drivers/video/da8xx-fb.c |   28 
 1 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/drivers/video/da8xx-fb.c b/drivers/video/da8xx-fb.c
index d065894..d9ab839 100644
--- a/drivers/video/da8xx-fb.c
+++ b/drivers/video/da8xx-fb.c
@@ -113,6 +113,7 @@ struct da8xx_fb_par {
unsigned short pseudo_palette[16];
unsigned int databuf_sz;
unsigned int palette_sz;
+   unsigned int pxl_clk;
 };
 
 /* Variable Screen Information */
@@ -155,7 +156,7 @@ struct da8xx_panel {
int vfp;/* Vertical front porch */
int vbp;/* Vertical back porch */
int vsw;/* Vertical Sync Pulse Width */
-   int pxl_clk;/* Pixel clock */
+   unsigned intpxl_clk;/* Pixel clock */
unsigned char   invert_pxl_clk; /* Invert Pixel clock */
 };
 
@@ -171,7 +172,7 @@ static struct da8xx_panel known_lcd_panels[] = {
.vfp = 2,
.vbp = 2,
.vsw = 0,
-   .pxl_clk = 0x10,
+   .pxl_clk = 4608000,
.invert_pxl_clk = 1,
},
/* Sharp LK043T1DG01 */
@@ -185,7 +186,7 @@ static struct da8xx_panel known_lcd_panels[] = {
.vfp = 2,
.vbp = 2,
.vsw = 10,
-   .pxl_clk = 0x12,
+   .pxl_clk = 7833600,
.invert_pxl_clk = 0,
},
 };
@@ -451,6 +452,18 @@ static void lcd_reset(struct da8xx_fb_par *par)
lcdc_write(0, LCD_RASTER_CTRL_REG);
 }
 
+static void lcd_calc_clk_divider(struct da8xx_fb_par *par)
+{
+   unsigned int lcd_clk, div;
+
+   lcd_clk = clk_get_rate(par-lcdc_clk);
+   div = lcd_clk / par-pxl_clk;
+
+   /* Configure the LCD clock divisor. */
+   lcdc_write(LCD_CLK_DIVISOR(div) |
+   (LCD_RASTER_MODE  0x1), LCD_CTRL_REG);
+}
+
 static int lcd_init(struct da8xx_fb_par *par, const struct lcd_ctrl_config 
*cfg,
struct da8xx_panel *panel)
 {
@@ -459,9 +472,8 @@ static int lcd_init(struct da8xx_fb_par *par, const struct 
lcd_ctrl_config *cfg,
 
lcd_reset(par);
 
-   /* Configure the LCD clock divisor. */
-   lcdc_write(LCD_CLK_DIVISOR(panel-pxl_clk) |
-   (LCD_RASTER_MODE  0x1), LCD_CTRL_REG);
+   /* Calculate the divider */
+   lcd_calc_clk_divider(par);
 
if (panel-invert_pxl_clk)
lcdc_write((lcdc_read(LCD_RASTER_TIMING_2_REG) |
@@ -721,6 +733,8 @@ static int __init fb_probe(struct platform_device *device)
}
 
par = da8xx_fb_info-par;
+   par-lcdc_clk = fb_clk;
+   par-pxl_clk = lcdc_info-pxl_clk;
 
if (lcd_init(par, lcd_cfg, lcdc_info)  0) {
dev_err(device-dev, lcd_init failed\n);
@@ -753,8 +767,6 @@ static int __init fb_probe(struct platform_device *device)
da8xx_fb_fix.smem_len = par-databuf_sz - par-palette_sz;
da8xx_fb_fix.line_length = (lcdc_info-width * lcd_cfg-bpp) / 8;
 
-   par-lcdc_clk = fb_clk;
-
par-irq = platform_get_irq(device, 0);
if (par-irq  0) {
ret = -ENOENT;
-- 
1.5.6

___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


[PATCH] davinci: MMC: add cpufreq support

2009-10-13 Thread Chaithrika U S
Add cpufreq support to MMC driver. The clock dividervalue has to be
modified according to the controller input frequency.

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
This patch applies to DaVinci GIT tree as the driver is not yet present in
Linus' tree.

 drivers/mmc/host/davinci_mmc.c |  100 +--
 1 files changed, 84 insertions(+), 16 deletions(-)

diff --git a/drivers/mmc/host/davinci_mmc.c b/drivers/mmc/host/davinci_mmc.c
index 6c76f64..dd45e7c 100644
--- a/drivers/mmc/host/davinci_mmc.c
+++ b/drivers/mmc/host/davinci_mmc.c
@@ -25,6 +25,7 @@
 #include linux/platform_device.h
 #include linux/clk.h
 #include linux/err.h
+#include linux/cpufreq.h
 #include linux/mmc/host.h
 #include linux/io.h
 #include linux/irq.h
@@ -200,6 +201,9 @@ struct mmc_davinci_host {
u8 version;
/* for ns in one cycle calculation */
unsigned ns_in_one_cycle;
+#ifdef CONFIG_CPU_FREQ
+   struct notifier_block   freq_transition;
+#endif
 };
 
 
@@ -739,27 +743,12 @@ static unsigned int calculate_freq_for_card(struct 
mmc_davinci_host *host,
return mmc_push_pull_divisor;
 }
 
-static void mmc_davinci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
+static void calculate_clk_divider(struct mmc_host *mmc, struct mmc_ios *ios)
 {
unsigned int open_drain_freq = 0, mmc_pclk = 0;
unsigned int mmc_push_pull_freq = 0;
struct mmc_davinci_host *host = mmc_priv(mmc);
 
-   mmc_pclk = host-mmc_input_clk;
-   dev_dbg(mmc_dev(host-mmc),
-   clock %dHz busmode %d powermode %d Vdd %04x\n,
-   ios-clock, ios-bus_mode, ios-power_mode,
-   ios-vdd);
-   if (ios-bus_width == MMC_BUS_WIDTH_4) {
-   dev_dbg(mmc_dev(host-mmc), Enabling 4 bit mode\n);
-   writel(readl(host-base + DAVINCI_MMCCTL) | MMCCTL_WIDTH_4_BIT,
-   host-base + DAVINCI_MMCCTL);
-   } else {
-   dev_dbg(mmc_dev(host-mmc), Disabling 4 bit mode\n);
-   writel(readl(host-base + DAVINCI_MMCCTL)  ~MMCCTL_WIDTH_4_BIT,
-   host-base + DAVINCI_MMCCTL);
-   }
-
if (ios-bus_mode == MMC_BUSMODE_OPENDRAIN) {
u32 temp;
 
@@ -798,6 +787,29 @@ static void mmc_davinci_set_ios(struct mmc_host *mmc, 
struct mmc_ios *ios)
 
udelay(10);
}
+}
+
+static void mmc_davinci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
+{
+   unsigned int mmc_pclk = 0;
+   struct mmc_davinci_host *host = mmc_priv(mmc);
+
+   mmc_pclk = host-mmc_input_clk;
+   dev_dbg(mmc_dev(host-mmc),
+   clock %dHz busmode %d powermode %d Vdd %04x\n,
+   ios-clock, ios-bus_mode, ios-power_mode,
+   ios-vdd);
+   if (ios-bus_width == MMC_BUS_WIDTH_4) {
+   dev_dbg(mmc_dev(host-mmc), Enabling 4 bit mode\n);
+   writel(readl(host-base + DAVINCI_MMCCTL) | MMCCTL_WIDTH_4_BIT,
+   host-base + DAVINCI_MMCCTL);
+   } else {
+   dev_dbg(mmc_dev(host-mmc), Disabling 4 bit mode\n);
+   writel(readl(host-base + DAVINCI_MMCCTL)  ~MMCCTL_WIDTH_4_BIT,
+   host-base + DAVINCI_MMCCTL);
+   }
+
+   calculate_clk_divider(mmc, ios);
 
host-bus_mode = ios-bus_mode;
if (ios-power_mode == MMC_POWER_UP) {
@@ -1040,6 +1052,52 @@ static struct mmc_host_ops mmc_davinci_ops = {
 
 /*--*/
 
+#ifdef CONFIG_CPU_FREQ
+static int mmc_davinci_cpufreq_transition(struct notifier_block *nb,
+unsigned long val, void *data)
+{
+   struct mmc_davinci_host *host;
+   unsigned int mmc_pclk;
+   struct mmc_host *mmc;
+   unsigned long flags;
+
+   host = container_of(nb, struct mmc_davinci_host, freq_transition);
+   mmc = host-mmc;
+   mmc_pclk = clk_get_rate(host-clk);
+
+   if (val == CPUFREQ_POSTCHANGE) {
+   spin_lock_irqsave(mmc-lock, flags);
+   host-mmc_input_clk = mmc_pclk;
+   calculate_clk_divider(mmc, mmc-ios);
+   spin_unlock_irqrestore(mmc-lock, flags);
+   }
+
+   return 0;
+}
+
+static inline int mmc_davinci_cpufreq_register(struct mmc_davinci_host *host)
+{
+   host-freq_transition.notifier_call = mmc_davinci_cpufreq_transition;
+
+   return cpufreq_register_notifier(host-freq_transition,
+CPUFREQ_TRANSITION_NOTIFIER);
+}
+
+static inline void mmc_davinci_cpufreq_deregister(struct mmc_davinci_host 
*host)
+{
+   cpufreq_unregister_notifier(host-freq_transition,
+   CPUFREQ_TRANSITION_NOTIFIER);
+}
+#else
+static inline int mmc_davinci_cpufreq_register(struct mmc_davinci_host *host)
+{
+   return 0;
+}
+
+static inline void mmc_davinci_cpufreq_deregister(struct mmc_davinci_host 
*host)
+{
+}
+#endif
 static void __init

[PATCH] davinci: DA850/OMAP-L138: Set ASYNC3 domain flag for McASP

2009-10-13 Thread Chaithrika U S
In the McASP clock definition add a flag to indicate that the peripheral clock
belongs to ASYNC3 clock domain.

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
 arch/arm/mach-davinci/da850.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c
index fcf74e6..d0d9dce 100644
--- a/arch/arm/mach-davinci/da850.c
+++ b/arch/arm/mach-davinci/da850.c
@@ -309,6 +309,7 @@ static struct clk mcasp_clk = {
.parent = pll0_sysclk2,
.lpsc   = DA8XX_LPSC1_McASP0,
.gpsc   = 1,
+   .flags  = DA850_CLK_ASYNC3,
 };
 
 static struct clk lcdc_clk = {
-- 
1.5.6

___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


RE: DM6446:eth0 problem in git kernel

2009-10-08 Thread Chaithrika U S
: network logging started
 i2c /dev entries driver
 TCP cubic registered
 NET: Registered protocol family 17
 RPC: Registered udp transport module.
 RPC: Registered tcp transport module.
 Clocks: disable unused uart1
 Clocks: disable unused uart2
 Clocks: disable unused ide
 Clocks: disable unused asp0
 Clocks: disable unused mmcsd
 Clocks: disable unused spi
 Clocks: disable unused usb
 Clocks: disable unused vlynq
 Clocks: disable unused pwm0
 Clocks: disable unused pwm1
 Clocks: disable unused pwm2
 Clocks: disable unused timer1
 eth0: no PHY found

It could be possible that the phy_mask info from the EMAC
platform data does not match the address of the PHY device.
You may want to check with phy_mask value of 0x to see
if the PHY device is detected.

Regards,
Chaithrika

 IP-Config: Failed to open eth0
 IP-Config: No network devices available.
 VFS: Unable to mount root fs via NFS, trying floppy.
 VFS: Cannot open root device nfs,nolock or unknown-block(2,0) Please 
 append a correct root= boot option; here are the available
 partitions:
 Kernel panic - not syncing: VFS: Unable to mount root fs on
 unknown-block(2,0)
 Backtrace:
 [c002b6a0] (dump_backtrace+0x0/0x110) from [c002b7e4]
 (dump_stack+0x18/0x1c)
  r6:c0021850 r5:c02ebe64 r4:c7023f58
 [c002b7cc] (dump_stack+0x0/0x1c) from [c003c038] 
 (panic+0x54/0x134) [c003bfe4] (panic+0x0/0x134) from [c0008fcc]
 (mount_block_root+0x1d4/0x21c)
  r3:0001 r2:c7022000 r1:c7023f58 r0:c0291804 [c0008df8] 
 (mount_block_root+0x0/0x21c) from [c00090d8]
 (mount_root+0xc4/0xfc)
 [c0009014] (mount_root+0x0/0xfc) from [c000927c]
 (prepare_namespace+0x16c/0x1d0)
  r5:c0021808 r4:c02eb944
 [c0009110] (prepare_namespace+0x0/0x1d0) from [c00087b8]
 (kernel_init+0xd8/0x10c)
  r5:c0020364 r4:c02eb938
 [c00086e0] (kernel_init+0x0/0x10c) from [c003f0d0]
 (do_exit+0x0/0x62c)
  r5: r4:
 
 With Regard's
 Rohan Tabish
 
   
 
 



___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


RE: [PATCH 1/2] davinci: DA850/OMAP-L138 EVM expander setup and UI card detection

2009-10-07 Thread Chaithrika U S
All,

Any comments/suggestions on this patch set?

Regards, 
Chaithrika

On Thu, Oct 01, 2009 at 02:30:28, Chaithrika U S wrote:
 DA850/OMAP-L138 EVM can be connected to an UI card which has various
 peripherals on it.The UI card has TCA6416 expander which can be probed
 to check whether the UI card is connected or not. If the UI card is
 connected, setup NOR and NAND devices. This is done via the expander
 setup callback.
 
 Signed-off-by: Chaithrika U S chaithr...@ti.com
 ---
  arch/arm/mach-davinci/board-da850-evm.c |  127 
 ---
  1 files changed, 99 insertions(+), 28 deletions(-)
 
 diff --git a/arch/arm/mach-davinci/board-da850-evm.c 
 b/arch/arm/mach-davinci/board-da850-evm.c
 index 25ae007..dd43644 100644
 --- a/arch/arm/mach-davinci/board-da850-evm.c
 +++ b/arch/arm/mach-davinci/board-da850-evm.c
 @@ -17,6 +17,7 @@
  #include linux/console.h
  #include linux/i2c.h
  #include linux/i2c/at24.h
 +#include linux/i2c/pca953x.h
  #include linux/gpio.h
  #include linux/platform_device.h
  #include linux/mtd/mtd.h
 @@ -144,10 +145,85 @@ static struct platform_device 
 da850_evm_nandflash_device = {
   .resource   = da850_evm_nandflash_resource,
  };
  
 +static u32 ui_card_detected;
 +static void da850_evm_setup_nor_nand(void);
 +
 +static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned 
 gpio,
 + unsigned ngpio, void *c)
 +{
 + int sel_a, sel_b, sel_c, ret;
 +
 + sel_a = gpio + 7;
 + sel_b = gpio + 6;
 + sel_c = gpio + 5;
 +
 + ret = gpio_request(sel_a, sel_a);
 + if (ret) {
 + pr_warning(Cannot open UI expander pin %d\n, sel_a);
 + goto exp_setup_sela_fail;
 + }
 +
 + ret = gpio_request(sel_b, sel_b);
 + if (ret) {
 + pr_warning(Cannot open UI expander pin %d\n, sel_b);
 + goto exp_setup_selb_fail;
 + }
 +
 + ret = gpio_request(sel_c, sel_c);
 + if (ret) {
 + pr_warning(Cannot open UI expander pin %d\n, sel_c);
 + goto exp_setup_selc_fail;
 + }
 +
 + /* deselect all functionalities */
 + gpio_direction_output(sel_a, 1);
 + gpio_direction_output(sel_b, 1);
 + gpio_direction_output(sel_c, 1);
 +
 + ui_card_detected = 1;
 + pr_info(DA850/OMAP-L138 EVM UI card detected\n);
 +
 + da850_evm_setup_nor_nand();
 +
 + return 0;
 +
 +exp_setup_selc_fail:
 + gpio_free(sel_b);
 +exp_setup_selb_fail:
 + gpio_free(sel_a);
 +exp_setup_sela_fail:
 + return ret;
 +}
 +
 +static int da850_evm_ui_expander_teardown(struct i2c_client *client,
 + unsigned gpio, unsigned ngpio, void *c)
 +{
 + /* deselect all functionalities */
 + gpio_set_value(gpio + 5, 1);
 + gpio_set_value(gpio + 6, 1);
 + gpio_set_value(gpio + 7, 1);
 +
 + gpio_free(gpio + 5);
 + gpio_free(gpio + 6);
 + gpio_free(gpio + 7);
 +
 + return 0;
 +}
 +
 +static struct pca953x_platform_data da850_evm_ui_expander_info = {
 + .gpio_base  = DAVINCI_N_GPIO,
 + .setup  = da850_evm_ui_expander_setup,
 + .teardown   = da850_evm_ui_expander_teardown,
 +};
 +
  static struct i2c_board_info __initdata da850_evm_i2c_devices[] = {
   {
   I2C_BOARD_INFO(tlv320aic3x, 0x18),
 - }
 + },
 + {
 + I2C_BOARD_INFO(tca6416, 0x20),
 + .platform_data = da850_evm_ui_expander_info,
 + },
  };
  
  static struct davinci_i2c_platform_data da850_evm_i2c_0_pdata = {
 @@ -251,13 +327,6 @@ static void __init da850_evm_init_nor(void)
   iounmap(aemif_addr);
  }
  
 -#if defined(CONFIG_MTD_PHYSMAP) || \
 -defined(CONFIG_MTD_PHYSMAP_MODULE)
 -#define HAS_NOR 1
 -#else
 -#define HAS_NOR 0
 -#endif
 -
  #if defined(CONFIG_MMC_DAVINCI) || \
  defined(CONFIG_MMC_DAVINCI_MODULE)
  #define HAS_MMC 1
 @@ -265,6 +334,28 @@ static void __init da850_evm_init_nor(void)
  #define HAS_MMC 0
  #endif
  
 +static void da850_evm_setup_nor_nand(void)
 +{
 + int ret = 0;
 +
 + if (ui_card_detected  !HAS_MMC) {
 + ret = da8xx_pinmux_setup(da850_nand_pins);
 + if (ret)
 + pr_warning(da850_evm_init: nand mux setup failed: 
 + %d\n, ret);
 +
 + ret = da8xx_pinmux_setup(da850_nor_pins);
 + if (ret)
 + pr_warning(da850_evm_init: nor mux setup failed: %d\n,
 + ret);
 +
 + da850_evm_init_nor();
 +
 + platform_add_devices(da850_evm_devices,
 + ARRAY_SIZE(da850_evm_devices));
 + }
 +}
 +
  static const short da850_evm_lcdc_pins[] = {
   DA850_GPIO2_8, DA850_GPIO2_15,
   -1
 @@ -275,21 +366,6 @@ static __init void da850_evm_init(void)
   struct davinci_soc_info *soc_info = davinci_soc_info;
   int ret;
  
 - ret = da8xx_pinmux_setup(da850_nand_pins

[PATCH] TI DaVinci EMAC: Minor macro related updates

2009-10-01 Thread Chaithrika U S
Use BIT for macro definitions wherever possible, remove
unused and redundant macros.

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
Applies to Linus' kernel tree

 drivers/net/davinci_emac.c |   26 +++---
 1 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/drivers/net/davinci_emac.c b/drivers/net/davinci_emac.c
index 65a2d0b..a421ec0 100644
--- a/drivers/net/davinci_emac.c
+++ b/drivers/net/davinci_emac.c
@@ -164,16 +164,14 @@ static const char emac_version_string[] = TI DaVinci 
EMAC Linux v6.1;
 # define EMAC_MBP_MCASTCHAN(ch)((ch)  0x7)
 
 /* EMAC mac_control register */
-#define EMAC_MACCONTROL_TXPTYPE(0x200)
-#define EMAC_MACCONTROL_TXPACEEN   (0x40)
-#define EMAC_MACCONTROL_MIIEN  (0x20)
-#define EMAC_MACCONTROL_GIGABITEN  (0x80)
-#define EMAC_MACCONTROL_GIGABITEN_SHIFT (7)
-#define EMAC_MACCONTROL_FULLDUPLEXEN   (0x1)
+#define EMAC_MACCONTROL_TXPTYPEBIT(9)
+#define EMAC_MACCONTROL_TXPACEEN   BIT(6)
+#define EMAC_MACCONTROL_GMIIEN BIT(5)
+#define EMAC_MACCONTROL_GIGABITEN  BIT(7)
+#define EMAC_MACCONTROL_FULLDUPLEXEN   BIT(0)
 #define EMAC_MACCONTROL_RMIISPEED_MASK BIT(15)
 
 /* GIGABIT MODE related bits */
-#define EMAC_DM646X_MACCONTORL_GMIIEN  BIT(5)
 #define EMAC_DM646X_MACCONTORL_GIG BIT(7)
 #define EMAC_DM646X_MACCONTORL_GIGFORCEBIT(17)
 
@@ -192,10 +190,10 @@ static const char emac_version_string[] = TI DaVinci 
EMAC Linux v6.1;
 #define EMAC_RX_BUFFER_OFFSET_MASK (0x)
 
 /* MAC_IN_VECTOR (0x180) register bit fields */
-#define EMAC_DM644X_MAC_IN_VECTOR_HOST_INT   (0x2)
-#define EMAC_DM644X_MAC_IN_VECTOR_STATPEND_INT   (0x1)
-#define EMAC_DM644X_MAC_IN_VECTOR_RX_INT_VEC (0x0100)
-#define EMAC_DM644X_MAC_IN_VECTOR_TX_INT_VEC (0x01)
+#define EMAC_DM644X_MAC_IN_VECTOR_HOST_INT BIT(17)
+#define EMAC_DM644X_MAC_IN_VECTOR_STATPEND_INT BIT(16)
+#define EMAC_DM644X_MAC_IN_VECTOR_RX_INT_VEC   BIT(8)
+#define EMAC_DM644X_MAC_IN_VECTOR_TX_INT_VEC   BIT(0)
 
 /** NOTE:: For DM646x the IN_VECTOR has changed */
 #define EMAC_DM646X_MAC_IN_VECTOR_RX_INT_VEC   BIT(EMAC_DEF_RX_CH)
@@ -203,7 +201,6 @@ static const char emac_version_string[] = TI DaVinci EMAC 
Linux v6.1;
 #define EMAC_DM646X_MAC_IN_VECTOR_HOST_INT BIT(26)
 #define EMAC_DM646X_MAC_IN_VECTOR_STATPEND_INT BIT(27)
 
-
 /* CPPI bit positions */
 #define EMAC_CPPI_SOP_BIT  BIT(31)
 #define EMAC_CPPI_EOP_BIT  BIT(30)
@@ -747,8 +744,7 @@ static void emac_update_phystatus(struct emac_priv *priv)
 
if (priv-speed == SPEED_1000  (priv-version == EMAC_VERSION_2)) {
mac_control = emac_read(EMAC_MACCONTROL);
-   mac_control |= (EMAC_DM646X_MACCONTORL_GMIIEN |
-   EMAC_DM646X_MACCONTORL_GIG |
+   mac_control |= (EMAC_DM646X_MACCONTORL_GIG |
EMAC_DM646X_MACCONTORL_GIGFORCE);
} else {
/* Clear the GIG bit and GIGFORCE bit */
@@ -2105,7 +2101,7 @@ static int emac_hw_enable(struct emac_priv *priv)
 
/* Enable MII */
val = emac_read(EMAC_MACCONTROL);
-   val |= (EMAC_MACCONTROL_MIIEN);
+   val |= (EMAC_MACCONTROL_GMIIEN);
emac_write(EMAC_MACCONTROL, val);
 
/* Enable NAPI and interrupts */
-- 
1.5.6

___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


[PATCH 2/2] davinci: RMII support for DA850/OMAP-L138 EVM

2009-09-30 Thread Chaithrika U S
DA850/OMAP-L138 EVM has a RMII Ethernet PHY on the UI daughter card. The PHY
is enabled by proper programming of the IO Expander (TCA6416) ports. Also for
RMII PHY to work, the MDIO clock of MII PHY has to be disabled since both the
PHYs have the same address. This is done via the GPIO2[6] pin. This patch adds
support for RMII PHY.

This patch also adds a menuconfig option to select one or no peripheral
connected to expander. Currently, sub-options in this menu are RMII and no
peripheral.This menuconfig option is similar to the one present for UI card on
DA830/OMAP-L137 EVM.

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
 arch/arm/mach-davinci/Kconfig  |   31 
 arch/arm/mach-davinci/board-da850-evm.c|   71 ++--
 arch/arm/mach-davinci/da850.c  |   17 +++
 arch/arm/mach-davinci/include/mach/da8xx.h |1 +
 arch/arm/mach-davinci/include/mach/mux.h   |9 
 5 files changed, 125 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-davinci/Kconfig b/arch/arm/mach-davinci/Kconfig
index 7b6dddf..806eefc 100644
--- a/arch/arm/mach-davinci/Kconfig
+++ b/arch/arm/mach-davinci/Kconfig
@@ -129,6 +129,37 @@ config MACH_DAVINCI_DA850_EVM
help
  Say Y here to select the TI DA850/OMAP-L138 Evaluation Module.
 
+config DA850_UI_EXP
+   bool DA850/OMAP-L138 UI (User Interface) board expander configuration
+   depends on MACH_DAVINCI_DA850_EVM
+   select GPIO_PCA953X
+   help
+ Say Y here if you have the DA850/OMAP-L138 UI
+ (User Interface) board installed and you want to
+ enable the peripherals located on User Interface
+ board contorlled by TCA6416 expander.
+
+choice
+   prompt Select peripherals connected to expander on UI board
+   depends on DA850_UI_EXP
+
+config DA850_UI_NONE
+   bool No peripheral is enabled
+   help
+ Say Y if you do not want to enable any of the peripherals connected
+ to TCA6416 expander on DA850/OMAP-L138 EVM UI card
+
+config DA850_UI_RMII
+   bool RMII Ethernet PHY
+   help
+ Say Y if you want to use the RMII PHY on the DA850/OMAP-L138 EVM.
+ This PHY is found on the UI daughter card that is supplied with
+ the EVM.
+ NOTE: Please take care while choosing this option, MII PHY will
+ not be functional if RMII mode is selected.
+
+endchoice
+
 config DAVINCI_MUX
bool DAVINCI multiplexing support
depends on ARCH_DAVINCI
diff --git a/arch/arm/mach-davinci/board-da850-evm.c 
b/arch/arm/mach-davinci/board-da850-evm.c
index dd43644..d6edafd 100644
--- a/arch/arm/mach-davinci/board-da850-evm.c
+++ b/arch/arm/mach-davinci/board-da850-evm.c
@@ -44,6 +44,8 @@
 #define DA850_MMCSD_CD_PIN GPIO_TO_PIN(4, 0)
 #define DA850_MMCSD_WP_PIN GPIO_TO_PIN(4, 1)
 
+#define DA850_MII_MDIO_CLKEN_PIN   GPIO_TO_PIN(2, 6)
+
 static struct mtd_partition da850_evm_norflash_partition[] = {
{
.name   = NOR filesystem,
@@ -151,6 +153,7 @@ static void da850_evm_setup_nor_nand(void);
 static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned 
gpio,
unsigned ngpio, void *c)
 {
+   struct davinci_soc_info *soc_info = davinci_soc_info;
int sel_a, sel_b, sel_c, ret;
 
sel_a = gpio + 7;
@@ -185,6 +188,10 @@ static int da850_evm_ui_expander_setup(struct i2c_client 
*client, unsigned gpio,
 
da850_evm_setup_nor_nand();
 
+   if (soc_info-emac_pdata-rmii_en)
+   /* enable RMII */
+   gpio_set_value(sel_a, 0);
+
return 0;
 
 exp_setup_selc_fail:
@@ -361,11 +368,69 @@ static const short da850_evm_lcdc_pins[] = {
-1
 };
 
+static int __init da850_evm_config_emac(u8 rmii_en)
+{
+   void __iomem *cfg_chip3_base;
+   int ret;
+   u32 val;
+
+   cfg_chip3_base = DA8XX_SYSCFG_VIRT(DA8XX_CFGCHIP3_REG);
+
+   /* configure the CFGCHIP3 register for RMII or MII */
+   val = __raw_readl(cfg_chip3_base);
+   if (rmii_en)
+   val |= BIT(8);
+   else
+   val = ~BIT(8);
+
+   __raw_writel(val, cfg_chip3_base);
+
+   if (!rmii_en)
+   ret = da8xx_pinmux_setup(da850_cpgmac_pins);
+   else
+   ret = da8xx_pinmux_setup(da850_rmii_pins);
+   if (ret)
+   pr_warning(da850_evm_init: cpgmac/rmii mux setup failed: %d\n,
+   ret);
+
+   ret = davinci_cfg_reg(DA850_GPIO2_6);
+   if (ret)
+   pr_warning(da850_evm_init:GPIO(2,6) mux setup 
+   failed\n);
+
+   ret = gpio_request(DA850_MII_MDIO_CLKEN_PIN, mdio_clk_en);
+   if (ret) {
+   pr_warning(Cannot open GPIO %d\n,
+   DA850_MII_MDIO_CLKEN_PIN);
+   return ret;
+   }
+
+   if (rmii_en

[PATCH 1/2] davinci: DA850/OMAP-L138 EVM expander setup and UI card detection

2009-09-30 Thread Chaithrika U S
DA850/OMAP-L138 EVM can be connected to an UI card which has various
peripherals on it.The UI card has TCA6416 expander which can be probed
to check whether the UI card is connected or not. If the UI card is
connected, setup NOR and NAND devices. This is done via the expander
setup callback.

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
 arch/arm/mach-davinci/board-da850-evm.c |  127 ---
 1 files changed, 99 insertions(+), 28 deletions(-)

diff --git a/arch/arm/mach-davinci/board-da850-evm.c 
b/arch/arm/mach-davinci/board-da850-evm.c
index 25ae007..dd43644 100644
--- a/arch/arm/mach-davinci/board-da850-evm.c
+++ b/arch/arm/mach-davinci/board-da850-evm.c
@@ -17,6 +17,7 @@
 #include linux/console.h
 #include linux/i2c.h
 #include linux/i2c/at24.h
+#include linux/i2c/pca953x.h
 #include linux/gpio.h
 #include linux/platform_device.h
 #include linux/mtd/mtd.h
@@ -144,10 +145,85 @@ static struct platform_device da850_evm_nandflash_device 
= {
.resource   = da850_evm_nandflash_resource,
 };
 
+static u32 ui_card_detected;
+static void da850_evm_setup_nor_nand(void);
+
+static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned 
gpio,
+   unsigned ngpio, void *c)
+{
+   int sel_a, sel_b, sel_c, ret;
+
+   sel_a = gpio + 7;
+   sel_b = gpio + 6;
+   sel_c = gpio + 5;
+
+   ret = gpio_request(sel_a, sel_a);
+   if (ret) {
+   pr_warning(Cannot open UI expander pin %d\n, sel_a);
+   goto exp_setup_sela_fail;
+   }
+
+   ret = gpio_request(sel_b, sel_b);
+   if (ret) {
+   pr_warning(Cannot open UI expander pin %d\n, sel_b);
+   goto exp_setup_selb_fail;
+   }
+
+   ret = gpio_request(sel_c, sel_c);
+   if (ret) {
+   pr_warning(Cannot open UI expander pin %d\n, sel_c);
+   goto exp_setup_selc_fail;
+   }
+
+   /* deselect all functionalities */
+   gpio_direction_output(sel_a, 1);
+   gpio_direction_output(sel_b, 1);
+   gpio_direction_output(sel_c, 1);
+
+   ui_card_detected = 1;
+   pr_info(DA850/OMAP-L138 EVM UI card detected\n);
+
+   da850_evm_setup_nor_nand();
+
+   return 0;
+
+exp_setup_selc_fail:
+   gpio_free(sel_b);
+exp_setup_selb_fail:
+   gpio_free(sel_a);
+exp_setup_sela_fail:
+   return ret;
+}
+
+static int da850_evm_ui_expander_teardown(struct i2c_client *client,
+   unsigned gpio, unsigned ngpio, void *c)
+{
+   /* deselect all functionalities */
+   gpio_set_value(gpio + 5, 1);
+   gpio_set_value(gpio + 6, 1);
+   gpio_set_value(gpio + 7, 1);
+
+   gpio_free(gpio + 5);
+   gpio_free(gpio + 6);
+   gpio_free(gpio + 7);
+
+   return 0;
+}
+
+static struct pca953x_platform_data da850_evm_ui_expander_info = {
+   .gpio_base  = DAVINCI_N_GPIO,
+   .setup  = da850_evm_ui_expander_setup,
+   .teardown   = da850_evm_ui_expander_teardown,
+};
+
 static struct i2c_board_info __initdata da850_evm_i2c_devices[] = {
{
I2C_BOARD_INFO(tlv320aic3x, 0x18),
-   }
+   },
+   {
+   I2C_BOARD_INFO(tca6416, 0x20),
+   .platform_data = da850_evm_ui_expander_info,
+   },
 };
 
 static struct davinci_i2c_platform_data da850_evm_i2c_0_pdata = {
@@ -251,13 +327,6 @@ static void __init da850_evm_init_nor(void)
iounmap(aemif_addr);
 }
 
-#if defined(CONFIG_MTD_PHYSMAP) || \
-defined(CONFIG_MTD_PHYSMAP_MODULE)
-#define HAS_NOR 1
-#else
-#define HAS_NOR 0
-#endif
-
 #if defined(CONFIG_MMC_DAVINCI) || \
 defined(CONFIG_MMC_DAVINCI_MODULE)
 #define HAS_MMC 1
@@ -265,6 +334,28 @@ static void __init da850_evm_init_nor(void)
 #define HAS_MMC 0
 #endif
 
+static void da850_evm_setup_nor_nand(void)
+{
+   int ret = 0;
+
+   if (ui_card_detected  !HAS_MMC) {
+   ret = da8xx_pinmux_setup(da850_nand_pins);
+   if (ret)
+   pr_warning(da850_evm_init: nand mux setup failed: 
+   %d\n, ret);
+
+   ret = da8xx_pinmux_setup(da850_nor_pins);
+   if (ret)
+   pr_warning(da850_evm_init: nor mux setup failed: %d\n,
+   ret);
+
+   da850_evm_init_nor();
+
+   platform_add_devices(da850_evm_devices,
+   ARRAY_SIZE(da850_evm_devices));
+   }
+}
+
 static const short da850_evm_lcdc_pins[] = {
DA850_GPIO2_8, DA850_GPIO2_15,
-1
@@ -275,21 +366,6 @@ static __init void da850_evm_init(void)
struct davinci_soc_info *soc_info = davinci_soc_info;
int ret;
 
-   ret = da8xx_pinmux_setup(da850_nand_pins);
-   if (ret)
-   pr_warning(da850_evm_init: nand mux setup failed: %d\n,
-   ret);
-
-   ret

[PATCH] ASoC: DaVinci: McASP FIFO related updates

2009-09-30 Thread Chaithrika U S
The DMA params for McASP with FIFO has been updated so that it works for
various FIFO levels. A member- 'fifo_level' has been added to the DMA
params data structure. The fifo_level can be adjusted by the tx[rx]_numevt
platform data. This is relevant only for DA8xx/OMAP-L1xx platforms. This
implementation has been tested for numevt values 1, 2, 4, 8.

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
Applies to ALSA GIT tree on branch topic/asoc at
http://git.kernel.org/?p=linux/kernel/git/tiwai/sound-2.6.git;a=shortlog;
h=topic/asoc

 sound/soc/davinci/davinci-i2s.c   |2 ++
 sound/soc/davinci/davinci-mcasp.c |   17 +++--
 sound/soc/davinci/davinci-pcm.c   |   21 ++---
 sound/soc/davinci/davinci-pcm.h   |1 +
 4 files changed, 28 insertions(+), 13 deletions(-)

diff --git a/sound/soc/davinci/davinci-i2s.c b/sound/soc/davinci/davinci-i2s.c
index 4ae7070..2ab8093 100644
--- a/sound/soc/davinci/davinci-i2s.c
+++ b/sound/soc/davinci/davinci-i2s.c
@@ -397,6 +397,8 @@ static int davinci_i2s_hw_params(struct snd_pcm_substream 
*substream,
}
 
dma_params-acnt  = dma_params-data_type;
+   dma_params-fifo_level = 0;
+
rcr |= DAVINCI_MCBSP_RCR_RFRLEN1(1);
xcr |= DAVINCI_MCBSP_XCR_XFRLEN1(1);
 
diff --git a/sound/soc/davinci/davinci-mcasp.c 
b/sound/soc/davinci/davinci-mcasp.c
index 5d1f98a..50ad051 100644
--- a/sound/soc/davinci/davinci-mcasp.c
+++ b/sound/soc/davinci/davinci-mcasp.c
@@ -714,16 +714,13 @@ static int davinci_mcasp_hw_params(struct 
snd_pcm_substream *substream,
struct davinci_pcm_dma_params *dma_params =
dev-dma_params[substream-stream];
int word_length;
-   u8 numevt;
+   u8 fifo_level;
 
davinci_hw_common_param(dev, substream-stream);
if (substream-stream == SNDRV_PCM_STREAM_PLAYBACK)
-   numevt = dev-txnumevt;
+   fifo_level = dev-txnumevt;
else
-   numevt = dev-rxnumevt;
-
-   if (!numevt)
-   numevt = 1;
+   fifo_level = dev-rxnumevt;
 
if (dev-op_mode == DAVINCI_MCASP_DIT_MODE)
davinci_hw_dit_param(dev);
@@ -751,12 +748,12 @@ static int davinci_mcasp_hw_params(struct 
snd_pcm_substream *substream,
return -EINVAL;
}
 
-   if (dev-version == MCASP_VERSION_2) {
-   dma_params-data_type *= numevt;
-   dma_params-acnt = 4 * numevt;
-   } else
+   if (dev-version == MCASP_VERSION_2  !fifo_level)
+   dma_params-acnt = 4;
+   else
dma_params-acnt = dma_params-data_type;
 
+   dma_params-fifo_level = fifo_level;
davinci_config_channel_size(dev, word_length);
 
return 0;
diff --git a/sound/soc/davinci/davinci-pcm.c b/sound/soc/davinci/davinci-pcm.c
index 359e99e..1152d8b 100644
--- a/sound/soc/davinci/davinci-pcm.c
+++ b/sound/soc/davinci/davinci-pcm.c
@@ -66,38 +66,53 @@ static void davinci_pcm_enqueue_dma(struct 
snd_pcm_substream *substream)
dma_addr_t dma_pos;
dma_addr_t src, dst;
unsigned short src_bidx, dst_bidx;
+   unsigned short src_cidx, dst_cidx;
unsigned int data_type;
unsigned short acnt;
unsigned int count;
+   unsigned int fifo_level;
 
period_size = snd_pcm_lib_period_bytes(substream);
dma_offset = prtd-period * period_size;
dma_pos = runtime-dma_addr + dma_offset;
+   fifo_level = prtd-params-fifo_level;
 
pr_debug(davinci_pcm: audio_set_dma_params_play channel = %d 
dma_ptr = %x period_size=%x\n, lch, dma_pos, period_size);
 
data_type = prtd-params-data_type;
count = period_size / data_type;
+   if (fifo_level)
+   count /= fifo_level;
 
if (substream-stream == SNDRV_PCM_STREAM_PLAYBACK) {
src = dma_pos;
dst = prtd-params-dma_addr;
src_bidx = data_type;
dst_bidx = 0;
+   src_cidx = data_type * fifo_level;
+   dst_cidx = 0;
} else {
src = prtd-params-dma_addr;
dst = dma_pos;
src_bidx = 0;
dst_bidx = data_type;
+   src_cidx = 0;
+   dst_cidx = data_type * fifo_level;
}
 
acnt = prtd-params-acnt;
edma_set_src(lch, src, INCR, W8BIT);
edma_set_dest(lch, dst, INCR, W8BIT);
-   edma_set_src_index(lch, src_bidx, 0);
-   edma_set_dest_index(lch, dst_bidx, 0);
-   edma_set_transfer_params(lch, acnt, count, 1, 0, ASYNC);
+
+   edma_set_src_index(lch, src_bidx, src_cidx);
+   edma_set_dest_index(lch, dst_bidx, dst_cidx);
+
+   if (!fifo_level)
+   edma_set_transfer_params(lch, acnt, count, 1, 0, ASYNC);
+   else
+   edma_set_transfer_params(lch, acnt, fifo_level, count,
+   fifo_level

RE: [alsa-devel] [PATCH] ASoC: DaVinci: McASP FIFO related updates

2009-09-30 Thread Chaithrika U S
On Thu, Oct 01, 2009 at 01:43:02, Troy Kisky wrote:
 Chaithrika U S wrote:
  The DMA params for McASP with FIFO has been updated so that it works for
  various FIFO levels. A member- 'fifo_level' has been added to the DMA
  params data structure. The fifo_level can be adjusted by the tx[rx]_numevt
  platform data. This is relevant only for DA8xx/OMAP-L1xx platforms. This
  implementation has been tested for numevt values 1, 2, 4, 8.
  +   if (fifo_level)
  +   count /= fifo_level;
 
 So can this be fifo_shift instead
   count = fifo_shift;
 

No, it cannot be so. The fifo_level can take any value.
Have tried with values 3, 5 too...

Regards, 
Chaithrika


___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


[PATCH v3] davinci: RMII support for DA850/OMAP-L138 EVM

2009-09-29 Thread Chaithrika U S
DA850/OMAP-L138 EVM has a RMII Ethernet PHY on the UI daughter card. The PHY
is enabled by proper programming of the IO Expander (TCA6416) ports. Also for
RMII PHY to work, the MDIO clock of MII PHY has to be disabled since both the
PHYs have the same address. This is done via the GPIO2[6] pin. This patch adds
support for RMII PHY.

This patch also adds a menuconfig option to select UI card and peripherals
present on it. Currently, the only sub-option in this menu is RMII.
This menuconfig option is similar to the one present for UI card on
DA830/OMAP-L137 EVM.

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
 arch/arm/mach-davinci/Kconfig  |   24 +
 arch/arm/mach-davinci/board-da850-evm.c|  148 +++-
 arch/arm/mach-davinci/da850.c  |   17 +++
 arch/arm/mach-davinci/include/mach/da8xx.h |1 +
 arch/arm/mach-davinci/include/mach/mux.h   |9 ++
 5 files changed, 194 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-davinci/Kconfig b/arch/arm/mach-davinci/Kconfig
index 7b6dddf..665e7b1 100644
--- a/arch/arm/mach-davinci/Kconfig
+++ b/arch/arm/mach-davinci/Kconfig
@@ -129,6 +129,30 @@ config MACH_DAVINCI_DA850_EVM
help
  Say Y here to select the TI DA850/OMAP-L138 Evaluation Module.
 
+config DA850_UI_EXP
+   bool DA850/OMAP-L138 UI (User Interface) board expander configuration
+   depends on MACH_DAVINCI_DA850_EVM
+   help
+ Say Y here if you have the DA850/OMAP-L138 UI
+ (User Interface) board installed and you want to
+ enable the peripherals located on User Interface
+ board contorlled by TCA6416 expander.
+
+choice
+   prompt Select peripherals connected to expander on UI board
+   depends on DA850_UI_EXP
+
+config DA850_UI_RMII
+   bool RMII Ethernet PHY
+   help
+ Say Y if you want to use the RMII PHY on the DA850/OMAP-L138 EVM.
+ This PHY is found on the UI daughter card that is supplied with
+ the EVM.
+ NOTE: Please take care while choosing this option, MII PHY will
+ not be functional if RMII mode is selected.
+
+endchoice
+
 config DAVINCI_MUX
bool DAVINCI multiplexing support
depends on ARCH_DAVINCI
diff --git a/arch/arm/mach-davinci/board-da850-evm.c 
b/arch/arm/mach-davinci/board-da850-evm.c
index 25ae007..5f9512c 100644
--- a/arch/arm/mach-davinci/board-da850-evm.c
+++ b/arch/arm/mach-davinci/board-da850-evm.c
@@ -17,6 +17,7 @@
 #include linux/console.h
 #include linux/i2c.h
 #include linux/i2c/at24.h
+#include linux/i2c/pca953x.h
 #include linux/gpio.h
 #include linux/platform_device.h
 #include linux/mtd/mtd.h
@@ -43,6 +44,8 @@
 #define DA850_MMCSD_CD_PIN GPIO_TO_PIN(4, 0)
 #define DA850_MMCSD_WP_PIN GPIO_TO_PIN(4, 1)
 
+#define DA850_MII_MDIO_CLKEN_PIN   GPIO_TO_PIN(2, 6)
+
 static struct mtd_partition da850_evm_norflash_partition[] = {
{
.name   = NOR filesystem,
@@ -270,11 +273,148 @@ static const short da850_evm_lcdc_pins[] = {
-1
 };
 
+#ifdef CONFIG_DA850_UI_EXP
+static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned 
gpio,
+   unsigned ngpio, void *c)
+{
+   struct davinci_soc_info *soc_info = davinci_soc_info;
+   int sel_a, sel_b, sel_c, ret;
+
+   sel_a = gpio + 7;
+   sel_b = gpio + 6;
+   sel_c = gpio + 5;
+
+   ret = gpio_request(sel_a, sel_a);
+   if (ret) {
+   pr_warning(Cannot open UI expander pin %d\n, sel_a);
+   goto exp_setup_sela_fail;
+   }
+
+   ret = gpio_request(sel_b, sel_b);
+   if (ret) {
+   pr_warning(Cannot open UI expander pin %d\n, sel_b);
+   goto exp_setup_selb_fail;
+   }
+
+   ret = gpio_request(sel_c, sel_c);
+   if (ret) {
+   pr_warning(Cannot open UI expander pin %d\n, sel_c);
+   goto exp_setup_selc_fail;
+   }
+
+   /* deselect all functionalities */
+   gpio_direction_output(sel_a, 1);
+   gpio_direction_output(sel_b, 1);
+   gpio_direction_output(sel_c, 1);
+
+   if (soc_info-emac_pdata-rmii_en)
+   /* enable RMII */
+   gpio_set_value(sel_a, 0);
+
+   return 0;
+
+exp_setup_selc_fail:
+   gpio_free(sel_b);
+exp_setup_selb_fail:
+   gpio_free(sel_a);
+exp_setup_sela_fail:
+   return ret;
+}
+
+static int da850_evm_ui_expander_teardown(struct i2c_client *client,
+   unsigned gpio, unsigned ngpio, void *c)
+{
+   /* deselect all functionalities */
+   gpio_set_value(gpio + 5, 1);
+   gpio_set_value(gpio + 6, 1);
+   gpio_set_value(gpio + 7, 1);
+
+   gpio_free(gpio + 5);
+   gpio_free(gpio + 6);
+   gpio_free(gpio + 7);
+
+   return 0;
+}
+
+static struct pca953x_platform_data da850_evm_ui_expander_info = {
+   .gpio_base  = DAVINCI_N_GPIO,
+   .setup

RE: [PATCH v2] davinci: RMII support for DA850/OMAP-L138 EVM

2009-09-23 Thread Chaithrika U S
On Tue, Sep 22, 2009 at 18:35:12, Sergei Shtylyov wrote:
 Hello.
 
 Chaithrika U S wrote:
 
  DA850/OMAP-L138 EVM has a RMII Ethernet PHY on the UI daughter card. The PHY
  is enabled by proper programming of the IO Expander (TCA6416) ports. Also 
  for
  RMII PHY to work, the MDIO clock of MII PHY has to be disabled since both 
  the
  PHYs have the same address. This is done via the GPIO2[6] pin. This patch 
  adds
  support for RMII PHY.
  
  This patch also adds a menuconfig option to select UI card and peripherals
  present on it. Currently, the only sub-option in this menu is RMII.
  This menuconfig option is similar to the one present for UI card on
  DA830/OMAP-L137 EVM.
  
  Signed-off-by: Chaithrika U S chaithr...@ti.com
 
 [...]
 
  diff --git a/arch/arm/mach-davinci/Kconfig b/arch/arm/mach-davinci/Kconfig
  index 7b6dddf..4ee61cc 100644
  --- a/arch/arm/mach-davinci/Kconfig
  +++ b/arch/arm/mach-davinci/Kconfig
  @@ -129,6 +129,32 @@ config MACH_DAVINCI_DA850_EVM
  help
Say Y here to select the TI DA850/OMAP-L138 Evaluation Module.
   
  +config DA850_UI
  +   bool DA850/OMAP-L138 UI (User Interface) board support
  +   depends on MACH_DAVINCI_DA850_EVM
  +   help
  + Say Y here if you have the DA850/OMAP-L138 UI
  + (User Interface) board installed and you want to
  + enable the peripherals located on User Interface
  + board.
  +
  +choice
  +   prompt Select DA850/OMAP-L138 UI board peripheral
  +   depends on DA850_UI
 
  Are the devices on the UI board really mutually exclusive?
 

Yes, the devices are mutually exclusive.

  +
  +config DA850_UI_RMII
  +   bool RMII Ethernet PHY
  +   help
  + Say Y if you want to use the RMII PHY on the DA850/OMAP-L138 EVM.
  + This PHY is found on the UI daughter card that is supplied with
  + the EVM.
  + NOTE: Please take care while choosing this option, MII PHY will
  + not be functional if RMII mode is selected. This also affects
  + the operation of video devices as they are pin multiplexed with
  + RMII pins.
 
 Perhaps it's worth printing out a message about this when DA850_UI_RMII 
 is enabled?
 

OK.

  diff --git a/arch/arm/mach-davinci/board-da850-evm.c 
  b/arch/arm/mach-davinci/board-da850-evm.c
  index 25ae007..43cc629 100644
  --- a/arch/arm/mach-davinci/board-da850-evm.c
  +++ b/arch/arm/mach-davinci/board-da850-evm.c
 [...]
  @@ -43,6 +44,8 @@
   #define DA850_MMCSD_CD_PIN GPIO_TO_PIN(4, 0)
   #define DA850_MMCSD_WP_PIN GPIO_TO_PIN(4, 1)
   
  +#define DA850_MII_MDIO_CLKEN_PIN   GPIO_TO_PIN(2, 6)
  +
   static struct mtd_partition da850_evm_norflash_partition[] = {
  {
  .name   = NOR filesystem,
  @@ -270,11 +273,141 @@ static const short da850_evm_lcdc_pins[] = {
  -1
   };
   
  +#ifdef CONFIG_DA850_UI
  +static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned 
  gpio,
  +   unsigned ngpio, void *c)
  +{
  +   struct davinci_soc_info *soc_info = davinci_soc_info;
  +   int sel_a, sel_b, sel_c, ret;
  +
  +   sel_a = gpio + 7;
  +   sel_b = gpio + 6;
  +   sel_c = gpio + 5;
  +
  +   ret = gpio_request(sel_a, sel_a);
  +   if (ret) {
  +   pr_warning(Cannot open UI expander pin %d\n, sel_a);
  +   goto exp_setup_sela_fail;
  +   }
  +
  +   ret = gpio_request(sel_b, sel_b);
  +   if (ret) {
  +   pr_warning(Cannot open UI expander pin %d\n, sel_b);
  +   goto exp_setup_selb_fail;
  +   }
  +
  +   ret = gpio_request(sel_c, sel_c);
  +   if (ret) {
  +   pr_warning(Cannot open UI expander pin %d\n, sel_c);
  +   goto exp_setup_selc_fail;
  +   }
  +
  +   /* deselect all fucntionalities */
  +   gpio_direction_output(sel_a, 1);
  +   gpio_direction_output(sel_b, 1);
  +   gpio_direction_output(sel_c, 1);
  +
  +   if (soc_info-emac_pdata-rmii_en)
  +   /* enable RMII */
  +   gpio_direction_output(sel_a, 0);
 
 gpio_set_value() is enough.
 
  +static int da850_evm_ui_expander_teardown(struct i2c_client *client,
  +   unsigned gpio, unsigned ngpio, void *c)
  +{
  +   /* deselect all fucntionalities */
 
 Functionalities. :-)
 
  +static int __init da850_evm_config_emac(u8 rmii_en)
  +{
  +   void __iomem *cfg_chip3_base;
  +   int ret;
  +   u32 val;
  +
  +   cfg_chip3_base = DA8XX_SYSCFG_VIRT(DA8XX_CFGCHIP3_REG);
  +
  +   /* configure the CFGCHIP3 register for RMII or MII */
  +   val = __raw_readl(cfg_chip3_base);
  +   if (rmii_en)
  +   val |= BIT(8);
  +   else
  +   val = ~BIT(8);
  +
  +   __raw_writel(val, cfg_chip3_base);
  +
  +   if (!rmii_en)
  +   ret = da8xx_pinmux_setup(da850_cpgmac_pins);
  +   else
  +   ret = da8xx_pinmux_setup(da850_rmii_pins);
  +   if (ret)
  +   pr_warning(da850_evm_init: cpgmac/rmii mux setup failed: %d\n,
  +   ret);
  +
  +   if (rmii_en

RE: [PATCH v2] davinci: RMII support for DA850/OMAP-L138 EVM

2009-09-23 Thread Chaithrika U S
On Wed, Sep 23, 2009 at 02:10:13, Sergei Shtylyov wrote:
 Hello.
 
 Nori, Sekhar wrote:
 
  is enabled by proper programming of the IO Expander (TCA6416) ports. Also 
  for
  RMII PHY to work, the MDIO clock of MII PHY has to be disabled since both 
  the
  PHYs have the same address. This is done via the GPIO2[6] pin. This patch 
  adds
  support for RMII PHY.
 
  This patch also adds a menuconfig option to select UI card and peripherals
  present on it. Currently, the only sub-option in this menu is RMII.
  This menuconfig option is similar to the one present for UI card on
  DA830/OMAP-L137 EVM.
 
  Signed-off-by: Chaithrika U S chaithr...@ti.com

  [...]
  
  diff --git a/arch/arm/mach-davinci/Kconfig b/arch/arm/mach-davinci/Kconfig
  index 7b6dddf..4ee61cc 100644
  --- a/arch/arm/mach-davinci/Kconfig
  +++ b/arch/arm/mach-davinci/Kconfig
  @@ -129,6 +129,32 @@ config MACH_DAVINCI_DA850_EVM
  help
Say Y here to select the TI DA850/OMAP-L138 Evaluation Module.
 
  +config DA850_UI
  +   bool DA850/OMAP-L138 UI (User Interface) board support
  +   depends on MACH_DAVINCI_DA850_EVM
  +   help
  + Say Y here if you have the DA850/OMAP-L138 UI
  + (User Interface) board installed and you want to
  + enable the peripherals located on User Interface
  + board.
  +
  +choice
  +   prompt Select DA850/OMAP-L138 UI board peripheral
  +   depends on DA850_UI

   Are the devices on the UI board really mutually exclusive?
  
 
  What is the purpose of the UI board configuration? Is it just to
  provide one place where all UI board peripherals can be disabled?

 
In case of DA830 EVM, it's a place where the UI board support can be 
 disabled -- you can't do that with the 'choice' statement which would 
 alwys select at least one item. But it's not only that. The board has 
 the GPIO expander which we need not support (and setup) if the board is 
 absent. It was not clear to me where the TCA6414 GPIO expander is 
 situated on DA850 EVM -- on the board itself or on the UI daughter board...
 

TCA6416 is present on the UI card for DA850/OMAP-L138 EVM.


Regards, 
Chaithrika


___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


[PATCH v2] davinci: RMII support for DA850/OMAP-L138 EVM

2009-09-22 Thread Chaithrika U S
DA850/OMAP-L138 EVM has a RMII Ethernet PHY on the UI daughter card. The PHY
is enabled by proper programming of the IO Expander (TCA6416) ports. Also for
RMII PHY to work, the MDIO clock of MII PHY has to be disabled since both the
PHYs have the same address. This is done via the GPIO2[6] pin. This patch adds
support for RMII PHY.

This patch also adds a menuconfig option to select UI card and peripherals
present on it. Currently, the only sub-option in this menu is RMII.
This menuconfig option is similar to the one present for UI card on
DA830/OMAP-L137 EVM.

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
 arch/arm/mach-davinci/Kconfig  |   26 +
 arch/arm/mach-davinci/board-da850-evm.c|  141 +++-
 arch/arm/mach-davinci/da850.c  |   17 
 arch/arm/mach-davinci/include/mach/da8xx.h |1 +
 arch/arm/mach-davinci/include/mach/mux.h   |9 ++
 5 files changed, 189 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-davinci/Kconfig b/arch/arm/mach-davinci/Kconfig
index 7b6dddf..4ee61cc 100644
--- a/arch/arm/mach-davinci/Kconfig
+++ b/arch/arm/mach-davinci/Kconfig
@@ -129,6 +129,32 @@ config MACH_DAVINCI_DA850_EVM
help
  Say Y here to select the TI DA850/OMAP-L138 Evaluation Module.
 
+config DA850_UI
+   bool DA850/OMAP-L138 UI (User Interface) board support
+   depends on MACH_DAVINCI_DA850_EVM
+   help
+ Say Y here if you have the DA850/OMAP-L138 UI
+ (User Interface) board installed and you want to
+ enable the peripherals located on User Interface
+ board.
+
+choice
+   prompt Select DA850/OMAP-L138 UI board peripheral
+   depends on DA850_UI
+
+config DA850_UI_RMII
+   bool RMII Ethernet PHY
+   help
+ Say Y if you want to use the RMII PHY on the DA850/OMAP-L138 EVM.
+ This PHY is found on the UI daughter card that is supplied with
+ the EVM.
+ NOTE: Please take care while choosing this option, MII PHY will
+ not be functional if RMII mode is selected. This also affects
+ the operation of video devices as they are pin multiplexed with
+ RMII pins.
+
+endchoice
+
 config DAVINCI_MUX
bool DAVINCI multiplexing support
depends on ARCH_DAVINCI
diff --git a/arch/arm/mach-davinci/board-da850-evm.c 
b/arch/arm/mach-davinci/board-da850-evm.c
index 25ae007..43cc629 100644
--- a/arch/arm/mach-davinci/board-da850-evm.c
+++ b/arch/arm/mach-davinci/board-da850-evm.c
@@ -17,6 +17,7 @@
 #include linux/console.h
 #include linux/i2c.h
 #include linux/i2c/at24.h
+#include linux/i2c/pca953x.h
 #include linux/gpio.h
 #include linux/platform_device.h
 #include linux/mtd/mtd.h
@@ -43,6 +44,8 @@
 #define DA850_MMCSD_CD_PIN GPIO_TO_PIN(4, 0)
 #define DA850_MMCSD_WP_PIN GPIO_TO_PIN(4, 1)
 
+#define DA850_MII_MDIO_CLKEN_PIN   GPIO_TO_PIN(2, 6)
+
 static struct mtd_partition da850_evm_norflash_partition[] = {
{
.name   = NOR filesystem,
@@ -270,11 +273,141 @@ static const short da850_evm_lcdc_pins[] = {
-1
 };
 
+#ifdef CONFIG_DA850_UI
+static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned 
gpio,
+   unsigned ngpio, void *c)
+{
+   struct davinci_soc_info *soc_info = davinci_soc_info;
+   int sel_a, sel_b, sel_c, ret;
+
+   sel_a = gpio + 7;
+   sel_b = gpio + 6;
+   sel_c = gpio + 5;
+
+   ret = gpio_request(sel_a, sel_a);
+   if (ret) {
+   pr_warning(Cannot open UI expander pin %d\n, sel_a);
+   goto exp_setup_sela_fail;
+   }
+
+   ret = gpio_request(sel_b, sel_b);
+   if (ret) {
+   pr_warning(Cannot open UI expander pin %d\n, sel_b);
+   goto exp_setup_selb_fail;
+   }
+
+   ret = gpio_request(sel_c, sel_c);
+   if (ret) {
+   pr_warning(Cannot open UI expander pin %d\n, sel_c);
+   goto exp_setup_selc_fail;
+   }
+
+   /* deselect all fucntionalities */
+   gpio_direction_output(sel_a, 1);
+   gpio_direction_output(sel_b, 1);
+   gpio_direction_output(sel_c, 1);
+
+   if (soc_info-emac_pdata-rmii_en)
+   /* enable RMII */
+   gpio_direction_output(sel_a, 0);
+
+   return 0;
+
+exp_setup_selc_fail:
+   gpio_free(sel_b);
+exp_setup_selb_fail:
+   gpio_free(sel_a);
+exp_setup_sela_fail:
+   return ret;
+}
+
+static int da850_evm_ui_expander_teardown(struct i2c_client *client,
+   unsigned gpio, unsigned ngpio, void *c)
+{
+   /* deselect all fucntionalities */
+   gpio_direction_output(gpio + 5, 1);
+   gpio_direction_output(gpio + 6, 1);
+   gpio_direction_output(gpio + 7, 1);
+
+   gpio_free(gpio + 5);
+   gpio_free(gpio + 6);
+   gpio_free(gpio + 7);
+
+   return 0;
+}
+
+static struct pca953x_platform_data

[PATCH] ASoC: DaVinci: Correct McASP FIFO initialization

2009-09-22 Thread Chaithrika U S
McASP write FIFO registers should be modified for playback and read FIFO
registers for capture. Check the PCM mode before manipulating the
FIFO registers. Currently, irrespective of playback/capture both the
FIFOs are enabled or disbaled. This resulted in errors in audio loopback
mode.

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
Applies to ALSA GIT tree on branch topic/asoc at
http://git.kernel.org/?p=linux/kernel/git/tiwai/sound-2.6.git;a=shortlog;
h=topic/asoc

 sound/soc/davinci/davinci-mcasp.c |   36 ++--
 1 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/sound/soc/davinci/davinci-mcasp.c 
b/sound/soc/davinci/davinci-mcasp.c
index 7a06c0a..613fd98 100644
--- a/sound/soc/davinci/davinci-mcasp.c
+++ b/sound/soc/davinci/davinci-mcasp.c
@@ -386,17 +386,17 @@ static void mcasp_start_tx(struct davinci_audio_dev *dev)
 
 static void davinci_mcasp_start(struct davinci_audio_dev *dev, int stream)
 {
-   if (stream == SNDRV_PCM_STREAM_PLAYBACK)
+   if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
+   if (dev-txnumevt)  /* enable FIFO */
+   mcasp_set_bits(dev-base + DAVINCI_MCASP_WFIFOCTL,
+   FIFO_ENABLE);
mcasp_start_tx(dev);
-   else
+   } else {
+   if (dev-rxnumevt)  /* enable FIFO */
+   mcasp_set_bits(dev-base + DAVINCI_MCASP_RFIFOCTL,
+   FIFO_ENABLE);
mcasp_start_rx(dev);
-
-   /* enable FIFO */
-   if (dev-txnumevt)
-   mcasp_set_bits(dev-base + DAVINCI_MCASP_WFIFOCTL, FIFO_ENABLE);
-
-   if (dev-rxnumevt)
-   mcasp_set_bits(dev-base + DAVINCI_MCASP_RFIFOCTL, FIFO_ENABLE);
+   }
 }
 
 static void mcasp_stop_rx(struct davinci_audio_dev *dev)
@@ -413,17 +413,17 @@ static void mcasp_stop_tx(struct davinci_audio_dev *dev)
 
 static void davinci_mcasp_stop(struct davinci_audio_dev *dev, int stream)
 {
-   if (stream == SNDRV_PCM_STREAM_PLAYBACK)
+   if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
+   if (dev-txnumevt)  /* disable FIFO */
+   mcasp_clr_bits(dev-base + DAVINCI_MCASP_WFIFOCTL,
+   FIFO_ENABLE);
mcasp_stop_tx(dev);
-   else
+   } else {
+   if (dev-rxnumevt)  /* disable FIFO */
+   mcasp_clr_bits(dev-base + DAVINCI_MCASP_RFIFOCTL,
+   FIFO_ENABLE);
mcasp_stop_rx(dev);
-
-   /* disable FIFO */
-   if (dev-txnumevt)
-   mcasp_clr_bits(dev-base + DAVINCI_MCASP_WFIFOCTL, FIFO_ENABLE);
-
-   if (dev-rxnumevt)
-   mcasp_clr_bits(dev-base + DAVINCI_MCASP_RFIFOCTL, FIFO_ENABLE);
+   }
 }
 
 static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai,
-- 
1.5.6

___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


RE: [PATCH] davinci: RMII support for DA850/OMAP-L138 EVM

2009-09-17 Thread Chaithrika U S
Kevin,

On Wed, Sep 16, 2009 at 21:43:46, Kevin Hilman wrote:
 Chaithrika U S chaithr...@ti.com writes:
 
  DA850/OMAP-L138 EVM has a RMII ethernet PHY on the UI
  daughter card. The PHY is enabled by proper programming of the
  IO Expander (TCA6416) ports. Also for RMII PHY to work, the MDIO
  clock of MII PHY has to be disabled since both the PHYs have the
  same address. This is done via the GPIO2[6] pin.
 
  This patch adds support for RMII PHY. It also provides a menuconfig
  option to choose the required PHY interface.
 
  Signed-off-by: Chaithrika U S chaithr...@ti.com
 
 Functionally, looks mostly ok but some organizational comments inline below.
 
 Also, after addressing comments, please refresh against current
 master.  There are some other mux changes now pushed that cause some
 minor conflits with yours.
 
OK, will send an updated patch.

  ---
   arch/arm/mach-davinci/Kconfig  |   12 +++
   arch/arm/mach-davinci/board-da850-evm.c|  104 
  ++--
   arch/arm/mach-davinci/da850.c  |   17 +
   arch/arm/mach-davinci/include/mach/da8xx.h |1 +
   arch/arm/mach-davinci/include/mach/mux.h   |9 +++
   5 files changed, 137 insertions(+), 6 deletions(-)
 
  diff --git a/arch/arm/mach-davinci/Kconfig b/arch/arm/mach-davinci/Kconfig
  index 40866c6..08bdeb3 100644
  --- a/arch/arm/mach-davinci/Kconfig
  +++ b/arch/arm/mach-davinci/Kconfig
  @@ -145,6 +145,18 @@ config DAVINCI_RESET_CLOCKS
probably do not want this option enabled until your
device drivers work properly.
   
  +config DA850_RMII
  +   bool Use RMII Ethernet PHY on DA850/OMAP-L138 EVM
  +   depends on MACH_DAVINCI_DA850_EVM
  +   help
  + Say Y if you want to use the RMII PHY on the DA850/OMAP-L138 EVM.
  + This PHY is found on the UI daughter card that is supplied with
  + the EVM.
  + NOTE: Please take care while choosing this option, MII PHY will
  + not be functional if RMII mode is selected. This also affects
  + the operation of video devices as they are pin multiplexed with
  + RMII pins.
  +
   endmenu
 
 Can you rework the Kconfig options to be similar to the ones done for
 DA830 (See the new DA830_UI Kconfig option)
 
 Basically, in Kconfig, you can select the UI board and select which
 peripherals on the UI board to enable, and these are sub-options of
 the DA830_EVM Kconfig option.
 
 On da830, currently the only sub-option is LCD, but on da850, there
 would be LCD and now this PHY.
 
OK. 

   endif
  diff --git a/arch/arm/mach-davinci/board-da850-evm.c 
  b/arch/arm/mach-davinci/board-da850-evm.c
  index fbc7aae..f7845bb 100644
  --- a/arch/arm/mach-davinci/board-da850-evm.c
  +++ b/arch/arm/mach-davinci/board-da850-evm.c
  @@ -17,6 +17,7 @@
   #include linux/console.h
   #include linux/i2c.h
   #include linux/i2c/at24.h
  +#include linux/i2c/pca953x.h
   #include linux/gpio.h
   #include linux/platform_device.h
   #include linux/mtd/mtd.h
  @@ -32,6 +33,7 @@
   #include mach/cp_intc.h
   #include mach/da8xx.h
   #include mach/nand.h
  +#include mach/mux.h
   
   #define DA850_EVM_PHY_MASK 0x1
   #define DA850_EVM_MDIO_FREQUENCY   220 /* PHY bus frequency */
  @@ -42,6 +44,8 @@
   #define DA850_MMCSD_CD_PIN GPIO_TO_PIN(4, 0)
   #define DA850_MMCSD_WP_PIN GPIO_TO_PIN(4, 1)
   
  +#define DA850_MII_MDIO_CLKEN_PIN   GPIO_TO_PIN(2, 6)
  +
   static struct mtd_partition da850_evm_norflash_partition[] = {
  {
  .name   = NOR filesystem,
  @@ -264,11 +268,103 @@ static void __init da850_evm_init_nor(void)
   #define HAS_MMC 0
   #endif
   
  +static int gpio_exp_setup(struct i2c_client *client, unsigned gpio,
  +   unsigned ngpio, void *c)
  +{
  +   struct davinci_soc_info *soc_info = davinci_soc_info;
  +   int sel_a, sel_b, sel_c;
  +
  +   sel_a = gpio + 7;
  +   sel_b = gpio + 6;
  +   sel_c = gpio + 5;
  +
  +   /* deselect all fucntionalities */
  +   gpio_request(sel_a, sel_a);
  +   gpio_direction_output(sel_a, 1);
  +
  +   gpio_request(sel_b, sel_b);
  +   gpio_direction_output(sel_b, 1);
  +
  +   gpio_request(sel_c, sel_c);
  +   gpio_direction_output(sel_c, 1);
  +
  +   if (soc_info-emac_pdata-rmii_en) {
  +   /* enable RMII */
  +   gpio_direction_output(sel_a, 0);
  +   gpio_direction_output(sel_b, 1);
  +   gpio_direction_output(sel_c, 1);
  +   }
  +
  +   return 0;
  +}
  +
  +static int gpio_exp_teardown(struct i2c_client *client, unsigned gpio,
  +   unsigned ngpio, void *c)
  +{
  +   gpio_free(gpio + 5);
  +   gpio_free(gpio + 6);
  +   gpio_free(gpio + 7);
 
 Do you want/need to disable all functionality here as well?
 
It is not needed but can be done. 

  +   return 0;
  +}
  +
  +static struct pca953x_platform_data gpio_exp = {
  +   .gpio_base  = DAVINCI_N_GPIO,
  +   .setup  = gpio_exp_setup,
  +   .teardown

RE: Booting kernel 2.6.31-rc7

2009-09-16 Thread Chaithrika U S
On Wed, Sep 16, 2009 at 12:32:09, Viral Sachde wrote:
 On Wed, Sep 16, 2009 at 12:22 PM, Nori, Sekhar nsek...@ti.com wrote:
  On Wed, Sep 16, 2009 at 12:11:19, Viral Sachde wrote:
  On Tue, Sep 15, 2009 at 8:24 PM, Nori, Sekhar nsek...@ti.com wrote:
   Hi Viral,
  
   On Tue, Sep 15, 2009 at 19:06:55, Viral Sachde wrote:
   On Tue, Sep 15, 2009 at 5:58 PM,  wenkatesh.tala...@wipro.com wrote:
Hi,
   
 Here you don't need to create the nodes in /dev dir, as they 
are created on the boot-up time.
Make sure that your configuration in kernel for the console is 
correct. And make sure that the file-system your using is not a 
corrupted one.
   
Regards,
Venkatesh
  
   Hi Venkatesh,
  
   I have used defconfig of davinci for kernel configuration.
  
   What is the full build step?
  
   I do something like:
  
   make distclean davinci_all_defconfig uImage ARCH=arm 
   CROSS_COMPILE=path to CodeSourcery 2009q1 toolchain
  
   File system is NFS based and working well with previous versions of 
   kernel.
  
   Within TI we are using filesystem from arago project[1] for testing.
  
   Can you pick up the one of the latest versions and see if you are 
   able to boot-up?
  
   Also, DaVinci git is now based on 2.6.31, you can rebase before retrying.
  
   Thanks,
   Sekhar
  
   [1] http://arago-project.org/files/releases/
  
  
 
 
  Hi Sekhar  all,
 
  Thanks for directions. I am now able to boot 2.6.31 compiled with 
  codesourcery tool chain and arago filesys.
 
  Couple of things:
  1. In codesourcery tool chain mkimage tool is not available.
 
  Hi Viral,
 
  This is a part of U-Boot; it gets built when you build U-Boot.
 
  2. In arago project page, lot of release are available, but none 
  marked as latest-stable.
 
  The ones marked -rcX are release candidates, rest are released versions.
  You can pick up the latest released version.
 
  Thanks,
  Sekhar
 
 
  Regards, Viral
 
 Hi all,
 
 With recent 2.6.31, After configuring AIC audio codec and USB as hub with few 
 more usb drivers selected, such as serial, mass
storage, I re-compiled kernel.
 
 It is not able to detect AIC33 and USB Hub. Any suggestions are well come. 
 With LSP 1.30, it was working fine. I have attached
boot log and kernel config for 2.6.31.
 
 Regards, Viral
 

Audio is currently broken on master branch. Please check the
temp-asoc branch for audio.

Regards,
Chaithrika


___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


[PATCH] davinci: RMII support for DA850/OMAP-L138 EVM

2009-09-16 Thread Chaithrika U S
DA850/OMAP-L138 EVM has a RMII ethernet PHY on the UI
daughter card. The PHY is enabled by proper programming of the
IO Expander (TCA6416) ports. Also for RMII PHY to work, the MDIO
clock of MII PHY has to be disabled since both the PHYs have the
same address. This is done via the GPIO2[6] pin.

This patch adds support for RMII PHY. It also provides a menuconfig
option to choose the required PHY interface.

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
 arch/arm/mach-davinci/Kconfig  |   12 +++
 arch/arm/mach-davinci/board-da850-evm.c|  104 ++--
 arch/arm/mach-davinci/da850.c  |   17 +
 arch/arm/mach-davinci/include/mach/da8xx.h |1 +
 arch/arm/mach-davinci/include/mach/mux.h   |9 +++
 5 files changed, 137 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-davinci/Kconfig b/arch/arm/mach-davinci/Kconfig
index 40866c6..08bdeb3 100644
--- a/arch/arm/mach-davinci/Kconfig
+++ b/arch/arm/mach-davinci/Kconfig
@@ -145,6 +145,18 @@ config DAVINCI_RESET_CLOCKS
  probably do not want this option enabled until your
  device drivers work properly.
 
+config DA850_RMII
+   bool Use RMII Ethernet PHY on DA850/OMAP-L138 EVM
+   depends on MACH_DAVINCI_DA850_EVM
+   help
+ Say Y if you want to use the RMII PHY on the DA850/OMAP-L138 EVM.
+ This PHY is found on the UI daughter card that is supplied with
+ the EVM.
+ NOTE: Please take care while choosing this option, MII PHY will
+ not be functional if RMII mode is selected. This also affects
+ the operation of video devices as they are pin multiplexed with
+ RMII pins.
+
 endmenu
 
 endif
diff --git a/arch/arm/mach-davinci/board-da850-evm.c 
b/arch/arm/mach-davinci/board-da850-evm.c
index fbc7aae..f7845bb 100644
--- a/arch/arm/mach-davinci/board-da850-evm.c
+++ b/arch/arm/mach-davinci/board-da850-evm.c
@@ -17,6 +17,7 @@
 #include linux/console.h
 #include linux/i2c.h
 #include linux/i2c/at24.h
+#include linux/i2c/pca953x.h
 #include linux/gpio.h
 #include linux/platform_device.h
 #include linux/mtd/mtd.h
@@ -32,6 +33,7 @@
 #include mach/cp_intc.h
 #include mach/da8xx.h
 #include mach/nand.h
+#include mach/mux.h
 
 #define DA850_EVM_PHY_MASK 0x1
 #define DA850_EVM_MDIO_FREQUENCY   220 /* PHY bus frequency */
@@ -42,6 +44,8 @@
 #define DA850_MMCSD_CD_PIN GPIO_TO_PIN(4, 0)
 #define DA850_MMCSD_WP_PIN GPIO_TO_PIN(4, 1)
 
+#define DA850_MII_MDIO_CLKEN_PIN   GPIO_TO_PIN(2, 6)
+
 static struct mtd_partition da850_evm_norflash_partition[] = {
{
.name   = NOR filesystem,
@@ -264,11 +268,103 @@ static void __init da850_evm_init_nor(void)
 #define HAS_MMC 0
 #endif
 
+static int gpio_exp_setup(struct i2c_client *client, unsigned gpio,
+   unsigned ngpio, void *c)
+{
+   struct davinci_soc_info *soc_info = davinci_soc_info;
+   int sel_a, sel_b, sel_c;
+
+   sel_a = gpio + 7;
+   sel_b = gpio + 6;
+   sel_c = gpio + 5;
+
+   /* deselect all fucntionalities */
+   gpio_request(sel_a, sel_a);
+   gpio_direction_output(sel_a, 1);
+
+   gpio_request(sel_b, sel_b);
+   gpio_direction_output(sel_b, 1);
+
+   gpio_request(sel_c, sel_c);
+   gpio_direction_output(sel_c, 1);
+
+   if (soc_info-emac_pdata-rmii_en) {
+   /* enable RMII */
+   gpio_direction_output(sel_a, 0);
+   gpio_direction_output(sel_b, 1);
+   gpio_direction_output(sel_c, 1);
+   }
+
+   return 0;
+}
+
+static int gpio_exp_teardown(struct i2c_client *client, unsigned gpio,
+   unsigned ngpio, void *c)
+{
+   gpio_free(gpio + 5);
+   gpio_free(gpio + 6);
+   gpio_free(gpio + 7);
+
+   return 0;
+}
+
+static struct pca953x_platform_data gpio_exp = {
+   .gpio_base  = DAVINCI_N_GPIO,
+   .setup  = gpio_exp_setup,
+   .teardown   = gpio_exp_teardown,
+};
+
+static struct i2c_board_info __initdata i2c_info[] =  {
+   {
+   I2C_BOARD_INFO(tca6416, 0x20),
+   .platform_data = gpio_exp,
+   },
+};
+
+static void __init da850_evm_config_emac(u8 rmii_en)
+{
+   void __iomem *cfg_chip3_base;
+   int ret;
+   u32 val;
+
+   cfg_chip3_base = DA8XX_SYSCFG_VIRT(DA8XX_CFGCHIP3_REG);
+
+   /* configure the CFGCHIP3 register for RMII or MII */
+   val = readl(cfg_chip3_base);
+   if (rmii_en)
+   val |= BIT(8);
+   else
+   val = ~BIT(8);
+
+   writel(val, cfg_chip3_base);
+
+   if (!rmii_en)
+   ret = da8xx_pinmux_setup(da850_cpgmac_pins);
+   else
+   ret = da8xx_pinmux_setup(da850_rmii_pins);
+   if (ret)
+   pr_warning(da850_evm_init: cpgmac/rmii mux setup failed: %d\n,
+   ret);
+
+   if (rmii_en

[PATCH] ASoC: DaVinci: Fixes to McASP configuration

2009-09-15 Thread Chaithrika U S
McASP register settings are not correct for DSP mode of operation.
There is a channel swap initally. This patch provides fixes to
the register values for proper working.

Tested on DA830/OMAP-L137 EVM, DM6467 EVM.

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
Applies to ALSA GIT tree on branch topic/asoc at
http://git.kernel.org/?p=linux/kernel/git/tiwai/sound-2.6.git;a=shortlog;
h=topic/asoc

 sound/soc/davinci/davinci-mcasp.c |   24 ++--
 1 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/sound/soc/davinci/davinci-mcasp.c 
b/sound/soc/davinci/davinci-mcasp.c
index eca22d7..7a06c0a 100644
--- a/sound/soc/davinci/davinci-mcasp.c
+++ b/sound/soc/davinci/davinci-mcasp.c
@@ -512,34 +512,49 @@ static int davinci_config_channel_size(struct 
davinci_audio_dev *dev,
   int channel_size)
 {
u32 fmt = 0;
+   u32 mask, rotate;
 
switch (channel_size) {
case DAVINCI_AUDIO_WORD_8:
fmt = 0x03;
+   rotate = 6;
+   mask = 0x00ff;
break;
 
case DAVINCI_AUDIO_WORD_12:
fmt = 0x05;
+   rotate = 5;
+   mask = 0x0fff;
break;
 
case DAVINCI_AUDIO_WORD_16:
fmt = 0x07;
+   rotate = 4;
+   mask = 0x;
break;
 
case DAVINCI_AUDIO_WORD_20:
fmt = 0x09;
+   rotate = 3;
+   mask = 0x000f;
break;
 
case DAVINCI_AUDIO_WORD_24:
fmt = 0x0B;
+   rotate = 2;
+   mask = 0x00ff;
break;
 
case DAVINCI_AUDIO_WORD_28:
fmt = 0x0D;
+   rotate = 1;
+   mask = 0x0fff;
break;
 
case DAVINCI_AUDIO_WORD_32:
fmt = 0x0F;
+   rotate = 0;
+   mask = 0x;
break;
 
default:
@@ -550,6 +565,13 @@ static int davinci_config_channel_size(struct 
davinci_audio_dev *dev,
RXSSZ(fmt), RXSSZ(0x0F));
mcasp_mod_bits(dev-base + DAVINCI_MCASP_TXFMT_REG,
TXSSZ(fmt), TXSSZ(0x0F));
+   mcasp_mod_bits(dev-base + DAVINCI_MCASP_TXFMT_REG, TXROT(rotate),
+   TXROT(7));
+   mcasp_mod_bits(dev-base + DAVINCI_MCASP_RXFMT_REG, RXROT(rotate),
+   RXROT(7));
+   mcasp_set_reg(dev-base + DAVINCI_MCASP_TXMASK_REG, mask);
+   mcasp_set_reg(dev-base + DAVINCI_MCASP_RXMASK_REG, mask);
+
return 0;
 }
 
@@ -638,7 +660,6 @@ static void davinci_hw_param(struct davinci_audio_dev *dev, 
int stream)
printk(KERN_ERR playback tdm slot %d not supported\n,
dev-tdm_slots);
 
-   mcasp_set_reg(dev-base + DAVINCI_MCASP_TXMASK_REG, 0x);
mcasp_clr_bits(dev-base + DAVINCI_MCASP_TXFMCTL_REG, FSXDUR);
} else {
/* bit stream is MSB first with no delay */
@@ -655,7 +676,6 @@ static void davinci_hw_param(struct davinci_audio_dev *dev, 
int stream)
printk(KERN_ERR capture tdm slot %d not supported\n,
dev-tdm_slots);
 
-   mcasp_set_reg(dev-base + DAVINCI_MCASP_RXMASK_REG, 0x);
mcasp_clr_bits(dev-base + DAVINCI_MCASP_RXFMCTL_REG, FSRDUR);
}
 }
-- 
1.5.6

___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


RE: [PATCH] ARM: DaVinci: Add or modify AIC3x I2C board info

2009-08-27 Thread Chaithrika U S
On Fri, Aug 28, 2009 at 08:22:52, J.C. Wren wrote:
 This patch seems to break audio on a Davinci 6446 EVM.
 
 -rc7---
 

Hi,

Which branch of the DaVinci GIT are you checking it on?
This patch works for temp/asoc branch. It will not work for the
master branch as some changes from the ASoC tree are not yet 
available on master.

Regards,
Chaithrika
 
 Advanced Linux Sound Architecture Driver Version 1.0.20.
 No device for DAI tlv320aic3x
 No device for DAI davinci-i2s
 AIC3X Audio Codec 0.2
 i2c-adapter i2c-1: Failed to register i2c client tlv320aic3x at 0x1b
 (-16)
 soc-audio soc-audio.0: can't add i2c device at 0x1b ALSA device list:
   No soundcards found.
 TCP cubic registered
 
 It was working under -rc5 ---
 
 Advanced Linux Sound Architecture Driver Version 1.0.20.
 No device for DAI tlv320aic3x
 No device for DAI davinci-i2s
 AIC3X Audio Codec 0.2
 asoc: tlv320aic3x - davinci-i2s mapping ok ALSA device list:
   #0: DaVinci EVM (tlv320aic3x)
 TCP cubic registered
 
 --jc
 
 On Wed, Aug 26, 2009 at 12:08 PM, Chaithrika U S chaithr...@ti.com
 wrote:
 
 
   This patch includes the codec I2C board info for DM6446 EVM
   and DM355 EVM. Also, it corrects the codec names in DA8xx/OMAP-L1xx
   board files.
   
   Tested on DM6446, DM355, DM6447, DA850 EVMs.
   
   Signed-off-by: Chaithrika U S chaithr...@ti.com
   ---
   Applies to temp/asoc branch of DaVinci GIT tree.
   
arch/arm/mach-davinci/board-da830-evm.c  |2 +-
arch/arm/mach-davinci/board-da850-evm.c  |2 +-
arch/arm/mach-davinci/board-dm355-evm.c  |2 +-
arch/arm/mach-davinci/board-dm644x-evm.c |4 +++-
4 files changed, 6 insertions(+), 4 deletions(-)
   
   diff --git a/arch/arm/mach-davinci/board-da830-evm.c
 b/arch/arm/mach-davinci/board-da830-evm.c
   index 489b317..bfbb639 100644
   --- a/arch/arm/mach-davinci/board-da830-evm.c
   +++ b/arch/arm/mach-davinci/board-da830-evm.c
   @@ -42,7 +42,7 @@ static struct i2c_board_info __initdata 
 da830_evm_i2c_devices[] = {
  .platform_data  = da830_evm_i2c_eeprom_info,
  },
  {
   -   I2C_BOARD_INFO(tlv320aic33, 0x18),
   +   I2C_BOARD_INFO(tlv320aic3x, 0x18),
  }
};
   
   diff --git a/arch/arm/mach-davinci/board-da850-evm.c
 b/arch/arm/mach-davinci/board-da850-evm.c
   index 6adc0df..c759d72 100644
   --- a/arch/arm/mach-davinci/board-da850-evm.c
   +++ b/arch/arm/mach-davinci/board-da850-evm.c
   @@ -145,7 +145,7 @@ static struct platform_device 
 da850_evm_nandflash_device = {
   
static struct i2c_board_info __initdata da850_evm_i2c_devices[] = {
  {
   -   I2C_BOARD_INFO(tlv320aic33, 0x18),
   +   I2C_BOARD_INFO(tlv320aic3x, 0x18),
  }
};
   
   diff --git a/arch/arm/mach-davinci/board-dm355-evm.c
 b/arch/arm/mach-davinci/board-dm355-evm.c
   index 38157f7..9f25fd8 100644
   --- a/arch/arm/mach-davinci/board-dm355-evm.c
   +++ b/arch/arm/mach-davinci/board-dm355-evm.c
   @@ -139,7 +139,7 @@ static struct i2c_board_info dm355evm_i2c_info[] = {
  { I2C_BOARD_INFO(dm355evm_msp, 0x25),
  .platform_data = dm355evm_mmcsd_gpios,
  /* plus irq */ },
   -   /* { I2C_BOARD_INFO(tlv320aic3x, 0x1b), }, */
   +   { I2C_BOARD_INFO(tlv320aic33, 0x1b), },
  /* { I2C_BOARD_INFO(tvp5146, 0x5d), }, */
};
   
   diff --git a/arch/arm/mach-davinci/board-dm644x-evm.c
 b/arch/arm/mach-davinci/board-dm644x-evm.c
   index 6a27c5d..31cf84f 100644
   --- a/arch/arm/mach-davinci/board-dm644x-evm.c
   +++ b/arch/arm/mach-davinci/board-dm644x-evm.c
   @@ -559,8 +559,10 @@ static struct i2c_board_info __initdata i2c_info[] 
 =  {
  I2C_BOARD_INFO(24c256, 0x50),
  .platform_data  = eeprom_info,
  },
   +   {
   +   I2C_BOARD_INFO(tlv320aic33, 0x1b),
   +   },
  /* ALSO:
   -* - tvl320aic33 audio codec (0x1b)
   * - tvp5146 video decoder (0x5d)
   */
};
   --
   1.5.6
   
   ___
   Davinci-linux-open-source mailing list
   Davinci-linux-open-source@linux.davincidsp.com
   
 http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source
   
 
 
 


___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


RE: DaVinci ASoC build failures

2009-08-26 Thread Chaithrika U S
On Wed, Aug 26, 2009 at 06:02:15, Narnakaje, Snehaprabha wrote:
 Kevin,
 
  -Original Message-
  From: davinci-linux-open-source-
  bounces+nsnehaprabha=ti@linux.davincidsp.com [mailto:davinci-linux-
  open-source-bounces+nsnehaprabha=ti@linux.davincidsp.com] On Behalf Of
  Kevin Hilman
  Sent: Tuesday, August 25, 2009 8:26 AM
  To: Mark Brown
  Cc: b...@simtec.co.uk; davinci-linux-open-source@linux.davincidsp.com
  Subject: Re: DaVinci ASoC build failures
  
  Mark Brown broo...@opensource.wolfsonmicro.com writes:
  
   On Tue, Aug 25, 2009 at 02:18:58PM +0300, Kevin Hilman wrote:
  
   So, I went to remedy this, and now I'm getting several other build
   failures[2] when combining davinci git and Mark's for-2.6.32 branch.
   Are there some outstanding patches that are missing here?
  
   No, it's that Ben's update to the board files to register the
  tlv320aic3x
   I2C device didn't update all the various DaVinci EVMs correctly.  The
   relevant commit is aa6b904e66d5f484bd52763d63259b9a16f6e107 - it needs a
   followon to handle the other EVMs.  Ultimately the CODEC should just be
   registered under arch/arm so just doing that at once would be good
   providing it doesn't create any merge issues.
  
   Will you take a look at this, Kevin?  If not I'll try but it'd be nice
   to check on real hardware as well if possible.
  
  OK, I pushed a new temp/asoc branch which is my master branch with
  your for-2.6.32 branch, followed by two patches for review/test.
  
  The first adds the i2c init to the davinci board files, the 2nd drops
  it from sound/soc/davinci/davinci-evm.c.  I did it in two patches so I
  can merge the arch/arm/* one and you can merge the sound/* one since
  otherwise, we'll get conflicts to to lots of other board file changes
  in my tree.
  
  Unfortunately, I'm currently on the road and while I have remote
  access to my davinci hw, it doesn't help for testing audio.  ;)
  
  Someone from TI will have to test these and verify that the i2c
  addresses are still right and sound still plays fine.
 
 Arun had tried to test temp/asoc branch, but the codec was not getting 
 detected (similar to the old clock name problem, or could
be new I2C related).
 
 netconsole: network logging started
 i2c /dev entries driver
 Advanced Linux Sound Architecture Driver Version 1.0.20.
 No device for DAI davinci-i2s
 ALSA device list:
   No soundcards found.
 
 We will debug this further and let you know.

For DM6446 and DM355 EVMs, i2c board info has to be added for codec.
Along with this change, defining aic3x setup data structure in the
sound/soc/davinci/davinci-evm.c file is needed, else probe fails.

I will post patches which apply to temp/asoc branch for these changes.

Regards, 
Chaithrika

 
 Thanks
 Sneha
 
  
  I have only tested that it builds.
  
   For others to test, I pushed a new 'temp/asoc' branch to DaVinci git
   which is my master branch merged with Mark's for-2.6.31 and for-2.6.32
   branches (which have been updated since I last merged them.)
  
   There should be no need to merge for-2.6.31 explicitly, I always keep
   the fixes branch merged into the current development version.
  
  ok, good to know.
  
  Kevin
  
  ___
  Davinci-linux-open-source mailing list
  Davinci-linux-open-source@linux.davincidsp.com
  http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source
 ___
 Davinci-linux-open-source mailing list
 Davinci-linux-open-source@linux.davincidsp.com
 http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source
 



___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


[PATCH] ARM: DaVinci: ASoC: Define AIC3x setup info

2009-08-26 Thread Chaithrika U S
The codec setup data structure has to be defined for
successful probe.

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
Applies to temp/asoc branch of DaVinci GIT tree.

 sound/soc/davinci/davinci-evm.c |6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/sound/soc/davinci/davinci-evm.c b/sound/soc/davinci/davinci-evm.c
index 81628ac..67414f6 100644
--- a/sound/soc/davinci/davinci-evm.c
+++ b/sound/soc/davinci/davinci-evm.c
@@ -206,27 +206,33 @@ static struct snd_soc_card da850_snd_soc_card = {
.num_links = 1,
 };
 
+static struct aic3x_setup_data aic3x_setup;
+
 /* evm audio subsystem */
 static struct snd_soc_device evm_snd_devdata = {
.card = snd_soc_card_evm,
.codec_dev = soc_codec_dev_aic3x,
+   .codec_data = aic3x_setup,
 };
 
 /* evm audio subsystem */
 static struct snd_soc_device dm6467_evm_snd_devdata = {
.card = dm6467_snd_soc_card_evm,
.codec_dev = soc_codec_dev_aic3x,
+   .codec_data = aic3x_setup,
 };
 
 /* evm audio subsystem */
 static struct snd_soc_device da830_evm_snd_devdata = {
.card = da830_snd_soc_card,
.codec_dev = soc_codec_dev_aic3x,
+   .codec_data = aic3x_setup,
 };
 
 static struct snd_soc_device da850_evm_snd_devdata = {
.card   = da850_snd_soc_card,
.codec_dev  = soc_codec_dev_aic3x,
+   .codec_data = aic3x_setup,
 };
 
 static struct platform_device *evm_snd_device;
-- 
1.5.6

___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


[PATCH] ARM: DaVinci: Add or modify AIC3x I2C board info

2009-08-26 Thread Chaithrika U S
This patch includes the codec I2C board info for DM6446 EVM
and DM355 EVM. Also, it corrects the codec names in DA8xx/OMAP-L1xx
board files.

Tested on DM6446, DM355, DM6447, DA850 EVMs.

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
Applies to temp/asoc branch of DaVinci GIT tree.

 arch/arm/mach-davinci/board-da830-evm.c  |2 +-
 arch/arm/mach-davinci/board-da850-evm.c  |2 +-
 arch/arm/mach-davinci/board-dm355-evm.c  |2 +-
 arch/arm/mach-davinci/board-dm644x-evm.c |4 +++-
 4 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-davinci/board-da830-evm.c 
b/arch/arm/mach-davinci/board-da830-evm.c
index 489b317..bfbb639 100644
--- a/arch/arm/mach-davinci/board-da830-evm.c
+++ b/arch/arm/mach-davinci/board-da830-evm.c
@@ -42,7 +42,7 @@ static struct i2c_board_info __initdata 
da830_evm_i2c_devices[] = {
.platform_data  = da830_evm_i2c_eeprom_info,
},
{
-   I2C_BOARD_INFO(tlv320aic33, 0x18),
+   I2C_BOARD_INFO(tlv320aic3x, 0x18),
}
 };
 
diff --git a/arch/arm/mach-davinci/board-da850-evm.c 
b/arch/arm/mach-davinci/board-da850-evm.c
index 6adc0df..c759d72 100644
--- a/arch/arm/mach-davinci/board-da850-evm.c
+++ b/arch/arm/mach-davinci/board-da850-evm.c
@@ -145,7 +145,7 @@ static struct platform_device da850_evm_nandflash_device = {
 
 static struct i2c_board_info __initdata da850_evm_i2c_devices[] = {
{
-   I2C_BOARD_INFO(tlv320aic33, 0x18),
+   I2C_BOARD_INFO(tlv320aic3x, 0x18),
}
 };
 
diff --git a/arch/arm/mach-davinci/board-dm355-evm.c 
b/arch/arm/mach-davinci/board-dm355-evm.c
index 38157f7..9f25fd8 100644
--- a/arch/arm/mach-davinci/board-dm355-evm.c
+++ b/arch/arm/mach-davinci/board-dm355-evm.c
@@ -139,7 +139,7 @@ static struct i2c_board_info dm355evm_i2c_info[] = {
{ I2C_BOARD_INFO(dm355evm_msp, 0x25),
.platform_data = dm355evm_mmcsd_gpios,
/* plus irq */ },
-   /* { I2C_BOARD_INFO(tlv320aic3x, 0x1b), }, */
+   { I2C_BOARD_INFO(tlv320aic33, 0x1b), },
/* { I2C_BOARD_INFO(tvp5146, 0x5d), }, */
 };
 
diff --git a/arch/arm/mach-davinci/board-dm644x-evm.c 
b/arch/arm/mach-davinci/board-dm644x-evm.c
index 6a27c5d..31cf84f 100644
--- a/arch/arm/mach-davinci/board-dm644x-evm.c
+++ b/arch/arm/mach-davinci/board-dm644x-evm.c
@@ -559,8 +559,10 @@ static struct i2c_board_info __initdata i2c_info[] =  {
I2C_BOARD_INFO(24c256, 0x50),
.platform_data  = eeprom_info,
},
+   {
+   I2C_BOARD_INFO(tlv320aic33, 0x1b),
+   },
/* ALSO:
-* - tvl320aic33 audio codec (0x1b)
 * - tvp5146 video decoder (0x5d)
 */
 };
-- 
1.5.6

___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


RE: [PATCH] ARM: DaVinci: ASoC: Define AIC3x setup info

2009-08-26 Thread Chaithrika U S
On Wed, Aug 26, 2009 at 14:58:02, Mark Brown wrote:
 On Wed, Aug 26, 2009 at 12:08:10PM -0400, Chaithrika U S wrote:
  The codec setup data structure has to be defined for
  successful probe.
 
 This would be better fixed in the CODEC driver - if there's nothing in
 the setup data it should cope.  Please try the patch below, it should
 eliminate the need for the setup data but I've not even compile tested
 it:
 

Mark,

Agree. I did a quick try of this patch on DA850/OMAP-L138 EVM and
it is working fine. Thank you for the patch.

Regards, 
Chaithrika

 diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
 index 5d54767..3395cf9 100644
 --- a/sound/soc/codecs/tlv320aic3x.c
 +++ b/sound/soc/codecs/tlv320aic3x.c
 @@ -1385,15 +1385,14 @@ static int aic3x_probe(struct platform_device *pdev)
   socdev-card-codec = codec;
   setup = socdev-codec_data;
  
 - if (!setup) {
 - dev_err(pdev-dev, No setup data supplied\n);
 - return -EINVAL;
 + if (setup) {
 + /* setup GPIO functions */
 + aic3x_write(codec, AIC3X_GPIO1_REG,
 + (setup-gpio_func[0]  0xf)  4);
 + aic3x_write(codec, AIC3X_GPIO2_REG,
 + (setup-gpio_func[1]  0xf)  4);
   }
  
 - /* setup GPIO functions */
 - aic3x_write(codec, AIC3X_GPIO1_REG, (setup-gpio_func[0]  0xf)  4);
 - aic3x_write(codec, AIC3X_GPIO2_REG, (setup-gpio_func[1]  0xf)  4);
 -
   /* register pcms */
   ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
   if (ret  0) {
 


___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


RE: ALSA on Linux Kernel v2.6.31-rc5-davinci1

2009-08-14 Thread Chaithrika U S
On Fri, Aug 14, 2009 at 15:19:56, Viral Sachde wrote:
 Hi all,
 
 I was trying to play audio on Linux Kernel v2.6.31-rc5-davinci1.
 I have enabled ALSA related following configurations:
 *   Sequencer support
 *   OSS Mixer API
 *   OSS PCM (digital audio) API
 [*] OSS PCM (digital audio) API - Include plugin system
 [*]   Support old ALSA API
 [*]   Verbose procfs contents
 [*]   Verbose printk
 [*]   Generic sound devices
 [*]   ARM sound devices ---
 *   ALSA for SoC audio support
 *   SoC Audio for the TI DAVINCI chip
 *   SoC Audio support for DaVinci DM6446 or DM355 EVM
 
 In dmesg, I can see one alsa device.
 
 I was able to play back using my old oss based application, but when I
 tried to play using aplay utility, output was not available.
 I also tried to use amixer but it failed as below:
 
 r...@192.168.1.247:~# amixer cset numid=1 127,127
 ALSA sound/core/control.c:1227: ALSA sound/core/control.c:1227:
 unknown ioctl = 0xc2c85513
 
 unknown ioctl = 0xc2c85513
 amixer: Control default element write error: Inappropriate ioctl for
device
 
 Any suggestions ?


Viral,

I checked with the above configuration options you have set, I do not
observe
the issues you have mentioned. Tested it on DM6446 and DM355 EVM.
Both ALSA and OSS emulation are working fine.
I am using Sourcery G++ Lite 2009q1-203 tool chain and Arago file system 
Arago 2009.03-rc4.

Regards, 
Chaithrika

 Regards, Viral
 
 ___
 Davinci-linux-open-source mailing list
 Davinci-linux-open-source@linux.davincidsp.com
 http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source
 


___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


[PATCH v2 1/2] ASoC: DaVinci: McASP driver enhacements

2009-08-11 Thread Chaithrika U S
On DA830/OMAP-L137 and DA850/OMAP-L138 SoCs, the McASP peripheral has FIFO
support. This FIFO provides additional data buffering. It also provides
tolerance to variation in host/DMA controller response times.
The read and write FIFO sizes are 256 bytes each. If FIFO is enabled,
the DMA events from McASP are sent to the FIFO which in turn sends DMA requests
to the host CPU according to the thresholds programmed.
More details of the FIFO operation can be found at
http://focus.ti.com/general/docs/lit/getliterature.tsp?literatureNumber=
sprufm1fileType=pdf

This patch adds support for FIFO configuration. The platform data has a
version field which differentiates the McASP on different SoCs.

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
In this version of the patch, the davinci-i2s driver changes have been done
to account acnt member introduced in the dma_params structure. Also, the DAI
format addition has been removed from this patch.

Applies to ALSA GIT tree on branch topic/asoc at
http://git.kernel.org/?p=linux/kernel/git/tiwai/sound-2.6.git;a=shortlog;
h=topic/asoc

 sound/soc/davinci/davinci-i2s.c   |1 +
 sound/soc/davinci/davinci-mcasp.c |  105 ++---
 sound/soc/davinci/davinci-mcasp.h |5 ++
 sound/soc/davinci/davinci-pcm.c   |4 +-
 sound/soc/davinci/davinci-pcm.h   |1 +
 5 files changed, 107 insertions(+), 9 deletions(-)

diff --git a/sound/soc/davinci/davinci-i2s.c b/sound/soc/davinci/davinci-i2s.c
index 2a56fb7..12a6c54 100644
--- a/sound/soc/davinci/davinci-i2s.c
+++ b/sound/soc/davinci/davinci-i2s.c
@@ -406,6 +406,7 @@ static int davinci_i2s_hw_params(struct snd_pcm_substream 
*substream,
return -EINVAL;
}
 
+   dma_params-acnt  = dma_params-data_type;
rcr |= DAVINCI_MCBSP_RCR_RFRLEN1(1);
xcr |= DAVINCI_MCBSP_XCR_XFRLEN1(1);
 
diff --git a/sound/soc/davinci/davinci-mcasp.c 
b/sound/soc/davinci/davinci-mcasp.c
index f0c0347..e672f43 100644
--- a/sound/soc/davinci/davinci-mcasp.c
+++ b/sound/soc/davinci/davinci-mcasp.c
@@ -102,6 +102,11 @@
 /* Receive Buffer for Serializer n */
 #define DAVINCI_MCASP_RXBUF_REG0x280
 
+/* McASP FIFO Registers */
+#define DAVINCI_MCASP_WFIFOCTL (0x1010)
+#define DAVINCI_MCASP_WFIFOSTS (0x1014)
+#define DAVINCI_MCASP_RFIFOCTL (0x1018)
+#define DAVINCI_MCASP_RFIFOSTS (0x101C)
 
 /*
  * DAVINCI_MCASP_PWREMUMGT_REG - Power Down and Emulation Management
@@ -276,6 +281,13 @@
  */
 #define TXDATADMADIS   BIT(0)
 
+/*
+ * DAVINCI_MCASP_W[R]FIFOCTL - Write/Read FIFO Control Register bits
+ */
+#define FIFO_ENABLEBIT(16)
+#define NUMEVT_MASK(0xFF  8)
+#define NUMDMA_MASK(0xFF)
+
 #define DAVINCI_MCASP_NUM_SERIALIZER   16
 
 static inline void mcasp_set_bits(void __iomem *reg, u32 val)
@@ -345,6 +357,9 @@ static void mcasp_start_rx(struct davinci_audio_dev *dev)
 
 static void mcasp_start_tx(struct davinci_audio_dev *dev)
 {
+   u8 offset = 0, i;
+   u32 cnt;
+
mcasp_set_ctl_reg(dev-base + DAVINCI_MCASP_GBLCTLX_REG, TXHCLKRST);
mcasp_set_ctl_reg(dev-base + DAVINCI_MCASP_GBLCTLX_REG, TXCLKRST);
mcasp_set_ctl_reg(dev-base + DAVINCI_MCASP_GBLCTLX_REG, TXSERCLR);
@@ -353,6 +368,19 @@ static void mcasp_start_tx(struct davinci_audio_dev *dev)
mcasp_set_ctl_reg(dev-base + DAVINCI_MCASP_GBLCTLX_REG, TXSMRST);
mcasp_set_ctl_reg(dev-base + DAVINCI_MCASP_GBLCTLX_REG, TXFSRST);
mcasp_set_reg(dev-base + DAVINCI_MCASP_TXBUF_REG, 0);
+   for (i = 0; i  dev-num_serializer; i++) {
+   if (dev-serial_dir[i] == TX_MODE) {
+   offset = i;
+   break;
+   }
+   }
+
+   /* wait for TX ready */
+   cnt = 0;
+   while (!(mcasp_get_reg(dev-base + DAVINCI_MCASP_XRSRCTL_REG(offset)) 
+TXSTATE)  (cnt  10))
+   cnt++;
+
mcasp_set_reg(dev-base + DAVINCI_MCASP_TXBUF_REG, 0);
 }
 
@@ -362,6 +390,13 @@ static void davinci_mcasp_start(struct davinci_audio_dev 
*dev, int stream)
mcasp_start_tx(dev);
else
mcasp_start_rx(dev);
+
+   /* enable FIFO */
+   if (dev-txnumevt)
+   mcasp_set_bits(dev-base + DAVINCI_MCASP_WFIFOCTL, FIFO_ENABLE);
+
+   if (dev-rxnumevt)
+   mcasp_set_bits(dev-base + DAVINCI_MCASP_RFIFOCTL, FIFO_ENABLE);
 }
 
 static void mcasp_stop_rx(struct davinci_audio_dev *dev)
@@ -382,6 +417,13 @@ static void davinci_mcasp_stop(struct davinci_audio_dev 
*dev, int stream)
mcasp_stop_tx(dev);
else
mcasp_stop_rx(dev);
+
+   /* disable FIFO */
+   if (dev-txnumevt)
+   mcasp_clr_bits(dev-base + DAVINCI_MCASP_WFIFOCTL, FIFO_ENABLE);
+
+   if (dev-rxnumevt)
+   mcasp_clr_bits(dev-base + DAVINCI_MCASP_RFIFOCTL, FIFO_ENABLE);
 }
 
 static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai,
@@ -401,7 +443,6 @@ static int

[PATCH v2 2/2] ASoC: DaVinci: Add a DAI format to McASP driver

2009-08-11 Thread Chaithrika U S
The patch adds a DAI format: Codec bit clock master and frame sync slave,
to the driver.

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
This patch has been separated out from the first patch of this series.
In the previous version, this was part of the McASP driver FIFO support patch.

Applies to ALSA GIT tree on branch topic/asoc at
http://git.kernel.org/?p=linux/kernel/git/tiwai/sound-2.6.git;a=shortlog;
h=topic/asoc

 sound/soc/davinci/davinci-mcasp.c |   10 ++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/sound/soc/davinci/davinci-mcasp.c 
b/sound/soc/davinci/davinci-mcasp.c
index e672f43..eca22d7 100644
--- a/sound/soc/davinci/davinci-mcasp.c
+++ b/sound/soc/davinci/davinci-mcasp.c
@@ -443,6 +443,16 @@ static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai 
*cpu_dai,
 
mcasp_set_bits(base + DAVINCI_MCASP_PDIR_REG, (0x7  26));
break;
+   case SND_SOC_DAIFMT_CBM_CFS:
+   /* codec is clock master and frame slave */
+   mcasp_set_bits(base + DAVINCI_MCASP_ACLKXCTL_REG, ACLKXE);
+   mcasp_set_bits(base + DAVINCI_MCASP_TXFMCTL_REG, AFSXE);
+
+   mcasp_set_bits(base + DAVINCI_MCASP_ACLKRCTL_REG, ACLKRE);
+   mcasp_set_bits(base + DAVINCI_MCASP_RXFMCTL_REG, AFSRE);
+
+   mcasp_set_bits(base + DAVINCI_MCASP_PDIR_REG, (0x2d  26));
+   break;
case SND_SOC_DAIFMT_CBM_CFM:
/* codec is clock and frame master */
mcasp_clr_bits(base + DAVINCI_MCASP_ACLKXCTL_REG, ACLKXE);
-- 
1.5.6

___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


[PATCH v2] ARM: DaVinci: Audio support for DA830 EVM

2009-08-11 Thread Chaithrika U S
Define resources for McASP1 used on DA830/OMAP-L137 EVM, add platform
device defintion, initialization function.
Additionally, this patch also adds version and FIFO related
members to platform data structure.

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
Applies to DaVinci GIT tree.
In this version of the patch, the init fucntion, resource and platform device
definitions have neen moved to the devices-da8xx.c file.

 arch/arm/mach-davinci/board-da830-evm.c|   27 +
 arch/arm/mach-davinci/da830.c  |7 +++--
 arch/arm/mach-davinci/devices-da8xx.c  |   36 
 arch/arm/mach-davinci/include/mach/asp.h   |   15 +++
 arch/arm/mach-davinci/include/mach/da8xx.h |3 ++
 5 files changed, 85 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-davinci/board-da830-evm.c 
b/arch/arm/mach-davinci/board-da830-evm.c
index 9025669..a45340d 100644
--- a/arch/arm/mach-davinci/board-da830-evm.c
+++ b/arch/arm/mach-davinci/board-da830-evm.c
@@ -23,6 +23,7 @@
 #include mach/irqs.h
 #include mach/cp_intc.h
 #include mach/da8xx.h
+#include mach/asp.h
 
 #define DA830_EVM_PHY_MASK 0x0
 #define DA830_EVM_MDIO_FREQUENCY   220 /* PHY bus frequency */
@@ -51,6 +52,25 @@ static struct davinci_uart_config da830_evm_uart_config 
__initdata = {
.enabled_uarts = 0x7,
 };
 
+static u8 da830_iis_serializer_direction[] = {
+   RX_MODE,INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,
+   INACTIVE_MODE,  TX_MODE,INACTIVE_MODE,  INACTIVE_MODE,
+   INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,
+};
+
+static struct snd_platform_data da830_evm_snd_data = {
+   .tx_dma_offset  = 0x2000,
+   .rx_dma_offset  = 0x2000,
+   .op_mode= DAVINCI_MCASP_IIS_MODE,
+   .num_serializer = ARRAY_SIZE(da830_iis_serializer_direction),
+   .tdm_slots  = 2,
+   .serial_dir = da830_iis_serializer_direction,
+   .eventq_no  = EVENTQ_0,
+   .version= MCASP_VERSION_2,
+   .txnumevt   = 1,
+   .rxnumevt   = 1,
+};
+
 static __init void da830_evm_init(void)
 {
struct davinci_soc_info *soc_info = davinci_soc_info;
@@ -93,6 +113,13 @@ static __init void da830_evm_init(void)
davinci_serial_init(da830_evm_uart_config);
i2c_register_board_info(1, da830_evm_i2c_devices,
ARRAY_SIZE(da830_evm_i2c_devices));
+
+   ret = da8xx_pinmux_setup(da830_mcasp1_pins);
+   if (ret)
+   pr_warning(da830_evm_init: mcasp1 mux setup failed: %d\n,
+   ret);
+
+   da8xx_init_mcasp(1, da830_evm_snd_data);
 }
 
 #ifdef CONFIG_SERIAL_8250_CONSOLE
diff --git a/arch/arm/mach-davinci/da830.c b/arch/arm/mach-davinci/da830.c
index 3a9b634..19b2748 100644
--- a/arch/arm/mach-davinci/da830.c
+++ b/arch/arm/mach-davinci/da830.c
@@ -23,6 +23,7 @@
 #include mach/common.h
 #include mach/time.h
 #include mach/da8xx.h
+#include mach/asp.h
 
 #include clock.h
 #include mux.h
@@ -411,9 +412,9 @@ static struct davinci_clk da830_clks[] = {
CLK(eqep.0,   NULL,   eqep0_clk),
CLK(eqep.1,   NULL,   eqep1_clk),
CLK(da830_lcdc,   NULL,   lcdc_clk),
-   CLK(soc-audio.0,  NULL,   mcasp0_clk),
-   CLK(soc-audio.1,  NULL,   mcasp1_clk),
-   CLK(soc-audio.2,  NULL,   mcasp2_clk),
+   CLK(davinci-mcasp.0,  NULL,   mcasp0_clk),
+   CLK(davinci-mcasp.1,  NULL,   mcasp1_clk),
+   CLK(davinci-mcasp.2,  NULL,   mcasp2_clk),
CLK(musb_hdrc,NULL,   usb20_clk),
CLK(NULL,   aemif,aemif_clk),
CLK(NULL,   aintc,aintc_clk),
diff --git a/arch/arm/mach-davinci/devices-da8xx.c 
b/arch/arm/mach-davinci/devices-da8xx.c
index 11c0971..fe0baaf 100644
--- a/arch/arm/mach-davinci/devices-da8xx.c
+++ b/arch/arm/mach-davinci/devices-da8xx.c
@@ -281,7 +281,43 @@ static struct platform_device da8xx_emac_device = {
.resource   = da8xx_emac_resources,
 };
 
+static struct resource da830_mcasp1_resources[] = {
+   {
+   .name   = mcasp1,
+   .start  = DAVINCI_DA830_MCASP1_REG_BASE,
+   .end= DAVINCI_DA830_MCASP1_REG_BASE + (SZ_1K * 12) - 1,
+   .flags  = IORESOURCE_MEM,
+   },
+   /* TX event */
+   {
+   .start  = DAVINCI_DA830_DMA_MCASP1_AXEVT,
+   .end= DAVINCI_DA830_DMA_MCASP1_AXEVT,
+   .flags  = IORESOURCE_DMA,
+   },
+   /* RX event */
+   {
+   .start  = DAVINCI_DA830_DMA_MCASP1_AREVT,
+   .end= DAVINCI_DA830_DMA_MCASP1_AREVT,
+   .flags  = IORESOURCE_DMA,
+   },
+};
+
+static struct platform_device da830_mcasp1_device = {
+   .name   = davinci-mcasp,
+   .id = 1,
+   .num_resources

(no subject)

2009-08-11 Thread Chaithrika U S
Define resources for McASP used on DA850/OMAP-L138 EVM, add platform
device defintion and Pin Mux configurations.

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
Applies on DaVinci GIT tree.
This patch is dependent on the following patch which I have
submitted earlier:
[PATCH v2] ARM: DaVinci: Audio support for DA830 EVM

 arch/arm/mach-davinci/board-da850-evm.c  |   29 ++
 arch/arm/mach-davinci/da850.c|   39 ++
 arch/arm/mach-davinci/devices-da8xx.c|   34 +-
 arch/arm/mach-davinci/include/mach/asp.h |7 +
 arch/arm/mach-davinci/include/mach/mux.h |   25 +++
 5 files changed, 133 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-davinci/board-da850-evm.c 
b/arch/arm/mach-davinci/board-da850-evm.c
index d989346..52bfe4c 100644
--- a/arch/arm/mach-davinci/board-da850-evm.c
+++ b/arch/arm/mach-davinci/board-da850-evm.c
@@ -38,6 +38,28 @@ static struct davinci_uart_config da850_evm_uart_config 
__initdata = {
.enabled_uarts = 0x7,
 };
 
+/* davinci da850 evm audio machine driver */
+static u8 da850_iis_serializer_direction[] = {
+   INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,
+   INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,
+   INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,  TX_MODE,
+   RX_MODE,INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,
+};
+
+static struct snd_platform_data da850_evm_snd_data = {
+   .tx_dma_offset  = 0x2000,
+   .rx_dma_offset  = 0x2000,
+   .op_mode= DAVINCI_MCASP_IIS_MODE,
+   .num_serializer = ARRAY_SIZE(da850_iis_serializer_direction),
+   .tdm_slots  = 2,
+   .serial_dir = da850_iis_serializer_direction,
+   .eventq_no  = EVENTQ_1,
+   .version= MCASP_VERSION_2,
+   .txnumevt   = 1,
+   .rxnumevt   = 1,
+};
+
+
 static __init void da850_evm_init(void)
 {
struct davinci_soc_info *soc_info = davinci_soc_info;
@@ -86,6 +108,13 @@ static __init void da850_evm_init(void)
 */
__raw_writel(0, IO_ADDRESS(DA8XX_UART1_BASE) + 0x30);
__raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE) + 0x30);
+
+   ret = da8xx_pinmux_setup(da850_mcasp_pins);
+   if (ret)
+   pr_warning(da850_evm_init: mcasp mux setup failed: %d\n,
+   ret);
+
+   da8xx_init_mcasp(0, da850_evm_snd_data);
 }
 
 #ifdef CONFIG_SERIAL_8250_CONSOLE
diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c
index 4a43ae2..e33b226 100644
--- a/arch/arm/mach-davinci/da850.c
+++ b/arch/arm/mach-davinci/da850.c
@@ -289,6 +289,13 @@ static struct clk emac_clk = {
.lpsc   = DA8XX_LPSC1_CPGMAC,
 };
 
+static struct clk mcasp_clk = {
+   .name   = mcasp,
+   .parent = pll0_sysclk2,
+   .lpsc   = DA8XX_LPSC1_McASP0,
+   .psc_ctlr   = 1,
+};
+
 static struct davinci_clk da850_clks[] = {
CLK(NULL,   ref,  ref_clk),
CLK(NULL,   pll0, pll0_clk),
@@ -326,6 +333,7 @@ static struct davinci_clk da850_clks[] = {
CLK(NULL,   arm,  arm_clk),
CLK(NULL,   rmii, rmii_clk),
CLK(davinci_emac.1,   NULL,   emac_clk),
+   CLK(davinci-mcasp.0,  NULL,   mcasp_clk),
CLK(NULL,   NULL,   NULL),
 };
 
@@ -370,6 +378,30 @@ static const struct mux_config da850_pins[] = {
MUX_CFG(DA850, MII_RXD_2,   3,  20, 15, 8,  false)
MUX_CFG(DA850, MII_RXD_1,   3,  24, 15, 8,  false)
MUX_CFG(DA850, MII_RXD_0,   3,  28, 15, 8,  false)
+   /* McASP function */
+   MUX_CFG(DA850,  ACLKR,  0,  0,  15, 1,  false)
+   MUX_CFG(DA850,  ACLKX,  0,  4,  15, 1,  false)
+   MUX_CFG(DA850,  AFSR,   0,  8,  15, 1,  false)
+   MUX_CFG(DA850,  AFSX,   0,  12, 15, 1,  false)
+   MUX_CFG(DA850,  AHCLKR, 0,  16, 15, 1,  false)
+   MUX_CFG(DA850,  AHCLKX, 0,  20, 15, 1,  false)
+   MUX_CFG(DA850,  AMUTE,  0,  24, 15, 1,  false)
+   MUX_CFG(DA850,  AXR_15, 1,  0,  15, 1,  false)
+   MUX_CFG(DA850,  AXR_14, 1,  4,  15, 1,  false)
+   MUX_CFG(DA850,  AXR_13, 1,  8,  15, 1,  false)
+   MUX_CFG(DA850,  AXR_12, 1,  12, 15, 1,  false)
+   MUX_CFG(DA850,  AXR_11, 1,  16, 15, 1,  false)
+   MUX_CFG(DA850,  AXR_10, 1,  20, 15, 1,  false)
+   MUX_CFG(DA850,  AXR_9,  1,  24, 15, 1,  false)
+   MUX_CFG(DA850,  AXR_8,  1,  28, 15

[PATCH] ARM: DaVinci: Audio support for DA850/OMAP-L138 EVM

2009-08-11 Thread Chaithrika U S
Define resources for McASP used on DA850/OMAP-L138 EVM, add platform
device defintion and Pin Mux configurations.

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
Applies on DaVinci GIT tree.
This patch is dependent on the following patch which I have
submitted earlier:
[PATCH v2] ARM: DaVinci: Audio support for DA830 EVM

 arch/arm/mach-davinci/board-da850-evm.c  |   29 ++
 arch/arm/mach-davinci/da850.c|   39 ++
 arch/arm/mach-davinci/devices-da8xx.c|   34 +-
 arch/arm/mach-davinci/include/mach/asp.h |7 +
 arch/arm/mach-davinci/include/mach/mux.h |   25 +++
 5 files changed, 133 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-davinci/board-da850-evm.c 
b/arch/arm/mach-davinci/board-da850-evm.c
index d989346..52bfe4c 100644
--- a/arch/arm/mach-davinci/board-da850-evm.c
+++ b/arch/arm/mach-davinci/board-da850-evm.c
@@ -38,6 +38,28 @@ static struct davinci_uart_config da850_evm_uart_config 
__initdata = {
.enabled_uarts = 0x7,
 };
 
+/* davinci da850 evm audio machine driver */
+static u8 da850_iis_serializer_direction[] = {
+   INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,
+   INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,
+   INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,  TX_MODE,
+   RX_MODE,INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,
+};
+
+static struct snd_platform_data da850_evm_snd_data = {
+   .tx_dma_offset  = 0x2000,
+   .rx_dma_offset  = 0x2000,
+   .op_mode= DAVINCI_MCASP_IIS_MODE,
+   .num_serializer = ARRAY_SIZE(da850_iis_serializer_direction),
+   .tdm_slots  = 2,
+   .serial_dir = da850_iis_serializer_direction,
+   .eventq_no  = EVENTQ_1,
+   .version= MCASP_VERSION_2,
+   .txnumevt   = 1,
+   .rxnumevt   = 1,
+};
+
+
 static __init void da850_evm_init(void)
 {
struct davinci_soc_info *soc_info = davinci_soc_info;
@@ -86,6 +108,13 @@ static __init void da850_evm_init(void)
 */
__raw_writel(0, IO_ADDRESS(DA8XX_UART1_BASE) + 0x30);
__raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE) + 0x30);
+
+   ret = da8xx_pinmux_setup(da850_mcasp_pins);
+   if (ret)
+   pr_warning(da850_evm_init: mcasp mux setup failed: %d\n,
+   ret);
+
+   da8xx_init_mcasp(0, da850_evm_snd_data);
 }
 
 #ifdef CONFIG_SERIAL_8250_CONSOLE
diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c
index 4a43ae2..e33b226 100644
--- a/arch/arm/mach-davinci/da850.c
+++ b/arch/arm/mach-davinci/da850.c
@@ -289,6 +289,13 @@ static struct clk emac_clk = {
.lpsc   = DA8XX_LPSC1_CPGMAC,
 };
 
+static struct clk mcasp_clk = {
+   .name   = mcasp,
+   .parent = pll0_sysclk2,
+   .lpsc   = DA8XX_LPSC1_McASP0,
+   .psc_ctlr   = 1,
+};
+
 static struct davinci_clk da850_clks[] = {
CLK(NULL,   ref,  ref_clk),
CLK(NULL,   pll0, pll0_clk),
@@ -326,6 +333,7 @@ static struct davinci_clk da850_clks[] = {
CLK(NULL,   arm,  arm_clk),
CLK(NULL,   rmii, rmii_clk),
CLK(davinci_emac.1,   NULL,   emac_clk),
+   CLK(davinci-mcasp.0,  NULL,   mcasp_clk),
CLK(NULL,   NULL,   NULL),
 };
 
@@ -370,6 +378,30 @@ static const struct mux_config da850_pins[] = {
MUX_CFG(DA850, MII_RXD_2,   3,  20, 15, 8,  false)
MUX_CFG(DA850, MII_RXD_1,   3,  24, 15, 8,  false)
MUX_CFG(DA850, MII_RXD_0,   3,  28, 15, 8,  false)
+   /* McASP function */
+   MUX_CFG(DA850,  ACLKR,  0,  0,  15, 1,  false)
+   MUX_CFG(DA850,  ACLKX,  0,  4,  15, 1,  false)
+   MUX_CFG(DA850,  AFSR,   0,  8,  15, 1,  false)
+   MUX_CFG(DA850,  AFSX,   0,  12, 15, 1,  false)
+   MUX_CFG(DA850,  AHCLKR, 0,  16, 15, 1,  false)
+   MUX_CFG(DA850,  AHCLKX, 0,  20, 15, 1,  false)
+   MUX_CFG(DA850,  AMUTE,  0,  24, 15, 1,  false)
+   MUX_CFG(DA850,  AXR_15, 1,  0,  15, 1,  false)
+   MUX_CFG(DA850,  AXR_14, 1,  4,  15, 1,  false)
+   MUX_CFG(DA850,  AXR_13, 1,  8,  15, 1,  false)
+   MUX_CFG(DA850,  AXR_12, 1,  12, 15, 1,  false)
+   MUX_CFG(DA850,  AXR_11, 1,  16, 15, 1,  false)
+   MUX_CFG(DA850,  AXR_10, 1,  20, 15, 1,  false)
+   MUX_CFG(DA850,  AXR_9,  1,  24, 15, 1,  false)
+   MUX_CFG(DA850,  AXR_8,  1,  28, 15

RE:

2009-08-11 Thread chaithrika
All,

Please ignore this mail/patch as the subject line is missing!

Regards, 
Chaithrika

On Wed, Aug 12, 2009 at 02:32:27, Chaithrika U S wrote:
 Define resources for McASP used on DA850/OMAP-L138 EVM, add platform
device defintion and Pin Mux configurations.
 
 Signed-off-by: Chaithrika U S chaithr...@ti.com
 ---
 Applies on DaVinci GIT tree.
 This patch is dependent on the following patch which I have submitted
earlier:
   [PATCH v2] ARM: DaVinci: Audio support for DA830 EVM
 
  arch/arm/mach-davinci/board-da850-evm.c  |   29 ++
  arch/arm/mach-davinci/da850.c|   39
++
  arch/arm/mach-davinci/devices-da8xx.c|   34
+-
  arch/arm/mach-davinci/include/mach/asp.h |7 +
  arch/arm/mach-davinci/include/mach/mux.h |   25 +++
  5 files changed, 133 insertions(+), 1 deletions(-)
 
 diff --git a/arch/arm/mach-davinci/board-da850-evm.c
b/arch/arm/mach-davinci/board-da850-evm.c
 index d989346..52bfe4c 100644
 --- a/arch/arm/mach-davinci/board-da850-evm.c
 +++ b/arch/arm/mach-davinci/board-da850-evm.c
 @@ -38,6 +38,28 @@ static struct davinci_uart_config da850_evm_uart_config
__initdata = {
   .enabled_uarts = 0x7,
  };
  
 +/* davinci da850 evm audio machine driver */ static u8 
 +da850_iis_serializer_direction[] = {
 + INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,
 + INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,
 + INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,  TX_MODE,
 + RX_MODE,INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,
 +};
 +
 +static struct snd_platform_data da850_evm_snd_data = {
 + .tx_dma_offset  = 0x2000,
 + .rx_dma_offset  = 0x2000,
 + .op_mode= DAVINCI_MCASP_IIS_MODE,
 + .num_serializer = ARRAY_SIZE(da850_iis_serializer_direction),
 + .tdm_slots  = 2,
 + .serial_dir = da850_iis_serializer_direction,
 + .eventq_no  = EVENTQ_1,
 + .version= MCASP_VERSION_2,
 + .txnumevt   = 1,
 + .rxnumevt   = 1,
 +};
 +
 +
  static __init void da850_evm_init(void)  {
   struct davinci_soc_info *soc_info = davinci_soc_info; @@ -86,6
+108,13 @@ static __init void da850_evm_init(void)
*/
   __raw_writel(0, IO_ADDRESS(DA8XX_UART1_BASE) + 0x30);
   __raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE) + 0x30);
 +
 + ret = da8xx_pinmux_setup(da850_mcasp_pins);
 + if (ret)
 + pr_warning(da850_evm_init: mcasp mux setup failed: %d\n,
 + ret);
 +
 + da8xx_init_mcasp(0, da850_evm_snd_data);
  }
  
  #ifdef CONFIG_SERIAL_8250_CONSOLE
 diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c
index 4a43ae2..e33b226 100644
 --- a/arch/arm/mach-davinci/da850.c
 +++ b/arch/arm/mach-davinci/da850.c
 @@ -289,6 +289,13 @@ static struct clk emac_clk = {
   .lpsc   = DA8XX_LPSC1_CPGMAC,
  };
  
 +static struct clk mcasp_clk = {
 + .name   = mcasp,
 + .parent = pll0_sysclk2,
 + .lpsc   = DA8XX_LPSC1_McASP0,
 + .psc_ctlr   = 1,
 +};
 +
  static struct davinci_clk da850_clks[] = {
   CLK(NULL,   ref,  ref_clk),
   CLK(NULL,   pll0, pll0_clk),
 @@ -326,6 +333,7 @@ static struct davinci_clk da850_clks[] = {
   CLK(NULL,   arm,  arm_clk),
   CLK(NULL,   rmii, rmii_clk),
   CLK(davinci_emac.1,   NULL,   emac_clk),
 + CLK(davinci-mcasp.0,  NULL,   mcasp_clk),
   CLK(NULL,   NULL,   NULL),
  };
  
 @@ -370,6 +378,30 @@ static const struct mux_config da850_pins[] = {
   MUX_CFG(DA850, MII_RXD_2,   3,  20, 15, 8,
false)
   MUX_CFG(DA850, MII_RXD_1,   3,  24, 15, 8,
false)
   MUX_CFG(DA850, MII_RXD_0,   3,  28, 15, 8,
false)
 + /* McASP function */
 + MUX_CFG(DA850,  ACLKR,  0,  0,  15, 1,
false)
 + MUX_CFG(DA850,  ACLKX,  0,  4,  15, 1,
false)
 + MUX_CFG(DA850,  AFSR,   0,  8,  15, 1,
false)
 + MUX_CFG(DA850,  AFSX,   0,  12, 15, 1,
false)
 + MUX_CFG(DA850,  AHCLKR, 0,  16, 15, 1,
false)
 + MUX_CFG(DA850,  AHCLKX, 0,  20, 15, 1,
false)
 + MUX_CFG(DA850,  AMUTE,  0,  24, 15, 1,
false)
 + MUX_CFG(DA850,  AXR_15, 1,  0,  15, 1,
false)
 + MUX_CFG(DA850,  AXR_14, 1,  4,  15, 1,
false)
 + MUX_CFG(DA850,  AXR_13, 1,  8,  15, 1,
false)
 + MUX_CFG(DA850,  AXR_12, 1,  12, 15, 1,
false)
 + MUX_CFG(DA850,  AXR_11, 1,  16, 15, 1,
false)
 + MUX_CFG(DA850,  AXR_10, 1,  20, 15, 1,
false)
 + MUX_CFG(DA850,  AXR_9,  1,  24, 15, 1,
false

RE: [PATCH 1/2] ASoC: DaVinci: McASP driver enhacements

2009-08-09 Thread chaithrika
On Sat, Aug 08, 2009 at 01:29:05, Troy Kisky wrote:
 Chaithrika U S wrote:
  ---
   sound/soc/davinci/davinci-mcasp.c |  113
++--
   sound/soc/davinci/davinci-mcasp.h |5 ++
   sound/soc/davinci/davinci-pcm.c   |4 +-
   sound/soc/davinci/davinci-pcm.h   |1 +
   4 files changed, 115 insertions(+), 8 deletions(-)
 
 .
  diff --git a/sound/soc/davinci/davinci-pcm.c
b/sound/soc/davinci/davinci-pcm.c
  index 8fd0c3c..1e2dfd0 100644
  --- a/sound/soc/davinci/davinci-pcm.c
  +++ b/sound/soc/davinci/davinci-pcm.c
  @@ -67,6 +67,7 @@ static void davinci_pcm_enqueue_dma(struct
snd_pcm_substream *substream)
  dma_addr_t src, dst;
  unsigned short src_bidx, dst_bidx;
  unsigned int data_type;
  +   unsigned short acnt;
  unsigned int count;
   
  period_size = snd_pcm_lib_period_bytes(substream);
  @@ -91,11 +92,12 @@ static void davinci_pcm_enqueue_dma(struct
snd_pcm_substream *substream)
  dst_bidx = data_type;
  }
   
  +   acnt = prtd-params-acnt;
  edma_set_src(lch, src, INCR, W8BIT);
  edma_set_dest(lch, dst, INCR, W8BIT);
  edma_set_src_index(lch, src_bidx, 0);
  edma_set_dest_index(lch, dst_bidx, 0);
  -   edma_set_transfer_params(lch, data_type, count, 1, 0, ASYNC);
  +   edma_set_transfer_params(lch, acnt, count, 1, 0, ASYNC);
 
 Since I see no change to davinci-i2s, I think this will break any platform
which
 uses davinci-i2s.
 
Yes, I agree. I have missed out the changes got davinci-i2s.
I will submit a patch for this.

Thanks,
Chaithrika


   
  prtd-period++;
  if (unlikely(prtd-period = runtime-periods))
  diff --git a/sound/soc/davinci/davinci-pcm.h
b/sound/soc/davinci/davinci-pcm.h
  index eb4287f..63d9625 100644
  --- a/sound/soc/davinci/davinci-pcm.h
  +++ b/sound/soc/davinci/davinci-pcm.h
  @@ -19,6 +19,7 @@
   struct davinci_pcm_dma_params {
  char *name; /* stream identifier */
  int channel;/* sync dma channel ID */
  +   unsigned short acnt;
  dma_addr_t dma_addr;/* device physical address for DMA
*/
  enum dma_event_q eventq_no; /* event queue number */
  unsigned char data_type;/* xfer data type */
 
 




___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


RE: [alsa-devel] [PATCH 1/2] ASoC: DaVinci: McASP driver enhacements

2009-08-09 Thread chaithrika
On Sat, Aug 08, 2009 at 13:41:58, Mark Brown wrote:
 On Fri, Aug 07, 2009 at 10:07:42AM -0400, Chaithrika U S wrote:
 
  This patch adds support for FIFO configuration.The platform member has a

  version field which differentiates the McASP on different SoCs. The
patch 
  also adds another DAI format to the driver.
 
 You really should split out the DAI format addition into another patch -
 there's no code overlap between that and the rest of your changes.
OK. I will post a separate patch for this change.

 Aside from the issue Troy raised everything seems fine except for one
OK. I will submit a patch for that issue.

 small issue:
 
  +
  +   /* McASP FIFO related */
  +   u8  txnumevt;
  +   u8  rxnumevt;
 
 These names don't seem particularly obvious.  If they were chosen to
 match the datasheet name then it probably won't be a problem but
 otherwise something more like tx_fifo_depth might be easier for people
 to figure out.
 
Currently, the names are as per the peripheral datasheet. So, will 
retain the same name.

Regards, 
Chaithrika


___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


[PATCH] ARM: DaVinci: Audio support for DA830 EVM

2009-08-06 Thread Chaithrika U S
Define resources for McASP1 used on DA830 EVM, add platform
device defintion, initialization function.
Additionally, this patch also adds version and FIFO related
members to platform data structure.

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
Applies to DaVinci GIT tree

 arch/arm/mach-davinci/board-da830-evm.c|   22 +
 arch/arm/mach-davinci/da830.c  |   48 ++--
 arch/arm/mach-davinci/include/mach/asp.h   |   15 +
 arch/arm/mach-davinci/include/mach/da8xx.h |2 +
 4 files changed, 84 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-davinci/board-da830-evm.c 
b/arch/arm/mach-davinci/board-da830-evm.c
index 9025669..4643795 100644
--- a/arch/arm/mach-davinci/board-da830-evm.c
+++ b/arch/arm/mach-davinci/board-da830-evm.c
@@ -23,6 +23,7 @@
 #include mach/irqs.h
 #include mach/cp_intc.h
 #include mach/da8xx.h
+#include mach/asp.h
 
 #define DA830_EVM_PHY_MASK 0x0
 #define DA830_EVM_MDIO_FREQUENCY   220 /* PHY bus frequency */
@@ -51,6 +52,25 @@ static struct davinci_uart_config da830_evm_uart_config 
__initdata = {
.enabled_uarts = 0x7,
 };
 
+static u8 da830_iis_serializer_direction[] = {
+   RX_MODE,INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,
+   INACTIVE_MODE,  TX_MODE,INACTIVE_MODE,  INACTIVE_MODE,
+   INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,
+};
+
+static struct snd_platform_data da830_evm_snd_data = {
+   .tx_dma_offset  = 0x2000,
+   .rx_dma_offset  = 0x2000,
+   .op_mode= DAVINCI_MCASP_IIS_MODE,
+   .num_serializer = ARRAY_SIZE(da830_iis_serializer_direction),
+   .tdm_slots  = 2,
+   .serial_dir = da830_iis_serializer_direction,
+   .eventq_no  = EVENTQ_0,
+   .version= MCASP_VERSION_2,
+   .txnumevt   = 1,
+   .rxnumevt   = 1,
+};
+
 static __init void da830_evm_init(void)
 {
struct davinci_soc_info *soc_info = davinci_soc_info;
@@ -93,6 +113,8 @@ static __init void da830_evm_init(void)
davinci_serial_init(da830_evm_uart_config);
i2c_register_board_info(1, da830_evm_i2c_devices,
ARRAY_SIZE(da830_evm_i2c_devices));
+
+   da830_init_mcasp1(da830_evm_snd_data);
 }
 
 #ifdef CONFIG_SERIAL_8250_CONSOLE
diff --git a/arch/arm/mach-davinci/da830.c b/arch/arm/mach-davinci/da830.c
index 3a9b634..a160a7f 100644
--- a/arch/arm/mach-davinci/da830.c
+++ b/arch/arm/mach-davinci/da830.c
@@ -23,6 +23,7 @@
 #include mach/common.h
 #include mach/time.h
 #include mach/da8xx.h
+#include mach/asp.h
 
 #include clock.h
 #include mux.h
@@ -411,9 +412,9 @@ static struct davinci_clk da830_clks[] = {
CLK(eqep.0,   NULL,   eqep0_clk),
CLK(eqep.1,   NULL,   eqep1_clk),
CLK(da830_lcdc,   NULL,   lcdc_clk),
-   CLK(soc-audio.0,  NULL,   mcasp0_clk),
-   CLK(soc-audio.1,  NULL,   mcasp1_clk),
-   CLK(soc-audio.2,  NULL,   mcasp2_clk),
+   CLK(davinci-mcasp.0,  NULL,   mcasp0_clk),
+   CLK(davinci-mcasp.1,  NULL,   mcasp1_clk),
+   CLK(davinci-mcasp.2,  NULL,   mcasp2_clk),
CLK(musb_hdrc,NULL,   usb20_clk),
CLK(NULL,   aemif,aemif_clk),
CLK(NULL,   aintc,aintc_clk),
@@ -1198,6 +1199,47 @@ static struct davinci_soc_info davinci_soc_info_da830 = {
.emac_pdata = da8xx_emac_pdata,
 };
 
+static struct resource da830_mcasp1_resources[] = {
+   {
+   .name   = mcasp1,
+   .start  = DAVINCI_DA830_MCASP1_REG_BASE,
+   .end= DAVINCI_DA830_MCASP1_REG_BASE + (SZ_1K * 12) - 1,
+   .flags  = IORESOURCE_MEM,
+   },
+   /* TX event */
+   {
+   .start  = DAVINCI_DA830_DMA_MCASP1_AXEVT,
+   .end= DAVINCI_DA830_DMA_MCASP1_AXEVT,
+   .flags  = IORESOURCE_DMA,
+   },
+   /* RX event */
+   {
+   .start  = DAVINCI_DA830_DMA_MCASP1_AREVT,
+   .end= DAVINCI_DA830_DMA_MCASP1_AREVT,
+   .flags  = IORESOURCE_DMA,
+   },
+};
+
+static struct platform_device da830_mcasp1_device = {
+   .name   = davinci-mcasp,
+   .id = 1,
+   .num_resources  = ARRAY_SIZE(da830_mcasp1_resources),
+   .resource   = da830_mcasp1_resources,
+};
+
+void __init da830_init_mcasp1(struct snd_platform_data *pdata)
+{
+   int ret;
+
+   ret = da8xx_pinmux_setup(da830_mcasp1_pins);
+   if (ret)
+   pr_warning(da830_evm_init: mcasp1 mux setup failed: %d\n,
+   ret);
+
+   da830_mcasp1_device.dev.platform_data = pdata;
+   platform_device_register(da830_mcasp1_device);
+}
+
 void __init da830_init(void)
 {
davinci_common_init(davinci_soc_info_da830);
diff --git a/arch/arm/mach-davinci

[PATCH 2/2] ASoC: DaVinci: Support Audio on DA830 EVM

2009-08-06 Thread Chaithrika U S
Add support for audio on DA830 EVM- here McASP1 is interfaced to 
TLV320AIC3106 codec.

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
Applies to ALSA GIT tree on branch topic/asoc at
http://git.kernel.org/?p=linux/kernel/git/tiwai/sound-2.6.git;a=shortlog;
h=topic/asoc

 sound/soc/davinci/Kconfig   |   11 +++
 sound/soc/davinci/Makefile  |1 +
 sound/soc/davinci/davinci-evm.c |   33 +
 3 files changed, 45 insertions(+), 0 deletions(-)

diff --git a/sound/soc/davinci/Kconfig b/sound/soc/davinci/Kconfig
index 6802dd5..677a538 100644
--- a/sound/soc/davinci/Kconfig
+++ b/sound/soc/davinci/Kconfig
@@ -41,3 +41,14 @@ config SND_DAVINCI_SOC_SFFSDR
help
  Say Y if you want to add support for SoC audio on
  Lyrtech SFFSDR board.
+
+config  SND_DA830_SOC_EVM
+   tristate SoC Audio support for DA830/OMAPL137 EVM
+   depends on SND_DAVINCI_SOC  MACH_DAVINCI_DA830_EVM
+   select SND_DAVINCI_SOC_MCASP
+   select SND_SOC_TLV320AIC3X
+
+   help
+ Say Y if you want to add support for SoC audio on TI
+ DA830/OMAPL137 EVM
+
diff --git a/sound/soc/davinci/Makefile b/sound/soc/davinci/Makefile
index 67be54f..5e2195f 100644
--- a/sound/soc/davinci/Makefile
+++ b/sound/soc/davinci/Makefile
@@ -13,4 +13,5 @@ snd-soc-sffsdr-objs := davinci-sffsdr.o
 
 obj-$(CONFIG_SND_DAVINCI_SOC_EVM) += snd-soc-evm.o
 obj-$(CONFIG_SND_DM6467_SOC_EVM) += snd-soc-evm.o
+obj-$(CONFIG_SND_DA830_SOC_EVM) += snd-soc-evm.o
 obj-$(CONFIG_SND_DAVINCI_SOC_SFFSDR) += snd-soc-sffsdr.o
diff --git a/sound/soc/davinci/davinci-evm.c b/sound/soc/davinci/davinci-evm.c
index f3bb6f6..a5a9212 100644
--- a/sound/soc/davinci/davinci-evm.c
+++ b/sound/soc/davinci/davinci-evm.c
@@ -54,6 +54,9 @@ static int evm_hw_params(struct snd_pcm_substream *substream,
else if (machine_is_davinci_evm())
sysclk = 12288000;
 
+   else if (machine_is_davinci_da830_evm())
+   sysclk = 24576000;
+
else
return -EINVAL;
 
@@ -162,6 +165,14 @@ static struct snd_soc_dai_link dm6467_evm_dai[] = {
.ops = evm_ops,
},
 };
+static struct snd_soc_dai_link da830_evm_dai = {
+   .name = TLV320AIC3X,
+   .stream_name = AIC3X,
+   .cpu_dai = davinci_mcasp_dai[DAVINCI_MCASP_I2S_DAI],
+   .codec_dai = aic3x_dai,
+   .init = evm_aic3x_init,
+   .ops = evm_ops,
+};
 
 /* davinci-evm audio machine driver */
 static struct snd_soc_card snd_soc_card_evm = {
@@ -179,6 +190,13 @@ static struct snd_soc_card dm6467_snd_soc_card_evm = {
.num_links = ARRAY_SIZE(dm6467_evm_dai),
 };
 
+static struct snd_soc_card da830_snd_soc_card = {
+   .name = DA830 EVM,
+   .dai_link = da830_evm_dai,
+   .platform = davinci_soc_platform,
+   .num_links = 1,
+};
+
 /* evm audio private data */
 static struct aic3x_setup_data evm_aic3x_setup = {
.i2c_bus = 1,
@@ -191,6 +209,11 @@ static struct aic3x_setup_data dm6467_evm_aic3x_setup = {
.i2c_address = 0x18,
 };
 
+static struct aic3x_setup_data da830_evm_aic3x_setup = {
+   .i2c_bus = 1,
+   .i2c_address = 0x18,
+};
+
 /* evm audio subsystem */
 static struct snd_soc_device evm_snd_devdata = {
.card = snd_soc_card_evm,
@@ -205,6 +228,13 @@ static struct snd_soc_device dm6467_evm_snd_devdata = {
.codec_data = dm6467_evm_aic3x_setup,
 };
 
+/* evm audio subsystem */
+static struct snd_soc_device da830_evm_snd_devdata = {
+   .card = da830_snd_soc_card,
+   .codec_dev = soc_codec_dev_aic3x,
+   .codec_data = da830_evm_aic3x_setup,
+};
+
 static struct platform_device *evm_snd_device;
 
 static int __init evm_init(void)
@@ -222,6 +252,9 @@ static int __init evm_init(void)
} else if (machine_is_davinci_dm6467_evm()) {
evm_snd_dev_data = dm6467_evm_snd_devdata;
index = 0;
+   } else if (machine_is_davinci_da830_evm()) {
+   evm_snd_dev_data = da830_evm_snd_devdata;
+   index = 1;
} else
return -EINVAL;
 
-- 
1.5.6

___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


[PATCH 1/2] ASoC: DaVinci: McASP driver enhacements

2009-08-06 Thread Chaithrika U S
On DA830/OMAPL137 SoC, the McASP peripheral has internal FIFO support.
It provides additional data buffering. It also provides tolerance to
vairiation in host/DMA controller response times. The read and write FIFO
sizes are 256 bytes each. If FIFO is enabled, the DMA events from McASP
are sent to the FIFO which inturn sends DMA requests to the host CPU 
according to the thresholds programmed.
More details of the FIFO operation can be found at
http://focus.ti.com/general/docs/lit/getliterature.tsp?literatureNumber=
sprufm1fileType=pdf 

This patch adds support for FIFO configuration.The platform member has a 
version field which differentiates the McASP on different SoCs. The patch 
also adds another DAI format to the driver.

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
 sound/soc/davinci/davinci-mcasp.c |  113 ++--
 sound/soc/davinci/davinci-mcasp.h |5 ++
 sound/soc/davinci/davinci-pcm.c   |4 +-
 sound/soc/davinci/davinci-pcm.h   |1 +
 4 files changed, 115 insertions(+), 8 deletions(-)

diff --git a/sound/soc/davinci/davinci-mcasp.c 
b/sound/soc/davinci/davinci-mcasp.c
index f0c0347..eca22d7 100644
--- a/sound/soc/davinci/davinci-mcasp.c
+++ b/sound/soc/davinci/davinci-mcasp.c
@@ -102,6 +102,11 @@
 /* Receive Buffer for Serializer n */
 #define DAVINCI_MCASP_RXBUF_REG0x280
 
+/* McASP FIFO Registers */
+#define DAVINCI_MCASP_WFIFOCTL (0x1010)
+#define DAVINCI_MCASP_WFIFOSTS (0x1014)
+#define DAVINCI_MCASP_RFIFOCTL (0x1018)
+#define DAVINCI_MCASP_RFIFOSTS (0x101C)
 
 /*
  * DAVINCI_MCASP_PWREMUMGT_REG - Power Down and Emulation Management
@@ -276,6 +281,13 @@
  */
 #define TXDATADMADIS   BIT(0)
 
+/*
+ * DAVINCI_MCASP_W[R]FIFOCTL - Write/Read FIFO Control Register bits
+ */
+#define FIFO_ENABLEBIT(16)
+#define NUMEVT_MASK(0xFF  8)
+#define NUMDMA_MASK(0xFF)
+
 #define DAVINCI_MCASP_NUM_SERIALIZER   16
 
 static inline void mcasp_set_bits(void __iomem *reg, u32 val)
@@ -345,6 +357,9 @@ static void mcasp_start_rx(struct davinci_audio_dev *dev)
 
 static void mcasp_start_tx(struct davinci_audio_dev *dev)
 {
+   u8 offset = 0, i;
+   u32 cnt;
+
mcasp_set_ctl_reg(dev-base + DAVINCI_MCASP_GBLCTLX_REG, TXHCLKRST);
mcasp_set_ctl_reg(dev-base + DAVINCI_MCASP_GBLCTLX_REG, TXCLKRST);
mcasp_set_ctl_reg(dev-base + DAVINCI_MCASP_GBLCTLX_REG, TXSERCLR);
@@ -353,6 +368,19 @@ static void mcasp_start_tx(struct davinci_audio_dev *dev)
mcasp_set_ctl_reg(dev-base + DAVINCI_MCASP_GBLCTLX_REG, TXSMRST);
mcasp_set_ctl_reg(dev-base + DAVINCI_MCASP_GBLCTLX_REG, TXFSRST);
mcasp_set_reg(dev-base + DAVINCI_MCASP_TXBUF_REG, 0);
+   for (i = 0; i  dev-num_serializer; i++) {
+   if (dev-serial_dir[i] == TX_MODE) {
+   offset = i;
+   break;
+   }
+   }
+
+   /* wait for TX ready */
+   cnt = 0;
+   while (!(mcasp_get_reg(dev-base + DAVINCI_MCASP_XRSRCTL_REG(offset)) 
+TXSTATE)  (cnt  10))
+   cnt++;
+
mcasp_set_reg(dev-base + DAVINCI_MCASP_TXBUF_REG, 0);
 }
 
@@ -362,6 +390,13 @@ static void davinci_mcasp_start(struct davinci_audio_dev 
*dev, int stream)
mcasp_start_tx(dev);
else
mcasp_start_rx(dev);
+
+   /* enable FIFO */
+   if (dev-txnumevt)
+   mcasp_set_bits(dev-base + DAVINCI_MCASP_WFIFOCTL, FIFO_ENABLE);
+
+   if (dev-rxnumevt)
+   mcasp_set_bits(dev-base + DAVINCI_MCASP_RFIFOCTL, FIFO_ENABLE);
 }
 
 static void mcasp_stop_rx(struct davinci_audio_dev *dev)
@@ -382,6 +417,13 @@ static void davinci_mcasp_stop(struct davinci_audio_dev 
*dev, int stream)
mcasp_stop_tx(dev);
else
mcasp_stop_rx(dev);
+
+   /* disable FIFO */
+   if (dev-txnumevt)
+   mcasp_clr_bits(dev-base + DAVINCI_MCASP_WFIFOCTL, FIFO_ENABLE);
+
+   if (dev-rxnumevt)
+   mcasp_clr_bits(dev-base + DAVINCI_MCASP_RFIFOCTL, FIFO_ENABLE);
 }
 
 static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai,
@@ -401,7 +443,16 @@ static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai 
*cpu_dai,
 
mcasp_set_bits(base + DAVINCI_MCASP_PDIR_REG, (0x7  26));
break;
+   case SND_SOC_DAIFMT_CBM_CFS:
+   /* codec is clock master and frame slave */
+   mcasp_set_bits(base + DAVINCI_MCASP_ACLKXCTL_REG, ACLKXE);
+   mcasp_set_bits(base + DAVINCI_MCASP_TXFMCTL_REG, AFSXE);
 
+   mcasp_set_bits(base + DAVINCI_MCASP_ACLKRCTL_REG, ACLKRE);
+   mcasp_set_bits(base + DAVINCI_MCASP_RXFMCTL_REG, AFSRE);
+
+   mcasp_set_bits(base + DAVINCI_MCASP_PDIR_REG, (0x2d  26));
+   break;
case SND_SOC_DAIFMT_CBM_CFM:
/* codec is clock and frame master */
mcasp_clr_bits(base + DAVINCI_MCASP_ACLKXCTL_REG

RE: [PATCH v3] ARM: DaVinci: DM646x Video: Platform and board specific setup

2009-08-04 Thread chaithrika
On Wed, Aug 05, 2009 at 02:45:36, Karicheri, Muralidharan wrote:
 
 
 -Original Message-
 From: davinci-linux-open-source-boun...@linux.davincidsp.com
 [mailto:davinci-linux-open-source-boun...@linux.davincidsp.com] On Behalf
 Of Subrahmanya, Chaithrika
 Sent: Monday, July 20, 2009 4:01 AM
 To: li...@arm.linux.org.uk
 Cc: davinci-linux-open-source@linux.davincidsp.com;
mche...@infradead.org;
 linux-me...@vger.kernel.org
 Subject: [PATCH v3] ARM: DaVinci: DM646x Video: Platform and board
specific
 setup
 
 Platform specific display device setup for DM646x EVM
 
 Add platform device and resource structures. Also define a platform
 specific
 clock setup function that can be accessed by the driver to configure the
 clock
 and CPLD.
 
 Signed-off-by: Manjunath Hadli m...@ti.com
 Signed-off-by: Brijesh Jadav brijes...@ti.com
 Signed-off-by: Chaithrika U S chaithr...@ti.com
 Signed-off-by: Kevin Hilman khil...@deeprootsystems.com
 ---
 Applies to Davinci GIT tree. Minor updates like change in structure name-
 subdev_info to vpif_subdev_info and correction to VDD3P3V_VID_MASK value.
 
  arch/arm/mach-davinci/board-dm646x-evm.c|  125
 +++
  arch/arm/mach-davinci/dm646x.c  |   62 +
  arch/arm/mach-davinci/include/mach/dm646x.h |   24 +
  3 files changed, 211 insertions(+), 0 deletions(-)
 
 diff --git a/arch/arm/mach-davinci/board-dm646x-evm.c b/arch/arm/mach-
 davinci/board-dm646x-evm.c
 index b1bf18c..8c88fd0 100644
 --- a/arch/arm/mach-davinci/board-dm646x-evm.c
 +++ b/arch/arm/mach-davinci/board-dm646x-evm.c
 @@ -63,6 +63,19 @@
  #define DM646X_EVM_PHY_MASK (0x2)
  #define DM646X_EVM_MDIO_FREQUENCY   (220) /* PHY bus frequency */
 
 +#define VIDCLKCTL_OFFSET(0x38)
 +#define VSCLKDIS_OFFSET (0x6c)
 +
 +#define VCH2CLK_MASK(BIT_MASK(10) | BIT_MASK(9) |
BIT_MASK(8))
 +#define VCH2CLK_SYSCLK8 (BIT(9))
 +#define VCH2CLK_AUXCLK  (BIT(9) | BIT(8))
 +#define VCH3CLK_MASK(BIT_MASK(14) | BIT_MASK(13) |
BIT_MASK(12))
 +#define VCH3CLK_SYSCLK8 (BIT(13))
 +#define VCH3CLK_AUXCLK  (BIT(14) | BIT(13))
 +
 +#define VIDCH2CLK   (BIT(10))
 +#define VIDCH3CLK   (BIT(11))
 +
  static struct davinci_uart_config uart_config __initdata = {
  .enabled_uarts = (1  0),
  };
 @@ -288,6 +301,40 @@ static struct snd_platform_data
dm646x_evm_snd_data[]
 = {
  },
  };
 
 +static struct i2c_client *cpld_client;
 +
 +static int cpld_video_probe(struct i2c_client *client,
 +const struct i2c_device_id *id)
 +{
 +cpld_client = client;
 +return 0;
 +}
 +
 +static int __devexit cpld_video_remove(struct i2c_client *client)
 +{
 +cpld_client = NULL;
 +return 0;
 +}
 +
 +static const struct i2c_device_id cpld_video_id[] = {
 +{ cpld_video, 0 },
 +{ }
 +};
 +
 +static struct i2c_driver cpld_video_driver = {
 +.driver = {
 +.name   = cpld_video,
 +},
 +.probe  = cpld_video_probe,
 +.remove = cpld_video_remove,
 +.id_table   = cpld_video_id,
 +};
 +
 +static void evm_init_cpld(void)
 +{
 +i2c_add_driver(cpld_video_driver);
 +}
 +
  static struct i2c_board_info __initdata i2c_info[] =  {
  {
  I2C_BOARD_INFO(24c256, 0x50),
 @@ -300,6 +347,9 @@ static struct i2c_board_info __initdata i2c_info[] =
{
  {
  I2C_BOARD_INFO(cpld_reg0, 0x3a),
  },
 +{
 +I2C_BOARD_INFO(cpld_video, 0x3B),
 +},
  };
 
  static struct davinci_i2c_platform_data i2c_pdata = {
 @@ -307,11 +357,85 @@ static struct davinci_i2c_platform_data i2c_pdata =
{
  .bus_delay  = 0 /* usec */,
  };
 
 +static int set_vpif_clock(int mux_mode, int hd)
 +{
 +int val = 0;
 +int err = 0;
 +unsigned int value;
 +void __iomem *base = IO_ADDRESS(DAVINCI_SYSTEM_MODULE_BASE);
 +
 +if (!cpld_client)
 +return -ENXIO;
 +
 +/* disable the clock */
 +value = __raw_readl(base + VSCLKDIS_OFFSET);
 +value |= (VIDCH3CLK | VIDCH2CLK);
 +__raw_writel(value, base + VSCLKDIS_OFFSET);
 +
 +val = i2c_smbus_read_byte(cpld_client);
 +if (val  0)
 +return val;
 +
 +if (mux_mode == 1)
 +val = ~0x40;
 +else
 +val |= 0x40;
 +
 +err = i2c_smbus_write_byte(cpld_client, val);
 +if (err)
 +return err;
 +
 +value = __raw_readl(base + VIDCLKCTL_OFFSET);
 +value = ~(VCH2CLK_MASK);
 +value = ~(VCH3CLK_MASK);
 +
 +if (hd = 1)
 +value |= (VCH2CLK_SYSCLK8 | VCH3CLK_SYSCLK8);
 +else
 +value |= (VCH2CLK_AUXCLK | VCH3CLK_AUXCLK);
 +
 +__raw_writel(value, base + VIDCLKCTL_OFFSET);
 +
 +/* enable the clock */
 +value = __raw_readl(base + VSCLKDIS_OFFSET);
 +value = ~(VIDCH3CLK | VIDCH2CLK);
 +__raw_writel(value, base + VSCLKDIS_OFFSET);
 +
 +return 0;
 +}
 +
 +static const struct vpif_subdev_info

[PATCH v4] ARM: DaVinci: DM646x Video: Platform and board specific setup

2009-08-04 Thread Chaithrika U S
Platform specific display device setup for DM646x EVM

Add platform device and resource structures. Also define a platform specific
clock setup function that can be accessed by the driver to configure the clock
and CPLD.

Signed-off-by: Manjunath Hadli m...@ti.com
Signed-off-by: Brijesh Jadav brijes...@ti.com
Signed-off-by: Chaithrika U S chaithr...@ti.com
Signed-off-by: Kevin Hilman khil...@deeprootsystems.com
---
Applies to Davinci GIT tree. Minor updates like change in structure name-
subdev_info to vpif_subdev_info and correction to VDD3P3V_VID_MASK value.

 arch/arm/mach-davinci/board-dm646x-evm.c|  125 +++
 arch/arm/mach-davinci/dm646x.c  |   62 +
 arch/arm/mach-davinci/include/mach/dm646x.h |   24 +
 3 files changed, 211 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-davinci/board-dm646x-evm.c 
b/arch/arm/mach-davinci/board-dm646x-evm.c
index b1bf18c..8c88fd0 100644
--- a/arch/arm/mach-davinci/board-dm646x-evm.c
+++ b/arch/arm/mach-davinci/board-dm646x-evm.c
@@ -63,6 +63,19 @@
 #define DM646X_EVM_PHY_MASK(0x2)
 #define DM646X_EVM_MDIO_FREQUENCY  (220) /* PHY bus frequency */
 
+#define VIDCLKCTL_OFFSET   (0x38)
+#define VSCLKDIS_OFFSET(0x6c)
+
+#define VCH2CLK_MASK   (BIT_MASK(10) | BIT_MASK(9) | BIT_MASK(8))
+#define VCH2CLK_SYSCLK8(BIT(9))
+#define VCH2CLK_AUXCLK (BIT(9) | BIT(8))
+#define VCH3CLK_MASK   (BIT_MASK(14) | BIT_MASK(13) | BIT_MASK(12))
+#define VCH3CLK_SYSCLK8(BIT(13))
+#define VCH3CLK_AUXCLK (BIT(14) | BIT(13))
+
+#define VIDCH2CLK  (BIT(10))
+#define VIDCH3CLK  (BIT(11))
+
 static struct davinci_uart_config uart_config __initdata = {
.enabled_uarts = (1  0),
 };
@@ -288,6 +301,40 @@ static struct snd_platform_data dm646x_evm_snd_data[] = {
},
 };
 
+static struct i2c_client *cpld_client;
+
+static int cpld_video_probe(struct i2c_client *client,
+   const struct i2c_device_id *id)
+{
+   cpld_client = client;
+   return 0;
+}
+
+static int __devexit cpld_video_remove(struct i2c_client *client)
+{
+   cpld_client = NULL;
+   return 0;
+}
+
+static const struct i2c_device_id cpld_video_id[] = {
+   { cpld_video, 0 },
+   { }
+};
+
+static struct i2c_driver cpld_video_driver = {
+   .driver = {
+   .name   = cpld_video,
+   },
+   .probe  = cpld_video_probe,
+   .remove = cpld_video_remove,
+   .id_table   = cpld_video_id,
+};
+
+static void evm_init_cpld(void)
+{
+   i2c_add_driver(cpld_video_driver);
+}
+
 static struct i2c_board_info __initdata i2c_info[] =  {
{
I2C_BOARD_INFO(24c256, 0x50),
@@ -300,6 +347,9 @@ static struct i2c_board_info __initdata i2c_info[] =  {
{
I2C_BOARD_INFO(cpld_reg0, 0x3a),
},
+   {
+   I2C_BOARD_INFO(cpld_video, 0x3B),
+   },
 };
 
 static struct davinci_i2c_platform_data i2c_pdata = {
@@ -307,11 +357,85 @@ static struct davinci_i2c_platform_data i2c_pdata = {
.bus_delay  = 0 /* usec */,
 };
 
+static int set_vpif_clock(int mux_mode, int hd)
+{
+   int val = 0;
+   int err = 0;
+   unsigned int value;
+   void __iomem *base = IO_ADDRESS(DAVINCI_SYSTEM_MODULE_BASE);
+
+   if (!cpld_client)
+   return -ENXIO;
+
+   /* disable the clock */
+   value = __raw_readl(base + VSCLKDIS_OFFSET);
+   value |= (VIDCH3CLK | VIDCH2CLK);
+   __raw_writel(value, base + VSCLKDIS_OFFSET);
+
+   val = i2c_smbus_read_byte(cpld_client);
+   if (val  0)
+   return val;
+
+   if (mux_mode == 1)
+   val = ~0x40;
+   else
+   val |= 0x40;
+
+   err = i2c_smbus_write_byte(cpld_client, val);
+   if (err)
+   return err;
+
+   value = __raw_readl(base + VIDCLKCTL_OFFSET);
+   value = ~(VCH2CLK_MASK);
+   value = ~(VCH3CLK_MASK);
+
+   if (hd = 1)
+   value |= (VCH2CLK_SYSCLK8 | VCH3CLK_SYSCLK8);
+   else
+   value |= (VCH2CLK_AUXCLK | VCH3CLK_AUXCLK);
+
+   __raw_writel(value, base + VIDCLKCTL_OFFSET);
+
+   /* enable the clock */
+   value = __raw_readl(base + VSCLKDIS_OFFSET);
+   value = ~(VIDCH3CLK | VIDCH2CLK);
+   __raw_writel(value, base + VSCLKDIS_OFFSET);
+
+   return 0;
+}
+
+static const struct vpif_subdev_info dm646x_vpif_subdev[] = {
+   {
+   .addr   = 0x2A,
+   .name   = adv7343,
+   },
+   {
+   .addr   = 0x2C,
+   .name   = ths7303,
+   },
+};
+
+static const char *output[] = {
+   Composite,
+   Component,
+   S-Video,
+};
+
+static struct vpif_config dm646x_vpif_config = {
+   .set_clock  = set_vpif_clock,
+   .subdevinfo = dm646x_vpif_subdev,
+   .subdev_count   = ARRAY_SIZE(dm646x_vpif_subdev

RE: [PATCH v3] ARM: DaVinci: DM646x Video: Platform and board specific setup

2009-08-03 Thread chaithrika
Mauro,

OK. Thank you for taking care of this.

On Mon, Aug 03, 2009 at 11:20:03, Mauro Carvalho Chehab wrote:
 Em Mon, 3 Aug 2009 09:17:06 +0530
 chaithrika chaithr...@ti.com escreveu:
 
  Mauro/Russell,
  
  The previous version (v2) of this patch is on the linux-next tree.
  This patch has some updates done on top of that patch. Should I post 
  an incremental patch for those changes to the Linux-next tree?
  Please suggest.
  
 It is not needed. After having Russell ack, I'll just replace the old
patch by the new one.
 
 
 
 Cheers,
 Mauro
 


Regards, 
Chaithrika


___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


RE: [PATCH v3] ARM: DaVinci: DM646x Video: Platform and board specific setup

2009-08-02 Thread chaithrika
Mauro/Russell,

The previous version (v2) of this patch is on the linux-next tree.
This patch has some updates done on top of that patch. Should I
post an incremental patch for those changes to the Linux-next tree?
Please suggest.

Regards,
Chaithrika

On Mon, Jul 20, 2009 at 13:31:22, Chaithrika U S wrote:
 Platform specific display device setup for DM646x EVM
 
 Add platform device and resource structures. Also define a platform
specific
 clock setup function that can be accessed by the driver to configure the
clock
 and CPLD.
 
 Signed-off-by: Manjunath Hadli m...@ti.com
 Signed-off-by: Brijesh Jadav brijes...@ti.com
 Signed-off-by: Chaithrika U S chaithr...@ti.com
 Signed-off-by: Kevin Hilman khil...@deeprootsystems.com
 ---
 Applies to Davinci GIT tree. Minor updates like change in structure name-
 subdev_info to vpif_subdev_info and correction to VDD3P3V_VID_MASK value.
 
  arch/arm/mach-davinci/board-dm646x-evm.c|  125
+++
  arch/arm/mach-davinci/dm646x.c  |   62 +
  arch/arm/mach-davinci/include/mach/dm646x.h |   24 +
  3 files changed, 211 insertions(+), 0 deletions(-)
 
 diff --git a/arch/arm/mach-davinci/board-dm646x-evm.c
b/arch/arm/mach-davinci/board-dm646x-evm.c
 index b1bf18c..8c88fd0 100644
 --- a/arch/arm/mach-davinci/board-dm646x-evm.c
 +++ b/arch/arm/mach-davinci/board-dm646x-evm.c
 @@ -63,6 +63,19 @@
  #define DM646X_EVM_PHY_MASK  (0x2)
  #define DM646X_EVM_MDIO_FREQUENCY(220) /* PHY bus frequency */
  
 +#define VIDCLKCTL_OFFSET (0x38)
 +#define VSCLKDIS_OFFSET  (0x6c)
 +
 +#define VCH2CLK_MASK (BIT_MASK(10) | BIT_MASK(9) | BIT_MASK(8))
 +#define VCH2CLK_SYSCLK8  (BIT(9))
 +#define VCH2CLK_AUXCLK   (BIT(9) | BIT(8))
 +#define VCH3CLK_MASK (BIT_MASK(14) | BIT_MASK(13) | BIT_MASK(12))
 +#define VCH3CLK_SYSCLK8  (BIT(13))
 +#define VCH3CLK_AUXCLK   (BIT(14) | BIT(13))
 +
 +#define VIDCH2CLK(BIT(10))
 +#define VIDCH3CLK(BIT(11))
 +
  static struct davinci_uart_config uart_config __initdata = {
   .enabled_uarts = (1  0),
  };
 @@ -288,6 +301,40 @@ static struct snd_platform_data dm646x_evm_snd_data[]
= {
   },
  };
  
 +static struct i2c_client *cpld_client;
 +
 +static int cpld_video_probe(struct i2c_client *client,
 + const struct i2c_device_id *id)
 +{
 + cpld_client = client;
 + return 0;
 +}
 +
 +static int __devexit cpld_video_remove(struct i2c_client *client)
 +{
 + cpld_client = NULL;
 + return 0;
 +}
 +
 +static const struct i2c_device_id cpld_video_id[] = {
 + { cpld_video, 0 },
 + { }
 +};
 +
 +static struct i2c_driver cpld_video_driver = {
 + .driver = {
 + .name   = cpld_video,
 + },
 + .probe  = cpld_video_probe,
 + .remove = cpld_video_remove,
 + .id_table   = cpld_video_id,
 +};
 +
 +static void evm_init_cpld(void)
 +{
 + i2c_add_driver(cpld_video_driver);
 +}
 +
  static struct i2c_board_info __initdata i2c_info[] =  {
   {
   I2C_BOARD_INFO(24c256, 0x50),
 @@ -300,6 +347,9 @@ static struct i2c_board_info __initdata i2c_info[] =
{
   {
   I2C_BOARD_INFO(cpld_reg0, 0x3a),
   },
 + {
 + I2C_BOARD_INFO(cpld_video, 0x3B),
 + },
  };
  
  static struct davinci_i2c_platform_data i2c_pdata = {
 @@ -307,11 +357,85 @@ static struct davinci_i2c_platform_data i2c_pdata =
{
   .bus_delay  = 0 /* usec */,
  };
  
 +static int set_vpif_clock(int mux_mode, int hd)
 +{
 + int val = 0;
 + int err = 0;
 + unsigned int value;
 + void __iomem *base = IO_ADDRESS(DAVINCI_SYSTEM_MODULE_BASE);
 +
 + if (!cpld_client)
 + return -ENXIO;
 +
 + /* disable the clock */
 + value = __raw_readl(base + VSCLKDIS_OFFSET);
 + value |= (VIDCH3CLK | VIDCH2CLK);
 + __raw_writel(value, base + VSCLKDIS_OFFSET);
 +
 + val = i2c_smbus_read_byte(cpld_client);
 + if (val  0)
 + return val;
 +
 + if (mux_mode == 1)
 + val = ~0x40;
 + else
 + val |= 0x40;
 +
 + err = i2c_smbus_write_byte(cpld_client, val);
 + if (err)
 + return err;
 +
 + value = __raw_readl(base + VIDCLKCTL_OFFSET);
 + value = ~(VCH2CLK_MASK);
 + value = ~(VCH3CLK_MASK);
 +
 + if (hd = 1)
 + value |= (VCH2CLK_SYSCLK8 | VCH3CLK_SYSCLK8);
 + else
 + value |= (VCH2CLK_AUXCLK | VCH3CLK_AUXCLK);
 +
 + __raw_writel(value, base + VIDCLKCTL_OFFSET);
 +
 + /* enable the clock */
 + value = __raw_readl(base + VSCLKDIS_OFFSET);
 + value = ~(VIDCH3CLK | VIDCH2CLK);
 + __raw_writel(value, base + VSCLKDIS_OFFSET);
 +
 + return 0;
 +}
 +
 +static const struct vpif_subdev_info dm646x_vpif_subdev[] = {
 + {
 + .addr   = 0x2A,
 + .name   = adv7343,
 + },
 + {
 + .addr   = 0x2C

[PATCH] ASoC: tlv320aic3x: Enable PLL when not bypassed

2009-07-22 Thread Chaithrika U S
PLL was not being enabled when it was not bypassed. This patch
enables the PLL when it is used. Additionally, it disables the PLL
when it is bypassed.

Without this patch, the audio on TI DM646x EVM and DM355 EVM
does not work properly. The bit clocks and the frame sync signals
from the codec are not correct and hence the playback/record are faster
than usual for most sample rates. The reason for this was that the PLL
was not enabled when it was not bypassed.

Tested on DM6467 EVM, playback tested on DM355 EVM.

Signed-off-by: Chaithrika U S chaithr...@ti.com
---
Applies to master branch of ALSA GIT tree at
http://git.kernel.org/?p=linux/kernel/git/tiwai/sound-2.6.git;a=summary

 sound/soc/codecs/tlv320aic3x.c |   11 ++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
index ab099f4..cb0d1bf 100644
--- a/sound/soc/codecs/tlv320aic3x.c
+++ b/sound/soc/codecs/tlv320aic3x.c
@@ -767,6 +767,7 @@ static int aic3x_hw_params(struct snd_pcm_substream 
*substream,
int codec_clk = 0, bypass_pll = 0, fsref, last_clk = 0;
u8 data, r, p, pll_q, pll_p = 1, pll_r = 1, pll_j = 1;
u16 pll_d = 1;
+   u8 reg;
 
/* select data word length */
data =
@@ -801,8 +802,16 @@ static int aic3x_hw_params(struct snd_pcm_substream 
*substream,
pll_q = 0xf;
aic3x_write(codec, AIC3X_PLL_PROGA_REG, pll_q  PLLQ_SHIFT);
aic3x_write(codec, AIC3X_GPIOB_REG, CODEC_CLKIN_CLKDIV);
-   } else
+   /* disable PLL if it is bypassed */
+   reg = aic3x_read_reg_cache(codec, AIC3X_PLL_PROGA_REG);
+   aic3x_write(codec, AIC3X_PLL_PROGA_REG, reg  ~PLL_ENABLE);
+
+   } else {
aic3x_write(codec, AIC3X_GPIOB_REG, CODEC_CLKIN_PLLDIV);
+   /* enable PLL when it is used */
+   reg = aic3x_read_reg_cache(codec, AIC3X_PLL_PROGA_REG);
+   aic3x_write(codec, AIC3X_PLL_PROGA_REG, reg | PLL_ENABLE);
+   }
 
/* Route Left DAC to left channel input and
 * right DAC to right channel input */
-- 
1.5.6

___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


RE: [PATCH] ASoC: tlv320aic3x: Enable PLL when not bypassed

2009-07-22 Thread chaithrika
On Wed, Jul 22, 2009 at 18:12:14, Mark Brown wrote:
 On Wed, Jul 22, 2009 at 07:45:04AM -0400, Chaithrika U S wrote:
  PLL was not being enabled when it was not bypassed. This patch
  enables the PLL when it is used. Additionally, it disables the PLL
  when it is bypassed.
  
  Without this patch, the audio on TI DM646x EVM and DM355 EVM
  does not work properly. The bit clocks and the frame sync signals
  from the codec are not correct and hence the playback/record are faster
  than usual for most sample rates. The reason for this was that the PLL
  was not enabled when it was not bypassed.
 
 Looks reasonable though I've no knowledge of the CODEC.  Sounds like
 this is needed in 2.6.31?
 

Yes, it is needed in 2.6.31.

Regards, 
Chaithrika


___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


  1   2   3   >