* [PATCH] ata/ahci_platform: Add support for enabling/disabling clock.
@ 2011-06-09 8:58 Viresh Kumar
2011-06-27 11:02 ` viresh kumar
0 siblings, 1 reply; 5+ messages in thread
From: Viresh Kumar @ 2011-06-09 8:58 UTC (permalink / raw)
To: jgarzik, linux-ide
Cc: armando.visconti, shiraz.hashim, vipin.kumar, rajeev-dlh.kumar,
deepak.sikri, vipulkumar.samar, amit.virdi, viresh.kumar,
pratyush.anand, bhupesh.sharma, viresh.linux
On many architectures, drivers are supposed to enable/disable functional clock
of device. This patch adds support for clock enabling/disabling in
ahci_platform.c.
Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
---
drivers/ata/ahci.h | 4 ++++
drivers/ata/ahci_platform.c | 36 +++++++++++++++++++++++++++++++-----
2 files changed, 35 insertions(+), 5 deletions(-)
diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h
index 12c5282..fec6289 100644
--- a/drivers/ata/ahci.h
+++ b/drivers/ata/ahci.h
@@ -35,6 +35,7 @@
#ifndef _AHCI_H
#define _AHCI_H
+#include <linux/clk.h>
#include <linux/libata.h>
/* Enclosure Management Control */
@@ -296,6 +297,9 @@ struct ahci_host_priv {
u32 em_loc; /* enclosure management location */
u32 em_buf_sz; /* EM buffer size in byte */
u32 em_msg_type; /* EM message type */
+#ifdef CONFIG_HAVE_CLK
+ struct clk *clk; /* clk structure, only if HAVE_CLK is defined */
+#endif
};
extern int ahci_ignore_sss;
diff --git a/drivers/ata/ahci_platform.c b/drivers/ata/ahci_platform.c
index 6fef1fa..eaa4053 100644
--- a/drivers/ata/ahci_platform.c
+++ b/drivers/ata/ahci_platform.c
@@ -12,6 +12,7 @@
* any later version.
*/
+#include <linux/clk.h>
#include <linux/kernel.h>
#include <linux/gfp.h>
#include <linux/module.h>
@@ -75,6 +76,20 @@ static int __init ahci_probe(struct platform_device *pdev)
return -ENOMEM;
}
+#ifdef CONFIG_HAVE_CLK
+ hpriv->clk = clk_get(dev, NULL);
+ if (IS_ERR(hpriv->clk)) {
+ dev_err(dev, "Clock not found\n");
+ return PTR_ERR(hpriv->clk);
+ }
+
+ rc = clk_enable(hpriv->clk);
+ if (rc) {
+ dev_err(dev, "clock enable failed");
+ goto free_clk;
+ }
+#endif
+
/*
* Some platforms might need to prepare for mmio region access,
* which could be done in the following init call. So, the mmio
@@ -84,7 +99,7 @@ static int __init ahci_probe(struct platform_device *pdev)
if (pdata && pdata->init) {
rc = pdata->init(dev, hpriv->mmio);
if (rc)
- return rc;
+ goto disable_clk;
}
ahci_save_initial_config(dev, hpriv,
@@ -110,7 +125,7 @@ static int __init ahci_probe(struct platform_device *pdev)
host = ata_host_alloc_pinfo(dev, ppi, n_ports);
if (!host) {
rc = -ENOMEM;
- goto err0;
+ goto pdata_exit;
}
host->private_data = hpriv;
@@ -140,7 +155,7 @@ static int __init ahci_probe(struct platform_device *pdev)
rc = ahci_reset_controller(host);
if (rc)
- goto err0;
+ goto pdata_exit;
ahci_init_controller(host);
ahci_print_info(host, "platform");
@@ -148,12 +163,18 @@ static int __init ahci_probe(struct platform_device *pdev)
rc = ata_host_activate(host, irq, ahci_interrupt, IRQF_SHARED,
&ahci_platform_sht);
if (rc)
- goto err0;
+ goto pdata_exit;
return 0;
-err0:
+pdata_exit:
if (pdata && pdata->exit)
pdata->exit(dev);
+disable_clk:
+#ifdef CONFIG_HAVE_CLK
+ clk_disable(hpriv->clk);
+free_clk:
+ clk_put(hpriv->clk);
+#endif
return rc;
}
@@ -162,12 +183,17 @@ static int __devexit ahci_remove(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct ahci_platform_data *pdata = dev->platform_data;
struct ata_host *host = dev_get_drvdata(dev);
+ struct ahci_host_priv *hpriv = host->private_data;
ata_host_detach(host);
if (pdata && pdata->exit)
pdata->exit(dev);
+#ifdef CONFIG_HAVE_CLK
+ clk_disable(hpriv->clk);
+ clk_put(hpriv->clk);
+#endif
return 0;
}
--
1.7.2.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] ata/ahci_platform: Add support for enabling/disabling clock.
2011-06-09 8:58 [PATCH] ata/ahci_platform: Add support for enabling/disabling clock Viresh Kumar
@ 2011-06-27 11:02 ` viresh kumar
2011-07-23 22:14 ` Jeff Garzik
0 siblings, 1 reply; 5+ messages in thread
From: viresh kumar @ 2011-06-27 11:02 UTC (permalink / raw)
To: jgarzik@pobox.com
Cc: linux-ide@vger.kernel.org, Armando VISCONTI, Shiraz HASHIM,
Vipin KUMAR, Rajeev KUMAR, Deepak SIKRI, Vipul Kumar SAMAR,
Amit VIRDI, Pratyush ANAND, Bhupesh SHARMA,
viresh.linux@gmail.com
On 06/09/2011 02:28 PM, Viresh KUMAR wrote:
> On many architectures, drivers are supposed to enable/disable functional clock
> of device. This patch adds support for clock enabling/disabling in
> ahci_platform.c.
>
> Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
> ---
> drivers/ata/ahci.h | 4 ++++
> drivers/ata/ahci_platform.c | 36 +++++++++++++++++++++++++++++++-----
> 2 files changed, 35 insertions(+), 5 deletions(-)
>
Hi Jeff,
Any inputs on this patch?
--
viresh
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ata/ahci_platform: Add support for enabling/disabling clock.
2011-06-27 11:02 ` viresh kumar
@ 2011-07-23 22:14 ` Jeff Garzik
2011-07-26 3:43 ` viresh kumar
0 siblings, 1 reply; 5+ messages in thread
From: Jeff Garzik @ 2011-07-23 22:14 UTC (permalink / raw)
To: viresh kumar
Cc: linux-ide@vger.kernel.org, Armando VISCONTI, Shiraz HASHIM,
Vipin KUMAR, Rajeev KUMAR, Deepak SIKRI, Vipul Kumar SAMAR,
Amit VIRDI, Pratyush ANAND, Bhupesh SHARMA,
viresh.linux@gmail.com
On 06/27/2011 07:02 AM, viresh kumar wrote:
> On 06/09/2011 02:28 PM, Viresh KUMAR wrote:
>> On many architectures, drivers are supposed to enable/disable functional clock
>> of device. This patch adds support for clock enabling/disabling in
>> ahci_platform.c.
>>
>> Signed-off-by: Viresh Kumar<viresh.kumar@st.com>
>> ---
>> drivers/ata/ahci.h | 4 ++++
>> drivers/ata/ahci_platform.c | 36 +++++++++++++++++++++++++++++++-----
>> 2 files changed, 35 insertions(+), 5 deletions(-)
>>
>
> Hi Jeff,
>
> Any inputs on this patch?
Is it actually -used- somewhere?
It certainly looks straightforward...
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ata/ahci_platform: Add support for enabling/disabling clock.
2011-07-23 22:14 ` Jeff Garzik
@ 2011-07-26 3:43 ` viresh kumar
2011-07-26 3:47 ` Jeff Garzik
0 siblings, 1 reply; 5+ messages in thread
From: viresh kumar @ 2011-07-26 3:43 UTC (permalink / raw)
To: Jeff Garzik
Cc: linux-ide@vger.kernel.org, Armando VISCONTI, Shiraz HASHIM,
Vipin KUMAR, Rajeev KUMAR, Deepak SIKRI, Vipul Kumar SAMAR,
Amit VIRDI, Pratyush ANAND, Bhupesh SHARMA,
viresh.linux@gmail.com
On 07/24/2011 03:44 AM, Jeff Garzik wrote:
> Is it actually -used- somewhere?
>
> It certainly looks straightforward...
Yes, this will be used for SPEAr1340. (Yet to add support for 1340 in mainline)
--
viresh
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ata/ahci_platform: Add support for enabling/disabling clock.
2011-07-26 3:43 ` viresh kumar
@ 2011-07-26 3:47 ` Jeff Garzik
0 siblings, 0 replies; 5+ messages in thread
From: Jeff Garzik @ 2011-07-26 3:47 UTC (permalink / raw)
To: viresh kumar
Cc: linux-ide@vger.kernel.org, Armando VISCONTI, Shiraz HASHIM,
Vipin KUMAR, Rajeev KUMAR, Deepak SIKRI, Vipul Kumar SAMAR,
Amit VIRDI, Pratyush ANAND, Bhupesh SHARMA,
viresh.linux@gmail.com
On 07/25/2011 11:43 PM, viresh kumar wrote:
> On 07/24/2011 03:44 AM, Jeff Garzik wrote:
>> Is it actually -used- somewhere?
>>
>> It certainly looks straightforward...
>
> Yes, this will be used for SPEAr1340. (Yet to add support for 1340 in mainline)
We'll add it when the first user appears...
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-07-26 3:47 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-09 8:58 [PATCH] ata/ahci_platform: Add support for enabling/disabling clock Viresh Kumar
2011-06-27 11:02 ` viresh kumar
2011-07-23 22:14 ` Jeff Garzik
2011-07-26 3:43 ` viresh kumar
2011-07-26 3:47 ` Jeff Garzik
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).