From nobody Tue Nov 26 16:31:14 2024 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=linux.vnet.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1706223044; cv=none; d=zohomail.com; s=zohoarc; b=K99CF60wM6YnbsKBxxwYL+dy1/ywjKZXWAq9Ov9mevr7dH7i1gd+ywoZ6RA0WZzPaBzBs5Et1fAIDuJtXNLKSIpbv+DEAKUEx9ydk6W7MBJt8FjNHnw7ZPTDMWsLnCp4Wf23rq0BBss13PHCddvTpJhBSty4XA3AR2tCaz/ujxs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706223044; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=iT+KujHMgPQTEhNtuj4AWxsRsQ7y4V0Nz3cGTO+yFNw=; b=gkwYYxMZgL+sCt8wVGsHBBr+8eCvhLn0srIx86STfpf4xW/PmwMJBjhlFHzqXY5K363ttyMtpt3nbItCTJu9/Xt/cmgsa/FQ5Swv9lkGCtcANkSyxILGrrencFPkjK54G6QM4Qk7C8jDzPE916k1Aeb5duXHLi7K7z9ddDbGtIE= 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 1706223044239614.6619877466424; Thu, 25 Jan 2024 14:50:44 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rT8X5-00079V-Vx; Thu, 25 Jan 2024 17:49:16 -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 ) id 1rT8X2-00076b-I0; Thu, 25 Jan 2024 17:49:13 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rT8X0-0000TR-5V; Thu, 25 Jan 2024 17:49:12 -0500 Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 40PKSgYt018200; Thu, 25 Jan 2024 22:48:56 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3vuvv0x5qm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Jan 2024 22:48:56 +0000 Received: from m0360083.ppops.net (m0360083.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 40PM05gM030608; Thu, 25 Jan 2024 22:48:55 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3vuvv0x5q4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Jan 2024 22:48:55 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 40PJVTjb022429; Thu, 25 Jan 2024 22:48:54 GMT Received: from smtprelay07.wdc07v.mail.ibm.com ([172.16.1.74]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3vrt0mey37-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Jan 2024 22:48:54 +0000 Received: from smtpav01.dal12v.mail.ibm.com (smtpav01.dal12v.mail.ibm.com [10.241.53.100]) by smtprelay07.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 40PMmrIc16974378 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Jan 2024 22:48:53 GMT Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 18F4B58057; Thu, 25 Jan 2024 22:48:53 +0000 (GMT) Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D804758059; Thu, 25 Jan 2024 22:48:52 +0000 (GMT) Received: from mamboa4.aus.stglabs.ibm.com (unknown [9.3.84.87]) by smtpav01.dal12v.mail.ibm.com (Postfix) with ESMTP; Thu, 25 Jan 2024 22:48:52 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=iT+KujHMgPQTEhNtuj4AWxsRsQ7y4V0Nz3cGTO+yFNw=; b=m5Q6iX0eU2ZA3PcsqJmlY8BrcwCbkWpwDGM53UXiVEm1D1lPJ4/1TSjUorYObf4mo1v9 8SLiWduE8GzjvOkkXZERqRXrcOwCNPt5TjG/aEUwA/7jA/JFOSsyp73xgwowu1qOzDvH d8v3wpf4YmE4cwerWriWKqJvIDzNyNMyfuQTTPdFFihwehv7/0ec/7sE2LEx2w9UZkvp 5qCAtAvLJU59UlbIG/XJzMTNgRivTNyXMiKV/yEWCn290F/JY+zEWl2mc9LRNr2t8Gtp xJ0XxKZ+SMieVLdkHaO07qDqdnqtUnYD1e+wPDI287Iw+BwfeuP8F2uN38iEx3vQUps8 oQ== From: Glenn Miles To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Cc: Glenn Miles , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Nicholas Piggin , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , Reza Arbab , Andrew Jeffery Subject: [PATCH v7 1/9] misc/pca9552: Fix inverted input status Date: Thu, 25 Jan 2024 16:48:10 -0600 Message-Id: <20240125224818.146499-2-milesg@linux.vnet.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240125224818.146499-1-milesg@linux.vnet.ibm.com> References: <20240125224818.146499-1-milesg@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: ILAf95B3FL1iPjMARy2jHDL5nuAIoCnm X-Proofpoint-GUID: d-ho7cSWVS3RWigKA8OQsqScnWqPdA0c X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-25_14,2024-01-25_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 mlxscore=0 adultscore=0 phishscore=0 clxscore=1011 priorityscore=1501 impostorscore=0 suspectscore=0 spamscore=0 lowpriorityscore=0 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401250164 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: none client-ip=148.163.156.1; envelope-from=milesg@linux.vnet.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 @ibm.com) X-ZM-MESSAGEID: 1706223044834100001 Content-Type: text/plain; charset="utf-8" The pca9552 INPUT0 and INPUT1 registers are supposed to hold the logical values of the LED pins. A logical 0 should be seen in the INPUT0/1 registers for a pin when its corresponding LSn bits are set to 0, which is also the state needed for turning on an LED in a typical usage scenario. Existing code was doing the opposite and setting INPUT0/1 bit to a 1 when the LSn bit was set to 0, so this commit fixes that. Reviewed-by: Andrew Jeffery Signed-off-by: Glenn Miles --- No changes from previous version hw/misc/pca9552.c | 18 +++++++++++++----- tests/qtest/pca9552-test.c | 6 +++--- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/hw/misc/pca9552.c b/hw/misc/pca9552.c index 72b653463f..f00a149d61 100644 --- a/hw/misc/pca9552.c +++ b/hw/misc/pca9552.c @@ -36,7 +36,10 @@ typedef struct PCA955xClass PCA955xClass; =20 DECLARE_CLASS_CHECKERS(PCA955xClass, PCA955X, TYPE_PCA955X) - +/* + * Note: The LED_ON and LED_OFF configuration values for the PCA955X + * chips are the reverse of the PCA953X family of chips. + */ #define PCA9552_LED_ON 0x0 #define PCA9552_LED_OFF 0x1 #define PCA9552_LED_PWM0 0x2 @@ -112,13 +115,18 @@ static void pca955x_update_pin_input(PCA955xState *s) =20 switch (config) { case PCA9552_LED_ON: - qemu_set_irq(s->gpio[i], 1); - s->regs[input_reg] |=3D 1 << input_shift; - break; - case PCA9552_LED_OFF: + /* Pin is set to 0V to turn on LED */ qemu_set_irq(s->gpio[i], 0); s->regs[input_reg] &=3D ~(1 << input_shift); break; + case PCA9552_LED_OFF: + /* + * Pin is set to Hi-Z to turn off LED and + * pullup sets it to a logical 1. + */ + qemu_set_irq(s->gpio[i], 1); + s->regs[input_reg] |=3D 1 << input_shift; + break; case PCA9552_LED_PWM0: case PCA9552_LED_PWM1: /* TODO */ diff --git a/tests/qtest/pca9552-test.c b/tests/qtest/pca9552-test.c index d80ed93cd3..ccca2b3d91 100644 --- a/tests/qtest/pca9552-test.c +++ b/tests/qtest/pca9552-test.c @@ -60,7 +60,7 @@ static void send_and_receive(void *obj, void *data, QGues= tAllocator *alloc) g_assert_cmphex(value, =3D=3D, 0x55); =20 value =3D i2c_get8(i2cdev, PCA9552_INPUT0); - g_assert_cmphex(value, =3D=3D, 0x0); + g_assert_cmphex(value, =3D=3D, 0xFF); =20 pca9552_init(i2cdev); =20 @@ -68,13 +68,13 @@ static void send_and_receive(void *obj, void *data, QGu= estAllocator *alloc) g_assert_cmphex(value, =3D=3D, 0x54); =20 value =3D i2c_get8(i2cdev, PCA9552_INPUT0); - g_assert_cmphex(value, =3D=3D, 0x01); + g_assert_cmphex(value, =3D=3D, 0xFE); =20 value =3D i2c_get8(i2cdev, PCA9552_LS3); g_assert_cmphex(value, =3D=3D, 0x54); =20 value =3D i2c_get8(i2cdev, PCA9552_INPUT1); - g_assert_cmphex(value, =3D=3D, 0x10); + g_assert_cmphex(value, =3D=3D, 0xEF); } =20 static void pca9552_register_nodes(void) --=20 2.31.1