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

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

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

Pull chrome platform updates from Benson Leung:
 "cros_ec_typec:

   - Add support for switch control and alternate modes to the Chrome EC
     Type C port driver

   - Add basic suspend/resume support

  sensorhub:

   - Fix timestamp overflow issue

   - Fix legacy timestamp spreading on Nami systems

  cros_ec_proto:

   - After removing all users of, stop exporting cros_ec_cmd_xfer

   - Check for missing EC_CMD_HOST_EVENT_GET_WAKE_MASK and ignore
     wakeups on old ECs

  misc:

   - Documentation warning cleanup

   - Fix double unlock issue in ishtp"

* tag 'tag-chrome-platform-for-v5.9' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux: (21 commits)
  platform/chrome: cros_ec_proto: check for missing EC_CMD_HOST_EVENT_GET_WAKE_MASK
  platform/chrome: cros_ec_proto: ignore unnecessary wakeups on old ECs
  platform/chrome: cros_ec_sensorhub: Simplify legacy timestamp spreading
  platform/chrome: cros_ec_proto: Do not export cros_ec_cmd_xfer()
  platform/chrome: cros_ec_typec: Unregister partner on error
  platform/chrome: cros_ec_sensorhub: Fix EC timestamp overflow
  platform/chrome: cros_ec_typec: Add PM support
  platform/chrome: cros_ec_typec: Use workqueue for port update
  platform/chrome: cros_ec_typec: Add a dependency on USB_ROLE_SWITCH
  platform/chrome: cros_ec_ishtp: Fix a double-unlock issue
  platform/chrome: cros_ec_rpmsg: Document missing struct parameters
  platform/chrome: cros_ec_spi: Document missing function parameters
  platform/chrome: cros_ec_typec: Add TBT compat support
  platform/chrome: cros_ec: Add TBT pd_ctrl fields
  platform/chrome: cros_ec_typec: Make configure_mux static
  platform/chrome: cros_ec_typec: Support DP alt mode
  platform/chrome: cros_ec_typec: Add USB mux control
  platform/chrome: cros_ec_typec: Register PD CTRL cmd v2
  platform/chrome: cros_ec: Update mux state bits
  platform/chrome: cros_ec_typec: Register Type C switches
  ...
parents d668e848 fc8cacf3
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -218,6 +218,7 @@ config CROS_EC_TYPEC
	tristate "ChromeOS EC Type-C Connector Control"
	depends on MFD_CROS_EC_DEV && TYPEC
	depends on CROS_USBPD_NOTIFY
	depends on USB_ROLE_SWITCH
	default MFD_CROS_EC_DEV
	help
	  If you say Y here, you get support for accessing Type C connector
+22 −2
Original line number Diff line number Diff line
@@ -242,6 +242,25 @@ static ssize_t cros_ec_pdinfo_read(struct file *file,
				       read_buf, p - read_buf);
}

static bool cros_ec_uptime_is_supported(struct cros_ec_device *ec_dev)
{
	struct {
		struct cros_ec_command cmd;
		struct ec_response_uptime_info resp;
	} __packed msg = {};
	int ret;

	msg.cmd.command = EC_CMD_GET_UPTIME_INFO;
	msg.cmd.insize = sizeof(msg.resp);

	ret = cros_ec_cmd_xfer_status(ec_dev, &msg.cmd);
	if (ret == -EPROTO && msg.cmd.result == EC_RES_INVALID_COMMAND)
		return false;

	/* Other errors maybe a transient error, do not rule about support. */
	return true;
}

static ssize_t cros_ec_uptime_read(struct file *file, char __user *user_buf,
				   size_t count, loff_t *ppos)
{
@@ -444,6 +463,7 @@ static int cros_ec_debugfs_probe(struct platform_device *pd)
	debugfs_create_file("pdinfo", 0444, debug_info->dir, debug_info,
			    &cros_ec_pdinfo_fops);

	if (cros_ec_uptime_is_supported(ec->ec_dev))
		debugfs_create_file("uptime", 0444, debug_info->dir, debug_info,
				    &cros_ec_uptime_fops);

+3 −1
Original line number Diff line number Diff line
@@ -681,8 +681,10 @@ static int cros_ec_ishtp_probe(struct ishtp_cl_device *cl_device)

	/* Register croc_ec_dev mfd */
	rv = cros_ec_dev_init(client_data);
	if (rv)
	if (rv) {
		down_write(&init_lock);
		goto end_cros_ec_dev_init_error;
	}

	return 0;

+33 −9
Original line number Diff line number Diff line
@@ -208,6 +208,12 @@ static int cros_ec_get_host_event_wake_mask(struct cros_ec_device *ec_dev,
	msg->insize = sizeof(*r);

	ret = send_command(ec_dev, msg);
	if (ret >= 0) {
		if (msg->result == EC_RES_INVALID_COMMAND)
			return -EOPNOTSUPP;
		if (msg->result != EC_RES_SUCCESS)
			return -EPROTO;
	}
	if (ret > 0) {
		r = (struct ec_response_host_event_mask *)msg->data;
		*mask = r->mask;
@@ -469,14 +475,33 @@ int cros_ec_query_all(struct cros_ec_device *ec_dev)
						    &ver_mask);
	ec_dev->host_sleep_v1 = (ret >= 0 && (ver_mask & EC_VER_MASK(1)));

	/*
	 * Get host event wake mask, assume all events are wake events
	 * if unavailable.
	 */
	/* Get host event wake mask. */
	ret = cros_ec_get_host_event_wake_mask(ec_dev, proto_msg,
					       &ec_dev->host_event_wake_mask);
	if (ret < 0)
		ec_dev->host_event_wake_mask = U32_MAX;
	if (ret < 0) {
		/*
		 * If the EC doesn't support EC_CMD_HOST_EVENT_GET_WAKE_MASK,
		 * use a reasonable default. Note that we ignore various
		 * battery, AC status, and power-state events, because (a)
		 * those can be quite common (e.g., when sitting at full
		 * charge, on AC) and (b) these are not actionable wake events;
		 * if anything, we'd like to continue suspending (to save
		 * power), not wake up.
		 */
		ec_dev->host_event_wake_mask = U32_MAX &
			~(BIT(EC_HOST_EVENT_AC_DISCONNECTED) |
			  BIT(EC_HOST_EVENT_BATTERY_LOW) |
			  BIT(EC_HOST_EVENT_BATTERY_CRITICAL) |
			  BIT(EC_HOST_EVENT_PD_MCU) |
			  BIT(EC_HOST_EVENT_BATTERY_STATUS));
		/*
		 * Old ECs may not support this command. Complain about all
		 * other errors.
		 */
		if (ret != -EOPNOTSUPP)
			dev_err(ec_dev->dev,
				"failed to retrieve wake mask: %d\n", ret);
	}

	ret = 0;

@@ -496,7 +521,7 @@ EXPORT_SYMBOL(cros_ec_query_all);
 *
 * Return: 0 on success or negative error code.
 */
int cros_ec_cmd_xfer(struct cros_ec_device *ec_dev,
static int cros_ec_cmd_xfer(struct cros_ec_device *ec_dev,
			    struct cros_ec_command *msg)
{
	int ret;
@@ -541,7 +566,6 @@ int cros_ec_cmd_xfer(struct cros_ec_device *ec_dev,

	return ret;
}
EXPORT_SYMBOL(cros_ec_cmd_xfer);

/**
 * cros_ec_cmd_xfer_status() - Send a command to the ChromeOS EC.
+3 −0
Original line number Diff line number Diff line
@@ -38,6 +38,9 @@ struct cros_ec_rpmsg_response {
 * @rpdev:	rpmsg device we are connected to
 * @xfer_ack:	completion for host command transfer.
 * @host_event_work:	Work struct for pending host event.
 * @ept: The rpmsg endpoint of this channel.
 * @has_pending_host_event: Boolean used to check if there is a pending event.
 * @probe_done: Flag to indicate that probe is done.
 */
struct cros_ec_rpmsg {
	struct rpmsg_device *rpdev;
Loading