Skip to content

Commit afbe06a

Browse files
committed
spi: atmel-quadspi: Add support for sam9x7 QSPI
- Add support for the sam9x7 QSPI controller in the QSPI driver. - The sam9x7 QSPI controller does not support pad calibration. - The data rate supported is upto 100 MHz and the GCK is a 2x clock. Signed-off-by: Varshini Rajendran <varshini.rajendran@microchip.com> [durai.manickamkr@microchip.com: logically squashed the commits] Signed-off-by: Durai Manickam KR <durai.manickamkr@microchip.com>
1 parent 49d0b52 commit afbe06a

1 file changed

Lines changed: 32 additions & 6 deletions

File tree

drivers/spi/atmel-quadspi.c

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@
6565
#define SAMA7G5_QSPI0_MAX_SPEED_HZ 200000000
6666
#define SAMA7G5_QSPI1_SDR_MAX_SPEED_HZ 133000000
6767

68+
#define SAM9X7_QSPI_MAX_SPEED_HZ 100000000
69+
6870
/* Bitfields in QSPI_CR (Control Register) */
6971
#define QSPI_CR_QSPIEN BIT(0)
7072
#define QSPI_CR_QSPIDIS BIT(1)
@@ -258,11 +260,13 @@ static const struct atmel_qspi_pcal pcal[ATMEL_QSPI_PCAL_ARRAY_SIZE] = {
258260

259261
struct atmel_qspi_caps {
260262
u32 max_speed_hz;
263+
u32 gclk_freq_hz;
261264
bool has_qspick;
262265
bool has_gclk;
263266
bool has_ricr;
264267
bool octal;
265268
bool has_dma;
269+
bool is_9x7;
266270
};
267271

268272
struct atmel_qspi_ops;
@@ -1021,11 +1025,17 @@ static int atmel_qspi_set_pad_calibration(struct atmel_qspi *aq)
10211025
/* DLL On + start calibration. */
10221026
atmel_qspi_write(QSPI_CR_DLLON | QSPI_CR_STPCAL, aq, QSPI_CR);
10231027

1024-
/* Check synchronization status before updating configuration. */
1025-
ret = readl_poll_timeout(aq->regs + QSPI_SR2, val,
1026-
(val & QSPI_SR2_DLOCK) &&
1027-
!(val & QSPI_SR2_CALBSY), 40,
1028-
ATMEL_QSPI_TIMEOUT);
1028+
/*
1029+
* Check synchronization status before updating configuration.
1030+
* This synchronization check is not applicable for sam9x7 SOC
1031+
* because there is no pad calibration support.
1032+
*/
1033+
if (!aq->caps->is_9x7) {
1034+
ret = readl_poll_timeout(aq->regs + QSPI_SR2, val,
1035+
(val & QSPI_SR2_DLOCK) &&
1036+
!(val & QSPI_SR2_CALBSY), 40,
1037+
ATMEL_QSPI_TIMEOUT);
1038+
}
10291039

10301040
/* Refresh analogic blocks every 1 ms.*/
10311041
atmel_qspi_write(FIELD_PREP(QSPI_REFRESH_DELAY_COUNTER,
@@ -1057,7 +1067,8 @@ static int atmel_qspi_set_gclk(struct atmel_qspi *aq)
10571067
else
10581068
atmel_qspi_write(0, aq, QSPI_DLLCFG);
10591069

1060-
ret = clk_set_rate(aq->gclk, aq->slave_max_speed_hz);
1070+
ret = clk_set_rate(aq->gclk, aq->caps->gclk_freq_hz);
1071+
10611072
if (ret) {
10621073
dev_err(&aq->pdev->dev, "Failed to set generic clock rate.\n");
10631074
return ret;
@@ -1578,17 +1589,28 @@ static const struct atmel_qspi_caps atmel_sam9x60_qspi_caps = {
15781589

15791590
static const struct atmel_qspi_caps atmel_sama7g5_ospi_caps = {
15801591
.max_speed_hz = SAMA7G5_QSPI0_MAX_SPEED_HZ,
1592+
.gclk_freq_hz = SAMA7G5_QSPI0_MAX_SPEED_HZ,
15811593
.has_gclk = true,
15821594
.octal = true,
15831595
.has_dma = true,
15841596
};
15851597

15861598
static const struct atmel_qspi_caps atmel_sama7g5_qspi_caps = {
15871599
.max_speed_hz = SAMA7G5_QSPI1_SDR_MAX_SPEED_HZ,
1600+
.gclk_freq_hz = SAMA7G5_QSPI1_SDR_MAX_SPEED_HZ,
15881601
.has_gclk = true,
15891602
.has_dma = true,
15901603
};
15911604

1605+
static const struct atmel_qspi_caps atmel_sam9x7_ospi_caps = {
1606+
.max_speed_hz = SAM9X7_QSPI_MAX_SPEED_HZ,
1607+
.gclk_freq_hz = 2 * SAM9X7_QSPI_MAX_SPEED_HZ,
1608+
.has_gclk = true,
1609+
.octal = true,
1610+
.has_dma = true,
1611+
.is_9x7 = true,
1612+
};
1613+
15921614
static const struct of_device_id atmel_qspi_dt_ids[] = {
15931615
{
15941616
.compatible = "atmel,sama5d2-qspi",
@@ -1606,6 +1628,10 @@ static const struct of_device_id atmel_qspi_dt_ids[] = {
16061628
.compatible = "microchip,sama7g5-qspi",
16071629
.data = &atmel_sama7g5_qspi_caps,
16081630
},
1631+
{
1632+
.compatible = "microchip,sam9x7-ospi",
1633+
.data = &atmel_sam9x7_ospi_caps,
1634+
},
16091635

16101636
{ /* sentinel */ }
16111637
};

0 commit comments

Comments
 (0)