Skip to content

Commit 1a64e6a

Browse files
Mihai Saincristibirsan
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 afbe06a commit 1a64e6a

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");
@@ -1589,22 +1592,19 @@ static const struct atmel_qspi_caps atmel_sam9x60_qspi_caps = {
15891592

15901593
static const struct atmel_qspi_caps atmel_sama7g5_ospi_caps = {
15911594
.max_speed_hz = SAMA7G5_QSPI0_MAX_SPEED_HZ,
1592-
.gclk_freq_hz = SAMA7G5_QSPI0_MAX_SPEED_HZ,
15931595
.has_gclk = true,
15941596
.octal = true,
15951597
.has_dma = true,
15961598
};
15971599

15981600
static const struct atmel_qspi_caps atmel_sama7g5_qspi_caps = {
15991601
.max_speed_hz = SAMA7G5_QSPI1_SDR_MAX_SPEED_HZ,
1600-
.gclk_freq_hz = SAMA7G5_QSPI1_SDR_MAX_SPEED_HZ,
16011602
.has_gclk = true,
16021603
.has_dma = true,
16031604
};
16041605

16051606
static const struct atmel_qspi_caps atmel_sam9x7_ospi_caps = {
16061607
.max_speed_hz = SAM9X7_QSPI_MAX_SPEED_HZ,
1607-
.gclk_freq_hz = 2 * SAM9X7_QSPI_MAX_SPEED_HZ,
16081608
.has_gclk = true,
16091609
.octal = true,
16101610
.has_dma = true,

0 commit comments

Comments
 (0)