| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | /* pmc - Driver implementation for power management functions
 | 
					
						
							|  |  |  |  * of Power Management Controller (PMC) on SPARCstation-Voyager. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Copyright (c) 2002 Eric Brower (ebrower@usa.net) | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <linux/kernel.h>
 | 
					
						
							|  |  |  | #include <linux/fs.h>
 | 
					
						
							|  |  |  | #include <linux/errno.h>
 | 
					
						
							|  |  |  | #include <linux/init.h>
 | 
					
						
							|  |  |  | #include <linux/pm.h>
 | 
					
						
							| 
									
										
										
										
											2008-08-27 02:48:26 -07:00
										 |  |  | #include <linux/of.h>
 | 
					
						
							|  |  |  | #include <linux/of_device.h>
 | 
					
						
							| 
									
										
										
										
											2011-07-31 01:50:31 -04:00
										 |  |  | #include <linux/module.h>
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include <asm/io.h>
 | 
					
						
							|  |  |  | #include <asm/oplib.h>
 | 
					
						
							|  |  |  | #include <asm/uaccess.h>
 | 
					
						
							|  |  |  | #include <asm/auxio.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Debug
 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * #define PMC_DEBUG_LED | 
					
						
							|  |  |  |  * #define PMC_NO_IDLE | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define PMC_OBPNAME	"SUNW,pmc"
 | 
					
						
							| 
									
										
										
										
											2008-12-08 01:02:55 -08:00
										 |  |  | #define PMC_DEVNAME	"pmc"
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | #define PMC_IDLE_REG	0x00
 | 
					
						
							| 
									
										
										
										
											2008-12-08 01:02:55 -08:00
										 |  |  | #define PMC_IDLE_ON	0x01
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-08-27 02:48:26 -07:00
										 |  |  | static u8 __iomem *regs; | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-08-27 02:48:26 -07:00
										 |  |  | #define pmc_readb(offs)		(sbus_readb(regs+offs))
 | 
					
						
							| 
									
										
										
										
											2008-12-08 01:02:55 -08:00
										 |  |  | #define pmc_writeb(val, offs)	(sbus_writeb(val, regs+offs))
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-08 01:02:55 -08:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  |  * CPU idle callback function | 
					
						
							|  |  |  |  * See .../arch/sparc/kernel/process.c | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2008-12-08 01:02:23 -08:00
										 |  |  | static void pmc_swift_idle(void) | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | { | 
					
						
							|  |  |  | #ifdef PMC_DEBUG_LED
 | 
					
						
							| 
									
										
										
										
											2008-12-08 01:02:55 -08:00
										 |  |  | 	set_auxio(0x00, AUXIO_LED); | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	pmc_writeb(pmc_readb(PMC_IDLE_REG) | PMC_IDLE_ON, PMC_IDLE_REG); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef PMC_DEBUG_LED
 | 
					
						
							| 
									
										
										
										
											2008-12-08 01:02:55 -08:00
										 |  |  | 	set_auxio(AUXIO_LED, 0x00); | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2008-12-08 01:02:55 -08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-22 20:01:33 -07:00
										 |  |  | static int __devinit pmc_probe(struct platform_device *op) | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2008-08-27 02:48:26 -07:00
										 |  |  | 	regs = of_ioremap(&op->resource[0], 0, | 
					
						
							|  |  |  | 			  resource_size(&op->resource[0]), PMC_OBPNAME); | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	if (!regs) { | 
					
						
							|  |  |  | 		printk(KERN_ERR "%s: unable to map registers\n", PMC_DEVNAME); | 
					
						
							|  |  |  | 		return -ENODEV; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef PMC_NO_IDLE
 | 
					
						
							|  |  |  | 	/* Assign power management IDLE handler */ | 
					
						
							| 
									
										
										
										
											2008-12-08 01:02:55 -08:00
										 |  |  | 	pm_idle = pmc_swift_idle; | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	printk(KERN_INFO "%s: power management initialized\n", PMC_DEVNAME); | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												sparc32: fix section mismatch warnings in apc, pmc and time_32
In all cases there were a struct of_device_id variable defined __initdata.
But it was referenced from struct platform_driver.of_match_table
which is not guaranteed to be used during init only.
So drop the __initdata annotation.
This fixes following warnings:
WARNING: arch/sparc/kernel/built-in.o(.data+0x810): Section mismatch in reference from the variable clock_driver to the variable .init.data:clock_match
The variable clock_driver references
the variable __initdata clock_match
If the reference is valid then annotate the
variable with __init* or __refdata (see linux/init.h) or name the variable:
*_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console
WARNING: arch/sparc/kernel/built-in.o(.data+0xcec): Section mismatch in reference from the variable apc_driver to the variable .init.data:apc_match
The variable apc_driver references
the variable __initdata apc_match
If the reference is valid then annotate the
variable with __init* or __refdata (see linux/init.h) or name the variable:
*_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console
WARNING: arch/sparc/kernel/built-in.o(.data+0xd60): Section mismatch in reference from the variable pmc_driver to the variable .init.data:pmc_match
The variable pmc_driver references
the variable __initdata pmc_match
If the reference is valid then annotate the
variable with __init* or __refdata (see linux/init.h) or name the variable:
*_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
											
										 
											2011-04-21 15:37:20 -07:00
										 |  |  | static struct of_device_id pmc_match[] = { | 
					
						
							| 
									
										
										
										
											2008-08-27 02:48:26 -07:00
										 |  |  | 	{ | 
					
						
							|  |  |  | 		.name = PMC_OBPNAME, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	{}, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | MODULE_DEVICE_TABLE(of, pmc_match); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-22 20:01:33 -07:00
										 |  |  | static struct platform_driver pmc_driver = { | 
					
						
							| 
									
										
										
										
											2010-04-13 16:13:02 -07:00
										 |  |  | 	.driver = { | 
					
						
							|  |  |  | 		.name = "pmc", | 
					
						
							|  |  |  | 		.owner = THIS_MODULE, | 
					
						
							|  |  |  | 		.of_match_table = pmc_match, | 
					
						
							|  |  |  | 	}, | 
					
						
							| 
									
										
										
										
											2008-08-27 02:48:26 -07:00
										 |  |  | 	.probe		= pmc_probe, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int __init pmc_init(void) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2011-02-22 20:01:33 -07:00
										 |  |  | 	return platform_driver_register(&pmc_driver); | 
					
						
							| 
									
										
										
										
											2008-08-27 02:48:26 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | /* This driver is not critical to the boot process
 | 
					
						
							|  |  |  |  * and is easiest to ioremap when SBus is already | 
					
						
							|  |  |  |  * initialized, so we install ourselves thusly: | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2008-08-27 02:48:26 -07:00
										 |  |  | __initcall(pmc_init); |