Commit 19e2d350 authored by Mika Westerberg's avatar Mika Westerberg Committed by Andy Shevchenko

platform/x86: intel_scu_ipc: Add constants for register offsets

This makes the code more readable. These are taken from intel_pmc_ipc.c
which implements the same thing.
Signed-off-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
parent e48b72a5
...@@ -97,12 +97,14 @@ static struct intel_scu_ipc_dev ipcdev; /* Only one for now */ ...@@ -97,12 +97,14 @@ static struct intel_scu_ipc_dev ipcdev; /* Only one for now */
#define IPC_STATUS 0x04 #define IPC_STATUS 0x04
#define IPC_STATUS_IRQ BIT(2) #define IPC_STATUS_IRQ BIT(2)
#define IPC_STATUS_ERR BIT(1)
#define IPC_STATUS_BUSY BIT(0)
/* /*
* IPC Read Buffer (Read Only): * IPC Write/Read Buffers:
* 16 byte buffer for receiving data from SCU, if IPC command * 16 byte buffer for sending and receiving data to and from SCU.
* processing results in response data
*/ */
#define IPC_WRITE_BUFFER 0x80
#define IPC_READ_BUFFER 0x90 #define IPC_READ_BUFFER 0x90
#define IPC_I2C_CNTRL_ADDR 0 #define IPC_I2C_CNTRL_ADDR 0
...@@ -131,7 +133,7 @@ static inline void ipc_command(struct intel_scu_ipc_dev *scu, u32 cmd) ...@@ -131,7 +133,7 @@ static inline void ipc_command(struct intel_scu_ipc_dev *scu, u32 cmd)
*/ */
static inline void ipc_data_writel(struct intel_scu_ipc_dev *scu, u32 data, u32 offset) static inline void ipc_data_writel(struct intel_scu_ipc_dev *scu, u32 data, u32 offset)
{ {
writel(data, scu->ipc_base + 0x80 + offset); writel(data, scu->ipc_base + IPC_WRITE_BUFFER + offset);
} }
/* /*
...@@ -143,7 +145,7 @@ static inline void ipc_data_writel(struct intel_scu_ipc_dev *scu, u32 data, u32 ...@@ -143,7 +145,7 @@ static inline void ipc_data_writel(struct intel_scu_ipc_dev *scu, u32 data, u32
*/ */
static inline u8 ipc_read_status(struct intel_scu_ipc_dev *scu) static inline u8 ipc_read_status(struct intel_scu_ipc_dev *scu)
{ {
return __raw_readl(scu->ipc_base + 0x04); return __raw_readl(scu->ipc_base + IPC_STATUS);
} }
/* Read ipc byte data */ /* Read ipc byte data */
...@@ -165,17 +167,17 @@ static inline int busy_loop(struct intel_scu_ipc_dev *scu) ...@@ -165,17 +167,17 @@ static inline int busy_loop(struct intel_scu_ipc_dev *scu)
u32 loop_count = 100000; u32 loop_count = 100000;
/* break if scu doesn't reset busy bit after huge retry */ /* break if scu doesn't reset busy bit after huge retry */
while ((status & BIT(0)) && --loop_count) { while ((status & IPC_STATUS_BUSY) && --loop_count) {
udelay(1); /* scu processing time is in few u secods */ udelay(1); /* scu processing time is in few u secods */
status = ipc_read_status(scu); status = ipc_read_status(scu);
} }
if (status & BIT(0)) { if (status & IPC_STATUS_BUSY) {
dev_err(scu->dev, "IPC timed out"); dev_err(scu->dev, "IPC timed out");
return -ETIMEDOUT; return -ETIMEDOUT;
} }
if (status & BIT(1)) if (status & IPC_STATUS_ERR)
return -EIO; return -EIO;
return 0; return 0;
...@@ -192,7 +194,7 @@ static inline int ipc_wait_for_interrupt(struct intel_scu_ipc_dev *scu) ...@@ -192,7 +194,7 @@ static inline int ipc_wait_for_interrupt(struct intel_scu_ipc_dev *scu)
} }
status = ipc_read_status(scu); status = ipc_read_status(scu);
if (status & BIT(1)) if (status & IPC_STATUS_ERR)
return -EIO; return -EIO;
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