root/arch/arm/mach-s3c24xx/setup-camif.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. camif_get_gpios
  2. s3c_camif_gpio_get
  3. s3c_camif_gpio_put

   1 // SPDX-License-Identifier: GPL-2.0
   2 //
   3 // Copyright (C) 2012 Sylwester Nawrocki <sylvester.nawrocki@gmail.com>
   4 //
   5 // Helper functions for S3C24XX/S3C64XX SoC series CAMIF driver
   6 
   7 #include <linux/gpio.h>
   8 #include <plat/gpio-cfg.h>
   9 #include <mach/gpio-samsung.h>
  10 
  11 /* Number of camera port pins, without FIELD */
  12 #define S3C_CAMIF_NUM_GPIOS     13
  13 
  14 /* Default camera port configuration helpers. */
  15 
  16 static void camif_get_gpios(int *gpio_start, int *gpio_reset)
  17 {
  18 #ifdef CONFIG_ARCH_S3C24XX
  19         *gpio_start = S3C2410_GPJ(0);
  20         *gpio_reset = S3C2410_GPJ(12);
  21 #else
  22         /* s3c64xx */
  23         *gpio_start = S3C64XX_GPF(0);
  24         *gpio_reset = S3C64XX_GPF(3);
  25 #endif
  26 }
  27 
  28 int s3c_camif_gpio_get(void)
  29 {
  30         int gpio_start, gpio_reset;
  31         int ret, i;
  32 
  33         camif_get_gpios(&gpio_start, &gpio_reset);
  34 
  35         for (i = 0; i < S3C_CAMIF_NUM_GPIOS; i++) {
  36                 int gpio = gpio_start + i;
  37 
  38                 if (gpio == gpio_reset)
  39                         continue;
  40 
  41                 ret = gpio_request(gpio, "camif");
  42                 if (!ret)
  43                         ret = s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
  44                 if (ret) {
  45                         pr_err("failed to configure GPIO %d\n", gpio);
  46                         for (--i; i >= 0; i--)
  47                                 gpio_free(gpio--);
  48                         return ret;
  49                 }
  50                 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
  51         }
  52 
  53         return 0;
  54 }
  55 
  56 void s3c_camif_gpio_put(void)
  57 {
  58         int i, gpio_start, gpio_reset;
  59 
  60         camif_get_gpios(&gpio_start, &gpio_reset);
  61 
  62         for (i = 0; i < S3C_CAMIF_NUM_GPIOS; i++) {
  63                 int gpio = gpio_start + i;
  64                 if (gpio != gpio_reset)
  65                         gpio_free(gpio);
  66         }
  67 }

/* [<][>][^][v][top][bottom][index][help] */