diff options
Diffstat (limited to 'board/isee/common')
-rw-r--r-- | board/isee/common/igep_eeprom.c | 62 | ||||
-rw-r--r-- | board/isee/common/igep_eeprom.h | 17 |
2 files changed, 79 insertions, 0 deletions
diff --git a/board/isee/common/igep_eeprom.c b/board/isee/common/igep_eeprom.c new file mode 100644 index 0000000..ff2e4e2 --- /dev/null +++ b/board/isee/common/igep_eeprom.c @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2016 ISEE 2007 SL - http://www.isee.biz + * + * EEPROM support source file for IGEP0046 board + * + * Author: Jose Miguel Sanchez Sanabria <jsanabria@iseebcn.com> + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include <common.h> +#include <i2c.h> +#include <asm/arch/sys_proto.h> + + +int eeprom_write_setup (uint8_t s_addr, const char* data, u32 size) +{ + u32 i; + u32 remain = size % 32; + u32 blocks = size / 32; + for (i=0; i < blocks; i++){ + if(i2c_write(CONFIG_SYS_I2C_EEPROM_ADDR, s_addr + (i*32), 2, (uint8_t*) data + (i*32), 32)){ + return -1; + } + udelay(5000); + } + if(remain > 0){ + if(i2c_write(CONFIG_SYS_I2C_EEPROM_ADDR, s_addr + (i*32), 2, (uint8_t*) data + (i*32), remain)) + return -1; + else + udelay(5000); + } + return 0; +} + +int eeprom_read_setup (uint8_t s_addr, char* data, u32 size) +{ + u32 i; + u32 remain = size % 32; + u32 blocks = size / 32; + for (i=0; i < blocks; i++){ + if(i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, s_addr + (i*32), 2, (uint8_t*) data + (i*32), 32)){ + return -1; + } + } + if(remain > 0) + if(i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, s_addr + (i*32), 2, (uint8_t*) data + (i*32), remain)) + return -1; + return 0; +} + +int check_eeprom (void) +{ + i2c_set_bus_num(CONFIG_SYS_I2C_EEPROM_BUS); + /* Check if baseboard eeprom is available */ + if (i2c_probe(CONFIG_SYS_I2C_EEPROM_ADDR)) { + printf("Could not probe the EEPROM at 0x%x\n", + CONFIG_SYS_I2C_EEPROM_ADDR); + return -1; + } + return 0; +} diff --git a/board/isee/common/igep_eeprom.h b/board/isee/common/igep_eeprom.h new file mode 100644 index 0000000..db56247 --- /dev/null +++ b/board/isee/common/igep_eeprom.h @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2016 ISEE 2007 SL - http://www.isee.biz + * + * 0046 EEPROM Definitions + * + * Author: Jose Miguel Sanchez Sanabria <jsanabria@iseebcn.com> + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef __EEPROM_BOARD_HELPER__ +#define __EEPROM_BOARD_HELPER__ + +int eeprom_write_setup (uint8_t s_addr, const char* data, u32 size); +int eeprom_read_setup (uint8_t s_addr, char* data, u32 size); +int check_eeprom (void); +#endif |