ARM: S3C64XX: Add S3C64XX support to the generic Samsung ADC driver
authorMaurus Cuelenaere <mcuelenaere@gmail.com>
Wed, 13 Jan 2010 23:30:34 +0000 (00:30 +0100)
committerBen Dooks <ben-linux@fluff.org>
Mon, 18 Jan 2010 00:30:49 +0000 (09:30 +0900)
Add S3C64XX support to the generic Samsung ADC driver

Signed-off-by: Maurus Cuelenaere <mcuelenaere@gmail.com>
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
arch/arm/mach-s3c6400/include/mach/map.h
arch/arm/plat-s3c/include/plat/regs-adc.h
arch/arm/plat-s3c64xx/Makefile
arch/arm/plat-s3c64xx/dev-adc.c [new file with mode: 0644]
arch/arm/plat-samsung/adc.c

index d4cd3abe3cba7144d26948b2cfba64c14e82a845..5a35f24fcb80efc0967d8366aa13902dfb27215e 100644 (file)
@@ -42,6 +42,7 @@
 #define S3C64XX_PA_FB          (0x77100000)
 #define S3C64XX_PA_USB_HSOTG   (0x7C000000)
 #define S3C64XX_PA_WATCHDOG    (0x7E004000)
+#define S3C64XX_PA_ADC         (0x7E00B000)
 #define S3C64XX_PA_SYSCON      (0x7E00F000)
 #define S3C64XX_PA_AC97                (0x7F001000)
 #define S3C64XX_PA_IIS0                (0x7F002000)
index 4323cccc86cd916b2452882b76ce644796728f1b..f43c8dab39e4cd1367b599b65b299f13fefe584f 100644 (file)
@@ -19,6 +19,9 @@
 #define S3C2410_ADCDLY    S3C2410_ADCREG(0x08)
 #define S3C2410_ADCDAT0           S3C2410_ADCREG(0x0C)
 #define S3C2410_ADCDAT1           S3C2410_ADCREG(0x10)
+#define S3C64XX_ADCUPDN                S3C2410_ADCREG(0x14)
+#define S3C64XX_ADCCLRINT      S3C2410_ADCREG(0x18)
+#define S3C64XX_ADCCLRINTPNDNUP        S3C2410_ADCREG(0x20)
 
 
 /* ADCCON Register Bits */
index b85b4359e935fa9c3d0fd5ab4abc3ca22e27f3fe..80600176cf2acc549959bfa225e9ad504b2fd0fe 100644 (file)
@@ -35,6 +35,10 @@ obj-$(CONFIG_PM)             += irq-pm.o
 
 obj-$(CONFIG_S3C64XX_DMA)      += dma.o
 
+# ADC support
+
+obj-$(CONFIG_S3C_ADC)          += dev-adc.o
+
 # Device setup
 
 obj-$(CONFIG_S3C64XX_SETUP_I2C0) += setup-i2c0.o
diff --git a/arch/arm/plat-s3c64xx/dev-adc.c b/arch/arm/plat-s3c64xx/dev-adc.c
new file mode 100644 (file)
index 0000000..fafef9b
--- /dev/null
@@ -0,0 +1,46 @@
+/* linux/arch/arm/plat-s3c64xx/dev-adc.c
+ *
+ * Copyright 2010 Maurus Cuelenaere
+ *
+ * S3C64xx series device definition for ADC device
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+*/
+
+#include <linux/kernel.h>
+#include <linux/string.h>
+#include <linux/platform_device.h>
+
+#include <mach/irqs.h>
+#include <mach/map.h>
+
+#include <plat/adc.h>
+#include <plat/devs.h>
+#include <plat/cpu.h>
+
+static struct resource s3c_adc_resource[] = {
+       [0] = {
+               .start = S3C64XX_PA_ADC,
+               .end   = S3C64XX_PA_ADC + SZ_256 - 1,
+               .flags = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start = IRQ_TC,
+               .end   = IRQ_TC,
+               .flags = IORESOURCE_IRQ,
+       },
+       [2] = {
+               .start = IRQ_ADC,
+               .end   = IRQ_ADC,
+               .flags = IORESOURCE_IRQ,
+       },
+};
+
+struct platform_device s3c_device_adc = {
+       .name           = "s3c64xx-adc",
+       .id             = -1,
+       .num_resources  = ARRAY_SIZE(s3c_adc_resource),
+       .resource       = s3c_adc_resource,
+};
index a8843dd5e1e7b7f4a242934b53c550d2ad0f2d85..120b7902fc2fd02a6b55512cbfaf74d296ac4775 100644 (file)
  * action is required.
  */
 
+enum s3c_cpu_type {
+       TYPE_S3C24XX,
+       TYPE_S3C64XX
+};
+
 struct s3c_adc_client {
        struct platform_device  *pdev;
        struct list_head         pend;
@@ -262,7 +267,7 @@ static irqreturn_t s3c_adc_irq(int irq, void *pw)
 
        if (!client) {
                dev_warn(&adc->pdev->dev, "%s: no adc pending\n", __func__);
-               return IRQ_HANDLED;
+               goto exit;
        }
 
        data0 = readl(adc->regs + S3C2410_ADCDAT0);
@@ -289,6 +294,11 @@ static irqreturn_t s3c_adc_irq(int irq, void *pw)
                local_irq_restore(flags);
        }
 
+exit:
+       if (platform_get_device_id(client->pdev)->driver_data == TYPE_S3C64XX) {
+               /* Clear ADC interrupt */
+               writel(0, adc->regs + S3C64XX_ADCCLRINT);
+       }
        return IRQ_HANDLED;
 }
 
@@ -410,9 +420,22 @@ static int s3c_adc_resume(struct platform_device *pdev)
 #define s3c_adc_resume NULL
 #endif
 
+static struct platform_device_id s3c_adc_driver_ids[] = {
+       {
+               .name           = "s3c24xx-adc",
+               .driver_data    = TYPE_S3C24XX,
+       }, {
+               .name           = "s3c64xx-adc",
+               .driver_data    = TYPE_S3C64XX,
+       },
+       { }
+};
+MODULE_DEVICE_TABLE(platform, s3c_adc_driver_ids);
+
 static struct platform_driver s3c_adc_driver = {
+       .id_table       = s3c_adc_driver_ids,
        .driver         = {
-               .name   = "s3c24xx-adc",
+               .name   = "s3c-adc",
                .owner  = THIS_MODULE,
        },
        .probe          = s3c_adc_probe,