aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/macintosh/via-pmu.c
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2005-12-06 17:31:30 -0500
committerLen Brown <len.brown@intel.com>2005-12-06 17:31:30 -0500
commit3d5271f9883cba7b54762bc4fe027d4172f06db7 (patch)
treeab8a881a14478598a0c8bda0d26c62cdccfffd6d /drivers/macintosh/via-pmu.c
parent378b2556f4e09fa6f87ff0cb5c4395ff28257d02 (diff)
parent9115a6c787596e687df03010d97fccc5e0762506 (diff)
Pull release into acpica branch
Diffstat (limited to 'drivers/macintosh/via-pmu.c')
-rw-r--r--drivers/macintosh/via-pmu.c181
1 files changed, 86 insertions, 95 deletions
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
index 645a2e5c70ab..564043508569 100644
--- a/drivers/macintosh/via-pmu.c
+++ b/drivers/macintosh/via-pmu.c
@@ -155,10 +155,10 @@ static spinlock_t pmu_lock;
155static u8 pmu_intr_mask; 155static u8 pmu_intr_mask;
156static int pmu_version; 156static int pmu_version;
157static int drop_interrupts; 157static int drop_interrupts;
158#ifdef CONFIG_PM 158#if defined(CONFIG_PM) && defined(CONFIG_PPC32)
159static int option_lid_wakeup = 1; 159static int option_lid_wakeup = 1;
160static int sleep_in_progress; 160static int sleep_in_progress;
161#endif /* CONFIG_PM */ 161#endif /* CONFIG_PM && CONFIG_PPC32 */
162static unsigned long async_req_locks; 162static unsigned long async_req_locks;
163static unsigned int pmu_irq_stats[11]; 163static unsigned int pmu_irq_stats[11];
164 164
@@ -244,7 +244,7 @@ int pmu_wink(struct adb_request *req);
244 * - the number of response bytes which the PMU will return, or 244 * - the number of response bytes which the PMU will return, or
245 * -1 if it will send a length byte. 245 * -1 if it will send a length byte.
246 */ 246 */
247static const s8 pmu_data_len[256][2] __openfirmwaredata = { 247static const s8 pmu_data_len[256][2] = {
248/* 0 1 2 3 4 5 6 7 */ 248/* 0 1 2 3 4 5 6 7 */
249/*00*/ {-1, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0}, 249/*00*/ {-1, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0},
250/*08*/ {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1}, 250/*08*/ {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},
@@ -295,7 +295,7 @@ static struct backlight_controller pmu_backlight_controller = {
295}; 295};
296#endif /* CONFIG_PMAC_BACKLIGHT */ 296#endif /* CONFIG_PMAC_BACKLIGHT */
297 297
298int __openfirmware 298int
299find_via_pmu(void) 299find_via_pmu(void)
300{ 300{
301 if (via != 0) 301 if (via != 0)
@@ -374,7 +374,7 @@ find_via_pmu(void)
374} 374}
375 375
376#ifdef CONFIG_ADB 376#ifdef CONFIG_ADB
377static int __openfirmware 377static int
378pmu_probe(void) 378pmu_probe(void)
379{ 379{
380 return vias == NULL? -ENODEV: 0; 380 return vias == NULL? -ENODEV: 0;
@@ -405,7 +405,7 @@ static int __init via_pmu_start(void)
405 bright_req_2.complete = 1; 405 bright_req_2.complete = 1;
406 batt_req.complete = 1; 406 batt_req.complete = 1;
407 407
408#ifdef CONFIG_PPC32 408#if defined(CONFIG_PPC32) && !defined(CONFIG_PPC_MERGE)
409 if (pmu_kind == PMU_KEYLARGO_BASED) 409 if (pmu_kind == PMU_KEYLARGO_BASED)
410 openpic_set_irq_priority(vias->intrs[0].line, 410 openpic_set_irq_priority(vias->intrs[0].line,
411 OPENPIC_PRIORITY_DEFAULT + 1); 411 OPENPIC_PRIORITY_DEFAULT + 1);
@@ -520,7 +520,7 @@ static int __init via_pmu_dev_init(void)
520 520
521device_initcall(via_pmu_dev_init); 521device_initcall(via_pmu_dev_init);
522 522
523static int __openfirmware 523static int
524init_pmu(void) 524init_pmu(void)
525{ 525{
526 int timeout; 526 int timeout;
@@ -588,17 +588,6 @@ pmu_get_model(void)
588 return pmu_kind; 588 return pmu_kind;
589} 589}
590 590
591#ifndef CONFIG_PPC64
592static inline void wakeup_decrementer(void)
593{
594 set_dec(tb_ticks_per_jiffy);
595 /* No currently-supported powerbook has a 601,
596 * so use get_tbl, not native
597 */
598 last_jiffy_stamp(0) = tb_last_stamp = get_tbl();
599}
600#endif
601
602static void pmu_set_server_mode(int server_mode) 591static void pmu_set_server_mode(int server_mode)
603{ 592{
604 struct adb_request req; 593 struct adb_request req;
@@ -625,7 +614,7 @@ static void pmu_set_server_mode(int server_mode)
625/* This new version of the code for 2400/3400/3500 powerbooks 614/* This new version of the code for 2400/3400/3500 powerbooks
626 * is inspired from the implementation in gkrellm-pmu 615 * is inspired from the implementation in gkrellm-pmu
627 */ 616 */
628static void __pmac 617static void
629done_battery_state_ohare(struct adb_request* req) 618done_battery_state_ohare(struct adb_request* req)
630{ 619{
631 /* format: 620 /* format:
@@ -713,7 +702,7 @@ done_battery_state_ohare(struct adb_request* req)
713 clear_bit(0, &async_req_locks); 702 clear_bit(0, &async_req_locks);
714} 703}
715 704
716static void __pmac 705static void
717done_battery_state_smart(struct adb_request* req) 706done_battery_state_smart(struct adb_request* req)
718{ 707{
719 /* format: 708 /* format:
@@ -791,7 +780,7 @@ done_battery_state_smart(struct adb_request* req)
791 clear_bit(0, &async_req_locks); 780 clear_bit(0, &async_req_locks);
792} 781}
793 782
794static void __pmac 783static void
795query_battery_state(void) 784query_battery_state(void)
796{ 785{
797 if (test_and_set_bit(0, &async_req_locks)) 786 if (test_and_set_bit(0, &async_req_locks))
@@ -804,7 +793,7 @@ query_battery_state(void)
804 2, PMU_SMART_BATTERY_STATE, pmu_cur_battery+1); 793 2, PMU_SMART_BATTERY_STATE, pmu_cur_battery+1);
805} 794}
806 795
807static int __pmac 796static int
808proc_get_info(char *page, char **start, off_t off, 797proc_get_info(char *page, char **start, off_t off,
809 int count, int *eof, void *data) 798 int count, int *eof, void *data)
810{ 799{
@@ -819,7 +808,7 @@ proc_get_info(char *page, char **start, off_t off,
819 return p - page; 808 return p - page;
820} 809}
821 810
822static int __pmac 811static int
823proc_get_irqstats(char *page, char **start, off_t off, 812proc_get_irqstats(char *page, char **start, off_t off,
824 int count, int *eof, void *data) 813 int count, int *eof, void *data)
825{ 814{
@@ -846,7 +835,7 @@ proc_get_irqstats(char *page, char **start, off_t off,
846 return p - page; 835 return p - page;
847} 836}
848 837
849static int __pmac 838static int
850proc_get_batt(char *page, char **start, off_t off, 839proc_get_batt(char *page, char **start, off_t off,
851 int count, int *eof, void *data) 840 int count, int *eof, void *data)
852{ 841{
@@ -870,13 +859,13 @@ proc_get_batt(char *page, char **start, off_t off,
870 return p - page; 859 return p - page;
871} 860}
872 861
873static int __pmac 862static int
874proc_read_options(char *page, char **start, off_t off, 863proc_read_options(char *page, char **start, off_t off,
875 int count, int *eof, void *data) 864 int count, int *eof, void *data)
876{ 865{
877 char *p = page; 866 char *p = page;
878 867
879#ifdef CONFIG_PM 868#if defined(CONFIG_PM) && defined(CONFIG_PPC32)
880 if (pmu_kind == PMU_KEYLARGO_BASED && 869 if (pmu_kind == PMU_KEYLARGO_BASED &&
881 pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,-1) >= 0) 870 pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,-1) >= 0)
882 p += sprintf(p, "lid_wakeup=%d\n", option_lid_wakeup); 871 p += sprintf(p, "lid_wakeup=%d\n", option_lid_wakeup);
@@ -887,7 +876,7 @@ proc_read_options(char *page, char **start, off_t off,
887 return p - page; 876 return p - page;
888} 877}
889 878
890static int __pmac 879static int
891proc_write_options(struct file *file, const char __user *buffer, 880proc_write_options(struct file *file, const char __user *buffer,
892 unsigned long count, void *data) 881 unsigned long count, void *data)
893{ 882{
@@ -917,7 +906,7 @@ proc_write_options(struct file *file, const char __user *buffer,
917 *(val++) = 0; 906 *(val++) = 0;
918 while(*val == ' ') 907 while(*val == ' ')
919 val++; 908 val++;
920#ifdef CONFIG_PM 909#if defined(CONFIG_PM) && defined(CONFIG_PPC32)
921 if (pmu_kind == PMU_KEYLARGO_BASED && 910 if (pmu_kind == PMU_KEYLARGO_BASED &&
922 pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,-1) >= 0) 911 pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,-1) >= 0)
923 if (!strcmp(label, "lid_wakeup")) 912 if (!strcmp(label, "lid_wakeup"))
@@ -934,7 +923,7 @@ proc_write_options(struct file *file, const char __user *buffer,
934 923
935#ifdef CONFIG_ADB 924#ifdef CONFIG_ADB
936/* Send an ADB command */ 925/* Send an ADB command */
937static int __pmac 926static int
938pmu_send_request(struct adb_request *req, int sync) 927pmu_send_request(struct adb_request *req, int sync)
939{ 928{
940 int i, ret; 929 int i, ret;
@@ -1014,7 +1003,7 @@ pmu_send_request(struct adb_request *req, int sync)
1014} 1003}
1015 1004
1016/* Enable/disable autopolling */ 1005/* Enable/disable autopolling */
1017static int __pmac 1006static int
1018pmu_adb_autopoll(int devs) 1007pmu_adb_autopoll(int devs)
1019{ 1008{
1020 struct adb_request req; 1009 struct adb_request req;
@@ -1037,7 +1026,7 @@ pmu_adb_autopoll(int devs)
1037} 1026}
1038 1027
1039/* Reset the ADB bus */ 1028/* Reset the ADB bus */
1040static int __pmac 1029static int
1041pmu_adb_reset_bus(void) 1030pmu_adb_reset_bus(void)
1042{ 1031{
1043 struct adb_request req; 1032 struct adb_request req;
@@ -1072,7 +1061,7 @@ pmu_adb_reset_bus(void)
1072#endif /* CONFIG_ADB */ 1061#endif /* CONFIG_ADB */
1073 1062
1074/* Construct and send a pmu request */ 1063/* Construct and send a pmu request */
1075int __openfirmware 1064int
1076pmu_request(struct adb_request *req, void (*done)(struct adb_request *), 1065pmu_request(struct adb_request *req, void (*done)(struct adb_request *),
1077 int nbytes, ...) 1066 int nbytes, ...)
1078{ 1067{
@@ -1098,7 +1087,7 @@ pmu_request(struct adb_request *req, void (*done)(struct adb_request *),
1098 return pmu_queue_request(req); 1087 return pmu_queue_request(req);
1099} 1088}
1100 1089
1101int __pmac 1090int
1102pmu_queue_request(struct adb_request *req) 1091pmu_queue_request(struct adb_request *req)
1103{ 1092{
1104 unsigned long flags; 1093 unsigned long flags;
@@ -1190,7 +1179,7 @@ pmu_done(struct adb_request *req)
1190 (*done)(req); 1179 (*done)(req);
1191} 1180}
1192 1181
1193static void __pmac 1182static void
1194pmu_start(void) 1183pmu_start(void)
1195{ 1184{
1196 struct adb_request *req; 1185 struct adb_request *req;
@@ -1214,7 +1203,7 @@ pmu_start(void)
1214 send_byte(req->data[0]); 1203 send_byte(req->data[0]);
1215} 1204}
1216 1205
1217void __openfirmware 1206void
1218pmu_poll(void) 1207pmu_poll(void)
1219{ 1208{
1220 if (!via) 1209 if (!via)
@@ -1224,7 +1213,7 @@ pmu_poll(void)
1224 via_pmu_interrupt(0, NULL, NULL); 1213 via_pmu_interrupt(0, NULL, NULL);
1225} 1214}
1226 1215
1227void __openfirmware 1216void
1228pmu_poll_adb(void) 1217pmu_poll_adb(void)
1229{ 1218{
1230 if (!via) 1219 if (!via)
@@ -1239,7 +1228,7 @@ pmu_poll_adb(void)
1239 || req_awaiting_reply)); 1228 || req_awaiting_reply));
1240} 1229}
1241 1230
1242void __openfirmware 1231void
1243pmu_wait_complete(struct adb_request *req) 1232pmu_wait_complete(struct adb_request *req)
1244{ 1233{
1245 if (!via) 1234 if (!via)
@@ -1253,7 +1242,7 @@ pmu_wait_complete(struct adb_request *req)
1253 * This is done to avoid spurrious shutdowns when we know we'll have 1242 * This is done to avoid spurrious shutdowns when we know we'll have
1254 * interrupts switched off for a long time 1243 * interrupts switched off for a long time
1255 */ 1244 */
1256void __openfirmware 1245void
1257pmu_suspend(void) 1246pmu_suspend(void)
1258{ 1247{
1259 unsigned long flags; 1248 unsigned long flags;
@@ -1293,7 +1282,7 @@ pmu_suspend(void)
1293 } while (1); 1282 } while (1);
1294} 1283}
1295 1284
1296void __openfirmware 1285void
1297pmu_resume(void) 1286pmu_resume(void)
1298{ 1287{
1299 unsigned long flags; 1288 unsigned long flags;
@@ -1323,7 +1312,7 @@ pmu_resume(void)
1323} 1312}
1324 1313
1325/* Interrupt data could be the result data from an ADB cmd */ 1314/* Interrupt data could be the result data from an ADB cmd */
1326static void __pmac 1315static void
1327pmu_handle_data(unsigned char *data, int len, struct pt_regs *regs) 1316pmu_handle_data(unsigned char *data, int len, struct pt_regs *regs)
1328{ 1317{
1329 unsigned char ints, pirq; 1318 unsigned char ints, pirq;
@@ -1435,7 +1424,7 @@ next:
1435 goto next; 1424 goto next;
1436} 1425}
1437 1426
1438static struct adb_request* __pmac 1427static struct adb_request*
1439pmu_sr_intr(struct pt_regs *regs) 1428pmu_sr_intr(struct pt_regs *regs)
1440{ 1429{
1441 struct adb_request *req; 1430 struct adb_request *req;
@@ -1541,7 +1530,7 @@ pmu_sr_intr(struct pt_regs *regs)
1541 return NULL; 1530 return NULL;
1542} 1531}
1543 1532
1544static irqreturn_t __pmac 1533static irqreturn_t
1545via_pmu_interrupt(int irq, void *arg, struct pt_regs *regs) 1534via_pmu_interrupt(int irq, void *arg, struct pt_regs *regs)
1546{ 1535{
1547 unsigned long flags; 1536 unsigned long flags;
@@ -1629,7 +1618,7 @@ no_free_slot:
1629 return IRQ_RETVAL(handled); 1618 return IRQ_RETVAL(handled);
1630} 1619}
1631 1620
1632void __pmac 1621void
1633pmu_unlock(void) 1622pmu_unlock(void)
1634{ 1623{
1635 unsigned long flags; 1624 unsigned long flags;
@@ -1642,7 +1631,7 @@ pmu_unlock(void)
1642} 1631}
1643 1632
1644 1633
1645static irqreturn_t __pmac 1634static irqreturn_t
1646gpio1_interrupt(int irq, void *arg, struct pt_regs *regs) 1635gpio1_interrupt(int irq, void *arg, struct pt_regs *regs)
1647{ 1636{
1648 unsigned long flags; 1637 unsigned long flags;
@@ -1663,12 +1652,12 @@ gpio1_interrupt(int irq, void *arg, struct pt_regs *regs)
1663} 1652}
1664 1653
1665#ifdef CONFIG_PMAC_BACKLIGHT 1654#ifdef CONFIG_PMAC_BACKLIGHT
1666static int backlight_to_bright[] __pmacdata = { 1655static int backlight_to_bright[] = {
1667 0x7f, 0x46, 0x42, 0x3e, 0x3a, 0x36, 0x32, 0x2e, 1656 0x7f, 0x46, 0x42, 0x3e, 0x3a, 0x36, 0x32, 0x2e,
1668 0x2a, 0x26, 0x22, 0x1e, 0x1a, 0x16, 0x12, 0x0e 1657 0x2a, 0x26, 0x22, 0x1e, 0x1a, 0x16, 0x12, 0x0e
1669}; 1658};
1670 1659
1671static int __openfirmware 1660static int
1672pmu_set_backlight_enable(int on, int level, void* data) 1661pmu_set_backlight_enable(int on, int level, void* data)
1673{ 1662{
1674 struct adb_request req; 1663 struct adb_request req;
@@ -1688,7 +1677,7 @@ pmu_set_backlight_enable(int on, int level, void* data)
1688 return 0; 1677 return 0;
1689} 1678}
1690 1679
1691static void __openfirmware 1680static void
1692pmu_bright_complete(struct adb_request *req) 1681pmu_bright_complete(struct adb_request *req)
1693{ 1682{
1694 if (req == &bright_req_1) 1683 if (req == &bright_req_1)
@@ -1697,7 +1686,7 @@ pmu_bright_complete(struct adb_request *req)
1697 clear_bit(2, &async_req_locks); 1686 clear_bit(2, &async_req_locks);
1698} 1687}
1699 1688
1700static int __openfirmware 1689static int
1701pmu_set_backlight_level(int level, void* data) 1690pmu_set_backlight_level(int level, void* data)
1702{ 1691{
1703 if (vias == NULL) 1692 if (vias == NULL)
@@ -1717,7 +1706,7 @@ pmu_set_backlight_level(int level, void* data)
1717} 1706}
1718#endif /* CONFIG_PMAC_BACKLIGHT */ 1707#endif /* CONFIG_PMAC_BACKLIGHT */
1719 1708
1720void __pmac 1709void
1721pmu_enable_irled(int on) 1710pmu_enable_irled(int on)
1722{ 1711{
1723 struct adb_request req; 1712 struct adb_request req;
@@ -1732,7 +1721,7 @@ pmu_enable_irled(int on)
1732 pmu_wait_complete(&req); 1721 pmu_wait_complete(&req);
1733} 1722}
1734 1723
1735void __pmac 1724void
1736pmu_restart(void) 1725pmu_restart(void)
1737{ 1726{
1738 struct adb_request req; 1727 struct adb_request req;
@@ -1757,7 +1746,7 @@ pmu_restart(void)
1757 ; 1746 ;
1758} 1747}
1759 1748
1760void __pmac 1749void
1761pmu_shutdown(void) 1750pmu_shutdown(void)
1762{ 1751{
1763 struct adb_request req; 1752 struct adb_request req;
@@ -2064,6 +2053,7 @@ pmu_register_sleep_notifier(struct pmu_sleep_notifier *n)
2064 __list_add(&n->list, list->prev, list); 2053 __list_add(&n->list, list->prev, list);
2065 return 0; 2054 return 0;
2066} 2055}
2056EXPORT_SYMBOL(pmu_register_sleep_notifier);
2067 2057
2068int 2058int
2069pmu_unregister_sleep_notifier(struct pmu_sleep_notifier* n) 2059pmu_unregister_sleep_notifier(struct pmu_sleep_notifier* n)
@@ -2074,9 +2064,13 @@ pmu_unregister_sleep_notifier(struct pmu_sleep_notifier* n)
2074 n->list.next = NULL; 2064 n->list.next = NULL;
2075 return 0; 2065 return 0;
2076} 2066}
2067EXPORT_SYMBOL(pmu_unregister_sleep_notifier);
2068#endif /* CONFIG_PM */
2069
2070#if defined(CONFIG_PM) && defined(CONFIG_PPC32)
2077 2071
2078/* Sleep is broadcast last-to-first */ 2072/* Sleep is broadcast last-to-first */
2079static int __pmac 2073static int
2080broadcast_sleep(int when, int fallback) 2074broadcast_sleep(int when, int fallback)
2081{ 2075{
2082 int ret = PBOOK_SLEEP_OK; 2076 int ret = PBOOK_SLEEP_OK;
@@ -2101,7 +2095,7 @@ broadcast_sleep(int when, int fallback)
2101} 2095}
2102 2096
2103/* Wake is broadcast first-to-last */ 2097/* Wake is broadcast first-to-last */
2104static int __pmac 2098static int
2105broadcast_wake(void) 2099broadcast_wake(void)
2106{ 2100{
2107 int ret = PBOOK_SLEEP_OK; 2101 int ret = PBOOK_SLEEP_OK;
@@ -2132,7 +2126,7 @@ static struct pci_save {
2132} *pbook_pci_saves; 2126} *pbook_pci_saves;
2133static int pbook_npci_saves; 2127static int pbook_npci_saves;
2134 2128
2135static void __pmac 2129static void
2136pbook_alloc_pci_save(void) 2130pbook_alloc_pci_save(void)
2137{ 2131{
2138 int npci; 2132 int npci;
@@ -2149,7 +2143,7 @@ pbook_alloc_pci_save(void)
2149 pbook_npci_saves = npci; 2143 pbook_npci_saves = npci;
2150} 2144}
2151 2145
2152static void __pmac 2146static void
2153pbook_free_pci_save(void) 2147pbook_free_pci_save(void)
2154{ 2148{
2155 if (pbook_pci_saves == NULL) 2149 if (pbook_pci_saves == NULL)
@@ -2159,7 +2153,7 @@ pbook_free_pci_save(void)
2159 pbook_npci_saves = 0; 2153 pbook_npci_saves = 0;
2160} 2154}
2161 2155
2162static void __pmac 2156static void
2163pbook_pci_save(void) 2157pbook_pci_save(void)
2164{ 2158{
2165 struct pci_save *ps = pbook_pci_saves; 2159 struct pci_save *ps = pbook_pci_saves;
@@ -2190,7 +2184,7 @@ pbook_pci_save(void)
2190 * during boot, it will be in the pci dev list. If it's disabled at this point 2184 * during boot, it will be in the pci dev list. If it's disabled at this point
2191 * (and it will probably be), then you can't access it's config space. 2185 * (and it will probably be), then you can't access it's config space.
2192 */ 2186 */
2193static void __pmac 2187static void
2194pbook_pci_restore(void) 2188pbook_pci_restore(void)
2195{ 2189{
2196 u16 cmd; 2190 u16 cmd;
@@ -2238,7 +2232,7 @@ pbook_pci_restore(void)
2238 2232
2239#ifdef DEBUG_SLEEP 2233#ifdef DEBUG_SLEEP
2240/* N.B. This doesn't work on the 3400 */ 2234/* N.B. This doesn't work on the 3400 */
2241void __pmac 2235void
2242pmu_blink(int n) 2236pmu_blink(int n)
2243{ 2237{
2244 struct adb_request req; 2238 struct adb_request req;
@@ -2277,9 +2271,9 @@ pmu_blink(int n)
2277 * Put the powerbook to sleep. 2271 * Put the powerbook to sleep.
2278 */ 2272 */
2279 2273
2280static u32 save_via[8] __pmacdata; 2274static u32 save_via[8];
2281 2275
2282static void __pmac 2276static void
2283save_via_state(void) 2277save_via_state(void)
2284{ 2278{
2285 save_via[0] = in_8(&via[ANH]); 2279 save_via[0] = in_8(&via[ANH]);
@@ -2291,7 +2285,7 @@ save_via_state(void)
2291 save_via[6] = in_8(&via[T1CL]); 2285 save_via[6] = in_8(&via[T1CL]);
2292 save_via[7] = in_8(&via[T1CH]); 2286 save_via[7] = in_8(&via[T1CH]);
2293} 2287}
2294static void __pmac 2288static void
2295restore_via_state(void) 2289restore_via_state(void)
2296{ 2290{
2297 out_8(&via[ANH], save_via[0]); 2291 out_8(&via[ANH], save_via[0]);
@@ -2307,7 +2301,7 @@ restore_via_state(void)
2307 out_8(&via[IER], IER_SET | SR_INT | CB1_INT); 2301 out_8(&via[IER], IER_SET | SR_INT | CB1_INT);
2308} 2302}
2309 2303
2310static int __pmac 2304static int
2311pmac_suspend_devices(void) 2305pmac_suspend_devices(void)
2312{ 2306{
2313 int ret; 2307 int ret;
@@ -2397,7 +2391,7 @@ pmac_suspend_devices(void)
2397 return 0; 2391 return 0;
2398} 2392}
2399 2393
2400static int __pmac 2394static int
2401pmac_wakeup_devices(void) 2395pmac_wakeup_devices(void)
2402{ 2396{
2403 mdelay(100); 2397 mdelay(100);
@@ -2436,7 +2430,7 @@ pmac_wakeup_devices(void)
2436#define GRACKLE_NAP (1<<4) 2430#define GRACKLE_NAP (1<<4)
2437#define GRACKLE_SLEEP (1<<3) 2431#define GRACKLE_SLEEP (1<<3)
2438 2432
2439int __pmac 2433int
2440powerbook_sleep_grackle(void) 2434powerbook_sleep_grackle(void)
2441{ 2435{
2442 unsigned long save_l2cr; 2436 unsigned long save_l2cr;
@@ -2520,7 +2514,7 @@ powerbook_sleep_grackle(void)
2520 return 0; 2514 return 0;
2521} 2515}
2522 2516
2523static int __pmac 2517static int
2524powerbook_sleep_Core99(void) 2518powerbook_sleep_Core99(void)
2525{ 2519{
2526 unsigned long save_l2cr; 2520 unsigned long save_l2cr;
@@ -2620,7 +2614,7 @@ powerbook_sleep_Core99(void)
2620#define PB3400_MEM_CTRL 0xf8000000 2614#define PB3400_MEM_CTRL 0xf8000000
2621#define PB3400_MEM_CTRL_SLEEP 0x70 2615#define PB3400_MEM_CTRL_SLEEP 0x70
2622 2616
2623static int __pmac 2617static int
2624powerbook_sleep_3400(void) 2618powerbook_sleep_3400(void)
2625{ 2619{
2626 int ret, i, x; 2620 int ret, i, x;
@@ -2675,10 +2669,10 @@ powerbook_sleep_3400(void)
2675 asleep = 1; 2669 asleep = 1;
2676 2670
2677 /* Put the CPU into sleep mode */ 2671 /* Put the CPU into sleep mode */
2678 asm volatile("mfspr %0,1008" : "=r" (hid0) :); 2672 hid0 = mfspr(SPRN_HID0);
2679 hid0 = (hid0 & ~(HID0_NAP | HID0_DOZE)) | HID0_SLEEP; 2673 hid0 = (hid0 & ~(HID0_NAP | HID0_DOZE)) | HID0_SLEEP;
2680 asm volatile("mtspr 1008,%0" : : "r" (hid0)); 2674 mtspr(SPRN_HID0, hid0);
2681 _nmask_and_or_msr(0, MSR_POW | MSR_EE); 2675 mtmsr(mfmsr() | MSR_POW | MSR_EE);
2682 udelay(10); 2676 udelay(10);
2683 2677
2684 /* OK, we're awake again, start restoring things */ 2678 /* OK, we're awake again, start restoring things */
@@ -2698,7 +2692,7 @@ powerbook_sleep_3400(void)
2698 return 0; 2692 return 0;
2699} 2693}
2700 2694
2701#endif /* CONFIG_PM */ 2695#endif /* CONFIG_PM && CONFIG_PPC32 */
2702 2696
2703/* 2697/*
2704 * Support for /dev/pmu device 2698 * Support for /dev/pmu device
@@ -2720,9 +2714,9 @@ struct pmu_private {
2720}; 2714};
2721 2715
2722static LIST_HEAD(all_pmu_pvt); 2716static LIST_HEAD(all_pmu_pvt);
2723static DEFINE_SPINLOCK(all_pvt_lock __pmacdata); 2717static DEFINE_SPINLOCK(all_pvt_lock);
2724 2718
2725static void __pmac 2719static void
2726pmu_pass_intr(unsigned char *data, int len) 2720pmu_pass_intr(unsigned char *data, int len)
2727{ 2721{
2728 struct pmu_private *pp; 2722 struct pmu_private *pp;
@@ -2751,7 +2745,7 @@ pmu_pass_intr(unsigned char *data, int len)
2751 spin_unlock_irqrestore(&all_pvt_lock, flags); 2745 spin_unlock_irqrestore(&all_pvt_lock, flags);
2752} 2746}
2753 2747
2754static int __pmac 2748static int
2755pmu_open(struct inode *inode, struct file *file) 2749pmu_open(struct inode *inode, struct file *file)
2756{ 2750{
2757 struct pmu_private *pp; 2751 struct pmu_private *pp;
@@ -2773,7 +2767,7 @@ pmu_open(struct inode *inode, struct file *file)
2773 return 0; 2767 return 0;
2774} 2768}
2775 2769
2776static ssize_t __pmac 2770static ssize_t
2777pmu_read(struct file *file, char __user *buf, 2771pmu_read(struct file *file, char __user *buf,
2778 size_t count, loff_t *ppos) 2772 size_t count, loff_t *ppos)
2779{ 2773{
@@ -2825,14 +2819,14 @@ pmu_read(struct file *file, char __user *buf,
2825 return ret; 2819 return ret;
2826} 2820}
2827 2821
2828static ssize_t __pmac 2822static ssize_t
2829pmu_write(struct file *file, const char __user *buf, 2823pmu_write(struct file *file, const char __user *buf,
2830 size_t count, loff_t *ppos) 2824 size_t count, loff_t *ppos)
2831{ 2825{
2832 return 0; 2826 return 0;
2833} 2827}
2834 2828
2835static unsigned int __pmac 2829static unsigned int
2836pmu_fpoll(struct file *filp, poll_table *wait) 2830pmu_fpoll(struct file *filp, poll_table *wait)
2837{ 2831{
2838 struct pmu_private *pp = filp->private_data; 2832 struct pmu_private *pp = filp->private_data;
@@ -2849,7 +2843,7 @@ pmu_fpoll(struct file *filp, poll_table *wait)
2849 return mask; 2843 return mask;
2850} 2844}
2851 2845
2852static int __pmac 2846static int
2853pmu_release(struct inode *inode, struct file *file) 2847pmu_release(struct inode *inode, struct file *file)
2854{ 2848{
2855 struct pmu_private *pp = file->private_data; 2849 struct pmu_private *pp = file->private_data;
@@ -2874,8 +2868,7 @@ pmu_release(struct inode *inode, struct file *file)
2874 return 0; 2868 return 0;
2875} 2869}
2876 2870
2877/* Note: removed __openfirmware here since it causes link errors */ 2871static int
2878static int __pmac
2879pmu_ioctl(struct inode * inode, struct file *filp, 2872pmu_ioctl(struct inode * inode, struct file *filp,
2880 u_int cmd, u_long arg) 2873 u_int cmd, u_long arg)
2881{ 2874{
@@ -2883,7 +2876,7 @@ pmu_ioctl(struct inode * inode, struct file *filp,
2883 int error = -EINVAL; 2876 int error = -EINVAL;
2884 2877
2885 switch (cmd) { 2878 switch (cmd) {
2886#ifdef CONFIG_PM 2879#if defined(CONFIG_PM) && defined(CONFIG_PPC32)
2887 case PMU_IOC_SLEEP: 2880 case PMU_IOC_SLEEP:
2888 if (!capable(CAP_SYS_ADMIN)) 2881 if (!capable(CAP_SYS_ADMIN))
2889 return -EACCES; 2882 return -EACCES;
@@ -2911,7 +2904,7 @@ pmu_ioctl(struct inode * inode, struct file *filp,
2911 return put_user(0, argp); 2904 return put_user(0, argp);
2912 else 2905 else
2913 return put_user(1, argp); 2906 return put_user(1, argp);
2914#endif /* CONFIG_PM */ 2907#endif /* CONFIG_PM && CONFIG_PPC32 */
2915 2908
2916#ifdef CONFIG_PMAC_BACKLIGHT 2909#ifdef CONFIG_PMAC_BACKLIGHT
2917 /* Backlight should have its own device or go via 2910 /* Backlight should have its own device or go via
@@ -2957,7 +2950,7 @@ pmu_ioctl(struct inode * inode, struct file *filp,
2957 return error; 2950 return error;
2958} 2951}
2959 2952
2960static struct file_operations pmu_device_fops __pmacdata = { 2953static struct file_operations pmu_device_fops = {
2961 .read = pmu_read, 2954 .read = pmu_read,
2962 .write = pmu_write, 2955 .write = pmu_write,
2963 .poll = pmu_fpoll, 2956 .poll = pmu_fpoll,
@@ -2966,7 +2959,7 @@ static struct file_operations pmu_device_fops __pmacdata = {
2966 .release = pmu_release, 2959 .release = pmu_release,
2967}; 2960};
2968 2961
2969static struct miscdevice pmu_device __pmacdata = { 2962static struct miscdevice pmu_device = {
2970 PMU_MINOR, "pmu", &pmu_device_fops 2963 PMU_MINOR, "pmu", &pmu_device_fops
2971}; 2964};
2972 2965
@@ -2982,7 +2975,7 @@ device_initcall(pmu_device_init);
2982 2975
2983 2976
2984#ifdef DEBUG_SLEEP 2977#ifdef DEBUG_SLEEP
2985static inline void __pmac 2978static inline void
2986polled_handshake(volatile unsigned char __iomem *via) 2979polled_handshake(volatile unsigned char __iomem *via)
2987{ 2980{
2988 via[B] &= ~TREQ; eieio(); 2981 via[B] &= ~TREQ; eieio();
@@ -2993,7 +2986,7 @@ polled_handshake(volatile unsigned char __iomem *via)
2993 ; 2986 ;
2994} 2987}
2995 2988
2996static inline void __pmac 2989static inline void
2997polled_send_byte(volatile unsigned char __iomem *via, int x) 2990polled_send_byte(volatile unsigned char __iomem *via, int x)
2998{ 2991{
2999 via[ACR] |= SR_OUT | SR_EXT; eieio(); 2992 via[ACR] |= SR_OUT | SR_EXT; eieio();
@@ -3001,7 +2994,7 @@ polled_send_byte(volatile unsigned char __iomem *via, int x)
3001 polled_handshake(via); 2994 polled_handshake(via);
3002} 2995}
3003 2996
3004static inline int __pmac 2997static inline int
3005polled_recv_byte(volatile unsigned char __iomem *via) 2998polled_recv_byte(volatile unsigned char __iomem *via)
3006{ 2999{
3007 int x; 3000 int x;
@@ -3013,7 +3006,7 @@ polled_recv_byte(volatile unsigned char __iomem *via)
3013 return x; 3006 return x;
3014} 3007}
3015 3008
3016int __pmac 3009int
3017pmu_polled_request(struct adb_request *req) 3010pmu_polled_request(struct adb_request *req)
3018{ 3011{
3019 unsigned long flags; 3012 unsigned long flags;
@@ -3059,7 +3052,7 @@ pmu_polled_request(struct adb_request *req)
3059 * to do suspend-to-disk. 3052 * to do suspend-to-disk.
3060 */ 3053 */
3061 3054
3062#ifdef CONFIG_PM 3055#if defined(CONFIG_PM) && defined(CONFIG_PPC32)
3063 3056
3064static int pmu_sys_suspended = 0; 3057static int pmu_sys_suspended = 0;
3065 3058
@@ -3094,7 +3087,7 @@ static int pmu_sys_resume(struct sys_device *sysdev)
3094 return 0; 3087 return 0;
3095} 3088}
3096 3089
3097#endif /* CONFIG_PM */ 3090#endif /* CONFIG_PM && CONFIG_PPC32 */
3098 3091
3099static struct sysdev_class pmu_sysclass = { 3092static struct sysdev_class pmu_sysclass = {
3100 set_kset_name("pmu"), 3093 set_kset_name("pmu"),
@@ -3106,10 +3099,10 @@ static struct sys_device device_pmu = {
3106}; 3099};
3107 3100
3108static struct sysdev_driver driver_pmu = { 3101static struct sysdev_driver driver_pmu = {
3109#ifdef CONFIG_PM 3102#if defined(CONFIG_PM) && defined(CONFIG_PPC32)
3110 .suspend = &pmu_sys_suspend, 3103 .suspend = &pmu_sys_suspend,
3111 .resume = &pmu_sys_resume, 3104 .resume = &pmu_sys_resume,
3112#endif /* CONFIG_PM */ 3105#endif /* CONFIG_PM && CONFIG_PPC32 */
3113}; 3106};
3114 3107
3115static int __init init_pmu_sysfs(void) 3108static int __init init_pmu_sysfs(void)
@@ -3147,12 +3140,10 @@ EXPORT_SYMBOL(pmu_i2c_combined_read);
3147EXPORT_SYMBOL(pmu_i2c_stdsub_write); 3140EXPORT_SYMBOL(pmu_i2c_stdsub_write);
3148EXPORT_SYMBOL(pmu_i2c_simple_read); 3141EXPORT_SYMBOL(pmu_i2c_simple_read);
3149EXPORT_SYMBOL(pmu_i2c_simple_write); 3142EXPORT_SYMBOL(pmu_i2c_simple_write);
3150#ifdef CONFIG_PM 3143#if defined(CONFIG_PM) && defined(CONFIG_PPC32)
3151EXPORT_SYMBOL(pmu_register_sleep_notifier);
3152EXPORT_SYMBOL(pmu_unregister_sleep_notifier);
3153EXPORT_SYMBOL(pmu_enable_irled); 3144EXPORT_SYMBOL(pmu_enable_irled);
3154EXPORT_SYMBOL(pmu_battery_count); 3145EXPORT_SYMBOL(pmu_battery_count);
3155EXPORT_SYMBOL(pmu_batteries); 3146EXPORT_SYMBOL(pmu_batteries);
3156EXPORT_SYMBOL(pmu_power_flags); 3147EXPORT_SYMBOL(pmu_power_flags);
3157#endif /* CONFIG_PM */ 3148#endif /* CONFIG_PM && CONFIG_PPC32 */
3158 3149