/* * Backlight Driver for Dialog DA9052 PMICs * * Copyright(c) 2012 Dialog Semiconductor Ltd. * * Author: David Dajun Chen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * */ #include #include #include #include #include #include #include #define DA9052_MAX_BRIGHTNESS 0xFF enum { DA9052_WLEDS_OFF, DA9052_WLEDS_ON, }; enum { DA9052_TYPE_WLED1, DA9052_TYPE_WLED2, DA9052_TYPE_WLED3, }; static const unsigned char wled_bank[] = { DA9052_LED1_CONF_REG, DA9052_LED2_CONF_REG, DA9052_LED3_CONF_REG, }; struct da9052_bl { struct da9052 *da9052; uint brightness; uint state; uint led_reg; }; static int da9052_adjust_wled_brightness(struct da9052_bl *wleds) { unsigned char boost_en; unsigned char i_sink; int ret; boost_en = 0x3F; i_sink = 0xFF; if (wleds->state == DA9052_WLEDS_OFF) { boost_en = 0x00; i_sink = 0x00; } ret = da9052_reg_write(wleds->da9052, DA9052_BOOST_REG, boost_en); if (ret < 0) return ret; ret = da9052_reg_write(wleds->da9052, DA9052_LED_CONT_REG, i_sink); if (ret < 0) return ret; ret = da9052_reg_write(wleds->da9052, wled_bank[wleds->led_reg], 0x0); if (ret < 0) return ret; usleep_range(10000, 11000); if (wleds->brightness) { ret = da9052_reg_write(wleds->da9052, wled_bank[wleds->led_reg], wleds->brightness); if (ret < 0) return ret; } return 0; } static int da9052_backlight_update_status(struct backlight_device *bl) { int brightness = bl->props.brightness; struct da9052_bl *wleds = bl_get_data(bl); wleds->brightness = brightness; wleds->state = DA9052_WLEDS_ON; return da9052_adjust_wled_brightness(wleds); } static int da9052_backlight_get_brightness(struct backlight_device *bl) { struct da9052_bl *wleds = bl_get_data(bl); return wleds->brightness; } static const struct backlight_ops da9052_backlight_ops = { .update_status = da9052_backlight_update_status, .get_brightness = da9052_backlight_get_brightness, }; static int da9052_backlight_probe(struct platform_device *pdev) { struct backlight_device *bl; struct backlight_properties props; struct da9052_bl *wleds; wleds = devm_kzalloc(&pdev->dev, sizeof(struct da9052_bl), GFP_KERNEL); if (!wleds) return -ENOMEM; wleds->da9052 = dev_get_drvdata(pdev->dev.parent); wleds->brightness = 0; wleds->led_reg = platform_get_device_id(pdev)->driver_data; wleds->state = DA9052_WLEDS_OFF; props.type = BACKLIGHT_RAW; props.max_brightness = DA9052_MAX_BRIGHTNESS; bl = devm_backlight_device_register(&pdev->dev, pdev->name, wleds->da9052->dev, wleds, &da9052_backlight_ops, &props); if (IS_ERR(bl)) { dev_err(&pdev->dev, "Failed to register backlight\n"); return PTR_ERR(bl); } bl->props.max_brightness = DA9052_MAX_BRIGHTNESS; bl->props.brightness = 0; platform_set_drvdata(pdev, bl); return da9052_adjust_wled_brightness(wleds); } static int da9052_backlight_remove(struct platform_device *pdev) { struct backlight_device *bl = platform_get_drvdata(pdev); struct da9052_bl *wleds = bl_get_data(bl); wleds->brightness = 0; wleds->state = DA9052_WLEDS_OFF; da9052_adjust_wled_brightness(wleds); return 0; } static const struct platform_device_id da9052_wled_ids[] = { { .name = "da9052-wled1", .driver_data = DA9052_TYPE_WLED1, }, { .name = "da9052-wled2", .driver_data = DA9052_TYPE_WLED2, }, { .name = "da9052-wled3", .driver_data = DA9052_TYPE_WLED3, }, { }, }; static struct platform_driver da9052_wled_driver = { .probe = da9052_backlight_probe, .remove = da9052_backlight_remove, .id_table = da9052_wled_ids, .driver = { .name = "da9052-wled", }, }; module_platform_driver(da9052_wled_driver); MODULE_AUTHOR("David Dajun Chen "); MODULE_DESCRIPTION("Backlight driver for DA9052 PMIC"); MODULE_LICENSE("GPL"); MODULE_ALIAS("platform:da9052-backlight"); option value='10'>10space:mode:
Diffstat (limited to 'include/dt-bindings/reset')
drm_agpsupport.h
3867logplain
-rw-r--r--drm_atomic.h14443logplain
-rw-r--r--drm_atomic_helper.h10607logplain
-rw-r--r--drm_auth.h2260logplain
-rw-r--r--drm_blend.h2700logplain
-rw-r--r--drm_bridge.h7977logplain
-rw-r--r--drm_cache.h1763logplain
-rw-r--r--drm_color_mgmt.h2166logplain
-rw-r--r--drm_connector.h28613logplain
-rw-r--r--drm_crtc.h28999logplain
-rw-r--r--drm_crtc_helper.h3301logplain
-rw-r--r--drm_debugfs_crc.h2670logplain
-rw-r--r--drm_displayid.h2850logplain
-rw-r--r--drm_dp_dual_mode_helper.h4532logplain
-rw-r--r--drm_dp_helper.h30638logplain
-rw-r--r--drm_dp_mst_helper.h16260logplain
-rw-r--r--drm_drv.h14861logplain
-rw-r--r--drm_edid.h14335logplain
-rw-r--r--drm_encoder.h8160logplain
-rw-r--r--drm_encoder_slave.h6583logplain
-rw-r--r--drm_fb_cma_helper.h1929logplain
-rw-r--r--drm_fb_helper.h15125logplain
-rw-r--r--drm_fixed.h4825logplain
-rw-r--r--drm_flip_work.h3071logplain
-rw-r--r--drm_fourcc.h2748logplain
-rw-r--r--drm_framebuffer.h9623logplain
-rw-r--r--drm_gem.h8052logplain
-rw-r--r--drm_gem_cma_helper.h2286logplain
-rw-r--r--drm_global.h2011logplain
-rw-r--r--drm_hashtab.h3139logplain
-rw-r--r--drm_irq.h6323logplain
-rw-r--r--drm_legacy.h6933logplain
-rw-r--r--drm_mem_util.h2468logplain
-rw-r--r--drm_mipi_dsi.h10327logplain
-rw-r--r--drm_mm.h11462logplain
-rw-r--r--drm_mode_config.h23728logplain
-rw-r--r--drm_mode_object.h4911logplain
-rw-r--r--drm_modes.h17078logplain
-rw-r--r--drm_modeset_helper.h1576logplain
-rw-r--r--drm_modeset_helper_vtables.h41180logplain
-rw-r--r--drm_modeset_lock.h4241logplain
-rw-r--r--drm_of.h2034logplain
-rw-r--r--drm_os_linux.h2230logplain
-rw-r--r--drm_panel.h7079logplain
-rw-r--r--drm_pciids.h68035logplain
-rw-r--r--drm_plane.h19435logplain
-rw-r--r--drm_plane_helper.h3186logplain
-rw-r--r--drm_print.h3232logplain
-rw-r--r--drm_property.h11460logplain
-rw-r--r--drm_rect.h5103logplain
-rw-r--r--drm_simple_kms_helper.h4090logplain
-rw-r--r--drm_sysfs.h300logplain
-rw-r--r--drm_vma_manager.h7840logplain
-rw-r--r--gma_drm.h1033logplain
d---------i2c109logplain