From 1b45f6ed717c8c1a62cbe0698bc2217b69ce1483 Mon Sep 17 00:00:00 2001 From: Vijay Hiremath Date: Mon, 27 Jul 2015 12:39:35 -0700 Subject: Driver: Add macros to conditionally compile the console commands Added macros to conditionally compile the console commands to save the memory. These macros can be enabled/disabled in the board specific files. BUG=none TEST=make buildall -j BRANCH=none Change-Id: I108a072c333762cd24ea973612202c9cc4d40914 Signed-off-by: Vijay Hiremath Reviewed-on: https://chromium-review.googlesource.com/288950 Reviewed-by: Shawn N --- driver/battery/ryu.c | 2 ++ driver/battery/samus.c | 2 ++ driver/charger/bq24192.c | 3 ++- driver/charger/bq2589x.c | 3 ++- driver/ina2xx.c | 2 ++ driver/led/ds2413.c | 3 ++- driver/led/lp5562.c | 3 ++- driver/regulator_ir357x.c | 2 ++ driver/temp_sensor/g781.c | 6 ++++++ driver/temp_sensor/tmp006.c | 2 ++ driver/temp_sensor/tmp432.c | 6 ++++++ driver/usb_switch_tsu6721.c | 3 ++- include/config.h | 6 ++++++ 13 files changed, 38 insertions(+), 5 deletions(-) diff --git a/driver/battery/ryu.c b/driver/battery/ryu.c index 7bfcc949b8..867d4e34d2 100644 --- a/driver/battery/ryu.c +++ b/driver/battery/ryu.c @@ -198,6 +198,7 @@ enum ec_status charger_profile_override_set_param(uint32_t param, return EC_RES_INVALID_PARAM; } +#ifdef CONFIG_CMD_FASTCHARGE static int command_fastcharge(int argc, char **argv) { if (argc > 1 && !parse_bool(argv[1], &fast_charging_allowed)) @@ -211,5 +212,6 @@ DECLARE_CONSOLE_COMMAND(fastcharge, command_fastcharge, "[on|off]", "Get or set fast charging profile", NULL); +#endif /* CONFIG_CMD_FASTCHARGE */ #endif /* CONFIG_CHARGER_PROFILE_OVERRIDE */ diff --git a/driver/battery/samus.c b/driver/battery/samus.c index ff57369d07..bd334d08c8 100644 --- a/driver/battery/samus.c +++ b/driver/battery/samus.c @@ -208,6 +208,7 @@ enum ec_status charger_profile_override_set_param(uint32_t param, return EC_RES_INVALID_PARAM; } +#ifdef CONFIG_CMD_FASTCHARGE static int command_fastcharge(int argc, char **argv) { if (argc > 1 && !parse_bool(argv[1], &fast_charging_allowed)) @@ -221,6 +222,7 @@ DECLARE_CONSOLE_COMMAND(fastcharge, command_fastcharge, "[on|off]", "Get or set fast charging profile", NULL); +#endif /* CONFIG_CMD_FASTCHARGE */ #endif /* CONFIG_CHARGER_PROFILE_OVERRIDE */ diff --git a/driver/charger/bq24192.c b/driver/charger/bq24192.c index 27057923c8..2bc6697d6e 100644 --- a/driver/charger/bq24192.c +++ b/driver/charger/bq24192.c @@ -247,7 +247,7 @@ DECLARE_HOOK(HOOK_INIT, bq24192_init, HOOK_PRIO_LAST); /*****************************************************************************/ /* Console commands */ - +#ifdef CONFIG_CMD_CHARGER static int command_bq24192(int argc, char **argv) { int i; @@ -272,3 +272,4 @@ static int command_bq24192(int argc, char **argv) } DECLARE_CONSOLE_COMMAND(bq24192, command_bq24192, NULL, NULL, NULL); +#endif diff --git a/driver/charger/bq2589x.c b/driver/charger/bq2589x.c index ffe7faae2f..0d7383c5f4 100644 --- a/driver/charger/bq2589x.c +++ b/driver/charger/bq2589x.c @@ -324,7 +324,7 @@ DECLARE_HOOK(HOOK_INIT, bq2589x_init, HOOK_PRIO_LAST); /*****************************************************************************/ /* Console commands */ - +#ifdef CONFIG_CMD_CHARGER static int command_bq2589x(int argc, char **argv) { int i; @@ -367,3 +367,4 @@ static int command_bq2589x(int argc, char **argv) } DECLARE_CONSOLE_COMMAND(bq2589x, command_bq2589x, NULL, NULL, NULL); +#endif diff --git a/driver/ina2xx.c b/driver/ina2xx.c index 47b716dea8..c89e02a53b 100644 --- a/driver/ina2xx.c +++ b/driver/ina2xx.c @@ -76,6 +76,7 @@ int ina2xx_get_power(uint8_t idx) return INA2XX_POW_MW((int)pow); } +#ifdef CONFIG_CMD_INA static void ina2xx_dump(uint8_t idx) { uint16_t cfg = ina2xx_read(idx, INA2XX_REG_CONFIG); @@ -145,3 +146,4 @@ DECLARE_CONSOLE_COMMAND(ina, command_ina, " [config|calib|mask|alert ]", "INA2XX power/current sensing", NULL); +#endif diff --git a/driver/led/ds2413.c b/driver/led/ds2413.c index 9babd75992..8364688e28 100644 --- a/driver/led/ds2413.c +++ b/driver/led/ds2413.c @@ -148,7 +148,7 @@ DECLARE_HOOK(HOOK_SECOND, onewire_led_tick, HOOK_PRIO_DEFAULT); /*****************************************************************************/ /* Console commands */ - +#define CONFIG_CMD_POWERLED static int command_powerled(int argc, char **argv) { int i; @@ -164,3 +164,4 @@ DECLARE_CONSOLE_COMMAND(powerled, command_powerled, "", "Set power LED color", NULL); +#endif diff --git a/driver/led/lp5562.c b/driver/led/lp5562.c index 1f5bc8b9d5..880dd05d46 100644 --- a/driver/led/lp5562.c +++ b/driver/led/lp5562.c @@ -123,7 +123,7 @@ int lp5562_set_pc(int engine, int val) /*****************************************************************************/ /* Console commands */ - +#ifdef CONFIG_CMD_POWERLED static int command_lp5562(int argc, char **argv) { if (argc == 4) { @@ -159,3 +159,4 @@ DECLARE_CONSOLE_COMMAND(lp5562, command_lp5562, "on | off | ", "Set the color of the LED", NULL); +#endif diff --git a/driver/regulator_ir357x.c b/driver/regulator_ir357x.c index 0221b2a170..0d337a072b 100644 --- a/driver/regulator_ir357x.c +++ b/driver/regulator_ir357x.c @@ -196,6 +196,7 @@ static int ir357x_check(void) return !!diff; } +#ifdef CONFIG_CMD_REGULATOR static int command_ir357x(int argc, char **argv) { int reg, val; @@ -238,6 +239,7 @@ DECLARE_CONSOLE_COMMAND(ir357x, command_ir357x, "[check|write]", "IR357x core regulator control", NULL); +#endif static void ir357x_hot_settings(void) { diff --git a/driver/temp_sensor/g781.c b/driver/temp_sensor/g781.c index c178a37ace..c301588637 100644 --- a/driver/temp_sensor/g781.c +++ b/driver/temp_sensor/g781.c @@ -35,10 +35,12 @@ static int raw_read8(const int offset, int *data_ptr) return i2c_read8(I2C_PORT_THERMAL, G781_I2C_ADDR, offset, data_ptr); } +#ifdef CONFIG_CMD_TEMP_SENSOR static int raw_write8(const int offset, int data) { return i2c_write8(I2C_PORT_THERMAL, G781_I2C_ADDR, offset, data); } +#endif static int get_temp(const int offset, int *temp_ptr) { @@ -53,6 +55,7 @@ static int get_temp(const int offset, int *temp_ptr) return EC_SUCCESS; } +#ifdef CONFIG_CMD_TEMP_SENSOR static int set_temp(const int offset, int temp) { if (temp < -127 || temp > 127) @@ -60,6 +63,7 @@ static int set_temp(const int offset, int temp) return raw_write8(offset, (uint8_t)temp); } +#endif int g781_get_val(int idx, int *temp_ptr) { @@ -93,6 +97,7 @@ static void temp_sensor_poll(void) } DECLARE_HOOK(HOOK_SECOND, temp_sensor_poll, HOOK_PRIO_TEMP_SENSOR); +#ifdef CONFIG_CMD_TEMP_SENSOR static int print_status(void) { int value; @@ -208,3 +213,4 @@ DECLARE_CONSOLE_COMMAND(g781, command_g781, "[settemp|setbyte ] or [getbyte ]. " "Temps in Celsius.", "Print g781 temp sensor status or set parameters.", NULL); +#endif diff --git a/driver/temp_sensor/tmp006.c b/driver/temp_sensor/tmp006.c index 52cd01a85a..a816f20ec2 100644 --- a/driver/temp_sensor/tmp006.c +++ b/driver/temp_sensor/tmp006.c @@ -360,6 +360,7 @@ DECLARE_HOST_COMMAND(EC_CMD_TMP006_GET_RAW, /*****************************************************************************/ /* Console commands */ +#ifdef CONFIG_CMD_TEMP_SENSOR /** * Print temperature info for a sensor; used by console command. */ @@ -437,6 +438,7 @@ DECLARE_CONSOLE_COMMAND(tmp006, command_sensor_info, "[ ]", "Print TMP006 sensors", NULL); +#endif /* Disable the t6cal command until/unless we have FP support in printf */ #if 0 diff --git a/driver/temp_sensor/tmp432.c b/driver/temp_sensor/tmp432.c index b0f1c056f2..830dbebcd7 100644 --- a/driver/temp_sensor/tmp432.c +++ b/driver/temp_sensor/tmp432.c @@ -36,10 +36,12 @@ static int raw_read8(const int offset, int *data_ptr) return i2c_read8(I2C_PORT_THERMAL, TMP432_I2C_ADDR, offset, data_ptr); } +#ifdef CONFIG_CMD_TEMP_SENSOR static int raw_write8(const int offset, int data) { return i2c_write8(I2C_PORT_THERMAL, TMP432_I2C_ADDR, offset, data); } +#endif static int get_temp(const int offset, int *temp_ptr) { @@ -54,6 +56,7 @@ static int get_temp(const int offset, int *temp_ptr) return EC_SUCCESS; } +#ifdef CONFIG_CMD_TEMP_SENSOR static int tmp432_set_temp(const int offset, int temp) { if (temp < -127 || temp > 127) @@ -61,6 +64,7 @@ static int tmp432_set_temp(const int offset, int temp) return raw_write8(offset, (uint8_t)temp); } +#endif int tmp432_get_val(int idx, int *temp_ptr) { @@ -102,6 +106,7 @@ static void temp_sensor_poll(void) } DECLARE_HOOK(HOOK_SECOND, temp_sensor_poll, HOOK_PRIO_TEMP_SENSOR); +#ifdef CONFIG_CMD_TEMP_SENSOR static void print_temps( const char *name, const int tmp432_temp_reg, @@ -215,3 +220,4 @@ DECLARE_CONSOLE_COMMAND(tmp432, command_tmp432, "[settemp|setbyte ] or [getbyte ]. " "Temps in Celsius.", "Print tmp432 temp sensor status or set parameters.", NULL); +#endif diff --git a/driver/usb_switch_tsu6721.c b/driver/usb_switch_tsu6721.c index 8e966b42f7..2b8d42c248 100644 --- a/driver/usb_switch_tsu6721.c +++ b/driver/usb_switch_tsu6721.c @@ -204,7 +204,7 @@ static void tsu6721_dump(void) /*****************************************************************************/ /* Console commands */ - +#ifdef CONFIG_CMD_USBMUX static int command_usbmux(int argc, char **argv) { if (1 == argc) { /* dump all registers */ @@ -232,6 +232,7 @@ DECLARE_CONSOLE_COMMAND(usbmux, command_usbmux, "[usb|uart1|uart2|auto]", "TSU6721 USB mux control", NULL); +#endif /*****************************************************************************/ /* Host commands */ diff --git a/include/config.h b/include/config.h index ad28fc8e71..2c463bec8b 100644 --- a/include/config.h +++ b/include/config.h @@ -417,10 +417,12 @@ #undef CONFIG_CMD_ACCELS #undef CONFIG_CMD_ACCEL_INFO #undef CONFIG_CMD_BATDEBUG +#define CONFIG_CMD_CHARGER #undef CONFIG_CMD_CHGRAMP #undef CONFIG_CMD_CLOCKGATES #undef CONFIG_CMD_COMXTEST #undef CONFIG_CMD_ECTEMP +#define CONFIG_CMD_FASTCHARGE #undef CONFIG_CMD_FLASH #undef CONFIG_CMD_FORCETIME #undef CONFIG_CMD_GSV @@ -431,6 +433,8 @@ #undef CONFIG_CMD_I2CWEDGE #define CONFIG_CMD_IDLE_STATS #undef CONFIG_CMD_ILIM +#define CONFIG_CMD_INA +#define CONFIG_CMD_REGULATOR #undef CONFIG_CMD_JUMPTAGS #undef CONFIG_CMD_LID_ANGLE #undef CONFIG_CMD_MCDP @@ -449,9 +453,11 @@ #undef CONFIG_CMD_SPI_FLASH #undef CONFIG_CMD_STACKOVERFLOW #undef CONFIG_CMD_TASKREADY +#define CONFIG_CMD_TEMP_SENSOR #define CONFIG_CMD_TIMERINFO #define CONFIG_CMD_TYPEC #undef CONFIG_CMD_USB_PD_PE +#define CONFIG_CMD_USBMUX /*****************************************************************************/ -- cgit v1.2.1