Merge pull request #3901 from bigmagic123/raspi_add_mbox

Raspi add mbox
This commit is contained in:
Bernard Xiong authored and GitHub committed 2020-09-15 16:59:50 +08:00
commit 0908df39e7
7 files changed
+621 -13

No files matched your search

+10 -6
View File
@@ -125,9 +125,13 @@ msh />
| Drive | Support | Remark |
| -------------- | ------- | ------ |
| UART | Support | UART0 |
| GPIO | Support | |
| IIC | Support | |
| SPI | Support | |
| CPU Timer | Support | |
| SD card driver | Support | |
| GPIO | Support | - |
| IIC | Support | - |
| SPI | Support | - |
| CPU Timer | Support | - |
| SD card driver | Support | - |
| RTC | Support | - |
| WDT | Support | - |
| MAILBOX | Support | - |
| SMP | Support | - |
| FRAMEBUFFER | Support | HDMI |
+10 -5
View File
@@ -136,11 +136,16 @@ msh />
| 驱动 | 支持情况 | 备注 |
| ------ | ---- | :------: |
| UART | 支持 | UART0|
| GPIO | 支持 | |
| IIC | 支持 | |
| SPI | 支持 | |
| CPU Timer | 支持 | |
| SD卡驱动 | 支持 | |
| GPIO | 支持 | - |
| IIC | 支持 | - |
| SPI | 支持 | - |
| CPU Timer | 支持 | - |
| SD卡驱动 | 支持 | - |
| RTC | 支持 | - |
| WDT | 支持 | - |
| MAILBOX | 支持 | - |
| SMP | 支持 | - |
| FRAMEBUFFER | 支持 | HDMI |
## 5. 联系人信息
+9
View File
@@ -78,4 +78,13 @@ msh >
| Drive | Support | Remark |
| ----- | ------- | ------ |
| UART | Support | UART0 |
| GPIO | Support | - |
| I2C | Support | - |
| RTC | Support | - |
| SDIO | Support | SDCARD |
| SPI | Support | - |
| TIMER | Support | - |
| WDT | Support | - |
| MBOX | Support | - |
| FRAMEBUFFER | Support | HDMI |
+11 -2
View File
@@ -98,13 +98,22 @@ msh >
| 驱动 | 支持情况 | 备注 |
| ------ | ---- | :------: |
| UART | 支持 | UART0|
| GPIO | 支持 | - |
| I2C | 支持 | - |
| RTC | 支持 | - |
| SDIO | 支持 | SDCARD |
| SPI | 支持 | - |
| TIMER | 支持 | - |
| WDT | 支持 | - |
| MBOX | 支持 | - |
| FRAMEBUFFER | 支持 | HDMI |
## 5. 联系人信息
维护人:[bernard][5]
维护人:[bigmagic123][5]
[1]: https://www.rt-thread.org/page/download.html
[2]: https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-a/downloads
[3]: https://downloads.raspberrypi.org/raspbian_lite_latest
[4]: https://etcher.io
[5]: https://github.com/BernardXiong
[5]: https://github.com/bigmagic123
+3
View File
@@ -68,6 +68,9 @@ msh />
| 驱动 | 支持情况 | 备注 |
| ------ | ---- | :------: |
| UART | 支持 | UART0,UART2,UART3,UART4,UART5 |
| GPIO | 支持 | - |
| SPI | 支持 | SPI0 |
| MAILBOX | 支持 | - |
## 5. 联系人信息
File diff suppressed because it is too large. Load diff
+127
View File
@@ -0,0 +1,127 @@
/*
* Copyright (c) 2006-2020, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2020-09-10 bigmagic first version
*/
#ifndef __MBOX_H__
#define __MBOX_H__
#include <rtthread.h>
//https://github.com/raspberrypi/firmware/wiki/Mailbox-property-interface
//https://github.com/hermanhermitage/videocoreiv
/* a properly aligned buffer */
extern volatile unsigned int* mbox;
#define MBOX_REQUEST 0
/* channels */
#define MBOX_CH_POWER 0
#define MBOX_CH_FB 1
#define MBOX_CH_VUART 2
#define MBOX_CH_VCHIQ 3
#define MBOX_CH_LEDS 4
#define MBOX_CH_BTNS 5
#define MBOX_CH_TOUCH 6
#define MBOX_CH_COUNT 7
#define MBOX_CH_PROP 8
/* tags */
#define MBOX_TAG_SETPOWER 0x28001
#define MBOX_TAG_SETCLKRATE 0x38002
#define MBOX_GET_MAC_ADDRESS 0x10003
#define MBOX_TAG_LAST 0
#define MMIO_BASE 0xFE000000
#define VIDEOCORE_MBOX (MMIO_BASE+0x0000B880)
#define MBOX_READ ((volatile unsigned int*)(VIDEOCORE_MBOX+0x0))
#define MBOX_POLL ((volatile unsigned int*)(VIDEOCORE_MBOX+0x10))
#define MBOX_SENDER ((volatile unsigned int*)(VIDEOCORE_MBOX+0x14))
#define MBOX_STATUS ((volatile unsigned int*)(VIDEOCORE_MBOX+0x18))
#define MBOX_CONFIG ((volatile unsigned int*)(VIDEOCORE_MBOX+0x1C))
#define MBOX_WRITE ((volatile unsigned int*)(VIDEOCORE_MBOX+0x20))
#define MBOX_RESPONSE 0x80000000
#define MBOX_FULL 0x80000000
#define MBOX_EMPTY 0x40000000
#define DEVICE_ID_SD_CARD 0
#define DEVICE_ID_USB_HCD 3
#define POWER_STATE_OFF (0 << 0)
#define POWER_STATE_ON (1 << 0)
#define POWER_STATE_WAIT (1 << 1)
#define POWER_STATE_NO_DEVICE (1 << 1) // in response
#define MMU_ENABLE 1
#define MMU_DISABLE 0
/*
* raspi hardware info
*/
enum {
MBOX_TAG_HARDWARE_GET_MODEL = 0x00010001,
MBOX_TAG_HARDWARE_GET_REV = 0x00010002,
MBOX_TAG_HARDWARE_GET_MAC_ADDRESS = 0x00010003,
MBOX_TAG_HARDWARE_GET_SERIAL = 0x00010004,
MBOX_TAG_HARDWARE_GET_ARM_MEMORY = 0x00010005,
MBOX_TAG_HARDWARE_GET_VC_MEMORY = 0x00010006,
MBOX_TAG_HARDWARE_GET_CLOCKS = 0x00010007,
};
/*
* raspi clock
*/
enum {
MBOX_TAG_CLOCK_GET_TURBO = 0x00030009,
MBOX_TAG_CLOCK_SET_TURBO = 0x00038009,
MBOX_TAG_CLOCK_GET_STATE = 0x00030001,
MBOX_TAG_CLOCK_SET_STATE = 0x00038001,
MBOX_TAG_CLOCK_GET_RATE = 0x00030002,
MBOX_TAG_CLOCK_SET_RATE = 0x00038002,
MBOX_TAG_CLOCK_GET_MAX_RATE = 0x00030004,
MBOX_TAG_CLOCK_GET_MIN_RATE = 0x00030007,
};
/*
* raspi power
*/
enum {
MBOX_TAG_POWER_GET_STATE = 0x00020001,
MBOX_TAG_POWER_SET_STATE = 0x00028001,
};
/*
* raspi temperature
*/
enum {
MBOX_TAG_TEMP_GET = 0x00030006,
MBOX_TAG_TEMP_GET_MAX = 0x0003000A,
};
#define MBOX_ADDR 0xc00000
int mbox_call(unsigned char ch, int mmu_enable);
int bcm271x_mbox_hardware_get_model(void);
int bcm271x_mbox_hardware_get_revison(void);
int bcm271x_mbox_hardware_get_mac_address(uint8_t * mac);
int bcm271x_mbox_hardware_get_serial(rt_uint64_t* sn);
int bcm271x_mbox_hardware_get_arm_memory(rt_uint32_t * base, rt_uint32_t * size);
int bcm271x_mbox_hardware_get_vc_memory(rt_uint32_t * base, rt_uint32_t * size);
int bcm271x_mbox_clock_get_turbo(void);
int bcm271x_mbox_clock_set_turbo(int level);
int bcm271x_mbox_clock_get_state(int id);
int bcm271x_mbox_clock_set_state(int id, int state);
int bcm271x_mbox_clock_get_rate(int id);
int bcm271x_mbox_clock_set_rate(int id, int rate);
int bcm271x_mbox_clock_get_max_rate(int id);
int bcm271x_mbox_clock_get_min_rate(int id);
int bcm271x_mbox_power_get_state(int id);
int bcm271x_mbox_power_set_state(int id, int state);
int bcm271x_mbox_temp_get(void);
int bcm271x_mbox_temp_get_max(void);
#endif