Re: [PATCH v4 2/2] power_supply: platform/chrome: wilco_ec: Add charging config driver

2019-04-19 Thread kbuild test robot
Hi Nick,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.1-rc5 next-20190418]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Nick-Crews/power_supply-Add-more-charge-types-and-CHARGE_CONTROL_-properties/20190420-045118
config: i386-randconfig-x017-201915 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot 


All errors (new ones prefixed by >>):

   drivers/platform/chrome/wilco_ec/core.c: In function 'wilco_ec_probe':
>> drivers/platform/chrome/wilco_ec/core.c:106:33: error: 'struct 
>> wilco_ec_device' has no member named 'kbbl_pdev'; did you mean 'rtc_pdev'?
 platform_device_unregister(ec->kbbl_pdev);
^
rtc_pdev
   drivers/platform/chrome/wilco_ec/core.c:105:1: warning: label 
'unregister_kbbl' defined but not used [-Wunused-label]
unregister_kbbl:
^~~

vim +106 drivers/platform/chrome/wilco_ec/core.c

40  
41  static int wilco_ec_probe(struct platform_device *pdev)
42  {
43  struct device *dev = >dev;
44  struct wilco_ec_device *ec;
45  int ret;
46  
47  ec = devm_kzalloc(dev, sizeof(*ec), GFP_KERNEL);
48  if (!ec)
49  return -ENOMEM;
50  
51  platform_set_drvdata(pdev, ec);
52  ec->dev = dev;
53  mutex_init(>mailbox_lock);
54  
55  /* Largest data buffer size requirement is extended data 
response */
56  ec->data_size = sizeof(struct wilco_ec_response) +
57  EC_MAILBOX_DATA_SIZE_EXTENDED;
58  ec->data_buffer = devm_kzalloc(dev, ec->data_size, GFP_KERNEL);
59  if (!ec->data_buffer)
60  return -ENOMEM;
61  
62  /* Prepare access to IO regions provided by ACPI */
63  ec->io_data = wilco_get_resource(pdev, 0);  /* Host Data */
64  ec->io_command = wilco_get_resource(pdev, 1);   /* Host Command 
*/
65  ec->io_packet = wilco_get_resource(pdev, 2);/* MEC EMI */
66  if (!ec->io_data || !ec->io_command || !ec->io_packet)
67  return -ENODEV;
68  
69  /* Initialize cros_ec register interface for communication */
70  cros_ec_lpc_mec_init(ec->io_packet->start,
71   ec->io_packet->start + 
EC_MAILBOX_DATA_SIZE);
72  
73  /*
74   * Register a child device that will be found by the debugfs 
driver.
75   * Ignore failure.
76   */
77  ec->debugfs_pdev = platform_device_register_data(dev,
78   
"wilco-ec-debugfs",
79   
PLATFORM_DEVID_AUTO,
80   NULL, 0);
81  
82  /* Register a child device that will be found by the RTC 
driver. */
83  ec->rtc_pdev = platform_device_register_data(dev, 
"rtc-wilco-ec",
84   
PLATFORM_DEVID_AUTO,
85   NULL, 0);
86  if (IS_ERR(ec->rtc_pdev)) {
87  dev_err(dev, "Failed to create RTC platform device\n");
88  ret = PTR_ERR(ec->rtc_pdev);
89  goto unregister_debugfs;
90  }
91  
92  /* Register child device to be found by charging config driver. 
*/
93  ec->charging_pdev = platform_device_register_data(dev,
94
"wilco-ec-charging",
95
PLATFORM_DEVID_AUTO,
96NULL, 0);
97  if (IS_ERR(ec->charging_pdev)) {
98  dev_err(dev, "Failed to create charging platform 
device\n");
99  ret = PTR_ERR(ec->charging_pdev);
   100  goto unregister_rtc;
   101  }
   102  
   103  return 0;
   104  
   105  unregister_kbbl:
 > 106  platform_device_unregister(ec->kbbl_pdev);
   107  unregister_rtc:
   108  platform_device_unregister(ec->rtc_pdev);
   109  unregister_debugfs:
   110  if (ec->debugfs_pdev)
   111  platform_device_unregister(ec->debugfs_pdev);
   112  cros_ec_lpc_mec_destroy();
   113  return ret;
   114  }
   115  

---
0-DAY kernel test infrastructure   

[PATCH v4 2/2] power_supply: platform/chrome: wilco_ec: Add charging config driver

2019-04-16 Thread Nick Crews
Add control of the charging algorithm used on Wilco devices.
See Documentation/ABI/testing/sysfs-class-power-wilco for the
userspace interface and other info.

v4 changes:
-Move implementation from
 drivers/platform/chrome/wilco_ec/charge_config.c to
 drivers/power/supply/wilco_charger.c
-Move drivers/platform/chrome/wilco_ec/properties.h to
 include/linux/platform_data/wilco-ec-properties.h
-Remove parentheses in switch statement in psp_val_to_charge_mode()
-Check for any negatvie return code from psp_val_to_charge_mode()
 instead of just -EINVAL so its less brittle
-Tweak comments in wilco-ec-properties.h
v3 changes:
-Add this changelog
-Fix commit message tags
v2 changes:
-Update Documentation to say KernelVersion 5.2
-Update Documentation to explain Trickle mode better.
-rename things from using *PCC* to *CHARGE*
-Split up conversions between POWER_SUPPLY_PROP_CHARGE_TYPE values
and Wilco EC codes
-Use devm_ flavor of power_supply_register(), which simplifies things
-Add extra error checking on property messages received from the EC
-Fix bug in memcpy() calls in properties.c
-Refactor fill_property_id()
-Add valid input checks to charge_type
-Properly convert charge_type when get()ting

Signed-off-by: Nick Crews 
---
 .../ABI/testing/sysfs-class-power-wilco   |  30 +++
 drivers/platform/chrome/wilco_ec/Kconfig  |   9 +
 drivers/platform/chrome/wilco_ec/Makefile |   2 +
 drivers/platform/chrome/wilco_ec/core.c   |  16 ++
 drivers/platform/chrome/wilco_ec/properties.c | 125 
 drivers/power/supply/wilco_charger.c  | 190 ++
 .../linux/platform_data/wilco-ec-properties.h |  68 +++
 include/linux/platform_data/wilco-ec.h|   2 +
 8 files changed, 442 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-class-power-wilco
 create mode 100644 drivers/platform/chrome/wilco_ec/properties.c
 create mode 100644 drivers/power/supply/wilco_charger.c
 create mode 100644 include/linux/platform_data/wilco-ec-properties.h

diff --git a/Documentation/ABI/testing/sysfs-class-power-wilco 
b/Documentation/ABI/testing/sysfs-class-power-wilco
new file mode 100644
index ..7f3b01310476
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-class-power-wilco
@@ -0,0 +1,30 @@
+What:  /sys/class/power_supply/wilco_charger/charge_type
+Date:  April 2019
+KernelVersion: 5.2
+Description:
+   What charging algorithm to use:
+
+   Standard: Fully charges battery at a standard rate.
+   Adaptive: Battery settings adaptively optimized based on
+   typical battery usage pattern.
+   Fast: Battery charges over a shorter period.
+   Trickle: Extends battery lifespan, intended for users who
+   primarily use their Chromebook while connected to AC.
+   Custom: A low and high threshold percentage is specified.
+   Charging begins when level drops below
+   charge_control_start_threshold, and ceases when
+   level is above charge_control_end_threshold.
+
+What:  
/sys/class/power_supply/wilco_charger/charge_control_start_threshold
+Date:  April 2019
+KernelVersion: 5.2
+Description:
+   Used when charge_type="Custom", as described above. Measured in
+   percentages. The valid range is [50, 95].
+
+What:  
/sys/class/power_supply/wilco_charger/charge_control_end_threshold
+Date:  April 2019
+KernelVersion: 5.2
+Description:
+   Used when charge_type="Custom", as described above. Measured in
+   percentages. The valid range is [55, 100].
diff --git a/drivers/platform/chrome/wilco_ec/Kconfig 
b/drivers/platform/chrome/wilco_ec/Kconfig
index e09e4cebe9b4..1c427830bd57 100644
--- a/drivers/platform/chrome/wilco_ec/Kconfig
+++ b/drivers/platform/chrome/wilco_ec/Kconfig
@@ -18,3 +18,12 @@ config WILCO_EC_DEBUGFS
  manipulation and allow for testing arbitrary commands.  This
  interface is intended for debug only and will not be present
  on production devices.
+
+config WILCO_EC_CHARGE_CNTL
+   tristate "Enable charging control"
+   depends on WILCO_EC
+   help
+ If you say Y here, you get support to control the charging
+ routines performed by the Wilco Embedded Controller.
+ Further information can be found in
+ Documentation/ABI/testing/sysfs-class-power-wilco)
diff --git a/drivers/platform/chrome/wilco_ec/Makefile 
b/drivers/platform/chrome/wilco_ec/Makefile
index 063e7fb4ea17..7e980f56f793 100644
--- a/drivers/platform/chrome/wilco_ec/Makefile
+++ b/drivers/platform/chrome/wilco_ec/Makefile
@@ -4,3 +4,5 @@ wilco_ec-objs   := core.o mailbox.o
 obj-$(CONFIG_WILCO_EC) += wilco_ec.o
 wilco_ec_debugfs-objs  := debugfs.o
 obj-$(CONFIG_WILCO_EC_DEBUGFS) += wilco_ec_debugfs.o