Date: Sun, 22 Feb 2015 03:04:41 +0000 (UTC) From: Nathan Whitehorn <nwhitehorn@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r279137 - in user/nwhitehorn/ppc64-pmap-rework: powermac ps3 Message-ID: <201502220304.t1M34fKi045722@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: nwhitehorn Date: Sun Feb 22 03:04:40 2015 New Revision: 279137 URL: https://svnweb.freebsd.org/changeset/base/279137 Log: MFC @ r279136 Modified: user/nwhitehorn/ppc64-pmap-rework/powermac/atibl.c user/nwhitehorn/ppc64-pmap-rework/powermac/nvbl.c user/nwhitehorn/ppc64-pmap-rework/powermac/powermac_thermal.c user/nwhitehorn/ppc64-pmap-rework/ps3/ps3_syscons.c Directory Properties: user/nwhitehorn/ppc64-pmap-rework/ (props changed) Modified: user/nwhitehorn/ppc64-pmap-rework/powermac/atibl.c ============================================================================== --- user/nwhitehorn/ppc64-pmap-rework/powermac/atibl.c Sun Feb 22 02:59:53 2015 (r279136) +++ user/nwhitehorn/ppc64-pmap-rework/powermac/atibl.c Sun Feb 22 03:04:40 2015 (r279137) @@ -38,6 +38,11 @@ __FBSDID("$FreeBSD$"); #include <machine/bus.h> #include <dev/ofw/openfirm.h> +#include <dev/pci/pcivar.h> + +#ifndef PCI_VENDOR_ID_ATI +#define PCI_VENDOR_ID_ATI 0x1002 +#endif /* From the xf86-video-ati driver's radeon_reg.h */ #define RADEON_LVDS_GEN_CNTL 0x02d0 @@ -121,7 +126,9 @@ atibl_probe(device_t dev) if (OF_getprop(handle, "backlight-control", &control, sizeof(control)) < 0) return (ENXIO); - if (strcmp(control, "ati") != 0) + if (strcmp(control, "ati") != 0 && + (strcmp(control, "mnca") != 0 || + pci_get_vendor(device_get_parent(dev)) != 0x1002)) return (ENXIO); device_set_desc(dev, "PowerBook backlight for ATI graphics"); @@ -162,14 +169,13 @@ atibl_pll_rreg(struct atibl_softc *sc, u { uint32_t data, save, tmp; - bus_write_1(sc->sc_memr, RADEON_CLOCK_CNTL_INDEX, - ((reg & 0x3f) | RADEON_PLL_WR_EN)); + bus_write_1(sc->sc_memr, RADEON_CLOCK_CNTL_INDEX, (reg & 0x3f)); (void)bus_read_4(sc->sc_memr, RADEON_CLOCK_CNTL_DATA); (void)bus_read_4(sc->sc_memr, RADEON_CRTC_GEN_CNTL); data = bus_read_4(sc->sc_memr, RADEON_CLOCK_CNTL_DATA); - /* Only necessary on R300, bt won't hurt others. */ + /* Only necessary on R300, but won't hurt others. */ save = bus_read_4(sc->sc_memr, RADEON_CLOCK_CNTL_INDEX); tmp = save & (~0x3f | RADEON_PLL_WR_EN); bus_write_4(sc->sc_memr, RADEON_CLOCK_CNTL_INDEX, tmp); @@ -192,7 +198,7 @@ atibl_pll_wreg(struct atibl_softc *sc, u bus_write_4(sc->sc_memr, RADEON_CLOCK_CNTL_DATA, val); DELAY(5000); - /* Only necessary on R300, bt won't hurt others. */ + /* Only necessary on R300, but won't hurt others. */ save = bus_read_4(sc->sc_memr, RADEON_CLOCK_CNTL_INDEX); tmp = save & (~0x3f | RADEON_PLL_WR_EN); bus_write_4(sc->sc_memr, RADEON_CLOCK_CNTL_INDEX, tmp); Modified: user/nwhitehorn/ppc64-pmap-rework/powermac/nvbl.c ============================================================================== --- user/nwhitehorn/ppc64-pmap-rework/powermac/nvbl.c Sun Feb 22 02:59:53 2015 (r279136) +++ user/nwhitehorn/ppc64-pmap-rework/powermac/nvbl.c Sun Feb 22 03:04:40 2015 (r279137) @@ -38,6 +38,9 @@ __FBSDID("$FreeBSD$"); #include <machine/bus.h> #include <dev/ofw/openfirm.h> +#include <dev/pci/pcivar.h> + +#define PCI_VENDOR_ID_NVIDIA 0x10de #define NVIDIA_BRIGHT_MIN (0x0ec) #define NVIDIA_BRIGHT_MAX (0x538) @@ -102,7 +105,8 @@ nvbl_probe(device_t dev) if (OF_getprop(handle, "backlight-control", &control, sizeof(control)) < 0) return (ENXIO); - if (strcmp(control, "mnca") != 0) + if ((strcmp(control, "mnca") != 0) || + pci_get_vendor(device_get_parent(dev)) != PCI_VENDOR_ID_NVIDIA) return (ENXIO); device_set_desc(dev, "PowerBook backlight for nVidia graphics"); Modified: user/nwhitehorn/ppc64-pmap-rework/powermac/powermac_thermal.c ============================================================================== --- user/nwhitehorn/ppc64-pmap-rework/powermac/powermac_thermal.c Sun Feb 22 02:59:53 2015 (r279136) +++ user/nwhitehorn/ppc64-pmap-rework/powermac/powermac_thermal.c Sun Feb 22 03:04:40 2015 (r279137) @@ -42,6 +42,9 @@ __FBSDID("$FreeBSD$"); #include "powermac_thermal.h" +/* A 10 second timer for spinning down fans. */ +#define FAN_HYSTERESIS_TIMER 10 + static void fan_management_proc(void); static void pmac_therm_manage_fans(void); @@ -63,6 +66,7 @@ static MALLOC_DEFINE(M_PMACTHERM, "pmact struct pmac_fan_le { struct pmac_fan *fan; int last_val; + int timer; SLIST_ENTRY(pmac_fan_le) entries; }; struct pmac_sens_le { @@ -95,6 +99,7 @@ pmac_therm_manage_fans(void) struct pmac_sens_le *sensor; struct pmac_fan_le *fan; int average_excess, max_excess_zone, frac_excess; + int fan_speed; int nsens, nsens_zone; int temp; @@ -137,10 +142,11 @@ pmac_therm_manage_fans(void) nsens = nsens_zone = 0; average_excess = max_excess_zone = 0; SLIST_FOREACH(sensor, &sensors, entries) { - frac_excess = (sensor->last_val - + temp = imin(sensor->last_val, + sensor->sensor->max_temp); + frac_excess = (temp - sensor->sensor->target_temp)*100 / - (sensor->sensor->max_temp - - sensor->sensor->target_temp); + (sensor->sensor->max_temp - temp + 1); if (frac_excess < 0) frac_excess = 0; if (sensor->sensor->zone == fan->fan->zone) { @@ -166,9 +172,21 @@ pmac_therm_manage_fans(void) * Scale the fan linearly in the max temperature in its * thermal zone. */ - fan->fan->set(fan->fan, max_excess_zone * + max_excess_zone = imin(max_excess_zone, 100); + fan_speed = max_excess_zone * (fan->fan->max_rpm - fan->fan->min_rpm)/100 + - fan->fan->min_rpm); + fan->fan->min_rpm; + if (fan_speed >= fan->last_val) { + fan->timer = FAN_HYSTERESIS_TIMER; + fan->last_val = fan_speed; + } else { + fan->timer--; + if (fan->timer == 0) { + fan->last_val = fan_speed; + fan->timer = FAN_HYSTERESIS_TIMER; + } + } + fan->fan->set(fan->fan, fan->last_val); } } Modified: user/nwhitehorn/ppc64-pmap-rework/ps3/ps3_syscons.c ============================================================================== --- user/nwhitehorn/ppc64-pmap-rework/ps3/ps3_syscons.c Sun Feb 22 02:59:53 2015 (r279136) +++ user/nwhitehorn/ppc64-pmap-rework/ps3/ps3_syscons.c Sun Feb 22 03:04:40 2015 (r279137) @@ -49,8 +49,6 @@ __FBSDID("$FreeBSD$"); #include "ps3-hvcall.h" -#define PS3FB_SIZE (4*1024*1024) - #define L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_MODE_SET 0x0100 #define L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC 0x0101 #define L1GPU_DISPLAY_SYNC_HSYNC 1 @@ -138,8 +136,8 @@ ps3fb_remap(void) 0,L1GPU_DISPLAY_SYNC_VSYNC,0,0); lv1_gpu_context_attribute(0, L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC, 1,L1GPU_DISPLAY_SYNC_VSYNC,0,0); - lv1_gpu_memory_allocate(PS3FB_SIZE, 0, 0, 0, 0, &sc->sc_fbhandle, - &fb_paddr); + lv1_gpu_memory_allocate(roundup2(sc->fb_info.fb_size, 1024*1024), + 0, 0, 0, 0, &sc->sc_fbhandle, &fb_paddr); lv1_gpu_context_allocate(sc->sc_fbhandle, 0, &sc->sc_fbcontext, &sc->sc_dma_control, &sc->sc_driver_info, &sc->sc_reports, &sc->sc_reports_size); @@ -150,7 +148,7 @@ ps3fb_remap(void) L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP, 1, 0, 0, 0); sc->fb_info.fb_pbase = fb_paddr; - for (va = 0; va < PS3FB_SIZE; va += PAGE_SIZE) + for (va = 0; va < sc->fb_info.fb_size; va += PAGE_SIZE) pmap_kenter_attr(0x10000000 + va, fb_paddr + va, VM_MEMATTR_WRITE_COMBINING); sc->fb_info.fb_flags &= ~FB_FLAG_NOWRITE; @@ -168,6 +166,8 @@ ps3fb_init(struct vt_device *vd) sc->fb_info.fb_depth = 32; sc->fb_info.fb_height = 480; sc->fb_info.fb_width = 720; + TUNABLE_INT_FETCH("hw.ps3fb.height", &sc->fb_info.fb_height); + TUNABLE_INT_FETCH("hw.ps3fb.width", &sc->fb_info.fb_width); sc->fb_info.fb_stride = sc->fb_info.fb_width*4; sc->fb_info.fb_size = sc->fb_info.fb_height * sc->fb_info.fb_stride; sc->fb_info.fb_bpp = sc->fb_info.fb_stride / sc->fb_info.fb_width * 8;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201502220304.t1M34fKi045722>