From patchwork Thu Mar 10 12:11:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shubhrajyoti Datta X-Patchwork-Id: 8556861 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1DD65C0553 for ; Thu, 10 Mar 2016 12:11:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 30A3620376 for ; Thu, 10 Mar 2016 12:11:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3B42020375 for ; Thu, 10 Mar 2016 12:11:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752566AbcCJMLS (ORCPT ); Thu, 10 Mar 2016 07:11:18 -0500 Received: from mail-bl2nam02on0062.outbound.protection.outlook.com ([104.47.38.62]:28924 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750744AbcCJMLR (ORCPT ); Thu, 10 Mar 2016 07:11:17 -0500 Received: from BL2NAM02FT059.eop-nam02.prod.protection.outlook.com (10.152.76.59) by BL2NAM02HT216.eop-nam02.prod.protection.outlook.com (10.152.76.185) with Microsoft SMTP Server (TLS) id 15.1.434.11; Thu, 10 Mar 2016 12:11:14 +0000 Authentication-Results: spf=pass (sender IP is 149.199.60.100) smtp.mailfrom=xilinx.com; kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=bestguesspass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.60.100 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.100; helo=xsj-pvapsmtpgw02; Received: from xsj-pvapsmtpgw02 (149.199.60.100) by BL2NAM02FT059.mail.protection.outlook.com (10.152.76.247) with Microsoft SMTP Server (TLS) id 15.1.434.11 via Frontend Transport; Thu, 10 Mar 2016 12:11:13 +0000 Received: from unknown-38-66.xilinx.com ([149.199.38.66]:55296 helo=xsj-pvapsmtp01) by xsj-pvapsmtpgw02 with esmtp (Exim 4.63) (envelope-from ) id 1adzQu-0008Og-QS; Thu, 10 Mar 2016 04:11:12 -0800 Received: from [127.0.0.1] (helo=localhost) by xsj-pvapsmtp01 with smtp (Exim 4.63) (envelope-from ) id 1adzQu-00032a-N0; Thu, 10 Mar 2016 04:11:12 -0800 Received: from [172.23.146.171] (helo=xhdl3763.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1adzQt-00032N-SP; Thu, 10 Mar 2016 04:11:12 -0800 Received: by xhdl3763.xilinx.com (Postfix, from userid 9049) id 106042CE0561; Thu, 10 Mar 2016 17:41:11 +0530 (IST) From: Shubhrajyoti Datta To: CC: , , , , , Shubhrajyoti Datta Subject: [PATCHv3 1/2] spi/spi-xilinx: Add clock support Date: Thu, 10 Mar 2016 17:41:04 +0530 Message-ID: <1457611865-40120-1-git-send-email-shubhraj@xilinx.com> X-Mailer: git-send-email 2.1.2 X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.0.0.1202-22182.005 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:149.199.60.100; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(438002)(199003)(189002)(5003940100001)(4326007)(47776003)(92566002)(2351001)(1220700001)(36756003)(1096002)(103686003)(2906002)(106466001)(86362001)(6806005)(87936001)(229853001)(52956003)(36386004)(11100500001)(63266004)(45336002)(4001430100002)(586003)(5008740100001)(42186005)(46386002)(19580405001)(33646002)(19580395003)(110136002)(90966002)(50226001)(189998001)(107886002)(50986999)(81166005)(48376002)(50466002)(107986001); DIR:OUT; SFP:1101; SCL:1; SRVR:BL2NAM02HT216; H:xsj-pvapsmtpgw02; FPR:; SPF:Pass; MLV:nov; A:1; MX:1; PTR:unknown-60-100.xilinx.com,xapps1.xilinx.com; LANG:en; MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 969061b4-d337-45e6-6aa8-08d348dd1364 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501002); SRVR:BL2NAM02HT216; X-Microsoft-Antispam-PRVS: <436fecf14fe248c5bc16f48889a80666@BL2NAM02HT216.eop-nam02.prod.protection.outlook.com> X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13024025)(13018025)(5005006)(8121501046)(13015025)(13017025)(13023025)(3002001)(10201501046); SRVR:BL2NAM02HT216; BCL:0; PCL:0; RULEID:; SRVR:BL2NAM02HT216; X-Forefront-PRVS: 08770259B4 X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Mar 2016 12:11:13.7192 (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.100]; Helo=[xsj-pvapsmtpgw02] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2NAM02HT216 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=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 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 drivers/spi/spi-xilinx.c | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-) diff --git a/drivers/spi/spi-xilinx.c b/drivers/spi/spi-xilinx.c index 3009121..426ce12 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 *clk; int irq; @@ -428,6 +430,22 @@ static int xilinx_spi_probe(struct platform_device *pdev) goto put_master; } + xspi->clk = devm_clk_get(&pdev->dev, "spi_fclk"); + if (IS_ERR(xspi->clk)) { + if (PTR_ERR(xspi->clk) == -ENOENT) { + xspi->clk = NULL; + } else { + ret = PTR_ERR(xspi->clk); + goto put_master; + } + } + + ret = clk_prepare_enable(xspi->clk); + if (ret) { + dev_err(&pdev->dev, "Unable to enable clock.\n"); + goto put_master; + } + master->bus_num = pdev->id; master->num_chipselect = num_cs; master->dev.of_node = pdev->dev.of_node; @@ -485,6 +503,7 @@ static int xilinx_spi_probe(struct platform_device *pdev) put_master: spi_master_put(master); + clk_disable_unprepare(xspi->clk); return ret; } @@ -503,6 +522,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->clk); return 0; }