Commit 3d10ee29 authored by Mikael Starvik's avatar Mikael Starvik Committed by Linus Torvalds

[PATCH] CRIS architecture update for 2.5.74

This brings the chris architecture up to date with 2.5.

The patch is huge because files have been moved to prepare
for future subarchitechtures.
parent 495c3da1
This diff is collapsed.
# $Id: Makefile,v 1.3 2002/01/21 15:21:23 bjornw Exp $
# $Id: Makefile,v 1.15 2003/07/04 12:47:53 tobiasa Exp $
# cris/Makefile
#
# This file is included by the global makefile so that you can add your own
......@@ -13,37 +13,40 @@
# A bug in ld prevents us from having a (constant-value) symbol in a
# "ORIGIN =" or "LENGTH =" expression.
LD = $(CROSS_COMPILE)ld -mcrislinux
arch-y := v10
arch-$(CONFIG_ETRAX_ARCH_V10) := v10
# No config avaiable for make clean etc
ifneq ($(arch-y),)
SARCH := arch-$(arch-y)
else
SARCH :=
endif
# objcopy is used to make binary images from the resulting linked file
LD = $(CROSS_COMPILE)ld -mcrislinux
LDFLAGS_BLOB := --format binary --oformat elf32-cris \
-T arch/cris/$(SARCH)/output_arch.ld
OBJCOPYFLAGS := -O binary -R .note -R .comment -S
# -mlinux enables -march=v10, -fno-underscores, -D__linux__ among others
AFLAGS_vmlinux.lds.o = -DDRAM_VIRTUAL_BASE=0x$(CONFIG_ETRAX_DRAM_VIRTUAL_BASE)
AFLAGS += -mlinux
CFLAGS := $(CFLAGS) -mlinux -pipe
CFLAGS := $(CFLAGS) -mlinux -march=$(arch-y) -pipe
ifdef CONFIG_ETRAX_KGDB
CFLAGS := $(subst -fomit-frame-pointer,,$(CFLAGS)) -g
CFLAGS += -fno-omit-frame-pointer
endif
AFLAGS += -mlinux
HEAD := arch/$(ARCH)/$(SARCH)/kernel/head.o
HEAD := arch/cris/kernel/head.o
ifdef CONFIG_ETRAX_AXISFLASHMAP
# only build this if axis flash map is used, because they depend on
# each others config options
SUBDIRS += arch/cris/boot/rescue
endif
LIBGCC = $(shell $(CC) $(CFLAGS) -print-file-name=libgcc.a)
core-y += arch/cris/kernel/ arch/cris/mm/
drivers-y += arch/cris/drivers/
libs-y += arch/cris/lib/lib.a $(LIBGCC)
MAKEBOOT = $(MAKE) -C arch/$(ARCH)/boot
core-y += arch/$(ARCH)/kernel/ arch/$(ARCH)/mm/
core-y += arch/$(ARCH)/$(SARCH)/kernel/ arch/$(ARCH)/$(SARCH)/mm/
drivers-y += arch/$(ARCH)/$(SARCH)/drivers/
libs-y += arch/$(ARCH)/$(SARCH)/lib/ $(LIBGCC)
vmlinux.bin: vmlinux
$(OBJCOPY) $(OBJCOPYFLAGS) vmlinux vmlinux.bin
......@@ -65,20 +68,43 @@ cramfs:
clinux: vmlinux.bin decompress.bin rescue.bin
decompress.bin: FORCE
@make -C arch/cris/boot/compressed decompress.bin
@make -C arch/$(ARCH)/boot/compressed decompress.bin
rescue.bin: FORCE
@make -C arch/cris/boot/rescue rescue.bin
@make -C arch/$(ARCH)/boot/rescue rescue.bin
zImage: vmlinux.bin
zImage: vmlinux.bin rescue.bin
## zImage - Compressed kernel (gzip)
@$(MAKEBOOT) zImage
@make -C arch/$(ARCH)/boot/ zImage
compressed: zImage
archmrproper:
archclean:
@$(MAKEBOOT) clean
$(Q)$(MAKE) -f scripts/Makefile.clean obj=arch/$(ARCH)/boot
rm -f timage vmlinux.bin cramfs.img
rm -rf $(LD_SCRIPT).tmp
archmrproper:
prepare: arch/$(ARCH)/.links include/asm-$(ARCH)/.arch \
include/asm-$(ARCH)/$(SARCH)/offset.h
# Create some links to make all tools happy
arch/$(ARCH)/.links:
@ln -sfn $(SARCH)/drivers arch/$(ARCH)/drivers
@ln -sfn $(SARCH)/boot arch/$(ARCH)/boot
@ln -sfn $(SARCH)/lib arch/$(ARCH)/lib
@ln -sfn $(SARCH)/vmlinux.lds.S arch/$(ARCH)/vmlinux.lds.S
@touch $@
# Create link to sub arch includes
include/asm-$(ARCH)/.arch: $(wildcard include/config/arch/*.h)
@echo ' Making asm-$(ARCH)/arch -> asm-$(ARCH)/$(SARCH) symlink'
@rm -f include/asm-$(ARCH)/arch
@ln -sf $(SARCH) include/asm-$(ARCH)/arch
@touch $@
arch/$(ARCH)/$(SARCH)/kernel/asm-offsets.s: include/asm include/linux/version.h \
include/config/MARKER
include/asm-$(ARCH)/$(SARCH)/offset.h: arch/$(ARCH)/$(SARCH)/kernel/asm-offsets.s
$(call filechk,gen-asm-offsets)
This diff is collapsed.
......@@ -3,8 +3,8 @@ Memory management for CRIS/MMU
HISTORY:
$Log: README.mm,v $
Revision 1.1.1.1 2001/12/17 13:59:27 bjornw
Import of Linux 2.5.1
Revision 1.1 2001/12/17 13:59:27 bjornw
Initial revision
Revision 1.1 2000/07/10 16:25:21 bjornw
Initial revision
......
Creation of the self-extracting compressed kernel image (vmlinuz)
-----------------------------------------------------------------
$Id: README,v 1.1.1.1 2001/12/17 13:59:27 bjornw Exp $
$Id: README,v 1.1 2001/12/17 13:59:27 bjornw Exp $
This can be slightly confusing because it's a process with many steps.
......
......@@ -13,6 +13,7 @@ SECTIONS
_stext = . ;
*(.text)
*(.rodata)
*(.rodata.*)
_etext = . ;
} > dram
.data :
......
......@@ -10,7 +10,7 @@
#include <linux/config.h>
#define ASSEMBLER_MACROS_ONLY
#include <asm/sv_addr_ag.h>
#include <asm/arch/sv_addr_ag.h>
#define RAM_INIT_MAGIC 0x56902387
......
/*
* misc.c
*
* $Id: misc.c,v 1.1.1.1 2001/12/17 13:59:27 bjornw Exp $
* $Id: misc.c,v 1.4 2003/04/09 05:20:45 starvik Exp $
*
* This is a collection of several routines from gzip-1.0.3
* adapted for Linux.
......@@ -15,7 +15,7 @@
/* where the piggybacked kernel image expects itself to live.
* it is the same address we use when we network load an uncompressed
* image into DRAM, and it is the address the kernel is linked to live
* at by etrax100.ld.
* at by vmlinux.lds.S
*/
#define KERNEL_LOAD_ADR 0x40004000
......@@ -23,7 +23,7 @@
#include <linux/config.h>
#include <linux/types.h>
#include <asm/svinto.h>
#include <asm/arch/svinto.h>
/*
* gzip declarations
......@@ -109,7 +109,7 @@ static void puts(const char *);
extern int end;
static long free_mem_ptr = (long)&end;
#include "../../../../lib/inflate.c"
#include "../../../../../lib/inflate.c"
static void *malloc(int size)
{
......
/* $Id: head.S,v 1.2 2001/12/18 13:35:12 bjornw Exp $
/* $Id: head.S,v 1.6 2003/04/09 08:12:43 pkj Exp $
*
* Rescue code, made to reside at the beginning of the
* flash-memory. when it starts, it checks a partition
......@@ -52,7 +52,7 @@
*
* Bit 0 in flags signifies RW or RO. The rescue code only bothers
* to check the checksum for RO partitions, since the others will
* change its data without updating the checksums. A 1 in bit 0
* change their data without updating the checksums. A 1 in bit 0
* means RO, 0 means RW. That way, it is possible to set a partition
* in RO mode initially, and later mark it as RW, since you can always
* write 0's to the flash.
......@@ -60,12 +60,12 @@
* During the wait for serial input, the status LED will flash so the
* user knows something went wrong.
*
* Copyright (C) 1999,2001 Axis Communications AB
* Copyright (C) 1999, 2000, 2001, 2002, 2003 Axis Communications AB
*/
#include <linux/config.h>
#define ASSEMBLER_MACROS_ONLY
#include <asm/sv_addr_ag.h>
#include <asm/arch/sv_addr_ag.h>
;; The partitiontable is looked for at the first sector after the boot
;; sector. Sector size is 65536 bytes in all flashes we use.
......@@ -192,7 +192,7 @@ no_newjump:
moveq -1, $r7
ploop: move.d [$r3+], $r1 ; partition offset (from ptable start)
bne notfirst ; check if its the partition containing ptable
bne notfirst ; check if it is the partition containing ptable
nop ; yes..
move.d $r8, $r1 ; for its checksum check, skip the ptable
move.d [$r3+], $r2 ; partition length
......
/* $Id: kimagerescue.S,v 1.1.1.1 2001/12/17 13:59:27 bjornw Exp $
/* $Id: kimagerescue.S,v 1.1 2001/12/17 13:59:27 bjornw Exp $
*
* Rescue code to be prepended on a kimage and copied to the
* rescue serial port.
......
/* $Id: testrescue.S,v 1.1.1.1 2001/12/17 13:59:27 bjornw Exp $
/* $Id: testrescue.S,v 1.1 2001/12/17 13:59:27 bjornw Exp $
*
* Simple testcode to download by the rescue block.
* Just lits some LEDs to show it was downloaded correctly.
......
This diff is collapsed.
......@@ -4,13 +4,11 @@
obj-$(CONFIG_ETRAX_ETHERNET) += ethernet.o
obj-$(CONFIG_ETRAX_SERIAL) += serial.o
obj-$(CONFIG_ETRAX_IDE) += ide.o
obj-$(CONFIG_ETRAX_AXISFLASHMAP) += axisflashmap.o
obj-$(CONFIG_ETRAX_I2C) += i2c.o
obj-$(CONFIG_ETRAX_I2C_EEPROM) += eeprom.o
obj-$(CONFIG_ETRAX_GPIO) += gpio.o
obj-$(CONFIG_ETRAX_USB_HOST) += usb-host.o
obj-$(CONFIG_ETRAX_SYNCHRONOUS_SERIAL) += sync_serial.o
obj-$(CONFIG_ETRAX_PARPORT) += parport.o
obj-$(CONFIG_ETRAX_DS1302) += ds1302.o
obj-$(CONFIG_ETRAX_ETHERNET_LPSLAVE) += lpslave
obj-$(CONFIG_ETRAX_PCF8563) += pcf8563.o
......@@ -7,8 +7,37 @@
*! Functions exported: ds1302_readreg, ds1302_writereg, ds1302_init, get_rtc_status
*!
*! $Log: ds1302.c,v $
*! Revision 1.1.1.1 2001/12/17 13:59:27 bjornw
*! Import of Linux 2.5.1
*! Revision 1.9 2003/07/04 08:27:37 starvik
*! Merge of Linux 2.5.74
*!
*! Revision 1.8 2003/04/09 05:20:47 starvik
*! Merge of Linux 2.5.67
*!
*! Revision 1.6 2003/01/09 14:42:51 starvik
*! Merge of Linux 2.5.55
*!
*! Revision 1.4 2002/12/11 13:13:57 starvik
*! Added arch/ to v10 specific includes
*! Added fix from Linux 2.4 in serial.c (flush_to_flip_buffer)
*!
*! Revision 1.3 2002/11/20 11:56:10 starvik
*! Merge of Linux 2.5.48
*!
*! Revision 1.2 2002/11/18 13:16:06 starvik
*! Linux 2.5 port of latest 2.4 drivers
*!
*! Revision 1.15 2002/10/11 16:14:33 johana
*! Added CONFIG_ETRAX_DS1302_TRICKLE_CHARGE and initial setting of the
*! trcklecharge register.
*!
*! Revision 1.14 2002/10/10 12:15:38 magnusmn
*! Added support for having the RST signal on bit g0
*!
*! Revision 1.13 2002/05/29 15:16:08 johana
*! Removed unused variables.
*!
*! Revision 1.12 2002/04/10 15:35:25 johana
*! Moved probe function closer to init function and marked it __init.
*!
*! Revision 1.11 2001/06/14 12:35:52 jonashg
*! The ATA hack is back. It is unfortunately the only way to set g27 to output.
......@@ -85,7 +114,7 @@
*!
*! (C) Copyright 1999, 2000, 2001 Axis Communications AB, LUND, SWEDEN
*!
*! $Id: ds1302.c,v 1.1.1.1 2001/12/17 13:59:27 bjornw Exp $
*! $Id: ds1302.c,v 1.9 2003/07/04 08:27:37 starvik Exp $
*!
*!***************************************************************************/
......@@ -101,7 +130,7 @@
#include <asm/uaccess.h>
#include <asm/system.h>
#include <asm/svinto.h>
#include <asm/arch/svinto.h>
#include <asm/io.h>
#include <asm/rtc.h>
......@@ -232,54 +261,6 @@ ds1302_wdisable(void)
stop();
}
/* Probe for the chip by writing something to its RAM and try reading it back. */
#define MAGIC_PATTERN 0x42
static int
ds1302_probe(void)
{
int retval, res;
TK_RST_DIR(1);
TK_SCL_DIR(1);
TK_SDA_DIR(0);
/* Try to talk to timekeeper. */
ds1302_wenable();
start();
out_byte(0xc0); /* write RAM byte 0 */
out_byte(MAGIC_PATTERN); /* write something magic */
start();
out_byte(0xc1); /* read RAM byte 0 */
if((res = in_byte()) == MAGIC_PATTERN) {
char buf[100];
stop();
ds1302_wdisable();
printk("%s: RTC found.\n", ds1302_name);
printk("%s: SDA, SCL, RST on PB%i, PB%i, %s%i\n",
ds1302_name,
CONFIG_ETRAX_DS1302_SDABIT,
CONFIG_ETRAX_DS1302_SCLBIT,
#ifdef CONFIG_ETRAX_DS1302_RST_ON_GENERIC_PORT
"GENIO",
#else
"PB",
#endif
CONFIG_ETRAX_DS1302_RSTBIT);
get_rtc_status(buf);
printk(buf);
retval = 1;
} else {
stop();
printk("%s: RTC not found.\n", ds1302_name);
retval = 0;
}
return retval;
}
/* Read a byte from the selected register in the DS1302. */
......@@ -315,8 +296,8 @@ get_rtc_time(struct rtc_time *rtc_tm)
{
unsigned long flags;
save_flags(flags);
cli();
local_irq_save(flags);
local_irq_disable();
rtc_tm->tm_sec = CMOS_READ(RTC_SECONDS);
rtc_tm->tm_min = CMOS_READ(RTC_MINUTES);
......@@ -325,7 +306,7 @@ get_rtc_time(struct rtc_time *rtc_tm)
rtc_tm->tm_mon = CMOS_READ(RTC_MONTH);
rtc_tm->tm_year = CMOS_READ(RTC_YEAR);
restore_flags(flags);
local_irq_restore(flags);
BCD_TO_BIN(rtc_tm->tm_sec);
BCD_TO_BIN(rtc_tm->tm_min);
......@@ -371,7 +352,6 @@ rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
{
struct rtc_time rtc_tm;
unsigned char mon, day, hrs, min, sec, leap_yr;
unsigned char save_control, save_freq_select;
unsigned int yrs;
if (!capable(CAP_SYS_TIME))
......@@ -414,15 +394,15 @@ rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
BIN_TO_BCD(mon);
BIN_TO_BCD(yrs);
save_flags(flags);
cli();
local_irq_save(flags);
local_irq_disable();
CMOS_WRITE(yrs, RTC_YEAR);
CMOS_WRITE(mon, RTC_MONTH);
CMOS_WRITE(day, RTC_DAY_OF_MONTH);
CMOS_WRITE(hrs, RTC_HOURS);
CMOS_WRITE(min, RTC_MINUTES);
CMOS_WRITE(sec, RTC_SECONDS);
restore_flags(flags);
local_irq_restore(flags);
/* Notice that at this point, the RTC is updated but
* the kernel is still running with the old time.
......@@ -435,7 +415,6 @@ rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
case RTC_SET_CHARGE: /* set the RTC TRICKLE CHARGE register */
{
int tcs_val;
unsigned char save_control, save_freq_select;
if (!capable(CAP_SYS_TIME))
return -EPERM;
......@@ -484,6 +463,56 @@ static struct file_operations rtc_fops = {
.ioctl = rtc_ioctl,
};
/* Probe for the chip by writing something to its RAM and try reading it back. */
#define MAGIC_PATTERN 0x42
static int __init
ds1302_probe(void)
{
int retval, res;
TK_RST_DIR(1);
TK_SCL_DIR(1);
TK_SDA_DIR(0);
/* Try to talk to timekeeper. */
ds1302_wenable();
start();
out_byte(0xc0); /* write RAM byte 0 */
out_byte(MAGIC_PATTERN); /* write something magic */
start();
out_byte(0xc1); /* read RAM byte 0 */
if((res = in_byte()) == MAGIC_PATTERN) {
char buf[100];
stop();
ds1302_wdisable();
printk("%s: RTC found.\n", ds1302_name);
printk("%s: SDA, SCL, RST on PB%i, PB%i, %s%i\n",
ds1302_name,
CONFIG_ETRAX_DS1302_SDABIT,
CONFIG_ETRAX_DS1302_SCLBIT,
#ifdef CONFIG_ETRAX_DS1302_RST_ON_GENERIC_PORT
"GENIO",
#else
"PB",
#endif
CONFIG_ETRAX_DS1302_RSTBIT);
get_rtc_status(buf);
printk(buf);
retval = 1;
} else {
stop();
printk("%s: RTC not found.\n", ds1302_name);
retval = 0;
}
return retval;
}
/* Just probe for the RTC and register the device to handle the ioctl needed. */
int __init
......@@ -491,27 +520,47 @@ ds1302_init(void)
{
if (!ds1302_probe()) {
#ifdef CONFIG_ETRAX_DS1302_RST_ON_GENERIC_PORT
#if CONFIG_ETRAX_DS1302_RSTBIT == 27
/*
* The only way to set g27 to output is to enable ATA.
*
* Make sure that R_GEN_CONFIG is setup correct.
*/
genconfig_shadow = ((genconfig_shadow &
~IO_MASK(R_GEN_CONFIG, ata))
|
~IO_MASK(R_GEN_CONFIG, ata)) |
(IO_STATE(R_GEN_CONFIG, ata, select)));
*R_GEN_CONFIG = genconfig_shadow;
if (!ds1302_probe())
#elif CONFIG_ETRAX_DS1302_RSTBIT == 0
/* Set the direction of this bit to out. */
genconfig_shadow = ((genconfig_shadow &
~IO_MASK(R_GEN_CONFIG, g0dir)) |
(IO_STATE(R_GEN_CONFIG, g0dir, out)));
*R_GEN_CONFIG = genconfig_shadow;
#endif
if (!ds1302_probe())
return -1;
#else
return -1;
#endif
}
/* Initialise trickle charger */
ds1302_writereg(RTC_TRICKLECHARGER,
RTC_TCR_PATTERN |(CONFIG_ETRAX_DS1302_TRICKLE_CHARGE & 0x0F));
return 0;
}
static int __init ds1302_register(void)
{
ds1302_init();
if (register_chrdev(RTC_MAJOR_NR, ds1302_name, &rtc_fops)) {
printk(KERN_INFO "%s: unable to get major %d for rtc\n",
ds1302_name, RTC_MAJOR_NR);
return -1;
}
return 0;
return 0;
}
module_init(ds1302_register);
......@@ -20,8 +20,24 @@
*! in the spin-lock.
*!
*! $Log: eeprom.c,v $
*! Revision 1.1.1.1 2001/12/17 13:59:27 bjornw
*! Import of Linux 2.5.1
*! Revision 1.9 2003/07/04 08:27:37 starvik
*! Merge of Linux 2.5.74
*!
*! Revision 1.8 2003/04/09 05:20:47 starvik
*! Merge of Linux 2.5.67
*!
*! Revision 1.6 2003/02/10 07:19:28 starvik
*! Removed misplaced ;
*!
*! Revision 1.5 2002/12/11 13:13:57 starvik
*! Added arch/ to v10 specific includes
*! Added fix from Linux 2.4 in serial.c (flush_to_flip_buffer)
*!
*! Revision 1.4 2002/11/20 11:56:10 starvik
*! Merge of Linux 2.5.48
*!
*! Revision 1.3 2002/11/18 13:16:06 starvik
*! Linux 2.5 port of latest 2.4 drivers
*!
*! Revision 1.8 2001/06/15 13:24:29 jonashg
*! * Added verification of pointers from userspace in read and write.
......@@ -74,7 +90,7 @@
#include <linux/fs.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/smp_lock.h>
#include <linux/interrupt.h>
#include <asm/uaccess.h>
#include "i2c.h"
......@@ -425,9 +441,9 @@ int __init eeprom_init(void)
static int eeprom_open(struct inode * inode, struct file * file)
{
if(MINOR(inode->i_rdev) != EEPROM_MINOR_NR)
if(minor(inode->i_rdev) != EEPROM_MINOR_NR)
return -ENXIO;
if(MAJOR(inode->i_rdev) != EEPROM_MAJOR_NR)
if(major(inode->i_rdev) != EEPROM_MAJOR_NR)
return -ENXIO;
if( eeprom.size > 0 )
......@@ -449,39 +465,36 @@ static loff_t eeprom_lseek(struct file * file, loff_t offset, int orig)
* orig 1: relative from current position
* orig 2: position from last eeprom address
*/
loff_t ret;
lock_kernel();
switch (orig)
{
case 0:
ret = file->f_pos = offset;
file->f_pos = offset;
break;
case 1:
ret = file->f_pos += offset;
file->f_pos += offset;
break;
case 2:
ret = file->f_pos = eeprom.size - offset;
file->f_pos = eeprom.size - offset;
break;
default:
ret = -EINVAL;
return -EINVAL;
}
/* truncate position */
if (file->f_pos < 0)
{
file->f_pos = 0;
ret = -EOVERFLOW;
file->f_pos = 0;
return(-EOVERFLOW);
}
if (file->f_pos >= eeprom.size)
{
file->f_pos = eeprom.size - 1;
ret = -EOVERFLOW;
return(-EOVERFLOW);
}
unlock_kernel();
return ( ret );
return ( file->f_pos );
}
/* Reads data from eeprom. */
......@@ -500,7 +513,7 @@ static int eeprom_read_buf(loff_t addr, char * buf, int count)
static ssize_t eeprom_read(struct file * file, char * buf, size_t count, loff_t *off)
{
int i, read=0;
int read=0;
unsigned long p = file->f_pos;
unsigned char page;
......@@ -526,7 +539,7 @@ static ssize_t eeprom_read(struct file * file, char * buf, size_t count, loff_t
if(!eeprom_address(p))
{
printk(KERN_INFO "%s: Read failed to address the eeprom: "
"0x%08X (%i) page: %i\n", eeprom_name, p, p, page);
"0x%08X (%i) page: %i\n", eeprom_name, (int)p, (int)p, page);
i2c_stop();
/* don't forget to wake them up */
......@@ -609,7 +622,7 @@ static ssize_t eeprom_write(struct file * file, const char * buf, size_t count,
if(!eeprom_address(p))
{
printk(KERN_INFO "%s: Write failed to address the eeprom: "
"0x%08X (%i) \n", eeprom_name, p, p);
"0x%08X (%i) \n", eeprom_name, (int)p, (int)p);
i2c_stop();
/* don't forget to wake them up */
......@@ -747,7 +760,7 @@ static int eeprom_close(struct inode * inode, struct file * file)
static int eeprom_address(unsigned long addr)
{
int i, j;
int i;
unsigned char page, offset;
page = (unsigned char) (addr >> 8);
......
This diff is collapsed.
......@@ -12,8 +12,25 @@
*! don't use PB_I2C if DS1302 uses same bits,
*! use PB.
*! $Log: i2c.c,v $
*! Revision 1.1.1.1 2001/12/17 13:59:27 bjornw
*! Import of Linux 2.5.1
*! Revision 1.4 2002/12/11 13:13:57 starvik
*! Added arch/ to v10 specific includes
*! Added fix from Linux 2.4 in serial.c (flush_to_flip_buffer)
*!
*! Revision 1.3 2002/11/20 11:56:11 starvik
*! Merge of Linux 2.5.48
*!
*! Revision 1.2 2002/11/18 13:16:06 starvik
*! Linux 2.5 port of latest 2.4 drivers
*!
*! Revision 1.9 2002/10/31 15:32:26 starvik
*! Update Port B register and shadow even when running with hardware support
*! to avoid glitches when reading bits
*! Never set direction to out in i2c_inbyte
*! Removed incorrect clock togling at end of i2c_inbyte
*!
*! Revision 1.8 2002/08/13 06:31:53 starvik
*! Made SDA and SCL line configurable
*! Modified i2c_inbyte to work with PCF8563
*!
*! Revision 1.7 2001/04/04 13:11:36 markusl
*! Updated according to review remarks
......@@ -43,10 +60,11 @@
*!
*! ---------------------------------------------------------------------------
*!
*! (C) Copyright 1999, 2000, 2001 Axis Communications AB, LUND, SWEDEN
*! (C) Copyright 1999-2002 Axis Communications AB, LUND, SWEDEN
*!
*!***************************************************************************/
/* $Id: i2c.c,v 1.1.1.1 2001/12/17 13:59:27 bjornw Exp $ */
/* $Id: i2c.c,v 1.4 2002/12/11 13:13:57 starvik Exp $ */
/****************** INCLUDE FILES SECTION ***********************************/
#include <linux/module.h>
......@@ -62,7 +80,7 @@
#include <asm/etraxi2c.h>
#include <asm/system.h>
#include <asm/svinto.h>
#include <asm/arch/svinto.h>
#include <asm/io.h>
#include <asm/delay.h>
......@@ -96,8 +114,15 @@ static const char i2c_name[] = "i2c";
#ifdef CONFIG_ETRAX_I2C_USES_PB_NOT_PB_I2C
/* Use PB and not PB_I2C */
#define SDABIT 0
#define SCLBIT 1
#ifndef CONFIG_ETRAX_I2C_DATA_PORT
#define CONFIG_ETRAX_I2C_DATA_PORT 0
#endif
#ifndef CONFIG_ETRAX_I2C_CLK_PORT
#define CONFIG_ETRAX_I2C_CLK_PORT 1
#endif
#define SDABIT CONFIG_ETRAX_I2C_DATA_PORT
#define SCLBIT CONFIG_ETRAX_I2C_CLK_PORT
#define i2c_enable()
#define i2c_disable()
......@@ -117,7 +142,7 @@ static const char i2c_name[] = "i2c";
/* read a bit from the i2c interface */
#define i2c_getbit() (*R_PORT_PB_READ & (1 << SDABIT))
#define i2c_getbit() (((*R_PORT_PB_READ & (1 << SDABIT))) >> SDABIT)
#else
/* enable or disable the i2c interface */
......@@ -127,16 +152,24 @@ static const char i2c_name[] = "i2c";
/* enable or disable output-enable, to select output or input on the i2c bus */
#define i2c_dir_out() *R_PORT_PB_I2C = (port_pb_i2c_shadow &= ~IO_MASK(R_PORT_PB_I2C, i2c_oe_))
#define i2c_dir_in() *R_PORT_PB_I2C = (port_pb_i2c_shadow |= IO_MASK(R_PORT_PB_I2C, i2c_oe_))
#define i2c_dir_out() \
*R_PORT_PB_I2C = (port_pb_i2c_shadow &= ~IO_MASK(R_PORT_PB_I2C, i2c_oe_)); \
REG_SHADOW_SET(R_PORT_PB_DIR, port_pb_dir_shadow, 0, 1);
#define i2c_dir_in() \
*R_PORT_PB_I2C = (port_pb_i2c_shadow |= IO_MASK(R_PORT_PB_I2C, i2c_oe_)); \
REG_SHADOW_SET(R_PORT_PB_DIR, port_pb_dir_shadow, 0, 0);
/* control the i2c clock and data signals */
#define i2c_clk(x) *R_PORT_PB_I2C = (port_pb_i2c_shadow = (port_pb_i2c_shadow & \
~IO_MASK(R_PORT_PB_I2C, i2c_clk)) | IO_FIELD(R_PORT_PB_I2C, i2c_clk, (x)))
#define i2c_clk(x) \
*R_PORT_PB_I2C = (port_pb_i2c_shadow = (port_pb_i2c_shadow & \
~IO_MASK(R_PORT_PB_I2C, i2c_clk)) | IO_FIELD(R_PORT_PB_I2C, i2c_clk, (x))); \
REG_SHADOW_SET(R_PORT_PB_DATA, port_pb_data_shadow, 1, x);
#define i2c_data(x) *R_PORT_PB_I2C = (port_pb_i2c_shadow = (port_pb_i2c_shadow & \
~IO_MASK(R_PORT_PB_I2C, i2c_d)) | IO_FIELD(R_PORT_PB_I2C, i2c_d, (x)))
#define i2c_data(x) \
*R_PORT_PB_I2C = (port_pb_i2c_shadow = (port_pb_i2c_shadow & \
~IO_MASK(R_PORT_PB_I2C, i2c_d)) | IO_FIELD(R_PORT_PB_I2C, i2c_d, (x))); \
REG_SHADOW_SET(R_PORT_PB_DATA, port_pb_data_shadow, 0, x);
/* read a bit from the i2c interface */
......@@ -209,14 +242,15 @@ void
i2c_outbyte(unsigned char x)
{
int i;
i2c_dir_out();
for (i = 0; i < 8; i++) {
if (x & 0x80)
if (x & 0x80) {
i2c_data(I2C_DATA_HIGH);
else
} else {
i2c_data(I2C_DATA_LOW);
}
i2c_delay(CLOCK_LOW_TIME/2);
i2c_clk(I2C_CLOCK_HIGH);
......@@ -241,65 +275,41 @@ i2c_inbyte(void)
{
unsigned char aBitByte = 0;
int i;
int iaa;
/*
* enable output
*/
i2c_dir_out();
/*
* Release data bus by setting
* data high
*/
i2c_data(I2C_DATA_HIGH);
/*
* enable input
*/
/* Switch off I2C to get bit */
i2c_disable();
i2c_dir_in();
/*
* Use PORT PB instead of I2C
* for input. (I2C not working)
*/
i2c_clk(1);
i2c_data(1);
/*
* get bits
*/
for (i = 0; i < 8; i++) {
i2c_delay(CLOCK_LOW_TIME/2);
/*
* low clock period
*/
i2c_delay(CLOCK_HIGH_TIME/2);
/* Get bit */
aBitByte |= i2c_getbit();
/* Enable I2C */
i2c_enable();
i2c_delay(CLOCK_LOW_TIME/2);
for (i = 1; i < 8; i++) {
aBitByte <<= 1;
/* Clock pulse */
i2c_clk(I2C_CLOCK_HIGH);
/*
* switch off I2C
*/
i2c_data(1);
i2c_delay(CLOCK_HIGH_TIME);
i2c_clk(I2C_CLOCK_LOW);
i2c_delay(CLOCK_LOW_TIME);
/* Switch off I2C to get bit */
i2c_disable();
i2c_dir_in();
/*
* wait before getting bit
*/
i2c_delay(CLOCK_HIGH_TIME/2);
aBitByte = (aBitByte << 1);
iaa = i2c_getbit();
aBitByte = aBitByte | iaa ;
/*
* wait
*/
i2c_delay(CLOCK_HIGH_TIME/2);
/*
* end clock puls
*/
/* Get bit */
aBitByte |= i2c_getbit();
/* Enable I2C */
i2c_enable();
i2c_dir_out();
i2c_clk(I2C_CLOCK_LOW);
/*
* low clock period
*/
i2c_delay(CLOCK_LOW_TIME/2);
}
i2c_dir_out();
i2c_clk(I2C_CLOCK_HIGH);
i2c_delay(CLOCK_HIGH_TIME);
return aBitByte;
}
......@@ -424,44 +434,25 @@ i2c_sendack(void)
*#
*#--------------------------------------------------------------------------*/
int
i2c_writereg(unsigned char theSlave, unsigned char theReg,
i2c_writereg(unsigned char theSlave, unsigned char theReg,
unsigned char theValue)
{
int error, cntr = 3;
unsigned long flags;
do {
error = 0;
/*
* we don't like to be interrupted
*/
save_flags(flags);
cli();
/*
* generate start condition
*/
i2c_start();
/*
* dummy preamble
*/
i2c_outbyte(0x01);
i2c_data(I2C_DATA_HIGH);
i2c_clk(I2C_CLOCK_HIGH);
i2c_delay(CLOCK_HIGH_TIME); /* Dummy Acknowledge */
i2c_clk(I2C_CLOCK_LOW);
i2c_delay(CLOCK_LOW_TIME);
i2c_clk(I2C_CLOCK_HIGH);
i2c_delay(CLOCK_LOW_TIME); /* Repeated Start Condition */
i2c_data(I2C_DATA_LOW);
i2c_delay(CLOCK_HIGH_TIME);
i2c_clk(I2C_CLOCK_LOW);
i2c_delay(CLOCK_LOW_TIME);
local_irq_save(flags);
local_irq_disable();
i2c_start();
/*
* send slave address
*/
i2c_outbyte(theSlave);
i2c_outbyte((theSlave & 0xfe));
/*
* wait for ack
*/
......@@ -493,10 +484,10 @@ i2c_writereg(unsigned char theSlave, unsigned char theReg,
/*
* enable interrupt again
*/
restore_flags(flags);
local_irq_restore(flags);
} while(error && cntr--);
i2c_delay(CLOCK_LOW_TIME);
return -error;
......@@ -515,40 +506,23 @@ i2c_readreg(unsigned char theSlave, unsigned char theReg)
unsigned char b = 0;
int error, cntr = 3;
unsigned long flags;
do {
error = 0;
/*
* we don't like to be interrupted
*/
save_flags(flags);
cli();
local_irq_save(flags);
local_irq_disable();
/*
* generate start condition
*/
i2c_start();
/*
* dummy preamble
*/
i2c_outbyte(0x01);
i2c_data(I2C_DATA_HIGH);
i2c_clk(I2C_CLOCK_HIGH);
i2c_delay(CLOCK_HIGH_TIME); /* Dummy Acknowledge */
i2c_clk(I2C_CLOCK_LOW);
i2c_delay(CLOCK_LOW_TIME);
i2c_clk(I2C_CLOCK_HIGH);
i2c_delay(CLOCK_LOW_TIME); /* Repeated Start Condition */
i2c_data(I2C_DATA_LOW);
i2c_delay(CLOCK_HIGH_TIME);
i2c_clk(I2C_CLOCK_LOW);
i2c_delay(CLOCK_LOW_TIME);
i2c_start();
/*
* send slave address
*/
i2c_outbyte(theSlave);
i2c_outbyte((theSlave & 0xfe));
/*
* wait for ack
*/
......@@ -593,7 +567,7 @@ i2c_readreg(unsigned char theSlave, unsigned char theReg)
/*
* enable interrupt again
*/
restore_flags(flags);
local_irq_restore(flags);
} while(error && cntr--);
......
/* $Id: i2c.h,v 1.1.1.1 2001/12/17 13:59:27 bjornw Exp $ */
/* $Id: i2c.h,v 1.2 2002/11/18 13:16:06 starvik Exp $ */
/* High level I2C actions */
int i2c_writereg(unsigned char theSlave, unsigned char theReg, unsigned char theValue);
......
This diff is collapsed.
......@@ -25,6 +25,15 @@
#define SERIAL_RECV_DESCRIPTORS 8
struct etrax_recv_buffer {
struct etrax_recv_buffer *next;
unsigned short length;
unsigned char error;
unsigned char pad;
unsigned char buffer[0];
};
struct e100_serial {
int baud;
volatile u8 *port; /* R_SERIALx_CTRL */
......@@ -79,10 +88,12 @@ struct e100_serial {
int count; /* # of fd on device */
int blocked_open; /* # of blocked opens */
struct circ_buf xmit;
struct circ_buf recv;
unsigned char *flag_buf;
struct etrax_recv_buffer *first_recv_buffer;
struct etrax_recv_buffer *last_recv_buffer;
unsigned int recv_cnt;
unsigned int max_recv_cnt;
struct tq_struct tqueue;
struct work_struct work;
struct async_icount icount; /* error-statistics etc.*/
#ifdef DECLARE_WAITQUEUE
wait_queue_head_t open_wait;
......@@ -101,7 +112,7 @@ struct e100_serial {
int break_detected_cnt;
int errorcode;
#ifdef CONFIG_RS485
#ifdef CONFIG_ETRAX_RS485
struct rs485_control rs485; /* RS-485 support */
#endif
};
......
# $Id: Makefile,v 1.4 2003/07/04 12:57:13 tobiasa Exp $
#
# Makefile for the linux kernel.
#
extra-y := head.o
obj-y := entry.o traps.o shadows.o debugport.o irq.o \
process.o setup.o signal.o traps.o time.o ptrace.o
obj-$(CONFIG_ETRAX_KGDB) += kgdb.o
obj-$(CONFIG_ETRAX_FAST_TIMER) += fasttimer.o
clean:
#include <linux/sched.h>
#include <asm/thread_info.h>
/*
* Generate definitions needed by assembly language modules.
* This code generates raw asm output which is post-processed to extract
* and format the required data.
*/
#define DEFINE(sym, val) \
asm volatile("\n->" #sym " %0 " #val : : "i" (val))
#define BLANK() asm volatile("\n->" : : )
int main(void)
{
#define ENTRY(entry) DEFINE(PT_ ## entry, offsetof(struct pt_regs, entry))
ENTRY(orig_r10);
ENTRY(r13);
ENTRY(r12);
ENTRY(r11);
ENTRY(r10);
ENTRY(r9);
ENTRY(mof);
ENTRY(dccr);
ENTRY(srp);
BLANK();
#undef ENTRY
#define ENTRY(entry) DEFINE(TI_ ## entry, offsetof(struct thread_info, entry))
ENTRY(task);
ENTRY(flags);
ENTRY(preempt_count);
BLANK();
#undef ENTRY
#define ENTRY(entry) DEFINE(THREAD_ ## entry, offsetof(struct thread_struct, entry))
ENTRY(ksp);
ENTRY(usp);
ENTRY(dccr);
BLANK();
#undef ENTRY
#define ENTRY(entry) DEFINE(TASK_ ## entry, offsetof(struct task_struct, entry))
ENTRY(pid);
BLANK();
DEFINE(LCLONE_VM, CLONE_VM);
DEFINE(LCLONE_UNTRACED, CLONE_UNTRACED);
return 0;
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/* $Id: shadows.c,v 1.1.1.1 2001/12/17 13:59:27 bjornw Exp $
/* $Id: shadows.c,v 1.1 2001/12/17 13:59:27 bjornw Exp $
*
* Various shadow registers. Defines for these are in include/asm-etrax100/io.h
*/
......
This diff is collapsed.
This diff is collapsed.
......@@ -2,6 +2,8 @@
# Makefile for Etrax-specific library files..
#
EXTRA_AFLAGS := -traditional
lib-y = checksum.o checksumcopy.o string.o usercopy.o memset.o csumcpfruser.o
/* $Id: checksum.S,v 1.1.1.1 2001/12/17 13:59:27 bjornw Exp $
/* $Id: checksum.S,v 1.1 2001/12/17 13:59:27 bjornw Exp $
* A fast checksum routine using movem
* Copyright (c) 1998-2001 Axis Communications AB
*
......
/* $Id: checksumcopy.S,v 1.1.1.1 2001/12/17 13:59:27 bjornw Exp $
/* $Id: checksumcopy.S,v 1.1 2001/12/17 13:59:27 bjornw Exp $
* A fast checksum+copy routine using movem
* Copyright (c) 1998, 2001 Axis Communications AB
*
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/* At the time of this writing, there's no equivalent ld option. */
OUTPUT_ARCH (cris)
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment