Skip to content

Commit

Permalink
Merge tag 'mailbox-v4.21' of git://git.linaro.org/landing-teams/worki…
Browse files Browse the repository at this point in the history
…ng/fujitsu/integration

Pull mailbox updates from Jassi Brar:

 - Introduce device-managed registration
   devm_mbox_controller_un/register and convert drivers to use it

 - Introduce flush api to support clients that must busy-wait in atomic
   context

 - Support multiple controllers per device

 - Hi3660: a bugfix and constify ops structure

 - TI-MsgMgr: off by one bugfix.

 - BCM: switch to spdx license

 - Tegra-HSP: support for shared mailboxes and suspend/resume.

* tag 'mailbox-v4.21' of git://git.linaro.org/landing-teams/working/fujitsu/integration: (30 commits)
  mailbox: tegra-hsp: Use device-managed registration API
  mailbox: tegra-hsp: use devm_kstrdup_const()
  mailbox: tegra-hsp: Add suspend/resume support
  mailbox: tegra-hsp: Add support for shared mailboxes
  dt-bindings: tegra186-hsp: Add shared mailboxes
  mailbox: Allow multiple controllers per device
  mailbox: Support blocking transfers in atomic context
  mailbox: ti-msgmgr: Use device-managed registration API
  mailbox: stm32-ipcc: Use device-managed registration API
  mailbox: rockchip: Use device-managed registration API
  mailbox: qcom-apcs: Use device-managed registration API
  mailbox: platform-mhu: Use device-managed registration API
  mailbox: omap: Use device-managed registration API
  mailbox: mtk-cmdq: Remove needless devm_kfree() calls
  mailbox: mtk-cmdq: Use device-managed registration API
  mailbox: xgene-slimpro: Use device-managed registration API
  mailbox: sti: Use device-managed registration API
  mailbox: altera: Use device-managed registration API
  mailbox: imx: Use device-managed registration API
  mailbox: hi6220: Use device-managed registration API
  ...
  • Loading branch information
torvalds committed Jan 3, 2019
2 parents 6aa293d + d69e116 commit 35ddb06
Show file tree
Hide file tree
Showing 23 changed files with 612 additions and 247 deletions.
30 changes: 25 additions & 5 deletions Documentation/devicetree/bindings/mailbox/nvidia,tegra186-hsp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ Required properties:
Array of strings.
one of:
- "nvidia,tegra186-hsp"
- "nvidia,tegra194-hsp", "nvidia,tegra186-hsp"
- reg : Offset and length of the register set for the device.
- interrupt-names
Array of strings.
Contains a list of names for the interrupts described by the interrupt
property. May contain the following entries, in any order:
- "doorbell"
- "sharedN", where 'N' is a number from zero up to the number of
external interrupts supported by the HSP instance minus one.
Users of this binding MUST look up entries in the interrupt property
by name, using this interrupt-names property to do so.
- interrupts
Expand All @@ -29,12 +32,29 @@ Required properties:
in a matching order.
- #mbox-cells : Should be 2.

The mbox specifier of the "mboxes" property in the client node should
contain two data. The first one should be the HSP type and the second
one should be the ID that the client is going to use. Those information
can be found in the following file.
The mbox specifier of the "mboxes" property in the client node should contain
two cells. The first cell determines the HSP type and the second cell is used
to identify the mailbox that the client is going to use.

- <dt-bindings/mailbox/tegra186-hsp.h>.
For doorbells, the second cell specifies the index of the doorbell to use.

For shared mailboxes, the second cell is composed of two fields:
- bits 31..24:
A bit mask of flags that further specify how the shared mailbox will be
used. Valid flags are:
- bit 31:
Defines the direction of the mailbox. If set, the mailbox will be used
as a producer (i.e. used to send data). If cleared, the mailbox is the
consumer of data sent by a producer.

- bits 23.. 0:
The index of the shared mailbox to use. The number of available mailboxes
may vary by instance of the HSP block and SoC generation.

The following file contains definitions that can be used to construct mailbox
specifiers:

<dt-bindings/mailbox/tegra186-hsp.h>

Example:

Expand Down
12 changes: 1 addition & 11 deletions drivers/mailbox/arm_mhu.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ static int mhu_probe(struct amba_device *adev, const struct amba_id *id)

amba_set_drvdata(adev, mhu);

err = mbox_controller_register(&mhu->mbox);
err = devm_mbox_controller_register(dev, &mhu->mbox);
if (err) {
dev_err(dev, "Failed to register mailboxes %d\n", err);
return err;
Expand All @@ -162,15 +162,6 @@ static int mhu_probe(struct amba_device *adev, const struct amba_id *id)
return 0;
}

static int mhu_remove(struct amba_device *adev)
{
struct arm_mhu *mhu = amba_get_drvdata(adev);

mbox_controller_unregister(&mhu->mbox);

return 0;
}

static struct amba_id mhu_ids[] = {
{
.id = 0x1bb098,
Expand All @@ -186,7 +177,6 @@ static struct amba_driver arm_mhu_driver = {
},
.id_table = mhu_ids,
.probe = mhu_probe,
.remove = mhu_remove,
};
module_amba_driver(arm_mhu_driver);

Expand Down
4 changes: 1 addition & 3 deletions drivers/mailbox/bcm-flexrm-mailbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -1665,7 +1665,7 @@ static int flexrm_mbox_probe(struct platform_device *pdev)
mbox->controller.chans[index].con_priv = &mbox->rings[index];

/* Register mailbox controller */
ret = mbox_controller_register(&mbox->controller);
ret = devm_mbox_controller_register(dev, &mbox->controller);
if (ret)
goto fail_free_debugfs_root;

Expand All @@ -1691,8 +1691,6 @@ static int flexrm_mbox_remove(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct flexrm_mbox *mbox = platform_get_drvdata(pdev);

mbox_controller_unregister(&mbox->controller);

debugfs_remove_recursive(mbox->root);

platform_msi_domain_free_irqs(dev);
Expand Down
4 changes: 1 addition & 3 deletions drivers/mailbox/bcm-pdc-mailbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -1471,7 +1471,7 @@ static int pdc_mb_init(struct pdc_state *pdcs)
mbc->chans[chan_index].con_priv = pdcs;

/* Register mailbox controller */
err = mbox_controller_register(mbc);
err = devm_mbox_controller_register(dev, mbc);
if (err) {
dev_crit(dev,
"Failed to register PDC mailbox controller. Error %d.",
Expand Down Expand Up @@ -1641,8 +1641,6 @@ static int pdc_remove(struct platform_device *pdev)

pdc_hw_disable(pdcs);

mbox_controller_unregister(&pdcs->mbc);

dma_pool_destroy(pdcs->rx_buf_pool);
dma_pool_destroy(pdcs->ring_pool);
return 0;
Expand Down
18 changes: 2 additions & 16 deletions drivers/mailbox/bcm2835-mailbox.c
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2010,2015 Broadcom
* Copyright (C) 2013-2014 Lubomir Rintel
* Copyright (C) 2013 Craig McGeachie
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This device provides a mechanism for writing to the mailboxes,
* that are shared between the ARM and the VideoCore processor
*
* Parts of the driver are based on:
* - arch/arm/mach-bcm2708/vcio.c file written by Gray Girling that was
* obtained from branch "rpi-3.6.y" of git://github.com/raspberrypi/
Expand Down Expand Up @@ -178,7 +172,7 @@ static int bcm2835_mbox_probe(struct platform_device *pdev)
if (!mbox->controller.chans)
return -ENOMEM;

ret = mbox_controller_register(&mbox->controller);
ret = devm_mbox_controller_register(dev, &mbox->controller);
if (ret)
return ret;

Expand All @@ -188,13 +182,6 @@ static int bcm2835_mbox_probe(struct platform_device *pdev)
return ret;
}

static int bcm2835_mbox_remove(struct platform_device *pdev)
{
struct bcm2835_mbox *mbox = platform_get_drvdata(pdev);
mbox_controller_unregister(&mbox->controller);
return 0;
}

static const struct of_device_id bcm2835_mbox_of_match[] = {
{ .compatible = "brcm,bcm2835-mbox", },
{},
Expand All @@ -207,7 +194,6 @@ static struct platform_driver bcm2835_mbox_driver = {
.of_match_table = bcm2835_mbox_of_match,
},
.probe = bcm2835_mbox_probe,
.remove = bcm2835_mbox_remove,
};
module_platform_driver(bcm2835_mbox_driver);

Expand Down
35 changes: 12 additions & 23 deletions drivers/mailbox/hi3660-mailbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#define MBOX_AUTOMATIC_ACK 1

#define MBOX_STATE_IDLE BIT(4)
#define MBOX_STATE_READY BIT(5)
#define MBOX_STATE_ACK BIT(7)

#define MBOX_MSG_LEN 8
Expand Down Expand Up @@ -91,8 +92,8 @@ static int hi3660_mbox_check_state(struct mbox_chan *chan)
unsigned long val;
unsigned int ret;

/* Mailbox is idle so directly bail out */
if (readl(base + MBOX_MODE_REG) & MBOX_STATE_IDLE)
/* Mailbox is ready to use */
if (readl(base + MBOX_MODE_REG) & MBOX_STATE_READY)
return 0;

/* Wait for acknowledge from remote */
Expand All @@ -103,9 +104,9 @@ static int hi3660_mbox_check_state(struct mbox_chan *chan)
return ret;
}

/* Ensure channel is released */
writel(0xffffffff, base + MBOX_IMASK_REG);
writel(BIT(mchan->ack_irq), base + MBOX_SRC_REG);
/* clear ack state, mailbox will get back to ready state */
writel(BIT(mchan->ack_irq), base + MBOX_ICLR_REG);

return 0;
}

Expand Down Expand Up @@ -160,10 +161,6 @@ static int hi3660_mbox_startup(struct mbox_chan *chan)
{
int ret;

ret = hi3660_mbox_check_state(chan);
if (ret)
return ret;

ret = hi3660_mbox_unlock(chan);
if (ret)
return ret;
Expand All @@ -183,10 +180,11 @@ static int hi3660_mbox_send_data(struct mbox_chan *chan, void *msg)
void __iomem *base = MBOX_BASE(mbox, ch);
u32 *buf = msg;
unsigned int i;
int ret;

/* Ensure channel is released */
writel_relaxed(0xffffffff, base + MBOX_IMASK_REG);
writel_relaxed(BIT(mchan->ack_irq), base + MBOX_SRC_REG);
ret = hi3660_mbox_check_state(chan);
if (ret)
return ret;

/* Clear mask for destination interrupt */
writel_relaxed(~BIT(mchan->dst_irq), base + MBOX_IMASK_REG);
Expand All @@ -206,7 +204,7 @@ static int hi3660_mbox_send_data(struct mbox_chan *chan, void *msg)
return 0;
}

static struct mbox_chan_ops hi3660_mbox_ops = {
static const struct mbox_chan_ops hi3660_mbox_ops = {
.startup = hi3660_mbox_startup,
.send_data = hi3660_mbox_send_data,
};
Expand Down Expand Up @@ -267,7 +265,7 @@ static int hi3660_mbox_probe(struct platform_device *pdev)
for (ch = 0; ch < MBOX_CHAN_MAX; ch++)
chan[ch].con_priv = (void *)ch;

err = mbox_controller_register(&mbox->controller);
err = devm_mbox_controller_register(dev, &mbox->controller);
if (err) {
dev_err(dev, "Failed to register mailbox %d\n", err);
return err;
Expand All @@ -278,17 +276,8 @@ static int hi3660_mbox_probe(struct platform_device *pdev)
return 0;
}

static int hi3660_mbox_remove(struct platform_device *pdev)
{
struct hi3660_mbox *mbox = platform_get_drvdata(pdev);

mbox_controller_unregister(&mbox->controller);
return 0;
}

static struct platform_driver hi3660_mbox_driver = {
.probe = hi3660_mbox_probe,
.remove = hi3660_mbox_remove,
.driver = {
.name = "hi3660-mbox",
.of_match_table = hi3660_mbox_of_match,
Expand Down
11 changes: 1 addition & 10 deletions drivers/mailbox/hi6220-mailbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ static int hi6220_mbox_probe(struct platform_device *pdev)
mbox->controller.txpoll_period = 5;
}

err = mbox_controller_register(&mbox->controller);
err = devm_mbox_controller_register(dev, &mbox->controller);
if (err) {
dev_err(dev, "Failed to register mailbox %d\n", err);
return err;
Expand All @@ -360,22 +360,13 @@ static int hi6220_mbox_probe(struct platform_device *pdev)
return 0;
}

static int hi6220_mbox_remove(struct platform_device *pdev)
{
struct hi6220_mbox *mbox = platform_get_drvdata(pdev);

mbox_controller_unregister(&mbox->controller);
return 0;
}

static struct platform_driver hi6220_mbox_driver = {
.driver = {
.name = "hi6220-mbox",
.owner = THIS_MODULE,
.of_match_table = hi6220_mbox_of_match,
},
.probe = hi6220_mbox_probe,
.remove = hi6220_mbox_remove,
};

static int __init hi6220_mbox_init(void)
Expand Down
3 changes: 1 addition & 2 deletions drivers/mailbox/imx-mailbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,14 +324,13 @@ static int imx_mu_probe(struct platform_device *pdev)

imx_mu_init_generic(priv);

return mbox_controller_register(&priv->mbox);
return devm_mbox_controller_register(dev, &priv->mbox);
}

static int imx_mu_remove(struct platform_device *pdev)
{
struct imx_mu_priv *priv = platform_get_drvdata(pdev);

mbox_controller_unregister(&priv->mbox);
clk_disable_unprepare(priv->clk);

return 0;
Expand Down
15 changes: 1 addition & 14 deletions drivers/mailbox/mailbox-altera.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ static int altera_mbox_probe(struct platform_device *pdev)
}
}

ret = mbox_controller_register(&mbox->controller);
ret = devm_mbox_controller_register(&pdev->dev, &mbox->controller);
if (ret) {
dev_err(&pdev->dev, "Register mailbox failed\n");
goto err;
Expand All @@ -352,18 +352,6 @@ static int altera_mbox_probe(struct platform_device *pdev)
return ret;
}

static int altera_mbox_remove(struct platform_device *pdev)
{
struct altera_mbox *mbox = platform_get_drvdata(pdev);

if (!mbox)
return -EINVAL;

mbox_controller_unregister(&mbox->controller);

return 0;
}

static const struct of_device_id altera_mbox_match[] = {
{ .compatible = "altr,mailbox-1.0" },
{ /* Sentinel */ }
Expand All @@ -373,7 +361,6 @@ MODULE_DEVICE_TABLE(of, altera_mbox_match);

static struct platform_driver altera_mbox_driver = {
.probe = altera_mbox_probe,
.remove = altera_mbox_remove,
.driver = {
.name = DRIVER_NAME,
.of_match_table = altera_mbox_match,
Expand Down
13 changes: 1 addition & 12 deletions drivers/mailbox/mailbox-sti.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ static int sti_mbox_probe(struct platform_device *pdev)
mbox->chans = chans;
mbox->num_chans = STI_MBOX_CHAN_MAX;

ret = mbox_controller_register(mbox);
ret = devm_mbox_controller_register(&pdev->dev, mbox);
if (ret)
return ret;

Expand All @@ -480,7 +480,6 @@ static int sti_mbox_probe(struct platform_device *pdev)
IRQF_ONESHOT, mdev->name, mdev);
if (ret) {
dev_err(&pdev->dev, "Can't claim IRQ %d\n", irq);
mbox_controller_unregister(mbox);
return -EINVAL;
}

Expand All @@ -489,18 +488,8 @@ static int sti_mbox_probe(struct platform_device *pdev)
return 0;
}

static int sti_mbox_remove(struct platform_device *pdev)
{
struct sti_mbox_device *mdev = platform_get_drvdata(pdev);

mbox_controller_unregister(mdev->mbox);

return 0;
}

static struct platform_driver sti_mbox_driver = {
.probe = sti_mbox_probe,
.remove = sti_mbox_remove,
.driver = {
.name = "sti-mailbox",
.of_match_table = sti_mailbox_match,
Expand Down
Loading

0 comments on commit 35ddb06

Please sign in to comment.