Commit Graph

13 Commits

Author SHA1 Message Date
Pedro F. Giffuni
718cf2ccb9 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.
2017-11-27 14:52:40 +00:00
Konstantin Belousov
48a225d412 Fix supposed typo in the include guard symbol name, use full path for
the name.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2017-10-01 19:03:21 +00:00
Andriy Gapon
19a8946bce smbus: remove smbus_trans / SMB_TRANS
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
2016-11-03 07:40:52 +00:00
Andriy Gapon
94dce59911 smbus: allow child devices to be added via hints
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
2016-10-12 06:58:01 +00:00
Michael Gmelin
202379af84 Expand SMBUS API to add smbus_trans() function.
Differential Revision:	https://reviews.freebsd.org/D1955
Reviewed by:	adrian, jhb, wblock
Approved by:	adrian, jhb
2015-04-25 16:15:01 +00:00
John Baldwin
7048a99c30 Minor overhaul of SMBus support:
- 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)
2006-09-11 20:52:41 +00:00
Nicolas Souchu
c17d43407f Major rework of the iicbus/smbus framework:
- VIA chipset SMBus controllers added
	- alpm driver updated
	- Support for dynamic modules added
	- bktr FreeBSD smbus updated but not tested
	- cleanup
2002-03-23 15:49:15 +00:00
Peter Wemm
c3aac50f28 $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
Nicolas Souchu
4012f363f2 Return approriate errors to userland. 1999-02-14 14:36:45 +00:00
Nicolas Souchu
ba81c311c1 Fix smbus allocation and add the alsmb (see alpm(4)) driver. 1999-02-13 17:57:19 +00:00
Matthew Dillon
d7bcbf6358 Add parens to SMBPRI, fixing bug in tsleep() call that OR's SMBPRI with
something else.
1999-01-27 19:58:53 +00:00
Nicolas Souchu
3ab1f0562c New callback mechanism to allow iicbus bus allocation when requesting
smbus over iicsmb(4).
1998-10-31 11:39:54 +00:00
Nicolas Souchu
d70424edcb Submitted by: nsouch
System Management Bus generic support over new bus architecture.
1998-09-03 20:52:54 +00:00