Skip to content

Commit 84adb64

Browse files
Mihai Sainduraikvddp
authored andcommitted
spi: atmel-quadspi: Fix generic clock for sam9x7 SoC
Generic clock on sam9x7 must be 2 times higher than flash clock. Fix the calculation for generic clock in order to probe the flash. Fixes: afbe06a ("spi: atmel-quadspi: Add support for sam9x7 QSPI") Signed-off-by: Mihai Sain <mihai.sain@microchip.com>
1 parent 49b04cb commit 84adb64

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

drivers/spi/atmel-quadspi.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,6 @@ static const struct atmel_qspi_pcal pcal[ATMEL_QSPI_PCAL_ARRAY_SIZE] = {
260260

261261
struct atmel_qspi_caps {
262262
u32 max_speed_hz;
263-
u32 gclk_freq_hz;
264263
bool has_qspick;
265264
bool has_gclk;
266265
bool has_ricr;
@@ -1030,12 +1029,13 @@ static int atmel_qspi_set_pad_calibration(struct atmel_qspi *aq)
10301029
* This synchronization check is not applicable for sam9x7 SOC
10311030
* because there is no pad calibration support.
10321031
*/
1033-
if (!aq->caps->is_9x7) {
1032+
if (aq->caps->is_9x7)
1033+
ret=0;
1034+
else
10341035
ret = readl_poll_timeout(aq->regs + QSPI_SR2, val,
10351036
(val & QSPI_SR2_DLOCK) &&
10361037
!(val & QSPI_SR2_CALBSY), 40,
10371038
ATMEL_QSPI_TIMEOUT);
1038-
}
10391039

10401040
/* Refresh analogic blocks every 1 ms.*/
10411041
atmel_qspi_write(FIELD_PREP(QSPI_REFRESH_DELAY_COUNTER,
@@ -1067,7 +1067,10 @@ static int atmel_qspi_set_gclk(struct atmel_qspi *aq)
10671067
else
10681068
atmel_qspi_write(0, aq, QSPI_DLLCFG);
10691069

1070-
ret = clk_set_rate(aq->gclk, aq->caps->gclk_freq_hz);
1070+
if (aq->caps->is_9x7)
1071+
ret = clk_set_rate(aq->gclk, 2 * aq->slave_max_speed_hz);
1072+
else
1073+
ret = clk_set_rate(aq->gclk, aq->slave_max_speed_hz);
10711074

10721075
if (ret) {
10731076
dev_err(&aq->pdev->dev, "Failed to set generic clock rate.\n");
@@ -1633,22 +1636,19 @@ static const struct atmel_qspi_caps atmel_sam9x60_qspi_caps = {
16331636

16341637
static const struct atmel_qspi_caps atmel_sama7g5_ospi_caps = {
16351638
.max_speed_hz = SAMA7G5_QSPI0_MAX_SPEED_HZ,
1636-
.gclk_freq_hz = SAMA7G5_QSPI0_MAX_SPEED_HZ,
16371639
.has_gclk = true,
16381640
.octal = true,
16391641
.has_dma = true,
16401642
};
16411643

16421644
static const struct atmel_qspi_caps atmel_sama7g5_qspi_caps = {
16431645
.max_speed_hz = SAMA7G5_QSPI1_SDR_MAX_SPEED_HZ,
1644-
.gclk_freq_hz = SAMA7G5_QSPI1_SDR_MAX_SPEED_HZ,
16451646
.has_gclk = true,
16461647
.has_dma = true,
16471648
};
16481649

16491650
static const struct atmel_qspi_caps atmel_sam9x7_ospi_caps = {
16501651
.max_speed_hz = SAM9X7_QSPI_MAX_SPEED_HZ,
1651-
.gclk_freq_hz = 2 * SAM9X7_QSPI_MAX_SPEED_HZ,
16521652
.has_gclk = true,
16531653
.octal = true,
16541654
.has_dma = true,

0 commit comments

Comments
 (0)