gpio: add driver for Mellanox BlueField 2 GPIO controller
v2 cover gpio: add driver for Mellanox BlueField 2 GPIO controller
This patch adds support for the GPIO controller used by Mellanox BlueFIeld
2 SOCs.
This patch addresses the following issues:
1) Split in one gpio_chip per instance (there are 3 instances)
2) Use bgpio_init() for set/clear/get gpio values
3) The direction settings need some special HW lock/unlock to happen and it also uses 2 registers to set the direction instead of one. So direction_input and direction_output are overriden.
Asmaa Mnebhi (1):
gpio: add driver for Mellanox BlueField 2 GPIO controller
drivers/gpio/Kconfig | 7 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-mlxbf2.c | 345 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 353 insertions(+) create mode 100644 drivers/gpio/gpio-mlxbf2.c
Signature · 1 line
2.1.2
PATCH v2 1/1 gpio: add driver for Mellanox BlueField 2 GPIO controller
This patch adds support for the GPIO controller used by Mellanox BlueField 2 SOCs.
--- drivers/gpio/Kconfig | 7 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-mlxbf2.c | 345 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 353 insertions(+) create mode 100644 drivers/gpio/gpio-mlxbf2.c
drivers/gpio/Kconfig +7 -0
@@ -1399,6 +1399,13 @@ config GPIO_MLXBF help Say Y here if you want GPIO support on Mellanox BlueField SoC. +config GPIO_MLXBF2 + tristate "Mellanox BlueField 2 SoC GPIO" + depends on (MELLANOX_PLATFORM && ARM64 && ACPI) || (64BIT && COMPILE_TEST) + select GPIO_GENERIC + help + Say Y here if you want GPIO support on Mellanox BlueField 2 SoC. + config GPIO_ML_IOH tristate "OKI SEMICONDUCTOR ML7213 IOH GPIO support" depends on X86 || COMPILE_TEST
drivers/gpio/Makefile +1 -0
@@ -93,6 +93,7 @@ obj-$(CONFIG_GPIO_MENZ127) += gpio-menz127.o obj-$(CONFIG_GPIO_MERRIFIELD) += gpio-merrifield.o obj-$(CONFIG_GPIO_ML_IOH) += gpio-ml-ioh.o obj-$(CONFIG_GPIO_MLXBF) += gpio-mlxbf.o +obj-$(CONFIG_GPIO_MLXBF2) += gpio-mlxbf2.o obj-$(CONFIG_GPIO_MM_LANTIQ) += gpio-mm-lantiq.o obj-$(CONFIG_GPIO_MOCKUP) += gpio-mockup.o obj-$(CONFIG_GPIO_MOXTET) += gpio-moxtet.o
drivers/gpio/gpio-mlxbf2.c new file +345 -0
345 lines not on this page · raw message
Signature · 1 line
2.1.2
Hi Linus,
Thank you for your feedback!
I have addressed your comments and tested the code. Please note that the YU_ARM_GPIO_LOCK is a shared resource between the 3 gpio blocks instances.
So now that we have split up the gpio_chip into 3 instances, we need to share that LOCK resource accordingly. I have created a global variable for that purpose. Also note, that although it is not supported in this driver at the moment, some gpio interrupt registers will be similar to that LOCK i.e. they are shared among the 3 gpio block instances.
-----Original Message-----
From: Asmaa Mnebhi <[email protected]>
Sent: Tuesday, February 25, 2020 11:33 AM
To: [email protected]; [email protected]
Cc: Asmaa Mnebhi <[email protected]>; [email protected]
Subject: [PATCH v2 1/1] gpio: add driver for Mellanox BlueField 2 GPIO controller
This patch adds support for the GPIO controller used by Mellanox BlueField 2 SOCs.
--- drivers/gpio/Kconfig | 7 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-mlxbf2.c | 345 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 353 insertions(+) create mode 100644 drivers/gpio/gpio-mlxbf2.c
drivers/gpio/Kconfig +7 -0
@@ -1399,6 +1399,13 @@ config GPIO_MLXBF help Say Y here if you want GPIO support on Mellanox BlueField SoC. +config GPIO_MLXBF2 + tristate "Mellanox BlueField 2 SoC GPIO" + depends on (MELLANOX_PLATFORM && ARM64 && ACPI) || (64BIT && COMPILE_TEST) + select GPIO_GENERIC + help + Say Y here if you want GPIO support on Mellanox BlueField 2 SoC. + config GPIO_ML_IOH tristate "OKI SEMICONDUCTOR ML7213 IOH GPIO support" depends on X86 || COMPILE_TEST
drivers/gpio/Makefile +1 -0
@@ -93,6 +93,7 @@ obj-$(CONFIG_GPIO_MENZ127) += gpio-menz127.o obj-$(CONFIG_GPIO_MERRIFIELD) += gpio-merrifield.o obj-$(CONFIG_GPIO_ML_IOH) += gpio-ml-ioh.o obj-$(CONFIG_GPIO_MLXBF) += gpio-mlxbf.o +obj-$(CONFIG_GPIO_MLXBF2) += gpio-mlxbf2.o obj-$(CONFIG_GPIO_MM_LANTIQ) += gpio-mm-lantiq.o obj-$(CONFIG_GPIO_MOCKUP) += gpio-mockup.o obj-$(CONFIG_GPIO_MOXTET) += gpio-moxtet.o
drivers/gpio/gpio-mlxbf2.c new file +332 -0
332 lines not on this page · raw message
--
2.1.2
Quoted 5 lines · Asmaa Mnebhi
I have addressed your comments and tested the code. Please note
that theYU_ARM_GPIO_LOCKis a shared resource between the 3
gpio blocks instances.
So now that we have split up thegpio_chipinto 3 instances, we need to share
that LOCK resource accordingly. I have created a global variable for that purpose.
Fair enough, all looks so much nicer now :)
This:
+ /*
+ * Although the arm_gpio_lock was set in the probe function,
+ * check again it is still enabled to be able to write to the
+ * ModeX registers.
+ */
+ spin_lock(&gs->gc.bgpio_lock);
+ ret = mlxbf2_gpio_lock_acquire();
+ if (ret < 0) {+ spin_unlock(&gs->gc.bgpio_lock);
+ return ret;
+ }
Is open-coded in two places, please create a helper function for this or just merge it into mlbx2_gpio_lock_acquire() since it is done all the time when that is called.
Quoted 3 lines
Also note, that although it is not supported in this driver at the moment, some gpio interrupt registers will be similar to that LOCK i.e. they are shared among the 3 gpio block instances.
It's a good start like this.
The robot complains about devm_ioremap_nocache which is now deleted, use devm_ioremap() simply, they are all write-through.
Yours,
Linus Walleij
kbuild test robot
build botThank you for the patch! Yet something to improve:
Hi Asmaa,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on gpio/for-next]
[also build test ERROR on v5.6-rc3 next-20200225]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Asmaa-Mnebhi/gpio-add-driver-for-Mellanox-BlueField-2-GPIO-controller/20200226-034440 base: https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git for-next config: ia64-allyesconfig (attached as .config) compiler: ia64-linux-gcc (GCC) 7.5.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.5.0 make.cross ARCH=ia64
If you fix the issue, kindly add following tag
All error/warnings (new ones prefixed by >>):
drivers//gpio/gpio-mlxbf2.c: In function 'mlxbf2_gpio_get_lock_res':
>> drivers//gpio/gpio-mlxbf2.c:112:30: error: implicit declaration of function 'devm_ioremap_nocache'; did you mean 'devm_ioremap_release'? [-Werror=implicit-function-declaration]
yu_arm_gpio_lock_param.io = devm_ioremap_nocache(dev, res->start, size);
^~~~~~~~~~~~~~~~~~~~
devm_ioremap_release
>> drivers//gpio/gpio-mlxbf2.c:112:28: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
yu_arm_gpio_lock_param.io = devm_ioremap_nocache(dev, res->start, size);
^cc1: some warnings being treated as errors
vim +112 drivers//gpio/gpio-mlxbf2.c
89
90 /* Request memory region and map yu_arm_gpio_lock resource */
91 static int mlxbf2_gpio_get_lock_res(struct platform_device *pdev)
92 {
93 struct device *dev = &pdev->dev;
94 struct resource *res;
95 resource_size_t size;
96 int ret = 0;
97
98 mutex_lock(yu_arm_gpio_lock_param.lock);
99
100 /* Check if the memory map already exists */
101 if (yu_arm_gpio_lock_param.io)
102 goto exit;
103
104 res = yu_arm_gpio_lock_param.res;
105 size = resource_size(res);
106
107 if (!devm_request_mem_region(dev, res->start, size, res->name)) {
108 ret = -EFAULT;
109 goto exit;
110 }
111
> 112 yu_arm_gpio_lock_param.io = devm_ioremap_nocache(dev, res->start, size); 113 if (IS_ERR(yu_arm_gpio_lock_param.io))
114 ret = PTR_ERR(yu_arm_gpio_lock_param.io);
115
116 exit:
117 mutex_unlock(yu_arm_gpio_lock_param.lock);
118
119 return ret;
120 }
121
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org