From a95e80dd47474a25a77f0a3507053848c3fa0f36 Mon Sep 17 00:00:00 2001 From: Randall Spangler Date: Mon, 16 Sep 2013 15:19:29 -0700 Subject: [PATCH] cleanup: move board-specific battery files to board dirs The battery files contain board-specific constants and a few small methods like battery-detect and battery-cut. Most of these aren't reused across platforms. The battery files have also been cleaned up so those board-specific constants basically all that's left in them. Where a file is used by a single board only, move it to board/(boardname)/battery.c. Batteries used by more than one board (e.g. battery_link.c used by both link and bolt) are still in common/battery_*.c, since that's cleaner than duplicating the file in each board's directory. No code changes, just moving files. BUG=chrome-os-partner:18343 BRANCH=none TEST=build all boards and pass unit tests Change-Id: I946c8eb874672c77f9b77105e5b900f98fa48d0f Signed-off-by: Randall Spangler Reviewed-on: https://chromium-review.googlesource.com/169893 Reviewed-by: Vincent Palatin --- board/bolt/board.h | 1 + .../battery_falco.c => board/falco/battery.c | 0 board/falco/build.mk | 2 +- .../battery_kirby.c => board/kirby/battery.c | 0 board/kirby/build.mk | 2 +- board/link/board.h | 1 + .../battery_peppy.c => board/peppy/battery.c | 0 board/peppy/build.mk | 2 +- .../slippy/battery.c | 0 board/slippy/build.mk | 2 +- .../spring/battery.c | 0 board/spring/build.mk | 2 +- common/battery_wolf.c | 42 ------------------- common/build.mk | 12 +++--- include/config.h | 15 ++++--- 15 files changed, 22 insertions(+), 59 deletions(-) rename common/battery_falco.c => board/falco/battery.c (100%) rename common/battery_kirby.c => board/kirby/battery.c (100%) rename common/battery_peppy.c => board/peppy/battery.c (100%) rename common/battery_slippy.c => board/slippy/battery.c (100%) rename common/battery_spring.c => board/spring/battery.c (100%) delete mode 100644 common/battery_wolf.c diff --git a/board/bolt/board.h b/board/bolt/board.h index 98e8c3f42f..b5751b9a36 100644 --- a/board/bolt/board.h +++ b/board/bolt/board.h @@ -27,6 +27,7 @@ #define CONFIG_POWER_BUTTON_X86 #define CONFIG_WP_ACTIVE_HIGH +#define CONFIG_BATTERY_LINK #define CONFIG_BATTERY_SMART #define CONFIG_BACKLIGHT_X86 #define CONFIG_CHARGER diff --git a/common/battery_falco.c b/board/falco/battery.c similarity index 100% rename from common/battery_falco.c rename to board/falco/battery.c diff --git a/board/falco/build.mk b/board/falco/build.mk index 6d1006db16..479e75aef2 100644 --- a/board/falco/build.mk +++ b/board/falco/build.mk @@ -9,4 +9,4 @@ # the IC is TI Stellaris LM4 CHIP:=lm4 -board-y=board.o panel.o +board-y=board.o battery.o panel.o diff --git a/common/battery_kirby.c b/board/kirby/battery.c similarity index 100% rename from common/battery_kirby.c rename to board/kirby/battery.c diff --git a/board/kirby/build.mk b/board/kirby/build.mk index 3d89a2fca7..a02cbb0fee 100644 --- a/board/kirby/build.mk +++ b/board/kirby/build.mk @@ -10,4 +10,4 @@ CHIP:=stm32 CHIP_FAMILY:=stm32l CHIP_VARIANT:=stm32l15x -board-y=board.o +board-y=board.o battery.o diff --git a/board/link/board.h b/board/link/board.h index 668736b0b1..f2de5ddfd4 100644 --- a/board/link/board.h +++ b/board/link/board.h @@ -10,6 +10,7 @@ /* Optional features */ #define CONFIG_BACKLIGHT_X86 +#define CONFIG_BATTERY_LINK #define CONFIG_BATTERY_SMART #define CONFIG_BATTERY_VENDOR_PARAMS #define CONFIG_BOARD_VERSION diff --git a/common/battery_peppy.c b/board/peppy/battery.c similarity index 100% rename from common/battery_peppy.c rename to board/peppy/battery.c diff --git a/board/peppy/build.mk b/board/peppy/build.mk index 1843369ed4..b82aa39df6 100644 --- a/board/peppy/build.mk +++ b/board/peppy/build.mk @@ -9,4 +9,4 @@ # the IC is TI Stellaris LM4 CHIP:=lm4 -board-y=board.o +board-y=board.o battery.o diff --git a/common/battery_slippy.c b/board/slippy/battery.c similarity index 100% rename from common/battery_slippy.c rename to board/slippy/battery.c diff --git a/board/slippy/build.mk b/board/slippy/build.mk index 1843369ed4..b82aa39df6 100644 --- a/board/slippy/build.mk +++ b/board/slippy/build.mk @@ -9,4 +9,4 @@ # the IC is TI Stellaris LM4 CHIP:=lm4 -board-y=board.o +board-y=board.o battery.o diff --git a/common/battery_spring.c b/board/spring/battery.c similarity index 100% rename from common/battery_spring.c rename to board/spring/battery.c diff --git a/board/spring/build.mk b/board/spring/build.mk index 28c73da08f..6825668505 100644 --- a/board/spring/build.mk +++ b/board/spring/build.mk @@ -9,4 +9,4 @@ CHIP:=stm32 CHIP_FAMILY:=stm32f CHIP_VARIANT:=stm32f100 -board-y=board.o +board-y=board.o battery.o diff --git a/common/battery_wolf.c b/common/battery_wolf.c deleted file mode 100644 index 6ae9506aad..0000000000 --- a/common/battery_wolf.c +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Battery pack vendor provided charging profile - */ - -#include "battery_pack.h" -#include "gpio.h" - -/* FIXME: We need REAL values for all this stuff */ -const struct battery_temperature_ranges bat_temp_ranges = { - .start_charging_min_c = 0, - .start_charging_max_c = 50, - .charging_min_c = 0, - .charging_max_c = 50, - .discharging_min_c = -20, - .discharging_max_c = 60, -}; - -static const struct battery_info info = { -/* Based on 3S1P, same as peppy */ - - .voltage_max = 12600, - .voltage_normal = 11100, - .voltage_min = 9000, - - /* Pre-charge values. */ - .precharge_current = 256, /* mA */ -}; - -const struct battery_info *battery_get_info(void) -{ - return &info; -} - -/* FIXME: The smart battery should do the right thing - that's why it's - * called "smart". Do we really want to second-guess it? For now, let's not. */ -void battery_vendor_params(struct batt_params *batt) -{ -} - diff --git a/common/build.mk b/common/build.mk index a31d2c8588..3946396e73 100644 --- a/common/build.mk +++ b/common/build.mk @@ -11,19 +11,17 @@ common-y+=memory_commands.o shared_mem.o system_common.o hooks.o common-y+=gpio_common.o version.o printf.o queue.o common-y+=throttle_ap.o -common-$(BOARD_bolt)+=battery_link.o common-$(BOARD_daisy)+=extpower_snow.o -common-$(BOARD_falco)+=battery_falco.o led_falco.o -common-$(BOARD_kirby)+=battery_kirby.o led_kirby.o -common-$(BOARD_link)+=battery_link.o -common-$(BOARD_peppy)+=battery_peppy.o led_common.o led_peppy.o -common-$(BOARD_slippy)+=battery_slippy.o led_slippy.o +common-$(BOARD_falco)+=led_falco.o +common-$(BOARD_kirby)+=led_kirby.o +common-$(BOARD_peppy)+=led_common.o led_peppy.o +common-$(BOARD_slippy)+=led_slippy.o common-$(BOARD_snow)+=extpower_snow.o -common-$(BOARD_spring)+=battery_spring.o common-$(CONFIG_BACKLIGHT_X86)+=backlight_x86.o common-$(CONFIG_BATTERY_BQ20Z453)+=battery_bq20z453.o common-$(CONFIG_BATTERY_BQ27541)+=battery.o battery_bq27541.o +common-$(CONFIG_BATTERY_LINK)+=battery_link.o common-$(CONFIG_BATTERY_MOCK)+=mock_smart_battery.o mock_charger.o common-$(CONFIG_BATTERY_SMART)+=battery.o smart_battery.o common-$(CONFIG_CHARGER)+=charge_state.o charger_common.o diff --git a/include/config.h b/include/config.h index 148b5921e4..fda29dfca6 100644 --- a/include/config.h +++ b/include/config.h @@ -55,11 +55,16 @@ /*****************************************************************************/ /* Battery config */ -/* Compile support for the BQ20Z453 battery used on some of the ARM laptops */ -#undef CONFIG_BATTERY_BQ20Z453 - -/* Compile support for the BQ27541 battery */ -#undef CONFIG_BATTERY_BQ27541 +/* + * Compile battery-specific code. Choose at most one. + * + * Note that some boards have their own unique battery constants / functions. + * In this case, those are provided in board/(boardname)/battery.c, and none of + * these are defined. + */ +#undef CONFIG_BATTERY_BQ20Z453 /* BQ20Z453 battery used on some ARM laptops */ +#undef CONFIG_BATTERY_BQ27541 /* BQ27541 battery */ +#undef CONFIG_BATTERY_LINK /* Battery used on Link, Bolt, etc. */ /* Compile mock battery support; used by tests. */ #undef CONFIG_BATTERY_MOCK