Commit 306d6a02 authored by Grzegorz Daniluk's avatar Grzegorz Daniluk

rename eeprom_* to storage_* as we now have also Flash support

parent 69f8368e
......@@ -13,7 +13,7 @@ obj-$(CONFIG_WR_NODE) += \
obj-$(CONFIG_WR_SWITCH) += dev/timer-wrs.o dev/ad9516.o
obj-$(CONFIG_LEGACY_EEPROM) += dev/eeprom.o
obj-$(CONFIG_SDB_EEPROM) += dev/sdb-eeprom.o
obj-$(CONFIG_SDB_EEPROM) += dev/sdb-storage.o
obj-$(CONFIG_W1) += dev/w1.o dev/w1-hw.o dev/w1-shell.o
obj-$(CONFIG_W1) += dev/w1-temp.o dev/w1-eeprom.o
......
......@@ -11,7 +11,7 @@
#include "types.h"
#include "i2c.h"
#include "eeprom.h"
#include "storage.h"
#include "board.h"
#include "syscon.h"
......@@ -60,7 +60,7 @@ uint8_t has_eeprom = 0;
static int i2cif, i2c_addr; /* globals, using the names we always used */
void eeprom_init(int chosen_i2cif, int chosen_i2c_addr)
void storage_init(int chosen_i2cif, int chosen_i2c_addr)
{
/* Save these to globals, they are never passed any more */
i2cif = chosen_i2cif;
......@@ -134,7 +134,7 @@ static int eeprom_write(uint8_t i2cif, uint8_t i2c_addr, uint32_t offset,
return size;
}
int32_t eeprom_sfpdb_erase(void)
int32_t storage_sfpdb_erase(void)
{
uint8_t sfpcount = 0;
......@@ -146,7 +146,7 @@ int32_t eeprom_sfpdb_erase(void)
return sfpcount;
}
int eeprom_get_sfp(struct s_sfpinfo * sfp,
int storage_get_sfp(struct s_sfpinfo * sfp,
uint8_t add, uint8_t pos)
{
static uint8_t sfpcount = 0;
......@@ -201,14 +201,14 @@ int eeprom_get_sfp(struct s_sfpinfo * sfp,
return sfpcount;
}
int eeprom_match_sfp(struct s_sfpinfo * sfp)
int storage_match_sfp(struct s_sfpinfo * sfp)
{
uint8_t sfpcount = 1;
int8_t i, temp;
struct s_sfpinfo dbsfp;
for (i = 0; i < sfpcount; ++i) {
temp = eeprom_get_sfp(&dbsfp, 0, i);
temp = storage_get_sfp(&dbsfp, 0, i);
if (!i) {
sfpcount = temp; //only in first round valid sfpcount is returned from eeprom_get_sfp
if (sfpcount == 0 || sfpcount == 0xFF)
......@@ -227,7 +227,7 @@ int eeprom_match_sfp(struct s_sfpinfo * sfp)
return 0;
}
int eeprom_phtrans(uint32_t * val,
int storage_phtrans(uint32_t * val,
uint8_t write)
{
int8_t ret;
......@@ -254,7 +254,7 @@ int eeprom_phtrans(uint32_t * val,
}
}
int eeprom_init_erase(void)
int storage_init_erase(void)
{
uint16_t used = 0;
......@@ -268,7 +268,7 @@ int eeprom_init_erase(void)
/*
* Appends a new shell command at the end of boot script
*/
int eeprom_init_add(const char *args[])
int storage_init_add(const char *args[])
{
uint8_t i = 1;
uint8_t separator = ' ';
......@@ -311,7 +311,7 @@ int eeprom_init_add(const char *args[])
return 0;
}
int eeprom_init_show(void)
int storage_init_show(void)
{
uint16_t used, i;
uint8_t byte;
......@@ -335,7 +335,7 @@ int eeprom_init_show(void)
return 0;
}
int eeprom_init_readcmd(uint8_t *buf, uint8_t bufsize, uint8_t next)
int storage_init_readcmd(uint8_t *buf, uint8_t bufsize, uint8_t next)
{
static uint16_t ptr;
static uint16_t used = 0;
......
......@@ -14,7 +14,7 @@ LGPL 2.1
#include "board.h"
#include "syscon.h"
#include <endpoint.h>
#include "eeprom.h"
#include "storage.h"
#include <hw/endpoint_regs.h>
#include <hw/endpoint_mdio.h>
......
......@@ -17,7 +17,7 @@
#include "endpoint.h"
#include "softpll_ng.h"
#include "wrc_ptp.h"
#include "eeprom.h"
#include "storage.h"
#include "ptpd_netif.h"
/* New calibrator for the transition phase value. A major pain in the ass for
......@@ -213,7 +213,7 @@ static int calib_t24p_master(uint32_t *value)
{
int rv;
rv = eeprom_phtrans(value, 0);
rv = storage_phtrans(value, 0);
if(rv < 0) {
pp_printf("Error %d while reading EEPROM\n", rv);
return rv;
......@@ -241,9 +241,9 @@ static int calib_t24p_slave(uint32_t *value)
* Let's see if we have a matching value in EEPROM:
* accept a 200ps difference, otherwise rewrite eeprom
*/
rv = eeprom_phtrans(&prev, 0 /* rd */);
rv = storage_phtrans(&prev, 0 /* rd */);
if (rv < 0 || (prev < *value - 200) || (prev > *value + 200)) {
rv = eeprom_phtrans(value, 1);
rv = storage_phtrans(value, 1);
pp_printf("Wrote new t24p value: %d ps (%s)\n", *value,
rv < 0 ? "Failed" : "Success");
}
......
......@@ -10,13 +10,10 @@
//#include <string.h>
#include <wrc.h>
#include <w1.h>
#include <eeprom.h>
#include <storage.h>
#include "types.h"
#include "i2c.h"
//#include "eeprom.h"
//#include "board.h"
//#include "syscon.h"
#include <sdb.h>
#define SDBFS_BIG_ENDIAN
......@@ -163,7 +160,7 @@ static int sdb_i2c_erase(struct sdbfs *fs, int offset, int count)
/*
* A trivial dumper, just to show what's up in there
*/
static void eeprom_sdb_list(struct sdbfs *fs)
static void storage_sdb_list(struct sdbfs *fs)
{
struct sdb_device *d;
int new = 1;
......@@ -192,7 +189,7 @@ uint8_t has_eeprom = 0; /* modified at init time */
*
* This is called by wrc_main, after initializing both w1 and i2c
*/
void eeprom_init(int chosen_i2cif, int chosen_i2c_addr)
void storage_init(int chosen_i2cif, int chosen_i2c_addr)
{
uint32_t magic = 0;
static unsigned entry_points_eeprom[] = {0, 64, 128, 256, 512, 1024};
......@@ -283,7 +280,7 @@ found_exit:
/* found: register the filesystem */
has_eeprom = 1;
sdbfs_dev_create(&wrc_sdb);
eeprom_sdb_list(&wrc_sdb);
storage_sdb_list(&wrc_sdb);
return;
}
......@@ -366,7 +363,7 @@ int set_persistent_mac(uint8_t portnum, uint8_t * mac)
/* Erase SFB database in the memory */
int32_t eeprom_sfpdb_erase(void)
int32_t storage_sfpdb_erase(void)
{
int ret;
......@@ -381,7 +378,7 @@ int32_t eeprom_sfpdb_erase(void)
/* Dummy check if sfp information is correct by verifying it doesn't have
* 0xff bytes */
static int eeprom_sfp_valid(struct s_sfpinfo *sfp)
static int sfp_valid(struct s_sfpinfo *sfp)
{
int i;
......@@ -392,7 +389,7 @@ static int eeprom_sfp_valid(struct s_sfpinfo *sfp)
return 1;
}
int eeprom_get_sfp(struct s_sfpinfo * sfp,
int storage_get_sfp(struct s_sfpinfo * sfp,
uint8_t add, uint8_t pos)
{
static uint8_t sfpcount = 0;
......@@ -413,7 +410,7 @@ int eeprom_get_sfp(struct s_sfpinfo * sfp,
while (sdbfs_fread(&wrc_sdb, sizeof(sfpcount) +
sfpcount*sizeof(tempsfp), &tempsfp,
sizeof(tempsfp)) == sizeof(tempsfp)) {
if(!eeprom_sfp_valid(&tempsfp))
if(!sfp_valid(&tempsfp))
break;
sfpcount++;
......@@ -463,14 +460,14 @@ out:
return 0;
}
int eeprom_match_sfp(struct s_sfpinfo * sfp)
int storage_match_sfp(struct s_sfpinfo * sfp)
{
uint8_t sfpcount = 1;
int8_t i, temp;
struct s_sfpinfo dbsfp;
for (i = 0; i < sfpcount; ++i) {
temp = eeprom_get_sfp(&dbsfp, 0, i);
temp = storage_get_sfp(&dbsfp, 0, i);
if (!i) {
// first round: valid sfpcount is returned
sfpcount = temp;
......@@ -494,7 +491,7 @@ int eeprom_match_sfp(struct s_sfpinfo * sfp)
* Phase transition ("calibration" file)
*/
#define VALIDITY_BIT 0x80000000
int eeprom_phtrans(uint32_t * valp,
int storage_phtrans(uint32_t * valp,
uint8_t write)
{
int ret = -1;
......@@ -534,7 +531,7 @@ out:
* ------------------------------------------------
*/
int eeprom_init_erase(void)
int storage_init_erase(void)
{
int ret;
......@@ -550,7 +547,7 @@ int eeprom_init_erase(void)
/*
* Appends a new shell command at the end of boot script
*/
int eeprom_init_add(const char *args[])
int storage_init_add(const char *args[])
{
int len, i;
uint8_t separator = ' ';
......@@ -604,7 +601,7 @@ out:
return ret;
}
int eeprom_init_show(void)
int storage_init_show(void)
{
int ret = -1;
uint16_t used;
......@@ -631,7 +628,7 @@ out:
return ret;
}
int eeprom_init_readcmd(uint8_t *buf, uint8_t bufsize, uint8_t next)
int storage_init_readcmd(uint8_t *buf, uint8_t bufsize, uint8_t next)
{
int i = 0, ret = -1;
uint16_t used;
......
#ifndef __EEPROM_H
#define __EEPROM_H
#ifndef __STORAGE_H
#define __STORAGE_H
#define SFP_SECTION_PATTERN 0xdeadbeef
#define SFPS_MAX 4
......@@ -27,19 +27,19 @@ struct s_sfpinfo {
uint8_t chksum;
} __attribute__ ((__packed__));
void eeprom_init(int i2cif, int i2c_addr);
void storage_init(int i2cif, int i2c_addr);
int eeprom_sfpdb_erase(void);
int eeprom_match_sfp(struct s_sfpinfo *sfp);
int eeprom_get_sfp(struct s_sfpinfo * sfp,
int storage_sfpdb_erase(void);
int storage_match_sfp(struct s_sfpinfo *sfp);
int storage_get_sfp(struct s_sfpinfo * sfp,
uint8_t add, uint8_t pos);
int eeprom_phtrans(uint32_t * val,
int storage_phtrans(uint32_t * val,
uint8_t write);
int eeprom_init_erase(void);
int eeprom_init_add(const char *args[]);
int eeprom_init_show(void);
int eeprom_init_readcmd(uint8_t *buf, uint8_t bufsize, uint8_t next);
int storage_init_erase(void);
int storage_init_add(const char *args[]);
int storage_init_show(void);
int storage_init_readcmd(uint8_t *buf, uint8_t bufsize, uint8_t next);
#endif
......@@ -16,7 +16,7 @@
#include <string.h>
#include <wrc.h>
#include "shell.h"
#include "eeprom.h"
#include "storage.h"
#include "syscon.h"
#include "rxts_calibrator.h"
......@@ -27,9 +27,9 @@ static int cmd_calibration(const char *args[])
if (args[0] && !strcasecmp(args[0], "force")) {
if (measure_t24p(&trans) < 0)
return -1;
return eeprom_phtrans(&trans, 1);
return storage_phtrans(&trans, 1);
} else if (!args[0]) {
if (eeprom_phtrans(&trans, 0) > 0) {
if (storage_phtrans(&trans, 0) > 0) {
mprintf("Found phase transition in EEPROM: %dps\n",
trans);
cal_phase_transition = trans;
......@@ -39,7 +39,7 @@ static int cmd_calibration(const char *args[])
if (measure_t24p(&trans) < 0)
return -1;
cal_phase_transition = trans;
return eeprom_phtrans(&trans, 1);
return storage_phtrans(&trans, 1);
}
}
......
......@@ -10,7 +10,7 @@
#include <string.h>
#include <wrc.h>
#include "shell.h"
#include "eeprom.h"
#include "storage.h"
#include "syscon.h"
#include "i2c.h"
......@@ -22,15 +22,15 @@ static int cmd_init(const char *args[])
}
if (args[0] && !strcasecmp(args[0], "erase")) {
if (eeprom_init_erase() < 0)
if (storage_init_erase() < 0)
mprintf("Could not erase init script\n");
} else if (args[1] && !strcasecmp(args[0], "add")) {
if (eeprom_init_add(args) < 0)
if (storage_init_add(args) < 0)
mprintf("Could not add the command\n");
else
mprintf("OK.\n");
} else if (args[0] && !strcasecmp(args[0], "show")) {
eeprom_init_show();
storage_init_show();
} else if (args[0] && !strcasecmp(args[0], "boot")) {
shell_boot_script();
}
......
......@@ -25,7 +25,7 @@
#include <wrc.h>
#include "shell.h"
#include "eeprom.h"
#include "storage.h"
#include "syscon.h"
#include "sfp.h"
......@@ -51,7 +51,7 @@ static int cmd_sfp(const char *args[])
// return 0;
// }
else if (!strcasecmp(args[0], "erase")) {
if (eeprom_sfpdb_erase() ==
if (storage_sfpdb_erase() ==
EE_RET_I2CERR)
mprintf("Could not erase DB\n");
} else if (args[4] && !strcasecmp(args[0], "add")) {
......@@ -66,7 +66,7 @@ static int cmd_sfp(const char *args[])
sfp.dTx = atoi(args[2]);
sfp.dRx = atoi(args[3]);
sfp.alpha = atoi(args[4]);
temp = eeprom_get_sfp(&sfp, 1, 0);
temp = storage_get_sfp(&sfp, 1, 0);
if (temp == EE_RET_DBFULL)
mprintf("SFP DB is full\n");
else if (temp == EE_RET_I2CERR)
......@@ -75,9 +75,9 @@ static int cmd_sfp(const char *args[])
mprintf("%d SFPs in DB\n", temp);
} else if (args[0] && !strcasecmp(args[0], "show")) {
for (i = 0; i < sfpcount; ++i) {
temp = eeprom_get_sfp(&sfp, 0, i);
temp = storage_get_sfp(&sfp, 0, i);
if (!i) {
sfpcount = temp; //only in first round valid sfpcount is returned from eeprom_get_sfp
sfpcount = temp; //only in first round valid sfpcount is returned from storage_get_sfp
if (sfpcount == 0 || sfpcount == 0xFF) {
mprintf("SFP database empty...\n");
return 0;
......@@ -98,7 +98,7 @@ static int cmd_sfp(const char *args[])
return 0;
}
strncpy(sfp.pn, pn, SFP_PN_LEN);
if (eeprom_match_sfp(&sfp) > 0) {
if (storage_match_sfp(&sfp) > 0) {
mprintf("SFP matched, dTx=%d, dRx=%d, alpha=%d\n",
sfp.dTx, sfp.dRx, sfp.alpha);
sfp_deltaTx = sfp.dTx;
......
......@@ -18,7 +18,7 @@
#include "uart.h"
#include "syscon.h"
#include "shell.h"
#include "eeprom.h"
#include "storage.h"
#define SH_MAX_LINE_LEN 80
#define SH_MAX_ARGS 8
......@@ -256,7 +256,7 @@ int shell_boot_script(void)
return -1;
while (1) {
cmd_len = eeprom_init_readcmd((uint8_t *)cmd_buf,
cmd_len = storage_init_readcmd((uint8_t *)cmd_buf,
SH_MAX_LINE_LEN, next);
if (cmd_len <= 0) {
if (next == 0)
......
......@@ -21,7 +21,7 @@
#include "pps_gen.h"
#include "ptpd_netif.h"
#include "i2c.h"
#include "eeprom.h"
#include "storage.h"
#include "softpll_ng.h"
#include "onewire.h"
#include "pps_gen.h"
......@@ -62,8 +62,8 @@ static void wrc_initialize()
flash_init();
/*initialize I2C bus*/
mi2c_init(WRPC_FMC_I2C);
/*check if EEPROM is onboard*/
eeprom_init(WRPC_FMC_I2C, FMC_EEPROM_ADR);
/*init storage (Flash / W1 EEPROM / I2C EEPROM*/
storage_init(WRPC_FMC_I2C, FMC_EEPROM_ADR);
mac_addr[0] = 0x08; //
mac_addr[1] = 0x00; // CERN OUI
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment