History

i2c: algo: pca: Reapply i2c bus settings after reset

If something goes wrong (such as the SCL being stuck low) then we need to reset the PCA chip. The issue with this is that on reset we lose all config settings and the chip ends up in a disabled state which results in a lock up/high CPU usage. We need to re-apply any configuration that had previously been set and re-enable the chip.

Evan Nimmo committed 6 years ago

Commit 0a355ae1 parent 0065ec02 files · +38 −12Browse files

Showing the changes to include/linux (1 of 2 files). Show all

Unified · Split

include/linux/i2c-algo-pca.h+15−0
@@ -53,6 +53,20 @@ · 52 unmodified lines
53#define I2C_PCA_CON_SI 0x08 /* Serial Interrupt */53#define I2C_PCA_CON_SI 0x08 /* Serial Interrupt */
54#define I2C_PCA_CON_CR 0x07 /* Clock Rate (MASK) */54#define I2C_PCA_CON_CR 0x07 /* Clock Rate (MASK) */
55 55
56/**
57 * struct pca_i2c_bus_settings - The configured PCA i2c bus settings
58 * @mode: Configured i2c bus mode
59 * @tlow: Configured SCL LOW period
60 * @thi: Configured SCL HIGH period
61 * @clock_freq: The configured clock frequency
62 */
63struct pca_i2c_bus_settings {
64 int mode;
65 int tlow;
66 int thi;
67 int clock_freq;
68};
69
56struct i2c_algo_pca_data {70struct i2c_algo_pca_data {
57 void *data; /* private low level data */71 void *data; /* private low level data */
58 void (*write_byte) (void *data, int reg, int val);72 void (*write_byte) (void *data, int reg, int val);
@@ -64,6 +78,7 @@ struct i2c_algo_pca_data { · 5 unmodified lines
64 * For PCA9665, use the frequency you want here. */78 * For PCA9665, use the frequency you want here. */
65 unsigned int i2c_clock;79 unsigned int i2c_clock;
66 unsigned int chip;80 unsigned int chip;
81 struct pca_i2c_bus_settings bus_settings;
67};82};
68 83
69int i2c_pca_add_bus(struct i2c_adapter *);84int i2c_pca_add_bus(struct i2c_adapter *);