linux-omap-psp 2.6.32: sync with .dev
[glsdk/meta-ti-glsdk.git] / recipes-bsp / linux / linux-omap-psp-2.6.32 / beagleboard-xmc / 0001-omap-Beagle-revision-detection.patch
1 From 325afc09116e11e28265b648ef33d8c0306c61f1 Mon Sep 17 00:00:00 2001
2 From: Robert Nelson <robertcnelson@gmail.com>
3 Date: Thu, 23 Sep 2010 18:22:47 -0700
4 Subject: [PATCH 01/10] omap: Beagle: revision detection
6 Due to the omap3530 ES3.0 Silicon being used on both the
7 B5/B6 and C1/2/3 Beagle we can't use the cpu_is_omap34xx()
8 routines to differentiate the Beagle Boards.
10 However gpio pins 171,172,173 where setup for this prupose, so
11 lets use them.
13 Changes:
14 for older U-Boot's, use omap_mux_init_gpio()
15 keep Beagle Rev in board-omap3beagle.c
16 gpio_free on gpio request failure
18 Tested on Beagle Revisions: B5, C2, C4, and xMA
20 Signed-off-by: Robert Nelson <robertcnelson@gmail.com>
21 Acked-by: Jarkko Nikula <jhnikula@gmail.com>
22 Signed-off-by: Tony Lindgren <tony@atomide.com>
23 ---
24  arch/arm/mach-omap2/board-omap3beagle.c |   88 +++++++++++++++++++++++++++++++
25  1 files changed, 88 insertions(+), 0 deletions(-)
27 diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
28 index 2677b41..7ca2b3b 100644
29 --- a/arch/arm/mach-omap2/board-omap3beagle.c
30 +++ b/arch/arm/mach-omap2/board-omap3beagle.c
31 @@ -175,6 +175,93 @@ static void __init omap3beagle_ks8851_init(void)
32  static inline void __init omap3beagle_ks8851_init(void) { return; }
33  #endif
34  
35 +/*
36 + * OMAP3 Beagle revision
37 + * Run time detection of Beagle revision is done by reading GPIO.
38 + * GPIO ID -
39 + *     AXBX    = GPIO173, GPIO172, GPIO171: 1 1 1
40 + *     C1_3    = GPIO173, GPIO172, GPIO171: 1 1 0
41 + *     C4      = GPIO173, GPIO172, GPIO171: 1 0 1
42 + *     XM      = GPIO173, GPIO172, GPIO171: 0 0 0
43 + */
44 +enum {
45 +       OMAP3BEAGLE_BOARD_UNKN = 0,
46 +       OMAP3BEAGLE_BOARD_AXBX,
47 +       OMAP3BEAGLE_BOARD_C1_3,
48 +       OMAP3BEAGLE_BOARD_C4,
49 +       OMAP3BEAGLE_BOARD_XM,
50 +};
51 +
52 +static u8 omap3_beagle_version;
53 +
54 +static u8 omap3_beagle_get_rev(void)
55 +{
56 +       return omap3_beagle_version;
57 +}
58 +
59 +static void __init omap3_beagle_init_rev(void)
60 +{
61 +       int ret;
62 +       u16 beagle_rev = 0;
63 +
64 +       omap_mux_init_gpio(171, OMAP_PIN_INPUT_PULLUP);
65 +       omap_mux_init_gpio(172, OMAP_PIN_INPUT_PULLUP);
66 +       omap_mux_init_gpio(173, OMAP_PIN_INPUT_PULLUP);
67 +
68 +       ret = gpio_request(171, "rev_id_0");
69 +       if (ret < 0)
70 +               goto fail0;
71 +
72 +       ret = gpio_request(172, "rev_id_1");
73 +       if (ret < 0)
74 +               goto fail1;
75 +
76 +       ret = gpio_request(173, "rev_id_2");
77 +       if (ret < 0)
78 +               goto fail2;
79 +
80 +       gpio_direction_input(171);
81 +       gpio_direction_input(172);
82 +       gpio_direction_input(173);
83 +
84 +       beagle_rev = gpio_get_value(171) | (gpio_get_value(172) << 1)
85 +                       | (gpio_get_value(173) << 2);
86 +
87 +       switch (beagle_rev) {
88 +       case 7:
89 +               printk(KERN_INFO "OMAP3 Beagle Rev: Ax/Bx\n");
90 +               omap3_beagle_version = OMAP3BEAGLE_BOARD_AXBX;
91 +               break;
92 +       case 6:
93 +               printk(KERN_INFO "OMAP3 Beagle Rev: C1/C2/C3\n");
94 +               omap3_beagle_version = OMAP3BEAGLE_BOARD_C1_3;
95 +               break;
96 +       case 5:
97 +               printk(KERN_INFO "OMAP3 Beagle Rev: C4\n");
98 +               omap3_beagle_version = OMAP3BEAGLE_BOARD_C4;
99 +               break;
100 +       case 0:
101 +               printk(KERN_INFO "OMAP3 Beagle Rev: xM\n");
102 +               omap3_beagle_version = OMAP3BEAGLE_BOARD_XM;
103 +               break;
104 +       default:
105 +               printk(KERN_INFO "OMAP3 Beagle Rev: unknown %hd\n", beagle_rev);
106 +               omap3_beagle_version = OMAP3BEAGLE_BOARD_UNKN;
107 +       }
109 +       return;
111 +fail2:
112 +       gpio_free(172);
113 +fail1:
114 +       gpio_free(171);
115 +fail0:
116 +       printk(KERN_ERR "Unable to get revision detection GPIO pins\n");
117 +       omap3_beagle_version = OMAP3BEAGLE_BOARD_UNKN;
119 +       return;
120 +}
122  static struct mtd_partition omap3beagle_nand_partitions[] = {
123         /* All the partition sizes are listed in terms of NAND block size */
124         {
125 @@ -853,6 +940,7 @@ static int __init cameraboard_setup(char *str)
126  static void __init omap3_beagle_init(void)
127  {
128         omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
129 +       omap3_beagle_init_rev();
130         omap3_beagle_i2c_init();
131  
132         if (cpu_is_omap3630()) {
133 -- 
134 1.6.6.1