net: wireless: bcmdhd: use nvidia specific country code
Harshavardhan Nalajala [Tue, 20 Jan 2015 11:27:03 +0000 (16:27 +0530)]
using below nvidia specific country code..
US/CA -> Q2/113
EU -> E0/53

Bug 200056522

Change-Id: I1a2c954915c80aa8013d4f6fbecb484dbcfdf6f2
Signed-off-by: Om Prakash Singh <omp@nvidia.com>
Reviewed-on: http://git-master/r/673997
(cherry picked from commit 56d6774cd8d6259746b111e8c2b56f7d3e8f7927)

net: wireless: bcmdhd: get custom country code from dts file

platfrom specific country code is added in dts file.

Bug 200056522

Change-Id: I8e160232fdf186fdc6fd0e775f4c70dc41285c97
Signed-off-by: Om Prakash Singh <omp@nvidia.com>
Reviewed-on: http://git-master/r/681621
(cherry picked from commit f3092d1328c1e9b078df947666fc3d4c115e01a2)
Reviewed-on: http://git-master/r/709308
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>

drivers/net/wireless/bcmdhd/Makefile
drivers/net/wireless/bcmdhd/dhd_custom_gpio.c
drivers/net/wireless/bcmdhd/dhd_linux.h
drivers/net/wireless/bcmdhd/dhd_linux_platdev.c

index 70df640..a4ebb12 100644 (file)
@@ -10,7 +10,8 @@ DHDCFLAGS += -Wall -Wstrict-prototypes -Dlinux -DLINUX -DBCMDRIVER            \
        -DKEEP_ALIVE -DCSCAN -DPKT_FILTER_SUPPORT                             \
        -DEMBEDDED_PLATFORM -DPNO_SUPPORT                                     \
        -DDHD_DONOT_FORWARD_BCMEVENT_AS_NETWORK_PKT -DGET_CUSTOM_MAC_ENABLE   \
-       -DCUSTOMER_HW2 -DENABLE_INSMOD_NO_FW_LOAD
+       -DCUSTOMER_HW2 -DENABLE_INSMOD_NO_FW_LOAD -DCUSTOM_COUNTRY_LOCALE     \
+       -DNV_COUNTRY_CODE
 
 #################
 # Common feature
index 4b9287c..b9df1dc 100644 (file)
@@ -258,7 +258,7 @@ const struct cntry_locales_custom translate_custom_table[] = {
 */
 void get_customized_country_code(void *adapter, char *country_iso_code, wl_country_t *cspec)
 {
-#if defined(CUSTOMER_HW2) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39))
+#if !defined(CUSTOM_COUNTRY_LOCALE) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39))
 
        struct cntry_locales_custom *cloc_ptr;
 
@@ -274,11 +274,29 @@ void get_customized_country_code(void *adapter, char *country_iso_code, wl_count
 #else
        int size, i;
 
-       size = ARRAYSIZE(translate_custom_table);
 
        if (cspec == 0)
                 return;
 
+#ifdef NV_COUNTRY_CODE
+       wifi_adapter_info_t *wifi_adapter = (wifi_adapter_info_t *)adapter;
+       if (wifi_adapter->n_country == 0)
+                return;
+
+       for (i = 0; i < wifi_adapter->n_country; i++) {
+               if (strncmp(country_iso_code, wifi_adapter->country_code_map[i].iso_abbrev, 2) == 0) {
+                       memcpy(cspec->ccode,
+                               wifi_adapter->country_code_map[i].custom_locale, 2);
+                       cspec->rev = wifi_adapter->country_code_map[i].custom_locale_rev;
+                       return;
+               }
+       }
+       /* set default country code at index 0 */
+       memcpy(cspec->ccode, wifi_adapter->country_code_map[0].custom_locale, 2);
+       cspec->rev = wifi_adapter->country_code_map[0].custom_locale_rev;
+       return;
+#endif
+       size = ARRAYSIZE(translate_custom_table);
        if (size == 0)
                 return;
 
@@ -290,6 +308,7 @@ void get_customized_country_code(void *adapter, char *country_iso_code, wl_count
                        return;
                }
        }
+
 #ifdef EXAMPLE_TABLE
        /* if no country code matched return first universal code from translate_custom_table */
        memcpy(cspec->ccode, translate_custom_table[0].custom_locale, WLC_CNTRY_BUF_SZ);
index 8e653f8..d297d67 100644 (file)
@@ -64,6 +64,10 @@ typedef struct wifi_adapter_info {
        uint            bus_num;
        uint            slot_num;
        struct sysedp_consumer *sysedpc;
+#ifdef NV_COUNTRY_CODE
+       int             n_country;
+       struct cntry_locales_custom *country_code_map;
+#endif
 } wifi_adapter_info_t;
 
 typedef struct bcmdhd_wifi_platdata {
index d4cc36d..6f6df23 100644 (file)
@@ -36,6 +36,7 @@
 #include <dhd_bus.h>
 #include <dhd_linux.h>
 #include <wl_android.h>
+#include <wl_iw.h>
 #if defined(CONFIG_WIFI_CONTROL_FUNC)
 #include <linux/wlan_plat.h>
 #endif
@@ -329,6 +330,74 @@ void *wifi_platform_get_country_code(wifi_adapter_info_t *adapter, char *ccode)
        return NULL;
 }
 
+#ifdef NV_COUNTRY_CODE
+static int wifi_platform_get_country_code_map(struct device_node *node,
+                                               wifi_adapter_info_t *adapter)
+{
+       struct device_node *np_country;
+       struct device_node *child;
+       struct cntry_locales_custom *country;
+       int n_country;
+       int ret;
+       int i;
+       char *strptr;
+
+       np_country = of_get_child_by_name(node, "country_code_map");
+       if (!np_country) {
+               DHD_ERROR(("%s: could not get country_code_map\n", __func__));
+               return -1;
+       }
+
+       n_country = of_get_child_count(np_country);
+       if (!n_country) {
+               DHD_ERROR(("%s: n_country\n", __func__));
+               return -1;
+       }
+
+       country = kmalloc(n_country * sizeof(struct cntry_locales_custom), GFP_KERNEL);
+       if (!country) {
+               DHD_ERROR(("%s: fail to allocate memory\n", __func__));
+               return -1;
+       }
+       memset(country, 0, sizeof(country));
+
+       i = 0;
+       for_each_child_of_node(np_country, child) {
+               ret = of_property_read_string(child, "iso_abbrev", &strptr);
+               if (ret) {
+                       DHD_ERROR(("%s:read error iso_abbrev %s\n", __func__, child->name));
+                       goto fail;
+               } else {
+                       strncpy(country[i].iso_abbrev, strptr, 3);
+               }
+
+               ret = of_property_read_string(child, "custom_locale", &strptr);
+               if (ret) {
+                       DHD_ERROR(("%s:read error custom_locale  %s\n", __func__, child->name));
+                       goto fail;
+               } else {
+                       strncpy(country[i].custom_locale, strptr, 3);
+               }
+
+               ret = of_property_read_u32(child, "custom_locale_rev", &country[i].custom_locale_rev);
+               if (ret) {
+                       DHD_ERROR(("%s:read error custom_locale_rev %s\n", __func__, child->name));
+                       goto fail;
+               }
+               i++;
+       }
+
+       adapter->country_code_map = country;
+       adapter->n_country = n_country;
+       return 0;
+fail:
+       kfree(country);
+       adapter->country_code_map = NULL;
+       adapter->n_country = 0;
+       return -1;
+}
+#endif
+
 static int wifi_plat_dev_drv_probe(struct platform_device *pdev)
 {
        struct resource *resource;
@@ -366,6 +435,10 @@ static int wifi_plat_dev_drv_probe(struct platform_device *pdev)
                } else {
                        adapter->sysedpc = sysedp_create_consumer("primary-wifi", adapter->edp_name);
                }
+#ifdef NV_COUNTRY_CODE
+               if (wifi_platform_get_country_code_map(node, adapter))
+                       DHD_ERROR(("%s:platform country code map is not available\n", __func__));
+#endif
        } else {
                resource = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "bcmdhd_wlan_irq");
                if (resource == NULL)