void ft_pci_setup(void *blob, bd_t *bd) { int nodeoffset; int tmp[2]; const char *path; nodeoffset = fdt_path_offset(blob, "/aliases"); if (nodeoffset >= 0) { path = fdt_getprop(blob, nodeoffset, "pci0", NULL); if (path) { tmp[0] = cpu_to_be32(pci_hose[0].first_busno); tmp[1] = cpu_to_be32(pci_hose[0].last_busno); do_fixup_by_path(blob, path, "bus-range", &tmp, sizeof(tmp), 1); tmp[0] = cpu_to_be32(gd->pci_clk); do_fixup_by_path(blob, path, "clock-frequency", &tmp, sizeof(tmp[0]), 1); } #ifdef CONFIG_MPC83XX_PCI2 path = fdt_getprop(blob, nodeoffset, "pci1", NULL); if (path) { tmp[0] = cpu_to_be32(pci_hose[0].first_busno); tmp[1] = cpu_to_be32(pci_hose[0].last_busno); do_fixup_by_path(blob, path, "bus-range", &tmp, sizeof(tmp), 1); tmp[0] = cpu_to_be32(gd->pci_clk); do_fixup_by_path(blob, path, "clock-frequency", &tmp, sizeof(tmp[0]), 1); } #endif } }
void ft_pci_setup(void *blob, bd_t *bd) { int node, tmp[2]; const char *path; node = fdt_path_offset(blob, "/aliases"); tmp[0] = 0; if (node >= 0) { #ifdef CONFIG_PCI1 path = fdt_getprop(blob, node, "pci0", NULL); if (path) { tmp[1] = hose[0].last_busno - hose[0].first_busno; do_fixup_by_path(blob, path, "bus-range", &tmp, 8, 1); } #endif #ifdef CONFIG_MPC85XX_PCI2 path = fdt_getprop(blob, node, "pci1", NULL); if (path) { tmp[1] = hose[1].last_busno - hose[1].first_busno; do_fixup_by_path(blob, path, "bus-range", &tmp, 8, 1); } #endif } }
void fdt_fixup_ethernet(void *fdt) { int node, i, j; char enet[16], *tmp, *end; char mac[16] = "ethaddr"; const char *path; unsigned char mac_addr[6]; node = fdt_path_offset(fdt, "/aliases"); if (node < 0) return; i = 0; while ((tmp = getenv(mac)) != NULL) { sprintf(enet, "ethernet%d", i); path = fdt_getprop(fdt, node, enet, NULL); if (!path) { debug("No alias for %s\n", enet); sprintf(mac, "eth%daddr", ++i); continue; } for (j = 0; j < 6; j++) { mac_addr[j] = tmp ? simple_strtoul(tmp, &end, 16) : 0; if (tmp) tmp = (*end) ? end+1 : end; } do_fixup_by_path(fdt, path, "mac-address", &mac_addr, 6, 0); do_fixup_by_path(fdt, path, "local-mac-address", &mac_addr, 6, 1); sprintf(mac, "eth%daddr", ++i); } }
void ft_board_setup(void *blob, bd_t *bd) { int node, tmp[2]; const char *path; ft_cpu_setup(blob, bd); node = fdt_path_offset(blob, "/aliases"); tmp[0] = 0; if (node >= 0) { #ifdef CONFIG_PCI1 path = fdt_getprop(blob, node, "pci0", NULL); if (path) { tmp[1] = pci1_hose.last_busno - pci1_hose.first_busno; do_fixup_by_path(blob, path, "bus-range", &tmp, 8, 1); } #endif #ifdef CONFIG_PCIE1 path = fdt_getprop(blob, node, "pci1", NULL); if (path) { tmp[1] = pcie1_hose.last_busno - pcie1_hose.first_busno; do_fixup_by_path(blob, path, "bus-range", &tmp, 8, 1); } #endif } }
void fdt_fixup_ethernet(void *fdt) { int i, j, prop; char *tmp, *end; char mac[16]; const char *path; unsigned char mac_addr[ARP_HLEN]; int offset; if (fdt_path_offset(fdt, "/aliases") < 0) return; /* Cycle through all aliases */ for (prop = 0; ; prop++) { const char *name; /* FDT might have been edited, recompute the offset */ offset = fdt_first_property_offset(fdt, fdt_path_offset(fdt, "/aliases")); /* Select property number 'prop' */ for (i = 0; i < prop; i++) offset = fdt_next_property_offset(fdt, offset); if (offset < 0) break; path = fdt_getprop_by_offset(fdt, offset, &name, NULL); if (!strncmp(name, "ethernet", 8)) { /* Treat plain "ethernet" same as "ethernet0". */ if (!strcmp(name, "ethernet")) i = 0; else i = trailing_strtol(name); if (i != -1) { if (i == 0) strcpy(mac, "ethaddr"); else sprintf(mac, "eth%daddr", i); } else { continue; } tmp = env_get(mac); if (!tmp) continue; for (j = 0; j < 6; j++) { mac_addr[j] = tmp ? simple_strtoul(tmp, &end, 16) : 0; if (tmp) tmp = (*end) ? end + 1 : end; } do_fixup_by_path(fdt, path, "mac-address", &mac_addr, 6, 0); do_fixup_by_path(fdt, path, "local-mac-address", &mac_addr, 6, 1); } } }
int esdhc_status_fixup(void *blob, const char *compat) { char esdhc0_path[] = "/soc/esdhc@1560000"; char esdhc1_path[] = "/soc/esdhc@1580000"; u8 card_id; do_fixup_by_path(blob, esdhc0_path, "status", "okay", sizeof("okay"), 1); /* * The Presence Detect 2 register detects the installation * of cards in various PCI Express or SGMII slots. * * STAT_PRS2[7:5]: Specifies the type of card installed in the * SDHC2 Adapter slot. 0b111 indicates no adapter is installed. */ card_id = (QIXIS_READ(present2) & 0xe0) >> 5; /* If no adapter is installed in SDHC2, disable SDHC2 */ if (card_id == 0x7) do_fixup_by_path(blob, esdhc1_path, "status", "disabled", sizeof("disabled"), 1); else do_fixup_by_path(blob, esdhc1_path, "status", "okay", sizeof("okay"), 1); return 0; }
/* * Given an alias or a path for a node, set the mux value of that node. * * If 'alias' is not a valid alias, then it is treated as a full path to the * node. No error checking is performed. * * This function is normally called to set the fsl,hydra-mdio-muxval property * of a virtual MDIO node. */ static void fdt_set_mdio_mux(void *fdt, const char *alias, u32 mux) { const char *path = fdt_get_alias(fdt, alias); if (!path) path = alias; do_fixup_by_path(fdt, path, "reg", &mux, sizeof(mux), 1); do_fixup_by_path(fdt, path, "fsl,hydra-mdio-muxval", &mux, sizeof(mux), 1); }
int esdhc_status_fixup(void *blob, const char *compat) { char esdhc0_path[] = "/soc/esdhc@1560000"; char esdhc1_path[] = "/soc/esdhc@1580000"; do_fixup_by_path(blob, esdhc0_path, "status", "okay", sizeof("okay"), 1); do_fixup_by_path(blob, esdhc1_path, "status", "disabled", sizeof("disabled"), 1); return 0; }
int esdhc_status_fixup(void *blob, const char *compat) { char esdhc1_path[] = "/soc/esdhc@1580000"; bool sdhc2_en = false; u8 mux_sdhc2; u8 io = 0; i2c_set_bus_num(0); /* IO1[7:3] is the field of board revision info. */ if (i2c_read(I2C_MUX_IO_ADDR, I2C_MUX_IO_1, 1, &io, 1) < 0) { printf("Error reading i2c boot information!\n"); return 0; } /* hwconfig method is used for RevD and later versions. */ if ((io & SW_REV_MASK) <= SW_REV_D) { #ifdef CONFIG_HWCONFIG if (hwconfig("esdhc1")) sdhc2_en = true; #endif } else { /* * The I2C IO-expander for mux select is used to control * the muxing of various onboard interfaces. * * IO0[3:2] indicates SDHC2 interface demultiplexer * select lines. * 00 - SDIO wifi * 01 - GPIO (to Arduino) * 10 - eMMC Memory * 11 - SPI */ if (i2c_read(I2C_MUX_IO_ADDR, I2C_MUX_IO_0, 1, &io, 1) < 0) { printf("Error reading i2c boot information!\n"); return 0; } mux_sdhc2 = (io & 0x0c) >> 2; /* Enable SDHC2 only when use SDIO wifi and eMMC */ if (mux_sdhc2 == 2 || mux_sdhc2 == 0) sdhc2_en = true; } if (sdhc2_en) do_fixup_by_path(blob, esdhc1_path, "status", "okay", sizeof("okay"), 1); else do_fixup_by_path(blob, esdhc1_path, "status", "disabled", sizeof("disabled"), 1); return 0; }
static int pfe_set_properties(void *set_blob, struct pfe_prop_val prop_val, char *enet_path, char *mdio_path) { do_fixup_by_path(set_blob, enet_path, "fsl,gemac-bus-id", &prop_val.busid, PFE_PROP_LEN, 1); do_fixup_by_path(set_blob, enet_path, "fsl,gemac-phy-id", &prop_val.phyid, PFE_PROP_LEN, 1); do_fixup_by_path(set_blob, enet_path, "fsl,mdio-mux-val", &prop_val.mux_val, PFE_PROP_LEN, 1); do_fixup_by_path(set_blob, enet_path, "phy-mode", prop_val.phy_mode, strlen(prop_val.phy_mode) + 1, 1); do_fixup_by_path(set_blob, mdio_path, "fsl,mdio-phy-mask", &prop_val.phy_mask, PFE_PROP_LEN, 1); return 0; }
void ft_fixup_enet_phy_connect_type(void *fdt) { struct eth_device *dev; struct tsec_private *priv; const char *enet_path, *phy_path; char enet[16]; char phy[16]; int phy_node; int i = 0; uint32_t ph; char *name[3] = { "eTSEC1", "eTSEC2", "eTSEC3" }; for (; i < ARRAY_SIZE(name); i++) { dev = eth_get_dev_by_name(name[i]); if (dev) { sprintf(enet, "ethernet%d", i); sprintf(phy, "enet%d_rgmii_phy", i); } else { continue; } priv = dev->priv; if (priv->flags & TSEC_SGMII) continue; enet_path = fdt_get_alias(fdt, enet); if (!enet_path) continue; phy_path = fdt_get_alias(fdt, phy); if (!phy_path) continue; phy_node = fdt_path_offset(fdt, phy_path); if (phy_node < 0) continue; ph = fdt_create_phandle(fdt, phy_node); if (ph) do_fixup_by_path_u32(fdt, enet_path, "phy-handle", ph, 1); do_fixup_by_path(fdt, enet_path, "phy-connection-type", phy_string_for_interface( PHY_INTERFACE_MODE_RGMII_ID), sizeof(phy_string_for_interface( PHY_INTERFACE_MODE_RGMII_ID)), 1); } }
void fdt_fixup_ethernet(void *fdt, bd_t *bd) { int node; const char *path; node = fdt_path_offset(fdt, "/aliases"); if (node >= 0) { #if defined(CONFIG_HAS_ETH0) path = fdt_getprop(fdt, node, "ethernet0", NULL); if (path) { do_fixup_by_path(fdt, path, "mac-address", bd->bi_enetaddr, 6, 0); do_fixup_by_path(fdt, path, "local-mac-address", bd->bi_enetaddr, 6, 1); } #endif #if defined(CONFIG_HAS_ETH1) path = fdt_getprop(fdt, node, "ethernet1", NULL); if (path) { do_fixup_by_path(fdt, path, "mac-address", bd->bi_enet1addr, 6, 0); do_fixup_by_path(fdt, path, "local-mac-address", bd->bi_enet1addr, 6, 1); } #endif #if defined(CONFIG_HAS_ETH2) path = fdt_getprop(fdt, node, "ethernet2", NULL); if (path) { do_fixup_by_path(fdt, path, "mac-address", bd->bi_enet2addr, 6, 0); do_fixup_by_path(fdt, path, "local-mac-address", bd->bi_enet2addr, 6, 1); } #endif #if defined(CONFIG_HAS_ETH3) path = fdt_getprop(fdt, node, "ethernet3", NULL); if (path) { do_fixup_by_path(fdt, path, "mac-address", bd->bi_enet3addr, 6, 0); do_fixup_by_path(fdt, path, "local-mac-address", bd->bi_enet3addr, 6, 1); } #endif } }
void do_fixup_by_path_u32(void *fdt, const char *path, const char *prop, u32 val, int create) { val = cpu_to_fdt32(val); do_fixup_by_path(fdt, path, prop, &val, sizeof(val), create); }
void do_fixup_by_path_u32(void *fdt, const char *path, const char *prop, u32 val, int create) { fdt32_t tmp = cpu_to_fdt32(val); do_fixup_by_path(fdt, path, prop, &tmp, sizeof(tmp), create); }
void fdt_fixup_ethernet(void *fdt) { int i = 0, j, prop; char *tmp, *end; char mac[16]; const char *path; unsigned char mac_addr[ARP_HLEN]; int offset; #ifdef FDT_SEQ_MACADDR_FROM_ENV int nodeoff; const struct fdt_property *fdt_prop; #endif if (fdt_path_offset(fdt, "/aliases") < 0) return; /* Cycle through all aliases */ for (prop = 0; ; prop++) { const char *name; /* FDT might have been edited, recompute the offset */ offset = fdt_first_property_offset(fdt, fdt_path_offset(fdt, "/aliases")); /* Select property number 'prop' */ for (j = 0; j < prop; j++) offset = fdt_next_property_offset(fdt, offset); if (offset < 0) break; path = fdt_getprop_by_offset(fdt, offset, &name, NULL); if (!strncmp(name, "ethernet", 8)) { /* Treat plain "ethernet" same as "ethernet0". */ if (!strcmp(name, "ethernet") #ifdef FDT_SEQ_MACADDR_FROM_ENV || !strcmp(name, "ethernet0") #endif ) i = 0; #ifndef FDT_SEQ_MACADDR_FROM_ENV else i = trailing_strtol(name); #endif if (i != -1) { if (i == 0) strcpy(mac, "ethaddr"); else sprintf(mac, "eth%daddr", i); } else { continue; } #ifdef FDT_SEQ_MACADDR_FROM_ENV nodeoff = fdt_path_offset(fdt, path); fdt_prop = fdt_get_property(fdt, nodeoff, "status", NULL); if (fdt_prop && !strcmp(fdt_prop->data, "disabled")) continue; i++; #endif tmp = env_get(mac); if (!tmp) continue; for (j = 0; j < 6; j++) { mac_addr[j] = tmp ? simple_strtoul(tmp, &end, 16) : 0; if (tmp) tmp = (*end) ? end + 1 : end; } do_fixup_by_path(fdt, path, "mac-address", &mac_addr, 6, 0); do_fixup_by_path(fdt, path, "local-mac-address", &mac_addr, 6, 1); } } }