.. | .. |
---|
38 | 38 | #define MBOX_AUTOMATIC_ACK 1 |
---|
39 | 39 | |
---|
40 | 40 | #define MBOX_STATE_IDLE BIT(4) |
---|
| 41 | +#define MBOX_STATE_READY BIT(5) |
---|
41 | 42 | #define MBOX_STATE_ACK BIT(7) |
---|
42 | 43 | |
---|
43 | 44 | #define MBOX_MSG_LEN 8 |
---|
.. | .. |
---|
91 | 92 | unsigned long val; |
---|
92 | 93 | unsigned int ret; |
---|
93 | 94 | |
---|
94 | | - /* Mailbox is idle so directly bail out */ |
---|
95 | | - if (readl(base + MBOX_MODE_REG) & MBOX_STATE_IDLE) |
---|
| 95 | + /* Mailbox is ready to use */ |
---|
| 96 | + if (readl(base + MBOX_MODE_REG) & MBOX_STATE_READY) |
---|
96 | 97 | return 0; |
---|
97 | 98 | |
---|
98 | 99 | /* Wait for acknowledge from remote */ |
---|
.. | .. |
---|
103 | 104 | return ret; |
---|
104 | 105 | } |
---|
105 | 106 | |
---|
106 | | - /* Ensure channel is released */ |
---|
107 | | - writel(0xffffffff, base + MBOX_IMASK_REG); |
---|
108 | | - writel(BIT(mchan->ack_irq), base + MBOX_SRC_REG); |
---|
| 107 | + /* clear ack state, mailbox will get back to ready state */ |
---|
| 108 | + writel(BIT(mchan->ack_irq), base + MBOX_ICLR_REG); |
---|
| 109 | + |
---|
109 | 110 | return 0; |
---|
110 | 111 | } |
---|
111 | 112 | |
---|
.. | .. |
---|
160 | 161 | { |
---|
161 | 162 | int ret; |
---|
162 | 163 | |
---|
163 | | - ret = hi3660_mbox_check_state(chan); |
---|
164 | | - if (ret) |
---|
165 | | - return ret; |
---|
166 | | - |
---|
167 | 164 | ret = hi3660_mbox_unlock(chan); |
---|
168 | 165 | if (ret) |
---|
169 | 166 | return ret; |
---|
.. | .. |
---|
183 | 180 | void __iomem *base = MBOX_BASE(mbox, ch); |
---|
184 | 181 | u32 *buf = msg; |
---|
185 | 182 | unsigned int i; |
---|
| 183 | + int ret; |
---|
186 | 184 | |
---|
187 | | - /* Ensure channel is released */ |
---|
188 | | - writel_relaxed(0xffffffff, base + MBOX_IMASK_REG); |
---|
189 | | - writel_relaxed(BIT(mchan->ack_irq), base + MBOX_SRC_REG); |
---|
| 185 | + ret = hi3660_mbox_check_state(chan); |
---|
| 186 | + if (ret) |
---|
| 187 | + return ret; |
---|
190 | 188 | |
---|
191 | 189 | /* Clear mask for destination interrupt */ |
---|
192 | 190 | writel_relaxed(~BIT(mchan->dst_irq), base + MBOX_IMASK_REG); |
---|
.. | .. |
---|
206 | 204 | return 0; |
---|
207 | 205 | } |
---|
208 | 206 | |
---|
209 | | -static struct mbox_chan_ops hi3660_mbox_ops = { |
---|
| 207 | +static const struct mbox_chan_ops hi3660_mbox_ops = { |
---|
210 | 208 | .startup = hi3660_mbox_startup, |
---|
211 | 209 | .send_data = hi3660_mbox_send_data, |
---|
212 | 210 | }; |
---|
.. | .. |
---|
267 | 265 | for (ch = 0; ch < MBOX_CHAN_MAX; ch++) |
---|
268 | 266 | chan[ch].con_priv = (void *)ch; |
---|
269 | 267 | |
---|
270 | | - err = mbox_controller_register(&mbox->controller); |
---|
| 268 | + err = devm_mbox_controller_register(dev, &mbox->controller); |
---|
271 | 269 | if (err) { |
---|
272 | 270 | dev_err(dev, "Failed to register mailbox %d\n", err); |
---|
273 | 271 | return err; |
---|
.. | .. |
---|
278 | 276 | return 0; |
---|
279 | 277 | } |
---|
280 | 278 | |
---|
281 | | -static int hi3660_mbox_remove(struct platform_device *pdev) |
---|
282 | | -{ |
---|
283 | | - struct hi3660_mbox *mbox = platform_get_drvdata(pdev); |
---|
284 | | - |
---|
285 | | - mbox_controller_unregister(&mbox->controller); |
---|
286 | | - return 0; |
---|
287 | | -} |
---|
288 | | - |
---|
289 | 279 | static struct platform_driver hi3660_mbox_driver = { |
---|
290 | 280 | .probe = hi3660_mbox_probe, |
---|
291 | | - .remove = hi3660_mbox_remove, |
---|
292 | 281 | .driver = { |
---|
293 | 282 | .name = "hi3660-mbox", |
---|
294 | 283 | .of_match_table = hi3660_mbox_of_match, |
---|