From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (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 5E0D41714C0 for ; Wed, 9 Oct 2024 07:25:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728458724; cv=none; b=kLv6qUNrv77WOsTq6f5Am2qGvU1WKI5sOJvg8bLUnJVMZLU7c8U5kd+8VqT/eU8AT0yL+497H5DH7dacZQaY1kF3WL2o32FeScAokJiuvznfgU3VFiXbIZMUQ79e8r6vcih1Y5SDfS71Ofj87nCB+SW/eWjr7hZWqgHRwYZVzSM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728458724; c=relaxed/simple; bh=Ty5eMVVvVY5MCaKiPLxYbiTFsrUClvu/JT4lPiqjxXs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=PsxYZMAZD7DC7prv3tlSqRaVefDT5KtVUa83syyNN7Met2vvCoMWkE15p2BML/3ZvDp7bboOb+w9E1J6AQa5CxDKzaPijvtv9+P+xjR+2Fkm3D4n8VxOxkZ38h5ehH2/PWNWDxLJyPgiGZcjdxTax3UWgQlOeGfJmAZ4oV18zDY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1syR4J-0002qF-Ra; Wed, 09 Oct 2024 09:25:11 +0200 Received: from [2a0a:edc0:2:b01:1d::c5] (helo=pty.whiteo.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1syR4I-000YHt-V7; Wed, 09 Oct 2024 09:25:10 +0200 Received: from ore by pty.whiteo.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1syR4I-0022uJ-2j; Wed, 09 Oct 2024 09:25:10 +0200 Date: Wed, 9 Oct 2024 09:25:10 +0200 From: Oleksij Rempel To: Kory Maincent Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jonathan Corbet , Donald Hunter , Thomas Petazzoni , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-doc@vger.kernel.org, Kyle Swenson , Dent Project , kernel@pengutronix.de Subject: Re: [PATCH net-next 12/12] net: pse-pd: tps23881: Add support for PSE events and interrupts Message-ID: References: <20241002-feature_poe_port_prio-v1-0-787054f74ed5@bootlin.com> <20241002-feature_poe_port_prio-v1-12-787054f74ed5@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20241002-feature_poe_port_prio-v1-12-787054f74ed5@bootlin.com> X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Hi Kory, On Wed, Oct 02, 2024 at 06:28:08PM +0200, Kory Maincent wrote: > From: Kory Maincent (Dent Project) > > Add support for PSE event reporting through interrupts. Set up the newly > introduced devm_pse_irq_helper helper to register the interrupt. Events are > reported for over-current and over-temperature conditions. > > This patch also adds support for an OSS GPIO line to turn off all low > priority ports in case of an over-current event. > > Signed-off-by: Kory Maincent ... > +static int tps23881_irq_handler(int irq, struct pse_irq_data *pid, > + unsigned long *dev_mask) > +{ > + struct tps23881_priv *priv = (struct tps23881_priv *)pid->data; > + struct i2c_client *client = priv->client; > + struct pse_err_state *stat; > + int ret, i; > + u16 val; > + > + *dev_mask = 0; > + for (i = 0; i < TPS23881_MAX_CHANS; i++) { > + stat = &pid->states[i]; > + stat->notifs = 0; > + stat->errors = 0; > + } > + > + ret = i2c_smbus_read_word_data(client, TPS23881_REG_IT); > + if (ret < 0) > + return PSE_FAILED_RETRY; > + > + val = (u16)ret; > + if (val & TPS23881_REG_IT_SUPF) { > + ret = i2c_smbus_read_word_data(client, TPS23881_REG_SUPF_EVENT); > + if (ret < 0) > + return PSE_FAILED_RETRY; > + > + if (ret & TPS23881_REG_TSD) { > + for (i = 0; i < TPS23881_MAX_CHANS; i++) { > + stat = &pid->states[i]; > + *dev_mask |= 1 << i; > + stat->notifs = PSE_EVENT_OVER_TEMP; > + stat->errors = PSE_ERROR_OVER_TEMP; > + } > + } > + } > + > + if (val & (TPS23881_REG_IT_IFAULT | TPS23881_REG_IT_IFAULT << 8)) { > + ret = i2c_smbus_read_word_data(client, TPS23881_REG_FAULT); > + if (ret < 0) > + return PSE_FAILED_RETRY; > + > + val = (u16)(ret & 0xf0f); > + > + /* Power cut detected, shutdown low priority port */ > + if (val && priv->oss) > + tps23881_turn_off_low_prio(priv); Sorry, this is policy and even not the best one. The priority concept is related to the power budget, but this implementation will shutdown all low prios ports only if some port/channel has over-current event. It means, in case high prio port has over-current event, it will be not shut down. I'll propose not to add prio support for this chip right now, it will need more software infrastructure to handle it nearly in similar way as it is done by pd692x0. -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |