r3196 - branches/src/target/kernel/2.6.23.x/patches

shoragan at sita.openmoko.org shoragan at sita.openmoko.org
Tue Oct 16 19:27:16 CEST 2007


Author: shoragan
Date: 2007-10-16 19:27:14 +0200 (Tue, 16 Oct 2007)
New Revision: 3196

Modified:
   branches/src/target/kernel/2.6.23.x/patches/gta01-backlight.patch
   branches/src/target/kernel/2.6.23.x/patches/gta01-vibrator.patch
   branches/src/target/kernel/2.6.23.x/patches/s3c2410-pwm.patch
Log:
Follow change in 2.6.22:
(orig r3179):  laforge | 2007-10-15 18:44:08 +0200

s3c2410_pwm:
* change structure name into one without _t suffix (it's not a typedef, thank god)
* don't allocate the pwm structure within s3c2410_pwm code, but rather embed it
  into other structures
* rename s3c2410_pwm variables into just 'pwm'
gta01-vibrator:
* adopt s3c2410_pwm api changes
* set gpio pwm mode at startup, not at every update
gta01-backlight:
* adopt s3c2410_pwm api changes


Modified: branches/src/target/kernel/2.6.23.x/patches/gta01-backlight.patch
===================================================================
--- branches/src/target/kernel/2.6.23.x/patches/gta01-backlight.patch	2007-10-16 16:39:39 UTC (rev 3195)
+++ branches/src/target/kernel/2.6.23.x/patches/gta01-backlight.patch	2007-10-16 17:27:14 UTC (rev 3196)
@@ -35,7 +35,7 @@
 ===================================================================
 --- /dev/null
 +++ linux-2.6.22.5-moko/drivers/video/backlight/gta01_bl.c
-@@ -0,0 +1,249 @@
+@@ -0,0 +1,253 @@
 +/*
 + *  Backlight Driver for FIC GTA01 (Neo1973) GSM Phone
 + *
@@ -89,7 +89,7 @@
 +	int intensity;
 +	struct mutex mutex;
 +	struct clk *clk;
-+	struct s3c2410_pwm_t *pwm;
++	struct s3c2410_pwm pwm;
 +};
 +
 +static struct gta01bl_data gta01bl;
@@ -130,7 +130,7 @@
 +		s3c2410_gpio_setpin(GTA01_GPIO_BACKLIGHT, 1);
 +		s3c2410_gpio_cfgpin(GTA01_GPIO_BACKLIGHT, S3C2410_GPIO_OUTPUT);
 +	} else  {
-+		s3c2410_pwm_duty_cycle(intensity & 0xffff, gta01bl.pwm);
++		s3c2410_pwm_duty_cycle(intensity & 0xffff, &gta01bl.pwm);
 +		s3c2410_gpio_cfgpin(GTA01_GPIO_BACKLIGHT, S3C2410_GPB0_TOUT0);
 +	}
 +#endif
@@ -140,18 +140,25 @@
 +	return 0;
 +}
 +
-+static void gta01bl_init_hw(void)
++static int gta01bl_init_hw(void)
 +{
-+	gta01bl.pwm->timerid = PWM0;
-+	gta01bl.pwm->prescaler = (4 - 1);
-+	gta01bl.pwm->divider = S3C2410_TCFG1_MUX0_DIV8;
-+	gta01bl.pwm->counter = (((gta01bl.pwm->pclk_rate) / 32) / GTA01BL_FREQ) -1;
-+	gta01bl.pwm->comparer = gta01bl.pwm->counter;
++	int rc;
 +
-+	s3c2410_pwm_enable(gta01bl.pwm);
-+	s3c2410_pwm_start(gta01bl.pwm);
++	gta01bl.pwm.timerid = PWM0;
++	gta01bl.pwm.prescaler = (4 - 1);
++	gta01bl.pwm.divider = S3C2410_TCFG1_MUX0_DIV8;
++	gta01bl.pwm.counter = (((gta01bl.pwm.pclk_rate) / 32) / GTA01BL_FREQ) -1;
++	gta01bl.pwm.comparer = gta01bl.pwm.counter;
 +
-+	gta01bl_prop.max_brightness = gta01bl.pwm->counter;
++	rc = s3c2410_pwm_enable(&gta01bl.pwm);
++	if (rc)
++		return rc;
++
++	s3c2410_pwm_start(&gta01bl.pwm);
++
++	gta01bl_prop.max_brightness = gta01bl.pwm.counter;
++
++	return 0;
 +}
 +
 +#ifdef CONFIG_PM
@@ -211,16 +218,15 @@
 +static int __init gta01bl_probe(struct platform_device *pdev)
 +{
 +	struct gta01bl_machinfo *machinfo = pdev->dev.platform_data;
++	int rc;
 +
 +#ifdef GTA01_BACKLIGHT_ONOFF_ONLY
 +	s3c2410_gpio_cfgpin(GTA01_GPIO_BACKLIGHT, S3C2410_GPIO_OUTPUT);
 +	gta01bl_prop.max_brightness = 1;
 +#else
-+	/* use s3c_device_timer0 for PWM */
-+	if (!(gta01bl.pwm = s3c2410_pwm_alloc()))
-+		return -ENOMEM;
-+
-+	gta01bl_init_hw();
++	rc = gta01bl_init_hw();
++	if (rc < 0)
++		return rc;
 +#endif
 +	mutex_init(&gta01bl.mutex);
 +
@@ -246,9 +252,7 @@
 +static int gta01bl_remove(struct platform_device *dev)
 +{
 +#ifndef GTA01_BACKLIGHT_ONOFF_ONLY
-+
-+	s3c2410_pwm_disable(gta01bl.pwm);
-+
++	s3c2410_pwm_disable(&gta01bl.pwm);
 +#endif
 +	backlight_device_unregister(gta01_backlight_device);
 +	mutex_destroy(&gta01bl.mutex);

Modified: branches/src/target/kernel/2.6.23.x/patches/gta01-vibrator.patch
===================================================================
--- branches/src/target/kernel/2.6.23.x/patches/gta01-vibrator.patch	2007-10-16 16:39:39 UTC (rev 3195)
+++ branches/src/target/kernel/2.6.23.x/patches/gta01-vibrator.patch	2007-10-16 17:27:14 UTC (rev 3196)
@@ -6,7 +6,7 @@
 ===================================================================
 --- /dev/null
 +++ linux-2.6.22.5-moko/drivers/leds/leds-gta01.c
-@@ -0,0 +1,188 @@
+@@ -0,0 +1,189 @@
 +/*
 + * LED driver for the FIC GTA01 (Neo1973) GSM Phone Vibrator
 + *
@@ -40,7 +40,7 @@
 +	unsigned int gpio;
 +	struct mutex mutex;
 +	unsigned int has_pwm;
-+	struct s3c2410_pwm_t *pwm;
++	struct s3c2410_pwm pwm;
 +};
 +
 +static inline struct gta01_vib_priv *pdev_to_vpriv(struct platform_device *dev)
@@ -65,8 +65,7 @@
 + 	 */
 + 	mutex_lock(&vp->mutex);
 +	if (vp->has_pwm) {
-+			s3c2410_pwm_duty_cycle(value/4, vp->pwm);
-+			s3c2410_gpio_cfgpin(vp->gpio, S3C2410_GPB3_TOUT3);
++		s3c2410_pwm_duty_cycle(value/4, &vp->pwm);
 +	} else {
 +		if (value)
 +			s3c2410_gpio_setpin(vp->gpio, 1);
@@ -96,21 +95,24 @@
 +}
 +#endif
 +
-+static void gta01vib_init_hw(struct platform_device *pdev)
++static int gta01vib_init_hw(struct gta01_vib_priv *vp)
 +{
-+	struct gta01_vib_priv *vp = pdev_to_vpriv(pdev);
++	int rc;
 +
-+	vp->pwm->timerid= PWM3;
++	vp->pwm.timerid= PWM3;
 +	/* use same prescaler as arch/arm/plat-s3c24xx/time.c */
-+	vp->pwm->prescaler = (6 - 1) / 2;
-+	vp->pwm->divider = S3C2410_TCFG1_MUX3_DIV2;
-+	vp->pwm->counter = COUNTER;
-+	vp->pwm->comparer = COUNTER;
++	vp->pwm.prescaler = (6 - 1) / 2;
++	vp->pwm.divider = S3C2410_TCFG1_MUX3_DIV2;
++	vp->pwm.counter = COUNTER;
++	vp->pwm.comparer = COUNTER;
 +
-+	s3c2410_pwm_enable(vp->pwm);
-+	s3c2410_pwm_start(vp->pwm);
++	rc = s3c2410_pwm_enable(&vp->pwm);
++	if (rc)
++		return rc;
 +
-+	return;
++	s3c2410_pwm_start(&vp->pwm);
++
++	return 0;
 +}
 +
 +static int __init gta01vib_probe(struct platform_device *pdev)
@@ -129,25 +131,24 @@
 +	if (!vp)
 +		return -ENOMEM;
 +
-+	platform_set_drvdata(pdev, vp);
-+
 +	vp->gpio = r->start;
 +
 +	/* TOUT3 */
 +	if (vp->gpio == S3C2410_GPB3) {
-+		vp->has_pwm = 1;
++		int rc;
 +
-+		vp->pwm = s3c2410_pwm_alloc();
-+		if (!vp->pwm) {
-+			dev_err(&pdev->dev, "PWM allocation failed\n");
++		rc = gta01vib_init_hw(vp);
++		if (rc) {
 +			kfree(vp);
-+			return -ENOMEM;
++			return rc;
 +		}
 +
-+		gta01vib_init_hw(pdev);
++		s3c2410_gpio_cfgpin(vp->gpio, S3C2410_GPB3_TOUT3);
++		vp->has_pwm = 1;
 +	}
 +
 +	mutex_init(&vp->mutex);
++	platform_set_drvdata(pdev, vp);
 +
 +	return led_classdev_register(&pdev->dev, &gta01_vib_led);
 +}
@@ -157,7 +158,7 @@
 +	struct gta01_vib_priv *vp = pdev_to_vpriv(pdev);
 +
 +	if (vp->has_pwm)
-+		s3c2410_pwm_disable(vp->pwm);
++		s3c2410_pwm_disable(&vp->pwm);
 +
 +	led_classdev_unregister(&gta01_vib_led);
 +	platform_set_drvdata(pdev, NULL);

Modified: branches/src/target/kernel/2.6.23.x/patches/s3c2410-pwm.patch
===================================================================
--- branches/src/target/kernel/2.6.23.x/patches/s3c2410-pwm.patch	2007-10-16 16:39:39 UTC (rev 3195)
+++ branches/src/target/kernel/2.6.23.x/patches/s3c2410-pwm.patch	2007-10-16 17:27:14 UTC (rev 3196)
@@ -1,7 +1,7 @@
-Index: linux-2.6.22/arch/arm/mach-s3c2410/Kconfig
+Index: linux-2.6.23/arch/arm/mach-s3c2410/Kconfig
 ===================================================================
---- linux-2.6.22.orig/arch/arm/mach-s3c2410/Kconfig
-+++ linux-2.6.22/arch/arm/mach-s3c2410/Kconfig
+--- linux-2.6.23.orig/arch/arm/mach-s3c2410/Kconfig
++++ linux-2.6.23/arch/arm/mach-s3c2410/Kconfig
 @@ -9,6 +9,7 @@
  	depends on ARCH_S3C2410
  	select S3C2410_CLOCK
@@ -22,10 +22,10 @@
  
  menu "S3C2410 Machines"
  
-Index: linux-2.6.22/arch/arm/mach-s3c2410/Makefile
+Index: linux-2.6.23/arch/arm/mach-s3c2410/Makefile
 ===================================================================
---- linux-2.6.22.orig/arch/arm/mach-s3c2410/Makefile
-+++ linux-2.6.22/arch/arm/mach-s3c2410/Makefile
+--- linux-2.6.23.orig/arch/arm/mach-s3c2410/Makefile
++++ linux-2.6.23/arch/arm/mach-s3c2410/Makefile
 @@ -16,6 +16,7 @@
  obj-$(CONFIG_S3C2410_PM)	+= pm.o sleep.o
  obj-$(CONFIG_S3C2410_GPIO)	+= gpio.o
@@ -34,11 +34,11 @@
  
  # Machine support
  
-Index: linux-2.6.22/arch/arm/mach-s3c2410/pwm.c
+Index: linux-2.6.23/arch/arm/mach-s3c2410/pwm.c
 ===================================================================
 --- /dev/null
-+++ linux-2.6.22/arch/arm/mach-s3c2410/pwm.c
-@@ -0,0 +1,234 @@
++++ linux-2.6.23/arch/arm/mach-s3c2410/pwm.c
+@@ -0,0 +1,210 @@
 +/*
 + * arch/arm/mach-s3c2410/3c2410-pwm.c
 + *
@@ -65,34 +65,8 @@
 +#include <asm/plat-s3c/regs-timer.h>
 +#include <asm/arch/pwm.h>
 +
-+struct s3c2410_pwm_t *s3c2410_pwm_alloc(void)
++int s3c2410_pwm_disable(struct s3c2410_pwm *pwm)
 +{
-+	struct s3c2410_pwm_t *s3c2410_pwm;
-+
-+        s3c2410_pwm = kzalloc(sizeof(*s3c2410_pwm), GFP_KERNEL);
-+        if (!s3c2410_pwm)
-+                /*return -ENOMEM;*/
-+		return NULL;
-+
-+	s3c2410_pwm->pclk = clk_get(NULL, "timers");
-+
-+	if (IS_ERR(s3c2410_pwm->pclk)) {
-+		/*return PTR_ERR(clk);*/
-+		kfree(s3c2410_pwm);
-+		return NULL;
-+	}
-+
-+	clk_enable(s3c2410_pwm->pclk);
-+
-+	s3c2410_pwm->pclk_rate = clk_get_rate(s3c2410_pwm->pclk);
-+
-+	return s3c2410_pwm;
-+}
-+
-+EXPORT_SYMBOL_GPL(s3c2410_pwm_alloc);
-+
-+int s3c2410_pwm_disable(struct s3c2410_pwm_t *s3c2410_pwm)
-+{
 +	unsigned long tcon;
 +
 +	/* stop timer */
@@ -100,25 +74,31 @@
 +        tcon &= 0xffffff00;
 +        __raw_writel(tcon, S3C2410_TCON);
 +
-+	clk_disable(s3c2410_pwm->pclk);
-+	clk_put(s3c2410_pwm->pclk);
++	clk_disable(pwm->pclk);
++	clk_put(pwm->pclk);
 +
-+	kfree(s3c2410_pwm);
++	kfree(pwm);
 +	return 0;
 +}
-+
 +EXPORT_SYMBOL_GPL(s3c2410_pwm_disable);
 +
-+int s3c2410_pwm_enable(struct s3c2410_pwm_t *s3c2410_pwm)
++int s3c2410_pwm_enable(struct s3c2410_pwm *pwm)
 +{
 +	unsigned long tcfg0, tcfg1, tcnt, tcmp;
 +
++	pwm->pclk = clk_get(NULL, "timers");
++	if (IS_ERR(pwm->pclk))
++		return PTR_ERR(pwm->pclk);
++
++	clk_enable(pwm->pclk);
++	pwm->pclk_rate = clk_get_rate(pwm->pclk);
++
 +	/* control registers bits */
 +	tcfg1 = __raw_readl(S3C2410_TCFG1);
 +	tcfg0 = __raw_readl(S3C2410_TCFG0);
 +
 +	/* divider & scaler slection */
-+	switch (s3c2410_pwm->timerid) {
++	switch (pwm->timerid) {
 +	case PWM0:
 +		tcfg1 &= ~S3C2410_TCFG1_MUX0_MASK;
 +		tcfg0 &= ~S3C2410_TCFG_PRESCALER0_MASK;
@@ -139,50 +119,51 @@
 +		/* timer four is not capable of doing PWM */
 +		break;
 +	default:
++		clk_disable(pwm->pclk);
++		clk_put(pwm->pclk);
 +		return -1;
 +	}
 +
 +	/* divider & scaler values */
-+	tcfg1 |= s3c2410_pwm->divider;
++	tcfg1 |= pwm->divider;
 +	__raw_writel(tcfg1, S3C2410_TCFG1);
 +
-+	switch (s3c2410_pwm->timerid) {
++	switch (pwm->timerid) {
 +	case PWM0:
 +	case PWM1:
-+		tcfg0 |= s3c2410_pwm->prescaler;
++		tcfg0 |= pwm->prescaler;
 +		__raw_writel(tcfg0, S3C2410_TCFG0);
 +		break;
 +	default:
-+		if ((tcfg0 | s3c2410_pwm->prescaler) != tcfg0) {
++		if ((tcfg0 | pwm->prescaler) != tcfg0) {
 +			printk(KERN_WARNING "not changing prescaler of PWM %u,"
 +			       " since it's shared with timer4 (clock tick)\n",
-+			       s3c2410_pwm->timerid);
++			       pwm->timerid);
 +		}
 +		break;
 +	}
 +
 +	/* timer count and compare buffer initial values */
-+	tcnt = s3c2410_pwm->counter;
-+	tcmp = s3c2410_pwm->comparer;
++	tcnt = pwm->counter;
++	tcmp = pwm->comparer;
 +
-+	__raw_writel(tcnt, S3C2410_TCNTB(s3c2410_pwm->timerid));
-+	__raw_writel(tcmp, S3C2410_TCMPB(s3c2410_pwm->timerid));
++	__raw_writel(tcnt, S3C2410_TCNTB(pwm->timerid));
++	__raw_writel(tcmp, S3C2410_TCMPB(pwm->timerid));
 +
 +	/* ensure timer is stopped */
-+	s3c2410_pwm_stop(s3c2410_pwm);
++	s3c2410_pwm_stop(pwm);
 +
 +	return 0;
 +}
-+
 +EXPORT_SYMBOL_GPL(s3c2410_pwm_enable);
 +
-+int s3c2410_pwm_start(struct s3c2410_pwm_t *s3c2410_pwm)
++int s3c2410_pwm_start(struct s3c2410_pwm *pwm)
 +{
 +	unsigned long tcon;
 +
 +	tcon = __raw_readl(S3C2410_TCON);
 +
-+	switch (s3c2410_pwm->timerid) {
++	switch (pwm->timerid) {
 +	case PWM0:
 +		tcon |= S3C2410_TCON_T0START;
 +		tcon &= ~S3C2410_TCON_T0MANUALUPD;
@@ -202,23 +183,22 @@
 +	case PWM4:
 +		/* timer four is not capable of doing PWM */
 +	default:
-+		return -1;
++		return -ENODEV;
 +	}
 +
 +	__raw_writel(tcon, S3C2410_TCON);
 +
 +	return 0;
 +}
-+
 +EXPORT_SYMBOL_GPL(s3c2410_pwm_start);
 +
-+int s3c2410_pwm_stop(struct s3c2410_pwm_t *s3c2410_pwm)
++int s3c2410_pwm_stop(struct s3c2410_pwm *pwm)
 +{
 +	unsigned long tcon;
 +
 +	tcon = __raw_readl(S3C2410_TCON);
 +
-+	switch (s3c2410_pwm->timerid) {
++	switch (pwm->timerid) {
 +	case PWM0:
 +		tcon &= ~0x00000000;
 +		tcon |= S3C2410_TCON_T0RELOAD;
@@ -242,23 +222,21 @@
 +	case PWM4:
 +		/* timer four is not capable of doing PWM */
 +	default:
-+		return -1;
++		return -ENODEV;
 +	}
 +
 +	__raw_writel(tcon, S3C2410_TCON);
 +
 +	return 0;
 +}
-+
 +EXPORT_SYMBOL_GPL(s3c2410_pwm_stop);
 +
-+int s3c2410_pwm_duty_cycle(int reg_value, struct s3c2410_pwm_t *s3c2410_pwm)
++int s3c2410_pwm_duty_cycle(int reg_value, struct s3c2410_pwm *pwm)
 +{
-+	__raw_writel(reg_value, S3C2410_TCMPB(s3c2410_pwm->timerid));
++	__raw_writel(reg_value, S3C2410_TCMPB(pwm->timerid));
 +
 +	return 0;
 +}
-+
 +EXPORT_SYMBOL_GPL(s3c2410_pwm_duty_cycle);
 +
 +int s3c2410_pwm_dumpregs(void)
@@ -270,14 +248,12 @@
 +
 +	return 0;
 +}
-+
 +EXPORT_SYMBOL_GPL(s3c2410_pwm_dumpregs);
-+
-Index: linux-2.6.22/include/asm-arm/arch-s3c2410/pwm.h
+Index: linux-2.6.23/include/asm-arm/arch-s3c2410/pwm.h
 ===================================================================
 --- /dev/null
-+++ linux-2.6.22/include/asm-arm/arch-s3c2410/pwm.h
-@@ -0,0 +1,39 @@
++++ linux-2.6.23/include/asm-arm/arch-s3c2410/pwm.h
+@@ -0,0 +1,38 @@
 +#ifndef __S3C2410_PWM_H
 +#define __S3C2410_PWM_H
 +
@@ -298,7 +274,7 @@
 +	PWM4
 +};
 +
-+struct s3c2410_pwm_t {
++struct s3c2410_pwm {
 +	enum pwm_timer timerid;
 +	struct clk *pclk;
 +	unsigned long pclk_rate;
@@ -308,12 +284,11 @@
 +	unsigned long comparer;
 +};
 +
-+struct s3c2410_pwm_t *s3c2410_pwm_alloc(void);
-+int s3c2410_pwm_enable(struct s3c2410_pwm_t *s3c2410_pwm);
-+int s3c2410_pwm_disable(struct s3c2410_pwm_t *s3c2410_pwm);
-+int s3c2410_pwm_start(struct s3c2410_pwm_t *s3c2410_pwm);
-+int s3c2410_pwm_stop(struct s3c2410_pwm_t *s3c2410_pwm);
-+int s3c2410_pwm_duty_cycle(int reg_value, struct s3c2410_pwm_t *s3c2410_pwm);
++int s3c2410_pwm_enable(struct s3c2410_pwm *s3c2410_pwm);
++int s3c2410_pwm_disable(struct s3c2410_pwm *s3c2410_pwm);
++int s3c2410_pwm_start(struct s3c2410_pwm *s3c2410_pwm);
++int s3c2410_pwm_stop(struct s3c2410_pwm *s3c2410_pwm);
++int s3c2410_pwm_duty_cycle(int reg_value, struct s3c2410_pwm *s3c2410_pwm);
 +int s3c2410_pwm_dumpregs(void);
 +
 +#endif /* __S3C2410_PWM_H */





More information about the commitlog mailing list