Staging tree patches for 3.6-rc1
Here's the big staging tree merge for the 3.6-rc1 merge window. There are some patches in here outside of drivers/staging/, notibly the iio code (which is still stradeling the staging / not staging boundry), the pstore code, and the tracing code. All of these have gotten ackes from the various subsystem maintainers to be included in this tree. The pstore and tracing patches are related, and are coming here as they replace one of the android staging drivers. Otherwise, the normal staging mess. Lots of cleanups and a few new drivers (some iio drivers, and the large csr wireless driver abomination.) Note, you will get a merge issue with the following files: drivers/staging/comedi/drivers/s626.h drivers/staging/gdm72xx/netlink_k.c both of which should be trivial for you to handle. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.18 (GNU/Linux) iEYEABECAAYFAlAQiD8ACgkQMUfUDdst+ykxhgCeMUjvc+1RTtSprzvkzpejgoUU 6A4AnAleWMnkaCD8vruGnRdGl/Qtz51+ =mN6M -----END PGP SIGNATURE----- Merge tag 'staging-3.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging Pull staging tree patches from Greg Kroah-Hartman: "Here's the big staging tree merge for the 3.6-rc1 merge window. There are some patches in here outside of drivers/staging/, notibly the iio code (which is still stradeling the staging / not staging boundry), the pstore code, and the tracing code. All of these have gotten acks from the various subsystem maintainers to be included in this tree. The pstore and tracing patches are related, and are coming here as they replace one of the android staging drivers. Otherwise, the normal staging mess. Lots of cleanups and a few new drivers (some iio drivers, and the large csr wireless driver abomination.) Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>" Fixed up trivial conflicts in drivers/staging/comedi/drivers/s626.h and drivers/staging/gdm72xx/netlink_k.c * tag 'staging-3.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (1108 commits) staging: csr: delete a bunch of unused library functions staging: csr: remove csr_utf16.c staging: csr: remove csr_pmem.h staging: csr: remove CsrPmemAlloc staging: csr: remove CsrPmemFree() staging: csr: remove CsrMemAllocDma() staging: csr: remove CsrMemCalloc() staging: csr: remove CsrMemAlloc() staging: csr: remove CsrMemFree() and CsrMemFreeDma() staging: csr: remove csr_util.h staging: csr: remove CsrOffSetOf() stating: csr: remove unneeded #includes in csr_util.c staging: csr: make CsrUInt16ToHex static staging: csr: remove CsrMemCpy() staging: csr: remove CsrStrLen() staging: csr: remove CsrVsnprintf() staging: csr: remove CsrStrDup staging: csr: remove CsrStrChr() staging: csr: remove CsrStrNCmp staging: csr: remove CsrStrCmp ...
This commit is contained in:
commit
b13bc8dda8
660 changed files with 122330 additions and 26548 deletions
|
@ -40,9 +40,9 @@ Contact: linux-iio@vger.kernel.org
|
|||
Description:
|
||||
Some devices have internal clocks. This parameter sets the
|
||||
resulting sampling frequency. In many devices this
|
||||
parameter has an effect on input filters etc rather than
|
||||
parameter has an effect on input filters etc. rather than
|
||||
simply controlling when the input is sampled. As this
|
||||
effects datardy triggers, hardware buffers and the sysfs
|
||||
effects data ready triggers, hardware buffers and the sysfs
|
||||
direct access interfaces, it may be found in any of the
|
||||
relevant directories. If it effects all of the above
|
||||
then it is to be found in the base device directory.
|
||||
|
@ -74,7 +74,7 @@ What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_supply_raw
|
|||
KernelVersion: 2.6.35
|
||||
Contact: linux-iio@vger.kernel.org
|
||||
Description:
|
||||
Raw (unscaled no bias removal etc) voltage measurement from
|
||||
Raw (unscaled no bias removal etc.) voltage measurement from
|
||||
channel Y. In special cases where the channel does not
|
||||
correspond to externally available input one of the named
|
||||
versions may be used. The number must always be specified and
|
||||
|
@ -118,11 +118,11 @@ What: /sys/bus/iio/devices/iio:deviceX/in_temp_z_raw
|
|||
KernelVersion: 2.6.35
|
||||
Contact: linux-iio@vger.kernel.org
|
||||
Description:
|
||||
Raw (unscaled no bias removal etc) temperature measurement.
|
||||
Raw (unscaled no bias removal etc.) temperature measurement.
|
||||
If an axis is specified it generally means that the temperature
|
||||
sensor is associated with one part of a compound device (e.g.
|
||||
a gyroscope axis). Units after application of scale and offset
|
||||
are milli degrees Celsuis.
|
||||
are milli degrees Celsius.
|
||||
|
||||
What: /sys/bus/iio/devices/iio:deviceX/in_tempX_input
|
||||
KernelVersion: 2.6.38
|
||||
|
@ -148,10 +148,9 @@ KernelVersion: 2.6.35
|
|||
Contact: linux-iio@vger.kernel.org
|
||||
Description:
|
||||
Angular velocity about axis x, y or z (may be arbitrarily
|
||||
assigned) Data converted by application of offset then scale to
|
||||
radians per second. Has all the equivalent parameters as
|
||||
per voltageY. Units after application of scale and offset are
|
||||
radians per second.
|
||||
assigned). Has all the equivalent parameters as per voltageY.
|
||||
Units after application of scale and offset are radians per
|
||||
second.
|
||||
|
||||
What: /sys/bus/iio/devices/iio:deviceX/in_incli_x_raw
|
||||
What: /sys/bus/iio/devices/iio:deviceX/in_incli_y_raw
|
||||
|
@ -161,7 +160,7 @@ Contact: linux-iio@vger.kernel.org
|
|||
Description:
|
||||
Inclination raw reading about axis x, y or z (may be
|
||||
arbitrarily assigned). Data converted by application of offset
|
||||
and scale to Degrees.
|
||||
and scale to degrees.
|
||||
|
||||
What: /sys/bus/iio/devices/iio:deviceX/in_magn_x_raw
|
||||
What: /sys/bus/iio/devices/iio:deviceX/in_magn_y_raw
|
||||
|
@ -203,7 +202,7 @@ Contact: linux-iio@vger.kernel.org
|
|||
Description:
|
||||
If known for a device, offset to be added to <type>[Y]_raw prior
|
||||
to scaling by <type>[Y]_scale in order to obtain value in the
|
||||
<type> units as specified in <type>[y]_raw documentation.
|
||||
<type> units as specified in <type>[Y]_raw documentation.
|
||||
Not present if the offset is always 0 or unknown. If Y or
|
||||
axis <x|y|z> is not present, then the offset applies to all
|
||||
in channels of <type>.
|
||||
|
@ -249,7 +248,7 @@ What: /sys/bus/iio/devices/iio:deviceX/in_proximity0_calibbias
|
|||
KernelVersion: 2.6.35
|
||||
Contact: linux-iio@vger.kernel.org
|
||||
Description:
|
||||
Hardware applied calibration offset. (assumed to fix production
|
||||
Hardware applied calibration offset (assumed to fix production
|
||||
inaccuracies).
|
||||
|
||||
What /sys/bus/iio/devices/iio:deviceX/in_voltageY_calibscale
|
||||
|
@ -266,7 +265,7 @@ what /sys/bus/iio/devices/iio:deviceX/in_proximity0_calibscale
|
|||
KernelVersion: 2.6.35
|
||||
Contact: linux-iio@vger.kernel.org
|
||||
Description:
|
||||
Hardware applied calibration scale factor. (assumed to fix
|
||||
Hardware applied calibration scale factor (assumed to fix
|
||||
production inaccuracies). If shared across all channels,
|
||||
<type>_calibscale is used.
|
||||
|
||||
|
@ -276,10 +275,10 @@ What: /sys/.../iio:deviceX/in_voltage-voltage_scale_available
|
|||
What: /sys/.../iio:deviceX/out_voltageX_scale_available
|
||||
What: /sys/.../iio:deviceX/out_altvoltageX_scale_available
|
||||
What: /sys/.../iio:deviceX/in_capacitance_scale_available
|
||||
KernelVersion: 2.635
|
||||
KernelVersion: 2.6.35
|
||||
Contact: linux-iio@vger.kernel.org
|
||||
Description:
|
||||
If a discrete set of scale values are available, they
|
||||
If a discrete set of scale values is available, they
|
||||
are listed in this attribute.
|
||||
|
||||
What /sys/bus/iio/devices/iio:deviceX/out_voltageY_hardwaregain
|
||||
|
@ -330,9 +329,11 @@ Contact: linux-iio@vger.kernel.org
|
|||
Description:
|
||||
Specifies the output powerdown mode.
|
||||
DAC output stage is disconnected from the amplifier and
|
||||
1kohm_to_gnd: connected to ground via an 1kOhm resistor
|
||||
100kohm_to_gnd: connected to ground via an 100kOhm resistor
|
||||
three_state: left floating
|
||||
1kohm_to_gnd: connected to ground via an 1kOhm resistor,
|
||||
6kohm_to_gnd: connected to ground via a 6kOhm resistor,
|
||||
20kohm_to_gnd: connected to ground via a 20kOhm resistor,
|
||||
100kohm_to_gnd: connected to ground via an 100kOhm resistor,
|
||||
three_state: left floating.
|
||||
For a list of available output power down options read
|
||||
outX_powerdown_mode_available. If Y is not present the
|
||||
mode is shared across all outputs.
|
||||
|
@ -355,9 +356,10 @@ KernelVersion: 2.6.38
|
|||
Contact: linux-iio@vger.kernel.org
|
||||
Description:
|
||||
Writing 1 causes output Y to enter the power down mode specified
|
||||
by the corresponding outY_powerdown_mode. Clearing returns to
|
||||
normal operation. Y may be suppressed if all outputs are
|
||||
controlled together.
|
||||
by the corresponding outY_powerdown_mode. DAC output stage is
|
||||
disconnected from the amplifier. Clearing returns to normal
|
||||
operation. Y may be suppressed if all outputs are controlled
|
||||
together.
|
||||
|
||||
What: /sys/bus/iio/devices/iio:deviceX/out_altvoltageY_frequency
|
||||
KernelVersion: 3.4.0
|
||||
|
@ -421,12 +423,12 @@ Description:
|
|||
different values, but the device can only enable both thresholds
|
||||
or neither.
|
||||
Note the driver will assume the last p events requested are
|
||||
to be enabled where p is however many it supports (which may
|
||||
vary depending on the exact set requested. So if you want to be
|
||||
to be enabled where p is how many it supports (which may vary
|
||||
depending on the exact set requested. So if you want to be
|
||||
sure you have set what you think you have, check the contents of
|
||||
these attributes after everything is configured. Drivers may
|
||||
have to buffer any parameters so that they are consistent when
|
||||
a given event type is enabled a future point (and not those for
|
||||
a given event type is enabled at a future point (and not those for
|
||||
whatever event was previously enabled).
|
||||
|
||||
What: /sys/.../iio:deviceX/events/in_accel_x_roc_rising_en
|
||||
|
@ -702,7 +704,7 @@ What: /sys/.../buffer/scan_elements/in_anglvel_type
|
|||
What: /sys/.../buffer/scan_elements/in_magn_type
|
||||
What: /sys/.../buffer/scan_elements/in_incli_type
|
||||
What: /sys/.../buffer/scan_elements/in_voltageY_type
|
||||
What: /sys/.../buffer/scan_elements/in_voltage-in_type
|
||||
What: /sys/.../buffer/scan_elements/in_voltage_type
|
||||
What: /sys/.../buffer/scan_elements/in_voltageY_supply_type
|
||||
What: /sys/.../buffer/scan_elements/in_timestamp_type
|
||||
KernelVersion: 2.6.37
|
||||
|
@ -723,7 +725,7 @@ Description:
|
|||
the buffer output value appropriately. The storagebits value
|
||||
also specifies the data alignment. So s48/64>>2 will be a
|
||||
signed 48 bit integer stored in a 64 bit location aligned to
|
||||
a a64 bit boundary. To obtain the clean value, shift right 2
|
||||
a 64 bit boundary. To obtain the clean value, shift right 2
|
||||
and apply a mask to zero the top 16 bits of the result.
|
||||
For other storage combinations this attribute will be extended
|
||||
appropriately.
|
||||
|
|
37
Documentation/ABI/testing/sysfs-bus-iio-frequency-ad9523
Normal file
37
Documentation/ABI/testing/sysfs-bus-iio-frequency-ad9523
Normal file
|
@ -0,0 +1,37 @@
|
|||
What: /sys/bus/iio/devices/iio:deviceX/pll2_feedback_clk_present
|
||||
What: /sys/bus/iio/devices/iio:deviceX/pll2_reference_clk_present
|
||||
What: /sys/bus/iio/devices/iio:deviceX/pll1_reference_clk_a_present
|
||||
What: /sys/bus/iio/devices/iio:deviceX/pll1_reference_clk_b_present
|
||||
What: /sys/bus/iio/devices/iio:deviceX/pll1_reference_clk_test_present
|
||||
What: /sys/bus/iio/devices/iio:deviceX/vcxo_clk_present
|
||||
KernelVersion: 3.4.0
|
||||
Contact: linux-iio@vger.kernel.org
|
||||
Description:
|
||||
Reading returns either '1' or '0'.
|
||||
'1' means that the clock in question is present.
|
||||
'0' means that the clock is missing.
|
||||
|
||||
What: /sys/bus/iio/devices/iio:deviceX/pllY_locked
|
||||
KernelVersion: 3.4.0
|
||||
Contact: linux-iio@vger.kernel.org
|
||||
Description:
|
||||
Reading returns either '1' or '0'. '1' means that the
|
||||
pllY is locked.
|
||||
|
||||
What: /sys/bus/iio/devices/iio:deviceX/store_eeprom
|
||||
KernelVersion: 3.4.0
|
||||
Contact: linux-iio@vger.kernel.org
|
||||
Description:
|
||||
Writing '1' stores the current device configuration into
|
||||
on-chip EEPROM. After power-up or chip reset the device will
|
||||
automatically load the saved configuration.
|
||||
|
||||
What: /sys/bus/iio/devices/iio:deviceX/sync_dividers
|
||||
KernelVersion: 3.4.0
|
||||
Contact: linux-iio@vger.kernel.org
|
||||
Description:
|
||||
Writing '1' triggers the clock distribution synchronization
|
||||
functionality. All dividers are reset and the channels start
|
||||
with their predefined phase offsets (out_altvoltageY_phase).
|
||||
Writing this file has the effect as driving the external
|
||||
/SYNC pin low.
|
21
Documentation/ABI/testing/sysfs-bus-iio-frequency-adf4350
Normal file
21
Documentation/ABI/testing/sysfs-bus-iio-frequency-adf4350
Normal file
|
@ -0,0 +1,21 @@
|
|||
What: /sys/bus/iio/devices/iio:deviceX/out_altvoltageY_frequency_resolution
|
||||
KernelVersion: 3.4.0
|
||||
Contact: linux-iio@vger.kernel.org
|
||||
Description:
|
||||
Stores channel Y frequency resolution/channel spacing in Hz.
|
||||
The value given directly influences the MODULUS used by
|
||||
the fractional-N PLL. It is assumed that the algorithm
|
||||
that is used to compute the various dividers, is able to
|
||||
generate proper values for multiples of channel spacing.
|
||||
|
||||
What: /sys/bus/iio/devices/iio:deviceX/out_altvoltageY_refin_frequency
|
||||
KernelVersion: 3.4.0
|
||||
Contact: linux-iio@vger.kernel.org
|
||||
Description:
|
||||
Sets channel Y REFin frequency in Hz. In some clock chained
|
||||
applications, the reference frequency used by the PLL may
|
||||
change during runtime. This attribute allows the user to
|
||||
adjust the reference frequency accordingly.
|
||||
The value written has no effect until out_altvoltageY_frequency
|
||||
is updated. Consider to use out_altvoltageY_powerdown to power
|
||||
down the PLL and it's RFOut buffers during REFin changes.
|
61
Documentation/ABI/testing/sysfs-bus-iio-light-lm3533-als
Normal file
61
Documentation/ABI/testing/sysfs-bus-iio-light-lm3533-als
Normal file
|
@ -0,0 +1,61 @@
|
|||
What: /sys/.../events/in_illuminance0_thresh_either_en
|
||||
Date: April 2012
|
||||
KernelVersion: 3.5
|
||||
Contact: Johan Hovold <jhovold@gmail.com>
|
||||
Description:
|
||||
Event generated when channel passes one of the four thresholds
|
||||
in each direction (rising|falling) and a zone change occurs.
|
||||
The corresponding light zone can be read from
|
||||
in_illuminance0_zone.
|
||||
|
||||
What: /sys/.../events/in_illuminance0_threshY_hysteresis
|
||||
Date: May 2012
|
||||
KernelVersion: 3.5
|
||||
Contact: Johan Hovold <jhovold@gmail.com>
|
||||
Description:
|
||||
Get the hysteresis for thresholds Y, that is,
|
||||
threshY_hysteresis = threshY_raising - threshY_falling
|
||||
|
||||
What: /sys/.../events/illuminance_threshY_falling_value
|
||||
What: /sys/.../events/illuminance_threshY_raising_value
|
||||
Date: April 2012
|
||||
KernelVersion: 3.5
|
||||
Contact: Johan Hovold <jhovold@gmail.com>
|
||||
Description:
|
||||
Specifies the value of threshold that the device is comparing
|
||||
against for the events enabled by
|
||||
in_illuminance0_thresh_either_en (0..255), where Y in 0..3.
|
||||
|
||||
Note that threshY_falling must be less than or equal to
|
||||
threshY_raising.
|
||||
|
||||
These thresholds correspond to the eight zone-boundary
|
||||
registers (boundaryY_{low,high}) and define the five light
|
||||
zones.
|
||||
|
||||
What: /sys/bus/iio/devices/iio:deviceX/in_illuminance0_zone
|
||||
Date: April 2012
|
||||
KernelVersion: 3.5
|
||||
Contact: Johan Hovold <jhovold@gmail.com>
|
||||
Description:
|
||||
Get the current light zone (0..4) as defined by the
|
||||
in_illuminance0_threshY_{falling,rising} thresholds.
|
||||
|
||||
What: /sys/bus/iio/devices/iio:deviceX/out_currentY_raw
|
||||
Date: May 2012
|
||||
KernelVersion: 3.5
|
||||
Contact: Johan Hovold <jhovold@gmail.com>
|
||||
Description:
|
||||
Get output current for channel Y (0..255), that is,
|
||||
out_currentY_currentZ_raw, where Z is the current zone.
|
||||
|
||||
What: /sys/bus/iio/devices/iio:deviceX/out_currentY_currentZ_raw
|
||||
Date: May 2012
|
||||
KernelVersion: 3.5
|
||||
Contact: Johan Hovold <jhovold@gmail.com>
|
||||
Description:
|
||||
Set the output current for channel out_currentY when in zone
|
||||
Z (0..255), where Y in 0..2 and Z in 0..4.
|
||||
|
||||
These values correspond to the ALS-mapper target registers for
|
||||
ALS-mapper Y + 1.
|
|
@ -40,6 +40,12 @@ corrupt, but usually it is restorable.
|
|||
Setting the ramoops parameters can be done in 2 different manners:
|
||||
1. Use the module parameters (which have the names of the variables described
|
||||
as before).
|
||||
For quick debugging, you can also reserve parts of memory during boot
|
||||
and then use the reserved memory for ramoops. For example, assuming a machine
|
||||
with > 128 MB of memory, the following kernel command line will tell the
|
||||
kernel to use only the first 128 MB of memory, and place ECC-protected ramoops
|
||||
region at 128 MB boundary:
|
||||
"mem=128M ramoops.mem_address=0x8000000 ramoops.ecc=1"
|
||||
2. Use a platform device and set the platform data. The parameters can then
|
||||
be set through that platform data. An example of doing that is:
|
||||
|
||||
|
@ -70,6 +76,14 @@ if (ret) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
You can specify either RAM memory or peripheral devices' memory. However, when
|
||||
specifying RAM, be sure to reserve the memory by issuing memblock_reserve()
|
||||
very early in the architecture code, e.g.:
|
||||
|
||||
#include <linux/memblock.h>
|
||||
|
||||
memblock_reserve(ramoops_data.mem_address, ramoops_data.mem_size);
|
||||
|
||||
3. Dump format
|
||||
|
||||
The data dump begins with a header, currently defined as "====" followed by a
|
||||
|
@ -80,3 +94,28 @@ timestamp and a new line. The dump then continues with the actual data.
|
|||
The dump data can be read from the pstore filesystem. The format for these
|
||||
files is "dmesg-ramoops-N", where N is the record number in memory. To delete
|
||||
a stored record from RAM, simply unlink the respective pstore file.
|
||||
|
||||
5. Persistent function tracing
|
||||
|
||||
Persistent function tracing might be useful for debugging software or hardware
|
||||
related hangs. The functions call chain log is stored in a "ftrace-ramoops"
|
||||
file. Here is an example of usage:
|
||||
|
||||
# mount -t debugfs debugfs /sys/kernel/debug/
|
||||
# cd /sys/kernel/debug/tracing
|
||||
# echo function > current_tracer
|
||||
# echo 1 > options/func_pstore
|
||||
# reboot -f
|
||||
[...]
|
||||
# mount -t pstore pstore /mnt/
|
||||
# tail /mnt/ftrace-ramoops
|
||||
0 ffffffff8101ea64 ffffffff8101bcda native_apic_mem_read <- disconnect_bsp_APIC+0x6a/0xc0
|
||||
0 ffffffff8101ea44 ffffffff8101bcf6 native_apic_mem_write <- disconnect_bsp_APIC+0x86/0xc0
|
||||
0 ffffffff81020084 ffffffff8101a4b5 hpet_disable <- native_machine_shutdown+0x75/0x90
|
||||
0 ffffffff81005f94 ffffffff8101a4bb iommu_shutdown_noop <- native_machine_shutdown+0x7b/0x90
|
||||
0 ffffffff8101a6a1 ffffffff8101a437 native_machine_emergency_restart <- native_machine_restart+0x37/0x40
|
||||
0 ffffffff811f9876 ffffffff8101a73a acpi_reboot <- native_machine_emergency_restart+0xaa/0x1e0
|
||||
0 ffffffff8101a514 ffffffff8101a772 mach_reboot_fixups <- native_machine_emergency_restart+0xe2/0x1e0
|
||||
0 ffffffff811d9c54 ffffffff8101a7a0 __const_udelay <- native_machine_emergency_restart+0x110/0x1e0
|
||||
0 ffffffff811d9c34 ffffffff811d9c80 __delay <- __const_udelay+0x30/0x40
|
||||
0 ffffffff811d9d14 ffffffff811d9c3f delay_tsc <- __delay+0xf/0x20
|
||||
|
|
|
@ -29,6 +29,13 @@ config IIO_KFIFO_BUF
|
|||
no buffer events so it is up to userspace to work out how
|
||||
often to read from the buffer.
|
||||
|
||||
config IIO_TRIGGERED_BUFFER
|
||||
tristate
|
||||
select IIO_TRIGGER
|
||||
select IIO_KFIFO_BUF
|
||||
help
|
||||
Provides helper functions for setting up triggered buffers.
|
||||
|
||||
endif # IIO_BUFFER
|
||||
|
||||
config IIO_TRIGGER
|
||||
|
@ -49,5 +56,8 @@ config IIO_CONSUMERS_PER_TRIGGER
|
|||
|
||||
source "drivers/iio/adc/Kconfig"
|
||||
source "drivers/iio/amplifiers/Kconfig"
|
||||
source "drivers/iio/light/Kconfig"
|
||||
source "drivers/iio/frequency/Kconfig"
|
||||
source "drivers/iio/dac/Kconfig"
|
||||
|
||||
endif # IIO
|
||||
|
|
|
@ -7,7 +7,11 @@ industrialio-y := industrialio-core.o industrialio-event.o inkern.o
|
|||
industrialio-$(CONFIG_IIO_BUFFER) += industrialio-buffer.o
|
||||
industrialio-$(CONFIG_IIO_TRIGGER) += industrialio-trigger.o
|
||||
|
||||
obj-$(CONFIG_IIO_TRIGGERED_BUFFER) += industrialio-triggered-buffer.o
|
||||
obj-$(CONFIG_IIO_KFIFO_BUF) += kfifo_buf.o
|
||||
|
||||
obj-y += adc/
|
||||
obj-y += amplifiers/
|
||||
obj-y += light/
|
||||
obj-y += frequency/
|
||||
obj-y += dac/
|
||||
|
|
|
@ -3,12 +3,21 @@
|
|||
#
|
||||
menu "Analog to digital converters"
|
||||
|
||||
config AD7266
|
||||
tristate "Analog Devices AD7265/AD7266 ADC driver"
|
||||
depends on SPI_MASTER
|
||||
select IIO_BUFFER
|
||||
select IIO_TRIGGER
|
||||
select IIO_TRIGGERED_BUFFER
|
||||
help
|
||||
Say yes here to build support for Analog Devices AD7265 and AD7266
|
||||
ADCs.
|
||||
|
||||
config AT91_ADC
|
||||
tristate "Atmel AT91 ADC"
|
||||
depends on ARCH_AT91
|
||||
select IIO_BUFFER
|
||||
select IIO_KFIFO_BUF
|
||||
select IIO_TRIGGER
|
||||
select IIO_TRIGGERED_BUFFER
|
||||
select SYSFS
|
||||
help
|
||||
Say yes here to build support for Atmel AT91 ADC.
|
||||
|
|
|
@ -2,4 +2,5 @@
|
|||
# Makefile for IIO ADC drivers
|
||||
#
|
||||
|
||||
obj-$(CONFIG_AD7266) += ad7266.o
|
||||
obj-$(CONFIG_AT91_ADC) += at91_adc.o
|
||||
|
|
536
drivers/iio/adc/ad7266.c
Normal file
536
drivers/iio/adc/ad7266.c
Normal file
|
@ -0,0 +1,536 @@
|
|||
/*
|
||||
* AD7266/65 SPI ADC driver
|
||||
*
|
||||
* Copyright 2012 Analog Devices Inc.
|
||||
*
|
||||
* Licensed under the GPL-2.
|
||||
*/
|
||||
|
||||
#include <linux/device.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/spi/spi.h>
|
||||
#include <linux/regulator/consumer.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/module.h>
|
||||
|
||||
#include <linux/interrupt.h>
|
||||
|
||||
#include <linux/iio/iio.h>
|
||||
#include <linux/iio/buffer.h>
|
||||
#include <linux/iio/trigger_consumer.h>
|
||||
#include <linux/iio/triggered_buffer.h>
|
||||
|
||||
#include <linux/platform_data/ad7266.h>
|
||||
|
||||
struct ad7266_state {
|
||||
struct spi_device *spi;
|
||||
struct regulator *reg;
|
||||
unsigned long vref_uv;
|
||||
|
||||
struct spi_transfer single_xfer[3];
|
||||
struct spi_message single_msg;
|
||||
|
||||
enum ad7266_range range;
|
||||
enum ad7266_mode mode;
|
||||
bool fixed_addr;
|
||||
struct gpio gpios[3];
|
||||
|
||||
/*
|
||||
* DMA (thus cache coherency maintenance) requires the
|
||||
* transfer buffers to live in their own cache lines.
|
||||
* The buffer needs to be large enough to hold two samples (4 bytes) and
|
||||
* the naturally aligned timestamp (8 bytes).
|
||||
*/
|
||||
uint8_t data[ALIGN(4, sizeof(s64)) + sizeof(s64)] ____cacheline_aligned;
|
||||
};
|
||||
|
||||
static int ad7266_wakeup(struct ad7266_state *st)
|
||||
{
|
||||
/* Any read with >= 2 bytes will wake the device */
|
||||
return spi_read(st->spi, st->data, 2);
|
||||
}
|
||||
|
||||
static int ad7266_powerdown(struct ad7266_state *st)
|
||||
{
|
||||
/* Any read with < 2 bytes will powerdown the device */
|
||||
return spi_read(st->spi, st->data, 1);
|
||||
}
|
||||
|
||||
static int ad7266_preenable(struct iio_dev *indio_dev)
|
||||
{
|
||||
struct ad7266_state *st = iio_priv(indio_dev);
|
||||
int ret;
|
||||
|
||||
ret = ad7266_wakeup(st);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = iio_sw_buffer_preenable(indio_dev);
|
||||
if (ret)
|
||||
ad7266_powerdown(st);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int ad7266_postdisable(struct iio_dev *indio_dev)
|
||||
{
|
||||
struct ad7266_state *st = iio_priv(indio_dev);
|
||||
return ad7266_powerdown(st);
|
||||
}
|
||||
|
||||
static const struct iio_buffer_setup_ops iio_triggered_buffer_setup_ops = {
|
||||
.preenable = &ad7266_preenable,
|
||||
.postenable = &iio_triggered_buffer_postenable,
|
||||
.predisable = &iio_triggered_buffer_predisable,
|
||||
.postdisable = &ad7266_postdisable,
|
||||
};
|
||||
|
||||
static irqreturn_t ad7266_trigger_handler(int irq, void *p)
|
||||
{
|
||||
struct iio_poll_func *pf = p;
|
||||
struct iio_dev *indio_dev = pf->indio_dev;
|
||||
struct iio_buffer *buffer = indio_dev->buffer;
|
||||
struct ad7266_state *st = iio_priv(indio_dev);
|
||||
int ret;
|
||||
|
||||
ret = spi_read(st->spi, st->data, 4);
|
||||
if (ret == 0) {
|
||||
if (indio_dev->scan_timestamp)
|
||||
((s64 *)st->data)[1] = pf->timestamp;
|
||||
iio_push_to_buffer(buffer, (u8 *)st->data, pf->timestamp);
|
||||
}
|
||||
|
||||
iio_trigger_notify_done(indio_dev->trig);
|
||||
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
static void ad7266_select_input(struct ad7266_state *st, unsigned int nr)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
if (st->fixed_addr)
|
||||
return;
|
||||
|
||||
switch (st->mode) {
|
||||
case AD7266_MODE_SINGLE_ENDED:
|
||||
nr >>= 1;
|
||||
break;
|
||||
case AD7266_MODE_PSEUDO_DIFF:
|
||||
nr |= 1;
|
||||
break;
|
||||
case AD7266_MODE_DIFF:
|
||||
nr &= ~1;
|
||||
break;
|
||||
}
|
||||
|
||||
for (i = 0; i < 3; ++i)
|
||||
gpio_set_value(st->gpios[i].gpio, (bool)(nr & BIT(i)));
|
||||
}
|
||||
|
||||
static int ad7266_update_scan_mode(struct iio_dev *indio_dev,
|
||||
const unsigned long *scan_mask)
|
||||
{
|
||||
struct ad7266_state *st = iio_priv(indio_dev);
|
||||
unsigned int nr = find_first_bit(scan_mask, indio_dev->masklength);
|
||||
|
||||
ad7266_select_input(st, nr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ad7266_read_single(struct ad7266_state *st, int *val,
|
||||
unsigned int address)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ad7266_select_input(st, address);
|
||||
|
||||
ret = spi_sync(st->spi, &st->single_msg);
|
||||
*val = be16_to_cpu(st->data[address % 2]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int ad7266_read_raw(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec const *chan, int *val, int *val2, long m)
|
||||
{
|
||||
struct ad7266_state *st = iio_priv(indio_dev);
|
||||
unsigned long scale_uv;
|
||||
int ret;
|
||||
|
||||
switch (m) {
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
if (iio_buffer_enabled(indio_dev))
|
||||
return -EBUSY;
|
||||
|
||||
ret = ad7266_read_single(st, val, chan->address);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
*val = (*val >> 2) & 0xfff;
|
||||
if (chan->scan_type.sign == 's')
|
||||
*val = sign_extend32(*val, 11);
|
||||
|
||||
return IIO_VAL_INT;
|
||||
case IIO_CHAN_INFO_SCALE:
|
||||
scale_uv = (st->vref_uv * 100);
|
||||
if (st->mode == AD7266_MODE_DIFF)
|
||||
scale_uv *= 2;
|
||||
if (st->range == AD7266_RANGE_2VREF)
|
||||
scale_uv *= 2;
|
||||
|
||||
scale_uv >>= chan->scan_type.realbits;
|
||||
*val = scale_uv / 100000;
|
||||
*val2 = (scale_uv % 100000) * 10;
|
||||
return IIO_VAL_INT_PLUS_MICRO;
|
||||
case IIO_CHAN_INFO_OFFSET:
|
||||
if (st->range == AD7266_RANGE_2VREF &&
|
||||
st->mode != AD7266_MODE_DIFF)
|
||||
*val = 2048;
|
||||
else
|
||||
*val = 0;
|
||||
return IIO_VAL_INT;
|
||||
}
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
#define AD7266_CHAN(_chan, _sign) { \
|
||||
.type = IIO_VOLTAGE, \
|
||||
.indexed = 1, \
|
||||
.channel = (_chan), \
|
||||
.address = (_chan), \
|
||||
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT \
|
||||
| IIO_CHAN_INFO_SCALE_SHARED_BIT \
|
||||
| IIO_CHAN_INFO_OFFSET_SHARED_BIT, \
|
||||
.scan_index = (_chan), \
|
||||
.scan_type = { \
|
||||
.sign = (_sign), \
|
||||
.realbits = 12, \
|
||||
.storagebits = 16, \
|
||||
.shift = 2, \
|
||||
.endianness = IIO_BE, \
|
||||
}, \
|
||||
}
|
||||
|
||||
#define AD7266_DECLARE_SINGLE_ENDED_CHANNELS(_name, _sign) \
|
||||
const struct iio_chan_spec ad7266_channels_##_name[] = { \
|
||||
AD7266_CHAN(0, (_sign)), \
|
||||
AD7266_CHAN(1, (_sign)), \
|
||||
AD7266_CHAN(2, (_sign)), \
|
||||
AD7266_CHAN(3, (_sign)), \
|
||||
AD7266_CHAN(4, (_sign)), \
|
||||
AD7266_CHAN(5, (_sign)), \
|
||||
AD7266_CHAN(6, (_sign)), \
|
||||
AD7266_CHAN(7, (_sign)), \
|
||||
AD7266_CHAN(8, (_sign)), \
|
||||
AD7266_CHAN(9, (_sign)), \
|
||||
AD7266_CHAN(10, (_sign)), \
|
||||
AD7266_CHAN(11, (_sign)), \
|
||||
IIO_CHAN_SOFT_TIMESTAMP(13), \
|
||||
}
|
||||
|
||||
#define AD7266_DECLARE_SINGLE_ENDED_CHANNELS_FIXED(_name, _sign) \
|
||||
const struct iio_chan_spec ad7266_channels_##_name##_fixed[] = { \
|
||||
AD7266_CHAN(0, (_sign)), \
|
||||
AD7266_CHAN(1, (_sign)), \
|
||||
IIO_CHAN_SOFT_TIMESTAMP(2), \
|
||||
}
|
||||
|
||||
static AD7266_DECLARE_SINGLE_ENDED_CHANNELS(u, 'u');
|
||||
static AD7266_DECLARE_SINGLE_ENDED_CHANNELS(s, 's');
|
||||
static AD7266_DECLARE_SINGLE_ENDED_CHANNELS_FIXED(u, 'u');
|
||||
static AD7266_DECLARE_SINGLE_ENDED_CHANNELS_FIXED(s, 's');
|
||||
|
||||
#define AD7266_CHAN_DIFF(_chan, _sign) { \
|
||||
.type = IIO_VOLTAGE, \
|
||||
.indexed = 1, \
|
||||
.channel = (_chan) * 2, \
|
||||
.channel2 = (_chan) * 2 + 1, \
|
||||
.address = (_chan), \
|
||||
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT \
|
||||
| IIO_CHAN_INFO_SCALE_SHARED_BIT \
|
||||
| IIO_CHAN_INFO_OFFSET_SHARED_BIT, \
|
||||
.scan_index = (_chan), \
|
||||
.scan_type = { \
|
||||
.sign = _sign, \
|
||||
.realbits = 12, \
|
||||
.storagebits = 16, \
|
||||
.shift = 2, \
|
||||
.endianness = IIO_BE, \
|
||||
}, \
|
||||
.differential = 1, \
|
||||
}
|
||||
|
||||
#define AD7266_DECLARE_DIFF_CHANNELS(_name, _sign) \
|
||||
const struct iio_chan_spec ad7266_channels_diff_##_name[] = { \
|
||||
AD7266_CHAN_DIFF(0, (_sign)), \
|
||||
AD7266_CHAN_DIFF(1, (_sign)), \
|
||||
AD7266_CHAN_DIFF(2, (_sign)), \
|
||||
AD7266_CHAN_DIFF(3, (_sign)), \
|
||||
AD7266_CHAN_DIFF(4, (_sign)), \
|
||||
AD7266_CHAN_DIFF(5, (_sign)), \
|
||||
IIO_CHAN_SOFT_TIMESTAMP(6), \
|
||||
}
|
||||
|
||||
static AD7266_DECLARE_DIFF_CHANNELS(s, 's');
|
||||
static AD7266_DECLARE_DIFF_CHANNELS(u, 'u');
|
||||
|
||||
#define AD7266_DECLARE_DIFF_CHANNELS_FIXED(_name, _sign) \
|
||||
const struct iio_chan_spec ad7266_channels_diff_fixed_##_name[] = { \
|
||||
AD7266_CHAN_DIFF(0, (_sign)), \
|
||||
AD7266_CHAN_DIFF(1, (_sign)), \
|
||||
IIO_CHAN_SOFT_TIMESTAMP(2), \
|
||||
}
|
||||
|
||||
static AD7266_DECLARE_DIFF_CHANNELS_FIXED(s, 's');
|
||||
static AD7266_DECLARE_DIFF_CHANNELS_FIXED(u, 'u');
|
||||
|
||||
static const struct iio_info ad7266_info = {
|
||||
.read_raw = &ad7266_read_raw,
|
||||
.update_scan_mode = &ad7266_update_scan_mode,
|
||||
.driver_module = THIS_MODULE,
|
||||
};
|
||||
|
||||
static unsigned long ad7266_available_scan_masks[] = {
|
||||
0x003,
|
||||
0x00c,
|
||||
0x030,
|
||||
0x0c0,
|
||||
0x300,
|
||||
0xc00,
|
||||
0x000,
|
||||
};
|
||||
|
||||
static unsigned long ad7266_available_scan_masks_diff[] = {
|
||||
0x003,
|
||||
0x00c,
|
||||
0x030,
|
||||
0x000,
|
||||
};
|
||||
|
||||
static unsigned long ad7266_available_scan_masks_fixed[] = {
|
||||
0x003,
|
||||
0x000,
|
||||
};
|
||||
|
||||
struct ad7266_chan_info {
|
||||
const struct iio_chan_spec *channels;
|
||||
unsigned int num_channels;
|
||||
unsigned long *scan_masks;
|
||||
};
|
||||
|
||||
#define AD7266_CHAN_INFO_INDEX(_differential, _signed, _fixed) \
|
||||
(((_differential) << 2) | ((_signed) << 1) | ((_fixed) << 0))
|
||||
|
||||
static const struct ad7266_chan_info ad7266_chan_infos[] = {
|
||||
[AD7266_CHAN_INFO_INDEX(0, 0, 0)] = {
|
||||
.channels = ad7266_channels_u,
|
||||
.num_channels = ARRAY_SIZE(ad7266_channels_u),
|
||||
.scan_masks = ad7266_available_scan_masks,
|
||||
},
|
||||
[AD7266_CHAN_INFO_INDEX(0, 0, 1)] = {
|
||||
.channels = ad7266_channels_u_fixed,
|
||||
.num_channels = ARRAY_SIZE(ad7266_channels_u_fixed),
|
||||
.scan_masks = ad7266_available_scan_masks_fixed,
|
||||
},
|
||||
[AD7266_CHAN_INFO_INDEX(0, 1, 0)] = {
|
||||
.channels = ad7266_channels_s,
|
||||
.num_channels = ARRAY_SIZE(ad7266_channels_s),
|
||||
.scan_masks = ad7266_available_scan_masks,
|
||||
},
|
||||
[AD7266_CHAN_INFO_INDEX(0, 1, 1)] = {
|
||||
.channels = ad7266_channels_s_fixed,
|
||||
.num_channels = ARRAY_SIZE(ad7266_channels_s_fixed),
|
||||
.scan_masks = ad7266_available_scan_masks_fixed,
|
||||
},
|
||||
[AD7266_CHAN_INFO_INDEX(1, 0, 0)] = {
|
||||
.channels = ad7266_channels_diff_u,
|
||||
.num_channels = ARRAY_SIZE(ad7266_channels_diff_u),
|
||||
.scan_masks = ad7266_available_scan_masks_diff,
|
||||
},
|
||||
[AD7266_CHAN_INFO_INDEX(1, 0, 1)] = {
|
||||
.channels = ad7266_channels_diff_fixed_u,
|
||||
.num_channels = ARRAY_SIZE(ad7266_channels_diff_fixed_u),
|
||||
.scan_masks = ad7266_available_scan_masks_fixed,
|
||||
},
|
||||
[AD7266_CHAN_INFO_INDEX(1, 1, 0)] = {
|
||||
.channels = ad7266_channels_diff_s,
|
||||
.num_channels = ARRAY_SIZE(ad7266_channels_diff_s),
|
||||
.scan_masks = ad7266_available_scan_masks_diff,
|
||||
},
|
||||
[AD7266_CHAN_INFO_INDEX(1, 1, 1)] = {
|
||||
.channels = ad7266_channels_diff_fixed_s,
|
||||
.num_channels = ARRAY_SIZE(ad7266_channels_diff_fixed_s),
|
||||
.scan_masks = ad7266_available_scan_masks_fixed,
|
||||
},
|
||||
};
|
||||
|
||||
static void __devinit ad7266_init_channels(struct iio_dev *indio_dev)
|
||||
{
|
||||
struct ad7266_state *st = iio_priv(indio_dev);
|
||||
bool is_differential, is_signed;
|
||||
const struct ad7266_chan_info *chan_info;
|
||||
int i;
|
||||
|
||||
is_differential = st->mode != AD7266_MODE_SINGLE_ENDED;
|
||||
is_signed = (st->range == AD7266_RANGE_2VREF) |
|
||||
(st->mode == AD7266_MODE_DIFF);
|
||||
|
||||
i = AD7266_CHAN_INFO_INDEX(is_differential, is_signed, st->fixed_addr);
|
||||
chan_info = &ad7266_chan_infos[i];
|
||||
|
||||
indio_dev->channels = chan_info->channels;
|
||||
indio_dev->num_channels = chan_info->num_channels;
|
||||
indio_dev->available_scan_masks = chan_info->scan_masks;
|
||||
indio_dev->masklength = chan_info->num_channels - 1;
|
||||
}
|
||||
|
||||
static const char * const ad7266_gpio_labels[] = {
|
||||
"AD0", "AD1", "AD2",
|
||||
};
|
||||
|
||||
static int __devinit ad7266_probe(struct spi_device *spi)
|
||||
{
|
||||
struct ad7266_platform_data *pdata = spi->dev.platform_data;
|
||||
struct iio_dev *indio_dev;
|
||||
struct ad7266_state *st;
|
||||
unsigned int i;
|
||||
int ret;
|
||||
|
||||
indio_dev = iio_device_alloc(sizeof(*st));
|
||||
if (indio_dev == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
st = iio_priv(indio_dev);
|
||||
|
||||
st->reg = regulator_get(&spi->dev, "vref");
|
||||
if (!IS_ERR_OR_NULL(st->reg)) {
|
||||
ret = regulator_enable(st->reg);
|
||||
if (ret)
|
||||
goto error_put_reg;
|
||||
|
||||
st->vref_uv = regulator_get_voltage(st->reg);
|
||||
} else {
|
||||
/* Use internal reference */
|
||||
st->vref_uv = 2500000;
|
||||
}
|
||||
|
||||
if (pdata) {
|
||||
st->fixed_addr = pdata->fixed_addr;
|
||||
st->mode = pdata->mode;
|
||||
st->range = pdata->range;
|
||||
|
||||
if (!st->fixed_addr) {
|
||||
for (i = 0; i < ARRAY_SIZE(st->gpios); ++i) {
|
||||
st->gpios[i].gpio = pdata->addr_gpios[i];
|
||||
st->gpios[i].flags = GPIOF_OUT_INIT_LOW;
|
||||
st->gpios[i].label = ad7266_gpio_labels[i];
|
||||
}
|
||||
ret = gpio_request_array(st->gpios,
|
||||
ARRAY_SIZE(st->gpios));
|
||||
if (ret)
|
||||
goto error_disable_reg;
|
||||
}
|
||||
} else {
|
||||
st->fixed_addr = true;
|
||||
st->range = AD7266_RANGE_VREF;
|
||||
st->mode = AD7266_MODE_DIFF;
|
||||
}
|
||||
|
||||
spi_set_drvdata(spi, indio_dev);
|
||||
st->spi = spi;
|
||||
|
||||
indio_dev->dev.parent = &spi->dev;
|
||||
indio_dev->name = spi_get_device_id(spi)->name;
|
||||
indio_dev->modes = INDIO_DIRECT_MODE;
|
||||
indio_dev->info = &ad7266_info;
|
||||
|
||||
ad7266_init_channels(indio_dev);
|
||||
|
||||
/* wakeup */
|
||||
st->single_xfer[0].rx_buf = &st->data;
|
||||
st->single_xfer[0].len = 2;
|
||||
st->single_xfer[0].cs_change = 1;
|
||||
/* conversion */
|
||||
st->single_xfer[1].rx_buf = &st->data;
|
||||
st->single_xfer[1].len = 4;
|
||||
st->single_xfer[1].cs_change = 1;
|
||||
/* powerdown */
|
||||
st->single_xfer[2].tx_buf = &st->data;
|
||||
st->single_xfer[2].len = 1;
|
||||
|
||||
spi_message_init(&st->single_msg);
|
||||
spi_message_add_tail(&st->single_xfer[0], &st->single_msg);
|
||||
spi_message_add_tail(&st->single_xfer[1], &st->single_msg);
|
||||
spi_message_add_tail(&st->single_xfer[2], &st->single_msg);
|
||||
|
||||
ret = iio_triggered_buffer_setup(indio_dev, &iio_pollfunc_store_time,
|
||||
&ad7266_trigger_handler, &iio_triggered_buffer_setup_ops);
|
||||
if (ret)
|
||||
goto error_free_gpios;
|
||||
|
||||
ret = iio_device_register(indio_dev);
|
||||
if (ret)
|
||||
goto error_buffer_cleanup;
|
||||
|
||||
return 0;
|
||||
|
||||
error_buffer_cleanup:
|
||||
iio_triggered_buffer_cleanup(indio_dev);
|
||||
error_free_gpios:
|
||||
if (!st->fixed_addr)
|
||||
gpio_free_array(st->gpios, ARRAY_SIZE(st->gpios));
|
||||
error_disable_reg:
|
||||
if (!IS_ERR_OR_NULL(st->reg))
|
||||
regulator_disable(st->reg);
|
||||
error_put_reg:
|
||||
if (!IS_ERR_OR_NULL(st->reg))
|
||||
regulator_put(st->reg);
|
||||
|
||||
iio_device_free(indio_dev);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int __devexit ad7266_remove(struct spi_device *spi)
|
||||
{
|
||||
struct iio_dev *indio_dev = spi_get_drvdata(spi);
|
||||
struct ad7266_state *st = iio_priv(indio_dev);
|
||||
|
||||
iio_device_unregister(indio_dev);
|
||||
iio_triggered_buffer_cleanup(indio_dev);
|
||||
if (!st->fixed_addr)
|
||||
gpio_free_array(st->gpios, ARRAY_SIZE(st->gpios));
|
||||
if (!IS_ERR_OR_NULL(st->reg)) {
|
||||
regulator_disable(st->reg);
|
||||
regulator_put(st->reg);
|
||||
}
|
||||
iio_device_free(indio_dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct spi_device_id ad7266_id[] = {
|
||||
{"ad7265", 0},
|
||||
{"ad7266", 0},
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(spi, ad7266_id);
|
||||
|
||||
static struct spi_driver ad7266_driver = {
|
||||
.driver = {
|
||||
.name = "ad7266",
|
||||
.owner = THIS_MODULE,
|
||||
},
|
||||
.probe = ad7266_probe,
|
||||
.remove = __devexit_p(ad7266_remove),
|
||||
.id_table = ad7266_id,
|
||||
};
|
||||
module_spi_driver(ad7266_driver);
|
||||
|
||||
MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
|
||||
MODULE_DESCRIPTION("Analog Devices AD7266/65 ADC");
|
||||
MODULE_LICENSE("GPL v2");
|
|
@ -26,9 +26,9 @@
|
|||
|
||||
#include <linux/iio/iio.h>
|
||||
#include <linux/iio/buffer.h>
|
||||
#include <linux/iio/kfifo_buf.h>
|
||||
#include <linux/iio/trigger.h>
|
||||
#include <linux/iio/trigger_consumer.h>
|
||||
#include <linux/iio/triggered_buffer.h>
|
||||
|
||||
#include <mach/at91_adc.h>
|
||||
|
||||
|
@ -318,58 +318,15 @@ static void at91_adc_trigger_remove(struct iio_dev *idev)
|
|||
}
|
||||
}
|
||||
|
||||
static const struct iio_buffer_setup_ops at91_adc_buffer_ops = {
|
||||
.preenable = &iio_sw_buffer_preenable,
|
||||
.postenable = &iio_triggered_buffer_postenable,
|
||||
.predisable = &iio_triggered_buffer_predisable,
|
||||
};
|
||||
|
||||
static int at91_adc_buffer_init(struct iio_dev *idev)
|
||||
{
|
||||
int ret;
|
||||
|
||||
idev->buffer = iio_kfifo_allocate(idev);
|
||||
if (!idev->buffer) {
|
||||
ret = -ENOMEM;
|
||||
goto error_ret;
|
||||
}
|
||||
|
||||
idev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time,
|
||||
&at91_adc_trigger_handler,
|
||||
IRQF_ONESHOT,
|
||||
idev,
|
||||
"%s-consumer%d",
|
||||
idev->name,
|
||||
idev->id);
|
||||
if (idev->pollfunc == NULL) {
|
||||
ret = -ENOMEM;
|
||||
goto error_pollfunc;
|
||||
}
|
||||
|
||||
idev->setup_ops = &at91_adc_buffer_ops;
|
||||
idev->modes |= INDIO_BUFFER_TRIGGERED;
|
||||
|
||||
ret = iio_buffer_register(idev,
|
||||
idev->channels,
|
||||
idev->num_channels);
|
||||
if (ret)
|
||||
goto error_register;
|
||||
|
||||
return 0;
|
||||
|
||||
error_register:
|
||||
iio_dealloc_pollfunc(idev->pollfunc);
|
||||
error_pollfunc:
|
||||
iio_kfifo_free(idev->buffer);
|
||||
error_ret:
|
||||
return ret;
|
||||
return iio_triggered_buffer_setup(idev, &iio_pollfunc_store_time,
|
||||
&at91_adc_trigger_handler, NULL);
|
||||
}
|
||||
|
||||
static void at91_adc_buffer_remove(struct iio_dev *idev)
|
||||
{
|
||||
iio_buffer_unregister(idev);
|
||||
iio_dealloc_pollfunc(idev->pollfunc);
|
||||
iio_kfifo_free(idev->buffer);
|
||||
iio_triggered_buffer_cleanup(idev);
|
||||
}
|
||||
|
||||
static int at91_adc_read_raw(struct iio_dev *idev,
|
||||
|
@ -392,9 +349,11 @@ static int at91_adc_read_raw(struct iio_dev *idev,
|
|||
st->done,
|
||||
msecs_to_jiffies(1000));
|
||||
if (ret == 0)
|
||||
return -ETIMEDOUT;
|
||||
else if (ret < 0)
|
||||
ret = -ETIMEDOUT;
|
||||
if (ret < 0) {
|
||||
mutex_unlock(&st->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
*val = st->last_value;
|
||||
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
menu "Digital to analog converters"
|
||||
|
||||
config AD5064
|
||||
tristate "Analog Devices AD5064/64-1/65/44/45/24/25, AD5628/48/66/68 DAC driver"
|
||||
depends on SPI
|
||||
tristate "Analog Devices AD5064 and similar multi-channel DAC driver"
|
||||
depends on (SPI_MASTER || I2C)
|
||||
help
|
||||
Say yes here to build support for Analog Devices AD5024, AD5025, AD5044,
|
||||
AD5045, AD5064, AD5064-1, AD5065, AD5628, AD5648, AD5666, AD5668 Digital
|
||||
to Analog Converter.
|
||||
AD5045, AD5064, AD5064-1, AD5065, AD5628, AD5629R, AD5648, AD5666, AD5668,
|
||||
AD5669R Digital to Analog Converter.
|
||||
|
||||
To compile this driver as a module, choose M here: the
|
||||
module will be called ad5064.
|
||||
|
@ -59,9 +59,9 @@ config AD5446
|
|||
tristate "Analog Devices AD5446 and similar single channel DACs driver"
|
||||
depends on SPI
|
||||
help
|
||||
Say yes here to build support for Analog Devices AD5444, AD5446,
|
||||
AD5512A, AD5541A, AD5542A, AD5543, AD5553, AD5601, AD5611, AD5620,
|
||||
AD5621, AD5640, AD5660, AD5662 DACs.
|
||||
Say yes here to build support for Analog Devices AD5444, AD5446, AD5450,
|
||||
AD5451, AD5452, AD5453, AD5512A, AD5541A, AD5542A, AD5543, AD5553, AD5601,
|
||||
AD5611, AD5620, AD5621, AD5640, AD5660, AD5662 DACs.
|
||||
|
||||
To compile this driver as a module, choose M here: the
|
||||
module will be called ad5446.
|
||||
|
@ -118,4 +118,15 @@ config MAX517
|
|||
This driver can also be built as a module. If so, the module
|
||||
will be called max517.
|
||||
|
||||
config MCP4725
|
||||
tristate "MCP4725 DAC driver"
|
||||
depends on I2C
|
||||
---help---
|
||||
Say Y here if you want to build a driver for the Microchip
|
||||
MCP 4725 12-bit digital-to-analog converter (DAC) with I2C
|
||||
interface.
|
||||
|
||||
To compile this driver as a module, choose M here: the module
|
||||
will be called mcp4725.
|
||||
|
||||
endmenu
|
|
@ -13,3 +13,4 @@ obj-$(CONFIG_AD5764) += ad5764.o
|
|||
obj-$(CONFIG_AD5791) += ad5791.o
|
||||
obj-$(CONFIG_AD5686) += ad5686.o
|
||||
obj-$(CONFIG_MAX517) += max517.o
|
||||
obj-$(CONFIG_MCP4725) += mcp4725.o
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* AD5024, AD5025, AD5044, AD5045, AD5064, AD5064-1, AD5065, AD5628, AD5648,
|
||||
* AD5666, AD5668 Digital to analog converters driver
|
||||
* AD5024, AD5025, AD5044, AD5045, AD5064, AD5064-1, AD5065, AD5628, AD5629R,
|
||||
* AD5648, AD5666, AD5668, AD5669R Digital to analog converters driver
|
||||
*
|
||||
* Copyright 2011 Analog Devices Inc.
|
||||
*
|
||||
|
@ -12,13 +12,14 @@
|
|||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/spi/spi.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/sysfs.h>
|
||||
#include <linux/regulator/consumer.h>
|
||||
#include <asm/unaligned.h>
|
||||
|
||||
#include <linux/iio/iio.h>
|
||||
#include <linux/iio/sysfs.h>
|
||||
#include "dac.h"
|
||||
|
||||
#define AD5064_MAX_DAC_CHANNELS 8
|
||||
#define AD5064_MAX_VREFS 4
|
||||
|
@ -63,9 +64,14 @@ struct ad5064_chip_info {
|
|||
unsigned int num_channels;
|
||||
};
|
||||
|
||||
struct ad5064_state;
|
||||
|
||||
typedef int (*ad5064_write_func)(struct ad5064_state *st, unsigned int cmd,
|
||||
unsigned int addr, unsigned int val);
|
||||
|
||||
/**
|
||||
* struct ad5064_state - driver instance specific data
|
||||
* @spi: spi_device
|
||||
* @dev: the device for this driver instance
|
||||
* @chip_info: chip model specific constants, available modes etc
|
||||
* @vref_reg: vref supply regulators
|
||||
* @pwr_down: whether channel is powered down
|
||||
|
@ -73,11 +79,12 @@ struct ad5064_chip_info {
|
|||
* @dac_cache: current DAC raw value (chip does not support readback)
|
||||
* @use_internal_vref: set to true if the internal reference voltage should be
|
||||
* used.
|
||||
* @data: spi transfer buffers
|
||||
* @write: register write callback
|
||||
* @data: i2c/spi transfer buffers
|
||||
*/
|
||||
|
||||
struct ad5064_state {
|
||||
struct spi_device *spi;
|
||||
struct device *dev;
|
||||
const struct ad5064_chip_info *chip_info;
|
||||
struct regulator_bulk_data vref_reg[AD5064_MAX_VREFS];
|
||||
bool pwr_down[AD5064_MAX_DAC_CHANNELS];
|
||||
|
@ -85,11 +92,16 @@ struct ad5064_state {
|
|||
unsigned int dac_cache[AD5064_MAX_DAC_CHANNELS];
|
||||
bool use_internal_vref;
|
||||
|
||||
ad5064_write_func write;
|
||||
|
||||
/*
|
||||
* DMA (thus cache coherency maintenance) requires the
|
||||
* transfer buffers to live in their own cache lines.
|
||||
*/
|
||||
__be32 data ____cacheline_aligned;
|
||||
union {
|
||||
u8 i2c[3];
|
||||
__be32 spi;
|
||||
} data ____cacheline_aligned;
|
||||
};
|
||||
|
||||
enum ad5064_type {
|
||||
|
@ -110,14 +122,12 @@ enum ad5064_type {
|
|||
ID_AD5668_2,
|
||||
};
|
||||
|
||||
static int ad5064_spi_write(struct ad5064_state *st, unsigned int cmd,
|
||||
static int ad5064_write(struct ad5064_state *st, unsigned int cmd,
|
||||
unsigned int addr, unsigned int val, unsigned int shift)
|
||||
{
|
||||
val <<= shift;
|
||||
|
||||
st->data = cpu_to_be32(AD5064_CMD(cmd) | AD5064_ADDR(addr) | val);
|
||||
|
||||
return spi_write(st->spi, &st->data, sizeof(st->data));
|
||||
return st->write(st, cmd, addr, val);
|
||||
}
|
||||
|
||||
static int ad5064_sync_powerdown_mode(struct ad5064_state *st,
|
||||
|
@ -131,62 +141,47 @@ static int ad5064_sync_powerdown_mode(struct ad5064_state *st,
|
|||
if (st->pwr_down[channel])
|
||||
val |= st->pwr_down_mode[channel] << 8;
|
||||
|
||||
ret = ad5064_spi_write(st, AD5064_CMD_POWERDOWN_DAC, 0, val, 0);
|
||||
ret = ad5064_write(st, AD5064_CMD_POWERDOWN_DAC, 0, val, 0);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const char ad5064_powerdown_modes[][15] = {
|
||||
[AD5064_LDAC_PWRDN_NONE] = "",
|
||||
[AD5064_LDAC_PWRDN_1K] = "1kohm_to_gnd",
|
||||
[AD5064_LDAC_PWRDN_100K] = "100kohm_to_gnd",
|
||||
[AD5064_LDAC_PWRDN_3STATE] = "three_state",
|
||||
static const char * const ad5064_powerdown_modes[] = {
|
||||
"1kohm_to_gnd",
|
||||
"100kohm_to_gnd",
|
||||
"three_state",
|
||||
};
|
||||
|
||||
static ssize_t ad5064_read_powerdown_mode_available(struct iio_dev *indio_dev,
|
||||
uintptr_t private, const struct iio_chan_spec *chan, char *buf)
|
||||
{
|
||||
return sprintf(buf, "%s %s %s\n", ad5064_powerdown_modes[1],
|
||||
ad5064_powerdown_modes[2], ad5064_powerdown_modes[3]);
|
||||
}
|
||||
|
||||
static ssize_t ad5064_read_powerdown_mode(struct iio_dev *indio_dev,
|
||||
uintptr_t private, const struct iio_chan_spec *chan, char *buf)
|
||||
static int ad5064_get_powerdown_mode(struct iio_dev *indio_dev,
|
||||
const struct iio_chan_spec *chan)
|
||||
{
|
||||
struct ad5064_state *st = iio_priv(indio_dev);
|
||||
|
||||
return sprintf(buf, "%s\n",
|
||||
ad5064_powerdown_modes[st->pwr_down_mode[chan->channel]]);
|
||||
return st->pwr_down_mode[chan->channel] - 1;
|
||||
}
|
||||
|
||||
static ssize_t ad5064_write_powerdown_mode(struct iio_dev *indio_dev,
|
||||
uintptr_t private, const struct iio_chan_spec *chan, const char *buf,
|
||||
size_t len)
|
||||
static int ad5064_set_powerdown_mode(struct iio_dev *indio_dev,
|
||||
const struct iio_chan_spec *chan, unsigned int mode)
|
||||
{
|
||||
struct ad5064_state *st = iio_priv(indio_dev);
|
||||
unsigned int mode, i;
|
||||
int ret;
|
||||
|
||||
mode = 0;
|
||||
|
||||
for (i = 1; i < ARRAY_SIZE(ad5064_powerdown_modes); ++i) {
|
||||
if (sysfs_streq(buf, ad5064_powerdown_modes[i])) {
|
||||
mode = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (mode == 0)
|
||||
return -EINVAL;
|
||||
|
||||
mutex_lock(&indio_dev->mlock);
|
||||
st->pwr_down_mode[chan->channel] = mode;
|
||||
st->pwr_down_mode[chan->channel] = mode + 1;
|
||||
|
||||
ret = ad5064_sync_powerdown_mode(st, chan->channel);
|
||||
mutex_unlock(&indio_dev->mlock);
|
||||
|
||||
return ret ? ret : len;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const struct iio_enum ad5064_powerdown_mode_enum = {
|
||||
.items = ad5064_powerdown_modes,
|
||||
.num_items = ARRAY_SIZE(ad5064_powerdown_modes),
|
||||
.get = ad5064_get_powerdown_mode,
|
||||
.set = ad5064_set_powerdown_mode,
|
||||
};
|
||||
|
||||
static ssize_t ad5064_read_dac_powerdown(struct iio_dev *indio_dev,
|
||||
uintptr_t private, const struct iio_chan_spec *chan, char *buf)
|
||||
{
|
||||
|
@ -267,7 +262,7 @@ static int ad5064_write_raw(struct iio_dev *indio_dev,
|
|||
return -EINVAL;
|
||||
|
||||
mutex_lock(&indio_dev->mlock);
|
||||
ret = ad5064_spi_write(st, AD5064_CMD_WRITE_INPUT_N_UPDATE_N,
|
||||
ret = ad5064_write(st, AD5064_CMD_WRITE_INPUT_N_UPDATE_N,
|
||||
chan->address, val, chan->scan_type.shift);
|
||||
if (ret == 0)
|
||||
st->dac_cache[chan->channel] = val;
|
||||
|
@ -286,22 +281,14 @@ static const struct iio_info ad5064_info = {
|
|||
.driver_module = THIS_MODULE,
|
||||
};
|
||||
|
||||
static struct iio_chan_spec_ext_info ad5064_ext_info[] = {
|
||||
static const struct iio_chan_spec_ext_info ad5064_ext_info[] = {
|
||||
{
|
||||
.name = "powerdown",
|
||||
.read = ad5064_read_dac_powerdown,
|
||||
.write = ad5064_write_dac_powerdown,
|
||||
},
|
||||
{
|
||||
.name = "powerdown_mode",
|
||||
.read = ad5064_read_powerdown_mode,
|
||||
.write = ad5064_write_powerdown_mode,
|
||||
},
|
||||
{
|
||||
.name = "powerdown_mode_available",
|
||||
.shared = true,
|
||||
.read = ad5064_read_powerdown_mode_available,
|
||||
},
|
||||
IIO_ENUM("powerdown_mode", false, &ad5064_powerdown_mode_enum),
|
||||
IIO_ENUM_AVAILABLE("powerdown_mode", &ad5064_powerdown_mode_enum),
|
||||
{ },
|
||||
};
|
||||
|
||||
|
@ -437,9 +424,9 @@ static const char * const ad5064_vref_name(struct ad5064_state *st,
|
|||
return st->chip_info->shared_vref ? "vref" : ad5064_vref_names[vref];
|
||||
}
|
||||
|
||||
static int __devinit ad5064_probe(struct spi_device *spi)
|
||||
static int __devinit ad5064_probe(struct device *dev, enum ad5064_type type,
|
||||
const char *name, ad5064_write_func write)
|
||||
{
|
||||
enum ad5064_type type = spi_get_device_id(spi)->driver_data;
|
||||
struct iio_dev *indio_dev;
|
||||
struct ad5064_state *st;
|
||||
unsigned int i;
|
||||
|
@ -450,24 +437,25 @@ static int __devinit ad5064_probe(struct spi_device *spi)
|
|||
return -ENOMEM;
|
||||
|
||||
st = iio_priv(indio_dev);
|
||||
spi_set_drvdata(spi, indio_dev);
|
||||
dev_set_drvdata(dev, indio_dev);
|
||||
|
||||
st->chip_info = &ad5064_chip_info_tbl[type];
|
||||
st->spi = spi;
|
||||
st->dev = dev;
|
||||
st->write = write;
|
||||
|
||||
for (i = 0; i < ad5064_num_vref(st); ++i)
|
||||
st->vref_reg[i].supply = ad5064_vref_name(st, i);
|
||||
|
||||
ret = regulator_bulk_get(&st->spi->dev, ad5064_num_vref(st),
|
||||
ret = regulator_bulk_get(dev, ad5064_num_vref(st),
|
||||
st->vref_reg);
|
||||
if (ret) {
|
||||
if (!st->chip_info->internal_vref)
|
||||
goto error_free;
|
||||
st->use_internal_vref = true;
|
||||
ret = ad5064_spi_write(st, AD5064_CMD_CONFIG, 0,
|
||||
ret = ad5064_write(st, AD5064_CMD_CONFIG, 0,
|
||||
AD5064_CONFIG_INT_VREF_ENABLE, 0);
|
||||
if (ret) {
|
||||
dev_err(&spi->dev, "Failed to enable internal vref: %d\n",
|
||||
dev_err(dev, "Failed to enable internal vref: %d\n",
|
||||
ret);
|
||||
goto error_free;
|
||||
}
|
||||
|
@ -482,8 +470,8 @@ static int __devinit ad5064_probe(struct spi_device *spi)
|
|||
st->dac_cache[i] = 0x8000;
|
||||
}
|
||||
|
||||
indio_dev->dev.parent = &spi->dev;
|
||||
indio_dev->name = spi_get_device_id(spi)->name;
|
||||
indio_dev->dev.parent = dev;
|
||||
indio_dev->name = name;
|
||||
indio_dev->info = &ad5064_info;
|
||||
indio_dev->modes = INDIO_DIRECT_MODE;
|
||||
indio_dev->channels = st->chip_info->channels;
|
||||
|
@ -507,10 +495,9 @@ static int __devinit ad5064_probe(struct spi_device *spi)
|
|||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static int __devexit ad5064_remove(struct spi_device *spi)
|
||||
static int __devexit ad5064_remove(struct device *dev)
|
||||
{
|
||||
struct iio_dev *indio_dev = spi_get_drvdata(spi);
|
||||
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||
struct ad5064_state *st = iio_priv(indio_dev);
|
||||
|
||||
iio_device_unregister(indio_dev);
|
||||
|
@ -525,7 +512,31 @@ static int __devexit ad5064_remove(struct spi_device *spi)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static const struct spi_device_id ad5064_id[] = {
|
||||
#if IS_ENABLED(CONFIG_SPI_MASTER)
|
||||
|
||||
static int ad5064_spi_write(struct ad5064_state *st, unsigned int cmd,
|
||||
unsigned int addr, unsigned int val)
|
||||
{
|
||||
struct spi_device *spi = to_spi_device(st->dev);
|
||||
|
||||
st->data.spi = cpu_to_be32(AD5064_CMD(cmd) | AD5064_ADDR(addr) | val);
|
||||
return spi_write(spi, &st->data.spi, sizeof(st->data.spi));
|
||||
}
|
||||
|
||||
static int __devinit ad5064_spi_probe(struct spi_device *spi)
|
||||
{
|
||||
const struct spi_device_id *id = spi_get_device_id(spi);
|
||||
|
||||
return ad5064_probe(&spi->dev, id->driver_data, id->name,
|
||||
ad5064_spi_write);
|
||||
}
|
||||
|
||||
static int __devexit ad5064_spi_remove(struct spi_device *spi)
|
||||
{
|
||||
return ad5064_remove(&spi->dev);
|
||||
}
|
||||
|
||||
static const struct spi_device_id ad5064_spi_ids[] = {
|
||||
{"ad5024", ID_AD5024},
|
||||
{"ad5025", ID_AD5025},
|
||||
{"ad5044", ID_AD5044},
|
||||
|
@ -544,19 +555,122 @@ static const struct spi_device_id ad5064_id[] = {
|
|||
{"ad5668-3", ID_AD5668_2}, /* similar enough to ad5668-2 */
|
||||
{}
|
||||
};
|
||||
MODULE_DEVICE_TABLE(spi, ad5064_id);
|
||||
MODULE_DEVICE_TABLE(spi, ad5064_spi_ids);
|
||||
|
||||
static struct spi_driver ad5064_driver = {
|
||||
static struct spi_driver ad5064_spi_driver = {
|
||||
.driver = {
|
||||
.name = "ad5064",
|
||||
.owner = THIS_MODULE,
|
||||
},
|
||||
.probe = ad5064_probe,
|
||||
.remove = __devexit_p(ad5064_remove),
|
||||
.id_table = ad5064_id,
|
||||
.probe = ad5064_spi_probe,
|
||||
.remove = __devexit_p(ad5064_spi_remove),
|
||||
.id_table = ad5064_spi_ids,
|
||||
};
|
||||
module_spi_driver(ad5064_driver);
|
||||
|
||||
static int __init ad5064_spi_register_driver(void)
|
||||
{
|
||||
return spi_register_driver(&ad5064_spi_driver);
|
||||
}
|
||||
|
||||
static void ad5064_spi_unregister_driver(void)
|
||||
{
|
||||
spi_unregister_driver(&ad5064_spi_driver);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static inline int ad5064_spi_register_driver(void) { return 0; }
|
||||
static inline void ad5064_spi_unregister_driver(void) { }
|
||||
|
||||
#endif
|
||||
|
||||
#if IS_ENABLED(CONFIG_I2C)
|
||||
|
||||
static int ad5064_i2c_write(struct ad5064_state *st, unsigned int cmd,
|
||||
unsigned int addr, unsigned int val)
|
||||
{
|
||||
struct i2c_client *i2c = to_i2c_client(st->dev);
|
||||
|
||||
st->data.i2c[0] = (cmd << 4) | addr;
|
||||
put_unaligned_be16(val, &st->data.i2c[1]);
|
||||
return i2c_master_send(i2c, st->data.i2c, 3);
|
||||
}
|
||||
|
||||
static int __devinit ad5064_i2c_probe(struct i2c_client *i2c,
|
||||
const struct i2c_device_id *id)
|
||||
{
|
||||
return ad5064_probe(&i2c->dev, id->driver_data, id->name,
|
||||
ad5064_i2c_write);
|
||||
}
|
||||
|
||||
static int __devexit ad5064_i2c_remove(struct i2c_client *i2c)
|
||||
{
|
||||
return ad5064_remove(&i2c->dev);
|
||||
}
|
||||
|
||||
static const struct i2c_device_id ad5064_i2c_ids[] = {
|
||||
{"ad5629-1", ID_AD5628_1},
|
||||
{"ad5629-2", ID_AD5628_2},
|
||||
{"ad5629-3", ID_AD5628_2}, /* similar enough to ad5629-2 */
|
||||
{"ad5669-1", ID_AD5668_1},
|
||||
{"ad5669-2", ID_AD5668_2},
|
||||
{"ad5669-3", ID_AD5668_2}, /* similar enough to ad5669-2 */
|
||||
{}
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, ad5064_i2c_ids);
|
||||
|
||||
static struct i2c_driver ad5064_i2c_driver = {
|
||||
.driver = {
|
||||
.name = "ad5064",
|
||||
.owner = THIS_MODULE,
|
||||
},
|
||||
.probe = ad5064_i2c_probe,
|
||||
.remove = __devexit_p(ad5064_i2c_remove),
|
||||
.id_table = ad5064_i2c_ids,
|
||||
};
|
||||
|
||||
static int __init ad5064_i2c_register_driver(void)
|
||||
{
|
||||
return i2c_add_driver(&ad5064_i2c_driver);
|
||||
}
|
||||
|
||||
static void __exit ad5064_i2c_unregister_driver(void)
|
||||
{
|
||||
i2c_del_driver(&ad5064_i2c_driver);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static inline int ad5064_i2c_register_driver(void) { return 0; }
|
||||
static inline void ad5064_i2c_unregister_driver(void) { }
|
||||
|
||||
#endif
|
||||
|
||||
static int __init ad5064_init(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = ad5064_spi_register_driver();
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = ad5064_i2c_register_driver();
|
||||
if (ret) {
|
||||
ad5064_spi_unregister_driver();
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
module_init(ad5064_init);
|
||||
|
||||
static void __exit ad5064_exit(void)
|
||||
{
|
||||
ad5064_i2c_unregister_driver();
|
||||
ad5064_spi_unregister_driver();
|
||||
}
|
||||
module_exit(ad5064_exit);
|
||||
|
||||
MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
|
||||
MODULE_DESCRIPTION("Analog Devices AD5024/25/44/45/64/64-1/65, AD5628/48/66/68 DAC");
|
||||
MODULE_DESCRIPTION("Analog Devices AD5024 and similar multi-channel DACs");
|
||||
MODULE_LICENSE("GPL v2");
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
#include <linux/iio/iio.h>
|
||||
#include <linux/iio/sysfs.h>
|
||||
#include "dac.h"
|
||||
|
||||
#define AD5360_CMD(x) ((x) << 22)
|
||||
#define AD5360_ADDR(x) ((x) << 16)
|
|
@ -20,8 +20,6 @@
|
|||
|
||||
#include <linux/iio/iio.h>
|
||||
#include <linux/iio/sysfs.h>
|
||||
#include "dac.h"
|
||||
|
||||
|
||||
#define AD5380_REG_DATA(x) (((x) << 2) | 3)
|
||||
#define AD5380_REG_OFFSET(x) (((x) << 2) | 2)
|
||||
|
@ -81,103 +79,18 @@ enum ad5380_type {
|
|||
ID_AD5392_5,
|
||||
};
|
||||
|
||||
#define AD5380_CHANNEL(_bits) { \
|
||||
.type = IIO_VOLTAGE, \
|
||||
.indexed = 1, \
|
||||
.output = 1, \
|
||||
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
|
||||
IIO_CHAN_INFO_SCALE_SHARED_BIT | \
|
||||
IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT | \
|
||||
IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT, \
|
||||
.scan_type = IIO_ST('u', (_bits), 16, 14 - (_bits)) \
|
||||
}
|
||||
|
||||
static const struct ad5380_chip_info ad5380_chip_info_tbl[] = {
|
||||
[ID_AD5380_3] = {
|
||||
.channel_template = AD5380_CHANNEL(14),
|
||||
.num_channels = 40,
|
||||
.int_vref = 1250000,
|
||||
},
|
||||
[ID_AD5380_5] = {
|
||||
.channel_template = AD5380_CHANNEL(14),
|
||||
.num_channels = 40,
|
||||
.int_vref = 2500000,
|
||||
},
|
||||
[ID_AD5381_3] = {
|
||||
.channel_template = AD5380_CHANNEL(12),
|
||||
.num_channels = 16,
|
||||
.int_vref = 1250000,
|
||||
},
|
||||
[ID_AD5381_5] = {
|
||||
.channel_template = AD5380_CHANNEL(12),
|
||||
.num_channels = 16,
|
||||
.int_vref = 2500000,
|
||||
},
|
||||
[ID_AD5382_3] = {
|
||||
.channel_template = AD5380_CHANNEL(14),
|
||||
.num_channels = 32,
|
||||
.int_vref = 1250000,
|
||||
},
|
||||
[ID_AD5382_5] = {
|
||||
.channel_template = AD5380_CHANNEL(14),
|
||||
.num_channels = 32,
|
||||
.int_vref = 2500000,
|
||||
},
|
||||
[ID_AD5383_3] = {
|
||||
.channel_template = AD5380_CHANNEL(12),
|
||||
.num_channels = 32,
|
||||
.int_vref = 1250000,
|
||||
},
|
||||
[ID_AD5383_5] = {
|
||||
.channel_template = AD5380_CHANNEL(12),
|
||||
.num_channels = 32,
|
||||
.int_vref = 2500000,
|
||||
},
|
||||
[ID_AD5390_3] = {
|
||||
.channel_template = AD5380_CHANNEL(14),
|
||||
.num_channels = 16,
|
||||
.int_vref = 1250000,
|
||||
},
|
||||
[ID_AD5390_5] = {
|
||||
.channel_template = AD5380_CHANNEL(14),
|
||||
.num_channels = 16,
|
||||
.int_vref = 2500000,
|
||||
},
|
||||
[ID_AD5391_3] = {
|
||||
.channel_template = AD5380_CHANNEL(12),
|
||||
.num_channels = 16,
|
||||
.int_vref = 1250000,
|
||||
},
|
||||
[ID_AD5391_5] = {
|
||||
.channel_template = AD5380_CHANNEL(12),
|
||||
.num_channels = 16,
|
||||
.int_vref = 2500000,
|
||||
},
|
||||
[ID_AD5392_3] = {
|
||||
.channel_template = AD5380_CHANNEL(14),
|
||||
.num_channels = 8,
|
||||
.int_vref = 1250000,
|
||||
},
|
||||
[ID_AD5392_5] = {
|
||||
.channel_template = AD5380_CHANNEL(14),
|
||||
.num_channels = 8,
|
||||
.int_vref = 2500000,
|
||||
},
|
||||
};
|
||||
|
||||
static ssize_t ad5380_read_dac_powerdown(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
static ssize_t ad5380_read_dac_powerdown(struct iio_dev *indio_dev,
|
||||
uintptr_t private, const struct iio_chan_spec *chan, char *buf)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct ad5380_state *st = iio_priv(indio_dev);
|
||||
|
||||
return sprintf(buf, "%d\n", st->pwr_down);
|
||||
}
|
||||
|
||||
static ssize_t ad5380_write_dac_powerdown(struct device *dev,
|
||||
struct device_attribute *attr, const char *buf, size_t len)
|
||||
static ssize_t ad5380_write_dac_powerdown(struct iio_dev *indio_dev,
|
||||
uintptr_t private, const struct iio_chan_spec *chan, const char *buf,
|
||||
size_t len)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct ad5380_state *st = iio_priv(indio_dev);
|
||||
bool pwr_down;
|
||||
int ret;
|
||||
|
@ -200,20 +113,14 @@ static ssize_t ad5380_write_dac_powerdown(struct device *dev,
|
|||
return ret ? ret : len;
|
||||
}
|
||||
|
||||
static IIO_DEVICE_ATTR(out_voltage_powerdown,
|
||||
S_IRUGO | S_IWUSR,
|
||||
ad5380_read_dac_powerdown,
|
||||
ad5380_write_dac_powerdown, 0);
|
||||
|
||||
static const char ad5380_powerdown_modes[][15] = {
|
||||
[0] = "100kohm_to_gnd",
|
||||
[1] = "three_state",
|
||||
static const char * const ad5380_powerdown_modes[] = {
|
||||
"100kohm_to_gnd",
|
||||
"three_state",
|
||||
};
|
||||
|
||||
static ssize_t ad5380_read_powerdown_mode(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
static int ad5380_get_powerdown_mode(struct iio_dev *indio_dev,
|
||||
const struct iio_chan_spec *chan)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct ad5380_state *st = iio_priv(indio_dev);
|
||||
unsigned int mode;
|
||||
int ret;
|
||||
|
@ -224,49 +131,27 @@ static ssize_t ad5380_read_powerdown_mode(struct device *dev,
|
|||
|
||||
mode = (mode >> AD5380_CTRL_PWR_DOWN_MODE_OFFSET) & 1;
|
||||
|
||||
return sprintf(buf, "%s\n", ad5380_powerdown_modes[mode]);
|
||||
return mode;
|
||||
}
|
||||
|
||||
static ssize_t ad5380_write_powerdown_mode(struct device *dev,
|
||||
struct device_attribute *attr, const char *buf, size_t len)
|
||||
static int ad5380_set_powerdown_mode(struct iio_dev *indio_dev,
|
||||
const struct iio_chan_spec *chan, unsigned int mode)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct ad5380_state *st = iio_priv(indio_dev);
|
||||
unsigned int i;
|
||||
int ret;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(ad5380_powerdown_modes); ++i) {
|
||||
if (sysfs_streq(buf, ad5380_powerdown_modes[i]))
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == ARRAY_SIZE(ad5380_powerdown_modes))
|
||||
return -EINVAL;
|
||||
|
||||
ret = regmap_update_bits(st->regmap, AD5380_REG_SF_CTRL,
|
||||
1 << AD5380_CTRL_PWR_DOWN_MODE_OFFSET,
|
||||
i << AD5380_CTRL_PWR_DOWN_MODE_OFFSET);
|
||||
mode << AD5380_CTRL_PWR_DOWN_MODE_OFFSET);
|
||||
|
||||
return ret ? ret : len;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static IIO_DEVICE_ATTR(out_voltage_powerdown_mode,
|
||||
S_IRUGO | S_IWUSR,
|
||||
ad5380_read_powerdown_mode,
|
||||
ad5380_write_powerdown_mode, 0);
|
||||
|
||||
static IIO_CONST_ATTR(out_voltage_powerdown_mode_available,
|
||||
"100kohm_to_gnd three_state");
|
||||
|
||||
static struct attribute *ad5380_attributes[] = {
|
||||
&iio_dev_attr_out_voltage_powerdown.dev_attr.attr,
|
||||
&iio_dev_attr_out_voltage_powerdown_mode.dev_attr.attr,
|
||||
&iio_const_attr_out_voltage_powerdown_mode_available.dev_attr.attr,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const struct attribute_group ad5380_attribute_group = {
|
||||
.attrs = ad5380_attributes,
|
||||
static const struct iio_enum ad5380_powerdown_mode_enum = {
|
||||
.items = ad5380_powerdown_modes,
|
||||
.num_items = ARRAY_SIZE(ad5380_powerdown_modes),
|
||||
.get = ad5380_get_powerdown_mode,
|
||||
.set = ad5380_set_powerdown_mode,
|
||||
};
|
||||
|
||||
static unsigned int ad5380_info_to_reg(struct iio_chan_spec const *chan,
|
||||
|
@ -354,10 +239,105 @@ static int ad5380_read_raw(struct iio_dev *indio_dev,
|
|||
static const struct iio_info ad5380_info = {
|
||||
.read_raw = ad5380_read_raw,
|
||||
.write_raw = ad5380_write_raw,
|
||||
.attrs = &ad5380_attribute_group,
|
||||
.driver_module = THIS_MODULE,
|
||||
};
|
||||
|
||||
static struct iio_chan_spec_ext_info ad5380_ext_info[] = {
|
||||
{
|
||||
.name = "powerdown",
|
||||
.read = ad5380_read_dac_powerdown,
|
||||
.write = ad5380_write_dac_powerdown,
|
||||
},
|
||||
IIO_ENUM("powerdown_mode", true, &ad5380_powerdown_mode_enum),
|
||||
IIO_ENUM_AVAILABLE("powerdown_mode", &ad5380_powerdown_mode_enum),
|
||||
{ },
|
||||
};
|
||||
|
||||
#define AD5380_CHANNEL(_bits) { \
|
||||
.type = IIO_VOLTAGE, \
|
||||
.indexed = 1, \
|
||||
.output = 1, \
|
||||
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
|
||||
IIO_CHAN_INFO_SCALE_SHARED_BIT | \
|
||||
IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT | \
|
||||
IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT, \
|
||||
.scan_type = IIO_ST('u', (_bits), 16, 14 - (_bits)), \
|
||||
.ext_info = ad5380_ext_info, \
|
||||
}
|
||||
|
||||
static const struct ad5380_chip_info ad5380_chip_info_tbl[] = {
|
||||
[ID_AD5380_3] = {
|
||||
.channel_template = AD5380_CHANNEL(14),
|
||||
.num_channels = 40,
|
||||
.int_vref = 1250000,
|
||||
},
|
||||
[ID_AD5380_5] = {
|
||||
.channel_template = AD5380_CHANNEL(14),
|
||||
.num_channels = 40,
|
||||
.int_vref = 2500000,
|
||||
},
|
||||
[ID_AD5381_3] = {
|
||||
.channel_template = AD5380_CHANNEL(12),
|
||||
.num_channels = 16,
|
||||
.int_vref = 1250000,
|
||||
},
|
||||
[ID_AD5381_5] = {
|
||||
.channel_template = AD5380_CHANNEL(12),
|
||||
.num_channels = 16,
|
||||
.int_vref = 2500000,
|
||||
},
|
||||
[ID_AD5382_3] = {
|
||||
.channel_template = AD5380_CHANNEL(14),
|
||||
.num_channels = 32,
|
||||
.int_vref = 1250000,
|
||||
},
|
||||
[ID_AD5382_5] = {
|
||||
.channel_template = AD5380_CHANNEL(14),
|
||||
.num_channels = 32,
|
||||
.int_vref = 2500000,
|
||||
},
|
||||
[ID_AD5383_3] = {
|
||||
.channel_template = AD5380_CHANNEL(12),
|
||||
.num_channels = 32,
|
||||
.int_vref = 1250000,
|
||||
},
|
||||
[ID_AD5383_5] = {
|
||||
.channel_template = AD5380_CHANNEL(12),
|
||||
.num_channels = 32,
|
||||
.int_vref = 2500000,
|
||||
},
|
||||
[ID_AD5390_3] = {
|
||||
.channel_template = AD5380_CHANNEL(14),
|
||||
.num_channels = 16,
|
||||
.int_vref = 1250000,
|
||||
},
|
||||
[ID_AD5390_5] = {
|
||||
.channel_template = AD5380_CHANNEL(14),
|
||||
.num_channels = 16,
|
||||
.int_vref = 2500000,
|
||||
},
|
||||
[ID_AD5391_3] = {
|
||||
.channel_template = AD5380_CHANNEL(12),
|
||||
.num_channels = 16,
|
||||
.int_vref = 1250000,
|
||||
},
|
||||
[ID_AD5391_5] = {
|
||||
.channel_template = AD5380_CHANNEL(12),
|
||||
.num_channels = 16,
|
||||
.int_vref = 2500000,
|
||||
},
|
||||
[ID_AD5392_3] = {
|
||||
.channel_template = AD5380_CHANNEL(14),
|
||||
.num_channels = 8,
|
||||
.int_vref = 1250000,
|
||||
},
|
||||
[ID_AD5392_5] = {
|
||||
.channel_template = AD5380_CHANNEL(14),
|
||||
.num_channels = 8,
|
||||
.int_vref = 2500000,
|
||||
},
|
||||
};
|
||||
|
||||
static int __devinit ad5380_alloc_channels(struct iio_dev *indio_dev)
|
||||
{
|
||||
struct ad5380_state *st = iio_priv(indio_dev);
|
||||
|
@ -393,7 +373,7 @@ static int __devinit ad5380_probe(struct device *dev, struct regmap *regmap,
|
|||
if (indio_dev == NULL) {
|
||||
dev_err(dev, "Failed to allocate iio device\n");
|
||||
ret = -ENOMEM;
|
||||
goto error_regmap_exit;
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
st = iio_priv(indio_dev);
|
||||
|
@ -456,8 +436,7 @@ static int __devinit ad5380_probe(struct device *dev, struct regmap *regmap,
|
|||
kfree(indio_dev->channels);
|
||||
error_free:
|
||||
iio_device_free(indio_dev);
|
||||
error_regmap_exit:
|
||||
regmap_exit(regmap);
|
||||
error_out:
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -476,7 +455,6 @@ static int __devexit ad5380_remove(struct device *dev)
|
|||
regulator_put(st->vref_reg);
|
||||
}
|
||||
|
||||
regmap_exit(st->regmap);
|
||||
iio_device_free(indio_dev);
|
||||
|
||||
return 0;
|
||||
|
@ -505,7 +483,7 @@ static int __devinit ad5380_spi_probe(struct spi_device *spi)
|
|||
const struct spi_device_id *id = spi_get_device_id(spi);
|
||||
struct regmap *regmap;
|
||||
|
||||
regmap = regmap_init_spi(spi, &ad5380_regmap_config);
|
||||
regmap = devm_regmap_init_spi(spi, &ad5380_regmap_config);
|
||||
|
||||
if (IS_ERR(regmap))
|
||||
return PTR_ERR(regmap);
|
||||
|
@ -579,7 +557,7 @@ static int __devinit ad5380_i2c_probe(struct i2c_client *i2c,
|
|||
{
|
||||
struct regmap *regmap;
|
||||
|
||||
regmap = regmap_init_i2c(i2c, &ad5380_regmap_config);
|
||||
regmap = devm_regmap_init_i2c(i2c, &ad5380_regmap_config);
|
||||
|
||||
if (IS_ERR(regmap))
|
||||
return PTR_ERR(regmap);
|
|
@ -19,8 +19,7 @@
|
|||
#include <linux/iio/iio.h>
|
||||
#include <linux/iio/sysfs.h>
|
||||
#include <linux/iio/events.h>
|
||||
#include "dac.h"
|
||||
#include "ad5421.h"
|
||||
#include <linux/iio/dac/ad5421.h>
|
||||
|
||||
|
||||
#define AD5421_REG_DAC_DATA 0x1
|
|
@ -20,7 +20,6 @@
|
|||
|
||||
#include <linux/iio/iio.h>
|
||||
#include <linux/iio/sysfs.h>
|
||||
#include "dac.h"
|
||||
|
||||
#include "ad5446.h"
|
||||
|
||||
|
@ -42,47 +41,34 @@ static int ad5660_write(struct ad5446_state *st, unsigned val)
|
|||
}
|
||||
|
||||
static const char * const ad5446_powerdown_modes[] = {
|
||||
"", "1kohm_to_gnd", "100kohm_to_gnd", "three_state"
|
||||
"1kohm_to_gnd", "100kohm_to_gnd", "three_state"
|
||||
};
|
||||
|
||||
static ssize_t ad5446_read_powerdown_mode_available(struct iio_dev *indio_dev,
|
||||
uintptr_t private, const struct iio_chan_spec *chan, char *buf)
|
||||
{
|
||||
return sprintf(buf, "%s %s %s\n", ad5446_powerdown_modes[1],
|
||||
ad5446_powerdown_modes[2], ad5446_powerdown_modes[3]);
|
||||
}
|
||||
|
||||
static ssize_t ad5446_write_powerdown_mode(struct iio_dev *indio_dev,
|
||||
uintptr_t private,
|
||||
const struct iio_chan_spec *chan,
|
||||
const char *buf, size_t len)
|
||||
{
|
||||
struct ad5446_state *st = iio_priv(indio_dev);
|
||||
int i;
|
||||
|
||||
for (i = 1; i < ARRAY_SIZE(ad5446_powerdown_modes); i++) {
|
||||
if (sysfs_streq(buf, ad5446_powerdown_modes[i])) {
|
||||
st->pwr_down_mode = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == ARRAY_SIZE(ad5446_powerdown_modes))
|
||||
return -EINVAL;
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
static ssize_t ad5446_read_powerdown_mode(struct iio_dev *indio_dev,
|
||||
uintptr_t private,
|
||||
const struct iio_chan_spec *chan,
|
||||
char *buf)
|
||||
static int ad5446_set_powerdown_mode(struct iio_dev *indio_dev,
|
||||
const struct iio_chan_spec *chan, unsigned int mode)
|
||||
{
|
||||
struct ad5446_state *st = iio_priv(indio_dev);
|
||||
|
||||
return sprintf(buf, "%s\n", ad5446_powerdown_modes[st->pwr_down_mode]);
|
||||
st->pwr_down_mode = mode + 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ad5446_get_powerdown_mode(struct iio_dev *indio_dev,
|
||||
const struct iio_chan_spec *chan)
|
||||
{
|
||||
struct ad5446_state *st = iio_priv(indio_dev);
|
||||
|
||||
return st->pwr_down_mode - 1;
|
||||
}
|
||||
|
||||
static const struct iio_enum ad5446_powerdown_mode_enum = {
|
||||
.items = ad5446_powerdown_modes,
|
||||
.num_items = ARRAY_SIZE(ad5446_powerdown_modes),
|
||||
.get = ad5446_get_powerdown_mode,
|
||||
.set = ad5446_set_powerdown_mode,
|
||||
};
|
||||
|
||||
static ssize_t ad5446_read_dac_powerdown(struct iio_dev *indio_dev,
|
||||
uintptr_t private,
|
||||
const struct iio_chan_spec *chan,
|
||||
|
@ -129,15 +115,9 @@ static const struct iio_chan_spec_ext_info ad5064_ext_info_powerdown[] = {
|
|||
.name = "powerdown",
|
||||
.read = ad5446_read_dac_powerdown,
|
||||
.write = ad5446_write_dac_powerdown,
|
||||
}, {
|
||||
.name = "powerdown_mode",
|
||||
.read = ad5446_read_powerdown_mode,
|
||||
.write = ad5446_write_powerdown_mode,
|
||||
}, {
|
||||
.name = "powerdown_mode_available",
|
||||
.shared = true,
|
||||
.read = ad5446_read_powerdown_mode_available,
|
||||
},
|
||||
IIO_ENUM("powerdown_mode", false, &ad5446_powerdown_mode_enum),
|
||||
IIO_ENUM_AVAILABLE("powerdown_mode", &ad5446_powerdown_mode_enum),
|
||||
{ },
|
||||
};
|
||||
|
||||
|
@ -167,6 +147,14 @@ static const struct ad5446_chip_info ad5446_chip_info_tbl[] = {
|
|||
.channel = AD5446_CHANNEL(14, 16, 0),
|
||||
.write = ad5446_write,
|
||||
},
|
||||
[ID_AD5450] = {
|
||||
.channel = AD5446_CHANNEL(8, 16, 6),
|
||||
.write = ad5446_write,
|
||||
},
|
||||
[ID_AD5451] = {
|
||||
.channel = AD5446_CHANNEL(10, 16, 4),
|
||||
.write = ad5446_write,
|
||||
},
|
||||
[ID_AD5541A] = {
|
||||
.channel = AD5446_CHANNEL(16, 16, 0),
|
||||
.write = ad5446_write,
|
||||
|
@ -321,6 +309,8 @@ static int __devinit ad5446_probe(struct spi_device *spi)
|
|||
indio_dev->channels = &st->chip_info->channel;
|
||||
indio_dev->num_channels = 1;
|
||||
|
||||
st->pwr_down_mode = MODE_PWRDWN_1k;
|
||||
|
||||
if (st->chip_info->int_vref_mv)
|
||||
st->vref_mv = st->chip_info->int_vref_mv;
|
||||
else if (voltage_uv)
|
||||
|
@ -364,6 +354,10 @@ static int ad5446_remove(struct spi_device *spi)
|
|||
static const struct spi_device_id ad5446_id[] = {
|
||||
{"ad5444", ID_AD5444},
|
||||
{"ad5446", ID_AD5446},
|
||||
{"ad5450", ID_AD5450},
|
||||
{"ad5451", ID_AD5451},
|
||||
{"ad5452", ID_AD5444}, /* ad5452 is compatible to the ad5444 */
|
||||
{"ad5453", ID_AD5446}, /* ad5453 is compatible to the ad5446 */
|
||||
{"ad5512a", ID_AD5512A},
|
||||
{"ad5541a", ID_AD5541A},
|
||||
{"ad5542a", ID_AD5541A}, /* ad5541a and ad5542a are compatible */
|
|
@ -71,6 +71,8 @@ struct ad5446_chip_info {
|
|||
enum ad5446_supported_device_ids {
|
||||
ID_AD5444,
|
||||
ID_AD5446,
|
||||
ID_AD5450,
|
||||
ID_AD5451,
|
||||
ID_AD5541A,
|
||||
ID_AD5512A,
|
||||
ID_AD5553,
|
|
@ -19,25 +19,51 @@
|
|||
#include <linux/iio/iio.h>
|
||||
#include <linux/iio/sysfs.h>
|
||||
#include <linux/iio/events.h>
|
||||
#include "dac.h"
|
||||
#include "ad5504.h"
|
||||
#include <linux/iio/dac/ad5504.h>
|
||||
|
||||
#define AD5504_CHANNEL(_chan) { \
|
||||
.type = IIO_VOLTAGE, \
|
||||
.indexed = 1, \
|
||||
.output = 1, \
|
||||
.channel = (_chan), \
|
||||
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
|
||||
IIO_CHAN_INFO_SCALE_SHARED_BIT, \
|
||||
.address = AD5504_ADDR_DAC(_chan), \
|
||||
.scan_type = IIO_ST('u', 12, 16, 0), \
|
||||
}
|
||||
#define AD5505_BITS 12
|
||||
#define AD5504_RES_MASK ((1 << (AD5505_BITS)) - 1)
|
||||
|
||||
static const struct iio_chan_spec ad5504_channels[] = {
|
||||
AD5504_CHANNEL(0),
|
||||
AD5504_CHANNEL(1),
|
||||
AD5504_CHANNEL(2),
|
||||
AD5504_CHANNEL(3),
|
||||
#define AD5504_CMD_READ (1 << 15)
|
||||
#define AD5504_CMD_WRITE (0 << 15)
|
||||
#define AD5504_ADDR(addr) ((addr) << 12)
|
||||
|
||||
/* Registers */
|
||||
#define AD5504_ADDR_NOOP 0
|
||||
#define AD5504_ADDR_DAC(x) ((x) + 1)
|
||||
#define AD5504_ADDR_ALL_DAC 5
|
||||
#define AD5504_ADDR_CTRL 7
|
||||
|
||||
/* Control Register */
|
||||
#define AD5504_DAC_PWR(ch) ((ch) << 2)
|
||||
#define AD5504_DAC_PWRDWN_MODE(mode) ((mode) << 6)
|
||||
#define AD5504_DAC_PWRDN_20K 0
|
||||
#define AD5504_DAC_PWRDN_3STATE 1
|
||||
|
||||
/**
|
||||
* struct ad5446_state - driver instance specific data
|
||||
* @us: spi_device
|
||||
* @reg: supply regulator
|
||||
* @vref_mv: actual reference voltage used
|
||||
* @pwr_down_mask power down mask
|
||||
* @pwr_down_mode current power down mode
|
||||
*/
|
||||
|
||||
struct ad5504_state {
|
||||
struct spi_device *spi;
|
||||
struct regulator *reg;
|
||||
unsigned short vref_mv;
|
||||
unsigned pwr_down_mask;
|
||||
unsigned pwr_down_mode;
|
||||
};
|
||||
|
||||
/**
|
||||
* ad5504_supported_device_ids:
|
||||
*/
|
||||
|
||||
enum ad5504_supported_device_ids {
|
||||
ID_AD5504,
|
||||
ID_AD5501,
|
||||
};
|
||||
|
||||
static int ad5504_spi_write(struct spi_device *spi, u8 addr, u16 val)
|
||||
|
@ -122,67 +148,61 @@ static int ad5504_write_raw(struct iio_dev *indio_dev,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
static ssize_t ad5504_read_powerdown_mode(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
static const char * const ad5504_powerdown_modes[] = {
|
||||
"20kohm_to_gnd",
|
||||
"three_state",
|
||||
};
|
||||
|
||||
static int ad5504_get_powerdown_mode(struct iio_dev *indio_dev,
|
||||
const struct iio_chan_spec *chan)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct ad5504_state *st = iio_priv(indio_dev);
|
||||
|
||||
const char mode[][14] = {"20kohm_to_gnd", "three_state"};
|
||||
|
||||
return sprintf(buf, "%s\n", mode[st->pwr_down_mode]);
|
||||
return st->pwr_down_mode;
|
||||
}
|
||||
|
||||
static ssize_t ad5504_write_powerdown_mode(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t len)
|
||||
static int ad5504_set_powerdown_mode(struct iio_dev *indio_dev,
|
||||
const struct iio_chan_spec *chan, unsigned int mode)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct ad5504_state *st = iio_priv(indio_dev);
|
||||
int ret;
|
||||
|
||||
if (sysfs_streq(buf, "20kohm_to_gnd"))
|
||||
st->pwr_down_mode = AD5504_DAC_PWRDN_20K;
|
||||
else if (sysfs_streq(buf, "three_state"))
|
||||
st->pwr_down_mode = AD5504_DAC_PWRDN_3STATE;
|
||||
else
|
||||
ret = -EINVAL;
|
||||
st->pwr_down_mode = mode;
|
||||
|
||||
return ret ? ret : len;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ssize_t ad5504_read_dac_powerdown(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
static const struct iio_enum ad5504_powerdown_mode_enum = {
|
||||
.items = ad5504_powerdown_modes,
|
||||
.num_items = ARRAY_SIZE(ad5504_powerdown_modes),
|
||||
.get = ad5504_get_powerdown_mode,
|
||||
.set = ad5504_set_powerdown_mode,
|
||||
};
|
||||
|
||||
static ssize_t ad5504_read_dac_powerdown(struct iio_dev *indio_dev,
|
||||
uintptr_t private, const struct iio_chan_spec *chan, char *buf)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct ad5504_state *st = iio_priv(indio_dev);
|
||||
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
|
||||
|
||||
return sprintf(buf, "%d\n",
|
||||
!(st->pwr_down_mask & (1 << this_attr->address)));
|
||||
!(st->pwr_down_mask & (1 << chan->channel)));
|
||||
}
|
||||
|
||||
static ssize_t ad5504_write_dac_powerdown(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t len)
|
||||
static ssize_t ad5504_write_dac_powerdown(struct iio_dev *indio_dev,
|
||||
uintptr_t private, const struct iio_chan_spec *chan, const char *buf,
|
||||
size_t len)
|
||||
{
|
||||
long readin;
|
||||
bool pwr_down;
|
||||
int ret;
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct ad5504_state *st = iio_priv(indio_dev);
|
||||
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
|
||||
|
||||
ret = strict_strtol(buf, 10, &readin);
|
||||
ret = strtobool(buf, &pwr_down);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (readin == 0)
|
||||
st->pwr_down_mask |= (1 << this_attr->address);
|
||||
else if (readin == 1)
|
||||
st->pwr_down_mask &= ~(1 << this_attr->address);
|
||||
if (pwr_down)
|
||||
st->pwr_down_mask |= (1 << chan->channel);
|
||||
else
|
||||
ret = -EINVAL;
|
||||
st->pwr_down_mask &= ~(1 << chan->channel);
|
||||
|
||||
ret = ad5504_spi_write(st->spi, AD5504_ADDR_CTRL,
|
||||
AD5504_DAC_PWRDWN_MODE(st->pwr_down_mode) |
|
||||
|
@ -194,50 +214,6 @@ static ssize_t ad5504_write_dac_powerdown(struct device *dev,
|
|||
return ret ? ret : len;
|
||||
}
|
||||
|
||||
static IIO_DEVICE_ATTR(out_voltage_powerdown_mode, S_IRUGO |
|
||||
S_IWUSR, ad5504_read_powerdown_mode,
|
||||
ad5504_write_powerdown_mode, 0);
|
||||
|
||||
static IIO_CONST_ATTR(out_voltage_powerdown_mode_available,
|
||||
"20kohm_to_gnd three_state");
|
||||
|
||||
#define IIO_DEV_ATTR_DAC_POWERDOWN(_num, _show, _store, _addr) \
|
||||
IIO_DEVICE_ATTR(out_voltage##_num##_powerdown, \
|
||||
S_IRUGO | S_IWUSR, _show, _store, _addr)
|
||||
static IIO_DEV_ATTR_DAC_POWERDOWN(0, ad5504_read_dac_powerdown,
|
||||
ad5504_write_dac_powerdown, 0);
|
||||
static IIO_DEV_ATTR_DAC_POWERDOWN(1, ad5504_read_dac_powerdown,
|
||||
ad5504_write_dac_powerdown, 1);
|
||||
static IIO_DEV_ATTR_DAC_POWERDOWN(2, ad5504_read_dac_powerdown,
|
||||
ad5504_write_dac_powerdown, 2);
|
||||
static IIO_DEV_ATTR_DAC_POWERDOWN(3, ad5504_read_dac_powerdown,
|
||||
ad5504_write_dac_powerdown, 3);
|
||||
|
||||
static struct attribute *ad5504_attributes[] = {
|
||||
&iio_dev_attr_out_voltage0_powerdown.dev_attr.attr,
|
||||
&iio_dev_attr_out_voltage1_powerdown.dev_attr.attr,
|
||||
&iio_dev_attr_out_voltage2_powerdown.dev_attr.attr,
|
||||
&iio_dev_attr_out_voltage3_powerdown.dev_attr.attr,
|
||||
&iio_dev_attr_out_voltage_powerdown_mode.dev_attr.attr,
|
||||
&iio_const_attr_out_voltage_powerdown_mode_available.dev_attr.attr,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const struct attribute_group ad5504_attribute_group = {
|
||||
.attrs = ad5504_attributes,
|
||||
};
|
||||
|
||||
static struct attribute *ad5501_attributes[] = {
|
||||
&iio_dev_attr_out_voltage0_powerdown.dev_attr.attr,
|
||||
&iio_dev_attr_out_voltage_powerdown_mode.dev_attr.attr,
|
||||
&iio_const_attr_out_voltage_powerdown_mode_available.dev_attr.attr,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const struct attribute_group ad5501_attribute_group = {
|
||||
.attrs = ad5501_attributes,
|
||||
};
|
||||
|
||||
static IIO_CONST_ATTR(temp0_thresh_rising_value, "110000");
|
||||
static IIO_CONST_ATTR(temp0_thresh_rising_en, "1");
|
||||
|
||||
|
@ -267,17 +243,38 @@ static irqreturn_t ad5504_event_handler(int irq, void *private)
|
|||
static const struct iio_info ad5504_info = {
|
||||
.write_raw = ad5504_write_raw,
|
||||
.read_raw = ad5504_read_raw,
|
||||
.attrs = &ad5504_attribute_group,
|
||||
.event_attrs = &ad5504_ev_attribute_group,
|
||||
.driver_module = THIS_MODULE,
|
||||
};
|
||||
|
||||
static const struct iio_info ad5501_info = {
|
||||
.write_raw = ad5504_write_raw,
|
||||
.read_raw = ad5504_read_raw,
|
||||
.attrs = &ad5501_attribute_group,
|
||||
.event_attrs = &ad5504_ev_attribute_group,
|
||||
.driver_module = THIS_MODULE,
|
||||
static const struct iio_chan_spec_ext_info ad5504_ext_info[] = {
|
||||
{
|
||||
.name = "powerdown",
|
||||
.read = ad5504_read_dac_powerdown,
|
||||
.write = ad5504_write_dac_powerdown,
|
||||
},
|
||||
IIO_ENUM("powerdown_mode", true, &ad5504_powerdown_mode_enum),
|
||||
IIO_ENUM_AVAILABLE("powerdown_mode", &ad5504_powerdown_mode_enum),
|
||||
{ },
|
||||
};
|
||||
|
||||
#define AD5504_CHANNEL(_chan) { \
|
||||
.type = IIO_VOLTAGE, \
|
||||
.indexed = 1, \
|
||||
.output = 1, \
|
||||
.channel = (_chan), \
|
||||
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
|
||||
IIO_CHAN_INFO_SCALE_SHARED_BIT, \
|
||||
.address = AD5504_ADDR_DAC(_chan), \
|
||||
.scan_type = IIO_ST('u', 12, 16, 0), \
|
||||
.ext_info = ad5504_ext_info, \
|
||||
}
|
||||
|
||||
static const struct iio_chan_spec ad5504_channels[] = {
|
||||
AD5504_CHANNEL(0),
|
||||
AD5504_CHANNEL(1),
|
||||
AD5504_CHANNEL(2),
|
||||
AD5504_CHANNEL(3),
|
||||
};
|
||||
|
||||
static int __devinit ad5504_probe(struct spi_device *spi)
|
||||
|
@ -315,13 +312,11 @@ static int __devinit ad5504_probe(struct spi_device *spi)
|
|||
st->spi = spi;
|
||||
indio_dev->dev.parent = &spi->dev;
|
||||
indio_dev->name = spi_get_device_id(st->spi)->name;
|
||||
if (spi_get_device_id(st->spi)->driver_data == ID_AD5501) {
|
||||
indio_dev->info = &ad5501_info;
|
||||
indio_dev->info = &ad5504_info;
|
||||
if (spi_get_device_id(st->spi)->driver_data == ID_AD5501)
|
||||
indio_dev->num_channels = 1;
|
||||
} else {
|
||||
indio_dev->info = &ad5504_info;
|
||||
else
|
||||
indio_dev->num_channels = 4;
|
||||
}
|
||||
indio_dev->channels = ad5504_channels;
|
||||
indio_dev->modes = INDIO_DIRECT_MODE;
|
||||
|
||||
|
@ -343,7 +338,8 @@ static int __devinit ad5504_probe(struct spi_device *spi)
|
|||
return 0;
|
||||
|
||||
error_free_irq:
|
||||
free_irq(spi->irq, indio_dev);
|
||||
if (spi->irq)
|
||||
free_irq(spi->irq, indio_dev);
|
||||
error_disable_reg:
|
||||
if (!IS_ERR(reg))
|
||||
regulator_disable(reg);
|
|
@ -18,59 +18,9 @@
|
|||
|
||||
#include <linux/iio/iio.h>
|
||||
#include <linux/iio/sysfs.h>
|
||||
#include "dac.h"
|
||||
|
||||
#include "ad5624r.h"
|
||||
|
||||
#define AD5624R_CHANNEL(_chan, _bits) { \
|
||||
.type = IIO_VOLTAGE, \
|
||||
.indexed = 1, \
|
||||
.output = 1, \
|
||||
.channel = (_chan), \
|
||||
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
|
||||
IIO_CHAN_INFO_SCALE_SHARED_BIT, \
|
||||
.address = (_chan), \
|
||||
.scan_type = IIO_ST('u', (_bits), 16, 16 - (_bits)), \
|
||||
}
|
||||
|
||||
#define DECLARE_AD5624R_CHANNELS(_name, _bits) \
|
||||
const struct iio_chan_spec _name##_channels[] = { \
|
||||
AD5624R_CHANNEL(0, _bits), \
|
||||
AD5624R_CHANNEL(1, _bits), \
|
||||
AD5624R_CHANNEL(2, _bits), \
|
||||
AD5624R_CHANNEL(3, _bits), \
|
||||
}
|
||||
|
||||
static DECLARE_AD5624R_CHANNELS(ad5624r, 12);
|
||||
static DECLARE_AD5624R_CHANNELS(ad5644r, 14);
|
||||
static DECLARE_AD5624R_CHANNELS(ad5664r, 16);
|
||||
|
||||
static const struct ad5624r_chip_info ad5624r_chip_info_tbl[] = {
|
||||
[ID_AD5624R3] = {
|
||||
.channels = ad5624r_channels,
|
||||
.int_vref_mv = 1250,
|
||||
},
|
||||
[ID_AD5624R5] = {
|
||||
.channels = ad5624r_channels,
|
||||
.int_vref_mv = 2500,
|
||||
},
|
||||
[ID_AD5644R3] = {
|
||||
.channels = ad5644r_channels,
|
||||
.int_vref_mv = 1250,
|
||||
},
|
||||
[ID_AD5644R5] = {
|
||||
.channels = ad5644r_channels,
|
||||
.int_vref_mv = 2500,
|
||||
},
|
||||
[ID_AD5664R3] = {
|
||||
.channels = ad5664r_channels,
|
||||
.int_vref_mv = 1250,
|
||||
},
|
||||
[ID_AD5664R5] = {
|
||||
.channels = ad5664r_channels,
|
||||
.int_vref_mv = 2500,
|
||||
},
|
||||
};
|
||||
|
||||
static int ad5624r_spi_write(struct spi_device *spi,
|
||||
u8 cmd, u8 addr, u16 val, u8 len)
|
||||
{
|
||||
|
@ -138,69 +88,62 @@ static int ad5624r_write_raw(struct iio_dev *indio_dev,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
static ssize_t ad5624r_read_powerdown_mode(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
static const char * const ad5624r_powerdown_modes[] = {
|
||||
"1kohm_to_gnd",
|
||||
"100kohm_to_gnd",
|
||||
"three_state"
|
||||
};
|
||||
|
||||
static int ad5624r_get_powerdown_mode(struct iio_dev *indio_dev,
|
||||
const struct iio_chan_spec *chan)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct ad5624r_state *st = iio_priv(indio_dev);
|
||||
|
||||
char mode[][15] = {"", "1kohm_to_gnd", "100kohm_to_gnd", "three_state"};
|
||||
|
||||
return sprintf(buf, "%s\n", mode[st->pwr_down_mode]);
|
||||
return st->pwr_down_mode;
|
||||
}
|
||||
|
||||
static ssize_t ad5624r_write_powerdown_mode(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t len)
|
||||
static int ad5624r_set_powerdown_mode(struct iio_dev *indio_dev,
|
||||
const struct iio_chan_spec *chan, unsigned int mode)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct ad5624r_state *st = iio_priv(indio_dev);
|
||||
int ret;
|
||||
|
||||
if (sysfs_streq(buf, "1kohm_to_gnd"))
|
||||
st->pwr_down_mode = AD5624R_LDAC_PWRDN_1K;
|
||||
else if (sysfs_streq(buf, "100kohm_to_gnd"))
|
||||
st->pwr_down_mode = AD5624R_LDAC_PWRDN_100K;
|
||||
else if (sysfs_streq(buf, "three_state"))
|
||||
st->pwr_down_mode = AD5624R_LDAC_PWRDN_3STATE;
|
||||
else
|
||||
ret = -EINVAL;
|
||||
st->pwr_down_mode = mode;
|
||||
|
||||
return ret ? ret : len;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ssize_t ad5624r_read_dac_powerdown(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
static const struct iio_enum ad5624r_powerdown_mode_enum = {
|
||||
.items = ad5624r_powerdown_modes,
|
||||
.num_items = ARRAY_SIZE(ad5624r_powerdown_modes),
|
||||
.get = ad5624r_get_powerdown_mode,
|
||||
.set = ad5624r_set_powerdown_mode,
|
||||
};
|
||||
|
||||
static ssize_t ad5624r_read_dac_powerdown(struct iio_dev *indio_dev,
|
||||
uintptr_t private, const struct iio_chan_spec *chan, char *buf)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct ad5624r_state *st = iio_priv(indio_dev);
|
||||
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
|
||||
|
||||
return sprintf(buf, "%d\n",
|
||||
!!(st->pwr_down_mask & (1 << this_attr->address)));
|
||||
!!(st->pwr_down_mask & (1 << chan->channel)));
|
||||
}
|
||||
|
||||
static ssize_t ad5624r_write_dac_powerdown(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t len)
|
||||
static ssize_t ad5624r_write_dac_powerdown(struct iio_dev *indio_dev,
|
||||
uintptr_t private, const struct iio_chan_spec *chan, const char *buf,
|
||||
size_t len)
|
||||
{
|
||||
long readin;
|
||||
bool pwr_down;
|
||||
int ret;
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct ad5624r_state *st = iio_priv(indio_dev);
|
||||
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
|
||||
|
||||
ret = strict_strtol(buf, 10, &readin);
|
||||
ret = strtobool(buf, &pwr_down);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (readin == 1)
|
||||
st->pwr_down_mask |= (1 << this_attr->address);
|
||||
else if (!readin)
|
||||
st->pwr_down_mask &= ~(1 << this_attr->address);
|
||||
if (pwr_down)
|
||||
st->pwr_down_mask |= (1 << chan->channel);
|
||||
else
|
||||
ret = -EINVAL;
|
||||
st->pwr_down_mask &= ~(1 << chan->channel);
|
||||
|
||||
ret = ad5624r_spi_write(st->us, AD5624R_CMD_POWERDOWN_DAC, 0,
|
||||
(st->pwr_down_mode << 4) |
|
||||
|
@ -209,47 +152,74 @@ static ssize_t ad5624r_write_dac_powerdown(struct device *dev,
|
|||
return ret ? ret : len;
|
||||
}
|
||||
|
||||
static IIO_DEVICE_ATTR(out_voltage_powerdown_mode, S_IRUGO |
|
||||
S_IWUSR, ad5624r_read_powerdown_mode,
|
||||
ad5624r_write_powerdown_mode, 0);
|
||||
|
||||
static IIO_CONST_ATTR(out_voltage_powerdown_mode_available,
|
||||
"1kohm_to_gnd 100kohm_to_gnd three_state");
|
||||
|
||||
#define IIO_DEV_ATTR_DAC_POWERDOWN(_num, _show, _store, _addr) \
|
||||
IIO_DEVICE_ATTR(out_voltage##_num##_powerdown, \
|
||||
S_IRUGO | S_IWUSR, _show, _store, _addr)
|
||||
|
||||
static IIO_DEV_ATTR_DAC_POWERDOWN(0, ad5624r_read_dac_powerdown,
|
||||
ad5624r_write_dac_powerdown, 0);
|
||||
static IIO_DEV_ATTR_DAC_POWERDOWN(1, ad5624r_read_dac_powerdown,
|
||||
ad5624r_write_dac_powerdown, 1);
|
||||
static IIO_DEV_ATTR_DAC_POWERDOWN(2, ad5624r_read_dac_powerdown,
|
||||
ad5624r_write_dac_powerdown, 2);
|
||||
static IIO_DEV_ATTR_DAC_POWERDOWN(3, ad5624r_read_dac_powerdown,
|
||||
ad5624r_write_dac_powerdown, 3);
|
||||
|
||||
static struct attribute *ad5624r_attributes[] = {
|
||||
&iio_dev_attr_out_voltage0_powerdown.dev_attr.attr,
|
||||
&iio_dev_attr_out_voltage1_powerdown.dev_attr.attr,
|
||||
&iio_dev_attr_out_voltage2_powerdown.dev_attr.attr,
|
||||
&iio_dev_attr_out_voltage3_powerdown.dev_attr.attr,
|
||||
&iio_dev_attr_out_voltage_powerdown_mode.dev_attr.attr,
|
||||
&iio_const_attr_out_voltage_powerdown_mode_available.dev_attr.attr,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const struct attribute_group ad5624r_attribute_group = {
|
||||
.attrs = ad5624r_attributes,
|
||||
};
|
||||
|
||||
static const struct iio_info ad5624r_info = {
|
||||
.write_raw = ad5624r_write_raw,
|
||||
.read_raw = ad5624r_read_raw,
|
||||
.attrs = &ad5624r_attribute_group,
|
||||
.driver_module = THIS_MODULE,
|
||||
};
|
||||
|
||||
static const struct iio_chan_spec_ext_info ad5624r_ext_info[] = {
|
||||
{
|
||||
.name = "powerdown",
|
||||
.read = ad5624r_read_dac_powerdown,
|
||||
.write = ad5624r_write_dac_powerdown,
|
||||
},
|
||||
IIO_ENUM("powerdown_mode", true, &ad5624r_powerdown_mode_enum),
|
||||
IIO_ENUM_AVAILABLE("powerdown_mode", &ad5624r_powerdown_mode_enum),
|
||||
{ },
|
||||
};
|
||||
|
||||
#define AD5624R_CHANNEL(_chan, _bits) { \
|
||||
.type = IIO_VOLTAGE, \
|
||||
.indexed = 1, \
|
||||
.output = 1, \
|
||||
.channel = (_chan), \
|
||||
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
|
||||
IIO_CHAN_INFO_SCALE_SHARED_BIT, \
|
||||
.address = (_chan), \
|
||||
.scan_type = IIO_ST('u', (_bits), 16, 16 - (_bits)), \
|
||||
.ext_info = ad5624r_ext_info, \
|
||||
}
|
||||
|
||||
#define DECLARE_AD5624R_CHANNELS(_name, _bits) \
|
||||
const struct iio_chan_spec _name##_channels[] = { \
|
||||
AD5624R_CHANNEL(0, _bits), \
|
||||
AD5624R_CHANNEL(1, _bits), \
|
||||
AD5624R_CHANNEL(2, _bits), \
|
||||
AD5624R_CHANNEL(3, _bits), \
|
||||
}
|
||||
|
||||
static DECLARE_AD5624R_CHANNELS(ad5624r, 12);
|
||||
static DECLARE_AD5624R_CHANNELS(ad5644r, 14);
|
||||
static DECLARE_AD5624R_CHANNELS(ad5664r, 16);
|
||||
|
||||
static const struct ad5624r_chip_info ad5624r_chip_info_tbl[] = {
|
||||
[ID_AD5624R3] = {
|
||||
.channels = ad5624r_channels,
|
||||
.int_vref_mv = 1250,
|
||||
},
|
||||
[ID_AD5624R5] = {
|
||||
.channels = ad5624r_channels,
|
||||
.int_vref_mv = 2500,
|
||||
},
|
||||
[ID_AD5644R3] = {
|
||||
.channels = ad5644r_channels,
|
||||
.int_vref_mv = 1250,
|
||||
},
|
||||
[ID_AD5644R5] = {
|
||||
.channels = ad5644r_channels,
|
||||
.int_vref_mv = 2500,
|
||||
},
|
||||
[ID_AD5664R3] = {
|
||||
.channels = ad5664r_channels,
|
||||
.int_vref_mv = 1250,
|
||||
},
|
||||
[ID_AD5664R5] = {
|
||||
.channels = ad5664r_channels,
|
||||
.int_vref_mv = 2500,
|
||||
},
|
||||
};
|
||||
|
||||
static int __devinit ad5624r_probe(struct spi_device *spi)
|
||||
{
|
||||
struct ad5624r_state *st;
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
#include <linux/iio/iio.h>
|
||||
#include <linux/iio/sysfs.h>
|
||||
#include "dac.h"
|
||||
|
||||
#define AD5686_DAC_CHANNELS 4
|
||||
|
||||
|
@ -93,40 +92,6 @@ enum ad5686_supported_device_ids {
|
|||
ID_AD5685,
|
||||
ID_AD5686,
|
||||
};
|
||||
#define AD5868_CHANNEL(chan, bits, shift) { \
|
||||
.type = IIO_VOLTAGE, \
|
||||
.indexed = 1, \
|
||||
.output = 1, \
|
||||
.channel = chan, \
|
||||
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
|
||||
IIO_CHAN_INFO_SCALE_SHARED_BIT, \
|
||||
.address = AD5686_ADDR_DAC(chan), \
|
||||
.scan_type = IIO_ST('u', bits, 16, shift) \
|
||||
}
|
||||
static const struct ad5686_chip_info ad5686_chip_info_tbl[] = {
|
||||
[ID_AD5684] = {
|
||||
.channel[0] = AD5868_CHANNEL(0, 12, 4),
|
||||
.channel[1] = AD5868_CHANNEL(1, 12, 4),
|
||||
.channel[2] = AD5868_CHANNEL(2, 12, 4),
|
||||
.channel[3] = AD5868_CHANNEL(3, 12, 4),
|
||||
.int_vref_mv = 2500,
|
||||
},
|
||||
[ID_AD5685] = {
|
||||
.channel[0] = AD5868_CHANNEL(0, 14, 2),
|
||||
.channel[1] = AD5868_CHANNEL(1, 14, 2),
|
||||
.channel[2] = AD5868_CHANNEL(2, 14, 2),
|
||||
.channel[3] = AD5868_CHANNEL(3, 14, 2),
|
||||
.int_vref_mv = 2500,
|
||||
},
|
||||
[ID_AD5686] = {
|
||||
.channel[0] = AD5868_CHANNEL(0, 16, 0),
|
||||
.channel[1] = AD5868_CHANNEL(1, 16, 0),
|
||||
.channel[2] = AD5868_CHANNEL(2, 16, 0),
|
||||
.channel[3] = AD5868_CHANNEL(3, 16, 0),
|
||||
.int_vref_mv = 2500,
|
||||
},
|
||||
};
|
||||
|
||||
static int ad5686_spi_write(struct ad5686_state *st,
|
||||
u8 cmd, u8 addr, u16 val, u8 shift)
|
||||
{
|
||||
|
@ -170,73 +135,63 @@ static int ad5686_spi_read(struct ad5686_state *st, u8 addr)
|
|||
return be32_to_cpu(st->data[2].d32);
|
||||
}
|
||||
|
||||
static ssize_t ad5686_read_powerdown_mode(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
static const char * const ad5686_powerdown_modes[] = {
|
||||
"1kohm_to_gnd",
|
||||
"100kohm_to_gnd",
|
||||
"three_state"
|
||||
};
|
||||
|
||||
static int ad5686_get_powerdown_mode(struct iio_dev *indio_dev,
|
||||
const struct iio_chan_spec *chan)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct ad5686_state *st = iio_priv(indio_dev);
|
||||
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
|
||||
|
||||
char mode[][15] = {"", "1kohm_to_gnd", "100kohm_to_gnd", "three_state"};
|
||||
|
||||
return sprintf(buf, "%s\n", mode[(st->pwr_down_mode >>
|
||||
(this_attr->address * 2)) & 0x3]);
|
||||
return ((st->pwr_down_mode >> (chan->channel * 2)) & 0x3) - 1;
|
||||
}
|
||||
|
||||
static ssize_t ad5686_write_powerdown_mode(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t len)
|
||||
static int ad5686_set_powerdown_mode(struct iio_dev *indio_dev,
|
||||
const struct iio_chan_spec *chan, unsigned int mode)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct ad5686_state *st = iio_priv(indio_dev);
|
||||
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
|
||||
unsigned mode;
|
||||
|
||||
if (sysfs_streq(buf, "1kohm_to_gnd"))
|
||||
mode = AD5686_LDAC_PWRDN_1K;
|
||||
else if (sysfs_streq(buf, "100kohm_to_gnd"))
|
||||
mode = AD5686_LDAC_PWRDN_100K;
|
||||
else if (sysfs_streq(buf, "three_state"))
|
||||
mode = AD5686_LDAC_PWRDN_3STATE;
|
||||
else
|
||||
return -EINVAL;
|
||||
st->pwr_down_mode &= ~(0x3 << (chan->channel * 2));
|
||||
st->pwr_down_mode |= ((mode + 1) << (chan->channel * 2));
|
||||
|
||||
st->pwr_down_mode &= ~(0x3 << (this_attr->address * 2));
|
||||
st->pwr_down_mode |= (mode << (this_attr->address * 2));
|
||||
|
||||
return len;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ssize_t ad5686_read_dac_powerdown(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
static const struct iio_enum ad5686_powerdown_mode_enum = {
|
||||
.items = ad5686_powerdown_modes,
|
||||
.num_items = ARRAY_SIZE(ad5686_powerdown_modes),
|
||||
.get = ad5686_get_powerdown_mode,
|
||||
.set = ad5686_set_powerdown_mode,
|
||||
};
|
||||
|
||||
static ssize_t ad5686_read_dac_powerdown(struct iio_dev *indio_dev,
|
||||
uintptr_t private, const struct iio_chan_spec *chan, char *buf)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct ad5686_state *st = iio_priv(indio_dev);
|
||||
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
|
||||
|
||||
return sprintf(buf, "%d\n", !!(st->pwr_down_mask &
|
||||
(0x3 << (this_attr->address * 2))));
|
||||
(0x3 << (chan->channel * 2))));
|
||||
}
|
||||
|
||||
static ssize_t ad5686_write_dac_powerdown(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t len)
|
||||
static ssize_t ad5686_write_dac_powerdown(struct iio_dev *indio_dev,
|
||||
uintptr_t private, const struct iio_chan_spec *chan, const char *buf,
|
||||
size_t len)
|
||||
{
|
||||
bool readin;
|
||||
int ret;
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct ad5686_state *st = iio_priv(indio_dev);
|
||||
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
|
||||
|
||||
ret = strtobool(buf, &readin);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (readin == true)
|
||||
st->pwr_down_mask |= (0x3 << (this_attr->address * 2));
|
||||
st->pwr_down_mask |= (0x3 << (chan->channel * 2));
|
||||
else
|
||||
st->pwr_down_mask &= ~(0x3 << (this_attr->address * 2));
|
||||
st->pwr_down_mask &= ~(0x3 << (chan->channel * 2));
|
||||
|
||||
ret = ad5686_spi_write(st, AD5686_CMD_POWERDOWN_DAC, 0,
|
||||
st->pwr_down_mask & st->pwr_down_mode, 0);
|
||||
|
@ -244,48 +199,6 @@ static ssize_t ad5686_write_dac_powerdown(struct device *dev,
|
|||
return ret ? ret : len;
|
||||
}
|
||||
|
||||
static IIO_CONST_ATTR(out_voltage_powerdown_mode_available,
|
||||
"1kohm_to_gnd 100kohm_to_gnd three_state");
|
||||
|
||||
#define IIO_DEV_ATTR_DAC_POWERDOWN_MODE(_num) \
|
||||
IIO_DEVICE_ATTR(out_voltage##_num##_powerdown_mode, \
|
||||
S_IRUGO | S_IWUSR, \
|
||||
ad5686_read_powerdown_mode, \
|
||||
ad5686_write_powerdown_mode, _num)
|
||||
|
||||
static IIO_DEV_ATTR_DAC_POWERDOWN_MODE(0);
|
||||
static IIO_DEV_ATTR_DAC_POWERDOWN_MODE(1);
|
||||
static IIO_DEV_ATTR_DAC_POWERDOWN_MODE(2);
|
||||
static IIO_DEV_ATTR_DAC_POWERDOWN_MODE(3);
|
||||
|
||||
#define IIO_DEV_ATTR_DAC_POWERDOWN(_num) \
|
||||
IIO_DEVICE_ATTR(out_voltage##_num##_powerdown, \
|
||||
S_IRUGO | S_IWUSR, \
|
||||
ad5686_read_dac_powerdown, \
|
||||
ad5686_write_dac_powerdown, _num)
|
||||
|
||||
static IIO_DEV_ATTR_DAC_POWERDOWN(0);
|
||||
static IIO_DEV_ATTR_DAC_POWERDOWN(1);
|
||||
static IIO_DEV_ATTR_DAC_POWERDOWN(2);
|
||||
static IIO_DEV_ATTR_DAC_POWERDOWN(3);
|
||||
|
||||
static struct attribute *ad5686_attributes[] = {
|
||||
&iio_dev_attr_out_voltage0_powerdown.dev_attr.attr,
|
||||
&iio_dev_attr_out_voltage1_powerdown.dev_attr.attr,
|
||||
&iio_dev_attr_out_voltage2_powerdown.dev_attr.attr,
|
||||
&iio_dev_attr_out_voltage3_powerdown.dev_attr.attr,
|
||||
&iio_dev_attr_out_voltage0_powerdown_mode.dev_attr.attr,
|
||||
&iio_dev_attr_out_voltage1_powerdown_mode.dev_attr.attr,
|
||||
&iio_dev_attr_out_voltage2_powerdown_mode.dev_attr.attr,
|
||||
&iio_dev_attr_out_voltage3_powerdown_mode.dev_attr.attr,
|
||||
&iio_const_attr_out_voltage_powerdown_mode_available.dev_attr.attr,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const struct attribute_group ad5686_attribute_group = {
|
||||
.attrs = ad5686_attributes,
|
||||
};
|
||||
|
||||
static int ad5686_read_raw(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec const *chan,
|
||||
int *val,
|
||||
|
@ -349,10 +262,57 @@ static int ad5686_write_raw(struct iio_dev *indio_dev,
|
|||
static const struct iio_info ad5686_info = {
|
||||
.read_raw = ad5686_read_raw,
|
||||
.write_raw = ad5686_write_raw,
|
||||
.attrs = &ad5686_attribute_group,
|
||||
.driver_module = THIS_MODULE,
|
||||
};
|
||||
|
||||
static const struct iio_chan_spec_ext_info ad5686_ext_info[] = {
|
||||
{
|
||||
.name = "powerdown",
|
||||
.read = ad5686_read_dac_powerdown,
|
||||
.write = ad5686_write_dac_powerdown,
|
||||
},
|
||||
IIO_ENUM("powerdown_mode", false, &ad5686_powerdown_mode_enum),
|
||||
IIO_ENUM_AVAILABLE("powerdown_mode", &ad5686_powerdown_mode_enum),
|
||||
{ },
|
||||
};
|
||||
|
||||
#define AD5868_CHANNEL(chan, bits, shift) { \
|
||||
.type = IIO_VOLTAGE, \
|
||||
.indexed = 1, \
|
||||
.output = 1, \
|
||||
.channel = chan, \
|
||||
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
|
||||
IIO_CHAN_INFO_SCALE_SHARED_BIT, \
|
||||
.address = AD5686_ADDR_DAC(chan), \
|
||||
.scan_type = IIO_ST('u', bits, 16, shift), \
|
||||
.ext_info = ad5686_ext_info, \
|
||||
}
|
||||
|
||||
static const struct ad5686_chip_info ad5686_chip_info_tbl[] = {
|
||||
[ID_AD5684] = {
|
||||
.channel[0] = AD5868_CHANNEL(0, 12, 4),
|
||||
.channel[1] = AD5868_CHANNEL(1, 12, 4),
|
||||
.channel[2] = AD5868_CHANNEL(2, 12, 4),
|
||||
.channel[3] = AD5868_CHANNEL(3, 12, 4),
|
||||
.int_vref_mv = 2500,
|
||||
},
|
||||
[ID_AD5685] = {
|
||||
.channel[0] = AD5868_CHANNEL(0, 14, 2),
|
||||
.channel[1] = AD5868_CHANNEL(1, 14, 2),
|
||||
.channel[2] = AD5868_CHANNEL(2, 14, 2),
|
||||
.channel[3] = AD5868_CHANNEL(3, 14, 2),
|
||||
.int_vref_mv = 2500,
|
||||
},
|
||||
[ID_AD5686] = {
|
||||
.channel[0] = AD5868_CHANNEL(0, 16, 0),
|
||||
.channel[1] = AD5868_CHANNEL(1, 16, 0),
|
||||
.channel[2] = AD5868_CHANNEL(2, 16, 0),
|
||||
.channel[3] = AD5868_CHANNEL(3, 16, 0),
|
||||
.int_vref_mv = 2500,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
static int __devinit ad5686_probe(struct spi_device *spi)
|
||||
{
|
||||
struct ad5686_state *st;
|
||||
|
@ -385,6 +345,9 @@ static int __devinit ad5686_probe(struct spi_device *spi)
|
|||
|
||||
st->spi = spi;
|
||||
|
||||
/* Set all the power down mode for all channels to 1K pulldown */
|
||||
st->pwr_down_mode = 0x55;
|
||||
|
||||
indio_dev->dev.parent = &spi->dev;
|
||||
indio_dev->name = spi_get_device_id(spi)->name;
|
||||
indio_dev->info = &ad5686_info;
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
#include <linux/iio/iio.h>
|
||||
#include <linux/iio/sysfs.h>
|
||||
#include "dac.h"
|
||||
|
||||
#define AD5764_REG_SF_NOP 0x0
|
||||
#define AD5764_REG_SF_CONFIG 0x1
|
|
@ -19,8 +19,90 @@
|
|||
|
||||
#include <linux/iio/iio.h>
|
||||
#include <linux/iio/sysfs.h>
|
||||
#include "dac.h"
|
||||
#include "ad5791.h"
|
||||
#include <linux/iio/dac/ad5791.h>
|
||||
|
||||
#define AD5791_RES_MASK(x) ((1 << (x)) - 1)
|
||||
#define AD5791_DAC_MASK AD5791_RES_MASK(20)
|
||||
#define AD5791_DAC_MSB (1 << 19)
|
||||
|
||||
#define AD5791_CMD_READ (1 << 23)
|
||||
#define AD5791_CMD_WRITE (0 << 23)
|
||||
#define AD5791_ADDR(addr) ((addr) << 20)
|
||||
|
||||
/* Registers */
|
||||
#define AD5791_ADDR_NOOP 0
|
||||
#define AD5791_ADDR_DAC0 1
|
||||
#define AD5791_ADDR_CTRL 2
|
||||
#define AD5791_ADDR_CLRCODE 3
|
||||
#define AD5791_ADDR_SW_CTRL 4
|
||||
|
||||
/* Control Register */
|
||||
#define AD5791_CTRL_RBUF (1 << 1)
|
||||
#define AD5791_CTRL_OPGND (1 << 2)
|
||||
#define AD5791_CTRL_DACTRI (1 << 3)
|
||||
#define AD5791_CTRL_BIN2SC (1 << 4)
|
||||
#define AD5791_CTRL_SDODIS (1 << 5)
|
||||
#define AD5761_CTRL_LINCOMP(x) ((x) << 6)
|
||||
|
||||
#define AD5791_LINCOMP_0_10 0
|
||||
#define AD5791_LINCOMP_10_12 1
|
||||
#define AD5791_LINCOMP_12_16 2
|
||||
#define AD5791_LINCOMP_16_19 3
|
||||
#define AD5791_LINCOMP_19_20 12
|
||||
|
||||
#define AD5780_LINCOMP_0_10 0
|
||||
#define AD5780_LINCOMP_10_20 12
|
||||
|
||||
/* Software Control Register */
|
||||
#define AD5791_SWCTRL_LDAC (1 << 0)
|
||||
#define AD5791_SWCTRL_CLR (1 << 1)
|
||||
#define AD5791_SWCTRL_RESET (1 << 2)
|
||||
|
||||
#define AD5791_DAC_PWRDN_6K 0
|
||||
#define AD5791_DAC_PWRDN_3STATE 1
|
||||
|
||||
/**
|
||||
* struct ad5791_chip_info - chip specific information
|
||||
* @get_lin_comp: function pointer to the device specific function
|
||||
*/
|
||||
|
||||
struct ad5791_chip_info {
|
||||
int (*get_lin_comp) (unsigned int span);
|
||||
};
|
||||
|
||||
/**
|
||||
* struct ad5791_state - driver instance specific data
|
||||
* @us: spi_device
|
||||
* @reg_vdd: positive supply regulator
|
||||
* @reg_vss: negative supply regulator
|
||||
* @chip_info: chip model specific constants
|
||||
* @vref_mv: actual reference voltage used
|
||||
* @vref_neg_mv: voltage of the negative supply
|
||||
* @pwr_down_mode current power down mode
|
||||
*/
|
||||
|
||||
struct ad5791_state {
|
||||
struct spi_device *spi;
|
||||
struct regulator *reg_vdd;
|
||||
struct regulator *reg_vss;
|
||||
const struct ad5791_chip_info *chip_info;
|
||||
unsigned short vref_mv;
|
||||
unsigned int vref_neg_mv;
|
||||
unsigned ctrl;
|
||||
unsigned pwr_down_mode;
|
||||
bool pwr_down;
|
||||
};
|
||||
|
||||
/**
|
||||
* ad5791_supported_device_ids:
|
||||
*/
|
||||
|
||||
enum ad5791_supported_device_ids {
|
||||
ID_AD5760,
|
||||
ID_AD5780,
|
||||
ID_AD5781,
|
||||
ID_AD5791,
|
||||
};
|
||||
|
||||
static int ad5791_spi_write(struct spi_device *spi, u8 addr, u32 val)
|
||||
{
|
||||
|
@ -72,119 +154,71 @@ static int ad5791_spi_read(struct spi_device *spi, u8 addr, u32 *val)
|
|||
return ret;
|
||||
}
|
||||
|
||||
#define AD5791_CHAN(bits, shift) { \
|
||||
.type = IIO_VOLTAGE, \
|
||||
.output = 1, \
|
||||
.indexed = 1, \
|
||||
.address = AD5791_ADDR_DAC0, \
|
||||
.channel = 0, \
|
||||
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
|
||||
IIO_CHAN_INFO_SCALE_SHARED_BIT | \
|
||||
IIO_CHAN_INFO_OFFSET_SHARED_BIT, \
|
||||
.scan_type = IIO_ST('u', bits, 24, shift) \
|
||||
}
|
||||
|
||||
static const struct iio_chan_spec ad5791_channels[] = {
|
||||
[ID_AD5760] = AD5791_CHAN(16, 4),
|
||||
[ID_AD5780] = AD5791_CHAN(18, 2),
|
||||
[ID_AD5781] = AD5791_CHAN(18, 2),
|
||||
[ID_AD5791] = AD5791_CHAN(20, 0)
|
||||
static const char * const ad5791_powerdown_modes[] = {
|
||||
"6kohm_to_gnd",
|
||||
"three_state",
|
||||
};
|
||||
|
||||
static ssize_t ad5791_read_powerdown_mode(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
static int ad5791_get_powerdown_mode(struct iio_dev *indio_dev,
|
||||
const struct iio_chan_spec *chan)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct ad5791_state *st = iio_priv(indio_dev);
|
||||
|
||||
const char mode[][14] = {"6kohm_to_gnd", "three_state"};
|
||||
|
||||
return sprintf(buf, "%s\n", mode[st->pwr_down_mode]);
|
||||
return st->pwr_down_mode;
|
||||
}
|
||||
|
||||
static ssize_t ad5791_write_powerdown_mode(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t len)
|
||||
static int ad5791_set_powerdown_mode(struct iio_dev *indio_dev,
|
||||
const struct iio_chan_spec *chan, unsigned int mode)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct ad5791_state *st = iio_priv(indio_dev);
|
||||
int ret;
|
||||
|
||||
if (sysfs_streq(buf, "6kohm_to_gnd"))
|
||||
st->pwr_down_mode = AD5791_DAC_PWRDN_6K;
|
||||
else if (sysfs_streq(buf, "three_state"))
|
||||
st->pwr_down_mode = AD5791_DAC_PWRDN_3STATE;
|
||||
else
|
||||
ret = -EINVAL;
|
||||
st->pwr_down_mode = mode;
|
||||
|
||||
return ret ? ret : len;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ssize_t ad5791_read_dac_powerdown(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
static const struct iio_enum ad5791_powerdown_mode_enum = {
|
||||
.items = ad5791_powerdown_modes,
|
||||
.num_items = ARRAY_SIZE(ad5791_powerdown_modes),
|
||||
.get = ad5791_get_powerdown_mode,
|
||||
.set = ad5791_set_powerdown_mode,
|
||||
};
|
||||
|
||||
static ssize_t ad5791_read_dac_powerdown(struct iio_dev *indio_dev,
|
||||
uintptr_t private, const struct iio_chan_spec *chan, char *buf)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct ad5791_state *st = iio_priv(indio_dev);
|
||||
|
||||
return sprintf(buf, "%d\n", st->pwr_down);
|
||||
}
|
||||
|
||||
static ssize_t ad5791_write_dac_powerdown(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t len)
|
||||
static ssize_t ad5791_write_dac_powerdown(struct iio_dev *indio_dev,
|
||||
uintptr_t private, const struct iio_chan_spec *chan, const char *buf,
|
||||
size_t len)
|
||||
{
|
||||
long readin;
|
||||
bool pwr_down;
|
||||
int ret;
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct ad5791_state *st = iio_priv(indio_dev);
|
||||
|
||||
ret = strict_strtol(buf, 10, &readin);
|
||||
ret = strtobool(buf, &pwr_down);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (readin == 0) {
|
||||
st->pwr_down = false;
|
||||
if (!pwr_down) {
|
||||
st->ctrl &= ~(AD5791_CTRL_OPGND | AD5791_CTRL_DACTRI);
|
||||
} else if (readin == 1) {
|
||||
st->pwr_down = true;
|
||||
} else {
|
||||
if (st->pwr_down_mode == AD5791_DAC_PWRDN_6K)
|
||||
st->ctrl |= AD5791_CTRL_OPGND;
|
||||
else if (st->pwr_down_mode == AD5791_DAC_PWRDN_3STATE)
|
||||
st->ctrl |= AD5791_CTRL_DACTRI;
|
||||
} else
|
||||
ret = -EINVAL;
|
||||
}
|
||||
st->pwr_down = pwr_down;
|
||||
|
||||
ret = ad5791_spi_write(st->spi, AD5791_ADDR_CTRL, st->ctrl);
|
||||
|
||||
return ret ? ret : len;
|
||||
}
|
||||
|
||||
static IIO_DEVICE_ATTR(out_voltage_powerdown_mode, S_IRUGO |
|
||||
S_IWUSR, ad5791_read_powerdown_mode,
|
||||
ad5791_write_powerdown_mode, 0);
|
||||
|
||||
static IIO_CONST_ATTR(out_voltage_powerdown_mode_available,
|
||||
"6kohm_to_gnd three_state");
|
||||
|
||||
#define IIO_DEV_ATTR_DAC_POWERDOWN(_num, _show, _store, _addr) \
|
||||
IIO_DEVICE_ATTR(out_voltage##_num##_powerdown, \
|
||||
S_IRUGO | S_IWUSR, _show, _store, _addr)
|
||||
|
||||
static IIO_DEV_ATTR_DAC_POWERDOWN(0, ad5791_read_dac_powerdown,
|
||||
ad5791_write_dac_powerdown, 0);
|
||||
|
||||
static struct attribute *ad5791_attributes[] = {
|
||||
&iio_dev_attr_out_voltage0_powerdown.dev_attr.attr,
|
||||
&iio_dev_attr_out_voltage_powerdown_mode.dev_attr.attr,
|
||||
&iio_const_attr_out_voltage_powerdown_mode_available.dev_attr.attr,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const struct attribute_group ad5791_attribute_group = {
|
||||
.attrs = ad5791_attributes,
|
||||
};
|
||||
|
||||
static int ad5791_get_lin_comp(unsigned int span)
|
||||
{
|
||||
if (span <= 10000)
|
||||
|
@ -254,6 +288,37 @@ static int ad5791_read_raw(struct iio_dev *indio_dev,
|
|||
|
||||
};
|
||||
|
||||
static const struct iio_chan_spec_ext_info ad5791_ext_info[] = {
|
||||
{
|
||||
.name = "powerdown",
|
||||
.shared = true,
|
||||
.read = ad5791_read_dac_powerdown,
|
||||
.write = ad5791_write_dac_powerdown,
|
||||
},
|
||||
IIO_ENUM("powerdown_mode", true, &ad5791_powerdown_mode_enum),
|
||||
IIO_ENUM_AVAILABLE("powerdown_mode", &ad5791_powerdown_mode_enum),
|
||||
{ },
|
||||
};
|
||||
|
||||
#define AD5791_CHAN(bits, shift) { \
|
||||
.type = IIO_VOLTAGE, \
|
||||
.output = 1, \
|
||||
.indexed = 1, \
|
||||
.address = AD5791_ADDR_DAC0, \
|
||||
.channel = 0, \
|
||||
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
|
||||
IIO_CHAN_INFO_SCALE_SHARED_BIT | \
|
||||
IIO_CHAN_INFO_OFFSET_SHARED_BIT, \
|
||||
.scan_type = IIO_ST('u', bits, 24, shift), \
|
||||
.ext_info = ad5791_ext_info, \
|
||||
}
|
||||
|
||||
static const struct iio_chan_spec ad5791_channels[] = {
|
||||
[ID_AD5760] = AD5791_CHAN(16, 4),
|
||||
[ID_AD5780] = AD5791_CHAN(18, 2),
|
||||
[ID_AD5781] = AD5791_CHAN(18, 2),
|
||||
[ID_AD5791] = AD5791_CHAN(20, 0)
|
||||
};
|
||||
|
||||
static int ad5791_write_raw(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec const *chan,
|
||||
|
@ -278,7 +343,6 @@ static int ad5791_write_raw(struct iio_dev *indio_dev,
|
|||
static const struct iio_info ad5791_info = {
|
||||
.read_raw = &ad5791_read_raw,
|
||||
.write_raw = &ad5791_write_raw,
|
||||
.attrs = &ad5791_attribute_group,
|
||||
.driver_module = THIS_MODULE,
|
||||
};
|
||||
|
|
@ -27,9 +27,7 @@
|
|||
|
||||
#include <linux/iio/iio.h>
|
||||
#include <linux/iio/sysfs.h>
|
||||
#include "dac.h"
|
||||
|
||||
#include "max517.h"
|
||||
#include <linux/iio/dac/max517.h>
|
||||
|
||||
#define MAX517_DRV_NAME "max517"
|
||||
|
||||
|
@ -45,7 +43,6 @@ enum max517_device_ids {
|
|||
};
|
||||
|
||||
struct max517_data {
|
||||
struct iio_dev *indio_dev;
|
||||
struct i2c_client *client;
|
||||
unsigned short vref_mv[2];
|
||||
};
|
||||
|
@ -55,129 +52,67 @@ struct max517_data {
|
|||
* bit 1: channel 2
|
||||
* (this way, it's possible to set both channels at once)
|
||||
*/
|
||||
static ssize_t max517_set_value(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t count, int channel)
|
||||
static int max517_set_value(struct iio_dev *indio_dev,
|
||||
long val, int channel)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct max517_data *data = iio_priv(indio_dev);
|
||||
struct i2c_client *client = data->client;
|
||||
u8 outbuf[4]; /* 1x or 2x command + value */
|
||||
int outbuf_size = 0;
|
||||
u8 outbuf[2];
|
||||
int res;
|
||||
long val;
|
||||
|
||||
res = strict_strtol(buf, 10, &val);
|
||||
|
||||
if (res)
|
||||
return res;
|
||||
|
||||
if (val < 0 || val > 255)
|
||||
return -EINVAL;
|
||||
|
||||
if (channel & 1) {
|
||||
outbuf[outbuf_size++] = COMMAND_CHANNEL0;
|
||||
outbuf[outbuf_size++] = val;
|
||||
}
|
||||
if (channel & 2) {
|
||||
outbuf[outbuf_size++] = COMMAND_CHANNEL1;
|
||||
outbuf[outbuf_size++] = val;
|
||||
}
|
||||
outbuf[0] = channel;
|
||||
outbuf[1] = val;
|
||||
|
||||
/*
|
||||
* At this point, there are always 1 or 2 two-byte commands in
|
||||
* outbuf. With 2 commands, the device can set two outputs
|
||||
* simultaneously, latching the values upon the end of the I2C
|
||||
* transfer.
|
||||
*/
|
||||
|
||||
res = i2c_master_send(client, outbuf, outbuf_size);
|
||||
res = i2c_master_send(client, outbuf, 2);
|
||||
if (res < 0)
|
||||
return res;
|
||||
|
||||
return count;
|
||||
else if (res != 2)
|
||||
return -EIO;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ssize_t max517_set_value_1(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
static int max517_read_raw(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec const *chan,
|
||||
int *val,
|
||||
int *val2,
|
||||
long m)
|
||||
{
|
||||
return max517_set_value(dev, attr, buf, count, 1);
|
||||
}
|
||||
static IIO_DEV_ATTR_OUT_RAW(1, max517_set_value_1, 0);
|
||||
|
||||
static ssize_t max517_set_value_2(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
return max517_set_value(dev, attr, buf, count, 2);
|
||||
}
|
||||
static IIO_DEV_ATTR_OUT_RAW(2, max517_set_value_2, 1);
|
||||
|
||||
static ssize_t max517_set_value_both(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
return max517_set_value(dev, attr, buf, count, 3);
|
||||
}
|
||||
static IIO_DEVICE_ATTR_NAMED(out_voltage1and2_raw,
|
||||
out_voltage1&2_raw, S_IWUSR, NULL,
|
||||
max517_set_value_both, -1);
|
||||
|
||||
static ssize_t max517_show_scale(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf, int channel)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct max517_data *data = iio_priv(indio_dev);
|
||||
/* Corresponds to Vref / 2^(bits) */
|
||||
unsigned int scale_uv = (data->vref_mv[channel - 1] * 1000) >> 8;
|
||||
unsigned int scale_uv;
|
||||
|
||||
return sprintf(buf, "%d.%03d\n", scale_uv / 1000, scale_uv % 1000);
|
||||
switch (m) {
|
||||
case IIO_CHAN_INFO_SCALE:
|
||||
/* Corresponds to Vref / 2^(bits) */
|
||||
scale_uv = (data->vref_mv[chan->channel] * 1000) >> 8;
|
||||
*val = scale_uv / 1000000;
|
||||
*val2 = scale_uv % 1000000;
|
||||
return IIO_VAL_INT_PLUS_MICRO;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static ssize_t max517_show_scale1(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
static int max517_write_raw(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec const *chan, int val, int val2, long mask)
|
||||
{
|
||||
return max517_show_scale(dev, attr, buf, 1);
|
||||
int ret;
|
||||
|
||||
switch (mask) {
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
ret = max517_set_value(indio_dev, val, chan->channel);
|
||||
break;
|
||||
default:
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
static IIO_DEVICE_ATTR(out_voltage1_scale, S_IRUGO,
|
||||
max517_show_scale1, NULL, 0);
|
||||
|
||||
static ssize_t max517_show_scale2(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
return max517_show_scale(dev, attr, buf, 2);
|
||||
}
|
||||
static IIO_DEVICE_ATTR(out_voltage2_scale, S_IRUGO,
|
||||
max517_show_scale2, NULL, 0);
|
||||
|
||||
/* On MAX517 variant, we have one output */
|
||||
static struct attribute *max517_attributes[] = {
|
||||
&iio_dev_attr_out_voltage1_raw.dev_attr.attr,
|
||||
&iio_dev_attr_out_voltage1_scale.dev_attr.attr,
|
||||
NULL
|
||||
};
|
||||
|
||||
static struct attribute_group max517_attribute_group = {
|
||||
.attrs = max517_attributes,
|
||||
};
|
||||
|
||||
/* On MAX518 and MAX519 variant, we have two outputs */
|
||||
static struct attribute *max518_attributes[] = {
|
||||
&iio_dev_attr_out_voltage1_raw.dev_attr.attr,
|
||||
&iio_dev_attr_out_voltage1_scale.dev_attr.attr,
|
||||
&iio_dev_attr_out_voltage2_raw.dev_attr.attr,
|
||||
&iio_dev_attr_out_voltage2_scale.dev_attr.attr,
|
||||
&iio_dev_attr_out_voltage1and2_raw.dev_attr.attr,
|
||||
NULL
|
||||
};
|
||||
|
||||
static struct attribute_group max518_attribute_group = {
|
||||
.attrs = max518_attributes,
|
||||
};
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
static int max517_suspend(struct device *dev)
|
||||
|
@ -201,16 +136,27 @@ static SIMPLE_DEV_PM_OPS(max517_pm_ops, max517_suspend, max517_resume);
|
|||
#endif
|
||||
|
||||
static const struct iio_info max517_info = {
|
||||
.attrs = &max517_attribute_group,
|
||||
.read_raw = max517_read_raw,
|
||||
.write_raw = max517_write_raw,
|
||||
.driver_module = THIS_MODULE,
|
||||
};
|
||||
|
||||
static const struct iio_info max518_info = {
|
||||
.attrs = &max518_attribute_group,
|
||||
.driver_module = THIS_MODULE,
|
||||
#define MAX517_CHANNEL(chan) { \
|
||||
.type = IIO_VOLTAGE, \
|
||||
.indexed = 1, \
|
||||
.output = 1, \
|
||||
.channel = (chan), \
|
||||
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
|
||||
IIO_CHAN_INFO_SCALE_SEPARATE_BIT, \
|
||||
.scan_type = IIO_ST('u', 8, 8, 0), \
|
||||
}
|
||||
|
||||
static const struct iio_chan_spec max517_channels[] = {
|
||||
MAX517_CHANNEL(0),
|
||||
MAX517_CHANNEL(1)
|
||||
};
|
||||
|
||||
static int max517_probe(struct i2c_client *client,
|
||||
static int __devinit max517_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *id)
|
||||
{
|
||||
struct max517_data *data;
|
||||
|
@ -230,12 +176,14 @@ static int max517_probe(struct i2c_client *client,
|
|||
/* establish that the iio_dev is a child of the i2c device */
|
||||
indio_dev->dev.parent = &client->dev;
|
||||
|
||||
/* reduced attribute set for MAX517 */
|
||||
/* reduced channel set for MAX517 */
|
||||
if (id->driver_data == ID_MAX517)
|
||||
indio_dev->info = &max517_info;
|
||||
indio_dev->num_channels = 1;
|
||||
else
|
||||
indio_dev->info = &max518_info;
|
||||
indio_dev->num_channels = 2;
|
||||
indio_dev->channels = max517_channels;
|
||||
indio_dev->modes = INDIO_DIRECT_MODE;
|
||||
indio_dev->info = &max517_info;
|
||||
|
||||
/*
|
||||
* Reference voltage on MAX518 and default is 5V, else take vref_mv
|
||||
|
@ -262,7 +210,7 @@ static int max517_probe(struct i2c_client *client,
|
|||
return err;
|
||||
}
|
||||
|
||||
static int max517_remove(struct i2c_client *client)
|
||||
static int __devexit max517_remove(struct i2c_client *client)
|
||||
{
|
||||
iio_device_unregister(i2c_get_clientdata(client));
|
||||
iio_device_free(i2c_get_clientdata(client));
|
||||
|
@ -284,7 +232,7 @@ static struct i2c_driver max517_driver = {
|
|||
.pm = MAX517_PM_OPS,
|
||||
},
|
||||
.probe = max517_probe,
|
||||
.remove = max517_remove,
|
||||
.remove = __devexit_p(max517_remove),
|
||||
.id_table = max517_id,
|
||||
};
|
||||
module_i2c_driver(max517_driver);
|
227
drivers/iio/dac/mcp4725.c
Normal file
227
drivers/iio/dac/mcp4725.c
Normal file
|
@ -0,0 +1,227 @@
|
|||
/*
|
||||
* mcp4725.c - Support for Microchip MCP4725
|
||||
*
|
||||
* Copyright (C) 2012 Peter Meerwald <pmeerw@pmeerw.net>
|
||||
*
|
||||
* Based on max517 by Roland Stigge <stigge@antcom.de>
|
||||
*
|
||||
* This file is subject to the terms and conditions of version 2 of
|
||||
* the GNU General Public License. See the file COPYING in the main
|
||||
* directory of this archive for more details.
|
||||
*
|
||||
* driver for the Microchip I2C 12-bit digital-to-analog converter (DAC)
|
||||
* (7-bit I2C slave address 0x60, the three LSBs can be configured in
|
||||
* hardware)
|
||||
*
|
||||
* writing the DAC value to EEPROM is not supported
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/err.h>
|
||||
|
||||
#include <linux/iio/iio.h>
|
||||
#include <linux/iio/sysfs.h>
|
||||
|
||||
#include <linux/iio/dac/mcp4725.h>
|
||||
|
||||
#define MCP4725_DRV_NAME "mcp4725"
|
||||
|
||||
struct mcp4725_data {
|
||||
struct i2c_client *client;
|
||||
u16 vref_mv;
|
||||
u16 dac_value;
|
||||
};
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
static int mcp4725_suspend(struct device *dev)
|
||||
{
|
||||
u8 outbuf[2];
|
||||
|
||||
outbuf[0] = 0x3 << 4; /* power-down bits, 500 kOhm resistor */
|
||||
outbuf[1] = 0;
|
||||
|
||||
return i2c_master_send(to_i2c_client(dev), outbuf, 2);
|
||||
}
|
||||
|
||||
static int mcp4725_resume(struct device *dev)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct mcp4725_data *data = iio_priv(indio_dev);
|
||||
u8 outbuf[2];
|
||||
|
||||
/* restore previous DAC value */
|
||||
outbuf[0] = (data->dac_value >> 8) & 0xf;
|
||||
outbuf[1] = data->dac_value & 0xff;
|
||||
|
||||
return i2c_master_send(to_i2c_client(dev), outbuf, 2);
|
||||
}
|
||||
|
||||
static SIMPLE_DEV_PM_OPS(mcp4725_pm_ops, mcp4725_suspend, mcp4725_resume);
|
||||
#define MCP4725_PM_OPS (&mcp4725_pm_ops)
|
||||
#else
|
||||
#define MCP4725_PM_OPS NULL
|
||||
#endif
|
||||
|
||||
static const struct iio_chan_spec mcp4725_channel = {
|
||||
.type = IIO_VOLTAGE,
|
||||
.indexed = 1,
|
||||
.output = 1,
|
||||
.channel = 0,
|
||||
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
|
||||
IIO_CHAN_INFO_SCALE_SHARED_BIT,
|
||||
.scan_type = IIO_ST('u', 12, 16, 0),
|
||||
};
|
||||
|
||||
static int mcp4725_set_value(struct iio_dev *indio_dev, int val)
|
||||
{
|
||||
struct mcp4725_data *data = iio_priv(indio_dev);
|
||||
u8 outbuf[2];
|
||||
int ret;
|
||||
|
||||
if (val >= (1 << 12) || val < 0)
|
||||
return -EINVAL;
|
||||
|
||||
outbuf[0] = (val >> 8) & 0xf;
|
||||
outbuf[1] = val & 0xff;
|
||||
|
||||
ret = i2c_master_send(data->client, outbuf, 2);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
else if (ret != 2)
|
||||
return -EIO;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mcp4725_read_raw(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec const *chan,
|
||||
int *val, int *val2, long mask)
|
||||
{
|
||||
struct mcp4725_data *data = iio_priv(indio_dev);
|
||||
unsigned long scale_uv;
|
||||
|
||||
switch (mask) {
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
*val = data->dac_value;
|
||||
return IIO_VAL_INT;
|
||||
case IIO_CHAN_INFO_SCALE:
|
||||
scale_uv = (data->vref_mv * 1000) >> 12;
|
||||
*val = scale_uv / 1000000;
|
||||
*val2 = scale_uv % 1000000;
|
||||
return IIO_VAL_INT_PLUS_MICRO;
|
||||
}
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static int mcp4725_write_raw(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec const *chan,
|
||||
int val, int val2, long mask)
|
||||
{
|
||||
struct mcp4725_data *data = iio_priv(indio_dev);
|
||||
int ret;
|
||||
|
||||
switch (mask) {
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
ret = mcp4725_set_value(indio_dev, val);
|
||||
data->dac_value = val;
|
||||
break;
|
||||
default:
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const struct iio_info mcp4725_info = {
|
||||
.read_raw = mcp4725_read_raw,
|
||||
.write_raw = mcp4725_write_raw,
|
||||
.driver_module = THIS_MODULE,
|
||||
};
|
||||
|
||||
static int __devinit mcp4725_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *id)
|
||||
{
|
||||
struct mcp4725_data *data;
|
||||
struct iio_dev *indio_dev;
|
||||
struct mcp4725_platform_data *platform_data = client->dev.platform_data;
|
||||
u8 inbuf[3];
|
||||
int err;
|
||||
|
||||
if (!platform_data || !platform_data->vref_mv) {
|
||||
dev_err(&client->dev, "invalid platform data");
|
||||
err = -EINVAL;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
indio_dev = iio_device_alloc(sizeof(*data));
|
||||
if (indio_dev == NULL) {
|
||||
err = -ENOMEM;
|
||||
goto exit;
|
||||
}
|
||||
data = iio_priv(indio_dev);
|
||||
i2c_set_clientdata(client, indio_dev);
|
||||
data->client = client;
|
||||
|
||||
indio_dev->dev.parent = &client->dev;
|
||||
indio_dev->info = &mcp4725_info;
|
||||
indio_dev->channels = &mcp4725_channel;
|
||||
indio_dev->num_channels = 1;
|
||||
indio_dev->modes = INDIO_DIRECT_MODE;
|
||||
|
||||
data->vref_mv = platform_data->vref_mv;
|
||||
|
||||
/* read current DAC value */
|
||||
err = i2c_master_recv(client, inbuf, 3);
|
||||
if (err < 0) {
|
||||
dev_err(&client->dev, "failed to read DAC value");
|
||||
goto exit_free_device;
|
||||
}
|
||||
data->dac_value = (inbuf[1] << 4) | (inbuf[2] >> 4);
|
||||
|
||||
err = iio_device_register(indio_dev);
|
||||
if (err)
|
||||
goto exit_free_device;
|
||||
|
||||
dev_info(&client->dev, "MCP4725 DAC registered\n");
|
||||
|
||||
return 0;
|
||||
|
||||
exit_free_device:
|
||||
iio_device_free(indio_dev);
|
||||
exit:
|
||||
return err;
|
||||
}
|
||||
|
||||
static int __devexit mcp4725_remove(struct i2c_client *client)
|
||||
{
|
||||
struct iio_dev *indio_dev = i2c_get_clientdata(client);
|
||||
|
||||
iio_device_unregister(indio_dev);
|
||||
iio_device_free(indio_dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct i2c_device_id mcp4725_id[] = {
|
||||
{ "mcp4725", 0 },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, mcp4725_id);
|
||||
|
||||
static struct i2c_driver mcp4725_driver = {
|
||||
.driver = {
|
||||
.name = MCP4725_DRV_NAME,
|
||||
.pm = MCP4725_PM_OPS,
|
||||
},
|
||||
.probe = mcp4725_probe,
|
||||
.remove = __devexit_p(mcp4725_remove),
|
||||
.id_table = mcp4725_id,
|
||||
};
|
||||
module_i2c_driver(mcp4725_driver);
|
||||
|
||||
MODULE_AUTHOR("Peter Meerwald <pmeerw@pmeerw.net>");
|
||||
MODULE_DESCRIPTION("MCP4725 12-bit DAC");
|
||||
MODULE_LICENSE("GPL");
|
41
drivers/iio/frequency/Kconfig
Normal file
41
drivers/iio/frequency/Kconfig
Normal file
|
@ -0,0 +1,41 @@
|
|||
#
|
||||
# Frequency
|
||||
# Direct Digital Synthesis drivers (DDS)
|
||||
# Clock Distribution device drivers
|
||||
# Phase-Locked Loop (PLL) frequency synthesizers
|
||||
#
|
||||
|
||||
menu "Frequency Synthesizers DDS/PLL"
|
||||
|
||||
menu "Clock Generator/Distribution"
|
||||
|
||||
config AD9523
|
||||
tristate "Analog Devices AD9523 Low Jitter Clock Generator"
|
||||
depends on SPI
|
||||
help
|
||||
Say yes here to build support for Analog Devices AD9523 Low Jitter
|
||||
Clock Generator. The driver provides direct access via sysfs.
|
||||
|
||||
To compile this driver as a module, choose M here: the
|
||||
module will be called ad9523.
|
||||
|
||||
endmenu
|
||||
|
||||
#
|
||||
# Phase-Locked Loop (PLL) frequency synthesizers
|
||||
#
|
||||
|
||||
menu "Phase-Locked Loop (PLL) frequency synthesizers"
|
||||
|
||||
config ADF4350
|
||||
tristate "Analog Devices ADF4350/ADF4351 Wideband Synthesizers"
|
||||
depends on SPI
|
||||
help
|
||||
Say yes here to build support for Analog Devices ADF4350/ADF4351
|
||||
Wideband Synthesizers. The driver provides direct access via sysfs.
|
||||
|
||||
To compile this driver as a module, choose M here: the
|
||||
module will be called adf4350.
|
||||
|
||||
endmenu
|
||||
endmenu
|
6
drivers/iio/frequency/Makefile
Normal file
6
drivers/iio/frequency/Makefile
Normal file
|
@ -0,0 +1,6 @@
|
|||
#
|
||||
# Makefile iio/frequency
|
||||
#
|
||||
|
||||
obj-$(CONFIG_AD9523) += ad9523.o
|
||||
obj-$(CONFIG_ADF4350) += adf4350.o
|
1059
drivers/iio/frequency/ad9523.c
Normal file
1059
drivers/iio/frequency/ad9523.c
Normal file
File diff suppressed because it is too large
Load diff
480
drivers/iio/frequency/adf4350.c
Normal file
480
drivers/iio/frequency/adf4350.c
Normal file
|
@ -0,0 +1,480 @@
|
|||
/*
|
||||
* ADF4350/ADF4351 SPI Wideband Synthesizer driver
|
||||
*
|
||||
* Copyright 2012 Analog Devices Inc.
|
||||
*
|
||||
* Licensed under the GPL-2.
|
||||
*/
|
||||
|
||||
#include <linux/device.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/sysfs.h>
|
||||
#include <linux/spi/spi.h>
|
||||
#include <linux/regulator/consumer.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/gcd.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <asm/div64.h>
|
||||
|
||||
#include <linux/iio/iio.h>
|
||||
#include <linux/iio/sysfs.h>
|
||||
#include <linux/iio/frequency/adf4350.h>
|
||||
|
||||
enum {
|
||||
ADF4350_FREQ,
|
||||
ADF4350_FREQ_REFIN,
|
||||
ADF4350_FREQ_RESOLUTION,
|
||||
ADF4350_PWRDOWN,
|
||||
};
|
||||
|
||||
struct adf4350_state {
|
||||
struct spi_device *spi;
|
||||
struct regulator *reg;
|
||||
struct adf4350_platform_data *pdata;
|
||||
unsigned long clkin;
|
||||
unsigned long chspc; /* Channel Spacing */
|
||||
unsigned long fpfd; /* Phase Frequency Detector */
|
||||
unsigned long min_out_freq;
|
||||
unsigned r0_fract;
|
||||
unsigned r0_int;
|
||||
unsigned r1_mod;
|
||||
unsigned r4_rf_div_sel;
|
||||
unsigned long regs[6];
|
||||
unsigned long regs_hw[6];
|
||||
|
||||
/*
|
||||
* DMA (thus cache coherency maintenance) requires the
|
||||
* transfer buffers to live in their own cache lines.
|
||||
*/
|
||||
__be32 val ____cacheline_aligned;
|
||||
};
|
||||
|
||||
static struct adf4350_platform_data default_pdata = {
|
||||
.clkin = 122880000,
|
||||
.channel_spacing = 10000,
|
||||
.r2_user_settings = ADF4350_REG2_PD_POLARITY_POS |
|
||||
ADF4350_REG2_CHARGE_PUMP_CURR_uA(2500),
|
||||
.r3_user_settings = ADF4350_REG3_12BIT_CLKDIV_MODE(0),
|
||||
.r4_user_settings = ADF4350_REG4_OUTPUT_PWR(3) |
|
||||
ADF4350_REG4_MUTE_TILL_LOCK_EN,
|
||||
.gpio_lock_detect = -1,
|
||||
};
|
||||
|
||||
static int adf4350_sync_config(struct adf4350_state *st)
|
||||
{
|
||||
int ret, i, doublebuf = 0;
|
||||
|
||||
for (i = ADF4350_REG5; i >= ADF4350_REG0; i--) {
|
||||
if ((st->regs_hw[i] != st->regs[i]) ||
|
||||
((i == ADF4350_REG0) && doublebuf)) {
|
||||
|
||||
switch (i) {
|
||||
case ADF4350_REG1:
|
||||
case ADF4350_REG4:
|
||||
doublebuf = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
st->val = cpu_to_be32(st->regs[i] | i);
|
||||
ret = spi_write(st->spi, &st->val, 4);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
st->regs_hw[i] = st->regs[i];
|
||||
dev_dbg(&st->spi->dev, "[%d] 0x%X\n",
|
||||
i, (u32)st->regs[i] | i);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int adf4350_reg_access(struct iio_dev *indio_dev,
|
||||
unsigned reg, unsigned writeval,
|
||||
unsigned *readval)
|
||||
{
|
||||
struct adf4350_state *st = iio_priv(indio_dev);
|
||||
int ret;
|
||||
|
||||
if (reg > ADF4350_REG5)
|
||||
return -EINVAL;
|
||||
|
||||
mutex_lock(&indio_dev->mlock);
|
||||
if (readval == NULL) {
|
||||
st->regs[reg] = writeval & ~(BIT(0) | BIT(1) | BIT(2));
|
||||
ret = adf4350_sync_config(st);
|
||||
} else {
|
||||
*readval = st->regs_hw[reg];
|
||||
ret = 0;
|
||||
}
|
||||
mutex_unlock(&indio_dev->mlock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int adf4350_tune_r_cnt(struct adf4350_state *st, unsigned short r_cnt)
|
||||
{
|
||||
struct adf4350_platform_data *pdata = st->pdata;
|
||||
|
||||
do {
|
||||
r_cnt++;
|
||||
st->fpfd = (st->clkin * (pdata->ref_doubler_en ? 2 : 1)) /
|
||||
(r_cnt * (pdata->ref_div2_en ? 2 : 1));
|
||||
} while (st->fpfd > ADF4350_MAX_FREQ_PFD);
|
||||
|
||||
return r_cnt;
|
||||
}
|
||||
|
||||
static int adf4350_set_freq(struct adf4350_state *st, unsigned long long freq)
|
||||
{
|
||||
struct adf4350_platform_data *pdata = st->pdata;
|
||||
u64 tmp;
|
||||
u32 div_gcd, prescaler;
|
||||
u16 mdiv, r_cnt = 0;
|
||||
u8 band_sel_div;
|
||||
|
||||
if (freq > ADF4350_MAX_OUT_FREQ || freq < st->min_out_freq)
|
||||
return -EINVAL;
|
||||
|
||||
if (freq > ADF4350_MAX_FREQ_45_PRESC) {
|
||||
prescaler = ADF4350_REG1_PRESCALER;
|
||||
mdiv = 75;
|
||||
} else {
|
||||
prescaler = 0;
|
||||
mdiv = 23;
|
||||
}
|
||||
|
||||
st->r4_rf_div_sel = 0;
|
||||
|
||||
while (freq < ADF4350_MIN_VCO_FREQ) {
|
||||
freq <<= 1;
|
||||
st->r4_rf_div_sel++;
|
||||
}
|
||||
|
||||
/*
|
||||
* Allow a predefined reference division factor
|
||||
* if not set, compute our own
|
||||
*/
|
||||
if (pdata->ref_div_factor)
|
||||
r_cnt = pdata->ref_div_factor - 1;
|
||||
|
||||
do {
|
||||
r_cnt = adf4350_tune_r_cnt(st, r_cnt);
|
||||
|
||||
st->r1_mod = st->fpfd / st->chspc;
|
||||
while (st->r1_mod > ADF4350_MAX_MODULUS) {
|
||||
r_cnt = adf4350_tune_r_cnt(st, r_cnt);
|
||||
st->r1_mod = st->fpfd / st->chspc;
|
||||
}
|
||||
|
||||
tmp = freq * (u64)st->r1_mod + (st->fpfd > 1);
|
||||
do_div(tmp, st->fpfd); /* Div round closest (n + d/2)/d */
|
||||
st->r0_fract = do_div(tmp, st->r1_mod);
|
||||
st->r0_int = tmp;
|
||||
} while (mdiv > st->r0_int);
|
||||
|
||||
band_sel_div = DIV_ROUND_UP(st->fpfd, ADF4350_MAX_BANDSEL_CLK);
|
||||
|
||||
if (st->r0_fract && st->r1_mod) {
|
||||
div_gcd = gcd(st->r1_mod, st->r0_fract);
|
||||
st->r1_mod /= div_gcd;
|
||||
st->r0_fract /= div_gcd;
|
||||
} else {
|
||||
st->r0_fract = 0;
|
||||
st->r1_mod = 1;
|
||||
}
|
||||
|
||||
dev_dbg(&st->spi->dev, "VCO: %llu Hz, PFD %lu Hz\n"
|
||||
"REF_DIV %d, R0_INT %d, R0_FRACT %d\n"
|
||||
"R1_MOD %d, RF_DIV %d\nPRESCALER %s, BAND_SEL_DIV %d\n",
|
||||
freq, st->fpfd, r_cnt, st->r0_int, st->r0_fract, st->r1_mod,
|
||||
1 << st->r4_rf_div_sel, prescaler ? "8/9" : "4/5",
|
||||
band_sel_div);
|
||||
|
||||
st->regs[ADF4350_REG0] = ADF4350_REG0_INT(st->r0_int) |
|
||||
ADF4350_REG0_FRACT(st->r0_fract);
|
||||
|
||||
st->regs[ADF4350_REG1] = ADF4350_REG1_PHASE(0) |
|
||||
ADF4350_REG1_MOD(st->r1_mod) |
|
||||
prescaler;
|
||||
|
||||
st->regs[ADF4350_REG2] =
|
||||
ADF4350_REG2_10BIT_R_CNT(r_cnt) |
|
||||
ADF4350_REG2_DOUBLE_BUFF_EN |
|
||||
(pdata->ref_doubler_en ? ADF4350_REG2_RMULT2_EN : 0) |
|
||||
(pdata->ref_div2_en ? ADF4350_REG2_RDIV2_EN : 0) |
|
||||
(pdata->r2_user_settings & (ADF4350_REG2_PD_POLARITY_POS |
|
||||
ADF4350_REG2_LDP_6ns | ADF4350_REG2_LDF_INT_N |
|
||||
ADF4350_REG2_CHARGE_PUMP_CURR_uA(5000) |
|
||||
ADF4350_REG2_MUXOUT(0x7) | ADF4350_REG2_NOISE_MODE(0x9)));
|
||||
|
||||
st->regs[ADF4350_REG3] = pdata->r3_user_settings &
|
||||
(ADF4350_REG3_12BIT_CLKDIV(0xFFF) |
|
||||
ADF4350_REG3_12BIT_CLKDIV_MODE(0x3) |
|
||||
ADF4350_REG3_12BIT_CSR_EN |
|
||||
ADF4351_REG3_CHARGE_CANCELLATION_EN |
|
||||
ADF4351_REG3_ANTI_BACKLASH_3ns_EN |
|
||||
ADF4351_REG3_BAND_SEL_CLOCK_MODE_HIGH);
|
||||
|
||||
st->regs[ADF4350_REG4] =
|
||||
ADF4350_REG4_FEEDBACK_FUND |
|
||||
ADF4350_REG4_RF_DIV_SEL(st->r4_rf_div_sel) |
|
||||
ADF4350_REG4_8BIT_BAND_SEL_CLKDIV(band_sel_div) |
|
||||
ADF4350_REG4_RF_OUT_EN |
|
||||
(pdata->r4_user_settings &
|
||||
(ADF4350_REG4_OUTPUT_PWR(0x3) |
|
||||
ADF4350_REG4_AUX_OUTPUT_PWR(0x3) |
|
||||
ADF4350_REG4_AUX_OUTPUT_EN |
|
||||
ADF4350_REG4_AUX_OUTPUT_FUND |
|
||||
ADF4350_REG4_MUTE_TILL_LOCK_EN));
|
||||
|
||||
st->regs[ADF4350_REG5] = ADF4350_REG5_LD_PIN_MODE_DIGITAL;
|
||||
|
||||
return adf4350_sync_config(st);
|
||||
}
|
||||
|
||||
static ssize_t adf4350_write(struct iio_dev *indio_dev,
|
||||
uintptr_t private,
|
||||
const struct iio_chan_spec *chan,
|
||||
const char *buf, size_t len)
|
||||
{
|
||||
struct adf4350_state *st = iio_priv(indio_dev);
|
||||
unsigned long long readin;
|
||||
int ret;
|
||||
|
||||
ret = kstrtoull(buf, 10, &readin);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
mutex_lock(&indio_dev->mlock);
|
||||
switch ((u32)private) {
|
||||
case ADF4350_FREQ:
|
||||
ret = adf4350_set_freq(st, readin);
|
||||
break;
|
||||
case ADF4350_FREQ_REFIN:
|
||||
if (readin > ADF4350_MAX_FREQ_REFIN)
|
||||
ret = -EINVAL;
|
||||
else
|
||||
st->clkin = readin;
|
||||
break;
|
||||
case ADF4350_FREQ_RESOLUTION:
|
||||
if (readin == 0)
|
||||
ret = -EINVAL;
|
||||
else
|
||||
st->chspc = readin;
|
||||
break;
|
||||
case ADF4350_PWRDOWN:
|
||||
if (readin)
|
||||
st->regs[ADF4350_REG2] |= ADF4350_REG2_POWER_DOWN_EN;
|
||||
else
|
||||
st->regs[ADF4350_REG2] &= ~ADF4350_REG2_POWER_DOWN_EN;
|
||||
|
||||
adf4350_sync_config(st);
|
||||
break;
|
||||
default:
|
||||
ret = -EINVAL;
|
||||
}
|
||||
mutex_unlock(&indio_dev->mlock);
|
||||
|
||||
return ret ? ret : len;
|
||||
}
|
||||
|
||||
static ssize_t adf4350_read(struct iio_dev *indio_dev,
|
||||
uintptr_t private,
|
||||
const struct iio_chan_spec *chan,
|
||||
char *buf)
|
||||
{
|
||||
struct adf4350_state *st = iio_priv(indio_dev);
|
||||
unsigned long long val;
|
||||
int ret = 0;
|
||||
|
||||
mutex_lock(&indio_dev->mlock);
|
||||
switch ((u32)private) {
|
||||
case ADF4350_FREQ:
|
||||
val = (u64)((st->r0_int * st->r1_mod) + st->r0_fract) *
|
||||
(u64)st->fpfd;
|
||||
do_div(val, st->r1_mod * (1 << st->r4_rf_div_sel));
|
||||
/* PLL unlocked? return error */
|
||||
if (gpio_is_valid(st->pdata->gpio_lock_detect))
|
||||
if (!gpio_get_value(st->pdata->gpio_lock_detect)) {
|
||||
dev_dbg(&st->spi->dev, "PLL un-locked\n");
|
||||
ret = -EBUSY;
|
||||
}
|
||||
break;
|
||||
case ADF4350_FREQ_REFIN:
|
||||
val = st->clkin;
|
||||
break;
|
||||
case ADF4350_FREQ_RESOLUTION:
|
||||
val = st->chspc;
|
||||
break;
|
||||
case ADF4350_PWRDOWN:
|
||||
val = !!(st->regs[ADF4350_REG2] & ADF4350_REG2_POWER_DOWN_EN);
|
||||
break;
|
||||
default:
|
||||
ret = -EINVAL;
|
||||
}
|
||||
mutex_unlock(&indio_dev->mlock);
|
||||
|
||||
return ret < 0 ? ret : sprintf(buf, "%llu\n", val);
|
||||
}
|
||||
|
||||
#define _ADF4350_EXT_INFO(_name, _ident) { \
|
||||
.name = _name, \
|
||||
.read = adf4350_read, \
|
||||
.write = adf4350_write, \
|
||||
.private = _ident, \
|
||||
}
|
||||
|
||||
static const struct iio_chan_spec_ext_info adf4350_ext_info[] = {
|
||||
/* Ideally we use IIO_CHAN_INFO_FREQUENCY, but there are
|
||||
* values > 2^32 in order to support the entire frequency range
|
||||
* in Hz. Using scale is a bit ugly.
|
||||
*/
|
||||
_ADF4350_EXT_INFO("frequency", ADF4350_FREQ),
|
||||
_ADF4350_EXT_INFO("frequency_resolution", ADF4350_FREQ_RESOLUTION),
|
||||
_ADF4350_EXT_INFO("refin_frequency", ADF4350_FREQ_REFIN),
|
||||
_ADF4350_EXT_INFO("powerdown", ADF4350_PWRDOWN),
|
||||
{ },
|
||||
};
|
||||
|
||||
static const struct iio_chan_spec adf4350_chan = {
|
||||
.type = IIO_ALTVOLTAGE,
|
||||
.indexed = 1,
|
||||
.output = 1,
|
||||
.ext_info = adf4350_ext_info,
|
||||
};
|
||||
|
||||
static const struct iio_info adf4350_info = {
|
||||
.debugfs_reg_access = &adf4350_reg_access,
|
||||
.driver_module = THIS_MODULE,
|
||||
};
|
||||
|
||||
static int __devinit adf4350_probe(struct spi_device *spi)
|
||||
{
|
||||
struct adf4350_platform_data *pdata = spi->dev.platform_data;
|
||||
struct iio_dev *indio_dev;
|
||||
struct adf4350_state *st;
|
||||
int ret;
|
||||
|
||||
if (!pdata) {
|
||||
dev_warn(&spi->dev, "no platform data? using default\n");
|
||||
|
||||
pdata = &default_pdata;
|
||||
}
|
||||
|
||||
indio_dev = iio_device_alloc(sizeof(*st));
|
||||
if (indio_dev == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
st = iio_priv(indio_dev);
|
||||
|
||||
st->reg = regulator_get(&spi->dev, "vcc");
|
||||
if (!IS_ERR(st->reg)) {
|
||||
ret = regulator_enable(st->reg);
|
||||
if (ret)
|
||||
goto error_put_reg;
|
||||
}
|
||||
|
||||
spi_set_drvdata(spi, indio_dev);
|
||||
st->spi = spi;
|
||||
st->pdata = pdata;
|
||||
|
||||
indio_dev->dev.parent = &spi->dev;
|
||||
indio_dev->name = (pdata->name[0] != 0) ? pdata->name :
|
||||
spi_get_device_id(spi)->name;
|
||||
|
||||
indio_dev->info = &adf4350_info;
|
||||
indio_dev->modes = INDIO_DIRECT_MODE;
|
||||
indio_dev->channels = &adf4350_chan;
|
||||
indio_dev->num_channels = 1;
|
||||
|
||||
st->chspc = pdata->channel_spacing;
|
||||
st->clkin = pdata->clkin;
|
||||
|
||||
st->min_out_freq = spi_get_device_id(spi)->driver_data == 4351 ?
|
||||
ADF4351_MIN_OUT_FREQ : ADF4350_MIN_OUT_FREQ;
|
||||
|
||||
memset(st->regs_hw, 0xFF, sizeof(st->regs_hw));
|
||||
|
||||
if (gpio_is_valid(pdata->gpio_lock_detect)) {
|
||||
ret = gpio_request(pdata->gpio_lock_detect, indio_dev->name);
|
||||
if (ret) {
|
||||
dev_err(&spi->dev, "fail to request lock detect GPIO-%d",
|
||||
pdata->gpio_lock_detect);
|
||||
goto error_disable_reg;
|
||||
}
|
||||
gpio_direction_input(pdata->gpio_lock_detect);
|
||||
}
|
||||
|
||||
if (pdata->power_up_frequency) {
|
||||
ret = adf4350_set_freq(st, pdata->power_up_frequency);
|
||||
if (ret)
|
||||
goto error_free_gpio;
|
||||
}
|
||||
|
||||
ret = iio_device_register(indio_dev);
|
||||
if (ret)
|
||||
goto error_free_gpio;
|
||||
|
||||
return 0;
|
||||
|
||||
error_free_gpio:
|
||||
if (gpio_is_valid(pdata->gpio_lock_detect))
|
||||
gpio_free(pdata->gpio_lock_detect);
|
||||
|
||||
error_disable_reg:
|
||||
if (!IS_ERR(st->reg))
|
||||
regulator_disable(st->reg);
|
||||
error_put_reg:
|
||||
if (!IS_ERR(st->reg))
|
||||
regulator_put(st->reg);
|
||||
|
||||
iio_device_free(indio_dev);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int __devexit adf4350_remove(struct spi_device *spi)
|
||||
{
|
||||
struct iio_dev *indio_dev = spi_get_drvdata(spi);
|
||||
struct adf4350_state *st = iio_priv(indio_dev);
|
||||
struct regulator *reg = st->reg;
|
||||
|
||||
st->regs[ADF4350_REG2] |= ADF4350_REG2_POWER_DOWN_EN;
|
||||
adf4350_sync_config(st);
|
||||
|
||||
iio_device_unregister(indio_dev);
|
||||
|
||||
if (!IS_ERR(reg)) {
|
||||
regulator_disable(reg);
|
||||
regulator_put(reg);
|
||||
}
|
||||
|
||||
if (gpio_is_valid(st->pdata->gpio_lock_detect))
|
||||
gpio_free(st->pdata->gpio_lock_detect);
|
||||
|
||||
iio_device_free(indio_dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct spi_device_id adf4350_id[] = {
|
||||
{"adf4350", 4350},
|
||||
{"adf4351", 4351},
|
||||
{}
|
||||
};
|
||||
|
||||
static struct spi_driver adf4350_driver = {
|
||||
.driver = {
|
||||
.name = "adf4350",
|
||||
.owner = THIS_MODULE,
|
||||
},
|
||||
.probe = adf4350_probe,
|
||||
.remove = __devexit_p(adf4350_remove),
|
||||
.id_table = adf4350_id,
|
||||
};
|
||||
module_spi_driver(adf4350_driver);
|
||||
|
||||
MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>");
|
||||
MODULE_DESCRIPTION("Analog Devices ADF4350/ADF4351 PLL");
|
||||
MODULE_LICENSE("GPL v2");
|
|
@ -285,11 +285,14 @@ int iio_buffer_register(struct iio_dev *indio_dev,
|
|||
if (channels) {
|
||||
/* new magic */
|
||||
for (i = 0; i < num_channels; i++) {
|
||||
if (channels[i].scan_index < 0)
|
||||
continue;
|
||||
|
||||
/* Establish necessary mask length */
|
||||
if (channels[i].scan_index >
|
||||
(int)indio_dev->masklength - 1)
|
||||
indio_dev->masklength
|
||||
= indio_dev->channels[i].scan_index + 1;
|
||||
= channels[i].scan_index + 1;
|
||||
|
||||
ret = iio_buffer_add_channel_sysfs(indio_dev,
|
||||
&channels[i]);
|
||||
|
@ -553,6 +556,10 @@ int iio_sw_buffer_preenable(struct iio_dev *indio_dev)
|
|||
buffer->scan_mask);
|
||||
else
|
||||
indio_dev->active_scan_mask = buffer->scan_mask;
|
||||
|
||||
if (indio_dev->active_scan_mask == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
iio_update_demux(indio_dev);
|
||||
|
||||
if (indio_dev->info->update_scan_mode)
|
||||
|
@ -563,6 +570,31 @@ int iio_sw_buffer_preenable(struct iio_dev *indio_dev)
|
|||
}
|
||||
EXPORT_SYMBOL(iio_sw_buffer_preenable);
|
||||
|
||||
/**
|
||||
* iio_validate_scan_mask_onehot() - Validates that exactly one channel is selected
|
||||
* @indio_dev: the iio device
|
||||
* @mask: scan mask to be checked
|
||||
*
|
||||
* Return true if exactly one bit is set in the scan mask, false otherwise. It
|
||||
* can be used for devices where only one channel can be active for sampling at
|
||||
* a time.
|
||||
*/
|
||||
bool iio_validate_scan_mask_onehot(struct iio_dev *indio_dev,
|
||||
const unsigned long *mask)
|
||||
{
|
||||
return bitmap_weight(mask, indio_dev->masklength) == 1;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(iio_validate_scan_mask_onehot);
|
||||
|
||||
static bool iio_validate_scan_mask(struct iio_dev *indio_dev,
|
||||
const unsigned long *mask)
|
||||
{
|
||||
if (!indio_dev->setup_ops->validate_scan_mask)
|
||||
return true;
|
||||
|
||||
return indio_dev->setup_ops->validate_scan_mask(indio_dev, mask);
|
||||
}
|
||||
|
||||
/**
|
||||
* iio_scan_mask_set() - set particular bit in the scan mask
|
||||
* @buffer: the buffer whose scan mask we are interested in
|
||||
|
@ -582,27 +614,31 @@ int iio_scan_mask_set(struct iio_dev *indio_dev,
|
|||
return -ENOMEM;
|
||||
if (!indio_dev->masklength) {
|
||||
WARN_ON("trying to set scanmask prior to registering buffer\n");
|
||||
kfree(trialmask);
|
||||
return -EINVAL;
|
||||
goto err_invalid_mask;
|
||||
}
|
||||
bitmap_copy(trialmask, buffer->scan_mask, indio_dev->masklength);
|
||||
set_bit(bit, trialmask);
|
||||
|
||||
if (!iio_validate_scan_mask(indio_dev, trialmask))
|
||||
goto err_invalid_mask;
|
||||
|
||||
if (indio_dev->available_scan_masks) {
|
||||
mask = iio_scan_mask_match(indio_dev->available_scan_masks,
|
||||
indio_dev->masklength,
|
||||
trialmask);
|
||||
if (!mask) {
|
||||
kfree(trialmask);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!mask)
|
||||
goto err_invalid_mask;
|
||||
}
|
||||
bitmap_copy(buffer->scan_mask, trialmask, indio_dev->masklength);
|
||||
|
||||
kfree(trialmask);
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
err_invalid_mask:
|
||||
kfree(trialmask);
|
||||
return -EINVAL;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(iio_scan_mask_set);
|
||||
|
||||
int iio_scan_mask_query(struct iio_dev *indio_dev,
|
||||
|
|
|
@ -64,14 +64,21 @@ static const char * const iio_chan_type_name_spec[] = {
|
|||
[IIO_TIMESTAMP] = "timestamp",
|
||||
[IIO_CAPACITANCE] = "capacitance",
|
||||
[IIO_ALTVOLTAGE] = "altvoltage",
|
||||
[IIO_CCT] = "cct",
|
||||
};
|
||||
|
||||
static const char * const iio_modifier_names[] = {
|
||||
[IIO_MOD_X] = "x",
|
||||
[IIO_MOD_Y] = "y",
|
||||
[IIO_MOD_Z] = "z",
|
||||
[IIO_MOD_ROOT_SUM_SQUARED_X_Y] = "sqrt(x^2+y^2)",
|
||||
[IIO_MOD_SUM_SQUARED_X_Y_Z] = "x^2+y^2+z^2",
|
||||
[IIO_MOD_LIGHT_BOTH] = "both",
|
||||
[IIO_MOD_LIGHT_IR] = "ir",
|
||||
[IIO_MOD_LIGHT_CLEAR] = "clear",
|
||||
[IIO_MOD_LIGHT_RED] = "red",
|
||||
[IIO_MOD_LIGHT_GREEN] = "green",
|
||||
[IIO_MOD_LIGHT_BLUE] = "blue",
|
||||
};
|
||||
|
||||
/* relies on pairs of these shared then separate */
|
||||
|
@ -289,6 +296,69 @@ static ssize_t iio_write_channel_ext_info(struct device *dev,
|
|||
this_attr->c, buf, len);
|
||||
}
|
||||
|
||||
ssize_t iio_enum_available_read(struct iio_dev *indio_dev,
|
||||
uintptr_t priv, const struct iio_chan_spec *chan, char *buf)
|
||||
{
|
||||
const struct iio_enum *e = (const struct iio_enum *)priv;
|
||||
unsigned int i;
|
||||
size_t len = 0;
|
||||
|
||||
if (!e->num_items)
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < e->num_items; ++i)
|
||||
len += scnprintf(buf + len, PAGE_SIZE - len, "%s ", e->items[i]);
|
||||
|
||||
/* replace last space with a newline */
|
||||
buf[len - 1] = '\n';
|
||||
|
||||
return len;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(iio_enum_available_read);
|
||||
|
||||
ssize_t iio_enum_read(struct iio_dev *indio_dev,
|
||||
uintptr_t priv, const struct iio_chan_spec *chan, char *buf)
|
||||
{
|
||||
const struct iio_enum *e = (const struct iio_enum *)priv;
|
||||
int i;
|
||||
|
||||
if (!e->get)
|
||||
return -EINVAL;
|
||||
|
||||
i = e->get(indio_dev, chan);
|
||||
if (i < 0)
|
||||
return i;
|
||||
else if (i >= e->num_items)
|
||||
return -EINVAL;
|
||||
|
||||
return sprintf(buf, "%s\n", e->items[i]);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(iio_enum_read);
|
||||
|
||||
ssize_t iio_enum_write(struct iio_dev *indio_dev,
|
||||
uintptr_t priv, const struct iio_chan_spec *chan, const char *buf,
|
||||
size_t len)
|
||||
{
|
||||
const struct iio_enum *e = (const struct iio_enum *)priv;
|
||||
unsigned int i;
|
||||
int ret;
|
||||
|
||||
if (!e->set)
|
||||
return -EINVAL;
|
||||
|
||||
for (i = 0; i < e->num_items; i++) {
|
||||
if (sysfs_streq(buf, e->items[i]))
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == e->num_items)
|
||||
return -EINVAL;
|
||||
|
||||
ret = e->set(indio_dev, chan, i);
|
||||
return ret ? ret : len;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(iio_enum_write);
|
||||
|
||||
static ssize_t iio_read_channel_info(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
|
|
|
@ -345,7 +345,6 @@ static inline int __iio_add_event_config_attrs(struct iio_dev *indio_dev)
|
|||
{
|
||||
int j, ret, attrcount = 0;
|
||||
|
||||
INIT_LIST_HEAD(&indio_dev->event_interface->dev_attr_list);
|
||||
/* Dynically created from the channels array */
|
||||
for (j = 0; j < indio_dev->num_channels; j++) {
|
||||
ret = iio_device_add_event_sysfs(indio_dev,
|
||||
|
@ -396,6 +395,8 @@ int iio_device_register_eventset(struct iio_dev *indio_dev)
|
|||
goto error_ret;
|
||||
}
|
||||
|
||||
INIT_LIST_HEAD(&indio_dev->event_interface->dev_attr_list);
|
||||
|
||||
iio_setup_ev_int(indio_dev->event_interface);
|
||||
if (indio_dev->info->event_attrs != NULL) {
|
||||
attr = indio_dev->info->event_attrs->attrs;
|
||||
|
|
|
@ -45,31 +45,25 @@ static ssize_t iio_trigger_read_name(struct device *dev,
|
|||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct iio_trigger *trig = dev_get_drvdata(dev);
|
||||
struct iio_trigger *trig = to_iio_trigger(dev);
|
||||
return sprintf(buf, "%s\n", trig->name);
|
||||
}
|
||||
|
||||
static DEVICE_ATTR(name, S_IRUGO, iio_trigger_read_name, NULL);
|
||||
|
||||
/**
|
||||
* iio_trigger_register_sysfs() - create a device for this trigger
|
||||
* @trig_info: the trigger
|
||||
*
|
||||
* Also adds any control attribute registered by the trigger driver
|
||||
**/
|
||||
static int iio_trigger_register_sysfs(struct iio_trigger *trig_info)
|
||||
{
|
||||
return sysfs_add_file_to_group(&trig_info->dev.kobj,
|
||||
&dev_attr_name.attr,
|
||||
NULL);
|
||||
}
|
||||
static struct attribute *iio_trig_dev_attrs[] = {
|
||||
&dev_attr_name.attr,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static void iio_trigger_unregister_sysfs(struct iio_trigger *trig_info)
|
||||
{
|
||||
sysfs_remove_file_from_group(&trig_info->dev.kobj,
|
||||
&dev_attr_name.attr,
|
||||
NULL);
|
||||
}
|
||||
static struct attribute_group iio_trig_attr_group = {
|
||||
.attrs = iio_trig_dev_attrs,
|
||||
};
|
||||
|
||||
static const struct attribute_group *iio_trig_attr_groups[] = {
|
||||
&iio_trig_attr_group,
|
||||
NULL
|
||||
};
|
||||
|
||||
int iio_trigger_register(struct iio_trigger *trig_info)
|
||||
{
|
||||
|
@ -88,10 +82,6 @@ int iio_trigger_register(struct iio_trigger *trig_info)
|
|||
if (ret)
|
||||
goto error_unregister_id;
|
||||
|
||||
ret = iio_trigger_register_sysfs(trig_info);
|
||||
if (ret)
|
||||
goto error_device_del;
|
||||
|
||||
/* Add to list of available triggers held by the IIO core */
|
||||
mutex_lock(&iio_trigger_list_lock);
|
||||
list_add_tail(&trig_info->list, &iio_trigger_list);
|
||||
|
@ -99,8 +89,6 @@ int iio_trigger_register(struct iio_trigger *trig_info)
|
|||
|
||||
return 0;
|
||||
|
||||
error_device_del:
|
||||
device_del(&trig_info->dev);
|
||||
error_unregister_id:
|
||||
ida_simple_remove(&iio_trigger_ida, trig_info->id);
|
||||
error_ret:
|
||||
|
@ -114,7 +102,6 @@ void iio_trigger_unregister(struct iio_trigger *trig_info)
|
|||
list_del(&trig_info->list);
|
||||
mutex_unlock(&iio_trigger_list_lock);
|
||||
|
||||
iio_trigger_unregister_sysfs(trig_info);
|
||||
ida_simple_remove(&iio_trigger_ida, trig_info->id);
|
||||
/* Possible issue in here */
|
||||
device_unregister(&trig_info->dev);
|
||||
|
@ -234,7 +221,7 @@ static int iio_trigger_attach_poll_func(struct iio_trigger *trig,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int iio_trigger_dettach_poll_func(struct iio_trigger *trig,
|
||||
static int iio_trigger_detach_poll_func(struct iio_trigger *trig,
|
||||
struct iio_poll_func *pf)
|
||||
{
|
||||
int ret = 0;
|
||||
|
@ -406,6 +393,7 @@ static void iio_trig_release(struct device *device)
|
|||
|
||||
static struct device_type iio_trig_type = {
|
||||
.release = iio_trig_release,
|
||||
.groups = iio_trig_attr_groups,
|
||||
};
|
||||
|
||||
static void iio_trig_subirqmask(struct irq_data *d)
|
||||
|
@ -436,7 +424,6 @@ struct iio_trigger *iio_trigger_alloc(const char *fmt, ...)
|
|||
trig->dev.type = &iio_trig_type;
|
||||
trig->dev.bus = &iio_bus_type;
|
||||
device_initialize(&trig->dev);
|
||||
dev_set_drvdata(&trig->dev, (void *)trig);
|
||||
|
||||
mutex_init(&trig->pool_lock);
|
||||
trig->subirq_base
|
||||
|
@ -503,7 +490,7 @@ EXPORT_SYMBOL(iio_triggered_buffer_postenable);
|
|||
|
||||
int iio_triggered_buffer_predisable(struct iio_dev *indio_dev)
|
||||
{
|
||||
return iio_trigger_dettach_poll_func(indio_dev->trig,
|
||||
return iio_trigger_detach_poll_func(indio_dev->trig,
|
||||
indio_dev->pollfunc);
|
||||
}
|
||||
EXPORT_SYMBOL(iio_triggered_buffer_predisable);
|
||||
|
|
110
drivers/iio/industrialio-triggered-buffer.c
Normal file
110
drivers/iio/industrialio-triggered-buffer.c
Normal file
|
@ -0,0 +1,110 @@
|
|||
/*
|
||||
* Copyright (c) 2012 Analog Devices, Inc.
|
||||
* Author: Lars-Peter Clausen <lars@metafoo.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 as published by
|
||||
* the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/export.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/iio/iio.h>
|
||||
#include <linux/iio/buffer.h>
|
||||
#include <linux/iio/kfifo_buf.h>
|
||||
#include <linux/iio/triggered_buffer.h>
|
||||
#include <linux/iio/trigger_consumer.h>
|
||||
|
||||
static const struct iio_buffer_setup_ops iio_triggered_buffer_setup_ops = {
|
||||
.preenable = &iio_sw_buffer_preenable,
|
||||
.postenable = &iio_triggered_buffer_postenable,
|
||||
.predisable = &iio_triggered_buffer_predisable,
|
||||
};
|
||||
|
||||
/**
|
||||
* iio_triggered_buffer_setup() - Setup triggered buffer and pollfunc
|
||||
* @indio_dev: IIO device structure
|
||||
* @pollfunc_bh: Function which will be used as pollfunc bottom half
|
||||
* @pollfunc_th: Function which will be used as pollfunc top half
|
||||
* @setup_ops: Buffer setup functions to use for this device.
|
||||
* If NULL the default setup functions for triggered
|
||||
* buffers will be used.
|
||||
*
|
||||
* This function combines some common tasks which will normally be performed
|
||||
* when setting up a triggered buffer. It will allocate the buffer and the
|
||||
* pollfunc, as well as register the buffer with the IIO core.
|
||||
*
|
||||
* Before calling this function the indio_dev structure should already be
|
||||
* completely initialized, but not yet registered. In practice this means that
|
||||
* this function should be called right before iio_device_register().
|
||||
*
|
||||
* To free the resources allocated by this function call
|
||||
* iio_triggered_buffer_cleanup().
|
||||
*/
|
||||
int iio_triggered_buffer_setup(struct iio_dev *indio_dev,
|
||||
irqreturn_t (*pollfunc_bh)(int irq, void *p),
|
||||
irqreturn_t (*pollfunc_th)(int irq, void *p),
|
||||
const struct iio_buffer_setup_ops *setup_ops)
|
||||
{
|
||||
int ret;
|
||||
|
||||
indio_dev->buffer = iio_kfifo_allocate(indio_dev);
|
||||
if (!indio_dev->buffer) {
|
||||
ret = -ENOMEM;
|
||||
goto error_ret;
|
||||
}
|
||||
|
||||
indio_dev->pollfunc = iio_alloc_pollfunc(pollfunc_bh,
|
||||
pollfunc_th,
|
||||
IRQF_ONESHOT,
|
||||
indio_dev,
|
||||
"%s_consumer%d",
|
||||
indio_dev->name,
|
||||
indio_dev->id);
|
||||
if (indio_dev->pollfunc == NULL) {
|
||||
ret = -ENOMEM;
|
||||
goto error_kfifo_free;
|
||||
}
|
||||
|
||||
/* Ring buffer functions - here trigger setup related */
|
||||
if (setup_ops)
|
||||
indio_dev->setup_ops = setup_ops;
|
||||
else
|
||||
indio_dev->setup_ops = &iio_triggered_buffer_setup_ops;
|
||||
|
||||
/* Flag that polled ring buffering is possible */
|
||||
indio_dev->modes |= INDIO_BUFFER_TRIGGERED;
|
||||
|
||||
ret = iio_buffer_register(indio_dev,
|
||||
indio_dev->channels,
|
||||
indio_dev->num_channels);
|
||||
if (ret)
|
||||
goto error_dealloc_pollfunc;
|
||||
|
||||
return 0;
|
||||
|
||||
error_dealloc_pollfunc:
|
||||
iio_dealloc_pollfunc(indio_dev->pollfunc);
|
||||
error_kfifo_free:
|
||||
iio_kfifo_free(indio_dev->buffer);
|
||||
error_ret:
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(iio_triggered_buffer_setup);
|
||||
|
||||
/**
|
||||
* iio_triggered_buffer_cleanup() - Free resources allocated by iio_triggered_buffer_setup()
|
||||
* @indio_dev: IIO device structure
|
||||
*/
|
||||
void iio_triggered_buffer_cleanup(struct iio_dev *indio_dev)
|
||||
{
|
||||
iio_buffer_unregister(indio_dev);
|
||||
iio_dealloc_pollfunc(indio_dev->pollfunc);
|
||||
iio_kfifo_free(indio_dev->buffer);
|
||||
}
|
||||
EXPORT_SYMBOL(iio_triggered_buffer_cleanup);
|
||||
|
||||
MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
|
||||
MODULE_DESCRIPTION("IIO helper functions for setting up triggered buffers");
|
||||
MODULE_LICENSE("GPL");
|
|
@ -92,8 +92,7 @@ int iio_map_array_unregister(struct iio_dev *indio_dev,
|
|||
EXPORT_SYMBOL_GPL(iio_map_array_unregister);
|
||||
|
||||
static const struct iio_chan_spec
|
||||
*iio_chan_spec_from_name(const struct iio_dev *indio_dev,
|
||||
const char *name)
|
||||
*iio_chan_spec_from_name(const struct iio_dev *indio_dev, const char *name)
|
||||
{
|
||||
int i;
|
||||
const struct iio_chan_spec *chan = NULL;
|
||||
|
@ -108,8 +107,7 @@ static const struct iio_chan_spec
|
|||
}
|
||||
|
||||
|
||||
struct iio_channel *iio_st_channel_get(const char *name,
|
||||
const char *channel_name)
|
||||
struct iio_channel *iio_channel_get(const char *name, const char *channel_name)
|
||||
{
|
||||
struct iio_map_internal *c_i = NULL, *c = NULL;
|
||||
struct iio_channel *channel;
|
||||
|
@ -125,7 +123,7 @@ struct iio_channel *iio_st_channel_get(const char *name,
|
|||
strcmp(channel_name, c_i->map->consumer_channel) != 0))
|
||||
continue;
|
||||
c = c_i;
|
||||
get_device(&c->indio_dev->dev);
|
||||
iio_device_get(c->indio_dev);
|
||||
break;
|
||||
}
|
||||
mutex_unlock(&iio_map_list_lock);
|
||||
|
@ -145,16 +143,16 @@ struct iio_channel *iio_st_channel_get(const char *name,
|
|||
|
||||
return channel;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(iio_st_channel_get);
|
||||
EXPORT_SYMBOL_GPL(iio_channel_get);
|
||||
|
||||
void iio_st_channel_release(struct iio_channel *channel)
|
||||
void iio_channel_release(struct iio_channel *channel)
|
||||
{
|
||||
put_device(&channel->indio_dev->dev);
|
||||
iio_device_put(channel->indio_dev);
|
||||
kfree(channel);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(iio_st_channel_release);
|
||||
EXPORT_SYMBOL_GPL(iio_channel_release);
|
||||
|
||||
struct iio_channel *iio_st_channel_get_all(const char *name)
|
||||
struct iio_channel *iio_channel_get_all(const char *name)
|
||||
{
|
||||
struct iio_channel *chans;
|
||||
struct iio_map_internal *c = NULL;
|
||||
|
@ -195,44 +193,43 @@ struct iio_channel *iio_st_channel_get_all(const char *name)
|
|||
c->map->adc_channel_label);
|
||||
if (chans[mapind].channel == NULL) {
|
||||
ret = -EINVAL;
|
||||
put_device(&chans[mapind].indio_dev->dev);
|
||||
goto error_free_chans;
|
||||
}
|
||||
get_device(&chans[mapind].indio_dev->dev);
|
||||
iio_device_get(chans[mapind].indio_dev);
|
||||
mapind++;
|
||||
}
|
||||
mutex_unlock(&iio_map_list_lock);
|
||||
if (mapind == 0) {
|
||||
ret = -ENODEV;
|
||||
goto error_free_chans;
|
||||
}
|
||||
mutex_unlock(&iio_map_list_lock);
|
||||
|
||||
return chans;
|
||||
|
||||
error_free_chans:
|
||||
for (i = 0; i < nummaps; i++)
|
||||
if (chans[i].indio_dev)
|
||||
put_device(&chans[i].indio_dev->dev);
|
||||
iio_device_put(chans[i].indio_dev);
|
||||
kfree(chans);
|
||||
error_ret:
|
||||
mutex_unlock(&iio_map_list_lock);
|
||||
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(iio_st_channel_get_all);
|
||||
EXPORT_SYMBOL_GPL(iio_channel_get_all);
|
||||
|
||||
void iio_st_channel_release_all(struct iio_channel *channels)
|
||||
void iio_channel_release_all(struct iio_channel *channels)
|
||||
{
|
||||
struct iio_channel *chan = &channels[0];
|
||||
|
||||
while (chan->indio_dev) {
|
||||
put_device(&chan->indio_dev->dev);
|
||||
iio_device_put(chan->indio_dev);
|
||||
chan++;
|
||||
}
|
||||
kfree(channels);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(iio_st_channel_release_all);
|
||||
EXPORT_SYMBOL_GPL(iio_channel_release_all);
|
||||
|
||||
int iio_st_read_channel_raw(struct iio_channel *chan, int *val)
|
||||
int iio_read_channel_raw(struct iio_channel *chan, int *val)
|
||||
{
|
||||
int val2, ret;
|
||||
|
||||
|
@ -249,9 +246,9 @@ int iio_st_read_channel_raw(struct iio_channel *chan, int *val)
|
|||
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(iio_st_read_channel_raw);
|
||||
EXPORT_SYMBOL_GPL(iio_read_channel_raw);
|
||||
|
||||
int iio_st_read_channel_scale(struct iio_channel *chan, int *val, int *val2)
|
||||
int iio_read_channel_scale(struct iio_channel *chan, int *val, int *val2)
|
||||
{
|
||||
int ret;
|
||||
|
||||
|
@ -270,10 +267,9 @@ int iio_st_read_channel_scale(struct iio_channel *chan, int *val, int *val2)
|
|||
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(iio_st_read_channel_scale);
|
||||
EXPORT_SYMBOL_GPL(iio_read_channel_scale);
|
||||
|
||||
int iio_st_get_channel_type(struct iio_channel *chan,
|
||||
enum iio_chan_type *type)
|
||||
int iio_get_channel_type(struct iio_channel *chan, enum iio_chan_type *type)
|
||||
{
|
||||
int ret = 0;
|
||||
/* Need to verify underlying driver has not gone away */
|
||||
|
@ -290,4 +286,4 @@ int iio_st_get_channel_type(struct iio_channel *chan,
|
|||
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(iio_st_get_channel_type);
|
||||
EXPORT_SYMBOL_GPL(iio_get_channel_type);
|
||||
|
|
45
drivers/iio/light/Kconfig
Normal file
45
drivers/iio/light/Kconfig
Normal file
|
@ -0,0 +1,45 @@
|
|||
#
|
||||
# Light sensors
|
||||
#
|
||||
menu "Light sensors"
|
||||
|
||||
config ADJD_S311
|
||||
tristate "ADJD-S311-CR999 digital color sensor"
|
||||
select IIO_BUFFER
|
||||
select IIO_TRIGGERED_BUFFER
|
||||
depends on I2C
|
||||
help
|
||||
If you say yes here you get support for the Avago ADJD-S311-CR999
|
||||
digital color light sensor.
|
||||
|
||||
This driver can also be built as a module. If so, the module
|
||||
will be called adjd_s311.
|
||||
|
||||
config SENSORS_LM3533
|
||||
tristate "LM3533 ambient light sensor"
|
||||
depends on MFD_LM3533
|
||||
help
|
||||
If you say yes here you get support for the ambient light sensor
|
||||
interface on National Semiconductor / TI LM3533 Lighting Power
|
||||
chips.
|
||||
|
||||
The sensor interface can be used to control the LEDs and backlights
|
||||
of the chip through defining five light zones and three sets of
|
||||
corresponding output-current values.
|
||||
|
||||
The driver provides raw and mean adc readings along with the current
|
||||
light zone through sysfs. A threshold event can be generated on zone
|
||||
changes. The ALS-control output values can be set per zone for the
|
||||
three current output channels.
|
||||
|
||||
config VCNL4000
|
||||
tristate "VCNL4000 combined ALS and proximity sensor"
|
||||
depends on I2C
|
||||
help
|
||||
Say Y here if you want to build a driver for the Vishay VCNL4000
|
||||
combined ambient light and proximity sensor.
|
||||
|
||||
To compile this driver as a module, choose M here: the
|
||||
module will be called vcnl4000.
|
||||
|
||||
endmenu
|
7
drivers/iio/light/Makefile
Normal file
7
drivers/iio/light/Makefile
Normal file
|
@ -0,0 +1,7 @@
|
|||
#
|
||||
# Makefile for IIO Light sensors
|
||||
#
|
||||
|
||||
obj-$(CONFIG_ADJD_S311) += adjd_s311.o
|
||||
obj-$(CONFIG_SENSORS_LM3533) += lm3533-als.o
|
||||
obj-$(CONFIG_VCNL4000) += vcnl4000.o
|
364
drivers/iio/light/adjd_s311.c
Normal file
364
drivers/iio/light/adjd_s311.c
Normal file
|
@ -0,0 +1,364 @@
|
|||
/*
|
||||
* adjd_s311.c - Support for ADJD-S311-CR999 digital color sensor
|
||||
*
|
||||
* Copyright (C) 2012 Peter Meerwald <pmeerw@pmeerw.net>
|
||||
*
|
||||
* This file is subject to the terms and conditions of version 2 of
|
||||
* the GNU General Public License. See the file COPYING in the main
|
||||
* directory of this archive for more details.
|
||||
*
|
||||
* driver for ADJD-S311-CR999 digital color sensor (10-bit channels for
|
||||
* red, green, blue, clear); 7-bit I2C slave address 0x74
|
||||
*
|
||||
* limitations: no calibration, no offset mode, no sleep mode
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/bitmap.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/irq.h>
|
||||
|
||||
#include <linux/iio/iio.h>
|
||||
#include <linux/iio/sysfs.h>
|
||||
#include <linux/iio/trigger_consumer.h>
|
||||
#include <linux/iio/buffer.h>
|
||||
#include <linux/iio/triggered_buffer.h>
|
||||
|
||||
#define ADJD_S311_DRV_NAME "adjd_s311"
|
||||
|
||||
#define ADJD_S311_CTRL 0x00
|
||||
#define ADJD_S311_CONFIG 0x01
|
||||
#define ADJD_S311_CAP_RED 0x06
|
||||
#define ADJD_S311_CAP_GREEN 0x07
|
||||
#define ADJD_S311_CAP_BLUE 0x08
|
||||
#define ADJD_S311_CAP_CLEAR 0x09
|
||||
#define ADJD_S311_INT_RED_LO 0x0a
|
||||
#define ADJD_S311_INT_RED_HI 0x0b
|
||||
#define ADJD_S311_INT_GREEN_LO 0x0c
|
||||
#define ADJD_S311_INT_GREEN_HI 0x0d
|
||||
#define ADJD_S311_INT_BLUE_LO 0x0e
|
||||
#define ADJD_S311_INT_BLUE_HI 0x0f
|
||||
#define ADJD_S311_INT_CLEAR_LO 0x10
|
||||
#define ADJD_S311_INT_CLEAR_HI 0x11
|
||||
#define ADJD_S311_DATA_RED_LO 0x40
|
||||
#define ADJD_S311_DATA_RED_HI 0x41
|
||||
#define ADJD_S311_DATA_GREEN_LO 0x42
|
||||
#define ADJD_S311_DATA_GREEN_HI 0x43
|
||||
#define ADJD_S311_DATA_BLUE_LO 0x44
|
||||
#define ADJD_S311_DATA_BLUE_HI 0x45
|
||||
#define ADJD_S311_DATA_CLEAR_LO 0x46
|
||||
#define ADJD_S311_DATA_CLEAR_HI 0x47
|
||||
#define ADJD_S311_OFFSET_RED 0x48
|
||||
#define ADJD_S311_OFFSET_GREEN 0x49
|
||||
#define ADJD_S311_OFFSET_BLUE 0x4a
|
||||
#define ADJD_S311_OFFSET_CLEAR 0x4b
|
||||
|
||||
#define ADJD_S311_CTRL_GOFS 0x02
|
||||
#define ADJD_S311_CTRL_GSSR 0x01
|
||||
#define ADJD_S311_CAP_MASK 0x0f
|
||||
#define ADJD_S311_INT_MASK 0x0fff
|
||||
#define ADJD_S311_DATA_MASK 0x03ff
|
||||
|
||||
struct adjd_s311_data {
|
||||
struct i2c_client *client;
|
||||
u16 *buffer;
|
||||
};
|
||||
|
||||
enum adjd_s311_channel_idx {
|
||||
IDX_RED, IDX_GREEN, IDX_BLUE, IDX_CLEAR
|
||||
};
|
||||
|
||||
#define ADJD_S311_DATA_REG(chan) (ADJD_S311_DATA_RED_LO + (chan) * 2)
|
||||
#define ADJD_S311_INT_REG(chan) (ADJD_S311_INT_RED_LO + (chan) * 2)
|
||||
#define ADJD_S311_CAP_REG(chan) (ADJD_S311_CAP_RED + (chan))
|
||||
|
||||
static int adjd_s311_req_data(struct iio_dev *indio_dev)
|
||||
{
|
||||
struct adjd_s311_data *data = iio_priv(indio_dev);
|
||||
int tries = 10;
|
||||
|
||||
int ret = i2c_smbus_write_byte_data(data->client, ADJD_S311_CTRL,
|
||||
ADJD_S311_CTRL_GSSR);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
while (tries--) {
|
||||
ret = i2c_smbus_read_byte_data(data->client, ADJD_S311_CTRL);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
if (!(ret & ADJD_S311_CTRL_GSSR))
|
||||
break;
|
||||
msleep(20);
|
||||
}
|
||||
|
||||
if (tries < 0) {
|
||||
dev_err(&data->client->dev,
|
||||
"adjd_s311_req_data() failed, data not ready\n");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int adjd_s311_read_data(struct iio_dev *indio_dev, u8 reg, int *val)
|
||||
{
|
||||
struct adjd_s311_data *data = iio_priv(indio_dev);
|
||||
|
||||
int ret = adjd_s311_req_data(indio_dev);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ret = i2c_smbus_read_word_data(data->client, reg);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
*val = ret & ADJD_S311_DATA_MASK;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ssize_t adjd_s311_read_int_time(struct iio_dev *indio_dev,
|
||||
uintptr_t private, const struct iio_chan_spec *chan, char *buf)
|
||||
{
|
||||
struct adjd_s311_data *data = iio_priv(indio_dev);
|
||||
s32 ret;
|
||||
|
||||
ret = i2c_smbus_read_word_data(data->client,
|
||||
ADJD_S311_INT_REG(chan->address));
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
return sprintf(buf, "%d\n", ret & ADJD_S311_INT_MASK);
|
||||
}
|
||||
|
||||
static ssize_t adjd_s311_write_int_time(struct iio_dev *indio_dev,
|
||||
uintptr_t private, const struct iio_chan_spec *chan, const char *buf,
|
||||
size_t len)
|
||||
{
|
||||
struct adjd_s311_data *data = iio_priv(indio_dev);
|
||||
unsigned long int_time;
|
||||
int ret;
|
||||
|
||||
ret = kstrtoul(buf, 10, &int_time);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (int_time > ADJD_S311_INT_MASK)
|
||||
return -EINVAL;
|
||||
|
||||
ret = i2c_smbus_write_word_data(data->client,
|
||||
ADJD_S311_INT_REG(chan->address), int_time);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
static irqreturn_t adjd_s311_trigger_handler(int irq, void *p)
|
||||
{
|
||||
struct iio_poll_func *pf = p;
|
||||
struct iio_dev *indio_dev = pf->indio_dev;
|
||||
struct adjd_s311_data *data = iio_priv(indio_dev);
|
||||
struct iio_buffer *buffer = indio_dev->buffer;
|
||||
s64 time_ns = iio_get_time_ns();
|
||||
int len = 0;
|
||||
int i, j = 0;
|
||||
|
||||
int ret = adjd_s311_req_data(indio_dev);
|
||||
if (ret < 0)
|
||||
goto done;
|
||||
|
||||
for_each_set_bit(i, indio_dev->active_scan_mask,
|
||||
indio_dev->masklength) {
|
||||
ret = i2c_smbus_read_word_data(data->client,
|
||||
ADJD_S311_DATA_REG(i));
|
||||
if (ret < 0)
|
||||
goto done;
|
||||
|
||||
data->buffer[j++] = ret & ADJD_S311_DATA_MASK;
|
||||
len += 2;
|
||||
}
|
||||
|
||||
if (indio_dev->scan_timestamp)
|
||||
*(s64 *)((u8 *)data->buffer + ALIGN(len, sizeof(s64)))
|
||||
= time_ns;
|
||||
iio_push_to_buffer(buffer, (u8 *)data->buffer, time_ns);
|
||||
|
||||
done:
|
||||
iio_trigger_notify_done(indio_dev->trig);
|
||||
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
static const struct iio_chan_spec_ext_info adjd_s311_ext_info[] = {
|
||||
{
|
||||
.name = "integration_time",
|
||||
.read = adjd_s311_read_int_time,
|
||||
.write = adjd_s311_write_int_time,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
#define ADJD_S311_CHANNEL(_color, _scan_idx) { \
|
||||
.type = IIO_INTENSITY, \
|
||||
.modified = 1, \
|
||||
.address = (IDX_##_color), \
|
||||
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
|
||||
IIO_CHAN_INFO_HARDWAREGAIN_SEPARATE_BIT, \
|
||||
.channel2 = (IIO_MOD_LIGHT_##_color), \
|
||||
.scan_index = (_scan_idx), \
|
||||
.scan_type = IIO_ST('u', 10, 16, 0), \
|
||||
.ext_info = adjd_s311_ext_info, \
|
||||
}
|
||||
|
||||
static const struct iio_chan_spec adjd_s311_channels[] = {
|
||||
ADJD_S311_CHANNEL(RED, 0),
|
||||
ADJD_S311_CHANNEL(GREEN, 1),
|
||||
ADJD_S311_CHANNEL(BLUE, 2),
|
||||
ADJD_S311_CHANNEL(CLEAR, 3),
|
||||
IIO_CHAN_SOFT_TIMESTAMP(4),
|
||||
};
|
||||
|
||||
static int adjd_s311_read_raw(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec const *chan,
|
||||
int *val, int *val2, long mask)
|
||||
{
|
||||
struct adjd_s311_data *data = iio_priv(indio_dev);
|
||||
int ret;
|
||||
|
||||
switch (mask) {
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
ret = adjd_s311_read_data(indio_dev, chan->address, val);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
return IIO_VAL_INT;
|
||||
case IIO_CHAN_INFO_HARDWAREGAIN:
|
||||
ret = i2c_smbus_read_byte_data(data->client,
|
||||
ADJD_S311_CAP_REG(chan->address));
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
*val = ret & ADJD_S311_CAP_MASK;
|
||||
return IIO_VAL_INT;
|
||||
}
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static int adjd_s311_write_raw(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec const *chan,
|
||||
int val, int val2, long mask)
|
||||
{
|
||||
struct adjd_s311_data *data = iio_priv(indio_dev);
|
||||
int ret;
|
||||
|
||||
switch (mask) {
|
||||
case IIO_CHAN_INFO_HARDWAREGAIN:
|
||||
if (val < 0 || val > ADJD_S311_CAP_MASK)
|
||||
return -EINVAL;
|
||||
|
||||
ret = i2c_smbus_write_byte_data(data->client,
|
||||
ADJD_S311_CAP_REG(chan->address), val);
|
||||
return ret;
|
||||
}
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static int adjd_s311_update_scan_mode(struct iio_dev *indio_dev,
|
||||
const unsigned long *scan_mask)
|
||||
{
|
||||
struct adjd_s311_data *data = iio_priv(indio_dev);
|
||||
data->buffer = krealloc(data->buffer, indio_dev->scan_bytes,
|
||||
GFP_KERNEL);
|
||||
if (!data->buffer)
|
||||
return -ENOMEM;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct iio_info adjd_s311_info = {
|
||||
.read_raw = adjd_s311_read_raw,
|
||||
.write_raw = adjd_s311_write_raw,
|
||||
.update_scan_mode = adjd_s311_update_scan_mode,
|
||||
.driver_module = THIS_MODULE,
|
||||
};
|
||||
|
||||
static int __devinit adjd_s311_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *id)
|
||||
{
|
||||
struct adjd_s311_data *data;
|
||||
struct iio_dev *indio_dev;
|
||||
int err;
|
||||
|
||||
indio_dev = iio_device_alloc(sizeof(*data));
|
||||
if (indio_dev == NULL) {
|
||||
err = -ENOMEM;
|
||||
goto exit;
|
||||
}
|
||||
data = iio_priv(indio_dev);
|
||||
i2c_set_clientdata(client, indio_dev);
|
||||
data->client = client;
|
||||
|
||||
indio_dev->dev.parent = &client->dev;
|
||||
indio_dev->info = &adjd_s311_info;
|
||||
indio_dev->name = ADJD_S311_DRV_NAME;
|
||||
indio_dev->channels = adjd_s311_channels;
|
||||
indio_dev->num_channels = ARRAY_SIZE(adjd_s311_channels);
|
||||
indio_dev->modes = INDIO_DIRECT_MODE;
|
||||
|
||||
err = iio_triggered_buffer_setup(indio_dev, NULL,
|
||||
adjd_s311_trigger_handler, NULL);
|
||||
if (err < 0)
|
||||
goto exit_free_device;
|
||||
|
||||
err = iio_device_register(indio_dev);
|
||||
if (err)
|
||||
goto exit_unreg_buffer;
|
||||
|
||||
dev_info(&client->dev, "ADJD-S311 color sensor registered\n");
|
||||
|
||||
return 0;
|
||||
|
||||
exit_unreg_buffer:
|
||||
iio_triggered_buffer_cleanup(indio_dev);
|
||||
exit_free_device:
|
||||
iio_device_free(indio_dev);
|
||||
exit:
|
||||
return err;
|
||||
}
|
||||
|
||||
static int __devexit adjd_s311_remove(struct i2c_client *client)
|
||||
{
|
||||
struct iio_dev *indio_dev = i2c_get_clientdata(client);
|
||||
struct adjd_s311_data *data = iio_priv(indio_dev);
|
||||
|
||||
iio_device_unregister(indio_dev);
|
||||
iio_triggered_buffer_cleanup(indio_dev);
|
||||
kfree(data->buffer);
|
||||
iio_device_free(indio_dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct i2c_device_id adjd_s311_id[] = {
|
||||
{ "adjd_s311", 0 },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, adjd_s311_id);
|
||||
|
||||
static struct i2c_driver adjd_s311_driver = {
|
||||
.driver = {
|
||||
.name = ADJD_S311_DRV_NAME,
|
||||
},
|
||||
.probe = adjd_s311_probe,
|
||||
.remove = __devexit_p(adjd_s311_remove),
|
||||
.id_table = adjd_s311_id,
|
||||
};
|
||||
module_i2c_driver(adjd_s311_driver);
|
||||
|
||||
MODULE_AUTHOR("Peter Meerwald <pmeerw@pmeerw.net>");
|
||||
MODULE_DESCRIPTION("ADJD-S311 color sensor");
|
||||
MODULE_LICENSE("GPL");
|
932
drivers/iio/light/lm3533-als.c
Normal file
932
drivers/iio/light/lm3533-als.c
Normal file
|
@ -0,0 +1,932 @@
|
|||
/*
|
||||
* lm3533-als.c -- LM3533 Ambient Light Sensor driver
|
||||
*
|
||||
* Copyright (C) 2011-2012 Texas Instruments
|
||||
*
|
||||
* Author: Johan Hovold <jhovold@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*/
|
||||
|
||||
#include <linux/atomic.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/io.h>
|
||||
#include <linux/iio/events.h>
|
||||
#include <linux/iio/iio.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/mfd/core.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/uaccess.h>
|
||||
|
||||
#include <linux/mfd/lm3533.h>
|
||||
|
||||
|
||||
#define LM3533_ALS_RESISTOR_MIN 1
|
||||
#define LM3533_ALS_RESISTOR_MAX 127
|
||||
#define LM3533_ALS_CHANNEL_CURRENT_MAX 2
|
||||
#define LM3533_ALS_THRESH_MAX 3
|
||||
#define LM3533_ALS_ZONE_MAX 4
|
||||
|
||||
#define LM3533_REG_ALS_RESISTOR_SELECT 0x30
|
||||
#define LM3533_REG_ALS_CONF 0x31
|
||||
#define LM3533_REG_ALS_ZONE_INFO 0x34
|
||||
#define LM3533_REG_ALS_READ_ADC_RAW 0x37
|
||||
#define LM3533_REG_ALS_READ_ADC_AVERAGE 0x38
|
||||
#define LM3533_REG_ALS_BOUNDARY_BASE 0x50
|
||||
#define LM3533_REG_ALS_TARGET_BASE 0x60
|
||||
|
||||
#define LM3533_ALS_ENABLE_MASK 0x01
|
||||
#define LM3533_ALS_INPUT_MODE_MASK 0x02
|
||||
#define LM3533_ALS_INT_ENABLE_MASK 0x01
|
||||
|
||||
#define LM3533_ALS_ZONE_SHIFT 2
|
||||
#define LM3533_ALS_ZONE_MASK 0x1c
|
||||
|
||||
#define LM3533_ALS_FLAG_INT_ENABLED 1
|
||||
|
||||
|
||||
struct lm3533_als {
|
||||
struct lm3533 *lm3533;
|
||||
struct platform_device *pdev;
|
||||
|
||||
unsigned long flags;
|
||||
int irq;
|
||||
|
||||
atomic_t zone;
|
||||
struct mutex thresh_mutex;
|
||||
};
|
||||
|
||||
|
||||
static int lm3533_als_get_adc(struct iio_dev *indio_dev, bool average,
|
||||
int *adc)
|
||||
{
|
||||
struct lm3533_als *als = iio_priv(indio_dev);
|
||||
u8 reg;
|
||||
u8 val;
|
||||
int ret;
|
||||
|
||||
if (average)
|
||||
reg = LM3533_REG_ALS_READ_ADC_AVERAGE;
|
||||
else
|
||||
reg = LM3533_REG_ALS_READ_ADC_RAW;
|
||||
|
||||
ret = lm3533_read(als->lm3533, reg, &val);
|
||||
if (ret) {
|
||||
dev_err(&indio_dev->dev, "failed to read adc\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
*adc = val;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _lm3533_als_get_zone(struct iio_dev *indio_dev, u8 *zone)
|
||||
{
|
||||
struct lm3533_als *als = iio_priv(indio_dev);
|
||||
u8 val;
|
||||
int ret;
|
||||
|
||||
ret = lm3533_read(als->lm3533, LM3533_REG_ALS_ZONE_INFO, &val);
|
||||
if (ret) {
|
||||
dev_err(&indio_dev->dev, "failed to read zone\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
val = (val & LM3533_ALS_ZONE_MASK) >> LM3533_ALS_ZONE_SHIFT;
|
||||
*zone = min_t(u8, val, LM3533_ALS_ZONE_MAX);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lm3533_als_get_zone(struct iio_dev *indio_dev, u8 *zone)
|
||||
{
|
||||
struct lm3533_als *als = iio_priv(indio_dev);
|
||||
int ret;
|
||||
|
||||
if (test_bit(LM3533_ALS_FLAG_INT_ENABLED, &als->flags)) {
|
||||
*zone = atomic_read(&als->zone);
|
||||
} else {
|
||||
ret = _lm3533_als_get_zone(indio_dev, zone);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* channel output channel 0..2
|
||||
* zone zone 0..4
|
||||
*/
|
||||
static inline u8 lm3533_als_get_target_reg(unsigned channel, unsigned zone)
|
||||
{
|
||||
return LM3533_REG_ALS_TARGET_BASE + 5 * channel + zone;
|
||||
}
|
||||
|
||||
static int lm3533_als_get_target(struct iio_dev *indio_dev, unsigned channel,
|
||||
unsigned zone, u8 *val)
|
||||
{
|
||||
struct lm3533_als *als = iio_priv(indio_dev);
|
||||
u8 reg;
|
||||
int ret;
|
||||
|
||||
if (channel > LM3533_ALS_CHANNEL_CURRENT_MAX)
|
||||
return -EINVAL;
|
||||
|
||||
if (zone > LM3533_ALS_ZONE_MAX)
|
||||
return -EINVAL;
|
||||
|
||||
reg = lm3533_als_get_target_reg(channel, zone);
|
||||
ret = lm3533_read(als->lm3533, reg, val);
|
||||
if (ret)
|
||||
dev_err(&indio_dev->dev, "failed to get target current\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int lm3533_als_set_target(struct iio_dev *indio_dev, unsigned channel,
|
||||
unsigned zone, u8 val)
|
||||
{
|
||||
struct lm3533_als *als = iio_priv(indio_dev);
|
||||
u8 reg;
|
||||
int ret;
|
||||
|
||||
if (channel > LM3533_ALS_CHANNEL_CURRENT_MAX)
|
||||
return -EINVAL;
|
||||
|
||||
if (zone > LM3533_ALS_ZONE_MAX)
|
||||
return -EINVAL;
|
||||
|
||||
reg = lm3533_als_get_target_reg(channel, zone);
|
||||
ret = lm3533_write(als->lm3533, reg, val);
|
||||
if (ret)
|
||||
dev_err(&indio_dev->dev, "failed to set target current\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int lm3533_als_get_current(struct iio_dev *indio_dev, unsigned channel,
|
||||
int *val)
|
||||
{
|
||||
u8 zone;
|
||||
u8 target;
|
||||
int ret;
|
||||
|
||||
ret = lm3533_als_get_zone(indio_dev, &zone);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = lm3533_als_get_target(indio_dev, channel, zone, &target);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
*val = target;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lm3533_als_read_raw(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec const *chan,
|
||||
int *val, int *val2, long mask)
|
||||
{
|
||||
int ret;
|
||||
|
||||
switch (mask) {
|
||||
case 0:
|
||||
switch (chan->type) {
|
||||
case IIO_LIGHT:
|
||||
ret = lm3533_als_get_adc(indio_dev, false, val);
|
||||
break;
|
||||
case IIO_CURRENT:
|
||||
ret = lm3533_als_get_current(indio_dev, chan->channel,
|
||||
val);
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
break;
|
||||
case IIO_CHAN_INFO_AVERAGE_RAW:
|
||||
ret = lm3533_als_get_adc(indio_dev, true, val);
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return IIO_VAL_INT;
|
||||
}
|
||||
|
||||
#define CHANNEL_CURRENT(_channel) \
|
||||
{ \
|
||||
.type = IIO_CURRENT, \
|
||||
.channel = _channel, \
|
||||
.indexed = true, \
|
||||
.output = true, \
|
||||
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT, \
|
||||
}
|
||||
|
||||
static const struct iio_chan_spec lm3533_als_channels[] = {
|
||||
{
|
||||
.type = IIO_LIGHT,
|
||||
.channel = 0,
|
||||
.indexed = true,
|
||||
.info_mask = (IIO_CHAN_INFO_AVERAGE_RAW_SEPARATE_BIT |
|
||||
IIO_CHAN_INFO_RAW_SEPARATE_BIT),
|
||||
},
|
||||
CHANNEL_CURRENT(0),
|
||||
CHANNEL_CURRENT(1),
|
||||
CHANNEL_CURRENT(2),
|
||||
};
|
||||
|
||||
static irqreturn_t lm3533_als_isr(int irq, void *dev_id)
|
||||
{
|
||||
|
||||
struct iio_dev *indio_dev = dev_id;
|
||||
struct lm3533_als *als = iio_priv(indio_dev);
|
||||
u8 zone;
|
||||
int ret;
|
||||
|
||||
/* Clear interrupt by reading the ALS zone register. */
|
||||
ret = _lm3533_als_get_zone(indio_dev, &zone);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
atomic_set(&als->zone, zone);
|
||||
|
||||
iio_push_event(indio_dev,
|
||||
IIO_UNMOD_EVENT_CODE(IIO_LIGHT,
|
||||
0,
|
||||
IIO_EV_TYPE_THRESH,
|
||||
IIO_EV_DIR_EITHER),
|
||||
iio_get_time_ns());
|
||||
out:
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
static int lm3533_als_set_int_mode(struct iio_dev *indio_dev, int enable)
|
||||
{
|
||||
struct lm3533_als *als = iio_priv(indio_dev);
|
||||
u8 mask = LM3533_ALS_INT_ENABLE_MASK;
|
||||
u8 val;
|
||||
int ret;
|
||||
|
||||
if (enable)
|
||||
val = mask;
|
||||
else
|
||||
val = 0;
|
||||
|
||||
ret = lm3533_update(als->lm3533, LM3533_REG_ALS_ZONE_INFO, val, mask);
|
||||
if (ret) {
|
||||
dev_err(&indio_dev->dev, "failed to set int mode %d\n",
|
||||
enable);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lm3533_als_get_int_mode(struct iio_dev *indio_dev, int *enable)
|
||||
{
|
||||
struct lm3533_als *als = iio_priv(indio_dev);
|
||||
u8 mask = LM3533_ALS_INT_ENABLE_MASK;
|
||||
u8 val;
|
||||
int ret;
|
||||
|
||||
ret = lm3533_read(als->lm3533, LM3533_REG_ALS_ZONE_INFO, &val);
|
||||
if (ret) {
|
||||
dev_err(&indio_dev->dev, "failed to get int mode\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
*enable = !!(val & mask);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline u8 lm3533_als_get_threshold_reg(unsigned nr, bool raising)
|
||||
{
|
||||
u8 offset = !raising;
|
||||
|
||||
return LM3533_REG_ALS_BOUNDARY_BASE + 2 * nr + offset;
|
||||
}
|
||||
|
||||
static int lm3533_als_get_threshold(struct iio_dev *indio_dev, unsigned nr,
|
||||
bool raising, u8 *val)
|
||||
{
|
||||
struct lm3533_als *als = iio_priv(indio_dev);
|
||||
u8 reg;
|
||||
int ret;
|
||||
|
||||
if (nr > LM3533_ALS_THRESH_MAX)
|
||||
return -EINVAL;
|
||||
|
||||
reg = lm3533_als_get_threshold_reg(nr, raising);
|
||||
ret = lm3533_read(als->lm3533, reg, val);
|
||||
if (ret)
|
||||
dev_err(&indio_dev->dev, "failed to get threshold\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int lm3533_als_set_threshold(struct iio_dev *indio_dev, unsigned nr,
|
||||
bool raising, u8 val)
|
||||
{
|
||||
struct lm3533_als *als = iio_priv(indio_dev);
|
||||
u8 val2;
|
||||
u8 reg, reg2;
|
||||
int ret;
|
||||
|
||||
if (nr > LM3533_ALS_THRESH_MAX)
|
||||
return -EINVAL;
|
||||
|
||||
reg = lm3533_als_get_threshold_reg(nr, raising);
|
||||
reg2 = lm3533_als_get_threshold_reg(nr, !raising);
|
||||
|
||||
mutex_lock(&als->thresh_mutex);
|
||||
ret = lm3533_read(als->lm3533, reg2, &val2);
|
||||
if (ret) {
|
||||
dev_err(&indio_dev->dev, "failed to get threshold\n");
|
||||
goto out;
|
||||
}
|
||||
/*
|
||||
* This device does not allow negative hysteresis (in fact, it uses
|
||||
* whichever value is smaller as the lower bound) so we need to make
|
||||
* sure that thresh_falling <= thresh_raising.
|
||||
*/
|
||||
if ((raising && (val < val2)) || (!raising && (val > val2))) {
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = lm3533_write(als->lm3533, reg, val);
|
||||
if (ret) {
|
||||
dev_err(&indio_dev->dev, "failed to set threshold\n");
|
||||
goto out;
|
||||
}
|
||||
out:
|
||||
mutex_unlock(&als->thresh_mutex);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int lm3533_als_get_hysteresis(struct iio_dev *indio_dev, unsigned nr,
|
||||
u8 *val)
|
||||
{
|
||||
struct lm3533_als *als = iio_priv(indio_dev);
|
||||
u8 falling;
|
||||
u8 raising;
|
||||
int ret;
|
||||
|
||||
if (nr > LM3533_ALS_THRESH_MAX)
|
||||
return -EINVAL;
|
||||
|
||||
mutex_lock(&als->thresh_mutex);
|
||||
ret = lm3533_als_get_threshold(indio_dev, nr, false, &falling);
|
||||
if (ret)
|
||||
goto out;
|
||||
ret = lm3533_als_get_threshold(indio_dev, nr, true, &raising);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
*val = raising - falling;
|
||||
out:
|
||||
mutex_unlock(&als->thresh_mutex);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int show_thresh_either_en(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct lm3533_als *als = iio_priv(indio_dev);
|
||||
int enable;
|
||||
int ret;
|
||||
|
||||
if (als->irq) {
|
||||
ret = lm3533_als_get_int_mode(indio_dev, &enable);
|
||||
if (ret)
|
||||
return ret;
|
||||
} else {
|
||||
enable = 0;
|
||||
}
|
||||
|
||||
return scnprintf(buf, PAGE_SIZE, "%u\n", enable);
|
||||
}
|
||||
|
||||
static int store_thresh_either_en(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t len)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct lm3533_als *als = iio_priv(indio_dev);
|
||||
unsigned long enable;
|
||||
bool int_enabled;
|
||||
u8 zone;
|
||||
int ret;
|
||||
|
||||
if (!als->irq)
|
||||
return -EBUSY;
|
||||
|
||||
if (kstrtoul(buf, 0, &enable))
|
||||
return -EINVAL;
|
||||
|
||||
int_enabled = test_bit(LM3533_ALS_FLAG_INT_ENABLED, &als->flags);
|
||||
|
||||
if (enable && !int_enabled) {
|
||||
ret = lm3533_als_get_zone(indio_dev, &zone);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
atomic_set(&als->zone, zone);
|
||||
|
||||
set_bit(LM3533_ALS_FLAG_INT_ENABLED, &als->flags);
|
||||
}
|
||||
|
||||
ret = lm3533_als_set_int_mode(indio_dev, enable);
|
||||
if (ret) {
|
||||
if (!int_enabled)
|
||||
clear_bit(LM3533_ALS_FLAG_INT_ENABLED, &als->flags);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (!enable)
|
||||
clear_bit(LM3533_ALS_FLAG_INT_ENABLED, &als->flags);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
static ssize_t show_zone(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
u8 zone;
|
||||
int ret;
|
||||
|
||||
ret = lm3533_als_get_zone(indio_dev, &zone);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return scnprintf(buf, PAGE_SIZE, "%u\n", zone);
|
||||
}
|
||||
|
||||
enum lm3533_als_attribute_type {
|
||||
LM3533_ATTR_TYPE_HYSTERESIS,
|
||||
LM3533_ATTR_TYPE_TARGET,
|
||||
LM3533_ATTR_TYPE_THRESH_FALLING,
|
||||
LM3533_ATTR_TYPE_THRESH_RAISING,
|
||||
};
|
||||
|
||||
struct lm3533_als_attribute {
|
||||
struct device_attribute dev_attr;
|
||||
enum lm3533_als_attribute_type type;
|
||||
u8 val1;
|
||||
u8 val2;
|
||||
};
|
||||
|
||||
static inline struct lm3533_als_attribute *
|
||||
to_lm3533_als_attr(struct device_attribute *attr)
|
||||
{
|
||||
return container_of(attr, struct lm3533_als_attribute, dev_attr);
|
||||
}
|
||||
|
||||
static ssize_t show_als_attr(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct lm3533_als_attribute *als_attr = to_lm3533_als_attr(attr);
|
||||
u8 val;
|
||||
int ret;
|
||||
|
||||
switch (als_attr->type) {
|
||||
case LM3533_ATTR_TYPE_HYSTERESIS:
|
||||
ret = lm3533_als_get_hysteresis(indio_dev, als_attr->val1,
|
||||
&val);
|
||||
break;
|
||||
case LM3533_ATTR_TYPE_TARGET:
|
||||
ret = lm3533_als_get_target(indio_dev, als_attr->val1,
|
||||
als_attr->val2, &val);
|
||||
break;
|
||||
case LM3533_ATTR_TYPE_THRESH_FALLING:
|
||||
ret = lm3533_als_get_threshold(indio_dev, als_attr->val1,
|
||||
false, &val);
|
||||
break;
|
||||
case LM3533_ATTR_TYPE_THRESH_RAISING:
|
||||
ret = lm3533_als_get_threshold(indio_dev, als_attr->val1,
|
||||
true, &val);
|
||||
break;
|
||||
default:
|
||||
ret = -ENXIO;
|
||||
}
|
||||
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return scnprintf(buf, PAGE_SIZE, "%u\n", val);
|
||||
}
|
||||
|
||||
static ssize_t store_als_attr(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t len)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct lm3533_als_attribute *als_attr = to_lm3533_als_attr(attr);
|
||||
u8 val;
|
||||
int ret;
|
||||
|
||||
if (kstrtou8(buf, 0, &val))
|
||||
return -EINVAL;
|
||||
|
||||
switch (als_attr->type) {
|
||||
case LM3533_ATTR_TYPE_TARGET:
|
||||
ret = lm3533_als_set_target(indio_dev, als_attr->val1,
|
||||
als_attr->val2, val);
|
||||
break;
|
||||
case LM3533_ATTR_TYPE_THRESH_FALLING:
|
||||
ret = lm3533_als_set_threshold(indio_dev, als_attr->val1,
|
||||
false, val);
|
||||
break;
|
||||
case LM3533_ATTR_TYPE_THRESH_RAISING:
|
||||
ret = lm3533_als_set_threshold(indio_dev, als_attr->val1,
|
||||
true, val);
|
||||
break;
|
||||
default:
|
||||
ret = -ENXIO;
|
||||
}
|
||||
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
#define ALS_ATTR(_name, _mode, _show, _store, _type, _val1, _val2) \
|
||||
{ .dev_attr = __ATTR(_name, _mode, _show, _store), \
|
||||
.type = _type, \
|
||||
.val1 = _val1, \
|
||||
.val2 = _val2 }
|
||||
|
||||
#define LM3533_ALS_ATTR(_name, _mode, _show, _store, _type, _val1, _val2) \
|
||||
struct lm3533_als_attribute lm3533_als_attr_##_name = \
|
||||
ALS_ATTR(_name, _mode, _show, _store, _type, _val1, _val2)
|
||||
|
||||
#define ALS_TARGET_ATTR_RW(_channel, _zone) \
|
||||
LM3533_ALS_ATTR(out_current##_channel##_current##_zone##_raw, \
|
||||
S_IRUGO | S_IWUSR, \
|
||||
show_als_attr, store_als_attr, \
|
||||
LM3533_ATTR_TYPE_TARGET, _channel, _zone)
|
||||
/*
|
||||
* ALS output current values (ALS mapper targets)
|
||||
*
|
||||
* out_current[0-2]_current[0-4]_raw 0-255
|
||||
*/
|
||||
static ALS_TARGET_ATTR_RW(0, 0);
|
||||
static ALS_TARGET_ATTR_RW(0, 1);
|
||||
static ALS_TARGET_ATTR_RW(0, 2);
|
||||
static ALS_TARGET_ATTR_RW(0, 3);
|
||||
static ALS_TARGET_ATTR_RW(0, 4);
|
||||
|
||||
static ALS_TARGET_ATTR_RW(1, 0);
|
||||
static ALS_TARGET_ATTR_RW(1, 1);
|
||||
static ALS_TARGET_ATTR_RW(1, 2);
|
||||
static ALS_TARGET_ATTR_RW(1, 3);
|
||||
static ALS_TARGET_ATTR_RW(1, 4);
|
||||
|
||||
static ALS_TARGET_ATTR_RW(2, 0);
|
||||
static ALS_TARGET_ATTR_RW(2, 1);
|
||||
static ALS_TARGET_ATTR_RW(2, 2);
|
||||
static ALS_TARGET_ATTR_RW(2, 3);
|
||||
static ALS_TARGET_ATTR_RW(2, 4);
|
||||
|
||||
#define ALS_THRESH_FALLING_ATTR_RW(_nr) \
|
||||
LM3533_ALS_ATTR(in_illuminance0_thresh##_nr##_falling_value, \
|
||||
S_IRUGO | S_IWUSR, \
|
||||
show_als_attr, store_als_attr, \
|
||||
LM3533_ATTR_TYPE_THRESH_FALLING, _nr, 0)
|
||||
|
||||
#define ALS_THRESH_RAISING_ATTR_RW(_nr) \
|
||||
LM3533_ALS_ATTR(in_illuminance0_thresh##_nr##_raising_value, \
|
||||
S_IRUGO | S_IWUSR, \
|
||||
show_als_attr, store_als_attr, \
|
||||
LM3533_ATTR_TYPE_THRESH_RAISING, _nr, 0)
|
||||
/*
|
||||
* ALS Zone thresholds (boundaries)
|
||||
*
|
||||
* in_illuminance0_thresh[0-3]_falling_value 0-255
|
||||
* in_illuminance0_thresh[0-3]_raising_value 0-255
|
||||
*/
|
||||
static ALS_THRESH_FALLING_ATTR_RW(0);
|
||||
static ALS_THRESH_FALLING_ATTR_RW(1);
|
||||
static ALS_THRESH_FALLING_ATTR_RW(2);
|
||||
static ALS_THRESH_FALLING_ATTR_RW(3);
|
||||
|
||||
static ALS_THRESH_RAISING_ATTR_RW(0);
|
||||
static ALS_THRESH_RAISING_ATTR_RW(1);
|
||||
static ALS_THRESH_RAISING_ATTR_RW(2);
|
||||
static ALS_THRESH_RAISING_ATTR_RW(3);
|
||||
|
||||
#define ALS_HYSTERESIS_ATTR_RO(_nr) \
|
||||
LM3533_ALS_ATTR(in_illuminance0_thresh##_nr##_hysteresis, \
|
||||
S_IRUGO, show_als_attr, NULL, \
|
||||
LM3533_ATTR_TYPE_HYSTERESIS, _nr, 0)
|
||||
/*
|
||||
* ALS Zone threshold hysteresis
|
||||
*
|
||||
* threshY_hysteresis = threshY_raising - threshY_falling
|
||||
*
|
||||
* in_illuminance0_thresh[0-3]_hysteresis 0-255
|
||||
* in_illuminance0_thresh[0-3]_hysteresis 0-255
|
||||
*/
|
||||
static ALS_HYSTERESIS_ATTR_RO(0);
|
||||
static ALS_HYSTERESIS_ATTR_RO(1);
|
||||
static ALS_HYSTERESIS_ATTR_RO(2);
|
||||
static ALS_HYSTERESIS_ATTR_RO(3);
|
||||
|
||||
#define ILLUMINANCE_ATTR_RO(_name) \
|
||||
DEVICE_ATTR(in_illuminance0_##_name, S_IRUGO, show_##_name, NULL)
|
||||
#define ILLUMINANCE_ATTR_RW(_name) \
|
||||
DEVICE_ATTR(in_illuminance0_##_name, S_IRUGO | S_IWUSR , \
|
||||
show_##_name, store_##_name)
|
||||
/*
|
||||
* ALS Zone threshold-event enable
|
||||
*
|
||||
* in_illuminance0_thresh_either_en 0,1
|
||||
*/
|
||||
static ILLUMINANCE_ATTR_RW(thresh_either_en);
|
||||
|
||||
/*
|
||||
* ALS Current Zone
|
||||
*
|
||||
* in_illuminance0_zone 0-4
|
||||
*/
|
||||
static ILLUMINANCE_ATTR_RO(zone);
|
||||
|
||||
static struct attribute *lm3533_als_event_attributes[] = {
|
||||
&dev_attr_in_illuminance0_thresh_either_en.attr,
|
||||
&lm3533_als_attr_in_illuminance0_thresh0_falling_value.dev_attr.attr,
|
||||
&lm3533_als_attr_in_illuminance0_thresh0_hysteresis.dev_attr.attr,
|
||||
&lm3533_als_attr_in_illuminance0_thresh0_raising_value.dev_attr.attr,
|
||||
&lm3533_als_attr_in_illuminance0_thresh1_falling_value.dev_attr.attr,
|
||||
&lm3533_als_attr_in_illuminance0_thresh1_hysteresis.dev_attr.attr,
|
||||
&lm3533_als_attr_in_illuminance0_thresh1_raising_value.dev_attr.attr,
|
||||
&lm3533_als_attr_in_illuminance0_thresh2_falling_value.dev_attr.attr,
|
||||
&lm3533_als_attr_in_illuminance0_thresh2_hysteresis.dev_attr.attr,
|
||||
&lm3533_als_attr_in_illuminance0_thresh2_raising_value.dev_attr.attr,
|
||||
&lm3533_als_attr_in_illuminance0_thresh3_falling_value.dev_attr.attr,
|
||||
&lm3533_als_attr_in_illuminance0_thresh3_hysteresis.dev_attr.attr,
|
||||
&lm3533_als_attr_in_illuminance0_thresh3_raising_value.dev_attr.attr,
|
||||
NULL
|
||||
};
|
||||
|
||||
static struct attribute_group lm3533_als_event_attribute_group = {
|
||||
.attrs = lm3533_als_event_attributes
|
||||
};
|
||||
|
||||
static struct attribute *lm3533_als_attributes[] = {
|
||||
&dev_attr_in_illuminance0_zone.attr,
|
||||
&lm3533_als_attr_out_current0_current0_raw.dev_attr.attr,
|
||||
&lm3533_als_attr_out_current0_current1_raw.dev_attr.attr,
|
||||
&lm3533_als_attr_out_current0_current2_raw.dev_attr.attr,
|
||||
&lm3533_als_attr_out_current0_current3_raw.dev_attr.attr,
|
||||
&lm3533_als_attr_out_current0_current4_raw.dev_attr.attr,
|
||||
&lm3533_als_attr_out_current1_current0_raw.dev_attr.attr,
|
||||
&lm3533_als_attr_out_current1_current1_raw.dev_attr.attr,
|
||||
&lm3533_als_attr_out_current1_current2_raw.dev_attr.attr,
|
||||
&lm3533_als_attr_out_current1_current3_raw.dev_attr.attr,
|
||||
&lm3533_als_attr_out_current1_current4_raw.dev_attr.attr,
|
||||
&lm3533_als_attr_out_current2_current0_raw.dev_attr.attr,
|
||||
&lm3533_als_attr_out_current2_current1_raw.dev_attr.attr,
|
||||
&lm3533_als_attr_out_current2_current2_raw.dev_attr.attr,
|
||||
&lm3533_als_attr_out_current2_current3_raw.dev_attr.attr,
|
||||
&lm3533_als_attr_out_current2_current4_raw.dev_attr.attr,
|
||||
NULL
|
||||
};
|
||||
|
||||
static struct attribute_group lm3533_als_attribute_group = {
|
||||
.attrs = lm3533_als_attributes
|
||||
};
|
||||
|
||||
static int __devinit lm3533_als_set_input_mode(struct lm3533_als *als,
|
||||
bool pwm_mode)
|
||||
{
|
||||
u8 mask = LM3533_ALS_INPUT_MODE_MASK;
|
||||
u8 val;
|
||||
int ret;
|
||||
|
||||
if (pwm_mode)
|
||||
val = mask; /* pwm input */
|
||||
else
|
||||
val = 0; /* analog input */
|
||||
|
||||
ret = lm3533_update(als->lm3533, LM3533_REG_ALS_CONF, val, mask);
|
||||
if (ret) {
|
||||
dev_err(&als->pdev->dev, "failed to set input mode %d\n",
|
||||
pwm_mode);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __devinit lm3533_als_set_resistor(struct lm3533_als *als, u8 val)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (val < LM3533_ALS_RESISTOR_MIN || val > LM3533_ALS_RESISTOR_MAX)
|
||||
return -EINVAL;
|
||||
|
||||
ret = lm3533_write(als->lm3533, LM3533_REG_ALS_RESISTOR_SELECT, val);
|
||||
if (ret) {
|
||||
dev_err(&als->pdev->dev, "failed to set resistor\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __devinit lm3533_als_setup(struct lm3533_als *als,
|
||||
struct lm3533_als_platform_data *pdata)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = lm3533_als_set_input_mode(als, pdata->pwm_mode);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
/* ALS input is always high impedance in PWM-mode. */
|
||||
if (!pdata->pwm_mode) {
|
||||
ret = lm3533_als_set_resistor(als, pdata->r_select);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __devinit lm3533_als_setup_irq(struct lm3533_als *als, void *dev)
|
||||
{
|
||||
u8 mask = LM3533_ALS_INT_ENABLE_MASK;
|
||||
int ret;
|
||||
|
||||
/* Make sure interrupts are disabled. */
|
||||
ret = lm3533_update(als->lm3533, LM3533_REG_ALS_ZONE_INFO, 0, mask);
|
||||
if (ret) {
|
||||
dev_err(&als->pdev->dev, "failed to disable interrupts\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = request_threaded_irq(als->irq, NULL, lm3533_als_isr,
|
||||
IRQF_TRIGGER_LOW | IRQF_ONESHOT,
|
||||
dev_name(&als->pdev->dev), dev);
|
||||
if (ret) {
|
||||
dev_err(&als->pdev->dev, "failed to request irq %d\n",
|
||||
als->irq);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __devinit lm3533_als_enable(struct lm3533_als *als)
|
||||
{
|
||||
u8 mask = LM3533_ALS_ENABLE_MASK;
|
||||
int ret;
|
||||
|
||||
ret = lm3533_update(als->lm3533, LM3533_REG_ALS_CONF, mask, mask);
|
||||
if (ret)
|
||||
dev_err(&als->pdev->dev, "failed to enable ALS\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int lm3533_als_disable(struct lm3533_als *als)
|
||||
{
|
||||
u8 mask = LM3533_ALS_ENABLE_MASK;
|
||||
int ret;
|
||||
|
||||
ret = lm3533_update(als->lm3533, LM3533_REG_ALS_CONF, 0, mask);
|
||||
if (ret)
|
||||
dev_err(&als->pdev->dev, "failed to disable ALS\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const struct iio_info lm3533_als_info = {
|
||||
.attrs = &lm3533_als_attribute_group,
|
||||
.event_attrs = &lm3533_als_event_attribute_group,
|
||||
.driver_module = THIS_MODULE,
|
||||
.read_raw = &lm3533_als_read_raw,
|
||||
};
|
||||
|
||||
static int __devinit lm3533_als_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct lm3533 *lm3533;
|
||||
struct lm3533_als_platform_data *pdata;
|
||||
struct lm3533_als *als;
|
||||
struct iio_dev *indio_dev;
|
||||
int ret;
|
||||
|
||||
lm3533 = dev_get_drvdata(pdev->dev.parent);
|
||||
if (!lm3533)
|
||||
return -EINVAL;
|
||||
|
||||
pdata = pdev->dev.platform_data;
|
||||
if (!pdata) {
|
||||
dev_err(&pdev->dev, "no platform data\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
indio_dev = iio_device_alloc(sizeof(*als));
|
||||
if (!indio_dev)
|
||||
return -ENOMEM;
|
||||
|
||||
indio_dev->info = &lm3533_als_info;
|
||||
indio_dev->channels = lm3533_als_channels;
|
||||
indio_dev->num_channels = ARRAY_SIZE(lm3533_als_channels);
|
||||
indio_dev->name = dev_name(&pdev->dev);
|
||||
indio_dev->dev.parent = pdev->dev.parent;
|
||||
indio_dev->modes = INDIO_DIRECT_MODE;
|
||||
|
||||
als = iio_priv(indio_dev);
|
||||
als->lm3533 = lm3533;
|
||||
als->pdev = pdev;
|
||||
als->irq = lm3533->irq;
|
||||
atomic_set(&als->zone, 0);
|
||||
mutex_init(&als->thresh_mutex);
|
||||
|
||||
platform_set_drvdata(pdev, indio_dev);
|
||||
|
||||
if (als->irq) {
|
||||
ret = lm3533_als_setup_irq(als, indio_dev);
|
||||
if (ret)
|
||||
goto err_free_dev;
|
||||
}
|
||||
|
||||
ret = lm3533_als_setup(als, pdata);
|
||||
if (ret)
|
||||
goto err_free_irq;
|
||||
|
||||
ret = lm3533_als_enable(als);
|
||||
if (ret)
|
||||
goto err_free_irq;
|
||||
|
||||
ret = iio_device_register(indio_dev);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "failed to register ALS\n");
|
||||
goto err_disable;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
err_disable:
|
||||
lm3533_als_disable(als);
|
||||
err_free_irq:
|
||||
if (als->irq)
|
||||
free_irq(als->irq, indio_dev);
|
||||
err_free_dev:
|
||||
iio_device_free(indio_dev);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int __devexit lm3533_als_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct iio_dev *indio_dev = platform_get_drvdata(pdev);
|
||||
struct lm3533_als *als = iio_priv(indio_dev);
|
||||
|
||||
lm3533_als_set_int_mode(indio_dev, false);
|
||||
iio_device_unregister(indio_dev);
|
||||
lm3533_als_disable(als);
|
||||
if (als->irq)
|
||||
free_irq(als->irq, indio_dev);
|
||||
iio_device_free(indio_dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct platform_driver lm3533_als_driver = {
|
||||
.driver = {
|
||||
.name = "lm3533-als",
|
||||
.owner = THIS_MODULE,
|
||||
},
|
||||
.probe = lm3533_als_probe,
|
||||
.remove = __devexit_p(lm3533_als_remove),
|
||||
};
|
||||
module_platform_driver(lm3533_als_driver);
|
||||
|
||||
MODULE_AUTHOR("Johan Hovold <jhovold@gmail.com>");
|
||||
MODULE_DESCRIPTION("LM3533 Ambient Light Sensor driver");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_ALIAS("platform:lm3533-als");
|
217
drivers/iio/light/vcnl4000.c
Normal file
217
drivers/iio/light/vcnl4000.c
Normal file
|
@ -0,0 +1,217 @@
|
|||
/*
|
||||
* vcnl4000.c - Support for Vishay VCNL4000 combined ambient light and
|
||||
* proximity sensor
|
||||
*
|
||||
* Copyright 2012 Peter Meerwald <pmeerw@pmeerw.net>
|
||||
*
|
||||
* This file is subject to the terms and conditions of version 2 of
|
||||
* the GNU General Public License. See the file COPYING in the main
|
||||
* directory of this archive for more details.
|
||||
*
|
||||
* IIO driver for VCNL4000 (7-bit I2C slave address 0x13)
|
||||
*
|
||||
* TODO:
|
||||
* allow to adjust IR current
|
||||
* proximity threshold and event handling
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/delay.h>
|
||||
|
||||
#include <linux/iio/iio.h>
|
||||
#include <linux/iio/sysfs.h>
|
||||
|
||||
#define VCNL4000_DRV_NAME "vcnl4000"
|
||||
|
||||
#define VCNL4000_COMMAND 0x80 /* Command register */
|
||||
#define VCNL4000_PROD_REV 0x81 /* Product ID and Revision ID */
|
||||
#define VCNL4000_LED_CURRENT 0x83 /* IR LED current for proximity mode */
|
||||
#define VCNL4000_AL_PARAM 0x84 /* Ambient light parameter register */
|
||||
#define VCNL4000_AL_RESULT_HI 0x85 /* Ambient light result register, MSB */
|
||||
#define VCNL4000_AL_RESULT_LO 0x86 /* Ambient light result register, LSB */
|
||||
#define VCNL4000_PS_RESULT_HI 0x87 /* Proximity result register, MSB */
|
||||
#define VCNL4000_PS_RESULT_LO 0x88 /* Proximity result register, LSB */
|
||||
#define VCNL4000_PS_MEAS_FREQ 0x89 /* Proximity test signal frequency */
|
||||
#define VCNL4000_PS_MOD_ADJ 0x8a /* Proximity modulator timing adjustment */
|
||||
|
||||
/* Bit masks for COMMAND register */
|
||||
#define VCNL4000_AL_RDY 0x40 /* ALS data ready? */
|
||||
#define VCNL4000_PS_RDY 0x20 /* proximity data ready? */
|
||||
#define VCNL4000_AL_OD 0x10 /* start on-demand ALS measurement */
|
||||
#define VCNL4000_PS_OD 0x08 /* start on-demand proximity measurement */
|
||||
|
||||
struct vcnl4000_data {
|
||||
struct i2c_client *client;
|
||||
};
|
||||
|
||||
static const struct i2c_device_id vcnl4000_id[] = {
|
||||
{ "vcnl4000", 0 },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, vcnl4000_id);
|
||||
|
||||
static int vcnl4000_measure(struct vcnl4000_data *data, u8 req_mask,
|
||||
u8 rdy_mask, u8 data_reg, int *val)
|
||||
{
|
||||
int tries = 20;
|
||||
u16 buf;
|
||||
int ret;
|
||||
|
||||
ret = i2c_smbus_write_byte_data(data->client, VCNL4000_COMMAND,
|
||||
req_mask);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
/* wait for data to become ready */
|
||||
while (tries--) {
|
||||
ret = i2c_smbus_read_byte_data(data->client, VCNL4000_COMMAND);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
if (ret & rdy_mask)
|
||||
break;
|
||||
msleep(20); /* measurement takes up to 100 ms */
|
||||
}
|
||||
|
||||
if (tries < 0) {
|
||||
dev_err(&data->client->dev,
|
||||
"vcnl4000_measure() failed, data not ready\n");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
ret = i2c_smbus_read_i2c_block_data(data->client,
|
||||
data_reg, sizeof(buf), (u8 *) &buf);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
*val = be16_to_cpu(buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct iio_chan_spec vcnl4000_channels[] = {
|
||||
{
|
||||
.type = IIO_LIGHT,
|
||||
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
|
||||
IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
|
||||
}, {
|
||||
.type = IIO_PROXIMITY,
|
||||
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
|
||||
}
|
||||
};
|
||||
|
||||
static int vcnl4000_read_raw(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec const *chan,
|
||||
int *val, int *val2, long mask)
|
||||
{
|
||||
int ret = -EINVAL;
|
||||
struct vcnl4000_data *data = iio_priv(indio_dev);
|
||||
|
||||
switch (mask) {
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
switch (chan->type) {
|
||||
case IIO_LIGHT:
|
||||
ret = vcnl4000_measure(data,
|
||||
VCNL4000_AL_OD, VCNL4000_AL_RDY,
|
||||
VCNL4000_AL_RESULT_HI, val);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
ret = IIO_VAL_INT;
|
||||
break;
|
||||
case IIO_PROXIMITY:
|
||||
ret = vcnl4000_measure(data,
|
||||
VCNL4000_PS_OD, VCNL4000_PS_RDY,
|
||||
VCNL4000_PS_RESULT_HI, val);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
ret = IIO_VAL_INT;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case IIO_CHAN_INFO_SCALE:
|
||||
if (chan->type == IIO_LIGHT) {
|
||||
*val = 0;
|
||||
*val2 = 250000;
|
||||
ret = IIO_VAL_INT_PLUS_MICRO;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const struct iio_info vcnl4000_info = {
|
||||
.read_raw = vcnl4000_read_raw,
|
||||
.driver_module = THIS_MODULE,
|
||||
};
|
||||
|
||||
static int __devinit vcnl4000_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *id)
|
||||
{
|
||||
struct vcnl4000_data *data;
|
||||
struct iio_dev *indio_dev;
|
||||
int ret;
|
||||
|
||||
indio_dev = iio_device_alloc(sizeof(*data));
|
||||
if (!indio_dev)
|
||||
return -ENOMEM;
|
||||
|
||||
data = iio_priv(indio_dev);
|
||||
i2c_set_clientdata(client, indio_dev);
|
||||
data->client = client;
|
||||
|
||||
ret = i2c_smbus_read_byte_data(data->client, VCNL4000_PROD_REV);
|
||||
if (ret < 0)
|
||||
goto error_free_dev;
|
||||
|
||||
dev_info(&client->dev, "VCNL4000 Ambient light/proximity sensor, Prod %02x, Rev: %02x\n",
|
||||
ret >> 4, ret & 0xf);
|
||||
|
||||
indio_dev->dev.parent = &client->dev;
|
||||
indio_dev->info = &vcnl4000_info;
|
||||
indio_dev->channels = vcnl4000_channels;
|
||||
indio_dev->num_channels = ARRAY_SIZE(vcnl4000_channels);
|
||||
indio_dev->name = VCNL4000_DRV_NAME;
|
||||
indio_dev->modes = INDIO_DIRECT_MODE;
|
||||
|
||||
ret = iio_device_register(indio_dev);
|
||||
if (ret < 0)
|
||||
goto error_free_dev;
|
||||
|
||||
return 0;
|
||||
|
||||
error_free_dev:
|
||||
iio_device_free(indio_dev);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int __devexit vcnl4000_remove(struct i2c_client *client)
|
||||
{
|
||||
struct iio_dev *indio_dev = i2c_get_clientdata(client);
|
||||
|
||||
iio_device_unregister(indio_dev);
|
||||
iio_device_free(indio_dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct i2c_driver vcnl4000_driver = {
|
||||
.driver = {
|
||||
.name = VCNL4000_DRV_NAME,
|
||||
.owner = THIS_MODULE,
|
||||
},
|
||||
.probe = vcnl4000_probe,
|
||||
.remove = __devexit_p(vcnl4000_remove),
|
||||
.id_table = vcnl4000_id,
|
||||
};
|
||||
|
||||
module_i2c_driver(vcnl4000_driver);
|
||||
|
||||
MODULE_AUTHOR("Peter Meerwald <pmeerw@pmeerw.net>");
|
||||
MODULE_DESCRIPTION("Vishay VCNL4000 proximity/ambient light sensor driver");
|
||||
MODULE_LICENSE("GPL");
|
|
@ -84,7 +84,7 @@ source "drivers/staging/wlags49_h2/Kconfig"
|
|||
|
||||
source "drivers/staging/wlags49_h25/Kconfig"
|
||||
|
||||
source "drivers/staging/sm7xx/Kconfig"
|
||||
source "drivers/staging/sm7xxfb/Kconfig"
|
||||
|
||||
source "drivers/staging/crystalhd/Kconfig"
|
||||
|
||||
|
@ -132,4 +132,8 @@ source "drivers/staging/ipack/Kconfig"
|
|||
|
||||
source "drivers/staging/gdm72xx/Kconfig"
|
||||
|
||||
source "drivers/staging/csr/Kconfig"
|
||||
|
||||
source "drivers/staging/omap-thermal/Kconfig"
|
||||
|
||||
endif # STAGING
|
||||
|
|
|
@ -37,7 +37,7 @@ obj-$(CONFIG_ZCACHE) += zcache/
|
|||
obj-$(CONFIG_ZSMALLOC) += zsmalloc/
|
||||
obj-$(CONFIG_WLAGS49_H2) += wlags49_h2/
|
||||
obj-$(CONFIG_WLAGS49_H25) += wlags49_h25/
|
||||
obj-$(CONFIG_FB_SM7XX) += sm7xx/
|
||||
obj-$(CONFIG_FB_SM7XX) += sm7xxfb/
|
||||
obj-$(CONFIG_CRYSTALHD) += crystalhd/
|
||||
obj-$(CONFIG_CXT1E1) += cxt1e1/
|
||||
obj-$(CONFIG_FB_XGI) += xgifb/
|
||||
|
@ -58,3 +58,5 @@ obj-$(CONFIG_RAMSTER) += ramster/
|
|||
obj-$(CONFIG_USB_WPAN_HCD) += ozwpan/
|
||||
obj-$(CONFIG_USB_G_CCG) += ccg/
|
||||
obj-$(CONFIG_WIMAX_GDM72XX) += gdm72xx/
|
||||
obj-$(CONFIG_CSR_WIFI) += csr/
|
||||
obj-$(CONFIG_OMAP_BANDGAP) += omap-thermal/
|
||||
|
|
|
@ -25,11 +25,6 @@ config ANDROID_LOGGER
|
|||
tristate "Android log driver"
|
||||
default n
|
||||
|
||||
config ANDROID_RAM_CONSOLE
|
||||
bool "Android RAM buffer console"
|
||||
depends on !S390 && !UML && HAVE_MEMBLOCK && PSTORE_RAM=y
|
||||
default n
|
||||
|
||||
config ANDROID_TIMED_OUTPUT
|
||||
bool "Timed output class driver"
|
||||
default y
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
obj-$(CONFIG_ANDROID_BINDER_IPC) += binder.o
|
||||
obj-$(CONFIG_ASHMEM) += ashmem.o
|
||||
obj-$(CONFIG_ANDROID_LOGGER) += logger.o
|
||||
obj-$(CONFIG_ANDROID_RAM_CONSOLE) += ram_console.o
|
||||
obj-$(CONFIG_ANDROID_TIMED_OUTPUT) += timed_output.o
|
||||
obj-$(CONFIG_ANDROID_TIMED_GPIO) += timed_gpio.o
|
||||
obj-$(CONFIG_ANDROID_LOW_MEMORY_KILLER) += lowmemorykiller.o
|
||||
|
|
|
@ -29,16 +29,14 @@
|
|||
#define ANDROID_ALARM_PRINT_IO (1U << 1)
|
||||
#define ANDROID_ALARM_PRINT_INT (1U << 2)
|
||||
|
||||
|
||||
static int debug_mask = ANDROID_ALARM_PRINT_INFO;
|
||||
module_param_named(debug_mask, debug_mask, int, S_IRUGO | S_IWUSR | S_IWGRP);
|
||||
|
||||
#define pr_alarm(debug_level_mask, args...) \
|
||||
do { \
|
||||
if (debug_mask & ANDROID_ALARM_PRINT_##debug_level_mask) { \
|
||||
pr_info(args); \
|
||||
} \
|
||||
} while (0)
|
||||
#define alarm_dbg(debug_level_mask, fmt, ...) \
|
||||
do { \
|
||||
if (debug_mask & ANDROID_ALARM_PRINT_##debug_level_mask) \
|
||||
pr_info(fmt, ##__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#define ANDROID_ALARM_WAKEUP_MASK ( \
|
||||
ANDROID_ALARM_RTC_WAKEUP_MASK | \
|
||||
|
@ -138,7 +136,7 @@ static long alarm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
|||
switch (ANDROID_ALARM_BASE_CMD(cmd)) {
|
||||
case ANDROID_ALARM_CLEAR(0):
|
||||
spin_lock_irqsave(&alarm_slock, flags);
|
||||
pr_alarm(IO, "alarm %d clear\n", alarm_type);
|
||||
alarm_dbg(IO, "alarm %d clear\n", alarm_type);
|
||||
devalarm_try_to_cancel(&alarms[alarm_type]);
|
||||
if (alarm_pending) {
|
||||
alarm_pending &= ~alarm_type_mask;
|
||||
|
@ -167,8 +165,9 @@ static long alarm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
|||
}
|
||||
from_old_alarm_set:
|
||||
spin_lock_irqsave(&alarm_slock, flags);
|
||||
pr_alarm(IO, "alarm %d set %ld.%09ld\n", alarm_type,
|
||||
new_alarm_time.tv_sec, new_alarm_time.tv_nsec);
|
||||
alarm_dbg(IO, "alarm %d set %ld.%09ld\n",
|
||||
alarm_type,
|
||||
new_alarm_time.tv_sec, new_alarm_time.tv_nsec);
|
||||
alarm_enabled |= alarm_type_mask;
|
||||
devalarm_start(&alarms[alarm_type],
|
||||
timespec_to_ktime(new_alarm_time));
|
||||
|
@ -179,7 +178,7 @@ static long alarm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
|||
/* fall though */
|
||||
case ANDROID_ALARM_WAIT:
|
||||
spin_lock_irqsave(&alarm_slock, flags);
|
||||
pr_alarm(IO, "alarm wait\n");
|
||||
alarm_dbg(IO, "alarm wait\n");
|
||||
if (!alarm_pending && wait_pending) {
|
||||
__pm_relax(&alarm_wake_lock);
|
||||
wait_pending = 0;
|
||||
|
@ -238,7 +237,6 @@ static long alarm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
|||
|
||||
default:
|
||||
rv = -EINVAL;
|
||||
goto err1;
|
||||
}
|
||||
err1:
|
||||
return rv;
|
||||
|
@ -256,13 +254,14 @@ static int alarm_release(struct inode *inode, struct file *file)
|
|||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&alarm_slock, flags);
|
||||
if (file->private_data != 0) {
|
||||
if (file->private_data) {
|
||||
for (i = 0; i < ANDROID_ALARM_TYPE_COUNT; i++) {
|
||||
uint32_t alarm_type_mask = 1U << i;
|
||||
if (alarm_enabled & alarm_type_mask) {
|
||||
pr_alarm(INFO, "alarm_release: clear alarm, "
|
||||
"pending %d\n",
|
||||
!!(alarm_pending & alarm_type_mask));
|
||||
alarm_dbg(INFO,
|
||||
"%s: clear alarm, pending %d\n",
|
||||
__func__,
|
||||
!!(alarm_pending & alarm_type_mask));
|
||||
alarm_enabled &= ~alarm_type_mask;
|
||||
}
|
||||
spin_unlock_irqrestore(&alarm_slock, flags);
|
||||
|
@ -271,8 +270,8 @@ static int alarm_release(struct inode *inode, struct file *file)
|
|||
}
|
||||
if (alarm_pending | wait_pending) {
|
||||
if (alarm_pending)
|
||||
pr_alarm(INFO, "alarm_release: clear "
|
||||
"pending alarms %x\n", alarm_pending);
|
||||
alarm_dbg(INFO, "%s: clear pending alarms %x\n",
|
||||
__func__, alarm_pending);
|
||||
__pm_relax(&alarm_wake_lock);
|
||||
wait_pending = 0;
|
||||
alarm_pending = 0;
|
||||
|
@ -288,7 +287,7 @@ static void devalarm_triggered(struct devalarm *alarm)
|
|||
unsigned long flags;
|
||||
uint32_t alarm_type_mask = 1U << alarm->type;
|
||||
|
||||
pr_alarm(INT, "devalarm_triggered type %d\n", alarm->type);
|
||||
alarm_dbg(INT, "%s: type %d\n", __func__, alarm->type);
|
||||
spin_lock_irqsave(&alarm_slock, flags);
|
||||
if (alarm_enabled & alarm_type_mask) {
|
||||
__pm_wakeup_event(&alarm_wake_lock, 5000); /* 5secs */
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
** GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#define pr_fmt(fmt) "ashmem: " fmt
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/file.h>
|
||||
#include <linux/fs.h>
|
||||
|
@ -707,7 +709,7 @@ static int __init ashmem_init(void)
|
|||
sizeof(struct ashmem_area),
|
||||
0, 0, NULL);
|
||||
if (unlikely(!ashmem_area_cachep)) {
|
||||
printk(KERN_ERR "ashmem: failed to create slab cache\n");
|
||||
pr_err("failed to create slab cache\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
|
@ -715,19 +717,19 @@ static int __init ashmem_init(void)
|
|||
sizeof(struct ashmem_range),
|
||||
0, 0, NULL);
|
||||
if (unlikely(!ashmem_range_cachep)) {
|
||||
printk(KERN_ERR "ashmem: failed to create slab cache\n");
|
||||
pr_err("failed to create slab cache\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
ret = misc_register(&ashmem_misc);
|
||||
if (unlikely(ret)) {
|
||||
printk(KERN_ERR "ashmem: failed to register misc device!\n");
|
||||
pr_err("failed to register misc device!\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
register_shrinker(&ashmem_shrinker);
|
||||
|
||||
printk(KERN_INFO "ashmem: initialized\n");
|
||||
pr_info("initialized\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -740,12 +742,12 @@ static void __exit ashmem_exit(void)
|
|||
|
||||
ret = misc_deregister(&ashmem_misc);
|
||||
if (unlikely(ret))
|
||||
printk(KERN_ERR "ashmem: failed to unregister misc device!\n");
|
||||
pr_err("failed to unregister misc device!\n");
|
||||
|
||||
kmem_cache_destroy(ashmem_range_cachep);
|
||||
kmem_cache_destroy(ashmem_area_cachep);
|
||||
|
||||
printk(KERN_INFO "ashmem: unloaded\n");
|
||||
pr_info("unloaded\n");
|
||||
}
|
||||
|
||||
module_init(ashmem_init);
|
||||
|
|
|
@ -124,13 +124,13 @@ module_param_call(stop_on_user_error, binder_set_stop_on_user_error,
|
|||
#define binder_debug(mask, x...) \
|
||||
do { \
|
||||
if (binder_debug_mask & mask) \
|
||||
printk(KERN_INFO x); \
|
||||
pr_info(x); \
|
||||
} while (0)
|
||||
|
||||
#define binder_user_error(x...) \
|
||||
do { \
|
||||
if (binder_debug_mask & BINDER_DEBUG_USER_ERROR) \
|
||||
printk(KERN_INFO x); \
|
||||
pr_info(x); \
|
||||
if (binder_stop_on_user_error) \
|
||||
binder_stop_on_user_error = 2; \
|
||||
} while (0)
|
||||
|
@ -418,7 +418,7 @@ int task_get_unused_fd_flags(struct binder_proc *proc, int flags)
|
|||
#if 1
|
||||
/* Sanity check */
|
||||
if (fdt->fd[fd] != NULL) {
|
||||
printk(KERN_WARNING "get_unused_fd: slot %d not NULL!\n", fd);
|
||||
pr_warn("get_unused_fd: slot %d not NULL!\n", fd);
|
||||
fdt->fd[fd] = NULL;
|
||||
}
|
||||
#endif
|
||||
|
@ -644,7 +644,7 @@ static int binder_update_page_range(struct binder_proc *proc, int allocate,
|
|||
goto free_range;
|
||||
|
||||
if (vma == NULL) {
|
||||
printk(KERN_ERR "binder: %d: binder_alloc_buf failed to "
|
||||
pr_err("binder: %d: binder_alloc_buf failed to "
|
||||
"map pages in userspace, no vma\n", proc->pid);
|
||||
goto err_no_vma;
|
||||
}
|
||||
|
@ -657,7 +657,7 @@ static int binder_update_page_range(struct binder_proc *proc, int allocate,
|
|||
BUG_ON(*page);
|
||||
*page = alloc_page(GFP_KERNEL | __GFP_ZERO);
|
||||
if (*page == NULL) {
|
||||
printk(KERN_ERR "binder: %d: binder_alloc_buf failed "
|
||||
pr_err("binder: %d: binder_alloc_buf failed "
|
||||
"for page at %p\n", proc->pid, page_addr);
|
||||
goto err_alloc_page_failed;
|
||||
}
|
||||
|
@ -666,7 +666,7 @@ static int binder_update_page_range(struct binder_proc *proc, int allocate,
|
|||
page_array_ptr = page;
|
||||
ret = map_vm_area(&tmp_area, PAGE_KERNEL, &page_array_ptr);
|
||||
if (ret) {
|
||||
printk(KERN_ERR "binder: %d: binder_alloc_buf failed "
|
||||
pr_err("binder: %d: binder_alloc_buf failed "
|
||||
"to map page at %p in kernel\n",
|
||||
proc->pid, page_addr);
|
||||
goto err_map_kernel_failed;
|
||||
|
@ -675,7 +675,7 @@ static int binder_update_page_range(struct binder_proc *proc, int allocate,
|
|||
(uintptr_t)page_addr + proc->user_buffer_offset;
|
||||
ret = vm_insert_page(vma, user_page_addr, page[0]);
|
||||
if (ret) {
|
||||
printk(KERN_ERR "binder: %d: binder_alloc_buf failed "
|
||||
pr_err("binder: %d: binder_alloc_buf failed "
|
||||
"to map page at %lx in userspace\n",
|
||||
proc->pid, user_page_addr);
|
||||
goto err_vm_insert_page_failed;
|
||||
|
@ -724,7 +724,7 @@ static struct binder_buffer *binder_alloc_buf(struct binder_proc *proc,
|
|||
size_t size;
|
||||
|
||||
if (proc->vma == NULL) {
|
||||
printk(KERN_ERR "binder: %d: binder_alloc_buf, no vma\n",
|
||||
pr_err("binder: %d: binder_alloc_buf, no vma\n",
|
||||
proc->pid);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -762,7 +762,7 @@ static struct binder_buffer *binder_alloc_buf(struct binder_proc *proc,
|
|||
}
|
||||
}
|
||||
if (best_fit == NULL) {
|
||||
printk(KERN_ERR "binder: %d: binder_alloc_buf size %zd failed, "
|
||||
pr_err("binder: %d: binder_alloc_buf size %zd failed, "
|
||||
"no address space\n", proc->pid, size);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -997,7 +997,7 @@ static int binder_inc_node(struct binder_node *node, int strong, int internal,
|
|||
node->internal_strong_refs == 0 &&
|
||||
!(node == binder_context_mgr_node &&
|
||||
node->has_strong_ref)) {
|
||||
printk(KERN_ERR "binder: invalid inc strong "
|
||||
pr_err("binder: invalid inc strong "
|
||||
"node for %d\n", node->debug_id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -1013,7 +1013,7 @@ static int binder_inc_node(struct binder_node *node, int strong, int internal,
|
|||
node->local_weak_refs++;
|
||||
if (!node->has_weak_ref && list_empty(&node->work.entry)) {
|
||||
if (target_list == NULL) {
|
||||
printk(KERN_ERR "binder: invalid inc weak node "
|
||||
pr_err("binder: invalid inc weak node "
|
||||
"for %d\n", node->debug_id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -1276,7 +1276,7 @@ static void binder_send_failed_reply(struct binder_transaction *t,
|
|||
target_thread->return_error = error_code;
|
||||
wake_up_interruptible(&target_thread->wait);
|
||||
} else {
|
||||
printk(KERN_ERR "binder: reply failed, target "
|
||||
pr_err("binder: reply failed, target "
|
||||
"thread, %d:%d, has error code %d "
|
||||
"already\n", target_thread->proc->pid,
|
||||
target_thread->pid,
|
||||
|
@ -1331,7 +1331,7 @@ static void binder_transaction_buffer_release(struct binder_proc *proc,
|
|||
if (*offp > buffer->data_size - sizeof(*fp) ||
|
||||
buffer->data_size < sizeof(*fp) ||
|
||||
!IS_ALIGNED(*offp, sizeof(void *))) {
|
||||
printk(KERN_ERR "binder: transaction release %d bad"
|
||||
pr_err("binder: transaction release %d bad"
|
||||
"offset %zd, size %zd\n", debug_id,
|
||||
*offp, buffer->data_size);
|
||||
continue;
|
||||
|
@ -1342,7 +1342,7 @@ static void binder_transaction_buffer_release(struct binder_proc *proc,
|
|||
case BINDER_TYPE_WEAK_BINDER: {
|
||||
struct binder_node *node = binder_get_node(proc, fp->binder);
|
||||
if (node == NULL) {
|
||||
printk(KERN_ERR "binder: transaction release %d"
|
||||
pr_err("binder: transaction release %d"
|
||||
" bad node %p\n", debug_id, fp->binder);
|
||||
break;
|
||||
}
|
||||
|
@ -1355,7 +1355,7 @@ static void binder_transaction_buffer_release(struct binder_proc *proc,
|
|||
case BINDER_TYPE_WEAK_HANDLE: {
|
||||
struct binder_ref *ref = binder_get_ref(proc, fp->handle);
|
||||
if (ref == NULL) {
|
||||
printk(KERN_ERR "binder: transaction release %d"
|
||||
pr_err("binder: transaction release %d"
|
||||
" bad handle %ld\n", debug_id,
|
||||
fp->handle);
|
||||
break;
|
||||
|
@ -1374,7 +1374,7 @@ static void binder_transaction_buffer_release(struct binder_proc *proc,
|
|||
break;
|
||||
|
||||
default:
|
||||
printk(KERN_ERR "binder: transaction release %d bad "
|
||||
pr_err("binder: transaction release %d bad "
|
||||
"object type %lx\n", debug_id, fp->type);
|
||||
break;
|
||||
}
|
||||
|
@ -1925,10 +1925,10 @@ int binder_thread_write(struct binder_proc *proc, struct binder_thread *thread,
|
|||
break;
|
||||
}
|
||||
case BC_ATTEMPT_ACQUIRE:
|
||||
printk(KERN_ERR "binder: BC_ATTEMPT_ACQUIRE not supported\n");
|
||||
pr_err("binder: BC_ATTEMPT_ACQUIRE not supported\n");
|
||||
return -EINVAL;
|
||||
case BC_ACQUIRE_RESULT:
|
||||
printk(KERN_ERR "binder: BC_ACQUIRE_RESULT not supported\n");
|
||||
pr_err("binder: BC_ACQUIRE_RESULT not supported\n");
|
||||
return -EINVAL;
|
||||
|
||||
case BC_FREE_BUFFER: {
|
||||
|
@ -2165,7 +2165,7 @@ int binder_thread_write(struct binder_proc *proc, struct binder_thread *thread,
|
|||
} break;
|
||||
|
||||
default:
|
||||
printk(KERN_ERR "binder: %d:%d unknown command %d\n",
|
||||
pr_err("binder: %d:%d unknown command %d\n",
|
||||
proc->pid, thread->pid, cmd);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -2635,7 +2635,7 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
|
|||
unsigned int size = _IOC_SIZE(cmd);
|
||||
void __user *ubuf = (void __user *)arg;
|
||||
|
||||
/*printk(KERN_INFO "binder_ioctl: %d:%d %x %lx\n", proc->pid, current->pid, cmd, arg);*/
|
||||
/*pr_info("binder_ioctl: %d:%d %x %lx\n", proc->pid, current->pid, cmd, arg);*/
|
||||
|
||||
ret = wait_event_interruptible(binder_user_error_wait, binder_stop_on_user_error < 2);
|
||||
if (ret)
|
||||
|
@ -2701,13 +2701,13 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
|
|||
break;
|
||||
case BINDER_SET_CONTEXT_MGR:
|
||||
if (binder_context_mgr_node != NULL) {
|
||||
printk(KERN_ERR "binder: BINDER_SET_CONTEXT_MGR already set\n");
|
||||
pr_err("binder: BINDER_SET_CONTEXT_MGR already set\n");
|
||||
ret = -EBUSY;
|
||||
goto err;
|
||||
}
|
||||
if (binder_context_mgr_uid != -1) {
|
||||
if (binder_context_mgr_uid != current->cred->euid) {
|
||||
printk(KERN_ERR "binder: BINDER_SET_"
|
||||
pr_err("binder: BINDER_SET_"
|
||||
"CONTEXT_MGR bad uid %d != %d\n",
|
||||
current->cred->euid,
|
||||
binder_context_mgr_uid);
|
||||
|
@ -2753,7 +2753,7 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
|
|||
mutex_unlock(&binder_lock);
|
||||
wait_event_interruptible(binder_user_error_wait, binder_stop_on_user_error < 2);
|
||||
if (ret && ret != -ERESTARTSYS)
|
||||
printk(KERN_INFO "binder: %d:%d ioctl %x %lx returned %d\n", proc->pid, current->pid, cmd, arg, ret);
|
||||
pr_info("binder: %d:%d ioctl %x %lx returned %d\n", proc->pid, current->pid, cmd, arg, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -2829,7 +2829,7 @@ static int binder_mmap(struct file *filp, struct vm_area_struct *vma)
|
|||
#ifdef CONFIG_CPU_CACHE_VIPT
|
||||
if (cache_is_vipt_aliasing()) {
|
||||
while (CACHE_COLOUR((vma->vm_start ^ (uint32_t)proc->buffer))) {
|
||||
printk(KERN_INFO "binder_mmap: %d %lx-%lx maps %p bad alignment\n", proc->pid, vma->vm_start, vma->vm_end, proc->buffer);
|
||||
pr_info("binder_mmap: %d %lx-%lx maps %p bad alignment\n", proc->pid, vma->vm_start, vma->vm_end, proc->buffer);
|
||||
vma->vm_start += PAGE_SIZE;
|
||||
}
|
||||
}
|
||||
|
@ -2861,7 +2861,7 @@ static int binder_mmap(struct file *filp, struct vm_area_struct *vma)
|
|||
proc->vma = vma;
|
||||
proc->vma_vm_mm = vma->vm_mm;
|
||||
|
||||
/*printk(KERN_INFO "binder_mmap: %d %lx-%lx maps %p\n",
|
||||
/*pr_info("binder_mmap: %d %lx-%lx maps %p\n",
|
||||
proc->pid, vma->vm_start, vma->vm_end, proc->buffer);*/
|
||||
return 0;
|
||||
|
||||
|
@ -2876,7 +2876,7 @@ static int binder_mmap(struct file *filp, struct vm_area_struct *vma)
|
|||
err_already_mapped:
|
||||
mutex_unlock(&binder_mmap_lock);
|
||||
err_bad_arg:
|
||||
printk(KERN_ERR "binder_mmap: %d %lx-%lx %s failed %d\n",
|
||||
pr_err("binder_mmap: %d %lx-%lx %s failed %d\n",
|
||||
proc->pid, vma->vm_start, vma->vm_end, failure_string, ret);
|
||||
return ret;
|
||||
}
|
||||
|
@ -3031,7 +3031,7 @@ static void binder_deferred_release(struct binder_proc *proc)
|
|||
if (t) {
|
||||
t->buffer = NULL;
|
||||
buffer->transaction = NULL;
|
||||
printk(KERN_ERR "binder: release proc %d, "
|
||||
pr_err("binder: release proc %d, "
|
||||
"transaction %d, not freed\n",
|
||||
proc->pid, t->debug_id);
|
||||
/*BUG();*/
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#define pr_fmt(fmt) "logger: " fmt
|
||||
|
||||
#include <linux/sched.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/fs.h>
|
||||
|
@ -621,13 +623,13 @@ static int __init create_log(char *log_name, int size)
|
|||
/* finally, initialize the misc device for this log */
|
||||
ret = misc_register(&log->misc);
|
||||
if (unlikely(ret)) {
|
||||
printk(KERN_ERR "logger: failed to register misc "
|
||||
"device for log '%s'!\n", log->misc.name);
|
||||
pr_err("failed to register misc device for log '%s'!\n",
|
||||
log->misc.name);
|
||||
goto out_free_log;
|
||||
}
|
||||
|
||||
printk(KERN_INFO "logger: created %luK log '%s'\n",
|
||||
(unsigned long) log->size >> 10, log->misc.name);
|
||||
pr_info("created %luK log '%s'\n",
|
||||
(unsigned long) log->size >> 10, log->misc.name);
|
||||
|
||||
return 0;
|
||||
|
||||
|
|
|
@ -1,179 +0,0 @@
|
|||
/* drivers/android/ram_console.c
|
||||
*
|
||||
* Copyright (C) 2007-2008 Google, Inc.
|
||||
*
|
||||
* This software is licensed under the terms of the GNU General Public
|
||||
* License version 2, as published by the Free Software Foundation, and
|
||||
* may be copied, distributed, and modified under those terms.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/console.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/proc_fs.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/uaccess.h>
|
||||
#include <linux/io.h>
|
||||
#include <linux/pstore_ram.h>
|
||||
#include "ram_console.h"
|
||||
|
||||
static struct persistent_ram_zone *ram_console_zone;
|
||||
static const char *bootinfo;
|
||||
static size_t bootinfo_size;
|
||||
|
||||
static void
|
||||
ram_console_write(struct console *console, const char *s, unsigned int count)
|
||||
{
|
||||
struct persistent_ram_zone *prz = console->data;
|
||||
persistent_ram_write(prz, s, count);
|
||||
}
|
||||
|
||||
static struct console ram_console = {
|
||||
.name = "ram",
|
||||
.write = ram_console_write,
|
||||
.flags = CON_PRINTBUFFER | CON_ENABLED | CON_ANYTIME,
|
||||
.index = -1,
|
||||
};
|
||||
|
||||
void ram_console_enable_console(int enabled)
|
||||
{
|
||||
if (enabled)
|
||||
ram_console.flags |= CON_ENABLED;
|
||||
else
|
||||
ram_console.flags &= ~CON_ENABLED;
|
||||
}
|
||||
|
||||
static int __init ram_console_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct ram_console_platform_data *pdata = pdev->dev.platform_data;
|
||||
struct persistent_ram_zone *prz;
|
||||
|
||||
prz = persistent_ram_init_ringbuffer(&pdev->dev, true);
|
||||
if (IS_ERR(prz))
|
||||
return PTR_ERR(prz);
|
||||
|
||||
|
||||
if (pdata) {
|
||||
bootinfo = kstrdup(pdata->bootinfo, GFP_KERNEL);
|
||||
if (bootinfo)
|
||||
bootinfo_size = strlen(bootinfo);
|
||||
}
|
||||
|
||||
ram_console_zone = prz;
|
||||
ram_console.data = prz;
|
||||
|
||||
register_console(&ram_console);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct platform_driver ram_console_driver = {
|
||||
.driver = {
|
||||
.name = "ram_console",
|
||||
},
|
||||
};
|
||||
|
||||
static int __init ram_console_module_init(void)
|
||||
{
|
||||
return platform_driver_probe(&ram_console_driver, ram_console_probe);
|
||||
}
|
||||
|
||||
#ifndef CONFIG_PRINTK
|
||||
#define dmesg_restrict 0
|
||||
#endif
|
||||
|
||||
static ssize_t ram_console_read_old(struct file *file, char __user *buf,
|
||||
size_t len, loff_t *offset)
|
||||
{
|
||||
loff_t pos = *offset;
|
||||
ssize_t count;
|
||||
struct persistent_ram_zone *prz = ram_console_zone;
|
||||
size_t old_log_size = persistent_ram_old_size(prz);
|
||||
const char *old_log = persistent_ram_old(prz);
|
||||
char *str;
|
||||
int ret;
|
||||
|
||||
if (dmesg_restrict && !capable(CAP_SYSLOG))
|
||||
return -EPERM;
|
||||
|
||||
/* Main last_kmsg log */
|
||||
if (pos < old_log_size) {
|
||||
count = min(len, (size_t)(old_log_size - pos));
|
||||
if (copy_to_user(buf, old_log + pos, count))
|
||||
return -EFAULT;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* ECC correction notice */
|
||||
pos -= old_log_size;
|
||||
count = persistent_ram_ecc_string(prz, NULL, 0);
|
||||
if (pos < count) {
|
||||
str = kmalloc(count, GFP_KERNEL);
|
||||
if (!str)
|
||||
return -ENOMEM;
|
||||
persistent_ram_ecc_string(prz, str, count + 1);
|
||||
count = min(len, (size_t)(count - pos));
|
||||
ret = copy_to_user(buf, str + pos, count);
|
||||
kfree(str);
|
||||
if (ret)
|
||||
return -EFAULT;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Boot info passed through pdata */
|
||||
pos -= count;
|
||||
if (pos < bootinfo_size) {
|
||||
count = min(len, (size_t)(bootinfo_size - pos));
|
||||
if (copy_to_user(buf, bootinfo + pos, count))
|
||||
return -EFAULT;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
return 0;
|
||||
|
||||
out:
|
||||
*offset += count;
|
||||
return count;
|
||||
}
|
||||
|
||||
static const struct file_operations ram_console_file_ops = {
|
||||
.owner = THIS_MODULE,
|
||||
.read = ram_console_read_old,
|
||||
};
|
||||
|
||||
static int __init ram_console_late_init(void)
|
||||
{
|
||||
struct proc_dir_entry *entry;
|
||||
struct persistent_ram_zone *prz = ram_console_zone;
|
||||
|
||||
if (!prz)
|
||||
return 0;
|
||||
|
||||
if (persistent_ram_old_size(prz) == 0)
|
||||
return 0;
|
||||
|
||||
entry = create_proc_entry("last_kmsg", S_IFREG | S_IRUGO, NULL);
|
||||
if (!entry) {
|
||||
printk(KERN_ERR "ram_console: failed to create proc entry\n");
|
||||
persistent_ram_free_old(prz);
|
||||
return 0;
|
||||
}
|
||||
|
||||
entry->proc_fops = &ram_console_file_ops;
|
||||
entry->size = persistent_ram_old_size(prz) +
|
||||
persistent_ram_ecc_string(prz, NULL, 0) +
|
||||
bootinfo_size;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
late_initcall(ram_console_late_init);
|
||||
postcore_initcall(ram_console_module_init);
|
|
@ -14,6 +14,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#define pr_fmt(fmt) "timed_output: " fmt
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/device.h>
|
||||
|
@ -90,7 +92,7 @@ int timed_output_dev_register(struct timed_output_dev *tdev)
|
|||
|
||||
err_create_file:
|
||||
device_destroy(timed_output_class, MKDEV(0, tdev->index));
|
||||
printk(KERN_ERR "timed_output: Failed to register driver %s\n",
|
||||
pr_err("failed to register driver %s\n",
|
||||
tdev->name);
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -782,20 +782,20 @@ static int __init asus_oled_init(void)
|
|||
oled_class = class_create(THIS_MODULE, ASUS_OLED_UNDERSCORE_NAME);
|
||||
|
||||
if (IS_ERR(oled_class)) {
|
||||
printk(KERN_ERR "Error creating " ASUS_OLED_UNDERSCORE_NAME " class\n");
|
||||
pr_err("Error creating " ASUS_OLED_UNDERSCORE_NAME " class\n");
|
||||
return PTR_ERR(oled_class);
|
||||
}
|
||||
|
||||
retval = class_create_file(oled_class, &class_attr_version.attr);
|
||||
if (retval) {
|
||||
printk(KERN_ERR "Error creating class version file\n");
|
||||
pr_err("Error creating class version file\n");
|
||||
goto error;
|
||||
}
|
||||
|
||||
retval = usb_register(&oled_driver);
|
||||
|
||||
if (retval) {
|
||||
printk(KERN_ERR "usb_register failed. Error number %d\n", retval);
|
||||
pr_err("usb_register failed. Error number %d\n", retval);
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,74 +7,28 @@
|
|||
#define MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES 256
|
||||
#include "Debug.h"
|
||||
|
||||
struct _LEADER {
|
||||
struct bcm_leader {
|
||||
USHORT Vcid;
|
||||
USHORT PLength;
|
||||
UCHAR Status;
|
||||
UCHAR Unused[3];
|
||||
} __packed;
|
||||
typedef struct _LEADER LEADER, *PLEADER;
|
||||
|
||||
struct _PACKETTOSEND {
|
||||
LEADER Leader;
|
||||
struct bcm_packettosend {
|
||||
struct bcm_leader Leader;
|
||||
UCHAR ucPayload;
|
||||
} __packed;
|
||||
typedef struct _PACKETTOSEND PACKETTOSEND, *PPACKETTOSEND;
|
||||
|
||||
struct _CONTROL_PACKET {
|
||||
struct bcm_control_packet {
|
||||
PVOID ControlBuff;
|
||||
UINT ControlBuffLen;
|
||||
struct _CONTROL_PACKET *next;
|
||||
struct bcm_control_packet *next;
|
||||
} __packed;
|
||||
typedef struct _CONTROL_PACKET CONTROL_PACKET, *PCONTROL_PACKET;
|
||||
|
||||
struct link_request {
|
||||
LEADER Leader;
|
||||
struct bcm_link_request {
|
||||
struct bcm_leader Leader;
|
||||
UCHAR szData[4];
|
||||
} __packed;
|
||||
typedef struct link_request LINK_REQUEST, *PLINK_REQUEST;
|
||||
|
||||
/* classification extension is added */
|
||||
typedef struct _ADD_CONNECTION {
|
||||
ULONG SrcIpAddressCount;
|
||||
ULONG SrcIpAddress[MAX_CONNECTIONS];
|
||||
ULONG SrcIpMask[MAX_CONNECTIONS];
|
||||
|
||||
ULONG DestIpAddressCount;
|
||||
ULONG DestIpAddress[MAX_CONNECTIONS];
|
||||
ULONG DestIpMask[MAX_CONNECTIONS];
|
||||
|
||||
USHORT SrcPortBegin;
|
||||
USHORT SrcPortEnd;
|
||||
|
||||
USHORT DestPortBegin;
|
||||
USHORT DestPortEnd;
|
||||
|
||||
UCHAR SrcTOS;
|
||||
UCHAR SrcProtocol;
|
||||
} ADD_CONNECTION, *PADD_CONNECTION;
|
||||
|
||||
typedef struct _CLASSIFICATION_RULE {
|
||||
UCHAR ucIPSrcAddrLen;
|
||||
UCHAR ucIPSrcAddr[32];
|
||||
UCHAR ucIPDestAddrLen;
|
||||
UCHAR ucIPDestAddr[32];
|
||||
UCHAR ucSrcPortRangeLen;
|
||||
UCHAR ucSrcPortRange[4];
|
||||
UCHAR ucDestPortRangeLen;
|
||||
UCHAR ucDestPortRange[4];
|
||||
USHORT usVcid;
|
||||
} CLASSIFICATION_RULE, *PCLASSIFICATION_RULE;
|
||||
|
||||
typedef struct _CLASSIFICATION_ONLY {
|
||||
USHORT usVcid;
|
||||
ULONG DestIpAddress;
|
||||
ULONG DestIpMask;
|
||||
USHORT usPortLo;
|
||||
USHORT usPortHi;
|
||||
BOOLEAN bIpVersion;
|
||||
UCHAR ucDestinationAddress[16];
|
||||
} CLASSIFICATION_ONLY, *PCLASSIFICATION_ONLY;
|
||||
|
||||
#define MAX_IP_RANGE_LENGTH 4
|
||||
#define MAX_PORT_RANGE 4
|
||||
|
@ -99,14 +53,13 @@ typedef union _U_IP_ADDRESS {
|
|||
UCHAR ucIpv6Mask[MAX_IP_RANGE_LENGTH * IPV6_ADDRESS_SIZEINBYTES];
|
||||
};
|
||||
} U_IP_ADDRESS;
|
||||
struct _packet_info;
|
||||
|
||||
typedef struct _S_HDR_SUPRESSION_CONTEXTINFO {
|
||||
UCHAR ucaHdrSupressionInBuf[MAX_PHS_LENGTHS]; /* Intermediate buffer to accumulate pkt Header for PHS */
|
||||
UCHAR ucaHdrSupressionOutBuf[MAX_PHS_LENGTHS + PHSI_LEN]; /* Intermediate buffer containing pkt Header after PHS */
|
||||
} S_HDR_SUPRESSION_CONTEXTINFO;
|
||||
struct bcm_hdr_suppression_contextinfo {
|
||||
UCHAR ucaHdrSuppressionInBuf[MAX_PHS_LENGTHS]; /* Intermediate buffer to accumulate pkt Header for PHS */
|
||||
UCHAR ucaHdrSuppressionOutBuf[MAX_PHS_LENGTHS + PHSI_LEN]; /* Intermediate buffer containing pkt Header after PHS */
|
||||
};
|
||||
|
||||
typedef struct _S_CLASSIFIER_RULE {
|
||||
struct bcm_classifier_rule {
|
||||
ULONG ulSFID;
|
||||
UCHAR ucReserved[2];
|
||||
B_UINT16 uiClassifierRuleIndex;
|
||||
|
@ -157,18 +110,17 @@ typedef struct _S_CLASSIFIER_RULE {
|
|||
UCHAR usUserPriority[2];
|
||||
USHORT usVLANID;
|
||||
USHORT usValidityBitMap;
|
||||
} S_CLASSIFIER_RULE;
|
||||
/* typedef struct _S_CLASSIFIER_RULE S_CLASSIFIER_RULE; */
|
||||
};
|
||||
|
||||
typedef struct _S_FRAGMENTED_PACKET_INFO {
|
||||
struct bcm_fragmented_packet_info {
|
||||
BOOLEAN bUsed;
|
||||
ULONG ulSrcIpAddress;
|
||||
USHORT usIpIdentification;
|
||||
S_CLASSIFIER_RULE *pstMatchedClassifierEntry;
|
||||
struct bcm_classifier_rule *pstMatchedClassifierEntry;
|
||||
BOOLEAN bOutOfOrderFragment;
|
||||
} S_FRAGMENTED_PACKET_INFO, *PS_FRAGMENTED_PACKET_INFO;
|
||||
};
|
||||
|
||||
struct _packet_info {
|
||||
struct bcm_packet_info {
|
||||
/* classification extension Rule */
|
||||
ULONG ulSFID;
|
||||
USHORT usVCID_Value;
|
||||
|
@ -237,11 +189,10 @@ struct _packet_info {
|
|||
UCHAR bIPCSSupport;
|
||||
UCHAR bEthCSSupport;
|
||||
};
|
||||
typedef struct _packet_info PacketInfo;
|
||||
|
||||
typedef struct _PER_TARANG_DATA {
|
||||
struct _PER_TARANG_DATA *next;
|
||||
struct _MINI_ADAPTER *Adapter;
|
||||
struct bcm_tarang_data {
|
||||
struct bcm_tarang_data *next;
|
||||
struct bcm_mini_adapter *Adapter;
|
||||
struct sk_buff *RxAppControlHead;
|
||||
struct sk_buff *RxAppControlTail;
|
||||
int AppCtrlQueueLen;
|
||||
|
@ -249,104 +200,23 @@ typedef struct _PER_TARANG_DATA {
|
|||
BOOLEAN bApplicationToExit;
|
||||
S_MIBS_DROPPED_APP_CNTRL_MESSAGES stDroppedAppCntrlMsgs;
|
||||
ULONG RxCntrlMsgBitMask;
|
||||
} PER_TARANG_DATA, *PPER_TARANG_DATA;
|
||||
};
|
||||
|
||||
#ifdef REL_4_1
|
||||
typedef struct _TARGET_PARAMS {
|
||||
B_UINT32 m_u32CfgVersion;
|
||||
|
||||
/* Scanning Related Params */
|
||||
B_UINT32 m_u32CenterFrequency;
|
||||
B_UINT32 m_u32BandAScan;
|
||||
B_UINT32 m_u32BandBScan;
|
||||
B_UINT32 m_u32BandCScan;
|
||||
|
||||
/* QoS Params */
|
||||
B_UINT32 m_u32minGrantsize; /* size of minimum grant is 0 or 6 */
|
||||
B_UINT32 m_u32PHSEnable;
|
||||
|
||||
/* HO Params */
|
||||
B_UINT32 m_u32HoEnable;
|
||||
B_UINT32 m_u32HoReserved1;
|
||||
B_UINT32 m_u32HoReserved2;
|
||||
|
||||
/* Power Control Params */
|
||||
B_UINT32 m_u32MimoEnable;
|
||||
B_UINT32 m_u32SecurityEnable;
|
||||
/*
|
||||
* bit 1: 1 Idlemode enable;
|
||||
* bit 2: 1 Sleepmode Enable
|
||||
*/
|
||||
B_UINT32 m_u32PowerSavingModesEnable;
|
||||
/* PowerSaving Mode Options:
|
||||
* bit 0 = 1: CPE mode - to keep pcmcia if alive;
|
||||
* bit 1 = 1: CINR reporing in Idlemode Msg
|
||||
* bit 2 = 1: Default PSC Enable in sleepmode
|
||||
*/
|
||||
B_UINT32 m_u32PowerSavingModeOptions;
|
||||
|
||||
B_UINT32 m_u32ArqEnable;
|
||||
|
||||
/* From Version #3, the HARQ section renamed as general */
|
||||
B_UINT32 m_u32HarqEnable;
|
||||
/* EEPROM Param Location */
|
||||
B_UINT32 m_u32EEPROMFlag;
|
||||
/* BINARY TYPE - 4th MSByte:
|
||||
* Interface Type - 3rd MSByte:
|
||||
* Vendor Type - 2nd MSByte
|
||||
*/
|
||||
/* Unused - LSByte */
|
||||
B_UINT32 m_u32Customize;
|
||||
B_UINT32 m_u32ConfigBW; /* In Hz */
|
||||
B_UINT32 m_u32ShutDownTimer;
|
||||
B_UINT32 m_u32RadioParameter;
|
||||
B_UINT32 m_u32PhyParameter1;
|
||||
B_UINT32 m_u32PhyParameter2;
|
||||
B_UINT32 m_u32PhyParameter3;
|
||||
|
||||
/* in eval mode only;
|
||||
* lower 16bits = basic cid for testing;
|
||||
* then bit 16 is test cqich,
|
||||
* bit 17 test init rang;
|
||||
* bit 18 test periodic rang
|
||||
* bit 19 is test harq ack/nack
|
||||
*/
|
||||
B_UINT32 m_u32TestOptions;
|
||||
B_UINT32 m_u32MaxMACDataperDLFrame;
|
||||
B_UINT32 m_u32MaxMACDataperULFrame;
|
||||
B_UINT32 m_u32Corr2MacFlags;
|
||||
|
||||
/* adding driver params. */
|
||||
B_UINT32 HostDrvrConfig1;
|
||||
B_UINT32 HostDrvrConfig2;
|
||||
B_UINT32 HostDrvrConfig3;
|
||||
B_UINT32 HostDrvrConfig4;
|
||||
B_UINT32 HostDrvrConfig5;
|
||||
B_UINT32 HostDrvrConfig6;
|
||||
B_UINT32 m_u32SegmentedPUSCenable;
|
||||
|
||||
/* BAMC enable - but 4.x does not support this feature
|
||||
* This is added just to sync 4.x and 5.x CFGs
|
||||
*/
|
||||
B_UINT32 m_u32BandAMCEnable;
|
||||
} STARGETPARAMS, *PSTARGETPARAMS;
|
||||
#endif
|
||||
|
||||
typedef struct _STTARGETDSXBUFFER {
|
||||
struct bcm_targetdsx_buffer {
|
||||
ULONG ulTargetDsxBuffer;
|
||||
B_UINT16 tid;
|
||||
BOOLEAN valid;
|
||||
} STTARGETDSXBUFFER, *PSTTARGETDSXBUFFER;
|
||||
};
|
||||
|
||||
typedef int (*FP_FLASH_WRITE)(struct _MINI_ADAPTER *, UINT, PVOID);
|
||||
typedef int (*FP_FLASH_WRITE)(struct bcm_mini_adapter *, UINT, PVOID);
|
||||
|
||||
typedef int (*FP_FLASH_WRITE_STATUS)(struct _MINI_ADAPTER *, UINT, PVOID);
|
||||
typedef int (*FP_FLASH_WRITE_STATUS)(struct bcm_mini_adapter *, UINT, PVOID);
|
||||
|
||||
/*
|
||||
* Driver adapter data structure
|
||||
*/
|
||||
struct _MINI_ADAPTER {
|
||||
struct _MINI_ADAPTER *next;
|
||||
struct bcm_mini_adapter {
|
||||
struct bcm_mini_adapter *next;
|
||||
struct net_device *dev;
|
||||
u32 msg_enable;
|
||||
CHAR *caDsxReqResp;
|
||||
|
@ -361,7 +231,7 @@ struct _MINI_ADAPTER {
|
|||
struct sk_buff *RxControlTail;
|
||||
struct semaphore RxAppControlQueuelock;
|
||||
struct semaphore fw_download_sema;
|
||||
PPER_TARANG_DATA pTarangs;
|
||||
struct bcm_tarang_data *pTarangs;
|
||||
spinlock_t control_queue_lock;
|
||||
wait_queue_head_t process_read_wait_queue;
|
||||
|
||||
|
@ -377,8 +247,8 @@ struct _MINI_ADAPTER {
|
|||
USHORT PrevNumRecvDescs;
|
||||
USHORT CurrNumRecvDescs;
|
||||
UINT u32TotalDSD;
|
||||
PacketInfo PackInfo[NO_OF_QUEUES];
|
||||
S_CLASSIFIER_RULE astClassifierTable[MAX_CLASSIFIERS];
|
||||
struct bcm_packet_info PackInfo[NO_OF_QUEUES];
|
||||
struct bcm_classifier_rule astClassifierTable[MAX_CLASSIFIERS];
|
||||
BOOLEAN TransferMode;
|
||||
|
||||
/*************** qos ******************/
|
||||
|
@ -404,7 +274,7 @@ struct _MINI_ADAPTER {
|
|||
UINT index_datpkt;
|
||||
struct semaphore rdmwrmsync;
|
||||
|
||||
STTARGETDSXBUFFER astTargetDsxBuffer[MAX_TARGET_DSX_BUFFERS];
|
||||
struct bcm_targetdsx_buffer astTargetDsxBuffer[MAX_TARGET_DSX_BUFFERS];
|
||||
ULONG ulFreeTargetBufferCnt;
|
||||
ULONG ulCurrentTargetBuffer;
|
||||
ULONG ulTotalTargetBuffersAvailable;
|
||||
|
@ -464,7 +334,7 @@ struct _MINI_ADAPTER {
|
|||
BOOLEAN bLinkDownRequested;
|
||||
int downloadDDR;
|
||||
PHS_DEVICE_EXTENSION stBCMPhsContext;
|
||||
S_HDR_SUPRESSION_CONTEXTINFO stPhsTxContextInfo;
|
||||
struct bcm_hdr_suppression_contextinfo stPhsTxContextInfo;
|
||||
uint8_t ucaPHSPktRestoreBuf[2048];
|
||||
uint8_t bPHSEnabled;
|
||||
BOOLEAN AutoFirmDld;
|
||||
|
@ -472,7 +342,7 @@ struct _MINI_ADAPTER {
|
|||
BOOLEAN bDPLLConfig;
|
||||
UINT32 aTxPktSizeHist[MIBS_MAX_HIST_ENTRIES];
|
||||
UINT32 aRxPktSizeHist[MIBS_MAX_HIST_ENTRIES];
|
||||
S_FRAGMENTED_PACKET_INFO astFragmentedPktClassifierTable[MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES];
|
||||
struct bcm_fragmented_packet_info astFragmentedPktClassifierTable[MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES];
|
||||
atomic_t uiMBupdate;
|
||||
UINT32 PmuMode;
|
||||
NVM_TYPE eNVMType;
|
||||
|
@ -524,37 +394,29 @@ struct _MINI_ADAPTER {
|
|||
UINT gpioBitMap;
|
||||
S_BCM_DEBUG_STATE stDebugState;
|
||||
};
|
||||
typedef struct _MINI_ADAPTER MINI_ADAPTER, *PMINI_ADAPTER;
|
||||
|
||||
#define GET_BCM_ADAPTER(net_dev) netdev_priv(net_dev)
|
||||
|
||||
struct _ETH_HEADER_STRUC {
|
||||
struct bcm_eth_header {
|
||||
UCHAR au8DestinationAddress[6];
|
||||
UCHAR au8SourceAddress[6];
|
||||
USHORT u16Etype;
|
||||
} __packed;
|
||||
typedef struct _ETH_HEADER_STRUC ETH_HEADER_STRUC, *PETH_HEADER_STRUC;
|
||||
|
||||
typedef struct FirmwareInfo {
|
||||
struct bcm_firmware_info {
|
||||
void __user *pvMappedFirmwareAddress;
|
||||
ULONG u32FirmwareLength;
|
||||
ULONG u32StartingAddress;
|
||||
} __packed FIRMWARE_INFO, *PFIRMWARE_INFO;
|
||||
} __packed;
|
||||
|
||||
/* holds the value of net_device structure.. */
|
||||
extern struct net_device *gblpnetdev;
|
||||
typedef struct _cntl_pkt {
|
||||
PMINI_ADAPTER Adapter;
|
||||
PLEADER PLeader;
|
||||
} cntl_pkt;
|
||||
typedef LINK_REQUEST CONTROL_MESSAGE;
|
||||
|
||||
typedef struct _DDR_SETTING {
|
||||
struct bcm_ddr_setting {
|
||||
UINT ulRegAddress;
|
||||
UINT ulRegValue;
|
||||
} DDR_SETTING, *PDDR_SETTING;
|
||||
typedef DDR_SETTING DDR_SET_NODE, *PDDR_SET_NODE;
|
||||
int InitAdapter(PMINI_ADAPTER psAdapter);
|
||||
};
|
||||
int InitAdapter(struct bcm_mini_adapter *psAdapter);
|
||||
|
||||
/* =====================================================================
|
||||
* Beceem vendor request codes for EP0
|
||||
|
@ -585,9 +447,9 @@ int InitAdapter(PMINI_ADAPTER psAdapter);
|
|||
#define EP5 4
|
||||
#define EP6 5
|
||||
|
||||
typedef enum eInterface_setting {
|
||||
enum bcm_einterface_setting {
|
||||
DEFAULT_SETTING_0 = 0,
|
||||
ALTERNATE_SETTING_1 = 1,
|
||||
} INTERFACE_SETTING;
|
||||
};
|
||||
|
||||
#endif /* __ADAPTER_H__ */
|
||||
|
|
|
@ -15,11 +15,11 @@
|
|||
|
||||
static int bcm_char_open(struct inode *inode, struct file * filp)
|
||||
{
|
||||
PMINI_ADAPTER Adapter = NULL;
|
||||
PPER_TARANG_DATA pTarang = NULL;
|
||||
struct bcm_mini_adapter *Adapter = NULL;
|
||||
struct bcm_tarang_data *pTarang = NULL;
|
||||
|
||||
Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
pTarang = kzalloc(sizeof(PER_TARANG_DATA), GFP_KERNEL);
|
||||
pTarang = kzalloc(sizeof(struct bcm_tarang_data), GFP_KERNEL);
|
||||
if (!pTarang)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@ -43,11 +43,11 @@ static int bcm_char_open(struct inode *inode, struct file * filp)
|
|||
|
||||
static int bcm_char_release(struct inode *inode, struct file *filp)
|
||||
{
|
||||
PPER_TARANG_DATA pTarang, tmp, ptmp;
|
||||
PMINI_ADAPTER Adapter = NULL;
|
||||
struct bcm_tarang_data *pTarang, *tmp, *ptmp;
|
||||
struct bcm_mini_adapter *Adapter = NULL;
|
||||
struct sk_buff *pkt, *npkt;
|
||||
|
||||
pTarang = (PPER_TARANG_DATA)filp->private_data;
|
||||
pTarang = (struct bcm_tarang_data *)filp->private_data;
|
||||
|
||||
if (pTarang == NULL) {
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0,
|
||||
|
@ -97,8 +97,8 @@ static int bcm_char_release(struct inode *inode, struct file *filp)
|
|||
static ssize_t bcm_char_read(struct file *filp, char __user *buf, size_t size,
|
||||
loff_t *f_pos)
|
||||
{
|
||||
PPER_TARANG_DATA pTarang = filp->private_data;
|
||||
PMINI_ADAPTER Adapter = pTarang->Adapter;
|
||||
struct bcm_tarang_data *pTarang = filp->private_data;
|
||||
struct bcm_mini_adapter *Adapter = pTarang->Adapter;
|
||||
struct sk_buff *Packet = NULL;
|
||||
ssize_t PktLen = 0;
|
||||
int wait_ret_val = 0;
|
||||
|
@ -155,9 +155,9 @@ static ssize_t bcm_char_read(struct file *filp, char __user *buf, size_t size,
|
|||
|
||||
static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
|
||||
{
|
||||
PPER_TARANG_DATA pTarang = filp->private_data;
|
||||
struct bcm_tarang_data *pTarang = filp->private_data;
|
||||
void __user *argp = (void __user *)arg;
|
||||
PMINI_ADAPTER Adapter = pTarang->Adapter;
|
||||
struct bcm_mini_adapter *Adapter = pTarang->Adapter;
|
||||
INT Status = STATUS_FAILURE;
|
||||
int timeout = 0;
|
||||
IOCTL_BUFFER IoBuffer;
|
||||
|
@ -722,7 +722,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
|
|||
if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)))
|
||||
return -EFAULT;
|
||||
|
||||
if (IoBuffer.InputLength < sizeof(struct link_request))
|
||||
if (IoBuffer.InputLength < sizeof(struct bcm_link_request))
|
||||
return -EINVAL;
|
||||
|
||||
if (IoBuffer.InputLength > MAX_CNTL_PKT_SIZE)
|
||||
|
@ -787,7 +787,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
|
|||
}
|
||||
|
||||
case IOCTL_BCM_BUFFER_DOWNLOAD: {
|
||||
FIRMWARE_INFO *psFwInfo = NULL;
|
||||
struct bcm_firmware_info *psFwInfo = NULL;
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Starting the firmware download PID =0x%x!!!!\n", current->pid);
|
||||
|
||||
if (!down_trylock(&Adapter->fw_download_sema)) {
|
||||
|
@ -807,7 +807,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
|
|||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0,
|
||||
"Length for FW DLD is : %lx\n", IoBuffer.InputLength);
|
||||
|
||||
if (IoBuffer.InputLength > sizeof(FIRMWARE_INFO)) {
|
||||
if (IoBuffer.InputLength > sizeof(struct bcm_firmware_info)) {
|
||||
up(&Adapter->fw_download_sema);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -971,7 +971,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
|
|||
break;
|
||||
|
||||
case IOCTL_GET_PACK_INFO:
|
||||
if (copy_to_user(argp, &Adapter->PackInfo, sizeof(PacketInfo)*NO_OF_QUEUES))
|
||||
if (copy_to_user(argp, &Adapter->PackInfo, sizeof(struct bcm_packet_info)*NO_OF_QUEUES))
|
||||
return -EFAULT;
|
||||
Status = STATUS_SUCCESS;
|
||||
break;
|
||||
|
@ -2014,7 +2014,7 @@ static const struct file_operations bcm_fops = {
|
|||
.llseek = no_llseek,
|
||||
};
|
||||
|
||||
int register_control_device_interface(PMINI_ADAPTER Adapter)
|
||||
int register_control_device_interface(struct bcm_mini_adapter *Adapter)
|
||||
{
|
||||
|
||||
if (Adapter->major > 0)
|
||||
|
@ -2039,7 +2039,7 @@ int register_control_device_interface(PMINI_ADAPTER Adapter)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void unregister_control_device_interface(PMINI_ADAPTER Adapter)
|
||||
void unregister_control_device_interface(struct bcm_mini_adapter *Adapter)
|
||||
{
|
||||
if (Adapter->major > 0) {
|
||||
device_destroy(bcm_class, MKDEV(Adapter->major, 0));
|
||||
|
|
|
@ -4,7 +4,7 @@ struct net_device *gblpnetdev;
|
|||
|
||||
static INT bcm_open(struct net_device *dev)
|
||||
{
|
||||
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(dev);
|
||||
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(dev);
|
||||
|
||||
if (Adapter->fw_download_done == FALSE) {
|
||||
pr_notice(PFX "%s: link up failed (download in progress)\n",
|
||||
|
@ -28,7 +28,7 @@ static INT bcm_open(struct net_device *dev)
|
|||
|
||||
static INT bcm_close(struct net_device *dev)
|
||||
{
|
||||
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(dev);
|
||||
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(dev);
|
||||
|
||||
if (netif_msg_ifdown(Adapter))
|
||||
pr_info(PFX "%s: disabling interface\n", dev->name);
|
||||
|
@ -59,7 +59,7 @@ static u16 bcm_select_queue(struct net_device *dev, struct sk_buff *skb)
|
|||
|
||||
static netdev_tx_t bcm_transmit(struct sk_buff *skb, struct net_device *dev)
|
||||
{
|
||||
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(dev);
|
||||
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(dev);
|
||||
u16 qindex = skb_get_queue_mapping(skb);
|
||||
|
||||
|
||||
|
@ -141,7 +141,7 @@ static int bcm_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
|
|||
static void bcm_get_drvinfo(struct net_device *dev,
|
||||
struct ethtool_drvinfo *info)
|
||||
{
|
||||
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(dev);
|
||||
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(dev);
|
||||
PS_INTERFACE_ADAPTER psIntfAdapter = Adapter->pvInterfaceAdapter;
|
||||
struct usb_device *udev = interface_to_usbdev(psIntfAdapter->interface);
|
||||
|
||||
|
@ -156,21 +156,21 @@ static void bcm_get_drvinfo(struct net_device *dev,
|
|||
|
||||
static u32 bcm_get_link(struct net_device *dev)
|
||||
{
|
||||
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(dev);
|
||||
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(dev);
|
||||
|
||||
return Adapter->LinkUpStatus;
|
||||
}
|
||||
|
||||
static u32 bcm_get_msglevel(struct net_device *dev)
|
||||
{
|
||||
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(dev);
|
||||
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(dev);
|
||||
|
||||
return Adapter->msg_enable;
|
||||
}
|
||||
|
||||
static void bcm_set_msglevel(struct net_device *dev, u32 level)
|
||||
{
|
||||
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(dev);
|
||||
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(dev);
|
||||
|
||||
Adapter->msg_enable = level;
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ static const struct ethtool_ops bcm_ethtool_ops = {
|
|||
.set_msglevel = bcm_set_msglevel,
|
||||
};
|
||||
|
||||
int register_networkdev(PMINI_ADAPTER Adapter)
|
||||
int register_networkdev(struct bcm_mini_adapter *Adapter)
|
||||
{
|
||||
struct net_device *net = Adapter->dev;
|
||||
PS_INTERFACE_ADAPTER IntfAdapter = Adapter->pvInterfaceAdapter;
|
||||
|
@ -224,7 +224,7 @@ int register_networkdev(PMINI_ADAPTER Adapter)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void unregister_networkdev(PMINI_ADAPTER Adapter)
|
||||
void unregister_networkdev(struct bcm_mini_adapter *Adapter)
|
||||
{
|
||||
struct net_device *net = Adapter->dev;
|
||||
PS_INTERFACE_ADAPTER IntfAdapter = Adapter->pvInterfaceAdapter;
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
* Management.
|
||||
************************************************************/
|
||||
|
||||
/* #define CONN_MSG */
|
||||
#include "headers.h"
|
||||
|
||||
enum E_CLASSIFIER_ACTION {
|
||||
|
@ -14,7 +13,7 @@ enum E_CLASSIFIER_ACTION {
|
|||
eDeleteClassifier
|
||||
};
|
||||
|
||||
static ULONG GetNextTargetBufferLocation(PMINI_ADAPTER Adapter, B_UINT16 tid);
|
||||
static ULONG GetNextTargetBufferLocation(struct bcm_mini_adapter *Adapter, B_UINT16 tid);
|
||||
|
||||
/************************************************************
|
||||
* Function - SearchSfid
|
||||
|
@ -28,7 +27,7 @@ static ULONG GetNextTargetBufferLocation(PMINI_ADAPTER Adapter, B_UINT16 tid);
|
|||
* Returns - Queue index for this SFID(If matched)
|
||||
* Else Invalid Queue Index(If Not matched)
|
||||
************************************************************/
|
||||
int SearchSfid(PMINI_ADAPTER Adapter, UINT uiSfid)
|
||||
int SearchSfid(struct bcm_mini_adapter *Adapter, UINT uiSfid)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -49,7 +48,7 @@ int SearchSfid(PMINI_ADAPTER Adapter, UINT uiSfid)
|
|||
* Returns - Queue index for the free SFID
|
||||
* Else returns Invalid Index.
|
||||
****************************************************************/
|
||||
static int SearchFreeSfid(PMINI_ADAPTER Adapter)
|
||||
static int SearchFreeSfid(struct bcm_mini_adapter *Adapter)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -63,12 +62,12 @@ static int SearchFreeSfid(PMINI_ADAPTER Adapter)
|
|||
/*
|
||||
* Function: SearchClsid
|
||||
* Description: This routinue would search Classifier having specified ClassifierID as input parameter
|
||||
* Input parameters: PMINI_ADAPTER Adapter - Adapter Context
|
||||
* Input parameters: struct bcm_mini_adapter *Adapter - Adapter Context
|
||||
* unsigned int uiSfid - The SF in which the classifier is to searched
|
||||
* B_UINT16 uiClassifierID - The classifier ID to be searched
|
||||
* Return: int :Classifier table index of matching entry
|
||||
*/
|
||||
static int SearchClsid(PMINI_ADAPTER Adapter, ULONG ulSFID, B_UINT16 uiClassifierID)
|
||||
static int SearchClsid(struct bcm_mini_adapter *Adapter, ULONG ulSFID, B_UINT16 uiClassifierID)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -87,7 +86,7 @@ static int SearchClsid(PMINI_ADAPTER Adapter, ULONG ulSFID, B_UINT16 uiClassifi
|
|||
* This routinue would search Free available Classifier entry in classifier table.
|
||||
* @return free Classifier Entry index in classifier table for specified SF
|
||||
*/
|
||||
static int SearchFreeClsid(PMINI_ADAPTER Adapter /**Adapter Context*/)
|
||||
static int SearchFreeClsid(struct bcm_mini_adapter *Adapter /**Adapter Context*/)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -99,7 +98,7 @@ static int SearchFreeClsid(PMINI_ADAPTER Adapter /**Adapter Context*/)
|
|||
return MAX_CLASSIFIERS+1;
|
||||
}
|
||||
|
||||
static VOID deleteSFBySfid(PMINI_ADAPTER Adapter, UINT uiSearchRuleIndex)
|
||||
static VOID deleteSFBySfid(struct bcm_mini_adapter *Adapter, UINT uiSearchRuleIndex)
|
||||
{
|
||||
/* deleting all the packet held in the SF */
|
||||
flush_queue(Adapter, uiSearchRuleIndex);
|
||||
|
@ -112,7 +111,7 @@ static VOID deleteSFBySfid(PMINI_ADAPTER Adapter, UINT uiSearchRuleIndex)
|
|||
}
|
||||
|
||||
static inline VOID
|
||||
CopyIpAddrToClassifier(S_CLASSIFIER_RULE *pstClassifierEntry,
|
||||
CopyIpAddrToClassifier(struct bcm_classifier_rule *pstClassifierEntry,
|
||||
B_UINT8 u8IpAddressLen, B_UINT8 *pu8IpAddressMaskSrc,
|
||||
BOOLEAN bIpVersion6, E_IPADDR_CONTEXT eIpAddrContext)
|
||||
{
|
||||
|
@ -120,7 +119,7 @@ CopyIpAddrToClassifier(S_CLASSIFIER_RULE *pstClassifierEntry,
|
|||
UINT nSizeOfIPAddressInBytes = IP_LENGTH_OF_ADDRESS;
|
||||
UCHAR *ptrClassifierIpAddress = NULL;
|
||||
UCHAR *ptrClassifierIpMask = NULL;
|
||||
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
|
||||
if (bIpVersion6)
|
||||
nSizeOfIPAddressInBytes = IPV6_ADDRESS_SIZEINBYTES;
|
||||
|
@ -214,7 +213,7 @@ CopyIpAddrToClassifier(S_CLASSIFIER_RULE *pstClassifierEntry,
|
|||
}
|
||||
}
|
||||
|
||||
void ClearTargetDSXBuffer(PMINI_ADAPTER Adapter, B_UINT16 TID, BOOLEAN bFreeAll)
|
||||
void ClearTargetDSXBuffer(struct bcm_mini_adapter *Adapter, B_UINT16 TID, BOOLEAN bFreeAll)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -236,9 +235,9 @@ void ClearTargetDSXBuffer(PMINI_ADAPTER Adapter, B_UINT16 TID, BOOLEAN bFreeAll)
|
|||
* @ingroup ctrl_pkt_functions
|
||||
* copy classifier rule into the specified SF index
|
||||
*/
|
||||
static inline VOID CopyClassifierRuleToSF(PMINI_ADAPTER Adapter, stConvergenceSLTypes *psfCSType, UINT uiSearchRuleIndex, UINT nClassifierIndex)
|
||||
static inline VOID CopyClassifierRuleToSF(struct bcm_mini_adapter *Adapter, stConvergenceSLTypes *psfCSType, UINT uiSearchRuleIndex, UINT nClassifierIndex)
|
||||
{
|
||||
S_CLASSIFIER_RULE *pstClassifierEntry = NULL;
|
||||
struct bcm_classifier_rule *pstClassifierEntry = NULL;
|
||||
/* VOID *pvPhsContext = NULL; */
|
||||
int i;
|
||||
/* UCHAR ucProtocolLength=0; */
|
||||
|
@ -365,9 +364,9 @@ static inline VOID CopyClassifierRuleToSF(PMINI_ADAPTER Adapter, stConvergenceSL
|
|||
/*
|
||||
* @ingroup ctrl_pkt_functions
|
||||
*/
|
||||
static inline VOID DeleteClassifierRuleFromSF(PMINI_ADAPTER Adapter, UINT uiSearchRuleIndex, UINT nClassifierIndex)
|
||||
static inline VOID DeleteClassifierRuleFromSF(struct bcm_mini_adapter *Adapter, UINT uiSearchRuleIndex, UINT nClassifierIndex)
|
||||
{
|
||||
S_CLASSIFIER_RULE *pstClassifierEntry = NULL;
|
||||
struct bcm_classifier_rule *pstClassifierEntry = NULL;
|
||||
B_UINT16 u16PacketClassificationRuleIndex;
|
||||
USHORT usVCID;
|
||||
/* VOID *pvPhsContext = NULL; */
|
||||
|
@ -386,7 +385,7 @@ static inline VOID DeleteClassifierRuleFromSF(PMINI_ADAPTER Adapter, UINT uiSear
|
|||
if (pstClassifierEntry) {
|
||||
pstClassifierEntry->bUsed = FALSE;
|
||||
pstClassifierEntry->uiClassifierRuleIndex = 0;
|
||||
memset(pstClassifierEntry, 0, sizeof(S_CLASSIFIER_RULE));
|
||||
memset(pstClassifierEntry, 0, sizeof(struct bcm_classifier_rule));
|
||||
|
||||
/* Delete the PHS Rule for this classifier */
|
||||
PhsDeleteClassifierRule(&Adapter->stBCMPhsContext, usVCID, u16PacketClassificationRuleIndex);
|
||||
|
@ -396,9 +395,9 @@ static inline VOID DeleteClassifierRuleFromSF(PMINI_ADAPTER Adapter, UINT uiSear
|
|||
/*
|
||||
* @ingroup ctrl_pkt_functions
|
||||
*/
|
||||
VOID DeleteAllClassifiersForSF(PMINI_ADAPTER Adapter, UINT uiSearchRuleIndex)
|
||||
VOID DeleteAllClassifiersForSF(struct bcm_mini_adapter *Adapter, UINT uiSearchRuleIndex)
|
||||
{
|
||||
S_CLASSIFIER_RULE *pstClassifierEntry = NULL;
|
||||
struct bcm_classifier_rule *pstClassifierEntry = NULL;
|
||||
int i;
|
||||
/* B_UINT16 u16PacketClassificationRuleIndex; */
|
||||
USHORT ulVCID;
|
||||
|
@ -428,7 +427,7 @@ VOID DeleteAllClassifiersForSF(PMINI_ADAPTER Adapter, UINT uiSearchRuleIndex)
|
|||
* related data into the Adapter structure.
|
||||
* @ingroup ctrl_pkt_functions
|
||||
*/
|
||||
static VOID CopyToAdapter(register PMINI_ADAPTER Adapter, /* <Pointer to the Adapter structure */
|
||||
static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* <Pointer to the Adapter structure */
|
||||
register pstServiceFlowParamSI psfLocalSet, /* <Pointer to the ServiceFlowParamSI structure */
|
||||
register UINT uiSearchRuleIndex, /* <Index of Queue, to which this data belongs */
|
||||
register UCHAR ucDsxType,
|
||||
|
@ -836,7 +835,7 @@ static VOID DumpCmControlPacket(PVOID pvBuffer)
|
|||
int nIndex;
|
||||
stLocalSFAddIndicationAlt *pstAddIndication;
|
||||
UINT nCurClassifierCnt;
|
||||
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
|
||||
pstAddIndication = (stLocalSFAddIndicationAlt *)pvBuffer;
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "======>");
|
||||
|
@ -967,24 +966,18 @@ static VOID DumpCmControlPacket(PVOID pvBuffer)
|
|||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetDestMacAddressLength: 0x%02X ",
|
||||
psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength);
|
||||
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetDestMacAddress[6]: 0x %02X %02X %02X %02X %02X %02X",
|
||||
psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[0],
|
||||
psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[1],
|
||||
psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[2],
|
||||
psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[3],
|
||||
psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[4],
|
||||
psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[5]);
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
|
||||
DBG_LVL_ALL, "u8EthernetDestMacAddress[6]: %pM",
|
||||
psfCSType->cCPacketClassificationRule.
|
||||
u8EthernetDestMacAddress);
|
||||
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetSourceMACAddressLength: 0x%02X ",
|
||||
psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength);
|
||||
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetSourceMACAddress[6]: 0x %02X %02X %02X %02X %02X %02X",
|
||||
psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[0],
|
||||
psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[1],
|
||||
psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[2],
|
||||
psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[3],
|
||||
psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[4],
|
||||
psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[5]);
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
|
||||
DBG_LVL_ALL, "u8EthernetSourceMACAddress[6]: "
|
||||
"%pM", psfCSType->cCPacketClassificationRule.
|
||||
u8EthernetSourceMACAddress);
|
||||
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthertypeLength: 0x%02X ",
|
||||
psfCSType->cCPacketClassificationRule.u8EthertypeLength);
|
||||
|
@ -1123,24 +1116,18 @@ static VOID DumpCmControlPacket(PVOID pvBuffer)
|
|||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetDestMacAddressLength: 0x%02X ",
|
||||
psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength);
|
||||
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetDestMacAddress[6]: 0x %02X %02X %02X %02X %02X %02X",
|
||||
psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[0],
|
||||
psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[1],
|
||||
psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[2],
|
||||
psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[3],
|
||||
psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[4],
|
||||
psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[5]);
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
|
||||
DBG_LVL_ALL, "u8EthernetDestMacAddress[6]: %pM",
|
||||
psfCSType->cCPacketClassificationRule.
|
||||
u8EthernetDestMacAddress);
|
||||
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetSourceMACAddressLength: 0x%02X ",
|
||||
psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength);
|
||||
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetSourceMACAddress[6]: 0x %02X %02X %02X %02X %02X %02X",
|
||||
psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[0],
|
||||
psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[1],
|
||||
psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[2],
|
||||
psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[3],
|
||||
psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[4],
|
||||
psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[5]);
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
|
||||
DBG_LVL_ALL, "u8EthernetSourceMACAddress[6]: "
|
||||
"%pM", psfCSType->cCPacketClassificationRule.
|
||||
u8EthernetSourceMACAddress);
|
||||
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthertypeLength: 0x%02X ", psfCSType->cCPacketClassificationRule.u8EthertypeLength);
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8Ethertype[3]: 0x%02X %02X %02X",
|
||||
|
@ -1325,7 +1312,7 @@ static VOID DumpCmControlPacket(PVOID pvBuffer)
|
|||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " bValid: 0x%X", pstAddIndication->sfActiveSet.bValid);
|
||||
}
|
||||
|
||||
static inline ULONG RestoreSFParam(PMINI_ADAPTER Adapter, ULONG ulAddrSFParamSet, PUCHAR pucDestBuffer)
|
||||
static inline ULONG RestoreSFParam(struct bcm_mini_adapter *Adapter, ULONG ulAddrSFParamSet, PUCHAR pucDestBuffer)
|
||||
{
|
||||
UINT nBytesToRead = sizeof(stServiceFlowParamSI);
|
||||
|
||||
|
@ -1342,7 +1329,7 @@ static inline ULONG RestoreSFParam(PMINI_ADAPTER Adapter, ULONG ulAddrSFParamSet
|
|||
return 1;
|
||||
}
|
||||
|
||||
static ULONG StoreSFParam(PMINI_ADAPTER Adapter, PUCHAR pucSrcBuffer, ULONG ulAddrSFParamSet)
|
||||
static ULONG StoreSFParam(struct bcm_mini_adapter *Adapter, PUCHAR pucSrcBuffer, ULONG ulAddrSFParamSet)
|
||||
{
|
||||
UINT nBytesToWrite = sizeof(stServiceFlowParamSI);
|
||||
int ret = 0;
|
||||
|
@ -1358,7 +1345,7 @@ static ULONG StoreSFParam(PMINI_ADAPTER Adapter, PUCHAR pucSrcBuffer, ULONG ulAd
|
|||
return 1;
|
||||
}
|
||||
|
||||
ULONG StoreCmControlResponseMessage(PMINI_ADAPTER Adapter, PVOID pvBuffer, UINT *puBufferLength)
|
||||
ULONG StoreCmControlResponseMessage(struct bcm_mini_adapter *Adapter, PVOID pvBuffer, UINT *puBufferLength)
|
||||
{
|
||||
stLocalSFAddIndicationAlt *pstAddIndicationAlt = NULL;
|
||||
stLocalSFAddIndication *pstAddIndication = NULL;
|
||||
|
@ -1473,7 +1460,7 @@ ULONG StoreCmControlResponseMessage(PMINI_ADAPTER Adapter, PVOID pvBuffer, UINT
|
|||
}
|
||||
|
||||
static inline stLocalSFAddIndicationAlt
|
||||
*RestoreCmControlResponseMessage(register PMINI_ADAPTER Adapter, register PVOID pvBuffer)
|
||||
*RestoreCmControlResponseMessage(register struct bcm_mini_adapter *Adapter, register PVOID pvBuffer)
|
||||
{
|
||||
ULONG ulStatus = 0;
|
||||
stLocalSFAddIndication *pstAddIndication = NULL;
|
||||
|
@ -1551,7 +1538,7 @@ static inline stLocalSFAddIndicationAlt
|
|||
return NULL;
|
||||
}
|
||||
|
||||
ULONG SetUpTargetDsxBuffers(PMINI_ADAPTER Adapter)
|
||||
ULONG SetUpTargetDsxBuffers(struct bcm_mini_adapter *Adapter)
|
||||
{
|
||||
ULONG ulTargetDsxBuffersBase = 0;
|
||||
ULONG ulCntTargetBuffers;
|
||||
|
@ -1598,7 +1585,7 @@ ULONG SetUpTargetDsxBuffers(PMINI_ADAPTER Adapter)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static ULONG GetNextTargetBufferLocation(PMINI_ADAPTER Adapter, B_UINT16 tid)
|
||||
static ULONG GetNextTargetBufferLocation(struct bcm_mini_adapter *Adapter, B_UINT16 tid)
|
||||
{
|
||||
ULONG ulTargetDSXBufferAddress;
|
||||
ULONG ulTargetDsxBufferIndexToUse, ulMaxTry;
|
||||
|
@ -1632,7 +1619,7 @@ static ULONG GetNextTargetBufferLocation(PMINI_ADAPTER Adapter, B_UINT16 tid)
|
|||
return ulTargetDSXBufferAddress;
|
||||
}
|
||||
|
||||
int AllocAdapterDsxBuffer(PMINI_ADAPTER Adapter)
|
||||
int AllocAdapterDsxBuffer(struct bcm_mini_adapter *Adapter)
|
||||
{
|
||||
/*
|
||||
* Need to Allocate memory to contain the SUPER Large structures
|
||||
|
@ -1645,7 +1632,7 @@ int AllocAdapterDsxBuffer(PMINI_ADAPTER Adapter)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int FreeAdapterDsxBuffer(PMINI_ADAPTER Adapter)
|
||||
int FreeAdapterDsxBuffer(struct bcm_mini_adapter *Adapter)
|
||||
{
|
||||
kfree(Adapter->caDsxReqResp);
|
||||
return 0;
|
||||
|
@ -1657,13 +1644,13 @@ int FreeAdapterDsxBuffer(PMINI_ADAPTER Adapter)
|
|||
* for the Connection Management.
|
||||
* @return - Queue index for the free SFID else returns Invalid Index.
|
||||
*/
|
||||
BOOLEAN CmControlResponseMessage(PMINI_ADAPTER Adapter, /* <Pointer to the Adapter structure */
|
||||
BOOLEAN CmControlResponseMessage(struct bcm_mini_adapter *Adapter, /* <Pointer to the Adapter structure */
|
||||
PVOID pvBuffer /* Starting Address of the Buffer, that contains the AddIndication Data */)
|
||||
{
|
||||
stServiceFlowParamSI *psfLocalSet = NULL;
|
||||
stLocalSFAddIndicationAlt *pstAddIndication = NULL;
|
||||
stLocalSFChangeIndicationAlt *pstChangeIndication = NULL;
|
||||
PLEADER pLeader = NULL;
|
||||
struct bcm_leader *pLeader = NULL;
|
||||
|
||||
/*
|
||||
* Otherwise the message contains a target address from where we need to
|
||||
|
@ -1678,7 +1665,7 @@ BOOLEAN CmControlResponseMessage(PMINI_ADAPTER Adapter, /* <Pointer to the Adap
|
|||
|
||||
DumpCmControlPacket(pstAddIndication);
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "====>");
|
||||
pLeader = (PLEADER)Adapter->caDsxReqResp;
|
||||
pLeader = (struct bcm_leader *)Adapter->caDsxReqResp;
|
||||
|
||||
pLeader->Status = CM_CONTROL_NEWDSX_MULTICLASSIFIER_REQ;
|
||||
pLeader->Vcid = 0;
|
||||
|
@ -1915,10 +1902,10 @@ BOOLEAN CmControlResponseMessage(PMINI_ADAPTER Adapter, /* <Pointer to the Adap
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
int get_dsx_sf_data_to_application(PMINI_ADAPTER Adapter, UINT uiSFId, void __user *user_buffer)
|
||||
int get_dsx_sf_data_to_application(struct bcm_mini_adapter *Adapter, UINT uiSFId, void __user *user_buffer)
|
||||
{
|
||||
int status = 0;
|
||||
struct _packet_info *psSfInfo = NULL;
|
||||
struct bcm_packet_info *psSfInfo = NULL;
|
||||
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "status =%d", status);
|
||||
status = SearchSfid(Adapter, uiSFId);
|
||||
|
@ -1937,7 +1924,7 @@ int get_dsx_sf_data_to_application(PMINI_ADAPTER Adapter, UINT uiSFId, void __us
|
|||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
VOID OverrideServiceFlowParams(PMINI_ADAPTER Adapter, PUINT puiBuffer)
|
||||
VOID OverrideServiceFlowParams(struct bcm_mini_adapter *Adapter, PUINT puiBuffer)
|
||||
{
|
||||
B_UINT32 u32NumofSFsinMsg = ntohl(*(puiBuffer + 1));
|
||||
stIM_SFHostNotify *pHostInfo = NULL;
|
||||
|
|
|
@ -148,14 +148,14 @@ typedef struct stLocalSFChangeIndicationAlt{
|
|||
|
||||
}stLocalSFChangeIndicationAlt;
|
||||
|
||||
ULONG StoreCmControlResponseMessage(PMINI_ADAPTER Adapter,PVOID pvBuffer,UINT *puBufferLength);
|
||||
ULONG StoreCmControlResponseMessage(struct bcm_mini_adapter *Adapter, PVOID pvBuffer,UINT *puBufferLength);
|
||||
|
||||
INT AllocAdapterDsxBuffer(PMINI_ADAPTER Adapter);
|
||||
INT AllocAdapterDsxBuffer(struct bcm_mini_adapter *Adapter);
|
||||
|
||||
INT FreeAdapterDsxBuffer(PMINI_ADAPTER Adapter);
|
||||
ULONG SetUpTargetDsxBuffers(PMINI_ADAPTER Adapter);
|
||||
INT FreeAdapterDsxBuffer(struct bcm_mini_adapter *Adapter);
|
||||
ULONG SetUpTargetDsxBuffers(struct bcm_mini_adapter *Adapter);
|
||||
|
||||
BOOLEAN CmControlResponseMessage(PMINI_ADAPTER Adapter,PVOID pvBuffer);
|
||||
BOOLEAN CmControlResponseMessage(struct bcm_mini_adapter *Adapter, PVOID pvBuffer);
|
||||
|
||||
|
||||
#pragma pack (pop)
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
//DDR INIT-133Mhz
|
||||
#define T3_SKIP_CLOCK_PROGRAM_DUMP_133MHZ 12 //index for 0x0F007000
|
||||
static DDR_SET_NODE asT3_DDRSetting133MHz[]= {// # DPLL Clock Setting
|
||||
static struct bcm_ddr_setting asT3_DDRSetting133MHz[]= {// # DPLL Clock Setting
|
||||
{0x0F000800,0x00007212},
|
||||
{0x0f000820,0x07F13FFF},
|
||||
{0x0f000810,0x00000F95},
|
||||
|
@ -65,7 +65,7 @@ static DDR_SET_NODE asT3_DDRSetting133MHz[]= {// # DPLL Clock Setting
|
|||
};
|
||||
//80Mhz
|
||||
#define T3_SKIP_CLOCK_PROGRAM_DUMP_80MHZ 10 //index for 0x0F007000
|
||||
static DDR_SET_NODE asT3_DDRSetting80MHz[]= {// # DPLL Clock Setting
|
||||
static struct bcm_ddr_setting asT3_DDRSetting80MHz[]= {// # DPLL Clock Setting
|
||||
{0x0f000810,0x00000F95},
|
||||
{0x0f000820,0x07f1ffff},
|
||||
{0x0f000860,0x00000000},
|
||||
|
@ -117,7 +117,7 @@ static DDR_SET_NODE asT3_DDRSetting80MHz[]= {// # DPLL Clock Setting
|
|||
};
|
||||
//100Mhz
|
||||
#define T3_SKIP_CLOCK_PROGRAM_DUMP_100MHZ 13 //index for 0x0F007000
|
||||
static DDR_SET_NODE asT3_DDRSetting100MHz[]= {// # DPLL Clock Setting
|
||||
static struct bcm_ddr_setting asT3_DDRSetting100MHz[]= {// # DPLL Clock Setting
|
||||
{0x0F000800,0x00007008},
|
||||
{0x0f000810,0x00000F95},
|
||||
{0x0f000820,0x07F13E3F},
|
||||
|
@ -177,7 +177,7 @@ static DDR_SET_NODE asT3_DDRSetting100MHz[]= {// # DPLL Clock Setting
|
|||
|
||||
//Net T3B DDR Settings
|
||||
//DDR INIT-133Mhz
|
||||
static DDR_SET_NODE asDPLL_266MHZ[] = {
|
||||
static struct bcm_ddr_setting asDPLL_266MHZ[] = {
|
||||
{0x0F000800,0x00007212},
|
||||
{0x0f000820,0x07F13FFF},
|
||||
{0x0f000810,0x00000F95},
|
||||
|
@ -189,7 +189,7 @@ static DDR_SET_NODE asDPLL_266MHZ[] = {
|
|||
};
|
||||
|
||||
#define T3B_SKIP_CLOCK_PROGRAM_DUMP_133MHZ 11 //index for 0x0F007000
|
||||
static DDR_SET_NODE asT3B_DDRSetting133MHz[] = {// # DPLL Clock Setting
|
||||
static struct bcm_ddr_setting asT3B_DDRSetting133MHz[] = {// # DPLL Clock Setting
|
||||
{0x0f000810,0x00000F95},
|
||||
{0x0f000810,0x00000F95},
|
||||
{0x0f000810,0x00000F95},
|
||||
|
@ -247,7 +247,7 @@ static DDR_SET_NODE asT3B_DDRSetting133MHz[] = {// # DPLL Clock Setting
|
|||
};
|
||||
|
||||
#define T3B_SKIP_CLOCK_PROGRAM_DUMP_80MHZ 9 //index for 0x0F007000
|
||||
static DDR_SET_NODE asT3B_DDRSetting80MHz[] = {// # DPLL Clock Setting
|
||||
static struct bcm_ddr_setting asT3B_DDRSetting80MHz[] = {// # DPLL Clock Setting
|
||||
{0x0f000810,0x00000F95},
|
||||
{0x0f000820,0x07F13FFF},
|
||||
{0x0f000840,0x0FFF1F00},
|
||||
|
@ -301,7 +301,7 @@ static DDR_SET_NODE asT3B_DDRSetting80MHz[] = {// # DPLL Clock Setting
|
|||
|
||||
//100Mhz
|
||||
#define T3B_SKIP_CLOCK_PROGRAM_DUMP_100MHZ 9 //index for 0x0F007000
|
||||
static DDR_SET_NODE asT3B_DDRSetting100MHz[] = {// # DPLL Clock Setting
|
||||
static struct bcm_ddr_setting asT3B_DDRSetting100MHz[] = {// # DPLL Clock Setting
|
||||
{0x0f000810,0x00000F95},
|
||||
{0x0f000820,0x07F1369B},
|
||||
{0x0f000840,0x0FFF0800},
|
||||
|
@ -356,7 +356,7 @@ static DDR_SET_NODE asT3B_DDRSetting100MHz[] = {// # DPLL Clock Setting
|
|||
|
||||
|
||||
#define T3LP_SKIP_CLOCK_PROGRAM_DUMP_133MHZ 9 //index for 0x0F007000
|
||||
static DDR_SET_NODE asT3LP_DDRSetting133MHz[]= {// # DPLL Clock Setting
|
||||
static struct bcm_ddr_setting asT3LP_DDRSetting133MHz[]= {// # DPLL Clock Setting
|
||||
{0x0f000820,0x03F1365B},
|
||||
{0x0f000810,0x00002F95},
|
||||
{0x0f000880,0x000003DD},
|
||||
|
@ -416,7 +416,7 @@ static DDR_SET_NODE asT3LP_DDRSetting133MHz[]= {// # DPLL Clock Setting
|
|||
};
|
||||
|
||||
#define T3LP_SKIP_CLOCK_PROGRAM_DUMP_100MHZ 11 //index for 0x0F007000
|
||||
static DDR_SET_NODE asT3LP_DDRSetting100MHz[]= {// # DPLL Clock Setting
|
||||
static struct bcm_ddr_setting asT3LP_DDRSetting100MHz[]= {// # DPLL Clock Setting
|
||||
{0x0f000810,0x00002F95},
|
||||
{0x0f000820,0x03F1369B},
|
||||
{0x0f000840,0x0fff0000},
|
||||
|
@ -476,7 +476,7 @@ static DDR_SET_NODE asT3LP_DDRSetting100MHz[]= {// # DPLL Clock Setting
|
|||
};
|
||||
|
||||
#define T3LP_SKIP_CLOCK_PROGRAM_DUMP_80MHZ 9 //index for 0x0F007000
|
||||
static DDR_SET_NODE asT3LP_DDRSetting80MHz[]= {// # DPLL Clock Setting
|
||||
static struct bcm_ddr_setting asT3LP_DDRSetting80MHz[]= {// # DPLL Clock Setting
|
||||
{0x0f000820,0x07F13FFF},
|
||||
{0x0f000810,0x00002F95},
|
||||
{0x0f000860,0x00000000},
|
||||
|
@ -536,7 +536,7 @@ static DDR_SET_NODE asT3LP_DDRSetting80MHz[]= {// # DPLL Clock Setting
|
|||
///T3 LP-B (UMA-B)
|
||||
|
||||
#define T3LPB_SKIP_CLOCK_PROGRAM_DUMP_160MHZ 7 //index for 0x0F007000
|
||||
static DDR_SET_NODE asT3LPB_DDRSetting160MHz[]= {// # DPLL Clock Setting
|
||||
static struct bcm_ddr_setting asT3LPB_DDRSetting160MHz[]= {// # DPLL Clock Setting
|
||||
|
||||
{0x0f000820,0x03F137DB},
|
||||
{0x0f000810,0x01842795},
|
||||
|
@ -594,7 +594,7 @@ static DDR_SET_NODE asT3LPB_DDRSetting160MHz[]= {// # DPLL Clock Setting
|
|||
|
||||
|
||||
#define T3LPB_SKIP_CLOCK_PROGRAM_DUMP_133MHZ 7 //index for 0x0F007000
|
||||
static DDR_SET_NODE asT3LPB_DDRSetting133MHz[]= {// # DPLL Clock Setting
|
||||
static struct bcm_ddr_setting asT3LPB_DDRSetting133MHz[]= {// # DPLL Clock Setting
|
||||
{0x0f000820,0x03F1365B},
|
||||
{0x0f000810,0x00002F95},
|
||||
{0x0f000880,0x000003DD},
|
||||
|
@ -655,7 +655,7 @@ static DDR_SET_NODE asT3LPB_DDRSetting133MHz[]= {// # DPLL Clock Setting
|
|||
};
|
||||
|
||||
#define T3LPB_SKIP_CLOCK_PROGRAM_DUMP_100MHZ 8 //index for 0x0F007000
|
||||
static DDR_SET_NODE asT3LPB_DDRSetting100MHz[]= {// # DPLL Clock Setting
|
||||
static struct bcm_ddr_setting asT3LPB_DDRSetting100MHz[]= {// # DPLL Clock Setting
|
||||
{0x0f000810,0x00002F95},
|
||||
{0x0f000820,0x03F1369B},
|
||||
{0x0f000840,0x0fff0000},
|
||||
|
@ -716,7 +716,7 @@ static DDR_SET_NODE asT3LPB_DDRSetting100MHz[]= {// # DPLL Clock Setting
|
|||
};
|
||||
|
||||
#define T3LPB_SKIP_CLOCK_PROGRAM_DUMP_80MHZ 7 //index for 0x0F007000
|
||||
static DDR_SET_NODE asT3LPB_DDRSetting80MHz[]= {// # DPLL Clock Setting
|
||||
static struct bcm_ddr_setting asT3LPB_DDRSetting80MHz[]= {// # DPLL Clock Setting
|
||||
{0x0f000820,0x07F13FFF},
|
||||
{0x0f000810,0x00002F95},
|
||||
{0x0f000860,0x00000000},
|
||||
|
@ -772,9 +772,9 @@ static DDR_SET_NODE asT3LPB_DDRSetting80MHz[]= {// # DPLL Clock Setting
|
|||
};
|
||||
|
||||
|
||||
int ddr_init(MINI_ADAPTER *Adapter)
|
||||
int ddr_init(struct bcm_mini_adapter *Adapter)
|
||||
{
|
||||
PDDR_SETTING psDDRSetting=NULL;
|
||||
struct bcm_ddr_setting *psDDRSetting=NULL;
|
||||
ULONG RegCount=0;
|
||||
UINT value = 0;
|
||||
UINT uiResetValue = 0;
|
||||
|
@ -789,17 +789,17 @@ int ddr_init(MINI_ADAPTER *Adapter)
|
|||
case DDR_80_MHZ:
|
||||
psDDRSetting=asT3LP_DDRSetting80MHz;
|
||||
RegCount=(sizeof(asT3LP_DDRSetting80MHz)/
|
||||
sizeof(DDR_SETTING));
|
||||
sizeof(struct bcm_ddr_setting));
|
||||
break;
|
||||
case DDR_100_MHZ:
|
||||
psDDRSetting=asT3LP_DDRSetting100MHz;
|
||||
RegCount=(sizeof(asT3LP_DDRSetting100MHz)/
|
||||
sizeof(DDR_SETTING));
|
||||
sizeof(struct bcm_ddr_setting));
|
||||
break;
|
||||
case DDR_133_MHZ:
|
||||
psDDRSetting=asT3LP_DDRSetting133MHz;
|
||||
RegCount=(sizeof(asT3LP_DDRSetting133MHz)/
|
||||
sizeof(DDR_SETTING));
|
||||
sizeof(struct bcm_ddr_setting));
|
||||
if(Adapter->bMipsConfig == MIPS_200_MHZ)
|
||||
{
|
||||
uiClockSetting = 0x03F13652;
|
||||
|
@ -846,17 +846,17 @@ int ddr_init(MINI_ADAPTER *Adapter)
|
|||
case DDR_80_MHZ:
|
||||
psDDRSetting = asT3LPB_DDRSetting80MHz;
|
||||
RegCount=(sizeof(asT3B_DDRSetting80MHz)/
|
||||
sizeof(DDR_SETTING));
|
||||
sizeof(struct bcm_ddr_setting));
|
||||
break;
|
||||
case DDR_100_MHZ:
|
||||
psDDRSetting=asT3LPB_DDRSetting100MHz;
|
||||
RegCount=(sizeof(asT3B_DDRSetting100MHz)/
|
||||
sizeof(DDR_SETTING));
|
||||
sizeof(struct bcm_ddr_setting));
|
||||
break;
|
||||
case DDR_133_MHZ:
|
||||
psDDRSetting = asT3LPB_DDRSetting133MHz;
|
||||
RegCount=(sizeof(asT3B_DDRSetting133MHz)/
|
||||
sizeof(DDR_SETTING));
|
||||
sizeof(struct bcm_ddr_setting));
|
||||
|
||||
if(Adapter->bMipsConfig == MIPS_200_MHZ)
|
||||
{
|
||||
|
@ -870,7 +870,7 @@ int ddr_init(MINI_ADAPTER *Adapter)
|
|||
|
||||
case DDR_160_MHZ:
|
||||
psDDRSetting = asT3LPB_DDRSetting160MHz;
|
||||
RegCount = sizeof(asT3LPB_DDRSetting160MHz)/sizeof(DDR_SETTING);
|
||||
RegCount = sizeof(asT3LPB_DDRSetting160MHz)/sizeof(struct bcm_ddr_setting);
|
||||
|
||||
if(Adapter->bMipsConfig == MIPS_200_MHZ)
|
||||
{
|
||||
|
@ -894,17 +894,17 @@ int ddr_init(MINI_ADAPTER *Adapter)
|
|||
case DDR_80_MHZ:
|
||||
psDDRSetting = asT3_DDRSetting80MHz;
|
||||
RegCount = (sizeof(asT3_DDRSetting80MHz)/
|
||||
sizeof(DDR_SETTING));
|
||||
sizeof(struct bcm_ddr_setting));
|
||||
break;
|
||||
case DDR_100_MHZ:
|
||||
psDDRSetting = asT3_DDRSetting100MHz;
|
||||
RegCount = (sizeof(asT3_DDRSetting100MHz)/
|
||||
sizeof(DDR_SETTING));
|
||||
sizeof(struct bcm_ddr_setting));
|
||||
break;
|
||||
case DDR_133_MHZ:
|
||||
psDDRSetting = asT3_DDRSetting133MHz;
|
||||
RegCount = (sizeof(asT3_DDRSetting133MHz)/
|
||||
sizeof(DDR_SETTING));
|
||||
sizeof(struct bcm_ddr_setting));
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
|
@ -916,12 +916,12 @@ int ddr_init(MINI_ADAPTER *Adapter)
|
|||
case DDR_80_MHZ:
|
||||
psDDRSetting = asT3B_DDRSetting80MHz;
|
||||
RegCount=(sizeof(asT3B_DDRSetting80MHz)/
|
||||
sizeof(DDR_SETTING));
|
||||
sizeof(struct bcm_ddr_setting));
|
||||
break;
|
||||
case DDR_100_MHZ:
|
||||
psDDRSetting=asT3B_DDRSetting100MHz;
|
||||
RegCount=(sizeof(asT3B_DDRSetting100MHz)/
|
||||
sizeof(DDR_SETTING));
|
||||
sizeof(struct bcm_ddr_setting));
|
||||
break;
|
||||
case DDR_133_MHZ:
|
||||
|
||||
|
@ -931,13 +931,13 @@ int ddr_init(MINI_ADAPTER *Adapter)
|
|||
sizeof(asDPLL_266MHZ));
|
||||
psDDRSetting = asT3B_DDRSetting133MHz;
|
||||
RegCount=(sizeof(asT3B_DDRSetting133MHz)/
|
||||
sizeof(DDR_SETTING));
|
||||
sizeof(struct bcm_ddr_setting));
|
||||
}
|
||||
else
|
||||
{
|
||||
psDDRSetting = asT3B_DDRSetting133MHz;
|
||||
RegCount=(sizeof(asT3B_DDRSetting133MHz)/
|
||||
sizeof(DDR_SETTING));
|
||||
sizeof(struct bcm_ddr_setting));
|
||||
if(Adapter->bMipsConfig == MIPS_200_MHZ)
|
||||
{
|
||||
uiClockSetting = 0x07F13652;
|
||||
|
@ -1099,9 +1099,9 @@ int ddr_init(MINI_ADAPTER *Adapter)
|
|||
return retval;
|
||||
}
|
||||
|
||||
int download_ddr_settings(PMINI_ADAPTER Adapter)
|
||||
int download_ddr_settings(struct bcm_mini_adapter *Adapter)
|
||||
{
|
||||
PDDR_SET_NODE psDDRSetting=NULL;
|
||||
struct bcm_ddr_setting *psDDRSetting=NULL;
|
||||
ULONG RegCount=0;
|
||||
unsigned long ul_ddr_setting_load_addr = DDR_DUMP_INTERNAL_DEVICE_MEMORY;
|
||||
UINT value = 0;
|
||||
|
@ -1250,7 +1250,7 @@ int download_ddr_settings(PMINI_ADAPTER Adapter)
|
|||
}
|
||||
|
||||
ul_ddr_setting_load_addr+=sizeof(ULONG);
|
||||
RegCount*=(sizeof(DDR_SETTING)/sizeof(ULONG));
|
||||
RegCount*=(sizeof(struct bcm_ddr_setting)/sizeof(ULONG));
|
||||
|
||||
while(RegCount && !retval)
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
|
||||
|
||||
int ddr_init(PMINI_ADAPTER psAdapter);
|
||||
int download_ddr_settings(PMINI_ADAPTER psAdapter);
|
||||
int ddr_init(struct bcm_mini_adapter *psAdapter);
|
||||
int download_ddr_settings(struct bcm_mini_adapter *psAdapter);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -42,10 +42,6 @@
|
|||
#define ARP_REQ (TX<<5)
|
||||
#define ARP_RESP (TX<<6)
|
||||
|
||||
// dhcp.c
|
||||
//#define DHCP TX
|
||||
//#define DHCP_REQ (DHCP<<7)
|
||||
|
||||
// Leakybucket.c
|
||||
#define TOKEN_COUNTS (TX<<8)
|
||||
#define CHECK_TOKENS (TX<<9)
|
||||
|
@ -147,7 +143,6 @@ DriverEntry.c, bcmfwup.c, ChipDetectTask.c, HaltnReset.c, InterfaceDDR.c */
|
|||
|
||||
#define HOST_MIBS (OTHERS << 28)
|
||||
#define CONN_MSG (CMHOST << 29)
|
||||
//#define OTHERS_MISC (OTHERS << 29) // ProcSupport.c
|
||||
/*-----------------END SUBTYPEs------------------------------------------*/
|
||||
|
||||
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
* Enqueue the control packet for Application.
|
||||
* @return None
|
||||
*/
|
||||
static VOID handle_rx_control_packet(PMINI_ADAPTER Adapter, struct sk_buff *skb)
|
||||
static VOID handle_rx_control_packet(struct bcm_mini_adapter *Adapter, struct sk_buff *skb)
|
||||
{
|
||||
PPER_TARANG_DATA pTarang = NULL;
|
||||
struct bcm_tarang_data *pTarang = NULL;
|
||||
BOOLEAN HighPriorityMessage = FALSE;
|
||||
struct sk_buff *newPacket = NULL;
|
||||
CHAR cntrl_msg_mask_bit = 0;
|
||||
|
@ -154,7 +154,7 @@ static VOID handle_rx_control_packet(PMINI_ADAPTER Adapter, struct sk_buff *skb)
|
|||
* @ingroup ctrl_pkt_functions
|
||||
* Thread to handle control pkt reception
|
||||
*/
|
||||
int control_packet_handler(PMINI_ADAPTER Adapter /* pointer to adapter object*/)
|
||||
int control_packet_handler(struct bcm_mini_adapter *Adapter /* pointer to adapter object*/)
|
||||
{
|
||||
struct sk_buff *ctrl_packet = NULL;
|
||||
unsigned long flags = 0;
|
||||
|
@ -213,8 +213,8 @@ int control_packet_handler(PMINI_ADAPTER Adapter /* pointer to adapter object*/)
|
|||
|
||||
INT flushAllAppQ(void)
|
||||
{
|
||||
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
PPER_TARANG_DATA pTarang = NULL;
|
||||
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
struct bcm_tarang_data *pTarang = NULL;
|
||||
struct sk_buff *PacketToDrop = NULL;
|
||||
for (pTarang = Adapter->pTarangs; pTarang; pTarang = pTarang->next) {
|
||||
while (pTarang->RxAppControlHead != NULL) {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include "headers.h"
|
||||
|
||||
static BOOLEAN MatchSrcIpv6Address(S_CLASSIFIER_RULE *pstClassifierRule,
|
||||
static BOOLEAN MatchSrcIpv6Address(struct bcm_classifier_rule *pstClassifierRule,
|
||||
IPV6Header *pstIpv6Header);
|
||||
static BOOLEAN MatchDestIpv6Address(S_CLASSIFIER_RULE *pstClassifierRule,
|
||||
static BOOLEAN MatchDestIpv6Address(struct bcm_classifier_rule *pstClassifierRule,
|
||||
IPV6Header *pstIpv6Header);
|
||||
static VOID DumpIpv6Header(IPV6Header *pstIpv6Header);
|
||||
|
||||
|
@ -12,7 +12,7 @@ static UCHAR *GetNextIPV6ChainedHeader(UCHAR **ppucPayload,
|
|||
UCHAR *pucRetHeaderPtr = NULL;
|
||||
UCHAR *pucPayloadPtr = NULL;
|
||||
USHORT usNextHeaderOffset = 0 ;
|
||||
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
|
||||
if ((ppucPayload == NULL) || (*pusPayloadLength == 0) ||
|
||||
(*bParseDone)) {
|
||||
|
@ -147,7 +147,7 @@ static UCHAR GetIpv6ProtocolPorts(UCHAR *pucPayload, USHORT *pusSrcPort,
|
|||
BOOLEAN bDone = FALSE;
|
||||
UCHAR ucHeaderType = 0;
|
||||
UCHAR *pucNextHeader = NULL;
|
||||
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
|
||||
if (!pucPayload || (usPayloadLength == 0))
|
||||
return 0;
|
||||
|
@ -177,11 +177,11 @@ static UCHAR GetIpv6ProtocolPorts(UCHAR *pucPayload, USHORT *pusSrcPort,
|
|||
|
||||
|
||||
/*
|
||||
* Arg 1 PMINI_ADAPTER Adapter is a pointer ot the driver contorl structure
|
||||
* Arg 1 struct bcm_mini_adapter *Adapter is a pointer ot the driver contorl structure
|
||||
* Arg 2 PVOID pcIpHeader is a pointer to the IP header of the packet
|
||||
*/
|
||||
USHORT IpVersion6(PMINI_ADAPTER Adapter, PVOID pcIpHeader,
|
||||
S_CLASSIFIER_RULE *pstClassifierRule)
|
||||
USHORT IpVersion6(struct bcm_mini_adapter *Adapter, PVOID pcIpHeader,
|
||||
struct bcm_classifier_rule *pstClassifierRule)
|
||||
{
|
||||
USHORT ushDestPort = 0;
|
||||
USHORT ushSrcPort = 0;
|
||||
|
@ -288,14 +288,14 @@ USHORT IpVersion6(PMINI_ADAPTER Adapter, PVOID pcIpHeader,
|
|||
}
|
||||
|
||||
|
||||
static BOOLEAN MatchSrcIpv6Address(S_CLASSIFIER_RULE *pstClassifierRule,
|
||||
static BOOLEAN MatchSrcIpv6Address(struct bcm_classifier_rule *pstClassifierRule,
|
||||
IPV6Header *pstIpv6Header)
|
||||
{
|
||||
UINT uiLoopIndex = 0;
|
||||
UINT uiIpv6AddIndex = 0;
|
||||
UINT uiIpv6AddrNoLongWords = 4;
|
||||
ULONG aulSrcIP[4];
|
||||
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
/*
|
||||
* This is the no. of Src Addresses ie Range of IP Addresses contained
|
||||
* in the classifier rule for which we need to match
|
||||
|
@ -344,14 +344,14 @@ static BOOLEAN MatchSrcIpv6Address(S_CLASSIFIER_RULE *pstClassifierRule,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static BOOLEAN MatchDestIpv6Address(S_CLASSIFIER_RULE *pstClassifierRule,
|
||||
static BOOLEAN MatchDestIpv6Address(struct bcm_classifier_rule *pstClassifierRule,
|
||||
IPV6Header *pstIpv6Header)
|
||||
{
|
||||
UINT uiLoopIndex = 0;
|
||||
UINT uiIpv6AddIndex = 0;
|
||||
UINT uiIpv6AddrNoLongWords = 4;
|
||||
ULONG aulDestIP[4];
|
||||
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
/*
|
||||
* This is the no. of Destination Addresses
|
||||
* ie Range of IP Addresses contained in the classifier rule
|
||||
|
@ -406,7 +406,7 @@ VOID DumpIpv6Address(ULONG *puIpv6Address)
|
|||
{
|
||||
UINT uiIpv6AddrNoLongWords = 4;
|
||||
UINT uiIpv6AddIndex = 0;
|
||||
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
for (uiIpv6AddIndex = 0; uiIpv6AddIndex < uiIpv6AddrNoLongWords; uiIpv6AddIndex++) {
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL,
|
||||
":%lx", puIpv6Address[uiIpv6AddIndex]);
|
||||
|
@ -418,7 +418,7 @@ static VOID DumpIpv6Header(IPV6Header *pstIpv6Header)
|
|||
{
|
||||
UCHAR ucVersion;
|
||||
UCHAR ucPrio;
|
||||
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL,
|
||||
"----Ipv6 Header---");
|
||||
ucVersion = pstIpv6Header->ucVersionPrio & 0xf0;
|
||||
|
|
|
@ -102,15 +102,15 @@ typedef enum _E_IPADDR_CONTEXT
|
|||
|
||||
//Function Prototypes
|
||||
|
||||
USHORT IpVersion6(PMINI_ADAPTER Adapter, /**< Pointer to the driver control structure */
|
||||
USHORT IpVersion6(struct bcm_mini_adapter *Adapter, /**< Pointer to the driver control structure */
|
||||
PVOID pcIpHeader, /**<Pointer to the IP Hdr of the packet*/
|
||||
S_CLASSIFIER_RULE *pstClassifierRule );
|
||||
struct bcm_classifier_rule *pstClassifierRule );
|
||||
|
||||
VOID DumpIpv6Address(ULONG *puIpv6Address);
|
||||
|
||||
extern BOOLEAN MatchSrcPort(S_CLASSIFIER_RULE *pstClassifierRule,USHORT ushSrcPort);
|
||||
extern BOOLEAN MatchDestPort(S_CLASSIFIER_RULE *pstClassifierRule,USHORT ushSrcPort);
|
||||
extern BOOLEAN MatchProtocol(S_CLASSIFIER_RULE *pstClassifierRule,UCHAR ucProtocol);
|
||||
extern BOOLEAN MatchSrcPort(struct bcm_classifier_rule *pstClassifierRule,USHORT ushSrcPort);
|
||||
extern BOOLEAN MatchDestPort(struct bcm_classifier_rule *pstClassifierRule,USHORT ushSrcPort);
|
||||
extern BOOLEAN MatchProtocol(struct bcm_classifier_rule *pstClassifierRule,UCHAR ucProtocol);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -85,7 +85,7 @@ typedef struct _S_INTERFACE_ADAPTER
|
|||
atomic_t uNumRcbUsed;
|
||||
atomic_t uCurrRcb;
|
||||
|
||||
PMINI_ADAPTER psAdapter;
|
||||
struct bcm_mini_adapter *psAdapter;
|
||||
BOOLEAN bFlashBoot;
|
||||
BOOLEAN bHighSpeedDevice ;
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ int InterfaceFileDownload(PVOID arg, struct file *flp, unsigned int on_chip_loc)
|
|||
int errno = 0, len = 0; /* ,is_config_file = 0 */
|
||||
loff_t pos = 0;
|
||||
PS_INTERFACE_ADAPTER psIntfAdapter = (PS_INTERFACE_ADAPTER)arg;
|
||||
/* PMINI_ADAPTER Adapter = psIntfAdapter->psAdapter; */
|
||||
/* struct bcm_mini_adapter *Adapter = psIntfAdapter->psAdapter; */
|
||||
char *buff = kmalloc(MAX_TRANSFER_CTRL_BYTE_USB, GFP_KERNEL);
|
||||
|
||||
if (!buff)
|
||||
|
@ -132,7 +132,7 @@ int InterfaceFileReadbackFromChip(PVOID arg, struct file *flp, unsigned int on_c
|
|||
return Status;
|
||||
}
|
||||
|
||||
static int bcm_download_config_file(PMINI_ADAPTER Adapter, FIRMWARE_INFO *psFwInfo)
|
||||
static int bcm_download_config_file(struct bcm_mini_adapter *Adapter, struct bcm_firmware_info *psFwInfo)
|
||||
{
|
||||
int retval = STATUS_SUCCESS;
|
||||
B_UINT32 value = 0;
|
||||
|
@ -208,7 +208,7 @@ static int bcm_download_config_file(PMINI_ADAPTER Adapter, FIRMWARE_INFO *psFwIn
|
|||
static int bcm_compare_buff_contents(unsigned char *readbackbuff, unsigned char *buff, unsigned int len)
|
||||
{
|
||||
int retval = STATUS_SUCCESS;
|
||||
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
if ((len-sizeof(unsigned int)) < 4) {
|
||||
if (memcmp(readbackbuff , buff, len))
|
||||
retval = -EINVAL;
|
||||
|
@ -229,7 +229,7 @@ static int bcm_compare_buff_contents(unsigned char *readbackbuff, unsigned char
|
|||
return retval;
|
||||
}
|
||||
|
||||
int bcm_ioctl_fw_download(PMINI_ADAPTER Adapter, FIRMWARE_INFO *psFwInfo)
|
||||
int bcm_ioctl_fw_download(struct bcm_mini_adapter *Adapter, struct bcm_firmware_info *psFwInfo)
|
||||
{
|
||||
int retval = STATUS_SUCCESS;
|
||||
PUCHAR buff = NULL;
|
||||
|
@ -278,7 +278,7 @@ int bcm_ioctl_fw_download(PMINI_ADAPTER Adapter, FIRMWARE_INFO *psFwInfo)
|
|||
return retval;
|
||||
}
|
||||
|
||||
static INT buffDnld(PMINI_ADAPTER Adapter, PUCHAR mappedbuffer, UINT u32FirmwareLength, ULONG u32StartingAddress)
|
||||
static INT buffDnld(struct bcm_mini_adapter *Adapter, PUCHAR mappedbuffer, UINT u32FirmwareLength, ULONG u32StartingAddress)
|
||||
{
|
||||
unsigned int len = 0;
|
||||
int retval = STATUS_SUCCESS;
|
||||
|
@ -299,7 +299,7 @@ static INT buffDnld(PMINI_ADAPTER Adapter, PUCHAR mappedbuffer, UINT u32Firmware
|
|||
return retval;
|
||||
}
|
||||
|
||||
static INT buffRdbkVerify(PMINI_ADAPTER Adapter, PUCHAR mappedbuffer, UINT u32FirmwareLength, ULONG u32StartingAddress)
|
||||
static INT buffRdbkVerify(struct bcm_mini_adapter *Adapter, PUCHAR mappedbuffer, UINT u32FirmwareLength, ULONG u32StartingAddress)
|
||||
{
|
||||
UINT len = u32FirmwareLength;
|
||||
INT retval = STATUS_SUCCESS;
|
||||
|
@ -334,7 +334,7 @@ static INT buffRdbkVerify(PMINI_ADAPTER Adapter, PUCHAR mappedbuffer, UINT u32Fi
|
|||
return retval;
|
||||
}
|
||||
|
||||
INT buffDnldVerify(PMINI_ADAPTER Adapter, unsigned char *mappedbuffer, unsigned int u32FirmwareLength, unsigned long u32StartingAddress)
|
||||
INT buffDnldVerify(struct bcm_mini_adapter *Adapter, unsigned char *mappedbuffer, unsigned int u32FirmwareLength, unsigned long u32StartingAddress)
|
||||
{
|
||||
INT status = STATUS_SUCCESS;
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ Description: This is the hardware specific Function for waking up HW device fr
|
|||
A software abort pattern is written to the device to wake it and necessary power state
|
||||
transitions from host are performed here.
|
||||
|
||||
Input parameters: IN PMINI_ADAPTER Adapter - Miniport Adapter Context
|
||||
Input parameters: IN struct bcm_mini_adapter *Adapter - Miniport Adapter Context
|
||||
|
||||
|
||||
Return: BCM_STATUS_SUCCESS - If Wakeup of the HW Interface was successful.
|
||||
|
@ -22,7 +22,7 @@ Description: This is the hardware specific Function for responding to Idle mod
|
|||
Necessary power state transitions from host for idle mode or other device specific
|
||||
initializations are performed here.
|
||||
|
||||
Input parameters: IN PMINI_ADAPTER Adapter - Miniport Adapter Context
|
||||
Input parameters: IN struct bcm_mini_adapter * Adapter - Miniport Adapter Context
|
||||
|
||||
|
||||
Return: BCM_STATUS_SUCCESS - If Idle mode response related HW configuration was successful.
|
||||
|
@ -42,7 +42,7 @@ send to f/w with in 200 ms after the Idle/Shutdown req issued
|
|||
*/
|
||||
|
||||
|
||||
int InterfaceIdleModeRespond(PMINI_ADAPTER Adapter, unsigned int* puiBuffer)
|
||||
int InterfaceIdleModeRespond(struct bcm_mini_adapter *Adapter, unsigned int* puiBuffer)
|
||||
{
|
||||
int status = STATUS_SUCCESS;
|
||||
unsigned int uiRegRead = 0;
|
||||
|
@ -147,7 +147,7 @@ int InterfaceIdleModeRespond(PMINI_ADAPTER Adapter, unsigned int* puiBuffer)
|
|||
return status;
|
||||
}
|
||||
|
||||
static int InterfaceAbortIdlemode(PMINI_ADAPTER Adapter, unsigned int Pattern)
|
||||
static int InterfaceAbortIdlemode(struct bcm_mini_adapter *Adapter, unsigned int Pattern)
|
||||
{
|
||||
int status = STATUS_SUCCESS;
|
||||
unsigned int value;
|
||||
|
@ -246,7 +246,7 @@ static int InterfaceAbortIdlemode(PMINI_ADAPTER Adapter, unsigned int Pattern)
|
|||
}
|
||||
return status;
|
||||
}
|
||||
int InterfaceIdleModeWakeup(PMINI_ADAPTER Adapter)
|
||||
int InterfaceIdleModeWakeup(struct bcm_mini_adapter *Adapter)
|
||||
{
|
||||
ULONG Status = 0;
|
||||
if(Adapter->bTriedToWakeUpFromlowPowerMode)
|
||||
|
@ -263,7 +263,7 @@ int InterfaceIdleModeWakeup(PMINI_ADAPTER Adapter)
|
|||
return Status;
|
||||
}
|
||||
|
||||
void InterfaceHandleShutdownModeWakeup(PMINI_ADAPTER Adapter)
|
||||
void InterfaceHandleShutdownModeWakeup(struct bcm_mini_adapter *Adapter)
|
||||
{
|
||||
unsigned int uiRegVal = 0;
|
||||
INT Status = 0;
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
#ifndef _INTERFACE_IDLEMODE_H
|
||||
#define _INTERFACE_IDLEMODE_H
|
||||
|
||||
INT InterfaceIdleModeWakeup(PMINI_ADAPTER Adapter);
|
||||
INT InterfaceIdleModeWakeup(struct bcm_mini_adapter *Adapter);
|
||||
|
||||
INT InterfaceIdleModeRespond(PMINI_ADAPTER Adapter, unsigned int *puiBuffer);
|
||||
INT InterfaceIdleModeRespond(struct bcm_mini_adapter *Adapter, unsigned int *puiBuffer);
|
||||
|
||||
VOID InterfaceWriteIdleModeWakePattern(PMINI_ADAPTER Adapter);
|
||||
VOID InterfaceWriteIdleModeWakePattern(struct bcm_mini_adapter *Adapter);
|
||||
|
||||
INT InterfaceWakeUp(PMINI_ADAPTER Adapter);
|
||||
INT InterfaceWakeUp(struct bcm_mini_adapter * Adapter);
|
||||
|
||||
VOID InterfaceHandleShutdownModeWakeup(PMINI_ADAPTER Adapter);
|
||||
VOID InterfaceHandleShutdownModeWakeup(struct bcm_mini_adapter *Adapter);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ static void InterfaceAdapterFree(PS_INTERFACE_ADAPTER psIntfAdapter)
|
|||
AdapterFree(psIntfAdapter->psAdapter);
|
||||
}
|
||||
|
||||
static void ConfigureEndPointTypesThroughEEPROM(PMINI_ADAPTER Adapter)
|
||||
static void ConfigureEndPointTypesThroughEEPROM(struct bcm_mini_adapter *Adapter)
|
||||
{
|
||||
unsigned long ulReg = 0;
|
||||
int bytes;
|
||||
|
@ -143,12 +143,12 @@ static int usbbcm_device_probe(struct usb_interface *intf, const struct usb_devi
|
|||
{
|
||||
struct usb_device *udev = interface_to_usbdev(intf);
|
||||
int retval;
|
||||
PMINI_ADAPTER psAdapter;
|
||||
struct bcm_mini_adapter *psAdapter;
|
||||
PS_INTERFACE_ADAPTER psIntfAdapter;
|
||||
struct net_device *ndev;
|
||||
|
||||
/* Reserve one extra queue for the bit-bucket */
|
||||
ndev = alloc_etherdev_mq(sizeof(MINI_ADAPTER), NO_OF_QUEUES+1);
|
||||
ndev = alloc_etherdev_mq(sizeof(struct bcm_mini_adapter), NO_OF_QUEUES+1);
|
||||
if (ndev == NULL) {
|
||||
dev_err(&udev->dev, DRV_NAME ": no memory for device\n");
|
||||
return -ENOMEM;
|
||||
|
@ -257,7 +257,7 @@ static int usbbcm_device_probe(struct usb_interface *intf, const struct usb_devi
|
|||
static void usbbcm_disconnect(struct usb_interface *intf)
|
||||
{
|
||||
PS_INTERFACE_ADAPTER psIntfAdapter = usb_get_intfdata(intf);
|
||||
PMINI_ADAPTER psAdapter;
|
||||
struct bcm_mini_adapter *psAdapter;
|
||||
struct usb_device *udev = interface_to_usbdev(intf);
|
||||
|
||||
if (psIntfAdapter == NULL)
|
||||
|
|
|
@ -5,7 +5,7 @@ static void read_int_callback(struct urb *urb/*, struct pt_regs *regs*/)
|
|||
{
|
||||
int status = urb->status;
|
||||
PS_INTERFACE_ADAPTER psIntfAdapter = (PS_INTERFACE_ADAPTER)urb->context;
|
||||
PMINI_ADAPTER Adapter = psIntfAdapter->psAdapter ;
|
||||
struct bcm_mini_adapter *Adapter = psIntfAdapter->psAdapter ;
|
||||
|
||||
if (netif_msg_intr(Adapter))
|
||||
pr_info(PFX "%s: interrupt status %d\n",
|
||||
|
|
|
@ -7,9 +7,9 @@ int CreateInterruptUrb(PS_INTERFACE_ADAPTER psIntfAdapter);
|
|||
INT StartInterruptUrb(PS_INTERFACE_ADAPTER psIntfAdapter);
|
||||
|
||||
|
||||
VOID InterfaceEnableInterrupt(PMINI_ADAPTER Adapter);
|
||||
VOID InterfaceEnableInterrupt(struct bcm_mini_adapter *Adapter);
|
||||
|
||||
VOID InterfaceDisableInterrupt(PMINI_ADAPTER Adapter);
|
||||
VOID InterfaceDisableInterrupt(struct bcm_mini_adapter *Adapter);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ INT BcmWRM(PVOID arg,
|
|||
return InterfaceWRM((PS_INTERFACE_ADAPTER)arg, addr, buff, len);
|
||||
}
|
||||
|
||||
INT Bcm_clear_halt_of_endpoints(PMINI_ADAPTER Adapter)
|
||||
INT Bcm_clear_halt_of_endpoints(struct bcm_mini_adapter *Adapter)
|
||||
{
|
||||
PS_INTERFACE_ADAPTER psIntfAdapter = (PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter);
|
||||
INT status = STATUS_SUCCESS;
|
||||
|
|
|
@ -33,7 +33,7 @@ int BcmWRM(PVOID arg,
|
|||
PVOID buff,
|
||||
INT len);
|
||||
|
||||
INT Bcm_clear_halt_of_endpoints(PMINI_ADAPTER Adapter);
|
||||
INT Bcm_clear_halt_of_endpoints(struct bcm_mini_adapter *Adapter);
|
||||
|
||||
VOID Bcm_kill_all_URBs(PS_INTERFACE_ADAPTER psIntfAdapter);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "headers.h"
|
||||
|
||||
static int SearchVcid(PMINI_ADAPTER Adapter,unsigned short usVcid)
|
||||
static int SearchVcid(struct bcm_mini_adapter *Adapter,unsigned short usVcid)
|
||||
{
|
||||
int iIndex=0;
|
||||
|
||||
|
@ -45,8 +45,8 @@ static void read_bulk_callback(struct urb *urb)
|
|||
//int idleflag = 0 ;
|
||||
PUSB_RCB pRcb = (PUSB_RCB)urb->context;
|
||||
PS_INTERFACE_ADAPTER psIntfAdapter = pRcb->psIntfAdapter;
|
||||
PMINI_ADAPTER Adapter = psIntfAdapter->psAdapter;
|
||||
PLEADER pLeader = urb->transfer_buffer;
|
||||
struct bcm_mini_adapter *Adapter = psIntfAdapter->psAdapter;
|
||||
struct bcm_leader *pLeader = urb->transfer_buffer;
|
||||
|
||||
if (unlikely(netif_msg_rx_status(Adapter)))
|
||||
pr_info(PFX "%s: rx urb status %d length %d\n",
|
||||
|
@ -126,7 +126,7 @@ static void read_bulk_callback(struct urb *urb)
|
|||
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_RX, RX_CTRL, DBG_LVL_ALL, "Received control pkt...");
|
||||
*(PUSHORT)skb->data = pLeader->Status;
|
||||
memcpy(skb->data+sizeof(USHORT), urb->transfer_buffer +
|
||||
(sizeof(LEADER)), pLeader->PLength);
|
||||
(sizeof(struct bcm_leader)), pLeader->PLength);
|
||||
skb->len = pLeader->PLength + sizeof(USHORT);
|
||||
|
||||
spin_lock(&Adapter->control_queue_lock);
|
||||
|
@ -144,7 +144,7 @@ static void read_bulk_callback(struct urb *urb)
|
|||
*/
|
||||
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_RX, RX_DATA, DBG_LVL_ALL, "Received Data pkt...");
|
||||
skb_reserve(skb, 2 + SKB_RESERVE_PHS_BYTES);
|
||||
memcpy(skb->data+ETH_HLEN, (PUCHAR)urb->transfer_buffer + sizeof(LEADER), pLeader->PLength);
|
||||
memcpy(skb->data+ETH_HLEN, (PUCHAR)urb->transfer_buffer + sizeof(struct bcm_leader), pLeader->PLength);
|
||||
skb->dev = Adapter->dev;
|
||||
|
||||
/* currently skb->len has extra ETH_HLEN bytes in the beginning */
|
||||
|
@ -232,7 +232,7 @@ Function: InterfaceRx
|
|||
Description: This is the hardware specific Function for Receiving
|
||||
data packet/control packets from the device.
|
||||
|
||||
Input parameters: IN PMINI_ADAPTER Adapter - Miniport Adapter Context
|
||||
Input parameters: IN struct bcm_mini_adapter *Adapter - Miniport Adapter Context
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -5,10 +5,10 @@ static void write_bulk_callback(struct urb *urb/*, struct pt_regs *regs*/)
|
|||
{
|
||||
PUSB_TCB pTcb= (PUSB_TCB)urb->context;
|
||||
PS_INTERFACE_ADAPTER psIntfAdapter = pTcb->psIntfAdapter;
|
||||
CONTROL_MESSAGE *pControlMsg = (CONTROL_MESSAGE *)urb->transfer_buffer;
|
||||
PMINI_ADAPTER psAdapter = psIntfAdapter->psAdapter ;
|
||||
struct bcm_link_request *pControlMsg = (struct bcm_link_request *)urb->transfer_buffer;
|
||||
struct bcm_mini_adapter *psAdapter = psIntfAdapter->psAdapter ;
|
||||
BOOLEAN bpowerDownMsg = FALSE ;
|
||||
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
|
||||
if (unlikely(netif_msg_tx_done(Adapter)))
|
||||
pr_info(PFX "%s: transmit status %d\n", Adapter->dev->name, urb->status);
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* Returns - None
|
||||
**********************************************************************/
|
||||
|
||||
static VOID UpdateTokenCount(register PMINI_ADAPTER Adapter)
|
||||
static VOID UpdateTokenCount(register struct bcm_mini_adapter *Adapter)
|
||||
{
|
||||
ULONG liCurrentTime;
|
||||
INT i = 0;
|
||||
|
@ -75,7 +75,7 @@ static VOID UpdateTokenCount(register PMINI_ADAPTER Adapter)
|
|||
* Returns - The number of bytes allowed for transmission.
|
||||
*
|
||||
***********************************************************************/
|
||||
static ULONG GetSFTokenCount(PMINI_ADAPTER Adapter, PacketInfo *psSF)
|
||||
static ULONG GetSFTokenCount(struct bcm_mini_adapter *Adapter, struct bcm_packet_info *psSF)
|
||||
{
|
||||
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "IsPacketAllowedForFlow ===>");
|
||||
/* Validate the parameters */
|
||||
|
@ -112,8 +112,8 @@ static ULONG GetSFTokenCount(PMINI_ADAPTER Adapter, PacketInfo *psSF)
|
|||
This function despatches packet from the specified queue.
|
||||
@return Zero(success) or Negative value(failure)
|
||||
*/
|
||||
static INT SendPacketFromQueue(PMINI_ADAPTER Adapter,/**<Logical Adapter*/
|
||||
PacketInfo *psSF, /**<Queue identifier*/
|
||||
static INT SendPacketFromQueue(struct bcm_mini_adapter *Adapter,/**<Logical Adapter*/
|
||||
struct bcm_packet_info *psSF, /**<Queue identifier*/
|
||||
struct sk_buff* Packet) /**<Pointer to the packet to be sent*/
|
||||
{
|
||||
INT Status=STATUS_FAILURE;
|
||||
|
@ -156,7 +156,7 @@ static INT SendPacketFromQueue(PMINI_ADAPTER Adapter,/**<Logical Adapter*/
|
|||
* Returns - None.
|
||||
*
|
||||
****************************************************************************/
|
||||
static VOID CheckAndSendPacketFromIndex(PMINI_ADAPTER Adapter, PacketInfo *psSF)
|
||||
static VOID CheckAndSendPacketFromIndex(struct bcm_mini_adapter *Adapter, struct bcm_packet_info *psSF)
|
||||
{
|
||||
struct sk_buff *QueuePacket=NULL;
|
||||
char *pControlPacket = NULL;
|
||||
|
@ -243,10 +243,10 @@ static VOID CheckAndSendPacketFromIndex(PMINI_ADAPTER Adapter, PacketInfo *psSF)
|
|||
{
|
||||
spin_lock_bh(&psSF->SFQueueLock);
|
||||
psSF->NumOfPacketsSent++;
|
||||
psSF->uiSentBytes+=((PLEADER)pControlPacket)->PLength;
|
||||
psSF->uiSentBytes+=((struct bcm_leader *)pControlPacket)->PLength;
|
||||
psSF->uiSentPackets++;
|
||||
atomic_dec(&Adapter->TotalPacketCount);
|
||||
psSF->uiCurrentBytesOnHost -= ((PLEADER)pControlPacket)->PLength;
|
||||
psSF->uiCurrentBytesOnHost -= ((struct bcm_leader *)pControlPacket)->PLength;
|
||||
psSF->uiCurrentPacketsOnHost--;
|
||||
atomic_inc(&Adapter->index_rd_txcntrlpkt);
|
||||
spin_unlock_bh(&psSF->SFQueueLock);
|
||||
|
@ -273,7 +273,7 @@ static VOID CheckAndSendPacketFromIndex(PMINI_ADAPTER Adapter, PacketInfo *psSF)
|
|||
*
|
||||
* Returns - None.
|
||||
********************************************************************/
|
||||
VOID transmit_packets(PMINI_ADAPTER Adapter)
|
||||
VOID transmit_packets(struct bcm_mini_adapter *Adapter)
|
||||
{
|
||||
UINT uiPrevTotalCount = 0;
|
||||
int iIndex = 0;
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
#define TX_TIMER_PERIOD 10 /*10 msec*/
|
||||
#define MAX_CLASSIFIERS 100
|
||||
/* #define MAX_CLASSIFIERS_PER_SF 20 */
|
||||
#define MAX_TARGET_DSX_BUFFERS 24
|
||||
|
||||
#define MAX_CNTRL_PKTS 100
|
||||
|
@ -108,11 +107,11 @@
|
|||
/*Leader related terms */
|
||||
#define LEADER_STATUS 0x00
|
||||
#define LEADER_STATUS_TCP_ACK 0x1
|
||||
#define LEADER_SIZE sizeof(LEADER)
|
||||
#define MAC_ADDR_REQ_SIZE sizeof(PACKETTOSEND)
|
||||
#define SS_INFO_REQ_SIZE sizeof(PACKETTOSEND)
|
||||
#define LEADER_SIZE sizeof(struct bcm_leader)
|
||||
#define MAC_ADDR_REQ_SIZE sizeof(struct bcm_packettosend)
|
||||
#define SS_INFO_REQ_SIZE sizeof(struct bcm_packettosend)
|
||||
#define CM_REQUEST_SIZE (LEADER_SIZE + sizeof(stLocalSFChangeRequest))
|
||||
#define IDLE_REQ_SIZE sizeof(PACKETTOSEND)
|
||||
#define IDLE_REQ_SIZE sizeof(struct bcm_packettosend)
|
||||
|
||||
|
||||
#define MAX_TRANSFER_CTRL_BYTE_USB (2*1024)
|
||||
|
@ -252,11 +251,7 @@ typedef enum _E_PHS_DSC_ACTION {
|
|||
#define IDLE_MODE_WAKEUP_NOTIFIER_ADDRESS 0x1FC02FA8
|
||||
#define IDLE_MODE_MAX_RETRY_COUNT 1000
|
||||
|
||||
#ifdef REL_4_1
|
||||
#define CONFIG_BEGIN_ADDR 0xBF60B004
|
||||
#else
|
||||
#define CONFIG_BEGIN_ADDR 0xBF60B000
|
||||
#endif
|
||||
|
||||
#define FIRMWARE_BEGIN_ADDR 0xBFC00000
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#include "headers.h"
|
||||
|
||||
static int BcmFileDownload(PMINI_ADAPTER Adapter, const char *path, unsigned int loc);
|
||||
static VOID doPowerAutoCorrection(PMINI_ADAPTER psAdapter);
|
||||
static void HandleShutDownModeRequest(PMINI_ADAPTER Adapter, PUCHAR pucBuffer);
|
||||
static int bcm_parse_target_params(PMINI_ADAPTER Adapter);
|
||||
static void beceem_protocol_reset(PMINI_ADAPTER Adapter);
|
||||
static int BcmFileDownload(struct bcm_mini_adapter *Adapter, const char *path, unsigned int loc);
|
||||
static VOID doPowerAutoCorrection(struct bcm_mini_adapter *psAdapter);
|
||||
static void HandleShutDownModeRequest(struct bcm_mini_adapter *Adapter, PUCHAR pucBuffer);
|
||||
static int bcm_parse_target_params(struct bcm_mini_adapter *Adapter);
|
||||
static void beceem_protocol_reset(struct bcm_mini_adapter *Adapter);
|
||||
|
||||
static VOID default_wimax_protocol_initialize(PMINI_ADAPTER Adapter)
|
||||
static VOID default_wimax_protocol_initialize(struct bcm_mini_adapter *Adapter)
|
||||
{
|
||||
UINT uiLoopIndex;
|
||||
|
||||
|
@ -24,7 +24,7 @@ static VOID default_wimax_protocol_initialize(PMINI_ADAPTER Adapter)
|
|||
return;
|
||||
}
|
||||
|
||||
INT InitAdapter(PMINI_ADAPTER psAdapter)
|
||||
INT InitAdapter(struct bcm_mini_adapter *psAdapter)
|
||||
{
|
||||
int i = 0;
|
||||
INT Status = STATUS_SUCCESS;
|
||||
|
@ -93,7 +93,7 @@ INT InitAdapter(PMINI_ADAPTER psAdapter)
|
|||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
VOID AdapterFree(PMINI_ADAPTER Adapter)
|
||||
VOID AdapterFree(struct bcm_mini_adapter *Adapter)
|
||||
{
|
||||
int count;
|
||||
beceem_protocol_reset(Adapter);
|
||||
|
@ -134,7 +134,7 @@ VOID AdapterFree(PMINI_ADAPTER Adapter)
|
|||
free_netdev(Adapter->dev);
|
||||
}
|
||||
|
||||
static int create_worker_threads(PMINI_ADAPTER psAdapter)
|
||||
static int create_worker_threads(struct bcm_mini_adapter *psAdapter)
|
||||
{
|
||||
/* Rx Control Packets Processing */
|
||||
psAdapter->control_packet_handler = kthread_run((int (*)(void *))
|
||||
|
@ -155,7 +155,7 @@ static int create_worker_threads(PMINI_ADAPTER psAdapter)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static struct file *open_firmware_file(PMINI_ADAPTER Adapter, const char *path)
|
||||
static struct file *open_firmware_file(struct bcm_mini_adapter *Adapter, const char *path)
|
||||
{
|
||||
struct file *flp = NULL;
|
||||
mm_segment_t oldfs;
|
||||
|
@ -179,7 +179,7 @@ static struct file *open_firmware_file(PMINI_ADAPTER Adapter, const char *path)
|
|||
* Path to image file
|
||||
* Download Address on the chip
|
||||
*/
|
||||
static int BcmFileDownload(PMINI_ADAPTER Adapter, const char *path, unsigned int loc)
|
||||
static int BcmFileDownload(struct bcm_mini_adapter *Adapter, const char *path, unsigned int loc)
|
||||
{
|
||||
int errorno = 0;
|
||||
struct file *flp = NULL;
|
||||
|
@ -231,13 +231,13 @@ static int BcmFileDownload(PMINI_ADAPTER Adapter, const char *path, unsigned int
|
|||
* Logical Adapter
|
||||
* Control Packet Buffer
|
||||
*/
|
||||
INT CopyBufferToControlPacket(PMINI_ADAPTER Adapter, PVOID ioBuffer)
|
||||
INT CopyBufferToControlPacket(struct bcm_mini_adapter *Adapter, PVOID ioBuffer)
|
||||
{
|
||||
PLEADER pLeader = NULL;
|
||||
struct bcm_leader *pLeader = NULL;
|
||||
INT Status = 0;
|
||||
unsigned char *ctrl_buff = NULL;
|
||||
UINT pktlen = 0;
|
||||
PLINK_REQUEST pLinkReq = NULL;
|
||||
struct bcm_link_request *pLinkReq = NULL;
|
||||
PUCHAR pucAddIndication = NULL;
|
||||
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "======>");
|
||||
|
@ -246,8 +246,8 @@ INT CopyBufferToControlPacket(PMINI_ADAPTER Adapter, PVOID ioBuffer)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
pLinkReq = (PLINK_REQUEST)ioBuffer;
|
||||
pLeader = (PLEADER)ioBuffer; /* ioBuffer Contains sw_Status and Payload */
|
||||
pLinkReq = (struct bcm_link_request *)ioBuffer;
|
||||
pLeader = (struct bcm_leader *)ioBuffer; /* ioBuffer Contains sw_Status and Payload */
|
||||
|
||||
if (Adapter->bShutStatus == TRUE &&
|
||||
pLinkReq->szData[0] == LINK_DOWN_REQ_PAYLOAD &&
|
||||
|
@ -373,7 +373,7 @@ INT CopyBufferToControlPacket(PMINI_ADAPTER Adapter, PVOID ioBuffer)
|
|||
|
||||
memset(ctrl_buff, 0, pktlen+LEADER_SIZE);
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Copying the Control Packet Buffer with length=%d\n", pLeader->PLength);
|
||||
*(PLEADER)ctrl_buff = *pLeader;
|
||||
*(struct bcm_leader *)ctrl_buff = *pLeader;
|
||||
memcpy(ctrl_buff + LEADER_SIZE, ((PUCHAR)ioBuffer + LEADER_SIZE), pLeader->PLength);
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Enqueuing the Control Packet");
|
||||
|
||||
|
@ -402,30 +402,6 @@ INT CopyBufferToControlPacket(PMINI_ADAPTER Adapter, PVOID ioBuffer)
|
|||
return Status;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/*****************************************************************
|
||||
* Function - SendStatisticsPointerRequest()
|
||||
*
|
||||
* Description - This function builds and forwards the Statistics
|
||||
* Pointer Request control Packet.
|
||||
*
|
||||
* Parameters - Adapter : Pointer to Adapter structure.
|
||||
* - pstStatisticsPtrRequest : Pointer to link request.
|
||||
*
|
||||
* Returns - None.
|
||||
*****************************************************************/
|
||||
static VOID SendStatisticsPointerRequest(PMINI_ADAPTER Adapter, PLINK_REQUEST pstStatisticsPtrRequest)
|
||||
{
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "======>");
|
||||
pstStatisticsPtrRequest->Leader.Status = STATS_POINTER_REQ_STATUS;
|
||||
pstStatisticsPtrRequest->Leader.PLength = sizeof(ULONG); /* minimum 4 bytes */
|
||||
pstStatisticsPtrRequest->szData[0] = STATISTICS_POINTER_REQ;
|
||||
CopyBufferToControlPacket(Adapter, pstStatisticsPtrRequest);
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "<=====");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
/******************************************************************
|
||||
* Function - LinkMessage()
|
||||
*
|
||||
|
@ -436,12 +412,12 @@ static VOID SendStatisticsPointerRequest(PMINI_ADAPTER Adapter, PLINK_REQUEST ps
|
|||
*
|
||||
* Returns - None.
|
||||
*******************************************************************/
|
||||
VOID LinkMessage(PMINI_ADAPTER Adapter)
|
||||
VOID LinkMessage(struct bcm_mini_adapter *Adapter)
|
||||
{
|
||||
PLINK_REQUEST pstLinkRequest = NULL;
|
||||
struct bcm_link_request *pstLinkRequest = NULL;
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "=====>");
|
||||
if (Adapter->LinkStatus == SYNC_UP_REQUEST && Adapter->AutoSyncup) {
|
||||
pstLinkRequest = kzalloc(sizeof(LINK_REQUEST), GFP_ATOMIC);
|
||||
pstLinkRequest = kzalloc(sizeof(struct bcm_link_request), GFP_ATOMIC);
|
||||
if (!pstLinkRequest) {
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Can not allocate memory for Link request!");
|
||||
return;
|
||||
|
@ -456,7 +432,7 @@ VOID LinkMessage(PMINI_ADAPTER Adapter)
|
|||
Adapter->bSyncUpRequestSent = TRUE;
|
||||
|
||||
} else if (Adapter->LinkStatus == PHY_SYNC_ACHIVED && Adapter->AutoLinkUp) {
|
||||
pstLinkRequest = kzalloc(sizeof(LINK_REQUEST), GFP_ATOMIC);
|
||||
pstLinkRequest = kzalloc(sizeof(struct bcm_link_request), GFP_ATOMIC);
|
||||
if (!pstLinkRequest) {
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Can not allocate memory for Link request!");
|
||||
return;
|
||||
|
@ -487,7 +463,7 @@ VOID LinkMessage(PMINI_ADAPTER Adapter)
|
|||
*
|
||||
* Returns - None.
|
||||
************************************************************************/
|
||||
VOID StatisticsResponse(PMINI_ADAPTER Adapter, PVOID pvBuffer)
|
||||
VOID StatisticsResponse(struct bcm_mini_adapter *Adapter, PVOID pvBuffer)
|
||||
{
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "%s====>", __func__);
|
||||
Adapter->StatisticsPointer = ntohl(*(__be32 *)pvBuffer);
|
||||
|
@ -506,7 +482,7 @@ VOID StatisticsResponse(PMINI_ADAPTER Adapter, PVOID pvBuffer)
|
|||
*
|
||||
* Returns - None.
|
||||
***********************************************************************/
|
||||
VOID LinkControlResponseMessage(PMINI_ADAPTER Adapter, PUCHAR pucBuffer)
|
||||
VOID LinkControlResponseMessage(struct bcm_mini_adapter *Adapter, PUCHAR pucBuffer)
|
||||
{
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "=====>");
|
||||
|
||||
|
@ -580,11 +556,11 @@ VOID LinkControlResponseMessage(PMINI_ADAPTER Adapter, PUCHAR pucBuffer)
|
|||
return;
|
||||
}
|
||||
|
||||
void SendIdleModeResponse(PMINI_ADAPTER Adapter)
|
||||
void SendIdleModeResponse(struct bcm_mini_adapter *Adapter)
|
||||
{
|
||||
INT status = 0, NVMAccess = 0, lowPwrAbortMsg = 0;
|
||||
struct timeval tv;
|
||||
CONTROL_MESSAGE stIdleResponse = {{0} };
|
||||
struct bcm_link_request stIdleResponse = {{0} };
|
||||
memset(&tv, 0, sizeof(tv));
|
||||
stIdleResponse.Leader.Status = IDLE_MESSAGE;
|
||||
stIdleResponse.Leader.PLength = IDLE_MODE_PAYLOAD_LENGTH;
|
||||
|
@ -679,12 +655,12 @@ void SendIdleModeResponse(PMINI_ADAPTER Adapter)
|
|||
*
|
||||
* Returns - None.
|
||||
*******************************************************************/
|
||||
VOID DumpPackInfo(PMINI_ADAPTER Adapter)
|
||||
VOID DumpPackInfo(struct bcm_mini_adapter *Adapter)
|
||||
{
|
||||
UINT uiLoopIndex = 0;
|
||||
UINT uiIndex = 0;
|
||||
UINT uiClsfrIndex = 0;
|
||||
S_CLASSIFIER_RULE *pstClassifierEntry = NULL;
|
||||
struct bcm_classifier_rule *pstClassifierEntry = NULL;
|
||||
|
||||
for (uiLoopIndex = 0; uiLoopIndex < NO_OF_QUEUES; uiLoopIndex++) {
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "*********** Showing Details Of Queue %d***** ******", uiLoopIndex);
|
||||
|
@ -808,10 +784,10 @@ VOID DumpPackInfo(PMINI_ADAPTER Adapter)
|
|||
return;
|
||||
}
|
||||
|
||||
int reset_card_proc(PMINI_ADAPTER ps_adapter)
|
||||
int reset_card_proc(struct bcm_mini_adapter *ps_adapter)
|
||||
{
|
||||
int retval = STATUS_SUCCESS;
|
||||
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
PS_INTERFACE_ADAPTER psIntfAdapter = NULL;
|
||||
unsigned int value = 0, uiResetValue = 0;
|
||||
int bytes;
|
||||
|
@ -926,7 +902,7 @@ int reset_card_proc(PMINI_ADAPTER ps_adapter)
|
|||
return retval;
|
||||
}
|
||||
|
||||
int run_card_proc(PMINI_ADAPTER ps_adapter)
|
||||
int run_card_proc(struct bcm_mini_adapter *ps_adapter)
|
||||
{
|
||||
int status = STATUS_SUCCESS;
|
||||
int bytes;
|
||||
|
@ -953,7 +929,7 @@ int run_card_proc(PMINI_ADAPTER ps_adapter)
|
|||
return status;
|
||||
}
|
||||
|
||||
int InitCardAndDownloadFirmware(PMINI_ADAPTER ps_adapter)
|
||||
int InitCardAndDownloadFirmware(struct bcm_mini_adapter *ps_adapter)
|
||||
{
|
||||
int status;
|
||||
UINT value = 0;
|
||||
|
@ -1077,7 +1053,7 @@ int InitCardAndDownloadFirmware(PMINI_ADAPTER ps_adapter)
|
|||
return status;
|
||||
}
|
||||
|
||||
static int bcm_parse_target_params(PMINI_ADAPTER Adapter)
|
||||
static int bcm_parse_target_params(struct bcm_mini_adapter *Adapter)
|
||||
{
|
||||
struct file *flp = NULL;
|
||||
mm_segment_t oldfs = {0};
|
||||
|
@ -1128,7 +1104,7 @@ static int bcm_parse_target_params(PMINI_ADAPTER Adapter)
|
|||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
void beceem_parse_target_struct(PMINI_ADAPTER Adapter)
|
||||
void beceem_parse_target_struct(struct bcm_mini_adapter *Adapter)
|
||||
{
|
||||
UINT uiHostDrvrCfg6 = 0, uiEEPROMFlag = 0;
|
||||
|
||||
|
@ -1186,7 +1162,7 @@ void beceem_parse_target_struct(PMINI_ADAPTER Adapter)
|
|||
doPowerAutoCorrection(Adapter);
|
||||
}
|
||||
|
||||
static VOID doPowerAutoCorrection(PMINI_ADAPTER psAdapter)
|
||||
static VOID doPowerAutoCorrection(struct bcm_mini_adapter *psAdapter)
|
||||
{
|
||||
UINT reporting_mode;
|
||||
|
||||
|
@ -1217,45 +1193,6 @@ static VOID doPowerAutoCorrection(PMINI_ADAPTER psAdapter)
|
|||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
static unsigned char *ReadMacAddrEEPROM(PMINI_ADAPTER Adapter, ulong dwAddress)
|
||||
{
|
||||
int status = 0, i = 0;
|
||||
unsigned int temp = 0;
|
||||
unsigned char *pucmacaddr = kmalloc(MAC_ADDRESS_SIZE, GFP_KERNEL);
|
||||
int bytes;
|
||||
|
||||
if (!pucmacaddr) {
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "No Buffers to Read the EEPROM Address\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dwAddress |= 0x5b000000;
|
||||
status = wrmalt(Adapter, EEPROM_COMMAND_Q_REG, (PUINT)&dwAddress, sizeof(UINT));
|
||||
if (status != STATUS_SUCCESS) {
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "wrm Failed..\n");
|
||||
kfree(pucmacaddr);
|
||||
pucmacaddr = NULL;
|
||||
goto OUT;
|
||||
}
|
||||
|
||||
for (i = 0; i < MAC_ADDRESS_SIZE; i++) {
|
||||
bytes = rdmalt(Adapter, EEPROM_READ_DATA_Q_REG, &temp, sizeof(temp));
|
||||
if (bytes < 0) {
|
||||
status = bytes;
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "rdm Failed..\n");
|
||||
kfree(pucmacaddr);
|
||||
pucmacaddr = NULL;
|
||||
goto OUT;
|
||||
}
|
||||
pucmacaddr[i] = temp & 0xff;
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "%x\n", pucmacaddr[i]);
|
||||
}
|
||||
OUT:
|
||||
return pucmacaddr;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void convertEndian(B_UINT8 rwFlag, PUINT puiBuffer, UINT uiByteCount)
|
||||
{
|
||||
UINT uiIndex = 0;
|
||||
|
@ -1269,16 +1206,13 @@ static void convertEndian(B_UINT8 rwFlag, PUINT puiBuffer, UINT uiByteCount)
|
|||
}
|
||||
}
|
||||
|
||||
#define CACHE_ADDRESS_MASK 0x80000000
|
||||
#define UNCACHE_ADDRESS_MASK 0xa0000000
|
||||
|
||||
int rdm(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t sSize)
|
||||
int rdm(struct bcm_mini_adapter *Adapter, UINT uiAddress, PCHAR pucBuff, size_t sSize)
|
||||
{
|
||||
return Adapter->interface_rdm(Adapter->pvInterfaceAdapter,
|
||||
uiAddress, pucBuff, sSize);
|
||||
}
|
||||
|
||||
int wrm(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t sSize)
|
||||
int wrm(struct bcm_mini_adapter *Adapter, UINT uiAddress, PCHAR pucBuff, size_t sSize)
|
||||
{
|
||||
int iRetVal;
|
||||
|
||||
|
@ -1287,13 +1221,13 @@ int wrm(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t sSize)
|
|||
return iRetVal;
|
||||
}
|
||||
|
||||
int wrmalt(PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t size)
|
||||
int wrmalt(struct bcm_mini_adapter *Adapter, UINT uiAddress, PUINT pucBuff, size_t size)
|
||||
{
|
||||
convertEndian(RWM_WRITE, pucBuff, size);
|
||||
return wrm(Adapter, uiAddress, (PUCHAR)pucBuff, size);
|
||||
}
|
||||
|
||||
int rdmalt(PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t size)
|
||||
int rdmalt(struct bcm_mini_adapter *Adapter, UINT uiAddress, PUINT pucBuff, size_t size)
|
||||
{
|
||||
INT uiRetVal = 0;
|
||||
|
||||
|
@ -1303,7 +1237,7 @@ int rdmalt(PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t size)
|
|||
return uiRetVal;
|
||||
}
|
||||
|
||||
int wrmWithLock(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t sSize)
|
||||
int wrmWithLock(struct bcm_mini_adapter *Adapter, UINT uiAddress, PCHAR pucBuff, size_t sSize)
|
||||
{
|
||||
INT status = STATUS_SUCCESS;
|
||||
down(&Adapter->rdmwrmsync);
|
||||
|
@ -1322,7 +1256,7 @@ int wrmWithLock(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t sSi
|
|||
return status;
|
||||
}
|
||||
|
||||
int wrmaltWithLock(PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t size)
|
||||
int wrmaltWithLock(struct bcm_mini_adapter *Adapter, UINT uiAddress, PUINT pucBuff, size_t size)
|
||||
{
|
||||
int iRetVal = STATUS_SUCCESS;
|
||||
|
||||
|
@ -1342,7 +1276,7 @@ int wrmaltWithLock(PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t
|
|||
return iRetVal;
|
||||
}
|
||||
|
||||
int rdmaltWithLock(PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t size)
|
||||
int rdmaltWithLock(struct bcm_mini_adapter *Adapter, UINT uiAddress, PUINT pucBuff, size_t size)
|
||||
{
|
||||
INT uiRetVal = STATUS_SUCCESS;
|
||||
|
||||
|
@ -1361,7 +1295,7 @@ int rdmaltWithLock(PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t
|
|||
return uiRetVal;
|
||||
}
|
||||
|
||||
static VOID HandleShutDownModeWakeup(PMINI_ADAPTER Adapter)
|
||||
static VOID HandleShutDownModeWakeup(struct bcm_mini_adapter *Adapter)
|
||||
{
|
||||
int clear_abort_pattern = 0, Status = 0;
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "====>\n");
|
||||
|
@ -1390,13 +1324,13 @@ static VOID HandleShutDownModeWakeup(PMINI_ADAPTER Adapter)
|
|||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "<====\n");
|
||||
}
|
||||
|
||||
static VOID SendShutModeResponse(PMINI_ADAPTER Adapter)
|
||||
static VOID SendShutModeResponse(struct bcm_mini_adapter *Adapter)
|
||||
{
|
||||
CONTROL_MESSAGE stShutdownResponse;
|
||||
struct bcm_link_request stShutdownResponse;
|
||||
UINT NVMAccess = 0, lowPwrAbortMsg = 0;
|
||||
UINT Status = 0;
|
||||
|
||||
memset(&stShutdownResponse, 0, sizeof(CONTROL_MESSAGE));
|
||||
memset(&stShutdownResponse, 0, sizeof(struct bcm_link_request));
|
||||
stShutdownResponse.Leader.Status = LINK_UP_CONTROL_REQ;
|
||||
stShutdownResponse.Leader.PLength = 8; /* 8 bytes; */
|
||||
stShutdownResponse.szData[0] = LINK_UP_ACK;
|
||||
|
@ -1474,7 +1408,7 @@ static VOID SendShutModeResponse(PMINI_ADAPTER Adapter)
|
|||
}
|
||||
}
|
||||
|
||||
static void HandleShutDownModeRequest(PMINI_ADAPTER Adapter, PUCHAR pucBuffer)
|
||||
static void HandleShutDownModeRequest(struct bcm_mini_adapter *Adapter, PUCHAR pucBuffer)
|
||||
{
|
||||
B_UINT32 uiResetValue = 0;
|
||||
|
||||
|
@ -1503,7 +1437,7 @@ static void HandleShutDownModeRequest(PMINI_ADAPTER Adapter, PUCHAR pucBuffer)
|
|||
return;
|
||||
}
|
||||
|
||||
VOID ResetCounters(PMINI_ADAPTER Adapter)
|
||||
VOID ResetCounters(struct bcm_mini_adapter *Adapter)
|
||||
{
|
||||
beceem_protocol_reset(Adapter);
|
||||
Adapter->CurrNumRecvDescs = 0;
|
||||
|
@ -1519,7 +1453,7 @@ VOID ResetCounters(PMINI_ADAPTER Adapter)
|
|||
Adapter->bShutStatus = FALSE;
|
||||
}
|
||||
|
||||
S_CLASSIFIER_RULE *GetFragIPClsEntry(PMINI_ADAPTER Adapter, USHORT usIpIdentification, ULONG SrcIP)
|
||||
struct bcm_classifier_rule *GetFragIPClsEntry(struct bcm_mini_adapter *Adapter, USHORT usIpIdentification, ULONG SrcIP)
|
||||
{
|
||||
UINT uiIndex = 0;
|
||||
for (uiIndex = 0; uiIndex < MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES; uiIndex++) {
|
||||
|
@ -1533,18 +1467,18 @@ S_CLASSIFIER_RULE *GetFragIPClsEntry(PMINI_ADAPTER Adapter, USHORT usIpIdentific
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void AddFragIPClsEntry(PMINI_ADAPTER Adapter, PS_FRAGMENTED_PACKET_INFO psFragPktInfo)
|
||||
void AddFragIPClsEntry(struct bcm_mini_adapter *Adapter, struct bcm_fragmented_packet_info *psFragPktInfo)
|
||||
{
|
||||
UINT uiIndex = 0;
|
||||
for (uiIndex = 0; uiIndex < MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES; uiIndex++) {
|
||||
if (!Adapter->astFragmentedPktClassifierTable[uiIndex].bUsed) {
|
||||
memcpy(&Adapter->astFragmentedPktClassifierTable[uiIndex], psFragPktInfo, sizeof(S_FRAGMENTED_PACKET_INFO));
|
||||
memcpy(&Adapter->astFragmentedPktClassifierTable[uiIndex], psFragPktInfo, sizeof(struct bcm_fragmented_packet_info));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DelFragIPClsEntry(PMINI_ADAPTER Adapter, USHORT usIpIdentification, ULONG SrcIp)
|
||||
void DelFragIPClsEntry(struct bcm_mini_adapter *Adapter, USHORT usIpIdentification, ULONG SrcIp)
|
||||
{
|
||||
UINT uiIndex = 0;
|
||||
for (uiIndex = 0; uiIndex < MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES; uiIndex++) {
|
||||
|
@ -1552,11 +1486,11 @@ void DelFragIPClsEntry(PMINI_ADAPTER Adapter, USHORT usIpIdentification, ULONG S
|
|||
(Adapter->astFragmentedPktClassifierTable[uiIndex].usIpIdentification == usIpIdentification) &&
|
||||
(Adapter->astFragmentedPktClassifierTable[uiIndex].ulSrcIpAddress == SrcIp))
|
||||
|
||||
memset(&Adapter->astFragmentedPktClassifierTable[uiIndex], 0, sizeof(S_FRAGMENTED_PACKET_INFO));
|
||||
memset(&Adapter->astFragmentedPktClassifierTable[uiIndex], 0, sizeof(struct bcm_fragmented_packet_info));
|
||||
}
|
||||
}
|
||||
|
||||
void update_per_cid_rx(PMINI_ADAPTER Adapter)
|
||||
void update_per_cid_rx(struct bcm_mini_adapter *Adapter)
|
||||
{
|
||||
UINT qindex = 0;
|
||||
|
||||
|
@ -1580,7 +1514,7 @@ void update_per_cid_rx(PMINI_ADAPTER Adapter)
|
|||
Adapter->liDrainCalculated = jiffies;
|
||||
}
|
||||
|
||||
void update_per_sf_desc_cnts(PMINI_ADAPTER Adapter)
|
||||
void update_per_sf_desc_cnts(struct bcm_mini_adapter *Adapter)
|
||||
{
|
||||
INT iIndex = 0;
|
||||
u32 uibuff[MAX_TARGET_DSX_BUFFERS];
|
||||
|
@ -1606,7 +1540,7 @@ void update_per_sf_desc_cnts(PMINI_ADAPTER Adapter)
|
|||
atomic_set(&Adapter->uiMBupdate, FALSE);
|
||||
}
|
||||
|
||||
void flush_queue(PMINI_ADAPTER Adapter, UINT iQIndex)
|
||||
void flush_queue(struct bcm_mini_adapter *Adapter, UINT iQIndex)
|
||||
{
|
||||
struct sk_buff *PacketToDrop = NULL;
|
||||
struct net_device_stats *netstats = &Adapter->dev->stats;
|
||||
|
@ -1630,7 +1564,7 @@ void flush_queue(PMINI_ADAPTER Adapter, UINT iQIndex)
|
|||
spin_unlock_bh(&Adapter->PackInfo[iQIndex].SFQueueLock);
|
||||
}
|
||||
|
||||
static void beceem_protocol_reset(PMINI_ADAPTER Adapter)
|
||||
static void beceem_protocol_reset(struct bcm_mini_adapter *Adapter)
|
||||
{
|
||||
int i;
|
||||
if (netif_msg_link(Adapter))
|
||||
|
@ -1652,7 +1586,7 @@ static void beceem_protocol_reset(PMINI_ADAPTER Adapter)
|
|||
if (Adapter->TimerActive == TRUE)
|
||||
Adapter->TimerActive = FALSE;
|
||||
|
||||
memset(Adapter->astFragmentedPktClassifierTable, 0, sizeof(S_FRAGMENTED_PACKET_INFO) * MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES);
|
||||
memset(Adapter->astFragmentedPktClassifierTable, 0, sizeof(struct bcm_fragmented_packet_info) * MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES);
|
||||
|
||||
for (i = 0; i < HiPriority; i++) {
|
||||
/* resetting only the first size (S_MIBS_SERVICEFLOW_TABLE) for the SF. */
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#define PHS_BUFFER_SIZE 1532
|
||||
|
||||
|
||||
//#define MAX_PHS_LENGTHS 100
|
||||
#define MAX_PHSRULE_PER_SF 20
|
||||
#define MAX_SERVICEFLOWS 17
|
||||
|
||||
|
|
|
@ -54,11 +54,11 @@ Function: PHSTransmit
|
|||
|
||||
Description: This routine handle PHS(Payload Header Suppression for Tx path.
|
||||
It extracts a fragment of the NDIS_PACKET containing the header
|
||||
to be suppressed.It then supresses the header by invoking PHS exported compress routine.
|
||||
The header data after supression is copied back to the NDIS_PACKET.
|
||||
to be suppressed. It then suppresses the header by invoking PHS exported compress routine.
|
||||
The header data after suppression is copied back to the NDIS_PACKET.
|
||||
|
||||
|
||||
Input parameters: IN PMINI_ADAPTER Adapter - Miniport Adapter Context
|
||||
Input parameters: IN struct bcm_mini_adapter *Adapter - Miniport Adapter Context
|
||||
IN Packet - NDIS packet containing data to be transmitted
|
||||
IN USHORT Vcid - vcid pertaining to connection on which the packet is being sent.Used to
|
||||
identify PHS rule to be applied.
|
||||
|
@ -69,7 +69,7 @@ Return: STATUS_SUCCESS - If the send was successful.
|
|||
Other - If an error occured.
|
||||
*/
|
||||
|
||||
int PHSTransmit(PMINI_ADAPTER Adapter,
|
||||
int PHSTransmit(struct bcm_mini_adapter *Adapter,
|
||||
struct sk_buff **pPacket,
|
||||
USHORT Vcid,
|
||||
B_UINT16 uiClassifierRuleID,
|
||||
|
@ -84,10 +84,10 @@ int PHSTransmit(PMINI_ADAPTER Adapter,
|
|||
UINT unPHSNewPktHeaderLen = 0;
|
||||
/* Pointer to PHS IN Hdr Buffer */
|
||||
PUCHAR pucPHSPktHdrInBuf =
|
||||
Adapter->stPhsTxContextInfo.ucaHdrSupressionInBuf;
|
||||
Adapter->stPhsTxContextInfo.ucaHdrSuppressionInBuf;
|
||||
/* Pointer to PHS OUT Hdr Buffer */
|
||||
PUCHAR pucPHSPktHdrOutBuf =
|
||||
Adapter->stPhsTxContextInfo.ucaHdrSupressionOutBuf;
|
||||
Adapter->stPhsTxContextInfo.ucaHdrSuppressionOutBuf;
|
||||
UINT usPacketType;
|
||||
UINT BytesToRemove=0;
|
||||
BOOLEAN bPHSI = 0;
|
||||
|
@ -101,7 +101,7 @@ int PHSTransmit(PMINI_ADAPTER Adapter,
|
|||
if(!bEthCSSupport)
|
||||
BytesToRemove=ETH_HLEN;
|
||||
/*
|
||||
Accumulate the header upto the size we support supression
|
||||
Accumulate the header upto the size we support suppression
|
||||
from NDIS packet
|
||||
*/
|
||||
|
||||
|
@ -125,7 +125,7 @@ int PHSTransmit(PMINI_ADAPTER Adapter,
|
|||
{
|
||||
|
||||
|
||||
// Step 2 Supress Header using PHS and fill into intermediate ucaPHSPktHdrOutBuf.
|
||||
// Step 2 Suppress Header using PHS and fill into intermediate ucaPHSPktHdrOutBuf.
|
||||
// Suppress only if IP Header and PHS Enabled For the Service Flow
|
||||
if(((usPacketType == ETHERNET_FRAMETYPE_IPV4) ||
|
||||
(usPacketType == ETHERNET_FRAMETYPE_IPV6)) &&
|
||||
|
@ -209,7 +209,7 @@ int PHSTransmit(PMINI_ADAPTER Adapter,
|
|||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
int PHSReceive(PMINI_ADAPTER Adapter,
|
||||
int PHSReceive(struct bcm_mini_adapter *Adapter,
|
||||
USHORT usVcid,
|
||||
struct sk_buff *packet,
|
||||
UINT *punPacketLen,
|
||||
|
@ -217,7 +217,7 @@ int PHSReceive(PMINI_ADAPTER Adapter,
|
|||
UINT bHeaderSuppressionEnabled)
|
||||
{
|
||||
u32 nStandardPktHdrLen = 0;
|
||||
u32 nTotalsupressedPktHdrBytes = 0;
|
||||
u32 nTotalsuppressedPktHdrBytes = 0;
|
||||
int ulPhsStatus = 0;
|
||||
PUCHAR pucInBuff = NULL ;
|
||||
UINT TotalBytesAdded = 0;
|
||||
|
@ -235,11 +235,11 @@ int PHSReceive(PMINI_ADAPTER Adapter,
|
|||
usVcid,
|
||||
pucInBuff,
|
||||
Adapter->ucaPHSPktRestoreBuf,
|
||||
&nTotalsupressedPktHdrBytes,
|
||||
&nTotalsuppressedPktHdrBytes,
|
||||
&nStandardPktHdrLen);
|
||||
|
||||
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECEIVE,DBG_LVL_ALL,"\nSupressed PktHdrLen : 0x%x Restored PktHdrLen : 0x%x",
|
||||
nTotalsupressedPktHdrBytes,nStandardPktHdrLen);
|
||||
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECEIVE,DBG_LVL_ALL,"\nSuppressed PktHdrLen : 0x%x Restored PktHdrLen : 0x%x",
|
||||
nTotalsuppressedPktHdrBytes,nStandardPktHdrLen);
|
||||
|
||||
if(ulPhsStatus != STATUS_PHS_COMPRESSED)
|
||||
{
|
||||
|
@ -248,7 +248,7 @@ int PHSReceive(PMINI_ADAPTER Adapter,
|
|||
}
|
||||
else
|
||||
{
|
||||
TotalBytesAdded = nStandardPktHdrLen - nTotalsupressedPktHdrBytes - PHSI_LEN;
|
||||
TotalBytesAdded = nStandardPktHdrLen - nTotalsuppressedPktHdrBytes - PHSI_LEN;
|
||||
if(TotalBytesAdded)
|
||||
{
|
||||
if(skb_headroom(packet) >= (SKB_RESERVE_ETHERNET_HEADER + TotalBytesAdded))
|
||||
|
@ -273,7 +273,7 @@ int PHSReceive(PMINI_ADAPTER Adapter,
|
|||
|
||||
void DumpFullPacket(UCHAR *pBuf,UINT nPktLen)
|
||||
{
|
||||
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,"Dumping Data Packet");
|
||||
BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,pBuf,nPktLen);
|
||||
}
|
||||
|
@ -291,7 +291,7 @@ void DumpFullPacket(UCHAR *pBuf,UINT nPktLen)
|
|||
// TRUE(1) -If allocation of memory was success full.
|
||||
// FALSE -If allocation of memory fails.
|
||||
//-----------------------------------------------------------------------------
|
||||
int phs_init(PPHS_DEVICE_EXTENSION pPhsdeviceExtension,PMINI_ADAPTER Adapter)
|
||||
int phs_init(PPHS_DEVICE_EXTENSION pPhsdeviceExtension, struct bcm_mini_adapter *Adapter)
|
||||
{
|
||||
int i;
|
||||
S_SERVICEFLOW_TABLE *pstServiceFlowTable;
|
||||
|
@ -398,7 +398,7 @@ ULONG PhsUpdateClassifierRule(IN void* pvContext,
|
|||
ULONG lStatus =0;
|
||||
UINT nSFIndex =0 ;
|
||||
S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL;
|
||||
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
|
||||
|
||||
|
||||
|
@ -462,7 +462,7 @@ ULONG PhsDeletePHSRule(IN void* pvContext,IN B_UINT16 uiVcid,IN B_UINT8 u8PHSI)
|
|||
UINT nSFIndex =0, nClsidIndex =0 ;
|
||||
S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL;
|
||||
S_CLASSIFIER_TABLE *pstClassifierRulesTable = NULL;
|
||||
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
|
||||
|
||||
PPHS_DEVICE_EXTENSION pDeviceExtension= (PPHS_DEVICE_EXTENSION)pvContext;
|
||||
|
@ -528,7 +528,7 @@ ULONG PhsDeleteClassifierRule(IN void* pvContext,IN B_UINT16 uiVcid ,IN B_UINT16
|
|||
UINT nSFIndex =0, nClsidIndex =0 ;
|
||||
S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL;
|
||||
S_CLASSIFIER_ENTRY *pstClassifierEntry = NULL;
|
||||
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
PPHS_DEVICE_EXTENSION pDeviceExtension= (PPHS_DEVICE_EXTENSION)pvContext;
|
||||
|
||||
if(pDeviceExtension)
|
||||
|
@ -592,7 +592,7 @@ ULONG PhsDeleteSFRules(IN void* pvContext,IN B_UINT16 uiVcid)
|
|||
UINT nSFIndex =0, nClsidIndex =0 ;
|
||||
S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL;
|
||||
S_CLASSIFIER_TABLE *pstClassifierRulesTable = NULL;
|
||||
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
PPHS_DEVICE_EXTENSION pDeviceExtension= (PPHS_DEVICE_EXTENSION)pvContext;
|
||||
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,"====> \n");
|
||||
|
||||
|
@ -684,7 +684,7 @@ ULONG PhsCompress(IN void* pvContext,
|
|||
S_CLASSIFIER_ENTRY *pstClassifierEntry = NULL;
|
||||
S_PHS_RULE *pstPhsRule = NULL;
|
||||
ULONG lStatus =0;
|
||||
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
|
||||
|
||||
|
||||
|
@ -778,7 +778,7 @@ ULONG PhsDeCompress(IN void* pvContext,
|
|||
S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL;
|
||||
S_PHS_RULE *pstPhsRule = NULL;
|
||||
UINT phsi;
|
||||
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
PPHS_DEVICE_EXTENSION pDeviceExtension=
|
||||
(PPHS_DEVICE_EXTENSION)pvContext;
|
||||
|
||||
|
@ -847,7 +847,7 @@ ULONG PhsDeCompress(IN void* pvContext,
|
|||
static void free_phs_serviceflow_rules(S_SERVICEFLOW_TABLE *psServiceFlowRulesTable)
|
||||
{
|
||||
int i,j;
|
||||
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
|
||||
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "=======>\n");
|
||||
if(psServiceFlowRulesTable)
|
||||
|
@ -1057,7 +1057,7 @@ UINT CreateClassiferToPHSRuleMapping(IN B_UINT16 uiVcid,
|
|||
UINT uiStatus =PHS_SUCCESS;
|
||||
UINT nClassifierIndex = 0;
|
||||
S_CLASSIFIER_TABLE *psaClassifiertable = NULL;
|
||||
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
psaClassifiertable = pstServiceFlowEntry->pstClassifierTable;
|
||||
|
||||
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "==>");
|
||||
|
@ -1148,7 +1148,7 @@ static UINT CreateClassifierPHSRule(IN B_UINT16 uiClsId,
|
|||
BOOLEAN bFreeEntryFound = FALSE;
|
||||
S_CLASSIFIER_ENTRY *psClassifierRules = NULL;
|
||||
UINT nStatus = PHS_SUCCESS;
|
||||
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,"Inside CreateClassifierPHSRule");
|
||||
if(psaClassifiertable == NULL)
|
||||
{
|
||||
|
@ -1259,7 +1259,7 @@ static UINT UpdateClassifierPHSRule(IN B_UINT16 uiClsId,
|
|||
S_PHS_RULE *pstAddPhsRule = NULL;
|
||||
UINT nPhsRuleIndex = 0;
|
||||
BOOLEAN bPHSRuleOrphaned = FALSE;
|
||||
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
psPhsRule->u8RefCnt =0;
|
||||
|
||||
/* Step 1 Deref Any Exisiting PHS Rule in this classifier Entry*/
|
||||
|
@ -1334,7 +1334,7 @@ static BOOLEAN DerefPhsRule(IN B_UINT16 uiClsId,S_CLASSIFIER_TABLE *psaClassifi
|
|||
void DumpPhsRules(PPHS_DEVICE_EXTENSION pDeviceExtension)
|
||||
{
|
||||
int i,j,k,l;
|
||||
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\n Dumping PHS Rules : \n");
|
||||
for(i=0;i<MAX_SERVICEFLOWS;i++)
|
||||
{
|
||||
|
@ -1415,7 +1415,7 @@ int phs_decompress(unsigned char *in_buf,unsigned char *out_buf,
|
|||
int bit,i=0;
|
||||
unsigned char *phsf,*phsm;
|
||||
int in_buf_len = *header_size-1;
|
||||
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
in_buf++;
|
||||
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECEIVE,DBG_LVL_ALL,"====>\n");
|
||||
*header_size = 0;
|
||||
|
@ -1494,8 +1494,8 @@ static int phs_compress(S_PHS_RULE *phs_rule,unsigned char *in_buf
|
|||
,unsigned char *out_buf,UINT *header_size,UINT *new_header_size)
|
||||
{
|
||||
unsigned char *old_addr = out_buf;
|
||||
int supress = 0;
|
||||
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
int suppress = 0;
|
||||
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
if(phs_rule == NULL)
|
||||
{
|
||||
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nphs_compress(): phs_rule null!");
|
||||
|
@ -1514,10 +1514,10 @@ static int phs_compress(S_PHS_RULE *phs_rule,unsigned char *in_buf
|
|||
}
|
||||
//To copy PHSI
|
||||
out_buf++;
|
||||
supress = verify_suppress_phsf(in_buf,out_buf,phs_rule->u8PHSF,
|
||||
suppress = verify_suppress_phsf(in_buf,out_buf,phs_rule->u8PHSF,
|
||||
phs_rule->u8PHSM, phs_rule->u8PHSS, phs_rule->u8PHSV,new_header_size);
|
||||
|
||||
if(supress == STATUS_PHS_COMPRESSED)
|
||||
if(suppress == STATUS_PHS_COMPRESSED)
|
||||
{
|
||||
*old_addr = (unsigned char)phs_rule->u8PHSI;
|
||||
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nCOMP:In phs_compress phsi %d",phs_rule->u8PHSI);
|
||||
|
@ -1527,7 +1527,7 @@ static int phs_compress(S_PHS_RULE *phs_rule,unsigned char *in_buf
|
|||
*old_addr = ZERO_PHSI;
|
||||
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nCOMP:In phs_compress PHSV Verification failed");
|
||||
}
|
||||
return supress;
|
||||
return suppress;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1557,7 +1557,7 @@ static int verify_suppress_phsf(unsigned char *in_buffer,unsigned char *out_buff
|
|||
{
|
||||
unsigned int size=0;
|
||||
int bit,i=0;
|
||||
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nCOMP:In verify_phsf PHSM - 0x%X",*phsm);
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef BCM_MINIPORT_PHSMODULE_H
|
||||
#define BCM_MINIPORT_PHSMODULE_H
|
||||
|
||||
int PHSTransmit(PMINI_ADAPTER Adapter,
|
||||
int PHSTransmit(struct bcm_mini_adapter *Adapter,
|
||||
struct sk_buff **pPacket,
|
||||
USHORT Vcid,
|
||||
B_UINT16 uiClassifierRuleID,
|
||||
|
@ -9,7 +9,7 @@ int PHSTransmit(PMINI_ADAPTER Adapter,
|
|||
PUINT PacketLen,
|
||||
UCHAR bEthCSSupport);
|
||||
|
||||
int PHSReceive(PMINI_ADAPTER Adapter,
|
||||
int PHSReceive(struct bcm_mini_adapter *Adapter,
|
||||
USHORT usVcid,
|
||||
struct sk_buff *packet,
|
||||
UINT *punPacketLen,
|
||||
|
@ -25,7 +25,7 @@ void DumpFullPacket(UCHAR *pBuf,UINT nPktLen);
|
|||
void DumpPhsRules(PPHS_DEVICE_EXTENSION pDeviceExtension);
|
||||
|
||||
|
||||
int phs_init(PPHS_DEVICE_EXTENSION pPhsdeviceExtension,PMINI_ADAPTER Adapter);
|
||||
int phs_init(PPHS_DEVICE_EXTENSION pPhsdeviceExtension,struct bcm_mini_adapter *Adapter);
|
||||
|
||||
int PhsCleanup(PPHS_DEVICE_EXTENSION pPHSDeviceExt);
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ typedef struct _S_ETHCS_PKT_INFO
|
|||
|
||||
typedef struct _ETH_CS_802_Q_FRAME
|
||||
{
|
||||
ETH_HEADER_STRUC EThHdr;
|
||||
struct bcm_eth_header EThHdr;
|
||||
USHORT UserPriority:3;
|
||||
USHORT CFI:1;
|
||||
USHORT VLANID:12;
|
||||
|
@ -64,7 +64,7 @@ typedef struct _ETH_CS_802_Q_FRAME
|
|||
|
||||
typedef struct _ETH_CS_802_LLC_FRAME
|
||||
{
|
||||
ETH_HEADER_STRUC EThHdr;
|
||||
struct bcm_eth_header EThHdr;
|
||||
unsigned char DSAP;
|
||||
unsigned char SSAP;
|
||||
unsigned char Control;
|
||||
|
@ -72,7 +72,7 @@ typedef struct _ETH_CS_802_LLC_FRAME
|
|||
|
||||
typedef struct _ETH_CS_802_LLC_SNAP_FRAME
|
||||
{
|
||||
ETH_HEADER_STRUC EThHdr;
|
||||
struct bcm_eth_header EThHdr;
|
||||
unsigned char DSAP;
|
||||
unsigned char SSAP;
|
||||
unsigned char Control;
|
||||
|
@ -82,7 +82,7 @@ typedef struct _ETH_CS_802_LLC_SNAP_FRAME
|
|||
|
||||
typedef struct _ETH_CS_ETH2_FRAME
|
||||
{
|
||||
ETH_HEADER_STRUC EThHdr;
|
||||
struct bcm_eth_header EThHdr;
|
||||
} __attribute__((packed)) ETH_CS_ETH2_FRAME;
|
||||
|
||||
#define ETHERNET_FRAMETYPE_IPV4 ntohs(0x0800)
|
||||
|
|
|
@ -1,172 +1,172 @@
|
|||
#ifndef _PROTOTYPES_H_
|
||||
#define _PROTOTYPES_H_
|
||||
|
||||
VOID LinkControlResponseMessage(PMINI_ADAPTER Adapter, PUCHAR pucBuffer);
|
||||
VOID LinkControlResponseMessage(struct bcm_mini_adapter *Adapter, PUCHAR pucBuffer);
|
||||
|
||||
VOID StatisticsResponse(PMINI_ADAPTER Adapter,PVOID pvBuffer);
|
||||
VOID StatisticsResponse(struct bcm_mini_adapter *Adapter,PVOID pvBuffer);
|
||||
|
||||
VOID IdleModeResponse(PMINI_ADAPTER Adapter,PUINT puiBuffer);
|
||||
VOID IdleModeResponse(struct bcm_mini_adapter *Adapter,PUINT puiBuffer);
|
||||
|
||||
int control_packet_handler (PMINI_ADAPTER Adapter);
|
||||
int control_packet_handler (struct bcm_mini_adapter *Adapter);
|
||||
|
||||
VOID DeleteAllClassifiersForSF(PMINI_ADAPTER Adapter,UINT uiSearchRuleIndex);
|
||||
VOID DeleteAllClassifiersForSF(struct bcm_mini_adapter *Adapter,UINT uiSearchRuleIndex);
|
||||
|
||||
VOID flush_all_queues(PMINI_ADAPTER Adapter);
|
||||
VOID flush_all_queues(struct bcm_mini_adapter *Adapter);
|
||||
|
||||
int register_control_device_interface(PMINI_ADAPTER ps_adapter);
|
||||
int register_control_device_interface(struct bcm_mini_adapter *ps_adapter);
|
||||
|
||||
void unregister_control_device_interface(PMINI_ADAPTER Adapter);
|
||||
void unregister_control_device_interface(struct bcm_mini_adapter *Adapter);
|
||||
|
||||
INT CopyBufferToControlPacket(PMINI_ADAPTER Adapter,/**<Logical Adapter*/
|
||||
INT CopyBufferToControlPacket(struct bcm_mini_adapter *Adapter,/**<Logical Adapter*/
|
||||
PVOID ioBuffer/**<Control Packet Buffer*/
|
||||
);
|
||||
|
||||
VOID SortPackInfo(PMINI_ADAPTER Adapter);
|
||||
VOID SortPackInfo(struct bcm_mini_adapter *Adapter);
|
||||
|
||||
VOID SortClassifiers(PMINI_ADAPTER Adapter);
|
||||
VOID SortClassifiers(struct bcm_mini_adapter *Adapter);
|
||||
|
||||
VOID flush_all_queues(PMINI_ADAPTER Adapter);
|
||||
VOID flush_all_queues(struct bcm_mini_adapter *Adapter);
|
||||
|
||||
VOID PruneQueueAllSF(PMINI_ADAPTER Adapter);
|
||||
VOID PruneQueueAllSF(struct bcm_mini_adapter *Adapter);
|
||||
|
||||
INT SearchSfid(PMINI_ADAPTER Adapter,UINT uiSfid);
|
||||
INT SearchSfid(struct bcm_mini_adapter *Adapter,UINT uiSfid);
|
||||
|
||||
USHORT ClassifyPacket(PMINI_ADAPTER Adapter,struct sk_buff* skb);
|
||||
USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter,struct sk_buff* skb);
|
||||
|
||||
BOOLEAN MatchSrcPort(S_CLASSIFIER_RULE *pstClassifierRule,USHORT ushSrcPort);
|
||||
BOOLEAN MatchDestPort(S_CLASSIFIER_RULE *pstClassifierRule,USHORT ushSrcPort);
|
||||
BOOLEAN MatchProtocol(S_CLASSIFIER_RULE *pstClassifierRule,UCHAR ucProtocol);
|
||||
BOOLEAN MatchSrcPort(struct bcm_classifier_rule *pstClassifierRule,USHORT ushSrcPort);
|
||||
BOOLEAN MatchDestPort(struct bcm_classifier_rule *pstClassifierRule,USHORT ushSrcPort);
|
||||
BOOLEAN MatchProtocol(struct bcm_classifier_rule *pstClassifierRule,UCHAR ucProtocol);
|
||||
|
||||
|
||||
INT SetupNextSend(PMINI_ADAPTER Adapter, /**<Logical Adapter*/
|
||||
INT SetupNextSend(struct bcm_mini_adapter *Adapter, /**<Logical Adapter*/
|
||||
struct sk_buff *Packet, /**<data buffer*/
|
||||
USHORT Vcid) ;
|
||||
|
||||
VOID LinkMessage(PMINI_ADAPTER Adapter);
|
||||
VOID LinkMessage(struct bcm_mini_adapter *Adapter);
|
||||
|
||||
VOID transmit_packets(PMINI_ADAPTER Adapter);
|
||||
VOID transmit_packets(struct bcm_mini_adapter *Adapter);
|
||||
|
||||
INT SendControlPacket(PMINI_ADAPTER Adapter, /**<Logical Adapter*/
|
||||
INT SendControlPacket(struct bcm_mini_adapter *Adapter, /**<Logical Adapter*/
|
||||
char *pControlPacket/**<Control Packet*/
|
||||
);
|
||||
|
||||
|
||||
int register_networkdev(PMINI_ADAPTER Adapter);
|
||||
void unregister_networkdev(PMINI_ADAPTER Adapter);
|
||||
int register_networkdev(struct bcm_mini_adapter *Adapter);
|
||||
void unregister_networkdev(struct bcm_mini_adapter *Adapter);
|
||||
|
||||
INT AllocAdapterDsxBuffer(PMINI_ADAPTER Adapter);
|
||||
INT AllocAdapterDsxBuffer(struct bcm_mini_adapter *Adapter);
|
||||
|
||||
VOID AdapterFree(PMINI_ADAPTER Adapter);
|
||||
VOID AdapterFree(struct bcm_mini_adapter *Adapter);
|
||||
|
||||
INT FreeAdapterDsxBuffer(PMINI_ADAPTER Adapter);
|
||||
INT FreeAdapterDsxBuffer(struct bcm_mini_adapter *Adapter);
|
||||
|
||||
int tx_pkt_handler(PMINI_ADAPTER Adapter);
|
||||
int tx_pkt_handler(struct bcm_mini_adapter *Adapter);
|
||||
|
||||
int reset_card_proc(PMINI_ADAPTER Adapter );
|
||||
int reset_card_proc(struct bcm_mini_adapter *Adapter );
|
||||
|
||||
int run_card_proc(PMINI_ADAPTER Adapter );
|
||||
int run_card_proc(struct bcm_mini_adapter *Adapter );
|
||||
|
||||
int InitCardAndDownloadFirmware(PMINI_ADAPTER ps_adapter);
|
||||
int InitCardAndDownloadFirmware(struct bcm_mini_adapter *ps_adapter);
|
||||
|
||||
|
||||
INT ReadMacAddressFromNVM(PMINI_ADAPTER Adapter);
|
||||
INT ReadMacAddressFromNVM(struct bcm_mini_adapter *Adapter);
|
||||
|
||||
int register_control_device_interface(PMINI_ADAPTER ps_adapter);
|
||||
int register_control_device_interface(struct bcm_mini_adapter *ps_adapter);
|
||||
|
||||
void DumpPackInfo(PMINI_ADAPTER Adapter);
|
||||
void DumpPackInfo(struct bcm_mini_adapter *Adapter);
|
||||
|
||||
int rdm(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t size);
|
||||
int rdm(struct bcm_mini_adapter *Adapter, UINT uiAddress, PCHAR pucBuff, size_t size);
|
||||
|
||||
int wrm(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t size);
|
||||
int wrm(struct bcm_mini_adapter *Adapter, UINT uiAddress, PCHAR pucBuff, size_t size);
|
||||
|
||||
int wrmalt (PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t sSize);
|
||||
int wrmalt (struct bcm_mini_adapter *Adapter, UINT uiAddress, PUINT pucBuff, size_t sSize);
|
||||
|
||||
int rdmalt (PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t sSize);
|
||||
int rdmalt (struct bcm_mini_adapter *Adapter, UINT uiAddress, PUINT pucBuff, size_t sSize);
|
||||
|
||||
int get_dsx_sf_data_to_application(PMINI_ADAPTER Adapter, UINT uiSFId, void __user * user_buffer);
|
||||
int get_dsx_sf_data_to_application(struct bcm_mini_adapter *Adapter, UINT uiSFId, void __user * user_buffer);
|
||||
|
||||
void SendIdleModeResponse(PMINI_ADAPTER Adapter);
|
||||
void SendIdleModeResponse(struct bcm_mini_adapter *Adapter);
|
||||
|
||||
|
||||
int ProcessGetHostMibs(PMINI_ADAPTER Adapter, S_MIBS_HOST_STATS_MIBS *buf);
|
||||
void GetDroppedAppCntrlPktMibs(S_MIBS_HOST_STATS_MIBS *ioBuffer, PPER_TARANG_DATA pTarang);
|
||||
void beceem_parse_target_struct(PMINI_ADAPTER Adapter);
|
||||
int ProcessGetHostMibs(struct bcm_mini_adapter *Adapter, S_MIBS_HOST_STATS_MIBS *buf);
|
||||
void GetDroppedAppCntrlPktMibs(S_MIBS_HOST_STATS_MIBS *ioBuffer, struct bcm_tarang_data *pTarang);
|
||||
void beceem_parse_target_struct(struct bcm_mini_adapter *Adapter);
|
||||
|
||||
int bcm_ioctl_fw_download(PMINI_ADAPTER Adapter, FIRMWARE_INFO *psFwInfo);
|
||||
int bcm_ioctl_fw_download(struct bcm_mini_adapter *Adapter, struct bcm_firmware_info *psFwInfo);
|
||||
|
||||
void CopyMIBSExtendedSFParameters(PMINI_ADAPTER Adapter,
|
||||
void CopyMIBSExtendedSFParameters(struct bcm_mini_adapter *Adapter,
|
||||
CServiceFlowParamSI *psfLocalSet, UINT uiSearchRuleIndex);
|
||||
|
||||
VOID ResetCounters(PMINI_ADAPTER Adapter);
|
||||
VOID ResetCounters(struct bcm_mini_adapter *Adapter);
|
||||
|
||||
int InitLedSettings(PMINI_ADAPTER Adapter);
|
||||
int InitLedSettings(struct bcm_mini_adapter *Adapter);
|
||||
|
||||
S_CLASSIFIER_RULE *GetFragIPClsEntry(PMINI_ADAPTER Adapter,USHORT usIpIdentification,ULONG SrcIP);
|
||||
struct bcm_classifier_rule *GetFragIPClsEntry(struct bcm_mini_adapter *Adapter,USHORT usIpIdentification,ULONG SrcIP);
|
||||
|
||||
void AddFragIPClsEntry(PMINI_ADAPTER Adapter,PS_FRAGMENTED_PACKET_INFO psFragPktInfo);
|
||||
void AddFragIPClsEntry(struct bcm_mini_adapter *Adapter, struct bcm_fragmented_packet_info *psFragPktInfo);
|
||||
|
||||
void DelFragIPClsEntry(PMINI_ADAPTER Adapter,USHORT usIpIdentification,ULONG SrcIp);
|
||||
void DelFragIPClsEntry(struct bcm_mini_adapter *Adapter,USHORT usIpIdentification,ULONG SrcIp);
|
||||
|
||||
void update_per_cid_rx (PMINI_ADAPTER Adapter);
|
||||
void update_per_cid_rx (struct bcm_mini_adapter *Adapter);
|
||||
|
||||
void update_per_sf_desc_cnts( PMINI_ADAPTER Adapter);
|
||||
void update_per_sf_desc_cnts( struct bcm_mini_adapter *Adapter);
|
||||
|
||||
void ClearTargetDSXBuffer(PMINI_ADAPTER Adapter,B_UINT16 TID,BOOLEAN bFreeAll);
|
||||
void ClearTargetDSXBuffer(struct bcm_mini_adapter *Adapter,B_UINT16 TID,BOOLEAN bFreeAll);
|
||||
|
||||
|
||||
void flush_queue(PMINI_ADAPTER Adapter, UINT iQIndex);
|
||||
void flush_queue(struct bcm_mini_adapter *Adapter, UINT iQIndex);
|
||||
|
||||
|
||||
INT flushAllAppQ(VOID);
|
||||
|
||||
|
||||
INT BeceemEEPROMBulkRead(
|
||||
PMINI_ADAPTER Adapter,
|
||||
struct bcm_mini_adapter *Adapter,
|
||||
PUINT pBuffer,
|
||||
UINT uiOffset,
|
||||
UINT uiNumBytes);
|
||||
|
||||
|
||||
|
||||
INT WriteBeceemEEPROM(PMINI_ADAPTER Adapter,UINT uiEEPROMOffset, UINT uiData);
|
||||
INT WriteBeceemEEPROM(struct bcm_mini_adapter *Adapter,UINT uiEEPROMOffset, UINT uiData);
|
||||
|
||||
INT PropagateCalParamsFromFlashToMemory(PMINI_ADAPTER Adapter);
|
||||
INT PropagateCalParamsFromFlashToMemory(struct bcm_mini_adapter *Adapter);
|
||||
|
||||
|
||||
INT BeceemEEPROMBulkWrite(
|
||||
PMINI_ADAPTER Adapter,
|
||||
struct bcm_mini_adapter *Adapter,
|
||||
PUCHAR pBuffer,
|
||||
UINT uiOffset,
|
||||
UINT uiNumBytes,
|
||||
BOOLEAN bVerify);
|
||||
|
||||
|
||||
INT ReadBeceemEEPROM(PMINI_ADAPTER Adapter,UINT dwAddress, UINT *pdwData);
|
||||
INT ReadBeceemEEPROM(struct bcm_mini_adapter *Adapter,UINT dwAddress, UINT *pdwData);
|
||||
|
||||
|
||||
INT BeceemNVMRead(
|
||||
PMINI_ADAPTER Adapter,
|
||||
struct bcm_mini_adapter *Adapter,
|
||||
PUINT pBuffer,
|
||||
UINT uiOffset,
|
||||
UINT uiNumBytes);
|
||||
|
||||
INT BeceemNVMWrite(
|
||||
PMINI_ADAPTER Adapter,
|
||||
struct bcm_mini_adapter *Adapter,
|
||||
PUINT pBuffer,
|
||||
UINT uiOffset,
|
||||
UINT uiNumBytes,
|
||||
BOOLEAN bVerify);
|
||||
|
||||
|
||||
INT BcmInitNVM(PMINI_ADAPTER Adapter);
|
||||
INT BcmInitNVM(struct bcm_mini_adapter *Adapter);
|
||||
|
||||
INT BcmUpdateSectorSize(PMINI_ADAPTER Adapter,UINT uiSectorSize);
|
||||
BOOLEAN IsSectionExistInFlash(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL section);
|
||||
INT BcmUpdateSectorSize(struct bcm_mini_adapter *Adapter,UINT uiSectorSize);
|
||||
BOOLEAN IsSectionExistInFlash(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL section);
|
||||
|
||||
INT BcmGetFlash2xSectionalBitMap(PMINI_ADAPTER Adapter, PFLASH2X_BITMAP psFlash2xBitMap);
|
||||
INT BcmGetFlash2xSectionalBitMap(struct bcm_mini_adapter *Adapter, PFLASH2X_BITMAP psFlash2xBitMap);
|
||||
|
||||
INT BcmFlash2xBulkWrite(
|
||||
PMINI_ADAPTER Adapter,
|
||||
struct bcm_mini_adapter *Adapter,
|
||||
PUINT pBuffer,
|
||||
FLASH2X_SECTION_VAL eFlashSectionVal,
|
||||
UINT uiOffset,
|
||||
|
@ -174,45 +174,45 @@ INT BcmFlash2xBulkWrite(
|
|||
UINT bVerify);
|
||||
|
||||
INT BcmFlash2xBulkRead(
|
||||
PMINI_ADAPTER Adapter,
|
||||
struct bcm_mini_adapter *Adapter,
|
||||
PUINT pBuffer,
|
||||
FLASH2X_SECTION_VAL eFlashSectionVal,
|
||||
UINT uiOffsetWithinSectionVal,
|
||||
UINT uiNumBytes);
|
||||
|
||||
INT BcmGetSectionValStartOffset(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlashSectionVal);
|
||||
INT BcmGetSectionValStartOffset(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eFlashSectionVal);
|
||||
|
||||
INT BcmSetActiveSection(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectVal);
|
||||
INT BcmAllocFlashCSStructure(PMINI_ADAPTER psAdapter);
|
||||
INT BcmDeAllocFlashCSStructure(PMINI_ADAPTER psAdapter);
|
||||
INT BcmSetActiveSection(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eFlash2xSectVal);
|
||||
INT BcmAllocFlashCSStructure(struct bcm_mini_adapter *psAdapter);
|
||||
INT BcmDeAllocFlashCSStructure(struct bcm_mini_adapter *psAdapter);
|
||||
|
||||
INT BcmCopyISO(PMINI_ADAPTER Adapter, FLASH2X_COPY_SECTION sCopySectStrut);
|
||||
INT BcmFlash2xCorruptSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal);
|
||||
INT BcmFlash2xWriteSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlashSectionVal);
|
||||
INT validateFlash2xReadWrite(PMINI_ADAPTER Adapter, PFLASH2X_READWRITE psFlash2xReadWrite);
|
||||
INT IsFlash2x(PMINI_ADAPTER Adapter);
|
||||
INT BcmCopySection(PMINI_ADAPTER Adapter,
|
||||
INT BcmCopyISO(struct bcm_mini_adapter *Adapter, FLASH2X_COPY_SECTION sCopySectStrut);
|
||||
INT BcmFlash2xCorruptSig(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal);
|
||||
INT BcmFlash2xWriteSig(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eFlashSectionVal);
|
||||
INT validateFlash2xReadWrite(struct bcm_mini_adapter *Adapter, PFLASH2X_READWRITE psFlash2xReadWrite);
|
||||
INT IsFlash2x(struct bcm_mini_adapter *Adapter);
|
||||
INT BcmCopySection(struct bcm_mini_adapter *Adapter,
|
||||
FLASH2X_SECTION_VAL SrcSection,
|
||||
FLASH2X_SECTION_VAL DstSection,
|
||||
UINT offset,
|
||||
UINT numOfBytes);
|
||||
|
||||
|
||||
BOOLEAN IsNonCDLessDevice(PMINI_ADAPTER Adapter);
|
||||
BOOLEAN IsNonCDLessDevice(struct bcm_mini_adapter *Adapter);
|
||||
|
||||
|
||||
VOID OverrideServiceFlowParams(PMINI_ADAPTER Adapter,PUINT puiBuffer);
|
||||
VOID OverrideServiceFlowParams(struct bcm_mini_adapter *Adapter,PUINT puiBuffer);
|
||||
|
||||
int wrmaltWithLock (PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t sSize);
|
||||
int rdmaltWithLock (PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t sSize);
|
||||
int wrmaltWithLock (struct bcm_mini_adapter *Adapter, UINT uiAddress, PUINT pucBuff, size_t sSize);
|
||||
int rdmaltWithLock (struct bcm_mini_adapter *Adapter, UINT uiAddress, PUINT pucBuff, size_t sSize);
|
||||
|
||||
int wrmWithLock(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t size);
|
||||
INT buffDnldVerify(PMINI_ADAPTER Adapter, unsigned char *mappedbuffer, unsigned int u32FirmwareLength,
|
||||
int wrmWithLock(struct bcm_mini_adapter *Adapter, UINT uiAddress, PCHAR pucBuff, size_t size);
|
||||
INT buffDnldVerify(struct bcm_mini_adapter *Adapter, unsigned char *mappedbuffer, unsigned int u32FirmwareLength,
|
||||
unsigned long u32StartingAddress);
|
||||
|
||||
|
||||
VOID putUsbSuspend(struct work_struct *work);
|
||||
BOOLEAN IsReqGpioIsLedInNVM(PMINI_ADAPTER Adapter, UINT gpios);
|
||||
BOOLEAN IsReqGpioIsLedInNVM(struct bcm_mini_adapter *Adapter, UINT gpios);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -4,13 +4,13 @@ This file contains the routines related to Quality of Service.
|
|||
*/
|
||||
#include "headers.h"
|
||||
|
||||
static void EThCSGetPktInfo(PMINI_ADAPTER Adapter,PVOID pvEthPayload,PS_ETHCS_PKT_INFO pstEthCsPktInfo);
|
||||
static BOOLEAN EThCSClassifyPkt(PMINI_ADAPTER Adapter,struct sk_buff* skb,PS_ETHCS_PKT_INFO pstEthCsPktInfo,S_CLASSIFIER_RULE *pstClassifierRule, B_UINT8 EthCSCupport);
|
||||
static void EThCSGetPktInfo(struct bcm_mini_adapter *Adapter,PVOID pvEthPayload,PS_ETHCS_PKT_INFO pstEthCsPktInfo);
|
||||
static BOOLEAN EThCSClassifyPkt(struct bcm_mini_adapter *Adapter,struct sk_buff* skb,PS_ETHCS_PKT_INFO pstEthCsPktInfo,struct bcm_classifier_rule *pstClassifierRule, B_UINT8 EthCSCupport);
|
||||
|
||||
static USHORT IpVersion4(PMINI_ADAPTER Adapter, struct iphdr *iphd,
|
||||
S_CLASSIFIER_RULE *pstClassifierRule );
|
||||
static USHORT IpVersion4(struct bcm_mini_adapter *Adapter, struct iphdr *iphd,
|
||||
struct bcm_classifier_rule *pstClassifierRule );
|
||||
|
||||
static VOID PruneQueue(PMINI_ADAPTER Adapter, INT iIndex);
|
||||
static VOID PruneQueue(struct bcm_mini_adapter *Adapter, INT iIndex);
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
|
@ -24,11 +24,11 @@ static VOID PruneQueue(PMINI_ADAPTER Adapter, INT iIndex);
|
|||
*
|
||||
* Returns - TRUE(If address matches) else FAIL .
|
||||
*********************************************************************/
|
||||
BOOLEAN MatchSrcIpAddress(S_CLASSIFIER_RULE *pstClassifierRule,ULONG ulSrcIP)
|
||||
BOOLEAN MatchSrcIpAddress(struct bcm_classifier_rule *pstClassifierRule,ULONG ulSrcIP)
|
||||
{
|
||||
UCHAR ucLoopIndex=0;
|
||||
|
||||
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
|
||||
ulSrcIP=ntohl(ulSrcIP);
|
||||
if(0 == pstClassifierRule->ucIPSourceAddressLength)
|
||||
|
@ -58,10 +58,10 @@ BOOLEAN MatchSrcIpAddress(S_CLASSIFIER_RULE *pstClassifierRule,ULONG ulSrcIP)
|
|||
*
|
||||
* Returns - TRUE(If address matches) else FAIL .
|
||||
*********************************************************************/
|
||||
BOOLEAN MatchDestIpAddress(S_CLASSIFIER_RULE *pstClassifierRule,ULONG ulDestIP)
|
||||
BOOLEAN MatchDestIpAddress(struct bcm_classifier_rule *pstClassifierRule,ULONG ulDestIP)
|
||||
{
|
||||
UCHAR ucLoopIndex=0;
|
||||
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
|
||||
ulDestIP=ntohl(ulDestIP);
|
||||
if(0 == pstClassifierRule->ucIPDestinationAddressLength)
|
||||
|
@ -91,10 +91,10 @@ BOOLEAN MatchDestIpAddress(S_CLASSIFIER_RULE *pstClassifierRule,ULONG ulDestIP)
|
|||
*
|
||||
* Returns - TRUE(If address matches) else FAIL.
|
||||
**************************************************************************/
|
||||
BOOLEAN MatchTos(S_CLASSIFIER_RULE *pstClassifierRule,UCHAR ucTypeOfService)
|
||||
BOOLEAN MatchTos(struct bcm_classifier_rule *pstClassifierRule,UCHAR ucTypeOfService)
|
||||
{
|
||||
|
||||
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
if( 3 != pstClassifierRule->ucIPTypeOfServiceLength )
|
||||
return TRUE;
|
||||
|
||||
|
@ -117,10 +117,10 @@ BOOLEAN MatchTos(S_CLASSIFIER_RULE *pstClassifierRule,UCHAR ucTypeOfService)
|
|||
*
|
||||
* Returns - TRUE(If address matches) else FAIL.
|
||||
****************************************************************************/
|
||||
BOOLEAN MatchProtocol(S_CLASSIFIER_RULE *pstClassifierRule,UCHAR ucProtocol)
|
||||
BOOLEAN MatchProtocol(struct bcm_classifier_rule *pstClassifierRule,UCHAR ucProtocol)
|
||||
{
|
||||
UCHAR ucLoopIndex=0;
|
||||
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
if(0 == pstClassifierRule->ucProtocolLength)
|
||||
return TRUE;
|
||||
for(ucLoopIndex=0;ucLoopIndex<pstClassifierRule->ucProtocolLength;ucLoopIndex++)
|
||||
|
@ -146,11 +146,11 @@ BOOLEAN MatchProtocol(S_CLASSIFIER_RULE *pstClassifierRule,UCHAR ucProtocol)
|
|||
*
|
||||
* Returns - TRUE(If address matches) else FAIL.
|
||||
***************************************************************************/
|
||||
BOOLEAN MatchSrcPort(S_CLASSIFIER_RULE *pstClassifierRule,USHORT ushSrcPort)
|
||||
BOOLEAN MatchSrcPort(struct bcm_classifier_rule *pstClassifierRule,USHORT ushSrcPort)
|
||||
{
|
||||
UCHAR ucLoopIndex=0;
|
||||
|
||||
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
|
||||
|
||||
if(0 == pstClassifierRule->ucSrcPortRangeLength)
|
||||
|
@ -178,10 +178,10 @@ BOOLEAN MatchSrcPort(S_CLASSIFIER_RULE *pstClassifierRule,USHORT ushSrcPort)
|
|||
*
|
||||
* Returns - TRUE(If address matches) else FAIL.
|
||||
***************************************************************************/
|
||||
BOOLEAN MatchDestPort(S_CLASSIFIER_RULE *pstClassifierRule,USHORT ushDestPort)
|
||||
BOOLEAN MatchDestPort(struct bcm_classifier_rule *pstClassifierRule,USHORT ushDestPort)
|
||||
{
|
||||
UCHAR ucLoopIndex=0;
|
||||
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
|
||||
if(0 == pstClassifierRule->ucDestPortRangeLength)
|
||||
return TRUE;
|
||||
|
@ -204,9 +204,9 @@ BOOLEAN MatchDestPort(S_CLASSIFIER_RULE *pstClassifierRule,USHORT ushDestPort)
|
|||
Compares IPV4 Ip address and port number
|
||||
@return Queue Index.
|
||||
*/
|
||||
static USHORT IpVersion4(PMINI_ADAPTER Adapter,
|
||||
static USHORT IpVersion4(struct bcm_mini_adapter *Adapter,
|
||||
struct iphdr *iphd,
|
||||
S_CLASSIFIER_RULE *pstClassifierRule )
|
||||
struct bcm_classifier_rule *pstClassifierRule)
|
||||
{
|
||||
xporthdr *xprt_hdr=NULL;
|
||||
BOOLEAN bClassificationSucceed=FALSE;
|
||||
|
@ -302,7 +302,7 @@ static USHORT IpVersion4(PMINI_ADAPTER Adapter,
|
|||
return bClassificationSucceed;
|
||||
}
|
||||
|
||||
VOID PruneQueueAllSF(PMINI_ADAPTER Adapter)
|
||||
VOID PruneQueueAllSF(struct bcm_mini_adapter *Adapter)
|
||||
{
|
||||
UINT iIndex = 0;
|
||||
|
||||
|
@ -323,7 +323,7 @@ is less than number of bytes in the queue. If so -
|
|||
drops packets from the Head till the number of bytes is
|
||||
less than or equal to max queue size for the queue.
|
||||
*/
|
||||
static VOID PruneQueue(PMINI_ADAPTER Adapter, INT iIndex)
|
||||
static VOID PruneQueue(struct bcm_mini_adapter *Adapter, INT iIndex)
|
||||
{
|
||||
struct sk_buff* PacketToDrop=NULL;
|
||||
struct net_device_stats *netstats;
|
||||
|
@ -392,7 +392,7 @@ static VOID PruneQueue(PMINI_ADAPTER Adapter, INT iIndex)
|
|||
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, PRUNE_QUEUE, DBG_LVL_ALL, "<=====");
|
||||
}
|
||||
|
||||
VOID flush_all_queues(PMINI_ADAPTER Adapter)
|
||||
VOID flush_all_queues(struct bcm_mini_adapter *Adapter)
|
||||
{
|
||||
INT iQIndex;
|
||||
UINT uiTotalPacketLength;
|
||||
|
@ -442,10 +442,10 @@ VOID flush_all_queues(PMINI_ADAPTER Adapter)
|
|||
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "<=====");
|
||||
}
|
||||
|
||||
USHORT ClassifyPacket(PMINI_ADAPTER Adapter,struct sk_buff* skb)
|
||||
USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter,struct sk_buff* skb)
|
||||
{
|
||||
INT uiLoopIndex=0;
|
||||
S_CLASSIFIER_RULE *pstClassifierRule = NULL;
|
||||
struct bcm_classifier_rule *pstClassifierRule = NULL;
|
||||
S_ETHCS_PKT_INFO stEthCsPktInfo;
|
||||
PVOID pvEThPayload = NULL;
|
||||
struct iphdr *pIpHeader = NULL;
|
||||
|
@ -631,7 +631,7 @@ USHORT ClassifyPacket(PMINI_ADAPTER Adapter,struct sk_buff* skb)
|
|||
if(bFragmentedPkt && (usCurrFragment == 0))
|
||||
{
|
||||
//First Fragment of Fragmented Packet. Create Frag CLS Entry
|
||||
S_FRAGMENTED_PACKET_INFO stFragPktInfo;
|
||||
struct bcm_fragmented_packet_info stFragPktInfo;
|
||||
stFragPktInfo.bUsed = TRUE;
|
||||
stFragPktInfo.ulSrcIpAddress = pIpHeader->saddr;
|
||||
stFragPktInfo.usIpIdentification = pIpHeader->id;
|
||||
|
@ -649,10 +649,10 @@ USHORT ClassifyPacket(PMINI_ADAPTER Adapter,struct sk_buff* skb)
|
|||
return INVALID_QUEUE_INDEX;
|
||||
}
|
||||
|
||||
static BOOLEAN EthCSMatchSrcMACAddress(S_CLASSIFIER_RULE *pstClassifierRule,PUCHAR Mac)
|
||||
static BOOLEAN EthCSMatchSrcMACAddress(struct bcm_classifier_rule *pstClassifierRule,PUCHAR Mac)
|
||||
{
|
||||
UINT i=0;
|
||||
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
if(pstClassifierRule->ucEthCSSrcMACLen==0)
|
||||
return TRUE;
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s \n",__FUNCTION__);
|
||||
|
@ -666,10 +666,10 @@ static BOOLEAN EthCSMatchSrcMACAddress(S_CLASSIFIER_RULE *pstClassifierRule,PUCH
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOLEAN EthCSMatchDestMACAddress(S_CLASSIFIER_RULE *pstClassifierRule,PUCHAR Mac)
|
||||
static BOOLEAN EthCSMatchDestMACAddress(struct bcm_classifier_rule *pstClassifierRule,PUCHAR Mac)
|
||||
{
|
||||
UINT i=0;
|
||||
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
if(pstClassifierRule->ucEthCSDestMACLen==0)
|
||||
return TRUE;
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s \n",__FUNCTION__);
|
||||
|
@ -683,9 +683,9 @@ static BOOLEAN EthCSMatchDestMACAddress(S_CLASSIFIER_RULE *pstClassifierRule,PUC
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOLEAN EthCSMatchEThTypeSAP(S_CLASSIFIER_RULE *pstClassifierRule,struct sk_buff* skb,PS_ETHCS_PKT_INFO pstEthCsPktInfo)
|
||||
static BOOLEAN EthCSMatchEThTypeSAP(struct bcm_classifier_rule *pstClassifierRule,struct sk_buff* skb,PS_ETHCS_PKT_INFO pstEthCsPktInfo)
|
||||
{
|
||||
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
if((pstClassifierRule->ucEtherTypeLen==0)||
|
||||
(pstClassifierRule->au8EthCSEtherType[0] == 0))
|
||||
return TRUE;
|
||||
|
@ -718,12 +718,12 @@ static BOOLEAN EthCSMatchEThTypeSAP(S_CLASSIFIER_RULE *pstClassifierRule,struct
|
|||
|
||||
}
|
||||
|
||||
static BOOLEAN EthCSMatchVLANRules(S_CLASSIFIER_RULE *pstClassifierRule,struct sk_buff* skb,PS_ETHCS_PKT_INFO pstEthCsPktInfo)
|
||||
static BOOLEAN EthCSMatchVLANRules(struct bcm_classifier_rule *pstClassifierRule,struct sk_buff* skb,PS_ETHCS_PKT_INFO pstEthCsPktInfo)
|
||||
{
|
||||
BOOLEAN bClassificationSucceed = FALSE;
|
||||
USHORT usVLANID;
|
||||
B_UINT8 uPriority = 0;
|
||||
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
|
||||
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s CLS UserPrio:%x CLS VLANID:%x\n",__FUNCTION__,ntohs(*((USHORT *)pstClassifierRule->usUserPriority)),pstClassifierRule->usVLANID);
|
||||
|
||||
|
@ -733,7 +733,7 @@ static BOOLEAN EthCSMatchVLANRules(S_CLASSIFIER_RULE *pstClassifierRule,struct s
|
|||
if(pstEthCsPktInfo->eNwpktEthFrameType!=eEth802QVLANFrame)
|
||||
return FALSE;
|
||||
|
||||
uPriority = (ntohs(*(USHORT *)(skb->data + sizeof(ETH_HEADER_STRUC))) & 0xF000) >> 13;
|
||||
uPriority = (ntohs(*(USHORT *)(skb->data + sizeof(struct bcm_eth_header))) & 0xF000) >> 13;
|
||||
|
||||
if((uPriority >= pstClassifierRule->usUserPriority[0]) && (uPriority <= pstClassifierRule->usUserPriority[1]))
|
||||
bClassificationSucceed = TRUE;
|
||||
|
@ -751,7 +751,7 @@ static BOOLEAN EthCSMatchVLANRules(S_CLASSIFIER_RULE *pstClassifierRule,struct s
|
|||
if(pstEthCsPktInfo->eNwpktEthFrameType!=eEth802QVLANFrame)
|
||||
return FALSE;
|
||||
|
||||
usVLANID = ntohs(*(USHORT *)(skb->data + sizeof(ETH_HEADER_STRUC))) & 0xFFF;
|
||||
usVLANID = ntohs(*(USHORT *)(skb->data + sizeof(struct bcm_eth_header))) & 0xFFF;
|
||||
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s Pkt VLANID %x Priority: %d\n",__FUNCTION__,usVLANID, uPriority);
|
||||
|
||||
|
@ -768,18 +768,18 @@ static BOOLEAN EthCSMatchVLANRules(S_CLASSIFIER_RULE *pstClassifierRule,struct s
|
|||
}
|
||||
|
||||
|
||||
static BOOLEAN EThCSClassifyPkt(PMINI_ADAPTER Adapter,struct sk_buff* skb,
|
||||
static BOOLEAN EThCSClassifyPkt(struct bcm_mini_adapter *Adapter,struct sk_buff* skb,
|
||||
PS_ETHCS_PKT_INFO pstEthCsPktInfo,
|
||||
S_CLASSIFIER_RULE *pstClassifierRule,
|
||||
struct bcm_classifier_rule *pstClassifierRule,
|
||||
B_UINT8 EthCSCupport)
|
||||
{
|
||||
BOOLEAN bClassificationSucceed = FALSE;
|
||||
bClassificationSucceed = EthCSMatchSrcMACAddress(pstClassifierRule,((ETH_HEADER_STRUC *)(skb->data))->au8SourceAddress);
|
||||
bClassificationSucceed = EthCSMatchSrcMACAddress(pstClassifierRule,((struct bcm_eth_header *)(skb->data))->au8SourceAddress);
|
||||
if(!bClassificationSucceed)
|
||||
return FALSE;
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ETH CS SrcMAC Matched\n");
|
||||
|
||||
bClassificationSucceed = EthCSMatchDestMACAddress(pstClassifierRule,((ETH_HEADER_STRUC*)(skb->data))->au8DestinationAddress);
|
||||
bClassificationSucceed = EthCSMatchDestMACAddress(pstClassifierRule,((struct bcm_eth_header *)(skb->data))->au8DestinationAddress);
|
||||
if(!bClassificationSucceed)
|
||||
return FALSE;
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ETH CS DestMAC Matched\n");
|
||||
|
@ -801,10 +801,10 @@ static BOOLEAN EThCSClassifyPkt(PMINI_ADAPTER Adapter,struct sk_buff* skb,
|
|||
return bClassificationSucceed;
|
||||
}
|
||||
|
||||
static void EThCSGetPktInfo(PMINI_ADAPTER Adapter,PVOID pvEthPayload,
|
||||
static void EThCSGetPktInfo(struct bcm_mini_adapter *Adapter,PVOID pvEthPayload,
|
||||
PS_ETHCS_PKT_INFO pstEthCsPktInfo)
|
||||
{
|
||||
USHORT u16Etype = ntohs(((ETH_HEADER_STRUC*)pvEthPayload)->u16Etype);
|
||||
USHORT u16Etype = ntohs(((struct bcm_eth_header *)pvEthPayload)->u16Etype);
|
||||
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "EthCSGetPktInfo : Eth Hdr Type : %X\n",u16Etype);
|
||||
if(u16Etype > 0x5dc)
|
||||
|
@ -845,7 +845,7 @@ static void EThCSGetPktInfo(PMINI_ADAPTER Adapter,PVOID pvEthPayload,
|
|||
else
|
||||
pstEthCsPktInfo->eNwpktIPFrameType = eNonIPPacket;
|
||||
|
||||
pstEthCsPktInfo->usEtherType = ((ETH_HEADER_STRUC*)pvEthPayload)->u16Etype;
|
||||
pstEthCsPktInfo->usEtherType = ((struct bcm_eth_header *)pvEthPayload)->u16Etype;
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "EthCsPktInfo->eNwpktIPFrameType : %x\n",pstEthCsPktInfo->eNwpktIPFrameType);
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "EthCsPktInfo->eNwpktEthFrameType : %x\n",pstEthCsPktInfo->eNwpktEthFrameType);
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "EthCsPktInfo->usEtherType : %x\n",pstEthCsPktInfo->usEtherType);
|
||||
|
|
|
@ -41,9 +41,9 @@ SendPacketFromQueue->SetupNextSend->bcm_cmd53
|
|||
This function dispatches control packet to the h/w interface
|
||||
@return zero(success) or -ve value(failure)
|
||||
*/
|
||||
INT SendControlPacket(PMINI_ADAPTER Adapter, char *pControlPacket)
|
||||
INT SendControlPacket(struct bcm_mini_adapter *Adapter, char *pControlPacket)
|
||||
{
|
||||
PLEADER PLeader = (PLEADER)pControlPacket;
|
||||
struct bcm_leader *PLeader = (struct bcm_leader *)pControlPacket;
|
||||
|
||||
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Tx");
|
||||
if(!pControlPacket || !Adapter)
|
||||
|
@ -84,13 +84,13 @@ This function despatches the IP packets with the given vcid
|
|||
to the target via the host h/w interface.
|
||||
@return zero(success) or -ve value(failure)
|
||||
*/
|
||||
INT SetupNextSend(PMINI_ADAPTER Adapter, struct sk_buff *Packet, USHORT Vcid)
|
||||
INT SetupNextSend(struct bcm_mini_adapter *Adapter, struct sk_buff *Packet, USHORT Vcid)
|
||||
{
|
||||
int status=0;
|
||||
BOOLEAN bHeaderSupressionEnabled = FALSE;
|
||||
B_UINT16 uiClassifierRuleID;
|
||||
u16 QueueIndex = skb_get_queue_mapping(Packet);
|
||||
LEADER Leader={0};
|
||||
struct bcm_leader Leader={0};
|
||||
|
||||
if(Packet->len > MAX_DEVICE_DESC_SIZE)
|
||||
{
|
||||
|
@ -143,7 +143,7 @@ INT SetupNextSend(PMINI_ADAPTER Adapter, struct sk_buff *Packet, USHORT Vcid)
|
|||
else
|
||||
{
|
||||
Leader.PLength = Packet->len - ETH_HLEN;
|
||||
memcpy((LEADER*)skb_pull(Packet, (ETH_HLEN - LEADER_SIZE)), &Leader, LEADER_SIZE);
|
||||
memcpy((struct bcm_leader *)skb_pull(Packet, (ETH_HLEN - LEADER_SIZE)), &Leader, LEADER_SIZE);
|
||||
}
|
||||
|
||||
status = Adapter->interface_transmit(Adapter->pvInterfaceAdapter,
|
||||
|
@ -180,7 +180,7 @@ INT SetupNextSend(PMINI_ADAPTER Adapter, struct sk_buff *Packet, USHORT Vcid)
|
|||
return status;
|
||||
}
|
||||
|
||||
static int tx_pending(PMINI_ADAPTER Adapter)
|
||||
static int tx_pending(struct bcm_mini_adapter *Adapter)
|
||||
{
|
||||
return (atomic_read(&Adapter->TxPktAvail)
|
||||
&& MINIMUM_PENDING_DESCRIPTORS < atomic_read(&Adapter->CurrNumFreeTxDesc))
|
||||
|
@ -191,7 +191,7 @@ static int tx_pending(PMINI_ADAPTER Adapter)
|
|||
@ingroup tx_functions
|
||||
Transmit thread
|
||||
*/
|
||||
int tx_pkt_handler(PMINI_ADAPTER Adapter /**< pointer to adapter object*/
|
||||
int tx_pkt_handler(struct bcm_mini_adapter *Adapter /**< pointer to adapter object*/
|
||||
)
|
||||
{
|
||||
int status = 0;
|
||||
|
|
|
@ -117,7 +117,7 @@ typedef struct _stPhsRuleSI {
|
|||
B_UINT8 u8PHSM[MAX_PHS_LENGTHS];
|
||||
/** 8bit Total number of bytes to be suppressed for the Service Flow*/
|
||||
B_UINT8 u8PHSS;
|
||||
/** 8bit Indicates whether or not Packet Header contents need to be verified prior to supression */
|
||||
/** 8bit Indicates whether or not Packet Header contents need to be verified prior to suppression */
|
||||
B_UINT8 u8PHSV;
|
||||
/** Vendor Specific PHS param Length Of The Service Flow*/
|
||||
B_UINT8 u8VendorSpecificPHSParamsLength;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include "headers.h"
|
||||
|
||||
INT ProcessGetHostMibs(PMINI_ADAPTER Adapter, S_MIBS_HOST_STATS_MIBS *pstHostMibs)
|
||||
INT ProcessGetHostMibs(struct bcm_mini_adapter *Adapter, S_MIBS_HOST_STATS_MIBS *pstHostMibs)
|
||||
{
|
||||
S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL;
|
||||
S_PHS_RULE *pstPhsRule = NULL;
|
||||
|
@ -94,14 +94,14 @@ INT ProcessGetHostMibs(PMINI_ADAPTER Adapter, S_MIBS_HOST_STATS_MIBS *pstHostMib
|
|||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
VOID GetDroppedAppCntrlPktMibs(S_MIBS_HOST_STATS_MIBS *pstHostMibs, const PPER_TARANG_DATA pTarang)
|
||||
VOID GetDroppedAppCntrlPktMibs(S_MIBS_HOST_STATS_MIBS *pstHostMibs, struct bcm_tarang_data *pTarang)
|
||||
{
|
||||
memcpy(&(pstHostMibs->stDroppedAppCntrlMsgs),
|
||||
&(pTarang->stDroppedAppCntrlMsgs),
|
||||
sizeof(S_MIBS_DROPPED_APP_CNTRL_MESSAGES));
|
||||
}
|
||||
|
||||
VOID CopyMIBSExtendedSFParameters(PMINI_ADAPTER Adapter, CServiceFlowParamSI *psfLocalSet, UINT uiSearchRuleIndex)
|
||||
VOID CopyMIBSExtendedSFParameters(struct bcm_mini_adapter *Adapter, CServiceFlowParamSI *psfLocalSet, UINT uiSearchRuleIndex)
|
||||
{
|
||||
S_MIBS_EXTSERVICEFLOW_PARAMETERS *t = &Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable;
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ static B_UINT16 CFG_CalculateChecksum(B_UINT8 *pu8Buffer, B_UINT32 u32Size)
|
|||
return u16CheckSum;
|
||||
}
|
||||
|
||||
BOOLEAN IsReqGpioIsLedInNVM(PMINI_ADAPTER Adapter, UINT gpios)
|
||||
BOOLEAN IsReqGpioIsLedInNVM(struct bcm_mini_adapter *Adapter, UINT gpios)
|
||||
{
|
||||
INT Status;
|
||||
Status = (Adapter->gpioBitMap & gpios) ^ gpios;
|
||||
|
@ -23,7 +23,7 @@ BOOLEAN IsReqGpioIsLedInNVM(PMINI_ADAPTER Adapter, UINT gpios)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static INT LED_Blink(PMINI_ADAPTER Adapter, UINT GPIO_Num, UCHAR uiLedIndex,
|
||||
static INT LED_Blink(struct bcm_mini_adapter *Adapter, UINT GPIO_Num, UCHAR uiLedIndex,
|
||||
ULONG timeout, INT num_of_time, LedEventInfo_t currdriverstate)
|
||||
{
|
||||
int Status = STATUS_SUCCESS;
|
||||
|
@ -95,7 +95,7 @@ static INT ScaleRateofTransfer(ULONG rate)
|
|||
|
||||
|
||||
|
||||
static INT LED_Proportional_Blink(PMINI_ADAPTER Adapter, UCHAR GPIO_Num_tx,
|
||||
static INT LED_Proportional_Blink(struct bcm_mini_adapter *Adapter, UCHAR GPIO_Num_tx,
|
||||
UCHAR uiTxLedIndex, UCHAR GPIO_Num_rx, UCHAR uiRxLedIndex,
|
||||
LedEventInfo_t currdriverstate)
|
||||
{
|
||||
|
@ -261,7 +261,7 @@ static INT LED_Proportional_Blink(PMINI_ADAPTER Adapter, UCHAR GPIO_Num_tx,
|
|||
* <OSAL_STATUS_CODE>
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
static INT ValidateDSDParamsChecksum(PMINI_ADAPTER Adapter, ULONG ulParamOffset,
|
||||
static INT ValidateDSDParamsChecksum(struct bcm_mini_adapter *Adapter, ULONG ulParamOffset,
|
||||
USHORT usParamLen)
|
||||
{
|
||||
INT Status = STATUS_SUCCESS;
|
||||
|
@ -347,7 +347,7 @@ static INT ValidateDSDParamsChecksum(PMINI_ADAPTER Adapter, ULONG ulParamOffset,
|
|||
* <OSAL_STATUS_CODE>
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
static INT ValidateHWParmStructure(PMINI_ADAPTER Adapter, ULONG ulHwParamOffset)
|
||||
static INT ValidateHWParmStructure(struct bcm_mini_adapter *Adapter, ULONG ulHwParamOffset)
|
||||
{
|
||||
|
||||
INT Status = STATUS_SUCCESS;
|
||||
|
@ -371,7 +371,7 @@ static INT ValidateHWParmStructure(PMINI_ADAPTER Adapter, ULONG ulHwParamOffset)
|
|||
return Status;
|
||||
} /* ValidateHWParmStructure() */
|
||||
|
||||
static int ReadLEDInformationFromEEPROM(PMINI_ADAPTER Adapter,
|
||||
static int ReadLEDInformationFromEEPROM(struct bcm_mini_adapter *Adapter,
|
||||
UCHAR GPIO_Array[])
|
||||
{
|
||||
int Status = STATUS_SUCCESS;
|
||||
|
@ -477,7 +477,7 @@ static int ReadLEDInformationFromEEPROM(PMINI_ADAPTER Adapter,
|
|||
}
|
||||
|
||||
|
||||
static int ReadConfigFileStructure(PMINI_ADAPTER Adapter,
|
||||
static int ReadConfigFileStructure(struct bcm_mini_adapter *Adapter,
|
||||
BOOLEAN *bEnableThread)
|
||||
{
|
||||
int Status = STATUS_SUCCESS;
|
||||
|
@ -580,7 +580,7 @@ static int ReadConfigFileStructure(PMINI_ADAPTER Adapter,
|
|||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
static VOID LedGpioInit(PMINI_ADAPTER Adapter)
|
||||
static VOID LedGpioInit(struct bcm_mini_adapter *Adapter)
|
||||
{
|
||||
UINT uiResetValue = 0;
|
||||
UINT uiIndex = 0;
|
||||
|
@ -605,7 +605,7 @@ static VOID LedGpioInit(PMINI_ADAPTER Adapter)
|
|||
Adapter->LEDInfo.bIdle_led_off = FALSE;
|
||||
}
|
||||
|
||||
static INT BcmGetGPIOPinInfo(PMINI_ADAPTER Adapter, UCHAR *GPIO_num_tx,
|
||||
static INT BcmGetGPIOPinInfo(struct bcm_mini_adapter *Adapter, UCHAR *GPIO_num_tx,
|
||||
UCHAR *GPIO_num_rx, UCHAR *uiLedTxIndex, UCHAR *uiLedRxIndex,
|
||||
LedEventInfo_t currdriverstate)
|
||||
{
|
||||
|
@ -645,7 +645,7 @@ static INT BcmGetGPIOPinInfo(PMINI_ADAPTER Adapter, UCHAR *GPIO_num_tx,
|
|||
}
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
static VOID LEDControlThread(PMINI_ADAPTER Adapter)
|
||||
static VOID LEDControlThread(struct bcm_mini_adapter *Adapter)
|
||||
{
|
||||
UINT uiIndex = 0;
|
||||
UCHAR GPIO_num = 0;
|
||||
|
@ -857,7 +857,7 @@ static VOID LEDControlThread(PMINI_ADAPTER Adapter)
|
|||
Adapter->LEDInfo.led_thread_running = BCM_LED_THREAD_DISABLED;
|
||||
}
|
||||
|
||||
int InitLedSettings(PMINI_ADAPTER Adapter)
|
||||
int InitLedSettings(struct bcm_mini_adapter *Adapter)
|
||||
{
|
||||
int Status = STATUS_SUCCESS;
|
||||
BOOLEAN bEnableThread = TRUE;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -13,8 +13,8 @@
|
|||
|
||||
static int compare_packet_info(void const *a, void const *b)
|
||||
{
|
||||
PacketInfo const *pa = a;
|
||||
PacketInfo const *pb = b;
|
||||
struct bcm_packet_info const *pa = a;
|
||||
struct bcm_packet_info const *pb = b;
|
||||
|
||||
if (!pa->bValid || !pb->bValid)
|
||||
return 0;
|
||||
|
@ -22,19 +22,19 @@ static int compare_packet_info(void const *a, void const *b)
|
|||
return pa->u8TrafficPriority - pb->u8TrafficPriority;
|
||||
}
|
||||
|
||||
VOID SortPackInfo(PMINI_ADAPTER Adapter)
|
||||
VOID SortPackInfo(struct bcm_mini_adapter *Adapter)
|
||||
{
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG,
|
||||
DBG_LVL_ALL, "<=======");
|
||||
|
||||
sort(Adapter->PackInfo, NO_OF_QUEUES, sizeof(PacketInfo),
|
||||
sort(Adapter->PackInfo, NO_OF_QUEUES, sizeof(struct bcm_packet_info),
|
||||
compare_packet_info, NULL);
|
||||
}
|
||||
|
||||
static int compare_classifiers(void const *a, void const *b)
|
||||
{
|
||||
S_CLASSIFIER_RULE const *pa = a;
|
||||
S_CLASSIFIER_RULE const *pb = b;
|
||||
struct bcm_classifier_rule const *pa = a;
|
||||
struct bcm_classifier_rule const *pb = b;
|
||||
|
||||
if (!pa->bUsed || !pb->bUsed)
|
||||
return 0;
|
||||
|
@ -42,11 +42,11 @@ static int compare_classifiers(void const *a, void const *b)
|
|||
return pa->u8ClassifierRulePriority - pb->u8ClassifierRulePriority;
|
||||
}
|
||||
|
||||
VOID SortClassifiers(PMINI_ADAPTER Adapter)
|
||||
VOID SortClassifiers(struct bcm_mini_adapter *Adapter)
|
||||
{
|
||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG,
|
||||
DBG_LVL_ALL, "<=======");
|
||||
|
||||
sort(Adapter->astClassifierTable, MAX_CLASSIFIERS,
|
||||
sizeof(S_CLASSIFIER_RULE), compare_classifiers, NULL);
|
||||
sizeof(struct bcm_classifier_rule), compare_classifiers, NULL);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ INT vendorextnGetSectionInfo(PVOID pContext,PFLASH2X_VENDORSPECIFIC_INFO pVendo
|
|||
// STATUS_SUCCESS/STATUS_FAILURE
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
INT vendorextnInit(PMINI_ADAPTER Adapter)
|
||||
INT vendorextnInit(struct bcm_mini_adapter *Adapter)
|
||||
{
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ INT vendorextnInit(PMINI_ADAPTER Adapter)
|
|||
// STATUS_SUCCESS/STATUS_FAILURE
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
INT vendorextnExit(PMINI_ADAPTER Adapter)
|
||||
INT vendorextnExit(struct bcm_mini_adapter *Adapter)
|
||||
{
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ INT vendorextnExit(PMINI_ADAPTER Adapter)
|
|||
// STATUS_SUCCESS/STATUS_FAILURE as per the IOCTL return value
|
||||
//
|
||||
//--------------------------------------------------------------------------
|
||||
INT vendorextnIoctl(PMINI_ADAPTER Adapter, UINT cmd, ULONG arg)
|
||||
INT vendorextnIoctl(struct bcm_mini_adapter *Adapter, UINT cmd, ULONG arg)
|
||||
{
|
||||
return CONTINUE_COMMON_PATH;
|
||||
}
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
#define CONTINUE_COMMON_PATH 0xFFFF
|
||||
|
||||
INT vendorextnGetSectionInfo(PVOID pContext,PFLASH2X_VENDORSPECIFIC_INFO pVendorInfo);
|
||||
INT vendorextnExit(PMINI_ADAPTER Adapter);
|
||||
INT vendorextnInit(PMINI_ADAPTER Adapter);
|
||||
INT vendorextnIoctl(PMINI_ADAPTER Adapter, UINT cmd, ULONG arg);
|
||||
INT vendorextnExit(struct bcm_mini_adapter *Adapter);
|
||||
INT vendorextnInit(struct bcm_mini_adapter *Adapter);
|
||||
INT vendorextnIoctl(struct bcm_mini_adapter *Adapter, UINT cmd, ULONG arg);
|
||||
INT vendorextnReadSection(PVOID pContext, PUCHAR pBuffer, FLASH2X_SECTION_VAL SectionVal,
|
||||
UINT offset, UINT numOfBytes);
|
||||
INT vendorextnWriteSection(PVOID pContext, PUCHAR pBuffer, FLASH2X_SECTION_VAL SectionVal,
|
||||
|
|
|
@ -2,7 +2,7 @@ if USB_GADGET
|
|||
|
||||
config USB_G_CCG
|
||||
tristate "Configurable Composite Gadget (STAGING)"
|
||||
depends on STAGING && !USB_ZERO && !USB_ZERO_HNPTEST && !USB_AUDIO && !GADGET_UAC1 && !USB_ETH && !USB_ETH_RNDIS && !USB_ETH_EEM && !USB_G_NCM && !USB_GADGETFS && !USB_FUNCTIONFS && !USB_FUNCTIONFS_ETH && !USB_FUNCTIONFS_RNDIS && !USB_FUNCTIONFS_GENERIC && !USB_FILE_STORAGE && !USB_FILE_STORAGE_TEST && !USB_MASS_STORAGE && !USB_G_SERIAL && !USB_MIDI_GADGET && !USB_G_PRINTER && !USB_CDC_COMPOSITE && !USB_G_NOKIA && !USB_G_ACM_MS && !USB_G_MULTI && !USB_G_MULTI_RNDIS && !USB_G_MULTI_CDC && !USB_G_HID && !USB_G_DBGP && !USB_G_WEBCAM
|
||||
depends on STAGING && BLOCK && !USB_ZERO && !USB_ZERO_HNPTEST && !USB_AUDIO && !GADGET_UAC1 && !USB_ETH && !USB_ETH_RNDIS && !USB_ETH_EEM && !USB_G_NCM && !USB_GADGETFS && !USB_FUNCTIONFS && !USB_FUNCTIONFS_ETH && !USB_FUNCTIONFS_RNDIS && !USB_FUNCTIONFS_GENERIC && !USB_FILE_STORAGE && !USB_FILE_STORAGE_TEST && !USB_MASS_STORAGE && !USB_G_SERIAL && !USB_MIDI_GADGET && !USB_G_PRINTER && !USB_CDC_COMPOSITE && !USB_G_NOKIA && !USB_G_ACM_MS && !USB_G_MULTI && !USB_G_MULTI_RNDIS && !USB_G_MULTI_CDC && !USB_G_HID && !USB_G_DBGP && !USB_G_WEBCAM
|
||||
help
|
||||
The Configurable Composite Gadget supports multiple USB
|
||||
functions: acm, mass storage, rndis and FunctionFS.
|
||||
|
|
|
@ -564,9 +564,7 @@ static int rndis_function_bind_config(struct ccg_usb_function *f,
|
|||
return -1;
|
||||
}
|
||||
|
||||
pr_info("%s MAC: %02X:%02X:%02X:%02X:%02X:%02X\n", __func__,
|
||||
rndis->ethaddr[0], rndis->ethaddr[1], rndis->ethaddr[2],
|
||||
rndis->ethaddr[3], rndis->ethaddr[4], rndis->ethaddr[5]);
|
||||
pr_info("%s MAC: %pM\n", __func__, rndis->ethaddr);
|
||||
|
||||
ret = gether_setup_name(c->cdev->gadget, rndis->ethaddr, "rndis");
|
||||
if (ret) {
|
||||
|
@ -654,9 +652,7 @@ static ssize_t rndis_ethaddr_show(struct device *dev,
|
|||
{
|
||||
struct ccg_usb_function *f = dev_get_drvdata(dev);
|
||||
struct rndis_function_config *rndis = f->config;
|
||||
return sprintf(buf, "%02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
rndis->ethaddr[0], rndis->ethaddr[1], rndis->ethaddr[2],
|
||||
rndis->ethaddr[3], rndis->ethaddr[4], rndis->ethaddr[5]);
|
||||
return sprintf(buf, "%pM\n", rndis->ethaddr);
|
||||
}
|
||||
|
||||
static ssize_t rndis_ethaddr_store(struct device *dev,
|
||||
|
@ -1143,7 +1139,7 @@ static int ccg_bind(struct usb_composite_dev *cdev)
|
|||
if (gcnum >= 0)
|
||||
device_desc.bcdDevice = cpu_to_le16(0x0200 + gcnum);
|
||||
else {
|
||||
pr_warning("%s: controller '%s' not recognized\n",
|
||||
pr_warn("%s: controller '%s' not recognized\n",
|
||||
longname, gadget->name);
|
||||
device_desc.bcdDevice = __constant_cpu_to_le16(0x9999);
|
||||
}
|
||||
|
|
|
@ -6,9 +6,10 @@ config COMEDI
|
|||
Enable support a wide range of data acquisition devices
|
||||
for Linux.
|
||||
|
||||
if COMEDI
|
||||
|
||||
config COMEDI_DEBUG
|
||||
bool "Comedi debugging"
|
||||
depends on COMEDI != n
|
||||
---help---
|
||||
This is an option for use by developers; most people should
|
||||
say N here. This enables comedi core and driver debugging.
|
||||
|
@ -16,7 +17,6 @@ config COMEDI_DEBUG
|
|||
config COMEDI_DEFAULT_BUF_SIZE_KB
|
||||
int "Comedi default initial asynchronous buffer size in KiB"
|
||||
default "2048"
|
||||
depends on COMEDI != n
|
||||
---help---
|
||||
This is the default asynchronous buffer size which is used for
|
||||
commands running in the background in kernel space. This
|
||||
|
@ -26,7 +26,6 @@ config COMEDI_DEFAULT_BUF_SIZE_KB
|
|||
config COMEDI_DEFAULT_BUF_MAXSIZE_KB
|
||||
int "Comedi default maximum asynchronous buffer size in KiB"
|
||||
default "20480"
|
||||
depends on COMEDI != n
|
||||
---help---
|
||||
This is the default maximum asynchronous buffer size which can
|
||||
be requested by a userspace program without root privileges.
|
||||
|
@ -34,8 +33,7 @@ config COMEDI_DEFAULT_BUF_MAXSIZE_KB
|
|||
channels running at 100 kHz has 2-4 seconds of buffer.
|
||||
|
||||
menuconfig COMEDI_MISC_DRIVERS
|
||||
tristate "Comedi misc drivers"
|
||||
depends on COMEDI
|
||||
bool "Comedi misc drivers"
|
||||
---help---
|
||||
Enable comedi misc drivers to be built
|
||||
|
||||
|
@ -102,8 +100,8 @@ config COMEDI_SKEL
|
|||
endif # COMEDI_MISC_DRIVERS
|
||||
|
||||
menuconfig COMEDI_ISA_DRIVERS
|
||||
tristate "Comedi ISA and PC/104 drivers"
|
||||
depends on COMEDI && ISA
|
||||
bool "Comedi ISA and PC/104 drivers"
|
||||
depends on ISA
|
||||
---help---
|
||||
Enable comedi ISA and PC/104 drivers to be built
|
||||
|
||||
|
@ -111,7 +109,7 @@ menuconfig COMEDI_ISA_DRIVERS
|
|||
kernel: saying N will just cause the configurator to skip all
|
||||
the questions about ISA and PC/104 comedi drivers.
|
||||
|
||||
if COMEDI_ISA_DRIVERS && ISA
|
||||
if COMEDI_ISA_DRIVERS
|
||||
|
||||
config COMEDI_ACL7225B
|
||||
tristate "ADlink NuDAQ ACL-7225b and compatibles support"
|
||||
|
@ -215,7 +213,6 @@ config COMEDI_PCM3730
|
|||
config COMEDI_AMPLC_DIO200_ISA
|
||||
tristate "Amplicon PC212E/PC214E/PC215E/PC218E/PC272E"
|
||||
select COMEDI_AMPLC_DIO200
|
||||
depends on COMEDI_ISA_DRIVERS
|
||||
---help---
|
||||
Enable support for Amplicon PC212E, PC214E, PC215E, PC218E and
|
||||
PC272E ISA DIO boards
|
||||
|
@ -447,7 +444,6 @@ config COMEDI_ADQ12B
|
|||
|
||||
config COMEDI_NI_AT_A2150
|
||||
tristate "NI AT-A2150 ISA card support"
|
||||
depends on COMEDI_NI_COMMON
|
||||
depends on VIRT_TO_BUS
|
||||
---help---
|
||||
Enable support for National Instruments AT-A2150 cards
|
||||
|
@ -457,7 +453,6 @@ config COMEDI_NI_AT_A2150
|
|||
|
||||
config COMEDI_NI_AT_AO
|
||||
tristate "NI AT-AO-6/10 EISA card support"
|
||||
depends on COMEDI_NI_COMMON
|
||||
---help---
|
||||
Enable support for National Instruments AT-AO-6/10 cards
|
||||
|
||||
|
@ -466,8 +461,9 @@ config COMEDI_NI_AT_AO
|
|||
|
||||
config COMEDI_NI_ATMIO
|
||||
tristate "NI AT-MIO E series ISA-PNP card support"
|
||||
depends on ISAPNP && COMEDI_NI_TIO && COMEDI_NI_COMMON
|
||||
depends on ISAPNP
|
||||
select COMEDI_8255
|
||||
select COMEDI_NI_TIO
|
||||
---help---
|
||||
Enable support for National Instruments AT-MIO E series cards
|
||||
National Instruments AT-MIO-16E-1 (ni_atmio),
|
||||
|
@ -479,7 +475,7 @@ config COMEDI_NI_ATMIO
|
|||
|
||||
config COMEDI_NI_ATMIO16D
|
||||
tristate "NI AT-MIO16/AT-MIO16D series ISA-PNP card support"
|
||||
depends on ISAPNP && COMEDI_NI_COMMON
|
||||
depends on ISAPNP
|
||||
select COMEDI_8255
|
||||
---help---
|
||||
Enable support for National Instruments AT-MIO16/AT-MIO16D cards.
|
||||
|
@ -542,8 +538,8 @@ config COMEDI_POC
|
|||
endif # COMEDI_ISA_DRIVERS
|
||||
|
||||
menuconfig COMEDI_PCI_DRIVERS
|
||||
tristate "Comedi PCI drivers"
|
||||
depends on COMEDI && PCI
|
||||
bool "Comedi PCI drivers"
|
||||
depends on PCI
|
||||
---help---
|
||||
Enable comedi PCI drivers to be built
|
||||
|
||||
|
@ -551,7 +547,7 @@ menuconfig COMEDI_PCI_DRIVERS
|
|||
kernel: saying N will just cause the configurator to skip all
|
||||
the questions about PCI comedi drivers.
|
||||
|
||||
if COMEDI_PCI_DRIVERS && PCI
|
||||
if COMEDI_PCI_DRIVERS
|
||||
|
||||
config COMEDI_ADDI_APCI_035
|
||||
tristate "ADDI-DATA APCI_035 support"
|
||||
|
@ -674,7 +670,6 @@ config COMEDI_ADDI_APCI_3XXX
|
|||
|
||||
config COMEDI_ADL_PCI6208
|
||||
tristate "ADLink PCI-6208A support"
|
||||
select COMEDI_8255
|
||||
---help---
|
||||
Enable support for ADLink PCI-6208A cards
|
||||
|
||||
|
@ -691,6 +686,7 @@ config COMEDI_ADL_PCI7230
|
|||
|
||||
config COMEDI_ADL_PCI7296
|
||||
tristate "ADLink PCI-7296 96 ch. digital io board support"
|
||||
select COMEDI_8255
|
||||
---help---
|
||||
Enable support for ADlink PCI-7296 96 ch. digital io board support
|
||||
|
||||
|
@ -988,7 +984,7 @@ config COMEDI_ME_DAQ
|
|||
|
||||
config COMEDI_NI_6527
|
||||
tristate "NI 6527 support"
|
||||
depends on COMEDI_MITE
|
||||
select COMEDI_MITE
|
||||
---help---
|
||||
Enable support for the National Instruments 6527 PCI card
|
||||
|
||||
|
@ -997,7 +993,7 @@ config COMEDI_NI_6527
|
|||
|
||||
config COMEDI_NI_65XX
|
||||
tristate "NI 65xx static dio PCI card support"
|
||||
depends on COMEDI_MITE
|
||||
select COMEDI_MITE
|
||||
---help---
|
||||
Enable support for National Instruments 65xx static dio boards.
|
||||
Supported devices: National Instruments PCI-6509 (ni_65xx),
|
||||
|
@ -1010,7 +1006,7 @@ config COMEDI_NI_65XX
|
|||
|
||||
config COMEDI_NI_660X
|
||||
tristate "NI 660x counter/timer PCI card support"
|
||||
depends on COMEDI_NI_TIO && COMEDI_NI_COMMON
|
||||
select COMEDI_NI_TIOCMD
|
||||
---help---
|
||||
Enable support for National Instruments PCI-6601 (ni_660x), PCI-6602,
|
||||
PXI-6602 and PXI-6608.
|
||||
|
@ -1020,16 +1016,31 @@ config COMEDI_NI_660X
|
|||
|
||||
config COMEDI_NI_670X
|
||||
tristate "NI 670x PCI card support"
|
||||
depends on COMEDI_MITE
|
||||
select COMEDI_MITE
|
||||
---help---
|
||||
Enable support for National Instruments PCI-6703 and PCI-6704
|
||||
|
||||
To compile this driver as a module, choose M here: the module will be
|
||||
called ni_670x.
|
||||
|
||||
config COMEDI_NI_LABPC
|
||||
tristate "NI Lab-PC and compatibles ISA and PCI support"
|
||||
select COMEDI_MITE
|
||||
select COMEDI_8255
|
||||
select COMEDI_FC
|
||||
depends on VIRT_TO_BUS
|
||||
---help---
|
||||
Enable support for National Instruments Lab-PC and compatibles
|
||||
Lab-PC-1200, Lab-PC-1200AI, Lab-PC+ and PCI-1200.
|
||||
Kernel-level ISA plug-and-play support for the lab-pc-1200 boards has
|
||||
not yet been added to the driver.
|
||||
|
||||
To compile this driver as a module, choose M here: the module will be
|
||||
called ni_labpc.
|
||||
|
||||
config COMEDI_NI_PCIDIO
|
||||
tristate "NI PCI-DIO32HS, PCI-DIO96, PCI-6533, PCI-6503 support"
|
||||
depends on COMEDI_MITE
|
||||
select COMEDI_MITE
|
||||
select COMEDI_8255
|
||||
---help---
|
||||
Enable support for National Instruments PCI-DIO-32HS, PXI-6533,
|
||||
|
@ -1043,7 +1054,7 @@ config COMEDI_NI_PCIDIO
|
|||
|
||||
config COMEDI_NI_PCIMIO
|
||||
tristate "NI PCI-MIO-E series and M series support"
|
||||
depends on COMEDI_NI_TIO && COMEDI_NI_COMMON
|
||||
select COMEDI_NI_TIOCMD
|
||||
select COMEDI_8255
|
||||
select COMEDI_FC
|
||||
---help---
|
||||
|
@ -1063,7 +1074,6 @@ config COMEDI_NI_PCIMIO
|
|||
|
||||
config COMEDI_RTD520
|
||||
tristate "Real Time Devices PCI4520/DM7520 support"
|
||||
select COMEDI_8255
|
||||
---help---
|
||||
Enable support for Real Time Devices PCI4520/DM7520
|
||||
|
||||
|
@ -1095,11 +1105,19 @@ config COMEDI_SSV_DNP
|
|||
To compile this driver as a module, choose M here: the module will be
|
||||
called ssv_dnp.
|
||||
|
||||
config COMEDI_MITE
|
||||
tristate
|
||||
|
||||
config COMEDI_NI_TIOCMD
|
||||
tristate
|
||||
select COMEDI_NI_TIO
|
||||
select COMEDI_MITE
|
||||
|
||||
endif # COMEDI_PCI_DRIVERS
|
||||
|
||||
menuconfig COMEDI_PCMCIA_DRIVERS
|
||||
tristate "Comedi PCMCIA drivers"
|
||||
depends on COMEDI && (PCMCIA || PCCARD)
|
||||
bool "Comedi PCMCIA drivers"
|
||||
depends on PCMCIA
|
||||
---help---
|
||||
Enable comedi PCMCIA and PCCARD drivers to be built
|
||||
|
||||
|
@ -1107,7 +1125,7 @@ menuconfig COMEDI_PCMCIA_DRIVERS
|
|||
kernel: saying N will just cause the configurator to skip all
|
||||
the questions about PCMCIA comedi drivers.
|
||||
|
||||
if COMEDI_PCMCIA_DRIVERS && PCMCIA
|
||||
if COMEDI_PCMCIA_DRIVERS
|
||||
|
||||
config COMEDI_CB_DAS16_CS
|
||||
tristate "CB DAS16 series PCMCIA support"
|
||||
|
@ -1130,7 +1148,6 @@ config COMEDI_DAS08_CS
|
|||
|
||||
config COMEDI_NI_DAQ_700_CS
|
||||
tristate "NI DAQCard-700 PCMCIA support"
|
||||
depends on COMEDI_NI_COMMON
|
||||
---help---
|
||||
Enable support for the National Instruments PCMCIA DAQCard-700 DIO
|
||||
|
||||
|
@ -1139,7 +1156,6 @@ config COMEDI_NI_DAQ_700_CS
|
|||
|
||||
config COMEDI_NI_DAQ_DIO24_CS
|
||||
tristate "NI DAQ-Card DIO-24 PCMCIA support"
|
||||
depends on COMEDI_NI_COMMON
|
||||
select COMEDI_8255
|
||||
---help---
|
||||
Enable support for the National Instruments PCMCIA DAQ-Card DIO-24
|
||||
|
@ -1158,7 +1174,7 @@ config COMEDI_NI_LABPC_CS
|
|||
|
||||
config COMEDI_NI_MIO_CS
|
||||
tristate "NI DAQCard E series PCMCIA support"
|
||||
depends on COMEDI_NI_TIO && COMEDI_NI_COMMON
|
||||
select COMEDI_NI_TIO
|
||||
select COMEDI_8255
|
||||
select COMEDI_FC
|
||||
---help---
|
||||
|
@ -1181,8 +1197,8 @@ config COMEDI_QUATECH_DAQP_CS
|
|||
endif # COMEDI_PCMCIA_DRIVERS
|
||||
|
||||
menuconfig COMEDI_USB_DRIVERS
|
||||
tristate "Comedi USB drivers"
|
||||
depends on COMEDI && USB
|
||||
bool "Comedi USB drivers"
|
||||
depends on USB
|
||||
---help---
|
||||
Enable comedi USB drivers to be built
|
||||
|
||||
|
@ -1190,7 +1206,7 @@ menuconfig COMEDI_USB_DRIVERS
|
|||
kernel: saying N will just cause the configurator to skip all
|
||||
the questions about USB comedi drivers.
|
||||
|
||||
if COMEDI_USB_DRIVERS && USB
|
||||
if COMEDI_USB_DRIVERS
|
||||
|
||||
config COMEDI_DT9812
|
||||
tristate "DataTranslation DT9812 USB module support"
|
||||
|
@ -1237,60 +1253,8 @@ config COMEDI_VMK80XX
|
|||
|
||||
endif # COMEDI_USB_DRIVERS
|
||||
|
||||
menuconfig COMEDI_NI_COMMON
|
||||
tristate "Comedi National Instruments card support"
|
||||
depends on COMEDI
|
||||
---help---
|
||||
Enable comedi support for National Instruments cards.
|
||||
Modules in this section are used by many comedi NI drivers.
|
||||
|
||||
Note that the answer to this question won't directly affect the
|
||||
kernel: saying N will just cause the configurator to skip all
|
||||
the questions about National Instruments cards.
|
||||
|
||||
if COMEDI_NI_COMMON
|
||||
|
||||
config COMEDI_MITE
|
||||
tristate "NI Mite PCI interface chip support"
|
||||
depends on PCI
|
||||
---help---
|
||||
Enable support for National Instruments Mite PCI interface chip
|
||||
|
||||
To compile this driver as a module, choose M here: the module will be
|
||||
called mite.
|
||||
|
||||
config COMEDI_NI_TIO
|
||||
tristate "NI general purpose counter support"
|
||||
depends on COMEDI_MITE
|
||||
---help---
|
||||
Enable support for National Instruments general purpose counters.
|
||||
This module is not used directly by end-users. Rather, it
|
||||
is used by other drivers (for example ni_660x and ni_pcimio)
|
||||
to provide support for NI's general purpose counters.
|
||||
|
||||
To compile this driver as a modules, choose M here: two modules will
|
||||
be build: ni_tio and ni_tiocmd.
|
||||
|
||||
config COMEDI_NI_LABPC
|
||||
tristate "NI Lab-PC and compatibles ISA and PCI support"
|
||||
depends on COMEDI_MITE
|
||||
select COMEDI_8255
|
||||
select COMEDI_FC
|
||||
depends on VIRT_TO_BUS
|
||||
---help---
|
||||
Enable support for National Instruments Lab-PC and compatibles
|
||||
Lab-PC-1200, Lab-PC-1200AI, Lab-PC+ and PCI-1200.
|
||||
Kernel-level ISA plug-and-play support for the lab-pc-1200 boards has
|
||||
not yet been added to the driver.
|
||||
|
||||
To compile this driver as a module, choose M here: the module will be
|
||||
called ni_labpc.
|
||||
|
||||
endif # COMEDI_NI_COMMON
|
||||
|
||||
config COMEDI_8255
|
||||
tristate "Generic 8255 support"
|
||||
depends on COMEDI
|
||||
---help---
|
||||
Enable generic 8255 support.
|
||||
|
||||
|
@ -1305,31 +1269,24 @@ config COMEDI_8255
|
|||
called 8255.
|
||||
|
||||
config COMEDI_FC
|
||||
tristate "Comedi shared functions for low-level driver support"
|
||||
depends on COMEDI
|
||||
---help---
|
||||
Enable support for shared functions for low-level drivers.
|
||||
This module is not used directly by end-users. Rather, it
|
||||
is used by many other comedi drivers.
|
||||
|
||||
To compile this driver as a module, choose M here: the module will be
|
||||
called comedi_fc.
|
||||
tristate
|
||||
|
||||
config COMEDI_AMPLC_DIO200
|
||||
tristate
|
||||
depends on COMEDI
|
||||
select COMEDI_8255
|
||||
|
||||
config COMEDI_AMPLC_PC236
|
||||
tristate
|
||||
depends on COMEDI
|
||||
select COMEDI_8255
|
||||
|
||||
config COMEDI_AMPLC_PC263
|
||||
tristate
|
||||
depends on COMEDI
|
||||
|
||||
config COMEDI_DAS08
|
||||
tristate
|
||||
depends on COMEDI
|
||||
select COMEDI_8255
|
||||
|
||||
config COMEDI_NI_TIO
|
||||
tristate
|
||||
|
||||
endif # COMEDI
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
|
||||
#define __NO_VERSION__
|
||||
#include <linux/uaccess.h>
|
||||
#include <linux/compat.h>
|
||||
#include <linux/fs.h>
|
||||
#include "comedi.h"
|
||||
#include "comedi_compat32.h"
|
||||
|
||||
|
|
|
@ -27,17 +27,15 @@
|
|||
#ifndef _COMEDI_COMPAT32_H
|
||||
#define _COMEDI_COMPAT32_H
|
||||
|
||||
#include <linux/compat.h>
|
||||
#include <linux/fs.h>
|
||||
|
||||
#ifdef CONFIG_COMPAT
|
||||
|
||||
struct file;
|
||||
extern long comedi_compat_ioctl(struct file *file, unsigned int cmd,
|
||||
unsigned long arg);
|
||||
|
||||
#else /* CONFIG_COMPAT */
|
||||
|
||||
#define comedi_compat_ioctl 0 /* NULL */
|
||||
#define comedi_compat_ioctl NULL
|
||||
|
||||
#endif /* CONFIG_COMPAT */
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#undef DEBUG
|
||||
|
||||
#define __NO_VERSION__
|
||||
#include "comedi_fops.h"
|
||||
#include "comedi_compat32.h"
|
||||
|
||||
#include <linux/module.h>
|
||||
|
@ -49,7 +48,7 @@
|
|||
#include <linux/io.h>
|
||||
#include <linux/uaccess.h>
|
||||
|
||||
#include "internal.h"
|
||||
#include "comedi_internal.h"
|
||||
|
||||
MODULE_AUTHOR("http://www.comedi.org");
|
||||
MODULE_DESCRIPTION("Comedi core module");
|
||||
|
@ -92,36 +91,6 @@ static DEFINE_SPINLOCK(comedi_file_info_table_lock);
|
|||
static struct comedi_device_file_info
|
||||
*comedi_file_info_table[COMEDI_NUM_MINORS];
|
||||
|
||||
static int do_devconfig_ioctl(struct comedi_device *dev,
|
||||
struct comedi_devconfig __user *arg);
|
||||
static int do_bufconfig_ioctl(struct comedi_device *dev,
|
||||
struct comedi_bufconfig __user *arg);
|
||||
static int do_devinfo_ioctl(struct comedi_device *dev,
|
||||
struct comedi_devinfo __user *arg,
|
||||
struct file *file);
|
||||
static int do_subdinfo_ioctl(struct comedi_device *dev,
|
||||
struct comedi_subdinfo __user *arg, void *file);
|
||||
static int do_chaninfo_ioctl(struct comedi_device *dev,
|
||||
struct comedi_chaninfo __user *arg);
|
||||
static int do_bufinfo_ioctl(struct comedi_device *dev,
|
||||
struct comedi_bufinfo __user *arg, void *file);
|
||||
static int do_cmd_ioctl(struct comedi_device *dev,
|
||||
struct comedi_cmd __user *arg, void *file);
|
||||
static int do_lock_ioctl(struct comedi_device *dev, unsigned int arg,
|
||||
void *file);
|
||||
static int do_unlock_ioctl(struct comedi_device *dev, unsigned int arg,
|
||||
void *file);
|
||||
static int do_cancel_ioctl(struct comedi_device *dev, unsigned int arg,
|
||||
void *file);
|
||||
static int do_cmdtest_ioctl(struct comedi_device *dev,
|
||||
struct comedi_cmd __user *arg, void *file);
|
||||
static int do_insnlist_ioctl(struct comedi_device *dev,
|
||||
struct comedi_insnlist __user *arg, void *file);
|
||||
static int do_insn_ioctl(struct comedi_device *dev,
|
||||
struct comedi_insn __user *arg, void *file);
|
||||
static int do_poll_ioctl(struct comedi_device *dev, unsigned int subd,
|
||||
void *file);
|
||||
|
||||
static void do_become_nonbusy(struct comedi_device *dev,
|
||||
struct comedi_subdevice *s);
|
||||
static int do_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
|
||||
|
@ -172,28 +141,19 @@ static int resize_async_buffer(struct comedi_device *dev,
|
|||
|
||||
/* sysfs attribute files */
|
||||
|
||||
static const unsigned bytes_per_kibi = 1024;
|
||||
|
||||
static ssize_t show_max_read_buffer_kb(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
ssize_t retval;
|
||||
struct comedi_device_file_info *info = dev_get_drvdata(dev);
|
||||
unsigned max_buffer_size_kb = 0;
|
||||
struct comedi_subdevice *const read_subdevice =
|
||||
comedi_get_read_subdevice(info);
|
||||
struct comedi_subdevice *s = comedi_get_read_subdevice(info);
|
||||
unsigned int size = 0;
|
||||
|
||||
mutex_lock(&info->device->mutex);
|
||||
if (read_subdevice &&
|
||||
(read_subdevice->subdev_flags & SDF_CMD_READ) &&
|
||||
read_subdevice->async) {
|
||||
max_buffer_size_kb = read_subdevice->async->max_bufsize /
|
||||
bytes_per_kibi;
|
||||
}
|
||||
retval = snprintf(buf, PAGE_SIZE, "%i\n", max_buffer_size_kb);
|
||||
if (s && (s->subdev_flags & SDF_CMD_READ) && s->async)
|
||||
size = s->async->max_bufsize / 1024;
|
||||
mutex_unlock(&info->device->mutex);
|
||||
|
||||
return retval;
|
||||
return snprintf(buf, PAGE_SIZE, "%i\n", size);
|
||||
}
|
||||
|
||||
static ssize_t store_max_read_buffer_kb(struct device *dev,
|
||||
|
@ -201,52 +161,40 @@ static ssize_t store_max_read_buffer_kb(struct device *dev,
|
|||
const char *buf, size_t count)
|
||||
{
|
||||
struct comedi_device_file_info *info = dev_get_drvdata(dev);
|
||||
unsigned int new_max_size_kb;
|
||||
unsigned int new_max_size;
|
||||
int ret;
|
||||
struct comedi_subdevice *const read_subdevice =
|
||||
comedi_get_read_subdevice(info);
|
||||
struct comedi_subdevice *s = comedi_get_read_subdevice(info);
|
||||
unsigned int size;
|
||||
int err;
|
||||
|
||||
ret = kstrtouint(buf, 10, &new_max_size_kb);
|
||||
if (ret)
|
||||
return ret;
|
||||
if (new_max_size_kb > (UINT_MAX / bytes_per_kibi))
|
||||
err = kstrtouint(buf, 10, &size);
|
||||
if (err)
|
||||
return err;
|
||||
if (size > (UINT_MAX / 1024))
|
||||
return -EINVAL;
|
||||
new_max_size = new_max_size_kb * bytes_per_kibi;
|
||||
size *= 1024;
|
||||
|
||||
mutex_lock(&info->device->mutex);
|
||||
if (read_subdevice == NULL ||
|
||||
(read_subdevice->subdev_flags & SDF_CMD_READ) == 0 ||
|
||||
read_subdevice->async == NULL) {
|
||||
mutex_unlock(&info->device->mutex);
|
||||
return -EINVAL;
|
||||
}
|
||||
read_subdevice->async->max_bufsize = new_max_size;
|
||||
if (s && (s->subdev_flags & SDF_CMD_READ) && s->async)
|
||||
s->async->max_bufsize = size;
|
||||
else
|
||||
err = -EINVAL;
|
||||
mutex_unlock(&info->device->mutex);
|
||||
|
||||
return count;
|
||||
return err ? err : count;
|
||||
}
|
||||
|
||||
static ssize_t show_read_buffer_kb(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
ssize_t retval;
|
||||
struct comedi_device_file_info *info = dev_get_drvdata(dev);
|
||||
unsigned buffer_size_kb = 0;
|
||||
struct comedi_subdevice *const read_subdevice =
|
||||
comedi_get_read_subdevice(info);
|
||||
struct comedi_subdevice *s = comedi_get_read_subdevice(info);
|
||||
unsigned int size = 0;
|
||||
|
||||
mutex_lock(&info->device->mutex);
|
||||
if (read_subdevice &&
|
||||
(read_subdevice->subdev_flags & SDF_CMD_READ) &&
|
||||
read_subdevice->async) {
|
||||
buffer_size_kb = read_subdevice->async->prealloc_bufsz /
|
||||
bytes_per_kibi;
|
||||
}
|
||||
retval = snprintf(buf, PAGE_SIZE, "%i\n", buffer_size_kb);
|
||||
if (s && (s->subdev_flags & SDF_CMD_READ) && s->async)
|
||||
size = s->async->prealloc_bufsz / 1024;
|
||||
mutex_unlock(&info->device->mutex);
|
||||
|
||||
return retval;
|
||||
return snprintf(buf, PAGE_SIZE, "%i\n", size);
|
||||
}
|
||||
|
||||
static ssize_t store_read_buffer_kb(struct device *dev,
|
||||
|
@ -254,57 +202,41 @@ static ssize_t store_read_buffer_kb(struct device *dev,
|
|||
const char *buf, size_t count)
|
||||
{
|
||||
struct comedi_device_file_info *info = dev_get_drvdata(dev);
|
||||
unsigned int new_size_kb;
|
||||
unsigned int new_size;
|
||||
int retval;
|
||||
int ret;
|
||||
struct comedi_subdevice *const read_subdevice =
|
||||
comedi_get_read_subdevice(info);
|
||||
struct comedi_subdevice *s = comedi_get_read_subdevice(info);
|
||||
unsigned int size;
|
||||
int err;
|
||||
|
||||
ret = kstrtouint(buf, 10, &new_size_kb);
|
||||
if (ret)
|
||||
return ret;
|
||||
if (new_size_kb > (UINT_MAX / bytes_per_kibi))
|
||||
err = kstrtouint(buf, 10, &size);
|
||||
if (err)
|
||||
return err;
|
||||
if (size > (UINT_MAX / 1024))
|
||||
return -EINVAL;
|
||||
new_size = new_size_kb * bytes_per_kibi;
|
||||
size *= 1024;
|
||||
|
||||
mutex_lock(&info->device->mutex);
|
||||
if (read_subdevice == NULL ||
|
||||
(read_subdevice->subdev_flags & SDF_CMD_READ) == 0 ||
|
||||
read_subdevice->async == NULL) {
|
||||
mutex_unlock(&info->device->mutex);
|
||||
return -EINVAL;
|
||||
}
|
||||
retval = resize_async_buffer(info->device, read_subdevice,
|
||||
read_subdevice->async, new_size);
|
||||
if (s && (s->subdev_flags & SDF_CMD_READ) && s->async)
|
||||
err = resize_async_buffer(info->device, s, s->async, size);
|
||||
else
|
||||
err = -EINVAL;
|
||||
mutex_unlock(&info->device->mutex);
|
||||
|
||||
if (retval < 0)
|
||||
return retval;
|
||||
return count;
|
||||
return err ? err : count;
|
||||
}
|
||||
|
||||
static ssize_t show_max_write_buffer_kb(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
ssize_t retval;
|
||||
struct comedi_device_file_info *info = dev_get_drvdata(dev);
|
||||
unsigned max_buffer_size_kb = 0;
|
||||
struct comedi_subdevice *const write_subdevice =
|
||||
comedi_get_write_subdevice(info);
|
||||
struct comedi_subdevice *s = comedi_get_write_subdevice(info);
|
||||
unsigned int size = 0;
|
||||
|
||||
mutex_lock(&info->device->mutex);
|
||||
if (write_subdevice &&
|
||||
(write_subdevice->subdev_flags & SDF_CMD_WRITE) &&
|
||||
write_subdevice->async) {
|
||||
max_buffer_size_kb = write_subdevice->async->max_bufsize /
|
||||
bytes_per_kibi;
|
||||
}
|
||||
retval = snprintf(buf, PAGE_SIZE, "%i\n", max_buffer_size_kb);
|
||||
if (s && (s->subdev_flags & SDF_CMD_WRITE) && s->async)
|
||||
size = s->async->max_bufsize / 1024;
|
||||
mutex_unlock(&info->device->mutex);
|
||||
|
||||
return retval;
|
||||
return snprintf(buf, PAGE_SIZE, "%i\n", size);
|
||||
}
|
||||
|
||||
static ssize_t store_max_write_buffer_kb(struct device *dev,
|
||||
|
@ -312,52 +244,40 @@ static ssize_t store_max_write_buffer_kb(struct device *dev,
|
|||
const char *buf, size_t count)
|
||||
{
|
||||
struct comedi_device_file_info *info = dev_get_drvdata(dev);
|
||||
unsigned int new_max_size_kb;
|
||||
unsigned int new_max_size;
|
||||
int ret;
|
||||
struct comedi_subdevice *const write_subdevice =
|
||||
comedi_get_write_subdevice(info);
|
||||
struct comedi_subdevice *s = comedi_get_write_subdevice(info);
|
||||
unsigned int size;
|
||||
int err;
|
||||
|
||||
ret = kstrtouint(buf, 10, &new_max_size_kb);
|
||||
if (ret)
|
||||
return ret;
|
||||
if (new_max_size_kb > (UINT_MAX / bytes_per_kibi))
|
||||
err = kstrtouint(buf, 10, &size);
|
||||
if (err)
|
||||
return err;
|
||||
if (size > (UINT_MAX / 1024))
|
||||
return -EINVAL;
|
||||
new_max_size = new_max_size_kb * bytes_per_kibi;
|
||||
size *= 1024;
|
||||
|
||||
mutex_lock(&info->device->mutex);
|
||||
if (write_subdevice == NULL ||
|
||||
(write_subdevice->subdev_flags & SDF_CMD_WRITE) == 0 ||
|
||||
write_subdevice->async == NULL) {
|
||||
mutex_unlock(&info->device->mutex);
|
||||
return -EINVAL;
|
||||
}
|
||||
write_subdevice->async->max_bufsize = new_max_size;
|
||||
if (s && (s->subdev_flags & SDF_CMD_WRITE) && s->async)
|
||||
s->async->max_bufsize = size;
|
||||
else
|
||||
err = -EINVAL;
|
||||
mutex_unlock(&info->device->mutex);
|
||||
|
||||
return count;
|
||||
return err ? err : count;
|
||||
}
|
||||
|
||||
static ssize_t show_write_buffer_kb(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
ssize_t retval;
|
||||
struct comedi_device_file_info *info = dev_get_drvdata(dev);
|
||||
unsigned buffer_size_kb = 0;
|
||||
struct comedi_subdevice *const write_subdevice =
|
||||
comedi_get_write_subdevice(info);
|
||||
struct comedi_subdevice *s = comedi_get_write_subdevice(info);
|
||||
unsigned int size = 0;
|
||||
|
||||
mutex_lock(&info->device->mutex);
|
||||
if (write_subdevice &&
|
||||
(write_subdevice->subdev_flags & SDF_CMD_WRITE) &&
|
||||
write_subdevice->async) {
|
||||
buffer_size_kb = write_subdevice->async->prealloc_bufsz /
|
||||
bytes_per_kibi;
|
||||
}
|
||||
retval = snprintf(buf, PAGE_SIZE, "%i\n", buffer_size_kb);
|
||||
if (s && (s->subdev_flags & SDF_CMD_WRITE) && s->async)
|
||||
size = s->async->prealloc_bufsz / 1024;
|
||||
mutex_unlock(&info->device->mutex);
|
||||
|
||||
return retval;
|
||||
return snprintf(buf, PAGE_SIZE, "%i\n", size);
|
||||
}
|
||||
|
||||
static ssize_t store_write_buffer_kb(struct device *dev,
|
||||
|
@ -365,34 +285,25 @@ static ssize_t store_write_buffer_kb(struct device *dev,
|
|||
const char *buf, size_t count)
|
||||
{
|
||||
struct comedi_device_file_info *info = dev_get_drvdata(dev);
|
||||
unsigned int new_size_kb;
|
||||
unsigned int new_size;
|
||||
int retval;
|
||||
int ret;
|
||||
struct comedi_subdevice *const write_subdevice =
|
||||
comedi_get_write_subdevice(info);
|
||||
struct comedi_subdevice *s = comedi_get_write_subdevice(info);
|
||||
unsigned int size;
|
||||
int err;
|
||||
|
||||
ret = kstrtouint(buf, 10, &new_size_kb);
|
||||
if (ret)
|
||||
return ret;
|
||||
if (new_size_kb > (UINT_MAX / bytes_per_kibi))
|
||||
err = kstrtouint(buf, 10, &size);
|
||||
if (err)
|
||||
return err;
|
||||
if (size > (UINT_MAX / 1024))
|
||||
return -EINVAL;
|
||||
new_size = ((uint64_t) new_size_kb) * bytes_per_kibi;
|
||||
size *= 1024;
|
||||
|
||||
mutex_lock(&info->device->mutex);
|
||||
if (write_subdevice == NULL ||
|
||||
(write_subdevice->subdev_flags & SDF_CMD_WRITE) == 0 ||
|
||||
write_subdevice->async == NULL) {
|
||||
mutex_unlock(&info->device->mutex);
|
||||
return -EINVAL;
|
||||
}
|
||||
retval = resize_async_buffer(info->device, write_subdevice,
|
||||
write_subdevice->async, new_size);
|
||||
if (s && (s->subdev_flags & SDF_CMD_WRITE) && s->async)
|
||||
err = resize_async_buffer(info->device, s, s->async, size);
|
||||
else
|
||||
err = -EINVAL;
|
||||
mutex_unlock(&info->device->mutex);
|
||||
|
||||
if (retval < 0)
|
||||
return retval;
|
||||
return count;
|
||||
return err ? err : count;
|
||||
}
|
||||
|
||||
static struct device_attribute comedi_dev_attrs[] = {
|
||||
|
@ -407,98 +318,6 @@ static struct device_attribute comedi_dev_attrs[] = {
|
|||
__ATTR_NULL
|
||||
};
|
||||
|
||||
static long comedi_unlocked_ioctl(struct file *file, unsigned int cmd,
|
||||
unsigned long arg)
|
||||
{
|
||||
const unsigned minor = iminor(file->f_dentry->d_inode);
|
||||
struct comedi_device_file_info *dev_file_info =
|
||||
comedi_get_device_file_info(minor);
|
||||
struct comedi_device *dev;
|
||||
int rc;
|
||||
|
||||
if (dev_file_info == NULL || dev_file_info->device == NULL)
|
||||
return -ENODEV;
|
||||
dev = dev_file_info->device;
|
||||
|
||||
mutex_lock(&dev->mutex);
|
||||
|
||||
/* Device config is special, because it must work on
|
||||
* an unconfigured device. */
|
||||
if (cmd == COMEDI_DEVCONFIG) {
|
||||
rc = do_devconfig_ioctl(dev,
|
||||
(struct comedi_devconfig __user *)arg);
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (!dev->attached) {
|
||||
DPRINTK("no driver configured on /dev/comedi%i\n", dev->minor);
|
||||
rc = -ENODEV;
|
||||
goto done;
|
||||
}
|
||||
|
||||
switch (cmd) {
|
||||
case COMEDI_BUFCONFIG:
|
||||
rc = do_bufconfig_ioctl(dev,
|
||||
(struct comedi_bufconfig __user *)arg);
|
||||
break;
|
||||
case COMEDI_DEVINFO:
|
||||
rc = do_devinfo_ioctl(dev, (struct comedi_devinfo __user *)arg,
|
||||
file);
|
||||
break;
|
||||
case COMEDI_SUBDINFO:
|
||||
rc = do_subdinfo_ioctl(dev,
|
||||
(struct comedi_subdinfo __user *)arg,
|
||||
file);
|
||||
break;
|
||||
case COMEDI_CHANINFO:
|
||||
rc = do_chaninfo_ioctl(dev, (void __user *)arg);
|
||||
break;
|
||||
case COMEDI_RANGEINFO:
|
||||
rc = do_rangeinfo_ioctl(dev, (void __user *)arg);
|
||||
break;
|
||||
case COMEDI_BUFINFO:
|
||||
rc = do_bufinfo_ioctl(dev,
|
||||
(struct comedi_bufinfo __user *)arg,
|
||||
file);
|
||||
break;
|
||||
case COMEDI_LOCK:
|
||||
rc = do_lock_ioctl(dev, arg, file);
|
||||
break;
|
||||
case COMEDI_UNLOCK:
|
||||
rc = do_unlock_ioctl(dev, arg, file);
|
||||
break;
|
||||
case COMEDI_CANCEL:
|
||||
rc = do_cancel_ioctl(dev, arg, file);
|
||||
break;
|
||||
case COMEDI_CMD:
|
||||
rc = do_cmd_ioctl(dev, (struct comedi_cmd __user *)arg, file);
|
||||
break;
|
||||
case COMEDI_CMDTEST:
|
||||
rc = do_cmdtest_ioctl(dev, (struct comedi_cmd __user *)arg,
|
||||
file);
|
||||
break;
|
||||
case COMEDI_INSNLIST:
|
||||
rc = do_insnlist_ioctl(dev,
|
||||
(struct comedi_insnlist __user *)arg,
|
||||
file);
|
||||
break;
|
||||
case COMEDI_INSN:
|
||||
rc = do_insn_ioctl(dev, (struct comedi_insn __user *)arg,
|
||||
file);
|
||||
break;
|
||||
case COMEDI_POLL:
|
||||
rc = do_poll_ioctl(dev, arg, file);
|
||||
break;
|
||||
default:
|
||||
rc = -ENOTTY;
|
||||
break;
|
||||
}
|
||||
|
||||
done:
|
||||
mutex_unlock(&dev->mutex);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
COMEDI_DEVCONFIG
|
||||
device config ioctl
|
||||
|
@ -1709,6 +1528,98 @@ static int do_poll_ioctl(struct comedi_device *dev, unsigned int arg,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
static long comedi_unlocked_ioctl(struct file *file, unsigned int cmd,
|
||||
unsigned long arg)
|
||||
{
|
||||
const unsigned minor = iminor(file->f_dentry->d_inode);
|
||||
struct comedi_device_file_info *dev_file_info =
|
||||
comedi_get_device_file_info(minor);
|
||||
struct comedi_device *dev;
|
||||
int rc;
|
||||
|
||||
if (dev_file_info == NULL || dev_file_info->device == NULL)
|
||||
return -ENODEV;
|
||||
dev = dev_file_info->device;
|
||||
|
||||
mutex_lock(&dev->mutex);
|
||||
|
||||
/* Device config is special, because it must work on
|
||||
* an unconfigured device. */
|
||||
if (cmd == COMEDI_DEVCONFIG) {
|
||||
rc = do_devconfig_ioctl(dev,
|
||||
(struct comedi_devconfig __user *)arg);
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (!dev->attached) {
|
||||
DPRINTK("no driver configured on /dev/comedi%i\n", dev->minor);
|
||||
rc = -ENODEV;
|
||||
goto done;
|
||||
}
|
||||
|
||||
switch (cmd) {
|
||||
case COMEDI_BUFCONFIG:
|
||||
rc = do_bufconfig_ioctl(dev,
|
||||
(struct comedi_bufconfig __user *)arg);
|
||||
break;
|
||||
case COMEDI_DEVINFO:
|
||||
rc = do_devinfo_ioctl(dev, (struct comedi_devinfo __user *)arg,
|
||||
file);
|
||||
break;
|
||||
case COMEDI_SUBDINFO:
|
||||
rc = do_subdinfo_ioctl(dev,
|
||||
(struct comedi_subdinfo __user *)arg,
|
||||
file);
|
||||
break;
|
||||
case COMEDI_CHANINFO:
|
||||
rc = do_chaninfo_ioctl(dev, (void __user *)arg);
|
||||
break;
|
||||
case COMEDI_RANGEINFO:
|
||||
rc = do_rangeinfo_ioctl(dev, (void __user *)arg);
|
||||
break;
|
||||
case COMEDI_BUFINFO:
|
||||
rc = do_bufinfo_ioctl(dev,
|
||||
(struct comedi_bufinfo __user *)arg,
|
||||
file);
|
||||
break;
|
||||
case COMEDI_LOCK:
|
||||
rc = do_lock_ioctl(dev, arg, file);
|
||||
break;
|
||||
case COMEDI_UNLOCK:
|
||||
rc = do_unlock_ioctl(dev, arg, file);
|
||||
break;
|
||||
case COMEDI_CANCEL:
|
||||
rc = do_cancel_ioctl(dev, arg, file);
|
||||
break;
|
||||
case COMEDI_CMD:
|
||||
rc = do_cmd_ioctl(dev, (struct comedi_cmd __user *)arg, file);
|
||||
break;
|
||||
case COMEDI_CMDTEST:
|
||||
rc = do_cmdtest_ioctl(dev, (struct comedi_cmd __user *)arg,
|
||||
file);
|
||||
break;
|
||||
case COMEDI_INSNLIST:
|
||||
rc = do_insnlist_ioctl(dev,
|
||||
(struct comedi_insnlist __user *)arg,
|
||||
file);
|
||||
break;
|
||||
case COMEDI_INSN:
|
||||
rc = do_insn_ioctl(dev, (struct comedi_insn __user *)arg,
|
||||
file);
|
||||
break;
|
||||
case COMEDI_POLL:
|
||||
rc = do_poll_ioctl(dev, arg, file);
|
||||
break;
|
||||
default:
|
||||
rc = -ENOTTY;
|
||||
break;
|
||||
}
|
||||
|
||||
done:
|
||||
mutex_unlock(&dev->mutex);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int do_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
|
||||
{
|
||||
int ret = 0;
|
||||
|
@ -2270,7 +2181,7 @@ static int comedi_fasync(int fd, struct file *file, int on)
|
|||
return fasync_helper(fd, file, on, &dev->async_queue);
|
||||
}
|
||||
|
||||
const struct file_operations comedi_fops = {
|
||||
static const struct file_operations comedi_fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.unlocked_ioctl = comedi_unlocked_ioctl,
|
||||
.compat_ioctl = comedi_compat_ioctl,
|
||||
|
@ -2284,7 +2195,7 @@ const struct file_operations comedi_fops = {
|
|||
.llseek = noop_llseek,
|
||||
};
|
||||
|
||||
struct class *comedi_class;
|
||||
static struct class *comedi_class;
|
||||
static struct cdev comedi_cdev;
|
||||
|
||||
static void comedi_cleanup_legacy_minors(void)
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
|
||||
#ifndef _COMEDI_FOPS_H
|
||||
#define _COMEDI_FOPS_H
|
||||
#include <linux/types.h>
|
||||
|
||||
extern struct class *comedi_class;
|
||||
extern const struct file_operations comedi_fops;
|
||||
extern bool comedi_autoconfig;
|
||||
extern struct comedi_driver *comedi_drivers;
|
||||
|
||||
#endif /* _COMEDI_FOPS_H */
|
|
@ -1,3 +1,8 @@
|
|||
#ifndef _COMEDI_INTERNAL_H
|
||||
#define _COMEDI_INTERNAL_H
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
/*
|
||||
* various internal comedi stuff
|
||||
*/
|
||||
|
@ -14,3 +19,7 @@ int comedi_buf_alloc(struct comedi_device *dev, struct comedi_subdevice *s,
|
|||
|
||||
extern unsigned int comedi_default_buf_size_kb;
|
||||
extern unsigned int comedi_default_buf_maxsize_kb;
|
||||
extern bool comedi_autoconfig;
|
||||
extern struct comedi_driver *comedi_drivers;
|
||||
|
||||
#endif /* _COMEDI_INTERNAL_H */
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue