1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright © 2015 Broadcom
6 #ifndef __SOC_RASPBERRY_FIRMWARE_H__
7 #define __SOC_RASPBERRY_FIRMWARE_H__
9 #include <linux/types.h>
10 #include <linux/of_device.h>
14 enum rpi_firmware_property_status {
15 RPI_FIRMWARE_STATUS_REQUEST = 0,
16 RPI_FIRMWARE_STATUS_SUCCESS = 0x80000000,
17 RPI_FIRMWARE_STATUS_ERROR = 0x80000001,
21 * struct rpi_firmware_property_tag_header - Firmware property tag header
22 * @tag: One of enum_mbox_property_tag.
23 * @buf_size: The number of bytes in the value buffer following this
25 * @req_resp_size: On submit, the length of the request (though it doesn't
26 * appear to be currently used by the firmware). On return,
27 * the length of the response (always 4 byte aligned), with
30 struct rpi_firmware_property_tag_header {
36 enum rpi_firmware_property_tag {
37 RPI_FIRMWARE_PROPERTY_END = 0,
38 RPI_FIRMWARE_GET_FIRMWARE_REVISION = 0x00000001,
39 RPI_FIRMWARE_GET_FIRMWARE_VARIANT = 0x00000002,
40 RPI_FIRMWARE_GET_FIRMWARE_HASH = 0x00000003,
42 RPI_FIRMWARE_SET_CURSOR_INFO = 0x00008010,
43 RPI_FIRMWARE_SET_CURSOR_STATE = 0x00008011,
45 RPI_FIRMWARE_GET_BOARD_MODEL = 0x00010001,
46 RPI_FIRMWARE_GET_BOARD_REVISION = 0x00010002,
47 RPI_FIRMWARE_GET_BOARD_MAC_ADDRESS = 0x00010003,
48 RPI_FIRMWARE_GET_BOARD_SERIAL = 0x00010004,
49 RPI_FIRMWARE_GET_ARM_MEMORY = 0x00010005,
50 RPI_FIRMWARE_GET_VC_MEMORY = 0x00010006,
51 RPI_FIRMWARE_GET_CLOCKS = 0x00010007,
52 RPI_FIRMWARE_GET_POWER_STATE = 0x00020001,
53 RPI_FIRMWARE_GET_TIMING = 0x00020002,
54 RPI_FIRMWARE_SET_POWER_STATE = 0x00028001,
55 RPI_FIRMWARE_GET_CLOCK_STATE = 0x00030001,
56 RPI_FIRMWARE_GET_CLOCK_RATE = 0x00030002,
57 RPI_FIRMWARE_GET_VOLTAGE = 0x00030003,
58 RPI_FIRMWARE_GET_MAX_CLOCK_RATE = 0x00030004,
59 RPI_FIRMWARE_GET_MAX_VOLTAGE = 0x00030005,
60 RPI_FIRMWARE_GET_TEMPERATURE = 0x00030006,
61 RPI_FIRMWARE_GET_MIN_CLOCK_RATE = 0x00030007,
62 RPI_FIRMWARE_GET_MIN_VOLTAGE = 0x00030008,
63 RPI_FIRMWARE_GET_TURBO = 0x00030009,
64 RPI_FIRMWARE_GET_MAX_TEMPERATURE = 0x0003000a,
65 RPI_FIRMWARE_GET_STC = 0x0003000b,
66 RPI_FIRMWARE_ALLOCATE_MEMORY = 0x0003000c,
67 RPI_FIRMWARE_LOCK_MEMORY = 0x0003000d,
68 RPI_FIRMWARE_UNLOCK_MEMORY = 0x0003000e,
69 RPI_FIRMWARE_RELEASE_MEMORY = 0x0003000f,
70 RPI_FIRMWARE_EXECUTE_CODE = 0x00030010,
71 RPI_FIRMWARE_EXECUTE_QPU = 0x00030011,
72 RPI_FIRMWARE_SET_ENABLE_QPU = 0x00030012,
73 RPI_FIRMWARE_GET_DISPMANX_RESOURCE_MEM_HANDLE = 0x00030014,
74 RPI_FIRMWARE_GET_EDID_BLOCK = 0x00030020,
75 RPI_FIRMWARE_GET_CUSTOMER_OTP = 0x00030021,
76 RPI_FIRMWARE_GET_EDID_BLOCK_DISPLAY = 0x00030023,
77 RPI_FIRMWARE_GET_DOMAIN_STATE = 0x00030030,
78 RPI_FIRMWARE_GET_THROTTLED = 0x00030046,
79 RPI_FIRMWARE_GET_CLOCK_MEASURED = 0x00030047,
80 RPI_FIRMWARE_NOTIFY_REBOOT = 0x00030048,
81 RPI_FIRMWARE_SET_CLOCK_STATE = 0x00038001,
82 RPI_FIRMWARE_SET_CLOCK_RATE = 0x00038002,
83 RPI_FIRMWARE_SET_VOLTAGE = 0x00038003,
84 RPI_FIRMWARE_SET_TURBO = 0x00038009,
85 RPI_FIRMWARE_SET_CUSTOMER_OTP = 0x00038021,
86 RPI_FIRMWARE_SET_DOMAIN_STATE = 0x00038030,
87 RPI_FIRMWARE_GET_GPIO_STATE = 0x00030041,
88 RPI_FIRMWARE_SET_GPIO_STATE = 0x00038041,
89 RPI_FIRMWARE_SET_SDHOST_CLOCK = 0x00038042,
90 RPI_FIRMWARE_GET_GPIO_CONFIG = 0x00030043,
91 RPI_FIRMWARE_SET_GPIO_CONFIG = 0x00038043,
92 RPI_FIRMWARE_GET_PERIPH_REG = 0x00030045,
93 RPI_FIRMWARE_SET_PERIPH_REG = 0x00038045,
94 RPI_FIRMWARE_GET_POE_HAT_VAL = 0x00030049,
95 RPI_FIRMWARE_SET_POE_HAT_VAL = 0x00038049,
96 RPI_FIRMWARE_SET_POE_HAT_VAL_OLD = 0x00030050,
97 RPI_FIRMWARE_NOTIFY_XHCI_RESET = 0x00030058,
98 RPI_FIRMWARE_GET_REBOOT_FLAGS = 0x00030064,
99 RPI_FIRMWARE_SET_REBOOT_FLAGS = 0x00038064,
100 RPI_FIRMWARE_NOTIFY_DISPLAY_DONE = 0x00030066,
103 RPI_FIRMWARE_FRAMEBUFFER_ALLOCATE = 0x00040001,
104 RPI_FIRMWARE_FRAMEBUFFER_BLANK = 0x00040002,
105 RPI_FIRMWARE_FRAMEBUFFER_GET_PHYSICAL_WIDTH_HEIGHT = 0x00040003,
106 RPI_FIRMWARE_FRAMEBUFFER_GET_VIRTUAL_WIDTH_HEIGHT = 0x00040004,
107 RPI_FIRMWARE_FRAMEBUFFER_GET_DEPTH = 0x00040005,
108 RPI_FIRMWARE_FRAMEBUFFER_GET_PIXEL_ORDER = 0x00040006,
109 RPI_FIRMWARE_FRAMEBUFFER_GET_ALPHA_MODE = 0x00040007,
110 RPI_FIRMWARE_FRAMEBUFFER_GET_PITCH = 0x00040008,
111 RPI_FIRMWARE_FRAMEBUFFER_GET_VIRTUAL_OFFSET = 0x00040009,
112 RPI_FIRMWARE_FRAMEBUFFER_GET_OVERSCAN = 0x0004000a,
113 RPI_FIRMWARE_FRAMEBUFFER_GET_PALETTE = 0x0004000b,
114 RPI_FIRMWARE_FRAMEBUFFER_GET_LAYER = 0x0004000c,
115 RPI_FIRMWARE_FRAMEBUFFER_GET_TRANSFORM = 0x0004000d,
116 RPI_FIRMWARE_FRAMEBUFFER_GET_VSYNC = 0x0004000e,
117 RPI_FIRMWARE_FRAMEBUFFER_GET_TOUCHBUF = 0x0004000f,
118 RPI_FIRMWARE_FRAMEBUFFER_GET_GPIOVIRTBUF = 0x00040010,
119 RPI_FIRMWARE_FRAMEBUFFER_RELEASE = 0x00048001,
120 RPI_FIRMWARE_FRAMEBUFFER_GET_DISPLAY_ID = 0x00040016,
121 RPI_FIRMWARE_FRAMEBUFFER_SET_DISPLAY_NUM = 0x00048013,
122 RPI_FIRMWARE_FRAMEBUFFER_GET_NUM_DISPLAYS = 0x00040013,
123 RPI_FIRMWARE_FRAMEBUFFER_GET_DISPLAY_SETTINGS = 0x00040014,
124 RPI_FIRMWARE_FRAMEBUFFER_TEST_PHYSICAL_WIDTH_HEIGHT = 0x00044003,
125 RPI_FIRMWARE_FRAMEBUFFER_TEST_VIRTUAL_WIDTH_HEIGHT = 0x00044004,
126 RPI_FIRMWARE_FRAMEBUFFER_TEST_DEPTH = 0x00044005,
127 RPI_FIRMWARE_FRAMEBUFFER_TEST_PIXEL_ORDER = 0x00044006,
128 RPI_FIRMWARE_FRAMEBUFFER_TEST_ALPHA_MODE = 0x00044007,
129 RPI_FIRMWARE_FRAMEBUFFER_TEST_VIRTUAL_OFFSET = 0x00044009,
130 RPI_FIRMWARE_FRAMEBUFFER_TEST_OVERSCAN = 0x0004400a,
131 RPI_FIRMWARE_FRAMEBUFFER_TEST_PALETTE = 0x0004400b,
132 RPI_FIRMWARE_FRAMEBUFFER_TEST_LAYER = 0x0004400c,
133 RPI_FIRMWARE_FRAMEBUFFER_TEST_TRANSFORM = 0x0004400d,
134 RPI_FIRMWARE_FRAMEBUFFER_TEST_VSYNC = 0x0004400e,
135 RPI_FIRMWARE_FRAMEBUFFER_SET_PHYSICAL_WIDTH_HEIGHT = 0x00048003,
136 RPI_FIRMWARE_FRAMEBUFFER_SET_VIRTUAL_WIDTH_HEIGHT = 0x00048004,
137 RPI_FIRMWARE_FRAMEBUFFER_SET_DEPTH = 0x00048005,
138 RPI_FIRMWARE_FRAMEBUFFER_SET_PIXEL_ORDER = 0x00048006,
139 RPI_FIRMWARE_FRAMEBUFFER_SET_ALPHA_MODE = 0x00048007,
140 RPI_FIRMWARE_FRAMEBUFFER_SET_PITCH = 0x00048008,
141 RPI_FIRMWARE_FRAMEBUFFER_SET_VIRTUAL_OFFSET = 0x00048009,
142 RPI_FIRMWARE_FRAMEBUFFER_SET_OVERSCAN = 0x0004800a,
143 RPI_FIRMWARE_FRAMEBUFFER_SET_PALETTE = 0x0004800b,
145 RPI_FIRMWARE_FRAMEBUFFER_SET_TOUCHBUF = 0x0004801f,
146 RPI_FIRMWARE_FRAMEBUFFER_SET_GPIOVIRTBUF = 0x00048020,
147 RPI_FIRMWARE_FRAMEBUFFER_SET_VSYNC = 0x0004800e,
148 RPI_FIRMWARE_FRAMEBUFFER_SET_LAYER = 0x0004800c,
149 RPI_FIRMWARE_FRAMEBUFFER_SET_TRANSFORM = 0x0004800d,
150 RPI_FIRMWARE_FRAMEBUFFER_SET_BACKLIGHT = 0x0004800f,
152 RPI_FIRMWARE_VCHIQ_INIT = 0x00048010,
154 RPI_FIRMWARE_SET_PLANE = 0x00048015,
155 RPI_FIRMWARE_GET_DISPLAY_TIMING = 0x00040017,
156 RPI_FIRMWARE_SET_TIMING = 0x00048017,
157 RPI_FIRMWARE_GET_DISPLAY_CFG = 0x00040018,
158 RPI_FIRMWARE_SET_DISPLAY_POWER = 0x00048019,
159 RPI_FIRMWARE_GET_COMMAND_LINE = 0x00050001,
160 RPI_FIRMWARE_GET_DMA_CHANNELS = 0x00060001,
163 #define GET_DISPLAY_SETTINGS_PAYLOAD_SIZE 64
165 #if IS_ENABLED(CONFIG_RASPBERRYPI_FIRMWARE)
166 int rpi_firmware_property(struct rpi_firmware *fw,
167 u32 tag, void *data, size_t len);
168 int rpi_firmware_property_list(struct rpi_firmware *fw,
169 void *data, size_t tag_size);
170 void rpi_firmware_put(struct rpi_firmware *fw);
171 struct rpi_firmware *rpi_firmware_get(struct device_node *firmware_node);
172 struct rpi_firmware *devm_rpi_firmware_get(struct device *dev,
173 struct device_node *firmware_node);
175 static inline int rpi_firmware_property(struct rpi_firmware *fw, u32 tag,
176 void *data, size_t len)
181 static inline int rpi_firmware_property_list(struct rpi_firmware *fw,
182 void *data, size_t tag_size)
187 static inline void rpi_firmware_put(struct rpi_firmware *fw) { }
188 static inline struct rpi_firmware *rpi_firmware_get(struct device_node *firmware_node)
193 static inline struct rpi_firmware *devm_rpi_firmware_get(struct device *dev,
194 struct device_node *firmware_node)
200 #endif /* __SOC_RASPBERRY_FIRMWARE_H__ */