Lines Matching refs:req
176 static int pmu_send_request(struct adb_request *req, int sync);
182 static int pmu_queue_request(struct adb_request *req);
223 int pmu_polled_request(struct adb_request *req);
504 struct adb_request req; in init_pmu() local
509 pmu_request(&req, NULL, 2, PMU_SET_INTR_MASK, pmu_intr_mask); in init_pmu()
511 while (!req.complete) { in init_pmu()
536 pmu_request(&req, NULL, 2, PMU_SYSTEM_READY, 2); in init_pmu()
537 while (!req.complete) in init_pmu()
542 pmu_request(&req, NULL, 1, PMU_GET_VERSION); in init_pmu()
543 while (!req.complete) in init_pmu()
545 if (req.reply_len > 0) in init_pmu()
546 pmu_version = req.reply[0]; in init_pmu()
573 done_battery_state_ohare(struct adb_request* req) in done_battery_state_ohare() argument
600 if (req->reply[0] & 0x01) in done_battery_state_ohare()
617 if (req->reply[0] & 0x04) { in done_battery_state_ohare()
619 if (req->reply[0] & 0x02) in done_battery_state_ohare()
621 vb = (req->reply[1] << 8) | req->reply[2]; in done_battery_state_ohare()
623 current = req->reply[5]; in done_battery_state_ohare()
624 if ((req->reply[0] & 0x01) == 0) { in done_battery_state_ohare()
627 } else if (req->reply[0] & 0x02) { in done_battery_state_ohare()
632 if (req->reply[0] & 0x40) { in done_battery_state_ohare()
633 pcharge = (req->reply[6] << 8) + req->reply[7]; in done_battery_state_ohare()
659 done_battery_state_smart(struct adb_request* req) in done_battery_state_smart() argument
684 if (req->reply[1] & 0x01) in done_battery_state_smart()
690 if (req->reply[1] & 0x04) { in done_battery_state_smart()
692 switch(req->reply[0]) { in done_battery_state_smart()
694 case 4: capa = req->reply[2]; in done_battery_state_smart()
695 max = req->reply[3]; in done_battery_state_smart()
696 current = *((signed char *)&req->reply[4]); in done_battery_state_smart()
697 voltage = req->reply[5]; in done_battery_state_smart()
699 case 5: capa = (req->reply[2] << 8) | req->reply[3]; in done_battery_state_smart()
700 max = (req->reply[4] << 8) | req->reply[5]; in done_battery_state_smart()
701 current = *((signed short *)&req->reply[6]); in done_battery_state_smart()
702 voltage = (req->reply[8] << 8) | req->reply[9]; in done_battery_state_smart()
706 req->reply_len, req->reply[0], req->reply[1], req->reply[2], req->reply[3]); in done_battery_state_smart()
712 if ((req->reply[1] & 0x01) && (current > 0)) in done_battery_state_smart()
721 if ((req->reply[1] & 0x01) && (current > 0)) in done_battery_state_smart()
847 pmu_send_request(struct adb_request *req, int sync) in pmu_send_request() argument
852 req->complete = 1; in pmu_send_request()
858 switch (req->data[0]) { in pmu_send_request()
860 for (i = 0; i < req->nbytes - 1; ++i) in pmu_send_request()
861 req->data[i] = req->data[i+1]; in pmu_send_request()
862 --req->nbytes; in pmu_send_request()
863 if (pmu_data_len[req->data[0]][1] != 0) { in pmu_send_request()
864 req->reply[0] = ADB_RET_OK; in pmu_send_request()
865 req->reply_len = 1; in pmu_send_request()
867 req->reply_len = 0; in pmu_send_request()
868 ret = pmu_queue_request(req); in pmu_send_request()
871 switch (req->data[1]) { in pmu_send_request()
873 if (req->nbytes != 2) in pmu_send_request()
875 req->data[0] = PMU_READ_RTC; in pmu_send_request()
876 req->nbytes = 1; in pmu_send_request()
877 req->reply_len = 3; in pmu_send_request()
878 req->reply[0] = CUDA_PACKET; in pmu_send_request()
879 req->reply[1] = 0; in pmu_send_request()
880 req->reply[2] = CUDA_GET_TIME; in pmu_send_request()
881 ret = pmu_queue_request(req); in pmu_send_request()
884 if (req->nbytes != 6) in pmu_send_request()
886 req->data[0] = PMU_SET_RTC; in pmu_send_request()
887 req->nbytes = 5; in pmu_send_request()
889 req->data[i] = req->data[i+1]; in pmu_send_request()
890 req->reply_len = 3; in pmu_send_request()
891 req->reply[0] = CUDA_PACKET; in pmu_send_request()
892 req->reply[1] = 0; in pmu_send_request()
893 req->reply[2] = CUDA_SET_TIME; in pmu_send_request()
894 ret = pmu_queue_request(req); in pmu_send_request()
901 for (i = req->nbytes - 1; i > 1; --i) in pmu_send_request()
902 req->data[i+2] = req->data[i]; in pmu_send_request()
903 req->data[3] = req->nbytes - 2; in pmu_send_request()
904 req->data[2] = pmu_adb_flags; in pmu_send_request()
906 req->data[0] = PMU_ADB_CMD; in pmu_send_request()
907 req->nbytes += 2; in pmu_send_request()
908 req->reply_expected = 1; in pmu_send_request()
909 req->reply_len = 0; in pmu_send_request()
910 ret = pmu_queue_request(req); in pmu_send_request()
914 req->complete = 1; in pmu_send_request()
919 while (!req->complete) in pmu_send_request()
929 struct adb_request req; in pmu_adb_autopoll() local
936 pmu_request(&req, NULL, 5, PMU_ADB_CMD, 0, 0x86, in pmu_adb_autopoll()
940 pmu_request(&req, NULL, 1, PMU_ADB_POLL_OFF); in pmu_adb_autopoll()
943 while (!req.complete) in pmu_adb_autopoll()
952 struct adb_request req; in pmu_adb_reset_bus() local
961 req.nbytes = 5; in pmu_adb_reset_bus()
962 req.done = NULL; in pmu_adb_reset_bus()
963 req.data[0] = PMU_ADB_CMD; in pmu_adb_reset_bus()
964 req.data[1] = 0; in pmu_adb_reset_bus()
965 req.data[2] = ADB_BUSRESET; in pmu_adb_reset_bus()
966 req.data[3] = 0; in pmu_adb_reset_bus()
967 req.data[4] = 0; in pmu_adb_reset_bus()
968 req.reply_len = 0; in pmu_adb_reset_bus()
969 req.reply_expected = 1; in pmu_adb_reset_bus()
970 if (pmu_queue_request(&req) != 0) { in pmu_adb_reset_bus()
974 while (!req.complete) in pmu_adb_reset_bus()
986 pmu_request(struct adb_request *req, void (*done)(struct adb_request *), in pmu_request() argument
997 req->complete = 1; in pmu_request()
1000 req->nbytes = nbytes; in pmu_request()
1001 req->done = done; in pmu_request()
1004 req->data[i] = va_arg(list, int); in pmu_request()
1006 req->reply_len = 0; in pmu_request()
1007 req->reply_expected = 0; in pmu_request()
1008 return pmu_queue_request(req); in pmu_request()
1012 pmu_queue_request(struct adb_request *req) in pmu_queue_request() argument
1018 req->complete = 1; in pmu_queue_request()
1021 if (req->nbytes <= 0) { in pmu_queue_request()
1022 req->complete = 1; in pmu_queue_request()
1025 nsend = pmu_data_len[req->data[0]][0]; in pmu_queue_request()
1026 if (nsend >= 0 && req->nbytes != nsend + 1) { in pmu_queue_request()
1027 req->complete = 1; in pmu_queue_request()
1031 req->next = 0; in pmu_queue_request()
1032 req->sent = 0; in pmu_queue_request()
1033 req->complete = 0; in pmu_queue_request()
1037 last_req->next = req; in pmu_queue_request()
1038 last_req = req; in pmu_queue_request()
1040 current_req = req; in pmu_queue_request()
1041 last_req = req; in pmu_queue_request()
1091 pmu_done(struct adb_request *req) in pmu_done() argument
1093 void (*done)(struct adb_request *) = req->done; in pmu_done()
1095 req->complete = 1; in pmu_done()
1100 (*done)(req); in pmu_done()
1106 struct adb_request *req; in pmu_start() local
1110 req = current_req; in pmu_start()
1111 if (req == 0 || pmu_state != idle in pmu_start()
1117 data_len = pmu_data_len[req->data[0]][0]; in pmu_start()
1124 send_byte(req->data[0]); in pmu_start()
1153 struct adb_request *req; in pmu_suspend() local
1171 pmu_request(&req, NULL, 2, PMU_SET_INTR_MASK, 0); in pmu_suspend()
1173 while(!req.complete) in pmu_suspend()
1202 pmu_request(&req, NULL, 2, PMU_SET_INTR_MASK, pmu_intr_mask); in pmu_resume()
1204 while(!req.complete) in pmu_resume()
1230 struct adb_request *req = req_awaiting_reply; in pmu_handle_data() local
1231 if (req == 0) { in pmu_handle_data()
1237 req->reply_len = 0; in pmu_handle_data()
1239 memcpy(req->reply, data + 1, len - 1); in pmu_handle_data()
1240 req->reply_len = len - 1; in pmu_handle_data()
1242 pmu_done(req); in pmu_handle_data()
1294 struct adb_request *req; in pmu_sr_intr() local
1316 req = current_req; in pmu_sr_intr()
1318 data_len = req->nbytes - 1; in pmu_sr_intr()
1323 send_byte(req->data[data_index++]); in pmu_sr_intr()
1326 req->sent = 1; in pmu_sr_intr()
1327 data_len = pmu_data_len[req->data[0]][1]; in pmu_sr_intr()
1330 current_req = req->next; in pmu_sr_intr()
1331 if (req->reply_expected) in pmu_sr_intr()
1332 req_awaiting_reply = req; in pmu_sr_intr()
1334 return req; in pmu_sr_intr()
1338 reply_ptr = req->reply + req->reply_len; in pmu_sr_intr()
1370 req = current_req; in pmu_sr_intr()
1371 current_req = req->next; in pmu_sr_intr()
1372 req->reply_len += data_index; in pmu_sr_intr()
1374 return req; in pmu_sr_intr()
1392 struct adb_request *req = NULL; in via_pmu_interrupt() local
1412 req = pmu_sr_intr(regs); in via_pmu_interrupt()
1413 if (req) in via_pmu_interrupt()
1452 if (req) { in via_pmu_interrupt()
1453 pmu_done(req); in via_pmu_interrupt()
1454 req = NULL; in via_pmu_interrupt()
1486 struct adb_request req; in pmu_set_backlight_enable() local
1492 pmu_request(&req, NULL, 2, PMU_BACKLIGHT_BRIGHT, in pmu_set_backlight_enable()
1494 while (!req.complete) in pmu_set_backlight_enable()
1497 pmu_request(&req, NULL, 2, PMU_POWER_CTRL, in pmu_set_backlight_enable()
1499 while (!req.complete) in pmu_set_backlight_enable()
1527 struct adb_request req; in pmu_enable_irled() local
1534 pmu_request(&req, NULL, 2, PMU_POWER_CTRL, PMU_POW_IRLED | in pmu_enable_irled()
1536 while (!req.complete) in pmu_enable_irled()
1543 struct adb_request req; in pmu_restart() local
1550 pmu_request(&req, NULL, 2, PMU_SET_INTR_MASK, PMU_INT_ADB | in pmu_restart()
1552 while(!req.complete) in pmu_restart()
1556 pmu_request(&req, NULL, 1, PMU_RESET); in pmu_restart()
1557 while(!req.complete || (pmu_state != idle)) in pmu_restart()
1566 struct adb_request req; in pmu_shutdown() local
1573 pmu_request(&req, NULL, 2, PMU_SET_INTR_MASK, PMU_INT_ADB | in pmu_shutdown()
1575 while(!req.complete) in pmu_shutdown()
1579 pmu_request(&req, NULL, 5, PMU_SHUTDOWN, in pmu_shutdown()
1581 while(!req.complete || (pmu_state != idle)) in pmu_shutdown()
1606 struct adb_request req; in pmu_i2c_combined_read() local
1607 struct pmu_i2c_hdr *hdr = (struct pmu_i2c_hdr *)&req.data[1]; in pmu_i2c_combined_read()
1612 memset(&req, 0, sizeof(req)); in pmu_i2c_combined_read()
1622 req.nbytes = sizeof(struct pmu_i2c_hdr) + 1; in pmu_i2c_combined_read()
1623 req.reply_expected = 0; in pmu_i2c_combined_read()
1624 req.reply_len = 0; in pmu_i2c_combined_read()
1625 req.data[0] = PMU_I2C_CMD; in pmu_i2c_combined_read()
1626 req.reply[0] = 0xff; in pmu_i2c_combined_read()
1627 rc = pmu_queue_request(&req); in pmu_i2c_combined_read()
1630 while(!req.complete) in pmu_i2c_combined_read()
1632 if (req.reply[0] == PMU_I2C_STATUS_OK) in pmu_i2c_combined_read()
1636 if (req.reply[0] != PMU_I2C_STATUS_OK) in pmu_i2c_combined_read()
1640 memset(&req, 0, sizeof(req)); in pmu_i2c_combined_read()
1645 req.reply[0] = 0xff; in pmu_i2c_combined_read()
1647 req.nbytes = 2; in pmu_i2c_combined_read()
1648 req.reply_expected = 0; in pmu_i2c_combined_read()
1649 req.reply_len = 0; in pmu_i2c_combined_read()
1650 req.data[0] = PMU_I2C_CMD; in pmu_i2c_combined_read()
1651 rc = pmu_queue_request(&req); in pmu_i2c_combined_read()
1654 while(!req.complete) in pmu_i2c_combined_read()
1656 if (req.reply[0] == PMU_I2C_STATUS_DATAREAD) { in pmu_i2c_combined_read()
1657 memcpy(data, &req.reply[1], req.reply_len - 1); in pmu_i2c_combined_read()
1658 return req.reply_len - 1; in pmu_i2c_combined_read()
1667 struct adb_request req; in pmu_i2c_stdsub_write() local
1668 struct pmu_i2c_hdr *hdr = (struct pmu_i2c_hdr *)&req.data[1]; in pmu_i2c_stdsub_write()
1673 memset(&req, 0, sizeof(req)); in pmu_i2c_stdsub_write()
1683 req.data[0] = PMU_I2C_CMD; in pmu_i2c_stdsub_write()
1684 memcpy(&req.data[sizeof(struct pmu_i2c_hdr) + 1], data, len); in pmu_i2c_stdsub_write()
1685 req.nbytes = sizeof(struct pmu_i2c_hdr) + len + 1; in pmu_i2c_stdsub_write()
1686 req.reply_expected = 0; in pmu_i2c_stdsub_write()
1687 req.reply_len = 0; in pmu_i2c_stdsub_write()
1688 req.reply[0] = 0xff; in pmu_i2c_stdsub_write()
1689 rc = pmu_queue_request(&req); in pmu_i2c_stdsub_write()
1692 while(!req.complete) in pmu_i2c_stdsub_write()
1694 if (req.reply[0] == PMU_I2C_STATUS_OK) in pmu_i2c_stdsub_write()
1698 if (req.reply[0] != PMU_I2C_STATUS_OK) in pmu_i2c_stdsub_write()
1702 memset(&req, 0, sizeof(req)); in pmu_i2c_stdsub_write()
1707 req.reply[0] = 0xff; in pmu_i2c_stdsub_write()
1709 req.nbytes = 2; in pmu_i2c_stdsub_write()
1710 req.reply_expected = 0; in pmu_i2c_stdsub_write()
1711 req.reply_len = 0; in pmu_i2c_stdsub_write()
1712 req.data[0] = PMU_I2C_CMD; in pmu_i2c_stdsub_write()
1713 rc = pmu_queue_request(&req); in pmu_i2c_stdsub_write()
1716 while(!req.complete) in pmu_i2c_stdsub_write()
1718 if (req.reply[0] == PMU_I2C_STATUS_OK) in pmu_i2c_stdsub_write()
1727 struct adb_request req; in pmu_i2c_simple_read() local
1728 struct pmu_i2c_hdr *hdr = (struct pmu_i2c_hdr *)&req.data[1]; in pmu_i2c_simple_read()
1733 memset(&req, 0, sizeof(req)); in pmu_i2c_simple_read()
1743 req.data[0] = PMU_I2C_CMD; in pmu_i2c_simple_read()
1744 req.nbytes = sizeof(struct pmu_i2c_hdr) + 1; in pmu_i2c_simple_read()
1745 req.reply_expected = 0; in pmu_i2c_simple_read()
1746 req.reply_len = 0; in pmu_i2c_simple_read()
1747 req.reply[0] = 0xff; in pmu_i2c_simple_read()
1748 rc = pmu_queue_request(&req); in pmu_i2c_simple_read()
1751 while(!req.complete) in pmu_i2c_simple_read()
1753 if (req.reply[0] == PMU_I2C_STATUS_OK) in pmu_i2c_simple_read()
1757 if (req.reply[0] != PMU_I2C_STATUS_OK) in pmu_i2c_simple_read()
1761 memset(&req, 0, sizeof(req)); in pmu_i2c_simple_read()
1766 req.reply[0] = 0xff; in pmu_i2c_simple_read()
1768 req.nbytes = 2; in pmu_i2c_simple_read()
1769 req.reply_expected = 0; in pmu_i2c_simple_read()
1770 req.reply_len = 0; in pmu_i2c_simple_read()
1771 req.data[0] = PMU_I2C_CMD; in pmu_i2c_simple_read()
1772 rc = pmu_queue_request(&req); in pmu_i2c_simple_read()
1775 while(!req.complete) in pmu_i2c_simple_read()
1777 if (req.reply[0] == PMU_I2C_STATUS_DATAREAD) { in pmu_i2c_simple_read()
1778 memcpy(data, &req.reply[1], req.reply_len - 1); in pmu_i2c_simple_read()
1779 return req.reply_len - 1; in pmu_i2c_simple_read()
1788 struct adb_request req; in pmu_i2c_simple_write() local
1789 struct pmu_i2c_hdr *hdr = (struct pmu_i2c_hdr *)&req.data[1]; in pmu_i2c_simple_write()
1794 memset(&req, 0, sizeof(req)); in pmu_i2c_simple_write()
1804 req.data[0] = PMU_I2C_CMD; in pmu_i2c_simple_write()
1805 memcpy(&req.data[sizeof(struct pmu_i2c_hdr) + 1], data, len); in pmu_i2c_simple_write()
1806 req.nbytes = sizeof(struct pmu_i2c_hdr) + len + 1; in pmu_i2c_simple_write()
1807 req.reply_expected = 0; in pmu_i2c_simple_write()
1808 req.reply_len = 0; in pmu_i2c_simple_write()
1809 req.reply[0] = 0xff; in pmu_i2c_simple_write()
1810 rc = pmu_queue_request(&req); in pmu_i2c_simple_write()
1813 while(!req.complete) in pmu_i2c_simple_write()
1815 if (req.reply[0] == PMU_I2C_STATUS_OK) in pmu_i2c_simple_write()
1819 if (req.reply[0] != PMU_I2C_STATUS_OK) in pmu_i2c_simple_write()
1823 memset(&req, 0, sizeof(req)); in pmu_i2c_simple_write()
1828 req.reply[0] = 0xff; in pmu_i2c_simple_write()
1830 req.nbytes = 2; in pmu_i2c_simple_write()
1831 req.reply_expected = 0; in pmu_i2c_simple_write()
1832 req.reply_len = 0; in pmu_i2c_simple_write()
1833 req.data[0] = PMU_I2C_CMD; in pmu_i2c_simple_write()
1834 rc = pmu_queue_request(&req); in pmu_i2c_simple_write()
1837 while(!req.complete) in pmu_i2c_simple_write()
1839 if (req.reply[0] == PMU_I2C_STATUS_OK) in pmu_i2c_simple_write()
1851 struct adb_request req; in pmu_blink() local
1853 memset(&req, 0, sizeof(req)); in pmu_blink()
1856 req.nbytes = 4; in pmu_blink()
1857 req.done = NULL; in pmu_blink()
1858 req.data[0] = 0xee; in pmu_blink()
1859 req.data[1] = 4; in pmu_blink()
1860 req.data[2] = 0; in pmu_blink()
1861 req.data[3] = 1; in pmu_blink()
1862 req.reply[0] = ADB_RET_OK; in pmu_blink()
1863 req.reply_len = 1; in pmu_blink()
1864 req.reply_expected = 0; in pmu_blink()
1865 pmu_polled_request(&req); in pmu_blink()
1867 req.nbytes = 4; in pmu_blink()
1868 req.done = NULL; in pmu_blink()
1869 req.data[0] = 0xee; in pmu_blink()
1870 req.data[1] = 4; in pmu_blink()
1871 req.data[2] = 0; in pmu_blink()
1872 req.data[3] = 0; in pmu_blink()
1873 req.reply[0] = ADB_RET_OK; in pmu_blink()
1874 req.reply_len = 1; in pmu_blink()
1875 req.reply_expected = 0; in pmu_blink()
1876 pmu_polled_request(&req); in pmu_blink()
2139 struct adb_request req; in powerbook_sleep_G3() local
2179 pmu_request(&req, NULL, 2, PMU_POWER_CTRL0, PMU_POW0_OFF|PMU_POW0_HARD_DRIVE); in powerbook_sleep_G3()
2180 while (!req.complete) in powerbook_sleep_G3()
2182 pmu_request(&req, NULL, 2, PMU_POWER_CTRL, in powerbook_sleep_G3()
2184 while (!req.complete) in powerbook_sleep_G3()
2213 pmu_request(&req, NULL, 5, PMU_SLEEP, 'M', 'A', 'T', 'T'); in powerbook_sleep_G3()
2214 while (!req.complete) in powerbook_sleep_G3()
2248 pmu_request(&req, NULL, 2, PMU_SET_INTR_MASK, 0xfc); in powerbook_sleep_G3()
2249 while (!req.complete) in powerbook_sleep_G3()
2251 pmu_request(&req, NULL, 2, PMU_POWER_CTRL0, in powerbook_sleep_G3()
2253 while (!req.complete) in powerbook_sleep_G3()
2255 pmu_request(&req, NULL, 2, PMU_POWER_CTRL, in powerbook_sleep_G3()
2257 while (!req.complete) in powerbook_sleep_G3()
2287 struct adb_request req; in powerbook_sleep_Core99() local
2326 pmu_request(&req, NULL, 4, PMU_POWER_EVENTS, PMU_PWR_CLR_WAKEUP_EVENTS, in powerbook_sleep_Core99()
2328 while (!req.complete) in powerbook_sleep_Core99()
2331 pmu_request(&req, NULL, 4, PMU_POWER_EVENTS, PMU_PWR_SET_WAKEUP_EVENTS, in powerbook_sleep_Core99()
2334 while (!req.complete) in powerbook_sleep_Core99()
2375 pmu_request(&req, NULL, 5, PMU_SLEEP, 'M', 'A', 'T', 'T'); in powerbook_sleep_Core99()
2376 while (!req.complete && pmu_state != idle) in powerbook_sleep_Core99()
2426 pmu_request(&req, NULL, 2, PMU_SYSTEM_READY, 2); in powerbook_sleep_Core99()
2427 while (!req.complete) in powerbook_sleep_Core99()
2429 pmu_request(&req, NULL, 2, PMU_SET_INTR_MASK, 0xfc); in powerbook_sleep_Core99()
2430 while (!req.complete) in powerbook_sleep_Core99()
2881 pmu_polled_request(struct adb_request *req) in pmu_polled_request() argument
2887 req->complete = 1; in pmu_polled_request()
2888 c = req->data[0]; in pmu_polled_request()
2890 if (l >= 0 && req->nbytes != l + 1) in pmu_polled_request()
2901 l = req->nbytes - 1; in pmu_polled_request()
2905 polled_send_byte(v, req->data[i]); in pmu_polled_request()
2911 req->reply[i + req->reply_len] = polled_recv_byte(v); in pmu_polled_request()
2913 if (req->done) in pmu_polled_request()
2914 (*req->done)(req); in pmu_polled_request()