Blame view
drivers/bus/omap-ocp2scp.c
3.44 KB
26a84b3ea drivers: bus: add... |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
/* * omap-ocp2scp.c - transform ocp interface protocol to scp protocol * * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Author: Kishon Vijay Abraham I <kishon@ti.com> * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * */ |
cdf61240e bus: ocp2scp: SYN... |
18 |
#include <linux/io.h> |
26a84b3ea drivers: bus: add... |
19 20 21 22 23 24 |
#include <linux/module.h> #include <linux/platform_device.h> #include <linux/err.h> #include <linux/pm_runtime.h> #include <linux/of.h> #include <linux/of_platform.h> |
cdf61240e bus: ocp2scp: SYN... |
25 26 |
#define OCP2SCP_TIMING 0x18 #define SYNC2_MASK 0xf |
26a84b3ea drivers: bus: add... |
27 28 29 30 31 32 33 34 |
static int ocp2scp_remove_devices(struct device *dev, void *c) { struct platform_device *pdev = to_platform_device(dev); platform_device_unregister(pdev); return 0; } |
0fe763c57 Drivers: misc: re... |
35 |
static int omap_ocp2scp_probe(struct platform_device *pdev) |
26a84b3ea drivers: bus: add... |
36 |
{ |
0133370f9 drivers: bus: ocp... |
37 |
int ret; |
cdf61240e bus: ocp2scp: SYN... |
38 39 40 |
u32 reg; void __iomem *regs; struct resource *res; |
0133370f9 drivers: bus: ocp... |
41 |
struct device_node *np = pdev->dev.of_node; |
26a84b3ea drivers: bus: add... |
42 43 44 45 |
if (np) { ret = of_platform_populate(np, NULL, NULL, &pdev->dev); if (ret) { |
0133370f9 drivers: bus: ocp... |
46 47 48 |
dev_err(&pdev->dev, "failed to add resources for ocp2scp child "); |
26a84b3ea drivers: bus: add... |
49 50 51 |
goto err0; } } |
0133370f9 drivers: bus: ocp... |
52 |
|
26a84b3ea drivers: bus: add... |
53 |
pm_runtime_enable(&pdev->dev); |
cdf61240e bus: ocp2scp: SYN... |
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
/* * As per AM572x TRM: http://www.ti.com/lit/ug/spruhz6/spruhz6.pdf * under section 26.3.2.2, table 26-26 OCP2SCP TIMING Caution; * As per OMAP4430 TRM: http://www.ti.com/lit/ug/swpu231ap/swpu231ap.pdf * under section 23.12.6.2.2 , Table 23-1213 OCP2SCP TIMING Caution; * As per OMAP4460 TRM: http://www.ti.com/lit/ug/swpu235ab/swpu235ab.pdf * under section 23.12.6.2.2, Table 23-1213 OCP2SCP TIMING Caution; * As per OMAP543x TRM http://www.ti.com/lit/pdf/swpu249 * under section 27.3.2.2, Table 27-27 OCP2SCP TIMING Caution; * * Read path of OCP2SCP is not working properly due to low reset value * of SYNC2 parameter in OCP2SCP. Suggested reset value is 0x6 or more. */ if (!of_device_is_compatible(np, "ti,am437x-ocp2scp")) { res = platform_get_resource(pdev, IORESOURCE_MEM, 0); regs = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(regs)) goto err0; pm_runtime_get_sync(&pdev->dev); reg = readl_relaxed(regs + OCP2SCP_TIMING); reg &= ~(SYNC2_MASK); reg |= 0x6; writel_relaxed(reg, regs + OCP2SCP_TIMING); pm_runtime_put_sync(&pdev->dev); } |
26a84b3ea drivers: bus: add... |
80 81 82 83 84 85 86 87 |
return 0; err0: device_for_each_child(&pdev->dev, NULL, ocp2scp_remove_devices); return ret; } |
0fe763c57 Drivers: misc: re... |
88 |
static int omap_ocp2scp_remove(struct platform_device *pdev) |
26a84b3ea drivers: bus: add... |
89 90 91 92 93 94 95 96 97 98 |
{ pm_runtime_disable(&pdev->dev); device_for_each_child(&pdev->dev, NULL, ocp2scp_remove_devices); return 0; } #ifdef CONFIG_OF static const struct of_device_id omap_ocp2scp_id_table[] = { { .compatible = "ti,omap-ocp2scp" }, |
cdf61240e bus: ocp2scp: SYN... |
99 |
{ .compatible = "ti,am437x-ocp2scp" }, |
26a84b3ea drivers: bus: add... |
100 101 |
{} }; |
46ca68115 drivers: bus: oma... |
102 |
MODULE_DEVICE_TABLE(of, omap_ocp2scp_id_table); |
26a84b3ea drivers: bus: add... |
103 104 105 106 |
#endif static struct platform_driver omap_ocp2scp_driver = { .probe = omap_ocp2scp_probe, |
0fe763c57 Drivers: misc: re... |
107 |
.remove = omap_ocp2scp_remove, |
26a84b3ea drivers: bus: add... |
108 109 |
.driver = { .name = "omap-ocp2scp", |
26a84b3ea drivers: bus: add... |
110 111 112 113 114 |
.of_match_table = of_match_ptr(omap_ocp2scp_id_table), }, }; module_platform_driver(omap_ocp2scp_driver); |
7ef71b70e bus: omap-ocp2scp... |
115 |
MODULE_ALIAS("platform:omap-ocp2scp"); |
26a84b3ea drivers: bus: add... |
116 117 118 |
MODULE_AUTHOR("Texas Instruments Inc."); MODULE_DESCRIPTION("OMAP OCP2SCP driver"); MODULE_LICENSE("GPL v2"); |