Skip to content

Commit 6f0c2cf

Browse files
authored
Merge pull request #1224 from hathach/chipidea-controller
rename transdimension to chipidea
2 parents 821c0a9 + 94c35de commit 6f0c2cf

File tree

15 files changed

+1088
-119
lines changed

15 files changed

+1088
-119
lines changed

docs/reference/supported.rst

Lines changed: 101 additions & 111 deletions
Large diffs are not rendered by default.

examples/host/cdc_msc_hid/Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ SRC_C += \
2020
src/host/hub.c \
2121
src/host/usbh.c \
2222
src/host/usbh_control.c \
23-
src/portable/ehci/ehci.c \
2423
src/portable/ohci/ohci.c \
25-
src/portable/nxp/transdimension/hcd_transdimension.c \
2624
src/portable/nxp/lpc17_40/hcd_lpc17_40.c
2725

2826
include ../../rules.mk

examples/host/hid_controller/Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ SRC_C += \
2323
src/host/hub.c \
2424
src/host/usbh.c \
2525
src/host/usbh_control.c \
26-
src/portable/ehci/ehci.c \
2726
src/portable/ohci/ohci.c \
28-
src/portable/nxp/transdimension/hcd_transdimension.c \
2927
src/portable/nxp/lpc17_40/hcd_lpc17_40.c
3028

3129
include ../../rules.mk

hw/bsp/ea4357/board.mk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ MCU_DIR = hw/mcu/nxp/lpcopen/lpc43xx/lpc_chip_43xx
2121
LD_FILE = hw/bsp/$(BOARD)/lpc4357.ld
2222

2323
SRC_C += \
24-
src/portable/nxp/transdimension/dcd_transdimension.c \
24+
src/portable/chipidea/ci_hs/dcd_ci_hs.c \
25+
src/portable/chipidea/ci_hs/hcd_ci_hs.c \
26+
src/portable/ehci/ehci.c \
2527
$(MCU_DIR)/../gcc/cr_startup_lpc43xx.c \
2628
$(MCU_DIR)/src/chip_18xx_43xx.c \
2729
$(MCU_DIR)/src/clock_18xx_43xx.c \

hw/bsp/imxrt/family.mk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ LDFLAGS += \
2828
-Wl,--defsym,__stack_size__=0x800 \
2929

3030
SRC_C += \
31-
src/portable/nxp/transdimension/dcd_transdimension.c \
31+
src/portable/chipidea/ci_hs/dcd_ci_hs.c \
32+
src/portable/chipidea/ci_hs/hcd_ci_hs.c \
33+
src/portable/ehci/ehci.c \
3234
$(MCU_DIR)/system_$(MCU_VARIANT).c \
3335
$(MCU_DIR)/xip/fsl_flexspi_nor_boot.c \
3436
$(MCU_DIR)/project_template/clock_config.c \

hw/bsp/lpc18/family.mk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ CFLAGS += -Wno-error=unused-parameter -Wno-error=strict-prototypes -Wno-error=ca
1818
MCU_DIR = hw/mcu/nxp/lpcopen/lpc18xx/lpc_chip_18xx
1919

2020
SRC_C += \
21-
src/portable/nxp/transdimension/dcd_transdimension.c \
21+
src/portable/chipidea/ci_hs/dcd_ci_hs.c \
22+
src/portable/chipidea/ci_hs/hcd_ci_hs.c \
23+
src/portable/ehci/ehci.c \
2224
$(MCU_DIR)/../gcc/cr_startup_lpc18xx.c \
2325
$(MCU_DIR)/src/chip_18xx_43xx.c \
2426
$(MCU_DIR)/src/clock_18xx_43xx.c \

hw/bsp/ngx4330/board.mk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ MCU_DIR = hw/mcu/nxp/lpcopen/lpc43xx/lpc_chip_43xx
2121
LD_FILE = hw/bsp/$(BOARD)/ngx4330.ld
2222

2323
SRC_C += \
24-
src/portable/nxp/transdimension/dcd_transdimension.c \
24+
src/portable/chipidea/ci_hs/dcd_ci_hs.c \
25+
src/portable/chipidea/ci_hs/hcd_ci_hs.c \
26+
src/portable/ehci/ehci.c \
2527
$(MCU_DIR)/../gcc/cr_startup_lpc43xx.c \
2628
$(MCU_DIR)/src/chip_18xx_43xx.c \
2729
$(MCU_DIR)/src/clock_18xx_43xx.c \

src/device/dcd_attr.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444

4545
#elif TU_CHECK_MCU(OPT_MCU_LPC18XX, OPT_MCU_LPC43XX)
4646
// TODO USB0 has 6, USB1 has 4
47+
#define DCD_ATTR_CONTROLLER_CHIPIDEA_HS
4748
#define DCD_ATTR_ENDPOINT_MAX 6
4849

4950
#elif TU_CHECK_MCU(OPT_MCU_LPC51UXX)
@@ -58,6 +59,7 @@
5859
#define DCD_ATTR_ENDPOINT_MAX 6
5960

6061
#elif TU_CHECK_MCU(OPT_MCU_MIMXRT10XX)
62+
#define DCD_ATTR_CONTROLLER_CHIPIDEA_HS
6163
#define DCD_ATTR_ENDPOINT_MAX 8
6264

6365
#elif TU_CHECK_MCU(OPT_MCU_MKL25ZXX, OPT_MCU_K32L2BXX)
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2021, Ha Thach (tinyusb.org)
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*
24+
* This file is part of the TinyUSB stack.
25+
*/
26+
27+
#ifndef _CI_HS_IMXRT_H_
28+
#define _CI_HS_IMXRT_H_
29+
30+
#include "fsl_device_registers.h"
31+
32+
static const ci_hs_controller_t _ci_controller[] =
33+
{
34+
// RT1010 and RT1020 only has 1 USB controller
35+
#if FSL_FEATURE_SOC_USBHS_COUNT == 1
36+
{ .reg_base = USB_BASE , .irqnum = USB_OTG1_IRQn, .ep_count = 8 }
37+
#else
38+
{ .reg_base = USB1_BASE, .irqnum = USB_OTG1_IRQn, .ep_count = 8 },
39+
{ .reg_base = USB2_BASE, .irqnum = USB_OTG2_IRQn, .ep_count = 8 }
40+
#endif
41+
};
42+
43+
#define CI_DCD_INT_ENABLE(_p) NVIC_EnableIRQ (_ci_controller[_p].irqnum)
44+
#define CI_DCD_INT_DISABLE(_p) NVIC_DisableIRQ(_ci_controller[_p].irqnum)
45+
46+
#define CI_HCD_INT_ENABLE(_p) NVIC_EnableIRQ (_ci_controller[_p].irqnum)
47+
#define CI_HCD_INT_DISABLE(_p) NVIC_DisableIRQ(_ci_controller[_p].irqnum)
48+
49+
50+
#endif
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2021, Ha Thach (tinyusb.org)
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*
24+
* This file is part of the TinyUSB stack.
25+
*/
26+
27+
#ifndef _CI_HS_LPC18_43_H_
28+
#define _CI_HS_LPC18_43_H_
29+
30+
// LPCOpen for 18xx & 43xx
31+
#include "chip.h"
32+
33+
static const ci_hs_controller_t _ci_controller[] =
34+
{
35+
{ .reg_base = LPC_USB0_BASE, .irqnum = USB0_IRQn, .ep_count = 6 },
36+
{ .reg_base = LPC_USB1_BASE, .irqnum = USB1_IRQn, .ep_count = 4 }
37+
};
38+
39+
#define CI_DCD_INT_ENABLE(_p) NVIC_EnableIRQ (_ci_controller[_p].irqnum)
40+
#define CI_DCD_INT_DISABLE(_p) NVIC_DisableIRQ(_ci_controller[_p].irqnum)
41+
42+
#define CI_HCD_INT_ENABLE(_p) NVIC_EnableIRQ (_ci_controller[_p].irqnum)
43+
#define CI_HCD_INT_DISABLE(_p) NVIC_DisableIRQ(_ci_controller[_p].irqnum)
44+
45+
#endif
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2021, Ha Thach (tinyusb.org)
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*
24+
* This file is part of the TinyUSB stack.
25+
*/
26+
27+
#ifndef CI_HS_TYPE_H_
28+
#define CI_HS_TYPE_H_
29+
30+
#ifdef __cplusplus
31+
extern "C" {
32+
#endif
33+
34+
// USBCMD
35+
enum {
36+
USBCMD_RUN_STOP = TU_BIT(0),
37+
USBCMD_RESET = TU_BIT(1),
38+
USBCMD_SETUP_TRIPWIRE = TU_BIT(13),
39+
USBCMD_ADD_QTD_TRIPWIRE = TU_BIT(14) ///< This bit is used as a semaphore to ensure the to proper addition of a new dTD to an active (primed) endpoint’s linked list. This bit is set and cleared by software during the process of adding a new dTD
40+
// Interrupt Threshold bit 23:16
41+
};
42+
43+
// PORTSC1
44+
#define PORTSC1_PORT_SPEED_POS 26
45+
46+
enum {
47+
PORTSC1_CURRENT_CONNECT_STATUS = TU_BIT(0),
48+
PORTSC1_FORCE_PORT_RESUME = TU_BIT(6),
49+
PORTSC1_SUSPEND = TU_BIT(7),
50+
PORTSC1_FORCE_FULL_SPEED = TU_BIT(24),
51+
PORTSC1_PORT_SPEED = TU_BIT(26) | TU_BIT(27)
52+
};
53+
54+
// OTGSC
55+
enum {
56+
OTGSC_VBUS_DISCHARGE = TU_BIT(0),
57+
OTGSC_VBUS_CHARGE = TU_BIT(1),
58+
// OTGSC_HWASSIST_AUTORESET = TU_BIT(2),
59+
OTGSC_OTG_TERMINATION = TU_BIT(3), ///< Must set to 1 when OTG go to device mode
60+
OTGSC_DATA_PULSING = TU_BIT(4),
61+
OTGSC_ID_PULLUP = TU_BIT(5),
62+
// OTGSC_HWASSIT_DATA_PULSE = TU_BIT(6),
63+
// OTGSC_HWASSIT_BDIS_ACONN = TU_BIT(7),
64+
OTGSC_ID = TU_BIT(8), ///< 0 = A device, 1 = B Device
65+
OTGSC_A_VBUS_VALID = TU_BIT(9),
66+
OTGSC_A_SESSION_VALID = TU_BIT(10),
67+
OTGSC_B_SESSION_VALID = TU_BIT(11),
68+
OTGSC_B_SESSION_END = TU_BIT(12),
69+
OTGSC_1MS_TOGGLE = TU_BIT(13),
70+
OTGSC_DATA_BUS_PULSING_STATUS = TU_BIT(14),
71+
};
72+
73+
// USBMode
74+
enum {
75+
USBMODE_CM_DEVICE = 2,
76+
USBMODE_CM_HOST = 3,
77+
78+
USBMODE_SLOM = TU_BIT(3),
79+
USBMODE_SDIS = TU_BIT(4),
80+
81+
USBMODE_VBUS_POWER_SELECT = TU_BIT(5), // Need to be enabled for LPC18XX/43XX in host mode
82+
};
83+
84+
// Device Registers
85+
typedef struct
86+
{
87+
//------------- ID + HW Parameter Registers-------------//
88+
volatile uint32_t TU_RESERVED[64]; ///< For iMX RT10xx, but not used by LPC18XX/LPC43XX
89+
90+
//------------- Capability Registers-------------//
91+
volatile uint8_t CAPLENGTH; ///< Capability Registers Length
92+
volatile uint8_t TU_RESERVED[1];
93+
volatile uint16_t HCIVERSION; ///< Host Controller Interface Version
94+
95+
volatile uint32_t HCSPARAMS; ///< Host Controller Structural Parameters
96+
volatile uint32_t HCCPARAMS; ///< Host Controller Capability Parameters
97+
volatile uint32_t TU_RESERVED[5];
98+
99+
volatile uint16_t DCIVERSION; ///< Device Controller Interface Version
100+
volatile uint8_t TU_RESERVED[2];
101+
102+
volatile uint32_t DCCPARAMS; ///< Device Controller Capability Parameters
103+
volatile uint32_t TU_RESERVED[6];
104+
105+
//------------- Operational Registers -------------//
106+
volatile uint32_t USBCMD; ///< USB Command Register
107+
volatile uint32_t USBSTS; ///< USB Status Register
108+
volatile uint32_t USBINTR; ///< Interrupt Enable Register
109+
volatile uint32_t FRINDEX; ///< USB Frame Index
110+
volatile uint32_t TU_RESERVED;
111+
volatile uint32_t DEVICEADDR; ///< Device Address
112+
volatile uint32_t ENDPTLISTADDR; ///< Endpoint List Address
113+
volatile uint32_t TU_RESERVED;
114+
volatile uint32_t BURSTSIZE; ///< Programmable Burst Size
115+
volatile uint32_t TXFILLTUNING; ///< TX FIFO Fill Tuning
116+
uint32_t TU_RESERVED[4];
117+
volatile uint32_t ENDPTNAK; ///< Endpoint NAK
118+
volatile uint32_t ENDPTNAKEN; ///< Endpoint NAK Enable
119+
volatile uint32_t TU_RESERVED;
120+
volatile uint32_t PORTSC1; ///< Port Status & Control
121+
volatile uint32_t TU_RESERVED[7];
122+
volatile uint32_t OTGSC; ///< On-The-Go Status & control
123+
volatile uint32_t USBMODE; ///< USB Device Mode
124+
volatile uint32_t ENDPTSETUPSTAT; ///< Endpoint Setup Status
125+
volatile uint32_t ENDPTPRIME; ///< Endpoint Prime
126+
volatile uint32_t ENDPTFLUSH; ///< Endpoint Flush
127+
volatile uint32_t ENDPTSTAT; ///< Endpoint Status
128+
volatile uint32_t ENDPTCOMPLETE; ///< Endpoint Complete
129+
volatile uint32_t ENDPTCTRL[8]; ///< Endpoint Control 0 - 7
130+
} ci_hs_regs_t;
131+
132+
133+
typedef struct
134+
{
135+
uint32_t reg_base;
136+
uint32_t irqnum;
137+
uint8_t ep_count; // Max bi-directional Endpoints
138+
}ci_hs_controller_t;
139+
140+
#ifdef __cplusplus
141+
}
142+
#endif
143+
144+
#endif /* CI_HS_TYPE_H_ */

0 commit comments

Comments
 (0)