2 * Library's linux interface.
3 * Currently FIC GTA02 specific.
5 * Copyright (C) 2007 OpenMoko, Inc.
6 * Author: Chia-I Wu <olv@openmoko.org>
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 or
11 * (at your option) version 3 of the License.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
28 #include <sys/types.h>
29 #include <sys/ioctl.h>
37 #define FB_SIZE 0x800000
41 static struct fb_fix_screeninfo fix
;
43 volatile unsigned char *glamo_fb
;
44 volatile unsigned char *glamo_mmio
;
47 #ifndef FB_ACCEL_GLAMO
48 # define FB_ACCEL_GLAMO 50 /* SMedia Glamo */
51 int glamo_os_init(const char *fb_path
)
53 if (!fb_path
|| !*fb_path
)
56 fd_fb
= open(fb_path
, O_RDWR
| O_SYNC
);
59 printf("error opening %s: %s\n", fb_path
, strerror(errno
));
63 if (ioctl(fd_fb
, FBIOGET_FSCREENINFO
, &fix
) < 0)
65 printf("error in FBIOGET_FSCREENINFO: %s\n", strerror(errno
));
71 if (fix
.accel
!= FB_ACCEL_GLAMO
) {
72 printf("No Glamo chip found or the kerne is old.\n");
73 /* TODO: Bail out, once the FB_ACCEL_GLAMO #define goes
78 fix
.smem_len
= FB_SIZE
;
79 glamo_pitch
= fix
.line_length
;
81 fd_mem
= open("/dev/mem", O_RDWR
| O_SYNC
);
84 printf("error opening mem: %s\n", strerror(errno
));
90 /* TODO: use map_phys_mem and unmap_phys_mem */
91 glamo_fb
= mmap(NULL
, fix
.smem_len
, PROT_READ
| PROT_WRITE
,
92 MAP_SHARED
, fd_mem
, fix
.smem_start
);
93 if (glamo_fb
== MAP_FAILED
)
95 printf("error mmap'ping fb: %s\n", strerror(errno
));
97 munmap((void *) glamo_fb
, fix
.smem_len
);
103 /* TODO: use map_phys_mem and unmap_phys_mem */
104 glamo_mmio
= mmap(NULL
, GLAMO_MMIO_SIZE
, PROT_READ
| PROT_WRITE
,
105 MAP_SHARED
, fd_mem
, GLAMO_MMIO_BASE
);
106 if (glamo_mmio
== MAP_FAILED
)
108 printf("error mmap'ping mmio: %s\n", strerror(errno
));
110 munmap((void *) glamo_fb
, fix
.smem_len
);
117 printf("fb 0x%08lx (0x%x)\n"
118 "mmio 0x%08x (0x%x)\n",
119 fix
.smem_start
, fix
.smem_len
,
120 GLAMO_MMIO_BASE
, GLAMO_MMIO_SIZE
);
125 void glamo_os_finish(void)
127 munmap((void *) glamo_mmio
, GLAMO_MMIO_SIZE
);
128 munmap((void *) glamo_fb
, fix
.smem_len
);