From patchwork Wed Aug 24 13:07:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milo Kim X-Patchwork-Id: 9297741 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6D36660757 for ; Wed, 24 Aug 2016 13:26:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5EAE428FD9 for ; Wed, 24 Aug 2016 13:26:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5375328FE0; Wed, 24 Aug 2016 13:26:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B9B8128FD9 for ; Wed, 24 Aug 2016 13:26:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753002AbcHXN0n (ORCPT ); Wed, 24 Aug 2016 09:26:43 -0400 Received: from mail-pa0-f65.google.com ([209.85.220.65]:35661 "EHLO mail-pa0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753073AbcHXN0k (ORCPT ); Wed, 24 Aug 2016 09:26:40 -0400 Received: by mail-pa0-f65.google.com with SMTP id cf3so1208408pad.2; Wed, 24 Aug 2016 06:25:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=eq3VGST+IUgarcWH9wM6R73SvwrEyprAmeWW+cshBFs=; b=uCcRnn3jwQQ5cmuV9NaQuTIqMCq7wcCN/kRyV3e80JGPDBGpFP0FrmLgsRIneCeyil ubyVh85PzSZBTmAulmpMnfjsVOGTz3Y4s/pf4WHy/J9Iiy7QB7mHQ5l9T71A8PjS9bGF 57PLrbog3oVxEiZ8LxLafx+lpQ+Y1RFI/5Pak6QM/pNa3TeE8jqYKWRYw/lzzCnoYNcu r1tuABMZDY9u376dLLND0fPn+p2HMRYoOVLhpE7kLqYiNG3fOnRwFnL30U19e7Qz2t9I W00Ivxcdx9Qm3HvjZB/LPBfFyI/znRke6qG5u/1Z9SkpSYuM63lsyEm1nwey1lTSBWO4 ybCA== 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=eq3VGST+IUgarcWH9wM6R73SvwrEyprAmeWW+cshBFs=; b=KrWZYlJsifH+oWR01ME+erxvbI/NEQFrryv2ATqu8skQxRCXv3WKS1PyFhLiA+4bNg JjQljoOZYV7+GvNO0CPWdZuPw0d/Vc4zYc1kt+GtsHGjqlpZb/Lt43UaZ+lSwWatjKjU EsEU6BVrvcPaYkSsij6W5fAiEDiRyhP+pTmO6mThsAOP3rKpKj090VFfwteOqgif5zAF wa4M+YFwDAKWAOHfyaUTm7fNqvlJM3wOzkWSUc/lCIu9rhPDaggyiiHaZVdDYr8UPdYh q+z71Ud5jFfmg5XcekFJOBfHsV7yC1X3L+uDEphPe8Ttk/8alUKhzOsXWtN0ooQiBed9 GuaQ== X-Gm-Message-State: AE9vXwOmnsvcQ0TkvZwZuFGzTgKmzsev6CqGAeRZoqgTN0ENn171pgrERTBporONoe6sNg== X-Received: by 10.66.20.41 with SMTP id k9mr5633305pae.142.1472044119514; Wed, 24 Aug 2016 06:08:39 -0700 (PDT) Received: from milo-dev.kornet ([61.77.30.12]) by smtp.gmail.com with ESMTPSA id h125sm13689199pfg.54.2016.08.24.06.08.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 24 Aug 2016 06:08:38 -0700 (PDT) From: Milo Kim To: Kukjin Kim , Krzysztof Kozlowski , David Airlie Cc: Inki Dae , Joonyoung Shim , Seung-Woo Kim , Kyungmin Park , Rob Herring , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Milo Kim Subject: [PATCH v3 4/5] gpu: drm: exynos_hdmi: Move PHY logic into single function Date: Wed, 24 Aug 2016 22:07:18 +0900 Message-Id: <1472044039-16536-5-git-send-email-woogyom.kim@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1472044039-16536-1-git-send-email-woogyom.kim@gmail.com> References: <1472044039-16536-1-git-send-email-woogyom.kim@gmail.com> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Paring DT properties and getting PHY IO (memory mapped or I2C) in one function. Cc: Kukjin Kim Cc: Krzysztof Kozlowski Cc: David Airlie Cc: Inki Dae Cc: Joonyoung Shim Cc: Seung-Woo Kim Cc: Kyungmin Park Cc: Rob Herring Cc: devicetree@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-samsung-soc@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Signed-off-by: Milo Kim --- drivers/gpu/drm/exynos/exynos_hdmi.c | 63 +++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c index 8d99b5d..249cb23 100644 --- a/drivers/gpu/drm/exynos/exynos_hdmi.c +++ b/drivers/gpu/drm/exynos/exynos_hdmi.c @@ -1790,16 +1790,44 @@ static int hdmi_get_ddc_adapter(struct hdmi_context *hdata) return 0; } -static struct device_node *hdmi_legacy_phy_dt_binding(struct device *dev) +static int hdmi_get_phy_io(struct hdmi_context *hdata) { const char *compatible_str = "samsung,exynos4212-hdmiphy"; + struct device_node *np; + int ret = 0; + + np = of_find_compatible_node(NULL, NULL, compatible_str); + if (!np) { + np = of_parse_phandle(hdata->dev->of_node, "phy", 0); + if (!np) { + DRM_ERROR("Failed to find hdmiphy node in device tree\n"); + return -ENODEV; + } + } + + if (hdata->drv_data->is_apb_phy) { + hdata->regs_hdmiphy = of_iomap(np, 0); + if (!hdata->regs_hdmiphy) { + DRM_ERROR("failed to ioremap hdmi phy\n"); + ret = -ENOMEM; + goto out; + } + } else { + hdata->hdmiphy_port = of_find_i2c_device_by_node(np); + if (!hdata->hdmiphy_port) { + DRM_ERROR("Failed to get hdmi phy i2c client\n"); + ret = -EPROBE_DEFER; + goto out; + } + } - return of_find_compatible_node(NULL, NULL, compatible_str); +out: + of_node_put(np); + return ret; } static int hdmi_probe(struct platform_device *pdev) { - struct device_node *phy_node; struct device *dev = &pdev->dev; struct hdmi_context *hdata; struct resource *res; @@ -1833,34 +1861,9 @@ static int hdmi_probe(struct platform_device *pdev) if (ret) return ret; - phy_node = hdmi_legacy_phy_dt_binding(dev); - if (phy_node) - goto out_get_phy_port; - - phy_node = of_parse_phandle(dev->of_node, "phy", 0); - if (!phy_node) { - DRM_ERROR("Failed to find hdmiphy node in device tree\n"); - ret = -ENODEV; + ret = hdmi_get_phy_io(hdata); + if (ret) goto err_ddc; - } - of_node_put(dev->of_node); - -out_get_phy_port: - if (hdata->drv_data->is_apb_phy) { - hdata->regs_hdmiphy = of_iomap(phy_node, 0); - if (!hdata->regs_hdmiphy) { - DRM_ERROR("failed to ioremap hdmi phy\n"); - ret = -ENOMEM; - goto err_ddc; - } - } else { - hdata->hdmiphy_port = of_find_i2c_device_by_node(phy_node); - if (!hdata->hdmiphy_port) { - DRM_ERROR("Failed to get hdmi phy i2c client\n"); - ret = -EPROBE_DEFER; - goto err_ddc; - } - } INIT_DELAYED_WORK(&hdata->hotplug_work, hdmi_hotplug_work_func);