uboot/board/matrix_vision/common/mv_common.c
<<
>>
Prefs
   1/*
   2 * (C) Copyright 2008
   3 * Andre Schwarz, Matrix Vision GmbH, andre.schwarz@matrix-vision.de
   4 *
   5 * See file CREDITS for list of people who contributed to this
   6 * project.
   7 *
   8 * This program is free software; you can redistribute it and/or
   9 * modify it under the terms of the GNU General Public License as
  10 * published by the Free Software Foundation; either version 2 of
  11 * the License, or (at your option) any later version.
  12 *
  13 * This program is distributed in the hope that it will be useful,
  14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16 * GNU General Public License for more details.
  17 *
  18 * You should have received a copy of the GNU General Public License
  19 * along with this program; if not, write to the Free Software
  20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21 * MA 02111-1307 USA
  22 */
  23
  24#include <common.h>
  25#include <malloc.h>
  26#include <environment.h>
  27#include <fpga.h>
  28#include <asm/io.h>
  29
  30DECLARE_GLOBAL_DATA_PTR;
  31
  32static char* entries_to_keep[] = {
  33        "serial#", "ethaddr", "eth1addr", "model_info", "sensor_cnt",
  34        "fpgadatasize", "ddr_size", "use_dhcp", "use_static_ipaddr",
  35        "static_ipaddr", "static_netmask", "static_gateway",
  36        "syslog", "watchdog", "netboot", "evo8serialnumber" };
  37
  38#define MV_MAX_ENV_ENTRY_LENGTH 64
  39#define MV_KEEP_ENTRIES         ARRAY_SIZE(entries_to_keep)
  40
  41void mv_reset_environment(void)
  42{
  43        int i;
  44        char *s[MV_KEEP_ENTRIES];
  45        char entries[MV_KEEP_ENTRIES][MV_MAX_ENV_ENTRY_LENGTH];
  46
  47        printf("\n*** RESET ENVIRONMENT ***\n");
  48
  49        memset(entries, 0, MV_KEEP_ENTRIES * MV_MAX_ENV_ENTRY_LENGTH);
  50        for (i = 0; i < MV_KEEP_ENTRIES; i++) {
  51                s[i] = getenv(entries_to_keep[i]);
  52                if (s[i]) {
  53                        printf("save '%s' : %s\n", entries_to_keep[i], s[i]);
  54                        strncpy(entries[i], s[i], MV_MAX_ENV_ENTRY_LENGTH);
  55                }
  56        }
  57
  58        gd->env_valid = 0;
  59        env_relocate();
  60
  61        for (i = 0; i < MV_KEEP_ENTRIES; i++) {
  62                if (s[i]) {
  63                        printf("restore '%s' : %s\n", entries_to_keep[i], s[i]);
  64                        setenv(entries_to_keep[i], s[i]);
  65                }
  66        }
  67
  68        saveenv();
  69}
  70
  71int mv_load_fpga(void)
  72{
  73        int result;
  74        size_t data_size = 0;
  75        void *fpga_data = NULL;
  76        char *datastr = getenv("fpgadata");
  77        char *sizestr = getenv("fpgadatasize");
  78
  79        if (getenv("skip_fpga")) {
  80                printf("found 'skip_fpga' -> FPGA _not_ loaded !\n");
  81                return -1;
  82        }
  83        printf("loading FPGA\n");
  84
  85        if (datastr)
  86                fpga_data = (void *)simple_strtoul(datastr, NULL, 16);
  87        if (sizestr)
  88                data_size = (size_t)simple_strtoul(sizestr, NULL, 16);
  89        if (!data_size) {
  90                printf("fpgadatasize invalid -> FPGA _not_ loaded !\n");
  91                return -1;
  92        }
  93
  94        result = fpga_load(0, fpga_data, data_size);
  95        if (!result)
  96                show_boot_progress(0);
  97
  98        return result;
  99}
 100
 101u8 *dhcp_vendorex_prep(u8 *e)
 102{
 103        char *ptr;
 104
 105        /* DHCP vendor-class-identifier = 60 */
 106        if ((ptr = getenv("dhcp_vendor-class-identifier"))) {
 107                *e++ = 60;
 108                *e++ = strlen(ptr);
 109                while (*ptr)
 110                        *e++ = *ptr++;
 111        }
 112        /* DHCP_CLIENT_IDENTIFIER = 61 */
 113        if ((ptr = getenv("dhcp_client_id"))) {
 114                *e++ = 61;
 115                *e++ = strlen(ptr);
 116                while (*ptr)
 117                        *e++ = *ptr++;
 118        }
 119
 120        return e;
 121}
 122
 123u8 *dhcp_vendorex_proc(u8 *popt)
 124{
 125        return NULL;
 126}
 127