From patchwork Mon Nov 19 20:34:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sylwester Nawrocki X-Patchwork-Id: 1768911 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 55DC6DF264 for ; Mon, 19 Nov 2012 20:36:34 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TaY3M-0006Cc-Cc; Mon, 19 Nov 2012 20:34:48 +0000 Received: from mail-ea0-f177.google.com ([209.85.215.177]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TaY3I-0006CC-75 for linux-arm-kernel@lists.infradead.org; Mon, 19 Nov 2012 20:34:45 +0000 Received: by mail-ea0-f177.google.com with SMTP id c10so339066eaa.36 for ; Mon, 19 Nov 2012 12:34:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=5oO/PqMl5yXvaGjDCcYOHwX0FLV1NnZalHmaMojYF5g=; b=L86F5zfzzhvKjtGEnpRti0w+XFc8myllhtT7zTRA86TXXzX95pXVbNVJ+wqyGlEvRn jMv7mhCkoQzX99GdR0S0Fzaz1ejxKqmesqEqtP4VsqWmfmro4a8zr8adxOAK50BYqgZI PuDeNs64kvJuX2Z+AQO9582i2nCpCcc4F6bSiV0HzUoGftqiXwLaoUa37+JdY6o3Qmcp XohICXvV1jQ0ADhBC4XZ/QEjZIS1GfMsDq0OmbHQFUlDO/e++CgyhRXcmi7lIulGqNlE Ng8h4vJVvhcl4SCdBI82y7f8SZeu0/ifL2dZoGY4cCW98+10qW4w1ydmndEdtPT5IJoc K1Kg== Received: by 10.14.209.6 with SMTP id r6mr27353923eeo.34.1353357280174; Mon, 19 Nov 2012 12:34:40 -0800 (PST) Received: from localhost.localdomain (178235118103.warszawa.vectranet.pl. [178.235.118.103]) by mx.google.com with ESMTPS id o47sm26194399eem.11.2012.11.19.12.34.38 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 19 Nov 2012 12:34:39 -0800 (PST) From: Sylwester Nawrocki To: kgene.kim@samsung.com Subject: [PATCH] ARM: SAMSUNG: Add s3c24xx/s3c64xx CAMIF GPIO setup helpers Date: Mon, 19 Nov 2012 21:34:22 +0100 Message-Id: <1353357262-18935-1-git-send-email-sylvester.nawrocki@gmail.com> X-Mailer: git-send-email 1.7.4.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121119_153444_440169_DF56ABDB X-CRM114-Status: GOOD ( 20.36 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (sylvester.nawrocki[at]gmail.com) -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.215.177 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Sylwester Nawrocki , linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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 --- 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 + * + * 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 +#include + +/* 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); + } +}