Skip to content

Commit 24042d0

Browse files
authored
Automatically switch KSZ VLAN mode based on features (#749)
1 parent fc837d1 commit 24042d0

File tree

5 files changed

+23
-3
lines changed

5 files changed

+23
-3
lines changed

task/net/src/bsp/gimlet_1.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,11 @@ impl Bsp {
9292
// SP_TO_MGMT_MUX_RESET_L
9393
ksz8463_nrst: Port::C.pin(2),
9494
ksz8463_rst_type: mgmt::Ksz8463ResetSpeed::Normal,
95+
96+
#[cfg(feature = "vlan")]
9597
ksz8463_vlan_mode: ksz8463::VLanMode::Mandatory,
98+
#[cfg(not(feature = "vlan"))]
99+
ksz8463_vlan_mode: ksz8463::VLanMode::Optional,
96100

97101
// SP_TO_MGMT_PHY_COMA_MODE
98102
vsc85x2_coma_mode: Some(Port::D.pin(7)),

task/net/src/bsp/gimletlet_mgmt.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ impl Bsp {
133133
ksz8463_spi: Spi::from(SPI.get_task_id()).device(0),
134134
ksz8463_nrst: Port::A.pin(9),
135135
ksz8463_rst_type: mgmt::Ksz8463ResetSpeed::Slow,
136+
137+
#[cfg(feature = "vlan")]
138+
ksz8463_vlan_mode: ksz8463::VLanMode::Mandatory,
139+
#[cfg(not(feature = "vlan"))]
136140
ksz8463_vlan_mode: ksz8463::VLanMode::Optional,
137141

138142
vsc85x2_coma_mode: None,

task/net/src/bsp/gimletlet_nic.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,13 @@ impl Bsp {
6565
// Initialize the KSZ8463 (using SPI4_RESET, PB10)
6666
sys.gpio_init_reset_pulse(Port::B.pin(10), 10, 1).unwrap();
6767
let ksz8463 = Ksz8463::new(ksz8463_spi);
68-
match ksz8463
69-
.configure(ksz8463::Mode::Copper, ksz8463::VLanMode::Mandatory)
70-
{
68+
69+
#[cfg(feature = "vlan")]
70+
let vlan_mode = ksz8463::VLanMode::Mandatory;
71+
#[cfg(not(feature = "vlan"))]
72+
let vlan_mode = ksz8463::VLanMode::Optional;
73+
74+
match ksz8463.configure(ksz8463::Mode::Copper, vlan_mode) {
7175
Err(err) => {
7276
ringbuf_entry!(Trace::KszErr { err });
7377
sleep_for(100);

task/net/src/bsp/psc_1.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@ impl Bsp {
6262
ksz8463_spi: Spi::from(SPI.get_task_id()).device(0),
6363
ksz8463_nrst: Port::C.pin(2),
6464
ksz8463_rst_type: mgmt::Ksz8463ResetSpeed::Normal,
65+
66+
#[cfg(feature = "vlan")]
6567
ksz8463_vlan_mode: ksz8463::VLanMode::Mandatory,
68+
#[cfg(not(feature = "vlan"))]
69+
ksz8463_vlan_mode: ksz8463::VLanMode::Optional,
6670

6771
// SP_TO_MGMT_PHY_COMA_MODE
6872
vsc85x2_coma_mode: Some(Port::D.pin(7)),

task/net/src/bsp/sidecar_1.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ impl Bsp {
6868
// SP_TO_EPE_RESET_L
6969
ksz8463_nrst: Port::A.pin(0),
7070
ksz8463_rst_type: mgmt::Ksz8463ResetSpeed::Normal,
71+
72+
#[cfg(feature = "vlan")]
7173
ksz8463_vlan_mode: ksz8463::VLanMode::Mandatory,
74+
#[cfg(not(feature = "vlan"))]
75+
ksz8463_vlan_mode: ksz8463::VLanMode::Optional,
7276

7377
// SP_TO_PHY2_COMA_MODE_3V3
7478
vsc85x2_coma_mode: Some(Port::I.pin(15)),

0 commit comments

Comments
 (0)