Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp166104rdb; Mon, 18 Sep 2023 11:07:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEeNG7mO3OPtwNueJ8SPdS7+WBQKqoKQl11n7fuEtgTKRdjJQXHxkK/tyV42THjdO2LIqcr X-Received: by 2002:a17:902:e5d1:b0:1c3:c5b5:8a94 with SMTP id u17-20020a170902e5d100b001c3c5b58a94mr9978668plf.18.1695060446927; Mon, 18 Sep 2023 11:07:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1695060446; cv=pass; d=google.com; s=arc-20160816; b=sQ0UqCvTO5kdgUJ07wnM692FeON3p8CwQE+AhMu0y9woKcv1uhxBJTJTuLYZ1kP7sw SEcQJCbJyNBqW8YhnUYn0tuDFi4bIo5XC2RQb+w7GkZIiJtMD+XMgDt1Z2RreZkjiKX3 rsUzlSx6MUrZvWpErr9WeprBVxEt6yPij4MeAAlspg0SxQBMW32g+KdvqObAEq5SKrJu 0n6CVPbi4p3EB109qxNXK/uoQ6eqZqhxPFaC2TsWkFHAW+j4c2pu1/OLFGTFZFl11A7f DFic5FS4DqpiTQp4U5QI6txHzJ1bpSgWVgMcZueG75qAIUZm1KmYOHBtMQyPDi+nOgG2 +x4w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=DOqOMGTmJpthW2Uqreeehqg9BcUS8kh3LUPBQksWZN8=; fh=S2Yd6ZWf4PE3UWmHWDKlbLbWMSMC5tewAeJBwAWxIdQ=; b=sWMtCfjA2rz7ZilxwF73yA5+sPU5ptXEuTHWCxm4uUlU3BlO6LHr2tmNzK2z5/1Hr6 v2dvTToLnJhqaM6L0ArNZyKg2WGa7Z4tjOYicD8TsUiGbbz7qvZ4FFAr6RqVaOg9ngcf 9BpPM+4mQR1VvnwQb2P/kl8BDeTevtCtqbF6Fu1IDv9CMvJ4KkwHn3AXRW2ATEriWfi8 jeLRBiPD/A+cNTtt215ZlB0zrRkXVpzRgE28F2Ev7xXvgFd/3jBZAZjxkKjDFenbCdZd 3UpN4+yIeBdgSSyPwgP65j7ILIjwNmJugR/3qImU3pNWErGpQv6qTr0XkvXOP2GT/QZR CgqQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nuvoton.onmicrosoft.com header.s=selector2-nuvoton-onmicrosoft-com header.b=sG6vJwd+; arc=pass (i=1 spf=pass spfdomain=nuvoton.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id x14-20020a170902a38e00b001c56dc2f6ccsi2010848pla.155.2023.09.18.11.07.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 11:07:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@nuvoton.onmicrosoft.com header.s=selector2-nuvoton-onmicrosoft-com header.b=sG6vJwd+; arc=pass (i=1 spf=pass spfdomain=nuvoton.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 2C79480417C1; Mon, 18 Sep 2023 10:00:40 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231460AbjIRRAf (ORCPT + 99 others); Mon, 18 Sep 2023 13:00:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231374AbjIRRAX (ORCPT ); Mon, 18 Sep 2023 13:00:23 -0400 Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2082.outbound.protection.outlook.com [40.107.117.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A75F95; Mon, 18 Sep 2023 10:00:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y8KdJNMikKJfObxRyfgFNzmd/33RBk5rUhHc9X2Vs5R5zxqYCAogrgwFqCH2ofcVUkwFEQh0BYaWu+I8X/eTvaxRxuG5b7ZHFPamYhzY3SXAt/qdO1bo9jgBaKETiWMxryWMMOav+kJrXKx/UNqxnZQIt9RK2ArVHreotO8CCfhqN4fNWqCiae3OSGc2E4HDQBoKFXGe/+IW9x7oNW9zAzi6zGRbh4u6HyZCpHgOxpgWWSTBsQLd9IdoLuaL0QQ8aaRKRqfYx4UI7He4fV12OEYcaM+zzl+rsSKPvtEgXgJvaJTxcdz5qFb06FMdJc3pt0IIAY4uG6CsA3/NCWoz+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=DOqOMGTmJpthW2Uqreeehqg9BcUS8kh3LUPBQksWZN8=; b=Zyj51pizDmNUxisZB5KfosHDwH4oHBCEJnBhk/wpcN7SBjHuAJi5rcyTJmLO8xQ9PTCABe6MDrCCEPYj23D6Em3dUn2RgV9XENWYpKbJCpEe6TIwzlj3x0Q5+v6DJPCnEpoNcRcO1BRt4hBu6tSO0uI+G1mFmGlmqlLKI+Y0KIMdOIvTWMGDMCE018oxfJRRwHsUcdgOa0nI6YOsxGDzjFwH2RItwIsKrFgdxobu2tvgFH4uUeO9P259CpwbL7Wibylstdelth3Ro59tZwzHkHtLdIDkijwp3jcTIcRCXplxsidhk543vYUBqcmTthrciOHqFDWnySj8lJQfhoqXgQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 175.98.123.7) smtp.rcpttodomain=gmail.com smtp.mailfrom=nuvoton.com; dmarc=fail (p=none sp=quarantine pct=100) action=none header.from=gmail.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuvoton.onmicrosoft.com; s=selector2-nuvoton-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DOqOMGTmJpthW2Uqreeehqg9BcUS8kh3LUPBQksWZN8=; b=sG6vJwd+qBbmkCXSjiIRXgX5lbmoKbwGWVaOtaQUUMWZffde1Gam3LS/ypmGfeZ1d+oJRMRMm1fhwKleWeYnj/ndMrojcgJk3m+8R8DZRhKwqtAQrzW/pjmWa/s3h3nMHNmcagSDp9iKZC7BffWKpAZcALj6EUt+i5kA2vlJfcg= Received: from SI2PR02CA0054.apcprd02.prod.outlook.com (2603:1096:4:196::13) by SEYPR03MB7697.apcprd03.prod.outlook.com (2603:1096:101:147::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27; Mon, 18 Sep 2023 17:00:09 +0000 Received: from SG2PEPF000B66CB.apcprd03.prod.outlook.com (2603:1096:4:196:cafe::54) by SI2PR02CA0054.outlook.office365.com (2603:1096:4:196::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.26 via Frontend Transport; Mon, 18 Sep 2023 17:00:09 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 175.98.123.7) smtp.mailfrom=nuvoton.com; dkim=none (message not signed) header.d=none;dmarc=fail action=none header.from=gmail.com; Received-SPF: Pass (protection.outlook.com: domain of nuvoton.com designates 175.98.123.7 as permitted sender) receiver=protection.outlook.com; client-ip=175.98.123.7; helo=NTHCCAS04.nuvoton.com; pr=C Received: from NTHCCAS04.nuvoton.com (175.98.123.7) by SG2PEPF000B66CB.mail.protection.outlook.com (10.167.240.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.6792.20 via Frontend Transport; Mon, 18 Sep 2023 17:00:09 +0000 Received: from NTHCML01B.nuvoton.com (10.1.8.178) by NTHCCAS04.nuvoton.com (10.1.8.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.14; Tue, 19 Sep 2023 01:00:04 +0800 Received: from NTHCCAS01.nuvoton.com (10.1.8.28) by NTHCML01B.nuvoton.com (10.1.8.178) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Tue, 19 Sep 2023 01:00:03 +0800 Received: from taln60.nuvoton.co.il (10.191.1.180) by NTHCCAS01.nuvoton.com (10.1.8.28) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 19 Sep 2023 01:00:03 +0800 Received: by taln60.nuvoton.co.il (Postfix, from userid 10070) id DEC7D64741; Mon, 18 Sep 2023 20:00:02 +0300 (IDT) From: Tomer Maimon To: , , , , , , , , , , , , CC: , , , , Tomer Maimon Subject: [PATCH v1 2/2] usb: chipidea: Add support for NPCM Date: Mon, 18 Sep 2023 19:59:58 +0300 Message-ID: <20230918165958.2659-3-tmaimon77@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230918165958.2659-1-tmaimon77@gmail.com> References: <20230918165958.2659-1-tmaimon77@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-NotSetDelaration: True X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SG2PEPF000B66CB:EE_|SEYPR03MB7697:EE_ X-MS-Office365-Filtering-Correlation-Id: 82f53c75-1d14-4877-8764-08dbb868b77c X-MS-Exchange-SenderADCheck: 0 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: F8LtVg8s3+WgALI8Ec1vpfTFbyqGbm/PVy1K9GkD3PiHnQFvSAB01xqcn5QfYYplA4jUsHtam4MbzeWNjnzwTPT5xoSgDaqt7XPdtzyqYh80sSvS0KNkaUk3VcHzZ+HLYw8fsxlkVNhXOQ8ZfNXIRKx3Xsh9PzApdCOtCXt7RQxEOvCOJ4teFN5Bg1olloEpW04KolZ44rpzxzckNeBIUUHMyoj9ysuBjsO2z7vYiYaTZ28BEtn476zXheNfofPhvifTck4vvxJAuZMgKdQMAN57ew1pxBW8Ts38r/BAOwWiYRWc5d+e8x7DtM+6eGAeiQ9i3Nj1yr5BvZLOmxRP0LKjT2YtuLI8Q7hfqG3H4FjYqaTz26okfy+N2fWWW+mE1tAMQ1lrwuPjWCfILxjRMWfHTw7P+ybkV9t8Q8k1twboerjMvQCHouUn5FRikLnLjAv7P5FzRoslA6L7t359On29MqEhFfS4aEoiUCYY/Zos2Q8mD9udG0WFJ0nFZ6izeDO1jjaREcufDmMmGYlFBkfXkQzyjmW6dKmLnP6vTXcwGUxOLDpStWLKdF0/7hdi0qhmmkjlK5ZrgDNibnXH8IATU/R7w02ywanqbs5HNoDUxCsQbYG3QQUn7EqqIYxpaINK0GtHhFqWehEJTaw+13RFbMdvjINhsiWQO3lDnAt3G4gWtRjbKTSs+enoqbXnxLyncOVR3OtF9rSjT54E18sWUfluVMyGMSaZbyII+V1Oao/cpUJOgADMi4w+1cJRQdv2baOUFNu5PeMi/vKvHBqxaPkXX2XSHeDOPRmTgerE4XZcAIcPk9odNPDcrPJw+tGtzh98x03oNStHLqb28DVfNeTmgsJH1KglxHXffPca2IOEiVyE8kxJPAbullsuUscWd/G2Rne3I6+yu16sEw== X-Forefront-Antispam-Report: CIP:175.98.123.7;CTRY:TW;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:NTHCCAS04.nuvoton.com;PTR:175-98-123-7.static.tfn.net.tw;CAT:NONE;SFS:(13230031)(4636009)(346002)(376002)(136003)(396003)(39860400002)(186009)(61400799006)(451199024)(48200799006)(82310400011)(40470700004)(46966006)(36840700001)(2906002)(40460700003)(76482006)(83380400001)(82202003)(1076003)(36756003)(55446002)(6666004)(2616005)(478600001)(42882007)(73392003)(336012)(6266002)(26005)(40480700001)(8936002)(8676002)(36860700001)(4326008)(41300700001)(83170400001)(47076005)(70586007)(5660300002)(7416002)(316002)(356005)(82740400003)(921005)(81166007)(42186006)(54906003)(110136005)(70206006)(45356006)(35450700002);DIR:OUT;SFP:1101; X-OriginatorOrg: nuvoton.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2023 17:00:09.5839 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 82f53c75-1d14-4877-8764-08dbb868b77c X-MS-Exchange-CrossTenant-Id: a3f24931-d403-4b4a-94f1-7d83ac638e07 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=a3f24931-d403-4b4a-94f1-7d83ac638e07;Ip=[175.98.123.7];Helo=[NTHCCAS04.nuvoton.com] X-MS-Exchange-CrossTenant-AuthSource: SG2PEPF000B66CB.apcprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR03MB7697 X-Spam-Status: No, score=0.5 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 18 Sep 2023 10:00:40 -0700 (PDT) Add Nuvoton NPCM BMC SoCs support to USB ChipIdea driver. NPCM SoC include ChipIdea IP block that used for USB device controller mode. Signed-off-by: Tomer Maimon --- drivers/usb/chipidea/Kconfig | 4 + drivers/usb/chipidea/Makefile | 1 + drivers/usb/chipidea/ci_hdrc_npcm.c | 126 ++++++++++++++++++++++++++++ 3 files changed, 131 insertions(+) create mode 100644 drivers/usb/chipidea/ci_hdrc_npcm.c diff --git a/drivers/usb/chipidea/Kconfig b/drivers/usb/chipidea/Kconfig index c815824a0b2d..bab45bc62361 100644 --- a/drivers/usb/chipidea/Kconfig +++ b/drivers/usb/chipidea/Kconfig @@ -43,6 +43,10 @@ config USB_CHIPIDEA_MSM tristate "Enable MSM hsusb glue driver" if EXPERT default USB_CHIPIDEA +config USB_CHIPIDEA_NPCM + tristate "Enable NPCM hsusb glue driver" if EXPERT + default USB_CHIPIDEA + config USB_CHIPIDEA_IMX tristate "Enable i.MX USB glue driver" if EXPERT depends on OF diff --git a/drivers/usb/chipidea/Makefile b/drivers/usb/chipidea/Makefile index 71afeab97e83..718cb24603dd 100644 --- a/drivers/usb/chipidea/Makefile +++ b/drivers/usb/chipidea/Makefile @@ -13,6 +13,7 @@ ci_hdrc-$(CONFIG_USB_OTG_FSM) += otg_fsm.o obj-$(CONFIG_USB_CHIPIDEA_GENERIC) += ci_hdrc_usb2.o obj-$(CONFIG_USB_CHIPIDEA_MSM) += ci_hdrc_msm.o +obj-$(CONFIG_USB_CHIPIDEA_NPCM) += ci_hdrc_npcm.o obj-$(CONFIG_USB_CHIPIDEA_PCI) += ci_hdrc_pci.o obj-$(CONFIG_USB_CHIPIDEA_IMX) += usbmisc_imx.o ci_hdrc_imx.o obj-$(CONFIG_USB_CHIPIDEA_TEGRA) += ci_hdrc_tegra.o diff --git a/drivers/usb/chipidea/ci_hdrc_npcm.c b/drivers/usb/chipidea/ci_hdrc_npcm.c new file mode 100644 index 000000000000..8214a4d1e418 --- /dev/null +++ b/drivers/usb/chipidea/ci_hdrc_npcm.c @@ -0,0 +1,126 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (c) 2023 Nuvoton Technology corporation. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "ci.h" + +struct npcm_udc_data { + struct platform_device *ci; + struct clk *core_clk; + struct ci_hdrc_platform_data pdata; +}; + +static int npcm_udc_notify_event(struct ci_hdrc *ci, unsigned event) +{ + struct device *dev = ci->dev->parent; + + switch (event) { + case CI_HDRC_CONTROLLER_RESET_EVENT: + /* clear all mode bits */ + hw_write(ci, OP_USBMODE, 0xffffffff, 0x0); + break; + default: + dev_dbg(dev, "unknown ci_hdrc event\n"); + break; + } + + return 0; +} + +static int npcm_udc_probe(struct platform_device *pdev) +{ + int ret; + unsigned int args[3]; + struct regmap *gcr_regmap; + struct npcm_udc_data *ci; + struct platform_device *plat_ci; + struct device *dev = &pdev->dev; + struct device_node *np = dev->of_node; + + ci = devm_kzalloc(&pdev->dev, sizeof(*ci), GFP_KERNEL); + if (!ci) + return -ENOMEM; + platform_set_drvdata(pdev, ci); + + ci->core_clk = devm_clk_get_optional(dev, NULL); + if (IS_ERR(ci->core_clk)) + return PTR_ERR(ci->core_clk); + + ret = clk_prepare_enable(ci->core_clk); + if (ret) { + dev_err(dev, "failed to enable the clock: %d\n", ret); + return ret; + } + + ci->pdata.name = dev_name(dev); + ci->pdata.capoffset = DEF_CAPOFFSET; + ci->pdata.flags = CI_HDRC_REQUIRES_ALIGNED_DMA | + CI_HDRC_FORCE_VBUS_ACTIVE_ALWAYS; + ci->pdata.phy_mode = USBPHY_INTERFACE_MODE_UTMI; + ci->pdata.notify_event = npcm_udc_notify_event; + + gcr_regmap = syscon_regmap_lookup_by_phandle_args(np, "nuvoton,sysgcr", + 3, args); + if (!IS_ERR(gcr_regmap)) + regmap_update_bits(gcr_regmap, args[0], args[1], args[2]); + + plat_ci = ci_hdrc_add_device(dev, pdev->resource, pdev->num_resources, + &ci->pdata); + if (IS_ERR(plat_ci)) { + ret = PTR_ERR(plat_ci); + dev_err(dev, "failed to register HDRC NPCM device: %d\n", ret); + goto clk_err; + } + + pm_runtime_no_callbacks(dev); + pm_runtime_enable(dev); + + return 0; + +clk_err: + clk_disable_unprepare(ci->core_clk); + return ret; +} + +static int npcm_udc_remove(struct platform_device *pdev) +{ + struct npcm_udc_data *ci = platform_get_drvdata(pdev); + + pm_runtime_disable(&pdev->dev); + ci_hdrc_remove_device(ci->ci); + clk_disable_unprepare(ci->core_clk); + + return 0; +} + +static const struct of_device_id npcm_udc_dt_match[] = { + { .compatible = "nuvoton,npcm-udc", }, + { } +}; +MODULE_DEVICE_TABLE(of, npcm_udc_dt_match); + +static struct platform_driver npcm_udc_driver = { + .probe = npcm_udc_probe, + .remove = npcm_udc_remove, + .driver = { + .name = "npcm_udc", + .of_match_table = npcm_udc_dt_match, + }, +}; + +module_platform_driver(npcm_udc_driver); + +MODULE_DESCRIPTION("NPCM USB device controller driver"); +MODULE_AUTHOR("Tomer Maimon "); +MODULE_ALIAS("platform:npcm-udc"); +MODULE_LICENSE("GPL v2"); -- 2.33.0