 
 #
-# Patch managed by http://www.holgerschurig.de/patcher.html
+# Patch managed by http://www.mn-logistik.de/unsupported/pxa250/patcher
 #
 
---- linux-2.6.16/arch/arm/mach-pxa/ezx.c~ezx-backlight-r1.patch
-+++ linux-2.6.16/arch/arm/mach-pxa/ezx.c
+--- linux-2.6.16/arch/arm/mach-pxa/ezx.c~ezx-backlight-r1.patch	2006-06-08 19:33:36.000000000 +0200
++++ linux-2.6.16/arch/arm/mach-pxa/ezx.c	2006-06-08 19:33:37.000000000 +0200
 @@ -274,34 +274,9 @@
  	.udc_command		= ezx_udc_command,
  };

+
+	spin_lock_irqsave(&bl_lock, flags);
+
+	printk( KERN_DEBUG "backlight last intensity was %d, new intensity is %d", last_intensity, intensity );
+	
+	if ( !last_intensity && intensity ) {
+		printk( KERN_DEBUG "backlight power ON" );
+		/* need to power on backlight */
+		PWM_CTRL0 = 2; /* pre-scaler */
+		PWM_PWDUTY0 = intensity; /* duty cycle */
+		PWM_PERVAL0 = 49; /* period */
+		pxa_set_cken(CKEN0_PWM0, 1); /* clock enable */
+		GPDR0 |= 0x00010000; /* set GPIO16 as output */
+		pxa_gpio_mode(GPIO16_PWM0_MD); /* set GPIO16 as output */
+	}
+	else if ( last_intensity && !intensity ) {
+		printk( KERN_DEBUG "backlight power OFF" );
+		/* need to power off backlight */
+		PWM_PWDUTY0 = 0;
+    		GAFR0_U &= 0xFFFFFFFC;
+    		GPDR0 &= 0xFFFEFFFF; //PWM0 is GPIO16, set PWM0 as input when turn off bklight
+		pxa_set_cken(CKEN0_PWM0, 0); /* clock disable */
+	} else if ( last_intensity && intensity ) {
+		printk( KERN_DEBUG "backlight adjusting duty cycle" );
+		/* need to adjust duty cycle */
+		PWM_PWDUTY0 = intensity; /* duty cycle */
+	}
+	spin_unlock_irqrestore(&bl_lock, flags);

+	return 0;
+}
+
+static int ezxbl_get_intensity(struct backlight_device *bd)
+{
+	return last_intensity;
+}
+
+static int ezxbl_set_intensity(struct backlight_device *bd)
+{
+	return ezxbl_send_intensity(ezx_backlight_device);
+}
+
+#ifdef CONFIG_PM
+static int ezxbl_suspend(struct platform_device *pdev, pm_message_t state)
+{
+	//set suspend flag
+	ezxbl_set_intensity(ezx_backlight_device);
+	return 0;
+}
+
+static int ezxbl_resume(struct platform_device *pdev)
+{
+	// set resume flag
+	ezxbl_set_intensity(ezx_backlight_device);
+	return 0;
+}
+#else
+#define ezxbl_suspend	NULL
+#define ezxbl_resume	NULL
+#endif
+
+static struct backlight_properties ezxbl_data = {
+	.owner          = THIS_MODULE,
+	.get_brightness = ezxbl_get_intensity,
+	.max_brightness = EZX_MAX_INTENSITY,
+	.update_status	= ezxbl_set_intensity,
+};
+
+static int __init ezxbl_probe(struct platform_device *pdev)
+{
+	ezx_backlight_device = backlight_device_register ("ezx-bl",
+		NULL, &ezxbl_data);
+	if (IS_ERR (ezx_backlight_device))
+		return PTR_ERR (ezx_backlight_device);
+
+	ezxbl_data.power = FB_BLANK_UNBLANK;
+	ezxbl_data.brightness = EZX_DEFAULT_INTENSITY;
+	ezxbl_set_intensity(ezx_backlight_device);
+
+	printk("EZX Backlight Driver Initialized.\n");
+	return 0;
+}
+
+static int ezxbl_remove(struct platform_device *pdev)
+{
+	backlight_device_unregister(ezx_backlight_device);
+
