diff options
| author | Philipp Hortmann <philipp.g.hortmann@gmail.com> | 2024-04-21 21:57:17 +0200 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2024-05-04 18:42:43 +0200 |
| commit | eb563dc752d33b0a5d4952964af15ca892f59524 (patch) | |
| tree | 876aea35e9b07d3b4401c325edcd80776a014c45 /drivers | |
| parent | cf707f77a12b905deb22b2a2420a13c359485bff (diff) | |
| download | linux-eb563dc752d33b0a5d4952964af15ca892f59524.tar.gz linux-eb563dc752d33b0a5d4952964af15ca892f59524.tar.bz2 linux-eb563dc752d33b0a5d4952964af15ca892f59524.zip | |
staging: pi433: Remove unused driver
Marcus started a project in 2016 to bring the pi433 alive. One project
was funded successfully but the second not. So only a few pi433 got sold
to early adaptors during this time that ended late 2017. There is a
simple user space program available for a demo with the pi433 but that
does not use this driver.
The driver is unused since 2018. No description or user space application
to use it can be found. To bring it alive the device tree needs to be
adjusted manually.
The last patch reviewed by Marcus was in June 2018, last patch tested
was in July 2017.
No response since 27. March 2024 regarding the removal of the driver.
Remove unused driver because of the above named reasons.
Link: https://lore.kernel.org/linux-staging/c4c5ab38-8c67-4c21-86bc-f4f3c06be358@gmail.com/
Link: https://www.kickstarter.com/projects/1292669042/pi433-a-radio-module-funkmodul-for-raspberry-pi
Link: https://www.kickstarter.com/projects/1292669042/smarthome-pi/comments
Link: https://www.pi433.de/en.html
Signed-off-by: Philipp Hortmann <philipp.g.hortmann@gmail.com>
Cc: Marcus Wolf <marcus.wolf@wolf-entwicklungen.de>
Link: https://lore.kernel.org/r/20240421195717.GA10943@matrix-ESPRIMO-P710
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/staging/Kconfig | 2 | ||||
| -rw-r--r-- | drivers/staging/Makefile | 1 | ||||
| -rw-r--r-- | drivers/staging/pi433/Documentation/devicetree/pi433-overlay.dtso | 48 | ||||
| -rw-r--r-- | drivers/staging/pi433/Documentation/devicetree/pi433.txt | 62 | ||||
| -rw-r--r-- | drivers/staging/pi433/Documentation/pi433.txt | 274 | ||||
| -rw-r--r-- | drivers/staging/pi433/Kconfig | 17 | ||||
| -rw-r--r-- | drivers/staging/pi433/Makefile | 4 | ||||
| -rw-r--r-- | drivers/staging/pi433/TODO | 8 | ||||
| -rw-r--r-- | drivers/staging/pi433/pi433_if.c | 1437 | ||||
| -rw-r--r-- | drivers/staging/pi433/pi433_if.h | 148 | ||||
| -rw-r--r-- | drivers/staging/pi433/rf69.c | 832 | ||||
| -rw-r--r-- | drivers/staging/pi433/rf69.h | 66 | ||||
| -rw-r--r-- | drivers/staging/pi433/rf69_enum.h | 126 | ||||
| -rw-r--r-- | drivers/staging/pi433/rf69_registers.h | 478 |
14 files changed, 0 insertions, 3503 deletions
diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index 8e0e9ab37302..db4a392841b1 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -60,8 +60,6 @@ source "drivers/staging/greybus/Kconfig" source "drivers/staging/vc04_services/Kconfig" -source "drivers/staging/pi433/Kconfig" - source "drivers/staging/axis-fifo/Kconfig" source "drivers/staging/fieldbus/Kconfig" diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index 471b483e9042..5390879b5d1b 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -20,6 +20,5 @@ obj-$(CONFIG_MOST) += most/ obj-$(CONFIG_KS7010) += ks7010/ obj-$(CONFIG_GREYBUS) += greybus/ obj-$(CONFIG_BCM2835_VCHIQ) += vc04_services/ -obj-$(CONFIG_PI433) += pi433/ obj-$(CONFIG_XIL_AXIS_FIFO) += axis-fifo/ obj-$(CONFIG_FIELDBUS_DEV) += fieldbus/ diff --git a/drivers/staging/pi433/Documentation/devicetree/pi433-overlay.dtso b/drivers/staging/pi433/Documentation/devicetree/pi433-overlay.dtso deleted file mode 100644 index 096137fcd5cc..000000000000 --- a/drivers/staging/pi433/Documentation/devicetree/pi433-overlay.dtso +++ /dev/null @@ -1,48 +0,0 @@ -// Definitions for Pi433 -/dts-v1/; -/plugin/; - -/ { - compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709"; -}; - -&spi0 { - #address-cells = <1>; - #size-cells = <0>; - status = "okay"; - - spidev@0{ - reg = <0>; - status = "disabled"; - }; - - spidev@1{ - reg = <1>; - status = "disabled"; - }; -}; - -&gpio { - pi433_pins: pi433_pins { - brcm,pins = <7 25 24>; - brcm,function = <0 0 0>; // in in in - }; -}; - -&spi0 { - #address-cells = <1>; - #size-cells = <0>; - status = "okay"; - - pi433: pi433@0 { - compatible = "Smarthome-Wolf,pi433"; - reg = <0>; - spi-max-frequency = <10000000>; - status = "okay"; - - pinctrl-0 = <&pi433_pins>; - DIO0-gpio = <&gpio 24 0>; - DIO1-gpio = <&gpio 25 0>; - DIO2-gpio = <&gpio 7 0>; - }; -}; diff --git a/drivers/staging/pi433/Documentation/devicetree/pi433.txt b/drivers/staging/pi433/Documentation/devicetree/pi433.txt deleted file mode 100644 index d317c0ec3419..000000000000 --- a/drivers/staging/pi433/Documentation/devicetree/pi433.txt +++ /dev/null @@ -1,62 +0,0 @@ -* Smarthome-Wolf Pi433 - a 433MHz radio module/shield for Raspberry Pi (see www.pi433.de) - -Required properties: -- compatible: must be "Smarthome-Wolf,pi433" -- reg: chip select of SPI Interface -- DIOx-gpio must be dedicated to the GPIO, connected with DIOx of the RFM69 module - - -Example: - -With the following lines in gpio-section, the gpio pins, connected with pi433 are -reserved/declared. - -&gpio{ - [...] - - pi433_pins: pi433_pins { - brcm,pins = <7 25 24>; - brcm,function = <0 0 0>; // in in in - }; - - [...] -} - -With the following lines in spi section, the device pi433 is declared. -It consists of the three gpio pins and an spi interface (here chip select 0) - -&spi0{ - [...] - - pi433: pi433@0 { - compatible = "Smarthome-Wolf,pi433"; - reg = <0>; /* CE 0 */ - #address-cells = <1>; - #size-cells = <0>; - spi-max-frequency = <10000000>; - - pinctrl-0 = <&pi433_pins>; - DIO0-gpio = <&gpio 24 0>; - DIO1-gpio = <&gpio 25 0>; - DIO2-gpio = <&gpio 7 0>; - }; -} - - - -For Raspbian users only -======================= -Since Raspbian supports device tree overlays, you may use an overlay instead -of editing your boards device tree. -To use the overlay, you need to compile the file pi433-overlay.dtso which can -be found alongside this documentation. -The file needs to be compiled - either manually or by integration in your kernel -source tree. For a manual compile, you may use a command line like the following: -'linux/scripts/dtc/dtc -@ -I dts -O dtb -o pi433.dtbo pi433-overlay.dtso' - -For compiling inside of the kernel tree, you need to copy pi433-overlay.dtso to -arch/arm/boot/dts/overlays and you need to add the file to the list of files -in the Makefile over there. Execute 'make dtbs' in kernel tree root to make the -kernel make files compile the device tree overlay for you. - - diff --git a/drivers/staging/pi433/Documentation/pi433.txt b/drivers/staging/pi433/Documentation/pi433.txt deleted file mode 100644 index 4a0d34b4ad37..000000000000 --- a/drivers/staging/pi433/Documentation/pi433.txt +++ /dev/null @@ -1,274 +0,0 @@ -===== -Pi433 -===== - - -Introduction -============ -This driver is for controlling pi433, a radio module for the Raspberry Pi -(www.pi433.de). It supports transmission and reception. It can be opened -by multiple applications for transmission and reception. While transmit -jobs are queued and processed automatically in the background, the first -application asking for reception will block out all other applications -until something gets received terminates the read request. -The driver supports on the fly reloading of the hardware fifo of the rf -chip, thus enabling for much longer telegrams than the hardware fifo size. - -Description of driver operation -=============================== - -a) transmission - -Each transmission can take place with a different configuration of the rf -module. Therefore each application can set its own set of parameters. The driver -takes care, that each transmission takes place with the parameterset of the -application, that requests the transmission. To allow the transmission to take -place in the background, a tx thread is introduced. -The transfer of data from the main thread to the tx thread is realised by a -kfifo. With each write request of an application, the passed in data and the -corresponding parameter set gets written to the kfifo. -On the other "side" of the kfifo, the tx thread continuously checks, whether the -kfifo is empty. If not, it gets one set of config and data from the kfifo. If -there is no receive request or the receiver is still waiting for something in -the air, the rf module is set to standby, the parameters for transmission gets -set, the hardware fifo of the rf chip gets preloaded and the transmission gets -started. Upon hardware fifo threshold interrupt it gets reloaded, thus enabling -much longer telegrams than the hardware fifo size. If the telegram is sent and there -is more data available in the kfifo, the procedure is repeated. If not the -transmission cycle ends. - -b) reception - -Since there is only one application allowed to receive data at a time, for -reception there is only one configuration set. -As soon as an application sets a request for receiving a telegram, the reception -configuration set is written to the rf module and it gets set into receiving mode. -Now the driver is waiting, that a predefined RSSI level (signal strength at the -receiver) is reached. Until this hasn't happened, the reception can be -interrupted by the transmission thread at any time to insert a transmission cycle. -As soon as the predefined RSSI level is met, a receiving cycle starts. Similar -as described for the transmission cycle the read out of the hardware fifo is done -dynamically. Upon each hardware fifo threshold interrupt, a portion of data gets -read. So also for reception it is possible to receive more data than the hardware -fifo can hold. - - -Driver API -========== - -The driver is currently implemented as a character device. Therefore it supports -the calls open, ioctl, read, write and close. - - -params for ioctl ----------------- - -There are four options: -PI433_IOC_RD_TX_CFG - get the transmission parameters from the driver -PI433_IOC_WR_TX_CFG - set the transmission parameters -PI433_IOC_RD_RX_CFG - get the receiving parameters from the driver -PI433_IOC_WR_RX_CFG - set the receiving parameters - -The tx configuration is transferred via struct pi433_tx_cfg, the parameterset for transmission. -It is divided into two sections: rf parameters and packet format. - -rf params: - frequency - frequency used for transmission. - Allowed values: 433050000...434790000 - bit_rate - bit rate used for transmission. - Allowed values: ##### - dev_frequency - frequency deviation in case of FSK. - Allowed values: 600...500000 - modulation - FSK - frequency shift key - OOK - On-Off-key - modShaping - shapingOff - no shaping - shaping1_0 - gauss filter with BT 1 (FSK only) - shaping0_5 - gauss filter with BT 0.5 (FSK only) - shaping0_3 - gauss filter with BT 0.3 (FSK only) - shapingBR - filter cut off at BR (OOK only) - shaping2BR - filter cut off at 2*BR (OOK only) - pa_ramp (FSK only) - ramp3400 - amp ramps up in 3.4ms - ramp2000 - amp ramps up in 2.0ms - ramp1000 - amp ramps up in 1ms - ramp500 - amp ramps up in 500us - ramp250 - amp ramps up in 250us - ramp125 - amp ramps up in 125us - ramp100 - amp ramps up in 100us - ramp62 - amp ramps up in 62us - ramp50 - amp ramps up in 50us - ramp40 - amp ramps up in 40us - ramp31 - amp ramps up in 31us - ramp25 - amp ramps up in 25us - ramp20 - amp ramps up in 20us - ramp15 - amp ramps up in 15us - ramp12 - amp ramps up in 12us - ramp10 - amp ramps up in 10us - tx_start_condition - fifo_level - transmission starts, if fifo is filled to - threshold level - fifo_not_empty - transmission starts, as soon as there is one - byte in internal fifo - repetitions - This gives the option, to send a telegram multiple times. Default: 1 - -packet format: - enable_preamble - optionOn - a preamble will be automatically generated - optionOff - no preamble will be generated - enable_sync - optionOn - a sync word will be automatically added to - the telegram after the preamble - optionOff - no sync word will be added - Attention: While possible to generate sync without preamble, the - receiver won't be able to detect the sync without preamble. - enable_length_byte - optionOn - the length of the telegram will be automatically - added to the telegram. It's part of the payload - optionOff - no length information will be automatically added - to the telegram. - Attention: For telegram length over 255 bytes, this option can't be used - Attention: should be used in combination with sync, only - enable_address_byte - optionOn - the address byte will be automatically added to the - telegram. It's part of the payload - optionOff - the address byte will not be added to the telegram. - The address byte can be used for address filtering, so the receiver - will only receive telegrams with a given address byte. - Attention: should be used in combination with sync, only - enable_crc - optionOn - an crc will be automatically calculated over the - payload of the telegram and added to the telegram - after payload. - optionOff - no crc will be calculated - preamble_length - length of the preamble. Allowed values: 0...65536 - sync_length - length of the sync word. Allowed values: 0...8 - fixed_message_length - length of the payload of the telegram. Will override the length - given by the buffer, passed in with the write command. Will be - ignored if set to zero. - sync_pattern[8] - contains up to eight values, that are used as the sync pattern - on sync option - address_byte - one byte, used as address byte on address byte option. - - -The rx configuration is transferred via struct pi433_rx_cfg, the parameterset for receiving. It is divided into two sections: rf parameters and packet format. - -rf params: - frequency - frequency used for transmission. - Allowed values: 433050000...434790000 - bit_rate - bit rate used for transmission. - Allowed values: ##### - dev_frequency - frequency deviation in case of FSK. - Allowed values: 600...500000 - modulation - FSK - frequency shift key - OOK - on off key - rssi_threshold - threshold value for the signal strength on the receiver input. - If this value is exceeded, a reception cycle starts - Allowed values: 0...255 - threshold_decrement - in order to adapt to different levels of singnal strength, over - time the receiver gets more and more sensitive. This value - determs, how fast the sensitivity increases. - step_0_5db - increase in 0,5dB steps - step_1_0db - increase in 1 db steps - step_1_5db - increase in 1,5dB steps - step_2_0db - increase in 2 db steps - step_3_0db - increase in 3 db steps - step_4_0db - increase in 4 db steps - step_5_0db - increase in 5 db steps - step_6_0db - increase in 6 db steps - antenna_impedance - sets the electrical adoption of the antenna - fifty_ohm - for antennas with an impedance of 50Ohm - two_hundred_ohm - for antennas with an impedance of 200Ohm - lna_gain - sets the gain of the low noise amp - automatic - lna gain is determined by an agc - max - lna gain is set to maximum - max_minus_6 - lna gain is set to 6db below max - max_minus_12 - lna gain is set to 12db below max - max_minus_24 - lna gain is set to 24db below max - max_minus_36 - lna gain is set to 36db below max - max_minus_48 - lna gain is set to 48db below max - bw_mantisse - sets the bandwidth of the channel filter - part one: mantisse. - mantisse16 - mantisse is set to 16 - mantisse20 - mantisse is set to 20 - mantisse24 - mantisse is set to 24 - bw_exponent - sets the bandwidth of the channel filter - part two: exponent. - Allowd values: 0...7 - dagc; - operation mode of the digital automatic gain control - normal_mode - improve - improve_for_low_modulation_index - - packet format: - enable_sync - optionOn - sync detection is enabled. If configured sync pattern - isn't found, telegram will be internally discarded - optionOff - sync detection is disabled. - enable_length_byte - optionOn - First byte of payload will be used as a length byte, - regardless of the amount of bytes that were requested - by the read request. - optionOff - Number of bytes to be read will be set according to - amount of bytes that were requested by the read request. - Attention: should be used in combination with sync, only - enable_address_filtering; - filtering_off - no address filtering will take place - node_address - all telegrams, not matching the node - address will be internally discarded - node_or_broadcast_address - all telegrams, neither matching the - node, nor the broadcast address will - be internally discarded - Attention: Sync option must be enabled in order to use this feature - enable_crc - optionOn - a crc will be calculated over the payload of - the telegram, that was received. If the - calculated crc doesn't match to two bytes, - that follow the payload, the telegram will be - internally discarded. - Attention: This option is only operational if sync on and fixed length - or length byte is used - sync_length - Gives the length of the payload. - Attention: This setting must meet the setting of the transmitter, - if sync option is used. - fixed_message_length - Overrides the telegram length either given by the first byte of - payload or by the read request. - bytes_to_drop - gives the number of bytes, that will be dropped before transferring - data to the read buffer - This option is only useful if all packet helper are switched - off and the rf chip is used in raw receiving mode. This may be - needed, if a telegram of a third party device should be received, - using a protocol not compatible with the packet engine of the rf69 chip. - sync_pattern[8] - contains up to eight values, that are used as the sync pattern - on sync option. - This setting must meet the configuration of the transmitting device, - if sync option is enabled. - node_address - one byte, used as node address byte on address byte option. - broadcast_address - one byte, used as broadcast address byte on address byte option. - - diff --git a/drivers/staging/pi433/Kconfig b/drivers/staging/pi433/Kconfig deleted file mode 100644 index dd9e4709d1a8..000000000000 --- a/drivers/staging/pi433/Kconfig +++ /dev/null @@ -1,17 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -config PI433 - tristate "Pi433 - a 433MHz radio module for Raspberry Pi" - depends on SPI - help - This option allows you to enable support for the radio module Pi433. - - Pi433 is a shield that fits onto the GPIO header of a Raspberry Pi - or compatible. It extends the Raspberry Pi with the option, to - send and receive data in the 433MHz ISM band - for example to - communicate between two systems without using ethernet or bluetooth - or for control or read sockets, actors, sensors, widely available - for low price. - - For details or the option to buy, please visit https://pi433.de/en.html - - If in doubt, say N here, but saying yes most probably won't hurt diff --git a/drivers/staging/pi433/Makefile b/drivers/staging/pi433/Makefile deleted file mode 100644 index 051132fe4dae..000000000000 --- a/drivers/staging/pi433/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -obj-$(CONFIG_PI433) += pi433.o - -pi433-objs := pi433_if.o rf69.o diff --git a/drivers/staging/pi433/TODO b/drivers/staging/pi433/TODO deleted file mode 100644 index 23c808fc99de..000000000000 --- a/drivers/staging/pi433/TODO +++ /dev/null @@ -1,8 +0,0 @@ -* currently the code introduces new IOCTLs. I'm afraid this is a bad idea. - -> Replace this with another interface, hints are welcome! -* Some missing data (marked with ###) needs to be added in the documentation -* Change (struct pi433_tx_cfg)->bit_rate to be a u32 so that we can support - bit rates up to 300kbps per the spec. - -> This configuration needs to be moved to sysfs instead of being done through - IOCTL. Going forward, we need to port userspace tools to use sysfs instead - of IOCTL and then we would delete IOCTL. diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c deleted file mode 100644 index befddf6bcea9..000000000000 --- a/drivers/staging/pi433/pi433_if.c +++ /dev/null @@ -1,1437 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * userspace interface for pi433 radio module - * - * Pi433 is a 433MHz radio module for the Raspberry Pi. - * It is based on the HopeRf Module RFM69CW. Therefore inside of this - * driver, you'll find an abstraction of the rf69 chip. - * - * If needed, this driver could be extended, to also support other - * devices, basing on HopeRfs rf69. - * - * The driver can also be extended, to support other modules of - * HopeRf with a similar interface - e. g. RFM69HCW, RFM12, RFM95, ... - * - * Copyright (C) 2016 Wolf-Entwicklungen - * Marcus Wolf <linux@wolf-entwicklungen.de> - */ - -#undef DEBUG - -#include <linux/init.h> -#include <linux/module.h> -#include <linux/idr.h> -#include <linux/ioctl.h> -#include <linux/uaccess.h> -#include <linux/fs.h> -#include <linux/device.h> -#include <linux/cdev.h> -#include <linux/err.h> -#include <linux/kfifo.h> -#include <linux/errno.h> -#include <linux/mutex.h> -#include <linux/of.h> -#include <linux/interrupt.h> -#include <linux/irq.h> -#include <linux/gpio/consumer.h> -#include <linux/kthread.h> -#include <linux/wait.h> -#include <linux/spi/spi.h> -#ifdef CONFIG_COMPAT -#include <linux/compat.h> -#endif -#include <linux/debugfs.h> -#include <linux/seq_file.h> - -#include "pi433_if.h" -#include "rf69.h" - -#define N_PI433_MINORS BIT(MINORBITS) /*32*/ /* ... up to 256 */ -#define MAX_MSG_SIZE 900 /* min: FIFO_SIZE! */ -#define MSG_FIFO_SIZE 65536 /* 65536 = 2^16 */ -#define FIFO_THRESHOLD 15 /* bytes */ -#define NUM_DIO 2 - -static dev_t pi433_devt; -static DEFINE_IDR(pi433_idr); -static DEFINE_MUTEX(minor_lock); /* Protect idr accesses */ -static struct dentry *root_dir; /* debugfs root directory for the driver */ - -/* mainly for udev to create /dev/pi433 */ -static const struct class pi433_class = { - .name = "pi433", -}; - -/* - * tx config is instance specific - * so with each open a new tx config struct is needed - */ -/* - * rx config is device specific - * so we have just one rx config, embedded in device struct - */ -struct pi433_device { - /* device handling related values */ - dev_t devt; - int minor; - struct device *dev; - struct cdev *cdev; - struct spi_device *spi; - - /* irq related values */ - struct gpio_desc *gpiod[NUM_DIO]; - int irq_num[NUM_DIO]; - u8 irq_state[NUM_DIO]; - - /* tx related values */ - STRUCT_KFIFO_REC_1(MSG_FIFO_SIZE) tx_fifo; - struct mutex tx_fifo_lock; /* serialize userspace writers */ - struct task_struct *tx_task_struct; - wait_queue_head_t tx_wait_queue; - u8 free_in_fifo; - char tx_buffer[MAX_MSG_SIZE]; - - /* rx related values */ - struct pi433_rx_cfg rx_cfg; - u8 *rx_buffer; - unsigned int rx_buffer_size; - u32 rx_bytes_to_drop; - u32 rx_bytes_dropped; - unsigned int rx_position; - struct mutex rx_lock; /* protects rx_* variable accesses */ - wait_queue_head_t rx_wait_queue; - - /* fifo wait queue */ - struct task_struct *fifo_task_struct; - wait_queue_head_t fifo_wait_queue; - - /* flags */ - bool rx_active; - bool tx_active; - bool interrupt_rx_allowed; -}; - -struct pi433_instance { - struct pi433_device *pi433; - struct pi433_tx_cfg tx_cfg; - - /* control flags */ - bool tx_cfg_initialized; -}; - -/*-------------------------------------------------------------------------*/ - -/* GPIO interrupt handlers */ -static irqreturn_t DIO0_irq_handler(int irq, void *dev_id) -{ - struct pi433_device *pi433 = dev_id; - - if (pi433->irq_state[DIO0] == DIO_PACKET_SENT) { - pi433->free_in_fifo = FIFO_SIZE; - dev_dbg(pi433->dev, "DIO0 irq: Packet sent\n"); - wake_up_interruptible(&pi433->fifo_wait_queue); - } else if (pi433->irq_state[DIO0] == DIO_RSSI_DIO0) { - dev_dbg(pi433->dev, "DIO0 irq: RSSI level over threshold\n"); - wake_up_interruptible(&pi433->rx_wait_queue); - } else if (pi433->irq_state[DIO0] == DIO_PAYLOAD_READY) { - dev_dbg(pi433->dev, "DIO0 irq: Payload ready\n"); - pi433->free_in_fifo = 0; - wake_up_interruptible(&pi433->fifo_wait_queue); - } - - return IRQ_HANDLED; -} - -static irqreturn_t DIO1_irq_handler(int irq, void *dev_id) -{ - struct pi433_device *pi433 = dev_id; - - if (pi433->irq_state[DIO1] == DIO_FIFO_NOT_EMPTY_DIO1) { - pi433->free_in_fifo = FIFO_SIZE; - } else if (pi433->irq_state[DIO1] == DIO_FIFO_LEVEL) { - if (pi433->rx_active) - pi433->free_in_fifo = FIFO_THRESHOLD - 1; - else - pi433->free_in_fifo = FIFO_SIZE - FIFO_THRESHOLD - 1; - } - dev_dbg(pi433->dev, - "DIO1 irq: %d bytes free in fifo\n", pi433->free_in_fifo); - wake_up_interruptible(&pi433->fifo_wait_queue); - - return IRQ_HANDLED; -} - -/*-------------------------------------------------------------------------*/ - -static int -rf69_set_rx_cfg(struct pi433_device *pi433, struct pi433_rx_cfg *rx_cfg) -{ - int ret; - int payload_length; - - /* receiver config */ - ret = rf69_set_frequency(pi433->spi, rx_cfg->frequency); - if (ret < 0) - return ret; - ret = rf69_set_modulation(pi433->spi, rx_cfg->modulation); - if (ret < 0) - return ret; - ret = rf69_set_bit_rate(pi433->spi, rx_cfg->bit_rate); - if (ret < 0) - return ret; - ret = rf69_set_antenna_impedance(pi433->spi, rx_cfg->antenna_impedance); - if (ret < 0) - return ret; - ret = rf69_set_rssi_threshold(pi433->spi, rx_cfg->rssi_threshold); - if (ret < 0) - return ret; - ret = rf69_set_ook_threshold_dec(pi433->spi, rx_cfg->threshold_decrement); - if (ret < 0) - return ret; - ret = rf69_set_bandwidth(pi433->spi, rx_cfg->bw_mantisse, - rx_cfg->bw_exponent); - if (ret < 0) - return ret; - ret = rf69_set_bandwidth_during_afc(pi433->spi, rx_cfg->bw_mantisse, - rx_cfg->bw_exponent); - if (ret < 0) - return ret; - ret = rf69_set_dagc(pi433->spi, rx_cfg->dagc); - if (ret < 0) - return ret; - - pi433->rx_bytes_to_drop = rx_cfg->bytes_to_drop; - - /* packet config */ - /* enable */ - if (rx_cfg->enable_sync == OPTION_ON) { - ret = rf69_enable_sync(pi433->spi); - if (ret < 0) - return ret; - - ret = rf69_set_fifo_fill_condition(pi433->spi, - after_sync_interrupt); - if (ret < 0) - return ret; - } else { - ret = rf69_disable_sync(pi433->spi); - if (ret < 0) - return ret; - - ret = rf69_set_fifo_fill_condition(pi433->spi, always); - if (ret < 0) - return ret; - } - if (rx_cfg->enable_length_byte == OPTION_ON) { - ret = rf69_set_packet_format(pi433->spi, packet_length_var); - if (ret < 0) - return ret; - } else { - ret = rf69_set_packet_format(pi433->spi, packet_length_fix); - if (ret < 0) - return ret; - } - ret = rf69_set_address_filtering(pi433->spi, - rx_cfg->enable_address_filtering); - if (ret < 0) - return ret; - - if (rx_cfg->enable_crc == OPTION_ON) { - ret = rf69_enable_crc(pi433->spi); - if (ret < 0) - return ret; - } else { - ret = rf69_disable_crc(pi433->spi); - if (ret < 0) - return ret; - } - - /* lengths */ - ret = rf69_set_sync_size(pi433->spi, rx_cfg->sync_length); - if (ret < 0) - return ret; - if (rx_cfg->enable_length_byte == OPTION_ON) { - ret = rf69_set_payload_length(pi433->spi, 0xff); - if (ret < 0) - return ret; - } else if (rx_cfg->fixed_message_length != 0) { - payload_length = rx_cfg->fixed_message_length; - if (rx_cfg->enable_length_byte == OPTION_ON) - payload_length++; - if (rx_cfg->enable_address_filtering != filtering_off) - payload_length++; - ret = rf69_set_payload_length(pi433->spi, payload_length); - if (ret < 0) - return ret; - } else { - ret = rf69_set_payload_length(pi433->spi, 0); - if (ret < 0) - return ret; - } - - /* values */ - if (rx_cfg->enable_sync == OPTION_ON) { - ret = rf69_set_sync_values(pi433->spi, rx_cfg->sync_pattern); - if (ret < 0) - return ret; - } - if (rx_cfg->enable_address_filtering != filtering_off) { - ret = rf69_set_node_address(pi433->spi, rx_cfg->node_address); - if (ret < 0) - return ret; - ret = rf69_set_broadcast_address(pi433->spi, - rx_cfg->broadcast_address); - if (ret < 0) - return ret; - } - - return 0; -} - -static int -rf69_set_tx_cfg(struct pi433_device *pi433, struct pi433_tx_cfg *tx_cfg) -{ - int ret; - - ret = rf69_set_frequency(pi433->spi, tx_cfg->frequency); - if (ret < 0) - return ret; - ret = rf69_set_modulation(pi433->spi, tx_cfg->modulation); - if (ret < 0) - return ret; - ret = rf69_set_bit_rate(pi433->spi, tx_cfg->bit_rate); - if (ret < 0) - return ret; - ret = rf69_set_deviation(pi433->spi, tx_cfg->dev_frequency); - if (ret < 0) - return ret; - ret = rf69_set_pa_ramp(pi433->spi, tx_cfg->pa_ramp); - if (ret < 0) - return ret; - ret = rf69_set_modulation_shaping(pi433->spi, tx_cfg->mod_shaping); - if (ret < 0) - return ret; - ret = rf69_set_tx_start_condition(pi433->spi, tx_cfg->tx_start_condition); - if (ret < 0) - return ret; - - /* packet format enable */ - if (tx_cfg->enable_preamble == OPTION_ON) { - ret = rf69_set_preamble_length(pi433->spi, - tx_cfg->preamble_length); - if (ret < 0) - return ret; - } else { - ret = rf69_set_preamble_length(pi433->spi, 0); - if (ret < 0) - return ret; - } - - if (tx_cfg->enable_sync == OPTION_ON) { - ret = rf69_set_sync_size(pi433->spi, tx_cfg->sync_length); - if (ret < 0) - return ret; - ret = rf69_set_sync_values(pi433->spi, tx_cfg->sync_pattern); - if (ret < 0) - return ret; - ret = rf69_enable_sync(pi433->spi); - if (ret < 0) - return ret; - } else { - ret = rf69_disable_sync(pi433->spi); - if (ret < 0) - return ret; - } - - if (tx_cfg->enable_length_byte == OPTION_ON) { - ret = rf69_set_packet_format(pi433->spi, packet_length_var); - if (ret < 0) - return ret; - } else { - ret = rf69_set_packet_format(pi433->spi, packet_length_fix); - if (ret < 0) - return ret; - } - - if (tx_cfg->enable_crc == OPTION_ON) { - ret = rf69_enable_crc(pi433->spi); - if (ret < 0) - return ret; - } else { - ret = rf69_disable_crc(pi433->spi); - if (ret < 0) - return ret; - } - - return 0; -} - -/*-------------------------------------------------------------------------*/ - -static int pi433_start_rx(struct pi433_device *pi433) -{ - int retval; - - /* return without action, if no pending read request */ - if (!pi433->rx_active) - return 0; - - /* setup for receiving */ - retval = rf69_set_rx_cfg(pi433, &pi433->rx_cfg); - if (retval) - return retval; - - /* setup rssi irq */ - retval = rf69_set_dio_mapping(pi433->spi, DIO0, DIO_RSSI_DIO0); - if (retval < 0) - return retval; - pi433->irq_state[DIO0] = DIO_RSSI_DIO0; - irq_set_irq_type(pi433->irq_num[DIO0], IRQ_TYPE_EDGE_RISING); - - /* setup fifo level interrupt */ - retval = rf69_set_fifo_threshold(pi433->spi, FIFO_SIZE - FIFO_THRESHOLD); - if (retval < 0) - return retval; - retval = rf69_set_dio_mapping(pi433->spi, DIO1, DIO_FIFO_LEVEL); - if (retval < 0) - return retval; - pi433->irq_state[DIO1] = DIO_FIFO_LEVEL; - irq_set_irq_type(pi433->irq_num[DIO1], IRQ_TYPE_EDGE_RISING); - - /* set module to receiving mode */ - retval = rf69_set_mode(pi433->spi, receive); - if (retval < 0) - return retval; - - return 0; -} - -/*-------------------------------------------------------------------------*/ - -static int pi433_receive(struct pi433_device *pi433) -{ - struct spi_device *spi = pi433->spi; - int bytes_to_read, bytes_total; - int retval; - - pi433->interrupt_rx_allowed = false; - - /* wait for any tx to finish */ - dev_dbg(pi433->dev, "rx: going to wait for any tx to finish\n"); - retval = wait_event_interruptible(pi433->rx_wait_queue, !pi433->tx_active); - if (retval) { - /* wait was interrupted */ - pi433->interrupt_rx_allowed = true; - wake_up_interrup |
