From: Heiko Schocher <hs@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 12/13] at91: add hardware i2c drivers
Date: Mon, 30 Mar 2009 07:53:35 +0200 [thread overview]
Message-ID: <49D05E5F.6060000@denx.de> (raw)
In-Reply-To: <1238193026-12564-12-git-send-email-plagnioj@jcrosoft.com>
Hello Jean,
Jean-Christophe PLAGNIOL-VILLARD wrote:
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> ---
> cpu/arm926ejs/at91/Makefile | 6 +
> .../arm926ejs/at91/at91cap9_i2c.c | 31 ++--
> .../arm926ejs/at91/at91sam9260_i2c.c | 31 ++--
> .../arm926ejs/at91/at91sam9261_i2c.c | 31 ++--
> .../arm926ejs/at91/at91sam9263_i2c.c | 31 ++--
> .../clk.h => cpu/arm926ejs/at91/at91sam9rl_i2c.c | 37 ++--
> drivers/i2c/Makefile | 1 +
> drivers/i2c/atmel_i2c.c | 234 ++++++++++++++++++++
> include/asm-arm/arch-at91/at91_common.h | 2 +
> include/asm-arm/arch-at91/at91_twi.h | 68 ++++++
> include/asm-arm/arch-at91/clk.h | 4 +
> include/asm-arm/arch-at91/hardware.h | 5 +
> 12 files changed, 405 insertions(+), 76 deletions(-)
> copy include/asm-arm/arch-at91/at91_common.h => cpu/arm926ejs/at91/at91cap9_i2c.c (61%)
> copy include/asm-arm/arch-at91/at91_common.h => cpu/arm926ejs/at91/at91sam9260_i2c.c (61%)
> copy include/asm-arm/arch-at91/at91_common.h => cpu/arm926ejs/at91/at91sam9261_i2c.c (61%)
> copy include/asm-arm/arch-at91/at91_common.h => cpu/arm926ejs/at91/at91sam9263_i2c.c (61%)
> copy include/asm-arm/arch-at91/clk.h => cpu/arm926ejs/at91/at91sam9rl_i2c.c (52%)
> create mode 100644 drivers/i2c/atmel_i2c.c
> create mode 100644 include/asm-arm/arch-at91/at91_twi.h
>
>
[...]
> diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
> index 9c74657..27a5251 100644
> --- a/drivers/i2c/Makefile
> +++ b/drivers/i2c/Makefile
> @@ -25,6 +25,7 @@ include $(TOPDIR)/config.mk
>
> LIB := $(obj)libi2c.a
>
> +COBJS-$(CONFIG_I2C_ATMEL) += atmel_i2c.o
> COBJS-$(CONFIG_BFIN_TWI_I2C) += bfin-twi_i2c.o
> COBJS-$(CONFIG_FSL_I2C) += fsl_i2c.o
> COBJS-$(CONFIG_I2C_MXC) += mxc_i2c.o
>
Independent from your patch, I think we need here a common
rule. Either we name in future this define "CONFIG_I2C_XXX"
or "CONFIG_XXX_I2C. I vote for using "CONFIG_I2C_XXX"
> diff --git a/drivers/i2c/atmel_i2c.c b/drivers/i2c/atmel_i2c.c
> new file mode 100644
> index 0000000..b4c5530
> --- /dev/null
> +++ b/drivers/i2c/atmel_i2c.c
> @@ -0,0 +1,234 @@
> +/*
> + * 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 at 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
>
Why not "#if defined(CONFIG_I2C_ATMEL)" as in the Makefile?
> +
> +#include <i2c.h>
> +#include <asm/io.h>
>
[...]
> + 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
>
please remove dead code.
> + 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
>
here too, please remove dead code.
> + addr = addr & 0xff;
> + if (at91_xfer(chip, addr, alen, buf++, 1, 0))
> + return 1;
> + addr++;
> + }
> + return 0;
>
[...]
> diff --git a/include/asm-arm/arch-at91/at91_twi.h b/include/asm-arm/arch-at91/at91_twi.h
> new file mode 100644
> index 0000000..bb2880f
> --- /dev/null
> +++ b/include/asm-arm/arch-at91/at91_twi.h
> @@ -0,0 +1,68 @@
> +/*
> + * arch/arm/mach-at91/include/mach/at91_twi.h
> + *
> + * Copyright (C) 2005 Ivan Kokshaysky
> + * Copyright (C) SAN People
> + *
> + * Two-wire Interface (TWI) registers.
> + * Based on AT91RM9200 datasheet revision E.
> + *
> + * 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.
> + */
> +
> +#ifndef AT91_TWI_H
> +#define AT91_TWI_H
> +
> +#define AT91_TWI_CR 0x00 /* Control Register */
> +#define AT91_TWI_START (1 << 0) /* Send a Start Condition */
> +#define AT91_TWI_STOP (1 << 1) /* Send a Stop Condition */
> +#define AT91_TWI_MSEN (1 << 2) /* Master Transfer Enable */
> +#define AT91_TWI_MSDIS (1 << 3) /* Master Transfer Disable */
> +#define AT91_TWI_SVEN (1 << 4) /* Slave Transfer Enable [SAM9260 only] */
> +#define AT91_TWI_SVDIS (1 << 5) /* Slave Transfer Disable [SAM9260 only] */
> +#define AT91_TWI_SWRST (1 << 7) /* Software Reset */
>
^^^^^^^^^^^^^^^
doule tabs breaks line length (this affects for the
whole file)
> +
> +#define AT91_TWI_MMR 0x04 /* Master Mode Register */
> +#define AT91_TWI_IADRSZ (3 << 8) /* Internal Device Address Size */
> +#define AT91_TWI_IADRSZ_NO (0 << 8)
> +#define AT91_TWI_IADRSZ_1 (1 << 8)
> +#define AT91_TWI_IADRSZ_2 (2 << 8)
> +#define AT91_TWI_IADRSZ_3 (3 << 8)
> +#define AT91_TWI_MREAD (1 << 12) /* Master Read Direction */
> +#define AT91_TWI_DADR (0x7f << 16) /* Device Address */
> +
> +#define AT91_TWI_SMR 0x08 /* Slave Mode Register [SAM9260 only] */
> +#define AT91_TWI_SADR (0x7f << 16) /* Slave Address */
> +
> +#define AT91_TWI_IADR 0x0c /* Internal Address Register */
> +
> +#define AT91_TWI_CWGR 0x10 /* Clock Waveform Generator Register */
> +#define AT91_TWI_CLDIV (0xff << 0) /* Clock Low Divisor */
> +#define AT91_TWI_CHDIV (0xff << 8) /* Clock High Divisor */
> +#define AT91_TWI_CKDIV (7 << 16) /* Clock Divider */
> +
> +#define AT91_TWI_SR 0x20 /* Status Register */
> +#define AT91_TWI_TXCOMP (1 << 0) /* Transmission Complete */
> +#define AT91_TWI_RXRDY (1 << 1) /* Receive Holding Register Ready */
> +#define AT91_TWI_TXRDY (1 << 2) /* Transmit Holding Register Ready */
> +#define AT91_TWI_SVREAD (1 << 3) /* Slave Read [SAM9260 only] */
> +#define AT91_TWI_SVACC (1 << 4) /* Slave Access [SAM9260 only] */
> +#define AT91_TWI_GACC (1 << 5) /* General Call Access [SAM9260 only] */
> +#define AT91_TWI_OVRE (1 << 6) /* Overrun Error [AT91RM9200 only] */
> +#define AT91_TWI_UNRE (1 << 7) /* Underrun Error [AT91RM9200 only] */
> +#define AT91_TWI_NACK (1 << 8) /* Not Acknowledged */
> +#define AT91_TWI_ARBLST (1 << 9) /* Arbitration Lost [SAM9260 only] */
> +#define AT91_TWI_SCLWS (1 << 10) /* Clock Wait State [SAM9260 only] */
> +#define AT91_TWI_EOSACC (1 << 11) /* End of Slave Address [SAM9260 only] */
> +
> +#define AT91_TWI_IER 0x24 /* Interrupt Enable Register */
> +#define AT91_TWI_IDR 0x28 /* Interrupt Disable Register */
> +#define AT91_TWI_IMR 0x2c /* Interrupt Mask Register */
> +#define AT91_TWI_RHR 0x30 /* Receive Holding Register */
> +#define AT91_TWI_THR 0x34 /* Transmit Holding Register */
> +
> +#endif
> +
>
bye
Heiko
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
next prev parent reply other threads:[~2009-03-30 5:53 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-27 22:30 [U-Boot] [PATCH 01/13 V2] at91sam9/at91cap: spi init add hardware chip select support Jean-Christophe PLAGNIOL-VILLARD
2009-03-27 22:30 ` [U-Boot] [PATCH 02/13 V2] at91sam9: add watchdog support Jean-Christophe PLAGNIOL-VILLARD
2009-03-27 22:30 ` [U-Boot] [PATCH 03/13] at91: rename DATAFLASH_MMC_SELECT to CONFIG_DATAFLASH_MMC_SELECT Jean-Christophe PLAGNIOL-VILLARD
2009-03-27 22:30 ` [U-Boot] [PATCH 04/13] at91rm9200dk: Move conditional compilation to Makefile Jean-Christophe PLAGNIOL-VILLARD
2009-03-27 22:30 ` [U-Boot] [PATCH 05/13] add dataflash mmc mux missing support Jean-Christophe PLAGNIOL-VILLARD
2009-03-27 22:30 ` [U-Boot] [PATCH 06/13] Add support for the AT91RM9200EK Board Jean-Christophe PLAGNIOL-VILLARD
2009-03-27 22:30 ` [U-Boot] [PATCH 07/13] at91rm9200: move serial driver to drivers/serial Jean-Christophe PLAGNIOL-VILLARD
2009-03-27 22:30 ` [U-Boot] [PATCH 08/13] at91rm9200: move serial shutdown code to serial drivers Jean-Christophe PLAGNIOL-VILLARD
2009-03-27 22:30 ` [U-Boot] [PATCH 09/13] at91rm9200: Reset update Jean-Christophe PLAGNIOL-VILLARD
2009-03-27 22:30 ` [U-Boot] [PATCH 10/13] at91: move usb driver to drivers/usb Jean-Christophe PLAGNIOL-VILLARD
2009-03-27 22:30 ` [U-Boot] [PATCH 11/13] at91: move dataflash spi driver to drivers/spi Jean-Christophe PLAGNIOL-VILLARD
2009-03-27 22:30 ` [U-Boot] [PATCH 12/13] at91: add hardware i2c drivers Jean-Christophe PLAGNIOL-VILLARD
2009-03-27 22:30 ` [U-Boot] [PATCH 13/13] at91sam9263ek: active hush and auto compelete support Jean-Christophe PLAGNIOL-VILLARD
2009-03-31 20:35 ` Wolfgang Denk
2009-03-31 22:42 ` Stelian Pop
2009-03-30 5:53 ` Heiko Schocher [this message]
2009-03-30 7:24 ` [U-Boot] [PATCH 12/13] at91: add hardware i2c drivers Jean-Christophe PLAGNIOL-VILLARD
2009-03-30 8:26 ` Heiko Schocher
2009-03-30 8:50 ` Jean-Christophe PLAGNIOL-VILLARD
2009-03-30 10:43 ` Wolfgang Denk
2009-03-30 11:55 ` Jean-Christophe PLAGNIOL-VILLARD
2009-03-31 20:40 ` Wolfgang Denk
2009-05-14 6:06 ` Daniel Gorsulowski
2009-03-31 18:28 ` [U-Boot] [PATCH 10/13] at91: move usb driver to drivers/usb Remy Bohmer
2009-03-31 19:21 ` Jean-Christophe PLAGNIOL-VILLARD
2009-03-31 20:38 ` Wolfgang Denk
2009-03-31 21:55 ` Jean-Christophe PLAGNIOL-VILLARD
2009-04-01 6:55 ` Stefan Roese
2009-04-01 7:25 ` Remy Bohmer
2009-04-01 7:22 ` Jean-Christophe PLAGNIOL-VILLARD
2009-04-01 7:57 ` Remy Bohmer
2009-04-01 8:01 ` Jean-Christophe PLAGNIOL-VILLARD
2009-04-01 9:07 ` Wolfgang Denk
2009-04-01 8:13 ` Jean-Christophe PLAGNIOL-VILLARD
2009-04-01 8:59 ` Michael Trimarchi
2009-04-01 9:27 ` Stefan Roese
2009-04-01 9:44 ` Jean-Christophe PLAGNIOL-VILLARD
2009-04-01 12:19 ` Stefan Roese
2009-04-01 17:21 ` [U-Boot] [RFC PATCH] drivers/usb: regorganisation Jean-Christophe PLAGNIOL-VILLARD
2009-04-01 22:12 ` Wolfgang Denk
2009-04-02 5:22 ` Jean-Christophe PLAGNIOL-VILLARD
2009-04-02 15:26 ` Remy Bohmer
2009-04-02 16:55 ` [U-Boot] [RFC PATCH V2] " Jean-Christophe PLAGNIOL-VILLARD
2009-04-02 18:07 ` Wolfgang Denk
2009-04-02 19:27 ` Jean-Christophe PLAGNIOL-VILLARD
2009-04-02 23:06 ` Wolfgang Denk
2009-04-03 5:10 ` Jean-Christophe PLAGNIOL-VILLARD
2009-04-03 10:46 ` [U-Boot] [PATCH] " Jean-Christophe PLAGNIOL-VILLARD
2009-04-03 11:19 ` Remy Bohmer
2009-04-02 11:11 ` [U-Boot] [RFC PATCH] " Mike Frysinger
2009-04-01 15:56 ` [U-Boot] [PATCH 10/13] at91: move usb driver to drivers/usb ksi at koi8.net
2009-04-01 15:53 ` ksi at koi8.net
2009-04-01 15:48 ` ksi at koi8.net
2009-04-01 16:03 ` Michael Trimarchi
2009-04-01 16:31 ` Jean-Christophe PLAGNIOL-VILLARD
2009-04-01 16:28 ` Jean-Christophe PLAGNIOL-VILLARD
2009-04-01 19:42 ` Scott Wood
2009-03-31 21:22 ` Remy Bohmer
2009-03-31 20:36 ` Wolfgang Denk
2009-04-01 22:15 ` [U-Boot] [PATCH 08/13] at91rm9200: move serial shutdown code to serial drivers Wolfgang Denk
2009-04-01 22:14 ` [U-Boot] [PATCH 07/13] at91rm9200: move serial driver to drivers/serial Wolfgang Denk
2009-05-26 15:47 ` [U-Boot] [PATCH 06/13] Add support for the AT91RM9200EK Board Haavard Skinnemoen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49D05E5F.6060000@denx.de \
--to=hs@denx.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.