Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp186697lqh; Fri, 3 May 2024 19:08:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUN+dODhBAPxmUyuCoGOrPSPyGno2s7JCJaZnyGq9p0ygMTkCEJ7wy16sbkIcjtqfvWrikHklApRPg/+dNr7GAMzF2cVxHdP7uG8Gb3JQ== X-Google-Smtp-Source: AGHT+IFmdKLhdjx68170QuN4MuS5JuNfXGBWwpRpbYitxYgD4cJhat2eP3/l0jguNQZrSIP8V1Or X-Received: by 2002:a17:907:9875:b0:a52:2441:277 with SMTP id ko21-20020a170907987500b00a5224410277mr2597933ejc.66.1714788496956; Fri, 03 May 2024 19:08:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714788496; cv=pass; d=google.com; s=arc-20160816; b=h24GQ0mG8jjYdSQTcCR+1Uqh3imPSfz1T5u8sTrYWONWaGJYHthKxBLc2vDsI6Uwwm k4wONkcXG+FVq6jA3iT52rpXp//Wj3dVK67JhrTPeNkiJzd+wFU0Dvuzb5v8xMQkUjFC MVJNWx1jYRuVf0fjsRrDm0yQboTr9Zu+UsBj3nh73KyFEA2gIU9eCNOyFF9pXf8BkXAw e4l1k2SaF1b/HxALX4UkWxkL+YdAomByiAtRZdJr6c4kbOA9htXBesEruW49vBI/tZ9r c2XEoKBmD33/usOR1r5GCBHS8+jrBuhcvat6Wlkfa1NaafkLetRN6xjVFHWiiyqlBYzt /RmA== 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=urS88EVc3Y2DTRlVBr6koQ8c8bKoBQO9OBgP+LpuXV0=; fh=3Ml11XK5MY/MGDMKcsZeKW7JtixbKgbbbw2mRmCYf9o=; b=c2gbag/GwCCjrM/XB3v/CSXdOx8mQQ5mmkqG7lD6moh3cqtvYkD9Dzp5yASl5T2p+B 6oG22GM5X5gjQaRvXNqCbGKS00G3ubNCPJCEgetg8LlIZDQfNhBfBagobuauDQLcrTg6 j584DR07rPMf8vRCbyhh0L58Tyd2Sgibb6xv4DJmt49uoRZR6lZYsgVV1dRsMu4Zn5e1 x1/2MWyjP4T/u3VdOV0gRyfTTGvLqZf5fMd/kX7eNkKMJHCSdVu4lea9w54FBk2dECJw yDAK9qlGmA9yxSs5ZZCGnNZcY93dfIoA6seTDHZZo4DOJa1JumQoeU0gnDL1UFQwK73s zmNQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kaechele.ca header.s=201907 header.b=mJ1Zhou+; 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-168490-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168490-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=kaechele.ca Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id ga19-20020a170906b85300b00a59a0bb392asi524187ejb.471.2024.05.03.19.08.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 19:08:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-168490-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kaechele.ca header.s=201907 header.b=mJ1Zhou+; 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-168490-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168490-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 85B141F24239 for ; Sat, 4 May 2024 02:08:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9FF1DF4E7; Sat, 4 May 2024 02:08:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=kaechele.ca header.i=@kaechele.ca header.b="mJ1Zhou+" 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 5B1EF210D; Sat, 4 May 2024 02:08:02 +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=1714788484; cv=none; b=F2L0xb3avCttOTBxTfAnWxaDIjvosZgbDf1MbwnVyJIPnCbJ1/rM4zcC9DwqfGBPzGtWLHnBWIT1r+u3PxZ4CKKPeqw4udJdfPPOSASlArM78v3baCZQdEtVhZgPzR04CdLR7MDrhKn0sxg7AObU13V49l9RP86dhDtNOtkNydQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714788484; c=relaxed/simple; bh=BYyg1SiTgeo3qfXhKZEi1hR0S5PAcTSMT9TliXuH9hY=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ckx0ujMrUL8VfdRCmEfzwT6aDQGeIP0AYdzLoQKuUSTYDo2FZn4xyG2KohltCLhArvS4ndgtWE6VQ0zF1qRUWYCKPZ7o2p/E6unOUVGsRmOQi+D9hnMiH6lPtfPumSn1QgKJpCmlIeBce3L9tulqLWR1ePoO3kuGG+cVVjLeJaE= 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=mJ1Zhou+; 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 EBDD9C0072; Fri, 3 May 2024 22:08:11 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kaechele.ca; s=201907; t=1714788492; h=from:subject:date:message-id:to:mime-version: content-transfer-encoding:in-reply-to:references; bh=urS88EVc3Y2DTRlVBr6koQ8c8bKoBQO9OBgP+LpuXV0=; b=mJ1Zhou+K7+3qsOhx6ecPzBFInJ/SuPXoVtBpzVFfi7rOLh/vxLkbEWFAHD52SO+KiuPh4 mlKn13eFDJ4DWwsqpg4jBvyli3JgfP9nnX0L3ePpo+Sv1jb7MPTSHt0p8aE83zXCVQUfxY 4+IMvNonBRXVB4ZOZmRf1qRSPdp27Lo= 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 5/6] input: himax_hx83112b: add himax_chip struct for multi-chip support Date: Fri, 3 May 2024 22:04:44 -0400 Message-ID: <20240504020745.68525-6-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 In preparation for HX83100A support allow defining separate functions for specific chip operations. Signed-off-by: Felix Kaechele --- drivers/input/touchscreen/himax_hx83112b.c | 53 +++++++++++++++------- 1 file changed, 37 insertions(+), 16 deletions(-) diff --git a/drivers/input/touchscreen/himax_hx83112b.c b/drivers/input/touchscreen/himax_hx83112b.c index 0173ff394a99..667611c5a018 100644 --- a/drivers/input/touchscreen/himax_hx83112b.c +++ b/drivers/input/touchscreen/himax_hx83112b.c @@ -21,8 +21,6 @@ #include #include -#define HIMAX_ID_83112B 0x83112b - #define HIMAX_MAX_POINTS 10 #define HIMAX_MAX_SUPPLIES 2 @@ -57,7 +55,17 @@ struct himax_event { static_assert(sizeof(struct himax_event) == 56); +struct himax_ts_data; +struct himax_chip { + u32 id; + int (*check_id)(struct himax_ts_data *ts); + int (*read_events)(struct himax_ts_data *ts, + struct himax_event *event, + size_t length); +}; + struct himax_ts_data { + const struct himax_chip *chip; struct regulator_bulk_data supplies[HIMAX_MAX_SUPPLIES]; struct gpio_desc *gpiod_rst; struct input_dev *input_dev; @@ -176,15 +184,12 @@ static int himax_check_product_id(struct himax_ts_data *ts) dev_dbg(&ts->client->dev, "Product id: %x\n", product_id); - switch (product_id) { - case HIMAX_ID_83112B: + if (product_id == ts->chip->id) return 0; - default: - dev_err(&ts->client->dev, - "Unknown product id: %x\n", product_id); - return -EINVAL; - } + dev_err(&ts->client->dev, "Unknown product id: %x\n", + product_id); + return -EINVAL; } static int himax_input_register(struct himax_ts_data *ts) @@ -286,13 +291,20 @@ static bool himax_verify_checksum(struct himax_ts_data *ts, return true; } +static int himax_read_events(struct himax_ts_data *ts, + struct himax_event *event, + size_t length) +{ + return regmap_raw_read(ts->regmap, HIMAX_AHB_ADDR_EVENT_STACK, event, + length); +} + static int himax_handle_input(struct himax_ts_data *ts) { int error; struct himax_event event; - error = regmap_raw_read(ts->regmap, HIMAX_AHB_ADDR_EVENT_STACK, &event, - sizeof(event)); + error = ts->chip->read_events(ts, &event, sizeof(event)); if (error) { dev_err(&ts->client->dev, "Failed to read input event: %d\n", error); @@ -338,6 +350,7 @@ static int himax_probe(struct i2c_client *client) i2c_set_clientdata(client, ts); ts->client = client; + ts->chip = i2c_get_match_data(client); ts->regmap = devm_regmap_init_i2c(client, &himax_regmap_config); error = PTR_ERR_OR_ZERO(ts->regmap); @@ -375,9 +388,11 @@ static int himax_probe(struct i2c_client *client) himax_reset(ts); - error = himax_check_product_id(ts); - if (error) - return error; + if (ts->chip->check_id) { + error = himax_check_product_id(ts); + if (error) + return error; + } error = himax_input_register(ts); if (error) @@ -421,15 +436,21 @@ static int himax_resume(struct device *dev) static DEFINE_SIMPLE_DEV_PM_OPS(himax_pm_ops, himax_suspend, himax_resume); +static const struct himax_chip hx83112b_chip = { + .id = 0x83112b, + .check_id = himax_check_product_id, + .read_events = himax_read_events, +}; + static const struct i2c_device_id himax_ts_id[] = { - { "hx83112b", 0 }, + { "hx83112b", (kernel_ulong_t) &hx83112b_chip }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(i2c, himax_ts_id); #ifdef CONFIG_OF static const struct of_device_id himax_of_match[] = { - { .compatible = "himax,hx83112b" }, + { .compatible = "himax,hx83112b", .data = &hx83112b_chip }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, himax_of_match); -- 2.44.0