blob: 9f252c68ff9423ee96acad1d1ee1aba7756202c8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
// SPDX-License-Identifier: GPL-2.0-or-later
// SPDX-FileCopyrightText: 2009 Carlo Caione <carlo@carlocaione.org>
#include <mach/mbox.h>
#include "lowlevel.h"
struct msg_get_arm_mem {
struct bcm2835_mbox_hdr hdr;
struct bcm2835_mbox_tag_get_arm_mem get_arm_mem;
u32 end_tag;
};
struct msg_get_board_rev {
struct bcm2835_mbox_hdr hdr;
struct bcm2835_mbox_tag_get_board_rev get_board_rev;
u32 end_tag;
};
struct msg_get_mac_address {
struct bcm2835_mbox_hdr hdr;
struct bcm2835_mbox_tag_get_mac_address get_mac_address;
u32 end_tag;
};
ssize_t rpi_get_arm_mem(void)
{
BCM2835_MBOX_STACK_ALIGN(struct msg_get_arm_mem, msg);
int ret;
BCM2835_MBOX_INIT_HDR(msg);
BCM2835_MBOX_INIT_TAG(&msg->get_arm_mem, GET_ARM_MEMORY);
ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr);
if (ret)
return ret;
return msg->get_arm_mem.body.resp.mem_size;
}
int rpi_get_usbethaddr(u8 mac[6])
{
BCM2835_MBOX_STACK_ALIGN(struct msg_get_mac_address, msg);
int ret;
BCM2835_MBOX_INIT_HDR(msg);
BCM2835_MBOX_INIT_TAG(&msg->get_mac_address, GET_MAC_ADDRESS);
ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr);
if (ret) {
pr_info("bcm2835: Could not query MAC address\n");
return ret;
}
memcpy(mac, msg->get_mac_address.body.resp.mac, 6);
return 0;
}
int rpi_get_board_rev(void)
{
int ret;
BCM2835_MBOX_STACK_ALIGN(struct msg_get_board_rev, msg);
BCM2835_MBOX_INIT_HDR(msg);
BCM2835_MBOX_INIT_TAG(&msg->get_board_rev, GET_BOARD_REV);
ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr);
if (ret) {
pr_err("Could not query board revision\n");
return ret;
}
return msg->get_board_rev.body.resp.rev;
}
|