1 /*
2  * Raspberry Pi firmware definitions
3  *
4  * Copyright (C) 2022  Auriga LLC, based on Linux kernel
5  *   `include/soc/bcm2835/raspberrypi-firmware.h` (Copyright © 2015 Broadcom)
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  */
9 
10 #ifndef INCLUDE_HW_MISC_RASPBERRYPI_FW_DEFS_H_
11 #define INCLUDE_HW_MISC_RASPBERRYPI_FW_DEFS_H_
12 
13 
14 enum rpi_firmware_property_tag {
15     RPI_FWREQ_PROPERTY_END =                           0,
16     RPI_FWREQ_GET_FIRMWARE_REVISION =                  0x00000001,
17     RPI_FWREQ_GET_FIRMWARE_VARIANT =                   0x00000002,
18     RPI_FWREQ_GET_FIRMWARE_HASH =                      0x00000003,
19 
20     RPI_FWREQ_SET_CURSOR_INFO =                        0x00008010,
21     RPI_FWREQ_SET_CURSOR_STATE =                       0x00008011,
22 
23     RPI_FWREQ_GET_BOARD_MODEL =                        0x00010001,
24     RPI_FWREQ_GET_BOARD_REVISION =                     0x00010002,
25     RPI_FWREQ_GET_BOARD_MAC_ADDRESS =                  0x00010003,
26     RPI_FWREQ_GET_BOARD_SERIAL =                       0x00010004,
27     RPI_FWREQ_GET_ARM_MEMORY =                         0x00010005,
28     RPI_FWREQ_GET_VC_MEMORY =                          0x00010006,
29     RPI_FWREQ_GET_CLOCKS =                             0x00010007,
30     RPI_FWREQ_GET_POWER_STATE =                        0x00020001,
31     RPI_FWREQ_GET_TIMING =                             0x00020002,
32     RPI_FWREQ_SET_POWER_STATE =                        0x00028001,
33     RPI_FWREQ_GET_CLOCK_STATE =                        0x00030001,
34     RPI_FWREQ_GET_CLOCK_RATE =                         0x00030002,
35     RPI_FWREQ_GET_VOLTAGE =                            0x00030003,
36     RPI_FWREQ_GET_MAX_CLOCK_RATE =                     0x00030004,
37     RPI_FWREQ_GET_MAX_VOLTAGE =                        0x00030005,
38     RPI_FWREQ_GET_TEMPERATURE =                        0x00030006,
39     RPI_FWREQ_GET_MIN_CLOCK_RATE =                     0x00030007,
40     RPI_FWREQ_GET_MIN_VOLTAGE =                        0x00030008,
41     RPI_FWREQ_GET_TURBO =                              0x00030009,
42     RPI_FWREQ_GET_MAX_TEMPERATURE =                    0x0003000a,
43     RPI_FWREQ_GET_STC =                                0x0003000b,
44     RPI_FWREQ_ALLOCATE_MEMORY =                        0x0003000c,
45     RPI_FWREQ_LOCK_MEMORY =                            0x0003000d,
46     RPI_FWREQ_UNLOCK_MEMORY =                          0x0003000e,
47     RPI_FWREQ_RELEASE_MEMORY =                         0x0003000f,
48     RPI_FWREQ_EXECUTE_CODE =                           0x00030010,
49     RPI_FWREQ_EXECUTE_QPU =                            0x00030011,
50     RPI_FWREQ_SET_ENABLE_QPU =                         0x00030012,
51     RPI_FWREQ_GET_DISPMANX_RESOURCE_MEM_HANDLE =       0x00030014,
52     RPI_FWREQ_GET_EDID_BLOCK =                         0x00030020,
53     RPI_FWREQ_GET_CUSTOMER_OTP =                       0x00030021,
54     RPI_FWREQ_GET_EDID_BLOCK_DISPLAY =                 0x00030023,
55     RPI_FWREQ_GET_DOMAIN_STATE =                       0x00030030,
56     RPI_FWREQ_GET_THROTTLED =                          0x00030046,
57     RPI_FWREQ_GET_CLOCK_MEASURED =                     0x00030047,
58     RPI_FWREQ_NOTIFY_REBOOT =                          0x00030048,
59     RPI_FWREQ_GET_PRIVATE_KEY =                        0x00030081,
60     RPI_FWREQ_SET_CLOCK_STATE =                        0x00038001,
61     RPI_FWREQ_SET_CLOCK_RATE =                         0x00038002,
62     RPI_FWREQ_SET_VOLTAGE =                            0x00038003,
63     RPI_FWREQ_SET_MAX_CLOCK_RATE =                     0x00038004,
64     RPI_FWREQ_SET_MIN_CLOCK_RATE =                     0x00038007,
65     RPI_FWREQ_SET_TURBO =                              0x00038009,
66     RPI_FWREQ_SET_CUSTOMER_OTP =                       0x00038021,
67     RPI_FWREQ_SET_DOMAIN_STATE =                       0x00038030,
68     RPI_FWREQ_GET_GPIO_STATE =                         0x00030041,
69     RPI_FWREQ_SET_GPIO_STATE =                         0x00038041,
70     RPI_FWREQ_SET_SDHOST_CLOCK =                       0x00038042,
71     RPI_FWREQ_GET_GPIO_CONFIG =                        0x00030043,
72     RPI_FWREQ_SET_GPIO_CONFIG =                        0x00038043,
73     RPI_FWREQ_GET_PERIPH_REG =                         0x00030045,
74     RPI_FWREQ_SET_PERIPH_REG =                         0x00038045,
75     RPI_FWREQ_GET_POE_HAT_VAL =                        0x00030049,
76     RPI_FWREQ_SET_POE_HAT_VAL =                        0x00038049,
77     RPI_FWREQ_SET_PRIVATE_KEY =                        0x00038081,
78     RPI_FWREQ_SET_POE_HAT_VAL_OLD =                    0x00030050,
79     RPI_FWREQ_NOTIFY_XHCI_RESET =                      0x00030058,
80     RPI_FWREQ_GET_REBOOT_FLAGS =                       0x00030064,
81     RPI_FWREQ_SET_REBOOT_FLAGS =                       0x00038064,
82     RPI_FWREQ_NOTIFY_DISPLAY_DONE =                    0x00030066,
83 
84     /* Dispmanx TAGS */
85     RPI_FWREQ_FRAMEBUFFER_ALLOCATE =                   0x00040001,
86     RPI_FWREQ_FRAMEBUFFER_BLANK =                      0x00040002,
87     RPI_FWREQ_FRAMEBUFFER_GET_PHYSICAL_WIDTH_HEIGHT =  0x00040003,
88     RPI_FWREQ_FRAMEBUFFER_GET_VIRTUAL_WIDTH_HEIGHT =   0x00040004,
89     RPI_FWREQ_FRAMEBUFFER_GET_DEPTH =                  0x00040005,
90     RPI_FWREQ_FRAMEBUFFER_GET_PIXEL_ORDER =            0x00040006,
91     RPI_FWREQ_FRAMEBUFFER_GET_ALPHA_MODE =             0x00040007,
92     RPI_FWREQ_FRAMEBUFFER_GET_PITCH =                  0x00040008,
93     RPI_FWREQ_FRAMEBUFFER_GET_VIRTUAL_OFFSET =         0x00040009,
94     RPI_FWREQ_FRAMEBUFFER_GET_OVERSCAN =               0x0004000a,
95     RPI_FWREQ_FRAMEBUFFER_GET_PALETTE =                0x0004000b,
96     RPI_FWREQ_FRAMEBUFFER_GET_LAYER =                  0x0004000c,
97     RPI_FWREQ_FRAMEBUFFER_GET_TRANSFORM =              0x0004000d,
98     RPI_FWREQ_FRAMEBUFFER_GET_VSYNC =                  0x0004000e,
99     RPI_FWREQ_FRAMEBUFFER_GET_TOUCHBUF =               0x0004000f,
100     RPI_FWREQ_FRAMEBUFFER_GET_GPIOVIRTBUF =            0x00040010,
101     RPI_FWREQ_FRAMEBUFFER_RELEASE =                    0x00048001,
102     RPI_FWREQ_FRAMEBUFFER_GET_DISPLAY_ID =             0x00040016,
103     RPI_FWREQ_FRAMEBUFFER_SET_DISPLAY_NUM =            0x00048013,
104     RPI_FWREQ_FRAMEBUFFER_GET_NUM_DISPLAYS =           0x00040013,
105     RPI_FWREQ_FRAMEBUFFER_GET_DISPLAY_SETTINGS =       0x00040014,
106     RPI_FWREQ_FRAMEBUFFER_TEST_PHYSICAL_WIDTH_HEIGHT = 0x00044003,
107     RPI_FWREQ_FRAMEBUFFER_TEST_VIRTUAL_WIDTH_HEIGHT =  0x00044004,
108     RPI_FWREQ_FRAMEBUFFER_TEST_DEPTH =                 0x00044005,
109     RPI_FWREQ_FRAMEBUFFER_TEST_PIXEL_ORDER =           0x00044006,
110     RPI_FWREQ_FRAMEBUFFER_TEST_ALPHA_MODE =            0x00044007,
111     RPI_FWREQ_FRAMEBUFFER_TEST_VIRTUAL_OFFSET =        0x00044009,
112     RPI_FWREQ_FRAMEBUFFER_TEST_OVERSCAN =              0x0004400a,
113     RPI_FWREQ_FRAMEBUFFER_TEST_PALETTE =               0x0004400b,
114     RPI_FWREQ_FRAMEBUFFER_TEST_LAYER =                 0x0004400c,
115     RPI_FWREQ_FRAMEBUFFER_TEST_TRANSFORM =             0x0004400d,
116     RPI_FWREQ_FRAMEBUFFER_TEST_VSYNC =                 0x0004400e,
117     RPI_FWREQ_FRAMEBUFFER_SET_PHYSICAL_WIDTH_HEIGHT =  0x00048003,
118     RPI_FWREQ_FRAMEBUFFER_SET_VIRTUAL_WIDTH_HEIGHT =   0x00048004,
119     RPI_FWREQ_FRAMEBUFFER_SET_DEPTH =                  0x00048005,
120     RPI_FWREQ_FRAMEBUFFER_SET_PIXEL_ORDER =            0x00048006,
121     RPI_FWREQ_FRAMEBUFFER_SET_ALPHA_MODE =             0x00048007,
122     RPI_FWREQ_FRAMEBUFFER_SET_PITCH =                  0x00048008,
123     RPI_FWREQ_FRAMEBUFFER_SET_VIRTUAL_OFFSET =         0x00048009,
124     RPI_FWREQ_FRAMEBUFFER_SET_OVERSCAN =               0x0004800a,
125     RPI_FWREQ_FRAMEBUFFER_SET_PALETTE =                0x0004800b,
126 
127     RPI_FWREQ_FRAMEBUFFER_SET_TOUCHBUF =               0x0004801f,
128     RPI_FWREQ_FRAMEBUFFER_SET_GPIOVIRTBUF =            0x00048020,
129     RPI_FWREQ_FRAMEBUFFER_SET_VSYNC =                  0x0004800e,
130     RPI_FWREQ_FRAMEBUFFER_SET_LAYER =                  0x0004800c,
131     RPI_FWREQ_FRAMEBUFFER_SET_TRANSFORM =              0x0004800d,
132     RPI_FWREQ_FRAMEBUFFER_SET_BACKLIGHT =              0x0004800f,
133 
134     RPI_FWREQ_VCHIQ_INIT =                             0x00048010,
135 
136     RPI_FWREQ_SET_PLANE =                              0x00048015,
137     RPI_FWREQ_GET_DISPLAY_TIMING =                     0x00040017,
138     RPI_FWREQ_SET_TIMING =                             0x00048017,
139     RPI_FWREQ_GET_DISPLAY_CFG =                        0x00040018,
140     RPI_FWREQ_SET_DISPLAY_POWER =                      0x00048019,
141     RPI_FWREQ_GET_COMMAND_LINE =                       0x00050001,
142     RPI_FWREQ_GET_DMA_CHANNELS =                       0x00060001,
143 };
144 
145 enum rpi_firmware_clk_id {
146     RPI_FIRMWARE_EMMC_CLK_ID = 1,
147     RPI_FIRMWARE_UART_CLK_ID,
148     RPI_FIRMWARE_ARM_CLK_ID,
149     RPI_FIRMWARE_CORE_CLK_ID,
150     RPI_FIRMWARE_V3D_CLK_ID,
151     RPI_FIRMWARE_H264_CLK_ID,
152     RPI_FIRMWARE_ISP_CLK_ID,
153     RPI_FIRMWARE_SDRAM_CLK_ID,
154     RPI_FIRMWARE_PIXEL_CLK_ID,
155     RPI_FIRMWARE_PWM_CLK_ID,
156     RPI_FIRMWARE_HEVC_CLK_ID,
157     RPI_FIRMWARE_EMMC2_CLK_ID,
158     RPI_FIRMWARE_M2MC_CLK_ID,
159     RPI_FIRMWARE_PIXEL_BVB_CLK_ID,
160     RPI_FIRMWARE_VEC_CLK_ID,
161     RPI_FIRMWARE_NUM_CLK_ID,
162 };
163 
164 struct rpi_firmware_property_tag_header {
165     uint32_t tag;
166     uint32_t buf_size;
167     uint32_t req_resp_size;
168 };
169 
170 typedef struct rpi_firmware_prop_request {
171     struct rpi_firmware_property_tag_header hdr;
172     uint8_t payload[0];
173 } rpi_firmware_prop_request_t;
174 
175 #endif /* INCLUDE_HW_MISC_RASPBERRYPI_FW_DEFS_H_ */
176