Skip to contentSkip to conversation

ARM: OMAP2: TWL4030 RTC driver (v2)

PATCH New Dmitry Krivoschekov 1 participant 1 message Jun 1, 2007

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: OMAP2: TWL4030 RTC driver (v2)

This patch adds TWL4030 Real-Time Clock support for OMAP2430.

---

 arch/arm/mach-omap2/board-2430sdp.c     |   43 ++
 drivers/rtc/Kconfig                     |   10 
 drivers/rtc/Makefile                    |    1 
 drivers/rtc/rtc-twl4030.c               |  639 +++++++++++++++++++++++++++++++
 include/asm-arm/arch-omap/twl4030-rtc.h |  230 +++++++++++
 5 files changed, 923 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/board-2430sdp.c +43 -0
index ab9b23b..047a4e6 100644
@@ -38,6 +38,7 @@
 #include <asm/arch/keypad.h>
 #include <asm/arch/gpmc.h>
 #include <asm/arch/mcspi.h>
+#include <asm/arch/twl4030-rtc.h>
 
 #include <asm/io.h>
 
@@ -50,6 +51,8 @@
  * that driver is used for the touchscreen. */
 #define TS_GPIO                 24
 
+#define TWL4030_MSECURE_GPIO	118
+
 static struct mtd_partition sdp2430_partitions[] = {
 	/* bootloader (U-Boot, etc) in first sector */
 	{
@@ -183,11 +186,51 @@ static struct platform_device sdp2430_kp
 	},
 };
 
+static int twl4030_rtc_init(void)
+{
+	int ret = 0;
+
+	ret = omap_request_gpio(TWL4030_MSECURE_GPIO);
+	if (ret < 0) {
+		printk(KERN_ERR "twl4030_rtc_init: can't reserve GPIO:%d !\n",
+			TWL4030_MSECURE_GPIO);
+		goto out;
+	}
+	/*
+	 * TWL4030 will be in secure mode if msecure line from OMAP is low.
+	 * Make msecure line high in order to change the TWL4030 RTC time
+	 * and calender registers.
+	 */
+	omap_set_gpio_direction(TWL4030_MSECURE_GPIO, 0);	/*dir out */
+	omap_set_gpio_dataout(TWL4030_MSECURE_GPIO, 1);
+out:
+	return ret;
+}
+
+static void twl4030_rtc_exit(void)
+{
+	omap_free_gpio(TWL4030_MSECURE_GPIO);
+}
+
+static struct twl4030rtc_platform_data sdp2430_twl4030rtc_data = {
+	.init = &twl4030_rtc_init,
+	.exit = &twl4030_rtc_exit,
+};
+
+static struct platform_device sdp2430_twl4030rtc_device = {
+ 	.name		= "twl4030_rtc",
+ 	.id		= -1,
+	.dev		= {
+		.platform_data	= &sdp2430_twl4030rtc_data,
+	},
+};
+
 static struct platform_device *sdp2430_devices[] __initdata = {
 	&sdp2430_smc91x_device,
 	&sdp2430_flash_device,
 	&sdp2430_kp_device,
 	&sdp2430_lcd_device,
+	&sdp2430_twl4030rtc_device,	
 };
 
 static void ads7846_dev_init(void)
drivers/rtc/Kconfig +10 -0
index 4e4c10a..d54bc8f 100644
@@ -213,6 +213,16 @@ config RTC_DRV_PCF8583
 	  This driver can also be built as a module. If so, the module
 	  will be called rtc-pcf8583.
 
+config RTC_DRV_TWL4030
+	tristate "OMAP TWL4030 Real Time Clock"
+	depends on RTC_CLASS && TWL4030_CORE
+	help
+	  If you say yes here you get support for internal Real-Time 
+	  Clock of TWL4030 chip.
+	
+	  This driver can also be built as a module. If so, the module
+	  will be called rtc-twl4030.
+
 comment "SPI RTC drivers"
 	depends on RTC_CLASS
 
drivers/rtc/Makefile +1 -0
index a1afbc2..0423f8f 100644
@@ -41,3 +41,4 @@ obj-$(CONFIG_RTC_DRV_V3020)	+= rtc-v3020
 obj-$(CONFIG_RTC_DRV_AT91RM9200)+= rtc-at91rm9200.o
 obj-$(CONFIG_RTC_DRV_SH)	+= rtc-sh.o
 obj-$(CONFIG_RTC_DRV_BFIN)	+= rtc-bfin.o
+obj-$(CONFIG_RTC_DRV_TWL4030)	+= rtc-twl4030.o
drivers/rtc/rtc-twl4030.c new file +639 -0

639 lines not on this page · raw message

include/asm-arm/arch-omap/twl4030-rtc.h new file +230 -0

230 lines not on this page · raw message