You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2022/09/30 12:31:39 UTC

[mynewt-core] branch master updated: hw/ipc_nrf5340: Add support for HCI IPC transport

This is an automated email from the ASF dual-hosted git repository.

andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
     new 04933eba6 hw/ipc_nrf5340: Add support for HCI IPC transport
04933eba6 is described below

commit 04933eba69b3dcc3d73c117b06f8f5cb7096a807
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Tue Sep 27 23:54:24 2022 +0200

    hw/ipc_nrf5340: Add support for HCI IPC transport
    
    This adds structure required for HCI IPC transport to shared memory.
    Since HCI IPC transport implements generic flow control for HCI over
    IPC, we can remove "old" flow control code.
---
 .../ipc_nrf5340/include/ipc_nrf5340/ipc_nrf5340.h  |  4 ++
 .../include/ipc_nrf5340/ipc_nrf5340_priv.h         |  7 +++-
 hw/drivers/ipc_nrf5340/src/ipc_nrf5340.c           | 45 ++--------------------
 3 files changed, 13 insertions(+), 43 deletions(-)

diff --git a/hw/drivers/ipc_nrf5340/include/ipc_nrf5340/ipc_nrf5340.h b/hw/drivers/ipc_nrf5340/include/ipc_nrf5340/ipc_nrf5340.h
index 36a6471a6..d0398d518 100644
--- a/hw/drivers/ipc_nrf5340/include/ipc_nrf5340/ipc_nrf5340.h
+++ b/hw/drivers/ipc_nrf5340/include/ipc_nrf5340/ipc_nrf5340.h
@@ -151,6 +151,10 @@ uint16_t ipc_nrf5340_consume(int channel, uint16_t len);
  */
 void ipc_nrf5340_set_net_core_restart_cb(void (*on_restart)(void));
 
+#if MYNEWT_PKG_apache_mynewt_nimble__nimble_transport_common_hci_ipc
+volatile struct hci_ipc_shm *ipc_nrf5340_hci_shm_get(void);
+#endif
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/hw/drivers/ipc_nrf5340/include/ipc_nrf5340/ipc_nrf5340_priv.h b/hw/drivers/ipc_nrf5340/include/ipc_nrf5340/ipc_nrf5340_priv.h
index 9fa20232b..94f0c35ce 100644
--- a/hw/drivers/ipc_nrf5340/include/ipc_nrf5340/ipc_nrf5340_priv.h
+++ b/hw/drivers/ipc_nrf5340/include/ipc_nrf5340/ipc_nrf5340_priv.h
@@ -21,6 +21,9 @@
 #define _HW_DRIVERS_IPC_NRF5340_PRIV_H
 
 #include <stdint.h>
+#if MYNEWT_PKG_apache_mynewt_nimble__nimble_transport_common_hci_ipc
+#include <nimble/transport/hci_ipc.h>
+#endif
 
 #ifdef __cplusplus
 extern "C" {
@@ -46,8 +49,8 @@ struct ipc_shared {
         APP_AND_NET_RUNNING,
         NET_RESTARTED,
     } ipc_state;
-#if MYNEWT_VAL(BLE_TRANSPORT_INT_FLOW_CTL)
-    uint8_t acl_from_ll_count;
+#if MYNEWT_PKG_apache_mynewt_nimble__nimble_transport_common_hci_ipc
+    volatile struct hci_ipc_shm hci_shm;
 #endif
 };
 
diff --git a/hw/drivers/ipc_nrf5340/src/ipc_nrf5340.c b/hw/drivers/ipc_nrf5340/src/ipc_nrf5340.c
index 3fb6482b6..5cd879dca 100644
--- a/hw/drivers/ipc_nrf5340/src/ipc_nrf5340.c
+++ b/hw/drivers/ipc_nrf5340/src/ipc_nrf5340.c
@@ -25,9 +25,6 @@
 #include <hal/hal_gpio.h>
 #include <bsp.h>
 #include <nrf_mutex.h>
-#if MYNEWT_VAL(BLE_TRANSPORT_INT_FLOW_CTL)
-#include <nimble/transport.h>
-#endif
 
 #if MYNEWT_VAL(IPC_NRF5340_NET_GPIO)
 #include <mcu/nrf5340_hal.h>
@@ -271,10 +268,6 @@ ipc_nrf5340_init(void)
     ipc_shared->ipc_shms = shms;
     ipc_shared->ipc_state = APP_WAITS_FOR_NET;
 
-#if MYNEWT_VAL(BLE_TRANSPORT_INT_FLOW_CTL)
-    ipc_shared->acl_from_ll_count = MYNEWT_VAL(BLE_TRANSPORT_ACL_FROM_LL_COUNT);
-#endif
-
     if (MYNEWT_VAL(MCU_APP_SECURE) && !MYNEWT_VAL(IPC_NRF5340_PRE_TRUSTZONE_NETCORE_BOOT)) {
         /*
          * When bootloader is secure and application is not all peripherals are
@@ -486,40 +479,10 @@ ipc_nrf5340_consume(int channel, uint16_t len)
     return ipc_nrf5340_shm_read(&shms[channel], NULL, NULL, len);
 }
 
-#if MYNEWT_VAL(BLE_TRANSPORT_INT_FLOW_CTL)
-int
-ble_transport_int_flow_ctl_get(void)
-{
-    int ret;
-
-    __asm__ volatile (".syntax unified                \n"
-                      "1: ldrexb r1, [%[addr]]        \n"
-                      "   mov %[ret], r1              \n"
-                      "   cmp r1, #0                  \n"
-                      "   itte ne                     \n"
-                      "   subne r2, r1, #1            \n"
-                      "   strexbne r1, r2, [%[addr]]  \n"
-                      "   clrexeq                     \n"
-                      "   cmp r1, #0                  \n"
-                      "   bne 1b                      \n"
-                      : [ret] "=&r" (ret)
-                      : [addr] "r"(&ipc_shared->acl_from_ll_count)
-                      : "r1", "r2", "memory");
-
-    return ret;
-}
-
-void
-ble_transport_int_flow_ctl_put(void)
+#if MYNEWT_PKG_apache_mynewt_nimble__nimble_transport_common_hci_ipc
+volatile struct hci_ipc_shm *
+ipc_nrf5340_hci_shm_get(void)
 {
-    __asm__ volatile (".syntax unified              \n"
-                      "1: ldrexb r1, [%[addr]]      \n"
-                      "   add r1, r1, #1            \n"
-                      "   strexb r2, r1, [%[addr]]  \n"
-                      "   cmp r2, #0                \n"
-                      "   bne 1b                    \n"
-                      :
-                      : [addr] "r"(&ipc_shared->acl_from_ll_count)
-                      : "r1", "r2", "memory");
+    return &ipc_shared->hci_shm;
 }
 #endif