axi: add AXI bus driver
RFC PATCH v4 1/1 axi: add AXI bus driver
---
Greg: is this what you expected from dynamic allocation and documentation?
Did I miss any other comments about something to change?
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
--- Documentation/ABI/testing/sysfs-bus-axi | 31 +++ drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/axi/Kconfig | 33 +++ drivers/axi/Makefile | 7 + drivers/axi/TODO | 3 + drivers/axi/axi_pci_bridge.c | 33 +++ drivers/axi/axi_private.h | 37 +++ drivers/axi/core.c | 51 ++++ drivers/axi/driver_chipcommon.c | 87 +++++++ drivers/axi/driver_chipcommon_pmu.c | 134 ++++++++++ drivers/axi/driver_pci.c | 163 ++++++++++++ drivers/axi/host_pci.c | 178 +++++++++++++ drivers/axi/main.c | 271 ++++++++++++++++++++ drivers/axi/scan.c | 392 +++++++++++++++++++++++++++++ drivers/axi/scan.h | 56 ++++ include/linux/axi/axi.h | 227 +++++++++++++++++ include/linux/axi/axi_driver_chipcommon.h | 308 ++++++++++++++++++++++ include/linux/axi/axi_driver_pci.h | 89 +++++++ include/linux/axi/axi_regs.h | 34 +++ include/linux/mod_devicetable.h | 17 ++ scripts/mod/file2alias.c | 21 ++ 22 files changed, 2175 insertions(+), 0 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-bus-axi create mode 100644 drivers/axi/Kconfig create mode 100644 drivers/axi/Makefile create mode 100644 drivers/axi/TODO create mode 100644 drivers/axi/axi_pci_bridge.c create mode 100644 drivers/axi/axi_private.h create mode 100644 drivers/axi/core.c create mode 100644 drivers/axi/driver_chipcommon.c create mode 100644 drivers/axi/driver_chipcommon_pmu.c create mode 100644 drivers/axi/driver_pci.c create mode 100644 drivers/axi/host_pci.c create mode 100644 drivers/axi/main.c create mode 100644 drivers/axi/scan.c create mode 100644 drivers/axi/scan.h create mode 100644 include/linux/axi/axi.h create mode 100644 include/linux/axi/axi_driver_chipcommon.h create mode 100644 include/linux/axi/axi_driver_pci.h create mode 100644 include/linux/axi/axi_regs.h
Documentation/ABI/testing/sysfs-bus-axi new file +31 -0
@@ -0,0 +1,31 @@ +What: /sys/bus/axi/devices/.../class +Date: April 2011 +KernelVersion: 2.6.40 +Contact: Rafał Miłecki <[email protected]> +Description: + Each AXI core is identified by few fields, including class it + belongs to. See include/linux/axi/axi.h for possible values. + +What: /sys/bus/axi/devices/.../manuf +Date: April 2011 +KernelVersion: 2.6.40 +Contact: Rafał Miłecki <[email protected]> +Description: + Each AXI core has it's manufacturer id. See + include/linux/axi/axi.h for possible values. + +What: /sys/bus/axi/devices/.../rev +Date: April 2011 +KernelVersion: 2.6.40 +Contact: Rafał Miłecki <[email protected]> +Description: + AXI cores of the same type can still slightly differ depending + on their revision. Use it for detailed programming. + +What: /sys/bus/axi/devices/.../id +Date: April 2011 +KernelVersion: 2.6.40 +Contact: Rafał Miłecki <[email protected]> +Description: + There are a few types of AXI cores, they can be identified by + id field.
drivers/Kconfig +2 -0
@@ -68,6 +68,8 @@ source "drivers/watchdog/Kconfig" source "drivers/ssb/Kconfig" +source "drivers/axi/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_AXI) += axi/ obj-$(CONFIG_VHOST_NET) += vhost/ obj-$(CONFIG_VLYNQ) += vlynq/ obj-$(CONFIG_STAGING) += staging/
drivers/axi/Kconfig new file +33 -0
@@ -0,0 +1,33 @@ +config AXI_POSSIBLE + bool + depends on HAS_IOMEM && HAS_DMA + default y + +menu "AMBA AXI" + depends on AXI_POSSIBLE + +config AXI + tristate "AXI support" + depends on AXI_POSSIBLE + help + Bus driver for one of the Advanced Microcontroller Bus Architecture + interfaces: Advanced eXtensible Interface. + +config AXI_HOST_PCI_POSSIBLE + bool + depends on AXI && PCI = y + default y + +config AXI_HOST_PCI + bool "Support for AXI on PCI-host bus" + depends on AXI_HOST_PCI_POSSIBLE + +config AXI_DEBUG + bool "AXI debugging" + depends on AXI + help + This turns on additional debugging messages. + + If unsure, say N + +endmenu
drivers/axi/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +axi-y += main.o scan.o core.o +axi-y += driver_chipcommon.o driver_chipcommon_pmu.o +axi-y += driver_pci.o +axi-$(CONFIG_AXI_HOST_PCI) += host_pci.o axi_pci_bridge.o +obj-$(CONFIG_AXI) += axi.o + +ccflags-$(CONFIG_AXI_DEBUG) := -DDEBUG
drivers/axi/TODO new file +3 -0
@@ -0,0 +1,3 @@ +- Interrupts +- Defines for PCI core driver +- Convert axi_bus->cores into linked list
drivers/axi/axi_pci_bridge.c new file +33 -0
@@ -0,0 +1,33 @@ +/* +* AXI PCI bridge module +* +* Licensed under the GNU/GPL. See COPYING for details. +*/ + +#include "axi_private.h" + +#include <linux/axi/axi.h> +#include <linux/pci.h> + +static DEFINE_PCI_DEVICE_TABLE (axi_pci_bridge_tbl) = { + {PCI_DEVICE (PCI_VENDOR_ID_BROADCOM ,0x4331 ) }, + {PCI_DEVICE (PCI_VENDOR_ID_BROADCOM ,0x4353 ) }, + {PCI_DEVICE (PCI_VENDOR_ID_BROADCOM ,0x4727 ) }, + {0 , }, +}; +MODULE_DEVICE_TABLE (pci, axi_pci_bridge_tbl); + +static struct pci_driver axi_pci_bridge_driver = { + .name ="axi-pci-bridge" , + .id_table = axi_pci_bridge_tbl, +}; + +int __init axi_pci_bridge_init (void ) +{ +return axi_host_pci_register (&axi_pci_bridge_driver); +} + +void __exit axi_pci_bridge_exit(void) +{ +axi_host_pci_unregister (&axi_pci_bridge_driver); +}
drivers/axi/axi_private.h new file +37 -0
@@ -0,0 +1,37 @@ +#ifndef LINUX_AXI_PRIVATE_H_ +#define LINUX_AXI_PRIVATE_H_ + +#ifndef pr_fmt +#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt +#endif + +#include <linux/axi/axi.h> + +#define AXI_ADDR_BASE 0x18000000 +#define AXI_WRAP_BASE 0x18100000 + +#define AXI_CORE_SIZE 0x1000 + +struct axi_bus ; + +/* main.c */ +extern int axi_bus_register (struct axi_bus *bus); +extern void axi_bus_unregister (struct axi_bus *bus); + +/* scan.c */ +int axi_bus_scan (struct axi_bus *bus); + +#ifdef CONFIG_AXI_HOST_PCI +/* b43_pci_ai_bridge.c */ +extern int __init axi_pci_bridge_init (void ); +extern void __exit axi_pci_bridge_exit(void); + +/* host_pci.c */ +extern int axi_host_pci_register (struct pci_driver *driver); +static inline void axi_host_pci_unregister (struct pci_driver *driver) +{ +pci_unregister_driver (driver); +} +#endif /* CONFIG_AXI_HOST_PCI */ + +#endif
drivers/axi/core.c new file +51 -0
51 lines not on this page · raw message
drivers/axi/driver_chipcommon.c new file +87 -0
87 lines not on this page · raw message
drivers/axi/driver_chipcommon_pmu.c new file +134 -0
134 lines not on this page · raw message
drivers/axi/driver_pci.c new file +163 -0
163 lines not on this page · raw message
drivers/axi/host_pci.c new file +178 -0
178 lines not on this page · raw message
drivers/axi/main.c new file +271 -0
271 lines not on this page · raw message
drivers/axi/scan.c new file +392 -0
392 lines not on this page · raw message
drivers/axi/scan.h new file +56 -0
56 lines not on this page · raw message
include/linux/axi/axi.h new file +227 -0
227 lines not on this page · raw message
include/linux/axi/axi_driver_chipcommon.h new file +308 -0
308 lines not on this page · raw message
include/linux/axi/axi_driver_pci.h new file +89 -0
89 lines not on this page · raw message
include/linux/axi/axi_regs.h new file +34 -0
@@ -0,0 +1,34 @@ +#ifndef LINUX_AXI_REGS_H_ +#define LINUX_AXI_REGS_H_ + +/* Agent registers (common for every core) */ +#define AXI_IOCTL 0x0408 +#define AXI_IOCTL_CORE_BITS 0x3FFC +#define AXI_IOCTL_CLK 0x0001 +#define AXI_IOCTL_FGC 0x0002 +#define AXI_IOCTL_PME_EN 0x4000 +#define AXI_IOCTL_BIST_EN 0x8000 +#define AXI_RESET_CTL 0x0800 +#define AXI_RESET_CTL_RESET 0x0001 + +/* AXI PCI config space registers. */ +#define AXI_PCI_PMCSR 0x44 +#define AXI_PCI_PE 0x100 +#define AXI_PCI_BAR0_WIN 0x80/* Backplane address space 0 */ +#define AXI_PCI_BAR1_WIN 0x84/* Backplane address space 1 */ +#define AXI_PCI_SPROMCTL 0x88/* SPROM control */ +#define AXI_PCI_SPROMCTL_WE 0x10/* SPROM write enable */ +#define AXI_PCI_BAR1_CONTROL 0x8c/* Address space 1 burst control */ +#define AXI_PCI_IRQS 0x90/* PCI interrupts */ +#define AXI_PCI_IRQMASK 0x94/* PCI IRQ control and mask (pcirev >= 6 only) */ +#define AXI_PCI_BACKPLANE_IRQS 0x98/* Backplane Interrupts */ +#define AXI_PCI_BAR0_WIN2 0xAC +#define AXI_PCI_GPIO_IN 0xB0/* GPIO Input (pcirev >= 3 only) */ +#define AXI_PCI_GPIO_OUT 0xB4/* GPIO Output (pcirev >= 3 only) */ +#define AXI_PCI_GPIO_OUT_ENABLE 0xB8/* GPIO Output Enable/Disable (pcirev >= 3 only) */ +#define AXI_PCI_GPIO_SCS 0x10/* PCI config space bit 4 for 4306c0 slow clock source */ +#define AXI_PCI_GPIO_HWRAD 0x20/* PCI config space GPIO 13 for hw radio disable */ +#define AXI_PCI_GPIO_XTAL 0x40/* PCI config space GPIO 14 for Xtal powerup */ +#define AXI_PCI_GPIO_PLL 0x80/* PCI config space GPIO 15 for PLL powerdown */ + +#endif /* LINUX_AXI_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 +/* AMBA AXI core, see drivers/axi/ */ +struct axi_device_id { +__u16 manuf; +__u16 id; +__u8 rev; +__u8 class; +}; +#define AXI_CORE (_manuf, _id, _rev, _class) \ + { .manuf = _manuf, .id = _id, .rev = _rev, .class = _class, } +#define AXI_CORETABLE_END \ + { 0, }, + +#define AXI_ANY_MANUF 0xFFFF +#define AXI_ANY_ID 0xFFFF +#define AXI_ANY_REV 0xFF +#define AXI_ANY_CLASS 0xFF +struct virtio_device_id {__u32 device;__u32 vendor;
scripts/mod/file2alias.c +21 -0
@@ -702,6 +702,23 @@ static int do_ssb_entry(const char *filename,return 1 ; } +/* Looks like: axi:mNidNrevNclN. */ +static int do_axi_entry (const char *filename, +struct axi_device_id *id,char *alias) +{ + id->manuf =TO_NATIVE (id->manuf); + id->id =TO_NATIVE (id->id); + id->rev =TO_NATIVE (id->rev); + +strcpy (alias,"axi:" ); +ADD (alias,"m" , id->manuf !=AXI_ANY_MANUF , id->manuf); +ADD (alias,"id" , id->id !=AXI_ANY_ID , id->id); +ADD (alias,"rev" , id->rev !=AXI_ANY_REV , id->rev); +ADD (alias,"cl" , id->class !=AXI_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 +985,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_axi_device_table")) + do_table(symval, sym->st_size, + sizeof(struct axi_device_id), "axi", + do_axi_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
Quoted 231 lines · Rafa? Mi?ecki
Cc Greg KH <[email protected]>Cc Michael B?sch <[email protected]>Cc Larry Finger <[email protected]>Cc George Kashperko <[email protected]>Cc Arend van Spriel <[email protected]>Cc linux-arm-kernel at lists.infradead.orgCc Russell King <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Andy Botting <[email protected]>Cc linuxdriverproject <[email protected]>Cc linux-kernel at vger.kernel.org <[email protected]>Signed-off-by Rafa? Mi?ecki <[email protected]>---
Greg: is this what you expected from dynamic allocation and documentation?Did I miss any other comments about something to change?
V2: Rename to axi
UseDEFINE_PCI_DEVICE_TABLEin bridge
Make use ofpr_fmtand pr_*
Store core class
Rename bridge to not b43 specific
Replace magic0x1000withBCMAI_CORE_SIZERemove some old "ssb" names and defines
MoveBCMAI_ADDR_BASEdef
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--- Documentation/ABI/testing/sysfs-bus-axi | 31 +++ drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/axi/Kconfig | 33 +++ drivers/axi/Makefile | 7 + drivers/axi/TODO | 3 + drivers/axi/axi_pci_bridge.c | 33 +++ drivers/axi/axi_private.h | 37 +++ drivers/axi/core.c | 51 ++++ drivers/axi/driver_chipcommon.c | 87 +++++++ drivers/axi/driver_chipcommon_pmu.c | 134 ++++++++++ drivers/axi/driver_pci.c | 163 ++++++++++++ drivers/axi/host_pci.c | 178 +++++++++++++ drivers/axi/main.c | 271 ++++++++++++++++++++ drivers/axi/scan.c | 392 +++++++++++++++++++++++++++++ drivers/axi/scan.h | 56 ++++ include/linux/axi/axi.h | 227 +++++++++++++++++ include/linux/axi/axi_driver_chipcommon.h | 308 ++++++++++++++++++++++ include/linux/axi/axi_driver_pci.h | 89 +++++++ include/linux/axi/axi_regs.h | 34 +++ include/linux/mod_devicetable.h | 17 ++ scripts/mod/file2alias.c | 21 ++ 22 files changed, 2175 insertions(+), 0 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-bus-axi create mode 100644 drivers/axi/Kconfig create mode 100644 drivers/axi/Makefile create mode 100644 drivers/axi/TODO create mode 100644 drivers/axi/axi_pci_bridge.c create mode 100644 drivers/axi/axi_private.h create mode 100644 drivers/axi/core.c create mode 100644 drivers/axi/driver_chipcommon.c create mode 100644 drivers/axi/driver_chipcommon_pmu.c create mode 100644 drivers/axi/driver_pci.c create mode 100644 drivers/axi/host_pci.c create mode 100644 drivers/axi/main.c create mode 100644 drivers/axi/scan.c create mode 100644 drivers/axi/scan.h create mode 100644 include/linux/axi/axi.h create mode 100644 include/linux/axi/axi_driver_chipcommon.h create mode 100644 include/linux/axi/axi_driver_pci.h create mode 100644 include/linux/axi/axi_regs.hDocumentation/ABI/testing/sysfs-bus-axi new file +31
-0@@ -0,0 +1,31 @@ +What: /sys/bus/axi/devices/.../class +Date: April 2011 +KernelVersion: 2.6.40 +Contact: Rafa? Mi?ecki <[email protected]> +Description: + Each AXI core is identified by few fields, including class it + belongs to. See include/linux/axi/axi.h for possible values. + +What: /sys/bus/axi/devices/.../manuf +Date: April 2011 +KernelVersion: 2.6.40 +Contact: Rafa? Mi?ecki <[email protected]> +Description: + Each AXI core has it's manufacturer id. See + include/linux/axi/axi.h for possible values. + +What: /sys/bus/axi/devices/.../rev +Date: April 2011 +KernelVersion: 2.6.40 +Contact: Rafa? Mi?ecki <[email protected]> +Description: + AXI cores of the same type can still slightly differ depending + on their revision. Use it for detailed programming. + +What: /sys/bus/axi/devices/.../id +Date: April 2011 +KernelVersion: 2.6.40 +Contact: Rafa? Mi?ecki <[email protected]> +Description: + There are a few types of AXI cores, they can be identified by + id field.drivers/Kconfig +2
-0@@ -68,6 +68,8 @@ source "drivers/watchdog/Kconfig" source "drivers/ssb/Kconfig" +source "drivers/axi/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_AXI) += axi/ obj-$(CONFIG_VHOST_NET) += vhost/ obj-$(CONFIG_VLYNQ) += vlynq/ obj-$(CONFIG_STAGING) += staging/drivers/axi/Kconfig new file +33
-0@@ -0,0 +1,33 @@ +config AXI_POSSIBLE + bool + depends on HAS_IOMEM && HAS_DMA + default y + +menu "AMBA AXI" + depends on AXI_POSSIBLE + +config AXI + tristate "AXI support" + depends on AXI_POSSIBLE + help + Bus driver for one of the Advanced Microcontroller Bus Architecture + interfaces: Advanced eXtensible Interface. + +config AXI_HOST_PCI_POSSIBLE + bool + depends on AXI && PCI = y + default y + +config AXI_HOST_PCI + bool "Support for AXI on PCI-host bus" + depends on AXI_HOST_PCI_POSSIBLE + +config AXI_DEBUG + bool "AXI debugging" + depends on AXI + help + This turns on additional debugging messages. + + If unsure, say N + +endmenudrivers/axi/Makefile new file +7
-0@@ -0,0 +1,7 @@ +axi-y += main.o scan.o core.o +axi-y += driver_chipcommon.o driver_chipcommon_pmu.o +axi-y += driver_pci.o +axi-$(CONFIG_AXI_HOST_PCI) += host_pci.o axi_pci_bridge.o +obj-$(CONFIG_AXI) += axi.o + +ccflags-$(CONFIG_AXI_DEBUG) := -DDEBUGdrivers/axi/TODO new file +3
-0@@ -0,0 +1,3 @@ +- Interrupts +- Defines for PCI core driver +- Convert axi_bus->cores into linked listdrivers/axi/axi_pci_bridge.c new file +23
-0@@ -0,0 +1,33 @@ +/* +* AXI PCI bridge module +* +* Licensed under the GNU/GPL. See COPYING for details. +*/ + +#include "axi_private.h" + +#include <linux/axi/axi.h> +#include <linux/pci.h> + +static DEFINE_PCI_DEVICE_TABLE (axi_pci_bridge_tbl) = { + {PCI_DEVICE (PCI_VENDOR_ID_BROADCOM ,0x4331 ) }, + {PCI_DEVICE (PCI_VENDOR_ID_BROADCOM ,0x4353 ) }, + {PCI_DEVICE (PCI_VENDOR_ID_BROADCOM ,0x4727 ) }, + {0 , }, +}; +MODULE_DEVICE_TABLE (pci, axi_pci_bridge_tbl); + +static struct pci_driver axi_pci_bridge_driver = { + .name ="axi-pci-bridge" , + .id_table = axi_pci_bridge_tbl, +};
drivers/axi/axi_pci_bridge.c line 33
Quoted 10 lines
drivers/axi/axi_pci_bridge.c new file +10
-0+ +int __init axi_pci_bridge_init (void ) +{ +return axi_host_pci_register (&axi_pci_bridge_driver); +} + +void __exit axi_pci_bridge_exit(void) +{ +axi_host_pci_unregister (&axi_pci_bridge_driver); +}
You register a pci driver that does nothing? That's not right, you need to then base your axi bus off of that pci device, so it is hooked up correctly in the /sys/devices/ tree. Otherwise you are somewhere up in the virtual location for your axi bus, right?
drivers/axi/axi_pci_bridge.c
Quoted 10 lines
drivers/axi/axi_pci_bridge.c new file +10
-0+bool axi_core_is_enabled (struct axi_device *core) +{ +if ((axi_aread32 (core,AXI_IOCTL ) & (AXI_IOCTL_CLK |AXI_IOCTL_FGC )) + !=AXI_IOCTL_CLK ) +return false; +if (axi_aread32 (core,AXI_RESET_CTL ) &AXI_RESET_CTL_RESET ) +return false; +return true; +} +EXPORT_SYMBOL (axi_core_is_enabled);
EXPORT_SYMBOL_GPL()?
What module uses this? And why would it care?
Quoted 1 line
+EXPORT_SYMBOL(axi_core_enable);
EXPORT_SYMBOL_GPL()?
Same goes for your other exports, just want you to be sure here.
drivers/axi/axi_pci_bridge.c
Quoted 5 lines
drivers/axi/axi_pci_bridge.c new file +5
-0+u32 xaxi_chipco_gpio_control (struct axi_drv_cc *cc,u32 mask,u32 value) +{ +return axi_cc_write32_masked (cc,AXI_CC_GPIOCTL , mask, value); +} +EXPORT_SYMBOL (xaxi_chipco_gpio_control);
"xaxi"? Shouldn't that be consistant with the other exports and start with "axi"?
drivers/axi/axi_pci_bridge.c
Quoted 3 lines
drivers/axi/axi_pci_bridge.c new file +3
-0+static u8 axi_host_pci_read8 (struct axi_device *core,u16 offset) +{ +if (unlikely (core->bus->mapped_core != core))
Are you sure about the use of unlikely in this, and other functions? The compiler almost always does a better job than we do for these types of calls, just let it do it's job.
drivers/axi/axi_pci_bridge.c
Quoted 2 lines
drivers/axi/axi_pci_bridge.c new file +2
-0+axi_host_pci_switch_core (core); +return ioread8 (core->bus->mmio + offset);
I think because of that unlikely, you just slowed down all pci devices, right? That's not very nice :)
thanks,
greg k-h
Quoted 290 lines · Rafa? Mi?ecki
Cc Greg KH<[email protected]>Cc Michael B?sch<[email protected]>Cc Larry Finger<[email protected]>Cc George Kashperko<[email protected]>Cc Arend van Spriel<[email protected]>Cc linux-arm-kernel at lists.infradead.orgCc Russell King<[email protected]>Cc Arnd Bergmann<[email protected]>Cc Andy Botting<[email protected]>Cc linuxdriverproject<[email protected]>Cc linux-kernel at vger.kernel.org<[email protected]>Signed-off-by Rafa? Mi?ecki<[email protected]>---
Greg: is this what you expected from dynamic allocation and documentation?Did I miss any other comments about something to change?
V2: Rename to axi
UseDEFINE_PCI_DEVICE_TABLEin bridge
Make use ofpr_fmtand pr_*
Store core class
Rename bridge to not b43 specific
Replace magic0x1000withBCMAI_CORE_SIZERemove some old "ssb" names and defines
MoveBCMAI_ADDR_BASEdef
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--- Documentation/ABI/testing/sysfs-bus-axi | 31 +++ drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/axi/Kconfig | 33 +++ drivers/axi/Makefile | 7 + drivers/axi/TODO | 3 + drivers/axi/axi_pci_bridge.c | 33 +++ drivers/axi/axi_private.h | 37 +++ drivers/axi/core.c | 51 ++++ drivers/axi/driver_chipcommon.c | 87 +++++++ drivers/axi/driver_chipcommon_pmu.c | 134 ++++++++++ drivers/axi/driver_pci.c | 163 ++++++++++++ drivers/axi/host_pci.c | 178 +++++++++++++ drivers/axi/main.c | 271 ++++++++++++++++++++ drivers/axi/scan.c | 392 +++++++++++++++++++++++++++++ drivers/axi/scan.h | 56 ++++ include/linux/axi/axi.h | 227 +++++++++++++++++ include/linux/axi/axi_driver_chipcommon.h | 308 ++++++++++++++++++++++ include/linux/axi/axi_driver_pci.h | 89 +++++++ include/linux/axi/axi_regs.h | 34 +++ include/linux/mod_devicetable.h | 17 ++ scripts/mod/file2alias.c | 21 ++ 22 files changed, 2175 insertions(+), 0 deletions(-)create mode 100644
Documentation/ABI/testing/sysfs-bus-axicreate mode 100644drivers/axi/Kconfig
create mode 100644drivers/axi/Makefile
create mode 100644drivers/axi/TODO
create mode 100644drivers/axi/axi_pci_bridge.ccreate mode 100644drivers/axi/axi_private.hcreate mode 100644drivers/axi/core.c
create mode 100644drivers/axi/driver_chipcommon.ccreate mode 100644drivers/axi/driver_chipcommon_pmu.ccreate mode 100644drivers/axi/driver_pci.c
create mode 100644drivers/axi/host_pci.c
create mode 100644drivers/axi/main.c
create mode 100644drivers/axi/scan.c
create mode 100644drivers/axi/scan.h
create mode 100644include/linux/axi/axi.h
create mode 100644include/linux/axi/axi_driver_chipcommon.hcreate mode 100644include/linux/axi/axi_driver_pci.hcreate mode 100644include/linux/axi/axi_regs.hDocumentation/ABI/testing/sysfs-bus-axi new file +31
-0@@ -0,0 +1,31 @@ +What: /sys/bus/axi/devices/.../class +Date: April 2011 +KernelVersion: 2.6.40 +Contact: Rafa? Mi?ecki<[email protected]> +Description: + Each AXI core is identified by few fields, including class it + belongs to. See include/linux/axi/axi.h for possible values. + +What: /sys/bus/axi/devices/.../manuf +Date: April 2011 +KernelVersion: 2.6.40 +Contact: Rafa? Mi?ecki<[email protected]> +Description: + Each AXI core has it's manufacturer id. See + include/linux/axi/axi.h for possible values. + +What: /sys/bus/axi/devices/.../rev +Date: April 2011 +KernelVersion: 2.6.40 +Contact: Rafa? Mi?ecki<[email protected]> +Description: + AXI cores of the same type can still slightly differ depending + on their revision. Use it for detailed programming. + +What: /sys/bus/axi/devices/.../id +Date: April 2011 +KernelVersion: 2.6.40 +Contact: Rafa? Mi?ecki<[email protected]> +Description: + There are a few types of AXI cores, they can be identified by + id field.drivers/Kconfig +2
-0@@ -68,6 +68,8 @@ source "drivers/watchdog/Kconfig" source "drivers/ssb/Kconfig" +source "drivers/axi/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_AXI) += axi/ obj-$(CONFIG_VHOST_NET) += vhost/ obj-$(CONFIG_VLYNQ) += vlynq/ obj-$(CONFIG_STAGING) += staging/drivers/axi/Kconfig new file +33
-0@@ -0,0 +1,33 @@ +config AXI_POSSIBLE + bool + depends on HAS_IOMEM&& HAS_DMA + default y + +menu "AMBA AXI" + depends on AXI_POSSIBLE + +config AXI + tristate "AXI support" + depends on AXI_POSSIBLE + help + Bus driver for one of the Advanced Microcontroller Bus Architecture + interfaces: Advanced eXtensible Interface. + +config AXI_HOST_PCI_POSSIBLE + bool + depends on AXI&& PCI = y + default y + +config AXI_HOST_PCI + bool "Support for AXI on PCI-host bus" + depends on AXI_HOST_PCI_POSSIBLE + +config AXI_DEBUG + bool "AXI debugging" + depends on AXI + help + This turns on additional debugging messages. + + If unsure, say N + +endmenudrivers/axi/Makefile new file +7
-0@@ -0,0 +1,7 @@ +axi-y += main.o scan.o core.o +axi-y += driver_chipcommon.o driver_chipcommon_pmu.o +axi-y += driver_pci.o +axi-$(CONFIG_AXI_HOST_PCI) += host_pci.o axi_pci_bridge.o +obj-$(CONFIG_AXI) += axi.o + +ccflags-$(CONFIG_AXI_DEBUG) := -DDEBUGdrivers/axi/TODO new file +3
-0@@ -0,0 +1,3 @@ +- Interrupts +- Defines for PCI core driver +- Convert axi_bus->cores into linked listdrivers/axi/axi_pci_bridge.c new file +33
-0@@ -0,0 +1,33 @@ +/* +* AXI PCI bridge module +* +* Licensed under the GNU/GPL. See COPYING for details. +*/ + +#include "axi_private.h" + +#include <linux/axi/axi.h> +#include <linux/pci.h> + +static DEFINE_PCI_DEVICE_TABLE (axi_pci_bridge_tbl) = { + {PCI_DEVICE (PCI_VENDOR_ID_BROADCOM ,0x4331 ) }, + {PCI_DEVICE (PCI_VENDOR_ID_BROADCOM ,0x4353 ) }, + {PCI_DEVICE (PCI_VENDOR_ID_BROADCOM ,0x4727 ) }, + {0 , }, +}; +MODULE_DEVICE_TABLE (pci, axi_pci_bridge_tbl); + +static struct pci_driver axi_pci_bridge_driver = { + .name ="axi-pci-bridge" , + .id_table = axi_pci_bridge_tbl, +}; + +int __init axi_pci_bridge_init (void ) +{ +return axi_host_pci_register (&axi_pci_bridge_driver); +} + +void __exit axi_pci_bridge_exit(void) +{ +axi_host_pci_unregister (&axi_pci_bridge_driver); +}drivers/axi/axi_private.h new file +37
-0@@ -0,0 +1,37 @@ +#ifndef LINUX_AXI_PRIVATE_H_ +#define LINUX_AXI_PRIVATE_H_ + +#ifndef pr_fmt +#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt +#endif + +#include <linux/axi/axi.h> + +#define AXI_ADDR_BASE 0x18000000 +#define AXI_WRAP_BASE 0x18100000 + +#define AXI_CORE_SIZE 0x1000 + +struct axi_bus ; + +/* main.c */ +extern int axi_bus_register (struct axi_bus *bus); +extern void axi_bus_unregister (struct axi_bus *bus); + +/* scan.c */ +int axi_bus_scan (struct axi_bus *bus); + +#ifdef CONFIG_AXI_HOST_PCI +/* b43_pci_ai_bridge.c */ +extern int __init axi_pci_bridge_init (void ); +extern void __exit axi_pci_bridge_exit(void); + +/* host_pci.c */ +extern int axi_host_pci_register (struct pci_driver *driver); +static inline void axi_host_pci_unregister (struct pci_driver *driver) +{ +pci_unregister_driver (driver); +} +#endif /* CONFIG_AXI_HOST_PCI */ + +#endif drivers/axi/core.c new file +0
-0
drivers/axi/core.c line 9
Quoted 9 lines
drivers/axi/core.c new file +9
-0@@ -0,0 +1,51 @@ +/* +* AMBA AXI +* Core ops +* +* Licensed under the GNU/GPL. See COPYING for details. +*/ + +#include "axi_private.h" +#include <linux/axi/axi.h>
#include <linux/delay.h>
Quoted 283 lines
drivers/axi/core.c new file +42
-0+ +bool axi_core_is_enabled (struct axi_device *core) +{ +if ((axi_aread32 (core,AXI_IOCTL )& (AXI_IOCTL_CLK |AXI_IOCTL_FGC )) + !=AXI_IOCTL_CLK ) +return false; +if (axi_aread32 (core,AXI_RESET_CTL )&AXI_RESET_CTL_RESET ) +return false; +return true; +} +EXPORT_SYMBOL (axi_core_is_enabled); + +static void axi_core_disable (struct axi_device *core,u32 flags) +{ +if (axi_aread32 (core,AXI_RESET_CTL )&AXI_RESET_CTL_RESET ) +return ; + +axi_awrite32 (core,AXI_IOCTL , flags); +axi_aread32 (core,AXI_IOCTL ); +udelay (10 ); + +axi_awrite32 (core,AXI_RESET_CTL ,AXI_RESET_CTL_RESET ); +udelay (1 ); +} + +int axi_core_enable (struct axi_device *core,u32 flags) +{ +axi_core_disable (core, flags); + +axi_awrite32 (core,AXI_IOCTL , (AXI_IOCTL_CLK |AXI_IOCTL_FGC | flags)); +axi_aread32 (core,AXI_IOCTL ); + +axi_awrite32 (core,AXI_RESET_CTL ,0 ); +udelay (1 ); + +axi_awrite32 (core,AXI_IOCTL , (AXI_IOCTL_CLK | flags)); +axi_aread32 (core,AXI_IOCTL ); +udelay (1 ); + +return 0 ; +} +EXPORT_SYMBOL (axi_core_enable);drivers/axi/driver_chipcommon.c new file +87
-0@@ -0,0 +1,87 @@ +/* +* AMBA AXI +* ChipCommon core driver +* +* Copyright 2005, Broadcom Corporation +* Copyright 2006, 2007, Michael Buesch<[email protected]> +* +* Licensed under the GNU/GPL. See COPYING for details. +*/ + +#include "axi_private.h" +#include <linux/axi/axi.h> + +static inline u32 axi_cc_write32_masked (struct axi_drv_cc *cc,u16 offset, +u32 mask,u32 value) +{ + value&= mask; + value |=axi_cc_read32 (cc, offset)& ~mask; +axi_cc_write32 (cc, offset, value); + +return value; +} + +void axi_core_chipcommon_init (struct axi_drv_cc *cc) +{ +if (cc->core->id.rev>=11 ) + cc->status =axi_cc_read32 (cc,AXI_CC_CHIPSTAT ); + cc->capabilities =axi_cc_read32 (cc,AXI_CC_CAP ); +if (cc->core->id.rev>=35 ) + cc->capabilities_ext =axi_cc_read32 (cc,AXI_CC_CAP_EXT ); + +axi_cc_write32 (cc,0x58 ,0 ); +axi_cc_write32 (cc,0x5C ,0 ); + +if (cc->capabilities&AXI_CC_CAP_PMU ) +axi_pmu_init (cc); +if (cc->capabilities&AXI_CC_CAP_PCTL ) +pr_err ("Power control not implemented!\n" ); +} + +/* Set chip watchdog reset timer to fire in 'ticks' backplane cycles */ +void axi_chipco_watchdog_timer_set (struct axi_drv_cc *cc,u32 ticks) +{ +/* instant NMI */ +axi_cc_write32 (cc,AXI_CC_WATCHDOG , ticks); +} + +void axi_chipco_irq_mask (struct axi_drv_cc *cc,u32 mask,u32 value) +{ +axi_cc_write32_masked (cc,AXI_CC_IRQMASK , mask, value); +} + +u32 axi_chipco_irq_status (struct axi_drv_cc *cc,u32 mask) +{ +return axi_cc_read32 (cc,AXI_CC_IRQSTAT )& mask; +} + +u32 axi_chipco_gpio_in (struct axi_drv_cc *cc,u32 mask) +{ +return axi_cc_read32 (cc,AXI_CC_GPIOIN )& mask; +} + +u32 axi_chipco_gpio_out (struct axi_drv_cc *cc,u32 mask,u32 value) +{ +return axi_cc_write32_masked (cc,AXI_CC_GPIOOUT , mask, value); +} + +u32 axi_chipco_gpio_outen (struct axi_drv_cc *cc,u32 mask,u32 value) +{ +return axi_cc_write32_masked (cc,AXI_CC_GPIOOUTEN , mask, value); +} + +u32 xaxi_chipco_gpio_control (struct axi_drv_cc *cc,u32 mask,u32 value) +{ +return axi_cc_write32_masked (cc,AXI_CC_GPIOCTL , mask, value); +} +EXPORT_SYMBOL (xaxi_chipco_gpio_control); + +u32 axi_chipco_gpio_intmask (struct axi_drv_cc *cc,u32 mask,u32 value) +{ +return axi_cc_write32_masked (cc,AXI_CC_GPIOIRQ , mask, value); +} + +u32 axi_chipco_gpio_polarity (struct axi_drv_cc *cc,u32 mask,u32 value) +{ +return axi_cc_write32_masked (cc,AXI_CC_GPIOPOL , mask, value); +}drivers/axi/driver_chipcommon_pmu.c new file +134
-0@@ -0,0 +1,134 @@ +/* +* AMBA AXI +* ChipCommon Power Management Unit driver +* +* Copyright 2009, Michael Buesch<[email protected]> +* Copyright 2007, Broadcom Corporation +* +* Licensed under the GNU/GPL. See COPYING for details. +*/ + +#include "axi_private.h" +#include <linux/axi/axi.h> + +static void axi_chipco_chipctl_maskset (struct axi_drv_cc *cc, +u32 offset,u32 mask,u32 set) +{ +u32 value; + +axi_cc_read32 (cc,AXI_CC_CHIPCTL_ADDR ); +axi_cc_write32 (cc,AXI_CC_CHIPCTL_ADDR , offset); +axi_cc_read32 (cc,AXI_CC_CHIPCTL_ADDR ); + value =axi_cc_read32 (cc,AXI_CC_CHIPCTL_DATA ); + value&= mask; + value |= set; +axi_cc_write32 (cc,AXI_CC_CHIPCTL_DATA , value); +axi_cc_read32 (cc,AXI_CC_CHIPCTL_DATA ); +} + +static void axi_pmu_pll_init (struct axi_drv_cc *cc) +{ +struct axi_bus *bus = cc->core->bus; + +switch (bus->chipinfo.id) { +case 0x4313 : +case 0x4331 : +case 43224 : +case 43225 : +break ; +default : +pr_err ("PLL init unknown for device 0x%04X\n" , + bus->chipinfo.id); + } +} + +static void axi_pmu_resources_init (struct axi_drv_cc *cc) +{ +struct axi_bus *bus = cc->core->bus; +u32 min_msk =0 , max_msk =0 ; + +switch (bus->chipinfo.id) { +case 0x4313 : + min_msk =0x200D ; + max_msk =0xFFFF ; +break ; +case 43224 : +break ; +default : +pr_err ("PMU resource config unknown for device 0x%04X\n" , + bus->chipinfo.id); + } + +/* Set the resource masks. */ +if (min_msk) +axi_cc_write32 (cc,AXI_CC_PMU_MINRES_MSK , min_msk); +if (max_msk) +axi_cc_write32 (cc,AXI_CC_PMU_MAXRES_MSK , max_msk); +} + +void axi_pmu_swreg_init (struct axi_drv_cc *cc) +{ +struct axi_bus *bus = cc->core->bus; + +switch (bus->chipinfo.id) { +case 0x4313 : +case 0x4331 : +case 43224 : +break ; +default : +pr_err ("PMU switch/regulators init unknown for device " +"0x%04X\n" , bus->chipinfo.id); + } +} + +void axi_pmu_workarounds (struct axi_drv_cc *cc) +{ +struct axi_bus *bus = cc->core->bus; + +switch (bus->chipinfo.id) { +case 0x4313 : +axi_chipco_chipctl_maskset (cc,0 , ~0 ,0x7 ); +break ; +case 0x4331 : +pr_err ("Enabling Ext PA lines not implemented\n" ); +break ; +case 43224 : +if (bus->chipinfo.rev ==0 ) { +pr_err ("Workarounds for 43224 rev 0 not fully " +"implemented\n" ); +axi_chipco_chipctl_maskset (cc,0 , ~0 ,0xF0 ); + }else { +axi_chipco_chipctl_maskset (cc,0 , ~0 ,0xF0 ); + } +break ; +default : +pr_err ("Workarounds unknown for device 0x%04X\n" , + bus->chipinfo.id); + } +} + +void axi_pmu_init (struct axi_drv_cc *cc) +{ +u32 pmucap; + + pmucap =axi_cc_read32 (cc,AXI_CC_PMU_CAP ); + cc->pmu.rev = (pmucap&AXI_CC_PMU_CAP_REVISION ); + +pr_debug ("Found rev %u PMU (capabilities 0x%08X)\n" , cc->pmu.rev, + pmucap); + +if (cc->pmu.rev ==1 ) +axi_cc_mask32 (cc,AXI_CC_PMU_CTL , + ~AXI_CC_PMU_CTL_NOILPONW ); +else +axi_cc_set32 (cc,AXI_CC_PMU_CTL , +AXI_CC_PMU_CTL_NOILPONW ); + +if (cc->core->id.id ==0x4329 && cc->core->id.rev ==2 ) +pr_err ("Fix for 4329b0 bad LPOM state not implemented!\n" ); + +axi_pmu_pll_init (cc); +axi_pmu_resources_init (cc); +axi_pmu_swreg_init (cc); +axi_pmu_workarounds (cc); +}drivers/axi/driver_pci.c new file +2
-0@@ -0,0 +1,163 @@ +/* +* AMBA AXI
drivers/axi/driver_pci.c line 12
Quoted 10 lines
drivers/axi/driver_pci.c new file +10
-0+* PCI Core +* +* Copyright 2005, Broadcom Corporation +* Copyright 2006, 2007, Michael Buesch<[email protected]> +* +* Licensed under the GNU/GPL. See COPYING for details. +*/ + +#include "axi_private.h" +#include <linux/axi/axi.h>
#include <linux/delay.h>
Are you compiling for i386 architecture? For some reason, delay.h is not included for my x86_64 system, and the include is needed for core.c and driver_pci.c.
Larry
2011/4/13 Greg KH <[email protected]>:
Quoted 36 lines
Quoted 36 lines
drivers/axi/axi_pci_bridge.c new file +30
-0@@ -0,0 +1,33 @@ +/* +* AXI PCI bridge module +* +* Licensed under the GNU/GPL. See COPYING for details. +*/ + +#include "axi_private.h" + +#include <linux/axi/axi.h> +#include <linux/pci.h> + +static DEFINE_PCI_DEVICE_TABLE (axi_pci_bridge_tbl) = { + ? ? { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4331) }, + ? ? { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4353) }, + ? ? { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4727) }, + ? ? { 0, }, +}; +MODULE_DEVICE_TABLE (pci, axi_pci_bridge_tbl); + +static struct pci_driver axi_pci_bridge_driver = { + ? ? .name = "axi-pci-bridge", + ? ? .id_table = axi_pci_bridge_tbl, +}; + +int __init axi_pci_bridge_init (void ) +{ + ? ? return axi_host_pci_register(&axi_pci_bridge_driver); +} + +void __exit axi_pci_bridge_exit(void)
Quoted 8 lines
drivers/axi/axi_pci_bridge.c line 28
Quoted 3 lines
drivers/axi/axi_pci_bridge.c new file +3
-0+{ + ? ? axi_host_pci_unregister(&axi_pci_bridge_driver); +}You register a pci driver that does nothing? ?That's not right, you need to then base your axi bus off of that pci device, so it is hooked up correctly in the
/sys/devices/tree. ?Otherwise you are somewhere up in the virtual location for your axi bus, right?
Please take a look at:driver->probe = axi_host_pci_probe;driver->remove = axi_host_pci_remove;
return pci_register_driver(driver);
Quoted 13 lines
drivers/axi/axi_pci_bridge.c
Quoted 10 lines
drivers/axi/axi_pci_bridge.c new file +10
-0+bool axi_core_is_enabled (struct axi_device *core) +{ + ? ? if ((axi_aread32(core, AXI_IOCTL) & (AXI_IOCTL_CLK | AXI_IOCTL_FGC)) + ? ? ? ? != AXI_IOCTL_CLK) + ? ? ? ? ? ? return false; + ? ? if (axi_aread32(core, AXI_RESET_CTL) & AXI_RESET_CTL_RESET) + ? ? ? ? ? ? return false; + ? ? return true; +} +EXPORT_SYMBOL (axi_core_is_enabled);
EXPORT_SYMBOL_GPL()?
Quoted 7 lines
What module uses this? ?And why would it care?
Quoted 1 line
+EXPORT_SYMBOL(axi_core_enable);
EXPORT_SYMBOL_GPL()?Same goes for your other exports, just want you to be sure here.
Hm, I'm not sure. Using EXPORT_SYMBOL_GPL will forbid closed source drivers from using our bus driver, right? I'm don't have preferences on this, if you prefer us to force GPL, I can.
Quoted 8 lines
drivers/axi/axi_pci_bridge.c
Quoted 5 lines
drivers/axi/axi_pci_bridge.c new file +5
-0+u32 xaxi_chipco_gpio_control (struct axi_drv_cc *cc,u32 mask,u32 value) +{ + ? ? return axi_cc_write32_masked(cc, AXI_CC_GPIOCTL, mask, value); +} +EXPORT_SYMBOL (xaxi_chipco_gpio_control);"xaxi"? ?Shouldn't that be consistant with the other exports and start with "axi"?
Left from old tests/rewrites/splitting. Thanks.
Quoted 8 lines
drivers/axi/axi_pci_bridge.c
Quoted 3 lines
drivers/axi/axi_pci_bridge.c new file +3
-0+static u8 axi_host_pci_read8 (struct axi_device *core,u16 offset) +{ + ? ? if (unlikely(core->bus->mapped_core != core))Are you sure about the use of unlikely in this, and other functions? The compiler almost always does a better job than we do for these types of calls, just let it do it's job.
Quoted 5 lines
Quoted 2 lines
+ ? ? ? ? ? ?
axi_host_pci_switch_core(core);
+ ? ? returnioread8(core->bus->mmio + offset);I think because of that unlikely, you just slowed down all pci devices, right? ?That's not very nice :)
Hm, my logic suggests it is alright, but please consider this once more with me ;)
For the most of the time mapped_core (active core) do not change. We perform few hundreds of operations on one core in a row. This way mapped_core points to passed core for most of the time. Condition (mapped_core != core) is unlikely to happen.
Is there anything wrong in my logic?
Signature · 1 line
Rafa?
2011/4/13 Larry Finger <[email protected]>:
Quoted 615 lines · Rafa? Mi?ecki
Quoted 299 lines
Cc Greg KH<[email protected]>Cc Michael B?sch<[email protected]>Cc Larry Finger<[email protected]>Cc George Kashperko<[email protected]>Cc Arend van Spriel<[email protected]>Cc linux-arm-kernel at lists.infradead.orgCc Russell King<[email protected]>Cc Arnd Bergmann<[email protected]>Cc Andy Botting<[email protected]>Cc linuxdriverproject<[email protected]>Cc linux-kernel at vger.kernel.org<[email protected]>Signed-off-by Rafa? Mi?ecki<[email protected]>---
Greg: is this what you expected from dynamic allocation and documentation?Did I miss any other comments about something to change?
V2: Rename to axi
? ? UseDEFINE_PCI_DEVICE_TABLEin bridge
? ? Make use ofpr_fmtand pr_*
? ? Store core class
? ? Rename bridge to not b43 specific
? ? Replace magic0x1000withBCMAI_CORE_SIZE
? ? Remove some old "ssb" names and defines
? ? MoveBCMAI_ADDR_BASEdef
? ? 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
---?Documentation/ABI/testing/sysfs-bus-axi ? | ? 31 +++ ?drivers/Kconfig ? ? ? ? ? ? ? ? ? ? ? ? ? | ? ?2 + ?drivers/Makefile ? ? ? ? ? ? ? ? ? ? ? ? ?| ? ?1 + ?drivers/axi/Kconfig ? ? ? ? ? ? ? ? ? ? ? | ? 33 +++ ?drivers/axi/Makefile ? ? ? ? ? ? ? ? ? ? ?| ? ?7 + ?drivers/axi/TODO ? ? ? ? ? ? ? ? ? ? ? ? ?| ? ?3 + ?drivers/axi/axi_pci_bridge.c ? ? ? ? ? ? ?| ? 33 +++ ?drivers/axi/axi_private.h ? ? ? ? ? ? ? ? | ? 37 +++ ?drivers/axi/core.c ? ? ? ? ? ? ? ? ? ? ? ?| ? 51 ++++ ?drivers/axi/driver_chipcommon.c ? ? ? ? ? | ? 87 +++++++ ?drivers/axi/driver_chipcommon_pmu.c ? ? ? | ?134 ++++++++++ ?drivers/axi/driver_pci.c ? ? ? ? ? ? ? ? ?| ?163 ++++++++++++ ?drivers/axi/host_pci.c ? ? ? ? ? ? ? ? ? ?| ?178 +++++++++++++ ?drivers/axi/main.c ? ? ? ? ? ? ? ? ? ? ? ?| ?271 ++++++++++++++++++++ ?drivers/axi/scan.c ? ? ? ? ? ? ? ? ? ? ? ?| ?392 +++++++++++++++++++++++++++++ ?drivers/axi/scan.h ? ? ? ? ? ? ? ? ? ? ? ?| ? 56 ++++ ?include/linux/axi/axi.h ? ? ? ? ? ? ? ? ? | ?227 +++++++++++++++++ ?include/linux/axi/axi_driver_chipcommon.h | ?308 ++++++++++++++++++++++ ?include/linux/axi/axi_driver_pci.h ? ? ? ?| ? 89 +++++++ ?include/linux/axi/axi_regs.h ? ? ? ? ? ? ?| ? 34 +++ ?include/linux/mod_devicetable.h ? ? ? ? ? | ? 17 ++ ?scripts/mod/file2alias.c ? ? ? ? ? ? ? ? ?| ? 21 ++?22 files changed, 2175 insertions(+), 0 deletions(-) ?create mode 100644
Documentation/ABI/testing/sysfs-bus-axi?create mode 100644drivers/axi/Kconfig
?create mode 100644drivers/axi/Makefile
?create mode 100644drivers/axi/TODO
?create mode 100644drivers/axi/axi_pci_bridge.c?create mode 100644drivers/axi/axi_private.h?create mode 100644drivers/axi/core.c
?create mode 100644drivers/axi/driver_chipcommon.c?create mode 100644drivers/axi/driver_chipcommon_pmu.c?create mode 100644drivers/axi/driver_pci.c?create mode 100644drivers/axi/host_pci.c
?create mode 100644drivers/axi/main.c
?create mode 100644drivers/axi/scan.c
?create mode 100644drivers/axi/scan.h
?create mode 100644include/linux/axi/axi.h
?create mode 100644include/linux/axi/axi_driver_chipcommon.h?create mode 100644include/linux/axi/axi_driver_pci.h?create mode 100644include/linux/axi/axi_regs.hDocumentation/ABI/testing/sysfs-bus-axi new file +6
-0@@ -0,0 +1,31 @@ +What: ? ? ? ? ?/sys/bus/axi/devices/.../class +Date: ? ? ? ? ?April 2011 +KernelVersion: 2.6.40 +Contact: ? ? ? Rafa? Mi?ecki<[email protected]> +Description: + ? ? ? ? ? ? ? Each AXI core is identified by few fields, including classit
+ ? ? ? ? ? ? ? belongs to. Seeinclude/linux/axi/axi.hfor possible values.Documentation/ABI/testing/sysfs-bus-axi new file +15
-0+ +What: ? ? ? ? ?/sys/bus/axi/devices/.../manuf +Date: ? ? ? ? ?April 2011 +KernelVersion: 2.6.40 +Contact: ? ? ? Rafa? Mi?ecki<[email protected]> +Description: + ? ? ? ? ? ? ? Each AXI core has it's manufacturer id. See + ? ? ? ? ? ? ? include/linux/axi/axi.h for possible values. + +What: ? ? ? ? ?/sys/bus/axi/devices/.../rev +Date: ? ? ? ? ?April 2011 +KernelVersion: 2.6.40 +Contact: ? ? ? Rafa? Mi?ecki<[email protected]> +Description: + ? ? ? ? ? ? ? AXI cores of the same type can still slightly differdepending
+ ? ? ? ? ? ? ? on their revision. Use it for detailed programming.Documentation/ABI/testing/sysfs-bus-axi new file +7
-0+ +What: ? ? ? ? ?/sys/bus/axi/devices/.../id +Date: ? ? ? ? ?April 2011 +KernelVersion: 2.6.40 +Contact: ? ? ? Rafa? Mi?ecki<[email protected]> +Description: + ? ? ? ? ? ? ? There are a few types of AXI cores, they can be identifiedby
+ ? ? ? ? ? ? ? id field.drivers/Kconfig +0
-0@@ -68,6 +68,8 @@ source "drivers/watchdog/Kconfig"?source "
drivers/ssb/Kconfig"drivers/Kconfig +2
-0+source "drivers/axi/Kconfig" +?source "
drivers/mfd/Kconfig"?source "
drivers/regulator/Kconfig"drivers/Makefile +0
-0@@ -110,6 +110,7 @@ obj-$(CONFIG_HID) ? ? ? ? ? += hid/?obj-$(CONFIG_PPC_PS3) ? ? ? ? += ps3/
?obj-$(CONFIG_OF) ? ? ? ? ? ? ?+= of/
?obj-$(CONFIG_SSB) ? ? ? ? ? ? += ssb/
+obj-$(CONFIG_AXI) ? ? ? ? ? ? ?+= axi/
?obj-$(CONFIG_VHOST_NET) ? ? ? ? ? ? ? += vhost/
?obj-$(CONFIG_VLYNQ) ? ? ? ? ? += vlynq/
?obj-$(CONFIG_STAGING) ? ? ? ? += staging/drivers/axi/Kconfig new file +13
-0@@ -0,0 +1,33 @@ +config AXI_POSSIBLE + ? ? ? bool + ? ? ? depends on HAS_IOMEM&& ?HAS_DMA + ? ? ? default y + +menu "AMBA AXI" + ? ? ? depends on AXI_POSSIBLE + +config AXI + ? ? ? tristate "AXI support" + ? ? ? depends on AXI_POSSIBLE + ? ? ? help + ? ? ? ? Bus driver for one of the Advanced Microcontroller BusArchitecture
+ ? ? ? ? interfaces: Advanced eXtensible Interface.drivers/axi/Kconfig new file +19
-0+ +config AXI_HOST_PCI_POSSIBLE + ? ? ? bool + ? ? ? depends on AXI&& ?PCI = y + ? ? ? default y + +config AXI_HOST_PCI + ? ? ? bool "Support for AXI on PCI-host bus" + ? ? ? depends on AXI_HOST_PCI_POSSIBLE + +config AXI_DEBUG + ? ? ? bool "AXI debugging" + ? ? ? depends on AXI + ? ? ? help + ? ? ? ? This turns on additional debugging messages. + + ? ? ? ? If unsure, say N + +endmenudrivers/axi/Makefile new file +2
-0@@ -0,0 +1,7 @@ +axi-y ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?+= main.o scan.o core.o +axi-y ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?+= driver_chipcommon.odriver_chipcommon_pmu.o
drivers/axi/Makefile new file +5
-0+axi-y ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?+= driver_pci.o +axi-$(CONFIG_AXI_HOST_PCI) ? ? ? ? ? ? += host_pci.o axi_pci_bridge.o +obj-$(CONFIG_AXI) ? ? ? ? ? ? ? ? ? ? ?+= axi.o + +ccflags-$(CONFIG_AXI_DEBUG) ? ? ? ? ? ?:= -DDEBUGdrivers/axi/TODO new file +3
-0@@ -0,0 +1,3 @@ +- Interrupts +- Defines for PCI core driver +- Convert axi_bus->cores into linked listdrivers/axi/axi_pci_bridge.c new file +33
-0@@ -0,0 +1,33 @@ +/* +* AXI PCI bridge module +* +* Licensed under the GNU/GPL. See COPYING for details. +*/ + +#include "axi_private.h" + +#include <linux/axi/axi.h> +#include <linux/pci.h> + +static DEFINE_PCI_DEVICE_TABLE (axi_pci_bridge_tbl) = { + ? ? ? { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4331) }, + ? ? ? { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4353) }, + ? ? ? { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4727) }, + ? ? ? { 0, }, +}; +MODULE_DEVICE_TABLE (pci, axi_pci_bridge_tbl); + +static struct pci_driver axi_pci_bridge_driver = { + ? ? ? .name = "axi-pci-bridge", + ? ? ? .id_table = axi_pci_bridge_tbl, +}; + +int __init axi_pci_bridge_init (void ) +{ + ? ? ? return axi_host_pci_register(&axi_pci_bridge_driver); +} + +void __exit axi_pci_bridge_exit(void) +{ + ? ? ? axi_host_pci_unregister(&axi_pci_bridge_driver); +}drivers/axi/axi_private.h new file +37
-0@@ -0,0 +1,37 @@ +#ifndef LINUX_AXI_PRIVATE_H_ +#define LINUX_AXI_PRIVATE_H_ + +#ifndef pr_fmt +#define pr_fmt (fmt) ? ? ? ? ? ?KBUILD_MODNAME ": " fmt +#endif + +#include <linux/axi/axi.h> + +#define AXI_ADDR_BASE ? ? ? ? ?0x18000000 +#define AXI_WRAP_BASE ? ? ? ? ?0x18100000 + +#define AXI_CORE_SIZE ? ? ? ? ?0x1000 + +struct axi_bus ; + +/* main.c */ +extern int axi_bus_register (struct axi_bus *bus); +extern void axi_bus_unregister (struct axi_bus *bus); + +/* scan.c */ +int axi_bus_scan (struct axi_bus *bus); + +#ifdef CONFIG_AXI_HOST_PCI +/* b43_pci_ai_bridge.c */ +extern int __init axi_pci_bridge_init (void ); +extern void __exit axi_pci_bridge_exit(void); + +/* host_pci.c */ +extern int axi_host_pci_register (struct pci_driver *driver); +static inline void axi_host_pci_unregister (struct pci_driver *driver) +{ + ? ? ? pci_unregister_driver(driver); +} +#endif /* CONFIG_AXI_HOST_PCI */ + +#endif drivers/axi/core.c new file +0
-0drivers/axi/core.c line 9
Quoted 9 lines
drivers/axi/core.c new file +9
-0@@ -0,0 +1,51 @@ +/* +* AMBA AXI +* Core ops +* +* Licensed under the GNU/GPL. See COPYING for details. +*/ + +#include "axi_private.h" +#include <linux/axi/axi.h> #include <
linux/delay.h>Quoted 289 lines
drivers/axi/core.c new file +4
-0+ +bool axi_core_is_enabled (struct axi_device *core) +{ + ? ? ? if ((axi_aread32(core, AXI_IOCTL)& ?(AXI_IOCTL_CLK |
AXI_IOCTL_FGC))
+ ? ? ? ? ? !=AXI_IOCTL_CLK)
+ ? ? ? ? ? ? ? return false;
+ ? ? ? if (axi_aread32(core, AXI_RESET_CTL)& ?AXI_RESET_CTL_RESET)
+ ? ? ? ? ? ? ? return false;
+ ? ? ? return true;drivers/axi/core.c new file +21
-0+} +EXPORT_SYMBOL (axi_core_is_enabled); + +static void axi_core_disable (struct axi_device *core,u32 flags) +{ + ? ? ? if (axi_aread32(core, AXI_RESET_CTL)& ?AXI_RESET_CTL_RESET) + ? ? ? ? ? ? ? return; + + ? ? ? axi_awrite32(core, AXI_IOCTL, flags); + ? ? ? axi_aread32(core, AXI_IOCTL); + ? ? ? udelay(10); + + ? ? ? axi_awrite32(core, AXI_RESET_CTL, AXI_RESET_CTL_RESET); + ? ? ? udelay(1); +} + +int axi_core_enable (struct axi_device *core,u32 flags) +{ + ? ? ? axi_core_disable(core, flags); + + ? ? ? axi_awrite32(core, AXI_IOCTL, (AXI_IOCTL_CLK | AXI_IOCTL_FGC |flags));
+ ? ? ?axi_aread32(core, AXI_IOCTL);drivers/axi/core.c new file +11
-0+ + ? ? ? axi_awrite32(core, AXI_RESET_CTL, 0); + ? ? ? udelay(1); + + ? ? ? axi_awrite32(core, AXI_IOCTL, (AXI_IOCTL_CLK | flags)); + ? ? ? axi_aread32(core, AXI_IOCTL); + ? ? ? udelay(1); + + ? ? ? return 0; +} +EXPORT_SYMBOL (axi_core_enable);drivers/axi/driver_chipcommon.c new file +14
-0@@ -0,0 +1,87 @@ +/* +* AMBA AXI +* ChipCommon core driver +* +* Copyright 2005, Broadcom Corporation +* Copyright 2006, 2007, Michael Buesch<[email protected]> +* +* Licensed under the GNU/GPL. See COPYING for details. +*/ + +#include "axi_private.h" +#include <linux/axi/axi.h> + +static inline u32 axi_cc_write32_masked(struct axi_drv_cc *cc, u16offset,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? u32 mask, u32 value)drivers/axi/driver_chipcommon.c new file +72
-0+{ + ? ? ? value&= mask; + ? ? ? value |= axi_cc_read32(cc, offset)& ?~mask; + ? ? ? axi_cc_write32(cc, offset, value); + + ? ? ? return value; +} + +void axi_core_chipcommon_init (struct axi_drv_cc *cc) +{ + ? ? ? if (cc->core->id.rev>= 11) + ? ? ? ? ? ? ? cc->status = axi_cc_read32(cc, AXI_CC_CHIPSTAT); + ? ? ? cc->capabilities = axi_cc_read32(cc, AXI_CC_CAP); + ? ? ? if (cc->core->id.rev>= 35) + ? ? ? ? ? ? ? cc->capabilities_ext = axi_cc_read32(cc, AXI_CC_CAP_EXT); + + ? ? ? axi_cc_write32(cc, 0x58, 0); + ? ? ? axi_cc_write32(cc, 0x5C, 0); + + ? ? ? if (cc->capabilities& ?AXI_CC_CAP_PMU) + ? ? ? ? ? ? ? axi_pmu_init(cc); + ? ? ? if (cc->capabilities& ?AXI_CC_CAP_PCTL) + ? ? ? ? ? ? ? pr_err("Power control not implemented!\n"); +} + +/* Set chip watchdog reset timer to fire in 'ticks' backplane cycles */ +void axi_chipco_watchdog_timer_set (struct axi_drv_cc *cc,u32 ticks) +{ + ? ? ? /* instant NMI */ + ? ? ? axi_cc_write32(cc, AXI_CC_WATCHDOG, ticks); +} + +void axi_chipco_irq_mask (struct axi_drv_cc *cc,u32 mask,u32 value) +{ + ? ? ? axi_cc_write32_masked(cc, AXI_CC_IRQMASK, mask, value); +} + +u32 axi_chipco_irq_status (struct axi_drv_cc *cc,u32 mask) +{ + ? ? ? return axi_cc_read32(cc, AXI_CC_IRQSTAT)& ?mask; +} + +u32 axi_chipco_gpio_in (struct axi_drv_cc *cc,u32 mask) +{ + ? ? ? return axi_cc_read32(cc, AXI_CC_GPIOIN)& ?mask; +} + +u32 axi_chipco_gpio_out (struct axi_drv_cc *cc,u32 mask,u32 value) +{ + ? ? ? return axi_cc_write32_masked(cc, AXI_CC_GPIOOUT, mask, value); +} + +u32 axi_chipco_gpio_outen (struct axi_drv_cc *cc,u32 mask,u32 value) +{ + ? ? ? return axi_cc_write32_masked(cc, AXI_CC_GPIOOUTEN, mask, value); +} + +u32 xaxi_chipco_gpio_control (struct axi_drv_cc *cc,u32 mask,u32 value) +{ + ? ? ? return axi_cc_write32_masked(cc, AXI_CC_GPIOCTL, mask, value); +} +EXPORT_SYMBOL (xaxi_chipco_gpio_control); + +u32 axi_chipco_gpio_intmask (struct axi_drv_cc *cc,u32 mask,u32 value) +{ + ? ? ? return axi_cc_write32_masked(cc, AXI_CC_GPIOIRQ, mask, value); +} + +u32 axi_chipco_gpio_polarity (struct axi_drv_cc *cc,u32 mask,u32 value) +{ + ? ? ? return axi_cc_write32_masked(cc, AXI_CC_GPIOPOL, mask, value); +}drivers/axi/driver_chipcommon_pmu.c new file +128
-0@@ -0,0 +1,134 @@ +/* +* AMBA AXI +* ChipCommon Power Management Unit driver +* +* Copyright 2009, Michael Buesch<[email protected]> +* Copyright 2007, Broadcom Corporation +* +* Licensed under the GNU/GPL. See COPYING for details. +*/ + +#include "axi_private.h" +#include <linux/axi/axi.h> + +static void axi_chipco_chipctl_maskset (struct axi_drv_cc *cc, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?u32 offset, u32 mask, u32 set) +{ + ? ? ? u32 value; + + ? ? ? axi_cc_read32(cc, AXI_CC_CHIPCTL_ADDR); + ? ? ? axi_cc_write32(cc, AXI_CC_CHIPCTL_ADDR, offset); + ? ? ? axi_cc_read32(cc, AXI_CC_CHIPCTL_ADDR); + ? ? ? value = axi_cc_read32(cc, AXI_CC_CHIPCTL_DATA); + ? ? ? value&= mask; + ? ? ? value |= set; + ? ? ? axi_cc_write32(cc, AXI_CC_CHIPCTL_DATA, value); + ? ? ? axi_cc_read32(cc, AXI_CC_CHIPCTL_DATA); +} + +static void axi_pmu_pll_init (struct axi_drv_cc *cc) +{ + ? ? ? struct axi_bus *bus = cc->core->bus; + + ? ? ? switch (bus->chipinfo.id) { + ? ? ? case 0x4313: + ? ? ? case 0x4331: + ? ? ? case 43224: + ? ? ? case 43225: + ? ? ? ? ? ? ? break; + ? ? ? default: + ? ? ? ? ? ? ? pr_err("PLL init unknown for device 0x%04X\n", + ? ? ? ? ? ? ? ? ? ? ? bus->chipinfo.id); + ? ? ? } +} + +static void axi_pmu_resources_init (struct axi_drv_cc *cc) +{ + ? ? ? struct axi_bus *bus = cc->core->bus; + ? ? ? u32 min_msk = 0, max_msk = 0; + + ? ? ? switch (bus->chipinfo.id) { + ? ? ? case 0x4313: + ? ? ? ? ? ? ? min_msk = 0x200D; + ? ? ? ? ? ? ? max_msk = 0xFFFF; + ? ? ? ? ? ? ? break; + ? ? ? case 43224: + ? ? ? ? ? ? ? break; + ? ? ? default: + ? ? ? ? ? ? ? pr_err("PMU resource config unknown for device 0x%04X\n", + ? ? ? ? ? ? ? ? ? ? ? bus->chipinfo.id); + ? ? ? } + + ? ? ? /* Set the resource masks. */ + ? ? ? if (min_msk) + ? ? ? ? ? ? ? axi_cc_write32(cc, AXI_CC_PMU_MINRES_MSK, min_msk); + ? ? ? if (max_msk) + ? ? ? ? ? ? ? axi_cc_write32(cc, AXI_CC_PMU_MAXRES_MSK, max_msk); +} + +void axi_pmu_swreg_init (struct axi_drv_cc *cc) +{ + ? ? ? struct axi_bus *bus = cc->core->bus; + + ? ? ? switch (bus->chipinfo.id) { + ? ? ? case 0x4313: + ? ? ? case 0x4331: + ? ? ? case 43224: + ? ? ? ? ? ? ? break; + ? ? ? default: + ? ? ? ? ? ? ? pr_err("PMU switch/regulators init unknown for device " + ? ? ? ? ? ? ? ? ? ? ? "0x%04X\n", bus->chipinfo.id); + ? ? ? } +} + +void axi_pmu_workarounds (struct axi_drv_cc *cc) +{ + ? ? ? struct axi_bus *bus = cc->core->bus; + + ? ? ? switch (bus->chipinfo.id) { + ? ? ? case 0x4313: + ? ? ? ? ? ? ? axi_chipco_chipctl_maskset(cc, 0, ~0, 0x7); + ? ? ? ? ? ? ? break; + ? ? ? case 0x4331: + ? ? ? ? ? ? ? pr_err("Enabling Ext PA lines not implemented\n"); + ? ? ? ? ? ? ? break; + ? ? ? case 43224: + ? ? ? ? ? ? ? if (bus->chipinfo.rev == 0) { + ? ? ? ? ? ? ? ? ? ? ? pr_err("Workarounds for 43224 rev 0 not fully " + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? "implemented\n"); + ? ? ? ? ? ? ? ? ? ? ? axi_chipco_chipctl_maskset(cc, 0, ~0, 0xF0); + ? ? ? ? ? ? ? } else { + ? ? ? ? ? ? ? ? ? ? ? axi_chipco_chipctl_maskset(cc, 0, ~0, 0xF0); + ? ? ? ? ? ? ? } + ? ? ? ? ? ? ? break; + ? ? ? default: + ? ? ? ? ? ? ? pr_err("Workarounds unknown for device 0x%04X\n", + ? ? ? ? ? ? ? ? ? ? ? bus->chipinfo.id); + ? ? ? } +} + +void axi_pmu_init (struct axi_drv_cc *cc) +{ + ? ? ? u32 pmucap; + + ? ? ? pmucap = axi_cc_read32(cc, AXI_CC_PMU_CAP); + ? ? ? cc->pmu.rev = (pmucap& ?AXI_CC_PMU_CAP_REVISION); + + ? ? ? pr_debug("Found rev %u PMU (capabilities 0x%08X)\n", cc->pmu.rev, + ? ? ? ? ? ? ? ?pmucap); + + ? ? ? if (cc->pmu.rev == 1) + ? ? ? ? ? ? ? axi_cc_mask32(cc, AXI_CC_PMU_CTL, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ~AXI_CC_PMU_CTL_NOILPONW); + ? ? ? else + ? ? ? ? ? ? ? axi_cc_set32(cc, AXI_CC_PMU_CTL, + ? ? ? ? ? ? ? ? ? ? ? ? ? ?AXI_CC_PMU_CTL_NOILPONW); + + ? ? ? if (cc->core->id.id == 0x4329&& ?cc->core->id.rev == 2) + ? ? ? ? ? ? ? pr_err("Fix for 4329b0 bad LPOM state notimplemented!\n");
drivers/axi/driver_chipcommon_pmu.c new file +6
-0+ + ? ? ? axi_pmu_pll_init(cc); + ? ? ? axi_pmu_resources_init(cc); + ? ? ? axi_pmu_swreg_init(cc); + ? ? ? axi_pmu_workarounds(cc); +}drivers/axi/driver_pci.c new file +2
-0@@ -0,0 +1,163 @@ +/* +* AMBA AXI drivers/axi/driver_pci.c line 12
Quoted 10 lines
drivers/axi/driver_pci.c new file +10
-0+* PCI Core +* +* Copyright 2005, Broadcom Corporation +* Copyright 2006, 2007, Michael Buesch<[email protected]> +* +* Licensed under the GNU/GPL. See COPYING for details. +*/ + +#include "axi_private.h" +#include <linux/axi/axi.h> #include <
linux/delay.h>
Quoted 3 lines
Are you compiling for i386 architecture? For some reason,
delay.his not included for myx86_64system, and the include is needed forcore.canddriver_pci.c.
Yes, I use x86. Will include delay.h in next version, thanks for reporting.
Signature · 1 line
Rafa?
? ???, 13/04/2011 ? 21:39 +0200, Rafa? Mi?ecki ?????:
Quoted 107 lines
2011/4/13 Greg KH <[email protected]>:
Quoted 36 lines
Quoted 36 lines
drivers/axi/axi_pci_bridge.c new file +30
-0@@ -0,0 +1,33 @@ +/* +* AXI PCI bridge module +* +* Licensed under the GNU/GPL. See COPYING for details. +*/ + +#include "axi_private.h" + +#include <linux/axi/axi.h> +#include <linux/pci.h> + +static DEFINE_PCI_DEVICE_TABLE (axi_pci_bridge_tbl) = { + {PCI_DEVICE (PCI_VENDOR_ID_BROADCOM ,0x4331 ) }, + {PCI_DEVICE (PCI_VENDOR_ID_BROADCOM ,0x4353 ) }, + {PCI_DEVICE (PCI_VENDOR_ID_BROADCOM ,0x4727 ) }, + {0 , }, +}; +MODULE_DEVICE_TABLE (pci, axi_pci_bridge_tbl); + +static struct pci_driver axi_pci_bridge_driver = { + .name ="axi-pci-bridge" , + .id_table = axi_pci_bridge_tbl, +}; + +int __init axi_pci_bridge_init (void ) +{ +return axi_host_pci_register (&axi_pci_bridge_driver); +} + +void __exit axi_pci_bridge_exit(void)Quoted 8 lines
drivers/axi/axi_pci_bridge.c line 33
Quoted 3 lines
drivers/axi/axi_pci_bridge.c new file +3
-0+{ +axi_host_pci_unregister (&axi_pci_bridge_driver); +}You register a pci driver that does nothing? That's not right, you need to then base your axi bus off of that pci device, so it is hooked up correctly in the
/sys/devices/tree. Otherwise you are somewhere up in the virtual location for your axi bus, right?Please take a look at:
driver->probe=axi_host_pci_probe;driver->remove=axi_host_pci_remove;
returnpci_register_driver(driver);Quoted 13 lines
drivers/axi/axi_pci_bridge.c
Quoted 10 lines
drivers/axi/axi_pci_bridge.c new file +10
-0+bool axi_core_is_enabled (struct axi_device *core) +{ +if ((axi_aread32 (core,AXI_IOCTL ) & (AXI_IOCTL_CLK |AXI_IOCTL_FGC )) + !=AXI_IOCTL_CLK ) +return false; +if (axi_aread32 (core,AXI_RESET_CTL ) &AXI_RESET_CTL_RESET ) +return false; +return true; +} +EXPORT_SYMBOL (axi_core_is_enabled);
EXPORT_SYMBOL_GPL()?Quoted 7 lines
What module uses this? And why would it care?
Quoted 1 line
+EXPORT_SYMBOL(axi_core_enable);
EXPORT_SYMBOL_GPL()?Same goes for your other exports, just want you to be sure here.
Hm, I'm not sure. Using
EXPORT_SYMBOL_GPLwill forbid closed source drivers from using our bus driver, right? I'm don't have preferences on this, if you prefer us to force GPL, I can.Quoted 8 lines
drivers/axi/axi_pci_bridge.c
Quoted 5 lines
drivers/axi/axi_pci_bridge.c new file +5
-0+u32 xaxi_chipco_gpio_control (struct axi_drv_cc *cc,u32 mask,u32 value) +{ +return axi_cc_write32_masked (cc,AXI_CC_GPIOCTL , mask, value); +} +EXPORT_SYMBOL (xaxi_chipco_gpio_control);"xaxi"? Shouldn't that be consistant with the other exports and start with "axi"?
Left from old tests/rewrites/splitting. Thanks.
Quoted 8 lines
drivers/axi/axi_pci_bridge.c
Quoted 3 lines
drivers/axi/axi_pci_bridge.c new file +3
-0+static u8 axi_host_pci_read8 (struct axi_device *core,u16 offset) +{ +if (unlikely (core->bus->mapped_core != core))Are you sure about the use of unlikely in this, and other functions? The compiler almost always does a better job than we do for these types of calls, just let it do it's job.
Quoted 5 lines
drivers/axi/axi_pci_bridge.c
Quoted 2 lines
drivers/axi/axi_pci_bridge.c new file +2
-0+axi_host_pci_switch_core (core); +return ioread8 (core->bus->mmio + offset);I think because of that unlikely, you just slowed down all pci devices, right? That's not very nice :)
Hm, my logic suggests it is alright, but please consider this once more with me ;)
Quoted 7 lines
For the most of the time
mapped_core(active core) do not change. We perform few hundreds of operations on one core in a row. This waymapped_corepoints to passed core for most of the time. Condition (mapped_core!= core) is unlikely to happen.Is there anything wrong in my logic?
Yes, there is. You don't need that "if" at all.
Have nice day,
George
Quoted 69 lines · Rafa? Mi?ecki
2011/4/13 Greg KH <[email protected]>:
Quoted 36 lines
Quoted 36 lines
drivers/axi/axi_pci_bridge.c new file +30
-0@@ -0,0 +1,33 @@ +/* +* AXI PCI bridge module +* +* Licensed under the GNU/GPL. See COPYING for details. +*/ + +#include "axi_private.h" + +#include <linux/axi/axi.h> +#include <linux/pci.h> + +static DEFINE_PCI_DEVICE_TABLE (axi_pci_bridge_tbl) = { + ? ? { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4331) }, + ? ? { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4353) }, + ? ? { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4727) }, + ? ? { 0, }, +}; +MODULE_DEVICE_TABLE (pci, axi_pci_bridge_tbl); + +static struct pci_driver axi_pci_bridge_driver = { + ? ? .name = "axi-pci-bridge", + ? ? .id_table = axi_pci_bridge_tbl, +}; + +int __init axi_pci_bridge_init (void ) +{ + ? ? return axi_host_pci_register(&axi_pci_bridge_driver); +} + +void __exit axi_pci_bridge_exit(void)Quoted 8 lines
drivers/axi/axi_pci_bridge.c line 28
Quoted 3 lines
drivers/axi/axi_pci_bridge.c new file +3
-0+{ + ? ? axi_host_pci_unregister(&axi_pci_bridge_driver); +}You register a pci driver that does nothing? ?That's not right, you need to then base your axi bus off of that pci device, so it is hooked up correctly in the
/sys/devices/tree. ?Otherwise you are somewhere up in the virtual location for your axi bus, right?Please take a look at:
driver->probe=axi_host_pci_probe;driver->remove=axi_host_pci_remove;
returnpci_register_driver(driver);Quoted 17 lines
drivers/axi/axi_pci_bridge.c
Quoted 10 lines
drivers/axi/axi_pci_bridge.c new file +10
-0+bool axi_core_is_enabled (struct axi_device *core) +{ + ? ? if ((axi_aread32(core, AXI_IOCTL) & (AXI_IOCTL_CLK | AXI_IOCTL_FGC)) + ? ? ? ? != AXI_IOCTL_CLK) + ? ? ? ? ? ? return false; + ? ? if (axi_aread32(core, AXI_RESET_CTL) & AXI_RESET_CTL_RESET) + ? ? ? ? ? ? return false; + ? ? return true; +} +EXPORT_SYMBOL (axi_core_is_enabled);
EXPORT_SYMBOL_GPL()?What module uses this? ?And why would it care?
Quoted 1 line
+EXPORT_SYMBOL(axi_core_enable);
Quoted 7 lines
Quoted 3 lines
EXPORT_SYMBOL_GPL()?Same goes for your other exports, just want you to be sure here.
Hm, I'm not sure. Using
EXPORT_SYMBOL_GPLwill forbid closed source drivers from using our bus driver, right? I'm don't have preferences on this, if you prefer us to force GPL, I can.
Isn't EXPORT_SYMBOL_GPL for symbols that are considered to form a tight coupling between the kernel and users of the symbol? Using _GPL just because you are against proprietary drivers in general and want to force GPL on HW vendors is wrong.
Quoted 45 lines
Quoted 10 lines
drivers/axi/axi_pci_bridge.c
Quoted 7 lines
drivers/axi/axi_pci_bridge.c new file +5
-0+u32 xaxi_chipco_gpio_control (struct axi_drv_cc *cc,u32 mask,u32 value) +{ + ? ? return axi_cc_write32_masked(cc, AXI_CC_GPIOCTL, mask, value); +} +EXPORT_SYMBOL (xaxi_chipco_gpio_control);"xaxi"? ?Shouldn't that be consistant with the other exports and start with "axi"?
Left from old tests/rewrites/splitting. Thanks.
Quoted 8 lines
drivers/axi/axi_pci_bridge.c
Quoted 3 lines
drivers/axi/axi_pci_bridge.c new file +3
-0+static u8 axi_host_pci_read8 (struct axi_device *core,u16 offset) +{ + ? ? if (unlikely(core->bus->mapped_core != core))Are you sure about the use of unlikely in this, and other functions? The compiler almost always does a better job than we do for these types of calls, just let it do it's job.
Quoted 5 lines
Quoted 2 lines
+ ? ? ? ? ? ?
axi_host_pci_switch_core(core);
+ ? ? returnioread8(core->bus->mmio + offset);I think because of that unlikely, you just slowed down all pci devices, right? ?That's not very nice :)
Hm, my logic suggests it is alright, but please consider this once more with me ;)
For the most of the time
mapped_core(active core) do not change. We perform few hundreds of operations on one core in a row. This waymapped_corepoints to passed core for most of the time. Condition (mapped_core!= core) is unlikely to happen.Is there anything wrong in my logic?
--
Rafa?
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo at vger.kernel.org
More majordomo info at ?http://vger.kernel.org/majordomo-info.html
Signature · 1 line
Vista: [V]iruses, [I]ntruders, [S]pyware, [T]rojans and [A]dware. :-)
2011/4/13 George Kashperko <[email protected]>:
Quoted 109 lines
? ???, 13/04/2011 ? 21:39 +0200, Rafa? Mi?ecki ?????:
Quoted 107 lines
2011/4/13 Greg KH <[email protected]>:
Quoted 36 lines
Quoted 36 lines
drivers/axi/axi_pci_bridge.c new file +30
-0@@ -0,0 +1,33 @@ +/* +* AXI PCI bridge module +* +* Licensed under the GNU/GPL. See COPYING for details. +*/ + +#include "axi_private.h" + +#include <linux/axi/axi.h> +#include <linux/pci.h> + +static DEFINE_PCI_DEVICE_TABLE (axi_pci_bridge_tbl) = { + ? ? { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4331) }, + ? ? { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4353) }, + ? ? { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4727) }, + ? ? { 0, }, +}; +MODULE_DEVICE_TABLE (pci, axi_pci_bridge_tbl); + +static struct pci_driver axi_pci_bridge_driver = { + ? ? .name = "axi-pci-bridge", + ? ? .id_table = axi_pci_bridge_tbl, +}; + +int __init axi_pci_bridge_init (void ) +{ + ? ? return axi_host_pci_register(&axi_pci_bridge_driver); +} + +void __exit axi_pci_bridge_exit(void)Quoted 8 lines
drivers/axi/axi_pci_bridge.c line 28
Quoted 3 lines
drivers/axi/axi_pci_bridge.c new file +3
-0+{ + ? ? axi_host_pci_unregister(&axi_pci_bridge_driver); +}You register a pci driver that does nothing? ?That's not right, you need to then base your axi bus off of that pci device, so it is hooked up correctly in the
/sys/devices/tree. ?Otherwise you are somewhere up in the virtual location for your axi bus, right?Please take a look at:
driver->probe=axi_host_pci_probe;driver->remove=axi_host_pci_remove;
returnpci_register_driver(driver);Quoted 13 lines
drivers/axi/axi_pci_bridge.c
Quoted 10 lines
drivers/axi/axi_pci_bridge.c new file +10
-0+bool axi_core_is_enabled (struct axi_device *core) +{ + ? ? if ((axi_aread32(core, AXI_IOCTL) & (AXI_IOCTL_CLK | AXI_IOCTL_FGC)) + ? ? ? ? != AXI_IOCTL_CLK) + ? ? ? ? ? ? return false; + ? ? if (axi_aread32(core, AXI_RESET_CTL) & AXI_RESET_CTL_RESET) + ? ? ? ? ? ? return false; + ? ? return true; +} +EXPORT_SYMBOL (axi_core_is_enabled);
EXPORT_SYMBOL_GPL()?Quoted 7 lines
What module uses this? ?And why would it care?
Quoted 1 line
+EXPORT_SYMBOL(axi_core_enable);
EXPORT_SYMBOL_GPL()?Same goes for your other exports, just want you to be sure here.
Hm, I'm not sure. Using
EXPORT_SYMBOL_GPLwill forbid closed source drivers from using our bus driver, right? I'm don't have preferences on this, if you prefer us to force GPL, I can.Quoted 8 lines
drivers/axi/axi_pci_bridge.c
Quoted 5 lines
drivers/axi/axi_pci_bridge.c new file +5
-0+u32 xaxi_chipco_gpio_control (struct axi_drv_cc *cc,u32 mask,u32 value) +{ + ? ? return axi_cc_write32_masked(cc, AXI_CC_GPIOCTL, mask, value); +} +EXPORT_SYMBOL (xaxi_chipco_gpio_control);"xaxi"? ?Shouldn't that be consistant with the other exports and start with "axi"?
Left from old tests/rewrites/splitting. Thanks.
Quoted 8 lines
drivers/axi/axi_pci_bridge.c
Quoted 3 lines
drivers/axi/axi_pci_bridge.c new file +3
-0+static u8 axi_host_pci_read8 (struct axi_device *core,u16 offset) +{ + ? ? if (unlikely(core->bus->mapped_core != core))Are you sure about the use of unlikely in this, and other functions? The compiler almost always does a better job than we do for these types of calls, just let it do it's job.
Quoted 5 lines
Quoted 2 lines
+ ? ? ? ? ? ?
axi_host_pci_switch_core(core);
+ ? ? returnioread8(core->bus->mmio + offset);I think because of that unlikely, you just slowed down all pci devices, right? ?That's not very nice :)
Hm, my logic suggests it is alright, but please consider this once more with me ;)
Quoted 8 lines
Quoted 7 lines
For the most of the time
mapped_core(active core) do not change. We perform few hundreds of operations on one core in a row. This waymapped_corepoints to passed core for most of the time. Condition (mapped_core!= core) is unlikely to happen.Is there anything wrong in my logic?
Yes, there is. You don't need that "if" at all.
Damn, WHY do you make me ask why, why, why, all the time?! Can't you just write word of explanation without being asked for?
Signature · 1 line
Rafa?
Quoted 116 lines
2011/4/13 George Kashperko <[email protected]>:
Quoted 114 lines
? ???, 13/04/2011 ? 21:39 +0200, Rafa? Mi?ecki ?????:
Quoted 112 lines
2011/4/13 Greg KH <[email protected]>:
Quoted 36 lines
Quoted 36 lines
drivers/axi/axi_pci_bridge.c new file +30
-0@@ -0,0 +1,33 @@ +/* +* AXI PCI bridge module +* +* Licensed under the GNU/GPL. See COPYING for details. +*/ + +#include "axi_private.h" + +#include <linux/axi/axi.h> +#include <linux/pci.h> + +static DEFINE_PCI_DEVICE_TABLE (axi_pci_bridge_tbl) = { + {PCI_DEVICE (PCI_VENDOR_ID_BROADCOM ,0x4331 ) }, + {PCI_DEVICE (PCI_VENDOR_ID_BROADCOM ,0x4353 ) }, + {PCI_DEVICE (PCI_VENDOR_ID_BROADCOM ,0x4727 ) }, + {0 , }, +}; +MODULE_DEVICE_TABLE (pci, axi_pci_bridge_tbl); + +static struct pci_driver axi_pci_bridge_driver = { + .name ="axi-pci-bridge" , + .id_table = axi_pci_bridge_tbl, +}; + +int __init axi_pci_bridge_init (void ) +{ +return axi_host_pci_register (&axi_pci_bridge_driver); +} + +void __exit axi_pci_bridge_exit(void)Quoted 8 lines
drivers/axi/axi_pci_bridge.c line 33
Quoted 3 lines
drivers/axi/axi_pci_bridge.c new file +3
-0+{ +axi_host_pci_unregister (&axi_pci_bridge_driver); +}You register a pci driver that does nothing? That's not right, you need to then base your axi bus off of that pci device, so it is hooked up correctly in the
/sys/devices/tree. Otherwise you are somewhere up in the virtual location for your axi bus, right?Please take a look at:
driver->probe=axi_host_pci_probe;driver->remove=axi_host_pci_remove;
returnpci_register_driver(driver);Quoted 13 lines
drivers/axi/axi_pci_bridge.c
Quoted 10 lines
drivers/axi/axi_pci_bridge.c new file +10
-0+bool axi_core_is_enabled (struct axi_device *core) +{ +if ((axi_aread32 (core,AXI_IOCTL ) & (AXI_IOCTL_CLK |AXI_IOCTL_FGC )) + !=AXI_IOCTL_CLK ) +return false; +if (axi_aread32 (core,AXI_RESET_CTL ) &AXI_RESET_CTL_RESET ) +return false; +return true; +} +EXPORT_SYMBOL (axi_core_is_enabled);
EXPORT_SYMBOL_GPL()?Quoted 7 lines
What module uses this? And why would it care?
Quoted 1 line
+EXPORT_SYMBOL(axi_core_enable);
EXPORT_SYMBOL_GPL()?Same goes for your other exports, just want you to be sure here.
Hm, I'm not sure. Using
EXPORT_SYMBOL_GPLwill forbid closed source drivers from using our bus driver, right? I'm don't have preferences on this, if you prefer us to force GPL, I can.Quoted 8 lines
drivers/axi/axi_pci_bridge.c
Quoted 5 lines
drivers/axi/axi_pci_bridge.c new file +5
-0+u32 xaxi_chipco_gpio_control (struct axi_drv_cc *cc,u32 mask,u32 value) +{ +return axi_cc_write32_masked (cc,AXI_CC_GPIOCTL , mask, value); +} +EXPORT_SYMBOL (xaxi_chipco_gpio_control);"xaxi"? Shouldn't that be consistant with the other exports and start with "axi"?
Left from old tests/rewrites/splitting. Thanks.
Quoted 8 lines
drivers/axi/axi_pci_bridge.c
Quoted 3 lines
drivers/axi/axi_pci_bridge.c new file +3
-0+static u8 axi_host_pci_read8 (struct axi_device *core,u16 offset) +{ +if (unlikely (core->bus->mapped_core != core))Are you sure about the use of unlikely in this, and other functions? The compiler almost always does a better job than we do for these types of calls, just let it do it's job.
Quoted 5 lines
drivers/axi/axi_pci_bridge.c
Quoted 2 lines
drivers/axi/axi_pci_bridge.c new file +2
-0+axi_host_pci_switch_core (core); +return ioread8 (core->bus->mmio + offset);I think because of that unlikely, you just slowed down all pci devices, right? That's not very nice :)
Hm, my logic suggests it is alright, but please consider this once more with me ;)
For the most of the time
mapped_core(active core) do not change. We perform few hundreds of operations on one core in a row. This waymapped_corepoints to passed core for most of the time. Condition (mapped_core!= core) is unlikely to happen.
Quoted 7 lines
Quoted 3 lines
Quoted 2 lines
Is there anything wrong in my logic?
Yes, there is. You don't need that "if" at all.
Damn, WHY do you make me ask why, why, why, all the time?! Can't you just write word of explanation without being asked for?
Errm... Sorry, but I've already explained PCIE host behaviour _several_ times several days ago. Personally I like to ask questions. Have absolutely nothing agains anyone else asking good questions. Never try to make people ask me questions I know they would ask anyway. Really you might missed some my messages earlier or maybe my english is too awful ?
Yet again, for PCIE cores (not only for them, for some PCI cores as well) buscommon, buscore and function core are all available simultaneously. You dont need window sliding when access them.
Have nice day,
George
2011/4/13 George Kashperko <[email protected]>:
Quoted 129 lines
Quoted 116 lines
2011/4/13 George Kashperko <[email protected]>:
Quoted 114 lines
? ???, 13/04/2011 ? 21:39 +0200, Rafa? Mi?ecki ?????:
Quoted 112 lines
2011/4/13 Greg KH <[email protected]>:
Quoted 36 lines
Quoted 36 lines
drivers/axi/axi_pci_bridge.c new file +30
-0@@ -0,0 +1,33 @@ +/* +* AXI PCI bridge module +* +* Licensed under the GNU/GPL. See COPYING for details. +*/ + +#include "axi_private.h" + +#include <linux/axi/axi.h> +#include <linux/pci.h> + +static DEFINE_PCI_DEVICE_TABLE (axi_pci_bridge_tbl) = { + ? ? { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4331) }, + ? ? { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4353) }, + ? ? { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4727) }, + ? ? { 0, }, +}; +MODULE_DEVICE_TABLE (pci, axi_pci_bridge_tbl); + +static struct pci_driver axi_pci_bridge_driver = { + ? ? .name = "axi-pci-bridge", + ? ? .id_table = axi_pci_bridge_tbl, +}; + +int __init axi_pci_bridge_init (void ) +{ + ? ? return axi_host_pci_register(&axi_pci_bridge_driver); +} + +void __exit axi_pci_bridge_exit(void)Quoted 8 lines
drivers/axi/axi_pci_bridge.c line 28
Quoted 3 lines
drivers/axi/axi_pci_bridge.c new file +3
-0+{ + ? ? axi_host_pci_unregister(&axi_pci_bridge_driver); +}You register a pci driver that does nothing? ?That's not right, you need to then base your axi bus off of that pci device, so it is hooked up correctly in the
/sys/devices/tree. ?Otherwise you are somewhere up in the virtual location for your axi bus, right?Please take a look at:
driver->probe=axi_host_pci_probe;driver->remove=axi_host_pci_remove;
returnpci_register_driver(driver);Quoted 13 lines
drivers/axi/axi_pci_bridge.c
Quoted 10 lines
drivers/axi/axi_pci_bridge.c new file +10
-0+bool axi_core_is_enabled (struct axi_device *core) +{ + ? ? if ((axi_aread32(core, AXI_IOCTL) & (AXI_IOCTL_CLK | AXI_IOCTL_FGC)) + ? ? ? ? != AXI_IOCTL_CLK) + ? ? ? ? ? ? return false; + ? ? if (axi_aread32(core, AXI_RESET_CTL) & AXI_RESET_CTL_RESET) + ? ? ? ? ? ? return false; + ? ? return true; +} +EXPORT_SYMBOL (axi_core_is_enabled);
EXPORT_SYMBOL_GPL()?Quoted 7 lines
What module uses this? ?And why would it care?
Quoted 1 line
+EXPORT_SYMBOL(axi_core_enable);
EXPORT_SYMBOL_GPL()?Same goes for your other exports, just want you to be sure here.
Hm, I'm not sure. Using
EXPORT_SYMBOL_GPLwill forbid closed source drivers from using our bus driver, right? I'm don't have preferences on this, if you prefer us to force GPL, I can.Quoted 8 lines
drivers/axi/axi_pci_bridge.c
Quoted 5 lines
drivers/axi/axi_pci_bridge.c new file +5
-0+u32 xaxi_chipco_gpio_control (struct axi_drv_cc *cc,u32 mask,u32 value) +{ + ? ? return axi_cc_write32_masked(cc, AXI_CC_GPIOCTL, mask, value); +} +EXPORT_SYMBOL (xaxi_chipco_gpio_control);"xaxi"? ?Shouldn't that be consistant with the other exports and start with "axi"?
Left from old tests/rewrites/splitting. Thanks.
Quoted 8 lines
drivers/axi/axi_pci_bridge.c
Quoted 3 lines
drivers/axi/axi_pci_bridge.c new file +3
-0+static u8 axi_host_pci_read8 (struct axi_device *core,u16 offset) +{ + ? ? if (unlikely(core->bus->mapped_core != core))Are you sure about the use of unlikely in this, and other functions? The compiler almost always does a better job than we do for these types of calls, just let it do it's job.
Quoted 5 lines
Quoted 2 lines
+ ? ? ? ? ? ?
axi_host_pci_switch_core(core);
+ ? ? returnioread8(core->bus->mmio + offset);I think because of that unlikely, you just slowed down all pci devices, right? ?That's not very nice :)
Hm, my logic suggests it is alright, but please consider this once more with me ;)
For the most of the time
mapped_core(active core) do not change. We perform few hundreds of operations on one core in a row. This waymapped_corepoints to passed core for most of the time. Condition (mapped_core!= core) is unlikely to happen.Quoted 7 lines
Quoted 3 lines
Quoted 2 lines
Is there anything wrong in my logic?
Yes, there is. You don't need that "if" at all.
Damn, WHY do you make me ask why, why, why, all the time?! Can't you just write word of explanation without being asked for?
Errm... Sorry, but I've already explained PCIE host behaviour _several_ times several days ago. Personally I like to ask questions. Have absolutely nothing agains anyone else asking good questions. Never try to make people ask me questions I know they would ask anyway. Really you might missed some my messages earlier or maybe my english is too awful ?
Quoted 3 lines
Yet again, for PCIE cores (not only for them, for some PCI cores as well) buscommon, buscore and function core are all available simultaneously. You dont need window sliding when access them.
I had no idea what you were referring to. We do not dig into PCIe functions yet, so I believe for now we need this "if".
I'm getting totally frustrated with that whole situation :|
Signature · 1 line
Rafa?
Quoted 9 lines · G?bor Stefanik
Quoted 3 lines · Rafa? Mi?ecki
Hm, I'm not sure. Using
EXPORT_SYMBOL_GPLwill forbid closed source drivers from using our bus driver, right? I'm don't have preferences on this, if you prefer us to force GPL, I can.Isn't
EXPORT_SYMBOL_GPLfor symbols that are considered to form a tight coupling between the kernel and users of the symbol? Using_GPLjust because you are against proprietary drivers in general and want to force GPL on HW vendors is wrong.
It shows _intent_. Not to say that functions that are not exported in this manner do not also require only GPL kernel code to be used as well at all.
See the archives for more details if you are curious about it, it's been covered numerous times in the past.
thanks,
greg k-h
Quoted 46 lines · Rafa? Mi?ecki
2011/4/13 Greg KH <[email protected]>:
Quoted 36 lines
Quoted 36 lines
drivers/axi/axi_pci_bridge.c new file +30
-0@@ -0,0 +1,33 @@ +/* +* AXI PCI bridge module +* +* Licensed under the GNU/GPL. See COPYING for details. +*/ + +#include "axi_private.h" + +#include <linux/axi/axi.h> +#include <linux/pci.h> + +static DEFINE_PCI_DEVICE_TABLE (axi_pci_bridge_tbl) = { + ? ? { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4331) }, + ? ? { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4353) }, + ? ? { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4727) }, + ? ? { 0, }, +}; +MODULE_DEVICE_TABLE (pci, axi_pci_bridge_tbl); + +static struct pci_driver axi_pci_bridge_driver = { + ? ? .name = "axi-pci-bridge", + ? ? .id_table = axi_pci_bridge_tbl, +}; + +int __init axi_pci_bridge_init (void ) +{ + ? ? return axi_host_pci_register(&axi_pci_bridge_driver); +} + +void __exit axi_pci_bridge_exit(void)Quoted 8 lines
drivers/axi/axi_pci_bridge.c line 28
Quoted 3 lines
drivers/axi/axi_pci_bridge.c new file +3
-0+{ + ? ? axi_host_pci_unregister(&axi_pci_bridge_driver); +}You register a pci driver that does nothing? ?That's not right, you need to then base your axi bus off of that pci device, so it is hooked up correctly in the
/sys/devices/tree. ?Otherwise you are somewhere up in the virtual location for your axi bus, right?
Quoted 4 lines
Please take a look at:
driver->probe=axi_host_pci_probe;driver->remove=axi_host_pci_remove;
returnpci_register_driver(driver);
Odd, why not just set up those functions in that file? Or move all of this to that file and do it there? This seems like a very small file :)
Quoted 17 lines
Quoted 17 lines
drivers/axi/axi_pci_bridge.c
Quoted 10 lines
drivers/axi/axi_pci_bridge.c new file +10
-0+bool axi_core_is_enabled (struct axi_device *core) +{ + ? ? if ((axi_aread32(core, AXI_IOCTL) & (AXI_IOCTL_CLK | AXI_IOCTL_FGC)) + ? ? ? ? != AXI_IOCTL_CLK) + ? ? ? ? ? ? return false; + ? ? if (axi_aread32(core, AXI_RESET_CTL) & AXI_RESET_CTL_RESET) + ? ? ? ? ? ? return false; + ? ? return true; +} +EXPORT_SYMBOL (axi_core_is_enabled);
EXPORT_SYMBOL_GPL()?What module uses this? ?And why would it care?
Quoted 1 line
+EXPORT_SYMBOL(axi_core_enable);
Quoted 7 lines
Quoted 3 lines
EXPORT_SYMBOL_GPL()?Same goes for your other exports, just want you to be sure here.
Hm, I'm not sure. Using
EXPORT_SYMBOL_GPLwill forbid closed source drivers from using our bus driver, right? I'm don't have preferences on this, if you prefer us to force GPL, I can.
It's totally up to you, it's your code, not mine. Just wanted to remind you of the option.
Quoted 29 lines
Quoted 8 lines
drivers/axi/axi_pci_bridge.c
Quoted 5 lines
drivers/axi/axi_pci_bridge.c new file +5
-0+u32 xaxi_chipco_gpio_control (struct axi_drv_cc *cc,u32 mask,u32 value) +{ + ? ? return axi_cc_write32_masked(cc, AXI_CC_GPIOCTL, mask, value); +} +EXPORT_SYMBOL (xaxi_chipco_gpio_control);"xaxi"? ?Shouldn't that be consistant with the other exports and start with "axi"?
Left from old tests/rewrites/splitting. Thanks.
Quoted 8 lines
drivers/axi/axi_pci_bridge.c
Quoted 3 lines
drivers/axi/axi_pci_bridge.c new file +3
-0+static u8 axi_host_pci_read8 (struct axi_device *core,u16 offset) +{ + ? ? if (unlikely(core->bus->mapped_core != core))Are you sure about the use of unlikely in this, and other functions? The compiler almost always does a better job than we do for these types of calls, just let it do it's job.
Quoted 5 lines
Quoted 2 lines
+ ? ? ? ? ? ?
axi_host_pci_switch_core(core);
+ ? ? returnioread8(core->bus->mmio + offset);I think because of that unlikely, you just slowed down all pci devices, right? ?That's not very nice :)
Hm, my logic suggests it is alright, but please consider this once more with me ;)
Quoted 6 lines
For the most of the time
mapped_core(active core) do not change. We perform few hundreds of operations on one core in a row. This waymapped_corepoints to passed core for most of the time. Condition (mapped_core!= core) is unlikely to happen.Is there anything wrong in my logic?
Drivers almost _never_ need to use likely or unlikely in their code. The CPU can schedule things better and so can the compiler, so I would just drop them, _unless_ you can show a benchmark where it matters.
thanks,
greg k-h
Quoted 131 lines
2011/4/13 George Kashperko <[email protected]>:
Quoted 129 lines
Quoted 116 lines
2011/4/13 George Kashperko <[email protected]>:
Quoted 114 lines
? ???, 13/04/2011 ? 21:39 +0200, Rafa? Mi?ecki ?????:
Quoted 112 lines
2011/4/13 Greg KH <[email protected]>:
Quoted 36 lines
Quoted 36 lines
drivers/axi/axi_pci_bridge.c new file +30
-0@@ -0,0 +1,33 @@ +/* +* AXI PCI bridge module +* +* Licensed under the GNU/GPL. See COPYING for details. +*/ + +#include "axi_private.h" + +#include <linux/axi/axi.h> +#include <linux/pci.h> + +static DEFINE_PCI_DEVICE_TABLE (axi_pci_bridge_tbl) = { + {PCI_DEVICE (PCI_VENDOR_ID_BROADCOM ,0x4331 ) }, + {PCI_DEVICE (PCI_VENDOR_ID_BROADCOM ,0x4353 ) }, + {PCI_DEVICE (PCI_VENDOR_ID_BROADCOM ,0x4727 ) }, + {0 , }, +}; +MODULE_DEVICE_TABLE (pci, axi_pci_bridge_tbl); + +static struct pci_driver axi_pci_bridge_driver = { + .name ="axi-pci-bridge" , + .id_table = axi_pci_bridge_tbl, +}; + +int __init axi_pci_bridge_init (void ) +{ +return axi_host_pci_register (&axi_pci_bridge_driver); +} + +void __exit axi_pci_bridge_exit(void)Quoted 8 lines
drivers/axi/axi_pci_bridge.c line 33
Quoted 3 lines
drivers/axi/axi_pci_bridge.c new file +3
-0+{ +axi_host_pci_unregister (&axi_pci_bridge_driver); +}You register a pci driver that does nothing? That's not right, you need to then base your axi bus off of that pci device, so it is hooked up correctly in the
/sys/devices/tree. Otherwise you are somewhere up in the virtual location for your axi bus, right?Please take a look at:
driver->probe=axi_host_pci_probe;driver->remove=axi_host_pci_remove;
returnpci_register_driver(driver);Quoted 13 lines
drivers/axi/axi_pci_bridge.c
Quoted 10 lines
drivers/axi/axi_pci_bridge.c new file +10
-0+bool axi_core_is_enabled (struct axi_device *core) +{ +if ((axi_aread32 (core,AXI_IOCTL ) & (AXI_IOCTL_CLK |AXI_IOCTL_FGC )) + !=AXI_IOCTL_CLK ) +return false; +if (axi_aread32 (core,AXI_RESET_CTL ) &AXI_RESET_CTL_RESET ) +return false; +return true; +} +EXPORT_SYMBOL (axi_core_is_enabled);
EXPORT_SYMBOL_GPL()?Quoted 7 lines
What module uses this? And why would it care?
Quoted 1 line
+EXPORT_SYMBOL(axi_core_enable);
EXPORT_SYMBOL_GPL()?Same goes for your other exports, just want you to be sure here.
Hm, I'm not sure. Using
EXPORT_SYMBOL_GPLwill forbid closed source drivers from using our bus driver, right? I'm don't have preferences on this, if you prefer us to force GPL, I can.Quoted 8 lines
drivers/axi/axi_pci_bridge.c
Quoted 5 lines
drivers/axi/axi_pci_bridge.c new file +5
-0+u32 xaxi_chipco_gpio_control (struct axi_drv_cc *cc,u32 mask,u32 value) +{ +return axi_cc_write32_masked (cc,AXI_CC_GPIOCTL , mask, value); +} +EXPORT_SYMBOL (xaxi_chipco_gpio_control);"xaxi"? Shouldn't that be consistant with the other exports and start with "axi"?
Left from old tests/rewrites/splitting. Thanks.
Quoted 8 lines
drivers/axi/axi_pci_bridge.c
Quoted 3 lines
drivers/axi/axi_pci_bridge.c new file +3
-0+static u8 axi_host_pci_read8 (struct axi_device *core,u16 offset) +{ +if (unlikely (core->bus->mapped_core != core))Are you sure about the use of unlikely in this, and other functions? The compiler almost always does a better job than we do for these types of calls, just let it do it's job.
Quoted 5 lines
drivers/axi/axi_pci_bridge.c
Quoted 2 lines
drivers/axi/axi_pci_bridge.c new file +2
-0+axi_host_pci_switch_core (core); +return ioread8 (core->bus->mmio + offset);I think because of that unlikely, you just slowed down all pci devices, right? That's not very nice :)
Hm, my logic suggests it is alright, but please consider this once more with me ;)
For the most of the time
mapped_core(active core) do not change. We perform few hundreds of operations on one core in a row. This waymapped_corepoints to passed core for most of the time. Condition (mapped_core!= core) is unlikely to happen.Quoted 7 lines
Quoted 3 lines
Quoted 2 lines
Is there anything wrong in my logic?
Yes, there is. You don't need that "if" at all.
Damn, WHY do you make me ask why, why, why, all the time?! Can't you just write word of explanation without being asked for?
Errm... Sorry, but I've already explained PCIE host behaviour _several_ times several days ago. Personally I like to ask questions. Have absolutely nothing agains anyone else asking good questions. Never try to make people ask me questions I know they would ask anyway. Really you might missed some my messages earlier or maybe my english is too awful ?
Quoted 6 lines
Quoted 3 lines
Yet again, for PCIE cores (not only for them, for some PCI cores as well) buscommon, buscore and function core are all available simultaneously. You dont need window sliding when access them.
I had no idea what you were referring to. We do not dig into PCIe functions yet, so I believe for now we need this "if".
You are already deep inside. Your host code drives pci function.
Quoted 3 lines
I'm getting totally frustrated with that whole situation :|
Have nice day,
George
2011/4/13 George Kashperko <[email protected]>:
Quoted 3 lines
Quoted 2 lines
I had no idea what you were referring to. We do not dig into PCIe functions yet, so I believe for now we need this "if".
You are already deep inside. Your host code drives pci function.
But I don't use multiple PCIe functions, do not focus on that at all.
Signature · 1 line
Rafa?
Quoted 8 lines
2011/4/13 George Kashperko <[email protected]>:
Quoted 3 lines
Quoted 2 lines
I had no idea what you were referring to. We do not dig into PCIe functions yet, so I believe for now we need this "if".
You are already deep inside. Your host code drives pci function.
But I don't use multiple PCIe functions, do not focus on that at all.
Don't see anything in the host driver code preventing it to be bound to functions other than 0. But anyways if you sure your host will be used by several cores then why don't you spinlock window accesses ?
Have nice day,
George
2011/4/13 George Kashperko <[email protected]>:
Quoted 10 lines
Quoted 7 lines
2011/4/13 George Kashperko <[email protected]>:
Quoted 3 lines
Quoted 2 lines
I had no idea what you were referring to. We do not dig into PCIe functions yet, so I believe for now we need this "if".
You are already deep inside. Your host code drives pci function.
But I don't use multiple PCIe functions, do not focus on that at all.
Don't see anything in the host driver code preventing it to be bound to functions other than 0. But anyways if you sure your host will be used by several cores then why don't you spinlock window accesses ?
I should, it was discussed, please let's leave it for now.
Lets first focus on how to correctly implement this driver.
Signature · 1 line
Rafa?
Quoted 6 lines · Rafa? Mi?ecki
2011/4/13 George Kashperko <[email protected]>:
Quoted 3 lines
Quoted 2 lines
I had no idea what you were referring to. We do not dig into PCIe functions yet, so I believe for now we need this "if".
You are already deep inside. Your host code drives pci function.
But I don't use multiple PCIe functions, do not focus on that at all.
I think what George meant is the following (please correct me if I understood you wrong) and has nothing to do with PCIe functions:
<http://lxr.free-electrons.com/source/drivers/staging/brcm80211/util/aiutils.c#L522>
The chipcommon and PCIe core registers seem to be always available on PCIe and no core switching is necessary for them. So as long as you only access the core registers of chipcommon, PCIe + one other core, you never need to do any switching (except for the initial switch to the other core)
But If you need to access the agent registers you do have to do adapt the PCIe windows.
(This seems to apply also to PCI cards with a PCI core revision >= 13, but this is probably only relevant for SSB - unless Arend says there are/were also PCI cards with AMBA AXI backplanes ;-).
Jonas
2011/4/14 Jonas Gorski <[email protected]>:
Quoted 11 lines · Rafa? Mi?ecki
Quoted 6 lines
2011/4/13 George Kashperko <[email protected]>:
Quoted 3 lines
Quoted 2 lines
I had no idea what you were referring to. We do not dig into PCIe functions yet, so I believe for now we need this "if".
You are already deep inside. Your host code drives pci function.
But I don't use multiple PCIe functions, do not focus on that at all.
I think what George meant is the following (please correct me if I understood you wrong) and has nothing to do with PCIe functions:
<http://lxr.free-electrons.com/source/drivers/staging/brcm80211/util/aiutils.c#L522>
Ahh, thanks, I though PCIe functions are something different, that we have to register for pci device differently to access them or sth.
Signature · 1 line
Rafa?