Commit f348c351 authored by Icenowy Zheng's avatar Icenowy Zheng
Browse files

marvell: drivers: use anonymous union in I2C driver



The I2C controller found in Marvell A8K SoCs (and some older SoCs) mux
status and baudrate registers into the same address, however, it's a
vendor customization, and the original IP core by Mentor Graphics uses
two different addresses for the two registers.

Use anonymous union in the driver, in order to ease code sharing for
other SoC vendors that use this IP core (Allwinner SoCs that are newly
introduced to mainline ATF use this core).
Signed-off-by: default avatarIcenowy Zheng <icenowy@aosc.io>
parent 42dc3310
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
#define I2C_UNSTUCK_TRIGGER 0x1 #define I2C_UNSTUCK_TRIGGER 0x1
#define I2C_UNSTUCK_ONGOING 0x2 #define I2C_UNSTUCK_ONGOING 0x2
#define I2C_UNSTUCK_ERROR 0x4 #define I2C_UNSTUCK_ERROR 0x4
struct marvell_i2c_regs { struct marvell_i2c_regs {
uint32_t slave_address; uint32_t slave_address;
uint32_t data; uint32_t data;
...@@ -57,7 +58,7 @@ struct marvell_i2c_regs { ...@@ -57,7 +58,7 @@ struct marvell_i2c_regs {
union { union {
uint32_t status; /* when reading */ uint32_t status; /* when reading */
uint32_t baudrate; /* when writing */ uint32_t baudrate; /* when writing */
} u; };
uint32_t xtnd_slave_addr; uint32_t xtnd_slave_addr;
uint32_t reserved[2]; uint32_t reserved[2];
uint32_t soft_reset; uint32_t soft_reset;
...@@ -69,7 +70,7 @@ static struct marvell_i2c_regs *base; ...@@ -69,7 +70,7 @@ static struct marvell_i2c_regs *base;
static int marvell_i2c_lost_arbitration(uint32_t *status) static int marvell_i2c_lost_arbitration(uint32_t *status)
{ {
*status = mmio_read_32((uintptr_t)&base->u.status); *status = mmio_read_32((uintptr_t)&base->status);
if ((*status == I2C_STATUS_LOST_ARB_DATA_ADDR_TRANSFER) || if ((*status == I2C_STATUS_LOST_ARB_DATA_ADDR_TRANSFER) ||
(*status == I2C_STATUS_LOST_ARB_GENERAL_CALL)) (*status == I2C_STATUS_LOST_ARB_GENERAL_CALL))
return -EAGAIN; return -EAGAIN;
...@@ -271,7 +272,7 @@ static unsigned int marvell_i2c_bus_speed_set(unsigned int requested_speed) ...@@ -271,7 +272,7 @@ static unsigned int marvell_i2c_bus_speed_set(unsigned int requested_speed)
VERBOSE("%s: actual_n = %u, actual_m = %u\n", VERBOSE("%s: actual_n = %u, actual_m = %u\n",
__func__, actual_n, actual_m); __func__, actual_n, actual_m);
/* Set the baud rate */ /* Set the baud rate */
mmio_write_32((uintptr_t)&base->u.baudrate, (actual_m << 3) | actual_n); mmio_write_32((uintptr_t)&base->baudrate, (actual_m << 3) | actual_n);
return 0; return 0;
} }
......
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