• Home
  • Raw
  • Download

Lines Matching +full:msc313 +full:- +full:gpio

1 // SPDX-License-Identifier: GPL-2.0
10 #include <linux/gpio/driver.h>
14 #include <dt-bindings/gpio/msc313-gpio.h>
15 #include <dt-bindings/interrupt-controller/arm-gic.h>
17 #define DRIVER_NAME "gpio-msc313"
25 * gpio state when resuming from suspend to memory.
222 MSC313_GPIO_CHIPDATA(msc313);
225 * Unlike the msc313(e) the ssd20xd have a bunch of pins
226 * that are actually called gpio probably because they
445 * of the registers that control the gpio.
490 struct msc313_gpio *gpio = gpiochip_get_data(chip); in msc313_gpio_set() local
491 u8 gpioreg = readb_relaxed(gpio->base + gpio->gpio_data->offsets[offset]); in msc313_gpio_set()
498 writeb_relaxed(gpioreg, gpio->base + gpio->gpio_data->offsets[offset]); in msc313_gpio_set()
503 struct msc313_gpio *gpio = gpiochip_get_data(chip); in msc313_gpio_get() local
505 return readb_relaxed(gpio->base + gpio->gpio_data->offsets[offset]) & MSC313_GPIO_IN; in msc313_gpio_get()
510 struct msc313_gpio *gpio = gpiochip_get_data(chip); in msc313_gpio_direction_input() local
511 u8 gpioreg = readb_relaxed(gpio->base + gpio->gpio_data->offsets[offset]); in msc313_gpio_direction_input()
514 writeb_relaxed(gpioreg, gpio->base + gpio->gpio_data->offsets[offset]); in msc313_gpio_direction_input()
521 struct msc313_gpio *gpio = gpiochip_get_data(chip); in msc313_gpio_direction_output() local
522 u8 gpioreg = readb_relaxed(gpio->base + gpio->gpio_data->offsets[offset]); in msc313_gpio_direction_output()
529 writeb_relaxed(gpioreg, gpio->base + gpio->gpio_data->offsets[offset]); in msc313_gpio_direction_output()
539 gpiochip_disable_irq(gc, d->hwirq); in msc313_gpio_irq_mask()
546 gpiochip_enable_irq(gc, d->hwirq); in msc313_gpio_irq_unmask()
555 .name = "GPIO",
575 struct irq_fwspec *fwspec = &gfwspec->fwspec; in msc313_gpio_populate_parent_fwspec()
577 fwspec->fwnode = gc->irq.parent_domain->fwnode; in msc313_gpio_populate_parent_fwspec()
578 fwspec->param_count = 3; in msc313_gpio_populate_parent_fwspec()
579 fwspec->param[0] = GIC_SPI; in msc313_gpio_populate_parent_fwspec()
580 fwspec->param[1] = parent_hwirq; in msc313_gpio_populate_parent_fwspec()
581 fwspec->param[2] = parent_type; in msc313_gpio_populate_parent_fwspec()
593 unsigned int offset = priv->gpio_data->offsets[child]; in msc313e_gpio_child_to_parent_hwirq()
602 *parent = ((offset - OFF_SPI0_CZ) >> 2) + 28; in msc313e_gpio_child_to_parent_hwirq()
606 return -EINVAL; in msc313e_gpio_child_to_parent_hwirq()
612 struct msc313_gpio *gpio; in msc313_gpio_probe() local
617 struct device *dev = &pdev->dev; in msc313_gpio_probe()
621 return -EINVAL; in msc313_gpio_probe()
623 parent_node = of_irq_find_parent(dev->of_node); in msc313_gpio_probe()
625 return -ENODEV; in msc313_gpio_probe()
629 return -ENODEV; in msc313_gpio_probe()
631 gpio = devm_kzalloc(dev, sizeof(*gpio), GFP_KERNEL); in msc313_gpio_probe()
632 if (!gpio) in msc313_gpio_probe()
633 return -ENOMEM; in msc313_gpio_probe()
635 gpio->gpio_data = match_data; in msc313_gpio_probe()
637 gpio->saved = devm_kcalloc(dev, gpio->gpio_data->num, sizeof(*gpio->saved), GFP_KERNEL); in msc313_gpio_probe()
638 if (!gpio->saved) in msc313_gpio_probe()
639 return -ENOMEM; in msc313_gpio_probe()
641 gpio->base = devm_platform_ioremap_resource(pdev, 0); in msc313_gpio_probe()
642 if (IS_ERR(gpio->base)) in msc313_gpio_probe()
643 return PTR_ERR(gpio->base); in msc313_gpio_probe()
645 platform_set_drvdata(pdev, gpio); in msc313_gpio_probe()
649 return -ENOMEM; in msc313_gpio_probe()
651 gpiochip->label = DRIVER_NAME; in msc313_gpio_probe()
652 gpiochip->parent = dev; in msc313_gpio_probe()
653 gpiochip->request = gpiochip_generic_request; in msc313_gpio_probe()
654 gpiochip->free = gpiochip_generic_free; in msc313_gpio_probe()
655 gpiochip->direction_input = msc313_gpio_direction_input; in msc313_gpio_probe()
656 gpiochip->direction_output = msc313_gpio_direction_output; in msc313_gpio_probe()
657 gpiochip->get = msc313_gpio_get; in msc313_gpio_probe()
658 gpiochip->set = msc313_gpio_set; in msc313_gpio_probe()
659 gpiochip->base = -1; in msc313_gpio_probe()
660 gpiochip->ngpio = gpio->gpio_data->num; in msc313_gpio_probe()
661 gpiochip->names = gpio->gpio_data->names; in msc313_gpio_probe()
663 gpioirqchip = &gpiochip->irq; in msc313_gpio_probe()
665 gpioirqchip->fwnode = of_node_to_fwnode(dev->of_node); in msc313_gpio_probe()
666 gpioirqchip->parent_domain = parent_domain; in msc313_gpio_probe()
667 gpioirqchip->child_to_parent_hwirq = msc313e_gpio_child_to_parent_hwirq; in msc313_gpio_probe()
668 gpioirqchip->populate_parent_alloc_arg = msc313_gpio_populate_parent_fwspec; in msc313_gpio_probe()
669 gpioirqchip->handler = handle_bad_irq; in msc313_gpio_probe()
670 gpioirqchip->default_type = IRQ_TYPE_NONE; in msc313_gpio_probe()
672 return devm_gpiochip_add_data(dev, gpiochip, gpio); in msc313_gpio_probe()
678 .compatible = "mstar,msc313-gpio",
682 .compatible = "sstar,ssd20xd-gpio",
690 * The GPIO controller loses the state of the registers when the
696 struct msc313_gpio *gpio = dev_get_drvdata(dev); in msc313_gpio_suspend() local
699 for (i = 0; i < gpio->gpio_data->num; i++) in msc313_gpio_suspend()
700 gpio->saved[i] = readb_relaxed(gpio->base + gpio->gpio_data->offsets[i]) & MSC313_GPIO_BITSTOSAVE; in msc313_gpio_suspend()
707 struct msc313_gpio *gpio = dev_get_drvdata(dev); in msc313_gpio_resume() local
710 for (i = 0; i < gpio->gpio_data->num; i++) in msc313_gpio_resume()
711 writeb_relaxed(gpio->saved[i], gpio->base + gpio->gpio_data->offsets[i]); in msc313_gpio_resume()