usb: dwc3: exynos: Use of_platform API to create dwc3 core pdev
Used of_platform_populate() to create dwc3 core platform_device from device tree data. Additionally some cleanup is also done. Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com> CC: Felipe Balbi <balbi@ti.com> CC: Kukjin Kim <kgene.kim@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
This commit is contained in:
parent
b527675817
commit
adcf20dcd2
@ -22,9 +22,9 @@
|
|||||||
#include <linux/usb/otg.h>
|
#include <linux/usb/otg.h>
|
||||||
#include <linux/usb/nop-usb-xceiv.h>
|
#include <linux/usb/nop-usb-xceiv.h>
|
||||||
#include <linux/of.h>
|
#include <linux/of.h>
|
||||||
|
#include <linux/of_platform.h>
|
||||||
|
|
||||||
struct dwc3_exynos {
|
struct dwc3_exynos {
|
||||||
struct platform_device *dwc3;
|
|
||||||
struct platform_device *usb2_phy;
|
struct platform_device *usb2_phy;
|
||||||
struct platform_device *usb3_phy;
|
struct platform_device *usb3_phy;
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
@ -86,21 +86,30 @@ err1:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int dwc3_exynos_remove_child(struct device *dev, void *unused)
|
||||||
|
{
|
||||||
|
struct platform_device *pdev = to_platform_device(dev);
|
||||||
|
|
||||||
|
platform_device_unregister(pdev);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static u64 dwc3_exynos_dma_mask = DMA_BIT_MASK(32);
|
static u64 dwc3_exynos_dma_mask = DMA_BIT_MASK(32);
|
||||||
|
|
||||||
static int dwc3_exynos_probe(struct platform_device *pdev)
|
static int dwc3_exynos_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct platform_device *dwc3;
|
|
||||||
struct dwc3_exynos *exynos;
|
struct dwc3_exynos *exynos;
|
||||||
struct clk *clk;
|
struct clk *clk;
|
||||||
struct device *dev = &pdev->dev;
|
struct device *dev = &pdev->dev;
|
||||||
|
struct device_node *node = dev->of_node;
|
||||||
|
|
||||||
int ret = -ENOMEM;
|
int ret = -ENOMEM;
|
||||||
|
|
||||||
exynos = devm_kzalloc(dev, sizeof(*exynos), GFP_KERNEL);
|
exynos = devm_kzalloc(dev, sizeof(*exynos), GFP_KERNEL);
|
||||||
if (!exynos) {
|
if (!exynos) {
|
||||||
dev_err(dev, "not enough memory\n");
|
dev_err(dev, "not enough memory\n");
|
||||||
return -ENOMEM;
|
goto err1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -108,21 +117,15 @@ static int dwc3_exynos_probe(struct platform_device *pdev)
|
|||||||
* Since shared usb code relies on it, set it here for now.
|
* Since shared usb code relies on it, set it here for now.
|
||||||
* Once we move to full device tree support this will vanish off.
|
* Once we move to full device tree support this will vanish off.
|
||||||
*/
|
*/
|
||||||
if (!pdev->dev.dma_mask)
|
if (!dev->dma_mask)
|
||||||
pdev->dev.dma_mask = &dwc3_exynos_dma_mask;
|
dev->dma_mask = &dwc3_exynos_dma_mask;
|
||||||
|
|
||||||
platform_set_drvdata(pdev, exynos);
|
platform_set_drvdata(pdev, exynos);
|
||||||
|
|
||||||
ret = dwc3_exynos_register_phys(exynos);
|
ret = dwc3_exynos_register_phys(exynos);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(dev, "couldn't register PHYs\n");
|
dev_err(dev, "couldn't register PHYs\n");
|
||||||
return ret;
|
goto err1;
|
||||||
}
|
|
||||||
|
|
||||||
dwc3 = platform_device_alloc("dwc3", PLATFORM_DEVID_AUTO);
|
|
||||||
if (!dwc3) {
|
|
||||||
dev_err(dev, "couldn't allocate dwc3 device\n");
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
clk = devm_clk_get(dev, "usbdrd30");
|
clk = devm_clk_get(dev, "usbdrd30");
|
||||||
@ -132,27 +135,20 @@ static int dwc3_exynos_probe(struct platform_device *pdev)
|
|||||||
goto err1;
|
goto err1;
|
||||||
}
|
}
|
||||||
|
|
||||||
dma_set_coherent_mask(&dwc3->dev, dev->coherent_dma_mask);
|
|
||||||
|
|
||||||
dwc3->dev.parent = dev;
|
|
||||||
dwc3->dev.dma_mask = dev->dma_mask;
|
|
||||||
dwc3->dev.dma_parms = dev->dma_parms;
|
|
||||||
exynos->dwc3 = dwc3;
|
|
||||||
exynos->dev = dev;
|
exynos->dev = dev;
|
||||||
exynos->clk = clk;
|
exynos->clk = clk;
|
||||||
|
|
||||||
clk_enable(exynos->clk);
|
clk_enable(exynos->clk);
|
||||||
|
|
||||||
ret = platform_device_add_resources(dwc3, pdev->resource,
|
if (node) {
|
||||||
pdev->num_resources);
|
ret = of_platform_populate(node, NULL, NULL, dev);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(dev, "couldn't add resources to dwc3 device\n");
|
dev_err(dev, "failed to add dwc3 core\n");
|
||||||
goto err2;
|
goto err2;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
ret = platform_device_add(dwc3);
|
dev_err(dev, "no device node, failed to add dwc3 core\n");
|
||||||
if (ret) {
|
ret = -ENODEV;
|
||||||
dev_err(dev, "failed to register dwc3 device\n");
|
|
||||||
goto err2;
|
goto err2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,8 +157,6 @@ static int dwc3_exynos_probe(struct platform_device *pdev)
|
|||||||
err2:
|
err2:
|
||||||
clk_disable(clk);
|
clk_disable(clk);
|
||||||
err1:
|
err1:
|
||||||
platform_device_put(dwc3);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,9 +164,9 @@ static int dwc3_exynos_remove(struct platform_device *pdev)
|
|||||||
{
|
{
|
||||||
struct dwc3_exynos *exynos = platform_get_drvdata(pdev);
|
struct dwc3_exynos *exynos = platform_get_drvdata(pdev);
|
||||||
|
|
||||||
platform_device_unregister(exynos->dwc3);
|
|
||||||
platform_device_unregister(exynos->usb2_phy);
|
platform_device_unregister(exynos->usb2_phy);
|
||||||
platform_device_unregister(exynos->usb3_phy);
|
platform_device_unregister(exynos->usb3_phy);
|
||||||
|
device_for_each_child(&pdev->dev, NULL, dwc3_exynos_remove_child);
|
||||||
|
|
||||||
clk_disable(exynos->clk);
|
clk_disable(exynos->clk);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user