Ejemplo n.º 1
0
static int mxs_mci_probe(struct device_d *hw_dev)
{
	struct mxs_mci_platform_data *pd = hw_dev->platform_data;
	struct mxs_mci_host *mxs_mci;
	struct mci_host *host;
	unsigned long rate;

	if (hw_dev->platform_data == NULL) {
		dev_err(hw_dev, "Missing platform data\n");
		return -EINVAL;
	}

	mxs_mci = xzalloc(sizeof(*mxs_mci));
	host = &mxs_mci->host;

	hw_dev->priv = mxs_mci;
	host->hw_dev = hw_dev;
	host->send_cmd = mxs_mci_request;
	host->set_ios = mxs_mci_set_ios;
	host->init = mxs_mci_initialize;
	mxs_mci->regs = dev_request_mem_region(hw_dev, 0);

	/* feed forward the platform specific values */
	host->voltages = pd->voltages;
	host->host_caps = pd->caps;
	host->devname = pd->devname;

	mxs_mci->clk = clk_get(hw_dev, NULL);
	if (IS_ERR(mxs_mci->clk))
		return PTR_ERR(mxs_mci->clk);

	clk_enable(mxs_mci->clk);

	rate = clk_get_rate(mxs_mci->clk);

	if (pd->f_min == 0) {
		host->f_min = rate / 254 / 256;
		dev_dbg(hw_dev, "Min. frequency is %u Hz\n", host->f_min);
	} else {
		host->f_min = pd->f_min;
		dev_dbg(hw_dev, "Min. frequency is %u Hz, could be %lu Hz\n",
			host->f_min, rate / 254 / 256);
	}
	if (pd->f_max == 0) {
		host->f_max = rate / 2 / 1;
		dev_dbg(hw_dev, "Max. frequency is %u Hz\n", host->f_max);
	} else {
		host->f_max =  pd->f_max;
		dev_dbg(hw_dev, "Max. frequency is %u Hz, could be %lu Hz\n",
			host->f_max, rate / 2 / 1);
	}

	if (IS_ENABLED(CONFIG_MCI_INFO)) {
		mxs_mci->f_min = host->f_min;
		mxs_mci->f_max = host->f_max;
		hw_dev->info = mxs_mci_info;
	}

	return mci_register(host);
}
Ejemplo n.º 2
0
static int spi_mci_probe(struct device_d *dev)
{
	struct spi_device	*spi = (struct spi_device *)dev->type_data;
	struct mmc_spi_host	*host;
	void			*ones;

	host = xzalloc(sizeof(*host));
	host->mci.send_cmd = mmc_spi_request;
	host->mci.set_ios = mmc_spi_set_ios;
	host->mci.init = mmc_spi_init;
	host->mci.hw_dev = dev;

	host->dev = dev;
	host->spi = spi;
	dev->priv = host;

	ones = xmalloc(MMC_SPI_BLOCKSIZE);
	memset(ones, 0xff, MMC_SPI_BLOCKSIZE);

	host->ones = ones;

	spi_message_init(&host->m_tx);
	spi_message_init(&host->m_rx);

	spi_message_add_tail(&host->t_tx, &host->m_tx);
	spi_message_add_tail(&host->t_rx, &host->m_rx);

	host->t_rx.tx_buf = host->ones;
	host->t_rx.cs_change = 1;

	host->t_tx.cs_change = 1;

	host->mci.voltages = MMC_VDD_32_33 | MMC_VDD_33_34;
	host->mci.host_caps = MMC_CAP_SPI;

	mci_register(&host->mci);

	return 0;
}
Ejemplo n.º 3
0
static int mxs_mci_probe(struct device_d *hw_dev)
{
    struct mxs_mci_platform_data *pd = hw_dev->platform_data;
    struct mxs_mci_host *mxs_mci;
    struct mci_host *host;

    if (hw_dev->platform_data == NULL) {
        pr_err("Missing platform data\n");
        return -EINVAL;
    }

    mxs_mci = xzalloc(sizeof(*mxs_mci));
    host = &mxs_mci->host;

    hw_dev->priv = mxs_mci;
    host->hw_dev = hw_dev;
    host->send_cmd = mxs_mci_request;
    host->set_ios = mxs_mci_set_ios;
    host->init = mxs_mci_initialize;
    mxs_mci->regs = dev_request_mem_region(hw_dev, 0);

    /* feed forward the platform specific values */
    host->voltages = pd->voltages;
    host->host_caps = pd->caps;

#ifdef CONFIG_ARCH_IMX23
    mxs_mci->index = 0;	/* there is only one clock for all */
#endif
#ifdef CONFIG_ARCH_IMX28
    /* one dedicated clock per unit */
    switch (hw_dev->resource[0].start) {
    case IMX_SSP0_BASE:
        mxs_mci->index = 0;
        break;
    case IMX_SSP1_BASE:
        mxs_mci->index = 1;
        break;
    case IMX_SSP2_BASE:
        mxs_mci->index = 2;
        break;
    case IMX_SSP3_BASE:
        mxs_mci->index = 3;
        break;
    default:
        pr_debug("Unknown SSP unit at address 0x%08x\n", mxs_mci->regs);
        return 0;
    }
#endif
    if (pd->f_min == 0) {
        host->f_min = mxs_mci_get_unit_clock(mxs_mci) / 254 / 256;
        pr_debug("Min. frequency is %u Hz\n", host->f_min);
    } else {
        host->f_min = pd->f_min;
        pr_debug("Min. frequency is %u Hz, could be %u Hz\n",
                 host->f_min, mxs_mci_get_unit_clock(mxs_mci) / 254 / 256);
    }
    if (pd->f_max == 0) {
        host->f_max = mxs_mci_get_unit_clock(mxs_mci) / 2 / 1;
        pr_debug("Max. frequency is %u Hz\n", host->f_max);
    } else {
        host->f_max =  pd->f_max;
        pr_debug("Max. frequency is %u Hz, could be %u Hz\n",
                 host->f_max, mxs_mci_get_unit_clock(mxs_mci) / 2 / 1);
    }

#ifdef CONFIG_MCI_INFO
    mxs_mci->f_min = host->f_min;
    mxs_mci->f_max = host->f_max;
#endif

    return mci_register(host);
}
Ejemplo n.º 4
0
static int dw_mmc_probe(struct device_d *dev)
{
	struct resource *iores;
	struct dwmci_host *host;
	struct dw_mmc_platform_data *pdata = dev->platform_data;

	host = xzalloc(sizeof(*host));

	host->clk_biu = clk_get(dev, "biu");
	if (IS_ERR(host->clk_biu))
		return PTR_ERR(host->clk_biu);

	host->clk_ciu = clk_get(dev, "ciu");
	if (IS_ERR(host->clk_ciu))
		return PTR_ERR(host->clk_ciu);

	clk_enable(host->clk_biu);
	clk_enable(host->clk_ciu);

	host->dev = dev;
	iores = dev_request_mem_resource(dev, 0);
	if (IS_ERR(iores))
		return PTR_ERR(iores);
	host->ioaddr = IOMEM(iores->start);

	host->idmac = dma_alloc_coherent(sizeof(*host->idmac) * DW_MMC_NUM_IDMACS,
					 DMA_ADDRESS_BROKEN);

	host->mci.send_cmd = dwmci_cmd;
	host->mci.set_ios = dwmci_set_ios;
	host->mci.init = dwmci_init;
	host->mci.card_present = dwmci_card_present;
	host->mci.hw_dev = dev;
	host->mci.voltages = MMC_VDD_32_33 | MMC_VDD_33_34;
	host->mci.host_caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA;
	host->mci.host_caps |= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED_52MHZ |
			       MMC_CAP_SD_HIGHSPEED;

	if (pdata) {
		host->ciu_div = pdata->ciu_div;
		host->mci.host_caps &= ~MMC_CAP_BIT_DATA_MASK;
		host->mci.host_caps |= pdata->bus_width_caps;
	} else if (dev->device_node) {
		const char *alias = of_alias_get(dev->device_node);
		if (alias)
			host->mci.devname = xstrdup(alias);
		of_property_read_u32(dev->device_node, "dw-mshc-ciu-div",
				&host->ciu_div);
	}

	/* divider is 0 based in pdata and 1 based in our private struct */
	host->ciu_div++;

	if (of_device_is_compatible(dev->device_node,
	    "rockchip,rk2928-dw-mshc"))
		host->pwren_value = 0;
	else
		host->pwren_value = 1;

	dev->detect = dw_mmc_detect;

	host->clkrate = clk_get_rate(host->clk_ciu);
	host->mci.f_min = host->clkrate / 510 / host->ciu_div;
	if (host->mci.f_min < 200000)
		host->mci.f_min = 200000;
	host->mci.f_max = host->clkrate / host->ciu_div;

	mci_of_parse(&host->mci);

	dev->priv = host;

	return mci_register(&host->mci);
}
Ejemplo n.º 5
0
static int dw_mmc_probe(struct device_d *dev)
{
	struct dwmci_host *host;
	struct mci_host *mci;
	struct dw_mmc_platform_data *pdata = dev->platform_data;

	host = xzalloc(sizeof(*host));
	mci = &host->mci;

	host->clk_biu = clk_get(dev, "biu");
	if (IS_ERR(host->clk_biu))
		return PTR_ERR(host->clk_biu);

	host->clk_ciu = clk_get(dev, "ciu");
	if (IS_ERR(host->clk_ciu))
		return PTR_ERR(host->clk_ciu);

	clk_enable(host->clk_biu);
	clk_enable(host->clk_ciu);

	host->dev = dev;
	host->ioaddr = dev_request_mem_region(dev, 0);
	if (!host->ioaddr)
		return -EBUSY;

	if (pdata) {
		mci->devname = pdata->devname;
		host->ciu_div = pdata->ciu_div;
	} else if (dev->device_node) {
		const char *alias = of_alias_get(dev->device_node);
		if (alias)
			mci->devname = xstrdup(alias);
		of_property_read_u32(dev->device_node, "dw-mshc-ciu-div",
				&host->ciu_div);
	}

	/* divider is 0 based in pdata and 1 based in our private struct */
	host->ciu_div++;

	host->idmac = dma_alloc_coherent(sizeof(*host->idmac) * DW_MMC_NUM_IDMACS);

	host->mci.send_cmd = dwmci_cmd;
	host->mci.set_ios = dwmci_set_ios;
	host->mci.init = dwmci_init;
	host->mci.card_present = dwmci_card_present;
	host->mci.hw_dev = dev;
	host->mci.voltages = MMC_VDD_32_33 | MMC_VDD_33_34;
	host->mci.host_caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA;

	dev->detect = dw_mmc_detect;

	host->clkrate = clk_get_rate(host->clk_ciu);
	host->mci.f_min = host->clkrate / 510 / host->ciu_div;
	if (host->mci.f_min < 200000)
		host->mci.f_min = 200000;
	host->mci.f_max = host->clkrate / host->ciu_div;

	mci_of_parse(&host->mci);

	dev->priv = host;

	return mci_register(&host->mci);
}