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: 20849 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f69.google.com (mail-vb0-f69.google.com [209.85.212.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6160624697 for ; Mon, 7 Oct 2013 10:12:48 +0000 (UTC) Received: by mail-vb0-f69.google.com with SMTP id e13sf13608185vbg.4 for ; Mon, 07 Oct 2013 03:12:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=OLpMsWZ4n3HsVPi5pmMZ4e2GMsomx/NIi5nhSxVtXCQ=; b=dfySJ9Kg+BIPmgVZvJ7Y7l6xwbNiE3wgFnmEAMEmHPElpcWdPSwzpsGBpnBuA/heeJ Wpy3aU/Z9bSai0nC4+Q7SiLPR2DjLkxEtINCMp0qxTauzPEe0uutbzC77p6WAoS/9AA0 O1UNxzCmcn73tqkwTV8BrXvV+euWBGiR6UnBeQyuc9IWIil/GQZ66BJB83tE8HGZXvMt S6E+x4Ai5YM0qRDyocX7MGI/ZSLdoKBf7CrMcGP3lXTHBZDq2QS1RvNvZA+GPkk43gsw SlyMQe5Z/NxbiY/Vgg4dAoAXiAxW9JxhS/FoqwFSM0ShzL7Awykdyx+KLr7dxRG7O4ck 5t2Q== X-Received: by 10.236.125.228 with SMTP id z64mr17357542yhh.47.1381140767995; Mon, 07 Oct 2013 03:12:47 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.74.35 with SMTP id q3ls2344057qev.50.gmail; Mon, 07 Oct 2013 03:12:47 -0700 (PDT) X-Received: by 10.220.94.206 with SMTP id a14mr1022757vcn.19.1381140767843; Mon, 07 Oct 2013 03:12:47 -0700 (PDT) Received: from mail-ve0-f171.google.com (mail-ve0-f171.google.com [209.85.128.171]) by mx.google.com with ESMTPS id l1si7602837vcl.139.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 07 Oct 2013 03:12:47 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.171; Received: by mail-ve0-f171.google.com with SMTP id pa12so3756816veb.30 for ; Mon, 07 Oct 2013 03:12:47 -0700 (PDT) X-Gm-Message-State: ALoCoQkLT9OKjAvgr+6xnKukMNhtCBmawFuyBi+alUDwJIzDsTIFbdy0gPXm8DppAmSHg8FiB2Iz X-Received: by 10.58.201.73 with SMTP id jy9mr1033552vec.20.1381140767689; Mon, 07 Oct 2013 03:12:47 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp113283vcz; Mon, 7 Oct 2013 03:12:47 -0700 (PDT) X-Received: by 10.50.23.76 with SMTP id k12mr16398477igf.37.1381140766885; Mon, 07 Oct 2013 03:12:46 -0700 (PDT) Received: from mail-ie0-f176.google.com (mail-ie0-f176.google.com [209.85.223.176]) by mx.google.com with ESMTPS id nl6si10704692igb.56.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 07 Oct 2013 03:12:46 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.223.176 is neither permitted nor denied by best guess record for domain of matt.porter@linaro.org) client-ip=209.85.223.176; Received: by mail-ie0-f176.google.com with SMTP id as1so14558403iec.7 for ; Mon, 07 Oct 2013 03:12:46 -0700 (PDT) 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 Cc: Paul Zimmerman , Linux USB List , Linux ARM Kernel List , Linux Kernel Mailing List , Devicetree List , Linaro Patches 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-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: matt.porter@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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");