diff options
author | Lee Jones <lee.jones@linaro.org> | 2013-05-03 10:32:11 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2013-05-23 15:13:06 -0400 |
commit | 1814a1703ce2d6d4b88b5f62a52b137afebad990 (patch) | |
tree | 0a035efe9458f9ebef3dc3a01e278540ab75276d | |
parent | bb75d93b903afcd0904c83850835857fd9f8ef2d (diff) |
dmaengine: ste_dma40: Allow driver to be probe()able when DT is enabled
When booting using Device Tree, devices aren't registered in the normal
way. Instead, they need to be provided with a compatible string which is
held in an OF Match Table for comparison during start-up. Here we provide
the compatible string and prepare the driver to not receive a platform
data pointer.
Acked-by: Vinod Koul <vnod.koul@intel.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
[Fixed up whitespace error]
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r-- | drivers/dma/ste_dma40.c | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c index 925cdbe08c2e..495e8869b9b0 100644 --- a/drivers/dma/ste_dma40.c +++ b/drivers/dma/ste_dma40.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/pm.h> | 17 | #include <linux/pm.h> |
18 | #include <linux/pm_runtime.h> | 18 | #include <linux/pm_runtime.h> |
19 | #include <linux/err.h> | 19 | #include <linux/err.h> |
20 | #include <linux/of.h> | ||
20 | #include <linux/amba/bus.h> | 21 | #include <linux/amba/bus.h> |
21 | #include <linux/regulator/consumer.h> | 22 | #include <linux/regulator/consumer.h> |
22 | #include <linux/platform_data/dma-ste-dma40.h> | 23 | #include <linux/platform_data/dma-ste-dma40.h> |
@@ -3471,17 +3472,52 @@ failure: | |||
3471 | return ret; | 3472 | return ret; |
3472 | } | 3473 | } |
3473 | 3474 | ||
3475 | static int __init d40_of_probe(struct platform_device *pdev, | ||
3476 | struct device_node *np) | ||
3477 | { | ||
3478 | struct stedma40_platform_data *pdata; | ||
3479 | |||
3480 | /* | ||
3481 | * FIXME: Fill in this routine as more support is added. | ||
3482 | * First platform enabled (u8500) doens't need any extra | ||
3483 | * properties to run, so this is fairly sparce currently. | ||
3484 | */ | ||
3485 | |||
3486 | pdata = devm_kzalloc(&pdev->dev, | ||
3487 | sizeof(struct stedma40_platform_data), | ||
3488 | GFP_KERNEL); | ||
3489 | if (!pdata) | ||
3490 | return -ENOMEM; | ||
3491 | |||
3492 | pdev->dev.platform_data = pdata; | ||
3493 | |||
3494 | return 0; | ||
3495 | } | ||
3496 | |||
3474 | static int __init d40_probe(struct platform_device *pdev) | 3497 | static int __init d40_probe(struct platform_device *pdev) |
3475 | { | 3498 | { |
3499 | struct stedma40_platform_data *plat_data = pdev->dev.platform_data; | ||
3500 | struct device_node *np = pdev->dev.of_node; | ||
3476 | int err; | 3501 | int err; |
3477 | int ret = -ENOENT; | 3502 | int ret = -ENOENT; |
3478 | struct d40_base *base; | 3503 | struct d40_base *base = NULL; |
3479 | struct resource *res = NULL; | 3504 | struct resource *res = NULL; |
3480 | int num_reserved_chans; | 3505 | int num_reserved_chans; |
3481 | u32 val; | 3506 | u32 val; |
3482 | 3507 | ||
3483 | base = d40_hw_detect_init(pdev); | 3508 | if (!plat_data) { |
3509 | if (np) { | ||
3510 | if(d40_of_probe(pdev, np)) { | ||
3511 | ret = -ENOMEM; | ||
3512 | goto failure; | ||
3513 | } | ||
3514 | } else { | ||
3515 | d40_err(&pdev->dev, "No pdata or Device Tree provided\n"); | ||
3516 | goto failure; | ||
3517 | } | ||
3518 | } | ||
3484 | 3519 | ||
3520 | base = d40_hw_detect_init(pdev); | ||
3485 | if (!base) | 3521 | if (!base) |
3486 | goto failure; | 3522 | goto failure; |
3487 | 3523 | ||
@@ -3655,11 +3691,17 @@ failure: | |||
3655 | return ret; | 3691 | return ret; |
3656 | } | 3692 | } |
3657 | 3693 | ||
3694 | static const struct of_device_id d40_match[] = { | ||
3695 | { .compatible = "stericsson,dma40", }, | ||
3696 | {} | ||
3697 | }; | ||
3698 | |||
3658 | static struct platform_driver d40_driver = { | 3699 | static struct platform_driver d40_driver = { |
3659 | .driver = { | 3700 | .driver = { |
3660 | .owner = THIS_MODULE, | 3701 | .owner = THIS_MODULE, |
3661 | .name = D40_NAME, | 3702 | .name = D40_NAME, |
3662 | .pm = DMA40_PM_OPS, | 3703 | .pm = DMA40_PM_OPS, |
3704 | .of_match_table = d40_match, | ||
3663 | }, | 3705 | }, |
3664 | }; | 3706 | }; |
3665 | 3707 | ||