Changeset 3c74f4aa in rtems


Ignore:
Timestamp:
Aug 27, 2016, 6:15:04 AM (3 years ago)
Author:
Mudit Jain <muditjain18011995@…>
Branches:
master
Children:
6deb4190
Parents:
8099e0a
git-author:
Mudit Jain <muditjain18011995@…> (08/27/16 06:15:04)
git-committer:
Pavel Pisa <pisa@…> (08/27/16 08:18:19)
Message:

arm/raspberrypi: Mailbox : Extending functionality

Adding functionality to get board serial,
power state & clock rate

Location:
c/src/lib/libbsp/arm/raspberrypi
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/arm/raspberrypi/include/vc.h

    r8099e0a r3c74f4aa  
    107107int bcm2835_mailbox_set_power_state( bcm2835_set_power_state_entries *_entries );
    108108
     109int bcm2835_mailbox_get_power_state( bcm2835_set_power_state_entries *_entries );
     110
    109111typedef struct {
    110112  uint32_t base;
     
    136138int bcm2835_mailbox_get_board_revision(
    137139  bcm2835_get_board_spec_entries *_entries );
     140
     141typedef struct {
     142  uint64_t board_serial;
     143} bcm2835_get_board_serial_entries;
     144
     145int bcm2835_mailbox_get_board_serial(
     146  bcm2835_get_board_serial_entries *_entries );
     147
     148typedef struct {
     149  uint32_t clock_id;
     150  uint32_t clock_rate;
     151} bcm2835_get_clock_rate_entries;
     152
     153int bcm2835_mailbox_get_clock_rate(
     154  bcm2835_get_clock_rate_entries *_entries );
    138155/** @} */
    139156
  • c/src/lib/libbsp/arm/raspberrypi/misc/vc.c

    r8099e0a r3c74f4aa  
    243243}
    244244
     245int bcm2835_mailbox_get_power_state( bcm2835_set_power_state_entries *_entries )
     246{
     247  struct BCM2835_MBOX_BUF_ALIGN_ATTRIBUTE {
     248    bcm2835_mbox_buf_hdr hdr;
     249    bcm2835_mbox_tag_get_power_state get_power_state;
     250    uint32_t end_tag;
     251    uint32_t padding_reserve[16];
     252  } buffer;
     253  BCM2835_MBOX_INIT_BUF( &buffer );
     254  BCM2835_MBOX_INIT_TAG( &buffer.get_power_state,
     255    BCM2835_MAILBOX_TAG_GET_POWER_STATE );
     256  buffer.get_power_state.body.req.dev_id = _entries->dev_id;
     257  bcm2835_mailbox_buffer_flush_and_invalidate( &buffer, sizeof( &buffer ) );
     258
     259  if ( bcm2835_mailbox_send_read_buffer( &buffer ) )
     260    return -1;
     261
     262  _entries->dev_id = buffer.get_power_state.body.resp.dev_id;
     263  _entries->state = buffer.get_power_state.body.resp.state;
     264
     265  if ( !bcm2835_mailbox_buffer_suceeded( &buffer.hdr ) )
     266    return -2;
     267
     268  return 0;
     269}
     270
    245271int bcm2835_mailbox_set_power_state( bcm2835_set_power_state_entries *_entries )
    246272{
     
    408434  return 0;
    409435}
     436
     437int bcm2835_mailbox_get_board_serial(
     438  bcm2835_get_board_serial_entries *_entries )
     439{
     440  struct BCM2835_MBOX_BUF_ALIGN_ATTRIBUTE {
     441    bcm2835_mbox_buf_hdr hdr;
     442    bcm2835_mbox_tag_get_board_serial get_board_serial;
     443    uint32_t end_tag;
     444    uint32_t padding_reserve[16];
     445  } buffer;
     446  BCM2835_MBOX_INIT_BUF( &buffer );
     447  BCM2835_MBOX_INIT_TAG_NO_REQ( &buffer.get_board_serial,
     448    BCM2835_MAILBOX_TAG_GET_BOARD_SERIAL );
     449  bcm2835_mailbox_buffer_flush_and_invalidate( &buffer, sizeof( &buffer ) );
     450
     451  if ( bcm2835_mailbox_send_read_buffer( &buffer ) )
     452    return -1;
     453
     454  _entries->board_serial = buffer.get_board_serial.body.resp.board_serial;
     455
     456  if ( !bcm2835_mailbox_buffer_suceeded( &buffer.hdr ) )
     457    return -2;
     458
     459  return 0;
     460}
     461
     462int bcm2835_mailbox_get_clock_rate(
     463  bcm2835_get_clock_rate_entries *_entries )
     464{
     465  struct BCM2835_MBOX_BUF_ALIGN_ATTRIBUTE {
     466    bcm2835_mbox_buf_hdr hdr;
     467    bcm2835_mbox_tag_get_clock_rate get_clock_rate;
     468    uint32_t end_tag;
     469    uint32_t padding_reserve[16];
     470  } buffer;
     471  BCM2835_MBOX_INIT_BUF( &buffer );
     472  BCM2835_MBOX_INIT_TAG_NO_REQ( &buffer.get_clock_rate,
     473    BCM2835_MAILBOX_TAG_GET_CLOCK_RATE );
     474  buffer.get_clock_rate.body.req.clock_id = _entries->clock_id;
     475  bcm2835_mailbox_buffer_flush_and_invalidate( &buffer, sizeof( &buffer ) );
     476
     477  if ( bcm2835_mailbox_send_read_buffer( &buffer ) )
     478    return -1;
     479
     480  _entries->clock_id = buffer.get_clock_rate.body.resp.clock_id;
     481  _entries->clock_rate = buffer.get_clock_rate.body.resp.clock_rate;
     482
     483  if ( !bcm2835_mailbox_buffer_suceeded( &buffer.hdr ) )
     484    return -2;
     485
     486  return 0;
     487}
  • c/src/lib/libbsp/arm/raspberrypi/misc/vc_defines.h

    r8099e0a r3c74f4aa  
    183183#define BCM2835_MAILBOX_TAG_GET_BOARD_MAC       0x00010003
    184184#define BCM2835_MAILBOX_TAG_GET_BOARD_SERIAL    0x00010004
     185typedef struct {
     186  bcm2835_mbox_tag_hdr tag_hdr;
     187  union {
     188    struct {
     189    } req;
     190    struct {
     191      uint64_t board_serial;
     192    } resp;
     193  } body;
     194} bcm2835_mbox_tag_get_board_serial;
     195
    185196#define BCM2835_MAILBOX_TAG_GET_ARM_MEMORY      0x00010005
    186197typedef struct {
     
    210221
    211222#define BCM2835_MAILBOX_TAG_GET_CLOCKS          0x00010007
     223typedef struct {
     224  bcm2835_mbox_tag_hdr tag_hdr;
     225  union {
     226    struct {
     227      uint32_t clock_id;
     228    } req;
     229    struct {
     230      uint32_t clock_id;
     231      uint32_t clock_rate;
     232    } resp;
     233  } body;
     234} bcm2835_mbox_tag_get_clock_rate;
    212235
    213236/* Config */
     
    239262
    240263#define BCM2835_MAILBOX_TAG_GET_POWER_STATE     0x00020001
     264typedef struct {
     265  bcm2835_mbox_tag_hdr tag_hdr;
     266  union {
     267    struct {
     268      uint32_t dev_id;
     269    } req;
     270    struct {
     271      uint32_t dev_id;
     272      uint32_t state;
     273    } resp;
     274  } body;
     275} bcm2835_mbox_tag_get_power_state;
    241276
    242277#define BCM2835_MAILBOX_POWER_STATE_RESP_ON       (1 << 0)
Note: See TracChangeset for help on using the changeset viewer.