diff --git a/components/hal/CMakeLists.txt b/components/hal/CMakeLists.txt index b983fc1a0d..067ac01093 100644 --- a/components/hal/CMakeLists.txt +++ b/components/hal/CMakeLists.txt @@ -181,7 +181,6 @@ if(NOT BOOTLOADER_BUILD) if(CONFIG_SOC_USB_OTG_SUPPORTED) list(APPEND srcs - "usb_hal.c" "usb_dwc_hal.c" "usb_fsls_phy_hal.c") endif() diff --git a/components/hal/esp32s2/include/hal/usb_ll.h b/components/hal/esp32s2/include/hal/usb_ll.h deleted file mode 100644 index 2be637f55c..0000000000 --- a/components/hal/esp32s2/include/hal/usb_ll.h +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - -#include "soc/soc.h" -#include "soc/system_reg.h" -#include "soc/gpio_sig_map.h" -#include "soc/usb_periph.h" - -static inline void usb_ll_int_phy_enable(void) -{ - USB_WRAP.otg_conf.pad_enable = 1; - USB_WRAP.otg_conf.phy_sel = 0; -} - -static inline void usb_ll_ext_phy_enable(void) -{ - USB_WRAP.otg_conf.pad_enable = 1; - USB_WRAP.otg_conf.phy_sel = 1; -} - -static inline void usb_ll_int_phy_pullup_conf(bool dp_pu, bool dp_pd, bool dm_pu, bool dm_pd) -{ - usb_wrap_otg_conf_reg_t conf = USB_WRAP.otg_conf; - conf.pad_pull_override = 1; - conf.dp_pullup = dp_pu; - conf.dp_pulldown = dp_pd; - conf.dm_pullup = dm_pu; - conf.dm_pulldown = dm_pd; - USB_WRAP.otg_conf = conf; -} diff --git a/components/hal/esp32s3/include/hal/usb_ll.h b/components/hal/esp32s3/include/hal/usb_ll.h deleted file mode 100644 index 81950021d2..0000000000 --- a/components/hal/esp32s3/include/hal/usb_ll.h +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - -#include "soc/soc.h" -#include "soc/system_reg.h" -#include "soc/gpio_sig_map.h" -#include "soc/usb_periph.h" -#include "soc/rtc_cntl_struct.h" - -static inline void usb_ll_int_phy_enable(void) -{ - USB_WRAP.otg_conf.pad_enable = 1; - // USB_OTG use internal PHY - USB_WRAP.otg_conf.phy_sel = 0; - // phy_sel is controlled by the following register value - RTCCNTL.usb_conf.sw_hw_usb_phy_sel = 1; - // phy_sel=sw_usb_phy_sel=1, USB_OTG is connected with internal PHY - RTCCNTL.usb_conf.sw_usb_phy_sel = 1; -} - -static inline void usb_ll_ext_phy_enable(void) -{ - USB_WRAP.otg_conf.pad_enable = 1; - // USB_OTG use external PHY - USB_WRAP.otg_conf.phy_sel = 1; - // phy_sel is controlled by the following register value - RTCCNTL.usb_conf.sw_hw_usb_phy_sel = 1; - // phy_sel=sw_usb_phy_sel=0, USB_OTG is connected with external PHY through GPIO Matrix - RTCCNTL.usb_conf.sw_usb_phy_sel = 0; -} - -static inline void usb_ll_int_phy_pullup_conf(bool dp_pu, bool dp_pd, bool dm_pu, bool dm_pd) -{ - usb_wrap_otg_conf_reg_t conf = USB_WRAP.otg_conf; - conf.pad_pull_override = 1; - conf.dp_pullup = dp_pu; - conf.dp_pulldown = dp_pd; - conf.dm_pullup = dm_pu; - conf.dm_pulldown = dm_pd; - USB_WRAP.otg_conf = conf; -} diff --git a/components/hal/include/hal/usb_hal.h b/components/hal/include/hal/usb_hal.h deleted file mode 100644 index b79740932f..0000000000 --- a/components/hal/include/hal/usb_hal.h +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - bool use_external_phy; -} usb_hal_context_t; - -void usb_hal_init(usb_hal_context_t *usb); - - -#ifdef __cplusplus -} -#endif diff --git a/components/hal/usb_hal.c b/components/hal/usb_hal.c deleted file mode 100644 index 359f50d68a..0000000000 --- a/components/hal/usb_hal.c +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - -#include "hal/usb_ll.h" -#include "hal/usb_hal.h" - -void usb_hal_init(usb_hal_context_t *usb) -{ - if (usb->use_external_phy) { - usb_ll_ext_phy_enable(); - } else { - usb_ll_int_phy_enable(); - } -} diff --git a/components/soc/CMakeLists.txt b/components/soc/CMakeLists.txt index e8f8f4cccb..46212a3229 100644 --- a/components/soc/CMakeLists.txt +++ b/components/soc/CMakeLists.txt @@ -101,7 +101,7 @@ endif() if(CONFIG_SOC_USB_OTG_SUPPORTED) list(APPEND srcs "${target}/usb_periph.c" - "${target}/usb_otg_periph.c") + "${target}/usb_dwc_periph.c") endif() if(CONFIG_SOC_DAC_SUPPORTED) diff --git a/components/soc/esp32s2/include/soc/usb_pins.h b/components/soc/esp32s2/include/soc/usb_pins.h index 436df2baa6..8c837fed27 100644 --- a/components/soc/esp32s2/include/soc/usb_pins.h +++ b/components/soc/esp32s2/include/soc/usb_pins.h @@ -1,12 +1,18 @@ /* - * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #pragma once -/* GPIOs used to connect an external USB PHY */ +/* +Note: These macros are deprecated. When connecting USB OTG to an external FSLS +PHY, the FSLS Serial Interface signals can be routed to any GPIO via the GPIO +matrix. Thus, these macros are meaningless. + +Todo: Remove in IDF v6.0 (IDF-9029) +*/ #define USBPHY_VP_NUM 33 #define USBPHY_VM_NUM 34 #define USBPHY_RCV_NUM 35 diff --git a/components/soc/esp32s2/include/soc/usb_struct.h b/components/soc/esp32s2/include/soc/usb_struct.h index 14277b10e8..697c79e416 100644 --- a/components/soc/esp32s2/include/soc/usb_struct.h +++ b/components/soc/esp32s2/include/soc/usb_struct.h @@ -1,26 +1,41 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #include -#include "usb_types.h" #ifdef __cplusplus extern "C" { #endif +/* USB IN EP Register block type */ +typedef struct usb_in_ep_reg { + volatile uint32_t diepctl; + uint32_t reserved; + volatile uint32_t diepint; + uint32_t reserved1; + volatile uint32_t dieptsiz; + volatile uint32_t diepdma; + volatile uint32_t dtxfsts; + uint32_t reserved2; +} usb_in_endpoint_t; + +/* USB OUT EP Register block type */ +typedef struct usb_out_ep_reg { + volatile uint32_t doepctl; + uint32_t reserved; + volatile uint32_t doepint; + uint32_t reserved1; + volatile uint32_t doeptsiz; + volatile uint32_t doepdma; + uint32_t reserved2; + uint32_t reserved3; +} usb_out_endpoint_t; + typedef struct usb_reg { volatile uint32_t gotgctl; // 0x0000 OTG Control and Status Register volatile uint32_t gotgint; // 0x0004 OTG Interrupt Register @@ -82,10 +97,10 @@ typedef struct usb_reg { volatile uint32_t dtknqr4_fifoemptymsk; // 0x0834 Device IN Endpoint FIFO Empty Interrupt Mask register uint32_t reserved_0x0838_0x0900[50]; // 0x0838 to 0x0900 // Input Endpoints - usb_in_endpoint_t in_ep_reg[USB_IN_EP_NUM]; // 0x0900 to 0x09e0 IN EP registers + usb_in_endpoint_t in_ep_reg[7]; // 0x0900 to 0x09e0 IN EP registers uint32_t reserved_0x09e0_0x0b00[72]; // 0x09e0 to 0x0b00 // Output Endpoints - usb_out_endpoint_t out_ep_reg[USB_OUT_EP_NUM]; // 0x0b00 to 0x0be0 OUT EP registers + usb_out_endpoint_t out_ep_reg[7]; // 0x0b00 to 0x0be0 OUT EP registers uint32_t reserved_0x0be0_0x0d00[72]; // 0x0be0 to 0x0d00 uint32_t reserved_0x0d00_0x0e00[64]; // 0x0d00 to 0x0e00 /** diff --git a/components/soc/esp32s2/include/soc/usb_types.h b/components/soc/esp32s2/include/soc/usb_types.h deleted file mode 100644 index 69e213ec84..0000000000 --- a/components/soc/esp32s2/include/soc/usb_types.h +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#pragma once -#ifdef __cplusplus -extern "C" -{ -#endif - -#include - -/* USB IN EP index */ -typedef enum { - USB_IN_EP_0 = 0, - USB_IN_EP_1, - USB_IN_EP_2, - USB_IN_EP_3, - USB_IN_EP_4, - USB_IN_EP_5, - USB_IN_EP_6, - USB_IN_EP_NUM -} usb_in_ep_idx_t; - -/* USB OUT EP index */ -typedef enum { - USB_OUT_EP_0 = 0, - USB_OUT_EP_1, - USB_OUT_EP_2, - USB_OUT_EP_3, - USB_OUT_EP_4, - USB_OUT_EP_5, - USB_OUT_EP_6, - USB_OUT_EP_NUM -} usb_out_ep_idx_t; - -/* USB IN EP Register block type */ -typedef struct usb_in_ep_reg { - volatile uint32_t diepctl; - uint32_t reserved; - volatile uint32_t diepint; - uint32_t reserved1; - volatile uint32_t dieptsiz; - volatile uint32_t diepdma; - volatile uint32_t dtxfsts; - uint32_t reserved2; -} usb_in_endpoint_t; - -/* USB OUT EP Register block type */ -typedef struct usb_out_ep_reg { - volatile uint32_t doepctl; - uint32_t reserved; - volatile uint32_t doepint; - uint32_t reserved1; - volatile uint32_t doeptsiz; - volatile uint32_t doepdma; - uint32_t reserved2; - uint32_t reserved3; -} usb_out_endpoint_t; - -#ifdef __cplusplus -} -#endif diff --git a/components/soc/esp32s2/usb_otg_periph.c b/components/soc/esp32s2/usb_dwc_periph.c similarity index 91% rename from components/soc/esp32s2/usb_otg_periph.c rename to components/soc/esp32s2/usb_dwc_periph.c index e2f96e23b6..eba3eaaf60 100644 --- a/components/soc/esp32s2/usb_otg_periph.c +++ b/components/soc/esp32s2/usb_dwc_periph.c @@ -1,10 +1,10 @@ /* - * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ -#include "soc/usb_otg_periph.h" +#include "soc/usb_dwc_periph.h" #include "soc/gpio_sig_map.h" /* diff --git a/components/soc/esp32s2/usb_periph.c b/components/soc/esp32s2/usb_periph.c index 2f55335feb..a3fda7193e 100644 --- a/components/soc/esp32s2/usb_periph.c +++ b/components/soc/esp32s2/usb_periph.c @@ -1,20 +1,19 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #include "soc/soc_caps.h" #include "soc/usb_periph.h" +/* +Note: These IO pins are deprecated. When connecting USB OTG to an external FSLS +PHY, the FSLS Serial Interface signals can be routed to any GPIO via the GPIO +matrix. Thus, this mapping of signals to IO pins is meaningless. + +Todo: Remove in IDF v6.0 (IDF-9029) +*/ const usb_iopin_dsc_t usb_periph_iopins[] = { {USBPHY_VP_NUM, USB_EXTPHY_VP_IDX, 0, 1}, {USBPHY_VM_NUM, USB_EXTPHY_VM_IDX, 0, 1}, diff --git a/components/soc/esp32s3/include/soc/usb_pins.h b/components/soc/esp32s3/include/soc/usb_pins.h index 7407b0a615..7b82a1b440 100644 --- a/components/soc/esp32s3/include/soc/usb_pins.h +++ b/components/soc/esp32s3/include/soc/usb_pins.h @@ -1,12 +1,18 @@ /* - * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #pragma once -/* GPIOs used to connect an external USB PHY */ +/* +Note: These macros are deprecated. When connecting USB OTG to an external FSLS +PHY, the FSLS Serial Interface signals can be routed to any GPIO via the GPIO +matrix. Thus, these macros are meaningless. + +Todo: Remove in IDF v6.0 (IDF-9029) +*/ #define USBPHY_VP_NUM 42 #define USBPHY_VM_NUM 41 #define USBPHY_RCV_NUM 21 diff --git a/components/soc/esp32s3/include/soc/usb_struct.h b/components/soc/esp32s3/include/soc/usb_struct.h index d9645f1cb5..697c79e416 100644 --- a/components/soc/esp32s3/include/soc/usb_struct.h +++ b/components/soc/esp32s3/include/soc/usb_struct.h @@ -1,27 +1,41 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #include -#include "usb_types.h" -#include #ifdef __cplusplus extern "C" { #endif +/* USB IN EP Register block type */ +typedef struct usb_in_ep_reg { + volatile uint32_t diepctl; + uint32_t reserved; + volatile uint32_t diepint; + uint32_t reserved1; + volatile uint32_t dieptsiz; + volatile uint32_t diepdma; + volatile uint32_t dtxfsts; + uint32_t reserved2; +} usb_in_endpoint_t; + +/* USB OUT EP Register block type */ +typedef struct usb_out_ep_reg { + volatile uint32_t doepctl; + uint32_t reserved; + volatile uint32_t doepint; + uint32_t reserved1; + volatile uint32_t doeptsiz; + volatile uint32_t doepdma; + uint32_t reserved2; + uint32_t reserved3; +} usb_out_endpoint_t; + typedef struct usb_reg { volatile uint32_t gotgctl; // 0x0000 OTG Control and Status Register volatile uint32_t gotgint; // 0x0004 OTG Interrupt Register @@ -83,10 +97,10 @@ typedef struct usb_reg { volatile uint32_t dtknqr4_fifoemptymsk; // 0x0834 Device IN Endpoint FIFO Empty Interrupt Mask register uint32_t reserved_0x0838_0x0900[50]; // 0x0838 to 0x0900 // Input Endpoints - usb_in_endpoint_t in_ep_reg[USB_IN_EP_NUM]; // 0x0900 to 0x09e0 IN EP registers + usb_in_endpoint_t in_ep_reg[7]; // 0x0900 to 0x09e0 IN EP registers uint32_t reserved_0x09e0_0x0b00[72]; // 0x09e0 to 0x0b00 // Output Endpoints - usb_out_endpoint_t out_ep_reg[USB_OUT_EP_NUM]; // 0x0b00 to 0x0be0 OUT EP registers + usb_out_endpoint_t out_ep_reg[7]; // 0x0b00 to 0x0be0 OUT EP registers uint32_t reserved_0x0be0_0x0d00[72]; // 0x0be0 to 0x0d00 uint32_t reserved_0x0d00_0x0e00[64]; // 0x0d00 to 0x0e00 /** diff --git a/components/soc/esp32s3/include/soc/usb_types.h b/components/soc/esp32s3/include/soc/usb_types.h deleted file mode 100644 index 69e213ec84..0000000000 --- a/components/soc/esp32s3/include/soc/usb_types.h +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#pragma once -#ifdef __cplusplus -extern "C" -{ -#endif - -#include - -/* USB IN EP index */ -typedef enum { - USB_IN_EP_0 = 0, - USB_IN_EP_1, - USB_IN_EP_2, - USB_IN_EP_3, - USB_IN_EP_4, - USB_IN_EP_5, - USB_IN_EP_6, - USB_IN_EP_NUM -} usb_in_ep_idx_t; - -/* USB OUT EP index */ -typedef enum { - USB_OUT_EP_0 = 0, - USB_OUT_EP_1, - USB_OUT_EP_2, - USB_OUT_EP_3, - USB_OUT_EP_4, - USB_OUT_EP_5, - USB_OUT_EP_6, - USB_OUT_EP_NUM -} usb_out_ep_idx_t; - -/* USB IN EP Register block type */ -typedef struct usb_in_ep_reg { - volatile uint32_t diepctl; - uint32_t reserved; - volatile uint32_t diepint; - uint32_t reserved1; - volatile uint32_t dieptsiz; - volatile uint32_t diepdma; - volatile uint32_t dtxfsts; - uint32_t reserved2; -} usb_in_endpoint_t; - -/* USB OUT EP Register block type */ -typedef struct usb_out_ep_reg { - volatile uint32_t doepctl; - uint32_t reserved; - volatile uint32_t doepint; - uint32_t reserved1; - volatile uint32_t doeptsiz; - volatile uint32_t doepdma; - uint32_t reserved2; - uint32_t reserved3; -} usb_out_endpoint_t; - -#ifdef __cplusplus -} -#endif diff --git a/components/soc/esp32s3/usb_otg_periph.c b/components/soc/esp32s3/usb_dwc_periph.c similarity index 91% rename from components/soc/esp32s3/usb_otg_periph.c rename to components/soc/esp32s3/usb_dwc_periph.c index e2f96e23b6..eba3eaaf60 100644 --- a/components/soc/esp32s3/usb_otg_periph.c +++ b/components/soc/esp32s3/usb_dwc_periph.c @@ -1,10 +1,10 @@ /* - * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ -#include "soc/usb_otg_periph.h" +#include "soc/usb_dwc_periph.h" #include "soc/gpio_sig_map.h" /* diff --git a/components/soc/esp32s3/usb_periph.c b/components/soc/esp32s3/usb_periph.c index 2f55335feb..a3fda7193e 100644 --- a/components/soc/esp32s3/usb_periph.c +++ b/components/soc/esp32s3/usb_periph.c @@ -1,20 +1,19 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #include "soc/soc_caps.h" #include "soc/usb_periph.h" +/* +Note: These IO pins are deprecated. When connecting USB OTG to an external FSLS +PHY, the FSLS Serial Interface signals can be routed to any GPIO via the GPIO +matrix. Thus, this mapping of signals to IO pins is meaningless. + +Todo: Remove in IDF v6.0 (IDF-9029) +*/ const usb_iopin_dsc_t usb_periph_iopins[] = { {USBPHY_VP_NUM, USB_EXTPHY_VP_IDX, 0, 1}, {USBPHY_VM_NUM, USB_EXTPHY_VM_IDX, 0, 1}, diff --git a/components/soc/include/soc/usb_dwc_periph.h b/components/soc/include/soc/usb_dwc_periph.h new file mode 100644 index 0000000000..d13286aa1d --- /dev/null +++ b/components/soc/include/soc/usb_dwc_periph.h @@ -0,0 +1,46 @@ +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once +#include +#include "soc/soc_caps.h" +#include "soc/periph_defs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* + Stores a bunch of USB-peripheral data. +*/ +typedef struct { + const uint8_t extphy_vp_in; + const uint8_t extphy_vm_in; + const uint8_t extphy_rcv_in; + const uint8_t extphy_oen_out; + const uint8_t extphy_vpo_out; + const uint8_t extphy_vmo_out; + const uint8_t extphy_suspend_in; + const uint8_t extphy_speed_in; + const uint8_t srp_bvalid_in; + const uint8_t srp_sessend_in; + const uint8_t srp_chrgvbus_out; + const uint8_t srp_dischrgvbus_out; + const uint8_t otg_iddig_in; + const uint8_t otg_avalid_in; + const uint8_t otg_vbusvalid_in; + const uint8_t otg_idpullup_out; + const uint8_t otg_dppulldown_out; + const uint8_t otg_dmpulldown_out; + const uint8_t otg_drvvbus_out; + const periph_module_t module; +} usb_phy_signal_conn_t; + +extern const usb_phy_signal_conn_t usb_otg_periph_signal; + +#ifdef __cplusplus +} +#endif diff --git a/components/soc/include/soc/usb_otg_periph.h b/components/soc/include/soc/usb_otg_periph.h index d13286aa1d..be92ac4eb1 100644 --- a/components/soc/include/soc/usb_otg_periph.h +++ b/components/soc/include/soc/usb_otg_periph.h @@ -1,46 +1,12 @@ /* - * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #pragma once -#include -#include "soc/soc_caps.h" -#include "soc/periph_defs.h" -#ifdef __cplusplus -extern "C" { -#endif +/* Todo: Remove in ESP-IDF v6.0 (IDF-9052) */ +#warning "This header is deprecated, please use usb_dwc_periph.h instead" -/* - Stores a bunch of USB-peripheral data. -*/ -typedef struct { - const uint8_t extphy_vp_in; - const uint8_t extphy_vm_in; - const uint8_t extphy_rcv_in; - const uint8_t extphy_oen_out; - const uint8_t extphy_vpo_out; - const uint8_t extphy_vmo_out; - const uint8_t extphy_suspend_in; - const uint8_t extphy_speed_in; - const uint8_t srp_bvalid_in; - const uint8_t srp_sessend_in; - const uint8_t srp_chrgvbus_out; - const uint8_t srp_dischrgvbus_out; - const uint8_t otg_iddig_in; - const uint8_t otg_avalid_in; - const uint8_t otg_vbusvalid_in; - const uint8_t otg_idpullup_out; - const uint8_t otg_dppulldown_out; - const uint8_t otg_dmpulldown_out; - const uint8_t otg_drvvbus_out; - const periph_module_t module; -} usb_phy_signal_conn_t; - -extern const usb_phy_signal_conn_t usb_otg_periph_signal; - -#ifdef __cplusplus -} -#endif +#include "soc/usb_dwc_periph.h" diff --git a/components/soc/include/soc/usb_periph.h b/components/soc/include/soc/usb_periph.h index 1f0adb36b5..cd2672e79a 100644 --- a/components/soc/include/soc/usb_periph.h +++ b/components/soc/include/soc/usb_periph.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -10,18 +10,21 @@ #include #include "soc/soc_pins.h" #include "soc/gpio_sig_map.h" -#include "soc/usb_reg.h" -#include "soc/usb_types.h" -#include "soc/usb_struct.h" -#include "soc/usb_wrap_reg.h" -#include "soc/usb_wrap_struct.h" #ifdef __cplusplus extern "C" { #endif +#if SOC_USB_OTG_SUPPORTED + /** - * @brief A pin descriptor for init + * @brief A pin descriptor for init (DEPRECATED) + * + * Todo: Remove in IDF v6.0 (IDF-9029) + * + * @note These IO pins are deprecated. When connecting USB OTG to an external + * FSLS PHY, the FSLS Serial Interface signals can be routed to any GPIO via the + * GPI0 matrix. Thus, this mapping of signals to IO pins is meaningless. */ typedef struct { const int pin; @@ -32,6 +35,8 @@ typedef struct { extern const usb_iopin_dsc_t usb_periph_iopins[]; +#endif // SOC_USB_OTG_SUPPORTED + #ifdef __cplusplus } #endif diff --git a/components/usb/usb_phy.c b/components/usb/usb_phy.c index 991bc4803d..0e36500f5e 100644 --- a/components/usb/usb_phy.c +++ b/components/usb/usb_phy.c @@ -11,7 +11,7 @@ #include "esp_check.h" #include "esp_private/periph_ctrl.h" #include "esp_private/usb_phy.h" -#include "soc/usb_otg_periph.h" +#include "soc/usb_dwc_periph.h" #include "hal/usb_fsls_phy_hal.h" #include "hal/usb_fsls_phy_ll.h" #include "esp_rom_gpio.h" diff --git a/examples/peripherals/usb/host/msc/main/msc_example_main.c b/examples/peripherals/usb/host/msc/main/msc_example_main.c index c37107a39d..d6e4dc2153 100644 --- a/examples/peripherals/usb/host/msc/main/msc_example_main.c +++ b/examples/peripherals/usb/host/msc/main/msc_example_main.c @@ -18,7 +18,6 @@ #include "ffconf.h" #include "esp_vfs.h" #include "errno.h" -#include "hal/usb_hal.h" #include "driver/gpio.h" #include diff --git a/tools/ci/check_copyright_ignore.txt b/tools/ci/check_copyright_ignore.txt index 8f286358df..15adc2ac92 100644 --- a/tools/ci/check_copyright_ignore.txt +++ b/tools/ci/check_copyright_ignore.txt @@ -878,15 +878,12 @@ components/soc/esp32s2/include/soc/touch_sensor_pins.h components/soc/esp32s2/include/soc/uart_pins.h components/soc/esp32s2/include/soc/uart_reg.h components/soc/esp32s2/include/soc/uhci_reg.h -components/soc/esp32s2/include/soc/usb_struct.h -components/soc/esp32s2/include/soc/usb_types.h components/soc/esp32s2/include/soc/usb_wrap_reg.h components/soc/esp32s2/include/soc/usb_wrap_struct.h components/soc/esp32s2/include/soc/usbh_struct.h components/soc/esp32s2/include/soc/wdev_reg.h components/soc/esp32s2/ledc_periph.c components/soc/esp32s2/uart_periph.c -components/soc/esp32s2/usb_periph.c components/soc/esp32s3/dedic_gpio_periph.c components/soc/esp32s3/i2c_periph.c components/soc/esp32s3/include/soc/apb_ctrl_reg.h @@ -950,8 +947,6 @@ components/soc/esp32s3/include/soc/uart_struct.h components/soc/esp32s3/include/soc/uhci_reg.h components/soc/esp32s3/include/soc/uhci_struct.h components/soc/esp32s3/include/soc/usb_serial_jtag_struct.h -components/soc/esp32s3/include/soc/usb_struct.h -components/soc/esp32s3/include/soc/usb_types.h components/soc/esp32s3/include/soc/usb_wrap_reg.h components/soc/esp32s3/include/soc/usb_wrap_struct.h components/soc/esp32s3/include/soc/usbh_struct.h @@ -960,7 +955,6 @@ components/soc/esp32s3/ledc_periph.c components/soc/esp32s3/sdio_slave_periph.c components/soc/esp32s3/sdmmc_periph.c components/soc/esp32s3/uart_periph.c -components/soc/esp32s3/usb_periph.c components/soc/include/soc/dedic_gpio_periph.h components/soc/include/soc/emac_periph.h components/soc/include/soc/gpio_periph.h