@@ -222,13 +222,16 @@ static const struct of_device_id sam9x60_ws_ids[] = {
222222 { /* sentinel */ }
223223};
224224
225- static const struct of_device_id sama7g5_ws_ids [] = {
225+ static const struct of_device_id sama7_ws_ids [] = {
226+ { .compatible = "microchip,sama7d65-rtc" , .data = & ws_info [1 ] },
226227 { .compatible = "microchip,sama7g5-rtc" , .data = & ws_info [1 ] },
227228 { .compatible = "microchip,sama7g5-ohci" , .data = & ws_info [2 ] },
228229 { .compatible = "usb-ohci" , .data = & ws_info [2 ] },
229230 { .compatible = "atmel,at91sam9g45-ehci" , .data = & ws_info [2 ] },
230231 { .compatible = "usb-ehci" , .data = & ws_info [2 ] },
232+ { .compatible = "microchip,sama7d65-sdhci" , .data = & ws_info [3 ] },
231233 { .compatible = "microchip,sama7g5-sdhci" , .data = & ws_info [3 ] },
234+ { .compatible = "microchip,sama7d65-rtt" , .data = & ws_info [4 ] },
232235 { .compatible = "microchip,sama7g5-rtt" , .data = & ws_info [4 ] },
233236 { /* sentinel */ }
234237};
@@ -545,11 +548,12 @@ extern u32 at91_pm_suspend_in_sram_sz;
545548
546549static int at91_suspend_finish (unsigned long val )
547550{
548- unsigned char modified_gray_code [] = {
549- 0x00 , 0x01 , 0x02 , 0x03 , 0x06 , 0x07 , 0x04 , 0x05 , 0x0c , 0x0d ,
550- 0x0e , 0x0f , 0x0a , 0x0b , 0x08 , 0x09 , 0x18 , 0x19 , 0x1a , 0x1b ,
551- 0x1e , 0x1f , 0x1c , 0x1d , 0x14 , 0x15 , 0x16 , 0x17 , 0x12 , 0x13 ,
552- 0x10 , 0x11 ,
551+ /* SYNOPSYS workaround to fix a bug in the calibration logic */
552+ unsigned char modified_fix_code [] = {
553+ 0x00 , 0x01 , 0x01 , 0x06 , 0x07 , 0x0c , 0x06 , 0x07 , 0x0b , 0x18 ,
554+ 0x0a , 0x0b , 0x0c , 0x0d , 0x0d , 0x0a , 0x13 , 0x13 , 0x12 , 0x13 ,
555+ 0x14 , 0x15 , 0x15 , 0x12 , 0x18 , 0x19 , 0x19 , 0x1e , 0x1f , 0x14 ,
556+ 0x1e , 0x1f ,
553557 };
554558 unsigned int tmp , index ;
555559 int i ;
@@ -560,25 +564,25 @@ static int at91_suspend_finish(unsigned long val)
560564 * restore the ZQ0SR0 with the value saved here. But the
561565 * calibration is buggy and restoring some values from ZQ0SR0
562566 * is forbidden and risky thus we need to provide processed
563- * values for these (modified gray code values) .
567+ * values for these.
564568 */
565569 tmp = readl (soc_pm .data .ramc_phy + DDR3PHY_ZQ0SR0 );
566570
567571 /* Store pull-down output impedance select. */
568572 index = (tmp >> DDR3PHY_ZQ0SR0_PDO_OFF ) & 0x1f ;
569- soc_pm .bu -> ddr_phy_calibration [0 ] = modified_gray_code [index ];
573+ soc_pm .bu -> ddr_phy_calibration [0 ] = modified_fix_code [index ] << DDR3PHY_ZQ0SR0_PDO_OFF ;
570574
571575 /* Store pull-up output impedance select. */
572576 index = (tmp >> DDR3PHY_ZQ0SR0_PUO_OFF ) & 0x1f ;
573- soc_pm .bu -> ddr_phy_calibration [0 ] |= modified_gray_code [index ];
577+ soc_pm .bu -> ddr_phy_calibration [0 ] |= modified_fix_code [index ] << DDR3PHY_ZQ0SR0_PUO_OFF ;
574578
575579 /* Store pull-down on-die termination impedance select. */
576580 index = (tmp >> DDR3PHY_ZQ0SR0_PDODT_OFF ) & 0x1f ;
577- soc_pm .bu -> ddr_phy_calibration [0 ] |= modified_gray_code [index ];
581+ soc_pm .bu -> ddr_phy_calibration [0 ] |= modified_fix_code [index ] << DDR3PHY_ZQ0SR0_PDODT_OFF ;
578582
579583 /* Store pull-up on-die termination impedance select. */
580584 index = (tmp >> DDR3PHY_ZQ0SRO_PUODT_OFF ) & 0x1f ;
581- soc_pm .bu -> ddr_phy_calibration [0 ] |= modified_gray_code [index ];
585+ soc_pm .bu -> ddr_phy_calibration [0 ] |= modified_fix_code [index ] << DDR3PHY_ZQ0SRO_PUODT_OFF ;
582586
583587 /*
584588 * The 1st 8 words of memory might get corrupted in the process
@@ -643,6 +647,11 @@ static void at91_pm_suspend(suspend_state_t state)
643647 at91_suspend_sram_fn = fncpy (at91_suspend_sram_fn ,
644648 & at91_pm_suspend_in_sram ,
645649 at91_pm_suspend_in_sram_sz );
650+
651+ if (IS_ENABLED (CONFIG_SOC_SAMA7D65 )) {
652+ /* SHDWC.SR */
653+ readl (soc_pm .data .shdwc + 0x08 );
654+ }
646655 } else {
647656 at91_suspend_finish (0 );
648657 }
@@ -1061,7 +1070,8 @@ static int __init at91_pm_backup_init(void)
10611070 int ret = - ENODEV , located = 0 ;
10621071
10631072 if (!IS_ENABLED (CONFIG_SOC_SAMA5D2 ) &&
1064- !IS_ENABLED (CONFIG_SOC_SAMA7G5 ))
1073+ !IS_ENABLED (CONFIG_SOC_SAMA7G5 ) &&
1074+ !IS_ENABLED (CONFIG_SOC_SAMA7D65 ))
10651075 return - EPERM ;
10661076
10671077 if (!at91_is_pm_mode_active (AT91_PM_BACKUP ))
@@ -1329,6 +1339,7 @@ struct pmc_info {
13291339 unsigned long uhp_udp_mask ;
13301340 unsigned long mckr ;
13311341 unsigned long version ;
1342+ unsigned long mcks ;
13321343};
13331344
13341345static const struct pmc_info pmc_infos [] __initconst = {
@@ -1360,8 +1371,14 @@ static const struct pmc_info pmc_infos[] __initconst = {
13601371 {
13611372 .mckr = 0x28 ,
13621373 .version = AT91_PMC_V2 ,
1374+ .mcks = 4 ,
1375+ },
1376+ {
1377+ .uhp_udp_mask = AT91SAM926x_PMC_UHP ,
1378+ .mckr = 0x28 ,
1379+ .version = AT91_PMC_V2 ,
1380+ .mcks = 9 ,
13631381 },
1364-
13651382};
13661383
13671384static const struct of_device_id atmel_pmc_ids [] __initconst = {
@@ -1378,6 +1395,7 @@ static const struct of_device_id atmel_pmc_ids[] __initconst = {
13781395 { .compatible = "atmel,sama5d2-pmc" , .data = & pmc_infos [1 ] },
13791396 { .compatible = "microchip,sam9x60-pmc" , .data = & pmc_infos [4 ] },
13801397 { .compatible = "microchip,sam9x7-pmc" , .data = & pmc_infos [4 ] },
1398+ { .compatible = "microchip,sama7d65-pmc" , .data = & pmc_infos [6 ] },
13811399 { .compatible = "microchip,sama7g5-pmc" , .data = & pmc_infos [5 ] },
13821400 { /* sentinel */ },
13831401};
@@ -1448,6 +1466,7 @@ static void __init at91_pm_init(void (*pm_idle)(void))
14481466 soc_pm .data .uhp_udp_mask = pmc -> uhp_udp_mask ;
14491467 soc_pm .data .pmc_mckr_offset = pmc -> mckr ;
14501468 soc_pm .data .pmc_version = pmc -> version ;
1469+ soc_pm .data .pmc_mcks = pmc -> mcks ;
14511470
14521471 if (pm_idle )
14531472 arm_pm_idle = pm_idle ;
@@ -1671,7 +1690,7 @@ void __init sama7_pm_init(void)
16711690 at91_pm_modes_init (iomaps , ARRAY_SIZE (iomaps ));
16721691 at91_pm_init (NULL );
16731692
1674- soc_pm .ws_ids = sama7g5_ws_ids ;
1693+ soc_pm .ws_ids = sama7_ws_ids ;
16751694 soc_pm .config_pmc_ws = at91_sam9x60_config_pmc_ws ;
16761695
16771696 soc_pm .sfrbu_regs .pswbu .key = (0x4BD20C << 8 );
0 commit comments