From nobody Mon Feb 9 00:43:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1675896280; cv=none; d=zohomail.com; s=zohoarc; b=aYmZ5TDowOkhpzfKlICDwxiXz92iNexXC+7qBkJfiUBl6DXIMEayXuHipBFkLAvpTUOvxIY90EsTPO91K7ilZY/3/Io8vyNPfiQrl/PqEEr3hONWUZD8Dw9lqsM+2GxchhsexLYCWRZZD5GjdZK6R4/1J628KnJ7UHNUden7dzI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675896280; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5oMuDhrUQqITAotZfJ8MWZdGKIdyKs09j9oU2pnVQlU=; b=IyrYYmBWIQ7nhytyJuqfYDtys0pqBsV66I3Kmz3TtZwBTBqTbEYyFNw4c9kzRy7pYO5rU2ja7qp2Zfh8piME71MiePd3G0bgiSjc846GTUXnTW1NG8H/69MNYiFSXYQfCIco4KrUYf4bI46zPRpHqH9mtaDoeEYcsbW/oSqgtg4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1675896280575384.8224840162254; Wed, 8 Feb 2023 14:44:40 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pPtAY-0008TA-0u; Wed, 08 Feb 2023 17:44:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3rCXkYwYKCq0gVghfeTbbTYR.PbZdRZh-QRiRYabaTah.beT@flex--titusr.bounces.google.com>) id 1pPtAV-0008R7-Nq for qemu-devel@nongnu.org; Wed, 08 Feb 2023 17:43:59 -0500 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3rCXkYwYKCq0gVghfeTbbTYR.PbZdRZh-QRiRYabaTah.beT@flex--titusr.bounces.google.com>) id 1pPtAT-0002fx-Om for qemu-devel@nongnu.org; Wed, 08 Feb 2023 17:43:59 -0500 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-4fa63c84621so1063727b3.20 for ; Wed, 08 Feb 2023 14:43:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=5oMuDhrUQqITAotZfJ8MWZdGKIdyKs09j9oU2pnVQlU=; b=Ffg0Hi27/B0DGCFy+s9HUCXZp+jiFOv/iN6/1o+tikvqXF4nz/HxJaH0BVwxFCoWk9 v6TvSEMB1PcKoa7wt4nKbclLb5oR0nkCvLY+BkQQyEE8HNsBX/yUl7cn0vi72JQiRu+g PIu3pI8hgOcPj325r8tIH7G3I+JzcDU5ocgbU4pddCzpntP9rGoXlyVXpslYDkZEE5Q0 4DGWZLVcJAh1AJV8YHe+ndsJD8T+iTQvSqZh/HDxvfaT1dTYcMpVmfsfQCeAPh3rvI/F 8HC1QwCr7VkLqF3y4yb4FhEhhafx0AXvOOSKQOFk2tJdxXQB0hh23weoCVLE2wjG9S5N YWcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=5oMuDhrUQqITAotZfJ8MWZdGKIdyKs09j9oU2pnVQlU=; b=w+5uvXkvDdE42mZD9DL/cfKRiVb8rZf8ecZpUfgzCZJY0gqSfGJ4NQR6WnghhzeBu3 Nh4zGocEctP+BytvStoUoY8n09vNkU4lxwXVxMoLVOMwtSSwkrpcYmQurgo04Q0ySSxg JurY5o3qFw3vooCh/9BrBJxXpPHcjS3UvvqwdIKMoHJRmWhJZJGEG3G+uWH5LwDNsCbI MdYQSODLrgdKvaiMJt8pXvgxMLuFd6/3lp/ueuHKS1BetP0I8GP9RC6EcaIk88++tM3B 7l3/UQ2nBpKlo7oIzFNo4hKpb/bLNa+E/KRbZVExqG5qy0xE0ExK8JGtpMd6K8TrXTyv TRVQ== X-Gm-Message-State: AO0yUKXw6tZ23D+Np83z1fDiZqAac1bDef+dLDN6yhIykeORmSTo1g70 kOYHL/fp7FkY+6phcRMP9C31lA/ZjpI= X-Google-Smtp-Source: AK7set9dedtyRkFYOKAMa4rg5Ei3ucK3cZjekLVCkIl2wDY/ln99k3arbd0NoM0dMw8dYLaJ0wH7wFvmw84= X-Received: from titusr.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:22b8]) (user=titusr job=sendgmr) by 2002:a25:6dd4:0:b0:8ac:dc22:ddec with SMTP id i203-20020a256dd4000000b008acdc22ddecmr8ybc.10.1675896236337; Wed, 08 Feb 2023 14:43:56 -0800 (PST) Date: Wed, 8 Feb 2023 22:43:38 +0000 In-Reply-To: <20230208224339.270589-1-titusr@google.com> Mime-Version: 1.0 References: <20230208224339.270589-1-titusr@google.com> X-Mailer: git-send-email 2.39.1.581.gbfd45094c4-goog Message-ID: <20230208224339.270589-4-titusr@google.com> Subject: [PATCH v2 3/4] hw/gpio: add PCA9536 i2c gpio expander From: Titus Rwantare To: philmd@linaro.org, minyard@acm.org, eddie.dong@intel.com Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org, joel@jms.id.au, Titus Rwantare , Hao Wu Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1149; envelope-from=3rCXkYwYKCq0gVghfeTbbTYR.PbZdRZh-QRiRYabaTah.beT@flex--titusr.bounces.google.com; helo=mail-yw1-x1149.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, USER_IN_DEF_DKIM_WL=-7.5 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1675896281396100002 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This device has the same register layout as the pca9538, but 4 fewer gpio pins. This commit lowers the number of pins initialised, and reuses the pca9538 logic. Reviewed-by: Hao Wu Signed-off-by: Titus Rwantare Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/gpio/pca_i2c_gpio.c | 18 ++++++++++++++++++ include/hw/gpio/pca_i2c_gpio.h | 2 ++ 2 files changed, 20 insertions(+) diff --git a/hw/gpio/pca_i2c_gpio.c b/hw/gpio/pca_i2c_gpio.c index fa69523556..8e30064990 100644 --- a/hw/gpio/pca_i2c_gpio.c +++ b/hw/gpio/pca_i2c_gpio.c @@ -426,6 +426,19 @@ static void pca9538_gpio_class_init(ObjectClass *klass= , void *data) k->send =3D pca9538_send; } =20 +static void pca9536_gpio_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + I2CSlaveClass *k =3D I2C_SLAVE_CLASS(klass); + PCAGPIOClass *pc =3D PCA_I2C_GPIO_CLASS(klass); + + dc->desc =3D "PCA9536 4-bit I/O expander"; + pc->num_pins =3D PCA9536_NUM_PINS; + + k->recv =3D pca9538_recv; + k->send =3D pca9538_send; +} + static void pca_i2c_gpio_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); @@ -477,6 +490,11 @@ static const TypeInfo pca_gpio_types[] =3D { .parent =3D TYPE_PCA_I2C_GPIO, .class_init =3D pca9538_gpio_class_init, }, + { + .name =3D TYPE_PCA9536_GPIO, + .parent =3D TYPE_PCA_I2C_GPIO, + .class_init =3D pca9536_gpio_class_init, + }, }; =20 DEFINE_TYPES(pca_gpio_types); diff --git a/include/hw/gpio/pca_i2c_gpio.h b/include/hw/gpio/pca_i2c_gpio.h index 3ab7d19a97..6f8260a8c6 100644 --- a/include/hw/gpio/pca_i2c_gpio.h +++ b/include/hw/gpio/pca_i2c_gpio.h @@ -20,6 +20,7 @@ #define PCA_I2C_MAX_PINS 16 #define PCA6416_NUM_PINS 16 #define PCA9538_NUM_PINS 8 +#define PCA9536_NUM_PINS 4 =20 typedef struct PCAGPIOClass { I2CSlaveClass parent; @@ -72,5 +73,6 @@ OBJECT_DECLARE_TYPE(PCAGPIOState, PCAGPIOClass, PCA_I2C_G= PIO) =20 #define TYPE_PCA6416_GPIO "pca6416" #define TYPE_PCA9538_GPIO "pca9538" +#define TYPE_PCA9536_GPIO "pca9536" =20 #endif --=20 2.39.1.581.gbfd45094c4-goog