Commit d4efc0de authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'tag-chrome-platform-for-v5.16' of...

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

Pull chrome platform updates from Benson Leung:
 "cros_ec_typec:

   - Clean up use of cros_ec_check_features

  cros_ec_*:

   - Rename and move cros_ec_pd_command to cros_ec_command, and make
     changes to cros_ec_typec and cros_ec_proto to use the new common
     command, reducing duplication.

  sensorhub:

   - simplify getting .driver_data in cros_ec_sensors_core and
     cros_ec_sensorhub

  misc:

   - Maintainership change. Enric Balletbo i Serra has moved on from
     Collabora, so removing him from chrome/platform maintainers. Thanks
     for all of your hard work maintaining this, Enric, and best of luck
     to you in your new role!

   - Add Prashant Malani as driver maintainer for cros_ec_typec.c and
     cros_usbpd_notify. He was already principal contributor of these
     drivers"

* tag 'tag-chrome-platform-for-v5.16' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux:
  platform/chrome: cros_ec_proto: Use ec_command for check_features
  platform/chrome: cros_ec_proto: Use EC struct for features
  MAINTAINERS: Chrome: Drop Enric Balletbo i Serra
  platform/chrome: cros_ec_typec: Use cros_ec_command()
  platform/chrome: cros_ec_proto: Add version for ec_command
  platform/chrome: cros_ec_proto: Make data pointers void
  platform/chrome: cros_usbpd_notify: Move ec_command()
  platform/chrome: cros_usbpd_notify: Rename cros_ec_pd_command()
  platform/chrome: cros_ec: Fix spelling mistake "responsed" -> "response"
  platform/chrome: cros_ec_sensorhub: simplify getting .driver_data
  iio: common: cros_ec_sensors: simplify getting .driver_data
  platform/chrome: cros-ec-typec: Cleanup use of check_features
  platform/chrome: cros_ec_proto: Fix check_features ret val
  MAINTAINERS: Add Prashant's maintainership of cros_ec drivers
parents 89fa0be0 297d34e7
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -4468,14 +4468,12 @@ F: drivers/input/touchscreen/chipone_icn8505.c
CHROME HARDWARE PLATFORM SUPPORT
M:	Benson Leung <bleung@chromium.org>
M:	Enric Balletbo i Serra <enric.balletbo@collabora.com>
S:	Maintained
T:	git git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux.git
F:	drivers/platform/chrome/
CHROMEOS EC CODEC DRIVER
M:	Cheng-Yi Chiang <cychiang@chromium.org>
R:	Enric Balletbo i Serra <enric.balletbo@collabora.com>
R:	Guenter Roeck <groeck@chromium.org>
S:	Maintained
F:	Documentation/devicetree/bindings/sound/google,cros-ec-codec.yaml
@@ -4483,13 +4481,23 @@ F: sound/soc/codecs/cros_ec_codec.*
CHROMEOS EC SUBDRIVERS
M:	Benson Leung <bleung@chromium.org>
M:	Enric Balletbo i Serra <enric.balletbo@collabora.com>
R:	Guenter Roeck <groeck@chromium.org>
S:	Maintained
F:	drivers/power/supply/cros_usbpd-charger.c
N:	cros_ec
N:	cros-ec
CHROMEOS EC USB TYPE-C DRIVER
M:	Prashant Malani <pmalani@chromium.org>
S:	Maintained
F:	drivers/platform/chrome/cros_ec_typec.c
CHROMEOS EC USB PD NOTIFY DRIVER
M:	Prashant Malani <pmalani@chromium.org>
S:	Maintained
F:	drivers/platform/chrome/cros_usbpd_notify.c
F:	include/linux/platform_data/cros_usbpd_notify.h
CHRONTEL CH7322 CEC DRIVER
M:	Joe Tessler <jrt@google.com>
L:	linux-media@vger.kernel.org
+1 −2
Original line number Diff line number Diff line
@@ -831,8 +831,7 @@ EXPORT_SYMBOL_GPL(cros_ec_sensors_core_write);

static int __maybe_unused cros_ec_sensors_resume(struct device *dev)
{
	struct platform_device *pdev = to_platform_device(dev);
	struct iio_dev *indio_dev = platform_get_drvdata(pdev);
	struct iio_dev *indio_dev = dev_get_drvdata(dev);
	struct cros_ec_sensors_core_state *st = iio_priv(indio_dev);
	int ret = 0;

+2 −2
Original line number Diff line number Diff line
@@ -146,8 +146,8 @@ static int ec_device_probe(struct platform_device *pdev)
	ec->ec_dev = dev_get_drvdata(dev->parent);
	ec->dev = dev;
	ec->cmd_offset = ec_platform->cmd_offset;
	ec->features[0] = -1U; /* Not cached yet */
	ec->features[1] = -1U; /* Not cached yet */
	ec->features.flags[0] = -1U; /* Not cached yet */
	ec->features.flags[1] = -1U; /* Not cached yet */
	device_initialize(&ec->class_dev);

	for (i = 0; i < ARRAY_SIZE(cros_mcu_devices); i++) {
+2 −2
Original line number Diff line number Diff line
@@ -156,7 +156,7 @@ static int cros_ec_pkt_xfer_lpc(struct cros_ec_device *ec,
	cros_ec_lpc_ops.write(EC_LPC_ADDR_HOST_CMD, 1, &sum);

	if (ec_response_timed_out()) {
		dev_warn(ec->dev, "EC responsed timed out\n");
		dev_warn(ec->dev, "EC response timed out\n");
		ret = -EIO;
		goto done;
	}
@@ -238,7 +238,7 @@ static int cros_ec_cmd_xfer_lpc(struct cros_ec_device *ec,
	cros_ec_lpc_ops.write(EC_LPC_ADDR_HOST_CMD, 1, &sum);

	if (ec_response_timed_out()) {
		dev_warn(ec->dev, "EC responsed timed out\n");
		dev_warn(ec->dev, "EC response timed out\n");
		ret = -EIO;
		goto done;
	}
+58 −21
Original line number Diff line number Diff line
@@ -808,38 +808,27 @@ EXPORT_SYMBOL(cros_ec_get_host_event);
 *
 * Call this function to test whether the ChromeOS EC supports a feature.
 *
 * Return: 1 if supported, 0 if not
 * Return: true if supported, false if not (or if an error was encountered).
 */
int cros_ec_check_features(struct cros_ec_dev *ec, int feature)
bool cros_ec_check_features(struct cros_ec_dev *ec, int feature)
{
	struct cros_ec_command *msg;
	struct ec_response_get_features *features = &ec->features;
	int ret;

	if (ec->features[0] == -1U && ec->features[1] == -1U) {
	if (features->flags[0] == -1U && features->flags[1] == -1U) {
		/* features bitmap not read yet */
		msg = kzalloc(sizeof(*msg) + sizeof(ec->features), GFP_KERNEL);
		if (!msg)
			return -ENOMEM;

		msg->command = EC_CMD_GET_FEATURES + ec->cmd_offset;
		msg->insize = sizeof(ec->features);

		ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg);
		ret = cros_ec_command(ec->ec_dev, 0, EC_CMD_GET_FEATURES + ec->cmd_offset,
				      NULL, 0, features, sizeof(*features));
		if (ret < 0) {
			dev_warn(ec->dev, "cannot get EC features: %d/%d\n",
				 ret, msg->result);
			memset(ec->features, 0, sizeof(ec->features));
		} else {
			memcpy(ec->features, msg->data, sizeof(ec->features));
			dev_warn(ec->dev, "cannot get EC features: %d\n", ret);
			memset(features, 0, sizeof(*features));
		}

		dev_dbg(ec->dev, "EC features %08x %08x\n",
			ec->features[0], ec->features[1]);

		kfree(msg);
			features->flags[0], features->flags[1]);
	}

	return ec->features[feature / 32] & EC_FEATURE_MASK_0(feature);
	return !!(features->flags[feature / 32] & EC_FEATURE_MASK_0(feature));
}
EXPORT_SYMBOL_GPL(cros_ec_check_features);

@@ -908,3 +897,51 @@ int cros_ec_get_sensor_count(struct cros_ec_dev *ec)
	return sensor_count;
}
EXPORT_SYMBOL_GPL(cros_ec_get_sensor_count);

/**
 * cros_ec_command - Send a command to the EC.
 *
 * @ec_dev: EC device
 * @version: EC command version
 * @command: EC command
 * @outdata: EC command output data
 * @outsize: Size of outdata
 * @indata: EC command input data
 * @insize: Size of indata
 *
 * Return: >= 0 on success, negative error number on failure.
 */
int cros_ec_command(struct cros_ec_device *ec_dev,
		    unsigned int version,
		    int command,
		    void *outdata,
		    int outsize,
		    void *indata,
		    int insize)
{
	struct cros_ec_command *msg;
	int ret;

	msg = kzalloc(sizeof(*msg) + max(insize, outsize), GFP_KERNEL);
	if (!msg)
		return -ENOMEM;

	msg->version = version;
	msg->command = command;
	msg->outsize = outsize;
	msg->insize = insize;

	if (outsize)
		memcpy(msg->data, outdata, outsize);

	ret = cros_ec_cmd_xfer_status(ec_dev, msg);
	if (ret < 0)
		goto error;

	if (insize)
		memcpy(indata, msg->data, insize);
error:
	kfree(msg);
	return ret;
}
EXPORT_SYMBOL_GPL(cros_ec_command);
Loading