2 * (C) Copyright 2012 Stephen Warren
4 * See file CREDITS for list of people who contributed to this
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
20 #include <asm/arch/mbox.h>
21 #include <asm/global_data.h>
23 DECLARE_GLOBAL_DATA_PTR;
25 /* Global variables that lcd.c expects to exist */
30 void *lcd_console_address;
34 char lcd_cursor_enabled;
35 ushort lcd_cursor_width;
36 ushort lcd_cursor_height;
39 struct bcm2835_mbox_hdr hdr;
40 struct bcm2835_mbox_tag_physical_w_h physical_w_h;
45 struct bcm2835_mbox_hdr hdr;
46 struct bcm2835_mbox_tag_physical_w_h physical_w_h;
47 struct bcm2835_mbox_tag_virtual_w_h virtual_w_h;
48 struct bcm2835_mbox_tag_depth depth;
49 struct bcm2835_mbox_tag_pixel_order pixel_order;
50 struct bcm2835_mbox_tag_alpha_mode alpha_mode;
51 struct bcm2835_mbox_tag_virtual_offset virtual_offset;
52 struct bcm2835_mbox_tag_overscan overscan;
53 struct bcm2835_mbox_tag_allocate_buffer allocate_buffer;
57 void lcd_ctrl_init(void *lcdbase)
59 ALLOC_ALIGN_BUFFER(struct msg_query, msg_query, 1, 16);
60 ALLOC_ALIGN_BUFFER(struct msg_setup, msg_setup, 1, 16);
64 debug("bcm2835: Query resolution...\n");
66 BCM2835_MBOX_INIT_HDR(msg_query);
67 BCM2835_MBOX_INIT_TAG_NO_REQ(&msg_query->physical_w_h,
69 ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg_query->hdr);
71 printf("bcm2835: Could not query display resolution\n");
72 /* FIXME: How to disable the LCD to prevent errors? hang()? */
76 w = msg_query->physical_w_h.body.resp.width;
77 h = msg_query->physical_w_h.body.resp.height;
79 debug("bcm2835: Setting up display for %d x %d\n", w, h);
81 BCM2835_MBOX_INIT_HDR(msg_setup);
82 BCM2835_MBOX_INIT_TAG(&msg_setup->physical_w_h, SET_PHYSICAL_W_H);
83 msg_setup->physical_w_h.body.req.width = w;
84 msg_setup->physical_w_h.body.req.height = h;
85 BCM2835_MBOX_INIT_TAG(&msg_setup->virtual_w_h, SET_VIRTUAL_W_H);
86 msg_setup->virtual_w_h.body.req.width = w;
87 msg_setup->virtual_w_h.body.req.height = h;
88 BCM2835_MBOX_INIT_TAG(&msg_setup->depth, SET_DEPTH);
89 msg_setup->depth.body.req.bpp = 16;
90 BCM2835_MBOX_INIT_TAG(&msg_setup->pixel_order, SET_PIXEL_ORDER);
91 msg_setup->pixel_order.body.req.order = BCM2835_MBOX_PIXEL_ORDER_BGR;
92 BCM2835_MBOX_INIT_TAG(&msg_setup->alpha_mode, SET_ALPHA_MODE);
93 msg_setup->alpha_mode.body.req.alpha = BCM2835_MBOX_ALPHA_MODE_IGNORED;
94 BCM2835_MBOX_INIT_TAG(&msg_setup->virtual_offset, SET_VIRTUAL_OFFSET);
95 msg_setup->virtual_offset.body.req.x = 0;
96 msg_setup->virtual_offset.body.req.y = 0;
97 BCM2835_MBOX_INIT_TAG(&msg_setup->overscan, SET_OVERSCAN);
98 msg_setup->overscan.body.req.top = 0;
99 msg_setup->overscan.body.req.bottom = 0;
100 msg_setup->overscan.body.req.left = 0;
101 msg_setup->overscan.body.req.right = 0;
102 BCM2835_MBOX_INIT_TAG(&msg_setup->allocate_buffer, ALLOCATE_BUFFER);
103 msg_setup->allocate_buffer.body.req.alignment = 0x100;
105 ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg_setup->hdr);
107 printf("bcm2835: Could not configure display\n");
108 /* FIXME: How to disable the LCD to prevent errors? hang()? */
112 w = msg_setup->physical_w_h.body.resp.width;
113 h = msg_setup->physical_w_h.body.resp.height;
115 debug("bcm2835: Final resolution is %d x %d\n", w, h);
117 panel_info.vl_col = w;
118 panel_info.vl_row = h;
119 panel_info.vl_bpix = LCD_COLOR16;
121 gd->fb_base = msg_setup->allocate_buffer.body.resp.fb_address;
122 lcd_base = (void *)gd->fb_base;
125 void lcd_enable(void)