aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/smbus
Commit message (Collapse)AuthorAgeFilesLines
* smbus: clean up empty lines in .c and .h filesMateusz Guzik2020-09-013-4/+2
| | | | Notes: svn path=/head/; revision=365153
* sys/dev: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-276-0/+12
| | | | | | | | | | | | | | | 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
* Fix supposed typo in the include guard symbol name, use full path forKonstantin Belousov2017-10-011-3/+3
| | | | | | | | | | the name. Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=324174
* Improve smb(4) devfs interactions.Konstantin Belousov2017-10-011-51/+17
| | | | | | | | | | | | | | | | | | | Use make_dev_s(9) to create device, since the device ioctl interface needs to access si_drv1 to get softc pointer. Remove the common but not functional attempt to prevent parallel accesses by file descriptors by blocking more than one open. Either threads in one process, or forked siblings, or file descriptors passed over unix domain sockets all allow to execute parallel requests once one fd is opened. Since ioctl handler uses smbus_request_bus() to take the bus ownership, the correct mechanism establishes exclusive access already. Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Notes: svn path=/head/; revision=324156
* smb: fix SMB_READB, SMB_READW, SMB_PCALL to work as documentedAndriy Gapon2016-11-112-5/+12
| | | | | | | | | | | | | | | | | | Previously, those ioctls were defined as 'in' only, so rdata.byte and rdata.word were never updated in the userland. The read data went only to rbuf if it was provided. Thus, consumers were forced to always use it. Now the ioctls are marked as in-out. Compatibility handlers are provided for old ioctls. PR: 213481 Reported by: Lewis Donzis <lew@perftech.com> MFC after: 2 weeks Relnotes: maybe Differential Revision: https://reviews.freebsd.org/D8430 Notes: svn path=/head/; revision=308527
* smbus: remove smbus_trans / SMB_TRANSAndriy Gapon2016-11-034-59/+2
| | | | | | | | | | | | | | | | This change reverts most of r281985. The method did not map to anything defined by SMBus protocol and could not be implemented for SMBus controllers. This change is obviously not backwards compatible, but I have good reasons to believe that there have never been any users of SMB_TRANS. Discussed with: grembo, jhb MFC after: 6 weeks Notes: svn path=/head/; revision=308242
* smbus: remove the potentially very dangerous slave probing codeAndriy Gapon2016-11-021-29/+0
| | | | | | | MFC after: 5 weeks Notes: svn path=/head/; revision=308220
* smbus: allow child devices to be added via hintsAndriy Gapon2016-10-122-63/+139
| | | | | | | | | | | | | | | | | | | | | | | | This will allow to add slave drivers in the same fashion as for iicbus. Also, allow other code to add a child device and set its 'addr' ivar. The ivar can only be set if it's unset, it can not be changed. That could be used, for example, by a platform driver that has a precise description of the hardware and, thus, knows what drivers can handle what slaves. The slave auto-probing code is unsafe and broken because it uses 7-bit slave addresses. It's going to be removed. Note: internally the driver uses address of zero as an unset address while smbus_get_addr() returns it as -1 for compatibility reasons. The address is expected to be unset only for children that do not work with slaves like, for example, smb(4). Reviewed by: jhb Differential Revision: https://reviews.freebsd.org/D8173 Notes: svn path=/head/; revision=307130
* Expand SMBUS API to add smbus_trans() function.Michael Gmelin2015-04-256-76/+251
| | | | | | | | | Differential Revision: https://reviews.freebsd.org/D1955 Reviewed by: adrian, jhb, wblock Approved by: adrian, jhb Notes: svn path=/head/; revision=281985
* - There's no need to overwrite the default device method with the defaultMarius Strobl2011-11-221-3/+2
| | | | | | | | | | | | | 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
* Make generic_intr routines match prototype.Warner Losh2009-03-092-2/+2
| | | | Notes: svn path=/head/; revision=189580
* - Change ichsmb(4) to follow the format of all the other smbus controllersJohn Baldwin2009-02-031-0/+4
| | | | | | | | | | | | | | | | for slave addressing by using left-adjusted slave addresses (i.e. xxxxxxx0b). - Require the low bit of the slave address to always be zero in smb(4) to help catch broken applications. - Adjust some code in the IPMI driver to not convert the slave address for SSIF to a right-adjusted address. I (or possibly ambrisko@) added this in the past to (unknowingly) work around the bug in ichsmb(4). Submitted by: Andriy Gapon <avg of icyb.net.ua> (1,2) MFC after: 1 month Notes: svn path=/head/; revision=188077
* - Store the device_t of the smbX device in the softc.John Baldwin2008-06-061-37/+22
| | | | | | | | | | | | | | | | - Store the softc of the device in the 'si_drv1' of the cdev. - Lookup the softc via 'si_drv1' in cdev methods rather than using the minor number as a unit for devclass_get_softc(). - Lookup the device_t via the softc field in cdev methods rather than using the minor number as a unit for devclass_get_device(). - Add a mutex to the softc to protect 'sc_opened'. - Remove D_NEEDGIANT as all the smbus drivers are now MPSAFE and this driver is now MPSAFE. - Remove some checks for NULL softc pointers that can't happen and don't bzero the softc during attach. Notes: svn path=/head/; revision=179625
* Only support the SMB_OLD_BREAD ioctl if one of COMPAT_FREEBSD[456] isJohn Baldwin2006-09-261-0/+6
| | | | | | | defined. Notes: svn path=/head/; revision=162662
* - Revert making bus_generic_add_child() the default for BUS_ADD_CHILD().John Baldwin2006-09-111-0/+1
| | | | | | | | | | | | Instead, we want busses to explicitly specify an add_child routine if they want to support identify routines, but by default disallow having outside drivers add devices. - Give smbus(4) an explicit bus_add_child() method. Requested by: imp Notes: svn path=/head/; revision=162237
* Minor overhaul of SMBus support:John Baldwin2006-09-117-78/+108
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Change smbus_callback() to pass a void * rather than caddr_t. - Change smbus_bread() to pass a pointer to the count and have it be an in/out parameter. The input is the size of the buffer (same as before), but on return it will contain the actual amount of data read back from the bus. Note that this value may be larger than the input value. It is up to the caller to treat this as an error if desired. - Change the SMB_BREAD ioctl to write out the updated struct smbcmd which will contain the actual number of bytes read in the 'count' field. To preserve the previous ABI, the old ioctl value is mapped to SMB_OLD_BREAD which doesn't copy the updated smbcmd back out to userland. I doubt anyone actually used the old BREAD anyway as it was rediculous to do a bulk-read but not tell the using program how much data was actually read. - Make the smbus driver and devclass public in the smbus module and push all the DRIVER_MODULE()'s for attaching the smbus driver to various foosmb drivers out into the foosmb modules. This makes all the foosmb logic centralized and allows new foosmb modules to be self-contained w/o having to hack smbus.c everytime a new smbus driver is added. - Add a new SMB_EINVAL error bit and use it in place of EINVAL to return an error for bad arguments (such as invalid counts for bread and bwrite). - Map SMB bus error bits to EIO in smbus_error(). - Make the smbus driver call bus_generic_probe() and require child drivers such as smb(4) to create device_t's via identify routines. Previously, smbus just created one anonymous device during attach, and if you had multiple drivers that could attach it was just random chance as to which driver got to probe for the sole device_t first. - Add a mutex to the smbus(4) softc and use it in place of dummy splhigh() to protect the 'owner' field and perform necessary synchronization for smbus_request_bus() and smbus_release_bus(). - Change the bread() and bwrite() methods of alpm(4), amdpm(4), and viapm(4) to only perform a single transaction and not try to use a loop of multiple transactions for a large request. The framing and commands to use for a large transaction depend on the upper-layer protocol (such as SSIF for IPMI over SMBus) from what I can tell, and the smb(4) driver never allowed bulk read/writes of more than 32-bytes anyway. The other smb drivers only performed single transactions. - Fix buffer overflows in the bread() methods of ichsmb(4), alpm(4), amdpm(4), amdsmb(4), intpm(4), and nfsmb(4). - Use SMB_xxx errors in viapm(4). - Destroy ichsmb(4)'s mutex after bus_generic_detach() to avoid problems from child devices making smb upcalls that would use the mutex during their detach methods. MFC after: 1 week Reviewed by: jmg (mostly) Notes: svn path=/head/; revision=162234
* Drivers for AMD-8111 and NVIDIA nForce2/3/4 SMBus 2.0 controllers.Ruslan Ermilov2005-12-211-0/+2
| | | | Notes: svn path=/head/; revision=153618
* Create "smb" device when "smbus" device is attached, so that it'sRuslan Ermilov2005-12-202-11/+11
| | | | | | | | possible to load/unload smb.ko and smbus-implementing driver in any order, and get expected results. Notes: svn path=/head/; revision=153569
* Stop creating duplicate "smb" devices when unloading/loading smb.ko,Ruslan Ermilov2005-12-202-24/+4
| | | | | | | using the protection mechanisms described in device_add_child(9). Notes: svn path=/head/; revision=153556
* Remove public declarations of variables that were forgotten when they wereDavid E. O'Brien2005-08-101-2/+0
| | | | | | | made static. Notes: svn path=/head/; revision=148920
* Start each of the license/copyright comments with /*-, minor shuffle of linesWarner Losh2005-01-061-1/+1
| | | | Notes: svn path=/head/; revision=139749
* Do the dreaded s/dev_t/struct cdev */Poul-Henning Kamp2004-06-161-4/+4
| | | | | | | Bump __FreeBSD_version accordingly. Notes: svn path=/head/; revision=130585
* Fix various style(9) bugs. This includes the removal of wrongJoerg Wunsch2004-05-171-38/+21
| | | | | | | | | | | | | | | reimplementations of enodev() (for the smbread() and smbwrite() functions), as well as fixing various errno values to conform to errno(3). Bruce also points out that a number of the pointer == NULL tests are probably nonsense because the respective checks are already done at upper layers. (Mostly) submitted by: bde Notes: svn path=/head/; revision=129352
* You wouldn't believe a driver could survive doing userland IO withoutJoerg Wunsch2004-05-162-12/+49
| | | | | | | | | | | properly using copyin/copyout for more than 5 years? This one did. :-) Properly encapsulate all user<->kernel data transfers using copy{in,out}. MFC after: 1 month Notes: svn path=/head/; revision=129290
* Device megapatch 4/6:Poul-Henning Kamp2004-02-211-0/+2
| | | | | | | | | | | Introduce d_version field in struct cdevsw, this must always be initialized to D_VERSION. Flip sense of D_NOGIANT flag to D_NEEDGIANT, this involves removing four D_NOGIANT flags and adding 145 D_NEEDGIANT flags. Notes: svn path=/head/; revision=126080
* Device megapatch 1/6:Poul-Henning Kamp2004-02-211-2/+0
| | | | | | | | | | Free approx 86 major numbers with a mostly automatically generated patch. A number of strategic drivers have been left behind by caution, and a few because they still (ab)use their major number. Notes: svn path=/head/; revision=126076
* No need for a separate nfpm driver now - amdpm handles both.Doug Rabson2003-09-061-1/+0
| | | | Notes: svn path=/head/; revision=119797
* Use __FBSDID().David E. O'Brien2003-08-242-2/+6
| | | | | | | Also some minor style cleanups. Notes: svn path=/head/; revision=119419
* Don't hardcode unit numer '0'.Bernd Walter2003-08-101-1/+1
| | | | | | | We can have multiple instances. Notes: svn path=/head/; revision=118728
* Gigacommit to improve device-driver source compatibility betweenPoul-Henning Kamp2003-03-031-13/+7
| | | | | | | | | | | | | | | | branches: Initialize struct cdevsw using C99 sparse initializtion and remove all initializations to default values. This patch is automatically generated and has been tested by compiling LINT with all the fields in struct cdevsw in reverse order on alpha, sparc64 and i386. Approved by: re(scottl) Notes: svn path=/head/; revision=111815
* Cleanup of amdpm(4).Nicolas Souchu2002-09-211-0/+1
| | | | | | | | | Add of NVIDIA nForce (nfpm) smbus support. Obtained from: Thomas D. Dean <tomdean@speakeasy.org> Notes: svn path=/head/; revision=103764
* move <machine/iic.h> and <machine/smb.h> to <dev/iicbus/iic.h> andPeter Wemm2002-09-191-2/+1
| | | | | | | <dev/smbus/smb.h> - there is nothing MD about these ioctl definitions. Notes: svn path=/head/; revision=103588
* Major rework of the iicbus/smbus framework:Nicolas Souchu2002-03-234-107/+60
| | | | | | | | | | | - VIA chipset SMBus controllers added - alpm driver updated - Support for dynamic modules added - bktr FreeBSD smbus updated but not tested - cleanup Notes: svn path=/head/; revision=93023
* SMBus support for the AMD 756 power management unit. See smbus(4),Murray Stokely2001-09-161-0/+1
| | | | | | | | | | | | | | amdpm(4) and smb(4). This device can be used with userland programs such as sysutils/lmmon to retrieve sensor information from the motherboard. PR: kern/23989 Obtained from: Matthew C. Forman <mcf@dmu.ac.uk> Based on: alpm(4) Notes: svn path=/head/; revision=83553
* KSE Milestone 2Julian Elischer2001-09-121-3/+3
| | | | | | | | | | | | | | | | | Note ALL MODULES MUST BE RECOMPILED make the kernel aware that there are smaller units of scheduling than the process. (but only allow one thread per process at this time). This is functionally equivalent to teh previousl -current except that there is a thread associated with each process. Sorry john! (your next MFC will be a doosie!) Reviewed by: peter@freebsd.org, dillon@freebsd.org X-MFC after: ha ha ha ha Notes: svn path=/head/; revision=83366
* Send the remains (such as I have located) of "block major numbers" toPoul-Henning Kamp2001-03-261-1/+0
| | | | | | | the bit-bucket. Notes: svn path=/head/; revision=74810
* Remove unneeded #include <machine/clock.h>Poul-Henning Kamp2000-10-151-1/+0
| | | | Notes: svn path=/head/; revision=67164
* Driver for the Intel 82801AA (ICH) SMBus controller and compatibles.Archie Cobbs2000-10-061-0/+1
| | | | | | | Obtained from: Whistle source tree Notes: svn path=/head/; revision=66703
* Remove unneeded #include <sys/kernel.h>Poul-Henning Kamp2000-04-291-1/+0
| | | | Notes: svn path=/head/; revision=59760
* Remove ~25 unneeded #include <sys/conf.h>Poul-Henning Kamp2000-04-192-2/+0
| | | | | | | Remove ~60 unneeded #include <sys/malloc.h> Notes: svn path=/head/; revision=59391
* Remove unneeded <sys/buf.h> includes.Poul-Henning Kamp2000-04-181-1/+0
| | | | | | | | Due to some interesting cpp tricks in lockmgr, the LINT kernel shrinks by 924 bytes. Notes: svn path=/head/; revision=59368
* * Factor out the object system from new-bus so that it can be used byDoug Rabson2000-04-081-0/+2
| | | | | | | | | | | | | non-device code. * Re-implement the method dispatch to improve efficiency. The new system takes about 40ns for a method dispatch on a 300Mhz PII which is only 10ns slower than a direct function call on the same hardware. This changes the new-bus ABI slightly so make sure you re-compile any driver modules which you use. Notes: svn path=/head/; revision=59093
* Remove the 'ivars' arguement to device_add_child() andMatthew N. Dodd1999-12-032-3/+3
| | | | | | | | | | | | | | | | | | | device_add_child_ordered(). 'ivars' may now be set using the device_set_ivars() function. This makes it easier for us to change how arbitrary data structures are associated with a device_t. Eventually we won't be modifying device_t to add additional pointers for ivars, softc data etc. Despite my best efforts I've probably forgotten something so let me know if this breaks anything. I've been running with this change for months and its been quite involved actually isolating all the changes from the rest of the local changes in my tree. Reviewed by: peter, dfr Notes: svn path=/head/; revision=54073
* Convert smb to use make_dev() rather than cdevsw_add(). This stops thePeter Wemm1999-11-181-1/+3
| | | | | | | | annoying 'smb is usurping smb's cdevsw' type messages. (Yes, there are other ways to fix cdevsw_add(), but that is a doomed api) Notes: svn path=/head/; revision=53330
* Use (temporarily) cdevsw_add() so we can change from DEV_DRIVER_MODULE()Peter Wemm1999-11-081-1/+2
| | | | | | | to DRIVER_MODULE(). Notes: svn path=/head/; revision=52999
* Sync with RELENG_3.Nicolas Souchu1999-11-012-4/+8
| | | | Notes: svn path=/head/; revision=52776
* Remove five now unused fields from struct cdevsw. They should neverPoul-Henning Kamp1999-09-251-5/+0
| | | | | | | | | | | have been there in the first place. A GENERIC kernel shrinks almost 1k. Add a slightly different safetybelt under nostop for tty drivers. Add some missing FreeBSD tags Notes: svn path=/head/; revision=51658
* $Id$ -> $FreeBSD$Peter Wemm1999-08-287-7/+7
| | | | Notes: svn path=/head/; revision=50477
* Alter the behavior of sys/kern/subr_bus.c:device_print_child()Matthew N. Dodd1999-07-291-12/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - device_print_child() either lets the BUS_PRINT_CHILD method produce the entire device announcement message or it prints "foo0: not found\n" Alter sys/kern/subr_bus.c:bus_generic_print_child() to take on the previous behavior of device_print_child() (printing the "foo0: <FooDevice 1.1>" bit of the announce message.) Provide bus_print_child_header() and bus_print_child_footer() to actually print the output for bus_generic_print_child(). These functions should be used whenever possible (unless you can just use bus_generic_print_child()) The BUS_PRINT_CHILD method now returns int instead of void. Modify everything else that defines or uses a BUS_PRINT_CHILD method to comply with the above changes. - Devices are 'on' a bus, not 'at' it. - If a custom BUS_PRINT_CHILD method does the same thing as bus_generic_print_child(), use bus_generic_print_child() - Use device_get_nameunit() instead of both device_get_name() and device_get_unit() - All BUS_PRINT_CHILD methods return the number of characters output. Reviewed by: dfr, peter Notes: svn path=/head/; revision=49195
* Don't clobber the smb cdevsw entry that was installed by the driverPeter Wemm1999-07-061-5/+1
| | | | | | | framework. Notes: svn path=/head/; revision=48637