xor.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * Copyright (C) Marvell International Ltd. and its affiliates
  3. *
  4. * SPDX-License-Identifier: GPL-2.0
  5. */
  6. #ifndef _XOR_H
  7. #define _XOR_H
  8. #define SRAM_BASE 0x40000000
  9. #include "ddr3_hws_hw_training_def.h"
  10. #define MV_XOR_MAX_UNIT 2 /* XOR unit == XOR engine */
  11. #define MV_XOR_MAX_CHAN 4 /* total channels for all units */
  12. #define MV_XOR_MAX_CHAN_PER_UNIT 2 /* channels for units */
  13. #define MV_IS_POWER_OF_2(num) (((num) != 0) && (((num) & ((num) - 1)) == 0))
  14. /*
  15. * This structure describes address space window. Window base can be
  16. * 64 bit, window size up to 4GB
  17. */
  18. struct addr_win {
  19. u32 base_low; /* 32bit base low */
  20. u32 base_high; /* 32bit base high */
  21. u32 size; /* 32bit size */
  22. };
  23. /* This structure describes SoC units address decode window */
  24. struct unit_win_info {
  25. struct addr_win addr_win; /* An address window */
  26. int enable; /* Address decode window is enabled/disabled */
  27. u8 attrib; /* chip select attributes */
  28. u8 target_id; /* Target Id of this MV_TARGET */
  29. };
  30. /*
  31. * This enumerator describes the type of functionality the XOR channel
  32. * can have while using the same data structures.
  33. */
  34. enum xor_type {
  35. MV_XOR, /* XOR channel functions as XOR accelerator */
  36. MV_DMA, /* XOR channel functions as IDMA channel */
  37. MV_CRC32 /* XOR channel functions as CRC 32 calculator */
  38. };
  39. enum mv_state {
  40. MV_IDLE,
  41. MV_ACTIVE,
  42. MV_PAUSED,
  43. MV_UNDEFINED_STATE
  44. };
  45. /*
  46. * This enumerator describes the set of commands that can be applied on
  47. * an engine (e.g. IDMA, XOR). Appling a comman depends on the current
  48. * status (see MV_STATE enumerator)
  49. *
  50. * Start can be applied only when status is IDLE
  51. * Stop can be applied only when status is IDLE, ACTIVE or PAUSED
  52. * Pause can be applied only when status is ACTIVE
  53. * Restart can be applied only when status is PAUSED
  54. */
  55. enum mv_command {
  56. MV_START, /* Start */
  57. MV_STOP, /* Stop */
  58. MV_PAUSE, /* Pause */
  59. MV_RESTART /* Restart */
  60. };
  61. enum xor_override_target {
  62. SRC_ADDR0, /* Source Address #0 Control */
  63. SRC_ADDR1, /* Source Address #1 Control */
  64. SRC_ADDR2, /* Source Address #2 Control */
  65. SRC_ADDR3, /* Source Address #3 Control */
  66. SRC_ADDR4, /* Source Address #4 Control */
  67. SRC_ADDR5, /* Source Address #5 Control */
  68. SRC_ADDR6, /* Source Address #6 Control */
  69. SRC_ADDR7, /* Source Address #7 Control */
  70. XOR_DST_ADDR, /* Destination Address Control */
  71. XOR_NEXT_DESC /* Next Descriptor Address Control */
  72. };
  73. enum mv_state mv_xor_state_get(u32 chan);
  74. void mv_xor_hal_init(u32 xor_chan_num);
  75. int mv_xor_ctrl_set(u32 chan, u32 xor_ctrl);
  76. int mv_xor_command_set(u32 chan, enum mv_command command);
  77. int mv_xor_override_set(u32 chan, enum xor_override_target target, u32 win_num,
  78. int enable);
  79. #endif