io_addr_dec.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright (C) 2018 Marvell International Ltd.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. * https://spdx.org/licenses
  6. */
  7. #ifndef IO_ADDR_DEC_H
  8. #define IO_ADDR_DEC_H
  9. #include <stdint.h>
  10. /* There are 5 configurable cpu decoder windows. */
  11. #define DRAM_WIN_MAP_NUM_MAX 5
  12. /* Target number for dram in cpu decoder windows. */
  13. #define DRAM_CPU_DEC_TARGET_NUM 0
  14. /*
  15. * Not all configurable decode windows could be used for dram, some units have
  16. * to reserve one decode window for other unit they have to communicate with;
  17. * for example, DMA engineer has 3 configurable windows, but only two could be
  18. * for dram while the last one has to be for pcie, so for DMA, its max_dram_win
  19. * is 2.
  20. */
  21. struct dec_win_config {
  22. uint32_t dec_reg_base; /* IO address decoder register base address */
  23. uint32_t win_attr; /* IO address decoder windows attributes */
  24. /* How many configurable dram decoder windows that this unit has; */
  25. uint32_t max_dram_win;
  26. /* The decoder windows number including remapping that this unit has */
  27. uint32_t max_remap;
  28. /* The offset between continuous decode windows
  29. * within the same unit, typically 0x10
  30. */
  31. uint32_t win_offset;
  32. };
  33. struct dram_win {
  34. uintptr_t base_addr;
  35. uintptr_t win_size;
  36. };
  37. struct dram_win_map {
  38. int dram_win_num;
  39. struct dram_win dram_windows[DRAM_WIN_MAP_NUM_MAX];
  40. };
  41. /*
  42. * init_io_addr_dec
  43. *
  44. * This function initializes io address decoder windows by
  45. * cpu dram window mapping information
  46. *
  47. * @input: N/A
  48. * - dram_wins_map: cpu dram windows mapping
  49. * - io_dec_config: io address decoder windows configuration
  50. * - io_unit_num: io address decoder unit number
  51. * @output: N/A
  52. *
  53. * @return: 0 on success and others on failure
  54. */
  55. int init_io_addr_dec(struct dram_win_map *dram_wins_map,
  56. struct dec_win_config *io_dec_config,
  57. uint32_t io_unit_num);
  58. #endif /* IO_ADDR_DEC_H */