Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2678054pxa; Mon, 17 Aug 2020 16:22:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxpr8aoR/e2u1cnLZ/uGslPDTQ48tmCEMSP4hG2mUIojbIWaEORi4SlOxeOFdPe1KocJ0w4 X-Received: by 2002:aa7:ccc1:: with SMTP id y1mr18153459edt.317.1597706540226; Mon, 17 Aug 2020 16:22:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597706540; cv=none; d=google.com; s=arc-20160816; b=VzJnWF1txALi0lvXriVtpSt2iQNEWdAMFMYjorJKPFwD7Zbs8D0UZ9h3aFAAgT4/IG q5P8vCDJFeo7n1EGta2mVWqT3+YfAsYDSN83z3Un4P2RIEu4UK/FS3CTrVo1gWtfb4YG Ph/3/FGRomIGkmeIdnAlZKKttTBo+0jO14a5tWghnJGqBuvJ3C/tPitk0EiUxfEVjxj6 OfCq4sAPRM78ogwaEU8PC6y7th0SCkhNG67IkGz3IoIvIZMpHjSOgABz+VlSs2XLeKKL OV+u+N+LVjf5g/DPiPoXqCtrgswqujiCkfP/5yZ3Mg+BGY8PwZ8TAs3UJOENLPz2SV9x Vmog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=q0Oer5rw0j7E/NzthfemkMeY1qxc3Uk/sV4Rd8IkXT4=; b=zWHM2evHVai+h7jeIKgNAIMdG6R8qRY1n52c6Smn/hEA1gYCHMLrV9KTbWumwOg3Lg BRoiqS1lfxXV5FdGcZZ7ZB87KW0fCY0tuVu0XQU4jZcUxJDWh2Io/ocvyvzg8sWQS9L+ 9RYTxnG6jYEeI9pL+b+f0OX1/gff7YV1eE2Glh6hU4HgsmZD+TCjIx9FLQyFInM6ij/s UX6U5Kl5HpfcBH+pKzgYsZnOHcSQ8arTGZJ0+zd7vt21p+YAsNTorIAy20fhXuTdtkAb AT3NDCJKtpjdP0RyoIqtta+LVwB70K+DUJZ7z4w/N9lJOsjhjEmJHTMcUDsBQXnRQ9WR h9Wg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z15si11956649eja.112.2020.08.17.16.21.56; Mon, 17 Aug 2020 16:22:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729982AbgHQWec (ORCPT + 99 others); Mon, 17 Aug 2020 18:34:32 -0400 Received: from mail.v3.sk ([167.172.186.51]:54256 "EHLO shell.v3.sk" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729947AbgHQWe3 (ORCPT ); Mon, 17 Aug 2020 18:34:29 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by zimbra.v3.sk (Postfix) with ESMTP id 283AEDFA73; Mon, 17 Aug 2020 22:33:30 +0000 (UTC) Received: from shell.v3.sk ([127.0.0.1]) by localhost (zimbra.v3.sk [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id wEwqFHfQGGNu; Mon, 17 Aug 2020 22:33:28 +0000 (UTC) Received: from localhost (localhost.localdomain [127.0.0.1]) by zimbra.v3.sk (Postfix) with ESMTP id 685CEDF880; Mon, 17 Aug 2020 22:33:24 +0000 (UTC) X-Virus-Scanned: amavisd-new at zimbra.v3.sk Received: from shell.v3.sk ([127.0.0.1]) by localhost (zimbra.v3.sk [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id cxjoEFMROsQ1; Mon, 17 Aug 2020 22:33:22 +0000 (UTC) Received: from localhost (unknown [109.183.109.54]) by zimbra.v3.sk (Postfix) with ESMTPSA id 1286BDFA73; Mon, 17 Aug 2020 22:33:17 +0000 (UTC) From: Lubomir Rintel To: Kishon Vijay Abraham I Cc: Vinod Koul , Rob Herring , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Lubomir Rintel Subject: [RESEND PATCH v3 3/3] phy: Add USB HSIC PHY driver for Marvell MMP3 SoC Date: Tue, 18 Aug 2020 00:34:00 +0200 Message-Id: <20200817223400.403505-4-lkundrak@v3.sk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200817223400.403505-1-lkundrak@v3.sk> References: <20200817223400.403505-1-lkundrak@v3.sk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add PHY driver for the HSICs found on Marvell MMP3 SoC. The driver is rather straightforward -- the PHY essentially just needs to be enabled. Signed-off-by: Lubomir Rintel --- Changes since v1: - Explicitely cast drvdata pointer to make sparse happy drivers/phy/marvell/Kconfig | 12 +++++ drivers/phy/marvell/Makefile | 1 + drivers/phy/marvell/phy-mmp3-hsic.c | 82 +++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+) create mode 100644 drivers/phy/marvell/phy-mmp3-hsic.c diff --git a/drivers/phy/marvell/Kconfig b/drivers/phy/marvell/Kconfig index 8f6273c837ec3..6c96f2bf52665 100644 --- a/drivers/phy/marvell/Kconfig +++ b/drivers/phy/marvell/Kconfig @@ -116,3 +116,15 @@ config PHY_MMP3_USB The PHY driver will be used by Marvell udc/ehci/otg driver. =20 To compile this driver as a module, choose M here. + +config PHY_MMP3_HSIC + tristate "Marvell MMP3 USB HSIC PHY Driver" + depends on MACH_MMP3_DT || COMPILE_TEST + select GENERIC_PHY + help + Enable this to support Marvell MMP3 USB HSIC PHY driver for + Marvell MMP3 SoC. This driver will be used my the Marvell EHCI + driver to initialize the interface to internal USB HSIC + components on MMP3-based boards. + + To compile this driver as a module, choose M here. diff --git a/drivers/phy/marvell/Makefile b/drivers/phy/marvell/Makefile index 5a106b1549f41..7f296ef028292 100644 --- a/drivers/phy/marvell/Makefile +++ b/drivers/phy/marvell/Makefile @@ -3,6 +3,7 @@ obj-$(CONFIG_ARMADA375_USBCLUSTER_PHY) +=3D phy-armada375= -usb2.o obj-$(CONFIG_PHY_BERLIN_SATA) +=3D phy-berlin-sata.o obj-$(CONFIG_PHY_BERLIN_USB) +=3D phy-berlin-usb.o obj-$(CONFIG_PHY_MMP3_USB) +=3D phy-mmp3-usb.o +obj-$(CONFIG_PHY_MMP3_HSIC) +=3D phy-mmp3-hsic.o obj-$(CONFIG_PHY_MVEBU_A3700_COMPHY) +=3D phy-mvebu-a3700-comphy.o obj-$(CONFIG_PHY_MVEBU_A3700_UTMI) +=3D phy-mvebu-a3700-utmi.o obj-$(CONFIG_PHY_MVEBU_A38X_COMPHY) +=3D phy-armada38x-comphy.o diff --git a/drivers/phy/marvell/phy-mmp3-hsic.c b/drivers/phy/marvell/ph= y-mmp3-hsic.c new file mode 100644 index 0000000000000..47c1e8894939f --- /dev/null +++ b/drivers/phy/marvell/phy-mmp3-hsic.c @@ -0,0 +1,82 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2020 Lubomir Rintel + */ + +#include +#include +#include +#include +#include + +#define HSIC_CTRL 0x08 +#define HSIC_ENABLE BIT(7) +#define PLL_BYPASS BIT(4) + +static int mmp3_hsic_phy_init(struct phy *phy) +{ + void __iomem *base =3D (void __iomem *)phy_get_drvdata(phy); + u32 hsic_ctrl; + + hsic_ctrl =3D readl_relaxed(base + HSIC_CTRL); + hsic_ctrl |=3D HSIC_ENABLE; + hsic_ctrl |=3D PLL_BYPASS; + writel_relaxed(hsic_ctrl, base + HSIC_CTRL); + + return 0; +} + +static const struct phy_ops mmp3_hsic_phy_ops =3D { + .init =3D mmp3_hsic_phy_init, + .owner =3D THIS_MODULE, +}; + +static const struct of_device_id mmp3_hsic_phy_of_match[] =3D { + { .compatible =3D "marvell,mmp3-hsic-phy", }, + { }, +}; +MODULE_DEVICE_TABLE(of, mmp3_hsic_phy_of_match); + +static int mmp3_hsic_phy_probe(struct platform_device *pdev) +{ + struct device *dev =3D &pdev->dev; + struct phy_provider *provider; + struct resource *resource; + void __iomem *base; + struct phy *phy; + + resource =3D platform_get_resource(pdev, IORESOURCE_MEM, 0); + base =3D devm_ioremap_resource(dev, resource); + if (IS_ERR(base)) { + dev_err(dev, "failed to remap PHY regs\n"); + return PTR_ERR(base); + } + + phy =3D devm_phy_create(dev, NULL, &mmp3_hsic_phy_ops); + if (IS_ERR(phy)) { + dev_err(dev, "failed to create PHY\n"); + return PTR_ERR(phy); + } + + phy_set_drvdata(phy, (void *)base); + provider =3D devm_of_phy_provider_register(dev, of_phy_simple_xlate); + if (IS_ERR(provider)) { + dev_err(dev, "failed to register PHY provider\n"); + return PTR_ERR(provider); + } + + return 0; +} + +static struct platform_driver mmp3_hsic_phy_driver =3D { + .probe =3D mmp3_hsic_phy_probe, + .driver =3D { + .name =3D "mmp3-hsic-phy", + .of_match_table =3D mmp3_hsic_phy_of_match, + }, +}; +module_platform_driver(mmp3_hsic_phy_driver); + +MODULE_AUTHOR("Lubomir Rintel "); +MODULE_DESCRIPTION("Marvell MMP3 USB HSIC PHY Driver"); +MODULE_LICENSE("GPL"); --=20 2.26.2