[PATCH 1/6] add mailbox support for rpi bsp

QIAO YANG yangqiao0505 at me.com
Thu Aug 13 20:31:44 UTC 2015


I rebased on the latest commit on master:

commit 61e7c698a44137afbc1447ed328b14a0d9e55016
Author: Andre Marques <andre.lousa.marques at gmail.com>
Date:   Mon Jul 27 17:01:44 2015 +0100
        Raspberry Pi implementation for the RTEMS GPIO API.

I've just cloned it and the patches are all applied. Maybe I misunderstand which commit to rebase on?

On Aug 13, 2015, at 09:16 AM, Joel Sherrill <joel.sherrill at oarcorp.com> wrote:

> This still doesn't apply for me.
>
> Did you pull the latest changes and rebase?
>
> --joel
>
> On 8/12/2015 5:08 PM, YANG QIAO wrote:
>> From: YANG Qiao <yangqiao0505 at me.com>
>>
>> ---
>> c/src/lib/libbsp/arm/raspberrypi/Makefile.am | 4 ++
>> c/src/lib/libbsp/arm/raspberrypi/include/mailbox.h | 32 +++++++++++++
>> .../libbsp/arm/raspberrypi/include/raspberrypi.h | 49 +++++++++++++++++++
>> c/src/lib/libbsp/arm/raspberrypi/misc/mailbox.c | 56 ++++++++++++++++++++++
>> c/src/lib/libbsp/arm/raspberrypi/preinstall.am | 4 ++
>> 5 files changed, 145 insertions(+)
>> create mode 100644 c/src/lib/libbsp/arm/raspberrypi/include/mailbox.h
>> create mode 100644 c/src/lib/libbsp/arm/raspberrypi/misc/mailbox.c
>>
>> diff --git a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
>> index 03be711..e1398bb 100644
>> --- a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
>> +++ b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
>> @@ -45,6 +45,7 @@ include_bsp_HEADERS += include/mmu.h
>> include_bsp_HEADERS += include/usart.h
>> include_bsp_HEADERS += include/raspberrypi.h
>> include_bsp_HEADERS += include/rpi-gpio.h
>> +include_bsp_HEADERS += include/mailbox.h
>>
>> include_libcpu_HEADERS = ../../../libcpu/arm/shared/include/cache_.h \
>> ../../../libcpu/arm/shared/include/arm-cp15.h
>> @@ -128,6 +129,9 @@ libbsp_a_SOURCES += gpio/rpi-gpio.c
>>
>> # I2C
>>
>> +# Mailbox
>> +libbsp_a_SOURCES += misc/mailbox.c
>> +
>> # Cache
>> libbsp_a_SOURCES += ../../../libcpu/shared/src/cache_manager.c
>> libbsp_a_SOURCES += ../../../libcpu/arm/shared/include/cache_.h
>> diff --git a/c/src/lib/libbsp/arm/raspberrypi/include/mailbox.h b/c/src/lib/libbsp/arm/raspberrypi/include/mailbox.h
>> new file mode 100644
>> index 0000000..e6cb0f8
>> --- /dev/null
>> +++ b/c/src/lib/libbsp/arm/raspberrypi/include/mailbox.h
>> @@ -0,0 +1,32 @@
>> +/**
>> + * @file
>> + *
>> + * @ingroup raspberrypi
>> + *
>> + * @brief mailbox support.
>> + */
>> +/*
>> + * Copyright (c) 2015 Yang Qiao
>> + *
>> + * The license and distribution terms for this file may be
>> + * found in the file LICENSE in this distribution or at
>> + *
>> + * http://www.rtems.org/license/LICENSE
>>  
>> + *
>> + */
>> +
>> +#ifndef LIBBSP_ARM_RASPBERRYPI_MAILBOX_H
>> +#define LIBBSP_ARM_RASPBERRYPI_MAILBOX_H
>> +
>> +#ifdef __cplusplus
>> +extern "C" {
>> +#endif /* __cplusplus */
>> +
>> +extern unsigned int raspberrypi_mailbox_read(unsigned int channel);
>> +extern void raspberrypi_mailbox_write(unsigned int channel, unsigned int data);
>> +
>> +#ifdef __cplusplus
>> +}
>> +#endif /* __cplusplus */
>> +
>> +#endif /* LIBBSP_ARM_RASPBERRYPI_MAILBOX_H */
>> diff --git a/c/src/lib/libbsp/arm/raspberrypi/include/raspberrypi.h b/c/src/lib/libbsp/arm/raspberrypi/include/raspberrypi.h
>> index ddcd4ff..ef7a061 100644
>> --- a/c/src/lib/libbsp/arm/raspberrypi/include/raspberrypi.h
>> +++ b/c/src/lib/libbsp/arm/raspberrypi/include/raspberrypi.h
>> @@ -7,6 +7,7 @@
>> */
>>
>> /*
>> + * Copyright (c) 2015 Yang Qiao
>> * Copyright (c) 2014 Andre Marques <andre.lousa.marques at gmail.com>
>> * Copyright (c) 2013 Alan Cudmore.
>> *
>> @@ -272,6 +273,54 @@
>>
>> /** @} */
>>
>> +/**
>> +* @name Mailbox Registers
>> +*
>> +* @{
>> +*/
>> +
>> +#define BCM2835_MBOX_BASE (RPI_PERIPHERAL_BASE+0xB880)
>> +
>> +#define BCM2835_MBOX_PEEK (BCM2835_MBOX_BASE+0x10)
>> +#define BCM2835_MBOX_READ (BCM2835_MBOX_BASE+0x00)
>> +#define BCM2835_MBOX_WRITE (BCM2835_MBOX_BASE+0x20)
>> +#define BCM2835_MBOX_STATUS (BCM2835_MBOX_BASE+0x18)
>> +#define BCM2835_MBOX_SENDER (BCM2835_MBOX_BASE+0x14)
>> +#define BCM2835_MBOX_CONFIG (BCM2835_MBOX_BASE+0x1C)
>> +
>> +#define BCM2835_MBOX_FULL (BCM2835_MBOX_BASE+0x80000000)
>> +#define BCM2835_MBOX_EMPTY (BCM2835_MBOX_BASE+0x40000000)
>> +
>> +/** @} */
>> +
>> +/**
>> +* @name Mailbox Channels
>> +*
>> +* @{
>> +*/
>> +
>> +/* Power Manager channel */
>> +#define BCM2835_MBOX_CHANNEL_PM 0
>> +/* Framebuffer channel */
>> +#define BCM2835_MBOX_CHANNEL_FB 1
>> + /* Virtual UART channel */
>> +#define BCM2835_MBOX_CHANNEL_VUART 2
>> + /* VCHIQ channel */
>> +#define BCM2835_MBOX_CHANNEL_VCHIQ 3
>> + /* LEDs channel */
>> +#define BCM2835_MBOX_CHANNEL_LED 4
>> + /* Button channel */
>> +#define BCM2835_MBOX_CHANNEL_BUTTON 5
>> + /* Touch screen channel */
>> +#define BCM2835_MBOX_CHANNEL_TOUCHS 6
>> +/* Property tags (ARM <-> VC) channel */
>> +#define BCM2835_MBOX_CHANNEL_PROP_AVC 8
>> + /* Property tags (VC <-> ARM) channel */
>> +#define BCM2835_MBOX_CHANNEL_PROP_VCA 9
>> +
>> +/** @} */
>> +
>> +
>> /** @} */
>>
>> #endif /* LIBBSP_ARM_RASPBERRYPI_RASPBERRYPI_H */
>> diff --git a/c/src/lib/libbsp/arm/raspberrypi/misc/mailbox.c b/c/src/lib/libbsp/arm/raspberrypi/misc/mailbox.c
>> new file mode 100644
>> index 0000000..8ec730a
>> --- /dev/null
>> +++ b/c/src/lib/libbsp/arm/raspberrypi/misc/mailbox.c
>> @@ -0,0 +1,56 @@
>> +/**
>> + * @file
>> + *
>> + * @ingroup raspberrypi
>> + *
>> + * @brief mailbox support.
>> + */
>> +/*
>> + * Copyright (c) 2015 Yang Qiao
>> + *
>> + * The license and distribution terms for this file may be
>> + * found in the file LICENSE in this distribution or at
>> + *
>> + * http://www.rtems.org/license/LICENSE
>>  
>> + *
>> + */
>> +
>> +#include <stdint.h>
>> +#include <stdbool.h>
>> +#include <bsp/raspberrypi.h>
>> +#include <bsp/mailbox.h>
>> +
>> +#define BCM2835_MBOX_DATA_MASK(data) (data & 0xFFFFFFF0U)
>> +#define BCM2835_MBOX_CHANNEL_MASK(data) (data & 0xFU)
>> +
>> +static inline bool bcm2835_mailbox_is_empty()
>> +{
>> + return (BCM2835_REG(BCM2835_MBOX_STATUS) & BCM2835_MBOX_EMPTY);
>> +}
>> +
>> +static inline bool bcm2835_mailbox_is_full()
>> +{
>> + return (BCM2835_REG(BCM2835_MBOX_STATUS) & BCM2835_MBOX_FULL);
>> +}
>> +
>> +unsigned int raspberrypi_mailbox_read(unsigned int channel)
>> +{
>> + unsigned int raw;
>> + unsigned int read_channel;
>> +
>> + while (1){
>> + while (bcm2835_mailbox_is_empty());
>> + raw = BCM2835_REG (BCM2835_MBOX_READ );
>> + read_channel = BCM2835_MBOX_CHANNEL_MASK(raw) ;
>> + if (read_channel == channel)
>> + return BCM2835_MBOX_DATA_MASK(raw);
>> + }
>> +}
>> +
>> +void raspberrypi_mailbox_write(unsigned int channel, unsigned int data)
>> +{
>> + while (bcm2835_mailbox_is_full());
>> + BCM2835_REG(BCM2835_MBOX_WRITE) =
>> + BCM2835_MBOX_DATA_MASK(data) |
>> + BCM2835_MBOX_CHANNEL_MASK(channel);
>> +}
>> diff --git a/c/src/lib/libbsp/arm/raspberrypi/preinstall.am b/c/src/lib/libbsp/arm/raspberrypi/preinstall.am
>> index 122bc00..346e557 100644
>> --- a/c/src/lib/libbsp/arm/raspberrypi/preinstall.am
>> +++ b/c/src/lib/libbsp/arm/raspberrypi/preinstall.am
>> @@ -134,6 +134,10 @@ $(PROJECT_INCLUDE)/bsp/rpi-gpio.h: include/rpi-gpio.h $(PROJECT_INCLUDE)/bsp/$(d
>>  $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/rpi-gpio.h
>> PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/rpi-gpio.h
>>
>> +$(PROJECT_INCLUDE)/bsp/mailbox.h: include/mailbox.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
>> +  $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/mailbox.h
>> +PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/mailbox.h
>> +
>> $(PROJECT_INCLUDE)/libcpu/cache_.h: ../../../libcpu/arm/shared/include/cache_.h $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
>>  $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libcpu/cache_.h
>> PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu/cache_.h
>>
>
> -- 
> Joel Sherrill, Ph.D. Director of Research & Development
> joel.sherrill at OARcorp.com On-Line Applications Research
> Ask me about RTEMS: a free RTOS Huntsville AL 35805
> Support Available (256) 722-9985
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20150813/06b48d3e/attachment-0002.html>


More information about the devel mailing list