From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.2 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,UNWANTED_LANGUAGE_BODY,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2E39C43219 for ; Sat, 27 Apr 2019 22:06:30 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8C4F3206E0 for ; Sat, 27 Apr 2019 22:06:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="jDFe4Eqx"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=xilinx.onmicrosoft.com header.i=@xilinx.onmicrosoft.com header.b="J/prrZ0+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8C4F3206E0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=7bM8SdapGUuIpfdxyc9vk84s13BmjU7C+RlFI7oJktw=; b=jDFe4Eqx/O/JBD 0mT34U/kjXIM8bM99VoOJCAZinueYj8iQtnQKNKWbqHaM1W6ENOpQU6MLp1krfOeToQ7Rw7RNdWkj W1yBLY+/hYQT/dGxbWEQWGmhq38MhnRldnGI4CpmTXvASX6GdqfbFRmtvPGSfWzcfev06cFZWDd+h 0y194tzgqXKXI2/yzFX0CHfxx7B86Hlvi0nYH0Cm3wo897foAoHj656zR3KRPDjHkc2NiZOjMsfTh /K3YLn+EbFZQ6vPgjtKrJ6T9IG3DGskEBDG72JQ5/PjfUlWR4SGFEwprnN2SYqot7KIPpUtsPvTsp craiqOefvx5PTxsOk6VQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hKVSm-0001r8-WE; Sat, 27 Apr 2019 22:06:29 +0000 Received: from mail-eopbgr810045.outbound.protection.outlook.com ([40.107.81.45] helo=NAM01-BY2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hKVRk-0000Ts-0Z for linux-arm-kernel@lists.infradead.org; Sat, 27 Apr 2019 22:05:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector1-xilinx-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4KG6tPgbFXqsNx0PbtL/51rJKF6iU6ts7qJXoIywukE=; b=J/prrZ0+qn01qb9P05ZujUSmr4eZHLk/pm+FMxtvlwlevnrv2Pj58Lbc52IjwYnI5XZX36vv+Jr5vmKYb2nd+FFje+RrzvDmhUs1GZcbcQvQesNLev4Mr6eZgkGB7wT0VMP39vC5aQrVFx+LfOk73TYQ2o13+tOVevedRsHiePk= Received: from SN4PR0201CA0031.namprd02.prod.outlook.com (2603:10b6:803:2e::17) by BY2PR02MB153.namprd02.prod.outlook.com (2a01:111:e400:2c20::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.1835.14; Sat, 27 Apr 2019 22:05:19 +0000 Received: from CY1NAM02FT061.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e45::200) by SN4PR0201CA0031.outlook.office365.com (2603:10b6:803:2e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1835.12 via Frontend Transport; Sat, 27 Apr 2019 22:05:18 +0000 Authentication-Results: spf=pass (sender IP is 149.199.80.198) smtp.mailfrom=xilinx.com; arndb.de; dkim=none (message not signed) header.d=none;arndb.de; dmarc=bestguesspass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.80.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.80.198; helo=xir-pvapexch02.xlnx.xilinx.com; Received: from xir-pvapexch02.xlnx.xilinx.com (149.199.80.198) by CY1NAM02FT061.mail.protection.outlook.com (10.152.75.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.1835.13 via Frontend Transport; Sat, 27 Apr 2019 22:05:17 +0000 Received: from xir-pvapexch01.xlnx.xilinx.com (172.21.17.15) by xir-pvapexch02.xlnx.xilinx.com (172.21.17.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1531.3; Sat, 27 Apr 2019 23:05:12 +0100 Received: from smtp.xilinx.com (172.21.105.197) by xir-pvapexch01.xlnx.xilinx.com (172.21.17.15) with Microsoft SMTP Server id 15.1.1531.3 via Frontend Transport; Sat, 27 Apr 2019 23:05:12 +0100 Received: from [149.199.110.15] (port=52636 helo=xirdraganc40.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1hKVRY-0002Gu-2N; Sat, 27 Apr 2019 23:05:12 +0100 From: Dragan Cvetic To: , , , , , , Subject: [PATCH V3 03/12] misc: xilinx_sdfec: Add CCF support Date: Sat, 27 Apr 2019 23:04:57 +0100 Message-ID: <1556402706-176271-4-git-send-email-dragan.cvetic@xilinx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1556402706-176271-1-git-send-email-dragan.cvetic@xilinx.com> References: <1556402706-176271-1-git-send-email-dragan.cvetic@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:149.199.80.198; IPV:CAL; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(39860400002)(396003)(346002)(376002)(136003)(2980300002)(189003)(199004)(956004)(11346002)(2616005)(50466002)(476003)(106002)(48376002)(60926002)(446003)(5660300002)(93146003)(54906003)(426003)(16586007)(110136005)(316002)(126002)(70586007)(36906005)(70206006)(305945005)(4326008)(71366001)(47776003)(336012)(478600001)(186003)(7636002)(356004)(6666004)(2201001)(44832011)(50226002)(14444005)(26826003)(9786002)(26005)(51416003)(2906002)(8676002)(8936002)(246002)(486006)(7696005)(28376004)(76176011)(36756003)(107886003)(76130400001)(102446001); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR02MB153; H:xir-pvapexch02.xlnx.xilinx.com; FPR:; SPF:Pass; LANG:en; PTR:unknown-80-198.xilinx.com; MX:1; A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 520920e5-08fc-45e8-fea5-08d6cb5c6f5b X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(4709054)(2017052603328); SRVR:BY2PR02MB153; X-MS-TrafficTypeDiagnostic: BY2PR02MB153: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:185; X-Forefront-PRVS: 0020414413 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: s6Je9SotuiB5XINkq9LktTKgllMk7NNKjzo6k8MZlA6tEPf+wCWwNJMxPkzbSiseqPfHmQo2m81s0SYRJ/x7ggHWsIz+6giGWgfUB8eHpuii1uGn59Bng/tCth2J0tIqB9+ovoykpHqBueHB2XpNhsP6wF9eFzI1uQPCpxgf9Mv0TO7brnQgpSR0WmcLa/qKOB3fVlsm/1EP5YAQhcztTdLhgwXUzkk6LnJMA2olHxHcno38mLiljAytQzIYFn2KGzncX3iChR3S5GCdtBipWP11vDV/7h7C1XTBSpmi5O5ju3TKUhUpkQLc/OaeYbkXpETFgdJ44cJqoPUjRpmuO2n9RMfHIzGwGllnuVAO7Oclqua0sw/05xfl1JwStQqi31ldFJd7lqn9TCQLfEMHdo83eJ2wzOqucCjEtu1tPjM= X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Apr 2019 22:05:17.9178 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 520920e5-08fc-45e8-fea5-08d6cb5c6f5b X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.80.198]; Helo=[xir-pvapexch02.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR02MB153 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190427_150524_276563_A12214AE X-CRM114-Status: UNSURE ( 9.71 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dragan Cvetic , Derek Kiernan , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add the support for Linux Clock Control Framework (CCF). Registers and enables clocks with the Clock Control Framework (CCF), to prevent shared clocks from been disabled. Tested-by: Dragan Cvetic Signed-off-by: Derek Kiernan Signed-off-by: Dragan Cvetic --- drivers/misc/xilinx_sdfec.c | 154 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) diff --git a/drivers/misc/xilinx_sdfec.c b/drivers/misc/xilinx_sdfec.c index 278754b..a52a5c6 100644 --- a/drivers/misc/xilinx_sdfec.c +++ b/drivers/misc/xilinx_sdfec.c @@ -37,6 +37,28 @@ static atomic_t xsdfec_ndevs = ATOMIC_INIT(0); static dev_t xsdfec_devt; /** + * struct xsdfec_clks - For managing SD-FEC clocks + * @core_clk: Main processing clock for core + * @axi_clk: AXI4-Lite memory-mapped clock + * @din_words_clk: DIN Words AXI4-Stream Slave clock + * @din_clk: DIN AXI4-Stream Slave clock + * @dout_clk: DOUT Words AXI4-Stream Slave clock + * @dout_words_clk: DOUT AXI4-Stream Slave clock + * @ctrl_clk: Control AXI4-Stream Slave clock + * @status_clk: Status AXI4-Stream Slave clock + */ +struct xsdfec_clks { + struct clk *core_clk; + struct clk *axi_clk; + struct clk *din_words_clk; + struct clk *din_clk; + struct clk *dout_clk; + struct clk *dout_words_clk; + struct clk *ctrl_clk; + struct clk *status_clk; +}; + +/** * struct xsdfec_dev - Driver data for SDFEC * @regs: device physical base address * @dev: pointer to device struct @@ -44,6 +66,7 @@ static dev_t xsdfec_devt; * @open_count: Count of char device being opened * @xsdfec_cdev: Character device handle * @irq_lock: Driver spinlock + * @clks: Clocks managed by the SDFEC driver * * This structure contains necessary state for SDFEC driver to operate */ @@ -55,12 +78,136 @@ struct xsdfec_dev { struct cdev xsdfec_cdev; /* Spinlock to protect state_updated and stats_updated */ spinlock_t irq_lock; + struct xsdfec_clks clks; }; static const struct file_operations xsdfec_fops = { .owner = THIS_MODULE, }; +static int xsdfec_clk_init(struct platform_device *pdev, + struct xsdfec_clks *clks) +{ + int err; + + clks->core_clk = devm_clk_get(&pdev->dev, "core_clk"); + if (IS_ERR(clks->core_clk)) { + dev_err(&pdev->dev, "failed to get core_clk"); + return PTR_ERR(clks->core_clk); + } + + clks->axi_clk = devm_clk_get(&pdev->dev, "s_axi_aclk"); + if (IS_ERR(clks->axi_clk)) { + dev_err(&pdev->dev, "failed to get axi_clk"); + return PTR_ERR(clks->axi_clk); + } + + clks->din_words_clk = devm_clk_get(&pdev->dev, "s_axis_din_words_aclk"); + if (IS_ERR(clks->din_words_clk)) + clks->din_words_clk = NULL; + + clks->din_clk = devm_clk_get(&pdev->dev, "s_axis_din_aclk"); + if (IS_ERR(clks->din_clk)) + clks->din_clk = NULL; + + clks->dout_clk = devm_clk_get(&pdev->dev, "m_axis_dout_aclk"); + if (IS_ERR(clks->dout_clk)) + clks->dout_clk = NULL; + + clks->dout_words_clk = + devm_clk_get(&pdev->dev, "s_axis_dout_words_aclk"); + if (IS_ERR(clks->dout_words_clk)) + clks->dout_words_clk = NULL; + + clks->ctrl_clk = devm_clk_get(&pdev->dev, "s_axis_ctrl_aclk"); + if (IS_ERR(clks->ctrl_clk)) + clks->ctrl_clk = NULL; + + clks->status_clk = devm_clk_get(&pdev->dev, "m_axis_status_aclk"); + if (IS_ERR(clks->status_clk)) + clks->status_clk = NULL; + + err = clk_prepare_enable(clks->core_clk); + if (err) { + dev_err(&pdev->dev, "failed to enable core_clk (%d)", err); + return err; + } + + err = clk_prepare_enable(clks->axi_clk); + if (err) { + dev_err(&pdev->dev, "failed to enable axi_clk (%d)", err); + goto err_disable_core_clk; + } + + err = clk_prepare_enable(clks->din_clk); + if (err) { + dev_err(&pdev->dev, "failed to enable din_clk (%d)", err); + goto err_disable_axi_clk; + } + + err = clk_prepare_enable(clks->din_words_clk); + if (err) { + dev_err(&pdev->dev, "failed to enable din_words_clk (%d)", err); + goto err_disable_din_clk; + } + + err = clk_prepare_enable(clks->dout_clk); + if (err) { + dev_err(&pdev->dev, "failed to enable dout_clk (%d)", err); + goto err_disable_din_words_clk; + } + + err = clk_prepare_enable(clks->dout_words_clk); + if (err) { + dev_err(&pdev->dev, "failed to enable dout_words_clk (%d)", + err); + goto err_disable_dout_clk; + } + + err = clk_prepare_enable(clks->ctrl_clk); + if (err) { + dev_err(&pdev->dev, "failed to enable ctrl_clk (%d)", err); + goto err_disable_dout_words_clk; + } + + err = clk_prepare_enable(clks->status_clk); + if (err) { + dev_err(&pdev->dev, "failed to enable status_clk (%d)\n", err); + goto err_disable_ctrl_clk; + } + + return err; + +err_disable_ctrl_clk: + clk_disable_unprepare(clks->ctrl_clk); +err_disable_dout_words_clk: + clk_disable_unprepare(clks->dout_words_clk); +err_disable_dout_clk: + clk_disable_unprepare(clks->dout_clk); +err_disable_din_words_clk: + clk_disable_unprepare(clks->din_words_clk); +err_disable_din_clk: + clk_disable_unprepare(clks->din_clk); +err_disable_axi_clk: + clk_disable_unprepare(clks->axi_clk); +err_disable_core_clk: + clk_disable_unprepare(clks->core_clk); + + return err; +} + +static void xsdfec_disable_all_clks(struct xsdfec_clks *clks) +{ + clk_disable_unprepare(clks->status_clk); + clk_disable_unprepare(clks->ctrl_clk); + clk_disable_unprepare(clks->dout_words_clk); + clk_disable_unprepare(clks->dout_clk); + clk_disable_unprepare(clks->din_words_clk); + clk_disable_unprepare(clks->din_clk); + clk_disable_unprepare(clks->core_clk); + clk_disable_unprepare(clks->axi_clk); +} + static int xsdfec_probe(struct platform_device *pdev) { struct xsdfec_dev *xsdfec; @@ -77,6 +224,10 @@ static int xsdfec_probe(struct platform_device *pdev) xsdfec->config.fec_id = atomic_read(&xsdfec_ndevs); spin_lock_init(&xsdfec->irq_lock); + err = xsdfec_clk_init(pdev, &xsdfec->clks); + if (err) + return err; + dev = xsdfec->dev; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); xsdfec->regs = devm_ioremap_resource(dev, res); @@ -124,6 +275,7 @@ static int xsdfec_probe(struct platform_device *pdev) err_xsdfec_cdev: cdev_del(&xsdfec->xsdfec_cdev); err_xsdfec_dev: + xsdfec_disable_all_clks(&xsdfec->clks); return err; } @@ -141,6 +293,8 @@ static int xsdfec_remove(struct platform_device *pdev) return -EIO; } + xsdfec_disable_all_clks(&xsdfec->clks); + device_destroy(xsdfec_class, MKDEV(MAJOR(xsdfec_devt), xsdfec->config.fec_id)); cdev_del(&xsdfec->xsdfec_cdev); -- 2.7.4 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel