diff --git a/board/slippy/board.c b/board/slippy/board.c index 3bfd0ef6e3..ff37bc82f1 100644 --- a/board/slippy/board.c +++ b/board/slippy/board.c @@ -125,11 +125,13 @@ const struct adc_t adc_channels[ADC_CH_COUNT] = { {"ECTemp", LM4_ADC_SEQ0, -225, ADC_READ_MAX, 420, LM4_AIN_NONE, 0x0e /* TS0 | IE0 | END0 */, 0, 0}, - /* HEY: need different equation for Slippy */ - /* Charger current is mapped from 0~4000mA to 0~1.6V. - * And ADC maps 0~3.3V to ADC_READ_MAX. + /* IOUT == ICMNT is on PE3/AIN0 */ + /* We have 0.01-ohm resistors, and IOUT is 20X the differential + * voltage, so 1000mA ==> 200mV. + * ADC returns 0x000-0xFFF, which maps to 0.0-3.3V (as configured). + * mA = 1000 * ADC_VALUE / ADC_READ_MAX * 3300 / 200 */ - {"ChargerCurrent", LM4_ADC_SEQ1, 33 * 4000, ADC_READ_MAX * 16, 0, + {"ChargerCurrent", LM4_ADC_SEQ1, 33000, ADC_READ_MAX * 2, 0, LM4_AIN(0), 0x06 /* IE0 | END0 */, LM4_GPIO_E, (1<<3)}, }; diff --git a/chip/lm4/clock.c b/chip/lm4/clock.c index c0a5558cdb..02f955776e 100644 --- a/chip/lm4/clock.c +++ b/chip/lm4/clock.c @@ -27,7 +27,6 @@ static int freq; */ static void disable_pll(void) { -#ifdef BOARD_link /* FIXME: crosbug.com/p/19366 */ /* Switch to 16MHz internal oscillator and power down the PLL */ LM4_SYSTEM_RCC = LM4_SYSTEM_RCC_SYSDIV(0) | LM4_SYSTEM_RCC_BYPASS | @@ -35,7 +34,6 @@ static void disable_pll(void) LM4_SYSTEM_RCC_OSCSRC(1) | LM4_SYSTEM_RCC_MOSCDIS; LM4_SYSTEM_RCC2 &= ~LM4_SYSTEM_RCC2_USERCC2; -#endif freq = INTERNAL_CLOCK; } @@ -48,7 +46,6 @@ static void enable_pll(void) /* Disable the PLL so we can reconfigure it */ disable_pll(); -#ifdef BOARD_link /* FIXME: crosbug.com/p/19366 */ /* * Enable the PLL (PWRDN is no longer set) and set divider. PLL is * still bypassed, since it hasn't locked yet. @@ -66,7 +63,6 @@ static void enable_pll(void) /* Remove bypass on PLL */ LM4_SYSTEM_RCC &= ~LM4_SYSTEM_RCC_BYPASS; -#endif freq = PLL_CLOCK; } diff --git a/common/charger_bq24707a.c b/common/charger_bq24707a.c index 8c8aefccb9..35ca469ed1 100644 --- a/common/charger_bq24707a.c +++ b/common/charger_bq24707a.c @@ -180,6 +180,7 @@ int charger_post_init(void) * input current limit = ~1/2 maximum setting * charging voltage = 0 mV * charging current = 0 mA + * IOUT = 20x adapter current sense */ /* Set charger input current limit */