Lines Matching +full:mbox +full:- +full:name
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2017-2018 HiSilicon Limited.
3 // Copyright (c) 2017-2018 Linaro Limited.
25 #define MBOX_BASE(mbox, ch) ((mbox)->base + ((ch) * 0x40)) argument
48 * struct hi3660_chan_info - Hi3660 mailbox channel information
62 * struct hi3660_mbox - Hi3660 mailbox controller data
80 static struct hi3660_mbox *to_hi3660_mbox(struct mbox_controller *mbox) in to_hi3660_mbox() argument
82 return container_of(mbox, struct hi3660_mbox, controller); in to_hi3660_mbox()
87 unsigned long ch = (unsigned long)chan->con_priv; in hi3660_mbox_check_state()
88 struct hi3660_mbox *mbox = to_hi3660_mbox(chan->mbox); in hi3660_mbox_check_state() local
89 struct hi3660_chan_info *mchan = &mbox->mchan[ch]; in hi3660_mbox_check_state()
90 void __iomem *base = MBOX_BASE(mbox, ch); in hi3660_mbox_check_state()
102 dev_err(mbox->dev, "%s: timeout for receiving ack\n", __func__); in hi3660_mbox_check_state()
107 writel(BIT(mchan->ack_irq), base + MBOX_ICLR_REG); in hi3660_mbox_check_state()
114 struct hi3660_mbox *mbox = to_hi3660_mbox(chan->mbox); in hi3660_mbox_unlock() local
118 writel(MBOX_IPC_UNLOCK, mbox->base + MBOX_IPC_LOCK_REG); in hi3660_mbox_unlock()
120 val = readl(mbox->base + MBOX_IPC_LOCK_REG); in hi3660_mbox_unlock()
125 } while (retry--); in hi3660_mbox_unlock()
128 dev_err(mbox->dev, "%s: failed to unlock mailbox\n", __func__); in hi3660_mbox_unlock()
130 return (!val) ? 0 : -ETIMEDOUT; in hi3660_mbox_unlock()
135 unsigned long ch = (unsigned long)chan->con_priv; in hi3660_mbox_acquire_channel()
136 struct hi3660_mbox *mbox = to_hi3660_mbox(chan->mbox); in hi3660_mbox_acquire_channel() local
137 struct hi3660_chan_info *mchan = &mbox->mchan[ch]; in hi3660_mbox_acquire_channel()
138 void __iomem *base = MBOX_BASE(mbox, ch); in hi3660_mbox_acquire_channel()
141 for (retry = 10; retry; retry--) { in hi3660_mbox_acquire_channel()
144 writel(BIT(mchan->ack_irq), base + MBOX_SRC_REG); in hi3660_mbox_acquire_channel()
148 if (val & BIT(mchan->ack_irq)) in hi3660_mbox_acquire_channel()
154 dev_err(mbox->dev, "%s: failed to acquire channel\n", __func__); in hi3660_mbox_acquire_channel()
156 return retry ? 0 : -ETIMEDOUT; in hi3660_mbox_acquire_channel()
176 unsigned long ch = (unsigned long)chan->con_priv; in hi3660_mbox_send_data()
177 struct hi3660_mbox *mbox = to_hi3660_mbox(chan->mbox); in hi3660_mbox_send_data() local
178 struct hi3660_chan_info *mchan = &mbox->mchan[ch]; in hi3660_mbox_send_data()
179 void __iomem *base = MBOX_BASE(mbox, ch); in hi3660_mbox_send_data()
189 writel_relaxed(~BIT(mchan->dst_irq), base + MBOX_IMASK_REG); in hi3660_mbox_send_data()
192 writel_relaxed(BIT(mchan->dst_irq), base + MBOX_DST_REG); in hi3660_mbox_send_data()
202 writel(BIT(mchan->ack_irq), base + MBOX_SEND_REG); in hi3660_mbox_send_data()
214 struct hi3660_mbox *mbox = to_hi3660_mbox(controller); in hi3660_mbox_xlate() local
216 unsigned int ch = spec->args[0]; in hi3660_mbox_xlate()
219 dev_err(mbox->dev, "Invalid channel idx %d\n", ch); in hi3660_mbox_xlate()
220 return ERR_PTR(-EINVAL); in hi3660_mbox_xlate()
223 mchan = &mbox->mchan[ch]; in hi3660_mbox_xlate()
224 mchan->dst_irq = spec->args[1]; in hi3660_mbox_xlate()
225 mchan->ack_irq = spec->args[2]; in hi3660_mbox_xlate()
227 return &mbox->chan[ch]; in hi3660_mbox_xlate()
231 { .compatible = "hisilicon,hi3660-mbox", },
239 struct device *dev = &pdev->dev; in hi3660_mbox_probe()
240 struct hi3660_mbox *mbox; in hi3660_mbox_probe() local
245 mbox = devm_kzalloc(dev, sizeof(*mbox), GFP_KERNEL); in hi3660_mbox_probe()
246 if (!mbox) in hi3660_mbox_probe()
247 return -ENOMEM; in hi3660_mbox_probe()
249 mbox->base = devm_platform_ioremap_resource(pdev, 0); in hi3660_mbox_probe()
250 if (IS_ERR(mbox->base)) in hi3660_mbox_probe()
251 return PTR_ERR(mbox->base); in hi3660_mbox_probe()
253 mbox->dev = dev; in hi3660_mbox_probe()
254 mbox->controller.dev = dev; in hi3660_mbox_probe()
255 mbox->controller.chans = mbox->chan; in hi3660_mbox_probe()
256 mbox->controller.num_chans = MBOX_CHAN_MAX; in hi3660_mbox_probe()
257 mbox->controller.ops = &hi3660_mbox_ops; in hi3660_mbox_probe()
258 mbox->controller.of_xlate = hi3660_mbox_xlate; in hi3660_mbox_probe()
261 chan = mbox->chan; in hi3660_mbox_probe()
265 err = devm_mbox_controller_register(dev, &mbox->controller); in hi3660_mbox_probe()
271 platform_set_drvdata(pdev, mbox); in hi3660_mbox_probe()
279 .name = "hi3660-mbox",