@@ -78,9 +78,15 @@ struct pmc_reg_config {
7878 u8 mckr ;
7979};
8080
81+ struct ddrc_reg_config {
82+ u32 type_offset ;
83+ u32 type_mask ;
84+ };
85+
8186struct reg_config {
8287 struct shdwc_reg_config shdwc ;
8388 struct pmc_reg_config pmc ;
89+ struct ddrc_reg_config ddrc ;
8490};
8591
8692struct shdwc {
@@ -262,6 +268,10 @@ static const struct reg_config sama5d2_reg_config = {
262268 .pmc = {
263269 .mckr = 0x30 ,
264270 },
271+ .ddrc = {
272+ .type_offset = AT91_DDRSDRC_MDR ,
273+ .type_mask = AT91_DDRSDRC_MD
274+ },
265275};
266276
267277static const struct reg_config sam9x60_reg_config = {
@@ -275,6 +285,23 @@ static const struct reg_config sam9x60_reg_config = {
275285 .pmc = {
276286 .mckr = 0x28 ,
277287 },
288+ .ddrc = {
289+ .type_offset = AT91_DDRSDRC_MDR ,
290+ .type_mask = AT91_DDRSDRC_MD
291+ },
292+ };
293+
294+ static const struct reg_config sama7g5_reg_config = {
295+ .shdwc = {
296+ .wkup_pin_input = 0 ,
297+ .mr_rtcwk_shift = 17 ,
298+ .mr_rttwk_shift = 16 ,
299+ .sr_rtcwk_shift = 5 ,
300+ .sr_rttwk_shift = 4 ,
301+ },
302+ .pmc = {
303+ .mckr = 0x28 ,
304+ },
278305};
279306
280307static const struct of_device_id at91_shdwc_of_match [] = {
@@ -285,6 +312,10 @@ static const struct of_device_id at91_shdwc_of_match[] = {
285312 {
286313 .compatible = "microchip,sam9x60-shdwc" ,
287314 .data = & sam9x60_reg_config ,
315+ },
316+ {
317+ .compatible = "microchip,sama7g5-shdwc" ,
318+ .data = & sama7g5_reg_config ,
288319 }, {
289320 /*sentinel*/
290321 }
@@ -294,6 +325,7 @@ MODULE_DEVICE_TABLE(of, at91_shdwc_of_match);
294325static const struct of_device_id at91_pmc_ids [] = {
295326 { .compatible = "atmel,sama5d2-pmc" },
296327 { .compatible = "microchip,sam9x60-pmc" },
328+ { .compatible = "microchip,sama7g5-pmc" },
297329 { /* Sentinel. */ }
298330};
299331
@@ -355,30 +387,34 @@ static int __init at91_shdwc_probe(struct platform_device *pdev)
355387 goto clk_disable ;
356388 }
357389
358- np = of_find_compatible_node (NULL , NULL , "atmel,sama5d3-ddramc" );
359- if (!np ) {
360- ret = - ENODEV ;
361- goto unmap ;
362- }
390+ if (at91_shdwc -> rcfg -> ddrc .type_mask ) {
391+ np = of_find_compatible_node (NULL , NULL ,
392+ "atmel,sama5d3-ddramc" );
393+ if (!np ) {
394+ ret = - ENODEV ;
395+ goto unmap ;
396+ }
363397
364- at91_shdwc -> mpddrc_base = of_iomap (np , 0 );
365- of_node_put (np );
398+ at91_shdwc -> mpddrc_base = of_iomap (np , 0 );
399+ of_node_put (np );
366400
367- if (!at91_shdwc -> mpddrc_base ) {
368- ret = - ENOMEM ;
369- goto unmap ;
401+ if (!at91_shdwc -> mpddrc_base ) {
402+ ret = - ENOMEM ;
403+ goto unmap ;
404+ }
405+
406+ ddr_type = readl (at91_shdwc -> mpddrc_base +
407+ at91_shdwc -> rcfg -> ddrc .type_offset ) &
408+ at91_shdwc -> rcfg -> ddrc .type_mask ;
409+ if (ddr_type != AT91_DDRSDRC_MD_LPDDR2 &&
410+ ddr_type != AT91_DDRSDRC_MD_LPDDR3 ) {
411+ iounmap (at91_shdwc -> mpddrc_base );
412+ at91_shdwc -> mpddrc_base = NULL ;
413+ }
370414 }
371415
372416 pm_power_off = at91_poweroff ;
373417
374- ddr_type = readl (at91_shdwc -> mpddrc_base + AT91_DDRSDRC_MDR ) &
375- AT91_DDRSDRC_MD ;
376- if (ddr_type != AT91_DDRSDRC_MD_LPDDR2 &&
377- ddr_type != AT91_DDRSDRC_MD_LPDDR3 ) {
378- iounmap (at91_shdwc -> mpddrc_base );
379- at91_shdwc -> mpddrc_base = NULL ;
380- }
381-
382418 return 0 ;
383419
384420unmap :
0 commit comments