dp_umac_reset.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #include <dp_types.h>
  17. QDF_STATUS dp_soc_umac_reset_init(struct dp_soc *soc)
  18. {
  19. struct dp_soc_umac_reset_ctx *umac_reset_ctx;
  20. size_t alloc_size;
  21. if (!soc) {
  22. dp_umac_reset_err("DP SOC is null");
  23. return QDF_STATUS_E_NULL_VALUE;
  24. }
  25. umac_reset_ctx = &soc->umac_reset_ctx;
  26. qdf_mem_zero(umac_reset_ctx, sizeof(*umac_reset_ctx));
  27. umac_reset_ctx->current_state = UMAC_RESET_STATE_WAIT_FOR_PRE_RESET;
  28. alloc_size = sizeof(struct umac_reset_shmem) +
  29. DP_UMAC_RESET_SHMEM_ALIGN - 1;
  30. umac_reset_ctx->shmem_vaddr_unaligned =
  31. qdf_mem_alloc_consistent(soc->osdev, soc->osdev->dev,
  32. alloc_size,
  33. &umac_reset_ctx->shmem_paddr_unaligned);
  34. if (!umac_reset_ctx->shmem_vaddr_unaligned) {
  35. dp_umac_reset_err("shmem allocation failed");
  36. return QDF_STATUS_E_NOMEM;
  37. }
  38. umac_reset_ctx->shmem_vaddr_aligned = (void *)(uintptr_t)qdf_roundup(
  39. (uint64_t)(uintptr_t)umac_reset_ctx->shmem_vaddr_unaligned,
  40. DP_UMAC_RESET_SHMEM_ALIGN);
  41. umac_reset_ctx->shmem_paddr_aligned = qdf_roundup(
  42. (uint64_t)umac_reset_ctx->shmem_paddr_unaligned,
  43. DP_UMAC_RESET_SHMEM_ALIGN);
  44. return QDF_STATUS_SUCCESS;
  45. }