2009-06-02 11:01:37 +00:00
|
|
|
rfkill - RF kill switch support
|
|
|
|
===============================
|
2007-09-13 07:22:55 +00:00
|
|
|
|
2009-06-02 11:01:37 +00:00
|
|
|
1. Introduction
|
|
|
|
2. Implementation details
|
|
|
|
3. Kernel driver guidelines
|
|
|
|
4. Kernel API
|
|
|
|
5. Userspace support
|
2007-09-13 07:22:55 +00:00
|
|
|
|
2008-06-23 20:23:08 +00:00
|
|
|
|
2009-06-02 11:01:37 +00:00
|
|
|
1. Introduction
|
2007-09-13 07:22:55 +00:00
|
|
|
|
2009-06-02 11:01:37 +00:00
|
|
|
The rfkill subsystem provides a generic interface to disabling any radio
|
|
|
|
transmitter in the system. When a transmitter is blocked, it shall not
|
|
|
|
radiate any power.
|
2008-06-23 20:22:56 +00:00
|
|
|
|
2009-06-02 11:01:37 +00:00
|
|
|
The subsystem also provides the ability to react on button presses and
|
|
|
|
disable all transmitters of a certain type (or all). This is intended for
|
|
|
|
situations where transmitters need to be turned off, for example on
|
|
|
|
aircraft.
|
2008-06-23 20:46:43 +00:00
|
|
|
|
2008-06-23 20:22:56 +00:00
|
|
|
|
2007-09-13 07:22:55 +00:00
|
|
|
|
2009-06-02 11:01:37 +00:00
|
|
|
2. Implementation details
|
2008-06-23 20:23:08 +00:00
|
|
|
|
2008-06-23 20:46:43 +00:00
|
|
|
The rfkill subsystem is composed of various components: the rfkill class, the
|
|
|
|
rfkill-input module (an input layer handler), and some specific input layer
|
|
|
|
events.
|
|
|
|
|
2009-06-02 11:01:37 +00:00
|
|
|
The rfkill class is provided for kernel drivers to register their radio
|
|
|
|
transmitter with the kernel, provide methods for turning it on and off and,
|
|
|
|
optionally, letting the system know about hardware-disabled states that may
|
|
|
|
be implemented on the device. This code is enabled with the CONFIG_RFKILL
|
|
|
|
Kconfig option, which drivers can "select".
|
2008-06-23 20:46:43 +00:00
|
|
|
|
2009-06-02 11:01:37 +00:00
|
|
|
The rfkill class code also notifies userspace of state changes, this is
|
|
|
|
achieved via uevents. It also provides some sysfs files for userspace to
|
|
|
|
check the status of radio transmitters. See the "Userspace support" section
|
|
|
|
below.
|
2008-08-26 14:58:01 +00:00
|
|
|
|
|
|
|
|
2009-06-02 11:01:37 +00:00
|
|
|
The rfkill-input code implements a basic response to rfkill buttons -- it
|
|
|
|
implements turning on/off all devices of a certain class (or all).
|
2008-08-26 14:58:01 +00:00
|
|
|
|
2009-06-02 11:01:37 +00:00
|
|
|
When the device is hard-blocked (either by a call to rfkill_set_hw_state()
|
|
|
|
or from query_hw_block) set_block() will be invoked but drivers can well
|
|
|
|
ignore the method call since they can use the return value of the function
|
|
|
|
rfkill_set_hw_state() to sync the software state instead of keeping track
|
|
|
|
of calls to set_block().
|
2008-08-26 14:58:01 +00:00
|
|
|
|
|
|
|
|
2009-06-02 11:01:37 +00:00
|
|
|
The entire functionality is spread over more than one subsystem:
|
2008-08-26 14:58:01 +00:00
|
|
|
|
2009-06-02 11:01:37 +00:00
|
|
|
* The kernel input layer generates KEY_WWAN, KEY_WLAN etc. and
|
|
|
|
SW_RFKILL_ALL -- when the user presses a button. Drivers for radio
|
|
|
|
transmitters generally do not register to the input layer, unless the
|
|
|
|
device really provides an input device (i.e. a button that has no
|
|
|
|
effect other than generating a button press event)
|
2008-08-26 14:58:01 +00:00
|
|
|
|
2009-06-02 11:01:37 +00:00
|
|
|
* The rfkill-input code hooks up to these events and switches the soft-block
|
|
|
|
of the various radio transmitters, depending on the button type.
|
2008-08-02 17:56:25 +00:00
|
|
|
|
2009-06-02 11:01:37 +00:00
|
|
|
* The rfkill drivers turn off/on their transmitters as requested.
|
2008-06-23 20:46:43 +00:00
|
|
|
|
2009-06-02 11:01:37 +00:00
|
|
|
* The rfkill class will generate userspace notifications (uevents) to tell
|
|
|
|
userspace what the current state is.
|
2008-06-23 20:46:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2009-06-02 11:01:37 +00:00
|
|
|
3. Kernel driver guidelines
|
2008-06-23 20:46:43 +00:00
|
|
|
|
|
|
|
|
2009-06-02 11:01:37 +00:00
|
|
|
Drivers for radio transmitters normally implement only the rfkill class.
|
|
|
|
These drivers may not unblock the transmitter based on own decisions, they
|
|
|
|
should act on information provided by the rfkill class only.
|
2008-06-23 20:46:43 +00:00
|
|
|
|
2009-06-02 11:01:37 +00:00
|
|
|
Platform drivers might implement input devices if the rfkill button is just
|
|
|
|
that, a button. If that button influences the hardware then you need to
|
|
|
|
implement an rfkill class instead. This also applies if the platform provides
|
|
|
|
a way to turn on/off the transmitter(s).
|
2008-06-23 20:46:43 +00:00
|
|
|
|
2009-06-02 11:01:37 +00:00
|
|
|
During suspend/hibernation, transmitters should only be left enabled when
|
|
|
|
wake-on wlan or similar functionality requires it and the device wasn't
|
|
|
|
blocked before suspend/hibernate. Note that it may be necessary to update
|
|
|
|
the rfkill subsystem's idea of what the current state is at resume time if
|
|
|
|
the state may have changed over suspend.
|
2008-06-23 20:46:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2009-06-02 11:01:37 +00:00
|
|
|
4. Kernel API
|
2008-06-23 20:23:08 +00:00
|
|
|
|
|
|
|
To build a driver with rfkill subsystem support, the driver should depend on
|
2009-06-02 11:01:37 +00:00
|
|
|
(or select) the Kconfig symbol RFKILL.
|
2008-06-23 20:23:08 +00:00
|
|
|
|
|
|
|
The hardware the driver talks to may be write-only (where the current state
|
|
|
|
of the hardware is unknown), or read-write (where the hardware can be queried
|
|
|
|
about its current state).
|
|
|
|
|
2009-06-02 11:01:37 +00:00
|
|
|
Calling rfkill_set_hw_state() when a state change happens is required from
|
|
|
|
rfkill drivers that control devices that can be hard-blocked unless they also
|
|
|
|
assign the poll_hw_block() callback (then the rfkill core will poll the
|
|
|
|
device). Don't do this unless you cannot get the event in any other way.
|
2007-09-13 07:22:55 +00:00
|
|
|
|
2008-06-23 20:46:42 +00:00
|
|
|
|
|
|
|
|
2009-06-02 11:01:37 +00:00
|
|
|
5. Userspace support
|
2007-09-13 07:22:55 +00:00
|
|
|
|
2009-06-02 11:01:37 +00:00
|
|
|
The following sysfs entries exist for every rfkill device:
|
2007-09-13 07:22:55 +00:00
|
|
|
|
|
|
|
name: Name assigned by driver to this key (interface or driver name).
|
|
|
|
type: Name of the key type ("wlan", "bluetooth", etc).
|
2008-06-23 20:46:42 +00:00
|
|
|
state: Current state of the transmitter
|
|
|
|
0: RFKILL_STATE_SOFT_BLOCKED
|
2009-06-02 11:01:37 +00:00
|
|
|
transmitter is turned off by software
|
2008-06-23 20:46:42 +00:00
|
|
|
1: RFKILL_STATE_UNBLOCKED
|
2009-06-03 08:17:59 +00:00
|
|
|
transmitter is (potentially) active
|
2008-06-23 20:46:42 +00:00
|
|
|
2: RFKILL_STATE_HARD_BLOCKED
|
|
|
|
transmitter is forced off by something outside of
|
2009-06-02 11:01:37 +00:00
|
|
|
the driver's control.
|
|
|
|
claim: 0: Kernel handles events (currently always reads that value)
|
|
|
|
|
|
|
|
rfkill devices also issue uevents (with an action of "change"), with the
|
|
|
|
following environment variables set:
|
|
|
|
|
|
|
|
RFKILL_NAME
|
|
|
|
RFKILL_STATE
|
|
|
|
RFKILL_TYPE
|
|
|
|
|
|
|
|
The contents of these variables corresponds to the "name", "state" and
|
|
|
|
"type" sysfs files explained above.
|
2009-06-03 08:17:59 +00:00
|
|
|
|
|
|
|
An alternative userspace interface exists as a misc device /dev/rfkill,
|
|
|
|
which allows userspace to obtain and set the state of rfkill devices and
|
|
|
|
sets of devices. It also notifies userspace about device addition and
|
|
|
|
removal. The API is a simple read/write API that is defined in
|
|
|
|
linux/rfkill.h.
|