mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
commit
e5971e38ea
2 changed files with 21 additions and 11 deletions
|
|
@ -32,8 +32,9 @@ pub const BAOCHIP_1X_UF2_FAMILY: u32 = 0xa7d7_6373;
|
|||
// density 18, memory type 20, mfg ID C2 ==> MX25L128833F
|
||||
// density 38, memory type 25, mfg ID C2 ==> MX25U12832F
|
||||
// mfg ID 0b ==> XT25Q64FWOIGT cost down option (8MiB)
|
||||
// mfg ID ba ==> ZD25Q64B super-cost down option (8MiB)
|
||||
pub const SPI_FLASH_IDS: [u32; 4] = [0x1820c2, 0x3825c2, 0x17600b, 0x1732ba];
|
||||
// mfg ID ba ==> ZD25Q64B super-cost down option (8MiB / 3.3V)
|
||||
// mfg ID 85 ==> PY25Q64HA (8MiB / 3.3V)
|
||||
pub const SPI_FLASH_IDS: [u32; 5] = [0x1820c2, 0x3825c2, 0x17600b, 0x1732ba, 0x172085];
|
||||
// KGD 5D, mfg ID 9D; remainder of bits are part of the EID
|
||||
pub const RAM_IDS: [u32; 3] = [0x5D9D, 0x559d, 0x5D0D];
|
||||
|
||||
|
|
|
|||
|
|
@ -96,10 +96,12 @@ pub enum CommandSet {
|
|||
Macronix = 0xc2,
|
||||
Xtx = 0x0b,
|
||||
Zetta = 0xba,
|
||||
Puya = 0x85,
|
||||
}
|
||||
// be sure to update this when updating the command set above! this is used to iterate
|
||||
// through all valid types by other routines.
|
||||
pub const ALL_COMMAND_SETS: [CommandSet; 3] = [CommandSet::Macronix, CommandSet::Xtx, CommandSet::Zetta];
|
||||
pub const ALL_COMMAND_SETS: [CommandSet; 4] =
|
||||
[CommandSet::Macronix, CommandSet::Xtx, CommandSet::Zetta, CommandSet::Puya];
|
||||
impl TryFrom<u8> for CommandSet {
|
||||
type Error = xous::Error;
|
||||
|
||||
|
|
@ -108,6 +110,7 @@ impl TryFrom<u8> for CommandSet {
|
|||
0xc2 => Ok(CommandSet::Macronix),
|
||||
0x0b => Ok(CommandSet::Xtx),
|
||||
0xba => Ok(CommandSet::Zetta),
|
||||
0x85 => Ok(CommandSet::Puya),
|
||||
_ => Err(xous::Error::BadAddress),
|
||||
}
|
||||
}
|
||||
|
|
@ -1089,7 +1092,9 @@ impl Spim {
|
|||
SpimMode::Standard => self.mem_send_cmd(0x9F),
|
||||
SpimMode::Quad => match self.command_set {
|
||||
Some(CommandSet::Macronix) | None => self.mem_send_cmd(0xAF),
|
||||
Some(CommandSet::Xtx) | Some(CommandSet::Zetta) => self.mem_send_cmd(0x9F),
|
||||
Some(CommandSet::Xtx) | Some(CommandSet::Zetta) | Some(CommandSet::Puya) => {
|
||||
self.mem_send_cmd(0x9F)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -1153,8 +1158,8 @@ impl Spim {
|
|||
if activate {
|
||||
match self.command_set {
|
||||
Some(CommandSet::Macronix) | None => self.mem_send_cmd(0x35),
|
||||
Some(CommandSet::Xtx) | Some(CommandSet::Zetta) => {
|
||||
crate::println!("activating Xtx QPI");
|
||||
Some(CommandSet::Xtx) | Some(CommandSet::Zetta) | Some(CommandSet::Puya) => {
|
||||
crate::println!("activating Xtx/Zetta/Puya QPI");
|
||||
self.mem_send_cmd(0x38)
|
||||
}
|
||||
}
|
||||
|
|
@ -1162,7 +1167,9 @@ impl Spim {
|
|||
self.mode = SpimMode::Quad; // pre-assumes quad mode
|
||||
match self.command_set {
|
||||
Some(CommandSet::Macronix) | None => self.mem_send_cmd(0xF5),
|
||||
Some(CommandSet::Xtx) | Some(CommandSet::Zetta) => self.mem_send_cmd(0xFF),
|
||||
Some(CommandSet::Xtx) | Some(CommandSet::Zetta) | Some(CommandSet::Puya) => {
|
||||
self.mem_send_cmd(0xFF)
|
||||
}
|
||||
}
|
||||
}
|
||||
self.mem_cs(false);
|
||||
|
|
@ -1175,7 +1182,7 @@ impl Spim {
|
|||
// cleanup any parameter settings
|
||||
match self.command_set {
|
||||
Some(CommandSet::Macronix) | None => (),
|
||||
Some(CommandSet::Xtx) | Some(CommandSet::Zetta) => {
|
||||
Some(CommandSet::Xtx) | Some(CommandSet::Zetta) | Some(CommandSet::Puya) => {
|
||||
crate::println!("Xtx setting 6 dummy cycles");
|
||||
// set 6 dummy cycles; 8 is default
|
||||
self.mem_param_set(false, 0xc0, &[0b0010_0000]);
|
||||
|
|
@ -1405,7 +1412,7 @@ impl Spim {
|
|||
}
|
||||
self.mem_read_id_flash();
|
||||
let addresses: &[u8] = match self.command_set {
|
||||
Some(CommandSet::Xtx) | Some(CommandSet::Zetta) => &[0x05, 0x35, 0x15],
|
||||
Some(CommandSet::Xtx) | Some(CommandSet::Zetta) | Some(CommandSet::Puya) => &[0x05, 0x35, 0x15],
|
||||
Some(CommandSet::Macronix) | None => &[0x05],
|
||||
};
|
||||
let mut ret = 0u32;
|
||||
|
|
@ -1443,7 +1450,9 @@ impl Spim {
|
|||
let sr = self.flash_read_status_register();
|
||||
let qe_set = match self.command_set {
|
||||
Some(CommandSet::Macronix) => 0b0100_0000 & sr != 0,
|
||||
Some(CommandSet::Xtx) | Some(CommandSet::Zetta) => 0b10_0000_0000 & sr != 0,
|
||||
Some(CommandSet::Xtx) | Some(CommandSet::Zetta) | Some(CommandSet::Puya) => {
|
||||
0b10_0000_0000 & sr != 0
|
||||
}
|
||||
None => {
|
||||
crate::println!("Can't set QE on unknown flash type");
|
||||
return;
|
||||
|
|
@ -1458,7 +1467,7 @@ impl Spim {
|
|||
CommandSet::Macronix => {
|
||||
self.mem_write_status_register(0b0100_0000 | (sr & 0xFF) as u8, ((sr & 0xFF00) >> 8) as u8);
|
||||
}
|
||||
CommandSet::Xtx | CommandSet::Zetta => {
|
||||
CommandSet::Xtx | CommandSet::Zetta | CommandSet::Puya => {
|
||||
self.mem_param_set(true, 0x31, &[((sr & 0xFF00 >> 8) as u8) | 0b0000_0010]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue