OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [rc203soc/] [sw/] [uClinux/] [arch/] [i960/] [kernel/] [bios32.c] - Diff between revs 1623 and 1765

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 1623 Rev 1765
/*
/*
 * Copyright (C) 1999   Keith Adams     <kma@cse.ogi.edu>
 * Copyright (C) 1999   Keith Adams     <kma@cse.ogi.edu>
 *                      Oregon Graduate Institute
 *                      Oregon Graduate Institute
 *
 *
 * Bios and PCI stuff.
 * Bios and PCI stuff.
 */
 */
 
 
#include <linux/pci.h>
#include <linux/pci.h>
#include <linux/bios32.h>
#include <linux/bios32.h>
#include <linux/config.h>
#include <linux/config.h>
#include <linux/kernel.h>
#include <linux/kernel.h>
#include <asm/system.h>
#include <asm/system.h>
 
 
unsigned long bios32_init(unsigned long memory_start, unsigned long memory_end)
unsigned long bios32_init(unsigned long memory_start, unsigned long memory_end)
{
{
        return memory_start;
        return memory_start;
}
}
 
 
unsigned long pcibios_init(unsigned long memory_start, unsigned long memory_end)
unsigned long pcibios_init(unsigned long memory_start, unsigned long memory_end)
{
{
        return memory_start;
        return memory_start;
}
}
 
 
unsigned long pcibios_fixup(unsigned long memory_start, unsigned long memory_end)
unsigned long pcibios_fixup(unsigned long memory_start, unsigned long memory_end)
{
{
        return memory_start;
        return memory_start;
}
}
 
 
#ifdef CONFIG_MON960
#ifdef CONFIG_MON960
 
 
#include <asm/mon960.h>
#include <asm/mon960.h>
 
 
/*
/*
 * mon960 system calls for pci management
 * mon960 system calls for pci management
 */
 */
extern int mon960_pcibios_present(void* info);
extern int mon960_pcibios_present(void* info);
extern int mon960_pcibios_find_device(int vendor, int dev, int idx, void* loc);
extern int mon960_pcibios_find_device(int vendor, int dev, int idx, void* loc);
extern int mon960_pcibios_find_class(int class, int idx, void* dev);
extern int mon960_pcibios_find_class(int class, int idx, void* dev);
 
 
int pcibios_present(void)
int pcibios_present(void)
{
{
        return 1;
        return 1;
}
}
 
 
int pcibios_find_device(unsigned short vendor, unsigned short dev,
int pcibios_find_device(unsigned short vendor, unsigned short dev,
                        unsigned short index, unsigned char* bus,
                        unsigned short index, unsigned char* bus,
                        unsigned char* dev_fn)
                        unsigned char* dev_fn)
{
{
        pci_dev_info    loc;
        pci_dev_info    loc;
        int             status;
        int             status;
 
 
        if ((status=mon960_pcibios_find_device(vendor, dev, index, &loc)))
        if ((status=mon960_pcibios_find_device(vendor, dev, index, &loc)))
                return -1;
                return -1;
 
 
        printk("PCI device found: %x, %x, %x\n", loc.bus, loc.dev, loc.fn);
        printk("PCI device found: %x, %x, %x\n", loc.bus, loc.dev, loc.fn);
        *bus = loc.bus;
        *bus = loc.bus;
        *dev_fn = loc.dev;
        *dev_fn = loc.dev;
        return 0;
        return 0;
}
}
 
 
int pcibios_find_class(unsigned int class, unsigned short idx,
int pcibios_find_class(unsigned int class, unsigned short idx,
                       unsigned char* bus, unsigned char* dev_fn)
                       unsigned char* bus, unsigned char* dev_fn)
{
{
        pci_dev_info    loc;
        pci_dev_info    loc;
        int             status;
        int             status;
 
 
        if ((status=mon960_pcibios_find_class(class, idx, &loc)))
        if ((status=mon960_pcibios_find_class(class, idx, &loc)))
                return -1;
                return -1;
 
 
        *bus = loc.bus;
        *bus = loc.bus;
        *dev_fn = loc.dev;
        *dev_fn = loc.dev;
        return 0;
        return 0;
}
}
 
 
#define CONFIG_RDWR(op,sz,type) \
#define CONFIG_RDWR(op,sz,type) \
int pcibios_ ## op ## _config_ ## sz(unsigned char bus, unsigned char fn, \
int pcibios_ ## op ## _config_ ## sz(unsigned char bus, unsigned char fn, \
                                unsigned char offset, type val) \
                                unsigned char offset, type val) \
{       \
{       \
        return mon960_pcibios_ ## op ## _config_ ## sz(bus, fn, 0, offset, val); \
        return mon960_pcibios_ ## op ## _config_ ## sz(bus, fn, 0, offset, val); \
}
}
 
 
CONFIG_RDWR(read,byte,unsigned char*);
CONFIG_RDWR(read,byte,unsigned char*);
CONFIG_RDWR(read,word,unsigned short*);
CONFIG_RDWR(read,word,unsigned short*);
CONFIG_RDWR(read,dword,unsigned int*);
CONFIG_RDWR(read,dword,unsigned int*);
CONFIG_RDWR(write,byte,unsigned char);
CONFIG_RDWR(write,byte,unsigned char);
CONFIG_RDWR(write,word,unsigned short);
CONFIG_RDWR(write,word,unsigned short);
CONFIG_RDWR(write,dword,unsigned int);
CONFIG_RDWR(write,dword,unsigned int);
 
 
#endif  /* CONFIG_MON960 */
#endif  /* CONFIG_MON960 */
 
 
/*
/*
 * Dealing with the ATU. We just do all accesses translated; checking
 * Dealing with the ATU. We just do all accesses translated; checking
 * whether we can directly use the address might not be any faster.
 * whether we can directly use the address might not be any faster.
 */
 */
 
 
/* external address = (local address & 0x03ffffff) | ATU_OMWVR */
/* external address = (local address & 0x03ffffff) | ATU_OMWVR */
#define OIOW_BASE       0x90000000UL    /* outbound I/O space window */
#define OIOW_BASE       0x90000000UL    /* outbound I/O space window */
#define ATU_OIOWVR      ((unsigned long*) 0x125c)       /* I/O window val */
#define ATU_OIOWVR      ((unsigned long*) 0x125c)       /* I/O window val */
 
 
/* Set up ATU, return local address to use */
/* Set up ATU, return local address to use */
static unsigned long program_atu(unsigned long pciaddr)
static unsigned long program_atu(unsigned long pciaddr)
{
{
        unsigned long retval;
        unsigned long retval;
        unsigned long pci_hibits = pciaddr & 0xfc000000;
        unsigned long pci_hibits = pciaddr & 0xfc000000;
        *ATU_OIOWVR = pci_hibits;
        *ATU_OIOWVR = pci_hibits;
        retval = (pciaddr & 0x03ffffff) | OIOW_BASE;
        retval = (pciaddr & 0x03ffffff) | OIOW_BASE;
        return retval;
        return retval;
}
}
 
 
/* Note that we synchronize ATU access with the ipl.
/* Note that we synchronize ATU access with the ipl.
 *
 *
 * XXX: diddling the ipl every time seems to be a performance problem. Is
 * XXX: diddling the ipl every time seems to be a performance problem. Is
 * there any way to use the i960 hardware in just one memory op, instead of
 * there any way to use the i960 hardware in just one memory op, instead of
 * two?
 * two?
 */
 */
 
 
#define READ_OP(type,name)      \
#define READ_OP(type,name)      \
type name(char* addr)   \
type name(char* addr)   \
{       \
{       \
        volatile type *local_addr;      \
        volatile type *local_addr;      \
        type retval;    \
        type retval;    \
        unsigned long oldatu = *ATU_OIOWVR;     \
        unsigned long oldatu = *ATU_OIOWVR;     \
        local_addr = (volatile type*)   \
        local_addr = (volatile type*)   \
                program_atu((unsigned long)addr);       \
                program_atu((unsigned long)addr);       \
        retval = *local_addr;   \
        retval = *local_addr;   \
        *ATU_OIOWVR = oldatu;   \
        *ATU_OIOWVR = oldatu;   \
        return retval;  \
        return retval;  \
}
}
READ_OP(unsigned char,readb)
READ_OP(unsigned char,readb)
READ_OP(unsigned short,readw)
READ_OP(unsigned short,readw)
READ_OP(unsigned int,readl)
READ_OP(unsigned int,readl)
#undef READ_OP
#undef READ_OP
 
 
#define WRITE_OP(type,name)     \
#define WRITE_OP(type,name)     \
type name(type val, char* addr) \
type name(type val, char* addr) \
{       \
{       \
        volatile type *local_addr;      \
        volatile type *local_addr;      \
        type retval;    \
        type retval;    \
        unsigned long oldatu = *ATU_OIOWVR;     \
        unsigned long oldatu = *ATU_OIOWVR;     \
        local_addr = (volatile type*)   \
        local_addr = (volatile type*)   \
                program_atu((unsigned long)addr);       \
                program_atu((unsigned long)addr);       \
        retval = *local_addr = val;     \
        retval = *local_addr = val;     \
        *ATU_OIOWVR = oldatu;   \
        *ATU_OIOWVR = oldatu;   \
        return retval;  \
        return retval;  \
}
}
WRITE_OP(unsigned char,writeb)
WRITE_OP(unsigned char,writeb)
WRITE_OP(unsigned short,writew)
WRITE_OP(unsigned short,writew)
WRITE_OP(unsigned int,writel)
WRITE_OP(unsigned int,writel)
#undef WRITE_OP
#undef WRITE_OP
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.