aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl/bcm
diff options
context:
space:
mode:
authorPramod Kumar <pramodku@broadcom.com>2015-11-18 22:52:17 -0500
committerLinus Walleij <linus.walleij@linaro.org>2015-11-30 03:40:05 -0500
commitafc8c78d179d36b85b648dca865e56040afc5f2d (patch)
tree45293c88e749a1238ca11143ee22b9f7eb1d6fe3 /drivers/pinctrl/bcm
parent462de629942212d90e6c915eca3eaebb45b647a3 (diff)
gpio: Rename func/macro/var to IP-block,iproc
Change functions, macros and variables name from cygnus to IP block, iproc, so that it could be used in all iproc based future SoCs having same GPIO controller block. Signed-off-by: Pramod Kumar <pramodku@broadcom.com> Reviewed-by: Ray Jui <rjui@broadcom.com> Reviewed-by: Scott Branden <sbranden@broadcom.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/bcm')
-rw-r--r--drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c306
1 files changed, 154 insertions, 152 deletions
diff --git a/drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c b/drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c
index f60ec8edead1..fa66c3e05cc3 100644
--- a/drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c
+++ b/drivers/pinctrl/bcm/pinctrl-cygnus-gpio.c
@@ -10,14 +10,16 @@
10 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details. 11 * GNU General Public License for more details.
12 * 12 *
13 * This file contains the Broadcom Cygnus GPIO driver that supports 3 13 * This file contains the Broadcom Iproc GPIO driver that supports 3
14 * GPIO controllers on Cygnus including the ASIU GPIO controller, the 14 * GPIO controllers on Iproc including the ASIU GPIO controller, the
15 * chipCommonG GPIO controller, and the always-on GPIO controller. Basic 15 * chipCommonG GPIO controller, and the always-on GPIO controller. Basic
16 * PINCONF such as bias pull up/down, and drive strength are also supported 16 * PINCONF such as bias pull up/down, and drive strength are also supported
17 * in this driver. 17 * in this driver.
18 * 18 *
19 * Pins from the ASIU GPIO can be individually muxed to GPIO function, 19 * It provides the functionality where pins from the GPIO can be
20 * through the interaction with the Cygnus IOMUX controller 20 * individually muxed to GPIO function, if individual pad
21 * configuration is supported, through the interaction with respective
22 * SoCs IOMUX controller.
21 */ 23 */
22 24
23#include <linux/kernel.h> 25#include <linux/kernel.h>
@@ -34,42 +36,42 @@
34 36
35#include "../pinctrl-utils.h" 37#include "../pinctrl-utils.h"
36 38
37#define CYGNUS_GPIO_DATA_IN_OFFSET 0x00 39#define IPROC_GPIO_DATA_IN_OFFSET 0x00
38#define CYGNUS_GPIO_DATA_OUT_OFFSET 0x04 40#define IPROC_GPIO_DATA_OUT_OFFSET 0x04
39#define CYGNUS_GPIO_OUT_EN_OFFSET 0x08 41#define IPROC_GPIO_OUT_EN_OFFSET 0x08
40#define CYGNUS_GPIO_INT_TYPE_OFFSET 0x0c 42#define IPROC_GPIO_INT_TYPE_OFFSET 0x0c
41#define CYGNUS_GPIO_INT_DE_OFFSET 0x10 43#define IPROC_GPIO_INT_DE_OFFSET 0x10
42#define CYGNUS_GPIO_INT_EDGE_OFFSET 0x14 44#define IPROC_GPIO_INT_EDGE_OFFSET 0x14
43#define CYGNUS_GPIO_INT_MSK_OFFSET 0x18 45#define IPROC_GPIO_INT_MSK_OFFSET 0x18
44#define CYGNUS_GPIO_INT_STAT_OFFSET 0x1c 46#define IPROC_GPIO_INT_STAT_OFFSET 0x1c
45#define CYGNUS_GPIO_INT_MSTAT_OFFSET 0x20 47#define IPROC_GPIO_INT_MSTAT_OFFSET 0x20
46#define CYGNUS_GPIO_INT_CLR_OFFSET 0x24 48#define IPROC_GPIO_INT_CLR_OFFSET 0x24
47#define CYGNUS_GPIO_PAD_RES_OFFSET 0x34 49#define IPROC_GPIO_PAD_RES_OFFSET 0x34
48#define CYGNUS_GPIO_RES_EN_OFFSET 0x38 50#define IPROC_GPIO_RES_EN_OFFSET 0x38
49 51
50/* drive strength control for ASIU GPIO */ 52/* drive strength control for ASIU GPIO */
51#define CYGNUS_GPIO_ASIU_DRV0_CTRL_OFFSET 0x58 53#define IPROC_GPIO_ASIU_DRV0_CTRL_OFFSET 0x58
52 54
53/* drive strength control for CCM/CRMU (AON) GPIO */ 55/* drive strength control for CCM/CRMU (AON) GPIO */
54#define CYGNUS_GPIO_DRV0_CTRL_OFFSET 0x00 56#define IPROC_GPIO_DRV0_CTRL_OFFSET 0x00
55 57
56#define GPIO_BANK_SIZE 0x200 58#define GPIO_BANK_SIZE 0x200
57#define NGPIOS_PER_BANK 32 59#define NGPIOS_PER_BANK 32
58#define GPIO_BANK(pin) ((pin) / NGPIOS_PER_BANK) 60#define GPIO_BANK(pin) ((pin) / NGPIOS_PER_BANK)
59 61
60#define CYGNUS_GPIO_REG(pin, reg) (GPIO_BANK(pin) * GPIO_BANK_SIZE + (reg)) 62#define IPROC_GPIO_REG(pin, reg) (GPIO_BANK(pin) * GPIO_BANK_SIZE + (reg))
61#define CYGNUS_GPIO_SHIFT(pin) ((pin) % NGPIOS_PER_BANK) 63#define IPROC_GPIO_SHIFT(pin) ((pin) % NGPIOS_PER_BANK)
62 64
63#define GPIO_DRV_STRENGTH_BIT_SHIFT 20 65#define GPIO_DRV_STRENGTH_BIT_SHIFT 20
64#define GPIO_DRV_STRENGTH_BITS 3 66#define GPIO_DRV_STRENGTH_BITS 3
65#define GPIO_DRV_STRENGTH_BIT_MASK ((1 << GPIO_DRV_STRENGTH_BITS) - 1) 67#define GPIO_DRV_STRENGTH_BIT_MASK ((1 << GPIO_DRV_STRENGTH_BITS) - 1)
66 68
67/* 69/*
68 * Cygnus GPIO core 70 * Iproc GPIO core
69 * 71 *
70 * @dev: pointer to device 72 * @dev: pointer to device
71 * @base: I/O register base for Cygnus GPIO controller 73 * @base: I/O register base for Iproc GPIO controller
72 * @io_ctrl: I/O register base for certain type of Cygnus GPIO controller that 74 * @io_ctrl: I/O register base for certain type of Iproc GPIO controller that
73 * has the PINCONF support implemented outside of the GPIO block 75 * has the PINCONF support implemented outside of the GPIO block
74 * @lock: lock to protect access to I/O registers 76 * @lock: lock to protect access to I/O registers
75 * @gc: GPIO chip 77 * @gc: GPIO chip
@@ -79,7 +81,7 @@
79 * @pctl: pointer to pinctrl_dev 81 * @pctl: pointer to pinctrl_dev
80 * @pctldesc: pinctrl descriptor 82 * @pctldesc: pinctrl descriptor
81 */ 83 */
82struct cygnus_gpio { 84struct iproc_gpio {
83 struct device *dev; 85 struct device *dev;
84 86
85 void __iomem *base; 87 void __iomem *base;
@@ -96,33 +98,33 @@ struct cygnus_gpio {
96 struct pinctrl_desc pctldesc; 98 struct pinctrl_desc pctldesc;
97}; 99};
98 100
99static inline struct cygnus_gpio *to_cygnus_gpio(struct gpio_chip *gc) 101static inline struct iproc_gpio *to_iproc_gpio(struct gpio_chip *gc)
100{ 102{
101 return container_of(gc, struct cygnus_gpio, gc); 103 return container_of(gc, struct iproc_gpio, gc);
102} 104}
103 105
104/* 106/*
105 * Mapping from PINCONF pins to GPIO pins is 1-to-1 107 * Mapping from PINCONF pins to GPIO pins is 1-to-1
106 */ 108 */
107static inline unsigned cygnus_pin_to_gpio(unsigned pin) 109static inline unsigned iproc_pin_to_gpio(unsigned pin)
108{ 110{
109 return pin; 111 return pin;
110} 112}
111 113
112/** 114/**
113 * cygnus_set_bit - set or clear one bit (corresponding to the GPIO pin) in a 115 * iproc_set_bit - set or clear one bit (corresponding to the GPIO pin) in a
114 * Cygnus GPIO register 116 * Iproc GPIO register
115 * 117 *
116 * @cygnus_gpio: Cygnus GPIO device 118 * @iproc_gpio: Iproc GPIO device
117 * @reg: register offset 119 * @reg: register offset
118 * @gpio: GPIO pin 120 * @gpio: GPIO pin
119 * @set: set or clear 121 * @set: set or clear
120 */ 122 */
121static inline void cygnus_set_bit(struct cygnus_gpio *chip, unsigned int reg, 123static inline void iproc_set_bit(struct iproc_gpio *chip, unsigned int reg,
122 unsigned gpio, bool set) 124 unsigned gpio, bool set)
123{ 125{
124 unsigned int offset = CYGNUS_GPIO_REG(gpio, reg); 126 unsigned int offset = IPROC_GPIO_REG(gpio, reg);
125 unsigned int shift = CYGNUS_GPIO_SHIFT(gpio); 127 unsigned int shift = IPROC_GPIO_SHIFT(gpio);
126 u32 val; 128 u32 val;
127 129
128 val = readl(chip->base + offset); 130 val = readl(chip->base + offset);
@@ -133,19 +135,19 @@ static inline void cygnus_set_bit(struct cygnus_gpio *chip, unsigned int reg,
133 writel(val, chip->base + offset); 135 writel(val, chip->base + offset);
134} 136}
135 137
136static inline bool cygnus_get_bit(struct cygnus_gpio *chip, unsigned int reg, 138static inline bool iproc_get_bit(struct iproc_gpio *chip, unsigned int reg,
137 unsigned gpio) 139 unsigned gpio)
138{ 140{
139 unsigned int offset = CYGNUS_GPIO_REG(gpio, reg); 141 unsigned int offset = IPROC_GPIO_REG(gpio, reg);
140 unsigned int shift = CYGNUS_GPIO_SHIFT(gpio); 142 unsigned int shift = IPROC_GPIO_SHIFT(gpio);
141 143
142 return !!(readl(chip->base + offset) & BIT(shift)); 144 return !!(readl(chip->base + offset) & BIT(shift));
143} 145}
144 146
145static void cygnus_gpio_irq_handler(struct irq_desc *desc) 147static void iproc_gpio_irq_handler(struct irq_desc *desc)
146{ 148{
147 struct gpio_chip *gc = irq_desc_get_handler_data(desc); 149 struct gpio_chip *gc = irq_desc_get_handler_data(desc);
148 struct cygnus_gpio *chip = to_cygnus_gpio(gc); 150 struct iproc_gpio *chip = to_iproc_gpio(gc);
149 struct irq_chip *irq_chip = irq_desc_get_chip(desc); 151 struct irq_chip *irq_chip = irq_desc_get_chip(desc);
150 int i, bit; 152 int i, bit;
151 153
@@ -154,7 +156,7 @@ static void cygnus_gpio_irq_handler(struct irq_desc *desc)
154 /* go through the entire GPIO banks and handle all interrupts */ 156 /* go through the entire GPIO banks and handle all interrupts */
155 for (i = 0; i < chip->num_banks; i++) { 157 for (i = 0; i < chip->num_banks; i++) {
156 unsigned long val = readl(chip->base + (i * GPIO_BANK_SIZE) + 158 unsigned long val = readl(chip->base + (i * GPIO_BANK_SIZE) +
157 CYGNUS_GPIO_INT_MSTAT_OFFSET); 159 IPROC_GPIO_INT_MSTAT_OFFSET);
158 160
159 for_each_set_bit(bit, &val, NGPIOS_PER_BANK) { 161 for_each_set_bit(bit, &val, NGPIOS_PER_BANK) {
160 unsigned pin = NGPIOS_PER_BANK * i + bit; 162 unsigned pin = NGPIOS_PER_BANK * i + bit;
@@ -165,7 +167,7 @@ static void cygnus_gpio_irq_handler(struct irq_desc *desc)
165 * handler, so we do not leave any window 167 * handler, so we do not leave any window
166 */ 168 */
167 writel(BIT(bit), chip->base + (i * GPIO_BANK_SIZE) + 169 writel(BIT(bit), chip->base + (i * GPIO_BANK_SIZE) +
168 CYGNUS_GPIO_INT_CLR_OFFSET); 170 IPROC_GPIO_INT_CLR_OFFSET);
169 171
170 generic_handle_irq(child_irq); 172 generic_handle_irq(child_irq);
171 } 173 }
@@ -175,60 +177,60 @@ static void cygnus_gpio_irq_handler(struct irq_desc *desc)
175} 177}
176 178
177 179
178static void cygnus_gpio_irq_ack(struct irq_data *d) 180static void iproc_gpio_irq_ack(struct irq_data *d)
179{ 181{
180 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 182 struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
181 struct cygnus_gpio *chip = to_cygnus_gpio(gc); 183 struct iproc_gpio *chip = to_iproc_gpio(gc);
182 unsigned gpio = d->hwirq; 184 unsigned gpio = d->hwirq;
183 unsigned int offset = CYGNUS_GPIO_REG(gpio, 185 unsigned int offset = IPROC_GPIO_REG(gpio,
184 CYGNUS_GPIO_INT_CLR_OFFSET); 186 IPROC_GPIO_INT_CLR_OFFSET);
185 unsigned int shift = CYGNUS_GPIO_SHIFT(gpio); 187 unsigned int shift = IPROC_GPIO_SHIFT(gpio);
186 u32 val = BIT(shift); 188 u32 val = BIT(shift);
187 189
188 writel(val, chip->base + offset); 190 writel(val, chip->base + offset);
189} 191}
190 192
191/** 193/**
192 * cygnus_gpio_irq_set_mask - mask/unmask a GPIO interrupt 194 * iproc_gpio_irq_set_mask - mask/unmask a GPIO interrupt
193 * 195 *
194 * @d: IRQ chip data 196 * @d: IRQ chip data
195 * @unmask: mask/unmask GPIO interrupt 197 * @unmask: mask/unmask GPIO interrupt
196 */ 198 */
197static void cygnus_gpio_irq_set_mask(struct irq_data *d, bool unmask) 199static void iproc_gpio_irq_set_mask(struct irq_data *d, bool unmask)
198{ 200{
199 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 201 struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
200 struct cygnus_gpio *chip = to_cygnus_gpio(gc); 202 struct iproc_gpio *chip = to_iproc_gpio(gc);
201 unsigned gpio = d->hwirq; 203 unsigned gpio = d->hwirq;
202 204
203 cygnus_set_bit(chip, CYGNUS_GPIO_INT_MSK_OFFSET, gpio, unmask); 205 iproc_set_bit(chip, IPROC_GPIO_INT_MSK_OFFSET, gpio, unmask);
204} 206}
205 207
206static void cygnus_gpio_irq_mask(struct irq_data *d) 208static void iproc_gpio_irq_mask(struct irq_data *d)
207{ 209{
208 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 210 struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
209 struct cygnus_gpio *chip = to_cygnus_gpio(gc); 211 struct iproc_gpio *chip = to_iproc_gpio(gc);
210 unsigned long flags; 212 unsigned long flags;
211 213
212 spin_lock_irqsave(&chip->lock, flags); 214 spin_lock_irqsave(&chip->lock, flags);
213 cygnus_gpio_irq_set_mask(d, false); 215 iproc_gpio_irq_set_mask(d, false);
214 spin_unlock_irqrestore(&chip->lock, flags); 216 spin_unlock_irqrestore(&chip->lock, flags);
215} 217}
216 218
217static void cygnus_gpio_irq_unmask(struct irq_data *d) 219static void iproc_gpio_irq_unmask(struct irq_data *d)
218{ 220{
219 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 221 struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
220 struct cygnus_gpio *chip = to_cygnus_gpio(gc); 222 struct iproc_gpio *chip = to_iproc_gpio(gc);
221 unsigned long flags; 223 unsigned long flags;
222 224
223 spin_lock_irqsave(&chip->lock, flags); 225 spin_lock_irqsave(&chip->lock, flags);
224 cygnus_gpio_irq_set_mask(d, true); 226 iproc_gpio_irq_set_mask(d, true);
225 spin_unlock_irqrestore(&chip->lock, flags); 227 spin_unlock_irqrestore(&chip->lock, flags);
226} 228}
227 229
228static int cygnus_gpio_irq_set_type(struct irq_data *d, unsigned int type) 230static int iproc_gpio_irq_set_type(struct irq_data *d, unsigned int type)
229{ 231{
230 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 232 struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
231 struct cygnus_gpio *chip = to_cygnus_gpio(gc); 233 struct iproc_gpio *chip = to_iproc_gpio(gc);
232 unsigned gpio = d->hwirq; 234 unsigned gpio = d->hwirq;
233 bool level_triggered = false; 235 bool level_triggered = false;
234 bool dual_edge = false; 236 bool dual_edge = false;
@@ -263,10 +265,10 @@ static int cygnus_gpio_irq_set_type(struct irq_data *d, unsigned int type)
263 } 265 }
264 266
265 spin_lock_irqsave(&chip->lock, flags); 267 spin_lock_irqsave(&chip->lock, flags);
266 cygnus_set_bit(chip, CYGNUS_GPIO_INT_TYPE_OFFSET, gpio, 268 iproc_set_bit(chip, IPROC_GPIO_INT_TYPE_OFFSET, gpio,
267 level_triggered); 269 level_triggered);
268 cygnus_set_bit(chip, CYGNUS_GPIO_INT_DE_OFFSET, gpio, dual_edge); 270 iproc_set_bit(chip, IPROC_GPIO_INT_DE_OFFSET, gpio, dual_edge);
269 cygnus_set_bit(chip, CYGNUS_GPIO_INT_EDGE_OFFSET, gpio, 271 iproc_set_bit(chip, IPROC_GPIO_INT_EDGE_OFFSET, gpio,
270 rising_or_high); 272 rising_or_high);
271 spin_unlock_irqrestore(&chip->lock, flags); 273 spin_unlock_irqrestore(&chip->lock, flags);
272 274
@@ -277,32 +279,32 @@ static int cygnus_gpio_irq_set_type(struct irq_data *d, unsigned int type)
277 return 0; 279 return 0;
278} 280}
279 281
280static struct irq_chip cygnus_gpio_irq_chip = { 282static struct irq_chip iproc_gpio_irq_chip = {
281 .name = "bcm-cygnus-gpio", 283 .name = "bcm-iproc-gpio",
282 .irq_ack = cygnus_gpio_irq_ack, 284 .irq_ack = iproc_gpio_irq_ack,
283 .irq_mask = cygnus_gpio_irq_mask, 285 .irq_mask = iproc_gpio_irq_mask,
284 .irq_unmask = cygnus_gpio_irq_unmask, 286 .irq_unmask = iproc_gpio_irq_unmask,
285 .irq_set_type = cygnus_gpio_irq_set_type, 287 .irq_set_type = iproc_gpio_irq_set_type,
286}; 288};
287 289
288/* 290/*
289 * Request the Cygnus IOMUX pinmux controller to mux individual pins to GPIO 291 * Request the Iproc IOMUX pinmux controller to mux individual pins to GPIO
290 */ 292 */
291static int cygnus_gpio_request(struct gpio_chip *gc, unsigned offset) 293static int iproc_gpio_request(struct gpio_chip *gc, unsigned offset)
292{ 294{
293 struct cygnus_gpio *chip = to_cygnus_gpio(gc); 295 struct iproc_gpio *chip = to_iproc_gpio(gc);
294 unsigned gpio = gc->base + offset; 296 unsigned gpio = gc->base + offset;
295 297
296 /* not all Cygnus GPIO pins can be muxed individually */ 298 /* not all Iproc GPIO pins can be muxed individually */
297 if (!chip->pinmux_is_supported) 299 if (!chip->pinmux_is_supported)
298 return 0; 300 return 0;
299 301
300 return pinctrl_request_gpio(gpio); 302 return pinctrl_request_gpio(gpio);
301} 303}
302 304
303static void cygnus_gpio_free(struct gpio_chip *gc, unsigned offset) 305static void iproc_gpio_free(struct gpio_chip *gc, unsigned offset)
304{ 306{
305 struct cygnus_gpio *chip = to_cygnus_gpio(gc); 307 struct iproc_gpio *chip = to_iproc_gpio(gc);
306 unsigned gpio = gc->base + offset; 308 unsigned gpio = gc->base + offset;
307 309
308 if (!chip->pinmux_is_supported) 310 if (!chip->pinmux_is_supported)
@@ -311,13 +313,13 @@ static void cygnus_gpio_free(struct gpio_chip *gc, unsigned offset)
311 pinctrl_free_gpio(gpio); 313 pinctrl_free_gpio(gpio);
312} 314}
313 315
314static int cygnus_gpio_direction_input(struct gpio_chip *gc, unsigned gpio) 316static int iproc_gpio_direction_input(struct gpio_chip *gc, unsigned gpio)
315{ 317{
316 struct cygnus_gpio *chip = to_cygnus_gpio(gc); 318 struct iproc_gpio *chip = to_iproc_gpio(gc);
317 unsigned long flags; 319 unsigned long flags;
318 320
319 spin_lock_irqsave(&chip->lock, flags); 321 spin_lock_irqsave(&chip->lock, flags);
320 cygnus_set_bit(chip, CYGNUS_GPIO_OUT_EN_OFFSET, gpio, false); 322 iproc_set_bit(chip, IPROC_GPIO_OUT_EN_OFFSET, gpio, false);
321 spin_unlock_irqrestore(&chip->lock, flags); 323 spin_unlock_irqrestore(&chip->lock, flags);
322 324
323 dev_dbg(chip->dev, "gpio:%u set input\n", gpio); 325 dev_dbg(chip->dev, "gpio:%u set input\n", gpio);
@@ -325,15 +327,15 @@ static int cygnus_gpio_direction_input(struct gpio_chip *gc, unsigned gpio)
325 return 0; 327 return 0;
326} 328}
327 329
328static int cygnus_gpio_direction_output(struct gpio_chip *gc, unsigned gpio, 330static int iproc_gpio_direction_output(struct gpio_chip *gc, unsigned gpio,
329 int val) 331 int val)
330{ 332{
331 struct cygnus_gpio *chip = to_cygnus_gpio(gc); 333 struct iproc_gpio *chip = to_iproc_gpio(gc);
332 unsigned long flags; 334 unsigned long flags;
333 335
334 spin_lock_irqsave(&chip->lock, flags); 336 spin_lock_irqsave(&chip->lock, flags);
335 cygnus_set_bit(chip, CYGNUS_GPIO_OUT_EN_OFFSET, gpio, true); 337 iproc_set_bit(chip, IPROC_GPIO_OUT_EN_OFFSET, gpio, true);
336 cygnus_set_bit(chip, CYGNUS_GPIO_DATA_OUT_OFFSET, gpio, !!(val)); 338 iproc_set_bit(chip, IPROC_GPIO_DATA_OUT_OFFSET, gpio, !!(val));
337 spin_unlock_irqrestore(&chip->lock, flags); 339 spin_unlock_irqrestore(&chip->lock, flags);
338 340
339 dev_dbg(chip->dev, "gpio:%u set output, value:%d\n", gpio, val); 341 dev_dbg(chip->dev, "gpio:%u set output, value:%d\n", gpio, val);
@@ -341,29 +343,29 @@ static int cygnus_gpio_direction_output(struct gpio_chip *gc, unsigned gpio,
341 return 0; 343 return 0;
342} 344}
343 345
344static void cygnus_gpio_set(struct gpio_chip *gc, unsigned gpio, int val) 346static void iproc_gpio_set(struct gpio_chip *gc, unsigned gpio, int val)
345{ 347{
346 struct cygnus_gpio *chip = to_cygnus_gpio(gc); 348 struct iproc_gpio *chip = to_iproc_gpio(gc);
347 unsigned long flags; 349 unsigned long flags;
348 350
349 spin_lock_irqsave(&chip->lock, flags); 351 spin_lock_irqsave(&chip->lock, flags);
350 cygnus_set_bit(chip, CYGNUS_GPIO_DATA_OUT_OFFSET, gpio, !!(val)); 352 iproc_set_bit(chip, IPROC_GPIO_DATA_OUT_OFFSET, gpio, !!(val));
351 spin_unlock_irqrestore(&chip->lock, flags); 353 spin_unlock_irqrestore(&chip->lock, flags);
352 354
353 dev_dbg(chip->dev, "gpio:%u set, value:%d\n", gpio, val); 355 dev_dbg(chip->dev, "gpio:%u set, value:%d\n", gpio, val);
354} 356}
355 357
356static int cygnus_gpio_get(struct gpio_chip *gc, unsigned gpio) 358static int iproc_gpio_get(struct gpio_chip *gc, unsigned gpio)
357{ 359{
358 struct cygnus_gpio *chip = to_cygnus_gpio(gc); 360 struct iproc_gpio *chip = to_iproc_gpio(gc);
359 unsigned int offset = CYGNUS_GPIO_REG(gpio, 361 unsigned int offset = IPROC_GPIO_REG(gpio,
360 CYGNUS_GPIO_DATA_IN_OFFSET); 362 IPROC_GPIO_DATA_IN_OFFSET);
361 unsigned int shift = CYGNUS_GPIO_SHIFT(gpio); 363 unsigned int shift = IPROC_GPIO_SHIFT(gpio);
362 364
363 return !!(readl(chip->base + offset) & BIT(shift)); 365 return !!(readl(chip->base + offset) & BIT(shift));
364} 366}
365 367
366static int cygnus_get_groups_count(struct pinctrl_dev *pctldev) 368static int iproc_get_groups_count(struct pinctrl_dev *pctldev)
367{ 369{
368 return 1; 370 return 1;
369} 371}
@@ -372,20 +374,20 @@ static int cygnus_get_groups_count(struct pinctrl_dev *pctldev)
372 * Only one group: "gpio_grp", since this local pinctrl device only performs 374 * Only one group: "gpio_grp", since this local pinctrl device only performs
373 * GPIO specific PINCONF configurations 375 * GPIO specific PINCONF configurations
374 */ 376 */
375static const char *cygnus_get_group_name(struct pinctrl_dev *pctldev, 377static const char *iproc_get_group_name(struct pinctrl_dev *pctldev,
376 unsigned selector) 378 unsigned selector)
377{ 379{
378 return "gpio_grp"; 380 return "gpio_grp";
379} 381}
380 382
381static const struct pinctrl_ops cygnus_pctrl_ops = { 383static const struct pinctrl_ops iproc_pctrl_ops = {
382 .get_groups_count = cygnus_get_groups_count, 384 .get_groups_count = iproc_get_groups_count,
383 .get_group_name = cygnus_get_group_name, 385 .get_group_name = iproc_get_group_name,
384 .dt_node_to_map = pinconf_generic_dt_node_to_map_pin, 386 .dt_node_to_map = pinconf_generic_dt_node_to_map_pin,
385 .dt_free_map = pinctrl_utils_dt_free_map, 387 .dt_free_map = pinctrl_utils_dt_free_map,
386}; 388};
387 389
388static int cygnus_gpio_set_pull(struct cygnus_gpio *chip, unsigned gpio, 390static int iproc_gpio_set_pull(struct iproc_gpio *chip, unsigned gpio,
389 bool disable, bool pull_up) 391 bool disable, bool pull_up)
390{ 392{
391 unsigned long flags; 393 unsigned long flags;
@@ -393,11 +395,11 @@ static int cygnus_gpio_set_pull(struct cygnus_gpio *chip, unsigned gpio,
393 spin_lock_irqsave(&chip->lock, flags); 395 spin_lock_irqsave(&chip->lock, flags);
394 396
395 if (disable) { 397 if (disable) {
396 cygnus_set_bit(chip, CYGNUS_GPIO_RES_EN_OFFSET, gpio, false); 398 iproc_set_bit(chip, IPROC_GPIO_RES_EN_OFFSET, gpio, false);
397 } else { 399 } else {
398 cygnus_set_bit(chip, CYGNUS_GPIO_PAD_RES_OFFSET, gpio, 400 iproc_set_bit(chip, IPROC_GPIO_PAD_RES_OFFSET, gpio,
399 pull_up); 401 pull_up);
400 cygnus_set_bit(chip, CYGNUS_GPIO_RES_EN_OFFSET, gpio, true); 402 iproc_set_bit(chip, IPROC_GPIO_RES_EN_OFFSET, gpio, true);
401 } 403 }
402 404
403 spin_unlock_irqrestore(&chip->lock, flags); 405 spin_unlock_irqrestore(&chip->lock, flags);
@@ -407,18 +409,18 @@ static int cygnus_gpio_set_pull(struct cygnus_gpio *chip, unsigned gpio,
407 return 0; 409 return 0;
408} 410}
409 411
410static void cygnus_gpio_get_pull(struct cygnus_gpio *chip, unsigned gpio, 412static void iproc_gpio_get_pull(struct iproc_gpio *chip, unsigned gpio,
411 bool *disable, bool *pull_up) 413 bool *disable, bool *pull_up)
412{ 414{
413 unsigned long flags; 415 unsigned long flags;
414 416
415 spin_lock_irqsave(&chip->lock, flags); 417 spin_lock_irqsave(&chip->lock, flags);
416 *disable = !cygnus_get_bit(chip, CYGNUS_GPIO_RES_EN_OFFSET, gpio); 418 *disable = !iproc_get_bit(chip, IPROC_GPIO_RES_EN_OFFSET, gpio);
417 *pull_up = cygnus_get_bit(chip, CYGNUS_GPIO_PAD_RES_OFFSET, gpio); 419 *pull_up = iproc_get_bit(chip, IPROC_GPIO_PAD_RES_OFFSET, gpio);
418 spin_unlock_irqrestore(&chip->lock, flags); 420 spin_unlock_irqrestore(&chip->lock, flags);
419} 421}
420 422
421static int cygnus_gpio_set_strength(struct cygnus_gpio *chip, unsigned gpio, 423static int iproc_gpio_set_strength(struct iproc_gpio *chip, unsigned gpio,
422 unsigned strength) 424 unsigned strength)
423{ 425{
424 void __iomem *base; 426 void __iomem *base;
@@ -432,14 +434,14 @@ static int cygnus_gpio_set_strength(struct cygnus_gpio *chip, unsigned gpio,
432 434
433 if (chip->io_ctrl) { 435 if (chip->io_ctrl) {
434 base = chip->io_ctrl; 436 base = chip->io_ctrl;
435 offset = CYGNUS_GPIO_DRV0_CTRL_OFFSET; 437 offset = IPROC_GPIO_DRV0_CTRL_OFFSET;
436 } else { 438 } else {
437 base = chip->base; 439 base = chip->base;
438 offset = CYGNUS_GPIO_REG(gpio, 440 offset = IPROC_GPIO_REG(gpio,
439 CYGNUS_GPIO_ASIU_DRV0_CTRL_OFFSET); 441 IPROC_GPIO_ASIU_DRV0_CTRL_OFFSET);
440 } 442 }
441 443
442 shift = CYGNUS_GPIO_SHIFT(gpio); 444 shift = IPROC_GPIO_SHIFT(gpio);
443 445
444 dev_dbg(chip->dev, "gpio:%u set drive strength:%d mA\n", gpio, 446 dev_dbg(chip->dev, "gpio:%u set drive strength:%d mA\n", gpio,
445 strength); 447 strength);
@@ -458,7 +460,7 @@ static int cygnus_gpio_set_strength(struct cygnus_gpio *chip, unsigned gpio,
458 return 0; 460 return 0;
459} 461}
460 462
461static int cygnus_gpio_get_strength(struct cygnus_gpio *chip, unsigned gpio, 463static int iproc_gpio_get_strength(struct iproc_gpio *chip, unsigned gpio,
462 u16 *strength) 464 u16 *strength)
463{ 465{
464 void __iomem *base; 466 void __iomem *base;
@@ -468,14 +470,14 @@ static int cygnus_gpio_get_strength(struct cygnus_gpio *chip, unsigned gpio,
468 470
469 if (chip->io_ctrl) { 471 if (chip->io_ctrl) {
470 base = chip->io_ctrl; 472 base = chip->io_ctrl;
471 offset = CYGNUS_GPIO_DRV0_CTRL_OFFSET; 473 offset = IPROC_GPIO_DRV0_CTRL_OFFSET;
472 } else { 474 } else {
473 base = chip->base; 475 base = chip->base;
474 offset = CYGNUS_GPIO_REG(gpio, 476 offset = IPROC_GPIO_REG(gpio,
475 CYGNUS_GPIO_ASIU_DRV0_CTRL_OFFSET); 477 IPROC_GPIO_ASIU_DRV0_CTRL_OFFSET);
476 } 478 }
477 479
478 shift = CYGNUS_GPIO_SHIFT(gpio); 480 shift = IPROC_GPIO_SHIFT(gpio);
479 481
480 spin_lock_irqsave(&chip->lock, flags); 482 spin_lock_irqsave(&chip->lock, flags);
481 *strength = 0; 483 *strength = 0;
@@ -493,40 +495,40 @@ static int cygnus_gpio_get_strength(struct cygnus_gpio *chip, unsigned gpio,
493 return 0; 495 return 0;
494} 496}
495 497
496static int cygnus_pin_config_get(struct pinctrl_dev *pctldev, unsigned pin, 498static int iproc_pin_config_get(struct pinctrl_dev *pctldev, unsigned pin,
497 unsigned long *config) 499 unsigned long *config)
498{ 500{
499 struct cygnus_gpio *chip = pinctrl_dev_get_drvdata(pctldev); 501 struct iproc_gpio *chip = pinctrl_dev_get_drvdata(pctldev);
500 enum pin_config_param param = pinconf_to_config_param(*config); 502 enum pin_config_param param = pinconf_to_config_param(*config);
501 unsigned gpio = cygnus_pin_to_gpio(pin); 503 unsigned gpio = iproc_pin_to_gpio(pin);
502 u16 arg; 504 u16 arg;
503 bool disable, pull_up; 505 bool disable, pull_up;
504 int ret; 506 int ret;
505 507
506 switch (param) { 508 switch (param) {
507 case PIN_CONFIG_BIAS_DISABLE: 509 case PIN_CONFIG_BIAS_DISABLE:
508 cygnus_gpio_get_pull(chip, gpio, &disable, &pull_up); 510 iproc_gpio_get_pull(chip, gpio, &disable, &pull_up);
509 if (disable) 511 if (disable)
510 return 0; 512 return 0;
511 else 513 else
512 return -EINVAL; 514 return -EINVAL;
513 515
514 case PIN_CONFIG_BIAS_PULL_UP: 516 case PIN_CONFIG_BIAS_PULL_UP:
515 cygnus_gpio_get_pull(chip, gpio, &disable, &pull_up); 517 iproc_gpio_get_pull(chip, gpio, &disable, &pull_up);
516 if (!disable && pull_up) 518 if (!disable && pull_up)
517 return 0; 519 return 0;
518 else 520 else
519 return -EINVAL; 521 return -EINVAL;
520 522
521 case PIN_CONFIG_BIAS_PULL_DOWN: 523 case PIN_CONFIG_BIAS_PULL_DOWN:
522 cygnus_gpio_get_pull(chip, gpio, &disable, &pull_up); 524 iproc_gpio_get_pull(chip, gpio, &disable, &pull_up);
523 if (!disable && !pull_up) 525 if (!disable && !pull_up)
524 return 0; 526 return 0;
525 else 527 else
526 return -EINVAL; 528 return -EINVAL;
527 529
528 case PIN_CONFIG_DRIVE_STRENGTH: 530 case PIN_CONFIG_DRIVE_STRENGTH:
529 ret = cygnus_gpio_get_strength(chip, gpio, &arg); 531 ret = iproc_gpio_get_strength(chip, gpio, &arg);
530 if (ret) 532 if (ret)
531 return ret; 533 return ret;
532 else 534 else
@@ -541,13 +543,13 @@ static int cygnus_pin_config_get(struct pinctrl_dev *pctldev, unsigned pin,
541 return -ENOTSUPP; 543 return -ENOTSUPP;
542} 544}
543 545
544static int cygnus_pin_config_set(struct pinctrl_dev *pctldev, unsigned pin, 546static int iproc_pin_config_set(struct pinctrl_dev *pctldev, unsigned pin,
545 unsigned long *configs, unsigned num_configs) 547 unsigned long *configs, unsigned num_configs)
546{ 548{
547 struct cygnus_gpio *chip = pinctrl_dev_get_drvdata(pctldev); 549 struct iproc_gpio *chip = pinctrl_dev_get_drvdata(pctldev);
548 enum pin_config_param param; 550 enum pin_config_param param;
549 u16 arg; 551 u16 arg;
550 unsigned i, gpio = cygnus_pin_to_gpio(pin); 552 unsigned i, gpio = iproc_pin_to_gpio(pin);
551 int ret = -ENOTSUPP; 553 int ret = -ENOTSUPP;
552 554
553 for (i = 0; i < num_configs; i++) { 555 for (i = 0; i < num_configs; i++) {
@@ -556,25 +558,25 @@ static int cygnus_pin_config_set(struct pinctrl_dev *pctldev, unsigned pin,
556 558
557 switch (param) { 559 switch (param) {
558 case PIN_CONFIG_BIAS_DISABLE: 560 case PIN_CONFIG_BIAS_DISABLE:
559 ret = cygnus_gpio_set_pull(chip, gpio, true, false); 561 ret = iproc_gpio_set_pull(chip, gpio, true, false);
560 if (ret < 0) 562 if (ret < 0)
561 goto out; 563 goto out;
562 break; 564 break;
563 565
564 case PIN_CONFIG_BIAS_PULL_UP: 566 case PIN_CONFIG_BIAS_PULL_UP:
565 ret = cygnus_gpio_set_pull(chip, gpio, false, true); 567 ret = iproc_gpio_set_pull(chip, gpio, false, true);
566 if (ret < 0) 568 if (ret < 0)
567 goto out; 569 goto out;
568 break; 570 break;
569 571
570 case PIN_CONFIG_BIAS_PULL_DOWN: 572 case PIN_CONFIG_BIAS_PULL_DOWN:
571 ret = cygnus_gpio_set_pull(chip, gpio, false, false); 573 ret = iproc_gpio_set_pull(chip, gpio, false, false);
572 if (ret < 0) 574 if (ret < 0)
573 goto out; 575 goto out;
574 break; 576 break;
575 577
576 case PIN_CONFIG_DRIVE_STRENGTH: 578 case PIN_CONFIG_DRIVE_STRENGTH:
577 ret = cygnus_gpio_set_strength(chip, gpio, arg); 579 ret = iproc_gpio_set_strength(chip, gpio, arg);
578 if (ret < 0) 580 if (ret < 0)
579 goto out; 581 goto out;
580 break; 582 break;
@@ -589,20 +591,20 @@ out:
589 return ret; 591 return ret;
590} 592}
591 593
592static const struct pinconf_ops cygnus_pconf_ops = { 594static const struct pinconf_ops iproc_pconf_ops = {
593 .is_generic = true, 595 .is_generic = true,
594 .pin_config_get = cygnus_pin_config_get, 596 .pin_config_get = iproc_pin_config_get,
595 .pin_config_set = cygnus_pin_config_set, 597 .pin_config_set = iproc_pin_config_set,
596}; 598};
597 599
598/* 600/*
599 * Cygnus GPIO controller supports some PINCONF related configurations such as 601 * Iproc GPIO controller supports some PINCONF related configurations such as
600 * pull up, pull down, and drive strength, when the pin is configured to GPIO 602 * pull up, pull down, and drive strength, when the pin is configured to GPIO
601 * 603 *
602 * Here a local pinctrl device is created with simple 1-to-1 pin mapping to the 604 * Here a local pinctrl device is created with simple 1-to-1 pin mapping to the
603 * local GPIO pins 605 * local GPIO pins
604 */ 606 */
605static int cygnus_gpio_register_pinconf(struct cygnus_gpio *chip) 607static int iproc_gpio_register_pinconf(struct iproc_gpio *chip)
606{ 608{
607 struct pinctrl_desc *pctldesc = &chip->pctldesc; 609 struct pinctrl_desc *pctldesc = &chip->pctldesc;
608 struct pinctrl_pin_desc *pins; 610 struct pinctrl_pin_desc *pins;
@@ -622,10 +624,10 @@ static int cygnus_gpio_register_pinconf(struct cygnus_gpio *chip)
622 } 624 }
623 625
624 pctldesc->name = dev_name(chip->dev); 626 pctldesc->name = dev_name(chip->dev);
625 pctldesc->pctlops = &cygnus_pctrl_ops; 627 pctldesc->pctlops = &iproc_pctrl_ops;
626 pctldesc->pins = pins; 628 pctldesc->pins = pins;
627 pctldesc->npins = gc->ngpio; 629 pctldesc->npins = gc->ngpio;
628 pctldesc->confops = &cygnus_pconf_ops; 630 pctldesc->confops = &iproc_pconf_ops;
629 631
630 chip->pctl = pinctrl_register(pctldesc, chip->dev, chip); 632 chip->pctl = pinctrl_register(pctldesc, chip->dev, chip);
631 if (IS_ERR(chip->pctl)) { 633 if (IS_ERR(chip->pctl)) {
@@ -636,12 +638,12 @@ static int cygnus_gpio_register_pinconf(struct cygnus_gpio *chip)
636 return 0; 638 return 0;
637} 639}
638 640
639static void cygnus_gpio_unregister_pinconf(struct cygnus_gpio *chip) 641static void iproc_gpio_unregister_pinconf(struct cygnus_gpio *chip)
640{ 642{
641 pinctrl_unregister(chip->pctl); 643 pinctrl_unregister(chip->pctl);
642} 644}
643 645
644static const struct of_device_id cygnus_gpio_of_match[] = { 646static const struct of_device_id iproc_gpio_of_match[] = {
645 { .compatible = "brcm,cygnus-ccm-gpio" }, 647 { .compatible = "brcm,cygnus-ccm-gpio" },
646 { .compatible = "brcm,cygnus-asiu-gpio" }, 648 { .compatible = "brcm,cygnus-asiu-gpio" },
647 { .compatible = "brcm,cygnus-crmu-gpio" }, 649 { .compatible = "brcm,cygnus-crmu-gpio" },
@@ -649,11 +651,11 @@ static const struct of_device_id cygnus_gpio_of_match[] = {
649 { } 651 { }
650}; 652};
651 653
652static int cygnus_gpio_probe(struct platform_device *pdev) 654static int iproc_gpio_probe(struct platform_device *pdev)
653{ 655{
654 struct device *dev = &pdev->dev; 656 struct device *dev = &pdev->dev;
655 struct resource *res; 657 struct resource *res;
656 struct cygnus_gpio *chip; 658 struct iproc_gpio *chip;
657 struct gpio_chip *gc; 659 struct gpio_chip *gc;
658 u32 ngpios; 660 u32 ngpios;
659 int irq, ret; 661 int irq, ret;
@@ -695,12 +697,12 @@ static int cygnus_gpio_probe(struct platform_device *pdev)
695 gc->label = dev_name(dev); 697 gc->label = dev_name(dev);
696 gc->dev = dev; 698 gc->dev = dev;
697 gc->of_node = dev->of_node; 699 gc->of_node = dev->of_node;
698 gc->request = cygnus_gpio_request; 700 gc->request = iproc_gpio_request;
699 gc->free = cygnus_gpio_free; 701 gc->free = iproc_gpio_free;
700 gc->direction_input = cygnus_gpio_direction_input; 702 gc->direction_input = iproc_gpio_direction_input;
701 gc->direction_output = cygnus_gpio_direction_output; 703 gc->direction_output = iproc_gpio_direction_output;
702 gc->set = cygnus_gpio_set; 704 gc->set = iproc_gpio_set;
703 gc->get = cygnus_gpio_get; 705 gc->get = iproc_gpio_get;
704 706
705 chip->pinmux_is_supported = of_property_read_bool(dev->of_node, 707 chip->pinmux_is_supported = of_property_read_bool(dev->of_node,
706 "gpio-ranges"); 708 "gpio-ranges");
@@ -711,7 +713,7 @@ static int cygnus_gpio_probe(struct platform_device *pdev)
711 return ret; 713 return ret;
712 } 714 }
713 715
714 ret = cygnus_gpio_register_pinconf(chip); 716 ret = iproc_gpio_register_pinconf(chip);
715 if (ret) { 717 if (ret) {
716 dev_err(dev, "unable to register pinconf\n"); 718 dev_err(dev, "unable to register pinconf\n");
717 goto err_rm_gpiochip; 719 goto err_rm_gpiochip;
@@ -720,21 +722,21 @@ static int cygnus_gpio_probe(struct platform_device *pdev)
720 /* optional GPIO interrupt support */ 722 /* optional GPIO interrupt support */
721 irq = platform_get_irq(pdev, 0); 723 irq = platform_get_irq(pdev, 0);
722 if (irq) { 724 if (irq) {
723 ret = gpiochip_irqchip_add(gc, &cygnus_gpio_irq_chip, 0, 725 ret = gpiochip_irqchip_add(gc, &iproc_gpio_irq_chip, 0,
724 handle_simple_irq, IRQ_TYPE_NONE); 726 handle_simple_irq, IRQ_TYPE_NONE);
725 if (ret) { 727 if (ret) {
726 dev_err(dev, "no GPIO irqchip\n"); 728 dev_err(dev, "no GPIO irqchip\n");
727 goto err_unregister_pinconf; 729 goto err_unregister_pinconf;
728 } 730 }
729 731
730 gpiochip_set_chained_irqchip(gc, &cygnus_gpio_irq_chip, irq, 732 gpiochip_set_chained_irqchip(gc, &iproc_gpio_irq_chip, irq,
731 cygnus_gpio_irq_handler); 733 iproc_gpio_irq_handler);
732 } 734 }
733 735
734 return 0; 736 return 0;
735 737
736err_unregister_pinconf: 738err_unregister_pinconf:
737 cygnus_gpio_unregister_pinconf(chip); 739 iproc_gpio_unregister_pinconf(chip);
738 740
739err_rm_gpiochip: 741err_rm_gpiochip:
740 gpiochip_remove(gc); 742 gpiochip_remove(gc);
@@ -742,16 +744,16 @@ err_rm_gpiochip:
742 return ret; 744 return ret;
743} 745}
744 746
745static struct platform_driver cygnus_gpio_driver = { 747static struct platform_driver iproc_gpio_driver = {
746 .driver = { 748 .driver = {
747 .name = "cygnus-gpio", 749 .name = "iproc-gpio",
748 .of_match_table = cygnus_gpio_of_match, 750 .of_match_table = iproc_gpio_of_match,
749 }, 751 },
750 .probe = cygnus_gpio_probe, 752 .probe = iproc_gpio_probe,
751}; 753};
752 754
753static int __init cygnus_gpio_init(void) 755static int __init iproc_gpio_init(void)
754{ 756{
755 return platform_driver_probe(&cygnus_gpio_driver, cygnus_gpio_probe); 757 return platform_driver_probe(&iproc_gpio_driver, iproc_gpio_probe);
756} 758}
757arch_initcall_sync(cygnus_gpio_init); 759arch_initcall_sync(iproc_gpio_init);