vexpress.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * This program is free software; you can redistribute it and/or modify
  3. * it under the terms of the GNU General Public License version 2 as
  4. * published by the Free Software Foundation.
  5. *
  6. * This program is distributed in the hope that it will be useful,
  7. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. * GNU General Public License for more details.
  10. *
  11. * Copyright (C) 2012 ARM Limited
  12. */
  13. #ifndef _LINUX_VEXPRESS_H
  14. #define _LINUX_VEXPRESS_H
  15. #include <linux/device.h>
  16. #define VEXPRESS_SITE_MB 0
  17. #define VEXPRESS_SITE_DB1 1
  18. #define VEXPRESS_SITE_DB2 2
  19. #define VEXPRESS_SITE_MASTER 0xf
  20. #define VEXPRESS_CONFIG_STATUS_DONE 0
  21. #define VEXPRESS_CONFIG_STATUS_WAIT 1
  22. #define VEXPRESS_GPIO_MMC_CARDIN 0
  23. #define VEXPRESS_GPIO_MMC_WPROT 1
  24. #define VEXPRESS_GPIO_FLASH_WPn 2
  25. #define VEXPRESS_RES_FUNC(_site, _func) \
  26. { \
  27. .start = (_site), \
  28. .end = (_func), \
  29. .flags = IORESOURCE_BUS, \
  30. }
  31. /* Config bridge API */
  32. /**
  33. * struct vexpress_config_bridge_info - description of the platform
  34. * configuration infrastructure bridge.
  35. *
  36. * @name: Bridge name
  37. *
  38. * @func_get: Obtains pointer to a configuration function for a given
  39. * device or a Device Tree node, to be used with @func_put
  40. * and @func_exec. The node pointer should take precedence
  41. * over device pointer when both are passed.
  42. *
  43. * @func_put: Tells the bridge that the function will not be used any
  44. * more, so all allocated resources can be released.
  45. *
  46. * @func_exec: Executes a configuration function read or write operation.
  47. * The offset selects a 32 bit word of the value accessed.
  48. * Must return VEXPRESS_CONFIG_STATUS_DONE when operation
  49. * is finished immediately, VEXPRESS_CONFIG_STATUS_WAIT when
  50. * will be completed in some time or negative value in case
  51. * of error.
  52. */
  53. struct vexpress_config_bridge_info {
  54. const char *name;
  55. void *(*func_get)(struct device *dev, struct device_node *node);
  56. void (*func_put)(void *func);
  57. int (*func_exec)(void *func, int offset, bool write, u32 *data);
  58. };
  59. struct vexpress_config_bridge;
  60. struct vexpress_config_bridge *vexpress_config_bridge_register(
  61. struct device_node *node,
  62. struct vexpress_config_bridge_info *info);
  63. void vexpress_config_bridge_unregister(struct vexpress_config_bridge *bridge);
  64. void vexpress_config_complete(struct vexpress_config_bridge *bridge,
  65. int status);
  66. /* Config function API */
  67. struct vexpress_config_func;
  68. struct vexpress_config_func *__vexpress_config_func_get(struct device *dev,
  69. struct device_node *node);
  70. #define vexpress_config_func_get_by_dev(dev) \
  71. __vexpress_config_func_get(dev, NULL)
  72. #define vexpress_config_func_get_by_node(node) \
  73. __vexpress_config_func_get(NULL, node)
  74. void vexpress_config_func_put(struct vexpress_config_func *func);
  75. /* Both may sleep! */
  76. int vexpress_config_read(struct vexpress_config_func *func, int offset,
  77. u32 *data);
  78. int vexpress_config_write(struct vexpress_config_func *func, int offset,
  79. u32 data);
  80. /* Platform control */
  81. u32 vexpress_get_procid(int site);
  82. u32 vexpress_get_hbi(int site);
  83. void *vexpress_get_24mhz_clock_base(void);
  84. void vexpress_flags_set(u32 data);
  85. #define vexpress_get_site_by_node(node) __vexpress_get_site(NULL, node)
  86. #define vexpress_get_site_by_dev(dev) __vexpress_get_site(dev, NULL)
  87. unsigned __vexpress_get_site(struct device *dev, struct device_node *node);
  88. void vexpress_sysreg_early_init(void __iomem *base);
  89. void vexpress_sysreg_of_early_init(void);
  90. #endif