Home | History | Annotate | Download | only in dev
History log of /src/sys/arch/mips/atheros/dev/arspi.c
RevisionDateAuthorComments
 1.16  10-Sep-2025  thorpej Encapsulate what's needed to attach a SPI bus into a spibus_attach()
inline.
 1.15  07-Aug-2021  thorpej branches: 1.15.2;
Merge thorpej-cfargs2.
 1.14  24-Apr-2021  thorpej branches: 1.14.2; 1.14.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.13  04-Jan-2021  thorpej branches: 1.13.2;
malloc(9) -> kmem(9)
 1.12  13-Aug-2019  tnn branches: 1.12.8;
ensure spibus_attach_args is zero'ed
 1.11  03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.10  27-Oct-2012  chs branches: 1.10.36; 1.10.38;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.9  10-Jul-2011  matt branches: 1.9.2; 1.9.12;
Cleanup machine includes
 1.8  07-Jul-2011  matt Revamp / rework the Atheros MIPS SoC support. Add initial support for the
AR71xx (MIPS 24K core) SoC and the AR9344 (MIPS 74K core) SoC. Force use
of -mips32 for all Atheros kernels. Make code much more common.
 1.7  01-Jul-2011  dyoung #include <sys/bus.h> instead of <machine/bus.h>.
 1.6  08-Jun-2011  rmind - Use IPL_BIO (instead of IPL_SERIAL) for SPI.
- Convert simple_lock/ltsleep to mutex/condvar.
 1.5  28-Feb-2007  thorpej branches: 1.5.66; 1.5.76;
TRUE -> true, FALSE -> false
 1.4  21-Feb-2007  thorpej Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.3  25-Dec-2006  wiz branches: 1.3.2; 1.3.4;
Spell "separate" correctly. From Zafer Aydogan.
 1.2  20-Oct-2006  gdamore branches: 1.2.2; 1.2.4;
This commit provides substantial fixes and functionality for SPI flash.

Specifically, the SPI flash now operates as a nearly fully functional block
device (other than lacking disklabel support). It does some basic translation
stuff, so that if you attempt to write a block, the underlying flash sectors
(usually 64k in size) will be read, erased and rewritten.

To minize thrashing, the spiflash strategy routine attempts to gather writes
to the same sector together, so that in the typical case you will not have to
repeatedly erase/rewrite the sector. It also attempts to check and verify
whether an erase cycle is truly needed. There are still access patterns that
will cause multiple erases to occur, and so I heartily discourage the use
of these flash devices for storing anything other than small configuration
data, or write-once images. If you want to do more than that, then someone
should try to write a real flash translation layer.

The drivers attempt to provide some level of asynchronous operation, so that
while you are erasing or writing to the flash, other things can reasonably
take place.

Note that spiflash does not do bad block remapping. It also doesn't detect
when a device is in read-only mode, or if some sectors are read-only. It
only supports uniform sectored NOR flash. It lacks any code to deal with
disklabels, and does not offer any disk related ioctls.

These limitations aside, it would not be terribly hard, I think, to break
out the code I've done to create a generic "norflash" driver, backed by
a "common" spiflash module. Then other flash drivers (e.g. athflash, etc.)
could benefit from the ability to use this as a block device. I've tried
to architect it to support that, if someone else wants to do the work.
(Hi Jared!)

The primary reason that I've not added code to deal with disklabels is that
I had a difficult time figuring out which framework (disklabels or wedges)
to use, and which bits of code were necessary to implement. In the case of
the flash devices I'm working with, a parser to deal with redboot FIS images
(partitions) would need to be added. I was prepared to do this, but gave
up owing to the complete and total lack of any API or design documentation
pertaining to the requirements for disk drivers and disklabel management or
wedges. I would strongly encourage someone who knows something about
wedges or disklabels to write a simple document (or even a dummy driver)
showing which interfaces should be provided in new mass storage drivers.

This work was funded by the Champaign-Urbana Community Wireless Network
Project.
 1.1  07-Oct-2006  gdamore Add Atheros SPI controller. This is a "pseudo-controller", as it has some
artificial limitations which really only make it good for use with serial
flash devices. One of the more annoying limitations is a restriction that
it can only transfer 8 bytes at a time. (4 command/address, plus 4 data.)

The driver includes design to work around those limitations, but these
changes are only appropriate for serial flash devices.

This driver is designed to run in interrupt driven mode, but due to lack
of adequate documentation, we run it in polled mode.

A subsequent commit will introduce the MI M25P flash driver, which has been
tested and is known to function somewhat reasonably..
 1.2.4.3  12-Jan-2007  ad Sync with head.
 1.2.4.2  18-Nov-2006  ad Sync with head.
 1.2.4.1  20-Oct-2006  ad file arspi.c was added on branch newlock2 on 2006-11-18 21:29:25 +0000
 1.2.2.2  22-Oct-2006  yamt sync with head
 1.2.2.1  20-Oct-2006  yamt file arspi.c was added on branch yamt-splraiseipl on 2006-10-22 06:04:52 +0000
 1.3.4.2  12-Mar-2007  rmind Sync with HEAD.
 1.3.4.1  27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.3.2.4  03-Sep-2007  yamt sync with head.
 1.3.2.3  26-Feb-2007  yamt sync with head.
 1.3.2.2  30-Dec-2006  yamt sync with head.
 1.3.2.1  25-Dec-2006  yamt file arspi.c was added on branch yamt-lazymbuf on 2006-12-30 20:46:30 +0000
 1.5.76.1  23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.5.66.1  12-Jun-2011  rmind sync with head
 1.9.12.1  20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.9.2.1  30-Oct-2012  yamt sync with head
 1.10.38.2  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.10.38.1  10-Jun-2019  christos Sync with HEAD
 1.10.36.1  06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.12.8.1  03-Apr-2021  thorpej Sync with HEAD.
 1.13.2.1  23-Mar-2021  thorpej Convert config_found_ia() call sites where the device only carries
a single interface attribute to bare config_found() calls.
 1.14.8.1  04-Aug-2021  thorpej Adapt to CFARGS().
 1.14.2.1  18-May-2021  thorpej Pass the controller devhandle along to the "spi" instance.
 1.15.2.1  09-Aug-2021  thorpej Port over the changes from thorpej-i2c-spi-conf to thorpej-i2c-spi-conf2,
which is based on a newer HEAD revision.

RSS XML Feed