[U-Boot-Users] [PATCH 1/3] Add the RapidIO framework for U-Boot
Zhang Wei
wei.zhang at freescale.com
Thu Jan 10 12:38:00 CET 2008
The patch adds the RapidIO framework into U-Boot. The board configuration
can be added into individual rio_init_board() function. Some functions
about RapidIO can be added later.
The support for Freescale PowerPC RapidIO controller is also added.
Signed-off-by: Zhang Wei <wei.zhang at freescale.com>
---
Makefile | 1 +
drivers/rio/Makefile | 35 ++++++++++++++++++++++++++
drivers/rio/fsl_rio.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++
drivers/rio/rio.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++
include/common.h | 3 ++
include/rio.h | 46 ++++++++++++++++++++++++++++++++++
include/rio_ids.h | 9 +++++++
lib_ppc/board.c | 5 ++++
8 files changed, 228 insertions(+), 0 deletions(-)
create mode 100644 drivers/rio/Makefile
create mode 100644 drivers/rio/fsl_rio.c
create mode 100644 drivers/rio/rio.c
create mode 100644 include/rio.h
create mode 100644 include/rio_ids.h
diff --git a/Makefile b/Makefile
index 1983ca0..1f3f26a 100644
--- a/Makefile
+++ b/Makefile
@@ -228,6 +228,7 @@ endif
ifeq ($(CPU),mpc85xx)
LIBS += drivers/qe/qe.a
endif
+LIBS += drivers/rio/librio.a
LIBS += drivers/rtc/librtc.a
LIBS += drivers/serial/libserial.a
LIBS += drivers/usb/libusb.a
diff --git a/drivers/rio/Makefile b/drivers/rio/Makefile
new file mode 100644
index 0000000..4b940c2
--- /dev/null
+++ b/drivers/rio/Makefile
@@ -0,0 +1,35 @@
+#
+# Copyright (C) 2008 Freescale Semiconductor, Inc. All rights reserved.
+#
+# Author: Zhang Wei, wei.zhang at freescale.com, Jan 2008
+#
+# This 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 $(TOPDIR)/config.mk
+
+LIB := $(obj)librio.a
+
+COBJS-y += rio.o
+COBJS-y += fsl_rio.o
+
+COBJS := $(COBJS-y)
+SRCS := $(COBJS:.o=.c)
+OBJS := $(addprefix $(obj),$(COBJS))
+
+all: $(LIB)
+
+$(LIB): $(obj).depend $(OBJS)
+ $(AR) $(ARFLAGS) $@ $(OBJS)
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
diff --git a/drivers/rio/fsl_rio.c b/drivers/rio/fsl_rio.c
new file mode 100644
index 0000000..c8bfa92
--- /dev/null
+++ b/drivers/rio/fsl_rio.c
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2008 Freescale Semiconductor, Inc. All rights reserved.
+ *
+ * Author: Zhang Wei, wei.zhang at freescale.com, Jan 2008
+ *
+ * Description:
+ * Freescale PowerPC RapidIO controller initialization file.
+ *
+ * This 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 <common.h>
+
+#ifdef CONFIG_RAPIDIO
+#include <command.h>
+#include <malloc.h>
+#include <rio.h>
+#include <rio_ids.h>
+
+#include <asm/processor.h>
+#include <asm/io.h>
+#include <asm/immap_86xx.h>
+#include <asm/io.h>
+
+void fsl_rio_init(void *base, int busno)
+{
+ struct rio_dev *dev;
+ volatile ccsr_rio_t *rio = base;
+ struct rio_controller *hose;
+
+ dev = malloc(sizeof(struct rio_dev));
+ memset(dev, 0, sizeof(struct rio_dev));
+
+ dev->vendor = in_be32(&rio->didcar) & 0xffff;
+ dev->device = (in_be32(&rio->didcar) >> 16) & 0xffff;
+
+ hose = malloc(sizeof(struct rio_controller));
+ memset(hose, 0, sizeof(struct rio_controller));
+
+ INIT_LIST_HEAD(&hose->dev_list);
+ hose->busno = busno;
+ hose->base = base;
+ hose->self = dev;
+ list_add_tail(&hose->node, &rio_hose_list);
+
+ printf("RIO%d (%04x:%04x) on 0x%08x\n", hose->busno, dev->vendor,
+ dev->device, base);
+}
+
+void fsl_rio_quirk(struct rio_controller *hose, struct rio_dev *rdev)
+{
+#ifdef FSL_RIO_IP_V2
+ volatile ccsr_rio_t *rio = hose->base;
+ /* Set the controller to accept all packets
+ * without checking the target ID
+ */
+ out_be32(&rio->ptaacr, 1);
+#endif
+}
+#endif
diff --git a/drivers/rio/rio.c b/drivers/rio/rio.c
new file mode 100644
index 0000000..9391384
--- /dev/null
+++ b/drivers/rio/rio.c
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2007-2008 Freescale Semiconductor, Inc. All rights reserved.
+ *
+ * Author: Zhang Wei, wei.zhang at freescale.com, Jun 2007
+ *
+ * Description:
+ * RapidIO initialization file.
+ *
+ * This 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 <common.h>
+
+#ifdef CONFIG_RAPIDIO
+
+#include <command.h>
+#include <linux/list.h>
+#include <rio.h>
+#include <rio_ids.h>
+#include <asm/processor.h>
+#include <asm/io.h>
+
+struct list_head rio_hose_list;
+
+struct rio_quirk rio_post_quirk[] = {
+ {RIO_VENDOR_ID_FREESCALE, RIO_DEVICE_ID_MPC8548E, fsl_rio_quirk},
+ {RIO_VENDOR_ID_FREESCALE, RIO_DEVICE_ID_MPC8548, fsl_rio_quirk},
+ {RIO_VENDOR_ID_FREESCALE, RIO_DEVICE_ID_MPC8568E, fsl_rio_quirk},
+ {RIO_VENDOR_ID_FREESCALE, RIO_DEVICE_ID_MPC8568, fsl_rio_quirk},
+ {RIO_VENDOR_ID_FREESCALE, RIO_DEVICE_ID_MPC8641, fsl_rio_quirk},
+ {RIO_VENDOR_ID_FREESCALE, RIO_DEVICE_ID_MPC8641D, fsl_rio_quirk},
+ {},
+};
+
+void rio_hose_post(void)
+{
+ struct rio_controller *hose;
+ struct rio_quirk *post_quirk;
+
+ list_for_each_entry(hose, &rio_hose_list, node)
+ for (post_quirk = rio_post_quirk;
+ post_quirk->vendor || post_quirk->device; post_quirk++)
+ if ((post_quirk->vendor == hose->self->vendor)
+ && (post_quirk->device == hose->self->device)
+ && post_quirk->quirk) {
+ post_quirk->quirk(hose, hose->self);
+ break;
+ }
+}
+
+void rio_init(void)
+{
+ INIT_LIST_HEAD(&rio_hose_list);
+
+ /* Call board specific rio_init() */
+ rio_init_board();
+
+ rio_hose_post();
+}
+
+#endif /* CONFIG_RAPIDIO */
diff --git a/include/common.h b/include/common.h
index 9ef9344..84ff943 100644
--- a/include/common.h
+++ b/include/common.h
@@ -275,6 +275,9 @@ void pciinfo (int, int);
#endif
#endif
+void rio_init (void);
+void rio_init_board(void);
+
int misc_init_f (void);
int misc_init_r (void);
diff --git a/include/rio.h b/include/rio.h
new file mode 100644
index 0000000..379c56c
--- /dev/null
+++ b/include/rio.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2008 Freescale Semiconductor, Inc. All rights reserved.
+ *
+ * This 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.
+ *
+ */
+
+#ifndef __INCLUDE_RIO_H_
+#define __INCLUDE_RIO_H_
+
+#include <linux/list.h>
+
+struct rio_dev {
+ struct list_head node;
+ u16 vendor; /* Vendor ID */
+ u16 device; /* Device ID */
+
+ u32 devno; /* Device number */
+ u32 hostno; /* Host number in the bus */
+};
+
+struct rio_controller {
+ struct list_head node;
+ struct list_head dev_list;
+
+ int busno;
+
+ struct rio_dev *self; /* Controler RIO device */
+ void *base; /* Register base */
+};
+
+struct rio_quirk {
+ u16 vendor;
+ u16 device;
+ void (*quirk)(struct rio_controller *hose, struct rio_dev *dev);
+};
+
+void fsl_rio_init(void *base, int busno);
+void fsl_rio_quirk(struct rio_controller *hose, struct rio_dev *rdev);
+
+extern struct list_head rio_hose_list;
+
+#endif /* __INCLUDE_RIO_H_ */
diff --git a/include/rio_ids.h b/include/rio_ids.h
new file mode 100644
index 0000000..b6a4ab8
--- /dev/null
+++ b/include/rio_ids.h
@@ -0,0 +1,9 @@
+
+#define RIO_VENDOR_ID_FREESCALE 0x0002
+
+#define RIO_DEVICE_ID_MPC8548E 0x0012
+#define RIO_DEVICE_ID_MPC8548 0x0013
+#define RIO_DEVICE_ID_MPC8568E 0x0020
+#define RIO_DEVICE_ID_MPC8568 0x0021
+#define RIO_DEVICE_ID_MPC8641 0x7010
+#define RIO_DEVICE_ID_MPC8641D 0x7011
diff --git a/lib_ppc/board.c b/lib_ppc/board.c
index 0719745..75746ff 100644
--- a/lib_ppc/board.c
+++ b/lib_ppc/board.c
@@ -921,6 +921,11 @@ void board_init_r (gd_t *id, ulong dest_addr)
pci_init ();
#endif
+#if defined(CONFIG_RAPIDIO)
+ /* Do RapidIO configuration */
+ rio_init ();
+#endif
+
/** leave this here (after malloc(), environment and PCI are working) **/
/* Initialize devices */
devices_init ();
--
1.5.2
More information about the U-Boot
mailing list