Skip to content

Commit a6afa41

Browse files
committed
Merge tag 'mailbox-v6.1' of git://git.linaro.org/landing-teams/working/fujitsu/integration
Pull mailbox updates from Jassi Brar: - apple: implement poll and flush callbacks - qcom: fix clocks for IPQ6018 and IPQ8074 irq handler as not-a-thread - microchip: split reg-space into two - imx: RST channel fix - bcm: fix dma_map_sg error handling - misc: spelling fix in pcc driver * tag 'mailbox-v6.1' of git://git.linaro.org/landing-teams/working/fujitsu/integration: mailbox: qcom-ipcc: flag IRQ NO_THREAD mailbox: pcc: Fix spelling mistake "Plaform" -> "Platform" mailbox: bcm-ferxrm-mailbox: Fix error check for dma_map_sg mailbox: qcom-apcs-ipc: add IPQ8074 APSS clock support dt-bindings: mailbox: qcom: correct clocks for IPQ6018 and IPQ8074 dt-bindings: mailbox: qcom: set correct #clock-cells mailbox: mpfs: account for mbox offsets while sending mailbox: mpfs: fix handling of the reg property dt-bindings: mailbox: fix the mpfs' reg property mailbox: imx: fix RST channel support mailbox: apple: Implement poll_data() operation mailbox: apple: Implement flush() operation
2 parents bdc753c + b8ae88e commit a6afa41

File tree

9 files changed

+148
-43
lines changed

9 files changed

+148
-43
lines changed

Documentation/devicetree/bindings/mailbox/microchip,mpfs-mailbox.yaml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,15 @@ properties:
1414
const: microchip,mpfs-mailbox
1515

1616
reg:
17-
items:
18-
- description: mailbox data registers
19-
- description: mailbox interrupt registers
17+
oneOf:
18+
- items:
19+
- description: mailbox control & data registers
20+
- description: mailbox interrupt registers
21+
deprecated: true
22+
- items:
23+
- description: mailbox control registers
24+
- description: mailbox interrupt registers
25+
- description: mailbox data registers
2026

2127
interrupts:
2228
maxItems: 1
@@ -39,7 +45,8 @@ examples:
3945
#size-cells = <2>;
4046
mbox: mailbox@37020000 {
4147
compatible = "microchip,mpfs-mailbox";
42-
reg = <0x0 0x37020000 0x0 0x1000>, <0x0 0x2000318c 0x0 0x40>;
48+
reg = <0x0 0x37020000 0x0 0x58>, <0x0 0x2000318C 0x0 0x40>,
49+
<0x0 0x37020800 0x0 0x100>;
4350
interrupt-parent = <&L1>;
4451
interrupts = <96>;
4552
#mbox-cells = <1>;

Documentation/devicetree/bindings/mailbox/qcom,apcs-kpss-global.yaml

Lines changed: 50 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,17 @@ properties:
4545
clocks:
4646
description: phandles to the parent clocks of the clock driver
4747
minItems: 2
48-
items:
49-
- description: primary pll parent of the clock driver
50-
- description: auxiliary parent
51-
- description: reference clock
48+
maxItems: 3
5249

5350
'#mbox-cells':
5451
const: 1
5552

5653
'#clock-cells':
57-
const: 0
54+
enum: [0, 1]
5855

5956
clock-names:
6057
minItems: 2
61-
items:
62-
- const: pll
63-
- const: aux
64-
- const: ref
58+
maxItems: 3
6559

6660
required:
6761
- compatible
@@ -75,8 +69,6 @@ allOf:
7569
properties:
7670
compatible:
7771
enum:
78-
- qcom,ipq6018-apcs-apps-global
79-
- qcom,ipq8074-apcs-apps-global
8072
- qcom,msm8916-apcs-kpss-global
8173
- qcom,msm8994-apcs-kpss-global
8274
- qcom,msm8996-apcs-hmss-global
@@ -90,7 +82,13 @@ allOf:
9082
then:
9183
properties:
9284
clocks:
93-
maxItems: 2
85+
items:
86+
- description: primary pll parent of the clock driver
87+
- description: auxiliary parent
88+
clock-names:
89+
items:
90+
- const: pll
91+
- const: aux
9492
- if:
9593
properties:
9694
compatible:
@@ -99,7 +97,46 @@ allOf:
9997
then:
10098
properties:
10199
clocks:
102-
maxItems: 3
100+
items:
101+
- description: primary pll parent of the clock driver
102+
- description: auxiliary parent
103+
- description: reference clock
104+
clock-names:
105+
items:
106+
- const: pll
107+
- const: aux
108+
- const: ref
109+
- if:
110+
properties:
111+
compatible:
112+
enum:
113+
- qcom,ipq6018-apcs-apps-global
114+
- qcom,ipq8074-apcs-apps-global
115+
then:
116+
properties:
117+
clocks:
118+
items:
119+
- description: primary pll parent of the clock driver
120+
- description: XO clock
121+
clock-names:
122+
items:
123+
- const: pll
124+
- const: xo
125+
- if:
126+
properties:
127+
compatible:
128+
enum:
129+
- qcom,ipq6018-apcs-apps-global
130+
- qcom,ipq8074-apcs-apps-global
131+
then:
132+
properties:
133+
'#clock-cells':
134+
const: 1
135+
else:
136+
properties:
137+
'#clock-cells':
138+
const: 0
139+
103140
examples:
104141

105142
# Example apcs with msm8996

drivers/mailbox/apple-mailbox.c

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818

1919
#include <linux/apple-mailbox.h>
20+
#include <linux/delay.h>
2021
#include <linux/device.h>
2122
#include <linux/gfp.h>
2223
#include <linux/interrupt.h>
@@ -25,6 +26,7 @@
2526
#include <linux/module.h>
2627
#include <linux/of.h>
2728
#include <linux/platform_device.h>
29+
#include <linux/spinlock.h>
2830
#include <linux/types.h>
2931

3032
#define APPLE_ASC_MBOX_CONTROL_FULL BIT(16)
@@ -100,6 +102,7 @@ struct apple_mbox {
100102

101103
struct device *dev;
102104
struct mbox_controller controller;
105+
spinlock_t rx_lock;
103106
};
104107

105108
static const struct of_device_id apple_mbox_of_match[];
@@ -112,6 +115,14 @@ static bool apple_mbox_hw_can_send(struct apple_mbox *apple_mbox)
112115
return !(mbox_ctrl & apple_mbox->hw->control_full);
113116
}
114117

118+
static bool apple_mbox_hw_send_empty(struct apple_mbox *apple_mbox)
119+
{
120+
u32 mbox_ctrl =
121+
readl_relaxed(apple_mbox->regs + apple_mbox->hw->a2i_control);
122+
123+
return mbox_ctrl & apple_mbox->hw->control_empty;
124+
}
125+
115126
static int apple_mbox_hw_send(struct apple_mbox *apple_mbox,
116127
struct apple_mbox_msg *msg)
117128
{
@@ -195,13 +206,15 @@ static irqreturn_t apple_mbox_send_empty_irq(int irq, void *data)
195206
return IRQ_HANDLED;
196207
}
197208

198-
static irqreturn_t apple_mbox_recv_irq(int irq, void *data)
209+
static int apple_mbox_poll(struct apple_mbox *apple_mbox)
199210
{
200-
struct apple_mbox *apple_mbox = data;
201211
struct apple_mbox_msg msg;
212+
int ret = 0;
202213

203-
while (apple_mbox_hw_recv(apple_mbox, &msg) == 0)
214+
while (apple_mbox_hw_recv(apple_mbox, &msg) == 0) {
204215
mbox_chan_received_data(&apple_mbox->chan, (void *)&msg);
216+
ret++;
217+
}
205218

206219
/*
207220
* The interrupt will keep firing even if there are no more messages
@@ -216,9 +229,50 @@ static irqreturn_t apple_mbox_recv_irq(int irq, void *data)
216229
apple_mbox->regs + apple_mbox->hw->irq_ack);
217230
}
218231

232+
return ret;
233+
}
234+
235+
static irqreturn_t apple_mbox_recv_irq(int irq, void *data)
236+
{
237+
struct apple_mbox *apple_mbox = data;
238+
239+
spin_lock(&apple_mbox->rx_lock);
240+
apple_mbox_poll(apple_mbox);
241+
spin_unlock(&apple_mbox->rx_lock);
242+
219243
return IRQ_HANDLED;
220244
}
221245

246+
static bool apple_mbox_chan_peek_data(struct mbox_chan *chan)
247+
{
248+
struct apple_mbox *apple_mbox = chan->con_priv;
249+
unsigned long flags;
250+
int ret;
251+
252+
spin_lock_irqsave(&apple_mbox->rx_lock, flags);
253+
ret = apple_mbox_poll(apple_mbox);
254+
spin_unlock_irqrestore(&apple_mbox->rx_lock, flags);
255+
256+
return ret > 0;
257+
}
258+
259+
static int apple_mbox_chan_flush(struct mbox_chan *chan, unsigned long timeout)
260+
{
261+
struct apple_mbox *apple_mbox = chan->con_priv;
262+
unsigned long deadline = jiffies + msecs_to_jiffies(timeout);
263+
264+
while (time_before(jiffies, deadline)) {
265+
if (apple_mbox_hw_send_empty(apple_mbox)) {
266+
mbox_chan_txdone(&apple_mbox->chan, 0);
267+
return 0;
268+
}
269+
270+
udelay(1);
271+
}
272+
273+
return -ETIME;
274+
}
275+
222276
static int apple_mbox_chan_startup(struct mbox_chan *chan)
223277
{
224278
struct apple_mbox *apple_mbox = chan->con_priv;
@@ -250,6 +304,8 @@ static void apple_mbox_chan_shutdown(struct mbox_chan *chan)
250304

251305
static const struct mbox_chan_ops apple_mbox_ops = {
252306
.send_data = apple_mbox_chan_send_data,
307+
.peek_data = apple_mbox_chan_peek_data,
308+
.flush = apple_mbox_chan_flush,
253309
.startup = apple_mbox_chan_startup,
254310
.shutdown = apple_mbox_chan_shutdown,
255311
};
@@ -304,6 +360,7 @@ static int apple_mbox_probe(struct platform_device *pdev)
304360
mbox->controller.txdone_irq = true;
305361
mbox->controller.of_xlate = apple_mbox_of_xlate;
306362
mbox->chan.con_priv = mbox;
363+
spin_lock_init(&mbox->rx_lock);
307364

308365
irqname = devm_kasprintf(dev, GFP_KERNEL, "%s-recv", dev_name(dev));
309366
if (!irqname)

drivers/mailbox/bcm-flexrm-mailbox.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -622,15 +622,15 @@ static int flexrm_spu_dma_map(struct device *dev, struct brcm_message *msg)
622622

623623
rc = dma_map_sg(dev, msg->spu.src, sg_nents(msg->spu.src),
624624
DMA_TO_DEVICE);
625-
if (rc < 0)
626-
return rc;
625+
if (!rc)
626+
return -EIO;
627627

628628
rc = dma_map_sg(dev, msg->spu.dst, sg_nents(msg->spu.dst),
629629
DMA_FROM_DEVICE);
630-
if (rc < 0) {
630+
if (!rc) {
631631
dma_unmap_sg(dev, msg->spu.src, sg_nents(msg->spu.src),
632632
DMA_TO_DEVICE);
633-
return rc;
633+
return -EIO;
634634
}
635635

636636
return 0;

drivers/mailbox/imx-mailbox.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,7 @@ static const struct imx_mu_dcfg imx_mu_cfg_imx7ulp = {
904904
.xTR = 0x20,
905905
.xRR = 0x40,
906906
.xSR = {0x60, 0x60, 0x60, 0x60},
907-
.xCR = {0x64, 0x64, 0x64, 0x64},
907+
.xCR = {0x64, 0x64, 0x64, 0x64, 0x64},
908908
};
909909

910910
static const struct imx_mu_dcfg imx_mu_cfg_imx8ulp = {
@@ -927,7 +927,7 @@ static const struct imx_mu_dcfg imx_mu_cfg_imx8ulp_s4 = {
927927
.xTR = 0x200,
928928
.xRR = 0x280,
929929
.xSR = {0xC, 0x118, 0x124, 0x12C},
930-
.xCR = {0x110, 0x114, 0x120, 0x128},
930+
.xCR = {0x8, 0x110, 0x114, 0x120, 0x128},
931931
};
932932

933933
static const struct imx_mu_dcfg imx_mu_cfg_imx93_s4 = {
@@ -938,7 +938,7 @@ static const struct imx_mu_dcfg imx_mu_cfg_imx93_s4 = {
938938
.xTR = 0x200,
939939
.xRR = 0x280,
940940
.xSR = {0xC, 0x118, 0x124, 0x12C},
941-
.xCR = {0x110, 0x114, 0x120, 0x128},
941+
.xCR = {0x8, 0x110, 0x114, 0x120, 0x128},
942942
};
943943

944944
static const struct imx_mu_dcfg imx_mu_cfg_imx8_scu = {
@@ -949,7 +949,7 @@ static const struct imx_mu_dcfg imx_mu_cfg_imx8_scu = {
949949
.xTR = 0x0,
950950
.xRR = 0x10,
951951
.xSR = {0x20, 0x20, 0x20, 0x20},
952-
.xCR = {0x24, 0x24, 0x24, 0x24},
952+
.xCR = {0x24, 0x24, 0x24, 0x24, 0x24},
953953
};
954954

955955
static const struct imx_mu_dcfg imx_mu_cfg_imx8_seco = {
@@ -960,7 +960,7 @@ static const struct imx_mu_dcfg imx_mu_cfg_imx8_seco = {
960960
.xTR = 0x0,
961961
.xRR = 0x10,
962962
.xSR = {0x20, 0x20, 0x20, 0x20},
963-
.xCR = {0x24, 0x24, 0x24, 0x24},
963+
.xCR = {0x24, 0x24, 0x24, 0x24, 0x24},
964964
};
965965

966966
static const struct of_device_id imx_mu_dt_ids[] = {

0 commit comments

Comments
 (0)