Commit Graph

146 Commits

Author SHA1 Message Date
Landon J. Fuller
e129bcd6bc bhnd(4): Add support for chipc-attached flash
This adds support for serial (via SPI) and parallel (via CFI) flash
as found on BCM47xx/BCM53xx SoCs.

Submitted by:   Michael Zhilin <mizhka@gmail.com>
Approved by:    adrian (mentor)
Differential Revision:  https://reviews.freebsd.org/D6250
2016-06-04 19:39:05 +00:00
Landon J. Fuller
2b693a88f6 Fix several MIPS/BCM-blocking bugs in bhnd(4) chipc
- Correct IRQ lines for UART (to fix IRQ lookup in future)
- Check device unit in resource assignment during chipc_add_child
- If chipc hint->size is RM_MAX_END, resource end should be same as window end
- Clear reference from resource list entry to resource in case of resource release
- Add CHIPC_GET_CAPS implementation
- Correct chipc flash constants (to be unshifted)
- Default implementation of get_attach_type should iterate over device tree
- Add default implementation for BHND_CHIPC_GET_CAPS usable by chipc grandchildren

Submitted by:	Michael Zhilin <mizhka@gmail.com>
Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D6584
2016-06-04 19:31:06 +00:00
Adrian Chadd
72ebcd5db5 [bhnd] Fix release of uninitialized SPROM shadow in chipc detach.
This was triggering a panic on detach; the SPROM shadow is now
maintained by the bhnd_sprom_chipc driver, and should be removed
from chipc.

Submitted by:	Landon Fuller <landonf@landonf.org>
Differential Revision:	https://reviews.freebsd.org/D6548
2016-05-26 00:44:16 +00:00
Adrian Chadd
785df0cb3f [bhnd] Integrate bhnd_chipc's BUS_ADD_CHILD() with a child resource mapping table.
This adds support for automatically configuring bhnd_chipc bus children
with associated resources, using an internal 'hints' table based directly
on Michael Zhilin's chipc resource mapping work.

The bhnd_sprom_chipc driver has been converted to use DEVICE_IDENTIFY()
with the new resource table.

This should be nearly drop-in compatible with the child device drivers
in D6250.

Submitted by:	Landon Fuller <landonf@landonf.org>
Reviewed by:	Michael Zhilin <mizhka@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D6525
2016-05-26 00:43:08 +00:00
Adrian Chadd
5ad9ac037d [bhnd] Normalize bhnd(4) device matching API
This unifies handling of core, chip, and board-level device
matching, and adds support for matching device drivers
against the bus attach type (e.g. SoC vs WiFi adapter).

Core-level quirks on Broadcom's chipsets generally are specific
to some combination of chip model, core revision, chip
package (e.g. 12x9 SMT package), SROM revision, etc.

Unifying the match APIs for all three attribute types (core, chip,
board/srom) allows defining a single device quirk table that
matches across all of those attributes.

Submitted by:	Landon Fuller <landonf@landonf.org>
Differential Revision:	 https://reviews.freebsd.org/D6515
2016-05-24 21:20:17 +00:00
Adrian Chadd
b80427f906 [bhnd] fix compilation due to incompatible types
Submitted by:	Michael Zhilin <mizhka@gmail.com>
Differential Revision: https://reviews.freebsd.org/D6532
2016-05-24 15:39:57 +00:00
Adrian Chadd
f4a3eb0297 [bhnd] Implement pass-through resource management for ChipCommon.
This patchset adds support to bhnd_chipc for sharing SYS_RES_MEMORY
resources with its children, allowing us to hang devices off of
bhnd_chipc that rely on access to a subset of the device register space
that bhnd_chipc itself must also allocate.

We could avoid most of this heavy lifting if RF_SHAREABLE+SYS_RES_MEMORY
wasn't limited to use with allocations at the same size/offset.

As a work-around, I implemented something similar to vga_pci.c, which
implements similar reference counting of of PCI BAR resources for its
children.

With these changes, chipc will use reference counting of SYS_RES_MEMORY
allocation/activation requests, to decide when to allocate/activate/
deactivate/release resources from the parent bhnd(4) bus.

The requesting child device is allocated a new resource from chipc's
rman, pointing to (possibly a subregion of) the refcounted bhnd resources
allocated by chipc.

Other resource types are just passed directly to the parent bhnd bus;
RF_SHAREABLE works just fine with IRQs.

I also lifted the SPROM device code out into a common driver, since this
now allows me to hang simple subclasses off of a common driver off of both
bhndb_pci and bhnd_chipc.

Tested:

* (landonf) Tested against BCM4331 and BCM4312, confirmed that SPROM still
  attaches and can be queried.

Submitted by:	Landon Fuller <landonf@landonf.org>
Reviewed by:	mizkha@gmail.com
Differential Revision:	https://reviews.freebsd.org/D6471
2016-05-24 01:12:19 +00:00
Adrian Chadd
9d292ea16d [bhnd] Add support for querying the attachment type of the bhnd bus.
This adds a BHND_BUS_GET_ATTACH_TYPE(); the primary use-case is to let
chipc make a coarse-grained determination as to whether UART, SPI, etc
drivers ought to be attached, and on fullmac devices, whether a real
CPU driver ought to be skipped for the ARM core, etc.

Tested:

* BCM4331 (BHND)
* BCM4312 (SIBA)

Submitted by:	Landon Fuller <landonf@landonf.org>
Differential Revision:	https://reviews.freebsd.org/D6492
2016-05-23 03:47:44 +00:00
Adrian Chadd
223666cefe [bhnd] Add BHND SoC support (only BCMA case)
This patch introduces support of BHND on SoC: nexus-to-bhnd drivers.

bhnd_soc is attached under nexus and responsible for all BHND-style calls
from bhnd(4) bus to parents.

bcma_nexus is bhnd(4) bus, attached to bhnd_soc and implement all
nexus-style behaviour of BHND.

Submitted by:	Michael Zhilin <mizhka@gmail.com>
Reviewed by:	Landon Fuller <landonf@landonf.org>
Differential Revision:	https://reviews.freebsd.org/D6248
2016-05-20 01:02:58 +00:00
Adrian Chadd
249f3d3f77 [bhnd] Add bhnd bridge support for bus_adjust_resource().
Adds support for adjusting active bus resource allocations, limiting the
range to the constraints of the register window within which the resource
is mapped.

This is the final set of bhnd changes required to support delegating
ChipCommon's register space to child devices.

Submitted by:	Landon Fuller <landonf@landonf.org>
Differential Revision:	https://reviews.freebsd.org/D6470
2016-05-20 00:49:10 +00:00
Adrian Chadd
0e141e3c32 [bhnd] Add remaining bus_(read|write|set)_(1|2|4) APIs
This adds bhnd-compatible implementations of bus_(read|write|set)_(1|2|4) APIs,
and upgrades the SPROM parsing code to use bhnd_bus_read_region_stream_2().

This a precursor to bridge support for resource adjustment and the new
ChipCommon bus support.

Tested:

* Tested against BCM4331
* Kernel build verified via tinderbox.

Submitted by:	Landon Fuller <landonf@landonf.org>
Differential Revision:	https://reviews.freebsd.org/D6469
2016-05-20 00:45:16 +00:00
Eitan Adler
cef367e6a1 Don't repeat the the word 'the'
(one manual change to fix grammar)

Confirmed With: db
Approved by: secteam (not really, but this is a comment typo fix)
2016-05-17 12:52:31 +00:00
Adrian Chadd
8ef24a0d4b [bhnd] Finish bhnd(4) PCI/PCIe-G1 hostb support.
Now that we've got access to SPROM and can access board identification,
this implements all known remaining hardware work-arounds for the bhnd(4)
PCI and PCIe-G1 cores operating endpoint mode.

Additionally, this adds an initial set of skeleton PCIe-G2 hostb and pcib
drivers, required by fullmac and newer softmac devices.

Submitted by:	Landon Fuller <landonf@landonf.org>
Differential Revision:	https://reviews.freebsd.org/D6377
2016-05-17 06:52:53 +00:00
Adrian Chadd
d567592b68 [bhnd] Centralize fetching of board information
Centralizes fetching of board information (vendor, type, revision, etc),
and adds support for matching quirks against board identification info.

* Adds a BHND_BUS_READ_BOARD_INFO(), allowing bhnd bus/bus parent(s) to
  handle implementation-specific fetching of board info.
* Integrates board type constants from the latest Broadcom ISC-licensed
  bcmdevs.h included in dd-wrt's Broadcom driver source drops.
* Adds support for matching on chip/board quirks to bhnd_device_quirks()/
  bhnd_chip_quirks().
* Use the new board/chip quirk matching to match Apple devices that failed
  to set BFL2_PCIEWAR_OVR in SROM.

Submitted by:	Landon Fuller <landonf@landonf.org>
Differential Revision:	https://reviews.freebsd.org/D6361
2016-05-17 00:23:46 +00:00
Adrian Chadd
fb403678c2 [bhnd] Add logging macros to BHND.
There are 5 logging levels:

* ERROR
* WARN
* INFO
* DEBUG
* TRACE

There are 2 logging context:

* with
* without device

DEBUG and TRACE records are printed only if bootverbose.
Logging records are printed with source code line information if acceptable
logging level is DEBUG or TRACE.

Submitted by:	Michael Zhilin <mizhka@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D6247
2016-05-16 23:40:32 +00:00
Adrian Chadd
9d8ae244a3 [bhnd] Add support for matching of MIPS & ARM cores
Extend macros for MIPS & ARM cores. Now only BCM cores can be matched by matching mechanism.

Submitted by:	Michael Zhilin <mizhka@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D6246
2016-05-16 23:37:18 +00:00
Ed Maste
4de3a46c66 Use awk to run bhnd's awk script, to allow noexec src dir
PR:		209435
Submitted by:	Landon Fuller <landonf@landonf.org>
Differential Revision:	https://reviews.freebsd.org/D6312
2016-05-13 18:56:56 +00:00
Adrian Chadd
05992f9e2c [bhnd] fix bcma resource allocation for regions; EROM work around.
* bcma.c - assign different resource IDs for different regions
* bcma_erom.c - workaround for BCM/MIPS bus enumerations

Tested:

* (submitter) Tested on ASUS RT-N16 initially, double checked on ASUS RT-N53
* (landonf) BCM4331

Submitted by:	Michael Zhilin <mizkha@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D6245
2016-05-10 04:55:57 +00:00
Adrian Chadd
f9cf87a0e0 [bhnd] fix incorrect typing.
Pointed out by: emaste
2016-05-09 17:19:17 +00:00
Adrian Chadd
e83ce34035 [bhnd] Initial bhnd(4) SPROM/NVRAM support.
This adds support for the NVRAM handling and the basic SPROM
hardware used on siba(4) and bcma(4) devices, including:

* SPROM directly attached to the PCI core, accessible via PCI configuration
  space.
* SPROM attached to later ChipCommon cores.
* SPROM variables vended from the parent SoC bus (e.g. via a directly-attached
  flash device).

Additional improvements to the NVRAM/SPROM interface will
be required, but this changeset stands alone as working
checkpoint.

Submitted by:	Landon Fuller <landonf@landonf.org>
Reviewed by:	Michael Zhilin <mizkha@gmail.com> (Broadcom MIPS support)
Differential Revision:	https://reviews.freebsd.org/D6196
2016-05-08 19:14:05 +00:00
Adrian Chadd
f74f1a68d5 [bhnd] Add support for matching on chip identifiers.
This is used by the upcoming SPROM code to match on chipsets
that require special handling of muxed SPROM pins.

Submitted by:	Landon Fuller <landonf@landonf.org>
Differential Revision:	https://reviews.freebsd.org/D6195
2016-05-08 18:30:08 +00:00
Adrian Chadd
a73ac06d93 [bhnd] Add bhnd_resource support for the bus_(read|write)(_multi_)stream_* functions.
This adds additional bhnd_resource shims used by the upcoming SPROM deltas.

Submitted by:	Landon Fuller <landonf@landonf.org>
Differential Revision:	https://reviews.freebsd.org/D6194
2016-05-08 18:20:01 +00:00
Adrian Chadd
d935257080 [bhnd] Replace is_hostb_device() with a more general find_hostb_device()
This allows bus children to query for the host bridge device, rather
than having to iterate over all attached devices.

Submitted by:	Landon Fuller <landonf@landonf.org>
Differential Revision:	https://reviews.freebsd.org/D6193
2016-05-08 17:52:12 +00:00
Adrian Chadd
426a80d44d [bhnd] don't use anonymous unions.
Found by: gcc-4.2
2016-05-05 19:56:18 +00:00
Adrian Chadd
054ae23156 [bhnd] default to BUS_PROBE_DEFAULT for unknown BHND classes.
Found by: gcc-4.2
2016-05-05 19:55:16 +00:00
Adrian Chadd
0aba90e3bc [bhnd] handle unknown bhnd port type. 2016-05-05 19:54:17 +00:00
Adrian Chadd
10cb4427d5 [bhnd] quieten gcc warning. 2016-05-05 19:38:53 +00:00
Adrian Chadd
988fa8d078 [bhnd] handle unknown port type.
Reported by: emaste
2016-05-05 19:30:14 +00:00
Ed Maste
c009c4021c bhnd: another build fix for GCC-using architectures
Further to r299119. GCC architectures failed with
bcma_subr.c:138: warning: control reaches end of non-void function

Sponsored by:	The FreeBSD Foundation
2016-05-05 17:47:03 +00:00
Ed Maste
c2ec037ff5 bhnd: fix build on gcc architectures
"make tinderbox" fails on sparc64 GENERIC-NODEBUG with:
bhnd_subr.c:188: warning: control reaches end of non-void function

Sponsored by:	The FreeBSD Foundation
2016-05-05 15:07:40 +00:00
Adrian Chadd
148ed57165 [bwn] [bhnd] initial support for using bhnd for if_bwn devices.
This is an initial work in progress to use the replacement bhnd
bus code for devices which support it.

* Add manpage updates for bhnd, bhndb, siba
* Add kernel options for bhnd, bhndbus, etc
* Add initial support in if_bwn_pci / if_bwn_mac for using bhnd
  as the bus transport for suppoted NICs
* if_bwn_pci will eventually be the PCI bus glue to interface to bwn,
  which will use the right backend bus to attach to, versus direct
  nexus/bhnd attachments (as found in embedded broadcom devices.)

The PCI glue defaults to probing at a lower level than the bwn glue,
so bwn should still attach as per normal without a boot time tunable set.

It's also not fully fleshed out - the bwn probe/attach code needs to be
broken out into platform and bus specific things (just like ath, ath_pci,
ath_ahb) before we can shift the driver over to using this.

Tested:

* BCM4311, STA mode
* BCM4312, STA mode

Submitted by:	Landon Fuller <landonf@landonf.org>
Differential Revision:	https://reviews.freebsd.org/D6191
2016-05-04 23:38:27 +00:00
Pedro F. Giffuni
453130d9bf sys/dev: minor spelling fixes.
Most affect comments, very few have user-visible effects.
2016-05-03 03:41:25 +00:00
Adrian Chadd
eaddb80745 [bhnd] fix more module dependencies.
Submitted by:	Landon Fuller <landonf@landonf.org>
Differential Revision:	https://reviews.freebsd.org/D6180
2016-05-02 22:30:46 +00:00
Adrian Chadd
96546b75e7 [bhnd] add module dependencies.
Submitted by:	Landon Fuller <landonf@landonf.org>
Differential Revision:	https://reviews.freebsd.org/D6179
2016-05-02 21:01:08 +00:00
Adrian Chadd
8a3fcfa7be [bhnd] Fix ChipCommon probing.
ChipCommon probing uses mapping table "chipc_devices". It calls bhnd_device_lookup,
which iterate over mapping table with end condition:

entry->desc != NULL

So if mapping table contains row with description equals to NULL, it will
stop processing of mapping. I.e. description is mandatory field and should
be not NULL.

This patch corrects mapping table for ChipCommon.

Submitted by:	Michael Zhilin <mizhka@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D6088
2016-04-25 16:53:13 +00:00
Adrian Chadd
178c755910 [bhnd] use correct bus deallocation method
Submitted by:	Mizhka Zhilin <mizhka@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D5647
2016-04-22 16:28:41 +00:00
Adrian Chadd
05f61102bb [bhnd] Update bhndb format strings to match long -> rman_res_t size change.
Does what it says on the tin; this unbreaks 32-bit builds.

Submitted by:	Landon Fuller <landonf@landonf.org>
Differential Revision:	https://reviews.freebsd.org/D5764
2016-04-22 16:27:35 +00:00
Adrian Chadd
bb64eecc0b [bhnd] Add a common bhnd_pci driver shared by both bhnd_pcib and bhnd_pci_hostb
This extracts common code from bhndb_pci, bhnd_pcib, and bhnd_pci_hostb into a
simpler shared bhnd_pci base driver, and should enable SoC-side implementation
of bhnd_pcib root complex support.

Submitted by:	Landon Fuller <landonf@landonf.org>
Differential Revision:	https://reviews.freebsd.org/D5763
2016-04-22 16:26:53 +00:00
Adrian Chadd
36e4410ab0 [bhnd] Standardize bhnd device tables and quirk matching.
This add a bhnd device table mechanism that standardizes matching of
devices on the bhnd(4) bus, discovery of device quirk flags, and should
be pluggable into the new PNPINFO machinery.

Submitted by:	Landon Fuller <landonf@landonf.org>
Differential Revision:	https://reviews.freebsd.org/D5759
2016-04-19 15:56:39 +00:00
Adrian Chadd
386fb140a6 [bhnd] Clean up bhnd resource handling and inherited bus methods
To facilitate use by SoC implementors working with bhnd-inheriting fdt/nexus
drivers:

* Splits bhnd_bus method implementations into generic bus implementations
  (bhnd_bus_generic) and generic bhnd(4) driver implementations (bhnd_generic)
* Simplifies bhnd resource handling, allowing bhnd bus implementations to
  support bhnd resource activation by implementing the standard BUS_*
  resource APIs and BHND_BUS_ACTIVATE_RESOURCE().

Submitted by:	Landon Fuller <landonf@landonf.org>
Differential Revision:	https://reviews.freebsd.org/D5758
2016-04-19 15:53:57 +00:00
Adrian Chadd
e9378f456a [bhnd] Add support for specifying the address space used by bhndb children
This adds support for specifying the address space used by a bridge child;
this will either be the bridged SoC address space, or the host address space
required by children that map non SoC-address ranges from the PCI BAR.

This is necessary to support SROM/OTP child devices that live directly
beneath the bhndb device and require access to host resources, instead
of the standard behavior of delegating access to the bridged SoC address
space.

Submitted by:	Landon Fuller <landonf@landonf.org>
Differential Revision:	https://reviews.freebsd.org/D5757
2016-04-19 15:52:55 +00:00
Pedro F. Giffuni
74b8d63dcc Cleanup unnecessary semicolons from the kernel.
Found with devel/coccinelle.
2016-04-10 23:07:00 +00:00
Justin Hibbits
f8fd3fb518 Fix the resource_list_print_type() calls to use uintmax_t.
Missed a bunch from r297000.
2016-03-22 22:25:08 +00:00
Justin Hibbits
534ccd7bbf Replace all resource occurrences of '0UL/~0UL' with '0/~0'.
Summary:
The idea behind this is '~0ul' is well-defined, and casting to uintmax_t, on a
32-bit platform, will leave the upper 32 bits as 0.  The maximum range of a
resource is 0xFFF.... (all bits of the full type set).  By dropping the 'ul'
suffix, C type promotion rules apply, and the sign extension of ~0 on 32 bit
platforms gets it to a type-independent 'unsigned max'.

Reviewed By: cem
Sponsored by:	Alex Perez/Inertial Computing
Differential Revision: https://reviews.freebsd.org/D5255
2016-03-03 05:07:35 +00:00
Justin Hibbits
82ed3cb0e4 Replace some more default range checks with RMAN_IS_DEFAULT_RANGE().
This is a follow-on to r295832.
2016-03-02 03:26:56 +00:00
Adrian Chadd
4ad7e9b01a Bring over the initial rewrite of the broadcom bus support found in their
SoCs and various chips (including, famously, their wifi chips.)

This is "just" (all 20,000 lines of it) code to enumerate the various
versions of busses inside these devices, including the PCI bridge and
the direct SIBA bridge found in MIPS chips.

It also includes shared code for some bus operations (suspend, resume, etc);
EEPROM/SROM/etc parsing and other things that are shared between chips.

Eventually this'll replace the code that bwi/bwn uses for the internal
bus, as well as some apparently upcoming mips74k broadcom SoC support
which uses bwn!

Thanks to Landon Fuller <landonf@landonf.org> for all this work!

Obtained from:	https://github.com/landonf/freebsd/compare/user/landonf/bcm4331-CURRENT
2016-02-26 03:34:08 +00:00