Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'gpio-updates-for-v5.16' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux

Pull gpio updates from Bartosz Golaszewski:
"We have a single new driver, new features in others and some cleanups
all over the place.

Nothing really stands out and it is all relatively small.

- new driver: gpio-modepin (plus relevant change in zynqmp firmware)

- add interrupt support to gpio-virtio

- enable the 'gpio-line-names' property in the DT bindings for
gpio-rockchip

- use the subsystem helpers where applicable in gpio-uniphier instead
of accessing IRQ structures directly

- code shrink in gpio-xilinx

- add interrupt to gpio-mlxbf2 (and include the removal of custom
interrupt code from the mellanox ethernet driver)

- support multiple interrupts per bank in gpio-tegra186 (and force
one interrupt per bank in older models)

- fix GPIO line IRQ offset calculation in gpio-realtek-otto

- drop unneeded MODULE_ALIAS expansions in multiple drivers

- code cleanup in gpio-aggregator

- minor improvements in gpio-max730x and gpio-mc33880

- Kconfig cleanups"

* tag 'gpio-updates-for-v5.16' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux:
virtio_gpio: drop packed attribute
gpio: virtio: Add IRQ support
gpio: realtek-otto: fix GPIO line IRQ offset
gpio: clean up Kconfig file
net: mellanox: mlxbf_gige: Replace non-standard interrupt handling
gpio: mlxbf2: Introduce IRQ support
gpio: mc33880: Drop if with an always false condition
gpio: max730x: Make __max730x_remove() return void
gpio: aggregator: Wrap access to gpiochip_fwd.tmp[]
gpio: modepin: Add driver support for modepin GPIO controller
dt-bindings: gpio: zynqmp: Add binding documentation for modepin
firmware: zynqmp: Add MMIO read and write support for PS_MODE pin
gpio: tps65218: drop unneeded MODULE_ALIAS
gpio: max77620: drop unneeded MODULE_ALIAS
gpio: xilinx: simplify getting .driver_data
gpio: tegra186: Support multiple interrupts per bank
gpio: tegra186: Force one interrupt per bank
gpio: uniphier: Use helper functions to get private data from IRQ data
gpio: uniphier: Use helper function to get IRQ hardware number
dt-bindings: gpio: add gpio-line-names to rockchip,gpio-bank.yaml

+943 -351
+2
Documentation/devicetree/bindings/gpio/rockchip,gpio-bank.yaml
··· 29 29 30 30 gpio-controller: true 31 31 32 + gpio-line-names: true 33 + 32 34 "#gpio-cells": 33 35 const: 2 34 36
+43
Documentation/devicetree/bindings/gpio/xlnx,zynqmp-gpio-modepin.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: "http://devicetree.org/schemas/gpio/xlnx,zynqmp-gpio-modepin.yaml#" 5 + $schema: "http://devicetree.org/meta-schemas/core.yaml#" 6 + 7 + title: ZynqMP Mode Pin GPIO controller 8 + 9 + description: 10 + PS_MODE is 4-bits boot mode pins sampled on POR deassertion. Mode Pin 11 + GPIO controller with configurable from numbers of pins (from 0 to 3 per 12 + PS_MODE). Every pin can be configured as input/output. 13 + 14 + maintainers: 15 + - Piyush Mehta <piyush.mehta@xilinx.com> 16 + 17 + properties: 18 + compatible: 19 + const: xlnx,zynqmp-gpio-modepin 20 + 21 + gpio-controller: true 22 + 23 + "#gpio-cells": 24 + const: 2 25 + 26 + required: 27 + - compatible 28 + - gpio-controller 29 + - "#gpio-cells" 30 + 31 + additionalProperties: false 32 + 33 + examples: 34 + - | 35 + zynqmp-firmware { 36 + gpio { 37 + compatible = "xlnx,zynqmp-gpio-modepin"; 38 + gpio-controller; 39 + #gpio-cells = <2>; 40 + }; 41 + }; 42 + 43 + ...
+46
drivers/firmware/xilinx/zynqmp.c
··· 28 28 /* Max HashMap Order for PM API feature check (1<<7 = 128) */ 29 29 #define PM_API_FEATURE_CHECK_MAX_ORDER 7 30 30 31 + /* CRL registers and bitfields */ 32 + #define CRL_APB_BASE 0xFF5E0000U 33 + /* BOOT_PIN_CTRL- Used to control the mode pins after boot */ 34 + #define CRL_APB_BOOT_PIN_CTRL (CRL_APB_BASE + (0x250U)) 35 + /* BOOT_PIN_CTRL_MASK- out_val[11:8], out_en[3:0] */ 36 + #define CRL_APB_BOOTPIN_CTRL_MASK 0xF0FU 37 + 31 38 static bool feature_check_enabled; 32 39 static DEFINE_HASHTABLE(pm_api_features_map, PM_API_FEATURE_CHECK_MAX_ORDER); 33 40 ··· 948 941 param, value, 0, NULL); 949 942 } 950 943 EXPORT_SYMBOL_GPL(zynqmp_pm_pinctrl_set_config); 944 + 945 + /** 946 + * zynqmp_pm_bootmode_read() - PM Config API for read bootpin status 947 + * @ps_mode: Returned output value of ps_mode 948 + * 949 + * This API function is to be used for notify the power management controller 950 + * to read bootpin status. 951 + * 952 + * Return: status, either success or error+reason 953 + */ 954 + unsigned int zynqmp_pm_bootmode_read(u32 *ps_mode) 955 + { 956 + unsigned int ret; 957 + u32 ret_payload[PAYLOAD_ARG_CNT]; 958 + 959 + ret = zynqmp_pm_invoke_fn(PM_MMIO_READ, CRL_APB_BOOT_PIN_CTRL, 0, 960 + 0, 0, ret_payload); 961 + 962 + *ps_mode = ret_payload[1]; 963 + 964 + return ret; 965 + } 966 + EXPORT_SYMBOL_GPL(zynqmp_pm_bootmode_read); 967 + 968 + /** 969 + * zynqmp_pm_bootmode_write() - PM Config API for Configure bootpin 970 + * @ps_mode: Value to be written to the bootpin ctrl register 971 + * 972 + * This API function is to be used for notify the power management controller 973 + * to configure bootpin. 974 + * 975 + * Return: Returns status, either success or error+reason 976 + */ 977 + int zynqmp_pm_bootmode_write(u32 ps_mode) 978 + { 979 + return zynqmp_pm_invoke_fn(PM_MMIO_WRITE, CRL_APB_BOOT_PIN_CTRL, 980 + CRL_APB_BOOTPIN_CTRL_MASK, ps_mode, 0, NULL); 981 + } 982 + EXPORT_SYMBOL_GPL(zynqmp_pm_bootmode_write); 951 983 952 984 /** 953 985 * zynqmp_pm_init_finalize() - PM call to inform firmware that the caller
+68 -55
drivers/gpio/Kconfig
··· 15 15 bool "GPIO Support" 16 16 help 17 17 This enables GPIO support through the generic GPIO library. 18 - You only need to enable this, if you also want to enable 18 + You only need to enable this if you also want to enable 19 19 one or more of the GPIO drivers below. 20 20 21 21 If unsure, say N. ··· 140 140 depends on ACPI 141 141 select GPIO_GENERIC 142 142 help 143 - driver for GPIO functionality on Promontory IOHub 144 - Require ACPI ASL code to enumerate as a platform device. 143 + Driver for GPIO functionality on Promontory IOHub. 144 + Requires ACPI ASL code to enumerate as a platform device. 145 145 146 146 config GPIO_ASPEED 147 147 tristate "Aspeed GPIO support" ··· 306 306 help 307 307 Say Y or M here to build support for the HiSilicon GPIO controller 308 308 driver GPIO block. 309 - This GPIO controller support double-edge interrupt and multi-core 309 + This GPIO controller supports double-edge interrupt and multi-core 310 310 concurrent access. 311 311 312 312 config GPIO_HLWD ··· 326 326 help 327 327 Say yes here to support the GPIO functionality of a number of Intel 328 328 ICH-based chipsets. Currently supported devices: ICH6, ICH7, ICH8 329 - ICH9, ICH10, Series 5/3400 (eg Ibex Peak), Series 6/C200 (eg 329 + ICH9, ICH10, Series 5/3400 (e.g. Ibex Peak), Series 6/C200 (e.g. 330 330 Cougar Point), NM10 (Tiger Point), and 3100 (Whitmore Lake). 331 331 332 332 If unsure, say N. ··· 337 337 select GPIO_GENERIC 338 338 help 339 339 Say yes here to support the GPIO functionality of a number of Intel 340 - IOP32X or IOP33X. 340 + IOP32X or IOP33X series of chips. 341 341 342 342 If unsure, say N. 343 343 ··· 364 364 bool "Loongson-2/3 GPIO support" 365 365 depends on CPU_LOONGSON2EF || CPU_LOONGSON64 366 366 help 367 - driver for GPIO functionality on Loongson-2F/3A/3B processors. 367 + Driver for GPIO functionality on Loongson-2F/3A/3B processors. 368 368 369 369 config GPIO_LPC18XX 370 370 tristate "NXP LPC18XX/43XX GPIO support" ··· 392 392 depends on MCB 393 393 select GPIO_GENERIC 394 394 help 395 - Say yes here to support the MEN 16Z127 GPIO Controller 395 + Say yes here to support the MEN 16Z127 GPIO Controller. 396 396 397 397 config GPIO_MM_LANTIQ 398 398 bool "Lantiq Memory mapped GPIOs" 399 399 depends on LANTIQ && SOC_XWAY 400 400 help 401 401 This enables support for memory mapped GPIOs on the External Bus Unit 402 - (EBU) found on Lantiq SoCs. The gpios are output only as they are 403 - created by attaching a 16bit latch to the bus. 402 + (EBU) found on Lantiq SoCs. The GPIOs are output only as they are 403 + created by attaching a 16-bit latch to the bus. 404 404 405 405 config GPIO_MPC5200 406 406 def_bool y ··· 424 424 select GPIO_GENERIC 425 425 select GPIOLIB_IRQCHIP 426 426 help 427 - Say yes here to support the Mediatek MT7621 SoC GPIO device 427 + Say yes here to support the Mediatek MT7621 SoC GPIO device. 428 428 429 429 config GPIO_MVEBU 430 430 def_bool y ··· 469 469 select IRQ_DOMAIN 470 470 select GPIOLIB_IRQCHIP 471 471 help 472 - Say yes here to support the PrimeCell PL061 GPIO device 472 + Say yes here to support the PrimeCell PL061 GPIO device. 473 473 474 474 config GPIO_PMIC_EIC_SPRD 475 475 tristate "Spreadtrum PMIC EIC support" ··· 483 483 bool "PXA GPIO support" 484 484 depends on ARCH_PXA || ARCH_MMP || COMPILE_TEST 485 485 help 486 - Say yes here to support the PXA GPIO device 486 + Say yes here to support the PXA GPIO device. 487 487 488 488 config GPIO_RCAR 489 489 tristate "Renesas R-Car and RZ/G GPIO support" ··· 573 573 depends on PLAT_SPEAR 574 574 select GENERIC_IRQ_CHIP 575 575 help 576 - Say yes here to support ST SPEAr SPI Chip Select as GPIO device 576 + Say yes here to support ST SPEAr SPI Chip Select as GPIO device. 577 577 578 578 config GPIO_SPRD 579 579 tristate "Spreadtrum GPIO support" ··· 598 598 help 599 599 This enables support for the Serial To Parallel (STP) unit found on 600 600 XWAY SoC. The STP allows the SoC to drive a shift registers cascade, 601 - that can be up to 24 bit. This peripheral is aimed at driving leds. 602 - Some of the gpios/leds can be auto updated by the soc with dsl and 601 + that can be up to 24 bits. This peripheral is aimed at driving LEDs. 602 + Some of the GPIOs/LEDs can be auto updated by the SoC with DSL and 603 603 phy status. 604 604 605 605 config GPIO_SYSCON ··· 679 679 Say yes here to support GPIO on Tohisba Visconti. 680 680 681 681 config GPIO_VR41XX 682 - tristate "NEC VR4100 series General-purpose I/O Uint support" 682 + tristate "NEC VR4100 series General-purpose I/O Unit support" 683 683 depends on CPU_VR41XX 684 684 help 685 - Say yes here to support the NEC VR4100 series General-purpose I/O Uint 685 + Say yes here to support the NEC VR4100 series General-purpose I/O Unit. 686 686 687 687 config GPIO_VX855 688 688 tristate "VIA VX855/VX875 GPIO" ··· 690 690 select MFD_CORE 691 691 select MFD_VX855 692 692 help 693 - Support access to the VX855/VX875 GPIO lines through the gpio library. 693 + Support access to the VX855/VX875 GPIO lines through the GPIO library. 694 694 695 - This driver provides common support for accessing the device, 696 - additional drivers must be enabled in order to use the 695 + This driver provides common support for accessing the device. 696 + Additional drivers must be enabled in order to use the 697 697 functionality of the device. 698 698 699 699 config GPIO_WCD934X 700 - tristate "Qualcomm Technologies Inc WCD9340/WCD9341 gpio controller driver" 700 + tristate "Qualcomm Technologies Inc WCD9340/WCD9341 GPIO controller driver" 701 701 depends on MFD_WCD934X && OF_GPIO 702 702 help 703 703 This driver is to support GPIO block found on the Qualcomm Technologies ··· 727 727 select GPIOLIB_IRQCHIP 728 728 depends on OF_GPIO 729 729 help 730 - Say yes here to support the Xilinx FPGA GPIO device 730 + Say yes here to support the Xilinx FPGA GPIO device. 731 731 732 732 config GPIO_XLP 733 733 tristate "Netlogic XLP GPIO support" ··· 748 748 depends on !SMP 749 749 help 750 750 Say yes here to support the Xtensa internal GPIO32 IMPWIRE (input) 751 - and EXPSTATE (output) ports 751 + and EXPSTATE (output) ports. 752 752 753 753 config GPIO_ZEVIO 754 754 bool "LSI ZEVIO SoC memory mapped GPIOs" ··· 763 763 help 764 764 Say yes here to support Xilinx Zynq GPIO controller. 765 765 766 + config GPIO_ZYNQMP_MODEPIN 767 + tristate "ZynqMP ps-mode pin GPIO configuration driver" 768 + depends on ZYNQMP_FIRMWARE 769 + default ZYNQMP_FIRMWARE 770 + help 771 + Say yes here to support the ZynqMP ps-mode pin GPIO configuration 772 + driver. 773 + 774 + This ps-mode pin GPIO driver is based on GPIO framework. PS_MODE 775 + is 4-bits boot mode pins. It sets and gets the status of 776 + the ps-mode pin. Every pin can be configured as input/output. 777 + 766 778 config GPIO_LOONGSON1 767 779 tristate "Loongson1 GPIO support" 768 780 depends on MACH_LOONGSON32 ··· 785 773 config GPIO_AMD_FCH 786 774 tristate "GPIO support for AMD Fusion Controller Hub (G-series SOCs)" 787 775 help 788 - This option enables driver for GPIO on AMDs Fusion Controller Hub, 789 - as found on G-series SOCs (eg. GX-412TC) 776 + This option enables driver for GPIO on AMD's Fusion Controller Hub, 777 + as found on G-series SOCs (e.g. GX-412TC). 790 778 791 - Note: This driver doesn't registers itself automatically, as it 792 - needs to be provided with platform specific configuration. 793 - (See eg. CONFIG_PCENGINES_APU2.) 779 + Note: This driver doesn't register itself automatically, as it 780 + needs to be provided with platform-specific configuration. 781 + (See e.g. CONFIG_PCENGINES_APU2.) 794 782 795 783 config GPIO_MSC313 796 784 bool "MStar MSC313 GPIO support" ··· 800 788 select IRQ_DOMAIN_HIERARCHY 801 789 help 802 790 Say Y here to support the main GPIO block on MStar/SigmaStar 803 - ARMv7 based SoCs. 791 + ARMv7-based SoCs. 804 792 805 793 config GPIO_IDT3243X 806 794 tristate "IDT 79RC3243X GPIO support" ··· 809 797 select GPIOLIB_IRQCHIP 810 798 help 811 799 Select this option to enable GPIO driver for 812 - IDT 79RC3243X based devices like Mikrotik RB532. 800 + IDT 79RC3243X-based devices like Mikrotik RB532. 813 801 814 802 To compile this driver as a module, choose M here: the module will 815 803 be called gpio-idt3243x. ··· 887 875 well. 888 876 889 877 To compile this driver as a module, choose M here: the module will 890 - be called gpio_it87 878 + be called gpio_it87. 891 879 892 880 config GPIO_SCH 893 881 tristate "Intel SCH/TunnelCreek/Centerton/Quark X1000 GPIO" ··· 903 891 powered by the core power rail and are turned off during sleep 904 892 modes (S3 and higher). The remaining four GPIOs are powered by 905 893 the Intel SCH suspend power supply. These GPIOs remain 906 - active during S3. The suspend powered GPIOs can be used to wake the 894 + active during S3. The suspend-powered GPIOs can be used to wake the 907 895 system from the Suspend-to-RAM state. 908 896 909 897 The Intel Tunnel Creek processor has 5 GPIOs powered by the ··· 1056 1044 select GPIOLIB_IRQCHIP 1057 1045 help 1058 1046 Say yes here to enable the pca953x to be used as an interrupt 1059 - controller. It requires the driver to be built in the kernel. 1047 + controller. 1060 1048 1061 1049 config GPIO_PCA9570 1062 1050 tristate "PCA9570 4-Bit I2C GPO expander" ··· 1183 1171 help 1184 1172 Support for GPIO pins on Crystal Cove PMIC. 1185 1173 1186 - Say Yes if you have a Intel SoC based tablet with Crystal Cove PMIC 1174 + Say Yes if you have a Intel SoC-based tablet with Crystal Cove PMIC 1187 1175 inside. 1188 1176 1189 1177 This driver can also be built as a module. If so, the module will be ··· 1213 1201 Say yes here to enable the GPIO driver for the DA9055 chip. 1214 1202 1215 1203 The Dialog DA9055 PMIC chip has 3 GPIO pins that can be 1216 - be controller by this driver. 1204 + be controlled by this driver. 1217 1205 1218 1206 If driver is built as a module it will be called gpio-da9055. 1219 1207 ··· 1235 1223 help 1236 1224 This driver supports the CPLD egpio chip present on 1237 1225 several HTC phones. It provides basic support for input 1238 - pins, output pins, and irqs. 1226 + pins, output pins, and IRQs. 1239 1227 1240 1228 config GPIO_JANZ_TTL 1241 1229 tristate "Janz VMOD-TTL Digital IO Module" ··· 1296 1284 help 1297 1285 GPIO driver for MAX77620 and MAX20024 PMIC from Maxim Semiconductor. 1298 1286 MAX77620 PMIC has 8 pins that can be configured as GPIOs. The 1299 - driver also provides interrupt support for each of the gpios. 1300 - Say yes here to enable the max77620 to be used as gpio controller. 1287 + driver also provides interrupt support for each of the GPIOs. 1288 + Say yes here to enable the max77620 to be used as GPIO controller. 1301 1289 1302 1290 config GPIO_MAX77650 1303 1291 tristate "Maxim MAX77650/77651 GPIO support" ··· 1319 1307 help 1320 1308 Select this option to enable GPIO driver for the Ricoh RC5T583 1321 1309 chip family. 1322 - This driver provides the support for driving/reading the gpio pins 1323 - of RC5T583 device through standard gpio library. 1310 + This driver provides the support for driving/reading the GPIO pins 1311 + of RC5T583 device through standard GPIO library. 1324 1312 1325 1313 config GPIO_SL28CPLD 1326 1314 tristate "Kontron sl28cpld GPIO support" ··· 1389 1377 tristate "TI TPS65912 GPIO" 1390 1378 depends on MFD_TPS65912 1391 1379 help 1392 - This driver supports TPS65912 gpio chip 1380 + This driver supports TPS65912 GPIO chip. 1393 1381 1394 1382 config GPIO_TPS68470 1395 1383 bool "TPS68470 GPIO" ··· 1397 1385 help 1398 1386 Select this option to enable GPIO driver for the TPS68470 1399 1387 chip family. 1400 - There are 7 GPIOs and few sensor related GPIOs supported 1388 + There are 7 GPIOs and few sensor-related GPIOs supported 1401 1389 by the TPS68470. While the 7 GPIOs can be configured as 1402 1390 input or output as appropriate, the sensor related GPIOs 1403 1391 are "output only" GPIOs. ··· 1442 1430 help 1443 1431 Support for GPIO pins on Whiskey Cove PMIC. 1444 1432 1445 - Say Yes if you have a Intel SoC based tablet with Whiskey Cove PMIC 1433 + Say Yes if you have an Intel SoC-based tablet with Whiskey Cove PMIC 1446 1434 inside. 1447 1435 1448 1436 This driver can also be built as a module. If so, the module will be ··· 1479 1467 depends on X86 || COMPILE_TEST 1480 1468 depends on HAS_IOPORT_MAP 1481 1469 help 1482 - The AMD 8111 south bridge contains 32 GPIO pins which can be used. 1470 + The AMD 8111 southbridge contains 32 GPIO pins which can be used. 1483 1471 1484 - Note, that usually system firmware/ACPI handles GPIO pins on their 1485 - own and users might easily break their systems with uncarefull usage 1472 + Note that usually system firmware/ACPI handles GPIO pins on their 1473 + own and users might easily break their systems with uncareful usage 1486 1474 of this driver! 1487 1475 1488 1476 If unsure, say N ··· 1530 1518 select GENERIC_IRQ_CHIP 1531 1519 help 1532 1520 ML7213 is companion chip for Intel Atom E6xx series. 1533 - This driver can be used for OKI SEMICONDUCTOR ML7213 IOH(Input/Output 1534 - Hub) which is for IVI(In-Vehicle Infotainment) use. 1521 + This driver can be used for OKI SEMICONDUCTOR ML7213 IOH (Input/Output 1522 + Hub) which is for IVI (In-Vehicle Infotainment) use. 1535 1523 This driver can access the IOH's GPIO device. 1536 1524 1537 1525 config GPIO_PCH 1538 - tristate "Intel EG20T PCH/LAPIS Semiconductor IOH(ML7223/ML7831) GPIO" 1526 + tristate "Intel EG20T PCH/LAPIS Semiconductor IOH (ML7223/ML7831) GPIO" 1539 1527 depends on X86_32 || MIPS || COMPILE_TEST 1540 1528 select GENERIC_IRQ_CHIP 1541 1529 help 1542 - This driver is for PCH(Platform controller Hub) GPIO of Intel Topcliff 1543 - which is an IOH(Input/Output Hub) for x86 embedded processor. 1530 + This driver is for PCH (Platform Controller Hub) GPIO of Intel Topcliff, 1531 + which is an IOH (Input/Output Hub) for x86 embedded processor. 1544 1532 This driver can access PCH GPIO device. 1545 1533 1546 - This driver also can be used for LAPIS Semiconductor IOH(Input/ 1534 + This driver also can be used for LAPIS Semiconductor IOH (Input/ 1547 1535 Output Hub), ML7223 and ML7831. 1548 - ML7223 IOH is for MP(Media Phone) use. 1536 + ML7223 IOH is for MP (Media Phone) use. 1549 1537 ML7831 IOH is for general purpose use. 1550 1538 ML7223/ML7831 is companion chip for Intel Atom E6xx series. 1551 1539 ML7223/ML7831 is completely compatible for Intel EG20T PCH. ··· 1596 1584 help 1597 1585 Driver for 74x164 compatible serial-in/parallel-out 8-outputs 1598 1586 shift registers. This driver can be used to provide access 1599 - to more gpio outputs. 1587 + to more GPIO outputs. 1600 1588 1601 1589 config GPIO_MAX3191X 1602 1590 tristate "Maxim MAX3191x industrial serializer" ··· 1686 1674 config GPIO_VIRTIO 1687 1675 tristate "VirtIO GPIO support" 1688 1676 depends on VIRTIO 1677 + select GPIOLIB_IRQCHIP 1689 1678 help 1690 1679 Say Y here to enable guest support for virtio-based GPIO controllers. 1691 1680
+1
drivers/gpio/Makefile
··· 184 184 obj-$(CONFIG_GPIO_XTENSA) += gpio-xtensa.o 185 185 obj-$(CONFIG_GPIO_ZEVIO) += gpio-zevio.o 186 186 obj-$(CONFIG_GPIO_ZYNQ) += gpio-zynq.o 187 + obj-$(CONFIG_GPIO_ZYNQMP_MODEPIN) += gpio-zynqmp-modepin.o
+11 -14
drivers/gpio/gpio-aggregator.c
··· 247 247 unsigned long tmp[]; /* values and descs for multiple ops */ 248 248 }; 249 249 250 + #define fwd_tmp_values(fwd) &(fwd)->tmp[0] 251 + #define fwd_tmp_descs(fwd) (void *)&(fwd)->tmp[BITS_TO_LONGS((fwd)->chip.ngpio)] 252 + 253 + #define fwd_tmp_size(ngpios) (BITS_TO_LONGS((ngpios)) + (ngpios)) 254 + 250 255 static int gpio_fwd_get_direction(struct gpio_chip *chip, unsigned int offset) 251 256 { 252 257 struct gpiochip_fwd *fwd = gpiochip_get_data(chip); ··· 284 279 static int gpio_fwd_get_multiple(struct gpiochip_fwd *fwd, unsigned long *mask, 285 280 unsigned long *bits) 286 281 { 287 - struct gpio_desc **descs; 288 - unsigned long *values; 282 + struct gpio_desc **descs = fwd_tmp_descs(fwd); 283 + unsigned long *values = fwd_tmp_values(fwd); 289 284 unsigned int i, j = 0; 290 285 int error; 291 - 292 - /* Both values bitmap and desc pointers are stored in tmp[] */ 293 - values = &fwd->tmp[0]; 294 - descs = (void *)&fwd->tmp[BITS_TO_LONGS(fwd->chip.ngpio)]; 295 286 296 287 bitmap_clear(values, 0, fwd->chip.ngpio); 297 288 for_each_set_bit(i, mask, fwd->chip.ngpio) ··· 334 333 static void gpio_fwd_set_multiple(struct gpiochip_fwd *fwd, unsigned long *mask, 335 334 unsigned long *bits) 336 335 { 337 - struct gpio_desc **descs; 338 - unsigned long *values; 336 + struct gpio_desc **descs = fwd_tmp_descs(fwd); 337 + unsigned long *values = fwd_tmp_values(fwd); 339 338 unsigned int i, j = 0; 340 - 341 - /* Both values bitmap and desc pointers are stored in tmp[] */ 342 - values = &fwd->tmp[0]; 343 - descs = (void *)&fwd->tmp[BITS_TO_LONGS(fwd->chip.ngpio)]; 344 339 345 340 for_each_set_bit(i, mask, fwd->chip.ngpio) { 346 341 __assign_bit(j, values, test_bit(i, bits)); ··· 395 398 unsigned int i; 396 399 int error; 397 400 398 - fwd = devm_kzalloc(dev, struct_size(fwd, tmp, 399 - BITS_TO_LONGS(ngpios) + ngpios), GFP_KERNEL); 401 + fwd = devm_kzalloc(dev, struct_size(fwd, tmp, fwd_tmp_size(ngpios)), 402 + GFP_KERNEL); 400 403 if (!fwd) 401 404 return ERR_PTR(-ENOMEM); 402 405
+3 -1
drivers/gpio/gpio-max7300.c
··· 50 50 51 51 static int max7300_remove(struct i2c_client *client) 52 52 { 53 - return __max730x_remove(&client->dev); 53 + __max730x_remove(&client->dev); 54 + 55 + return 0; 54 56 } 55 57 56 58 static const struct i2c_device_id max7300_id[] = {
+3 -1
drivers/gpio/gpio-max7301.c
··· 66 66 67 67 static int max7301_remove(struct spi_device *spi) 68 68 { 69 - return __max730x_remove(&spi->dev); 69 + __max730x_remove(&spi->dev); 70 + 71 + return 0; 70 72 } 71 73 72 74 static const struct spi_device_id max7301_id[] = {
+1 -5
drivers/gpio/gpio-max730x.c
··· 220 220 } 221 221 EXPORT_SYMBOL_GPL(__max730x_probe); 222 222 223 - int __max730x_remove(struct device *dev) 223 + void __max730x_remove(struct device *dev) 224 224 { 225 225 struct max7301 *ts = dev_get_drvdata(dev); 226 - 227 - if (ts == NULL) 228 - return -ENODEV; 229 226 230 227 /* Power down the chip and disable IRQ output */ 231 228 ts->write(dev, 0x04, 0x00); 232 229 gpiochip_remove(&ts->chip); 233 230 mutex_destroy(&ts->lock); 234 - return 0; 235 231 } 236 232 EXPORT_SYMBOL_GPL(__max730x_remove); 237 233
-1
drivers/gpio/gpio-max77620.c
··· 365 365 MODULE_DESCRIPTION("GPIO interface for MAX77620 and MAX20024 PMIC"); 366 366 MODULE_AUTHOR("Laxman Dewangan <ldewangan@nvidia.com>"); 367 367 MODULE_AUTHOR("Chaitanya Bandi <bandik@nvidia.com>"); 368 - MODULE_ALIAS("platform:max77620-gpio"); 369 368 MODULE_LICENSE("GPL v2");
-2
drivers/gpio/gpio-mc33880.c
··· 139 139 struct mc33880 *mc; 140 140 141 141 mc = spi_get_drvdata(spi); 142 - if (!mc) 143 - return -ENODEV; 144 142 145 143 gpiochip_remove(&mc->chip); 146 144 mutex_destroy(&mc->lock);
+140 -2
drivers/gpio/gpio-mlxbf2.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 3 + /* 4 + * Copyright (C) 2020-2021 NVIDIA CORPORATION & AFFILIATES 5 + */ 6 + 3 7 #include <linux/bitfield.h> 4 8 #include <linux/bitops.h> 5 9 #include <linux/device.h> 6 10 #include <linux/gpio/driver.h> 11 + #include <linux/interrupt.h> 7 12 #include <linux/io.h> 8 13 #include <linux/ioport.h> 9 14 #include <linux/kernel.h> ··· 48 43 #define YU_GPIO_MODE0 0x0c 49 44 #define YU_GPIO_DATASET 0x14 50 45 #define YU_GPIO_DATACLEAR 0x18 46 + #define YU_GPIO_CAUSE_RISE_EN 0x44 47 + #define YU_GPIO_CAUSE_FALL_EN 0x48 51 48 #define YU_GPIO_MODE1_CLEAR 0x50 52 49 #define YU_GPIO_MODE0_SET 0x54 53 50 #define YU_GPIO_MODE0_CLEAR 0x58 51 + #define YU_GPIO_CAUSE_OR_CAUSE_EVTEN0 0x80 52 + #define YU_GPIO_CAUSE_OR_EVTEN0 0x94 53 + #define YU_GPIO_CAUSE_OR_CLRCAUSE 0x98 54 54 55 55 struct mlxbf2_gpio_context_save_regs { 56 56 u32 gpio_mode0; ··· 65 55 /* BlueField-2 gpio block context structure. */ 66 56 struct mlxbf2_gpio_context { 67 57 struct gpio_chip gc; 58 + struct irq_chip irq_chip; 68 59 69 60 /* YU GPIO blocks address */ 70 61 void __iomem *gpio_io; ··· 229 218 return ret; 230 219 } 231 220 221 + static void mlxbf2_gpio_irq_enable(struct irq_data *irqd) 222 + { 223 + struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd); 224 + struct mlxbf2_gpio_context *gs = gpiochip_get_data(gc); 225 + int offset = irqd_to_hwirq(irqd); 226 + unsigned long flags; 227 + u32 val; 228 + 229 + spin_lock_irqsave(&gs->gc.bgpio_lock, flags); 230 + val = readl(gs->gpio_io + YU_GPIO_CAUSE_OR_CLRCAUSE); 231 + val |= BIT(offset); 232 + writel(val, gs->gpio_io + YU_GPIO_CAUSE_OR_CLRCAUSE); 233 + 234 + val = readl(gs->gpio_io + YU_GPIO_CAUSE_OR_EVTEN0); 235 + val |= BIT(offset); 236 + writel(val, gs->gpio_io + YU_GPIO_CAUSE_OR_EVTEN0); 237 + spin_unlock_irqrestore(&gs->gc.bgpio_lock, flags); 238 + } 239 + 240 + static void mlxbf2_gpio_irq_disable(struct irq_data *irqd) 241 + { 242 + struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd); 243 + struct mlxbf2_gpio_context *gs = gpiochip_get_data(gc); 244 + int offset = irqd_to_hwirq(irqd); 245 + unsigned long flags; 246 + u32 val; 247 + 248 + spin_lock_irqsave(&gs->gc.bgpio_lock, flags); 249 + val = readl(gs->gpio_io + YU_GPIO_CAUSE_OR_EVTEN0); 250 + val &= ~BIT(offset); 251 + writel(val, gs->gpio_io + YU_GPIO_CAUSE_OR_EVTEN0); 252 + spin_unlock_irqrestore(&gs->gc.bgpio_lock, flags); 253 + } 254 + 255 + static irqreturn_t mlxbf2_gpio_irq_handler(int irq, void *ptr) 256 + { 257 + struct mlxbf2_gpio_context *gs = ptr; 258 + struct gpio_chip *gc = &gs->gc; 259 + unsigned long pending; 260 + u32 level; 261 + 262 + pending = readl(gs->gpio_io + YU_GPIO_CAUSE_OR_CAUSE_EVTEN0); 263 + writel(pending, gs->gpio_io + YU_GPIO_CAUSE_OR_CLRCAUSE); 264 + 265 + for_each_set_bit(level, &pending, gc->ngpio) { 266 + int gpio_irq = irq_find_mapping(gc->irq.domain, level); 267 + generic_handle_irq(gpio_irq); 268 + } 269 + 270 + return IRQ_RETVAL(pending); 271 + } 272 + 273 + static int 274 + mlxbf2_gpio_irq_set_type(struct irq_data *irqd, unsigned int type) 275 + { 276 + struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd); 277 + struct mlxbf2_gpio_context *gs = gpiochip_get_data(gc); 278 + int offset = irqd_to_hwirq(irqd); 279 + unsigned long flags; 280 + bool fall = false; 281 + bool rise = false; 282 + u32 val; 283 + 284 + switch (type & IRQ_TYPE_SENSE_MASK) { 285 + case IRQ_TYPE_EDGE_BOTH: 286 + fall = true; 287 + rise = true; 288 + break; 289 + case IRQ_TYPE_EDGE_RISING: 290 + rise = true; 291 + break; 292 + case IRQ_TYPE_EDGE_FALLING: 293 + fall = true; 294 + break; 295 + default: 296 + return -EINVAL; 297 + } 298 + 299 + spin_lock_irqsave(&gs->gc.bgpio_lock, flags); 300 + if (fall) { 301 + val = readl(gs->gpio_io + YU_GPIO_CAUSE_FALL_EN); 302 + val |= BIT(offset); 303 + writel(val, gs->gpio_io + YU_GPIO_CAUSE_FALL_EN); 304 + } 305 + 306 + if (rise) { 307 + val = readl(gs->gpio_io + YU_GPIO_CAUSE_RISE_EN); 308 + val |= BIT(offset); 309 + writel(val, gs->gpio_io + YU_GPIO_CAUSE_RISE_EN); 310 + } 311 + spin_unlock_irqrestore(&gs->gc.bgpio_lock, flags); 312 + 313 + return 0; 314 + } 315 + 232 316 /* BlueField-2 GPIO driver initialization routine. */ 233 317 static int 234 318 mlxbf2_gpio_probe(struct platform_device *pdev) 235 319 { 236 320 struct mlxbf2_gpio_context *gs; 237 321 struct device *dev = &pdev->dev; 322 + struct gpio_irq_chip *girq; 238 323 struct gpio_chip *gc; 239 324 unsigned int npins; 240 - int ret; 325 + const char *name; 326 + int ret, irq; 327 + 328 + name = dev_name(dev); 241 329 242 330 gs = devm_kzalloc(dev, sizeof(*gs), GFP_KERNEL); 243 331 if (!gs) ··· 375 265 gc->direction_output = mlxbf2_gpio_direction_output; 376 266 gc->ngpio = npins; 377 267 gc->owner = THIS_MODULE; 268 + 269 + irq = platform_get_irq(pdev, 0); 270 + if (irq >= 0) { 271 + gs->irq_chip.name = name; 272 + gs->irq_chip.irq_set_type = mlxbf2_gpio_irq_set_type; 273 + gs->irq_chip.irq_enable = mlxbf2_gpio_irq_enable; 274 + gs->irq_chip.irq_disable = mlxbf2_gpio_irq_disable; 275 + 276 + girq = &gs->gc.irq; 277 + girq->chip = &gs->irq_chip; 278 + girq->handler = handle_simple_irq; 279 + girq->default_type = IRQ_TYPE_NONE; 280 + /* This will let us handle the parent IRQ in the driver */ 281 + girq->num_parents = 0; 282 + girq->parents = NULL; 283 + girq->parent_handler = NULL; 284 + 285 + /* 286 + * Directly request the irq here instead of passing 287 + * a flow-handler because the irq is shared. 288 + */ 289 + ret = devm_request_irq(dev, irq, mlxbf2_gpio_irq_handler, 290 + IRQF_SHARED, name, gs); 291 + if (ret) { 292 + dev_err(dev, "failed to request IRQ"); 293 + return ret; 294 + } 295 + } 378 296 379 297 platform_set_drvdata(pdev, gs); 380 298 ··· 458 320 module_platform_driver(mlxbf2_gpio_driver); 459 321 460 322 MODULE_DESCRIPTION("Mellanox BlueField-2 GPIO Driver"); 461 - MODULE_AUTHOR("Mellanox Technologies"); 323 + MODULE_AUTHOR("Asmaa Mnebhi <asmaa@nvidia.com>"); 462 324 MODULE_LICENSE("GPL v2");
+1 -1
drivers/gpio/gpio-realtek-otto.c
··· 205 205 status = realtek_gpio_read_isr(ctrl, lines_done / 8); 206 206 port_pin_count = min(gc->ngpio - lines_done, 8U); 207 207 for_each_set_bit(offset, &status, port_pin_count) 208 - generic_handle_domain_irq(gc->irq.domain, offset); 208 + generic_handle_domain_irq(gc->irq.domain, offset + lines_done); 209 209 } 210 210 211 211 chained_irq_exit(irq_chip, desc);
+102 -12
drivers/gpio/gpio-tegra186.c
··· 69 69 const char *name; 70 70 unsigned int instance; 71 71 72 + unsigned int num_irqs_per_bank; 73 + 72 74 const struct tegra186_pin_range *pin_ranges; 73 75 unsigned int num_pin_ranges; 74 76 const char *pinmux; ··· 83 81 unsigned int *irq; 84 82 85 83 const struct tegra_gpio_soc *soc; 84 + unsigned int num_irqs_per_bank; 85 + unsigned int num_banks; 86 86 87 87 void __iomem *secure; 88 88 void __iomem *base; ··· 454 450 struct irq_domain *domain = gpio->gpio.irq.domain; 455 451 struct irq_chip *chip = irq_desc_get_chip(desc); 456 452 unsigned int parent = irq_desc_get_irq(desc); 457 - unsigned int i, offset = 0; 453 + unsigned int i, j, offset = 0; 458 454 459 455 chained_irq_enter(chip, desc); 460 456 ··· 467 463 base = gpio->base + port->bank * 0x1000 + port->port * 0x200; 468 464 469 465 /* skip ports that are not associated with this bank */ 470 - if (parent != gpio->irq[port->bank]) 466 + for (j = 0; j < gpio->num_irqs_per_bank; j++) { 467 + if (parent == gpio->irq[port->bank * gpio->num_irqs_per_bank + j]) 468 + break; 469 + } 470 + 471 + if (j == gpio->num_irqs_per_bank) 471 472 goto skip; 472 473 473 474 value = readl(base + TEGRA186_GPIO_INTERRUPT_STATUS(1)); ··· 574 565 575 566 static void tegra186_gpio_init_route_mapping(struct tegra_gpio *gpio) 576 567 { 568 + struct device *dev = gpio->gpio.parent; 577 569 unsigned int i, j; 578 570 u32 value; 579 571 ··· 593 583 */ 594 584 if ((value & TEGRA186_GPIO_CTL_SCR_SEC_REN) == 0 && 595 585 (value & TEGRA186_GPIO_CTL_SCR_SEC_WEN) == 0) { 596 - for (j = 0; j < 8; j++) { 586 + /* 587 + * On Tegra194 and later, each pin can be routed to one or more 588 + * interrupts. 589 + */ 590 + for (j = 0; j < gpio->num_irqs_per_bank; j++) { 591 + dev_dbg(dev, "programming default interrupt routing for port %s\n", 592 + port->name); 593 + 597 594 offset = TEGRA186_GPIO_INT_ROUTE_MAPPING(p, j); 598 595 599 - value = readl(base + offset); 600 - value = BIT(port->pins) - 1; 601 - writel(value, base + offset); 596 + /* 597 + * By default we only want to route GPIO pins to IRQ 0. This works 598 + * only under the assumption that we're running as the host kernel 599 + * and hence all GPIO pins are owned by Linux. 600 + * 601 + * For cases where Linux is the guest OS, the hypervisor will have 602 + * to configure the interrupt routing and pass only the valid 603 + * interrupts via device tree. 604 + */ 605 + if (j == 0) { 606 + value = readl(base + offset); 607 + value = BIT(port->pins) - 1; 608 + writel(value, base + offset); 609 + } 602 610 } 603 611 } 604 612 } 613 + } 614 + 615 + static unsigned int tegra186_gpio_irqs_per_bank(struct tegra_gpio *gpio) 616 + { 617 + struct device *dev = gpio->gpio.parent; 618 + 619 + if (gpio->num_irq > gpio->num_banks) { 620 + if (gpio->num_irq % gpio->num_banks != 0) 621 + goto error; 622 + } 623 + 624 + if (gpio->num_irq < gpio->num_banks) 625 + goto error; 626 + 627 + gpio->num_irqs_per_bank = gpio->num_irq / gpio->num_banks; 628 + 629 + if (gpio->num_irqs_per_bank > gpio->soc->num_irqs_per_bank) 630 + goto error; 631 + 632 + return 0; 633 + 634 + error: 635 + dev_err(dev, "invalid number of interrupts (%u) for %u banks\n", 636 + gpio->num_irq, gpio->num_banks); 637 + return -EINVAL; 605 638 } 606 639 607 640 static int tegra186_gpio_probe(struct platform_device *pdev) ··· 661 608 return -ENOMEM; 662 609 663 610 gpio->soc = device_get_match_data(&pdev->dev); 611 + gpio->gpio.label = gpio->soc->name; 612 + gpio->gpio.parent = &pdev->dev; 664 613 614 + /* count the number of banks in the controller */ 615 + for (i = 0; i < gpio->soc->num_ports; i++) 616 + if (gpio->soc->ports[i].bank > gpio->num_banks) 617 + gpio->num_banks = gpio->soc->ports[i].bank; 618 + 619 + gpio->num_banks++; 620 + 621 + /* get register apertures */ 665 622 gpio->secure = devm_platform_ioremap_resource_byname(pdev, "security"); 666 623 if (IS_ERR(gpio->secure)) { 667 624 gpio->secure = devm_platform_ioremap_resource(pdev, 0); ··· 692 629 693 630 gpio->num_irq = err; 694 631 632 + err = tegra186_gpio_irqs_per_bank(gpio); 633 + if (err < 0) 634 + return err; 635 + 695 636 gpio->irq = devm_kcalloc(&pdev->dev, gpio->num_irq, sizeof(*gpio->irq), 696 637 GFP_KERNEL); 697 638 if (!gpio->irq) ··· 708 641 709 642 gpio->irq[i] = err; 710 643 } 711 - 712 - gpio->gpio.label = gpio->soc->name; 713 - gpio->gpio.parent = &pdev->dev; 714 644 715 645 gpio->gpio.request = gpiochip_generic_request; 716 646 gpio->gpio.free = gpiochip_generic_free; ··· 772 708 irq->parent_handler = tegra186_gpio_irq; 773 709 irq->parent_handler_data = gpio; 774 710 irq->num_parents = gpio->num_irq; 775 - irq->parents = gpio->irq; 711 + 712 + /* 713 + * To simplify things, use a single interrupt per bank for now. Some 714 + * chips support up to 8 interrupts per bank, which can be useful to 715 + * distribute the load and decrease the processing latency for GPIOs 716 + * but it also requires a more complicated interrupt routing than we 717 + * currently program. 718 + */ 719 + if (gpio->num_irqs_per_bank > 1) { 720 + irq->parents = devm_kcalloc(&pdev->dev, gpio->num_banks, 721 + sizeof(*irq->parents), GFP_KERNEL); 722 + if (!irq->parents) 723 + return -ENOMEM; 724 + 725 + for (i = 0; i < gpio->num_banks; i++) 726 + irq->parents[i] = gpio->irq[i * gpio->num_irqs_per_bank]; 727 + 728 + irq->num_parents = gpio->num_banks; 729 + } else { 730 + irq->num_parents = gpio->num_irq; 731 + irq->parents = gpio->irq; 732 + } 733 + 734 + if (gpio->soc->num_irqs_per_bank > 1) 735 + tegra186_gpio_init_route_mapping(gpio); 776 736 777 737 np = of_find_matching_node(NULL, tegra186_pmc_of_match); 778 738 if (np) { ··· 806 718 if (!irq->parent_domain) 807 719 return -EPROBE_DEFER; 808 720 } 809 - 810 - tegra186_gpio_init_route_mapping(gpio); 811 721 812 722 irq->map = devm_kcalloc(&pdev->dev, gpio->gpio.ngpio, 813 723 sizeof(*irq->map), GFP_KERNEL); ··· 863 777 .ports = tegra186_main_ports, 864 778 .name = "tegra186-gpio", 865 779 .instance = 0, 780 + .num_irqs_per_bank = 1, 866 781 }; 867 782 868 783 #define TEGRA186_AON_GPIO_PORT(_name, _bank, _port, _pins) \ ··· 890 803 .ports = tegra186_aon_ports, 891 804 .name = "tegra186-gpio-aon", 892 805 .instance = 1, 806 + .num_irqs_per_bank = 1, 893 807 }; 894 808 895 809 #define TEGRA194_MAIN_GPIO_PORT(_name, _bank, _port, _pins) \ ··· 942 854 .ports = tegra194_main_ports, 943 855 .name = "tegra194-gpio", 944 856 .instance = 0, 857 + .num_irqs_per_bank = 8, 945 858 .num_pin_ranges = ARRAY_SIZE(tegra194_main_pin_ranges), 946 859 .pin_ranges = tegra194_main_pin_ranges, 947 860 .pinmux = "nvidia,tegra194-pinmux", ··· 969 880 .ports = tegra194_aon_ports, 970 881 .name = "tegra194-gpio-aon", 971 882 .instance = 1, 883 + .num_irqs_per_bank = 8, 972 884 }; 973 885 974 886 static const struct of_device_id tegra186_gpio_of_match[] = {
-1
drivers/gpio/gpio-tps65218.c
··· 230 230 MODULE_AUTHOR("Nicolas Saenz Julienne <nicolassaenzj@gmail.com>"); 231 231 MODULE_DESCRIPTION("GPO interface for TPS65218 PMICs"); 232 232 MODULE_LICENSE("GPL v2"); 233 - MODULE_ALIAS("platform:tps65218-gpio");
+10 -8
drivers/gpio/gpio-uniphier.c
··· 179 179 180 180 static void uniphier_gpio_irq_mask(struct irq_data *data) 181 181 { 182 - struct uniphier_gpio_priv *priv = data->chip_data; 183 - u32 mask = BIT(data->hwirq); 182 + struct uniphier_gpio_priv *priv = irq_data_get_irq_chip_data(data); 183 + u32 mask = BIT(irqd_to_hwirq(data)); 184 184 185 185 uniphier_gpio_reg_update(priv, UNIPHIER_GPIO_IRQ_EN, mask, 0); 186 186 ··· 189 189 190 190 static void uniphier_gpio_irq_unmask(struct irq_data *data) 191 191 { 192 - struct uniphier_gpio_priv *priv = data->chip_data; 193 - u32 mask = BIT(data->hwirq); 192 + struct uniphier_gpio_priv *priv = irq_data_get_irq_chip_data(data); 193 + u32 mask = BIT(irqd_to_hwirq(data)); 194 194 195 195 uniphier_gpio_reg_update(priv, UNIPHIER_GPIO_IRQ_EN, mask, mask); 196 196 ··· 199 199 200 200 static int uniphier_gpio_irq_set_type(struct irq_data *data, unsigned int type) 201 201 { 202 - struct uniphier_gpio_priv *priv = data->chip_data; 203 - u32 mask = BIT(data->hwirq); 202 + struct uniphier_gpio_priv *priv = irq_data_get_irq_chip_data(data); 203 + u32 mask = BIT(irqd_to_hwirq(data)); 204 204 u32 val = 0; 205 205 206 206 if (type == IRQ_TYPE_EDGE_BOTH) { ··· 297 297 struct uniphier_gpio_priv *priv = domain->host_data; 298 298 struct gpio_chip *chip = &priv->chip; 299 299 300 - return gpiochip_lock_as_irq(chip, data->hwirq + UNIPHIER_GPIO_IRQ_OFFSET); 300 + return gpiochip_lock_as_irq(chip, 301 + irqd_to_hwirq(data) + UNIPHIER_GPIO_IRQ_OFFSET); 301 302 } 302 303 303 304 static void uniphier_gpio_irq_domain_deactivate(struct irq_domain *domain, ··· 307 306 struct uniphier_gpio_priv *priv = domain->host_data; 308 307 struct gpio_chip *chip = &priv->chip; 309 308 310 - gpiochip_unlock_as_irq(chip, data->hwirq + UNIPHIER_GPIO_IRQ_OFFSET); 309 + gpiochip_unlock_as_irq(chip, 310 + irqd_to_hwirq(data) + UNIPHIER_GPIO_IRQ_OFFSET); 311 311 } 312 312 313 313 static const struct irq_domain_ops uniphier_gpio_irq_domain_ops = {
+298 -4
drivers/gpio/gpio-virtio.c
··· 16 16 #include <linux/kernel.h> 17 17 #include <linux/module.h> 18 18 #include <linux/mutex.h> 19 + #include <linux/spinlock.h> 19 20 #include <linux/virtio_config.h> 20 21 #include <uapi/linux/virtio_gpio.h> 21 22 #include <uapi/linux/virtio_ids.h> ··· 29 28 unsigned int rxlen; 30 29 }; 31 30 31 + struct vgpio_irq_line { 32 + u8 type; 33 + bool disabled; 34 + bool masked; 35 + bool queued; 36 + bool update_pending; 37 + bool queue_pending; 38 + 39 + struct virtio_gpio_irq_request ireq ____cacheline_aligned; 40 + struct virtio_gpio_irq_response ires ____cacheline_aligned; 41 + }; 42 + 32 43 struct virtio_gpio { 33 44 struct virtio_device *vdev; 34 45 struct mutex lock; /* Protects virtqueue operation */ 35 46 struct gpio_chip gc; 36 47 struct virtio_gpio_line *lines; 37 48 struct virtqueue *request_vq; 49 + 50 + /* irq support */ 51 + struct virtqueue *event_vq; 52 + struct mutex irq_lock; /* Protects irq operation */ 53 + raw_spinlock_t eventq_lock; /* Protects queuing of the buffer */ 54 + struct vgpio_irq_line *irq_lines; 38 55 }; 39 56 40 57 static int _virtio_gpio_req(struct virtio_gpio *vgpio, u16 type, u16 gpio, ··· 205 186 virtio_gpio_req(vgpio, VIRTIO_GPIO_MSG_SET_VALUE, gpio, value, NULL); 206 187 } 207 188 189 + /* Interrupt handling */ 190 + static void virtio_gpio_irq_prepare(struct virtio_gpio *vgpio, u16 gpio) 191 + { 192 + struct vgpio_irq_line *irq_line = &vgpio->irq_lines[gpio]; 193 + struct virtio_gpio_irq_request *ireq = &irq_line->ireq; 194 + struct virtio_gpio_irq_response *ires = &irq_line->ires; 195 + struct scatterlist *sgs[2], req_sg, res_sg; 196 + int ret; 197 + 198 + if (WARN_ON(irq_line->queued || irq_line->masked || irq_line->disabled)) 199 + return; 200 + 201 + ireq->gpio = cpu_to_le16(gpio); 202 + sg_init_one(&req_sg, ireq, sizeof(*ireq)); 203 + sg_init_one(&res_sg, ires, sizeof(*ires)); 204 + sgs[0] = &req_sg; 205 + sgs[1] = &res_sg; 206 + 207 + ret = virtqueue_add_sgs(vgpio->event_vq, sgs, 1, 1, irq_line, GFP_ATOMIC); 208 + if (ret) { 209 + dev_err(&vgpio->vdev->dev, "failed to add request to eventq\n"); 210 + return; 211 + } 212 + 213 + irq_line->queued = true; 214 + virtqueue_kick(vgpio->event_vq); 215 + } 216 + 217 + static void virtio_gpio_irq_enable(struct irq_data *d) 218 + { 219 + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 220 + struct virtio_gpio *vgpio = gpiochip_get_data(gc); 221 + struct vgpio_irq_line *irq_line = &vgpio->irq_lines[d->hwirq]; 222 + 223 + raw_spin_lock(&vgpio->eventq_lock); 224 + irq_line->disabled = false; 225 + irq_line->masked = false; 226 + irq_line->queue_pending = true; 227 + raw_spin_unlock(&vgpio->eventq_lock); 228 + 229 + irq_line->update_pending = true; 230 + } 231 + 232 + static void virtio_gpio_irq_disable(struct irq_data *d) 233 + { 234 + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 235 + struct virtio_gpio *vgpio = gpiochip_get_data(gc); 236 + struct vgpio_irq_line *irq_line = &vgpio->irq_lines[d->hwirq]; 237 + 238 + raw_spin_lock(&vgpio->eventq_lock); 239 + irq_line->disabled = true; 240 + irq_line->masked = true; 241 + irq_line->queue_pending = false; 242 + raw_spin_unlock(&vgpio->eventq_lock); 243 + 244 + irq_line->update_pending = true; 245 + } 246 + 247 + static void virtio_gpio_irq_mask(struct irq_data *d) 248 + { 249 + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 250 + struct virtio_gpio *vgpio = gpiochip_get_data(gc); 251 + struct vgpio_irq_line *irq_line = &vgpio->irq_lines[d->hwirq]; 252 + 253 + raw_spin_lock(&vgpio->eventq_lock); 254 + irq_line->masked = true; 255 + raw_spin_unlock(&vgpio->eventq_lock); 256 + } 257 + 258 + static void virtio_gpio_irq_unmask(struct irq_data *d) 259 + { 260 + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 261 + struct virtio_gpio *vgpio = gpiochip_get_data(gc); 262 + struct vgpio_irq_line *irq_line = &vgpio->irq_lines[d->hwirq]; 263 + 264 + raw_spin_lock(&vgpio->eventq_lock); 265 + irq_line->masked = false; 266 + 267 + /* Queue the buffer unconditionally on unmask */ 268 + virtio_gpio_irq_prepare(vgpio, d->hwirq); 269 + raw_spin_unlock(&vgpio->eventq_lock); 270 + } 271 + 272 + static int virtio_gpio_irq_set_type(struct irq_data *d, unsigned int type) 273 + { 274 + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 275 + struct virtio_gpio *vgpio = gpiochip_get_data(gc); 276 + struct vgpio_irq_line *irq_line = &vgpio->irq_lines[d->hwirq]; 277 + 278 + switch (type) { 279 + case IRQ_TYPE_EDGE_RISING: 280 + type = VIRTIO_GPIO_IRQ_TYPE_EDGE_RISING; 281 + break; 282 + case IRQ_TYPE_EDGE_FALLING: 283 + type = VIRTIO_GPIO_IRQ_TYPE_EDGE_FALLING; 284 + break; 285 + case IRQ_TYPE_EDGE_BOTH: 286 + type = VIRTIO_GPIO_IRQ_TYPE_EDGE_BOTH; 287 + break; 288 + case IRQ_TYPE_LEVEL_LOW: 289 + type = VIRTIO_GPIO_IRQ_TYPE_LEVEL_LOW; 290 + break; 291 + case IRQ_TYPE_LEVEL_HIGH: 292 + type = VIRTIO_GPIO_IRQ_TYPE_LEVEL_HIGH; 293 + break; 294 + default: 295 + dev_err(&vgpio->vdev->dev, "unsupported irq type: %u\n", type); 296 + return -EINVAL; 297 + } 298 + 299 + irq_line->type = type; 300 + irq_line->update_pending = true; 301 + 302 + return 0; 303 + } 304 + 305 + static void virtio_gpio_irq_bus_lock(struct irq_data *d) 306 + { 307 + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 308 + struct virtio_gpio *vgpio = gpiochip_get_data(gc); 309 + 310 + mutex_lock(&vgpio->irq_lock); 311 + } 312 + 313 + static void virtio_gpio_irq_bus_sync_unlock(struct irq_data *d) 314 + { 315 + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 316 + struct virtio_gpio *vgpio = gpiochip_get_data(gc); 317 + struct vgpio_irq_line *irq_line = &vgpio->irq_lines[d->hwirq]; 318 + u8 type = irq_line->disabled ? VIRTIO_GPIO_IRQ_TYPE_NONE : irq_line->type; 319 + unsigned long flags; 320 + 321 + if (irq_line->update_pending) { 322 + irq_line->update_pending = false; 323 + virtio_gpio_req(vgpio, VIRTIO_GPIO_MSG_IRQ_TYPE, d->hwirq, type, 324 + NULL); 325 + 326 + /* Queue the buffer only after interrupt is enabled */ 327 + raw_spin_lock_irqsave(&vgpio->eventq_lock, flags); 328 + if (irq_line->queue_pending) { 329 + irq_line->queue_pending = false; 330 + virtio_gpio_irq_prepare(vgpio, d->hwirq); 331 + } 332 + raw_spin_unlock_irqrestore(&vgpio->eventq_lock, flags); 333 + } 334 + 335 + mutex_unlock(&vgpio->irq_lock); 336 + } 337 + 338 + static struct irq_chip vgpio_irq_chip = { 339 + .name = "virtio-gpio", 340 + .irq_enable = virtio_gpio_irq_enable, 341 + .irq_disable = virtio_gpio_irq_disable, 342 + .irq_mask = virtio_gpio_irq_mask, 343 + .irq_unmask = virtio_gpio_irq_unmask, 344 + .irq_set_type = virtio_gpio_irq_set_type, 345 + 346 + /* These are required to implement irqchip for slow busses */ 347 + .irq_bus_lock = virtio_gpio_irq_bus_lock, 348 + .irq_bus_sync_unlock = virtio_gpio_irq_bus_sync_unlock, 349 + }; 350 + 351 + static bool ignore_irq(struct virtio_gpio *vgpio, int gpio, 352 + struct vgpio_irq_line *irq_line) 353 + { 354 + bool ignore = false; 355 + 356 + raw_spin_lock(&vgpio->eventq_lock); 357 + irq_line->queued = false; 358 + 359 + /* Interrupt is disabled currently */ 360 + if (irq_line->masked || irq_line->disabled) { 361 + ignore = true; 362 + goto unlock; 363 + } 364 + 365 + /* 366 + * Buffer is returned as the interrupt was disabled earlier, but is 367 + * enabled again now. Requeue the buffers. 368 + */ 369 + if (irq_line->ires.status == VIRTIO_GPIO_IRQ_STATUS_INVALID) { 370 + virtio_gpio_irq_prepare(vgpio, gpio); 371 + ignore = true; 372 + goto unlock; 373 + } 374 + 375 + if (WARN_ON(irq_line->ires.status != VIRTIO_GPIO_IRQ_STATUS_VALID)) 376 + ignore = true; 377 + 378 + unlock: 379 + raw_spin_unlock(&vgpio->eventq_lock); 380 + 381 + return ignore; 382 + } 383 + 384 + static void virtio_gpio_event_vq(struct virtqueue *vq) 385 + { 386 + struct virtio_gpio *vgpio = vq->vdev->priv; 387 + struct device *dev = &vgpio->vdev->dev; 388 + struct vgpio_irq_line *irq_line; 389 + int gpio, ret; 390 + unsigned int len; 391 + 392 + while (true) { 393 + irq_line = virtqueue_get_buf(vgpio->event_vq, &len); 394 + if (!irq_line) 395 + break; 396 + 397 + if (len != sizeof(irq_line->ires)) { 398 + dev_err(dev, "irq with incorrect length (%u : %u)\n", 399 + len, (unsigned int)sizeof(irq_line->ires)); 400 + continue; 401 + } 402 + 403 + /* 404 + * Find GPIO line number from the offset of irq_line within the 405 + * irq_lines block. We can also get GPIO number from 406 + * irq-request, but better not to rely on a buffer returned by 407 + * remote. 408 + */ 409 + gpio = irq_line - vgpio->irq_lines; 410 + WARN_ON(gpio >= vgpio->gc.ngpio); 411 + 412 + if (unlikely(ignore_irq(vgpio, gpio, irq_line))) 413 + continue; 414 + 415 + ret = generic_handle_domain_irq(vgpio->gc.irq.domain, gpio); 416 + if (ret) 417 + dev_err(dev, "failed to handle interrupt: %d\n", ret); 418 + }; 419 + } 420 + 208 421 static void virtio_gpio_request_vq(struct virtqueue *vq) 209 422 { 210 423 struct virtio_gpio_line *line; ··· 461 210 static int virtio_gpio_alloc_vqs(struct virtio_gpio *vgpio, 462 211 struct virtio_device *vdev) 463 212 { 464 - const char * const names[] = { "requestq" }; 213 + const char * const names[] = { "requestq", "eventq" }; 465 214 vq_callback_t *cbs[] = { 466 215 virtio_gpio_request_vq, 216 + virtio_gpio_event_vq, 467 217 }; 468 - struct virtqueue *vqs[1] = { NULL }; 218 + struct virtqueue *vqs[2] = { NULL, NULL }; 469 219 int ret; 470 220 471 - ret = virtio_find_vqs(vdev, 1, vqs, cbs, names, NULL); 221 + ret = virtio_find_vqs(vdev, vgpio->irq_lines ? 2 : 1, vqs, cbs, names, NULL); 472 222 if (ret) { 473 223 dev_err(&vdev->dev, "failed to find vqs: %d\n", ret); 474 224 return ret; ··· 477 225 478 226 if (!vqs[0]) { 479 227 dev_err(&vdev->dev, "failed to find requestq vq\n"); 480 - return -ENODEV; 228 + goto out; 481 229 } 482 230 vgpio->request_vq = vqs[0]; 483 231 232 + if (vgpio->irq_lines && !vqs[1]) { 233 + dev_err(&vdev->dev, "failed to find eventq vq\n"); 234 + goto out; 235 + } 236 + vgpio->event_vq = vqs[1]; 237 + 484 238 return 0; 239 + 240 + out: 241 + if (vqs[0] || vqs[1]) 242 + virtio_gpio_free_vqs(vdev); 243 + 244 + return -ENODEV; 485 245 } 486 246 487 247 static const char **virtio_gpio_get_names(struct virtio_gpio *vgpio, ··· 589 325 vgpio->gc.owner = THIS_MODULE; 590 326 vgpio->gc.can_sleep = true; 591 327 328 + /* Interrupt support */ 329 + if (virtio_has_feature(vdev, VIRTIO_GPIO_F_IRQ)) { 330 + vgpio->irq_lines = devm_kcalloc(dev, ngpio, sizeof(*vgpio->irq_lines), GFP_KERNEL); 331 + if (!vgpio->irq_lines) 332 + return -ENOMEM; 333 + 334 + /* The event comes from the outside so no parent handler */ 335 + vgpio->gc.irq.parent_handler = NULL; 336 + vgpio->gc.irq.num_parents = 0; 337 + vgpio->gc.irq.parents = NULL; 338 + vgpio->gc.irq.default_type = IRQ_TYPE_NONE; 339 + vgpio->gc.irq.handler = handle_level_irq; 340 + vgpio->gc.irq.chip = &vgpio_irq_chip; 341 + 342 + for (i = 0; i < ngpio; i++) { 343 + vgpio->irq_lines[i].type = VIRTIO_GPIO_IRQ_TYPE_NONE; 344 + vgpio->irq_lines[i].disabled = true; 345 + vgpio->irq_lines[i].masked = true; 346 + } 347 + 348 + mutex_init(&vgpio->irq_lock); 349 + raw_spin_lock_init(&vgpio->eventq_lock); 350 + } 351 + 592 352 ret = virtio_gpio_alloc_vqs(vgpio, vdev); 593 353 if (ret) 594 354 return ret; ··· 645 357 }; 646 358 MODULE_DEVICE_TABLE(virtio, id_table); 647 359 360 + static const unsigned int features[] = { 361 + VIRTIO_GPIO_F_IRQ, 362 + }; 363 + 648 364 static struct virtio_driver virtio_gpio_driver = { 365 + .feature_table = features, 366 + .feature_table_size = ARRAY_SIZE(features), 649 367 .id_table = id_table, 650 368 .probe = virtio_gpio_probe, 651 369 .remove = virtio_gpio_remove,
+2 -4
drivers/gpio/gpio-xilinx.c
··· 371 371 372 372 static int __maybe_unused xgpio_runtime_suspend(struct device *dev) 373 373 { 374 - struct platform_device *pdev = to_platform_device(dev); 375 - struct xgpio_instance *gpio = platform_get_drvdata(pdev); 374 + struct xgpio_instance *gpio = dev_get_drvdata(dev); 376 375 377 376 clk_disable(gpio->clk); 378 377 ··· 380 381 381 382 static int __maybe_unused xgpio_runtime_resume(struct device *dev) 382 383 { 383 - struct platform_device *pdev = to_platform_device(dev); 384 - struct xgpio_instance *gpio = platform_get_drvdata(pdev); 384 + struct xgpio_instance *gpio = dev_get_drvdata(dev); 385 385 386 386 return clk_enable(gpio->clk); 387 387 }
+162
drivers/gpio/gpio-zynqmp-modepin.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Driver for the ps-mode pin configuration. 4 + * 5 + * Copyright (c) 2021 Xilinx, Inc. 6 + */ 7 + 8 + #include <linux/delay.h> 9 + #include <linux/err.h> 10 + #include <linux/gpio/driver.h> 11 + #include <linux/io.h> 12 + #include <linux/kernel.h> 13 + #include <linux/module.h> 14 + #include <linux/platform_device.h> 15 + #include <linux/slab.h> 16 + #include <linux/firmware/xlnx-zynqmp.h> 17 + 18 + /* 4-bit boot mode pins */ 19 + #define MODE_PINS 4 20 + 21 + /** 22 + * modepin_gpio_get_value - Get the state of the specified pin of GPIO device 23 + * @chip: gpio_chip instance to be worked on 24 + * @pin: gpio pin number within the device 25 + * 26 + * This function reads the state of the specified pin of the GPIO device. 27 + * 28 + * Return: 0 if the pin is low, 1 if pin is high, -EINVAL wrong pin configured 29 + * or error value. 30 + */ 31 + static int modepin_gpio_get_value(struct gpio_chip *chip, unsigned int pin) 32 + { 33 + u32 regval = 0; 34 + int ret; 35 + 36 + ret = zynqmp_pm_bootmode_read(&regval); 37 + if (ret) 38 + return ret; 39 + 40 + /* When [0:3] corresponding bit is set, then read output bit [8:11], 41 + * if the bit is clear then read input bit [4:7] for status or value. 42 + */ 43 + if (regval & BIT(pin)) 44 + return !!(regval & BIT(pin + 8)); 45 + else 46 + return !!(regval & BIT(pin + 4)); 47 + } 48 + 49 + /** 50 + * modepin_gpio_set_value - Modify the state of the pin with specified value 51 + * @chip: gpio_chip instance to be worked on 52 + * @pin: gpio pin number within the device 53 + * @state: value used to modify the state of the specified pin 54 + * 55 + * This function reads the state of the specified pin of the GPIO device, mask 56 + * with the capture state of GPIO pin, and update pin of GPIO device. 57 + * 58 + * Return: None. 59 + */ 60 + static void modepin_gpio_set_value(struct gpio_chip *chip, unsigned int pin, 61 + int state) 62 + { 63 + u32 bootpin_val = 0; 64 + int ret; 65 + 66 + zynqmp_pm_bootmode_read(&bootpin_val); 67 + 68 + /* Configure pin as an output by set bit [0:3] */ 69 + bootpin_val |= BIT(pin); 70 + 71 + if (state) 72 + bootpin_val |= BIT(pin + 8); 73 + else 74 + bootpin_val &= ~BIT(pin + 8); 75 + 76 + /* Configure bootpin value */ 77 + ret = zynqmp_pm_bootmode_write(bootpin_val); 78 + if (ret) 79 + pr_err("modepin: set value error %d for pin %d\n", ret, pin); 80 + } 81 + 82 + /** 83 + * modepin_gpio_dir_in - Set the direction of the specified GPIO pin as input 84 + * @chip: gpio_chip instance to be worked on 85 + * @pin: gpio pin number within the device 86 + * 87 + * Return: 0 always 88 + */ 89 + static int modepin_gpio_dir_in(struct gpio_chip *chip, unsigned int pin) 90 + { 91 + return 0; 92 + } 93 + 94 + /** 95 + * modepin_gpio_dir_out - Set the direction of the specified GPIO pin as output 96 + * @chip: gpio_chip instance to be worked on 97 + * @pin: gpio pin number within the device 98 + * @state: value to be written to specified pin 99 + * 100 + * Return: 0 always 101 + */ 102 + static int modepin_gpio_dir_out(struct gpio_chip *chip, unsigned int pin, 103 + int state) 104 + { 105 + return 0; 106 + } 107 + 108 + /** 109 + * modepin_gpio_probe - Initialization method for modepin_gpio 110 + * @pdev: platform device instance 111 + * 112 + * Return: 0 on success, negative error otherwise. 113 + */ 114 + static int modepin_gpio_probe(struct platform_device *pdev) 115 + { 116 + struct gpio_chip *chip; 117 + int status; 118 + 119 + chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL); 120 + if (!chip) 121 + return -ENOMEM; 122 + 123 + platform_set_drvdata(pdev, chip); 124 + 125 + /* configure the gpio chip */ 126 + chip->base = -1; 127 + chip->ngpio = MODE_PINS; 128 + chip->owner = THIS_MODULE; 129 + chip->parent = &pdev->dev; 130 + chip->get = modepin_gpio_get_value; 131 + chip->set = modepin_gpio_set_value; 132 + chip->direction_input = modepin_gpio_dir_in; 133 + chip->direction_output = modepin_gpio_dir_out; 134 + chip->label = dev_name(&pdev->dev); 135 + 136 + /* modepin gpio registration */ 137 + status = devm_gpiochip_add_data(&pdev->dev, chip, chip); 138 + if (status) 139 + return dev_err_probe(&pdev->dev, status, 140 + "Failed to add GPIO chip\n"); 141 + 142 + return status; 143 + } 144 + 145 + static const struct of_device_id modepin_platform_id[] = { 146 + { .compatible = "xlnx,zynqmp-gpio-modepin", }, 147 + { } 148 + }; 149 + 150 + static struct platform_driver modepin_platform_driver = { 151 + .driver = { 152 + .name = "modepin-gpio", 153 + .of_match_table = modepin_platform_id, 154 + }, 155 + .probe = modepin_gpio_probe, 156 + }; 157 + 158 + module_platform_driver(modepin_platform_driver); 159 + 160 + MODULE_AUTHOR("Piyush Mehta <piyush.mehta@xilinx.com>"); 161 + MODULE_DESCRIPTION("ZynqMP Boot PS_MODE Configuration"); 162 + MODULE_LICENSE("GPL v2");
-1
drivers/net/ethernet/mellanox/mlxbf_gige/Makefile
··· 3 3 obj-$(CONFIG_MLXBF_GIGE) += mlxbf_gige.o 4 4 5 5 mlxbf_gige-y := mlxbf_gige_ethtool.o \ 6 - mlxbf_gige_gpio.o \ 7 6 mlxbf_gige_intr.o \ 8 7 mlxbf_gige_main.o \ 9 8 mlxbf_gige_mdio.o \
-12
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige.h
··· 51 51 #define MLXBF_GIGE_ERROR_INTR_IDX 0 52 52 #define MLXBF_GIGE_RECEIVE_PKT_INTR_IDX 1 53 53 #define MLXBF_GIGE_LLU_PLU_INTR_IDX 2 54 - #define MLXBF_GIGE_PHY_INT_N 3 55 - 56 - #define MLXBF_GIGE_MDIO_DEFAULT_PHY_ADDR 0x3 57 - 58 - #define MLXBF_GIGE_DEFAULT_PHY_INT_GPIO 12 59 54 60 55 struct mlxbf_gige_stats { 61 56 u64 hw_access_errors; ··· 76 81 struct platform_device *pdev; 77 82 void __iomem *mdio_io; 78 83 struct mii_bus *mdiobus; 79 - void __iomem *gpio_io; 80 - struct irq_domain *irqdomain; 81 - u32 phy_int_gpio_mask; 82 84 spinlock_t lock; /* for packet processing indices */ 83 - spinlock_t gpio_lock; /* for GPIO bus access */ 84 85 u16 rx_q_entries; 85 86 u16 tx_q_entries; 86 87 u64 *tx_wqe_base; ··· 174 183 int mlxbf_gige_poll(struct napi_struct *napi, int budget); 175 184 extern const struct ethtool_ops mlxbf_gige_ethtool_ops; 176 185 void mlxbf_gige_update_tx_wqe_next(struct mlxbf_gige *priv); 177 - 178 - int mlxbf_gige_gpio_init(struct platform_device *pdev, struct mlxbf_gige *priv); 179 - void mlxbf_gige_gpio_free(struct mlxbf_gige *priv); 180 186 181 187 #endif /* !defined(__MLXBF_GIGE_H__) */
-212
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_gpio.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-only OR BSD-3-Clause 2 - 3 - /* Initialize and handle GPIO interrupt triggered by INT_N PHY signal. 4 - * This GPIO interrupt triggers the PHY state machine to bring the link 5 - * up/down. 6 - * 7 - * Copyright (C) 2021 NVIDIA CORPORATION & AFFILIATES 8 - */ 9 - 10 - #include <linux/acpi.h> 11 - #include <linux/bitfield.h> 12 - #include <linux/device.h> 13 - #include <linux/err.h> 14 - #include <linux/gpio/driver.h> 15 - #include <linux/interrupt.h> 16 - #include <linux/io.h> 17 - #include <linux/irq.h> 18 - #include <linux/irqdomain.h> 19 - #include <linux/irqreturn.h> 20 - #include <linux/platform_device.h> 21 - #include <linux/property.h> 22 - 23 - #include "mlxbf_gige.h" 24 - #include "mlxbf_gige_regs.h" 25 - 26 - #define MLXBF_GIGE_GPIO_CAUSE_FALL_EN 0x48 27 - #define MLXBF_GIGE_GPIO_CAUSE_OR_CAUSE_EVTEN0 0x80 28 - #define MLXBF_GIGE_GPIO_CAUSE_OR_EVTEN0 0x94 29 - #define MLXBF_GIGE_GPIO_CAUSE_OR_CLRCAUSE 0x98 30 - 31 - static void mlxbf_gige_gpio_enable(struct mlxbf_gige *priv) 32 - { 33 - unsigned long flags; 34 - u32 val; 35 - 36 - spin_lock_irqsave(&priv->gpio_lock, flags); 37 - val = readl(priv->gpio_io + MLXBF_GIGE_GPIO_CAUSE_OR_CLRCAUSE); 38 - val |= priv->phy_int_gpio_mask; 39 - writel(val, priv->gpio_io + MLXBF_GIGE_GPIO_CAUSE_OR_CLRCAUSE); 40 - 41 - /* The INT_N interrupt level is active low. 42 - * So enable cause fall bit to detect when GPIO 43 - * state goes low. 44 - */ 45 - val = readl(priv->gpio_io + MLXBF_GIGE_GPIO_CAUSE_FALL_EN); 46 - val |= priv->phy_int_gpio_mask; 47 - writel(val, priv->gpio_io + MLXBF_GIGE_GPIO_CAUSE_FALL_EN); 48 - 49 - /* Enable PHY interrupt by setting the priority level */ 50 - val = readl(priv->gpio_io + MLXBF_GIGE_GPIO_CAUSE_OR_EVTEN0); 51 - val |= priv->phy_int_gpio_mask; 52 - writel(val, priv->gpio_io + MLXBF_GIGE_GPIO_CAUSE_OR_EVTEN0); 53 - spin_unlock_irqrestore(&priv->gpio_lock, flags); 54 - } 55 - 56 - static void mlxbf_gige_gpio_disable(struct mlxbf_gige *priv) 57 - { 58 - unsigned long flags; 59 - u32 val; 60 - 61 - spin_lock_irqsave(&priv->gpio_lock, flags); 62 - val = readl(priv->gpio_io + MLXBF_GIGE_GPIO_CAUSE_OR_EVTEN0); 63 - val &= ~priv->phy_int_gpio_mask; 64 - writel(val, priv->gpio_io + MLXBF_GIGE_GPIO_CAUSE_OR_EVTEN0); 65 - spin_unlock_irqrestore(&priv->gpio_lock, flags); 66 - } 67 - 68 - static irqreturn_t mlxbf_gige_gpio_handler(int irq, void *ptr) 69 - { 70 - struct mlxbf_gige *priv; 71 - u32 val; 72 - 73 - priv = ptr; 74 - 75 - /* Check if this interrupt is from PHY device. 76 - * Return if it is not. 77 - */ 78 - val = readl(priv->gpio_io + MLXBF_GIGE_GPIO_CAUSE_OR_CAUSE_EVTEN0); 79 - if (!(val & priv->phy_int_gpio_mask)) 80 - return IRQ_NONE; 81 - 82 - /* Clear interrupt when done, otherwise, no further interrupt 83 - * will be triggered. 84 - */ 85 - val = readl(priv->gpio_io + MLXBF_GIGE_GPIO_CAUSE_OR_CLRCAUSE); 86 - val |= priv->phy_int_gpio_mask; 87 - writel(val, priv->gpio_io + MLXBF_GIGE_GPIO_CAUSE_OR_CLRCAUSE); 88 - 89 - generic_handle_irq(priv->phy_irq); 90 - 91 - return IRQ_HANDLED; 92 - } 93 - 94 - static void mlxbf_gige_gpio_mask(struct irq_data *irqd) 95 - { 96 - struct mlxbf_gige *priv = irq_data_get_irq_chip_data(irqd); 97 - 98 - mlxbf_gige_gpio_disable(priv); 99 - } 100 - 101 - static void mlxbf_gige_gpio_unmask(struct irq_data *irqd) 102 - { 103 - struct mlxbf_gige *priv = irq_data_get_irq_chip_data(irqd); 104 - 105 - mlxbf_gige_gpio_enable(priv); 106 - } 107 - 108 - static struct irq_chip mlxbf_gige_gpio_chip = { 109 - .name = "mlxbf_gige_phy", 110 - .irq_mask = mlxbf_gige_gpio_mask, 111 - .irq_unmask = mlxbf_gige_gpio_unmask, 112 - }; 113 - 114 - static int mlxbf_gige_gpio_domain_map(struct irq_domain *d, 115 - unsigned int irq, 116 - irq_hw_number_t hwirq) 117 - { 118 - irq_set_chip_data(irq, d->host_data); 119 - irq_set_chip_and_handler(irq, &mlxbf_gige_gpio_chip, handle_simple_irq); 120 - irq_set_noprobe(irq); 121 - 122 - return 0; 123 - } 124 - 125 - static const struct irq_domain_ops mlxbf_gige_gpio_domain_ops = { 126 - .map = mlxbf_gige_gpio_domain_map, 127 - .xlate = irq_domain_xlate_twocell, 128 - }; 129 - 130 - #ifdef CONFIG_ACPI 131 - static int mlxbf_gige_gpio_resources(struct acpi_resource *ares, 132 - void *data) 133 - { 134 - struct acpi_resource_gpio *gpio; 135 - u32 *phy_int_gpio = data; 136 - 137 - if (ares->type == ACPI_RESOURCE_TYPE_GPIO) { 138 - gpio = &ares->data.gpio; 139 - *phy_int_gpio = gpio->pin_table[0]; 140 - } 141 - 142 - return 1; 143 - } 144 - #endif 145 - 146 - void mlxbf_gige_gpio_free(struct mlxbf_gige *priv) 147 - { 148 - irq_dispose_mapping(priv->phy_irq); 149 - irq_domain_remove(priv->irqdomain); 150 - } 151 - 152 - int mlxbf_gige_gpio_init(struct platform_device *pdev, 153 - struct mlxbf_gige *priv) 154 - { 155 - struct device *dev = &pdev->dev; 156 - struct resource *res; 157 - u32 phy_int_gpio = 0; 158 - int ret; 159 - 160 - LIST_HEAD(resources); 161 - 162 - res = platform_get_resource(pdev, IORESOURCE_MEM, MLXBF_GIGE_RES_GPIO0); 163 - if (!res) 164 - return -ENODEV; 165 - 166 - priv->gpio_io = devm_ioremap(dev, res->start, resource_size(res)); 167 - if (!priv->gpio_io) 168 - return -ENOMEM; 169 - 170 - #ifdef CONFIG_ACPI 171 - ret = acpi_dev_get_resources(ACPI_COMPANION(dev), 172 - &resources, mlxbf_gige_gpio_resources, 173 - &phy_int_gpio); 174 - acpi_dev_free_resource_list(&resources); 175 - if (ret < 0 || !phy_int_gpio) { 176 - dev_err(dev, "Error retrieving the gpio phy pin"); 177 - return -EINVAL; 178 - } 179 - #endif 180 - 181 - priv->phy_int_gpio_mask = BIT(phy_int_gpio); 182 - 183 - mlxbf_gige_gpio_disable(priv); 184 - 185 - priv->hw_phy_irq = platform_get_irq(pdev, MLXBF_GIGE_PHY_INT_N); 186 - 187 - priv->irqdomain = irq_domain_add_simple(NULL, 1, 0, 188 - &mlxbf_gige_gpio_domain_ops, 189 - priv); 190 - if (!priv->irqdomain) { 191 - dev_err(dev, "Failed to add IRQ domain\n"); 192 - return -ENOMEM; 193 - } 194 - 195 - priv->phy_irq = irq_create_mapping(priv->irqdomain, 0); 196 - if (!priv->phy_irq) { 197 - irq_domain_remove(priv->irqdomain); 198 - priv->irqdomain = NULL; 199 - dev_err(dev, "Error mapping PHY IRQ\n"); 200 - return -EINVAL; 201 - } 202 - 203 - ret = devm_request_irq(dev, priv->hw_phy_irq, mlxbf_gige_gpio_handler, 204 - IRQF_ONESHOT | IRQF_SHARED, "mlxbf_gige_phy", priv); 205 - if (ret) { 206 - dev_err(dev, "Failed to request PHY IRQ"); 207 - mlxbf_gige_gpio_free(priv); 208 - return ret; 209 - } 210 - 211 - return ret; 212 - }
+9 -13
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c
··· 280 280 void __iomem *llu_base; 281 281 void __iomem *plu_base; 282 282 void __iomem *base; 283 + int addr, phy_irq; 283 284 u64 control; 284 - int addr; 285 285 int err; 286 286 287 287 base = devm_platform_ioremap_resource(pdev, MLXBF_GIGE_RES_MAC); ··· 316 316 priv->pdev = pdev; 317 317 318 318 spin_lock_init(&priv->lock); 319 - spin_lock_init(&priv->gpio_lock); 320 319 321 320 /* Attach MDIO device */ 322 321 err = mlxbf_gige_mdio_probe(pdev, priv); 323 322 if (err) 324 323 return err; 325 - 326 - err = mlxbf_gige_gpio_init(pdev, priv); 327 - if (err) { 328 - dev_err(&pdev->dev, "PHY IRQ initialization failed\n"); 329 - mlxbf_gige_mdio_remove(priv); 330 - return -ENODEV; 331 - } 332 324 333 325 priv->base = base; 334 326 priv->llu_base = llu_base; ··· 342 350 priv->rx_irq = platform_get_irq(pdev, MLXBF_GIGE_RECEIVE_PKT_INTR_IDX); 343 351 priv->llu_plu_irq = platform_get_irq(pdev, MLXBF_GIGE_LLU_PLU_INTR_IDX); 344 352 353 + phy_irq = acpi_dev_gpio_irq_get_by(ACPI_COMPANION(&pdev->dev), "phy-gpios", 0); 354 + if (phy_irq < 0) { 355 + dev_err(&pdev->dev, "Error getting PHY irq. Use polling instead"); 356 + phy_irq = PHY_POLL; 357 + } 358 + 345 359 phydev = phy_find_first(priv->mdiobus); 346 360 if (!phydev) { 347 361 err = -ENODEV; ··· 355 357 } 356 358 357 359 addr = phydev->mdio.addr; 358 - priv->mdiobus->irq[addr] = priv->phy_irq; 359 - phydev->irq = priv->phy_irq; 360 + priv->mdiobus->irq[addr] = phy_irq; 361 + phydev->irq = phy_irq; 360 362 361 363 err = phy_connect_direct(netdev, phydev, 362 364 mlxbf_gige_adjust_link, ··· 392 394 return 0; 393 395 394 396 out: 395 - mlxbf_gige_gpio_free(priv); 396 397 mlxbf_gige_mdio_remove(priv); 397 398 return err; 398 399 } ··· 402 405 403 406 unregister_netdev(priv->netdev); 404 407 phy_disconnect(priv->netdev->phydev); 405 - mlxbf_gige_gpio_free(priv); 406 408 mlxbf_gige_mdio_remove(priv); 407 409 platform_set_drvdata(pdev, NULL); 408 410
+14
include/linux/firmware/xlnx-zynqmp.h
··· 72 72 PM_SET_REQUIREMENT = 15, 73 73 PM_RESET_ASSERT = 17, 74 74 PM_RESET_GET_STATUS = 18, 75 + PM_MMIO_WRITE = 19, 76 + PM_MMIO_READ = 20, 75 77 PM_PM_INIT_FINALIZE = 21, 76 78 PM_FPGA_LOAD = 22, 77 79 PM_FPGA_GET_STATUS = 23, ··· 399 397 int zynqmp_pm_reset_assert(const enum zynqmp_pm_reset reset, 400 398 const enum zynqmp_pm_reset_action assert_flag); 401 399 int zynqmp_pm_reset_get_status(const enum zynqmp_pm_reset reset, u32 *status); 400 + unsigned int zynqmp_pm_bootmode_read(u32 *ps_mode); 401 + int zynqmp_pm_bootmode_write(u32 ps_mode); 402 402 int zynqmp_pm_init_finalize(void); 403 403 int zynqmp_pm_set_suspend_mode(u32 mode); 404 404 int zynqmp_pm_request_node(const u32 node, const u32 capabilities, ··· 532 528 533 529 static inline int zynqmp_pm_reset_get_status(const enum zynqmp_pm_reset reset, 534 530 u32 *status) 531 + { 532 + return -ENODEV; 533 + } 534 + 535 + static inline unsigned int zynqmp_pm_bootmode_read(u32 *ps_mode) 536 + { 537 + return -ENODEV; 538 + } 539 + 540 + static inline int zynqmp_pm_bootmode_write(u32 ps_mode) 535 541 { 536 542 return -ENODEV; 537 543 }
+1 -1
include/linux/spi/max7301.h
··· 31 31 u32 input_pullup_active; 32 32 }; 33 33 34 - extern int __max730x_remove(struct device *dev); 34 + extern void __max730x_remove(struct device *dev); 35 35 extern int __max730x_probe(struct max7301 *ts); 36 36 #endif
+26 -1
include/uapi/linux/virtio_gpio.h
··· 5 5 6 6 #include <linux/types.h> 7 7 8 + /* Virtio GPIO Feature bits */ 9 + #define VIRTIO_GPIO_F_IRQ 0 10 + 8 11 /* Virtio GPIO request types */ 9 12 #define VIRTIO_GPIO_MSG_GET_NAMES 0x0001 10 13 #define VIRTIO_GPIO_MSG_GET_DIRECTION 0x0002 11 14 #define VIRTIO_GPIO_MSG_SET_DIRECTION 0x0003 12 15 #define VIRTIO_GPIO_MSG_GET_VALUE 0x0004 13 16 #define VIRTIO_GPIO_MSG_SET_VALUE 0x0005 17 + #define VIRTIO_GPIO_MSG_IRQ_TYPE 0x0006 14 18 15 19 /* Possible values of the status field */ 16 20 #define VIRTIO_GPIO_STATUS_OK 0x0 ··· 25 21 #define VIRTIO_GPIO_DIRECTION_OUT 0x01 26 22 #define VIRTIO_GPIO_DIRECTION_IN 0x02 27 23 24 + /* Virtio GPIO IRQ types */ 25 + #define VIRTIO_GPIO_IRQ_TYPE_NONE 0x00 26 + #define VIRTIO_GPIO_IRQ_TYPE_EDGE_RISING 0x01 27 + #define VIRTIO_GPIO_IRQ_TYPE_EDGE_FALLING 0x02 28 + #define VIRTIO_GPIO_IRQ_TYPE_EDGE_BOTH 0x03 29 + #define VIRTIO_GPIO_IRQ_TYPE_LEVEL_HIGH 0x04 30 + #define VIRTIO_GPIO_IRQ_TYPE_LEVEL_LOW 0x08 31 + 28 32 struct virtio_gpio_config { 29 33 __le16 ngpio; 30 34 __u8 padding[2]; 31 35 __le32 gpio_names_size; 32 - } __packed; 36 + }; 33 37 34 38 /* Virtio GPIO Request / Response */ 35 39 struct virtio_gpio_request { ··· 55 43 __u8 status; 56 44 __u8 value[]; 57 45 }; 46 + 47 + /* Virtio GPIO IRQ Request / Response */ 48 + struct virtio_gpio_irq_request { 49 + __le16 gpio; 50 + }; 51 + 52 + struct virtio_gpio_irq_response { 53 + __u8 status; 54 + }; 55 + 56 + /* Possible values of the interrupt status field */ 57 + #define VIRTIO_GPIO_IRQ_STATUS_INVALID 0x0 58 + #define VIRTIO_GPIO_IRQ_STATUS_VALID 0x1 58 59 59 60 #endif /* _LINUX_VIRTIO_GPIO_H */