From 7efbb2210ab7399aa8b7978d5827b4b1d5750465 Mon Sep 17 00:00:00 2001
From: yargil <yargil@free.fr>
Date: Wed, 17 Oct 2012 18:22:24 +0200
Subject: [PATCH] MINI2440: Add support of PWM timer

PWM_TIMER define the PWM timer used.
---
 arch/arm/mach-s3c24xx/mach-mini2440.c |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/arch/arm/mach-s3c24xx/mach-mini2440.c b/arch/arm/mach-s3c24xx/mach-mini2440.c
index 5d66fb2..7d226cf 100644
--- a/arch/arm/mach-s3c24xx/mach-mini2440.c
+++ b/arch/arm/mach-s3c24xx/mach-mini2440.c
@@ -513,6 +513,18 @@ static struct platform_device uda1340_codec = {
 		.id = -1,
 };
 
+#define PWM_TIMER 1	/* define the PWM timer and the GPB pin */
+#define S3C2410_GPB_TOUT(a)   (0x02 << (a*2))
+
+static struct platform_device mini2440_buzzer_device = {
+	.name = "pwm-gen",
+	.id = -1,
+	.dev = {
+		.parent = &s3c_device_timer[PWM_TIMER].dev,
+		.platform_data = (void *)PWM_TIMER,     /* timer number */
+	},
+};
+
 static struct platform_device *mini2440_devices[] __initdata = {
 	&s3c_device_ohci,
 	&s3c_device_wdt,
@@ -531,6 +543,8 @@ static struct platform_device *mini2440_devices[] __initdata = {
 	&uda1340_codec,
 	&mini2440_audio,
 	&samsung_asoc_dma,
+	&s3c_device_timer[PWM_TIMER],
+	&mini2440_buzzer_device,
 };
 
 static void __init mini2440_map_io(void)
@@ -686,6 +700,10 @@ static void __init mini2440_init(void)
 	i2c_register_board_info(0, mini2440_i2c_devs,
 				ARRAY_SIZE(mini2440_i2c_devs));
 
+	/* Connect the PWM timer to the GPB pin */
+	s3c_gpio_cfgpin(S3C2410_GPB(PWM_TIMER), S3C2410_GPB_TOUT(PWM_TIMER));
+//	s3c_gpio_cfgpin(S3C2410_GPB(1), S3C2410_GPB1_TOUT1); // PWM timer1 use GPB1
+
 	platform_add_devices(mini2440_devices, ARRAY_SIZE(mini2440_devices));
 
 	if (features.count)	/* the optional features */
-- 
1.7.10.4

