diff options
author | Jan Glauber <jglauber@cavium.com> | 2016-08-24 23:25:46 +0200 |
---|---|---|
committer | Wolfram Sang <wsa@the-dreams.de> | 2016-08-26 00:41:57 +0200 |
commit | 97d970046a15bf5baac849dbeac56310c8ee3966 (patch) | |
tree | 0a61089daf63501a2db807f70ad6f579fd8fd397 /drivers/i2c/busses/i2c-octeon-core.h | |
parent | 1e5866711accf16e931c4f8174cf898b554e9f4a (diff) | |
download | op-kernel-dev-97d970046a15bf5baac849dbeac56310c8ee3966.zip op-kernel-dev-97d970046a15bf5baac849dbeac56310c8ee3966.tar.gz |
i2c: octeon,thunderx: Move register offsets to struct
The register offsets are different between Octeon and ThunderX so move
them into the algorithm struct and get rid of the define.
Signed-off-by: Jan Glauber <jglauber@cavium.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Diffstat (limited to 'drivers/i2c/busses/i2c-octeon-core.h')
-rw-r--r-- | drivers/i2c/busses/i2c-octeon-core.h | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/drivers/i2c/busses/i2c-octeon-core.h b/drivers/i2c/busses/i2c-octeon-core.h index 2ed6f7a..87151ea 100644 --- a/drivers/i2c/busses/i2c-octeon-core.h +++ b/drivers/i2c/busses/i2c-octeon-core.h @@ -8,17 +8,6 @@ #include <linux/kernel.h> #include <linux/pci.h> -/* Register offsets */ -#if IS_ENABLED(CONFIG_I2C_THUNDERX) - #define SW_TWSI 0x1000 - #define TWSI_INT 0x1010 - #define SW_TWSI_EXT 0x1018 -#else - #define SW_TWSI 0x00 - #define TWSI_INT 0x10 - #define SW_TWSI_EXT 0x18 -#endif - /* Controller command patterns */ #define SW_TWSI_V BIT_ULL(63) /* Valid bit */ #define SW_TWSI_EIA BIT_ULL(61) /* Extended internal address */ @@ -98,9 +87,21 @@ #define I2C_OCTEON_EVENT_WAIT 80 /* microseconds */ +/* Register offsets */ +struct octeon_i2c_reg_offset { + unsigned int sw_twsi; + unsigned int twsi_int; + unsigned int sw_twsi_ext; +}; + +#define SW_TWSI(x) (x->roff.sw_twsi) +#define TWSI_INT(x) (x->roff.twsi_int) +#define SW_TWSI_EXT(x) (x->roff.sw_twsi_ext) + struct octeon_i2c { wait_queue_head_t queue; struct i2c_adapter adap; + struct octeon_i2c_reg_offset roff; struct clk *clk; int irq; int hlc_irq; /* For cn7890 only */ @@ -142,9 +143,9 @@ static inline void octeon_i2c_reg_write(struct octeon_i2c *i2c, u64 eop_reg, u8 { u64 tmp; - __raw_writeq(SW_TWSI_V | eop_reg | data, i2c->twsi_base + SW_TWSI); + __raw_writeq(SW_TWSI_V | eop_reg | data, i2c->twsi_base + SW_TWSI(i2c)); do { - tmp = __raw_readq(i2c->twsi_base + SW_TWSI); + tmp = __raw_readq(i2c->twsi_base + SW_TWSI(i2c)); } while ((tmp & SW_TWSI_V) != 0); } @@ -166,9 +167,9 @@ static inline u8 octeon_i2c_reg_read(struct octeon_i2c *i2c, u64 eop_reg) { u64 tmp; - __raw_writeq(SW_TWSI_V | eop_reg | SW_TWSI_R, i2c->twsi_base + SW_TWSI); + __raw_writeq(SW_TWSI_V | eop_reg | SW_TWSI_R, i2c->twsi_base + SW_TWSI(i2c)); do { - tmp = __raw_readq(i2c->twsi_base + SW_TWSI); + tmp = __raw_readq(i2c->twsi_base + SW_TWSI(i2c)); } while ((tmp & SW_TWSI_V) != 0); return tmp & 0xFF; @@ -189,7 +190,7 @@ static inline u8 octeon_i2c_reg_read(struct octeon_i2c *i2c, u64 eop_reg) */ static inline u64 octeon_i2c_read_int(struct octeon_i2c *i2c) { - return __raw_readq(i2c->twsi_base + TWSI_INT); + return __raw_readq(i2c->twsi_base + TWSI_INT(i2c)); } /** @@ -199,7 +200,7 @@ static inline u64 octeon_i2c_read_int(struct octeon_i2c *i2c) */ static inline void octeon_i2c_write_int(struct octeon_i2c *i2c, u64 data) { - octeon_i2c_writeq_flush(data, i2c->twsi_base + TWSI_INT); + octeon_i2c_writeq_flush(data, i2c->twsi_base + TWSI_INT(i2c)); } /* Prototypes */ |