|
14 | 14 | #include <linux/mailbox_client.h>
|
15 | 15 | #include <linux/module.h>
|
16 | 16 | #include <linux/of.h>
|
| 17 | +#include <linux/of_address.h> |
17 | 18 | #include <linux/of_platform.h>
|
18 | 19 | #include <linux/platform_device.h>
|
19 | 20 | #include <linux/pm_domain.h>
|
@@ -322,8 +323,10 @@ static int qcom_mpm_init(struct device_node *np, struct device_node *parent)
|
322 | 323 | struct device *dev = &pdev->dev;
|
323 | 324 | struct irq_domain *parent_domain;
|
324 | 325 | struct generic_pm_domain *genpd;
|
| 326 | + struct device_node *msgram_np; |
325 | 327 | struct qcom_mpm_priv *priv;
|
326 | 328 | unsigned int pin_cnt;
|
| 329 | + struct resource res; |
327 | 330 | int i, irq;
|
328 | 331 | int ret;
|
329 | 332 |
|
@@ -374,9 +377,26 @@ static int qcom_mpm_init(struct device_node *np, struct device_node *parent)
|
374 | 377 |
|
375 | 378 | raw_spin_lock_init(&priv->lock);
|
376 | 379 |
|
377 |
| - priv->base = devm_platform_ioremap_resource(pdev, 0); |
378 |
| - if (IS_ERR(priv->base)) |
379 |
| - return PTR_ERR(priv->base); |
| 380 | + /* If we have a handle to an RPM message ram partition, use it. */ |
| 381 | + msgram_np = of_parse_phandle(np, "qcom,rpm-msg-ram", 0); |
| 382 | + if (msgram_np) { |
| 383 | + ret = of_address_to_resource(msgram_np, 0, &res); |
| 384 | + if (ret) { |
| 385 | + of_node_put(msgram_np); |
| 386 | + return ret; |
| 387 | + } |
| 388 | + |
| 389 | + /* Don't use devm_ioremap_resource, as we're accessing a shared region. */ |
| 390 | + priv->base = devm_ioremap(dev, res.start, resource_size(&res)); |
| 391 | + of_node_put(msgram_np); |
| 392 | + if (IS_ERR(priv->base)) |
| 393 | + return PTR_ERR(priv->base); |
| 394 | + } else { |
| 395 | + /* Otherwise, fall back to simple MMIO. */ |
| 396 | + priv->base = devm_platform_ioremap_resource(pdev, 0); |
| 397 | + if (IS_ERR(priv->base)) |
| 398 | + return PTR_ERR(priv->base); |
| 399 | + } |
380 | 400 |
|
381 | 401 | for (i = 0; i < priv->reg_stride; i++) {
|
382 | 402 | qcom_mpm_write(priv, MPM_REG_ENABLE, i, 0);
|
|
0 commit comments