static int board_eth_init(void) { void __iomem *gur = IOMEM(MPC85xx_GUTS_ADDR); struct ge_product_data product; int st; /* Toggle eth0 reset pin */ gpio_set_value(4, 0); udelay(5); gpio_set_value(4, 1); /* Disable eTSEC3 */ out_be32(gur + MPC85xx_DEVDISR_OFFSET, in_be32(gur + MPC85xx_DEVDISR_OFFSET) & ~MPC85xx_DEVDISR_TSEC3); st = ge_get_product_data(&product); if (((product.v2.mac.count > 0) && (product.v2.mac.count <= MAX_MAC)) && (st == 0)) eth_register_ethaddr(0, (const char *)&product.v2.mac.mac[0]); fsl_eth_init(1, &gfar_info[0]); return 0; }
void tx28_get_ethaddr(void) { u32 buf[2]; /* to make use of cpu_to_be32 */ u32 ethaddr[2]; int ret; ret = mxs_ocotp_read(buf, 8, 0); if (ret != 8) return; ethaddr[0] = cpu_to_be32(buf[0]); ethaddr[1] = cpu_to_be32(buf[1]); eth_register_ethaddr(0, (char *)ethaddr); }
void rpi_set_usbethaddr(void) { BCM2835_MBOX_STACK_ALIGN(struct msg_get_mac_address, msg); int ret; BCM2835_MBOX_INIT_HDR(msg); BCM2835_MBOX_INIT_TAG(&msg->get_mac_address, GET_MAC_ADDRESS); ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr); if (ret) { printf("bcm2835: Could not query MAC address\n"); /* Ignore error; not critical */ return; } eth_register_ethaddr(0, msg->get_mac_address.body.resp.mac); }
/* fec */ static void mx28_evk_get_ethaddr(void) { u8 mac_ocotp[3], mac[6]; int ret; ret = mxs_ocotp_read(mac_ocotp, 3, 0); if (ret != 3) { pr_err("Reading MAC from OCOTP failed!\n"); return; } mac[0] = 0x00; mac[1] = 0x04; mac[2] = 0x9f; mac[3] = mac_ocotp[2]; mac[4] = mac_ocotp[1]; mac[5] = mac_ocotp[0]; eth_register_ethaddr(0, mac); }
int am33xx_register_ethaddr(int eth_id, int mac_id) { void __iomem *mac_id_low = (void *)AM33XX_MAC_ID0_LO + mac_id * 8; void __iomem *mac_id_high = (void *)AM33XX_MAC_ID0_HI + mac_id * 8; uint8_t mac_addr[6]; uint32_t mac_hi, mac_lo; mac_lo = readl(mac_id_low); mac_hi = readl(mac_id_high); mac_addr[0] = mac_hi & 0xff; mac_addr[1] = (mac_hi & 0xff00) >> 8; mac_addr[2] = (mac_hi & 0xff0000) >> 16; mac_addr[3] = (mac_hi & 0xff000000) >> 24; mac_addr[4] = mac_lo & 0xff; mac_addr[5] = (mac_lo & 0xff00) >> 8; if (is_valid_ether_addr(mac_addr)) { eth_register_ethaddr(eth_id, mac_addr); return 0; } return -ENODEV; }