From patchwork Tue Oct 22 05:58:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 3080831 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C5391BF924 for ; Tue, 22 Oct 2013 06:16:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B00D720434 for ; Tue, 22 Oct 2013 06:16:10 +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 D66E2203A3 for ; Tue, 22 Oct 2013 06:16:05 +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 1VYVFi-0007K3-Vn; Tue, 22 Oct 2013 06:15:39 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VYVFY-0002uO-KO; Tue, 22 Oct 2013 06:15:28 +0000 Received: from tx2ehsobe005.messaging.microsoft.com ([65.55.88.15] helo=tx2outboundpool.messaging.microsoft.com) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VYVFL-0002rc-E8 for linux-arm-kernel@lists.infradead.org; Tue, 22 Oct 2013 06:15:17 +0000 Received: from mail15-tx2-R.bigfish.com (10.9.14.241) by TX2EHSOBE008.bigfish.com (10.9.40.28) with Microsoft SMTP Server id 14.1.225.22; Tue, 22 Oct 2013 06:14:54 +0000 Received: from mail15-tx2 (localhost [127.0.0.1]) by mail15-tx2-R.bigfish.com (Postfix) with ESMTP id D75514800FC; Tue, 22 Oct 2013 06:14:53 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 0 X-BigFish: VS0(zzzz1f42h208ch1ee6h1de0h1fdah2073h1202h1e76h1d1ah1d2ah1fc6hzz1de098h1de097h8275bhz2dh2a8h839hd24he5bhf0ah1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h1504h1537h162dh1631h1758h1898h18e1h1946h19b5h1ad9h1b0ah1b2fh1fb3h1d0ch1d2eh1d3fh1dfeh1dffh1e23h1fe8h1ff5h1155h) Received: from mail15-tx2 (localhost.localdomain [127.0.0.1]) by mail15-tx2 (MessageSwitch) id 1382422492440220_9916; Tue, 22 Oct 2013 06:14:52 +0000 (UTC) Received: from TX2EHSMHS017.bigfish.com (unknown [10.9.14.237]) by mail15-tx2.bigfish.com (Postfix) with ESMTP id 572AA4003F; Tue, 22 Oct 2013 06:14:52 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by TX2EHSMHS017.bigfish.com (10.9.99.117) with Microsoft SMTP Server (TLS) id 14.16.227.3; Tue, 22 Oct 2013 06:14:52 +0000 Received: from tx30smr01.am.freescale.net (10.81.153.31) by 039-SN1MMR1-004.039d.mgd.msft.net (10.84.1.14) with Microsoft SMTP Server (TLS) id 14.3.158.2; Tue, 22 Oct 2013 06:14:51 +0000 Received: from shlinux1.ap.freescale.net (shlinux1.ap.freescale.net [10.192.225.216]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id r9M6EQkr021655; Mon, 21 Oct 2013 23:14:47 -0700 From: Peter Chen To: , , , Subject: [Patch v2 02/14] usb: phy-mxs: Add platform judgement code Date: Tue, 22 Oct 2013 13:58:36 +0800 Message-ID: <1382421528-17897-3-git-send-email-peter.chen@freescale.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1382421528-17897-1-git-send-email-peter.chen@freescale.com> References: <1382421528-17897-1-git-send-email-peter.chen@freescale.com> MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-FOPE-CONNECTOR: Id%0$Dn%*$RO%0$TLS%0$FQDN%$TlsDn% X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131022_021515_643419_E1744C72 X-CRM114-Status: GOOD ( 16.17 ) X-Spam-Score: -4.2 (----) Cc: marex@denx.de, devicetree@vger.kernel.org, m.grzeschik@pengutronix.de, frank.li@freescale.com, linux-doc@vger.kernel.org, alexander.shishkin@linux.intel.com, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, peter.chen@freescale.com, kernel@pengutronix.de, festevam@gmail.com, linux-arm-kernel@lists.infradead.org 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: , 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.6 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 The mxs-phy has three versions until now, each versions have some differences among PHY operations. the 1st version is for mx23/mx28 SoC, The 2nd version is for mx6q and mx6dl, the 3rd version is for mx6sl and later mx6 platform. Signed-off-by: Peter Chen --- drivers/usb/phy/phy-mxs-usb.c | 65 ++++++++++++++++++++++++++++++++++++----- 1 files changed, 57 insertions(+), 8 deletions(-) diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c index fdd33b4..a0628d6 100644 --- a/drivers/usb/phy/phy-mxs-usb.c +++ b/drivers/usb/phy/phy-mxs-usb.c @@ -1,5 +1,5 @@ /* - * Copyright 2012 Freescale Semiconductor, Inc. + * Copyright 2012-2013 Freescale Semiconductor, Inc. * Copyright (C) 2012 Marek Vasut * on behalf of DENX Software Engineering GmbH * @@ -20,6 +20,7 @@ #include #include #include +#include #define DRIVER_NAME "mxs_phy" @@ -34,12 +35,57 @@ #define BM_USBPHY_CTRL_ENUTMILEVEL2 BIT(14) #define BM_USBPHY_CTRL_ENHOSTDISCONDETECT BIT(1) +#define to_mxs_phy(p) container_of((p), struct mxs_phy, phy) + +enum imx_phy_type { + IMX6Q_USB_PHY, + IMX6SL_USB_PHY, + IMX23_USB_PHY, +}; + struct mxs_phy { struct usb_phy phy; struct clk *clk; + enum imx_phy_type devtype; }; -#define to_mxs_phy(p) container_of((p), struct mxs_phy, phy) +static inline int is_mx6q_phy(struct mxs_phy *data) +{ + return data->devtype == IMX6Q_USB_PHY; +} + +static inline int is_mx6sl_phy(struct mxs_phy *data) +{ + return data->devtype == IMX6SL_USB_PHY; +} + +static inline int is_mx23_phy(struct mxs_phy *data) +{ + return data->devtype == IMX23_USB_PHY; +} + +static struct platform_device_id imx_phy_devtype[] = { + { + .name = "usb-phy-imx6q", + .driver_data = IMX6Q_USB_PHY, + }, { + .name = "usb-phy-imx6sl", + .driver_data = IMX6SL_USB_PHY, + }, { + .name = "usb-phy-imx23", + .driver_data = IMX23_USB_PHY, + }, { + /* sentinel */ + } +}; + +static const struct of_device_id mxs_phy_dt_ids[] = { + { .compatible = "fsl,imx6q-usbphy", .data = &imx_phy_devtype[IMX6Q_USB_PHY], }, + { .compatible = "fsl,imx6sl-usbphy", .data = &imx_phy_devtype[IMX6SL_USB_PHY], }, + { .compatible = "fsl,imx23-usbphy", .data = &imx_phy_devtype[IMX23_USB_PHY], }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, mxs_phy_dt_ids); static int mxs_phy_hw_init(struct mxs_phy *mxs_phy) { @@ -131,6 +177,14 @@ static int mxs_phy_probe(struct platform_device *pdev) struct clk *clk; struct mxs_phy *mxs_phy; int ret; + const struct of_device_id *of_id = + of_match_device(mxs_phy_dt_ids, &pdev->dev); + + /* This driver is DT-only version now */ + if (!of_id) + return -ENXIO; + + pdev->id_entry = of_id->data; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); base = devm_ioremap_resource(&pdev->dev, res); @@ -163,6 +217,7 @@ static int mxs_phy_probe(struct platform_device *pdev) ATOMIC_INIT_NOTIFIER_HEAD(&mxs_phy->phy.notifier); mxs_phy->clk = clk; + mxs_phy->devtype = pdev->id_entry->driver_data; platform_set_drvdata(pdev, &mxs_phy->phy); @@ -182,12 +237,6 @@ static int mxs_phy_remove(struct platform_device *pdev) return 0; } -static const struct of_device_id mxs_phy_dt_ids[] = { - { .compatible = "fsl,imx23-usbphy", }, - { /* sentinel */ } -}; -MODULE_DEVICE_TABLE(of, mxs_phy_dt_ids); - static struct platform_driver mxs_phy_driver = { .probe = mxs_phy_probe, .remove = mxs_phy_remove,