1
0
aedrix-kernel/devices/pl110.c

76 lines
2.1 KiB
C
Raw Normal View History

/*
Copyright (C) 2012, Aaron Lindsay <aaron@aclindsay.com>
This file is part of Aedrix.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <framebuffer.h>
typedef unsigned int uint32;
#define PL110_CR_EN 0x001
#define PL110_CR_PWR 0x800
#define PL110_IOBASE 0xc0000000
#define PL110_PALBASE (PL110_IOBASE + 0x200)
#define PL110_FB_BASE 0x200000;
struct pl110_control {
uint32 volatile timing0; //0
uint32 volatile timing1; //4
uint32 volatile timing2; //8
uint32 volatile timing3; //c
uint32 volatile upbase; //10
uint32 volatile lpbase; //14
uint32 volatile intrenable; //18
uint32 volatile control; //1c
};
struct fbdev pl110_fb_device;
int pl110_init(struct fb *f, unsigned int color_depth) {
struct pl110_control *plio = (struct pl110_control*)PL110_IOBASE;
/* 640x480 pixels */
plio->timing0 = 0x3f1f3f9c;
plio->timing1 = 0x080b61df;
plio->upbase = PL110_FB_BASE;
if (color_depth == FB_COLOR_DEPTH_8) {
plio->control = 0x1827;
} else if (color_depth == FB_COLOR_DEPTH_16) {
plio->control = 0x1829;
} else if (color_depth == FB_COLOR_DEPTH_24) {
plio->control = 0x182B;
} else {
//assume 16 if nothing else fit
color_depth = 16;
plio->control = 0x1829;
}
f->device = &pl110_fb_device;
f->device->fbaddr = (void*)PL110_FB_BASE;
f->width = 640;
f->device->pixelwidth = 640;
f->height = 480;
f->device->pixelheight = 480;
f->color_depth = color_depth;
f->device->color_depth = color_depth;
return 0;
}