uboot/board/pn62/pn62.c
<<
>>
Prefs
   1/*
   2 * (C) Copyright 2002 Wolfgang Grandegger <wg@denx.de>
   3 *
   4 * SPDX-License-Identifier:     GPL-2.0+
   5 */
   6
   7#include <common.h>
   8#include <mpc824x.h>
   9#include <net.h>
  10#include <pci.h>
  11#include <netdev.h>
  12
  13#include "pn62.h"
  14
  15DECLARE_GLOBAL_DATA_PTR;
  16
  17static int get_serial_number (char *string, int size);
  18static void get_mac_address(int id, u8 *mac);
  19
  20#ifdef CONFIG_SHOW_BOOT_PROGRESS
  21void show_boot_progress (int phase)
  22{
  23        /*
  24         * Show phases of the bootm command on the front panel
  25         * LEDs and the scratchpad register #3 as well. We use
  26         * blinking LEDs for logical "1".
  27         */
  28        if (phase > 0) {
  29                set_led (8, (phase & 0x1) ? LED_SLOW_CLOCK : LED_0);
  30                set_led (9, (phase & 0x2) ? LED_SLOW_CLOCK : LED_0);
  31                set_led (10, (phase & 0x4) ? LED_SLOW_CLOCK : LED_0);
  32                set_led (11, (phase & 0x8) ? LED_SLOW_CLOCK : LED_0);
  33        }
  34        i2155x_write_scrapad (BOOT_STATUS, phase);
  35        if (phase < 0)
  36                i2155x_write_scrapad (BOOT_DONE, BOOT_DONE_ERROR);
  37}
  38#endif
  39
  40void show_startup_phase (int phase)
  41{
  42        /*
  43         * Show the phase of U-Boot startup on the front panel
  44         * LEDs and the scratchpad register #3 as well.
  45         */
  46        if (phase > 0) {
  47                set_led (8, (phase & 0x1) ? LED_1 : LED_0);
  48                set_led (9, (phase & 0x2) ? LED_1 : LED_0);
  49                set_led (10, (phase & 0x4) ? LED_1 : LED_0);
  50                set_led (11, (phase & 0x8) ? LED_1 : LED_0);
  51        }
  52        i2155x_write_scrapad (BOOT_STATUS, phase);
  53        if (phase < 0)
  54                i2155x_write_scrapad (BOOT_DONE, BOOT_DONE_ERROR);
  55}
  56
  57int checkboard (void)
  58{
  59        show_startup_phase (1);
  60        puts ("Board: PN62\n");
  61        return 0;
  62}
  63
  64phys_size_t initdram (int board_type)
  65{
  66        long size;
  67        long new_bank0_end;
  68        long mear1;
  69        long emear1;
  70
  71        show_startup_phase (2);
  72
  73        size = get_ram_size(CONFIG_SYS_SDRAM_BASE, CONFIG_SYS_MAX_RAM_SIZE);
  74
  75        new_bank0_end = size - 1;
  76        mear1 = mpc824x_mpc107_getreg (MEAR1);
  77        emear1 = mpc824x_mpc107_getreg (EMEAR1);
  78        mear1 = (mear1 & 0xFFFFFF00) |
  79                ((new_bank0_end & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT);
  80        emear1 = (emear1 & 0xFFFFFF00) |
  81                ((new_bank0_end & MICR_ADDR_MASK) >> MICR_EADDR_SHIFT);
  82        mpc824x_mpc107_setreg (MEAR1, mear1);
  83        mpc824x_mpc107_setreg (EMEAR1, emear1);
  84
  85        return (size);
  86}
  87
  88/*
  89 * Initialize PCI Devices. We rely on auto-configuration.
  90 */
  91#ifndef CONFIG_PCI_PNP
  92#error "CONFIG_PCI_PNP is not defined, please correct!"
  93#endif
  94
  95struct pci_controller hose = {
  96};
  97
  98void pci_init_board (void)
  99{
 100        show_startup_phase (4);
 101        pci_mpc824x_init (&hose);
 102
 103        show_startup_phase (5);
 104        i2155x_init ();
 105        show_startup_phase (6);
 106        am79c95x_init ();
 107        show_startup_phase (7);
 108}
 109
 110int misc_init_r (void)
 111{
 112        char str[20];
 113        u8 mac[6];
 114
 115        show_startup_phase (8);
 116        /*
 117         * Get serial number and ethernet addresses if not already defined
 118         * and update the board info structure and the environment.
 119         */
 120        if (getenv ("serial#") == NULL &&
 121                get_serial_number (str, strlen (str)) > 0) {
 122                setenv ("serial#", str);
 123        }
 124        show_startup_phase (9);
 125
 126        if (!eth_getenv_enetaddr("ethaddr", mac)) {
 127                get_mac_address(0, mac);
 128                eth_setenv_enetaddr("ethaddr", mac);
 129        }
 130        show_startup_phase (10);
 131
 132#ifdef CONFIG_HAS_ETH1
 133        if (!eth_getenv_enetaddr("eth1addr", mac)) {
 134                get_mac_address(1, mac);
 135                eth_setenv_enetaddr("eth1addr", mac);
 136        }
 137#endif /* CONFIG_HAS_ETH1 */
 138        show_startup_phase (11);
 139
 140        /* Tell everybody that U-Boot is up and runnig */
 141        i2155x_write_scrapad (0, 0x12345678);
 142        return (0);
 143}
 144
 145static int get_serial_number (char *string, int size)
 146{
 147        int i;
 148        char c;
 149
 150        if (size < I2155X_VPD_SN_SIZE)
 151                size = I2155X_VPD_SN_SIZE;
 152        for (i = 0; i < (size - 1); i++) {
 153                i2155x_read_vpd (I2155X_VPD_SN_START + i, 1, (uchar *)&c);
 154                if (c == '\0')
 155                        break;
 156                string[i] = c;
 157        }
 158        string[i] = '\0';                       /* make sure it's terminated */
 159
 160        return i;
 161}
 162
 163static void get_mac_address(int id, u8 *mac)
 164{
 165        i2155x_read_vpd (I2155X_VPD_MAC0_START + 6 * id, 6, mac);
 166}
 167
 168int board_eth_init(bd_t *bis)
 169{
 170        return pci_eth_init(bis);
 171}
 172