gmux: Add generic write32 function
[platform/adaptation/renesas_rcar/renesas_kernel.git] / drivers / platform / x86 / apple-gmux.c
index 694a15a..c9db507 100644 (file)
@@ -75,6 +75,18 @@ static inline u32 gmux_read32(struct apple_gmux_data *gmux_data, int port)
        return inl(gmux_data->iostart + port);
 }
 
+static inline u32 gmux_write32(struct apple_gmux_data *gmux_data, int port,
+                              u32 val)
+{
+       int i;
+       u8 tmpval;
+
+       for (i = 0; i < 4; i++) {
+               tmpval = (val >> (i * 8)) & 0xff;
+               outb(tmpval, port + i);
+       }
+}
+
 static int gmux_get_brightness(struct backlight_device *bd)
 {
        struct apple_gmux_data *gmux_data = bl_get_data(bd);
@@ -90,16 +102,7 @@ static int gmux_update_status(struct backlight_device *bd)
        if (bd->props.state & BL_CORE_SUSPENDED)
                return 0;
 
-       /*
-        * Older gmux versions require writing out lower bytes first then
-        * setting the upper byte to 0 to flush the values. Newer versions
-        * accept a single u32 write, but the old method also works, so we
-        * just use the old method for all gmux versions.
-        */
-       gmux_write8(gmux_data, GMUX_PORT_BRIGHTNESS, brightness);
-       gmux_write8(gmux_data, GMUX_PORT_BRIGHTNESS + 1, brightness >> 8);
-       gmux_write8(gmux_data, GMUX_PORT_BRIGHTNESS + 2, brightness >> 16);
-       gmux_write8(gmux_data, GMUX_PORT_BRIGHTNESS + 3, 0);
+       gmux_write32(gmux_data, GMUX_PORT_BRIGHTNESS, brightness);
 
        return 0;
 }
@@ -193,7 +196,10 @@ static int __devinit gmux_probe(struct pnp_dev *pnp,
         * backlight control and supports more levels than other options.
         * Disable the other backlight choices.
         */
+       acpi_video_dmi_promote_vendor();
+#ifdef CONFIG_ACPI_VIDEO
        acpi_video_unregister();
+#endif
        apple_bl_unregister();
 
        return 0;
@@ -213,7 +219,10 @@ static void __devexit gmux_remove(struct pnp_dev *pnp)
        release_region(gmux_data->iostart, gmux_data->iolen);
        kfree(gmux_data);
 
+       acpi_video_dmi_demote_vendor();
+#ifdef CONFIG_ACPI_VIDEO
        acpi_video_register();
+#endif
        apple_bl_register();
 }