On Tue, May 03, 2011 at 08:11:52AM +0530, Martin Pieuchot wrote:
> On macppc, the pm_* methods are always attached to a PMU (or PMU99), so
> no need to check for hardware.
> 
> Tested here with a powerbook6,5.
> 
> Ok?
This appears to be working fine on my PowerBook4,1 (ibook g3), will do more
testing tomorrow if needed. There's no dmesg change.

[ using 481912 bytes of bsd ELF symbol table ]
console out [ATY,RageM3p29s]console in [keyboard] , using ADB
: memaddr 94000000 size 4000000, : consaddr 96008000, : ioaddr 90020000, size 
20000: memtag 8000, iotag 8000: width 1024 linebytes 1024 height 768 depth 8
Copyright (c) 1982, 1986, 1989, 1991, 1993
        The Regents of the University of California.  All rights reserved.
Copyright (c) 1995-2011 OpenBSD. All rights reserved.  http://www.OpenBSD.org

OpenBSD 4.9-current (GENERIC) #0: Tue Oct  5 17:18:42 CEST 2010
    jasper@cupertino:/usr/src/sys/arch/macppc/compile/GENERIC
real mem = 402653184 (384MB)
avail mem = 376979456 (359MB)
mainbus0 at root: model PowerBook4,1
cpu0 at mainbus0: 750 (Revision 0x3311): 600 MHz: 256KB backside cache
mem0 at mainbus0
spdmem0 at mem0: SDRAM non-parity PC66
spdmem1 at mem0: 256MB SDRAM non-parity PC100CL2
memc0 at mainbus0: uni-n
kiic0 at memc0 offset 0xf8001000
iic0 at kiic0
mpcpcibr0 at mainbus0 pci: uni-north, Revision 0xff
pci0 at mpcpcibr0 bus 0
pchb0 at pci0 dev 11 function 0 "Apple Pangea AGP" rev 0x00
vgafb0 at pci0 dev 16 function 0 "ATI Mobility M3" rev 0x02, mmio
wsdisplay0 at vgafb0 mux 1: console (std, vt100 emulation)
mpcpcibr1 at mainbus0 pci: uni-north, Revision 0x0
pci1 at mpcpcibr1 bus 0
pchb1 at pci1 dev 11 function 0 "Apple Pangea" rev 0x00
macobio0 at pci1 dev 23 function 0 "Apple Pangea Macio" rev 0x00
openpic0 at macobio0 offset 0x40000: version 0x4614 little endian
macgpio0 at macobio0 offset 0x50
macgpio1 at macgpio0 irq 47
pgs0 at macgpio0: irq 55
"firewire-linkon" at macgpio0 not configured
"gpio1" at macgpio0 not configured
"gpio9" at macgpio0 not configured
"extint-gpio4" at macgpio0 not configured
"extint-gpio12" at macgpio0 not configured
"escc-legacy" at macobio0 offset 0x12000 not configured
zsc0 at macobio0 offset 0x13000: irq 22,23
zstty0 at zsc0 channel 0
zstty1 at zsc0 channel 1
tumbler0 at macobio0 offset 0x10000: irq 30,1,2
"timer" at macobio0 offset 0x15000 not configured
adb0 at macobio0 offset 0x16000 irq 25: via-pmu, 3 targets
akbd0 at adb0 addr 2: PowerBook G4 keyboard (Inverted T)
wskbd0 at akbd0: console keyboard, using wsdisplay0
ams0 at adb0 addr 3: EMP trackpad <tpad> 2-button, 400 dpi
wsmouse0 at ams0 mux 0
abtn0 at adb0 addr 7: brightness/volume/eject buttons
apm0 at adb0: battery flags 0x5, 7% charged
"battery" at macobio0 offset 0x0 not configured
"backlight" at macobio0 offset 0xf300 not configured
kiic1 at macobio0 offset 0x18000
iic1 at kiic1
wdc0 at macobio0 offset 0x1f000 irq 19: DMA
wd0 at wdc0 channel 0 drive 0: <HTS424040M9AT00>
wd0: 16-sector PIO, LBA48, 38154MB, 78140160 sectors
atapiscsi0 at wdc0 channel 0 drive 1
scsibus0 at atapiscsi0: 2 targets
cd0 at scsibus0 targ 0 lun 0: <TOSHIBA, DVD-ROM SD-R2002, 1B29> ATAPI 5/cdrom 
removable
wd0(wdc0:0:0): using PIO mode 4, DMA mode 2
cd0(wdc0:0:1): using PIO mode 4, DMA mode 2
wi0 at macobio0 offset 0x30000 irq 57:
wi0: Firmware 4.16 variant 1, address 00:10:c6:6a:93:64
audio0 at tumbler0
ohci0 at pci1 dev 24 function 0 "Apple Pangea USB" rev 0x00: irq 27, version 1.0
ohci1 at pci1 dev 25 function 0 "Apple Pangea USB" rev 0x00: irq 28, version 1.0
usb0 at ohci0: USB revision 1.0
uhub0 at usb0 "Apple OHCI root hub" rev 1.00/1.00 addr 1
usb1 at ohci1: USB revision 1.0
uhub1 at usb1 "Apple OHCI root hub" rev 1.00/1.00 addr 1
mpcpcibr2 at mainbus0 pci: uni-north, Revision 0x16
pci2 at mpcpcibr2 bus 0
pchb2 at pci2 dev 11 function 0 "Apple Pangea PCI" rev 0x00
"Apple Pangea FireWire" rev 0x00 at pci2 dev 14 function 0 not configured
gem0 at pci2 dev 15 function 0 "Apple Pangea GMAC" rev 0x00: irq 41, address 
00:03:93:62:98:f8
bmtphy0 at gem0 phy 0: BCM5221 100baseTX PHY, rev. 4
vscsi0 at root
scsibus1 at vscsi0: 256 targets
softraid0 at root
bootpath: /pci@f2000000/mac-io@17/ata-4@1f000/disk@0:/bsd
root on wd0a swap on wd0b dump on wd0b

> Index: dev/adb.c
> ===================================================================
> RCS file: /cvs/src/sys/arch/macppc/dev/adb.c,v
> retrieving revision 1.29
> diff -u -p -r1.29 adb.c
> --- dev/adb.c 1 Feb 2009 17:04:26 -0000       1.29
> +++ dev/adb.c 3 May 2011 02:27:28 -0000
> @@ -1307,7 +1307,6 @@ adb_setup_hw_type(void)
>  
>       case ADB_HW_PMU:
>               adbSoftPower = 1;
> -             pm_setup_adb();
>               return;
>  
>       default:
> Index: dev/pm_direct.c
> ===================================================================
> RCS file: /cvs/src/sys/arch/macppc/dev/pm_direct.c,v
> retrieving revision 1.22
> diff -u -p -r1.22 pm_direct.c
> --- dev/pm_direct.c   18 Feb 2007 19:33:48 -0000      1.22
> +++ dev/pm_direct.c   3 May 2011 02:27:28 -0000
> @@ -54,10 +54,6 @@
>  /* hardware dependent values */
>  #define ADBDelay 100         /* XXX */
>  
> -/* define the types of the Power Manager */
> -#define PM_HW_UNKNOWN                0x00    /* don't know */
> -#define      PM_HW_PB5XX             0x02    /* PowerBook Duo and 5XX series 
> */
> -
>  /* useful macros */
>  #define PM_SR()                      read_via_reg(VIA1, vSR)
>  #define PM_VIA_INTR_ENABLE() write_via_reg(VIA1, vIER, 0x90)
> @@ -75,11 +71,6 @@
>  #define PM_IS_OFF            (0x00 == (read_via_reg(VIA2, vBufB) & 0x08))
>  #endif
>  
> -/*
> - * Variables for internal use
> - */
> -int  pmHardware = PM_HW_UNKNOWN;
> -
>  /* these values shows that number of data returned after 'send' cmd is sent 
> */
>  signed char pm_send_cmd_type[] = {
>         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
> @@ -164,12 +155,8 @@ void     pm_printerr(char *, int, int, char 
>  
>  int  pm_wait_busy(int);
>  int  pm_wait_free(int);
> -
> -/* these functions are for the PB Duo series and the PB 5XX series */
> -int  pm_receive_pm2(u_char *);
> -int  pm_send_pm2(u_char);
> -int  pm_pmgrop_pm2(PMData *);
> -void pm_intr_pm2(void);
> +int  pm_receive(u_char *);
> +int  pm_send(u_char);
>  
>  /* these functions also use the variables of adb_direct.c */
>  void pm_adb_get_TALK_result(PMData *);
> @@ -221,18 +208,6 @@ pm_printerr(ttl, rval, num, data)
>  }
>  #endif
>  
> -
> -
> -/*
> - * Check the hardware type of the Power Manager
> - */
> -void
> -pm_setup_adb()
> -{
> -     pmHardware = PM_HW_PB5XX;       /* XXX */
> -}
> -
> -
>  /*
>   * Wait until PM IC is busy
>   */
> @@ -274,7 +249,7 @@ pm_wait_free(int delay)
>   * Receive data from PM for the PB Duo series and the PB 5XX series
>   */
>  int
> -pm_receive_pm2(u_char *data)
> +pm_receive(u_char *data)
>  {
>       int i;
>       int rval;
> @@ -313,7 +288,7 @@ pm_receive_pm2(u_char *data)
>   * Send data to PM for the PB Duo series and the PB 5XX series
>   */
>  int
> -pm_send_pm2(data)
> +pm_send(data)
>       u_char data;
>  {
>       int rval;
> @@ -346,7 +321,7 @@ pm_send_pm2(data)
>   * My PMgrOp routine for the PB Duo series and the PB 5XX series
>   */
>  int
> -pm_pmgrop_pm2(PMData *pmdata)
> +pmgrop(PMData *pmdata)
>  {
>       int i;
>       int s;
> @@ -376,20 +351,20 @@ pm_pmgrop_pm2(PMData *pmdata)
>                       break;                  /* timeout */
>  
>               /* send PM command */
> -             if ((rval = pm_send_pm2((u_char)(pm_cmd & 0xff))))
> +             if ((rval = pm_send((u_char)(pm_cmd & 0xff))))
>                       break;                          /* timeout */
>  
>               /* send number of PM data */
>               num_pm_data = pmdata->num_data;
>               if (pm_send_cmd_type[pm_cmd] < 0) {
> -                     if ((rval = pm_send_pm2((u_char)(num_pm_data & 0xff))) 
> != 0)
> +                     if ((rval = pm_send((u_char)(num_pm_data & 0xff))) != 0)
>                               break;          /* timeout */
>                       pmdata->command = 0;
>               }
>               /* send PM data */
>               pm_buf = (u_char *)pmdata->s_buf;
>               for (i = 0 ; i < num_pm_data; i++)
> -                     if ((rval = pm_send_pm2(pm_buf[i])) != 0)
> +                     if ((rval = pm_send(pm_buf[i])) != 0)
>                               break;                  /* timeout */
>               if (i != num_pm_data)
>                       break;                          /* timeout */
> @@ -407,7 +382,7 @@ pm_pmgrop_pm2(PMData *pmdata)
>               pm_data = pmdata->command;
>               pm_num_rx_data--;
>               if (pm_num_rx_data == 0)
> -                     if ((rval = pm_receive_pm2(&pm_data)) != 0) {
> +                     if ((rval = pm_receive(&pm_data)) != 0) {
>                               rval = 0xffffcd37;
>                               break;
>                       }
> @@ -415,7 +390,7 @@ pm_pmgrop_pm2(PMData *pmdata)
>  
>               /* receive number of PM data */
>               if (pm_num_rx_data < 0) {
> -                     if ((rval = pm_receive_pm2(&pm_data)) != 0)
> +                     if ((rval = pm_receive(&pm_data)) != 0)
>                               break;          /* timeout */
>                       num_pm_data = pm_data;
>               } else
> @@ -425,7 +400,7 @@ pm_pmgrop_pm2(PMData *pmdata)
>               /* receive PM data */
>               pm_buf = (u_char *)pmdata->r_buf;
>               for (i = 0; i < num_pm_data; i++) {
> -                     if ((rval = pm_receive_pm2(&pm_data)) != 0)
> +                     if ((rval = pm_receive(&pm_data)) != 0)
>                               break;                  /* timeout */
>                       pm_buf[i] = pm_data;
>               }
> @@ -445,7 +420,7 @@ pm_pmgrop_pm2(PMData *pmdata)
>   * My PM interrupt routine for the PB Duo series and the PB 5XX series
>   */
>  void
> -pm_intr_pm2()
> +pm_intr()
>  {
>       int s;
>       int rval;
> @@ -459,7 +434,7 @@ pm_intr_pm2()
>       pmdata.num_data = 0;
>       pmdata.s_buf = &pmdata.data[2];
>       pmdata.r_buf = &pmdata.data[2];
> -     rval = pm_pmgrop_pm2(&pmdata);
> +     rval = pmgrop(&pmdata);
>       if (rval != 0) {
>  #ifdef ADB_DEBUG
>               if (adb_debug)
> @@ -498,40 +473,6 @@ pm_intr_pm2()
>  
>       splx(s);
>  }
> -
> -
> -/*
> - * My PMgrOp routine
> - */
> -int
> -pmgrop(PMData *pmdata)
> -{
> -     switch (pmHardware) {
> -     case PM_HW_PB5XX:
> -             return (pm_pmgrop_pm2(pmdata));
> -     default:
> -             /* return (pmgrop_mrg(pmdata)); */
> -             return 1;
> -     }
> -}
> -
> -
> -/*
> - * My PM interrupt routine
> - */
> -void
> -pm_intr()
> -{
> -     switch (pmHardware) {
> -     case PM_HW_PB5XX:
> -             pm_intr_pm2();
> -             break;
> -     default:
> -             break;
> -     }
> -}
> -
> -
>  
>  /*
>   * Synchronous ADBOp routine for the Power Manager
> Index: dev/pm_direct.h
> ===================================================================
> RCS file: /cvs/src/sys/arch/macppc/dev/pm_direct.h,v
> retrieving revision 1.11
> diff -u -p -r1.11 pm_direct.h
> --- dev/pm_direct.h   18 Feb 2007 19:33:48 -0000      1.11
> +++ dev/pm_direct.h   3 May 2011 02:27:28 -0000
> @@ -54,7 +54,6 @@ void        pm_adb_poweroff(void);
>  void pm_intr(void);
>  void pm_read_date_time(time_t *);
>  void pm_set_date_time(time_t);
> -void pm_setup_adb(void);
>  
>  struct pmu_battery_info
>  {
> 

-- 
Cheers,
Jasper

"Capable, generous men do not create victims, they nurture them."

Reply via email to