From: Roger Quadros <rogerq@ti.com>
To: balbi@ti.com, bcousson@baylibre.com, tony@atomide.com
Cc: balajitk@ti.com, kishon@ti.com, linux-omap@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linux-ide@vger.kernel.org,
linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
Roger Quadros <rogerq@ti.com>
Subject: [RFC PATCH 05/15] phy: omap-pipe3: Add SATA DPLL support
Date: Thu, 19 Sep 2013 16:05:33 +0300 [thread overview]
Message-ID: <1379595943-14622-6-git-send-email-rogerq@ti.com> (raw)
In-Reply-To: <1379595943-14622-1-git-send-email-rogerq@ti.com>
USB and SATA DPLLs need different settings. Provide
the SATA DPLL settings and use the proper DPLL settings
based on device tree compatible_id.
Signed-off-by: Roger Quadros <rogerq@ti.com>
---
drivers/phy/phy-omap-pipe3.c | 82 ++++++++++++++++++++++++++--------------
include/linux/phy/omap_pipe3.h | 6 +++
2 files changed, 60 insertions(+), 28 deletions(-)
diff --git a/drivers/phy/phy-omap-pipe3.c b/drivers/phy/phy-omap-pipe3.c
index 807ab8a..19d1664 100644
--- a/drivers/phy/phy-omap-pipe3.c
+++ b/drivers/phy/phy-omap-pipe3.c
@@ -58,29 +58,41 @@
*/
# define PLL_IDLE_TIME 100;
-struct pipe3_dpll_map {
- unsigned long rate;
- struct pipe3_dpll_params params;
-};
-
-static struct pipe3_dpll_map dpll_map[] = {
+static struct pipe3_dpll_map dpll_map_usb[] = {
{12000000, {1250, 5, 4, 20, 0} }, /* 12 MHz */
{16800000, {3125, 20, 4, 20, 0} }, /* 16.8 MHz */
{19200000, {1172, 8, 4, 20, 65537} }, /* 19.2 MHz */
{20000000, {1000, 7, 4, 10, 0} }, /* 20 MHz */
{26000000, {1250, 12, 4, 20, 0} }, /* 26 MHz */
{38400000, {3125, 47, 4, 20, 92843} }, /* 38.4 MHz */
+ { }, /* Terminator */
+};
+
+static struct pipe3_dpll_map dpll_map_sata[] = {
+ {12000000, {1000, 7, 4, 6, 0} }, /* 12 MHz */
+ {16800000, {714, 7, 4, 6, 0} }, /* 16.8 MHz */
+ {19200000, {625, 7, 4, 6, 0} }, /* 19.2 MHz */
+ {20000000, {600, 7, 4, 6, 0} }, /* 20 MHz */
+ {26000000, {461, 7, 4, 6, 0} }, /* 26 MHz */
+ {38400000, {312, 7, 4, 6, 0} }, /* 38.4 MHz */
+ { }, /* Terminator */
};
-static struct pipe3_dpll_params *omap_pipe3_get_dpll_params(unsigned long rate)
+static struct pipe3_dpll_params *omap_pipe3_get_dpll_params(struct omap_pipe3
+ *pipe3)
{
- int i;
+ unsigned long rate;
+ struct pipe3_dpll_map *dpll_map = pipe3->dpll_map;
- for (i = 0; i < ARRAY_SIZE(dpll_map); i++) {
- if (rate == dpll_map[i].rate)
- return &dpll_map[i].params;
+ rate = clk_get_rate(pipe3->sys_clk);
+
+ for (; dpll_map->rate; dpll_map++) {
+ if (rate == dpll_map->rate)
+ return &dpll_map->params;
}
+ dev_err(pipe3->dev,
+ "No DPLL configuration for %lu Hz SYS CLK\n", rate);
return 0;
}
@@ -148,10 +160,8 @@ static int omap_pipe3_dpll_lock(struct omap_pipe3 *phy)
struct pipe3_dpll_params *dpll_params;
rate = clk_get_rate(phy->sys_clk);
- dpll_params = omap_pipe3_get_dpll_params(rate);
+ dpll_params = omap_pipe3_get_dpll_params(phy);
if (!dpll_params) {
- dev_err(phy->dev,
- "No DPLL configuration for %lu Hz SYS CLK\n", rate);
return -EINVAL;
}
@@ -206,6 +216,25 @@ static struct phy_ops ops = {
.owner = THIS_MODULE,
};
+#ifdef CONFIG_OF
+static const struct of_device_id omap_pipe3_id_table[] = {
+ {
+ .compatible = "ti,omap-pipe3",
+ .data = dpll_map_usb,
+ },
+ {
+ .compatible = "ti,omap-sata",
+ .data = dpll_map_sata,
+ },
+ {
+ .compatible = "ti,omap-usb3",
+ .data = dpll_map_usb,
+ },
+ {},
+};
+MODULE_DEVICE_TABLE(of, omap_pipe3_id_table);
+#endif
+
static int omap_pipe3_probe(struct platform_device *pdev)
{
struct omap_pipe3 *phy;
@@ -215,9 +244,7 @@ static int omap_pipe3_probe(struct platform_device *pdev)
struct device_node *node = pdev->dev.of_node;
struct device_node *control_node;
struct platform_device *control_pdev;
-
- if (!node)
- return -EINVAL;
+ const struct of_device_id *match;
phy = devm_kzalloc(&pdev->dev, sizeof(*phy), GFP_KERNEL);
if (!phy) {
@@ -225,6 +252,16 @@ static int omap_pipe3_probe(struct platform_device *pdev)
return -ENOMEM;
}
+ match = of_match_device(of_match_ptr(omap_pipe3_id_table), &pdev->dev);
+ if (!match)
+ return -EINVAL;
+
+ phy->dpll_map = (struct pipe3_dpll_map *)match->data;
+ if (!phy->dpll_map) {
+ dev_err(&pdev->dev, "no dpll data\n");
+ return -EINVAL;
+ }
+
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pll_ctrl");
phy->pll_ctrl_base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(phy->pll_ctrl_base))
@@ -354,17 +391,6 @@ static const struct dev_pm_ops omap_pipe3_pm_ops = {
#define DEV_PM_OPS NULL
#endif
-#ifdef CONFIG_OF
-static const struct of_device_id omap_pipe3_id_table[] = {
- { .compatible = "ti,omap-pipe3" },
- { .compatible = "ti,omap-sata" },
- { .compatible = "ti,omap-pcie" },
- { .compatible = "ti,omap-usb3" },
- {}
-};
-MODULE_DEVICE_TABLE(of, omap_pipe3_id_table);
-#endif
-
static struct platform_driver omap_pipe3_driver = {
.probe = omap_pipe3_probe,
.remove = omap_pipe3_remove,
diff --git a/include/linux/phy/omap_pipe3.h b/include/linux/phy/omap_pipe3.h
index 7329056..86825ca 100644
--- a/include/linux/phy/omap_pipe3.h
+++ b/include/linux/phy/omap_pipe3.h
@@ -29,6 +29,11 @@ struct pipe3_dpll_params {
u32 mf;
};
+struct pipe3_dpll_map {
+ unsigned long rate;
+ struct pipe3_dpll_params params;
+};
+
struct omap_pipe3 {
void __iomem *pll_ctrl_base;
struct device *dev;
@@ -36,6 +41,7 @@ struct omap_pipe3 {
struct clk *wkupclk;
struct clk *sys_clk;
struct clk *optclk;
+ struct pipe3_dpll_map *dpll_map;
};
static inline u32 omap_pipe3_readl(void __iomem *addr, unsigned offset)
--
1.7.4.1
next prev parent reply other threads:[~2013-09-19 13:05 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-19 13:05 [RFC PATCH 00/15] Add SATA support for TI OMAP5 and DRA7 SoCs Roger Quadros
2013-09-19 13:05 ` [RFC PATCH 01/15] phy: rename struct omap_control_usb to struct omap_control_phy Roger Quadros
[not found] ` <1379595943-14622-2-git-send-email-rogerq-l0cyMroinI0@public.gmane.org>
2013-09-19 14:25 ` Daniel Mack
2013-09-19 13:05 ` [RFC PATCH 02/15] phy: omap-control: Update DT binding information Roger Quadros
2013-09-19 13:05 ` [RFC PATCH 03/15] ARM: dts: omap5: Add clocks to usb3_phy node Roger Quadros
2013-09-19 13:05 ` Roger Quadros [this message]
2013-09-19 13:05 ` [RFC PATCH 06/15] phy: omap-pipe3: update compatibility string and DT binding Roger Quadros
2013-09-19 13:05 ` [RFC PATCH 07/15] ARM: dts: omap5: Update usb3phy node Roger Quadros
[not found] ` <1379595943-14622-1-git-send-email-rogerq-l0cyMroinI0@public.gmane.org>
2013-09-19 13:05 ` [RFC PATCH 04/15] phy: omap-pipe3: use generic clock names Roger Quadros
2013-09-19 13:05 ` [RFC PATCH 08/15] ata: ahci_platform: Manage SATA PHY Roger Quadros
[not found] ` <1379595943-14622-9-git-send-email-rogerq-l0cyMroinI0@public.gmane.org>
2013-09-22 16:58 ` Tejun Heo
2013-09-22 18:24 ` Sergei Shtylyov
2013-09-22 21:51 ` Tejun Heo
2013-09-23 7:37 ` Roger Quadros
[not found] ` <523FEFC2.801-l0cyMroinI0@public.gmane.org>
2013-09-23 12:59 ` Sergei Shtylyov
2013-09-23 13:59 ` Roger Quadros
2014-02-07 10:33 ` Roger Quadros
2014-02-07 10:39 ` Arnd Bergmann
2014-02-07 10:44 ` Roger Quadros
[not found] ` <20130922215107.GD27616-9pTldWuhBndy/B6EtB590w@public.gmane.org>
2013-09-23 12:53 ` Sergei Shtylyov
[not found] ` <524039E0.2060205-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
2013-09-25 12:16 ` Bartlomiej Zolnierkiewicz
2013-09-22 18:22 ` Sergei Shtylyov
[not found] ` <523F3567.80303-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
2013-09-22 21:48 ` Tejun Heo
2013-09-23 14:10 ` Sergei Shtylyov
2013-09-23 14:12 ` Tejun Heo
2013-09-23 7:42 ` Roger Quadros
2013-09-19 13:05 ` [RFC PATCH 09/15] ata: ti_sata: Add Texas Instruments SATA Wrapper driver Roger Quadros
2013-09-25 12:37 ` Bartlomiej Zolnierkiewicz
2013-09-25 12:49 ` Bartlomiej Zolnierkiewicz
2013-09-25 13:29 ` Roger Quadros
2013-09-19 13:22 ` [RFC PATCH 10/15] ARM: omap5: hwmod: Add ocp2scp3 and sata hwmods Roger Quadros
2013-09-19 13:23 ` [RFC PATCH 11/15] arm: omap5: hwmod: add missing ocp2scp hwmod data Roger Quadros
2013-09-19 13:23 ` [RFC PATCH 12/15] ARM: dts: omap5: add ocp2scp1 address resource Roger Quadros
[not found] ` <1379597019-15294-1-git-send-email-rogerq-l0cyMroinI0@public.gmane.org>
2013-09-19 14:17 ` Sergei Shtylyov
[not found] ` <523B0782.7050501-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
2013-09-20 9:22 ` Roger Quadros
2013-09-19 13:23 ` [RFC PATCH 13/15] arm: dts: omap5: add sata node Roger Quadros
2013-09-19 13:24 ` [RFC PATCH 14/15] ARM: DRA7: hwmod: Add ocp2scp3 and sata hwmods Roger Quadros
2013-09-19 13:24 ` [RFC PATCH 15/15] arm: dts: dra7: add sata node Roger Quadros
[not found] ` <1379597059-15405-1-git-send-email-rogerq-l0cyMroinI0@public.gmane.org>
2013-09-19 14:11 ` Sergei Shtylyov
[not found] ` <523B05FD.7020200-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
2013-09-20 10:19 ` Roger Quadros
2013-09-22 18:45 ` Sergei Shtylyov
2013-09-23 8:24 ` Roger Quadros
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1379595943-14622-6-git-send-email-rogerq@ti.com \
--to=rogerq@ti.com \
--cc=balajitk@ti.com \
--cc=balbi@ti.com \
--cc=bcousson@baylibre.com \
--cc=devicetree@vger.kernel.org \
--cc=kishon@ti.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=tony@atomide.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).