Commit Graph

9 Commits

Author SHA1 Message Date
Landon J. Fuller
f90f4b6532 bhnd(4): Initial PMU/PWRCTL power and clock management support.
- Added bhnd_pmu driver implementations for PMU and PWRCTL chipsets,
  derived from Broadcom's ISC-licensed HND code.
- Added bhnd bus-level support for routing per-core clock and resource
  power requests to the PMU device.
- Lift ChipCommon support out into the bhnd module, dropping
  bhnd_chipc.

Reviewed by:	mizhka
Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D7492
2016-08-27 00:03:02 +00:00
Landon J. Fuller
1728aef23d bhnd(4): Implement NVRAM support required for PMU bring-up.
- Added a generic bhnd_nvram_parser API, with support for the TLV format
  used on WGT634U devices, the standard BCM NVRAM format used on most
  modern devices, and the "board text file" format used on some hardware
  to supply external NVRAM data at runtime (e.g. via an EFI variable).

- Extended the bhnd_bus_if and bhnd_nvram_if interfaces to support both
  string-based and primitive data type variable access, required for
  common behavior across both SPROM and NVRAM data sources.
- Extended the existing SPROM implementation to support the new
  string-based NVRAM APIs.

- Added an abstract bhnd_nvram driver, implementing the bhnd_nvram_if
  atop the bhnd_nvram_parser API.
- Added a CFE-based bhnd_nvram driver to provide read-only access to
  NVRAM data on MIPS SoCs, pending implementation of a flash-aware
  bhnd_nvram driver.

Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D7489
2016-08-16 21:32:05 +00:00
Landon J. Fuller
71edabf7bd Fix heap overflow in bhnd(4) SPROM parsing.
The bus_region_* APIs accept the number of data items to be read, while
the code was passing the total number of bytes, resulting in an overflow
of the SPROM parser's buffer.

Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D7168
2016-07-10 00:08:40 +00:00
Landon J. Fuller
56a4cdd131 bhnd(4): support IPX OTP NVRAM/SPROM data source
Add support for fetching SPROM data from OTP on chipsets with an
IPX OTP controller (including the BCM43225).

This integrates the NVRAM data source into the chipc_caps capability
structure, and adds a sprom_offset field that can be used with OTP
to locate the SPROM image data (found within the general use
region, H/W subregion).

This also removes one of two duplicate parse error messages reported by
both the bhnd_sprom driver and the underlying SPROM parsing API.

Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D6729
2016-06-04 19:58:01 +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
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
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
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
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