/*
 * (C) Copyright 2000
 * Rob Taylor, Flying Pig Systems. robt@flyingpig.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
 */

#include <ppcboot.h>
#include <mpc8240.h>

int checkboard (void)
{
    printf("Sandpoint ");
    /*TODO: Check processor type*/
    printf("8240 Unity ##Test not implemented yet##\n");
    return 0;
}

int checkflash (void)
{
    /* TODO: XXX XXX XXX */
    printf ("## Test not implemented yet ##\n");

    return (0);
}

static long
dram_size(void)
{
  static const unsigned long
    addressmask = 0x4ff00000,
    addressinc  = 0x00100000;
  long result = 0;

#if (CFG_BANK_ENABLE & 0x80)
    result += (CFG_BANK7_END & addressmask) + addressinc - (CFG_BANK7_START & addressmask);
#endif
#if (CFG_BANK_ENABLE & 0x40)
    result += (CFG_BANK6_END & addressmask) + addressinc - (CFG_BANK6_START & addressmask);
#endif
#if (CFG_BANK_ENABLE & 0x20)
    result += (CFG_BANK5_END & addressmask) + addressinc - (CFG_BANK5_START & addressmask);
#endif
#if (CFG_BANK_ENABLE & 0x10)
    result += (CFG_BANK4_END & addressmask) + addressinc - (CFG_BANK4_START & addressmask);
#endif
#if (CFG_BANK_ENABLE & 0x08)
    result += (CFG_BANK3_END & addressmask) + addressinc - (CFG_BANK3_START & addressmask);
#endif
#if (CFG_BANK_ENABLE & 0x04)
    result += (CFG_BANK2_END & addressmask) + addressinc - (CFG_BANK2_START & addressmask);
#endif
#if (CFG_BANK_ENABLE & 0x02)
    result += (CFG_BANK1_END & addressmask) + addressinc - (CFG_BANK1_START & addressmask);
#endif
#if (CFG_BANK_ENABLE & 0x01)
    result += (CFG_BANK0_END & addressmask) + addressinc - (CFG_BANK0_START & addressmask);
#endif

  return result;
}

long int initdram(int board_type)
{
  return dram_size();
}



/* temporarily here: to be removed: */


int eth_init(bd_t *bis)
{
  /* Initialize the device  */
  return 0;
}

int eth_send(volatile void *packet, int length)
{
  /* Send a packet */
  return 0;
}

int eth_rx(void)
{
  /* Check for received packets */
  return 0;
}

void eth_halt(void)
{
  /* stop ethernet     */
}
