diff options
author | David S. Miller <davem@sunset.davemloft.net> | 2006-06-23 04:44:10 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-06-24 02:15:43 -0400 |
commit | a2bd4fd17926d715a470fbe0ebe05128ba410984 (patch) | |
tree | 3e39a2f6aaf3a628b955067ef3668cae3456de03 /arch/sparc64/kernel/power.c | |
parent | 8cd24ed4f8031636fb5dacb04adee9e02556ecd5 (diff) |
[SPARC64]: Add of_device layer and make ebus/isa use it.
Sparcspkr and power drivers are converted, to make sure it works.
Eventually the SBUS device layer will use this as a sub-class.
I really cannot cut loose on that bit until sparc32 is given the
same infrastructure.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc64/kernel/power.c')
-rw-r--r-- | arch/sparc64/kernel/power.c | 109 |
1 files changed, 53 insertions, 56 deletions
diff --git a/arch/sparc64/kernel/power.c b/arch/sparc64/kernel/power.c index 75159a7843f1..9496c7734014 100644 --- a/arch/sparc64/kernel/power.c +++ b/arch/sparc64/kernel/power.c | |||
@@ -115,66 +115,15 @@ static int __init has_button_interrupt(unsigned int irq, struct device_node *dp) | |||
115 | return 1; | 115 | return 1; |
116 | } | 116 | } |
117 | 117 | ||
118 | static int __init power_probe_ebus(struct resource **resp, unsigned int *irq_p, struct device_node **prom_node_p) | 118 | static void __devinit power_probe_common(struct of_device *dev, struct resource *res, unsigned int irq) |
119 | { | 119 | { |
120 | struct linux_ebus *ebus; | ||
121 | struct linux_ebus_device *edev; | ||
122 | |||
123 | for_each_ebus(ebus) { | ||
124 | for_each_ebusdev(edev, ebus) { | ||
125 | if (!strcmp(edev->prom_node->name, "power")) { | ||
126 | *resp = &edev->resource[0]; | ||
127 | *irq_p = edev->irqs[0]; | ||
128 | *prom_node_p = edev->prom_node; | ||
129 | return 0; | ||
130 | } | ||
131 | } | ||
132 | } | ||
133 | return -ENODEV; | ||
134 | } | ||
135 | |||
136 | static int __init power_probe_isa(struct resource **resp, unsigned int *irq_p, struct device_node **prom_node_p) | ||
137 | { | ||
138 | struct sparc_isa_bridge *isa_bus; | ||
139 | struct sparc_isa_device *isa_dev; | ||
140 | |||
141 | for_each_isa(isa_bus) { | ||
142 | for_each_isadev(isa_dev, isa_bus) { | ||
143 | if (!strcmp(isa_dev->prom_node->name, "power")) { | ||
144 | *resp = &isa_dev->resource; | ||
145 | *irq_p = isa_dev->irq; | ||
146 | *prom_node_p = isa_dev->prom_node; | ||
147 | return 0; | ||
148 | } | ||
149 | } | ||
150 | } | ||
151 | return -ENODEV; | ||
152 | } | ||
153 | |||
154 | void __init power_init(void) | ||
155 | { | ||
156 | struct resource *res = NULL; | ||
157 | unsigned int irq; | ||
158 | struct device_node *dp; | ||
159 | static int invoked; | ||
160 | |||
161 | if (invoked) | ||
162 | return; | ||
163 | invoked = 1; | ||
164 | |||
165 | if (!power_probe_ebus(&res, &irq, &dp)) | ||
166 | goto found; | ||
167 | |||
168 | if (!power_probe_isa(&res, &irq, &dp)) | ||
169 | goto found; | ||
170 | |||
171 | return; | ||
172 | |||
173 | found: | ||
174 | power_reg = ioremap(res->start, 0x4); | 120 | power_reg = ioremap(res->start, 0x4); |
121 | |||
175 | printk("power: Control reg at %p ... ", power_reg); | 122 | printk("power: Control reg at %p ... ", power_reg); |
123 | |||
176 | poweroff_method = machine_halt; /* able to use the standard halt */ | 124 | poweroff_method = machine_halt; /* able to use the standard halt */ |
177 | if (has_button_interrupt(irq, dp)) { | 125 | |
126 | if (has_button_interrupt(irq, dev->node)) { | ||
178 | if (kernel_thread(powerd, NULL, CLONE_FS) < 0) { | 127 | if (kernel_thread(powerd, NULL, CLONE_FS) < 0) { |
179 | printk("Failed to start power daemon.\n"); | 128 | printk("Failed to start power daemon.\n"); |
180 | return; | 129 | return; |
@@ -188,4 +137,52 @@ found: | |||
188 | printk("not using powerd.\n"); | 137 | printk("not using powerd.\n"); |
189 | } | 138 | } |
190 | } | 139 | } |
140 | |||
141 | static struct of_device_id power_match[] = { | ||
142 | { | ||
143 | .name = "power", | ||
144 | }, | ||
145 | {}, | ||
146 | }; | ||
147 | |||
148 | static int __devinit ebus_power_probe(struct of_device *dev, const struct of_device_id *match) | ||
149 | { | ||
150 | struct linux_ebus_device *edev = to_ebus_device(&dev->dev); | ||
151 | struct resource *res = &edev->resource[0]; | ||
152 | unsigned int irq = edev->irqs[0]; | ||
153 | |||
154 | power_probe_common(dev, res,irq); | ||
155 | |||
156 | return 0; | ||
157 | } | ||
158 | |||
159 | static struct of_platform_driver ebus_power_driver = { | ||
160 | .name = "power", | ||
161 | .match_table = power_match, | ||
162 | .probe = ebus_power_probe, | ||
163 | }; | ||
164 | |||
165 | static int __devinit isa_power_probe(struct of_device *dev, const struct of_device_id *match) | ||
166 | { | ||
167 | struct sparc_isa_device *idev = to_isa_device(&dev->dev); | ||
168 | struct resource *res = &idev->resource; | ||
169 | unsigned int irq = idev->irq; | ||
170 | |||
171 | power_probe_common(dev, res,irq); | ||
172 | |||
173 | return 0; | ||
174 | } | ||
175 | |||
176 | static struct of_platform_driver isa_power_driver = { | ||
177 | .name = "power", | ||
178 | .match_table = power_match, | ||
179 | .probe = isa_power_probe, | ||
180 | }; | ||
181 | |||
182 | void __init power_init(void) | ||
183 | { | ||
184 | of_register_driver(&ebus_power_driver, &ebus_bus_type); | ||
185 | of_register_driver(&isa_power_driver, &isa_bus_type); | ||
186 | return; | ||
187 | } | ||
191 | #endif /* CONFIG_PCI */ | 188 | #endif /* CONFIG_PCI */ |