mirror of
git://projects.qi-hardware.com/f32xbase.git
synced 2024-11-04 23:21:53 +02:00
f32x: added support for the c2ben adapter
- f32x/c2-ben.c: bitbang wrapper for the c2ben board - f32x/Makefile: added "ben" target - f32x/gpio-xburst.h, f32x/gpio-xburst.c: GPIO access primitives for XBurst CPUs
This commit is contained in:
parent
80a0152663
commit
bb600dada5
@ -18,12 +18,16 @@ TARGET = om
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
CC_om = arm-angstrom-linux-gnueabi-gcc
|
CC_om = arm-angstrom-linux-gnueabi-gcc
|
||||||
|
CC_ben = mipsel-openwrt-linux-gcc
|
||||||
|
|
||||||
CFLAGS_om = -O -DDRIVER=c2_om
|
CFLAGS_om = -O -DDRIVER=c2_om
|
||||||
|
CFLAGS_ben = -DDRIVER=c2_ben
|
||||||
|
|
||||||
LDFLAGS_om =
|
LDFLAGS_om =
|
||||||
|
LDFLAGS_ben =
|
||||||
|
|
||||||
OBJS_om = c2-om.o gpio-s3c24xx.o rt.o
|
OBJS_om = c2-om.o gpio-s3c24xx.o rt.o
|
||||||
|
OBJS_ben = c2-ben.o gpio-xburst.o
|
||||||
|
|
||||||
NAME = f32x
|
NAME = f32x
|
||||||
CC = $(CC_$(TARGET))
|
CC = $(CC_$(TARGET))
|
||||||
@ -56,9 +60,10 @@ include .depend
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
c2-om.o: c2-bitbang.c
|
c2-om.o: c2-bitbang.c
|
||||||
|
c2-ben.o: c2-bitbang.c
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(OBJS) $(OBJS_om) .depend
|
rm -f $(OBJS) $(OBJS_om) $(OBJS_ben) .depend
|
||||||
|
|
||||||
spotless: clean
|
spotless: clean
|
||||||
rm -f $(NAME)
|
rm -f $(NAME)
|
||||||
|
43
f32x/c2-ben.c
Normal file
43
f32x/c2-ben.c
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* f32x/c2-ben.c - Basic C2 messages, driver for Openmoko GTA01/GTA02+DebugV3
|
||||||
|
*
|
||||||
|
* Written 2010 by Werner Almesberger
|
||||||
|
* Copyright 2010 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 <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
|
#include "gpio-xburst.h"
|
||||||
|
#include "c2-drv.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define POWER_OFF 3, 2 /* PD02, drive low to enable power */
|
||||||
|
#define C2CK 3, 8 /* PD08 */
|
||||||
|
#define C2D 3, 12 /* PD12 */
|
||||||
|
|
||||||
|
|
||||||
|
#include "c2-bitbang.c"
|
||||||
|
|
||||||
|
|
||||||
|
static void ben_init(void)
|
||||||
|
{
|
||||||
|
gpio_init();
|
||||||
|
gpio_low(POWER_OFF);
|
||||||
|
c2_init();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct c2_ops c2_ben = {
|
||||||
|
.init = ben_init,
|
||||||
|
.reset = c2_reset,
|
||||||
|
.addr_write = c2_addr_write,
|
||||||
|
.addr_read = c2_addr_read,
|
||||||
|
.data_write = c2_data_write,
|
||||||
|
.data_read = c2_data_read,
|
||||||
|
};
|
42
f32x/gpio-xburst.c
Normal file
42
f32x/gpio-xburst.c
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* f32x/gpio-xburst.c - Really primitive XBurst GPIO access
|
||||||
|
*
|
||||||
|
* Written 2010 by Werner Almesberger
|
||||||
|
* Copyright 2010 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-xburst.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define BASE 0x10010000
|
||||||
|
|
||||||
|
|
||||||
|
volatile void *mem;
|
||||||
|
|
||||||
|
|
||||||
|
void gpio_init(void)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
fd = open("/dev/mem", O_RDWR);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
80
f32x/gpio-xburst.h
Normal file
80
f32x/gpio-xburst.h
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
/*
|
||||||
|
* f32x/gpio-xburst.h - Really primitive XBurst GPIO access
|
||||||
|
*
|
||||||
|
* Written 2010 by Werner Almesberger
|
||||||
|
* Copyright 2010 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Ports are numbered 0 = A, 1 = B, ...
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef GPIO_XBURST_H
|
||||||
|
#define GPIO_XBURST_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
|
||||||
|
volatile void *mem;
|
||||||
|
|
||||||
|
|
||||||
|
#define REG(off) (*(volatile uint32_t *) (mem+(off)))
|
||||||
|
|
||||||
|
#define port_pin(port) REG(port*0x100)
|
||||||
|
#define port_dats(port) REG(port*0x100+0x14)
|
||||||
|
#define port_datc(port) REG(port*0x100+0x18)
|
||||||
|
#define port_func(port) REG(port*0x100+0x48)
|
||||||
|
#define port_dirs(port) REG(port*0x100+0x64)
|
||||||
|
#define port_dirc(port) REG(port*0x100+0x68)
|
||||||
|
|
||||||
|
|
||||||
|
static inline void gpio_high(unsigned port, unsigned bit)
|
||||||
|
{
|
||||||
|
port_dats(port) = 1 << bit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static inline void gpio_low(unsigned port, unsigned bit)
|
||||||
|
{
|
||||||
|
port_datc(port) = 1 << bit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static inline void gpio_set(unsigned port, unsigned bit, int value)
|
||||||
|
{
|
||||||
|
if (value)
|
||||||
|
gpio_high(port, bit);
|
||||||
|
else
|
||||||
|
gpio_low(port, bit);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static inline int gpio_get(unsigned port, unsigned bit)
|
||||||
|
{
|
||||||
|
return (port_pin(port) >> bit) & 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static inline void gpio_output(unsigned port, unsigned bit)
|
||||||
|
{
|
||||||
|
port_dirs(port) = 1 << bit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static inline void gpio_input(unsigned port, unsigned bit)
|
||||||
|
{
|
||||||
|
port_dirc(port) = 1 << bit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void gpio_init(void);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* !GPIO_XBURST_H */
|
Loading…
Reference in New Issue
Block a user