LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* Re: io.h question
From: Andrei Konovalov @ 2006-01-05 23:54 UTC (permalink / raw)
  To: mcnernbm; +Cc: linuxppc-embedded
In-Reply-To: <OF4583615F.8ED595CE-ON852570ED.00736A17-852570ED.00736A1D@notes.udayton.edu>

Brett,

Is your program a kernel module?
asm/io.h is for kernel only (everything is inside #ifdef __KERNEL__ ... #endif)
Probably you build the module incorrectly so that __KERNEL__ is not defined.
If this is the case you may want to check the LDD book, chapter 2 "Building and
Running Modules".

Thanks,
Andrei

mcnernbm@notes.udayton.edu wrote:
> I finally noticed out_8 and in_8 and what not are located in the ppc 
> io.h file in the kernel development download.  But when I tried to do a 
> io.h with in my program I added #include <asm/io.h>  and it seems to 
> find it with not problems but it can not find the functions with in that 
> file.  Am i missing a define I need to set or something so I can see the 
> right files with in io.h I am compiling for a ppc405 on a xilinx virtex 
> 4 board.
> Thanks
> Brett
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Linuxppc-embedded mailing list
> Linuxppc-embedded@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-embedded

^ permalink raw reply

* Re: Cardmgr Prism Problem
From: Marcelo Tosatti @ 2006-01-08 15:59 UTC (permalink / raw)
  To: Miguel Bello; +Cc: linuxppc-embedded
In-Reply-To: <43BFE6A7.90809@tcc.com.pe>

On Sat, Jan 07, 2006 at 11:04:55AM -0500, Miguel Bello wrote:
> We have a TQMxxL board with ppcboot 1.1.5, kernel 2.4.25 and a ramdisk.
> I would like to setup a wireless link with WPA protocol (hostap driver
> and wpa_supplicant client). We are testing 2 cards: Netgear MA401 and
> Linksys WPC11 v3, both with prism chipset.
> 
> When I execute cardmgr, I get the kernel error message attached below.
> With others cards with no prism chipset, like YDI Diamond, YDI Sapphire
> or Cisco Airnet 350, I have no problem, the cardmgr recognize them.
> But I need to use the hostap driver with prism chipset cards
> (Please take note that with kernel 2.4.4 the cardmgr recognize the
> Netgear MA401, for instance)
> 
> If anyone has a clue to what I'm doing wrong, I'd appreciate it.
> 
> Best Regards
> 
> Miguel Bello
> 
> ====================================================================0
> 
> PPCBoot 1.1.5 (Sep  6 2004 - 13:09:55)
> 
> CPU:   PPC823EZTnnB2 at 50 MHz: 16 kB I-Cache 8 kB D-Cache
> Board: ### No HW ID - assuming TQM8xxL
> DRAM:  16 MB
> FLASH:  8 MB
> In:    serial
> Out:   lcd
> Err:   lcd
> Linux version 2.4.25 (root@desarrollo) (gcc version 2.95.2 19991024
> (release)) #18 Fri Jan 6 17:45:37 PET 2006
> MPC823 LCD memory at C01BE000
> On node 0 totalpages: 4096
> zone(0): 4096 pages.
> zone(1): 0 pages.
> zone(2): 0 pages.
> Kernel command line: root=/dev/ram/ rw
> ip=192.168.0.115:::255.255.255.0:::off panic=1
> Decrementer Frequency = 187500000/60
> Console: colour dummy device 80x25
> Calibrating delay loop... 49.86 BogoMIPS
> Memory: 12852k available (1240k kernel code, 436k data, 76k init, 0k
> highmem)
> Dentry cache hash table entries: 2048 (order: 2, 16384 bytes)
> Inode cache hash table entries: 1024 (order: 1, 8192 bytes)
> Mount cache hash table entries: 512 (order: 0, 4096 bytes)
> Buffer cache hash table entries: 1024 (order: 0, 4096 bytes)
> Page-cache hash table entries: 4096 (order: 2, 16384 bytes)
> POSIX conformance testing by UNIFIX
> Linux NET4.0 for Linux 2.4
> Based upon Swansea University Computer Society NET3.039
> Initializing RT netlink socket
> Starting kswapd
> JFFS version 1.0, (C) 1999, 2000  Axis Communications AB
> JFFS2 version 2.2. (NAND) (C) 2001-2003 Red Hat, Inc.
> Console: switching to colour frame buffer device 80x30
> fb0: MPC823 LCD frame buffer device
> CPM UART driver version 0.04
> ttyS0 at 0x0280 is on SMC1 using BRG1
> ttyS1 at 0x0380 is on SMC2 using BRG2
> pty: 256 Unix98 ptys configured
> Found 2x16bit 4MByte CFI flash device of type AMD/Fujitsu standard at
> 40000000
> Registered flash device /dev/flasha (minor 0, 4 partitions)
> Found 2x16bit 4MByte CFI flash device of type AMD/Fujitsu standard at
> 40400000
> Registered flash device /dev/flashb (minor 8, 2 partitions)
> eth0: CPM ENET Version 0.2 on SCC2, 00:d0:93:00:05:4c
> RAMDISK driver initialized: 16 RAM disks of 5120K size 1024 blocksize
> init_tqm_mtd: chip probing count 0
> TQM8xxL-0: Found 2 x16 devices at 0x0 in 32-bit bank
> TQM8xxL-0: Found 2 x16 devices at 0x400000 in 32-bit bank
> Amd/Fujitsu Extended Query Table at 0x0040
> number of CFI chips: 2
> cfi_cmdset_0002: Disabling erase-suspend-program due to code brokenness.
> init_tqm_mtd: bank1, name:TQM8xxL-0, size:8388608bytes
> TQM flash0: Using Static image partition definition
> Creating 7 MTD partitions on "TQM8xxL-0":
> 0x00000000-0x00040000 : "u-boot"
> 0x00040000-0x00100000 : "kernel"
> 0x00100000-0x00200000 : "user"
> 0x00200000-0x00400000 : "initrd"
> 0x00400000-0x00600000 : "cramfs"
> 0x00600000-0x00800000 : "jffs"
> 0x00400000-0x00800000 : "big_fs"
> Linux Kernel Card Services 3.1.22
> options:  none
> m8xx_pcmcia: Version 0.05, 14-Apr-2002
> m8xx_pcmcia: TQM8xxL using SLOT_B with IRQ 13.
> NET4: Linux TCP/IP 1.0 for NET4.0
> IP Protocols: ICMP, UDP, TCP
> IP: routing cache hash table of 512 buckets, 4Kbytes
> TCP: Hash tables configured (established 1024 bind 1024)
> IP-Config: Complete:
>     device=eth0, addr=192.168.0.115, mask=255.255.255.0,
> gw=255.255.255.255,
>    host=192.168.0.115, domain=, nis-domain=(none),
>    bootserver=255.255.255.255, rootserver=255.255.255.255, rootpath=
> NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
> RAMDISK: Compressed image found at block 0
> Freeing initrd memory: 1260k freed
> EXT2-fs warning: checktime reached, running e2fsck is recommended
> VFS: Mounted root (ext2 filesystem).
> Freeing unused kernel memory: 76k init
> init started:  BusyBox v0.51 (2005.12.14-06:57+0000) multi-call bi
> 
> BusyBox v0.51 (2005.12.14-06:57+0000) Built-in shell (lash)
> Enter 'help' for a list of built-in commands.
> 
> / #
> / #
> / # cardmgr
> cardmgr[14]: watching 1 sockets
> / # cardmgr[15]: starting, version is 3.2.1
> Machine check in kernel mode.
> Caused by (from SRR1=9032): Transfer error ack signal
> Oops: machine check, sig: 7
> NIP: C00C4840 XER: 00000000 LR: C00C481C SP: C094FB50 REGS: c094faa0
> TRAP: 0200    Not tainted
> MSR: 00009032 EE: 1 PR: 0 FP: 0 ME: 1 IR/DR: 11
> TASK = c094e000[15] 'cardmgr' Last syscall: 54
> last math 00000000 last altivec 00000000
> GPR00: C30C1000 C094FB50 C094E000 C30C0000 C0158C30 C30C0000 FDFB3000
> 00000000
> GPR08: C30C0000 C30C0000 C0F99000 00001000 84004002 100223D8 00000000
> 00000000
> GPR16: 00000000 00000000 00000000 00000000 00009032 0094FF40 00000000
> C0004768
> GPR24: C00044C0 C094FBBA 00000002 C0FE2844 C094FBBA 00000002 C0FE2800
> 00000000
> Call backtrace:
> C00C481C C00C4EF8 C00C5410 C00C51D8 C00C6B44 C00C9FF4 C0047EDC
> C000451C 00000000 10001A58 100031CC 10004874 0FEA2394 00000000

Please run the oops through ksymoops to transform hex addresses into
function+line. Is it DENX's v2.4.25?

^ permalink raw reply

* port linux to prpmc board
From: siman @ 2006-01-08 15:01 UTC (permalink / raw)
  To: linuxppc-embedded
In-Reply-To: <20060106230403.F1754689EB@ozlabs.org>

Hi Profession:
Who has any experience to port Linux to prpmc610 or the serious system, I
has port the LED light program from vxworks to the Linux system, and run it
on the ppc-bug system. How the Linux system initial to ppc cpu? I also want
to know how the Linux system boot from the ppc architecture system.
Thanks all.
Siman

^ permalink raw reply

* Re: [PATCH] powerpc: Fix PowerMac sound i2c
From: Andreas Schwab @ 2006-01-08 13:30 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev list, linuxppc64-dev
In-Reply-To: <jefynz0zvr.fsf@sykes.suse.de>

Andreas Schwab <schwab@suse.de> writes:

> Benjamin Herrenschmidt <benh@kernel.crashing.org> writes:
>
>> My patch reworking the PowerMac i2c code break the sound drivers as they
>> used to rely on some broken behaviour of i2c-keywest that is gone now.
>
> I'm not sure, but from looking at the other i2c drivers I'd rather think
> that the old behaviour of i2c-keywest was correct.

I have now read the thread on linux-kernel@ and I have to revise my
opinion.  I think I now understand better the difference between smbus and
i2c bus.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply

* Re: [PATCH] powerpc: Fix PowerMac sound i2c
From: Andreas Schwab @ 2006-01-08 10:37 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev list, linuxppc64-dev
In-Reply-To: <1136695956.30123.44.camel@localhost.localdomain>

Benjamin Herrenschmidt <benh@kernel.crashing.org> writes:

> My patch reworking the PowerMac i2c code break the sound drivers as they
> used to rely on some broken behaviour of i2c-keywest that is gone now.

I'm not sure, but from looking at the other i2c drivers I'd rather think
that the old behaviour of i2c-keywest was correct.  There are only a few
that implement both I2C_SMBUS_BLOCK_DATA and I2C_SMBUS_I2C_BLOCK_DATA, but
none of them write the length byte together with the data.  The commands
are ony different in behaviour when reading: with I2C_SMBUS_I2C_BLOCK_DATA
a fixed sized block is read from the bus, whereas with
I2C_SMBUS_BLOCK_DATA the size of the block is variable.  At least that's
how i2c-nforce2, i2c-viapro and i2c-amd8111 implement the commands.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply

* Re: [PATCH] powerpc: Fix PowerMac sound i2c
From: Benjamin Herrenschmidt @ 2006-01-08  6:22 UTC (permalink / raw)
  To: Hollis Blanchard; +Cc: linuxppc64-dev, linuxppc-dev list
In-Reply-To: <fe4d9bc576d696dfea0bc1b2a742307d@penguinppc.org>

On Sat, 2006-01-07 at 22:55 -0600, Hollis Blanchard wrote:
> On Jan 7, 2006, at 10:52 PM, Benjamin Herrenschmidt wrote:
> 
> > +        data.block[0] = len;
> > +	memcpy(&data.block[1], values, len);
> 
> Seem to be mixing tabs and spaces here (in both *_write_block 
> functions).

You mean the patch got mangled or the code is mixing tab/spaces ? I
think the driver was pretty mixed up in the first place, I'll have to
check.

Ben.

^ permalink raw reply

* Re: [PATCH] powerpc: Fix PowerMac sound i2c
From: Hollis Blanchard @ 2006-01-08  4:55 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc64-dev, linuxppc-dev list
In-Reply-To: <1136695956.30123.44.camel@localhost.localdomain>

On Jan 7, 2006, at 10:52 PM, Benjamin Herrenschmidt wrote:

> +        data.block[0] = len;
> +	memcpy(&data.block[1], values, len);

Seem to be mixing tabs and spaces here (in both *_write_block 
functions).

-Hollis

^ permalink raw reply

* [PATCH] powerpc: Fix PowerMac sound i2c
From: Benjamin Herrenschmidt @ 2006-01-08  4:52 UTC (permalink / raw)
  To: linuxppc-dev list, linuxppc64-dev

My patch reworking the PowerMac i2c code break the sound drivers as they
used to rely on some broken behaviour of i2c-keywest that is gone now.
This patch should fix them (tested on a g5 with alsa only). It might
also fix an oops if the alsa driver hits an unsupported chip.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

Index: linux-work/sound/ppc/tumbler.c
===================================================================
--- linux-work.orig/sound/ppc/tumbler.c	2005-11-24 17:19:14.000000000 +1100
+++ linux-work/sound/ppc/tumbler.c	2006-01-08 15:18:09.000000000 +1100
@@ -137,6 +137,22 @@ static int send_init_client(pmac_keywest
 	return 0;
 }
 
+static int tumbler_write_block(struct i2c_client *client, u8 reg, int len,
+			       u8 *values)
+{
+        union i2c_smbus_data data;
+        int err;
+
+        data.block[0] = len;
+	memcpy(&data.block[1], values, len);
+        err = i2c_smbus_xfer(client->adapter, client->addr, client->flags,
+                             I2C_SMBUS_WRITE, reg, I2C_SMBUS_I2C_BLOCK_DATA,
+                             &data);
+        return err;
+}
+
+
+
 
 static int tumbler_init_client(pmac_keywest_t *i2c)
 {
@@ -239,8 +255,7 @@ static int tumbler_set_master_volume(pma
 	block[4] = (right_vol >> 8)  & 0xff;
 	block[5] = (right_vol >> 0)  & 0xff;
   
-	if (i2c_smbus_write_block_data(mix->i2c.client, TAS_REG_VOL,
-				       6, block) < 0) {
+	if (tumbler_write_block(mix->i2c.client, TAS_REG_VOL, 6, block) < 0) {
 		snd_printk("failed to set volume \n");
 		return -EINVAL;
 	}
@@ -340,8 +355,7 @@ static int tumbler_set_drc(pmac_tumbler_
 		val[1] = 0;
 	}
 
-	if (i2c_smbus_write_block_data(mix->i2c.client, TAS_REG_DRC,
-				       2, val) < 0) {
+	if (tumbler_write_block(mix->i2c.client, TAS_REG_DRC, 2, val) < 0) {
 		snd_printk("failed to set DRC\n");
 		return -EINVAL;
 	}
@@ -376,8 +390,7 @@ static int snapper_set_drc(pmac_tumbler_
 	val[4] = 0x60;
 	val[5] = 0xa0;
 
-	if (i2c_smbus_write_block_data(mix->i2c.client, TAS_REG_DRC,
-				       6, val) < 0) {
+	if (tumbler_write_block(mix->i2c.client, TAS_REG_DRC, 6, val) < 0) {
 		snd_printk("failed to set DRC\n");
 		return -EINVAL;
 	}
@@ -481,8 +494,8 @@ static int tumbler_set_mono_volume(pmac_
 	vol = info->table[vol];
 	for (i = 0; i < info->bytes; i++)
 		block[i] = (vol >> ((info->bytes - i - 1) * 8)) & 0xff;
-	if (i2c_smbus_write_block_data(mix->i2c.client, info->reg,
-				       info->bytes, block) < 0) {
+	if (tumbler_write_block(mix->i2c.client, info->reg,
+				  info->bytes, block) < 0) {
 		snd_printk("failed to set mono volume %d\n", info->index);
 		return -EINVAL;
 	}
@@ -611,7 +624,7 @@ static int snapper_set_mix_vol1(pmac_tum
 		for (j = 0; j < 3; j++)
 			block[i * 3 + j] = (vol >> ((2 - j) * 8)) & 0xff;
 	}
-	if (i2c_smbus_write_block_data(mix->i2c.client, reg, 9, block) < 0) {
+	if (tumbler_write_block(mix->i2c.client, reg, 9, block) < 0) {
 		snd_printk("failed to set mono volume %d\n", reg);
 		return -EINVAL;
 	}
Index: linux-work/sound/oss/dmasound/tas_common.h
===================================================================
--- linux-work.orig/sound/oss/dmasound/tas_common.h	2005-11-24 17:19:14.000000000 +1100
+++ linux-work/sound/oss/dmasound/tas_common.h	2006-01-08 15:33:29.000000000 +1100
@@ -157,6 +157,21 @@ tas_mono_to_stereo(uint mono)
 	return mono | (mono<<8);
 }
 
+static int tas_write_block(struct i2c_client *client, u8 reg, int len, u8 *vals)
+{
+        union i2c_smbus_data data;
+        int err;
+
+        data.block[0] = len;
+	memcpy(&data.block[1], vals, len);
+        err = i2c_smbus_xfer(client->adapter, client->addr, client->flags,
+                             I2C_SMBUS_WRITE, reg, I2C_SMBUS_I2C_BLOCK_DATA,
+                             &data);
+        return err;
+}
+
+
+
 /*
  * Todo: make these functions a bit more efficient !
  */
@@ -178,10 +193,8 @@ tas_write_register(	struct tas_data_t *s
 	if (write_mode & WRITE_SHADOW)
 		memcpy(self->shadow[reg_num],data,reg_width);
 	if (write_mode & WRITE_HW) {
-		rc=i2c_smbus_write_block_data(self->client,
-					      reg_num,
-					      reg_width,
-					      data);
+		rc = tas_write_block(self->client, reg_num,
+				     reg_width, data);
 		if (rc < 0) {
 			printk("tas: I2C block write failed \n");  
 			return rc; 
@@ -199,10 +212,8 @@ tas_sync_register(	struct tas_data_t *se
 
 	if (reg_width==0 || self==NULL)
 		return -EINVAL;
-	rc=i2c_smbus_write_block_data(self->client,
-				      reg_num,
-				      reg_width,
-				      self->shadow[reg_num]);
+	rc = tas_write_block(self->client, reg_num,
+			     reg_width, self->shadow[reg_num]);
 	if (rc < 0) {
 		printk("tas: I2C block write failed \n");
 		return rc;
Index: linux-work/sound/ppc/pmac.c
===================================================================
--- linux-work.orig/sound/ppc/pmac.c	2005-12-19 16:13:48.000000000 +1100
+++ linux-work/sound/ppc/pmac.c	2006-01-08 15:37:10.000000000 +1100
@@ -74,7 +74,7 @@ static int snd_pmac_dbdma_alloc(pmac_t *
 
 static void snd_pmac_dbdma_free(pmac_t *chip, pmac_dbdma_t *rec)
 {
-	if (rec) {
+	if (rec->space) {
 		unsigned int rsize = sizeof(struct dbdma_cmd) * (rec->size + 1);
 
 		dma_free_coherent(&chip->pdev->dev, rsize, rec->space, rec->dma_base);
@@ -895,6 +895,7 @@ static int __init snd_pmac_detect(pmac_t
 	chip->can_capture = 1;
 	chip->num_freqs = ARRAY_SIZE(awacs_freqs);
 	chip->freq_table = awacs_freqs;
+	chip->pdev = NULL;
 
 	chip->control_mask = MASK_IEPC | MASK_IEE | 0x11; /* default */
 

^ permalink raw reply

* Questoin about stable kernel version for 405ep
From: 종윤 임 @ 2006-01-07 23:27 UTC (permalink / raw)
  To: linuxppc-embedded

Hi all

I got new projects that porting embedded linux to
405EP.

But i could not find information which linux kernel
version is stable for 405EP.

Please inform to me which version is stable for 405EP.

Thanks




	

	
		
________________________________________________________ 
무료 1GB용량!, 더 이상 용량 고민없는 - 야후! 메일 (http://mail.yahoo.co.kr) 
최신 휴대폰 정보, 벨소리, 캐릭터, 문자메세지 - 야후! 모바일 (http://kr.mobile.yahoo.com) 
야후! 멀티미디어 - 대한민국 멀티미디어의 시작,야미(http://kr.multimedia.yahoo.com)

^ permalink raw reply

* Re: [PATCH] 0/5 powerpc: Platform & i2c updates & cpufreq
From: Benjamin Herrenschmidt @ 2006-01-07 22:09 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: linuxppc-dev list, linuxppc64-dev
In-Reply-To: <jemzi8umx2.fsf@sykes.suse.de>

On Sat, 2006-01-07 at 15:34 +0100, Andreas Schwab wrote:
> Benjamin Herrenschmidt <benh@kernel.crashing.org> writes:
> 
> > This serie of patch replaces the 2 I posted recently for platform
> > functions & g5 cpufreq. It's not a 100% finished job yet but it's
> > getting closer.
> 
> The patch appears to break ALSA on PowerMac Dual 1.8GHz.  The volume
> control is going wild, and I'm getting distorted sound.

Ok, I think it's the sound driver's i2c code relied on a bug in
i2c-keywest that has been fixed by the new i2c driver.

I'll post a fix later today.

Ben.

^ permalink raw reply

* Re: [PATCH] 0/5 powerpc: Platform & i2c updates & cpufreq
From: Benjamin Herrenschmidt @ 2006-01-07 22:04 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: linuxppc-dev list, linuxppc64-dev
In-Reply-To: <jemzi8umx2.fsf@sykes.suse.de>

On Sat, 2006-01-07 at 15:34 +0100, Andreas Schwab wrote:
> Benjamin Herrenschmidt <benh@kernel.crashing.org> writes:
> 
> > This serie of patch replaces the 2 I posted recently for platform
> > functions & g5 cpufreq. It's not a 100% finished job yet but it's
> > getting closer.
> 
> The patch appears to break ALSA on PowerMac Dual 1.8GHz.  The volume
> control is going wild, and I'm getting distorted sound.

Which patch specifically ? I suspect a problem with the keywest i2c
code, I 'll have a look today or tomorrow.

Ben.

^ permalink raw reply

* Re: Booting from RAM Disk
From: David H. Lynch Jr. @ 2006-01-07 20:42 UTC (permalink / raw)
  To: Grant Likely; +Cc: Linuxppc-embedded
In-Reply-To: <43BF5302.4030602@secretlab.ca>

Grant Likely wrote:
> David H. Lynch Jr. wrote:
> 
>>	initramfs does nto exist in 2.4, but despite a dearth of information it
>>works extremely well in 2.6.
>>
>>	Set CONFIG_INITRAMFS=path to directory tree to build into ramdisk, and
>>the kernel building process will take care of most evrything else.
>>Unlike initrd, there are not two separate files, that each have to be
>>loaded. The initial ramdisk is part of the kernel image, gets
>>uncompressed by the kernel, and is just generally painless - except for
>>the scarcity of documentation.
> 
> So... have are been able to use initramfs as a drop in replacement for
> initrd, or did you have to jump through extra hoops?  I attempted to use
> initramfs a few months ago, but wasn't ever able to get it to run init.
> 
> g.
> 

	I can't exactly answer that - While I have used both, The only one I
have actually tried to put onto an embedded system is initramfs.

	I normallly use Debian which puts together an initrd for you fairly easily.
	I used Gentoo on a few systems and it uses initramfs - but it seems to
use it in an odd configuration similair to initrd, where the Ramdisk
image is a separate file.

	I have never tried to build an initrd system.

	I like initramfs - the only problem I had putting it together was
finding the information to do it.

	In the instance of the E12 I needed something that was wrapped into a
single file with the kernl. The E12 already had an elf loader, but all
it did was load elf files. It did not handle ramdisk other images etc.
INITRAMFS provided a means to start on the E12 without having to write
another loader.

^ permalink raw reply

* Re: How to build the zImage.prep was Re: Bug#345424 acknowledged by developer         (Bug#345424: fixed in linux-2.6 2.6.15-1)
From: Sebastian Heutling @ 2006-01-07 19:55 UTC (permalink / raw)
  To: Grant Likely; +Cc: Paul Mackerras, Paul Janzen, linuxppc-embedded
In-Reply-To: <43BF42AA.8030906@secretlab.ca>

Grant Likely wrote:
> Paul Janzen wrote:
> 
>>grant.likely at secretlab.ca (Grant Likely) writes:
>>
>>
>>
>>>Have you tried 2.6.14?  I'm having a similar issue with PReP images
>>>using QEMU.  2.6.14 works, but 2.6.15 is busted.  It *might* be the same
>>>issue.
>>>
>>>http://ozlabs.org/pipermail/linuxppc-dev/2005-December/020782.html
>>>
>>>I was able to use git-bisect to narrow it down to 20 or so changes, but
>>>I didn't get any farther.
>>
>>
>>This *might* be the problem described in: 
>>
>>http://ozlabs.org/pipermail/linuxppc-embedded/2006-January/021550.html
>>
>>It matches the git-bisect ID's you narrowed it down to, and it matches
>>the problem report.  I'm just not sure if it matches the environment
>>you're running in. 
> 
> 
> Yes, that's exactly it.  QEMU boots prep images again with that patch.
> Thank you.
> 
> g.
> 

Great! :)


Sebastian

^ permalink raw reply

* Cardmgr Prism Problem
From: Miguel Bello @ 2006-01-07 16:04 UTC (permalink / raw)
  To: linuxppc-embedded

[-- Attachment #1: Type: text/plain, Size: 7890 bytes --]

We have a TQMxxL board with ppcboot 1.1.5, kernel 2.4.25 and a ramdisk.
I would like to setup a wireless link with WPA protocol (hostap driver
and wpa_supplicant client). We are testing 2 cards: Netgear MA401 and
Linksys WPC11 v3, both with prism chipset.

When I execute cardmgr, I get the kernel error message attached below.
With others cards with no prism chipset, like YDI Diamond, YDI Sapphire
or Cisco Airnet 350, I have no problem, the cardmgr recognize them.
But I need to use the hostap driver with prism chipset cards
(Please take note that with kernel 2.4.4 the cardmgr recognize the
Netgear MA401, for instance)

If anyone has a clue to what I'm doing wrong, I'd appreciate it.

Best Regards

Miguel Bello

====================================================================0

PPCBoot 1.1.5 (Sep  6 2004 - 13:09:55)

CPU:   PPC823EZTnnB2 at 50 MHz: 16 kB I-Cache 8 kB D-Cache
Board: ### No HW ID - assuming TQM8xxL
DRAM:  16 MB
FLASH:  8 MB
In:    serial
Out:   lcd
Err:   lcd
Linux version 2.4.25 (root@desarrollo) (gcc version 2.95.2 19991024
(release)) #18 Fri Jan 6 17:45:37 PET 2006
MPC823 LCD memory at C01BE000
On node 0 totalpages: 4096
zone(0): 4096 pages.
zone(1): 0 pages.
zone(2): 0 pages.
Kernel command line: root=/dev/ram/ rw
ip=192.168.0.115:::255.255.255.0:::off panic=1
Decrementer Frequency = 187500000/60
Console: colour dummy device 80x25
Calibrating delay loop... 49.86 BogoMIPS
Memory: 12852k available (1240k kernel code, 436k data, 76k init, 0k
highmem)
Dentry cache hash table entries: 2048 (order: 2, 16384 bytes)
Inode cache hash table entries: 1024 (order: 1, 8192 bytes)
Mount cache hash table entries: 512 (order: 0, 4096 bytes)
Buffer cache hash table entries: 1024 (order: 0, 4096 bytes)
Page-cache hash table entries: 4096 (order: 2, 16384 bytes)
POSIX conformance testing by UNIFIX
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039
Initializing RT netlink socket
Starting kswapd
JFFS version 1.0, (C) 1999, 2000  Axis Communications AB
JFFS2 version 2.2. (NAND) (C) 2001-2003 Red Hat, Inc.
Console: switching to colour frame buffer device 80x30
fb0: MPC823 LCD frame buffer device
CPM UART driver version 0.04
ttyS0 at 0x0280 is on SMC1 using BRG1
ttyS1 at 0x0380 is on SMC2 using BRG2
pty: 256 Unix98 ptys configured
Found 2x16bit 4MByte CFI flash device of type AMD/Fujitsu standard at
40000000
Registered flash device /dev/flasha (minor 0, 4 partitions)
Found 2x16bit 4MByte CFI flash device of type AMD/Fujitsu standard at
40400000
Registered flash device /dev/flashb (minor 8, 2 partitions)
eth0: CPM ENET Version 0.2 on SCC2, 00:d0:93:00:05:4c
RAMDISK driver initialized: 16 RAM disks of 5120K size 1024 blocksize
init_tqm_mtd: chip probing count 0
TQM8xxL-0: Found 2 x16 devices at 0x0 in 32-bit bank
TQM8xxL-0: Found 2 x16 devices at 0x400000 in 32-bit bank
Amd/Fujitsu Extended Query Table at 0x0040
number of CFI chips: 2
cfi_cmdset_0002: Disabling erase-suspend-program due to code brokenness.
init_tqm_mtd: bank1, name:TQM8xxL-0, size:8388608bytes
TQM flash0: Using Static image partition definition
Creating 7 MTD partitions on "TQM8xxL-0":
0x00000000-0x00040000 : "u-boot"
0x00040000-0x00100000 : "kernel"
0x00100000-0x00200000 : "user"
0x00200000-0x00400000 : "initrd"
0x00400000-0x00600000 : "cramfs"
0x00600000-0x00800000 : "jffs"
0x00400000-0x00800000 : "big_fs"
Linux Kernel Card Services 3.1.22
 options:  none
m8xx_pcmcia: Version 0.05, 14-Apr-2002
m8xx_pcmcia: TQM8xxL using SLOT_B with IRQ 13.
NET4: Linux TCP/IP 1.0 for NET4.0
IP Protocols: ICMP, UDP, TCP
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP: Hash tables configured (established 1024 bind 1024)
IP-Config: Complete:
     device=eth0, addr=192.168.0.115, mask=255.255.255.0,
gw=255.255.255.255,
    host=192.168.0.115, domain=, nis-domain=(none),
    bootserver=255.255.255.255, rootserver=255.255.255.255, rootpath=
NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
RAMDISK: Compressed image found at block 0
Freeing initrd memory: 1260k freed
EXT2-fs warning: checktime reached, running e2fsck is recommended
VFS: Mounted root (ext2 filesystem).
Freeing unused kernel memory: 76k init
init started:  BusyBox v0.51 (2005.12.14-06:57+0000) multi-call bi

BusyBox v0.51 (2005.12.14-06:57+0000) Built-in shell (lash)
Enter 'help' for a list of built-in commands.

/ #
/ #
/ # cardmgr
cardmgr[14]: watching 1 sockets
/ # cardmgr[15]: starting, version is 3.2.1
Machine check in kernel mode.
Caused by (from SRR1=9032): Transfer error ack signal
Oops: machine check, sig: 7
NIP: C00C4840 XER: 00000000 LR: C00C481C SP: C094FB50 REGS: c094faa0
TRAP: 0200    Not tainted
MSR: 00009032 EE: 1 PR: 0 FP: 0 ME: 1 IR/DR: 11
TASK = c094e000[15] 'cardmgr' Last syscall: 54
last math 00000000 last altivec 00000000
GPR00: C30C1000 C094FB50 C094E000 C30C0000 C0158C30 C30C0000 FDFB3000
00000000
GPR08: C30C0000 C30C0000 C0F99000 00001000 84004002 100223D8 00000000
00000000
GPR16: 00000000 00000000 00000000 00000000 00009032 0094FF40 00000000
C0004768
GPR24: C00044C0 C094FBBA 00000002 C0FE2844 C094FBBA 00000002 C0FE2800
00000000
Call backtrace:
C00C481C C00C4EF8 C00C5410 C00C51D8 C00C6B44 C00C9FF4 C0047EDC
C000451C 00000000 10001A58 100031CC 10004874 0FEA2394 00000000

/ #

CONFIG_RWSEM_XCHGADD_ALGORITHM=y
CONFIG_HAVE_DEC_LOCK=y
CONFIG_EXPERIMENTAL=y
CONFIG_MODULES=y
CONFIG_KMOD=y
CONFIG_PPC=y
CONFIG_PPC32=y
CONFIG_8xx=y
CONFIG_SERIAL_CONSOLE=y
CONFIG_NOT_COHERENT_CACHE=y
CONFIG_TQM823L=y
CONFIG_MATH_EMULATION=y
CONFIG_EMBEDDEDBOOT=y
CONFIG_HIGHMEM_START=0xfe000000
CONFIG_LOWMEM_SIZE=0x30000000
CONFIG_KERNEL_START=0xc0000000
CONFIG_TASK_SIZE=0x80000000
CONFIG_NET=y
CONFIG_SYSCTL=y
CONFIG_SYSVIPC=y
CONFIG_KCORE_ELF=y
CONFIG_BINFMT_ELF=y
CONFIG_KERNEL_ELF=y
CONFIG_HOTPLUG=y
CONFIG_PCMCIA=y
CONFIG_PCMCIA_M8XX=y
CONFIG_MTD=y
CONFIG_MTD_PARTITIONS=y
CONFIG_MTD_CMDLINE_PARTS=y
CONFIG_MTD_CHAR=y
CONFIG_MTD_BLOCK=y
CONFIG_MTD_CFI=y
CONFIG_MTD_GEN_PROBE=y
CONFIG_MTD_MAP_BANK_WIDTH_1=y
CONFIG_MTD_MAP_BANK_WIDTH_2=y
CONFIG_MTD_MAP_BANK_WIDTH_4=y
CONFIG_MTD_CFI_I1=y
CONFIG_MTD_CFI_I2=y
CONFIG_MTD_CFI_AMDSTD=y
CONFIG_MTD_CFI_UTIL=y
CONFIG_MTD_ROM=y
CONFIG_MTD_TQM8XXL=y
CONFIG_BLK_DEV_RAM=y
CONFIG_BLK_DEV_RAM_SIZE=5120
CONFIG_BLK_DEV_INITRD=y
CONFIG_PACKET=y
CONFIG_NETLINK_DEV=y
CONFIG_UNIX=y
CONFIG_INET=y
CONFIG_IP_PNP=y
CONFIG_IPV6_SCTP__=y
CONFIG_NETDEVICES=y
CONFIG_NET_ETHERNET=y
CONFIG_NET_RADIO=y
CONFIG_HERMES=m
CONFIG_HOSTAP=m
CONFIG_PCMCIA_HERMES=m
CONFIG_HOSTAP_CS=m
CONFIG_AIRO_CS=m
CONFIG_NET_WIRELESS=y
CONFIG_NET_PCMCIA=y
CONFIG_NET_PCMCIA_RADIO=y
CONFIG_FB=y
CONFIG_DUMMY_CONSOLE=y
CONFIG_FB_8xx_LCD=y
CONFIG_PRIMEVIEW_V16C6448AC=y
CONFIG_FB_8xx_PRE_INIT_FB=y
CONFIG_INVERSE_VIDEO=y
CONFIG_FBCON_ADVANCED=y
CONFIG_FBCON_CFB8=y
CONFIG_FBCON_FONTS=y
CONFIG_FONT_8x8=y
CONFIG_FONT_8x16=y
CONFIG_VT=y
CONFIG_CONSOLE_NOBLANK=y
CONFIG_CONSOLE_NOCUR=y
CONFIG_UNIX98_PTYS=y
CONFIG_UNIX98_PTY_COUNT=32
CONFIG_RTC_8XX=y
CONFIG_FLASH=y
CONFIG_AMD_FLASH=y
CONFIG_FAT_FS=y
CONFIG_MSDOS_FS=y
CONFIG_VFAT_FS=y
CONFIG_JFFS_FS=y
CONFIG_JFFS_FS_VERBOSE=0
CONFIG_JFFS2_FS=y
CONFIG_JFFS2_FS_DEBUG=0
CONFIG_JFFS2_FS_WRITEBUFFER=y
CONFIG_JFFS2_ZLIB=y
CONFIG_JFFS2_RTIME=y
CONFIG_JFFS2_CMODE_PRIORITY=y
CONFIG_JFFS2_PROC=y
CONFIG_CRAMFS=y
CONFIG_TMPFS=y
CONFIG_RAMFS=y
CONFIG_PROC_FS=y
CONFIG_DEVPTS_FS=y
CONFIG_EXT2_FS=y
CONFIG_PARTITION_ADVANCED=y
CONFIG_MSDOS_PARTITION=y
CONFIG_NLS=y
CONFIG_NLS_DEFAULT="iso8859-1"
CONFIG_NLS_ISO8859_1=y
CONFIG_NLS_ISO8859_15=y
CONFIG_8xx_COPYBACK=y
CONFIG_SCC_ENET=y
CONFIG_SCC2_ENET=y
CONFIG_ENET_BIG_BUFFERS=y
CONFIG_8xx_SMC1=y
CONFIG_8xx_SMC1_RX_BDNUM=4
CONFIG_8xx_SMC1_RX_BDSIZE=32
CONFIG_8xx_SMC1_TX_BDNUM=4
CONFIG_8xx_SMC1_TX_BDSIZE=32
CONFIG_8xx_SMC2=y
CONFIG_ALTSMC2=y
CONFIG_8xx_SMC2_MAXIDL=1
CONFIG_8xx_SMC2_RX_BDNUM=4
CONFIG_8xx_SMC2_RX_BDSIZE=32
CONFIG_8xx_SMC2_TX_BDNUM=4
CONFIG_8xx_SMC2_TX_BDSIZE=32
CONFIG_ZLIB_INFLATE=y
CONFIG_ZLIB_DEFLATE=y
CONFIG_LOG_BUF_SHIFT=0


[-- Attachment #2: Type: text/html, Size: 8239 bytes --]

^ permalink raw reply

* Re: [PATCH] 0/5 powerpc: Platform & i2c updates & cpufreq
From: Andreas Schwab @ 2006-01-07 14:34 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev list, linuxppc64-dev
In-Reply-To: <1136593470.4840.154.camel@localhost.localdomain>

Benjamin Herrenschmidt <benh@kernel.crashing.org> writes:

> This serie of patch replaces the 2 I posted recently for platform
> functions & g5 cpufreq. It's not a 100% finished job yet but it's
> getting closer.

The patch appears to break ALSA on PowerMac Dual 1.8GHz.  The volume
control is going wild, and I'm getting distorted sound.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply

* FEC       CONFIG_FEC_PACKETHOOK
From: feng @ 2006-01-07  8:31 UTC (permalink / raw)
  To: linuxppc-embedded


bGludXhwcGMtZW1iZWRkZWSjoQ0KICAgICAgSGVsbG8sDQogICAgICAgICBqdXN0IGxvb2tlZCBp
bnRvIHRoZSA4eHggZmVjLmMgc291cmNlcyBvZiAyLjQuMTggdHJlZSBhbmQgZGlzY292ZXJlZCB0
aGVyZQ0KICAgICAgaXMgYSBDT05GSUdfRkVDX1BBQ0tFVEhPT0sgb3B0aW9uLiBDb3VsZG50IGZp
bmQgYW55IGZ1cnRoZXIgaW5mb3JtYXRpb24NCiAgICAgIGFib3V0IGl0LCBub3QgZXZlbiB0aGUg
aW5jbHVkZWQgbGludXgvcGt0aG9vay5oIGZpbGUuIEhhcyBhbnlvbmUgbW9yZQ0KICAgICAgaW5m
b3JtYXRpb24gd2hhdCB0aGlzIGlzIGZvcj8gSXMgdGhpcyBvdXRkYXRlZCwgbm90IGZpbmlzaGVk
IHlldC4uLj8NCg0KICAgICAgVGhhbmtzIGZvciBhbnkgaW5mb3JtYXRpb24sDQogICAgICBCZXN0
IHJlZ3JhZHMNCg0KoaGhoaGhoaGhoaGhoaGhoSBSaWNoYXJkDQqhoaGhoaGhoaGhoaGhoaGhY2hp
bmFmZW5nMjAwOEAxNjMuY29tDQqhoaGhoaGhoaGhoaGhoaGhoaGhoTIwMDYtMDEtMDcNCg==

^ permalink raw reply

* RE: Help on LXT971 eth initialization
From: KS Soumya-ask067 @ 2006-01-07  8:32 UTC (permalink / raw)
  To: linuxppc-embedded

 Hi=20
	Have you tried enabling =20
MPC8260 Communication options->FCC Ethernet option-->Ethernet on FCC1, =
Use MDIO for PHY-->LXT971 PHY support.
Hope this helps.


Best Regards,
Soumya

-----Original Message-----
From: linuxppc-embedded-bounces@ozlabs.org =
[mailto:linuxppc-embedded-bounces@ozlabs.org] On Behalf Of =
linuxppc-embedded-request@ozlabs.org
Sent: Friday, January 06, 2006 7:29 PM
To: linuxppc-embedded@ozlabs.org
Subject: Linuxppc-embedded Digest, Vol 17, Issue 11

Send Linuxppc-embedded mailing list submissions to
	linuxppc-embedded@ozlabs.org

To subscribe or unsubscribe via the World Wide Web, visit
	https://ozlabs.org/mailman/listinfo/linuxppc-embedded
or, via email, send a message with subject or body 'help' to
	linuxppc-embedded-request@ozlabs.org

You can reach the person managing the list at
	linuxppc-embedded-owner@ozlabs.org

When replying, please edit your Subject line so it is more specific than =
"Re: Contents of Linuxppc-embedded digest..."


Today's Topics:

   1. How to compile freescale example programs using eldk?
      (zengshuai@sogou.com)
   2. Help need: Porting Linux to PQ2FADS_ZU board (zengshuai@sogou.com)
   3. Re: [PM-SPAM] Help need: Porting Linux to PQ2FADS_ZU board
      (KokHow Teh)
   4. Re: How to compile freescale example programs using eldk?=20
      (Wolfgang Denk)
   5. Re: Help need: Porting Linux to PQ2FADS_ZU board  (Wolfgang Denk)
   6. Help on LXT971 eth initialization (batsayan.das@tcs.com)
   7. Re: io.h question (Arnd Bergmann)
   8. How to enable PHY (batsayan.das@tcs.com)
   9. Re: How to enable PHY (Mark Chambers)


----------------------------------------------------------------------

Message: 1
Date: Fri, 6 Jan 2006 16:23:54 +0800 (CST)
From: <zengshuai@sogou.com>
Subject: How to compile freescale example programs using eldk?
To: "ppc" <linuxppc-embedded@ozlabs.org>
Message-ID: <6251452.1136535834574.JavaMail.postfix@mx3.mail.sohu.com>
Content-Type: text/plain; charset=3D"GB2312"

I down some freescale example programs at
http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=3DMPC8260&=
nodeId=3D02VS0lDFTQJk192977

Device Drivers=20
ID and Description                                   Vendor          ID  =
    Format Size K  Rev # Availability=20
MPC8260API
PowerQUICC II API (Drivers and Examples)=20
Includes support for PCI, AAL2, AAL5, MSP, and more(10/03/2002)   =
FREESCALE   zip   15785   4.0.2    =20

Them aren't linux drvier but for bareboard. How can I compile them using =
eldk?

------------------------------
=CE=D2=CF=D6=D4=DA=CA=B9=D3=C3Sogou.com=B5=C42G=D3=CA=CF=E4=C1=CB=A3=AC=C4=
=E3=D2=B2=C0=B4=CA=D4=CA=D4=B0=C9!=20
http://mail.sogou.com/recommend/sogoumail_invite_reg1.jsp?from=3Dsogouinv=
itation&s_EMAIL=3Dzengshuai%40sogou.com&username=3Dlinuxppc-embedded&Full=
Name=3Dlinuxppc-embedded&Email=3Dlinuxppc-embedded%40ozlabs.org&verify=3D=
755eff4e640bdcfc57d93cbd8b0a9cb7



------------------------------

Message: 2
Date: Fri, 6 Jan 2006 16:49:50 +0800 (CST)
From: <zengshuai@sogou.com>
Subject: Help need: Porting Linux to PQ2FADS_ZU board
To: "ppc" <linuxppc-embedded@ozlabs.org>
Message-ID:
	<23894955.1136537390660.JavaMail.postfix@mx3.mail.sohu.com>
Content-Type: text/plain; charset=3D"GB2312"

I use ELDK3.1.1(2005-06-07).
There is a u-boot 1.1.3 and a linux 2.4.25 in the eldk.
I has compile u-boot successfully.And it works good.
I has compile kernel successfully too.(make ads8260_config) But it =
doesn't work.

Detail:
-------------------------------------------------------------------------=

U-Boot 1.1.3 (Dec 27 2005 - 19:35:12)

MPC8260 Reset Status: Check Stop, External Soft, External Hard

MPC8260 Clock Configuration
 - Bus-to-Core Mult 4.5x, VCO Div 2, 60x Bus Freq  22-65 , Core Freq =
100-300
 - dfbrg 1, corecnf 0x07, busdf 5, cpmdf 1, plldf 0, pllmf 5
 - vco_out  600000000, scc_clk  150000000, brg_clk   37500000
 - cpu_clk  450000000, cpm_clk  300000000, bus_clk  100000000
 - pci_clk   50000000

CPU:   MPC8260 (HiP7 Rev 13, Mask 0.1 1K49M) at 450 MHz
Board: Motorola PQ2FADS-ZU
DRAM:  32 MB
FLASH:  8 MB
In:    serial
Out:   serial
Err:   serial
Net:   FCC2 ETHERNET
Hit any key to stop autoboot:  0
=3D> printenv
bootdelay=3D5
baudrate=3D115200
ethact=3DFCC2 ETHERNET
ethaddr=3D0A:00:00:00:00:0A
gatewayip=3D172.17.248.1
netmask=3D255.255.255.0
ipaddr=3D172.17.248.244
serverip=3D172.17.248.253
bootcmd=3Dtftp 100000 vmlinux.UBoot; bootm 100000 =
bootargs=3Droot=3D/dev/nfs rw =
nfsroot=3D172.17.248.253:/opt/eldk3/ppc_6xx ip=3D172.17.24 =
8.244:172.17.248.253:172.17.248.253:255.255.255.0:pq2fads::off
stdin=3Dserial
stdout=3Dserial
stderr=3Dserial

Environment size: 398/262140 bytes
=3D> boot
Using FCC2 ETHERNET device
TFTP from server 172.17.248.253; our IP address is 172.17.248.244 =
Filename 'vmlinux.UBoot'.
Load address: 0x100000
Loading: =
#################################################################
         #########################################################
done
Bytes transferred =3D 623547 (983bb hex)
## Booting image at 00100000 ...
   Image Name:   Linux-2.4.25
   Image Type:   PowerPC Linux Kernel Image (gzip compressed)
   Data Size:    623483 Bytes =3D 608.9 kB
   Load Address: 00000000
   Entry Point:  00000000
   Verifying Checksum ... OK
   Uncompressing Kernel Image ... OK
-------------------------------------------------------------------------=
----------
At here,it stoped.
Later,I debug the kernel using bdi2000.
I bi start_kernel(),and setp by setp.
But printk(".........) didn't work.

My board is PQ2FADS_ZU.Does the ELDK not support it?


------------------------------
=CE=D2=CF=D6=D4=DA=CA=B9=D3=C3Sogou.com=B5=C42G=D3=CA=CF=E4=C1=CB=A3=AC=C4=
=E3=D2=B2=C0=B4=CA=D4=CA=D4=B0=C9!=20
http://mail.sogou.com/recommend/sogoumail_invite_reg1.jsp?from=3Dsogouinv=
itation&s_EMAIL=3Dzengshuai%40sogou.com&username=3Dlinuxppc-embedded&Full=
Name=3Dlinuxppc-embedded&Email=3Dlinuxppc-embedded%40ozlabs.org&verify=3D=
755eff4e640bdcfc57d93cbd8b0a9cb7



------------------------------

Message: 3
Date: Fri, 6 Jan 2006 17:09:35 +0800
From: "KokHow Teh" <KokHow.Teh@marconi.com>
Subject: Re: [PM-SPAM] Help need: Porting Linux to PQ2FADS_ZU board
To: linuxppc-embedded@ozlabs.org
Message-ID:
	<OFF860A6FA.D61DCEB9-ON482570EE.0031F142@uk.marconicomms.com>
Content-Type: text/plain; charset=3Dus-ascii



>bootargs=3Droot=3D/dev/nfs rw =
nfsroot=3D172.17.248.253:/opt/eldk3/ppc_6xx
ip=3D172.17.24
>8.244:172.17.248.253:172.17.248.253:255.255.255.0:pq2fads::off

add console=3D/dev/ttyS0,115200n8 and see if it works?





------------------------------

Message: 4
Date: Fri, 06 Jan 2006 11:08:44 +0100
From: Wolfgang Denk <wd@denx.de>
Subject: Re: How to compile freescale example programs using eldk?=20
To: zengshuai@sogou.com
Cc: ppc <linuxppc-embedded@ozlabs.org>
Message-ID: <20060106100844.A025D354113@atlas.denx.de>
Content-Type: text/plain; charset=3DISO-8859-1

In message <6251452.1136535834574.JavaMail.postfix@mx3.mail.sohu.com> =
you wrote:
>
> Them aren't linux drvier but for bareboard. How can I compile them =
using eldk?

You do it exactly the same way like you do it with any other compiler =
toolchain.

If the tools come with Makefiles and Linker scripts for GNU  gcc  and ld =
 then  you are set. If not, you will have to come up with your own build =
rules and linker commands.

You can check how U-Boot code (especially  the  standalone  programs) =
gets  linked, but be warned, this is not exactly trivial. You have to =
understand what you are doing, and how the linker works.

Best regards,

Wolfgang Denk

--
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de =
Just because your doctor has a name for your condition  doesn't  mean he =
knows what it is.


------------------------------

Message: 5
Date: Fri, 06 Jan 2006 11:13:25 +0100
From: Wolfgang Denk <wd@denx.de>
Subject: Re: Help need: Porting Linux to PQ2FADS_ZU board=20
To: zengshuai@sogou.com
Cc: ppc <linuxppc-embedded@ozlabs.org>
Message-ID: <20060106101325.B9FED354113@atlas.denx.de>
Content-Type: text/plain; charset=3DISO-8859-1

In message <23894955.1136537390660.JavaMail.postfix@mx3.mail.sohu.com> =
you wrote:
>
> My board is PQ2FADS_ZU.Does the ELDK not support it?

ELDK is, as the  name  suggests,  a  Development  Toolkit,  i.  e.  a
toolchain. As such, it is independent from the hardware and doesn not
support  any specific board, or, if you like, it supports all boards,
even those that don't exist yet.

What you are asking for is board support in a specific  kernel  tree.
There  is  no  specific  support  for  the  PQ2FADS_ZU  board  in our
linuxppc_2_4_devel  tree   (which   is   included   with   the   ELDK
distribution). On the other hand this is a standard board which which
is probably working fine, but we never tested or varified it.

I guess that it is not configured for use with U-Boot.

Best regards,

Wolfgang Denk

--=20
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de
"Never give in.  Never give in.  Never. Never. Never."
- Winston Churchill


------------------------------

Message: 6
Date: Fri, 6 Jan 2006 16:13:42 +0530
From: batsayan.das@tcs.com
Subject: Help on LXT971 eth initialization
To: linuxppc-embedded@ozlabs.org
Message-ID:
	<OFE75E4E98.D56217BF-ON652570EE.0039B69D-652570EE.003AEEB0@tcs.com>
Content-Type: text/plain; charset=3D"us-ascii"


Hi,

My MPC8260 customs board has LXT971 Ethernet chip on FCC1. I am able to=20
get the linux prompt, but I am unable to initialize ethernet. I have =
tried=20
different bootarg options (like setenv bootargs ip=3Ddhcp etc)  and=20
different kernel compilation options (like from make menuconfig, Network =

Option->enable DHCP support etc), but none enables the ethernet =
interface.=20


Any help will be appreciated.

FYI, the ethernet is working from U-Boot.=20

Thanks,
Batsayan Das
Tata Consultancy Services Limited
Mailto: batsayan.das@tcs.com
Website: http://www.tcs.com

Notice: The information contained in this e-mail message and/or =
attachments to it may contain confidential or privileged information.   =
If you are not the intended recipient, any dissemination, use, review, =
distribution, printing or copying of the information contained in this =
e-mail message and/or attachments to it are strictly prohibited.   If =
you have received this communication in error, please notify us by reply =
e-mail or telephone and immediately and permanently delete the message =
and any attachments.  Thank you
-------------- next part --------------
An HTML attachment was scrubbed...
URL: =
http://ozlabs.org/pipermail/linuxppc-embedded/attachments/20060106/83e47b=
9d/attachment-0001.htm

------------------------------

Message: 7
Date: Fri, 6 Jan 2006 12:03:55 +0000
From: Arnd Bergmann <arnd@arndb.de>
Subject: Re: io.h question
To: linuxppc-embedded@ozlabs.org
Message-ID: <200601061203.55926.arnd@arndb.de>
Content-Type: text/plain;  charset=3D"iso-8859-1"

On Thursday 05 January 2006 21:00, mcnernbm@notes.udayton.edu wrote:
> I finally noticed out_8 and in_8 and what not are located in the
> ppc io.h file in the kernel development download.=A0 But when I=20
> tried to do a io.h with in my program I added #include <asm/io.h>=A0
> and it seems to find it with not problems but it can not find the
> functions with in that file.=A0 Am i missing a define I need to set
> or something so I can see the right files with in io.h I am
> compiling for a ppc405 on a xilinx virtex 4 board.     =20

The definitions in that file are only usable from inside the kernel,
you can not use them in a user space application.

The correct way to solve your problem (which you did not explain, so
I can only guess) would be to write a kernel device driver for
the peripherial you want to drive, at least if it does not exist yet.

For prototyping, you can play with mmap() on /dev/mem in a user
application, but that is often not very reliable.

	Arnd <><


------------------------------

Message: 8
Date: Fri, 6 Jan 2006 18:43:08 +0530
From: batsayan.das@tcs.com
Subject: How to enable PHY
To: linuxppc-embedded@ozlabs.org
Message-ID:
	<OF114C07C5.7CED9F64-ON652570EE.00481B82-652570EE.00489CCF@tcs.com>
Content-Type: text/plain; charset=3D"us-ascii"


Hi,

I found that ADS8260 board enables PHY by the following lines of code

#ifndef CONFIG_ADS8260
        /* Enable the PHY.
        */
        *(volatile uint *)(BCSR_ADDR + 4) &=3D ~BCSR1_FETHIEN;
        *(volatile uint *)(BCSR_ADDR + 4) |=3D  BCSR1_FETH_RST;
#endif


Our board does not have BCSR. My question is how to enable PHY for =
MPC8260=20
based customs board without BCSR?=20

Thanks,
Batsayan Das
Tata Consultancy Services Limited
Mailto: batsayan.das@tcs.com
Website: http://www.tcs.com

Notice: The information contained in this e-mail message and/or =
attachments to it may contain confidential or privileged information.   =
If you are not the intended recipient, any dissemination, use, review, =
distribution, printing or copying of the information contained in this =
e-mail message and/or attachments to it are strictly prohibited.   If =
you have received this communication in error, please notify us by reply =
e-mail or telephone and immediately and permanently delete the message =
and any attachments.  Thank you
-------------- next part --------------
An HTML attachment was scrubbed...
URL: =
http://ozlabs.org/pipermail/linuxppc-embedded/attachments/20060106/8701df=
92/attachment-0001.htm

------------------------------

Message: 9
Date: Fri, 6 Jan 2006 08:41:41 -0500
From: "Mark Chambers" <markc@mail.com>
Subject: Re: How to enable PHY
To: <linuxppc-embedded@ozlabs.org>,	<batsayan.das@tcs.com>
Message-ID: <004201c612c6$ee3ede80$6601a8c0@chuck2>
Content-Type: text/plain; charset=3D"iso-8859-1"


>I found that ADS8260 board enables PHY by the following lines of code=20
>
>#ifndef CONFIG_ADS8260=20
>        /* Enable the PHY.=20
>        */=20
>        *(volatile uint *)(BCSR_ADDR + 4) &=3D ~BCSR1_FETHIEN;=20
>        *(volatile uint *)(BCSR_ADDR + 4) |=3D  BCSR1_FETH_RST;=20
>#endif=20
>
>Our board does not have BCSR. My question is how to enable PHY for =
MPC8260 based customs board without BCSR?=20

If your board does not have the BCSR you can just leave this code out.  =
Usually, you only need to configure which MDII=20
interface your PHY is connected to and which IRQ it uses.  But of course =
I don't know how your PHY is wired up on your
custom board.

Mark Chambers


-------------- next part --------------
An HTML attachment was scrubbed...
URL: =
http://ozlabs.org/pipermail/linuxppc-embedded/attachments/20060106/9228b0=
02/attachment.htm

------------------------------

_______________________________________________
Linuxppc-embedded mailing list
Linuxppc-embedded@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-embedded

End of Linuxppc-embedded Digest, Vol 17, Issue 11
*************************************************

^ permalink raw reply

* FEC       CONFIG_FEC_PACKETHOOK
From: feng @ 2006-01-07  8:01 UTC (permalink / raw)
  To: linuxppc-embedded


bGludXhwcGMtZW1iZWRkZWSjoQ0KICAgICAgSGVsbG8sDQogICAgICAgICBqdXN0IGxvb2tlZCBp
bnRvIHRoZSA4eHggZmVjLmMgc291cmNlcyBvZiAyLjQuMTggdHJlZSBhbmQgZGlzY292ZXJlZCB0
aGVyZQ0KICAgICAgaXMgYSBDT05GSUdfRkVDX1BBQ0tFVEhPT0sgb3B0aW9uLiBDb3VsZG50IGZp
bmQgYW55IGZ1cnRoZXIgaW5mb3JtYXRpb24NCiAgICAgIGFib3V0IGl0LCBub3QgZXZlbiB0aGUg
aW5jbHVkZWQgbGludXgvcGt0aG9vay5oIGZpbGUuIEhhcyBhbnlvbmUgbW9yZQ0KICAgICAgaW5m
b3JtYXRpb24gd2hhdCB0aGlzIGlzIGZvcj8gSXMgdGhpcyBvdXRkYXRlZCwgbm90IGZpbmlzaGVk
IHlldC4uLj8NCg0KICAgICAgVGhhbmtzIGZvciBhbnkgaW5mb3JtYXRpb24sDQogICAgICBCZXN0
IHJlZ3JhZHMNCg0KoaGhoaGhoaGhoaGhoaGhoSBSaWNoYXJkDQqhoaGhoaGhoaGhoaGhoaGhY2hp
bmFmZW5nMjAwOEAxNjMuY29tDQqhoaGhoaGhoaGhoaGhoaGhoaGhoTIwMDYtMDEtMDcNCg==

^ permalink raw reply

* Re: Booting from RAM Disk
From: Grant Likely @ 2006-01-07  5:34 UTC (permalink / raw)
  To: David H. Lynch Jr.; +Cc: Linuxppc-embedded
In-Reply-To: <43BF4AB8.6030003@comcast.net>

David H. Lynch Jr. wrote:
> 	initramfs does nto exist in 2.4, but despite a dearth of information it
> works extremely well in 2.6.
> 
> 	Set CONFIG_INITRAMFS=path to directory tree to build into ramdisk, and
> the kernel building process will take care of most evrything else.
> Unlike initrd, there are not two separate files, that each have to be
> loaded. The initial ramdisk is part of the kernel image, gets
> uncompressed by the kernel, and is just generally painless - except for
> the scarcity of documentation.
So... have are been able to use initramfs as a drop in replacement for
initrd, or did you have to jump through extra hoops?  I attempted to use
initramfs a few months ago, but wasn't ever able to get it to run init.

g.

-- 
Grant Likely, B.Sc. P.Eng.
Secret Lab Technologies Ltd.
(403) 663-0761

^ permalink raw reply

* Re: Booting from RAM Disk
From: David H. Lynch Jr. @ 2006-01-07  4:59 UTC (permalink / raw)
  To: Linuxppc-embedded
In-Reply-To: <20060106221601.78327.qmail@web33515.mail.mud.yahoo.com>


	initramfs does nto exist in 2.4, but despite a dearth of information it
works extremely well in 2.6.

	Set CONFIG_INITRAMFS=path to directory tree to build into ramdisk, and
the kernel building process will take care of most evrything else.
Unlike initrd, there are not two separate files, that each have to be
loaded. The initial ramdisk is part of the kernel image, gets
uncompressed by the kernel, and is just generally painless - except for
the scarcity of documentation.

^ permalink raw reply

* [Fwd: Re: RESEND:[RFC] Pico E12 (Xilinx V4) patches to 2.6.15]
From: Grant Likely @ 2006-01-07  4:43 UTC (permalink / raw)
  To: linuxppc-embedded

[Trimmed & Resent; first one rejected by mailing list due to size]

David H. Lynch Jr. wrote:
> I could not figure out how to seek to the 2.6.14 tag so it is against
> HEAD/2.6.15
try cg-seek, but head is just fine.  :)

> 
> I am also presuming that git diff produces a unified diff. I do not try
> to read diffs - I typically do my diff/merges with vim, but it looks
> about right to me.
Your right; git uses unified by default.  You'll need to start reading
them.  If found *lots* of stuff in this patch that shouldn't be there.

> 
> There are basically 5 parts, and I have no idea how to easily separate
> the pieces:
Commit to your git tree frequently and commit related files at the same
time.  Then you can bring up a list of all your commits and coalate
related changes into a single patch.

BTW, many of the long lines were word wrapped (making an unusable
patch).  You should attach the diff instead of pasting it into thunderbird.

> diff --git a/README.pico b/README.pico
> new file mode 120000
> index 0000000..3daad5a
> --- /dev/null
> +++ b/README.pico
> @@ -0,0 +1 @@
> +pico/README.pico
> \ No newline at end of file
> diff --git a/arch/ppc/Kconfig b/arch/ppc/Kconfig
> index cc3f64c..7c4318a 100644
> --- a/arch/ppc/Kconfig
> +++ b/arch/ppc/Kconfig
> @@ -53,7 +53,7 @@ menu "Processor"
> 
>  choice
>  	prompt "Processor Type"
> -	default 6xx
> +	default 4xx
You don't want to do this... Your defconfig file should set it instead.

> diff --git a/arch/ppc/boot/common/misc-common.c
> b/arch/ppc/boot/common/misc-common.c
> index e79e6b3..a50762a 100644
> --- a/arch/ppc/boot/common/misc-common.c
> +++ b/arch/ppc/boot/common/misc-common.c

<--- snip --->

> @@ -271,6 +284,15 @@ void gunzip(void *dst, int dstlen, unsig
>  	*lenp = s.next_out - (unsigned char *) dst;
>  	zlib_inflateEnd(&s);
>  }
> +#if 0
> +void
> +puthexb(unsigned char val)
> +{
> +	char digits[] = "0123456789abcdef" ;
> +	putc(digits[(val/16) & 0x0F]);
> +	putc(digits[val & 0x0F]);
> +}
> +#endif

Why is this in your patch?  Keep debug hacks to yourself, especially
"#if 0" ones.  :)

> 
>  void
>  puthex(unsigned long val)
> @@ -488,8 +510,13 @@ _dump_buf_with_offset(unsigned char *p,
>  			{
>  				_printk("  ");
>  			}
> +#if defined(CONFIG_PICO_DEBUG)
> +// more readable dump
> +			 _printk(" ");
> +#else
>  			if ((i % 2) == 1) _printk(" ");
>  			if ((i % 8) == 7) _printk(" ");
> +#endif

ditto

> diff --git a/arch/ppc/boot/simple/Makefile b/arch/ppc/boot/simple/Makefile
> index f3e9c53..3094f1c 100644
> --- a/arch/ppc/boot/simple/Makefile
> +++ b/arch/ppc/boot/simple/Makefile
> @@ -188,6 +188,7 @@ OBJCOPY_ARGS			:= -O elf32-powerpc
>  boot-y				:= head.o relocate.o $(extra.o-y) $(misc-y)
>  boot-$(CONFIG_REDWOOD_5)	+= embed_config.o
>  boot-$(CONFIG_REDWOOD_6)	+= embed_config.o
> +boot-$(CONFIG_PICO_E12)		+= embed_config.o
>  boot-$(CONFIG_8xx)		+= embed_config.o
>  boot-$(CONFIG_8260)		+= embed_config.o
>  boot-$(CONFIG_BSEIP)		+= iic.o
> @@ -202,6 +203,16 @@ boot-$(CONFIG_8260)		+= m8260_tty.o
>  endif
>  boot-$(CONFIG_SERIAL_MPC52xx_CONSOLE)	+= mpc52xx_tty.o
>  boot-$(CONFIG_SERIAL_MPSC_CONSOLE)	+= mv64x60_tty.o
> +boot-$(CONFIG_SERIAL_UARTLITE_CONSOLE)	+= uartlite_tty.o
> +boot-$(CONFIG_SERIAL_KEYHOLE_CONSOLE)	+= keyhole_tty.o
> +#ifdef CONFIG_XILINX_UARTLITE_CONSOLE
> +#LIBS				+= $(TOPDIR)/drivers/char/xilinx_uartlite/xuartlite_l.o
> +#endif
> +# ifeq ($(CONFIG_XILINX_ML300),y)
> +# CFLAGS_xuartlite_tty.o		+= -I$(TOPDIR)/drivers/char/xilinx_uartlite
> +# EXTRA_CFLAGS			+= -I$(TOPDIR)/arch/ppc/platforms/xilinx_ocp \
> +# 					-I$(TOPDIR)/drivers/i2c/xilinx_iic
> +# endif

Wrong place for this; should be done in:
drivers/char/xilinx_uartlite/Makefile

<--- snip --->

> diff --git a/arch/ppc/boot/simple/head.S b/arch/ppc/boot/simple/head.S
> index 5e4adc2..e432b64 100644
> --- a/arch/ppc/boot/simple/head.S
> +++ b/arch/ppc/boot/simple/head.S
> @@ -46,6 +46,46 @@ start:
>  #endif
> 
>  start_:
> +#if defined(CONFIG_XILINX_ML300) || defined(CONFIG_PICO_E12) /* PPC
> errata 213: only for Virtex-4 */
> +	mfccr0	0
> +	oris	0,0,0x50000000@h
> +	mtccr0	0
> +#endif

ML300 doesn't have this issue.

<--- snip --->

> diff --git a/arch/ppc/boot/simple/keyhole_tty.c
> b/arch/ppc/boot/simple/keyhole_tty.c
> new file mode 100644
> index 0000000..ab07ca8
> --- /dev/null
> +++ b/arch/ppc/boot/simple/keyhole_tty.c
> @@ -0,0 +1,93 @@
> +/*
> + * arch/ppc/boot/simple/keyhole_tty.c
> + *
> + * Bootloader version of the embedded Xilinx/KEYHOLE driver.
> + *
> + * Author: David H. Lynch Jr. <dhlii@dlasys.net>
> + *
> + * 2005 (c) DLA Systems  This file is licensed under
> + * the terms of the GNU General Public License version 2.  This program
> + * is licensed "as is" without any warranty of any kind, whether express
> + * or implied.
> + */
> +
> +#include <linux/config.h>
> +#include <linux/serial_keyhole.h>
> +
> +static int MillisecTimeout=1000;
> +void usleep(int t) {
> +   int ii, waitTime=100;
> +    while(t) {
> +    	for (ii=0; ii < MillisecTimeout*1000/waitTime; ii++){};
> +	t--;
> +    }
> +}

umm, isn't udelay already defined in the kernel?


<--- snip --->

> @@ -180,11 +192,16 @@ load_kernel(unsigned long load_addr, int
>  #ifdef CONFIG_CMDLINE_BOOL
>  	memcpy (cmd_line, compiled_string, sizeof(compiled_string));
>  #else
> +// INITRAMFS and initrd should be handled the same.
> +#ifdef CONFIG_INITRAMFS_SOURCE
> +	memcpy (cmd_line, ramroot_string, sizeof(ramroot_string));
> +#else
>  	if ( initrd_size )
>  		memcpy (cmd_line, ramroot_string, sizeof(ramroot_string));
>  	else
>  		memcpy (cmd_line, netroot_string, sizeof(netroot_string));
>  #endif
> +#endif
why?

<--- snip --->

> diff --git a/arch/ppc/boot/simple/uartlite_tty.c b/arch/ppc/boot/simple/uartlite_tty.c

Russell King needs to be CC'd on serial stuff; but looks okay from a
real-quick look

<--- snip --->

> diff --git a/arch/ppc/kernel/head_4xx.S b/arch/ppc/kernel/head_4xx.S
> index 10c261c..c08aa7f 100644
> --- a/arch/ppc/kernel/head_4xx.S
> +++ b/arch/ppc/kernel/head_4xx.S
> @@ -75,13 +75,25 @@ _GLOBAL(_start)
>   * ready to work.
>   */
>  turn_on_mmu:
> +#if 0						// debuging code used to find the spurious E12 machine check
> problem
> +	khdbg(0x57002)
> +
> +#if defined(CONFIG_PICO_DEBUG) && 0
> +	bl	pico_dbg
> +#endif
> +#endif
>  	lis	r0,MSR_KERNEL@h
>  	ori	r0,r0,MSR_KERNEL@l
>  	mtspr	SPRN_SRR1,r0
> -	lis	r0,start_here@h
> +	lis	r0,start_here@h			// SPRN_SRR0 is where the rfi resumes execution
>  	ori	r0,r0,start_here@l
>  	mtspr	SPRN_SRR0,r0
>  	SYNC
> +// 	PPC405_ERR77_SYNC
> +/* We now have the lower 16 Meg mapped into TLB entries, and the caches
> + * ready to work.
> + */
> +

again, leave out private debug stuff and notes; or put in seperate patch

>  	rfi				/* enables MMU */
>  	b	.			/* prevent prefetch past rfi */
> 
> @@ -364,6 +376,9 @@ label:
>  	b	.		/* prevent prefetch past rfi */
> 
>  2:
> +	// khdbg(0x55001)
> +	// khdbgr(r16)
> +	

ditto

>  	/* The bailout.  Restore registers to pre-exception conditions
>  	 * and call the heavyweights to help us out.
>  	 */
> @@ -478,8 +493,11 @@ label:
>  	mtspr	SPRN_SPRG7, r11
>  	mtspr	SPRN_SPRG6, r12
>  #endif
> -	mfspr	r10, SPRN_DEAR		/* Get faulting address */
> 
> +	// khdbg(0x55000)
> +	// khdbgr(r16)
> +	mfspr	r10, SPRN_DEAR		/* Get faulting address */
> +	// khdbgr(r10)

ditto

>  	/* If we are faulting a kernel address, we have to use the
>  	 * kernel page tables.
>  	 */
> @@ -521,6 +539,8 @@ label:
>  	b	finish_tlb_load
> 
>  2:	/* Check for possible large-page pmd entry */
> +	// khdbg(0x55002)
> +	// khdbgr(r16)

ditto


<--- snip --->

> diff --git a/arch/ppc/platforms/4xx/Kconfig b/arch/ppc/platforms/4xx/Kconfig
> diff --git a/arch/ppc/platforms/4xx/Makefile b/arch/ppc/platforms/4xx/Makefile

This stuff all conflicts with my patches of course; but that's to be
expected.  :)  Looks okay otherwise

> diff --git a/arch/ppc/platforms/4xx/pico_e12.c b/arch/ppc/platforms/4xx/pico_e12.c

this is just a copy of xilinx_ml300 and modified for the e12; I didn't
look deep into it; but seems okay.

> diff --git a/arch/ppc/platforms/4xx/pico_e12.h b/arch/ppc/platforms/4xx/pico_e12.h

ditto

> diff --git a/arch/ppc/platforms/4xx/virtex-iv.c b/arch/ppc/platforms/4xx/virtex-iv.c
> diff --git a/arch/ppc/platforms/4xx/virtex-iv.h b/arch/ppc/platforms/4xx/virtex-iv.h

conflicts with my changes; but okay.

> diff --git a/arch/ppc/platforms/4xx/xparameters/xparameters_pico_e12.h b/arch/ppc/platforms/4xx/xparameters/xparameters_pico_e12.h
okay


> diff --git a/arch/ppc/syslib/keyhole.h b/arch/ppc/syslib/keyhole.h
> new file mode 100644
> index 0000000..4b7a374
> --- /dev/null
> +++ b/arch/ppc/syslib/keyhole.h
> @@ -0,0 +1,17 @@
> +/*
> + * arch/ppc/syslib/keyhole.h
> + *
> + * keyhole prototypes
> + *
> + * Matt Porter <mporter@kernel.crashing.org>

You can add your name to the copyright list.

> + *
> + * 2004 (c) MontaVista Software, Inc.  This file is licensed under
> + * the terms of the GNU General Public License version 2.  This program
> + * is licensed "as is" without any warranty of any kind, whether express
> + * or implied.
> + */
> +
> +extern void keyhole_progress(char *, unsigned short);
> +extern void keyhole_puts(char *);
> +extern void keyhole_init(int, struct uart_port *);
> +extern void keyhole_kgdb_map_scc(void);
> diff --git a/arch/ppc/syslib/keyhole_dbg.c b/arch/ppc/syslib/keyhole_dbg.c
> new file mode 100644
> index 0000000..73dd275
> --- /dev/null
> +++ b/arch/ppc/syslib/keyhole_dbg.c

<--- snip --->

> +/* SERIAL_PORT_DFNS is defined in <asm/serial.h> */
> +#ifndef SERIAL_PORT_DFNS
> +#define SERIAL_PORT_DFNS
> +#endif
> +
> +static struct serial_state rs_table[RS_TABLE_SIZE] = {
> +	SERIAL_PORT_DFNS	/* defined in <asm/serial.h> */
> +};
> +static int MillisecTimeout=1000;
> +void usleep(int t) {
> +   int ii, waitTime=100;
> +    while(t) {
> +    	for (ii=0; ii < MillisecTimeout*1000/waitTime; ii++){};
> +	t--;
> +    }
> +}

again; what about udelay?

<--- snip --->

> diff --git a/arch/ppc/syslib/ppc4xx_setup.c b/arch/ppc/syslib/ppc4xx_setup.c
> index e83a83f..c601390 100644
> --- a/arch/ppc/syslib/ppc4xx_setup.c
> +++ b/arch/ppc/syslib/ppc4xx_setup.c
> @@ -41,7 +41,15 @@
>  #include <asm/pci-bridge.h>
>  #include <asm/bootinfo.h>
> 
> +#if defined(CONFIG_SERIAL_8250)
>  #include <syslib/gen550.h>
> +#endif
> +#if defined(CONFIG_SERIAL_KEYHOLE)
> +#include <syslib/keyhole.h>
> +#endif
> +#if defined(CONFIG_SERIAL_UARTLITE)
> +#include <syslib/uartlite.h>
> +#endif
> 
>  /* Function Prototypes */
>  extern void abort(void);
> @@ -72,11 +80,18 @@ ppc4xx_setup_arch(void)
>   *   This routine pretty-prints the platform's internal CPU clock
>   *   frequencies into the buffer for usage in /proc/cpuinfo.
>   */
> +#if defined(CONFIG_PICO_DEBUG)
> +#define DEBUG_PRINTK(fmt...)	_printk(fmt)
> +#else
> +#define DEBUG_PRINTK(fmt...)	do { } while (0)
> +#endif
> +#define _printk printk

The code cleanliness police will probably have something to say about
you defining your own debug macros.  :)

<--- snip --->

> diff --git a/config.x86 b/config.x86

why?  This is just noise in your diff.

> diff --git a/cross b/cross
> new file mode 120000
> index 0000000..d11f058
> --- /dev/null
> +++ b/cross
> @@ -0,0 +1 @@
> +pico/cross
> \ No newline at end of file

???

<--- snip --->

> diff --git a/drivers/char/Makefile b/drivers/char/Makefile
> index 4aeae68..800f4c8 100644
> --- a/drivers/char/Makefile
> +++ b/drivers/char/Makefile
> @@ -119,3 +119,20 @@ $(obj)/defkeymap.c $(obj)/qtronixmap.c:
>  	rm $@.tmp
> 
>  endif
> +# mod-subdirs     +=	xilinx_gpio xilinx_ts xilinx_uartlite xilinx_spi
> +# subdir-$(CONFIG_XILINX_GPIO) += xilinx_gpio
> +# subdir-$(CONFIG_XILINX_TS) += xilinx_ts
> +# subdir-$(CONFIG_XILINX_UARTLITE) += xilinx_uartlite
> +# subdir-$(CONFIG_XILINX_SPI) += xilinx_spi
> +# obj-$(CONFIG_XILINX_GPIO) += xilinx_gpio/xilinx_gpio.o
> +# obj-$(CONFIG_XILINX_TS) += xilinx_ts/xilinx_ts.o
> +# obj-$(CONFIG_XILINX_UARTLITE) += xilinx_uartlite/xilinx_uartlite.o
> generic_serial.o
> +# obj-$(CONFIG_XILINX_SPI) += xilinx_spi/xilinx_spi.o
> +# ifeq ($(CONFIG_VIRTEX_II_PRO),y)
> +#   ifeq ($(CONFIG_VT),y)
> +#     ifeq ($(CONFIG_PC_KEYBOARD),y)
> +#       subdir-$(CONFIG_VT) += xilinx_keyb
> +#       obj-$(CONFIG_VT) += xilinx_keyb/xilinx_keyb.o
> +#     endif
> +#   endif
> +# endif

???

> diff --git a/drivers/net/Makefile b/drivers/net/Makefile
> index 4cffd34..d559224 100644
> --- a/drivers/net/Makefile
> +++ b/drivers/net/Makefile
> @@ -206,4 +206,6 @@ obj-$(CONFIG_ETRAX_ETHERNET) += cris/
>  obj-$(CONFIG_NETCONSOLE) += netconsole.o
> 
>  obj-$(CONFIG_FS_ENET) += fs_enet/
> -
> +#mod-subdirs     +=	xilinx_enet
> +#subdir-$(CONFIG_XILINX_ENET) += xilinx_enet
> +#obj-$(CONFIG_XILINX_ENET) += xilinx_enet/xilinx_enet.o

???

<--- snip --->

> diff --git a/drivers/serial/printk.c b/drivers/serial/printk.c
> new file mode 100644
> index 0000000..5e87489
> --- /dev/null
> +++ b/drivers/serial/printk.c
> @@ -0,0 +1,267 @@
> +/*
> + * arch/ppc/kernel/printf.c
> + *
> + * early printk code code (almost) all platforms can use
> + *
> + * Author: David H. Lynch Jr. <dhlii@dlasys.net>
> + *
> + * Derived heavily from arch/ppc/boot/common/misc-common1.c
> + *
> + * 20050 (c) DLA Systems This file is licensed under
> + * the terms of the GNU General Public License version 2.  This program
> + * is licensed "as is" without any warranty of any kind, whether express
> + * or implied.
> + */
You'll need to run this stuff by Tom Rini.


<---snip--->

> diff --git a/drivers/serial/uartlite.c b/drivers/serial/uartlite.c
> diff --git a/drivers/serial/uartlite_early.c b/drivers/serial/uartlite_early.c

I didn't review these, sorry

<--- snip --->

> diff --git a/include/asm-ppc/reg_booke.h b/include/asm-ppc/reg_booke.h
> index 00ad9c7..5221970 100644
> --- a/include/asm-ppc/reg_booke.h
> +++ b/include/asm-ppc/reg_booke.h
> @@ -120,6 +120,11 @@ do {						\
>  #elif defined(CONFIG_BOOKE)
>  #define MSR_KERNEL	(MSR_ME|MSR_RI|MSR_CE)
>  #endif
> +#if defined (CONFIG_PICO_E12)
> +// The E12 seems to generate spurious Machine Checks - disable them.
> +#undef MSR_KERNEL
> +#define MSR_KERNEL	(MSR_RI|MSR_IR|MSR_DR|MSR_CE)
> +#endif

Ugh; this worries me.  What about legitimate machine checks?

<--- snip --->

> diff --git a/include/linux/serial_keyhole.h b/include/linux/serial_keyhole.h
> diff --git a/include/linux/serial_uartlite.h b/include/linux/serial_uartlite.h

Didn't review these, sorry

<--- snip --->

Ugh! I'm not doing that again.  Make sure your next patch set is broken
up into bite size emails.  That was far too long.

g.

-- 
Grant Likely, B.Sc. P.Eng.
Secret Lab Technologies Ltd.
(403) 663-0761

^ permalink raw reply

* Re: How to build the zImage.prep was Re: Bug#345424 acknowledged by developer         (Bug#345424: fixed in linux-2.6 2.6.15-1)
From: Grant Likely @ 2006-01-07  4:25 UTC (permalink / raw)
  To: Paul Janzen, linuxppc-embedded; +Cc: Sebastian Heutling, Paul Mackerras
In-Reply-To: <oqr77koggf.fsf@merlin.sez.to>

Paul Janzen wrote:
> grant.likely at secretlab.ca (Grant Likely) writes:
> 
> 
>>Have you tried 2.6.14?  I'm having a similar issue with PReP images
>>using QEMU.  2.6.14 works, but 2.6.15 is busted.  It *might* be the same
>>issue.
>>
>>http://ozlabs.org/pipermail/linuxppc-dev/2005-December/020782.html
>>
>>I was able to use git-bisect to narrow it down to 20 or so changes, but
>>I didn't get any farther.
> 
> 
> This *might* be the problem described in: 
> 
> http://ozlabs.org/pipermail/linuxppc-embedded/2006-January/021550.html
> 
> It matches the git-bisect ID's you narrowed it down to, and it matches
> the problem report.  I'm just not sure if it matches the environment
> you're running in. 

Yes, that's exactly it.  QEMU boots prep images again with that patch.
Thank you.

g.

-- 
Grant Likely, B.Sc. P.Eng.
Secret Lab Technologies Ltd.
(403) 663-0761

^ permalink raw reply

* [PATCH] 5/5 powerpc: Update g5 defconfig
From: Benjamin Herrenschmidt @ 2006-01-07  0:46 UTC (permalink / raw)
  To: linuxppc-dev list, linuxppc64-dev

This is just a deconfig update so that the Quad G5 works better with the
default config.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

Index: linux-work/arch/powerpc/configs/g5_defconfig
===================================================================
--- linux-work.orig/arch/powerpc/configs/g5_defconfig	2005-11-24 17:18:42.000000000 +1100
+++ linux-work/arch/powerpc/configs/g5_defconfig	2006-01-06 15:03:26.000000000 +1100
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.15-rc1
-# Tue Nov 15 14:39:20 2005
+# Linux kernel version: 2.6.15-rc6
+# Fri Jan  6 15:03:09 2006
 #
 CONFIG_PPC64=y
 CONFIG_64BIT=y
@@ -26,7 +26,7 @@ CONFIG_PPC_FPU=y
 CONFIG_ALTIVEC=y
 CONFIG_PPC_STD_MMU=y
 CONFIG_SMP=y
-CONFIG_NR_CPUS=2
+CONFIG_NR_CPUS=4
 
 #
 # Code maturity level options
@@ -53,6 +53,7 @@ CONFIG_IKCONFIG=y
 CONFIG_IKCONFIG_PROC=y
 # CONFIG_CPUSETS is not set
 CONFIG_INITRAMFS_SOURCE=""
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
 # CONFIG_EMBEDDED is not set
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_ALL is not set
@@ -116,6 +117,8 @@ CONFIG_U3_DART=y
 CONFIG_MPIC=y
 # CONFIG_PPC_RTAS is not set
 # CONFIG_MMIO_NVRAM is not set
+CONFIG_MPIC_BROKEN_U3=y
+# CONFIG_CRASH_DUMP is not set
 # CONFIG_PPC_MPC106 is not set
 CONFIG_GENERIC_TBSYNC=y
 CONFIG_CPU_FREQ=y
@@ -162,7 +165,7 @@ CONFIG_FLATMEM_MANUAL=y
 CONFIG_FLATMEM=y
 CONFIG_FLAT_NODE_MEM_MAP=y
 # CONFIG_SPARSEMEM_STATIC is not set
-CONFIG_SPLIT_PTLOCK_CPUS=4096
+CONFIG_SPLIT_PTLOCK_CPUS=4
 # CONFIG_PPC_64K_PAGES is not set
 # CONFIG_SCHED_SMT is not set
 CONFIG_PROC_DEVICETREE=y
@@ -629,6 +632,7 @@ CONFIG_THERM_PM72=y
 CONFIG_WINDFARM=y
 CONFIG_WINDFARM_PM81=y
 CONFIG_WINDFARM_PM91=y
+CONFIG_WINDFARM_PM112=y
 
 #
 # Network device support
@@ -681,7 +685,7 @@ CONFIG_E1000=y
 # CONFIG_SIS190 is not set
 # CONFIG_SKGE is not set
 # CONFIG_SK98LIN is not set
-CONFIG_TIGON3=m
+CONFIG_TIGON3=y
 # CONFIG_BNX2 is not set
 # CONFIG_MV643XX_ETH is not set
 
@@ -1141,6 +1145,7 @@ CONFIG_USB_STORAGE_JUMPSHOT=y
 #
 CONFIG_USB_HID=y
 CONFIG_USB_HIDINPUT=y
+# CONFIG_USB_HIDINPUT_POWERBOOK is not set
 CONFIG_HID_FF=y
 CONFIG_HID_PID=y
 CONFIG_LOGITECH_FF=y
@@ -1203,6 +1208,7 @@ CONFIG_USB_MON=y
 CONFIG_USB_SERIAL=m
 CONFIG_USB_SERIAL_GENERIC=y
 # CONFIG_USB_SERIAL_AIRPRIME is not set
+# CONFIG_USB_SERIAL_ANYDATA is not set
 CONFIG_USB_SERIAL_BELKIN=m
 CONFIG_USB_SERIAL_DIGI_ACCELEPORT=m
 # CONFIG_USB_SERIAL_CP2101 is not set
@@ -1233,7 +1239,6 @@ CONFIG_USB_SERIAL_KEYSPAN_USA49WLC=y
 CONFIG_USB_SERIAL_KLSI=m
 CONFIG_USB_SERIAL_KOBIL_SCT=m
 CONFIG_USB_SERIAL_MCT_U232=m
-# CONFIG_USB_SERIAL_NOKIA_DKU2 is not set
 CONFIG_USB_SERIAL_PL2303=m
 # CONFIG_USB_SERIAL_HP4X is not set
 CONFIG_USB_SERIAL_SAFE=m

^ permalink raw reply

* [PATCH] 4/5 powerpc: Add cpufreq support for all desktop G5
From: Benjamin Herrenschmidt @ 2006-01-07  0:45 UTC (permalink / raw)
  To: linuxppc-dev list, linuxppc64-dev

This patch adds cpufreq support for all desktop "tower" G5 models. The
only G5 models still lacking cpufreq support at this point are the
Xserve and possibly the new iMac iSight (not tested). I'll have those
added soon. That patch uses the new platform functions interpreter to
implement frequency and voltage switching on most models.

Note that in order to find the low frequency value, I had to hack
something that might now work properly on all models, so if the
frequency value reported when running low speed looks bogus to you,
please report it to me. (Appart from a bogus reported value, things
should work fine).

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

Index: linux-work/arch/powerpc/platforms/powermac/cpufreq_64.c
===================================================================
--- linux-work.orig/arch/powerpc/platforms/powermac/cpufreq_64.c	2006-01-07 10:53:19.000000000 +1100
+++ linux-work/arch/powerpc/platforms/powermac/cpufreq_64.c	2006-01-07 10:54:25.000000000 +1100
@@ -28,6 +28,7 @@
 #include <asm/cputable.h>
 #include <asm/time.h>
 #include <asm/smu.h>
+#include <asm/pmac_pfunc.h>
 
 #undef DEBUG
 
@@ -85,6 +86,10 @@ static u32 *g5_pmode_data;
 static int g5_pmode_max;
 static int g5_pmode_cur;
 
+static void (*g5_switch_volt)(int speed_mode);
+static int (*g5_switch_freq)(int speed_mode);
+static int (*g5_query_freq)(void);
+
 static DECLARE_MUTEX(g5_switch_mutex);
 
 
@@ -92,9 +97,11 @@ static struct smu_sdbp_fvt *g5_fvt_table
 static int g5_fvt_count;			/* number of op. points */
 static int g5_fvt_cur;				/* current op. point */
 
-/* ----------------- real hardware interface */
+/*
+ * SMU based voltage switching for Neo2 platforms
+ */
 
-static void g5_switch_volt(int speed_mode)
+static void g5_smu_switch_volt(int speed_mode)
 {
 	struct smu_simple_cmd	cmd;
 
@@ -105,26 +112,57 @@ static void g5_switch_volt(int speed_mod
 	wait_for_completion(&comp);
 }
 
-static int g5_switch_freq(int speed_mode)
-{
-	struct cpufreq_freqs freqs;
-	int to;
+/*
+ * Platform function based voltage/vdnap switching for Neo2
+ */
 
-	if (g5_pmode_cur == speed_mode)
-		return 0;
+static struct pmf_function *pfunc_set_vdnap0;
+static struct pmf_function *pfunc_vdnap0_complete;
 
-	down(&g5_switch_mutex);
+static void g5_vdnap_switch_volt(int speed_mode)
+{
+	struct pmf_args args;
+	u32 slew, done = 0;
+	unsigned long timeout;
+
+	slew = (speed_mode == CPUFREQ_LOW) ? 1 : 0;
+	args.count = 1;
+	args.u[0].p = &slew;
+
+	pmf_call_one(pfunc_set_vdnap0, &args);
+
+	/* It's an irq GPIO so we should be able to just block here,
+	 * I'll do that later after I've properly tested the IRQ code for
+	 * platform functions
+	 */
+	timeout = jiffies + HZ/10;
+	while(!time_after(jiffies, timeout)) {
+		args.count = 1;
+		args.u[0].p = &done;
+		pmf_call_one(pfunc_vdnap0_complete, &args);
+		if (done)
+			break;
+		msleep(1);
+	}
+	if (done == 0)
+		printk(KERN_WARNING "cpufreq: Timeout in clock slewing !\n");
+}
 
-	freqs.old = g5_cpu_freqs[g5_pmode_cur].frequency;
-	freqs.new = g5_cpu_freqs[speed_mode].frequency;
-	freqs.cpu = 0;
 
-	cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
+/*
+ * SCOM based frequency switching for 970FX rev3
+ */
+static int g5_scom_switch_freq(int speed_mode)
+{
+	unsigned long flags;
+	int to;
 
 	/* If frequency is going up, first ramp up the voltage */
 	if (speed_mode < g5_pmode_cur)
 		g5_switch_volt(speed_mode);
 
+	local_irq_save(flags);
+
 	/* Clear PCR high */
 	scom970_write(SCOM_PCR, 0);
 	/* Clear PCR low */
@@ -147,6 +185,8 @@ static int g5_switch_freq(int speed_mode
 		udelay(100);
 	}
 
+	local_irq_restore(flags);
+
 	/* If frequency is going down, last ramp the voltage */
 	if (speed_mode > g5_pmode_cur)
 		g5_switch_volt(speed_mode);
@@ -154,14 +194,10 @@ static int g5_switch_freq(int speed_mode
 	g5_pmode_cur = speed_mode;
 	ppc_proc_freq = g5_cpu_freqs[speed_mode].frequency * 1000ul;
 
-	cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
-
-	up(&g5_switch_mutex);
-
 	return 0;
 }
 
-static int g5_query_freq(void)
+static int g5_scom_query_freq(void)
 {
 	unsigned long psr = scom970_read(SCOM_PSR);
 	int i;
@@ -173,7 +209,104 @@ static int g5_query_freq(void)
 	return i;
 }
 
-/* ----------------- cpufreq bookkeeping */
+/*
+ * Platform function based voltage switching for PowerMac7,2 & 7,3
+ */
+
+static struct pmf_function *pfunc_cpu0_volt_high;
+static struct pmf_function *pfunc_cpu0_volt_low;
+static struct pmf_function *pfunc_cpu1_volt_high;
+static struct pmf_function *pfunc_cpu1_volt_low;
+
+static void g5_pfunc_switch_volt(int speed_mode)
+{
+	if (speed_mode == CPUFREQ_HIGH) {
+		if (pfunc_cpu0_volt_high)
+			pmf_call_one(pfunc_cpu0_volt_high, NULL);
+		if (pfunc_cpu1_volt_high)
+			pmf_call_one(pfunc_cpu1_volt_high, NULL);
+	} else {
+		if (pfunc_cpu0_volt_low)
+			pmf_call_one(pfunc_cpu0_volt_low, NULL);
+		if (pfunc_cpu1_volt_low)
+			pmf_call_one(pfunc_cpu1_volt_low, NULL);
+	}
+	msleep(10); /* should be faster , to fix */
+}
+
+/*
+ * Platform function based frequency switching for PowerMac7,2 & 7,3
+ */
+
+static struct pmf_function *pfunc_cpu_setfreq_high;
+static struct pmf_function *pfunc_cpu_setfreq_low;
+static struct pmf_function *pfunc_cpu_getfreq;
+static struct pmf_function *pfunc_slewing_done;;
+
+static int g5_pfunc_switch_freq(int speed_mode)
+{
+	struct pmf_args args;
+	u32 done = 0;
+	unsigned long timeout;
+
+	/* If frequency is going up, first ramp up the voltage */
+	if (speed_mode < g5_pmode_cur)
+		g5_switch_volt(speed_mode);
+
+	/* Do it */
+	if (speed_mode == CPUFREQ_HIGH)
+		pmf_call_one(pfunc_cpu_setfreq_high, NULL);
+	else
+		pmf_call_one(pfunc_cpu_setfreq_low, NULL);
+
+	/* It's an irq GPIO so we should be able to just block here,
+	 * I'll do that later after I've properly tested the IRQ code for
+	 * platform functions
+	 */
+	timeout = jiffies + HZ/10;
+	while(!time_after(jiffies, timeout)) {
+		args.count = 1;
+		args.u[0].p = &done;
+		pmf_call_one(pfunc_slewing_done, &args);
+		if (done)
+			break;
+		msleep(1);
+	}
+	if (done == 0)
+		printk(KERN_WARNING "cpufreq: Timeout in clock slewing !\n");
+
+	/* If frequency is going down, last ramp the voltage */
+	if (speed_mode > g5_pmode_cur)
+		g5_switch_volt(speed_mode);
+
+	g5_pmode_cur = speed_mode;
+	ppc_proc_freq = g5_cpu_freqs[speed_mode].frequency * 1000ul;
+
+	return 0;
+}
+
+static int g5_pfunc_query_freq(void)
+{
+	struct pmf_args args;
+	u32 val = 0;
+
+	args.count = 1;
+	args.u[0].p = &val;
+	pmf_call_one(pfunc_cpu_getfreq, &args);
+	return val ? CPUFREQ_HIGH : CPUFREQ_LOW;
+}
+
+/*
+ * Fake voltage switching for platforms with missing support
+ */
+
+static void g5_dummy_switch_volt(int speed_mode)
+{
+}
+
+/*
+ * Common interface to the cpufreq core
+ */
 
 static int g5_cpufreq_verify(struct cpufreq_policy *policy)
 {
@@ -183,13 +316,30 @@ static int g5_cpufreq_verify(struct cpuf
 static int g5_cpufreq_target(struct cpufreq_policy *policy,
 	unsigned int target_freq, unsigned int relation)
 {
-	unsigned int    newstate = 0;
+	unsigned int newstate = 0;
+	struct cpufreq_freqs freqs;
+	int rc;
 
 	if (cpufreq_frequency_table_target(policy, g5_cpu_freqs,
 			target_freq, relation, &newstate))
 		return -EINVAL;
 
-	return g5_switch_freq(newstate);
+	if (g5_pmode_cur == newstate)
+		return 0;
+
+	down(&g5_switch_mutex);
+
+	freqs.old = g5_cpu_freqs[g5_pmode_cur].frequency;
+	freqs.new = g5_cpu_freqs[newstate].frequency;
+	freqs.cpu = 0;
+
+	cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
+	rc = g5_switch_freq(newstate);
+	cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
+
+	up(&g5_switch_mutex);
+
+	return rc;
 }
 
 static unsigned int g5_cpufreq_get_speed(unsigned int cpu)
@@ -205,6 +355,7 @@ static int g5_cpufreq_cpu_init(struct cp
 	policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
 	policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
 	policy->cur = g5_cpu_freqs[g5_query_freq()].frequency;
+	policy->cpus = cpu_possible_map;
 	cpufreq_frequency_table_get_attr(g5_cpu_freqs, policy->cpu);
 
 	return cpufreq_frequency_table_cpuinfo(policy,
@@ -224,19 +375,39 @@ static struct cpufreq_driver g5_cpufreq_
 };
 
 
-static int __init g5_cpufreq_init(void)
+static int __init g5_neo2_cpufreq_init(struct device_node *cpus)
 {
 	struct device_node *cpunode;
 	unsigned int psize, ssize;
-	struct smu_sdbp_header *shdr;
 	unsigned long max_freq;
-	u32 *valp;
+	char *freq_method, *volt_method;
+	u32 *valp, pvr_hi;
+	int use_volts_vdnap = 0;
+	int use_volts_smu = 0;
 	int rc = -ENODEV;
 
-	/* Look for CPU and SMU nodes */
-	cpunode = of_find_node_by_type(NULL, "cpu");
-	if (!cpunode) {
-		DBG("No CPU node !\n");
+	/* Check supported platforms */
+	if (machine_is_compatible("PowerMac8,1") ||
+	    machine_is_compatible("PowerMac8,2") ||
+	    machine_is_compatible("PowerMac9,1"))
+		use_volts_smu = 1;
+	else if (machine_is_compatible("PowerMac11,2"))
+		use_volts_vdnap = 1;
+	else
+		return -ENODEV;
+
+	/* Get first CPU node */
+	for (cpunode = NULL;
+	     (cpunode = of_get_next_child(cpus, cpunode)) != NULL;) {
+		u32 *reg =
+			(u32 *)get_property(cpunode, "reg", NULL);
+		if (reg == NULL || (*reg) != 0)
+			continue;
+		if (!strcmp(cpunode->type, "cpu"))
+			break;
+	}
+	if (cpunode == NULL) {
+		printk(KERN_ERR "cpufreq: Can't find any CPU 0 node\n");
 		return -ENODEV;
 	}
 
@@ -246,8 +417,9 @@ static int __init g5_cpufreq_init(void)
 		DBG("No cpu-version property !\n");
 		goto bail_noprops;
 	}
-	if (((*valp) >> 16) != 0x3c) {
-		DBG("Wrong CPU version: %08x\n", *valp);
+	pvr_hi = (*valp) >> 16;
+	if (pvr_hi != 0x3c && pvr_hi != 0x44) {
+		printk(KERN_ERR "cpufreq: Unsupported CPU version\n");
 		goto bail_noprops;
 	}
 
@@ -259,18 +431,50 @@ static int __init g5_cpufreq_init(void)
 	}
 	g5_pmode_max = psize / sizeof(u32) - 1;
 
-	/* Look for the FVT table */
-	shdr = smu_get_sdb_partition(SMU_SDB_FVT_ID, NULL);
-	if (!shdr)
-		goto bail_noprops;
-	g5_fvt_table = (struct smu_sdbp_fvt *)&shdr[1];
-	ssize = (shdr->len * sizeof(u32)) - sizeof(struct smu_sdbp_header);
-	g5_fvt_count = ssize / sizeof(struct smu_sdbp_fvt);
-	g5_fvt_cur = 0;
+	if (use_volts_smu) {
+		struct smu_sdbp_header *shdr;
 
-	/* Sanity checking */
-	if (g5_fvt_count < 1 || g5_pmode_max < 1)
-		goto bail_noprops;
+		/* Look for the FVT table */
+		shdr = smu_get_sdb_partition(SMU_SDB_FVT_ID, NULL);
+		if (!shdr)
+			goto bail_noprops;
+		g5_fvt_table = (struct smu_sdbp_fvt *)&shdr[1];
+		ssize = (shdr->len * sizeof(u32)) -
+			sizeof(struct smu_sdbp_header);
+		g5_fvt_count = ssize / sizeof(struct smu_sdbp_fvt);
+		g5_fvt_cur = 0;
+
+		/* Sanity checking */
+		if (g5_fvt_count < 1 || g5_pmode_max < 1)
+			goto bail_noprops;
+
+		g5_switch_volt = g5_smu_switch_volt;
+		volt_method = "SMU";
+	} else if (use_volts_vdnap) {
+		struct device_node *root;
+
+		root = of_find_node_by_path("/");
+		if (root == NULL) {
+			printk(KERN_ERR "cpufreq: Can't find root of "
+			       "device tree\n");
+			goto bail_noprops;
+		}
+		pfunc_set_vdnap0 = pmf_find_function(root, "set-vdnap0");
+		pfunc_vdnap0_complete =
+			pmf_find_function(root, "slewing-done");
+		if (pfunc_set_vdnap0 == NULL ||
+		    pfunc_vdnap0_complete == NULL) {
+			printk(KERN_ERR "cpufreq: Can't find required "
+			       "platform function\n");
+			goto bail_noprops;
+		}
+
+		g5_switch_volt = g5_vdnap_switch_volt;
+		volt_method = "GPIO";
+	} else {
+		g5_switch_volt = g5_dummy_switch_volt;
+		volt_method = "none";
+	}
 
 	/*
 	 * From what I see, clock-frequency is always the maximal frequency.
@@ -286,19 +490,23 @@ static int __init g5_cpufreq_init(void)
 	g5_cpu_freqs[0].frequency = max_freq;
 	g5_cpu_freqs[1].frequency = max_freq/2;
 
-	/* Check current frequency */
-	g5_pmode_cur = g5_query_freq();
-	if (g5_pmode_cur > 1)
-		/* We don't support anything but 1:1 and 1:2, fixup ... */
-		g5_pmode_cur = 1;
+	/* Set callbacks */
+	g5_switch_freq = g5_scom_switch_freq;
+	g5_query_freq = g5_scom_query_freq;
+	freq_method = "SCOM";
 
 	/* Force apply current frequency to make sure everything is in
 	 * sync (voltage is right for example). Firmware may leave us with
 	 * a strange setting ...
 	 */
-	g5_switch_freq(g5_pmode_cur);
+	g5_switch_volt(CPUFREQ_HIGH);
+	msleep(10);
+	g5_pmode_cur = -1;
+	g5_switch_freq(g5_query_freq());
 
 	printk(KERN_INFO "Registering G5 CPU frequency driver\n");
+	printk(KERN_INFO "Frequency method: %s, Voltage method: %s\n",
+	       freq_method, volt_method);
 	printk(KERN_INFO "Low: %d Mhz, High: %d Mhz, Cur: %d MHz\n",
 		g5_cpu_freqs[1].frequency/1000,
 		g5_cpu_freqs[0].frequency/1000,
@@ -317,6 +525,200 @@ static int __init g5_cpufreq_init(void)
 	return rc;
 }
 
+static int __init g5_pm72_cpufreq_init(struct device_node *cpus)
+{
+	struct device_node *cpuid = NULL, *hwclock = NULL, *cpunode = NULL;
+	u8 *eeprom = NULL;
+	u32 *valp;
+	u64 max_freq, min_freq, ih, il;
+	int has_volt = 1, rc = 0;
+
+	/* Get first CPU node */
+	for (cpunode = NULL;
+	     (cpunode = of_get_next_child(cpus, cpunode)) != NULL;) {
+		if (!strcmp(cpunode->type, "cpu"))
+			break;
+	}
+	if (cpunode == NULL) {
+		printk(KERN_ERR "cpufreq: Can't find any CPU node\n");
+		return -ENODEV;
+	}
+
+	/* Lookup the cpuid eeprom node */
+        cpuid = of_find_node_by_path("/u3@0,f8000000/i2c@f8001000/cpuid@a0");
+	if (cpuid != NULL)
+		eeprom = (u8 *)get_property(cpuid, "cpuid", NULL);
+	if (eeprom == NULL) {
+		printk(KERN_ERR "cpufreq: Can't find cpuid EEPROM !\n");
+		rc = -ENODEV;
+		goto bail;
+	}
+
+	/* Lookup the i2c hwclock */
+	for (hwclock = NULL;
+	     (hwclock = of_find_node_by_name(hwclock, "i2c-hwclock")) != NULL;){
+		char *loc = get_property(hwclock, "hwctrl-location", NULL);
+		if (loc == NULL)
+			continue;
+		if (strcmp(loc, "CPU CLOCK"))
+			continue;
+		if (!get_property(hwclock, "platform-get-frequency", NULL))
+			continue;
+		break;
+	}
+	if (hwclock == NULL) {
+		printk(KERN_ERR "cpufreq: Can't find i2c clock chip !\n");
+		rc = -ENODEV;
+		goto bail;
+	}
+
+	DBG("cpufreq: i2c clock chip found: %s\n", hwclock->full_name);
+
+	/* Now get all the platform functions */
+	pfunc_cpu_getfreq =
+		pmf_find_function(hwclock, "get-frequency");
+	pfunc_cpu_setfreq_high =
+		pmf_find_function(hwclock, "set-frequency-high");
+	pfunc_cpu_setfreq_low =
+		pmf_find_function(hwclock, "set-frequency-low");
+	pfunc_slewing_done =
+		pmf_find_function(hwclock, "slewing-done");
+	pfunc_cpu0_volt_high =
+		pmf_find_function(hwclock, "set-voltage-high-0");
+	pfunc_cpu0_volt_low =
+		pmf_find_function(hwclock, "set-voltage-low-0");
+	pfunc_cpu1_volt_high =
+		pmf_find_function(hwclock, "set-voltage-high-1");
+	pfunc_cpu1_volt_low =
+		pmf_find_function(hwclock, "set-voltage-low-1");
+
+	/* Check we have minimum requirements */
+	if (pfunc_cpu_getfreq == NULL || pfunc_cpu_setfreq_high == NULL ||
+	    pfunc_cpu_setfreq_low == NULL || pfunc_slewing_done == NULL) {
+		printk(KERN_ERR "cpufreq: Can't find platform functions !\n");
+		rc = -ENODEV;
+		goto bail;
+	}
+
+	/* Check that we have complete sets */
+	if (pfunc_cpu0_volt_high == NULL || pfunc_cpu0_volt_low == NULL) {
+		pmf_put_function(pfunc_cpu0_volt_high);
+		pmf_put_function(pfunc_cpu0_volt_low);
+		pfunc_cpu0_volt_high = pfunc_cpu0_volt_low = NULL;
+		has_volt = 0;
+	}
+	if (!has_volt ||
+	    pfunc_cpu1_volt_high == NULL || pfunc_cpu1_volt_low == NULL) {
+		pmf_put_function(pfunc_cpu1_volt_high);
+		pmf_put_function(pfunc_cpu1_volt_low);
+		pfunc_cpu1_volt_high = pfunc_cpu1_volt_low = NULL;
+	}
+
+	/* Note: The device tree also contains a "platform-set-values"
+	 * function for which I haven't quite figured out the usage. It
+	 * might have to be called on init and/or wakeup, I'm not too sure
+	 * but things seem to work fine without it so far ...
+	 */
+
+	/* Get max frequency from device-tree */
+	valp = (u32 *)get_property(cpunode, "clock-frequency", NULL);
+	if (!valp) {
+		printk(KERN_ERR "cpufreq: Can't find CPU frequency !\n");
+		rc = -ENODEV;
+		goto bail;
+	}
+
+	max_freq = (*valp)/1000;
+
+	/* Now calculate reduced frequency by using the cpuid input freq
+	 * ratio. This requires 64 bits math unless we are willing to lose
+	 * some precision
+	 */
+	ih = *((u32 *)(eeprom + 0x10));
+	il = *((u32 *)(eeprom + 0x20));
+	min_freq = 0;
+	if (ih != 0 && il != 0)
+		min_freq = (max_freq * il) / ih;
+
+	/* Sanity check */
+	if (min_freq >= max_freq || min_freq < 1000) {
+		printk(KERN_ERR "cpufreq: Can't calculate low frequency !\n");
+		rc = -ENODEV;
+		goto bail;
+	}
+	g5_cpu_freqs[0].frequency = max_freq;
+	g5_cpu_freqs[1].frequency = min_freq;
+
+	/* Set callbacks */
+	g5_switch_volt = g5_pfunc_switch_volt;
+	g5_switch_freq = g5_pfunc_switch_freq;
+	g5_query_freq = g5_pfunc_query_freq;
+
+	/* Force apply current frequency to make sure everything is in
+	 * sync (voltage is right for example). Firmware may leave us with
+	 * a strange setting ...
+	 */
+	g5_switch_volt(CPUFREQ_HIGH);
+	msleep(10);
+	g5_pmode_cur = -1;
+	g5_switch_freq(g5_query_freq());
+
+	printk(KERN_INFO "Registering G5 CPU frequency driver\n");
+	printk(KERN_INFO "Frequency method: i2c/pfunc, "
+	       "Voltage method: %s\n", has_volt ? "i2c/pfunc" : "none");
+	printk(KERN_INFO "Low: %d Mhz, High: %d Mhz, Cur: %d MHz\n",
+		g5_cpu_freqs[1].frequency/1000,
+		g5_cpu_freqs[0].frequency/1000,
+		g5_cpu_freqs[g5_pmode_cur].frequency/1000);
+
+	rc = cpufreq_register_driver(&g5_cpufreq_driver);
+ bail:
+	if (rc != 0) {
+		pmf_put_function(pfunc_cpu_getfreq);
+		pmf_put_function(pfunc_cpu_setfreq_high);
+		pmf_put_function(pfunc_cpu_setfreq_low);
+		pmf_put_function(pfunc_slewing_done);
+		pmf_put_function(pfunc_cpu0_volt_high);
+		pmf_put_function(pfunc_cpu0_volt_low);
+		pmf_put_function(pfunc_cpu1_volt_high);
+		pmf_put_function(pfunc_cpu1_volt_low);
+	}
+	of_node_put(hwclock);
+	of_node_put(cpuid);
+	of_node_put(cpunode);
+
+	return rc;
+}
+
+static int __init g5_rm31_cpufreq_init(struct device_node *cpus)
+{
+	/* NYI */
+	return 0;
+}
+
+static int __init g5_cpufreq_init(void)
+{
+	struct device_node *cpus;
+	int rc;
+
+	cpus = of_find_node_by_path("/cpus");
+	if (cpus == NULL) {
+		DBG("No /cpus node !\n");
+		return -ENODEV;
+	}
+
+	if (machine_is_compatible("PowerMac7,2") ||
+	    machine_is_compatible("PowerMac7,3"))
+		rc = g5_pm72_cpufreq_init(cpus);
+	else if (machine_is_compatible("RackMac3,1"))
+		rc = g5_rm31_cpufreq_init(cpus);
+	else
+		rc = g5_neo2_cpufreq_init(cpus);
+
+	of_node_put(cpus);
+	return rc;
+}
+
 module_init(g5_cpufreq_init);
 
 

^ permalink raw reply

* [PATCH] 3/5 powerpc: Add platform functions interpreter
From: Benjamin Herrenschmidt @ 2006-01-07  0:41 UTC (permalink / raw)
  To: linuxppc-dev list, linuxppc64-dev

This is the platform function interpreter itself along with the backends
for UniN/U3/U4, mac-io, GPIOs and i2c. It adds the ability to execute
those do-platform-* scripts in the device-tree (at least for most
devices for which a backend is provided). This should replace the clock
spreading hacks properly. It might also have an impact on all sort of
machines since some of the scripts marked "at init" will now be executed
on boot (or some other on sleep/wakeup), those will possibly do things
that the kernel didn't do at all, like setting some values into some i2c
devices (changing thermal sensor calibration or conversion rate) etc...
Thus regression testing is MUCH welcome. Also loook for errors in dmesg.
That's also why I've left rather verbose debugging enabled in this
version of the patch.

(I do expect some Windtunnel G4s to show some errors as they have an i2c
clock chip on the PMU bus that uses some primitives that the i2c backend
doesn't implement yet. I really need users that have one of those
machine to come back to me so we can get that done right, though the
errors themselves should be harmless, I suspect the machine might not
run at full speed).

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

Index: linux-work/include/asm-powerpc/pmac_pfunc.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-work/include/asm-powerpc/pmac_pfunc.h	2006-01-07 10:54:03.000000000 +1100
@@ -0,0 +1,253 @@
+#ifndef __PMAC_PFUNC_H__
+#define __PMAC_PFUNC_H__
+
+#include <linux/types.h>
+#include <linux/list.h>
+
+/* Flags in command lists */
+#define PMF_FLAGS_ON_INIT		0x80000000u
+#define PMF_FLGAS_ON_TERM		0x40000000u
+#define PMF_FLAGS_ON_SLEEP		0x20000000u
+#define PMF_FLAGS_ON_WAKE		0x10000000u
+#define PMF_FLAGS_ON_DEMAND		0x08000000u
+#define PMF_FLAGS_INT_GEN		0x04000000u
+#define PMF_FLAGS_HIGH_SPEED		0x02000000u
+#define PMF_FLAGS_LOW_SPEED		0x01000000u
+#define PMF_FLAGS_SIDE_EFFECTS		0x00800000u
+
+/*
+ * Arguments to a platform function call.
+ *
+ * NOTE: By convention, pointer arguments point to an u32
+ */
+struct pmf_args {
+	union {
+		u32 v;
+		u32 *p;
+	} u[4];
+	unsigned int count;
+};
+
+/*
+ * A driver capable of interpreting commands provides a handlers
+ * structure filled with whatever handlers are implemented by this
+ * driver. Non implemented handlers are left NULL.
+ *
+ * PMF_STD_ARGS are the same arguments that are passed to the parser
+ * and that gets passed back to the various handlers.
+ *
+ * Interpreting a given function always start with a begin() call which
+ * returns an instance data to be passed around subsequent calls, and
+ * ends with an end() call. This allows the low level driver to implement
+ * locking policy or per-function instance data.
+ *
+ * For interrupt capable functions, irq_enable() is called when a client
+ * registers, and irq_disable() is called when the last client unregisters
+ * Note that irq_enable & irq_disable are called within a semaphore held
+ * by the core, thus you should not try to register yourself to some other
+ * pmf interrupt during those calls.
+ */
+
+#define PMF_STD_ARGS	struct pmf_function *func, void *instdata, \
+		        struct pmf_args *args
+
+struct pmf_function;
+
+struct pmf_handlers {
+	void * (*begin)(struct pmf_function *func, struct pmf_args *args);
+	void (*end)(struct pmf_function *func, void *instdata);
+
+	int (*irq_enable)(struct pmf_function *func);
+	int (*irq_disable)(struct pmf_function *func);
+
+	int (*write_gpio)(PMF_STD_ARGS, u8 value, u8 mask);
+	int (*read_gpio)(PMF_STD_ARGS, u8 mask, int rshift, u8 xor);
+
+	int (*write_reg32)(PMF_STD_ARGS, u32 offset, u32 value, u32 mask);
+	int (*read_reg32)(PMF_STD_ARGS, u32 offset);
+	int (*write_reg16)(PMF_STD_ARGS, u32 offset, u16 value, u16 mask);
+	int (*read_reg16)(PMF_STD_ARGS, u32 offset);
+	int (*write_reg8)(PMF_STD_ARGS, u32 offset, u8 value, u8 mask);
+	int (*read_reg8)(PMF_STD_ARGS, u32 offset);
+
+	int (*delay)(PMF_STD_ARGS, u32 duration);
+
+	int (*wait_reg32)(PMF_STD_ARGS, u32 offset, u32 value, u32 mask);
+	int (*wait_reg16)(PMF_STD_ARGS, u32 offset, u16 value, u16 mask);
+	int (*wait_reg8)(PMF_STD_ARGS, u32 offset, u8 value, u8 mask);
+
+	int (*read_i2c)(PMF_STD_ARGS, u32 len);
+	int (*write_i2c)(PMF_STD_ARGS, u32 len, const u8 *data);
+	int (*rmw_i2c)(PMF_STD_ARGS, u32 masklen, u32 valuelen, u32 totallen,
+		       const u8 *maskdata, const u8 *valuedata);
+
+	int (*read_cfg)(PMF_STD_ARGS, u32 offset, u32 len);
+	int (*write_cfg)(PMF_STD_ARGS, u32 offset, u32 len, const u8 *data);
+	int (*rmw_cfg)(PMF_STD_ARGS, u32 offset, u32 masklen, u32 valuelen,
+		       u32 totallen, const u8 *maskdata, const u8 *valuedata);
+
+	int (*read_i2c_sub)(PMF_STD_ARGS, u8 subaddr, u32 len);
+	int (*write_i2c_sub)(PMF_STD_ARGS, u8 subaddr, u32 len, const u8 *data);
+	int (*set_i2c_mode)(PMF_STD_ARGS, int mode);
+	int (*rmw_i2c_sub)(PMF_STD_ARGS, u8 subaddr, u32 masklen, u32 valuelen,
+			   u32 totallen, const u8 *maskdata,
+			   const u8 *valuedata);
+
+	int (*read_reg32_msrx)(PMF_STD_ARGS, u32 offset, u32 mask, u32 shift,
+			       u32 xor);
+	int (*read_reg16_msrx)(PMF_STD_ARGS, u32 offset, u32 mask, u32 shift,
+			       u32 xor);
+	int (*read_reg8_msrx)(PMF_STD_ARGS, u32 offset, u32 mask, u32 shift,
+			      u32 xor);
+
+	int (*write_reg32_slm)(PMF_STD_ARGS, u32 offset, u32 shift, u32 mask);
+	int (*write_reg16_slm)(PMF_STD_ARGS, u32 offset, u32 shift, u32 mask);
+	int (*write_reg8_slm)(PMF_STD_ARGS, u32 offset, u32 shift, u32 mask);
+
+	int (*mask_and_compare)(PMF_STD_ARGS, u32 len, const u8 *maskdata,
+				const u8 *valuedata);
+
+	struct module *owner;
+};
+
+
+/*
+ * Drivers who expose platform functions register at init time, this
+ * causes the platform functions for that device node to be parsed in
+ * advance and associated with the device. The data structures are
+ * partially public so a driver can walk the list of platform functions
+ * and eventually inspect the flags
+ */
+struct pmf_device;
+
+struct pmf_function {
+	/* All functions for a given driver are linked */
+	struct list_head	link;
+
+	/* Function node & driver data */
+	struct device_node	*node;
+	void			*driver_data;
+
+	/* For internal use by core */
+	struct pmf_device	*dev;
+
+	/* The name is the "xxx" in "platform-do-xxx", this is how
+	 * platform functions are identified by this code. Some functions
+	 * only operate for a given target, in which case the phandle is
+	 * here (or 0 if the filter doesn't apply)
+	 */
+	const char		*name;
+	u32			phandle;
+
+	/* The flags for that function. You can have several functions
+	 * with the same name and different flag
+	 */
+	u32			flags;
+
+	/* The actual tokenized function blob */
+	const void		*data;
+	unsigned int		length;
+
+	/* Interrupt clients */
+	struct list_head	irq_clients;
+
+	/* Refcounting */
+	struct kref		ref;
+};
+
+/*
+ * For platform functions that are interrupts, one can register
+ * irq_client structures. You canNOT use the same structure twice
+ * as it contains a link member. Also, the callback is called with
+ * a spinlock held, you must not call back into any of the pmf_* functions
+ * from within that callback
+ */
+struct pmf_irq_client {
+	void			(*handler)(void *data);
+	void			*data;
+	struct module		*owner;
+	struct list_head	link;
+};
+
+
+/*
+ * Register/Unregister a function-capable driver and its handlers
+ */
+extern int pmf_register_driver(struct device_node *np,
+			      struct pmf_handlers *handlers,
+			      void *driverdata);
+
+extern void pmf_unregister_driver(struct device_node *np);
+
+
+/*
+ * Register/Unregister interrupt clients
+ */
+extern int pmf_register_irq_client(struct device_node *np,
+				   const char *name,
+				   struct pmf_irq_client *client);
+
+extern void pmf_unregister_irq_client(struct device_node *np,
+				      const char *name,
+				      struct pmf_irq_client *client);
+
+/*
+ * Called by the handlers when an irq happens
+ */
+extern void pmf_do_irq(struct pmf_function *func);
+
+
+/*
+ * Low level call to platform functions.
+ *
+ * The phandle can filter on the target object for functions that have
+ * multiple targets, the flags allow you to restrict the call to a given
+ * combination of flags.
+ *
+ * The args array contains as many arguments as is required by the function,
+ * this is dependent on the function you are calling, unfortunately Apple
+ * mecanism provides no way to encode that so you have to get it right at
+ * the call site. Some functions require no args, in which case, you can
+ * pass NULL.
+ *
+ * You can also pass NULL to the name. This will match any function that has
+ * the appropriate combination of flags & phandle or you can pass 0 to the
+ * phandle to match any
+ */
+extern int pmf_do_functions(struct device_node *np, const char *name,
+			    u32 phandle, u32 flags, struct pmf_args *args);
+
+
+
+/*
+ * High level call to a platform function.
+ *
+ * This one looks for the platform-xxx first so you should call it to the
+ * actual target if any. It will fallback to platform-do-xxx if it can't
+ * find one. It will also exclusively target functions that have
+ * the "OnDemand" flag.
+ */
+
+extern int pmf_call_function(struct device_node *target, const char *name,
+			     struct pmf_args *args);
+
+
+/*
+ * For low latency interrupt usage, you can lookup for on-demand functions
+ * using the functions below
+ */
+
+extern struct pmf_function *pmf_find_function(struct device_node *target,
+					      const char *name);
+
+extern struct pmf_function * pmf_get_function(struct pmf_function *func);
+extern void pmf_put_function(struct pmf_function *func);
+
+extern int pmf_call_one(struct pmf_function *func, struct pmf_args *args);
+
+
+/* Suspend/resume code called by via-pmu directly for now */
+extern void pmac_pfunc_base_suspend(void);
+extern void pmac_pfunc_base_resume(void);
+
+#endif /* __PMAC_PFUNC_H__ */
Index: linux-work/arch/powerpc/platforms/powermac/Makefile
===================================================================
--- linux-work.orig/arch/powerpc/platforms/powermac/Makefile	2006-01-07 10:53:21.000000000 +1100
+++ linux-work/arch/powerpc/platforms/powermac/Makefile	2006-01-07 10:54:03.000000000 +1100
@@ -1,7 +1,8 @@
 CFLAGS_bootx_init.o  		+= -fPIC
 
 obj-y				+= pic.o setup.o time.o feature.o pci.o \
-				   sleep.o low_i2c.o cache.o
+				   sleep.o low_i2c.o cache.o pfunc_core.o \
+				   pfunc_base.o
 obj-$(CONFIG_PMAC_BACKLIGHT)	+= backlight.o
 obj-$(CONFIG_CPU_FREQ_PMAC)	+= cpufreq_32.o
 obj-$(CONFIG_CPU_FREQ_PMAC64)	+= cpufreq_64.o
Index: linux-work/arch/powerpc/platforms/powermac/feature.c
===================================================================
--- linux-work.orig/arch/powerpc/platforms/powermac/feature.c	2006-01-07 10:53:21.000000000 +1100
+++ linux-work/arch/powerpc/platforms/powermac/feature.c	2006-01-07 10:54:03.000000000 +1100
@@ -58,12 +58,11 @@ extern int powersave_lowspeed;
 extern int powersave_nap;
 extern struct device_node *k2_skiplist[2];
 
-
 /*
  * We use a single global lock to protect accesses. Each driver has
  * to take care of its own locking
  */
-static DEFINE_SPINLOCK(feature_lock);
+DEFINE_SPINLOCK(feature_lock);
 
 #define LOCK(flags)	spin_lock_irqsave(&feature_lock, flags);
 #define UNLOCK(flags)	spin_unlock_irqrestore(&feature_lock, flags);
@@ -106,22 +105,12 @@ static const char *macio_names[] =
 };
 
 
+struct device_node *uninorth_node;
+u32 __iomem *uninorth_base;
 
-/*
- * Uninorth reg. access. Note that Uni-N regs are big endian
- */
-
-#define UN_REG(r)	(uninorth_base + ((r) >> 2))
-#define UN_IN(r)	(in_be32(UN_REG(r)))
-#define UN_OUT(r,v)	(out_be32(UN_REG(r), (v)))
-#define UN_BIS(r,v)	(UN_OUT((r), UN_IN(r) | (v)))
-#define UN_BIC(r,v)	(UN_OUT((r), UN_IN(r) & ~(v)))
-
-static struct device_node *uninorth_node;
-static u32 __iomem *uninorth_base;
 static u32 uninorth_rev;
 static int uninorth_maj;
-static void __iomem *u3_ht;
+static void __iomem *u3_ht_base;
 
 /*
  * For each motherboard family, we have a table of functions pointers
@@ -1560,8 +1549,10 @@ void g5_phy_disable_cpu1(void)
 
 #ifndef CONFIG_POWER4
 
-static void
-keylargo_shutdown(struct macio_chip *macio, int sleep_mode)
+
+#ifdef CONFIG_PM
+
+static void keylargo_shutdown(struct macio_chip *macio, int sleep_mode)
 {
 	u32 temp;
 
@@ -1614,8 +1605,7 @@ keylargo_shutdown(struct macio_chip *mac
 	(void)MACIO_IN32(KEYLARGO_FCR0); mdelay(1);
 }
 
-static void
-pangea_shutdown(struct macio_chip *macio, int sleep_mode)
+static void pangea_shutdown(struct macio_chip *macio, int sleep_mode)
 {
 	u32 temp;
 
@@ -1648,8 +1638,7 @@ pangea_shutdown(struct macio_chip *macio
 	(void)MACIO_IN32(KEYLARGO_FCR0); mdelay(1);
 }
 
-static void
-intrepid_shutdown(struct macio_chip *macio, int sleep_mode)
+static void intrepid_shutdown(struct macio_chip *macio, int sleep_mode)
 {
 	u32 temp;
 
@@ -1833,6 +1822,8 @@ core99_wake_up(void)
 	return 0;
 }
 
+#endif /* CONFIG_PM */
+
 static long
 core99_sleep_state(struct device_node *node, long param, long value)
 {
@@ -1854,10 +1845,13 @@ core99_sleep_state(struct device_node *n
 	if ((pmac_mb.board_flags & PMAC_MB_CAN_SLEEP) == 0)
 		return -EPERM;
 
+#ifdef CONFIG_PM
 	if (value == 1)
 		return core99_sleep();
 	else if (value == 0)
 		return core99_wake_up();
+
+#endif /* CONFIG_PM */
 	return 0;
 }
 
@@ -1981,7 +1975,9 @@ static struct feature_table_entry core99
 	{ PMAC_FTR_USB_ENABLE,		core99_usb_enable },
 	{ PMAC_FTR_1394_ENABLE,		core99_firewire_enable },
 	{ PMAC_FTR_1394_CABLE_POWER,	core99_firewire_cable_power },
+#ifdef CONFIG_PM
 	{ PMAC_FTR_SLEEP_STATE,		core99_sleep_state },
+#endif
 #ifdef CONFIG_SMP
 	{ PMAC_FTR_RESET_CPU,		core99_reset_cpu },
 #endif /* CONFIG_SMP */
@@ -2572,7 +2568,7 @@ static void __init probe_uninorth(void)
 	uninorth_base = ioremap(address, 0x40000);
 	uninorth_rev = in_be32(UN_REG(UNI_N_VERSION));
 	if (uninorth_maj == 3 || uninorth_maj == 4)
-		u3_ht = ioremap(address + U3_HT_CONFIG_BASE, 0x1000);
+		u3_ht_base = ioremap(address + U3_HT_CONFIG_BASE, 0x1000);
 
 	printk(KERN_INFO "Found %s memory controller & host bridge"
 	       " @ 0x%08x revision: 0x%02x\n", uninorth_maj == 3 ? "U3" :
@@ -2921,9 +2917,9 @@ void __init pmac_check_ht_link(void)
 	u8	px_bus, px_devfn;
 	struct pci_controller *px_hose;
 
-	(void)in_be32(u3_ht + U3_HT_LINK_COMMAND);
-	ucfg = cfg = in_be32(u3_ht + U3_HT_LINK_CONFIG);
-	ufreq = freq = in_be32(u3_ht + U3_HT_LINK_FREQ);
+	(void)in_be32(u3_ht_base + U3_HT_LINK_COMMAND);
+	ucfg = cfg = in_be32(u3_ht_base + U3_HT_LINK_CONFIG);
+	ufreq = freq = in_be32(u3_ht_base + U3_HT_LINK_FREQ);
 	dump_HT_speeds("U3 HyperTransport", cfg, freq);
 
 	pcix_node = of_find_compatible_node(NULL, "pci", "pci-x");
Index: linux-work/arch/powerpc/platforms/powermac/pfunc_base.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-work/arch/powerpc/platforms/powermac/pfunc_base.c	2006-01-07 10:54:03.000000000 +1100
@@ -0,0 +1,405 @@
+#include <linux/config.h>
+#include <linux/types.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/kernel.h>
+#include <linux/interrupt.h>
+#include <linux/spinlock.h>
+
+#include <asm/pmac_feature.h>
+#include <asm/pmac_pfunc.h>
+
+#define DBG(fmt...)	printk(fmt)
+
+static irqreturn_t macio_gpio_irq(int irq, void *data, struct pt_regs *regs)
+{
+	pmf_do_irq(data);
+
+	return IRQ_HANDLED;
+}
+
+static int macio_do_gpio_irq_enable(struct pmf_function *func)
+{
+	if (func->node->n_intrs < 1)
+		return -EINVAL;
+
+	return request_irq(func->node->intrs[0].line, macio_gpio_irq, 0,
+			   func->node->name, func);
+}
+
+static int macio_do_gpio_irq_disable(struct pmf_function *func)
+{
+	if (func->node->n_intrs < 1)
+		return -EINVAL;
+
+	free_irq(func->node->intrs[0].line, func);
+	return 0;
+}
+
+static int macio_do_gpio_write(PMF_STD_ARGS, u8 value, u8 mask)
+{
+	u8 __iomem *addr = (u8 __iomem *)func->driver_data;
+	unsigned long flags;
+	u8 tmp;
+
+	/* Check polarity */
+	if (args && args->count && !args->u[0].v)
+		value = ~value;
+
+	/* Toggle the GPIO */
+	spin_lock_irqsave(&feature_lock, flags);
+	tmp = readb(addr);
+	tmp = (tmp & ~mask) | (value & mask);
+	DBG("Do write 0x%02x to GPIO %s (%p)\n",
+	    tmp, func->node->full_name, addr);
+	writeb(tmp, addr);
+	spin_unlock_irqrestore(&feature_lock, flags);
+
+	return 0;
+}
+
+static int macio_do_gpio_read(PMF_STD_ARGS, u8 mask, int rshift, u8 xor)
+{
+	u8 __iomem *addr = (u8 __iomem *)func->driver_data;
+	u32 value;
+
+	/* Check if we have room for reply */
+	if (args == NULL || args->count == 0 || args->u[0].p == NULL)
+		return -EINVAL;
+
+	value = readb(addr);
+	*args->u[0].p = ((value & mask) >> rshift) ^ xor;
+
+	return 0;
+}
+
+static int macio_do_delay(PMF_STD_ARGS, u32 duration)
+{
+	/* assume we can sleep ! */
+	msleep((duration + 999) / 1000);
+	return 0;
+}
+
+static struct pmf_handlers macio_gpio_handlers = {
+	.irq_enable	= macio_do_gpio_irq_enable,
+	.irq_disable	= macio_do_gpio_irq_disable,
+	.write_gpio	= macio_do_gpio_write,
+	.read_gpio	= macio_do_gpio_read,
+	.delay		= macio_do_delay,
+};
+
+static void macio_gpio_init_one(struct macio_chip *macio)
+{
+	struct device_node *gparent, *gp;
+
+	/*
+	 * Find the "gpio" parent node
+	 */
+
+	for (gparent = NULL;
+	     (gparent = of_get_next_child(macio->of_node, gparent)) != NULL;)
+		if (strcmp(gparent->name, "gpio") == 0)
+			break;
+	if (gparent == NULL)
+		return;
+
+	DBG("Installing GPIO functions for macio %s\n",
+	    macio->of_node->full_name);
+
+	/*
+	 * Ok, got one, we dont need anything special to track them down, so
+	 * we just create them all
+	 */
+	for (gp = NULL; (gp = of_get_next_child(gparent, gp)) != NULL;) {
+		u32 *reg = (u32 *)get_property(gp, "reg", NULL);
+		unsigned long offset;
+		if (reg == NULL)
+			continue;
+		offset = *reg;
+		/* Deal with old style device-tree. We can safely hard code the
+		 * offset for now too even if it's a bit gross ...
+		 */
+		if (offset < 0x50)
+			offset += 0x50;
+		offset += (unsigned long)macio->base;
+		pmf_register_driver(gp, &macio_gpio_handlers, (void *)offset);
+	}
+
+	DBG("Calling initial GPIO functions for macio %s\n",
+	    macio->of_node->full_name);
+
+	/* And now we run all the init ones */
+	for (gp = NULL; (gp = of_get_next_child(gparent, gp)) != NULL;)
+		pmf_do_functions(gp, NULL, 0, PMF_FLAGS_ON_INIT, NULL);
+
+	/* Note: We do not at this point implement the "at sleep" or "at wake"
+	 * functions. I yet to find any for GPIOs anyway
+	 */
+}
+
+static int macio_do_write_reg32(PMF_STD_ARGS, u32 offset, u32 value, u32 mask)
+{
+	struct macio_chip *macio = func->driver_data;
+	unsigned long flags;
+
+	spin_lock_irqsave(&feature_lock, flags);
+	MACIO_OUT32(offset, (MACIO_IN32(offset) & ~mask) | (value & mask));
+	spin_unlock_irqrestore(&feature_lock, flags);
+	return 0;
+}
+
+static int macio_do_read_reg32(PMF_STD_ARGS, u32 offset)
+{
+	struct macio_chip *macio = func->driver_data;
+
+	/* Check if we have room for reply */
+	if (args == NULL || args->count == 0 || args->u[0].p == NULL)
+		return -EINVAL;
+
+	*args->u[0].p = MACIO_IN32(offset);
+	return 0;
+}
+
+static int macio_do_write_reg8(PMF_STD_ARGS, u32 offset, u8 value, u8 mask)
+{
+	struct macio_chip *macio = func->driver_data;
+	unsigned long flags;
+
+	spin_lock_irqsave(&feature_lock, flags);
+	MACIO_OUT8(offset, (MACIO_IN8(offset) & ~mask) | (value & mask));
+	spin_unlock_irqrestore(&feature_lock, flags);
+	return 0;
+}
+
+static int macio_do_read_reg8(PMF_STD_ARGS, u32 offset)
+{
+	struct macio_chip *macio = func->driver_data;
+
+	/* Check if we have room for reply */
+	if (args == NULL || args->count == 0 || args->u[0].p == NULL)
+		return -EINVAL;
+
+	*((u8 *)(args->u[0].p)) = MACIO_IN8(offset);
+	return 0;
+}
+
+static int macio_do_read_reg32_msrx(PMF_STD_ARGS, u32 offset, u32 mask,
+				    u32 shift, u32 xor)
+{
+	struct macio_chip *macio = func->driver_data;
+
+	/* Check if we have room for reply */
+	if (args == NULL || args->count == 0 || args->u[0].p == NULL)
+		return -EINVAL;
+
+	*args->u[0].p = ((MACIO_IN32(offset) & mask) >> shift) ^ xor;
+	return 0;
+}
+
+static int macio_do_read_reg8_msrx(PMF_STD_ARGS, u32 offset, u32 mask,
+				   u32 shift, u32 xor)
+{
+	struct macio_chip *macio = func->driver_data;
+
+	/* Check if we have room for reply */
+	if (args == NULL || args->count == 0 || args->u[0].p == NULL)
+		return -EINVAL;
+
+	*((u8 *)(args->u[0].p)) = ((MACIO_IN8(offset) & mask) >> shift) ^ xor;
+	return 0;
+}
+
+static int macio_do_write_reg32_slm(PMF_STD_ARGS, u32 offset, u32 shift,
+				    u32 mask)
+{
+	struct macio_chip *macio = func->driver_data;
+	unsigned long flags;
+	u32 tmp, val;
+
+	/* Check args */
+	if (args == NULL || args->count == 0)
+		return -EINVAL;
+
+	spin_lock_irqsave(&feature_lock, flags);
+	tmp = MACIO_IN32(offset);
+	val = args->u[0].v << shift;
+	tmp = (tmp & ~mask) | (val & mask);
+	MACIO_OUT32(offset, tmp);
+	spin_unlock_irqrestore(&feature_lock, flags);
+	return 0;
+}
+
+static int macio_do_write_reg8_slm(PMF_STD_ARGS, u32 offset, u32 shift,
+				   u32 mask)
+{
+	struct macio_chip *macio = func->driver_data;
+	unsigned long flags;
+	u32 tmp, val;
+
+	/* Check args */
+	if (args == NULL || args->count == 0)
+		return -EINVAL;
+
+	spin_lock_irqsave(&feature_lock, flags);
+	tmp = MACIO_IN8(offset);
+	val = args->u[0].v << shift;
+	tmp = (tmp & ~mask) | (val & mask);
+	MACIO_OUT8(offset, tmp);
+	spin_unlock_irqrestore(&feature_lock, flags);
+	return 0;
+}
+
+static struct pmf_handlers macio_mmio_handlers = {
+	.write_reg32		= macio_do_write_reg32,
+	.read_reg32		= macio_do_read_reg32,
+	.write_reg8		= macio_do_write_reg8,
+	.read_reg32		= macio_do_read_reg8,
+	.read_reg32_msrx	= macio_do_read_reg32_msrx,
+	.read_reg8_msrx		= macio_do_read_reg8_msrx,
+	.write_reg32_slm	= macio_do_write_reg32_slm,
+	.write_reg8_slm		= macio_do_write_reg8_slm,
+	.delay			= macio_do_delay,
+};
+
+static void macio_mmio_init_one(struct macio_chip *macio)
+{
+	DBG("Installing MMIO functions for macio %s\n",
+	    macio->of_node->full_name);
+
+	pmf_register_driver(macio->of_node, &macio_mmio_handlers, macio);
+}
+
+static struct device_node *unin_hwclock;
+
+static int unin_do_write_reg32(PMF_STD_ARGS, u32 offset, u32 value, u32 mask)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&feature_lock, flags);
+	/* This is fairly bogus in darwin, but it should work for our needs
+	 * implemeted that way:
+	 */
+	UN_OUT(offset, (UN_IN(offset) & ~mask) | (value & mask));
+	spin_unlock_irqrestore(&feature_lock, flags);
+	return 0;
+}
+
+
+static struct pmf_handlers unin_mmio_handlers = {
+	.write_reg32		= unin_do_write_reg32,
+	.delay			= macio_do_delay,
+};
+
+static void uninorth_install_pfunc(void)
+{
+	struct device_node *np;
+
+	DBG("Installing functions for UniN %s\n",
+	    uninorth_node->full_name);
+
+	/*
+	 * Install handlers for the bridge itself
+	 */
+	pmf_register_driver(uninorth_node, &unin_mmio_handlers, NULL);
+	pmf_do_functions(uninorth_node, NULL, 0, PMF_FLAGS_ON_INIT, NULL);
+
+
+	/*
+	 * Install handlers for the hwclock child if any
+	 */
+	for (np = NULL; (np = of_get_next_child(uninorth_node, np)) != NULL;)
+		if (strcmp(np->name, "hw-clock") == 0) {
+			unin_hwclock = np;
+			break;
+		}
+	if (unin_hwclock) {
+		DBG("Installing functions for UniN clock %s\n",
+		    unin_hwclock->full_name);
+		pmf_register_driver(unin_hwclock, &unin_mmio_handlers, NULL);
+		pmf_do_functions(unin_hwclock, NULL, 0, PMF_FLAGS_ON_INIT,
+				 NULL);
+	}
+}
+
+/* We export this as the SMP code might init us early */
+int __init pmac_pfunc_base_install(void)
+{
+	static int pfbase_inited;
+	int i;
+
+	if (pfbase_inited)
+		return 0;
+	pfbase_inited = 1;
+
+
+	DBG("Installing base platform functions...\n");
+
+	/*
+	 * Locate mac-io chips and install handlers
+	 */
+	for (i = 0 ; i < MAX_MACIO_CHIPS; i++) {
+		if (macio_chips[i].of_node) {
+			macio_mmio_init_one(&macio_chips[i]);
+			macio_gpio_init_one(&macio_chips[i]);
+		}
+	}
+
+	/*
+	 * Install handlers for northbridge and direct mapped hwclock
+	 * if any. We do not implement the config space access callback
+	 * which is only ever used for functions that we do not call in
+	 * the current driver (enabling/disabling cells in U2, mostly used
+	 * to restore the PCI settings, we do that differently)
+	 */
+	if (uninorth_node && uninorth_base)
+		uninorth_install_pfunc();
+
+	DBG("All base functions installed\n");
+
+	return 0;
+}
+
+arch_initcall(pmac_pfunc_base_install);
+
+#ifdef CONFIG_PM
+
+/* Those can be called by pmac_feature. Ultimately, I should use a sysdev
+ * or a device, but for now, that's good enough until I sort out some
+ * ordering issues. Also, we do not bother with GPIOs, as so far I yet have
+ * to see a case where a GPIO function has the on-suspend or on-resume bit
+ */
+void pmac_pfunc_base_suspend(void)
+{
+	int i;
+
+	for (i = 0 ; i < MAX_MACIO_CHIPS; i++) {
+		if (macio_chips[i].of_node)
+			pmf_do_functions(macio_chips[i].of_node, NULL, 0,
+					 PMF_FLAGS_ON_SLEEP, NULL);
+	}
+	if (uninorth_node)
+		pmf_do_functions(uninorth_node, NULL, 0,
+				 PMF_FLAGS_ON_SLEEP, NULL);
+	if (unin_hwclock)
+		pmf_do_functions(unin_hwclock, NULL, 0,
+				 PMF_FLAGS_ON_SLEEP, NULL);
+}
+
+void pmac_pfunc_base_resume(void)
+{
+	int i;
+
+	if (unin_hwclock)
+		pmf_do_functions(unin_hwclock, NULL, 0,
+				 PMF_FLAGS_ON_WAKE, NULL);
+	if (uninorth_node)
+		pmf_do_functions(uninorth_node, NULL, 0,
+				 PMF_FLAGS_ON_WAKE, NULL);
+	for (i = 0 ; i < MAX_MACIO_CHIPS; i++) {
+		if (macio_chips[i].of_node)
+			pmf_do_functions(macio_chips[i].of_node, NULL, 0,
+					 PMF_FLAGS_ON_WAKE, NULL);
+	}
+}
+
+#endif /* CONFIG_PM */
Index: linux-work/arch/powerpc/platforms/powermac/pfunc_core.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-work/arch/powerpc/platforms/powermac/pfunc_core.c	2006-01-07 10:54:03.000000000 +1100
@@ -0,0 +1,989 @@
+/*
+ *
+ * FIXME: Properly make this race free with refcounting etc...
+ *
+ * FIXME: LOCKING !!!
+ */
+
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/kernel.h>
+#include <linux/spinlock.h>
+#include <linux/module.h>
+
+#include <asm/semaphore.h>
+#include <asm/prom.h>
+#include <asm/pmac_pfunc.h>
+
+/* Debug */
+#define LOG_PARSE(fmt...)
+#define LOG_ERROR(fmt...)	printk(fmt)
+#define LOG_BLOB(t,b,c)
+#define DBG(fmt...)		printk(fmt)
+
+/* Command numbers */
+#define PMF_CMD_LIST			0
+#define PMF_CMD_WRITE_GPIO		1
+#define PMF_CMD_READ_GPIO		2
+#define PMF_CMD_WRITE_REG32		3
+#define PMF_CMD_READ_REG32		4
+#define PMF_CMD_WRITE_REG16		5
+#define PMF_CMD_READ_REG16		6
+#define PMF_CMD_WRITE_REG8		7
+#define PMF_CMD_READ_REG8		8
+#define PMF_CMD_DELAY			9
+#define PMF_CMD_WAIT_REG32		10
+#define PMF_CMD_WAIT_REG16		11
+#define PMF_CMD_WAIT_REG8		12
+#define PMF_CMD_READ_I2C		13
+#define PMF_CMD_WRITE_I2C		14
+#define PMF_CMD_RMW_I2C			15
+#define PMF_CMD_GEN_I2C			16
+#define PMF_CMD_SHIFT_BYTES_RIGHT	17
+#define PMF_CMD_SHIFT_BYTES_LEFT	18
+#define PMF_CMD_READ_CFG		19
+#define PMF_CMD_WRITE_CFG		20
+#define PMF_CMD_RMW_CFG			21
+#define PMF_CMD_READ_I2C_SUBADDR	22
+#define PMF_CMD_WRITE_I2C_SUBADDR	23
+#define PMF_CMD_SET_I2C_MODE		24
+#define PMF_CMD_RMW_I2C_SUBADDR		25
+#define PMF_CMD_READ_REG32_MASK_SHR_XOR	26
+#define PMF_CMD_READ_REG16_MASK_SHR_XOR	27
+#define PMF_CMD_READ_REG8_MASK_SHR_XOR	28
+#define PMF_CMD_WRITE_REG32_SHL_MASK	29
+#define PMF_CMD_WRITE_REG16_SHL_MASK	30
+#define PMF_CMD_WRITE_REG8_SHL_MASK	31
+#define PMF_CMD_MASK_AND_COMPARE	32
+#define PMF_CMD_COUNT			33
+
+/* This structure holds the state of the parser while walking through
+ * a function definition
+ */
+struct pmf_cmd {
+	const void		*cmdptr;
+	const void		*cmdend;
+	struct pmf_function	*func;
+	void			*instdata;
+	struct pmf_args		*args;
+	int			error;
+};
+
+#if 0
+/* Debug output */
+static void print_blob(const char *title, const void *blob, int bytes)
+{
+	printk("%s", title);
+	while(bytes--) {
+		printk("%02x ", *((u8 *)blob));
+		blob += 1;
+	}
+	printk("\n");
+}
+#endif
+
+/*
+ * Parser helpers
+ */
+
+static u32 pmf_next32(struct pmf_cmd *cmd)
+{
+	u32 value;
+	if ((cmd->cmdend - cmd->cmdptr) < 4) {
+		cmd->error = 1;
+		return 0;
+	}
+	value = *((u32 *)cmd->cmdptr);
+	cmd->cmdptr += 4;
+	return value;
+}
+
+static const void* pmf_next_blob(struct pmf_cmd *cmd, int count)
+{
+	const void *value;
+	if ((cmd->cmdend - cmd->cmdptr) < count) {
+		cmd->error = 1;
+		return NULL;
+	}
+	value = cmd->cmdptr;
+	cmd->cmdptr += count;
+	return value;
+}
+
+/*
+ * Individual command parsers
+ */
+
+#define PMF_PARSE_CALL(name, cmd, handlers, p...) \
+	do { \
+		if (cmd->error) \
+			return -ENXIO; \
+		if (handlers == NULL) \
+			return 0; \
+		if (handlers->name)				      \
+			return handlers->name(cmd->func, cmd->instdata, \
+					      cmd->args, p);	      \
+		return -1; \
+	} while(0) \
+
+
+static int pmf_parser_write_gpio(struct pmf_cmd *cmd, struct pmf_handlers *h)
+{
+	u8 value = (u8)pmf_next32(cmd);
+	u8 mask = (u8)pmf_next32(cmd);
+
+	LOG_PARSE("pmf: write_gpio(value: %02x, mask: %02x)\n", value, mask);
+
+	PMF_PARSE_CALL(write_gpio, cmd, h, value, mask);
+}
+
+static int pmf_parser_read_gpio(struct pmf_cmd *cmd, struct pmf_handlers *h)
+{
+	u8 mask = (u8)pmf_next32(cmd);
+	int rshift = (int)pmf_next32(cmd);
+	u8 xor = (u8)pmf_next32(cmd);
+
+	LOG_PARSE("pmf: read_gpio(mask: %02x, rshift: %d, xor: %02x)\n",
+		  mask, rshift, xor);
+
+	PMF_PARSE_CALL(read_gpio, cmd, h, mask, rshift, xor);
+}
+
+static int pmf_parser_write_reg32(struct pmf_cmd *cmd, struct pmf_handlers *h)
+{
+	u32 offset = pmf_next32(cmd);
+	u32 value = pmf_next32(cmd);
+	u32 mask = pmf_next32(cmd);
+
+	LOG_PARSE("pmf: write_reg32(offset: %08x, value: %08x, mask: %08x)\n",
+		  offset, value, mask);
+
+	PMF_PARSE_CALL(write_reg32, cmd, h, offset, value, mask);
+}
+
+static int pmf_parser_read_reg32(struct pmf_cmd *cmd, struct pmf_handlers *h)
+{
+	u32 offset = pmf_next32(cmd);
+
+	LOG_PARSE("pmf: read_reg32(offset: %08x)\n", offset);
+
+	PMF_PARSE_CALL(read_reg32, cmd, h, offset);
+}
+
+
+static int pmf_parser_write_reg16(struct pmf_cmd *cmd, struct pmf_handlers *h)
+{
+	u32 offset = pmf_next32(cmd);
+	u16 value = (u16)pmf_next32(cmd);
+	u16 mask = (u16)pmf_next32(cmd);
+
+	LOG_PARSE("pmf: write_reg16(offset: %08x, value: %04x, mask: %04x)\n",
+		  offset, value, mask);
+
+	PMF_PARSE_CALL(write_reg16, cmd, h, offset, value, mask);
+}
+
+static int pmf_parser_read_reg16(struct pmf_cmd *cmd, struct pmf_handlers *h)
+{
+	u32 offset = pmf_next32(cmd);
+
+	LOG_PARSE("pmf: read_reg16(offset: %08x)\n", offset);
+
+	PMF_PARSE_CALL(read_reg16, cmd, h, offset);
+}
+
+
+static int pmf_parser_write_reg8(struct pmf_cmd *cmd, struct pmf_handlers *h)
+{
+	u32 offset = pmf_next32(cmd);
+	u8 value = (u16)pmf_next32(cmd);
+	u8 mask = (u16)pmf_next32(cmd);
+
+	LOG_PARSE("pmf: write_reg8(offset: %08x, value: %02x, mask: %02x)\n",
+		  offset, value, mask);
+
+	PMF_PARSE_CALL(write_reg8, cmd, h, offset, value, mask);
+}
+
+static int pmf_parser_read_reg8(struct pmf_cmd *cmd, struct pmf_handlers *h)
+{
+	u32 offset = pmf_next32(cmd);
+
+	LOG_PARSE("pmf: read_reg8(offset: %08x)\n", offset);
+
+	PMF_PARSE_CALL(read_reg8, cmd, h, offset);
+}
+
+static int pmf_parser_delay(struct pmf_cmd *cmd, struct pmf_handlers *h)
+{
+	u32 duration = pmf_next32(cmd);
+
+	LOG_PARSE("pmf: delay(duration: %d us)\n", duration);
+
+	PMF_PARSE_CALL(delay, cmd, h, duration);
+}
+
+static int pmf_parser_wait_reg32(struct pmf_cmd *cmd, struct pmf_handlers *h)
+{
+	u32 offset = pmf_next32(cmd);
+	u32 value = pmf_next32(cmd);
+	u32 mask = pmf_next32(cmd);
+
+	LOG_PARSE("pmf: wait_reg32(offset: %08x, comp_value: %08x,mask: %08x)\n",
+		  offset, value, mask);
+
+	PMF_PARSE_CALL(wait_reg32, cmd, h, offset, value, mask);
+}
+
+static int pmf_parser_wait_reg16(struct pmf_cmd *cmd, struct pmf_handlers *h)
+{
+	u32 offset = pmf_next32(cmd);
+	u16 value = (u16)pmf_next32(cmd);
+	u16 mask = (u16)pmf_next32(cmd);
+
+	LOG_PARSE("pmf: wait_reg16(offset: %08x, comp_value: %04x,mask: %04x)\n",
+		  offset, value, mask);
+
+	PMF_PARSE_CALL(wait_reg16, cmd, h, offset, value, mask);
+}
+
+static int pmf_parser_wait_reg8(struct pmf_cmd *cmd, struct pmf_handlers *h)
+{
+	u32 offset = pmf_next32(cmd);
+	u8 value = (u8)pmf_next32(cmd);
+	u8 mask = (u8)pmf_next32(cmd);
+
+	LOG_PARSE("pmf: wait_reg8(offset: %08x, comp_value: %02x,mask: %02x)\n",
+		  offset, value, mask);
+
+	PMF_PARSE_CALL(wait_reg8, cmd, h, offset, value, mask);
+}
+
+static int pmf_parser_read_i2c(struct pmf_cmd *cmd, struct pmf_handlers *h)
+{
+	u32 bytes = pmf_next32(cmd);
+
+	LOG_PARSE("pmf: read_i2c(bytes: %ud)\n", bytes);
+
+	PMF_PARSE_CALL(read_i2c, cmd, h, bytes);
+}
+
+static int pmf_parser_write_i2c(struct pmf_cmd *cmd, struct pmf_handlers *h)
+{
+	u32 bytes = pmf_next32(cmd);
+	const void *blob = pmf_next_blob(cmd, bytes);
+
+	LOG_PARSE("pmf: write_i2c(bytes: %ud) ...\n", bytes);
+	LOG_BLOB("pmf:   data: \n", blob, bytes);
+
+	PMF_PARSE_CALL(write_i2c, cmd, h, bytes, blob);
+}
+
+
+static int pmf_parser_rmw_i2c(struct pmf_cmd *cmd, struct pmf_handlers *h)
+{
+	u32 maskbytes = pmf_next32(cmd);
+	u32 valuesbytes = pmf_next32(cmd);
+	u32 totalbytes = pmf_next32(cmd);
+	const void *maskblob = pmf_next_blob(cmd, maskbytes);
+	const void *valuesblob = pmf_next_blob(cmd, valuesbytes);
+
+	LOG_PARSE("pmf: rmw_i2c(maskbytes: %ud, valuebytes: %ud, "
+		  "totalbytes: %d) ...\n",
+		  maskbytes, valuesbytes, totalbytes);
+	LOG_BLOB("pmf:   mask data: \n", maskblob, maskbytes);
+	LOG_BLOB("pmf:   values data: \n", valuesblob, valuesbytes);
+
+	PMF_PARSE_CALL(rmw_i2c, cmd, h, maskbytes, valuesbytes, totalbytes,
+		       maskblob, valuesblob);
+}
+
+static int pmf_parser_read_cfg(struct pmf_cmd *cmd, struct pmf_handlers *h)
+{
+	u32 offset = pmf_next32(cmd);
+	u32 bytes = pmf_next32(cmd);
+
+	LOG_PARSE("pmf: read_cfg(offset: %x, bytes: %ud)\n", offset, bytes);
+
+	PMF_PARSE_CALL(read_cfg, cmd, h, offset, bytes);
+}
+
+
+static int pmf_parser_write_cfg(struct pmf_cmd *cmd, struct pmf_handlers *h)
+{
+	u32 offset = pmf_next32(cmd);
+	u32 bytes = pmf_next32(cmd);
+	const void *blob = pmf_next_blob(cmd, bytes);
+
+	LOG_PARSE("pmf: write_cfg(offset: %x, bytes: %ud)\n", offset, bytes);
+	LOG_BLOB("pmf:   data: \n", blob, bytes);
+
+	PMF_PARSE_CALL(write_cfg, cmd, h, offset, bytes, blob);
+}
+
+static int pmf_parser_rmw_cfg(struct pmf_cmd *cmd, struct pmf_handlers *h)
+{
+	u32 offset = pmf_next32(cmd);
+	u32 maskbytes = pmf_next32(cmd);
+	u32 valuesbytes = pmf_next32(cmd);
+	u32 totalbytes = pmf_next32(cmd);
+	const void *maskblob = pmf_next_blob(cmd, maskbytes);
+	const void *valuesblob = pmf_next_blob(cmd, valuesbytes);
+
+	LOG_PARSE("pmf: rmw_cfg(maskbytes: %ud, valuebytes: %ud,"
+		  " totalbytes: %d) ...\n",
+		  maskbytes, valuesbytes, totalbytes);
+	LOG_BLOB("pmf:   mask data: \n", maskblob, maskbytes);
+	LOG_BLOB("pmf:   values data: \n", valuesblob, valuesbytes);
+
+	PMF_PARSE_CALL(rmw_cfg, cmd, h, offset, maskbytes, valuesbytes,
+		       totalbytes, maskblob, valuesblob);
+}
+
+
+static int pmf_parser_read_i2c_sub(struct pmf_cmd *cmd, struct pmf_handlers *h)
+{
+	u8 subaddr = (u8)pmf_next32(cmd);
+	u32 bytes = pmf_next32(cmd);
+
+	LOG_PARSE("pmf: read_i2c_sub(subaddr: %x, bytes: %ud)\n",
+		  subaddr, bytes);
+
+	PMF_PARSE_CALL(read_i2c_sub, cmd, h, subaddr, bytes);
+}
+
+static int pmf_parser_write_i2c_sub(struct pmf_cmd *cmd, struct pmf_handlers *h)
+{
+	u8 subaddr = (u8)pmf_next32(cmd);
+	u32 bytes = pmf_next32(cmd);
+	const void *blob = pmf_next_blob(cmd, bytes);
+
+	LOG_PARSE("pmf: write_i2c_sub(subaddr: %x, bytes: %ud) ...\n",
+		  subaddr, bytes);
+	LOG_BLOB("pmf:   data: \n", blob, bytes);
+
+	PMF_PARSE_CALL(write_i2c_sub, cmd, h, subaddr, bytes, blob);
+}
+
+static int pmf_parser_set_i2c_mode(struct pmf_cmd *cmd, struct pmf_handlers *h)
+{
+	u32 mode = pmf_next32(cmd);
+
+	LOG_PARSE("pmf: set_i2c_mode(mode: %d)\n", mode);
+
+	PMF_PARSE_CALL(set_i2c_mode, cmd, h, mode);
+}
+
+
+static int pmf_parser_rmw_i2c_sub(struct pmf_cmd *cmd, struct pmf_handlers *h)
+{
+	u8 subaddr = (u8)pmf_next32(cmd);
+	u32 maskbytes = pmf_next32(cmd);
+	u32 valuesbytes = pmf_next32(cmd);
+	u32 totalbytes = pmf_next32(cmd);
+	const void *maskblob = pmf_next_blob(cmd, maskbytes);
+	const void *valuesblob = pmf_next_blob(cmd, valuesbytes);
+
+	LOG_PARSE("pmf: rmw_i2c_sub(subaddr: %x, maskbytes: %ud, valuebytes: %ud"
+		  ", totalbytes: %d) ...\n",
+		  subaddr, maskbytes, valuesbytes, totalbytes);
+	LOG_BLOB("pmf:   mask data: \n", maskblob, maskbytes);
+	LOG_BLOB("pmf:   values data: \n", valuesblob, valuesbytes);
+
+	PMF_PARSE_CALL(rmw_i2c_sub, cmd, h, subaddr, maskbytes, valuesbytes,
+		       totalbytes, maskblob, valuesblob);
+}
+
+static int pmf_parser_read_reg32_msrx(struct pmf_cmd *cmd,
+				      struct pmf_handlers *h)
+{
+	u32 offset = pmf_next32(cmd);
+	u32 mask = pmf_next32(cmd);
+	u32 shift = pmf_next32(cmd);
+	u32 xor = pmf_next32(cmd);
+
+	LOG_PARSE("pmf: read_reg32_msrx(offset: %x, mask: %x, shift: %x,"
+		  " xor: %x\n", offset, mask, shift, xor);
+
+	PMF_PARSE_CALL(read_reg32_msrx, cmd, h, offset, mask, shift, xor);
+}
+
+static int pmf_parser_read_reg16_msrx(struct pmf_cmd *cmd,
+				      struct pmf_handlers *h)
+{
+	u32 offset = pmf_next32(cmd);
+	u32 mask = pmf_next32(cmd);
+	u32 shift = pmf_next32(cmd);
+	u32 xor = pmf_next32(cmd);
+
+	LOG_PARSE("pmf: read_reg16_msrx(offset: %x, mask: %x, shift: %x,"
+		  " xor: %x\n", offset, mask, shift, xor);
+
+	PMF_PARSE_CALL(read_reg16_msrx, cmd, h, offset, mask, shift, xor);
+}
+static int pmf_parser_read_reg8_msrx(struct pmf_cmd *cmd,
+				     struct pmf_handlers *h)
+{
+	u32 offset = pmf_next32(cmd);
+	u32 mask = pmf_next32(cmd);
+	u32 shift = pmf_next32(cmd);
+	u32 xor = pmf_next32(cmd);
+
+	LOG_PARSE("pmf: read_reg8_msrx(offset: %x, mask: %x, shift: %x,"
+		  " xor: %x\n", offset, mask, shift, xor);
+
+	PMF_PARSE_CALL(read_reg8_msrx, cmd, h, offset, mask, shift, xor);
+}
+
+static int pmf_parser_write_reg32_slm(struct pmf_cmd *cmd,
+				      struct pmf_handlers *h)
+{
+	u32 offset = pmf_next32(cmd);
+	u32 shift = pmf_next32(cmd);
+	u32 mask = pmf_next32(cmd);
+
+	LOG_PARSE("pmf: write_reg32_slm(offset: %x, shift: %x, mask: %x\n",
+		  offset, shift, mask);
+
+	PMF_PARSE_CALL(write_reg32_slm, cmd, h, offset, shift, mask);
+}
+
+static int pmf_parser_write_reg16_slm(struct pmf_cmd *cmd,
+				      struct pmf_handlers *h)
+{
+	u32 offset = pmf_next32(cmd);
+	u32 shift = pmf_next32(cmd);
+	u32 mask = pmf_next32(cmd);
+
+	LOG_PARSE("pmf: write_reg16_slm(offset: %x, shift: %x, mask: %x\n",
+		  offset, shift, mask);
+
+	PMF_PARSE_CALL(write_reg16_slm, cmd, h, offset, shift, mask);
+}
+
+static int pmf_parser_write_reg8_slm(struct pmf_cmd *cmd,
+				     struct pmf_handlers *h)
+{
+	u32 offset = pmf_next32(cmd);
+	u32 shift = pmf_next32(cmd);
+	u32 mask = pmf_next32(cmd);
+
+	LOG_PARSE("pmf: write_reg8_slm(offset: %x, shift: %x, mask: %x\n",
+		  offset, shift, mask);
+
+	PMF_PARSE_CALL(write_reg8_slm, cmd, h, offset, shift, mask);
+}
+
+static int pmf_parser_mask_and_compare(struct pmf_cmd *cmd,
+				       struct pmf_handlers *h)
+{
+	u32 bytes = pmf_next32(cmd);
+	const void *maskblob = pmf_next_blob(cmd, bytes);
+	const void *valuesblob = pmf_next_blob(cmd, bytes);
+
+	LOG_PARSE("pmf: mask_and_compare(length: %ud ...\n", bytes);
+	LOG_BLOB("pmf:   mask data: \n", maskblob, bytes);
+	LOG_BLOB("pmf:   values data: \n", valuesblob, bytes);
+
+	PMF_PARSE_CALL(mask_and_compare, cmd, h,
+		       bytes, maskblob, valuesblob);
+}
+
+
+typedef int (*pmf_cmd_parser_t)(struct pmf_cmd *cmd, struct pmf_handlers *h);
+
+static pmf_cmd_parser_t pmf_parsers[PMF_CMD_COUNT] =
+{
+	NULL,
+	pmf_parser_write_gpio,
+	pmf_parser_read_gpio,
+	pmf_parser_write_reg32,
+	pmf_parser_read_reg32,
+	pmf_parser_write_reg16,
+	pmf_parser_read_reg16,
+	pmf_parser_write_reg8,
+	pmf_parser_read_reg8,
+	pmf_parser_delay,
+	pmf_parser_wait_reg32,
+	pmf_parser_wait_reg16,
+	pmf_parser_wait_reg8,
+	pmf_parser_read_i2c,
+	pmf_parser_write_i2c,
+	pmf_parser_rmw_i2c,
+	NULL, /* Bogus command */
+	NULL, /* Shift bytes right: NYI */
+	NULL, /* Shift bytes left: NYI */
+	pmf_parser_read_cfg,
+	pmf_parser_write_cfg,
+	pmf_parser_rmw_cfg,
+	pmf_parser_read_i2c_sub,
+	pmf_parser_write_i2c_sub,
+	pmf_parser_set_i2c_mode,
+	pmf_parser_rmw_i2c_sub,
+	pmf_parser_read_reg32_msrx,
+	pmf_parser_read_reg16_msrx,
+	pmf_parser_read_reg8_msrx,
+	pmf_parser_write_reg32_slm,
+	pmf_parser_write_reg16_slm,
+	pmf_parser_write_reg8_slm,
+	pmf_parser_mask_and_compare,
+};
+
+struct pmf_device {
+	struct list_head	link;
+	struct device_node	*node;
+	struct pmf_handlers	*handlers;
+	struct list_head	functions;
+	struct kref		ref;
+};
+
+static LIST_HEAD(pmf_devices);
+static spinlock_t pmf_lock = SPIN_LOCK_UNLOCKED;
+
+static void pmf_release_device(struct kref *kref)
+{
+	struct pmf_device *dev = container_of(kref, struct pmf_device, ref);
+	kfree(dev);
+}
+
+static inline void pmf_put_device(struct pmf_device *dev)
+{
+	kref_put(&dev->ref, pmf_release_device);
+}
+
+static inline struct pmf_device *pmf_get_device(struct pmf_device *dev)
+{
+	kref_get(&dev->ref);
+	return dev;
+}
+
+static inline struct pmf_device *pmf_find_device(struct device_node *np)
+{
+	struct pmf_device *dev;
+
+	list_for_each_entry(dev, &pmf_devices, link) {
+		if (dev->node == np)
+			return pmf_get_device(dev);
+	}
+	return NULL;
+}
+
+static int pmf_parse_one(struct pmf_function *func,
+			 struct pmf_handlers *handlers,
+			 void *instdata, struct pmf_args *args)
+{
+	struct pmf_cmd cmd;
+	u32 ccode;
+	int count, rc;
+
+	cmd.cmdptr		= func->data;
+	cmd.cmdend		= func->data + func->length;
+	cmd.func       		= func;
+	cmd.instdata		= instdata;
+	cmd.args		= args;
+	cmd.error		= 0;
+
+	LOG_PARSE("pmf: func %s, %d bytes, %s...\n",
+		  func->name, func->length,
+		  handlers ? "executing" : "parsing");
+
+	/* One subcommand to parse for now */
+	count = 1;
+
+	while(count-- && cmd.cmdptr < cmd.cmdend) {
+		/* Get opcode */
+		ccode = pmf_next32(&cmd);
+		/* Check if we are hitting a command list, fetch new count */
+		if (ccode == 0) {
+			count = pmf_next32(&cmd) - 1;
+			ccode = pmf_next32(&cmd);
+		}
+		if (cmd.error) {
+			LOG_ERROR("pmf: parse error, not enough data\n");
+			return -ENXIO;
+		}
+		if (ccode >= PMF_CMD_COUNT) {
+			LOG_ERROR("pmf: command code %d unknown !\n", ccode);
+			return -ENXIO;
+		}
+		if (pmf_parsers[ccode] == NULL) {
+			LOG_ERROR("pmf: no parser for command %d !\n", ccode);
+			return -ENXIO;
+		}
+		rc = pmf_parsers[ccode](&cmd, handlers);
+		if (rc != 0) {
+			LOG_ERROR("pmf: parser for command %d returned"
+				  " error %d\n", ccode, rc);
+			return rc;
+		}
+	}
+
+	/* We are doing an initial parse pass, we need to adjust the size */
+	if (handlers == NULL)
+		func->length = cmd.cmdptr - func->data;
+
+	return 0;
+}
+
+static int pmf_add_function_prop(struct pmf_device *dev, void *driverdata,
+				 const char *name, u32 *data,
+				 unsigned int length)
+{
+	int count = 0;
+	struct pmf_function *func = NULL;
+
+	DBG("pmf: Adding functions for platform-do-%s\n", name);
+
+	while (length >= 12) {
+		/* Allocate a structure */
+		func = kzalloc(sizeof(struct pmf_function), GFP_KERNEL);
+		if (func == NULL)
+			goto bail;
+		kref_init(&func->ref);
+		INIT_LIST_HEAD(&func->irq_clients);
+		func->node = dev->node;
+		func->driver_data = driverdata;
+		func->name = name;
+		func->phandle = data[0];
+		func->flags = data[1];
+		data += 2;
+		length -= 8;
+		func->data = data;
+		func->length = length;
+		func->dev = dev;
+		DBG("pmf: idx %d: flags=%08x, phandle=%08x "
+		    " %d bytes remaining, parsing...\n",
+		    count+1, func->flags, func->phandle, length);
+		if (pmf_parse_one(func, NULL, NULL, NULL)) {
+			kfree(func);
+			goto bail;
+		}
+		length -= func->length;
+		data = (u32 *)(((u8 *)data) + func->length);
+		list_add(&func->link, &dev->functions);
+		pmf_get_device(dev);
+		count++;
+	}
+ bail:
+	DBG("pmf: Added %d functions\n", count);
+
+	return count;
+}
+
+static int pmf_add_functions(struct pmf_device *dev, void *driverdata)
+{
+	struct property *pp;
+#define PP_PREFIX "platform-do-"
+	const int plen = strlen(PP_PREFIX);
+	int count = 0;
+
+	for (pp = dev->node->properties; pp != 0; pp = pp->next) {
+		char *name;
+		if (strncmp(pp->name, PP_PREFIX, plen) != 0)
+			continue;
+		name = pp->name + plen;
+		if (strlen(name) && pp->length >= 12)
+			count += pmf_add_function_prop(dev, driverdata, name,
+						       (u32 *)pp->value,
+						       pp->length);
+	}
+	return count;
+}
+
+
+int pmf_register_driver(struct device_node *np,
+			struct pmf_handlers *handlers,
+			void *driverdata)
+{
+	struct pmf_device *dev;
+	unsigned long flags;
+	int rc = 0;
+
+	if (handlers == NULL)
+		return -EINVAL;
+
+	DBG("pmf: registering driver for node %s\n", np->full_name);
+
+	spin_lock_irqsave(&pmf_lock, flags);
+	dev = pmf_find_device(np);
+	spin_unlock_irqrestore(&pmf_lock, flags);
+	if (dev != NULL) {
+		DBG("pmf: already there !\n");
+		pmf_put_device(dev);
+		return -EBUSY;
+	}
+
+	dev = kzalloc(sizeof(struct pmf_device), GFP_KERNEL);
+	if (dev == NULL) {
+		DBG("pmf: no memory !\n");
+		return -ENOMEM;
+	}
+	kref_init(&dev->ref);
+	dev->node = of_node_get(np);
+	dev->handlers = handlers;
+	INIT_LIST_HEAD(&dev->functions);
+
+	rc = pmf_add_functions(dev, driverdata);
+	if (rc == 0) {
+		DBG("pmf: no functions, disposing.. \n");
+		of_node_put(np);
+		kfree(dev);
+		return -ENODEV;
+	}
+
+	spin_lock_irqsave(&pmf_lock, flags);
+	list_add(&dev->link, &pmf_devices);
+	spin_unlock_irqrestore(&pmf_lock, flags);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(pmf_register_driver);
+
+struct pmf_function *pmf_get_function(struct pmf_function *func)
+{
+	if (!try_module_get(func->dev->handlers->owner))
+		return NULL;
+	kref_get(&func->ref);
+	return func;
+}
+EXPORT_SYMBOL_GPL(pmf_get_function);
+
+static void pmf_release_function(struct kref *kref)
+{
+	struct pmf_function *func =
+		container_of(kref, struct pmf_function, ref);
+	pmf_put_device(func->dev);
+	kfree(func);
+}
+
+static inline void __pmf_put_function(struct pmf_function *func)
+{
+	kref_put(&func->ref, pmf_release_function);
+}
+
+void pmf_put_function(struct pmf_function *func)
+{
+	if (func == NULL)
+		return;
+	module_put(func->dev->handlers->owner);
+	__pmf_put_function(func);
+}
+EXPORT_SYMBOL_GPL(pmf_put_function);
+
+void pmf_unregister_driver(struct device_node *np)
+{
+	struct pmf_device *dev;
+	unsigned long flags;
+
+	DBG("pmf: unregistering driver for node %s\n", np->full_name);
+
+	spin_lock_irqsave(&pmf_lock, flags);
+	dev = pmf_find_device(np);
+	if (dev == NULL) {
+		DBG("pmf: not such driver !\n");
+		spin_unlock_irqrestore(&pmf_lock, flags);
+		return;
+	}
+	list_del(&dev->link);
+
+	while(!list_empty(&dev->functions)) {
+		struct pmf_function *func =
+			list_entry(dev->functions.next, typeof(*func), link);
+		list_del(&func->link);
+		__pmf_put_function(func);
+	}
+
+	pmf_put_device(dev);
+	spin_unlock_irqrestore(&pmf_lock, flags);
+}
+EXPORT_SYMBOL_GPL(pmf_unregister_driver);
+
+struct pmf_function *__pmf_find_function(struct device_node *target,
+					 const char *name, u32 flags)
+{
+	struct device_node *actor = of_node_get(target);
+	struct pmf_device *dev;
+	struct pmf_function *func, *result = NULL;
+	char fname[64];
+	u32 *prop, ph;
+
+	/*
+	 * Look for a "platform-*" function reference. If we can't find
+	 * one, then we fallback to a direct call attempt
+	 */
+	snprintf(fname, 63, "platform-%s", name);
+	prop = (u32 *)get_property(target, fname, NULL);
+	if (prop == NULL)
+		goto find_it;
+	ph = *prop;
+	if (ph == 0)
+		goto find_it;
+
+	/*
+	 * Ok, now try to find the actor. If we can't find it, we fail,
+	 * there is no point in falling back there
+	 */
+	of_node_put(actor);
+	actor = of_find_node_by_phandle(ph);
+	if (actor == NULL)
+		return NULL;
+ find_it:
+	dev = pmf_find_device(actor);
+	if (dev == NULL)
+		return NULL;
+
+	list_for_each_entry(func, &dev->functions, link) {
+		if (name && strcmp(name, func->name))
+			continue;
+		if (func->phandle && target->node != func->phandle)
+			continue;
+		if ((func->flags & flags) == 0)
+			continue;
+		result = func;
+		break;
+	}
+	of_node_put(actor);
+	pmf_put_device(dev);
+	return result;
+}
+
+
+int pmf_register_irq_client(struct device_node *target,
+			    const char *name,
+			    struct pmf_irq_client *client)
+{
+	struct pmf_function *func;
+	unsigned long flags;
+
+	spin_lock_irqsave(&pmf_lock, flags);
+	func = __pmf_find_function(target, name, PMF_FLAGS_INT_GEN);
+	if (func == NULL) {
+		spin_unlock_irqrestore(&pmf_lock, flags);
+		return -ENODEV;
+	}
+	list_add(&client->link, &func->irq_clients);
+	spin_unlock_irqrestore(&pmf_lock, flags);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(pmf_register_irq_client);
+
+void pmf_unregister_irq_client(struct device_node *np,
+			      const char *name,
+			      struct pmf_irq_client *client)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&pmf_lock, flags);
+	list_del(&client->link);
+	spin_unlock_irqrestore(&pmf_lock, flags);
+}
+EXPORT_SYMBOL_GPL(pmf_unregister_irq_client);
+
+
+void pmf_do_irq(struct pmf_function *func)
+{
+	unsigned long flags;
+	struct pmf_irq_client *client;
+
+	/* For now, using a spinlock over the whole function. Can be made
+	 * to drop the lock using 2 lists if necessary
+	 */
+	spin_lock_irqsave(&pmf_lock, flags);
+	list_for_each_entry(client, &func->irq_clients, link) {
+		if (!try_module_get(client->owner))
+			continue;
+		client->handler(client->data);
+		module_put(client->owner);
+	}
+	spin_unlock_irqrestore(&pmf_lock, flags);
+}
+EXPORT_SYMBOL_GPL(pmf_do_irq);
+
+
+int pmf_call_one(struct pmf_function *func, struct pmf_args *args)
+{
+	struct pmf_device *dev = func->dev;
+	void *instdata = NULL;
+	int rc = 0;
+
+	DBG(" ** pmf_call_one(%s/%s) **\n", dev->node->full_name, func->name);
+
+	if (dev->handlers->begin)
+		instdata = dev->handlers->begin(func, args);
+	rc = pmf_parse_one(func, dev->handlers, instdata, args);
+	if (dev->handlers->end)
+		dev->handlers->end(func, instdata);
+
+	return rc;
+}
+EXPORT_SYMBOL_GPL(pmf_call_one);
+
+int pmf_do_functions(struct device_node *np, const char *name,
+		     u32 phandle, u32 fflags, struct pmf_args *args)
+{
+	struct pmf_device *dev;
+	struct pmf_function *func, *tmp;
+	unsigned long flags;
+	int rc = -ENODEV;
+
+	spin_lock_irqsave(&pmf_lock, flags);
+
+	dev = pmf_find_device(np);
+	if (dev == NULL) {
+		spin_unlock_irqrestore(&pmf_lock, flags);
+		return -ENODEV;
+	}
+	list_for_each_entry_safe(func, tmp, &dev->functions, link) {
+		if (name && strcmp(name, func->name))
+			continue;
+		if (phandle && func->phandle && phandle != func->phandle)
+			continue;
+		if ((func->flags & fflags) == 0)
+			continue;
+		if (pmf_get_function(func) == NULL)
+			continue;
+		spin_unlock_irqrestore(&pmf_lock, flags);
+		rc = pmf_call_one(func, args);
+		pmf_put_function(func);
+		spin_lock_irqsave(&pmf_lock, flags);
+	}
+	pmf_put_device(dev);
+	spin_unlock_irqrestore(&pmf_lock, flags);
+
+	return rc;
+}
+EXPORT_SYMBOL_GPL(pmf_do_functions);
+
+
+struct pmf_function *pmf_find_function(struct device_node *target,
+				       const char *name)
+{
+	struct pmf_function *func;
+	unsigned long flags;
+
+	spin_lock_irqsave(&pmf_lock, flags);
+	func = __pmf_find_function(target, name, PMF_FLAGS_ON_DEMAND);
+	if (func)
+		func = pmf_get_function(func);
+	spin_unlock_irqrestore(&pmf_lock, flags);
+	return func;
+}
+EXPORT_SYMBOL_GPL(pmf_find_function);
+
+int pmf_call_function(struct device_node *target, const char *name,
+		      struct pmf_args *args)
+{
+	struct pmf_function *func = pmf_find_function(target, name);
+	int rc;
+
+	if (func == NULL)
+		return -ENODEV;
+
+	rc = pmf_call_one(func, args);
+	pmf_put_function(func);
+	return rc;
+}
+EXPORT_SYMBOL_GPL(pmf_call_function);
+
Index: linux-work/include/asm-powerpc/pmac_feature.h
===================================================================
--- linux-work.orig/include/asm-powerpc/pmac_feature.h	2006-01-07 10:53:21.000000000 +1100
+++ linux-work/include/asm-powerpc/pmac_feature.h	2006-01-07 10:54:03.000000000 +1100
@@ -374,5 +374,24 @@ extern struct macio_chip* macio_find(str
 #define MACIO_IN8(r)		(in_8(MACIO_FCR8(macio,r)))
 #define MACIO_OUT8(r,v)		(out_8(MACIO_FCR8(macio,r), (v)))
 
+/*
+ * Those are exported by pmac feature for internal use by arch code
+ * only like the platform function callbacks, do not use directly in drivers
+ */
+extern spinlock_t feature_lock;
+extern struct device_node *uninorth_node;
+extern u32 __iomem *uninorth_base;
+
+/*
+ * Uninorth reg. access. Note that Uni-N regs are big endian
+ */
+
+#define UN_REG(r)	(uninorth_base + ((r) >> 2))
+#define UN_IN(r)	(in_be32(UN_REG(r)))
+#define UN_OUT(r,v)	(out_be32(UN_REG(r), (v)))
+#define UN_BIS(r,v)	(UN_OUT((r), UN_IN(r) | (v)))
+#define UN_BIC(r,v)	(UN_OUT((r), UN_IN(r) & ~(v)))
+
+
 #endif /* __PPC_ASM_PMAC_FEATURE_H */
 #endif /* __KERNEL__ */
Index: linux-work/arch/powerpc/platforms/powermac/smp.c
===================================================================
--- linux-work.orig/arch/powerpc/platforms/powermac/smp.c	2006-01-07 10:53:21.000000000 +1100
+++ linux-work/arch/powerpc/platforms/powermac/smp.c	2006-01-07 10:54:03.000000000 +1100
@@ -52,8 +52,9 @@
 #include <asm/cacheflush.h>
 #include <asm/keylargo.h>
 #include <asm/pmac_low_i2c.h>
+#include <asm/pmac_pfunc.h>
 
-#undef DEBUG
+#define DEBUG
 
 #ifdef DEBUG
 #define DBG(fmt...) udbg_printf(fmt)
@@ -62,6 +63,7 @@
 #endif
 
 extern void __secondary_start_pmac_0(void);
+extern int pmac_pfunc_base_install(void);
 
 #ifdef CONFIG_PPC32
 
@@ -602,11 +604,29 @@ static void __init smp_core99_setup_i2c_
 	pmac_tb_clock_chip_host = NULL;
 }
 
-#endif /* CONFIG_PPC64 */
 
 
 /*
- * SMP G4 and newer G5 use a GPIO to enable/disable the timebase.
+ * Newer G5s uses a platform function
+ */
+
+static void smp_core99_pfunc_tb_freeze(int freeze)
+{
+	struct device_node *cpus;
+	struct pmf_args args;
+
+	cpus = of_find_node_by_path("/cpus");
+	BUG_ON(cpus == NULL);
+	args.count = 1;
+	args.u[0].v = !freeze;
+	pmf_call_function(cpus, "cpu-timebase", &args);
+	of_node_put(cpus);
+}
+
+#else /* CONFIG_PPC64 */
+
+/*
+ * SMP G4 use a GPIO to enable/disable the timebase.
  */
 
 static unsigned int core99_tb_gpio;	/* Timebase freeze GPIO */
@@ -620,6 +640,9 @@ static void smp_core99_gpio_tb_freeze(in
 	pmac_call_feature(PMAC_FTR_READ_GPIO, NULL, core99_tb_gpio, 0);
 }
 
+
+#endif /* !CONFIG_PPC64 */
+
 /* L2 and L3 cache settings to pass from CPU0 to CPU1 on G4 cpus */
 volatile static long int core99_l2_cache;
 volatile static long int core99_l3_cache;
@@ -665,19 +688,15 @@ static void __init smp_core99_setup(int 
 	    machine_is_compatible("RackMac3,1"))
 		smp_core99_setup_i2c_hwsync(ncpus);
 
-	/* GPIO based HW sync on recent G5s */
+	/* pfunc based HW sync on recent G5s */
 	if (pmac_tb_freeze == NULL) {
-		struct device_node *np =
-			of_find_node_by_name(NULL, "timebase-enable");
-		u32 *reg = (u32 *)get_property(np, "reg", NULL);
-
-		if (np && reg && !strcmp(np->type, "gpio")) {
-			core99_tb_gpio = *reg;
-			if (core99_tb_gpio < 0x50)
-				core99_tb_gpio += 0x50;
-			pmac_tb_freeze = smp_core99_gpio_tb_freeze;
+		struct device_node *cpus =
+			of_find_node_by_path("/cpus");
+		if (cpus &&
+		    get_property(cpus, "platform-cpu-timebase", NULL)) {
+			pmac_tb_freeze = smp_core99_pfunc_tb_freeze;
 			printk(KERN_INFO "Processor timebase sync using"
-			       " GPIO 0x%02x\n", core99_tb_gpio);
+			       " platform function\n");
 		}
 	}
 
@@ -746,6 +765,7 @@ static int __init smp_core99_probe(void)
 	/* We need to perform some early initialisations before we can start
 	 * setting up SMP as we are running before initcalls
 	 */
+	pmac_pfunc_base_install();
 	pmac_i2c_init();
 
 	/* Setup various bits like timebase sync method, ability to nap, ... */
Index: linux-work/arch/powerpc/platforms/powermac/low_i2c.c
===================================================================
--- linux-work.orig/arch/powerpc/platforms/powermac/low_i2c.c	2006-01-07 10:53:21.000000000 +1100
+++ linux-work/arch/powerpc/platforms/powermac/low_i2c.c	2006-01-07 10:54:03.000000000 +1100
@@ -49,6 +49,7 @@
 #include <asm/prom.h>
 #include <asm/machdep.h>
 #include <asm/smu.h>
+#include <asm/pmac_pfunc.h>
 #include <asm/pmac_low_i2c.h>
 
 #ifdef DEBUG
@@ -1162,9 +1163,291 @@ int pmac_i2c_xfer(struct pmac_i2c_bus *b
 }
 EXPORT_SYMBOL_GPL(pmac_i2c_xfer);
 
+/* some quirks for platform function decoding */
+enum {
+	pmac_i2c_quirk_invmask = 0x00000001u,
+};
+
+static void pmac_i2c_devscan(void (*callback)(struct device_node *dev,
+					      int quirks))
+{
+	struct pmac_i2c_bus *bus;
+	struct device_node *np;
+	static struct whitelist_ent {
+		char *name;
+		char *compatible;
+		int quirks;
+	} whitelist[] = {
+		/* XXX Study device-tree's & apple drivers are get the quirks
+		 * right !
+		 */
+		{ "i2c-hwclock", NULL, pmac_i2c_quirk_invmask },
+		{ "i2c-cpu-voltage", NULL, 0},
+		{  "temp-monitor", NULL, 0 },
+		{  "supply-monitor", NULL, 0 },
+		{ NULL, NULL, 0 },
+	};
+
+	/* Only some devices need to have platform functions instanciated
+	 * here. For now, we have a table. Others, like 9554 i2c GPIOs used
+	 * on Xserve, if we ever do a driver for them, will use their own
+	 * platform function instance
+	 */
+	list_for_each_entry(bus, &pmac_i2c_busses, link) {
+		for (np = NULL;
+		     (np = of_get_next_child(bus->busnode, np)) != NULL;) {
+			struct whitelist_ent *p;
+			/* If multibus, check if device is on that bus */
+			if (bus->flags & pmac_i2c_multibus)
+				if (bus != pmac_i2c_find_bus(np))
+					continue;
+			for (p = whitelist; p->name != NULL; p++) {
+				if (strcmp(np->name, p->name))
+					continue;
+				if (p->compatible &&
+				    !device_is_compatible(np, p->compatible))
+					continue;
+				callback(np, p->quirks);
+				break;
+			}
+		}
+	}
+}
+
+#define MAX_I2C_DATA	64
+
+struct pmac_i2c_pf_inst
+{
+	struct pmac_i2c_bus	*bus;
+	u8			addr;
+	u8			buffer[MAX_I2C_DATA];
+	u8			scratch[MAX_I2C_DATA];
+	int			bytes;
+	int			quirks;
+};
+
+static void* pmac_i2c_do_begin(struct pmf_function *func, struct pmf_args *args)
+{
+	struct pmac_i2c_pf_inst *inst;
+	struct pmac_i2c_bus	*bus;
+
+	bus = pmac_i2c_find_bus(func->node);
+	if (bus == NULL) {
+		printk(KERN_ERR "low_i2c: Can't find bus for %s (pfunc)\n",
+		       func->node->full_name);
+		return NULL;
+	}
+	if (pmac_i2c_open(bus, 0)) {
+		printk(KERN_ERR "low_i2c: Can't open i2c bus for %s (pfunc)\n",
+		       func->node->full_name);
+		return NULL;
+	}
+
+	/* XXX might need GFP_ATOMIC when called during the suspend process,
+	 * but then, there are already lots of issues with suspending when
+	 * near OOM that need to be resolved, the allocator itself should
+	 * probably make GFP_NOIO implicit during suspend
+	 */
+	inst = kzalloc(sizeof(struct pmac_i2c_pf_inst), GFP_KERNEL);
+	if (inst == NULL) {
+		pmac_i2c_close(bus);
+		return NULL;
+	}
+	inst->bus = bus;
+	inst->addr = pmac_i2c_get_dev_addr(func->node);
+	inst->quirks = (int)(long)func->driver_data;
+	return inst;
+}
+
+static void pmac_i2c_do_end(struct pmf_function *func, void *instdata)
+{
+	struct pmac_i2c_pf_inst *inst = instdata;
+
+	if (inst == NULL)
+		return;
+	pmac_i2c_close(inst->bus);
+	if (inst)
+		kfree(inst);
+}
+
+static int pmac_i2c_do_read(PMF_STD_ARGS, u32 len)
+{
+	struct pmac_i2c_pf_inst *inst = instdata;
+
+	inst->bytes = len;
+	return pmac_i2c_xfer(inst->bus, inst->addr | pmac_i2c_read, 0, 0,
+			     inst->buffer, len);
+}
+
+static int pmac_i2c_do_write(PMF_STD_ARGS, u32 len, const u8 *data)
+{
+	struct pmac_i2c_pf_inst *inst = instdata;
+
+	return pmac_i2c_xfer(inst->bus, inst->addr | pmac_i2c_write, 0, 0,
+			     (u8 *)data, len);
+}
+
+/* This function is used to do the masking & OR'ing for the "rmw" type
+ * callbacks. Ze should apply the mask and OR in the values in the
+ * buffer before writing back. The problem is that it seems that
+ * various darwin drivers implement the mask/or differently, thus
+ * we need to check the quirks first
+ */
+static void pmac_i2c_do_apply_rmw(struct pmac_i2c_pf_inst *inst,
+				  u32 len, const u8 *mask, const u8 *val)
+{
+	int i;
+
+	if (inst->quirks & pmac_i2c_quirk_invmask) {
+		for (i = 0; i < len; i ++)
+			inst->scratch[i] = (inst->buffer[i] & mask[i]) | val[i];
+	} else {
+		for (i = 0; i < len; i ++)
+			inst->scratch[i] = (inst->buffer[i] & ~mask[i])
+				| (val[i] & mask[i]);
+	}
+}
+
+static int pmac_i2c_do_rmw(PMF_STD_ARGS, u32 masklen, u32 valuelen,
+			   u32 totallen, const u8 *maskdata,
+			   const u8 *valuedata)
+{
+	struct pmac_i2c_pf_inst *inst = instdata;
+
+	if (masklen > inst->bytes || valuelen > inst->bytes ||
+	    totallen > inst->bytes || valuelen > masklen)
+		return -EINVAL;
+
+	pmac_i2c_do_apply_rmw(inst, masklen, maskdata, valuedata);
+
+	return pmac_i2c_xfer(inst->bus, inst->addr | pmac_i2c_write, 0, 0,
+			     inst->scratch, totallen);
+}
+
+static int pmac_i2c_do_read_sub(PMF_STD_ARGS, u8 subaddr, u32 len)
+{
+	struct pmac_i2c_pf_inst *inst = instdata;
+
+	inst->bytes = len;
+	return pmac_i2c_xfer(inst->bus, inst->addr | pmac_i2c_read, 1, subaddr,
+			     inst->buffer, len);
+}
+
+static int pmac_i2c_do_write_sub(PMF_STD_ARGS, u8 subaddr, u32 len,
+				     const u8 *data)
+{
+	struct pmac_i2c_pf_inst *inst = instdata;
+
+	return pmac_i2c_xfer(inst->bus, inst->addr | pmac_i2c_write, 1,
+			     subaddr, (u8 *)data, len);
+}
+
+static int pmac_i2c_do_set_mode(PMF_STD_ARGS, int mode)
+{
+	struct pmac_i2c_pf_inst *inst = instdata;
+
+	return pmac_i2c_setmode(inst->bus, mode);
+}
+
+static int pmac_i2c_do_rmw_sub(PMF_STD_ARGS, u8 subaddr, u32 masklen,
+			       u32 valuelen, u32 totallen, const u8 *maskdata,
+			       const u8 *valuedata)
+{
+	struct pmac_i2c_pf_inst *inst = instdata;
+
+	if (masklen > inst->bytes || valuelen > inst->bytes ||
+	    totallen > inst->bytes || valuelen > masklen)
+		return -EINVAL;
+
+	pmac_i2c_do_apply_rmw(inst, masklen, maskdata, valuedata);
+
+	return pmac_i2c_xfer(inst->bus, inst->addr | pmac_i2c_write, 1,
+			     subaddr, inst->scratch, totallen);
+}
+
+static int pmac_i2c_do_mask_and_comp(PMF_STD_ARGS, u32 len,
+				     const u8 *maskdata,
+				     const u8 *valuedata)
+{
+	struct pmac_i2c_pf_inst *inst = instdata;
+	int i, match;
+
+	/* Get return value pointer, it's assumed to be a u32 */
+	if (!args || !args->count || !args->u[0].p)
+		return -EINVAL;
+
+	/* Check buffer */
+	if (len > inst->bytes)
+		return -EINVAL;
+
+	for (i = 0, match = 1; match && i < len; i ++)
+		if ((inst->buffer[i] & maskdata[i]) != valuedata[i])
+			match = 0;
+	*args->u[0].p = match;
+	return 0;
+}
+
+static int pmac_i2c_do_delay(PMF_STD_ARGS, u32 duration)
+{
+	msleep((duration + 999) / 1000);
+	return 0;
+}
+
+
+static struct pmf_handlers pmac_i2c_pfunc_handlers = {
+	.begin			= pmac_i2c_do_begin,
+	.end			= pmac_i2c_do_end,
+	.read_i2c		= pmac_i2c_do_read,
+	.write_i2c		= pmac_i2c_do_write,
+	.rmw_i2c		= pmac_i2c_do_rmw,
+	.read_i2c_sub		= pmac_i2c_do_read_sub,
+	.write_i2c_sub		= pmac_i2c_do_write_sub,
+	.rmw_i2c_sub		= pmac_i2c_do_rmw_sub,
+	.set_i2c_mode		= pmac_i2c_do_set_mode,
+	.mask_and_compare	= pmac_i2c_do_mask_and_comp,
+	.delay			= pmac_i2c_do_delay,
+};
+
+static void __init pmac_i2c_dev_create(struct device_node *np, int quirks)
+{
+	DBG("dev_create(%s)\n", np->full_name);
+
+	pmf_register_driver(np, &pmac_i2c_pfunc_handlers,
+			    (void *)(long)quirks);
+}
+
+static void __init pmac_i2c_dev_init(struct device_node *np, int quirks)
+{
+	DBG("dev_create(%s)\n", np->full_name);
+
+	pmf_do_functions(np, NULL, 0, PMF_FLAGS_ON_INIT, NULL);
+}
+
+static void pmac_i2c_dev_suspend(struct device_node *np, int quirks)
+{
+	DBG("dev_suspend(%s)\n", np->full_name);
+	pmf_do_functions(np, NULL, 0, PMF_FLAGS_ON_SLEEP, NULL);
+}
+
+static void pmac_i2c_dev_resume(struct device_node *np, int quirks)
+{
+	DBG("dev_resume(%s)\n", np->full_name);
+	pmf_do_functions(np, NULL, 0, PMF_FLAGS_ON_WAKE, NULL);
+}
+
+void pmac_pfunc_i2c_suspend(void)
+{
+	pmac_i2c_devscan(pmac_i2c_dev_suspend);
+}
+
+void pmac_pfunc_i2c_resume(void)
+{
+	pmac_i2c_devscan(pmac_i2c_dev_resume);
+}
+
 /*
- * Initialize us: probe all i2c busses on the machine and instantiate
- * busses.
+ * Initialize us: probe all i2c busses on the machine, instantiate
+ * busses and platform functions as needed.
  */
 /* This is non-static as it might be called early by smp code */
 int __init pmac_i2c_init(void)
@@ -1187,6 +1470,10 @@ int __init pmac_i2c_init(void)
 	/* Probe SMU i2c busses */
 	smu_i2c_probe();
 #endif
+
+	/* Now add plaform functions for some known devices */
+	pmac_i2c_devscan(pmac_i2c_dev_create);
+
 	return 0;
 }
 arch_initcall(pmac_i2c_init);
@@ -1216,6 +1503,9 @@ static int __init pmac_i2c_create_platfo
 		platform_device_add(bus->platform_dev);
 	}
 
+	/* Now call platform "init" functions */
+	pmac_i2c_devscan(pmac_i2c_dev_init);
+
 	return 0;
 }
 subsys_initcall(pmac_i2c_create_platform_devices);
Index: linux-work/drivers/macintosh/via-pmu.c
===================================================================
--- linux-work.orig/drivers/macintosh/via-pmu.c	2006-01-07 10:53:21.000000000 +1100
+++ linux-work/drivers/macintosh/via-pmu.c	2006-01-07 10:54:03.000000000 +1100
@@ -55,6 +55,8 @@
 #include <asm/sections.h>
 #include <asm/irq.h>
 #include <asm/pmac_feature.h>
+#include <asm/pmac_pfunc.h>
+#include <asm/pmac_low_i2c.h>
 #include <asm/uaccess.h>
 #include <asm/mmu_context.h>
 #include <asm/cputable.h>
@@ -2105,6 +2107,10 @@ pmac_suspend_devices(void)
 		return -EBUSY;
 	}
 
+	/* Call platform functions marked "on sleep" */
+	pmac_pfunc_i2c_suspend();
+	pmac_pfunc_base_suspend();
+
 	/* Stop preemption */
 	preempt_disable();
 
@@ -2175,6 +2181,10 @@ pmac_wakeup_devices(void)
 	mdelay(10);
 	preempt_enable();
 
+	/* Call platform functions marked "on wake" */
+	pmac_pfunc_base_resume();
+	pmac_pfunc_i2c_resume();
+
 	/* Resume devices */
 	device_resume();
 
Index: linux-work/include/asm-powerpc/pmac_low_i2c.h
===================================================================
--- linux-work.orig/include/asm-powerpc/pmac_low_i2c.h	2006-01-07 10:53:21.000000000 +1100
+++ linux-work/include/asm-powerpc/pmac_low_i2c.h	2006-01-07 10:54:03.000000000 +1100
@@ -99,6 +99,9 @@ extern int pmac_i2c_setmode(struct pmac_
 extern int pmac_i2c_xfer(struct pmac_i2c_bus *bus, u8 addrdir, int subsize,
 			 u32 subaddr, u8 *data,  int len);
 
+/* Suspend/resume code called by via-pmu directly for now */
+extern void pmac_pfunc_i2c_suspend(void);
+extern void pmac_pfunc_i2c_resume(void);
 
 #endif /* __KERNEL__ */
 #endif /* __PMAC_LOW_I2C_H__ */

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox