gpio-iop.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * arch/arm/plat-iop/gpio.c
  3. * GPIO handling for Intel IOP3xx processors.
  4. *
  5. * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or (at
  10. * your option) any later version.
  11. */
  12. #include <linux/err.h>
  13. #include <linux/module.h>
  14. #include <linux/gpio/driver.h>
  15. #include <linux/platform_device.h>
  16. #define IOP3XX_GPOE 0x0000
  17. #define IOP3XX_GPID 0x0004
  18. #define IOP3XX_GPOD 0x0008
  19. static int iop3xx_gpio_probe(struct platform_device *pdev)
  20. {
  21. struct resource *res;
  22. struct gpio_chip *gc;
  23. void __iomem *base;
  24. int err;
  25. gc = devm_kzalloc(&pdev->dev, sizeof(*gc), GFP_KERNEL);
  26. if (!gc)
  27. return -ENOMEM;
  28. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  29. base = devm_ioremap_resource(&pdev->dev, res);
  30. if (IS_ERR(base))
  31. return PTR_ERR(base);
  32. err = bgpio_init(gc, &pdev->dev, 1, base + IOP3XX_GPID,
  33. base + IOP3XX_GPOD, NULL, NULL, base + IOP3XX_GPOE, 0);
  34. if (err)
  35. return err;
  36. gc->base = 0;
  37. gc->owner = THIS_MODULE;
  38. return devm_gpiochip_add_data(&pdev->dev, gc, NULL);
  39. }
  40. static struct platform_driver iop3xx_gpio_driver = {
  41. .driver = {
  42. .name = "gpio-iop",
  43. },
  44. .probe = iop3xx_gpio_probe,
  45. };
  46. static int __init iop3xx_gpio_init(void)
  47. {
  48. return platform_driver_register(&iop3xx_gpio_driver);
  49. }
  50. arch_initcall(iop3xx_gpio_init);
  51. MODULE_DESCRIPTION("GPIO handling for Intel IOP3xx processors");
  52. MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
  53. MODULE_LICENSE("GPL");