Skip to content

Commit

Permalink
dts: bindings: cc13xx-cc26xx: add port info for uart tx and rx pins
Browse files Browse the repository at this point in the history
Adding port information for uart tx and rx pins in dts, so that it can
be more systematically retrieved in the uart driver.

Signed-off-by: Vincent Wan <[email protected]>
  • Loading branch information
vanti authored and galak committed Apr 23, 2020
1 parent 9d89ce1 commit 9849882
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 14 deletions.
11 changes: 9 additions & 2 deletions boards/arm/cc1352r1_launchxl/cc1352r1_launchxl.dts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
#include <ti/cc1352r.dtsi>
#include "boosterpack_connector.dtsi"

/*
* Define some constants from driverlib/ioc.h in TI HAL,
* since we don't have a way to include the file directly.
*/
#define IOC_PORT_MCU_UART0_TX 0x00000010
#define IOC_PORT_MCU_UART0_RX 0x0000000F

#define BTN_GPIO_FLAGS (GPIO_ACTIVE_LOW | GPIO_PULL_UP)

/ {
Expand Down Expand Up @@ -69,8 +76,8 @@
&uart0 {
status = "okay";
current-speed = <115200>;
tx-pin = <13>;
rx-pin = <12>;
tx-pin = <13 IOC_PORT_MCU_UART0_TX>;
rx-pin = <12 IOC_PORT_MCU_UART0_RX>;
};

&i2c0 {
Expand Down
11 changes: 9 additions & 2 deletions boards/arm/cc26x2r1_launchxl/cc26x2r1_launchxl.dts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
#include <ti/cc2652r.dtsi>
#include "boosterpack_connector.dtsi"

/*
* Define some constants from driverlib/ioc.h in TI HAL,
* since we don't have a way to include the file directly.
*/
#define IOC_PORT_MCU_UART0_TX 0x00000010
#define IOC_PORT_MCU_UART0_RX 0x0000000F

#define BTN_GPIO_FLAGS (GPIO_ACTIVE_LOW | GPIO_PULL_UP)

/ {
Expand Down Expand Up @@ -69,8 +76,8 @@
&uart0 {
status = "okay";
current-speed = <115200>;
tx-pin = <3>;
rx-pin = <2>;
tx-pin = <3 IOC_PORT_MCU_UART0_TX>;
rx-pin = <2 IOC_PORT_MCU_UART0_RX>;
};

&i2c0 {
Expand Down
21 changes: 13 additions & 8 deletions drivers/serial/uart_cc13xx_cc26xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
#include <ti/drivers/Power.h>
#include <ti/drivers/power/PowerCC26X2.h>

#define GET_PIN(n, pin_name) \
DT_INST_PROP_BY_IDX(n, pin_name, 0)
#define GET_PORT(n, pin_name) \
DT_INST_PROP_BY_IDX(n, pin_name, 1)

struct uart_cc13xx_cc26xx_data {
struct uart_config uart_config;
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
Expand Down Expand Up @@ -534,10 +539,10 @@ static int uart_cc13xx_cc26xx_init_0(struct device *dev)
}
#endif
/* Configure IOC module to map UART signals to pins */
IOCPortConfigureSet(DT_PROP(DT_NODELABEL(uart0), tx_pin),
IOC_PORT_MCU_UART0_TX, IOC_STD_OUTPUT);
IOCPortConfigureSet(DT_PROP(DT_NODELABEL(uart0), rx_pin),
IOC_PORT_MCU_UART0_RX, IOC_STD_INPUT);
IOCPortConfigureSet(GET_PIN(0, tx_pin), GET_PORT(0, tx_pin),
IOC_STD_OUTPUT);
IOCPortConfigureSet(GET_PIN(0, rx_pin), GET_PORT(0, rx_pin),
IOC_STD_INPUT);

/* Configure and enable UART */
ret = uart_cc13xx_cc26xx_configure(dev,
Expand Down Expand Up @@ -637,10 +642,10 @@ static int uart_cc13xx_cc26xx_init_1(struct device *dev)
#endif

/* Configure IOC module to map UART signals to pins */
IOCPortConfigureSet(DT_PROP(DT_NODELABEL(uart1), tx_pin),
IOC_PORT_MCU_UART1_TX, IOC_STD_OUTPUT);
IOCPortConfigureSet(DT_PROP(DT_NODELABEL(uart1), rx_pin),
IOC_PORT_MCU_UART1_RX, IOC_STD_INPUT);
IOCPortConfigureSet(GET_PIN(1, tx_pin), GET_PORT(1, tx_pin),
IOC_STD_OUTPUT);
IOCPortConfigureSet(GET_PIN(1, rx_pin), GET_PORT(1, rx_pin),
IOC_STD_INPUT);

/* Configure and enable UART */
ret = uart_cc13xx_cc26xx_configure(dev,
Expand Down
4 changes: 2 additions & 2 deletions dts/bindings/serial/ti,cc13xx-cc26xx-uart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ properties:
required: true

tx-pin:
type: int
type: array
required: true
description: TX pin

rx-pin:
type: int
type: array
required: true
description: RX pin

0 comments on commit 9849882

Please sign in to comment.