Advanced I2C pin definition

RTL has up to 3 SCL pins and up to 4 SDA pins. Lets allow configuring
I2C with individual BUS numbers instead of 0/1 I2C.

This enables support for devices where SCL line is not shared between
SFP modules. MUX registry is now initialized depending on needed
pin function.

More over, some SFP pins require special MUX settings, lets initialize
those depending on SFP configuration. This adds TX Disable pin,
which right now is set to low at startup.

Caveats:
 - We may still override MUX registry later
 - Not sure how to handle invalid bus definitions
 - Without SFP is it fine to *not* initialize anything?
 - Do to RAM limitation we do inititalize output GPIO to low
This commit is contained in:
diijkstra
2026-02-01 12:58:16 +01:00
parent 2c200417b5
commit 7d62b24a42
7 changed files with 129 additions and 35 deletions
+16 -8
View File
@@ -12,12 +12,14 @@ __code const struct machine machine = {
.is_sfp = {0, 0, 0, 2, 0, 0, 0, 0, 1},
.sfp_port[0].pin_detect = 50,
.sfp_port[0].pin_los = 10,
.sfp_port[0].pin_tx_disable = 0xFF,
.sfp_port[0].sds = 1,
.sfp_port[0].i2c = 1,
.sfp_port[0].i2c_bus = { .sda = 3, .scl = 3 },
.sfp_port[1].pin_detect = 30,
.sfp_port[1].pin_los = 37,
.sfp_port[1].pin_tx_disable = 0xFF,
.sfp_port[1].sds = 0,
.sfp_port[1].i2c = 0,
.sfp_port[1].i2c_bus = { .sda = 4, .scl = 3 },
.reset_pin = 46,
};
#elif defined MACHINE_KP_9000_6XH_X
@@ -32,8 +34,9 @@ __code const struct machine machine = {
.is_sfp = {0, 0, 0, 0, 0, 0, 0, 0, 1},
.sfp_port[0].pin_detect = 30,
.sfp_port[0].pin_los = 37,
.sfp_port[0].pin_tx_disable = 0xFF,
.sfp_port[0].sds = 1,
.sfp_port[0].i2c = 0,
.sfp_port[0].i2c_bus = { .sda = 4, .scl = 3 },
};
#elif defined MACHINE_KP_9000_9XH_X_EU
__code const struct machine machine = {
@@ -47,9 +50,11 @@ __code const struct machine machine = {
.is_sfp = {0, 0, 0, 0, 0, 0, 0, 0, 1},
.sfp_port[0].pin_detect = 30,
.sfp_port[0].pin_los = 37,
.sfp_port[0].pin_tx_disable = 0xFF,
.sfp_port[0].sds = 1,
.sfp_port[0].i2c = 0,
.sfp_port[0].i2c_bus = { .sda = 4, .scl = 3 },
};
#elif defined MACHINE_SWGT024_V2_0
__code const struct machine machine = {
.machine_name = "SWGT024 V2.0",
@@ -63,15 +68,18 @@ __code const struct machine machine = {
// Left SFP port (J4)
.sfp_port[0].pin_detect = 30,
.sfp_port[0].pin_los = 37,
.sfp_port[0].pin_tx_disable = 0xFF,
.sfp_port[0].sds = 1,
.sfp_port[0].i2c = 0, /* GPIO 39 */
.sfp_port[0].i2c_bus = { .sda = 4, .scl = 3 }, /* GPIO 39 */
// Right SFP port (J2)
.sfp_port[1].pin_detect = 50,
.sfp_port[1].pin_los = 51,
.sfp_port[1].pin_tx_disable = 0xFF,
.sfp_port[1].sds = 0,
.sfp_port[1].i2c = 1, /* GPIO 40 */
.sfp_port[1].i2c_bus = { .sda = 3, .scl = 3 }, /* GPIO 40 */
.reset_pin = 36,
};
#elif defined DEFAULT_8C_1SFP
__code const struct machine machine = {
.machine_name = "8+1 SFP Port Switch",
@@ -84,8 +92,8 @@ __code const struct machine machine = {
.is_sfp = {0, 0, 0, 0, 0, 0, 0, 0, 1},
.sfp_port[0].pin_detect = 30,
.sfp_port[0].pin_los = 37,
.sfp_port[0].pin_tx_disable = 0xFF,
.sfp_port[0].sds = 1,
.sfp_port[0].i2c = 0,
.sfp_port[0].i2c_bus = { .sda = 4, .scl = 3 },
};
#endif