<feed xmlns='http://www.w3.org/2005/Atom'>
<title>src/sys/dev/flash, branch release/12.3.0</title>
<subtitle>FreeBSD source tree</subtitle>
<id>https://cgit-dev.freebsd.org/src/atom?h=release%2F12.3.0</id>
<link rel='self' href='https://cgit-dev.freebsd.org/src/atom?h=release%2F12.3.0'/>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/'/>
<updated>2020-01-17T17:57:34Z</updated>
<entry>
<title>MFC r356086, r356278, r356294, r356519, r356521-r356522, r356525-r356526</title>
<updated>2020-01-17T17:57:34Z</updated>
<author>
<name>Ian Lepore</name>
<email>ian@FreeBSD.org</email>
</author>
<published>2020-01-17T17:57:34Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=c9c6bfcf79db248063e9f5e82ba08262cc434d93'/>
<id>urn:sha1:c9c6bfcf79db248063e9f5e82ba08262cc434d93</id>
<content type='text'>
r356086:
Add comments to a couple i2c device lines in NOTES.

r356278:
Add support for i2c bus mux hardware.

An i2c bus can be divided into segments which can be selectively connected
and disconnected from the main bus. This is usually done to enable using
multiple slave devices having the same address, by isolating the devices
onto separate bus segments, only one of which is connected to the main bus
at once.

There are several types of i2c bus muxes, which break down into two general
categories...

 - Muxes which are themselves i2c slaves. These devices respond to i2c
   commands on their upstream bus, and based on those commands, connect
   various downstream buses to the upstream. In newbus terms, they are both
   a child of an iicbus and the parent of one or more iicbus instances.
 - Muxes which are not i2c devices themselves. Such devices are part of the
   i2c bus electrically, but in newbus terms their parent is some other
   bus. The association with the upstream bus must be established by
   separate metadata (such as FDT data).

In both cases, the mux driver has one or more iicbus child instances
representing the downstream buses. The mux driver implements the iicbus_if
interface, as if it were an iichb host bridge/i2c controller driver. It
services the IO requests sent to it by forwarding them to the iicbus
instance representing the upstream bus, after electrically connecting the
upstream bus to the downstream bus that hosts the i2c slave device which
made the IO request.

The net effect is automatic mux switching which is transparent to slaves on
the downstream buses. They just do i2c IO they way they normally do, and the
bus is electrically connected for the duration of the IO and then idled when
it is complete.

The existing iicbus_if callback() method is enhanced so that the parameter
passed to it can be a struct which contains a device_t for the requesting
bus and slave devices. This change is done by adding a flag that indicates
the extra values are present, and making the flags field the first field of
a new args struct. If the flag is set, the iichb or mux driver can recast
the pointer-to-flags into a pointer-to-struct and access the extra
fields. Thus abi compatibility with older drivers is retained (but a mux
cannot exist on the bus with the older iicbus driver in use.)

A new set of core support routines exists in iicbus.c. This code will help
implement mux drivers for any type of mux hardware by supplying all the
boilerplate code that forwards IO requests upstream. It also has code for
parsing metadata and instantiating the child iicbus instances based on it.

Two new hardware mux drivers are added. The ltc430x driver supports the
LTC4305/4306 mux chips which are controlled via i2c commands. The
iic_gpiomux driver supports any mux hardware which is controlled by
manipulating the state of one or more gpio pins.  Test Plan

Tested locally using a variety of mux'd bus configurations involving both
ltc4305 and a homebrew gpio-controlled mux. Tested configurations included
cascaded muxes (unlikely in the real world, but useful to prove that 'it all
just works' in terms of the automatic switching and upstream forwarding of
IO requests).

r356294:
Explicitly include sys/rman.h instead of relying on getting it via some
other header.

r356519:
Ensure any reserved gpio pins get released if an early exit is taken
from the attach function.

r356521:
Init sc-&gt;maxbus to -1, not 0.  It represents the highest array index that
has a non-NULL child bus stored in it, so the "none" value can't be zero
since that's a valid array index.  Also, when adding all possible buses
because there is no specific per-bus config, there's no need to reset
sc-&gt;maxbus on each loop iteration, it can be set once after the loop.

r356522:
Change some KASSERT to device_printf + return EINVAL.  There's no need to
bring the whole kernel down due to a configuration error detected when a
module is loaded, it suffices to just not attach the device.

r356525:
Split the code to find and add iicbus children out to its own function.
Move the decision to take an early exit from that function after adding
children based on FDT data into the #ifdef FDT block, so that it doesn't
offend coverity's notion of how the code should be written.  (What's the
point of compilers optimizing away dead code if static analyzers won't
let you use the feature in conjuction with an #ifdef block?)

Reported by:	coverity via vangyzen@

r356526:
Remove some trailing whitespace; no functional changes.
</content>
</entry>
<entry>
<title>MFC r354086:</title>
<updated>2019-12-16T17:59:02Z</updated>
<author>
<name>Emmanuel Vadot</name>
<email>manu@FreeBSD.org</email>
</author>
<published>2019-12-16T17:59:02Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=e61044a61035aed40ddb11a71b0273feddbedb97'/>
<id>urn:sha1:e61044a61035aed40ddb11a71b0273feddbedb97</id>
<content type='text'>
flash: Add GigaDevice gd25q128 flash

Add this flash chip which is a 128Mb spi flash.
</content>
</entry>
<entry>
<title>MFC r348169-r348170, r348172-r348173, r348183-r348184</title>
<updated>2019-06-23T16:16:55Z</updated>
<author>
<name>Ian Lepore</name>
<email>ian@FreeBSD.org</email>
</author>
<published>2019-06-23T16:16:55Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=682a3ddec43f2229a396e54a4edb11867379ae84'/>
<id>urn:sha1:682a3ddec43f2229a396e54a4edb11867379ae84</id>
<content type='text'>
r348169:
Define macros making it easier to define bus-specific pnpinfo for FDT systems.

Pnpinfo is bus-specific and requires the bus name. The FDTCOMPAT_PNP_INFO()
macro makes it easier to define new FDT-based pnpinfo for busses other than
simplebus.

Differential Revision:	https://reviews.freebsd.org/D20382

r348170:
Add pnpinfo for icee(4) on fdt systems.

r348172:
Use the new FDTCOMPAT_PNP_INFO() macro to define SPIBUS_FDT_PNP_INFO().
Also rename SPIBUS_PNP_INFO -&gt; SPIBUS_FDT_PNP_INFO because there could be
other kinds of pnpinfo for other (non-fdt) bus attachments.

r348173:
Rename IICBUS_FDT_PNPINFO -&gt; IICBUS_FDT_PNP_INFO because all the other
existing pnpinfo-related macros right now use PNP_INFO, not PNPINFO.

r348183:
Add pnpinfo.

r348184:
Add pnpinfo to all i2c drivers that have FDT compat data.
</content>
</entry>
<entry>
<title>MFC r344505-r344507, r344523, r344525-r344526, r344529, r344606-r344612,</title>
<updated>2019-04-22T00:38:25Z</updated>
<author>
<name>Ian Lepore</name>
<email>ian@FreeBSD.org</email>
</author>
<published>2019-04-22T00:38:25Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=b90d8d4fb588a84158a9d49426b3e0093ca3457a'/>
<id>urn:sha1:b90d8d4fb588a84158a9d49426b3e0093ca3457a</id>
<content type='text'>
r344614-r344616, r344681, r344684-r344686, r344728, r344733-r344734, r344981

A large set of changes that collectively modernize the at45d and mx25l
(DataFlash and SpiFlash) drivers, add FDT support, and add geom_flashmap and
geom_label support to them.

r344505:
Add a functional detach() implementation to make module unloading possible.

r344506:
Add support for probing/attaching on FDT-based systems.

r344507:
Switch to using config_intrhook_oneshot().  That allows the error handling
in the delayed attach to use early returns, which allows reducing the level
of indentation.  So all in all, what looks like a lot of changes is really
no change in behavior, mostly just moving whitespace around.

r344523:
Include the jedec "extended device information string" in the criteria used
to match a chip to our table of metadata describing the chips. At least one
new DataFlash chip has a 3-byte jedec ID identical to its predecessors and
differs only in the extended info, and it has different metadata requiring a
unique entry in the table.  This paves the way for supporting such chips.

The metadata table now includes two new fields, extmask and extid.  The two
bytes of extended info obtained from the chip are ANDed with extmask then
compared to extid, so it's possible to use only a subset of the extended
info in the matching.

We now always read 6 bytes of jedec ID info. Most chips don't return any
extended info, and the values read back for those two bytes may be
indeterminate, but such chips have extmask and extid values of 0x0000 in the
table, so the extid effectively doesn't participate in the matching on those
chips and it doesn't matter what they return in the extended info bytes.

r344525:
Add a metadata entry for the AT45DB641E chip.  This chip has the same 3-byte
jedec ID as its older cousin the AT45DB642D, but uses a different page size.
The only way to distinguish between the two chips is that the 2D chip has
0 bytes of extended ID info and the new 1E has 1 byte of extended ID.  The
actual value of the extended ID byte is all zeroes.  In other words, it's
the presence of the extended info that identifies this chip. (Presumably
a future upgrade might define non-zero values for the extended ID byte.)

r344526:
Resolve a name conflict when both SpiFlash and DataFlash devices are present.

Both SpiFlash (mx25l) and DataFlash (at45d) drivers create a disk device
with a name of /dev/flash/spiN where N is the driver's unit number.  If
both types of devices are present in the same system, this creates a fatal
conflict that prevents attachment of whichever device attaches second
(because mx25l0 and at45d0 both try to create a spi0).

This gives each type of device a unique name (mx25lN or at45dN respectively)
and also adds an alias of spiN for compatibility.  When both device types
appear in the same system, only the first to attach gets the spiN alias.
When the second device attaches there is a non-fatal warning that the alias
can't be created, but both devices are still accessible via their primary
names (and there is no need for the spiN name to work for backwards
compatibility on such a system, because it has never been possible to use
the spiN names when both devices exist).

r344529:
Fix a paste-o that broke the build on all arches.

r344606:
Add support for geom_flashmap by providing a getattr() for "SPI:device".

r344607:
Compile fdt_slicer and geom_flashmap when the at45d device is included.

r344608:
Update a comment to reflect reality; no functional changes.

r344609:
Make it possible to load fdt_slicer as a module (unloading works too fwiw).

r344610:
Add manpages for at45d(4) and mx25l(4).

r344611:
Add a module dependency on fdt_slicer.

r344612:
Add a module dependency on fdt_slicer.  Also, move the PNP_INFO to its more
usual location, down near the DRIVER_MODULE() stuff.

r344614:
Rename some functions and variables to have shorter names, which allows
unwrapping multiple lines of code.  Also, convert some short multiline
comments into single-line comments.  Change old-school FALSE to false.

All in all, no functional changes, it's just more compact and readable.

r344615:
Child nodes with a compatible property are not slices, according to the
devicetree/bindings/mtd/partitions.txt document, so just ignore them.

r344616:
Add support to fdt_slicer for the new style partition data documented in
devicetree/bindings/mtd/partition.txt.

In the old style, all the children of the device node which did not have a
compatible property were the partitions.  In the new style, there is a child
node of the device which has a compatible string of "fixed-partitions", and
its children are the individual partitions.

Also, support the read-only property by setting the corresponding slice flag.

r344681:
Build fdt support modules on systems that use fdt data.

kern.opts.mk sets make var OPT_FDT to a non-empty value if platform.h
contains OPT_FDT.

r344684:
Undo accidental part of r344681.

I think I must have accidentally mouse-click pasted while scrolling and
didn't notice it.

Reported by:	jhibbits@

r344685:
Add required header file to SRCS.

r344686:
Add another required header file.

For some reason this seems to be required on aarch64, but I can build armv7
from clean without needing this in the list.  (The file does get included,
so the mystery is why armv7 works.)

r344728:
Bugfix: use a dummy buffer for the inactive side of a transfer.

This is especially important for writes.  SPI is inherently a bidirectional
bus; you receive data (even if it's garbage) while writing.  We should not
receive that data into the same buffer we're writing to the device.

When reading it doesn't matter what we send to the device, but using the
dummy buffer for that as well is pleasingly symmetrical.

r344733:
Add some comments.  Give #define'd names to some scattered numbers.  Change
some #define'd names to be more descriptive.  When reporting a post-write
compare failure, report the page number, not the byte address of the page.
The latter is the only functional change, it makes the number match the
words of the error message.

r344734:
Allow the sector size of the disk device to be configured using hints or
FDT data.  The sector size must be a multiple of the device's page size.
If not configured, use the historical default of the device page size.

Setting the disk sector size to 512 or 4096 allows a variety of standard
filesystems to be used on the device.  Of course you wouldn't want to be
writing frequently to a SPI flash chip like it was a disk drive, but for
data that gets written once (or rarely) and read often, using a standard
filesystem is a nice convenient thing.

r344981:
Give the mx25l device sole ownership of the name /dev/flash/spi* instead of
trying to use disk_add_alias() to make spi* an alias for mx25l*.  It turns
out disk_add_alias() works for partitions, but not slices, and that's hard
to fix.

This change is, in effect, a partial revert of r344526.

The mips world relies on the existence of flashmap names formatted as
/dev/flash/spi0s.name, whereas pretty much nothing relies on at45d devices
using the /dev/spi* names (because until recently the at45d driver didn't
even work reliably). So this change makes mx25l devices the sole owner of
the /dev/flash/spi* namespace, which actually makes some sense because it is
a SpiFlash(tm) device, so flash/spi isn't a horrible name.
</content>
</entry>
<entry>
<title>The device ID tables are used only within the driver, make them static so</title>
<updated>2018-07-29T16:55:28Z</updated>
<author>
<name>Ian Lepore</name>
<email>ian@FreeBSD.org</email>
</author>
<published>2018-07-29T16:55:28Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=6dfd050075216be8538ae375a22d30db72916f7e'/>
<id>urn:sha1:6dfd050075216be8538ae375a22d30db72916f7e</id>
<content type='text'>
that both of these drivers can exist in the same kernel.
</content>
</entry>
<entry>
<title>mx25l: compat_data is only defined when FDT is</title>
<updated>2018-06-14T19:01:40Z</updated>
<author>
<name>Emmanuel Vadot</name>
<email>manu@FreeBSD.org</email>
</author>
<published>2018-06-14T19:01:40Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=7de871aa81ddbeb9545b5dc00d9dcdd94da94db3'/>
<id>urn:sha1:7de871aa81ddbeb9545b5dc00d9dcdd94da94db3</id>
<content type='text'>
Reported by:	O. Hartmann &lt;ohartmann@walstatt.org&gt;
</content>
</entry>
<entry>
<title>mx25l: Add pnp info</title>
<updated>2018-06-14T17:21:09Z</updated>
<author>
<name>Emmanuel Vadot</name>
<email>manu@FreeBSD.org</email>
</author>
<published>2018-06-14T17:21:09Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=50d3578f0bdf542633cb1651cddc788c20bd9081'/>
<id>urn:sha1:50d3578f0bdf542633cb1651cddc788c20bd9081</id>
<content type='text'>
</content>
</entry>
<entry>
<title>mx25l: Add mx25l1606e</title>
<updated>2018-05-17T10:13:18Z</updated>
<author>
<name>Emmanuel Vadot</name>
<email>manu@FreeBSD.org</email>
</author>
<published>2018-05-17T10:13:18Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=bb5125a411079c81bbd852b93f59a50e2a053801'/>
<id>urn:sha1:bb5125a411079c81bbd852b93f59a50e2a053801</id>
<content type='text'>
This is a 16Mbits spi flash arranged in 32x64k blocks or 512x4k
sectors.
</content>
</entry>
<entry>
<title>Add driver for Cadence Quad SPI Flash Controller found on</title>
<updated>2018-04-23T10:35:00Z</updated>
<author>
<name>Ruslan Bukin</name>
<email>br@FreeBSD.org</email>
</author>
<published>2018-04-23T10:35:00Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=eb69ed7f87055a3d8b303b4ef223a208103d6d88'/>
<id>urn:sha1:eb69ed7f87055a3d8b303b4ef223a208103d6d88</id>
<content type='text'>
Intel® Arria® 10 SoC.

Cadence Quad SPI Flash is not generic SPI controller, but SPI flash
controller, so don't use spibus here, instead provide quad spi flash
interface.

Since it is not on spibus, then mx25l flash device driver is not usable
here, so provide new n25q flash device driver with quad spi flash
interface.

Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D10245
</content>
</entry>
<entry>
<title>Add the device/chip type to the disk d_descr field, and print more info</title>
<updated>2018-03-18T18:58:47Z</updated>
<author>
<name>Ian Lepore</name>
<email>ian@FreeBSD.org</email>
</author>
<published>2018-03-18T18:58:47Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=d8920513230d7d2577d328031cb135842ebeae25'/>
<id>urn:sha1:d8920513230d7d2577d328031cb135842ebeae25</id>
<content type='text'>
about the chip including the erase block size at attach time.

Also add myself to the copyrights since at this point svn blame would point
to me as the culprit for much of this.
</content>
</entry>
</feed>
