From d17a78e726e23b91ce51dff2caa6cee597e0523d Mon Sep 17 00:00:00 2001 From: Greg Watson Date: Tue, 15 Apr 2003 19:32:35 +0000 Subject: [PATCH] more ppc --- src/mainboard/motorola/sandpoint/flash.h | 36 ++++++++ src/mainboard/motorola/sandpoint/nvram.h | 37 +++++++++ src/mainboard/motorola/sandpoint/sandpoint.c | 86 ++++++++++++++++++++ 3 files changed, 159 insertions(+) create mode 100644 src/mainboard/motorola/sandpoint/flash.h create mode 100644 src/mainboard/motorola/sandpoint/nvram.h create mode 100644 src/mainboard/motorola/sandpoint/sandpoint.c diff --git a/src/mainboard/motorola/sandpoint/flash.h b/src/mainboard/motorola/sandpoint/flash.h new file mode 100644 index 0000000000..5ef1c6e19a --- /dev/null +++ b/src/mainboard/motorola/sandpoint/flash.h @@ -0,0 +1,36 @@ +/* $Id$ */ +/* Copyright 2000 AG Electronics Ltd. */ +/* This code is distributed without warranty under the GPL v2 (see COPYING) */ + +#ifndef _FLASH_H +#define _FLASH_H + +struct flash_device; + +typedef struct flash_fn +{ + const char *(* identify)(struct flash_device *flash); + void *(* ptr)(void *data); + int (* erase_all)(void *data); + int (* erase)(void *data, unsigned offset, unsigned length); + int (* program)(void *data, unsigned offset, const void *source, unsigned length); + u8 ( *read_byte)(void *data, unsigned offset); +} flash_fn; + +typedef struct flash_device +{ + const flash_fn *fn; + char *tag; + void *data; + unsigned long base; + unsigned size; + unsigned erase_size; + unsigned store_size; + struct flash_device *next; +} flash_device; + +int register_flash_device(const flash_fn *fn, char *tag, void *data); +flash_device *find_flash_device(const char *tag); +int init_flash_amd800(char *tag, unsigned base, unsigned spacing); + +#endif diff --git a/src/mainboard/motorola/sandpoint/nvram.h b/src/mainboard/motorola/sandpoint/nvram.h new file mode 100644 index 0000000000..67b99f57f6 --- /dev/null +++ b/src/mainboard/motorola/sandpoint/nvram.h @@ -0,0 +1,37 @@ +/* $Id$ */ +/* Copyright 2000 AG Electronics Ltd. */ +/* This code is distributed without warranty under the GPL v2 (see COPYING) */ +/* Definitions for nvram devices - these are flash or eeprom devices used to + store information across power cycles and resets. Though they are byte + addressable, writes must be committed to allow flash devices to write + complete sectors. */ + +#ifndef _NVRAM_H +#define _NVRAM_H + +typedef struct nvram_device +{ + unsigned (*size)(struct nvram_device *data); + int (*read_block)(struct nvram_device *dev, unsigned offset, + unsigned char *data, unsigned length); + int (*write_byte)(struct nvram_device *dev, unsigned offset, unsigned char byte); + void (*commit)(struct nvram_device *data); + void *data; +} nvram_device; + +int nvram_init (nvram_device *dev); +void nvram_clear(void); + +extern nvram_device pcrtc_nvram; +extern void nvram_putenv(const char *name, const char *value); +extern int nvram_getenv(const char *name, char *buffer, unsigned size); + +typedef const struct nvram_constant +{ + const char *name; + const char *value; +} nvram_constant; + +extern nvram_constant hardcoded_environment[]; + +#endif diff --git a/src/mainboard/motorola/sandpoint/sandpoint.c b/src/mainboard/motorola/sandpoint/sandpoint.c new file mode 100644 index 0000000000..2491de8ff2 --- /dev/null +++ b/src/mainboard/motorola/sandpoint/sandpoint.c @@ -0,0 +1,86 @@ +/* $Id$ */ +/* Copyright 2000 AG Electronics Ltd. */ +/* This code is distributed without warranty under the GPL v2 (see COPYING) */ + +#include +#include +#include +#include +#include +#include +#include +#include "nvram.h" + +#define ONEMEG 0x00100000 +#define HALFMEG 0x00080000 + +int memory_has_failed = 0; + +//extern char __heap_end[]; +extern nvram_device bsp_nvram; +extern int init_flash_amd800(char *, unsigned, unsigned); + +#if 0 +void bsp_relocate(void) +{ + extern unsigned _iseg[]; + extern unsigned _liseg[]; + extern unsigned _eiseg[]; + unsigned *to; + unsigned *from; + + from = _liseg; + to = _iseg; + + while ( from < _eiseg ) + *to++ = *from++; +} + +void bsp_init_post_reloc(unsigned memory) +{ + extern char __stack_end[]; + physical_memory_size = memory; + memory_top = memory - ONEMEG; + memory_base = 0; + /* Use tiny default heap */ + malloc_add_pool(__stack_end, __heap_end - __stack_end); +} + +void bsp_init_post_hello(void) +{ + init_flash_amd800("BOOT", 0xff000000, 1); + init_flash_amd800("BOOT", 0xff800000, 1); + pci_configure(); + printk_info("Memory from 0x%08lx to 0x%08lx\n", memory_base, memory_top); + nvram_init(&bsp_nvram); + + if (!memory_has_failed) + { + printk_info("Clearing memory..."); + //memset(0, 0, memory_top); trashes dink + //block_add_pool(0, memory_top); + printk_info("Done\n"); + } +} + +void bsp_indicate_dead(void) +{ + for(;;) + { + } +} + +void bsp_identify(void) +{ + printk_info("Sandpoint BSP\n"); + + ppc_identify(); + //net_init(); +} +#endif + +unsigned bsp_clock_speed(void) +{ + return 100000000 / 4; +} +