]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - board/emk/top9000/top9000.c
Merge branch 'master' of git://git.denx.de/u-boot-mips
[karo-tx-uboot.git] / board / emk / top9000 / top9000.c
index b0fe2d68a83358f37d957dfb0dd6280b1808e341..6e2ffddb0a434ad570538924263d69bf4c803947 100644 (file)
@@ -1,37 +1,23 @@
 /*
  * (C) Copyright 2007-2008
- * Stelian Pop <stelian.pop@leadtechdesign.com>
+ * Stelian Pop <stelian@popies.net>
  * Lead Tech Design <www.leadtechdesign.com>
  *
  * (C) Copyright 2010
  * Reinhard Meyer, EMK Elektronik, reinhard.meyer@emk-elektronik.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
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
 #include <net.h>
 #include <netdev.h>
 #include <mmc.h>
+#include <atmel_mci.h>
 #include <i2c.h>
 #include <spi.h>
-#include <asm/arch/at91sam9260.h>
+#include <asm/io.h>
+#include <asm/arch/hardware.h>
 #include <asm/arch/at91sam9260_matrix.h>
 #include <asm/arch/at91sam9_smc.h>
 #include <asm/arch/at91_common.h>
 #include <asm/arch/at91_rstc.h>
 #include <asm/arch/at91_shdwn.h>
 #include <asm/arch/gpio.h>
-#include <asm/arch/io.h>
-#include <asm/arch/hardware.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
 #ifdef CONFIG_CMD_NAND
 static void 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;
 
-       /* Enable CS3 */
-       csa = at91_sys_read(AT91_MATRIX_EBICSA);
-       at91_sys_write(AT91_MATRIX_EBICSA,
-               csa | AT91_MATRIX_CS3A_SMC_SMARTMEDIA);
+       /* 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 */
-       at91_sys_write(AT91_SMC_SETUP(3),
-               AT91_SMC_NWESETUP_(1) | AT91_SMC_NCS_WRSETUP_(0) |
-               AT91_SMC_NRDSETUP_(1) | AT91_SMC_NCS_RDSETUP_(0));
-       at91_sys_write(AT91_SMC_PULSE(3),
-               AT91_SMC_NWEPULSE_(3) | AT91_SMC_NCS_WRPULSE_(3) |
-               AT91_SMC_NRDPULSE_(3) | AT91_SMC_NCS_RDPULSE_(3));
-       at91_sys_write(AT91_SMC_CYCLE(3),
-               AT91_SMC_NWECYCLE_(5) | AT91_SMC_NRDCYCLE_(5));
-       at91_sys_write(AT91_SMC_MODE(3),
-               AT91_SMC_READMODE | AT91_SMC_WRITEMODE |
-               AT91_SMC_EXNWMODE_DISABLE |
-               AT91_SMC_DBW_8 |
-               AT91_SMC_TDF_(2));
+       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);
 
        /* Configure RDY/BSY */
        at91_set_gpio_input(CONFIG_SYS_NAND_READY_PIN, 1);
@@ -80,8 +66,10 @@ static void nand_hw_init(void)
 #ifdef CONFIG_MACB
 static void macb_hw_init(void)
 {
+       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
+
        /* Enable EMAC clock */
-       at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9260_ID_EMAC);
+       writel(1 << ATMEL_ID_EMAC0, &pmc->pcer);
 
        /* Initialize EMAC=MACB hardware */
        at91_macb_hw_init();
@@ -92,35 +80,30 @@ static void macb_hw_init(void)
 /* this is a weak define that we are overriding */
 int board_mmc_init(bd_t *bd)
 {
+       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
+
        /* Enable MCI clock */
-       at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9260_ID_MCI);
+       writel(1 << ATMEL_ID_MCI, &pmc->pcer);
 
        /* Initialize MCI hardware */
        at91_mci_hw_init();
 
        /* This calls the atmel_mmc_init in gen_atmel_mci.c */
-       return atmel_mci_init((void *)AT91_BASE_MCI);
+       return atmel_mci_init((void *)ATMEL_BASE_MCI);
 }
 
 /* this is a weak define that we are overriding */
-int board_mmc_getcd(u8 *cd, struct mmc *mmc)
+int board_mmc_getcd(struct mmc *mmc)
 {
-       /*
-        * the only currently existing use of this function
-        * (fsl_esdhc.c) suggests this function must return
-        * *cs = TRUE if a card is NOT detected -> in most
-        * cases the value of the pin when the detect switch
-        * closes to GND
-        */
-       *cd = at91_get_gpio_value(CONFIG_SYS_MMC_CD_PIN) ? 1 : 0;
-       return 0;
+       return !at91_get_gpio_value(CONFIG_SYS_MMC_CD_PIN);
 }
 
 #endif
 
 int board_early_init_f(void)
 {
-       at91_shdwn_t *shdwn = (at91_shdwn_t *)AT91_SHDWN_BASE;
+       struct at91_shdwn *shdwn = (struct at91_shdwn *)ATMEL_BASE_SHDWN;
+       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
 
        /*
         * make sure the board can be powered on by
@@ -130,9 +113,9 @@ int board_early_init_f(void)
                &shdwn->mr);
 
        /* Enable clocks for all PIOs */
-       at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9260_ID_PIOA);
-       at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9260_ID_PIOB);
-       at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9260_ID_PIOC);
+       writel((1 << ATMEL_ID_PIOA) | (1 << ATMEL_ID_PIOB) |
+               (1 << ATMEL_ID_PIOC),
+               &pmc->pcer);
 
        /* set SCL0 and SDA0 to open drain */
        at91_set_pio_output(I2C0_PORT, SCL0_PIN, 1);
@@ -159,7 +142,7 @@ int board_init(void)
        /* adress of boot parameters */
        gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
 
-       at91_serial_hw_init();
+       at91_seriald_hw_init();
 #ifdef CONFIG_CMD_NAND
        nand_hw_init();
 #endif
@@ -211,7 +194,7 @@ int board_eth_init(bd_t *bis)
        int num = 0;
 #ifdef CONFIG_MACB
        rc = macb_eth_initialize(0,
-               (void *)AT91_EMAC_BASE,
+               (void *)ATMEL_BASE_EMAC0,
                CONFIG_SYS_PHY_ID);
        if (!rc)
                num++;
@@ -246,7 +229,7 @@ int board_eth_init(bd_t *bis)
  * However i2c_get_bus_num() cannot be called before
  * relocation.
  */
-#ifdef CONFIG_SOFT_I2C
+#ifdef CONFIG_SYS_I2C_SOFT
 void iic_init(void)
 {
        /* ports are now initialized in board_early_init_f() */
@@ -254,7 +237,7 @@ void iic_init(void)
 
 int iic_read(void)
 {
-       switch ((gd->flags & GD_FLG_RELOC) ? i2c_get_bus_num() : 0) {
+       switch (I2C_ADAP_HWNR) {
        case 0:
                return at91_get_pio_value(I2C0_PORT, SDA0_PIN);
        case 1:
@@ -265,7 +248,7 @@ int iic_read(void)
 
 void iic_sda(int bit)
 {
-       switch ((gd->flags & GD_FLG_RELOC) ? i2c_get_bus_num() : 0) {
+       switch (I2C_ADAP_HWNR) {
        case 0:
                at91_set_pio_value(I2C0_PORT, SDA0_PIN, bit);
                break;
@@ -277,7 +260,7 @@ void iic_sda(int bit)
 
 void iic_scl(int bit)
 {
-       switch ((gd->flags & GD_FLG_RELOC) ? i2c_get_bus_num() : 0) {
+       switch (I2C_ADAP_HWNR) {
        case 0:
                at91_set_pio_value(I2C0_PORT, SCL0_PIN, bit);
                break;