IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an
email to Administrator. User accounts are meant only to access repo
and report issues and/or generate pull requests.
This is a purpose-specific Git hosting for
BaseALT
projects. Thank you for your understanding!
Только зарегистрированные пользователи имеют доступ к сервису!
Для получения аккаунта, обратитесь к администратору.
With the grouping of ad7091r initialization data and callbacks into the
init_info struct, there is no more need to pass the device name and
register map through probe function parameters as those will be available
in the init_info object.
Remove probe parameters that are not needed anymore.
Signed-off-by: Marcelo Schmitt <marcelo.schmitt@analog.com>
Link: https://lore.kernel.org/r/090a6b461410a374511a8c73659de28b2665f96b.1703013352.git.marcelo.schmitt1@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
AD7091R designs may differ on their communication protocol and resources
required for proper setup. Extract what is design specific into a
init_info struct so the base driver can use data and callback functions
from that struct rather than checking which specific chip is connected
during device initialization.
Signed-off-by: Marcelo Schmitt <marcelo.schmitt@analog.com>
Link: https://lore.kernel.org/r/1aca2261e227474dc58ce26442845947bcde9b14.1703013352.git.marcelo.schmitt1@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Some code generic to AD7091R devices such as channel definitions were in
the AD7091R-5 driver. There was also some generic register definitions
declared in the base driver which would make more sense to be in the
header file.
The device state struct will be needed for the ad7091r8 driver in a
follow up patch so that ought to be moved to the header file as well.
Lastly, a couple of regmap callback functions are also capable of
abstracting characteristics of different AD7091R devices and those are
now being exported to IIO_AD7091R name space.
Move AD7091R generic code either to the base driver or to the header
file so both the ad7091r5 and the ad7091r8 driver can use those
declaration in follow up patches.
Signed-off-by: Marcelo Schmitt <marcelo.schmitt@analog.com>
Link: https://lore.kernel.org/r/6376fc523ee503d47ec499e2cd2ef13bfb5fd8ba.1703013352.git.marcelo.schmitt1@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
The ADC needs a voltage reference to work correctly.
Users can provide an external voltage reference or use the chip internal
reference to operate the ADC.
The availability of an in chip reference for the ADC saves the user from
having to supply an external voltage reference, which makes the external
reference an optional property as described in the device tree
documentation.
Though, to use the internal reference, it must be enabled by writing to
the configuration register.
Enable AD7091R internal voltage reference if no external vref is supplied.
Fixes: 260442cc5b ("iio: adc: ad7091r5: Add scale and external VREF support")
Signed-off-by: Marcelo Schmitt <marcelo.schmitt@analog.com>
Link: https://lore.kernel.org/r/b865033fa6a4fc4bf2b4a98ec51a6144e0f64f77.1703013352.git.marcelo.schmitt1@gmail.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
AD7091R-5 devices are supported by the ad7091r-5 driver together with
the ad7091r-base driver. Those drivers declared iio events for notifying
user space when ADC readings fall bellow the thresholds of low limit
registers or above the values set in high limit registers.
However, to configure iio events and their thresholds, a set of callback
functions must be implemented and those were not present until now.
The consequence of trying to configure ad7091r-5 events without the
proper callback functions was a null pointer dereference in the kernel
because the pointers to the callback functions were not set.
Implement event configuration callbacks allowing users to read/write
event thresholds and enable/disable event generation.
Since the event spec structs are generic to AD7091R devices, also move
those from the ad7091r-5 driver the base driver so they can be reused
when support for ad7091r-2/-4/-8 be added.
Fixes: ca69300173 ("iio: adc: Add support for AD7091R5 ADC")
Suggested-by: David Lechner <dlechner@baylibre.com>
Signed-off-by: Marcelo Schmitt <marcelo.schmitt@analog.com>
Link: https://lore.kernel.org/r/59552d3548dabd56adc3107b7b4869afee2b0c3c.1703013352.git.marcelo.schmitt1@gmail.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Adds driver for the MCP48xx series of DACs.
Device uses a simplex SPI channel. To set the value of an output channel,
a 16-bit data of following format must be written:
Bit field | Description
15 [MSB] | Channel selection bit
0 -> Channel A
1 -> Channel B
13 | Output Gain Selection bit
0 -> 2x Gain (Vref = 4.096V)
1 -> 1x Gain (Vref = 2.048V)
12 | Output Shutdown Control bit
0 -> Shutdown the selected channel
1 -> Active mode operation
11-0 [LSB]| DAC Input Data bits
Value's big endian representation is taken as input for the
selected DAC channel. For devices with a resolution of less
than 12-bits, only the x most significant bits are considered
where x is the resolution of the device.
Reference: Page#22 [MCP48x2 Datasheet]
Supported devices:
+---------+--------------+-------------+
| Device | Resolution | Channels |
|---------|--------------|-------------|
| MCP4801 | 8-bit | 1 |
| MCP4802 | 8-bit | 2 |
| MCP4811 | 10-bit | 1 |
| MCP4812 | 10-bit | 2 |
| MCP4821 | 12-bit | 1 |
| MCP4822 | 12-bit | 2 |
+---------+--------------+-------------+
Devices tested:
MCP4821 [12-bit single channel]
MCP4802 [8-bit dual channel]
Tested on Raspberry Pi Zero 2W
Datasheet: https://ww1.microchip.com/downloads/en/DeviceDoc/22244B.pdf #MCP48x1
Datasheet: https://ww1.microchip.com/downloads/en/DeviceDoc/20002249B.pdf #MCP48x2
Signed-off-by: Anshul Dalal <anshulusr@gmail.com>
Link: https://lore.kernel.org/r/20231220151954.154595-2-anshulusr@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This change splits the logic into a separate function, which will be
re-used later.
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Cc: Alexandru Ardelean <ardeleanalex@gmail.com>
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Link: https://lore.kernel.org/r/20231219175009.65482-3-paul@crapouillou.net
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
The buffer-dma code was using two queues, incoming and outgoing, to
manage the state of the blocks in use.
While this totally works, it adds some complexity to the code,
especially since the code only manages 2 blocks. It is much easier to
just check each block's state manually, and keep a counter for the next
block to dequeue.
Since the new DMABUF based API wouldn't use the outgoing queue anyway,
getting rid of it now makes the upcoming changes simpler.
With this change, the IIO_BLOCK_STATE_DEQUEUED is now useless, and can
be removed.
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Link: https://lore.kernel.org/r/20231219175009.65482-2-paul@crapouillou.net
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Use an explicit IIO_SEPARATE instead of 0 for the 'shared_by' parameter
when calling __iio_add_chan_devattr().
For some reason, commit 3704432fb1 ("iio: refactor info mask and ext_info
attribute creation.") updated only 1 place out of 4.
Update the remaining ones now.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/1d17f57423172fcb9d9797cfe7c8282f356049c2.1702831285.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1. Add new AMD AXI 1-wire host driver for AMD programmable logic IP
core.
2. Add support for Analog Devices DS28EC20 EEPROM to existing DS2433
driver.
3. Few cleanups in W1 GPIO driver.
-----BEGIN PGP SIGNATURE-----
iQJEBAABCgAuFiEE3dJiKD0RGyM7briowTdm5oaLg9cFAmWEEBgQHGtyemtAa2Vy
bmVsLm9yZwAKCRDBN2bmhouD17YbD/9kOm+qRZGaLJNV6TI4+oqU0i9hU2GsMYkO
veB12E4vXw72qBZcdpBhmeB5QpSXGuZsbG4d37jpsTFopjEluR3iwVnjhs66hJrD
+EPBkkoF0ZL5vD7FK+3B97pu+W0fhNxbVJ1Swdv+BEdhrzy+GZ2hl/xureSW4Tu/
bfw9Lszyug7smcMZ+g98oEoSbvdLdPxW3eFgEU5fFzzPmhDzEUdZ9fAum4q1lR4A
07VuDvSGCCY/bOSwnXrhhPEWHiBXZrNYcSGuCG+ZX+jRmcYs9ysyUkObKMp2eHbJ
wiGwQQxYMXJJr7Yqn3g3gRxR9ojq+L/X7tEfmJzxw7mcxteIQczuVRssB3cpFGId
Gc9AvLl6+8Tddf1mXN1CR8HZBmstI/SwXlFDWwS+UlpVMdWXy6sn1yqPfJKIQ91e
yvVl4la/pLMLkCbct2zKE5nf9WaddphN7pDWTf74LpjbHEyklcUc+Q46XD0sTg6X
fbzKGdS3s36hK9YN411u23xtIm1OHaP8eWV1HkDyqmwxHlCS7bKYfUNzZFLVLA5f
27+wDpGqYtfjZtcpRIZPE9iSo1HnP9i2nJHev5v9zvOBRWwRpdZLVAhX/8AzXeCn
UV+sD5k2ykBTpPSmu04pd6Vc6aOmcXhJpLryrJjOZaVOVsShdZOMgbzFk4+wHp+1
f8r3mnLdbw==
=f1E+
-----END PGP SIGNATURE-----
Merge tag 'w1-drv-6.8' of https://git.kernel.org/pub/scm/linux/kernel/git/krzk/linux-w1 into char-misc-next
Krzysztof writes:
1-Wire bus drivers for v6.8
1. Add new AMD AXI 1-wire host driver for AMD programmable logic IP
core.
2. Add support for Analog Devices DS28EC20 EEPROM to existing DS2433
driver.
3. Few cleanups in W1 GPIO driver.
* tag 'w1-drv-6.8' of https://git.kernel.org/pub/scm/linux/kernel/git/krzk/linux-w1:
w1: ds2433: add support for ds28ec20 eeprom
w1: ds2433: use the kernel bitmap implementation
w1: ds2433: introduce a configuration structure
w1: ds2433: remove unused definitions
w1: ds2490: support block sizes larger than 128 bytes in ds_read_block
w1: amd_axi_w1: Explicitly include correct DT includes
w1: gpio: rename pointer to driver data from pdata to ddata
w1: gpio: Drop unused enable_external_pullup from driver data
w1: gpio: Don't use platform data for driver data
w1: Add AXI 1-wire host driver for AMD programmable logic IP core
dt-bindings: w1: Add AMD AXI w1 host and MAINTAINERS entry
New device support
------------------
adi,hmc425a
* Add support for ADRF5740 attenuators. Minor changes to driver needed
alongside new IDs.
aosong,ags02ma
* New driver for this volatile organic compounds sensor.
bosch,bmp280
* Add BMP390 (small amount of refactoring + ID)
bosch,bmi323
* New driver to support the BMI323 6-axis IMU.
honeywell,hsc030pa
* New driver supporting a huge number of SSC and HSC series pressure and
temperature sensors.
isil,isl76682
* New driver for this simple Ambient Light sensor.
liteon,ltr390
* New driver for this ambient and ultraviolet light sensor.
maxim,max34408
* New driver to support the MAX34408 and MAX34409 current monitoring ADCs.
melexis,mlx90635
* New driver for this Infrared contactless temperature sensor.
mirochip,mcp9600
* New driver for this thermocouple EMF convertor.
ti,hdc3020
* New driver for this integrated relative humidity and temperature
sensor.
vishay,veml6075
* New driver for this UVA and UVB light sensor.
General features
----------------
Device properties
* Add fwnode_property_match_property_string() helper to allow matching
single value property against an array of predefined strings.
* Use fwnode_property_string_array_count() inside
fwnode_property_match_string() instead of open coding the same.
checkpatch.pl
* Add exclusion of __aligned() from a warning reducing false positives
on IIO drivers (and hopefully beyond)
IIO Features
------------
core
* New light channel modifiers for UVA and UVB.
* Add IIO_CHAN_INFO_TROUGH as counterpart to IIO_CHAN_INFO_PEAK so that
we can support device that keep running track of the lowest value they
have seen in similar fashion to the existing peak tracking.
adi,adis library
* Use spi cs inactive delay even when a burst reading is performed.
As it's now used every time, can centralize the handling in the SPI
setup code in the driver.
adi,ad2s1210
* Support for fixed-mode to this resolver driver where the A0 and A1
pins are hard wired to config mode in which case position and config
must be read from appropriate config registers.
* Support reset GPIO if present.
adi,ad5791
* Allow configuration of presence of external amplifier in DT binding.
adi,adis16400
* Add spi-cs-inactive-delay-ns to bindings to allow it to be tweaked
if default delays are not quite enough for a specific board.
adi,adis16475
* Add spi-cs-inactive-delay-ns to bindings to allow it to be tweaked
if default delays are not quite enough for a specific board.
bosch,bmp280
* Enable multiple chip IDs per family of devices.
rohm,bu27008
* Add an illuminance channel calculated from RGB and IR data.
Cleanup
-------
Minor white space, typos and tidy up not explicitly called out.
Core
* Check that the available_scan_masks array passed to the IIO core
by a driver is sensible by ensuring the entries are ordered so the
minimum number of channels is enabled in the earlier entries (as they
will be selected if sufficient for the requested channels).
* Document that the available_scan_masks infrastructure doesn't currently
handle masks that don't fit in a long int.
* Improve intensity documentation to reflect that there is no expectation
of sensible units (it's dependent on a frequency sensitivity curve)
Various
* Use new device_property_match_property_string() to replace open coded
versions of the same thing.
* Fix a few MAINTAINERS filenames.
* i2c_get_match_data() and spi_get_device_match_data() pushed into
more drivers reducing boilerplate handling.
* Some unnecessary headers removed.
* ACPI_PTR() removals. It's rarely worth using this.
adi,ad7091r (early part of a series adding device support - useful in
their own right)
* Pass iio_dev directly an event handler rather than relying
on broken use of dev_get_drvdata() as drvdata is never set in this driver.
* Make sure alert is turned on.
adi,ad9467 (general driver fixing up as precursor to iio-backend proposal
which is under review for 6.9)
* Fix reset gpio handling to match expected polarity.
* Always handle error codes from spi_writes.
* Add a driver instance local mutex to avoid some races.
* Fix scale setting to align with available scale values.
* Split array of chip_info structures up into named individual elements.
* Convert to regmap.
honeywell,mprls0025pa
* Drop now unnecessary type references in DT binding for properties in
pascals.
invensense,mpu6050
* Don't eat a potentially useful return value from regmap_bulk_write()
invensense,icm42600
* Use max macro to improve code readability and save a few lines.
liteon,ltrf216a
* Improve prevision of light intensity.
microchip,mcp3911
* Use cleanup.h magic.
qcom,spmi*
* Fix wrong descriptions of SPMI reg fields in bindings.
Other
----
mailmap
* Update for Matt Ranostay
-----BEGIN PGP SIGNATURE-----
iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAmWDAIIRHGppYzIzQGtl
cm5lbC5vcmcACgkQVIU0mcT0Foi37g//f9PEMOdLToWM6GoNidJmX+V8QTEKkDF5
omUTSjMTAa7aXMt5dgoevrRrg4tIZs5TfheEfHg2io+Dg3aGQxxPpgyZnVQSC4MN
bJwd+dVLjvi5sr7dEnwtJRfYCnt9LLI900xCg6b6YUFgJxY02HH6REPZVqU7M7Jl
ANTAycSrYdLJlMReHsuDZT/kMJaWo4M0azSBxWtICTtLmlfii8dWTfSex4xzk1Pf
nu13+ivz3FHpQOtLAHdtHf5CCDwcc+9DQw5O8Ihr8RQY9JEnwolaNgc0Fsmotfww
sJ8bhFy8Zyc7bYwskGl1vEX/lJdk+drDt1LmbxxaQPKISpUx3A4ITVvwiG60KGI3
gBwJmirxG9CFCa3MY4V608dvOkc58IyOX/GFq9l+5MlZvMdRqeRCFPOs8UT0G3zi
Kd422wjVpAwjV70wOb9NjnkVxQD69FaMiSA1QBCp8PYams/okwqT3ZiBqdqahwjb
77vx3gKL+Pa8hJJynA9eP8uRl6KpTxmallSuHsK4c1qdj+NaJfHPbSu0pmPALbE0
N5fcv+vA0WS/J2fWVoJuqPQ/+yYk6WddjpcOn0imlW6Uo4CP6CQISnbAuNWO6TTe
c8YAQiyoHMOk8slyU+++sPH6qS7hcyoPdBVJgCPwEN12PaZxnM7WaTN2WJX+TFXP
KARwsZQ+rUE=
=jH+G
-----END PGP SIGNATURE-----
Merge tag 'iio-for-6.8a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-next
Jonathan writes:
1st set of IIO new device support, features and cleanup for 6.8
New device support
------------------
adi,hmc425a
* Add support for ADRF5740 attenuators. Minor changes to driver needed
alongside new IDs.
aosong,ags02ma
* New driver for this volatile organic compounds sensor.
bosch,bmp280
* Add BMP390 (small amount of refactoring + ID)
bosch,bmi323
* New driver to support the BMI323 6-axis IMU.
honeywell,hsc030pa
* New driver supporting a huge number of SSC and HSC series pressure and
temperature sensors.
isil,isl76682
* New driver for this simple Ambient Light sensor.
liteon,ltr390
* New driver for this ambient and ultraviolet light sensor.
maxim,max34408
* New driver to support the MAX34408 and MAX34409 current monitoring ADCs.
melexis,mlx90635
* New driver for this Infrared contactless temperature sensor.
mirochip,mcp9600
* New driver for this thermocouple EMF convertor.
ti,hdc3020
* New driver for this integrated relative humidity and temperature
sensor.
vishay,veml6075
* New driver for this UVA and UVB light sensor.
General features
----------------
Device properties
* Add fwnode_property_match_property_string() helper to allow matching
single value property against an array of predefined strings.
* Use fwnode_property_string_array_count() inside
fwnode_property_match_string() instead of open coding the same.
checkpatch.pl
* Add exclusion of __aligned() from a warning reducing false positives
on IIO drivers (and hopefully beyond)
IIO Features
------------
core
* New light channel modifiers for UVA and UVB.
* Add IIO_CHAN_INFO_TROUGH as counterpart to IIO_CHAN_INFO_PEAK so that
we can support device that keep running track of the lowest value they
have seen in similar fashion to the existing peak tracking.
adi,adis library
* Use spi cs inactive delay even when a burst reading is performed.
As it's now used every time, can centralize the handling in the SPI
setup code in the driver.
adi,ad2s1210
* Support for fixed-mode to this resolver driver where the A0 and A1
pins are hard wired to config mode in which case position and config
must be read from appropriate config registers.
* Support reset GPIO if present.
adi,ad5791
* Allow configuration of presence of external amplifier in DT binding.
adi,adis16400
* Add spi-cs-inactive-delay-ns to bindings to allow it to be tweaked
if default delays are not quite enough for a specific board.
adi,adis16475
* Add spi-cs-inactive-delay-ns to bindings to allow it to be tweaked
if default delays are not quite enough for a specific board.
bosch,bmp280
* Enable multiple chip IDs per family of devices.
rohm,bu27008
* Add an illuminance channel calculated from RGB and IR data.
Cleanup
-------
Minor white space, typos and tidy up not explicitly called out.
Core
* Check that the available_scan_masks array passed to the IIO core
by a driver is sensible by ensuring the entries are ordered so the
minimum number of channels is enabled in the earlier entries (as they
will be selected if sufficient for the requested channels).
* Document that the available_scan_masks infrastructure doesn't currently
handle masks that don't fit in a long int.
* Improve intensity documentation to reflect that there is no expectation
of sensible units (it's dependent on a frequency sensitivity curve)
Various
* Use new device_property_match_property_string() to replace open coded
versions of the same thing.
* Fix a few MAINTAINERS filenames.
* i2c_get_match_data() and spi_get_device_match_data() pushed into
more drivers reducing boilerplate handling.
* Some unnecessary headers removed.
* ACPI_PTR() removals. It's rarely worth using this.
adi,ad7091r (early part of a series adding device support - useful in
their own right)
* Pass iio_dev directly an event handler rather than relying
on broken use of dev_get_drvdata() as drvdata is never set in this driver.
* Make sure alert is turned on.
adi,ad9467 (general driver fixing up as precursor to iio-backend proposal
which is under review for 6.9)
* Fix reset gpio handling to match expected polarity.
* Always handle error codes from spi_writes.
* Add a driver instance local mutex to avoid some races.
* Fix scale setting to align with available scale values.
* Split array of chip_info structures up into named individual elements.
* Convert to regmap.
honeywell,mprls0025pa
* Drop now unnecessary type references in DT binding for properties in
pascals.
invensense,mpu6050
* Don't eat a potentially useful return value from regmap_bulk_write()
invensense,icm42600
* Use max macro to improve code readability and save a few lines.
liteon,ltrf216a
* Improve prevision of light intensity.
microchip,mcp3911
* Use cleanup.h magic.
qcom,spmi*
* Fix wrong descriptions of SPMI reg fields in bindings.
Other
----
mailmap
* Update for Matt Ranostay
* tag 'iio-for-6.8a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (83 commits)
iio: adc: ad7091r: Align arguments to function call parenthesis
iio: adc: ad7091r: Set alert bit in config register
iio: adc: ad7091r: Pass iio_dev to event handler
scripts: checkpatch: Add __aligned to the list of attribute notes
iio: chemical: add support for Aosong AGS02MA
dt-bindings: iio: chemical: add aosong,ags02ma
dt-bindings: vendor-prefixes: add aosong
iio: accel: bmi088: update comments and Kconfig
dt-bindings: iio: humidity: Add TI HDC302x support
iio: humidity: Add driver for ti HDC302x humidity sensors
iio: ABI: document temperature and humidity peak/trough raw attributes
iio: core: introduce trough info element for minimum values
iio: light: driver for Lite-On ltr390
dt-bindings: iio: light: add ltr390
iio: light: isl76682: remove unreachable code
iio: pressure: driver for Honeywell HSC/SSC series
dt-bindings: iio: pressure: add honeywell,hsc030
doc: iio: Document intensity scale as poorly defined
dt-bindings: iio: temperature: add MLX90635 device
iio: temperature: mlx90635 MLX90635 IR Temperature sensor
...
The ds28ec20 eeprom is (almost) backward compatible with the
ds2433. The only differences are:
- the eeprom size is now 2560 bytes instead of 512;
- the number of pages is now 80 (same page size as the ds2433: 256 bits);
- the programming time has increased from 5ms to 10ms;
This patch adds support for the ds28ec20 to the ds2433 driver. From
the datasheet: The DS28EC20 provides a high degree of backward
compatibility with the DS2433. Besides the different family codes, the
only protocol change that is required on an existing DS2433
implementation is a lengthening of the programming duration (tPROG)
from 5ms to 10ms.
dmesg now returns:
w1_master_driver w1_bus_master1: Attaching one wire slave 43.000000478756 crc e0
instead of:
w1_master_driver w1_bus_master1: Attaching one wire slave 43.000000478756 crc e0
w1_master_driver w1_bus_master1: Family 43 for 43.000000478756.e0 is not registered.
Test script writing/reading random data (CONFIG_W1_SLAVE_DS2433_CRC is
not set):
#!/bin/sh
EEPROM=/sys/bus/w1/devices/43-000000478756/eeprom
BINFILE1=/home/root/file1.bin
BINFILE2=/home/root/file2.bin
for BS in 1 2 3 4 8 16 32 64 128 256 512 1024 2560; do
dd if=/dev/random of=${BINFILE1} bs=${BS} count=1 status=none
dd if=${BINFILE1} of=${EEPROM} status=none
dd if=${EEPROM} of=${BINFILE2} bs=${BS} count=1 status=none
if ! cmp --silent ${BINFILE1} ${BINFILE2}; then
echo file1
hexdump ${BINFILE1}
echo file2
hexdump ${BINFILE2}
echo FAIL
exit 1
fi
echo "${BS} OK!"
done
Results:
# ./test.sh
1 OK!
2 OK!
3 OK!
4 OK!
8 OK!
16 OK!
32 OK!
64 OK!
128 OK!
256 OK!
512 OK!
1024 OK!
2560 OK!
Tests with CONFIG_W1_SLAVE_DS2433_CRC=y:
$ cat /proc/config.gz | gunzip | grep CONFIG_W1_SLAVE_DS2433
CONFIG_W1_SLAVE_DS2433=m
CONFIG_W1_SLAVE_DS2433_CRC=y
# create a 32 bytes block with a crc, i.e.:
00000000 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 |123456789:;<=>?@|
00000010 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e ba 63 |ABCDEFGHIJKLMN.c|
# fill all 80 blocks
$ dd if=test.bin of=/sys/bus/w1/devices/43-000000478756/eeprom bs=32 count=80
# read back all blocks, i.e.:
$ hexdump -C /sys/bus/w1/devices/43-000000478756/eeprom
00000000 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 |123456789:;<=>?@|
00000010 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e ba 63 |ABCDEFGHIJKLMN.c|
00000020 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 |123456789:;<=>?@|
00000030 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e ba 63 |ABCDEFGHIJKLMN.c|
...
000009e0 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 |123456789:;<=>?@|
000009f0 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e ba 63 |ABCDEFGHIJKLMN.c|
00000a00
Note: both memories (ds2433 and ds28ec20) have been tested with the
new driver.
Signed-off-by: Marc Ferland <marc.ferland@sonatest.com>
Co-developed-by: Jean-Francois Dagenais <jeff.dagenais@gmail.com>
Signed-off-by: Jean-Francois Dagenais <jeff.dagenais@gmail.com>
Link: https://lore.kernel.org/r/20231218150230.1992448-6-marc.ferland@sonatest.com
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
The ds2433 driver uses the 'validcrc' variable to mark out which pages
have been successfully (crc is valid) retrieved from the eeprom and
placed in the internal 'memory' buffer (see CONFIG_W1_SLAVE_DS2433_CRC).
The current implementation assumes that the number of pages will never
go beyond 32 pages (bit field is a u32). This is fine for the ds2433
since it only has 16 pages.
On the ds28ec20 though, the number of pages increases to 80 which will
not fit on a single u32.
As a solution, I replaced the u32 variable with a standard bitmap and
set the number of bits to 32 which is the same size we had before.
Signed-off-by: Marc Ferland <marc.ferland@sonatest.com>
Link: https://lore.kernel.org/r/20231218150230.1992448-5-marc.ferland@sonatest.com
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Add a ds2433_config structure for parameters that are different
between the ds2433 and the ds28ec20. The goal is to reuse the same
code for both chips.
A pointer to this config structure is added to w1_f23_data and the
CONFIG_W1_SLAVE_DS2433_CRC ifdefs are adjusted since now both driver
configurations (with or without crc support) will make use of
w1_f23_data.
Also, the 'memory' buffer is now dynamically allocated based on the
size specififed in the config structure to help support memories of
different sizes.
Signed-off-by: Marc Ferland <marc.ferland@sonatest.com>
Link: https://lore.kernel.org/r/20231218150230.1992448-4-marc.ferland@sonatest.com
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
The current ds_read_block function only supports block sizes up to
128 bytes, which is the depth of the 'data out' fifo on the ds2490.
Reading larger blocks will fail with a: -110 (ETIMEDOUT) from
usb_control_msg(). Example:
$ dd if=/sys/bus/w1/devices/43-000000478756/eeprom bs=256 count=1
yields to the following message from the kernel:
usb 5-1: Failed to write 1-wire data to ep0x2: err=-110.
I discovered this issue while implementing support for the ds28ec20
eeprom in the w1-2433 driver. This driver accepts reading blocks of
sizes up to the size of the entire memory (2560 bytes in the case of
the ds28ec20). Note that this issue _does not_ arise when the kernel
is configured with CONFIG_W1_SLAVE_DS2433_CRC enabled since in this
mode the driver reads one 32 byte block at a time (a single memory
page).
Also, from the ds2490 datasheet (2995.pdf, page 22, BLOCK I/O
command):
For a block write sequence the EP2 FIFO must be pre-filled with
data before command execution. Additionally, for block sizes
greater then the FIFO size, the FIFO content status must be
monitored by host SW so that additional data can be sent to the
FIFO when necessary. A similar EP3 FIFO content monitoring
requirement exists for block read sequences. During a block read
the number of bytes loaded into the EP3 FIFO must be monitored so
that the data can be read before the FIFO overflows.
Breaking the block in smaller 128 bytes chunks and simply calling the
original code sequence has solved the issue for me.
Tested with a DS1490F usb<->one-wire adapter and both the DS28EC20 and
DS2433 eeprom memories.
Signed-off-by: Marc Ferland <marc.ferland@sonatest.com>
Link: https://lore.kernel.org/r/20231218150230.1992448-2-marc.ferland@sonatest.com
[krzysztof: fix checkpatch 'spaces preferred around']
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Detailed description for this pull request:
1. Fix possible memory leak of device name in extcon_dev_register()
: Fix memory leak on error path of extcon_dev_register().
2. Set interrupt polarity based on device-tree for extcon-usbc-tusb320.c
:Remove 'IRQF_TRIGGER_FALLING' request which is not allowed on
every interrupt controller (i.e. arm64 GIC). Replace flag by a
request that depends on the actual device-tree setting.
3. Fix the comment style according to guide on extcon-qcom-spmi-misc.c.
-----BEGIN PGP SIGNATURE-----
iQIzBAABCgAdFiEEsSpuqBtbWtRe4rLGnM3fLN7rz1MFAmWAx9gACgkQnM3fLN7r
z1ORMg//SGXMJx3P2ftYtjxQN0pn/EdyMFQwRzSMW484nsm/3lbpNsVlf/50b536
HBTUt+mkD/nUhWkEjPFfzPmWJWvX8tw/ly17aBi1VhBneJhAmxDggjNZAeTm4Xby
M5H+XvU4m+QeGLGuFqB03q/6UEHjmkn/I5f6cFUl+NYUTNNndT3Dyxfy98CpXcIR
r7ir5SgucLbjS4kwQluBE01fiGSE93xxFYFM/36JwOL7QBdXwVh0kSTcw5X1WMZd
+u81xU41P4CJDLcrtMAERuZbzVfZebUjMuPwNorgHV7RK5KmENlADh0HZxDmRWBK
pdyJXnK0C2Q4y+7zxzjRwsWBQ2CkWRyq1Gb93b41hD8MKZYITAS2y5FzczQ17iPk
KyOnJ8f1bXg5L0d4X5XVTBcy/7ZrgzJzvK51rD+78h7zFNW/T97pUzOt6KXaaY9X
YxTlCY2oxPJxpEjdWoBkRC2AX3wKL1b8KmO0x6uJ9ue4D0WhqGDr4PgRzE12eFxb
8kiu0cgcKvXTNGUam6BzWeu9uJ+6zX95Bybywh566jDqvUNHV50wCh2yRHQlj1Lr
VciwPW3iVPqeXIBOgHrxFM42bcsAK7b9PucxTjzVOhdJqGO8nww07eecPTnDZ2tI
kT0JpJpxpLOs4pps/szqqmxTaaQcWCqc49rqLRJdl4EOdZjRPpw=
=KBLg
-----END PGP SIGNATURE-----
Merge tag 'extcon-next-for-6.8' of git://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/extcon into char-misc-next
Chanwoo writes:
Update extcon next for v6.8
Detailed description for this pull request:
1. Fix possible memory leak of device name in extcon_dev_register()
: Fix memory leak on error path of extcon_dev_register().
2. Set interrupt polarity based on device-tree for extcon-usbc-tusb320.c
:Remove 'IRQF_TRIGGER_FALLING' request which is not allowed on
every interrupt controller (i.e. arm64 GIC). Replace flag by a
request that depends on the actual device-tree setting.
3. Fix the comment style according to guide on extcon-qcom-spmi-misc.c.
* tag 'extcon-next-for-6.8' of git://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/extcon:
extcon: qcom-spmi-misc: don't use kernel-doc marker for comment
extcon: usbc-tusb320: Set interrupt polarity based on device-tree
extcon: fix possible name leak in extcon_dev_register()
========
- Added alignment check for event ring read pointer to avoid the potential
buffer corruption issue.
- Added support for SDX75 modem which takes longer time to enter READY state.
- Added spinlock to protect concurrent access while queuing transfer ring
elements.
- Dropped the read channel lock before invoking the client callback as the
client can potentially queue buffers thus ending up wtih soft lockup.
MHI Endpoint
============
- Used kzalloc() to allocate event ring elements instead of allocating the
elements on the stack, as the endpoint controller trying to queue them may not
be able to use vmalloc memory (using DMA).
- Used slab allocator for allocting the memory for objects used frequently and
are of fixed size.
- Added support for interrupt moderation timer feature which is used by the host
to limit the number of interrupts raised by the device for an event ring.
- Added async read/write DMA support for transferring data between host and the
endpoint. So far MHI EP stack assumed that the data will be transferred
synchronously (i.e., it sends completion once the transfer APIs are returned).
But this impacts the throughput if the controller is using DMA to do the
transfer.
So to add async suport, existing sync transfer APIs are renamed to
{read/write}_sync and also introduced two new APIs {read/write}_async for
carrying out the async transfer.
Controllers implementing the async APIs should queue the buffers and return
immediately without waiting for transfer completion. Once the transfer
completion happens later, they should invoke the completion callback so that
the MHI EP stack can send the completion event to the host.
The controller driver patches (PCI EPF) for this async support are also merged
to the MHI tree with Acks from PCI maintainers.
- Fixed the DMA channel direction in error path of the PCI EPF driver.
-----BEGIN PGP SIGNATURE-----
iQEzBAABCgAdFiEEZ6VDKoFIy9ikWCeXVZ8R5v6RzvUFAmWAUzEACgkQVZ8R5v6R
zvX6kQf/T3vG4seI9u+pUEmkmtF0ilmbyFqgcoGQPgED736uNQo8jKhpVuz8gqmg
nfHDXP36dzpUL5ycVqDT8RwGfL1qqCNS65p0mGeheXwoAeapzEjU4Asopq1b6gXm
PE3/yjIzyMqBWBE/y6Ubms3ptNq1TPqU8mQ1HImhkPOfaVGxB0TGy4kfSwlO3ufY
RQ2qmfnXB28rslmEi28Wi9iuYSroKGT1zBj3a4mb4TlJ2RJMNjlGhvpuXZbLLqlh
1FA6DZRs4U2eM4MNsq/klxXLMBG4HCsKLkPZpZwgKrLlNSirAC3DKSAUlE8W6WHp
kJB/3dx0rVgRHYx/Z0epWKUWmnAXXA==
=1NzX
-----END PGP SIGNATURE-----
Merge tag 'mhi-for-v6.8' of git://git.kernel.org/pub/scm/linux/kernel/git/mani/mhi into char-misc-next
Manivannan writes:
MHI Host
========
- Added alignment check for event ring read pointer to avoid the potential
buffer corruption issue.
- Added support for SDX75 modem which takes longer time to enter READY state.
- Added spinlock to protect concurrent access while queuing transfer ring
elements.
- Dropped the read channel lock before invoking the client callback as the
client can potentially queue buffers thus ending up wtih soft lockup.
MHI Endpoint
============
- Used kzalloc() to allocate event ring elements instead of allocating the
elements on the stack, as the endpoint controller trying to queue them may not
be able to use vmalloc memory (using DMA).
- Used slab allocator for allocting the memory for objects used frequently and
are of fixed size.
- Added support for interrupt moderation timer feature which is used by the host
to limit the number of interrupts raised by the device for an event ring.
- Added async read/write DMA support for transferring data between host and the
endpoint. So far MHI EP stack assumed that the data will be transferred
synchronously (i.e., it sends completion once the transfer APIs are returned).
But this impacts the throughput if the controller is using DMA to do the
transfer.
So to add async suport, existing sync transfer APIs are renamed to
{read/write}_sync and also introduced two new APIs {read/write}_async for
carrying out the async transfer.
Controllers implementing the async APIs should queue the buffers and return
immediately without waiting for transfer completion. Once the transfer
completion happens later, they should invoke the completion callback so that
the MHI EP stack can send the completion event to the host.
The controller driver patches (PCI EPF) for this async support are also merged
to the MHI tree with Acks from PCI maintainers.
- Fixed the DMA channel direction in error path of the PCI EPF driver.
* tag 'mhi-for-v6.8' of git://git.kernel.org/pub/scm/linux/kernel/git/mani/mhi:
bus: mhi: host: Drop chan lock before queuing buffers
bus: mhi: host: Add spinlock to protect WP access when queueing TREs
PCI: epf-mhi: Fix the DMA data direction of dma_unmap_single()
bus: mhi: ep: Add checks for read/write callbacks while registering controllers
bus: mhi: ep: Add support for async DMA read operation
bus: mhi: ep: Add support for async DMA write operation
PCI: epf-mhi: Enable MHI async read/write support
PCI: epf-mhi: Add support for DMA async read/write operation
PCI: epf-mhi: Simulate async read/write using iATU
bus: mhi: ep: Introduce async read/write callbacks
bus: mhi: ep: Rename read_from_host() and write_to_host() APIs
bus: mhi: ep: Pass mhi_ep_buf_info struct to read/write APIs
bus: mhi: ep: Add support for interrupt moderation timer
bus: mhi: ep: Use slab allocator where applicable
bus: mhi: host: Add alignment check for event ring read pointer
bus: mhi: host: pci_generic: Add SDX75 based modem support
bus: mhi: host: Add a separate timeout parameter for waiting ready
bus: mhi: ep: Do not allocate event ring element on stack
DFL:
- Philipp's change uses memdup_array_user() to do better overflow check
All patches have been reviewed on the mailing list, and have been in the
last linux-next releases (as part of our for-next branch).
Signed-off-by: Xu Yilun <yilun.xu@intel.com>
-----BEGIN PGP SIGNATURE-----
iIkEABYIADEWIQSgSJpClIeaArXyudb8twOBpKCM2gUCZX/adBMceWlsdW4ueHVA
aW50ZWwuY29tAAoJEPy3A4GkoIzaYr4BAN3ETNLgUIhQ9Uc9qElSwfs2LvcoHcrf
3uUwMNdH2UXxAP9jMBRsfc41f1NzDbpHtjt6WgB/dTTQIqiZxsoRnn6DDg==
=PXVw
-----END PGP SIGNATURE-----
Merge tag 'fpga-for-6.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/fpga/linux-fpga into char-misc-next
Xu writes:
FPGA Manager changes for 6.8-rc1
DFL:
- Philipp's change uses memdup_array_user() to do better overflow check
All patches have been reviewed on the mailing list, and have been in the
last linux-next releases (as part of our for-next branch).
Signed-off-by: Xu Yilun <yilun.xu@intel.com>
* tag 'fpga-for-6.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/fpga/linux-fpga:
drivers/fpga: use standard array-copy function
The ad7091r-base driver sets up an interrupt handler for firing events
when inputs are either above or below a certain threshold.
However, for the interrupt signal to come from the device it must be
configured to enable the ALERT/BUSY/GPO pin to be used as ALERT, which
was not being done until now.
Enable interrupt signals on the ALERT/BUSY/GPO pin by setting the proper
bit in the configuration register.
Signed-off-by: Marcelo Schmitt <marcelo.schmitt@analog.com>
Link: https://lore.kernel.org/r/e8da2ee98d6df88318b14baf3dc9630e20218418.1702746240.git.marcelo.schmitt1@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Previous version of ad7091r event handler received the ADC state pointer
and retrieved the iio device from driver data field with dev_get_drvdata().
However, no driver data have ever been set, which led to null pointer
dereference when running the event handler.
Pass the iio device to the event handler and retrieve the ADC state struct
from it so we avoid the null pointer dereference and save the driver from
filling the driver data field.
Fixes: ca69300173 ("iio: adc: Add support for AD7091R5 ADC")
Signed-off-by: Marcelo Schmitt <marcelo.schmitt@analog.com>
Link: https://lore.kernel.org/r/5024b764107463de9578d5b3b0a3d5678e307b1a.1702746240.git.marcelo.schmitt1@gmail.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Checkpatch presumes attributes marked with __aligned(alignment) are part
of a function declaration and throws a warning stating that those
compiler attributes should have an identifier name which is not correct.
Add __aligned compiler attributes to the list of attribute notes
so they don't cause warnings anymore.
Signed-off-by: Marcelo Schmitt <marcelo.schmitt@analog.com>
Acked-by: Joe Perches <joe@perches.com>
Link: https://lore.kernel.org/r/1c5c93ecbd8c46a338b22a4ef52e51648e333c01.1702746240.git.marcelo.schmitt1@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
A simple driver for the TVOC (Total Volatile Organic Compounds)
sensor from Aosong: AGS02MA
Steps in reading the VOC sensor value over i2c:
1. Read 5 bytes from the register `AGS02MA_TVOC_READ_REG` [0x00]
2. The first 4 bytes are taken as the big endian sensor data with final
byte being the CRC
3. The CRC is verified and the value is returned over an
`IIO_CHAN_INFO_RAW` channel as percents
Tested on Raspberry Pi Zero 2W
Datasheet: https://asairsensors.com/wp-content/uploads/2021/09/AGS02MA.pdf
Signed-off-by: Anshul Dalal <anshulusr@gmail.com>
Link: https://lore.kernel.org/r/20231215162312.143568-3-anshulusr@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Aosong Electronic Co., LTD. is a supplier for MEMS sensors such as AHT20
temperature and humidity sensor under the brand name Asair
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Anshul Dalal <anshulusr@gmail.com>
Link: https://lore.kernel.org/r/20231215162312.143568-1-anshulusr@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
update the comments and Kconfig file with more descriptive and
accurate information about newly added device: BMI085, BMI090L.
Signed-off-by: Jun Yan <jerrysteve1101@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Make gb-beagleplay greybus spec compliant by moving cport information to
transport layer instead of using `header->pad` bytes.
Greybus HDLC frame now has the following payload:
1. le16 cport
2. gb_operation_msg_hdr msg_header
3. u8 *msg_payload
Fixes: ec558bbfea ("greybus: Add BeaglePlay Linux Driver")
Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
Link: https://lore.kernel.org/r/20231217121133.74703-2-ayushdevel1325@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Ensure read and write locks for the channel are not taken in succession by
dropping the read lock from parse_xfer_event() such that a callback given
to client can potentially queue buffers and acquire the write lock in that
process. Any queueing of buffers should be done without channel read lock
acquired as it can result in multiple locks and a soft lockup.
Cc: <stable@vger.kernel.org> # 5.7
Fixes: 1d3173a3ba ("bus: mhi: core: Add support for processing events from client device")
Signed-off-by: Qiang Yu <quic_qianyu@quicinc.com>
Reviewed-by: Jeffrey Hugo <quic_jhugo@quicinc.com>
Tested-by: Jeffrey Hugo <quic_jhugo@quicinc.com>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Link: https://lore.kernel.org/r/1702276972-41296-3-git-send-email-quic_qianyu@quicinc.com
[mani: added fixes tag and cc'ed stable]
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Protect WP accesses such that multiple threads queueing buffers for
incoming data do not race.
Meanwhile, if CONFIG_TRACE_IRQFLAGS is enabled, irq will be enabled once
__local_bh_enable_ip is called as part of write_unlock_bh. Hence, let's
take irqsave lock after TRE is generated to avoid running write_unlock_bh
when irqsave lock is held.
Cc: stable@vger.kernel.org
Fixes: 189ff97cca ("bus: mhi: core: Add support for data transfer")
Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
Signed-off-by: Qiang Yu <quic_qianyu@quicinc.com>
Reviewed-by: Jeffrey Hugo <quic_jhugo@quicinc.com>
Tested-by: Jeffrey Hugo <quic_jhugo@quicinc.com>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Link: https://lore.kernel.org/r/1702276972-41296-2-git-send-email-quic_qianyu@quicinc.com
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Add device IDs for the Brainboxes UC-203, UC-257, UC-414, UC-475,
IS-300/IS-500 and PX-263/PX-295 and define the relevant "geometry"
for the cards.
This patch requires part 1 of this series.
Cc: <stable@vger.kernel.org>
Signed-off-by: Cameron Williams <cang1@live.co.uk>
Acked-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Link: https://lore.kernel.org/r/AS4PR02MB7903A4094564BE28F1F926A6C4A6A@AS4PR02MB7903.eurprd02.prod.outlook.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
As per the current code base, PM_CLOCK_SETRATE and PM_CLOCK_GETRATE
APIs are not supported for the runtime operations. In the case of
ZynqMP returning an error from TF-A when there is any request to
access these APIs and for Versal also it is returning an error like
NO_ACCESS from the firmware. So, just removing the unused code to
avoid the confusion around these APIs.
Also, there is no issue with the backward compatibility as these APIs
were never used since implemented. Hence no need to bump up the
version of the feature check API as well.
Signed-off-by: Ronak Jain <ronak.jain@amd.com>
Signed-off-by: Michal Simek <michal.simek@amd.com>
Link: https://lore.kernel.org/r/6ccbffbafd1f0f48f6574d5a3bf2db6a5603fdb0.1702565618.git.michal.simek@amd.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Use struct_size() instead of handle_arr_calc_size().
This is much more conventional.
While at it, use size_add() when computing the needed size in
vmci_handle_arr_append_entry(). This prevents from (unlikely) overflow
when computing the new size to reallocate.
Suggested-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/84e7f2d8e7c4c2eab68f958307d56546978f76e3.1702125347.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Utilize the managed resource (devres) framework and add the following
devm_* helpers for the SPMI driver:
- devm_spmi_controller_alloc()
- devm_spmi_controller_add()
[sboyd@kernel.org: Rename to spmi-devres for module niceness, slap on
GPL module license]
Signed-off-by: Fei Shao <fshao@chromium.org>
Link: https://lore.kernel.org/r/20230824104101.4083400-2-fshao@chromium.org
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Link: https://lore.kernel.org/r/20231206231733.4031901-4-sboyd@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
The pmif driver data that contains the clocks is allocated along with
spmi_controller.
On device remove, spmi_controller will be freed first, and then devres
, including the clocks, will be cleanup.
This leads to UAF because putting the clocks will access the clocks in
the pmif driver data, which is already freed along with spmi_controller.
This can be reproduced by enabling DEBUG_TEST_DRIVER_REMOVE and
building the kernel with KASAN.
Fix the UAF issue by using unmanaged clk_bulk_get() and putting the
clocks before freeing spmi_controller.
Reported-by: Fei Shao <fshao@chromium.org>
Signed-off-by: Yu-Che Cheng <giver@chromium.org>
Link: https://lore.kernel.org/r/20230717173934.1.If004a6e055a189c7f2d0724fa814422c26789839@changeid
Tested-by: Fei Shao <fshao@chromium.org>
Reviewed-by: Fei Shao <fshao@chromium.org>
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Link: https://lore.kernel.org/r/20231206231733.4031901-3-sboyd@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Before writing the read or write command to the SPMI arbiter through the
PMIF interface, the current status of the channel is checked to ensure
it is idle. However, since the status only changes from idle when the
command is written, it is possible for two concurrent calls to determine
that the channel is idle and simultaneously send their commands. At this
point the PMIF interface hangs, with the status register no longer being
updated, and thus causing all subsequent operations to time out.
This was observed on the mt8195-cherry-tomato-r2 machine, particularly
after commit 46600ab142 ("regulator: Set PROBE_PREFER_ASYNCHRONOUS for
drivers between 5.10 and 5.15") was applied, since then the two MT6315
devices present on the SPMI bus would probe assynchronously and
sometimes (during probe or at a later point) read the bus
simultaneously, breaking the PMIF interface and consequently slowing
down the whole system.
To fix the issue at its root cause, introduce locking around the channel
status check and the command write, so that both become an atomic
operation, preventing race conditions between two (or more) SPMI bus
read/write operations. A spinlock is used since this is a fast bus, as
indicated by the usage of the atomic variant of readl_poll, and
'.fast_io = true' being used in the mt6315 driver, so spinlocks are
already used for the regmap access.
Fixes: b45b3ccef8 ("spmi: mediatek: Add support for MT6873/8192")
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Link: https://lore.kernel.org/r/20230724154739.493724-1-nfraprado@collabora.com
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Link: https://lore.kernel.org/r/20231206231733.4031901-2-sboyd@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
rts5264 can support sd express card, so add the id in sd express card init
to do rts5264 register setting when the sd express card insert
Signed-off-by: Ricky Wu <ricky_wu@realtek.com>
Link: https://lore.kernel.org/r/20231208032145.2143580-4-ricky_wu@realtek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
in order to support rts5264 in rtsx_pcr add the id in and
determine whether the device is rts5264 to call rts5264
functions and do rts5264 workflows or set rts5264 registers
Signed-off-by: Ricky Wu <ricky_wu@realtek.com>
Link: https://lore.kernel.org/r/20231208032145.2143580-3-ricky_wu@realtek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
in order to support NEW chip rts5264, the definitions of some internal
registers are define in new file rts5264.h, and some callback functions
and the workflow for rts5264 are define in new file rts5264.c
also add rts5264.o to Makefile
Signed-off-by: Ricky Wu <ricky_wu@realtek.com>
Link: https://lore.kernel.org/r/20231208032145.2143580-2-ricky_wu@realtek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
The DT of_device.h and of_platform.h date back to the separate
of_platform_bus_type before it was merged into the regular platform bus.
As part of that merge prepping Arm DT support 13 years ago, they
"temporarily" include each other. They also include platform_device.h
and of.h. As a result, there's a pretty much random mix of those include
files used throughout the tree. In order to detangle these headers and
replace the implicit includes with struct declarations, users need to
explicitly include the correct includes.
CDX was fixed once, but commit ("cdx: Remove cdx controller list from cdx
bus system") added another occurrence.
Fixes: 54b406e10f ("cdx: Remove cdx controller list from cdx bus system")
Signed-off-by: Rob Herring <robh@kernel.org>
Acked-by: Nikhil Agarwal <Nikhil.agarwal@amd.com>
Link: https://lore.kernel.org/r/20231207163128.2707993-2-robh@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Commit b9873755a6 ("misc: Add Nitro Secure Module driver") adds Nitro
Security Module support, which selects the non-existing config CBOR.
In the development of the commit, there was initially some code for CBOR
independent of the driver, and the driver included this code with the line
'select CBOR'. This code for CBOR was later reduced to its bare minimum of
functionality and included into the driver itself. The select CBOR remained
unnoticed and was left behind without having any further purpose.
Remove selecting the non-existing config CBOR.
Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Reviewed-by: Alexander Graf <graf@amazon.com>
Link: https://lore.kernel.org/r/20231211074242.22999-1-lukas.bulwahn@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>