bcma: add Broadcom specific AMBA bus driver
Subsystems (2)
Rafał Miłecki
maintainerPATCH v6 1/1 bcma: add Broadcom specific AMBA bus driver
---
V2: Rename to axi
Use DEFINE_PCI_DEVICE_TABLE in bridge
Make use of pr_fmt and pr_*
Store core class
Rename bridge to not b43 specific
Replace magic 0x1000 with BCMAI_CORE_SIZE Remove some old "ssb" names and defines
Move BCMAI_ADDR_BASE def
Add drvdata field
V3: Fix reloading (kfree issue)
Add 14e4:0x4331
Fix non-initialized struct issue
Drop useless inline functions wrappers for pci core drv Proper pr_* usage
V3.1: Include forgotten changes (pr_* and include related)
Explain why we dare to implement empty release function
V4: Add ABI documentation
Move struct device to wrapper and alloc it dynamically checkpatch.pl pointed fixes
V5: Rename to bcma, AXI was really bad name
Use EXPORT_SYMBOL_GPL
Set pci driver fields in one place
Drop unlikely
Use BCMA_CORE_SIZE for calc in awrite32
Add README
Fix compilation (delay.h)
V6: Replace AXI in Documentation
Fill MAINTAINERS
Names only for Broadcom
Update TODO and README
Use errno
--- Documentation/ABI/testing/sysfs-bus-bcma | 31 ++ MAINTAINERS | 7 + drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/bcma/Kconfig | 33 +++ drivers/bcma/Makefile | 7 + drivers/bcma/README | 19 ++ drivers/bcma/TODO | 4 + drivers/bcma/bcma_private.h | 28 ++ drivers/bcma/core.c | 51 ++++ drivers/bcma/driver_chipcommon.c | 87 ++++++ drivers/bcma/driver_chipcommon_pmu.c | 134 +++++++++ drivers/bcma/driver_pci.c | 163 +++++++++++ drivers/bcma/host_pci.c | 196 +++++++++++++ drivers/bcma/main.c | 271 ++++++++++++++++++ drivers/bcma/scan.c | 394 +++++++++++++++++++++++++++ drivers/bcma/scan.h | 56 ++++ include/linux/bcma/bcma.h | 232 ++++++++++++++++ include/linux/bcma/bcma_driver_chipcommon.h | 297 ++++++++++++++++++++ include/linux/bcma/bcma_driver_pci.h | 89 ++++++ include/linux/bcma/bcma_regs.h | 34 +++ include/linux/mod_devicetable.h | 17 ++ scripts/mod/file2alias.c | 22 ++ 23 files changed, 2175 insertions(+), 0 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-bus-bcma create mode 100644 drivers/bcma/Kconfig create mode 100644 drivers/bcma/Makefile create mode 100644 drivers/bcma/README create mode 100644 drivers/bcma/TODO create mode 100644 drivers/bcma/bcma_private.h create mode 100644 drivers/bcma/core.c create mode 100644 drivers/bcma/driver_chipcommon.c create mode 100644 drivers/bcma/driver_chipcommon_pmu.c create mode 100644 drivers/bcma/driver_pci.c create mode 100644 drivers/bcma/host_pci.c create mode 100644 drivers/bcma/main.c create mode 100644 drivers/bcma/scan.c create mode 100644 drivers/bcma/scan.h create mode 100644 include/linux/bcma/bcma.h create mode 100644 include/linux/bcma/bcma_driver_chipcommon.h create mode 100644 include/linux/bcma/bcma_driver_pci.h create mode 100644 include/linux/bcma/bcma_regs.h
Documentation/ABI/testing/sysfs-bus-bcma new file +31 -0
@@ -0,0 +1,31 @@ +What: /sys/bus/bcma/devices/.../manuf +Date: May 2011 +KernelVersion: 2.6.40 +Contact: Rafał Miłecki <[email protected]> +Description: + Each BCMA core has it's manufacturer id. See + include/linux/bcma/bcma.h for possible values. + +What: /sys/bus/bcma/devices/.../id +Date: May 2011 +KernelVersion: 2.6.40 +Contact: Rafał Miłecki <[email protected]> +Description: + There are a few types of BCMA cores, they can be identified by + id field. + +What: /sys/bus/bcma/devices/.../rev +Date: May 2011 +KernelVersion: 2.6.40 +Contact: Rafał Miłecki <[email protected]> +Description: + BCMA cores of the same type can still slightly differ depending + on their revision. Use it for detailed programming. + +What: /sys/bus/bcma/devices/.../class +Date: May 2011 +KernelVersion: 2.6.40 +Contact: Rafał Miłecki <[email protected]> +Description: + Each BCMA core is identified by few fields, including class it + belongs to. See include/linux/bcma/bcma.h for possible values.
MAINTAINERS +7 -0
@@ -5816,6 +5816,13 @@ S: Maintained F: drivers/ssb/ F: include/linux/ssb/ +BROADCOM SPECIFIC AMBA DRIVER (BCMA) +M: Rafał Miłecki <[email protected]> +L: [email protected] +S: Maintained +F: drivers/bcma/ +F: include/linux/bcma/ + SONY VAIO CONTROL DEVICE DRIVER M: Mattia Dongili <[email protected]> L: [email protected]
drivers/Kconfig +2 -0
@@ -68,6 +68,8 @@ source "drivers/watchdog/Kconfig" source "drivers/ssb/Kconfig" +source "drivers/bcma/Kconfig" + source "drivers/mfd/Kconfig" source "drivers/regulator/Kconfig"
drivers/Makefile +1 -0
@@ -110,6 +110,7 @@ obj-$(CONFIG_HID) += hid/ obj-$(CONFIG_PPC_PS3) += ps3/ obj-$(CONFIG_OF) += of/ obj-$(CONFIG_SSB) += ssb/ +obj-$(CONFIG_BCMA) += bcma/ obj-$(CONFIG_VHOST_NET) += vhost/ obj-$(CONFIG_VLYNQ) += vlynq/ obj-$(CONFIG_STAGING) += staging/
drivers/bcma/Kconfig new file +33 -0
@@ -0,0 +1,33 @@ +config BCMA_POSSIBLE + bool + depends on HAS_IOMEM && HAS_DMA + default y + +menu "Broadcom specific AMBA" + depends on BCMA_POSSIBLE + +config BCMA + tristate "BCMA support" + depends on BCMA_POSSIBLE + help + Bus driver for Broadcom specific Advanced Microcontroller Bus + Architecture. + +config BCMA_HOST_PCI_POSSIBLE + bool + depends on BCMA && PCI = y + default y + +config BCMA_HOST_PCI + bool "Support for BCMA on PCI-host bus" + depends on BCMA_HOST_PCI_POSSIBLE + +config BCMA_DEBUG + bool "BCMA debugging" + depends on BCMA + help + This turns on additional debugging messages. + + If unsure, say N + +endmenu
drivers/bcma/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +bcma-y += main.o scan.o core.o +bcma-y += driver_chipcommon.o driver_chipcommon_pmu.o +bcma-y += driver_pci.o +bcma-$(CONFIG_BCMA_HOST_PCI) += host_pci.o +obj-$(CONFIG_BCMA) += bcma.o + +ccflags-$(CONFIG_BCMA_DEBUG) := -DDEBUG
drivers/bcma/README new file +19 -0
@@ -0,0 +1,19 @@ +Broadcom introduced new bus as replacement for older SSB. It is based on AMBA, +however from programming point of view there is nothing AMBA specific we use. + +Standard AMBA drivers are platform specific, have hardcoded addresses and use +AMBA standard fields like CID and PID. + +In case of Broadcom's cards every device consists of: +1) Broadcom specific AMBA device. It is put on AMBA bus, but can not be treated + as standard AMBA device. Reading it's CID or PID can cause machine lockup. +2) AMBA standard devices called ports or wrappers. They have CIDs (AMBA_CID) + and PIDs (0x103BB369), but we do not use that info for anything. One of that + devices is used for managing Broadcom specific core. + +Addresses of AMBA devices are not hardcoded in driver and have to be read from +EPROM. + +In this situation we decided to introduce separated bus. It can contain up to +16 devices identified by Broadcom specific fields: manufacturer, id, revision +and class.
drivers/bcma/TODO new file +4 -0
@@ -0,0 +1,4 @@ +- Interrupts +- Defines for PCI core driver +- Convert bcma_bus->cores into linked list +- Make kernel Documentation (use info from README)
drivers/bcma/bcma_private.h new file +28 -0
@@ -0,0 +1,28 @@ +#ifndef LINUX_BCMA_PRIVATE_H_ +#define LINUX_BCMA_PRIVATE_H_ + +#ifndef pr_fmt +#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt +#endif + +#include <linux/bcma/bcma.h> +#include <linux/delay.h> + +#define BCMA_CORE_SIZE 0x1000 + +struct bcma_bus ; + +/* main.c */ +extern int bcma_bus_register (struct bcma_bus *bus); +extern void bcma_bus_unregister (struct bcma_bus *bus); + +/* scan.c */ +int bcma_bus_scan (struct bcma_bus *bus); + +#ifdef CONFIG_BCMA_HOST_PCI +/* host_pci.c */ +extern int __init bcma_host_pci_init (void ); +extern void __exit bcma_host_pci_exit(void); +#endif /* CONFIG_BCMA_HOST_PCI */ + +#endif
drivers/bcma/core.c new file +51 -0
51 lines not on this page · raw message
drivers/bcma/driver_chipcommon.c new file +87 -0
87 lines not on this page · raw message
drivers/bcma/driver_chipcommon_pmu.c new file +134 -0
134 lines not on this page · raw message
drivers/bcma/driver_pci.c new file +163 -0
163 lines not on this page · raw message
drivers/bcma/host_pci.c new file +196 -0
196 lines not on this page · raw message
drivers/bcma/main.c new file +271 -0
271 lines not on this page · raw message
drivers/bcma/scan.c new file +394 -0
394 lines not on this page · raw message
drivers/bcma/scan.h new file +56 -0
56 lines not on this page · raw message
include/linux/bcma/bcma.h new file +232 -0
232 lines not on this page · raw message
include/linux/bcma/bcma_driver_chipcommon.h new file +297 -0
297 lines not on this page · raw message
include/linux/bcma/bcma_driver_pci.h new file +89 -0
89 lines not on this page · raw message
include/linux/bcma/bcma_regs.h new file +34 -0
@@ -0,0 +1,34 @@ +#ifndef LINUX_BCMA_REGS_H_ +#define LINUX_BCMA_REGS_H_ + +/* Agent registers (common for every core) */ +#define BCMA_IOCTL 0x0408 +#define BCMA_IOCTL_CLK 0x0001 +#define BCMA_IOCTL_FGC 0x0002 +#define BCMA_IOCTL_CORE_BITS 0x3FFC +#define BCMA_IOCTL_PME_EN 0x4000 +#define BCMA_IOCTL_BIST_EN 0x8000 +#define BCMA_RESET_CTL 0x0800 +#define BCMA_RESET_CTL_RESET 0x0001 + +/* BCMA PCI config space registers. */ +#define BCMA_PCI_PMCSR 0x44 +#define BCMA_PCI_PE 0x100 +#define BCMA_PCI_BAR0_WIN 0x80/* Backplane address space 0 */ +#define BCMA_PCI_BAR1_WIN 0x84/* Backplane address space 1 */ +#define BCMA_PCI_SPROMCTL 0x88/* SPROM control */ +#define BCMA_PCI_SPROMCTL_WE 0x10/* SPROM write enable */ +#define BCMA_PCI_BAR1_CONTROL 0x8c/* Address space 1 burst control */ +#define BCMA_PCI_IRQS 0x90/* PCI interrupts */ +#define BCMA_PCI_IRQMASK 0x94/* PCI IRQ control and mask (pcirev >= 6 only) */ +#define BCMA_PCI_BACKPLANE_IRQS 0x98/* Backplane Interrupts */ +#define BCMA_PCI_BAR0_WIN2 0xAC +#define BCMA_PCI_GPIO_IN 0xB0/* GPIO Input (pcirev >= 3 only) */ +#define BCMA_PCI_GPIO_OUT 0xB4/* GPIO Output (pcirev >= 3 only) */ +#define BCMA_PCI_GPIO_OUT_ENABLE 0xB8/* GPIO Output Enable/Disable (pcirev >= 3 only) */ +#define BCMA_PCI_GPIO_SCS 0x10/* PCI config space bit 4 for 4306c0 slow clock source */ +#define BCMA_PCI_GPIO_HWRAD 0x20/* PCI config space GPIO 13 for hw radio disable */ +#define BCMA_PCI_GPIO_XTAL 0x40/* PCI config space GPIO 14 for Xtal powerup */ +#define BCMA_PCI_GPIO_PLL 0x80/* PCI config space GPIO 15 for PLL powerdown */ + +#endif /* LINUX_BCMA_REGS_H_ */
include/linux/mod_devicetable.h +17 -0
@@ -382,6 +382,23 @@ struct ssb_device_id {#define SSB_ANY_ID 0xFFFF#define SSB_ANY_REV 0xFF +/* Broadcom's specific AMBA core, see drivers/bcma/ */ +struct bcma_device_id { +__u16 manuf; +__u16 id; +__u8 rev; +__u8 class; +}; +#define BCMA_CORE (_manuf, _id, _rev, _class) \ + { .manuf = _manuf, .id = _id, .rev = _rev, .class = _class, } +#define BCMA_CORETABLE_END \ + { 0, }, + +#define BCMA_ANY_MANUF 0xFFFF +#define BCMA_ANY_ID 0xFFFF +#define BCMA_ANY_REV 0xFF +#define BCMA_ANY_CLASS 0xFF +struct virtio_device_id {__u32 device;__u32 vendor;
scripts/mod/file2alias.c +22 -0
@@ -702,6 +702,24 @@ static int do_ssb_entry(const char *filename,return 1 ; } +/* Looks like: bcma:mNidNrevNclN. */ +static int do_bcma_entry (const char *filename, +struct bcma_device_id *id,char *alias) +{ + id->manuf =TO_NATIVE (id->manuf); + id->id =TO_NATIVE (id->id); + id->rev =TO_NATIVE (id->rev); + id->class =TO_NATIVE (id->class); + +strcpy (alias,"bcma:" ); +ADD (alias,"m" , id->manuf !=BCMA_ANY_MANUF , id->manuf); +ADD (alias,"id" , id->id !=BCMA_ANY_ID , id->id); +ADD (alias,"rev" , id->rev !=BCMA_ANY_REV , id->rev); +ADD (alias,"cl" , id->class !=BCMA_ANY_CLASS , id->class); +add_wildcard (alias); +return 1 ; +} +/* Looks like: virtio:dNvN */ static int do_virtio_entry (const char *filename,struct virtio_device_id *id,char *alias)
@@ -968,6 +986,10 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,do_table (symval, sym->st_size,sizeof (struct ssb_device_id ),"ssb" , do_ssb_entry, mod); + else if (sym_is(symname, "__mod_bcma_device_table")) + do_table(symval, sym->st_size, + sizeof(struct bcma_device_id), "bcma", + do_bcma_entry, mod); else if (sym_is(symname, "__mod_virtio_device_table")) do_table(symval, sym->st_size, sizeof(struct virtio_device_id), "virtio",
Signature · 1 line
1.7.3.4