Automatically detect the amount of installed RAM by reading the memory
bank registers from the PCI host bridge. Previously the RAM size was hardcoded to 64MB. Also fill out ibm82660reg.h with more definitions from the PowerPC to PCI Bridge and Memory Controller User's Manual. Many thanks to Tim Rightnour for helping with this patch.
This commit is contained in:
parent
75946855ff
commit
7e2a8aea3b
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: machdep.c,v 1.10 2008/05/22 20:56:24 rjs Exp $ */
|
||||
/* $NetBSD: machdep.c,v 1.11 2008/06/14 12:01:28 mjf Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
|
||||
@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.10 2008/05/22 20:56:24 rjs Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.11 2008/06/14 12:01:28 mjf Exp $");
|
||||
|
||||
#include "opt_compat_netbsd.h"
|
||||
|
||||
@ -69,6 +69,9 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.10 2008/05/22 20:56:24 rjs Exp $");
|
||||
|
||||
#include <powerpc/oea/bat.h>
|
||||
#include <arch/powerpc/pic/picvar.h>
|
||||
#include <arch/powerpc/include/pio.h>
|
||||
#include <dev/pci/pcivar.h>
|
||||
#include <dev/ic/ibm82660reg.h>
|
||||
|
||||
#include <dev/cons.h>
|
||||
|
||||
@ -87,29 +90,49 @@ void
|
||||
initppc(u_long startkernel, u_long endkernel, u_int args, void *btinfo)
|
||||
{
|
||||
|
||||
uint32_t sa, ea, banks;
|
||||
u_long memsize = 0;
|
||||
pcitag_t tag;
|
||||
|
||||
/*
|
||||
* Set memory region
|
||||
* Set memory region by reading the memory size from the PCI
|
||||
* host bridge.
|
||||
*/
|
||||
{
|
||||
u_long memsize;
|
||||
|
||||
#if 0
|
||||
/* Get the memory size from the PCI host bridge */
|
||||
tag = genppc_pci_indirect_make_tag(NULL, 0, 0, 0);
|
||||
|
||||
pci_read_config_32(0, 0x90, &ea);
|
||||
if(ea & 0xff00)
|
||||
memsize = (((ea >> 8) & 0xff) + 1) << 20;
|
||||
else
|
||||
memsize = ((ea & 0xff) + 1) << 20;
|
||||
#else
|
||||
memsize = 64 * 1024 * 1024; /* 64MB hardcoded for now */
|
||||
#endif
|
||||
out32rb(PCI_MODE1_ADDRESS_REG, tag | IBM_82660_MEM_BANK0_START);
|
||||
sa = in32rb(PCI_MODE1_DATA_REG);
|
||||
|
||||
out32rb(PCI_MODE1_ADDRESS_REG, tag | IBM_82660_MEM_BANK0_END);
|
||||
ea = in32rb(PCI_MODE1_DATA_REG);
|
||||
|
||||
/* Which memory banks are enabled? */
|
||||
out32rb(PCI_MODE1_ADDRESS_REG, tag | IBM_82660_MEM_BANK_ENABLE);
|
||||
banks = in32rb(PCI_MODE1_DATA_REG) & 0xFF;
|
||||
|
||||
/* Reset the register for the next call. */
|
||||
out32rb(PCI_MODE1_ADDRESS_REG, 0);
|
||||
|
||||
if (banks & IBM_82660_MEM_BANK0_ENABLED)
|
||||
memsize += IBM_82660_BANK0_ADDR(ea) - IBM_82660_BANK0_ADDR(sa) + 1;
|
||||
|
||||
if (banks & IBM_82660_MEM_BANK1_ENABLED)
|
||||
memsize += IBM_82660_BANK1_ADDR(ea) - IBM_82660_BANK1_ADDR(sa) + 1;
|
||||
|
||||
if (banks & IBM_82660_MEM_BANK2_ENABLED)
|
||||
memsize += IBM_82660_BANK2_ADDR(ea) - IBM_82660_BANK2_ADDR(sa) + 1;
|
||||
|
||||
if (banks & IBM_82660_MEM_BANK3_ENABLED)
|
||||
memsize += IBM_82660_BANK3_ADDR(ea) - IBM_82660_BANK3_ADDR(sa) + 1;
|
||||
|
||||
memsize <<= 20;
|
||||
|
||||
physmemr[0].start = 0;
|
||||
physmemr[0].size = memsize & ~PGOFSET;
|
||||
availmemr[0].start = (endkernel + PGOFSET) & ~PGOFSET;
|
||||
availmemr[0].size = memsize - availmemr[0].start;
|
||||
|
||||
physmemr[0].start = 0;
|
||||
physmemr[0].size = memsize & ~PGOFSET;
|
||||
availmemr[0].start = (endkernel + PGOFSET) & ~PGOFSET;
|
||||
availmemr[0].size = memsize - availmemr[0].start;
|
||||
}
|
||||
avail_end = physmemr[0].start + physmemr[0].size; /* XXX temporary */
|
||||
|
||||
/*
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pci_machdep.h,v 1.5 2008/04/28 20:23:26 martin Exp $ */
|
||||
/* $NetBSD: pci_machdep.h,v 1.6 2008/06/14 12:01:28 mjf Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
@ -48,4 +48,9 @@ void ibmnws_pci_get_chipset_tag(pci_chipset_tag_t pc);
|
||||
* NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE.
|
||||
*/
|
||||
extern struct powerpc_bus_dma_tag pci_bus_dma_tag;
|
||||
|
||||
#define PCI_MODE1_ENABLE 0x80000000UL
|
||||
#define PCI_MODE1_ADDRESS_REG (PREP_BUS_SPACE_IO + 0xcf8)
|
||||
#define PCI_MODE1_DATA_REG (PREP_BUS_SPACE_IO + 0xcfc)
|
||||
|
||||
#endif
|
||||
|
@ -59,12 +59,6 @@
|
||||
#include <dev/pci/pcidevs.h>
|
||||
#include <dev/pci/pciconf.h>
|
||||
|
||||
#define PCI_MODE1_ENABLE 0x80000000UL
|
||||
#define PCI_MODE1_ADDRESS_REG (PREP_BUS_SPACE_IO + 0xcf8)
|
||||
#define PCI_MODE1_DATA_REG (PREP_BUS_SPACE_IO + 0xcfc)
|
||||
|
||||
#define PCI_CBIO 0x10
|
||||
|
||||
void
|
||||
ibmnws_pci_get_chipset_tag_indirect(pci_chipset_tag_t pc)
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ibm82660reg.h,v 1.2 2008/04/28 20:23:50 martin Exp $ */
|
||||
/* $NetBSD: ibm82660reg.h,v 1.3 2008/06/14 12:01:28 mjf Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
@ -36,15 +36,97 @@
|
||||
* Also known as a Lanai/Kauai.
|
||||
*/
|
||||
|
||||
/* Memmory Bank Starting Addresses */
|
||||
#define IBM_82660_MEM_BANK0_START 0x80
|
||||
#define IBM_82660_MEM_BANK1_START 0x81
|
||||
#define IBM_82660_MEM_BANK2_START 0x82
|
||||
#define IBM_82660_MEM_BANK3_START 0x83
|
||||
#define IBM_82660_MEM_BANK4_START 0x84
|
||||
#define IBM_82660_MEM_BANK5_START 0x85
|
||||
#define IBM_82660_MEM_BANK6_START 0x86
|
||||
#define IBM_82660_MEM_BANK7_START 0x87
|
||||
|
||||
/* Memory Bank Extended Starting Addresses */
|
||||
#define IBM_82660_MEM_BANK0_EXTSTART 0x88
|
||||
#define IBM_82660_MEM_BANK1_EXTSTART 0x89
|
||||
#define IBM_82660_MEM_BANK2_EXTSTART 0x8A
|
||||
#define IBM_82660_MEM_BANK3_EXTSTART 0x8B
|
||||
#define IBM_82660_MEM_BANK4_EXTSTART 0x8C
|
||||
#define IBM_82660_MEM_BANK5_EXTSTART 0x8D
|
||||
#define IBM_82660_MEM_BANK6_EXTSTART 0x8E
|
||||
#define IBM_82660_MEM_BANK7_EXTSTART 0x8F
|
||||
|
||||
/* Memory Bank Ending Addresses */
|
||||
#define IBM_82660_MEM_BANK0_END 0x90
|
||||
#define IBM_82660_MEM_BANK1_END 0x91
|
||||
#define IBM_82660_MEM_BANK2_END 0x92
|
||||
#define IBM_82660_MEM_BANK3_END 0x93
|
||||
#define IBM_82660_MEM_BANK4_END 0x94
|
||||
#define IBM_82660_MEM_BANK5_END 0x95
|
||||
#define IBM_82660_MEM_BANK6_END 0x96
|
||||
#define IBM_82660_MEM_BANK7_END 0x97
|
||||
|
||||
/*
|
||||
* Helper functions for working with the Memory Bank
|
||||
* Start/End Address registers.
|
||||
*/
|
||||
#define IBM_82660_BANK0_ADDR(x) ((x) & 0xFF)
|
||||
#define IBM_82660_BANK1_ADDR(x) (((x) & 0xFF00) >> 8)
|
||||
#define IBM_82660_BANK2_ADDR(x) (((x) & 0xFF0000) >> 16)
|
||||
#define IBM_82660_BANK3_ADDR(x) (((x) & 0xFF000000) >> 24)
|
||||
|
||||
/* Memory Bank Extended Ending Addresses */
|
||||
#define IBM_82660_MEM_BANK0_EXTEND 0x98
|
||||
#define IBM_82660_MEM_BANK1_EXTEND 0x99
|
||||
#define IBM_82660_MEM_BANK2_EXTEND 0x9A
|
||||
#define IBM_82660_MEM_BANK3_EXTEND 0x9B
|
||||
#define IBM_82660_MEM_BANK4_EXTEND 0x9C
|
||||
#define IBM_82660_MEM_BANK5_EXTEND 0x9D
|
||||
#define IBM_82660_MEM_BANK6_EXTEND 0x9E
|
||||
#define IBM_82660_MEM_BANK7_EXTEND 0x9F
|
||||
|
||||
#define IBM_82660_MEM_BANK_ENABLE 0xA0
|
||||
#define IBM_82660_MEM_BANK0_ENABLED 0x01
|
||||
#define IBM_82660_MEM_BANK1_ENABLED 0x02
|
||||
#define IBM_82660_MEM_BANK2_ENABLED 0x04
|
||||
#define IBM_82660_MEM_BANK3_ENABLED 0x08
|
||||
|
||||
#define IBM_82660_MEM_TIMING_1 0xA1
|
||||
#define IBM_82660_MEM_TIMING_2 0xA2
|
||||
|
||||
/* Memory Bank Addressing Modes */
|
||||
#define IBM_82660_MEM_BANK01_ADDR_MODE 0xA4 /* Bank 0 and 1 */
|
||||
#define IBM_82660_MEM_BANK23_ADDR_MODE 0xA5 /* Bank 2 and 3 */
|
||||
#define IBM_82660_MEM_BANK45_ADDR_MODE 0xA6 /* Bank 4 and 5 */
|
||||
#define IBM_82660_MEM_BANK67_ADDR_MODE 0xA7 /* Bank 6 and 7 */
|
||||
|
||||
#define IBM_82660_CACHE_STATUS 0xB1
|
||||
#define IBM_82660_CACHE_STATUS_L1_EN 0x01
|
||||
#define IBM_82660_CACHE_STATUS_L2_EN 0x02
|
||||
|
||||
#define IBM_82660_RAS_WATCHDOG_TIMER 0xB6
|
||||
|
||||
#define IBM_82660_SINGLEBIT_ERR_CNTR 0xB8
|
||||
#define IBM_82660_SINGLEBIT_ERR_LEVEL 0xB9
|
||||
|
||||
/* Bridge Options */
|
||||
#define IBM_82660_OPTIONS_1 0xBA
|
||||
#define IBM_82660_OPTIONS_1_MCP 0x01
|
||||
#define IBM_82660_OPTIONS_1_TEA 0x02
|
||||
#define IBM_82660_OPTIONS_1_ISA 0x04
|
||||
|
||||
#define IBM_82660_OPTIONS_2 0xBB
|
||||
|
||||
#define IBM_82660_ERR_ENABLE_1 0xC0
|
||||
#define IBM_82660_ERR_STATUS_1 0xC1
|
||||
|
||||
#define IBM_82660_CPU_ERR_STATUS 0xC3
|
||||
|
||||
#define IBM_82660_ERR_ENABLE_2 0xC4
|
||||
#define IBM_82660_ERR_STATUS_2 0xC5
|
||||
|
||||
#define IBM_82660_PCI_ERR_STATUS 0xC7
|
||||
|
||||
#define IBM_82660_OPTIONS_3 0xD4
|
||||
#define IBM_82660_OPTIONS_3_ECC 0x01
|
||||
#define IBM_82660_OPTIONS_3_DRAM 0x04
|
||||
|
Loading…
Reference in New Issue
Block a user