Skip to content
Permalink
Browse files

soc: ti_simplelink: add support for TI CC13x2 / CC26x2 series

Add initial support for the TI CC13x2 / CC26x2 series with the CC2652R
and CC1352R SoCs. The UART and GPIO peripherals are supported. Drivers
use the driverlib HAL from the TI CC13x2 / CC26x2 SDK.

Signed-off-by: Brett Witherspoon <spoonb@cdspooner.com>
  • Loading branch information...
bwitherspoon authored and galak committed Apr 18, 2019
1 parent e490be3 commit f101b77db298f800f8804b41bfd4c74807faab19
Showing with 1,299 additions and 0 deletions.
  1. +1 −0 drivers/gpio/CMakeLists.txt
  2. +2 −0 drivers/gpio/Kconfig
  3. +13 −0 drivers/gpio/Kconfig.cc13xx_cc26xx
  4. +256 −0 drivers/gpio/gpio_cc13xx_cc26xx.c
  5. +1 −0 drivers/pinmux/CMakeLists.txt
  6. +2 −0 drivers/pinmux/Kconfig
  7. +12 −0 drivers/pinmux/Kconfig.cc13xx_cc26xx
  8. +89 −0 drivers/pinmux/pinmux_cc13xx_cc26xx.c
  9. +1 −0 drivers/serial/CMakeLists.txt
  10. +2 −0 drivers/serial/Kconfig
  11. +29 −0 drivers/serial/Kconfig.cc13xx_cc26xx
  12. +464 −0 drivers/serial/uart_cc13xx_cc26xx.c
  13. +18 −0 dts/arm/ti/cc1352r.dtsi
  14. +75 −0 dts/arm/ti/cc13x2_cc26x2.dtsi
  15. +18 −0 dts/arm/ti/cc2652r.dtsi
  16. +44 −0 dts/bindings/gpio/ti,cc13xx-cc26xx-gpio.yaml
  17. +32 −0 dts/bindings/pinctrl/ti,cc13xx-cc26xx-pinmux.yaml
  18. +43 −0 dts/bindings/serial/ti,cc13xx-cc26xx-uart.yaml
  19. +11 −0 ext/hal/ti/simplelink/source/ti/devices/cc13x2_cc26x2/CMakeLists.txt
  20. +5 −0 soc/arm/ti_simplelink/cc13x2_cc26x2/CMakeLists.txt
  21. +14 −0 soc/arm/ti_simplelink/cc13x2_cc26x2/Kconfig.defconfig.cc1352r
  22. +14 −0 soc/arm/ti_simplelink/cc13x2_cc26x2/Kconfig.defconfig.cc2652r
  23. +49 −0 soc/arm/ti_simplelink/cc13x2_cc26x2/Kconfig.defconfig.series
  24. +16 −0 soc/arm/ti_simplelink/cc13x2_cc26x2/Kconfig.series
  25. +18 −0 soc/arm/ti_simplelink/cc13x2_cc26x2/Kconfig.soc
  26. +11 −0 soc/arm/ti_simplelink/cc13x2_cc26x2/dts_fixup.h
  27. +8 −0 soc/arm/ti_simplelink/cc13x2_cc26x2/linker.ld
  28. +21 −0 soc/arm/ti_simplelink/cc13x2_cc26x2/soc.c
  29. +30 −0 soc/arm/ti_simplelink/cc13x2_cc26x2/soc.h
@@ -4,6 +4,7 @@ zephyr_library()

zephyr_library_sources_ifdef(CONFIG_GPIO_ALTERA_NIOS2 gpio_altera_nios2.c)
zephyr_library_sources_ifdef(CONFIG_GPIO_ATMEL_SAM3 gpio_atmel_sam3.c)
zephyr_library_sources_ifdef(CONFIG_GPIO_CC13XX_CC26XX gpio_cc13xx_cc26xx.c)
zephyr_library_sources_ifdef(CONFIG_GPIO_CC2650 gpio_cc2650.c)
zephyr_library_sources_ifdef(CONFIG_GPIO_CC32XX gpio_cc32xx.c)
zephyr_library_sources_ifdef(CONFIG_GPIO_CMSDK_AHB gpio_cmsdk_ahb.c)
@@ -46,6 +46,8 @@ source "drivers/gpio/Kconfig.nrfx"

source "drivers/gpio/Kconfig.cmsdk_ahb"

source "drivers/gpio/Kconfig.cc13xx_cc26xx"

source "drivers/gpio/Kconfig.cc32xx"

source "drivers/gpio/Kconfig.sifive"
@@ -0,0 +1,13 @@
# Kconfig.cc13xx_cc26xx - TI CC13xx / CC26xx GPIO configuration options
#
# Copyright (c) 2019 Brett Witherspoon
#
# SPDX-License-Identifier: Apache-2.0
#

config GPIO_CC13XX_CC26XX
bool "TI SimpleLink CC13xx / CC26xx GPIO driver"
depends on SOC_SERIES_CC13X2_CC26X2
select HAS_DTS_GPIO
help
Enable the TI SimpleLink CC13xx / CC26xx GPIO driver.
@@ -0,0 +1,256 @@
/*
* Copyright (c) 2019 Brett Witherspoon
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/types.h>
#include <misc/__assert.h>
#include <device.h>
#include <errno.h>
#include <gpio.h>

#include <driverlib/gpio.h>
#include <driverlib/interrupt.h>
#include <driverlib/ioc.h>
#include <driverlib/prcm.h>

#include "gpio_utils.h"

struct gpio_cc13xx_cc26xx_data {
sys_slist_t callbacks;
u32_t pin_callback_enables;
};

static struct gpio_cc13xx_cc26xx_data gpio_cc13xx_cc26xx_data_0;

static int gpio_cc13xx_cc26xx_config(struct device *port, int access_op,
u32_t pin, int flags)
{
u32_t config;

if (access_op != GPIO_ACCESS_BY_PIN)
return -ENOTSUP;

__ASSERT_NO_MSG(pin < NUM_IO_MAX);

config = IOC_CURRENT_2MA | IOC_STRENGTH_AUTO | IOC_SLEW_DISABLE |
IOC_NO_WAKE_UP;

if (flags & GPIO_INT) {
__ASSERT_NO_MSG((flags & GPIO_DIR_MASK) == GPIO_DIR_IN);

config |= IOC_INT_ENABLE | IOC_INPUT_ENABLE;

if (flags & GPIO_INT_EDGE) {
if (flags & GPIO_INT_DOUBLE_EDGE) {
config |= IOC_BOTH_EDGES;
} else if (flags & GPIO_INT_ACTIVE_LOW) {
config |= IOC_FALLING_EDGE;
} else {
config |= IOC_RISING_EDGE;
}
} else {
return -ENOTSUP;
}

config |= (flags & GPIO_INT_DEBOUNCE) ? IOC_HYST_ENABLE :
IOC_HYST_DISABLE;
} else {
config |= IOC_INT_DISABLE | IOC_NO_EDGE | IOC_HYST_DISABLE;
config |= (flags & GPIO_DIR_MASK) == GPIO_DIR_IN ?
IOC_INPUT_ENABLE :
IOC_INPUT_DISABLE;
}

config |= (flags & GPIO_POL_MASK) == GPIO_POL_INV ? IOC_IOMODE_INV :
IOC_IOMODE_NORMAL;

switch (flags & GPIO_PUD_MASK) {
case GPIO_PUD_NORMAL:
config |= IOC_NO_IOPULL;
break;
case GPIO_PUD_PULL_UP:
config |= IOC_IOPULL_UP;
break;
case GPIO_PUD_PULL_DOWN:
config |= IOC_IOPULL_DOWN;
break;
default:
return -EINVAL;
}

IOCPortConfigureSet(pin, IOC_PORT_GPIO, config);

if ((flags & GPIO_DIR_MASK) == GPIO_DIR_IN) {
GPIO_setOutputEnableDio(pin, GPIO_OUTPUT_DISABLE);
} else {
GPIO_setOutputEnableDio(pin, GPIO_OUTPUT_ENABLE);
}

return 0;
}

static int gpio_cc13xx_cc26xx_write(struct device *port, int access_op,
u32_t pin, u32_t value)
{
switch (access_op) {
case GPIO_ACCESS_BY_PIN:
__ASSERT_NO_MSG(pin < NUM_IO_MAX);
if (value) {
GPIO_setDio(pin);
} else {
GPIO_clearDio(pin);
}
break;
case GPIO_ACCESS_BY_PORT:
if (value) {
GPIO_setMultiDio(GPIO_DIO_ALL_MASK);
} else {
GPIO_clearMultiDio(GPIO_DIO_ALL_MASK);
}
break;
default:
return -EINVAL;
}

return 0;
}

static int gpio_cc13xx_cc26xx_read(struct device *port, int access_op,
u32_t pin, u32_t *value)
{
__ASSERT_NO_MSG(value != NULL);

switch (access_op) {
case GPIO_ACCESS_BY_PIN:
__ASSERT_NO_MSG(pin < NUM_IO_MAX);
*value = GPIO_readDio(pin);
break;
case GPIO_ACCESS_BY_PORT:
*value = GPIO_readMultiDio(GPIO_DIO_ALL_MASK);
break;
default:
return -EINVAL;
}

return 0;
}

static int gpio_cc13xx_cc26xx_manage_callback(struct device *port,
struct gpio_callback *callback,
bool set)
{
struct gpio_cc13xx_cc26xx_data *data = port->driver_data;

return gpio_manage_callback(&data->callbacks, callback, set);
}

static int gpio_cc13xx_cc26xx_enable_callback(struct device *port,
int access_op, u32_t pin)
{
struct gpio_cc13xx_cc26xx_data *data = port->driver_data;

switch (access_op) {
case GPIO_ACCESS_BY_PIN:
__ASSERT_NO_MSG(pin < NUM_IO_MAX);
data->pin_callback_enables |= (1 << pin);
break;
case GPIO_ACCESS_BY_PORT:
data->pin_callback_enables = 0xFFFFFFFF;
break;
default:
return -EINVAL;
}

return 0;
}

static int gpio_cc13xx_cc26xx_disable_callback(struct device *port,
int access_op, u32_t pin)
{
struct gpio_cc13xx_cc26xx_data *data = port->driver_data;

switch (access_op) {
case GPIO_ACCESS_BY_PIN:
__ASSERT_NO_MSG(pin < NUM_IO_MAX);
data->pin_callback_enables &= ~(1 << pin);
break;
case GPIO_ACCESS_BY_PORT:
data->pin_callback_enables = 0U;
break;
default:
return -EINVAL;
}

return 0;
}

static u32_t gpio_cc13xx_cc26xx_get_pending_int(struct device *dev)
{
return GPIO_getEventMultiDio(GPIO_DIO_ALL_MASK);
}

DEVICE_DECLARE(gpio_cc13xx_cc26xx);

static void gpio_cc13xx_cc26xx_isr(void *arg)
{
struct device *dev = arg;
struct gpio_cc13xx_cc26xx_data *data = dev->driver_data;

u32_t status = GPIO_getEventMultiDio(GPIO_DIO_ALL_MASK);
u32_t enabled = status & data->pin_callback_enables;

GPIO_clearEventMultiDio(status);

gpio_fire_callbacks(&data->callbacks, dev, enabled);
}

static int gpio_cc13xx_cc26xx_init(struct device *dev)
{
struct gpio_cc13xx_cc26xx_data *data = dev->driver_data;

/* Enable peripheral power domain */
PRCMPowerDomainOn(PRCM_DOMAIN_PERIPH);

/* Enable GPIO peripheral */
PRCMPeripheralRunEnable(PRCM_PERIPH_GPIO);

/* Load PRCM settings */
PRCMLoadSet();
while (!PRCMLoadGet()) {
continue;
}

/* Enable IRQ */
IRQ_CONNECT(DT_TI_CC13XX_CC26XX_GPIO_0_IRQ_0,
DT_TI_CC13XX_CC26XX_GPIO_0_IRQ_0_PRIORITY,
gpio_cc13xx_cc26xx_isr, DEVICE_GET(gpio_cc13xx_cc26xx), 0);
irq_enable(DT_TI_CC13XX_CC26XX_GPIO_0_IRQ_0);

/* Disable callbacks */
data->pin_callback_enables = 0;

/* Peripheral should not be accessed until power domain is on. */
while (PRCMPowerDomainStatus(PRCM_DOMAIN_PERIPH) !=
PRCM_DOMAIN_POWER_ON) {
continue;
}

return 0;
}

static const struct gpio_driver_api gpio_cc13xx_cc26xx_driver_api = {
.config = gpio_cc13xx_cc26xx_config,
.write = gpio_cc13xx_cc26xx_write,
.read = gpio_cc13xx_cc26xx_read,
.manage_callback = gpio_cc13xx_cc26xx_manage_callback,
.enable_callback = gpio_cc13xx_cc26xx_enable_callback,
.disable_callback = gpio_cc13xx_cc26xx_disable_callback,
.get_pending_int = gpio_cc13xx_cc26xx_get_pending_int
};

DEVICE_AND_API_INIT(gpio_cc13xx_cc26xx, DT_TI_CC13XX_CC26XX_GPIO_0_LABEL,
gpio_cc13xx_cc26xx_init, &gpio_cc13xx_cc26xx_data_0, NULL,
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
&gpio_cc13xx_cc26xx_driver_api);
@@ -1,6 +1,7 @@
# SPDX-License-Identifier: Apache-2.0

# Board initialization
zephyr_sources_ifdef(CONFIG_PINMUX_CC13XX_CC26XX pinmux_cc13xx_cc26xx.c)
zephyr_sources_ifdef(CONFIG_PINMUX_CC2650 pinmux_cc2650.c)
zephyr_sources_ifdef(CONFIG_PINMUX_ESP32 pinmux_esp32.c)
zephyr_sources_ifdef(CONFIG_PINMUX_SIFIVE pinmux_sifive.c)
@@ -49,6 +49,8 @@ source "drivers/pinmux/Kconfig.beetle"

source "drivers/pinmux/Kconfig.sifive"

source "drivers/pinmux/Kconfig.cc13xx_cc26xx"

source "drivers/pinmux/Kconfig.cc2650"

source "drivers/pinmux/Kconfig.esp32"
@@ -0,0 +1,12 @@
# Kconfig.cc13xx_cc26xx - TI CC13xx / CC26xx PINMUX configuration options
#
# Copyright (c) 2019 Brett Witherspoon
#
# SPDX-License-Identifier: Apache-2.0
#

config PINMUX_CC13XX_CC26XX
bool "TI SimpleLink CC13xx / CC26xx pinmux driver"
depends on SOC_SERIES_CC13X2_CC26X2
help
Enable the TI SimpleLink CC13xx / CC26xx pinmux driver.

0 comments on commit f101b77

Please sign in to comment.
You can’t perform that action at this time.