aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/board-omap3beagle.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-omap2/board-omap3beagle.c')
-rw-r--r--arch/arm/mach-omap2/board-omap3beagle.c101
1 files changed, 99 insertions, 2 deletions
diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
index 51493f59325..7e704887864 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -51,6 +51,93 @@
51 51
52#define NAND_BLOCK_SIZE SZ_128K 52#define NAND_BLOCK_SIZE SZ_128K
53 53
54/*
55 * OMAP3 Beagle revision
56 * Run time detection of Beagle revision is done by reading GPIO.
57 * GPIO ID -
58 * AXBX = GPIO173, GPIO172, GPIO171: 1 1 1
59 * C1_3 = GPIO173, GPIO172, GPIO171: 1 1 0
60 * C4 = GPIO173, GPIO172, GPIO171: 1 0 1
61 * XM = GPIO173, GPIO172, GPIO171: 0 0 0
62 */
63enum {
64 OMAP3BEAGLE_BOARD_UNKN = 0,
65 OMAP3BEAGLE_BOARD_AXBX,
66 OMAP3BEAGLE_BOARD_C1_3,
67 OMAP3BEAGLE_BOARD_C4,
68 OMAP3BEAGLE_BOARD_XM,
69};
70
71static u8 omap3_beagle_version;
72
73static u8 omap3_beagle_get_rev(void)
74{
75 return omap3_beagle_version;
76}
77
78static void __init omap3_beagle_init_rev(void)
79{
80 int ret;
81 u16 beagle_rev = 0;
82
83 omap_mux_init_gpio(171, OMAP_PIN_INPUT_PULLUP);
84 omap_mux_init_gpio(172, OMAP_PIN_INPUT_PULLUP);
85 omap_mux_init_gpio(173, OMAP_PIN_INPUT_PULLUP);
86
87 ret = gpio_request(171, "rev_id_0");
88 if (ret < 0)
89 goto fail0;
90
91 ret = gpio_request(172, "rev_id_1");
92 if (ret < 0)
93 goto fail1;
94
95 ret = gpio_request(173, "rev_id_2");
96 if (ret < 0)
97 goto fail2;
98
99 gpio_direction_input(171);
100 gpio_direction_input(172);
101 gpio_direction_input(173);
102
103 beagle_rev = gpio_get_value(171) | (gpio_get_value(172) << 1)
104 | (gpio_get_value(173) << 2);
105
106 switch (beagle_rev) {
107 case 7:
108 printk(KERN_INFO "OMAP3 Beagle Rev: Ax/Bx\n");
109 omap3_beagle_version = OMAP3BEAGLE_BOARD_AXBX;
110 break;
111 case 6:
112 printk(KERN_INFO "OMAP3 Beagle Rev: C1/C2/C3\n");
113 omap3_beagle_version = OMAP3BEAGLE_BOARD_C1_3;
114 break;
115 case 5:
116 printk(KERN_INFO "OMAP3 Beagle Rev: C4\n");
117 omap3_beagle_version = OMAP3BEAGLE_BOARD_C4;
118 break;
119 case 0:
120 printk(KERN_INFO "OMAP3 Beagle Rev: xM\n");
121 omap3_beagle_version = OMAP3BEAGLE_BOARD_XM;
122 break;
123 default:
124 printk(KERN_INFO "OMAP3 Beagle Rev: unknown %hd\n", beagle_rev);
125 omap3_beagle_version = OMAP3BEAGLE_BOARD_UNKN;
126 }
127
128 return;
129
130fail2:
131 gpio_free(172);
132fail1:
133 gpio_free(171);
134fail0:
135 printk(KERN_ERR "Unable to get revision detection GPIO pins\n");
136 omap3_beagle_version = OMAP3BEAGLE_BOARD_UNKN;
137
138 return;
139}
140
54static struct mtd_partition omap3beagle_nand_partitions[] = { 141static struct mtd_partition omap3beagle_nand_partitions[] = {
55 /* All the partition sizes are listed in terms of NAND block size */ 142 /* All the partition sizes are listed in terms of NAND block size */
56 { 143 {
@@ -186,7 +273,10 @@ static struct gpio_led gpio_leds[];
186static int beagle_twl_gpio_setup(struct device *dev, 273static int beagle_twl_gpio_setup(struct device *dev,
187 unsigned gpio, unsigned ngpio) 274 unsigned gpio, unsigned ngpio)
188{ 275{
189 if (system_rev >= 0x20 && system_rev <= 0x34301000) { 276 if (omap3_beagle_get_rev() == OMAP3BEAGLE_BOARD_XM) {
277 mmc[0].gpio_wp = -EINVAL;
278 } else if ((omap3_beagle_get_rev() == OMAP3BEAGLE_BOARD_C1_3) ||
279 (omap3_beagle_get_rev() == OMAP3BEAGLE_BOARD_C4)) {
190 omap_mux_init_gpio(23, OMAP_PIN_INPUT); 280 omap_mux_init_gpio(23, OMAP_PIN_INPUT);
191 mmc[0].gpio_wp = 23; 281 mmc[0].gpio_wp = 23;
192 } else { 282 } else {
@@ -323,13 +413,19 @@ static struct i2c_board_info __initdata beagle_i2c_boardinfo[] = {
323 }, 413 },
324}; 414};
325 415
416static struct i2c_board_info __initdata beagle_i2c_eeprom[] = {
417 {
418 I2C_BOARD_INFO("eeprom", 0x50),
419 },
420};
421
326static int __init omap3_beagle_i2c_init(void) 422static int __init omap3_beagle_i2c_init(void)
327{ 423{
328 omap_register_i2c_bus(1, 2600, beagle_i2c_boardinfo, 424 omap_register_i2c_bus(1, 2600, beagle_i2c_boardinfo,
329 ARRAY_SIZE(beagle_i2c_boardinfo)); 425 ARRAY_SIZE(beagle_i2c_boardinfo));
330 /* Bus 3 is attached to the DVI port where devices like the pico DLP 426 /* Bus 3 is attached to the DVI port where devices like the pico DLP
331 * projector don't work reliably with 400kHz */ 427 * projector don't work reliably with 400kHz */
332 omap_register_i2c_bus(3, 100, NULL, 0); 428 omap_register_i2c_bus(3, 100, beagle_i2c_eeprom, ARRAY_SIZE(beagle_i2c_eeprom));
333 return 0; 429 return 0;
334} 430}
335 431
@@ -465,6 +561,7 @@ static struct omap_musb_board_data musb_board_data = {
465static void __init omap3_beagle_init(void) 561static void __init omap3_beagle_init(void)
466{ 562{
467 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB); 563 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
564 omap3_beagle_init_rev();
468 omap3_beagle_i2c_init(); 565 omap3_beagle_i2c_init();
469 platform_add_devices(omap3_beagle_devices, 566 platform_add_devices(omap3_beagle_devices,
470 ARRAY_SIZE(omap3_beagle_devices)); 567 ARRAY_SIZE(omap3_beagle_devices));