LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* Using kprobes [was Re: [PATCH] Performance Stats: Kernel patch
From: Linas Vepstas @ 2007-05-11 17:23 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Maxim Uvarov, dada1, pavel, wli, linuxppc-dev
In-Reply-To: <20070510111242.dd42adae.akpm@linux-foundation.org>

On Thu, May 10, 2007 at 11:12:42AM -0700, Andrew Morton wrote:
> 
> I don't think the syscall-counting feature has a future, sorry.  Perhaps
> you could do something like hooking it up on-demand by insertion of a kprobe,
> dunno.

This is an interesting point. I've started fiddling with (a wrapper
around) kprobes that allows me to pick any subroutine symbol in System.map,
and then get an event whenever that subroutine gets called. Its pretty
slick, and allows me to gather data on certain unusual events in the
kernel.  (I'm not using this for performance monitoring, I'm trying to 
do RAS).

It makes a lot of sense to me to have a generic kprobe extension, where 
you could give it a list of subroutine names, and it'll collect stats
on the number of times that the routine was called. Some user-space thingy
could poll for those stats, or you could put them in /sys or wherever.

Its more complicted than just instriumenting syscalls, but a lot more
useful, I would think ... 

--linas

^ permalink raw reply

* Re: [RFC] cell: saving spus information for kexec crash
From: Anton Blanchard @ 2007-05-11 17:22 UTC (permalink / raw)
  To: Andre Detsch; +Cc: linuxppc-dev, cbe-oss-dev
In-Reply-To: <200705111353.22781.adetsch@br.ibm.com>

 
Hi,

> This patch adds support for investigating spus information after a
> kernel crash event, through kdump vmcore file.
> Implementation is based on xmon code, but the new functionality was
> kept independent.

This brings up a point: it looks like kdump doesnt capture the FP and
altivec regs. Could be important for some bugs.

This brings up yet another point, it looks like our userspace core dumps
dont capture altivec or SPU state.

Anton

^ permalink raw reply

* [PATCH] powerpc: don't complain if size-cells == 0
From: Kim Phillips @ 2007-05-11 17:19 UTC (permalink / raw)
  To: linuxppc-dev

An mdio bus scan was added with ucc_geth phylib
migration patches, now machines complain on boot, saying:

prom_parse: Bad cell count for /qe@e0100000/mdio@2120/ethernet-phy@00
prom_parse: Bad cell count for /qe@e0100000/mdio@2120/ethernet-phy@01

since size-cells can indeed be 0, this patch fixes the check.

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
 arch/powerpc/kernel/prom_parse.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/kernel/prom_parse.c b/arch/powerpc/kernel/prom_parse.c
index b5c96af..3786dcc 100644
--- a/arch/powerpc/kernel/prom_parse.c
+++ b/arch/powerpc/kernel/prom_parse.c
@@ -24,7 +24,7 @@
 /* Max address size we deal with */
 #define OF_MAX_ADDR_CELLS	4
 #define OF_CHECK_COUNTS(na, ns)	((na) > 0 && (na) <= OF_MAX_ADDR_CELLS && \
-			(ns) > 0)
+			(ns) >= 0)
 
 static struct of_bus *of_match_bus(struct device_node *np);
 static int __of_address_to_resource(struct device_node *dev,
-- 
1.5.0.3

^ permalink raw reply related

* Re: arch/powerpc/sysdev: dumping ground or only for shared drivers?
From: Linas Vepstas @ 2007-05-11 17:05 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: Olof Johansson, linuxppc-dev
In-Reply-To: <17987.47155.935764.878634@cargo.ozlabs.ibm.com>

On Fri, May 11, 2007 at 10:26:27AM +1000, Paul Mackerras wrote:
> Olof Johansson writes:
> 
> > This adds yet another set of chipset drivers under sysdev, that are
> > only used by one platform (several board ports under that platform,
> > but only one platforms/* directory).
> > 
> > In my opinion, they really should go under the platform directory instead,
> > and not clutter the shared directory.
> 
> I disagree, actually.  Having these things in a shared directory makes
> it more likely that people will look at the code.  That means that
> it's more likely that bugs will be found, and more likely that parts
> of the code can get reused when people are doing the port to a new
> chip or board.
> 
> If there were hundreds of files in arch/powerpc/sysdev then I would be
> more likely to agree with you, but there aren't.

I like Paul's take, it matches my gut instincts.

--linas

^ permalink raw reply

* Re: [PATCH 1/13] powerpc: Add Makefile rules to wrap dts file in zImage
From: Mark A. Greer @ 2007-05-11 15:59 UTC (permalink / raw)
  To: Mark A. Greer, Paul Mackerras, linuxppc-dev
In-Reply-To: <20070510232945.GB27188@localhost.localdomain>

On Fri, May 11, 2007 at 09:29:45AM +1000, David Gibson wrote:
> On Thu, May 10, 2007 at 01:04:45PM -0700, Mark A. Greer wrote:
> > @@ -195,13 +213,17 @@ $(obj)/zImage:		$(addprefix $(obj)/, $(i
> >  	@rm -f $@; ln $< $@
> >  $(obj)/zImage.initrd:	$(addprefix $(obj)/, $(initrd-y))
> >  	@rm -f $@; ln $< $@
> > +$(obj)/zImage.dts:	$(addprefix $(obj)/, $(dts-y))
> > +	@rm -f $@; ln $< $@
> > +$(obj)/zImage.dts_initrd:	$(addprefix $(obj)/, $(dts_initrd-y))
> > +	@rm -f $@; ln $< $@
> 
> I don't think there a lot of point to this part of the patch.  Just
> have image-y directly specify the appropriate zImage.dts.% form (or
> forms).

Okay.  Thank you.  There will be a whole new set come out later today
with people's comments addressed.

Mark

^ permalink raw reply

* Re: Fixed PHY problems
From: Segher Boessenkool @ 2007-05-11 15:37 UTC (permalink / raw)
  To: Vitaly Bordug; +Cc: linuxppc-dev
In-Reply-To: <20070511180412.025aa1ca@vitb.ru.mvista.com>

>> 			phy3: ethernet-phy@03 {

>> 			phy4: ethernet-phy@04 {

@3 resp. @4 is more in line with existing practice.

> phy1: fixed-phy@01 {
> 	reg = <100 1>; /*100Mps, full duplex*/

The first entry in "reg" has to correspond to the
unit address (@01 in this case -- again, should be
@1 instead).

Never overload the meaning of well-known properties,
esp. not if it conflicts with the existing semantics,
like here.


Segher

^ permalink raw reply

* Re: Fixed PHY problems
From: Joakim Tjernlund @ 2007-05-11 14:20 UTC (permalink / raw)
  To: Vitaly Bordug; +Cc: linuxppc-dev
In-Reply-To: <20070511180412.025aa1ca@vitb.ru.mvista.com>

On Fri, 2007-05-11 at 18:04 +0400, Vitaly Bordug wrote:
> > hmm, been trying to figure out all day how to make ucc_geth find my
> > fixed PHY without success. OF experts, please give me some hints.
> > My board is derived from the in tree mpc832x_mds bord and I am trying to
> > convert this part:
> > 	mdio@2320 {
> > 			#address-cells = <1>;
> > 			#size-cells = <0>;
> > 			reg = <2320 18>;
> > 			device_type = "mdio";
> > 			compatible = "ucc_geth_phy";
> > 
> > 			phy3: ethernet-phy@03 {
> > 				interrupt-parent = < &ipic >;
> > 				interrupts = <11 8>;
> > 				reg = <3>;
> > 				device_type = "ethernet-phy";
> > 			};
> > 			phy4: ethernet-phy@04 {
> > 				interrupt-parent = < &ipic >;
> > 				interrupts = <12 8>;
> > 				reg = <4>;
> > 				device_type = "ethernet-phy";
> > 			};
> > 		};
> > into fixed PHYs, how do I do that?
> 
> Well, fixed phy didn't made it to have any representation in dts as of now, at least
> what I am aware of, and it is just a platform device so far.
> 
> Speaking about it, I am recalling long-pending enhancement to unify fixed interface with
> bus_id representation in gianfar (that is having numeric bus:device way).
> 
> About dts, the only options fixed phy can have, are speed and duplex, it does not trigger irq and
> so on, and I see something like 
> 
> phy1: fixed-phy@01 {
> 	reg = <100 1>; /*100Mps, full duplex*/
> 	device_type = "ethernet-phy";
> };

Looks resonable to me, although I think reg needs to be <d#100 1>

How do make ucc_geth find it?

PS.
   Could you send me the patch that fixes:
Device 'fixed@100:1' does not have a release() function, it is broken
and must be fixed.

Is this warning harmless?

^ permalink raw reply

* Re: 83xx: requesting external interrupts
From: Ben Warren @ 2007-05-11 14:12 UTC (permalink / raw)
  To: Alex Zeffertt; +Cc: linuxppc-embedded
In-Reply-To: <46443784.3060600@cambridgebroadband.com>

Alex,

On Fri, 2007-05-11 at 10:29 +0100, Alex Zeffertt wrote:
> Hi,
> 
> Thanks for your reply Ben, but I think my problem is slightly different.  It is not
> that the sense (high/low/rising/falling) of the interrupt is wrong, but that the
> kernel will not allow me to register the handler.
> 
> I've changed my code to:
> 
>      struct device_node *np = of_find_node_by_type(NULL, "ipic");
>      struct irq_host *host = irq_find_host(np);
>      int rc;
> 
>      unsigned int virq = irq_find_mapping(host, 5);
>      set_irq_type(virq, IRQ_TYPE_EDGE_FALLING);
>      rc = request_irq(virq, mpc832xemds_phy_interrupt, IRQF_SHARED, "pm5384", dev);
> 
> but the last line still returns a non-zero error code.
> 
> Is there a new way of requesting to install a handler for external interrupts?  I
> can't find any powerpc examples in the kernel tree....
> 
Sorry, I missed a bit of the implementation.  You need to register the
IRQs before attempting to attach an ISR. Here's some sample code that
works for me.  You'll probably need different IRQs, based on what your
board does:

/* All external IRQs + Generic timer IRQs must be initialized by BSP */
const int bsp_irqs[] = {48, 17, 18, 19, 20, 21, 22, 23, 90, 78, 84, 72};

Add this to your BSP IRQ init code (void __init xxx_init_IRQs())


	for (i=0;i<sizeof(bsp_irqs)/sizeof(bsp_irqs[0]);i++)
		virq = irq_create_mapping(NULL, bsp_irqs[i]);

That should do it.

regards,
Ben

^ permalink raw reply

* Re: Fixed PHY problems
From: Vitaly Bordug @ 2007-05-11 14:04 UTC (permalink / raw)
  To: joakim.tjernlund; +Cc: linuxppc-dev
In-Reply-To: <1178890872.20638.21.camel@gentoo-jocke.transmode.se>


> hmm, been trying to figure out all day how to make ucc_geth find my
> fixed PHY without success. OF experts, please give me some hints.
> My board is derived from the in tree mpc832x_mds bord and I am trying to
> convert this part:
> 	mdio@2320 {
> 			#address-cells = <1>;
> 			#size-cells = <0>;
> 			reg = <2320 18>;
> 			device_type = "mdio";
> 			compatible = "ucc_geth_phy";
> 
> 			phy3: ethernet-phy@03 {
> 				interrupt-parent = < &ipic >;
> 				interrupts = <11 8>;
> 				reg = <3>;
> 				device_type = "ethernet-phy";
> 			};
> 			phy4: ethernet-phy@04 {
> 				interrupt-parent = < &ipic >;
> 				interrupts = <12 8>;
> 				reg = <4>;
> 				device_type = "ethernet-phy";
> 			};
> 		};
> into fixed PHYs, how do I do that?

Well, fixed phy didn't made it to have any representation in dts as of now, at least
what I am aware of, and it is just a platform device so far.

Speaking about it, I am recalling long-pending enhancement to unify fixed interface with
bus_id representation in gianfar (that is having numeric bus:device way).

About dts, the only options fixed phy can have, are speed and duplex, it does not trigger irq and
so on, and I see something like 

phy1: fixed-phy@01 {
	reg = <100 1>; /*100Mps, full duplex*/
	device_type = "ethernet-phy";
};

-- 
Sincerely, 
Vitaly

^ permalink raw reply

* Re: Fixed PHY problems
From: Joakim Tjernlund @ 2007-05-11 13:41 UTC (permalink / raw)
  To: Vitaly Bordug; +Cc: linuxppc-dev
In-Reply-To: <1178874287.20638.8.camel@gentoo-jocke.transmode.se>

On Fri, 2007-05-11 at 11:04 +0200, Joakim Tjernlund wrote:
> On Fri, 2007-05-11 at 12:07 +0400, Vitaly Bordug wrote:
> > On Thu, 10 May 2007 19:41:53 +0200
> > Joakim Tjernlund wrote:
> > 
> > > Trying to boot todays linus tree with fixed PHY support enabled gets
> > > me this: Fixed PHY: Registered new driver
> > > Device 'fixed@100:1' does not have a release() function, it is broken
> > > and must be fixed. ------------[ cut here ]------------
> > > Badness at drivers/base/core.c:107
> > > Call Trace:
> > > [cffc1dc0] [c0008324] show_stack+0x48/0x194 (unreliable)
> > > [cffc1df0] [c00f4a4c] report_bug+0x84/0xec
> > > [cffc1e00] [c000dde8] program_check_exception+0x274/0x55c
> > > [cffc1e20] [c000f770] ret_from_except_full+0x0/0x4c
> > > --- Exception: 700 at device_release+0x54/0x90
> > >     LR = device_release+0x54/0x90
> > > [cffc1ef0] [c00f5e1c] kobject_cleanup+0xb4/0xb8
> > > [cffc1f10] [c00f6ca0] kref_put+0x68/0x80
> > > [cffc1f20] [c00f5d58] kobject_put+0x24/0x34
> > > [cffc1f30] [c01150bc] put_device+0x1c/0x2c
> > > [cffc1f40] [c0243a9c] fixed_init+0x1cc/0x210
> > > [cffc1f60] [c022e828] kernel_init+0x8c/0x2b4
> > > [cffc1ff0] [c000ff4c] kernel_thread+0x44/0x60
> > > 
> > > The other thing is, how do I specify a fixed PHY
> > > in OF?
> > > 
> > I have a patch that  fixes it but was busy with other stuff because of merge window.
> > Can send it to you meanwhile, going to deal with it after next rc released...
> 
> Please do, thanks.
> 
> Do you have any idea what needs to go into the DTS file to make my
> 832x(ucc_geth) find it?

hmm, been trying to figure out all day how to make ucc_geth find my
fixed PHY without success. OF experts, please give me some hints.
My board is derived from the in tree mpc832x_mds bord and I am trying to
convert this part:
	mdio@2320 {
			#address-cells = <1>;
			#size-cells = <0>;
			reg = <2320 18>;
			device_type = "mdio";
			compatible = "ucc_geth_phy";

			phy3: ethernet-phy@03 {
				interrupt-parent = < &ipic >;
				interrupts = <11 8>;
				reg = <3>;
				device_type = "ethernet-phy";
			};
			phy4: ethernet-phy@04 {
				interrupt-parent = < &ipic >;
				interrupts = <12 8>;
				reg = <4>;
				device_type = "ethernet-phy";
			};
		};
into fixed PHYs, how do I do that?

 Jocke

^ permalink raw reply

* Updated DTC tarball snapshot on jdl.com
From: Jon Loeliger @ 2007-05-11 13:35 UTC (permalink / raw)
  To: linuxppc-dev


Folks,

At the request of one our esteemed subscribers, I have
updated the DTC tarball on jdl.com for the git impaired.
(I know!  Hard to believe, isn't it? :-)

I've dropped one here now:

    http://www.jdl.com/software/dtc-20070510.tgz

My DTC git repo continues to be browsable here:

    http://www.jdl.com/git_repos

and cloned here:

    git clone git://www.jdl.com/software/dtc.git

Enjoy.

jdl

^ permalink raw reply

* [PATCH] simplify smp_space_timers
From: Will Schmidt @ 2007-05-11 13:34 UTC (permalink / raw)
  To: linuxppc-dev, paulus; +Cc: anton


greatly simplify the function smp_space_timers.

The stolen time calculation (per comment within the code) doesnt need the
half-jiffy stagger any more.  There isnt an issue with bouncing off global
locks, so we really shouldnt need any sort of staggering at all.

However, the last_jiffy value still needs to be set.   This removes the
extra stagger logic, and just sets the values.

This change should benefit applications that rely on barrier
synchronization, and will help cut down OS jitter.

boot tested across the board (G5,power3,power4,power5,970mp blade).

Signed-off-by: Will Schmidt <will_schmidt@vnet.ibm.com>
---

 arch/powerpc/kernel/time.c |   19 ++-----------------
 1 files changed, 2 insertions(+), 17 deletions(-)

diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index f6f0c6b..8baa1cb 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -711,30 +711,15 @@ void wakeup_decrementer(void)
 void __init smp_space_timers(unsigned int max_cpus)
 {
 	int i;
-	unsigned long half = tb_ticks_per_jiffy / 2;
-	unsigned long offset = tb_ticks_per_jiffy / max_cpus;
 	u64 previous_tb = per_cpu(last_jiffy, boot_cpuid);
 
 	/* make sure tb > per_cpu(last_jiffy, cpu) for all cpus always */
 	previous_tb -= tb_ticks_per_jiffy;
-	/*
-	 * The stolen time calculation for POWER5 shared-processor LPAR
-	 * systems works better if the two threads' timebase interrupts
-	 * are staggered by half a jiffy with respect to each other.
-	 */
+
 	for_each_possible_cpu(i) {
 		if (i == boot_cpuid)
 			continue;
-		if (i == (boot_cpuid ^ 1))
-			per_cpu(last_jiffy, i) =
-				per_cpu(last_jiffy, boot_cpuid) - half;
-		else if (i & 1)
-			per_cpu(last_jiffy, i) =
-				per_cpu(last_jiffy, i ^ 1) + half;
-		else {
-			previous_tb += offset;
-			per_cpu(last_jiffy, i) = previous_tb;
-		}
+		per_cpu(last_jiffy, i) = previous_tb;
 	}
 }
 #endif

^ permalink raw reply related

* [PATCH] Performance Stats: Kernel patch
From: Maxim Uvarov @ 2007-05-11 17:13 UTC (permalink / raw)
  To: LKML; +Cc: msyrchin, wli, dada1, linuxppc-dev, pavel


Hello,

Thanks all for very useful comments. 
Please review this version.


Best regards,
Maxim.

Patch makes available to the user the following
task and process performance statistics:
	* Involuntary Context Switches (task_struct->nivcsw)
	* Voluntary Context Switches (task_struct->nvcsw)
	* Number of system calls (added new counter
	  thread_info->sysall_count)
	           
Statistics information is available from:
        1. taskstats interface (Documentation/accounting/)
	2. /proc/PID/status (task only).

This data is useful for detecting hyperactivity
patterns between processes.

Signed-off-by: Maxim Uvarov <muvarov@ru.mvista.com>


                                                          
---

 Documentation/accounting/getdelays.c          |   20 ++++++++++++++++++--
 Documentation/accounting/taskstats-struct.txt |    7 +++++++
 arch/i386/kernel/asm-offsets.c                |    1 +
 arch/i386/kernel/entry.S                      |    3 +++
 arch/powerpc/kernel/asm-offsets.c             |    2 ++
 arch/powerpc/kernel/entry_32.S                |    5 +++++
 arch/powerpc/kernel/entry_64.S                |    5 +++++
 arch/x86_64/kernel/asm-offsets.c              |    1 +
 arch/x86_64/kernel/entry.S                    |    3 +++
 fs/proc/array.c                               |   14 ++++++++++++++
 include/asm-i386/thread_info.h                |    1 +
 include/asm-powerpc/thread_info.h             |    1 +
 include/asm-x86_64/thread_info.h              |    1 +
 include/linux/taskstats.h                     |    6 +++++-
 kernel/fork.c                                 |    3 +++
 kernel/taskstats.c                            |    6 ++++++
 16 files changed, 76 insertions(+), 3 deletions(-)

diff --git a/Documentation/accounting/getdelays.c b/Documentation/accounting/getdelays.c
index e9126e7..1be7d65 100644
--- a/Documentation/accounting/getdelays.c
+++ b/Documentation/accounting/getdelays.c
@@ -49,6 +49,7 @@ char name[100];
 int dbg;
 int print_delays;
 int print_io_accounting;
+int print_task_stats;
 __u64 stime, utime;
 
 #define PRINTF(fmt, arg...) {			\
@@ -187,7 +188,7 @@ void print_delayacct(struct taskstats *t)
 	       "IO    %15s%15s\n"
 	       "      %15llu%15llu\n"
 	       "MEM   %15s%15s\n"
-	       "      %15llu%15llu\n\n",
+	       "      %15llu%15llu\n"
 	       "count", "real total", "virtual total", "delay total",
 	       t->cpu_count, t->cpu_run_real_total, t->cpu_run_virtual_total,
 	       t->cpu_delay_total,
@@ -196,6 +197,15 @@ void print_delayacct(struct taskstats *t)
 	       "count", "delay total", t->swapin_count, t->swapin_delay_total);
 }
 
+void print_taskstats(struct taskstats *t)
+{
+	printf("\n\nTask  %15s%15s%15s\n"
+	       "      %15lu%15lu%15lu\n",
+	       "syscalls", "voluntary", "nonvoluntary",
+	       t->syscall_counter, t->nvcsw, t->nivcsw);
+
+}
+
 void print_ioacct(struct taskstats *t)
 {
 	printf("%s: read=%llu, write=%llu, cancelled_write=%llu\n",
@@ -227,7 +237,7 @@ int main(int argc, char *argv[])
 	struct msgtemplate msg;
 
 	while (1) {
-		c = getopt(argc, argv, "diw:r:m:t:p:v:l");
+		c = getopt(argc, argv, "qdiw:r:m:t:p:v:l");
 		if (c < 0)
 			break;
 
@@ -240,6 +250,10 @@ int main(int argc, char *argv[])
 			printf("printing IO accounting\n");
 			print_io_accounting = 1;
 			break;
+		case 'q':
+			printf("printing task/process stasistics:\n");
+			print_task_stats = 1;
+			break;
 		case 'w':
 			strncpy(logfile, optarg, MAX_FILENAME);
 			printf("write to file %s\n", logfile);
@@ -381,6 +395,8 @@ int main(int argc, char *argv[])
 							print_delayacct((struct taskstats *) NLA_DATA(na));
 						if (print_io_accounting)
 							print_ioacct((struct taskstats *) NLA_DATA(na));
+						if (print_task_stats)
+							print_taskstats((struct taskstats *) NLA_DATA(na));
 						if (fd) {
 							if (write(fd, NLA_DATA(na), na->nla_len) < 0) {
 								err(1,"write error\n");
diff --git a/Documentation/accounting/taskstats-struct.txt b/Documentation/accounting/taskstats-struct.txt
index 661c797..606aef6 100644
--- a/Documentation/accounting/taskstats-struct.txt
+++ b/Documentation/accounting/taskstats-struct.txt
@@ -22,6 +22,8 @@ There are three different groups of fields in the struct taskstats:
     /* Extended accounting fields end */
     Their values are collected if CONFIG_TASK_XACCT is set.
 
+4) Per-task and per-thread statistics
+
 Future extension should add fields to the end of the taskstats struct, and
 should not change the relative position of each field within the struct.
 
@@ -158,4 +160,9 @@ struct taskstats {
 
 	/* Extended accounting fields end */
 
+4) Per-task and per-thread statiscits
+	__u64	syscall_counter;	/* Syscall counter */
+	__u64	nvcsw;			/* Context voluntary switch counter */
+	__u64	nivcsw;			/* Context involuntary switch counter */
+
 }
diff --git a/arch/i386/kernel/asm-offsets.c b/arch/i386/kernel/asm-offsets.c
index 1b2f3cd..4ad49d2 100644
--- a/arch/i386/kernel/asm-offsets.c
+++ b/arch/i386/kernel/asm-offsets.c
@@ -56,6 +56,7 @@ void foo(void)
 	OFFSET(TI_addr_limit, thread_info, addr_limit);
 	OFFSET(TI_restart_block, thread_info, restart_block);
 	OFFSET(TI_sysenter_return, thread_info, sysenter_return);
+	OFFSET(TI_syscall_count, thread_info, syscall_count);
 	BLANK();
 
 	OFFSET(GDS_size, Xgt_desc_struct, size);
diff --git a/arch/i386/kernel/entry.S b/arch/i386/kernel/entry.S
index 5e47683..836961f 100644
--- a/arch/i386/kernel/entry.S
+++ b/arch/i386/kernel/entry.S
@@ -332,6 +332,9 @@ sysenter_past_esp:
 	SAVE_ALL
 	GET_THREAD_INFO(%ebp)
 
+#ifdef CONFIG_TASKSTATS
+	incl	TI_syscall_count(%ebp)	# Increment syscalls counter
+#endif
 	/* Note, _TIF_SECCOMP is bit number 8, and so it needs testw and not testb */
 	testw $(_TIF_SYSCALL_EMU|_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT),TI_flags(%ebp)
 	jnz syscall_trace_entry
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
index 030d300..b640039 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -94,6 +94,8 @@ int main(void)
 	DEFINE(TI_LOCAL_FLAGS, offsetof(struct thread_info, local_flags));
 	DEFINE(TI_PREEMPT, offsetof(struct thread_info, preempt_count));
 	DEFINE(TI_TASK, offsetof(struct thread_info, task));
+	DEFINE(TI_SYSCALL_COUNT, offsetof(struct thread_info, syscall_count));
+
 #ifdef CONFIG_PPC32
 	DEFINE(TI_EXECDOMAIN, offsetof(struct thread_info, exec_domain));
 	DEFINE(TI_CPU, offsetof(struct thread_info, cpu));
diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index c03e829..5d919e4 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -202,6 +202,11 @@ _GLOBAL(DoSyscall)
 	bl	do_show_syscall
 #endif /* SHOW_SYSCALLS */
 	rlwinm	r10,r1,0,0,(31-THREAD_SHIFT)	/* current_thread_info() */
+#ifdef CONFIG_TASKSTATS 
+	lwz r11,TI_SYSC_CNT(r10)
+	addi r11,r11,1
+	stw r11,TI_SYSC_CNT(r10)
+#endif
 	lwz	r11,TI_FLAGS(r10)
 	andi.	r11,r11,_TIF_SYSCALL_T_OR_A
 	bne-	syscall_dotrace
diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index 2551c08..5907f76 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -115,6 +115,11 @@ END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES)
 	addi	r9,r1,STACK_FRAME_OVERHEAD
 #endif
 	clrrdi	r11,r1,THREAD_SHIFT
+#ifdef CONFIG_TASKSTATS
+	ld r10,TI_SYSCALL_COUNT(r11)
+	addi r10,r10,1
+	std r10,TI_SYSCALL_COUNT(r11)
+#endif
 	ld	r10,TI_FLAGS(r11)
 	andi.	r11,r10,_TIF_SYSCALL_T_OR_A
 	bne-	syscall_dotrace
diff --git a/arch/x86_64/kernel/asm-offsets.c b/arch/x86_64/kernel/asm-offsets.c
index 96687e2..da57356 100644
--- a/arch/x86_64/kernel/asm-offsets.c
+++ b/arch/x86_64/kernel/asm-offsets.c
@@ -35,6 +35,7 @@ int main(void)
 	ENTRY(addr_limit);
 	ENTRY(preempt_count);
 	ENTRY(status);
+	ENTRY(syscall_count);
 	BLANK();
 #undef ENTRY
 #define ENTRY(entry) DEFINE(pda_ ## entry, offsetof(struct x8664_pda, entry))
diff --git a/arch/x86_64/kernel/entry.S b/arch/x86_64/kernel/entry.S
index 9f5dac6..af40ead 100644
--- a/arch/x86_64/kernel/entry.S
+++ b/arch/x86_64/kernel/entry.S
@@ -229,6 +229,9 @@ ENTRY(system_call)
 	movq  %rcx,RIP-ARGOFFSET(%rsp)
 	CFI_REL_OFFSET rip,RIP-ARGOFFSET
 	GET_THREAD_INFO(%rcx)
+#ifdef CONFIG_TASKSTATS
+	addq $1, threadinfo_syscall_count(%rcx)   # Increment syscalls counter
+#endif
 	testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%rcx)
 	jnz tracesys
 	cmpq $__NR_syscall_max,%rax
diff --git a/fs/proc/array.c b/fs/proc/array.c
index 70e4fab..c805c08 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -290,6 +290,19 @@ static inline char *task_cap(struct task_struct *p, char *buffer)
 			    cap_t(p->cap_permitted),
 			    cap_t(p->cap_effective));
 }
+static inline char *task_perf(struct task_struct *p, char *buffer)
+{
+	/* Syscall counter adds 1 line overhead on each syscall execution
+	 * in entry.S, so probably it is the leave this stuff under ifdefs.
+	 */
+#ifdef CONFIG_TASKSTATS
+	buffer += sprintf(buffer, "Syscalls:\t%lu\n", p->thread_info->syscall_count);
+#endif
+	return buffer + sprintf(buffer, "voluntary_ctxt_switches:\t%lu\n"
+			    "nonvoluntary_ctxt_switches:\t%lu\n",
+			    p->nvcsw,
+			    p->nivcsw);
+}
 
 int proc_pid_status(struct task_struct *task, char * buffer)
 {
@@ -309,6 +322,7 @@ int proc_pid_status(struct task_struct *task, char * buffer)
 #if defined(CONFIG_S390)
 	buffer = task_show_regs(task, buffer);
 #endif
+	buffer = task_perf(task, buffer);
 	return buffer - orig;
 }
 
diff --git a/include/asm-i386/thread_info.h b/include/asm-i386/thread_info.h
index 4b187bb..bccfd6a 100644
--- a/include/asm-i386/thread_info.h
+++ b/include/asm-i386/thread_info.h
@@ -33,6 +33,7 @@ struct thread_info {
 	int			preempt_count;	/* 0 => preemptable, <0 => BUG */
 
 
+	unsigned long		syscall_count;	/* Syscall counter */
 	mm_segment_t		addr_limit;	/* thread address space:
 					 	   0-0xBFFFFFFF for user-thead
 						   0-0xFFFFFFFF for kernel-thread
diff --git a/include/asm-powerpc/thread_info.h b/include/asm-powerpc/thread_info.h
index 3f32ca8..5306ac2 100644
--- a/include/asm-powerpc/thread_info.h
+++ b/include/asm-powerpc/thread_info.h
@@ -35,6 +35,7 @@ struct thread_info {
 	int		cpu;			/* cpu we're on */
 	int		preempt_count;		/* 0 => preemptable,
 						   <0 => BUG */
+	unsigned long	syscall_count;		/* Syscall counter */
 	struct restart_block restart_block;
 	unsigned long	local_flags;		/* private flags for thread */
 
diff --git a/include/asm-x86_64/thread_info.h b/include/asm-x86_64/thread_info.h
index 74a6c74..e53022d 100644
--- a/include/asm-x86_64/thread_info.h
+++ b/include/asm-x86_64/thread_info.h
@@ -31,6 +31,7 @@ struct thread_info {
 	__u32			cpu;		/* current CPU */
 	int 			preempt_count;	/* 0 => preemptable, <0 => BUG */
 
+	unsigned long		syscall_count;	/* Syscall counter */
 	mm_segment_t		addr_limit;	
 	struct restart_block    restart_block;
 };
diff --git a/include/linux/taskstats.h b/include/linux/taskstats.h
index 3fced47..98dfde7 100644
--- a/include/linux/taskstats.h
+++ b/include/linux/taskstats.h
@@ -31,7 +31,7 @@
  */
 
 
-#define TASKSTATS_VERSION	3
+#define TASKSTATS_VERSION	4
 #define TS_COMM_LEN		32	/* should be >= TASK_COMM_LEN
 					 * in linux/sched.h */
 
@@ -141,6 +141,10 @@ struct taskstats {
 	__u64	write_syscalls;		/* write syscalls */
 	/* Extended accounting fields end */
 
+	__u64  syscall_counter;		/* Syscall counter */
+	__u64  nvcsw;
+	__u64  nivcsw;
+
 #define TASKSTATS_HAS_IO_ACCOUNTING
 	/* Per-task storage I/O accounting starts */
 	__u64	read_bytes;		/* bytes of read I/O */
diff --git a/kernel/fork.c b/kernel/fork.c
index fc723e5..5213738 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1042,6 +1042,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
 	p->wchar = 0;		/* I/O counter: bytes written */
 	p->syscr = 0;		/* I/O counter: read syscalls */
 	p->syscw = 0;		/* I/O counter: write syscalls */
+#ifdef CONFIG_TASKSTATS
+	p->thread_info->syscall_count = 0; /* Syscall counter: total numbers of syscalls */
+#endif
 	task_io_accounting_init(p);
 	acct_clear_integrals(p);
 
diff --git a/kernel/taskstats.c b/kernel/taskstats.c
index 4c3476f..d7bf33f 100644
--- a/kernel/taskstats.c
+++ b/kernel/taskstats.c
@@ -196,6 +196,9 @@ static int fill_pid(pid_t pid, struct task_struct *tsk,
 
 	/* fill in basic acct fields */
 	stats->version = TASKSTATS_VERSION;
+	stats->syscall_counter = tsk->thread_info->syscall_count;
+	stats->nvcsw = tsk->nvcsw;
+	stats->nivcsw = tsk->nivcsw;
 	bacct_add_tsk(stats, tsk);
 
 	/* fill in extended acct fields */
@@ -242,6 +245,9 @@ static int fill_tgid(pid_t tgid, struct task_struct *first,
 		 */
 		delayacct_add_tsk(stats, tsk);
 
+		stats->syscall_counter += tsk->thread_info->syscall_count;
+		stats->nvcsw += tsk->nvcsw;
+		stats->nivcsw += tsk->nivcsw;
 	} while_each_thread(first, tsk);
 
 	unlock_task_sighand(first, &flags);

^ permalink raw reply related

* Re: [PATCH] Performance Stats: Kernel patch
From: Maxim Uvarov @ 2007-05-11 16:51 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linuxppc-dev, wli, pavel, dada1
In-Reply-To: <20070510111242.dd42adae.akpm@linux-foundation.org>

Andrew Morton wrote:

>
>What I meant was: the code appears to be counting sysenter-invoked syscalls,
>but it isn't counting not int 80-invoked syscalls.
>
>  
>
You are right. Seems it should be added too.

^ permalink raw reply

* Re: [PATCH v3] 83xx USB platform code rework
From: Stephen Rothwell @ 2007-05-11 12:13 UTC (permalink / raw)
  To: Li Yang; +Cc: linuxppc-dev, Paul
In-Reply-To: <46445455.608@freescale.com>

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

On Fri, 11 May 2007 19:32:37 +0800 Li Yang <leoli@freescale.com> wrote:
>
> +	if ((np = of_find_compatible_node(NULL, "usb", "fsl-usb2-dr"))
> +				!= NULL) {

Normally we like to separate the assignment from the test.  There are a
couple of other places like this.

> +		} else if (prop && !strcmp(prop, "serial")) {
> +			if (!strcmp(of_get_property(np, "dr_mode", NULL), "otg")) {
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Is there any chance that np doesn't have a "dr_mode" property?

> +#ifdef CONFIG_USB_OTG
> +		/* Set OTG_PORT */
> +		if (!strcmp(of_get_property(np, "dr_mode", NULL), "otg"))
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Again.

--
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply

* [PATCH v3] 83xx USB platform code rework
From: Li Yang @ 2007-05-11 11:32 UTC (permalink / raw)
  To: Paul; +Cc: sfr, linuxppc-dev

Add 831x USB platform setup code and rework 834x USB
platform setup code.  Move USB platform code to usb.c
for different boards with CPU of the same series to share
the USB initialization code.

Signed-off-by: Li Yang <leoli@freescale.com>
Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
Change to use of_get_property instead of get_property.

 arch/powerpc/platforms/83xx/Kconfig       |    2 +
 arch/powerpc/platforms/83xx/Makefile      |    2 +-
 arch/powerpc/platforms/83xx/mpc8313_rdb.c |    1 +
 arch/powerpc/platforms/83xx/mpc834x_mds.c |   49 +-------
 arch/powerpc/platforms/83xx/mpc83xx.h     |   28 ++++-
 arch/powerpc/platforms/83xx/usb.c         |  175 +++++++++++++++++++++++++++++
 6 files changed, 209 insertions(+), 48 deletions(-)
 create mode 100644 arch/powerpc/platforms/83xx/usb.c

diff --git a/arch/powerpc/platforms/83xx/Kconfig b/arch/powerpc/platforms/83xx/Kconfig
index 713b31a..9cb4d88 100644
--- a/arch/powerpc/platforms/83xx/Kconfig
+++ b/arch/powerpc/platforms/83xx/Kconfig
@@ -51,6 +51,7 @@ config PPC_MPC831x
 	bool
 	select PPC_UDBG_16550
 	select PPC_INDIRECT_PCI
+	select USB_EHCI_FSL
 	default y if MPC8313_RDB
 
 config PPC_MPC832x
@@ -63,6 +64,7 @@ config MPC834x
 	bool
 	select PPC_UDBG_16550
 	select PPC_INDIRECT_PCI
+	select USB_EHCI_FSL
 	default y if MPC834x_MDS || MPC834x_ITX
 
 config PPC_MPC836x
diff --git a/arch/powerpc/platforms/83xx/Makefile b/arch/powerpc/platforms/83xx/Makefile
index dfc970d..77712cb 100644
--- a/arch/powerpc/platforms/83xx/Makefile
+++ b/arch/powerpc/platforms/83xx/Makefile
@@ -1,7 +1,7 @@
 #
 # Makefile for the PowerPC 83xx linux kernel.
 #
-obj-y				:= misc.o
+obj-y				:= misc.o usb.o
 obj-$(CONFIG_PCI)		+= pci.o
 obj-$(CONFIG_MPC8313_RDB)	+= mpc8313_rdb.o
 obj-$(CONFIG_MPC834x_MDS)	+= mpc834x_mds.o
diff --git a/arch/powerpc/platforms/83xx/mpc8313_rdb.c b/arch/powerpc/platforms/83xx/mpc8313_rdb.c
index 96970ac..a404910 100644
--- a/arch/powerpc/platforms/83xx/mpc8313_rdb.c
+++ b/arch/powerpc/platforms/83xx/mpc8313_rdb.c
@@ -53,6 +53,7 @@ static void __init mpc8313_rdb_setup_arch(void)
 
 	ppc_md.pci_exclude_device = mpc83xx_exclude_device;
 #endif
+	mpc831x_usb_cfg();
 }
 
 void __init mpc8313_rdb_init_IRQ(void)
diff --git a/arch/powerpc/platforms/83xx/mpc834x_mds.c b/arch/powerpc/platforms/83xx/mpc834x_mds.c
index 10394b2..28b3840 100644
--- a/arch/powerpc/platforms/83xx/mpc834x_mds.c
+++ b/arch/powerpc/platforms/83xx/mpc834x_mds.c
@@ -44,55 +44,16 @@ unsigned long isa_mem_base = 0;
 #endif
 
 #define BCSR5_INT_USB		0x02
-/* Note: This is only for PB, not for PB+PIB
- * On PB only port0 is connected using ULPI */
-static int mpc834x_usb_cfg(void)
+static int mpc834xemds_usb_cfg(void)
 {
-	unsigned long sccr, sicrl;
-	void __iomem *immap;
+	struct device_node *np;
 	void __iomem *bcsr_regs = NULL;
 	u8 bcsr5;
-	struct device_node *np = NULL;
-	int port0_is_dr = 0;
-
-	if ((np = of_find_compatible_node(NULL, "usb", "fsl-usb2-dr")) != NULL)
-		port0_is_dr = 1;
-	if ((np = of_find_compatible_node(NULL, "usb", "fsl-usb2-mph")) != NULL){
-		if (port0_is_dr) {
-			printk(KERN_WARNING
-				"There is only one USB port on PB board! \n");
-			return -1;
-		} else if (!port0_is_dr)
-			/* No usb port enabled */
-			return -1;
-	}
-
-	immap = ioremap(get_immrbase(), 0x1000);
-	if (!immap)
-		return -1;
-
-	/* Configure clock */
-	sccr = in_be32(immap + MPC83XX_SCCR_OFFS);
-	if (port0_is_dr)
-		sccr |= MPC83XX_SCCR_USB_DRCM_11;  /* 1:3 */
-	else
-		sccr |= MPC83XX_SCCR_USB_MPHCM_11; /* 1:3 */
-	out_be32(immap + MPC83XX_SCCR_OFFS, sccr);
-
-	/* Configure Pin */
-	sicrl = in_be32(immap + MPC83XX_SICRL_OFFS);
-	/* set port0 only */
-	if (port0_is_dr)
-		sicrl |= MPC83XX_SICRL_USB0;
-	else
-		sicrl &= ~(MPC83XX_SICRL_USB0);
-	out_be32(immap + MPC83XX_SICRL_OFFS, sicrl);
-
-	iounmap(immap);
 
+	mpc834x_usb_cfg();
 	/* Map BCSR area */
 	np = of_find_node_by_name(NULL, "bcsr");
-	if (np != 0) {
+	if (np) {
 		struct resource res;
 
 		of_address_to_resource(np, 0, &res);
@@ -134,7 +95,7 @@ static void __init mpc834x_mds_setup_arch(void)
 	ppc_md.pci_exclude_device = mpc83xx_exclude_device;
 #endif
 
-	mpc834x_usb_cfg();
+	mpc834xemds_usb_cfg();
 }
 
 static void __init mpc834x_mds_init_IRQ(void)
diff --git a/arch/powerpc/platforms/83xx/mpc83xx.h b/arch/powerpc/platforms/83xx/mpc83xx.h
index 9cd03b5..a44e5b1 100644
--- a/arch/powerpc/platforms/83xx/mpc83xx.h
+++ b/arch/powerpc/platforms/83xx/mpc83xx.h
@@ -6,6 +6,7 @@
 
 /* System Clock Control Register */
 #define MPC83XX_SCCR_OFFS          0xA08
+#define MPC83XX_SCCR_USB_MASK      0x00f00000
 #define MPC83XX_SCCR_USB_MPHCM_11  0x00c00000
 #define MPC83XX_SCCR_USB_MPHCM_01  0x00400000
 #define MPC83XX_SCCR_USB_MPHCM_10  0x00800000
@@ -15,12 +16,31 @@
 
 /* system i/o configuration register low */
 #define MPC83XX_SICRL_OFFS         0x114
-#define MPC83XX_SICRL_USB0         0x40000000
-#define MPC83XX_SICRL_USB1         0x20000000
+#define MPC834X_SICRL_USB_MASK     0x60000000
+#define MPC834X_SICRL_USB0         0x40000000
+#define MPC834X_SICRL_USB1         0x20000000
+#define MPC831X_SICRL_USB_MASK     0x00000c00
+#define MPC831X_SICRL_USB_ULPI     0x00000800
 
 /* system i/o configuration register high */
 #define MPC83XX_SICRH_OFFS         0x118
-#define MPC83XX_SICRH_USB_UTMI     0x00020000
+#define MPC834X_SICRH_USB_UTMI     0x00020000
+#define MPC831X_SICRH_USB_MASK     0x000000e0
+#define MPC831X_SICRH_USB_ULPI     0x000000a0
+
+/* USB Control Register */
+#define FSL_USB2_CONTROL_OFFS      0x500
+#define CONTROL_UTMI_PHY_EN        0x00000200
+#define CONTROL_REFSEL_48MHZ       0x00000080
+#define CONTROL_PHY_CLK_SEL_ULPI   0x00000400
+#define CONTROL_OTG_PORT           0x00000020
+
+/* USB PORTSC Registers */
+#define FSL_USB2_PORTSC1_OFFS      0x184
+#define FSL_USB2_PORTSC2_OFFS      0x188
+#define PORTSCX_PTW_16BIT          0x10000000
+#define PORTSCX_PTS_UTMI           0x00000000
+#define PORTSCX_PTS_ULPI           0x80000000
 
 /*
  * Declaration for the various functions exported by the
@@ -31,5 +51,7 @@ extern int add_bridge(struct device_node *dev);
 extern int mpc83xx_exclude_device(u_char bus, u_char devfn);
 extern void mpc83xx_restart(char *cmd);
 extern long mpc83xx_time_init(void);
+extern int mpc834x_usb_cfg(void);
+extern int mpc831x_usb_cfg(void);
 
 #endif				/* __MPC83XX_H__ */
diff --git a/arch/powerpc/platforms/83xx/usb.c b/arch/powerpc/platforms/83xx/usb.c
new file mode 100644
index 0000000..f80fc5a
--- /dev/null
+++ b/arch/powerpc/platforms/83xx/usb.c
@@ -0,0 +1,175 @@
+/*
+ * Freescale 83xx USB SOC setup code
+ *
+ * Copyright (C) 2007 Freescale Semiconductor, Inc.
+ * Author: Li Yang
+ *
+ * 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/stddef.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+
+#include <asm/io.h>
+#include <asm/prom.h>
+#include <sysdev/fsl_soc.h>
+
+#include "mpc83xx.h"
+
+
+#ifdef CONFIG_MPC834x
+int mpc834x_usb_cfg(void)
+{
+	unsigned long sccr, sicrl, sicrh;
+	void __iomem *immap;
+	struct device_node *np = NULL;
+	int port0_is_dr = 0, port1_is_dr = 0;
+	const void *prop;
+
+	immap = ioremap(get_immrbase(), 0x1000);
+	if (!immap)
+		return -ENOMEM;
+
+	/* Read registers */
+	/* Note: DR and MPH must use the same clock setting in SCCR */
+	sccr = in_be32(immap + MPC83XX_SCCR_OFFS) & ~MPC83XX_SCCR_USB_MASK;
+	sicrl = in_be32(immap + MPC83XX_SICRL_OFFS) & ~MPC834X_SICRL_USB_MASK;
+	sicrh = in_be32(immap + MPC83XX_SICRH_OFFS) & ~MPC834X_SICRH_USB_UTMI;
+
+	if ((np = of_find_compatible_node(NULL, "usb", "fsl-usb2-dr"))
+				!= NULL) {
+		sccr |= MPC83XX_SCCR_USB_DRCM_11;  /* 1:3 */
+
+		prop = of_get_property(np, "phy_type", NULL);
+		if (prop && (!strcmp(prop, "utmi") ||
+					!strcmp(prop, "utmi_wide"))) {
+			sicrl |= MPC834X_SICRL_USB0 | MPC834X_SICRL_USB1;
+			sicrh |= MPC834X_SICRH_USB_UTMI;
+			port1_is_dr = 1;
+		} else if (prop && !strcmp(prop, "serial")) {
+			if (!strcmp(of_get_property(np, "dr_mode", NULL), "otg")) {
+				sicrl |= MPC834X_SICRL_USB0 | MPC834X_SICRL_USB1;
+				port1_is_dr = 1;
+			} else {
+				sicrl |= MPC834X_SICRL_USB0;
+			}
+		} else if (prop && !strcmp(prop, "ulpi")) {
+			sicrl |= MPC834X_SICRL_USB0;
+		} else {
+			printk(KERN_WARNING "834x USB PHY type not supported\n");
+		}
+		port0_is_dr = 1;
+		of_node_put(np);
+	}
+	if ((np = of_find_compatible_node(NULL, "usb", "fsl-usb2-mph"))
+				!= NULL) {
+		sccr |= MPC83XX_SCCR_USB_MPHCM_11; /* 1:3 */
+
+		prop = of_get_property(np, "port0", NULL);
+		if (prop) {
+			if (port0_is_dr)
+				printk(KERN_WARNING
+					"834x USB port0 can't be used by both DR and MPH!\n");
+			sicrl |= MPC834X_SICRL_USB0;
+		}
+		prop = of_get_property(np, "port1", NULL);
+		if (prop) {
+			if (port1_is_dr)
+				printk(KERN_WARNING
+					"834x USB port1 can't be used by both DR and MPH!\n");
+			sicrl |= MPC834X_SICRL_USB1;
+		}
+		of_node_put(np);
+	}
+
+	/* Write back */
+	out_be32(immap + MPC83XX_SCCR_OFFS, sccr);
+	out_be32(immap + MPC83XX_SICRL_OFFS, sicrl);
+	out_be32(immap + MPC83XX_SICRH_OFFS, sicrh);
+
+	iounmap(immap);
+	return 0;
+}
+#endif /* CONFIG_MPC834x */
+
+#ifdef CONFIG_PPC_MPC831x
+int mpc831x_usb_cfg(void)
+{
+	u32 temp;
+	void __iomem *immap, *usb_regs;
+	struct device_node *np = NULL;
+	const void *prop;
+	struct resource res;
+	int ret = 0;
+
+	if ((np = of_find_compatible_node(NULL, "usb", "fsl-usb2-dr")) == NULL)
+		return -ENODEV;
+	prop = of_get_property(np, "phy_type", NULL);
+
+	/* Map IMMR space for pin and clock settings */
+	immap = ioremap(get_immrbase(), 0x1000);
+	if (!immap) {
+		of_node_put(np);
+		return -ENOMEM;
+	}
+
+	/* Configure clock */
+	temp = in_be32(immap + MPC83XX_SCCR_OFFS);
+	temp &= ~MPC83XX_SCCR_USB_MASK;
+	temp |= MPC83XX_SCCR_USB_DRCM_11;  /* 1:3 */
+	out_be32(immap + MPC83XX_SCCR_OFFS, temp);
+
+	/* Configure pin mux for ULPI.  There is no pin mux for UTMI */
+	if (!strcmp(prop, "ulpi")) {
+		temp = in_be32(immap + MPC83XX_SICRL_OFFS);
+		temp &= ~MPC831X_SICRL_USB_MASK;
+		temp |= MPC831X_SICRL_USB_ULPI;
+		out_be32(immap + MPC83XX_SICRL_OFFS, temp);
+
+		temp = in_be32(immap + MPC83XX_SICRH_OFFS);
+		temp &= ~MPC831X_SICRH_USB_MASK;
+		temp |= MPC831X_SICRH_USB_ULPI;
+		out_be32(immap + MPC83XX_SICRH_OFFS, temp);
+	}
+
+	iounmap(immap);
+
+	/* Map USB SOC space */
+	ret = of_address_to_resource(np, 0, &res);
+	if (ret) {
+		of_node_put(np);
+		return ret;
+	}
+	usb_regs = ioremap(res.start, res.end - res.start + 1);
+
+	/* Using on-chip PHY */
+	if (!strcmp(prop, "utmi_wide") ||
+			!strcmp(prop, "utmi")) {
+		/* Set UTMI_PHY_EN, REFSEL to 48MHZ */
+		out_be32(usb_regs + FSL_USB2_CONTROL_OFFS,
+				CONTROL_UTMI_PHY_EN | CONTROL_REFSEL_48MHZ);
+	/* Using external UPLI PHY */
+	} else if (!strcmp(prop, "ulpi")) {
+		/* Set PHY_CLK_SEL to ULPI */
+		temp = CONTROL_PHY_CLK_SEL_ULPI;
+#ifdef CONFIG_USB_OTG
+		/* Set OTG_PORT */
+		if (!strcmp(of_get_property(np, "dr_mode", NULL), "otg"))
+			temp |= CONTROL_OTG_PORT;
+#endif /* CONFIG_USB_OTG */
+		out_be32(usb_regs + FSL_USB2_CONTROL_OFFS, temp);
+	} else {
+		printk(KERN_WARNING "831x USB PHY type not supported\n");
+		ret = -EINVAL;
+	}
+
+	iounmap(usb_regs);
+	of_node_put(np);
+	return ret;
+}
+#endif /* CONFIG_PPC_MPC831x */

^ permalink raw reply related

* RE: zImage.elf loads but does not start
From: Mirek23 @ 2007-05-11 11:21 UTC (permalink / raw)
  To: linuxppc-embedded
In-Reply-To: <D1AFFAE2CC4BD54CA4C1543CFF4A4FCC2F391B@exchangemb3.bnl.gov>


Hi Joe,

      Thank you very much for your e-mail. I did similar thing as you.
I have prepared simple init program to substitute one in /sbin :

#include <stdio.h>
#include <unistd.h>

int main(int argc, char *argv[])
{
    char myStr[30];

    printf("Enter the string!\n");
    gets(myStr);
    printf("My string is %s\n",myStr);
    sleep(60);
}

When I booted the kernel I have got a prompted "Enter the string!"
I was also able to type from the keyboard the string.
When I pressed ENTER I have got "My string is <the string I have typed>"

It seems to be that the console works fine and the root file system is
mounted properly via NFS.
I do not however understand why eldk4.1 init does not work.

I have reinstalled the eldk4.1 but still kernel boots to the point when it
executes the init.

I have tried to build the busybox and i have it installed in the place of
/opt/eldk41/ppc_4xx .
I have added to the ppc_4xx directory the dev/console.

When I rebooted the kernel it said that init was not found. I made sure that
init was pointing to ../bin/busybox
I have even copied busybox binary in place of init to have init as a regular
file but each time kernel was complaining that init is missing. Strange :(

Would you or somebody else recommend me the way how to build the root file
system which I could use for my ppc board.

Best Regards

Mirek




Mead, Joseph wrote:
> 
> Hi Mirek,
> 
> I am facing the same exact problem.   I am using the ML403 with standard
> UART but using initramfs to generate the root file system.   My root
> file system contains the /dev/console node and a simple init file that
> basically just tries to print out something.   I can tell it is finding
> my /dev/console because I don't get the kernel warning : "Unable to open
> an initial console"   (If I remove the /dev/console node I get the
> warning) 
> 
> My init program is just a simple hello world program (built statically)
> 
> printf("Hello World")
> sleep(10)
> 
> I can tell that the program is running because after exactly 10seconds I
> get a kernel panic, which indicates the end of the program, however I
> can never see any messages from user space.
> 
> 
> I also tried a statically built version of busybox as my init file but
> still get no output.
> 
> 
> my filesystem is built from the following file (using initramfs
> functionality, which creates the root file system from this file)
> 
> dir /dev 755 0 0
> nod /dev/console 644 0 0 c 5 1
> nod /dev/ttyS0   644 0 0 c 4 64
> dir /proc 755 0 0
> dir /sys 755 0 0
> file /init usr/busybox 755 0 0
> 
> 
> I received one bit of information to check my interrrupt lines, but I
> see Grant replied that the serial console is polled, so the interrupt
> line is probably not the problem.
> 
> 
> Please let me know if you make any progress...
> Joe
> 
> 
>  
> 
> -----Original Message-----
> From: linuxppc-embedded-bounces+mead=bnl.gov@ozlabs.org
> [mailto:linuxppc-embedded-bounces+mead=bnl.gov@ozlabs.org] On Behalf Of
> Mirek23
> Sent: Thursday, May 10, 2007 4:45 AM
> To: linuxppc-embedded@ozlabs.org
> Subject: RE: zImage.elf loads but does not start
> 
> 
> Thank you for all of the advices.
> I did more study on that problem but still without the success.
> 
> 1. I did redd the ELDK manual and I have invoked :
> ELDK_FIXOWNER
> ELDK_MAKEDEV
> 
> in the "dev" directory there were created many nodes like that:
> 
> crw-rw-rw-    1 root     root       5,   1 May  8 15:42 console
> crw-rw-rw-    1 root     root       4,  64 May  8 15:42 ttyS0
> 
> In the kernel command line configuration I have the entry :
> CONFIG_CMDLINE="console=ttyUL0,9600 root=/dev/nfs rw nfsroo ...
> 
> so I have created by hand the node:
> crw-rw-rw-    1 root     root     204, 187 May  8 15:44 ttyUL0
> 
> Unfortunately the kernel boots to the point:
> 
> [    9.130834] Looking up port of RPC 100003/2 on 129.129.130.106
> [    9.207363] Looking up port of RPC 100005/1 on 129.129.130.106
> [    9.303794] VFS: Mounted root (nfs filesystem).
> [    9.359316] Freeing unused kernel memory: 96k init
> 
> and after that it hangs.
> 
> I have made some modifications to the kernel init/main.c file. In that
> file I have inserted the printk statements to see how far the kernel
> goes. It seems to be that the last thing it does it executes the
> sbin/init command and it hangs.
> 
> Instead of the sbin/init I have tried to execute other commands like
> bin/echo this_is_text_string and bin/echo this_is_test >>
> /var/log/messages
> 
> the modification looks like (init/main.c):
> before modification:
>         printk("test 3\n");
>         run_init_process("/sbin/init");
>         printk("test 4\n");
> after modification
>         printk("test 3\n");
>         run_init_process("/bin/echo ala");
>         run_init_process("/bin/echo buba >> /var/log/messages");
>         printk("test 4\n");
> 
> 
> 
> In both cases the last thing which was printed is "test 3"
> The /var/log/messages remains empty.
> 
> I thought that it might be the uart_lite driver is the source of the
> problem. I rebuild the kernel configuring it for the standard UART
> driver instead of the uart_lite.
> This time my command line looks like:
> CONFIG_CMDLINE="console=ttyS0,9600 root=/dev/nfs rw nfsroo ...
> 
> When booting the kernel configured with the UART  I see anything printed
> on the screen so it is even worse than before.
> 
> Do you have any suggestions.
> 
> Best Regards
> 
> Mirek
> 
> 
> 
> Charles Krinke wrote:
>> 
>> I find this usually happens when /dev/tty, /dev/console or /dev/ttyS0 
>> are not setup properly. That is, they are files instead of nodes. This
> 
>> menas you have mounted the root filesystem and init is running on that
> 
>> root filesystem.
>> 
>> Charles
>> 
>> 
>> -----Original Message-----
>> From: linuxppc-embedded-bounces+ckrinke=istor.com@ozlabs.org
>> [mailto:linuxppc-embedded-bounces+ckrinke=istor.com@ozlabs.org] On 
>> Behalf Of Adrian Craine
>> Sent: Tuesday, May 08, 2007 2:50 PM
>> To: Leonid
>> Cc: linuxppc-embedded@ozlabs.org; Mirek23
>> Subject: Re: zImage.elf loads but does not start
>> 
>> Leonid wrote:
>>> rootpath=
>>> [    9.130834] Looking up port of RPC 100003/2 on 129.129.130.106
>>> [    9.207363] Looking up port of RPC 100005/1 on 129.129.130.106
>>> [    9.303794] VFS: Mounted root (nfs filesystem).
>>> [    9.359316] Freeing unused kernel memory: 96k init
>>> [    9.422162] Warning: unable to open an initial console.
>>>
>>>   
>> The exact device node this requires is /dev/console c 5 1 That should 
>> solve your issue.
>> 
>> Cheers,
>>              Adrian.
>> _______________________________________________
>> Linuxppc-embedded mailing list
>> Linuxppc-embedded@ozlabs.org
>> https://ozlabs.org/mailman/listinfo/linuxppc-embedded
>> _______________________________________________
>> Linuxppc-embedded mailing list
>> Linuxppc-embedded@ozlabs.org
>> https://ozlabs.org/mailman/listinfo/linuxppc-embedded
>> 
>> 
> 
> --
> View this message in context:
> http://www.nabble.com/zImage.elf-loads-but-not-starts-tf3607582.html#a10
> 409434
> Sent from the linuxppc-embedded mailing list archive at Nabble.com.
> 
> _______________________________________________
> Linuxppc-embedded mailing list
> Linuxppc-embedded@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-embedded
> _______________________________________________
> Linuxppc-embedded mailing list
> Linuxppc-embedded@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-embedded
> 
> 

-- 
View this message in context: http://www.nabble.com/zImage.elf-loads-but-not-starts-tf3607582.html#a10429898
Sent from the linuxppc-embedded mailing list archive at Nabble.com.

^ permalink raw reply

* Re: [PATCH v2] 83xx USB platform code rework
From: Stephen Rothwell @ 2007-05-11 11:04 UTC (permalink / raw)
  To: Li Yang; +Cc: linuxppc-dev, Paul
In-Reply-To: <464434CB.7020706@freescale.com>

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

On Fri, 11 May 2007 17:18:03 +0800 Li Yang <leoli@freescale.com> wrote:
>
> +
> +		prop = get_property(np, "phy_type", NULL);
                       ^^^^^^^^^^^^
get_property has been renamed ot of_get_property ...

--
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply

* Re: [PATCH] update sysfs kset initialisation in PPC64 DLPAR IO driver
From: Andy Whitcroft @ 2007-05-11 10:40 UTC (permalink / raw)
  To: michael
  Cc: Andrew Morton, Greg KH, linux-kernel, linuxppc-dev, paulus,
	Linus Torvalds
In-Reply-To: <1178870289.3923.6.camel@concordia.ozlabs.ibm.com>

Michael Ellerman wrote:
> On Fri, 2007-05-11 at 00:16 -0700, Greg KH wrote:
>> On Thu, May 10, 2007 at 04:54:41PM +0100, Andy Whitcroft wrote:
>>> Greg KH wrote:
>>>> On Thu, May 10, 2007 at 03:00:50PM +0100, Andy Whitcroft wrote:
>>>>> Move the rpadlpar device from "struct subsystem" to "struct kset"
>>>>> following the changes in sysfs.
>>>>>
>>>>> Signed-off-by: Andy Whitcroft <apw@shadowen.org>
>>>>> ---
>>>>>
>>>>> 	Ok, this patch seems to sort out the compile problem
>>>>> 	here and indeed boots and runs kernbench.  Perhaps
>>>>> 	you could confirm this is sufficient.
>>>> As per the discussion on the pci hotplug list, no, this doesn't seem to
>>>> fix the problem.  The developers there are looking into it.  If you can
>>>> test out patches for this, I'm sure the people there would appreciate
>>>> the help.
>>> Sure anything they have for testing, send them to me ...
>> They have the same patch that you made (I made it), yet they reported
>> that it didn't work properly for them.
>>
>> Can you test your patch out on "real" hardware?
> 
> I tested it on real hardware, but it can't hurt for Andy to try it too I
> guess.

To be fair I am not sure I have a clue how to test it.  Got a recipe?
My patch was based on how other drivers seemed to be converted which is
a concern for those drivers.

What sort of failure do you see?

-apw

^ permalink raw reply

* [PATCH v2] 83xx USB platform code rework
From: Li Yang @ 2007-05-11  9:18 UTC (permalink / raw)
  To: Paul; +Cc: linuxppc-dev

Add 831x USB platform setup code and rework 834x USB
platform setup code.  Move USB platform code to usb.c
for different boards with CPU of the same series to share
the USB initialization code.

Signed-off-by: Li Yang <leoli@freescale.com>
Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
Minor changes to address Kumar's comment.

 arch/powerpc/platforms/83xx/Kconfig       |    2 +
 arch/powerpc/platforms/83xx/Makefile      |    2 +-
 arch/powerpc/platforms/83xx/mpc8313_rdb.c |    1 +
 arch/powerpc/platforms/83xx/mpc834x_mds.c |   49 +-------
 arch/powerpc/platforms/83xx/mpc83xx.h     |   28 ++++-
 arch/powerpc/platforms/83xx/usb.c         |  176 +++++++++++++++++++++++++++++
 6 files changed, 210 insertions(+), 48 deletions(-)
 create mode 100644 arch/powerpc/platforms/83xx/usb.c

diff --git a/arch/powerpc/platforms/83xx/Kconfig b/arch/powerpc/platforms/83xx/Kconfig
index 713b31a..9cb4d88 100644
--- a/arch/powerpc/platforms/83xx/Kconfig
+++ b/arch/powerpc/platforms/83xx/Kconfig
@@ -51,6 +51,7 @@ config PPC_MPC831x
 	bool
 	select PPC_UDBG_16550
 	select PPC_INDIRECT_PCI
+	select USB_EHCI_FSL
 	default y if MPC8313_RDB
 
 config PPC_MPC832x
@@ -63,6 +64,7 @@ config MPC834x
 	bool
 	select PPC_UDBG_16550
 	select PPC_INDIRECT_PCI
+	select USB_EHCI_FSL
 	default y if MPC834x_MDS || MPC834x_ITX
 
 config PPC_MPC836x
diff --git a/arch/powerpc/platforms/83xx/Makefile b/arch/powerpc/platforms/83xx/Makefile
index dfc970d..77712cb 100644
--- a/arch/powerpc/platforms/83xx/Makefile
+++ b/arch/powerpc/platforms/83xx/Makefile
@@ -1,7 +1,7 @@
 #
 # Makefile for the PowerPC 83xx linux kernel.
 #
-obj-y				:= misc.o
+obj-y				:= misc.o usb.o
 obj-$(CONFIG_PCI)		+= pci.o
 obj-$(CONFIG_MPC8313_RDB)	+= mpc8313_rdb.o
 obj-$(CONFIG_MPC834x_MDS)	+= mpc834x_mds.o
diff --git a/arch/powerpc/platforms/83xx/mpc8313_rdb.c b/arch/powerpc/platforms/83xx/mpc8313_rdb.c
index 96970ac..a404910 100644
--- a/arch/powerpc/platforms/83xx/mpc8313_rdb.c
+++ b/arch/powerpc/platforms/83xx/mpc8313_rdb.c
@@ -53,6 +53,7 @@ static void __init mpc8313_rdb_setup_arch(void)
 
 	ppc_md.pci_exclude_device = mpc83xx_exclude_device;
 #endif
+	mpc831x_usb_cfg();
 }
 
 void __init mpc8313_rdb_init_IRQ(void)
diff --git a/arch/powerpc/platforms/83xx/mpc834x_mds.c b/arch/powerpc/platforms/83xx/mpc834x_mds.c
index 10394b2..28b3840 100644
--- a/arch/powerpc/platforms/83xx/mpc834x_mds.c
+++ b/arch/powerpc/platforms/83xx/mpc834x_mds.c
@@ -44,55 +44,16 @@ unsigned long isa_mem_base = 0;
 #endif
 
 #define BCSR5_INT_USB		0x02
-/* Note: This is only for PB, not for PB+PIB
- * On PB only port0 is connected using ULPI */
-static int mpc834x_usb_cfg(void)
+static int mpc834xemds_usb_cfg(void)
 {
-	unsigned long sccr, sicrl;
-	void __iomem *immap;
+	struct device_node *np;
 	void __iomem *bcsr_regs = NULL;
 	u8 bcsr5;
-	struct device_node *np = NULL;
-	int port0_is_dr = 0;
-
-	if ((np = of_find_compatible_node(NULL, "usb", "fsl-usb2-dr")) != NULL)
-		port0_is_dr = 1;
-	if ((np = of_find_compatible_node(NULL, "usb", "fsl-usb2-mph")) != NULL){
-		if (port0_is_dr) {
-			printk(KERN_WARNING
-				"There is only one USB port on PB board! \n");
-			return -1;
-		} else if (!port0_is_dr)
-			/* No usb port enabled */
-			return -1;
-	}
-
-	immap = ioremap(get_immrbase(), 0x1000);
-	if (!immap)
-		return -1;
-
-	/* Configure clock */
-	sccr = in_be32(immap + MPC83XX_SCCR_OFFS);
-	if (port0_is_dr)
-		sccr |= MPC83XX_SCCR_USB_DRCM_11;  /* 1:3 */
-	else
-		sccr |= MPC83XX_SCCR_USB_MPHCM_11; /* 1:3 */
-	out_be32(immap + MPC83XX_SCCR_OFFS, sccr);
-
-	/* Configure Pin */
-	sicrl = in_be32(immap + MPC83XX_SICRL_OFFS);
-	/* set port0 only */
-	if (port0_is_dr)
-		sicrl |= MPC83XX_SICRL_USB0;
-	else
-		sicrl &= ~(MPC83XX_SICRL_USB0);
-	out_be32(immap + MPC83XX_SICRL_OFFS, sicrl);
-
-	iounmap(immap);
 
+	mpc834x_usb_cfg();
 	/* Map BCSR area */
 	np = of_find_node_by_name(NULL, "bcsr");
-	if (np != 0) {
+	if (np) {
 		struct resource res;
 
 		of_address_to_resource(np, 0, &res);
@@ -134,7 +95,7 @@ static void __init mpc834x_mds_setup_arch(void)
 	ppc_md.pci_exclude_device = mpc83xx_exclude_device;
 #endif
 
-	mpc834x_usb_cfg();
+	mpc834xemds_usb_cfg();
 }
 
 static void __init mpc834x_mds_init_IRQ(void)
diff --git a/arch/powerpc/platforms/83xx/mpc83xx.h b/arch/powerpc/platforms/83xx/mpc83xx.h
index 9cd03b5..a44e5b1 100644
--- a/arch/powerpc/platforms/83xx/mpc83xx.h
+++ b/arch/powerpc/platforms/83xx/mpc83xx.h
@@ -6,6 +6,7 @@
 
 /* System Clock Control Register */
 #define MPC83XX_SCCR_OFFS          0xA08
+#define MPC83XX_SCCR_USB_MASK      0x00f00000
 #define MPC83XX_SCCR_USB_MPHCM_11  0x00c00000
 #define MPC83XX_SCCR_USB_MPHCM_01  0x00400000
 #define MPC83XX_SCCR_USB_MPHCM_10  0x00800000
@@ -15,12 +16,31 @@
 
 /* system i/o configuration register low */
 #define MPC83XX_SICRL_OFFS         0x114
-#define MPC83XX_SICRL_USB0         0x40000000
-#define MPC83XX_SICRL_USB1         0x20000000
+#define MPC834X_SICRL_USB_MASK     0x60000000
+#define MPC834X_SICRL_USB0         0x40000000
+#define MPC834X_SICRL_USB1         0x20000000
+#define MPC831X_SICRL_USB_MASK     0x00000c00
+#define MPC831X_SICRL_USB_ULPI     0x00000800
 
 /* system i/o configuration register high */
 #define MPC83XX_SICRH_OFFS         0x118
-#define MPC83XX_SICRH_USB_UTMI     0x00020000
+#define MPC834X_SICRH_USB_UTMI     0x00020000
+#define MPC831X_SICRH_USB_MASK     0x000000e0
+#define MPC831X_SICRH_USB_ULPI     0x000000a0
+
+/* USB Control Register */
+#define FSL_USB2_CONTROL_OFFS      0x500
+#define CONTROL_UTMI_PHY_EN        0x00000200
+#define CONTROL_REFSEL_48MHZ       0x00000080
+#define CONTROL_PHY_CLK_SEL_ULPI   0x00000400
+#define CONTROL_OTG_PORT           0x00000020
+
+/* USB PORTSC Registers */
+#define FSL_USB2_PORTSC1_OFFS      0x184
+#define FSL_USB2_PORTSC2_OFFS      0x188
+#define PORTSCX_PTW_16BIT          0x10000000
+#define PORTSCX_PTS_UTMI           0x00000000
+#define PORTSCX_PTS_ULPI           0x80000000
 
 /*
  * Declaration for the various functions exported by the
@@ -31,5 +51,7 @@ extern int add_bridge(struct device_node *dev);
 extern int mpc83xx_exclude_device(u_char bus, u_char devfn);
 extern void mpc83xx_restart(char *cmd);
 extern long mpc83xx_time_init(void);
+extern int mpc834x_usb_cfg(void);
+extern int mpc831x_usb_cfg(void);
 
 #endif				/* __MPC83XX_H__ */
diff --git a/arch/powerpc/platforms/83xx/usb.c b/arch/powerpc/platforms/83xx/usb.c
new file mode 100644
index 0000000..9ea65eb
--- /dev/null
+++ b/arch/powerpc/platforms/83xx/usb.c
@@ -0,0 +1,176 @@
+/*
+ * Freescale 83xx USB SOC setup code
+ *
+ * Copyright (C) 2007 Freescale Semiconductor, Inc.
+ * Author: Li Yang
+ *
+ * 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/stddef.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+
+#include <asm/io.h>
+#include <asm/prom.h>
+#include <sysdev/fsl_soc.h>
+
+#include "mpc83xx.h"
+
+
+#ifdef CONFIG_MPC834x
+int mpc834x_usb_cfg(void)
+{
+	unsigned long sccr, sicrl, sicrh;
+	void __iomem *immap;
+	struct device_node *np = NULL;
+	int port0_is_dr = 0, port1_is_dr = 0;
+	const void *prop;
+
+	immap = ioremap(get_immrbase(), 0x1000);
+	if (!immap)
+		return -ENOMEM;
+
+	/* Read registers */
+	/* Note: DR and MPH must use the same clock setting in SCCR */
+	sccr = in_be32(immap + MPC83XX_SCCR_OFFS) & ~MPC83XX_SCCR_USB_MASK;
+	sicrl = in_be32(immap + MPC83XX_SICRL_OFFS) & ~MPC834X_SICRL_USB_MASK;
+	sicrh = in_be32(immap + MPC83XX_SICRH_OFFS) & ~MPC834X_SICRH_USB_UTMI;
+
+	if ((np = of_find_compatible_node(NULL, "usb", "fsl-usb2-dr"))
+				!= NULL) {
+		sccr |= MPC83XX_SCCR_USB_DRCM_11;  /* 1:3 */
+
+		prop = get_property(np, "phy_type", NULL);
+		if (prop && (!strcmp(prop, "utmi") ||
+					!strcmp(prop, "utmi_wide"))) {
+			sicrl |= MPC834X_SICRL_USB0 | MPC834X_SICRL_USB1;
+			sicrh |= MPC834X_SICRH_USB_UTMI;
+			port1_is_dr = 1;
+		} else if (prop && !strcmp(prop, "serial")) {
+			if (!strcmp(get_property(np, "dr_mode", NULL), "otg")) {
+				sicrl |= MPC834X_SICRL_USB0 | MPC834X_SICRL_USB1;
+				port1_is_dr = 1;
+			} else {
+				sicrl |= MPC834X_SICRL_USB0;
+			}
+		} else if (prop && !strcmp(prop, "ulpi")) {
+			sicrl |= MPC834X_SICRL_USB0;
+		} else {
+			printk(KERN_WARNING "834x USB PHY type not supported\n");
+		}
+		port0_is_dr = 1;
+		of_node_put(np);
+	}
+	if ((np = of_find_compatible_node(NULL, "usb", "fsl-usb2-mph"))
+				!= NULL) {
+		sccr |= MPC83XX_SCCR_USB_MPHCM_11; /* 1:3 */
+
+		prop = get_property(np, "port0", NULL);
+		if (prop) {
+			if (port0_is_dr)
+				printk(KERN_WARNING
+					"834x USB port0 can't be used by both DR and MPH!\n");
+			sicrl |= MPC834X_SICRL_USB0;
+		}
+		prop = get_property(np, "port1", NULL);
+		if (prop) {
+			if (port1_is_dr)
+				printk(KERN_WARNING
+					"834x USB port1 can't be used by both DR and MPH!\n");
+			sicrl |= MPC834X_SICRL_USB1;
+		}
+		of_node_put(np);
+	}
+
+	/* Write back */
+	out_be32(immap + MPC83XX_SCCR_OFFS, sccr);
+	out_be32(immap + MPC83XX_SICRL_OFFS, sicrl);
+	out_be32(immap + MPC83XX_SICRH_OFFS, sicrh);
+
+	iounmap(immap);
+	return 0;
+}
+#endif /* CONFIG_MPC834x */
+
+#ifdef CONFIG_PPC_MPC831x
+int mpc831x_usb_cfg(void)
+{
+	u32 temp;
+	void __iomem *immap, *usb_regs;
+	struct device_node *np = NULL;
+	const void *prop;
+	struct resource res;
+	int ret = 0;
+
+	if ((np = of_find_compatible_node(NULL, "usb", "fsl-usb2-dr")) == NULL)
+		return -ENODEV;
+	prop = get_property(np, "phy_type", NULL);
+
+	/* Map IMMR space for pin and clock settings */
+	immap = ioremap(get_immrbase(), 0x1000);
+	if (!immap) {
+		of_node_put(np);
+		return -ENOMEM;
+	}
+
+	/* Configure clock */
+	temp = in_be32(immap + MPC83XX_SCCR_OFFS);
+	temp &= ~MPC83XX_SCCR_USB_MASK;
+	temp |= MPC83XX_SCCR_USB_DRCM_11;  /* 1:3 */
+	out_be32(immap + MPC83XX_SCCR_OFFS, temp);
+
+	/* Configure pin mux for ULPI.  There is no pin mux for UTMI */
+	if (!strcmp(prop, "ulpi")) {
+		temp = in_be32(immap + MPC83XX_SICRL_OFFS);
+		temp &= ~MPC831X_SICRL_USB_MASK;
+		temp |= MPC831X_SICRL_USB_ULPI;
+		out_be32(immap + MPC83XX_SICRL_OFFS, temp);
+
+		temp = in_be32(immap + MPC83XX_SICRH_OFFS);
+		temp &= ~MPC831X_SICRH_USB_MASK;
+		temp |= MPC831X_SICRH_USB_ULPI;
+		out_be32(immap + MPC83XX_SICRH_OFFS, temp);
+	}
+
+	iounmap(immap);
+
+	/* Map USB SOC space */
+	ret = of_address_to_resource(np, 0, &res);
+	if (ret) {
+		of_node_put(np);
+		return ret;
+	}
+	usb_regs = ioremap(res.start, res.end - res.start + 1);
+
+	/* Using on-chip PHY */
+	if (!strcmp(prop, "utmi_wide") ||
+			!strcmp(prop, "utmi")) {
+		/* Set UTMI_PHY_EN, REFSEL to 48MHZ */
+		out_be32(usb_regs + FSL_USB2_CONTROL_OFFS,
+				CONTROL_UTMI_PHY_EN | CONTROL_REFSEL_48MHZ);
+	/* Using external UPLI PHY */
+	} else if (!strcmp(prop, "ulpi")) {
+		/* Set PHY_CLK_SEL to ULPI */
+		temp = CONTROL_PHY_CLK_SEL_ULPI;
+#ifdef CONFIG_USB_OTG
+		if (!strcmp(get_property(np, "dr_mode", NULL), "otg")) {
+			/* Set OTG_PORT */
+			temp |= CONTROL_OTG_PORT;
+		}
+#endif /* CONFIG_USB_OTG */
+		out_be32(usb_regs + FSL_USB2_CONTROL_OFFS, temp);
+	} else {
+		printk(KERN_WARNING "831x USB PHY type not supported\n");
+		ret = -EINVAL;
+	}
+
+	iounmap(usb_regs);
+	of_node_put(np);
+	return ret;
+}
+#endif /* CONFIG_PPC_MPC831x */

^ permalink raw reply related

* Re: Fixed PHY problems
From: Joakim Tjernlund @ 2007-05-11  9:04 UTC (permalink / raw)
  To: Vitaly Bordug; +Cc: linuxppc-dev
In-Reply-To: <20070511120704.3e0377b7@localhost.localdomain>

On Fri, 2007-05-11 at 12:07 +0400, Vitaly Bordug wrote:
> On Thu, 10 May 2007 19:41:53 +0200
> Joakim Tjernlund wrote:
> 
> > Trying to boot todays linus tree with fixed PHY support enabled gets
> > me this: Fixed PHY: Registered new driver
> > Device 'fixed@100:1' does not have a release() function, it is broken
> > and must be fixed. ------------[ cut here ]------------
> > Badness at drivers/base/core.c:107
> > Call Trace:
> > [cffc1dc0] [c0008324] show_stack+0x48/0x194 (unreliable)
> > [cffc1df0] [c00f4a4c] report_bug+0x84/0xec
> > [cffc1e00] [c000dde8] program_check_exception+0x274/0x55c
> > [cffc1e20] [c000f770] ret_from_except_full+0x0/0x4c
> > --- Exception: 700 at device_release+0x54/0x90
> >     LR = device_release+0x54/0x90
> > [cffc1ef0] [c00f5e1c] kobject_cleanup+0xb4/0xb8
> > [cffc1f10] [c00f6ca0] kref_put+0x68/0x80
> > [cffc1f20] [c00f5d58] kobject_put+0x24/0x34
> > [cffc1f30] [c01150bc] put_device+0x1c/0x2c
> > [cffc1f40] [c0243a9c] fixed_init+0x1cc/0x210
> > [cffc1f60] [c022e828] kernel_init+0x8c/0x2b4
> > [cffc1ff0] [c000ff4c] kernel_thread+0x44/0x60
> > 
> > The other thing is, how do I specify a fixed PHY
> > in OF?
> > 
> I have a patch that  fixes it but was busy with other stuff because of merge window.
> Can send it to you meanwhile, going to deal with it after next rc released...

Please do, thanks.

Do you have any idea what needs to go into the DTS file to make my
832x(ucc_geth) find it?

^ permalink raw reply

* Re: [PATCH] i2c: adds support for i2c bus on 8xx
From: Jean Delvare @ 2007-05-11  8:12 UTC (permalink / raw)
  To: Vitaly Bordug; +Cc: linuxppc-dev, linux-kernel
In-Reply-To: <20070510143554.16c5df6a@localhost.localdomain>

Hi Vitaly,

On Thu, 10 May 2007 14:35:54 +0400, Vitaly Bordug wrote:
> On Thu, 10 May 2007 11:28:35 +0200 Jean Delvare wrote:
> > On Tue, 08 May 2007 10:31:31 +0400, Vitaly Bordug wrote:
> > > Interface has been reworked to of_device as well as other feedback
> > > addressed. Repeated start ability is missing from the
> > > implementation.
> > 
> > Did you check the hardware documentation? Is it a hardware limitation?
> > It is likely to cause problems, so it should be investigated, and if
> > it really cannot be fixed, then this must be clearly documented (in
> > Kconfig and in the driver) and the advertised functionalities  of the
> > driver should be reduced accordingly (most SMBus transactions include
> > a repeated start.)
>
> Yes, I've checked RM about I2C controller, and cannot find anything about repeated
> start. There are a few words about multi-master considerations, that SoC features bus arbitration,
> but to avoid collisions, "higher-level handshake protocol must be used" (MPC885 RM, p. 32-6).

After reading the MPC885 RM datasheet, I think the device supports
repeated start. I guess that you simply need to _only_ set the
BD_SC_LAST flag for the last message of the transaction, not all of
them as the driver does. If I am correct, this should be fairly easy to
fix. Please try, test and report.

> > > +static int cpm_iic_init(struct i2c_adapter *adap)
> > > +{
> > > (...)
> > > +	/* Initialize Tx/Rx parameters.
> > > +	 */
> > > +	if (cpm->reloc == 0) {
> > > +		cpm8xx_t *cp = cpm->cp;
> > > +		int res;
> > > +
> > > +		u16 v = mk_cr_cmd(CPM_CR_CH_I2C, CPM_CR_INIT_TRX) | CPM_CR_FLG;
> > > +
> > > +		out_be16(&cp->cp_cpcr, v);
> > > +		res = wait_event_timeout(iic_wait,
> > > +					 !(in_be16(&cp->cp_cpcr) & CPM_CR_FLG),
> > > +					 HZ * 10);
> > 
> > This is a pretty long timeout. Can it realistically take that long?
>
> In fact, it can. Especially when CPM is loaded with Ethernet/UART/Etc
> transactions. If you feel it is overkill and I2C shouldn't do that,
> I'll trim it down though.

No, if you think it's reasonable, fine with me.

-- 
Jean Delvare

^ permalink raw reply

* Re: Fixed PHY problems
From: Vitaly Bordug @ 2007-05-11  8:07 UTC (permalink / raw)
  To: joakim.tjernlund; +Cc: linuxppc-dev
In-Reply-To: <1178818913.20638.5.camel@gentoo-jocke.transmode.se>

On Thu, 10 May 2007 19:41:53 +0200
Joakim Tjernlund wrote:

> Trying to boot todays linus tree with fixed PHY support enabled gets
> me this: Fixed PHY: Registered new driver
> Device 'fixed@100:1' does not have a release() function, it is broken
> and must be fixed. ------------[ cut here ]------------
> Badness at drivers/base/core.c:107
> Call Trace:
> [cffc1dc0] [c0008324] show_stack+0x48/0x194 (unreliable)
> [cffc1df0] [c00f4a4c] report_bug+0x84/0xec
> [cffc1e00] [c000dde8] program_check_exception+0x274/0x55c
> [cffc1e20] [c000f770] ret_from_except_full+0x0/0x4c
> --- Exception: 700 at device_release+0x54/0x90
>     LR = device_release+0x54/0x90
> [cffc1ef0] [c00f5e1c] kobject_cleanup+0xb4/0xb8
> [cffc1f10] [c00f6ca0] kref_put+0x68/0x80
> [cffc1f20] [c00f5d58] kobject_put+0x24/0x34
> [cffc1f30] [c01150bc] put_device+0x1c/0x2c
> [cffc1f40] [c0243a9c] fixed_init+0x1cc/0x210
> [cffc1f60] [c022e828] kernel_init+0x8c/0x2b4
> [cffc1ff0] [c000ff4c] kernel_thread+0x44/0x60
> 
> The other thing is, how do I specify a fixed PHY
> in OF?
> 
I have a patch that  fixes it but was busy with other stuff because of merge window.
Can send it to you meanwhile, going to deal with it after next rc released...

>  Jocke
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev


-- 
Sincerely, Vitaly

^ permalink raw reply

* Re: [PATCH] update sysfs kset initialisation in PPC64 DLPAR IO driver
From: Michael Ellerman @ 2007-05-11  7:58 UTC (permalink / raw)
  To: Greg KH; +Cc: Andrew Morton, linux-kernel, linuxppc-dev, paulus, Linus Torvalds
In-Reply-To: <20070511071606.GB1211@suse.de>

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

On Fri, 2007-05-11 at 00:16 -0700, Greg KH wrote:
> On Thu, May 10, 2007 at 04:54:41PM +0100, Andy Whitcroft wrote:
> > Greg KH wrote:
> > > On Thu, May 10, 2007 at 03:00:50PM +0100, Andy Whitcroft wrote:
> > >> Move the rpadlpar device from "struct subsystem" to "struct kset"
> > >> following the changes in sysfs.
> > >>
> > >> Signed-off-by: Andy Whitcroft <apw@shadowen.org>
> > >> ---
> > >>
> > >> 	Ok, this patch seems to sort out the compile problem
> > >> 	here and indeed boots and runs kernbench.  Perhaps
> > >> 	you could confirm this is sufficient.
> > > 
> > > As per the discussion on the pci hotplug list, no, this doesn't seem to
> > > fix the problem.  The developers there are looking into it.  If you can
> > > test out patches for this, I'm sure the people there would appreciate
> > > the help.
> > 
> > Sure anything they have for testing, send them to me ...
> 
> They have the same patch that you made (I made it), yet they reported
> that it didn't work properly for them.
> 
> Can you test your patch out on "real" hardware?

I tested it on real hardware, but it can't hurt for Andy to try it too I
guess.

cheers

-- 
Michael Ellerman
OzLabs, IBM Australia Development Lab

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply

* Re: Fix Kconfig undefined symbol 'IBM_NEW_EMAC_ZMII'
From: Benjamin Herrenschmidt @ 2007-05-11  7:56 UTC (permalink / raw)
  To: Tony Breeds; +Cc: linuxppc-dev, David Gibson
In-Reply-To: <20070511070006.GF15955@bakeyournoodle.com>

On Fri, 2007-05-11 at 17:00 +1000, Tony Breeds wrote:
> Fix Kconfig undefined symbol 'IBM_NEW_EMAC_ZMII'
> 
> An allmodconfig on the current powerpc tree yields:
> arch/powerpc/platforms/44x/Kconfig:41:warning: 'select' used by config symbol '440GP' refers to undefined symbol 'IBM_NEW_EMAC_ZMII'
> 
> Remove the select until the driver exists.

Can you comment it out instead ?

Ben.

^ 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