]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
N800: Update board-specific audio support
authorJarkko Nikula <jarkko.nikula@nokia.com>
Fri, 16 Mar 2007 14:04:34 +0000 (16:04 +0200)
committerTony Lindgren <tony@atomide.com>
Tue, 3 Apr 2007 17:39:06 +0000 (13:39 -0400)
Signed-off-by: Jarkko Nikula <jarkko.nikula@nokia.com>
Signed-off-by: Juha Yrjola <juha.yrjola@solidboot.com>
arch/arm/mach-omap2/board-n800-audio.c

index 8e366919c8f5b232533ce882c9e0ed1fc6dcab15..fa6ab869927a054a6553feada55c87d6b265eb51 100644 (file)
@@ -2,7 +2,7 @@
  * linux/arch/arm/mach-omap2/board-n800-audio.c
  *
  * Copyright (C) 2006 Nokia Corporation
- * Contact: Juha Yrj?l?
+ * Contact: Juha Yrjola
  *          Jarkko Nikula <jarkko.nikula@nokia.com>
  *
  * This program is free software; you can redistribute it and/or
@@ -23,7 +23,6 @@
 
 #include <linux/err.h>
 #include <linux/clk.h>
-#include <linux/delay.h>
 #include <linux/platform_device.h>
 #include <linux/spi/tsc2301.h>
 
@@ -44,47 +43,63 @@ static int enable_audio;
 static int audio_ok;
 static spinlock_t audio_lock;
 
-
 /*
- * Leaving EAC pins multiplexed to EAC functionality results
- * in about 2 mA extra current leaked. The workaround is to
- * multiplex the EAC pins to protected mode (with pull-ups enabled)
+ * Leaving EAC and sys_clkout2 pins multiplexed to those subsystems results
+ * in about 2 mA extra current leak when audios are powered down. The
+ * workaround is to multiplex them to protected mode (with pull-ups enabled)
  * whenever audio is not being used.
  */
-static int mux_disabled;
+static int eac_mux_disabled = 0;
+static int clkout2_mux_disabled = 0;
 static u32 saved_mux[2];
 
 static void n800_enable_eac_mux(void)
 {
-       if (!mux_disabled)
+       if (!eac_mux_disabled)
                return;
-       __raw_writel(saved_mux[0], IO_ADDRESS(0x480000e8));
        __raw_writel(saved_mux[1], IO_ADDRESS(0x48000124));
-       mux_disabled = 0;
+       eac_mux_disabled = 0;
 }
 
 static void n800_disable_eac_mux(void)
+{
+       if (eac_mux_disabled) {
+               WARN_ON(eac_mux_disabled);
+               return;
+       }
+       saved_mux[1] = __raw_readl(IO_ADDRESS(0x48000124));
+       __raw_writel(0x1f1f1f1f, IO_ADDRESS(0x48000124));
+       eac_mux_disabled = 1;
+}
+
+static void n800_enable_clkout2_mux(void)
+{
+       if (!clkout2_mux_disabled)
+               return;
+       __raw_writel(saved_mux[0], IO_ADDRESS(0x480000e8));
+       clkout2_mux_disabled = 0;
+}
+
+static void n800_disable_clkout2_mux(void)
 {
        u32 l;
 
-       if (mux_disabled) {
-               WARN_ON(mux_disabled);
+       if (clkout2_mux_disabled) {
+               WARN_ON(clkout2_mux_disabled);
                return;
        }
        saved_mux[0] = __raw_readl(IO_ADDRESS(0x480000e8));
-       saved_mux[1] = __raw_readl(IO_ADDRESS(0x48000124));
        l = saved_mux[0] & ~0xff;
        l |= 0x1f;
        __raw_writel(l, IO_ADDRESS(0x480000e8));
-       __raw_writel(0x1f1f1f1f, IO_ADDRESS(0x48000124));
-       mux_disabled = 1;
+       clkout2_mux_disabled = 1;
 }
 
 static int n800_eac_enable_ext_clocks(struct device *dev)
 {
        BUG_ON(tsc2301_device == NULL);
        n800_enable_eac_mux();
-       tsc2301_enable_mclk(tsc2301_device);
+       tsc2301_mixer_enable_mclk(tsc2301_device);
 
        return 0;
 }
@@ -92,8 +107,8 @@ static int n800_eac_enable_ext_clocks(struct device *dev)
 static void n800_eac_disable_ext_clocks(struct device *dev)
 {
        BUG_ON(tsc2301_device == NULL);
+       tsc2301_mixer_disable_mclk(tsc2301_device);
        n800_disable_eac_mux();
-       tsc2301_disable_mclk(tsc2301_device);
 }
 
 static int n800_audio_set_power(void *pdata, int dac, int adc)
@@ -199,20 +214,14 @@ static void n800_codec_put_clocks(struct device *dev)
 
 static int n800_codec_enable_clock(struct device *dev)
 {
-       int err;
-
-       err = clk_enable(sys_clkout2);
-       if (err)
-               return err;
-       /* TODO: 'educated' guess for audio codec's PLL startup delay */
-       mdelay(1);
-
-       return 0;
+       n800_enable_clkout2_mux();
+       return clk_enable(sys_clkout2);
 }
 
 static void n800_codec_disable_clock(struct device *dev)
 {
        clk_disable(sys_clkout2);
+       n800_disable_clkout2_mux();
 }
 
 static int n800_codec_init(struct device *dev)