All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Herbrechtsmeier <stefan@herbrechtsmeier.net>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 3/5] omap3: overo: Move ethernet setup to board_eth_init function
Date: Tue, 16 Sep 2014 17:51:07 +0200	[thread overview]
Message-ID: <1410882669-705-4-git-send-email-stefan@herbrechtsmeier.net> (raw)
In-Reply-To: <1410882669-705-1-git-send-email-stefan@herbrechtsmeier.net>

Move ethernet setup to the board_eth_init function and select
the available network devices via expansion id.

Signed-off-by: Stefan Herbrechtsmeier <stefan@herbrechtsmeier.net>
---

 board/overo/overo.c | 76 +++++++++++++++++++++++++++++++++--------------------
 1 file changed, 47 insertions(+), 29 deletions(-)

diff --git a/board/overo/overo.c b/board/overo/overo.c
index 13220c5..caffb50 100644
--- a/board/overo/overo.c
+++ b/board/overo/overo.c
@@ -58,21 +58,6 @@ static struct {
 	char env_setting[64];
 } expansion_config;
 
-#if defined(CONFIG_CMD_NET)
-static void setup_net_chip(void);
-#endif
-
-/* GPMC definitions for LAN9221 chips on Tobi expansion boards */
-static const u32 gpmc_lan_config[] = {
-    NET_LAN9221_GPMC_CONFIG1,
-    NET_LAN9221_GPMC_CONFIG2,
-    NET_LAN9221_GPMC_CONFIG3,
-    NET_LAN9221_GPMC_CONFIG4,
-    NET_LAN9221_GPMC_CONFIG5,
-    NET_LAN9221_GPMC_CONFIG6,
-    /*CONFIG7- computed as params */
-};
-
 /*
  * Routine: board_init
  * Description: Early hardware init.
@@ -241,10 +226,6 @@ int misc_init_r(void)
 	twl4030_power_init();
 	twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
 
-#if defined(CONFIG_CMD_NET)
-	setup_net_chip();
-#endif
-
 	printf("Board revision: %d\n", get_board_revision());
 
 	switch (get_sdio2_config()) {
@@ -280,9 +261,6 @@ int misc_init_r(void)
 		printf("Recognized Tobi Duo expansion board (rev %d %s)\n",
 			expansion_config.revision,
 			expansion_config.fab_revision);
-		/* second lan chip */
-		enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[4],
-		    0x2B000000, GPMC_SIZE_16M);
 		break;
 	case GUMSTIX_PALO35:
 		printf("Recognized Palo35 expansion board (rev %d %s)\n",
@@ -388,7 +366,18 @@ void set_muxconf_regs(void)
 	MUX_OVERO();
 }
 
-#if defined(CONFIG_CMD_NET)
+#if defined(CONFIG_CMD_NET) && !defined(CONFIG_SPL_BUILD)
+/* GPMC definitions for LAN9221 chips on Tobi expansion boards */
+static const u32 gpmc_lan_config[] = {
+	NET_LAN9221_GPMC_CONFIG1,
+	NET_LAN9221_GPMC_CONFIG2,
+	NET_LAN9221_GPMC_CONFIG3,
+	NET_LAN9221_GPMC_CONFIG4,
+	NET_LAN9221_GPMC_CONFIG5,
+	NET_LAN9221_GPMC_CONFIG6,
+	/*CONFIG7- computed as params */
+};
+
 /*
  * Routine: setup_net_chip
  * Description: Setting up the configuration GPMC registers specific to the
@@ -398,10 +387,6 @@ static void setup_net_chip(void)
 {
 	struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
 
-	/* first lan chip */
-	enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[5], 0x2C000000,
-			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 */
@@ -409,7 +394,14 @@ static void setup_net_chip(void)
 	/* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */
 	writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00,
 		&ctrl_base->gpmc_nadv_ale);
+}
 
+/*
+ * Routine: reset_net_chip
+ * Description: Reset the Ethernet hardware.
+ */
+static void reset_net_chip(void)
+{
 	/* Make GPIO 64 as output pin and send a magic pulse through it */
 	if (!gpio_request(64, "")) {
 		gpio_direction_output(64, 0);
@@ -420,16 +412,42 @@ static void setup_net_chip(void)
 		gpio_set_value(64, 1);
 	}
 }
-#endif
 
 int board_eth_init(bd_t *bis)
 {
+	unsigned int expansion_id;
 	int rc = 0;
+
 #ifdef CONFIG_SMC911X
-	rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
+	expansion_id = get_expansion_id();
+	switch (expansion_id) {
+	case GUMSTIX_TOBI_DUO:
+		/* second lan chip */
+		enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[4],
+				      0x2B000000, GPMC_SIZE_16M);
+		/* no break */
+	case GUMSTIX_TOBI:
+	case GUMSTIX_CHESTNUT43:
+	case GUMSTIX_STAGECOACH:
+	case GUMSTIX_NO_EEPROM:
+	case GUMSTIX_EMPTY_EEPROM:
+		/* first lan chip */
+		enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[5],
+				      0x2C000000, GPMC_SIZE_16M);
+
+		setup_net_chip();
+		reset_net_chip();
+
+		rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
+		break;
+	default:
+		break;
+	}
 #endif
+
 	return rc;
 }
+#endif
 
 #if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD)
 int board_mmc_init(bd_t *bis)
-- 
2.1.0

  parent reply	other threads:[~2014-09-16 15:51 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-16 15:51 [U-Boot] [PATCH 0/5] omap3: overo: Add foreign expansion board support Stefan Herbrechtsmeier
2014-09-16 15:51 ` [U-Boot] [PATCH 1/5] omap3: overo: Fix fdtfile test Stefan Herbrechtsmeier
2014-10-10 14:39   ` [U-Boot] [U-Boot,1/5] " Tom Rini
2014-09-16 15:51 ` [U-Boot] [PATCH 2/5] omap3: overo: Call bootm only after successful nand read Stefan Herbrechtsmeier
2014-10-23 17:16   ` [U-Boot] [U-Boot, " Tom Rini
2014-09-16 15:51 ` Stefan Herbrechtsmeier [this message]
2014-10-23 17:16   ` [U-Boot] [U-Boot, 3/5] omap3: overo: Move ethernet setup to board_eth_init function Tom Rini
2014-09-16 15:51 ` [U-Boot] [PATCH 4/5] omap3: overo: Separate module and expansion board MUX configuration Stefan Herbrechtsmeier
2014-10-23 17:16   ` [U-Boot] [U-Boot, " Tom Rini
2014-09-16 15:51 ` [U-Boot] [PATCH 5/5] omap3: overo: Add usb host support Stefan Herbrechtsmeier
2014-10-23 17:16   ` [U-Boot] [U-Boot,5/5] " Tom Rini
2014-09-30  5:10 ` [U-Boot] [PATCH 0/5] omap3: overo: Add foreign expansion board support Stefan Herbrechtsmeier
2014-10-10 16:12 ` Tom Rini
2014-10-10 16:13   ` Ash Charles

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=1410882669-705-4-git-send-email-stefan@herbrechtsmeier.net \
    --to=stefan@herbrechtsmeier.net \
    --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.