summaryrefslogtreecommitdiff
path: root/board/egnite/ethernut5/ethernut5.c
diff options
context:
space:
mode:
authorWolfgang Denk <wd@denx.de>2011-12-07 09:09:58 +0100
committerWolfgang Denk <wd@denx.de>2011-12-07 09:09:58 +0100
commitc786f54b9ace5d7b20a0404a7deb1bae683cd4e8 (patch)
tree8c612b0abb45c0b1bb1ca39df97620a0ab026797 /board/egnite/ethernut5/ethernut5.c
parent99dee4b2ef570f289e2b1f105df0fdb8ad57ebd1 (diff)
parent15422043c4a213dc5d7d59a337be1ab34c9b2e7f (diff)
downloadu-boot-imx-c786f54b9ace5d7b20a0404a7deb1bae683cd4e8.zip
u-boot-imx-c786f54b9ace5d7b20a0404a7deb1bae683cd4e8.tar.gz
u-boot-imx-c786f54b9ace5d7b20a0404a7deb1bae683cd4e8.tar.bz2
Merge branch 'master' of git://git.denx.de/u-boot-arm
* 'master' of git://git.denx.de/u-boot-arm: davinci: Remove unwanted memsize.c from hawkboard's nand spl build devkit8000: Move CONFIG_SYS_TEXT_BASE out of bss da850evm: pass board revision info to kernel arch/arm/include/asm/arch-omap5/clocks.h: Fix GCC 4.2 warnings arch/arm/cpu/armv7/omap-common/clocks-common.c: Fix GCC 4.6 warnings arch/arm/cpu/armv7/omap-common/spl.c: Fix GCC 4.2 warnings MX35: flea3: changes due to hardware revision B MX: serial_mxc: cleanup removing nasty #ifdef M28: Fix OB1 bug in GPIO driver MXS: Add static annotations to dma driver apbh_dma: return error value on timeout Efika: Configure additional regulators for HDMI output mx5: Correct a warning in clock.c MC13892: Add REGMODE0 bits definitions mx51evk: Configure the pins as GPIOs prior to using gpio_get_value mx53smd: Configure the pins as GPIOs prior to using gpio_get_value mx53evk: Configure the pins as GPIOs prior to using gpio_get_value mx53ard: Configure the pins as GPIOs prior to using gpio_get_value mx53loco: Configure the pins as GPIOs prior to using gpio_get_value OMAP3: Add SPL_BOARD_INIT hook AM3517 CraneBoard: Add SPL support AM3517: Add SPL support OMAP3: Add SPL support to omap3_evm OMAP3: Add SPL support to Beagleboard OMAP3 SPL: Add identify_nand_chip function OMAP3 SPL: Rework memory initalization and devkit8000 support OMAP3: Suffix all Micron memory timing parts with their speed OMAP3: Add optimal SDRC autorefresh control values omap3: mem: Add MCFG helper macro OMAP3: Remove get_mem_type prototype OMAP3: Change mem_ok to clear again after reading back OMAP3: Add a helper function to set timings in SDRC OMAP3: Update SDRC dram_init to always call make_cs1_contiguous() omap3: mem: Comment enable_gpmc_cs_config more ARM: davici_emac: Fix condition for number of phy detects arm: printf() is not available in some SPL configurations arm, davinci: add support for am1808 based enbw_cmc board arm, davinci: move misc function in arch tree arm, board/davinci/common/misc.c: Codingstyle cleanup arm, davinci, da850: add uart1 tx rx pinmux config arm, davinci: move davinci_rtc struct to hardware.h arm, davinci: Remove duplication of pinmux configuration code arm, hawkboard: Use the pinmux configurations defined in the arch tree arm, da850evm: Use the pinmux configurations defined in the arch tree arm, da850: Add pinmux configurations to the arch tree arm, da850evm: Do pinmux configuration for EMAC together with other pinmuxes arm, hawkboard: Remove obsolete struct pinmux_config i2c_pins arm, davinci: Move pinmux functions from board to arch tree arm, arm926ejs: always do cpu critical inits omap_gpmc: use SOFTECC in SPL if it's enabled nand_spl_simple: add support for software ECC AM3517: move AM3517 specific mux defines to generic header AM35xx: add EMAC support davinci_emac: hardcode 100Mbps for AM35xx and RMII davinci_emac: fix for running with dcache enabled arm926ejs: add noop implementation for dcache ops davinci_emac: conditionally compile specific PHY support davinci_emac: use internal addresses in buffer descriptors davinci_emac: move arch-independent defines to separate header BeagleBoard: config: Really switch to ttyO2 ARM: davinci_dm6467Tevm: Fix build breakage ARM: OMAP: Remove STACKSIZE for IRQ and FIQ if unused ARM: OMAP3: Remove unused define SDRC_R_C_B ARM: OMAP3: Remove unused define CONFIG_OMAP3430 omap4: fix IO setting omap4+: streamline CONFIG_SYS_TEXT_BASE and other SDRAM addresses omap4460: add ES1.1 identification omap4: emif: fix error in driver omap: remove I2C from SPL omap4460: fix TPS initialization omap: fix cache line size for omap3/omap4 boards omap4: ttyO2 instead of ttyS2 in default bootargs omap: Improve PLL parameter calculation tool start.S: remove omap3 specific code from start.S armv7: setup vector armv7: include armv7/cpu.c in SPL build armv7: disable L2 cache in cleanup_before_linux() arm, arm926ejs: Fix clear bss loop for zero length bss PXA: Move colibri_pxa270 to board/toradex/ PXA: Flip colibri_pxa27x to pxa-common.h PXA: Introduce common configuration header for PXA PXA: Rename pxa_dram_init to pxa2xx_dram_init PXA: Squash extern pxa_dram_init() PXA: Export cpu_is_ and pxa_dram_init functions PXA: Cleanup Colibri PXA270 PXA: Replace timer driver PXA: Add cpuinfo display for PXA2xx PXA: Separate PXA2xx CPU init PXA: Rename CONFIG_PXA2[57]X to CONFIG_CPU_PXA2[57]X PXA: Unify vpac270 environment size PXA: Enable command line editing for vpac270 PXA: Adapt Voipac PXA270 to OneNAND SPL PXA: Drop Voipac PXA270 OneNAND IPL PXA: Fixup PXA25x boards after start.S update PXA: Re-add the Dcache locking as RAM for pxa250 PXA: Rework start.S to be closer to other ARMs PXA: Drop XM250 board PXA: Drop PLEB2 board PXA: Drop CRADLE board PXA: Drop CERF250 board Fix regression in SMDK6400 nand: Add common functions to linux/mtd/nand.h Ethernut 5 board support net: Armada100: Fix compilation warnings ARM: remove duplicated code for LaCie boards ARM: add support for LaCie 2Big Network v2 mvsata: fix ide_preinit for missing disks netspace_v2: Read Ethernet MAC address from EEPROM omap3evm: Add support for EFI partitions part_efi: Fix compile errors
Diffstat (limited to 'board/egnite/ethernut5/ethernut5.c')
-rw-r--r--board/egnite/ethernut5/ethernut5.c270
1 files changed, 270 insertions, 0 deletions
diff --git a/board/egnite/ethernut5/ethernut5.c b/board/egnite/ethernut5/ethernut5.c
new file mode 100644
index 0000000..e42e91e
--- /dev/null
+++ b/board/egnite/ethernut5/ethernut5.c
@@ -0,0 +1,270 @@
+/*
+ * (C) Copyright 2011
+ * egnite GmbH <info@egnite.de>
+ *
+ * (C) Copyright 2010
+ * Ole Reinhardt <ole.reinhardt@thermotemp.de>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program 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 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+/*
+ * Ethernut 5 general board support
+ *
+ * Ethernut is an open source hardware and software project for
+ * embedded Ethernet devices. Hardware layouts and CAD files are
+ * freely available under BSD-like license.
+ *
+ * Ethernut 5 is the first member of the Ethernut board family
+ * with U-Boot and Linux support. This implementation is based
+ * on the original work done by Ole Reinhardt, but heavily modified
+ * to support additional features and the latest board revision 5.0F.
+ *
+ * Main board components are by default:
+ *
+ * Atmel AT91SAM9XE512 CPU with 512 kBytes NOR Flash
+ * 2 x 64 MBytes Micron MT48LC32M16A2P SDRAM
+ * 512 MBytes Micron MT29F4G08ABADA NAND Flash
+ * 4 MBytes Atmel AT45DB321D DataFlash
+ * SMSC LAN8710 Ethernet PHY
+ * Atmel ATmega168 MCU used for power management
+ * Linear Technology LTC4411 PoE controller
+ *
+ * U-Boot relevant board interfaces are:
+ *
+ * 100 Mbit Ethernet with IEEE 802.3af PoE
+ * RS-232 serial port
+ * USB host and device
+ * MMC/SD-Card slot
+ * Expansion port with I2C, SPI and more...
+ *
+ * Typically the U-Boot image is loaded from serial DataFlash into
+ * SDRAM by the samboot boot loader, which is located in internal
+ * NOR Flash and provides all essential initializations like CPU
+ * and peripheral clocks and, of course, the SDRAM configuration.
+ *
+ * For testing purposes it is also possibly to directly transfer
+ * the image into SDRAM via JTAG. A tested configuration exists
+ * for the Turtelizer 2 hardware dongle and the OpenOCD software.
+ * In this case the latter will do the basic hardware configuration
+ * via its reset-init script.
+ *
+ * For additional information visit the project home page at
+ * http://www.ethernut.de/
+ */
+
+#include <common.h>
+#include <net.h>
+#include <netdev.h>
+#include <miiphy.h>
+#include <i2c.h>
+#include <spi.h>
+#include <dataflash.h>
+#include <mmc.h>
+
+#include <asm/arch/at91sam9260.h>
+#include <asm/arch/at91sam9260_matrix.h>
+#include <asm/arch/at91sam9_smc.h>
+#include <asm/arch/at91_common.h>
+#include <asm/arch/at91_pmc.h>
+#include <asm/arch/at91_spi.h>
+#include <asm/arch/gpio.h>
+#include <asm/io.h>
+
+#include "ethernut5_pwrman.h"
+
+DECLARE_GLOBAL_DATA_PTR;
+
+AT91S_DATAFLASH_INFO dataflash_info[CONFIG_SYS_MAX_DATAFLASH_BANKS];
+
+struct dataflash_addr cs[CONFIG_SYS_MAX_DATAFLASH_BANKS] = {
+ {CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS0, 0}
+};
+
+/*
+ * In fact we have 7 partitions, but u-boot supports 5 only. This is
+ * no big deal, because the first partition is reserved for applications
+ * and the last one is used by Nut/OS. Both need not to be visible here.
+ */
+dataflash_protect_t area_list[NB_DATAFLASH_AREA] = {
+ { 0x00021000, 0x00041FFF, FLAG_PROTECT_SET, 0, "setup" },
+ { 0x00042000, 0x000C5FFF, FLAG_PROTECT_SET, 0, "uboot" },
+ { 0x000C6000, 0x00359FFF, FLAG_PROTECT_SET, 0, "kernel" },
+ { 0x0035A000, 0x003DDFFF, FLAG_PROTECT_SET, 0, "nutos" },
+ { 0x003DE000, 0x003FEFFF, FLAG_PROTECT_CLEAR, 0, "env" }
+};
+
+/*
+ * This is called last during early initialization. Most of the basic
+ * hardware interfaces are up and running.
+ *
+ * The SDRAM hardware has been configured by the first stage boot loader.
+ * We only need to announce its size, using u-boot's memory check.
+ */
+int dram_init(void)
+{
+ gd->ram_size = get_ram_size(
+ (void *)CONFIG_SYS_SDRAM_BASE,
+ CONFIG_SYS_SDRAM_SIZE);
+ return 0;
+}
+
+#ifdef CONFIG_CMD_NAND
+static void ethernut5_nand_hw_init(void)
+{
+ struct at91_smc *smc = (struct at91_smc *)ATMEL_BASE_SMC;
+ struct at91_matrix *matrix = (struct at91_matrix *)ATMEL_BASE_MATRIX;
+ unsigned long csa;
+
+ /* Assign CS3 to NAND/SmartMedia Interface */
+ csa = readl(&matrix->ebicsa);
+ csa |= AT91_MATRIX_CS3A_SMC_SMARTMEDIA;
+ writel(csa, &matrix->ebicsa);
+
+ /* Configure SMC CS3 for NAND/SmartMedia */
+ writel(AT91_SMC_SETUP_NWE(1) | AT91_SMC_SETUP_NCS_WR(0) |
+ AT91_SMC_SETUP_NRD(1) | AT91_SMC_SETUP_NCS_RD(0),
+ &smc->cs[3].setup);
+ writel(AT91_SMC_PULSE_NWE(3) | AT91_SMC_PULSE_NCS_WR(3) |
+ AT91_SMC_PULSE_NRD(3) | AT91_SMC_PULSE_NCS_RD(3),
+ &smc->cs[3].pulse);
+ writel(AT91_SMC_CYCLE_NWE(5) | AT91_SMC_CYCLE_NRD(5),
+ &smc->cs[3].cycle);
+ writel(AT91_SMC_MODE_RM_NRD | AT91_SMC_MODE_WM_NWE |
+ AT91_SMC_MODE_EXNW_DISABLE |
+ AT91_SMC_MODE_DBW_8 |
+ AT91_SMC_MODE_TDF_CYCLE(2),
+ &smc->cs[3].mode);
+
+#ifdef CONFIG_SYS_NAND_READY_PIN
+ /* Ready pin is optional. */
+ at91_set_pio_input(CONFIG_SYS_NAND_READY_PIN, 1);
+#endif
+ at91_set_pio_output(CONFIG_SYS_NAND_ENABLE_PIN, 1);
+}
+#endif
+
+/*
+ * This is called first during late initialization.
+ */
+int board_init(void)
+{
+ struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
+
+ /* Enable clocks for all PIOs */
+ writel((1 << ATMEL_ID_PIOA) | (1 << ATMEL_ID_PIOB) |
+ (1 << ATMEL_ID_PIOC),
+ &pmc->pcer);
+ /* Set adress of boot parameters. */
+ gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
+ /* Initialize UARTs and power management. */
+ at91_seriald_hw_init();
+ ethernut5_power_init();
+#ifdef CONFIG_CMD_NAND
+ ethernut5_nand_hw_init();
+#endif
+#ifdef CONFIG_HAS_DATAFLASH
+ at91_spi0_hw_init(1 << 0);
+#endif
+ return 0;
+}
+
+#ifdef CONFIG_MACB
+/*
+ * This is optionally called last during late initialization.
+ */
+int board_eth_init(bd_t *bis)
+{
+ const char *devname;
+ unsigned short mode;
+ struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
+
+ /* Enable on-chip EMAC clock. */
+ writel(1 << ATMEL_ID_EMAC0, &pmc->pcer);
+ /* Need to reset PHY via power management. */
+ ethernut5_phy_reset();
+ /* Set peripheral pins. */
+ at91_macb_hw_init();
+ /* Basic EMAC initialization. */
+ if (macb_eth_initialize(0, (void *)ATMEL_BASE_EMAC0, CONFIG_PHY_ID))
+ return -1;
+ /*
+ * Early board revisions have a pull-down at the PHY's MODE0
+ * strap pin, which forces the PHY into power down. Here we
+ * switch to all-capable mode.
+ */
+ devname = miiphy_get_current_dev();
+ if (miiphy_read(devname, 0, 18, &mode) == 0) {
+ /* Set mode[2:0] to 0b111. */
+ mode |= 0x00E0;
+ miiphy_write(devname, 0, 18, mode);
+ /* Soft reset overrides strap pins. */
+ miiphy_write(devname, 0, MII_BMCR, BMCR_RESET);
+ }
+ /* Sync environment with network devices, needed for nfsroot. */
+ return eth_init(gd->bd);
+}
+#endif
+
+#ifdef CONFIG_GENERIC_ATMEL_MCI
+int board_mmc_init(bd_t *bd)
+{
+ struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
+
+ /* Enable MCI clock. */
+ writel(1 << ATMEL_ID_MCI, &pmc->pcer);
+ /* Initialize MCI hardware. */
+ at91_mci_hw_init();
+ /* Register the device. */
+ return atmel_mci_init((void *)ATMEL_BASE_MCI);
+}
+
+int board_mmc_getcd(u8 *cd, struct mmc *mmc)
+{
+ *cd = at91_get_pio_value(CONFIG_SYS_MMC_CD_PIN) ? 1 : 0;
+ return 0;
+}
+#endif
+
+#ifdef CONFIG_ATMEL_SPI
+/*
+ * Note, that u-boot uses different code for SPI bus access. While
+ * memory routines use automatic chip select control, the serial
+ * flash support requires 'manual' GPIO control. Thus, we switch
+ * modes.
+ */
+void spi_cs_activate(struct spi_slave *slave)
+{
+ /* Enable NPCS0 in GPIO mode. This disables peripheral control. */
+ at91_set_pio_output(AT91_PIO_PORTA, 3, 0);
+}
+
+void spi_cs_deactivate(struct spi_slave *slave)
+{
+ /* Disable NPCS0 in GPIO mode. */
+ at91_set_pio_output(AT91_PIO_PORTA, 3, 1);
+ /* Switch back to peripheral chip select control. */
+ at91_set_a_periph(AT91_PIO_PORTA, 3, 1);
+}
+
+int spi_cs_is_valid(unsigned int bus, unsigned int cs)
+{
+ return bus == 0 && cs == 0;
+}
+#endif