Root/target/linux/brcm47xx/patches-3.0/0008-bcma-add-pci-e-host-mode.patch

1From f93062e72447b4a4a51afbe33ea086ce8c922587 Mon Sep 17 00:00:00 2001
2From: Hauke Mehrtens <hauke@hauke-m.de>
3Date: Sun, 19 Jun 2011 17:52:09 +0200
4Subject: [PATCH 08/14] bcma: add pci(e) host mode
5
6This adds some stub for a pci(e) host controller. This controller is
7found on some embedded devices to attach other chips.
8
9Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
10---
11 drivers/bcma/Kconfig | 6 ++++
12 drivers/bcma/Makefile | 1 +
13 drivers/bcma/bcma_private.h | 6 ++++
14 drivers/bcma/driver_pci.c | 14 ++++++++++-
15 drivers/bcma/driver_pci_host.c | 43 ++++++++++++++++++++++++++++++++++
16 include/linux/bcma/bcma_driver_pci.h | 1 +
17 6 files changed, 70 insertions(+), 1 deletions(-)
18 create mode 100644 drivers/bcma/driver_pci_host.c
19
20--- a/drivers/bcma/Kconfig
21+++ b/drivers/bcma/Kconfig
22@@ -32,6 +32,12 @@ config BCMA_HOST_SOC
23     depends on BCMA_DRIVER_MIPS
24     default n
25 
26+config BCMA_DRIVER_PCI_HOSTMODE
27+ bool "Hostmode support for BCMA PCI core"
28+ depends on BCMA_DRIVER_MIPS
29+ help
30+ PCIcore hostmode operation (external PCI bus).
31+
32 config BCMA_DRIVER_MIPS
33     bool "BCMA Broadcom MIPS core driver"
34     depends on BCMA && MIPS
35--- a/drivers/bcma/Makefile
36+++ b/drivers/bcma/Makefile
37@@ -1,6 +1,7 @@
38 bcma-y += main.o scan.o core.o sprom.o
39 bcma-y += driver_chipcommon.o driver_chipcommon_pmu.o
40 bcma-y += driver_pci.o
41+bcma-$(CONFIG_BCMA_DRIVER_PCI_HOSTMODE) += driver_pci_host.o
42 bcma-$(CONFIG_BCMA_DRIVER_MIPS) += driver_mips.o
43 bcma-$(CONFIG_BCMA_HOST_PCI) += host_pci.o
44 bcma-$(CONFIG_BCMA_HOST_SOC) += host_soc.o
45--- a/drivers/bcma/bcma_private.h
46+++ b/drivers/bcma/bcma_private.h
47@@ -38,6 +38,12 @@ extern int bcma_chipco_serial_init(struc
48                    struct bcma_drv_mips_serial_port *ports);
49 #endif /* CONFIG_BCMA_DRIVER_MIPS */
50 
51+#ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE
52+/* driver_pci_host.c */
53+int bcma_core_pci_in_hostmode(struct bcma_drv_pci *pc);
54+void bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc);
55+#endif /* CONFIG_BCMA_DRIVER_PCI_HOSTMODE */
56+
57 #ifdef CONFIG_BCMA_HOST_PCI
58 /* host_pci.c */
59 extern int __init bcma_host_pci_init(void);
60--- a/drivers/bcma/driver_pci.c
61+++ b/drivers/bcma/driver_pci.c
62@@ -159,9 +159,21 @@ static void bcma_pcicore_serdes_workarou
63 
64 void bcma_core_pci_init(struct bcma_drv_pci *pc)
65 {
66+ struct bcma_device *core = pc->core;
67+
68     if (pc->setup_done)
69         return;
70- bcma_pcicore_serdes_workaround(pc);
71+
72+ if (!bcma_core_is_enabled(core))
73+ bcma_core_enable(core, 0);
74+#ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE
75+ pc->hostmode = bcma_core_pci_in_hostmode(pc);
76+ if (pc->hostmode)
77+ bcma_core_pci_hostmode_init(pc);
78+#endif /* CONFIG_BCMA_DRIVER_PCI_HOSTMODE */
79+ if (!pc->hostmode)
80+ bcma_pcicore_serdes_workaround(pc);
81+
82     pc->setup_done = true;
83 }
84 
85--- /dev/null
86+++ b/drivers/bcma/driver_pci_host.c
87@@ -0,0 +1,43 @@
88+/*
89+ * Broadcom specific AMBA
90+ * PCI Host mode
91+ *
92+ * Copyright 2005, Broadcom Corporation
93+ *
94+ * Licensed under the GNU/GPL. See COPYING for details.
95+ */
96+
97+#include "bcma_private.h"
98+#include <linux/bcma/bcma.h>
99+
100+#include <asm/paccess.h>
101+/* Probe a 32bit value on the bus and catch bus exceptions.
102+ * Returns nonzero on a bus exception.
103+ * This is MIPS specific */
104+#define mips_busprobe32(val, addr) get_dbe((val), ((u32 *)(addr)))
105+
106+
107+void bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc)
108+{
109+ /* TODO: implement PCI host mode */
110+}
111+
112+int bcma_core_pci_in_hostmode(struct bcma_drv_pci *pc)
113+{
114+ struct bcma_bus *bus = pc->core->bus;
115+ u16 chipid_top;
116+ u32 tmp;
117+
118+ chipid_top = (bus->chipinfo.id & 0xFF00);
119+ if (chipid_top != 0x4700 &&
120+ chipid_top != 0x5300)
121+ return 0;
122+
123+/* TODO: add when sprom is available
124+ * if (bus->sprom.boardflags_lo & SSB_PCICORE_BFL_NOPCI)
125+ * return 0;
126+ */
127+
128+ return !mips_busprobe32(tmp, (bus->mmio + (pc->core->core_index *
129+ BCMA_CORE_SIZE)));
130+}
131--- a/include/linux/bcma/bcma_driver_pci.h
132+++ b/include/linux/bcma/bcma_driver_pci.h
133@@ -78,6 +78,7 @@ struct pci_dev;
134 struct bcma_drv_pci {
135     struct bcma_device *core;
136     u8 setup_done:1;
137+ u8 hostmode:1;
138 };
139 
140 /* Register access */
141

Archive Download this file



interactive