Lines Matching +full:rk3328 +full:- +full:grf +full:- +full:gpio

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * SYSCON GPIO driver
9 #include <linux/gpio/driver.h>
20 /* SYSCON driver is designed to use 32-bit wide registers */
25 * struct syscon_gpio_data - Configuration for the device.
31 * @dat_bit_offset: Offset (in bits) to the first GPIO bit.
33 * GPIO direction (Used with GPIO_SYSCON_FEAT_DIR flag).
61 offs = priv->dreg_offset + priv->data->dat_bit_offset + offset; in syscon_gpio_get()
63 ret = regmap_read(priv->syscon, in syscon_gpio_get()
76 offs = priv->dreg_offset + priv->data->dat_bit_offset + offset; in syscon_gpio_set()
78 regmap_update_bits(priv->syscon, in syscon_gpio_set()
88 if (priv->data->flags & GPIO_SYSCON_FEAT_DIR) { in syscon_gpio_dir_in()
91 offs = priv->dir_reg_offset + in syscon_gpio_dir_in()
92 priv->data->dir_bit_offset + offset; in syscon_gpio_dir_in()
94 regmap_update_bits(priv->syscon, in syscon_gpio_dir_in()
106 if (priv->data->flags & GPIO_SYSCON_FEAT_DIR) { in syscon_gpio_dir_out()
109 offs = priv->dir_reg_offset + in syscon_gpio_dir_out()
110 priv->data->dir_bit_offset + offset; in syscon_gpio_dir_out()
112 regmap_update_bits(priv->syscon, in syscon_gpio_dir_out()
118 chip->set(chip, offset, val); in syscon_gpio_dir_out()
124 /* ARM CLPS711X SYSFLG1 Bits 8-10 */
139 offs = priv->dreg_offset + priv->data->dat_bit_offset + offset; in rockchip_gpio_set()
142 ret = regmap_write(priv->syscon, in rockchip_gpio_set()
146 dev_err(chip->parent, "gpio write failed ret(%d)\n", ret); in rockchip_gpio_set()
150 /* RK3328 GPIO_MUTE is an output only pin at GRF_SOC_CON10[1] */
165 offs = priv->dreg_offset + priv->data->dat_bit_offset + offset; in keystone_gpio_set()
171 priv->syscon, in keystone_gpio_set()
176 dev_err(chip->parent, "gpio write failed ret(%d)\n", ret); in keystone_gpio_set()
189 .compatible = "cirrus,ep7209-mctrl-gpio",
193 .compatible = "ti,keystone-dsp-gpio",
197 .compatible = "rockchip,rk3328-grf-gpio",
206 struct device *dev = &pdev->dev; in syscon_gpio_probe()
208 struct device_node *np = dev->of_node; in syscon_gpio_probe()
214 return -ENOMEM; in syscon_gpio_probe()
216 priv->data = of_device_get_match_data(dev); in syscon_gpio_probe()
218 priv->syscon = syscon_regmap_lookup_by_phandle(np, "gpio,syscon-dev"); in syscon_gpio_probe()
219 if (IS_ERR(priv->syscon) && np->parent) { in syscon_gpio_probe()
220 priv->syscon = syscon_node_to_regmap(np->parent); in syscon_gpio_probe()
223 if (IS_ERR(priv->syscon)) in syscon_gpio_probe()
224 return PTR_ERR(priv->syscon); in syscon_gpio_probe()
227 ret = of_property_read_u32_index(np, "gpio,syscon-dev", 1, in syscon_gpio_probe()
228 &priv->dreg_offset); in syscon_gpio_probe()
232 priv->dreg_offset <<= 3; in syscon_gpio_probe()
234 ret = of_property_read_u32_index(np, "gpio,syscon-dev", 2, in syscon_gpio_probe()
235 &priv->dir_reg_offset); in syscon_gpio_probe()
239 priv->dir_reg_offset <<= 3; in syscon_gpio_probe()
242 priv->chip.parent = dev; in syscon_gpio_probe()
243 priv->chip.owner = THIS_MODULE; in syscon_gpio_probe()
244 priv->chip.label = dev_name(dev); in syscon_gpio_probe()
245 priv->chip.base = -1; in syscon_gpio_probe()
246 priv->chip.ngpio = priv->data->bit_count; in syscon_gpio_probe()
247 priv->chip.get = syscon_gpio_get; in syscon_gpio_probe()
248 if (priv->data->flags & GPIO_SYSCON_FEAT_IN) in syscon_gpio_probe()
249 priv->chip.direction_input = syscon_gpio_dir_in; in syscon_gpio_probe()
250 if (priv->data->flags & GPIO_SYSCON_FEAT_OUT) { in syscon_gpio_probe()
251 priv->chip.set = priv->data->set ? : syscon_gpio_set; in syscon_gpio_probe()
252 priv->chip.direction_output = syscon_gpio_dir_out; in syscon_gpio_probe()
255 return devm_gpiochip_add_data(&pdev->dev, &priv->chip, priv); in syscon_gpio_probe()
260 .name = "gpio-syscon",
268 MODULE_DESCRIPTION("SYSCON GPIO driver");