xref: /linux/include/soc/bcm2835/raspberrypi-firmware.h (revision f663204c9a1f8d6fcc590667d9d7a9f44e064644)
1502b431cSStefan Wahren /* SPDX-License-Identifier: GPL-2.0 */
24e3d6065SEric Anholt /*
34e3d6065SEric Anholt  *  Copyright © 2015 Broadcom
44e3d6065SEric Anholt  */
54e3d6065SEric Anholt 
616134b3bSAlexander Aring #ifndef __SOC_RASPBERRY_FIRMWARE_H__
716134b3bSAlexander Aring #define __SOC_RASPBERRY_FIRMWARE_H__
816134b3bSAlexander Aring 
94e3d6065SEric Anholt #include <linux/types.h>
104e3d6065SEric Anholt #include <linux/of_device.h>
114e3d6065SEric Anholt 
124e3d6065SEric Anholt struct rpi_firmware;
134e3d6065SEric Anholt 
144e3d6065SEric Anholt enum rpi_firmware_property_status {
154e3d6065SEric Anholt 	RPI_FIRMWARE_STATUS_REQUEST = 0,
164e3d6065SEric Anholt 	RPI_FIRMWARE_STATUS_SUCCESS = 0x80000000,
174e3d6065SEric Anholt 	RPI_FIRMWARE_STATUS_ERROR =   0x80000001,
184e3d6065SEric Anholt };
194e3d6065SEric Anholt 
204e3d6065SEric Anholt /**
214e3d6065SEric Anholt  * struct rpi_firmware_property_tag_header - Firmware property tag header
224e3d6065SEric Anholt  * @tag:		One of enum_mbox_property_tag.
234e3d6065SEric Anholt  * @buf_size:		The number of bytes in the value buffer following this
244e3d6065SEric Anholt  *			struct.
254e3d6065SEric Anholt  * @req_resp_size:	On submit, the length of the request (though it doesn't
264e3d6065SEric Anholt  *			appear to be currently used by the firmware).  On return,
274e3d6065SEric Anholt  *			the length of the response (always 4 byte aligned), with
284e3d6065SEric Anholt  *			the low bit set.
294e3d6065SEric Anholt  */
304e3d6065SEric Anholt struct rpi_firmware_property_tag_header {
314e3d6065SEric Anholt 	u32 tag;
324e3d6065SEric Anholt 	u32 buf_size;
334e3d6065SEric Anholt 	u32 req_resp_size;
344e3d6065SEric Anholt };
354e3d6065SEric Anholt 
364e3d6065SEric Anholt enum rpi_firmware_property_tag {
374e3d6065SEric Anholt 	RPI_FIRMWARE_PROPERTY_END =                           0,
384e3d6065SEric Anholt 	RPI_FIRMWARE_GET_FIRMWARE_REVISION =                  0x00000001,
394e3d6065SEric Anholt 
404e3d6065SEric Anholt 	RPI_FIRMWARE_SET_CURSOR_INFO =                        0x00008010,
414e3d6065SEric Anholt 	RPI_FIRMWARE_SET_CURSOR_STATE =                       0x00008011,
424e3d6065SEric Anholt 
434e3d6065SEric Anholt 	RPI_FIRMWARE_GET_BOARD_MODEL =                        0x00010001,
444e3d6065SEric Anholt 	RPI_FIRMWARE_GET_BOARD_REVISION =                     0x00010002,
454e3d6065SEric Anholt 	RPI_FIRMWARE_GET_BOARD_MAC_ADDRESS =                  0x00010003,
464e3d6065SEric Anholt 	RPI_FIRMWARE_GET_BOARD_SERIAL =                       0x00010004,
474e3d6065SEric Anholt 	RPI_FIRMWARE_GET_ARM_MEMORY =                         0x00010005,
484e3d6065SEric Anholt 	RPI_FIRMWARE_GET_VC_MEMORY =                          0x00010006,
494e3d6065SEric Anholt 	RPI_FIRMWARE_GET_CLOCKS =                             0x00010007,
504e3d6065SEric Anholt 	RPI_FIRMWARE_GET_POWER_STATE =                        0x00020001,
514e3d6065SEric Anholt 	RPI_FIRMWARE_GET_TIMING =                             0x00020002,
524e3d6065SEric Anholt 	RPI_FIRMWARE_SET_POWER_STATE =                        0x00028001,
534e3d6065SEric Anholt 	RPI_FIRMWARE_GET_CLOCK_STATE =                        0x00030001,
544e3d6065SEric Anholt 	RPI_FIRMWARE_GET_CLOCK_RATE =                         0x00030002,
554e3d6065SEric Anholt 	RPI_FIRMWARE_GET_VOLTAGE =                            0x00030003,
564e3d6065SEric Anholt 	RPI_FIRMWARE_GET_MAX_CLOCK_RATE =                     0x00030004,
574e3d6065SEric Anholt 	RPI_FIRMWARE_GET_MAX_VOLTAGE =                        0x00030005,
584e3d6065SEric Anholt 	RPI_FIRMWARE_GET_TEMPERATURE =                        0x00030006,
594e3d6065SEric Anholt 	RPI_FIRMWARE_GET_MIN_CLOCK_RATE =                     0x00030007,
604e3d6065SEric Anholt 	RPI_FIRMWARE_GET_MIN_VOLTAGE =                        0x00030008,
614e3d6065SEric Anholt 	RPI_FIRMWARE_GET_TURBO =                              0x00030009,
624e3d6065SEric Anholt 	RPI_FIRMWARE_GET_MAX_TEMPERATURE =                    0x0003000a,
6308af112eSBaruch Siach 	RPI_FIRMWARE_GET_STC =                                0x0003000b,
644e3d6065SEric Anholt 	RPI_FIRMWARE_ALLOCATE_MEMORY =                        0x0003000c,
654e3d6065SEric Anholt 	RPI_FIRMWARE_LOCK_MEMORY =                            0x0003000d,
664e3d6065SEric Anholt 	RPI_FIRMWARE_UNLOCK_MEMORY =                          0x0003000e,
674e3d6065SEric Anholt 	RPI_FIRMWARE_RELEASE_MEMORY =                         0x0003000f,
684e3d6065SEric Anholt 	RPI_FIRMWARE_EXECUTE_CODE =                           0x00030010,
694e3d6065SEric Anholt 	RPI_FIRMWARE_EXECUTE_QPU =                            0x00030011,
704e3d6065SEric Anholt 	RPI_FIRMWARE_SET_ENABLE_QPU =                         0x00030012,
714e3d6065SEric Anholt 	RPI_FIRMWARE_GET_DISPMANX_RESOURCE_MEM_HANDLE =       0x00030014,
724e3d6065SEric Anholt 	RPI_FIRMWARE_GET_EDID_BLOCK =                         0x00030020,
7308af112eSBaruch Siach 	RPI_FIRMWARE_GET_CUSTOMER_OTP =                       0x00030021,
7460d56333SEric Anholt 	RPI_FIRMWARE_GET_DOMAIN_STATE =                       0x00030030,
75be3035e3SStefan Wahren 	RPI_FIRMWARE_GET_THROTTLED =                          0x00030046,
76c6275e4bSStefan Wahren 	RPI_FIRMWARE_GET_CLOCK_MEASURED =                     0x00030047,
77c6275e4bSStefan Wahren 	RPI_FIRMWARE_NOTIFY_REBOOT =                          0x00030048,
784e3d6065SEric Anholt 	RPI_FIRMWARE_SET_CLOCK_STATE =                        0x00038001,
794e3d6065SEric Anholt 	RPI_FIRMWARE_SET_CLOCK_RATE =                         0x00038002,
804e3d6065SEric Anholt 	RPI_FIRMWARE_SET_VOLTAGE =                            0x00038003,
814e3d6065SEric Anholt 	RPI_FIRMWARE_SET_TURBO =                              0x00038009,
8208af112eSBaruch Siach 	RPI_FIRMWARE_SET_CUSTOMER_OTP =                       0x00038021,
8360d56333SEric Anholt 	RPI_FIRMWARE_SET_DOMAIN_STATE =                       0x00038030,
8408af112eSBaruch Siach 	RPI_FIRMWARE_GET_GPIO_STATE =                         0x00030041,
8508af112eSBaruch Siach 	RPI_FIRMWARE_SET_GPIO_STATE =                         0x00038041,
8608af112eSBaruch Siach 	RPI_FIRMWARE_SET_SDHOST_CLOCK =                       0x00038042,
8708af112eSBaruch Siach 	RPI_FIRMWARE_GET_GPIO_CONFIG =                        0x00030043,
8808af112eSBaruch Siach 	RPI_FIRMWARE_SET_GPIO_CONFIG =                        0x00038043,
8908af112eSBaruch Siach 	RPI_FIRMWARE_GET_PERIPH_REG =                         0x00030045,
9008af112eSBaruch Siach 	RPI_FIRMWARE_SET_PERIPH_REG =                         0x00038045,
91c6275e4bSStefan Wahren 	RPI_FIRMWARE_GET_POE_HAT_VAL =                        0x00030049,
92c6275e4bSStefan Wahren 	RPI_FIRMWARE_SET_POE_HAT_VAL =                        0x00030050,
93ca91ddefSNicolas Saenz Julienne 	RPI_FIRMWARE_NOTIFY_XHCI_RESET =                      0x00030058,
944e3d6065SEric Anholt 
954e3d6065SEric Anholt 	/* Dispmanx TAGS */
964e3d6065SEric Anholt 	RPI_FIRMWARE_FRAMEBUFFER_ALLOCATE =                   0x00040001,
974e3d6065SEric Anholt 	RPI_FIRMWARE_FRAMEBUFFER_BLANK =                      0x00040002,
984e3d6065SEric Anholt 	RPI_FIRMWARE_FRAMEBUFFER_GET_PHYSICAL_WIDTH_HEIGHT =  0x00040003,
994e3d6065SEric Anholt 	RPI_FIRMWARE_FRAMEBUFFER_GET_VIRTUAL_WIDTH_HEIGHT =   0x00040004,
1004e3d6065SEric Anholt 	RPI_FIRMWARE_FRAMEBUFFER_GET_DEPTH =                  0x00040005,
1014e3d6065SEric Anholt 	RPI_FIRMWARE_FRAMEBUFFER_GET_PIXEL_ORDER =            0x00040006,
1024e3d6065SEric Anholt 	RPI_FIRMWARE_FRAMEBUFFER_GET_ALPHA_MODE =             0x00040007,
1034e3d6065SEric Anholt 	RPI_FIRMWARE_FRAMEBUFFER_GET_PITCH =                  0x00040008,
1044e3d6065SEric Anholt 	RPI_FIRMWARE_FRAMEBUFFER_GET_VIRTUAL_OFFSET =         0x00040009,
1054e3d6065SEric Anholt 	RPI_FIRMWARE_FRAMEBUFFER_GET_OVERSCAN =               0x0004000a,
1064e3d6065SEric Anholt 	RPI_FIRMWARE_FRAMEBUFFER_GET_PALETTE =                0x0004000b,
10708af112eSBaruch Siach 	RPI_FIRMWARE_FRAMEBUFFER_GET_TOUCHBUF =               0x0004000f,
10808af112eSBaruch Siach 	RPI_FIRMWARE_FRAMEBUFFER_GET_GPIOVIRTBUF =            0x00040010,
1094e3d6065SEric Anholt 	RPI_FIRMWARE_FRAMEBUFFER_RELEASE =                    0x00048001,
1104e3d6065SEric Anholt 	RPI_FIRMWARE_FRAMEBUFFER_TEST_PHYSICAL_WIDTH_HEIGHT = 0x00044003,
1114e3d6065SEric Anholt 	RPI_FIRMWARE_FRAMEBUFFER_TEST_VIRTUAL_WIDTH_HEIGHT =  0x00044004,
1124e3d6065SEric Anholt 	RPI_FIRMWARE_FRAMEBUFFER_TEST_DEPTH =                 0x00044005,
1134e3d6065SEric Anholt 	RPI_FIRMWARE_FRAMEBUFFER_TEST_PIXEL_ORDER =           0x00044006,
1144e3d6065SEric Anholt 	RPI_FIRMWARE_FRAMEBUFFER_TEST_ALPHA_MODE =            0x00044007,
1154e3d6065SEric Anholt 	RPI_FIRMWARE_FRAMEBUFFER_TEST_VIRTUAL_OFFSET =        0x00044009,
1164e3d6065SEric Anholt 	RPI_FIRMWARE_FRAMEBUFFER_TEST_OVERSCAN =              0x0004400a,
1174e3d6065SEric Anholt 	RPI_FIRMWARE_FRAMEBUFFER_TEST_PALETTE =               0x0004400b,
11808af112eSBaruch Siach 	RPI_FIRMWARE_FRAMEBUFFER_TEST_VSYNC =                 0x0004400e,
1194e3d6065SEric Anholt 	RPI_FIRMWARE_FRAMEBUFFER_SET_PHYSICAL_WIDTH_HEIGHT =  0x00048003,
1204e3d6065SEric Anholt 	RPI_FIRMWARE_FRAMEBUFFER_SET_VIRTUAL_WIDTH_HEIGHT =   0x00048004,
1214e3d6065SEric Anholt 	RPI_FIRMWARE_FRAMEBUFFER_SET_DEPTH =                  0x00048005,
1224e3d6065SEric Anholt 	RPI_FIRMWARE_FRAMEBUFFER_SET_PIXEL_ORDER =            0x00048006,
1234e3d6065SEric Anholt 	RPI_FIRMWARE_FRAMEBUFFER_SET_ALPHA_MODE =             0x00048007,
1244e3d6065SEric Anholt 	RPI_FIRMWARE_FRAMEBUFFER_SET_VIRTUAL_OFFSET =         0x00048009,
1254e3d6065SEric Anholt 	RPI_FIRMWARE_FRAMEBUFFER_SET_OVERSCAN =               0x0004800a,
1264e3d6065SEric Anholt 	RPI_FIRMWARE_FRAMEBUFFER_SET_PALETTE =                0x0004800b,
12708af112eSBaruch Siach 	RPI_FIRMWARE_FRAMEBUFFER_SET_TOUCHBUF =               0x0004801f,
12808af112eSBaruch Siach 	RPI_FIRMWARE_FRAMEBUFFER_SET_GPIOVIRTBUF =            0x00048020,
12908af112eSBaruch Siach 	RPI_FIRMWARE_FRAMEBUFFER_SET_VSYNC =                  0x0004800e,
13008af112eSBaruch Siach 	RPI_FIRMWARE_FRAMEBUFFER_SET_BACKLIGHT =              0x0004800f,
1314e3d6065SEric Anholt 
132e0cb3509SEric Anholt 	RPI_FIRMWARE_VCHIQ_INIT =                             0x00048010,
133e0cb3509SEric Anholt 
1344e3d6065SEric Anholt 	RPI_FIRMWARE_GET_COMMAND_LINE =                       0x00050001,
1354e3d6065SEric Anholt 	RPI_FIRMWARE_GET_DMA_CHANNELS =                       0x00060001,
1364e3d6065SEric Anholt };
1374e3d6065SEric Anholt 
138d45f1a56SGreg Kroah-Hartman #if IS_ENABLED(CONFIG_RASPBERRYPI_FIRMWARE)
1394e3d6065SEric Anholt int rpi_firmware_property(struct rpi_firmware *fw,
1404e3d6065SEric Anholt 			  u32 tag, void *data, size_t len);
1414e3d6065SEric Anholt int rpi_firmware_property_list(struct rpi_firmware *fw,
1424e3d6065SEric Anholt 			       void *data, size_t tag_size);
1431e7c5735SNicolas Saenz Julienne void rpi_firmware_put(struct rpi_firmware *fw);
1444e3d6065SEric Anholt struct rpi_firmware *rpi_firmware_get(struct device_node *firmware_node);
145*f663204cSNicolas Saenz Julienne struct rpi_firmware *devm_rpi_firmware_get(struct device *dev,
146*f663204cSNicolas Saenz Julienne 					   struct device_node *firmware_node);
147d45f1a56SGreg Kroah-Hartman #else
148d45f1a56SGreg Kroah-Hartman static inline int rpi_firmware_property(struct rpi_firmware *fw, u32 tag,
149d45f1a56SGreg Kroah-Hartman 					void *data, size_t len)
150d45f1a56SGreg Kroah-Hartman {
151144345a4SGeert Uytterhoeven 	return -ENOSYS;
152d45f1a56SGreg Kroah-Hartman }
153d45f1a56SGreg Kroah-Hartman 
154d45f1a56SGreg Kroah-Hartman static inline int rpi_firmware_property_list(struct rpi_firmware *fw,
155d45f1a56SGreg Kroah-Hartman 					     void *data, size_t tag_size)
156d45f1a56SGreg Kroah-Hartman {
157144345a4SGeert Uytterhoeven 	return -ENOSYS;
158d45f1a56SGreg Kroah-Hartman }
159d45f1a56SGreg Kroah-Hartman 
1601e7c5735SNicolas Saenz Julienne static inline void rpi_firmware_put(struct rpi_firmware *fw) { }
161d45f1a56SGreg Kroah-Hartman static inline struct rpi_firmware *rpi_firmware_get(struct device_node *firmware_node)
162d45f1a56SGreg Kroah-Hartman {
163d45f1a56SGreg Kroah-Hartman 	return NULL;
164d45f1a56SGreg Kroah-Hartman }
165*f663204cSNicolas Saenz Julienne 
166*f663204cSNicolas Saenz Julienne static inline struct rpi_firmware *devm_rpi_firmware_get(struct device *dev,
167*f663204cSNicolas Saenz Julienne 					struct device_node *firmware_node)
168*f663204cSNicolas Saenz Julienne {
169*f663204cSNicolas Saenz Julienne 	return NULL;
170*f663204cSNicolas Saenz Julienne }
171d45f1a56SGreg Kroah-Hartman #endif
17216134b3bSAlexander Aring 
17316134b3bSAlexander Aring #endif /* __SOC_RASPBERRY_FIRMWARE_H__ */
174