vexpress.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. /* Config bridge API */
  23. /**
  24. * struct vexpress_config_bridge_info - description of the platform
  25. * configuration infrastructure bridge.
  26. *
  27. * @name: Bridge name
  28. *
  29. * @func_get: Obtains pointer to a configuration function for a given
  30. * device or a Device Tree node, to be used with @func_put
  31. * and @func_exec. The node pointer should take precedence
  32. * over device pointer when both are passed.
  33. *
  34. * @func_put: Tells the bridge that the function will not be used any
  35. * more, so all allocated resources can be released.
  36. *
  37. * @func_exec: Executes a configuration function read or write operation.
  38. * The offset selects a 32 bit word of the value accessed.
  39. * Must return VEXPRESS_CONFIG_STATUS_DONE when operation
  40. * is finished immediately, VEXPRESS_CONFIG_STATUS_WAIT when
  41. * will be completed in some time or negative value in case
  42. * of error.
  43. */
  44. struct vexpress_config_bridge_info {
  45. const char *name;
  46. void *(*func_get)(struct device *dev, struct device_node *node);
  47. void (*func_put)(void *func);
  48. int (*func_exec)(void *func, int offset, bool write, u32 *data);
  49. };
  50. struct vexpress_config_bridge;
  51. struct vexpress_config_bridge *vexpress_config_bridge_register(
  52. struct device_node *node,
  53. struct vexpress_config_bridge_info *info);
  54. void vexpress_config_bridge_unregister(struct vexpress_config_bridge *bridge);
  55. void vexpress_config_complete(struct vexpress_config_bridge *bridge,
  56. int status);
  57. /* Config function API */
  58. struct vexpress_config_func;
  59. struct vexpress_config_func *__vexpress_config_func_get(struct device *dev,
  60. struct device_node *node);
  61. #define vexpress_config_func_get_by_dev(dev) \
  62. __vexpress_config_func_get(dev, NULL)
  63. #define vexpress_config_func_get_by_node(node) \
  64. __vexpress_config_func_get(NULL, node)
  65. void vexpress_config_func_put(struct vexpress_config_func *func);
  66. /* Both may sleep! */
  67. int vexpress_config_read(struct vexpress_config_func *func, int offset,
  68. u32 *data);
  69. int vexpress_config_write(struct vexpress_config_func *func, int offset,
  70. u32 data);
  71. #endif