aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/mt7621-gpio (follow)
AgeCommit message (Collapse)AuthorFilesLines
2018-06-01staging: mt7621-gpio: reorder includes alphabeticallySergio Paracuellos1-4/+4
This commit reviews driver includes reordering them in alphabetic order. This improves readability. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Reviewed-by: NeilBrown <neil@brown.name> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-01staging: mt7621-gpio: change gc_map to don't use pointersSergio Paracuellos1-10/+7
There is no special gain in using pointers for 'gc_map' inside 'mtk_data' structure. We know the number of banks which is fixed to MTK_BANK_CNT and we can just statically allocate them without using kernel allocators. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Reviewed-by: NeilBrown <neil@brown.name> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-01staging: mt7621-gpio: use GPIOF_DIR_OUT and GPIOF_DIR_IN macros instead of custom valuesSergio Paracuellos1-1/+2
There are macros in gpio kernel's headers to define direction of a gpio. Use them instead of return custom '0' and '1' values. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Reviewed-by: NeilBrown <neil@brown.name> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-01staging: mt7621-gpio: change 'to_mediatek_gpio' to make just a one line returnSergio Paracuellos1-7/+3
Function to_mediatek_gpio can directly return without declaring anything else in its body improving readability. Also change pointer '*' declaration to be with return type in the upper 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>
2018-06-01staging: mt7621-gpio: dt-bindings: update documentation for #interrupt-cells propertySergio Paracuellos1-2/+8
This commit update documentation for #interrupt-cells property in the gpio node which has been changed from '1' to '2'. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Reviewed-by: NeilBrown <neil@brown.name> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-01staging: mt7621-gpio: update #interrupt-cells for the gpio nodeSergio Paracuellos1-1/+1
Most gpio chips have two cells for interrupts and this should be also. Set this property in the device tree accordly fixing this up. In order to make this working properly the xlate function for the irq_domain must be updated to use the 'irq_domain_xlate_twocell' one in the driver. One more minimal change is needed two refer gpio's interrupt-parent from other nodes which is to add new 'gpio' label in the device tree. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Reviewed-by: NeilBrown <neil@brown.name> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-01staging: mt7621-gpio: dt-bindings: complete documentation for the gpioSergio Paracuellos1-5/+9
This commit reviews and complete documentation for gpio related stuff in the mt7621 device. It should be complete now. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Reviewed-by: NeilBrown <neil@brown.name> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-01staging: mt7621-gpio: change lock place in irq mask and unmask functionsSergio Paracuellos1-4/+2
Functions mediatek_gpio_irq_umask mediatek_gpio_irq_unmask are reading and modifying registers but only the write is being hold. It should be a complete lock instead for those which are type of "read-modify-write". This makes more sense. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Reviewed-by: NeilBrown <neil@brown.name> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-01staging: mt7621-gpio: avoid locking in mediatek_gpio_get_directionSergio Paracuellos1-6/+1
mediatek_gpio_get_direction function is holding across a simple read which it seems to be not neccessary at all. Just remove this locking cleaning code of this function a bit. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Reviewed-by: NeilBrown <neil@brown.name> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-01staging: mt7621-gpio: fix masks for gpio pinSergio Paracuellos1-5/+6
BIT macro is being used to get mask for gpio's pin which is retrieved using 'hwirq' from struct irq_data. The problem here is that 'hwirq' can be as large as 95, and 1UL << 95 is unlikely to work well. Instead of using BIT macro use a new PIN_MASK macro which takes into account pin and WIDTH of the bank in order to make a proper mask for the gpio pin. Also 'd->hwirq' has been replaced by 'pin' in some places because there was a 'pin' variable in changed functions with the proper value. This improves readability. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Reviewed-by: NeilBrown <neil@brown.name> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-01staging: mt7621-gpio: use module_platform_driver() instead subsys initcallSergio Paracuellos1-7/+1
The driver's init function don't do anything besides registering the platform driver, and the exit function which is not included in the driver should only do driver unregister. Because of this module_platform_driver() macro could just be used instead of having separate functions. Currently the macro is not being used because the driver is initialized at subsys init call level but this isn't necessary since platform devices are defined in the DT as dependencies so there's no need for init calls order. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Reviewed-by: NeilBrown <neil@brown.name> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-01staging: mt7621-gpio: rename MTK_MAX_BANK into MTK_BANK_CNTSergio Paracuellos1-5/+5
There are 3 banks of gpios numbered '0' and '1' and '2'. So the maximum bank number is "2". "3" is the count of banks. In order to make the code looks and be correct on checking max allowed gpio's id it makes sense to change the name of this definition. Also there is another definitions which start with the same prefix MKK_BANK_ of the new name so having those with the same prefix makes all preprocessor structure to be the same. This improves readability. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Reviewed-by: NeilBrown <neil@brown.name> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-25staging: mt7621-gpio: update TODO fileSergio Paracuellos1-2/+0
update TODO file accordly to last changes. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Reviewed-by: NeilBrown <neil@brown.name> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-25staging: mt7621-gpio: use MTK_BANK_WIDTH instead of magic numberSergio Paracuellos1-3/+3
There are some places where magic number '32' is being used to get the gpio bank. There already exist a definition MTK_BANK_WIDTH with this value, so just use it instead. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Reviewed-by: NeilBrown <neil@brown.name> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-25staging: mt7621-gpio: use ternary operator in return in mediatek_gpio_get_directionSergio Paracuellos1-4/+1
This commits replaces if statement and two returns in favour of a only one return using a ternary operator. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Reviewed-by: NeilBrown <neil@brown.name> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-25staging: mt7621-gpio: avoid devm_kzalloc() hidden inside declarations and refactor function a bitSergio Paracuellos1-5/+6
Driver probe function includes an allocation using devm_kzalloc which is "hidden" a bit inside the declarations. Extract this to a better place to increase readability. Also because we are allocating zeroed memory 'memset' statement is not needed at all. Condition for checking for a valid gpio id is wrong and it should be greater or equal instead of only greater so update to be the good one. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Reviewed-by: NeilBrown <neil@brown.name> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-25staging: mt7621-gpio: dt-bindings: add interrupt nodes to bindings docSergio Paracuellos1-1/+8
Interrupt related stuff for gpio controller in mt7621 was missing in device tree documentation. Add it to complete documentation for this driver. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Reviewed-by: NeilBrown <neil@brown.name> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-25staging: mt7621-gpio: avoid use of globals and use platform_data insteadSergio Paracuellos1-28/+62
Gpio driver have a some globals which can be avoided just using platform_data in a proper form. This commit adds a new struct mtk_data which includes all of those globals setting them using platform_set_drvdata and devm_gpiochip_add_data functions. With this properly set we are able to retrieve driver data along the code using kernel api's so globals are not needed anymore. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Reviewed-by: NeilBrown <neil@brown.name> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-25staging: mt7621-gpio: replace 'mtk' to use correct one 'mediatek'Sergio Paracuellos1-2/+2
Gpio driver is using mtk and there is already 'mediatek' binding defined for this maker. Update driver to use it instead the custom one 'mtk'. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Reviewed-by: NeilBrown <neil@brown.name> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-25staging: mt7621-gpio: dt-bindings: add documentation for mt7621-gpioSergio Paracuellos1-0/+51
This commit add missing dt bindings documentation for mt7621-gpio driver. There is some missing stuff here about interrupts with is not also being used in the mt7621.dtsi file. So just include in staging a incomplete version before moving this to kernel's dt-bindings place. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Reviewed-by: NeilBrown <neil@brown.name> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-15staging: mt7621-gpio: add SPDX identifierSergio Paracuellos1-4/+1
It's good to have SPDX identifiers in driver files to make it easier to audit the kernel tree for correct licenses. Fix up the one of staging gpio-mt7621 file to have a proper SPDX identifier, based on the license text in the file itself. The SPDX identifier is a legally binding shorthand, which can be used instead of the full boiler plate text. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Reviewed-by: NeilBrown <neil@brown.name> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-15staging: mt7621-gpio: fix some warnings because of lines exceeded 80 charactersSergio Paracuellos1-6/+13
This patch silence some complains of checkpatch script because of the use of long lines. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Reviewed-by: NeilBrown <neil@brown.name> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-04-23staging: mt7621-gpio: prefer unsigned int to bare unsignedSergio Paracuellos1-6/+6
This commit replaces some bare unsigned definitions in some function parameters in favour of 'unsigned int' which is preferred. This also fix checkpatch warnings about this. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Reviewed-by: NeilBrown <neil@brown.name> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-04-23staging: gpio-mt7621: Include the right headerLinus Walleij1-1/+1
GPIO drivers should include <linux/gpio/driver.h> only, the <linux/gpio.h> header is deprecated. Cc: John Crispin <john@phrozen.org> Cc: Zhiyong Tao <zhiyong.tao@mediatek.com> Cc: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-03-22staging: mt7621-gpio: mt7621: make symbol gc_map staticWei Yongjun1-1/+1
Fixes the following sparse warning: drivers/staging/mt7621-gpio/gpio-mt7621.c:47:3: warning: symbol 'gc_map' was not declared. Should it be static? Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-03-22staging: mt7621-gpio: remove redundant owner assignments of driversHariPrasath Elango1-1/+0
Remove the reduntant owner initialization from this platform driver as the platform_driver_register() takes care of it. Signed-off-by: HariPrasath Elango <hariprasath.elango@gmail.com> Reviewed-by: NeilBrown <neil@brown.name> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-03-19staging: mt7621-gpio: ralink: add mt7621 gpio controllerJohn Crispin4-0/+367
Signed-off-by: John Crispin <blogic@openwrt.org> Signed-off-by: NeilBrown <neil@brown.name> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>