aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/mt7621-pci/pci-mt7621.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2019-07-25staging: mt7621-pci: avoid use 'err' local variableSergio Paracuellos1-6/+1
Function 'mt7621_pcie_request_resources' is using 'err' local variable to get value returned from 'devm_request_pci_bus_resources' and returning after that. This is not needed at all. Instead of that just directly return returned value by the function which is also returning zero on success. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Link: https://lore.kernel.org/r/20190720072908.16795-1-sergio.paracuellos@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-07-22staging: mt7621-pci: Add of_node_put() before returnNishka Dasgupta1-1/+4
Each iteration of for_each_available_child_of_node puts the previous node, but in the case of a return from the middle of the loop, there is no put, thus causing a memory leak. Hence add an of_node_put before the return in two places. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com> Link: https://lore.kernel.org/r/20190716055944.3237-1-nishkadg.linux@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-07-01staging: mt7621-pci: fix PCIE_FTS_NUM_LO macroSergio Paracuellos1-1/+1
Add missing parenthesis to PCIE_FTS_NUM_LO macro to do the same it was being done in original code. Fixes: a4b2eb912bb1 ("staging: mt7621-pci: rewrite RC FTS configuration") Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-06-21staging: mt7621-pci: use 'module_init' instead of 'arch_initcall'Sergio Paracuellos1-1/+1
This driver has dependencies on mt7621-gpio and mt7621-pci-phy which are init in later stages. Hence, when this driver is probed it is always returning 'EPROBE_DEFER' and being initialized afterwards. Use function 'module_init' to just initialize later. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-06-21staging: mt7621-pci: add phy exit call if phy_power_on call failsSergio Paracuellos1-0/+1
Add missing call to 'phy_exit' function if the phy_power_on call fails. With this call added the error path is properly handled. Fixes: 07420a02b003 ("staging: mt7621-pci: use gpio perst instead of builtin behaviour") Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-06-21staging: mt7621-pci: disable pcie port clock if there is no pcie linkSergio Paracuellos1-0/+7
When there is no pcie link detected we have to properly disable the port pcie clock. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-06-20staging: mt7621-pci: use gpio perst instead of builtin behaviourSergio Paracuellos1-48/+58
Some boards seems to ignore the PERST builtin behaviour to properly perform a pcie line reset. Use gpio PERST behaviour instead which seems to be more common. Fixes: bd1a05bd87ad ("staging: mt7621-pci: use PERST_N instead of gpio control") Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-06-20staging: mt7621-pci: fix two messages in driver codeSergio Paracuellos1-2/+2
There are two messages in driver code which are not correct. Fix both of them to clarify boot runs. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-03-18staging: mt7621-pci: IF statement expression comparing to NULLBranden Bonaby1-1/+1
Remove comparison to NULL in the if statement expression to match the Linux Kernel coding style. CHECK: Comparison to NULL could be written "res" Signed-off-by: Branden Bonaby <brandonbonaby94@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-02-19staging: mt7621-pci: reverse condition to check for enabled portSergio Paracuellos1-1/+1
Each enabled port is being checked in 'mt7621_pcie_enable_ports" function calling 'mt7621_pcie_enable_port'. The return value for this function on success is zero, so the check is reversed. Fix it. Fixes: 802a2f7b2fe3: staging: mt7621-pci: factor out 'mt7621_pcie_enable_port' function Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-02-19staging: mt7621-pci: remove two register writesSergio Paracuellos1-4/+0
There is no need to write IO and memory space window Host PCI bridge registers before doing anything else. Just use its default values which should be ok. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Reviewed-by: NeilBrown <neil@brown.name> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-02-19staging: mt7621-pci: replace spaces with tabs in commentSergio Paracuellos1-9/+9
To properly follow kernel style replace spaces with tabs in comment where link status bits are explained. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Reviewed-by: NeilBrown <neil@brown.name> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-02-19staging: mt7621-pci: remove not used definitionsSergio Paracuellos1-2/+0
There are two definitions which are not being used at all. Remove them. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Reviewed-by: NeilBrown <neil@brown.name> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-02-19staging: mt7621-pci: add reset control for general pcie resetSergio Paracuellos1-5/+10
There is still a reset line which is not being handled using reset_control properly and just being accessing writing registers. Use reset_control instead for pcie general reset line. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Reviewed-by: NeilBrown <neil@brown.name> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-02-11Staging: mt7621-pci: Fix space required coding styleGuilherme Tadashi Maeoka1-2/+2
Fix some space required coding style. Signed-off-by: Guilherme Tadashi Maeoka <gui.maeoka@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-01-15staging: mt7621-pci: use PCI definitions instead of hardcode valuesSergio Paracuellos1-2/+3
Seting up ports to enable PCI_COMMAND_MASTER is using '0x4' as a hardcore value and '0x4' also for PCI_COMMAND register instead of use definitions from linux pci system headers. Replace both. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-01-07staging: mt7621-pci: handle phy using new generic phy 'pci-mt7621-phy' driverSergio Paracuellos1-218/+32
Phy part of this driver has been moved to a new 'pci-mt7621-phy' driver. Change code to use kernel's generic phy API removing also no more need moved code. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-05staging: mt7621-pci: add comment clarifying inverted reset linesSergio Paracuellos1-0/+4
To avoid people reading this code being very confused, add a comment clarifying the need for invert resets on some chip revisions. Suggested-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-26staging: mt7621-pci: avoid using clk_* operationsSergio Paracuellos1-16/+0
There is no clock driver for ralink mips and clk_enable are no-ops for this architecture. This has been also tested without using clocks and seems to work so avoid to use them in this driver. Fixes: ad9c87e129d1: "staging: mt7621-pci: parse and init port data from device tree" Reported-by: NeilBrown <neil@brown.name> Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Tested-by: NeilBrown <neil@brown.name> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-26staging: mt7621-pci: fix reset lines for each pcie portSergio Paracuellos1-6/+32
Depending of chip revision reset lines are inverted. It is also necessary to read PCIE_FTS_NUM register before enabling the phy. Hence update the code to achieve this. Fixes: 745eeeac68d7 ("staging: mt7621-pci: factor out 'mt7621_pcie_enable_port' function") Reported-by: NeilBrown <neil@brown.name> Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Tested-by: NeilBrown <neil@brown.name> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-26staging: mt7621-pci: avoid mapping sysctls registersSergio Paracuellos1-14/+1
The sysctl register are already claimed by palmbus, so pci fails to claim it. The best way to access the sysc registers is to use rt_sysc_[rwm]32(). Fixes: 89e9f6e6adfc: staging: mt7621-pci: remap and use sysctl from device tree Reported-by: NeilBrown <neil@brown.name> Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Tested-by: NeilBrown <neil@brown.name> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-11staging: mt7621-pci: replace 'mdelay()' with 'msleep()'Sergio Paracuellos1-1/+1
Function 'mt7621_pcie_init_ports' is never called in atomic context. It calls mdelay() to busily wait, which is not necessary. mdelay() can be replaced with msleep(). Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-11staging: mt7621-pci: move some code into 'mt7621_pcie_init_ports'Sergio Paracuellos1-10/+8
Some clocks bits related code is in driver probe function and can perfectly be moved into 'mt7621_pcie_init_ports' function which is a more accurate place for it. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-11staging: mt7621-pci: factor out 'mt7621_pcie_enable_port' functionSergio Paracuellos1-35/+45
Function 'mt7621_pcie_enable_ports' tries to enable all PCI ports. To make it more readable the single port initialization part has been factor out into a new 'mt7621_pcie_enable_port' function. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-11staging: mt7621-pci: enable interrupt when port is being enabledSergio Paracuellos1-4/+5
Interrupt is being enabled in port initialization when the port phy has not been initialized yet. Just enable the interrupt when the port is being enabled which is a more accurate place for this. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-11staging: mt7621-pci: use PCIE_PORT_LINKUP instead of hardcode valueSergio Paracuellos1-1/+1
PCIE_PORT_LINKUP is defined and can be used to check if link is up for each controller. Use it instead of use a hardcode value. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-11staging: mt7621-pci: use PERST_N instead of gpio controlSergio Paracuellos1-22/+24
Driver is using gpio control instead of each port PERST_N bit. Use PERST_N bit of each port cleaning all the ugly gpio code in driver probe function. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-11staging: mt7621-pci: add some definitions for enabling and disabling GEN and GEN1 clocksSergio Paracuellos1-3/+7
Instead of use hardcoded values when calling 'rt_sysc_m32' for enabling and disabling RALINK_PCIE_CLK_GEN and RALINK_PCIE_CLK_GEN1 create some preprocessor definitions. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-11staging: mt7621-pci: rewrite hardcoded code for enabling portsSergio Paracuellos1-6/+15
There are some hardcoded values in the process for enabling and disabling some stuff inside 'mt7621_pcie_enable_ports' function. Create some preprocessor definitions to make code more readable. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-11staging: mt7621-pci: rewrite RC FTS configurationSergio Paracuellos1-5/+11
The RC FTS configuration is done using hardcoded registers and bitshift operations. Make it a bit clean defining some prepocessor definitions and simple macros. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-11staging: mt7621-pci: align function definition style along the codeSergio Paracuellos1-8/+5
Make some function definition changes in order to get all the functions in the code with the same style. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-11staging: mt7621-pci: remove non sense commentSergio Paracuellos1-5/+0
There is a comment at the beggining which has no sense at all. Remove it. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-11staging: mt7621-pci: reorder preprocessor definitionsSergio Paracuellos1-16/+18
Reorder a bit register definitions and some values into logical groups adding some comments for each group. Also unify all of register to use 16 bit in definitions instead of having some with 16 bits and some with 8 bits. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-11staging: mt7621-pci: remove unused preprocessor definitionsSergio Paracuellos1-9/+0
There are some preprocessor definition which are not being used at all. Remove them cleaning the code a bit. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-11staging: mt7621-pci: factor out 'mt7621_pcie_init_ports' functionSergio Paracuellos1-10/+18
Instead of just inline this code in the probe driver function factor out a new 'mt7621_pcie_init_ports' function to achieve this. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-11staging: mt7621-pci: avoid use of global variable 'pcie_link_status'Sergio Paracuellos1-50/+75
'pcie_link_status' is a global variable which is being used as a mask to know which virtual bridges are or not enabled. Instead of this extract a new 'mt7621_pcie_init_virtual_bridges' function where a similar local variable is used for the same task. This allow us to properly configure the virtual PCI-PCI bridges in configuration registers of the mt7621 pci controller. For a correct initiation of which is connected use 'enabled' field of 'mt7621_pcie_port' struct. With this change driver probe function gets a bit cleaner and readable. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-11staging: mt7621-pci: factor out 'mt7621_pcie_enable_ports' functionSergio Paracuellos1-64/+42
Driver probe function check for a bit in 'pcie_link_status' for enabling the pcie port or not. Instead of this add 'enabled' field in 'mt7621_pcie_port' structure and check its value to achieve this inside a new 'mt7621_pcie_enable_ports' function. The offsets for the correct port are derived from the slot of the port. This field 'enabled' is properly initilized in 'mt7621_pcie_init_port'. Also depending of the number of ports enabled we have to properly init its registers taking into account that we will use virtual bridges from zero to num_slots_enabled as follows: - Only one enabled -> only enable virtual bridge 0. - Two enabled -> enable virtual bridges 0 and 1. - Three enabled -> enable virtual bridges 0, 1 and 2. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-11staging: mt7621-pci: use dev_* functions instead of printkSergio Paracuellos1-6/+8
checkpatch script is complaining about the use of printk instead of use more proper dev_* kernel functions. Replace all of them removing warnings. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-11staging: mt7621-pci: use a trailing */ on a separate lineSergio Paracuellos1-2/+4
Chackpatch script is compalining about one comment which is not following the kernel style. Fix it. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-11staging: mt7621-pci: remap and use sysctl from device treeSergio Paracuellos1-5/+33
There are some pointer read and writes which can be replaced properly using sysctl registers readed from device tree. Remap sysctl registers and replace in proper places. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-11staging: mt7621-pci: rename 'mt7621_pcie_enable_port' into 'mt7621_pcie_init_port'Sergio Paracuellos1-2/+2
Rename function 'mt7621_pcie_enable_port' with a name which is better for what the function is really doing calling it 'mt7621_pcie_init_port'. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-11staging: mt7621-pci: debug port N_FTS inside 'mt7621_pcie_enable_port'Sergio Paracuellos1-3/+3
Move debug for the port N_FTS from driver probe function to the more appropiate one 'mt7621_pcie_enable_port'. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-11staging: mt7621-pci: factor out 'mt7621_enable_phy' functionSergio Paracuellos1-3/+10
Factor out a new function 'mt7621_enable_phy' for enabling the pcie phy for each port and call it from 'mt7621_pcie_enable_port'. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-11staging: mt7621-pci: rewrite pcie phy related functionsSergio Paracuellos1-99/+195
Function 'bypass_pipe_rst' and 'set_phy_for_ssc' can be written in a cleaner way. Instead of use comments to see which bits are the ones which are being enabled add new macros with that information using BIT and GENMASK kernel macros. Avoid the use of set_pcie_phy which is kind of dark and use new macros also resetting and adding bits using bitwise operators directly in the code. Now these function are offset-based on the port to use them cleaner in driver probe functio and improving readability. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-11staging: mt7621-pci: reagroup reset related macros all togetherSergio Paracuellos1-2/+3
Reset bits related macros are in different parts. Reagroup all of them together to improve readability. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-11staging: mt7621-pci: remove reset related unused macrosSergio Paracuellos1-4/+0
There are three macros which are not being used at all. Remove them. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-11staging: mt7621-pci: remove two commented code linesSergio Paracuellos1-5/+0
This two lines whch are commented are not needed at all. Remove them. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-11staging: mt7621-pci: remove GPL2+ text from license headerSergio Paracuellos1-28/+3
This file has a valid SPDX license line added so reamining GPL2+ boilerplate text is not needed at all. Remove it. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-11staging: mt7621-pci: remove [ASSERT|DEASSERT]_SYSRST_PCIE macrosSergio Paracuellos1-15/+0
Driver is using reset_control kernel API's to manage this so this two macros are not needed anymore. Remove them. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-11staging: mt7621-pci: factor out 'mt7621_pcie_enable_port' functionSergio Paracuellos1-47/+41
Driver probe function is a mess and shall be refactored a lot. At first make use of assert and deassert control factoring out a new function called 'mt7621_pcie_enable_port'. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>