Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 38 additions & 4 deletions Documentation/devicetree/bindings/mailbox/apple,mailbox.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ properties:
- apple,t6020-asc-mailbox
- const: apple,asc-mailbox-v4

- description:
The T6021 ANE coprocessor mailbox is an ASC mailbox. Only its
recv-not-empty interrupt is known.
items:
- const: apple,t6021-ane-mailbox
- const: apple,asc-mailbox-v4

- description:
AOP setup-port mailbox with a separate register layout.
const: apple,t8140-aop-setup-mailbox
Expand All @@ -62,11 +69,11 @@ properties:
maxItems: 1

interrupts:
minItems: 2
minItems: 1
maxItems: 4

interrupt-names:
minItems: 2
minItems: 1
maxItems: 4

iommus:
Expand Down Expand Up @@ -95,6 +102,7 @@ allOf:
then:
properties:
interrupts:
minItems: 2
maxItems: 2
interrupt-names:
items:
Expand All @@ -104,6 +112,34 @@ allOf:
- iommus
- apple,dma-range
else:
properties:
iommus: false
apple,dma-range: false

- if:
properties:
compatible:
contains:
const: apple,t6021-ane-mailbox
then:
properties:
interrupt-names:
minItems: 1
items:
- const: recv-not-empty
- const: send-empty
- const: send-not-empty
- const: recv-empty

- if:
properties:
compatible:
not:
contains:
enum:
- apple,t6021-ane-mailbox
- apple,t8140-aop-setup-mailbox
then:
properties:
interrupts:
minItems: 4
Expand All @@ -113,8 +149,6 @@ allOf:
- const: send-not-empty
- const: recv-empty
- const: recv-not-empty
iommus: false
apple,dma-range: false

required:
- compatible
Expand Down
37 changes: 23 additions & 14 deletions drivers/soc/apple/mailbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ int apple_mbox_send(struct apple_mbox *mbox, const struct apple_mbox_msg msg,
mbox_ctrl = readl_relaxed(mbox->regs + mbox->hw->a2i_control);

while (mbox_ctrl & mbox->hw->control_full) {
if (atomic) {
if (atomic || mbox->irq_send_empty < 0) {
ret = readl_poll_timeout_atomic(
mbox->regs + mbox->hw->a2i_control, mbox_ctrl,
!(mbox_ctrl & mbox->hw->control_full), 100,
Expand Down Expand Up @@ -395,11 +395,16 @@ static int apple_mbox_probe(struct platform_device *pdev)
mbox->irq_recv_not_empty =
platform_get_irq_byname(pdev, "recv-not-empty");
if (mbox->irq_recv_not_empty < 0)
return -ENODEV;
return mbox->irq_recv_not_empty;

mbox->irq_send_empty = platform_get_irq_byname(pdev, "send-empty");
if (mbox->irq_send_empty < 0)
return -ENODEV;
/*
* Some coprocessors (e.g. the T6021 ANE ASC) have no send-empty line.
* apple_mbox_send then polls the A2I control register instead.
*/
mbox->irq_send_empty =
platform_get_irq_byname_optional(pdev, "send-empty");
if (mbox->irq_send_empty < 0 && mbox->irq_send_empty != -ENXIO)
return mbox->irq_send_empty;

spin_lock_init(&mbox->rx_lock);
spin_lock_init(&mbox->tx_lock);
Expand All @@ -415,15 +420,19 @@ static int apple_mbox_probe(struct platform_device *pdev)
if (ret)
return ret;

irqname = devm_kasprintf(dev, GFP_KERNEL, "%s-send", dev_name(dev));
if (!irqname)
return -ENOMEM;

ret = devm_request_irq(dev, mbox->irq_send_empty,
apple_mbox_send_empty_irq,
IRQF_NO_AUTOEN | IRQF_NO_SUSPEND, irqname, mbox);
if (ret)
return ret;
if (mbox->irq_send_empty >= 0) {
irqname = devm_kasprintf(dev, GFP_KERNEL, "%s-send",
dev_name(dev));
if (!irqname)
return -ENOMEM;

ret = devm_request_irq(dev, mbox->irq_send_empty,
apple_mbox_send_empty_irq,
IRQF_NO_AUTOEN | IRQF_NO_SUSPEND,
irqname, mbox);
if (ret)
return ret;
}

ret = devm_pm_runtime_enable(dev);
if (ret)
Expand Down
2 changes: 1 addition & 1 deletion include/linux/soc/apple/mailbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct apple_mbox {
bool active;

int irq_recv_not_empty;
int irq_send_empty;
int irq_send_empty; /* < 0: no send-empty IRQ, TX polls */

spinlock_t rx_lock;
spinlock_t tx_lock;
Expand Down