[PATCH 2/3] Mailbox : Added functionality to get power state
Mudit Jain
muditjain18011995 at gmail.com
Sat Aug 20 13:25:08 UTC 2016
From: Mudit Jain <muditj at nvidia.com>
---
c/src/lib/libbsp/arm/raspberrypi/include/vc.h | 2 ++
c/src/lib/libbsp/arm/raspberrypi/misc/vc.c | 25 ++++++++++++++++++++++
c/src/lib/libbsp/arm/raspberrypi/misc/vc_defines.h | 12 +++++++++++
3 files changed, 39 insertions(+)
diff --git a/c/src/lib/libbsp/arm/raspberrypi/include/vc.h b/c/src/lib/libbsp/arm/raspberrypi/include/vc.h
index d3408f9..74f7557 100644
--- a/c/src/lib/libbsp/arm/raspberrypi/include/vc.h
+++ b/c/src/lib/libbsp/arm/raspberrypi/include/vc.h
@@ -106,6 +106,8 @@ typedef struct {
#define BCM2835_MAILBOX_POWER_STATE_NODEV ( 1 << 1 )
int bcm2835_mailbox_set_power_state( bcm2835_set_power_state_entries *_entries );
+int bcm2835_mailbox_get_power_state( bcm2835_set_power_state_entries *_entries );
+
typedef struct {
uint32_t base;
size_t size;
diff --git a/c/src/lib/libbsp/arm/raspberrypi/misc/vc.c b/c/src/lib/libbsp/arm/raspberrypi/misc/vc.c
index 53ac1e8..c089b36 100644
--- a/c/src/lib/libbsp/arm/raspberrypi/misc/vc.c
+++ b/c/src/lib/libbsp/arm/raspberrypi/misc/vc.c
@@ -254,6 +254,31 @@ int bcm2835_mailbox_get_cmdline( bcm2835_get_cmdline_entries *_entries )
return 0;
}
+int bcm2835_mailbox_get_power_state( bcm2835_set_power_state_entries *_entries )
+{
+ struct {
+ bcm2835_mbox_buf_hdr hdr;
+ bcm2835_mbox_tag_get_power_state get_power_state;
+ uint32_t end_tag;
+ } buffer BCM2835_MBOX_BUF_ALIGN_ATTRIBUTE;
+ BCM2835_MBOX_INIT_BUF( &buffer );
+ BCM2835_MBOX_INIT_TAG( &buffer.get_power_state,
+ BCM2835_MAILBOX_TAG_GET_POWER_STATE );
+ buffer.get_power_state.body.req.dev_id = _entries->dev_id;
+ bcm2835_mailbox_buffer_flush_and_invalidate( &buffer, sizeof( &buffer ) );
+
+ if ( bcm2835_mailbox_send_read_buffer( &buffer ) )
+ return -1;
+
+ _entries->dev_id = buffer.get_power_state.body.resp.dev_id;
+ _entries->state = buffer.get_power_state.body.resp.state;
+
+ if ( !bcm2835_mailbox_buffer_suceeded( &buffer.hdr ) )
+ return -2;
+
+ return 0;
+}
+
int bcm2835_mailbox_set_power_state( bcm2835_set_power_state_entries *_entries )
{
struct {
diff --git a/c/src/lib/libbsp/arm/raspberrypi/misc/vc_defines.h b/c/src/lib/libbsp/arm/raspberrypi/misc/vc_defines.h
index 516f8f4..e1a5a5b 100644
--- a/c/src/lib/libbsp/arm/raspberrypi/misc/vc_defines.h
+++ b/c/src/lib/libbsp/arm/raspberrypi/misc/vc_defines.h
@@ -246,6 +246,18 @@ typedef struct {
#define BCM2835_MAILBOX_POWER_UDID_CCP2TX 0x00000008
#define BCM2835_MAILBOX_TAG_GET_POWER_STATE 0x00020001
+typedef struct {
+ bcm2835_mbox_tag_hdr tag_hdr;
+ union {
+ struct {
+ uint32_t dev_id;
+ } req;
+ struct {
+ uint32_t dev_id;
+ uint32_t state;
+ } resp;
+ } body;
+} bcm2835_mbox_tag_get_power_state;
#define BCM2835_MAILBOX_POWER_STATE_RESP_ON (1 << 0)
#define BCM2835_MAILBOX_POWER_STATE_RESP_NODEV (1 << 1)
--
1.9.1
More information about the devel
mailing list