• Home
  • Raw
  • Download

Lines Matching +full:chip +full:- +full:enable +full:- +full:gpios

1 // SPDX-License-Identifier: GPL-2.0-only
11 #include <linux/gpio/legacy-of-mm-gpiochip.h>
29 * GPIO LIB API implementation for wakeup GPIOs.
31 * There's a maximum of 8 wakeup GPIOs. Which of these are available
34 * 0 -> GPIO_WKUP_7
35 * 1 -> GPIO_WKUP_6
36 * 2 -> PSC6_1
37 * 3 -> PSC6_0
38 * 4 -> ETH_17
39 * 5 -> PSC3_9
40 * 6 -> PSC2_4
41 * 7 -> PSC1_4
47 struct mpc52xx_gpio_wkup __iomem *regs = mm_gc->regs; in mpc52xx_wkup_gpio_get()
50 ret = (in_8(&regs->wkup_ival) >> (7 - gpio)) & 1; in mpc52xx_wkup_gpio_get()
61 struct mpc52xx_gpiochip *chip = gpiochip_get_data(gc); in __mpc52xx_wkup_gpio_set() local
62 struct mpc52xx_gpio_wkup __iomem *regs = mm_gc->regs; in __mpc52xx_wkup_gpio_set()
65 chip->shadow_dvo |= 1 << (7 - gpio); in __mpc52xx_wkup_gpio_set()
67 chip->shadow_dvo &= ~(1 << (7 - gpio)); in __mpc52xx_wkup_gpio_set()
69 out_8(&regs->wkup_dvo, chip->shadow_dvo); in __mpc52xx_wkup_gpio_set()
89 struct mpc52xx_gpiochip *chip = gpiochip_get_data(gc); in mpc52xx_wkup_gpio_dir_in() local
90 struct mpc52xx_gpio_wkup __iomem *regs = mm_gc->regs; in mpc52xx_wkup_gpio_dir_in()
96 chip->shadow_ddr &= ~(1 << (7 - gpio)); in mpc52xx_wkup_gpio_dir_in()
97 out_8(&regs->wkup_ddr, chip->shadow_ddr); in mpc52xx_wkup_gpio_dir_in()
99 /* and enable the pin */ in mpc52xx_wkup_gpio_dir_in()
100 chip->shadow_gpioe |= 1 << (7 - gpio); in mpc52xx_wkup_gpio_dir_in()
101 out_8(&regs->wkup_gpioe, chip->shadow_gpioe); in mpc52xx_wkup_gpio_dir_in()
112 struct mpc52xx_gpio_wkup __iomem *regs = mm_gc->regs; in mpc52xx_wkup_gpio_dir_out()
113 struct mpc52xx_gpiochip *chip = gpiochip_get_data(gc); in mpc52xx_wkup_gpio_dir_out() local
121 chip->shadow_ddr |= 1 << (7 - gpio); in mpc52xx_wkup_gpio_dir_out()
122 out_8(&regs->wkup_ddr, chip->shadow_ddr); in mpc52xx_wkup_gpio_dir_out()
124 /* Finally enable the pin */ in mpc52xx_wkup_gpio_dir_out()
125 chip->shadow_gpioe |= 1 << (7 - gpio); in mpc52xx_wkup_gpio_dir_out()
126 out_8(&regs->wkup_gpioe, chip->shadow_gpioe); in mpc52xx_wkup_gpio_dir_out()
137 struct mpc52xx_gpiochip *chip; in mpc52xx_wkup_gpiochip_probe() local
142 chip = devm_kzalloc(&ofdev->dev, sizeof(*chip), GFP_KERNEL); in mpc52xx_wkup_gpiochip_probe()
143 if (!chip) in mpc52xx_wkup_gpiochip_probe()
144 return -ENOMEM; in mpc52xx_wkup_gpiochip_probe()
146 platform_set_drvdata(ofdev, chip); in mpc52xx_wkup_gpiochip_probe()
148 gc = &chip->mmchip.gc; in mpc52xx_wkup_gpiochip_probe()
150 gc->ngpio = 8; in mpc52xx_wkup_gpiochip_probe()
151 gc->direction_input = mpc52xx_wkup_gpio_dir_in; in mpc52xx_wkup_gpiochip_probe()
152 gc->direction_output = mpc52xx_wkup_gpio_dir_out; in mpc52xx_wkup_gpiochip_probe()
153 gc->get = mpc52xx_wkup_gpio_get; in mpc52xx_wkup_gpiochip_probe()
154 gc->set = mpc52xx_wkup_gpio_set; in mpc52xx_wkup_gpiochip_probe()
156 ret = of_mm_gpiochip_add_data(ofdev->dev.of_node, &chip->mmchip, chip); in mpc52xx_wkup_gpiochip_probe()
160 regs = chip->mmchip.regs; in mpc52xx_wkup_gpiochip_probe()
161 chip->shadow_gpioe = in_8(&regs->wkup_gpioe); in mpc52xx_wkup_gpiochip_probe()
162 chip->shadow_ddr = in_8(&regs->wkup_ddr); in mpc52xx_wkup_gpiochip_probe()
163 chip->shadow_dvo = in_8(&regs->wkup_dvo); in mpc52xx_wkup_gpiochip_probe()
170 struct mpc52xx_gpiochip *chip = platform_get_drvdata(ofdev); in mpc52xx_gpiochip_remove() local
172 of_mm_gpiochip_remove(&chip->mmchip); in mpc52xx_gpiochip_remove()
178 { .compatible = "fsl,mpc5200-gpio-wkup", },
184 .name = "mpc5200-gpio-wkup",
192 * GPIO LIB API implementation for simple GPIOs
194 * There's a maximum of 32 simple GPIOs. Which of these are available
211 struct mpc52xx_gpio __iomem *regs = mm_gc->regs; in mpc52xx_simple_gpio_get()
214 ret = (in_be32(&regs->simple_ival) >> (31 - gpio)) & 1; in mpc52xx_simple_gpio_get()
223 struct mpc52xx_gpiochip *chip = gpiochip_get_data(gc); in __mpc52xx_simple_gpio_set() local
224 struct mpc52xx_gpio __iomem *regs = mm_gc->regs; in __mpc52xx_simple_gpio_set()
227 chip->shadow_dvo |= 1 << (31 - gpio); in __mpc52xx_simple_gpio_set()
229 chip->shadow_dvo &= ~(1 << (31 - gpio)); in __mpc52xx_simple_gpio_set()
230 out_be32(&regs->simple_dvo, chip->shadow_dvo); in __mpc52xx_simple_gpio_set()
250 struct mpc52xx_gpiochip *chip = gpiochip_get_data(gc); in mpc52xx_simple_gpio_dir_in() local
251 struct mpc52xx_gpio __iomem *regs = mm_gc->regs; in mpc52xx_simple_gpio_dir_in()
257 chip->shadow_ddr &= ~(1 << (31 - gpio)); in mpc52xx_simple_gpio_dir_in()
258 out_be32(&regs->simple_ddr, chip->shadow_ddr); in mpc52xx_simple_gpio_dir_in()
260 /* and enable the pin */ in mpc52xx_simple_gpio_dir_in()
261 chip->shadow_gpioe |= 1 << (31 - gpio); in mpc52xx_simple_gpio_dir_in()
262 out_be32(&regs->simple_gpioe, chip->shadow_gpioe); in mpc52xx_simple_gpio_dir_in()
273 struct mpc52xx_gpiochip *chip = gpiochip_get_data(gc); in mpc52xx_simple_gpio_dir_out() local
274 struct mpc52xx_gpio __iomem *regs = mm_gc->regs; in mpc52xx_simple_gpio_dir_out()
283 chip->shadow_ddr |= 1 << (31 - gpio); in mpc52xx_simple_gpio_dir_out()
284 out_be32(&regs->simple_ddr, chip->shadow_ddr); in mpc52xx_simple_gpio_dir_out()
286 /* Finally enable the pin */ in mpc52xx_simple_gpio_dir_out()
287 chip->shadow_gpioe |= 1 << (31 - gpio); in mpc52xx_simple_gpio_dir_out()
288 out_be32(&regs->simple_gpioe, chip->shadow_gpioe); in mpc52xx_simple_gpio_dir_out()
299 struct mpc52xx_gpiochip *chip; in mpc52xx_simple_gpiochip_probe() local
304 chip = devm_kzalloc(&ofdev->dev, sizeof(*chip), GFP_KERNEL); in mpc52xx_simple_gpiochip_probe()
305 if (!chip) in mpc52xx_simple_gpiochip_probe()
306 return -ENOMEM; in mpc52xx_simple_gpiochip_probe()
308 platform_set_drvdata(ofdev, chip); in mpc52xx_simple_gpiochip_probe()
310 gc = &chip->mmchip.gc; in mpc52xx_simple_gpiochip_probe()
312 gc->ngpio = 32; in mpc52xx_simple_gpiochip_probe()
313 gc->direction_input = mpc52xx_simple_gpio_dir_in; in mpc52xx_simple_gpiochip_probe()
314 gc->direction_output = mpc52xx_simple_gpio_dir_out; in mpc52xx_simple_gpiochip_probe()
315 gc->get = mpc52xx_simple_gpio_get; in mpc52xx_simple_gpiochip_probe()
316 gc->set = mpc52xx_simple_gpio_set; in mpc52xx_simple_gpiochip_probe()
318 ret = of_mm_gpiochip_add_data(ofdev->dev.of_node, &chip->mmchip, chip); in mpc52xx_simple_gpiochip_probe()
322 regs = chip->mmchip.regs; in mpc52xx_simple_gpiochip_probe()
323 chip->shadow_gpioe = in_be32(&regs->simple_gpioe); in mpc52xx_simple_gpiochip_probe()
324 chip->shadow_ddr = in_be32(&regs->simple_ddr); in mpc52xx_simple_gpiochip_probe()
325 chip->shadow_dvo = in_be32(&regs->simple_dvo); in mpc52xx_simple_gpiochip_probe()
331 { .compatible = "fsl,mpc5200-gpio", },
337 .name = "mpc5200-gpio",