++#include "../../../drivers/cbus/tahvo.h"
++
++
++struct tahvo_pwm_device {
++ struct device *dev;
++ int tahvo_7bit_backlight;
++};
++
++static struct tahvo_pwm_device *tahvo_pwm;
++
++static unsigned int tahvo_pwm_get_backlight_level(struct tahvo_pwm_device *pd)
++{
++ unsigned int mask;
++
++ if (pd->tahvo_7bit_backlight)
++ mask = 0x7f;
++ else
++ mask = 0x0f;
++ return tahvo_read_reg(pd->dev, TAHVO_REG_LEDPWMR) & mask;
++}
++
++static unsigned int tahvo_pwm_get_max_backlight_level(struct tahvo_pwm_device *pd)
++{
++ if (pd->tahvo_7bit_backlight)
++ return 0x7f;
++ return 0x0f;
++}
++
++static void tahvo_pwm_set_backlight_level(struct tahvo_pwm_device *pd, unsigned int level)
++{
++ unsigned int max_level;
++
++ max_level = tahvo_pwm_get_max_backlight_level(pd);
++ if (level > max_level)
++ level = max_level;
++ tahvo_write_reg(pd->dev, TAHVO_REG_LEDPWMR, level);
++}
++
++static int __init n8x0_tahvo_pwm_probe(struct platform_device *pdev)
++{
++ struct tahvo_pwm_device *pd;
++ unsigned int rev, id;
++
++ pd = kzalloc(sizeof(*pd), GFP_KERNEL);
++ if (WARN_ON(!pd))
++ return -ENOMEM;
++ pd->dev = &pdev->dev;
++
++ rev = tahvo_read_reg(pd->dev, TAHVO_REG_ASICR);
++ id = (rev >> 8) & 0xff;
++ if (id == 0x03) {
++ if ((rev & 0xff) >= 0x50)
++ pd->tahvo_7bit_backlight = 1;
++ } else if (id == 0x0b)
++ pd->tahvo_7bit_backlight = 1;
++
++ dev_set_drvdata(pd->dev, pd);
++ tahvo_pwm = pd;
++}
++
++static struct platform_driver n8x0_tahvo_pwm_driver = {
++ .driver = {
++ .name = "tahvo-pwm",
++ },
++};
++
++static int __init n8x0_tahvo_pwm_init(void)
++{
++ return platform_driver_probe(&n8x0_tahvo_pwm_driver, n8x0_tahvo_pwm_probe);
++}
++fs_initcall(n8x0_tahvo_pwm_init);
++
++static int n8x0_get_backlight_level(struct mipid_platform_data *pdata)
++{
++ return tahvo_pwm_get_backlight_level(tahvo_pwm);
++}
++
++static int n8x0_get_max_backlight_level(struct mipid_platform_data *pdata)
++{
++ return tahvo_pwm_get_max_backlight_level(tahvo_pwm);
++}
++
++static void n8x0_set_backlight_level(struct mipid_platform_data *pdata, int level)
++{
++ tahvo_pwm_set_backlight_level(tahvo_pwm, level);
++}