Date: Thu, 15 May 2014 18:05:52 +0000 (UTC) From: Luiz Otavio O Souza <loos@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r266164 - stable/10/sys/arm/broadcom/bcm2835 Message-ID: <201405151805.s4FI5qqA023367@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: loos Date: Thu May 15 18:05:51 2014 New Revision: 266164 URL: http://svnweb.freebsd.org/changeset/base/266164 Log: MFC r256871, r259034, r266010 r256871: Implement watchdog function and register it with watchdog list. r259034: Make the sysctl node read-only. r266010: Remove extra newlines. No functional changes. Modified: stable/10/sys/arm/broadcom/bcm2835/bcm2835_fbd.c stable/10/sys/arm/broadcom/bcm2835/bcm2835_gpio.c stable/10/sys/arm/broadcom/bcm2835/bcm2835_wdog.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/arm/broadcom/bcm2835/bcm2835_fbd.c ============================================================================== --- stable/10/sys/arm/broadcom/bcm2835/bcm2835_fbd.c Thu May 15 18:02:08 2014 (r266163) +++ stable/10/sys/arm/broadcom/bcm2835/bcm2835_fbd.c Thu May 15 18:05:51 2014 (r266164) @@ -99,7 +99,6 @@ struct bcmsc_softc { struct bcm_fb_config* fb_config; bus_addr_t fb_config_phys; struct intr_config_hook init_hook; - }; static int bcm_fb_probe(device_t); @@ -167,14 +166,10 @@ bcm_fb_init(void *arg) fb_config->xoffset, fb_config->yoffset, fb_config->bpp); - device_printf(sc->dev, "pitch %d, base 0x%08x, screen_size %d\n", fb_config->pitch, fb_config->base, fb_config->screen_size); - - - info = malloc(sizeof(struct fb_info), M_DEVBUF, M_WAITOK | M_ZERO); info->fb_name = device_get_nameunit(sc->dev); @@ -199,8 +194,6 @@ bcm_fb_init(void *arg) device_printf(sc->dev, "Failed to attach fbd device\n"); return; } - - } else { device_printf(sc->dev, "Failed to set framebuffer info\n"); return; @@ -273,7 +266,6 @@ fail: return (ENXIO); } - static void bcm_fb_dmamap_cb(void *arg, bus_dma_segment_t *segs, int nseg, int err) { Modified: stable/10/sys/arm/broadcom/bcm2835/bcm2835_gpio.c ============================================================================== --- stable/10/sys/arm/broadcom/bcm2835/bcm2835_gpio.c Thu May 15 18:02:08 2014 (r266163) +++ stable/10/sys/arm/broadcom/bcm2835/bcm2835_gpio.c Thu May 15 18:05:51 2014 (r266164) @@ -589,7 +589,7 @@ bcm_gpio_sysctl_init(struct bcm_gpio_sof tree_node = device_get_sysctl_tree(sc->sc_dev); tree = SYSCTL_CHILDREN(tree_node); pin_node = SYSCTL_ADD_NODE(ctx, tree, OID_AUTO, "pin", - CTLFLAG_RW, NULL, "GPIO Pins"); + CTLFLAG_RD, NULL, "GPIO Pins"); pin_tree = SYSCTL_CHILDREN(pin_node); for (i = 0; i < sc->sc_gpio_npins; i++) { Modified: stable/10/sys/arm/broadcom/bcm2835/bcm2835_wdog.c ============================================================================== --- stable/10/sys/arm/broadcom/bcm2835/bcm2835_wdog.c Thu May 15 18:02:08 2014 (r266163) +++ stable/10/sys/arm/broadcom/bcm2835/bcm2835_wdog.c Thu May 15 18:05:51 2014 (r266164) @@ -76,11 +76,10 @@ struct bcmwd_softc { int wdog_armed; int wdog_period; char wdog_passwd; + struct mtx mtx; }; -#ifdef notyet static void bcmwd_watchdog_fn(void *private, u_int cmd, int *error); -#endif static int bcmwd_probe(device_t dev) @@ -123,19 +122,59 @@ bcmwd_attach(device_t dev) sc->bsh = rman_get_bushandle(sc->res); bcmwd_lsc = sc; -#ifdef notyet + mtx_init(&sc->mtx, "BCM2835 Watchdog", "bcmwd", MTX_DEF); EVENTHANDLER_REGISTER(watchdog_list, bcmwd_watchdog_fn, sc, 0); -#endif + return (0); } -#ifdef notyet static void bcmwd_watchdog_fn(void *private, u_int cmd, int *error) { - /* XXX: not yet */ + struct bcmwd_softc *sc; + uint64_t sec; + uint32_t ticks, reg; + + sc = private; + mtx_lock(&sc->mtx); + + cmd &= WD_INTERVAL; + + if (cmd > 0) { + sec = ((uint64_t)1 << (cmd & WD_INTERVAL)) / 1000000000; + ticks = (sec << 16) & BCM2835_WDOG_TIME_MASK; + if (ticks == 0) { + /* + * Can't arm + * disable watchdog as watchdog(9) requires + */ + device_printf(sc->dev, + "Can't arm, timeout is less than 1 second\n"); + WRITE(sc, BCM2835_RSTC_REG, + (BCM2835_PASWORD << BCM2835_PASSWORD_SHIFT) | + BCM2835_RSTC_RESET); + mtx_unlock(&sc->mtx); + return; + } + + reg = (BCM2835_PASWORD << BCM2835_PASSWORD_SHIFT) | ticks; + WRITE(sc, BCM2835_WDOG_REG, reg); + + reg = READ(sc, BCM2835_RSTC_REG); + reg &= BCM2835_RSTC_WRCFG_CLR; + reg |= BCM2835_RSTC_WRCFG_FULL_RESET; + reg |= (BCM2835_PASWORD << BCM2835_PASSWORD_SHIFT); + WRITE(sc, BCM2835_RSTC_REG, reg); + + *error = 0; + } + else + WRITE(sc, BCM2835_RSTC_REG, + (BCM2835_PASWORD << BCM2835_PASSWORD_SHIFT) | + BCM2835_RSTC_RESET); + + mtx_unlock(&sc->mtx); } -#endif void bcmwd_watchdog_reset()
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201405151805.s4FI5qqA023367>