]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
usb: gadget: aspeed-vhub: Add ast2700 support
authorRyan Chen <ryan_chen@aspeedtech.com>
Fri, 28 Nov 2025 00:27:31 +0000 (08:27 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Dec 2025 13:42:05 +0000 (14:42 +0100)
Add support for the AST2700 SOC in the vhub gadget driver. AST2700
uses a 64-bit DMA addressing capability, so select 64-bit DMA mask
for compatible. AST2700 vhub also requires an reset line, so hook
up the optional reset control and assert/deassert it during probe
and remove.

Signed-off-by: Ryan Chen <ryan_chen@aspeedtech.com>
Link: https://patch.msgid.link/20251128-upstream_vhub-v2-2-1fa66a5833c2@aspeedtech.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/gadget/udc/aspeed-vhub/core.c
drivers/usb/gadget/udc/aspeed-vhub/vhub.h

index f2685f89b3e50a2ccb4d979744fb520533a8b90c..19c1849ae665d2216d22af4791c0e963be60e677 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/of.h>
 #include <linux/regmap.h>
 #include <linux/dma-mapping.h>
+#include <linux/reset.h>
 
 #include "vhub.h"
 
@@ -280,6 +281,8 @@ static void ast_vhub_remove(struct platform_device *pdev)
        if (vhub->clk)
                clk_disable_unprepare(vhub->clk);
 
+       reset_control_assert(vhub->rst);
+
        spin_unlock_irqrestore(&vhub->lock, flags);
 
        if (vhub->ep0_bufs)
@@ -294,6 +297,7 @@ static void ast_vhub_remove(struct platform_device *pdev)
 static int ast_vhub_probe(struct platform_device *pdev)
 {
        enum usb_device_speed max_speed;
+       const u64 *dma_mask_ptr;
        struct ast_vhub *vhub;
        struct resource *res;
        int i, rc = 0;
@@ -348,6 +352,16 @@ static int ast_vhub_probe(struct platform_device *pdev)
                goto err;
        }
 
+       vhub->rst = devm_reset_control_get_optional_shared(&pdev->dev, NULL);
+       if (IS_ERR(vhub->rst)) {
+               rc = PTR_ERR(vhub->rst);
+               goto err;
+       }
+
+       rc = reset_control_deassert(vhub->rst);
+       if (rc)
+               goto err;
+
        /* Check if we need to limit the HW to USB1 */
        max_speed = usb_get_maximum_speed(&pdev->dev);
        if (max_speed != USB_SPEED_UNKNOWN && max_speed < USB_SPEED_HIGH)
@@ -370,6 +384,12 @@ static int ast_vhub_probe(struct platform_device *pdev)
                goto err;
        }
 
+       dma_mask_ptr = (u64 *)of_device_get_match_data(&pdev->dev);
+       if (dma_mask_ptr) {
+               rc = dma_coerce_mask_and_coherent(&pdev->dev, *dma_mask_ptr);
+               if (rc)
+                       goto err;
+       }
        /*
         * Allocate DMA buffers for all EP0s in one chunk,
         * one per port and one for the vHub itself
@@ -412,15 +432,25 @@ static int ast_vhub_probe(struct platform_device *pdev)
        return rc;
 }
 
+static const u64 dma_mask_32 = DMA_BIT_MASK(32);
+static const u64 dma_mask_64 = DMA_BIT_MASK(64);
+
 static const struct of_device_id ast_vhub_dt_ids[] = {
        {
                .compatible = "aspeed,ast2400-usb-vhub",
+               .data = &dma_mask_32,
        },
        {
                .compatible = "aspeed,ast2500-usb-vhub",
+               .data = &dma_mask_32,
        },
        {
                .compatible = "aspeed,ast2600-usb-vhub",
+               .data = &dma_mask_32,
+       },
+       {
+               .compatible = "aspeed,ast2700-usb-vhub",
+               .data = &dma_mask_64,
        },
        { }
 };
index 6b9dfa6e10eb401919af23eaa999461ec66165cd..aca2050e2db0bca3503f777556219d831703e940 100644 (file)
@@ -388,6 +388,7 @@ struct ast_vhub {
        spinlock_t                      lock;
        struct work_struct              wake_work;
        struct clk                      *clk;
+       struct reset_control            *rst;
 
        /* EP0 DMA buffers allocated in one chunk */
        void                            *ep0_bufs;