Skip to content
Permalink
Browse files

boards: mec15xxevb_assy6853: Use the pinmux api

Use the generic pinmux APIs provided by zephyr to select
alternate functions.

This also contains a fix for a formatting issue in the
documentation for this board. Additionally, the serial
console is now on UART2.

Signed-off-by: Francisco Munoz <francisco.munoz.ruiz@intel.com>
  • Loading branch information...
franciscomunoz authored and nashif committed May 15, 2019
1 parent 9506794 commit bce16753af1b7e5e99512fe0c9c08e4fd6027207
@@ -10,11 +10,33 @@ config BOARD

if UART_NS16550

config UART_NS16550_PORT_0
config UART_NS16550_PORT_2
def_bool y if UART_CONSOLE

endif

if PINMUX_XEC

config PINMUX_XEC_GPIO000_036
default y

config PINMUX_XEC_GPIO040_076
default n

config PINMUX_XEC_GPIO100_136
default y

config PINMUX_XEC_GPIO140_176
default y

config PINMUX_XEC_GPIO200_236
default n

config PINMUX_XEC_GPIO240_276
default n

endif # PINMUX_XEC

if GPIO_XEC

config GPIO_XEC_GPIO000_036
@@ -134,7 +134,7 @@ Boot-ROM Straps.

These jumpers configure MEC1501 Boot-ROM straps.

+-------------+---------- -+--------------+-------------+
+-------------+------------+--------------+-------------+
| JP93 | JP11 | JP46 | JP96 |
| (CMP_STRAP) | (CR_STRAP) | (VTR2_STRAP) | (BSS_STRAP) |
+=============+============+==============+=============+
@@ -148,26 +148,28 @@ loads from SHD SPI.
Peripheral Routing Jumpers
--------------------------

Each column of the following table illustrates how to enable UART0, JTAG,
Each column of the following table illustrates how to enable SWD,
PVT SPI, SHD SPI and LED0-2 respectively.

+---------+--------+-----------+----------+---------+
| JP68 | JP9 | JP38 | JP98 | JP41 |
| (UART0) | (JTAG) | (PVT SPI) | (SHD SPI)| (LED0-2)|
| JP9 | JP9 | JP38 | JP98 | JP41 |
| (UART2) | (SWD) | (PVT SPI) | (SHD SPI)| (LED0-2)|
+=========+========+===========+==========+=========+
| 1-2 | 2-3 | 2-3 | 2-3 | 1-2 |
| | 2-3 | 2-3 | 2-3 | 1-2 |
+---------+--------+-----------+----------+---------+
| 4-5 | 5-6 | 5-6 | 5-6 | 3-4 |
| 4-5 | | 5-6 | 5-6 | 3-4 |
+---------+--------+-----------+----------+---------+
| 8-9 | 8-9 | 8-9 | 8-9 | 5-6 |
| | 8-9 | 8-9 | 8-9 | 5-6 |
+---------+--------+-----------+----------+---------+
| | 11-12 | 11-12 | 11-12 | |
| 10-11 | | 11-12 | 11-12 | |
+---------+--------+-----------+----------+---------+
| | | 14-15 | 14-15 | |
+---------+--------+-----------+----------+---------+
| | | 17-18 | 20-21 | |
+---------+--------+-----------+----------+---------+

An additional setting for UART2 is to make sure JP39 does not have any jumper.

Jumper settings for MEC1501 144WFBGA Socket DC Assy 6883 Rev B1p0
=================================================================

@@ -238,7 +240,7 @@ Flashing
- Stop bits: 1

#. Connect the MEC15xxEVB_ASSY_6853 board to your host computer using the
UART0 port. Then build :ref: `hello_world` application. It is important
UART2 port. Then build :ref: `hello_world` application. It is important
to generate a binary with a new load address, for example do the following::

${OBJCOPY} --change-addresses -0xe0000 -O binary -S ${in_elf} ${out_bin}
@@ -14,12 +14,12 @@

chosen {
zephyr,sram = &sram0;
zephyr,console = &uart0;
zephyr,console = &uart2;
zephyr,flash = &flash0;
};
};

&uart0 {
&uart2 {
status = "ok";
current-speed = <115200>;
};
@@ -14,6 +14,7 @@ CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=48000000
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
CONFIG_SERIAL=y
CONFIG_PINMUX=y
CONFIG_GPIO=y

CONFIG_I2C=y
@@ -7,68 +7,76 @@
#include <device.h>
#include <init.h>
#include <kernel.h>
#include <pinmux.h>

#include "soc.h"

#define UART_GPIO_CFG \
(MCHP_GPIO_CTRL_PUD_NONE + MCHP_GPIO_CTRL_PWRG_VTR_IO +\
MCHP_GPIO_CTRL_IDET_DISABLE + MCHP_GPIO_CTRL_BUFT_PUSHPULL +\
MCHP_GPIO_CTRL_DIR_INPUT + MCHP_GPIO_CTRL_AOD_DIS +\
MCHP_GPIO_CTRL_POL_NON_INVERT)

#define GPIO_CFG_OUT \
(MCHP_GPIO_CTRL_PUD_NONE + MCHP_GPIO_CTRL_PWRG_VTR_IO +\
MCHP_GPIO_CTRL_IDET_DISABLE + MCHP_GPIO_CTRL_BUFT_PUSHPULL +\
MCHP_GPIO_CTRL_DIR_OUTPUT + MCHP_GPIO_CTRL_AOD_DIS +\
MCHP_GPIO_CTRL_POL_NON_INVERT)

static int board_pinmux_init(struct device *dev)
{
ARG_UNUSED(dev);

/* See table 2-4 from the Data sheet*/
#ifdef CONFIG_UART_NS16550_PORT_0
/* Set muxing, for UART 0 and power up */
mchp_pcr_periph_slp_ctrl(PCR_UART0, MCHP_PCR_SLEEP_DIS);

UART0_REGS->CFG_SEL = (MCHP_UART_LD_CFG_INTCLK +
MCHP_UART_LD_CFG_RESET_SYS + MCHP_UART_LD_CFG_NO_INVERT);
UART0_REGS->ACTV = MCHP_UART_LD_ACTIVATE;

GPIO_CTRL_REGS->CTRL_0104 = UART_GPIO_CFG + MCHP_GPIO_CTRL_MUX_F1;
GPIO_CTRL_REGS->CTRL_0105 = UART_GPIO_CFG + MCHP_GPIO_CTRL_MUX_F1;
#ifdef CONFIG_PINMUX_XEC_GPIO000_036
struct device *porta =
device_get_binding(CONFIG_PINMUX_XEC_GPIO000_036_NAME);
#endif
#ifdef CONFIG_PINMUX_XEC_GPIO040_076
struct device *portb =
device_get_binding(CONFIG_PINMUX_XEC_GPIO040_076_NAME);
#endif
#ifdef CONFIG_PINMUX_XEC_GPIO100_136
struct device *portc =
device_get_binding(CONFIG_PINMUX_XEC_GPIO100_136_NAME);
#endif
#ifdef CONFIG_PINMUX_XEC_GPIO140_176
struct device *portd =
device_get_binding(CONFIG_PINMUX_XEC_GPIO140_176_NAME);
#endif
#ifdef CONFIG_PINMUX_XEC_GPIO200_236
struct device *porte =
device_get_binding(CONFIG_PINMUX_XEC_GPIO200_236_NAME);
#endif
#ifdef CONFIG_PINMUX_XEC_GPIO240_276
struct device *portf =
device_get_binding(CONFIG_PINMUX_XEC_GPIO240_276_NAME);
#endif

/* Release JTAG TDI and JTAG TDO pins so they can be
* controlled by their respective PCR register (UART2).
* For more details see table 44-1
*/
ECS_REGS->DEBUG_CTRL |= 0x4;

#ifdef CONFIG_UART_NS16550_PORT_1
/* Set muxing, for UART 1 and power up */
mchp_pcr_periph_slp_ctrl(PCR_UART1, MCHP_PCR_SLEEP_DIS);
/* See table 2-4 from the data sheet for pin multiplexing*/
#ifdef CONFIG_UART_NS16550_PORT_2
/* Set muxing, for UART 2 TX/RX and power up */
mchp_pcr_periph_slp_ctrl(PCR_UART2, MCHP_PCR_SLEEP_DIS);

UART1_REGS->CFG_SEL = (MCHP_UART_LD_CFG_INTCLK +
UART2_REGS->CFG_SEL = (MCHP_UART_LD_CFG_INTCLK +
MCHP_UART_LD_CFG_RESET_SYS + MCHP_UART_LD_CFG_NO_INVERT);
UART1_REGS->ACTV = MCHP_UART_LD_ACTIVATE;
UART2_REGS->ACTV = MCHP_UART_LD_ACTIVATE;

GPIO_CTRL_REGS->CTRL_0170 = UART_GPIO_CFG + MCHP_GPIO_CTRL_MUX_F1;
GPIO_CTRL_REGS->CTRL_0171 = UART_GPIO_CFG + MCHP_GPIO_CTRL_MUX_F1;
pinmux_pin_set(portd, MCHP_GPIO_145, MCHP_GPIO_CTRL_MUX_F2);
pinmux_pin_set(portd, MCHP_GPIO_146, MCHP_GPIO_CTRL_MUX_F2);
#endif

#ifdef CONFIG_I2C_XEC_0
/* Set muxing, for I2C0 - SMB00 */
GPIO_CTRL_REGS->CTRL_0004 = MCHP_GPIO_CTRL_MUX_F1;
GPIO_CTRL_REGS->CTRL_0003 = MCHP_GPIO_CTRL_MUX_F1;
pinmux_pin_set(porta, MCHP_GPIO_003, MCHP_GPIO_CTRL_MUX_F1);
pinmux_pin_set(porta, MCHP_GPIO_004, MCHP_GPIO_CTRL_MUX_F1);
#endif

#ifdef CONFIG_I2C_XEC_1
/* Set muxing for I2C1 - SMB01 */
GPIO_CTRL_REGS->CTRL_0130 = MCHP_GPIO_CTRL_MUX_F1;
GPIO_CTRL_REGS->CTRL_0131 = MCHP_GPIO_CTRL_MUX_F1;
pinmux_pin_set(portc, MCHP_GPIO_130, MCHP_GPIO_CTRL_MUX_F1);
pinmux_pin_set(portc, MCHP_GPIO_131, MCHP_GPIO_CTRL_MUX_F1);
#endif

#ifdef CONFIG_I2C_XEC_2
/* Set muxing, for I2C2 - SMB04 */
GPIO_CTRL_REGS->CTRL_0143 = MCHP_GPIO_CTRL_MUX_F1;
GPIO_CTRL_REGS->CTRL_0144 = MCHP_GPIO_CTRL_MUX_F1;
pinmux_pin_set(portd, MCHP_GPIO_143, MCHP_GPIO_CTRL_MUX_F1);
pinmux_pin_set(portd, MCHP_GPIO_144, MCHP_GPIO_CTRL_MUX_F1);
#endif
return 0;
}

SYS_INIT(board_pinmux_init, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
SYS_INIT(board_pinmux_init, PRE_KERNEL_1, CONFIG_PINMUX_INIT_PRIORITY);

0 comments on commit bce1675

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