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, 9439feb6e7SMaxime Ripard RPI_FIRMWARE_NOTIFY_DISPLAY_DONE = 0x00030066, 954e3d6065SEric Anholt 964e3d6065SEric Anholt /* Dispmanx TAGS */ 974e3d6065SEric Anholt RPI_FIRMWARE_FRAMEBUFFER_ALLOCATE = 0x00040001, 984e3d6065SEric Anholt RPI_FIRMWARE_FRAMEBUFFER_BLANK = 0x00040002, 994e3d6065SEric Anholt RPI_FIRMWARE_FRAMEBUFFER_GET_PHYSICAL_WIDTH_HEIGHT = 0x00040003, 1004e3d6065SEric Anholt RPI_FIRMWARE_FRAMEBUFFER_GET_VIRTUAL_WIDTH_HEIGHT = 0x00040004, 1014e3d6065SEric Anholt RPI_FIRMWARE_FRAMEBUFFER_GET_DEPTH = 0x00040005, 1024e3d6065SEric Anholt RPI_FIRMWARE_FRAMEBUFFER_GET_PIXEL_ORDER = 0x00040006, 1034e3d6065SEric Anholt RPI_FIRMWARE_FRAMEBUFFER_GET_ALPHA_MODE = 0x00040007, 1044e3d6065SEric Anholt RPI_FIRMWARE_FRAMEBUFFER_GET_PITCH = 0x00040008, 1054e3d6065SEric Anholt RPI_FIRMWARE_FRAMEBUFFER_GET_VIRTUAL_OFFSET = 0x00040009, 1064e3d6065SEric Anholt RPI_FIRMWARE_FRAMEBUFFER_GET_OVERSCAN = 0x0004000a, 1074e3d6065SEric Anholt RPI_FIRMWARE_FRAMEBUFFER_GET_PALETTE = 0x0004000b, 10808af112eSBaruch Siach RPI_FIRMWARE_FRAMEBUFFER_GET_TOUCHBUF = 0x0004000f, 10908af112eSBaruch Siach RPI_FIRMWARE_FRAMEBUFFER_GET_GPIOVIRTBUF = 0x00040010, 1104e3d6065SEric Anholt RPI_FIRMWARE_FRAMEBUFFER_RELEASE = 0x00048001, 1114e3d6065SEric Anholt RPI_FIRMWARE_FRAMEBUFFER_TEST_PHYSICAL_WIDTH_HEIGHT = 0x00044003, 1124e3d6065SEric Anholt RPI_FIRMWARE_FRAMEBUFFER_TEST_VIRTUAL_WIDTH_HEIGHT = 0x00044004, 1134e3d6065SEric Anholt RPI_FIRMWARE_FRAMEBUFFER_TEST_DEPTH = 0x00044005, 1144e3d6065SEric Anholt RPI_FIRMWARE_FRAMEBUFFER_TEST_PIXEL_ORDER = 0x00044006, 1154e3d6065SEric Anholt RPI_FIRMWARE_FRAMEBUFFER_TEST_ALPHA_MODE = 0x00044007, 1164e3d6065SEric Anholt RPI_FIRMWARE_FRAMEBUFFER_TEST_VIRTUAL_OFFSET = 0x00044009, 1174e3d6065SEric Anholt RPI_FIRMWARE_FRAMEBUFFER_TEST_OVERSCAN = 0x0004400a, 1184e3d6065SEric Anholt RPI_FIRMWARE_FRAMEBUFFER_TEST_PALETTE = 0x0004400b, 11908af112eSBaruch Siach RPI_FIRMWARE_FRAMEBUFFER_TEST_VSYNC = 0x0004400e, 1204e3d6065SEric Anholt RPI_FIRMWARE_FRAMEBUFFER_SET_PHYSICAL_WIDTH_HEIGHT = 0x00048003, 1214e3d6065SEric Anholt RPI_FIRMWARE_FRAMEBUFFER_SET_VIRTUAL_WIDTH_HEIGHT = 0x00048004, 1224e3d6065SEric Anholt RPI_FIRMWARE_FRAMEBUFFER_SET_DEPTH = 0x00048005, 1234e3d6065SEric Anholt RPI_FIRMWARE_FRAMEBUFFER_SET_PIXEL_ORDER = 0x00048006, 1244e3d6065SEric Anholt RPI_FIRMWARE_FRAMEBUFFER_SET_ALPHA_MODE = 0x00048007, 1254e3d6065SEric Anholt RPI_FIRMWARE_FRAMEBUFFER_SET_VIRTUAL_OFFSET = 0x00048009, 1264e3d6065SEric Anholt RPI_FIRMWARE_FRAMEBUFFER_SET_OVERSCAN = 0x0004800a, 1274e3d6065SEric Anholt RPI_FIRMWARE_FRAMEBUFFER_SET_PALETTE = 0x0004800b, 12808af112eSBaruch Siach RPI_FIRMWARE_FRAMEBUFFER_SET_TOUCHBUF = 0x0004801f, 12908af112eSBaruch Siach RPI_FIRMWARE_FRAMEBUFFER_SET_GPIOVIRTBUF = 0x00048020, 13008af112eSBaruch Siach RPI_FIRMWARE_FRAMEBUFFER_SET_VSYNC = 0x0004800e, 13108af112eSBaruch Siach RPI_FIRMWARE_FRAMEBUFFER_SET_BACKLIGHT = 0x0004800f, 1324e3d6065SEric Anholt 133e0cb3509SEric Anholt RPI_FIRMWARE_VCHIQ_INIT = 0x00048010, 134e0cb3509SEric Anholt 1354e3d6065SEric Anholt RPI_FIRMWARE_GET_COMMAND_LINE = 0x00050001, 1364e3d6065SEric Anholt RPI_FIRMWARE_GET_DMA_CHANNELS = 0x00060001, 1374e3d6065SEric Anholt }; 1384e3d6065SEric Anholt 139d0cde9b3SMaxime Ripard enum rpi_firmware_clk_id { 140d0cde9b3SMaxime Ripard RPI_FIRMWARE_EMMC_CLK_ID = 1, 141d0cde9b3SMaxime Ripard RPI_FIRMWARE_UART_CLK_ID, 142d0cde9b3SMaxime Ripard RPI_FIRMWARE_ARM_CLK_ID, 143d0cde9b3SMaxime Ripard RPI_FIRMWARE_CORE_CLK_ID, 144d0cde9b3SMaxime Ripard RPI_FIRMWARE_V3D_CLK_ID, 145d0cde9b3SMaxime Ripard RPI_FIRMWARE_H264_CLK_ID, 146d0cde9b3SMaxime Ripard RPI_FIRMWARE_ISP_CLK_ID, 147d0cde9b3SMaxime Ripard RPI_FIRMWARE_SDRAM_CLK_ID, 148d0cde9b3SMaxime Ripard RPI_FIRMWARE_PIXEL_CLK_ID, 149d0cde9b3SMaxime Ripard RPI_FIRMWARE_PWM_CLK_ID, 150d0cde9b3SMaxime Ripard RPI_FIRMWARE_HEVC_CLK_ID, 151d0cde9b3SMaxime Ripard RPI_FIRMWARE_EMMC2_CLK_ID, 152d0cde9b3SMaxime Ripard RPI_FIRMWARE_M2MC_CLK_ID, 153d0cde9b3SMaxime Ripard RPI_FIRMWARE_PIXEL_BVB_CLK_ID, 154d0cde9b3SMaxime Ripard RPI_FIRMWARE_VEC_CLK_ID, 155d0cde9b3SMaxime Ripard RPI_FIRMWARE_NUM_CLK_ID, 156d0cde9b3SMaxime Ripard }; 157d0cde9b3SMaxime Ripard 15840c31955SMaxime Ripard /** 15940c31955SMaxime Ripard * struct rpi_firmware_clk_rate_request - Firmware Request for a rate 16040c31955SMaxime Ripard * @id: ID of the clock being queried 16140c31955SMaxime Ripard * @rate: Rate in Hertz. Set by the firmware. 16240c31955SMaxime Ripard * 16340c31955SMaxime Ripard * Used by @RPI_FIRMWARE_GET_CLOCK_RATE, @RPI_FIRMWARE_GET_CLOCK_MEASURED, 16440c31955SMaxime Ripard * @RPI_FIRMWARE_GET_MAX_CLOCK_RATE and @RPI_FIRMWARE_GET_MIN_CLOCK_RATE. 16540c31955SMaxime Ripard */ 16640c31955SMaxime Ripard struct rpi_firmware_clk_rate_request { 16740c31955SMaxime Ripard __le32 id; 16840c31955SMaxime Ripard __le32 rate; 16940c31955SMaxime Ripard } __packed; 17040c31955SMaxime Ripard 17140c31955SMaxime Ripard #define RPI_FIRMWARE_CLK_RATE_REQUEST(_id) \ 17240c31955SMaxime Ripard { \ 173*a1904fa4SMaxime Ripard .id = cpu_to_le32(_id), \ 17440c31955SMaxime Ripard } 17540c31955SMaxime Ripard 176d45f1a56SGreg Kroah-Hartman #if IS_ENABLED(CONFIG_RASPBERRYPI_FIRMWARE) 1774e3d6065SEric Anholt int rpi_firmware_property(struct rpi_firmware *fw, 1784e3d6065SEric Anholt u32 tag, void *data, size_t len); 1794e3d6065SEric Anholt int rpi_firmware_property_list(struct rpi_firmware *fw, 1804e3d6065SEric Anholt void *data, size_t tag_size); 1811e7c5735SNicolas Saenz Julienne void rpi_firmware_put(struct rpi_firmware *fw); 18240c31955SMaxime Ripard unsigned int rpi_firmware_clk_get_max_rate(struct rpi_firmware *fw, 18340c31955SMaxime Ripard unsigned int id); 184bc63897bSMaxime Ripard struct device_node *rpi_firmware_find_node(void); 1854e3d6065SEric Anholt struct rpi_firmware *rpi_firmware_get(struct device_node *firmware_node); 186f663204cSNicolas Saenz Julienne struct rpi_firmware *devm_rpi_firmware_get(struct device *dev, 187f663204cSNicolas Saenz Julienne struct device_node *firmware_node); 188d45f1a56SGreg Kroah-Hartman #else 189d45f1a56SGreg Kroah-Hartman static inline int rpi_firmware_property(struct rpi_firmware *fw, u32 tag, 190d45f1a56SGreg Kroah-Hartman void *data, size_t len) 191d45f1a56SGreg Kroah-Hartman { 192144345a4SGeert Uytterhoeven return -ENOSYS; 193d45f1a56SGreg Kroah-Hartman } 194d45f1a56SGreg Kroah-Hartman 195d45f1a56SGreg Kroah-Hartman static inline int rpi_firmware_property_list(struct rpi_firmware *fw, 196d45f1a56SGreg Kroah-Hartman void *data, size_t tag_size) 197d45f1a56SGreg Kroah-Hartman { 198144345a4SGeert Uytterhoeven return -ENOSYS; 199d45f1a56SGreg Kroah-Hartman } 200d45f1a56SGreg Kroah-Hartman 2011e7c5735SNicolas Saenz Julienne static inline void rpi_firmware_put(struct rpi_firmware *fw) { } 202bc63897bSMaxime Ripard 20340c31955SMaxime Ripard static inline unsigned int rpi_firmware_clk_get_max_rate(struct rpi_firmware *fw, 20440c31955SMaxime Ripard unsigned int id) 20540c31955SMaxime Ripard { 20640c31955SMaxime Ripard return UINT_MAX; 20740c31955SMaxime Ripard } 20840c31955SMaxime Ripard 209bc63897bSMaxime Ripard static inline struct device_node *rpi_firmware_find_node(void) 210bc63897bSMaxime Ripard { 211bc63897bSMaxime Ripard return NULL; 212bc63897bSMaxime Ripard } 213bc63897bSMaxime Ripard 214d45f1a56SGreg Kroah-Hartman static inline struct rpi_firmware *rpi_firmware_get(struct device_node *firmware_node) 215d45f1a56SGreg Kroah-Hartman { 216d45f1a56SGreg Kroah-Hartman return NULL; 217d45f1a56SGreg Kroah-Hartman } 218f663204cSNicolas Saenz Julienne 219f663204cSNicolas Saenz Julienne static inline struct rpi_firmware *devm_rpi_firmware_get(struct device *dev, 220f663204cSNicolas Saenz Julienne struct device_node *firmware_node) 221f663204cSNicolas Saenz Julienne { 222f663204cSNicolas Saenz Julienne return NULL; 223f663204cSNicolas Saenz Julienne } 224d45f1a56SGreg Kroah-Hartman #endif 22516134b3bSAlexander Aring 22616134b3bSAlexander Aring #endif /* __SOC_RASPBERRY_FIRMWARE_H__ */ 227