From owner-svn-src-head@FreeBSD.ORG Wed May 13 05:38:54 2015 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 04993F32; Wed, 13 May 2015 05:38:54 +0000 (UTC) Received: from st11p00im-asmtp004.me.com (st11p00im-asmtp004.me.com [17.172.80.98]) (using TLSv1.2 with cipher DHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CFB871DDF; Wed, 13 May 2015 05:38:53 +0000 (UTC) Received: from akita.localnet (c-73-162-13-215.hsd1.ca.comcast.net [73.162.13.215]) by st11p00im-asmtp004.me.com (Oracle Communications Messaging Server 7.0.5.35.0 64bit (built Dec 4 2014)) with ESMTPSA id <0NO900ISAU8F0I20@st11p00im-asmtp004.me.com>; Wed, 13 May 2015 04:38:45 +0000 (GMT) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.14.151,1.0.33,0.0.0000 definitions=2015-05-13_01:2015-05-12,2015-05-13,1970-01-01 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=2 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=7.0.1-1412110000 definitions=main-1505130038 From: Rui Paulo To: Luiz Otavio O Souza Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r282827 - in head/sys: arm/ti/am335x boot/fdt/dts/arm Date: Tue, 12 May 2015 21:38:39 -0700 Message-id: <12569579.LIGAUiFBhh@akita> User-Agent: KMail/4.14.3 (FreeBSD/11.0-CURRENT; KDE/4.14.3; amd64; ; ) In-reply-to: <201505130110.t4D1ASEG014421@svn.freebsd.org> References: <201505130110.t4D1ASEG014421@svn.freebsd.org> MIME-version: 1.0 Content-transfer-encoding: 7Bit Content-type: text/plain; charset=us-ascii X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 May 2015 05:38:54 -0000 On Wednesday 13 May 2015 01:10:28 Luiz Otavio O Souza wrote: > Author: loos > Date: Wed May 13 01:10:28 2015 > New Revision: 282827 > URL: https://svnweb.freebsd.org/changeset/base/282827 > > Log: > Add support for the power button on BeagleBone Black. > > Shutdown and turn off the board when the power button is pressed. > > Submitted by: Michal Meloun > Relnotes: yes Cool! But... > > Modified: > head/sys/arm/ti/am335x/am335x_pmic.c > head/sys/boot/fdt/dts/arm/beaglebone-black.dts > > Modified: head/sys/arm/ti/am335x/am335x_pmic.c > ============================================================================ > == --- head/sys/arm/ti/am335x/am335x_pmic.c Wed May 13 00:28:36 > 2015 (r282826) +++ head/sys/arm/ti/am335x/am335x_pmic.c Wed May 13 01:10:28 > 2015 (r282827) @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); > #include > #include > #include > +#include > #include > #include > #include > @@ -58,12 +59,20 @@ __FBSDID("$FreeBSD$"); > #define TPS65217D 0x6 > > /* TPS65217 Reisters */ > -#define TPS65217_CHIPID_REG 0x00 > -#define TPS65217_STATUS_REG 0x0A > -#define TPS65217_STATUS_OFF (1U << 7) > -#define TPS65217_STATUS_ACPWR (1U << 3) > -#define TPS65217_STATUS_USBPWR (1U << 2) > -#define TPS65217_STATUS_BT (1U << 0) > +#define TPS65217_CHIPID_REG 0x00 > +#define TPS65217_INT_REG 0x02 > +#define TPS65217_INT_PBM (1U << 6) > +#define TPS65217_INT_ACM (1U << 5) > +#define TPS65217_INT_USBM (1U << 4) > +#define TPS65217_INT_PBI (1U << 2) > +#define TPS65217_INT_ACI (1U << 1) > +#define TPS65217_INT_USBI (1U << 0) > + > +#define TPS65217_STATUS_REG 0x0A > +#define TPS65217_STATUS_OFF (1U << 7) > +#define TPS65217_STATUS_ACPWR (1U << 3) > +#define TPS65217_STATUS_USBPWR (1U << 2) > +#define TPS65217_STATUS_BT (1U << 0) > > #define MAX_IIC_DATA_SIZE 2 > > @@ -72,6 +81,8 @@ struct am335x_pmic_softc { > device_t sc_dev; > uint32_t sc_addr; > struct intr_config_hook enum_hook; > + struct resource *sc_irq_res; > + void *sc_intrhand; > }; > > static void am335x_pmic_shutdown(void *, int); > @@ -105,6 +116,38 @@ am335x_pmic_write(device_t dev, uint8_t > return (iicbus_transfer(dev, msg, 1)); > } > > +static void > +am335x_pmic_intr(void *arg) > +{ > + struct am335x_pmic_softc *sc = (struct am335x_pmic_softc *)arg; > + uint8_t int_reg, status_reg; > + int rv; > + char notify_buf[16]; > + > + THREAD_SLEEPING_OK(); > + rv = am335x_pmic_read(sc->sc_dev, TPS65217_INT_REG, &int_reg, 1); Scary! The correct way to handle this case is to start a task(9). Why wasn't that done here? -- Rui Paulo