summaryrefslogtreecommitdiff
path: root/firmware/target/arm/imx233/lradc-imx233.h
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2012-03-17 17:39:27 +0100
committerAmaury Pouly <amaury.pouly@gmail.com>2012-03-17 17:42:49 +0100
commite5b5041583e389e6866b210683a09c97a10077d3 (patch)
tree256bc4b1f0fbccce21295afbda907988be78f3bb /firmware/target/arm/imx233/lradc-imx233.h
parent7676dae3e0f279d4b193f1c9abf8977c8f52e5d2 (diff)
imx233/fuze+: rework lradc/adc code, add external temperature sensing(battery)
Rework code to be more useful: - move battery channel init to lradc - always init lradc from system (previously from adc) - don't reserve channels for vddio, nmos or pmos - implement external temperature sensing using current source - use this for battery sensing on the Fuze+ (calibration needed) Change-Id: I5f9a24b9243db7d1e6bdb16b84bc891e61d0c318
Diffstat (limited to 'firmware/target/arm/imx233/lradc-imx233.h')
-rw-r--r--firmware/target/arm/imx233/lradc-imx233.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/firmware/target/arm/imx233/lradc-imx233.h b/firmware/target/arm/imx233/lradc-imx233.h
index d79ebe0eff..b661fa8aa4 100644
--- a/firmware/target/arm/imx233/lradc-imx233.h
+++ b/firmware/target/arm/imx233/lradc-imx233.h
@@ -43,8 +43,14 @@
#define HW_LRADC_CTRL2__TEMP_ISRC1_BM 0xf0
#define HW_LRADC_CTRL2__TEMP_ISRC0_BP 0
#define HW_LRADC_CTRL2__TEMP_ISRC0_BM 0xf
+#define HW_LRADC_CTRL2__TEMP_ISRCx_BP(x) (4 * (x))
+#define HW_LRADC_CTRL2__TEMP_ISRCx_BM(x) (0xf << (4 * (x)))
+#define HW_LRADC_CTRL2__TEMP_ISRC__0uA 0
+#define HW_LRADC_CTRL2__TEMP_ISRC__20uA 1
+#define HW_LRADC_CTRL2__TEMP_ISRC__300uA 15
#define HW_LRADC_CTRL2__TEMP_SENSOR_IENABLE0 (1 << 8)
#define HW_LRADC_CTRL2__TEMP_SENSOR_IENABLE1 (1 << 9)
+#define HW_LRADC_CTRL2__TEMP_SENSOR_IENABLEx(x) (1 << (8 + (x)))
#define HW_LRADC_CTRL2__TEMPSENSE_PWD (1 << 15)
#define HW_LRADC_CTRL2__DIVIDE_BY_TWO(x) (1 << ((x) + 24))
@@ -59,7 +65,7 @@
#define HW_LRADC_STATUS (*(volatile uint32_t *)(HW_LRADC_BASE + 0x40))
#define HW_LRADC_CHx(x) (*(volatile uint32_t *)(HW_LRADC_BASE + 0x50 + (x) * 0x10))
-#define HW_LRADC_CHx__NUM_SAMPLES_BM (0xf << 24)
+#define HW_LRADC_CHx__NUM_SAMPLES_BM (0x1f << 24)
#define HW_LRADC_CHx__NUM_SAMPLES_BP 24
#define HW_LRADC_CHx__ACCUMULATE 29
#define HW_LRADC_CHx__VALUE_BM 0x3ffff
@@ -127,8 +133,11 @@ void imx233_lradc_reserve_delay(int dchannel);
void imx233_lradc_release_delay(int dchan);
/* enable sensing and return temperature in kelvin,
- * channels must already be configured as nmos and pmos */
+ * channels needs not to be configured */
int imx233_lradc_sense_die_temperature(int nmos_chan, int pmos_chan);
+/* return *raw* external temperature, might need some transformation
+ * channel needs not to be configured */
+int imx233_lradc_sense_ext_temperature(int chan, int sensor);
void imx233_lradc_setup_battery_conversion(bool automatic, unsigned long scale_factor);
// read scaled voltage, only available after proper setup