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.c106
1 files changed, 102 insertions, 4 deletions
diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
index 9d9f5b881ee8..14f42240ae79 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -27,6 +27,7 @@
27#include <linux/mtd/mtd.h> 27#include <linux/mtd/mtd.h>
28#include <linux/mtd/partitions.h> 28#include <linux/mtd/partitions.h>
29#include <linux/mtd/nand.h> 29#include <linux/mtd/nand.h>
30#include <linux/mmc/host.h>
30 31
31#include <linux/regulator/machine.h> 32#include <linux/regulator/machine.h>
32#include <linux/i2c/twl.h> 33#include <linux/i2c/twl.h>
@@ -43,13 +44,100 @@
43#include <plat/gpmc.h> 44#include <plat/gpmc.h>
44#include <plat/nand.h> 45#include <plat/nand.h>
45#include <plat/usb.h> 46#include <plat/usb.h>
46#include <plat/timer-gp.h>
47 47
48#include "mux.h" 48#include "mux.h"
49#include "hsmmc.h" 49#include "hsmmc.h"
50#include "timer-gp.h"
50 51
51#define NAND_BLOCK_SIZE SZ_128K 52#define NAND_BLOCK_SIZE SZ_128K
52 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
53static struct mtd_partition omap3beagle_nand_partitions[] = { 141static struct mtd_partition omap3beagle_nand_partitions[] = {
54 /* 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 */
55 { 143 {
@@ -166,7 +254,7 @@ static void __init beagle_display_init(void)
166static struct omap2_hsmmc_info mmc[] = { 254static struct omap2_hsmmc_info mmc[] = {
167 { 255 {
168 .mmc = 1, 256 .mmc = 1,
169 .wires = 8, 257 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
170 .gpio_wp = 29, 258 .gpio_wp = 29,
171 }, 259 },
172 {} /* Terminator */ 260 {} /* Terminator */
@@ -185,7 +273,10 @@ static struct gpio_led gpio_leds[];
185static int beagle_twl_gpio_setup(struct device *dev, 273static int beagle_twl_gpio_setup(struct device *dev,
186 unsigned gpio, unsigned ngpio) 274 unsigned gpio, unsigned ngpio)
187{ 275{
188 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)) {
189 omap_mux_init_gpio(23, OMAP_PIN_INPUT); 280 omap_mux_init_gpio(23, OMAP_PIN_INPUT);
190 mmc[0].gpio_wp = 23; 281 mmc[0].gpio_wp = 23;
191 } else { 282 } else {
@@ -322,13 +413,19 @@ static struct i2c_board_info __initdata beagle_i2c_boardinfo[] = {
322 }, 413 },
323}; 414};
324 415
416static struct i2c_board_info __initdata beagle_i2c_eeprom[] = {
417 {
418 I2C_BOARD_INFO("eeprom", 0x50),
419 },
420};
421
325static int __init omap3_beagle_i2c_init(void) 422static int __init omap3_beagle_i2c_init(void)
326{ 423{
327 omap_register_i2c_bus(1, 2600, beagle_i2c_boardinfo, 424 omap_register_i2c_bus(1, 2600, beagle_i2c_boardinfo,
328 ARRAY_SIZE(beagle_i2c_boardinfo)); 425 ARRAY_SIZE(beagle_i2c_boardinfo));
329 /* 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
330 * projector don't work reliably with 400kHz */ 427 * projector don't work reliably with 400kHz */
331 omap_register_i2c_bus(3, 100, NULL, 0); 428 omap_register_i2c_bus(3, 100, beagle_i2c_eeprom, ARRAY_SIZE(beagle_i2c_eeprom));
332 return 0; 429 return 0;
333} 430}
334 431
@@ -464,6 +561,7 @@ static struct omap_musb_board_data musb_board_data = {
464static void __init omap3_beagle_init(void) 561static void __init omap3_beagle_init(void)
465{ 562{
466 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB); 563 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
564 omap3_beagle_init_rev();
467 omap3_beagle_i2c_init(); 565 omap3_beagle_i2c_init();
468 platform_add_devices(omap3_beagle_devices, 566 platform_add_devices(omap3_beagle_devices,
469 ARRAY_SIZE(omap3_beagle_devices)); 567 ARRAY_SIZE(omap3_beagle_devices));