Commit Graph

12 Commits

Author SHA1 Message Date
Gustavo A. R. Silva df561f6688 treewide: Use fallthrough pseudo-keyword
Replace the existing /* fall through */ comments and its variants with
the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
fall-through markings when it is the case.

[1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
2020-08-23 17:36:59 -05:00
Jon Flatley f2437e48ac
power: supply: cros-ec-usbpd-charger: Fix host events
There's a bug on ACPI platforms where host events from the ECPD ACPI
device never make their way to the cros-ec-usbpd-charger driver. This
makes it so the only time the charger driver updates its state is when
user space accesses its sysfs attributes.

Now that these events have been unified into a single notifier chain on
both ACPI and non-ACPI platforms, update the charger driver to use this
new notifier.

Reviewed-by: Benson Leung <bleung@chromium.org>
Co-Developed-by: Prashant Malani <pmalani@chromium.org>
Signed-off-by: Jon Flatley <jflat@chromium.org>
Signed-off-by: Prashant Malani <pmalani@chromium.org>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Benson Leung <bleung@chromium.org>
2020-02-10 11:01:33 -08:00
Linus Torvalds 79703e014b chrome platform changes for 5.6
* CrOS EC
 - Refactoring of some of cros_ec's headers. include/linux/mfd/cros_ec.h now
   removed, new cros_ec.h added drivers/platform/chrome which contains shared
   operations of cros_ec transport drivers.
 - Response tracing in cros_ec_proto
 
 * Wilco EC
 - Fix unregistration order.
 - Fix keyboard backlight probing on systems without keyboard backlight
 - Minor cleanup (newlines in printks, COMPILE_TEST)
 
 * Misc
 - chromeos_laptop converted to use i2c_new_scanned_device instead of
   i2c_new_probed_device
 -----BEGIN PGP SIGNATURE-----
 
 iHUEABYKAB0WIQQCtZK6p/AktxXfkOlzbaomhzOwwgUCXjij4AAKCRBzbaomhzOw
 wrFjAP0bU5PFkxprCOTY9kF/cMgHPDljEPES4FVV11eGyYr3HgD/StpuIhFGrh7+
 Fz96dDdNu1melyGjmMqSN/M9JFo+Hw4=
 =FB/I
 -----END PGP SIGNATURE-----

Merge tag 'tag-chrome-platform-for-v5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux

Pull chrome platform updates from Benson Leung:
 "CrOS EC:

   - Refactoring of some of cros_ec's headers:

     include/linux/mfd/cros_ec.h now removed, new cros_ec.h added to
     drivers/platform/chrome which contains shared operations of cros_ec
     transport drivers.

   - Response tracing in cros_ec_proto

  Wilco EC:

   - Fix unregistration order.

   - Fix keyboard backlight probing on systems without keyboard
     backlight

   - Minor cleanup (newlines in printks, COMPILE_TEST)

  Misc:

   - chromeos_laptop converted to use i2c_new_scanned_device instead of
     i2c_new_probed_device"

* tag 'tag-chrome-platform-for-v5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux:
  platform/chrome: cros_ec: Match implementation with headers
  platform/chrome: cros_ec: Drop unaligned.h include
  platform/chrome: wilco_ec: Allow wilco to be compiled in COMPILE_TEST
  platform/chrome: wilco_ec: Add newlines to printks
  platform/chrome: wilco_ec: Fix unregistration order
  cros_ec: treewide: Remove 'include/linux/mfd/cros_ec.h'
  platform/chrome: cros_ec_ishtp: Make init_lock static
  platform/chrome: chromeos_laptop: Convert to i2c_new_scanned_device
  platform/chrome: cros_ec_lpc: Use platform_get_irq_optional() for optional IRQs
  platform/chrome: cros_ec_proto: Add response tracing
  platform/chrome: cros_ec_trace: Match trace commands with EC commands
2020-02-04 07:17:41 +00:00
Enric Balletbo i Serra 11f1eabee0 cros_ec: treewide: Remove 'include/linux/mfd/cros_ec.h'
This header file now only includes the cros_ec_dev struct, however, is the
'include/linux/platform_data/cros_ec_proto.h' who contains the definition of
all the Chrome OS EC related structs. There is no reason to have a
separate include for this struct so move to the place where other
structs are defined. That way, we can remove the include itself, but also
simplify the common pattern

    #include <linux/mfd/cros_ec.h>
    #include <linux/platform_data/cros_ec_proto.h>

for a single include

    #include <linux/platform_data/cros_ec_proto.h>

The changes to remove the cros_ec.h include were generated with the
following shell script:

    git grep -l "<linux/mfd/cros_ec.h>" | xargs sed -i '/<linux\/mfd\/cros_ec.h>/d'

Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Acked-by: Sebastian Reichel <sre@kernel.org>
Acked-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2020-01-07 17:36:46 +01:00
Enric Balletbo i Serra 464aca1648 power: supply: cros_usbpd: Remove dev_err() getting the number of ports
When a device has no support to get the charger number of ports, it
doesn't have to result in a dev_err(), print saying "Could not get
charger port count" using a dev_info() would suffice. In such case,
the dev_info() message is already printed but the dev_err() is annoying,
specially, on those devices that doesn't support the command. So remove
the dev_err().

Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-12-19 01:58:44 +01:00
Enric Balletbo i Serra 840d9f131f mfd / platform: cros_ec: Reorganize platform and mfd includes
There is a bit of mess between cros-ec mfd includes and platform
includes. For example, we have a linux/mfd/cros_ec.h include that
exports the interface implemented in platform/chrome/cros_ec_proto.c. Or
we have a linux/mfd/cros_ec_commands.h file that is non related to the
multifunction device (in the sense that is not exporting any function of
the mfd device). This causes crossed includes between mfd and
platform/chrome subsystems and makes the code difficult to read, apart
from creating 'curious' situations where a platform/chrome driver includes
a linux/mfd/cros_ec.h file just to get the exported functions that are
implemented in another platform/chrome driver.

In order to have a better separation on what the cros-ec multifunction
driver does and what the cros-ec core provides move and rework the
affected includes doing:

 - Move cros_ec_commands.h to include/linux/platform_data/cros_ec_commands.h
 - Get rid of the parts that are implemented in the platform/chrome/cros_ec_proto.c
   driver from include/linux/mfd/cros_ec.h to a new file
   include/linux/platform_data/cros_ec_proto.h
 - Update all the drivers with the new includes, so
   - Drivers that only need to know about the protocol include
     - linux/platform_data/cros_ec_proto.h
     - linux/platform_data/cros_ec_commands.h
   - Drivers that need to know about the cros-ec mfd device also include
     - linux/mfd/cros_ec.h

Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Mark Brown <broonie@kernel.org>
Acked-by: Wolfram Sang <wsa@the-dreams.de>
Acked-by: Neil Armstrong <narmstrong@baylibre.com>
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Tested-by: Gwendal Grignou <gwendal@chromium.org>
Series changes: 3
- Fix dereferencing pointer to incomplete type 'struct cros_ec_dev' (lkp)
Signed-off-by: Lee Jones <lee.jones@linaro.org>
2019-09-02 11:33:42 +01:00
Enric Balletbo i Serra 2ffb500d82 power: supply: cros: allow to set input voltage and current limit
This patch allows reading and writing the input voltage and current
limit through the POWER_SUPPLY_PROP_INPUT_VOLTAGE_LIMIT and
POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT sysfs properties. This allows
userspace to see current values and to re-configure these values at
runtime based on system-level knowledge or user input.

By default there is no limit, this is reported as a -1 when reading from
userspace. Writing a value will set the current or voltage limit in uA
or uV, and writing any negative value will remove that limit.

Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2019-06-28 17:28:27 +02:00
Sebastian Reichel 782853cf9b Immutable branch for mfd and power-supply for v4.20
Immutable branch between mfd and power-supply for driver
 changes in CROS USBPD charger driver.
 
 Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAlueOg8ACgkQ2O7X88g7
 +powaA//eiDVCADkBlnhzzfks3KEpkoGCS4Hct3uIcKri7Nuua9KhHrkun6rUzmO
 +CTx78sQl9Ctswr78/40TaXsgc+EfbGIMBB8Prrux2P8cy+QbVWD3dRfZKyc/oQp
 m9MrJqa4jmvSLnKmujXP+bIlWVBc1OTDo+O1OVH1J1dBnGmR/LrvVBbVHnx7H5tj
 LAhNZ40GxDDNXd94uZ1csxlulSV3/ezWto8Lp8lyh4fuYLnpGBl/k/x15HoaBcQ1
 TPSMg7I8OPrQkZaJQ3d2nMmpDmyuNgO4KTA7rLXc8MlwRGl4gx9zSZVOTstMlhE/
 oVR5DSRnxIMQO7JUSRLtmYOWYQmVWRDZVs3+O9UQv2WPecsz9aCvMbkxYHeJIGkD
 9jPTd/OT7uBmV+xketpTLPuIFcS72HDrrPhZAstkj+klt/aSoQDp9lecjcgU1ArE
 wAppp0YZ2Fj+m73XzDIUe3EqUMOmIBPQfUJd60ZAHOJot9p/4v40rnwgg8VA+WmU
 JhawDNa6Wq4cYYOpFPgPXWmsXB2mgPKJV+X6tjDDpwEtn+QF5c9OFWakgX06WN9h
 gZss2Qbn75dFDJUQyRzM8F5RkjVh7NrU1dMOgBMEXN5Hqb1//YJ5q4hiL280uFkD
 n9B07QL7oSvaV3qcXTkFFDqJG44nH91J6AMxUAqDG5L9Y63l5Hg=
 =ya3t
 -----END PGP SIGNATURE-----

Merge tag 'psy-mfd-cros-immutable-for-v4.20-signed' into psy-next

Immutable branch for mfd and power-supply for v4.20

Immutable branch between mfd and power-supply for driver
changes in CROS USBPD charger driver.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-09-16 13:10:37 +02:00
Fabien Parent 3af15cfacd power: supply: cros: add support for dedicated port
ChromeOS devices can have one optional dedicated port.
The Dedicated port is unique and similar to the USB PD ports
except that it doesn't support as many properties.

The presence of a dedicated port is determined from whether the
EC's charger port count is equal to 'number of USB PD port' + 1.
The dedicated port ID is always the last valid port ID.

This commit keeps compatibility with Embedded Controllers that do not
support the new EC_CMD_CHARGE_PORT_COUNT command by setting
the number of charger port to be equal to the number of USB PD port
when this command fails.

Signed-off-by: Fabien Parent <fparent@baylibre.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-09-16 12:55:25 +02:00
Colin Ian King 89a74789f4 power: supply: cros_usbpd: remove unused pointer 'dev'
Pointer 'dev' is being assigned but is never used hence it is
redundant and can be removed.

Cleans up clang warning:
variable 'dev' set but not used [-Wunused-but-set-variable]

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2018-08-29 23:55:39 +02:00
Gustavo A. R. Silva 37bab356f8 power: supply: mark expected switch fall-throughs
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Addresses-Coverity-ID: 1394724 ("Missing break in switch")
Addresses-Coverity-ID: 114958 ("Missing break in switch")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-07-23 00:10:47 +02:00
Sameer Nanda f68b883e8f power: supply: add cros-ec USBPD 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.

Signed-off-by: Sameer Nanda <snanda@chromium.org>
Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
2018-07-05 17:12:52 +02:00