]> Git Repo - esp-hosted.git/commitdiff
fix(esp_hosted_ng): Add support for esp32-c6 SDIO
authorKapil Gupta <[email protected]>
Fri, 5 Jan 2024 13:48:29 +0000 (19:18 +0530)
committerBOT <[email protected]>
Fri, 5 Jan 2024 15:00:35 +0000 (23:00 +0800)
esp_hosted_ng/esp/esp_driver/network_adapter/main/app_main.c
esp_hosted_ng/esp/esp_driver/network_adapter/main/include/interface.h
esp_hosted_ng/host/Makefile
esp_hosted_ng/host/esp_bt.c
esp_hosted_ng/host/esp_cfg80211.c
esp_hosted_ng/host/include/esp.h
esp_hosted_ng/host/rpi_init.sh
esp_hosted_ng/host/sdio/esp_sdio.c
esp_hosted_ng/host/spi/esp_spi.c

index dce11a3dc75793f1393c7eef660ff316c9636d88..48d5a60c6e01183ee19d4b14d248b525b2eb3a90 100644 (file)
@@ -300,7 +300,6 @@ void process_tx_pkt(interface_buffer_handle_t *buf_handle)
                        buf_handle->free_buf_handle(buf_handle->priv_buffer_handle);
                        buf_handle->priv_buffer_handle = NULL;
                }
-               ESP_LOGD(TAG, "Data path stopped");
                usleep(100*1000);
                return;
        }
index d4d79d63f4658b7d7859d0b7c1be239d3aafdfc3..07c59200bea7b23ee857fb37b3573782170411bc 100644 (file)
@@ -23,7 +23,7 @@
 #if defined(CONFIG_IDF_TARGET_ESP32)||defined(CONFIG_IDF_TARGET_ESP32C6)
        #include "driver/sdio_slave.h"
 #else
-       #error "SDIO is not supported ESP32S2"
+       #error "SDIO is not supported"
 #endif
 
 #endif
index 4cf3c20193cea48f0a5f72e37563fac79151fc59..9e820da9f0d42dc0914595bcd9e0808988af6da0 100644 (file)
@@ -8,11 +8,11 @@ CONFIG_ENABLE_MONITOR_PROCESS = n
 ESP_SLAVE := ""
 
 # Toolchain Path
-CROSS_COMPILE := /usr/bin/arm-linux-gnueabihf-
+CROSS_COMPILE :=
 # Linux Kernel header
 KERNEL := /lib/modules/$(shell uname -r)/build
 # Architecture
-ARCH := arm
+ARCH := arm64
 
 #Default interface is sdio
 MODULE_NAME=esp32_sdio
index 9fdc08af23f27a6e45e8d7681e109b6f36da0f28..d2a3bee804400cab9c4cb85743533b39d291bd70 100644 (file)
@@ -242,6 +242,9 @@ int esp_init_bt(struct esp_adapter *adapter)
 
        hdev->dev_type = HCI_PRIMARY;
 
+       if (adapter->if_type == ESP_IF_TYPE_SDIO)
+               SET_HCIDEV_DEV(hdev, adapter->dev);
+
        ret = hci_register_dev(hdev);
        if (ret < 0) {
                BT_ERR("Can not register HCI device");
index 62ed5f234337cb7dbbbc984288c9af46ca4d3cd0..65ddaecb032bc1add73ac1acb195ef9c11734088 100644 (file)
@@ -599,15 +599,21 @@ static void esp_reg_notifier(struct wiphy *wiphy,
                return;
        }
 
+       if (!test_bit(ESP_INIT_DONE, &adapter->state_flags)) {
+               esp_info("Driver init is ongoing\n");
+               return;
+       }
+       if (test_bit(ESP_CLEANUP_IN_PROGRESS, &adapter->state_flags)) {
+               esp_info("Driver cleanup is ongoing\n");
+               return;
+       }
+
        esp_dev = wiphy_priv(wiphy);
 
        if (!esp_dev || !esp_dev->adapter) {
                esp_info("%u esp_dev not initialized yet \n", __LINE__);
                return;
        }
-       if (test_bit(ESP_CLEANUP_IN_PROGRESS, &adapter->state_flags)) {
-               return;
-       }
 
        priv = esp_dev->adapter->priv[0];
 
index 39501fb5fbeef9f5b4c50f9077b5bd2779662951..c00db1679143bf9038c88ac68f761136c0dedae0 100644 (file)
@@ -60,6 +60,7 @@ enum adapter_flags_e {
        ESP_CLEANUP_IN_PROGRESS,    /* Driver unloading or ESP reseted */
        ESP_CMD_INIT_DONE,          /* Cmd component is initialized with esp_commands_setup() */
        ESP_DRIVER_ACTIVE,          /* kernel module __exit is not yet invoked */
+       ESP_INIT_DONE,              /* Driver init done */
 };
 
 enum priv_flags_e {
index 588fe261aeb5ee23d4c420900f23e7950c529e03..15a7ff8b52ed9239e621fa8d63f67f66ee02022a 100755 (executable)
@@ -49,12 +49,25 @@ wlan_init()
         VAL_CONFIG_TEST_RAW_TP=y
     fi
 
+    if [ "$ESP_SLAVE" != "" ] ; then
+        CUSTOM_OPTS=${CUSTOM_OPTS}" ESP_SLAVE=\"$ESP_SLAVE"\"
+    fi
+    if [ "$CUSTOM_OPTS" != "" ] ; then
+        echo "Adding $CUSTOM_OPTS"
+    fi
+
     # For Linux other than Raspberry Pi, Please point
     # CROSS_COMPILE -> <Toolchain-Path>/bin/arm-linux-gnueabihf-
     # KERNEL        -> Place where kernel is checked out and built
     # ARCH          -> Architecture
-    make -j8 target=$IF_TYPE CROSS_COMPILE=/usr/bin/arm-linux-gnueabihf- KERNEL="/lib/modules/$(uname -r)/build" \
-    CONFIG_TEST_RAW_TP="$VAL_CONFIG_TEST_RAW_TP" ARCH=arm
+    # make -j8 target=$IF_TYPE CROSS_COMPILE=/usr/bin/arm-linux-gnueabihf- KERNEL="/lib/modules/$(uname -r)/build" \
+    # CONFIG_TEST_RAW_TP="$VAL_CONFIG_TEST_RAW_TP" ARCH=arm64
+
+    # Populate your arch if not populated correctly.
+    arch_num_bits=$(getconf LONG_BIT)
+    if [ "$arch_num_bits" = "32" ] ; then arch_found="arm"; else arch_found="arm64"; fi
+
+    make -j8 target=$IF_TYPE KERNEL="/lib/modules/$(uname -r)/build" CONFIG_TEST_RAW_TP="$VAL_CONFIG_TEST_RAW_TP" ARCH=$arch_found $CUSTOM_OPTS
 
     if [ "$RESETPIN" = "" ] ; then
         #By Default, BCM6 is GPIO on host. use resetpin=6
@@ -153,6 +166,10 @@ select_esp_slave()
             echo "Building for esp32"
                        ESP_SLAVE='CONFIG_TARGET_ESP32=y'
             ;;
+        [Ee][Ss][Pp]32[Cc]6)
+            echo "Building for esp32c6"
+                       ESP_SLAVE='CONFIG_TARGET_ESP32C6=y'
+            ;;
         [Ee][Ss][Pp]32-[Cc]6)
             echo "Building for esp32c6"
                        ESP_SLAVE='CONFIG_TARGET_ESP32C6=y'
@@ -172,10 +189,10 @@ if [ "$IF_TYPE" = "" ] ; then
     usage
     exit 1
 else
-       if [ "$IF_TYPE" = "sdio" ] ; then
-               # SDIO Kernel driver registration varies for ESP32 and ESP32-C6 slave chipsets
-               select_esp_slave
-       fi
+if [ "$IF_TYPE" = "sdio" ] ; then
+    # SDIO Kernel driver registration varies for ESP32 and ESP32-C6 slave chipsets
+    select_esp_slave
+fi
     echo "Building for $IF_TYPE protocol"
     MODULE_NAME=esp32_${IF_TYPE}.ko
 fi
index a3a74f81e4505bd98353ec50a2b34b6a38862d34..dba7f4b5105d20d27fd4f55b2b833ac356f09e7b 100644 (file)
@@ -653,7 +653,7 @@ static int tx_process(void *data)
        return 0;
 }
 
-static struct esp_sdio_context *init_sdio_func(struct sdio_func *func)
+static struct esp_sdio_context *init_sdio_func(struct sdio_func *func, int *sdio_ret)
 {
        struct esp_sdio_context *context = NULL;
        int ret = 0;
@@ -670,13 +670,24 @@ static struct esp_sdio_context *init_sdio_func(struct sdio_func *func)
        /* Enable Function */
        ret = sdio_enable_func(func);
        if (ret) {
+               esp_err("sdio_enable_func ret: %d\n", ret);
+               if (sdio_ret)
+                       *sdio_ret = ret;
+               sdio_release_host(func);
+
                return NULL;
        }
 
        /* Register IRQ */
        ret = sdio_claim_irq(func, esp_handle_isr);
        if (ret) {
+               esp_err("sdio_claim_irq ret: %d\n", ret);
                sdio_disable_func(func);
+
+               if (sdio_ret)
+                       *sdio_ret = ret;
+               sdio_release_host(func);
+
                return NULL;
        }
 
@@ -757,10 +768,13 @@ static int esp_probe(struct sdio_func *func,
 
        esp_info("ESP network device detected\n");
 
-       context = init_sdio_func(func);
+       context = init_sdio_func(func, &ret);;
 
        if (!context) {
-               return -EINVAL;
+               if (ret)
+                       return ret;
+               else
+                       return -EINVAL;
        }
 
        if (sdio_context.sdio_clk_mhz) {
@@ -886,12 +900,12 @@ MODULE_DEVICE_TABLE(of, esp_sdio_of_match);
 
 /* SDIO driver structure to be registered with kernel */
 static struct sdio_driver esp_sdio_driver = {
-       .name           = "esp_sdio",
+       .name           = KBUILD_MODNAME,
        .id_table       = esp_devices,
        .probe          = esp_probe,
        .remove         = esp_remove,
        .drv = {
-               .name = "esp_sdio",
+               .name = KBUILD_MODNAME,
                .owner = THIS_MODULE,
                .pm = &esp_pm_ops,
                .of_match_table = esp_sdio_of_match,
@@ -923,8 +937,14 @@ void process_event_esp_bootup(struct esp_adapter *adapter, u8 *evt_buf, u8 len)
        if (!evt_buf)
                return;
 
+       if (len_left >= 64) {
+               esp_info("ESP init event len looks unexpected: %u (>=64)\n", len_left);
+               esp_info("You probably facing timing mismatch at transport layer\n");
+       }
+
        pos = evt_buf;
 
+       clear_bit(ESP_INIT_DONE, &adapter->state_flags);
        while (len_left) {
                tag_len = *(pos + 1);
 
@@ -933,8 +953,6 @@ void process_event_esp_bootup(struct esp_adapter *adapter, u8 *evt_buf, u8 len)
                if (*pos == ESP_BOOTUP_CAPABILITY) {
 
                        adapter->capabilities = *(pos + 2);
-                       process_capabilities(adapter);
-                       print_capabilities(*(pos + 2));
 
                } else if (*pos == ESP_BOOTUP_FIRMWARE_CHIP_ID) {
 
@@ -958,11 +976,12 @@ void process_event_esp_bootup(struct esp_adapter *adapter, u8 *evt_buf, u8 len)
                        if (tag_len != sizeof(struct fw_data))
                                esp_info("Length not matching to firmware data size\n");
                        else
-                               if (process_fw_data((struct fw_data *)(pos + 2)))
+                               if (process_fw_data((struct fw_data *)(pos + 2))) {
                                        if (context->func) {
                                                generate_slave_intr(context, BIT(ESP_CLOSE_DATA_PATH));
                                                return;
                                        }
+                               }
 
                } else {
                        esp_warn("Unsupported tag in event");
@@ -975,6 +994,10 @@ void process_event_esp_bootup(struct esp_adapter *adapter, u8 *evt_buf, u8 len)
        if (esp_add_card(adapter)) {
                esp_err("network iterface init failed\n");
                generate_slave_intr(context, BIT(ESP_CLOSE_DATA_PATH));
+       } else {
+               set_bit(ESP_INIT_DONE, &adapter->state_flags);
+               process_capabilities(adapter);
+               print_capabilities(adapter->capabilities);
        }
 }
 
index 9179e66f3cc1f37a9ecabe86a0037c3e372a5bf4..0395bbd4e6905bc00756f81a72480e1918a92a27 100644 (file)
@@ -286,6 +286,8 @@ void process_event_esp_bootup(struct esp_adapter *adapter, u8 *evt_buf, u8 len)
 
        if (esp_add_card(adapter)) {
                esp_err("network iterface init failed\n");
+       } else {
+               set_bit(ESP_INIT_DONE, &adapter->state_flags);
        }
 
        process_capabilities(adapter);
This page took 0.048004 seconds and 4 git commands to generate.