From patchwork Fri Jul 26 08:14:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 169789 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp12703224ilk; Fri, 26 Jul 2019 01:15:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqwO9xYFxPndZ7tU9QNOpIgSCAMTyiILx+tSdxO+6P5YPnA5qoPmdqV961tdrQownYC7c084 X-Received: by 2002:a17:902:4b:: with SMTP id 69mr94478194pla.89.1564128914126; Fri, 26 Jul 2019 01:15:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564128914; cv=none; d=google.com; s=arc-20160816; b=kkBTZNaqumiIfD0RgydAUzqJiOy1+QXG0izpFKBOUT2/hPOvpEKq9wsT1J2wUXvH+G 5qbbdrD1k1HAxPQuxce4+3RMq/85F2mB0T/5MLfMasNBqcL9DI6rV3qMmOSze8ZtWzAv wFDO2LmqJONl+U+kk+rpO9S8KfQdk4ZYLaNgU6mQsZvMGU6FMHvTB5UpViJdVrJm3Y+z Yq7LxtnjDSkU/MsKQDRsbBzbsqyZq8TuF6dLvdLgS5EWAJjfuQbo5GgfYJY/+ETqwgQG D3LUs6TRxbYXoqWmfzOkgyMsyM/hjT1tCWvUXSp5VoZgtWHM7PRhiEY0PzVdJCknaMhU BzcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type :content-transfer-encoding:mime-version:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=hZ4MwfR13AaNPCdSDCn6Bz3onvIw3auhZCwCGXSUNnY=; b=jw8x5uCNAEtaO80C47/1V/XpxwsYzYTlGPHdzYsXftvmAWYy7UDiiVDAuEnY2vYIY9 8+Cbh/yI7TtGpr6PsrVmxBDG5u/PfUzHFgAe3PnsJonVf2Vjp9wrftqZLLeiX2Y23ghA l610LiT1MFRNNcYtVIecBGfLtGG4QFuJ7ViVS7NUX96e2822ZQ4ZUBIvCi29HNegJovu agN/ddjYw0+I5lixXaBhrasLHC62VE1FHO7e0TKH/BUYPJxgHZoBxEkrktRlbdJXVIaf Sk342OgIzBjZ3teXYRU+qRw43qar951EOYU354jolBodStDZQ5TCmYoliYmgHYxpZ7ew pkFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=TSLvqFpK; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t13si19328731pfh.245.2019.07.26.01.15.13; Fri, 26 Jul 2019 01:15:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=TSLvqFpK; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726518AbfGZIPN (ORCPT + 5 others); Fri, 26 Jul 2019 04:15:13 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:40292 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726430AbfGZIPK (ORCPT ); Fri, 26 Jul 2019 04:15:10 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20190726081507euoutp027e2c650f46fe2161e3a452e6baf53cf4~05vRG53o10303103031euoutp02N for ; Fri, 26 Jul 2019 08:15:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20190726081507euoutp027e2c650f46fe2161e3a452e6baf53cf4~05vRG53o10303103031euoutp02N DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1564128907; bh=hZ4MwfR13AaNPCdSDCn6Bz3onvIw3auhZCwCGXSUNnY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TSLvqFpKJaK5hViqWUlAHLgVggZBQsZgwhNPi6ZAu7f5fCEGr3X7i0iW1NwtnDtc6 f83H0I9C+1og7rbJYE++bzwe+aNTMLBOVZVAtUetl2bp4pCGLsBZ2GoITZJdY2Cyib 6R7S5MNJmdo7Y0lB96aDA79haX2AkX6EvCOeLR5I= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20190726081506eucas1p14600c7c986b96b8ee9421c77feffeb1d~05vQhNVwB2123721237eucas1p1n; Fri, 26 Jul 2019 08:15:06 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id FE.1B.04377.A86BA3D5; Fri, 26 Jul 2019 09:15:06 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20190726081505eucas1p146c14eed320c57050aa968b7c97b227b~05vPw7Rex2124521245eucas1p1k; Fri, 26 Jul 2019 08:15:05 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20190726081505eusmtrp2a16d4c68bde1588516aa8abab6f93049~05vPi0ebv3187231872eusmtrp2s; Fri, 26 Jul 2019 08:15:05 +0000 (GMT) X-AuditID: cbfec7f4-12dff70000001119-d1-5d3ab68a4a7d Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id CD.7C.04146.986BA3D5; Fri, 26 Jul 2019 09:15:05 +0100 (BST) Received: from AMDC2765.DIGITAL.local (unknown [106.120.51.73]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20190726081505eusmtip2c82af7ba052a9d2ff106ab59d8600296~05vO8aiy43038030380eusmtip2t; Fri, 26 Jul 2019 08:15:05 +0000 (GMT) From: Marek Szyprowski To: linux-usb@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Greg Kroah-Hartman , Marek Szyprowski , Bartlomiej Zolnierkiewicz , Markus Reichl , =?utf-8?b?TcOlbnMgUnVsbGfDpXJk?= , Krzysztof Kozlowski , Peter Chen , Alan Stern , Rob Herring Subject: [PATCH v2 2/3] usb: exynos: add support for getting PHYs from the standard dt array Date: Fri, 26 Jul 2019 10:14:52 +0200 Message-Id: <20190726081453.9456-3-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190726081453.9456-1-m.szyprowski@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA01SfSyUcRz3u+eeF3L2ODY/uoWr9La8NGtPXE2rtWdrK72trYauPB3h2N0h WlxujJuk1sKpsSghzvs4k3AlbE6oybw2eltYWJ2dKXcP8t/n+/l+Pr/P57v9CITfjboQ4VIF I5OKI4WYDbfh7ZJhv7rBL8h7fk5AVedqUapA34tSqiItRhkMVTg1oHuMUbmGVxzq6fNUhPqu NwKqQj+KU8bJHA61PDaCUqktepzKNvVhATx6eCSZrinLwOjWJy9x+mdPN05XzzZy6PxRI6Cz 6soAvVCzLZC4ZCMKZSLD4xiZ15ErNmEfSkUx+dtvlowUo0pgEKiBNQFJX/imvxwxYz75AsDf s9fVwGYVLwJ4r2gaZ4cFAJUTtWDd8XClEGEXJQAudafhG5Y0432OWYWRPlA9o8bM2JEMgMXP RjCzC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dIQRUs//XbjaIekGJkzOfsICMYRZQl1g/ TwgkzAzU2rx1NvMERsFZSKpmIVTNQlK1gJF5FaNIamlxbnpusaFecWJucWleul5yfu4mRmBc bjv2c/MOxksbgw8xCnAwKvHwXlhuGSvEmlhWXJl7iFGCg1lJhHfrDqAQb0piZVVqUX58UWlO avEhRlOgzyYyS4km5wNTRl5JvKGpobmFpaG5sbmxmYWSOG+HwMEYIYH0xJLU7NTUgtQimD4m Dk6pBkb344lrr8zO3LY/VSTtcPfK9qdPc2LWZcyYmBV5aGV0ykbVR42200SZoroc15zgteQw D/5vayAQq/Dqc4L4tZrjR35y5UpvvKCxUfLhlXTBwyfyPynlBuipGXDPqytiDuBsC/JYGn25 yJuZ7+0xoXnXa0q3L9lv7GjZdnl3VZCuc8/NVVsL7ZVYijMSDbWYi4oTAe708dThAgAA X-CMS-MailID: 20190726081505eucas1p146c14eed320c57050aa968b7c97b227b X-Msg-Generator: CA X-RootMTR: 20190726081505eucas1p146c14eed320c57050aa968b7c97b227b X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20190726081505eucas1p146c14eed320c57050aa968b7c97b227b References: <20190726081453.9456-1-m.szyprowski@samsung.com> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Add the code for getting generic PHYs from standard device tree array from the main controller device node. This is a first step in resolving the conflict between Exynos EHCI/OHCI sub-nodes and generic USB device bindings. Later the sub-nodes currently used for assigning PHYs to root ports of the controller will be removed making a place for the generic USB device bindings nodes. Suggested-by: Måns Rullgård Signed-off-by: Marek Szyprowski --- drivers/usb/host/ehci-exynos.c | 23 +++++++++++++++++++---- drivers/usb/host/ohci-exynos.c | 23 +++++++++++++++++++---- 2 files changed, 38 insertions(+), 8 deletions(-) -- 2.17.1 diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c index 3a29a1a8519c..01debfd03d4a 100644 --- a/drivers/usb/host/ehci-exynos.c +++ b/drivers/usb/host/ehci-exynos.c @@ -41,6 +41,7 @@ struct exynos_ehci_hcd { struct clk *clk; struct device_node *of_node; struct phy *phy[PHY_NUMBER]; + bool legacy_phy; }; #define to_exynos_ehci(hcd) (struct exynos_ehci_hcd *)(hcd_to_ehci(hcd)->priv) @@ -50,10 +51,22 @@ static int exynos_ehci_get_phy(struct device *dev, { struct device_node *child; struct phy *phy; - int phy_number; + int phy_number, num_phys; int ret; /* Get PHYs for the controller */ + num_phys = of_count_phandle_with_args(dev->of_node, "phys", + "#phy-cells"); + for (phy_number = 0; phy_number < num_phys; phy_number++) { + phy = devm_of_phy_get_by_index(dev, dev->of_node, phy_number); + if (IS_ERR(phy)) + return PTR_ERR(phy); + exynos_ehci->phy[phy_number] = phy; + } + if (num_phys > 0) + return 0; + + /* Get PHYs using legacy bindings */ for_each_available_child_of_node(dev->of_node, child) { ret = of_property_read_u32(child, "reg", &phy_number); if (ret) { @@ -84,6 +97,7 @@ static int exynos_ehci_get_phy(struct device *dev, } } + exynos_ehci->legacy_phy = true; return 0; } @@ -205,11 +219,12 @@ static int exynos_ehci_probe(struct platform_device *pdev) ehci->caps = hcd->regs; /* - * Workaround: reset of_node pointer to avoid conflict between Exynos - * EHCI port subnodes and generic USB device bindings + * Workaround: reset of_node pointer to avoid conflict between legacy + * Exynos EHCI port subnodes and generic USB device bindings */ exynos_ehci->of_node = pdev->dev.of_node; - pdev->dev.of_node = NULL; + if (exynos_ehci->legacy_phy) + pdev->dev.of_node = NULL; /* DMA burst Enable */ writel(EHCI_INSNREG00_ENABLE_DMA_BURST, EHCI_INSNREG00(hcd->regs)); diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c index 905c6317e0c3..d5ce98e205c7 100644 --- a/drivers/usb/host/ohci-exynos.c +++ b/drivers/usb/host/ohci-exynos.c @@ -32,6 +32,7 @@ struct exynos_ohci_hcd { struct clk *clk; struct device_node *of_node; struct phy *phy[PHY_NUMBER]; + bool legacy_phy; }; static int exynos_ohci_get_phy(struct device *dev, @@ -39,10 +40,22 @@ static int exynos_ohci_get_phy(struct device *dev, { struct device_node *child; struct phy *phy; - int phy_number; + int phy_number, num_phys; int ret; /* Get PHYs for the controller */ + num_phys = of_count_phandle_with_args(dev->of_node, "phys", + "#phy-cells"); + for (phy_number = 0; phy_number < num_phys; phy_number++) { + phy = devm_of_phy_get_by_index(dev, dev->of_node, phy_number); + if (IS_ERR(phy)) + return PTR_ERR(phy); + exynos_ohci->phy[phy_number] = phy; + } + if (num_phys > 0) + return 0; + + /* Get PHYs using legacy bindings */ for_each_available_child_of_node(dev->of_node, child) { ret = of_property_read_u32(child, "reg", &phy_number); if (ret) { @@ -73,6 +86,7 @@ static int exynos_ohci_get_phy(struct device *dev, } } + exynos_ohci->legacy_phy = true; return 0; } @@ -172,11 +186,12 @@ static int exynos_ohci_probe(struct platform_device *pdev) } /* - * Workaround: reset of_node pointer to avoid conflict between Exynos - * OHCI port subnodes and generic USB device bindings + * Workaround: reset of_node pointer to avoid conflict between legacy + * Exynos OHCI port subnodes and generic USB device bindings */ exynos_ohci->of_node = pdev->dev.of_node; - pdev->dev.of_node = NULL; + if (exynos_ohci->legacy_phy) + pdev->dev.of_node = NULL; err = usb_add_hcd(hcd, irq, IRQF_SHARED); if (err) {