summaryrefslogtreecommitdiffstats
path: root/drivers/staging/wfx/bus_spi.c
Commit message (Collapse)AuthorAgeFilesLines
* staging: wfx: remove unused included header filesMuhammad Usama Anjum2021-02-121-7/+0
| | | | | | | | | Many header files have been included, but never used. Those header files have been removed. Signed-off-by: Muhammad Usama Anjum <musamaanjum@gmail.com> Link: https://lore.kernel.org/r/20210211143637.GA177425@LEGION Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* staging: wfx: update copyrights datesJérôme Pouiller2020-10-071-1/+1
| | | | | | | | | Most of the files have been modified in 2020, so update the copyright notices. Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com> Link: https://lore.kernel.org/r/20201007101943.749898-6-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* staging: wfx: Get descriptors for GPIOsLinus Walleij2020-07-101-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | The code has the functionality to insert the GPIO lines using the global GPIO numbers through module parameters. As we are clearly deprecating the use of global GPIO numbers look up the GPIO descriptors from the device instead. This usually falls back to device hardware descriptions using e.g. device tree or ACPI. This device clearly supports device tree when used over SPI for example. For example, this can be supplied in the device tree like so: wfx@0x01 { compatible = "silabs,wf200"; reset-gpios = <&gpio0 1>; wakeup-gpios = <&gpio0 2>; }; Cc: Jérôme Pouiller <jerome.pouiller@silabs.com> Reviewed-by: Jérôme Pouiller <jerome.pouiller@silabs.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20200703130756.514868-1-linus.walleij@linaro.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* staging: wfx: poll IRQ during initJérôme Pouiller2020-05-131-3/+13
| | | | | | | | | | | | | | When the chip starts in SDIO mode, the external IRQ (aka Out-Of-Band IRQ) cannot be used before to configure it. Therefore, the first exchanges with the chip have to be done without the OOB IRQ. This patch allow to poll the data until the OOB IRQ is correctly setup. In order to keep the code simpler, this patch also poll data even if OOB IRQ is not used. Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com> Link: https://lore.kernel.org/r/20200505123757.39506-9-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* staging: wfx: use threaded IRQ with SPIJérôme Pouiller2020-05-131-22/+12
| | | | | | | | | | | | | | Currently, the SPI implementation use a workqueue to acknowledge IRQ while the SDIO-OOB implementation use a threaded IRQ. The threaded also offers the advantage to allow level triggered IRQs. Uniformize the code and use threaded IRQ in both case. Therefore, prefer level triggered IRQs if the user does not specify it in the DT. Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com> Link: https://lore.kernel.org/r/20200505123757.39506-7-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* staging: wfx: drop useless checkJérôme Pouiller2020-05-131-4/+0
| | | | | | | | | | Currently, the ISR check if bus->core is not NULL. But, it is a useless check. bus->core is initialiased before to request IRQ and it is not assigned to NULL when it is released. Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com> Link: https://lore.kernel.org/r/20200505123757.39506-5-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* staging: wfx: use more power-efficient sleep for resetMichał Mirosław2020-02-111-2/+2
| | | | | | | | Replace udelay() with usleep_range() as all uses are in a sleepable context. Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl> Link: https://lore.kernel.org/r/59e1e4e5bd80c1879ef36eaa59916e47005dbb04.1581416843.git.mirq-linux@rere.qmqm.pl Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* staging: wfx: use sleeping gpio accessorsMichał Mirosław2020-02-111-2/+2
| | | | | | | | | Driver calls GPIO get/set only from non-atomic context and so can use any GPIOs. Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl> Link: https://lore.kernel.org/r/cb19e7c521712d5a166e0b7e9cac4450798fdce0.1581416843.git.mirq-linux@rere.qmqm.pl Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* staging: wfx: add proper "compatible" stringMichał Mirosław2020-02-111-4/+10
| | | | | | | | | | | | | Add "compatible" string matching "vendor,chip" template and proper GPIO flags handling. Keep support for old name and reset polarity for older devicetrees. Cc: stable@vger.kernel.org # d3a5bcb4a17f ("gpio: add gpiod_toggle_active_low()") Cc: stable@vger.kernel.org Fixes: 0096214a59a7 ("staging: wfx: add support for I/O access") Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl> Link: https://lore.kernel.org/r/0e6dda06f145676861860f073a53dc95987c7ab5.1581416843.git.mirq-linux@rere.qmqm.pl Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* staging: wfx: fix init/remove vs IRQ raceMichał Mirosław2020-02-111-13/+14
| | | | | | | | | | | | | | | | Current code races in init/exit with interrupt handlers. This is noticed by the warning below. Fix it by using devres for ordering allocations and IRQ de/registration. WARNING: CPU: 0 PID: 827 at drivers/staging/wfx/bus_spi.c:142 wfx_spi_irq_handler+0x5c/0x64 [wfx] race condition in driver init/deinit Cc: stable@vger.kernel.org Fixes: 0096214a59a7 ("staging: wfx: add support for I/O access") Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl> Reviewed-by: Jérôme Pouiller <jerome.pouiller@silabs.com> Link: https://lore.kernel.org/r/f0c66cbb3110c2736cd4357c753fba8c14ee3aee.1581416843.git.mirq-linux@rere.qmqm.pl Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* staging: wfx: use meaningful names for CFG_BYTE_ORDER_*Jérôme Pouiller2019-12-181-0/+2
| | | | | | | | This new naming allows to save a comment. Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com> Link: https://lore.kernel.org/r/20191217161318.31402-18-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* staging: wfx: uniformize naming ruleJérôme Pouiller2019-12-181-3/+2
| | | | | | | | | | | | | In wfx driver, when a function is used as a struct member, its name is the name of the member prefixed with "wfx_". This patch apply this rule to wfx_spi_remove(). Also remove the useless comment above the function. Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com> Link: https://lore.kernel.org/r/20191217161318.31402-17-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* staging: wfx: increase SPI bus frequency limitJérôme Pouiller2019-12-181-1/+1
| | | | | | | | | The chip has now proven that it can run at 50MHz on any boards without any problem. Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com> Link: https://lore.kernel.org/r/20191217161318.31402-12-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* staging: wfx: fix warning of line over 80 charactersJules Irenge2019-10-261-3/+6
| | | | | | | | | Fix warning of lines over 80 characters. Issue detected by checkpatch tool. Signed-off-by: Jules Irenge <jbi.octave@gmail.com> Link: https://lore.kernel.org/r/20191019140719.2542-3-jbi.octave@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* staging: wfx: fix warnings of no space is necessaryJules Irenge2019-10-261-1/+1
| | | | | | | | | Fix warnings of no space is necessary after a cast. Issue detected by checkpatch tool. Signed-off-by: Jules Irenge <jbi.octave@gmail.com> Link: https://lore.kernel.org/r/20191019140719.2542-2-jbi.octave@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* staging: wfx: setup initial chip configurationJérôme Pouiller2019-10-041-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | A few tasks remain to be done in order to finish chip initial configuration: - configure chip to use multi-tx confirmation (speed up data transfer) - configure chip to use wake-up feature (save power consumption during runtime) - set hardware configuration (clocks, RF, pinout, etc...) using a Platform Data Set (PDS) file On release, driver completely shutdown the chip to save power consumption. Documentation about PDS and PDS data for sample boards are available here[1]. One day, PDS data may find a place in device tree but, currently, PDS is too much linked with firmware to allowing that. This patch also add "send_pds" file in debugfs to be able to dynamically change PDS (only for debug, of course). [1]: https://github.com/SiliconLabs/wfx-firmware/tree/master/PDS Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com> Link: https://lore.kernel.org/r/20190919142527.31797-15-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* staging: wfx: add IRQ handlingJérôme Pouiller2019-10-041-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | bh_work() is in charge to schedule all HIF message from/to chip. On normal operation, when an IRQ is received, driver can get size of next message in control register. In order to save control register access, when chip send a message, it also appends a copy of control register after the message (this register is not accounted in message length declared in message header, but must accounted in bus request). This copy of control register is called "piggyback". It also handles a power saving mechanism specific to WFxxx series. This mechanism is based on a GPIO called "wakeup" GPIO. Obviously, this gpio is not part of SPI/SDIO standard buses and must be declared independently (this is the main reason for why SDIO mode try to get parameters from DT). When wakeup is enabled, host can communicate with chip only if it is awake. To wake up chip, there are two cases: - host receive an IRQ from chip (chip initiate communication): host just have to set wakeup GPIO before reading data - host want to send data to chip: host set wakeup GPIO, then wait for an IRQ (in fact, wait for an empty message) and finally send data bh_work() is also in charge to track usage of chip buffers. Normally each request expect a confirmation. However, you can notice that special "multi tx" confirmation can acknowledge multiple requests at time. Finally, note that wfx_bh_request_rx() is not atomic (because of control_reg_read()). So, in SPI mode, hard-irq handler only postpone all processing to wfx_spi_request_rx(). Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com> Link: https://lore.kernel.org/r/20190919142527.31797-8-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* staging: wfx: load firmwareJérôme Pouiller2019-10-041-0/+7
| | | | | | | | | | | | | | | | | | A firmware is necessary to run the chip. wfx_init_device() is in charge of loading firmware on chip and doing low level initialization. Firmwares for WF200 are available here: https://github.com/SiliconLabs/wfx-firmware/ Note that firmware are encrypted. Driver checks that key used to encrypt firmware match with key burned into chip. Currently, "C0" key is used for production chips. Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com> Link: https://lore.kernel.org/r/20190919142527.31797-6-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* staging: wfx: add support for I/O accessJérôme Pouiller2019-10-041-1/+199
| | | | | | | | | | | | Introduce bus level communication layer. At this level, 7 registers can be addressed. Notice that SPI driver is able to manage chip reset. SDIO mode relies on an external driver (`mmc-pwrseq`) to reset chip. Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com> Link: https://lore.kernel.org/r/20190919142527.31797-3-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* staging: wfx: add infrastructure for new driverJérôme Pouiller2019-10-041-0/+53
Instantiate build infrastructure WFx driver. This driver provides support for Wifi chipset Silicon Labs WF200 and further: https://www.silabs.com/documents/public/data-sheets/wf200-datasheet.pdf This chip support SPI and SDIO bus. SDIO interface has two particularities: 1. Some parameters may be useful for end user (I will talk about gpio_wakeup later). 2. The SDIO VID and PID of WF200 are 0000:0001 which are too much generic to rely on. So, current code checks VID/PID and looks for a node in DT (since WF200 targets embedded platforms, I don't think it is a problem to rely on DT). DT can also be used to define to parameters for driver. Currently, if no node is found, a warning is emitted, but it could be changed in error. Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com> Link: https://lore.kernel.org/r/20190919142527.31797-2-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>