[ARM] pxa: introduce sysdev for IRQ register saving/restoring

Signed-off-by: eric miao <eric.miao@marvell.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

authored by eric miao and committed by Russell King c0165504 cd5604d5

+122 -16
+2
arch/arm/mach-pxa/generic.h
··· 52 52 #define pxa3xx_get_clk_frequency_khz(x) (0) 53 53 #define pxa3xx_get_memclk_frequency_10khz() (0) 54 54 #endif 55 + 56 + extern struct sysdev_class pxa_irq_sysclass;
+62
arch/arm/mach-pxa/irq.c
··· 15 15 #include <linux/init.h> 16 16 #include <linux/module.h> 17 17 #include <linux/interrupt.h> 18 + #include <linux/sysdev.h> 18 19 19 20 #include <asm/hardware.h> 20 21 #include <asm/irq.h> ··· 322 321 pxa_low_gpio_chip.set_wake = set_wake; 323 322 pxa_muxed_gpio_chip.set_wake = set_wake; 324 323 } 324 + 325 + #ifdef CONFIG_PM 326 + static unsigned long saved_icmr[2]; 327 + 328 + static int pxa_irq_suspend(struct sys_device *dev, pm_message_t state) 329 + { 330 + switch (dev->id) { 331 + case 0: 332 + saved_icmr[0] = ICMR; 333 + ICMR = 0; 334 + break; 335 + #if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx) 336 + case 1: 337 + saved_icmr[1] = ICMR2; 338 + ICMR2 = 0; 339 + break; 340 + #endif 341 + default: 342 + return -EINVAL; 343 + } 344 + 345 + return 0; 346 + } 347 + 348 + static int pxa_irq_resume(struct sys_device *dev) 349 + { 350 + switch (dev->id) { 351 + case 0: 352 + ICMR = saved_icmr[0]; 353 + ICLR = 0; 354 + ICCR = 1; 355 + break; 356 + #if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx) 357 + case 1: 358 + ICMR2 = saved_icmr[1]; 359 + ICLR2 = 0; 360 + break; 361 + #endif 362 + default: 363 + return -EINVAL; 364 + } 365 + 366 + return 0; 367 + } 368 + #else 369 + #define pxa_irq_suspend NULL 370 + #define pxa_irq_resume NULL 371 + #endif 372 + 373 + struct sysdev_class pxa_irq_sysclass = { 374 + .name = "irq", 375 + .suspend = pxa_irq_suspend, 376 + .resume = pxa_irq_resume, 377 + }; 378 + 379 + static int __init pxa_irq_init(void) 380 + { 381 + return sysdev_class_register(&pxa_irq_sysclass); 382 + } 383 + 384 + core_initcall(pxa_irq_init);
+17 -7
arch/arm/mach-pxa/pxa25x.c
··· 21 21 #include <linux/init.h> 22 22 #include <linux/platform_device.h> 23 23 #include <linux/suspend.h> 24 + #include <linux/sysdev.h> 24 25 25 26 #include <asm/hardware.h> 26 27 #include <asm/arch/irqs.h> ··· 166 165 167 166 SLEEP_SAVE_PSTR, 168 167 169 - SLEEP_SAVE_ICMR, 170 168 SLEEP_SAVE_CKEN, 171 169 172 170 SLEEP_SAVE_SIZE ··· 184 184 SAVE(GAFR1_L); SAVE(GAFR1_U); 185 185 SAVE(GAFR2_L); SAVE(GAFR2_U); 186 186 187 - SAVE(ICMR); ICMR = 0; 188 187 SAVE(CKEN); 189 188 SAVE(PSTR); 190 189 ··· 209 210 PSSR = PSSR_RDH | PSSR_PH; 210 211 211 212 RESTORE(CKEN); 212 - 213 - ICLR = 0; 214 - ICCR = 1; 215 - RESTORE(ICMR); 216 213 RESTORE(PSTR); 217 214 } 218 215 ··· 299 304 &pxa25x_device_assp, 300 305 }; 301 306 307 + static struct sys_device pxa25x_sysdev[] = { 308 + { 309 + .cls = &pxa_irq_sysclass, 310 + }, 311 + }; 312 + 302 313 static int __init pxa25x_init(void) 303 314 { 304 - int ret = 0; 315 + int i, ret = 0; 305 316 306 317 /* Only add HWUART for PXA255/26x; PXA210/250/27x do not have it. */ 307 318 if (cpu_is_pxa25x()) ··· 321 320 322 321 pxa25x_init_pm(); 323 322 323 + for (i = 0; i < ARRAY_SIZE(pxa25x_sysdev); i++) { 324 + ret = sysdev_register(&pxa25x_sysdev[i]); 325 + if (ret) 326 + pr_err("failed to register sysdev[%d]\n", i); 327 + } 328 + 324 329 ret = platform_add_devices(pxa25x_devices, 325 330 ARRAY_SIZE(pxa25x_devices)); 331 + if (ret) 332 + return ret; 326 333 } 334 + 327 335 /* Only add HWUART for PXA255/26x; PXA210/250/27x do not have it. */ 328 336 if (cpu_is_pxa25x()) 329 337 ret = platform_device_register(&pxa_device_hwuart);
+20 -6
arch/arm/mach-pxa/pxa27x.c
··· 16 16 #include <linux/init.h> 17 17 #include <linux/suspend.h> 18 18 #include <linux/platform_device.h> 19 + #include <linux/sysdev.h> 19 20 20 21 #include <asm/hardware.h> 21 22 #include <asm/irq.h> ··· 197 196 198 197 SLEEP_SAVE_PSTR, 199 198 200 - SLEEP_SAVE_ICMR, 201 199 SLEEP_SAVE_CKEN, 202 200 203 201 SLEEP_SAVE_MDREFR, ··· 223 223 SAVE(PWER); SAVE(PCFR); SAVE(PRER); 224 224 SAVE(PFER); SAVE(PKWR); 225 225 226 - SAVE(ICMR); ICMR = 0; 227 226 SAVE(CKEN); 228 227 SAVE(PSTR); 229 228 ··· 255 256 256 257 RESTORE(CKEN); 257 258 258 - ICLR = 0; 259 - ICCR = 1; 260 - RESTORE(ICMR); 261 259 RESTORE(PSTR); 262 260 } 263 261 ··· 405 409 &pxa27x_device_ssp3, 406 410 }; 407 411 412 + static struct sys_device pxa27x_sysdev[] = { 413 + { 414 + .id = 0, 415 + .cls = &pxa_irq_sysclass, 416 + }, { 417 + .id = 1, 418 + .cls = &pxa_irq_sysclass, 419 + }, 420 + }; 421 + 408 422 static int __init pxa27x_init(void) 409 423 { 410 - int ret = 0; 424 + int i, ret = 0; 425 + 411 426 if (cpu_is_pxa27x()) { 412 427 clks_register(pxa27x_clks, ARRAY_SIZE(pxa27x_clks)); 413 428 ··· 427 420 428 421 pxa27x_init_pm(); 429 422 423 + for (i = 0; i < ARRAY_SIZE(pxa27x_sysdev); i++) { 424 + ret = sysdev_register(&pxa27x_sysdev[i]); 425 + if (ret) 426 + pr_err("failed to register sysdev[%d]\n", i); 427 + } 428 + 430 429 ret = platform_add_devices(devices, ARRAY_SIZE(devices)); 431 430 } 431 + 432 432 return ret; 433 433 } 434 434
+21 -3
arch/arm/mach-pxa/pxa3xx.c
··· 20 20 #include <linux/platform_device.h> 21 21 #include <linux/irq.h> 22 22 #include <linux/io.h> 23 + #include <linux/sysdev.h> 23 24 24 25 #include <asm/hardware.h> 25 26 #include <asm/arch/pxa3xx-regs.h> ··· 453 452 &pxa3xx_device_ssp4, 454 453 }; 455 454 455 + static struct sys_device pxa3xx_sysdev[] = { 456 + { 457 + .id = 0, 458 + .cls = &pxa_irq_sysclass, 459 + }, { 460 + .id = 1, 461 + .cls = &pxa_irq_sysclass, 462 + }, 463 + }; 464 + 456 465 static int __init pxa3xx_init(void) 457 466 { 458 - int ret = 0; 467 + int i, ret = 0; 459 468 460 469 if (cpu_is_pxa3xx()) { 461 470 clks_register(pxa3xx_clks, ARRAY_SIZE(pxa3xx_clks)); ··· 475 464 476 465 pxa3xx_init_pm(); 477 466 478 - return platform_add_devices(devices, ARRAY_SIZE(devices)); 467 + for (i = 0; i < ARRAY_SIZE(pxa3xx_sysdev); i++) { 468 + ret = sysdev_register(&pxa3xx_sysdev[i]); 469 + if (ret) 470 + pr_err("failed to register sysdev[%d]\n", i); 471 + } 472 + 473 + ret = platform_add_devices(devices, ARRAY_SIZE(devices)); 479 474 } 480 - return 0; 475 + 476 + return ret; 481 477 } 482 478 483 479 subsys_initcall(pxa3xx_init);