summaryrefslogtreecommitdiff
path: root/firmware/target/arm
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm')
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/audio-gigabeat-s.c56
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/fmradio-i2c-gigabeat-s.c49
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/power-imx31.c30
3 files changed, 135 insertions, 0 deletions
diff --git a/firmware/target/arm/imx31/gigabeat-s/audio-gigabeat-s.c b/firmware/target/arm/imx31/gigabeat-s/audio-gigabeat-s.c
new file mode 100644
index 0000000000..6dd90bfdb7
--- /dev/null
+++ b/firmware/target/arm/imx31/gigabeat-s/audio-gigabeat-s.c
@@ -0,0 +1,56 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2008 by Nils Wallménius
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#include "wm8978.h"
+#include "audio.h"
+
+void audio_set_output_source(int source)
+{
+ (void)source; /* TODO */
+}
+
+void audio_input_mux(int source, unsigned int flags)
+{
+ (void)flags;
+ switch (source)
+ {
+ case AUDIO_SRC_PLAYBACK:
+ /* deselect bypass patths and set volume to -15dB */
+ wmc_clear(WMC_LEFT_MIXER_CTRL, (WMC_BYPL2LMIX) | (7<<2));
+ wmc_clear(WMC_RIGHT_MIXER_CTRL, (WMC_BYPR2RMIX) | (7<<2));
+ /* disable L2/R2 inputs and boost stage */
+ wmc_clear(WMC_POWER_MANAGEMENT2,
+ WMC_INPPGAENR | WMC_INPPGAENL | WMC_BOOSTENL | WMC_BOOSTENR);
+ break;
+
+ case AUDIO_SRC_FMRADIO:
+ /* enable L2/R2 inputs and boost stage */
+ wmc_set(WMC_POWER_MANAGEMENT2,
+ WMC_INPPGAENR | WMC_INPPGAENL | WMC_BOOSTENL | WMC_BOOSTENR);
+ /* select bypass patths and set volume to 0dB */
+ wmc_set(WMC_LEFT_MIXER_CTRL, (WMC_BYPL2LMIX) | (5<<2));
+ wmc_set(WMC_RIGHT_MIXER_CTRL, (WMC_BYPR2RMIX) | (5<<2));
+ break;
+
+ default:
+ source = AUDIO_SRC_PLAYBACK;
+ }
+}
+
diff --git a/firmware/target/arm/imx31/gigabeat-s/fmradio-i2c-gigabeat-s.c b/firmware/target/arm/imx31/gigabeat-s/fmradio-i2c-gigabeat-s.c
new file mode 100644
index 0000000000..5e5c4853dd
--- /dev/null
+++ b/firmware/target/arm/imx31/gigabeat-s/fmradio-i2c-gigabeat-s.c
@@ -0,0 +1,49 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ * Physical interface of the SI4700 in the Gigabeat S
+ *
+ * Copyright (C) 2008 by Nils Wallménius
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#include "config.h"
+#include "system.h"
+#include "i2c-imx31.h"
+#include "fmradio_i2c.h"
+
+struct i2c_node si4700_i2c_node =
+{
+ .num = I2C2_NUM,
+ .ifdr = I2C_IFDR_DIV192, /* 66MHz/.4MHz = 165, closest = 192 = 343750Hz */
+ /* Just hard-code for now - scaling may require
+ * updating */
+ .addr = (0x20),
+};
+
+int fmradio_i2c_write(unsigned char address, const unsigned char* buf, int count)
+{
+ (void)address;
+ i2c_write(&si4700_i2c_node, buf, count);
+ return 0;
+}
+
+int fmradio_i2c_read(unsigned char address, unsigned char* buf, int count)
+{
+ (void)address;
+ i2c_read(&si4700_i2c_node, -1, buf, count);
+ return 0;
+}
+
diff --git a/firmware/target/arm/imx31/gigabeat-s/power-imx31.c b/firmware/target/arm/imx31/gigabeat-s/power-imx31.c
index de7f5800e6..07e6462bfb 100644
--- a/firmware/target/arm/imx31/gigabeat-s/power-imx31.c
+++ b/firmware/target/arm/imx31/gigabeat-s/power-imx31.c
@@ -26,6 +26,9 @@
#include "backlight-target.h"
#include "avic-imx31.h"
#include "mc13783.h"
+#include "i2c-imx31.h"
+
+extern struct i2c_node si4700_i2c_node;
static bool charger_detect = false;
@@ -79,6 +82,33 @@ bool ide_powered(void)
return (GPIO3_DR & (1 << 5)) != 0;
}
+#if CONFIG_TUNER
+bool tuner_power(bool status)
+{
+ if (status)
+ {
+ /* the si4700 is the only thing connected to i2c2 so
+ we can diable the i2c module when not in use */
+ i2c_enable_node(&si4700_i2c_node, true);
+ /* enable the fm chip */
+ imx31_regmod32(&GPIO1_DR, (1 << 26), (1 << 26));
+ /* enable CLK32KMCU clock */
+ mc13783_set(MC13783_POWER_CONTROL0, MC13783_CLK32KMCUEN);
+ }
+ else
+ {
+ /* the si4700 is the only thing connected to i2c2 so
+ we can diable the i2c module when not in use */
+ i2c_enable_node(&si4700_i2c_node, false);
+ /* disable the fm chip */
+ imx31_regmod32(&GPIO1_DR, 0, (1 << 26));
+ /* disable CLK32KMCU clock */
+ mc13783_clear(MC13783_POWER_CONTROL0, MC13783_CLK32KMCUEN);
+ }
+ return true;
+}
+#endif /* #if CONFIG_TUNER */
+
void power_off(void)
{
/* Cut backlight */