Commit 49abc3d0 authored by Adam Wujek's avatar Adam Wujek

[BUG: #249] userspace/libwr: don't toggle i2c pins before soft reset

After reset of the CPU (ARM) GPIO pins are set as input. During
configuration they were set to 0, which had a meaning to the i2c
transfer if the last transfer before reset was not completed (e.g. by
the switch restart).
Signed-off-by: 's avatarAdam Wujek <dev_public@wujek.eu>
parent 4495ed7d
...@@ -27,20 +27,21 @@ int i2c_bitbang_init_bus(struct i2c_bus *bus) ...@@ -27,20 +27,21 @@ int i2c_bitbang_init_bus(struct i2c_bus *bus)
priv = (struct i2c_bitbang *)bus->type_specific; priv = (struct i2c_bitbang *)bus->type_specific;
pr_debug("init: %s (%p)\n", bus->name, bus); pr_debug("init: %s (%p)\n", bus->name, bus);
shw_pio_configure(priv->scl);
shw_pio_configure(priv->sda);
shw_pio_setdir(priv->scl, 0);
shw_pio_setdir(priv->sda, 0);
priv->udelay = 50; priv->udelay = 50;
priv->timeout = 100; priv->timeout = 100;
//assign functions //assign functions
bus->transfer = i2c_bitbang_transfer; bus->transfer = i2c_bitbang_transfer;
bus->scan = i2c_bitbang_scan; bus->scan = i2c_bitbang_scan;
shw_pio_configure(priv->scl);
shw_pio_configure(priv->sda);
/* Perform a soft reset of a bus */ /* Perform a soft reset of a bus */
i2c_slave_soft_reset(bus, -1); i2c_slave_soft_reset(bus, -1);
shw_pio_setdir(priv->scl, 0);
shw_pio_setdir(priv->sda, 0);
return 0; return 0;
} }
......
...@@ -107,19 +107,23 @@ i2c_fpga_reg_t fpga_bus1_reg = { ...@@ -107,19 +107,23 @@ i2c_fpga_reg_t fpga_bus1_reg = {
.prescaler = 500, .prescaler = 500,
}; };
/* I2C pins are set to input to avoid wrong transfers (which can lead to
* e.g. overwrite of SFP's eeprom) on i2c buses if HAL was killed in
* the middle of a transfer (by e.g. system reset). */
/* The Bit-Banged I2C bus connected to the PCA9548A Multiplexers. WORKS */ /* The Bit-Banged I2C bus connected to the PCA9548A Multiplexers. WORKS */
pio_pin_t wr_mux_scl = { pio_pin_t wr_mux_scl = {
.port = PIOB, .port = PIOB,
.pin = 25, .pin = 25,
.mode = PIO_MODE_GPIO, .mode = PIO_MODE_GPIO,
.dir = PIO_OUT_0, .dir = PIO_IN, /* Set as input to avoid toggle after reset */
}; };
pio_pin_t wr_mux_sda = { pio_pin_t wr_mux_sda = {
.port = PIOB, .port = PIOB,
.pin = 27, .pin = 27,
.mode = PIO_MODE_GPIO, .mode = PIO_MODE_GPIO,
.dir = PIO_OUT_0, .dir = PIO_IN, /* Set as input to avoid toggle after reset */
}; };
struct i2c_bitbang wr_mux_bus_reg = { struct i2c_bitbang wr_mux_bus_reg = {
...@@ -132,14 +136,14 @@ pio_pin_t wr_link0_sda = { ...@@ -132,14 +136,14 @@ pio_pin_t wr_link0_sda = {
.port = PIOB, .port = PIOB,
.pin = 23, .pin = 23,
.mode = PIO_MODE_GPIO, .mode = PIO_MODE_GPIO,
.dir = PIO_OUT_0, .dir = PIO_IN, /* Set as input to avoid toggle after reset */
}; };
pio_pin_t wr_link0_scl = { pio_pin_t wr_link0_scl = {
.port = PIOB, .port = PIOB,
.pin = 26, .pin = 26,
.mode = PIO_MODE_GPIO, .mode = PIO_MODE_GPIO,
.dir = PIO_OUT_0, .dir = PIO_IN, /* Set as input to avoid toggle after reset */
}; };
struct i2c_bitbang wr_link0_reg = { struct i2c_bitbang wr_link0_reg = {
...@@ -152,14 +156,14 @@ pio_pin_t wr_link1_sda = { ...@@ -152,14 +156,14 @@ pio_pin_t wr_link1_sda = {
.port = PIOB, .port = PIOB,
.pin = 22, .pin = 22,
.mode = PIO_MODE_GPIO, .mode = PIO_MODE_GPIO,
.dir = PIO_OUT_0, .dir = PIO_IN, /* Set as input to avoid toggle after reset */
}; };
pio_pin_t wr_link1_scl = { pio_pin_t wr_link1_scl = {
.port = PIOB, .port = PIOB,
.pin = 21, .pin = 21,
.mode = PIO_MODE_GPIO, .mode = PIO_MODE_GPIO,
.dir = PIO_OUT_0, .dir = PIO_IN, /* Set as input to avoid toggle after reset */
}; };
struct i2c_bitbang wr_link1_reg = { struct i2c_bitbang wr_link1_reg = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment