net: Add TI_CC2520 RAW driver

Add TI CC2520 driver allowing RAW access to radio interface similar
way Bluetooth user channel works. This makes possible to handle radio
channel inside external 802.15.4 stacks, for example export it over USB
and handle in Linux.

Change-Id: I61bb4c8b998ff1e47dc65427ac471f04ec8fea63
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This commit is contained in:
Andrei Emeltchenko 2016-09-26 12:51:58 +03:00 committed by Jukka Rissanen
commit ca2cc81d7a
6 changed files with 49 additions and 7 deletions

View file

@ -46,7 +46,7 @@ endif
config BLUETOOTH_MONITOR_ON_DEV_NAME config BLUETOOTH_MONITOR_ON_DEV_NAME
default UART_QMSI_1_NAME if BLUETOOTH_DEBUG_MONITOR default UART_QMSI_1_NAME if BLUETOOTH_DEBUG_MONITOR
if TI_CC2520_LEGACY || TI_CC2520 if TI_CC2520_LEGACY || TI_CC2520 || TI_CC2520_RAW
config SPI config SPI
def_bool y def_bool y
@ -85,6 +85,6 @@ config TI_CC2520_GPIO_1_NAME
default GPIO_QMSI_1_NAME default GPIO_QMSI_1_NAME
endif endif
endif # TI_CC2520_LEGACY || TI_CC2520 endif # TI_CC2520_LEGACY || TI_CC2520 || TI_CC2520_RAW
endif # BOARD_QUARK_SE_C1000_DEVBOARD endif # BOARD_QUARK_SE_C1000_DEVBOARD

View file

@ -20,7 +20,9 @@
#include <device.h> #include <device.h>
#include <init.h> #include <init.h>
#if defined(CONFIG_TI_CC2520_LEGACY) || defined(CONFIG_TI_CC2520) #if defined(CONFIG_TI_CC2520_LEGACY) || \
defined(CONFIG_TI_CC2520) || \
defined(CONFIG_TI_CC2520_RAW)
#include <gpio.h> #include <gpio.h>
@ -56,4 +58,4 @@ struct device **cc2520_configure_gpios(void)
return cc2520_gpio_config; return cc2520_gpio_config;
} }
#endif /* CONFIG_TI_CC2520_LEGACY || CONFIG_TI_CC2520 */ #endif /* CONFIG_TI_CC2520_LEGACY || CONFIG_TI_CC2520 || CONFIG_TI_CC2520_RAW */

View file

@ -31,7 +31,9 @@
#define LED0_GPIO_PORT CONFIG_GPIO_QMSI_0_NAME #define LED0_GPIO_PORT CONFIG_GPIO_QMSI_0_NAME
#define LED0_GPIO_PIN 25 #define LED0_GPIO_PIN 25
#if defined(CONFIG_TI_CC2520_LEGACY) || defined(CONFIG_TI_CC2520) #if defined(CONFIG_TI_CC2520_LEGACY) || \
defined(CONFIG_TI_CC2520) || \
defined(CONFIG_TI_CC2520_RAW)
/* GPIO numbers where the TI cc2520 chip is connected to */ /* GPIO numbers where the TI cc2520 chip is connected to */
#define CONFIG_CC2520_GPIO_VREG_EN 0 /* PIN ?, ATP_AON_INT0 (out) */ #define CONFIG_CC2520_GPIO_VREG_EN 0 /* PIN ?, ATP_AON_INT0 (out) */
@ -56,7 +58,7 @@ enum cc2520_gpio_index {
CC2520_GPIO_IDX_LAST_ENTRY CC2520_GPIO_IDX_LAST_ENTRY
}; };
#endif /* CONFIG_TI_CC2520_LEGACY || CONFIG_TI_CC2520 */ #endif /* CONFIG_TI_CC2520_LEGACY || CONFIG_TI_CC2520 || CONFIG_TI_CC2520_RAW */
#if defined(CONFIG_USB) #if defined(CONFIG_USB)
/* GPIO driver name */ /* GPIO driver name */

View file

@ -46,7 +46,16 @@ config TI_CC2520
select NET_L2_IEEE802154 select NET_L2_IEEE802154
default n default n
if TI_CC2520_LEGACY || TI_CC2520 config TI_CC2520_RAW
bool "TI CC2520 Driver RAW channel"
default n
help
Enable TI_CC2520 driver with RAW channel
The CC2520 driver with RAW channel allows to export radio interface
over USB making an USB 802.15.4 dongle.
if TI_CC2520_LEGACY || TI_CC2520 || TI_CC2520_RAW
config SYS_LOG_TI_CC2520_LEVEL config SYS_LOG_TI_CC2520_LEVEL
int int

View file

@ -5,4 +5,5 @@ subdir-ccflags-$(CONFIG_TI_CC2520_LEGACY) +=-I${srctree}/net/ip
obj-$(CONFIG_TI_CC2520_LEGACY) += ieee802154_cc2520_legacy.o obj-$(CONFIG_TI_CC2520_LEGACY) += ieee802154_cc2520_legacy.o
obj-$(CONFIG_TI_CC2520) += ieee802154_cc2520.o obj-$(CONFIG_TI_CC2520) += ieee802154_cc2520.o
obj-$(CONFIG_TI_CC2520_RAW) += ieee802154_cc2520.o
obj-$(CONFIG_UPIPE_15_4) += ieee802154_uart_pipe.o obj-$(CONFIG_UPIPE_15_4) += ieee802154_uart_pipe.o

View file

@ -612,7 +612,14 @@ static void cc2520_rx(int arg, int unused2)
goto flush; goto flush;
} }
#if defined(CONFIG_TI_CC2520_RAW)
/**
* Reserve 1 byte for length
*/
pkt_buf = net_nbuf_get_reserve_data(1);
#else
pkt_buf = net_nbuf_get_reserve_data(0); pkt_buf = net_nbuf_get_reserve_data(0);
#endif
if (!pkt_buf) { if (!pkt_buf) {
SYS_LOG_DBG("No pkt_buf available\n"); SYS_LOG_DBG("No pkt_buf available\n");
goto out; goto out;
@ -635,6 +642,20 @@ static void cc2520_rx(int arg, int unused2)
goto out; goto out;
} }
#if defined(CONFIG_TI_CC2520_RAW)
/**
* add LQI needed for Linux
*/
{
uint8_t lqi = pkt_buf->data[pkt_len - 1] &
CC2520_FCS_CORRELATION;
net_buf_add_u8(pkt_buf, lqi);
SYS_LOG_DBG("lqi %u\n", lqi);
}
#endif
SYS_LOG_DBG("Caught a packet (%u)\n", pkt_len - CC2520_FCS_LENGTH); SYS_LOG_DBG("Caught a packet (%u)\n", pkt_len - CC2520_FCS_LENGTH);
if (net_recv_data(cc2520->iface, buf) < 0) { if (net_recv_data(cc2520->iface, buf) < 0) {
@ -1038,8 +1059,15 @@ static struct ieee802154_radio_api cc2520_radio_api = {
.tx = cc2520_tx, .tx = cc2520_tx,
}; };
#if defined(CONFIG_TI_CC2520_RAW)
DEVICE_AND_API_INIT(cc2520, CONFIG_TI_CC2520_DRV_NAME,
cc2520_init, &cc2520_context_data, NULL,
APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
&cc2520_radio_api);
#else
NET_DEVICE_INIT(cc2520, CONFIG_TI_CC2520_DRV_NAME, NET_DEVICE_INIT(cc2520, CONFIG_TI_CC2520_DRV_NAME,
cc2520_init, &cc2520_context_data, NULL, cc2520_init, &cc2520_context_data, NULL,
CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
&cc2520_radio_api, IEEE802154_L2, &cc2520_radio_api, IEEE802154_L2,
NET_L2_GET_CTX_TYPE(IEEE802154_L2), 127); NET_L2_GET_CTX_TYPE(IEEE802154_L2), 127);
#endif