* gdb & kgdb in MPC85xx
From: Charles Krinke @ 2007-04-15 16:32 UTC (permalink / raw)
To: linuxppc-embedded
In-Reply-To: <3C02138692C13C4BB675FE7EA24095293284D7@bluefin.Soneticom.local>
I have a question relating to stepping with gdb connected to a remote =
target. I can connect to the target with its ttyS1 and 'list', 'break' =
just fine. This is with a Linux-2.6.17.11 kernel and gdb 6.5.
=20
A 'cont' begets a message, and a step fails to return. I am hoping =
someone can offer a suggestion or two.
As an example, I start from uboot with the kernel command line =
containing 'kgdbwait kgdb=3DttyS1,115200' and the target stops at =
'setup_arch: kgdb breakpoint' as I would expect. I am using a USB serial =
dongle, which has worked well for this type of debugging on other =
targets.
=20
$ .../linux
$ ppc-gdb vmlinux [its version 6.5 cross from ultsol]
(gdb) show architeture [its powerpc:common]
(gdb) show verbose [its on]=20
(gdb) target remote /dev/ttyUSB0=20
(gdb) list [works fine]=20
(gdb) break do_fork [sets fine]=20
(gdb) cont
[some problem here as gdb says=20
"Can't send signals to this remote system. SIGILL not sent."
but the breakpoint is taken and the target stops at the beginning of =
do_fork]
(gdb) step
[big problem now as the step never returns]
=20
=20
Charles Krinke
^ permalink raw reply
* Re: Mr Grant Likely's New Patches for 2.6 Kernel and Xilinx FPGA ( Virtex-4 & Virtex-2
From: Grant Likely @ 2007-04-15 14:27 UTC (permalink / raw)
To: Mohammad Sadegh Sadri; +Cc: Linux PPC
In-Reply-To: <BAY115-W1269AFE45FDEDFDEB86A99B2530@phx.gbl>
On 4/15/07, Mohammad Sadegh Sadri <mamsadegh@hotmail.com> wrote:
>
> Hi
>
> - Are these patches going to be part of 2.6.22 kernel? so we should wait a little and then using 2.6.22 we will have builtin support for sys ace without applying any new patches?
I would *like* them to become part of 2.6.22, but that really depends
on how well they are received, and if Paull will pick up arch/ppc
patches.
> - Do we still new to apply the paulus patch to the main kernel so that we can have hard TEMAC support? Or you have a same program as sys ace for it?
No, I did not include TEMAC support. However, I will publish my git
tree tomorrow which will include the TEMAC driver.
> - Actually As a beginner I could not understand what are the rest of the patches
> released by Grant, I understood that one is for sys ace , but the others? Do I
> really need to apply them to for example , my 2.6.20.4 kernel?
You don't need to if you've got a working solution. But these patches
should make it easier to build a working virtex kernel when using
Linus' tree.
--
Grant Likely, B.Sc. P.Eng.
Secret Lab Technologies Ltd.
grant.likely@secretlab.ca
(403) 399-0195
^ permalink raw reply
* Re: [PATCH 1/5] [PPC] Rework Kconfig dependancies for Xilinx Virtex ppc405 platform
From: Grant Likely @ 2007-04-15 14:20 UTC (permalink / raw)
To: Dale Farnsworth; +Cc: Linuxppc-embedded
In-Reply-To: <20070415104819.6709.qmail@farnsworth.org>
On 15 Apr 2007 03:48:19 -0700, Dale Farnsworth <dale@farnsworth.org> wrote:
> In article <11766220692537-git-send-email-grant.likely@secretlab.ca> you write:
> > config XILINX_VIRTEX_II_PRO
> > bool
> > - depends on XILINX_ML300
> > - default y
> > + select XILINX_VIRTEX
> > + default n
>
> Since these variables are not user selectable, it's better to
> remove the "default n", so they don't show up when not selected.
Ah, okay. I didn't know that. Thanks. I'll make that change.
g.
--
Grant Likely, B.Sc. P.Eng.
Secret Lab Technologies Ltd.
grant.likely@secretlab.ca
(403) 399-0195
^ permalink raw reply
* Re: [PATCH] hvc_console polling mode timer backoff
From: Michael Ellerman @ 2007-04-15 13:33 UTC (permalink / raw)
To: will_schmidt; +Cc: linuxppc-dev
In-Reply-To: <1176491513.28514.66.camel@farscape.rchland.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 1689 bytes --]
On Fri, 2007-04-13 at 14:11 -0500, Will Schmidt wrote:
> On Fri, 2007-13-04 at 17:47 +1000, Michael Ellerman wrote:
> > Because this is a super tight performance critical inner loop I've
> > changed it to use a shift instead of divide. So now it's more like 1.5%,
> > but still the point is it increases faster as time passes.
>
> Using a shift here is a good idea. I had considered accelerating the
> backoff value, but it got more complex than I wanted quickly.. I didnt
> consider a shift. :-)
>
> > It'd be good if some more people can bang on this and see what they
> > think of the interactivity.
>
> Still works OK on my power4. I can see the delay on my console, but
> I'm specifically looking for it, I don't think it's an issue.
Cool. Yeah I think people will hardly notice it unless they're trying to
t notice it.
> > +#include <linux/debugfs.h>
> > +static int hvc_debug_init(void)
> > +{
> > + debugfs_create_u32("hvc_timeout", 0400, NULL, &timeout);
> > + return 0;
> > +}
> > +__initcall(hvc_debug_init);
> > +
>
> Is this part temporary for your graphing, or think it's something that
> should go in?
No that's just debug foobar I used for the graphs, I'll send a cleaned
up version during the week if you don't beat me to it.
> I used /proc/timer_stats output for my graphing, just dont have a good
> public spot to upload the pics..
Time to get a blag! ;)
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: [PATCH 1/5] [PPC] Rework Kconfig dependancies for Xilinx Virtex ppc405 platform
From: Dale Farnsworth @ 2007-04-15 10:48 UTC (permalink / raw)
To: grant.likely, Linuxppc-embedded
In-Reply-To: <11766220692537-git-send-email-grant.likely@secretlab.ca>
In article <11766220692537-git-send-email-grant.likely@secretlab.ca> you write:
> Reverse dependency order for Xilinx Virtex parts. For these parts, It
> makes more sense for boards/chips to specify which features they
> provide instead of the features listing the parts they are implemented
> in. I think it also makes adding new board ports simpler.
>
> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
> ---
> arch/ppc/platforms/4xx/Kconfig | 13 +++++++------
> 1 files changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/arch/ppc/platforms/4xx/Kconfig b/arch/ppc/platforms/4xx/Kconfig
> index 705ae56..f74e25b 100644
> --- a/arch/ppc/platforms/4xx/Kconfig
> +++ b/arch/ppc/platforms/4xx/Kconfig
> @@ -54,11 +54,13 @@ config WALNUT
>
> config XILINX_ML300
> bool "Xilinx-ML300"
> + select XILINX_VIRTEX_II_PRO
> help
> This option enables support for the Xilinx ML300 evaluation board.
>
> config XILINX_ML403
> bool "Xilinx-ML403"
> + select XILINX_VIRTEX_4_FX
> help
> This option enables support for the Xilinx ML403 evaluation board.
> endchoice
> @@ -215,18 +217,17 @@ config 405GPR
>
> config XILINX_VIRTEX_II_PRO
> bool
> - depends on XILINX_ML300
> - default y
> + select XILINX_VIRTEX
> + default n
Since these variables are not user selectable, it's better to
remove the "default n", so they don't show up when not selected.
> config XILINX_VIRTEX_4_FX
> bool
> - depends on XILINX_ML403
> - default y
> + select XILINX_VIRTEX
> + default n
>
> config XILINX_VIRTEX
> bool
> - depends on XILINX_VIRTEX_II_PRO || XILINX_VIRTEX_4_FX
> - default y
> + default n
>
> config STB03xxx
> bool
> --
> 1.5.1
-Dale
^ permalink raw reply
* Mr Grant Likely's New Patches for 2.6 Kernel and Xilinx FPGA ( Virtex-4 & Virtex-2 )
From: Mohammad Sadegh Sadri @ 2007-04-15 10:42 UTC (permalink / raw)
To: Linux PPC Linux PPC
Hi
I'm seeing mr grant likely releasing new patches to the 2.6 kernel, one of =
them was for system ace and the others ... as a beginner, I do really know =
what are them ...
now some simple questions about these new patches:
- Are these patches going to be part of 2.6.22 kernel? so we should wait a =
little and then using 2.6.22 we will have builtin support for sys ace witho=
ut applying any new patches?
- Do we still new to apply the paulus patch to the main kernel so that we c=
an have hard TEMAC support? Or you have a same program as sys ace for it?=20
- Actually As a beginner I could not understand what are the rest of the pa=
tches released by Grant, I understood that one is for sys ace , but the oth=
ers? Do I really need to apply them to for example , my 2.6.20.4 kernel?=20
Thanks.
_________________________________________________________________
Invite your mail contacts to join your friends list with Windows Live Space=
s. It's easy!
http://spaces.live.com/spacesapi.aspx?wx_action=3Dcreate&wx_url=3D/friends.=
aspx&mkt=3Den-us=
^ permalink raw reply
* [PATCH 5/5] [PPC] Add uartlite boot console driver for the zImage wrapper
From: Grant Likely @ 2007-04-15 7:27 UTC (permalink / raw)
To: linuxppc-embedded, Andrei Konovalov, Peter Korsgaard,
Rick Moleres, Paul Mackerras
In-Reply-To: <11766220702647-git-send-email-grant.likely@secretlab.ca>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
arch/ppc/boot/common/misc-common.c | 15 +++++++++----
arch/ppc/boot/simple/Makefile | 1 +
arch/ppc/boot/simple/uartlite_tty.c | 37 +++++++++++++++++++++++++++++++++++
3 files changed, 48 insertions(+), 5 deletions(-)
create mode 100644 arch/ppc/boot/simple/uartlite_tty.c
diff --git a/arch/ppc/boot/common/misc-common.c b/arch/ppc/boot/common/misc-common.c
index 8e1fccd..9589969 100644
--- a/arch/ppc/boot/common/misc-common.c
+++ b/arch/ppc/boot/common/misc-common.c
@@ -57,7 +57,8 @@ unsigned char *ISA_io = NULL;
#if defined(CONFIG_SERIAL_CPM_CONSOLE) || defined(CONFIG_SERIAL_8250_CONSOLE) \
|| defined(CONFIG_SERIAL_MPC52xx_CONSOLE) \
- || defined(CONFIG_SERIAL_MPSC_CONSOLE)
+ || defined(CONFIG_SERIAL_MPSC_CONSOLE) \
+ || defined(CONFIG_SERIAL_UARTLITE_CONSOLE)
extern unsigned long com_port;
extern int serial_tstc(unsigned long com_port);
@@ -80,7 +81,8 @@ int tstc(void)
{
#if defined(CONFIG_SERIAL_CPM_CONSOLE) || defined(CONFIG_SERIAL_8250_CONSOLE) \
|| defined(CONFIG_SERIAL_MPC52xx_CONSOLE) \
- || defined(CONFIG_SERIAL_MPSC_CONSOLE)
+ || defined(CONFIG_SERIAL_MPSC_CONSOLE) \
+ || defined(CONFIG_SERIAL_UARTLITE_CONSOLE)
if(keyb_present)
return (CRT_tstc() || serial_tstc(com_port));
else
@@ -95,7 +97,8 @@ int getc(void)
while (1) {
#if defined(CONFIG_SERIAL_CPM_CONSOLE) || defined(CONFIG_SERIAL_8250_CONSOLE) \
|| defined(CONFIG_SERIAL_MPC52xx_CONSOLE) \
- || defined(CONFIG_SERIAL_MPSC_CONSOLE)
+ || defined(CONFIG_SERIAL_MPSC_CONSOLE) \
+ || defined(CONFIG_SERIAL_UARTLITE_CONSOLE)
if (serial_tstc(com_port))
return (serial_getc(com_port));
#endif /* serial console */
@@ -112,7 +115,8 @@ putc(const char c)
#if defined(CONFIG_SERIAL_CPM_CONSOLE) || defined(CONFIG_SERIAL_8250_CONSOLE) \
|| defined(CONFIG_SERIAL_MPC52xx_CONSOLE) \
- || defined(CONFIG_SERIAL_MPSC_CONSOLE)
+ || defined(CONFIG_SERIAL_MPSC_CONSOLE) \
+ || defined(CONFIG_SERIAL_UARTLITE_CONSOLE)
serial_putc(com_port, c);
if ( c == '\n' )
serial_putc(com_port, '\r');
@@ -161,7 +165,8 @@ void puts(const char *s)
while ( ( c = *s++ ) != '\0' ) {
#if defined(CONFIG_SERIAL_CPM_CONSOLE) || defined(CONFIG_SERIAL_8250_CONSOLE) \
|| defined(CONFIG_SERIAL_MPC52xx_CONSOLE) \
- || defined(CONFIG_SERIAL_MPSC_CONSOLE)
+ || defined(CONFIG_SERIAL_MPSC_CONSOLE) \
+ || defined(CONFIG_SERIAL_UARTLITE_CONSOLE)
serial_putc(com_port, c);
if ( c == '\n' ) serial_putc(com_port, '\r');
#endif /* serial console */
diff --git a/arch/ppc/boot/simple/Makefile b/arch/ppc/boot/simple/Makefile
index bcfb6cd..5b87779 100644
--- a/arch/ppc/boot/simple/Makefile
+++ b/arch/ppc/boot/simple/Makefile
@@ -201,6 +201,7 @@ boot-$(CONFIG_8260) += m8260_tty.o
endif
boot-$(CONFIG_SERIAL_MPC52xx_CONSOLE) += mpc52xx_tty.o
boot-$(CONFIG_SERIAL_MPSC_CONSOLE) += mv64x60_tty.o
+boot-$(CONFIG_SERIAL_UARTLITE_CONSOLE) += uartlite_tty.o
LIBS := $(common)/lib.a $(bootlib)/lib.a
ifeq ($(CONFIG_PPC_PREP),y)
diff --git a/arch/ppc/boot/simple/uartlite_tty.c b/arch/ppc/boot/simple/uartlite_tty.c
new file mode 100644
index 0000000..0eae1ea
--- /dev/null
+++ b/arch/ppc/boot/simple/uartlite_tty.c
@@ -0,0 +1,37 @@
+/*
+ * Xilinx UARTLITE bootloader driver
+ *
+ * Copyright (c) 2007 Secret Lab Technologies Ltd.
+ *
+ * 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/types.h>
+#include <asm/serial.h>
+#include <asm/io.h>
+#include <platforms/4xx/xparameters/xparameters.h>
+
+#define UARTLITE_BASEADDR ((void*)(XPAR_UARTLITE_0_BASEADDR))
+
+void
+serial_putc(unsigned long com_port, unsigned char c)
+{
+ while ((in_be32(UARTLITE_BASEADDR + 0x8) & 0x08) != 0); /* spin */
+ out_be32(UARTLITE_BASEADDR + 0x4, c);
+}
+
+unsigned char
+serial_getc(unsigned long com_port)
+{
+ while ((in_be32(UARTLITE_BASEADDR + 0x8) & 0x01) == 0); /* spin */
+ return in_be32(UARTLITE_BASEADDR);
+}
+
+int
+serial_tstc(unsigned long com_port)
+{
+ return ((in_be32(UARTLITE_BASEADDR + 0x8) & 0x01) != 0);
+}
--
1.5.1
^ permalink raw reply related
* [PATCH 4/5] [PPC] Stop using ppc_sys for Xilinx Virtex boards
From: Grant Likely @ 2007-04-15 7:27 UTC (permalink / raw)
To: linuxppc-embedded, Andrei Konovalov, Peter Korsgaard,
Rick Moleres, Paul Mackerras
In-Reply-To: <1176622070387-git-send-email-grant.likely@secretlab.ca>
The arch/ppc/syslib/ppc_sys.c infrastructure does not work well for the
virtex ports. Move the ml300 and ml403 board ports over to use the new
virtex_devices infrastructure.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
arch/ppc/platforms/4xx/Makefile | 1 -
arch/ppc/platforms/4xx/virtex.c | 56 ----------------------------
arch/ppc/platforms/4xx/virtex.h | 7 +---
arch/ppc/platforms/4xx/xilinx_ml300.c | 64 ++------------------------------
arch/ppc/platforms/4xx/xilinx_ml403.c | 65 ++-------------------------------
arch/ppc/syslib/Makefile | 3 +-
include/asm-ppc/ppc_sys.h | 2 -
7 files changed, 11 insertions(+), 187 deletions(-)
delete mode 100644 arch/ppc/platforms/4xx/virtex.c
diff --git a/arch/ppc/platforms/4xx/Makefile b/arch/ppc/platforms/4xx/Makefile
index fa6610b..723ad79 100644
--- a/arch/ppc/platforms/4xx/Makefile
+++ b/arch/ppc/platforms/4xx/Makefile
@@ -28,5 +28,4 @@ obj-$(CONFIG_440SP) += ibm440sp.o
obj-$(CONFIG_440SPE) += ppc440spe.o
obj-$(CONFIG_405EP) += ibm405ep.o
obj-$(CONFIG_405GPR) += ibm405gpr.o
-obj-$(CONFIG_XILINX_VIRTEX) += virtex.o
diff --git a/arch/ppc/platforms/4xx/virtex.c b/arch/ppc/platforms/4xx/virtex.c
deleted file mode 100644
index 133a831..0000000
--- a/arch/ppc/platforms/4xx/virtex.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Virtex-II Pro & Virtex-4 FX common infrastructure
- *
- * Maintainer: Grant Likely <grant.likely@secretlab.ca>
- *
- * Copyright 2005 Secret Lab Technologies Ltd.
- * Copyright 2005 General Dynamics Canada Ltd.
- * Copyright 2005 Freescale Semiconductor Inc.
- *
- * 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/init.h>
-#include <linux/module.h>
-#include <linux/device.h>
-#include <linux/serial_8250.h>
-#include <asm/ppc_sys.h>
-#include <platforms/4xx/virtex.h>
-#include <platforms/4xx/xparameters/xparameters.h>
-
-#define XPAR_UART(num) { \
- .mapbase = XPAR_UARTNS550_##num##_BASEADDR + 3, \
- .irq = XPAR_INTC_0_UARTNS550_##num##_VEC_ID, \
- .iotype = UPIO_MEM, \
- .uartclk = XPAR_UARTNS550_##num##_CLOCK_FREQ_HZ, \
- .flags = UPF_BOOT_AUTOCONF, \
- .regshift = 2, \
- }
-
-struct plat_serial8250_port serial_platform_data[] = {
-#ifdef XPAR_UARTNS550_0_BASEADDR
- XPAR_UART(0),
-#endif
-#ifdef XPAR_UARTNS550_1_BASEADDR
- XPAR_UART(1),
-#endif
-#ifdef XPAR_UARTNS550_2_BASEADDR
- XPAR_UART(2),
-#endif
-#ifdef XPAR_UARTNS550_3_BASEADDR
- XPAR_UART(3),
-#endif
- { }, /* terminated by empty record */
-};
-
-struct platform_device ppc_sys_platform_devices[] = {
- [VIRTEX_UART] = {
- .name = "serial8250",
- .id = 0,
- .dev.platform_data = serial_platform_data,
- },
-};
-
diff --git a/arch/ppc/platforms/4xx/virtex.h b/arch/ppc/platforms/4xx/virtex.h
index e9f58a7..4fc76da 100644
--- a/arch/ppc/platforms/4xx/virtex.h
+++ b/arch/ppc/platforms/4xx/virtex.h
@@ -19,13 +19,8 @@
#if !defined(BASE_BAUD)
#define BASE_BAUD (0) /* dummy value; not used */
#endif
-
-/* Device type enumeration for platform bus definitions */
+
#ifndef __ASSEMBLY__
-enum ppc_sys_devices {
- VIRTEX_UART, NUM_PPC_SYS_DEVS,
-};
-
typedef struct board_info {
unsigned int bi_memsize; /* DRAM installed, in bytes */
unsigned char bi_enetaddr[6]; /* Local Ethernet MAC address */
diff --git a/arch/ppc/platforms/4xx/xilinx_ml300.c b/arch/ppc/platforms/4xx/xilinx_ml300.c
index 4e4aca4..6e522fe 100644
--- a/arch/ppc/platforms/4xx/xilinx_ml300.c
+++ b/arch/ppc/platforms/4xx/xilinx_ml300.c
@@ -18,9 +18,9 @@
#include <linux/serialP.h>
#include <asm/io.h>
#include <asm/machdep.h>
-#include <asm/ppc_sys.h>
#include <syslib/gen550.h>
+#include <syslib/virtex_devices.h>
#include <platforms/4xx/xparameters/xparameters.h>
/*
@@ -53,25 +53,9 @@
* ppc4xx_pic_init arch/ppc/syslib/xilinx_pic.c
*/
-/* Board specifications structures */
-struct ppc_sys_spec *cur_ppc_sys_spec;
-struct ppc_sys_spec ppc_sys_specs[] = {
- {
- /* Only one entry, always assume the same design */
- .ppc_sys_name = "Xilinx ML300 Reference Design",
- .mask = 0x00000000,
- .value = 0x00000000,
- .num_devices = 1,
- .device_list = (enum ppc_sys_devices[])
- {
- VIRTEX_UART,
- },
- },
-};
const char* virtex_machine_name = "ML300 Reference Design";
#if defined(XPAR_POWER_0_POWERDOWN_BASEADDR)
-
static volatile unsigned *powerdown_base =
(volatile unsigned *) XPAR_POWER_0_POWERDOWN_BASEADDR;
@@ -96,52 +80,14 @@ ml300_map_io(void)
#endif
}
-/* Early serial support functions */
-static void __init
-ml300_early_serial_init(int num, struct plat_serial8250_port *pdata)
-{
-#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
- struct uart_port serial_req;
-
- memset(&serial_req, 0, sizeof(serial_req));
- serial_req.mapbase = pdata->mapbase;
- serial_req.membase = pdata->membase;
- serial_req.irq = pdata->irq;
- serial_req.uartclk = pdata->uartclk;
- serial_req.regshift = pdata->regshift;
- serial_req.iotype = pdata->iotype;
- serial_req.flags = pdata->flags;
- gen550_init(num, &serial_req);
-#endif
-}
-
-void __init
-ml300_early_serial_map(void)
-{
-#ifdef CONFIG_SERIAL_8250
- struct plat_serial8250_port *pdata;
- int i = 0;
-
- pdata = (struct plat_serial8250_port *) ppc_sys_get_pdata(VIRTEX_UART);
- while(pdata && pdata->flags)
- {
- pdata->membase = ioremap(pdata->mapbase, 0x100);
- ml300_early_serial_init(i, pdata);
- pdata++;
- i++;
- }
-#endif /* CONFIG_SERIAL_8250 */
-}
-
void __init
ml300_setup_arch(void)
{
- ml300_early_serial_map();
+ virtex_early_serial_map();
ppc4xx_setup_arch(); /* calls ppc4xx_find_bridges() */
/* Identify the system */
- printk(KERN_INFO "Xilinx Virtex-II Pro port\n");
- printk(KERN_INFO "Port by MontaVista Software, Inc. (source@mvista.com)\n");
+ printk(KERN_INFO "Xilinx ML300 Reference System (Virtex-II Pro)\n");
}
/* Called after board_setup_irq from ppc4xx_init_IRQ(). */
@@ -157,8 +103,6 @@ platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
{
ppc4xx_init(r3, r4, r5, r6, r7);
- identify_ppc_sys_by_id(mfspr(SPRN_PVR));
-
ppc_md.setup_arch = ml300_setup_arch;
ppc_md.setup_io_mappings = ml300_map_io;
ppc_md.init_IRQ = ml300_init_irq;
@@ -168,7 +112,7 @@ platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
#endif
#ifdef CONFIG_KGDB
- ppc_md.early_serial_map = ml300_early_serial_map;
+ ppc_md.early_serial_map = virtex_early_serial_map;
#endif
}
diff --git a/arch/ppc/platforms/4xx/xilinx_ml403.c b/arch/ppc/platforms/4xx/xilinx_ml403.c
index c98e40a..bc3ace3 100644
--- a/arch/ppc/platforms/4xx/xilinx_ml403.c
+++ b/arch/ppc/platforms/4xx/xilinx_ml403.c
@@ -1,11 +1,9 @@
/*
- * arch/ppc/platforms/4xx/xilinx_ml403.c
- *
* Xilinx ML403 evaluation board initialization
*
* Author: Grant Likely <grant.likely@secretlab.ca>
*
- * 2005 (c) Secret Lab Technologies Ltd.
+ * 2005-2007 (c) Secret Lab Technologies Ltd.
* 2002-2004 (c) MontaVista Software, Inc.
*
* This file is licensed under the terms of the GNU General Public License
@@ -22,9 +20,9 @@
#include <linux/serialP.h>
#include <asm/io.h>
#include <asm/machdep.h>
-#include <asm/ppc_sys.h>
#include <syslib/gen550.h>
+#include <syslib/virtex_devices.h>
#include <platforms/4xx/xparameters/xparameters.h>
/*
@@ -57,25 +55,9 @@
* ppc4xx_pic_init arch/ppc/syslib/xilinx_pic.c
*/
-/* Board specifications structures */
-struct ppc_sys_spec *cur_ppc_sys_spec;
-struct ppc_sys_spec ppc_sys_specs[] = {
- {
- /* Only one entry, always assume the same design */
- .ppc_sys_name = "Xilinx ML403 Reference Design",
- .mask = 0x00000000,
- .value = 0x00000000,
- .num_devices = 1,
- .device_list = (enum ppc_sys_devices[])
- {
- VIRTEX_UART,
- },
- },
-};
const char* virtex_machine_name = "ML403 Reference Design";
#if defined(XPAR_POWER_0_POWERDOWN_BASEADDR)
-
static volatile unsigned *powerdown_base =
(volatile unsigned *) XPAR_POWER_0_POWERDOWN_BASEADDR;
@@ -100,47 +82,10 @@ ml403_map_io(void)
#endif
}
-/* Early serial support functions */
-static void __init
-ml403_early_serial_init(int num, struct plat_serial8250_port *pdata)
-{
-#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
- struct uart_port serial_req;
-
- memset(&serial_req, 0, sizeof(serial_req));
- serial_req.mapbase = pdata->mapbase;
- serial_req.membase = pdata->membase;
- serial_req.irq = pdata->irq;
- serial_req.uartclk = pdata->uartclk;
- serial_req.regshift = pdata->regshift;
- serial_req.iotype = pdata->iotype;
- serial_req.flags = pdata->flags;
- gen550_init(num, &serial_req);
-#endif
-}
-
-void __init
-ml403_early_serial_map(void)
-{
-#ifdef CONFIG_SERIAL_8250
- struct plat_serial8250_port *pdata;
- int i = 0;
-
- pdata = (struct plat_serial8250_port *) ppc_sys_get_pdata(VIRTEX_UART);
- while(pdata && pdata->flags)
- {
- pdata->membase = ioremap(pdata->mapbase, 0x100);
- ml403_early_serial_init(i, pdata);
- pdata++;
- i++;
- }
-#endif /* CONFIG_SERIAL_8250 */
-}
-
void __init
ml403_setup_arch(void)
{
- ml403_early_serial_map();
+ virtex_early_serial_map();
ppc4xx_setup_arch(); /* calls ppc4xx_find_bridges() */
/* Identify the system */
@@ -160,8 +105,6 @@ platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
{
ppc4xx_init(r3, r4, r5, r6, r7);
- identify_ppc_sys_by_id(mfspr(SPRN_PVR));
-
ppc_md.setup_arch = ml403_setup_arch;
ppc_md.setup_io_mappings = ml403_map_io;
ppc_md.init_IRQ = ml403_init_irq;
@@ -171,7 +114,7 @@ platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
#endif
#ifdef CONFIG_KGDB
- ppc_md.early_serial_map = ml403_early_serial_map;
+ ppc_md.early_serial_map = virtex_early_serial_map;
#endif
}
diff --git a/arch/ppc/syslib/Makefile b/arch/ppc/syslib/Makefile
index 0991111..9569415 100644
--- a/arch/ppc/syslib/Makefile
+++ b/arch/ppc/syslib/Makefile
@@ -18,7 +18,8 @@ obj-$(CONFIG_440SP) += ibm440gx_common.o ibm440sp_common.o
obj-$(CONFIG_440SPE) += ibm440gx_common.o ibm440sp_common.o ppc440spe_pcie.o
ifeq ($(CONFIG_4xx),y)
ifeq ($(CONFIG_XILINX_VIRTEX),y)
-obj-$(CONFIG_40x) += xilinx_pic.o ppc_sys.o
+obj-$(CONFIG_40x) += xilinx_pic.o
+obj-y += virtex_devices.o
else
ifeq ($(CONFIG_403),y)
obj-$(CONFIG_40x) += ppc403_pic.o
diff --git a/include/asm-ppc/ppc_sys.h b/include/asm-ppc/ppc_sys.h
index 40f197a..de99e92 100644
--- a/include/asm-ppc/ppc_sys.h
+++ b/include/asm-ppc/ppc_sys.h
@@ -33,8 +33,6 @@
#include <asm/mpc52xx.h>
#elif defined(CONFIG_MPC10X_BRIDGE)
#include <asm/mpc10x.h>
-#elif defined(CONFIG_XILINX_VIRTEX)
-#include <platforms/4xx/virtex.h>
#else
#error "need definition of ppc_sys_devices"
#endif
--
1.5.1
^ permalink raw reply related
* [PATCH 3/5] [PPC] New registration for common Xilinx Virtex ppc405 platform devices
From: Grant Likely @ 2007-04-15 7:27 UTC (permalink / raw)
To: linuxppc-embedded, Andrei Konovalov, Peter Korsgaard,
Rick Moleres, Paul Mackerras
In-Reply-To: <11766220693636-git-send-email-grant.likely@secretlab.ca>
Currently virtex support in mainline make use of the infrastructure in
arch/ppc/syslib/ppc_sys.c for registering common devices on virtex ppc405
platforms. The ppc_sys.c code is not well suited to the dynamic nature of
FPGA designs and makes adding new board ports more complex. This patch
adds a new listing of common devices which does not depend on the ppc_sys.c
infrastructure.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
arch/ppc/syslib/virtex_devices.c | 209 ++++++++++++++++++++++++++++++++++++++
arch/ppc/syslib/virtex_devices.h | 27 +++++
2 files changed, 236 insertions(+), 0 deletions(-)
create mode 100644 arch/ppc/syslib/virtex_devices.c
create mode 100644 arch/ppc/syslib/virtex_devices.h
diff --git a/arch/ppc/syslib/virtex_devices.c b/arch/ppc/syslib/virtex_devices.c
new file mode 100644
index 0000000..096fb2a
--- /dev/null
+++ b/arch/ppc/syslib/virtex_devices.c
@@ -0,0 +1,209 @@
+/*
+ * Virtex hard ppc405 core common device listing
+ *
+ * Copyright 2005-2007 Secret Lab Technologies Ltd.
+ * Copyright 2005 Freescale Semiconductor Inc.
+ * Copyright 2002-2004 MontaVista Software, Inc.
+ *
+ * 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/init.h>
+#include <linux/module.h>
+#include <linux/device.h>
+#include <linux/serial_8250.h>
+#include <syslib/virtex_devices.h>
+#include <platforms/4xx/xparameters/xparameters.h>
+#include <asm/io.h>
+
+/*
+ * UARTLITE: shortcut macro for single instance
+ */
+#define XPAR_UARTLITE(num) { \
+ .name = "uartlite", \
+ .id = num, \
+ .num_resources = 2, \
+ .resource = (struct resource[]) { \
+ { \
+ .start = XPAR_UARTLITE_##num##_BASEADDR + 3, \
+ .end = XPAR_UARTLITE_##num##_HIGHADDR, \
+ .flags = IORESOURCE_MEM, \
+ }, \
+ { \
+ .start = XPAR_INTC_0_UARTLITE_##num##_VEC_ID, \
+ .flags = IORESOURCE_IRQ, \
+ }, \
+ }, \
+}
+
+/*
+ * Full UART: shortcut macro for single instance + platform data structure
+ */
+#define XPAR_UART(num) { \
+ .mapbase = XPAR_UARTNS550_##num##_BASEADDR + 3, \
+ .irq = XPAR_INTC_0_UARTNS550_##num##_VEC_ID, \
+ .iotype = UPIO_MEM, \
+ .uartclk = XPAR_UARTNS550_##num##_CLOCK_FREQ_HZ, \
+ .flags = UPF_BOOT_AUTOCONF, \
+ .regshift = 2, \
+}
+
+/*
+ * SystemACE: shortcut macro for single instance
+ */
+#define XPAR_SYSACE(num) { \
+ .name = "xsysace", \
+ .id = XPAR_SYSACE_##num##_DEVICE_ID, \
+ .num_resources = 2, \
+ .resource = (struct resource[]) { \
+ { \
+ .start = XPAR_SYSACE_##num##_BASEADDR, \
+ .end = XPAR_SYSACE_##num##_HIGHADDR, \
+ .flags = IORESOURCE_MEM, \
+ }, \
+ { \
+ .start = XPAR_INTC_0_SYSACE_##num##_VEC_ID, \
+ .flags = IORESOURCE_IRQ, \
+ }, \
+ }, \
+}
+
+
+/* UART 8250 driver platform data table */
+struct plat_serial8250_port virtex_serial_platform_data[] = {
+#if defined(XPAR_UARTNS550_0_BASEADDR)
+ XPAR_UART(0),
+#endif
+#if defined(XPAR_UARTNS550_1_BASEADDR)
+ XPAR_UART(1),
+#endif
+#if defined(XPAR_UARTNS550_2_BASEADDR)
+ XPAR_UART(2),
+#endif
+#if defined(XPAR_UARTNS550_3_BASEADDR)
+ XPAR_UART(3),
+#endif
+ { }, /* terminated by empty record */
+};
+
+
+struct platform_device virtex_platform_devices[] = {
+ /* UARTLITE instances */
+#if defined(XPAR_UARTLITE_0_BASEADDR)
+ XPAR_UARTLITE(0),
+#endif
+#if defined(XPAR_UARTLITE_1_BASEADDR)
+ XPAR_UARTLITE(1),
+#endif
+#if defined(XPAR_UARTLITE_2_BASEADDR)
+ XPAR_UARTLITE(2),
+#endif
+#if defined(XPAR_UARTLITE_3_BASEADDR)
+ XPAR_UARTLITE(3),
+#endif
+
+ /* Full UART instances */
+#if defined(XPAR_UARTNS550_0_BASEADDR)
+ {
+ .name = "serial8250",
+ .id = 0,
+ .dev.platform_data = virtex_serial_platform_data,
+ },
+#endif
+
+ /* SystemACE instances */
+#if defined(XPAR_SYSACE_0_BASEADDR)
+ XPAR_SYSACE(0),
+#endif
+#if defined(XPAR_SYSACE_1_BASEADDR)
+ XPAR_SYSACE(1),
+#endif
+
+ /* ML300/403 reference design framebuffer */
+#if defined(XPAR_TFT_0_BASEADDR)
+ {
+ .name = "xilinxfb",
+ .id = 0,
+ .num_resources = 1,
+ .resource = (struct resource[]) {
+ {
+ .start = XPAR_TFT_0_BASEADDR,
+ .end = XPAR_TFT_0_BASEADDR+7,
+ .flags = IORESOURCE_IO,
+ },
+ },
+ },
+#endif
+};
+
+/* Early serial support functions */
+static void __init
+virtex_early_serial_init(int num, struct plat_serial8250_port *pdata)
+{
+#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
+ struct uart_port serial_req;
+
+ memset(&serial_req, 0, sizeof(serial_req));
+ serial_req.mapbase = pdata->mapbase;
+ serial_req.membase = pdata->membase;
+ serial_req.irq = pdata->irq;
+ serial_req.uartclk = pdata->uartclk;
+ serial_req.regshift = pdata->regshift;
+ serial_req.iotype = pdata->iotype;
+ serial_req.flags = pdata->flags;
+ gen550_init(num, &serial_req);
+#endif
+}
+
+void __init
+virtex_early_serial_map(void)
+{
+#ifdef CONFIG_SERIAL_8250
+ struct plat_serial8250_port *pdata;
+ int i = 0;
+
+ pdata = virtex_serial_platform_data;
+ while(pdata && pdata->flags) {
+ pdata->membase = ioremap(pdata->mapbase, 0x100);
+ virtex_early_serial_init(i, pdata);
+ pdata++;
+ i++;
+ }
+#endif /* CONFIG_SERIAL_8250 */
+}
+
+/*
+ * default fixup routine; do nothing and return success.
+ *
+ * Reimplement this routine in your custom board support file to
+ * override the default behaviour
+ */
+int __attribute__ ((weak))
+virtex_device_fixup(struct platform_device *dev)
+{
+ return 0;
+}
+
+static int __init virtex_init(void)
+{
+ struct platform_device *index = virtex_platform_devices;
+ unsigned int ret = 0;
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(virtex_platform_devices); i++, index++) {
+ if (virtex_device_fixup(index) != 0)
+ continue;
+
+ if (platform_device_register(index)) {
+ ret = 1;
+ printk(KERN_ERR "cannot register dev %s:%d\n",
+ index->name, index->id);
+ }
+ }
+ return ret;
+}
+
+subsys_initcall(virtex_init);
diff --git a/arch/ppc/syslib/virtex_devices.h b/arch/ppc/syslib/virtex_devices.h
new file mode 100644
index 0000000..4a17dd3
--- /dev/null
+++ b/arch/ppc/syslib/virtex_devices.h
@@ -0,0 +1,27 @@
+/*
+ * Common support header for virtex ppc405 platforms
+ *
+ * Copyright 2007 Secret Lab Technologies Ltd.
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2. This program is licensed "as is" without any warranty of any
+ * kind, whether express or implied.
+ */
+
+#ifndef __ASM_VIRTEX_DEVICES_H__
+#define __ASM_VIRTEX_DEVICES_H__
+
+#include <linux/platform_device.h>
+
+void __init virtex_early_serial_map(void);
+
+/* Prototype for device fixup routine. Implement this routine in the
+ * board specific fixup code and the generic setup code will call it for
+ * each device is the platform device list.
+ *
+ * If the hook returns a non-zero value, then the device will not get
+ * registered with the platform bus
+ */
+int virtex_device_fixup(struct platform_device *dev);
+
+#endif /* __ASM_VIRTEX_DEVICES_H__ */
--
1.5.1
^ permalink raw reply related
* [PATCH 2/5] [PPC] Merge common virtex header files
From: Grant Likely @ 2007-04-15 7:27 UTC (permalink / raw)
To: linuxppc-embedded, Andrei Konovalov, Peter Korsgaard,
Rick Moleres, Paul Mackerras
In-Reply-To: <11766220692537-git-send-email-grant.likely@secretlab.ca>
The header files for the ml403 and ml300 are virtually identical, merge
them into a single file.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
arch/ppc/platforms/4xx/virtex.h | 40 +++++++++++++++++++-------
arch/ppc/platforms/4xx/xilinx_ml300.c | 1 +
arch/ppc/platforms/4xx/xilinx_ml300.h | 45 ------------------------------
arch/ppc/platforms/4xx/xilinx_ml403.c | 1 +
arch/ppc/platforms/4xx/xilinx_ml403.h | 49 ---------------------------------
include/asm-ppc/ibm4xx.h | 8 +----
6 files changed, 33 insertions(+), 111 deletions(-)
delete mode 100644 arch/ppc/platforms/4xx/xilinx_ml300.h
delete mode 100644 arch/ppc/platforms/4xx/xilinx_ml403.h
diff --git a/arch/ppc/platforms/4xx/virtex.h b/arch/ppc/platforms/4xx/virtex.h
index c14325d..e9f58a7 100644
--- a/arch/ppc/platforms/4xx/virtex.h
+++ b/arch/ppc/platforms/4xx/virtex.h
@@ -1,22 +1,18 @@
/*
- * arch/ppc/platforms/4xx/virtex.h
+ * Basic Virtex platform defines, included by <asm/ibm4xx.h>
*
- * Include file that defines the Xilinx Virtex-II Pro processor
+ * 2005-2007 (c) Secret Lab Technologies Ltd.
+ * 2002-2004 (c) MontaVista Software, Inc.
*
- * Author: MontaVista Software, Inc.
- * source@mvista.com
- *
- * 2002-2004 (c) MontaVista Software, Inc. This file is licensed under the
- * terms of the GNU General Public License version 2. This program is licensed
- * "as is" without any warranty of any kind, whether express or implied.
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2. This program is licensed "as is" without any warranty of any
+ * kind, whether express or implied.
*/
#ifdef __KERNEL__
#ifndef __ASM_VIRTEX_H__
#define __ASM_VIRTEX_H__
-/* serial defines */
-
#include <asm/ibm405.h>
/* Ugly, ugly, ugly! BASE_BAUD defined here to keep 8250.c happy. */
@@ -29,7 +25,29 @@
enum ppc_sys_devices {
VIRTEX_UART, NUM_PPC_SYS_DEVS,
};
-#endif
+typedef struct board_info {
+ unsigned int bi_memsize; /* DRAM installed, in bytes */
+ unsigned char bi_enetaddr[6]; /* Local Ethernet MAC address */
+ unsigned int bi_intfreq; /* Processor speed, in Hz */
+ unsigned int bi_busfreq; /* PLB Bus speed, in Hz */
+ unsigned int bi_pci_busfreq; /* PCI Bus speed, in Hz */
+} bd_t;
+
+/* Some 4xx parts use a different timebase frequency from the internal clock.
+ * the Virtex 405 does not, so just use a macro to make tbfreq match intfreq
+*/
+#define bi_tbfreq bi_intfreq
+
+extern const char* virtex_machine_name;
+#define PPC4xx_MACHINE_NAME (virtex_machine_name)
+
+#endif /* !__ASSEMBLY__ */
+
+/* We don't need anything mapped. Size of zero will accomplish that. */
+#define PPC4xx_ONB_IO_PADDR 0u
+#define PPC4xx_ONB_IO_VADDR 0u
+#define PPC4xx_ONB_IO_SIZE 0u
+
#endif /* __ASM_VIRTEX_H__ */
#endif /* __KERNEL__ */
diff --git a/arch/ppc/platforms/4xx/xilinx_ml300.c b/arch/ppc/platforms/4xx/xilinx_ml300.c
index fb5f0b5..4e4aca4 100644
--- a/arch/ppc/platforms/4xx/xilinx_ml300.c
+++ b/arch/ppc/platforms/4xx/xilinx_ml300.c
@@ -68,6 +68,7 @@ struct ppc_sys_spec ppc_sys_specs[] = {
},
},
};
+const char* virtex_machine_name = "ML300 Reference Design";
#if defined(XPAR_POWER_0_POWERDOWN_BASEADDR)
diff --git a/arch/ppc/platforms/4xx/xilinx_ml300.h b/arch/ppc/platforms/4xx/xilinx_ml300.h
deleted file mode 100644
index 3d57332..0000000
--- a/arch/ppc/platforms/4xx/xilinx_ml300.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Include file that defines the Xilinx ML300 evaluation board
- *
- * Author: MontaVista Software, Inc.
- * source@mvista.com
- *
- * 2002-2004 (c) MontaVista Software, Inc. This file is licensed under the
- * terms of the GNU General Public License version 2. This program is licensed
- * "as is" without any warranty of any kind, whether express or implied.
- */
-
-#ifdef __KERNEL__
-#ifndef __ASM_XILINX_ML300_H__
-#define __ASM_XILINX_ML300_H__
-
-/* ML300 has a Xilinx Virtex-II Pro processor */
-#include <platforms/4xx/virtex.h>
-
-#ifndef __ASSEMBLY__
-
-#include <linux/types.h>
-
-typedef struct board_info {
- unsigned int bi_memsize; /* DRAM installed, in bytes */
- unsigned char bi_enetaddr[6]; /* Local Ethernet MAC address */
- unsigned int bi_intfreq; /* Processor speed, in Hz */
- unsigned int bi_busfreq; /* PLB Bus speed, in Hz */
- unsigned int bi_pci_busfreq; /* PCI Bus speed, in Hz */
-} bd_t;
-
-/* Some 4xx parts use a different timebase frequency from the internal clock.
-*/
-#define bi_tbfreq bi_intfreq
-
-#endif /* !__ASSEMBLY__ */
-
-/* We don't need anything mapped. Size of zero will accomplish that. */
-#define PPC4xx_ONB_IO_PADDR 0u
-#define PPC4xx_ONB_IO_VADDR 0u
-#define PPC4xx_ONB_IO_SIZE 0u
-
-#define PPC4xx_MACHINE_NAME "Xilinx ML300 Reference System"
-
-#endif /* __ASM_XILINX_ML300_H__ */
-#endif /* __KERNEL__ */
diff --git a/arch/ppc/platforms/4xx/xilinx_ml403.c b/arch/ppc/platforms/4xx/xilinx_ml403.c
index cb3bf7a..c98e40a 100644
--- a/arch/ppc/platforms/4xx/xilinx_ml403.c
+++ b/arch/ppc/platforms/4xx/xilinx_ml403.c
@@ -72,6 +72,7 @@ struct ppc_sys_spec ppc_sys_specs[] = {
},
},
};
+const char* virtex_machine_name = "ML403 Reference Design";
#if defined(XPAR_POWER_0_POWERDOWN_BASEADDR)
diff --git a/arch/ppc/platforms/4xx/xilinx_ml403.h b/arch/ppc/platforms/4xx/xilinx_ml403.h
deleted file mode 100644
index 4735969..0000000
--- a/arch/ppc/platforms/4xx/xilinx_ml403.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * arch/ppc/platforms/4xx/xilinx_ml403.h
- *
- * Include file that defines the Xilinx ML403 reference design
- *
- * Author: Grant Likely <grant.likely@secretlab.ca>
- *
- * 2005 (c) Secret Lab Technologies Ltd.
- * 2002-2004 (c) MontaVista Software, Inc.
- *
- * This file is licensed under the terms of the GNU General Public License
- * version 2. This program is licensed "as is" without any warranty of any
- * kind, whether express or implied.
- */
-
-#ifdef __KERNEL__
-#ifndef __ASM_XILINX_ML403_H__
-#define __ASM_XILINX_ML403_H__
-
-/* ML403 has a Xilinx Virtex-4 FPGA with a PPC405 hard core */
-#include <platforms/4xx/virtex.h>
-
-#ifndef __ASSEMBLY__
-
-#include <linux/types.h>
-
-typedef struct board_info {
- unsigned int bi_memsize; /* DRAM installed, in bytes */
- unsigned char bi_enetaddr[6]; /* Local Ethernet MAC address */
- unsigned int bi_intfreq; /* Processor speed, in Hz */
- unsigned int bi_busfreq; /* PLB Bus speed, in Hz */
- unsigned int bi_pci_busfreq; /* PCI Bus speed, in Hz */
-} bd_t;
-
-/* Some 4xx parts use a different timebase frequency from the internal clock.
-*/
-#define bi_tbfreq bi_intfreq
-
-#endif /* !__ASSEMBLY__ */
-
-/* We don't need anything mapped. Size of zero will accomplish that. */
-#define PPC4xx_ONB_IO_PADDR 0u
-#define PPC4xx_ONB_IO_VADDR 0u
-#define PPC4xx_ONB_IO_SIZE 0u
-
-#define PPC4xx_MACHINE_NAME "Xilinx ML403 Reference Design"
-
-#endif /* __ASM_XILINX_ML403_H__ */
-#endif /* __KERNEL__ */
diff --git a/include/asm-ppc/ibm4xx.h b/include/asm-ppc/ibm4xx.h
index 92fd02d..ed6891a 100644
--- a/include/asm-ppc/ibm4xx.h
+++ b/include/asm-ppc/ibm4xx.h
@@ -47,12 +47,8 @@
#include <platforms/4xx/walnut.h>
#endif
-#if defined(CONFIG_XILINX_ML300)
-#include <platforms/4xx/xilinx_ml300.h>
-#endif
-
-#if defined(CONFIG_XILINX_ML403)
-#include <platforms/4xx/xilinx_ml403.h>
+#if defined(CONFIG_XILINX_VIRTEX)
+#include <platforms/4xx/virtex.h>
#endif
#ifndef __ASSEMBLY__
--
1.5.1
^ permalink raw reply related
* Patchset to establish sanity in Xilinx Virtex support
From: Grant Likely @ 2007-04-15 7:27 UTC (permalink / raw)
To: linuxppc-embedded, Andrei Konovalov, Peter Korsgaard,
Rick Moleres, Paul Mackerras
The Virtex support in Linus' tree is a mess. When I ported the common
devices over to using the platform bus I tried the use the ppc_sys
infrastructure. ppc_sys is intended for SoCs that have a fixed set of
devices. It is the *wrong* approach for FPGA support, and I made a
royal mess of things. This patch set fixes that problem and makes
a number of other changes that make supporting Virtex boards easier.
I do know that changes to arch/ppc are frowned upon at the moment. However,
4xx support in arch/powerpc is not merged yet, and Virtex support needs
additional work beyond that. I suspect that arch/ppc support for the
4xx parts is going to need to stay alive for the next 2-3 kernel releases
anyway while arch/powerpc support stablizes. Getting these patches in
will make it easier to support the Virtex ports while I hack on getting
arch/powerpc stuff figured out.
arch/ppc/boot/common/misc-common.c | 15 ++-
arch/ppc/boot/simple/Makefile | 1 +
arch/ppc/boot/simple/uartlite_tty.c | 37 ++++++
arch/ppc/platforms/4xx/Kconfig | 13 +-
arch/ppc/platforms/4xx/Makefile | 1 -
arch/ppc/platforms/4xx/virtex.c | 56 ---------
arch/ppc/platforms/4xx/virtex.h | 47 +++++---
arch/ppc/platforms/4xx/xilinx_ml300.c | 65 +----------
arch/ppc/platforms/4xx/xilinx_ml300.h | 45 -------
arch/ppc/platforms/4xx/xilinx_ml403.c | 66 +----------
arch/ppc/platforms/4xx/xilinx_ml403.h | 49 --------
arch/ppc/syslib/Makefile | 3 +-
arch/ppc/syslib/virtex_devices.c | 209 +++++++++++++++++++++++++++++++++
arch/ppc/syslib/virtex_devices.h | 27 +++++
include/asm-ppc/ibm4xx.h | 8 +-
include/asm-ppc/ppc_sys.h | 2 -
16 files changed, 335 insertions(+), 309 deletions(-)
^ permalink raw reply
* [PATCH 1/5] [PPC] Rework Kconfig dependancies for Xilinx Virtex ppc405 platform
From: Grant Likely @ 2007-04-15 7:27 UTC (permalink / raw)
To: linuxppc-embedded, Andrei Konovalov, Peter Korsgaard,
Rick Moleres, Paul Mackerras
In-Reply-To: <1176622062492-git-send-email-grant.likely@secretlab.ca>
Reverse dependency order for Xilinx Virtex parts. For these parts, It
makes more sense for boards/chips to specify which features they
provide instead of the features listing the parts they are implemented
in. I think it also makes adding new board ports simpler.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
arch/ppc/platforms/4xx/Kconfig | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/arch/ppc/platforms/4xx/Kconfig b/arch/ppc/platforms/4xx/Kconfig
index 705ae56..f74e25b 100644
--- a/arch/ppc/platforms/4xx/Kconfig
+++ b/arch/ppc/platforms/4xx/Kconfig
@@ -54,11 +54,13 @@ config WALNUT
config XILINX_ML300
bool "Xilinx-ML300"
+ select XILINX_VIRTEX_II_PRO
help
This option enables support for the Xilinx ML300 evaluation board.
config XILINX_ML403
bool "Xilinx-ML403"
+ select XILINX_VIRTEX_4_FX
help
This option enables support for the Xilinx ML403 evaluation board.
endchoice
@@ -215,18 +217,17 @@ config 405GPR
config XILINX_VIRTEX_II_PRO
bool
- depends on XILINX_ML300
- default y
+ select XILINX_VIRTEX
+ default n
config XILINX_VIRTEX_4_FX
bool
- depends on XILINX_ML403
- default y
+ select XILINX_VIRTEX
+ default n
config XILINX_VIRTEX
bool
- depends on XILINX_VIRTEX_II_PRO || XILINX_VIRTEX_4_FX
- default y
+ default n
config STB03xxx
bool
--
1.5.1
^ permalink raw reply related
* Re: [PATCH dtc] Implement the -R option and add a -S option.
From: Jerry Van Baren @ 2007-04-15 2:41 UTC (permalink / raw)
To: Linuxppc-dev
In-Reply-To: <20070415022244.GA12016@localhost.localdomain>
David Gibson wrote:
> On Sat, Apr 14, 2007 at 10:13:49PM -0400, Jerry Van Baren wrote:
>> David Gibson wrote:
>>> On Sat, Apr 14, 2007 at 08:58:49AM -0400, Jerry Van Baren wrote:
>> [snip]
>>
>>>> On an unrelated related note, I don't believe my -R additions are
>>>> actually putting out additional reserve map slots (easiest to see using
>>>> the asm format output). I'm still trying to understand why not, it
>>>> seemed pretty straight-forward. When I implemented it, I was looking at
>>>> hexdumps of the dtb binary format and looking at the header and thought
>>>> I had it working... using it with my u-boot mods shows no extra reserved
>>>> slots. I'm looking into where I went wrong.
>>> Be careful to check the actual offsets. Bear in mind that objdump may
>>> elide zero words. Also bear in mind that the only way a reader of the
>>> device tree has of counting the number of reserve entries is stepping
>>> through until it hits the terminating (0,0), so the extra entries will
>>> just look like an early termination of the list. In this sense -R
>>> doesn't add "extra slots", but just ensures that there is space after
>>> the reserve map to add more entries.
>> Hi David,
>>
>> It actually is OK, went back and verified it. I needed to modify the
>> asm output to implement the -R extra slots which was confusing me (patch
>> that you didn't like the calloc in ;-).
>>
>> The calloc change was actually window dressing, I was just being
>> paranoid about a binary blob that is bigger than its contents (has extra
>> space). The unused space is unused, so it doen't really matter if it is
>> non-zero. I'll roll a new version.
>
> Oh, I think zeroing it is correct, I'd just prefer it was done at the
> callsite, rather than within xmalloc(). Strictly speaking you're
> right, what's in the extra area shouldn't matter, but I don't like the
> idea of potentially leaking random memory contents to file, which I
> think could happen without a memset(). Because dtc is unpriveleged it
> shouldn't actually matter, but it's ugly and a bad habit to establish.
Where I got concerned was a conversion of a .dtb input into a .dts or
.asm output (or even a .dtb output). I've run it and verified that the
extra space (which is potentially random garbage) is not copied to the
output - the size in the header is what it is and the data output is
only the actual data (no major surprise there).
Generating a text output format actually strips the extra size/data
because dtc turns it back into a symbolic form and padding is outside of
the symbolic form, if you follow my drift (there isn't a way to
represent extra blob padding in a dts format).
gvb
^ permalink raw reply
* [PATCH dtc take 2] Fix reserve map output for asm format.
From: Jerry Van Baren @ 2007-04-15 2:29 UTC (permalink / raw)
To: linuxppc-dev, jdl
Add extra reserve map slots output for asm format (previously done for dtb
output).
Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
---
Hi Jon, David,
Here is a patch that fixes the asm output without the (unnecessary)
calloc change.
Best regards,
gvb
flattree.c | 14 +++++++++++---
1 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/flattree.c b/flattree.c
index 151d16e..6f0c9b7 100644
--- a/flattree.c
+++ b/flattree.c
@@ -21,6 +21,9 @@
#include "dtc.h"
#include "flat_dt.h"
+#define WARNMSG(...) if (quiet < 1) fprintf(stderr, "Warning: " __VA_ARGS__)
+
+
#define FTF_FULLPATH 0x1
#define FTF_VARALIGN 0x2
#define FTF_NAMEPROPS 0x4
@@ -490,6 +493,9 @@ void dt_to_asm(FILE *f, struct boot_info *bi, int version, int boot_cpuid_phys)
(unsigned int)(re->re.size >> 32),
(unsigned int)(re->re.size & 0xffffffff));
}
+ for (i = 0; i < reservenum; i++) {
+ fprintf(f, "\t.long\t0, 0\n\t.long\t0, 0\n");
+ }
fprintf(f, "\t.long\t0, 0\n\t.long\t0, 0\n");
@@ -818,9 +824,11 @@ struct boot_info *dt_from_blob(FILE *f)
p = blob + sizeof(magic) + sizeof(totalsize);
while (sizeleft) {
- if (feof(f))
- die("EOF before reading %d bytes of DT blob\n",
- totalsize);
+ if (feof(f)) {
+ WARNMSG("EOF after reading %d of %d bytes of DT blob, assuming there is extra space in the blob.\n",
+ totalsize - sizeleft, totalsize);
+ break;
+ }
rc = fread(p, 1, sizeleft, f);
if (ferror(f))
--
1.4.4.4
^ permalink raw reply related
* Re: [PATCH dtc] Implement the -R option and add a -S option.
From: David Gibson @ 2007-04-15 2:22 UTC (permalink / raw)
To: Jerry Van Baren; +Cc: Linuxppc-dev
In-Reply-To: <46218A5D.80805@gmail.com>
On Sat, Apr 14, 2007 at 10:13:49PM -0400, Jerry Van Baren wrote:
> David Gibson wrote:
> > On Sat, Apr 14, 2007 at 08:58:49AM -0400, Jerry Van Baren wrote:
>
> [snip]
>
> >> On an unrelated related note, I don't believe my -R additions are
> >> actually putting out additional reserve map slots (easiest to see using
> >> the asm format output). I'm still trying to understand why not, it
> >> seemed pretty straight-forward. When I implemented it, I was looking at
> >> hexdumps of the dtb binary format and looking at the header and thought
> >> I had it working... using it with my u-boot mods shows no extra reserved
> >> slots. I'm looking into where I went wrong.
> >
> > Be careful to check the actual offsets. Bear in mind that objdump may
> > elide zero words. Also bear in mind that the only way a reader of the
> > device tree has of counting the number of reserve entries is stepping
> > through until it hits the terminating (0,0), so the extra entries will
> > just look like an early termination of the list. In this sense -R
> > doesn't add "extra slots", but just ensures that there is space after
> > the reserve map to add more entries.
>
> Hi David,
>
> It actually is OK, went back and verified it. I needed to modify the
> asm output to implement the -R extra slots which was confusing me (patch
> that you didn't like the calloc in ;-).
>
> The calloc change was actually window dressing, I was just being
> paranoid about a binary blob that is bigger than its contents (has extra
> space). The unused space is unused, so it doen't really matter if it is
> non-zero. I'll roll a new version.
Oh, I think zeroing it is correct, I'd just prefer it was done at the
callsite, rather than within xmalloc(). Strictly speaking you're
right, what's in the extra area shouldn't matter, but I don't like the
idea of potentially leaking random memory contents to file, which I
think could happen without a memset(). Because dtc is unpriveleged it
shouldn't actually matter, but it's ugly and a bad habit to establish.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
^ permalink raw reply
* Re: [PATCH dtc] Implement the -R option and add a -S option.
From: Jerry Van Baren @ 2007-04-15 2:13 UTC (permalink / raw)
To: Linuxppc-dev
In-Reply-To: <20070415004229.GD9104@localhost.localdomain>
David Gibson wrote:
> On Sat, Apr 14, 2007 at 08:58:49AM -0400, Jerry Van Baren wrote:
[snip]
>> On an unrelated related note, I don't believe my -R additions are
>> actually putting out additional reserve map slots (easiest to see using
>> the asm format output). I'm still trying to understand why not, it
>> seemed pretty straight-forward. When I implemented it, I was looking at
>> hexdumps of the dtb binary format and looking at the header and thought
>> I had it working... using it with my u-boot mods shows no extra reserved
>> slots. I'm looking into where I went wrong.
>
> Be careful to check the actual offsets. Bear in mind that objdump may
> elide zero words. Also bear in mind that the only way a reader of the
> device tree has of counting the number of reserve entries is stepping
> through until it hits the terminating (0,0), so the extra entries will
> just look like an early termination of the list. In this sense -R
> doesn't add "extra slots", but just ensures that there is space after
> the reserve map to add more entries.
Hi David,
It actually is OK, went back and verified it. I needed to modify the
asm output to implement the -R extra slots which was confusing me (patch
that you didn't like the calloc in ;-).
The calloc change was actually window dressing, I was just being
paranoid about a binary blob that is bigger than its contents (has extra
space). The unused space is unused, so it doen't really matter if it is
non-zero. I'll roll a new version.
gvb
^ permalink raw reply
* [RFC] Xilinx SystemACE device driver
From: Grant Likely @ 2007-04-15 1:23 UTC (permalink / raw)
To: linuxppc-embedded, Andrei Konovalov, Peter Korsgaard,
Rick Moleres, Stefan Roese
Add support for block device access to the Xilinx SystemACE Compact
flash interface
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
I think this driver is in pretty good shape. I've got a few things to
clean up a bit. Specifically, I'm still working on error handling and
making sure that the state machine is sane at all times.
I would appreciate any review/comments. One area where I am undecided is
the format of the state machine. The current code uses one big function
with a large switch() statment for each state. I'm considering breaking
this up into a seperate function for each state, and adding a static
state table with pointers to each state function.
I feel this driver is pretty close to done, and I'd like to get it into
mainline for the 2.6.22 timeframe.
Cheers,
g.
drivers/block/Kconfig | 6 +
drivers/block/Makefile | 1 +
drivers/block/xsysace.c | 1070 +++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 1077 insertions(+), 0 deletions(-)
create mode 100644 drivers/block/xsysace.c
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index 17ee97f..08ad23c 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -453,6 +453,12 @@ config ATA_OVER_ETH
This driver provides Support for ATA over Ethernet block
devices like the Coraid EtherDrive (R) Storage Blade.
+config XILINX_SYSACE
+ tristate "Xilinx SystemACE support"
+ depends on XILINX_VIRTEX
+ help
+ Include support for the Xilinx SystemACE CompactFlash interface
+
endmenu
endif
diff --git a/drivers/block/Makefile b/drivers/block/Makefile
index dd88e33..31ea323 100644
--- a/drivers/block/Makefile
+++ b/drivers/block/Makefile
@@ -28,4 +28,5 @@ obj-$(CONFIG_BLK_DEV_CRYPTOLOOP) += cryptoloop.o
obj-$(CONFIG_VIODASD) += viodasd.o
obj-$(CONFIG_BLK_DEV_SX8) += sx8.o
obj-$(CONFIG_BLK_DEV_UB) += ub.o
+obj-$(CONFIG_XILINX_SYSACE) += xsysace.o
diff --git a/drivers/block/xsysace.c b/drivers/block/xsysace.c
new file mode 100644
index 0000000..e8b4cd4
--- /dev/null
+++ b/drivers/block/xsysace.c
@@ -0,0 +1,1070 @@
+/*
+ * Xilinx SystemACE device driver
+ *
+ * Copyright 2007 Secret Lab Technologies Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ */
+
+/*
+ * The SystemACE chip is designed to configure FPGAs by loading an FPGA
+ * bitstream from a file on a CF card and squirting it into FPGAs connected
+ * to the SystemACE JTAG chain. It also has the advantage of providing an
+ * MPU interface which can be used to control the FPGA configuration process
+ * and to use the attached CF card for general purpose storage.
+ *
+ * This driver is a block device driver for the SystemACE.
+ *
+ * Initialization:
+ * The driver registers itself as a platform_device driver at module
+ * load time. The platform bus will take care of calling the
+ * ace_probe() method for all SystemACE instances in the system. Any
+ * number of SystemACE instances are supported. ace_probe() calls
+ * ace_setup() which initialized all data structures, reads the CF
+ * id structure and registers the device.
+ *
+ * Processing:
+ * Just about all of the heavy lifting in this driver is performed by
+ * a Finite State Machine (FSM). The driver needs to wait on a number
+ * of events; some raised by interrupts, some which need to be polled
+ * for. Describing all of the behaviour in a FSM seems to be the
+ * easiest way to keep the complexity low and make it easy to
+ * understand what the driver is doing. If the block ops or the
+ * request function need to interact with the hardware, then they
+ * simply need to flag the request and kick of FSM processing.
+ *
+ * The FSM itself is atomic-safe code which can be run from any
+ * context. The general process flow is:
+ * 1. obtain the ace->lock spinlock.
+ * 2. loop on ace_fsm_dostate() until the ace->fsm_continue flag is
+ * cleared.
+ * 3. release the lock.
+ *
+ * Individual states do not sleep in any way. If a condition needs to
+ * be waited for then the state much clear the fsm_continue flag and
+ * either schedule the FSM to be run again at a later time, or expect
+ * an interrupt to call the FSM when the desired condition is met.
+ *
+ * In normal operation, the FSM is processed at interrupt context
+ * either when the driver's tasklet is scheduled, or when an irq is
+ * raised by the hardware. The tasklet can be scheduled at any time.
+ * The request method in particular schedules the tasklet when a new
+ * request has been indicated by the block layer. Once started, the
+ * FSM proceeds as far as it can processing the request until it
+ * needs on a hardware event. At this point, it must yield execution.
+ *
+ * A state has two options when yielding execution:
+ * 1. ace_fsm_yield()
+ * - Call if need to poll for event.
+ * - clears the fsm_continue flag to exit the processing loop
+ * - reschedules the tasklet to run again as soon as possible
+ * 2. ace_fsm_yieldirq()
+ * - Call if an irq is expected from the HW
+ * - clears the fsm_continue flag to exit the processing loop
+ * - does not reschedule the tasklet so the FSM will not be processed
+ * again until an irq is received.
+ * After calling a yield function, the state must return control back
+ * to the FSM main loop.
+ *
+ * Additionally, the driver maintains a kernel timer which can process
+ * the FSM. If the FSM gets stalled, typically due to a missed
+ * interrupt, then the kernel timer will expire and the driver can
+ * continue where it left off.
+ *
+ * To Do:
+ * - Add FPGA configuration control interface.
+ * - Request major number from lanana
+ * - Add legacy device geometry ioctl
+ */
+
+#undef DEBUG
+#undef DEBUG_ENDIAN /* Uncomment to debug register endinaness */
+
+#include <linux/module.h>
+#include <linux/ctype.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/errno.h>
+#include <linux/kernel.h>
+#include <linux/delay.h>
+#include <linux/slab.h>
+#include <linux/blkdev.h>
+#include <linux/hdreg.h>
+#include <linux/platform_device.h>
+
+MODULE_AUTHOR("Grant Likely <grant.likely@secretlab.ca>");
+MODULE_DESCRIPTION("Xilinx SystemACE device driver");
+MODULE_LICENSE("GPL");
+
+/* SystemACE register definitions */
+#define ACE_BUSMODE (0x00)
+
+#define ACE_STATUS (0x04)
+#define ACE_STATUS_CFGLOCK (0x00000001)
+#define ACE_STATUS_MPULOCK (0x00000002)
+#define ACE_STATUS_CFGERROR (0x00000004) /* config controller error */
+#define ACE_STATUS_CFCERROR (0x00000008) /* CF controller error */
+#define ACE_STATUS_CFDETECT (0x00000010)
+#define ACE_STATUS_DATABUFRDY (0x00000020)
+#define ACE_STATUS_DATABUFMODE (0x00000040)
+#define ACE_STATUS_CFGDONE (0x00000080)
+#define ACE_STATUS_RDYFORCFCMD (0x00000100)
+#define ACE_STATUS_CFGMODEPIN (0x00000200)
+#define ACE_STATUS_CFGADDR_MASK (0x0000e000)
+#define ACE_STATUS_CFBSY (0x00020000)
+#define ACE_STATUS_CFRDY (0x00040000)
+#define ACE_STATUS_CFDWF (0x00080000)
+#define ACE_STATUS_CFDSC (0x00100000)
+#define ACE_STATUS_CFDRQ (0x00200000)
+#define ACE_STATUS_CFCORR (0x00400000)
+#define ACE_STATUS_CFERR (0x00800000)
+
+#define ACE_ERROR (0x08)
+#define ACE_CFGLBA (0x0c)
+#define ACE_MPULBA (0x10)
+
+#define ACE_SECCNTCMD (0x14)
+#define ACE_SECCNTCMD_RESET (0x0100)
+#define ACE_SECCNTCMD_IDENTIFY (0x0200)
+#define ACE_SECCNTCMD_READ_DATA (0x0300)
+#define ACE_SECCNTCMD_WRITE_DATA (0x0400)
+#define ACE_SECCNTCMD_ABORT (0x0600)
+
+#define ACE_VERSION (0x16)
+#define ACE_VERSION_REVISION_MASK (0x00FF)
+#define ACE_VERSION_MINOR_MASK (0x0F00)
+#define ACE_VERSION_MAJOR_MASK (0xF000)
+
+#define ACE_CTRL (0x18)
+#define ACE_CTRL_FORCELOCKREQ (0x0001)
+#define ACE_CTRL_LOCKREQ (0x0002)
+#define ACE_CTRL_FORCECFGADDR (0x0004)
+#define ACE_CTRL_FORCECFGMODE (0x0008)
+#define ACE_CTRL_CFGMODE (0x0010)
+#define ACE_CTRL_CFGSTART (0x0020)
+#define ACE_CTRL_CFGSEL (0x0040)
+#define ACE_CTRL_CFGRESET (0x0080)
+#define ACE_CTRL_DATABUFRDYIRQ (0x0100)
+#define ACE_CTRL_ERRORIRQ (0x0200)
+#define ACE_CTRL_CFGDONEIRQ (0x0400)
+#define ACE_CTRL_RESETIRQ (0x0800)
+#define ACE_CTRL_CFGPROG (0x1000)
+#define ACE_CTRL_CFGADDR_MASK (0xe000)
+
+#define ACE_FATSTAT (0x1c)
+
+#define ACE_NUM_MINORS 16
+#define ACE_BUF_PER_SECTOR (512 / 32) /* 512_byte_sector / 32_byte_fifo */
+
+/* ---------------------------------------------------------------------
+ * Low level register access
+ */
+
+/* register access macros */
+#if 1 /* Little endian 16-bit regs */
+#define ace_reg_read8(ace, reg) in_8(ace->baseaddr + reg)
+#define ace_reg_read16(ace, reg) in_le16(ace->baseaddr + reg)
+#define ace_reg_readdata(ace, reg) in_be16(ace->baseaddr + reg)
+#define ace_reg_read32(ace, reg) ((in_le16(ace->baseaddr + reg+2) << 16) | \
+ (in_le16(ace->baseaddr + reg)))
+#define ace_reg_write16(ace, reg, val) out_le16(ace->baseaddr + reg, val)
+#define ace_reg_writedata(ace, reg, val) out_be16(ace->baseaddr + reg, val)
+#define ace_reg_write32(ace, reg, val) { \
+ out_le16(ace->baseaddr + reg+2, (val) >> 16); \
+ out_le16(ace->baseaddr + reg, val); \
+ }
+#else /* Big endian 16-bit regs */
+#define ace_reg_read8(ace, reg) in_8(ace->baseaddr + reg)
+#define ace_reg_read16(ace, reg) in_be16(ace->baseaddr + reg)
+#define ace_reg_readdata(ace, reg) in_le16(ace->baseaddr + reg)
+#define ace_reg_read32(ace, reg) ((in_be16(ace->baseaddr + reg+2) << 16) | \
+ (in_be16(ace->baseaddr + reg)))
+#define ace_reg_write16(ace, reg, val) out_be16(ace->baseaddr + reg, val)
+#define ace_reg_writedata(ace, reg, val) out_le16(ace->baseaddr + reg, val)
+#define ace_reg_write32(ace, reg, val) { \
+ out_be16(ace->baseaddr + reg+2, (val) >> 16); \
+ out_be16(ace->baseaddr + reg, val); \
+ }
+#endif
+
+struct ace_device {
+ /* driver state data */
+ int id;
+ int media_change;
+ int users;
+ struct list_head list;
+
+ /* finite state machine data */
+ struct tasklet_struct fsm_tasklet;
+ uint fsm_task; /* Current activity (ACE_TASK_*) */
+ uint fsm_state; /* Current state (ACE_FSM_STATE_*) */
+ uint fsm_continue_flag; /* cleared to exit FSM mainloop */
+ uint fsm_iter_num;
+ struct timer_list stall_timer;
+
+ /* Transfer state/result, use for both id and block request */
+ struct request *req; /* request being processed */
+ uint16_t* data_ptr; /* pointer to I/O buffer */
+ int data_count; /* number of buffers remaining */
+ int data_result; /* Result of transfer; 0 := success */
+
+ int id_req_count; /* count of id requests */
+ int id_result;
+ struct completion id_completion;/* used when id requests finish */
+ int in_irq;
+
+ /* Details of hardware device */
+ ulong physaddr;
+ void* baseaddr;
+ int irq;
+ int bus_width; /* 0 := 8 bit; 1 := 16 bit */
+ int lock_count;
+
+ /* Block device data structures */
+ spinlock_t lock;
+ struct device *dev;
+ struct request_queue *queue;
+ struct gendisk *gd;
+
+ /* Inserted CF card parameters */
+ struct hd_driveid cf_id;
+};
+
+static LIST_HEAD(ace_instances);
+static int ace_major = 0;
+
+/* ---------------------------------------------------------------------
+ * Debug support functions
+ */
+
+#define ace_dbg(ace, format, arg...) dev_dbg(ace->dev, format, ## arg)
+#define ace_err(ace, format, arg...) dev_err(ace->dev, format, ## arg)
+#define ace_info(ace, format, arg...) dev_info(ace->dev, format, ## arg)
+#define ace_warn(ace, format, arg...) dev_warn(ace->dev, format, ## arg)
+#define ace_notice(ace, format, arg...) dev_notice(ace->dev, format, ## arg)
+
+#if defined(DEBUG)
+static void ace_dump_mem(void* base, int len)
+{
+ const char* ptr = base;
+ int i, j;
+
+ for (i = 0; i < len; i += 16) {
+ printk(KERN_INFO "%.8x:", i);
+ for (j = 0; j < 16; j++) {
+ if (!(j % 4))
+ printk(" ");
+ printk("%.2x", ptr[i+j]);
+ }
+ printk(" ");
+ for (j = 0; j < 16; j++)
+ printk("%c", isprint(ptr[i+j]) ? ptr[i+j] : '.');
+ printk("\n");
+ }
+}
+#else
+static inline void ace_dump_mem(void* base, int len) {}
+#endif
+
+static void ace_dump_regs(struct ace_device *ace)
+{
+
+#if defined(DEBUG_ENDIAN)
+ /* some test routines to see if 8 16 and 32 bit access is working */
+ ace_info(ace, "register dump:"); /* No '\n' needed! */
+ {
+ int i;
+ for (i = 0; i < 0x20; i++) {
+ if (!(i % 16))
+ printk("\n" KERN_INFO " %.2x:", i);
+ printk(" %.2x", ace_reg_read8(ace, i));
+ }
+ for (i = 0; i < 0x20; i+=2) {
+ if (!(i % 16))
+ printk("\n" KERN_INFO " %.2x:", i);
+ printk(" %.4x ", ace_reg_read16(ace, i));
+ }
+ for (i = 0; i < 0x20; i+=4) {
+ if (!(i % 16))
+ printk("\n" KERN_INFO " %.2x:", i);
+ printk(" %.8x ", ace_reg_read32(ace, i));
+ }
+ }
+ printk("\n");
+#endif
+
+ ace_info(ace, " ctrl: %.8x seccnt/cmd: %.4x ver:%.4x\n"
+ " status:%.8x mpu_lba:%.8x busmode:%4x\n"
+ " error: %.8x cfg_lba:%.8x fatstat:%.4x\n",
+ ace_reg_read32(ace, ACE_CTRL),
+ ace_reg_read16(ace, ACE_SECCNTCMD),
+ ace_reg_read16(ace, ACE_VERSION),
+ ace_reg_read32(ace, ACE_STATUS),
+ ace_reg_read32(ace, ACE_MPULBA),
+ ace_reg_read16(ace, ACE_BUSMODE),
+ ace_reg_read32(ace, ACE_ERROR),
+ ace_reg_read32(ace, ACE_CFGLBA),
+ ace_reg_read16(ace, ACE_FATSTAT));
+}
+
+void ace_fix_driveid (struct hd_driveid *id)
+{
+#ifndef __LITTLE_ENDIAN
+# ifdef __BIG_ENDIAN
+ /* The ace_reg_read16 macro handles 16 bit reads correctly, but
+ * 32bit values are partially little endian; swap the words
+ */
+ id->lba_capacity = ((id->lba_capacity >> 16) & 0x0000FFFF) |
+ ((id->lba_capacity << 16) & 0xFFFF0000);
+ id->spg = ((id->spg >> 16) & 0x0000FFFF) |
+ ((id->spg << 16) & 0xFFFF0000);
+# else
+# error "Please fix <asm/byteorder.h>"
+# endif
+#endif
+}
+
+/* ---------------------------------------------------------------------
+ * Finite State Machine (FSM) implementation
+ */
+
+/* FSM tasks; used to direct state transitions */
+#define ACE_TASK_IDLE 0
+#define ACE_TASK_IDENTIFY 1
+#define ACE_TASK_READ 2
+#define ACE_TASK_WRITE 3
+#define ACE_FSM_NUM_TASKS 4
+
+/* FSM state definitions */
+#define ACE_FSM_STATE_IDLE 0
+#define ACE_FSM_STATE_REQ_LOCK 1
+#define ACE_FSM_STATE_WAIT_LOCK 2
+#define ACE_FSM_STATE_WAIT_CFREADY 3
+#define ACE_FSM_STATE_IDENTIFY_PREPARE 4
+#define ACE_FSM_STATE_IDENTIFY_TRANSFER 5
+#define ACE_FSM_STATE_IDENTIFY_COMPLETE 6
+#define ACE_FSM_STATE_REQ_PREPARE 7
+#define ACE_FSM_STATE_REQ_TRANSFER 8
+#define ACE_FSM_STATE_REQ_COMPLETE 9
+#define ACE_FSM_NUM_STATES 10
+
+#if defined(DEBUG)
+const char* ace_statenames[ACE_FSM_NUM_STATES] = {
+ "idle",
+ "req lock",
+ "wait lock",
+ "wait cf ready",
+ "identify prepare",
+ "identify transfer",
+ "identify complete",
+ "request prepare",
+ "request transfer",
+ "request complete",
+};
+#endif
+
+/* Set flag to exit FSM loop and reschedule tasklet */
+static void inline ace_fsm_yield(struct ace_device *ace)
+{
+ ace_dbg(ace, "ace_fsm_yield()\n");
+ tasklet_schedule(&ace->fsm_tasklet);
+ ace->fsm_continue_flag = 0;
+}
+
+/* Set flag to exit FSM loop and wait for IRQ to reschedule tasklet */
+static void inline ace_fsm_yieldirq(struct ace_device *ace)
+{
+ ace_dbg(ace, "ace_fsm_yieldirq()\n");
+ ace->fsm_continue_flag = 0;
+}
+
+/* Get the next read/write request; ending requests that we don't handle */
+struct request* ace_get_next_request(request_queue_t *q)
+{
+ struct request *req;
+
+ while ((req = elv_next_request(q)) != NULL) {
+ if (blk_fs_request(req))
+ break;
+ end_request(req, 0);
+ }
+ return req;
+}
+
+static void ace_fsm_dostate(struct ace_device *ace)
+{
+ struct request *req;
+ uint32_t status;
+ uint16_t val;
+ int count;
+ int i;
+
+#if defined(DEBUG)
+ const char *name = "invalid";
+ if (ace->fsm_state < ACE_FSM_NUM_STATES)
+ name = ace_statenames[ace->fsm_state];
+ ace_info(ace, "fsm_state=%i \"%s\", id_req_count=%i\n",
+ ace->fsm_state, name, ace->id_req_count);
+#endif
+
+ switch (ace->fsm_state) {
+ case ACE_FSM_STATE_IDLE:
+ /* See if there is anything to do */
+ if (ace->id_req_count || ace_get_next_request(ace->queue)) {
+ ace->fsm_iter_num++;
+ ace->fsm_state = ACE_FSM_STATE_REQ_LOCK;
+ mod_timer(&ace->stall_timer, jiffies + HZ);
+ if (!timer_pending(&ace->stall_timer))
+ add_timer(&ace->stall_timer);
+ break;
+ }
+ del_timer(&ace->stall_timer);
+ ace->fsm_continue_flag = 0;
+ break;
+
+ case ACE_FSM_STATE_REQ_LOCK:
+ if (ace_reg_read16(ace, ACE_STATUS) & ACE_STATUS_MPULOCK) {
+ /* Already have the lock, jump to next state */
+ ace->fsm_state = ACE_FSM_STATE_WAIT_CFREADY;
+ break;
+ }
+
+ /* Request the lock */
+ val = ace_reg_read16(ace, ACE_CTRL);
+ ace_reg_write16(ace, ACE_CTRL, val | ACE_CTRL_LOCKREQ);
+ ace->fsm_state = ACE_FSM_STATE_WAIT_LOCK;
+ break;
+
+ case ACE_FSM_STATE_WAIT_LOCK:
+ if (ace_reg_read16(ace, ACE_STATUS) & ACE_STATUS_MPULOCK) {
+ /* got the lock; move to next state */
+ ace->fsm_state = ACE_FSM_STATE_WAIT_CFREADY;
+ break;
+ }
+
+ /* wait a bit for the lock */
+ ace_fsm_yield(ace);
+ break;
+
+ case ACE_FSM_STATE_WAIT_CFREADY:
+ status = ace_reg_read32(ace, ACE_STATUS);
+ if (!(status & ACE_STATUS_RDYFORCFCMD) ||
+ (status & ACE_STATUS_CFBSY)) {
+ /* CF card isn't ready; it needs to be polled */
+ ace_fsm_yield(ace);
+ break;
+ }
+
+ /* Device is ready for command; determine what to do next */
+ if (ace->id_req_count)
+ ace->fsm_state = ACE_FSM_STATE_IDENTIFY_PREPARE;
+ else
+ ace->fsm_state = ACE_FSM_STATE_REQ_PREPARE;
+ break;
+
+ case ACE_FSM_STATE_IDENTIFY_PREPARE:
+ /* Send identify command */
+ ace->fsm_task = ACE_TASK_IDENTIFY;
+ ace->data_ptr = (void*)&ace->cf_id;
+ ace->data_count = ACE_BUF_PER_SECTOR;
+ ace_reg_write16(ace, ACE_SECCNTCMD, ACE_SECCNTCMD_IDENTIFY);
+
+ /* As per datasheet, put config controller in reset */
+ val = ace_reg_read16(ace, ACE_CTRL);
+ ace_reg_write16(ace, ACE_CTRL, val | ACE_CTRL_CFGRESET);
+
+ /* irq handler takes over from this point; wait for the
+ * transfer to complete */
+ ace->fsm_state = ACE_FSM_STATE_IDENTIFY_TRANSFER;
+ ace_fsm_yieldirq(ace);
+ break;
+
+ case ACE_FSM_STATE_IDENTIFY_TRANSFER:
+ /* Check that the sysace is ready to receive data */
+ status = ace_reg_read32(ace, ACE_STATUS);
+ if (status & ACE_STATUS_CFBSY) {
+ ace_dbg(ace, "CFBSY set; t=%i iter=%i dc=%i\n",
+ ace->fsm_task, ace->fsm_iter_num,
+ ace->data_count);
+ ace_fsm_yield(ace);
+ break;
+ }
+ if (!(status & ACE_STATUS_DATABUFRDY)) {
+ ace_fsm_yield(ace);
+ break;
+ }
+
+ /* Transfer the next buffer */
+ i = 16;
+ while (i--)
+ *ace->data_ptr++ = ace_reg_read16(ace, 0x40);
+ ace->data_count--;
+
+ /* If there are still buffers to be transfers; jump out here */
+ if (ace->data_count != 0) {
+ ace_fsm_yieldirq(ace);
+ break;
+ }
+
+ /* transfer finished; kick state machine */
+ ace_dbg(ace, "identify finished\n");
+ ace->fsm_state = ACE_FSM_STATE_IDENTIFY_COMPLETE;
+ break;
+
+ case ACE_FSM_STATE_IDENTIFY_COMPLETE:
+ ace_fix_driveid(&ace->cf_id);
+ ace_dump_mem(&ace->cf_id, 512); /* Debug: Dump out disk ID */
+
+ if (ace->data_result) {
+ /* Error occured, disable the disk */
+ ace->media_change = 1;
+ set_capacity(ace->gd, 0);
+ ace_err(ace, "error fetching CF id (%i)\n",
+ ace->data_result);
+ } else {
+ ace->media_change = 0;
+
+ /* Record disk parameters */
+ set_capacity(ace->gd, ace->cf_id.lba_capacity);
+ ace_info(ace, "capacity: %i sectors\n",
+ ace->cf_id.lba_capacity);
+ }
+
+ /* We're done, drop to IDLE state and notify waiters */
+ ace->fsm_state = ACE_FSM_STATE_IDLE;
+ ace->id_result = ace->data_result;
+ while (ace->id_req_count) {
+ complete(&ace->id_completion);
+ ace->id_req_count--;
+ }
+ break;
+
+ case ACE_FSM_STATE_REQ_PREPARE:
+ req = ace_get_next_request(ace->queue);
+ if (!req) {
+ ace->fsm_state = ACE_FSM_STATE_IDLE;
+ break;
+ }
+
+ /* Okay, it's a data request, set it up for transfer */
+ ace_dbg(ace, "request: sec=%lx hcnt=%lx, ccnt=%x, dir=%i\n",
+ req->sector, req->hard_nr_sectors,
+ req->current_nr_sectors, rq_data_dir(req));
+
+ ace->req = req;
+ ace->data_ptr = (void*)req->buffer;
+ ace->data_count = req->current_nr_sectors * ACE_BUF_PER_SECTOR;
+ ace_reg_write32(ace, ACE_MPULBA, req->sector & 0x0FFFFFFF);
+
+ count = req->hard_nr_sectors;
+ if (rq_data_dir(req)) {
+ /* Kick off write request */
+ ace_dbg(ace, "write data\n");
+ ace->fsm_task = ACE_TASK_WRITE;
+ ace_reg_write16(ace, ACE_SECCNTCMD,
+ count | ACE_SECCNTCMD_WRITE_DATA);
+ } else {
+ /* Kick off read request */
+ ace_dbg(ace, "read data\n");
+ ace->fsm_task = ACE_TASK_READ;
+ ace_reg_write16(ace, ACE_SECCNTCMD,
+ count | ACE_SECCNTCMD_READ_DATA);
+ }
+
+ /* As per datasheet, put config controller in reset */
+ val = ace_reg_read16(ace, ACE_CTRL);
+ ace_reg_write16(ace, ACE_CTRL, val | ACE_CTRL_CFGRESET);
+
+ /* Move to the transfer state. The systemace will raise
+ * an interrupt once there is something to do
+ */
+ ace->fsm_state = ACE_FSM_STATE_REQ_TRANSFER;
+ if (ace->fsm_task == ACE_TASK_READ)
+ ace_fsm_yieldirq(ace); /* wait for data ready */
+ break;
+
+ case ACE_FSM_STATE_REQ_TRANSFER:
+ /* Check that the sysace is ready to receive data */
+ status = ace_reg_read32(ace, ACE_STATUS);
+ if (status & ACE_STATUS_CFBSY) {
+ ace_dbg(ace, "CFBSY set; t=%i iter=%i c=%i dc=%i irq=%i\n",
+ ace->fsm_task, ace->fsm_iter_num,
+ ace->req->current_nr_sectors*16,
+ ace->data_count, ace->in_irq);
+ ace_fsm_yield(ace); /* need to poll CFBSY bit */
+ break;
+ }
+ if (!(status & ACE_STATUS_DATABUFRDY)) {
+ ace_dbg(ace, "DATABUF not set; t=%i iter=%i c=%i dc=%i irq=%i\n",
+ ace->fsm_task, ace->fsm_iter_num,
+ ace->req->current_nr_sectors*16,
+ ace->data_count, ace->in_irq);
+ ace_fsm_yieldirq(ace);
+ break;
+ }
+
+ /* Transfer the next buffer */
+ i = 16;
+ if (ace->fsm_task == ACE_TASK_WRITE)
+ while (i--)
+ ace_reg_writedata(ace, 0x40, *ace->data_ptr++);
+ else
+ while (i--)
+ *ace->data_ptr++ = ace_reg_readdata(ace, 0x40);
+ ace->data_count--;
+
+ /* If there are still buffers to be transfers; jump out here */
+ if (ace->data_count != 0) {
+ ace_fsm_yieldirq(ace);
+ break;
+ }
+
+ /* bio finished; is there another one? */
+ i = ace->req->current_nr_sectors;
+ if (end_that_request_first(ace->req, 1, i)) {
+ /* ace_dbg(ace, "next block; h=%li c=%i\n",
+ * ace->req->hard_nr_sectors,
+ * ace->req->current_nr_sectors);
+ */
+ ace->data_ptr = (void*)ace->req->buffer;
+ ace->data_count = ace->req->current_nr_sectors * 16;
+ ace_fsm_yieldirq(ace);
+ break;
+ }
+
+ ace->fsm_state = ACE_FSM_STATE_REQ_COMPLETE;
+ break;
+
+ case ACE_FSM_STATE_REQ_COMPLETE:
+ /* Complete the block request */
+ blkdev_dequeue_request(ace->req);
+ end_that_request_last(ace->req, 1);
+ ace->req = NULL;
+
+ /* Finished request; go to idle state */
+ ace->fsm_state = ACE_FSM_STATE_IDLE;
+ break;
+
+ default:
+ ace->fsm_state = ACE_FSM_STATE_IDLE;
+ break;
+ }
+}
+
+static void ace_fsm_tasklet(ulong data)
+{
+ struct ace_device *ace = (void*)data;
+ unsigned long flags;
+
+ spin_lock_irqsave(&ace->lock, flags);
+
+ /* Loop over state machine until told to stop */
+ ace->fsm_continue_flag = 1;
+ while (ace->fsm_continue_flag)
+ ace_fsm_dostate(ace);
+
+ spin_unlock_irqrestore(&ace->lock, flags);
+}
+
+static void ace_stall_timer(ulong data)
+{
+ struct ace_device *ace = (void*)data;
+ unsigned long flags;
+
+ ace_warn(ace, "kicking stalled fsm; state=%i task=%i iter=%i dc=%i\n",
+ ace->fsm_state, ace->fsm_task, ace->fsm_iter_num,
+ ace->data_count);
+ spin_lock_irqsave(&ace->lock, flags);
+
+ /* Loop over state machine until told to stop */
+ ace->fsm_continue_flag = 1;
+ while (ace->fsm_continue_flag)
+ ace_fsm_dostate(ace);
+
+ /* Rearm the stall timer */
+ ace->stall_timer.expires = jiffies + HZ;
+ add_timer(&ace->stall_timer);
+
+ spin_unlock_irqrestore(&ace->lock, flags);
+}
+
+/* ---------------------------------------------------------------------
+ * Interrupt handling routines
+ */
+static int ace_interrupt_checkstate(struct ace_device *ace)
+{
+ uint32_t sreg = ace_reg_read32(ace, ACE_STATUS);
+ uint16_t creg = ace_reg_read16(ace, ACE_CTRL);
+
+ /* Check for error occurance */
+ if ((sreg & (ACE_STATUS_CFGERROR | ACE_STATUS_CFCERROR)) &&
+ (creg & ACE_CTRL_ERRORIRQ)) {
+ ace_err(ace, "transfer failure\n");
+ ace_dump_regs(ace);
+ return -EIO;
+ }
+
+ return 0;
+}
+
+static irqreturn_t ace_interrupt(int irq, void *dev_id)
+{
+ uint16_t creg;
+ struct ace_device *ace = dev_id;
+ unsigned long flags;
+
+ /* be safe and get the lock */
+ spin_lock_irqsave(&ace->lock, flags);
+ ace->in_irq = 1;
+
+ /* clear the interrupt */
+ creg = ace_reg_read16(ace, ACE_CTRL);
+ ace_reg_write16(ace, ACE_CTRL, creg | ACE_CTRL_RESETIRQ);
+ ace_reg_write16(ace, ACE_CTRL, creg);
+
+ /* check for IO failures */
+ if (ace_interrupt_checkstate(ace))
+ ace->data_result = -EIO;
+
+ if (ace->fsm_task == 0) {
+ ace_err(ace, "spurious irq; stat=%.8x ctrl=%.8x cmd=%.4x\n",
+ ace_reg_read32(ace, ACE_STATUS),
+ ace_reg_read32(ace, ACE_CTRL),
+ ace_reg_read16(ace, ACE_SECCNTCMD));
+ ace_err(ace, "fsm_task=%i fsm_state=%i data_count=%i\n",
+ ace->fsm_task, ace->fsm_state, ace->data_count);
+ }
+
+ /* Loop over state machine until told to stop */
+ ace->fsm_continue_flag = 1;
+ while (ace->fsm_continue_flag)
+ ace_fsm_dostate(ace);
+
+ /* done with interrupt; drop the lock */
+ ace->in_irq = 0;
+ spin_unlock_irqrestore(&ace->lock, flags);
+
+ return IRQ_HANDLED;
+}
+
+/* ---------------------------------------------------------------------
+ * Block ops
+ */
+static void ace_request(request_queue_t *q)
+{
+ struct request *req;
+ struct ace_device *ace;
+
+ req = ace_get_next_request(q);
+
+ if (req) {
+ ace = req->rq_disk->private_data;
+ tasklet_schedule(&ace->fsm_tasklet);
+ }
+}
+
+static int ace_media_changed(struct gendisk *gd)
+{
+ struct ace_device *ace = gd->private_data;
+ ace_dbg(ace, "ace_media_changed(): %i\n", ace->media_change);
+
+ return ace->media_change;
+}
+
+static int ace_revalidate_disk(struct gendisk *gd)
+{
+ struct ace_device *ace = gd->private_data;
+ ulong flags;
+
+ ace_dbg(ace, "ace_revalidate_disk()\n");
+
+ if (ace->media_change) {
+ ace_dbg(ace, "requesting cf id and scheduling tasklet\n");
+
+ spin_lock_irqsave(&ace->lock, flags);
+ ace->id_req_count++;
+ spin_unlock_irqrestore(&ace->lock, flags);
+
+ tasklet_schedule(&ace->fsm_tasklet);
+ wait_for_completion(&ace->id_completion);
+ }
+
+ ace_dbg(ace, "revalidate complete\n");
+ return ace->id_result;
+}
+
+static int ace_open(struct inode *inode, struct file *filp)
+{
+ struct ace_device *ace = inode->i_bdev->bd_disk->private_data;
+ unsigned long flags;
+
+ ace_dbg(ace, "ace_open() users=%i\n", ace->users+1);
+
+ filp->private_data = ace;
+ spin_lock_irqsave(&ace->lock, flags);
+ ace->users++;
+ spin_unlock_irqrestore(&ace->lock, flags);
+
+ check_disk_change(inode->i_bdev);
+ return 0;
+}
+
+static int ace_release(struct inode *inode, struct file *filp)
+{
+ struct ace_device *ace = inode->i_bdev->bd_disk->private_data;
+ unsigned long flags;
+ uint16_t val;
+
+ ace_dbg(ace, "ace_release() users=%i\n", ace->users-1);
+
+ spin_lock_irqsave(&ace->lock, flags);
+ ace->users--;
+ if (ace->users == 0) {
+ val = ace_reg_read16(ace, ACE_CTRL);
+ ace_reg_write16(ace, ACE_CTRL, val & ~ACE_CTRL_LOCKREQ);
+ }
+ spin_unlock_irqrestore(&ace->lock, flags);
+ return 0;
+}
+
+static int ace_ioctl(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg)
+{
+ struct ace_device *ace = inode->i_bdev->bd_disk->private_data;
+ ace_dbg(ace, "ace_ioctl()\n");
+
+ return -ENOTTY;
+}
+
+static struct block_device_operations ace_fops = {
+ .owner = THIS_MODULE,
+ .open = ace_open,
+ .release = ace_release,
+ .media_changed = ace_media_changed,
+ .revalidate_disk = ace_revalidate_disk,
+ .ioctl = ace_ioctl,
+};
+
+/* --------------------------------------------------------------------
+ * SystemACE device setup/teardown code
+ */
+static int ace_setup(struct ace_device *ace)
+{
+ uint16_t version;
+ uint16_t val;
+ int rc;
+
+ spin_lock_init(&ace->lock);
+ init_completion(&ace->id_completion);
+
+ /*
+ * Map the device
+ */
+ ace->baseaddr = ioremap(ace->physaddr, 0x80);
+ if (!ace->baseaddr)
+ goto err_ioremap;
+
+ if (ace->irq != NO_IRQ) {
+ rc = request_irq(ace->irq, ace_interrupt, 0, "systemace", ace);
+ if (rc) {
+ /* Failure - fall back to polled mode */
+ ace_err(ace, "request_irq failed\n");
+ ace->irq = NO_IRQ;
+ }
+ }
+
+ /*
+ * Initialize the state machine tasklet and stall timer
+ */
+ tasklet_init(&ace->fsm_tasklet, ace_fsm_tasklet, (ulong)ace);
+ init_timer(&ace->stall_timer);
+ ace->stall_timer.function = ace_stall_timer;
+ ace->stall_timer.data = (ulong)ace;
+
+ /*
+ * Initialize the request queue
+ */
+ ace->queue = blk_init_queue(ace_request, &ace->lock);
+ if (ace->queue == NULL)
+ goto err_blk_initq;
+ blk_queue_hardsect_size(ace->queue, 512);
+
+ /*
+ * Allocate and initialize GD structure
+ */
+ ace->gd = alloc_disk(ACE_NUM_MINORS);
+ if (!ace->gd)
+ goto err_alloc_disk;
+
+ ace->gd->major = ace_major;
+ ace->gd->first_minor = ace->id * ACE_NUM_MINORS;
+ ace->gd->fops = &ace_fops;
+ ace->gd->queue = ace->queue;
+ ace->gd->private_data = ace;
+ snprintf(ace->gd->disk_name, 32, "xs%c", ace->id + 'a');
+ device_rename(ace->dev, ace->gd->disk_name);
+
+ /* set 16-bit bus width */
+ ace_reg_write16(ace, ACE_BUSMODE, 0x0001);
+
+ /* Make sure version register is sane */
+ version = ace_reg_read16(ace, ACE_VERSION);
+ if ((version == 0) || (version == 0xFFFF))
+ goto err_read;
+
+ /* Put sysace in a sane state by clearing most control reg bits */
+ ace_reg_write16(ace, ACE_CTRL, ACE_CTRL_FORCECFGMODE |
+ ACE_CTRL_DATABUFRDYIRQ |
+ ACE_CTRL_ERRORIRQ);
+
+ /* Enable interrupts */
+ val = ace_reg_read16(ace, ACE_CTRL);
+ val |= ACE_CTRL_DATABUFRDYIRQ | ACE_CTRL_ERRORIRQ;
+ ace_reg_write16(ace, ACE_CTRL, val);
+
+ /* Print the identification */
+ ace_info(ace, "Xilinx SystemACE revision %i.%i.%i\n",
+ (version>>12)&0xf, (version>>8)&0x0f, version&0xff);
+ ace_dbg(ace, "physaddr 0x%lx, mapped to 0x%p, irq=%i\n",
+ ace->physaddr, ace->baseaddr, ace->irq);
+
+ ace->media_change = 1;
+ ace_revalidate_disk(ace->gd);
+
+ /* Make the sysace device 'live' */
+ list_add(&ace->list, &ace_instances);
+ add_disk(ace->gd);
+
+ return 0;
+
+err_read:
+ put_disk(ace->gd);
+err_alloc_disk:
+ blk_cleanup_queue(ace->queue);
+err_blk_initq:
+ iounmap(ace->baseaddr);
+ if (ace->irq != NO_IRQ)
+ free_irq(ace->irq, ace);
+err_ioremap:
+ printk(KERN_INFO "xsysace: error initializing device at 0x%lx\n",
+ ace->physaddr);
+ return -ENOMEM;
+}
+
+static void ace_teardown(struct ace_device *ace)
+{
+ if (ace->gd) {
+ del_gendisk(ace->gd);
+ put_disk(ace->gd);
+ }
+
+ if (ace->queue)
+ blk_cleanup_queue(ace->queue);
+
+ tasklet_kill(&ace->fsm_tasklet);
+
+ if (ace->irq != NO_IRQ)
+ free_irq(ace->irq, ace);
+
+ iounmap(ace->baseaddr);
+}
+
+/* ---------------------------------------------------------------------
+ * Platform Bus Support
+ */
+
+static int ace_probe(struct device *device)
+{
+ struct platform_device *dev = to_platform_device(device);
+ struct ace_device *ace;
+ int i;
+
+ dev_dbg(device, "ace_probe(%p)\n", device);
+
+ /*
+ * Allocate the ace device structure
+ */
+ ace = kmalloc(sizeof(struct ace_device), GFP_KERNEL);
+ if (!ace)
+ goto err_alloc;
+ memset(ace, 0, sizeof(struct ace_device));
+
+ ace->dev = device;
+ ace->id = dev->id;
+ ace->irq = NO_IRQ;
+
+ for (i = 0; i < dev->num_resources; i++) {
+ if (dev->resource[i].flags & IORESOURCE_MEM)
+ ace->physaddr = dev->resource[i].start;
+ if (dev->resource[i].flags & IORESOURCE_IRQ)
+ ace->irq = dev->resource[i].start;
+ }
+
+ dev_set_drvdata(&dev->dev, ace);
+
+ /* Call the bus-independant setup code */
+ if (ace_setup(ace) != 0)
+ goto err_setup;
+
+ return 0;
+
+err_setup:
+ dev_set_drvdata(&dev->dev, NULL);
+ kfree(ace);
+err_alloc:
+ printk(KERN_ERR "xsysace: could not initialize device\n");
+ return -ENOMEM;
+}
+
+/*
+ * Platform bus remove() method
+ */
+static int ace_remove(struct device *device)
+{
+ struct ace_device *ace = dev_get_drvdata(device);
+
+ dev_dbg(device, "ace_remove(%p)\n", device);
+
+ if (ace) {
+ ace_teardown(ace);
+ kfree(ace);
+ }
+
+ return 0;
+}
+
+static struct device_driver ace_driver = {
+ .name = "xsysace",
+ .bus = &platform_bus_type,
+ .probe = ace_probe,
+ .remove = ace_remove,
+};
+
+/* ---------------------------------------------------------------------
+ * Module init/exit routines
+ */
+static int __init ace_init(void)
+{
+ ace_major = register_blkdev(ace_major, "xsysace");
+ if (ace_major <= 0) {
+ printk(KERN_WARNING "xsysace: register_blkdev() failed\n");
+ return ace_major;
+ }
+
+ pr_debug("Registering Xilinx SystemACE driver, major=%i\n", ace_major);
+ return driver_register(&ace_driver);
+}
+
+static void __exit ace_exit(void)
+{
+ pr_debug("Unregistering Xilinx SystemACE driver\n");
+ driver_unregister(&ace_driver);
+ if (unregister_blkdev(ace_major, "xsysace"))
+ printk(KERN_WARNING "systemace unregister_blkdev(%i) failed\n",
+ ace_major);
+}
+
+module_init(ace_init);
+module_exit(ace_exit);
--
1.5.1
^ permalink raw reply related
* Re: [PATCH dtc] Add -o <output file> to the usage message.
From: David Gibson @ 2007-04-15 0:44 UTC (permalink / raw)
To: Jerry Van Baren; +Cc: linuxppc-dev, jdl
In-Reply-To: <20070414221647.GB23870@dellserver.lan>
On Sat, Apr 14, 2007 at 06:16:47PM -0400, Jerry Van Baren wrote:
>
> Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
> ---
>
> Hi Jon,
>
> It turns out -o <file> was there all along, just not in the usage. :-)
Oops..
> (Jon: sorry for the dup, I messed up the linuxppc-dev@ozlabs.org address
> the first time).
>
> Best regards,
> gvb
>
>
> dtc.c | 1 +
> 1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/dtc.c b/dtc.c
> index a94a402..5767834 100644
> --- a/dtc.c
> +++ b/dtc.c
> @@ -83,6 +83,7 @@ static void usage(void)
> fprintf(stderr, "\t\t\tdts - device tree source text\n");
> fprintf(stderr, "\t\t\tdtb - device tree blob\n");
> fprintf(stderr, "\t\t\tfs - /proc/device-tree style directory\n");
> + fprintf(stderr, "\t-o <output file>\n");
> fprintf(stderr, "\t-O <output format>\n");
> fprintf(stderr, "\t\tOutput formats are:\n");
> fprintf(stderr, "\t\t\tdts - device tree source text\n");
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
^ permalink raw reply
* Re: [PATCH dtc] Fix reserve map output for asm format.
From: David Gibson @ 2007-04-15 0:44 UTC (permalink / raw)
To: Jerry Van Baren; +Cc: linuxppc-dev, jdl
In-Reply-To: <20070414221526.GA23870@dellserver.lan>
On Sat, Apr 14, 2007 at 06:15:27PM -0400, Jerry Van Baren wrote:
> Add extra reserve map slots output for asm format (previously done for dtb
> output).
> Use cmalloc to pre-zero memory (for dtb input) and handle dtb (binary)
> input being shorter than the total blob length (result of putting
> extra space in the blob).
>
> Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
> ---
>
> Hi Jon:
>
> Some simple fixes for handling extra reserve slots and extra space in
> the blob.
>
> Best regards,
> gvb
>
> dtc.h | 4 ++--
> flattree.c | 14 +++++++++++---
> 2 files changed, 13 insertions(+), 5 deletions(-)
>
> diff --git a/dtc.h b/dtc.h
> index 8cfe1a1..e77f9d1 100644
> --- a/dtc.h
> +++ b/dtc.h
> @@ -55,10 +55,10 @@ static inline void die(char * str, ...)
>
> static inline void *xmalloc(size_t len)
> {
> - void *new = malloc(len);
> + void *new = calloc(len, 1);
>
> if (! new)
> - die("malloc() failed\n");
> + die("calloc() failed\n");
>
> return new;
> }
I'm less that thrilled about this change. There's a semi-standard
definition of "xmalloc()" and using callc() isn't it. I'd prefer the
clearing was done in the caller.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
^ permalink raw reply
* Re: [PATCH dtc] Implement the -R option and add a -S option.
From: David Gibson @ 2007-04-15 0:42 UTC (permalink / raw)
To: Jerry Van Baren; +Cc: Linuxppc-dev
In-Reply-To: <4620D009.1000800@gmail.com>
On Sat, Apr 14, 2007 at 08:58:49AM -0400, Jerry Van Baren wrote:
> David Gibson wrote:
> > On Thu, Apr 05, 2007 at 01:10:40PM -0400, Jerry Van Baren wrote:
> >> Scott Wood wrote:
> >>> On Wed, Apr 04, 2007 at 10:04:33PM -0400, Jerry Van Baren wrote:
> >>>> Implement the -R <number> option to add memory reserve slots.
> >>>> Add a -S <size> option makes the blob at least this number of bytes.
> >>> Wouldn't it be better to just specify the amount of extra space, instead
> >>> of the minimum total space? That way, you only need to know what you
> >>> intend to add, not how much is already there.
> >>>
> >>> -Scott
> >> I thought briefly about this, but decided to implement a fixed size so
> >> that someone could allocate, say, 8K of memory in their memory map
> >> (likely flash) and know their blob would fit.
> >>
> >> Maybe we need a little -s option to say "add -s bytes".
> >
> > I think having both options would be a good idea. It would also be
> > nice to have options to do this from the dts file (something similar
> > to /memreserve/).
> >
> >> Jon suggested a --stats option to print out the important statistics.
> >> That would also be a good enhancement.
> >
> > Ok. How would you envisage this working?
> >
> > I've thought for some time that it would be a good idea to add an
> > "info" output mode. In that mode instead of outputting a converted
> > device tree, it would give various bits of info on the input tree.
> > This would include things like the header field debugging information
> > that's currently output as pseudo-error messages when using dtb input.
> >
> > I'm not sure to what extent your "--stats" idea would overlap with
> > that.
>
> Hi David,
>
> Well, that was Jon's suggestion/idea so I have not thought about it
> much. It would probably overlap 100% with your --info idea, with the
> exception that Jon's suggestion would also put out the blob.
Well, my idea wasn't a new --info but rather "-O info", if that
distinction makes sense.
> Since the dtc puts out the blob to sdtout, this actually is problematic.
> I presume that is why you suggest inhibiting output. Using stderr
> would sorta bypass that problem, but is not ideal (IMHO).
Yes, that's more or less precisely my reasoning.
> Is there any reason we don't have a -o option to direct the compiled
> blob output to a file? Since the usual use is to write to a file, it
> would free up stdout for (info/stats) outputs.
We do have a -o option...
> On an unrelated related note, I don't believe my -R additions are
> actually putting out additional reserve map slots (easiest to see using
> the asm format output). I'm still trying to understand why not, it
> seemed pretty straight-forward. When I implemented it, I was looking at
> hexdumps of the dtb binary format and looking at the header and thought
> I had it working... using it with my u-boot mods shows no extra reserved
> slots. I'm looking into where I went wrong.
Be careful to check the actual offsets. Bear in mind that objdump may
elide zero words. Also bear in mind that the only way a reader of the
device tree has of counting the number of reserve entries is stepping
through until it hits the terminating (0,0), so the extra entries will
just look like an early termination of the list. In this sense -R
doesn't add "extra slots", but just ensures that there is space after
the reserve map to add more entries.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
^ permalink raw reply
* [PATCH dtc] Add -o <output file> to the usage message.
From: Jerry Van Baren @ 2007-04-14 22:16 UTC (permalink / raw)
To: linuxppc-dev, jdl
Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
---
Hi Jon,
It turns out -o <file> was there all along, just not in the usage. :-)
(Jon: sorry for the dup, I messed up the linuxppc-dev@ozlabs.org address
the first time).
Best regards,
gvb
dtc.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/dtc.c b/dtc.c
index a94a402..5767834 100644
--- a/dtc.c
+++ b/dtc.c
@@ -83,6 +83,7 @@ static void usage(void)
fprintf(stderr, "\t\t\tdts - device tree source text\n");
fprintf(stderr, "\t\t\tdtb - device tree blob\n");
fprintf(stderr, "\t\t\tfs - /proc/device-tree style directory\n");
+ fprintf(stderr, "\t-o <output file>\n");
fprintf(stderr, "\t-O <output format>\n");
fprintf(stderr, "\t\tOutput formats are:\n");
fprintf(stderr, "\t\t\tdts - device tree source text\n");
--
1.4.4.4
^ permalink raw reply related
* [PATCH dtc] Fix reserve map output for asm format.
From: Jerry Van Baren @ 2007-04-14 22:15 UTC (permalink / raw)
To: linuxppc-dev, jdl
Add extra reserve map slots output for asm format (previously done for dtb
output).
Use cmalloc to pre-zero memory (for dtb input) and handle dtb (binary)
input being shorter than the total blob length (result of putting
extra space in the blob).
Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
---
Hi Jon:
Some simple fixes for handling extra reserve slots and extra space in
the blob.
Best regards,
gvb
dtc.h | 4 ++--
flattree.c | 14 +++++++++++---
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/dtc.h b/dtc.h
index 8cfe1a1..e77f9d1 100644
--- a/dtc.h
+++ b/dtc.h
@@ -55,10 +55,10 @@ static inline void die(char * str, ...)
static inline void *xmalloc(size_t len)
{
- void *new = malloc(len);
+ void *new = calloc(len, 1);
if (! new)
- die("malloc() failed\n");
+ die("calloc() failed\n");
return new;
}
diff --git a/flattree.c b/flattree.c
index 151d16e..6f0c9b7 100644
--- a/flattree.c
+++ b/flattree.c
@@ -21,6 +21,9 @@
#include "dtc.h"
#include "flat_dt.h"
+#define WARNMSG(...) if (quiet < 1) fprintf(stderr, "Warning: " __VA_ARGS__)
+
+
#define FTF_FULLPATH 0x1
#define FTF_VARALIGN 0x2
#define FTF_NAMEPROPS 0x4
@@ -490,6 +493,9 @@ void dt_to_asm(FILE *f, struct boot_info *bi, int version, int boot_cpuid_phys)
(unsigned int)(re->re.size >> 32),
(unsigned int)(re->re.size & 0xffffffff));
}
+ for (i = 0; i < reservenum; i++) {
+ fprintf(f, "\t.long\t0, 0\n\t.long\t0, 0\n");
+ }
fprintf(f, "\t.long\t0, 0\n\t.long\t0, 0\n");
@@ -818,9 +824,11 @@ struct boot_info *dt_from_blob(FILE *f)
p = blob + sizeof(magic) + sizeof(totalsize);
while (sizeleft) {
- if (feof(f))
- die("EOF before reading %d bytes of DT blob\n",
- totalsize);
+ if (feof(f)) {
+ WARNMSG("EOF after reading %d of %d bytes of DT blob, assuming there is extra space in the blob.\n",
+ totalsize - sizeleft, totalsize);
+ break;
+ }
rc = fread(p, 1, sizeleft, f);
if (ferror(f))
--
1.4.4.4
^ permalink raw reply related
* Re: [PATCH] hvc_console polling mode timer backoff
From: Milton Miller @ 2007-04-14 19:42 UTC (permalink / raw)
To: Michael Ellerman, Will Schmidt; +Cc: Olof Johansson, ppcdev
In-Reply-To: <1176450459.4734.32.camel@concordia.ozlabs.ibm.com>
Michael Ellerman wrote:
> + * msleep until we reach the max. This may be noticable as a brief
> (average
> + * one second) delay on the console before the console responds to
> input when
> + * there has been no input for sometime.
> + */
> +#define MIN_TIMEOUT (10)
> +#define MAX_TIMEOUT (2000)
> +static u32 timeout = MIN_TIMEOUT;
Did you consider making MAX_TIMEOUT a module parameter? It could then
be changed at runtime through /sys/modules/.
> +
> + if (timeout < MAX_TIMEOUT)
> + timeout += (timeout >> 6) + 1;
Keeping MIN_TIMEOUT a define is okay with me, and the code will
naturally ignore max < MIN. It may overshoot timeout by 1/64th.
I doubt we would worry about the overflow case, because by then
the timeout would have been quite long, and the user would like
it to be short again.
milton
^ permalink raw reply
* RE: Linux 2.6 and uboot
From: Guennadi Liakhovetski @ 2007-04-14 19:01 UTC (permalink / raw)
To: Clint Thomas; +Cc: linuxppc-embedded
In-Reply-To: <3C02138692C13C4BB675FE7EA24095293284E0@bluefin.Soneticom.local>
On Fri, 13 Apr 2007, Clint Thomas wrote:
> mice: PS/2 mouse device common for all mice
> i2c /dev entries driver
> TCP cubic registered
> NET: Registered protocol family 1
> NET: Registered protocol family 17
>
> This is the point where it stops booting.
It might be just the point before root is mounted... That's what I'd check
anyway... I see it has 2 eth interfaces. Can it be that their order has
changed and it's trying the wrong one?
Thanks
Guennadi
---
Guennadi Liakhovetski
^ permalink raw reply
* Re: [PATCH dtc] Implement the -R option and add a -S option.
From: Jerry Van Baren @ 2007-04-14 16:43 UTC (permalink / raw)
To: Linuxppc-dev
In-Reply-To: <4620D009.1000800@gmail.com>
Jerry Van Baren wrote:
[snip]
> On an unrelated related note, I don't believe my -R additions are
> actually putting out additional reserve map slots (easiest to see using
> the asm format output). I'm still trying to understand why not, it
> seemed pretty straight-forward. When I implemented it, I was looking at
> hexdumps of the dtb binary format and looking at the header and thought
> I had it working... using it with my u-boot mods shows no extra reserved
> slots. I'm looking into where I went wrong.
OK, I didn't add a reserve additional slots output in the asm emission
code, so that was a pretty simple fix. I'll provide a patch after a bit
more testing.
gvb
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox