diff options
Diffstat (limited to 'drivers/pinctrl/pinctrl-max77620.c')
| -rw-r--r-- | drivers/pinctrl/pinctrl-max77620.c | 63 |
1 files changed, 29 insertions, 34 deletions
diff --git a/drivers/pinctrl/pinctrl-max77620.c b/drivers/pinctrl/pinctrl-max77620.c index b8d2180a2bea..acb945a25743 100644 --- a/drivers/pinctrl/pinctrl-max77620.c +++ b/drivers/pinctrl/pinctrl-max77620.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-only /* * MAX77620 pin control driver. * @@ -6,21 +7,19 @@ * Author: * Chaitanya Bandi <bandik@nvidia.com> * Laxman Dewangan <ldewangan@nvidia.com> - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. */ #include <linux/mfd/max77620.h> +#include <linux/mod_devicetable.h> #include <linux/module.h> -#include <linux/of.h> +#include <linux/platform_device.h> +#include <linux/property.h> +#include <linux/regmap.h> + #include <linux/pinctrl/pinctrl.h> #include <linux/pinctrl/pinconf-generic.h> #include <linux/pinctrl/pinconf.h> #include <linux/pinctrl/pinmux.h> -#include <linux/platform_device.h> -#include <linux/regmap.h> #include "core.h" #include "pinconf.h" @@ -34,14 +33,12 @@ enum max77620_pin_ppdrv { MAX77620_PIN_PP_DRV, }; -enum max77620_pinconf_param { - MAX77620_ACTIVE_FPS_SOURCE = PIN_CONFIG_END + 1, - MAX77620_ACTIVE_FPS_POWER_ON_SLOTS, - MAX77620_ACTIVE_FPS_POWER_DOWN_SLOTS, - MAX77620_SUSPEND_FPS_SOURCE, - MAX77620_SUSPEND_FPS_POWER_ON_SLOTS, - MAX77620_SUSPEND_FPS_POWER_DOWN_SLOTS, -}; +#define MAX77620_ACTIVE_FPS_SOURCE (PIN_CONFIG_END + 1) +#define MAX77620_ACTIVE_FPS_POWER_ON_SLOTS (PIN_CONFIG_END + 2) +#define MAX77620_ACTIVE_FPS_POWER_DOWN_SLOTS (PIN_CONFIG_END + 3) +#define MAX77620_SUSPEND_FPS_SOURCE (PIN_CONFIG_END + 4) +#define MAX77620_SUSPEND_FPS_POWER_ON_SLOTS (PIN_CONFIG_END + 5) +#define MAX77620_SUSPEND_FPS_POWER_DOWN_SLOTS (PIN_CONFIG_END + 6) struct max77620_pin_function { const char *name; @@ -91,7 +88,6 @@ struct max77620_pingroup { struct max77620_pin_info { enum max77620_pin_ppdrv drv_type; - int pull_config; }; struct max77620_fps_config { @@ -107,7 +103,6 @@ struct max77620_pctrl_info { struct device *dev; struct pinctrl_dev *pctl; struct regmap *rmap; - int pins_current_opt[MAX77620_GPIO_NR]; const struct max77620_pin_function *functions; unsigned int num_functions; const struct max77620_pingroup *pin_groups; @@ -420,11 +415,9 @@ static int max77620_pinconf_set(struct pinctrl_dev *pctldev, MAX77620_REG_GPIO0 + pin, MAX77620_CNFG_GPIO_DRV_MASK, val); - if (ret < 0) { - dev_err(dev, "Reg 0x%02x update failed %d\n", - MAX77620_REG_GPIO0 + pin, ret); - return ret; - } + if (ret) + goto report_update_failure; + mpci->pin_info[pin].drv_type = val ? MAX77620_PIN_PP_DRV : MAX77620_PIN_OD_DRV; break; @@ -435,11 +428,9 @@ static int max77620_pinconf_set(struct pinctrl_dev *pctldev, MAX77620_REG_GPIO0 + pin, MAX77620_CNFG_GPIO_DRV_MASK, val); - if (ret < 0) { - dev_err(dev, "Reg 0x%02x update failed %d\n", - MAX77620_REG_GPIO0 + pin, ret); - return ret; - } + if (ret) + goto report_update_failure; + mpci->pin_info[pin].drv_type = val ? MAX77620_PIN_PP_DRV : MAX77620_PIN_OD_DRV; break; @@ -536,6 +527,11 @@ static int max77620_pinconf_set(struct pinctrl_dev *pctldev, } return 0; + +report_update_failure: + dev_err(dev, "Reg 0x%02x update failed %d\n", + MAX77620_REG_GPIO0 + pin, ret); + return ret; } static const struct pinconf_ops max77620_pinconf_ops = { @@ -547,6 +543,10 @@ static struct pinctrl_desc max77620_pinctrl_desc = { .pctlops = &max77620_pinctrl_ops, .pmxops = &max77620_pinmux_ops, .confops = &max77620_pinconf_ops, + .pins = max77620_pins_desc, + .npins = ARRAY_SIZE(max77620_pins_desc), + .num_custom_params = ARRAY_SIZE(max77620_cfg_params), + .custom_params = max77620_cfg_params, }; static int max77620_pinctrl_probe(struct platform_device *pdev) @@ -555,12 +555,13 @@ static int max77620_pinctrl_probe(struct platform_device *pdev) struct max77620_pctrl_info *mpci; int i; + device_set_node(&pdev->dev, dev_fwnode(pdev->dev.parent)); + mpci = devm_kzalloc(&pdev->dev, sizeof(*mpci), GFP_KERNEL); if (!mpci) return -ENOMEM; mpci->dev = &pdev->dev; - mpci->dev->of_node = pdev->dev.parent->of_node; mpci->rmap = max77620->rmap; mpci->pins = max77620_pins_desc; @@ -572,11 +573,6 @@ static int max77620_pinctrl_probe(struct platform_device *pdev) platform_set_drvdata(pdev, mpci); max77620_pinctrl_desc.name = dev_name(&pdev->dev); - max77620_pinctrl_desc.pins = max77620_pins_desc; - max77620_pinctrl_desc.npins = ARRAY_SIZE(max77620_pins_desc); - max77620_pinctrl_desc.num_custom_params = - ARRAY_SIZE(max77620_cfg_params); - max77620_pinctrl_desc.custom_params = max77620_cfg_params; for (i = 0; i < MAX77620_PIN_NUM; ++i) { mpci->fps_config[i].active_fps_src = -1; @@ -669,5 +665,4 @@ module_platform_driver(max77620_pinctrl_driver); MODULE_DESCRIPTION("MAX77620/MAX20024 pin control driver"); MODULE_AUTHOR("Chaitanya Bandi<bandik@nvidia.com>"); MODULE_AUTHOR("Laxman Dewangan<ldewangan@nvidia.com>"); -MODULE_ALIAS("platform:max77620-pinctrl"); MODULE_LICENSE("GPL v2"); |
