Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Mr_Pangza
rt-thread
提交
252b9aa0
R
rt-thread
项目概览
Mr_Pangza
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
2
Star
1
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
252b9aa0
编写于
4月 27, 2020
作者:
B
Bernard Xiong
提交者:
GitHub
4月 27, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3562 from bigmagic123/raspi_mbox
Raspi mbox
上级
d64a7e05
6251fc93
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
609 addition
and
20 deletion
+609
-20
bsp/raspberry-pi/raspi3-64/driver/drv_fb.c
bsp/raspberry-pi/raspi3-64/driver/drv_fb.c
+145
-19
bsp/raspberry-pi/raspi3-64/driver/mbox.c
bsp/raspberry-pi/raspi3-64/driver/mbox.c
+401
-0
bsp/raspberry-pi/raspi3-64/driver/mbox.h
bsp/raspberry-pi/raspi3-64/driver/mbox.h
+63
-1
未找到文件。
bsp/raspberry-pi/raspi3-64/driver/drv_fb.c
浏览文件 @
252b9aa0
...
...
@@ -15,9 +15,10 @@
#include "drv_fb.h"
#include "mmu.h"
#define LCD_WIDTH (
64
0)
#define LCD_WIDTH (
80
0)
#define LCD_HEIGHT (480)
#define LCD_DEPTH (32)
#define LCD_BPP (32)
#define TAG_ALLOCATE_BUFFER 0x00040001
#define TAG_SET_PHYS_WIDTH_HEIGHT 0x00048003
...
...
@@ -28,6 +29,39 @@
#define TAG_SET_VIRT_OFFSET 0x00048009
#define TAG_END 0x00000000
enum
{
MBOX_TAG_FB_GET_GPIOVIRT
=
0x00040010
,
MBOX_TAG_FB_ALLOCATE_BUFFER
=
0x00040001
,
MBOX_TAG_FB_RELEASE_BUFFER
=
0x00048001
,
MBOX_TAG_FB_BLANK_SCREEN
=
0x00040002
,
MBOX_TAG_FB_GET_PHYS_WH
=
0x00040003
,
MBOX_TAG_FB_TEST_PHYS_WH
=
0x00044003
,
MBOX_TAG_FB_SET_PHYS_WH
=
0x00048003
,
MBOX_TAG_FB_GET_VIRT_WH
=
0x00040004
,
MBOX_TAG_FB_TEST_VIRT_WH
=
0x00044004
,
MBOX_TAG_FB_SET_VIRT_WH
=
0x00048004
,
MBOX_TAG_FB_GET_DEPTH
=
0x00040005
,
MBOX_TAG_FB_TEST_DEPTH
=
0x00044005
,
MBOX_TAG_FB_SET_DEPTH
=
0x00048005
,
MBOX_TAG_FB_GET_PIXEL_ORDER
=
0x00040006
,
MBOX_TAG_FB_TEST_PIXEL_ORDER
=
0x00044006
,
MBOX_TAG_FB_SET_PIXEL_ORDER
=
0x00048006
,
MBOX_TAG_FB_GET_ALPHA_MODE
=
0x00040007
,
MBOX_TAG_FB_TEST_ALPHA_MODE
=
0x00044007
,
MBOX_TAG_FB_SET_ALPHA_MODE
=
0x00048007
,
MBOX_TAG_FB_GET_PITCH
=
0x00040008
,
MBOX_TAG_FB_GET_VIRT_OFFSET
=
0x00040009
,
MBOX_TAG_FB_TEST_VIRT_OFFSET
=
0x00044009
,
MBOX_TAG_FB_SET_VIRT_OFFSET
=
0x00048009
,
MBOX_TAG_FB_GET_OVERSCAN
=
0x0004000a
,
MBOX_TAG_FB_TEST_OVERSCAN
=
0x0004400a
,
MBOX_TAG_FB_SET_OVERSCAN
=
0x0004800a
,
MBOX_TAG_FB_GET_PALETTE
=
0x0004000b
,
MBOX_TAG_FB_TEST_PALETTE
=
0x0004400b
,
MBOX_TAG_FB_SET_PALETTE
=
0x0004800b
,
};
#define LCD_DEVICE(dev) (struct rt_hdmi_fb_device*)(dev)
static
struct
rt_hdmi_fb_device
_hdmi
;
...
...
@@ -75,7 +109,7 @@ rt_err_t hdmi_fb_control(rt_device_t dev, int cmd, void *args)
info
->
bits_per_pixel
=
LCD_DEPTH
;
info
->
width
=
lcd
->
width
;
info
->
height
=
lcd
->
height
;
info
->
framebuffer
=
lcd
->
fb
;
//(rt_uint8_t *)lcd->fb;
info
->
framebuffer
=
lcd
->
fb
;
}
break
;
}
...
...
@@ -119,38 +153,122 @@ rt_err_t rt_hdmi_fb_device_init(struct rt_hdmi_fb_device *hdmi_fb, const char *n
return
RT_EOK
;
}
int
hdmi_fb_init
(
void
)
rt_uint32_t
bcm283x_mbox_fb_get_gpiovirt
(
void
)
{
mbox
[
0
]
=
8
*
4
;
// length of the message
mbox
[
1
]
=
MBOX_REQUEST
;
// this is a request message
mbox
[
2
]
=
MBOX_TAG_FB_GET_GPIOVIRT
;
mbox
[
3
]
=
4
;
// buffer size
mbox
[
4
]
=
0
;
// len
mbox
[
5
]
=
0
;
// id
mbox
[
6
]
=
0
;
mbox
[
7
]
=
MBOX_TAG_LAST
;
mbox_call
(
8
,
MMU_DISABLE
);
return
(
mbox
[
5
]
&
0x3fffffff
);
}
rt_uint32_t
bcm283x_mbox_fb_get_pitch
(
void
)
{
mbox
[
0
]
=
8
*
4
;
// length of the message
mbox
[
1
]
=
MBOX_REQUEST
;
// this is a request message
mbox
[
2
]
=
MBOX_TAG_FB_GET_PITCH
;
mbox
[
3
]
=
4
;
// buffer size
mbox
[
4
]
=
0
;
// len
mbox
[
5
]
=
0
;
// id
mbox
[
6
]
=
0
;
mbox
[
7
]
=
MBOX_TAG_LAST
;
mbox_call
(
8
,
MMU_DISABLE
);
return
mbox
[
5
];
}
void
bcm283x_mbox_fb_set_porder
(
int
rgb
)
{
mbox
[
0
]
=
8
*
4
;
// length of the message
mbox
[
1
]
=
MBOX_REQUEST
;
// this is a request message
mbox
[
2
]
=
MBOX_TAG_FB_SET_PIXEL_ORDER
;
mbox
[
3
]
=
4
;
// buffer size
mbox
[
4
]
=
4
;
// len
mbox
[
5
]
=
rgb
;
// id
mbox
[
6
]
=
0
;
mbox
[
7
]
=
MBOX_TAG_LAST
;
mbox_call
(
8
,
MMU_DISABLE
);
}
void
bcm283x_mbox_fb_setoffset
(
int
xoffset
,
int
yoffset
)
{
mbox
[
0
]
=
8
*
4
;
// length of the message
mbox
[
1
]
=
MBOX_REQUEST
;
// this is a request message
mbox
[
2
]
=
MBOX_TAG_FB_SET_VIRT_OFFSET
;
mbox
[
3
]
=
8
;
// buffer size
mbox
[
4
]
=
8
;
// len
mbox
[
5
]
=
xoffset
;
// id
mbox
[
6
]
=
yoffset
;
mbox
[
7
]
=
MBOX_TAG_LAST
;
mbox_call
(
8
,
MMU_DISABLE
);
}
void
bcm283x_mbox_fb_setalpha
(
int
alpha
)
{
mbox
[
0
]
=
8
*
4
;
// length of the message
mbox
[
1
]
=
MBOX_REQUEST
;
// this is a request message
mbox
[
2
]
=
MBOX_TAG_FB_SET_ALPHA_MODE
;
mbox
[
3
]
=
4
;
// buffer size
mbox
[
4
]
=
4
;
// len
mbox
[
5
]
=
alpha
;
// id
mbox
[
6
]
=
0
;
mbox
[
7
]
=
MBOX_TAG_LAST
;
mbox_call
(
8
,
MMU_DISABLE
);
}
void
*
bcm283x_mbox_fb_alloc
(
int
width
,
int
height
,
int
bpp
,
int
nrender
)
{
mbox
[
0
]
=
4
*
35
;
mbox
[
1
]
=
MBOX_REQUEST
;
mbox
[
2
]
=
TAG_ALLOCATE_BUFFER
;
//get framebuffer, gets alignment on request
mbox
[
3
]
=
8
;
mbox
[
4
]
=
0
;
mbox
[
5
]
=
4096
;
//FrameBufferInfo.pointer
mbox
[
6
]
=
0
;
//FrameBufferInfo.size
mbox
[
3
]
=
8
;
//size
mbox
[
4
]
=
4
;
//len
mbox
[
5
]
=
4096
;
//The design of MBOX driver forces us to give the virtual address 0x3C100000
mbox
[
6
]
=
0
;
//FrameBufferInfo.size
mbox
[
7
]
=
TAG_SET_PHYS_WIDTH_HEIGHT
;
mbox
[
8
]
=
8
;
mbox
[
9
]
=
0
;
mbox
[
10
]
=
LCD_WIDTH
;
mbox
[
11
]
=
LCD_HEIGHT
;
mbox
[
9
]
=
8
;
mbox
[
10
]
=
width
;
mbox
[
11
]
=
height
;
mbox
[
12
]
=
TAG_SET_VIRT_WIDTH_HEIGHT
;
mbox
[
13
]
=
8
;
mbox
[
14
]
=
0
;
mbox
[
15
]
=
LCD_WIDTH
;
mbox
[
16
]
=
LCD_HEIGHT
;
mbox
[
14
]
=
8
;
mbox
[
15
]
=
width
;
mbox
[
16
]
=
height
*
nrender
;
mbox
[
17
]
=
TAG_SET_DEPTH
;
mbox
[
18
]
=
4
;
mbox
[
19
]
=
0
;
mbox
[
20
]
=
16
;
//FrameBufferInfo.depth RGB 565
mbox
[
19
]
=
4
;
mbox
[
20
]
=
bpp
;
mbox
[
21
]
=
TAG_SET_PIXEL_ORDER
;
mbox
[
22
]
=
4
;
mbox
[
23
]
=
0
;
mbox
[
24
]
=
1
;
//RGB, not BGR preferably
mbox
[
24
]
=
0
;
//RGB, not BGR preferably
mbox
[
25
]
=
TAG_GET_PITCH
;
mbox
[
26
]
=
4
;
...
...
@@ -167,17 +285,25 @@ int hdmi_fb_init(void)
mbox_call
(
MBOX_CH_PROP
,
MMU_DISABLE
);
_hdmi
.
fb
=
(
rt_uint8_t
*
)(
uintptr_t
)(
mbox
[
5
]
&
0x3FFFFFFF
);
return
(
void
*
)((
rt_uint64_t
)(
mbox
[
5
]
&
0x3fffffff
));
}
int
hdmi_fb_init
(
void
)
{
_hdmi
.
fb
=
(
rt_uint8_t
*
)
bcm283x_mbox_fb_alloc
(
LCD_WIDTH
,
LCD_HEIGHT
,
LCD_BPP
,
1
);
bcm283x_mbox_fb_setoffset
(
0
,
0
);
bcm283x_mbox_fb_set_porder
(
0
);
_hdmi
.
width
=
LCD_WIDTH
;
_hdmi
.
height
=
LCD_HEIGHT
;
_hdmi
.
depth
=
LCD_DEPTH
;
_hdmi
.
pitch
=
0
;
_hdmi
.
pixel_format
=
RTGRAPHIC_PIXEL_FORMAT_RGB888
;
armv8_map
((
unsigned
long
)
_hdmi
.
fb
,
(
unsigned
long
)
_hdmi
.
fb
,
0x200000
,
MEM_ATTR_MEMORY
);
armv8_map
((
unsigned
long
)
_hdmi
.
fb
,
(
unsigned
long
)
_hdmi
.
fb
,
0x200000
,
MEM_ATTR_IO
);
rt_hw_dcache_invalidate_range
((
unsigned
long
)
_hdmi
.
fb
,
LCD_WIDTH
*
LCD_HEIGHT
*
3
);
rt_kprintf
(
"_hdmi.fb is %p
\n
"
,
_hdmi
.
fb
);
//
rt_kprintf("_hdmi.fb is %p\n", _hdmi.fb);
rt_hdmi_fb_device_init
(
&
_hdmi
,
"lcd"
);
return
0
;
...
...
bsp/raspberry-pi/raspi3-64/driver/mbox.c
浏览文件 @
252b9aa0
...
...
@@ -47,3 +47,404 @@ int mbox_call(unsigned char ch, int mmu_enable)
}
return
0
;
}
int
bcm283x_mbox_hardware_get_model
(
void
)
{
mbox
[
0
]
=
8
*
4
;
// length of the message
mbox
[
1
]
=
MBOX_REQUEST
;
// this is a request message
mbox
[
2
]
=
MBOX_TAG_HARDWARE_GET_MODEL
;
mbox
[
3
]
=
4
;
// buffer size
mbox
[
4
]
=
0
;
// len
mbox
[
5
]
=
0
;
mbox
[
6
]
=
0
;
mbox
[
7
]
=
MBOX_TAG_LAST
;
mbox_call
(
8
,
MMU_DISABLE
);
return
mbox
[
5
];
}
int
bcm283x_mbox_hardware_get_revison
(
void
)
{
mbox
[
0
]
=
8
*
4
;
// length of the message
mbox
[
1
]
=
MBOX_REQUEST
;
// this is a request message
mbox
[
2
]
=
MBOX_TAG_HARDWARE_GET_REV
;
mbox
[
3
]
=
4
;
// buffer size
mbox
[
4
]
=
0
;
// len
mbox
[
5
]
=
0
;
mbox
[
6
]
=
0
;
mbox
[
7
]
=
MBOX_TAG_LAST
;
mbox_call
(
8
,
MMU_DISABLE
);
return
mbox
[
5
];
}
int
bcm283x_mbox_hardware_get_mac_address
(
uint8_t
*
mac
)
{
mbox
[
0
]
=
8
*
4
;
// length of the message
mbox
[
1
]
=
MBOX_REQUEST
;
// this is a request message
mbox
[
2
]
=
MBOX_TAG_HARDWARE_GET_MAC_ADDRESS
;
mbox
[
3
]
=
6
;
// buffer size
mbox
[
4
]
=
0
;
// len
mbox
[
5
]
=
0
;
mbox
[
6
]
=
0
;
mbox
[
7
]
=
MBOX_TAG_LAST
;
mbox_call
(
8
,
MMU_DISABLE
);
char
*
mac_str
=
(
char
*
)
&
mbox
[
5
];
mac
[
0
]
=
mac_str
[
0
];
mac
[
1
]
=
mac_str
[
1
];
mac
[
2
]
=
mac_str
[
2
];
mac
[
3
]
=
mac_str
[
3
];
mac
[
4
]
=
mac_str
[
4
];
mac
[
5
]
=
mac_str
[
5
];
return
0
;
}
int
bcm283x_mbox_hardware_get_serial
(
rt_uint64_t
*
sn
)
{
mbox
[
0
]
=
8
*
4
;
// length of the message
mbox
[
1
]
=
MBOX_REQUEST
;
// this is a request message
mbox
[
2
]
=
MBOX_TAG_HARDWARE_GET_SERIAL
;
mbox
[
3
]
=
8
;
// buffer size
mbox
[
4
]
=
0
;
// len
mbox
[
5
]
=
0
;
mbox
[
6
]
=
0
;
mbox
[
7
]
=
MBOX_TAG_LAST
;
mbox_call
(
8
,
MMU_DISABLE
);
sn
=
(
rt_uint64_t
*
)
&
mbox
[
5
];
return
0
;
}
int
bcm283x_mbox_hardware_get_arm_memory
(
rt_uint32_t
*
base
,
rt_uint32_t
*
size
)
{
mbox
[
0
]
=
8
*
4
;
// length of the message
mbox
[
1
]
=
MBOX_REQUEST
;
// this is a request message
mbox
[
2
]
=
MBOX_TAG_HARDWARE_GET_ARM_MEMORY
;
mbox
[
3
]
=
8
;
// buffer size
mbox
[
4
]
=
0
;
// len
mbox
[
5
]
=
0
;
mbox
[
6
]
=
0
;
mbox
[
7
]
=
MBOX_TAG_LAST
;
mbox_call
(
8
,
MMU_DISABLE
);
*
base
=
mbox
[
5
];
*
size
=
mbox
[
6
];
return
0
;
}
int
bcm283x_mbox_hardware_get_vc_memory
(
rt_uint32_t
*
base
,
rt_uint32_t
*
size
)
{
mbox
[
0
]
=
8
*
4
;
// length of the message
mbox
[
1
]
=
MBOX_REQUEST
;
// this is a request message
mbox
[
2
]
=
MBOX_TAG_HARDWARE_GET_VC_MEMORY
;
mbox
[
3
]
=
8
;
// buffer size
mbox
[
4
]
=
0
;
// len
mbox
[
5
]
=
0
;
mbox
[
6
]
=
0
;
mbox
[
7
]
=
MBOX_TAG_LAST
;
mbox_call
(
8
,
MMU_DISABLE
);
*
base
=
mbox
[
5
];
*
size
=
mbox
[
6
];
return
0
;
}
int
bcm283x_mbox_clock_get_turbo
(
void
)
{
mbox
[
0
]
=
8
*
4
;
// length of the message
mbox
[
1
]
=
MBOX_REQUEST
;
// this is a request message
mbox
[
2
]
=
MBOX_TAG_CLOCK_GET_TURBO
;
mbox
[
3
]
=
8
;
// buffer size
mbox
[
4
]
=
4
;
// len
mbox
[
5
]
=
0
;
// id
mbox
[
6
]
=
0
;
// val
mbox
[
7
]
=
MBOX_TAG_LAST
;
mbox_call
(
8
,
MMU_DISABLE
);
if
(
mbox
[
5
]
!=
0
)
{
return
-
1
;
}
return
mbox
[
6
];
}
int
bcm283x_mbox_clock_set_turbo
(
int
level
)
{
mbox
[
0
]
=
8
*
4
;
// length of the message
mbox
[
1
]
=
MBOX_REQUEST
;
// this is a request message
mbox
[
2
]
=
MBOX_TAG_CLOCK_SET_TURBO
;
mbox
[
3
]
=
8
;
// buffer size
mbox
[
4
]
=
8
;
// len
mbox
[
5
]
=
0
;
// id
mbox
[
6
]
=
level
?
1
:
0
;
mbox
[
7
]
=
MBOX_TAG_LAST
;
mbox_call
(
8
,
MMU_DISABLE
);
if
(
mbox
[
5
]
!=
0
)
{
return
-
1
;
}
return
mbox
[
6
];
}
int
bcm283x_mbox_clock_get_state
(
int
id
)
{
mbox
[
0
]
=
8
*
4
;
// length of the message
mbox
[
1
]
=
MBOX_REQUEST
;
// this is a request message
mbox
[
2
]
=
MBOX_TAG_CLOCK_GET_STATE
;
mbox
[
3
]
=
8
;
// buffer size
mbox
[
4
]
=
4
;
// len
mbox
[
5
]
=
id
;
// id
mbox
[
6
]
=
0
;
mbox
[
7
]
=
MBOX_TAG_LAST
;
mbox_call
(
8
,
MMU_DISABLE
);
if
(
mbox
[
5
]
!=
id
)
{
return
-
1
;
}
return
(
mbox
[
6
]
&
0x3
);
}
int
bcm283x_mbox_clock_set_state
(
int
id
,
int
state
)
{
mbox
[
0
]
=
8
*
4
;
// length of the message
mbox
[
1
]
=
MBOX_REQUEST
;
// this is a request message
mbox
[
2
]
=
MBOX_TAG_CLOCK_SET_STATE
;
mbox
[
3
]
=
8
;
// buffer size
mbox
[
4
]
=
8
;
// len
mbox
[
5
]
=
id
;
// id
mbox
[
6
]
=
state
&
0x3
;
mbox
[
7
]
=
MBOX_TAG_LAST
;
mbox_call
(
8
,
MMU_DISABLE
);
if
(
mbox
[
5
]
!=
id
)
{
return
-
1
;
}
return
(
mbox
[
6
]
&
0x3
);
}
int
bcm283x_mbox_clock_get_rate
(
int
id
)
{
mbox
[
0
]
=
8
*
4
;
// length of the message
mbox
[
1
]
=
MBOX_REQUEST
;
// this is a request message
mbox
[
2
]
=
MBOX_TAG_CLOCK_GET_RATE
;
mbox
[
3
]
=
8
;
// buffer size
mbox
[
4
]
=
4
;
// len
mbox
[
5
]
=
id
;
// id
mbox
[
6
]
=
0
;
mbox
[
7
]
=
MBOX_TAG_LAST
;
mbox_call
(
8
,
MMU_DISABLE
);
if
(
mbox
[
5
]
!=
id
)
{
return
-
1
;
}
return
mbox
[
6
];
}
int
bcm283x_mbox_clock_set_rate
(
int
id
,
int
rate
)
{
mbox
[
0
]
=
8
*
4
;
// length of the message
mbox
[
1
]
=
MBOX_REQUEST
;
// this is a request message
mbox
[
2
]
=
MBOX_TAG_CLOCK_SET_RATE
;
mbox
[
3
]
=
8
;
// buffer size
mbox
[
4
]
=
8
;
// len
mbox
[
5
]
=
id
;
// id
mbox
[
6
]
=
rate
;
mbox
[
7
]
=
MBOX_TAG_LAST
;
mbox_call
(
8
,
MMU_DISABLE
);
if
(
mbox
[
5
]
!=
id
)
{
return
-
1
;
}
return
mbox
[
6
];
}
int
bcm283x_mbox_clock_get_max_rate
(
int
id
)
{
mbox
[
0
]
=
8
*
4
;
// length of the message
mbox
[
1
]
=
MBOX_REQUEST
;
// this is a request message
mbox
[
2
]
=
MBOX_TAG_CLOCK_GET_MAX_RATE
;
mbox
[
3
]
=
8
;
// buffer size
mbox
[
4
]
=
4
;
// len
mbox
[
5
]
=
id
;
// id
mbox
[
6
]
=
0
;
mbox
[
7
]
=
MBOX_TAG_LAST
;
mbox_call
(
8
,
MMU_DISABLE
);
if
(
mbox
[
5
]
!=
id
)
{
return
-
1
;
}
return
mbox
[
6
];
}
int
bcm283x_mbox_clock_get_min_rate
(
int
id
)
{
mbox
[
0
]
=
8
*
4
;
// length of the message
mbox
[
1
]
=
MBOX_REQUEST
;
// this is a request message
mbox
[
2
]
=
MBOX_TAG_CLOCK_GET_MIN_RATE
;
mbox
[
3
]
=
8
;
// buffer size
mbox
[
4
]
=
4
;
// len
mbox
[
5
]
=
id
;
// id
mbox
[
6
]
=
0
;
mbox
[
7
]
=
MBOX_TAG_LAST
;
mbox_call
(
8
,
MMU_DISABLE
);
if
(
mbox
[
5
]
!=
id
)
{
return
-
1
;
}
return
mbox
[
6
];
}
int
bcm283x_mbox_power_get_state
(
int
id
)
{
mbox
[
0
]
=
8
*
4
;
// length of the message
mbox
[
1
]
=
MBOX_REQUEST
;
// this is a request message
mbox
[
2
]
=
MBOX_TAG_POWER_GET_STATE
;
mbox
[
3
]
=
8
;
// buffer size
mbox
[
4
]
=
4
;
// len
mbox
[
5
]
=
id
;
// id
mbox
[
6
]
=
0
;
mbox
[
7
]
=
MBOX_TAG_LAST
;
mbox_call
(
8
,
MMU_DISABLE
);
if
(
mbox
[
5
]
!=
id
)
{
return
-
1
;
}
return
(
mbox
[
6
]
&
0x3
);
}
int
bcm283x_mbox_power_set_state
(
int
id
,
int
state
)
{
mbox
[
0
]
=
8
*
4
;
// length of the message
mbox
[
1
]
=
MBOX_REQUEST
;
// this is a request message
mbox
[
2
]
=
MBOX_TAG_POWER_SET_STATE
;
mbox
[
3
]
=
8
;
// buffer size
mbox
[
4
]
=
8
;
// len
mbox
[
5
]
=
id
;
// id
mbox
[
6
]
=
state
&
0x3
;
mbox
[
7
]
=
MBOX_TAG_LAST
;
mbox_call
(
8
,
MMU_DISABLE
);
if
(
mbox
[
5
]
!=
id
)
{
return
-
1
;
}
return
(
mbox
[
6
]
&
0x3
);
}
int
bcm283x_mbox_temp_get
(
void
)
{
mbox
[
0
]
=
8
*
4
;
// length of the message
mbox
[
1
]
=
MBOX_REQUEST
;
// this is a request message
mbox
[
2
]
=
MBOX_TAG_TEMP_GET
;
mbox
[
3
]
=
8
;
// buffer size
mbox
[
4
]
=
4
;
// len
mbox
[
5
]
=
0
;
//id
mbox
[
6
]
=
0
;
mbox
[
7
]
=
MBOX_TAG_LAST
;
mbox_call
(
8
,
MMU_DISABLE
);
if
(
mbox
[
5
]
!=
0
)
{
return
-
1
;
}
return
mbox
[
6
];
}
int
bcm283x_mbox_temp_get_max
(
void
)
{
mbox
[
0
]
=
8
*
4
;
// length of the message
mbox
[
1
]
=
MBOX_REQUEST
;
// this is a request message
mbox
[
2
]
=
MBOX_TAG_TEMP_GET_MAX
;
mbox
[
3
]
=
8
;
// buffer size
mbox
[
4
]
=
4
;
// len
mbox
[
5
]
=
0
;
// id
mbox
[
6
]
=
0
;
mbox
[
7
]
=
MBOX_TAG_LAST
;
mbox_call
(
8
,
MMU_DISABLE
);
if
(
mbox
[
5
]
!=
0
)
{
return
-
1
;
}
return
mbox
[
6
];
}
bsp/raspberry-pi/raspi3-64/driver/mbox.h
浏览文件 @
252b9aa0
...
...
@@ -12,7 +12,7 @@
#ifndef __MBOX_H__
#define __MBOX_H__
#include <rtthread.h>
/* a properly aligned buffer */
extern
volatile
unsigned
int
*
mbox
;
...
...
@@ -56,7 +56,69 @@ extern volatile unsigned int* mbox;
#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
bcm283x_mbox_hardware_get_model
(
void
);
int
bcm283x_mbox_hardware_get_revison
(
void
);
int
bcm283x_mbox_hardware_get_mac_address
(
uint8_t
*
mac
);
int
bcm283x_mbox_hardware_get_serial
(
rt_uint64_t
*
sn
);
int
bcm283x_mbox_hardware_get_arm_memory
(
rt_uint32_t
*
base
,
rt_uint32_t
*
size
);
int
bcm283x_mbox_hardware_get_vc_memory
(
rt_uint32_t
*
base
,
rt_uint32_t
*
size
);
int
bcm283x_mbox_clock_get_turbo
(
void
);
int
bcm283x_mbox_clock_set_turbo
(
int
level
);
int
bcm283x_mbox_clock_get_state
(
int
id
);
int
bcm283x_mbox_clock_set_state
(
int
id
,
int
state
);
int
bcm283x_mbox_clock_get_rate
(
int
id
);
int
bcm283x_mbox_clock_set_rate
(
int
id
,
int
rate
);
int
bcm283x_mbox_clock_get_max_rate
(
int
id
);
int
bcm283x_mbox_clock_get_min_rate
(
int
id
);
int
bcm283x_mbox_power_get_state
(
int
id
);
int
bcm283x_mbox_power_set_state
(
int
id
,
int
state
);
int
bcm283x_mbox_temp_get
(
void
);
int
bcm283x_mbox_temp_get_max
(
void
);
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录