[U-Boot] [PATCH v2] OMAP3: add CM-T35 board
Mike Rapoport
mike.rapoport at gmail.com
Wed Nov 11 23:21:27 CET 2009
On Wed, Nov 11, 2009 at 10:03 PM, Ben Warren <biggerbadderben at gmail.com> wrote:
> Mike Rapoport wrote:
>> Add CM-T35 board support
>>
>> --
>> v2 changes:
>> - rename board config file from omap3_cm-t35.h to cm-t35.h
>> - remove SZ_xx references
>> - add MAKEALL/MAINTEINERS entries
>> --
>>
>>
> <snip>
>> --- /dev/null
>> +++ b/board/cm-t35/cm-t35.c
>> @@ -0,0 +1,196 @@
>> +/*
>> + * (C) Copyright 2009
>> + * CompuLab, Ltd. <www.compulab.co.il>
>> + *
>> + * Authors :
>> + * Igor Vaisbein <igor at compulab.co.il>
>> + * Mike Rapoport <mike at compulab.co.il>
>> + *
>> + * Derived from omap3evm and Beagle Board by
>> + * Manikandan Pillai <mani.pillai at ti.com>
>> + * Richard Woodruff <r-woodruff2 at ti.com>
>> + * Syed Mohammed Khasim <x0khasim at ti.com>
>> + *
>> + * 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
>> + */
>> +
>> +#include <common.h>
>> +#include <netdev.h>
>> +#include <net.h>
>> +#include <i2c.h>
>> +#include <twl4030.h>
>> +
>> +#include <asm/io.h>
>> +#include <asm/arch/mem.h>
>> +#include <asm/arch/mux.h>
>> +#include <asm/arch/sys_proto.h>
>> +#include <asm/mach-types.h>
>> +
>> +#include "cm-t35.h"
>> +
>> +#define CM_T35_SMC911X_BASE 0x2C000000
>> +#define SB_T35_SMC911X_BASE (CM_T35_SMC911X_BASE + (16 << 20))
>>
> Please follow convention and put this stuff in include/configs/board.h
>> +
>> +static u32 gpmc_net_config[GPMC_MAX_REG] = {
>> + NET_GPMC_CONFIG1,
>> + NET_GPMC_CONFIG2,
>> + NET_GPMC_CONFIG3,
>> + NET_GPMC_CONFIG4,
>> + NET_GPMC_CONFIG5,
>> + NET_GPMC_CONFIG6,
>> + 0
>> +};
>> +
>> +DECLARE_GLOBAL_DATA_PTR;
>> +
>> +/*
>> + * Routine: setup_net_chip
>> + * Description: Setting up the configuration GPMC registers specific to the
>> + * Ethernet hardware.
>> + */
>> +static void setup_net_chip(void)
>> +{
>> + struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
>> +
>> + enable_gpmc_cs_config(gpmc_net_config, &gpmc_cfg->cs[5],
>> + CM_T35_SMC911X_BASE, GPMC_SIZE_16M);
>> + enable_gpmc_cs_config(gpmc_net_config, &gpmc_cfg->cs[4],
>> + SB_T35_SMC911X_BASE, GPMC_SIZE_16M);
>> +
>> + /* Enable off mode for NWE in PADCONF_GPMC_NWE register */
>> + writew(readw(&ctrl_base->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe);
>> +
>> + /* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */
>> + writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe);
>> +
>> + /* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */
>> + writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00,
>> + &ctrl_base->gpmc_nadv_ale);
>> +
>> + /* Reset the ethernet controller via TPS65930 GPIO */
>> + /* Set GPIO1 of TPS65930 as output */
>> + twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, 0x02,
>> + TWL4030_BASEADD_GPIO+0x03);
>> + /* Send a pulse on the GPIO pin */
>> + twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, 0x02,
>> + TWL4030_BASEADD_GPIO+0x0C);
>> + udelay(1);
>> + twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, 0x02,
>> + TWL4030_BASEADD_GPIO+0x09);
>> + udelay(1);
>> + twl4030_i2c_write_u8(TWL4030_CHIP_GPIO, 0x02,
>> + TWL4030_BASEADD_GPIO+0x0C);
>> +
>> +}
>> +
>> +/*
>> + * Routine: board_init
>> + * Description: Early hardware init.
>> + */
>> +int board_init(void)
>> +{
>> + gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
>> +
>> + /* board id for Linux */
>> + gd->bd->bi_arch_number = MACH_TYPE_CM_T35;
>> + /* boot param addr */
>> + gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
>> +
>> + return 0;
>> +}
>> +
>> +/*
>> + * Routine: misc_init_r
>> + * Description: Init ethernet (done here so udelay works)
>> + */
>> +int misc_init_r(void)
>> +{
>> +
>> +#ifdef CONFIG_DRIVER_OMAP34XX_I2C
>> + i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
>> +#endif
>> +
>> +#if defined(CONFIG_CMD_NET)
>> + setup_net_chip();
>> +#endif
>> +
>> + dieid_num_r();
>> +
>> + return 0;
>> +}
>> +
>> +/*
>> + * Routine: set_muxconf_regs
>> + * Description: Setting up the configuration Mux registers specific to the
>> + * hardware. Many pins need to be moved from protect to primary
>> + * mode.
>> + */
>> +void set_muxconf_regs(void)
>> +{
>> + MUX_CM_T35();
>> +}
>> +
>> +/*
>> + * Routine: handle_mac_address
>> + * Description: prepare MAC address for on-board Ethernet.
>> + */
>> +static int handle_mac_address(void)
>> +{
>> + unsigned char enetaddr[6];
>> + int rc;
>> +
>> + rc = eth_getenv_enetaddr("ethaddr", enetaddr);
>> + if (rc)
>> + return 0;
>> +
>> + rc = i2c_read(0x50, 0, 1, enetaddr, 6);
>> + if (rc)
>> + return rc;
>> +
>> + if (!is_valid_ether_addr(enetaddr))
>> + return -1;
>> +
>> + return eth_setenv_enetaddr("ethaddr", enetaddr);
>> +}
>>
> the value in environment must be able to override the value in NV-RAM.
> This seems to do the opposite. If you're implementing NV-RAM in a
> different way that is common for the driver in question, I'd prefer to
> see you implement some kind of callback mechanism in the driver. This
> will ensure proper flow.
The driver assumes that there's an SROM attached to the chip.
Unfortunately, CM-T35 does not have the SROM and stores the MAC
address in the U-Boot environment and a backup copy in a system
EEPROM. The handle_mac_address function here checks is "ethaddr" is
set and only otherwise reads the MAC address from the system EEPROM.
Which is to my understanding complies with docs/README.enetaddr.
>> +
>> +/*
>> + * Routine: board_eth_init
>> + * Description: initialize module and base-board Ethernet chips
>> + */
>> +int board_eth_init(bd_t *bis)
>> +{
>> + int err1 = 0, err2 = 0;
>> +
>> +#ifdef CONFIG_SMC911X
>> + err1 = handle_mac_address();
>> + err2 = smc911x_initialize(0, CM_T35_SMC911X_BASE);
>> +
>> + if (err1 && !err2)
>> + printf("CM-T35: No MAC address found\n");
>> +
>> + err1 = smc911x_initialize(1, SB_T35_SMC911X_BASE);
>> +
>> + /* run eth_init to set up MAC address prior to OS boot */
>> + if (!err1 || !err2)
>> + err1 = eth_init(bis);
>>
> We don't touch hardware that isn't used by U-boot. You'll find all
> sorts of threads in the archive about this.
I've already did :)
I'm not about to re-open the old discussions, so I'll remove the
eth_init() call althought I'm not completely agree that this is the
right thing to do.
>> + else
>> + err1 = -1;
>> +#endif
>> + return err1;
>>
> As I believe others have mentioned, return the number of interfaces
> initialized (will be 0 or 1).
Will fix.
> <snip>
>> +/* BOOTP fields */
>> +#define CONFIG_BOOTP_SUBNETMASK 0x00000001
>> +#define CONFIG_BOOTP_GATEWAY 0x00000002
>> +#define CONFIG_BOOTP_HOSTNAME 0x00000004
>> +#define CONFIG_BOOTP_BOOTPATH 0x00000010
>> +
>>
> Please don't set any default network parameters.
Will fix.
> regards,
> Ben
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
>
--
Sincerely Yours,
Mike.
More information about the U-Boot
mailing list