Commit 20224965 authored by Jarkko Nikula's avatar Jarkko Nikula Committed by Tony Lindgren

N800: Update board-specific audio support

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