Skip to content

Commit

Permalink
imxrt: add support for rt1050
Browse files Browse the repository at this point in the history
This change splits 10xx into 106x (copy) and extracts 105x. Modules such
as otp.c, console.c, timer.c and others come from the common 10xx
implementation, config.h, init.S and imxrt.[ch] hal are dedicated
separately for 105x and 106x.

The linker script for rt105x target have been adapted to the FlexRAM
configuration as follows: ITCM = 160 KiB, DTCM = 288 KiB, OCRAM = 64 KiB,
and FLASH = 8 MiB.

Because it carries code that was already implemented, it does not
introduce fixes related to MISRA

JIRA: RTOS-575
  • Loading branch information
gerard5 committed Aug 30, 2023
1 parent 14bef44 commit b0c20fa
Show file tree
Hide file tree
Showing 18 changed files with 2,938 additions and 32 deletions.
2 changes: 1 addition & 1 deletion devices/flash-flexspi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ifneq (, $(findstring imxrt117x, $(TARGET_SUBFAMILY)))
else ifneq (, $(findstring imxrt106x, $(TARGET_SUBFAMILY)))
FLEXSPI_OBJS += flashdrv.o nor/nor.o nor/nor_mx.o
else ifneq (, $(findstring imxrt105x, $(TARGET_SUBFAMILY)))
FLEXSPI_OBJS += flashdrv.o nor/nor.o hyperbus/hyper.o
FLEXSPI_OBJS += flashdrv.o nor/nor.o nor/nor_mx.o hyperbus/hyper.o
endif

OBJS += $(addprefix $(PREFIX_O)devices/flash-flexspi/, $(FLEXSPI_OBJS))
121 changes: 121 additions & 0 deletions devices/usbc-cdc/usbphy-imxrt105x.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/*
* Phoenix-RTOS
*
* Operating system loader
*
* i.MX RT106x USB physical layer controller
*
* Copyright 2021 Phoenix Systems
* Author: Hubert Buczynski
*
* This file is part of Phoenix-RTOS.
*
* %LICENSE%
*/

#include "client.h"
#include "usbphy.h"


/* clang-format off */

enum {
/* Power-Down Register */
usbphy_pwd, usbphy_pwd_set, usbphy_pwd_clr, usbphy_pwd_tog,
/* Transmitter & Receiver Control Registers */
usbphy_tx, usbphy_tx_set, usbphy_tx_clr, usbphy_tx_tog,
usbphy_rx, usbphy_rx_set, usbphy_rx_clr, usbphy_rx_tog,
/* General Control Register */
usbphy_ctrl, usbphy_ctrl_set, usbphy_ctrl_clr, usbphy_ctrl_tog,
/* USB Status & Debug Registers */
usbphy_status,
usbphy_debug = 20, usbphy_debug_set, usbphy_debug_clr, usbphy_debug_tog,
/* UTMI Status & Debug Registers */
usbphy_debug0_status, usbphy_debug1 = 28,
usbphy_debug1_set, usbphy_debug1_clr, usbphy_debug1_tog,
/* UTMI RTL */
usbphy_version
};

/* clang-format on */


struct {
u8 pool[USB_POOL_SIZE] __attribute__((aligned(USB_BUFFER_SIZE)));
size_t usedPools;
} phyusb_common;


void *usbclient_allocBuff(u32 size)
{
size_t org = USB_BUFFER_SIZE * phyusb_common.usedPools;

if ((size % USB_BUFFER_SIZE) != 0 || org + size > USB_POOL_SIZE)
return NULL;

phyusb_common.usedPools += size / USB_BUFFER_SIZE;

return &phyusb_common.pool[org];
}


void usbclient_buffReset(void)
{
phyusb_common.usedPools = 0;
}

void *phy_getBase(void)
{
return USB0_BASE_ADDR;
}


u32 phy_getIrq(void)
{
return USB0_IRQ;
}


static void phy_setClock(void)
{
_imxrt_setDevClock(pctl_clk_iomuxc, clk_state_run_wait);
_imxrt_setDevClock(pctl_clk_usboh3, clk_state_run_wait);
}


static void phy_initPad(void)
{
/* USB_OTG1_ID is an instance of anatop */
_imxrt_setIOisel(pctl_isel_anatop_usb_otg1_id, 0);

/* GPIO_AD_B0_01 is configured as USB_OTG1_ID (input) ALT3 */
_imxrt_setIOmux(pctl_mux_gpio_ad_b0_01, 0, 3);

/* IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B0_01 = 0x10b0 */
_imxrt_setIOpad(pctl_mux_gpio_ad_b0_01, 0, 0, 0, 1, 0, 2, 6, 0);
}


void phy_reset(void)
{
volatile u32 *usbphy = (u32 *)USB0_PHY_BASE_ADDR;

/* Reset PHY */
*(usbphy + usbphy_ctrl_set) = (1 << 31);

/* Enable clock and release the PHY from reset */
*(usbphy + usbphy_ctrl_clr) = (1 << 31) | (1 << 30);

/* Power up the PHY */
*(usbphy + usbphy_pwd) = 0;
}


void phy_init(void)
{
phyusb_common.usedPools = 0;

phy_setClock();
phy_initPad();
phy_reset();
}
24 changes: 24 additions & 0 deletions hal/armv7m/imxrt/10xx/105x/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# Makefile for Phoenix-RTOS loader (ARMv7M HAL imxrt105x)
#
# Copyright 2021 Phoenix Systems
#
# %LICENSE%
#

LDFLAGS:=$(filter-out -Tbss% , $(LDFLAGS))
LDFLAGS:=$(filter-out -Tdata% , $(LDFLAGS))

CFLAGS:=$(filter-out -mfloat-abi% , $(CFLAGS))
CFLAGS+= -mfloat-abi=soft

GCCLIB := $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)

PLO_COMMANDS = alias app call console copy dump echo erase go help kernel kernelimg map \
mem mpu otp phfs reboot script wait

include devices/usbc-cdc/Makefile
include devices/uart-imxrt106x/Makefile
include devices/flash-flexspi/Makefile

OBJS += $(addprefix $(PREFIX_O)hal/$(TARGET_SUFF)/imxrt/10xx/105x/, _init.o imxrt.o)
Loading

0 comments on commit b0c20fa

Please sign in to comment.