uboot/board/keymile/kmeter1/kmeter1.c
<<
>>
Prefs
   1/*
   2 * Copyright (C) 2006 Freescale Semiconductor, Inc.
   3 *                    Dave Liu <daveliu@freescale.com>
   4 *
   5 * Copyright (C) 2007 Logic Product Development, Inc.
   6 *                    Peter Barada <peterb@logicpd.com>
   7 *
   8 * Copyright (C) 2007 MontaVista Software, Inc.
   9 *                    Anton Vorontsov <avorontsov@ru.mvista.com>
  10 *
  11 * (C) Copyright 2008
  12 * Heiko Schocher, DENX Software Engineering, hs@denx.de.
  13 *
  14 * This program is free software; you can redistribute it and/or
  15 * modify it under the terms of the GNU General Public License as
  16 * published by the Free Software Foundation; either version 2 of
  17 * the License, or (at your option) any later version.
  18 */
  19
  20#include <common.h>
  21#include <ioports.h>
  22#include <mpc83xx.h>
  23#include <i2c.h>
  24#include <miiphy.h>
  25#include <asm/io.h>
  26#include <asm/mmu.h>
  27#include <asm/processor.h>
  28#include <pci.h>
  29#include <libfdt.h>
  30
  31#include "../common/common.h"
  32
  33extern void disable_addr_trans (void);
  34extern void enable_addr_trans (void);
  35const qe_iop_conf_t qe_iop_conf_tab[] = {
  36        /* port pin dir open_drain assign */
  37
  38        /* MDIO */
  39        {0,  1, 3, 0, 2}, /* MDIO */
  40        {0,  2, 1, 0, 1}, /* MDC */
  41
  42        /* UCC4 - UEC */
  43        {1, 14, 1, 0, 1}, /* TxD0 */
  44        {1, 15, 1, 0, 1}, /* TxD1 */
  45        {1, 20, 2, 0, 1}, /* RxD0 */
  46        {1, 21, 2, 0, 1}, /* RxD1 */
  47        {1, 18, 1, 0, 1}, /* TX_EN */
  48        {1, 26, 2, 0, 1}, /* RX_DV */
  49        {1, 27, 2, 0, 1}, /* RX_ER */
  50        {1, 24, 2, 0, 1}, /* COL */
  51        {1, 25, 2, 0, 1}, /* CRS */
  52        {2, 15, 2, 0, 1}, /* TX_CLK - CLK16 */
  53        {2, 16, 2, 0, 1}, /* RX_CLK - CLK17 */
  54
  55        /* DUART - UART2 */
  56        {5,  0, 1, 0, 2}, /* UART2_SOUT */
  57        {5,  2, 1, 0, 1}, /* UART2_RTS */
  58        {5,  3, 2, 0, 2}, /* UART2_SIN */
  59        {5,  1, 2, 0, 3}, /* UART2_CTS */
  60
  61        /* END of table */
  62        {0,  0, 0, 0, QE_IOP_TAB_END},
  63};
  64
  65static int board_init_i2c_busses (void)
  66{
  67        I2C_MUX_DEVICE *dev = NULL;
  68        uchar   *buf;
  69
  70        /* Set up the Bus for the DTTs */
  71        buf = (unsigned char *) getenv ("dtt_bus");
  72        if (buf != NULL)
  73                dev = i2c_mux_ident_muxstring (buf);
  74        if (dev == NULL) {
  75                printf ("Error couldn't add Bus for DTT\n");
  76                printf ("please setup dtt_bus to where your\n");
  77                printf ("DTT is found.\n");
  78        }
  79        return 0;
  80}
  81
  82int board_early_init_r (void)
  83{
  84        unsigned short  svid;
  85
  86        /*
  87         * Because of errata in the UCCs, we have to write to the reserved
  88         * registers to slow the clocks down.
  89         */
  90        svid =  SVR_REV(mfspr (SVR));
  91        switch (svid) {
  92        case 0x0020:
  93                setbits_be32((void *)(CONFIG_SYS_IMMR + 0x14a8), 0x0c003000);
  94                break;
  95        case 0x0021:
  96                clrsetbits_be32((void *)(CONFIG_SYS_IMMR + 0x14ac),
  97                        0x00000050, 0x000000a0);
  98                break;
  99        }
 100        /* enable the PHY on the PIGGY */
 101        setbits (8, (void *)(CONFIG_SYS_PIGGY_BASE + 0x10003), 0x01);
 102        /* enable the Unit LED (green) */
 103        setbits (8, (void *)(CONFIG_SYS_PIGGY_BASE + 0x00002), 0x01);
 104        /* take FE/GbE PHYs out of reset */
 105        setbits (8, (void *)(CONFIG_SYS_PIGGY_BASE + 0x0000f), 0x1c);
 106
 107        return 0;
 108}
 109
 110int misc_init_r (void)
 111{
 112        /* add board specific i2c busses */
 113        board_init_i2c_busses ();
 114        return 0;
 115}
 116
 117int fixed_sdram(void)
 118{
 119        volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
 120        u32 msize = 0;
 121        u32 ddr_size;
 122        u32 ddr_size_log2;
 123
 124        im->sysconf.ddrlaw[0].ar = LAWAR_EN | 0x1e;
 125        im->ddr.csbnds[0].csbnds = CONFIG_SYS_DDR_CS0_BNDS;
 126        im->ddr.cs_config[0] = CONFIG_SYS_DDR_CS0_CONFIG;
 127        im->ddr.timing_cfg_0 = CONFIG_SYS_DDR_TIMING_0;
 128        im->ddr.timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1;
 129        im->ddr.timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2;
 130        im->ddr.timing_cfg_3 = CONFIG_SYS_DDR_TIMING_3;
 131        im->ddr.sdram_cfg = CONFIG_SYS_DDR_SDRAM_CFG;
 132        im->ddr.sdram_cfg2 = CONFIG_SYS_DDR_SDRAM_CFG2;
 133        im->ddr.sdram_mode = CONFIG_SYS_DDR_MODE;
 134        im->ddr.sdram_mode2 = CONFIG_SYS_DDR_MODE2;
 135        im->ddr.sdram_interval = CONFIG_SYS_DDR_INTERVAL;
 136        im->ddr.sdram_clk_cntl = CONFIG_SYS_DDR_CLK_CNTL;
 137        udelay (200);
 138        im->ddr.sdram_cfg |= SDRAM_CFG_MEM_EN;
 139
 140        msize = CONFIG_SYS_DDR_SIZE << 20;
 141        disable_addr_trans ();
 142        msize = get_ram_size (CONFIG_SYS_DDR_BASE, msize);
 143        enable_addr_trans ();
 144        msize /= (1024 * 1024);
 145        if (CONFIG_SYS_DDR_SIZE != msize) {
 146                for (ddr_size = msize << 20, ddr_size_log2 = 0;
 147                     (ddr_size > 1); ddr_size = ddr_size >> 1, ddr_size_log2++)
 148                        if (ddr_size & 1)
 149                                return -1;
 150                im->sysconf.ddrlaw[0].ar =
 151                    LAWAR_EN | ((ddr_size_log2 - 1) & LAWAR_SIZE);
 152                im->ddr.csbnds[0].csbnds = (((msize / 16) - 1) & 0xff);
 153        }
 154
 155        return msize;
 156}
 157
 158phys_size_t initdram (int board_type)
 159{
 160#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
 161        extern void ddr_enable_ecc (unsigned int dram_size);
 162#endif
 163        volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
 164        u32 msize = 0;
 165
 166        if ((im->sysconf.immrbar & IMMRBAR_BASE_ADDR) != (u32)im)
 167                return -1;
 168
 169        /* DDR SDRAM - Main SODIMM */
 170        im->sysconf.ddrlaw[0].bar = CONFIG_SYS_DDR_BASE & LAWBAR_BAR;
 171        msize = fixed_sdram ();
 172
 173#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
 174        /*
 175         * Initialize DDR ECC byte
 176         */
 177        ddr_enable_ecc (msize * 1024 * 1024);
 178#endif
 179
 180        /* return total bus SDRAM size(bytes)  -- DDR */
 181        return (msize * 1024 * 1024);
 182}
 183
 184int checkboard (void)
 185{
 186        puts ("Board: Keymile kmeter1");
 187        if (ethernet_present ())
 188                puts (" with PIGGY.");
 189        puts ("\n");
 190        return 0;
 191}
 192
 193#if defined(CONFIG_OF_BOARD_SETUP)
 194/*
 195 * update property in the blob
 196 */
 197void ft_blob_update (void *blob, bd_t *bd)
 198{
 199  /* no board specific update */
 200}
 201
 202
 203void ft_board_setup (void *blob, bd_t *bd)
 204{
 205        ft_cpu_setup (blob, bd);
 206        ft_blob_update (blob, bd);
 207}
 208#endif
 209
 210#if defined(CONFIG_HUSH_INIT_VAR)
 211extern int ivm_read_eeprom (void);
 212int hush_init_var (void)
 213{
 214        ivm_read_eeprom ();
 215        return 0;
 216}
 217#endif
 218