Page MenuHomeFreeBSD

Initial bhnd(4) SPROM/NVRAM support.
ClosedPublic

Authored by landon_landonf.org on May 3 2016, 7:19 PM.
Tags
None
Referenced Files
F83609682: D6196.diff
Sun, May 12, 3:52 PM
Unknown Object (File)
Thu, May 2, 9:17 PM
Unknown Object (File)
Thu, May 2, 9:17 PM
Unknown Object (File)
Thu, May 2, 9:17 PM
Unknown Object (File)
Thu, May 2, 9:17 PM
Unknown Object (File)
Thu, May 2, 8:02 PM
Unknown Object (File)
Thu, May 2, 7:59 PM
Unknown Object (File)
Thu, May 2, 6:39 PM
Subscribers

Details

Summary

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.

Depends on D6195

Test Plan

Load if_bwn_pci and look for a valid Broadcom MAC address:

bwn0: got macaddr 8c:2d:aa:36:5f:07

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 3566
Build 3606: arc lint + arc unit

Event Timeline

landon_landonf.org retitled this revision from to Initial bhnd(4) SPROM/NVRAM support..
landon_landonf.org updated this object.
landon_landonf.org edited the test plan for this revision. (Show Details)
landon_landonf.org added a reviewer: adrian.

Optimize NVRAM table lookup, rebase against master.

  • Fix generation of struct variable records.
  • Implement a stable sorting guarantee for the generated NVRAM table.
  • Use the variable table order guarantee to implement binary search for variable definitions.

mizkha: when you get a chance, can you eyeball this for any issues on the SoC side?

sys/dev/bhnd/cores/chipc/chipc.c
196–199

I think if sprom is unsupported, it shouldn't cause fail of chipc attach call.

sys/dev/bhnd/nvram/nvram_subr.c
49–55

CRC8 polinom is duplicated few times in kernel. May be to add generic support?

mizhka requested changes to this revision.May 7 2016, 5:56 AM
mizhka edited edge metadata.
This revision now requires changes to proceed.May 7 2016, 5:56 AM
landon_landonf.org edited edge metadata.
  • Add support for generating a set of #defines for all bhnd(4) NVRAM variable keys.
  • Allow ChipCommon to attach when OTP or NFLASH SPROM sources are identified.
  • Rename the bhnd_nvram_* variable functions (modeled on the OF_prop* API).
  • When generating nvram map headers, truncate any existing output file.
  • Add an explicit fallback cases for unmatched enums.
  • Re-integrate module dependency that went missing in a merge.
sys/dev/bhnd/cores/chipc/chipc.c
196–199

Makes sense; the unhandled sources will now just print a message, rather than breaking attach.

sys/dev/bhnd/nvram/nvram_subr.c
49–55

I think the only other code using these same crc8 parameters is in the siba code we're replacing.

mizhka edited edge metadata.
This revision is now accepted and ready to land.May 7 2016, 9:40 PM
This revision was automatically updated to reflect the committed changes.
/scratch/tmp/emaste/freebsd/sys/modules/bhnd/bhndb_pci/../../../dev/bhnd/bhndb/bhndb_pci.c:170:52: error: format specifies type 'size_t' (aka 'unsigned int') but the argument has type 'bus_size_t' (aka 'unsigned long') [-Werror,-Wformat]
                        device_printf(dev, "found SPROM (%zu bytes)\n", nv_sz);
                                                         ~~~            ^~~~~
                                                         %lu
/scratch/tmp/emaste/freebsd/sys/modules/bhnd/bhndb_pci/../../../dev/bhnd/bhndb/bhndb_pci.c:237:1: error: conflicting types for 'bhndb_pci_sprom_size'
bhndb_pci_sprom_size(struct bhndb_pci_softc *sc)
^
/scratch/tmp/emaste/freebsd/sys/modules/bhnd/bhndb_pci/../../../dev/bhnd/bhndb/bhndb_pci.c:76:16: note: previous declaration is here
static size_t           bhndb_pci_sprom_size(struct bhndb_pci_softc *sc);
                        ^
2 errors generated.