Line data Source code
1 1 : /*
2 : * Copyright 2024 NXP
3 : *
4 : * SPDX-License-Identifier: Apache-2.0
5 : */
6 :
7 : /**
8 : * @file
9 : * @brief SCMI pinctrl protocol helpers
10 : */
11 :
12 : #ifndef _INCLUDE_ZEPHYR_DRIVERS_FIRMWARE_SCMI_PINCTRL_H_
13 : #define _INCLUDE_ZEPHYR_DRIVERS_FIRMWARE_SCMI_PINCTRL_H_
14 :
15 : #include <zephyr/drivers/firmware/scmi/protocol.h>
16 :
17 0 : #define ARM_SCMI_PINCTRL_MAX_CONFIG_SIZE (10 * 2)
18 :
19 0 : #define SCMI_PINCTRL_NO_FUNCTION 0xFFFFFFFF
20 :
21 0 : #define SCMI_PINCTRL_CONFIG_ATTRIBUTES(fid_valid, cfg_num, selector) \
22 : (SCMI_FIELD_MAKE(fid_valid, BIT(1), 10) | \
23 : SCMI_FIELD_MAKE(cfg_num, GENMASK(7, 0), 2) | \
24 : SCMI_FIELD_MAKE(selector, GENMASK(1, 0), 0))
25 :
26 0 : #define SCMI_PINCTRL_SELECTOR_PIN 0x0
27 0 : #define SCMI_PINCTRL_SELECTOR_GROUP 0x1
28 :
29 0 : #define SCMI_PINCTRL_ATTRIBUTES_CONFIG_NUM(attributes)\
30 : (((attributes) & GENMASK(9, 2)) >> 2)
31 :
32 : /**
33 : * @brief Pinctrl protocol command message IDs
34 : */
35 0 : enum scmi_pinctrl_message {
36 : SCMI_PINCTRL_MSG_PROTOCOL_VERSION = 0x0,
37 : SCMI_PINCTRL_MSG_PROTOCOL_ATTRIBUTES = 0x1,
38 : SCMI_PINCTRL_MSG_PROTOCOL_MESSAGE_ATTRIBUTES = 0x2,
39 : SCMI_PINCTRL_MSG_PINCTRL_ATTRIBUTES = 0x3,
40 : SCMI_PINCTRL_MSG_PINCTRL_LIST_ASSOCIATIONS = 0x4,
41 : SCMI_PINCTRL_MSG_PINCTRL_SETTINGS_GET = 0x5,
42 : SCMI_PINCTRL_MSG_PINCTRL_SETTINGS_CONFIGURE = 0x6,
43 : SCMI_PINCTRL_MSG_PINCTRL_REQUEST = 0x7,
44 : SCMI_PINCTRL_MSG_PINCTRL_RELEASE = 0x8,
45 : SCMI_PINCTRL_MSG_PINCTRL_NAME_GET = 0x9,
46 : SCMI_PINCTRL_MSG_PINCTRL_SET_PERMISSIONS = 0xa,
47 : SCMI_PINCTRL_MSG_NEGOTIATE_PROTOCOL_VERSION = 0x10,
48 : };
49 :
50 : /**
51 : * @brief Pinctrl configurations
52 : */
53 0 : enum scmi_pinctrl_config {
54 : SCMI_PINCTRL_DEFAULT = 0,
55 : SCMI_PINCTRL_BIAS_BUS_HOLD = 1,
56 : SCMI_PINCTRL_BIAS_DISABLE = 2,
57 : SCMI_PINCTRL_BIAS_HIGH_Z = 3,
58 : SCMI_PINCTRL_BIAS_PULL_UP = 4,
59 : SCMI_PINCTRL_BIAS_PULL_DEFAULT = 5,
60 : SCMI_PINCTRL_BIAS_PULL_DOWN = 6,
61 : SCMI_PINCTRL_DRIVE_OPEN_DRAIN = 7,
62 : SCMI_PINCTRL_DRIVE_OPEN_SOURCE = 8,
63 : SCMI_PCINTRL_DRIVE_PUSH_PULL = 9,
64 : SCMI_PCINTRL_DRIVE_STRENGTH = 10,
65 : SCMI_PINCTRL_INPUT_DEBOUNCE = 11,
66 : SCMI_PINCTRL_INPUT_MODE = 12,
67 : SCMI_PINCTRL_PULL_MODE = 13,
68 : SCMI_PINCTRL_INPUT_VALUE = 14,
69 : SCMI_PINCTRL_INPUT_SCHMITT = 15,
70 : SCMI_PINCTRL_LP_MODE = 16,
71 : SCMI_PINCTRL_OUTPUT_MODE = 17,
72 : SCMI_PINCTRL_OUTPUT_VALUE = 18,
73 : SCMI_PINCTRL_POWER_SOURCE = 19,
74 : SCMI_PINCTRL_SLEW_RATE = 20,
75 : SCMI_PINCTRL_RESERVED_START = 21,
76 : SCMI_PINCTRL_RESERVED_END = 191,
77 : SCMI_PINCTRL_VENDOR_START = 192,
78 : };
79 :
80 : /**
81 : * @struct scmi_pinctrl_settings
82 : *
83 : * @brief Describes the parameters for the PINCTRL_SETTINGS_CONFIGURE
84 : * command
85 : */
86 1 : struct scmi_pinctrl_settings {
87 0 : uint32_t id;
88 0 : uint32_t function;
89 0 : uint32_t attributes;
90 0 : uint32_t config[ARM_SCMI_PINCTRL_MAX_CONFIG_SIZE];
91 : };
92 :
93 : /**
94 : * @brief Send the PINCTRL_SETTINGS_CONFIGURE command and get its reply
95 : *
96 : * @param settings pointer to settings to be applied
97 : *
98 : * @retval 0 if successful
99 : * @retval negative errno if failure
100 : */
101 1 : int scmi_pinctrl_settings_configure(struct scmi_pinctrl_settings *settings);
102 :
103 : #endif /* _INCLUDE_ZEPHYR_DRIVERS_FIRMWARE_SCMI_PINCTRL_H_ */
|