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

firmware: arm_scpi: add support for device power state management

SCPI protocol supports device power state management. This deals with
power states of various peripheral devices in the system other than the
core compute subsystem.

This patch adds support for the power state management of those
peripheral devices.

Tested-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Tested-by: Jon Medhurst <tixy@linaro.org>
Reviewed-by: Jon Medhurst <tixy@linaro.org>
Reviewed-by: Kevin Hilman <khilman@baylibre.com>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>

+32
+30
drivers/firmware/arm_scpi.c
··· 231 231 __le32 hi_val; 232 232 } __packed; 233 233 234 + struct dev_pstate_set { 235 + u16 dev_id; 236 + u8 pstate; 237 + } __packed; 238 + 234 239 static struct scpi_drvinfo *scpi_info; 235 240 236 241 static int scpi_linux_errmap[SCPI_ERR_MAX] = { ··· 542 537 return ret; 543 538 } 544 539 540 + static int scpi_device_get_power_state(u16 dev_id) 541 + { 542 + int ret; 543 + u8 pstate; 544 + __le16 id = cpu_to_le16(dev_id); 545 + 546 + ret = scpi_send_message(SCPI_CMD_GET_DEVICE_PWR_STATE, &id, 547 + sizeof(id), &pstate, sizeof(pstate)); 548 + return ret ? ret : pstate; 549 + } 550 + 551 + static int scpi_device_set_power_state(u16 dev_id, u8 pstate) 552 + { 553 + int stat; 554 + struct dev_pstate_set dev_set = { 555 + .dev_id = cpu_to_le16(dev_id), 556 + .pstate = pstate, 557 + }; 558 + 559 + return scpi_send_message(SCPI_CMD_SET_DEVICE_PWR_STATE, &dev_set, 560 + sizeof(dev_set), &stat, sizeof(stat)); 561 + } 562 + 545 563 static struct scpi_ops scpi_ops = { 546 564 .get_version = scpi_get_version, 547 565 .clk_get_range = scpi_clk_get_range, ··· 576 548 .sensor_get_capability = scpi_sensor_get_capability, 577 549 .sensor_get_info = scpi_sensor_get_info, 578 550 .sensor_get_value = scpi_sensor_get_value, 551 + .device_get_power_state = scpi_device_get_power_state, 552 + .device_set_power_state = scpi_device_set_power_state, 579 553 }; 580 554 581 555 struct scpi_ops *get_scpi_ops(void)
+2
include/linux/scpi_protocol.h
··· 70 70 int (*sensor_get_capability)(u16 *sensors); 71 71 int (*sensor_get_info)(u16 sensor_id, struct scpi_sensor_info *); 72 72 int (*sensor_get_value)(u16, u64 *); 73 + int (*device_get_power_state)(u16); 74 + int (*device_set_power_state)(u16, u8); 73 75 }; 74 76 75 77 #if IS_REACHABLE(CONFIG_ARM_SCPI_PROTOCOL)