All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kukjin Kim <kgene@kernel.org>
To: 'Sylwester Nawrocki' <sylvester.nawrocki@gmail.com>
Cc: linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Subject: RE: [PATCH] ARM: SAMSUNG: Add s3c24xx/s3c64xx CAMIF GPIO setup helpers
Date: Thu, 22 Nov 2012 15:51:15 +0900	[thread overview]
Message-ID: <0f5b01cdc87d$c447f610$4cd7e230$@org> (raw)
In-Reply-To: <1353357262-18935-1-git-send-email-sylvester.nawrocki@gmail.com>

Sylwester Nawrocki wrote:
> 
> This patch adds default helper functions for the camera port
> pin configuration. Whenever pinctrl support for s3c24xx/s3c64xx
> SoCs is available these code should be removed and proper pinctrl
> API should be used in the CAMIF driver.
> 
> Signed-off-by: Sylwester Nawrocki <sylvester.nawrocki@gmail.com>
> ---
>  arch/arm/mach-s3c24xx/Kconfig       |    1 +
>  arch/arm/plat-samsung/Kconfig       |    5 ++
>  arch/arm/plat-samsung/Makefile      |    1 +
>  arch/arm/plat-samsung/setup-camif.c |   70
> +++++++++++++++++++++++++++++++++++
>  4 files changed, 77 insertions(+), 0 deletions(-)
>  create mode 100644 arch/arm/plat-samsung/setup-camif.c
> 
> diff --git a/arch/arm/mach-s3c24xx/Kconfig b/arch/arm/mach-s3c24xx/Kconfig
> index 2b6cb5f..01f70c9 100644
> --- a/arch/arm/mach-s3c24xx/Kconfig
> +++ b/arch/arm/mach-s3c24xx/Kconfig
> @@ -405,6 +405,7 @@ config MACH_MINI2440
>  	select NEW_LEDS
>  	select S3C_DEV_NAND
>  	select S3C_DEV_USB_HOST
> +	select S3C_SETUP_CAMIF
>  	help
>  	  Say Y here to select support for the MINI2440. Is a 10cm x 10cm
> board
>  	  available via various sources. It can come with a 3.5" or 7"
> touch LCD.
> diff --git a/arch/arm/plat-samsung/Kconfig b/arch/arm/plat-samsung/Kconfig
> index 59401e1..95360e6 100644
> --- a/arch/arm/plat-samsung/Kconfig
> +++ b/arch/arm/plat-samsung/Kconfig
> @@ -414,6 +414,11 @@ config S5P_SETUP_MIPIPHY
>  	help
>  	  Compile in common setup code for MIPI-CSIS and MIPI-DSIM devices
> 
> +config S3C_SETUP_CAMIF
> +	bool
> +	help
> +	  Compile in common setup code for S3C CAMIF devices
> +
>  # DMA
> 
>  config S3C_DMA
> diff --git a/arch/arm/plat-samsung/Makefile b/arch/arm/plat-
> samsung/Makefile
> index 9e40e8d..3a7c64d 100644
> --- a/arch/arm/plat-samsung/Makefile
> +++ b/arch/arm/plat-samsung/Makefile
> @@ -41,6 +41,7 @@ obj-$(CONFIG_S5P_DEV_UART)	+= s5p-dev-uart.o
> 
>  obj-$(CONFIG_SAMSUNG_DEV_BACKLIGHT)	+= dev-backlight.o
> 
> +obj-$(CONFIG_S3C_SETUP_CAMIF)	+= setup-camif.o
>  obj-$(CONFIG_S5P_SETUP_MIPIPHY)	+= setup-mipiphy.o
> 
>  # DMA support
> diff --git a/arch/arm/plat-samsung/setup-camif.c b/arch/arm/plat-
> samsung/setup-camif.c
> new file mode 100644
> index 0000000..e01bf76
> --- /dev/null
> +++ b/arch/arm/plat-samsung/setup-camif.c
> @@ -0,0 +1,70 @@
> +/*
> + * 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>
> +
> +/* 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);
> +	}
> +}
> --
> 1.7.4.1

Yes, we can move on using pinctrl later when it is available. OK, applied.

Thanks.

K-Gene <kgene@kernel.org>

WARNING: multiple messages have this Message-ID (diff)
From: kgene@kernel.org (Kukjin Kim)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: SAMSUNG: Add s3c24xx/s3c64xx CAMIF GPIO setup helpers
Date: Thu, 22 Nov 2012 15:51:15 +0900	[thread overview]
Message-ID: <0f5b01cdc87d$c447f610$4cd7e230$@org> (raw)
In-Reply-To: <1353357262-18935-1-git-send-email-sylvester.nawrocki@gmail.com>

Sylwester Nawrocki wrote:
> 
> This patch adds default helper functions for the camera port
> pin configuration. Whenever pinctrl support for s3c24xx/s3c64xx
> SoCs is available these code should be removed and proper pinctrl
> API should be used in the CAMIF driver.
> 
> Signed-off-by: Sylwester Nawrocki <sylvester.nawrocki@gmail.com>
> ---
>  arch/arm/mach-s3c24xx/Kconfig       |    1 +
>  arch/arm/plat-samsung/Kconfig       |    5 ++
>  arch/arm/plat-samsung/Makefile      |    1 +
>  arch/arm/plat-samsung/setup-camif.c |   70
> +++++++++++++++++++++++++++++++++++
>  4 files changed, 77 insertions(+), 0 deletions(-)
>  create mode 100644 arch/arm/plat-samsung/setup-camif.c
> 
> diff --git a/arch/arm/mach-s3c24xx/Kconfig b/arch/arm/mach-s3c24xx/Kconfig
> index 2b6cb5f..01f70c9 100644
> --- a/arch/arm/mach-s3c24xx/Kconfig
> +++ b/arch/arm/mach-s3c24xx/Kconfig
> @@ -405,6 +405,7 @@ config MACH_MINI2440
>  	select NEW_LEDS
>  	select S3C_DEV_NAND
>  	select S3C_DEV_USB_HOST
> +	select S3C_SETUP_CAMIF
>  	help
>  	  Say Y here to select support for the MINI2440. Is a 10cm x 10cm
> board
>  	  available via various sources. It can come with a 3.5" or 7"
> touch LCD.
> diff --git a/arch/arm/plat-samsung/Kconfig b/arch/arm/plat-samsung/Kconfig
> index 59401e1..95360e6 100644
> --- a/arch/arm/plat-samsung/Kconfig
> +++ b/arch/arm/plat-samsung/Kconfig
> @@ -414,6 +414,11 @@ config S5P_SETUP_MIPIPHY
>  	help
>  	  Compile in common setup code for MIPI-CSIS and MIPI-DSIM devices
> 
> +config S3C_SETUP_CAMIF
> +	bool
> +	help
> +	  Compile in common setup code for S3C CAMIF devices
> +
>  # DMA
> 
>  config S3C_DMA
> diff --git a/arch/arm/plat-samsung/Makefile b/arch/arm/plat-
> samsung/Makefile
> index 9e40e8d..3a7c64d 100644
> --- a/arch/arm/plat-samsung/Makefile
> +++ b/arch/arm/plat-samsung/Makefile
> @@ -41,6 +41,7 @@ obj-$(CONFIG_S5P_DEV_UART)	+= s5p-dev-uart.o
> 
>  obj-$(CONFIG_SAMSUNG_DEV_BACKLIGHT)	+= dev-backlight.o
> 
> +obj-$(CONFIG_S3C_SETUP_CAMIF)	+= setup-camif.o
>  obj-$(CONFIG_S5P_SETUP_MIPIPHY)	+= setup-mipiphy.o
> 
>  # DMA support
> diff --git a/arch/arm/plat-samsung/setup-camif.c b/arch/arm/plat-
> samsung/setup-camif.c
> new file mode 100644
> index 0000000..e01bf76
> --- /dev/null
> +++ b/arch/arm/plat-samsung/setup-camif.c
> @@ -0,0 +1,70 @@
> +/*
> + * 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>
> +
> +/* 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);
> +	}
> +}
> --
> 1.7.4.1

Yes, we can move on using pinctrl later when it is available. OK, applied.

Thanks.

K-Gene <kgene@kernel.org>

  reply	other threads:[~2012-11-22  6:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-19 20:34 [PATCH] ARM: SAMSUNG: Add s3c24xx/s3c64xx CAMIF GPIO setup helpers Sylwester Nawrocki
2012-11-19 20:34 ` Sylwester Nawrocki
2012-11-22  6:51 ` Kukjin Kim [this message]
2012-11-22  6:51   ` Kukjin Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='0f5b01cdc87d$c447f610$4cd7e230$@org' \
    --to=kgene@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=sylvester.nawrocki@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.