[U-Boot-Users] [PATCH] New Dummy I2C Driver

Ricardo Ribalda Delgado ricardo.ribalda at uam.es
Fri Jul 11 12:26:56 CEST 2008


Version cleaned

On Fri, Jul 11, 2008 at 12:26 PM, Ricardo Ribalda Delgado
<ricardo.ribalda at uam.es> wrote:
> This driver provides access to a false i2c eeprom.
>  This false eeprom could be very useful in boards with
>  ddr2 memories and no i2c interfaces.
>  Using this driver the user can simulate the spd interface
>  of the ddr2 memory and use the ddr2 auto config
>
> Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda at uam.es>
> ---
>  drivers/i2c/Makefile    |    1 +
>  drivers/i2c/dummy_i2c.c |   65 +++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 66 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/i2c/dummy_i2c.c
>
> diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
> index 534c015..94a0791 100644
> --- a/drivers/i2c/Makefile
> +++ b/drivers/i2c/Makefile
> @@ -30,6 +30,7 @@ COBJS-y += omap1510_i2c.o
>  COBJS-y += omap24xx_i2c.o
>  COBJS-y += tsi108_i2c.o
>  COBJS-y += mxc_i2c.o
> +COBJS-$(CONFIG_DUMMY_I2C) += dummy_i2c.o
>
>  COBJS  := $(COBJS-y)
>  SRCS   := $(COBJS:.o=.c)
> diff --git a/drivers/i2c/dummy_i2c.c b/drivers/i2c/dummy_i2c.c
> new file mode 100644
> index 0000000..ce859c3
> --- /dev/null
> +++ b/drivers/i2c/dummy_i2c.c
> @@ -0,0 +1,65 @@
> +/*
> +    (C) Copyright 2008
> +    Ricado Ribalda-Universidad Autonoma de Madrid-ricardo.ribalda at uam.es
> +    This work has been supported by: Q-Technology  http://qtec.com/
> +
> +    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, see <http://www.gnu.org/licenses/>.
> +*/
> +
> +#include <common.h>
> +#include <i2c.h>
> +
> +#define DUMMY_I2C_LEN 256
> +
> +u8 i2c_dummy_buffer[DUMMY_I2C_LEN]= CONFIG_DUMMY_I2C_DATA;
> +
> +void i2c_init(int speed, int slaveaddr){
> +       return ;
> +}
> +
> +int i2c_read(uchar chip, uint addr, int alen, uchar * buffer, int len)
> +{
> +       int i;
> +       if (alen!=1)
> +               return -1;
> +
> +       if (addr+len>DUMMY_I2C_LEN)
> +               return -1;
> +
> +       for(i=0;i<len;i++){
> +               buffer[i]=i2c_dummy_buffer[i+addr];
> +       }
> +
> +       return 0;
> +}
> +int i2c_write(uchar chip, uint addr, int alen, uchar * buffer, int len)
> +{
> +       int i;
> +       if (alen!=1)
> +               return -1;
> +       if (addr+len>DUMMY_I2C_LEN)
> +               return -1;
> +
> +       for(i=0;i<len;i++){
> +               i2c_dummy_buffer[i+addr]=buffer[i];
> +       }
> +
> +       return 0;
> +}
> +
> +int i2c_probe(uchar chip)
> +{
> +       return 0;
> +}
> +
> --
> 1.5.6.2
>
>



-- 
Ricardo Ribalda
http://www.eps.uam.es/~rribalda/




More information about the U-Boot mailing list