From patchwork Mon Oct 7 10:12:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Porter X-Patchwork-Id: 2995481 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1B85F9F1C4 for ; Mon, 7 Oct 2013 10:15:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D80F6201CE for ; Mon, 7 Oct 2013 10:15:26 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 28DDC201C7 for ; Mon, 7 Oct 2013 10:15:25 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VT7p7-0000bs-S9; Mon, 07 Oct 2013 10:13:58 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VT7oo-0007Os-HA; Mon, 07 Oct 2013 10:13:38 +0000 Received: from mail-ie0-f182.google.com ([209.85.223.182]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VT7oJ-0007JN-Pg for linux-arm-kernel@lists.infradead.org; Mon, 07 Oct 2013 10:13:13 +0000 Received: by mail-ie0-f182.google.com with SMTP id aq17so15408726iec.13 for ; Mon, 07 Oct 2013 03:12:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OLpMsWZ4n3HsVPi5pmMZ4e2GMsomx/NIi5nhSxVtXCQ=; b=jTkOYuCESna28ZtGmFN9fkJRfFMYMk0kion+/KxrHpXCfl7O3wRrsf7H1uIzb72nlu NTuKAhNo52weyjU7gStJ/hdp/xSlKO0Fl+okgvHeJ1ZF3jHLKUBCn/0S3c1mFGOjdi9l n2R83Dv4N2r2lDA8CZn5mbp2qLC37OcrYuqJmgkF5Z2RAm50Xsp6Xbmuo29FDSbpjeb8 dG40EA2wrUiBioR7Rlixa1jxA6mgU80pkyyZ69JCpPdOuMVG0AQ+m3w8KzcyaRoEY48c wgatD9k4esOfwlxHtuhaOqG6XgUiMCat7RNJdbo0ixCGWTZzDcT1Fx+aZ7ncUmgB/uig YnHA== X-Gm-Message-State: ALoCoQlGP4veeJhYXf8EedcJbSzg86tekdhikDTK3wRtDFOy7WvF78ElC3ZE0fc3d1AXAqWL9Fxr X-Received: by 10.50.178.167 with SMTP id cz7mr16125573igc.7.1381140766478; Mon, 07 Oct 2013 03:12:46 -0700 (PDT) Received: from beef.ohporter.com (cpe-98-27-254-98.neo.res.rr.com. [98.27.254.98]) by mx.google.com with ESMTPSA id y10sm22710942igl.4.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 07 Oct 2013 03:12:45 -0700 (PDT) From: Matt Porter To: Felipe Balbi , Greg Kroah-Hartman , Rob Herring , Pawel Moll , Mark Rutland , Stephen Warren , Ian Campbell , Christian Daudt Subject: [PATCH 4/5] usb: phy: add Broadcom Kona USB PHY driver Date: Mon, 7 Oct 2013 06:12:31 -0400 Message-Id: <1381140752-312-5-git-send-email-matt.porter@linaro.org> X-Mailer: git-send-email 1.8.4 In-Reply-To: <1381140752-312-1-git-send-email-matt.porter@linaro.org> References: <1381140752-312-1-git-send-email-matt.porter@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131007_061307_980184_6279132B X-CRM114-Status: GOOD ( 18.78 ) X-Spam-Score: -2.6 (--) Cc: Devicetree List , Linaro Patches , Linux USB List , Linux Kernel Mailing List , Paul Zimmerman , Linux ARM Kernel List X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a USB PHY driver for BCM281xx devices. This driver makes use of the Broadcom Kona USB control driver to control init/shutdown of the PHY. Signed-off-by: Matt Porter Reviewed-by: Markus Mayer Reviewed-by: Tim Kryger --- .../devicetree/bindings/usb/bcm-kona-usb-phy.txt | 10 +++ drivers/usb/phy/Kconfig | 7 ++ drivers/usb/phy/Makefile | 1 + drivers/usb/phy/phy-bcm-kona-usb2.c | 99 ++++++++++++++++++++++ 4 files changed, 117 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/bcm-kona-usb-phy.txt create mode 100644 drivers/usb/phy/phy-bcm-kona-usb2.c diff --git a/Documentation/devicetree/bindings/usb/bcm-kona-usb-phy.txt b/Documentation/devicetree/bindings/usb/bcm-kona-usb-phy.txt new file mode 100644 index 0000000..a935fe2 --- /dev/null +++ b/Documentation/devicetree/bindings/usb/bcm-kona-usb-phy.txt @@ -0,0 +1,10 @@ +BROADCOM KONA USB PHY + +Required properties: + - compatible: brcm,kona-usb2 + +Example: + + usbphy: usbphy { + compatible = "brcm,kona-usb2"; + }; diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig index 2b7b4f1..d063204 100644 --- a/drivers/usb/phy/Kconfig +++ b/drivers/usb/phy/Kconfig @@ -105,6 +105,13 @@ config BCM_KONA_CTRL_USB help Enable this to support the Broadcom Kona USB control block +config BCM_KONA_PHY_USB2 + tristate "Broadcom Kona USB2 PHY Driver" + select USB_PHY + select BCM_KONA_CTRL_USB + help + Enable this to support the Broadcom Kona USB 2.0 PHY. + config SAMSUNG_USBPHY tristate help diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile index 98c545e..227fba5 100644 --- a/drivers/usb/phy/Makefile +++ b/drivers/usb/phy/Makefile @@ -16,6 +16,7 @@ obj-$(CONFIG_OMAP_CONTROL_USB) += phy-omap-control.o obj-$(CONFIG_AM335X_CONTROL_USB) += phy-am335x-control.o obj-$(CONFIG_AM335X_PHY_USB) += phy-am335x.o obj-$(CONFIG_BCM_KONA_CTRL_USB) += phy-bcm-kona-ctrl.o +obj-$(CONFIG_BCM_KONA_PHY_USB2) += phy-bcm-kona-usb2.o obj-$(CONFIG_OMAP_USB2) += phy-omap-usb2.o obj-$(CONFIG_OMAP_USB3) += phy-omap-usb3.o obj-$(CONFIG_SAMSUNG_USBPHY) += phy-samsung-usb.o diff --git a/drivers/usb/phy/phy-bcm-kona-usb2.c b/drivers/usb/phy/phy-bcm-kona-usb2.c new file mode 100644 index 0000000..21aee4a --- /dev/null +++ b/drivers/usb/phy/phy-bcm-kona-usb2.c @@ -0,0 +1,99 @@ +/* + * phy-bcm-kona-control.c - Broadcom Kona USB2 Phy Driver + * + * Copyright (C) 2013 Linaro Limited + * Matt Porter + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include + +#include "bcm-kona-usb.h" + +static int bcm_kona_phy_init(struct usb_phy *uphy) +{ + struct bcm_kona_usb *phy = dev_get_drvdata(uphy->dev); + + bcm_kona_ctrl_usb_phy_power(phy->ctrl_dev, 1); + + return 0; +} + +static void bcm_kona_phy_shutdown(struct usb_phy *uphy) +{ + struct bcm_kona_usb *phy = dev_get_drvdata(uphy->dev); + + bcm_kona_ctrl_usb_phy_power(phy->ctrl_dev, 0); +} + +static int bcm_kona_usb2_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct bcm_kona_usb *phy; + + phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL); + if (!phy) + return -ENOMEM; + + phy->ctrl_dev = bcm_kona_get_ctrl_dev(); + if (IS_ERR(phy->ctrl_dev)) { + dev_dbg(&pdev->dev, "Failed to get control device\n"); + return -ENODEV; + } + + phy->dev = dev; + phy->phy.dev = phy->dev; + phy->phy.label = "bcm-kona-usb2"; + phy->phy.init = bcm_kona_phy_init; + phy->phy.shutdown = bcm_kona_phy_shutdown; + phy->phy.type = USB_PHY_TYPE_USB2; + + platform_set_drvdata(pdev, phy); + + usb_add_phy_dev(&phy->phy); + + return 0; +} + +static int bcm_kona_usb2_remove(struct platform_device *pdev) +{ + struct bcm_kona_usb *phy = platform_get_drvdata(pdev); + + usb_remove_phy(&phy->phy); + + return 0; +} + +static const struct of_device_id bcm_kona_usb2_dt_ids[] = { + { .compatible = "brcm,kona-usb2" }, + { /* sentinel */ } +}; + +MODULE_DEVICE_TABLE(of, bcm_kona_usb2_dt_ids); + +static struct platform_driver bcm_kona_usb2_driver = { + .probe = bcm_kona_usb2_probe, + .remove = bcm_kona_usb2_remove, + .driver = { + .name = "bcm-kona-usb2", + .owner = THIS_MODULE, + .of_match_table = bcm_kona_usb2_dt_ids, + }, +}; + +module_platform_driver(bcm_kona_usb2_driver); + +MODULE_ALIAS("platform:bcm-kona-usb2"); +MODULE_AUTHOR("Matt Porter"); +MODULE_DESCRIPTION("BCM Kona USB 2.0 PHY driver"); +MODULE_LICENSE("GPL v2");