/* * linux/arch/sh/kernel/io_microdev.c * * Copyright (C) 2003 Sean McGoogan (Sean.McGoogan@superh.com) * * SuperH SH4-202 MicroDev board support. * * May be copied or modified under the terms of the GNU General Public * License. See linux/COPYING for more information. */ #include #include #include /* * we need to have a 'safe' address to re-direct all I/O requests * that we do not explicitly wish to handle. This safe address * must have the following properies: * * * writes are ignored (no exception) * * reads are benign (no side-effects) * * accesses of width 1, 2 and 4-bytes are all valid. * * The Processor Version Register (PVR) has these properties. */ #define PVR 0xff000030 /* Processor Version Register */ #define IO_LAN91C111 0x300ul /* I/O port for SMSC LAN91C111 Ethernet chip */ #define PORT2ADDR(x) (microdev_isa_port2addr(x)) static inline void delay(void) { ctrl_inw(0xa0000000); } unsigned char microdev_inb(unsigned long port) { return *(volatile unsigned char*)PORT2ADDR(port); } unsigned short microdev_inw(unsigned long port) { return *(volatile unsigned short*)PORT2ADDR(port); } unsigned int microdev_inl(unsigned long port) { return *(volatile unsigned int*)PORT2ADDR(port); } void microdev_outb(unsigned char b, unsigned long port) { /* * There is a board feature with the current SH4-202 MicroDev * in that the 2 byte enables (nBE0 and nBE1) are tied together (and to the * Chip Select Line (Ethernet_CS)). Due to this conectivity, it is not possible * to safely perform 8-bit writes to the Ethernet registers, as 16-bits * will be consumed from the Data lines (corrupting the other byte). * Hence, this function is written to impliment 16-bit read/modify/write * for all byte-wide acceses. * * Note: there is no problem with byte READS (even or odd). * * Sean McGoogan - 16th June 2003. */ if ( (port>=IO_LAN91C111) && (port=IO_LAN91C111) && (offset