drtio: remove remote RTIO PHY resets

This commit is contained in:
Sebastien Bourdeauducq 2018-09-20 11:10:32 +08:00
parent 53a979e74d
commit 1b7f403a4b
4 changed files with 17 additions and 30 deletions

View File

@ -18,7 +18,7 @@ impl<T> From<IoError<T>> for Error<T> {
pub enum Packet { pub enum Packet {
EchoRequest, EchoRequest,
EchoReply, EchoReply,
ResetRequest { phy: bool }, ResetRequest,
ResetAck, ResetAck,
TSCAck, TSCAck,
@ -62,9 +62,7 @@ impl Packet {
Ok(match reader.read_u8()? { Ok(match reader.read_u8()? {
0x00 => Packet::EchoRequest, 0x00 => Packet::EchoRequest,
0x01 => Packet::EchoReply, 0x01 => Packet::EchoReply,
0x02 => Packet::ResetRequest { 0x02 => Packet::ResetRequest,
phy: reader.read_bool()?
},
0x03 => Packet::ResetAck, 0x03 => Packet::ResetAck,
0x04 => Packet::TSCAck, 0x04 => Packet::TSCAck,
@ -192,10 +190,8 @@ impl Packet {
writer.write_u8(0x00)?, writer.write_u8(0x00)?,
Packet::EchoReply => Packet::EchoReply =>
writer.write_u8(0x01)?, writer.write_u8(0x01)?,
Packet::ResetRequest { phy } => { Packet::ResetRequest =>
writer.write_u8(0x02)?; writer.write_u8(0x02)?,
writer.write_bool(phy)?;
},
Packet::ResetAck => Packet::ResetAck =>
writer.write_u8(0x03)?, writer.write_u8(0x03)?,
Packet::TSCAck => Packet::TSCAck =>

View File

@ -334,7 +334,7 @@ pub mod drtio {
let linkno = linkno as u8; let linkno = linkno as u8;
if link_rx_up(linkno) { if link_rx_up(linkno) {
let reply = aux_transact(io, aux_mutex, linkno, let reply = aux_transact(io, aux_mutex, linkno,
&drtioaux::Packet::ResetRequest { phy: false }); &drtioaux::Packet::ResetRequest);
match reply { match reply {
Ok(drtioaux::Packet::ResetAck) => (), Ok(drtioaux::Packet::ResetAck) => (),
Ok(_) => error!("[LINK#{}] reset failed, received unexpected aux packet", linkno), Ok(_) => error!("[LINK#{}] reset failed, received unexpected aux packet", linkno),

View File

@ -75,18 +75,13 @@ fn process_aux_packet(_repeaters: &mut [repeater::Repeater],
match packet { match packet {
drtioaux::Packet::EchoRequest => drtioaux::Packet::EchoRequest =>
drtioaux::send(0, &drtioaux::Packet::EchoReply), drtioaux::send(0, &drtioaux::Packet::EchoReply),
drtioaux::Packet::ResetRequest { phy } => { drtioaux::Packet::ResetRequest => {
info!("resetting RTIO"); info!("resetting RTIO");
if phy {
drtiosat_reset_phy(true);
drtiosat_reset_phy(false);
} else {
drtiosat_reset(true); drtiosat_reset(true);
clock::spin_us(100); clock::spin_us(100);
drtiosat_reset(false); drtiosat_reset(false);
}
for rep in _repeaters.iter() { for rep in _repeaters.iter() {
if let Err(e) = rep.rtio_reset(phy) { if let Err(e) = rep.rtio_reset() {
error!("failed to issue RTIO reset ({})", e); error!("failed to issue RTIO reset ({})", e);
} }
} }

View File

@ -242,21 +242,17 @@ impl Repeater {
Ok(()) Ok(())
} }
pub fn rtio_reset(&self, phy: bool) -> Result<(), drtioaux::Error<!>> { pub fn rtio_reset(&self) -> Result<(), drtioaux::Error<!>> {
let repno = self.repno as usize; let repno = self.repno as usize;
if !phy {
unsafe { (csr::DRTIOREP[repno].reset_write)(1); } unsafe { (csr::DRTIOREP[repno].reset_write)(1); }
clock::spin_us(100); clock::spin_us(100);
unsafe { (csr::DRTIOREP[repno].reset_write)(0); } unsafe { (csr::DRTIOREP[repno].reset_write)(0); }
}
if self.state != RepeaterState::Up { if self.state != RepeaterState::Up {
return Ok(()); return Ok(());
} }
drtioaux::send(self.auxno, &drtioaux::Packet::ResetRequest { drtioaux::send(self.auxno, &drtioaux::Packet::ResetRequest).unwrap();
phy: phy
}).unwrap();
let reply = self.recv_aux_timeout(200)?; let reply = self.recv_aux_timeout(200)?;
if reply != drtioaux::Packet::ResetAck { if reply != drtioaux::Packet::ResetAck {
return Err(drtioaux::Error::UnexpectedReply); return Err(drtioaux::Error::UnexpectedReply);
@ -278,5 +274,5 @@ impl Repeater {
pub fn sync_tsc(&self) -> Result<(), drtioaux::Error<!>> { Ok(()) } pub fn sync_tsc(&self) -> Result<(), drtioaux::Error<!>> { Ok(()) }
pub fn rtio_reset(&self, _phy: bool) -> Result<(), drtioaux::Error<!>> { Ok(()) } pub fn rtio_reset(&self) -> Result<(), drtioaux::Error<!>> { Ok(()) }
} }