wrap_pinmux_config.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. * Copyright (C) 2015 Marek Vasut <marex@denx.de>
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <common.h>
  7. #include <errno.h>
  8. /*
  9. * Yes, dear reader, we're including a C file here, this is no mistake.
  10. * But this time around, we do even more perverse hacking here to be
  11. * compatible with QTS headers and obtain reasonably nice results too.
  12. *
  13. * First, we define _PRELOADER_PINMUX_CONFIG_H_, which will neutralise
  14. * the pinmux_config.h inclusion in pinmux_config.c . Since we are
  15. * probing everything from DT, we do NOT want those macros from the
  16. * pinmux_config.h to ooze into our build system, anywhere, ever. So
  17. * we nip it at the bud.
  18. *
  19. * Next, pinmux_config.c needs CONFIG_HPS_PINMUX_NUM and uses it to
  20. * specify sized array explicitly. Instead, we want to use ARRAY_SIZE
  21. * to figure out the size of the array, so define this macro as an
  22. * empty one, so that the preprocessor optimizes things such that the
  23. * arrays are not sized by default.
  24. */
  25. #define _PRELOADER_PINMUX_CONFIG_H_
  26. #define CONFIG_HPS_PINMUX_NUM
  27. #include <qts/pinmux_config.c>
  28. void sysmgr_get_pinmux_table(const unsigned long **table,
  29. unsigned int *table_len)
  30. {
  31. *table = sys_mgr_init_table;
  32. *table_len = ARRAY_SIZE(sys_mgr_init_table);
  33. }