summaryrefslogtreecommitdiff
path: root/sys/dev/spibus
Commit message (Collapse)AuthorAgeFilesLines
* Add IRQ resource to SPIBUSEmmanuel Vadot2020-12-173-0/+44
| | | | | | | | | | | | | | Add capability to SPIBUS to have child device with IRQ. For example many ADC chip have a dedicated pin to signal "data ready" and the host can just wait for a interrupt to go out and read the result. It is the same code as in R282674 and R282702 for IICBUS by Michal Meloun Submitted by: Oskar Holmund <oskar.holmlund@ohdata.se> Differential Revision: https://reviews.freebsd.org/D27396 Notes: svn path=/head/; revision=368725
* spibus: clean up empty lines in .c and .h filesMateusz Guzik2020-09-012-4/+2
| | | | Notes: svn path=/head/; revision=365151
* Consistently use busy and vm_page_valid() rather than touching page bitsJeff Roberson2020-01-231-2/+3
| | | | | | | | | | directly. This improves API compliance, asserts, etc. Reviewed by: kib, markj Differential Revision: https://reviews.freebsd.org/D23283 Notes: svn path=/head/; revision=357017
* Regularize my copyright noticeWarner Losh2019-12-044-8/+4
| | | | | | | | | | | | 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
* Use the new FDTCOMPAT_PNP_INFO() macro to define SPIBUS_FDT_PNP_INFO().Ian Lepore2019-05-231-3/+5
| | | | | | | | 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
* Set maximum bus clock speed from hints when attaching hinted spibus(4) children.Ian Lepore2019-02-251-0/+1
| | | | | | | | Some devices (such as spigen(4)) document that this works, but it appears that the code to implement it never got added. Notes: svn path=/head/; revision=344556
* Reapply, with minor tweaks, r338025, from the original commit:Warner Losh2018-09-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove unused and easy to misuse PNP macro parameter Inspired by r338025, just remove the element size parameter to the MODULE_PNP_INFO macro entirely. The 'table' parameter is now required to have correct pointer (or array) type. Since all invocations of the macro already had this property and the emitted PNP data continues to include the element size, there is no functional change. Mostly done with the coccinelle 'spatch' tool: $ cat modpnpsize0.cocci @normaltables@ identifier b,c; expression a,d,e; declarer MODULE_PNP_INFO; @@ MODULE_PNP_INFO(a,b,c,d, -sizeof(d[0]), e); @singletons@ identifier b,c,d; expression a; declarer MODULE_PNP_INFO; @@ MODULE_PNP_INFO(a,b,c,&d, -sizeof(d), 1); $ rg -l MODULE_PNP_INFO -- sys | \ xargs spatch --in-place --sp-file modpnpsize0.cocci (Note that coccinelle invokes diff(1) via a PATH search and expects diff to tolerate the -B flag, which BSD diff does not. So I had to link gdiff into PATH as diff to use spatch.) Tinderbox'd (-DMAKE_JUST_KERNELS). Approved by: re (glen) Notes: svn path=/head/; revision=338948
* Back out r338035 until Warner is finished churning GSoC PNP patchesConrad Meyer2018-08-191-1/+1
| | | | | | | | | | I was not aware Warner was making or planning to make forward progress in this area and have since been informed of that. It's easy to apply/reapply when churn dies down. Notes: svn path=/head/; revision=338037
* Remove unused and easy to misuse PNP macro parameterConrad Meyer2018-08-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Inspired by r338025, just remove the element size parameter to the MODULE_PNP_INFO macro entirely. The 'table' parameter is now required to have correct pointer (or array) type. Since all invocations of the macro already had this property and the emitted PNP data continues to include the element size, there is no functional change. Mostly done with the coccinelle 'spatch' tool: $ cat modpnpsize0.cocci @normaltables@ identifier b,c; expression a,d,e; declarer MODULE_PNP_INFO; @@ MODULE_PNP_INFO(a,b,c,d, -sizeof(d[0]), e); @singletons@ identifier b,c,d; expression a; declarer MODULE_PNP_INFO; @@ MODULE_PNP_INFO(a,b,c,&d, -sizeof(d), 1); $ rg -l MODULE_PNP_INFO -- sys | \ xargs spatch --in-place --sp-file modpnpsize0.cocci (Note that coccinelle invokes diff(1) via a PATH search and expects diff to tolerate the -B flag, which BSD diff does not. So I had to link gdiff into PATH as diff to use spatch.) Tinderbox'd (-DMAKE_JUST_KERNELS). Notes: svn path=/head/; revision=338035
* Enhancements and fixes for the spigen(4) driver...Ian Lepore2018-07-111-168/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | | - Resources used by spigen_mmap_single() are now tracked using devfs_set_cdevpriv() rather than in the softc. - Since resources are now tracked per-open-fd, there is no need to try to impose any exclusive-open logic, so flags related to that are removed. - Flags used to track open status to prevent detach() when the device is open are replaced with calls to device_busy()/device_unbusy(). That extends the protection up the hierarchy so that the spibus and hardware controller drivers also can't be detached while the device is open/in use. - Arbitrary limits on the maximum size of a transfer are removed, along with the sysctl variables that allowed the limits to be changed. There is just no reason to limit the size of a spi transfer to the machine's page size. Or to any other arbitrary value, really. - Most of the locking is removed. It was mostly protecting access to flags and fields in the softc that no longer exist. The locking that remains is just to prevent concurrent calls to device_[un]busy(). - The code was calling malloc() with M_WAITOK while holding a mutex in several places. Since most of the locking is gone, that's fixed. Notes: svn path=/head/; revision=336202
* Incorporate bus and chip select numbers into spigen(4) cdev names. RatherIan Lepore2018-06-212-6/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | than assigning spigen device names in order of creation, this uses a device name that corresponds to the owning spibus and chip-select index. Example: /dev/spigen0.1 would be a child of spibus0, and use cs = 1 The intent is for systems like Raspberry Pi to have a consistent way of using an SPI interface with a specific cs value from a user application. Otherwise, there is no consistent way of knowing which cs pin will be assigned to a particular spigen device. The alternative is to specify everything in "the right order" in an overlay file, which is less than ideal. Additionally, this duplicates (to some extent) the way Linux handles a similar situation with their 'spidev' device, so it would be somewhat familiar to those who also use Linux. A new kernel config option, SPIGEN_LEGACY_CDEVNAME, causes the driver to also create /dev/spigenN device name aliases, with N incrementing in the order of device instantiation. This is provided to ease the transition for existing systems using the original naming convention (particularly when these changes are MFC'd to stable branches). Differential Revision: https://reviews.freebsd.org/D15301 Notes: svn path=/head/; revision=335506
* spi: Add SPIBUS_PNP_INFO macroEmmanuel Vadot2018-06-141-0/+4
| | | | | | | | The PNP info string is the same as the SIMPLEBUS one but driver should depend on spibus and not simplebus Notes: svn path=/head/; revision=335158
* Allow hinted attachment on FDT-based systems. Instead of returning ENXIOIan Lepore2018-04-081-8/+11
| | | | | | | | when the FDT data doesn't enable the device instance, return BUS_PROBE_NOWILDCARD, the same as for non-FDT systems. Notes: svn path=/head/; revision=332292
* Cast the data pointer to the correct type for the data being accessed (asIan Lepore2018-04-071-2/+2
| | | | | | | | | | | opposed to one that accidentally worked on the one arch I test-compiled for on my first try). Reported by: np@, O. Hartmann <ohartmann@walstatt.org> Pointy hat: ian@ Notes: svn path=/head/; revision=332259
* Don't check for impossible NULL return from malloc(..., M_WAITOK).Ian Lepore2018-04-071-6/+0
| | | | Notes: svn path=/head/; revision=332258
* Add an ioctl to get/set the SPI transfer mode. Also, make the bus clockIan Lepore2018-04-071-12/+11
| | | | | | | | | frequency ioctl actually set the corresponding ivar instead of just storing the value locally in the softc (and then not using it for anything). Also, return the correct error code if the ioctl cmd is not recognized. Notes: svn path=/head/; revision=332233
* Generate a spibus_set_[ivarname]() convenience function for each ivar,Ian Lepore2018-04-071-1/+7
| | | | | | | now that they can be set. Notes: svn path=/head/; revision=332231
* Remove the existing identify() hack to force-add a spigen device onIan Lepore2018-04-071-15/+16
| | | | | | | | | | FDT-based systems, and instead add proper FDT probe code. Because this driver is freebsd-specific and just provides generic userland access to run spibus transactions, there is no bindings document to mandate a compatible string, so just arbitrarily use "freebsd,spigen". Notes: svn path=/head/; revision=332219
* Return BUS_PROBE_DEFAULT, not zero, because this is not the one driverIan Lepore2018-04-071-1/+5
| | | | | | | | | | implementation that must be used, it's just the base system default driver. Also add a comment noting that we're being more liberal about the bus frequency property than the dts binding documents require. Notes: svn path=/head/; revision=332196
* A couple minor improvements to spibus.c...Ian Lepore2018-04-071-9/+5
| | | | | | | | | | | | | - Change the description string to "SPI bus" (was "spibus bus"). - This is the default driver for a SPI bus, not a generic implementation, so return the probe value that indicates such. - Use device_delete_children() at detach time, instead of a local loop to enumerate the children and detach each one individually. Notes: svn path=/head/; revision=332195
* Add support for writing/changing spi device ivars. The SPI mode (polarityIan Lepore2018-04-071-0/+32
| | | | | | | | | | and phase) and the maximum bus speed can be changed. The chip select number cannot be changed, because the device instances which are children of spibus are inherently associated with the chip select number they were instantiated for. Notes: svn path=/head/; revision=332194
* Add a missing MODULE_DEPEND().Ian Lepore2018-04-041-0/+1
| | | | Notes: svn path=/head/; revision=332046
* Provide public declarations for ofw_spibus_driver and ofw_spibus_devclassIan Lepore2018-02-182-2/+4
| | | | | | | so other drivers can refer to them in DRIVER_MODULE() decls. Notes: svn path=/head/; revision=329539
* SPDX: fix wrong license ID tag in dev/spibus.Pedro F. Giffuni2017-12-281-1/+1
| | | | Notes: svn path=/head/; revision=327260
* sys/dev: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-271-0/+2
| | | | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=326255
* [spigen] make spigen device ready to be compiled as a moduleOleksandr Tymoshenko2017-03-091-8/+41
| | | | | | | | | | - Add flag to indicate that device is opened by userland - Replace "always fail" detach method with proper detach implementation MFC after: 1 week Notes: svn path=/head/; revision=314933
* [spibus] small code refactoringMichael Zhilin2017-01-161-3/+2
| | | | | | | | | | | | Merge 3 sequential printf calls into one. Reported by: rpokala Reviewed by: rpokala, adrian Approved by: adrian (mentor) Differential Revision: https://reviews.freebsd.org/D8795 Notes: svn path=/head/; revision=312289
* [spigen] Fix spigen attaching as a driver for SPI devices nodes in FDTOleksandr Tymoshenko2016-12-241-1/+3
| | | | | | | | | | | | | | | Return BUS_PROBE_NOWILDCARD in probe method to make sure that spigen attaches only to the device created in identify method. Before this change spigen probe method used to return 0 which meant it competed with other drivers to be attached to the devices created for child nodes of SPI bus node in FDT. Reported by: Daniel Braniss MFC after: 1 week Notes: svn path=/head/; revision=310492
* ofw_spi: Parse property for the SPI mode and CS polarity.Emmanuel Vadot2016-12-182-0/+22
| | | | | | | | | | | | As cs is stored in a uint32_t, use the last bit to store the active high flag as it's unlikely that we will have that much CS. Reviewed by: loos MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D8614 Notes: svn path=/head/; revision=310229
* [spigen] Make "data" part of spigen_transfer optionalOleksandr Tymoshenko2016-12-161-8/+12
| | | | | | | | | | Make st_data part of spigen_transfer optional by letting pass zero length and NULL pointer. SPI controller drivers handle this case fine. MFC after: 1 week Notes: svn path=/head/; revision=310170
* [spi] reformat message and ar5315_spi minor fixMichael Zhilin2016-12-131-2/+2
| | | | | | | | | | | | | | This commit corrects print of nomatch (newline was too early) and fix unit number for new child in ar5315_spi (was 0, now is -1 to calculate it according to actual system state) Submitted by: Hiroki Mori <yamori813@yahoo.co.jp> Reviewed by: ray, loos, mizhka MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D8749 Notes: svn path=/head/; revision=310017
* Enable the use of spigen on FDT platformEmmanuel Vadot2016-11-201-0/+16
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=308895
* [spigen] add initial spigen driver from green@Adrian Chadd2016-05-262-0/+405
| | | | | | | | | | | | | | | This is a simple ioctl and mmap API to issue SPI transactions from userland. It's useful for simple devices (eg spi temperature sensors, etc) for experimentation. TODO: * Write some documentation! Submitted by: green Notes: svn path=/head/; revision=300713
* [spibus] implement maximum clock frequency lookup from ofw.Adrian Chadd2016-05-261-1/+10
| | | | | | | Obtained from: loos Notes: svn path=/head/; revision=300712
* [spibus] add missing break.Adrian Chadd2016-05-261-0/+1
| | | | | | | Pointy hat to: me Notes: svn path=/head/; revision=300711
* [spibus] add initial placeholders for transfer mode and frequency.Adrian Chadd2016-05-262-1/+21
| | | | | | | | | | This doesn't yet implement it in the controllers or the transfer calls, but it's a start. Obtained from: loos (frequency), ray/zrouter (transfer mode) Notes: svn path=/head/; revision=300710
* Fix the parameter type according to method declaration.Ruslan Bukin2016-04-261-1/+1
| | | | | | | This fixes compilation on riscv with GCC 5.2.0 Notes: svn path=/head/; revision=298651
* Revert r298268 (Add optional chip_select/deselect methods).Ruslan Bukin2016-04-192-33/+0
| | | | | | | None of supported hardware do require that. Notes: svn path=/head/; revision=298274
* Add optional chip_select/deselect methods. This is requiredRuslan Bukin2016-04-192-0/+33
| | | | | | | when we want to keep CS asserted for multiple transfers. Notes: svn path=/head/; revision=298268
* Add copyright statement I should have had on these files in 2006,Warner Losh2015-02-183-2/+81
| | | | | | | based on the spibus_if.m file. Notes: svn path=/head/; revision=278957
* Add an OFW SPI compatible bus. Fix the spibus probe to returnLuiz Otavio O Souza2013-10-243-2/+197
| | | | | | | | | | | | BUS_PROBE_GENERIC and not BUS_PROBE_SPECIFIC (0) so the OFW SPI bus can attach when enabled. Export the spibus devclass_t and driver_t declarations. Submitted by: ray Approved by: adrian (mentor) Notes: svn path=/head/; revision=257064
* Fetch the chip select in the bridge driver, like all the other spiWarner Losh2012-08-232-4/+0
| | | | | | | bridges do. Notes: svn path=/head/; revision=239626
* Add the chip select glue.Warner Losh2012-08-012-0/+6
| | | | Notes: svn path=/head/; revision=238965
* Replace `inline static' by `static inline'.Ed Schouten2011-12-131-1/+1
| | | | | | | | | If I interpret the C standard correctly, the storage specifier should be placed before the inline keyword. While at it, replace __inline by inline in the files affected. Notes: svn path=/head/; revision=228471
* - There's no need to overwrite the default device method with the defaultMarius Strobl2011-11-221-2/+1
| | | | | | | | | | | | | one. Interestingly, these are actually the default for quite some time (bus_generic_driver_added(9) since r52045 and bus_generic_print_child(9) since r52045) but even recently added device drivers do this unnecessarily. Discussed with: jhb, marcel - While at it, use DEVMETHOD_END. Discussed with: jhb - Also while at it, use __FBSDID. Notes: svn path=/head/; revision=227843
* bus_add_child: change type of order parameter to u_intAndriy Gapon2010-09-101-1/+1
| | | | | | | | | | | | | This reflects actual type used to store and compare child device orders. Change is mostly done via a Coccinelle (soon to be devel/coccinelle) semantic patch. Verified by LINT+modules kernel builds. Followup to: r212213 MFC after: 10 days Notes: svn path=/head/; revision=212413
* strict kobj signatures: fix assortment of bus_read_ivar implsAndriy Gapon2009-06-111-1/+1
| | | | | | | | Reviewed by: imp, current@ Approved by: jhb (mentor) Notes: svn path=/head/; revision=194020
* - Make SPI bus bridge be non-arch dependent by using more genericOleksandr Tymoshenko2009-05-131-1/+1
| | | | | | | | | name Reviewed by: imp Notes: svn path=/head/; revision=192059
* MFp4: when passing the transfer up the foodchain, make sure we go upWarner Losh2006-10-201-2/+4
| | | | | | | the food chain. devi == NULL is the error condition. Treat it as such. Notes: svn path=/head/; revision=163527
* Fix comments.Olivier Houchard2006-07-172-2/+2
| | | | Notes: svn path=/head/; revision=160452