void sdhci_get_of_property(struct platform_device *pdev)
{
	struct device_node *np = pdev->dev.of_node;
	struct sdhci_host *host = platform_get_drvdata(pdev);
	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
	const __be32 *clk;
	int size;

	if (of_device_is_available(np)) {
		if (of_get_property(np, "sdhci,auto-cmd12", NULL))
			host->quirks |= SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12;

		if (of_get_property(np, "sdhci,1-bit-only", NULL))
			host->quirks |= SDHCI_QUIRK_FORCE_1_BIT_DATA;

		if (sdhci_of_wp_inverted(np))
			host->quirks |= SDHCI_QUIRK_INVERTED_WRITE_PROTECT;

		if (of_device_is_compatible(np, "fsl,p2020-rev1-esdhc"))
			host->quirks |= SDHCI_QUIRK_BROKEN_DMA;

		if (of_device_is_compatible(np, "fsl,p2020-esdhc") ||
		    of_device_is_compatible(np, "fsl,p1010-esdhc") ||
		    of_device_is_compatible(np, "fsl,mpc8536-esdhc"))
			host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;

		clk = of_get_property(np, "clock-frequency", &size);
		if (clk && size == sizeof(*clk) && *clk)
			pltfm_host->clock = be32_to_cpup(clk);
	}
}
Beispiel #2
0
void sdhci_get_of_property(struct platform_device *pdev)
{
	struct device_node *np = pdev->dev.of_node;
	struct sdhci_host *host = platform_get_drvdata(pdev);
	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
	const __be32 *clk;
	u32 bus_width;
	int size;

	if (of_device_is_available(np)) {
		if (of_get_property(np, "sdhci,auto-cmd12", NULL))
			host->quirks |= SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12;

		if (of_get_property(np, "sdhci,1-bit-only", NULL) ||
		    (of_property_read_u32(np, "bus-width", &bus_width) == 0 &&
		    bus_width == 1))
			host->quirks |= SDHCI_QUIRK_FORCE_1_BIT_DATA;

		if (sdhci_of_wp_inverted(np))
			host->quirks |= SDHCI_QUIRK_INVERTED_WRITE_PROTECT;

		if (of_get_property(np, "broken-cd", NULL))
			host->quirks |= SDHCI_QUIRK_BROKEN_CARD_DETECTION;

		if (of_get_property(np, "no-1-8-v", NULL))
			host->quirks2 |= SDHCI_QUIRK2_NO_1_8_V;

		if (of_device_is_compatible(np, "fsl,p2020-rev1-esdhc"))
			host->quirks |= SDHCI_QUIRK_BROKEN_DMA;

		if (of_device_is_compatible(np, "fsl,p2020-esdhc") ||
		    of_device_is_compatible(np, "fsl,p1010-esdhc") ||
		    of_device_is_compatible(np, "fsl,t4240-esdhc") ||
		    of_device_is_compatible(np, "fsl,mpc8536-esdhc"))
			host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;

		clk = of_get_property(np, "clock-frequency", &size);
		if (clk && size == sizeof(*clk) && *clk)
			pltfm_host->clock = be32_to_cpup(clk);

		if (of_find_property(np, "keep-power-in-suspend", NULL))
			host->mmc->pm_caps |= MMC_PM_KEEP_POWER;

		if (of_find_property(np, "enable-sdio-wakeup", NULL))
			host->mmc->pm_caps |= MMC_PM_WAKE_SDIO_IRQ;
	}
}
static int __devinit sdhci_of_probe(struct of_device *ofdev,
				 const struct of_device_id *match)
{
	struct device_node *np = ofdev->dev.of_node;
	struct sdhci_of_data *sdhci_of_data = match->data;
	struct sdhci_host *host;
	struct sdhci_of_host *of_host;
	const u32 *clk;
	int size;
	int ret;

	if (!of_device_is_available(np))
		return -ENODEV;

	host = sdhci_alloc_host(&ofdev->dev, sizeof(*of_host));
	if (IS_ERR(host))
		return -ENOMEM;

	of_host = sdhci_priv(host);
	dev_set_drvdata(&ofdev->dev, host);

	host->ioaddr = of_iomap(np, 0);
	if (!host->ioaddr) {
		ret = -ENOMEM;
		goto err_addr_map;
	}

	host->irq = irq_of_parse_and_map(np, 0);
	if (!host->irq) {
		ret = -EINVAL;
		goto err_no_irq;
	}

	host->hw_name = dev_name(&ofdev->dev);
	if (sdhci_of_data) {
		host->quirks = sdhci_of_data->quirks;
		host->ops = &sdhci_of_data->ops;
	}

	if (of_get_property(np, "sdhci,1-bit-only", NULL))
		host->quirks |= SDHCI_QUIRK_FORCE_1_BIT_DATA;

	if (sdhci_of_wp_inverted(np))
		host->quirks |= SDHCI_QUIRK_INVERTED_WRITE_PROTECT;

	if (of_get_property(np, "fsl,sdhci-dma-broken", NULL))
		host->quirks |= SDHCI_QUIRK_BROKEN_DMA;

	if (of_get_property(np, "fsl,sdhci-ahb2mag-irq-bypass", NULL))
		host->quirks |= SDHCI_QUIRK_SET_AHB2MAG_IRQ_BYPASS;

	if (of_get_property(np, "fsl,sdhci-adjust-timeout", NULL))
		host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;

	clk = of_get_property(np, "clock-frequency", &size);
	if (clk && size == sizeof(*clk) && *clk)
		of_host->clock = *clk;

	ret = sdhci_add_host(host);
	if (ret)
		goto err_add_host;

	return 0;

err_add_host:
	irq_dispose_mapping(host->irq);
err_no_irq:
	iounmap(host->ioaddr);
err_addr_map:
	sdhci_free_host(host);
	return ret;
}
Beispiel #4
0
static int __devinit sdhci_of_probe(struct platform_device *ofdev)
{
	const struct of_device_id *match;
	struct device_node *np = ofdev->dev.of_node;
	struct sdhci_of_data *sdhci_of_data;
	struct sdhci_host *host;
	struct sdhci_of_host *of_host;
	const __be32 *clk;
	int size;
	int ret;

	match = of_match_device(sdhci_of_match, &ofdev->dev);
	if (!match)
		return -EINVAL;
	sdhci_of_data = match->data;

	if (!of_device_is_available(np))
		return -ENODEV;

	host = sdhci_alloc_host(&ofdev->dev, sizeof(*of_host));
	if (IS_ERR(host))
		return -ENOMEM;

	of_host = sdhci_priv(host);
	dev_set_drvdata(&ofdev->dev, host);

	host->ioaddr = of_iomap(np, 0);
	if (!host->ioaddr) {
		ret = -ENOMEM;
		goto err_addr_map;
	}

	host->irq = irq_of_parse_and_map(np, 0);
	if (!host->irq) {
		ret = -EINVAL;
		goto err_no_irq;
	}

	host->hw_name = dev_name(&ofdev->dev);
	if (sdhci_of_data) {
		host->quirks = sdhci_of_data->quirks;
		host->ops = &sdhci_of_data->ops;
	}

	if (of_get_property(np, "sdhci,auto-cmd12", NULL))
		host->quirks |= SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12;


	if (of_get_property(np, "sdhci,1-bit-only", NULL))
		host->quirks |= SDHCI_QUIRK_FORCE_1_BIT_DATA;

	if (sdhci_of_wp_inverted(np))
		host->quirks |= SDHCI_QUIRK_INVERTED_WRITE_PROTECT;

	clk = of_get_property(np, "clock-frequency", &size);
	if (clk && size == sizeof(*clk) && *clk)
		of_host->clock = be32_to_cpup(clk);

	ret = sdhci_add_host(host);
	if (ret)
		goto err_add_host;

	return 0;

err_add_host:
	irq_dispose_mapping(host->irq);
err_no_irq:
	iounmap(host->ioaddr);
err_addr_map:
	sdhci_free_host(host);
	return ret;
}
void sdhci_get_of_property(struct platform_device *pdev)
{
	struct device_node *np = pdev->dev.of_node;
	struct sdhci_host *host = platform_get_drvdata(pdev);
	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
	const __be32 *clk;
	u32 bus_width = 0;
	int size;
	int runmode_normal;
	int batterystate_exist;

	if (of_device_is_available(np)) {
		if (of_get_property(np, "sdhci,auto-cmd12", NULL))
			host->quirks |= SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12;

		if (of_get_property(np, "sdhci,1-bit-only", NULL) ||
		    (of_property_read_u32(np, "bus-width", &bus_width) == 0 &&
		    bus_width == 1))
			host->quirks |= SDHCI_QUIRK_FORCE_1_BIT_DATA;

		if (bus_width == 4)
			host->mmc->caps |= MMC_CAP_4_BIT_DATA;
		else if (bus_width == 8)
			host->mmc->caps |= MMC_CAP_8_BIT_DATA | MMC_CAP_4_BIT_DATA;

		if (sdhci_of_wp_inverted(np))
			host->quirks |= SDHCI_QUIRK_INVERTED_WRITE_PROTECT;

		if (of_get_property(np, "broken-cd", NULL))
			host->quirks |= SDHCI_QUIRK_BROKEN_CARD_DETECTION;

		if (of_find_property(np, "non-removable", NULL))
			host->mmc->caps |= MMC_CAP_NONREMOVABLE;

		if (of_get_property(np, "no-1-8-v", NULL))
			host->quirks2 |= SDHCI_QUIRK2_NO_1_8_V;

		if (of_device_is_compatible(np, "fsl,p2020-rev1-esdhc"))
			host->quirks |= SDHCI_QUIRK_BROKEN_DMA;

		if (of_find_property(np, "use-pio", NULL))
		{
			host->quirks |= SDHCI_QUIRK_BROKEN_DMA;
			host->quirks |= SDHCI_QUIRK_BROKEN_ADMA;
		}

		if (of_find_property(np, "use-dma", NULL))
			host->quirks |= SDHCI_QUIRK_BROKEN_ADMA;

		if (!of_find_property(np, "sdhci-adma-64bit", NULL))
			host->quirks2 |= SDHCI_QUIRK2_BROKEN_64_BIT_DMA;

		if (of_device_is_compatible(np, "fsl,p2020-esdhc") ||
		    of_device_is_compatible(np, "fsl,p1010-esdhc") ||
		    of_device_is_compatible(np, "fsl,t4240-esdhc") ||
		    of_device_is_compatible(np, "fsl,mpc8536-esdhc"))
			host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;

		clk = of_get_property(np, "clock-frequency", &size);
		if (clk && size == sizeof(*clk) && *clk)
			pltfm_host->clock = be32_to_cpup(clk);

		host->quirks2 |= SDHCI_QUIRK2_BROKEN_HS200;
		if (of_find_property(np, "caps2-mmc-ddr50-1_8v", NULL))
			host->mmc->caps |= MMC_CAP_1_8V_DDR;

		if (of_find_property(np, "caps2-mmc-ddr50-1_2v", NULL))
			host->mmc->caps |= MMC_CAP_1_2V_DDR;

		if (of_find_property(np, "caps2-mmc-hs200-1_8v", NULL)) {
			host->mmc->caps2 |= MMC_CAP2_HS200_1_8V_SDR;
			host->quirks2 &= ~SDHCI_QUIRK2_BROKEN_HS200;
		}

		if (of_find_property(np, "caps2-mmc-hs200-1_2v", NULL)) {
			host->mmc->caps2 |= MMC_CAP2_HS200_1_2V_SDR;
			host->quirks2 &= ~SDHCI_QUIRK2_BROKEN_HS200;
		}

		if (of_find_property(np, "caps2-mmc-hs400-1_8v", NULL)){
			host->mmc->caps2 |= MMC_CAP2_HS200_1_8V_SDR;
			host->mmc->caps2 |= MMC_CAP2_HS400_1_8V;
			host->quirks2 &= ~SDHCI_QUIRK2_BROKEN_HS200;
		}

		if (of_find_property(np, "caps2-mmc-hs400-1_2v", NULL)){
			host->mmc->caps2 |= MMC_CAP2_HS200_1_2V_SDR;
			host->mmc->caps2 |= MMC_CAP2_HS400_1_2V;
			host->quirks2 &= ~SDHCI_QUIRK2_BROKEN_HS200;
		}

		if (of_find_property(np, "caps2-mmc-packed-command", NULL))
			host->mmc->caps2 |= MMC_CAP2_PACKED_CMD;

		runmode_normal = !runmode_is_factory();

#ifdef CONFIG_HISI_COUL
		batterystate_exist = is_hisi_battery_exist();
#else 
		batterystate_exist = 0;
#endif	
		dev_info(&pdev->dev, "runmode_normal = %d batterystate_exist = %d\n", runmode_normal, batterystate_exist);

		if (of_find_property(np, "caps2-mmc-cache-ctrl", NULL))
		{
			dev_info(&pdev->dev, "caps2-mmc-cache-ctrl is set in dts.\n");
			if(runmode_normal || batterystate_exist)
			{
				dev_info(&pdev->dev, "cache ctrl on\n");
				host->mmc->caps2 |= MMC_CAP2_CACHE_CTRL;
			}
			else
			{
				dev_info(&pdev->dev, "cache ctrl off\n");
			}
		}

		if (of_find_property(np, "full-pwr-cycle", NULL))
			host->mmc->caps2 |= MMC_CAP2_FULL_PWR_CYCLE;

		if (of_find_property(np, "caps2-mmc-cmd-queue", NULL))
		{
			dev_info(&pdev->dev, "caps2-mmc-cmd-queue is set in dts.\n");
			if(runmode_normal || batterystate_exist)
			{
				dev_info(&pdev->dev, "caps2-mmc-cmd-queue on\n");
				host->mmc->caps2 |= MMC_CAP2_CMD_QUEUE;
			}
			else
			{
				dev_info(&pdev->dev, "caps2-mmc-cmd-queue off\n");
			}
		}

		if (of_find_property(np, "keep-power-in-suspend", NULL))
			host->mmc->pm_caps |= MMC_PM_KEEP_POWER;

		if (of_find_property(np, "enable-sdio-wakeup", NULL))
			host->mmc->pm_caps |= MMC_PM_WAKE_SDIO_IRQ;

		if (of_find_property(np, "caps2-mmc-enhanced_strobe-ctrl", NULL))
			host->mmc->caps2 |= MMC_CAP2_ENHANCED_STROBE;

		if (of_find_property(np, "caps2-mmc-cache_flush_barrier-ctrl", NULL))
			host->mmc->caps2 |= MMC_CAP2_CACHE_FLUSH_BARRIER;

		if (of_find_property(np, "caps2-mmc-bkops_auto-ctrl", NULL))
			host->mmc->caps2 |= MMC_CAP2_BKOPS_AUTO_CTRL;

		if (of_find_property(np, "caps2-mmc-HC-erase-size", NULL))
			host->mmc->caps2 |= MMC_CAP2_HC_ERASE_SZ;

	}
}