Skip to content

Commit 8369ae3

Browse files
rmileckilinvjw
authored andcommitted
bcma: add Broadcom specific AMBA bus driver
Broadcom has released cards based on a new AMBA-based bus type. From a programming point of view, this new bus type differs from AMBA and does not use AMBA common registers. It also differs enough from SSB. We decided that a new bus driver is needed to keep the code clean. In its current form, the driver detects devices present on the bus and registers them in the system. It allows registering BCMA drivers for specified bus devices and provides them basic operations. The bus driver itself includes two important bus managing drivers: ChipCommon core driver and PCI(c) core driver. They are early used to allow correct initialization. Currently code is limited to supporting buses on PCI(e) devices, however the driver is designed to be used also on other hosts. The host abstraction layer is implemented and already used for PCI(e). Support for PCI(e) hosts is working and seems to be stable (access to 80211 core was tested successfully on a few devices). We can still optimize it by using some fixed windows, but this can be done later without affecting any external code. Windows are just ranges in MMIO used for accessing cores on the bus. Cc: Greg KH <greg@kroah.com> Cc: Michael Büsch <mb@bu3sch.de> Cc: Larry Finger <Larry.Finger@lwfinger.net> Cc: George Kashperko <george@znau.edu.ua> Cc: Arend van Spriel <arend@broadcom.com> Cc: linux-arm-kernel@lists.infradead.org Cc: Russell King <rmk@arm.linux.org.uk> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Andy Botting <andy@andybotting.com> Cc: linuxdriverproject <devel@linuxdriverproject.org> Cc: linux-kernel@vger.kernel.org <linux-kernel@vger.kernel.org> Signed-off-by: Rafał Miłecki <zajec5@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
1 parent 306fe93 commit 8369ae3

23 files changed

Lines changed: 2108 additions & 0 deletions
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
What: /sys/bus/bcma/devices/.../manuf
2+
Date: May 2011
3+
KernelVersion: 2.6.40
4+
Contact: Rafał Miłecki <zajec5@gmail.com>
5+
Description:
6+
Each BCMA core has it's manufacturer id. See
7+
include/linux/bcma/bcma.h for possible values.
8+
9+
What: /sys/bus/bcma/devices/.../id
10+
Date: May 2011
11+
KernelVersion: 2.6.40
12+
Contact: Rafał Miłecki <zajec5@gmail.com>
13+
Description:
14+
There are a few types of BCMA cores, they can be identified by
15+
id field.
16+
17+
What: /sys/bus/bcma/devices/.../rev
18+
Date: May 2011
19+
KernelVersion: 2.6.40
20+
Contact: Rafał Miłecki <zajec5@gmail.com>
21+
Description:
22+
BCMA cores of the same type can still slightly differ depending
23+
on their revision. Use it for detailed programming.
24+
25+
What: /sys/bus/bcma/devices/.../class
26+
Date: May 2011
27+
KernelVersion: 2.6.40
28+
Contact: Rafał Miłecki <zajec5@gmail.com>
29+
Description:
30+
Each BCMA core is identified by few fields, including class it
31+
belongs to. See include/linux/bcma/bcma.h for possible values.

‎MAINTAINERS‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5810,6 +5810,13 @@ S: Maintained
58105810
F: drivers/ssb/
58115811
F: include/linux/ssb/
58125812

5813+
BROADCOM SPECIFIC AMBA DRIVER (BCMA)
5814+
M: Rafał Miłecki <zajec5@gmail.com>
5815+
L: linux-wireless@vger.kernel.org
5816+
S: Maintained
5817+
F: drivers/bcma/
5818+
F: include/linux/bcma/
5819+
58135820
SONY VAIO CONTROL DEVICE DRIVER
58145821
M: Mattia Dongili <malattia@linux.it>
58155822
L: platform-driver-x86@vger.kernel.org

‎drivers/Kconfig‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ source "drivers/watchdog/Kconfig"
6868

6969
source "drivers/ssb/Kconfig"
7070

71+
source "drivers/bcma/Kconfig"
72+
7173
source "drivers/mfd/Kconfig"
7274

7375
source "drivers/regulator/Kconfig"

‎drivers/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ obj-$(CONFIG_HID) += hid/
110110
obj-$(CONFIG_PPC_PS3) += ps3/
111111
obj-$(CONFIG_OF) += of/
112112
obj-$(CONFIG_SSB) += ssb/
113+
obj-$(CONFIG_BCMA) += bcma/
113114
obj-$(CONFIG_VHOST_NET) += vhost/
114115
obj-$(CONFIG_VLYNQ) += vlynq/
115116
obj-$(CONFIG_STAGING) += staging/

‎drivers/bcma/Kconfig‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
config BCMA_POSSIBLE
2+
bool
3+
depends on HAS_IOMEM && HAS_DMA
4+
default y
5+
6+
menu "Broadcom specific AMBA"
7+
depends on BCMA_POSSIBLE
8+
9+
config BCMA
10+
tristate "BCMA support"
11+
depends on BCMA_POSSIBLE
12+
help
13+
Bus driver for Broadcom specific Advanced Microcontroller Bus
14+
Architecture.
15+
16+
config BCMA_HOST_PCI_POSSIBLE
17+
bool
18+
depends on BCMA && PCI = y
19+
default y
20+
21+
config BCMA_HOST_PCI
22+
bool "Support for BCMA on PCI-host bus"
23+
depends on BCMA_HOST_PCI_POSSIBLE
24+
25+
config BCMA_DEBUG
26+
bool "BCMA debugging"
27+
depends on BCMA
28+
help
29+
This turns on additional debugging messages.
30+
31+
If unsure, say N
32+
33+
endmenu

‎drivers/bcma/Makefile‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
bcma-y += main.o scan.o core.o
2+
bcma-y += driver_chipcommon.o driver_chipcommon_pmu.o
3+
bcma-y += driver_pci.o
4+
bcma-$(CONFIG_BCMA_HOST_PCI) += host_pci.o
5+
obj-$(CONFIG_BCMA) += bcma.o
6+
7+
ccflags-$(CONFIG_BCMA_DEBUG) := -DDEBUG

‎drivers/bcma/README‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Broadcom introduced new bus as replacement for older SSB. It is based on AMBA,
2+
however from programming point of view there is nothing AMBA specific we use.
3+
4+
Standard AMBA drivers are platform specific, have hardcoded addresses and use
5+
AMBA standard fields like CID and PID.
6+
7+
In case of Broadcom's cards every device consists of:
8+
1) Broadcom specific AMBA device. It is put on AMBA bus, but can not be treated
9+
as standard AMBA device. Reading it's CID or PID can cause machine lockup.
10+
2) AMBA standard devices called ports or wrappers. They have CIDs (AMBA_CID)
11+
and PIDs (0x103BB369), but we do not use that info for anything. One of that
12+
devices is used for managing Broadcom specific core.
13+
14+
Addresses of AMBA devices are not hardcoded in driver and have to be read from
15+
EPROM.
16+
17+
In this situation we decided to introduce separated bus. It can contain up to
18+
16 devices identified by Broadcom specific fields: manufacturer, id, revision
19+
and class.

‎drivers/bcma/TODO‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- Interrupts
2+
- Defines for PCI core driver
3+
- Create kernel Documentation (use info from README)

‎drivers/bcma/bcma_private.h‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#ifndef LINUX_BCMA_PRIVATE_H_
2+
#define LINUX_BCMA_PRIVATE_H_
3+
4+
#ifndef pr_fmt
5+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
6+
#endif
7+
8+
#include <linux/bcma/bcma.h>
9+
#include <linux/delay.h>
10+
11+
#define BCMA_CORE_SIZE 0x1000
12+
13+
struct bcma_bus;
14+
15+
/* main.c */
16+
extern int bcma_bus_register(struct bcma_bus *bus);
17+
extern void bcma_bus_unregister(struct bcma_bus *bus);
18+
19+
/* scan.c */
20+
int bcma_bus_scan(struct bcma_bus *bus);
21+
22+
#ifdef CONFIG_BCMA_HOST_PCI
23+
/* host_pci.c */
24+
extern int __init bcma_host_pci_init(void);
25+
extern void __exit bcma_host_pci_exit(void);
26+
#endif /* CONFIG_BCMA_HOST_PCI */
27+
28+
#endif

‎drivers/bcma/core.c‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Broadcom specific AMBA
3+
* Core ops
4+
*
5+
* Licensed under the GNU/GPL. See COPYING for details.
6+
*/
7+
8+
#include "bcma_private.h"
9+
#include <linux/bcma/bcma.h>
10+
11+
bool bcma_core_is_enabled(struct bcma_device *core)
12+
{
13+
if ((bcma_aread32(core, BCMA_IOCTL) & (BCMA_IOCTL_CLK | BCMA_IOCTL_FGC))
14+
!= BCMA_IOCTL_CLK)
15+
return false;
16+
if (bcma_aread32(core, BCMA_RESET_CTL) & BCMA_RESET_CTL_RESET)
17+
return false;
18+
return true;
19+
}
20+
EXPORT_SYMBOL_GPL(bcma_core_is_enabled);
21+
22+
static void bcma_core_disable(struct bcma_device *core, u32 flags)
23+
{
24+
if (bcma_aread32(core, BCMA_RESET_CTL) & BCMA_RESET_CTL_RESET)
25+
return;
26+
27+
bcma_awrite32(core, BCMA_IOCTL, flags);
28+
bcma_aread32(core, BCMA_IOCTL);
29+
udelay(10);
30+
31+
bcma_awrite32(core, BCMA_RESET_CTL, BCMA_RESET_CTL_RESET);
32+
udelay(1);
33+
}
34+
35+
int bcma_core_enable(struct bcma_device *core, u32 flags)
36+
{
37+
bcma_core_disable(core, flags);
38+
39+
bcma_awrite32(core, BCMA_IOCTL, (BCMA_IOCTL_CLK | BCMA_IOCTL_FGC | flags));
40+
bcma_aread32(core, BCMA_IOCTL);
41+
42+
bcma_awrite32(core, BCMA_RESET_CTL, 0);
43+
udelay(1);
44+
45+
bcma_awrite32(core, BCMA_IOCTL, (BCMA_IOCTL_CLK | flags));
46+
bcma_aread32(core, BCMA_IOCTL);
47+
udelay(1);
48+
49+
return 0;
50+
}
51+
EXPORT_SYMBOL_GPL(bcma_core_enable);

0 commit comments

Comments
 (0)