Lines Matching +full:reg +full:- +full:offset

2  * Copyright (c) 2010-2016, NVIDIA CORPORATION.
5 * SPDX-License-Identifier: GPL-2.0
16 #include <dm/device-internal.h>
17 #include <dt-bindings/gpio/gpio.h>
24 uint32_t offset; member
37 static uint32_t *tegra186_gpio_reg(struct udevice *dev, uint32_t reg, in tegra186_gpio_reg() argument
40 struct tegra186_gpio_platdata *plat = dev->platdata; in tegra186_gpio_reg()
41 uint32_t index = (reg + (gpio * TEGRA186_GPIO_PER_GPIO_STRIDE)) / 4; in tegra186_gpio_reg()
43 return &(plat->regs[index]); in tegra186_gpio_reg()
46 static int tegra186_gpio_set_out(struct udevice *dev, unsigned offset, in tegra186_gpio_set_out() argument
49 uint32_t *reg; in tegra186_gpio_set_out() local
52 reg = tegra186_gpio_reg(dev, TEGRA186_GPIO_OUTPUT_CONTROL, offset); in tegra186_gpio_set_out()
53 rval = readl(reg); in tegra186_gpio_set_out()
58 writel(rval, reg); in tegra186_gpio_set_out()
60 reg = tegra186_gpio_reg(dev, TEGRA186_GPIO_ENABLE_CONFIG, offset); in tegra186_gpio_set_out()
61 rval = readl(reg); in tegra186_gpio_set_out()
67 writel(rval, reg); in tegra186_gpio_set_out()
72 static int tegra186_gpio_set_val(struct udevice *dev, unsigned offset, bool val) in tegra186_gpio_set_val() argument
74 uint32_t *reg; in tegra186_gpio_set_val() local
77 reg = tegra186_gpio_reg(dev, TEGRA186_GPIO_OUTPUT_VALUE, offset); in tegra186_gpio_set_val()
78 rval = readl(reg); in tegra186_gpio_set_val()
83 writel(rval, reg); in tegra186_gpio_set_val()
88 static int tegra186_gpio_direction_input(struct udevice *dev, unsigned offset) in tegra186_gpio_direction_input() argument
90 return tegra186_gpio_set_out(dev, offset, false); in tegra186_gpio_direction_input()
93 static int tegra186_gpio_direction_output(struct udevice *dev, unsigned offset, in tegra186_gpio_direction_output() argument
98 ret = tegra186_gpio_set_val(dev, offset, value != 0); in tegra186_gpio_direction_output()
101 return tegra186_gpio_set_out(dev, offset, true); in tegra186_gpio_direction_output()
104 static int tegra186_gpio_get_value(struct udevice *dev, unsigned offset) in tegra186_gpio_get_value() argument
106 uint32_t *reg; in tegra186_gpio_get_value() local
109 reg = tegra186_gpio_reg(dev, TEGRA186_GPIO_ENABLE_CONFIG, offset); in tegra186_gpio_get_value()
110 rval = readl(reg); in tegra186_gpio_get_value()
113 reg = tegra186_gpio_reg(dev, TEGRA186_GPIO_OUTPUT_VALUE, in tegra186_gpio_get_value()
114 offset); in tegra186_gpio_get_value()
116 reg = tegra186_gpio_reg(dev, TEGRA186_GPIO_INPUT, offset); in tegra186_gpio_get_value()
118 rval = readl(reg); in tegra186_gpio_get_value()
122 static int tegra186_gpio_set_value(struct udevice *dev, unsigned offset, in tegra186_gpio_set_value() argument
125 return tegra186_gpio_set_val(dev, offset, value != 0); in tegra186_gpio_set_value()
128 static int tegra186_gpio_get_function(struct udevice *dev, unsigned offset) in tegra186_gpio_get_function() argument
130 uint32_t *reg; in tegra186_gpio_get_function() local
133 reg = tegra186_gpio_reg(dev, TEGRA186_GPIO_ENABLE_CONFIG, offset); in tegra186_gpio_get_function()
134 rval = readl(reg); in tegra186_gpio_get_function()
146 gpio = args->args[0]; in tegra186_gpio_xlate()
148 ret = device_get_child(dev, port, &desc->dev); in tegra186_gpio_xlate()
151 desc->offset = gpio % TEGRA186_GPIO_PER_GPIO_COUNT; in tegra186_gpio_xlate()
152 desc->flags = args->args[1] & GPIO_ACTIVE_LOW ? GPIOD_ACTIVE_LOW : 0; in tegra186_gpio_xlate()
167 * We have a top-level GPIO device with no actual GPIOs. It has a child device
172 struct tegra186_gpio_platdata *parent_plat = parent->platdata; in tegra186_gpio_bind()
184 return -EINVAL; in tegra186_gpio_bind()
186 for (port = 0; port < ctlr_data->port_count; port++) { in tegra186_gpio_bind()
192 return -ENOMEM; in tegra186_gpio_bind()
193 plat->name = ctlr_data->ports[port].name; in tegra186_gpio_bind()
194 plat->regs = &(regs[ctlr_data->ports[port].offset / 4]); in tegra186_gpio_bind()
196 ret = device_bind(parent, parent->driver, plat->name, plat, in tegra186_gpio_bind()
197 -1, &dev); in tegra186_gpio_bind()
208 struct tegra186_gpio_platdata *plat = dev->platdata; in tegra186_gpio_probe()
215 uc_priv->gpio_count = TEGRA186_GPIO_PER_GPIO_COUNT; in tegra186_gpio_probe()
216 uc_priv->bank_name = plat->name; in tegra186_gpio_probe()
270 .compatible = "nvidia,tegra186-gpio",
274 .compatible = "nvidia,tegra186-gpio-aon",