11da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/*
21da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *  arch/mips/pmc-sierra/yosemite/atmel_read_eeprom.c
31da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
41da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *  Copyright (C) 2003 PMC-Sierra Inc.
51da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *  Author: Manish Lachwani (lachwani@pmc-sierra.com)
61da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *  Copyright (C) 2005 Ralf Baechle (ralf@linux-mips.org)
71da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
81da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *  This program is free software; you can redistribute  it and/or modify it
91da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *  under  the terms of  the GNU General  Public License as published by the
101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *  Free Software Foundation;  either version 2 of the  License, or (at your
111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *  option) any later version.
121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *  You should have received a copy of the  GNU General Public License along
251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *  with this program; if not, write  to the Free Software Foundation, Inc.,
261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *  675 Mass Ave, Cambridge, MA 02139, USA.
271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */
281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/*
3042a3b4f25af8f8d77feddf27f839fa0628dbff1aRalf Baechle * Header file for atmel_read_eeprom.c
311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */
321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/types.h>
341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/pci.h>
351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/kernel.h>
361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/slab.h>
371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <asm/pci.h>
381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <asm/io.h>
391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/init.h>
401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <asm/termios.h>
411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <asm/ioctls.h>
421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/ioctl.h>
431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/fcntl.h>
441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define	DEFAULT_PORT 	"/dev/ttyS0"	/* Port to open */
461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define	TXX		0 		/* Dummy loop for spinning */
471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
4842a3b4f25af8f8d77feddf27f839fa0628dbff1aRalf Baechle#define	BLOCK_SEL	0x00
491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define	SLAVE_ADDR	0xa0
501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define	READ_BIT	0x01
511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define	WRITE_BIT	0x00
521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define	R_HEADER	SLAVE_ADDR + BLOCK_SEL + READ_BIT
531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define	W_HEADER	SLAVE_ADDR + BLOCK_SEL + WRITE_BIT
541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/*
561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Clock, Voltages and Data
571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */
581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define	vcc_off		(ioctl(fd, TIOCSBRK, 0))
591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define	vcc_on		(ioctl(fd, TIOCCBRK, 0))
601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define	sda_hi		(ioctl(fd, TIOCMBIS, &dtr))
611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define	sda_lo		(ioctl(fd, TIOCMBIC, &dtr))
621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define	scl_lo		(ioctl(fd, TIOCMBIC, &rts))
631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define	scl_hi		(ioctl(fd, TIOCMBIS, &rts))
641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsconst char rts = TIOCM_RTS;
661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsconst char dtr = TIOCM_DTR;
671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsint fd;
68