Skip to content

Commit 1938fca

Browse files
committed
[opentitanlib] Handle SetPll in Transport::dispatch()
Signed-off-by: Alphan Ulusoy <[email protected]>
1 parent 36bc93e commit 1938fca

File tree

1 file changed

+14
-0
lines changed
  • sw/host/opentitanlib/src/transport/cw310

1 file changed

+14
-0
lines changed

sw/host/opentitanlib/src/transport/cw310/mod.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,17 @@ impl Transport for CW310 {
216216
usb.spi1_enable(false)?;
217217
usb.fpga_program(&fpga_program.bitstream)?;
218218
Ok(None)
219+
} else if let Some(_set_pll) = action.downcast_ref::<SetPll>() {
220+
const TARGET_FREQ: u32 = 100_000_000;
221+
let usb = self.device.borrow();
222+
usb.pll_enable(true)?;
223+
usb.pll_out_freq_set(1, TARGET_FREQ)?;
224+
usb.pll_out_freq_set(2, TARGET_FREQ)?;
225+
usb.pll_out_enable(0, false)?;
226+
usb.pll_out_enable(1, true)?;
227+
usb.pll_out_enable(2, false)?;
228+
usb.pll_write_defaults()?;
229+
Ok(None)
219230
} else {
220231
Err(TransportError::UnsupportedOperation.into())
221232
}
@@ -233,3 +244,6 @@ pub struct FpgaProgram {
233244
/// How long to wait for the ROM to print its type and version.
234245
pub rom_timeout: Duration,
235246
}
247+
248+
/// Command for Transport::dispatch().
249+
pub struct SetPll {}

0 commit comments

Comments
 (0)