mailbox: mailbox-test: allow reserved areas in SRAM

When CONFIG_SRAM is enable and the SRAM region is found, the entire SRAM
region resource is requested and marked as occupied by SRAM driver even
if certain parts of regions is marked reserved.

It's quite possible that a small region of the SRAM is reserved for all
the mailbox communication and hence it may fail to request the region
as it's already marked busy region.

This patch tries to just do a ioremap of this mailbox memory region if
it finds it busy.

Cc: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
This commit is contained in:
Sudeep Holla 2016-11-29 14:37:05 +00:00 коммит произвёл Jassi Brar
Родитель baef9a35d2
Коммит db4d22c07e
1 изменённых файлов: 10 добавлений и 2 удалений

Просмотреть файл

@ -352,6 +352,7 @@ static int mbox_test_probe(struct platform_device *pdev)
{ {
struct mbox_test_device *tdev; struct mbox_test_device *tdev;
struct resource *res; struct resource *res;
resource_size_t size;
int ret; int ret;
tdev = devm_kzalloc(&pdev->dev, sizeof(*tdev), GFP_KERNEL); tdev = devm_kzalloc(&pdev->dev, sizeof(*tdev), GFP_KERNEL);
@ -360,14 +361,21 @@ static int mbox_test_probe(struct platform_device *pdev)
/* It's okay for MMIO to be NULL */ /* It's okay for MMIO to be NULL */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
size = resource_size(res);
tdev->tx_mmio = devm_ioremap_resource(&pdev->dev, res); tdev->tx_mmio = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(tdev->tx_mmio)) if (PTR_ERR(tdev->tx_mmio) == -EBUSY)
/* if reserved area in SRAM, try just ioremap */
tdev->tx_mmio = devm_ioremap(&pdev->dev, res->start, size);
else if (IS_ERR(tdev->tx_mmio))
tdev->tx_mmio = NULL; tdev->tx_mmio = NULL;
/* If specified, second reg entry is Rx MMIO */ /* If specified, second reg entry is Rx MMIO */
res = platform_get_resource(pdev, IORESOURCE_MEM, 1); res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
size = resource_size(res);
tdev->rx_mmio = devm_ioremap_resource(&pdev->dev, res); tdev->rx_mmio = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(tdev->rx_mmio)) if (PTR_ERR(tdev->rx_mmio) == -EBUSY)
tdev->rx_mmio = devm_ioremap(&pdev->dev, res->start, size);
else if (IS_ERR(tdev->rx_mmio))
tdev->rx_mmio = tdev->tx_mmio; tdev->rx_mmio = tdev->tx_mmio;
tdev->tx_channel = mbox_test_request_channel(pdev, "tx"); tdev->tx_channel = mbox_test_request_channel(pdev, "tx");