|
@@ -1,5 +1,4 @@
|
|
-/* linux/arch/arm/plat-s3c24xx/gpiolib.c
|
|
|
|
- *
|
|
|
|
|
|
+/*
|
|
* Copyright (c) 2008-2010 Simtec Electronics
|
|
* Copyright (c) 2008-2010 Simtec Electronics
|
|
* http://armlinux.simtec.co.uk/
|
|
* http://armlinux.simtec.co.uk/
|
|
* Ben Dooks <ben@simtec.co.uk>
|
|
* Ben Dooks <ben@simtec.co.uk>
|
|
@@ -19,16 +18,17 @@
|
|
#include <linux/ioport.h>
|
|
#include <linux/ioport.h>
|
|
#include <linux/io.h>
|
|
#include <linux/io.h>
|
|
#include <linux/gpio.h>
|
|
#include <linux/gpio.h>
|
|
|
|
+#include <asm/irq.h>
|
|
|
|
+
|
|
|
|
+#include <mach/hardware.h>
|
|
|
|
+#include <mach/gpio-fns.h>
|
|
|
|
+#include <mach/regs-gpio.h>
|
|
|
|
|
|
#include <plat/gpio-core.h>
|
|
#include <plat/gpio-core.h>
|
|
#include <plat/gpio-cfg.h>
|
|
#include <plat/gpio-cfg.h>
|
|
#include <plat/gpio-cfg-helpers.h>
|
|
#include <plat/gpio-cfg-helpers.h>
|
|
-#include <mach/hardware.h>
|
|
|
|
-#include <asm/irq.h>
|
|
|
|
#include <plat/pm.h>
|
|
#include <plat/pm.h>
|
|
|
|
|
|
-#include <mach/regs-gpio.h>
|
|
|
|
-
|
|
|
|
static int s3c24xx_gpiolib_banka_input(struct gpio_chip *chip, unsigned offset)
|
|
static int s3c24xx_gpiolib_banka_input(struct gpio_chip *chip, unsigned offset)
|
|
{
|
|
{
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
@@ -210,7 +210,6 @@ struct s3c_gpio_chip s3c24xx_gpios[] = {
|
|
},
|
|
},
|
|
};
|
|
};
|
|
|
|
|
|
-
|
|
|
|
static __init int s3c24xx_gpiolib_init(void)
|
|
static __init int s3c24xx_gpiolib_init(void)
|
|
{
|
|
{
|
|
struct s3c_gpio_chip *chip = s3c24xx_gpios;
|
|
struct s3c_gpio_chip *chip = s3c24xx_gpios;
|
|
@@ -225,5 +224,60 @@ static __init int s3c24xx_gpiolib_init(void)
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
-
|
|
|
|
core_initcall(s3c24xx_gpiolib_init);
|
|
core_initcall(s3c24xx_gpiolib_init);
|
|
|
|
+
|
|
|
|
+/* gpiolib wrappers until these are totally eliminated */
|
|
|
|
+
|
|
|
|
+void s3c2410_gpio_pullup(unsigned int pin, unsigned int to)
|
|
|
|
+{
|
|
|
|
+ int ret;
|
|
|
|
+
|
|
|
|
+ WARN_ON(to); /* should be none of these left */
|
|
|
|
+
|
|
|
|
+ if (!to) {
|
|
|
|
+ /* if pull is enabled, try first with up, and if that
|
|
|
|
+ * fails, try using down */
|
|
|
|
+
|
|
|
|
+ ret = s3c_gpio_setpull(pin, S3C_GPIO_PULL_UP);
|
|
|
|
+ if (ret)
|
|
|
|
+ s3c_gpio_setpull(pin, S3C_GPIO_PULL_DOWN);
|
|
|
|
+ } else {
|
|
|
|
+ s3c_gpio_setpull(pin, S3C_GPIO_PULL_NONE);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+EXPORT_SYMBOL(s3c2410_gpio_pullup);
|
|
|
|
+
|
|
|
|
+void s3c2410_gpio_setpin(unsigned int pin, unsigned int to)
|
|
|
|
+{
|
|
|
|
+ /* do this via gpiolib until all users removed */
|
|
|
|
+
|
|
|
|
+ gpio_request(pin, "temporary");
|
|
|
|
+ gpio_set_value(pin, to);
|
|
|
|
+ gpio_free(pin);
|
|
|
|
+}
|
|
|
|
+EXPORT_SYMBOL(s3c2410_gpio_setpin);
|
|
|
|
+
|
|
|
|
+unsigned int s3c2410_gpio_getpin(unsigned int pin)
|
|
|
|
+{
|
|
|
|
+ struct s3c_gpio_chip *chip = s3c_gpiolib_getchip(pin);
|
|
|
|
+ unsigned long offs = pin - chip->chip.base;
|
|
|
|
+
|
|
|
|
+ return __raw_readl(chip->base + 0x04) & (1<< offs);
|
|
|
|
+}
|
|
|
|
+EXPORT_SYMBOL(s3c2410_gpio_getpin);
|
|
|
|
+
|
|
|
|
+unsigned int s3c2410_modify_misccr(unsigned int clear, unsigned int change)
|
|
|
|
+{
|
|
|
|
+ unsigned long flags;
|
|
|
|
+ unsigned long misccr;
|
|
|
|
+
|
|
|
|
+ local_irq_save(flags);
|
|
|
|
+ misccr = __raw_readl(S3C24XX_MISCCR);
|
|
|
|
+ misccr &= ~clear;
|
|
|
|
+ misccr ^= change;
|
|
|
|
+ __raw_writel(misccr, S3C24XX_MISCCR);
|
|
|
|
+ local_irq_restore(flags);
|
|
|
|
+
|
|
|
|
+ return misccr;
|
|
|
|
+}
|
|
|
|
+EXPORT_SYMBOL(s3c2410_modify_misccr);
|