Skip to content

Commit 2e10289

Browse files
ConchuODJassiBrar
authored andcommitted
mailbox: mpfs: fix handling of the reg property
The "data" region of the PolarFire SoC's system controller mailbox is not one continuous register space - the system controller's QSPI sits between the control and data registers. Split the "data" reg into two parts: "data" & "control". Optionally get the "data" register address from the 3rd reg property in the devicetree & fall back to using the old base + MAILBOX_REG_OFFSET that the current code uses. Fixes: 83d7b15 ("mbox: add polarfire soc system controller mailbox") Signed-off-by: Conor Dooley <conor.dooley@microchip.com> Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
1 parent 6e2bdf7 commit 2e10289

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

drivers/mailbox/mailbox-mpfs.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ struct mpfs_mbox {
6262
struct mbox_controller controller;
6363
struct device *dev;
6464
int irq;
65+
void __iomem *ctrl_base;
6566
void __iomem *mbox_base;
6667
void __iomem *int_reg;
6768
struct mbox_chan chans[1];
@@ -73,7 +74,7 @@ static bool mpfs_mbox_busy(struct mpfs_mbox *mbox)
7374
{
7475
u32 status;
7576

76-
status = readl_relaxed(mbox->mbox_base + SERVICES_SR_OFFSET);
77+
status = readl_relaxed(mbox->ctrl_base + SERVICES_SR_OFFSET);
7778

7879
return status & SCB_STATUS_BUSY_MASK;
7980
}
@@ -99,29 +100,28 @@ static int mpfs_mbox_send_data(struct mbox_chan *chan, void *data)
99100

100101
for (index = 0; index < (msg->cmd_data_size / 4); index++)
101102
writel_relaxed(word_buf[index],
102-
mbox->mbox_base + MAILBOX_REG_OFFSET + index * 0x4);
103+
mbox->mbox_base + index * 0x4);
103104
if (extra_bits) {
104105
u8 i;
105106
u8 byte_off = ALIGN_DOWN(msg->cmd_data_size, 4);
106107
u8 *byte_buf = msg->cmd_data + byte_off;
107108

108-
val = readl_relaxed(mbox->mbox_base +
109-
MAILBOX_REG_OFFSET + index * 0x4);
109+
val = readl_relaxed(mbox->mbox_base + index * 0x4);
110110

111111
for (i = 0u; i < extra_bits; i++) {
112112
val &= ~(0xffu << (i * 8u));
113113
val |= (byte_buf[i] << (i * 8u));
114114
}
115115

116116
writel_relaxed(val,
117-
mbox->mbox_base + MAILBOX_REG_OFFSET + index * 0x4);
117+
mbox->mbox_base + index * 0x4);
118118
}
119119
}
120120

121121
opt_sel = ((msg->mbox_offset << 7u) | (msg->cmd_opcode & 0x7fu));
122122
tx_trigger = (opt_sel << SCB_CTRL_POS) & SCB_CTRL_MASK;
123123
tx_trigger |= SCB_CTRL_REQ_MASK | SCB_STATUS_NOTIFY_MASK;
124-
writel_relaxed(tx_trigger, mbox->mbox_base + SERVICES_CR_OFFSET);
124+
writel_relaxed(tx_trigger, mbox->ctrl_base + SERVICES_CR_OFFSET);
125125

126126
return 0;
127127
}
@@ -141,7 +141,7 @@ static void mpfs_mbox_rx_data(struct mbox_chan *chan)
141141
if (!mpfs_mbox_busy(mbox)) {
142142
for (i = 0; i < num_words; i++) {
143143
response->resp_msg[i] =
144-
readl_relaxed(mbox->mbox_base + MAILBOX_REG_OFFSET
144+
readl_relaxed(mbox->mbox_base
145145
+ mbox->resp_offset + i * 0x4);
146146
}
147147
}
@@ -200,14 +200,18 @@ static int mpfs_mbox_probe(struct platform_device *pdev)
200200
if (!mbox)
201201
return -ENOMEM;
202202

203-
mbox->mbox_base = devm_platform_get_and_ioremap_resource(pdev, 0, &regs);
204-
if (IS_ERR(mbox->mbox_base))
205-
return PTR_ERR(mbox->mbox_base);
203+
mbox->ctrl_base = devm_platform_get_and_ioremap_resource(pdev, 0, &regs);
204+
if (IS_ERR(mbox->ctrl_base))
205+
return PTR_ERR(mbox->ctrl_base);
206206

207207
mbox->int_reg = devm_platform_get_and_ioremap_resource(pdev, 1, &regs);
208208
if (IS_ERR(mbox->int_reg))
209209
return PTR_ERR(mbox->int_reg);
210210

211+
mbox->mbox_base = devm_platform_get_and_ioremap_resource(pdev, 2, &regs);
212+
if (IS_ERR(mbox->mbox_base)) // account for the old dt-binding w/ 2 regs
213+
mbox->mbox_base = mbox->ctrl_base + MAILBOX_REG_OFFSET;
214+
211215
mbox->irq = platform_get_irq(pdev, 0);
212216
if (mbox->irq < 0)
213217
return mbox->irq;

0 commit comments

Comments
 (0)