summaryrefslogtreecommitdiff
path: root/sys/dev/flash
AgeCommit message (Collapse)Author
2025-04-28Fix TXFIFO register write and timeout messagePremal Gajjar
Changes: - Fixed incorrect register write for TXFIFO invalidation (FSPI_IPRXFCR → FSPI_IPTXFCR). - Corrected error message for TXFIFO wait timeout (FSPI_INTR_IPRXWA → FSPI_INTR_IPTXWE). - Corrected comment for TXFIFO available (RXFIFO -> TXFIFO) Reviewed-by: imp@FreeBSD.org Reviewed-by: jlduran@FreeBSD.org Pull-request: https://github.com/freebsd/freebsd-src/pull/1604
2025-02-14flash: add w25n (nand flash) supportAdrian Chadd
This adds read only support for the W25N series of flash parts. Specifically starting with the W25N01GV, a 128MiB SPI NAND flash. This doesn't currently support writing or erasing, as this requires a NAND flash layer that we don't currently have. There are also plenty of other commands that aren't currently supported - notably maintaining the on-chip flash translation layer, flash wear statistics, etc. But read support is fine enough for now; it at least allows for reading the boot / config / calibration flash on my ASUS IPQ4018 based router. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D48979
2024-12-06Replace calls to bus_generic_attach with bus_attach_childrenJohn Baldwin
Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D47675
2024-09-03flexspi: Stop checking for failures from malloc(M_WAITOK)Zhenlei Huang
MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D45852
2024-01-10clk: Move clock code in dev/clkEmmanuel Vadot
We've removed kernel option EXT_RESOURCES almost two years ago. While it was ok to have some code under a common 'extres' subdirectory at first, we now have a lot of consumer of it and we made it mandatory so no need to have it under a cryptic name. Reviewed by: mhorne Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D43191
2023-11-26sys: Automated cleanup of cdefs and other formattingWarner Losh
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
2023-08-16sys: Remove $FreeBSD$: one-line sh patternWarner Losh
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16sys: Remove $FreeBSD$: one-line .c patternWarner Losh
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16sys: Remove $FreeBSD$: two-line .h patternWarner Losh
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-05-12spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh
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
2023-04-18flash: Add "n25q64" to mx25l driverStephen J. Kiernan
This is for 64Mb Micron N25Q serial NOR flash memory Obtained from: Juniper Networks, Inc.
2022-05-09spi flash: Remove unused devclass arguments to DRIVER_MODULE.John Baldwin
2022-04-13flash: Remove unused variables.John Baldwin
2022-04-05flexspi: In flex_spi_task remove dev, it's write onlyWarner Losh
Sponsored by: Netflix
2022-04-04mx25l_task: eliminate dev write only variableWarner Losh
Sponsored by: Netflix
2021-12-07flex_spi: Don't try to destroy disk if it doesn't existKornel Duleba
Try to stop and destroy the dist only if the driver has been successfully attached. Otherwise a kernel panic will be triggered from disk_destroy. The issue was observed on a board that missed SPI clock description in DT.
2021-11-30flex_spi: Support for FlexSPI Flash controller.Wojciech Macek
NXP FlexSPI is a complex SPI controller which provides full offload for accessing NOR Flash. Create a Flash driver which attaches to existing FreeBSD infrastructure and exports generic READ and WRITE disk commands. The Flash has to be identified first to configure controller internals. For now, only one NOR Flash chip is supported. Future commits shall either increase number of known chips or implement SFDP mechanism which can be used by other Flash drivers. Sponsored by: Alstom Obtained from: Semihalf Differential revision: https://reviews.freebsd.org/D33117
2021-08-30mx25l: Add support for Integrated Silicon Solution is25wp256Thomas Skibo
This is used for the on-board flash on the HiFive Unmatched board. Reviewed by: #riscv, jrtc27 MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D31562
2020-11-28Make MAXPHYS tunable. Bump MAXPHYS to 1M.Konstantin Belousov
Replace MAXPHYS by runtime variable maxphys. It is initialized from MAXPHYS by default, but can be also adjusted with the tunable kern.maxphys. Make b_pages[] array in struct buf flexible. Size b_pages[] for buffer cache buffers exactly to atop(maxbcachebuf) (currently it is sized to atop(MAXPHYS)), and b_pages[] for pbufs is sized to atop(maxphys) + 1. The +1 for pbufs allow several pbuf consumers, among them vmapbuf(), to use unaligned buffers still sized to maxphys, esp. when such buffers come from userspace (*). Overall, we save significant amount of otherwise wasted memory in b_pages[] for buffer cache buffers, while bumping MAXPHYS to desired high value. Eliminate all direct uses of the MAXPHYS constant in kernel and driver sources, except a place which initialize maxphys. Some random (and arguably weird) uses of MAXPHYS, e.g. in linuxolator, are converted straight. Some drivers, which use MAXPHYS to size embeded structures, get private MAXPHYS-like constant; their convertion is out of scope for this work. Changes to cam/, dev/ahci, dev/ata, dev/mpr, dev/mpt, dev/mvs, dev/siis, where either submitted by, or based on changes by mav. Suggested by: mav (*) Reviewed by: imp, mav, imp, mckusick, scottl (intermediate versions) Tested by: pho Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D27225 Notes: svn path=/head/; revision=368124
2020-10-02flash: Add support for SPI flash s25fl512sNick O'Brien
Reviewed by: kp Approved by: kp (mentor) Sponsored by: Axiado Notes: svn path=/head/; revision=366366
2020-02-08Enter the network epoch in the xdma interrupt handler if requiredRuslan Bukin
by a peripheral device driver. Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=357686
2020-02-07Ever since the block layer expanded its command syntax beyond justScott Long
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 Notes: svn path=/head/; revision=357647
2020-01-19zilinx/zy7_qspi: Add a qspi driver for Zynq platforms.Emmanuel Vadot
This is a qspi driver for the Xilinx Zynq-7000 chip. It could be useful for anyone wanting to boot a system from flash memory instead of SD cards. Submitted by: Thomas Skibo (thomasskibo@yahoo.com) Differential Revision: https://reviews.freebsd.org/D14698 Notes: svn path=/head/; revision=356895
2020-01-02Explicitly include sys/rman.h instead of relying on getting it via someIan Lepore
other header. Notes: svn path=/head/; revision=356294
2019-12-04Regularize my copyright noticeWarner Losh
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. Notes: svn path=/head/; revision=355394
2019-10-25flash: Add GigaDevice gd25q128 flashEmmanuel Vadot
Add this flash chip which is a 128Mb spi flash. MFC after: 1 week Notes: svn path=/head/; revision=354086
2019-05-23Use the new FDTCOMPAT_PNP_INFO() macro to define SPIBUS_FDT_PNP_INFO().Ian Lepore
Also rename SPIBUS_PNP_INFO -> SPIBUS_FDT_PNP_INFO because there could be other kinds of pnpinfo for other (non-fdt) bus attachments. Notes: svn path=/head/; revision=348172
2019-03-10Give the mx25l device sole ownership of the name /dev/flash/spi* instead ofIan Lepore
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> Notes: svn path=/head/; revision=344981
2019-03-02Allow the sector size of the disk device to be configured using hints orIan Lepore
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. Notes: svn path=/head/; revision=344734
2019-03-02Add some comments. Give #define'd names to some scattered numbers. ChangeIan Lepore
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. Notes: svn path=/head/; revision=344733
2019-03-02Bugfix: use a dummy buffer for the inactive side of a transfer.Ian Lepore
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. Notes: svn path=/head/; revision=344728
2019-02-26Add a module dependency on fdt_slicer. Also, move the PNP_INFO to its moreIan Lepore
usual location, down near the DRIVER_MODULE() stuff. Notes: svn path=/head/; revision=344612
2019-02-26Add a module dependency on fdt_slicer.Ian Lepore
Notes: svn path=/head/; revision=344611
2019-02-26Add support for geom_flashmap by providing a getattr() for "SPI:device".Ian Lepore
Notes: svn path=/head/; revision=344606
2019-02-25Fix a paste-o that broke the build on all arches.Ian Lepore
Reported by: many Pointy hat: ian@ Notes: svn path=/head/; revision=344529
2019-02-25Resolve a name conflict when both SpiFlash and DataFlash devices are present.Ian Lepore
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). Notes: svn path=/head/; revision=344526
2019-02-25Add a metadata entry for the AT45DB641E chip. This chip has the same 3-byteIan Lepore
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.) Notes: svn path=/head/; revision=344525
2019-02-25Include the jedec "extended device information string" in the criteria usedIan Lepore
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. Notes: svn path=/head/; revision=344523
2019-02-25Switch to using config_intrhook_oneshot(). That allows the error handlingIan Lepore
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. Notes: svn path=/head/; revision=344507
2019-02-24Add support for probing/attaching on FDT-based systems.Ian Lepore
Notes: svn path=/head/; revision=344506
2019-02-24Add a functional detach() implementation to make module unloading possible.Ian Lepore
Notes: svn path=/head/; revision=344505
2019-02-05Remove All Rights ReservedWarner Losh
Remove the all rights reserved clause from my copyright, and make other minor tweaks needed where that might have created ambiguity. Notes: svn path=/head/; revision=343811
2018-07-29The device ID tables are used only within the driver, make them static soIan Lepore
that both of these drivers can exist in the same kernel. Notes: svn path=/head/; revision=336869
2018-06-14mx25l: compat_data is only defined when FDT isEmmanuel Vadot
Reported by: O. Hartmann <ohartmann@walstatt.org> Notes: svn path=/head/; revision=335170
2018-06-14mx25l: Add pnp infoEmmanuel Vadot
Notes: svn path=/head/; revision=335159
2018-05-17mx25l: Add mx25l1606eEmmanuel Vadot
This is a 16Mbits spi flash arranged in 32x64k blocks or 512x4k sectors. Notes: svn path=/head/; revision=333706
2018-04-23Add driver for Cadence Quad SPI Flash Controller found onRuslan Bukin
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 Notes: svn path=/head/; revision=332885
2018-03-18Add the device/chip type to the disk d_descr field, and print more infoIan Lepore
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. Notes: svn path=/head/; revision=331141
2018-03-18Add support for 4K and 32K erase block sizes. Many of the supported chipsIan Lepore
have these flags set in the ident table, but there was no code to support using the smaller erase sizes. Notes: svn path=/head/; revision=331139
2018-03-18Make all internal routines return an int error status, and check theIan Lepore
status at all call points. Combine the get_status and wait_for_ready routines, since waiting for ready is the only reason to ever get status. Notes: svn path=/head/; revision=331138