blob: cceb9211f33aca1e3d7a88db296e570cb1708f03 [file] [log] [blame]
#include <osl.h>
#include <dhd_linux.h>
#ifdef CONFIG_MACH_ODROID_4210
#include <mach/gpio.h>
#include <mach/regs-gpio.h>
#include <plat/gpio-cfg.h>
#include <plat/sdhci.h>
#include <plat/devs.h>
#define sdmmc_channel s3c_device_hsmmc0
#endif
#ifdef CUSTOMER_HW_AMLOGIC
extern void sdio_reinit(void);
extern void extern_wifi_set_enable(int is_on);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0))
extern int wifi_irq_num(void);
#endif
#endif
struct wifi_platform_data dhd_wlan_control = {0};
#ifdef CUSTOMER_OOB
uint bcm_wlan_get_oob_irq(void)
{
uint host_oob_irq = 0;
#ifdef CONFIG_MACH_ODROID_4210
printf("GPIO(WL_HOST_WAKE) = EXYNOS4_GPX0(7) = %d\n", EXYNOS4_GPX0(7));
host_oob_irq = gpio_to_irq(EXYNOS4_GPX0(7));
gpio_direction_input(EXYNOS4_GPX0(7));
#endif
#ifdef CUSTOMER_HW_AMLOGIC
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0))
host_oob_irq = INT_GPIO_4;
#else
host_oob_irq = wifi_irq_num();
#endif
#endif
printf("host_oob_irq: %d\n", host_oob_irq);
return host_oob_irq;
}
uint bcm_wlan_get_oob_irq_flags(void)
{
uint host_oob_irq_flags = 0;
#ifdef HW_OOB
host_oob_irq_flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL | IORESOURCE_IRQ_SHAREABLE;
#else
host_oob_irq_flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE | IORESOURCE_IRQ_SHAREABLE;
#endif
printf("host_oob_irq_flags=0x%X\n", host_oob_irq_flags);
return host_oob_irq_flags;
}
#endif
int bcm_wlan_set_power(bool on)
{
int err = 0;
if (on) {
printf("======== PULL WL_REG_ON HIGH! ========\n");
#ifdef CONFIG_MACH_ODROID_4210
err = gpio_set_value(EXYNOS4_GPK1(0), 1);
#endif
#ifdef CUSTOMER_HW_AMLOGIC
extern_wifi_set_enable(0);
mdelay(200);
extern_wifi_set_enable(1);
mdelay(200);
// sdio_reinit();
#endif
/* Lets customer power to get stable */
mdelay(100);
} else {
printf("======== PULL WL_REG_ON LOW! ========\n");
#ifdef CONFIG_MACH_ODROID_4210
err = gpio_set_value(EXYNOS4_GPK1(0), 0);
#endif
#ifdef CUSTOMER_HW_AMLOGIC
// extern_wifi_set_enable(0);
// mdelay(200);
#endif
}
return err;
}
int bcm_wlan_set_carddetect(bool present)
{
int err = 0;
if (present) {
printf("======== Card detection to detect SDIO card! ========\n");
#ifdef CONFIG_MACH_ODROID_4210
err = sdhci_s3c_force_presence_change(&sdmmc_channel, 1);
#endif
#ifdef CUSTOMER_HW_AMLOGIC
sdio_reinit();
#endif
} else {
printf("======== Card detection to remove SDIO card! ========\n");
#ifdef CONFIG_MACH_ODROID_4210
err = sdhci_s3c_force_presence_change(&sdmmc_channel, 0);
#endif
#ifdef CUSTOMER_HW_AMLOGIC
extern_wifi_set_enable(0);
mdelay(200);
#endif
}
return err;
}
int bcm_wlan_get_mac_address(unsigned char *buf)
{
int err = 0;
printf("======== %s ========\n", __FUNCTION__);
#ifdef EXAMPLE_GET_MAC
/* EXAMPLE code */
{
struct ether_addr ea_example = {{0x00, 0x11, 0x22, 0x33, 0x44, 0xFF}};
bcopy((char *)&ea_example, buf, sizeof(struct ether_addr));
}
#endif /* EXAMPLE_GET_MAC */
return err;
}
#ifdef CONFIG_DHD_USE_STATIC_BUF
extern void *bcmdhd_mem_prealloc(int section, unsigned long size);
void* bcm_wlan_prealloc(int section, unsigned long size)
{
void *alloc_ptr = NULL;
alloc_ptr = bcmdhd_mem_prealloc(section, size);
if (alloc_ptr) {
printf("success alloc section %d, size %ld\n", section, size);
if (size != 0L)
bzero(alloc_ptr, size);
return alloc_ptr;
}
printf("can't alloc section %d\n", section);
return NULL;
}
#endif
#if !defined(WL_WIRELESS_EXT)
struct cntry_locales_custom {
char iso_abbrev[WLC_CNTRY_BUF_SZ]; /* ISO 3166-1 country abbreviation */
char custom_locale[WLC_CNTRY_BUF_SZ]; /* Custom firmware locale */
int32 custom_locale_rev; /* Custom local revisin default -1 */
};
#endif
static struct cntry_locales_custom brcm_wlan_translate_custom_table[] = {
/* Table should be filled out based on custom platform regulatory requirement */
{"", "XT", 49}, /* Universal if Country code is unknown or empty */
{"US", "US", 0},
};
static void *bcm_wlan_get_country_code(char *ccode)
{
struct cntry_locales_custom *locales;
int size;
int i;
if (!ccode)
return NULL;
locales = brcm_wlan_translate_custom_table;
size = ARRAY_SIZE(brcm_wlan_translate_custom_table);
for (i = 0; i < size; i++)
if (strcmp(ccode, locales[i].iso_abbrev) == 0)
return &locales[i];
return NULL;
}
int bcm_wlan_set_plat_data(void) {
printf("======== %s ========\n", __FUNCTION__);
dhd_wlan_control.set_power = bcm_wlan_set_power;
dhd_wlan_control.set_carddetect = bcm_wlan_set_carddetect;
dhd_wlan_control.get_mac_addr = bcm_wlan_get_mac_address;
#ifdef CONFIG_DHD_USE_STATIC_BUF
dhd_wlan_control.mem_prealloc = bcm_wlan_prealloc;
#endif
dhd_wlan_control.get_country_code = bcm_wlan_get_country_code;
return 0;
}