svn commit: r282827 - in head/sys: arm/ti/am335x boot/fdt/dts/arm

Rui Paulo rpaulo at me.com
Wed May 13 05:38:54 UTC 2015


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 <meloun at miracle.cz>
>   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 <sys/clock.h>
>  #include <sys/time.h>
>  #include <sys/bus.h>
> +#include <sys/proc.h>
>  #include <sys/reboot.h>
>  #include <sys/resource.h>
>  #include <sys/rman.h>
> @@ -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


More information about the svn-src-all mailing list