Lines Matching +full:chip +full:- +full:scu

1 // SPDX-License-Identifier: GPL-2.0-only
6 * to control the PIN resources on SCU domain.
14 #include <dt-bindings/firmware/imx/rsrc.h>
17 struct gpio_chip chip; member
34 static int imx_scu_gpio_get(struct gpio_chip *chip, unsigned int offset) in imx_scu_gpio_get() argument
36 struct scu_gpio_priv *priv = gpiochip_get_data(chip); in imx_scu_gpio_get()
40 if (offset >= chip->ngpio) in imx_scu_gpio_get()
41 return -EINVAL; in imx_scu_gpio_get()
43 mutex_lock(&priv->lock); in imx_scu_gpio_get()
45 /* to read PIN state via scu api */ in imx_scu_gpio_get()
46 err = imx_sc_misc_get_control(priv->handle, in imx_scu_gpio_get()
48 mutex_unlock(&priv->lock); in imx_scu_gpio_get()
51 dev_err(priv->dev, "SCU get failed: %d\n", err); in imx_scu_gpio_get()
58 static void imx_scu_gpio_set(struct gpio_chip *chip, unsigned int offset, int value) in imx_scu_gpio_set() argument
60 struct scu_gpio_priv *priv = gpiochip_get_data(chip); in imx_scu_gpio_set()
63 if (offset >= chip->ngpio) in imx_scu_gpio_set()
66 mutex_lock(&priv->lock); in imx_scu_gpio_set()
68 /* to set PIN output level via scu api */ in imx_scu_gpio_set()
69 err = imx_sc_misc_set_control(priv->handle, in imx_scu_gpio_set()
71 mutex_unlock(&priv->lock); in imx_scu_gpio_set()
74 dev_err(priv->dev, "SCU set (%d) failed: %d\n", in imx_scu_gpio_set()
78 static int imx_scu_gpio_get_direction(struct gpio_chip *chip, unsigned int offset) in imx_scu_gpio_get_direction() argument
80 if (offset >= chip->ngpio) in imx_scu_gpio_get_direction()
81 return -EINVAL; in imx_scu_gpio_get_direction()
88 struct device *dev = &pdev->dev; in imx_scu_gpio_probe()
93 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); in imx_scu_gpio_probe()
95 return -ENOMEM; in imx_scu_gpio_probe()
97 ret = imx_scu_get_handle(&priv->handle); in imx_scu_gpio_probe()
101 priv->dev = dev; in imx_scu_gpio_probe()
102 mutex_init(&priv->lock); in imx_scu_gpio_probe()
104 gc = &priv->chip; in imx_scu_gpio_probe()
105 gc->base = -1; in imx_scu_gpio_probe()
106 gc->parent = dev; in imx_scu_gpio_probe()
107 gc->ngpio = ARRAY_SIZE(scu_rsrc_arr); in imx_scu_gpio_probe()
108 gc->label = dev_name(dev); in imx_scu_gpio_probe()
109 gc->get = imx_scu_gpio_get; in imx_scu_gpio_probe()
110 gc->set = imx_scu_gpio_set; in imx_scu_gpio_probe()
111 gc->get_direction = imx_scu_gpio_get_direction; in imx_scu_gpio_probe()
119 { .compatible = "fsl,imx8qxp-sc-gpio" },
125 .name = "gpio-imx-scu",
139 MODULE_DESCRIPTION("NXP GPIO over IMX SCU API");