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 '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

+104 -137
+11 -3
MAINTAINERS
··· 4468 4468 4469 4469 CHROME HARDWARE PLATFORM SUPPORT 4470 4470 M: Benson Leung <bleung@chromium.org> 4471 - M: Enric Balletbo i Serra <enric.balletbo@collabora.com> 4472 4471 S: Maintained 4473 4472 T: git git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux.git 4474 4473 F: drivers/platform/chrome/ 4475 4474 4476 4475 CHROMEOS EC CODEC DRIVER 4477 4476 M: Cheng-Yi Chiang <cychiang@chromium.org> 4478 - R: Enric Balletbo i Serra <enric.balletbo@collabora.com> 4479 4477 R: Guenter Roeck <groeck@chromium.org> 4480 4478 S: Maintained 4481 4479 F: Documentation/devicetree/bindings/sound/google,cros-ec-codec.yaml ··· 4481 4483 4482 4484 CHROMEOS EC SUBDRIVERS 4483 4485 M: Benson Leung <bleung@chromium.org> 4484 - M: Enric Balletbo i Serra <enric.balletbo@collabora.com> 4485 4486 R: Guenter Roeck <groeck@chromium.org> 4486 4487 S: Maintained 4487 4488 F: drivers/power/supply/cros_usbpd-charger.c 4488 4489 N: cros_ec 4489 4490 N: cros-ec 4491 + 4492 + CHROMEOS EC USB TYPE-C DRIVER 4493 + M: Prashant Malani <pmalani@chromium.org> 4494 + S: Maintained 4495 + F: drivers/platform/chrome/cros_ec_typec.c 4496 + 4497 + CHROMEOS EC USB PD NOTIFY DRIVER 4498 + M: Prashant Malani <pmalani@chromium.org> 4499 + S: Maintained 4500 + F: drivers/platform/chrome/cros_usbpd_notify.c 4501 + F: include/linux/platform_data/cros_usbpd_notify.h 4490 4502 4491 4503 CHRONTEL CH7322 CEC DRIVER 4492 4504 M: Joe Tessler <jrt@google.com>
+1 -2
drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
··· 831 831 832 832 static int __maybe_unused cros_ec_sensors_resume(struct device *dev) 833 833 { 834 - struct platform_device *pdev = to_platform_device(dev); 835 - struct iio_dev *indio_dev = platform_get_drvdata(pdev); 834 + struct iio_dev *indio_dev = dev_get_drvdata(dev); 836 835 struct cros_ec_sensors_core_state *st = iio_priv(indio_dev); 837 836 int ret = 0; 838 837
+2 -2
drivers/mfd/cros_ec_dev.c
··· 146 146 ec->ec_dev = dev_get_drvdata(dev->parent); 147 147 ec->dev = dev; 148 148 ec->cmd_offset = ec_platform->cmd_offset; 149 - ec->features[0] = -1U; /* Not cached yet */ 150 - ec->features[1] = -1U; /* Not cached yet */ 149 + ec->features.flags[0] = -1U; /* Not cached yet */ 150 + ec->features.flags[1] = -1U; /* Not cached yet */ 151 151 device_initialize(&ec->class_dev); 152 152 153 153 for (i = 0; i < ARRAY_SIZE(cros_mcu_devices); i++) {
+2 -2
drivers/platform/chrome/cros_ec_lpc.c
··· 156 156 cros_ec_lpc_ops.write(EC_LPC_ADDR_HOST_CMD, 1, &sum); 157 157 158 158 if (ec_response_timed_out()) { 159 - dev_warn(ec->dev, "EC responsed timed out\n"); 159 + dev_warn(ec->dev, "EC response timed out\n"); 160 160 ret = -EIO; 161 161 goto done; 162 162 } ··· 238 238 cros_ec_lpc_ops.write(EC_LPC_ADDR_HOST_CMD, 1, &sum); 239 239 240 240 if (ec_response_timed_out()) { 241 - dev_warn(ec->dev, "EC responsed timed out\n"); 241 + dev_warn(ec->dev, "EC response timed out\n"); 242 242 ret = -EIO; 243 243 goto done; 244 244 }
+58 -21
drivers/platform/chrome/cros_ec_proto.c
··· 808 808 * 809 809 * Call this function to test whether the ChromeOS EC supports a feature. 810 810 * 811 - * Return: 1 if supported, 0 if not 811 + * Return: true if supported, false if not (or if an error was encountered). 812 812 */ 813 - int cros_ec_check_features(struct cros_ec_dev *ec, int feature) 813 + bool cros_ec_check_features(struct cros_ec_dev *ec, int feature) 814 814 { 815 - struct cros_ec_command *msg; 815 + struct ec_response_get_features *features = &ec->features; 816 816 int ret; 817 817 818 - if (ec->features[0] == -1U && ec->features[1] == -1U) { 818 + if (features->flags[0] == -1U && features->flags[1] == -1U) { 819 819 /* features bitmap not read yet */ 820 - msg = kzalloc(sizeof(*msg) + sizeof(ec->features), GFP_KERNEL); 821 - if (!msg) 822 - return -ENOMEM; 823 - 824 - msg->command = EC_CMD_GET_FEATURES + ec->cmd_offset; 825 - msg->insize = sizeof(ec->features); 826 - 827 - ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg); 820 + ret = cros_ec_command(ec->ec_dev, 0, EC_CMD_GET_FEATURES + ec->cmd_offset, 821 + NULL, 0, features, sizeof(*features)); 828 822 if (ret < 0) { 829 - dev_warn(ec->dev, "cannot get EC features: %d/%d\n", 830 - ret, msg->result); 831 - memset(ec->features, 0, sizeof(ec->features)); 832 - } else { 833 - memcpy(ec->features, msg->data, sizeof(ec->features)); 823 + dev_warn(ec->dev, "cannot get EC features: %d\n", ret); 824 + memset(features, 0, sizeof(*features)); 834 825 } 835 826 836 827 dev_dbg(ec->dev, "EC features %08x %08x\n", 837 - ec->features[0], ec->features[1]); 838 - 839 - kfree(msg); 828 + features->flags[0], features->flags[1]); 840 829 } 841 830 842 - return ec->features[feature / 32] & EC_FEATURE_MASK_0(feature); 831 + return !!(features->flags[feature / 32] & EC_FEATURE_MASK_0(feature)); 843 832 } 844 833 EXPORT_SYMBOL_GPL(cros_ec_check_features); 845 834 ··· 897 908 return sensor_count; 898 909 } 899 910 EXPORT_SYMBOL_GPL(cros_ec_get_sensor_count); 911 + 912 + /** 913 + * cros_ec_command - Send a command to the EC. 914 + * 915 + * @ec_dev: EC device 916 + * @version: EC command version 917 + * @command: EC command 918 + * @outdata: EC command output data 919 + * @outsize: Size of outdata 920 + * @indata: EC command input data 921 + * @insize: Size of indata 922 + * 923 + * Return: >= 0 on success, negative error number on failure. 924 + */ 925 + int cros_ec_command(struct cros_ec_device *ec_dev, 926 + unsigned int version, 927 + int command, 928 + void *outdata, 929 + int outsize, 930 + void *indata, 931 + int insize) 932 + { 933 + struct cros_ec_command *msg; 934 + int ret; 935 + 936 + msg = kzalloc(sizeof(*msg) + max(insize, outsize), GFP_KERNEL); 937 + if (!msg) 938 + return -ENOMEM; 939 + 940 + msg->version = version; 941 + msg->command = command; 942 + msg->outsize = outsize; 943 + msg->insize = insize; 944 + 945 + if (outsize) 946 + memcpy(msg->data, outdata, outsize); 947 + 948 + ret = cros_ec_cmd_xfer_status(ec_dev, msg); 949 + if (ret < 0) 950 + goto error; 951 + 952 + if (insize) 953 + memcpy(indata, msg->data, insize); 954 + error: 955 + kfree(msg); 956 + return ret; 957 + } 958 + EXPORT_SYMBOL_GPL(cros_ec_command);
+2 -4
drivers/platform/chrome/cros_ec_sensorhub.c
··· 224 224 */ 225 225 static int cros_ec_sensorhub_suspend(struct device *dev) 226 226 { 227 - struct platform_device *pdev = to_platform_device(dev); 228 - struct cros_ec_sensorhub *sensorhub = platform_get_drvdata(pdev); 227 + struct cros_ec_sensorhub *sensorhub = dev_get_drvdata(dev); 229 228 struct cros_ec_dev *ec = sensorhub->ec; 230 229 231 230 if (cros_ec_check_features(ec, EC_FEATURE_MOTION_SENSE_FIFO)) ··· 234 235 235 236 static int cros_ec_sensorhub_resume(struct device *dev) 236 237 { 237 - struct platform_device *pdev = to_platform_device(dev); 238 - struct cros_ec_sensorhub *sensorhub = platform_get_drvdata(pdev); 238 + struct cros_ec_sensorhub *sensorhub = dev_get_drvdata(dev); 239 239 struct cros_ec_dev *ec = sensorhub->ec; 240 240 241 241 if (cros_ec_check_features(ec, EC_FEATURE_MOTION_SENSE_FIFO))
+21 -53
drivers/platform/chrome/cros_ec_typec.c
··· 379 379 return ret; 380 380 } 381 381 382 - static int cros_typec_ec_command(struct cros_typec_data *typec, 383 - unsigned int version, 384 - unsigned int command, 385 - void *outdata, 386 - unsigned int outsize, 387 - void *indata, 388 - unsigned int insize) 389 - { 390 - struct cros_ec_command *msg; 391 - int ret; 392 - 393 - msg = kzalloc(sizeof(*msg) + max(outsize, insize), GFP_KERNEL); 394 - if (!msg) 395 - return -ENOMEM; 396 - 397 - msg->version = version; 398 - msg->command = command; 399 - msg->outsize = outsize; 400 - msg->insize = insize; 401 - 402 - if (outsize) 403 - memcpy(msg->data, outdata, outsize); 404 - 405 - ret = cros_ec_cmd_xfer_status(typec->ec, msg); 406 - if (ret >= 0 && insize) 407 - memcpy(indata, msg->data, insize); 408 - 409 - kfree(msg); 410 - return ret; 411 - } 412 - 413 382 static int cros_typec_usb_safe_state(struct cros_typec_port *port) 414 383 { 415 384 port->state.mode = TYPEC_STATE_SAFE; ··· 565 596 /* Sending Acknowledgment to EC */ 566 597 mux_ack.port = port_num; 567 598 568 - if (cros_typec_ec_command(typec, 0, EC_CMD_USB_PD_MUX_ACK, &mux_ack, 569 - sizeof(mux_ack), NULL, 0) < 0) 599 + if (cros_ec_command(typec->ec, 0, EC_CMD_USB_PD_MUX_ACK, &mux_ack, 600 + sizeof(mux_ack), NULL, 0) < 0) 570 601 dev_warn(typec->dev, 571 602 "Failed to send Mux ACK to EC for port: %d\n", 572 603 port_num); ··· 637 668 .port = port_num, 638 669 }; 639 670 640 - return cros_typec_ec_command(typec, 0, EC_CMD_USB_PD_MUX_INFO, &req, 641 - sizeof(req), resp, sizeof(*resp)); 671 + return cros_ec_command(typec->ec, 0, EC_CMD_USB_PD_MUX_INFO, &req, 672 + sizeof(req), resp, sizeof(*resp)); 642 673 } 643 674 644 675 /* ··· 745 776 int ret = 0; 746 777 747 778 memset(disc, 0, EC_PROTO2_MAX_RESPONSE_SIZE); 748 - ret = cros_typec_ec_command(typec, 0, EC_CMD_TYPEC_DISCOVERY, &req, sizeof(req), 749 - disc, EC_PROTO2_MAX_RESPONSE_SIZE); 779 + ret = cros_ec_command(typec->ec, 0, EC_CMD_TYPEC_DISCOVERY, &req, sizeof(req), 780 + disc, EC_PROTO2_MAX_RESPONSE_SIZE); 750 781 if (ret < 0) { 751 782 dev_err(typec->dev, "Failed to get SOP' discovery data for port: %d\n", port_num); 752 783 goto sop_prime_disc_exit; ··· 828 859 typec_partner_set_pd_revision(port->partner, pd_revision); 829 860 830 861 memset(sop_disc, 0, EC_PROTO2_MAX_RESPONSE_SIZE); 831 - ret = cros_typec_ec_command(typec, 0, EC_CMD_TYPEC_DISCOVERY, &req, sizeof(req), 832 - sop_disc, EC_PROTO2_MAX_RESPONSE_SIZE); 862 + ret = cros_ec_command(typec->ec, 0, EC_CMD_TYPEC_DISCOVERY, &req, sizeof(req), 863 + sop_disc, EC_PROTO2_MAX_RESPONSE_SIZE); 833 864 if (ret < 0) { 834 865 dev_err(typec->dev, "Failed to get SOP discovery data for port: %d\n", port_num); 835 866 goto disc_exit; ··· 861 892 .clear_events_mask = events_mask, 862 893 }; 863 894 864 - return cros_typec_ec_command(typec, 0, EC_CMD_TYPEC_CONTROL, &req, 865 - sizeof(req), NULL, 0); 895 + return cros_ec_command(typec->ec, 0, EC_CMD_TYPEC_CONTROL, &req, 896 + sizeof(req), NULL, 0); 866 897 } 867 898 868 899 static void cros_typec_handle_status(struct cros_typec_data *typec, int port_num) ··· 873 904 }; 874 905 int ret; 875 906 876 - ret = cros_typec_ec_command(typec, 0, EC_CMD_TYPEC_STATUS, &req, sizeof(req), 877 - &resp, sizeof(resp)); 907 + ret = cros_ec_command(typec->ec, 0, EC_CMD_TYPEC_STATUS, &req, sizeof(req), 908 + &resp, sizeof(resp)); 878 909 if (ret < 0) { 879 910 dev_warn(typec->dev, "EC_CMD_TYPEC_STATUS failed for port: %d\n", port_num); 880 911 return; ··· 952 983 req.mux = USB_PD_CTRL_MUX_NO_CHANGE; 953 984 req.swap = USB_PD_CTRL_SWAP_NONE; 954 985 955 - ret = cros_typec_ec_command(typec, typec->pd_ctrl_ver, 956 - EC_CMD_USB_PD_CONTROL, &req, sizeof(req), 957 - &resp, sizeof(resp)); 986 + ret = cros_ec_command(typec->ec, typec->pd_ctrl_ver, 987 + EC_CMD_USB_PD_CONTROL, &req, sizeof(req), 988 + &resp, sizeof(resp)); 958 989 if (ret < 0) 959 990 return ret; 960 991 ··· 1004 1035 1005 1036 /* We're interested in the PD control command version. */ 1006 1037 req_v1.cmd = EC_CMD_USB_PD_CONTROL; 1007 - ret = cros_typec_ec_command(typec, 1, EC_CMD_GET_CMD_VERSIONS, 1008 - &req_v1, sizeof(req_v1), &resp, 1038 + ret = cros_ec_command(typec->ec, 1, EC_CMD_GET_CMD_VERSIONS, 1039 + &req_v1, sizeof(req_v1), &resp, 1009 1040 sizeof(resp)); 1010 1041 if (ret < 0) 1011 1042 return ret; ··· 1085 1116 } 1086 1117 1087 1118 ec_dev = dev_get_drvdata(&typec->ec->ec->dev); 1088 - typec->typec_cmd_supported = !!cros_ec_check_features(ec_dev, EC_FEATURE_TYPEC_CMD); 1089 - typec->needs_mux_ack = !!cros_ec_check_features(ec_dev, 1090 - EC_FEATURE_TYPEC_MUX_REQUIRE_AP_ACK); 1119 + typec->typec_cmd_supported = cros_ec_check_features(ec_dev, EC_FEATURE_TYPEC_CMD); 1120 + typec->needs_mux_ack = cros_ec_check_features(ec_dev, EC_FEATURE_TYPEC_MUX_REQUIRE_AP_ACK); 1091 1121 1092 - ret = cros_typec_ec_command(typec, 0, EC_CMD_USB_PD_PORTS, NULL, 0, 1093 - &resp, sizeof(resp)); 1122 + ret = cros_ec_command(typec->ec, 0, EC_CMD_USB_PD_PORTS, NULL, 0, 1123 + &resp, sizeof(resp)); 1094 1124 if (ret < 0) 1095 1125 return ret; 1096 1126
+2 -48
drivers/platform/chrome/cros_usbpd_notify.c
··· 53 53 } 54 54 EXPORT_SYMBOL_GPL(cros_usbpd_unregister_notify); 55 55 56 - /** 57 - * cros_ec_pd_command - Send a command to the EC. 58 - * 59 - * @ec_dev: EC device 60 - * @command: EC command 61 - * @outdata: EC command output data 62 - * @outsize: Size of outdata 63 - * @indata: EC command input data 64 - * @insize: Size of indata 65 - * 66 - * Return: >= 0 on success, negative error number on failure. 67 - */ 68 - static int cros_ec_pd_command(struct cros_ec_device *ec_dev, 69 - int command, 70 - uint8_t *outdata, 71 - int outsize, 72 - uint8_t *indata, 73 - int insize) 74 - { 75 - struct cros_ec_command *msg; 76 - int ret; 77 - 78 - msg = kzalloc(sizeof(*msg) + max(insize, outsize), GFP_KERNEL); 79 - if (!msg) 80 - return -ENOMEM; 81 - 82 - msg->command = command; 83 - msg->outsize = outsize; 84 - msg->insize = insize; 85 - 86 - if (outsize) 87 - memcpy(msg->data, outdata, outsize); 88 - 89 - ret = cros_ec_cmd_xfer_status(ec_dev, msg); 90 - if (ret < 0) 91 - goto error; 92 - 93 - if (insize) 94 - memcpy(indata, msg->data, insize); 95 - error: 96 - kfree(msg); 97 - return ret; 98 - } 99 - 100 56 static void cros_usbpd_get_event_and_notify(struct device *dev, 101 57 struct cros_ec_device *ec_dev) 102 58 { ··· 71 115 } 72 116 73 117 /* Check for PD host events on EC. */ 74 - ret = cros_ec_pd_command(ec_dev, EC_CMD_PD_HOST_EVENT_STATUS, 75 - NULL, 0, 76 - (uint8_t *)&host_event_status, 77 - sizeof(host_event_status)); 118 + ret = cros_ec_command(ec_dev, 0, EC_CMD_PD_HOST_EVENT_STATUS, 119 + NULL, 0, &host_event_status, sizeof(host_event_status)); 78 120 if (ret < 0) { 79 121 dev_warn(dev, "Can't get host event status (err: %d)\n", ret); 80 122 goto send_notify;
+5 -2
include/linux/platform_data/cros_ec_proto.h
··· 205 205 struct cros_ec_debugfs *debug_info; 206 206 bool has_kb_wake_angle; 207 207 u16 cmd_offset; 208 - u32 features[2]; 208 + struct ec_response_get_features features; 209 209 }; 210 210 211 211 #define to_cros_ec_dev(dev) container_of(dev, struct cros_ec_dev, class_dev) ··· 227 227 228 228 u32 cros_ec_get_host_event(struct cros_ec_device *ec_dev); 229 229 230 - int cros_ec_check_features(struct cros_ec_dev *ec, int feature); 230 + bool cros_ec_check_features(struct cros_ec_dev *ec, int feature); 231 231 232 232 int cros_ec_get_sensor_count(struct cros_ec_dev *ec); 233 + 234 + int cros_ec_command(struct cros_ec_device *ec_dev, unsigned int version, int command, void *outdata, 235 + int outsize, void *indata, int insize); 233 236 234 237 /** 235 238 * cros_ec_get_time_ns() - Return time in ns.