1 From f93062e72447b4a4a51afbe33ea086ce8c922587 Mon Sep 17 00:00:00 2001
2 From: Hauke Mehrtens <hauke@hauke-m.de>
3 Date: Sun, 19 Jun 2011 17:52:09 +0200
4 Subject: [PATCH 08/14] bcma: add pci(e) host mode
6 This adds some stub for a pci(e) host controller. This controller is
7 found on some embedded devices to attach other chips.
9 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
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
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
26 +config BCMA_DRIVER_PCI_HOSTMODE
27 + bool "Hostmode support for BCMA PCI core"
28 + depends on BCMA_DRIVER_MIPS
30 + PCIcore hostmode operation (external PCI bus).
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
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 */
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 */
57 #ifdef CONFIG_BCMA_HOST_PCI
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
64 void bcma_core_pci_init(struct bcma_drv_pci *pc)
66 + struct bcma_device *core = pc->core;
70 - bcma_pcicore_serdes_workaround(pc);
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);
77 + bcma_core_pci_hostmode_init(pc);
78 +#endif /* CONFIG_BCMA_DRIVER_PCI_HOSTMODE */
80 + bcma_pcicore_serdes_workaround(pc);
82 pc->setup_done = true;
86 +++ b/drivers/bcma/driver_pci_host.c
89 + * Broadcom specific AMBA
92 + * Copyright 2005, Broadcom Corporation
94 + * Licensed under the GNU/GPL. See COPYING for details.
97 +#include "bcma_private.h"
98 +#include <linux/bcma/bcma.h>
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)))
107 +void bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc)
109 + /* TODO: implement PCI host mode */
112 +int bcma_core_pci_in_hostmode(struct bcma_drv_pci *pc)
114 + struct bcma_bus *bus = pc->core->bus;
118 + chipid_top = (bus->chipinfo.id & 0xFF00);
119 + if (chipid_top != 0x4700 &&
120 + chipid_top != 0x5300)
123 +/* TODO: add when sprom is available
124 + * if (bus->sprom.boardflags_lo & SSB_PCICORE_BFL_NOPCI)
128 + return !mips_busprobe32(tmp, (bus->mmio + (pc->core->core_index *
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;
140 /* Register access */