Changes in 4.9.283 ext4: fix race writing to an inline_data file while its xattrs are changing mtd: nand: atmel_nand: remove build warning in atmel_nand_remove() xtensa: fix kconfig unmet dependency warning for HAVE_FUTEX_CMPXCHG qed: Fix the VF msix vectors flow qede: Fix memset corruption perf/x86/amd/ibs: Work around erratum #1197 cryptoloop: add a deprecation warning ARM: 8918/2: only build return_address() if needed ALSA: pcm: fix divide error in snd_pcm_lib_ioctl ath: Use safer key clearing with key cache entries ath9k: Clear key cache explicitly on disabling hardware ath: Export ath_hw_keysetmac() ath: Modify ath_key_delete() to not need full key entry ath9k: Postpone key cache entry deletion for TXQ frames reference it media: stkwebcam: fix memory leak in stk_camera_probe igmp: Add ip_mc_list lock in ip_check_mc_rcu usb: phy: isp1301: Fix build warning when CONFIG_OF is disabled USB: serial: mos7720: improve OOM-handling in read_mos_reg() net/sched: cls_flower: Use mask for addr_type PM / wakeirq: Enable dedicated wakeirq for suspend tc358743: fix register i2c_rd/wr function fix nvme-pci: Fix an error handling path in 'nvme_probe()' gfs2: Don't clear SGID when inheriting ACLs ipv4/icmp: l3mdev: Perform icmp error route lookup on source device routing table (v2) s390/disassembler: correct disassembly lines alignment mm/kmemleak.c: make cond_resched() rate-limiting more efficient crypto: talitos - reduce max key size for SEC1 powerpc/module64: Fix comment in R_PPC64_ENTRY handling powerpc/boot: Delete unneeded .globl _zimage_start net: ll_temac: Remove left-over debug message mm/page_alloc: speed up the iteration of max_order Revert "btrfs: compression: don't try to compress if we don't have enough pages" x86/reboot: Limit Dell Optiplex 990 quirk to early BIOS versions PCI: Call Max Payload Size-related fixup quirks early regmap: fix the offset of register error log crypto: mxs-dcp - Check for DMA mapping errors power: supply: axp288_fuel_gauge: Report register-address on readb / writeb errors crypto: omap-sham - clear dma flags only after omap_sham_update_dma_stop() udf: Check LVID earlier power: supply: max17042_battery: fix typo in MAx17042_TOFF libata: fix ata_host_start() crypto: qat - do not ignore errors from enable_vf2pf_comms() crypto: qat - handle both source of interrupt in VF ISR crypto: qat - fix reuse of completion variable crypto: qat - fix naming for init/shutdown VF to PF notifications crypto: qat - do not export adf_iov_putmsg() udf_get_extendedattr() had no boundary checks. m68k: emu: Fix invalid free in nfeth_cleanup() spi: spi-pic32: Fix issue with uninitialized dma_slave_config crypto: qat - use proper type for vf_mask certs: Trigger creation of RSA module signing key if it's not an RSA key media: dvb-usb: fix uninit-value in dvb_usb_adapter_dvb_init media: dvb-usb: fix uninit-value in vp702x_read_mac_addr media: go7007: remove redundant initialization Bluetooth: sco: prevent information leak in sco_conn_defer_accept() tcp: seq_file: Avoid skipping sk during tcp_seek_last_pos net: cipso: fix warnings in netlbl_cipsov4_add_std i2c: highlander: add IRQ check PCI: PM: Enable PME if it can be signaled from D3cold soc: qcom: smsm: Fix missed interrupts if state changes while masked Bluetooth: increase BTNAMSIZ to 21 chars to fix potential buffer overflow arm64: dts: exynos: correct GIC CPU interfaces address range on Exynos7 Bluetooth: fix repeated calls to sco_sock_kill drm/msm/dsi: Fix some reference counted resource leaks usb: gadget: udc: at91: add IRQ check usb: phy: fsl-usb: add IRQ check usb: phy: twl6030: add IRQ checks Bluetooth: Move shutdown callback before flushing tx and rx queue usb: host: ohci-tmio: add IRQ check usb: phy: tahvo: add IRQ check usb: gadget: mv_u3d: request_irq() after initializing UDC Bluetooth: add timeout sanity check to hci_inquiry i2c: iop3xx: fix deferred probing i2c: s3c2410: fix IRQ check mmc: dw_mmc: Fix issue with uninitialized dma_slave_config mmc: moxart: Fix issue with uninitialized dma_slave_config CIFS: Fix a potencially linear read overflow i2c: mt65xx: fix IRQ check usb: ehci-orion: Handle errors of clk_prepare_enable() in probe ath6kl: wmi: fix an error code in ath6kl_wmi_sync_point() bcma: Fix memory leak for internally-handled cores ipv4: make exception cache less predictible tty: Fix data race between tiocsti() and flush_to_ldisc() KVM: x86: Update vCPU's hv_clock before back to guest when tsc_offset is adjusted IMA: remove -Wmissing-prototypes warning clk: kirkwood: Fix a clocking boot regression fbmem: don't allow too huge resolutions rtc: tps65910: Correct driver module alias PCI/MSI: Skip masking MSI-X on Xen PV powerpc/perf/hv-gpci: Fix counter value parsing xen: fix setting of max_pfn in shared_info crypto: public_key: fix overflow during implicit conversion power: supply: max17042: handle fails of reading status register VMCI: fix NULL pointer dereference when unmapping queue pair media: uvc: don't do DMA on stack media: rc-loopback: return number of emitters rather than error libata: add ATA_HORKAGE_NO_NCQ_TRIM for Samsung 860 and 870 SSDs ARM: 9105/1: atags_to_fdt: don't warn about stack size PCI: Restrict ASMedia ASM1062 SATA Max Payload Size Supported PCI: Return ~0 data on pciconfig_read() CAP_SYS_ADMIN failure vfio: Use config not menuconfig for VFIO_NOIOMMU openrisc: don't printk() unconditionally pinctrl: single: Fix error return code in pcs_parse_bits_in_pinctrl_entry() MIPS: Malta: fix alignment of the devicetree buffer crypto: mxs-dcp - Use sg_mapping_iter to copy data PCI: Use pci_update_current_state() in pci_enable_device_flags() iio: dac: ad5624r: Fix incorrect handling of an optional regulator. video: fbdev: kyro: fix a DoS bug by restricting user input netlink: Deal with ESRCH error in nlmsg_notify() Smack: Fix wrong semantics in smk_access_entry() usb: host: fotg210: fix the endpoint's transactional opportunities calculation usb: host: fotg210: fix the actual_length of an iso packet usb: gadget: u_ether: fix a potential null pointer dereference usb: gadget: composite: Allow bMaxPower=0 if self-powered staging: board: Fix uninitialized spinlock when attaching genpd tty: serial: jsm: hold port lock when reporting modem line changes bpf/tests: Fix copy-and-paste error in double word test bpf/tests: Do not PASS tests without actually testing the result video: fbdev: asiliantfb: Error out if 'pixclock' equals zero video: fbdev: kyro: Error out if 'pixclock' equals zero video: fbdev: riva: Error out if 'pixclock' equals zero ipv4: ip_output.c: Fix out-of-bounds warning in ip_copy_addrs() flow_dissector: Fix out-of-bounds warnings s390/jump_label: print real address in a case of a jump label bug serial: 8250: Define RX trigger levels for OxSemi 950 devices xtensa: ISS: don't panic in rs_init hvsi: don't panic on tty_register_driver failure serial: 8250_pci: make setup_port() parameters explicitly unsigned staging: ks7010: Fix the initialization of the 'sleep_status' structure ata: sata_dwc_460ex: No need to call phy_exit() befre phy_init() Bluetooth: skip invalid hci_sync_conn_complete_evt ASoC: Intel: bytcr_rt5640: Move "Platform Clock" routes to the maps for the matching in-/output net: ethernet: stmmac: Do not use unreachable() in ipq806x_gmac_probe() Bluetooth: avoid circular locks in sco_sock_connect gpu: drm: amd: amdgpu: amdgpu_i2c: fix possible uninitialized-variable access in amdgpu_i2c_router_select_ddc_port() ARM: tegra: tamonten: Fix UART pad setting rpc: fix gss_svc_init cleanup on failure gfs2: Don't call dlm after protocol is unmounted mmc: rtsx_pci: Fix long reads when clock is prescaled cifs: fix wrong release in sess_alloc_buffer() failed path Revert "USB: xhci: fix U1/U2 handling for hardware with XHCI_INTEL_HOST quirk set" usbip: give back URBs for unsent unlink requests during cleanup parport: remove non-zero check on count ath9k: fix OOB read ar9300_eeprom_restore_internal ath9k: fix sleeping in atomic context net: fix NULL pointer reference in cipso_v4_doi_free net: w5100: check return value after calling platform_get_resource() parisc: fix crash with signals and alloca scsi: BusLogic: Fix missing pr_cont() use mm/hugetlb: initialize hugetlb_usage in mm_init memcg: enable accounting for pids in nested pid namespaces platform/chrome: cros_ec_proto: Send command again when timeout occurs xen: reset legacy rtc flag for PV domU bnx2x: Fix enabling network interfaces without VFs net-caif: avoid user-triggerable WARN_ON(1) ptp: dp83640: don't define PAGE0 dccp: don't duplicate ccid when cloning dccp sock net/l2tp: Fix reference count leak in l2tp_udp_recv_core r6040: Restore MDIO clock frequency after MAC reset tipc: increase timeout in tipc_sk_enqueue() events: Reuse value read using READ_ONCE instead of re-reading it net/af_unix: fix a data-race in unix_dgram_poll tcp: fix tp->undo_retrans accounting in tcp_sacktag_one() x86/mm: Fix kern_addr_valid() to cope with existing but not present entries dt-bindings: mtd: gpmc: Fix the ECC bytes vs. OOB bytes equation mfd: Don't use irq_create_mapping() to resolve a mapping net: usb: cdc_mbim: avoid altsetting toggling for Telit LN920 ethtool: Fix an error code in cxgb2.c PCI: Sync __pci_register_driver() stub for CONFIG_PCI=n mtd: rawnand: cafe: Fix a resource leak in the error handling path of 'cafe_nand_probe()' ARC: export clear_user_page() for modules net: dsa: b53: Fix calculating number of switch ports qlcnic: Remove redundant unlock in qlcnic_pinit_from_rom net: renesas: sh_eth: Fix freeing wrong tx descriptor s390/bpf: Fix 64-bit subtraction of the -0x80000000 constant Linux 4.9.283 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Change-Id: I9e2017cce36805d71566ea1f265974a43bae33d1
727 lines
17 KiB
C
727 lines
17 KiB
C
/*
|
|
* Broadcom specific AMBA
|
|
* Bus subsystem
|
|
*
|
|
* Licensed under the GNU/GPL. See COPYING for details.
|
|
*/
|
|
|
|
#include "bcma_private.h"
|
|
#include <linux/module.h>
|
|
#include <linux/mmc/sdio_func.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/pci.h>
|
|
#include <linux/bcma/bcma.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/of_address.h>
|
|
#include <linux/of_irq.h>
|
|
#include <linux/of_platform.h>
|
|
|
|
MODULE_DESCRIPTION("Broadcom's specific AMBA driver");
|
|
MODULE_LICENSE("GPL");
|
|
|
|
/* contains the number the next bus should get. */
|
|
static unsigned int bcma_bus_next_num = 0;
|
|
|
|
/* bcma_buses_mutex locks the bcma_bus_next_num */
|
|
static DEFINE_MUTEX(bcma_buses_mutex);
|
|
|
|
static int bcma_bus_match(struct device *dev, struct device_driver *drv);
|
|
static int bcma_device_probe(struct device *dev);
|
|
static int bcma_device_remove(struct device *dev);
|
|
static int bcma_device_uevent(struct device *dev, struct kobj_uevent_env *env);
|
|
|
|
static ssize_t manuf_show(struct device *dev, struct device_attribute *attr, char *buf)
|
|
{
|
|
struct bcma_device *core = container_of(dev, struct bcma_device, dev);
|
|
return sprintf(buf, "0x%03X\n", core->id.manuf);
|
|
}
|
|
static DEVICE_ATTR_RO(manuf);
|
|
|
|
static ssize_t id_show(struct device *dev, struct device_attribute *attr, char *buf)
|
|
{
|
|
struct bcma_device *core = container_of(dev, struct bcma_device, dev);
|
|
return sprintf(buf, "0x%03X\n", core->id.id);
|
|
}
|
|
static DEVICE_ATTR_RO(id);
|
|
|
|
static ssize_t rev_show(struct device *dev, struct device_attribute *attr, char *buf)
|
|
{
|
|
struct bcma_device *core = container_of(dev, struct bcma_device, dev);
|
|
return sprintf(buf, "0x%02X\n", core->id.rev);
|
|
}
|
|
static DEVICE_ATTR_RO(rev);
|
|
|
|
static ssize_t class_show(struct device *dev, struct device_attribute *attr, char *buf)
|
|
{
|
|
struct bcma_device *core = container_of(dev, struct bcma_device, dev);
|
|
return sprintf(buf, "0x%X\n", core->id.class);
|
|
}
|
|
static DEVICE_ATTR_RO(class);
|
|
|
|
static struct attribute *bcma_device_attrs[] = {
|
|
&dev_attr_manuf.attr,
|
|
&dev_attr_id.attr,
|
|
&dev_attr_rev.attr,
|
|
&dev_attr_class.attr,
|
|
NULL,
|
|
};
|
|
ATTRIBUTE_GROUPS(bcma_device);
|
|
|
|
static struct bus_type bcma_bus_type = {
|
|
.name = "bcma",
|
|
.match = bcma_bus_match,
|
|
.probe = bcma_device_probe,
|
|
.remove = bcma_device_remove,
|
|
.uevent = bcma_device_uevent,
|
|
.dev_groups = bcma_device_groups,
|
|
};
|
|
|
|
static u16 bcma_cc_core_id(struct bcma_bus *bus)
|
|
{
|
|
if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4706)
|
|
return BCMA_CORE_4706_CHIPCOMMON;
|
|
return BCMA_CORE_CHIPCOMMON;
|
|
}
|
|
|
|
struct bcma_device *bcma_find_core_unit(struct bcma_bus *bus, u16 coreid,
|
|
u8 unit)
|
|
{
|
|
struct bcma_device *core;
|
|
|
|
list_for_each_entry(core, &bus->cores, list) {
|
|
if (core->id.id == coreid && core->core_unit == unit)
|
|
return core;
|
|
}
|
|
return NULL;
|
|
}
|
|
EXPORT_SYMBOL_GPL(bcma_find_core_unit);
|
|
|
|
bool bcma_wait_value(struct bcma_device *core, u16 reg, u32 mask, u32 value,
|
|
int timeout)
|
|
{
|
|
unsigned long deadline = jiffies + timeout;
|
|
u32 val;
|
|
|
|
do {
|
|
val = bcma_read32(core, reg);
|
|
if ((val & mask) == value)
|
|
return true;
|
|
cpu_relax();
|
|
udelay(10);
|
|
} while (!time_after_eq(jiffies, deadline));
|
|
|
|
bcma_warn(core->bus, "Timeout waiting for register 0x%04X!\n", reg);
|
|
|
|
return false;
|
|
}
|
|
|
|
static void bcma_release_core_dev(struct device *dev)
|
|
{
|
|
struct bcma_device *core = container_of(dev, struct bcma_device, dev);
|
|
if (core->io_addr)
|
|
iounmap(core->io_addr);
|
|
if (core->io_wrap)
|
|
iounmap(core->io_wrap);
|
|
kfree(core);
|
|
}
|
|
|
|
static bool bcma_is_core_needed_early(u16 core_id)
|
|
{
|
|
switch (core_id) {
|
|
case BCMA_CORE_NS_NAND:
|
|
case BCMA_CORE_NS_QSPI:
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
static struct device_node *bcma_of_find_child_device(struct platform_device *parent,
|
|
struct bcma_device *core)
|
|
{
|
|
struct device_node *node;
|
|
u64 size;
|
|
const __be32 *reg;
|
|
|
|
if (!parent || !parent->dev.of_node)
|
|
return NULL;
|
|
|
|
for_each_child_of_node(parent->dev.of_node, node) {
|
|
reg = of_get_address(node, 0, &size, NULL);
|
|
if (!reg)
|
|
continue;
|
|
if (of_translate_address(node, reg) == core->addr)
|
|
return node;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
static int bcma_of_irq_parse(struct platform_device *parent,
|
|
struct bcma_device *core,
|
|
struct of_phandle_args *out_irq, int num)
|
|
{
|
|
__be32 laddr[1];
|
|
int rc;
|
|
|
|
if (core->dev.of_node) {
|
|
rc = of_irq_parse_one(core->dev.of_node, num, out_irq);
|
|
if (!rc)
|
|
return rc;
|
|
}
|
|
|
|
out_irq->np = parent->dev.of_node;
|
|
out_irq->args_count = 1;
|
|
out_irq->args[0] = num;
|
|
|
|
laddr[0] = cpu_to_be32(core->addr);
|
|
return of_irq_parse_raw(laddr, out_irq);
|
|
}
|
|
|
|
static unsigned int bcma_of_get_irq(struct platform_device *parent,
|
|
struct bcma_device *core, int num)
|
|
{
|
|
struct of_phandle_args out_irq;
|
|
int ret;
|
|
|
|
if (!IS_ENABLED(CONFIG_OF_IRQ) || !parent || !parent->dev.of_node)
|
|
return 0;
|
|
|
|
ret = bcma_of_irq_parse(parent, core, &out_irq, num);
|
|
if (ret) {
|
|
bcma_debug(core->bus, "bcma_of_get_irq() failed with rc=%d\n",
|
|
ret);
|
|
return 0;
|
|
}
|
|
|
|
return irq_create_of_mapping(&out_irq);
|
|
}
|
|
|
|
static void bcma_of_fill_device(struct platform_device *parent,
|
|
struct bcma_device *core)
|
|
{
|
|
struct device_node *node;
|
|
|
|
if (!IS_ENABLED(CONFIG_OF_IRQ))
|
|
return;
|
|
|
|
node = bcma_of_find_child_device(parent, core);
|
|
if (node)
|
|
core->dev.of_node = node;
|
|
|
|
core->irq = bcma_of_get_irq(parent, core, 0);
|
|
|
|
of_dma_configure(&core->dev, node);
|
|
}
|
|
|
|
unsigned int bcma_core_irq(struct bcma_device *core, int num)
|
|
{
|
|
struct bcma_bus *bus = core->bus;
|
|
unsigned int mips_irq;
|
|
|
|
switch (bus->hosttype) {
|
|
case BCMA_HOSTTYPE_PCI:
|
|
return bus->host_pci->irq;
|
|
case BCMA_HOSTTYPE_SOC:
|
|
if (bus->drv_mips.core && num == 0) {
|
|
mips_irq = bcma_core_mips_irq(core);
|
|
return mips_irq <= 4 ? mips_irq + 2 : 0;
|
|
}
|
|
if (bus->host_pdev)
|
|
return bcma_of_get_irq(bus->host_pdev, core, num);
|
|
return 0;
|
|
case BCMA_HOSTTYPE_SDIO:
|
|
return 0;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL(bcma_core_irq);
|
|
|
|
void bcma_prepare_core(struct bcma_bus *bus, struct bcma_device *core)
|
|
{
|
|
device_initialize(&core->dev);
|
|
core->dev.release = bcma_release_core_dev;
|
|
core->dev.bus = &bcma_bus_type;
|
|
dev_set_name(&core->dev, "bcma%d:%d", bus->num, core->core_index);
|
|
|
|
switch (bus->hosttype) {
|
|
case BCMA_HOSTTYPE_PCI:
|
|
core->dev.parent = &bus->host_pci->dev;
|
|
core->dma_dev = &bus->host_pci->dev;
|
|
core->irq = bus->host_pci->irq;
|
|
break;
|
|
case BCMA_HOSTTYPE_SOC:
|
|
if (IS_ENABLED(CONFIG_OF) && bus->host_pdev) {
|
|
core->dma_dev = &bus->host_pdev->dev;
|
|
core->dev.parent = &bus->host_pdev->dev;
|
|
bcma_of_fill_device(bus->host_pdev, core);
|
|
} else {
|
|
core->dev.dma_mask = &core->dev.coherent_dma_mask;
|
|
core->dma_dev = &core->dev;
|
|
}
|
|
break;
|
|
case BCMA_HOSTTYPE_SDIO:
|
|
break;
|
|
}
|
|
}
|
|
|
|
struct device *bcma_bus_get_host_dev(struct bcma_bus *bus)
|
|
{
|
|
switch (bus->hosttype) {
|
|
case BCMA_HOSTTYPE_PCI:
|
|
if (bus->host_pci)
|
|
return &bus->host_pci->dev;
|
|
else
|
|
return NULL;
|
|
case BCMA_HOSTTYPE_SOC:
|
|
if (bus->host_pdev)
|
|
return &bus->host_pdev->dev;
|
|
else
|
|
return NULL;
|
|
case BCMA_HOSTTYPE_SDIO:
|
|
if (bus->host_sdio)
|
|
return &bus->host_sdio->dev;
|
|
else
|
|
return NULL;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
void bcma_init_bus(struct bcma_bus *bus)
|
|
{
|
|
mutex_lock(&bcma_buses_mutex);
|
|
bus->num = bcma_bus_next_num++;
|
|
mutex_unlock(&bcma_buses_mutex);
|
|
|
|
INIT_LIST_HEAD(&bus->cores);
|
|
bus->nr_cores = 0;
|
|
|
|
bcma_detect_chip(bus);
|
|
}
|
|
|
|
static void bcma_register_core(struct bcma_bus *bus, struct bcma_device *core)
|
|
{
|
|
int err;
|
|
|
|
err = device_add(&core->dev);
|
|
if (err) {
|
|
bcma_err(bus, "Could not register dev for core 0x%03X\n",
|
|
core->id.id);
|
|
return;
|
|
}
|
|
core->dev_registered = true;
|
|
}
|
|
|
|
static int bcma_register_devices(struct bcma_bus *bus)
|
|
{
|
|
struct bcma_device *core;
|
|
int err;
|
|
|
|
list_for_each_entry(core, &bus->cores, list) {
|
|
/* We support that cores ourself */
|
|
switch (core->id.id) {
|
|
case BCMA_CORE_4706_CHIPCOMMON:
|
|
case BCMA_CORE_CHIPCOMMON:
|
|
case BCMA_CORE_NS_CHIPCOMMON_B:
|
|
case BCMA_CORE_PCI:
|
|
case BCMA_CORE_PCIE:
|
|
case BCMA_CORE_PCIE2:
|
|
case BCMA_CORE_MIPS_74K:
|
|
case BCMA_CORE_4706_MAC_GBIT_COMMON:
|
|
continue;
|
|
}
|
|
|
|
/* Early cores were already registered */
|
|
if (bcma_is_core_needed_early(core->id.id))
|
|
continue;
|
|
|
|
/* Only first GMAC core on BCM4706 is connected and working */
|
|
if (core->id.id == BCMA_CORE_4706_MAC_GBIT &&
|
|
core->core_unit > 0)
|
|
continue;
|
|
|
|
bcma_register_core(bus, core);
|
|
}
|
|
|
|
#ifdef CONFIG_BCMA_PFLASH
|
|
if (bus->drv_cc.pflash.present) {
|
|
err = platform_device_register(&bcma_pflash_dev);
|
|
if (err)
|
|
bcma_err(bus, "Error registering parallel flash\n");
|
|
}
|
|
#endif
|
|
|
|
#ifdef CONFIG_BCMA_SFLASH
|
|
if (bus->drv_cc.sflash.present) {
|
|
err = platform_device_register(&bcma_sflash_dev);
|
|
if (err)
|
|
bcma_err(bus, "Error registering serial flash\n");
|
|
}
|
|
#endif
|
|
|
|
#ifdef CONFIG_BCMA_NFLASH
|
|
if (bus->drv_cc.nflash.present) {
|
|
err = platform_device_register(&bcma_nflash_dev);
|
|
if (err)
|
|
bcma_err(bus, "Error registering NAND flash\n");
|
|
}
|
|
#endif
|
|
err = bcma_gpio_init(&bus->drv_cc);
|
|
if (err == -ENOTSUPP)
|
|
bcma_debug(bus, "GPIO driver not activated\n");
|
|
else if (err)
|
|
bcma_err(bus, "Error registering GPIO driver: %i\n", err);
|
|
|
|
if (bus->hosttype == BCMA_HOSTTYPE_SOC) {
|
|
err = bcma_chipco_watchdog_register(&bus->drv_cc);
|
|
if (err)
|
|
bcma_err(bus, "Error registering watchdog driver\n");
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
void bcma_unregister_cores(struct bcma_bus *bus)
|
|
{
|
|
struct bcma_device *core, *tmp;
|
|
|
|
list_for_each_entry_safe(core, tmp, &bus->cores, list) {
|
|
if (!core->dev_registered)
|
|
continue;
|
|
list_del(&core->list);
|
|
device_unregister(&core->dev);
|
|
}
|
|
if (bus->hosttype == BCMA_HOSTTYPE_SOC)
|
|
platform_device_unregister(bus->drv_cc.watchdog);
|
|
|
|
/* Now noone uses internally-handled cores, we can free them */
|
|
list_for_each_entry_safe(core, tmp, &bus->cores, list) {
|
|
list_del(&core->list);
|
|
put_device(&core->dev);
|
|
}
|
|
}
|
|
|
|
int bcma_bus_register(struct bcma_bus *bus)
|
|
{
|
|
int err;
|
|
struct bcma_device *core;
|
|
struct device *dev;
|
|
|
|
/* Scan for devices (cores) */
|
|
err = bcma_bus_scan(bus);
|
|
if (err) {
|
|
bcma_err(bus, "Failed to scan: %d\n", err);
|
|
return err;
|
|
}
|
|
|
|
/* Early init CC core */
|
|
core = bcma_find_core(bus, bcma_cc_core_id(bus));
|
|
if (core) {
|
|
bus->drv_cc.core = core;
|
|
bcma_core_chipcommon_early_init(&bus->drv_cc);
|
|
}
|
|
|
|
/* Early init PCIE core */
|
|
core = bcma_find_core(bus, BCMA_CORE_PCIE);
|
|
if (core) {
|
|
bus->drv_pci[0].core = core;
|
|
bcma_core_pci_early_init(&bus->drv_pci[0]);
|
|
}
|
|
|
|
dev = bcma_bus_get_host_dev(bus);
|
|
if (dev) {
|
|
of_platform_default_populate(dev->of_node, NULL, dev);
|
|
}
|
|
|
|
/* Cores providing flash access go before SPROM init */
|
|
list_for_each_entry(core, &bus->cores, list) {
|
|
if (bcma_is_core_needed_early(core->id.id))
|
|
bcma_register_core(bus, core);
|
|
}
|
|
|
|
/* Try to get SPROM */
|
|
err = bcma_sprom_get(bus);
|
|
if (err == -ENOENT) {
|
|
bcma_err(bus, "No SPROM available\n");
|
|
} else if (err)
|
|
bcma_err(bus, "Failed to get SPROM: %d\n", err);
|
|
|
|
/* Init CC core */
|
|
core = bcma_find_core(bus, bcma_cc_core_id(bus));
|
|
if (core) {
|
|
bus->drv_cc.core = core;
|
|
bcma_core_chipcommon_init(&bus->drv_cc);
|
|
}
|
|
|
|
/* Init CC core */
|
|
core = bcma_find_core(bus, BCMA_CORE_NS_CHIPCOMMON_B);
|
|
if (core) {
|
|
bus->drv_cc_b.core = core;
|
|
bcma_core_chipcommon_b_init(&bus->drv_cc_b);
|
|
}
|
|
|
|
/* Init MIPS core */
|
|
core = bcma_find_core(bus, BCMA_CORE_MIPS_74K);
|
|
if (core) {
|
|
bus->drv_mips.core = core;
|
|
bcma_core_mips_init(&bus->drv_mips);
|
|
}
|
|
|
|
/* Init PCIE core */
|
|
core = bcma_find_core_unit(bus, BCMA_CORE_PCIE, 0);
|
|
if (core) {
|
|
bus->drv_pci[0].core = core;
|
|
bcma_core_pci_init(&bus->drv_pci[0]);
|
|
}
|
|
|
|
/* Init PCIE core */
|
|
core = bcma_find_core_unit(bus, BCMA_CORE_PCIE, 1);
|
|
if (core) {
|
|
bus->drv_pci[1].core = core;
|
|
bcma_core_pci_init(&bus->drv_pci[1]);
|
|
}
|
|
|
|
/* Init PCIe Gen 2 core */
|
|
core = bcma_find_core_unit(bus, BCMA_CORE_PCIE2, 0);
|
|
if (core) {
|
|
bus->drv_pcie2.core = core;
|
|
bcma_core_pcie2_init(&bus->drv_pcie2);
|
|
}
|
|
|
|
/* Init GBIT MAC COMMON core */
|
|
core = bcma_find_core(bus, BCMA_CORE_4706_MAC_GBIT_COMMON);
|
|
if (core) {
|
|
bus->drv_gmac_cmn.core = core;
|
|
bcma_core_gmac_cmn_init(&bus->drv_gmac_cmn);
|
|
}
|
|
|
|
/* Register found cores */
|
|
bcma_register_devices(bus);
|
|
|
|
bcma_info(bus, "Bus registered\n");
|
|
|
|
return 0;
|
|
}
|
|
|
|
void bcma_bus_unregister(struct bcma_bus *bus)
|
|
{
|
|
int err;
|
|
|
|
err = bcma_gpio_unregister(&bus->drv_cc);
|
|
if (err == -EBUSY)
|
|
bcma_err(bus, "Some GPIOs are still in use.\n");
|
|
else if (err)
|
|
bcma_err(bus, "Can not unregister GPIO driver: %i\n", err);
|
|
|
|
bcma_core_chipcommon_b_free(&bus->drv_cc_b);
|
|
|
|
bcma_unregister_cores(bus);
|
|
}
|
|
|
|
/*
|
|
* This is a special version of bus registration function designed for SoCs.
|
|
* It scans bus and performs basic initialization of main cores only.
|
|
* Please note it requires memory allocation, however it won't try to sleep.
|
|
*/
|
|
int __init bcma_bus_early_register(struct bcma_bus *bus)
|
|
{
|
|
int err;
|
|
struct bcma_device *core;
|
|
|
|
/* Scan for devices (cores) */
|
|
err = bcma_bus_scan(bus);
|
|
if (err) {
|
|
bcma_err(bus, "Failed to scan bus: %d\n", err);
|
|
return -1;
|
|
}
|
|
|
|
/* Early init CC core */
|
|
core = bcma_find_core(bus, bcma_cc_core_id(bus));
|
|
if (core) {
|
|
bus->drv_cc.core = core;
|
|
bcma_core_chipcommon_early_init(&bus->drv_cc);
|
|
}
|
|
|
|
/* Early init MIPS core */
|
|
core = bcma_find_core(bus, BCMA_CORE_MIPS_74K);
|
|
if (core) {
|
|
bus->drv_mips.core = core;
|
|
bcma_core_mips_early_init(&bus->drv_mips);
|
|
}
|
|
|
|
bcma_info(bus, "Early bus registered\n");
|
|
|
|
return 0;
|
|
}
|
|
|
|
#ifdef CONFIG_PM
|
|
int bcma_bus_suspend(struct bcma_bus *bus)
|
|
{
|
|
struct bcma_device *core;
|
|
|
|
list_for_each_entry(core, &bus->cores, list) {
|
|
struct device_driver *drv = core->dev.driver;
|
|
if (drv) {
|
|
struct bcma_driver *adrv = container_of(drv, struct bcma_driver, drv);
|
|
if (adrv->suspend)
|
|
adrv->suspend(core);
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int bcma_bus_resume(struct bcma_bus *bus)
|
|
{
|
|
struct bcma_device *core;
|
|
|
|
/* Init CC core */
|
|
if (bus->drv_cc.core) {
|
|
bus->drv_cc.setup_done = false;
|
|
bcma_core_chipcommon_init(&bus->drv_cc);
|
|
}
|
|
|
|
list_for_each_entry(core, &bus->cores, list) {
|
|
struct device_driver *drv = core->dev.driver;
|
|
if (drv) {
|
|
struct bcma_driver *adrv = container_of(drv, struct bcma_driver, drv);
|
|
if (adrv->resume)
|
|
adrv->resume(core);
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
#endif
|
|
|
|
int __bcma_driver_register(struct bcma_driver *drv, struct module *owner)
|
|
{
|
|
drv->drv.name = drv->name;
|
|
drv->drv.bus = &bcma_bus_type;
|
|
drv->drv.owner = owner;
|
|
|
|
return driver_register(&drv->drv);
|
|
}
|
|
EXPORT_SYMBOL_GPL(__bcma_driver_register);
|
|
|
|
void bcma_driver_unregister(struct bcma_driver *drv)
|
|
{
|
|
driver_unregister(&drv->drv);
|
|
}
|
|
EXPORT_SYMBOL_GPL(bcma_driver_unregister);
|
|
|
|
static int bcma_bus_match(struct device *dev, struct device_driver *drv)
|
|
{
|
|
struct bcma_device *core = container_of(dev, struct bcma_device, dev);
|
|
struct bcma_driver *adrv = container_of(drv, struct bcma_driver, drv);
|
|
const struct bcma_device_id *cid = &core->id;
|
|
const struct bcma_device_id *did;
|
|
|
|
for (did = adrv->id_table; did->manuf || did->id || did->rev; did++) {
|
|
if ((did->manuf == cid->manuf || did->manuf == BCMA_ANY_MANUF) &&
|
|
(did->id == cid->id || did->id == BCMA_ANY_ID) &&
|
|
(did->rev == cid->rev || did->rev == BCMA_ANY_REV) &&
|
|
(did->class == cid->class || did->class == BCMA_ANY_CLASS))
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static int bcma_device_probe(struct device *dev)
|
|
{
|
|
struct bcma_device *core = container_of(dev, struct bcma_device, dev);
|
|
struct bcma_driver *adrv = container_of(dev->driver, struct bcma_driver,
|
|
drv);
|
|
int err = 0;
|
|
|
|
get_device(dev);
|
|
if (adrv->probe)
|
|
err = adrv->probe(core);
|
|
if (err)
|
|
put_device(dev);
|
|
|
|
return err;
|
|
}
|
|
|
|
static int bcma_device_remove(struct device *dev)
|
|
{
|
|
struct bcma_device *core = container_of(dev, struct bcma_device, dev);
|
|
struct bcma_driver *adrv = container_of(dev->driver, struct bcma_driver,
|
|
drv);
|
|
|
|
if (adrv->remove)
|
|
adrv->remove(core);
|
|
put_device(dev);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int bcma_device_uevent(struct device *dev, struct kobj_uevent_env *env)
|
|
{
|
|
struct bcma_device *core = container_of(dev, struct bcma_device, dev);
|
|
|
|
return add_uevent_var(env,
|
|
"MODALIAS=bcma:m%04Xid%04Xrev%02Xcl%02X",
|
|
core->id.manuf, core->id.id,
|
|
core->id.rev, core->id.class);
|
|
}
|
|
|
|
static unsigned int bcma_bus_registered;
|
|
|
|
/*
|
|
* If built-in, bus has to be registered early, before any driver calls
|
|
* bcma_driver_register.
|
|
* Otherwise registering driver would trigger BUG in driver_register.
|
|
*/
|
|
static int __init bcma_init_bus_register(void)
|
|
{
|
|
int err;
|
|
|
|
if (bcma_bus_registered)
|
|
return 0;
|
|
|
|
err = bus_register(&bcma_bus_type);
|
|
if (!err)
|
|
bcma_bus_registered = 1;
|
|
|
|
return err;
|
|
}
|
|
#ifndef MODULE
|
|
fs_initcall(bcma_init_bus_register);
|
|
#endif
|
|
|
|
/* Main initialization has to be done with SPI/mtd/NAND/SPROM available */
|
|
static int __init bcma_modinit(void)
|
|
{
|
|
int err;
|
|
|
|
err = bcma_init_bus_register();
|
|
if (err)
|
|
return err;
|
|
|
|
err = bcma_host_soc_register_driver();
|
|
if (err) {
|
|
pr_err("SoC host initialization failed\n");
|
|
err = 0;
|
|
}
|
|
#ifdef CONFIG_BCMA_HOST_PCI
|
|
err = bcma_host_pci_init();
|
|
if (err) {
|
|
pr_err("PCI host initialization failed\n");
|
|
err = 0;
|
|
}
|
|
#endif
|
|
|
|
return err;
|
|
}
|
|
module_init(bcma_modinit);
|
|
|
|
static void __exit bcma_modexit(void)
|
|
{
|
|
#ifdef CONFIG_BCMA_HOST_PCI
|
|
bcma_host_pci_exit();
|
|
#endif
|
|
bcma_host_soc_unregister_driver();
|
|
bus_unregister(&bcma_bus_type);
|
|
}
|
|
module_exit(bcma_modexit)
|