Skip to content

Commit

Permalink
Mailbox : Adding functionality to get clock rate
Browse files Browse the repository at this point in the history
  • Loading branch information
Mudit Jain committed Aug 6, 2016
1 parent c62e086 commit 4244270
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
8 changes: 8 additions & 0 deletions c/src/lib/libbsp/arm/raspberrypi/include/vc.h
Expand Up @@ -144,6 +144,14 @@ typedef struct {

int bcm2835_mailbox_get_board_serial(
bcm2835_get_board_serial_entries *_entries );

typedef struct {
uint32_t clock_id;
uint32_t clock_rate;
} bcm2835_get_clock_rate_entries;

int bcm2835_mailbox_get_clock_rate(
bcm2835_get_clock_rate_entries *_entries );
/** @} */

#endif /* LIBBSP_ARM_RASPBERRYPI_VC_H */
26 changes: 26 additions & 0 deletions c/src/lib/libbsp/arm/raspberrypi/misc/vc.c
Expand Up @@ -447,3 +447,29 @@ int bcm2835_mailbox_get_board_serial(

return 0;
}

int bcm2835_mailbox_get_clock_rate(
bcm2835_get_clock_rate_entries *_entries )
{
struct {
bcm2835_mbox_buf_hdr hdr;
bcm2835_mbox_tag_get_clock_rate get_clock_rate;
uint32_t end_tag;
} buffer BCM2835_MBOX_BUF_ALIGN_ATTRIBUTE;
BCM2835_MBOX_INIT_BUF( &buffer );
BCM2835_MBOX_INIT_TAG_NO_REQ( &buffer.get_clock_rate,
BCM2835_MAILBOX_TAG_GET_CLOCK_RATE );
buffer.get_clock_rate.body.req.clock_id = _entries->clock_id;
bcm2835_mailbox_buffer_flush_and_invalidate( &buffer, sizeof( &buffer ) );

if ( bcm2835_mailbox_send_read_buffer( &buffer ) )
return -1;

_entries->clock_id = buffer.get_clock_rate.body.resp.clock_id;
_entries->clock_rate = buffer.get_clock_rate.body.resp.clock_rate;

if ( !bcm2835_mailbox_buffer_suceeded( &buffer.hdr ) )
return -2;

return 0;
}
12 changes: 12 additions & 0 deletions c/src/lib/libbsp/arm/raspberrypi/misc/vc_defines.h
Expand Up @@ -217,6 +217,18 @@ typedef struct {
} bcm2835_mbox_tag_get_vc_memory;

#define BCM2835_MAILBOX_TAG_GET_CLOCKS 0x00010007
typedef struct {
bcm2835_mbox_tag_hdr tag_hdr;
union {
struct {
uint32_t clock_id;
} req;
struct {
uint32_t clock_id;
uint32_t clock_rate;
} resp;
} body;
} bcm2835_mbox_tag_get_clock_rate;

/* Config */
#define BCM2835_MAILBOX_TAG_GET_CMD_LINE 0x00050001
Expand Down

0 comments on commit 4244270

Please sign in to comment.