Skip to contentSkip to conversation

drivers: brcmaxi: provide amba axi functionality in separate module

PATCH In review Arend van Spriel 3 participants 6 messages Apr 20, 2011 – Apr 23, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers: brcmaxi: provide amba axi functionality in separate module

The open-source community is looking for a library which will detect cores in a chip using axi backplane. Another proposal has been sent by Rafa? Mi?ecki, which registers detected cores in the linux device tree to be claimed by device drivers. This implies cores will always provide a system function to the kernel which is indepent from other cores and have very loose or no coupling. If this is not true, exceptions need to be added in the device registration process. This means knowledge of specific devices from specific vendors is sitting in a bus driver. Whether the exceptions are rarely or likely is a pending question.

To feed the discussion this implementation takes a different approach. A calling entity (being a pci device driver, or SoC initialization sequence) registers a table with core identities and a callback function. It then starts the scan and for each detected core with a callback function it does the call providing the core information. Apart from that it provides some basic operations on the core.

It has been tested using the brcmsmac driver (in drivers/staging/brcm80211).

V1:
- (brcm)axi interconnect scanning
- basic core functions (reset, disable, status, control)
- cores access over PCI(e)

TODO:
- sliding BAR windows only for PCI with small window size
- cleanup in Kconfig

Cc linux-kernel at vger.kernel.org
Cc linux-wireless at vger.kernel.org
Cc linux-arm-kernel at lists.infradead.org
Cc b43-dev at lists.infradead.org
Cc Rafa? Mi?ecki <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc George Kashperko <[email protected]>
Cc Jonas Gorski <[email protected]>
Cc Hauke Mehrtens <[email protected]>
Cc Russell King <[email protected]>
Cc Larry Finger <[email protected]>
Cc Andy Botting <[email protected]>
Cc Greg KH <[email protected]>
Cc Michael Buesch <[email protected]>
---
 drivers/Kconfig            |    2 +
 drivers/Makefile           |    1 +
 drivers/brcmaxi/Kconfig    |   23 ++
 drivers/brcmaxi/Makefile   |   25 ++
 drivers/brcmaxi/axi.c      |  784 ++++++++++++++++++++++++++++++++++++++++++++
 drivers/brcmaxi/axi_priv.h |   55 +++
 drivers/brcmaxi/pci.c      |  118 +++++++
 include/brcmaxi/amba.h     |   87 +++++
 include/brcmaxi/axi.h      |  310 +++++++++++++++++
 include/brcmaxi/pci.h      |  112 +++++++
 10 files changed, 1517 insertions(+), 0 deletions(-)
 create mode 100644 drivers/brcmaxi/Kconfig
 create mode 100644 drivers/brcmaxi/Makefile
 create mode 100644 drivers/brcmaxi/axi.c
 create mode 100644 drivers/brcmaxi/axi_priv.h
 create mode 100644 drivers/brcmaxi/pci.c
 create mode 100644 include/brcmaxi/amba.h
 create mode 100644 include/brcmaxi/axi.h
 create mode 100644 include/brcmaxi/pci.h
drivers/Kconfig +2 -0
index 177c7d1..8617526 100644
@@ -68,6 +68,8 @@ source "drivers/watchdog/Kconfig"
 
 source "drivers/ssb/Kconfig"
 
+source "drivers/brcmaxi/Kconfig"
+
 source "drivers/mfd/Kconfig"
 
 source "drivers/regulator/Kconfig"
drivers/Makefile +1 -0
index 3f135b6..1782ac9 100644
@@ -110,6 +110,7 @@ obj-$(CONFIG_HID)		+= hid/
 obj-$(CONFIG_PPC_PS3)		+= ps3/
 obj-$(CONFIG_OF)		+= of/
 obj-$(CONFIG_SSB)		+= ssb/
+obj-$(CONFIG_BRCMAXI)		+= brcmaxi/
 obj-$(CONFIG_VHOST_NET)		+= vhost/
 obj-$(CONFIG_VLYNQ)		+= vlynq/
 obj-$(CONFIG_STAGING)		+= staging/
drivers/brcmaxi/Kconfig new file +23 -0
new file mode 100644
index 0000000..255692e
@@ -0,0 +1,23 @@
+menuconfig BRCMAXI
+	tristate "Broadcom AXI utility function module"
+	---help---
+	  This module provides utility functions for detecting, enabling,
+	  initializing, and configuring cores on Broadcom chips which are
+	  using the AMBA AXI bus.
+
+	  The module is called brcmaxi.ko.
+
+config BRCMAXI_AMBA
+	bool "Broadcom AXI direct access"
+	default y
+	depends on BRCMAXI
+	---help---
+	  Selecting Y here allows direct access to the cores on the AMBA
+	  AXI backplane.
+
+config BRCMAXI_PCI
+	bool "Broadcom AXI over PCI"
+	depends on BRCMAXI
+	---help---
+	  Selecting Y here allows access to cores on AMBA AXI backplane
+	  through the PCI host interface.
drivers/brcmaxi/Makefile new file +25 -0
new file mode 100644
index 0000000..91f7797
@@ -0,0 +1,25 @@
+#
+# Makefile for Broadcom AMBA AXI utility module
+#
+# Copyright (c) 2011 Broadcom Corporation
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+MODULEPFX := brcmaxi
+
+ccflags-$(CONFIG_DEBUG_KERNEL)		+= -DDEBUG
+
+obj-$(CONFIG_BRCMAXI)			+= $(MODULEPFX).o
+
+$(MODULEPFX)-y				+= axi.o
+$(MODULEPFX)-$(CONFIG_BRCMAXI_PCI)	+= pci.o
drivers/brcmaxi/axi.c new file +784 -0

784 lines not on this page · raw message

drivers/brcmaxi/axi_priv.h new file +55 -0

55 lines not on this page · raw message

drivers/brcmaxi/pci.c new file +118 -0

118 lines not on this page · raw message

include/brcmaxi/amba.h new file +87 -0

87 lines not on this page · raw message

include/brcmaxi/axi.h new file +310 -0

310 lines not on this page · raw message

include/brcmaxi/pci.h new file +112 -0

112 lines not on this page · raw message

Signature · 1 line
1.7.1
#1 lore raw
Quoted 10 lines · Arend van Spriel

The open-source community is looking for a library which will detect cores in a chip using axi backplane. Another proposal has been sent by Rafa? Mi?ecki, which registers detected cores in the linux device tree to be claimed by device drivers. This implies cores will always provide a system function to the kernel which is indepent from other cores and have very loose or no coupling. If this is not true, exceptions need to be added in the device registration process. This means knowledge of specific devices from specific vendors is sitting in a bus driver. Whether the exceptions are rarely or likely is a pending question.

Hi Arend,

I have two very general comments about this:

Quoted 8 lines

To feed the discussion this implementation takes a different approach. A calling entity (being a pci device driver, or SoC initialization sequence) registers a table with core identities and a callback function. It then starts the scan and for each detected core with a callback function it does the call providing the core information. Apart from that it provides some basic operations on the core.

It has been tested using the brcmsmac driver (in drivers/staging/brcm80211).

The API split between PCI and non-PCI devices appears to be unhelpful. Can't you abstract the interface so that a user would apply the exact same interfaces in both cases, and handle the differences internally?

Quoted 10 lines
include/brcmaxi/axi.h new file +10 -0
+/* Core Codes */
+#define	NODEV_CORE_ID		0x700	/* Invalid coreid */
+#define	CC_CORE_ID		0x800	/* chipcommon core */
+#define	ILINE20_CORE_ID		0x801	/* iline20 core */
+#define	SRAM_CORE_ID		0x802	/* sram core */
+#define	SDRAM_CORE_ID		0x803	/* sdram core */
+#define	PCI_CORE_ID		0x804	/* pci core */
+#define	MIPS_CORE_ID		0x805	/* mips core */
+#define	ENET_CORE_ID		0x806	/* enet mac core */
+#define	CODEC_CORE_ID		0x807	/* v90 codec core */

include/brcmaxi/axi.h line 107

Quoted 10 lines
include/brcmaxi/axi.h new file +9 -0
+#define	USB_CORE_ID		0x808	/* usb 1.1 host/device core */
+#define	ADSL_CORE_ID		0x809	/* ADSL core */
+#define	ILINE100_CORE_ID	0x80a	/* iline100 core */
+#define	IPSEC_CORE_ID		0x80b	/* ipsec core */
+#define	UTOPIA_CORE_ID		0x80c	/* utopia core */
+#define	PCMCIA_CORE_ID		0x80d	/* pcmcia core */
+#define	SOCRAM_CORE_ID		0x80e	/* internal memory core */
+#define	MEMC_CORE_ID		0x80f	/* memc sdram core */
+#define	OFDM_CORE_ID		0x810	/* OFDM phy core */
...

This list to me is a strong hint that the cores behind the AXI bridge should normally be actual devices in Linux, i.e. the approach that Rafa? suggested. The vast majority of these is something that in Linux would be operated by a device driver. The exceptions that I can see are CPU cores and bus bridges, both of which we typically also represent as devices in the flattened device tree, even though they typically don't have a Linux driver attached to them.

Arnd

#2 lore raw
Quoted 24 lines · Arnd Bergmann
Quoted 10 lines · Arend van Spriel

The open-source community is looking for a library which will detect cores in a chip using axi backplane. Another proposal has been sent by Rafa? Mi?ecki, which registers detected cores in the linux device tree to be claimed by device drivers. This implies cores will always provide a system function to the kernel which is indepent from other cores and have very loose or no coupling. If this is not true, exceptions need to be added in the device registration process. This means knowledge of specific devices from specific vendors is sitting in a bus driver. Whether the exceptions are rarely or likely is a pending question.

Hi Arend,

I have two very general comments about this:

Quoted 8 lines

To feed the discussion this implementation takes a different approach. A calling entity (being a pci device driver, or SoC initialization sequence) registers a table with core identities and a callback function.
It then starts the scan and for each detected core with a callback function it does the call providing the core information. Apart from that it provides some basic operations on the core.

Quoted 7 lines
Quoted 2 lines

It has been tested using the brcmsmac driver (in
drivers/staging/brcm80211).

The API split between PCI and non-PCI devices appears to be unhelpful. Can't you abstract the interface so that a user would apply the exact same interfaces in both cases, and handle the differences internally?

Ok. that can be arranged ;-)

Quoted 21 lines
Quoted 10 lines
include/brcmaxi/axi.h new file +10 -0
+/* Core Codes */
+#define	NODEV_CORE_ID		0x700	/* Invalid coreid */
+#define	CC_CORE_ID		0x800	/* chipcommon core */
+#define	ILINE20_CORE_ID		0x801	/* iline20 core */
+#define	SRAM_CORE_ID		0x802	/* sram core */
+#define	SDRAM_CORE_ID		0x803	/* sdram core */
+#define	PCI_CORE_ID		0x804	/* pci core */
+#define	MIPS_CORE_ID		0x805	/* mips core */
+#define	ENET_CORE_ID		0x806	/* enet mac core */
+#define	CODEC_CORE_ID		0x807	/* v90 codec core */

include/brcmaxi/axi.h line 107

Quoted 10 lines
include/brcmaxi/axi.h new file +9 -0
+#define	USB_CORE_ID		0x808	/* usb 1.1 host/device core */
+#define	ADSL_CORE_ID		0x809	/* ADSL core */
+#define	ILINE100_CORE_ID	0x80a	/* iline100 core */
+#define	IPSEC_CORE_ID		0x80b	/* ipsec core */
+#define	UTOPIA_CORE_ID		0x80c	/* utopia core */
+#define	PCMCIA_CORE_ID		0x80d	/* pcmcia core */
+#define	SOCRAM_CORE_ID		0x80e	/* internal memory core */
+#define	MEMC_CORE_ID		0x80f	/* memc sdram core */
+#define	OFDM_CORE_ID		0x810	/* OFDM phy core */
...
Quoted 7 lines

This list to me is a strong hint that the cores behind the AXI bridge should normally be actual devices in Linux, i.e. the approach that Rafa? suggested. The vast majority of these is something that in Linux would be operated by a device driver. The exceptions that I can see are CPU cores and bus bridges, both of which we typically also represent as devices in the flattened device tree, even though they typically don't have a Linux driver attached to them.

Fine. Your providing the kind of feedback I was looking for. The OFDM_CORE_ID is also an exception.

So could a device driver claim multiple cores/devices to assure other drivers are not accessing those? I would prefer that over having exceptions coded in the axi bus driver, like the chipcommon core (CC_CORE_ID). I assume it can be done by the device table. Is that correct?

Rafa?,

Would it be possible to make chipcommon driver optional (not doing the initialization)?

Gr. AvS

Signature · 1 line
"The world is indeed comic, but the joke is on mankind." ? H.P. Lovecraft
#3 lore raw
Quoted 9 lines · Arend van Spriel
Quoted 8 lines

This list to me is a strong hint that the cores behind the AXI bridge should normally be actual devices in Linux, i.e. the approach that Rafa? suggested. The vast majority of these is something that in Linux would be operated by a device driver. The exceptions that I can see are CPU cores and bus bridges, both of which we typically also represent as devices in the flattened device tree, even though they typically don't have a Linux driver attached to them.

Quoted 7 lines

Fine. Your providing the kind of feedback I was looking for. The OFDM_CORE_ID is also an exception.

So could a device driver claim multiple cores/devices to assure other drivers are not accessing those? I would prefer that over having exceptions coded in the axi bus driver, like the chipcommon core (CC_CORE_ID). I assume it can be done by the device table. Is that correct?

You can bind any number of devices to one driver, and the match table can contain entries for different classes of devices. You can also have multiple drivers list the same ID and return an error from the probe() function for those devices that don't actually match the driver, based on additional properties. E.g you could have multiple ethernet drivers bind to ENET_CORE_ID, but then have each one check if the ethernet hardware is actually the one that the driver was written for.

A much harder thing to do would be having one device managed by multiple drivers simultaneously. This usually requires to have some kind of abstraction driver that provides interfaces to other drivers, or something like MFD that creates devices as children of the main device, and lets those be bound to individual drivers.

Arnd

#4 lore raw
In reply to Arend van Spriel
Quoted 2 lines · Arend van Spriel

Would it be possible to make chipcommon driver optional (not doing the initialization)?

This would need to be done on a per-device/bus basis, at least for embedded. Consider the following setup (which is quite common for dual band routers):

BCM4718

+- Common Core <- provides flash write access, GPIOs, watchdog, ...
+- 802.11 Core <- for 2.4Ghz wifi
+- PCIe Core
  + BCM43224
    +- Common Core
    +- 802.11 Core <- for 5Ghz wifi

(I omitted any cores not relevant for the example)

So eventually you want to able to drive both 802.11 cores, but can't exclusively claim both common cores.

Regards
Jonas

#5 lore raw
Quoted 9 lines · Jonas Gorski
Quoted 2 lines · Arend van Spriel

Would it be possible to make chipcommon driver optional (not doing the initialization)?

This would need to be done on a per-device/bus basis, at least for embedded. Consider the following setup (which is quite common for dual band routers):

BCM4718 (bus A)

+- MIPS74k

Quoted 8 lines
+- Common Core <- provides flash write access, GPIOs, watchdog, ...
+- 802.11 Core <- for 2.4Ghz wifi
+- PCIe Core
  + BCM43224 (bus B)
    +- Common Core
    +- 802.11 Core <- for 5Ghz wifi

(I omitted any cores not relevant for the example)

The MIPS may be relevant as well ;-)

In the example above I would expect two axi bus driver instances for bus A and bus B.

Quoted 2 lines

So eventually you want to able to drive both 802.11 cores, but can't exclusively claim both common cores.

I would expect to be probed twice. One call for 2.4GHz 802.11 core referencing to bus A and one call for 5GHz 802.11 core referencing to bus B.

Regarding chipcommon I agree that it requires one init sequence per device. I would just like to have the option to provide a custom initialization function for chip common (and possibly pcie) somehow.

Gr. AvS

Signature · 1 line
"The world is indeed comic, but the joke is on mankind." ? H.P. Lovecraft