1 /* 2 * Copyright 2024 NXP 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #include <zephyr/drivers/firmware/scmi/pinctrl.h> 8 9 DT_SCMI_PROTOCOL_DEFINE_NODEV(DT_INST(0, arm_scmi_pinctrl), NULL); 10 scmi_pinctrl_settings_configure(struct scmi_pinctrl_settings * settings)11int scmi_pinctrl_settings_configure(struct scmi_pinctrl_settings *settings) 12 { 13 struct scmi_protocol *proto; 14 struct scmi_message msg, reply; 15 uint32_t config_num; 16 int32_t status, ret; 17 18 proto = &SCMI_PROTOCOL_NAME(SCMI_PROTOCOL_PINCTRL); 19 20 /* sanity checks */ 21 if (!settings) { 22 return -EINVAL; 23 } 24 25 if (!proto) { 26 return -EINVAL; 27 } 28 29 if (proto->id != SCMI_PROTOCOL_PINCTRL) { 30 return -EINVAL; 31 } 32 33 config_num = SCMI_PINCTRL_ATTRIBUTES_CONFIG_NUM(settings->attributes); 34 35 if (!config_num) { 36 return -EINVAL; 37 } 38 39 if ((config_num * 2) > ARM_SCMI_PINCTRL_MAX_CONFIG_SIZE) { 40 return -EINVAL; 41 } 42 43 msg.hdr = SCMI_MESSAGE_HDR_MAKE(SCMI_PINCTRL_MSG_PINCTRL_SETTINGS_CONFIGURE, 44 SCMI_COMMAND, proto->id, 0x0); 45 msg.len = sizeof(*settings) - 46 (ARM_SCMI_PINCTRL_MAX_CONFIG_SIZE - config_num * 2) * 4; 47 msg.content = settings; 48 49 reply.hdr = msg.hdr; 50 reply.len = sizeof(status); 51 reply.content = &status; 52 53 ret = scmi_send_message(proto, &msg, &reply); 54 if (ret < 0) { 55 return ret; 56 } 57 58 if (status != SCMI_SUCCESS) { 59 return scmi_status_to_errno(status); 60 } 61 62 return 0; 63 } 64