Skip to contentSkip to conversation

arm:davinci: clk - migrate to new common clock API

PATCH In review Mike Turquette 3 participants 7 messages Aug 2, 2012 – Aug 30, 2012 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 arm:davinci: clk - migrate to new common clock API

Quoted 10 lines · Murali Karicheri

As a first step towards migrating davinci platforms to use common clock framework, replace all instances of clk_enable() with clk_prepare_enable() and clk_disable() with clk_disable_unprepare(). Until the platform is switched to use the CONFIG_HAVE_CLK_PREPARE Kconfig variable, this just adds a might_sleep() call and would work without any issues.

This will make it easy later to switch to common clk based implementation of clk driver from DaVinci specific driver.

Murali,

The important thing to know about clk_prepare is that it might sleep. All of the functions below look like initialization functions for code that is never run in interrupt context. If you can confirm that this is true then feel free to add my,

Regards,
Mike

Quoted 154 lines
---
 arch/arm/mach-davinci/board-dm355-evm.c     |    2 +-
 arch/arm/mach-davinci/board-dm355-leopard.c |    2 +-
 arch/arm/mach-davinci/board-dm365-evm.c     |    4 ++--
 arch/arm/mach-davinci/board-dm644x-evm.c    |    2 +-
 arch/arm/mach-davinci/board-neuros-osd2.c   |    2 +-
 arch/arm/mach-davinci/devices-da8xx.c       |    6 +++---
 arch/arm/mach-davinci/serial.c              |    2 +-
 arch/arm/mach-davinci/time.c                |    4 ++--
 8 files changed, 12 insertions(+), 12 deletions(-)
arch/arm/mach-davinci/board-dm355-evm.c +1 -1
index 1c7b1f4..4821fba 100644
@@ -324,7 +324,7 @@ static __init void dm355_evm_init(void)
 	if (IS_ERR(aemif))
 		WARN("%s: unable to get AEMIF clock\n", __func__);
 	else
-		clk_enable(aemif);
+		clk_prepare_enable(aemif);
 
 	platform_add_devices(davinci_evm_devices,
 			     ARRAY_SIZE(davinci_evm_devices));
arch/arm/mach-davinci/board-dm355-leopard.c +1 -1
index 8e77032..b754ccf 100644
@@ -246,7 +246,7 @@ static __init void dm355_leopard_init(void)
 	if (IS_ERR(aemif))
 		WARN("%s: unable to get AEMIF clock\n", __func__);
 	else
-		clk_enable(aemif);
+		clk_prepare_enable(aemif);
 
 	platform_add_devices(davinci_leopard_devices,
 			     ARRAY_SIZE(davinci_leopard_devices));
arch/arm/mach-davinci/board-dm365-evm.c +2 -2
index 2830692..3a4743b 100644
@@ -481,7 +481,7 @@ static void __init evm_init_cpld(void)
 	aemif_clk = clk_get(NULL, "aemif");
 	if (IS_ERR(aemif_clk))
 		return;
-	clk_enable(aemif_clk);
+	clk_prepare_enable(aemif_clk);
 
 	if (request_mem_region(DM365_ASYNC_EMIF_DATA_CE1_BASE, SECTION_SIZE,
 			"cpld") == NULL)
@@ -492,7 +492,7 @@ static void __init evm_init_cpld(void)
 				SECTION_SIZE);
 fail:
 		pr_err("ERROR: can't map CPLD\n");
-		clk_disable(aemif_clk);
+		clk_disable_unprepare(aemif_clk);
 		return;
 	}
 
arch/arm/mach-davinci/board-dm644x-evm.c +1 -1
index d34ed55..04ef708 100644
@@ -775,7 +775,7 @@ static __init void davinci_evm_init(void)
 	struct davinci_soc_info *soc_info = &davinci_soc_info;
 
 	aemif_clk = clk_get(NULL, "aemif");
-	clk_enable(aemif_clk);
+	clk_prepare_enable(aemif_clk);
 
 	if (HAS_ATA) {
 		if (HAS_NAND || HAS_NOR)
arch/arm/mach-davinci/board-neuros-osd2.c +1 -1
index 5de69f2..7fdd0a7b 100644
@@ -221,7 +221,7 @@ static __init void davinci_ntosd2_init(void)
 	int	status;
 
 	aemif_clk = clk_get(NULL, "aemif");
-	clk_enable(aemif_clk);
+	clk_prepare_enable(aemif_clk);
 
 	if (HAS_ATA) {
 		if (HAS_NAND)
arch/arm/mach-davinci/devices-da8xx.c +3 -3
index d1624a3..20141f5 100644
@@ -905,7 +905,7 @@ static int da850_sata_init(struct device *dev, void __iomem *addr)
 	if (IS_ERR(da850_sata_clk))
 		return PTR_ERR(da850_sata_clk);
 
-	ret = clk_enable(da850_sata_clk);
+	ret = clk_prepare_enable(da850_sata_clk);
 	if (ret)
 		goto err0;
 
@@ -936,7 +936,7 @@ static int da850_sata_init(struct device *dev, void __iomem *addr)
 	return 0;
 
 err1:
-	clk_disable(da850_sata_clk);
+	clk_disable_unprepare(da850_sata_clk);
 err0:
 	clk_put(da850_sata_clk);
 	return ret;
@@ -944,7 +944,7 @@ err0:
 
 static void da850_sata_exit(struct device *dev)
 {
-	clk_disable(da850_sata_clk);
+	clk_disable_unprepare(da850_sata_clk);
 	clk_put(da850_sata_clk);
 }
 
arch/arm/mach-davinci/serial.c +1 -1
index 1875740..24ddb0d 100644
@@ -95,7 +95,7 @@ int __init davinci_serial_init(struct davinci_uart_config *info)
 			continue;
 		}
 
-		clk_enable(uart_clk);
+		clk_prepare_enable(uart_clk);
 		p->uartclk = clk_get_rate(uart_clk);
 
 		if (!p->membase && p->mapbase) {
arch/arm/mach-davinci/time.c +2 -2
index 75da315..9847938 100644
@@ -379,7 +379,7 @@ static void __init davinci_timer_init(void)
 
 	timer_clk = clk_get(NULL, "timer0");
 	BUG_ON(IS_ERR(timer_clk));
-	clk_enable(timer_clk);
+	clk_prepare_enable(timer_clk);
 
 	/* init timer hw */
 	timer_init();
@@ -429,7 +429,7 @@ void davinci_watchdog_reset(struct platform_device *pdev)
 	wd_clk = clk_get(&pdev->dev, NULL);
 	if (WARN_ON(IS_ERR(wd_clk)))
 		return;
-	clk_enable(wd_clk);
+	clk_prepare_enable(wd_clk);
 
 	/* disable, internal clock source */
 	__raw_writel(0, base + TCR);
Signature · 1 line
1.7.9.5
#2 lore raw
Quoted 23 lines
Quoted 23 lines

-----Original Message-----
From: Turquette, Mike
Sent: Thursday, August 02, 2012 5:20 PM
To: Karicheri, Muralidharan
Cc: linux-arm-kernel at lists.infradead.org; davinci-linux-open-
source at linux.davincidsp.com; linux-keystone at list.ti.com - Linux developers for Keystone family of devices (May contain non-TIers); Chemparathy, Cyril; Nori, Sekhar; linux at arm.linux.org.uk
Subject: [linux-keystone] Re: [PATCH] arm:davinci: clk - migrate to new common clock API

Quoted 10 lines · Murali Karicheri

As a first step towards migrating davinci platforms to use common clock framework, replace all instances of clk_enable() with clk_prepare_enable() and clk_disable() with clk_disable_unprepare(). Until the platform is switched to use the CONFIG_HAVE_CLK_PREPARE Kconfig variable, this just adds a might_sleep() call and would work without any issues.

This will make it easy later to switch to common clk based implementation of clk driver from DaVinci specific driver.

Quoted 7 lines
Quoted 7 lines

Murali,

The important thing to know about clk_prepare is that it might sleep. All of the functions below look like initialization functions for code that is never run in interrupt context. If you can confirm that this is true then feel free to add my,

Mike,

I believe they are. I will double check and then post the patch again. If they are called under interrupt context, basically I need to make two API calls instead as below right?

clk_prepare()
clk_enable()

Murali Karicheri
Software Design Engineer

Quoted 167 lines
Quoted 167 lines

Regards,
Mike

arch/arm/mach-

Quoted 12 lines
---
 arch/arm/mach-davinci/board-dm355-evm.c     |    2 +-
 arch/arm/mach-davinci/board-dm355-leopard.c |    2 +-
 arch/arm/mach-davinci/board-dm365-evm.c     |    4 ++--
 arch/arm/mach-davinci/board-dm644x-evm.c    |    2 +-
 arch/arm/mach-davinci/board-neuros-osd2.c   |    2 +-
 arch/arm/mach-davinci/devices-da8xx.c       |    6 +++---
 arch/arm/mach-davinci/serial.c              |    2 +-
 arch/arm/mach-davinci/time.c                |    4 ++--
 8 files changed, 12 insertions(+), 12 deletions(-)
arch/arm/mach- renamed from arch/arm/mach-davinci/board-dm355-evm.c +0 -0

davinci/board-dm355-evm.c

arch/arm/mach-

Quoted 13 lines

index 1c7b1f4..4821fba 100644

arch/arm/mach-davinci/board-dm355-evm.c +1 -1
@@ -324,7 +324,7 @@ static __init void dm355_evm_init(void)
 	if (IS_ERR(aemif))
 		WARN("%s: unable to get AEMIF clock\n", __func__);
 	else
-		clk_enable(aemif);
+		clk_prepare_enable(aemif);
 
 	platform_add_devices(davinci_evm_devices,
 			     ARRAY_SIZE(davinci_evm_devices));
arch/arm/mach- renamed from arch/arm/mach-davinci/board-dm355-leopard.c +0 -0

davinci/board-dm355-leopard.c

arch/arm/mach-

Quoted 13 lines

index 8e77032..b754ccf 100644

arch/arm/mach-davinci/board-dm355-leopard.c +1 -1
@@ -246,7 +246,7 @@ static __init void dm355_leopard_init(void)
 	if (IS_ERR(aemif))
 		WARN("%s: unable to get AEMIF clock\n", __func__);
 	else
-		clk_enable(aemif);
+		clk_prepare_enable(aemif);
 
 	platform_add_devices(davinci_leopard_devices,
 			     ARRAY_SIZE(davinci_leopard_devices));
arch/arm/mach- renamed from arch/arm/mach-davinci/board-dm365-evm.c +0 -0

davinci/board-dm365-evm.c

arch/arm/mach-

Quoted 22 lines

index 2830692..3a4743b 100644

arch/arm/mach-davinci/board-dm365-evm.c +2 -2
@@ -481,7 +481,7 @@ static void __init evm_init_cpld(void)
 	aemif_clk = clk_get(NULL, "aemif");
 	if (IS_ERR(aemif_clk))
 		return;
-	clk_enable(aemif_clk);
+	clk_prepare_enable(aemif_clk);
 
 	if (request_mem_region(DM365_ASYNC_EMIF_DATA_CE1_BASE, SECTION_SIZE,
 			"cpld") == NULL)
@@ -492,7 +492,7 @@ static void __init evm_init_cpld(void)
 				SECTION_SIZE);
 fail:
 		pr_err("ERROR: can't map CPLD\n");
-		clk_disable(aemif_clk);
+		clk_disable_unprepare(aemif_clk);
 		return;
 	}
 
arch/arm/mach- renamed from arch/arm/mach-davinci/board-dm644x-evm.c +0 -0

davinci/board-dm644x-evm.c

arch/arm/mach-

Quoted 13 lines

index d34ed55..04ef708 100644

arch/arm/mach-davinci/board-dm644x-evm.c +1 -1
@@ -775,7 +775,7 @@ static __init void davinci_evm_init(void)
 	struct davinci_soc_info *soc_info = &davinci_soc_info;
 
 	aemif_clk = clk_get(NULL, "aemif");
-	clk_enable(aemif_clk);
+	clk_prepare_enable(aemif_clk);
 
 	if (HAS_ATA) {
 		if (HAS_NAND || HAS_NOR)
arch/arm/mach- renamed from arch/arm/mach-davinci/board-neuros-osd2.c +0 -0

davinci/board-neuros-osd2.c

arch/arm/mach-davinci/devices-

Quoted 13 lines

index 5de69f2..7fdd0a7b 100644

arch/arm/mach-davinci/board-neuros-osd2.c +1 -1
@@ -221,7 +221,7 @@ static __init void davinci_ntosd2_init(void)
 	int	status;
 
 	aemif_clk = clk_get(NULL, "aemif");
-	clk_enable(aemif_clk);
+	clk_prepare_enable(aemif_clk);
 
 	if (HAS_ATA) {
 		if (HAS_NAND)
arch/arm/mach-davinci/devices- renamed from arch/arm/mach-davinci/devices-da8xx.c +0 -0

da8xx.c

arch/arm/mach-davinci/devices-da8xx.c static int da850_sata_init(struct device *dev, void __iomem

Quoted 4 lines

index d1624a3..20141f5 100644

arch/arm/mach-davinci/devices-da8xx.c +0 -0
@@ -905,7 +905,7 @@ static int da850_sata_init(struct device *dev, void __iomem

*addr)

arch/arm/mach-davinci/devices-da8xx.c static int da850_sata_init(struct device *dev, void __iomem

Quoted 9 lines
arch/arm/mach-davinci/devices-da8xx.c +1 -1
 	if (IS_ERR(da850_sata_clk))
 		return PTR_ERR(da850_sata_clk);
 
-	ret = clk_enable(da850_sata_clk);
+	ret = clk_prepare_enable(da850_sata_clk);
 	if (ret)
 		goto err0;
 
@@ -936,7 +936,7 @@ static int da850_sata_init(struct device *dev, void __iomem

*addr)

Quoted 55 lines
arch/arm/mach-davinci/devices-da8xx.c +2 -2
 	return 0;
 
 err1:
-	clk_disable(da850_sata_clk);
+	clk_disable_unprepare(da850_sata_clk);
 err0:
 	clk_put(da850_sata_clk);
 	return ret;
@@ -944,7 +944,7 @@ err0:
 
 static void da850_sata_exit(struct device *dev)
 {
-	clk_disable(da850_sata_clk);
+	clk_disable_unprepare(da850_sata_clk);
 	clk_put(da850_sata_clk);
 }
 
arch/arm/mach-davinci/serial.c +1 -1
index 1875740..24ddb0d 100644
@@ -95,7 +95,7 @@ int __init davinci_serial_init(struct davinci_uart_config *info)
 			continue;
 		}
 
-		clk_enable(uart_clk);
+		clk_prepare_enable(uart_clk);
 		p->uartclk = clk_get_rate(uart_clk);
 
 		if (!p->membase && p->mapbase) {
arch/arm/mach-davinci/time.c +2 -3
index 75da315..9847938 100644
@@ -379,7 +379,7 @@ static void __init davinci_timer_init(void)
 
 	timer_clk = clk_get(NULL, "timer0");
 	BUG_ON(IS_ERR(timer_clk));
-	clk_enable(timer_clk);
+	clk_prepare_enable(timer_clk);
 
 	/* init timer hw */
 	timer_init();
@@ -429,7 +429,7 @@ void davinci_watchdog_reset(struct platform_device *pdev)
 	wd_clk = clk_get(&pdev->dev, NULL);
 	if (WARN_ON(IS_ERR(wd_clk)))
 		return;
-	clk_enable(wd_clk);
+	clk_prepare_enable(wd_clk);
 
 	/* disable, internal clock source */
 	__raw_writel(0, base + TCR);
--

1.7.9.5

#3 lore raw
Quoted 31 lines · Muralidharan
Quoted 23 lines
Quoted 23 lines

-----Original Message-----
From: Turquette, Mike
Sent: Thursday, August 02, 2012 5:20 PM
To: Karicheri, Muralidharan
Cc: linux-arm-kernel at lists.infradead.org; davinci-linux-open-
source at linux.davincidsp.com; linux-keystone at list.ti.com - Linux developers for Keystone family of devices (May contain non-TIers); Chemparathy, Cyril; Nori, Sekhar; linux at arm.linux.org.uk
Subject: [linux-keystone] Re: [PATCH] arm:davinci: clk - migrate to new common clock API

Quoted 10 lines · Murali Karicheri

As a first step towards migrating davinci platforms to use common clock framework, replace all instances of clk_enable() with clk_prepare_enable() and clk_disable() with clk_disable_unprepare(). Until the platform is switched to use the CONFIG_HAVE_CLK_PREPARE Kconfig variable, this just adds a might_sleep() call and would work without any issues.

This will make it easy later to switch to common clk based implementation of clk driver from DaVinci specific driver.

Quoted 7 lines
Quoted 7 lines

Murali,

The important thing to know about clk_prepare is that it might sleep. All of the functions below look like initialization functions for code that is never run in interrupt context. If you can confirm that this is true then feel free to add my,

Quoted 8 lines

Mike,

I believe they are. I will double check and then post the patch again. If they are called under interrupt context, basically I need to make two API calls instead as below right?

clk_prepare()
clk_enable()

This is correct. You must insure that clk_prepare is called (and will complete) before clk_enable is called. clk_prepare must be run from process context. It is still OK to call clk_enable/clk_disable from interrupt context as needed.

Regards,
Mike

Quoted 171 lines

Murali Karicheri
Software Design Engineer

Quoted 167 lines
Quoted 167 lines

Regards,
Mike

arch/arm/mach-

Quoted 12 lines
---
 arch/arm/mach-davinci/board-dm355-evm.c     |    2 +-
 arch/arm/mach-davinci/board-dm355-leopard.c |    2 +-
 arch/arm/mach-davinci/board-dm365-evm.c     |    4 ++--
 arch/arm/mach-davinci/board-dm644x-evm.c    |    2 +-
 arch/arm/mach-davinci/board-neuros-osd2.c   |    2 +-
 arch/arm/mach-davinci/devices-da8xx.c       |    6 +++---
 arch/arm/mach-davinci/serial.c              |    2 +-
 arch/arm/mach-davinci/time.c                |    4 ++--
 8 files changed, 12 insertions(+), 12 deletions(-)
arch/arm/mach- renamed from arch/arm/mach-davinci/board-dm355-evm.c +0 -0

davinci/board-dm355-evm.c

arch/arm/mach-

Quoted 13 lines

index 1c7b1f4..4821fba 100644

arch/arm/mach-davinci/board-dm355-evm.c +1 -1
@@ -324,7 +324,7 @@ static __init void dm355_evm_init(void)
   if (IS_ERR(aemif))
           WARN("%s: unable to get AEMIF clock\n", __func__);
   else
-          clk_enable(aemif);
+          clk_prepare_enable(aemif);
 
   platform_add_devices(davinci_evm_devices,
                        ARRAY_SIZE(davinci_evm_devices));
arch/arm/mach- renamed from arch/arm/mach-davinci/board-dm355-leopard.c +0 -0

davinci/board-dm355-leopard.c

arch/arm/mach-

Quoted 13 lines

index 8e77032..b754ccf 100644

arch/arm/mach-davinci/board-dm355-leopard.c +1 -1
@@ -246,7 +246,7 @@ static __init void dm355_leopard_init(void)
   if (IS_ERR(aemif))
           WARN("%s: unable to get AEMIF clock\n", __func__);
   else
-          clk_enable(aemif);
+          clk_prepare_enable(aemif);
 
   platform_add_devices(davinci_leopard_devices,
                        ARRAY_SIZE(davinci_leopard_devices));
arch/arm/mach- renamed from arch/arm/mach-davinci/board-dm365-evm.c +0 -0

davinci/board-dm365-evm.c

arch/arm/mach-

Quoted 22 lines

index 2830692..3a4743b 100644

arch/arm/mach-davinci/board-dm365-evm.c +2 -2
@@ -481,7 +481,7 @@ static void __init evm_init_cpld(void)
   aemif_clk = clk_get(NULL, "aemif");
   if (IS_ERR(aemif_clk))
           return;
-  clk_enable(aemif_clk);
+  clk_prepare_enable(aemif_clk);
 
   if (request_mem_region(DM365_ASYNC_EMIF_DATA_CE1_BASE, SECTION_SIZE,
                   "cpld") == NULL)
@@ -492,7 +492,7 @@ static void __init evm_init_cpld(void)
                           SECTION_SIZE);
 fail:
           pr_err("ERROR: can't map CPLD\n");
-          clk_disable(aemif_clk);
+          clk_disable_unprepare(aemif_clk);
           return;
   }
 
arch/arm/mach- renamed from arch/arm/mach-davinci/board-dm644x-evm.c +0 -0

davinci/board-dm644x-evm.c

arch/arm/mach-

Quoted 13 lines

index d34ed55..04ef708 100644

arch/arm/mach-davinci/board-dm644x-evm.c +1 -1
@@ -775,7 +775,7 @@ static __init void davinci_evm_init(void)
   struct davinci_soc_info *soc_info = &davinci_soc_info;
 
   aemif_clk = clk_get(NULL, "aemif");
-  clk_enable(aemif_clk);
+  clk_prepare_enable(aemif_clk);
 
   if (HAS_ATA) {
           if (HAS_NAND || HAS_NOR)
arch/arm/mach- renamed from arch/arm/mach-davinci/board-neuros-osd2.c +0 -0

davinci/board-neuros-osd2.c

arch/arm/mach-davinci/devices-

Quoted 13 lines

index 5de69f2..7fdd0a7b 100644

arch/arm/mach-davinci/board-neuros-osd2.c +1 -1
@@ -221,7 +221,7 @@ static __init void davinci_ntosd2_init(void)
   int     status;
 
   aemif_clk = clk_get(NULL, "aemif");
-  clk_enable(aemif_clk);
+  clk_prepare_enable(aemif_clk);
 
   if (HAS_ATA) {
           if (HAS_NAND)
arch/arm/mach-davinci/devices- renamed from arch/arm/mach-davinci/devices-da8xx.c +0 -0

da8xx.c

arch/arm/mach-davinci/devices-da8xx.c static int da850_sata_init(struct device *dev, void __iomem

Quoted 4 lines

index d1624a3..20141f5 100644

arch/arm/mach-davinci/devices-da8xx.c +0 -0
@@ -905,7 +905,7 @@ static int da850_sata_init(struct device *dev, void __iomem

*addr)

arch/arm/mach-davinci/devices-da8xx.c static int da850_sata_init(struct device *dev, void __iomem

Quoted 9 lines
arch/arm/mach-davinci/devices-da8xx.c +1 -1
   if (IS_ERR(da850_sata_clk))
           return PTR_ERR(da850_sata_clk);
 
-  ret = clk_enable(da850_sata_clk);
+  ret = clk_prepare_enable(da850_sata_clk);
   if (ret)
           goto err0;
 
@@ -936,7 +936,7 @@ static int da850_sata_init(struct device *dev, void __iomem

*addr)

Quoted 55 lines
arch/arm/mach-davinci/devices-da8xx.c +2 -2
   return 0;
 
 err1:
-  clk_disable(da850_sata_clk);
+  clk_disable_unprepare(da850_sata_clk);
 err0:
   clk_put(da850_sata_clk);
   return ret;
@@ -944,7 +944,7 @@ err0:
 
 static void da850_sata_exit(struct device *dev)
 {
-  clk_disable(da850_sata_clk);
+  clk_disable_unprepare(da850_sata_clk);
   clk_put(da850_sata_clk);
 }
 
arch/arm/mach-davinci/serial.c +1 -1
index 1875740..24ddb0d 100644
@@ -95,7 +95,7 @@ int __init davinci_serial_init(struct davinci_uart_config *info)
                   continue;
           }
 
-          clk_enable(uart_clk);
+          clk_prepare_enable(uart_clk);
           p->uartclk = clk_get_rate(uart_clk);
 
           if (!p->membase && p->mapbase) {
arch/arm/mach-davinci/time.c +2 -3
index 75da315..9847938 100644
@@ -379,7 +379,7 @@ static void __init davinci_timer_init(void)
 
   timer_clk = clk_get(NULL, "timer0");
   BUG_ON(IS_ERR(timer_clk));
-  clk_enable(timer_clk);
+  clk_prepare_enable(timer_clk);
 
   /* init timer hw */
   timer_init();
@@ -429,7 +429,7 @@ void davinci_watchdog_reset(struct platform_device *pdev)
   wd_clk = clk_get(&pdev->dev, NULL);
   if (WARN_ON(IS_ERR(wd_clk)))
           return;
-  clk_enable(wd_clk);
+  clk_prepare_enable(wd_clk);
 
   /* disable, internal clock source */
   __raw_writel(0, base + TCR);
--

1.7.9.5

#4 lore raw

PATCH 1/1 arm:davinci: clk - migrate to new common clock API

In reply to a message not in the archive
Quoted 10 lines · Murali Karicheri

As a first step towards migrating davinci platforms to use common clock framework, replace all instances of clk_enable() with clk_prepare_enable() and clk_disable() with clk_disable_unprepare(). Until the platform is switched to use the CONFIG_HAVE_CLK_PREPARE Kconfig variable, this just adds a might_sleep() call and would work without any issues.

This will make it easy later to switch to common clk based implementation of clk driver from DaVinci specific driver.

Murali,

The patch $subject is a bit misleading. This patch is preparation for converting davinci over to the common clk framework. How about:

arm: davinci: clk: call clk_prepare_enable

Also, the important thing to know about clk_prepare is that it might sleep. All of the functions below look like initialization functions for code that is never run in interrupt context. If you can confirm that this is true then feel free to add my,

Regards,
Mike

Quoted 154 lines
---
 arch/arm/mach-davinci/board-dm355-evm.c     |    2 +-
 arch/arm/mach-davinci/board-dm355-leopard.c |    2 +-
 arch/arm/mach-davinci/board-dm365-evm.c     |    4 ++--
 arch/arm/mach-davinci/board-dm644x-evm.c    |    2 +-
 arch/arm/mach-davinci/board-neuros-osd2.c   |    2 +-
 arch/arm/mach-davinci/devices-da8xx.c       |    6 +++---
 arch/arm/mach-davinci/serial.c              |    2 +-
 arch/arm/mach-davinci/time.c                |    4 ++--
 8 files changed, 12 insertions(+), 12 deletions(-)
arch/arm/mach-davinci/board-dm355-evm.c +1 -1
index 1c7b1f4..4821fba 100644
@@ -324,7 +324,7 @@ static __init void dm355_evm_init(void)
 	if (IS_ERR(aemif))
 		WARN("%s: unable to get AEMIF clock\n", __func__);
 	else
-		clk_enable(aemif);
+		clk_prepare_enable(aemif);
 
 	platform_add_devices(davinci_evm_devices,
 			     ARRAY_SIZE(davinci_evm_devices));
arch/arm/mach-davinci/board-dm355-leopard.c +1 -1
index 8e77032..b754ccf 100644
@@ -246,7 +246,7 @@ static __init void dm355_leopard_init(void)
 	if (IS_ERR(aemif))
 		WARN("%s: unable to get AEMIF clock\n", __func__);
 	else
-		clk_enable(aemif);
+		clk_prepare_enable(aemif);
 
 	platform_add_devices(davinci_leopard_devices,
 			     ARRAY_SIZE(davinci_leopard_devices));
arch/arm/mach-davinci/board-dm365-evm.c +2 -2
index 2830692..3a4743b 100644
@@ -481,7 +481,7 @@ static void __init evm_init_cpld(void)
 	aemif_clk = clk_get(NULL, "aemif");
 	if (IS_ERR(aemif_clk))
 		return;
-	clk_enable(aemif_clk);
+	clk_prepare_enable(aemif_clk);
 
 	if (request_mem_region(DM365_ASYNC_EMIF_DATA_CE1_BASE, SECTION_SIZE,
 			"cpld") == NULL)
@@ -492,7 +492,7 @@ static void __init evm_init_cpld(void)
 				SECTION_SIZE);
 fail:
 		pr_err("ERROR: can't map CPLD\n");
-		clk_disable(aemif_clk);
+		clk_disable_unprepare(aemif_clk);
 		return;
 	}
 
arch/arm/mach-davinci/board-dm644x-evm.c +1 -1
index d34ed55..04ef708 100644
@@ -775,7 +775,7 @@ static __init void davinci_evm_init(void)
 	struct davinci_soc_info *soc_info = &davinci_soc_info;
 
 	aemif_clk = clk_get(NULL, "aemif");
-	clk_enable(aemif_clk);
+	clk_prepare_enable(aemif_clk);
 
 	if (HAS_ATA) {
 		if (HAS_NAND || HAS_NOR)
arch/arm/mach-davinci/board-neuros-osd2.c +1 -1
index 5de69f2..7fdd0a7b 100644
@@ -221,7 +221,7 @@ static __init void davinci_ntosd2_init(void)
 	int	status;
 
 	aemif_clk = clk_get(NULL, "aemif");
-	clk_enable(aemif_clk);
+	clk_prepare_enable(aemif_clk);
 
 	if (HAS_ATA) {
 		if (HAS_NAND)
arch/arm/mach-davinci/devices-da8xx.c +3 -3
index d1624a3..20141f5 100644
@@ -905,7 +905,7 @@ static int da850_sata_init(struct device *dev, void __iomem *addr)
 	if (IS_ERR(da850_sata_clk))
 		return PTR_ERR(da850_sata_clk);
 
-	ret = clk_enable(da850_sata_clk);
+	ret = clk_prepare_enable(da850_sata_clk);
 	if (ret)
 		goto err0;
 
@@ -936,7 +936,7 @@ static int da850_sata_init(struct device *dev, void __iomem *addr)
 	return 0;
 
 err1:
-	clk_disable(da850_sata_clk);
+	clk_disable_unprepare(da850_sata_clk);
 err0:
 	clk_put(da850_sata_clk);
 	return ret;
@@ -944,7 +944,7 @@ err0:
 
 static void da850_sata_exit(struct device *dev)
 {
-	clk_disable(da850_sata_clk);
+	clk_disable_unprepare(da850_sata_clk);
 	clk_put(da850_sata_clk);
 }
 
arch/arm/mach-davinci/serial.c +1 -1
index 1875740..24ddb0d 100644
@@ -95,7 +95,7 @@ int __init davinci_serial_init(struct davinci_uart_config *info)
 			continue;
 		}
 
-		clk_enable(uart_clk);
+		clk_prepare_enable(uart_clk);
 		p->uartclk = clk_get_rate(uart_clk);
 
 		if (!p->membase && p->mapbase) {
arch/arm/mach-davinci/time.c +2 -2
index 75da315..9847938 100644
@@ -379,7 +379,7 @@ static void __init davinci_timer_init(void)
 
 	timer_clk = clk_get(NULL, "timer0");
 	BUG_ON(IS_ERR(timer_clk));
-	clk_enable(timer_clk);
+	clk_prepare_enable(timer_clk);
 
 	/* init timer hw */
 	timer_init();
@@ -429,7 +429,7 @@ void davinci_watchdog_reset(struct platform_device *pdev)
 	wd_clk = clk_get(&pdev->dev, NULL);
 	if (WARN_ON(IS_ERR(wd_clk)))
 		return;
-	clk_enable(wd_clk);
+	clk_prepare_enable(wd_clk);
 
 	/* disable, internal clock source */
 	__raw_writel(0, base + TCR);
Signature · 1 line
1.7.9.5
#5 lore raw

PATCH 1/1 arm:davinci: clk - migrate to new common clock API

Quoted 22 lines
Quoted 22 lines

-----Original Message-----
From: Turquette, Mike
Sent: Thursday, August 02, 2012 5:28 PM
To: Karicheri, Muralidharan
Cc: linux-arm-kernel at lists.infradead.org; davinci-linux-open-
source at linux.davincidsp.com; linux-keystone at list.ti.com - Linux developers for Keystone family of devices (May contain non-TIers); Chemparathy, Cyril; Nori, Sekhar; linux at arm.linux.org.uk
Subject: Re: [PATCH] arm:davinci: clk - migrate to new common clock API

Quoted 10 lines · Murali Karicheri

As a first step towards migrating davinci platforms to use common clock framework, replace all instances of clk_enable() with clk_prepare_enable() and clk_disable() with clk_disable_unprepare(). Until the platform is switched to use the CONFIG_HAVE_CLK_PREPARE Kconfig variable, this just adds a might_sleep() call and would work without any issues.

This will make it easy later to switch to common clk based implementation of clk driver from DaVinci specific driver.

Quoted 7 lines
Quoted 7 lines

Murali,

The patch $subject is a bit misleading. This patch is preparation for converting davinci over to the common clk framework. How about:

arm: davinci: clk: call clk_prepare_enable

Ok

Quoted 5 lines
Quoted 5 lines

Also, the important thing to know about clk_prepare is that it might sleep. All of the functions below look like initialization functions for code that is never run in interrupt context. If you can confirm that this is true then feel free to add my,

Will investigate and repost as appropriate.

Murali Karicheri
Software Design Engineer

Quoted 167 lines
Quoted 167 lines

Regards,
Mike

arch/arm/mach-

Quoted 12 lines
---
 arch/arm/mach-davinci/board-dm355-evm.c     |    2 +-
 arch/arm/mach-davinci/board-dm355-leopard.c |    2 +-
 arch/arm/mach-davinci/board-dm365-evm.c     |    4 ++--
 arch/arm/mach-davinci/board-dm644x-evm.c    |    2 +-
 arch/arm/mach-davinci/board-neuros-osd2.c   |    2 +-
 arch/arm/mach-davinci/devices-da8xx.c       |    6 +++---
 arch/arm/mach-davinci/serial.c              |    2 +-
 arch/arm/mach-davinci/time.c                |    4 ++--
 8 files changed, 12 insertions(+), 12 deletions(-)
arch/arm/mach- renamed from arch/arm/mach-davinci/board-dm355-evm.c +0 -0

davinci/board-dm355-evm.c

arch/arm/mach-

Quoted 13 lines

index 1c7b1f4..4821fba 100644

arch/arm/mach-davinci/board-dm355-evm.c +1 -1
@@ -324,7 +324,7 @@ static __init void dm355_evm_init(void)
 	if (IS_ERR(aemif))
 		WARN("%s: unable to get AEMIF clock\n", __func__);
 	else
-		clk_enable(aemif);
+		clk_prepare_enable(aemif);
 
 	platform_add_devices(davinci_evm_devices,
 			     ARRAY_SIZE(davinci_evm_devices));
arch/arm/mach- renamed from arch/arm/mach-davinci/board-dm355-leopard.c +0 -0

davinci/board-dm355-leopard.c

arch/arm/mach-

Quoted 13 lines

index 8e77032..b754ccf 100644

arch/arm/mach-davinci/board-dm355-leopard.c +1 -1
@@ -246,7 +246,7 @@ static __init void dm355_leopard_init(void)
 	if (IS_ERR(aemif))
 		WARN("%s: unable to get AEMIF clock\n", __func__);
 	else
-		clk_enable(aemif);
+		clk_prepare_enable(aemif);
 
 	platform_add_devices(davinci_leopard_devices,
 			     ARRAY_SIZE(davinci_leopard_devices));
arch/arm/mach- renamed from arch/arm/mach-davinci/board-dm365-evm.c +0 -0

davinci/board-dm365-evm.c

arch/arm/mach-

Quoted 22 lines

index 2830692..3a4743b 100644

arch/arm/mach-davinci/board-dm365-evm.c +2 -2
@@ -481,7 +481,7 @@ static void __init evm_init_cpld(void)
 	aemif_clk = clk_get(NULL, "aemif");
 	if (IS_ERR(aemif_clk))
 		return;
-	clk_enable(aemif_clk);
+	clk_prepare_enable(aemif_clk);
 
 	if (request_mem_region(DM365_ASYNC_EMIF_DATA_CE1_BASE, SECTION_SIZE,
 			"cpld") == NULL)
@@ -492,7 +492,7 @@ static void __init evm_init_cpld(void)
 				SECTION_SIZE);
 fail:
 		pr_err("ERROR: can't map CPLD\n");
-		clk_disable(aemif_clk);
+		clk_disable_unprepare(aemif_clk);
 		return;
 	}
 
arch/arm/mach- renamed from arch/arm/mach-davinci/board-dm644x-evm.c +0 -0

davinci/board-dm644x-evm.c

arch/arm/mach-

Quoted 13 lines

index d34ed55..04ef708 100644

arch/arm/mach-davinci/board-dm644x-evm.c +1 -1
@@ -775,7 +775,7 @@ static __init void davinci_evm_init(void)
 	struct davinci_soc_info *soc_info = &davinci_soc_info;
 
 	aemif_clk = clk_get(NULL, "aemif");
-	clk_enable(aemif_clk);
+	clk_prepare_enable(aemif_clk);
 
 	if (HAS_ATA) {
 		if (HAS_NAND || HAS_NOR)
arch/arm/mach- renamed from arch/arm/mach-davinci/board-neuros-osd2.c +0 -0

davinci/board-neuros-osd2.c

arch/arm/mach-davinci/devices-

Quoted 13 lines

index 5de69f2..7fdd0a7b 100644

arch/arm/mach-davinci/board-neuros-osd2.c +1 -1
@@ -221,7 +221,7 @@ static __init void davinci_ntosd2_init(void)
 	int	status;
 
 	aemif_clk = clk_get(NULL, "aemif");
-	clk_enable(aemif_clk);
+	clk_prepare_enable(aemif_clk);
 
 	if (HAS_ATA) {
 		if (HAS_NAND)
arch/arm/mach-davinci/devices- renamed from arch/arm/mach-davinci/devices-da8xx.c +0 -0

da8xx.c

arch/arm/mach-davinci/devices-da8xx.c static int da850_sata_init(struct device *dev, void __iomem

Quoted 4 lines

index d1624a3..20141f5 100644

arch/arm/mach-davinci/devices-da8xx.c +0 -0
@@ -905,7 +905,7 @@ static int da850_sata_init(struct device *dev, void __iomem

*addr)

arch/arm/mach-davinci/devices-da8xx.c static int da850_sata_init(struct device *dev, void __iomem

Quoted 9 lines
arch/arm/mach-davinci/devices-da8xx.c +1 -1
 	if (IS_ERR(da850_sata_clk))
 		return PTR_ERR(da850_sata_clk);
 
-	ret = clk_enable(da850_sata_clk);
+	ret = clk_prepare_enable(da850_sata_clk);
 	if (ret)
 		goto err0;
 
@@ -936,7 +936,7 @@ static int da850_sata_init(struct device *dev, void __iomem

*addr)

Quoted 55 lines
arch/arm/mach-davinci/devices-da8xx.c +2 -2
 	return 0;
 
 err1:
-	clk_disable(da850_sata_clk);
+	clk_disable_unprepare(da850_sata_clk);
 err0:
 	clk_put(da850_sata_clk);
 	return ret;
@@ -944,7 +944,7 @@ err0:
 
 static void da850_sata_exit(struct device *dev)
 {
-	clk_disable(da850_sata_clk);
+	clk_disable_unprepare(da850_sata_clk);
 	clk_put(da850_sata_clk);
 }
 
arch/arm/mach-davinci/serial.c +1 -1
index 1875740..24ddb0d 100644
@@ -95,7 +95,7 @@ int __init davinci_serial_init(struct davinci_uart_config *info)
 			continue;
 		}
 
-		clk_enable(uart_clk);
+		clk_prepare_enable(uart_clk);
 		p->uartclk = clk_get_rate(uart_clk);
 
 		if (!p->membase && p->mapbase) {
arch/arm/mach-davinci/time.c +2 -3
index 75da315..9847938 100644
@@ -379,7 +379,7 @@ static void __init davinci_timer_init(void)
 
 	timer_clk = clk_get(NULL, "timer0");
 	BUG_ON(IS_ERR(timer_clk));
-	clk_enable(timer_clk);
+	clk_prepare_enable(timer_clk);
 
 	/* init timer hw */
 	timer_init();
@@ -429,7 +429,7 @@ void davinci_watchdog_reset(struct platform_device *pdev)
 	wd_clk = clk_get(&pdev->dev, NULL);
 	if (WARN_ON(IS_ERR(wd_clk)))
 		return;
-	clk_enable(wd_clk);
+	clk_prepare_enable(wd_clk);
 
 	/* disable, internal clock source */
 	__raw_writel(0, base + TCR);
--

1.7.9.5

#6 lore raw

PATCH 1/1 arm:davinci: clk - migrate to new common clock API

In reply to a message not in the archive

Hi Murali,

Quoted 10 lines · Murali Karicheri

As a first step towards migrating davinci platforms to use common clock framework, replace all instances of clk_enable() with clk_prepare_enable() and clk_disable() with clk_disable_unprepare(). Until the platform is switched to use the CONFIG_HAVE_CLK_PREPARE Kconfig variable, this just adds a might_sleep() call and would work without any issues.

This will make it easy later to switch to common clk based implementation of clk driver from DaVinci specific driver.

Queuing this patch for v3.7. The subject line should have ARM in capitals for consistency. Also, you are not really migrating to new API in this patch - just preparing for migration so I prefer:

"ARM: davinci: convert platform code to use clk_prepare/clk_unprepare"

I will make this change while committing.

Thanks,
Sekhar

#7 lore raw

PATCH 1/1 arm:davinci: clk - migrate to new common clock API

Agreed. So I am not re-sending this patch.

Murali Karicheri
Software Design Engineer

Quoted 35 lines
Quoted 35 lines

-----Original Message-----
From: Nori, Sekhar
Sent: Tuesday, August 14, 2012 2:30 AM
To: Karicheri, Muralidharan
Cc: linux-arm-kernel at lists.infradead.org; davinci-linux-open-
source at linux.davincidsp.com; linux-keystone at list.ti.com - Linux developers for Keystone family of devices (May contain non-TIers); Turquette, Mike; Chemparathy, Cyril; linux at arm.linux.org.uk
Subject: Re: [PATCH] arm:davinci: clk - migrate to new common clock API

Hi Murali,

Quoted 10 lines · Murali Karicheri

As a first step towards migrating davinci platforms to use common clock framework, replace all instances of clk_enable() with clk_prepare_enable() and clk_disable() with clk_disable_unprepare(). Until the platform is switched to use the CONFIG_HAVE_CLK_PREPARE Kconfig variable, this just adds a might_sleep() call and would work without any issues.

This will make it easy later to switch to common clk based implementation of clk driver from DaVinci specific driver.

Queuing this patch for v3.7. The subject line should have ARM in capitals for consistency. Also, you are not really migrating to new API in this patch - just preparing for migration so I prefer:

"ARM: davinci: convert platform code to use clk_prepare/clk_unprepare"

I will make this change while committing.

Thanks,
Sekhar