diff options
Diffstat (limited to 'drivers/macintosh/via-pmu.c')
-rw-r--r-- | drivers/macintosh/via-pmu.c | 364 |
1 files changed, 66 insertions, 298 deletions
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c index 564043508569..6eb93e45fcd3 100644 --- a/drivers/macintosh/via-pmu.c +++ b/drivers/macintosh/via-pmu.c | |||
@@ -55,6 +55,8 @@ | |||
55 | #include <asm/sections.h> | 55 | #include <asm/sections.h> |
56 | #include <asm/irq.h> | 56 | #include <asm/irq.h> |
57 | #include <asm/pmac_feature.h> | 57 | #include <asm/pmac_feature.h> |
58 | #include <asm/pmac_pfunc.h> | ||
59 | #include <asm/pmac_low_i2c.h> | ||
58 | #include <asm/uaccess.h> | 60 | #include <asm/uaccess.h> |
59 | #include <asm/mmu_context.h> | 61 | #include <asm/mmu_context.h> |
60 | #include <asm/cputable.h> | 62 | #include <asm/cputable.h> |
@@ -147,6 +149,7 @@ static struct device_node *vias; | |||
147 | static int pmu_kind = PMU_UNKNOWN; | 149 | static int pmu_kind = PMU_UNKNOWN; |
148 | static int pmu_fully_inited = 0; | 150 | static int pmu_fully_inited = 0; |
149 | static int pmu_has_adb; | 151 | static int pmu_has_adb; |
152 | static struct device_node *gpio_node; | ||
150 | static unsigned char __iomem *gpio_reg = NULL; | 153 | static unsigned char __iomem *gpio_reg = NULL; |
151 | static int gpio_irq = -1; | 154 | static int gpio_irq = -1; |
152 | static int gpio_irq_enabled = -1; | 155 | static int gpio_irq_enabled = -1; |
@@ -157,8 +160,8 @@ static int pmu_version; | |||
157 | static int drop_interrupts; | 160 | static int drop_interrupts; |
158 | #if defined(CONFIG_PM) && defined(CONFIG_PPC32) | 161 | #if defined(CONFIG_PM) && defined(CONFIG_PPC32) |
159 | static int option_lid_wakeup = 1; | 162 | static int option_lid_wakeup = 1; |
160 | static int sleep_in_progress; | ||
161 | #endif /* CONFIG_PM && CONFIG_PPC32 */ | 163 | #endif /* CONFIG_PM && CONFIG_PPC32 */ |
164 | static int sleep_in_progress; | ||
162 | static unsigned long async_req_locks; | 165 | static unsigned long async_req_locks; |
163 | static unsigned int pmu_irq_stats[11]; | 166 | static unsigned int pmu_irq_stats[11]; |
164 | 167 | ||
@@ -196,7 +199,6 @@ static int pmu_adb_reset_bus(void); | |||
196 | #endif /* CONFIG_ADB */ | 199 | #endif /* CONFIG_ADB */ |
197 | 200 | ||
198 | static int init_pmu(void); | 201 | static int init_pmu(void); |
199 | static int pmu_queue_request(struct adb_request *req); | ||
200 | static void pmu_start(void); | 202 | static void pmu_start(void); |
201 | static irqreturn_t via_pmu_interrupt(int irq, void *arg, struct pt_regs *regs); | 203 | static irqreturn_t via_pmu_interrupt(int irq, void *arg, struct pt_regs *regs); |
202 | static irqreturn_t gpio1_interrupt(int irq, void *arg, struct pt_regs *regs); | 204 | static irqreturn_t gpio1_interrupt(int irq, void *arg, struct pt_regs *regs); |
@@ -295,22 +297,26 @@ static struct backlight_controller pmu_backlight_controller = { | |||
295 | }; | 297 | }; |
296 | #endif /* CONFIG_PMAC_BACKLIGHT */ | 298 | #endif /* CONFIG_PMAC_BACKLIGHT */ |
297 | 299 | ||
298 | int | 300 | int __init find_via_pmu(void) |
299 | find_via_pmu(void) | ||
300 | { | 301 | { |
302 | u64 taddr; | ||
303 | u32 *reg; | ||
304 | |||
301 | if (via != 0) | 305 | if (via != 0) |
302 | return 1; | 306 | return 1; |
303 | vias = find_devices("via-pmu"); | 307 | vias = of_find_node_by_name(NULL, "via-pmu"); |
304 | if (vias == 0) | 308 | if (vias == NULL) |
305 | return 0; | 309 | return 0; |
306 | if (vias->next != 0) | ||
307 | printk(KERN_WARNING "Warning: only using 1st via-pmu\n"); | ||
308 | 310 | ||
309 | if (vias->n_addrs < 1 || vias->n_intrs < 1) { | 311 | reg = (u32 *)get_property(vias, "reg", NULL); |
310 | printk(KERN_ERR "via-pmu: %d addresses, %d interrupts!\n", | 312 | if (reg == NULL) { |
311 | vias->n_addrs, vias->n_intrs); | 313 | printk(KERN_ERR "via-pmu: No \"reg\" property !\n"); |
312 | if (vias->n_addrs < 1 || vias->n_intrs < 1) | 314 | goto fail; |
313 | return 0; | 315 | } |
316 | taddr = of_translate_address(vias, reg); | ||
317 | if (taddr == OF_BAD_ADDR) { | ||
318 | printk(KERN_ERR "via-pmu: Can't translate address !\n"); | ||
319 | goto fail; | ||
314 | } | 320 | } |
315 | 321 | ||
316 | spin_lock_init(&pmu_lock); | 322 | spin_lock_init(&pmu_lock); |
@@ -331,7 +337,8 @@ find_via_pmu(void) | |||
331 | pmu_kind = PMU_HEATHROW_BASED; | 337 | pmu_kind = PMU_HEATHROW_BASED; |
332 | else if (device_is_compatible(vias->parent, "Keylargo") | 338 | else if (device_is_compatible(vias->parent, "Keylargo") |
333 | || device_is_compatible(vias->parent, "K2-Keylargo")) { | 339 | || device_is_compatible(vias->parent, "K2-Keylargo")) { |
334 | struct device_node *gpio, *gpiop; | 340 | struct device_node *gpiop; |
341 | u64 gaddr = OF_BAD_ADDR; | ||
335 | 342 | ||
336 | pmu_kind = PMU_KEYLARGO_BASED; | 343 | pmu_kind = PMU_KEYLARGO_BASED; |
337 | pmu_has_adb = (find_type_devices("adb") != NULL); | 344 | pmu_has_adb = (find_type_devices("adb") != NULL); |
@@ -341,19 +348,24 @@ find_via_pmu(void) | |||
341 | PMU_INT_TICK | | 348 | PMU_INT_TICK | |
342 | PMU_INT_ENVIRONMENT; | 349 | PMU_INT_ENVIRONMENT; |
343 | 350 | ||
344 | gpiop = find_devices("gpio"); | 351 | gpiop = of_find_node_by_name(NULL, "gpio"); |
345 | if (gpiop && gpiop->n_addrs) { | 352 | if (gpiop) { |
346 | gpio_reg = ioremap(gpiop->addrs->address, 0x10); | 353 | reg = (u32 *)get_property(gpiop, "reg", NULL); |
347 | gpio = find_devices("extint-gpio1"); | 354 | if (reg) |
348 | if (gpio == NULL) | 355 | gaddr = of_translate_address(gpiop, reg); |
349 | gpio = find_devices("pmu-interrupt"); | 356 | if (gaddr != OF_BAD_ADDR) |
350 | if (gpio && gpio->parent == gpiop && gpio->n_intrs) | 357 | gpio_reg = ioremap(gaddr, 0x10); |
351 | gpio_irq = gpio->intrs[0].line; | ||
352 | } | 358 | } |
359 | if (gpio_reg == NULL) | ||
360 | printk(KERN_ERR "via-pmu: Can't find GPIO reg !\n"); | ||
353 | } else | 361 | } else |
354 | pmu_kind = PMU_UNKNOWN; | 362 | pmu_kind = PMU_UNKNOWN; |
355 | 363 | ||
356 | via = ioremap(vias->addrs->address, 0x2000); | 364 | via = ioremap(taddr, 0x2000); |
365 | if (via == NULL) { | ||
366 | printk(KERN_ERR "via-pmu: Can't map address !\n"); | ||
367 | goto fail; | ||
368 | } | ||
357 | 369 | ||
358 | out_8(&via[IER], IER_CLR | 0x7f); /* disable all intrs */ | 370 | out_8(&via[IER], IER_CLR | 0x7f); /* disable all intrs */ |
359 | out_8(&via[IFR], 0x7f); /* clear IFR */ | 371 | out_8(&via[IFR], 0x7f); /* clear IFR */ |
@@ -365,23 +377,25 @@ find_via_pmu(void) | |||
365 | return 0; | 377 | return 0; |
366 | } | 378 | } |
367 | 379 | ||
368 | printk(KERN_INFO "PMU driver %d initialized for %s, firmware: %02x\n", | 380 | printk(KERN_INFO "PMU driver v%d initialized for %s, firmware: %02x\n", |
369 | PMU_DRIVER_VERSION, pbook_type[pmu_kind], pmu_version); | 381 | PMU_DRIVER_VERSION, pbook_type[pmu_kind], pmu_version); |
370 | 382 | ||
371 | sys_ctrler = SYS_CTRLER_PMU; | 383 | sys_ctrler = SYS_CTRLER_PMU; |
372 | 384 | ||
373 | return 1; | 385 | return 1; |
386 | fail: | ||
387 | of_node_put(vias); | ||
388 | vias = NULL; | ||
389 | return 0; | ||
374 | } | 390 | } |
375 | 391 | ||
376 | #ifdef CONFIG_ADB | 392 | #ifdef CONFIG_ADB |
377 | static int | 393 | static int pmu_probe(void) |
378 | pmu_probe(void) | ||
379 | { | 394 | { |
380 | return vias == NULL? -ENODEV: 0; | 395 | return vias == NULL? -ENODEV: 0; |
381 | } | 396 | } |
382 | 397 | ||
383 | static int __init | 398 | static int __init pmu_init(void) |
384 | pmu_init(void) | ||
385 | { | 399 | { |
386 | if (vias == NULL) | 400 | if (vias == NULL) |
387 | return -ENODEV; | 401 | return -ENODEV; |
@@ -405,7 +419,7 @@ static int __init via_pmu_start(void) | |||
405 | bright_req_2.complete = 1; | 419 | bright_req_2.complete = 1; |
406 | batt_req.complete = 1; | 420 | batt_req.complete = 1; |
407 | 421 | ||
408 | #if defined(CONFIG_PPC32) && !defined(CONFIG_PPC_MERGE) | 422 | #ifndef CONFIG_PPC_MERGE |
409 | if (pmu_kind == PMU_KEYLARGO_BASED) | 423 | if (pmu_kind == PMU_KEYLARGO_BASED) |
410 | openpic_set_irq_priority(vias->intrs[0].line, | 424 | openpic_set_irq_priority(vias->intrs[0].line, |
411 | OPENPIC_PRIORITY_DEFAULT + 1); | 425 | OPENPIC_PRIORITY_DEFAULT + 1); |
@@ -418,10 +432,22 @@ static int __init via_pmu_start(void) | |||
418 | return -EAGAIN; | 432 | return -EAGAIN; |
419 | } | 433 | } |
420 | 434 | ||
421 | if (pmu_kind == PMU_KEYLARGO_BASED && gpio_irq != -1) { | 435 | if (pmu_kind == PMU_KEYLARGO_BASED) { |
422 | if (request_irq(gpio_irq, gpio1_interrupt, 0, "GPIO1 ADB", (void *)0)) | 436 | gpio_node = of_find_node_by_name(NULL, "extint-gpio1"); |
423 | printk(KERN_ERR "pmu: can't get irq %d (GPIO1)\n", gpio_irq); | 437 | if (gpio_node == NULL) |
424 | gpio_irq_enabled = 1; | 438 | gpio_node = of_find_node_by_name(NULL, |
439 | "pmu-interrupt"); | ||
440 | if (gpio_node && gpio_node->n_intrs > 0) | ||
441 | gpio_irq = gpio_node->intrs[0].line; | ||
442 | |||
443 | if (gpio_irq != -1) { | ||
444 | if (request_irq(gpio_irq, gpio1_interrupt, 0, | ||
445 | "GPIO1 ADB", (void *)0)) | ||
446 | printk(KERN_ERR "pmu: can't get irq %d" | ||
447 | " (GPIO1)\n", gpio_irq); | ||
448 | else | ||
449 | gpio_irq_enabled = 1; | ||
450 | } | ||
425 | } | 451 | } |
426 | 452 | ||
427 | /* Enable interrupts */ | 453 | /* Enable interrupts */ |
@@ -454,9 +480,6 @@ static int __init via_pmu_dev_init(void) | |||
454 | if (vias == NULL) | 480 | if (vias == NULL) |
455 | return -ENODEV; | 481 | return -ENODEV; |
456 | 482 | ||
457 | #ifndef CONFIG_PPC64 | ||
458 | request_OF_resource(vias, 0, NULL); | ||
459 | #endif | ||
460 | #ifdef CONFIG_PMAC_BACKLIGHT | 483 | #ifdef CONFIG_PMAC_BACKLIGHT |
461 | /* Enable backlight */ | 484 | /* Enable backlight */ |
462 | register_backlight_controller(&pmu_backlight_controller, NULL, "pmu"); | 485 | register_backlight_controller(&pmu_backlight_controller, NULL, "pmu"); |
@@ -1371,7 +1394,6 @@ next: | |||
1371 | } | 1394 | } |
1372 | pmu_done(req); | 1395 | pmu_done(req); |
1373 | } else { | 1396 | } else { |
1374 | #if defined(CONFIG_XMON) && !defined(CONFIG_PPC64) | ||
1375 | if (len == 4 && data[1] == 0x2c) { | 1397 | if (len == 4 && data[1] == 0x2c) { |
1376 | extern int xmon_wants_key, xmon_adb_keycode; | 1398 | extern int xmon_wants_key, xmon_adb_keycode; |
1377 | if (xmon_wants_key) { | 1399 | if (xmon_wants_key) { |
@@ -1379,7 +1401,6 @@ next: | |||
1379 | return; | 1401 | return; |
1380 | } | 1402 | } |
1381 | } | 1403 | } |
1382 | #endif /* defined(CONFIG_XMON) && !defined(CONFIG_PPC64) */ | ||
1383 | #ifdef CONFIG_ADB | 1404 | #ifdef CONFIG_ADB |
1384 | /* | 1405 | /* |
1385 | * XXX On the [23]400 the PMU gives us an up | 1406 | * XXX On the [23]400 the PMU gives us an up |
@@ -1782,258 +1803,6 @@ pmu_present(void) | |||
1782 | return via != 0; | 1803 | return via != 0; |
1783 | } | 1804 | } |
1784 | 1805 | ||
1785 | struct pmu_i2c_hdr { | ||
1786 | u8 bus; | ||
1787 | u8 mode; | ||
1788 | u8 bus2; | ||
1789 | u8 address; | ||
1790 | u8 sub_addr; | ||
1791 | u8 comb_addr; | ||
1792 | u8 count; | ||
1793 | }; | ||
1794 | |||
1795 | int | ||
1796 | pmu_i2c_combined_read(int bus, int addr, int subaddr, u8* data, int len) | ||
1797 | { | ||
1798 | struct adb_request req; | ||
1799 | struct pmu_i2c_hdr *hdr = (struct pmu_i2c_hdr *)&req.data[1]; | ||
1800 | int retry; | ||
1801 | int rc; | ||
1802 | |||
1803 | for (retry=0; retry<16; retry++) { | ||
1804 | memset(&req, 0, sizeof(req)); | ||
1805 | |||
1806 | hdr->bus = bus; | ||
1807 | hdr->address = addr & 0xfe; | ||
1808 | hdr->mode = PMU_I2C_MODE_COMBINED; | ||
1809 | hdr->bus2 = 0; | ||
1810 | hdr->sub_addr = subaddr; | ||
1811 | hdr->comb_addr = addr | 1; | ||
1812 | hdr->count = len; | ||
1813 | |||
1814 | req.nbytes = sizeof(struct pmu_i2c_hdr) + 1; | ||
1815 | req.reply_expected = 0; | ||
1816 | req.reply_len = 0; | ||
1817 | req.data[0] = PMU_I2C_CMD; | ||
1818 | req.reply[0] = 0xff; | ||
1819 | rc = pmu_queue_request(&req); | ||
1820 | if (rc) | ||
1821 | return rc; | ||
1822 | while(!req.complete) | ||
1823 | pmu_poll(); | ||
1824 | if (req.reply[0] == PMU_I2C_STATUS_OK) | ||
1825 | break; | ||
1826 | mdelay(15); | ||
1827 | } | ||
1828 | if (req.reply[0] != PMU_I2C_STATUS_OK) | ||
1829 | return -1; | ||
1830 | |||
1831 | for (retry=0; retry<16; retry++) { | ||
1832 | memset(&req, 0, sizeof(req)); | ||
1833 | |||
1834 | mdelay(15); | ||
1835 | |||
1836 | hdr->bus = PMU_I2C_BUS_STATUS; | ||
1837 | req.reply[0] = 0xff; | ||
1838 | |||
1839 | req.nbytes = 2; | ||
1840 | req.reply_expected = 0; | ||
1841 | req.reply_len = 0; | ||
1842 | req.data[0] = PMU_I2C_CMD; | ||
1843 | rc = pmu_queue_request(&req); | ||
1844 | if (rc) | ||
1845 | return rc; | ||
1846 | while(!req.complete) | ||
1847 | pmu_poll(); | ||
1848 | if (req.reply[0] == PMU_I2C_STATUS_DATAREAD) { | ||
1849 | memcpy(data, &req.reply[1], req.reply_len - 1); | ||
1850 | return req.reply_len - 1; | ||
1851 | } | ||
1852 | } | ||
1853 | return -1; | ||
1854 | } | ||
1855 | |||
1856 | int | ||
1857 | pmu_i2c_stdsub_write(int bus, int addr, int subaddr, u8* data, int len) | ||
1858 | { | ||
1859 | struct adb_request req; | ||
1860 | struct pmu_i2c_hdr *hdr = (struct pmu_i2c_hdr *)&req.data[1]; | ||
1861 | int retry; | ||
1862 | int rc; | ||
1863 | |||
1864 | for (retry=0; retry<16; retry++) { | ||
1865 | memset(&req, 0, sizeof(req)); | ||
1866 | |||
1867 | hdr->bus = bus; | ||
1868 | hdr->address = addr & 0xfe; | ||
1869 | hdr->mode = PMU_I2C_MODE_STDSUB; | ||
1870 | hdr->bus2 = 0; | ||
1871 | hdr->sub_addr = subaddr; | ||
1872 | hdr->comb_addr = addr & 0xfe; | ||
1873 | hdr->count = len; | ||
1874 | |||
1875 | req.data[0] = PMU_I2C_CMD; | ||
1876 | memcpy(&req.data[sizeof(struct pmu_i2c_hdr) + 1], data, len); | ||
1877 | req.nbytes = sizeof(struct pmu_i2c_hdr) + len + 1; | ||
1878 | req.reply_expected = 0; | ||
1879 | req.reply_len = 0; | ||
1880 | req.reply[0] = 0xff; | ||
1881 | rc = pmu_queue_request(&req); | ||
1882 | if (rc) | ||
1883 | return rc; | ||
1884 | while(!req.complete) | ||
1885 | pmu_poll(); | ||
1886 | if (req.reply[0] == PMU_I2C_STATUS_OK) | ||
1887 | break; | ||
1888 | mdelay(15); | ||
1889 | } | ||
1890 | if (req.reply[0] != PMU_I2C_STATUS_OK) | ||
1891 | return -1; | ||
1892 | |||
1893 | for (retry=0; retry<16; retry++) { | ||
1894 | memset(&req, 0, sizeof(req)); | ||
1895 | |||
1896 | mdelay(15); | ||
1897 | |||
1898 | hdr->bus = PMU_I2C_BUS_STATUS; | ||
1899 | req.reply[0] = 0xff; | ||
1900 | |||
1901 | req.nbytes = 2; | ||
1902 | req.reply_expected = 0; | ||
1903 | req.reply_len = 0; | ||
1904 | req.data[0] = PMU_I2C_CMD; | ||
1905 | rc = pmu_queue_request(&req); | ||
1906 | if (rc) | ||
1907 | return rc; | ||
1908 | while(!req.complete) | ||
1909 | pmu_poll(); | ||
1910 | if (req.reply[0] == PMU_I2C_STATUS_OK) | ||
1911 | return len; | ||
1912 | } | ||
1913 | return -1; | ||
1914 | } | ||
1915 | |||
1916 | int | ||
1917 | pmu_i2c_simple_read(int bus, int addr, u8* data, int len) | ||
1918 | { | ||
1919 | struct adb_request req; | ||
1920 | struct pmu_i2c_hdr *hdr = (struct pmu_i2c_hdr *)&req.data[1]; | ||
1921 | int retry; | ||
1922 | int rc; | ||
1923 | |||
1924 | for (retry=0; retry<16; retry++) { | ||
1925 | memset(&req, 0, sizeof(req)); | ||
1926 | |||
1927 | hdr->bus = bus; | ||
1928 | hdr->address = addr | 1; | ||
1929 | hdr->mode = PMU_I2C_MODE_SIMPLE; | ||
1930 | hdr->bus2 = 0; | ||
1931 | hdr->sub_addr = 0; | ||
1932 | hdr->comb_addr = 0; | ||
1933 | hdr->count = len; | ||
1934 | |||
1935 | req.data[0] = PMU_I2C_CMD; | ||
1936 | req.nbytes = sizeof(struct pmu_i2c_hdr) + 1; | ||
1937 | req.reply_expected = 0; | ||
1938 | req.reply_len = 0; | ||
1939 | req.reply[0] = 0xff; | ||
1940 | rc = pmu_queue_request(&req); | ||
1941 | if (rc) | ||
1942 | return rc; | ||
1943 | while(!req.complete) | ||
1944 | pmu_poll(); | ||
1945 | if (req.reply[0] == PMU_I2C_STATUS_OK) | ||
1946 | break; | ||
1947 | mdelay(15); | ||
1948 | } | ||
1949 | if (req.reply[0] != PMU_I2C_STATUS_OK) | ||
1950 | return -1; | ||
1951 | |||
1952 | for (retry=0; retry<16; retry++) { | ||
1953 | memset(&req, 0, sizeof(req)); | ||
1954 | |||
1955 | mdelay(15); | ||
1956 | |||
1957 | hdr->bus = PMU_I2C_BUS_STATUS; | ||
1958 | req.reply[0] = 0xff; | ||
1959 | |||
1960 | req.nbytes = 2; | ||
1961 | req.reply_expected = 0; | ||
1962 | req.reply_len = 0; | ||
1963 | req.data[0] = PMU_I2C_CMD; | ||
1964 | rc = pmu_queue_request(&req); | ||
1965 | if (rc) | ||
1966 | return rc; | ||
1967 | while(!req.complete) | ||
1968 | pmu_poll(); | ||
1969 | if (req.reply[0] == PMU_I2C_STATUS_DATAREAD) { | ||
1970 | memcpy(data, &req.reply[1], req.reply_len - 1); | ||
1971 | return req.reply_len - 1; | ||
1972 | } | ||
1973 | } | ||
1974 | return -1; | ||
1975 | } | ||
1976 | |||
1977 | int | ||
1978 | pmu_i2c_simple_write(int bus, int addr, u8* data, int len) | ||
1979 | { | ||
1980 | struct adb_request req; | ||
1981 | struct pmu_i2c_hdr *hdr = (struct pmu_i2c_hdr *)&req.data[1]; | ||
1982 | int retry; | ||
1983 | int rc; | ||
1984 | |||
1985 | for (retry=0; retry<16; retry++) { | ||
1986 | memset(&req, 0, sizeof(req)); | ||
1987 | |||
1988 | hdr->bus = bus; | ||
1989 | hdr->address = addr & 0xfe; | ||
1990 | hdr->mode = PMU_I2C_MODE_SIMPLE; | ||
1991 | hdr->bus2 = 0; | ||
1992 | hdr->sub_addr = 0; | ||
1993 | hdr->comb_addr = 0; | ||
1994 | hdr->count = len; | ||
1995 | |||
1996 | req.data[0] = PMU_I2C_CMD; | ||
1997 | memcpy(&req.data[sizeof(struct pmu_i2c_hdr) + 1], data, len); | ||
1998 | req.nbytes = sizeof(struct pmu_i2c_hdr) + len + 1; | ||
1999 | req.reply_expected = 0; | ||
2000 | req.reply_len = 0; | ||
2001 | req.reply[0] = 0xff; | ||
2002 | rc = pmu_queue_request(&req); | ||
2003 | if (rc) | ||
2004 | return rc; | ||
2005 | while(!req.complete) | ||
2006 | pmu_poll(); | ||
2007 | if (req.reply[0] == PMU_I2C_STATUS_OK) | ||
2008 | break; | ||
2009 | mdelay(15); | ||
2010 | } | ||
2011 | if (req.reply[0] != PMU_I2C_STATUS_OK) | ||
2012 | return -1; | ||
2013 | |||
2014 | for (retry=0; retry<16; retry++) { | ||
2015 | memset(&req, 0, sizeof(req)); | ||
2016 | |||
2017 | mdelay(15); | ||
2018 | |||
2019 | hdr->bus = PMU_I2C_BUS_STATUS; | ||
2020 | req.reply[0] = 0xff; | ||
2021 | |||
2022 | req.nbytes = 2; | ||
2023 | req.reply_expected = 0; | ||
2024 | req.reply_len = 0; | ||
2025 | req.data[0] = PMU_I2C_CMD; | ||
2026 | rc = pmu_queue_request(&req); | ||
2027 | if (rc) | ||
2028 | return rc; | ||
2029 | while(!req.complete) | ||
2030 | pmu_poll(); | ||
2031 | if (req.reply[0] == PMU_I2C_STATUS_OK) | ||
2032 | return len; | ||
2033 | } | ||
2034 | return -1; | ||
2035 | } | ||
2036 | |||
2037 | #ifdef CONFIG_PM | 1806 | #ifdef CONFIG_PM |
2038 | 1807 | ||
2039 | static LIST_HEAD(sleep_notifiers); | 1808 | static LIST_HEAD(sleep_notifiers); |
@@ -2338,8 +2107,9 @@ pmac_suspend_devices(void) | |||
2338 | return -EBUSY; | 2107 | return -EBUSY; |
2339 | } | 2108 | } |
2340 | 2109 | ||
2341 | /* Disable clock spreading on some machines */ | 2110 | /* Call platform functions marked "on sleep" */ |
2342 | pmac_tweak_clock_spreading(0); | 2111 | pmac_pfunc_i2c_suspend(); |
2112 | pmac_pfunc_base_suspend(); | ||
2343 | 2113 | ||
2344 | /* Stop preemption */ | 2114 | /* Stop preemption */ |
2345 | preempt_disable(); | 2115 | preempt_disable(); |
@@ -2411,8 +2181,9 @@ pmac_wakeup_devices(void) | |||
2411 | mdelay(10); | 2181 | mdelay(10); |
2412 | preempt_enable(); | 2182 | preempt_enable(); |
2413 | 2183 | ||
2414 | /* Re-enable clock spreading on some machines */ | 2184 | /* Call platform functions marked "on wake" */ |
2415 | pmac_tweak_clock_spreading(1); | 2185 | pmac_pfunc_base_resume(); |
2186 | pmac_pfunc_i2c_resume(); | ||
2416 | 2187 | ||
2417 | /* Resume devices */ | 2188 | /* Resume devices */ |
2418 | device_resume(); | 2189 | device_resume(); |
@@ -3130,16 +2901,13 @@ static int __init init_pmu_sysfs(void) | |||
3130 | subsys_initcall(init_pmu_sysfs); | 2901 | subsys_initcall(init_pmu_sysfs); |
3131 | 2902 | ||
3132 | EXPORT_SYMBOL(pmu_request); | 2903 | EXPORT_SYMBOL(pmu_request); |
2904 | EXPORT_SYMBOL(pmu_queue_request); | ||
3133 | EXPORT_SYMBOL(pmu_poll); | 2905 | EXPORT_SYMBOL(pmu_poll); |
3134 | EXPORT_SYMBOL(pmu_poll_adb); | 2906 | EXPORT_SYMBOL(pmu_poll_adb); |
3135 | EXPORT_SYMBOL(pmu_wait_complete); | 2907 | EXPORT_SYMBOL(pmu_wait_complete); |
3136 | EXPORT_SYMBOL(pmu_suspend); | 2908 | EXPORT_SYMBOL(pmu_suspend); |
3137 | EXPORT_SYMBOL(pmu_resume); | 2909 | EXPORT_SYMBOL(pmu_resume); |
3138 | EXPORT_SYMBOL(pmu_unlock); | 2910 | EXPORT_SYMBOL(pmu_unlock); |
3139 | EXPORT_SYMBOL(pmu_i2c_combined_read); | ||
3140 | EXPORT_SYMBOL(pmu_i2c_stdsub_write); | ||
3141 | EXPORT_SYMBOL(pmu_i2c_simple_read); | ||
3142 | EXPORT_SYMBOL(pmu_i2c_simple_write); | ||
3143 | #if defined(CONFIG_PM) && defined(CONFIG_PPC32) | 2911 | #if defined(CONFIG_PM) && defined(CONFIG_PPC32) |
3144 | EXPORT_SYMBOL(pmu_enable_irled); | 2912 | EXPORT_SYMBOL(pmu_enable_irled); |
3145 | EXPORT_SYMBOL(pmu_battery_count); | 2913 | EXPORT_SYMBOL(pmu_battery_count); |