Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp188844lqh; Fri, 3 May 2024 19:15:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX2qJSYu3NOVtv/7hl3K8ZwDHC5ZTu5xCdtWnw7SA3LljWcN1Qeh0/p4SM6eThKkbpNxYZwuTnm+/zuz4dP2TUEKU14eYXS7vigPUAT2g== X-Google-Smtp-Source: AGHT+IGLzx35aNds9WqW8WlhlJmM36P5KFzjKUC1HxWorwUMPF7RiYV4xR20xVRSYSROK8kcthYp X-Received: by 2002:a05:6a20:3d91:b0:1a7:bb6d:6589 with SMTP id s17-20020a056a203d9100b001a7bb6d6589mr5197574pzi.29.1714788942248; Fri, 03 May 2024 19:15:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714788942; cv=pass; d=google.com; s=arc-20160816; b=LKypS2WcocudKS90bShq4ATc8tOyVlxtLBABD38udhyAa3EHuLLIJU4QffjhYaM3Lb YydhKHvf8aAdsEfSArTrrx/dRQ1xWP7i9eUNma7yoN4j1U+goiIhFkJ36XlLVdUrafXp DDn8H6QBbAKnRh4iE4WPLl82Af+EnAVskAPGkABCHggC0w8S6oqEWLfhaX66/qC6JRJh d8ErqUOcKP4dd6PiNWLxbE7cHflR+eVq6ZOBEhSQdIUeIIgjdW6Wq9Xkx5uSU0xn3Ljh kUG2wXdjtmCQTHTXM6iGQFuUhTgW6Pdv3rovNCrm9ZF2HLMTiDKAawZzHpJjY4iuqYfE e31g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=iT3udjGB19kjB5NF7BrwrjkqYtlnB7WlfhROoMGd5BA=; fh=3Ml11XK5MY/MGDMKcsZeKW7JtixbKgbbbw2mRmCYf9o=; b=RKBzQuP3O6EBR3zw7+MFw/5ZJ39RqIZGluCMl359imIjQKyzBvS4ot5gp638yMk2w0 U96mrKP9kqTsu62cHbZyAzZDcNEKTafcfOUUP30oALiwm+idMs3AV+CmticgphzNEgfC KhxjrW0dXo97nuYCmF5el7Em3a7EnIvqdRI6nvH5alSgxUdOGnHsvKf4VgougExlukMO NvX/MfQFJT/Q04iVvAedi1sSacwL53X5a66AOXeyqMFPcyXkbTeLKRbWEy74tVdT6PDU EQAivrFUdGxXLlm8miEuA2ZYxywX6v52paNTt+SPrjk2yrXDQKxbwIrlTyzGDxJ40wtZ i7MQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kaechele.ca header.s=201907 header.b=oFWSmhjR; arc=pass (i=1 spf=pass spfdomain=kaechele.ca dkim=pass dkdomain=kaechele.ca dmarc=pass fromdomain=kaechele.ca); spf=pass (google.com: domain of linux-kernel+bounces-168494-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168494-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=kaechele.ca Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id h24-20020a17090acf1800b002b3de96ad25si3594969pju.7.2024.05.03.19.15.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 19:15:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-168494-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kaechele.ca header.s=201907 header.b=oFWSmhjR; arc=pass (i=1 spf=pass spfdomain=kaechele.ca dkim=pass dkdomain=kaechele.ca dmarc=pass fromdomain=kaechele.ca); spf=pass (google.com: domain of linux-kernel+bounces-168494-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168494-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=kaechele.ca Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 9C07228297C for ; Sat, 4 May 2024 02:15:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9E7BD12E55; Sat, 4 May 2024 02:15:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=kaechele.ca header.i=@kaechele.ca header.b="oFWSmhjR" Received: from mail.kaechele.ca (mail.kaechele.ca [54.39.219.105]) (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 5D4C66AC0; Sat, 4 May 2024 02:15:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=54.39.219.105 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714788923; cv=none; b=D3T6CFhz6ydunx2+hSC9bgoG4nqgAEcoT7uSTRKnCIkqaeF3ww1VP4AXM5DEM94rWc4FxOHai5bTEzwYEaV7SRsmmmhBdFpbQGCRmi8llxVIkg1uI0kRlVmQZ6zKwlKLbLavBNI6XUAJ5silNQMeikKVT5HmQial1m12bRnKvOM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714788923; c=relaxed/simple; bh=xIMubRPsKcK6KDKMCglr9VJplkobSOyIGHpSONrXlIU=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TA1/YDEwEVwawsF7UPogj6X2CB08aCHJRbM6p0VPuuneYOcltRV3ImgYv8/+zMUoYUp+n6UOuYGJB7+o6SKYRpBIBFX88ViarNrA9/MhO10PSqGZmzk1FzXjGkpssL3PuFIhp0ehWi6TQYt1BGPP+3k3JHL6NdJi7U/b/LQ/Pfk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=kaechele.ca; spf=pass smtp.mailfrom=kaechele.ca; dkim=pass (1024-bit key) header.d=kaechele.ca header.i=@kaechele.ca header.b=oFWSmhjR; arc=none smtp.client-ip=54.39.219.105 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=kaechele.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kaechele.ca Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 30460C006E; Fri, 3 May 2024 22:08:09 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kaechele.ca; s=201907; t=1714788489; h=from:subject:date:message-id:to:mime-version: content-transfer-encoding:in-reply-to:references; bh=iT3udjGB19kjB5NF7BrwrjkqYtlnB7WlfhROoMGd5BA=; b=oFWSmhjRH++upK+uMJ0WW9cvi74ewzT32BtIulnQ374abgVXVEu9qyXNvw9F807RIKTVU7 p6XO+FxGvXnBFaJuCbow+1Ex4NQvx21HlEmywP+y2hk+Vi5uj9WUv0++tPrgniIu4kNVuD BAHKjqRFI96kxvzujN/aVMpUvsmeO8w= From: Felix Kaechele To: Job Noorman , Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/6] input: himax_hx83112b: add regulator handling Date: Fri, 3 May 2024 22:04:41 -0400 Message-ID: <20240504020745.68525-3-felix@kaechele.ca> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240504020745.68525-1-felix@kaechele.ca> References: <20240504020745.68525-1-felix@kaechele.ca> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Last-TLS-Session-Version: TLSv1.3 Handle regulators used on this chip family, namely AVDD and VDD. These definitions are taken from the GPLv2 licensed vendor driver. Signed-off-by: Felix Kaechele Link: https://github.com/HimaxSoftware/HX83112_Android_Driver --- drivers/input/touchscreen/himax_hx83112b.c | 48 ++++++++++++++++++++-- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/drivers/input/touchscreen/himax_hx83112b.c b/drivers/input/touchscreen/himax_hx83112b.c index 4f6609dcdef3..0a797789e548 100644 --- a/drivers/input/touchscreen/himax_hx83112b.c +++ b/drivers/input/touchscreen/himax_hx83112b.c @@ -19,10 +19,12 @@ #include #include #include +#include #define HIMAX_ID_83112B 0x83112b #define HIMAX_MAX_POINTS 10 +#define HIMAX_MAX_SUPPLIES 2 #define HIMAX_REG_CFG_SET_ADDR 0x00 #define HIMAX_REG_CFG_INIT_READ 0x0c @@ -50,6 +52,7 @@ struct himax_event { static_assert(sizeof(struct himax_event) == 56); struct himax_ts_data { + struct regulator_bulk_data supplies[HIMAX_MAX_SUPPLIES]; struct gpio_desc *gpiod_rst; struct input_dev *input_dev; struct i2c_client *client; @@ -63,6 +66,11 @@ static const struct regmap_config himax_regmap_config = { .val_format_endian = REGMAP_ENDIAN_LITTLE, }; +static const char *const himax_supply_names[] = { + "avdd", + "vdd", +}; + static int himax_read_config(struct himax_ts_data *ts, u32 address, u32 *dst) { int error; @@ -267,7 +275,7 @@ static irqreturn_t himax_irq_handler(int irq, void *dev_id) static int himax_probe(struct i2c_client *client) { - int error; + int error, i; struct device *dev = &client->dev; struct himax_ts_data *ts; @@ -290,11 +298,31 @@ static int himax_probe(struct i2c_client *client) return error; } + int num_supplies = ARRAY_SIZE(himax_supply_names); + + for (i = 0; i < num_supplies; i++) + ts->supplies[i].supply = himax_supply_names[i]; + + error = devm_regulator_bulk_get(dev, + num_supplies, + ts->supplies); + if (error) { + dev_err(dev, "Failed to get supplies: %d\n", error); + return error; + } + + error = regulator_bulk_enable(num_supplies, + ts->supplies); + if (error) { + dev_err(dev, "Failed to enable supplies: %d\n", error); + goto error_out; + } + ts->gpiod_rst = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); error = PTR_ERR_OR_ZERO(ts->gpiod_rst); if (error) { dev_err(dev, "Failed to get reset GPIO: %d\n", error); - return error; + goto error_out; } himax_reset(ts); @@ -305,15 +333,26 @@ static int himax_probe(struct i2c_client *client) error = himax_input_register(ts); if (error) - return error; + goto error_out; error = devm_request_threaded_irq(dev, client->irq, NULL, himax_irq_handler, IRQF_ONESHOT, client->name, ts); if (error) - return error; + goto error_out; return 0; + +error_out: + regulator_bulk_disable(num_supplies, ts->supplies); + return error; +} + +static void himax_remove(struct i2c_client *client) +{ + struct himax_ts_data *ts = i2c_get_clientdata(client); + + regulator_bulk_disable(ARRAY_SIZE(himax_supply_names), ts->supplies); } static int himax_suspend(struct device *dev) @@ -350,6 +389,7 @@ MODULE_DEVICE_TABLE(of, himax_of_match); static struct i2c_driver himax_ts_driver = { .probe = himax_probe, + .remove = himax_remove, .id_table = himax_ts_id, .driver = { .name = "Himax-hx83112b-TS", -- 2.44.0