Working SPD reading in fwstart.img

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-02-17 21:10:58 +01:00
parent a1efcc79d3
commit 7517048135
8 changed files with 321 additions and 12 deletions

View file

@ -19,17 +19,23 @@
#ifndef GRUB_CS5536_HEADER
#define GRUB_CS5536_HEADER 1
#ifndef ASM_FILE
#include <grub/pci.h>
#include <grub/err.h>
#include <grub/smbus.h>
#endif
#define GRUB_CS5536_PCIID 0x208f1022
#define GRUB_CS5536_MSR_MAILBOX_ADDR 0xf4
#define GRUB_CS5536_MSR_MAILBOX_DATA0 0xf8
#define GRUB_CS5536_MSR_MAILBOX_DATA1 0xfc
#define GRUB_CS5536_MSR_SMB_BAR 0x8000000b
#define GRUB_CS5536_MSR_GPIO_BAR 0x8000000c
#define GRUB_CS5536_SMB_REG_DATA 0x0
#define GRUB_CS5536_SMB_REG_STATUS 0x1
#define GRUB_CS5536_SMB_REG_STATUS_SDAST (1 << 6)
#define GRUB_CS5536_SMB_REG_STATUS_BER (1 << 5)
#define GRUB_CS5536_SMB_REG_STATUS_NACK (1 << 4)
#define GRUB_CS5536_SMB_REG_CTRL1 0x3
#define GRUB_CS5536_SMB_REG_CTRL1_START 0x01
#define GRUB_CS5536_SMB_REG_CTRL1_STOP 0x02
@ -41,11 +47,19 @@
#define GRUB_CS5536_SMB_REG_CTRL3 0x6
#define GRUB_CS5536_LBAR_ADDR_MASK 0x000000000000fff8ULL
#define GRUB_CS5536_LBAR_ADDR_OFF 3
#define GRUB_CS5536_LBAR_ENABLE 0x0000000100000000ULL
#define GRUB_SMB_RAM_START_ADDR 0x50
#define GRUB_SMB_RAM_NUM_MAX 0x08
/* PMON-compatible LBARs. */
#define GRUB_CS5536_LBAR_GPIO 0x0b000
#define GRUB_CS5536_LBAR_SMBUS 0x0b390
#define GRUB_GPIO_SMBUS_PINS ((1 << 14) | (1 << 15))
#define GRUB_GPIO_REG_OUT_EN 0x4
#define GRUB_GPIO_REG_OUT_AUX1 0x10
#define GRUB_GPIO_REG_IN_EN 0x20
#define GRUB_GPIO_REG_IN_AUX1 0x34
#ifndef ASM_FILE
int grub_cs5536_find (grub_pci_device_t *devp);
grub_uint64_t grub_cs5536_read_msr (grub_pci_device_t dev, grub_uint32_t addr);
@ -58,5 +72,6 @@ grub_err_t grub_cs5536_read_spd (grub_port_t smbbase, grub_uint8_t dev,
grub_err_t grub_cs5536_smbus_wait (grub_port_t smbbase);
grub_err_t grub_cs5536_init_smbus (grub_pci_device_t dev, grub_uint16_t divisor,
grub_port_t *smbbase);
#endif
#endif

View file

@ -0,0 +1,27 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2010 Free Software Foundation, Inc.
*
* GRUB 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 3 of the License, or
* (at your option) any later version.
*
* GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRUB_BOOT_MACHINE_HEADER
#define GRUB_BOOT_MACHINE_HEADER 1
#define GRUB_MACHINE_FLASH_START 0xbfc00000
#define GRUB_MACHINE_FLASH_TLB_REFILL 0xbfc00200
#define GRUB_MACHINE_FLASH_CACHE_ERROR 0xbfc00300
#define GRUB_MACHINE_FLASH_OTHER_EXCEPTION 0xbfc00380
#endif

View file

@ -19,16 +19,24 @@
#ifndef GRUB_MACHINE_PCI_H
#define GRUB_MACHINE_PCI_H 1
#ifndef ASM_FILE
#include <grub/types.h>
#include <grub/cpu/io.h>
#endif
#define GRUB_PCI_NUM_BUS 1
#define GRUB_PCI_NUM_DEVICES 16
#define GRUB_MACHINE_PCI_IO_BASE 0xbfd00000
#define GRUB_MACHINE_PCI_CONFSPACE 0xbfe80000
#ifndef ASM_FILE
#define GRUB_MACHINE_PCI_CONF_CTRL_REG (*(volatile grub_uint32_t *) 0xbfe00118)
#define GRUB_MACHINE_PCI_IO_CTRL_REG (*(volatile grub_uint32_t *) 0xbfe00110)
#else
#define GRUB_MACHINE_PCI_CONF_CTRL_REG_HI 0xbfe0
#define GRUB_MACHINE_PCI_CONF_CTRL_REG_LO 0x0118
#endif
#define GRUB_MACHINE_PCI_WIN_MASK_SIZE 6
#define GRUB_MACHINE_PCI_WIN_MASK ((1 << GRUB_MACHINE_PCI_WIN_MASK_SIZE) - 1)
@ -46,6 +54,7 @@
#define GRUB_MACHINE_PCI_WIN2_ADDR 0xb4000000
#define GRUB_MACHINE_PCI_WIN3_ADDR 0xb8000000
#ifndef ASM_FILE
static inline grub_uint32_t
grub_pci_read (grub_pci_address_t addr)
{
@ -101,5 +110,6 @@ void
grub_pci_device_unmap_range (grub_pci_device_t dev __attribute__ ((unused)),
volatile void *mem,
grub_size_t size __attribute__ ((unused)));
#endif
#endif /* GRUB_MACHINE_PCI_H */

View file

@ -19,8 +19,10 @@
#ifndef GRUB_PCI_H
#define GRUB_PCI_H 1
#ifndef ASM_FILE
#include <grub/types.h>
#include <grub/symbol.h>
#endif
#define GRUB_PCI_ADDR_SPACE_MASK 0x01
#define GRUB_PCI_ADDR_SPACE_MEMORY 0x00
@ -66,6 +68,7 @@
#define GRUB_PCI_REG_MIN_GNT 0x3e
#define GRUB_PCI_REG_MAX_LAT 0x3f
#ifndef ASM_FILE
typedef grub_uint32_t grub_pci_id_t;
#ifdef GRUB_UTIL
@ -106,5 +109,6 @@ grub_pci_address_t EXPORT_FUNC(grub_pci_make_address) (grub_pci_device_t dev,
int reg);
void EXPORT_FUNC(grub_pci_iterate) (grub_pci_iteratefunc_t hook);
#endif
#endif /* GRUB_PCI_H */

View file

@ -19,6 +19,9 @@
#ifndef GRUB_SMBUS_HEADER
#define GRUB_SMBUS_HEADER 1
#define GRUB_SMB_RAM_START_ADDR 0x50
#define GRUB_SMB_RAM_NUM_MAX 0x08
struct grub_smbus_spd
{
grub_uint8_t written_size;