Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
Software for White Rabbit PTP Core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
32
Issues
32
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Software for White Rabbit PTP Core
Commits
be5c7d72
Commit
be5c7d72
authored
Jul 15, 2020
by
Grzegorz Daniluk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
storage: fix i2c eeprom storage
parent
6ae2239e
Pipeline
#313
failed with stages
in 11 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
33 additions
and
15 deletions
+33
-15
bb_i2c.c
dev/bb_i2c.c
+3
-1
i2c_eeprom.c
dev/i2c_eeprom.c
+3
-0
storage.c
dev/storage.c
+21
-11
bb_i2c.h
include/dev/bb_i2c.h
+3
-3
syscon.h
include/dev/syscon.h
+2
-0
storage.h
include/storage.h
+1
-0
No files found.
dev/bb_i2c.c
View file @
be5c7d72
...
...
@@ -97,7 +97,9 @@ void bb_i2c_get_byte(struct i2c_bus *bus, uint8_t *data, uint8_t last)
*
data
=
indata
;
}
void
bb_i2c_create
(
struct
i2c_bus
*
bus
,
struct
gpio_pin
*
pin_scl
,
struct
gpio_pin
*
pin_sda
)
void
bb_i2c_create
(
struct
i2c_bus
*
bus
,
const
struct
gpio_pin
*
pin_scl
,
const
struct
gpio_pin
*
pin_sda
)
{
bus
->
pin_scl
=
pin_scl
;
bus
->
pin_sda
=
pin_sda
;
...
...
dev/i2c_eeprom.c
View file @
be5c7d72
...
...
@@ -11,6 +11,9 @@
#include "dev/bb_i2c.h"
#include "dev/i2c_eeprom.h"
struct
i2c_bus
i2c_wrc_eeprom
;
struct
i2c_eeprom_device
wrc_eeprom_dev
;
int
i2c_eeprom_create
(
struct
i2c_eeprom_device
*
dev
,
struct
i2c_bus
*
bus
,
uint8_t
i2c_addr
,
int
offset_bytes
)
{
dev
->
bus
=
bus
;
...
...
dev/storage.c
View file @
be5c7d72
...
...
@@ -67,11 +67,6 @@ struct storage_w1_priv
struct
w1_bus
*
dev
;
};
struct
storage_i2c_eeprom_priv
{
struct
i2c_eeprom_device
*
dev
;
};
/* Functions for Flash access */
static
int
sdb_flash_read
(
struct
storage_device
*
dev
,
int
offset
,
void
*
buf
,
int
count
)
...
...
@@ -109,6 +104,7 @@ const int32_t spi_flash_default_entry_points[] =
0x600000
,
/* after SVEC AFPGA bitstream */
-
1
};
const
int32_t
i2c_eeprom_default_entry_points
[]
=
{
0
,
64
,
128
,
256
,
512
,
1024
,
-
1
};
/* Functions for FRAM access */
static
int
sdb_fram_read
(
struct
storage_device
*
dev
,
int
offset
,
void
*
buf
,
int
count
)
{
...
...
@@ -164,22 +160,23 @@ const struct storage_rwops spi_w1_rwops = {
/* The methods for I2C access */
static
int
sdb_i2c_eeprom_read
(
struct
storage_device
*
dev
,
int
offset
,
void
*
buf
,
int
count
)
{
struct
storage_i2c_eeprom_priv
*
priv
=
(
struct
storage_i2c_eeprom_priv
*
)
dev
->
priv
;
return
i2c_eeprom_read
(
priv
->
dev
,
offset
,
buf
,
count
);
struct
i2c_eeprom_device
*
priv
=
(
struct
i2c_eeprom_device
*
)
dev
->
priv
;
return
i2c_eeprom_read
(
priv
,
offset
,
buf
,
count
);
}
static
int
sdb_i2c_eeprom_write
(
struct
storage_device
*
dev
,
int
offset
,
void
*
buf
,
int
count
)
{
struct
storage_i2c_eeprom_priv
*
priv
=
(
struct
storage_i2c_eeprom_priv
*
)
dev
->
priv
;
return
i2c_eeprom_
read
(
priv
->
de
v
,
offset
,
buf
,
count
);
struct
i2c_eeprom_device
*
priv
=
(
struct
i2c_eeprom_device
*
)
dev
->
priv
;
return
i2c_eeprom_
write
(
pri
v
,
offset
,
buf
,
count
);
}
static
int
sdb_i2c_eeprom_erase
(
struct
storage_device
*
dev
,
int
offset
,
int
count
)
{
struct
storage_i2c_eeprom_priv
*
priv
=
(
struct
storage_i2c_eeprom_priv
*
)
dev
->
priv
;
return
i2c_eeprom_erase
(
priv
->
dev
,
offset
,
count
);
struct
i2c_eeprom_device
*
priv
=
(
struct
i2c_eeprom_device
*
)
dev
->
priv
;
return
i2c_eeprom_erase
(
priv
,
offset
,
count
);
}
/* Functions for I2C EEPROM access */
const
struct
storage_rwops
i2c_eeprom_rwops
=
{
sdb_i2c_eeprom_read
,
sdb_i2c_eeprom_write
,
...
...
@@ -200,6 +197,19 @@ void storage_spiflash_create(struct storage_device *dev, struct spi_flash_device
dev
->
flags
=
STORAGE_FLAG_DEVICE_OK
;
}
void
storage_i2ceeprom_create
(
struct
storage_device
*
dev
,
struct
i2c_eeprom_device
*
eeprom
)
{
static
const
char
*
i2c_eeprom_str
=
"eeprom"
;
dev
->
name
=
(
char
*
)
i2c_eeprom_str
;
dev
->
priv
=
eeprom
;
dev
->
rwops
=
(
struct
storage_rwops
*
)
&
i2c_eeprom_rwops
;
dev
->
size
=
8192
;
dev
->
cfg_entry
=
0
;
dev
->
block_size
=
32
;
dev
->
entry_points
=
(
int32_t
*
)
i2c_eeprom_default_entry_points
;
dev
->
flags
=
STORAGE_FLAG_DEVICE_OK
;
}
#if 0
/*
...
...
include/dev/bb_i2c.h
View file @
be5c7d72
...
...
@@ -10,13 +10,13 @@
struct
i2c_bus
{
struct
gpio_pin
*
pin_scl
;
struct
gpio_pin
*
pin_sda
;
const
struct
gpio_pin
*
pin_scl
;
const
struct
gpio_pin
*
pin_sda
;
int
loop_delay
;
};
uint8_t
bb_i2c_devprobe
(
struct
i2c_bus
*
bus
,
uint8_t
i2c_addr
);
void
bb_i2c_create
(
struct
i2c_bus
*
bus
,
struct
gpio_pin
*
pin_scl
,
struct
gpio_pin
*
pin_sda
);
void
bb_i2c_create
(
struct
i2c_bus
*
bus
,
const
struct
gpio_pin
*
pin_scl
,
const
struct
gpio_pin
*
pin_sda
);
void
bb_i2c_init
(
struct
i2c_bus
*
bus
);
void
bb_i2c_start
(
struct
i2c_bus
*
bus
);
void
bb_i2c_repeat_start
(
struct
i2c_bus
*
bus
);
...
...
include/dev/syscon.h
View file @
be5c7d72
...
...
@@ -108,6 +108,8 @@ extern volatile struct SYSCON_WB *syscon;
extern
struct
spi_bus
spi_wrc_flash
;
extern
struct
spi_flash_device
wrc_flash_dev
;
extern
struct
i2c_bus
i2c_wrc_eeprom
;
extern
struct
i2c_eeprom_device
wrc_eeprom_dev
;
static
inline
int
sysc_get_memsize
(
void
)
{
...
...
include/storage.h
View file @
be5c7d72
...
...
@@ -115,6 +115,7 @@ struct storage_device
extern
struct
storage_device
wrc_storage_dev
;
void
storage_spiflash_create
(
struct
storage_device
*
dev
,
struct
spi_flash_device
*
flash
);
void
storage_i2ceeprom_create
(
struct
storage_device
*
dev
,
struct
i2c_eeprom_device
*
eeprom
);
void
storage_init
(
struct
i2c_bus
*
bus
,
int
i2c_addr
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment