Changeset f22f679 in mainline


Ignore:
Timestamp:
2013-04-04T21:01:11Z (11 years ago)
Author:
Beniamino Galvani <b.galvani@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
44186b01
Parents:
409a996
Message:

Raspberry Pi: add framebuffer initialization

Location:
kernel
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/arm32/src/mach/raspberrypi/raspberrypi.c

    r409a996 rf22f679  
    173173static void raspberrypi_output_init(void)
    174174{
     175#ifdef CONFIG_FB
     176        fb_properties_t prop;
     177        if (bcm2835_fb_init(&prop)) {
     178                outdev_t *fb_dev = fb_init(&prop);
     179                if (fb_dev)
     180                        stdout_wire(fb_dev);
     181        }
     182#endif
     183
    175184#ifdef CONFIG_PL011_UART
    176185        if (pl011_uart_init(&raspi.uart, BCM2835_UART_IRQ,
  • kernel/genarch/include/genarch/drivers/bcm2835/mbox.h

    r409a996 rf22f679  
    3737#define _BCM2835_MBOX_H_
    3838
     39#include <genarch/fb/fb.h>
    3940#include <arch/mm/page.h>
    4041#include <align.h>
     
    7980#define MBOX_MSG_VALUE(msg)     ((msg) & ~0xf)
    8081
    81 #define KA2VC(addr)             (KA2PA(addr) + 0x40000000)
     82#define KA2VCA(addr)            (KA2PA(addr) + 0x40000000)
    8283
    8384#define MBOX_ADDR_ALIGN         16
     
    120121} mbox_getmem_buf_t;
    121122
     123typedef struct {
     124        ioport32_t width;
     125        ioport32_t height;
     126        ioport32_t virt_width;
     127        ioport32_t virt_height;
     128        ioport32_t pitch;
     129        ioport32_t bpp;
     130        ioport32_t x_offset;
     131        ioport32_t y_offset;
     132        ioport32_t addr;
     133        ioport32_t size;
     134} bcm2835_fb_desc_t;
     135
    122136bool bcm2835_prop_get_memory(uint32_t *base, uint32_t *size);
     137bool bcm2835_fb_init(fb_properties_t *prop);
    123138
    124139#endif
  • kernel/genarch/src/drivers/bcm2835/mbox.c

    r409a996 rf22f679  
    3434 */
    3535
     36#include <mm/km.h>
     37#include <mm/slab.h>
    3638#include <typedefs.h>
    3739#include <genarch/drivers/bcm2835/mbox.h>
     
    3941static void mbox_write(bcm2835_mbox_t *mbox, uint8_t chan, uint32_t value)
    4042{
    41         if (!mbox)
    42                 mbox = (bcm2835_mbox_t *)BCM2835_MBOX0_ADDR;
    43 
    4443        while (mbox->status & MBOX_STATUS_FULL) ;
    4544        mbox->write = MBOX_COMPOSE(chan, value);
     
    4948{
    5049        uint32_t msg;
    51 
    52         if (!mbox)
    53                 mbox = (bcm2835_mbox_t *)BCM2835_MBOX0_ADDR;
    5450
    5551        do {
     
    7369        req->zero = 0;
    7470
    75         mbox_write(NULL, MBOX_CHAN_PROP_A2V, KA2VC((uint32_t)req));
    76         mbox_read(NULL, MBOX_CHAN_PROP_A2V);
     71        mbox_write((bcm2835_mbox_t *)BCM2835_MBOX0_ADDR,
     72                   MBOX_CHAN_PROP_A2V, KA2VCA((uint32_t)req));
     73        mbox_read((bcm2835_mbox_t *)BCM2835_MBOX0_ADDR,
     74                  MBOX_CHAN_PROP_A2V);
    7775
    7876        if (req->buf_hdr.code == MBOX_PROP_CODE_RESP_OK) {
     
    8785}
    8886
     87bool bcm2835_fb_init(fb_properties_t *prop)
     88{
     89        bcm2835_mbox_t *fb_mbox;
     90        bcm2835_fb_desc_t *fb_desc;
     91        void *fb_desc_buf;
     92        bool ret = false;
     93
     94        fb_desc_buf = malloc(sizeof(bcm2835_fb_desc_t) + MBOX_ADDR_ALIGN, 0);
     95        if (!fb_desc_buf)
     96                return false;
     97
     98        fb_mbox = (void *) km_map(BCM2835_MBOX0_ADDR, sizeof(bcm2835_mbox_t),
     99                                  PAGE_NOT_CACHEABLE);
     100        fb_desc = (bcm2835_fb_desc_t *) ALIGN_UP((uintptr_t)fb_desc_buf,
     101                                                 MBOX_ADDR_ALIGN);
     102
     103        fb_desc->width = 640;
     104        fb_desc->height = 480;
     105        fb_desc->virt_width = fb_desc->width;
     106        fb_desc->virt_height = fb_desc->height;
     107        fb_desc->pitch = 0;                     /* Set by VC */
     108        fb_desc->bpp = 16;
     109        fb_desc->x_offset = 0;
     110        fb_desc->y_offset = 0;
     111        fb_desc->addr = 0;                      /* Set by VC */
     112        fb_desc->size = 0;                      /* Set by VC */
     113
     114        mbox_write(fb_mbox, MBOX_CHAN_FB, KA2VCA(fb_desc));
     115
     116        if (mbox_read(fb_mbox, MBOX_CHAN_FB)) {
     117                printf("BCM2835 framebuffer initialization failed\n");
     118                goto out;
     119        }
     120
     121        prop->addr = fb_desc->addr;
     122        prop->offset = 0;
     123        prop->x = fb_desc->width;
     124        prop->y = fb_desc->height;
     125        prop->scan = fb_desc->pitch;
     126        prop->visual = VISUAL_RGB_5_6_5_LE;
     127
     128        printf("BCM2835 framebuffer at 0x%08x (%dx%d)\n", prop->addr,
     129               prop->x, prop->y);
     130        ret = true;
     131out:
     132        km_unmap((uintptr_t)fb_mbox, sizeof(bcm2835_mbox_t));
     133        free(fb_desc_buf);
     134        return ret;
     135}
     136
    89137/**
    90138 * @}
Note: See TracChangeset for help on using the changeset viewer.