Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'chrome-platform-v6.17' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux

Pull chrome platform updates from Tzung-Bi Shih:
"New:
- Support ECC in chromeos_pstore
- Allow to control power and data role via sysfs in cros_ec_typec

Improvements:
- Defer probe when the dependencies are not ready in cros_ec_typec
- Retry when a sensor is not ready in cros_ec_sensorhub

Fixes:
- Unregister the blocking notifier as well when unregistering the
struct cros_ec_device.

Cleanups:
- Remove redundant code and leverage more suitable helper macro in
chromeos_laptop
- Fix typo"

* tag 'chrome-platform-v6.17' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux:
platform/chrome: Fix typo in CROS_USBPD_NOTIFY help text
platform/chrome: cros_ec_typec: Check ec platform device pointer
platform/chrome: cros_ec: Unregister notifier in cros_ec_unregister()
platform/chrome: cros_ec_typec: Add role swap ops
platform/chrome: chromeos_laptop: Replace open coded variant of DEFINE_RES_IRQ()
platform/chrome: chromeos_laptop: Remove duplicate check
platform/chrome: cros_ec_sensorhub: Retries when a sensor is not ready
platform/chrome: chromeos_pstore: Add ecc_size module parameter
platform/chrome: cros_ec_typec: Defer probe on missing EC parent

+121 -14
+1 -1
drivers/platform/chrome/Kconfig
··· 286 286 default MFD_CROS_EC_DEV 287 287 help 288 288 If you say Y here, you get support for Type-C PD event notifications 289 - from the ChromeOS EC. On ACPI platorms this driver will bind to the 289 + from the ChromeOS EC. On ACPI platforms this driver will bind to the 290 290 GOOG0003 ACPI device, and on platforms which don't have this device it 291 291 will get initialized on ECs which support the feature 292 292 EC_FEATURE_USB_PD.
+4 -5
drivers/platform/chrome/chromeos_laptop.c
··· 726 726 if (irq < 0) 727 727 return irq; 728 728 729 - i2c_dev->irq_resource = (struct resource) 730 - DEFINE_RES_NAMED(irq, 1, NULL, 731 - IORESOURCE_IRQ | i2c_dev->irqflags); 729 + i2c_dev->irq_resource = DEFINE_RES_IRQ(irq); 730 + i2c_dev->irq_resource.flags |= i2c_dev->irqflags; 731 + 732 732 i2c_dev->board_info.resources = &i2c_dev->irq_resource; 733 733 i2c_dev->board_info.num_resources = 1; 734 734 } ··· 782 782 while (--i >= 0) { 783 783 i2c_dev = &i2c_peripherals[i]; 784 784 info = &i2c_dev->board_info; 785 - if (!IS_ERR_OR_NULL(info->fwnode)) 786 - fwnode_remove_software_node(info->fwnode); 785 + fwnode_remove_software_node(info->fwnode); 787 786 } 788 787 kfree(i2c_peripherals); 789 788 return error;
+7
drivers/platform/chrome/chromeos_pstore.c
··· 9 9 #include <linux/platform_device.h> 10 10 #include <linux/pstore_ram.h> 11 11 12 + static int ecc_size; 13 + module_param(ecc_size, int, 0400); 14 + MODULE_PARM_DESC(ecc_size, "ECC parity data size in bytes. A positive value enables ECC for the ramoops region."); 15 + 12 16 static const struct dmi_system_id chromeos_pstore_dmi_table[] __initconst = { 13 17 { 14 18 /* ··· 120 116 static int __init chromeos_pstore_init(void) 121 117 { 122 118 bool acpi_dev_found; 119 + 120 + if (ecc_size > 0) 121 + chromeos_ramoops_data.ecc_info.ecc_size = ecc_size; 123 122 124 123 /* First check ACPI for non-hardcoded values from firmware. */ 125 124 acpi_dev_found = chromeos_check_acpi();
+3
drivers/platform/chrome/cros_ec.c
··· 318 318 */ 319 319 void cros_ec_unregister(struct cros_ec_device *ec_dev) 320 320 { 321 + if (ec_dev->mkbp_event_supported) 322 + blocking_notifier_chain_unregister(&ec_dev->event_notifier, 323 + &ec_dev->notifier_ready); 321 324 platform_device_unregister(ec_dev->pd); 322 325 platform_device_unregister(ec_dev->ec); 323 326 mutex_destroy(&ec_dev->lock);
+19 -4
drivers/platform/chrome/cros_ec_sensorhub.c
··· 8 8 9 9 #include <linux/init.h> 10 10 #include <linux/device.h> 11 + #include <linux/delay.h> 11 12 #include <linux/mod_devicetable.h> 12 13 #include <linux/module.h> 13 14 #include <linux/platform_data/cros_ec_commands.h> ··· 19 18 #include <linux/types.h> 20 19 21 20 #define DRV_NAME "cros-ec-sensorhub" 21 + #define CROS_EC_CMD_INFO_RETRIES 50 22 22 23 23 static void cros_ec_sensorhub_free_sensor(void *arg) 24 24 { ··· 55 53 int sensor_type[MOTIONSENSE_TYPE_MAX] = { 0 }; 56 54 struct cros_ec_command *msg = sensorhub->msg; 57 55 struct cros_ec_dev *ec = sensorhub->ec; 58 - int ret, i; 56 + int ret, i, retries; 59 57 char *name; 60 58 61 59 ··· 67 65 sensorhub->params->cmd = MOTIONSENSE_CMD_INFO; 68 66 sensorhub->params->info.sensor_num = i; 69 67 70 - ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg); 68 + retries = CROS_EC_CMD_INFO_RETRIES; 69 + do { 70 + ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg); 71 + if (ret == -EBUSY) { 72 + /* The EC is still busy initializing sensors. */ 73 + usleep_range(5000, 6000); 74 + retries--; 75 + } 76 + } while (ret == -EBUSY && retries); 77 + 71 78 if (ret < 0) { 72 - dev_warn(dev, "no info for EC sensor %d : %d/%d\n", 73 - i, ret, msg->result); 79 + dev_err(dev, "no info for EC sensor %d : %d/%d\n", 80 + i, ret, msg->result); 74 81 continue; 82 + } 83 + if (retries < CROS_EC_CMD_INFO_RETRIES) { 84 + dev_warn(dev, "%d retries needed to bring up sensor %d\n", 85 + CROS_EC_CMD_INFO_RETRIES - retries, i); 75 86 } 76 87 77 88 switch (sensorhub->resp->info.type) {
+87 -4
drivers/platform/chrome/cros_ec_typec.c
··· 58 58 &req, sizeof(req), NULL, 0); 59 59 } 60 60 61 + static int cros_typec_perform_role_swap(struct typec_port *tc_port, int target_role, u8 swap_type) 62 + { 63 + struct cros_typec_port *port = typec_get_drvdata(tc_port); 64 + struct cros_typec_data *data = port->typec_data; 65 + struct ec_response_usb_pd_control_v2 resp; 66 + struct ec_params_usb_pd_control req; 67 + int role, ret; 68 + 69 + /* Must be at least v1 to support role swap. */ 70 + if (!data->pd_ctrl_ver) 71 + return -EOPNOTSUPP; 72 + 73 + /* First query the state */ 74 + req.port = port->port_num; 75 + req.role = USB_PD_CTRL_ROLE_NO_CHANGE; 76 + req.mux = USB_PD_CTRL_MUX_NO_CHANGE; 77 + req.swap = USB_PD_CTRL_SWAP_NONE; 78 + 79 + ret = cros_ec_cmd(data->ec, data->pd_ctrl_ver, EC_CMD_USB_PD_CONTROL, 80 + &req, sizeof(req), &resp, sizeof(resp)); 81 + if (ret < 0) 82 + return ret; 83 + 84 + switch (swap_type) { 85 + case USB_PD_CTRL_SWAP_DATA: 86 + role = (resp.role & PD_CTRL_RESP_ROLE_DATA) ? TYPEC_HOST : 87 + TYPEC_DEVICE; 88 + break; 89 + case USB_PD_CTRL_SWAP_POWER: 90 + role = (resp.role & PD_CTRL_RESP_ROLE_POWER) ? TYPEC_SOURCE : 91 + TYPEC_SINK; 92 + break; 93 + default: 94 + dev_warn(data->dev, "Unsupported role swap type %d\n", swap_type); 95 + return -EOPNOTSUPP; 96 + } 97 + 98 + if (role == target_role) 99 + return 0; 100 + 101 + req.swap = swap_type; 102 + ret = cros_ec_cmd(data->ec, data->pd_ctrl_ver, EC_CMD_USB_PD_CONTROL, 103 + &req, sizeof(req), &resp, sizeof(resp)); 104 + if (ret < 0) 105 + return ret; 106 + 107 + switch (swap_type) { 108 + case USB_PD_CTRL_SWAP_DATA: 109 + role = resp.role & PD_CTRL_RESP_ROLE_DATA ? TYPEC_HOST : TYPEC_DEVICE; 110 + if (role != target_role) { 111 + dev_err(data->dev, "Data role swap failed despite EC returning success\n"); 112 + return -EIO; 113 + } 114 + typec_set_data_role(tc_port, target_role); 115 + break; 116 + case USB_PD_CTRL_SWAP_POWER: 117 + role = resp.role & PD_CTRL_RESP_ROLE_POWER ? TYPEC_SOURCE : TYPEC_SINK; 118 + if (role != target_role) { 119 + dev_err(data->dev, "Power role swap failed despite EC returning success\n"); 120 + return -EIO; 121 + } 122 + typec_set_pwr_role(tc_port, target_role); 123 + break; 124 + default: 125 + /* Should never execute */ 126 + break; 127 + } 128 + 129 + return 0; 130 + } 131 + 132 + static int cros_typec_dr_swap(struct typec_port *port, enum typec_data_role role) 133 + { 134 + return cros_typec_perform_role_swap(port, role, USB_PD_CTRL_SWAP_DATA); 135 + } 136 + 137 + static int cros_typec_pr_swap(struct typec_port *port, enum typec_role role) 138 + { 139 + return cros_typec_perform_role_swap(port, role, USB_PD_CTRL_SWAP_POWER); 140 + } 141 + 61 142 static const struct typec_operations cros_typec_usb_mode_ops = { 62 - .enter_usb_mode = cros_typec_enter_usb_mode 143 + .enter_usb_mode = cros_typec_enter_usb_mode, 144 + .dr_set = cros_typec_dr_swap, 145 + .pr_set = cros_typec_pr_swap, 63 146 }; 64 147 65 148 static int cros_typec_parse_port_props(struct typec_capability *cap, ··· 1354 1271 typec->dev = dev; 1355 1272 1356 1273 typec->ec = dev_get_drvdata(pdev->dev.parent); 1357 - if (!typec->ec) { 1358 - dev_err(dev, "couldn't find parent EC device\n"); 1359 - return -ENODEV; 1274 + if (!typec->ec || !typec->ec->ec) { 1275 + dev_warn(dev, "couldn't find parent EC device\n"); 1276 + return -EPROBE_DEFER; 1360 1277 } 1361 1278 1362 1279 platform_set_drvdata(pdev, typec);