i2c/sfp: Demagic shift-values

This commit is contained in:
René van Dorst committed 2026-09-20 11:25:35 +02:00
1 parent f65d14f452
commit b5fe9f217f
3 files changed
+6 -4

No files matched your search

+2 -2
View File
@@ -398,8 +398,8 @@ void setup_i2c(void) __banked
reg_read_m(RTL837X_PIN_MUX_1);
for (uint8_t sfp = 0; sfp < machine.n_sfp; sfp++) {
uint8_t i2c = machine.sfp_port[sfp].i2c;
uint8_t scl_bus = (i2c >> 5) & 0x03;
uint8_t sda_bus = (i2c >> 2) & 0x07;
uint8_t scl_bus = (i2c >> RTL837X_REG_I2C_SCL_SHIFT) & 0x03;
uint8_t sda_bus = (i2c >> RTL837X_REG_I2C_SDA_SHIFT) & 0x07;
print_string("Configuring I2C for SFP idx="); print_byte(sfp); print_string(" SCL="); print_byte(scl_bus); print_string(", SDA="); print_byte(sda_bus); write_char('\n');
switch (scl_bus) {
case 3:
+2 -2
View File
@@ -6,8 +6,8 @@
#include "rtl837x_common.h"
#define I2CBUS(sda, scl) \
((uint8_t)((I2C_BUS_FROM_SCL_PIN(scl) << 5) | \
(I2C_BUS_FROM_SDA_PIN(sda) << 2)))
((uint8_t)((I2C_BUS_FROM_SCL_PIN(scl) << RTL837X_REG_I2C_SCL_SHIFT) | \
(I2C_BUS_FROM_SDA_PIN(sda) << RTL837X_REG_I2C_SDA_SHIFT)))
#define I2C_BUS_FROM_SDA_PIN(sda_pin) \
((sda_pin) == GPIO47_I2C_SDA0 ? (uint8_t)0 : \
+2
View File
@@ -126,6 +126,8 @@
#define RTL837X_REG_I2C_CTRL2 0x041c
#define RTL837X_REG_I2C_IN 0x0420
#define RTL837X_REG_I2C_OUT 0x0424
#define RTL837X_REG_I2C_SCL_SHIFT 5
#define RTL837X_REG_I2C_SDA_SHIFT 2
/*
* NIC Related registers