-
-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
219 changed files
with
212,152 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
config SPARD_WLAN_SUPPORT | ||
bool "Unisoc wireless Support" | ||
select RK_WIFI_DEVICE_UWE5622 if SPARD_WLAN_SUPPORT | ||
default n | ||
help | ||
This is support for spreadtrum wireless chip. | ||
|
||
if SPARD_WLAN_SUPPORT | ||
source "drivers/net/wireless/uwe5622/unisocwcn/Kconfig" | ||
source "drivers/net/wireless/uwe5622/unisocwifi/Kconfig" | ||
source "drivers/net/wireless/uwe5622/tty-sdio/Kconfig" | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
obj-$(CONFIG_RK_WIFI_DEVICE_UWE5622) += unisocwcn/ | ||
obj-$(CONFIG_WLAN_UWE5622) += unisocwifi/ | ||
obj-$(CONFIG_TTY_OVERY_SDIO) += tty-sdio/ | ||
|
||
UNISOCWCN_DIR := $(shell cd $(src)/unisocwcn/ && /bin/pwd) | ||
UNISOC_BSP_INCLUDE := $(UNISOCWCN_DIR)/include | ||
export UNISOC_BSP_INCLUDE | ||
|
||
UNISOC_FW_PATH_CONFIG := "/lib/firmware/" | ||
export UNISOC_FW_PATH_CONFIG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
config TTY_OVERY_SDIO | ||
tristate "Spard TTY Overy SDIO Driver" | ||
help | ||
Spard tty overy sdio driver. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
ifneq ($(UNISOC_BSP_INCLUDE),) | ||
ccflags-y += -I$(UNISOC_BSP_INCLUDE) | ||
endif | ||
|
||
# ccflags-y += -DDEBUG | ||
# ccflags-y += -DKERNEL_VERSION_414 | ||
ccflags-y += -I$(srctree)/drivers/net/wireless/uwe5622/sprdwcn/include | ||
#ccflags-y += -DOTT_UWE | ||
ccflags-y += -DWOBLE_FUN | ||
ccflags-y += -Wno-implicit-fallthrough | ||
|
||
ifneq ($(UNISOC_BSP_INCLUDE),) | ||
ccflags-y += -I$(UNISOC_BSP_INCLUDE) | ||
endif | ||
|
||
sprdbt_tty-objs := \ | ||
tty.o \ | ||
rfkill.o \ | ||
lpm.o \ | ||
woble.o \ | ||
alignment/sitm.o \ | ||
dump.o | ||
|
||
obj-$(CONFIG_TTY_OVERY_SDIO) += sprdbt_tty.o | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# validate lookup result | ||
ifeq ($(KDIR),) | ||
$(warning No KDIR found for platform $(TARGET_PLATFORM)) | ||
endif | ||
|
||
ifeq ($(BUILD),debug) | ||
ccflags-y += -DDEBUG | ||
endif | ||
|
||
ifeq ($(UNISOC_WCN_KERNEL_PATH),kernel4.14) | ||
ccflags-y += -DKERNEL_VERSION_414 | ||
endif | ||
|
||
obj-m += sprdbt_tty.o | ||
sprdbt_tty-objs := tty.o \ | ||
rfkill.o \ | ||
lpm.o \ | ||
alignment/sitm.o \ | ||
dump.o | ||
|
||
modules: | ||
$(MAKE) ARCH=$(ARCH) -C $(KDIR) M=$(CURDIR) $@ | ||
|
||
clean: | ||
rm -f *.o .*.o.cmd modules.order Module.symvers *.ko *.mod.c .*.ko.cmd | ||
rm -rf .tmp_versions | ||
rm -f alignment/*.o alignment/.*.o.cmd | ||
|
||
|
||
kernelrelease: | ||
$(MAKE) ARCH=$(ARCH) -C $(KDIR) $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
/* | ||
* Copyright (C) 2016 Spreadtrum Communications Inc. | ||
* | ||
* This software is licensed under the terms of the GNU General Public | ||
* License version 2, as published by the Free Software Foundation, and | ||
* may be copied, distributed, and modified under those terms. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
*/ | ||
|
||
#include <linux/slab.h> | ||
#include <linux/kfifo.h> | ||
#include "sitm.h" | ||
|
||
|
||
static const uint8_t preamble_sizes[] = { | ||
HCI_COMMAND_PREAMBLE_SIZE, | ||
HCI_ACL_PREAMBLE_SIZE, | ||
HCI_SCO_PREAMBLE_SIZE, | ||
HCI_EVENT_PREAMBLE_SIZE | ||
}; | ||
|
||
static struct packet_receive_data_t *rd; | ||
|
||
int sitm_ini(void) | ||
{ | ||
rd = kmalloc(sizeof(struct packet_receive_data_t), | ||
GFP_KERNEL); | ||
memset(rd, 0, sizeof(struct packet_receive_data_t)); | ||
if (kfifo_alloc(&rd->fifo, | ||
HCI_HAL_SERIAL_BUFFER_SIZE, GFP_KERNEL)) { | ||
pr_err("no memory for sitm ring buf"); | ||
} | ||
return 0; | ||
} | ||
|
||
int sitm_cleanup(void) | ||
{ | ||
kfifo_free(&rd->fifo); | ||
kfree(rd); | ||
rd = NULL; | ||
return 0; | ||
} | ||
|
||
|
||
|
||
static int data_ready(uint8_t *buf, uint32_t count) | ||
{ | ||
int ret = kfifo_out(&rd->fifo, buf, count); | ||
return ret; | ||
} | ||
|
||
void parse_frame(data_ready_cb data_ready, frame_complete_cb frame_complete) | ||
{ | ||
uint8_t byte; | ||
size_t buffer_size, bytes_read; | ||
|
||
while (data_ready(&byte, 1) == 1) { | ||
switch (rd->state) { | ||
case BRAND_NEW: | ||
if (byte > DATA_TYPE_EVENT | ||
|| byte < DATA_TYPE_COMMAND) { | ||
pr_err("unknown head: 0x%02x\n", byte); | ||
break; | ||
} | ||
rd->type = byte; | ||
rd->bytes_remaining = | ||
preamble_sizes[PACKET_TYPE_TO_INDEX(rd->type)] | ||
+ 1; | ||
memset(rd->preamble, 0, PREAMBLE_BUFFER_SIZE); | ||
rd->index = 0; | ||
rd->state = PREAMBLE; | ||
case PREAMBLE: | ||
rd->preamble[rd->index] = byte; | ||
rd->index++; | ||
rd->bytes_remaining--; | ||
|
||
if (rd->bytes_remaining == 0) { | ||
rd->bytes_remaining = | ||
(rd->type == DATA_TYPE_ACL) ? | ||
RETRIEVE_ACL_LENGTH(rd->preamble) | ||
: byte; | ||
buffer_size = rd->index | ||
+ rd->bytes_remaining; | ||
memcpy(rd->buffer, | ||
rd->preamble, | ||
rd->index); | ||
rd->state = | ||
rd->bytes_remaining > 0 ? | ||
BODY : FINISHED; | ||
} | ||
break; | ||
case BODY: | ||
rd->buffer[rd->index] = byte; | ||
rd->index++; | ||
rd->bytes_remaining--; | ||
bytes_read = data_ready((rd->buffer | ||
+ rd->index), | ||
rd->bytes_remaining); | ||
rd->index += bytes_read; | ||
rd->bytes_remaining -= bytes_read; | ||
rd->state = | ||
rd->bytes_remaining == 0 ? | ||
FINISHED : rd->state; | ||
break; | ||
case IGNORE: | ||
pr_err("PARSE IGNORE\n"); | ||
rd->bytes_remaining--; | ||
if (rd->bytes_remaining == 0) { | ||
rd->state = BRAND_NEW; | ||
return; | ||
} | ||
break; | ||
case FINISHED: | ||
pr_err("%s state.\n", __func__); | ||
break; | ||
default: | ||
pr_err("PARSE DEFAULT\n"); | ||
break; | ||
} | ||
|
||
if (rd->state == FINISHED) { | ||
if (rd->type == DATA_TYPE_COMMAND | ||
|| rd->type == DATA_TYPE_ACL) { | ||
uint32_t tail = BYTE_ALIGNMENT | ||
- ((rd->index | ||
+ BYTE_ALIGNMENT) | ||
% BYTE_ALIGNMENT); | ||
|
||
while (tail--) | ||
rd->buffer[rd->index++] = 0; | ||
} | ||
frame_complete(rd->buffer, | ||
rd->index); | ||
rd->state = BRAND_NEW; | ||
} | ||
} | ||
} | ||
|
||
int sitm_write(const uint8_t *buf, int count, frame_complete_cb frame_complete) | ||
{ | ||
int ret; | ||
|
||
if (!rd) { | ||
pr_err("hci fifo no memory\n"); | ||
return count; | ||
} | ||
|
||
ret = kfifo_avail(&rd->fifo); | ||
if (ret == 0) { | ||
pr_err("hci fifo no memory\n"); | ||
return ret; | ||
} else if (ret < count) { | ||
pr_err("hci fifo low memory\n"); | ||
count = ret; | ||
} | ||
|
||
kfifo_in(&rd->fifo, buf, count); | ||
parse_frame(data_ready, frame_complete); | ||
return count; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#ifndef __SITM_H | ||
#define __SITM_H | ||
|
||
#include <linux/types.h> | ||
#include <linux/kfifo.h> | ||
|
||
#define PREAMBLE_BUFFER_SIZE 5 | ||
#define PACKET_TYPE_TO_INDEX(type) ((type) - 1) | ||
#define HCI_COMMAND_PREAMBLE_SIZE 3 | ||
#define HCI_ACL_PREAMBLE_SIZE 4 | ||
#define HCI_SCO_PREAMBLE_SIZE 3 | ||
#define HCI_EVENT_PREAMBLE_SIZE 2 | ||
#define RETRIEVE_ACL_LENGTH(preamble) \ | ||
((((preamble)[4] & 0xFFFF) << 8) | (preamble)[3]) | ||
#define HCI_HAL_SERIAL_BUFFER_SIZE 1026 | ||
|
||
#define BYTE_ALIGNMENT 4 | ||
|
||
enum receive_state_t { | ||
BRAND_NEW, | ||
PREAMBLE, | ||
BODY, | ||
IGNORE, | ||
FINISHED | ||
}; | ||
|
||
enum serial_data_type_t { | ||
DATA_TYPE_COMMAND = 1, | ||
DATA_TYPE_ACL = 2, | ||
DATA_TYPE_SCO = 3, | ||
DATA_TYPE_EVENT = 4 | ||
}; | ||
|
||
|
||
struct packet_receive_data_t { | ||
enum receive_state_t state; | ||
uint16_t bytes_remaining; | ||
uint8_t type; | ||
uint8_t preamble[PREAMBLE_BUFFER_SIZE]; | ||
uint16_t index; | ||
struct kfifo fifo; | ||
uint8_t buffer[HCI_HAL_SERIAL_BUFFER_SIZE + BYTE_ALIGNMENT]; | ||
}; | ||
|
||
typedef int (*frame_complete_cb)(uint8_t *data, size_t len); | ||
typedef int (*data_ready_cb)(uint8_t *data, uint32_t len); | ||
|
||
|
||
int sitm_write(const uint8_t *buf, int count, frame_complete_cb frame_complete); | ||
int sitm_ini(void); | ||
int sitm_cleanup(void); | ||
#endif |
Oops, something went wrong.