forked from M-Labs/artiq-zynq
Revert "kasli_soc: add SFP0..3 LED indication"
This reverts commit 5111778363
.
This commit is contained in:
parent
c5e21a573c
commit
ca17cd419e
|
@ -86,8 +86,6 @@ class GenericStandalone(SoCCore):
|
||||||
self.acpki = acpki
|
self.acpki = acpki
|
||||||
self.rustc_cfg = dict()
|
self.rustc_cfg = dict()
|
||||||
|
|
||||||
self.rustc_cfg["hw_rev"] = description["hw_rev"]
|
|
||||||
|
|
||||||
platform = kasli_soc.Platform()
|
platform = kasli_soc.Platform()
|
||||||
platform.toolchain.bitstream_commands.extend([
|
platform.toolchain.bitstream_commands.extend([
|
||||||
"set_property BITSTREAM.GENERAL.COMPRESS True [current_design]",
|
"set_property BITSTREAM.GENERAL.COMPRESS True [current_design]",
|
||||||
|
@ -180,8 +178,6 @@ class GenericMaster(SoCCore):
|
||||||
self.acpki = acpki
|
self.acpki = acpki
|
||||||
self.rustc_cfg = dict()
|
self.rustc_cfg = dict()
|
||||||
|
|
||||||
self.rustc_cfg["hw_rev"] = description["hw_rev"]
|
|
||||||
|
|
||||||
platform = kasli_soc.Platform()
|
platform = kasli_soc.Platform()
|
||||||
platform.toolchain.bitstream_commands.extend([
|
platform.toolchain.bitstream_commands.extend([
|
||||||
"set_property BITSTREAM.GENERAL.COMPRESS True [current_design]",
|
"set_property BITSTREAM.GENERAL.COMPRESS True [current_design]",
|
||||||
|
@ -316,8 +312,6 @@ class GenericSatellite(SoCCore):
|
||||||
self.acpki = acpki
|
self.acpki = acpki
|
||||||
self.rustc_cfg = dict()
|
self.rustc_cfg = dict()
|
||||||
|
|
||||||
self.rustc_cfg["hw_rev"] = description["hw_rev"]
|
|
||||||
|
|
||||||
platform = kasli_soc.Platform()
|
platform = kasli_soc.Platform()
|
||||||
platform.toolchain.bitstream_commands.extend([
|
platform.toolchain.bitstream_commands.extend([
|
||||||
"set_property BITSTREAM.GENERAL.COMPRESS True [current_design]",
|
"set_property BITSTREAM.GENERAL.COMPRESS True [current_design]",
|
||||||
|
|
|
@ -10,27 +10,6 @@ struct Registers {
|
||||||
gpiob: u8, // Output Port 1
|
gpiob: u8, // Output Port 1
|
||||||
}
|
}
|
||||||
|
|
||||||
//IO expanders pins
|
|
||||||
const IO_DIR_INPUT_ALL: u8 = 0xFF;
|
|
||||||
const IO_DIR_OUT_SFP_TX_DISABLE: u8 = !0x02;
|
|
||||||
const IO_DIR_OUT_SFP_LED: u8 = !0x40;
|
|
||||||
//SFP0 LED has different place in v1.1
|
|
||||||
#[cfg(hw_rev = "v1.0")]
|
|
||||||
const IO_DIR_OUT_SFP0_LED: u8 = !0x40;
|
|
||||||
#[cfg(hw_rev = "v1.1")]
|
|
||||||
const IO_DIR_OUT_SFP0_LED: u8 = !0x80;
|
|
||||||
|
|
||||||
//IO expander port direction
|
|
||||||
const IO_DIR_MAPPING0: [u8; 2] = [
|
|
||||||
IO_DIR_INPUT_ALL & IO_DIR_OUT_SFP_TX_DISABLE & (IO_DIR_OUT_SFP0_LED),
|
|
||||||
IO_DIR_INPUT_ALL & IO_DIR_OUT_SFP_TX_DISABLE & IO_DIR_OUT_SFP_LED,
|
|
||||||
];
|
|
||||||
|
|
||||||
const IO_DIR_MAPPING1: [u8; 2] = [
|
|
||||||
IO_DIR_INPUT_ALL & IO_DIR_OUT_SFP_TX_DISABLE & IO_DIR_OUT_SFP_LED,
|
|
||||||
IO_DIR_INPUT_ALL & IO_DIR_OUT_SFP_TX_DISABLE & IO_DIR_OUT_SFP_LED,
|
|
||||||
];
|
|
||||||
|
|
||||||
pub struct IoExpander<'a> {
|
pub struct IoExpander<'a> {
|
||||||
i2c: &'a mut i2c::I2c,
|
i2c: &'a mut i2c::I2c,
|
||||||
address: u8,
|
address: u8,
|
||||||
|
@ -38,25 +17,16 @@ pub struct IoExpander<'a> {
|
||||||
out_current: [u8; 2],
|
out_current: [u8; 2],
|
||||||
out_target: [u8; 2],
|
out_target: [u8; 2],
|
||||||
registers: Registers,
|
registers: Registers,
|
||||||
virtual_led_mapping: &'static [(u8, u8, u8)],
|
|
||||||
channel: usize,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> IoExpander<'a> {
|
impl<'a> IoExpander<'a> {
|
||||||
pub fn new(i2c: &'a mut i2c::I2c, index: u8) -> Result<Self, &'static str> {
|
pub fn new(i2c: &'a mut i2c::I2c, index: u8) -> Result<Self, &'static str> {
|
||||||
#[cfg(hw_rev = "v1.0")]
|
|
||||||
const VIRTUAL_LED_MAPPING0: [(u8, u8, u8); 2] = [(0, 0, 6), (1, 1, 6)];
|
|
||||||
#[cfg(hw_rev = "v1.1")]
|
|
||||||
const VIRTUAL_LED_MAPPING0: [(u8, u8, u8); 2] = [(0, 0, 7), (1, 1, 6)];
|
|
||||||
|
|
||||||
const VIRTUAL_LED_MAPPING1: [(u8, u8, u8); 2] = [(2, 0, 6), (3, 1, 6)];
|
|
||||||
|
|
||||||
// Both expanders on SHARED I2C bus
|
// Both expanders on SHARED I2C bus
|
||||||
let mut io_expander = match index {
|
let mut io_expander = match index {
|
||||||
0 => IoExpander {
|
0 => IoExpander {
|
||||||
i2c,
|
i2c,
|
||||||
address: 0x40,
|
address: 0x40,
|
||||||
iodir: IO_DIR_MAPPING0,
|
iodir: [0xff; 2],
|
||||||
out_current: [0; 2],
|
out_current: [0; 2],
|
||||||
out_target: [0; 2],
|
out_target: [0; 2],
|
||||||
registers: Registers {
|
registers: Registers {
|
||||||
|
@ -65,13 +35,11 @@ impl<'a> IoExpander<'a> {
|
||||||
gpioa: 0x12,
|
gpioa: 0x12,
|
||||||
gpiob: 0x13,
|
gpiob: 0x13,
|
||||||
},
|
},
|
||||||
virtual_led_mapping: &VIRTUAL_LED_MAPPING0,
|
|
||||||
channel: 0,
|
|
||||||
},
|
},
|
||||||
1 => IoExpander {
|
1 => IoExpander {
|
||||||
i2c,
|
i2c,
|
||||||
address: 0x42,
|
address: 0x42,
|
||||||
iodir: IO_DIR_MAPPING1,
|
iodir: [0xff; 2],
|
||||||
out_current: [0; 2],
|
out_current: [0; 2],
|
||||||
out_target: [0; 2],
|
out_target: [0; 2],
|
||||||
registers: Registers {
|
registers: Registers {
|
||||||
|
@ -80,8 +48,6 @@ impl<'a> IoExpander<'a> {
|
||||||
gpioa: 0x12,
|
gpioa: 0x12,
|
||||||
gpiob: 0x13,
|
gpiob: 0x13,
|
||||||
},
|
},
|
||||||
virtual_led_mapping: &VIRTUAL_LED_MAPPING1,
|
|
||||||
channel: 1,
|
|
||||||
},
|
},
|
||||||
_ => return Err("incorrect I/O expander index"),
|
_ => return Err("incorrect I/O expander index"),
|
||||||
};
|
};
|
||||||
|
@ -133,13 +99,6 @@ impl<'a> IoExpander<'a> {
|
||||||
|
|
||||||
pub fn init(&mut self) -> Result<(), &'static str> {
|
pub fn init(&mut self) -> Result<(), &'static str> {
|
||||||
self.select()?;
|
self.select()?;
|
||||||
|
|
||||||
self.iodir = match self.channel {
|
|
||||||
0 => IO_DIR_MAPPING0,
|
|
||||||
1 => IO_DIR_MAPPING1,
|
|
||||||
_ => [IO_DIR_INPUT_ALL; 2],
|
|
||||||
};
|
|
||||||
|
|
||||||
self.update_iodir()?;
|
self.update_iodir()?;
|
||||||
|
|
||||||
self.out_current[0] = 0x00;
|
self.out_current[0] = 0x00;
|
||||||
|
@ -163,14 +122,6 @@ impl<'a> IoExpander<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn led_update(&mut self, led_state: u8) {
|
|
||||||
for (led_num, port, bit) in self.virtual_led_mapping.iter() {
|
|
||||||
let level = (led_state >> led_num) & 1;
|
|
||||||
self.set(*port, *bit, level != 0);
|
|
||||||
}
|
|
||||||
self.service().unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn service(&mut self) -> Result<(), &'static str> {
|
pub fn service(&mut self) -> Result<(), &'static str> {
|
||||||
if self.out_target != self.out_current {
|
if self.out_target != self.out_current {
|
||||||
self.select()?;
|
self.select()?;
|
||||||
|
|
|
@ -102,42 +102,6 @@ async fn report_async_rtio_errors() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(feature = "target_kasli_soc", has_drtio))]
|
|
||||||
static mut SEEN_RTIO_LED: u8 = 0;
|
|
||||||
#[cfg(all(feature = "target_kasli_soc", has_drtio))]
|
|
||||||
static mut READ_RTIO_LED: u8 = 0;
|
|
||||||
|
|
||||||
#[cfg(all(feature = "target_kasli_soc", has_drtio))]
|
|
||||||
fn wait_for_rtio_led_change() -> nb::Result<(), Void> {
|
|
||||||
unsafe {
|
|
||||||
let len: usize = pl::csr::DRTIO.len();
|
|
||||||
READ_RTIO_LED = 0;
|
|
||||||
for linkno in 0..len {
|
|
||||||
//let linkno = linkno as usize;
|
|
||||||
READ_RTIO_LED |= (pl::csr::DRTIO[linkno].rx_up_read)() << linkno;
|
|
||||||
}
|
|
||||||
if READ_RTIO_LED != SEEN_RTIO_LED {
|
|
||||||
Ok(())
|
|
||||||
} else {
|
|
||||||
Err(nb::Error::WouldBlock)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[cfg(all(feature = "target_kasli_soc", has_drtio))]
|
|
||||||
async fn async_rtio_led() {
|
|
||||||
loop {
|
|
||||||
let _ = block_async!(wait_for_rtio_led_change()).await;
|
|
||||||
unsafe {
|
|
||||||
let i2c = (&mut i2c::I2C_BUS).as_mut().unwrap();
|
|
||||||
for expander_i in 0..=1 {
|
|
||||||
let mut io_expander = io_expander::IoExpander::new(i2c, expander_i).unwrap();
|
|
||||||
io_expander.led_update(READ_RTIO_LED);
|
|
||||||
}
|
|
||||||
SEEN_RTIO_LED = READ_RTIO_LED;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static mut LOG_BUFFER: [u8; 1 << 17] = [0; 1 << 17];
|
static mut LOG_BUFFER: [u8; 1 << 17] = [0; 1 << 17];
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
@ -166,6 +130,8 @@ pub fn main_core0() {
|
||||||
let mut io_expander = io_expander::IoExpander::new(i2c, expander_i).unwrap();
|
let mut io_expander = io_expander::IoExpander::new(i2c, expander_i).unwrap();
|
||||||
io_expander.init().expect("I2C I/O expander #0 initialization failed");
|
io_expander.init().expect("I2C I/O expander #0 initialization failed");
|
||||||
// Actively drive TX_DISABLE to false on SFP0..3
|
// Actively drive TX_DISABLE to false on SFP0..3
|
||||||
|
io_expander.set_oe(0, 1 << 1).unwrap();
|
||||||
|
io_expander.set_oe(1, 1 << 1).unwrap();
|
||||||
io_expander.set(0, 1, false);
|
io_expander.set(0, 1, false);
|
||||||
io_expander.set(1, 1, false);
|
io_expander.set(1, 1, false);
|
||||||
io_expander.service().unwrap();
|
io_expander.service().unwrap();
|
||||||
|
@ -184,8 +150,5 @@ pub fn main_core0() {
|
||||||
|
|
||||||
task::spawn(report_async_rtio_errors());
|
task::spawn(report_async_rtio_errors());
|
||||||
|
|
||||||
#[cfg(all(feature = "target_kasli_soc", has_drtio))]
|
|
||||||
task::spawn(async_rtio_led());
|
|
||||||
|
|
||||||
comms::main(timer, cfg);
|
comms::main(timer, cfg);
|
||||||
}
|
}
|
||||||
|
|
|
@ -591,23 +591,6 @@ const SI5324_SETTINGS: si5324::FrequencySettings = si5324::FrequencySettings {
|
||||||
crystal_as_ckin2: true,
|
crystal_as_ckin2: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(all(feature = "target_kasli_soc", has_drtio))]
|
|
||||||
fn sfp_leds_update(i2c: &mut I2c) {
|
|
||||||
let mut virtual_leds;
|
|
||||||
unsafe {
|
|
||||||
virtual_leds = csr::drtiosat::rx_up_read();
|
|
||||||
let len: usize = csr::DRTIOREP.len();
|
|
||||||
for linkno in 0..len {
|
|
||||||
virtual_leds |= (csr::DRTIOREP[linkno].rx_up_read)() << (linkno + 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for expander_i in 0..=1 {
|
|
||||||
let mut io_expander = io_expander::IoExpander::new(i2c, expander_i).unwrap();
|
|
||||||
io_expander.led_update(virtual_leds);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static mut LOG_BUFFER: [u8; 1 << 17] = [0; 1 << 17];
|
static mut LOG_BUFFER: [u8; 1 << 17] = [0; 1 << 17];
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
@ -634,6 +617,8 @@ pub extern "C" fn main_core0() -> i32 {
|
||||||
let mut io_expander = io_expander::IoExpander::new(&mut i2c, expander_i).unwrap();
|
let mut io_expander = io_expander::IoExpander::new(&mut i2c, expander_i).unwrap();
|
||||||
io_expander.init().expect("I2C I/O expander #0 initialization failed");
|
io_expander.init().expect("I2C I/O expander #0 initialization failed");
|
||||||
// Actively drive TX_DISABLE to false on SFP0..3
|
// Actively drive TX_DISABLE to false on SFP0..3
|
||||||
|
io_expander.set_oe(0, 1 << 1).unwrap();
|
||||||
|
io_expander.set_oe(1, 1 << 1).unwrap();
|
||||||
io_expander.set(0, 1, false);
|
io_expander.set(0, 1, false);
|
||||||
io_expander.set(1, 1, false);
|
io_expander.set(1, 1, false);
|
||||||
io_expander.service().unwrap();
|
io_expander.service().unwrap();
|
||||||
|
@ -679,8 +664,6 @@ pub extern "C" fn main_core0() -> i32 {
|
||||||
for mut rep in repeaters.iter_mut() {
|
for mut rep in repeaters.iter_mut() {
|
||||||
rep.service(&routing_table, rank, &mut timer);
|
rep.service(&routing_table, rank, &mut timer);
|
||||||
}
|
}
|
||||||
#[cfg(all(feature = "target_kasli_soc", has_drtio))]
|
|
||||||
sfp_leds_update(&mut i2c);
|
|
||||||
hardware_tick(&mut hardware_tick_ts, &mut timer);
|
hardware_tick(&mut hardware_tick_ts, &mut timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -717,8 +700,6 @@ pub extern "C" fn main_core0() -> i32 {
|
||||||
for mut rep in repeaters.iter_mut() {
|
for mut rep in repeaters.iter_mut() {
|
||||||
rep.service(&routing_table, rank, &mut timer);
|
rep.service(&routing_table, rank, &mut timer);
|
||||||
}
|
}
|
||||||
#[cfg(all(feature = "target_kasli_soc", has_drtio))]
|
|
||||||
sfp_leds_update(&mut i2c);
|
|
||||||
hardware_tick(&mut hardware_tick_ts, &mut timer);
|
hardware_tick(&mut hardware_tick_ts, &mut timer);
|
||||||
if drtiosat_tsc_loaded() {
|
if drtiosat_tsc_loaded() {
|
||||||
info!("TSC loaded from uplink");
|
info!("TSC loaded from uplink");
|
||||||
|
|
Loading…
Reference in New Issue