diff options
Diffstat (limited to 'drivers/macintosh/via-pmu.c')
-rw-r--r-- | drivers/macintosh/via-pmu.c | 55 |
1 files changed, 19 insertions, 36 deletions
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c index b6073bdb50c3..1729d3fd7a11 100644 --- a/drivers/macintosh/via-pmu.c +++ b/drivers/macintosh/via-pmu.c | |||
@@ -289,7 +289,7 @@ int __init find_via_pmu(void) | |||
289 | if (vias == NULL) | 289 | if (vias == NULL) |
290 | return 0; | 290 | return 0; |
291 | 291 | ||
292 | reg = get_property(vias, "reg", NULL); | 292 | reg = of_get_property(vias, "reg", NULL); |
293 | if (reg == NULL) { | 293 | if (reg == NULL) { |
294 | printk(KERN_ERR "via-pmu: No \"reg\" property !\n"); | 294 | printk(KERN_ERR "via-pmu: No \"reg\" property !\n"); |
295 | goto fail; | 295 | goto fail; |
@@ -319,10 +319,13 @@ int __init find_via_pmu(void) | |||
319 | else if (device_is_compatible(vias->parent, "Keylargo") | 319 | else if (device_is_compatible(vias->parent, "Keylargo") |
320 | || device_is_compatible(vias->parent, "K2-Keylargo")) { | 320 | || device_is_compatible(vias->parent, "K2-Keylargo")) { |
321 | struct device_node *gpiop; | 321 | struct device_node *gpiop; |
322 | struct device_node *adbp; | ||
322 | u64 gaddr = OF_BAD_ADDR; | 323 | u64 gaddr = OF_BAD_ADDR; |
323 | 324 | ||
324 | pmu_kind = PMU_KEYLARGO_BASED; | 325 | pmu_kind = PMU_KEYLARGO_BASED; |
325 | pmu_has_adb = (find_type_devices("adb") != NULL); | 326 | adbp = of_find_node_by_type(NULL, "adb"); |
327 | pmu_has_adb = (adbp != NULL); | ||
328 | of_node_put(adbp); | ||
326 | pmu_intr_mask = PMU_INT_PCEJECT | | 329 | pmu_intr_mask = PMU_INT_PCEJECT | |
327 | PMU_INT_SNDBRT | | 330 | PMU_INT_SNDBRT | |
328 | PMU_INT_ADB | | 331 | PMU_INT_ADB | |
@@ -331,7 +334,7 @@ int __init find_via_pmu(void) | |||
331 | 334 | ||
332 | gpiop = of_find_node_by_name(NULL, "gpio"); | 335 | gpiop = of_find_node_by_name(NULL, "gpio"); |
333 | if (gpiop) { | 336 | if (gpiop) { |
334 | reg = get_property(gpiop, "reg", NULL); | 337 | reg = of_get_property(gpiop, "reg", NULL); |
335 | if (reg) | 338 | if (reg) |
336 | gaddr = of_translate_address(gpiop, reg); | 339 | gaddr = of_translate_address(gpiop, reg); |
337 | if (gaddr != OF_BAD_ADDR) | 340 | if (gaddr != OF_BAD_ADDR) |
@@ -484,10 +487,11 @@ static int __init via_pmu_dev_init(void) | |||
484 | pmu_batteries[0].flags |= PMU_BATT_TYPE_SMART; | 487 | pmu_batteries[0].flags |= PMU_BATT_TYPE_SMART; |
485 | pmu_batteries[1].flags |= PMU_BATT_TYPE_SMART; | 488 | pmu_batteries[1].flags |= PMU_BATT_TYPE_SMART; |
486 | } else { | 489 | } else { |
487 | struct device_node* prim = find_devices("power-mgt"); | 490 | struct device_node* prim = |
491 | of_find_node_by_name(NULL, "power-mgt"); | ||
488 | const u32 *prim_info = NULL; | 492 | const u32 *prim_info = NULL; |
489 | if (prim) | 493 | if (prim) |
490 | prim_info = get_property(prim, "prim-info", NULL); | 494 | prim_info = of_get_property(prim, "prim-info", NULL); |
491 | if (prim_info) { | 495 | if (prim_info) { |
492 | /* Other stuffs here yet unknown */ | 496 | /* Other stuffs here yet unknown */ |
493 | pmu_battery_count = (prim_info[6] >> 16) & 0xff; | 497 | pmu_battery_count = (prim_info[6] >> 16) & 0xff; |
@@ -495,6 +499,7 @@ static int __init via_pmu_dev_init(void) | |||
495 | if (pmu_battery_count > 1) | 499 | if (pmu_battery_count > 1) |
496 | pmu_batteries[1].flags |= PMU_BATT_TYPE_SMART; | 500 | pmu_batteries[1].flags |= PMU_BATT_TYPE_SMART; |
497 | } | 501 | } |
502 | of_node_put(prim); | ||
498 | } | 503 | } |
499 | #endif /* CONFIG_PPC32 */ | 504 | #endif /* CONFIG_PPC32 */ |
500 | 505 | ||
@@ -1769,35 +1774,21 @@ EXPORT_SYMBOL(pmu_unregister_sleep_notifier); | |||
1769 | #if defined(CONFIG_PM) && defined(CONFIG_PPC32) | 1774 | #if defined(CONFIG_PM) && defined(CONFIG_PPC32) |
1770 | 1775 | ||
1771 | /* Sleep is broadcast last-to-first */ | 1776 | /* Sleep is broadcast last-to-first */ |
1772 | static int | 1777 | static void broadcast_sleep(int when) |
1773 | broadcast_sleep(int when, int fallback) | ||
1774 | { | 1778 | { |
1775 | int ret = PBOOK_SLEEP_OK; | ||
1776 | struct list_head *list; | 1779 | struct list_head *list; |
1777 | struct pmu_sleep_notifier *notifier; | 1780 | struct pmu_sleep_notifier *notifier; |
1778 | 1781 | ||
1779 | for (list = sleep_notifiers.prev; list != &sleep_notifiers; | 1782 | for (list = sleep_notifiers.prev; list != &sleep_notifiers; |
1780 | list = list->prev) { | 1783 | list = list->prev) { |
1781 | notifier = list_entry(list, struct pmu_sleep_notifier, list); | 1784 | notifier = list_entry(list, struct pmu_sleep_notifier, list); |
1782 | ret = notifier->notifier_call(notifier, when); | 1785 | notifier->notifier_call(notifier, when); |
1783 | if (ret != PBOOK_SLEEP_OK) { | ||
1784 | printk(KERN_DEBUG "sleep %d rejected by %p (%p)\n", | ||
1785 | when, notifier, notifier->notifier_call); | ||
1786 | for (; list != &sleep_notifiers; list = list->next) { | ||
1787 | notifier = list_entry(list, struct pmu_sleep_notifier, list); | ||
1788 | notifier->notifier_call(notifier, fallback); | ||
1789 | } | ||
1790 | return ret; | ||
1791 | } | ||
1792 | } | 1786 | } |
1793 | return ret; | ||
1794 | } | 1787 | } |
1795 | 1788 | ||
1796 | /* Wake is broadcast first-to-last */ | 1789 | /* Wake is broadcast first-to-last */ |
1797 | static int | 1790 | static void broadcast_wake(void) |
1798 | broadcast_wake(void) | ||
1799 | { | 1791 | { |
1800 | int ret = PBOOK_SLEEP_OK; | ||
1801 | struct list_head *list; | 1792 | struct list_head *list; |
1802 | struct pmu_sleep_notifier *notifier; | 1793 | struct pmu_sleep_notifier *notifier; |
1803 | 1794 | ||
@@ -1806,7 +1797,6 @@ broadcast_wake(void) | |||
1806 | notifier = list_entry(list, struct pmu_sleep_notifier, list); | 1797 | notifier = list_entry(list, struct pmu_sleep_notifier, list); |
1807 | notifier->notifier_call(notifier, PBOOK_WAKE); | 1798 | notifier->notifier_call(notifier, PBOOK_WAKE); |
1808 | } | 1799 | } |
1809 | return ret; | ||
1810 | } | 1800 | } |
1811 | 1801 | ||
1812 | /* | 1802 | /* |
@@ -2013,12 +2003,8 @@ pmac_suspend_devices(void) | |||
2013 | 2003 | ||
2014 | pm_prepare_console(); | 2004 | pm_prepare_console(); |
2015 | 2005 | ||
2016 | /* Notify old-style device drivers & userland */ | 2006 | /* Notify old-style device drivers */ |
2017 | ret = broadcast_sleep(PBOOK_SLEEP_REQUEST, PBOOK_SLEEP_REJECT); | 2007 | broadcast_sleep(PBOOK_SLEEP_REQUEST); |
2018 | if (ret != PBOOK_SLEEP_OK) { | ||
2019 | printk(KERN_ERR "Sleep rejected by drivers\n"); | ||
2020 | return -EBUSY; | ||
2021 | } | ||
2022 | 2008 | ||
2023 | /* Sync the disks. */ | 2009 | /* Sync the disks. */ |
2024 | /* XXX It would be nice to have some way to ensure that | 2010 | /* XXX It would be nice to have some way to ensure that |
@@ -2028,12 +2014,7 @@ pmac_suspend_devices(void) | |||
2028 | */ | 2014 | */ |
2029 | sys_sync(); | 2015 | sys_sync(); |
2030 | 2016 | ||
2031 | /* Sleep can fail now. May not be very robust but useful for debugging */ | 2017 | broadcast_sleep(PBOOK_SLEEP_NOW); |
2032 | ret = broadcast_sleep(PBOOK_SLEEP_NOW, PBOOK_WAKE); | ||
2033 | if (ret != PBOOK_SLEEP_OK) { | ||
2034 | printk(KERN_ERR "Driver sleep failed\n"); | ||
2035 | return -EBUSY; | ||
2036 | } | ||
2037 | 2018 | ||
2038 | /* Send suspend call to devices, hold the device core's dpm_sem */ | 2019 | /* Send suspend call to devices, hold the device core's dpm_sem */ |
2039 | ret = device_suspend(PMSG_SUSPEND); | 2020 | ret = device_suspend(PMSG_SUSPEND); |
@@ -2154,7 +2135,7 @@ static int powerbook_sleep_grackle(void) | |||
2154 | int ret; | 2135 | int ret; |
2155 | struct pci_dev *grackle; | 2136 | struct pci_dev *grackle; |
2156 | 2137 | ||
2157 | grackle = pci_find_slot(0, 0); | 2138 | grackle = pci_get_bus_and_slot(0, 0); |
2158 | if (!grackle) | 2139 | if (!grackle) |
2159 | return -ENODEV; | 2140 | return -ENODEV; |
2160 | 2141 | ||
@@ -2202,6 +2183,8 @@ static int powerbook_sleep_grackle(void) | |||
2202 | pmcr1 &= ~(GRACKLE_PM|GRACKLE_DOZE|GRACKLE_SLEEP|GRACKLE_NAP); | 2183 | pmcr1 &= ~(GRACKLE_PM|GRACKLE_DOZE|GRACKLE_SLEEP|GRACKLE_NAP); |
2203 | pci_write_config_word(grackle, 0x70, pmcr1); | 2184 | pci_write_config_word(grackle, 0x70, pmcr1); |
2204 | 2185 | ||
2186 | pci_dev_put(grackle); | ||
2187 | |||
2205 | /* Make sure the PMU is idle */ | 2188 | /* Make sure the PMU is idle */ |
2206 | pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,0); | 2189 | pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,0); |
2207 | restore_via_state(); | 2190 | restore_via_state(); |