From nobody Sat Oct 4 03:18:38 2025 Received: from smtpout3.mo534.mail-out.ovh.net (smtpout3.mo534.mail-out.ovh.net [51.210.94.142]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C46017263A for ; Thu, 21 Aug 2025 10:19:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=51.210.94.142 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755771589; cv=none; b=WkzSH07NdqwcqJqcf02Dz4I3+G1BvqaXPF7q2quvoeBVGi+wA6eVizWtae0cuP5sTlFELqm6C2AL5y216oVsiKFuOKGBmRM5Q2iu8cAqtKSlRLmK3kFgcij6/6CW93lF5YrX9s7rznyNMhm7lon0ta8B2jwhZiQ6L4aGxAqXLuA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755771589; c=relaxed/simple; bh=NqQf9Jc+3SbRrfRkJ4AYKg+XmoSQqCNl3ADyalX/KvQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lYp6QKsqIHi99MNezb4odmPyBV0KeQHMMUTeS7c2GNazysYXfDWDcfTTLZz83RzQohRbENzBPayi6roAvLEwo+L2PcGGXr13Odwo8VYsosyJhsQWf8WB9QVCXH6Dzq+3Se0bBG2fBrEsCqrJwkRLCF/lGnex0V7SZbJeAAQVL/E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=orca.pet; spf=pass smtp.mailfrom=orca.pet; dkim=pass (2048-bit key) header.d=orca.pet header.i=@orca.pet header.b=BultrdNB; arc=none smtp.client-ip=51.210.94.142 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=orca.pet Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=orca.pet Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=orca.pet header.i=@orca.pet header.b="BultrdNB" Received: from director2.derp.mail-out.ovh.net (director2.derp.mail-out.ovh.net [79.137.60.36]) by mo534.mail-out.ovh.net (Postfix) with ESMTPS id 4c6zp91RMjz6BJy; Thu, 21 Aug 2025 10:19:45 +0000 (UTC) Received: from director2.derp.mail-out.ovh.net (director2.derp.mail-out.ovh.net. [127.0.0.1]) by director2.derp.mail-out.ovh.net (inspect_sender_mail_agent) with SMTP for ; Thu, 21 Aug 2025 10:19:45 +0000 (UTC) Received: from mta7.priv.ovhmail-u1.ea.mail.ovh.net (unknown [10.110.37.222]) by director2.derp.mail-out.ovh.net (Postfix) with ESMTPS id 4c6zp90Qbkz1xnh; Thu, 21 Aug 2025 10:19:45 +0000 (UTC) Received: from orca.pet (unknown [10.1.6.9]) by mta7.priv.ovhmail-u1.ea.mail.ovh.net (Postfix) with ESMTPSA id 07D81B832BF; Thu, 21 Aug 2025 10:19:43 +0000 (UTC) Authentication-Results: garm.ovh; auth=pass (GARM-97G002b6cf9774-3ea7-46e3-8327-10b8b50bb1ac, 684E78C7C579463DAB27E2CA1F9C4E28A39E1181) smtp.auth=marcos@orca.pet X-OVh-ClientIp: 147.156.42.5 From: Marcos Del Sol Vives To: linux-kernel@vger.kernel.org Cc: Marcos Del Sol Vives , Linus Walleij , Bartosz Golaszewski , Michael Walle , Lee Jones , Bjorn Helgaas , linux-gpio@vger.kernel.org, linux-pci@vger.kernel.org Subject: [PATCH v3 2/3] gpio: vortex: add new GPIO device driver Date: Thu, 21 Aug 2025 12:18:58 +0200 Message-Id: <20250821101902.626329-3-marcos@orca.pet> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250821101902.626329-1-marcos@orca.pet> References: <20250821101902.626329-1-marcos@orca.pet> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 17492262431657055846 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdduiedtleekucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrrhgtohhsucffvghlucfuohhlucggihhvvghsuceomhgrrhgtohhssehorhgtrgdrphgvtheqnecuggftrfgrthhtvghrnhepkeevudelhfdvvdekjeehgffhheetjeefhfevgffhfefhgfdvlefgtefhgeduhefgnecuffhomhgrihhnpegumhhprdgtohhmrdhtfienucfkphepuddvjedrtddrtddruddpudegjedrudehiedrgedvrdehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepuddvjedrtddrtddruddpmhgrihhlfhhrohhmpehmrghrtghoshesohhrtggrrdhpvghtpdhnsggprhgtphhtthhopeelpdhrtghpthhtohepsghrghhlsegsghguvghvrdhplhdprhgtphhtthhopegshhgvlhhgrggrshesghhoohhglhgvrdgtohhmpdhrtghpthhtoheplhgvvgeskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepmhifrghllhgvsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhhsrdifrghllhgvihhjsehlihhnrghrohdrohhrghdprhgtphhtthhopehmrghrtghoshesohhrtggrrdhpvghtpdhrtghpthhtoheplhhinhhugi dqghhpihhosehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqphgtihesvhhgvghrrdhkvghrnhgvlhdrohhrgh DKIM-Signature: a=rsa-sha256; bh=JiNSSypzdmcdGwO4MzvY7/7N/cIlsyO551KqNqoZdhU=; c=relaxed/relaxed; d=orca.pet; h=From; s=ovhmo-selector-1; t=1755771585; v=1; b=BultrdNBYhvdi669Qga+DOJa1f8TR4W8fJUcJgoICU0Nozw7GoaGy8p9djdfFhDzInV+Y0bS p777+2mquBuaFC1UUBNeawhFUhaRMOz1Qw/GrWkWqbMhIUp9oELzf1Bfkge92Qrbk3JgfJ5RQNE WwM8p8TaI0qSmsWH58UcbjjYwi8ingC5v+ZxvffJTxWeHTYNW+7VljM/a9MMMNX8jDdwNYQtJKO YUEv/J0k2qTlVtWVCxuSxDwlSEJWJZykMp3RIIbcyC1TF9qxuwDO3DC946Qoeu6C8AeozTNfIRj WAQddxr+dQuijWHywzx7soBj2HmWSnMttaQTA+D/phMkA== Content-Type: text/plain; charset="utf-8" Add a new simple GPIO device driver for Vortex86 lines of SoCs, implemented according to their programming reference manual [1]. This is required for detecting the status of the poweroff button and performing the poweroff sequence on ICOP eBox computers. IRQs are not implemented, as they are only available for ports 0 and 1, none which are accessible on my test machine (an EBOX-3352-GLW). [1]: http://www.dmp.com.tw/tech/DMP_Vortex86_Series_Software_Programming_Referen= ce_091216.pdf Signed-off-by: Marcos Del Sol Vives Reviewed-by: Linus Walleij --- MAINTAINERS | 5 ++ drivers/gpio/Kconfig | 11 ++++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-vortex.c | 110 +++++++++++++++++++++++++++++++++++++ 4 files changed, 127 insertions(+) create mode 100644 drivers/gpio/gpio-vortex.c diff --git a/MAINTAINERS b/MAINTAINERS index daf520a13bdf..8c3098a39411 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -26953,6 +26953,11 @@ VOLTAGE AND CURRENT REGULATOR IRQ HELPERS R: Matti Vaittinen F: drivers/regulator/irq_helpers.c =20 +VORTEX HARDWARE SUPPORT +R: Marcos Del Sol Vives +S: Maintained +F: drivers/gpio/gpio-vortex.c + VRF M: David Ahern L: netdev@vger.kernel.org diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index e43abb322fa6..cd2b1e105908 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -1077,6 +1077,17 @@ config GPIO_TS5500 blocks of the TS-5500: DIO1, DIO2 and the LCD port, and the TS-5600 LCD port. =20 +config GPIO_VORTEX + tristate "Vortex SoC GPIO support" + select REGMAP_MMIO + select GPIO_REGMAP + help + Driver to access the five 8-bit bidirectional GPIO ports present on + all DM&P Vortex SoCs. + + To compile this driver as a module, choose M here: the module will + be called gpio-vortex. + config GPIO_WINBOND tristate "Winbond Super I/O GPIO support" select ISA_BUS_API diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index 379f55e9ed1e..7b8626c9bd75 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile @@ -197,6 +197,7 @@ obj-$(CONFIG_GPIO_VIPERBOARD) +=3D gpio-viperboard.o obj-$(CONFIG_GPIO_VIRTUSER) +=3D gpio-virtuser.o obj-$(CONFIG_GPIO_VIRTIO) +=3D gpio-virtio.o obj-$(CONFIG_GPIO_VISCONTI) +=3D gpio-visconti.o +obj-$(CONFIG_GPIO_VORTEX) +=3D gpio-vortex.o obj-$(CONFIG_GPIO_VX855) +=3D gpio-vx855.o obj-$(CONFIG_GPIO_WCD934X) +=3D gpio-wcd934x.o obj-$(CONFIG_GPIO_WHISKEY_COVE) +=3D gpio-wcove.o diff --git a/drivers/gpio/gpio-vortex.c b/drivers/gpio/gpio-vortex.c new file mode 100644 index 000000000000..6fc184942e7f --- /dev/null +++ b/drivers/gpio/gpio-vortex.c @@ -0,0 +1,110 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * GPIO driver for Vortex86 SoCs + * + * Author: Marcos Del Sol Vives + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DAT_RANGE 0 +#define DIR_RANGE 1 + +struct vortex_gpio { + struct regmap_range ranges[2]; + struct regmap_access_table access_table; +}; + +static int vortex_gpio_probe(struct platform_device *pdev) +{ + struct gpio_regmap_config gpiocfg =3D {}; + struct resource *dat_res, *dir_res; + struct device *dev =3D &pdev->dev; + struct regmap_config rmcfg =3D {}; + unsigned long io_start, io_end; + struct vortex_gpio *priv; + struct regmap *map; + void __iomem *regs; + + dat_res =3D platform_get_resource_byname(pdev, IORESOURCE_IO, "dat"); + if (unlikely(!dat_res)) { + dev_err(dev, "failed to get data register\n"); + return -ENODEV; + } + + dir_res =3D platform_get_resource_byname(pdev, IORESOURCE_IO, "dir"); + if (unlikely(!dir_res)) { + dev_err(dev, "failed to get direction register\n"); + return -ENODEV; + } + + if (unlikely(resource_size(dat_res) !=3D resource_size(dir_res))) { + dev_err(dev, "data and direction size mismatch\n"); + return -EINVAL; + } + + priv =3D devm_kzalloc(&pdev->dev, sizeof(struct vortex_gpio), + GFP_KERNEL); + if (unlikely(!priv)) + return -ENOMEM; + pdev->dev.driver_data =3D priv; + + /* Map an I/O window that covers both data and direction */ + io_start =3D min(dat_res->start, dir_res->start); + io_end =3D max(dat_res->end, dir_res->end); + regs =3D devm_ioport_map(dev, io_start, io_end - io_start + 1); + if (unlikely(!regs)) + return -ENOMEM; + + /* Dynamically build access table from gpiocfg */ + priv->ranges[DAT_RANGE].range_min =3D dat_res->start - io_start; + priv->ranges[DAT_RANGE].range_max =3D dat_res->end - io_start; + priv->ranges[DIR_RANGE].range_min =3D dir_res->start - io_start; + priv->ranges[DIR_RANGE].range_max =3D dir_res->end - io_start; + priv->access_table.n_yes_ranges =3D ARRAY_SIZE(priv->ranges); + priv->access_table.yes_ranges =3D priv->ranges; + + rmcfg.reg_bits =3D 8; + rmcfg.val_bits =3D 8; + rmcfg.io_port =3D true; + rmcfg.wr_table =3D &priv->access_table; + rmcfg.rd_table =3D &priv->access_table; + + map =3D devm_regmap_init_mmio(dev, regs, &rmcfg); + if (unlikely(IS_ERR(map))) + return dev_err_probe(dev, PTR_ERR(map), + "Unable to initialize register map\n"); + + gpiocfg.parent =3D dev; + gpiocfg.regmap =3D map; + gpiocfg.ngpio =3D 8 * resource_size(dat_res); + gpiocfg.ngpio_per_reg =3D 8; + gpiocfg.reg_dat_base =3D GPIO_REGMAP_ADDR(priv->ranges[DAT_RANGE].range_m= in); + gpiocfg.reg_set_base =3D GPIO_REGMAP_ADDR(priv->ranges[DAT_RANGE].range_m= in); + gpiocfg.reg_dir_out_base =3D GPIO_REGMAP_ADDR(priv->ranges[DIR_RANGE].ran= ge_min); + gpiocfg.flags =3D GPIO_REGMAP_DIR_BEFORE_SET; + + return PTR_ERR_OR_ZERO(devm_gpio_regmap_register(dev, &gpiocfg)); +} + +static struct platform_driver vortex_gpio_driver =3D { + .driver.name =3D "vortex-gpio", + .probe =3D vortex_gpio_probe, +}; + +module_platform_driver(vortex_gpio_driver); + +MODULE_AUTHOR("Marcos Del Sol Vives "); +MODULE_DESCRIPTION("GPIO driver for Vortex86 SoCs"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:vortex-gpio"); --=20 2.34.1