Merge branch develop-3.10-next
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / rkwifi / bcmdhd / dhd_gpio.c
1
2 #include <osl.h>
3 #include <dngl_stats.h>
4 #include <dhd.h>
5 #include <linux/rfkill-wlan.h>
6
7 #ifdef CONFIG_MACH_ODROID_4210
8 #include <mach/gpio.h>
9 #include <mach/regs-gpio.h>
10 #include <plat/gpio-cfg.h>
11 #include <plat/sdhci.h>
12 #include <plat/devs.h>
13 #define sdmmc_channel   s3c_device_hsmmc0
14 #endif
15
16 struct wifi_platform_data dhd_wlan_control = {0};
17
18 #ifdef CUSTOMER_OOB
19 uint bcm_wlan_get_oob_irq(void)
20 {
21         uint host_oob_irq = 0;
22
23         host_oob_irq = rockchip_wifi_get_oob_irq();
24
25         printk("host_oob_irq: %d \r\n", host_oob_irq);
26
27         return host_oob_irq;
28 }
29
30 uint bcm_wlan_get_oob_irq_flags(void)
31 {
32         uint host_oob_irq_flags = 0;
33
34         host_oob_irq_flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL | IORESOURCE_IRQ_SHAREABLE) & IRQF_TRIGGER_MASK;
35         printk("host_oob_irq_flags=%d\n", host_oob_irq_flags);
36
37         return host_oob_irq_flags;
38 }
39 #endif
40
41 int bcm_wlan_set_power(bool on)
42 {
43         int err = 0;
44
45         if (on) {
46                 printk("======== PULL WL_REG_ON HIGH! ========\n");
47                 rockchip_wifi_power(1);
48         } else {
49                 printk("======== PULL WL_REG_ON LOW! ========\n");
50                 rockchip_wifi_power(0);
51         }
52
53         return err;
54 }
55
56 int bcm_wlan_set_carddetect(bool present)
57 {
58         int err = 0;
59
60         if (present) {
61                 printk("======== Card detection to detect SDIO card! ========\n");
62                 rockchip_wifi_set_carddetect(1);
63         } else {
64                 printk("======== Card detection to remove SDIO card! ========\n");
65                 rockchip_wifi_set_carddetect(0);
66         }
67
68         return err;
69 }
70
71 int bcm_wlan_get_mac_address(unsigned char *buf)
72 {
73         int err = 0;
74         
75         printk("======== %s ========\n", __FUNCTION__);
76 #ifdef EXAMPLE_GET_MAC
77         /* EXAMPLE code */
78         {
79                 struct ether_addr ea_example = {{0x00, 0x11, 0x22, 0x33, 0x44, 0xFF}};
80                 bcopy((char *)&ea_example, buf, sizeof(struct ether_addr));
81         }
82 #endif /* EXAMPLE_GET_MAC */
83         err = rockchip_wifi_mac_addr(buf);
84
85         return err;
86 }
87
88 #ifdef CONFIG_DHD_USE_STATIC_BUF
89 extern void *bcmdhd_mem_prealloc(int section, unsigned long size);
90 void* bcm_wlan_prealloc(int section, unsigned long size)
91 {
92         void *alloc_ptr = NULL;
93         alloc_ptr = bcmdhd_mem_prealloc(section, size);
94         if (alloc_ptr) {
95                 printk("success alloc section %d, size %ld\n", section, size);
96                 if (size != 0L)
97                         bzero(alloc_ptr, size);
98                 return alloc_ptr;
99         }
100         printk("can't alloc section %d\n", section);
101         return NULL;
102 }
103 #endif
104
105 int bcm_wlan_set_plat_data(void) {
106         printk("======== %s ========\n", __FUNCTION__);
107         dhd_wlan_control.set_power = bcm_wlan_set_power;
108         dhd_wlan_control.set_carddetect = bcm_wlan_set_carddetect;
109         dhd_wlan_control.get_mac_addr = bcm_wlan_get_mac_address;
110 #ifdef CONFIG_DHD_USE_STATIC_BUF
111         dhd_wlan_control.mem_prealloc = bcm_wlan_prealloc;
112 #endif
113         return 0;
114 }
115