aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSudeep Holla <sudeep.holla@arm.com>2016-02-19 11:01:18 -0500
committerJassi Brar <jaswinder.singh@linaro.org>2016-03-04 02:02:19 -0500
commit2d74ffdc910e06c407f0a3ace9795f77cc07d05b (patch)
tree6ad10150122a1dfd3c9d13df76afc0f32e39557f
parent27fa680f7f4143f1d04945dbcded0f52e26e5d56 (diff)
mailbox: mailbox-test: add support for separate tx/rx buffer with single channel
This patch adds support for different MMIO region for Tx and Rx paths. If only one region is specified, it's assumed to be shared between Rx and Tx, thereby retaining backward compatibility. Also in order to support single channel dealing with both Tx and Rx with dedicated MMIO regions, Tx channel itself is assigned to Rx if MMIO regions are different and Rx is not specified. Acked-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
-rw-r--r--drivers/mailbox/mailbox-test.c31
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
32struct mbox_test_device { 32struct 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