1
0
mirror of git://projects.qi-hardware.com/f32xbase.git synced 2024-11-24 00:33:10 +02:00
f32xbase/f32x/gpio-s3c24xx.c
Werner Almesberger 6dbd844d0f f32x: open /dev/mem with O_SYNC to disable caching
- f32x/gpio-s3c24xx.c (gpio_init), f32x/gpio-xburst.c (gpio_init): open
  /dev/mem with O_SYNC to disable caching
2011-01-03 18:33:56 -03:00

43 lines
859 B
C

/*
* f32x/gpio-s3c24xx.c - Really primitive S3C244x GPIO access. Ports B-H only.
*
* Written 2008, 2011 by Werner Almesberger
* Copyright 2008, 2011 Werner Almesberger
*
* 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.
*/
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/mman.h>
#include "gpio-s3c24xx.h"
#define BASE 0x56000000
volatile uint32_t *mem;
void gpio_init(void)
{
int fd;
fd = open("/dev/mem", O_RDWR | O_SYNC);
if (fd < 0) {
perror("/dev/mem");
exit(1);
}
mem = mmap(NULL, 0x1000, PROT_READ | PROT_WRITE, MAP_SHARED, fd, BASE);
if (mem == MAP_FAILED) {
perror("mmap");
exit(1);
}
}