1 // SPDX-License-Identifier: GPL-2.0+
4 * LCD Backlight driver for RAVE SP
6 * Copyright (C) 2018 Zodiac Inflight Innovations
10 #include <linux/backlight.h>
11 #include <linux/kernel.h>
12 #include <linux/module.h>
13 #include <linux/mfd/rave-sp.h>
14 #include <linux/platform_device.h>
16 #define RAVE_SP_BACKLIGHT_LCD_EN BIT(7)
18 static int rave_sp_backlight_update_status(struct backlight_device *bd)
20 const struct backlight_properties *p = &bd->props;
22 (p->power == FB_BLANK_UNBLANK) ? p->brightness : 0;
23 struct rave_sp *sp = dev_get_drvdata(&bd->dev);
25 [0] = RAVE_SP_CMD_SET_BACKLIGHT,
27 [2] = intensity ? RAVE_SP_BACKLIGHT_LCD_EN | intensity : 0,
32 return rave_sp_exec(sp, cmd, sizeof(cmd), NULL, 0);
35 static const struct backlight_ops rave_sp_backlight_ops = {
36 .options = BL_CORE_SUSPENDRESUME,
37 .update_status = rave_sp_backlight_update_status,
40 static struct backlight_properties rave_sp_backlight_props = {
41 .type = BACKLIGHT_PLATFORM,
42 .max_brightness = 100,
46 static int rave_sp_backlight_probe(struct platform_device *pdev)
48 struct device *dev = &pdev->dev;
49 struct backlight_device *bd;
51 bd = devm_backlight_device_register(dev, pdev->name, dev->parent,
52 dev_get_drvdata(dev->parent),
53 &rave_sp_backlight_ops,
54 &rave_sp_backlight_props);
58 backlight_update_status(bd);
63 static const struct of_device_id rave_sp_backlight_of_match[] = {
64 { .compatible = "zii,rave-sp-backlight" },
68 static struct platform_driver rave_sp_backlight_driver = {
69 .probe = rave_sp_backlight_probe,
71 .name = KBUILD_MODNAME,
72 .of_match_table = rave_sp_backlight_of_match,
75 module_platform_driver(rave_sp_backlight_driver);
77 MODULE_DEVICE_TABLE(of, rave_sp_backlight_of_match);
78 MODULE_LICENSE("GPL");
79 MODULE_AUTHOR("Andrey Vostrikov <andrey.vostrikov@cogentembedded.com>");
80 MODULE_AUTHOR("Nikita Yushchenko <nikita.yoush@cogentembedded.com>");
81 MODULE_AUTHOR("Andrey Smirnov <andrew.smirnov@gmail.com>");
82 MODULE_DESCRIPTION("RAVE SP Backlight driver");