Re: [uClinux-dev] m68k compile issue with 4.0.5

2015-06-18 Thread Greg Ungerer

Hi Waldemar,

On 17/06/15 15:42, Waldemar Brodkorb wrote:

Hi Greg,
Greg Ungerer wrote,

I don't have any compile (or runtime) problems with m5208evb_defconfig
on linux-4.0.5 either. That is close to what most people use with qemu.
What .config are you using?

Are you sure the defconfig creates a bootable image?

I still need at least two patches.

http://cgit.openadk.org/cgi/cgit/openadk.git/tree/target/m68k/qemu-m68k/patches/4.0.5/qemu-coldfire.patch
Without this one I get black screen.

http://cgit.openadk.org/cgi/cgit/openadk.git/tree/target/m68k/qemu-m68k/patches/4.0.5/m68k-coldfire-fec.patch
Without this one I get
qemu: hardware error: mcf_fec_read: Bad address 0x1c4
...
Abort

Networking still does not work for me after booting with the two
patches applied:
fec fec.0 (unnamed net_device) (uninitialized): MDIO read timeout
fec: probe of fec.0 failed with error -5

Any idea?


The qemu fec driver does not emulate any type of attached phy
or properly support the mdio read/write register.

The attached patch to qemu implements really simple phy support.
Was enough for me to get linux probing and finding a phy.

Regards
Greg

>From 0a949818b081261b8322da0bef4af92f0e379655 Mon Sep 17 00:00:00 2001
From: Greg Ungerer 
Date: Thu, 18 Jun 2015 23:27:13 +1000
Subject: [PATCH] m68k: add simple phy support to fec driver

The Linux fec driver needs at least basic PHY support to probe and work.

This code adds a very simple set of register results for a fixed PHY
setup - very similar to that used on an m5208evb board.

Signed-off-by: Greg Ungerer 
---
 hw/net/mcf_fec.c | 31 +--
 1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/hw/net/mcf_fec.c b/hw/net/mcf_fec.c
index 4bff3de..2df062f 100644
--- a/hw/net/mcf_fec.c
+++ b/hw/net/mcf_fec.c
@@ -216,6 +216,33 @@ static void mcf_fec_reset(mcf_fec_state *s)
 s->rfsr = 0x500;
 }
 
+#define MMFR_WRITE_OP	(1 << 28)
+#define MMFR_READ_OP	(2 << 28)
+#define MMFR_PHYADDR(v)	(((v) >> 23) & 0x1f)
+#define MMFR_REGNUM(v)	(((v) >> 18) & 0x1f)
+
+static uint64_t mcf_fec_read_mdio(mcf_fec_state *s)
+{
+	uint64_t v;
+
+	if (s->mmfr & MMFR_WRITE_OP)
+		return s->mmfr;
+	if (MMFR_PHYADDR(s->mmfr) != 1)
+		return s->mmfr |= 0x;
+
+	switch (MMFR_REGNUM(s->mmfr)) {
+	case 0x00: v = 0x3100; break;
+	case 0x01: v = 0x786d; break;
+	case 0x02: v = 0x2000; break;
+	case 0x03: v = 0x5c90; break;
+	case 0x04: v = 0x01e1; break;
+	case 0x05: v = 0xc1e1; break;
+	default: v = 0x ; break;
+	}
+	s->mmfr = (s->mmfr & ~0x) | v;
+	return s->mmfr;
+}
+
 static uint64_t mcf_fec_read(void *opaque, hwaddr addr,
  unsigned size)
 {
@@ -226,7 +253,7 @@ static uint64_t mcf_fec_read(void *opaque, hwaddr addr,
 case 0x010: return s->rx_enabled ? (1 << 24) : 0; /* RDAR */
 case 0x014: return 0; /* TDAR */
 case 0x024: return s->ecr;
-case 0x040: return s->mmfr;
+case 0x040: return mcf_fec_read_mdio(s);
 case 0x044: return s->mscr;
 case 0x064: return 0; /* MIBC */
 case 0x084: return s->rcr;
@@ -287,8 +314,8 @@ static void mcf_fec_write(void *opaque, hwaddr addr,
 }
 break;
 case 0x040:
-/* TODO: Implement MII.  */
 s->mmfr = value;
+	s->eir |= FEC_INT_MII;
 break;
 case 0x044:
 s->mscr = value & 0xfe;
-- 
1.9.1



Re: [uClinux-dev] m68k compile issue with 4.0.5

2015-06-18 Thread Greg Ungerer

Hi Waldemar,

On 17/06/15 15:42, Waldemar Brodkorb wrote:

Hi Greg,
Greg Ungerer wrote,

I don't have any compile (or runtime) problems with m5208evb_defconfig
on linux-4.0.5 either. That is close to what most people use with qemu.
What .config are you using?

Are you sure the defconfig creates a bootable image?

I still need at least two patches.

http://cgit.openadk.org/cgi/cgit/openadk.git/tree/target/m68k/qemu-m68k/patches/4.0.5/qemu-coldfire.patch
Without this one I get black screen.

http://cgit.openadk.org/cgi/cgit/openadk.git/tree/target/m68k/qemu-m68k/patches/4.0.5/m68k-coldfire-fec.patch
Without this one I get
qemu: hardware error: mcf_fec_read: Bad address 0x1c4
...
Abort

Networking still does not work for me after booting with the two
patches applied:
fec fec.0 (unnamed net_device) (uninitialized): MDIO read timeout
fec: probe of fec.0 failed with error -5

Any idea?


The qemu fec driver does not emulate any type of attached phy
or properly support the mdio read/write register.

The attached patch to qemu implements really simple phy support.
Was enough for me to get linux probing and finding a phy.

Regards
Greg

From 0a949818b081261b8322da0bef4af92f0e379655 Mon Sep 17 00:00:00 2001
From: Greg Ungerer g...@uclinux.org
Date: Thu, 18 Jun 2015 23:27:13 +1000
Subject: [PATCH] m68k: add simple phy support to fec driver

The Linux fec driver needs at least basic PHY support to probe and work.

This code adds a very simple set of register results for a fixed PHY
setup - very similar to that used on an m5208evb board.

Signed-off-by: Greg Ungerer g...@uclinux.org
---
 hw/net/mcf_fec.c | 31 +--
 1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/hw/net/mcf_fec.c b/hw/net/mcf_fec.c
index 4bff3de..2df062f 100644
--- a/hw/net/mcf_fec.c
+++ b/hw/net/mcf_fec.c
@@ -216,6 +216,33 @@ static void mcf_fec_reset(mcf_fec_state *s)
 s-rfsr = 0x500;
 }
 
+#define MMFR_WRITE_OP	(1  28)
+#define MMFR_READ_OP	(2  28)
+#define MMFR_PHYADDR(v)	(((v)  23)  0x1f)
+#define MMFR_REGNUM(v)	(((v)  18)  0x1f)
+
+static uint64_t mcf_fec_read_mdio(mcf_fec_state *s)
+{
+	uint64_t v;
+
+	if (s-mmfr  MMFR_WRITE_OP)
+		return s-mmfr;
+	if (MMFR_PHYADDR(s-mmfr) != 1)
+		return s-mmfr |= 0x;
+
+	switch (MMFR_REGNUM(s-mmfr)) {
+	case 0x00: v = 0x3100; break;
+	case 0x01: v = 0x786d; break;
+	case 0x02: v = 0x2000; break;
+	case 0x03: v = 0x5c90; break;
+	case 0x04: v = 0x01e1; break;
+	case 0x05: v = 0xc1e1; break;
+	default: v = 0x ; break;
+	}
+	s-mmfr = (s-mmfr  ~0x) | v;
+	return s-mmfr;
+}
+
 static uint64_t mcf_fec_read(void *opaque, hwaddr addr,
  unsigned size)
 {
@@ -226,7 +253,7 @@ static uint64_t mcf_fec_read(void *opaque, hwaddr addr,
 case 0x010: return s-rx_enabled ? (1  24) : 0; /* RDAR */
 case 0x014: return 0; /* TDAR */
 case 0x024: return s-ecr;
-case 0x040: return s-mmfr;
+case 0x040: return mcf_fec_read_mdio(s);
 case 0x044: return s-mscr;
 case 0x064: return 0; /* MIBC */
 case 0x084: return s-rcr;
@@ -287,8 +314,8 @@ static void mcf_fec_write(void *opaque, hwaddr addr,
 }
 break;
 case 0x040:
-/* TODO: Implement MII.  */
 s-mmfr = value;
+	s-eir |= FEC_INT_MII;
 break;
 case 0x044:
 s-mscr = value  0xfe;
-- 
1.9.1



Re: [uClinux-dev] m68k compile issue with 4.0.5

2015-06-17 Thread Greg Ungerer
Hi Waldemar,

On 17/06/15 15:42, Waldemar Brodkorb wrote:
> Hi Greg,
> Greg Ungerer wrote,
>>
>> I don't have any compile (or runtime) problems with m5208evb_defconfig
>> on linux-4.0.5 either. That is close to what most people use with qemu.
>> What .config are you using?
> 
> Are you sure the defconfig creates a bootable image?

Yes, on real M5208EVB hardware. That is what I ran it on.
I didn't run it under QEMU.


> I still need at least two patches.
> 
> http://cgit.openadk.org/cgi/cgit/openadk.git/tree/target/m68k/qemu-m68k/patches/4.0.5/qemu-coldfire.patch
> Without this one I get black screen.

Better to use the fixes to QEMU instead of working around
its problems in the linux kernel sources :-)

This thread has the QEMU fixes:

https://lists.nongnu.org/archive/html/qemu-devel/2014-08/msg03224.html

I have posted them a couple of times to the QEMU dev list, but
no-one seems to pick them up.


> http://cgit.openadk.org/cgi/cgit/openadk.git/tree/target/m68k/qemu-m68k/patches/4.0.5/m68k-coldfire-fec.patch
> Without this one I get 
> qemu: hardware error: mcf_fec_read: Bad address 0x1c4
> ...
> Abort

Yes, you still need that. I haven't cleaned that up into a
state that I am totally happy with yet.


> Networking still does not work for me after booting with the two
> patches applied:
> fec fec.0 (unnamed net_device) (uninitialized): MDIO read timeout
> fec: probe of fec.0 failed with error -5
> 
> Any idea?

Hmm, no, haven't seen that one. I'll try a run with qemu and see
if I can see what is going on.

Regards
Greg



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [uClinux-dev] m68k compile issue with 4.0.5

2015-06-17 Thread Greg Ungerer
Hi Waldemar,

On 17/06/15 15:42, Waldemar Brodkorb wrote:
 Hi Greg,
 Greg Ungerer wrote,

 I don't have any compile (or runtime) problems with m5208evb_defconfig
 on linux-4.0.5 either. That is close to what most people use with qemu.
 What .config are you using?
 
 Are you sure the defconfig creates a bootable image?

Yes, on real M5208EVB hardware. That is what I ran it on.
I didn't run it under QEMU.


 I still need at least two patches.
 
 http://cgit.openadk.org/cgi/cgit/openadk.git/tree/target/m68k/qemu-m68k/patches/4.0.5/qemu-coldfire.patch
 Without this one I get black screen.

Better to use the fixes to QEMU instead of working around
its problems in the linux kernel sources :-)

This thread has the QEMU fixes:

https://lists.nongnu.org/archive/html/qemu-devel/2014-08/msg03224.html

I have posted them a couple of times to the QEMU dev list, but
no-one seems to pick them up.


 http://cgit.openadk.org/cgi/cgit/openadk.git/tree/target/m68k/qemu-m68k/patches/4.0.5/m68k-coldfire-fec.patch
 Without this one I get 
 qemu: hardware error: mcf_fec_read: Bad address 0x1c4
 ...
 Abort

Yes, you still need that. I haven't cleaned that up into a
state that I am totally happy with yet.


 Networking still does not work for me after booting with the two
 patches applied:
 fec fec.0 (unnamed net_device) (uninitialized): MDIO read timeout
 fec: probe of fec.0 failed with error -5
 
 Any idea?

Hmm, no, haven't seen that one. I'll try a run with qemu and see
if I can see what is going on.

Regards
Greg



--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [uClinux-dev] m68k compile issue with 4.0.5

2015-06-16 Thread Waldemar Brodkorb
Hi Greg,
Greg Ungerer wrote,
> 
> I don't have any compile (or runtime) problems with m5208evb_defconfig
> on linux-4.0.5 either. That is close to what most people use with qemu.
> What .config are you using?

Are you sure the defconfig creates a bootable image?

I still need at least two patches.

http://cgit.openadk.org/cgi/cgit/openadk.git/tree/target/m68k/qemu-m68k/patches/4.0.5/qemu-coldfire.patch
Without this one I get black screen.

http://cgit.openadk.org/cgi/cgit/openadk.git/tree/target/m68k/qemu-m68k/patches/4.0.5/m68k-coldfire-fec.patch
Without this one I get 
qemu: hardware error: mcf_fec_read: Bad address 0x1c4
...
Abort

Networking still does not work for me after booting with the two
patches applied:
fec fec.0 (unnamed net_device) (uninitialized): MDIO read timeout
fec: probe of fec.0 failed with error -5

Any idea?

best regards
 Waldemar

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [uClinux-dev] m68k compile issue with 4.0.5

2015-06-16 Thread Greg Ungerer
Hi Waldemar,

On 16/06/15 16:24, Geert Uytterhoeven wrote:
> Hi Waldemar,
> 
> On Mon, Jun 15, 2015 at 10:23 PM, Waldemar Brodkorb  wrote:
>> I am trying to build a M68K (Coldfire no-MMU) kernel for Qemu-system-m68k.
>>
>> With 4.0.4 everything is fine. With 4.0.5 I get following compile
>> error:
>>   adk-uclinux-gcc -Wp,-MD,mm/.nommu.o.d  -nostdinc -isystem
>> /home/wbx/m68k/toolchain_qemu-m68k_uclibc-ng_m68k_nommu/usr/lib/gcc/m68k-openadk-uclinux-uclibc/4.9.2/include
>> -I./arch/m68k/include -Iarch/m68k/include/generated/uapi
>> -Iarch/m68k/include/generated  -Iinclude -I./arch/m68k/include/uapi
>> -Iarch/m68k/include/generated/uapi -I./include/uapi
>> -Iinclude/generated/uapi -include ./include/linux/kconfig.h
>> -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs
>> -fno-strict-aliasing -fno-common
>> -Werror-implicit-function-declaration -Wno-format-security
>> -std=gnu89 -mcpu=5208 -pipe -DUTS_SYSNAME=\"uClinux\" -D__uClinux__
>> -fno-delete-null-pointer-checks -Os -Wno-maybe-uninitialized
>> --param=allow-store-data-races=0 -Wframe-larger-than=1024
>> -fno-stack-protector -Wno-unused-but-set-variable
>> -fomit-frame-pointer -fno-var-tracking-assignments
>> -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow
>> -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes
>> -Werror=date-time -DCC_HAVE_ASM_GOTO-D"KBUILD_STR(s)=#s"
>> -D"KBUILD_BASENAME=KBUILD_STR(nommu)"
>> -D"KBUILD_MODNAME=KBUILD_STR(nommu)" -c -o mm/nommu.o mm/nommu.c
>> mm/nommu.c: In function 'delete_vma':
>> mm/nommu.c:861:3: error: implicit declaration of function 'vma_fput'
>> [-Werror=implicit-function-declaration]
>>vma_fput(vma);
>>^
>> cc1: some warnings being treated as errors
>>
>> Any idea what change breaks the compile?
> 
> I tried a few m68knommu defconfigs, but can't reproduce it.
> 
> Is this a plain v4.0.5? I can't find the offending call to vma_fput().
> "git grep vma_fput" tells me there's no "vma_fput" in the kernel sources?

I don't have any compile (or runtime) problems with m5208evb_defconfig
on linux-4.0.5 either. That is close to what most people use with qemu.
What .config are you using?

Regards
Greg


> Gr{oetje,eeting}s,
> 
> Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- 
> ge...@linux-m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like 
> that.
> -- Linus Torvalds
> ___
> uClinux-dev mailing list
> uclinux-...@uclinux.org
> http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
> This message was resent by uclinux-...@uclinux.org
> To unsubscribe see:
> http://mailman.uclinux.org/mailman/options/uclinux-dev
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [uClinux-dev] m68k compile issue with 4.0.5

2015-06-16 Thread Waldemar Brodkorb
Hi Greg,
Greg Ungerer wrote,
 
 I don't have any compile (or runtime) problems with m5208evb_defconfig
 on linux-4.0.5 either. That is close to what most people use with qemu.
 What .config are you using?

Are you sure the defconfig creates a bootable image?

I still need at least two patches.

http://cgit.openadk.org/cgi/cgit/openadk.git/tree/target/m68k/qemu-m68k/patches/4.0.5/qemu-coldfire.patch
Without this one I get black screen.

http://cgit.openadk.org/cgi/cgit/openadk.git/tree/target/m68k/qemu-m68k/patches/4.0.5/m68k-coldfire-fec.patch
Without this one I get 
qemu: hardware error: mcf_fec_read: Bad address 0x1c4
...
Abort

Networking still does not work for me after booting with the two
patches applied:
fec fec.0 (unnamed net_device) (uninitialized): MDIO read timeout
fec: probe of fec.0 failed with error -5

Any idea?

best regards
 Waldemar

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [uClinux-dev] m68k compile issue with 4.0.5

2015-06-16 Thread Greg Ungerer
Hi Waldemar,

On 16/06/15 16:24, Geert Uytterhoeven wrote:
 Hi Waldemar,
 
 On Mon, Jun 15, 2015 at 10:23 PM, Waldemar Brodkorb w...@openadk.org wrote:
 I am trying to build a M68K (Coldfire no-MMU) kernel for Qemu-system-m68k.

 With 4.0.4 everything is fine. With 4.0.5 I get following compile
 error:
   adk-uclinux-gcc -Wp,-MD,mm/.nommu.o.d  -nostdinc -isystem
 /home/wbx/m68k/toolchain_qemu-m68k_uclibc-ng_m68k_nommu/usr/lib/gcc/m68k-openadk-uclinux-uclibc/4.9.2/include
 -I./arch/m68k/include -Iarch/m68k/include/generated/uapi
 -Iarch/m68k/include/generated  -Iinclude -I./arch/m68k/include/uapi
 -Iarch/m68k/include/generated/uapi -I./include/uapi
 -Iinclude/generated/uapi -include ./include/linux/kconfig.h
 -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs
 -fno-strict-aliasing -fno-common
 -Werror-implicit-function-declaration -Wno-format-security
 -std=gnu89 -mcpu=5208 -pipe -DUTS_SYSNAME=\uClinux\ -D__uClinux__
 -fno-delete-null-pointer-checks -Os -Wno-maybe-uninitialized
 --param=allow-store-data-races=0 -Wframe-larger-than=1024
 -fno-stack-protector -Wno-unused-but-set-variable
 -fomit-frame-pointer -fno-var-tracking-assignments
 -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow
 -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes
 -Werror=date-time -DCC_HAVE_ASM_GOTO-DKBUILD_STR(s)=#s
 -DKBUILD_BASENAME=KBUILD_STR(nommu)
 -DKBUILD_MODNAME=KBUILD_STR(nommu) -c -o mm/nommu.o mm/nommu.c
 mm/nommu.c: In function 'delete_vma':
 mm/nommu.c:861:3: error: implicit declaration of function 'vma_fput'
 [-Werror=implicit-function-declaration]
vma_fput(vma);
^
 cc1: some warnings being treated as errors

 Any idea what change breaks the compile?
 
 I tried a few m68knommu defconfigs, but can't reproduce it.
 
 Is this a plain v4.0.5? I can't find the offending call to vma_fput().
 git grep vma_fput tells me there's no vma_fput in the kernel sources?

I don't have any compile (or runtime) problems with m5208evb_defconfig
on linux-4.0.5 either. That is close to what most people use with qemu.
What .config are you using?

Regards
Greg


 Gr{oetje,eeting}s,
 
 Geert
 
 --
 Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- 
 ge...@linux-m68k.org
 
 In personal conversations with technical people, I call myself a hacker. But
 when I'm talking to journalists I just say programmer or something like 
 that.
 -- Linus Torvalds
 ___
 uClinux-dev mailing list
 uclinux-...@uclinux.org
 http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
 This message was resent by uclinux-...@uclinux.org
 To unsubscribe see:
 http://mailman.uclinux.org/mailman/options/uclinux-dev
 

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/