From patchwork Sat Mar 12 08:00:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shubhrajyoti Datta X-Patchwork-Id: 8571071 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B6F189F46A for ; Sat, 12 Mar 2016 08:16:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CBF052035E for ; Sat, 12 Mar 2016 08:15:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C1D082034C for ; Sat, 12 Mar 2016 08:15:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751225AbcCLIP6 (ORCPT ); Sat, 12 Mar 2016 03:15:58 -0500 Received: from mail-sn1nam02on0077.outbound.protection.outlook.com ([104.47.36.77]:32250 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750981AbcCLIP5 (ORCPT ); Sat, 12 Mar 2016 03:15:57 -0500 X-Greylist: delayed 910 seconds by postgrey-1.27 at vger.kernel.org; Sat, 12 Mar 2016 03:15:57 EST Received: from SN1NAM02FT016.eop-nam02.prod.protection.outlook.com (10.152.72.58) by SN1NAM02HT225.eop-nam02.prod.protection.outlook.com (10.152.73.95) with Microsoft SMTP Server (TLS) id 15.1.427.7; Sat, 12 Mar 2016 08:00:46 +0000 Authentication-Results: spf=pass (sender IP is 149.199.60.83) smtp.mailfrom=xilinx.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.60.83 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.83; helo=xsj-pvapsmtpgw01; Received: from xsj-pvapsmtpgw01 (149.199.60.83) by SN1NAM02FT016.mail.protection.outlook.com (10.152.72.113) with Microsoft SMTP Server (TLS) id 15.1.434.11 via Frontend Transport; Sat, 12 Mar 2016 08:00:45 +0000 Received: from unknown-38-66.xilinx.com ([149.199.38.66] helo=xsj-pvapsmtp01) by xsj-pvapsmtpgw01 with esmtp (Exim 4.63) (envelope-from ) id 1aeeTd-0007LX-7q; Sat, 12 Mar 2016 00:00:45 -0800 Received: from [127.0.0.1] (helo=localhost) by xsj-pvapsmtp01 with smtp (Exim 4.63) (envelope-from ) id 1aeeTd-0002tZ-3f; Sat, 12 Mar 2016 00:00:45 -0800 Received: from xsj-pvapsmtp01 (smtp2.xilinx.com [149.199.38.66]) by xsj-smtp-dlp2.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id u2C80dhG026619; Sat, 12 Mar 2016 00:00:40 -0800 Received: from [172.23.146.171] (helo=xhdl3763.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1aeeTX-0002rB-IE; Sat, 12 Mar 2016 00:00:39 -0800 Received: by xhdl3763.xilinx.com (Postfix, from userid 9049) id BC3412CE04E1; Sat, 12 Mar 2016 13:30:38 +0530 (IST) From: Shubhrajyoti Datta To: CC: , , , , , Shubhrajyoti Datta Subject: [PATCHv4 1/2] spi/spi-xilinx: Add clock support Date: Sat, 12 Mar 2016 13:30:36 +0530 Message-ID: <1457769637-5627-1-git-send-email-shubhraj@xilinx.com> X-Mailer: git-send-email 2.1.2 X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.0.0.1202-22186.003 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:149.199.60.83; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(438002)(189002)(199003)(6806005)(42186005)(87936001)(90966002)(63266004)(45336002)(586003)(86362001)(5008740100001)(47776003)(11100500001)(189998001)(92566002)(81166005)(50466002)(52956003)(48376002)(4001430100002)(107886002)(110136002)(106466001)(50986999)(33646002)(4326007)(1096002)(103686003)(5003940100001)(2906002)(36756003)(36386004)(50226001)(2351001)(19580405001)(1220700001)(229853001)(19580395003)(107986001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1NAM02HT225; H:xsj-pvapsmtpgw01; FPR:; SPF:Pass; MLV:sfv; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: c96ca4a4-6a7f-44f0-052e-08d34a4c6aee X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501002); SRVR:SN1NAM02HT225; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13015025)(13017025)(13024025)(13023025)(5005006)(8121501046)(13018025)(10201501046)(3002001); SRVR:SN1NAM02HT225; BCL:0; PCL:0; RULEID:; SRVR:SN1NAM02HT225; X-Forefront-PRVS: 0879599414 X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Mar 2016 08:00:45.8669 (UTC) X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.60.83]; Helo=[xsj-pvapsmtpgw01] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1NAM02HT225 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 Add basic clock support. The clocks are requested at probe and released at remove. Signed-off-by: Shubhrajyoti Datta --- v3 changes: Do not fail probe if no clock is given Add a clk name Fix some space errors v4 changes: correct the clock name also check for ENOENT to prevent breaking current dts drivers/spi/spi-xilinx.c | 28 +++++++++++++++++++++++++--- 1 files changed, 25 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi-xilinx.c b/drivers/spi/spi-xilinx.c index 3009121..bd9ad61 100644 --- a/drivers/spi/spi-xilinx.c +++ b/drivers/spi/spi-xilinx.c @@ -21,6 +21,7 @@ #include #include #include +#include #define XILINX_SPI_MAX_CS 32 @@ -83,6 +84,7 @@ struct xilinx_spi { struct spi_bitbang bitbang; struct completion done; void __iomem *regs; /* virt. address of the control registers */ + struct clk *aclk; /* AXI clock */ int irq; @@ -428,6 +430,24 @@ static int xilinx_spi_probe(struct platform_device *pdev) goto put_master; } + xspi->aclk = devm_clk_get(&pdev->dev, "s_axi_aclk"); + if (IS_ERR(xspi->aclk)) { + if (PTR_ERR(xspi->aclk) == -ENOENT) { + dev_err(&pdev->dev, "No clocks found for aclk\n"); + xspi->aclk = NULL; + } else { + dev_err(&pdev->dev, "axi clock error %d\n", ret); + ret = PTR_ERR(xspi->aclk); + goto put_master; + } + } + + ret = clk_prepare_enable(xspi->aclk); + if (ret) { + dev_err(&pdev->dev, "Unable to enable axi clock.\n"); + goto put_master; + } + master->bus_num = pdev->id; master->num_chipselect = num_cs; master->dev.of_node = pdev->dev.of_node; @@ -460,7 +480,7 @@ static int xilinx_spi_probe(struct platform_device *pdev) ret = devm_request_irq(&pdev->dev, xspi->irq, xilinx_spi_irq, 0, dev_name(&pdev->dev), xspi); if (ret) - goto put_master; + goto dis_master_clk; } /* SPI controller initializations */ @@ -469,7 +489,7 @@ static int xilinx_spi_probe(struct platform_device *pdev) ret = spi_bitbang_start(&xspi->bitbang); if (ret) { dev_err(&pdev->dev, "spi_bitbang_start FAILED\n"); - goto put_master; + goto dis_master_clk; } dev_info(&pdev->dev, "at 0x%08llX mapped to 0x%p, irq=%d\n", @@ -483,9 +503,10 @@ static int xilinx_spi_probe(struct platform_device *pdev) platform_set_drvdata(pdev, master); return 0; +dis_master_clk: + clk_disable_unprepare(xspi->aclk); put_master: spi_master_put(master); - return ret; } @@ -503,6 +524,7 @@ static int xilinx_spi_remove(struct platform_device *pdev) xspi->write_fn(0, regs_base + XIPIF_V123B_DGIER_OFFSET); spi_master_put(xspi->bitbang.master); + clk_disable_unprepare(xspi->aclk); return 0; }