Thread (6 messages) 6 messages, 3 authors, 2008-03-07

RE: TQM5200 2.6-denx SM501 voyager enabling problem.

From: Pedro Luis D. L. <hidden>
Date: 2008-03-07 14:10:08


Anatolij wrote:
Hello,
Hello Anatoli,
Pedro Luis D. L. wrote:
=20
=20
=20
quoted
I tried to contact TQ but they seem not to be able to solve my
problem. They suggested that the problem could be in the different
endianness used by MPC5200 and SMI501. That problem seems to be
corrected in the driver. Anyway, this endianness problem may come
to light if I had any video output. It is possible to change the
endianness of SM501 chip from the u-boot writing a register.
I did it and it made no difference at all. The real problem is
still that none device is initialized or detected even when the
Framebuffer driver for SM501 and MFD Driver for SM501 are compiled
with the kernel. I checked that platform driver for both are
registered (using some printk output) but their probe functions
are never invoked.
=20
I thought that my problem could be that I don't have initialized
the device within the platform file tqm5200.c. I added the following
code (marked with +) to this file under arch/powerpc/platforms/52xx/tqm5=
200.c
quoted
=20
+static struct resource sm501_resources[] =3D {
+	[0]	=3D {
+		.start	=3D 0xE3E00000,
+		.end	=3D 0xE3DFFFFF,
=20
This is wrong as '.end' resource should be greater than '.start'.
The value for '.end' seems to origin from the typo in TQ docs for
TQM5200. The proper value results from adding 2MB register space
of the SM501 to the IO base 0xe3e00000 and is 0xe3ffffff.
Furthermore you didn't define any framebuffer memory resource
which is strictly needed here for the framebuffer driver.
Yes, I supposed I had to add another resource, but I was not sure how to po=
int them. I didn't realize the documentation error, ups, but it is true, e3=
d is smaller than e3E... My mistake, sorry :-(

quoted
+		.flags	=3D IORESOURCE_MEM,
+	},
+};
+
+static struct platform_device sm501_device =3D {
+	.name		=3D "sm501",
+	.id		=3D 0,
+	.num_resources	=3D ARRAY_SIZE(sm501_resources),
+	.resource	=3D sm501_resources,
+};
=20
static void __init tqm5200_setup_arch(void)
{
	if (ppc_md.progress)
		ppc_md.progress("tqm5200_setup_arch()", 0);
=20
	/* Some mpc5200 & mpc5200b related configuration */
	mpc5200_setup_xlb_arbiter();
=20
	/* Map wdt for mpc52xx_restart() */
	mpc52xx_map_wdt();
=20
#ifdef CONFIG_PCI
	np =3D of_find_node_by_type(NULL, "pci");
	if (np) {
		mpc52xx_add_bridge(np);
		of_node_put(np);
	}
#endif
+
+	platform_device_register(&sm501_device);
+
}
=20
I got this idea from the configuration files from other platforms,
but I still need to find out how exactly "resources" must be defined.
Anybody knows wheather am I pointing in the right direction and this
makes any sense?
=20
yes, the direction is right or this is at least a possible solution
among others provided that you do it correctly.
Calling "platform_device_register(...)" from "tqm5200_setup_arch()"
won't work, so move this call and the resource definitions to
sm501 platform driver. A really right direction would be adding
sm501 resource description to the device tree and adding appropriate
code to the sm501 platform driver, but it is more effort.
I thought about this possible solution (adding resource description to devi=
ce tree), but as far as I understood, the device tree was intended to descr=
ibe the microcontroller peripherals and tqm5200, based on the mpc5200 is so=
ld out also without sm501, so that's why I discarded this option.
quoted hunk ↗ jump to hunk
quoted
As far as I understand now (and I may be terribly wrong), once
that SM501 MFD and Framebuffer drivers are registered,  I need
to tell the kernel where to find the device in the local bus.
Is it right?
=20
yes, try the patch below, and also ensure that
CONFIG_VT,
CONFIG_VT_CONSOLE,
CONFIG_FRAMEBUFFER_CONSOLE
are enabled in the kernel configuration.
=20
diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c
index afd8296..599ffe6 100644
--- a/drivers/mfd/sm501.c
+++ b/drivers/mfd/sm501.c
@@ -901,6 +901,9 @@ static int sm501_init_dev(struct sm501_devdata *sm)
=20
 	INIT_LIST_HEAD(&sm->devices);
=20
+	/* switch to BE */
+	writel(0xffffffff, sm->regs + SM501_ENDIAN_CONTROL);
+
 	devid =3D readl(sm->regs + SM501_DEVICEID);
=20
 	if ((devid & SM501_DEVICEID_IDMASK) !=3D SM501_DEVICEID_SM501) {
@@ -1263,8 +1266,31 @@ static struct platform_driver sm501_plat_drv =3D {
 	.resume		=3D sm501_plat_resume,
 };
=20
+/* define some sm501 resources on tqm5200 */
+#define SM501_FB_BASE	0xe0000000
+#define SM501_IO_BASE	0xe3e00000
+#define SM501_FB_END	((SM501_FB_BASE) + 0x7fffff)
+#define SM501_IO_END	((SM501_IO_BASE) + 0x1fffff)
+
+static struct resource sm501_device0_resources[] =3D {
+	[0] =3D {.start =3D SM501_FB_BASE, .end =3D SM501_FB_END, .flags =3D IO=
RESOURCE_MEM,},
+	[1] =3D {.start =3D SM501_IO_BASE, .end =3D SM501_IO_END, .flags =3D IO=
RESOURCE_MEM,},
+};
+
+static struct platform_device sm501_device0 =3D {
+	.name =3D "sm501",
+	.id =3D 0,
+	.num_resources =3D ARRAY_SIZE(sm501_device0_resources),
+	.resource =3D sm501_device0_resources,
+};
+
+static struct platform_device *mfd_devices[] __initdata =3D {
+	&sm501_device0,
+};
+
 static int __init sm501_base_init(void)
 {
+	platform_add_devices(mfd_devices, ARRAY_SIZE(mfd_devices));
 	platform_driver_register(&sm501_plat_drv);
 	return pci_register_driver(&sm501_pci_drv);
 }
=20
Best regards,
Anatolij
It worked!! Thank you very much. The device is added and I can get some out=
put throught the LCD attached. Although the output is not correct yet (look=
s like static noise :-) ), but I think it could be because of an incorrect =
clocks and registers initialization. I should check it up right now.

I think this patch might be include within the kernel. Maybe like a configu=
ration option just in case that SM501 is attached to the tqm. I don't know =
how to do it but I'll give it a try and submit a patch to denx once I have =
a proper output when I figure out how.

Thank you very much,

Pedro L.
--=20
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office@denx.de
_________________________________________________________________
La vida de los famosos al desnudo en MSN Entretenimiento
http://entretenimiento.es.msn.com/=
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help