~beagleboard-kernel/+junk/2.6.35-devel

« back to all changes in this revision

Viewing changes to patches/gpio/0001-OMAP-Beagle-Revision-detection.patch

  • Committer: Robert Nelson
  • Date: 2010-08-11 17:34:01 UTC
  • Revision ID: robertcnelson@gmail.com-20100811173401-2fspui79s2wae63f
testing: new Bx/Cx/xM write protect patches

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
From 252cc1714077fd11d193669870f309843e7522b6 Mon Sep 17 00:00:00 2001
 
2
From: Robert Nelson <robertcnelson@gmail.com>
 
3
Date: Wed, 11 Aug 2010 11:41:23 -0500
 
4
Subject: [PATCH v2 1/3] ARM: OMAP: Beagle: Revision detection
 
5
 
 
6
Use the gpio 171,172,173 to determine Beagle Revision.
 
7
B5/B6 Beagle's use the same ES3.0 Silicon as the C1/2/3 Beagle.
 
8
 
 
9
Signed-off-by: Robert Nelson <robertcnelson@gmail.com>
 
10
---
 
11
 arch/arm/mach-omap2/board-omap3beagle.c |   59 +++++++++++++++++++++++++++++++
 
12
 arch/arm/plat-omap/include/plat/board.h |   23 ++++++++++++
 
13
 2 files changed, 82 insertions(+), 0 deletions(-)
 
14
 
 
15
diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
 
16
index 87969c7..891d8a8 100644
 
17
--- a/arch/arm/mach-omap2/board-omap3beagle.c
 
18
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
 
19
@@ -50,6 +50,64 @@
 
20
 
 
21
 #define NAND_BLOCK_SIZE                SZ_128K
 
22
 
 
23
+static u8 omap3_beagle_version;
 
24
+
 
25
+u8 get_omap3_beagle_rev(void)
 
26
+{
 
27
+       return omap3_beagle_version;
 
28
+}
 
29
+EXPORT_SYMBOL(get_omap3_beagle_rev);
 
30
+
 
31
+static void __init omap3_beagle_get_revision(void)
 
32
+{
 
33
+       int ret;
 
34
+       u16 beagle_rev = 0;
 
35
+
 
36
+       ret = gpio_request(171, "rev_id_0");
 
37
+       if (ret < 0)
 
38
+               goto fail;
 
39
+
 
40
+       ret = gpio_request(172, "rev_id_1");
 
41
+       if (ret < 0)
 
42
+               goto fail;
 
43
+
 
44
+       ret = gpio_request(173, "rev_id_2");
 
45
+       if (ret < 0)
 
46
+               goto fail;
 
47
+
 
48
+       gpio_direction_input(171);
 
49
+       gpio_direction_input(172);
 
50
+       gpio_direction_input(173);
 
51
+
 
52
+       beagle_rev = gpio_get_value(171) | (gpio_get_value(172) << 1) | (gpio_get_value(173) << 2);
 
53
+
 
54
+       switch (beagle_rev) {
 
55
+               case 7:
 
56
+                       printk(KERN_INFO "OMAP3 Beagle Rev: Ax/Bx\n");
 
57
+                       omap3_beagle_version = OMAP3BEAGLE_BOARD_AXBX;
 
58
+                       break;
 
59
+               case 6:
 
60
+                       printk(KERN_INFO "OMAP3 Beagle Rev: C1/C2/C3\n");
 
61
+                       omap3_beagle_version = OMAP3BEAGLE_BOARD_C1_3;
 
62
+                       break;
 
63
+               case 5:
 
64
+                       printk(KERN_INFO "OMAP3 Beagle Rev: C4\n");
 
65
+                       omap3_beagle_version = OMAP3BEAGLE_BOARD_C4;
 
66
+                       break;
 
67
+               case 0:
 
68
+                       printk(KERN_INFO "OMAP3 Beagle Rev: xM\n");
 
69
+                       omap3_beagle_version = OMAP3BEAGLE_BOARD_XM;
 
70
+                       break;
 
71
+               default:
 
72
+                       printk(KERN_INFO "OMAP3 Beagle Rev: unknown %hd\n", beagle_rev);
 
73
+                       omap3_beagle_version = OMAP3BEAGLE_BOARD_XM;
 
74
+       }
 
75
+
 
76
+       return;
 
77
+fail:
 
78
+       printk(KERN_ERR "Unable to get revision detection GPIO pins\n");
 
79
+}
 
80
+
 
81
 static struct mtd_partition omap3beagle_nand_partitions[] = {
 
82
        /* All the partition sizes are listed in terms of NAND block size */
 
83
        {
 
84
@@ -464,6 +522,7 @@ static struct omap_musb_board_data musb_board_data = {
 
85
 static void __init omap3_beagle_init(void)
 
86
 {
 
87
        omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
 
88
+       omap3_beagle_get_revision();
 
89
        omap3_beagle_i2c_init();
 
90
        platform_add_devices(omap3_beagle_devices,
 
91
                        ARRAY_SIZE(omap3_beagle_devices));
 
92
diff --git a/arch/arm/plat-omap/include/plat/board.h b/arch/arm/plat-omap/include/plat/board.h
 
93
index 3cf4fa2..e55a920 100644
 
94
--- a/arch/arm/plat-omap/include/plat/board.h
 
95
+++ b/arch/arm/plat-omap/include/plat/board.h
 
96
@@ -26,6 +26,22 @@ enum {
 
97
        OMAP3EVM_BOARD_GEN_2,           /* EVM Rev >= Rev E */
 
98
 };
 
99
 
 
100
+/*
 
101
+ * OMAP3 Beagle revision
 
102
+ * Run time detection of Beagle revision is done by reading GPIO.
 
103
+ * GPIO ID -
 
104
+ *     AXBX    = GPIO173, GPIO172, GPIO171: 1 1 1
 
105
+ *     C1_3    = GPIO173, GPIO172, GPIO171: 1 1 0
 
106
+ *     C4      = GPIO173, GPIO172, GPIO171: 1 0 1
 
107
+ *     XM      = GPIO173, GPIO172, GPIO171: 0 0 0
 
108
+ */
 
109
+enum {
 
110
+       OMAP3BEAGLE_BOARD_AXBX = 0,
 
111
+       OMAP3BEAGLE_BOARD_C1_3,
 
112
+       OMAP3BEAGLE_BOARD_C4,
 
113
+       OMAP3BEAGLE_BOARD_XM,
 
114
+};
 
115
+
 
116
 /* Different peripheral ids */
 
117
 #define OMAP_TAG_CLOCK         0x4f01
 
118
 #define OMAP_TAG_LCD           0x4f05
 
119
@@ -173,4 +189,11 @@ u8 get_omap3_evm_rev(void);
 
120
 #else
 
121
 #define get_omap3_evm_rev() (-EINVAL)
 
122
 #endif
 
123
+
 
124
+/* Beagle revision */
 
125
+#if defined(CONFIG_MACH_OMAP3_BEAGLE)
 
126
+u8 get_omap3_beagle_rev(void);
 
127
+#else
 
128
+#define get_omap3_beagle_rev() (-EINVAL)
 
129
+#endif
 
130
 #endif
 
131
-- 
 
132
1.7.0.4
 
133