LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH 2/3 v4] P4080/mtd: Only make elbc nand driver detect nand flash partitions
From: Scott Wood @ 2010-10-04 15:38 UTC (permalink / raw)
  To: Zang Roy-R61911
  Cc: Wood Scott-B07421, dedekind1, Lan Chunhe-B25806, linuxppc-dev,
	linux-mtd, akpm, dwmw2, Gala Kumar-B11780
In-Reply-To: <3850A844E6A3854C827AC5C0BEC7B60A256099@zch01exm23.fsl.freescale.net>

On Sat, 2 Oct 2010 05:36:27 -0700
"Zang Roy-R61911" <r61911@freescale.com> wrote:

> 
> 
> > -----Original Message-----
> > From: Anton Vorontsov [mailto:cbouatmailru@gmail.com]
> > Sent: Monday, September 20, 2010 21:19 PM
> > To: Zang Roy-R61911
> > Cc: linux-mtd@lists.infradead.org; dwmw2@infradead.org; dedekind1@gmail.com;
> > akpm@linux-foundation.org; Lan Chunhe-B25806; Wood Scott-B07421; Gala Kumar-
> > B11780; linuxppc-dev@ozlabs.org
> > Subject: Re: [PATCH 2/3 v4] P4080/mtd: Only make elbc nand driver detect nand
> > flash partitions
> > 
> > On Fri, Sep 17, 2010 at 03:01:08PM +0800, Roy Zang wrote:
> > [...]
> > > +static struct mutex fsl_elbc_nand_mutex;
> > > +
> > > +static int __devinit fsl_elbc_nand_probe(struct platform_device *dev)
> > >  {
> > > -	struct fsl_lbc_regs __iomem *lbc = ctrl->regs;
> > > +	struct fsl_lbc_regs __iomem *lbc;
> > >  	struct fsl_elbc_mtd *priv;
> > >  	struct resource res;
> > > +	struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl = NULL;
> > 
> > No need for = NULL.
> Any harm? Or just personal habit or style? Can you explain about why?

Besides not wanting superfluous code on general principle, it could
hide a bug if in the future the real initialization is missing on some
code path.  It would become a runtime NULL dereference rather than a
compiler warning.

-Scott

^ permalink raw reply

* Re: Serial RapidIO Maintaintance read causes lock up
From: Bounine, Alexandre @ 2010-10-04 15:49 UTC (permalink / raw)
  To: bastiaan.nijkamp; +Cc: linuxppc-dev

Hi Bastiaan,

Are you trying board-to-board connection?
I am not familiar with WRS SBC8548 board - which type of connector they
use for SRIO?

Assuming that all configuration is correct,
I would recommend first to try setting up x1 link mode at the lowest
link speed.
The x4 mode may present challenges in some cases.

For quick test you may just add port width override into fsl_rio.c
like shown below (ugly but sometimes it helps ;) ):

@@ -1461,10 +1461,16 @@ int fsl_rio_setup(struct platform_device *dev)
 	rio_register_mport(port);
=20
 	priv->regs_win =3D ioremap(regs.start, regs.end - regs.start + 1);
 	rio_regs_win =3D priv->regs_win;
=20
+dev_info(&dev->dev, "Overriding RIO_PORT setting to single lane 0\n");
+out_be32(priv->regs_win + 0x15C, in_be32(priv->regs_win + 0x15C) |
0x800000);
+out_be32(priv->regs_win + 0x15C, in_be32(priv->regs_win + 0x15C) |
0x2000000);
+out_be32(priv->regs_win + 0x15C, in_be32(priv->regs_win + 0x15C) &
~0x800000);
+msleep(100);
+
 	/* Probe the master port phy type */
 	ccsr =3D in_be32(priv->regs_win + RIO_CCSR);
 	port->phy_type =3D (ccsr & 1) ? RIO_PHY_SERIAL : RIO_PHY_PARALLEL;
 	dev_info(&dev->dev, "RapidIO PHY type: %s\n",
 			(port->phy_type =3D=3D RIO_PHY_PARALLEL) ?
"parallel" :


Let me know what happens.
Please keep me in the CC: list next time when posting RapidIO questions
to the linuxppc-dev or kernel mailing lists.

Regards,

Alex.
=20

^ permalink raw reply

* Re: use of BAT before taking over the MMU
From: Albert Cahalan @ 2010-10-04 16:06 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: linuxppc-dev
In-Reply-To: <63799.84.105.60.153.1286166325.squirrel@gate.crashing.org>

On Mon, Oct 4, 2010 at 12:25 AM, Segher Boessenkool
<segher@kernel.crashing.org> wrote:

> The PowerPC OF binding requires the firmware to save and restore
> the BATs on entry to / exit from the firmware.

This sucks, because using the BAT is **much** easier for
the firmware. In my case, it also means I don't need to worry
about Linux stomping on anything -- I have nothing in RAM.

(this is an emulator, but I don't want to cheat too much
because adding special cases affects performance)

Page tables would need to go in RAM. If Linux wants to
use that memory...? It seems that Linux does tend to ask;
will it panic if I refuse? Are there addresses Linux won't
ever ask for?

It also looks like I could just start up Linux w/o the MMU on.
I'm just making 1:1 mappings anyway.

^ permalink raw reply

* Re: powerpc, fs_enet: scanning PHY after Linux is up
From: Grant Likely @ 2010-10-04 16:20 UTC (permalink / raw)
  To: hs; +Cc: linuxppc-dev, devicetree-discuss, Holger Brunck, Detlev Zundel,
	netdev
In-Reply-To: <4CA9830A.2030605@denx.de>

On Mon, Oct 4, 2010 at 1:32 AM, Heiko Schocher <hs@denx.de> wrote:
> Hello all,
>
> we have on the mgcoge arch/powerpc/boot/dts/mgcoge.dts 3 fs_enet
> devices. The first is accessible on boot, and so get correct
> probed and works fine. For the other two fs_enet devices the PHYs
> are on startup in reset, and gets later, through userapplikations,
> out of reset ... so, on bootup, this 2 fs_enet devices could
> not detect the PHY in drivers/of/of_mdio.c of_mdiobus_register(),
> and if we want to use them later, we get for example:
>
> -bash-3.2# ifconfig eth2 172.31.31.33
> net eth2: Could not attach to PHY
> SIOCSIFFLAGS: No such device
>
> So the problem is, that we cannot rescan the PHYs, if they are
> accessible. Also we could not load the fs_enet driver as a module,
> because the first port is used fix.
>
> So, first question which comes in my mind, is:
>
> Is detecting the phy in drivers/of/of_mdio.c of_mdiobus_register()
> the right place, or should it not better be done, when really
> using the port?
>
> But we found another way to solve this issue:
>
> After the PHYs are out of reset, we just have to rescan the PHYs
> with (for example PHY with addr 1)
>
> err =3D mdiobus_scan(bus, 1);
>
> and
>
> of_find_node_by_path("/soc@f0000000/cpm@119c0/mdio@10d40/ethernet-phy@1")=
;
> of_node_get(np);
> dev_archdata_set_node(&err->dev.archdata, np);
>
> but thats just a hack ...

Yeah, that's a hack.  It really needs to be done via the of_mdio
mechanisms so that dt <--> phy_device linkages remain consistent.

> So, the question is, is there a possibility to solve this problem?
>
> If there is no standard option, what would be with adding a
> "scan_phy" file in
>
> /proc/device-tree/soc\@f0000000/cpm\@119c0/mdio\@10d40
> (or better destination?)
>
> which with we could rescan a PHY with
> "echo addr > /proc/device-tree/soc\@f0000000/cpm\@119c0/mdio\@10d40/scan_=
phy"
> (so there is no need for using of_find_node_by_path(), as we should
> =A0have the associated device node here, and can step through the child
> =A0nodes with "for_each_child_of_node(np, child)" and check if reg =3D=3D=
 addr)
>
> or shouldn;t be at least, if the phy couldn;t be found when opening
> the port, retrigger a scanning, if the phy now is accessible?

One option would be to still register a phy_device for each phy
described in the device tree, but defer binding a driver to each phy
that doesn't respond.  Then at of_phy_find_device() time, if it
matches with a phy_device that isn't bound to a driver yet, then
re-trigger the binding operation.  At which point the phy id can be
probed and the correct driver can be chosen.  If binding succeeds,
then return the phy_device handle.  If not, then fail as it currently
does.

g.

^ permalink raw reply

* RE: [PATCH] PPC4xx: ADMA separating SoC specific functions
From: Tirumala Marri @ 2010-10-04 17:30 UTC (permalink / raw)
  To: Greg KH, Dan Williams
  Cc: linux-raid, linuxppc-dev, Wolfgang Denk, yur, linux-crypto
In-Reply-To: <20101002184957.GA17774@kroah.com>

> >
> > You definitely need to be able to resolve "used but not defined" and
> > "defined but not used" warnings before tackling a driver conversion
> > like this.  In light of this comment I wonder if it would be
> > appropriate to submit your original driver, that just duplicated
> > routines from the ppc440spe driver, to the -staging tree.  Then it
> > would be available for someone familiar with driver conversions to
> > take a shot at unifying.
> >
> > Greg, is this an appropriate use of -staging?
>
> Possibly, but I really don't like duplication if possible.  What's
> keeping this code from being fixed up now properly?

[Marri] Hello Greg, I am working on restructuring ppc4xx/adma.c driver
into
Common code and SoC specific code. This way I can add support for similar
DMA engines.
In this process I had to declare some Of the functions non static so that
I can suppress "defined but not used" and "used but not defined".


Here is what series of patches I planned to work on.

1. First set patches to re-arrange the code. Functionally no change except
Structured into different files.
2. Second set to rename the common functions which are shared between SoC
dma-engines.
3. Add support of new DMA engine for different SoC.

I am working on first patch set right now.


Regards,
Marri

^ permalink raw reply

* in_atomic() check in page_cache_get_speculative()
From: Scott Wood @ 2010-10-04 20:22 UTC (permalink / raw)
  To: Nick Piggin, linuxppc-dev

I'm seeing the in_atomic() check in page_cache_get_speculative()
(linux/pagemap.h:138) fail when running e500 KVM with .  It's coming
from get_user_pages_fast(), from KVM's hva_to_pfn().  This is on kvm.git
plus a few local patches that should be completely unrelated, but it
looks like this code hasn't changed much in a couple years.

Interrupts are disabled by get_user_pages_fast(), but apparently
preemption was not separately disabled.  The comment in
page_cache_get_speculative() says that preemption disabling is done by
rcu_read_lock(), and that "this function must be called inside the same
rcu_read_lock() section as has been used to lookup the page in the
pagecache radix-tree (or page table)".

Where is this RCU lock supposed to be acquired?  I don't see any RCU in
arch/powerpc/mm/gup.c.  Is it buried in some macro or function call?

-Scott

^ permalink raw reply

* Re: in_atomic() check in page_cache_get_speculative()
From: Scott Wood @ 2010-10-04 20:37 UTC (permalink / raw)
  To: Nick Piggin, linuxppc-dev
In-Reply-To: <20101004152259.25c56ad2@udp111988uds.am.freescale.net>

[Updated with Nick's current address; previous one bounced]

On Mon, 4 Oct 2010 15:22:59 -0500
Scott Wood <scottwood@freescale.com> wrote:

> I'm seeing the in_atomic() check in page_cache_get_speculative()
> (linux/pagemap.h:138) fail when running e500 KVM with .  

Sorry, that should finish as "with CONFIG_DEBUG_VM."

> It's coming
> from get_user_pages_fast(), from KVM's hva_to_pfn().  This is on kvm.git
> plus a few local patches that should be completely unrelated, but it
> looks like this code hasn't changed much in a couple years.
> 
> Interrupts are disabled by get_user_pages_fast(), but apparently
> preemption was not separately disabled.  The comment in
> page_cache_get_speculative() says that preemption disabling is done by
> rcu_read_lock(), and that "this function must be called inside the same
> rcu_read_lock() section as has been used to lookup the page in the
> pagecache radix-tree (or page table)".
> 
> Where is this RCU lock supposed to be acquired?  I don't see any RCU in
> arch/powerpc/mm/gup.c.  Is it buried in some macro or function call?
> 
> -Scott

^ permalink raw reply

* Re: Introduce support for little endian PowerPC
From: Benjamin Herrenschmidt @ 2010-10-04 22:50 UTC (permalink / raw)
  To: Michel Dänzer; +Cc: paulus, linuxppc-dev, linux-kernel, Ian Munsie
In-Reply-To: <1286188242.15020.349.camel@thor.local>

On Mon, 2010-10-04 at 12:30 +0200, Michel Dänzer wrote:

> > And last I looked X still pukes if you give it a pixmap in non native
> > byte order but that might have been fixed.
> 
> I'm not sure what exactly you mean by that, but I'm not aware of any
> such issues offhand.

Hrm, I meant on the DDX side. Anyways, doesn't matter. Even if it works
fine on X side. Fact is, there's tons and tons of existing SW stack and
drivers on the field that are totally incapable of doing BE and
essentially unfixable without major work that the customer(s) is(are)
unwilling to do at this stage.

(Think embedded gfx IP cores mostly, including codecs etc...)

> I didn't say anything about that, just that IME it should be mostly
> possible to deal with endianness within the driver stack.

To some extent yes. Completely, I'm not sure. Apps manipulating pixels,
such as video players doing hand-made overlay etc... will potentially
have issues. It's more than actual pixel byte ordering. It's anything
that accesses a quantity in memory using different size accessors, ie,
storing a u32 and then expecting to find the LSB at u8* of the same
address etc... that sort of stuff happens more often in gfx-oriented
code than anywhere else in my experience.

> Note that I'm not arguing against these changes, just pointing out some
> apparent inaccuracies in the reasoning for them.

Right, I possibly made an incorrect statement relative to Xorg (I had
assumed the fb layer only worked properly in native endian format), but
that doesn't matter much since the problem here is existing code &
drivers and goes way beyond X (probably no X on the target setups
anyways).

Cheers,
Ben

^ permalink raw reply

* Re: [PATCH 3/9] v3 Add section count to memory_block struct
From: KAMEZAWA Hiroyuki @ 2010-10-05  5:08 UTC (permalink / raw)
  To: Nathan Fontenot
  Cc: Greg KH, steiner, linux-kernel, Dave Hansen, linux-mm, Robin Holt,
	linuxppc-dev
In-Reply-To: <4CA628D0.6030508@austin.ibm.com>

On Fri, 01 Oct 2010 13:30:40 -0500
Nathan Fontenot <nfont@austin.ibm.com> wrote:

> Add a section count property to the memory_block struct to track the number
> of memory sections that have been added/removed from a memory block. This
> allows us to know when the last memory section of a memory block has been
> removed so we can remove the memory block.
> 
> Signed-off-by: Nathan Fontenot <nfont@austin.ibm.com>
> 

Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>

a nitpick,


> Index: linux-next/include/linux/memory.h
> ===================================================================
> --- linux-next.orig/include/linux/memory.h	2010-09-29 14:56:29.000000000 -0500
> +++ linux-next/include/linux/memory.h	2010-09-30 14:13:50.000000000 -0500
> @@ -23,6 +23,8 @@
>  struct memory_block {
>  	unsigned long phys_index;
>  	unsigned long state;
> +	int section_count;

I prefer
	int section_count; /* updated under mutex */

or some for this kind of non-atomic counters. but nitpick.

^ permalink raw reply

* Re: [PATCH 4/9] v3 Allow memory blocks to span multiple memory sections
From: KAMEZAWA Hiroyuki @ 2010-10-05  5:13 UTC (permalink / raw)
  To: Nathan Fontenot
  Cc: Greg KH, steiner, linux-kernel, Dave Hansen, linux-mm, Robin Holt,
	linuxppc-dev
In-Reply-To: <4CA62FE2.2000003@austin.ibm.com>

On Fri, 01 Oct 2010 14:00:50 -0500
Nathan Fontenot <nfont@austin.ibm.com> wrote:

> Update the memory sysfs code such that each sysfs memory directory is now
> considered a memory block that can span multiple memory sections per
> memory block.  The default size of each memory block is SECTION_SIZE_BITS
> to maintain the current behavior of having a single memory section per
> memory block (i.e. one sysfs directory per memory section).
> 
> For architectures that want to have memory blocks span multiple
> memory sections they need only define their own memory_block_size_bytes()
> routine.
> 
This should be commented in code before MEMORY_BLOCK_SIZE declaration.

> Signed-off-by: Nathan Fontenot <nfont@austin.ibm.com>
> 

Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>

^ permalink raw reply

* Re: [PATCH 5/9] v3 rename phys_index properties of memory block struct
From: KAMEZAWA Hiroyuki @ 2010-10-05  5:14 UTC (permalink / raw)
  To: Nathan Fontenot
  Cc: Greg KH, steiner, linux-kernel, Dave Hansen, linux-mm, Robin Holt,
	linuxppc-dev
In-Reply-To: <4CA62982.5080900@austin.ibm.com>

On Fri, 01 Oct 2010 13:33:38 -0500
Nathan Fontenot <nfont@austin.ibm.com> wrote:

> Update the 'phys_index' property of a the memory_block struct to be
> called start_section_nr, and add a end_section_nr property.  The
> data tracked here is the same but the updated naming is more in line
> with what is stored here, namely the first and last section number
> that the memory block spans.
> 
> The names presented to userspace remain the same, phys_index for
> start_section_nr and end_phys_index for end_section_nr, to avoid breaking
> anything in userspace.
> 
> Signed-off-by: Nathan Fontenot <nfont@austin.ibm.com>

Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>

^ permalink raw reply

* Re: [PATCH 6/9] v3 Update node sysfs code
From: KAMEZAWA Hiroyuki @ 2010-10-05  5:15 UTC (permalink / raw)
  To: Nathan Fontenot
  Cc: Greg KH, steiner, linux-kernel, Dave Hansen, linux-mm, Robin Holt,
	linuxppc-dev
In-Reply-To: <4CA629BA.60100@austin.ibm.com>

On Fri, 01 Oct 2010 13:34:34 -0500
Nathan Fontenot <nfont@austin.ibm.com> wrote:

> Update the node sysfs code to be aware of the new capability for a memory
> block to contain multiple memory sections and be aware of the memory block
> structure name changes (start_section_nr).  This requires an additional
> parameter to unregister_mem_sect_under_nodes so that we know which memory
> section of the memory block to unregister.
> 
> Signed-off-by: Nathan Fontenot <nfont@austin.ibm.com>
Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>

^ permalink raw reply

* Re: advice on reading a call trace
From: Jean-Mickael Guerin @ 2010-10-05  5:21 UTC (permalink / raw)
  To: linuxppc-dev
In-Reply-To: <4CA9B967.9060907@6wind.com>

SLUB is turned on, and the oops does not seem to happen when SLAB replaces SLUB.
I just got lucky with SLAB, or does it sound familiar on ppc?

Regards,
Jean-Mickael

On 10/4/2010 1:24 PM, Jean-Mickael Guerin wrote:
> Hello,
> I'm stepping into ppc world and I'd like to know how to read this call trace,
> I enabled debug options but I'm not able to track the origin of this bug, I mean
> what happens before handle_page_fault():
> 
> Unable to handle kernel paging request for data at address 0x00000008
> Faulting instruction address: 0xc00abcd8
> 
> [c1d0dd40] [c00ab2e4] swapin_readahead+0x34/0xbc
> [c1d0dd80] [c009e91c] handle_mm_fault+0x724/0x9b0
> [c1d0dde0] [c0014e10] do_page_fault+0x2e8/0x55c
> [c1d0df40] [c000fc8c] handle_page_fault+0xc/0x80
> Instruction dump:
> 80010034 7d435378 bb210014 38210030 7c0803a6 4e800020 7d695b78 4bffff00
> 387a007c 4847616d 38000001 7c00f830 <817b0008> 7d3c0214 7f895840 7f9ee378
> Kernel panic - not syncing: Fatal exception
> 
> Another one:
> NIP: c00b6980 LR: c00b6978 CTR: 0f9ffb20
> REGS: d6a9dc60 TRAP: 0300   Not tainted  (2.6.34.6-00392-g31e1857)
> MSR: 10029002   CR: 24004442  XER: 00000000
> DEAR: 00000008, ESR: 00000000
> TASK = da6a7440[4915] 'smrd' THREAD: d6a9c000 CPU: 0
> GPR00: 00000008 d6a9dd10 da6a7440 c0738340 00000000 00000000 00000000 00000001
> GPR08: 00000000 00000000 c00b6978 00000000 44004442 10027f04 c077790c d79f94a8
> GPR16: d6a9dd88 c07a0000 d72301f0 d6a9c000 000001ff 00000000 0f9ffb20 da5c6f78
> GPR24: d79f9440 c0738340 d6a9dd48 00000000 07832400 00000001 00000003 07832400
> NIP [c00b6980] valid_swaphandles+0x19c/0x1d0
> LR [c00b6978] valid_swaphandles+0x194/0x1d0
> Call Trace:
> [d6a9dd10] [c00b6978] valid_swaphandles+0x194/0x1d0 (unreliable)
> [d6a9dd40] [c00b5a10] swapin_readahead+0x34/0xbc
> [d6a9dd80] [c00a9064] handle_mm_fault+0x7c0/0x868
> [d6a9dde0] [c00158d8] do_page_fault+0x2fc/0x570
> [d6a9df40] [c001061c] handle_page_fault+0xc/0x80
> Instruction dump:
> 38210030 7c0803a6 4e800020 7d695b78 4bffff04 3d20c074 39298300 3b290040
> 7f23cb78 484843a9 38000001 7c00f030 <817b0008> 7d3f0214 7f895840 7ffdfb78
> Kernel panic - not syncing: Fatal exception
> Call Trace:
> [d6a9dba0] [c000765c] show_stack+0x40/0x15c (unreliable)
> [d6a9dbd0] [c053b780] panic+0x94/0x118
> [d6a9dc20] [c000d630] die+0x15c/0x1bc
> [d6a9dc40] [c00155a4] bad_page_fault+0x90/0xc8
> [d6a9dc50] [c001068c] handle_page_fault+0x7c/0x80
> [d6a9dd10] [c00b6978] valid_swaphandles+0x194/0x1d0
> [d6a9dd40] [c00b5a10] swapin_readahead+0x34/0xbc
> [d6a9dd80] [c00a9064] handle_mm_fault+0x7c0/0x868
> [d6a9dde0] [c00158d8] do_page_fault+0x2fc/0x570
> [d6a9df40] [c001061c] handle_page_fault+0xc/0x80
> Rebooting in 5 seconds..
> 
> Thanks,
> Jean-Mickael

^ permalink raw reply

* Re: [PATCH 9/9] v3 Update memory hotplug documentation
From: KAMEZAWA Hiroyuki @ 2010-10-05  5:18 UTC (permalink / raw)
  To: Nathan Fontenot
  Cc: Greg KH, steiner, linux-kernel, Dave Hansen, linux-mm, Robin Holt,
	linuxppc-dev
In-Reply-To: <4CA62A7D.8030905@austin.ibm.com>

On Fri, 01 Oct 2010 13:37:49 -0500
Nathan Fontenot <nfont@austin.ibm.com> wrote:

> Update the memory hotplug documentation to reflect the new behaviors of
> memory blocks reflected in sysfs.
> 
> Signed-off-by: Nathan Fontenot <nfont@austin.ibm.com>
> 
Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>

Thank you for your patient work!.



> ---
>  Documentation/memory-hotplug.txt |   47 +++++++++++++++++++++++++--------------
>  1 file changed, 31 insertions(+), 16 deletions(-)
> 
> Index: linux-next/Documentation/memory-hotplug.txt
> ===================================================================
> --- linux-next.orig/Documentation/memory-hotplug.txt	2010-09-29 14:56:24.000000000 -0500
> +++ linux-next/Documentation/memory-hotplug.txt	2010-09-30 14:59:47.000000000 -0500
> @@ -126,36 +126,51 @@
>  --------------------------------
>  4 sysfs files for memory hotplug
>  --------------------------------
> -All sections have their device information under /sys/devices/system/memory as
> +All sections have their device information in sysfs.  Each section is part of
> +a memory block under /sys/devices/system/memory as
>  
>  /sys/devices/system/memory/memoryXXX
> -(XXX is section id.)
> +(XXX is the section id.)
>  
> -Now, XXX is defined as start_address_of_section / section_size.
> +Now, XXX is defined as (start_address_of_section / section_size) of the first
> +section contained in the memory block.  The files 'phys_index' and
> +'end_phys_index' under each directory report the beginning and end section id's
> +for the memory block covered by the sysfs directory.  It is expected that all
> +memory sections in this range are present and no memory holes exist in the
> +range. Currently there is no way to determine if there is a memory hole, but
> +the existence of one should not affect the hotplug capabilities of the memory
> +block.
>  
>  For example, assume 1GiB section size. A device for a memory starting at
>  0x100000000 is /sys/device/system/memory/memory4
>  (0x100000000 / 1Gib = 4)
>  This device covers address range [0x100000000 ... 0x140000000)
>  
> -Under each section, you can see 4 files.
> +Under each section, you can see 4 or 5 files, the end_phys_index file being
> +a recent addition and not present on older kernels.
>  
> -/sys/devices/system/memory/memoryXXX/phys_index
> +/sys/devices/system/memory/memoryXXX/start_phys_index
> +/sys/devices/system/memory/memoryXXX/end_phys_index
>  /sys/devices/system/memory/memoryXXX/phys_device
>  /sys/devices/system/memory/memoryXXX/state
>  /sys/devices/system/memory/memoryXXX/removable
>  
> -'phys_index' : read-only and contains section id, same as XXX.
> -'state'      : read-write
> -               at read:  contains online/offline state of memory.
> -               at write: user can specify "online", "offline" command
> -'phys_device': read-only: designed to show the name of physical memory device.
> -               This is not well implemented now.
> -'removable'  : read-only: contains an integer value indicating
> -               whether the memory section is removable or not
> -               removable.  A value of 1 indicates that the memory
> -               section is removable and a value of 0 indicates that
> -               it is not removable.
> +'phys_index'      : read-only and contains section id of the first section
> +		    in the memory block, same as XXX.
> +'end_phys_index'  : read-only and contains section id of the last section
> +		    in the memory block.
> +'state'           : read-write
> +                    at read:  contains online/offline state of memory.
> +                    at write: user can specify "online", "offline" command
> +                    which will be performed on al sections in the block.
> +'phys_device'     : read-only: designed to show the name of physical memory
> +                    device.  This is not well implemented now.
> +'removable'       : read-only: contains an integer value indicating
> +                    whether the memory block is removable or not
> +                    removable.  A value of 1 indicates that the memory
> +                    block is removable and a value of 0 indicates that
> +                    it is not removable. A memory block is removable only if
> +                    every section in the block is removable.
>  
>  NOTE:
>    These directories/files appear after physical memory hotplug phase.
> 
> 
> 

^ permalink raw reply

* Re: [PATCH 1/9] v3 Move find_memory_block routine
From: KAMEZAWA Hiroyuki @ 2010-10-05  5:01 UTC (permalink / raw)
  To: Nathan Fontenot
  Cc: Greg KH, steiner, linux-kernel, Dave Hansen, linux-mm, Robin Holt,
	linuxppc-dev
In-Reply-To: <4CA62857.4030803@austin.ibm.com>

On Fri, 01 Oct 2010 13:28:39 -0500
Nathan Fontenot <nfont@austin.ibm.com> wrote:

> Move the find_memory_block() routine up to avoid needing a forward
> declaration in subsequent patches.
> 
> Signed-off-by: Nathan Fontenot <nfont@austin.ibm.com>
> 
Reviewd-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>

^ permalink raw reply

* Re: [PATCH 2/9] v3 Add mutex for adding/removing memory blocks
From: KAMEZAWA Hiroyuki @ 2010-10-05  5:06 UTC (permalink / raw)
  To: Nathan Fontenot
  Cc: Greg KH, steiner, linux-kernel, Dave Hansen, linux-mm, Robin Holt,
	linuxppc-dev
In-Reply-To: <4CA62896.2060307@austin.ibm.com>

On Fri, 01 Oct 2010 13:29:42 -0500
Nathan Fontenot <nfont@austin.ibm.com> wrote:

> Add a new mutex for use in adding and removing of memory blocks.  This
> is needed to avoid any race conditions in which the same memory block could
> be added and removed at the same time.
> 
> Signed-off-by: Nathan Fontenot <nfont@austin.ibm.com>
> 
Reviewed-By: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>

^ permalink raw reply

* Re: use of BAT before taking over the MMU
From: Segher Boessenkool @ 2010-10-05  7:54 UTC (permalink / raw)
  To: Albert Cahalan; +Cc: linuxppc-dev
In-Reply-To: <AANLkTikt9e5s3UUn1+k=NY7UhqosM5qkgdih=UD+Hd+L@mail.gmail.com>

>> The PowerPC OF binding requires the firmware to save and restore
>> the BATs on entry to / exit from the firmware.
>
> This sucks, because using the BAT is **much** easier for
> the firmware. In my case, it also means I don't need to worry
> about Linux stomping on anything -- I have nothing in RAM.

It's easy to save and restore the BATs on firmware entry/exit,
where do you see a problem?

> Page tables would need to go in RAM. If Linux wants to
> use that memory...?

Same way as when the client uses *any* memory OF has claimed:
it has to stop calling OF from then on.

> It seems that Linux does tend to ask;
> will it panic if I refuse? Are there addresses Linux won't
> ever ask for?

Linux always "kills" OF pretty early on.

> It also looks like I could just start up Linux w/o the MMU on.

Yes, that's common and works.  You will still need BATs (or
something else) to do I/O from the firmware though.


Segher

^ permalink raw reply

* Re: use of BAT before taking over the MMU
From: Benjamin Herrenschmidt @ 2010-10-05  8:09 UTC (permalink / raw)
  To: Albert Cahalan; +Cc: linuxppc-dev
In-Reply-To: <AANLkTikPhpvJetY+NDFggYE6Wp6ppyt2BLmzEbsiwHuZ@mail.gmail.com>

On Sat, 2010-10-02 at 14:32 -0400, Albert Cahalan wrote:
> On the prom boot path, with the firmware supposed to
> be managing the MMU, there is a case where:
> 
> 1. Linux changes some BAT registers.
> 2. Bits 0x00000070 are/become set in the MSR.
> 3. Linux takes an MMU fault.

Meeep ! Linux should never take an MMU fault at that point :-) If it
does, then there's a bug somewhere that needs squashing.

> 4. The firmware handles it.
> 
> AFAIK, you can't expect the firmware to leave the BAT alone.
> If the firmware provides mapping services by using the BAT
> as a software-filled TLB, Linux's BAT changes may be lost.
> 
> You also can't expect that your BAT changes will not conflict
> with mappings that the firmware uses for itself. The firmware
> might write to your new BAT mapping, relying on those virtual
> addresses to be something else entirely.

Right, which is why the moment Linux takes over the BATs, it shouldn't
call into FW anymore nor take faults.

Cheers,
Ben.

^ permalink raw reply

* Re: use of BAT before taking over the MMU
From: Benjamin Herrenschmidt @ 2010-10-05  8:10 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: Albert Cahalan, linuxppc-dev
In-Reply-To: <63799.84.105.60.153.1286166325.squirrel@gate.crashing.org>

On Mon, 2010-10-04 at 06:25 +0200, Segher Boessenkool wrote:
> > On the prom boot path, with the firmware supposed to
> > be managing the MMU, there is a case where:
> >
> > 1. Linux changes some BAT registers.
> > 2. Bits 0x00000070 are/become set in the MSR.
> > 3. Linux takes an MMU fault.
> > 4. The firmware handles it.
> >
> > AFAIK, you can't expect the firmware to leave the BAT alone.
> > If the firmware provides mapping services by using the BAT
> > as a software-filled TLB, Linux's BAT changes may be lost.
> >
> > You also can't expect that your BAT changes will not conflict
> > with mappings that the firmware uses for itself. The firmware
> > might write to your new BAT mapping, relying on those virtual
> > addresses to be something else entirely.
> 
> The PowerPC OF binding requires the firmware to save and restore
> the BATs on entry to / exit from the firmware.

I'm not sure he was talking about OF here... In any case, we don't muck
around with BATs until after we're done with OF anyways.

Cheers,
Ben.

^ permalink raw reply

* Re: use of BAT before taking over the MMU
From: Benjamin Herrenschmidt @ 2010-10-05  8:11 UTC (permalink / raw)
  To: Albert Cahalan; +Cc: linuxppc-dev
In-Reply-To: <AANLkTikt9e5s3UUn1+k=NY7UhqosM5qkgdih=UD+Hd+L@mail.gmail.com>

On Mon, 2010-10-04 at 12:06 -0400, Albert Cahalan wrote:
> On Mon, Oct 4, 2010 at 12:25 AM, Segher Boessenkool
> <segher@kernel.crashing.org> wrote:
> 
> > The PowerPC OF binding requires the firmware to save and restore
> > the BATs on entry to / exit from the firmware.
> 
> This sucks, because using the BAT is **much** easier for
> the firmware. In my case, it also means I don't need to worry
> about Linux stomping on anything -- I have nothing in RAM.

What FW are we talking about here anyways ? As I said, Linux isn't
supposed to take any fault from the moment it starts setting up BATs to
the moment it takes over exceptions and can handle faults all by itself.

> (this is an emulator, but I don't want to cheat too much
> because adding special cases affects performance)
> 
> Page tables would need to go in RAM. If Linux wants to
> use that memory...? It seems that Linux does tend to ask;
> will it panic if I refuse? Are there addresses Linux won't
> ever ask for?
> 
> It also looks like I could just start up Linux w/o the MMU on.
> I'm just making 1:1 mappings anyway.

Cheers,
Ben.

^ permalink raw reply

* Re: Serial RapidIO Maintaintance read causes lock up
From: Bastiaan Nijkamp @ 2010-10-05  8:56 UTC (permalink / raw)
  To: Bounine, Alexandre; +Cc: linuxppc-dev
In-Reply-To: <0CE8B6BE3C4AD74AB97D9D29BD24E552013B97E8@CORPEXCH1.na.ads.idt.com>

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

Hi Alex,

Thanks for your advice. We are trying to make a board-to-board connection
without any additional hardware (eg. a switch). The boards use a 50-pin,
right-angle MEC8-125-02-L-D-RA1 connector from SAMTEC and are connected
trough a EEDP-016-12.00-RA1-RA2-2 cross cable from SAMTEC. I hope this
information is sufficient since there is not much one can find about it on
Google. In addition, you can see a picture of the board including the
connector in the datasheet located at
http://www.windriver.com/products/product-notes/SBC8548E-product-note.pdf.
It is the connector on the left side of the PCI-EX slot.

We have tried your suggestion but the situation does not change other than
the lane-mode being set to single lane 0, it still locks up when trying to
generate a maintenance transaction. I still think it is memory related since
the lock up occurs when accessing the maintenance window. Although all
memory related settings seems to be alright.

The kernel output is as follows:

Setting up RapidIO peer-to-peer network /soc8548@e0000000/rapidio@c0000
fsl-of-rio e00c0000.rapidio: Of-device full name
/soc8548@e0000000/rapidio@c0000
fsl-of-rio e00c0000.rapidio: Regs: [mem 0xe00c0000-0xe00dffff]
fsl-of-rio e00c0000.rapidio: LAW start 0x00000000c0000000, size
0x0000000010000000.
fsl-of-rio e00c0000.rapidio: pwirq: 48, bellirq: 50, txirq: 53, rxirq 54
fsl-of-rio e00c0000.rapidio: DeviceID is 0x0
fsl-of-rio e00c0000.rapidio: Configured as HOST
fsl-of-rio e00c0000.rapidio: Overriding RIO_PORT setting to single lane 0
fsl-of-rio e00c0000.rapidio: RapidIO PHY type: serial
fsl-of-rio e00c0000.rapidio: Hardware port width: 4
fsl-of-rio e00c0000.rapidio: Training connection status: Single-lane 0
fsl-of-rio e00c0000.rapidio: RapidIO Common Transport System size: 256
fsl-of-rio e00c0000.rapidio: LAW start 0x00000000c0000000, RIO Maintainance
Window Size 0x400000,New Main Start: 0xd1080000
RIO: enumerate master port 0, RIO0 mport
fsl_rio_config_read: index 0 destid 255 hopcount 0 offset 00000068 len 4
fsl_rio_config_read: Passed IS_ALIGNED.
fsl_rio_config_read: Passed 'out_be32_1'
fsl_rio_config_read: Passed 'out_be32_2'
fsl_rio_config_read: len is 4
fsl_rio_config_read: triggering '__fsl_read_rio_config'
fsl_rio_config_read: going to request to read data at d108006

Regards,
Bastiaan
2010/10/4 Bounine, Alexandre <Alexandre.Bounine@idt.com>

> Hi Bastiaan,
>
> Are you trying board-to-board connection?
> I am not familiar with WRS SBC8548 board - which type of connector they
> use for SRIO?
>
> Assuming that all configuration is correct,
> I would recommend first to try setting up x1 link mode at the lowest
> link speed.
> The x4 mode may present challenges in some cases.
>
> For quick test you may just add port width override into fsl_rio.c
> like shown below (ugly but sometimes it helps ;) ):
>
> @@ -1461,10 +1461,16 @@ int fsl_rio_setup(struct platform_device *dev)
>        rio_register_mport(port);
>
>        priv->regs_win = ioremap(regs.start, regs.end - regs.start + 1);
>        rio_regs_win = priv->regs_win;
>
> +dev_info(&dev->dev, "Overriding RIO_PORT setting to single lane 0\n");
> +out_be32(priv->regs_win + 0x15C, in_be32(priv->regs_win + 0x15C) |
> 0x800000);
> +out_be32(priv->regs_win + 0x15C, in_be32(priv->regs_win + 0x15C) |
> 0x2000000);
> +out_be32(priv->regs_win + 0x15C, in_be32(priv->regs_win + 0x15C) &
> ~0x800000);
> +msleep(100);
> +
>        /* Probe the master port phy type */
>        ccsr = in_be32(priv->regs_win + RIO_CCSR);
>        port->phy_type = (ccsr & 1) ? RIO_PHY_SERIAL : RIO_PHY_PARALLEL;
>        dev_info(&dev->dev, "RapidIO PHY type: %s\n",
>                        (port->phy_type == RIO_PHY_PARALLEL) ?
> "parallel" :
>
>
> Let me know what happens.
> Please keep me in the CC: list next time when posting RapidIO questions
> to the linuxppc-dev or kernel mailing lists.
>
> Regards,
>
> Alex.
>
>

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

^ permalink raw reply

* [PATCH] Move ams driver to macintosh
From: Jean Delvare @ 2010-10-05 10:10 UTC (permalink / raw)
  To: LM Sensors, linuxppc-dev; +Cc: Stelian Pop, Michael Hanselmann, Guenter Roeck

The ams driver isn't a hardware monitoring driver, so it shouldn't
live under driver/hwmon. drivers/macintosh seems much more
appropriate, as the driver is only useful on PowerBooks and iBooks.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Guenter Roeck <guenter.roeck@ericsson.com>
Cc: Stelian Pop <stelian@popies.net>
Cc: Michael Hanselmann <linux-kernel@hansmi.ch>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Grant Likely <grant.likely@secretlab.ca>
---
 MAINTAINERS                       |    2 
 drivers/hwmon/Kconfig             |   26 ---
 drivers/hwmon/Makefile            |    1 
 drivers/hwmon/ams/Makefile        |    8 -
 drivers/hwmon/ams/ams-core.c      |  250 ---------------------------------
 drivers/hwmon/ams/ams-i2c.c       |  277 -------------------------------------
 drivers/hwmon/ams/ams-input.c     |  157 --------------------
 drivers/hwmon/ams/ams-pmu.c       |  201 --------------------------
 drivers/hwmon/ams/ams.h           |   70 ---------
 drivers/macintosh/Kconfig         |   26 +++
 drivers/macintosh/Makefile        |    2 
 drivers/macintosh/ams/Makefile    |    8 +
 drivers/macintosh/ams/ams-core.c  |  250 +++++++++++++++++++++++++++++++++
 drivers/macintosh/ams/ams-i2c.c   |  277 +++++++++++++++++++++++++++++++++++++
 drivers/macintosh/ams/ams-input.c |  157 ++++++++++++++++++++
 drivers/macintosh/ams/ams-pmu.c   |  201 ++++++++++++++++++++++++++
 drivers/macintosh/ams/ams.h       |   70 +++++++++
 17 files changed, 992 insertions(+), 991 deletions(-)

--- linux-2.6.36-rc6.orig/drivers/hwmon/ams/Makefile	2010-08-02 00:11:14.000000000 +0200
+++ /dev/null	1970-01-01 00:00:00.000000000 +0000
@@ -1,8 +0,0 @@
-#
-# Makefile for Apple Motion Sensor driver
-#
-
-ams-y					:= ams-core.o ams-input.o
-ams-$(CONFIG_SENSORS_AMS_PMU)		+= ams-pmu.o
-ams-$(CONFIG_SENSORS_AMS_I2C)		+= ams-i2c.o
-obj-$(CONFIG_SENSORS_AMS)		+= ams.o
--- linux-2.6.36-rc6.orig/drivers/hwmon/ams/ams-core.c	2010-08-02 00:11:14.000000000 +0200
+++ /dev/null	1970-01-01 00:00:00.000000000 +0000
@@ -1,250 +0,0 @@
-/*
- * Apple Motion Sensor driver
- *
- * Copyright (C) 2005 Stelian Pop (stelian@popies.net)
- * Copyright (C) 2006 Michael Hanselmann (linux-kernel@hansmi.ch)
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/errno.h>
-#include <linux/init.h>
-#include <linux/of_platform.h>
-#include <asm/pmac_pfunc.h>
-
-#include "ams.h"
-
-/* There is only one motion sensor per machine */
-struct ams ams_info;
-
-static unsigned int verbose;
-module_param(verbose, bool, 0644);
-MODULE_PARM_DESC(verbose, "Show free falls and shocks in kernel output");
-
-/* Call with ams_info.lock held! */
-void ams_sensors(s8 *x, s8 *y, s8 *z)
-{
-	u32 orient = ams_info.vflag? ams_info.orient1 : ams_info.orient2;
-
-	if (orient & 0x80)
-		/* X and Y swapped */
-		ams_info.get_xyz(y, x, z);
-	else
-		ams_info.get_xyz(x, y, z);
-
-	if (orient & 0x04)
-		*z = ~(*z);
-	if (orient & 0x02)
-		*y = ~(*y);
-	if (orient & 0x01)
-		*x = ~(*x);
-}
-
-static ssize_t ams_show_current(struct device *dev,
-	struct device_attribute *attr, char *buf)
-{
-	s8 x, y, z;
-
-	mutex_lock(&ams_info.lock);
-	ams_sensors(&x, &y, &z);
-	mutex_unlock(&ams_info.lock);
-
-	return snprintf(buf, PAGE_SIZE, "%d %d %d\n", x, y, z);
-}
-
-static DEVICE_ATTR(current, S_IRUGO, ams_show_current, NULL);
-
-static void ams_handle_irq(void *data)
-{
-	enum ams_irq irq = *((enum ams_irq *)data);
-
-	spin_lock(&ams_info.irq_lock);
-
-	ams_info.worker_irqs |= irq;
-	schedule_work(&ams_info.worker);
-
-	spin_unlock(&ams_info.irq_lock);
-}
-
-static enum ams_irq ams_freefall_irq_data = AMS_IRQ_FREEFALL;
-static struct pmf_irq_client ams_freefall_client = {
-	.owner = THIS_MODULE,
-	.handler = ams_handle_irq,
-	.data = &ams_freefall_irq_data,
-};
-
-static enum ams_irq ams_shock_irq_data = AMS_IRQ_SHOCK;
-static struct pmf_irq_client ams_shock_client = {
-	.owner = THIS_MODULE,
-	.handler = ams_handle_irq,
-	.data = &ams_shock_irq_data,
-};
-
-/* Once hard disk parking is implemented in the kernel, this function can
- * trigger it.
- */
-static void ams_worker(struct work_struct *work)
-{
-	unsigned long flags;
-	u8 irqs_to_clear;
-
-	mutex_lock(&ams_info.lock);
-
-	spin_lock_irqsave(&ams_info.irq_lock, flags);
-	irqs_to_clear = ams_info.worker_irqs;
-
-	if (ams_info.worker_irqs & AMS_IRQ_FREEFALL) {
-		if (verbose)
-			printk(KERN_INFO "ams: freefall detected!\n");
-
-		ams_info.worker_irqs &= ~AMS_IRQ_FREEFALL;
-	}
-
-	if (ams_info.worker_irqs & AMS_IRQ_SHOCK) {
-		if (verbose)
-			printk(KERN_INFO "ams: shock detected!\n");
-
-		ams_info.worker_irqs &= ~AMS_IRQ_SHOCK;
-	}
-
-	spin_unlock_irqrestore(&ams_info.irq_lock, flags);
-
-	ams_info.clear_irq(irqs_to_clear);
-
-	mutex_unlock(&ams_info.lock);
-}
-
-/* Call with ams_info.lock held! */
-int ams_sensor_attach(void)
-{
-	int result;
-	const u32 *prop;
-
-	/* Get orientation */
-	prop = of_get_property(ams_info.of_node, "orientation", NULL);
-	if (!prop)
-		return -ENODEV;
-	ams_info.orient1 = *prop;
-	ams_info.orient2 = *(prop + 1);
-
-	/* Register freefall interrupt handler */
-	result = pmf_register_irq_client(ams_info.of_node,
-			"accel-int-1",
-			&ams_freefall_client);
-	if (result < 0)
-		return -ENODEV;
-
-	/* Reset saved irqs */
-	ams_info.worker_irqs = 0;
-
-	/* Register shock interrupt handler */
-	result = pmf_register_irq_client(ams_info.of_node,
-			"accel-int-2",
-			&ams_shock_client);
-	if (result < 0)
-		goto release_freefall;
-
-	/* Create device */
-	ams_info.of_dev = of_platform_device_create(ams_info.of_node, "ams", NULL);
-	if (!ams_info.of_dev) {
-		result = -ENODEV;
-		goto release_shock;
-	}
-
-	/* Create attributes */
-	result = device_create_file(&ams_info.of_dev->dev, &dev_attr_current);
-	if (result)
-		goto release_of;
-
-	ams_info.vflag = !!(ams_info.get_vendor() & 0x10);
-
-	/* Init input device */
-	result = ams_input_init();
-	if (result)
-		goto release_device_file;
-
-	return result;
-release_device_file:
-	device_remove_file(&ams_info.of_dev->dev, &dev_attr_current);
-release_of:
-	of_device_unregister(ams_info.of_dev);
-release_shock:
-	pmf_unregister_irq_client(&ams_shock_client);
-release_freefall:
-	pmf_unregister_irq_client(&ams_freefall_client);
-	return result;
-}
-
-int __init ams_init(void)
-{
-	struct device_node *np;
-
-	spin_lock_init(&ams_info.irq_lock);
-	mutex_init(&ams_info.lock);
-	INIT_WORK(&ams_info.worker, ams_worker);
-
-#ifdef CONFIG_SENSORS_AMS_I2C
-	np = of_find_node_by_name(NULL, "accelerometer");
-	if (np && of_device_is_compatible(np, "AAPL,accelerometer_1"))
-		/* Found I2C motion sensor */
-		return ams_i2c_init(np);
-#endif
-
-#ifdef CONFIG_SENSORS_AMS_PMU
-	np = of_find_node_by_name(NULL, "sms");
-	if (np && of_device_is_compatible(np, "sms"))
-		/* Found PMU motion sensor */
-		return ams_pmu_init(np);
-#endif
-	return -ENODEV;
-}
-
-void ams_sensor_detach(void)
-{
-	/* Remove input device */
-	ams_input_exit();
-
-	/* Remove attributes */
-	device_remove_file(&ams_info.of_dev->dev, &dev_attr_current);
-
-	/* Flush interrupt worker
-	 *
-	 * We do this after ams_info.exit(), because an interrupt might
-	 * have arrived before disabling them.
-	 */
-	flush_scheduled_work();
-
-	/* Remove device */
-	of_device_unregister(ams_info.of_dev);
-
-	/* Remove handler */
-	pmf_unregister_irq_client(&ams_shock_client);
-	pmf_unregister_irq_client(&ams_freefall_client);
-}
-
-static void __exit ams_exit(void)
-{
-	/* Shut down implementation */
-	ams_info.exit();
-}
-
-MODULE_AUTHOR("Stelian Pop, Michael Hanselmann");
-MODULE_DESCRIPTION("Apple Motion Sensor driver");
-MODULE_LICENSE("GPL");
-
-module_init(ams_init);
-module_exit(ams_exit);
--- linux-2.6.36-rc6.orig/drivers/hwmon/ams/ams-i2c.c	2010-08-02 00:11:14.000000000 +0200
+++ /dev/null	1970-01-01 00:00:00.000000000 +0000
@@ -1,277 +0,0 @@
-/*
- * Apple Motion Sensor driver (I2C variant)
- *
- * Copyright (C) 2005 Stelian Pop (stelian@popies.net)
- * Copyright (C) 2006 Michael Hanselmann (linux-kernel@hansmi.ch)
- *
- * Clean room implementation based on the reverse engineered Mac OS X driver by
- * Johannes Berg <johannes@sipsolutions.net>, documentation available at
- * http://johannes.sipsolutions.net/PowerBook/Apple_Motion_Sensor_Specification
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/errno.h>
-#include <linux/init.h>
-#include <linux/delay.h>
-
-#include "ams.h"
-
-/* AMS registers */
-#define AMS_COMMAND	0x00	/* command register */
-#define AMS_STATUS	0x01	/* status register */
-#define AMS_CTRL1	0x02	/* read control 1 (number of values) */
-#define AMS_CTRL2	0x03	/* read control 2 (offset?) */
-#define AMS_CTRL3	0x04	/* read control 3 (size of each value?) */
-#define AMS_DATA1	0x05	/* read data 1 */
-#define AMS_DATA2	0x06	/* read data 2 */
-#define AMS_DATA3	0x07	/* read data 3 */
-#define AMS_DATA4	0x08	/* read data 4 */
-#define AMS_DATAX	0x20	/* data X */
-#define AMS_DATAY	0x21	/* data Y */
-#define AMS_DATAZ	0x22	/* data Z */
-#define AMS_FREEFALL	0x24	/* freefall int control */
-#define AMS_SHOCK	0x25	/* shock int control */
-#define AMS_SENSLOW	0x26	/* sensitivity low limit */
-#define AMS_SENSHIGH	0x27	/* sensitivity high limit */
-#define AMS_CTRLX	0x28	/* control X */
-#define AMS_CTRLY	0x29	/* control Y */
-#define AMS_CTRLZ	0x2A	/* control Z */
-#define AMS_UNKNOWN1	0x2B	/* unknown 1 */
-#define AMS_UNKNOWN2	0x2C	/* unknown 2 */
-#define AMS_UNKNOWN3	0x2D	/* unknown 3 */
-#define AMS_VENDOR	0x2E	/* vendor */
-
-/* AMS commands - use with the AMS_COMMAND register */
-enum ams_i2c_cmd {
-	AMS_CMD_NOOP = 0,
-	AMS_CMD_VERSION,
-	AMS_CMD_READMEM,
-	AMS_CMD_WRITEMEM,
-	AMS_CMD_ERASEMEM,
-	AMS_CMD_READEE,
-	AMS_CMD_WRITEEE,
-	AMS_CMD_RESET,
-	AMS_CMD_START,
-};
-
-static int ams_i2c_probe(struct i2c_client *client,
-			 const struct i2c_device_id *id);
-static int ams_i2c_remove(struct i2c_client *client);
-
-static const struct i2c_device_id ams_id[] = {
-	{ "ams", 0 },
-	{ }
-};
-MODULE_DEVICE_TABLE(i2c, ams_id);
-
-static struct i2c_driver ams_i2c_driver = {
-	.driver = {
-		.name   = "ams",
-		.owner  = THIS_MODULE,
-	},
-	.probe          = ams_i2c_probe,
-	.remove         = ams_i2c_remove,
-	.id_table       = ams_id,
-};
-
-static s32 ams_i2c_read(u8 reg)
-{
-	return i2c_smbus_read_byte_data(ams_info.i2c_client, reg);
-}
-
-static int ams_i2c_write(u8 reg, u8 value)
-{
-	return i2c_smbus_write_byte_data(ams_info.i2c_client, reg, value);
-}
-
-static int ams_i2c_cmd(enum ams_i2c_cmd cmd)
-{
-	s32 result;
-	int count = 3;
-
-	ams_i2c_write(AMS_COMMAND, cmd);
-	msleep(5);
-
-	while (count--) {
-		result = ams_i2c_read(AMS_COMMAND);
-		if (result == 0 || result & 0x80)
-			return 0;
-
-		schedule_timeout_uninterruptible(HZ / 20);
-	}
-
-	return -1;
-}
-
-static void ams_i2c_set_irq(enum ams_irq reg, char enable)
-{
-	if (reg & AMS_IRQ_FREEFALL) {
-		u8 val = ams_i2c_read(AMS_CTRLX);
-		if (enable)
-			val |= 0x80;
-		else
-			val &= ~0x80;
-		ams_i2c_write(AMS_CTRLX, val);
-	}
-
-	if (reg & AMS_IRQ_SHOCK) {
-		u8 val = ams_i2c_read(AMS_CTRLY);
-		if (enable)
-			val |= 0x80;
-		else
-			val &= ~0x80;
-		ams_i2c_write(AMS_CTRLY, val);
-	}
-
-	if (reg & AMS_IRQ_GLOBAL) {
-		u8 val = ams_i2c_read(AMS_CTRLZ);
-		if (enable)
-			val |= 0x80;
-		else
-			val &= ~0x80;
-		ams_i2c_write(AMS_CTRLZ, val);
-	}
-}
-
-static void ams_i2c_clear_irq(enum ams_irq reg)
-{
-	if (reg & AMS_IRQ_FREEFALL)
-		ams_i2c_write(AMS_FREEFALL, 0);
-
-	if (reg & AMS_IRQ_SHOCK)
-		ams_i2c_write(AMS_SHOCK, 0);
-}
-
-static u8 ams_i2c_get_vendor(void)
-{
-	return ams_i2c_read(AMS_VENDOR);
-}
-
-static void ams_i2c_get_xyz(s8 *x, s8 *y, s8 *z)
-{
-	*x = ams_i2c_read(AMS_DATAX);
-	*y = ams_i2c_read(AMS_DATAY);
-	*z = ams_i2c_read(AMS_DATAZ);
-}
-
-static int ams_i2c_probe(struct i2c_client *client,
-			 const struct i2c_device_id *id)
-{
-	int vmaj, vmin;
-	int result;
-
-	/* There can be only one */
-	if (unlikely(ams_info.has_device))
-		return -ENODEV;
-
-	ams_info.i2c_client = client;
-
-	if (ams_i2c_cmd(AMS_CMD_RESET)) {
-		printk(KERN_INFO "ams: Failed to reset the device\n");
-		return -ENODEV;
-	}
-
-	if (ams_i2c_cmd(AMS_CMD_START)) {
-		printk(KERN_INFO "ams: Failed to start the device\n");
-		return -ENODEV;
-	}
-
-	/* get version/vendor information */
-	ams_i2c_write(AMS_CTRL1, 0x02);
-	ams_i2c_write(AMS_CTRL2, 0x85);
-	ams_i2c_write(AMS_CTRL3, 0x01);
-
-	ams_i2c_cmd(AMS_CMD_READMEM);
-
-	vmaj = ams_i2c_read(AMS_DATA1);
-	vmin = ams_i2c_read(AMS_DATA2);
-	if (vmaj != 1 || vmin != 52) {
-		printk(KERN_INFO "ams: Incorrect device version (%d.%d)\n",
-			vmaj, vmin);
-		return -ENODEV;
-	}
-
-	ams_i2c_cmd(AMS_CMD_VERSION);
-
-	vmaj = ams_i2c_read(AMS_DATA1);
-	vmin = ams_i2c_read(AMS_DATA2);
-	if (vmaj != 0 || vmin != 1) {
-		printk(KERN_INFO "ams: Incorrect firmware version (%d.%d)\n",
-			vmaj, vmin);
-		return -ENODEV;
-	}
-
-	/* Disable interrupts */
-	ams_i2c_set_irq(AMS_IRQ_ALL, 0);
-
-	result = ams_sensor_attach();
-	if (result < 0)
-		return result;
-
-	/* Set default values */
-	ams_i2c_write(AMS_SENSLOW, 0x15);
-	ams_i2c_write(AMS_SENSHIGH, 0x60);
-	ams_i2c_write(AMS_CTRLX, 0x08);
-	ams_i2c_write(AMS_CTRLY, 0x0F);
-	ams_i2c_write(AMS_CTRLZ, 0x4F);
-	ams_i2c_write(AMS_UNKNOWN1, 0x14);
-
-	/* Clear interrupts */
-	ams_i2c_clear_irq(AMS_IRQ_ALL);
-
-	ams_info.has_device = 1;
-
-	/* Enable interrupts */
-	ams_i2c_set_irq(AMS_IRQ_ALL, 1);
-
-	printk(KERN_INFO "ams: Found I2C based motion sensor\n");
-
-	return 0;
-}
-
-static int ams_i2c_remove(struct i2c_client *client)
-{
-	if (ams_info.has_device) {
-		ams_sensor_detach();
-
-		/* Disable interrupts */
-		ams_i2c_set_irq(AMS_IRQ_ALL, 0);
-
-		/* Clear interrupts */
-		ams_i2c_clear_irq(AMS_IRQ_ALL);
-
-		printk(KERN_INFO "ams: Unloading\n");
-
-		ams_info.has_device = 0;
-	}
-
-	return 0;
-}
-
-static void ams_i2c_exit(void)
-{
-	i2c_del_driver(&ams_i2c_driver);
-}
-
-int __init ams_i2c_init(struct device_node *np)
-{
-	int result;
-
-	/* Set implementation stuff */
-	ams_info.of_node = np;
-	ams_info.exit = ams_i2c_exit;
-	ams_info.get_vendor = ams_i2c_get_vendor;
-	ams_info.get_xyz = ams_i2c_get_xyz;
-	ams_info.clear_irq = ams_i2c_clear_irq;
-	ams_info.bustype = BUS_I2C;
-
-	result = i2c_add_driver(&ams_i2c_driver);
-
-	return result;
-}
--- linux-2.6.36-rc6.orig/drivers/hwmon/ams/ams-input.c	2010-08-02 00:11:14.000000000 +0200
+++ /dev/null	1970-01-01 00:00:00.000000000 +0000
@@ -1,157 +0,0 @@
-/*
- * Apple Motion Sensor driver (joystick emulation)
- *
- * Copyright (C) 2005 Stelian Pop (stelian@popies.net)
- * Copyright (C) 2006 Michael Hanselmann (linux-kernel@hansmi.ch)
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#include <linux/module.h>
-
-#include <linux/types.h>
-#include <linux/errno.h>
-#include <linux/init.h>
-#include <linux/delay.h>
-
-#include "ams.h"
-
-static unsigned int joystick;
-module_param(joystick, bool, S_IRUGO);
-MODULE_PARM_DESC(joystick, "Enable the input class device on module load");
-
-static unsigned int invert;
-module_param(invert, bool, S_IWUSR | S_IRUGO);
-MODULE_PARM_DESC(invert, "Invert input data on X and Y axis");
-
-static DEFINE_MUTEX(ams_input_mutex);
-
-static void ams_idev_poll(struct input_polled_dev *dev)
-{
-	struct input_dev *idev = dev->input;
-	s8 x, y, z;
-
-	mutex_lock(&ams_info.lock);
-
-	ams_sensors(&x, &y, &z);
-
-	x -= ams_info.xcalib;
-	y -= ams_info.ycalib;
-	z -= ams_info.zcalib;
-
-	input_report_abs(idev, ABS_X, invert ? -x : x);
-	input_report_abs(idev, ABS_Y, invert ? -y : y);
-	input_report_abs(idev, ABS_Z, z);
-
-	input_sync(idev);
-
-	mutex_unlock(&ams_info.lock);
-}
-
-/* Call with ams_info.lock held! */
-static int ams_input_enable(void)
-{
-	struct input_dev *input;
-	s8 x, y, z;
-	int error;
-
-	ams_sensors(&x, &y, &z);
-	ams_info.xcalib = x;
-	ams_info.ycalib = y;
-	ams_info.zcalib = z;
-
-	ams_info.idev = input_allocate_polled_device();
-	if (!ams_info.idev)
-		return -ENOMEM;
-
-	ams_info.idev->poll = ams_idev_poll;
-	ams_info.idev->poll_interval = 25;
-
-	input = ams_info.idev->input;
-	input->name = "Apple Motion Sensor";
-	input->id.bustype = ams_info.bustype;
-	input->id.vendor = 0;
-	input->dev.parent = &ams_info.of_dev->dev;
-
-	input_set_abs_params(input, ABS_X, -50, 50, 3, 0);
-	input_set_abs_params(input, ABS_Y, -50, 50, 3, 0);
-	input_set_abs_params(input, ABS_Z, -50, 50, 3, 0);
-
-	set_bit(EV_ABS, input->evbit);
-	set_bit(EV_KEY, input->evbit);
-	set_bit(BTN_TOUCH, input->keybit);
-
-	error = input_register_polled_device(ams_info.idev);
-	if (error) {
-		input_free_polled_device(ams_info.idev);
-		ams_info.idev = NULL;
-		return error;
-	}
-
-	joystick = 1;
-
-	return 0;
-}
-
-static void ams_input_disable(void)
-{
-	if (ams_info.idev) {
-		input_unregister_polled_device(ams_info.idev);
-		input_free_polled_device(ams_info.idev);
-		ams_info.idev = NULL;
-	}
-
-	joystick = 0;
-}
-
-static ssize_t ams_input_show_joystick(struct device *dev,
-	struct device_attribute *attr, char *buf)
-{
-	return sprintf(buf, "%d\n", joystick);
-}
-
-static ssize_t ams_input_store_joystick(struct device *dev,
-	struct device_attribute *attr, const char *buf, size_t count)
-{
-	unsigned long enable;
-	int error = 0;
-
-	if (strict_strtoul(buf, 0, &enable) || enable > 1)
-		return -EINVAL;
-
-	mutex_lock(&ams_input_mutex);
-
-	if (enable != joystick) {
-		if (enable)
-			error = ams_input_enable();
-		else
-			ams_input_disable();
-	}
-
-	mutex_unlock(&ams_input_mutex);
-
-	return error ? error : count;
-}
-
-static DEVICE_ATTR(joystick, S_IRUGO | S_IWUSR,
-	ams_input_show_joystick, ams_input_store_joystick);
-
-int ams_input_init(void)
-{
-	if (joystick)
-		ams_input_enable();
-
-	return device_create_file(&ams_info.of_dev->dev, &dev_attr_joystick);
-}
-
-void ams_input_exit(void)
-{
-	device_remove_file(&ams_info.of_dev->dev, &dev_attr_joystick);
-
-	mutex_lock(&ams_input_mutex);
-	ams_input_disable();
-	mutex_unlock(&ams_input_mutex);
-}
--- linux-2.6.36-rc6.orig/drivers/hwmon/ams/ams-pmu.c	2010-08-02 00:11:14.000000000 +0200
+++ /dev/null	1970-01-01 00:00:00.000000000 +0000
@@ -1,201 +0,0 @@
-/*
- * Apple Motion Sensor driver (PMU variant)
- *
- * Copyright (C) 2006 Michael Hanselmann (linux-kernel@hansmi.ch)
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/errno.h>
-#include <linux/init.h>
-#include <linux/adb.h>
-#include <linux/pmu.h>
-
-#include "ams.h"
-
-/* Attitude */
-#define AMS_X			0x00
-#define AMS_Y			0x01
-#define AMS_Z			0x02
-
-/* Not exactly known, maybe chip vendor */
-#define AMS_VENDOR		0x03
-
-/* Freefall registers */
-#define AMS_FF_CLEAR		0x04
-#define AMS_FF_ENABLE		0x05
-#define AMS_FF_LOW_LIMIT	0x06
-#define AMS_FF_DEBOUNCE		0x07
-
-/* Shock registers */
-#define AMS_SHOCK_CLEAR		0x08
-#define AMS_SHOCK_ENABLE	0x09
-#define AMS_SHOCK_HIGH_LIMIT	0x0a
-#define AMS_SHOCK_DEBOUNCE	0x0b
-
-/* Global interrupt and power control register */
-#define AMS_CONTROL		0x0c
-
-static u8 ams_pmu_cmd;
-
-static void ams_pmu_req_complete(struct adb_request *req)
-{
-	complete((struct completion *)req->arg);
-}
-
-/* Only call this function from task context */
-static void ams_pmu_set_register(u8 reg, u8 value)
-{
-	static struct adb_request req;
-	DECLARE_COMPLETION(req_complete);
-
-	req.arg = &req_complete;
-	if (pmu_request(&req, ams_pmu_req_complete, 4, ams_pmu_cmd, 0x00, reg, value))
-		return;
-
-	wait_for_completion(&req_complete);
-}
-
-/* Only call this function from task context */
-static u8 ams_pmu_get_register(u8 reg)
-{
-	static struct adb_request req;
-	DECLARE_COMPLETION(req_complete);
-
-	req.arg = &req_complete;
-	if (pmu_request(&req, ams_pmu_req_complete, 3, ams_pmu_cmd, 0x01, reg))
-		return 0;
-
-	wait_for_completion(&req_complete);
-
-	if (req.reply_len > 0)
-		return req.reply[0];
-	else
-		return 0;
-}
-
-/* Enables or disables the specified interrupts */
-static void ams_pmu_set_irq(enum ams_irq reg, char enable)
-{
-	if (reg & AMS_IRQ_FREEFALL) {
-		u8 val = ams_pmu_get_register(AMS_FF_ENABLE);
-		if (enable)
-			val |= 0x80;
-		else
-			val &= ~0x80;
-		ams_pmu_set_register(AMS_FF_ENABLE, val);
-	}
-
-	if (reg & AMS_IRQ_SHOCK) {
-		u8 val = ams_pmu_get_register(AMS_SHOCK_ENABLE);
-		if (enable)
-			val |= 0x80;
-		else
-			val &= ~0x80;
-		ams_pmu_set_register(AMS_SHOCK_ENABLE, val);
-	}
-
-	if (reg & AMS_IRQ_GLOBAL) {
-		u8 val = ams_pmu_get_register(AMS_CONTROL);
-		if (enable)
-			val |= 0x80;
-		else
-			val &= ~0x80;
-		ams_pmu_set_register(AMS_CONTROL, val);
-	}
-}
-
-static void ams_pmu_clear_irq(enum ams_irq reg)
-{
-	if (reg & AMS_IRQ_FREEFALL)
-		ams_pmu_set_register(AMS_FF_CLEAR, 0x00);
-
-	if (reg & AMS_IRQ_SHOCK)
-		ams_pmu_set_register(AMS_SHOCK_CLEAR, 0x00);
-}
-
-static u8 ams_pmu_get_vendor(void)
-{
-	return ams_pmu_get_register(AMS_VENDOR);
-}
-
-static void ams_pmu_get_xyz(s8 *x, s8 *y, s8 *z)
-{
-	*x = ams_pmu_get_register(AMS_X);
-	*y = ams_pmu_get_register(AMS_Y);
-	*z = ams_pmu_get_register(AMS_Z);
-}
-
-static void ams_pmu_exit(void)
-{
-	ams_sensor_detach();
-
-	/* Disable interrupts */
-	ams_pmu_set_irq(AMS_IRQ_ALL, 0);
-
-	/* Clear interrupts */
-	ams_pmu_clear_irq(AMS_IRQ_ALL);
-
-	ams_info.has_device = 0;
-
-	printk(KERN_INFO "ams: Unloading\n");
-}
-
-int __init ams_pmu_init(struct device_node *np)
-{
-	const u32 *prop;
-	int result;
-
-	/* Set implementation stuff */
-	ams_info.of_node = np;
-	ams_info.exit = ams_pmu_exit;
-	ams_info.get_vendor = ams_pmu_get_vendor;
-	ams_info.get_xyz = ams_pmu_get_xyz;
-	ams_info.clear_irq = ams_pmu_clear_irq;
-	ams_info.bustype = BUS_HOST;
-
-	/* Get PMU command, should be 0x4e, but we can never know */
-	prop = of_get_property(ams_info.of_node, "reg", NULL);
-	if (!prop)
-		return -ENODEV;
-
-	ams_pmu_cmd = ((*prop) >> 8) & 0xff;
-
-	/* Disable interrupts */
-	ams_pmu_set_irq(AMS_IRQ_ALL, 0);
-
-	/* Clear interrupts */
-	ams_pmu_clear_irq(AMS_IRQ_ALL);
-
-	result = ams_sensor_attach();
-	if (result < 0)
-		return result;
-
-	/* Set default values */
-	ams_pmu_set_register(AMS_FF_LOW_LIMIT, 0x15);
-	ams_pmu_set_register(AMS_FF_ENABLE, 0x08);
-	ams_pmu_set_register(AMS_FF_DEBOUNCE, 0x14);
-
-	ams_pmu_set_register(AMS_SHOCK_HIGH_LIMIT, 0x60);
-	ams_pmu_set_register(AMS_SHOCK_ENABLE, 0x0f);
-	ams_pmu_set_register(AMS_SHOCK_DEBOUNCE, 0x14);
-
-	ams_pmu_set_register(AMS_CONTROL, 0x4f);
-
-	/* Clear interrupts */
-	ams_pmu_clear_irq(AMS_IRQ_ALL);
-
-	ams_info.has_device = 1;
-
-	/* Enable interrupts */
-	ams_pmu_set_irq(AMS_IRQ_ALL, 1);
-
-	printk(KERN_INFO "ams: Found PMU based motion sensor\n");
-
-	return 0;
-}
--- linux-2.6.36-rc6.orig/drivers/hwmon/ams/ams.h	2010-09-21 11:07:14.000000000 +0200
+++ /dev/null	1970-01-01 00:00:00.000000000 +0000
@@ -1,70 +0,0 @@
-#include <linux/i2c.h>
-#include <linux/input-polldev.h>
-#include <linux/kthread.h>
-#include <linux/mutex.h>
-#include <linux/spinlock.h>
-#include <linux/types.h>
-#include <linux/of_device.h>
-
-enum ams_irq {
-	AMS_IRQ_FREEFALL = 0x01,
-	AMS_IRQ_SHOCK = 0x02,
-	AMS_IRQ_GLOBAL = 0x04,
-	AMS_IRQ_ALL =
-		AMS_IRQ_FREEFALL |
-		AMS_IRQ_SHOCK |
-		AMS_IRQ_GLOBAL,
-};
-
-struct ams {
-	/* Locks */
-	spinlock_t irq_lock;
-	struct mutex lock;
-
-	/* General properties */
-	struct device_node *of_node;
-	struct platform_device *of_dev;
-	char has_device;
-	char vflag;
-	u32 orient1;
-	u32 orient2;
-
-	/* Interrupt worker */
-	struct work_struct worker;
-	u8 worker_irqs;
-
-	/* Implementation
-	 *
-	 * Only call these functions with the main lock held.
-	 */
-	void (*exit)(void);
-
-	void (*get_xyz)(s8 *x, s8 *y, s8 *z);
-	u8 (*get_vendor)(void);
-
-	void (*clear_irq)(enum ams_irq reg);
-
-#ifdef CONFIG_SENSORS_AMS_I2C
-	/* I2C properties */
-	struct i2c_client *i2c_client;
-#endif
-
-	/* Joystick emulation */
-	struct input_polled_dev *idev;
-	__u16 bustype;
-
-	/* calibrated null values */
-	int xcalib, ycalib, zcalib;
-};
-
-extern struct ams ams_info;
-
-extern void ams_sensors(s8 *x, s8 *y, s8 *z);
-extern int ams_sensor_attach(void);
-extern void ams_sensor_detach(void);
-
-extern int ams_pmu_init(struct device_node *np);
-extern int ams_i2c_init(struct device_node *np);
-
-extern int ams_input_init(void);
-extern void ams_input_exit(void);
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6.36-rc6/drivers/macintosh/ams/Makefile	2010-08-02 00:11:14.000000000 +0200
@@ -0,0 +1,8 @@
+#
+# Makefile for Apple Motion Sensor driver
+#
+
+ams-y					:= ams-core.o ams-input.o
+ams-$(CONFIG_SENSORS_AMS_PMU)		+= ams-pmu.o
+ams-$(CONFIG_SENSORS_AMS_I2C)		+= ams-i2c.o
+obj-$(CONFIG_SENSORS_AMS)		+= ams.o
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6.36-rc6/drivers/macintosh/ams/ams-core.c	2010-08-02 00:11:14.000000000 +0200
@@ -0,0 +1,250 @@
+/*
+ * Apple Motion Sensor driver
+ *
+ * Copyright (C) 2005 Stelian Pop (stelian@popies.net)
+ * Copyright (C) 2006 Michael Hanselmann (linux-kernel@hansmi.ch)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/of_platform.h>
+#include <asm/pmac_pfunc.h>
+
+#include "ams.h"
+
+/* There is only one motion sensor per machine */
+struct ams ams_info;
+
+static unsigned int verbose;
+module_param(verbose, bool, 0644);
+MODULE_PARM_DESC(verbose, "Show free falls and shocks in kernel output");
+
+/* Call with ams_info.lock held! */
+void ams_sensors(s8 *x, s8 *y, s8 *z)
+{
+	u32 orient = ams_info.vflag? ams_info.orient1 : ams_info.orient2;
+
+	if (orient & 0x80)
+		/* X and Y swapped */
+		ams_info.get_xyz(y, x, z);
+	else
+		ams_info.get_xyz(x, y, z);
+
+	if (orient & 0x04)
+		*z = ~(*z);
+	if (orient & 0x02)
+		*y = ~(*y);
+	if (orient & 0x01)
+		*x = ~(*x);
+}
+
+static ssize_t ams_show_current(struct device *dev,
+	struct device_attribute *attr, char *buf)
+{
+	s8 x, y, z;
+
+	mutex_lock(&ams_info.lock);
+	ams_sensors(&x, &y, &z);
+	mutex_unlock(&ams_info.lock);
+
+	return snprintf(buf, PAGE_SIZE, "%d %d %d\n", x, y, z);
+}
+
+static DEVICE_ATTR(current, S_IRUGO, ams_show_current, NULL);
+
+static void ams_handle_irq(void *data)
+{
+	enum ams_irq irq = *((enum ams_irq *)data);
+
+	spin_lock(&ams_info.irq_lock);
+
+	ams_info.worker_irqs |= irq;
+	schedule_work(&ams_info.worker);
+
+	spin_unlock(&ams_info.irq_lock);
+}
+
+static enum ams_irq ams_freefall_irq_data = AMS_IRQ_FREEFALL;
+static struct pmf_irq_client ams_freefall_client = {
+	.owner = THIS_MODULE,
+	.handler = ams_handle_irq,
+	.data = &ams_freefall_irq_data,
+};
+
+static enum ams_irq ams_shock_irq_data = AMS_IRQ_SHOCK;
+static struct pmf_irq_client ams_shock_client = {
+	.owner = THIS_MODULE,
+	.handler = ams_handle_irq,
+	.data = &ams_shock_irq_data,
+};
+
+/* Once hard disk parking is implemented in the kernel, this function can
+ * trigger it.
+ */
+static void ams_worker(struct work_struct *work)
+{
+	unsigned long flags;
+	u8 irqs_to_clear;
+
+	mutex_lock(&ams_info.lock);
+
+	spin_lock_irqsave(&ams_info.irq_lock, flags);
+	irqs_to_clear = ams_info.worker_irqs;
+
+	if (ams_info.worker_irqs & AMS_IRQ_FREEFALL) {
+		if (verbose)
+			printk(KERN_INFO "ams: freefall detected!\n");
+
+		ams_info.worker_irqs &= ~AMS_IRQ_FREEFALL;
+	}
+
+	if (ams_info.worker_irqs & AMS_IRQ_SHOCK) {
+		if (verbose)
+			printk(KERN_INFO "ams: shock detected!\n");
+
+		ams_info.worker_irqs &= ~AMS_IRQ_SHOCK;
+	}
+
+	spin_unlock_irqrestore(&ams_info.irq_lock, flags);
+
+	ams_info.clear_irq(irqs_to_clear);
+
+	mutex_unlock(&ams_info.lock);
+}
+
+/* Call with ams_info.lock held! */
+int ams_sensor_attach(void)
+{
+	int result;
+	const u32 *prop;
+
+	/* Get orientation */
+	prop = of_get_property(ams_info.of_node, "orientation", NULL);
+	if (!prop)
+		return -ENODEV;
+	ams_info.orient1 = *prop;
+	ams_info.orient2 = *(prop + 1);
+
+	/* Register freefall interrupt handler */
+	result = pmf_register_irq_client(ams_info.of_node,
+			"accel-int-1",
+			&ams_freefall_client);
+	if (result < 0)
+		return -ENODEV;
+
+	/* Reset saved irqs */
+	ams_info.worker_irqs = 0;
+
+	/* Register shock interrupt handler */
+	result = pmf_register_irq_client(ams_info.of_node,
+			"accel-int-2",
+			&ams_shock_client);
+	if (result < 0)
+		goto release_freefall;
+
+	/* Create device */
+	ams_info.of_dev = of_platform_device_create(ams_info.of_node, "ams", NULL);
+	if (!ams_info.of_dev) {
+		result = -ENODEV;
+		goto release_shock;
+	}
+
+	/* Create attributes */
+	result = device_create_file(&ams_info.of_dev->dev, &dev_attr_current);
+	if (result)
+		goto release_of;
+
+	ams_info.vflag = !!(ams_info.get_vendor() & 0x10);
+
+	/* Init input device */
+	result = ams_input_init();
+	if (result)
+		goto release_device_file;
+
+	return result;
+release_device_file:
+	device_remove_file(&ams_info.of_dev->dev, &dev_attr_current);
+release_of:
+	of_device_unregister(ams_info.of_dev);
+release_shock:
+	pmf_unregister_irq_client(&ams_shock_client);
+release_freefall:
+	pmf_unregister_irq_client(&ams_freefall_client);
+	return result;
+}
+
+int __init ams_init(void)
+{
+	struct device_node *np;
+
+	spin_lock_init(&ams_info.irq_lock);
+	mutex_init(&ams_info.lock);
+	INIT_WORK(&ams_info.worker, ams_worker);
+
+#ifdef CONFIG_SENSORS_AMS_I2C
+	np = of_find_node_by_name(NULL, "accelerometer");
+	if (np && of_device_is_compatible(np, "AAPL,accelerometer_1"))
+		/* Found I2C motion sensor */
+		return ams_i2c_init(np);
+#endif
+
+#ifdef CONFIG_SENSORS_AMS_PMU
+	np = of_find_node_by_name(NULL, "sms");
+	if (np && of_device_is_compatible(np, "sms"))
+		/* Found PMU motion sensor */
+		return ams_pmu_init(np);
+#endif
+	return -ENODEV;
+}
+
+void ams_sensor_detach(void)
+{
+	/* Remove input device */
+	ams_input_exit();
+
+	/* Remove attributes */
+	device_remove_file(&ams_info.of_dev->dev, &dev_attr_current);
+
+	/* Flush interrupt worker
+	 *
+	 * We do this after ams_info.exit(), because an interrupt might
+	 * have arrived before disabling them.
+	 */
+	flush_scheduled_work();
+
+	/* Remove device */
+	of_device_unregister(ams_info.of_dev);
+
+	/* Remove handler */
+	pmf_unregister_irq_client(&ams_shock_client);
+	pmf_unregister_irq_client(&ams_freefall_client);
+}
+
+static void __exit ams_exit(void)
+{
+	/* Shut down implementation */
+	ams_info.exit();
+}
+
+MODULE_AUTHOR("Stelian Pop, Michael Hanselmann");
+MODULE_DESCRIPTION("Apple Motion Sensor driver");
+MODULE_LICENSE("GPL");
+
+module_init(ams_init);
+module_exit(ams_exit);
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6.36-rc6/drivers/macintosh/ams/ams-i2c.c	2010-08-02 00:11:14.000000000 +0200
@@ -0,0 +1,277 @@
+/*
+ * Apple Motion Sensor driver (I2C variant)
+ *
+ * Copyright (C) 2005 Stelian Pop (stelian@popies.net)
+ * Copyright (C) 2006 Michael Hanselmann (linux-kernel@hansmi.ch)
+ *
+ * Clean room implementation based on the reverse engineered Mac OS X driver by
+ * Johannes Berg <johannes@sipsolutions.net>, documentation available at
+ * http://johannes.sipsolutions.net/PowerBook/Apple_Motion_Sensor_Specification
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+
+#include "ams.h"
+
+/* AMS registers */
+#define AMS_COMMAND	0x00	/* command register */
+#define AMS_STATUS	0x01	/* status register */
+#define AMS_CTRL1	0x02	/* read control 1 (number of values) */
+#define AMS_CTRL2	0x03	/* read control 2 (offset?) */
+#define AMS_CTRL3	0x04	/* read control 3 (size of each value?) */
+#define AMS_DATA1	0x05	/* read data 1 */
+#define AMS_DATA2	0x06	/* read data 2 */
+#define AMS_DATA3	0x07	/* read data 3 */
+#define AMS_DATA4	0x08	/* read data 4 */
+#define AMS_DATAX	0x20	/* data X */
+#define AMS_DATAY	0x21	/* data Y */
+#define AMS_DATAZ	0x22	/* data Z */
+#define AMS_FREEFALL	0x24	/* freefall int control */
+#define AMS_SHOCK	0x25	/* shock int control */
+#define AMS_SENSLOW	0x26	/* sensitivity low limit */
+#define AMS_SENSHIGH	0x27	/* sensitivity high limit */
+#define AMS_CTRLX	0x28	/* control X */
+#define AMS_CTRLY	0x29	/* control Y */
+#define AMS_CTRLZ	0x2A	/* control Z */
+#define AMS_UNKNOWN1	0x2B	/* unknown 1 */
+#define AMS_UNKNOWN2	0x2C	/* unknown 2 */
+#define AMS_UNKNOWN3	0x2D	/* unknown 3 */
+#define AMS_VENDOR	0x2E	/* vendor */
+
+/* AMS commands - use with the AMS_COMMAND register */
+enum ams_i2c_cmd {
+	AMS_CMD_NOOP = 0,
+	AMS_CMD_VERSION,
+	AMS_CMD_READMEM,
+	AMS_CMD_WRITEMEM,
+	AMS_CMD_ERASEMEM,
+	AMS_CMD_READEE,
+	AMS_CMD_WRITEEE,
+	AMS_CMD_RESET,
+	AMS_CMD_START,
+};
+
+static int ams_i2c_probe(struct i2c_client *client,
+			 const struct i2c_device_id *id);
+static int ams_i2c_remove(struct i2c_client *client);
+
+static const struct i2c_device_id ams_id[] = {
+	{ "ams", 0 },
+	{ }
+};
+MODULE_DEVICE_TABLE(i2c, ams_id);
+
+static struct i2c_driver ams_i2c_driver = {
+	.driver = {
+		.name   = "ams",
+		.owner  = THIS_MODULE,
+	},
+	.probe          = ams_i2c_probe,
+	.remove         = ams_i2c_remove,
+	.id_table       = ams_id,
+};
+
+static s32 ams_i2c_read(u8 reg)
+{
+	return i2c_smbus_read_byte_data(ams_info.i2c_client, reg);
+}
+
+static int ams_i2c_write(u8 reg, u8 value)
+{
+	return i2c_smbus_write_byte_data(ams_info.i2c_client, reg, value);
+}
+
+static int ams_i2c_cmd(enum ams_i2c_cmd cmd)
+{
+	s32 result;
+	int count = 3;
+
+	ams_i2c_write(AMS_COMMAND, cmd);
+	msleep(5);
+
+	while (count--) {
+		result = ams_i2c_read(AMS_COMMAND);
+		if (result == 0 || result & 0x80)
+			return 0;
+
+		schedule_timeout_uninterruptible(HZ / 20);
+	}
+
+	return -1;
+}
+
+static void ams_i2c_set_irq(enum ams_irq reg, char enable)
+{
+	if (reg & AMS_IRQ_FREEFALL) {
+		u8 val = ams_i2c_read(AMS_CTRLX);
+		if (enable)
+			val |= 0x80;
+		else
+			val &= ~0x80;
+		ams_i2c_write(AMS_CTRLX, val);
+	}
+
+	if (reg & AMS_IRQ_SHOCK) {
+		u8 val = ams_i2c_read(AMS_CTRLY);
+		if (enable)
+			val |= 0x80;
+		else
+			val &= ~0x80;
+		ams_i2c_write(AMS_CTRLY, val);
+	}
+
+	if (reg & AMS_IRQ_GLOBAL) {
+		u8 val = ams_i2c_read(AMS_CTRLZ);
+		if (enable)
+			val |= 0x80;
+		else
+			val &= ~0x80;
+		ams_i2c_write(AMS_CTRLZ, val);
+	}
+}
+
+static void ams_i2c_clear_irq(enum ams_irq reg)
+{
+	if (reg & AMS_IRQ_FREEFALL)
+		ams_i2c_write(AMS_FREEFALL, 0);
+
+	if (reg & AMS_IRQ_SHOCK)
+		ams_i2c_write(AMS_SHOCK, 0);
+}
+
+static u8 ams_i2c_get_vendor(void)
+{
+	return ams_i2c_read(AMS_VENDOR);
+}
+
+static void ams_i2c_get_xyz(s8 *x, s8 *y, s8 *z)
+{
+	*x = ams_i2c_read(AMS_DATAX);
+	*y = ams_i2c_read(AMS_DATAY);
+	*z = ams_i2c_read(AMS_DATAZ);
+}
+
+static int ams_i2c_probe(struct i2c_client *client,
+			 const struct i2c_device_id *id)
+{
+	int vmaj, vmin;
+	int result;
+
+	/* There can be only one */
+	if (unlikely(ams_info.has_device))
+		return -ENODEV;
+
+	ams_info.i2c_client = client;
+
+	if (ams_i2c_cmd(AMS_CMD_RESET)) {
+		printk(KERN_INFO "ams: Failed to reset the device\n");
+		return -ENODEV;
+	}
+
+	if (ams_i2c_cmd(AMS_CMD_START)) {
+		printk(KERN_INFO "ams: Failed to start the device\n");
+		return -ENODEV;
+	}
+
+	/* get version/vendor information */
+	ams_i2c_write(AMS_CTRL1, 0x02);
+	ams_i2c_write(AMS_CTRL2, 0x85);
+	ams_i2c_write(AMS_CTRL3, 0x01);
+
+	ams_i2c_cmd(AMS_CMD_READMEM);
+
+	vmaj = ams_i2c_read(AMS_DATA1);
+	vmin = ams_i2c_read(AMS_DATA2);
+	if (vmaj != 1 || vmin != 52) {
+		printk(KERN_INFO "ams: Incorrect device version (%d.%d)\n",
+			vmaj, vmin);
+		return -ENODEV;
+	}
+
+	ams_i2c_cmd(AMS_CMD_VERSION);
+
+	vmaj = ams_i2c_read(AMS_DATA1);
+	vmin = ams_i2c_read(AMS_DATA2);
+	if (vmaj != 0 || vmin != 1) {
+		printk(KERN_INFO "ams: Incorrect firmware version (%d.%d)\n",
+			vmaj, vmin);
+		return -ENODEV;
+	}
+
+	/* Disable interrupts */
+	ams_i2c_set_irq(AMS_IRQ_ALL, 0);
+
+	result = ams_sensor_attach();
+	if (result < 0)
+		return result;
+
+	/* Set default values */
+	ams_i2c_write(AMS_SENSLOW, 0x15);
+	ams_i2c_write(AMS_SENSHIGH, 0x60);
+	ams_i2c_write(AMS_CTRLX, 0x08);
+	ams_i2c_write(AMS_CTRLY, 0x0F);
+	ams_i2c_write(AMS_CTRLZ, 0x4F);
+	ams_i2c_write(AMS_UNKNOWN1, 0x14);
+
+	/* Clear interrupts */
+	ams_i2c_clear_irq(AMS_IRQ_ALL);
+
+	ams_info.has_device = 1;
+
+	/* Enable interrupts */
+	ams_i2c_set_irq(AMS_IRQ_ALL, 1);
+
+	printk(KERN_INFO "ams: Found I2C based motion sensor\n");
+
+	return 0;
+}
+
+static int ams_i2c_remove(struct i2c_client *client)
+{
+	if (ams_info.has_device) {
+		ams_sensor_detach();
+
+		/* Disable interrupts */
+		ams_i2c_set_irq(AMS_IRQ_ALL, 0);
+
+		/* Clear interrupts */
+		ams_i2c_clear_irq(AMS_IRQ_ALL);
+
+		printk(KERN_INFO "ams: Unloading\n");
+
+		ams_info.has_device = 0;
+	}
+
+	return 0;
+}
+
+static void ams_i2c_exit(void)
+{
+	i2c_del_driver(&ams_i2c_driver);
+}
+
+int __init ams_i2c_init(struct device_node *np)
+{
+	int result;
+
+	/* Set implementation stuff */
+	ams_info.of_node = np;
+	ams_info.exit = ams_i2c_exit;
+	ams_info.get_vendor = ams_i2c_get_vendor;
+	ams_info.get_xyz = ams_i2c_get_xyz;
+	ams_info.clear_irq = ams_i2c_clear_irq;
+	ams_info.bustype = BUS_I2C;
+
+	result = i2c_add_driver(&ams_i2c_driver);
+
+	return result;
+}
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6.36-rc6/drivers/macintosh/ams/ams-input.c	2010-08-02 00:11:14.000000000 +0200
@@ -0,0 +1,157 @@
+/*
+ * Apple Motion Sensor driver (joystick emulation)
+ *
+ * Copyright (C) 2005 Stelian Pop (stelian@popies.net)
+ * Copyright (C) 2006 Michael Hanselmann (linux-kernel@hansmi.ch)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include <linux/module.h>
+
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+
+#include "ams.h"
+
+static unsigned int joystick;
+module_param(joystick, bool, S_IRUGO);
+MODULE_PARM_DESC(joystick, "Enable the input class device on module load");
+
+static unsigned int invert;
+module_param(invert, bool, S_IWUSR | S_IRUGO);
+MODULE_PARM_DESC(invert, "Invert input data on X and Y axis");
+
+static DEFINE_MUTEX(ams_input_mutex);
+
+static void ams_idev_poll(struct input_polled_dev *dev)
+{
+	struct input_dev *idev = dev->input;
+	s8 x, y, z;
+
+	mutex_lock(&ams_info.lock);
+
+	ams_sensors(&x, &y, &z);
+
+	x -= ams_info.xcalib;
+	y -= ams_info.ycalib;
+	z -= ams_info.zcalib;
+
+	input_report_abs(idev, ABS_X, invert ? -x : x);
+	input_report_abs(idev, ABS_Y, invert ? -y : y);
+	input_report_abs(idev, ABS_Z, z);
+
+	input_sync(idev);
+
+	mutex_unlock(&ams_info.lock);
+}
+
+/* Call with ams_info.lock held! */
+static int ams_input_enable(void)
+{
+	struct input_dev *input;
+	s8 x, y, z;
+	int error;
+
+	ams_sensors(&x, &y, &z);
+	ams_info.xcalib = x;
+	ams_info.ycalib = y;
+	ams_info.zcalib = z;
+
+	ams_info.idev = input_allocate_polled_device();
+	if (!ams_info.idev)
+		return -ENOMEM;
+
+	ams_info.idev->poll = ams_idev_poll;
+	ams_info.idev->poll_interval = 25;
+
+	input = ams_info.idev->input;
+	input->name = "Apple Motion Sensor";
+	input->id.bustype = ams_info.bustype;
+	input->id.vendor = 0;
+	input->dev.parent = &ams_info.of_dev->dev;
+
+	input_set_abs_params(input, ABS_X, -50, 50, 3, 0);
+	input_set_abs_params(input, ABS_Y, -50, 50, 3, 0);
+	input_set_abs_params(input, ABS_Z, -50, 50, 3, 0);
+
+	set_bit(EV_ABS, input->evbit);
+	set_bit(EV_KEY, input->evbit);
+	set_bit(BTN_TOUCH, input->keybit);
+
+	error = input_register_polled_device(ams_info.idev);
+	if (error) {
+		input_free_polled_device(ams_info.idev);
+		ams_info.idev = NULL;
+		return error;
+	}
+
+	joystick = 1;
+
+	return 0;
+}
+
+static void ams_input_disable(void)
+{
+	if (ams_info.idev) {
+		input_unregister_polled_device(ams_info.idev);
+		input_free_polled_device(ams_info.idev);
+		ams_info.idev = NULL;
+	}
+
+	joystick = 0;
+}
+
+static ssize_t ams_input_show_joystick(struct device *dev,
+	struct device_attribute *attr, char *buf)
+{
+	return sprintf(buf, "%d\n", joystick);
+}
+
+static ssize_t ams_input_store_joystick(struct device *dev,
+	struct device_attribute *attr, const char *buf, size_t count)
+{
+	unsigned long enable;
+	int error = 0;
+
+	if (strict_strtoul(buf, 0, &enable) || enable > 1)
+		return -EINVAL;
+
+	mutex_lock(&ams_input_mutex);
+
+	if (enable != joystick) {
+		if (enable)
+			error = ams_input_enable();
+		else
+			ams_input_disable();
+	}
+
+	mutex_unlock(&ams_input_mutex);
+
+	return error ? error : count;
+}
+
+static DEVICE_ATTR(joystick, S_IRUGO | S_IWUSR,
+	ams_input_show_joystick, ams_input_store_joystick);
+
+int ams_input_init(void)
+{
+	if (joystick)
+		ams_input_enable();
+
+	return device_create_file(&ams_info.of_dev->dev, &dev_attr_joystick);
+}
+
+void ams_input_exit(void)
+{
+	device_remove_file(&ams_info.of_dev->dev, &dev_attr_joystick);
+
+	mutex_lock(&ams_input_mutex);
+	ams_input_disable();
+	mutex_unlock(&ams_input_mutex);
+}
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6.36-rc6/drivers/macintosh/ams/ams-pmu.c	2010-08-02 00:11:14.000000000 +0200
@@ -0,0 +1,201 @@
+/*
+ * Apple Motion Sensor driver (PMU variant)
+ *
+ * Copyright (C) 2006 Michael Hanselmann (linux-kernel@hansmi.ch)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/adb.h>
+#include <linux/pmu.h>
+
+#include "ams.h"
+
+/* Attitude */
+#define AMS_X			0x00
+#define AMS_Y			0x01
+#define AMS_Z			0x02
+
+/* Not exactly known, maybe chip vendor */
+#define AMS_VENDOR		0x03
+
+/* Freefall registers */
+#define AMS_FF_CLEAR		0x04
+#define AMS_FF_ENABLE		0x05
+#define AMS_FF_LOW_LIMIT	0x06
+#define AMS_FF_DEBOUNCE		0x07
+
+/* Shock registers */
+#define AMS_SHOCK_CLEAR		0x08
+#define AMS_SHOCK_ENABLE	0x09
+#define AMS_SHOCK_HIGH_LIMIT	0x0a
+#define AMS_SHOCK_DEBOUNCE	0x0b
+
+/* Global interrupt and power control register */
+#define AMS_CONTROL		0x0c
+
+static u8 ams_pmu_cmd;
+
+static void ams_pmu_req_complete(struct adb_request *req)
+{
+	complete((struct completion *)req->arg);
+}
+
+/* Only call this function from task context */
+static void ams_pmu_set_register(u8 reg, u8 value)
+{
+	static struct adb_request req;
+	DECLARE_COMPLETION(req_complete);
+
+	req.arg = &req_complete;
+	if (pmu_request(&req, ams_pmu_req_complete, 4, ams_pmu_cmd, 0x00, reg, value))
+		return;
+
+	wait_for_completion(&req_complete);
+}
+
+/* Only call this function from task context */
+static u8 ams_pmu_get_register(u8 reg)
+{
+	static struct adb_request req;
+	DECLARE_COMPLETION(req_complete);
+
+	req.arg = &req_complete;
+	if (pmu_request(&req, ams_pmu_req_complete, 3, ams_pmu_cmd, 0x01, reg))
+		return 0;
+
+	wait_for_completion(&req_complete);
+
+	if (req.reply_len > 0)
+		return req.reply[0];
+	else
+		return 0;
+}
+
+/* Enables or disables the specified interrupts */
+static void ams_pmu_set_irq(enum ams_irq reg, char enable)
+{
+	if (reg & AMS_IRQ_FREEFALL) {
+		u8 val = ams_pmu_get_register(AMS_FF_ENABLE);
+		if (enable)
+			val |= 0x80;
+		else
+			val &= ~0x80;
+		ams_pmu_set_register(AMS_FF_ENABLE, val);
+	}
+
+	if (reg & AMS_IRQ_SHOCK) {
+		u8 val = ams_pmu_get_register(AMS_SHOCK_ENABLE);
+		if (enable)
+			val |= 0x80;
+		else
+			val &= ~0x80;
+		ams_pmu_set_register(AMS_SHOCK_ENABLE, val);
+	}
+
+	if (reg & AMS_IRQ_GLOBAL) {
+		u8 val = ams_pmu_get_register(AMS_CONTROL);
+		if (enable)
+			val |= 0x80;
+		else
+			val &= ~0x80;
+		ams_pmu_set_register(AMS_CONTROL, val);
+	}
+}
+
+static void ams_pmu_clear_irq(enum ams_irq reg)
+{
+	if (reg & AMS_IRQ_FREEFALL)
+		ams_pmu_set_register(AMS_FF_CLEAR, 0x00);
+
+	if (reg & AMS_IRQ_SHOCK)
+		ams_pmu_set_register(AMS_SHOCK_CLEAR, 0x00);
+}
+
+static u8 ams_pmu_get_vendor(void)
+{
+	return ams_pmu_get_register(AMS_VENDOR);
+}
+
+static void ams_pmu_get_xyz(s8 *x, s8 *y, s8 *z)
+{
+	*x = ams_pmu_get_register(AMS_X);
+	*y = ams_pmu_get_register(AMS_Y);
+	*z = ams_pmu_get_register(AMS_Z);
+}
+
+static void ams_pmu_exit(void)
+{
+	ams_sensor_detach();
+
+	/* Disable interrupts */
+	ams_pmu_set_irq(AMS_IRQ_ALL, 0);
+
+	/* Clear interrupts */
+	ams_pmu_clear_irq(AMS_IRQ_ALL);
+
+	ams_info.has_device = 0;
+
+	printk(KERN_INFO "ams: Unloading\n");
+}
+
+int __init ams_pmu_init(struct device_node *np)
+{
+	const u32 *prop;
+	int result;
+
+	/* Set implementation stuff */
+	ams_info.of_node = np;
+	ams_info.exit = ams_pmu_exit;
+	ams_info.get_vendor = ams_pmu_get_vendor;
+	ams_info.get_xyz = ams_pmu_get_xyz;
+	ams_info.clear_irq = ams_pmu_clear_irq;
+	ams_info.bustype = BUS_HOST;
+
+	/* Get PMU command, should be 0x4e, but we can never know */
+	prop = of_get_property(ams_info.of_node, "reg", NULL);
+	if (!prop)
+		return -ENODEV;
+
+	ams_pmu_cmd = ((*prop) >> 8) & 0xff;
+
+	/* Disable interrupts */
+	ams_pmu_set_irq(AMS_IRQ_ALL, 0);
+
+	/* Clear interrupts */
+	ams_pmu_clear_irq(AMS_IRQ_ALL);
+
+	result = ams_sensor_attach();
+	if (result < 0)
+		return result;
+
+	/* Set default values */
+	ams_pmu_set_register(AMS_FF_LOW_LIMIT, 0x15);
+	ams_pmu_set_register(AMS_FF_ENABLE, 0x08);
+	ams_pmu_set_register(AMS_FF_DEBOUNCE, 0x14);
+
+	ams_pmu_set_register(AMS_SHOCK_HIGH_LIMIT, 0x60);
+	ams_pmu_set_register(AMS_SHOCK_ENABLE, 0x0f);
+	ams_pmu_set_register(AMS_SHOCK_DEBOUNCE, 0x14);
+
+	ams_pmu_set_register(AMS_CONTROL, 0x4f);
+
+	/* Clear interrupts */
+	ams_pmu_clear_irq(AMS_IRQ_ALL);
+
+	ams_info.has_device = 1;
+
+	/* Enable interrupts */
+	ams_pmu_set_irq(AMS_IRQ_ALL, 1);
+
+	printk(KERN_INFO "ams: Found PMU based motion sensor\n");
+
+	return 0;
+}
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6.36-rc6/drivers/macintosh/ams/ams.h	2010-09-21 11:07:14.000000000 +0200
@@ -0,0 +1,70 @@
+#include <linux/i2c.h>
+#include <linux/input-polldev.h>
+#include <linux/kthread.h>
+#include <linux/mutex.h>
+#include <linux/spinlock.h>
+#include <linux/types.h>
+#include <linux/of_device.h>
+
+enum ams_irq {
+	AMS_IRQ_FREEFALL = 0x01,
+	AMS_IRQ_SHOCK = 0x02,
+	AMS_IRQ_GLOBAL = 0x04,
+	AMS_IRQ_ALL =
+		AMS_IRQ_FREEFALL |
+		AMS_IRQ_SHOCK |
+		AMS_IRQ_GLOBAL,
+};
+
+struct ams {
+	/* Locks */
+	spinlock_t irq_lock;
+	struct mutex lock;
+
+	/* General properties */
+	struct device_node *of_node;
+	struct platform_device *of_dev;
+	char has_device;
+	char vflag;
+	u32 orient1;
+	u32 orient2;
+
+	/* Interrupt worker */
+	struct work_struct worker;
+	u8 worker_irqs;
+
+	/* Implementation
+	 *
+	 * Only call these functions with the main lock held.
+	 */
+	void (*exit)(void);
+
+	void (*get_xyz)(s8 *x, s8 *y, s8 *z);
+	u8 (*get_vendor)(void);
+
+	void (*clear_irq)(enum ams_irq reg);
+
+#ifdef CONFIG_SENSORS_AMS_I2C
+	/* I2C properties */
+	struct i2c_client *i2c_client;
+#endif
+
+	/* Joystick emulation */
+	struct input_polled_dev *idev;
+	__u16 bustype;
+
+	/* calibrated null values */
+	int xcalib, ycalib, zcalib;
+};
+
+extern struct ams ams_info;
+
+extern void ams_sensors(s8 *x, s8 *y, s8 *z);
+extern int ams_sensor_attach(void);
+extern void ams_sensor_detach(void);
+
+extern int ams_pmu_init(struct device_node *np);
+extern int ams_i2c_init(struct device_node *np);
+
+extern int ams_input_init(void);
+extern void ams_input_exit(void);
--- linux-2.6.36-rc6.orig/MAINTAINERS	2010-10-05 10:45:16.000000000 +0200
+++ linux-2.6.36-rc6/MAINTAINERS	2010-10-05 11:51:21.000000000 +0200
@@ -445,7 +445,7 @@ AMS (Apple Motion Sensor) DRIVER
 M:	Stelian Pop <stelian@popies.net>
 M:	Michael Hanselmann <linux-kernel@hansmi.ch>
 S:	Supported
-F:	drivers/hwmon/ams/
+F:	drivers/macintosh/ams/
 
 AMSO1100 RNIC DRIVER
 M:	Tom Tucker <tom@opengridcomputing.com>
--- linux-2.6.36-rc6.orig/drivers/hwmon/Kconfig	2010-10-05 10:45:16.000000000 +0200
+++ linux-2.6.36-rc6/drivers/hwmon/Kconfig	2010-10-05 11:42:38.000000000 +0200
@@ -249,32 +249,6 @@ config SENSORS_K10TEMP
 	  This driver can also be built as a module.  If so, the module
 	  will be called k10temp.
 
-config SENSORS_AMS
-	tristate "Apple Motion Sensor driver"
-	depends on PPC_PMAC && !PPC64 && INPUT && ((ADB_PMU && I2C = y) || (ADB_PMU && !I2C) || I2C) && EXPERIMENTAL
-	select INPUT_POLLDEV
-	help
-	  Support for the motion sensor included in PowerBooks. Includes
-	  implementations for PMU and I2C.
-
-	  This driver can also be built as a module. If so, the module
-	  will be called ams.
-
-config SENSORS_AMS_PMU
-	bool "PMU variant"
-	depends on SENSORS_AMS && ADB_PMU
-	default y
-	help
-	  PMU variant of motion sensor, found in late 2005 PowerBooks.
-
-config SENSORS_AMS_I2C
-	bool "I2C variant"
-	depends on SENSORS_AMS && I2C
-	default y
-	help
-	  I2C variant of motion sensor, found in early 2005 PowerBooks and
-	  iBooks.
-
 config SENSORS_ASB100
 	tristate "Asus ASB100 Bach"
 	depends on X86 && I2C && EXPERIMENTAL
--- linux-2.6.36-rc6.orig/drivers/hwmon/Makefile	2010-10-05 10:45:16.000000000 +0200
+++ linux-2.6.36-rc6/drivers/hwmon/Makefile	2010-10-05 11:41:34.000000000 +0200
@@ -36,7 +36,6 @@ obj-$(CONFIG_SENSORS_ADT7462)	+= adt7462
 obj-$(CONFIG_SENSORS_ADT7470)	+= adt7470.o
 obj-$(CONFIG_SENSORS_ADT7475)	+= adt7475.o
 obj-$(CONFIG_SENSORS_APPLESMC)	+= applesmc.o
-obj-$(CONFIG_SENSORS_AMS)	+= ams/
 obj-$(CONFIG_SENSORS_ASC7621)	+= asc7621.o
 obj-$(CONFIG_SENSORS_ATXP1)	+= atxp1.o
 obj-$(CONFIG_SENSORS_CORETEMP)	+= coretemp.o
--- linux-2.6.36-rc6.orig/drivers/macintosh/Kconfig	2010-08-02 00:11:14.000000000 +0200
+++ linux-2.6.36-rc6/drivers/macintosh/Kconfig	2010-10-05 11:42:49.000000000 +0200
@@ -256,4 +256,30 @@ config PMAC_RACKMETER
 	  This driver provides some support to control the front panel
           blue LEDs "vu-meter" of the XServer macs.
 
+config SENSORS_AMS
+	tristate "Apple Motion Sensor driver"
+	depends on PPC_PMAC && !PPC64 && INPUT && ((ADB_PMU && I2C = y) || (ADB_PMU && !I2C) || I2C) && EXPERIMENTAL
+	select INPUT_POLLDEV
+	help
+	  Support for the motion sensor included in PowerBooks. Includes
+	  implementations for PMU and I2C.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called ams.
+
+config SENSORS_AMS_PMU
+	bool "PMU variant"
+	depends on SENSORS_AMS && ADB_PMU
+	default y
+	help
+	  PMU variant of motion sensor, found in late 2005 PowerBooks.
+
+config SENSORS_AMS_I2C
+	bool "I2C variant"
+	depends on SENSORS_AMS && I2C
+	default y
+	help
+	  I2C variant of motion sensor, found in early 2005 PowerBooks and
+	  iBooks.
+
 endif # MACINTOSH_DRIVERS
--- linux-2.6.36-rc6.orig/drivers/macintosh/Makefile	2010-08-02 00:11:14.000000000 +0200
+++ linux-2.6.36-rc6/drivers/macintosh/Makefile	2010-10-05 11:42:05.000000000 +0200
@@ -48,3 +48,5 @@ obj-$(CONFIG_WINDFARM_PM121)	+= windfarm
 				   windfarm_max6690_sensor.o \
 				   windfarm_lm75_sensor.o windfarm_pid.o
 obj-$(CONFIG_PMAC_RACKMETER)	+= rack-meter.o
+
+obj-$(CONFIG_SENSORS_AMS)	+= ams/


-- 
Jean Delvare

^ permalink raw reply

* Re: use of BAT before taking over the MMU
From: Albert Cahalan @ 2010-10-05 12:05 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev
In-Reply-To: <1286266201.2463.336.camel@pasglop>

On Tue, Oct 5, 2010 at 4:10 AM, Benjamin Herrenschmidt
<benh@kernel.crashing.org> wrote:
> On Mon, 2010-10-04 at 06:25 +0200, Segher Boessenkool wrote:
>> > On the prom boot path, with the firmware supposed to
>> > be managing the MMU, there is a case where:
>> >
>> > 1. Linux changes some BAT registers.
>> > 2. Bits 0x00000070 are/become set in the MSR.
>> > 3. Linux takes an MMU fault.
>> > 4. The firmware handles it.
>> >
>> > AFAIK, you can't expect the firmware to leave the BAT alone.
>> > If the firmware provides mapping services by using the BAT
>> > as a software-filled TLB, Linux's BAT changes may be lost.
>> >
>> > You also can't expect that your BAT changes will not conflict
>> > with mappings that the firmware uses for itself. The firmware
>> > might write to your new BAT mapping, relying on those virtual
>> > addresses to be something else entirely.
>>
>> The PowerPC OF binding requires the firmware to save and restore
>> the BATs on entry to / exit from the firmware.

That would defeat the purpose of setting them.
They are used to provide Linux with mappings.

> I'm not sure he was talking about OF here... In any case, we don't muck
> around with BATs until after we're done with OF anyways.

It's the Open Firmware client interface, not Firmworks code.
I wrote it. It just does hypervisor-like calls to an emulator which
does the real work. Essentially I have a prom_call opcode
and a handle_exception opcode. I claim to be an MPC7400.

The kernel is sitting at address 0, MSR becomes 0x70 when
an rfi goes to address 0. This will be head_32.S with r5 set,
so Linux will call prom_init to fetch the device tree.

Of course that faults immediately, so I have a handler that
loads IBAT0 with a 128 KiB mapping. I treat the BAT like a
direct-mapped software-loaded TLB. (like MIPS arch MMU)

I threw in a hack to skip to the next BAT when the chosen
one is not a 128 KiB 1:1 mapping. That seems to work, but
sure doesn't feel right.

Note that Linux can fail even with a firmware that doesn't touch
the BAT registers. The MMU is on, and 0xc0000000 may be
where the firmware expects to have... MMIO for the console,
the client interface entry point, a forth stack, whatever.
The BAT takes priority, and thus the firmware splatters stuff
right onto the kernel or dies trying to read something it left there.

^ permalink raw reply

* Re: use of BAT before taking over the MMU
From: Benjamin Herrenschmidt @ 2010-10-05 12:28 UTC (permalink / raw)
  To: Albert Cahalan; +Cc: linuxppc-dev
In-Reply-To: <AANLkTik9KeVzc6T7U=TX1bSA934Wmtbt4cjHrWSgWtLn@mail.gmail.com>


> >> The PowerPC OF binding requires the firmware to save and restore
> >> the BATs on entry to / exit from the firmware.
> 
> That would defeat the purpose of setting them.
> They are used to provide Linux with mappings.

How so ? As long as they are present when executing Linux code,
I don't see the problem if they contain different mappings while
inside FW...

> > I'm not sure he was talking about OF here... In any case, we don't muck
> > around with BATs until after we're done with OF anyways.
> 
> It's the Open Firmware client interface, not Firmworks code.
> I wrote it. It just does hypervisor-like calls to an emulator which
> does the real work. Essentially I have a prom_call opcode
> and a handle_exception opcode. I claim to be an MPC7400.
> 
> The kernel is sitting at address 0, MSR becomes 0x70 when
> an rfi goes to address 0. This will be head_32.S with r5 set,
> so Linux will call prom_init to fetch the device tree.

Right. Within prom_init we don't touch the BATs, we are still under FW
control at this stage.

> Of course that faults immediately,

It shouldn't but it can. When you enter Linux with an OF "client
interface" entry, you are responsible for having reasonable mappings for
executing the client code. You are allowed to fault these if you want
to, and do whatever you want, as long as the prom_init code can execute.
IE. Linux hasn't set any mappings nor BATs at this stage, it's operating
as a client program of the FW and entirely relies on the FW to provide
the necessary MMU setup until the end of prom_init.

>  so I have a handler that
> loads IBAT0 with a 128 KiB mapping. I treat the BAT like a
> direct-mapped software-loaded TLB. (like MIPS arch MMU)
> 
> I threw in a hack to skip to the next BAT when the chosen
> one is not a 128 KiB 1:1 mapping. That seems to work, but
> sure doesn't feel right.

Why would you need to do that ? Linux hasn't done anything to mappings
yet and only cares about what you have setup...

Linux will throw away your BATs etc... only after it returns from
prom_init at which point it won't call your FW anymore anyways.

> Note that Linux can fail even with a firmware that doesn't touch
> the BAT registers. The MMU is on, and 0xc0000000 may be
> where the firmware expects to have... MMIO for the console,
> the client interface entry point, a forth stack, whatever.

Right, but Linux doesn't establish nor relies on mappings at c0000000 at
this point. prom_init is relocatable code that can execute from any
address.

> The BAT takes priority, and thus the firmware splatters stuff
> right onto the kernel or dies trying to read something it left there.

I'm not entirely sure what you are doing but it certainly sounds
wrong :-)

As I said, at this stage, Linux is just a "normal" client interface
program. It's happy to run from any address you put it with any mapping
you provide until it returns from prom_init at which point it takes over
the MMU.

Ben.

^ permalink raw reply

* Re: Serial RapidIO Maintaintance read causes lock up
From: John Traill @ 2010-10-05 13:24 UTC (permalink / raw)
  To: Bastiaan Nijkamp; +Cc: Bounine, Alexandre, linuxppc-dev
In-Reply-To: <AANLkTimCiHWRR-kVuT0ift3CH63Xk_XcaXS22qmVh6fr@mail.gmail.com>

Bastiaan,

A few things to check.

1. Is the target board also set up for small common transport system size ie 256.

2. Make sure the target has "Accept All" set - in fsl_rio.c look for
>        /* Set to receive any dist ID for serial RapidIO controller. */
>         if (port->phy_type == RIO_PHY_SERIAL)
>                 out_be32((priv->regs_win + RIO_ISR_AACR), RIO_ISR_AACR_AA);

3. How do you synchronise reset between both systems ? Both need to be reset to 
insure the inbound/outbound ackid's remain in sync. If you only reset one then 
you have the potential for the ackid's to get out of sync. Also what is the 
kernel log on the agent system ?

Cheers.


On 05/10/10 09:56, Bastiaan Nijkamp wrote:
>
> Hi Alex,
>
> Thanks for your advice. We are trying to make a board-to-board
> connection without any additional hardware (eg. a switch). The boards
> use a 50-pin, right-angle MEC8-125-02-L-D-RA1 connector from SAMTEC and
> are connected trough a EEDP-016-12.00-RA1-RA2-2 cross cable from SAMTEC.
> I hope this information is sufficient since there is not much one can
> find about it on Google. In addition, you can see a picture of the board
> including the connector in the datasheet located at
> http://www.windriver.com/products/product-notes/SBC8548E-product-note.pdf.
> It is the connector on the left side of the PCI-EX slot.
>
> We have tried your suggestion but the situation does not change other
> than the lane-mode being set to single lane 0, it still locks up when
> trying to generate a maintenance transaction. I still think it is memory
> related since the lock up occurs when accessing the maintenance window.
> Although all memory related settings seems to be alright.
>
> The kernel output is as follows:
>
> Setting up RapidIO peer-to-peer network /soc8548@e0000000/rapidio@c0000
> fsl-of-rio e00c0000.rapidio: Of-device full name
> /soc8548@e0000000/rapidio@c0000
> fsl-of-rio e00c0000.rapidio: Regs: [mem 0xe00c0000-0xe00dffff]
> fsl-of-rio e00c0000.rapidio: LAW start 0x00000000c0000000, size
> 0x0000000010000000.
> fsl-of-rio e00c0000.rapidio: pwirq: 48, bellirq: 50, txirq: 53, rxirq 54
> fsl-of-rio e00c0000.rapidio: DeviceID is 0x0
> fsl-of-rio e00c0000.rapidio: Configured as HOST
> fsl-of-rio e00c0000.rapidio: Overriding RIO_PORT setting to single lane 0
> fsl-of-rio e00c0000.rapidio: RapidIO PHY type: serial
> fsl-of-rio e00c0000.rapidio: Hardware port width: 4
> fsl-of-rio e00c0000.rapidio: Training connection status: Single-lane 0
> fsl-of-rio e00c0000.rapidio: RapidIO Common Transport System size: 256
> fsl-of-rio e00c0000.rapidio: LAW start 0x00000000c0000000, RIO
> Maintainance Window Size 0x400000,New Main Start: 0xd1080000
> RIO: enumerate master port 0, RIO0 mport
> fsl_rio_config_read: index 0 destid 255 hopcount 0 offset 00000068 len 4
> fsl_rio_config_read: Passed IS_ALIGNED.
> fsl_rio_config_read: Passed 'out_be32_1'
> fsl_rio_config_read: Passed 'out_be32_2'
> fsl_rio_config_read: len is 4
> fsl_rio_config_read: triggering '__fsl_read_rio_config'
> fsl_rio_config_read: going to request to read data at d108006
>
> Regards,
> Bastiaan
>
> 2010/10/4 Bounine, Alexandre <Alexandre.Bounine@idt.com
> <mailto:Alexandre.Bounine@idt.com>>
>
>     Hi Bastiaan,
>
>     Are you trying board-to-board connection?
>     I am not familiar with WRS SBC8548 board - which type of connector they
>     use for SRIO?
>
>     Assuming that all configuration is correct,
>     I would recommend first to try setting up x1 link mode at the lowest
>     link speed.
>     The x4 mode may present challenges in some cases.
>
>     For quick test you may just add port width override into fsl_rio.c
>     like shown below (ugly but sometimes it helps ;) ):
>
>     @@ -1461,10 +1461,16 @@ int fsl_rio_setup(struct platform_device *dev)
>             rio_register_mport(port);
>
>             priv->regs_win = ioremap(regs.start, regs.end - regs.start + 1);
>             rio_regs_win = priv->regs_win;
>
>     +dev_info(&dev->dev, "Overriding RIO_PORT setting to single lane 0\n");
>     +out_be32(priv->regs_win + 0x15C, in_be32(priv->regs_win + 0x15C) |
>     0x800000);
>     +out_be32(priv->regs_win + 0x15C, in_be32(priv->regs_win + 0x15C) |
>     0x2000000);
>     +out_be32(priv->regs_win + 0x15C, in_be32(priv->regs_win + 0x15C) &
>     ~0x800000);
>     +msleep(100);
>     +
>             /* Probe the master port phy type */
>             ccsr = in_be32(priv->regs_win + RIO_CCSR);
>             port->phy_type = (ccsr & 1) ? RIO_PHY_SERIAL : RIO_PHY_PARALLEL;
>             dev_info(&dev->dev, "RapidIO PHY type: %s\n",
>                             (port->phy_type == RIO_PHY_PARALLEL) ?
>     "parallel" :
>
>
>     Let me know what happens.
>     Please keep me in the CC: list next time when posting RapidIO questions
>     to the linuxppc-dev or kernel mailing lists.
>
>     Regards,
>
>     Alex.
>
>
>
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev

-- 
John Traill
Systems Engineer
Network and Computing Systems Group

Freescale Semiconductor UK LTD
Colvilles Road
East Kilbride
Glasgow G75 0TG, Scotland

Tel: +44 (0) 1355 355494
Fax: +44 (0) 1355 261790

E-mail: john.traill@freescale.com

Registration Number: SC262720
VAT Number: GB831329053

[ ] General Business Use
[ ] Freescale Internal Use Only
[ ] Freescale Confidential Proprietary

^ 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