Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Sudeep Holla and committed by
Jassi Brar
2d74ffdc 27fa680f

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