linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/7] LPC32xx: clock.c: Missing header file
@ 2012-01-30 16:02 Roland Stigge
  2012-01-30 16:02 ` [PATCH v2 2/7] LPC32xx: clock.c: jiffies wrapping Roland Stigge
                   ` (6 more replies)
  0 siblings, 7 replies; 17+ messages in thread
From: Roland Stigge @ 2012-01-30 16:02 UTC (permalink / raw)
  To: w.sang, bangaragiri.g, srinivas.bakki, sundarapandian.andithevar,
	linus.walleij, linux-kernel, kevin.wells, grant.likely,
	linux-arm-kernel
  Cc: Roland Stigge

This patch fixes the compiler warnings regarding the EXPORT_SYMBOL usage

Signed-off-by: Roland Stigge <stigge@antcom.de>

diff --git a/arch/arm/mach-lpc32xx/clock.c b/arch/arm/mach-lpc32xx/clock.c
index 1e02751..8e79313 100644
--- a/arch/arm/mach-lpc32xx/clock.c
+++ b/arch/arm/mach-lpc32xx/clock.c
@@ -82,6 +82,7 @@
  *   will also impact the individual peripheral rates.
  */
 
+#include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/list.h>
 #include <linux/errno.h>

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v2 2/7] LPC32xx: clock.c: jiffies wrapping
  2012-01-30 16:02 [PATCH v2 1/7] LPC32xx: clock.c: Missing header file Roland Stigge
@ 2012-01-30 16:02 ` Roland Stigge
  2012-01-31 10:24   ` Wolfram Sang
  2012-01-30 16:02 ` [PATCH v2 3/7] LPC32xx: clock.c: Clock registration fixes Roland Stigge
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 17+ messages in thread
From: Roland Stigge @ 2012-01-30 16:02 UTC (permalink / raw)
  To: w.sang, bangaragiri.g, srinivas.bakki, sundarapandian.andithevar,
	linus.walleij, linux-kernel, kevin.wells, grant.likely,
	linux-arm-kernel
  Cc: Roland Stigge

This patch fixes the jiffies wrapping bug in clock.c.

It corrects the timeout computation based on jiffies, uses time_before() for
correct wrapping handling and replaces a binary "&" which should really be a
logical "&&" in a truth expression.

Signed-off-by: Roland Stigge <stigge@antcom.de>

diff --git a/arch/arm/mach-lpc32xx/clock.c b/arch/arm/mach-lpc32xx/clock.c
index 8e79313..f64c9a1 100644
--- a/arch/arm/mach-lpc32xx/clock.c
+++ b/arch/arm/mach-lpc32xx/clock.c
@@ -128,7 +128,7 @@ static struct clk osc_32KHz = {
 static int local_pll397_enable(struct clk *clk, int enable)
 {
 	u32 reg;
-	unsigned long timeout = 1 + msecs_to_jiffies(10);
+	unsigned long timeout = jiffies + msecs_to_jiffies(10);
 
 	reg = __raw_readl(LPC32XX_CLKPWR_PLL397_CTRL);
 
@@ -143,7 +143,7 @@ static int local_pll397_enable(struct clk *clk, int enable)
 		/* Wait for PLL397 lock */
 		while (((__raw_readl(LPC32XX_CLKPWR_PLL397_CTRL) &
 			LPC32XX_CLKPWR_SYSCTRL_PLL397_STS) == 0) &&
-			(timeout > jiffies))
+			time_before(jiffies, timeout))
 			cpu_relax();
 
 		if ((__raw_readl(LPC32XX_CLKPWR_PLL397_CTRL) &
@@ -157,7 +157,7 @@ static int local_pll397_enable(struct clk *clk, int enable)
 static int local_oscmain_enable(struct clk *clk, int enable)
 {
 	u32 reg;
-	unsigned long timeout = 1 + msecs_to_jiffies(10);
+	unsigned long timeout = jiffies + msecs_to_jiffies(10);
 
 	reg = __raw_readl(LPC32XX_CLKPWR_MAIN_OSC_CTRL);
 
@@ -172,7 +172,7 @@ static int local_oscmain_enable(struct clk *clk, int enable)
 		/* Wait for main oscillator to start */
 		while (((__raw_readl(LPC32XX_CLKPWR_MAIN_OSC_CTRL) &
 			LPC32XX_CLKPWR_MOSC_DISABLE) != 0) &&
-			(timeout > jiffies))
+			time_before(jiffies, timeout))
 			cpu_relax();
 
 		if ((__raw_readl(LPC32XX_CLKPWR_MAIN_OSC_CTRL) &
@@ -384,7 +384,7 @@ static int local_usbpll_enable(struct clk *clk, int enable)
 {
 	u32 reg;
 	int ret = -ENODEV;
-	unsigned long timeout = 1 + msecs_to_jiffies(10);
+	unsigned long timeout = jiffies + msecs_to_jiffies(10);
 
 	reg = __raw_readl(LPC32XX_CLKPWR_USB_CTRL);
 
@@ -397,7 +397,7 @@ static int local_usbpll_enable(struct clk *clk, int enable)
 		__raw_writel(reg, LPC32XX_CLKPWR_USB_CTRL);
 
 		/* Wait for PLL lock */
-		while ((timeout > jiffies) & (ret == -ENODEV)) {
+		while (time_before(jiffies, timeout) && (ret == -ENODEV)) {
 			reg = __raw_readl(LPC32XX_CLKPWR_USB_CTRL);
 			if (reg & LPC32XX_CLKPWR_USBCTRL_PLL_STS)
 				ret = 0;

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v2 3/7] LPC32xx: clock.c: Clock registration fixes
  2012-01-30 16:02 [PATCH v2 1/7] LPC32xx: clock.c: Missing header file Roland Stigge
  2012-01-30 16:02 ` [PATCH v2 2/7] LPC32xx: clock.c: jiffies wrapping Roland Stigge
@ 2012-01-30 16:02 ` Roland Stigge
  2012-01-30 16:02 ` [PATCH v2 4/7] LPC32xx: clock.c: MMC update Roland Stigge
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 17+ messages in thread
From: Roland Stigge @ 2012-01-30 16:02 UTC (permalink / raw)
  To: w.sang, bangaragiri.g, srinivas.bakki, sundarapandian.andithevar,
	linus.walleij, linux-kernel, kevin.wells, grant.likely,
	linux-arm-kernel
  Cc: Roland Stigge

This patch adjusts the clock registration list, ported from the latest version
of Kevin Wells' latest version of clock.c: i2s0_ck, i2s1_ck and dev:mmc0 have
NULL pointers associated as the .dev_id and .con_id, respectively. The old
values were not useful.

Signed-off-by: Roland Stigge <stigge@antcom.de>

--- a/arch/arm/mach-lpc32xx/clock.c
+++ b/arch/arm/mach-lpc32xx/clock.c
@@ -1076,10 +1098,10 @@ static struct clk_lookup lookups[] = {
 	_REGISTER_CLOCK("dev:ssp1", NULL, clk_ssp1)
 	_REGISTER_CLOCK("lpc32xx_keys.0", NULL, clk_kscan)
 	_REGISTER_CLOCK("lpc32xx-nand.0", "nand_ck", clk_nand)
-	_REGISTER_CLOCK("tbd", "i2s0_ck", clk_i2s0)
-	_REGISTER_CLOCK("tbd", "i2s1_ck", clk_i2s1)
+	_REGISTER_CLOCK(NULL, "i2s0_ck", clk_i2s0)
+	_REGISTER_CLOCK(NULL, "i2s1_ck", clk_i2s1)
 	_REGISTER_CLOCK("ts-lpc32xx", NULL, clk_tsc)
-	_REGISTER_CLOCK("dev:mmc0", "MCLK", clk_mmc)
+	_REGISTER_CLOCK("dev:mmc0", NULL, clk_mmc)
 	_REGISTER_CLOCK("lpc-net.0", NULL, clk_net)
 	_REGISTER_CLOCK("dev:clcd", NULL, clk_lcd)
 	_REGISTER_CLOCK("lpc32xx_udc", "ck_usbd", clk_usbd)


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v2 4/7] LPC32xx: clock.c: MMC update
  2012-01-30 16:02 [PATCH v2 1/7] LPC32xx: clock.c: Missing header file Roland Stigge
  2012-01-30 16:02 ` [PATCH v2 2/7] LPC32xx: clock.c: jiffies wrapping Roland Stigge
  2012-01-30 16:02 ` [PATCH v2 3/7] LPC32xx: clock.c: Clock registration fixes Roland Stigge
@ 2012-01-30 16:02 ` Roland Stigge
  2012-01-30 16:02 ` [PATCH v2 5/7] LPC32xx: clock.c: warning fix Roland Stigge
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 17+ messages in thread
From: Roland Stigge @ 2012-01-30 16:02 UTC (permalink / raw)
  To: w.sang, bangaragiri.g, srinivas.bakki, sundarapandian.andithevar,
	linus.walleij, linux-kernel, kevin.wells, grant.likely,
	linux-arm-kernel
  Cc: Roland Stigge

This patch updates MMC clocking in clock.c:
* No manual MMC clock enable/disable on MMC register access necessary
  (it's the MMC IP clock, not the MMC CLK signal rate)  
* Added comments

Signed-off-by: Roland Stigge <stigge@antcom.de>

diff --git a/arch/arm/mach-lpc32xx/clock.c b/arch/arm/mach-lpc32xx/clock.c
index 17709ca..229bec5 100644
--- a/arch/arm/mach-lpc32xx/clock.c
+++ b/arch/arm/mach-lpc32xx/clock.c
@@ -738,14 +738,9 @@ static int mmc_onoff_enable(struct clk *clk, int enable)
 
 static unsigned long mmc_get_rate(struct clk *clk)
 {
-	u32 div, rate, oldclk;
+	u32 div, rate;
 
-	/* The MMC clock must be on when accessing an MMC register */
-	oldclk = __raw_readl(LPC32XX_CLKPWR_MS_CTRL);
-	__raw_writel(oldclk | LPC32XX_CLKPWR_MSCARD_SDCARD_EN,
-		LPC32XX_CLKPWR_MS_CTRL);
 	div = __raw_readl(LPC32XX_CLKPWR_MS_CTRL);
-	__raw_writel(oldclk, LPC32XX_CLKPWR_MS_CTRL);
 
 	/* Get the parent clock rate */
 	rate = clk->parent->get_rate(clk->parent);
@@ -773,32 +768,36 @@ static unsigned long mmc_round_rate(struct clk *clk, unsigned long rate)
 	if (div > 0xf)
 		div = 0xf;
 
+	/*
+	 * The divider is forced to 1 to keep the SD clock granularity
+	 * good. Using a non-0 divider will limit the SD card clock rates
+	 * the SD driver can generate. Remove it if your feeling crazy.
+	 */
+	div = 1;
+
 	return prate / div;
 }
 
 static int mmc_set_rate(struct clk *clk, unsigned long rate)
 {
-	u32 oldclk, tmp;
+	u32 tmp;
 	unsigned long prate, div, crate = mmc_round_rate(clk, rate);
 
 	prate = clk->parent->get_rate(clk->parent);
 
 	div = prate / crate;
 
-	/* The MMC clock must be on when accessing an MMC register */
-	oldclk = __raw_readl(LPC32XX_CLKPWR_MS_CTRL);
-	__raw_writel(oldclk | LPC32XX_CLKPWR_MSCARD_SDCARD_EN,
-		LPC32XX_CLKPWR_MS_CTRL);
 	tmp = __raw_readl(LPC32XX_CLKPWR_MS_CTRL) &
 		~LPC32XX_CLKPWR_MSCARD_SDCARD_DIV(0xf);
 	tmp |= LPC32XX_CLKPWR_MSCARD_SDCARD_DIV(div);
 	__raw_writel(tmp, LPC32XX_CLKPWR_MS_CTRL);
 
-	__raw_writel(oldclk, LPC32XX_CLKPWR_MS_CTRL);
-
 	return 0;
 }
 
+/*
+ * This is the MMC IP clock, not the MMC CLK signal rate!
+ */
 static struct clk clk_mmc = {
 	.parent		= &clk_armpll,
 	.set_rate	= mmc_set_rate,

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v2 5/7] LPC32xx: clock.c: warning fix
  2012-01-30 16:02 [PATCH v2 1/7] LPC32xx: clock.c: Missing header file Roland Stigge
                   ` (2 preceding siblings ...)
  2012-01-30 16:02 ` [PATCH v2 4/7] LPC32xx: clock.c: MMC update Roland Stigge
@ 2012-01-30 16:02 ` Roland Stigge
  2012-01-31 10:26   ` Wolfram Sang
  2012-01-30 16:02 ` [PATCH v2 6/7] LPC32xx: clock.c: USB PLL fix Roland Stigge
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 17+ messages in thread
From: Roland Stigge @ 2012-01-30 16:02 UTC (permalink / raw)
  To: w.sang, bangaragiri.g, srinivas.bakki, sundarapandian.andithevar,
	linus.walleij, linux-kernel, kevin.wells, grant.likely,
	linux-arm-kernel
  Cc: Roland Stigge

This patch removes the debug warning on local_clk_disable() as done in Kevin
Wells' driver update

Signed-off-by: Roland Stigge <stigge@antcom.de>

diff --git a/arch/arm/mach-lpc32xx/clock.c b/arch/arm/mach-lpc32xx/clock.c
index 229bec5..01e9aba 100644
--- a/arch/arm/mach-lpc32xx/clock.c
+++ b/arch/arm/mach-lpc32xx/clock.c
@@ -903,8 +903,6 @@ static inline void clk_unlock(void)
 
 static void local_clk_disable(struct clk *clk)
 {
-	WARN_ON(clk->usecount == 0);
-
 	/* Don't attempt to disable clock if it has no users */
 	if (clk->usecount > 0) {
 		clk->usecount--;

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v2 6/7] LPC32xx: clock.c: USB PLL fix
  2012-01-30 16:02 [PATCH v2 1/7] LPC32xx: clock.c: Missing header file Roland Stigge
                   ` (3 preceding siblings ...)
  2012-01-30 16:02 ` [PATCH v2 5/7] LPC32xx: clock.c: warning fix Roland Stigge
@ 2012-01-30 16:02 ` Roland Stigge
  2012-01-31 10:34   ` Wolfram Sang
  2012-01-30 16:02 ` [PATCH v2 7/7] LPC32xx: clock.c: Fix mutex lock issues Roland Stigge
  2012-01-30 17:56 ` [PATCH v2 1/7] LPC32xx: clock.c: Missing header file Sergei Shtylyov
  6 siblings, 1 reply; 17+ messages in thread
From: Roland Stigge @ 2012-01-30 16:02 UTC (permalink / raw)
  To: w.sang, bangaragiri.g, srinivas.bakki, sundarapandian.andithevar,
	linus.walleij, linux-kernel, kevin.wells, grant.likely,
	linux-arm-kernel
  Cc: Roland Stigge

This patch fixes and updates the USB PLL handling. With the old driver version,
the USB clock was sometimes not started correctly. The update reflects the
driver changes in this regard from Kevin Wells.

See also git.lpclinux.com

Signed-off-by: Roland Stigge <stigge@antcom.de>

diff --git a/arch/arm/mach-lpc32xx/clock.c b/arch/arm/mach-lpc32xx/clock.c
index f64c9a1..6dd2c30 100644
--- a/arch/arm/mach-lpc32xx/clock.c
+++ b/arch/arm/mach-lpc32xx/clock.c
@@ -87,6 +87,7 @@
 #include <linux/list.h>
 #include <linux/errno.h>
 #include <linux/device.h>
+#include <linux/delay.h>
 #include <linux/err.h>
 #include <linux/clk.h>
 #include <linux/amba/bus.h>
@@ -98,6 +99,8 @@
 #include "clock.h"
 #include "common.h"
 
+static int usb_pll_enable, usb_pll_valid;
+
 static struct clk clk_armpll;
 static struct clk clk_usbpll;
 static DEFINE_MUTEX(clkm_lock);
@@ -383,30 +386,62 @@ static u32 local_clk_usbpll_setup(struct clk_pll_setup *pHCLKPllSetup)
 static int local_usbpll_enable(struct clk *clk, int enable)
 {
 	u32 reg;
-	int ret = -ENODEV;
-	unsigned long timeout = jiffies + msecs_to_jiffies(10);
+	int ret = 0;
+	unsigned long timeout = jiffies + msecs_to_jiffies(20);
 
 	reg = __raw_readl(LPC32XX_CLKPWR_USB_CTRL);
 
-	if (enable == 0) {
-		reg &= ~(LPC32XX_CLKPWR_USBCTRL_CLK_EN1 |
-			LPC32XX_CLKPWR_USBCTRL_CLK_EN2);
-		__raw_writel(reg, LPC32XX_CLKPWR_USB_CTRL);
-	} else if (reg & LPC32XX_CLKPWR_USBCTRL_PLL_PWRUP) {
+	__raw_writel(reg & ~(LPC32XX_CLKPWR_USBCTRL_CLK_EN2 |
+		LPC32XX_CLKPWR_USBCTRL_PLL_PWRUP),
+		LPC32XX_CLKPWR_USB_CTRL);
+	__raw_writel(reg & ~LPC32XX_CLKPWR_USBCTRL_CLK_EN1,
+		LPC32XX_CLKPWR_USB_CTRL);
+
+	if (enable && usb_pll_valid && usb_pll_enable) {
+		ret = -ENODEV;
+		/*
+		 * If the PLL rate has been previously set, then the rate
+		 * in the PLL register is valid and can be enabled here.
+		 * Otherwise, it needs to be enabled as part of setrate.
+		 */
+
+		/*
+		 * Gate clock into PLL
+		 */
 		reg |= LPC32XX_CLKPWR_USBCTRL_CLK_EN1;
 		__raw_writel(reg, LPC32XX_CLKPWR_USB_CTRL);
 
-		/* Wait for PLL lock */
+		/*
+		 * Enable PLL
+		 */
+		reg |= LPC32XX_CLKPWR_USBCTRL_PLL_PWRUP;
+		__raw_writel(reg, LPC32XX_CLKPWR_USB_CTRL);
+
+		/*
+		 * Wait for PLL to lock
+		 */
 		while (time_before(jiffies, timeout) && (ret == -ENODEV)) {
 			reg = __raw_readl(LPC32XX_CLKPWR_USB_CTRL);
 			if (reg & LPC32XX_CLKPWR_USBCTRL_PLL_STS)
 				ret = 0;
+			else
+				udelay(10);
 		}
 
+		/*
+		 * Gate clock from PLL if PLL is locked
+		 */
 		if (ret == 0) {
-			reg |= LPC32XX_CLKPWR_USBCTRL_CLK_EN2;
-			__raw_writel(reg, LPC32XX_CLKPWR_USB_CTRL);
+			__raw_writel(reg | LPC32XX_CLKPWR_USBCTRL_CLK_EN2,
+				LPC32XX_CLKPWR_USB_CTRL);
+		} else {
+			__raw_writel(reg & ~(LPC32XX_CLKPWR_USBCTRL_CLK_EN1 |
+				LPC32XX_CLKPWR_USBCTRL_PLL_PWRUP),
+				LPC32XX_CLKPWR_USB_CTRL);
 		}
+	} else if ((enable == 0) && usb_pll_valid  && usb_pll_enable) {
+		usb_pll_valid = 0;
+		usb_pll_enable = 0;
 	}
 
 	return ret;
@@ -424,7 +459,7 @@ static unsigned long local_usbpll_round_rate(struct clk *clk,
 	 */
 	rate = rate * 1000;
 
-	clkin = clk->parent->rate;
+	clkin = clk->get_rate(clk);
 	usbdiv = (__raw_readl(LPC32XX_CLKPWR_USBCLK_PDIV) &
 		LPC32XX_CLKPWR_USBPDIV_PLL_MASK) + 1;
 	clkin = clkin / usbdiv;
@@ -438,7 +473,8 @@ static unsigned long local_usbpll_round_rate(struct clk *clk,
 
 static int local_usbpll_set_rate(struct clk *clk, unsigned long rate)
 {
-	u32 clkin, reg, usbdiv;
+	int ret = -ENODEV;
+	u32 clkin, usbdiv;
 	struct clk_pll_setup pllsetup;
 
 	/*
@@ -447,7 +483,7 @@ static int local_usbpll_set_rate(struct clk *clk, unsigned long rate)
 	 */
 	rate = rate * 1000;
 
-	clkin = clk->get_rate(clk);
+	clkin = clk->get_rate(clk->parent);
 	usbdiv = (__raw_readl(LPC32XX_CLKPWR_USBCLK_PDIV) &
 		LPC32XX_CLKPWR_USBPDIV_PLL_MASK) + 1;
 	clkin = clkin / usbdiv;
@@ -456,22 +492,25 @@ static int local_usbpll_set_rate(struct clk *clk, unsigned long rate)
 	if (local_clk_find_pll_cfg(clkin, rate, &pllsetup) == 0)
 		return -EINVAL;
 
+	/*
+	 * Disable PLL clocks during PLL change
+	 */
 	local_usbpll_enable(clk, 0);
-
-	reg = __raw_readl(LPC32XX_CLKPWR_USB_CTRL);
-	reg |= LPC32XX_CLKPWR_USBCTRL_CLK_EN1;
-	__raw_writel(reg, LPC32XX_CLKPWR_USB_CTRL);
-
-	pllsetup.analog_on = 1;
+	pllsetup.analog_on = 0;
 	local_clk_usbpll_setup(&pllsetup);
 
-	clk->rate = clk_check_pll_setup(clkin, &pllsetup);
+	/*
+	 * Start USB PLL and check PLL status
+	 */
 
-	reg = __raw_readl(LPC32XX_CLKPWR_USB_CTRL);
-	reg |= LPC32XX_CLKPWR_USBCTRL_CLK_EN2;
-	__raw_writel(reg, LPC32XX_CLKPWR_USB_CTRL);
+	usb_pll_valid = 1;
+	usb_pll_enable = 1;
 
-	return 0;
+	ret = local_usbpll_enable(clk, 1);
+	if (ret >= 0)
+		clk->rate = clk_check_pll_setup(clkin, &pllsetup);
+
+	return ret;
 }
 
 static struct clk clk_usbpll = {
@@ -731,6 +770,10 @@ static int mmc_onoff_enable(struct clk *clk, int enable)
 	if (enable != 0)
 		tmp |= LPC32XX_CLKPWR_MSCARD_SDCARD_EN;
 
+	/* Start clock at highest rate */
+	if (!(tmp & LPC32XX_CLKPWR_MSCARD_SDCARD_DIV(0xF)))
+		tmp |= LPC32XX_CLKPWR_MSCARD_SDCARD_DIV(1);
+
 	__raw_writel(tmp, LPC32XX_CLKPWR_MS_CTRL);
 
 	return 0;

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v2 7/7] LPC32xx: clock.c: Fix mutex lock issues
  2012-01-30 16:02 [PATCH v2 1/7] LPC32xx: clock.c: Missing header file Roland Stigge
                   ` (4 preceding siblings ...)
  2012-01-30 16:02 ` [PATCH v2 6/7] LPC32xx: clock.c: USB PLL fix Roland Stigge
@ 2012-01-30 16:02 ` Roland Stigge
  2012-01-31 10:27   ` Wolfram Sang
  2012-01-30 17:56 ` [PATCH v2 1/7] LPC32xx: clock.c: Missing header file Sergei Shtylyov
  6 siblings, 1 reply; 17+ messages in thread
From: Roland Stigge @ 2012-01-30 16:02 UTC (permalink / raw)
  To: w.sang, bangaragiri.g, srinivas.bakki, sundarapandian.andithevar,
	linus.walleij, linux-kernel, kevin.wells, grant.likely,
	linux-arm-kernel
  Cc: Roland Stigge

This patch fixes the mutex issue in clock.c, as done in Kevin Wells' original
driver update:

In some cases, the clock drivers could grab a mutex twice in an improper
context. This patch changes the mutex mechanism to a simple irq lock/unlock
mechanism and removes un-needed locks from some functions.

(See also git.lpclinux.com)

Signed-off-by: Roland Stigge <stigge@antcom.de>

diff --git a/arch/arm/mach-lpc32xx/clock.c b/arch/arm/mach-lpc32xx/clock.c
index f49638a..aceb88a 100644
--- a/arch/arm/mach-lpc32xx/clock.c
+++ b/arch/arm/mach-lpc32xx/clock.c
@@ -99,11 +99,12 @@
 #include "clock.h"
 #include "common.h"
 
+static DEFINE_SPINLOCK(global_clkregs_lock);
+
 static int usb_pll_enable, usb_pll_valid;
 
 static struct clk clk_armpll;
 static struct clk clk_usbpll;
-static DEFINE_MUTEX(clkm_lock);
 
 /*
  * Post divider values for PLLs based on selected register value
@@ -934,16 +935,6 @@ static struct clk clk_lcd = {
 	.enable_mask	= LPC32XX_CLKPWR_LCDCTRL_CLK_EN,
 };
 
-static inline void clk_lock(void)
-{
-	mutex_lock(&clkm_lock);
-}
-
-static inline void clk_unlock(void)
-{
-	mutex_unlock(&clkm_lock);
-}
-
 static void local_clk_disable(struct clk *clk)
 {
 	/* Don't attempt to disable clock if it has no users */
@@ -988,10 +979,11 @@ static int local_clk_enable(struct clk *clk)
 int clk_enable(struct clk *clk)
 {
 	int ret;
+	unsigned long flags;
 
-	clk_lock();
+	spin_lock_irqsave(&global_clkregs_lock, flags);
 	ret = local_clk_enable(clk);
-	clk_unlock();
+	spin_unlock_irqrestore(&global_clkregs_lock, flags);
 
 	return ret;
 }
@@ -1002,9 +994,11 @@ EXPORT_SYMBOL(clk_enable);
  */
 void clk_disable(struct clk *clk)
 {
-	clk_lock();
+	unsigned long flags;
+
+	spin_lock_irqsave(&global_clkregs_lock, flags);
 	local_clk_disable(clk);
-	clk_unlock();
+	spin_unlock_irqrestore(&global_clkregs_lock, flags);
 }
 EXPORT_SYMBOL(clk_disable);
 
@@ -1013,13 +1007,7 @@ EXPORT_SYMBOL(clk_disable);
  */
 unsigned long clk_get_rate(struct clk *clk)
 {
-	unsigned long rate;
-
-	clk_lock();
-	rate = clk->get_rate(clk);
-	clk_unlock();
-
-	return rate;
+	return clk->get_rate(clk);
 }
 EXPORT_SYMBOL(clk_get_rate);
 
@@ -1035,11 +1023,8 @@ int clk_set_rate(struct clk *clk, unsigned long rate)
 	 * the actual rate set as part of the peripheral dividers
 	 * instead of high level clock control
 	 */
-	if (clk->set_rate) {
-		clk_lock();
+	if (clk->set_rate)
 		ret = clk->set_rate(clk, rate);
-		clk_unlock();
-	}
 
 	return ret;
 }
@@ -1050,15 +1035,11 @@ EXPORT_SYMBOL(clk_set_rate);
  */
 long clk_round_rate(struct clk *clk, unsigned long rate)
 {
-	clk_lock();
-
 	if (clk->round_rate)
 		rate = clk->round_rate(clk, rate);
 	else
 		rate = clk->get_rate(clk);
 
-	clk_unlock();
-
 	return rate;
 }
 EXPORT_SYMBOL(clk_round_rate);

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH v2 1/7] LPC32xx: clock.c: Missing header file
  2012-01-30 16:02 [PATCH v2 1/7] LPC32xx: clock.c: Missing header file Roland Stigge
                   ` (5 preceding siblings ...)
  2012-01-30 16:02 ` [PATCH v2 7/7] LPC32xx: clock.c: Fix mutex lock issues Roland Stigge
@ 2012-01-30 17:56 ` Sergei Shtylyov
  2012-01-31 10:22   ` Wolfram Sang
  6 siblings, 1 reply; 17+ messages in thread
From: Sergei Shtylyov @ 2012-01-30 17:56 UTC (permalink / raw)
  To: Roland Stigge
  Cc: w.sang, bangaragiri.g, srinivas.bakki, sundarapandian.andithevar,
	linus.walleij, linux-kernel, kevin.wells, grant.likely,
	linux-arm-kernel

Hello.

On 01/30/2012 07:02 PM, Roland Stigge wrote:

> This patch fixes the compiler warnings regarding the EXPORT_SYMBOL usage

> Signed-off-by: Roland Stigge<stigge@antcom.de>

> diff --git a/arch/arm/mach-lpc32xx/clock.c b/arch/arm/mach-lpc32xx/clock.c
> index 1e02751..8e79313 100644
> --- a/arch/arm/mach-lpc32xx/clock.c
> +++ b/arch/arm/mach-lpc32xx/clock.c
> @@ -82,6 +82,7 @@
>    *   will also impact the individual peripheral rates.
>    */
>
> +#include<linux/module.h>

    Shouldn't <linux/export.h> be included instead nowadays?

WBR, Sergei

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2 1/7] LPC32xx: clock.c: Missing header file
  2012-01-30 17:56 ` [PATCH v2 1/7] LPC32xx: clock.c: Missing header file Sergei Shtylyov
@ 2012-01-31 10:22   ` Wolfram Sang
  0 siblings, 0 replies; 17+ messages in thread
From: Wolfram Sang @ 2012-01-31 10:22 UTC (permalink / raw)
  To: Sergei Shtylyov
  Cc: Roland Stigge, bangaragiri.g, srinivas.bakki,
	sundarapandian.andithevar, linus.walleij, linux-kernel,
	kevin.wells, grant.likely, linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 880 bytes --]

On Mon, Jan 30, 2012 at 08:56:44PM +0300, Sergei Shtylyov wrote:
> Hello.
> 
> On 01/30/2012 07:02 PM, Roland Stigge wrote:
> 
> >This patch fixes the compiler warnings regarding the EXPORT_SYMBOL usage
> 
> >Signed-off-by: Roland Stigge<stigge@antcom.de>
> 
> >diff --git a/arch/arm/mach-lpc32xx/clock.c b/arch/arm/mach-lpc32xx/clock.c
> >index 1e02751..8e79313 100644
> >--- a/arch/arm/mach-lpc32xx/clock.c
> >+++ b/arch/arm/mach-lpc32xx/clock.c
> >@@ -82,6 +82,7 @@
> >   *   will also impact the individual peripheral rates.
> >   */
> >
> >+#include<linux/module.h>
> 
>    Shouldn't <linux/export.h> be included instead nowadays?

Ack.

@Roland: Nice series, thanks for splitting things up.

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2 2/7] LPC32xx: clock.c: jiffies wrapping
  2012-01-30 16:02 ` [PATCH v2 2/7] LPC32xx: clock.c: jiffies wrapping Roland Stigge
@ 2012-01-31 10:24   ` Wolfram Sang
  0 siblings, 0 replies; 17+ messages in thread
From: Wolfram Sang @ 2012-01-31 10:24 UTC (permalink / raw)
  To: Roland Stigge
  Cc: bangaragiri.g, srinivas.bakki, sundarapandian.andithevar,
	linus.walleij, linux-kernel, kevin.wells, grant.likely,
	linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 638 bytes --]

On Mon, Jan 30, 2012 at 05:02:01PM +0100, Roland Stigge wrote:
> This patch fixes the jiffies wrapping bug in clock.c.
> 
> It corrects the timeout computation based on jiffies, uses time_before() for
> correct wrapping handling and replaces a binary "&" which should really be a
> logical "&&" in a truth expression.
> 
> Signed-off-by: Roland Stigge <stigge@antcom.de>

Acked-by: Wolfram Sang <w.sang@pengutronix.de> 
Tested-by: Wolfram Sang <w.sang@pengutronix.de>

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2 5/7] LPC32xx: clock.c: warning fix
  2012-01-30 16:02 ` [PATCH v2 5/7] LPC32xx: clock.c: warning fix Roland Stigge
@ 2012-01-31 10:26   ` Wolfram Sang
  0 siblings, 0 replies; 17+ messages in thread
From: Wolfram Sang @ 2012-01-31 10:26 UTC (permalink / raw)
  To: Roland Stigge
  Cc: bangaragiri.g, srinivas.bakki, sundarapandian.andithevar,
	linus.walleij, linux-kernel, kevin.wells, grant.likely,
	linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 998 bytes --]

On Mon, Jan 30, 2012 at 05:02:04PM +0100, Roland Stigge wrote:
> This patch removes the debug warning on local_clk_disable() as done in Kevin
> Wells' driver update
> 
> Signed-off-by: Roland Stigge <stigge@antcom.de>

Maybe this can be folded with 7/7? Otherwise

Acked-by: Wolfram Sang <w.sang@pengutronix.de>
Tested-by: Wolfram Sang <w.sang@pengutronix.de>

> 
> diff --git a/arch/arm/mach-lpc32xx/clock.c b/arch/arm/mach-lpc32xx/clock.c
> index 229bec5..01e9aba 100644
> --- a/arch/arm/mach-lpc32xx/clock.c
> +++ b/arch/arm/mach-lpc32xx/clock.c
> @@ -903,8 +903,6 @@ static inline void clk_unlock(void)
>  
>  static void local_clk_disable(struct clk *clk)
>  {
> -	WARN_ON(clk->usecount == 0);
> -
>  	/* Don't attempt to disable clock if it has no users */
>  	if (clk->usecount > 0) {
>  		clk->usecount--;

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2 7/7] LPC32xx: clock.c: Fix mutex lock issues
  2012-01-30 16:02 ` [PATCH v2 7/7] LPC32xx: clock.c: Fix mutex lock issues Roland Stigge
@ 2012-01-31 10:27   ` Wolfram Sang
  0 siblings, 0 replies; 17+ messages in thread
From: Wolfram Sang @ 2012-01-31 10:27 UTC (permalink / raw)
  To: Roland Stigge
  Cc: bangaragiri.g, srinivas.bakki, sundarapandian.andithevar,
	linus.walleij, linux-kernel, kevin.wells, grant.likely,
	linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 684 bytes --]

On Mon, Jan 30, 2012 at 05:02:06PM +0100, Roland Stigge wrote:
> This patch fixes the mutex issue in clock.c, as done in Kevin Wells' original
> driver update:
> 
> In some cases, the clock drivers could grab a mutex twice in an improper
> context. This patch changes the mutex mechanism to a simple irq lock/unlock
> mechanism and removes un-needed locks from some functions.
> 
> (See also git.lpclinux.com)
> 
> Signed-off-by: Roland Stigge <stigge@antcom.de>

Tested-by: Wolfram Sang <w.sang@pengutronix.de>

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2 6/7] LPC32xx: clock.c: USB PLL fix
  2012-01-30 16:02 ` [PATCH v2 6/7] LPC32xx: clock.c: USB PLL fix Roland Stigge
@ 2012-01-31 10:34   ` Wolfram Sang
  2012-02-01 13:27     ` Roland Stigge
  0 siblings, 1 reply; 17+ messages in thread
From: Wolfram Sang @ 2012-01-31 10:34 UTC (permalink / raw)
  To: Roland Stigge
  Cc: bangaragiri.g, srinivas.bakki, sundarapandian.andithevar,
	linus.walleij, linux-kernel, kevin.wells, grant.likely,
	linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 767 bytes --]

On Mon, Jan 30, 2012 at 05:02:05PM +0100, Roland Stigge wrote:
> This patch fixes and updates the USB PLL handling. With the old driver version,
> the USB clock was sometimes not started correctly. The update reflects the
> driver changes in this regard from Kevin Wells.
> 
> See also git.lpclinux.com
> 
> Signed-off-by: Roland Stigge <stigge@antcom.de>

I remember we needed that fix back then as well, so I am tempted to ack
it. However, I'd like to test it but USB is currently not available. Do
you happen to have a USB fixing commit just to test (can be hackish)?

Thanks,

   Wolfram

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2 6/7] LPC32xx: clock.c: USB PLL fix
  2012-01-31 10:34   ` Wolfram Sang
@ 2012-02-01 13:27     ` Roland Stigge
  2012-02-02 16:49       ` Wolfram Sang
  0 siblings, 1 reply; 17+ messages in thread
From: Roland Stigge @ 2012-02-01 13:27 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: bangaragiri.g, srinivas.bakki, sundarapandian.andithevar,
	linus.walleij, linux-kernel, kevin.wells, linux-arm-kernel

Hi Wolfram,

Thanks for reviewing my patches! I collected (and applied) all your
suggestions and will re-post the series as a patch update for applying
to the mainline tree.

On 01/31/2012 11:34 AM, Wolfram Sang wrote:
> I remember we needed that fix back then as well, so I am tempted to
> ack it. However, I'd like to test it but USB is currently not
> available. Do you happen to have a USB fixing commit just to test
> (can be hackish)?

I'm posting this one separately (to be applied on top of all my and
your posted patches).

What do you think about mainline-integrating it?

Thanks in advance!

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2 6/7] LPC32xx: clock.c: USB PLL fix
  2012-02-01 13:27     ` Roland Stigge
@ 2012-02-02 16:49       ` Wolfram Sang
  2012-02-02 19:20         ` Roland Stigge
  0 siblings, 1 reply; 17+ messages in thread
From: Wolfram Sang @ 2012-02-02 16:49 UTC (permalink / raw)
  To: Roland Stigge
  Cc: bangaragiri.g, srinivas.bakki, sundarapandian.andithevar,
	linus.walleij, linux-kernel, kevin.wells, linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 935 bytes --]

Hi,

> Thanks for reviewing my patches! I collected (and applied) all your
> suggestions and will re-post the series as a patch update for applying
> to the mainline tree.

Yes, please repost this series with the updates. And without USB & MMC
updates. Those updates should be in later series, when we actually add
support for these devices.

> What do you think about mainline-integrating it?

See my comment there.

First step, I'd suggest: After you repost this series, I'll create a
branch with the relevant patches (defconfig, buildfixes, clock fixes)
and send a pull-request to Arnd/Olof. You can decide which issue you
want to tackle next. I'd think MMC or USB are more of the lower hanging
fruits, but I leave that to you.

Regards,

   Wolfram

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2 6/7] LPC32xx: clock.c: USB PLL fix
  2012-02-02 16:49       ` Wolfram Sang
@ 2012-02-02 19:20         ` Roland Stigge
  2012-02-02 23:01           ` Wolfram Sang
  0 siblings, 1 reply; 17+ messages in thread
From: Roland Stigge @ 2012-02-02 19:20 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: bangaragiri.g, srinivas.bakki, sundarapandian.andithevar,
	linus.walleij, linux-kernel, kevin.wells, linux-arm-kernel

Hi Wolfram,

On 02/02/2012 05:49 PM, Wolfram Sang wrote:
> Yes, please repost this series with the updates. And without USB &
> MMC updates. Those updates should be in later series, when we
> actually add support for these devices.

OK, reposting.

> First step, I'd suggest: After you repost this series, I'll create
> a branch with the relevant patches (defconfig, buildfixes, clock
> fixes) and send a pull-request to Arnd/Olof. You can decide which
> issue you want to tackle next. I'd think MMC or USB are more of the
> lower hanging fruits, but I leave that to you.

I'd then first repost the GPIO fixes I posted previously and then look
after USB if that's fine for you. :-)

Thanks,

Roland

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2 6/7] LPC32xx: clock.c: USB PLL fix
  2012-02-02 19:20         ` Roland Stigge
@ 2012-02-02 23:01           ` Wolfram Sang
  0 siblings, 0 replies; 17+ messages in thread
From: Wolfram Sang @ 2012-02-02 23:01 UTC (permalink / raw)
  To: Roland Stigge
  Cc: bangaragiri.g, srinivas.bakki, sundarapandian.andithevar,
	linus.walleij, linux-kernel, kevin.wells, linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 323 bytes --]


> I'd then first repost the GPIO fixes I posted previously and then look
> after USB if that's fine for you. :-)

Totally fine with me, it's all up to you :)

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2012-02-02 23:01 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-30 16:02 [PATCH v2 1/7] LPC32xx: clock.c: Missing header file Roland Stigge
2012-01-30 16:02 ` [PATCH v2 2/7] LPC32xx: clock.c: jiffies wrapping Roland Stigge
2012-01-31 10:24   ` Wolfram Sang
2012-01-30 16:02 ` [PATCH v2 3/7] LPC32xx: clock.c: Clock registration fixes Roland Stigge
2012-01-30 16:02 ` [PATCH v2 4/7] LPC32xx: clock.c: MMC update Roland Stigge
2012-01-30 16:02 ` [PATCH v2 5/7] LPC32xx: clock.c: warning fix Roland Stigge
2012-01-31 10:26   ` Wolfram Sang
2012-01-30 16:02 ` [PATCH v2 6/7] LPC32xx: clock.c: USB PLL fix Roland Stigge
2012-01-31 10:34   ` Wolfram Sang
2012-02-01 13:27     ` Roland Stigge
2012-02-02 16:49       ` Wolfram Sang
2012-02-02 19:20         ` Roland Stigge
2012-02-02 23:01           ` Wolfram Sang
2012-01-30 16:02 ` [PATCH v2 7/7] LPC32xx: clock.c: Fix mutex lock issues Roland Stigge
2012-01-31 10:27   ` Wolfram Sang
2012-01-30 17:56 ` [PATCH v2 1/7] LPC32xx: clock.c: Missing header file Sergei Shtylyov
2012-01-31 10:22   ` Wolfram Sang

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).