From patchwork Fri Aug 13 12:21:08 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Nelson X-Patchwork-Id: 119412 X-Patchwork-Delegate: tony@atomide.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o7DCLNsQ013092 for ; Fri, 13 Aug 2010 12:21:23 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934237Ab0HMMVW (ORCPT ); Fri, 13 Aug 2010 08:21:22 -0400 Received: from mail-gx0-f174.google.com ([209.85.161.174]:50032 "EHLO mail-gx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934235Ab0HMMVW (ORCPT ); Fri, 13 Aug 2010 08:21:22 -0400 Received: by gxk23 with SMTP id 23so910023gxk.19 for ; Fri, 13 Aug 2010 05:21:21 -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=6GbJB5+7/EM+Fy/q44CMZEaB1WzEtgmjQgem1YlNSBo=; b=nFDpTNeeZ66l3OCvVlAt8U6A0Es2uZUSytZnNNLP6G6nTCod5XPzTEb/7P+1QEycp+ pmQldZ1MP5DAhzU51fO/I9Q8MMUCOnKNK12pzkKXeUzrxC8Ei4DZmMr48++D+GOA7Gbm cBEPNx9HvgW8OJHQm91N6fxi0YRd3SrLIHQ8A= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=kJxfKkqEuUqQWco8gp+o03QaoM9nVe43a8RvRJ0Ya9scRAug5oPrCZHiPZ2FiLh9a8 CHcNnXOkbtV+TaGazg35DPUkFuTpIBxjKrj4tQnsTrSfxaBlOxizdRTjy6J/KxH6l8jv DcztdGEYEZoYs0AvbY0JB896rtoguCt3C8wgg= Received: by 10.150.181.14 with SMTP id d14mr1976701ybf.32.1281702079932; Fri, 13 Aug 2010 05:21:19 -0700 (PDT) Received: from localhost.localdomain (thief-pool1-30.mncable.net [64.77.208.30]) by mx.google.com with ESMTPS id p14sm2833238ybb.9.2010.08.13.05.21.17 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 13 Aug 2010 05:21:18 -0700 (PDT) From: Robert Nelson To: tony@atomide.com Cc: linux-omap@vger.kernel.org, Robert Nelson Subject: [PATCH v3 1/3] ARM: OMAP: Beagle: revision detection Date: Fri, 13 Aug 2010 07:21:08 -0500 Message-Id: <1281702070-10525-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: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Fri, 13 Aug 2010 12:21:23 +0000 (UTC) diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c index 87969c7..e42a5ff 100644 --- a/arch/arm/mach-omap2/board-omap3beagle.c +++ b/arch/arm/mach-omap2/board-omap3beagle.c @@ -50,6 +50,83 @@ #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_AXBX = 0, + OMAP3BEAGLE_BOARD_C1_3, + OMAP3BEAGLE_BOARD_C4, + OMAP3BEAGLE_BOARD_XM, +}; + +static u8 omap3_beagle_version; + +u8 get_omap3_beagle_rev(void) +{ + return omap3_beagle_version; +} + +static void __init omap3_beagle_get_revision(void) +{ + int ret; + u16 beagle_rev = 0; + + ret = gpio_request(171, "rev_id_0"); + if (ret < 0) + goto fail; + + ret = gpio_request(172, "rev_id_1"); + if (ret < 0) + goto fail; + + ret = gpio_request(173, "rev_id_2"); + if (ret < 0) + goto fail; + + /* Older U-Boot's such as 2009.01-dirty don't have the pins + * muxed correctly to use the generic gpio_direction_input(); + */ + 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); + + 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_XM; + } + + return; +fail: + printk(KERN_ERR "Unable to get revision detection GPIO pins\n"); +} + static struct mtd_partition omap3beagle_nand_partitions[] = { /* All the partition sizes are listed in terms of NAND block size */ { @@ -464,6 +541,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_get_revision(); omap3_beagle_i2c_init(); platform_add_devices(omap3_beagle_devices, ARRAY_SIZE(omap3_beagle_devices));