Exemple #1
0
/*
 * Initializes on-board ethernet controllers.
 */
int board_eth_init(bd_t *bis)
{
#ifdef CONFIG_DRIVER_TI_EMAC
	davinci_emac_mii_mode_sel(0);
#endif /* CONFIG_DRIVER_TI_EMAC */

	if (!davinci_emac_initialize()) {
		printf("Error: Ethernet init failed!\n");
		return -1;
	}

	if (hwconfig_subarg_cmp("switch", "lan", "on"))
		/* Switch port lan on */
		enbw_cmc_switch(1, 1);
	else
		enbw_cmc_switch(1, 0);

	if (hwconfig_subarg_cmp("switch", "pwl", "on"))
		/* Switch port pwl on */
		enbw_cmc_switch(2, 1);
	else
		enbw_cmc_switch(2, 0);

	return 0;
}
/*
 * Initializes on-board ethernet controllers.
 */
int board_eth_init(bd_t *bis)
{
	struct spi_slave *spi;
	const char *s;
	size_t len = 0;
	int config = 1;

	davinci_emac_mii_mode_sel(0);

	/* send a config file to the switch */
	s = hwconfig_subarg("switch", "config", &len);
	if (len) {
		unsigned long addr = simple_strtoul(s, NULL, 16);

		config = enbw_cmc_config_switch(addr);
	}

	if (config) {
		/*
		 * no valid config file -> do we have some args in
		 * hwconfig ?
		 */
		if ((hwconfig_subarg("switch", "lan", &len)) ||
		    (hwconfig_subarg("switch", "lmn", &len))) {
			/* If so start switch */
			spi = enbw_cmc_init_spi();
			if (spi) {
				if (enbw_cmc_switch_write(spi, 1, 0))
					config = 0;
				udelay(10000);
				if (enbw_cmc_switch_write(spi, 1, 1))
					config = 0;
				spi_release_bus(spi);
				spi_free_slave(spi);
			}
		} else {
			config = 0;
		}
	}
	if (!davinci_emac_initialize()) {
		printf("Error: Ethernet init failed!\n");
		return -1;
	}

	if (config) {
		if (hwconfig_subarg_cmp("switch", "lan", "on"))
			/* Switch port lan on */
			enbw_cmc_switch(1, 1);
		else
			enbw_cmc_switch(1, 0);

		if (hwconfig_subarg_cmp("switch", "lmn", "on"))
			/* Switch port pwl on */
			enbw_cmc_switch(2, 1);
		else
			enbw_cmc_switch(2, 0);
	}

	return 0;
}