From 289440605aeda05b0722c64f8798906dcd0af41a Mon Sep 17 00:00:00 2001 From: Amaury Pouly Date: Sat, 28 Jan 2012 00:43:04 +0100 Subject: 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 --- firmware/target/arm/imx233/power-imx233.c | 5 ++++ firmware/target/arm/imx233/power-imx233.h | 34 ++++++++++++++++++++++ .../arm/imx233/sansa-fuzeplus/audio-fuzeplus.c | 20 ++++++++++++- .../arm/imx233/sansa-fuzeplus/button-fuzeplus.c | 1 + .../arm/imx233/sansa-fuzeplus/power-fuzeplus.c | 2 ++ firmware/target/arm/imx233/system-target.h | 4 +-- firmware/target/arm/imx233/usb-imx233.c | 2 +- 7 files changed, 63 insertions(+), 5 deletions(-) (limited to 'firmware/target/arm') diff --git a/firmware/target/arm/imx233/power-imx233.c b/firmware/target/arm/imx233/power-imx233.c index 1d025675c7..479cba4430 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 368ca719da..3a2452ce19 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 1aac9e43e0..abdcda90cb 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 e349459d6e..b61ce68df0 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 bf06abe311..1b72a4b73c 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 6a5cecaf87..a4ab64e562 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 a89a2611ba..904f84b948 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) { -- cgit v1.2.3