All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Warren <biggerbadderben@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2] OMAP3: add CM-T35 board
Date: Wed, 11 Nov 2009 12:03:57 -0800	[thread overview]
Message-ID: <4AFB18AD.5010004@gmail.com> (raw)
In-Reply-To: <1257955131-16729-1-git-send-email-mike@compulab.co.il>

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@compulab.co.il>
> + *	Mike Rapoport <mike@compulab.co.il>
> + *
> + * Derived from omap3evm and Beagle Board by
> + *	Manikandan Pillai <mani.pillai@ti.com>
> + *	Richard Woodruff <r-woodruff2@ti.com>
> + *	Syed Mohammed Khasim <x0khasim@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.
> +
> +/*
> + * 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.
> +	else
> +		err1 = -1;
> +#endif
> +	return err1;
>   
As I believe others have mentioned, return the number of interfaces 
initialized (will be 0 or 1).

<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.

regards,
Ben

  parent reply	other threads:[~2009-11-11 20:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-11 15:58 [U-Boot] [PATCH v2] OMAP3: add CM-T35 board Mike Rapoport
2009-11-11 18:37 ` Dirk Behme
2009-11-11 21:25   ` Mike Rapoport
2009-11-11 20:03 ` Ben Warren [this message]
2009-11-11 22:21   ` Mike Rapoport
2009-11-11 21:56 ` Wolfgang Denk
2009-11-12 12:30   ` Mike Rapoport
  -- strict thread matches above, loose matches on Subject: below --
2010-12-08  6:33 Mike Rapoport
2010-12-08  8:56 ` Wolfgang Denk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4AFB18AD.5010004@gmail.com \
    --to=biggerbadderben@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.