Skip to content

Commit 5b54065

Browse files
author
Dinh Nguyen
committed
FogBugz #189684-1: Enhance QSPI driver to use common clock framework
Modify the QSPI driver so that it can get the clock from the DTS entry and use the clock driver to get the correct clock rate. Also update the GPLv2 license. Signed-off-by: Dinh Nguyen <[email protected]>
1 parent a02fb5c commit 5b54065

File tree

2 files changed

+28
-29
lines changed

2 files changed

+28
-29
lines changed

drivers/spi/spi-cadence-qspi.c

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
/*
22
* Driver for Cadence QSPI Controller
33
*
4-
* Copyright (C) 2012 Altera Corporation
4+
* Copyright Altera Corporation (C) 2012-2014. All rights reserved.
55
*
66
* This program is free software; you can redistribute it and/or modify
7-
* it under the terms of the GNU General Public License as published by
8-
* the Free Software Foundation; either version 2 of the License, or
9-
* (at your option) any later version.
7+
* it under the terms and conditions of the GNU General Public License,
8+
* version 2, as published by the Free Software Foundation.
109
*
11-
* This program is distributed in the hope that it will be useful,
12-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14-
* GNU General Public License for more details.
10+
* This program is distributed in the hope it will be useful, but WITHOUT
11+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13+
* more details.
1514
*
16-
* You should have received a copy of the GNU General Public License
17-
* along with this program; if not, write to the Free Software
18-
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15+
* You should have received a copy of the GNU General Public License along with
16+
* this program. If not, see <http://www.gnu.org/licenses/>.
1917
*/
20-
18+
#include <linux/clk.h>
2119
#include <linux/kernel.h>
2220
#include <linux/module.h>
2321
#include <linux/interrupt.h>
@@ -244,12 +242,6 @@ static int cadence_qspi_of_get_pdata(struct platform_device *pdev)
244242
}
245243
pdata->num_chipselect = prop;
246244

247-
if (of_property_read_u32(np, "master-ref-clk", &prop)) {
248-
dev_err(&pdev->dev, "couldn't determine master-ref-clk\n");
249-
return -ENXIO;
250-
}
251-
pdata->master_ref_clk_hz = prop;
252-
253245
if (of_property_read_u32(np, "ext-decoder", &prop)) {
254246
dev_err(&pdev->dev, "couldn't determine ext-decoder\n");
255247
return -ENXIO;
@@ -505,6 +497,13 @@ static int cadence_qspi_probe(struct platform_device *pdev)
505497
pdev->dev.platform_data = pdata;
506498
pdata->qspi_ahb_phy = res_ahb->start;
507499

500+
cadence_qspi->clk = devm_clk_get(&pdev->dev, NULL);
501+
if (IS_ERR(cadence_qspi->clk)) {
502+
dev_err(&pdev->dev, "cannot get qspi clk\n");
503+
return PTR_ERR(cadence_qspi->clk);
504+
}
505+
pdata->master_ref_clk_hz = clk_get_rate(cadence_qspi->clk);
506+
508507
status = cadence_qspi_of_get_pdata(pdev);
509508
if (status) {
510509
dev_err(&pdev->dev, "Get platform data failed.\n");

drivers/spi/spi-cadence-qspi.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
/*
22
* Driver for Cadence QSPI Controller
33
*
4-
* Copyright (C) 2012 Altera Corporation
4+
* Copyright Altera Corporation (C) 2012-2014. All rights reserved.
55
*
66
* This program is free software; you can redistribute it and/or modify
7-
* it under the terms of the GNU General Public License as published by
8-
* the Free Software Foundation; either version 2 of the License, or
9-
* (at your option) any later version.
7+
* it under the terms and conditions of the GNU General Public License,
8+
* version 2, as published by the Free Software Foundation.
109
*
11-
* This program is distributed in the hope that it will be useful,
12-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14-
* GNU General Public License for more details.
10+
* This program is distributed in the hope it will be useful, but WITHOUT
11+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13+
* more details.
1514
*
16-
* You should have received a copy of the GNU General Public License
17-
* along with this program; if not, write to the Free Software
18-
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15+
* You should have received a copy of the GNU General Public License along with
16+
* this program. If not, see <http://www.gnu.org/licenses/>.
1917
*/
2018

2119
#ifndef __CADENCE_QSPI_H__
@@ -57,6 +55,8 @@ struct struct_cqspi
5755
struct list_head msg_queue;
5856
struct platform_device *pdev;
5957

58+
struct clk *clk;
59+
6060
/* lock protects queue and registers */
6161
spinlock_t lock;
6262
/* Virtual base address of the controller */

0 commit comments

Comments
 (0)