コード例 #1
0
ファイル: rtc.c プロジェクト: 7LK/McWRT
static void platform_detect(void)
{
	char buf[20];
	int et0phyaddr, et1phyaddr;

	/* Based on "model_no".  */
	if (nvram_getenv("model_no", buf, sizeof(buf)) >= 0) {
		if (startswith(buf, "WL700")) { /* WL700* */
			sda_index = 2;
			scl_index = 5;
			return;
		}
	}

	if (nvram_getenv("et0phyaddr", buf, sizeof(buf)) >= 0 )
		et0phyaddr = simple_strtoul(buf, NULL, 0);
	if (nvram_getenv("et1phyaddr", buf, sizeof(buf)) >= 0 )
		et1phyaddr = simple_strtoul(buf, NULL, 0);

	if (nvram_getenv("hardware_version", buf, sizeof(buf)) >= 0) {
		/* Either WL-300g or WL-HDD, do more extensive checks */
		if (startswith(buf, "WL300-") && et0phyaddr == 0 && et1phyaddr == 1) {
			sda_index = 4;
			scl_index = 5;
			return;
		}
	}
	/* not found */
}
コード例 #2
0
static void __init bcm47xx_register_ssb(void)
{
	int err;
	char buf[100];
	struct ssb_mipscore *mcore;

	err = ssb_arch_register_fallback_sprom(&bcm47xx_get_sprom_ssb);
	if (err)
		printk(KERN_WARNING "bcm47xx: someone else already registered"
			" a ssb SPROM callback handler (err %d)\n", err);

	err = ssb_bus_ssbbus_register(&(bcm47xx_bus.ssb), SSB_ENUM_BASE,
				      bcm47xx_get_invariants);
	if (err)
		panic("Failed to initialize SSB bus (err %d)", err);

	mcore = &bcm47xx_bus.ssb.mipscore;
	if (nvram_getenv("kernel_args", buf, sizeof(buf)) >= 0) {
		if (strstr(buf, "console=ttyS1")) {
			struct ssb_serial_port port;

			printk(KERN_DEBUG "Swapping serial ports!\n");
			/*                   */
			memcpy(&port, &mcore->serial_ports[0], sizeof(port));
			memcpy(&mcore->serial_ports[0], &mcore->serial_ports[1],
			       sizeof(port));
			memcpy(&mcore->serial_ports[1], &port, sizeof(port));
		}
	}
}
コード例 #3
0
static int bcm47xx_get_invariants(struct ssb_bus *bus,
				   struct ssb_init_invariants *iv)
{
	char buf[100];

	/* Fill boardinfo structure */
	memset(&(iv->boardinfo), 0 , sizeof(struct ssb_boardinfo));

	if (cfe_getenv("boardvendor", buf, sizeof(buf)) >= 0 ||
	    nvram_getenv("boardvendor", buf, sizeof(buf)) >= 0)
		iv->boardinfo.type = (u16)simple_strtoul(buf, NULL, 0);
	if (cfe_getenv("boardtype", buf, sizeof(buf)) >= 0 ||
	    nvram_getenv("boardtype", buf, sizeof(buf)) >= 0)
		iv->boardinfo.type = (u16)simple_strtoul(buf, NULL, 0);
	if (cfe_getenv("boardrev", buf, sizeof(buf)) >= 0 ||
	    nvram_getenv("boardrev", buf, sizeof(buf)) >= 0)
		iv->boardinfo.rev = (u16)simple_strtoul(buf, NULL, 0);

	/* Fill sprom structure */
	memset(&(iv->sprom), 0, sizeof(struct ssb_sprom));
	iv->sprom.revision = 3;

	if (cfe_getenv("et0macaddr", buf, sizeof(buf)) >= 0 ||
	    nvram_getenv("et0macaddr", buf, sizeof(buf)) >= 0)
		str2eaddr(buf, iv->sprom.et0mac);

	if (cfe_getenv("et1macaddr", buf, sizeof(buf)) >= 0 ||
	    nvram_getenv("et1macaddr", buf, sizeof(buf)) >= 0)
		str2eaddr(buf, iv->sprom.et1mac);

	if (cfe_getenv("et0phyaddr", buf, sizeof(buf)) >= 0 ||
	    nvram_getenv("et0phyaddr", buf, sizeof(buf)) >= 0)
		iv->sprom.et0phyaddr = simple_strtoul(buf, NULL, 0);

	if (cfe_getenv("et1phyaddr", buf, sizeof(buf)) >= 0 ||
	    nvram_getenv("et1phyaddr", buf, sizeof(buf)) >= 0)
		iv->sprom.et1phyaddr = simple_strtoul(buf, NULL, 0);

	if (cfe_getenv("et0mdcport", buf, sizeof(buf)) >= 0 ||
	    nvram_getenv("et0mdcport", buf, sizeof(buf)) >= 0)
		iv->sprom.et0mdcport = simple_strtoul(buf, NULL, 10);

	if (cfe_getenv("et1mdcport", buf, sizeof(buf)) >= 0 ||
	    nvram_getenv("et1mdcport", buf, sizeof(buf)) >= 0)
		iv->sprom.et1mdcport = simple_strtoul(buf, NULL, 10);

	return 0;
}
コード例 #4
0
static int bcm47xx_get_invariants(struct ssb_bus *bus,
				  struct ssb_init_invariants *iv)
{
	char buf[20];

	/*                          */
	memset(&(iv->boardinfo), 0 , sizeof(struct ssb_boardinfo));

	if (nvram_getenv("boardvendor", buf, sizeof(buf)) >= 0)
		iv->boardinfo.vendor = (u16)simple_strtoul(buf, NULL, 0);
	else
		iv->boardinfo.vendor = SSB_BOARDVENDOR_BCM;
	if (nvram_getenv("boardtype", buf, sizeof(buf)) >= 0)
		iv->boardinfo.type = (u16)simple_strtoul(buf, NULL, 0);
	if (nvram_getenv("boardrev", buf, sizeof(buf)) >= 0)
		iv->boardinfo.rev = (u16)simple_strtoul(buf, NULL, 0);

	bcm47xx_fill_sprom(&iv->sprom, NULL);

	if (nvram_getenv("cardbus", buf, sizeof(buf)) >= 0)
		iv->has_cardbus_slot = !!simple_strtoul(buf, NULL, 10);

	return 0;
}
コード例 #5
0
ファイル: switch-robo.c プロジェクト: ETegro/OpenSAN
static int robo_switch_enable(void)
{
	unsigned int i, last_port;
	u16 val;
#ifdef CONFIG_BCM47XX
	char buf[20];
#endif

	val = robo_read16(ROBO_CTRL_PAGE, ROBO_SWITCH_MODE);
	if (!(val & (1 << 1))) {
		/* Unmanaged mode */
		val &= ~(1 << 0);
		/* With forwarding */
		val |= (1 << 1);
		robo_write16(ROBO_CTRL_PAGE, ROBO_SWITCH_MODE, val);
		val = robo_read16(ROBO_CTRL_PAGE, ROBO_SWITCH_MODE);
		if (!(val & (1 << 1))) {
			printk("Failed to enable switch\n");
			return -EBUSY;
		}

		last_port = (robo.devid == ROBO_DEVICE_ID_5398) ?
				ROBO_PORT6_CTRL : ROBO_PORT3_CTRL;
		for (i = ROBO_PORT0_CTRL; i < last_port + 1; i++)
			robo_write16(ROBO_CTRL_PAGE, i, 0);
	}

#ifdef CONFIG_BCM47XX
	/* WAN port LED, except for Netgear WGT634U */
	if (nvram_getenv("nvram_type", buf, sizeof(buf)) >= 0) {
		if (strcmp(buf, "cfe") != 0)
			robo_write16(ROBO_CTRL_PAGE, 0x16, 0x1F);
	}
#endif
	return 0;
}