gpio-iop.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * arch/arm/plat-iop/gpio.c
  4. * GPIO handling for Intel IOP3xx processors.
  5. *
  6. * Copyright (C) 2006 Lennert Buytenhek <[email protected]>
  7. */
  8. #include <linux/err.h>
  9. #include <linux/module.h>
  10. #include <linux/gpio/driver.h>
  11. #include <linux/platform_device.h>
  12. #define IOP3XX_GPOE 0x0000
  13. #define IOP3XX_GPID 0x0004
  14. #define IOP3XX_GPOD 0x0008
  15. static int iop3xx_gpio_probe(struct platform_device *pdev)
  16. {
  17. struct gpio_chip *gc;
  18. void __iomem *base;
  19. int err;
  20. gc = devm_kzalloc(&pdev->dev, sizeof(*gc), GFP_KERNEL);
  21. if (!gc)
  22. return -ENOMEM;
  23. base = devm_platform_ioremap_resource(pdev, 0);
  24. if (IS_ERR(base))
  25. return PTR_ERR(base);
  26. err = bgpio_init(gc, &pdev->dev, 1, base + IOP3XX_GPID,
  27. base + IOP3XX_GPOD, NULL, NULL, base + IOP3XX_GPOE, 0);
  28. if (err)
  29. return err;
  30. gc->base = 0;
  31. gc->owner = THIS_MODULE;
  32. gc->label = "gpio-iop";
  33. return devm_gpiochip_add_data(&pdev->dev, gc, NULL);
  34. }
  35. static struct platform_driver iop3xx_gpio_driver = {
  36. .driver = {
  37. .name = "gpio-iop",
  38. },
  39. .probe = iop3xx_gpio_probe,
  40. };
  41. static int __init iop3xx_gpio_init(void)
  42. {
  43. return platform_driver_register(&iop3xx_gpio_driver);
  44. }
  45. arch_initcall(iop3xx_gpio_init);
  46. MODULE_DESCRIPTION("GPIO handling for Intel IOP3xx processors");
  47. MODULE_AUTHOR("Lennert Buytenhek <[email protected]>");
  48. MODULE_LICENSE("GPL");