From patchwork Fri Aug 15 05:41:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 4726221 Return-Path: X-Original-To: patchwork-linux-arm-msm@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 36C319F38C for ; Fri, 15 Aug 2014 05:41:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3CFFA2017D for ; Fri, 15 Aug 2014 05:41:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 555D720173 for ; Fri, 15 Aug 2014 05:41:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751067AbaHOFlZ (ORCPT ); Fri, 15 Aug 2014 01:41:25 -0400 Received: from mail-pd0-f179.google.com ([209.85.192.179]:39279 "EHLO mail-pd0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751009AbaHOFlZ (ORCPT ); Fri, 15 Aug 2014 01:41:25 -0400 Received: by mail-pd0-f179.google.com with SMTP id v10so2837585pde.10 for ; Thu, 14 Aug 2014 22:41:24 -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; bh=/7CfMZPnoGmPb+/9eWu1k5H1frMi1TkUrXzBV0138PQ=; b=jzGHDJcATCfZ5I0uWXK7aw798Vnbc/TSHZPtcN3zI7WDSsYkU41p3JvhKECO331z/P oZsYRSUQ6DTVcwZaI0HqrztF/IFVS5Msyk8fmvjSr3m9mp9CQXo00yd+CPAX9pkAhcHV LnRiq7rTe/YBjtWe2jAdfBolHNqJ+ouK3y8X23oXm/F9WHgwVsL8Sp33+6eyl1x9rSLd 37ITHuJyX/oscQJhxsYrL3wDALjgW26sXFVxssVePXK+yyI1m8upUN6pLgPD/nUnx5Yq XOSGahQpN9Of0DIe58Y66pyBQYyyRP0hIvZwy+tqeqyIVxiHS0pqekzU4si94ImWChJf uB3w== X-Gm-Message-State: ALoCoQlY6JFAOOJROUu4gL03X53Wn4KSHWTrmb7CTYMuabHPAK1a5acaIZ0+HlBZ4pE+k88DVufO X-Received: by 10.66.97.99 with SMTP id dz3mr9339906pab.71.1408081284560; Thu, 14 Aug 2014 22:41:24 -0700 (PDT) Received: from localhost.localdomain ([117.222.40.137]) by mx.google.com with ESMTPSA id ob14sm10543172pdb.40.2014.08.14.22.41.20 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 14 Aug 2014 22:41:23 -0700 (PDT) From: Srinivas Kandagatla To: agross@codeaurora.org Cc: linux-arm-msm@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH v1] soc: qcom: do not disable the iface clock in probe Date: Fri, 15 Aug 2014 06:41:08 +0100 Message-Id: <1408081268-5748-1-git-send-email-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 1.9.1 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 use case here is when we have a bootconsole which is printing the characters on serial console and gsbi driver comes up after some time. As gsbi driver disables the clock in probe the bootconsole locks up. This patch fixes the problem by disabling the clock in platform remove rather than in probe. Tested-by: Linus Walleij Signed-off-by: Srinivas Kandagatla --- Changes since RFC: - none, just a subject line change. drivers/soc/qcom/qcom_gsbi.c | 46 +++++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/drivers/soc/qcom/qcom_gsbi.c b/drivers/soc/qcom/qcom_gsbi.c index 447458e..7e1f120 100644 --- a/drivers/soc/qcom/qcom_gsbi.c +++ b/drivers/soc/qcom/qcom_gsbi.c @@ -22,44 +22,63 @@ #define GSBI_CTRL_REG 0x0000 #define GSBI_PROTOCOL_SHIFT 4 +struct gsbi_info { + struct clk *hclk; + u32 mode; + u32 crci; +}; + static int gsbi_probe(struct platform_device *pdev) { struct device_node *node = pdev->dev.of_node; struct resource *res; void __iomem *base; - struct clk *hclk; - u32 mode, crci = 0; + struct gsbi_info *gsbi; + + gsbi = devm_kzalloc(&pdev->dev, sizeof(*gsbi), GFP_KERNEL); + + if (!gsbi) + return -ENOMEM; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); base = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(base)) return PTR_ERR(base); - if (of_property_read_u32(node, "qcom,mode", &mode)) { + if (of_property_read_u32(node, "qcom,mode", &gsbi->mode)) { dev_err(&pdev->dev, "missing mode configuration\n"); return -EINVAL; } /* not required, so default to 0 if not present */ - of_property_read_u32(node, "qcom,crci", &crci); + of_property_read_u32(node, "qcom,crci", &gsbi->crci); - dev_info(&pdev->dev, "GSBI port protocol: %d crci: %d\n", mode, crci); + dev_info(&pdev->dev, "GSBI port protocol: %d crci: %d\n", + gsbi->mode, gsbi->crci); + gsbi->hclk = devm_clk_get(&pdev->dev, "iface"); + if (IS_ERR(gsbi->hclk)) + return PTR_ERR(gsbi->hclk); - hclk = devm_clk_get(&pdev->dev, "iface"); - if (IS_ERR(hclk)) - return PTR_ERR(hclk); + clk_prepare_enable(gsbi->hclk); - clk_prepare_enable(hclk); - - writel_relaxed((mode << GSBI_PROTOCOL_SHIFT) | crci, + writel_relaxed((gsbi->mode << GSBI_PROTOCOL_SHIFT) | gsbi->crci, base + GSBI_CTRL_REG); /* make sure the gsbi control write is not reordered */ wmb(); - clk_disable_unprepare(hclk); + platform_set_drvdata(pdev, gsbi); + + return of_platform_populate(node, NULL, NULL, &pdev->dev); +} + +static int gsbi_remove(struct platform_device *pdev) +{ + struct gsbi_info *gsbi = platform_get_drvdata(pdev); + + clk_disable_unprepare(gsbi->hclk); - return of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev); + return 0; } static const struct of_device_id gsbi_dt_match[] = { @@ -76,6 +95,7 @@ static struct platform_driver gsbi_driver = { .of_match_table = gsbi_dt_match, }, .probe = gsbi_probe, + .remove = gsbi_remove, }; module_platform_driver(gsbi_driver);