From patchwork Mon Apr 9 08:52:03 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martin X-Patchwork-Id: 151423 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 3224AB7004 for ; Mon, 9 Apr 2012 18:54:30 +1000 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SHAKl-0006gR-GZ; Mon, 09 Apr 2012 08:52:23 +0000 Received: from mail-wg0-f41.google.com ([74.125.82.41]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1SHAKi-0006g3-Sz for linux-arm-kernel@lists.infradead.org; Mon, 09 Apr 2012 08:52:21 +0000 Received: by wgbds1 with SMTP id ds1so1853581wgb.0 for ; Mon, 09 Apr 2012 01:52:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=AAMHukVLAxvhPuCoIbigIEpW5XBILQJf7zTjckcpmcw=; b=JsjFt2GdX65661k8bDoAJsi7bowjWIy0jBO39nP9olfisA7F8kTqs0FQYXGDrlVSOO 5k5N8yQcs/edBFGvVedyXfBJFh/+DcRkqztI3zZTQfyYZGzgcgQG7LXGBdi9+SqAssYU F/RdVf308FanlhppxCyjgsjdxOZ4zcMk0/hiPn5E2rzdBBPYG+nm9bJPmDkmbEcFU0u3 p4OBv0LlexXvWFb9tYPJ9FcktqbloO/ikX4cPydX7Q2y4CjTi+ypm7x6PBo5+W2DE/60 WywJNeu1E/Vho3nLO5ws5uSXRAlmfEVm7bfIYwDnes04XFD+VysZ/7q2AIxKKVYG2CQR jSsg== Received: by 10.180.102.3 with SMTP id fk3mr14318126wib.9.1333961538818; Mon, 09 Apr 2012 01:52:18 -0700 (PDT) Received: from localhost.localdomain (124.253.106.212.dynamic.jazztel.es. [212.106.253.124]) by mx.google.com with ESMTPS id j3sm46570765wiw.1.2012.04.09.01.52.16 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 09 Apr 2012 01:52:18 -0700 (PDT) From: Javier Martin To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] Visstrim_M10: Add board version detection. Date: Mon, 9 Apr 2012 10:52:03 +0200 Message-Id: <1333961523-16356-1-git-send-email-javier.martin@vista-silicon.com> X-Mailer: git-send-email 1.7.0.4 X-Gm-Message-State: ALoCoQmOXENDK8dh5YHiJKGiJhP+QUcSI4sjnNBhc6E81ZIxU7AAtVoEc6QabXLwHQBycGMODfm/ X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.41 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] Cc: linux@arm.linux.org.uk, Javier Martin , kernel@pengutronix.de X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list 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+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org Visstrim_M10 boards have 3 gpios to detect the expansion board version attached and other 3 to detect the motherboard revision. Signed-off-by: Javier Martin --- arch/arm/mach-imx/mach-imx27_visstrim_m10.c | 38 +++++++++++++++++++++++++++ 1 files changed, 38 insertions(+), 0 deletions(-) diff --git a/arch/arm/mach-imx/mach-imx27_visstrim_m10.c b/arch/arm/mach-imx/mach-imx27_visstrim_m10.c index f9aa657..cdf277e 100644 --- a/arch/arm/mach-imx/mach-imx27_visstrim_m10.c +++ b/arch/arm/mach-imx/mach-imx27_visstrim_m10.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -48,6 +49,14 @@ #define OTG_PHY_CS_GPIO (GPIO_PORTF + 17) #define SDHC1_IRQ IRQ_GPIOB(25) +#define MOTHERBOARD_BIT2 (GPIO_PORTD + 31) +#define MOTHERBOARD_BIT1 (GPIO_PORTD + 30) +#define MOTHERBOARD_BIT0 (GPIO_PORTD + 29) + +#define EXPBOARD_BIT2 (GPIO_PORTD + 25) +#define EXPBOARD_BIT1 (GPIO_PORTD + 27) +#define EXPBOARD_BIT0 (GPIO_PORTD + 28) + static const int visstrim_m10_pins[] __initconst = { /* UART1 (console) */ PE12_PF_UART1_TXD, @@ -119,6 +128,14 @@ static const int visstrim_m10_pins[] __initconst = { PB19_PF_CSI_D7, PB20_PF_CSI_VSYNC, PB21_PF_CSI_HSYNC, + /* mother board version */ + MOTHERBOARD_BIT2 | GPIO_GPIO | GPIO_IN | GPIO_PUEN, + MOTHERBOARD_BIT1 | GPIO_GPIO | GPIO_IN | GPIO_PUEN, + MOTHERBOARD_BIT0 | GPIO_GPIO | GPIO_IN | GPIO_PUEN, + /* expansion board version */ + EXPBOARD_BIT2 | GPIO_GPIO | GPIO_IN | GPIO_PUEN, + EXPBOARD_BIT1 | GPIO_GPIO | GPIO_IN | GPIO_PUEN, + EXPBOARD_BIT0 | GPIO_GPIO | GPIO_IN | GPIO_PUEN, }; /* Camera */ @@ -399,11 +416,32 @@ static const struct imx_ssi_platform_data visstrim_m10_ssi_pdata __initconst = { .flags = IMX_SSI_DMA | IMX_SSI_SYN, }; +static void __init visstrim_m10_revision(void) +{ + int exp_version = 0; + int mo_version = 0; + + /* Get expansion board version (negative logic) */ + exp_version |= ((!gpio_get_value(EXPBOARD_BIT2) << 2) & (1 << 2)); + exp_version |= ((!gpio_get_value(EXPBOARD_BIT1) << 1) & (1 << 1)); + exp_version |= ((!gpio_get_value(EXPBOARD_BIT0)) & 1); + + /* Get mother board version (negative logic) */ + mo_version |= ((!gpio_get_value(MOTHERBOARD_BIT2) << 2) & (1 << 2)); + mo_version |= ((!gpio_get_value(MOTHERBOARD_BIT1) << 1) & (1 << 1)); + mo_version |= ((!gpio_get_value(MOTHERBOARD_BIT0)) & 1); + + system_rev = 0x27000; + system_rev |= (mo_version << 4); + system_rev |= exp_version; +} + static void __init visstrim_m10_board_init(void) { int ret; imx27_soc_init(); + visstrim_m10_revision(); ret = mxc_gpio_setup_multiple_pins(visstrim_m10_pins, ARRAY_SIZE(visstrim_m10_pins), "VISSTRIM_M10");