pinctrl-sprd.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Driver header file for pin controller driver
  3. * Copyright (C) 2017 Spreadtrum - http://www.spreadtrum.com
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * version 2 as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. */
  14. #ifndef __PINCTRL_SPRD_H__
  15. #define __PINCTRL_SPRD_H__
  16. struct platform_device;
  17. #define NUM_OFFSET (20)
  18. #define TYPE_OFFSET (16)
  19. #define BIT_OFFSET (8)
  20. #define WIDTH_OFFSET (4)
  21. #define SPRD_PIN_INFO(num, type, offset, width, reg) \
  22. (((num) & 0xFFF) << NUM_OFFSET | \
  23. ((type) & 0xF) << TYPE_OFFSET | \
  24. ((offset) & 0xFF) << BIT_OFFSET | \
  25. ((width) & 0xF) << WIDTH_OFFSET | \
  26. ((reg) & 0xF))
  27. #define SPRD_PINCTRL_PIN(pin) SPRD_PINCTRL_PIN_DATA(pin, #pin)
  28. #define SPRD_PINCTRL_PIN_DATA(a, b) \
  29. { \
  30. .name = b, \
  31. .num = (((a) >> NUM_OFFSET) & 0xfff), \
  32. .type = (((a) >> TYPE_OFFSET) & 0xf), \
  33. .bit_offset = (((a) >> BIT_OFFSET) & 0xff), \
  34. .bit_width = ((a) >> WIDTH_OFFSET & 0xf), \
  35. .reg = ((a) & 0xf) \
  36. }
  37. enum pin_type {
  38. GLOBAL_CTRL_PIN,
  39. COMMON_PIN,
  40. MISC_PIN,
  41. };
  42. struct sprd_pins_info {
  43. const char *name;
  44. unsigned int num;
  45. enum pin_type type;
  46. /* for global control pins configuration */
  47. unsigned long bit_offset;
  48. unsigned long bit_width;
  49. unsigned int reg;
  50. };
  51. int sprd_pinctrl_core_probe(struct platform_device *pdev,
  52. struct sprd_pins_info *sprd_soc_pin_info,
  53. int pins_cnt);
  54. int sprd_pinctrl_remove(struct platform_device *pdev);
  55. void sprd_pinctrl_shutdown(struct platform_device *pdev);
  56. #endif /* __PINCTRL_SPRD_H__ */