diff options
author | Wolfgang Denk <wd@denx.de> | 2011-08-04 23:05:07 +0200 |
---|---|---|
committer | Wolfgang Denk <wd@denx.de> | 2011-08-04 23:05:07 +0200 |
commit | fb6440ee9b110b759ef61fd80bbd0df1bbf0f37b (patch) | |
tree | dbde38784fb8b48c7f9b14e70a947fab3a1f3bab /arch/arm/cpu/arm920t/at91rm9200/i2c.c | |
parent | 01b0f50060923e89693bf155c677e4f665916b3f (diff) | |
parent | b608b95753873a5073f550cca002c4bebf1a18f5 (diff) | |
download | u-boot-imx-fb6440ee9b110b759ef61fd80bbd0df1bbf0f37b.zip u-boot-imx-fb6440ee9b110b759ef61fd80bbd0df1bbf0f37b.tar.gz u-boot-imx-fb6440ee9b110b759ef61fd80bbd0df1bbf0f37b.tar.bz2 |
Merge branch 'master' of git://git.denx.de/u-boot-arm
* 'master' of git://git.denx.de/u-boot-arm:
drivers/rtc: add Marvell Integrated RTC
Armada100: Add Board Support for Marvell GuruPlug-Display
Armada100: MFP macro naming correction
arm: auto gen asm-offsets.h for mb86r0x
spear: fix build errors for spear3xx/spear600 platforms
cosmetic: arm: lib/board.c: Coding Style cleanup
ARM: versatile: fix board support
SMDKV310: Enable device tree support
SMDKV310: MMC_SPL: Fix building when using "make O="
arm: a320: enable tagged list support
arm: a320: fix multiline comment style
ARMv7: u8500_href: Add missing header to fix compiler warning
Removed unused define, CONFIG_ARMV7.
avr32: add grasshopper (ICnova AP7000) board
AT91/SPI: fix atmel_dataflash_spi.c to allow building without warnings
MAKEALL: remove AT91 boards that are in boards.cfg
AT91: Makes AT91SAM9263-EK build correctly against u-boot-atmel/master
AT91: Makes AT91SAM9263 SoC build correctly against u-boot-atmel/master
AT91: Board fix for AT91SAM9261-EK
AT91: SoC fix at91sam9261_matrix.h
AT91: Makes AT91SAM9RL-EK build correctly against u-boot-atmel/master
AT91: Makes AT91SAM9RL SoC build correctly against u-boot-atmel/master
AT91: change common at91sam9261 files to compile with new scheme
AT91: fix mistake in at91sam9260_devices.c(spi1_hw_init)
a/a/c/arm920t/at91/reset.c: drop obsolete CONFIG_AT91RM9200_USART
README: fix arm920t/at91 path
net/eth.c: drop obsolete at91rm9200 support
README.at91-soc: remove AT91(RM9200) joining notice
a/a/c/arm920t/cpu.c: remove CONFIG_AT91_LEGACY warning
MAKEALL: remove obsolete at91rm9200 soc
ARM: remove obsolete at91rm9200
omap4: clock init support for omap4460
omap4: support TPS programming
omap: reuse omap3 gpio support in omap4
omap4: sdram init changes for omap4460
omap4: add omap4460 revision detection
mkimage: Add OMAP boot image support
omap: add MMC and FAT support to SPL
omap: add basic SPL support
armv7: start.S: fixes and enhancements for SPL
omap4: automatic sdram detection
omap4: calculate EMIF register values
omap4: add sdram init support
omap4: add clock support
omap4: add OMAP4430 revision check
omap4: cleanup pin mux data
omap4: utility function to identify the context of hw init
DA8xx: fix LPSC constants
DA8xx: switch an enum to defines for consistency
DA8xx: add MMC/SD controller addresses
DaVinci EMAC: declare function for all DA8xx CPUs
DA8xx: add generic GPIO driver
DaVinci: rename gpio_defs.h to gpio.h
omap3evm: eth: Include functions only when necessary
omap3evm: Update ethernet reset sequence for Rev.G board
omap3evm: eth: split function setup_net_chip
omap3: Include array definition only when it is used
omap730p2: fix build breaks
omap2420h4: fix build breaks
omap1610inn: fix build breaks
omap1510inn: fix build breaks
omap5912osk: fix build breaks
omap1610h2: fix build breaks
Diffstat (limited to 'arch/arm/cpu/arm920t/at91rm9200/i2c.c')
-rw-r--r-- | arch/arm/cpu/arm920t/at91rm9200/i2c.c | 192 |
1 files changed, 0 insertions, 192 deletions
diff --git a/arch/arm/cpu/arm920t/at91rm9200/i2c.c b/arch/arm/cpu/arm920t/at91rm9200/i2c.c deleted file mode 100644 index 1711088..0000000 --- a/arch/arm/cpu/arm920t/at91rm9200/i2c.c +++ /dev/null @@ -1,192 +0,0 @@ -/* - * i2c Support for Atmel's AT91RM9200 Two-Wire Interface - * - * (c) Rick Bronson - * - * Borrowed heavily from original work by: - * Copyright (c) 2000 Philip Edelbrock <phil@stimpy.netroedge.com> - * - * Modified to work with u-boot by (C) 2004 Gary Jennejohn garyj@denx.de - * - * 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. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * -*/ -#include <common.h> - -#ifdef CONFIG_HARD_I2C - -#include <i2c.h> -#include <asm/io.h> -#include <asm/arch/hardware.h> - -#include <at91rm9200_i2c.h> - -/* define DEBUG */ - -/* - * Poll the i2c status register until the specified bit is set. - * Returns 0 if timed out (100 msec) - */ -static short at91_poll_status(AT91PS_TWI twi, unsigned long bit) { - int loop_cntr = 10000; - do { - udelay(10); - } while (!(twi->TWI_SR & bit) && (--loop_cntr > 0)); - - return (loop_cntr > 0); -} - -/* - * Generic i2c master transfer entrypoint - * - * rw == 1 means that this is a read - */ -static int -at91_xfer(unsigned char chip, unsigned int addr, int alen, - unsigned char *buffer, int len, int rw) -{ - AT91PS_TWI twi = (AT91PS_TWI) AT91_TWI_BASE; - int length; - unsigned char *buf; - /* Set the TWI Master Mode Register */ - twi->TWI_MMR = (chip << 16) | (alen << 8) - | ((rw == 1) ? AT91C_TWI_MREAD : 0); - - /* Set TWI Internal Address Register with first messages data field */ - if (alen > 0) - twi->TWI_IADR = addr; - - length = len; - buf = buffer; - if (length && buf) { /* sanity check */ - if (rw) { - twi->TWI_CR = AT91C_TWI_START; - while (length--) { - if (!length) - twi->TWI_CR = AT91C_TWI_STOP; - /* Wait until transfer is finished */ - if (!at91_poll_status(twi, AT91C_TWI_RXRDY)) { - debug ("at91_i2c: timeout 1\n"); - return 1; - } - *buf++ = twi->TWI_RHR; - } - if (!at91_poll_status(twi, AT91C_TWI_TXCOMP)) { - debug ("at91_i2c: timeout 2\n"); - return 1; - } - } else { - twi->TWI_CR = AT91C_TWI_START; - while (length--) { - twi->TWI_THR = *buf++; - if (!length) - twi->TWI_CR = AT91C_TWI_STOP; - if (!at91_poll_status(twi, AT91C_TWI_TXRDY)) { - debug ("at91_i2c: timeout 3\n"); - return 1; - } - } - /* Wait until transfer is finished */ - if (!at91_poll_status(twi, AT91C_TWI_TXCOMP)) { - debug ("at91_i2c: timeout 4\n"); - return 1; - } - } - } - return 0; -} - -int -i2c_probe(unsigned char chip) -{ - unsigned char buffer[1]; - - return at91_xfer(chip, 0, 0, buffer, 1, 1); -} - -int -i2c_read (unsigned char chip, unsigned int addr, int alen, - unsigned char *buffer, int len) -{ -#ifdef CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW - /* we only allow one address byte */ - if (alen > 1) - return 1; - /* XXX assume an ATMEL AT24C16 */ - if (alen == 1) { -#if 0 /* EEPROM code already sets this correctly */ - chip |= (addr >> 8) & 0xff; -#endif - addr = addr & 0xff; - } -#endif - return at91_xfer(chip, addr, alen, buffer, len, 1); -} - -int -i2c_write(unsigned char chip, unsigned int addr, int alen, - unsigned char *buffer, int len) -{ -#ifdef CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW - int i; - unsigned char *buf; - - /* we only allow one address byte */ - if (alen > 1) - return 1; - /* XXX assume an ATMEL AT24C16 */ - if (alen == 1) { - buf = buffer; - /* do single byte writes */ - for (i = 0; i < len; i++) { -#if 0 /* EEPROM code already sets this correctly */ - chip |= (addr >> 8) & 0xff; -#endif - addr = addr & 0xff; - if (at91_xfer(chip, addr, alen, buf++, 1, 0)) - return 1; - addr++; - } - return 0; - } -#endif - return at91_xfer(chip, addr, alen, buffer, len, 0); -} - -/* - * Main initialization routine - */ -void -i2c_init(int speed, int slaveaddr) -{ - AT91PS_TWI twi = (AT91PS_TWI) AT91_TWI_BASE; - - *AT91C_PIOA_PDR = AT91C_PA25_TWD | AT91C_PA26_TWCK; - *AT91C_PIOA_ASR = AT91C_PA25_TWD | AT91C_PA26_TWCK; - *AT91C_PIOA_MDER = AT91C_PA25_TWD | AT91C_PA26_TWCK; - *AT91C_PMC_PCER = 1 << AT91C_ID_TWI; /* enable peripheral clock */ - - twi->TWI_IDR = 0x3ff; /* Disable all interrupts */ - twi->TWI_CR = AT91C_TWI_SWRST; /* Reset peripheral */ - twi->TWI_CR = AT91C_TWI_MSEN | AT91C_TWI_SVDIS; /* Set Master mode */ - - /* Here, CKDIV = 1 and CHDIV=CLDIV ==> CLDIV = CHDIV = 1/4*((Fmclk/FTWI) -6) */ - twi->TWI_CWGR = AT91C_TWI_CKDIV1 | AT91C_TWI_CLDIV3 | (AT91C_TWI_CLDIV3 << 8); - - debug ("Found AT91 i2c\n"); - return; -} - -#endif /* CONFIG_HARD_I2C */ |