kasli: support EEPROM on v2

This commit is contained in:
Sebastien Bourdeauducq 2020-04-23 23:00:36 +08:00
parent 77e6fdb7a7
commit 9bc43b2dbf
2 changed files with 14 additions and 2 deletions

View File

@ -13,7 +13,7 @@ pub struct EEPROM {
} }
impl EEPROM { impl EEPROM {
pub fn kasli_eeprom() -> Self { pub fn kasli1_eeprom() -> Self {
EEPROM { EEPROM {
busno: 0, busno: 0,
/// Same port as Si5324 /// Same port as Si5324
@ -22,6 +22,15 @@ impl EEPROM {
} }
} }
pub fn kasli2_eeprom() -> Self {
EEPROM {
busno: 0,
/// SHARED I2C bus
port: 11,
address: 0xae,
}
}
fn select(&self) -> Result<(), &'static str> { fn select(&self) -> Result<(), &'static str> {
let mask: u16 = 1 << self.port; let mask: u16 = 1 << self.port;
i2c::pca9548_select(self.busno, I2C_SWITCH0, mask as u8)?; i2c::pca9548_select(self.busno, I2C_SWITCH0, mask as u8)?;

View File

@ -33,7 +33,10 @@ pub fn get_adresses() -> NetAddresses {
_ => { _ => {
#[cfg(soc_platform = "kasli")] #[cfg(soc_platform = "kasli")]
{ {
let eeprom = i2c_eeprom::EEPROM::kasli_eeprom(); #[cfg(any(hw_rev = "v1.0", hw_rev = "v1.1"))]
let eeprom = i2c_eeprom::EEPROM::kasli1_eeprom();
#[cfg(hw_rev = "v2.0")]
let eeprom = i2c_eeprom::EEPROM::kasli2_eeprom();
hardware_addr = hardware_addr =
eeprom.read_eui48() eeprom.read_eui48()
.map(|addr_buf| EthernetAddress(addr_buf)) .map(|addr_buf| EthernetAddress(addr_buf))