Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/85xx: Add lbc suspend support for PM

Power supply for LBC registers is off when system go to deep-sleep state.
We save the values of registers before suspend and restore to registers
after resume.

We removed the last two reservation arrays from struct fsl_lbc_regs for
allocating less memory and minimizing the memcpy size.

Signed-off-by: Jiang Yutang <b14898@freescale.com>
Signed-off-by: Jia Hongtao <B38951@freescale.com>
Signed-off-by: Li Yang <leoli@freescale.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>

authored by

Jia Hongtao and committed by
Kumar Gala
09cef8bd 05737c7c

+41 -2
+5 -2
arch/powerpc/include/asm/fsl_lbc.h
··· 238 238 #define FPAR_LP_CI_SHIFT 0 239 239 __be32 fbcr; /**< Flash Byte Count Register */ 240 240 #define FBCR_BC 0x00000FFF 241 - u8 res11[0x8]; 242 - u8 res8[0xF00]; 243 241 }; 244 242 245 243 /* ··· 292 294 293 295 /* status read from LTESR by irq handler */ 294 296 unsigned int irq_status; 297 + 298 + #ifdef CONFIG_SUSPEND 299 + /* save regs when system go to deep-sleep */ 300 + struct fsl_lbc_regs *saved_regs; 301 + #endif 295 302 }; 296 303 297 304 extern int fsl_upm_run_pattern(struct fsl_upm *upm, void __iomem *io_base,
+36
arch/powerpc/sysdev/fsl_lbc.c
··· 332 332 return ret; 333 333 } 334 334 335 + #ifdef CONFIG_SUSPEND 336 + 337 + /* save lbc registers */ 338 + static int fsl_lbc_suspend(struct platform_device *pdev, pm_message_t state) 339 + { 340 + struct fsl_lbc_ctrl *ctrl = dev_get_drvdata(&pdev->dev); 341 + struct fsl_lbc_regs __iomem *lbc = ctrl->regs; 342 + 343 + ctrl->saved_regs = kmalloc(sizeof(struct fsl_lbc_regs), GFP_KERNEL); 344 + if (!ctrl->saved_regs) 345 + return -ENOMEM; 346 + 347 + _memcpy_fromio(ctrl->saved_regs, lbc, sizeof(struct fsl_lbc_regs)); 348 + return 0; 349 + } 350 + 351 + /* restore lbc registers */ 352 + static int fsl_lbc_resume(struct platform_device *pdev) 353 + { 354 + struct fsl_lbc_ctrl *ctrl = dev_get_drvdata(&pdev->dev); 355 + struct fsl_lbc_regs __iomem *lbc = ctrl->regs; 356 + 357 + if (ctrl->saved_regs) { 358 + _memcpy_toio(lbc, ctrl->saved_regs, 359 + sizeof(struct fsl_lbc_regs)); 360 + kfree(ctrl->saved_regs); 361 + ctrl->saved_regs = NULL; 362 + } 363 + return 0; 364 + } 365 + #endif /* CONFIG_SUSPEND */ 366 + 335 367 static const struct of_device_id fsl_lbc_match[] = { 336 368 { .compatible = "fsl,elbc", }, 337 369 { .compatible = "fsl,pq3-localbus", }, ··· 378 346 .of_match_table = fsl_lbc_match, 379 347 }, 380 348 .probe = fsl_lbc_ctrl_probe, 349 + #ifdef CONFIG_SUSPEND 350 + .suspend = fsl_lbc_suspend, 351 + .resume = fsl_lbc_resume, 352 + #endif 381 353 }; 382 354 383 355 static int __init fsl_lbc_init(void)