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
259261struct 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
268272struct 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 ;
@@ -1622,17 +1633,28 @@ static const struct atmel_qspi_caps atmel_sam9x60_qspi_caps = {
16221633
16231634static const struct atmel_qspi_caps atmel_sama7g5_ospi_caps = {
16241635 .max_speed_hz = SAMA7G5_QSPI0_MAX_SPEED_HZ ,
1636+ .gclk_freq_hz = SAMA7G5_QSPI0_MAX_SPEED_HZ ,
16251637 .has_gclk = true,
16261638 .octal = true,
16271639 .has_dma = true,
16281640};
16291641
16301642static const struct atmel_qspi_caps atmel_sama7g5_qspi_caps = {
16311643 .max_speed_hz = SAMA7G5_QSPI1_SDR_MAX_SPEED_HZ ,
1644+ .gclk_freq_hz = SAMA7G5_QSPI1_SDR_MAX_SPEED_HZ ,
16321645 .has_gclk = true,
16331646 .has_dma = true,
16341647};
16351648
1649+ static const struct atmel_qspi_caps atmel_sam9x7_ospi_caps = {
1650+ .max_speed_hz = SAM9X7_QSPI_MAX_SPEED_HZ ,
1651+ .gclk_freq_hz = 2 * SAM9X7_QSPI_MAX_SPEED_HZ ,
1652+ .has_gclk = true,
1653+ .octal = true,
1654+ .has_dma = true,
1655+ .is_9x7 = true,
1656+ };
1657+
16361658static const struct of_device_id atmel_qspi_dt_ids [] = {
16371659 {
16381660 .compatible = "atmel,sama5d2-qspi" ,
@@ -1650,6 +1672,10 @@ static const struct of_device_id atmel_qspi_dt_ids[] = {
16501672 .compatible = "microchip,sama7g5-qspi" ,
16511673 .data = & atmel_sama7g5_qspi_caps ,
16521674 },
1675+ {
1676+ .compatible = "microchip,sam9x7-ospi" ,
1677+ .data = & atmel_sam9x7_ospi_caps ,
1678+ },
16531679
16541680 { /* sentinel */ }
16551681};
0 commit comments