]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - board/matrix_vision/mvblx/sys_eeprom.c
Update from 2013.01 to 2013.07
[karo-tx-uboot.git] / board / matrix_vision / mvblx / sys_eeprom.c
index 945a36dfe6658196b95d2f81f3cfc70d0ade41b4..1a2ac8d6c8650144da112ded528bd5e2539117d2 100644 (file)
@@ -4,23 +4,7 @@
  * Haiying Wang (haiying.wang@freescale.com)
  * Timur Tabi (timur@freescale.com)
  *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
@@ -326,10 +310,28 @@ int do_mac(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
        return 0;
 }
 
+static inline int is_portrait(void)
+{
+       int i;
+       unsigned int orient_index = 0; /* idx of char which determines orientation */
+
+       for (i = sizeof(e.id)/sizeof(*e.id) - 1; i>=0; i--) {
+               if (e.id[i] == '-') {
+                       orient_index = i+1;
+                       break;
+               }
+       }
+
+       return (orient_index &&
+                       (e.id[orient_index] >= '5') && (e.id[orient_index] <= '8'));
+}
+
 int mac_read_from_eeprom(void)
 {
        u32 crc, crc_offset = offsetof(struct eeprom, crc);
        u32 *crcp; /* Pointer to the CRC in the data read from the EEPROM */
+#define FILENAME_LANDSCAPE "mvBlueLynx_X.rbf"
+#define FILENAME_PORTRAIT "mvBlueLynx_X_sensor_cd.rbf"
 
        if (read_eeprom()) {
                printf("EEPROM Read failed.\n");
@@ -374,6 +376,12 @@ int mac_read_from_eeprom(void)
                        setenv("serial#", serial_num);
        }
 
+       /* decide which fpga file to load depending on orientation */
+       if (is_portrait())
+               setenv("fpgafilename", FILENAME_PORTRAIT);
+       else
+               setenv("fpgafilename", FILENAME_LANDSCAPE);
+
        /* TODO should I calculate CRC here? */
        return 0;
 }