u-boot 2011.12: fix beagleboard C4 memory detection
[glsdk/meta-ti-glsdk.git] / recipes-bsp / u-boot / u-boot / 2011.12 / 0003-beagleboard-add-support-for-scanning-loop-through-ex.patch
1 From c8c3b1adff56c49f20732846a7087e95f6916e61 Mon Sep 17 00:00:00 2001
2 From: Koen Kooi <koen@dominion.thruhere.net>
3 Date: Sun, 27 Nov 2011 14:53:56 +0100
4 Subject: [PATCH 03/10] beagleboard: add support for scanning loop-through expansionboards like the uLCD-lite
6 Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
7 ---
8  board/ti/beagle/beagle.c       |   30 ++++++++++++++++++++++++++----
9  include/configs/omap3_beagle.h |    4 ++++
10  2 files changed, 30 insertions(+), 4 deletions(-)
12 diff --git a/board/ti/beagle/beagle.c b/board/ti/beagle/beagle.c
13 index 9c2e6d0..5ea50d1 100644
14 --- a/board/ti/beagle/beagle.c
15 +++ b/board/ti/beagle/beagle.c
16 @@ -74,6 +74,7 @@ extern volatile struct ehci_hcor *hcor;
17  #define BBTOYS_WIFI                    0x01000B00
18  #define BBTOYS_VGA                     0x02000B00
19  #define BBTOYS_LCD                     0x03000B00
20 +#define BBTOYS_ULCD                    0x04000B00
21  #define BEAGLE_NO_EEPROM               0xffffffff
22  
23  DECLARE_GLOBAL_DATA_PTR;
24 @@ -209,18 +210,18 @@ void get_board_mem_timings(u32 *mcfg, u32 *ctrla, u32 *ctrlb, u32 *rfr_ctrl,
25   *             bus 1 for the availability of an AT24C01B serial EEPROM.
26   *             returns the device_vendor field from the EEPROM
27   */
28 -unsigned int get_expansion_id(void)
29 +unsigned int get_expansion_id(int eeprom_address)
30  {
31         i2c_set_bus_num(EXPANSION_EEPROM_I2C_BUS);
32  
33         /* return BEAGLE_NO_EEPROM if eeprom doesn't respond */
34 -       if (i2c_probe(EXPANSION_EEPROM_I2C_ADDRESS) == 1) {
35 +       if (i2c_probe(eeprom_address) == 1) {
36                 i2c_set_bus_num(TWL4030_I2C_BUS);
37                 return BEAGLE_NO_EEPROM;
38         }
39  
40         /* read configuration data */
41 -       i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 1, (u8 *)&expansion_config,
42 +       i2c_read(eeprom_address, 0, 1, (u8 *)&expansion_config,
43                  sizeof(expansion_config));
44  
45         i2c_set_bus_num(TWL4030_I2C_BUS);
46 @@ -323,7 +324,7 @@ int misc_init_r(void)
47                                         TWL4030_PM_RECEIVER_DEV_GRP_P1);
48         }
49  
50 -       switch (get_expansion_id()) {
51 +       switch (get_expansion_id(EXPANSION_EEPROM_I2C_ADDRESS)) {
52         case TINCANTOOLS_ZIPPY:
53                 printf("Recognized Tincantools Zippy board (rev %d %s)\n",
54                         expansion_config.revision,
55 @@ -402,6 +403,27 @@ int misc_init_r(void)
56         if (expansion_config.content == 1)
57                 setenv(expansion_config.env_var, expansion_config.env_setting);
58  
59 +       /* Scan 0x51 as well for loop-thru boards */
60 +       switch (get_expansion_id(EXPANSION_EEPROM_I2C_ADDRESS + 1)) {
61 +       case BBTOYS_ULCD:
62 +               printf("Recognized BeagleBoardToys uLCD-lite board\n");
63 +               setenv("buddy2", "bbtoys-ulcd");
64 +               setenv("defaultdisplay", "lcd");
65 +               setenv("uenvcmd", "i2c dev 1 ; i2c mw 40 00 00; i2c mw 40 04 80; i2c mw 40 0d 05; i2c mw 40 0d 15");
66 +               break;
67 +       case BEAGLE_NO_EEPROM:
68 +               printf("No EEPROM on expansion board\n");
69 +               setenv("buddy2", "none");
70 +               break;
71 +       default:
72 +               printf("Unrecognized expansion board: %x\n",
73 +                       expansion_config.device_vendor);
74 +               setenv("buddy2", "unknown");
75 +       }
76 +
77 +       if (expansion_config.content == 1)
78 +               setenv(expansion_config.env_var, expansion_config.env_setting);
79 +
80         twl4030_power_init();
81         switch (get_board_revision()) {
82         case REVISION_XM_A:
83 diff --git a/include/configs/omap3_beagle.h b/include/configs/omap3_beagle.h
84 index d4f33d0..65ab8ee 100644
85 --- a/include/configs/omap3_beagle.h
86 +++ b/include/configs/omap3_beagle.h
87 @@ -214,6 +214,7 @@
88         "console=ttyO2,115200n8\0" \
89         "mpurate=auto\0" \
90         "buddy=none "\
91 +       "buddy2=none "\
92         "optargs=\0" \
93         "camera=none\0" \
94         "vram=12M\0" \
95 @@ -230,6 +231,7 @@
96                 "${optargs} " \
97                 "mpurate=${mpurate} " \
98                 "buddy=${buddy} "\
99 +               "buddy2=${buddy2} "\
100                 "camera=${camera} "\
101                 "vram=${vram} " \
102                 "omapfb.mode=dvi:${dvimode} " \
103 @@ -240,6 +242,7 @@
104                 "${optargs} " \
105                 "mpurate=${mpurate} " \
106                 "buddy=${buddy} "\
107 +               "buddy2=${buddy2} "\
108                 "camera=${camera} "\
109                 "vram=${vram} " \
110                 "omapfb.mode=dvi:${dvimode} " \
111 @@ -254,6 +257,7 @@
112                 "${optargs} " \
113                 "mpurate=${mpurate} " \
114                 "buddy=${buddy} "\
115 +               "buddy2=${buddy2} "\
116                 "vram=${vram} " \
117                 "omapfb.mode=dvi:${dvimode} " \
118                 "omapdss.def_disp=${defaultdisplay} " \
119 -- 
120 1.7.2.5