gpio-core.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* linux/arch/arm/plat-s3c/include/plat/gpio-core.h
  2. *
  3. * Copyright 2008 Simtec Electronics
  4. * http://armlinux.simtec.co.uk/
  5. * Ben Dooks <ben@simtec.co.uk>
  6. *
  7. * S3C Platform - GPIO core
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. /* Define the core gpiolib support functions that the s3c platforms may
  14. * need to extend or change depending on the hardware and the s3c chip
  15. * selected at build or found at run time.
  16. *
  17. * These definitions are not intended for driver inclusion, there is
  18. * nothing here that should not live outside the platform and core
  19. * specific code.
  20. */
  21. struct s3c_gpio_cfg;
  22. /**
  23. * struct s3c_gpio_chip - wrapper for specific implementation of gpio
  24. * @chip: The chip structure to be exported via gpiolib.
  25. * @base: The base pointer to the gpio configuration registers.
  26. * @config: special function and pull-resistor control information.
  27. *
  28. * This wrapper provides the necessary information for the Samsung
  29. * specific gpios being registered with gpiolib.
  30. */
  31. struct s3c_gpio_chip {
  32. struct gpio_chip chip;
  33. struct s3c_gpio_cfg *config;
  34. void __iomem *base;
  35. };
  36. static inline struct s3c_gpio_chip *to_s3c_gpio(struct gpio_chip *gpc)
  37. {
  38. return container_of(gpc, struct s3c_gpio_chip, chip);
  39. }
  40. /** s3c_gpiolib_add() - add the s3c specific version of a gpio_chip.
  41. * @chip: The chip to register
  42. *
  43. * This is a wrapper to gpiochip_add() that takes our specific gpio chip
  44. * information and makes the necessary alterations for the platform and
  45. * notes the information for use with the configuration systems and any
  46. * other parts of the system.
  47. */
  48. extern void s3c_gpiolib_add(struct s3c_gpio_chip *chip);
  49. /* CONFIG_S3C_GPIO_TRACK enables the tracking of the s3c specific gpios
  50. * for use with the configuration calls, and other parts of the s3c gpiolib
  51. * support code.
  52. *
  53. * Not all s3c support code will need this, as some configurations of cpu
  54. * may only support one or two different configuration options and have an
  55. * easy gpio to s3c_gpio_chip mapping function. If this is the case, then
  56. * the machine support file should provide its own s3c_gpiolib_getchip()
  57. * and any other necessary functions.
  58. */
  59. #ifdef CONFIG_S3C_GPIO_TRACK
  60. extern struct s3c_gpio_chip *s3c_gpios[S3C_GPIO_END];
  61. static inline struct s3c_gpio_chip *s3c_gpiolib_getchip(unsigned int chip)
  62. {
  63. return (chip < S3C_GPIO_END) ? s3c_gpios[chip] : NULL;
  64. }
  65. #else
  66. /* machine specific code should provide s3c_gpiolib_getchip */
  67. static inline void s3c_gpiolib_track(struct s3c_gpio_chip *chip) { }
  68. #endif