static int sdhci_get_config(const void *blob, int node, struct sdhci_host *host) { int bus_width, dev_id; unsigned int base; /* Get device id */ dev_id = pinmux_decode_periph_id(blob, node); if (dev_id < PERIPH_ID_SDMMC0 && dev_id > PERIPH_ID_SDMMC3) { debug("MMC: Can't get device id\n"); return -1; } host->index = dev_id - PERIPH_ID_SDMMC0; /* Get bus width */ bus_width = fdtdec_get_int(blob, node, "samsung,bus-width", 0); if (bus_width <= 0) { debug("MMC: Can't get bus-width\n"); return -1; } host->bus_width = bus_width; /* Get the base address from the device node */ base = fdtdec_get_addr(blob, node, "reg"); if (!base) { debug("MMC: Can't get base address\n"); return -1; } host->ioaddr = (void *)base; fdtdec_decode_gpio(blob, node, "pwr-gpios", &host->pwr_gpio); fdtdec_decode_gpio(blob, node, "cd-gpios", &host->cd_gpio); return 0; }
static int s3c_i2c_ofdata_to_platdata(struct udevice *dev) { const void *blob = gd->fdt_blob; struct s3c24x0_i2c_bus *i2c_bus = dev_get_priv(dev); int node; node = dev_of_offset(dev); i2c_bus->regs = (struct s3c24x0_i2c *)dev_get_addr(dev); i2c_bus->id = pinmux_decode_periph_id(blob, node); i2c_bus->clock_frequency = fdtdec_get_int(blob, node, "clock-frequency", 100000); i2c_bus->node = node; i2c_bus->bus_num = dev->seq; exynos_pinmux_config(i2c_bus->id, 0); i2c_bus->active = true; return 0; }
int exynos_dwmmc_init(const void *blob) { int index, bus_width; int node_list[DWMMC_MAX_CH_NUM]; int err = 0, dev_id, flag, count, i; u32 clksel_val, base, timing[3]; count = fdtdec_find_aliases_for_id(blob, "mmc", COMPAT_SAMSUNG_EXYNOS5_DWMMC, node_list, DWMMC_MAX_CH_NUM); for (i = 0; i < count; i++) { int node = node_list[i]; if (node <= 0) continue; /* Extract device id for each mmc channel */ dev_id = pinmux_decode_periph_id(blob, node); /* Get the bus width from the device node */ bus_width = fdtdec_get_int(blob, node, "samsung,bus-width", 0); if (bus_width <= 0) { debug("DWMMC: Can't get bus-width\n"); return -1; } if (8 == bus_width) flag = PINMUX_FLAG_8BIT_MODE; else flag = PINMUX_FLAG_NONE; /* config pinmux for each mmc channel */ err = exynos_pinmux_config(dev_id, flag); if (err) { debug("DWMMC not configured\n"); return err; } index = dev_id - PERIPH_ID_SDMMC0; /* Get the base address from the device node */ base = fdtdec_get_addr(blob, node, "reg"); if (!base) { debug("DWMMC: Can't get base address\n"); return -1; } /* Extract the timing info from the node */ err = fdtdec_get_int_array(blob, node, "samsung,timing", timing, 3); if (err) { debug("Can't get sdr-timings for divider\n"); return -1; } clksel_val = (DWMCI_SET_SAMPLE_CLK(timing[0]) | DWMCI_SET_DRV_CLK(timing[1]) | DWMCI_SET_DIV_RATIO(timing[2])); /* Initialise each mmc channel */ err = exynos_dwmci_add_port(index, base, bus_width, clksel_val); if (err) debug("dwmmc Channel-%d init failed\n", index); } return 0; }