coreboot-v3/mainboard/artecgroup/dbe63/initram.c
<<
>>
Prefs
   1/*
   2 * This file is part of the coreboot project.
   3 *
   4 * Copyright (C) 2007 Advanced Micro Devices, Inc.
   5 *
   6 * This program is free software; you can redistribute it and/or modify
   7 * it under the terms of the GNU General Public License as published by
   8 * the Free Software Foundation; either version 2 of the License, or
   9 * (at your option) any later version.
  10 *
  11 * This program is distributed in the hope that it will be useful,
  12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14 * GNU General Public License for more details.
  15 *
  16 * You should have received a copy of the GNU General Public License
  17 * along with this program; if not, write to the Free Software
  18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  19 */
  20
  21#define _MAINOBJECT
  22
  23#include <types.h>
  24#include <lib.h>
  25#include <console.h>
  26#include <device/device.h>
  27#include <device/pci.h>
  28#include <string.h>
  29#include <msr.h>
  30#include <io.h>
  31#include <amd_geodelx.h>
  32#include <northbridge/amd/geodelx/raminit.h>
  33
  34/* #include <device/smbus.h>
  35 * TODO: figure out how smbus functions should be done. See smbus_ops.c
  36 */
  37extern int smbus_read_byte(u16 device, u8 address);
  38
  39#define MANUALCONF 0            /* Do automatic strapped PLL config */
  40#define PLLMSRHI 0x00001490     /* manual settings for the PLL */
  41#define PLLMSRLO 0x02000030
  42#define DIMM0 ((u8) 0xA0)
  43#define DIMM1 ((u8) 0xA2)
  44
  45/**
  46 * Read a byte from the SPD. 
  47 *
  48 * For this board, that is really just saying 'read a byte from SMBus'.
  49 * So we use smbus_read_byte(). Nota Bene: leave this here as a function 
  50 * rather than a #define in an obscure location. This function is called 
  51 * only a few dozen times, and it's not performance critical. 
  52 *
  53 * @param device The device.
  54 * @param address The address.
  55 * @return The data from the SMBus packet area or an error of 0xff (i.e. -1).
  56 */
  57u8 spd_read_byte(u16 device, u8 address)
  58{
  59        u8 spdbyte;
  60
  61        printk(BIOS_DEBUG, "spd_read_byte dev %04x\n", device);
  62
  63        spdbyte = smbus_read_byte(device, address);
  64
  65        printk(BIOS_DEBUG, " addr %02x returns %02x\n", address, spdbyte);
  66
  67        return spdbyte;
  68}
  69
  70/**
  71  * Placeholder in case we ever need it. Since this file is a
  72  * template for other motherboards, we want this here and we want the
  73  * call in the right place.
  74  */
  75
  76static void mb_gpio_init(void)
  77{
  78        /* Early mainboard specific GPIO setup */
  79}
  80
  81/**
  82  * main for initram for the AMD DB800 development platform.
  83  * It might seem that you could somehow do these functions in, e.g., the cpu
  84  * code, but the order of operations and what those operations are is VERY
  85  * strongly mainboard dependent. It's best to leave it in the mainboard code.
  86  */
  87int main(void)
  88{
  89        printk(BIOS_DEBUG, "Hi there from initram (stage1) main!\n");
  90        post_code(POST_START_OF_MAIN);
  91
  92        system_preinit();
  93        printk(BIOS_DEBUG, "done preinit\n");
  94
  95        mb_gpio_init();
  96        printk(BIOS_DEBUG, "done gpio init\n");
  97
  98        pll_reset(MANUALCONF, PLLMSRHI, PLLMSRLO);
  99        printk(BIOS_DEBUG, "done pll reset\n");
 100
 101        cpu_reg_init(0, DIMM0, DIMM1, DRAM_UNTERMINATED);
 102        printk(BIOS_DEBUG, "done cpu reg init\n");
 103
 104        sdram_set_registers();
 105        printk(BIOS_DEBUG, "done sdram set registers\n");
 106
 107        sdram_set_spd_registers(DIMM0, DIMM1);
 108        printk(BIOS_DEBUG, "done sdram set spd registers\n");
 109
 110        sdram_enable(DIMM0, DIMM1);
 111        printk(BIOS_DEBUG, "done sdram enable\n");
 112
 113        /* Check low memory */
 114        /*ram_check(0x00000000, 640*1024); */
 115
 116        printk(BIOS_DEBUG, "stage1 returns\n");
 117        return 0;
 118}
 119
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.