From linux-omap-owner@vger.kernel.org Wed Aug 18 18:28:39 2010
Received: from localhost
	([127.0.0.1] helo=dominion ident=koen)
	by dominion.dominion.void with esmtp (Exim 4.69)
	(envelope-from <linux-omap-owner@vger.kernel.org>)
	id 1OllVH-0005Bg-9p
	for koen@localhost; Wed, 18 Aug 2010 18:28:39 +0200
Received: from xs.service.utwente.nl [130.89.5.250]
	by dominion with POP3 (fetchmail-6.3.9-rc2)
	for <koen@localhost> (single-drop); Wed, 18 Aug 2010 18:28:39 +0200 (CEST)
Received: from mail.service.utwente.nl ([130.89.5.254]) by exchange.service.utwente.nl with Microsoft SMTPSVC(6.0.3790.4675);
	 Wed, 18 Aug 2010 17:57:27 +0200
Received: from smtp.utwente.nl ([130.89.2.9]) by mail.service.utwente.nl with Microsoft SMTPSVC(6.0.3790.4675);
	 Wed, 18 Aug 2010 17:57:27 +0200
Received: from vger.kernel.org (vger.kernel.org [209.132.180.67])
          by smtp.utwente.nl (8.12.10/SuSE Linux 0.7) with ESMTP id o7IFv8o7030029
          for <k.kooi@student.utwente.nl>; Wed, 18 Aug 2010 17:57:09 +0200
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
	id S1753376Ab0HRP5F (ORCPT <rfc822;k.kooi@student.utwente.nl>);
	Wed, 18 Aug 2010 11:57:05 -0400
Received: from mail-yx0-f174.google.com ([209.85.213.174]:57357 "EHLO
	mail-yx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
	with ESMTP id S1751796Ab0HRP5E (ORCPT
	<rfc822;linux-omap@vger.kernel.org>); Wed, 18 Aug 2010 11:57:04 -0400
Received: by yxg6 with SMTP id 6so244231yxg.19
        for <linux-omap@vger.kernel.org>; Wed, 18 Aug 2010 08:57:03 -0700 (PDT)
DKIM-Signature: 	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:received:received:from:to:cc:subject:date
         :message-id:x-mailer;
        bh=wxQJH57JszAoGEW7Em8a4sT5ddcXG8QaR3fvkUwu4XU=;
        b=HkKHtmiV0GdXqOJ0b3HRhRGYuNlbYfbov0DPZ7awwzbTL5PB597lfqrd8nVZo/CWF2
         94OOiANstsEeTxHQpmrO/RlIqPgk5bSdFYR8HoYeUJz+Zv/2pek7NBK7FDwc/Dzay2y3
         kDc9k1G3XPX8wBU+VtyjQWrVD2iAOd2ctTh3s=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=from:to:cc:subject:date:message-id:x-mailer;
        b=ZsdIDkgddBUZr9kE94ytvDKlk1/m9fDeIKpyjaBw2etRLsXyJClvd7AzxyQdRGlMPx
         SVKkHl9Su0QVs9V41AltzZxVc3/QYI6RubWRWGO1WvumSAbYr90DEt3uxnsLZAV++Ncv
         9JtToYYv7m4ef2Z3CmPB6K1gtwHSe4m9wMAzs=
Received: by 10.151.92.3 with SMTP id u3mr554985ybl.209.1282147023697;
        Wed, 18 Aug 2010 08:57:03 -0700 (PDT)
Received: from localhost.localdomain (thief-statics-245.mncable.net [64.77.213.245])
        by mx.google.com with ESMTPS id q21sm1438081ybk.23.2010.08.18.08.57.00
        (version=TLSv1/SSLv3 cipher=RC4-MD5);
        Wed, 18 Aug 2010 08:57:01 -0700 (PDT)
From: Robert Nelson <robertcnelson@gmail.com>
To: tony@atomide.com
Cc: linux-omap@vger.kernel.org, Robert Nelson <robertcnelson@gmail.com>,
        Jarkko Nikula <jhnikula@gmail.com>
Subject: [PATCH v5 1/3] ARM: OMAP: Beagle: revision detection
Date: 	Wed, 18 Aug 2010 10:56:51 -0500
Message-Id: <1282147013-508-1-git-send-email-robertcnelson@gmail.com>
X-Mailer: git-send-email 1.7.0.4
Sender: linux-omap-owner@vger.kernel.org
Precedence: bulk
List-ID: <linux-omap.vger.kernel.org>
X-Mailing-List: 	linux-omap@vger.kernel.org
X-UTwente-MailScanner-Information: Scanned by MailScanner. Contact icts.servicedesk@utwente.nl for more information.
X-UTwente-MailScanner: Found to be clean
X-UTwente-MailScanner-From: linux-omap-owner@vger.kernel.org
X-Spam-Status: No
X-OriginalArrivalTime: 18 Aug 2010 15:57:27.0693 (UTC) FILETIME=[0E850BD0:01CB3EEE]

Due to the omap3530 ES3.0 Silicon being used on both the
B5/B6 and C1/2/3 Beagle we can't use the cpu_is_omap34xx() 
routines to differentiate the Beagle Boards.

However gpio pins 171,172,173 where setup for this prupose, so 
lets use them.

Changes:
for older U-Boot's, use omap_mux_init_gpio()
keep Beagle Rev in board-omap3beagle.c
gpio_free on gpio request failure

Tested on Beagle Revisions: B5, C2, C4, and xMA

Signed-off-by: Robert Nelson <robertcnelson@gmail.com>
Cc: Jarkko Nikula <jhnikula@gmail.com>
---
 arch/arm/mach-omap2/board-omap3beagle.c |   90 +++++++++++++++++++++++++++++++
 1 files changed, 90 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
index 87969c7..62d69a9 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -50,6 +50,95 @@
 
 #define NAND_BLOCK_SIZE		SZ_128K
 
+/*
+ * OMAP3 Beagle revision
+ * Run time detection of Beagle revision is done by reading GPIO.
+ * GPIO ID -
+ *	AXBX	= GPIO173, GPIO172, GPIO171: 1 1 1
+ *	C1_3	= GPIO173, GPIO172, GPIO171: 1 1 0
+ *	C4	= GPIO173, GPIO172, GPIO171: 1 0 1
+ *	XM	= GPIO173, GPIO172, GPIO171: 0 0 0
+ */
+enum {
+	OMAP3BEAGLE_BOARD_UNKN = 0,
+	OMAP3BEAGLE_BOARD_AXBX,
+	OMAP3BEAGLE_BOARD_C1_3,
+	OMAP3BEAGLE_BOARD_C4,
+	OMAP3BEAGLE_BOARD_XM,
+};
+
+static u8 omap3_beagle_version;
+
+static u8 omap3_beagle_get_rev(void)
+{
+	return omap3_beagle_version;
+}
+
+static void __init omap3_beagle_init_rev(void)
+{
+	int ret;
+	u16 beagle_rev = 0;
+
+	omap_mux_init_gpio(171, OMAP_PIN_INPUT_PULLUP);
+	omap_mux_init_gpio(172, OMAP_PIN_INPUT_PULLUP);
+	omap_mux_init_gpio(173, OMAP_PIN_INPUT_PULLUP);
+
+	ret = gpio_request(171, "rev_id_0");
+	if (ret < 0)
+		goto fail0;
+
+	ret = gpio_request(172, "rev_id_1");
+	if (ret < 0)
+		goto fail1;
+
+	ret = gpio_request(173, "rev_id_2");
+	if (ret < 0)
+		goto fail2;
+
+	gpio_direction_input(171);
+	gpio_direction_input(172);
+	gpio_direction_input(173);
+
+	beagle_rev = gpio_get_value(171) | (gpio_get_value(172) << 1)
+			| (gpio_get_value(173) << 2);
+
+	switch (beagle_rev) {
+	case 7:
+		printk(KERN_INFO "OMAP3 Beagle Rev: Ax/Bx\n");
+		omap3_beagle_version = OMAP3BEAGLE_BOARD_AXBX;
+		break;
+	case 6:
+		printk(KERN_INFO "OMAP3 Beagle Rev: C1/C2/C3\n");
+		omap3_beagle_version = OMAP3BEAGLE_BOARD_C1_3;
+		break;
+	case 5:
+		printk(KERN_INFO "OMAP3 Beagle Rev: C4\n");
+		omap3_beagle_version = OMAP3BEAGLE_BOARD_C4;
+		break;
+	case 0:
+		printk(KERN_INFO "OMAP3 Beagle Rev: xM\n");
+		omap3_beagle_version = OMAP3BEAGLE_BOARD_XM;
+		break;
+	default:
+		printk(KERN_INFO "OMAP3 Beagle Rev: unknown %hd\n", beagle_rev);
+		omap3_beagle_version = OMAP3BEAGLE_BOARD_UNKN;
+	}
+
+	return;
+
+fail2:
+	gpio_free(173);
+fail1:
+	gpio_free(172);
+fail0:
+	gpio_free(171);
+
+	printk(KERN_ERR "Unable to get revision detection GPIO pins\n");
+	omap3_beagle_version = OMAP3BEAGLE_BOARD_UNKN;
+
+	return;
+}
+
 static struct mtd_partition omap3beagle_nand_partitions[] = {
 	/* All the partition sizes are listed in terms of NAND block size */
 	{
@@ -464,6 +553,7 @@ static struct omap_musb_board_data musb_board_data = {
 static void __init omap3_beagle_init(void)
 {
 	omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
+	omap3_beagle_init_rev();
 	omap3_beagle_i2c_init();
 	platform_add_devices(omap3_beagle_devices,
 			ARRAY_SIZE(omap3_beagle_devices));
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

