Skip to content

Commit 19e2d35

Browse files
westeriandy-shev
authored andcommitted
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: Mika Westerberg <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Signed-off-by: Andy Shevchenko <[email protected]>
1 parent e48b72a commit 19e2d35

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

drivers/platform/x86/intel_scu_ipc.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,14 @@ static struct intel_scu_ipc_dev ipcdev; /* Only one for now */
9797

9898
#define IPC_STATUS 0x04
9999
#define IPC_STATUS_IRQ BIT(2)
100+
#define IPC_STATUS_ERR BIT(1)
101+
#define IPC_STATUS_BUSY BIT(0)
100102

101103
/*
102-
* IPC Read Buffer (Read Only):
103-
* 16 byte buffer for receiving data from SCU, if IPC command
104-
* processing results in response data
104+
* IPC Write/Read Buffers:
105+
* 16 byte buffer for sending and receiving data to and from SCU.
105106
*/
107+
#define IPC_WRITE_BUFFER 0x80
106108
#define IPC_READ_BUFFER 0x90
107109

108110
#define IPC_I2C_CNTRL_ADDR 0
@@ -131,7 +133,7 @@ static inline void ipc_command(struct intel_scu_ipc_dev *scu, u32 cmd)
131133
*/
132134
static inline void ipc_data_writel(struct intel_scu_ipc_dev *scu, u32 data, u32 offset)
133135
{
134-
writel(data, scu->ipc_base + 0x80 + offset);
136+
writel(data, scu->ipc_base + IPC_WRITE_BUFFER + offset);
135137
}
136138

137139
/*
@@ -143,7 +145,7 @@ static inline void ipc_data_writel(struct intel_scu_ipc_dev *scu, u32 data, u32
143145
*/
144146
static inline u8 ipc_read_status(struct intel_scu_ipc_dev *scu)
145147
{
146-
return __raw_readl(scu->ipc_base + 0x04);
148+
return __raw_readl(scu->ipc_base + IPC_STATUS);
147149
}
148150

149151
/* Read ipc byte data */
@@ -165,17 +167,17 @@ static inline int busy_loop(struct intel_scu_ipc_dev *scu)
165167
u32 loop_count = 100000;
166168

167169
/* break if scu doesn't reset busy bit after huge retry */
168-
while ((status & BIT(0)) && --loop_count) {
170+
while ((status & IPC_STATUS_BUSY) && --loop_count) {
169171
udelay(1); /* scu processing time is in few u secods */
170172
status = ipc_read_status(scu);
171173
}
172174

173-
if (status & BIT(0)) {
175+
if (status & IPC_STATUS_BUSY) {
174176
dev_err(scu->dev, "IPC timed out");
175177
return -ETIMEDOUT;
176178
}
177179

178-
if (status & BIT(1))
180+
if (status & IPC_STATUS_ERR)
179181
return -EIO;
180182

181183
return 0;
@@ -192,7 +194,7 @@ static inline int ipc_wait_for_interrupt(struct intel_scu_ipc_dev *scu)
192194
}
193195

194196
status = ipc_read_status(scu);
195-
if (status & BIT(1))
197+
if (status & IPC_STATUS_ERR)
196198
return -EIO;
197199

198200
return 0;

0 commit comments

Comments
 (0)