History log of /freebsd-current/sys/dev/flash/at45d.c
Revision Date Author Comments
# fdafd315 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

sys: Automated cleanup of cdefs and other formatting

Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by: Netflix


# 685dc743 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix


# 0d95fe04 09-May-2022 John Baldwin <jhb@FreeBSD.org>

spi flash: Remove unused devclass arguments to DRIVER_MODULE.


# d176b803 07-Feb-2020 Scott Long <scottl@FreeBSD.org>

Ever since the block layer expanded its command syntax beyond just
BIO_READ and BIO_WRITE, we've handled this expanded syntax poorly in
drivers when the driver doesn't support a particular command. Do a
sweep and fix that.

Reported by: imp


# f86e6000 04-Dec-2019 Warner Losh <imp@FreeBSD.org>

Regularize my copyright notice

o Remove All Rights Reserved from my notices
o imp@FreeBSD.org everywhere
o regularize punctiation, eliminate date ranges
o Make sure that it's clear that I don't claim All Rights reserved by listing
All Rights Reserved on same line as other copyright holders (but not
me). Other such holders are also listed last where it's clear.


# db63d251 23-May-2019 Ian Lepore <ian@FreeBSD.org>

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


# 68dd7795 10-Mar-2019 Ian Lepore <ian@FreeBSD.org>

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.

Reported by: Mori Hiroki <yamori813@yahoo.co.jp>


# e70ece12 02-Mar-2019 Ian Lepore <ian@FreeBSD.org>

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.


# 2274a2f7 02-Mar-2019 Ian Lepore <ian@FreeBSD.org>

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.


# d4249d08 02-Mar-2019 Ian Lepore <ian@FreeBSD.org>

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.


# 33ec975b 26-Feb-2019 Ian Lepore <ian@FreeBSD.org>

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


# fb019471 26-Feb-2019 Ian Lepore <ian@FreeBSD.org>

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


# dec1d337 25-Feb-2019 Ian Lepore <ian@FreeBSD.org>

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

Reported by: many
Pointy hat: ian@


# d3248c41 25-Feb-2019 Ian Lepore <ian@FreeBSD.org>

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).


# 56e07c3e 25-Feb-2019 Ian Lepore <ian@FreeBSD.org>

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.)


# 9b9a1641 25-Feb-2019 Ian Lepore <ian@FreeBSD.org>

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.


# 3ea8b6b3 24-Feb-2019 Ian Lepore <ian@FreeBSD.org>

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.


# b9f80455 24-Feb-2019 Ian Lepore <ian@FreeBSD.org>

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


# 4b06839f 24-Feb-2019 Ian Lepore <ian@FreeBSD.org>

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


# 42c52f36 19-Feb-2018 Ian Lepore <ian@FreeBSD.org>

Add missing MODULE_DEPENDS().


# 718cf2cc 27-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

sys/dev: further adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.


# c445ffce2 17-Apr-2016 Adrian Chadd <adrian@FreeBSD.org>

undo previous commit - WIP was committed by accident.

Noticed by: bz


# 75b3cfd2 16-Apr-2016 Adrian Chadd <adrian@FreeBSD.org>

Only compile the FDT bits when we are using FDT.


# 429b844b 02-Mar-2015 Kevin Lo <kevlo@FreeBSD.org>

Check the return value of config_intrhook_establish().


# 29658c96 05-Nov-2012 Dimitry Andric <dim@FreeBSD.org>

Remove duplicate const specifiers in many drivers (I hope I got all of
them, please let me know if not). Most of these are of the form:

static const struct bzzt_type {
[...list of members...]
} const bzzt_devs[] = {
[...list of initializers...]
};

The second const is unnecessary, as arrays cannot be modified anyway,
and if the elements are const, the whole thing is const automatically
(e.g. it is placed in .rodata).

I have verified this does not change the binary output of a full kernel
build (except for build timestamps embedded in the object files).

Reviewed by: yongari, marius
MFC after: 1 week


# d80b202d 18-Jun-2012 Marius Strobl <marius@FreeBSD.org>

Revert r236529, re-enabling verification of the flashed content as
the underlying problem was dealt with in r237239 (in fact, disabling
verification also actually only made the problem less likely to occur).


# 4c87055c 03-Jun-2012 Marius Strobl <marius@FreeBSD.org>

Disable verification of the flashed content for now; for reasons unknown
it sometimes causes physwr to hang.


# 7f2107d4 02-Jun-2012 Marius Strobl <marius@FreeBSD.org>

- Loop up to 3 seconds when waiting for a device to get ready. [1]
- Make the device description match the driver name.
- Identify the chip variant based on the JEDEC and use that information
to use the proper values for page count, offset and size instead of
hardcoding a AT45DB642x with 2^N byte page support disabled.
- Take advantage of bioq_takefirst().
- Given that CONTINUOUS_ARRAY_READ_HF (0x0b) command isn't even mentioned
in Atmel's DataFlash Application Note, as suggested by the previous
comment may not work on all all devices and actually doesn't properly
on at least AT45DB321D (JEDEC 0x1f2701), rewrite at45d_task() to use
CONTINUOUS_ARRAY_READ (0xe8) for reading instead. This rewrite is laid
out in a way allowing to easily add support for BIO_DELETE later on.
- Add support for reads and writes not starting on a page boundary.
- Verify the flash content after writing.
- Let at45d_task() gracefully handle errors on SPI transfers and the
device not becoming ready afterwards again. [1]
- Use DEVMETHOD_END. [1]
- Use NULL instead of 0 for pointers. [1]

Additional testing by: Ian Lepore

Submitted by: Ian Lepore [1]
MFC after: 1 week


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# ab88d607 13-May-2009 Oleksandr Tymoshenko <gonzo@FreeBSD.org>

- Remove nonexistent header file from includes list


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# 3745c395 20-Oct-2007 Julian Elischer <julian@FreeBSD.org>

Rename the kthread_xxx (e.g. kthread_create()) calls
to kproc_xxx as they actually make whole processes.
Thos makes way for us to add REAL kthread_create() and friends
that actually make theads. it turns out that most of these
calls actually end up being moved back to the thread version
when it's added. but we need to make this cosmetic change first.

I'd LOVE to do this rename in 7.0 so that we can eventually MFC the
new kthread_xxx() calls.


# 674a9140 29-Nov-2006 Warner Losh <imp@FreeBSD.org>

MFp4:
Preliminary support for Atmel AT45D series of DataFlash on the
SPI bus (ok, not really a hardware bus, but a logical
connection). This works only for the 8MB version of the part
due to hard coding. Both read and write are supported.