Beispiel #1
0
static int sh_pfc_probe(struct platform_device *pdev)
{
    const struct sh_pfc_soc_info *info;
    struct sh_pfc *pfc;
    int ret;

    info = pdev->id_entry->driver_data
           ? (void *)pdev->id_entry->driver_data : pdev->dev.platform_data;
    if (info == NULL)
        return -ENODEV;

    pfc = devm_kzalloc(&pdev->dev, sizeof(*pfc), GFP_KERNEL);
    if (pfc == NULL)
        return -ENOMEM;

    pfc->info = info;
    pfc->dev = &pdev->dev;

    ret = sh_pfc_ioremap(pfc, pdev);
    if (unlikely(ret < 0))
        return ret;

    spin_lock_init(&pfc->lock);

    pinctrl_provide_dummies();

    /*
     * Initialize pinctrl bindings first
     */
    ret = sh_pfc_register_pinctrl(pfc);
    if (unlikely(ret != 0))
        return ret;

#ifdef CONFIG_GPIO_SH_PFC
    /*
     * Then the GPIO chip
     */
    ret = sh_pfc_register_gpiochip(pfc);
    if (unlikely(ret != 0)) {
        /*
         * If the GPIO chip fails to come up we still leave the
         * PFC state as it is, given that there are already
         * extant users of it that have succeeded by this point.
         */
        dev_notice(pfc->dev, "failed to init GPIO chip, ignoring...\n");
    }
#endif

    platform_set_drvdata(pdev, pfc);

    dev_info(pfc->dev, "%s support registered\n", info->name);

    return 0;
}
Beispiel #2
0
static int sh_pfc_probe(struct platform_device *pdev)
{
	const struct platform_device_id *platid = platform_get_device_id(pdev);
#ifdef CONFIG_OF
	struct device_node *np = pdev->dev.of_node;
#endif
	const struct sh_pfc_soc_info *info;
	struct sh_pfc *pfc;
	int ret;

#ifdef CONFIG_OF
	if (np)
		info = of_device_get_match_data(&pdev->dev);
	else
#endif
		info = platid ? (const void *)platid->driver_data : NULL;

	if (info == NULL)
		return -ENODEV;

	pfc = devm_kzalloc(&pdev->dev, sizeof(*pfc), GFP_KERNEL);
	if (pfc == NULL)
		return -ENOMEM;

	pfc->info = info;
	pfc->dev = &pdev->dev;

	ret = sh_pfc_map_resources(pfc, pdev);
	if (unlikely(ret < 0))
		return ret;

	spin_lock_init(&pfc->lock);

	if (info->ops && info->ops->init) {
		ret = info->ops->init(pfc);
		if (ret < 0)
			return ret;
	}

	/* Enable dummy states for those platforms without pinctrl support */
	if (!of_have_populated_dt())
		pinctrl_provide_dummies();

	ret = sh_pfc_init_ranges(pfc);
	if (ret < 0)
		return ret;

	/*
	 * Initialize pinctrl bindings first
	 */
	ret = sh_pfc_register_pinctrl(pfc);
	if (unlikely(ret != 0))
		return ret;

#ifdef CONFIG_PINCTRL_SH_PFC_GPIO
	/*
	 * Then the GPIO chip
	 */
	ret = sh_pfc_register_gpiochip(pfc);
	if (unlikely(ret != 0)) {
		/*
		 * If the GPIO chip fails to come up we still leave the
		 * PFC state as it is, given that there are already
		 * extant users of it that have succeeded by this point.
		 */
		dev_notice(pfc->dev, "failed to init GPIO chip, ignoring...\n");
	}
#endif

	platform_set_drvdata(pdev, pfc);

	dev_info(pfc->dev, "%s support registered\n", info->name);

	return 0;
}