dcp.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * Copyright (c) 2011-2012, Freescale Semiconductor, Inc.
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without modification,
  6. * are permitted provided that the following conditions are met:
  7. *
  8. * o Redistributions of source code must retain the above copyright notice, this list
  9. * of conditions and the following disclaimer.
  10. *
  11. * o Redistributions in binary form must reproduce the above copyright notice, this
  12. * list of conditions and the following disclaimer in the documentation and/or
  13. * other materials provided with the distribution.
  14. *
  15. * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
  16. * contributors may be used to endorse or promote products derived from this
  17. * software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  20. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  21. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  22. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  23. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  24. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  25. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  26. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  28. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. /*!
  31. * @file dcp.h
  32. * @brief Interface for DCP module
  33. */
  34. #ifndef _DCP_H_
  35. #define _DCP_H_
  36. #include "sdk.h"
  37. #include "registers/regsdcp.h"
  38. #define HW_DCP_CHnCMDPTR_WR(ch, v) (((ch) == 0) ? HW_DCP_CH0CMDPTR_WR((v)) : \
  39. ((ch) == 1) ? HW_DCP_CH1CMDPTR_WR((v)): \
  40. ((ch) == 2) ? HW_DCP_CH2CMDPTR_WR((v)): \
  41. HW_DCP_CH3CMDPTR_WR((v)))
  42. #define HW_DCP_CHnSEMA_WR(ch, v) (((ch) == 0) ? HW_DCP_CH0SEMA_WR((v)) : \
  43. ((ch) == 1) ? HW_DCP_CH1SEMA_WR((v)): \
  44. ((ch) == 2) ? HW_DCP_CH2SEMA_WR((v)): \
  45. HW_DCP_CH3SEMA_WR((v)))
  46. typedef enum {
  47. DCP_CHANNEL_1 = 0,
  48. DCP_CHANNEL_2,
  49. DCP_CHANNEL_3,
  50. DCP_CHANNEL_4,
  51. DCP_CHANNEL_MAX,
  52. } dcp_channel_e;
  53. //! Data struture for DCP's work packet
  54. typedef struct {
  55. uint32_t* next_pkt;
  56. hw_dcp_packet1_t ctrl0;
  57. hw_dcp_packet2_t ctrl1;
  58. uint8_t *src_buf;
  59. uint8_t *dst_buf;
  60. uint32_t buf_size;
  61. uint8_t *payload;
  62. uint32_t stat;
  63. } dcp_work_pkt_t, *dcp_work_pkt_p;
  64. int dcp_init(void);
  65. int dcp_deinit(void);
  66. int dcp_config_channel(uint32_t ch, dcp_work_pkt_p pkt_list);
  67. int dcp_start_channel(uint32_t ch, uint32_t pkt_num);
  68. int dcp_wait_channel_cmpl(uint32_t ch);
  69. int dcp_memcpy(void* dst, void* src, uint32_t size);
  70. #endif