Re: [PATCH v4 5/6] power: cros_usbpd-charger: Add EC-based USB PD charger driver
On Tue, Mar 8, 2016 at 10:09 AM, kbuild test robot wrote: > Hi Sameer, > > [auto build test WARNING on v4.5-rc7] > [also build test WARNING on next-20160308] > [if your patch is applied to the wrong git tree, please drop us a note to > help improving the system] > > url: > https://github.com/0day-ci/linux/commits/Tomeu-Vizoso/mfd-cros_ec-Add-MKBP-event-support/20160308-184326 > config: blackfin-allmodconfig (attached as .config) > reproduce: > wget > https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross > -O ~/bin/make.cross > chmod +x ~/bin/make.cross > # save the attached .config to linux build tree > make.cross ARCH=blackfin > > All warnings (new ones prefixed by >>): > >drivers/power/cros_usbpd-charger.c: In function 'get_ec_usb_pd_power_info': >drivers/power/cros_usbpd-charger.c:241:21: error: > 'POWER_SUPPLY_TYPE_USB_PD_DRP' undeclared (first use in this function) >drivers/power/cros_usbpd-charger.c:241:21: note: each undeclared > identifier is reported only once for each function it appears in >drivers/power/cros_usbpd-charger.c:249:20: error: > 'POWER_SUPPLY_TYPE_USB_TYPE_C' undeclared (first use in this function) >drivers/power/cros_usbpd-charger.c:261:21: error: > 'POWER_SUPPLY_TYPE_USB_PD' undeclared (first use in this function) I think this patch is being built with the wrong git tree. The new types for these three errors landed in sre's linux-power-supply here : https://git.kernel.org/cgit/linux/kernel/git/sre/linux-power-supply.git/commit/?h=next&id=6659b55dae09b2042d8cdd0f4576502c3e81957c It should be in most recent linux-nexts, but it wouldn't be in v4.5-rc7. -- Benson Leung Senior Software Engineer, Chrom* OS ble...@chromium.org
Re: [PATCH v4 5/6] power: cros_usbpd-charger: Add EC-based USB PD charger driver
Hi Sameer, [auto build test WARNING on v4.5-rc7] [also build test WARNING on next-20160308] [if your patch is applied to the wrong git tree, please drop us a note to help improving the system] url: https://github.com/0day-ci/linux/commits/Tomeu-Vizoso/mfd-cros_ec-Add-MKBP-event-support/20160308-184326 config: blackfin-allmodconfig (attached as .config) reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=blackfin All warnings (new ones prefixed by >>): drivers/power/cros_usbpd-charger.c: In function 'get_ec_usb_pd_power_info': drivers/power/cros_usbpd-charger.c:241:21: error: 'POWER_SUPPLY_TYPE_USB_PD_DRP' undeclared (first use in this function) drivers/power/cros_usbpd-charger.c:241:21: note: each undeclared identifier is reported only once for each function it appears in drivers/power/cros_usbpd-charger.c:249:20: error: 'POWER_SUPPLY_TYPE_USB_TYPE_C' undeclared (first use in this function) drivers/power/cros_usbpd-charger.c:261:21: error: 'POWER_SUPPLY_TYPE_USB_PD' undeclared (first use in this function) drivers/power/cros_usbpd-charger.c: In function 'cros_usb_pd_print_log_entry': >> drivers/power/cros_usbpd-charger.c:527:2: warning: comparison of distinct >> pointer types lacks a cast [enabled by default] vim +527 drivers/power/cros_usbpd-charger.c 511MCDP_FAMILY(minfo->family), 512MCDP_CHIPID(minfo->chipid), 513minfo->irom.major, minfo->irom.minor, 514minfo->irom.build, minfo->fw.major, 515minfo->fw.minor, minfo->fw.build); 516 break; 517 default: 518 APPEND_STRING(buf, len, 519 "Event %02x (%04x) [", r->type, r->data); 520 for (i = 0; i < PD_LOG_SIZE(r->size_port); i++) 521 APPEND_STRING(buf, len, "%02x ", r->payload[i]); 522 APPEND_STRING(buf, len, "]"); 523 break; 524 } 525 526 msecs = ktime_to_ms(tstamp); > 527 do_div(msecs, MSEC_PER_SEC); 528 pr_info("PDLOG %d/%02d/%02d %02d:%02d:%02d.%03lld P%d %s\n", 529 rt.tm_year + 1900, rt.tm_mon + 1, rt.tm_mday, 530 rt.tm_hour, rt.tm_min, rt.tm_sec, msecs, 531 PD_LOG_PORT(r->size_port), buf); 532 } 533 534 static void cros_usb_pd_log_check(struct work_struct *work) 535 { --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: Binary data
[PATCH v4 5/6] power: cros_usbpd-charger: Add EC-based USB PD charger driver
From: Sameer Nanda This driver exposes the charger functionality in the PD EC to userspace. Signed-off-by: Tomeu Vizoso Cc: Sameer Nanda Cc: Benson Leung Cc: Shawn Nematbakhsh --- Changes in v4: - Declare size parameters in ec_command as size_t Changes in v3: - Use do_div so it builds on 32bit (suggested by 0-day kbuild bot). - Remove sysfs attributes ext_current_lim and ext_voltage_lim because I don't know yet where they should be placed (and don't have HW to test them). - Remove superfluous pre-allocated buffers ec_inbuf and ec_outbuf. - Lots of misc comments from Stephen Boyd were addressed. - Unregister notification listener in .remove callback. Changes in v2: - Split out changes to cros_ec_commands.h and the helpers added to mfd/cros_ec.h from the patch that adds the charger driver, as suggested by Lee. - Actually call get_ec_num_ports. drivers/power/Kconfig | 10 + drivers/power/Makefile | 1 + drivers/power/cros_usbpd-charger.c | 780 + 3 files changed, 791 insertions(+) create mode 100644 drivers/power/cros_usbpd-charger.c diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig index 1ddd13cc0c07..26355850d91b 100644 --- a/drivers/power/Kconfig +++ b/drivers/power/Kconfig @@ -502,6 +502,16 @@ config AXP20X_POWER This driver provides support for the power supply features of AXP20x PMIC. +config CHARGER_CROS_USB_PD + tristate "Chrome OS EC based USB PD charger" + depends on MFD_CROS_EC + default y + help + Say Y here to enable Chrome OS EC based USB PD charger driver. This + driver gets various bits of information about what is connected to + USB PD ports from the EC and converts that into power_supply + properties. + endif # POWER_SUPPLY source "drivers/power/reset/Kconfig" diff --git a/drivers/power/Makefile b/drivers/power/Makefile index 0e4eab55f8d7..b83685bfae61 100644 --- a/drivers/power/Makefile +++ b/drivers/power/Makefile @@ -73,3 +73,4 @@ obj-$(CONFIG_CHARGER_TPS65217)+= tps65217_charger.o obj-$(CONFIG_POWER_RESET) += reset/ obj-$(CONFIG_AXP288_FUEL_GAUGE) += axp288_fuel_gauge.o obj-$(CONFIG_AXP288_CHARGER) += axp288_charger.o +obj-$(CONFIG_CHARGER_CROS_USB_PD) += cros_usbpd-charger.o diff --git a/drivers/power/cros_usbpd-charger.c b/drivers/power/cros_usbpd-charger.c new file mode 100644 index ..b9ca6abc8dbf --- /dev/null +++ b/drivers/power/cros_usbpd-charger.c @@ -0,0 +1,780 @@ +/* + * Power supply driver for ChromeOS EC based USB PD Charger. + * + * Copyright (c) 2014 Google, Inc + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define CROS_USB_PD_MAX_PORTS 8 +#define CROS_USB_PD_MAX_LOG_ENTRIES30 + +#define CROS_USB_PD_LOG_UPDATE_DELAY msecs_to_jiffies(6) +#define CROS_USB_PD_CACHE_UPDATE_DELAY msecs_to_jiffies(500) + +/* Buffer + macro for building PDLOG string */ +#define BUF_SIZE 80 +#define APPEND_STRING(buf, len, str, ...) ((len) += \ + snprintf((buf) + (len), max(BUF_SIZE - (len), 0), (str), ##__VA_ARGS__)) + +#define CHARGER_DIR_NAME "CROS_USB_PD_CHARGER%d" +#define CHARGER_DIR_NAME_LENGTHsizeof(CHARGER_DIR_NAME) + +#define MANUFACTURER_MODEL_LENGTH 32 + +struct port_data { + int port_number; + char name[CHARGER_DIR_NAME_LENGTH]; + char manufacturer[MANUFACTURER_MODEL_LENGTH]; + char model_name[MANUFACTURER_MODEL_LENGTH]; + struct power_supply *psy; + struct power_supply_desc psy_desc; + int psy_type; + int psy_online; + int psy_status; + int psy_current_max; + int psy_voltage_max_design; + int psy_voltage_now; + int psy_power_max; + struct charger_data *charger; + unsigned long last_update; +}; + +struct charger_data { + struct device *dev; + struct cros_ec_dev *ec_dev; + struct cros_ec_device *ec_device; + int num_charger_ports; + int num_registered_psy; + struct port_data *ports[CROS_USB_PD_MAX_PORTS]; + struct delayed_work log_work; + struct workqueue_struct *log_workqueue; + struct notifier_block notifier; + bool suspended; +}; + +static enum power_supply_property cros_usb_pd_charger_props[] = { + POWER_SUPPLY_PROP_ONLINE, + POWER_SUPPLY_PROP_STATUS, + POWER_SUPPLY_PROP_CURRENT_MAX, + POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN, + POWER_S