diff options
-rw-r--r-- | drivers/mailbox/mailbox-test.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/drivers/mailbox/mailbox-test.c b/drivers/mailbox/mailbox-test.c index f690f11969a1..dc11bbf27274 100644 --- a/drivers/mailbox/mailbox-test.c +++ b/drivers/mailbox/mailbox-test.c | |||
@@ -31,7 +31,8 @@ static struct dentry *root_debugfs_dir; | |||
31 | 31 | ||
32 | struct mbox_test_device { | 32 | struct mbox_test_device { |
33 | struct device *dev; | 33 | struct device *dev; |
34 | void __iomem *mmio; | 34 | void __iomem *tx_mmio; |
35 | void __iomem *rx_mmio; | ||
35 | struct mbox_chan *tx_channel; | 36 | struct mbox_chan *tx_channel; |
36 | struct mbox_chan *rx_channel; | 37 | struct mbox_chan *rx_channel; |
37 | char *rx_buffer; | 38 | char *rx_buffer; |
@@ -112,7 +113,7 @@ static ssize_t mbox_test_message_write(struct file *filp, | |||
112 | * A separate signal is only of use if there is | 113 | * A separate signal is only of use if there is |
113 | * MMIO to subsequently pass the message through | 114 | * MMIO to subsequently pass the message through |
114 | */ | 115 | */ |
115 | if (tdev->mmio && tdev->signal) { | 116 | if (tdev->tx_mmio && tdev->signal) { |
116 | print_hex_dump_bytes("Client: Sending: Signal: ", DUMP_PREFIX_ADDRESS, | 117 | print_hex_dump_bytes("Client: Sending: Signal: ", DUMP_PREFIX_ADDRESS, |
117 | tdev->signal, MBOX_MAX_SIG_LEN); | 118 | tdev->signal, MBOX_MAX_SIG_LEN); |
118 | 119 | ||
@@ -220,8 +221,8 @@ static void mbox_test_receive_message(struct mbox_client *client, void *message) | |||
220 | unsigned long flags; | 221 | unsigned long flags; |
221 | 222 | ||
222 | spin_lock_irqsave(&tdev->lock, flags); | 223 | spin_lock_irqsave(&tdev->lock, flags); |
223 | if (tdev->mmio) { | 224 | if (tdev->rx_mmio) { |
224 | memcpy_fromio(tdev->rx_buffer, tdev->mmio, MBOX_MAX_MSG_LEN); | 225 | memcpy_fromio(tdev->rx_buffer, tdev->rx_mmio, MBOX_MAX_MSG_LEN); |
225 | print_hex_dump_bytes("Client: Received [MMIO]: ", DUMP_PREFIX_ADDRESS, | 226 | print_hex_dump_bytes("Client: Received [MMIO]: ", DUMP_PREFIX_ADDRESS, |
226 | tdev->rx_buffer, MBOX_MAX_MSG_LEN); | 227 | tdev->rx_buffer, MBOX_MAX_MSG_LEN); |
227 | } else if (message) { | 228 | } else if (message) { |
@@ -236,11 +237,11 @@ static void mbox_test_prepare_message(struct mbox_client *client, void *message) | |||
236 | { | 237 | { |
237 | struct mbox_test_device *tdev = dev_get_drvdata(client->dev); | 238 | struct mbox_test_device *tdev = dev_get_drvdata(client->dev); |
238 | 239 | ||
239 | if (tdev->mmio) { | 240 | if (tdev->tx_mmio) { |
240 | if (tdev->signal) | 241 | if (tdev->signal) |
241 | memcpy_toio(tdev->mmio, tdev->message, MBOX_MAX_MSG_LEN); | 242 | memcpy_toio(tdev->tx_mmio, tdev->message, MBOX_MAX_MSG_LEN); |
242 | else | 243 | else |
243 | memcpy_toio(tdev->mmio, message, MBOX_MAX_MSG_LEN); | 244 | memcpy_toio(tdev->tx_mmio, message, MBOX_MAX_MSG_LEN); |
244 | } | 245 | } |
245 | } | 246 | } |
246 | 247 | ||
@@ -294,9 +295,15 @@ static int mbox_test_probe(struct platform_device *pdev) | |||
294 | 295 | ||
295 | /* It's okay for MMIO to be NULL */ | 296 | /* It's okay for MMIO to be NULL */ |
296 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 297 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
297 | tdev->mmio = devm_ioremap_resource(&pdev->dev, res); | 298 | tdev->tx_mmio = devm_ioremap_resource(&pdev->dev, res); |
298 | if (IS_ERR(tdev->mmio)) | 299 | if (IS_ERR(tdev->tx_mmio)) |
299 | tdev->mmio = NULL; | 300 | tdev->tx_mmio = NULL; |
301 | |||
302 | /* If specified, second reg entry is Rx MMIO */ | ||
303 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); | ||
304 | tdev->rx_mmio = devm_ioremap_resource(&pdev->dev, res); | ||
305 | if (IS_ERR(tdev->rx_mmio)) | ||
306 | tdev->rx_mmio = tdev->tx_mmio; | ||
300 | 307 | ||
301 | tdev->tx_channel = mbox_test_request_channel(pdev, "tx"); | 308 | tdev->tx_channel = mbox_test_request_channel(pdev, "tx"); |
302 | tdev->rx_channel = mbox_test_request_channel(pdev, "rx"); | 309 | tdev->rx_channel = mbox_test_request_channel(pdev, "rx"); |
@@ -304,6 +311,10 @@ static int mbox_test_probe(struct platform_device *pdev) | |||
304 | if (!tdev->tx_channel && !tdev->rx_channel) | 311 | if (!tdev->tx_channel && !tdev->rx_channel) |
305 | return -EPROBE_DEFER; | 312 | return -EPROBE_DEFER; |
306 | 313 | ||
314 | /* If Rx is not specified but has Rx MMIO, then Rx = Tx */ | ||
315 | if (!tdev->rx_channel && (tdev->rx_mmio != tdev->tx_mmio)) | ||
316 | tdev->rx_channel = tdev->tx_channel; | ||
317 | |||
307 | tdev->dev = &pdev->dev; | 318 | tdev->dev = &pdev->dev; |
308 | platform_set_drvdata(pdev, tdev); | 319 | platform_set_drvdata(pdev, tdev); |
309 | 320 | ||