summaryrefslogtreecommitdiff
path: root/arch/arm/mach-s3c24xx/setup-camif.c
diff options
context:
space:
mode:
authorOlof Johansson <olof@lixom.net>2015-08-11 14:59:02 +0200
committerOlof Johansson <olof@lixom.net>2015-08-11 14:59:02 +0200
commit28d250c4ed03e148ea98db6e5bb614002606adc2 (patch)
treec0728a977cac706ba59617f712897543cb0e3f50 /arch/arm/mach-s3c24xx/setup-camif.c
parentfc293f5f2a2d94b889666c3dc3faa09f6b55e3e3 (diff)
parentd306d08f07183fe1504257101b25b5b33d77bae9 (diff)
Merge tag 'samsung-cleanup' of git://git.kernel.org/pub/scm/linux/kernel/git/kgene/linux-samsung into next/cleanup
Samsung cleanup for v4.3 - make the following headers local watchdog-reset, onenand-core, irq-uart, backlight, ata-core, regs-usb-hsotg-phy, spi-core, nand-core, fb-core and regs-srom headers - make the following c file local s5p-dev-mfc, dev-backlight and setup-camif c file - remove keypad-core.h file - drop owner assignment in pmu.c - remove duplicated define of SLEEP_MAGIC - make exynos5420_powerdown_conf() staic * tag 'samsung-cleanup' of git://git.kernel.org/pub/scm/linux/kernel/git/kgene/linux-samsung: ARM: SAMSUNG: remove keypad-core header in plat-samsung ARM: SAMSUNG: local watchdog-reset header in mach-s3c64xx ARM: SAMSUNG: local onenand-core header in mach-s3c64xx ARM: SAMSUNG: local irq-uart header in mach-s3c64xx ARM: SAMSUNG: local backlight header in mach-s3c64xx ARM: SAMSUNG: local ata-core header in mach-s3c64xx ARM: SAMSUNG: local regs-usb-hsotg-phy header in mach-s3c64xx ARM: SAMSUNG: local spi-core header in mach-s3c24xx ARM: SAMSUNG: local nand-core header in mach-s3c24xx ARM: SAMSUNG: local fb-core header in mach-s3c24xx ARM: SAMSUNG: local regs-srom header in mach-exynos ARM: SAMSUNG: make local s5p-dev-mfc in mach-exynos ARM: SAMSUNG: make local dev-backlight in mach-s3c64xx ARM: SAMSUNG: make local setup-camif in mach-s3c24xx ARM: EXYNOS: Drop owner assignment in pmu.c ARM: EXYNOS: Remove duplicated define of SLEEP_MAGIC ARM: EXYNOS: Make local function static Signed-off-by: Olof Johansson <olof@lixom.net>
Diffstat (limited to 'arch/arm/mach-s3c24xx/setup-camif.c')
-rw-r--r--arch/arm/mach-s3c24xx/setup-camif.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/arch/arm/mach-s3c24xx/setup-camif.c b/arch/arm/mach-s3c24xx/setup-camif.c
new file mode 100644
index 000000000000..72d8edb8927a
--- /dev/null
+++ b/arch/arm/mach-s3c24xx/setup-camif.c
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2012 Sylwester Nawrocki <sylvester.nawrocki@gmail.com>
+ *
+ * Helper functions for S3C24XX/S3C64XX SoC series CAMIF driver
+ *
+ * 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/gpio.h>
+#include <plat/gpio-cfg.h>
+#include <mach/gpio-samsung.h>
+
+/* Number of camera port pins, without FIELD */
+#define S3C_CAMIF_NUM_GPIOS 13
+
+/* Default camera port configuration helpers. */
+
+static void camif_get_gpios(int *gpio_start, int *gpio_reset)
+{
+#ifdef CONFIG_ARCH_S3C24XX
+ *gpio_start = S3C2410_GPJ(0);
+ *gpio_reset = S3C2410_GPJ(12);
+#else
+ /* s3c64xx */
+ *gpio_start = S3C64XX_GPF(0);
+ *gpio_reset = S3C64XX_GPF(3);
+#endif
+}
+
+int s3c_camif_gpio_get(void)
+{
+ int gpio_start, gpio_reset;
+ int ret, i;
+
+ camif_get_gpios(&gpio_start, &gpio_reset);
+
+ for (i = 0; i < S3C_CAMIF_NUM_GPIOS; i++) {
+ int gpio = gpio_start + i;
+
+ if (gpio == gpio_reset)
+ continue;
+
+ ret = gpio_request(gpio, "camif");
+ if (!ret)
+ ret = s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
+ if (ret) {
+ pr_err("failed to configure GPIO %d\n", gpio);
+ for (--i; i >= 0; i--)
+ gpio_free(gpio--);
+ return ret;
+ }
+ s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
+ }
+
+ return 0;
+}
+
+void s3c_camif_gpio_put(void)
+{
+ int i, gpio_start, gpio_reset;
+
+ camif_get_gpios(&gpio_start, &gpio_reset);
+
+ for (i = 0; i < S3C_CAMIF_NUM_GPIOS; i++) {
+ int gpio = gpio_start + i;
+ if (gpio != gpio_reset)
+ gpio_free(gpio);
+ }
+}