| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: pm_direct.c,v 1.30 2021/08/21 11:55:24 andvar Exp $ */ | | 1 | /* $NetBSD: pm_direct.c,v 1.31 2024/04/26 00:59:08 nat Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (C) 1997 Takashi Hamada | | 4 | * Copyright (C) 1997 Takashi Hamada |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -22,27 +22,27 @@ | | | @@ -22,27 +22,27 @@ |
22 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | | 22 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
23 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | | 23 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
24 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | | 24 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | | 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
26 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | | 26 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | | 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | | 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | | 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
31 | */ | | 31 | */ |
32 | /* From: pm_direct.c 1.3 03/18/98 Takashi Hamada */ | | 32 | /* From: pm_direct.c 1.3 03/18/98 Takashi Hamada */ |
33 | | | 33 | |
34 | #include <sys/cdefs.h> | | 34 | #include <sys/cdefs.h> |
35 | __KERNEL_RCSID(0, "$NetBSD: pm_direct.c,v 1.30 2021/08/21 11:55:24 andvar Exp $"); | | 35 | __KERNEL_RCSID(0, "$NetBSD: pm_direct.c,v 1.31 2024/04/26 00:59:08 nat Exp $"); |
36 | | | 36 | |
37 | #include "opt_adb.h" | | 37 | #include "opt_adb.h" |
38 | | | 38 | |
39 | #ifdef DEBUG | | 39 | #ifdef DEBUG |
40 | #ifndef ADB_DEBUG | | 40 | #ifndef ADB_DEBUG |
41 | #define ADB_DEBUG | | 41 | #define ADB_DEBUG |
42 | #endif | | 42 | #endif |
43 | #endif | | 43 | #endif |
44 | | | 44 | |
45 | /* #define PM_GRAB_SI 1 */ | | 45 | /* #define PM_GRAB_SI 1 */ |
46 | | | 46 | |
47 | #include <sys/types.h> | | 47 | #include <sys/types.h> |
48 | #include <sys/systm.h> | | 48 | #include <sys/systm.h> |
| @@ -552,26 +552,27 @@ pm_intr_pm1(void *arg) | | | @@ -552,26 +552,27 @@ pm_intr_pm1(void *arg) |
552 | /* ask PM what happened */ | | 552 | /* ask PM what happened */ |
553 | pmdata.command = 0x78; | | 553 | pmdata.command = 0x78; |
554 | pmdata.num_data = 0; | | 554 | pmdata.num_data = 0; |
555 | pmdata.data[0] = pmdata.data[1] = 0; | | 555 | pmdata.data[0] = pmdata.data[1] = 0; |
556 | pmdata.s_buf = &pmdata.data[2]; | | 556 | pmdata.s_buf = &pmdata.data[2]; |
557 | pmdata.r_buf = &pmdata.data[2]; | | 557 | pmdata.r_buf = &pmdata.data[2]; |
558 | rval = pm_pmgrop_pm1(&pmdata); | | 558 | rval = pm_pmgrop_pm1(&pmdata); |
559 | if (rval != 0) { | | 559 | if (rval != 0) { |
560 | #ifdef ADB_DEBUG | | 560 | #ifdef ADB_DEBUG |
561 | if (adb_debug) | | 561 | if (adb_debug) |
562 | printf("pm: PM is not ready. error code=%08x\n", rval); | | 562 | printf("pm: PM is not ready. error code=%08x\n", rval); |
563 | #endif | | 563 | #endif |
564 | splx(s); | | 564 | splx(s); |
| | | 565 | return; |
565 | } | | 566 | } |
566 | | | 567 | |
567 | if ((pmdata.data[2] & 0x10) == 0x10) { | | 568 | if ((pmdata.data[2] & 0x10) == 0x10) { |
568 | if ((pmdata.data[2] & 0x0f) == 0) { | | 569 | if ((pmdata.data[2] & 0x0f) == 0) { |
569 | /* ADB data that were requested by TALK command */ | | 570 | /* ADB data that were requested by TALK command */ |
570 | pm_adb_get_TALK_result(&pmdata); | | 571 | pm_adb_get_TALK_result(&pmdata); |
571 | } else if ((pmdata.data[2] & 0x08) == 0x8) { | | 572 | } else if ((pmdata.data[2] & 0x08) == 0x8) { |
572 | /* PM is requesting to poll */ | | 573 | /* PM is requesting to poll */ |
573 | pm_adb_poll_next_device_pm1(&pmdata); | | 574 | pm_adb_poll_next_device_pm1(&pmdata); |
574 | } else if ((pmdata.data[2] & 0x04) == 0x4) { | | 575 | } else if ((pmdata.data[2] & 0x04) == 0x4) { |
575 | /* ADB device event */ | | 576 | /* ADB device event */ |
576 | pm_adb_get_ADB_data(&pmdata); | | 577 | pm_adb_get_ADB_data(&pmdata); |
577 | } | | 578 | } |
| @@ -811,26 +812,27 @@ pm_intr_pm2(void *arg) | | | @@ -811,26 +812,27 @@ pm_intr_pm2(void *arg) |
811 | PM_VIA_CLR_INTR(); /* clear VIA1 interrupt */ | | 812 | PM_VIA_CLR_INTR(); /* clear VIA1 interrupt */ |
812 | /* ask PM what happened */ | | 813 | /* ask PM what happened */ |
813 | pmdata.command = 0x78; | | 814 | pmdata.command = 0x78; |
814 | pmdata.num_data = 0; | | 815 | pmdata.num_data = 0; |
815 | pmdata.s_buf = &pmdata.data[2]; | | 816 | pmdata.s_buf = &pmdata.data[2]; |
816 | pmdata.r_buf = &pmdata.data[2]; | | 817 | pmdata.r_buf = &pmdata.data[2]; |
817 | rval = pm_pmgrop_pm2(&pmdata); | | 818 | rval = pm_pmgrop_pm2(&pmdata); |
818 | if (rval != 0) { | | 819 | if (rval != 0) { |
819 | #ifdef ADB_DEBUG | | 820 | #ifdef ADB_DEBUG |
820 | if (adb_debug) | | 821 | if (adb_debug) |
821 | printf("pm: PM is not ready. error code: %08x\n", rval); | | 822 | printf("pm: PM is not ready. error code: %08x\n", rval); |
822 | #endif | | 823 | #endif |
823 | splx(s); | | 824 | splx(s); |
| | | 825 | return; |
824 | } | | 826 | } |
825 | | | 827 | |
826 | switch ((u_int)(pmdata.data[2] & 0xff)) { | | 828 | switch ((u_int)(pmdata.data[2] & 0xff)) { |
827 | case 0x00: /* 1 sec interrupt? */ | | 829 | case 0x00: /* 1 sec interrupt? */ |
828 | break; | | 830 | break; |
829 | case 0x80: /* 1 sec interrupt? */ | | 831 | case 0x80: /* 1 sec interrupt? */ |
830 | pm_counter++; | | 832 | pm_counter++; |
831 | break; | | 833 | break; |
832 | case 0x08: /* Brightness/Contrast button on LCD panel */ | | 834 | case 0x08: /* Brightness/Contrast button on LCD panel */ |
833 | /* get brightness and contrast of the LCD */ | | 835 | /* get brightness and contrast of the LCD */ |
834 | pm_LCD_brightness = (u_int)pmdata.data[3] & 0xff; | | 836 | pm_LCD_brightness = (u_int)pmdata.data[3] & 0xff; |
835 | pm_LCD_contrast = (u_int)pmdata.data[4] & 0xff; | | 837 | pm_LCD_contrast = (u_int)pmdata.data[4] & 0xff; |
836 | /* | | 838 | /* |