summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2012-01-28 00:43:04 +0100
committerAmaury Pouly <amaury.pouly@gmail.com>2012-02-01 15:02:22 +0100
commit289440605aeda05b0722c64f8798906dcd0af41a (patch)
tree39cb9c309c1134e7c10114b5effdd2a1de22b4e6
parentc18a4e631690250024031be1b306e9003b2300ad (diff)
downloadrockbox-289440605aeda05b0722c64f8798906dcd0af41a.zip
rockbox-289440605aeda05b0722c64f8798906dcd0af41a.tar.gz
rockbox-289440605aeda05b0722c64f8798906dcd0af41a.tar.bz2
rockbox-289440605aeda05b0722c64f8798906dcd0af41a.tar.xz
imx233/fuze+: set a few recommended power bits by Freescale, remove some uneeded headers, implement audio path selection for playback and radio
Change-Id: If926ead9b776504a58eb102fcc0e9acadf4f7379
-rw-r--r--firmware/target/arm/imx233/power-imx233.c5
-rw-r--r--firmware/target/arm/imx233/power-imx233.h34
-rw-r--r--firmware/target/arm/imx233/sansa-fuzeplus/audio-fuzeplus.c20
-rw-r--r--firmware/target/arm/imx233/sansa-fuzeplus/button-fuzeplus.c1
-rw-r--r--firmware/target/arm/imx233/sansa-fuzeplus/power-fuzeplus.c2
-rw-r--r--firmware/target/arm/imx233/system-target.h4
-rw-r--r--firmware/target/arm/imx233/usb-imx233.c2
7 files changed, 63 insertions, 5 deletions
diff --git a/firmware/target/arm/imx233/power-imx233.c b/firmware/target/arm/imx233/power-imx233.c
index 1d02567..479cba4 100644
--- a/firmware/target/arm/imx233/power-imx233.c
+++ b/firmware/target/arm/imx233/power-imx233.c
@@ -25,6 +25,7 @@
#include "string.h"
#include "usb.h"
#include "system-target.h"
+#include "power-imx233.h"
struct current_step_bit_t
{
@@ -99,6 +100,10 @@ void power_init(void)
__FIELD_SET(HW_POWER_VDDDCTRL, LINREG_OFFSET, 2);
__FIELD_SET(HW_POWER_VDDACTRL, LINREG_OFFSET, 2);
__FIELD_SET(HW_POWER_VDDIOCTRL, LINREG_OFFSET, 2);
+ /* enable a few bits controlling the DC-DC as recommended by Freescale */
+ __REG_SET(HW_POWER_LOOPCTRL) = HW_POWER_LOOPCTRL__TOGGLE_DIF |
+ HW_POWER_LOOPCTRL__EN_CM_HYST;
+ __FIELD_SET(HW_POWER_LOOPCTRL, EN_RCSCALE, HW_POWER_LOOPCTRL__EN_RCSCALE__2X);
}
void power_off(void)
diff --git a/firmware/target/arm/imx233/power-imx233.h b/firmware/target/arm/imx233/power-imx233.h
index 368ca71..3a2452c 100644
--- a/firmware/target/arm/imx233/power-imx233.h
+++ b/firmware/target/arm/imx233/power-imx233.h
@@ -52,6 +52,8 @@
#define HW_POWER_5VCTRL__PWD_CHARGE_4P2 (1 << 20)
#define HW_POWER_MINPWR (*(volatile uint32_t *)(HW_POWER_BASE + 0x20))
+#define HW_POWER_MINPWR__HALF_FETS (1 << 5)
+#define HW_POWER_MINPWR__DOUBLE_FETS (1 << 6)
#define HW_POWER_CHARGE (*(volatile uint32_t *)(HW_POWER_BASE + 0x30))
#define HW_POWER_CHARGE__BATTCHRG_I_BP 0
@@ -129,6 +131,27 @@
#define HW_POWER_MISC__FREQSEL__21p6MHz 6
#define HW_POWER_MISC__FREQSEL__17p28MHz 7
+#define HW_POWER_LOOPCTRL (*(volatile uint32_t *)(HW_POWER_BASE + 0xb0))
+#define HW_POWER_LOOPCTRL__DC_C_BP 0
+#define HW_POWER_LOOPCTRL__DC_C_BM 0x3
+#define HW_POWER_LOOPCTRL__DC_R_BP 4
+#define HW_POWER_LOOPCTRL__DC_R_BM 0xf0
+#define HW_POWER_LOOPCTRL__DC_FF_BP 8
+#define HW_POWER_LOOPCTRL__DC_FF_BM (0x7 << 8)
+#define HW_POWER_LOOPCTRL__EN_RCSCALE_BP 12
+#define HW_POWER_LOOPCTRL__EN_RCSCALE_BM (0x3 << 12)
+#define HW_POWER_LOOPCTRL__EN_RCSCALE__DISABLED 0
+#define HW_POWER_LOOPCTRL__EN_RCSCALE__2X 1
+#define HW_POWER_LOOPCTRL__EN_RCSCALE__4X 2
+#define HW_POWER_LOOPCTRL__EN_RCSCALE__8X 3
+#define HW_POWER_LOOPCTRL__RCSCALE_THRESH (1 << 14)
+#define HW_POWER_LOOPCTRL__DF_HYST_THRESH (1 << 15)
+#define HW_POWER_LOOPCTRL__CM_HYST_THRESH (1 << 16)
+#define HW_POWER_LOOPCTRL__EN_DF_HYST (1 << 17)
+#define HW_POWER_LOOPCTRL__EN_CM_HYST (1 << 18)
+#define HW_POWER_LOOPCTRL__HYST_SIGN (1 << 19)
+#define HW_POWER_LOOPCTRL__TOGGLE_DIF (1 << 20)
+
#define HW_POWER_STS (*(volatile uint32_t *)(HW_POWER_BASE + 0xc0))
#define HW_POWER_STS__VBUSVALID (1 << 1)
#define HW_POWER_STS__CHRGSTS (1 << 11)
@@ -148,6 +171,17 @@ void imx233_power_set_charge_current(unsigned current); /* in mA */
void imx233_power_set_stop_current(unsigned current); /* in mA */
void imx233_power_enable_batadj(bool enable);
+static inline void imx233_power_set_dcdc_freq(bool pll, unsigned freq)
+{
+ HW_POWER_MISC &= ~(HW_POWER_MISC__SEL_PLLCLK | HW_POWER_MISC__FREQSEL_BM);
+ /* WARNING: HW_POWER_MISC does have a SET/CLR variant ! */
+ if(pll)
+ {
+ HW_POWER_MISC |= freq << HW_POWER_MISC__FREQSEL_BP;
+ HW_POWER_MISC |= HW_POWER_MISC__SEL_PLLCLK;
+ }
+}
+
struct imx233_power_info_t
{
int vddd; /* in mV */
diff --git a/firmware/target/arm/imx233/sansa-fuzeplus/audio-fuzeplus.c b/firmware/target/arm/imx233/sansa-fuzeplus/audio-fuzeplus.c
index 1aac9e4..abdcda9 100644
--- a/firmware/target/arm/imx233/sansa-fuzeplus/audio-fuzeplus.c
+++ b/firmware/target/arm/imx233/sansa-fuzeplus/audio-fuzeplus.c
@@ -25,13 +25,31 @@
#include "audioout-imx233.h"
#include "audioin-imx233.h"
+static int input_source = AUDIO_SRC_PLAYBACK;
+static unsigned input_flags = 0;
+static int output_source = AUDIO_SRC_PLAYBACK;
+
+static void select_audio_path(void)
+{
+ if(input_source == AUDIO_SRC_PLAYBACK)
+ imx233_audiout_select_hp_input(false);
+ else
+ imx233_audiout_select_hp_input(true);
+}
+
void audio_input_mux(int source, unsigned flags)
{
(void) source;
(void) flags;
+ input_source = source;
+ input_flags = flags;
+ select_audio_path();
}
-
+
void audio_set_output_source(int source)
{
(void) source;
+ output_source = source;
+ select_audio_path();
}
+
diff --git a/firmware/target/arm/imx233/sansa-fuzeplus/button-fuzeplus.c b/firmware/target/arm/imx233/sansa-fuzeplus/button-fuzeplus.c
index e349459..b61ce68 100644
--- a/firmware/target/arm/imx233/sansa-fuzeplus/button-fuzeplus.c
+++ b/firmware/target/arm/imx233/sansa-fuzeplus/button-fuzeplus.c
@@ -27,6 +27,7 @@
#include "lcd.h"
#include "string.h"
#include "usb.h"
+#include "power-imx233.h"
#ifndef BOOTLOADER
diff --git a/firmware/target/arm/imx233/sansa-fuzeplus/power-fuzeplus.c b/firmware/target/arm/imx233/sansa-fuzeplus/power-fuzeplus.c
index bf06abe..1b72a4b 100644
--- a/firmware/target/arm/imx233/sansa-fuzeplus/power-fuzeplus.c
+++ b/firmware/target/arm/imx233/sansa-fuzeplus/power-fuzeplus.c
@@ -24,6 +24,7 @@
#include "tuner.h"
#include "fmradio_i2c.h"
#include "pinctrl-imx233.h"
+#include "power-imx233.h"
static bool tuner_enable = false;
@@ -37,6 +38,7 @@ bool tuner_power(bool enable)
imx233_enable_gpio_output(0, 29, enable);
imx233_set_gpio_output(0, 29, enable);
tuner_enable = enable;
+ //imx233_power_set_dcdc_freq(enable, HW_POWER_MISC__FREQSEL__24MHz);
}
return tuner_enable;
}
diff --git a/firmware/target/arm/imx233/system-target.h b/firmware/target/arm/imx233/system-target.h
index 6a5ceca..a4ab64e 100644
--- a/firmware/target/arm/imx233/system-target.h
+++ b/firmware/target/arm/imx233/system-target.h
@@ -24,10 +24,8 @@
#include "system-arm.h"
#include "mmu-arm.h"
#include "panic.h"
-
-#include "clock-target.h" /* CPUFREQ_* are defined here */
#include "clkctrl-imx233.h"
-#include "power-imx233.h"
+#include "clock-target.h" /* CPUFREQ_* are defined here */
/* Digital control */
#define HW_DIGCTL_BASE 0x8001C000
diff --git a/firmware/target/arm/imx233/usb-imx233.c b/firmware/target/arm/imx233/usb-imx233.c
index a89a261..904f84b 100644
--- a/firmware/target/arm/imx233/usb-imx233.c
+++ b/firmware/target/arm/imx233/usb-imx233.c
@@ -28,7 +28,7 @@
#include "system.h"
#include "system-target.h"
#include "clkctrl-imx233.h"
-
+#include "power-imx233.h"
void usb_insert_int(void)
{