diff options
author | Marcin Juszkiewicz <openembedded@hrw.one.pl> | 2007-02-07 22:24:01 +0000 |
---|---|---|
committer | Richard Purdie <rpurdie@rpsys.net> | 2007-02-20 08:35:09 +0000 |
commit | 7a208463b20e893e8e2074b2d41b8dc09568ddee (patch) | |
tree | d45ac55f11ec31d5728d0b6411c044b323fb5651 /drivers/video | |
parent | 300abeb5490d6fab640f7da3f612fc8c1b906580 (diff) |
backlight: Add Frontpath ProGear HX1050+ driver
Add control of LCD backlight for Frontpath ProGear HX1050+.
Patch is based on http://downloads.sf.net/progear/progear-lcd-0.2.tar.gz
driver by M Schacht.
Signed-off-by: Marcin Juszkiewicz <openembedded@hrw.one.pl>
Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
Diffstat (limited to 'drivers/video')
-rw-r--r-- | drivers/video/backlight/Kconfig | 8 | ||||
-rw-r--r-- | drivers/video/backlight/Makefile | 1 | ||||
-rw-r--r-- | drivers/video/backlight/progear_bl.c | 154 |
3 files changed, 163 insertions, 0 deletions
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig index 02f15297a02..cda32399c03 100644 --- a/drivers/video/backlight/Kconfig +++ b/drivers/video/backlight/Kconfig @@ -66,3 +66,11 @@ config BACKLIGHT_HP680 If you have a HP Jornada 680, say y to enable the backlight driver. +config BACKLIGHT_PROGEAR + tristate "Frontpath ProGear Backlight Driver" + depends on BACKLIGHT_DEVICE && PCI && X86 + default n + help + If you have a Frontpath ProGear say Y to enable the + backlight driver. + diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile index 65e5553fc84..0c3ce46f509 100644 --- a/drivers/video/backlight/Makefile +++ b/drivers/video/backlight/Makefile @@ -5,3 +5,4 @@ obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += backlight.o obj-$(CONFIG_BACKLIGHT_CORGI) += corgi_bl.o obj-$(CONFIG_BACKLIGHT_HP680) += hp680_bl.o obj-$(CONFIG_BACKLIGHT_LOCOMO) += locomolcd.o +obj-$(CONFIG_BACKLIGHT_PROGEAR) += progear_bl.o diff --git a/drivers/video/backlight/progear_bl.c b/drivers/video/backlight/progear_bl.c new file mode 100644 index 00000000000..13d831da8d9 --- /dev/null +++ b/drivers/video/backlight/progear_bl.c @@ -0,0 +1,154 @@ +/* + * Backlight Driver for Frontpath ProGear HX1050+ + * + * Copyright (c) 2006 Marcin Juszkiewicz + * + * Based on Progear LCD driver by M Schacht + * <mschacht at alumni dot washington dot edu> + * + * Based on Sharp's Corgi Backlight Driver + * Based on Backlight Driver for HP Jornada 680 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + */ + +#include <linux/module.h> +#include <linux/kernel.h> +#include <linux/init.h> +#include <linux/platform_device.h> +#include <linux/mutex.h> +#include <linux/fb.h> +#include <linux/backlight.h> +#include <linux/pci.h> +#include <asm/uaccess.h> + +#define PMU_LPCR 0xB0 +#define SB_MPS1 0x61 +#define HW_LEVEL_MAX 0x77 +#define HW_LEVEL_MIN 0x4f + +static struct pci_dev *pmu_dev = NULL; +static struct pci_dev *sb_dev = NULL; + +static int progearbl_set_intensity(struct backlight_device *bd) +{ + int intensity = bd->props->brightness; + + if (bd->props->power != FB_BLANK_UNBLANK) + intensity = 0; + if (bd->props->fb_blank != FB_BLANK_UNBLANK) + intensity = 0; + + pci_write_config_byte(pmu_dev, PMU_LPCR, intensity + HW_LEVEL_MIN); + + return 0; +} + +static int progearbl_get_intensity(struct backlight_device *bd) +{ + u8 intensity; + pci_read_config_byte(pmu_dev, PMU_LPCR, &intensity); + + return intensity - HW_LEVEL_MIN; +} + +static struct backlight_properties progearbl_data = { + .owner = THIS_MODULE, + .get_brightness = progearbl_get_intensity, + .update_status = progearbl_set_intensity, +}; + +static int progearbl_probe(struct platform_device *pdev) +{ + u8 temp; + struct backlight_device *progear_backlight_device; + + pmu_dev = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101, 0); + if (!pmu_dev) { + printk("ALI M7101 PMU not found.\n"); + return -ENODEV; + } + + sb_dev = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, 0); + if (!sb_dev) { + printk("ALI 1533 SB not found.\n"); + pci_dev_put(pmu_dev); + return -ENODEV; + } + + /* Set SB_MPS1 to enable brightness control. */ + pci_read_config_byte(sb_dev, SB_MPS1, &temp); + pci_write_config_byte(sb_dev, SB_MPS1, temp | 0x20); + + progear_backlight_device = backlight_device_register("progear-bl", + &pdev->dev, NULL, + &progearbl_data); + if (IS_ERR(progear_backlight_device)) + return PTR_ERR(progear_backlight_device); + + platform_set_drvdata(pdev, progear_backlight_device); + + progearbl_data.power = FB_BLANK_UNBLANK; + progearbl_data.brightness = HW_LEVEL_MAX - HW_LEVEL_MIN; + progearbl_data.max_brightness = HW_LEVEL_MAX - HW_LEVEL_MIN; + progearbl_set_intensity(progear_backlight_device); + + return 0; +} + +static int progearbl_remove(struct platform_device *pdev) +{ + struct backlight_device *bd = platform_get_drvdata(pdev); + backlight_device_unregister(bd); + + return 0; +} + +static struct platform_driver progearbl_driver = { + .probe = progearbl_probe, + .remove = progearbl_remove, + .driver = { + .name = "progear-bl", + }, +}; + +static struct platform_device *progearbl_device; + +static int __init progearbl_init(void) +{ + int ret = platform_driver_register(&progearbl_driver); + + if (!ret) { + progearbl_device = platform_device_alloc("progear-bl", -1); + if (!progearbl_device) + return -ENOMEM; + + ret = platform_device_add(progearbl_device); + + if (ret) { + platform_device_put(progearbl_device); + platform_driver_unregister(&progearbl_driver); + } + } + + return ret; +} + +static void __exit progearbl_exit(void) +{ + pci_dev_put(pmu_dev); + pci_dev_put(sb_dev); + + platform_device_unregister(progearbl_device); + platform_driver_unregister(&progearbl_driver); +} + +module_init(progearbl_init); +module_exit(progearbl_exit); + +MODULE_AUTHOR("Marcin Juszkiewicz <linux@hrw.one.pl>"); +MODULE_DESCRIPTION("ProGear Backlight Driver"); +MODULE_LICENSE("GPL"); |