/* * Backlight driver for Dialog Semiconductor DA9030/DA9034 * * Copyright (C) 2008 Compulab, Ltd. * Mike Rapoport * * Copyright (C) 2006-2008 Marvell International Ltd. * Eric Miao * * 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 #include #include #include #include #include #include #include #define DA9030_WLED_CONTROL 0x25 #define DA9030_WLED_CP_EN (1 << 6) #define DA9030_WLED_TRIM(x) ((x) & 0x7) #define DA9034_WLED_CONTROL1 0x3C #define DA9034_WLED_CONTROL2 0x3D #define DA9034_WLED_ISET(x) ((x) & 0x1f) #define DA9034_WLED_BOOST_EN (1 << 5) #define DA9030_MAX_BRIGHTNESS 7 #define DA9034_MAX_BRIGHTNESS 0x7f struct da903x_backlight_data { struct device *da903x_dev; int id; int current_brightness; }; static int da903x_backlight_set(struct backlight_device *bl, int brightness) { struct da903x_backlight_data *data = bl_get_data(bl); struct device *dev = data->da903x_dev; uint8_t val; int ret = 0; switch (data->id) { case DA9034_ID_WLED: ret = da903x_update(dev, DA9034_WLED_CONTROL1, brightness, 0x7f); if (ret) return ret; if (data->current_brightness && brightness == 0) ret = da903x_clr_bits(dev, DA9034_WLED_CONTROL2, DA9034_WLED_BOOST_EN); if (data->current_brightness == 0 && brightness) ret = da903x_set_bits(dev, DA9034_WLED_CONTROL2, DA9034_WLED_BOOST_EN); break; case DA9030_ID_WLED: val = DA9030_WLED_TRIM(brightness); val |= brightness ? DA9030_WLED_CP_EN : 0; ret = da903x_write(dev, DA9030_WLED_CONTROL, val); break; } if (ret) return ret; data->current_brightness = brightness; return 0; } static int da903x_backlight_update_status(struct backlight_device *bl) { int brightness = bl->props.brightness; if (bl->props.power != FB_BLANK_UNBLANK) brightness = 0; if (bl->props.fb_blank != FB_BLANK_UNBLANK) brightness = 0; if (bl->props.state & BL_CORE_SUSPENDED) brightness = 0; return da903x_backlight_set(bl, brightness); } static int da903x_backlight_get_brightness(struct backlight_device *bl) { struct da903x_backlight_data *data = bl_get_data(bl); return data->current_brightness; } static const struct backlight_ops da903x_backlight_ops = { .options = BL_CORE_SUSPENDRESUME, .update_status = da903x_backlight_update_status, .get_brightness = da903x_backlight_get_brightness, }; static int da903x_backlight_probe(struct platform_device *pdev) { struct da9034_backlight_pdata *pdata = dev_get_platdata(&pdev->dev); struct da903x_backlight_data *data; struct backlight_device *bl; struct backlight_properties props; int max_brightness; data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); if (data == NULL) return -ENOMEM; switch (pdev->id) { case DA9030_ID_WLED: max_brightness = DA9030_MAX_BRIGHTNESS; break; case DA9034_ID_WLED: max_brightness = DA9034_MAX_BRIGHTNESS; break; default: dev_err(&pdev->dev, "invalid backlight device ID(%d)\n", pdev->id); return -EINVAL; } data->id = pdev->id; data->da903x_dev = pdev->dev.parent; data->current_brightness = 0; /* adjust the WLED output current */ if (pdata) da903x_write(data->da903x_dev, DA9034_WLED_CONTROL2, DA9034_WLED_ISET(pdata->output_current)); memset(&props, 0, sizeof(props)); props.type = BACKLIGHT_RAW; props.max_brightness = max_brightness; bl = devm_backlight_device_register(&pdev->dev, pdev->name, data->da903x_dev, data, &da903x_backlight_ops, &props); if (IS_ERR(bl)) { dev_err(&pdev->dev, "failed to register backlight\n"); return PTR_ERR(bl); } bl->props.brightness = max_brightness; platform_set_drvdata(pdev, bl); backlight_update_status(bl); return 0; } static struct platform_driver da903x_backlight_driver = { .driver = { .name = "da903x-backlight", }, .probe = da903x_backlight_probe, }; module_platform_driver(da903x_backlight_driver); MODULE_DESCRIPTION("Backlight Driver for Dialog Semiconductor DA9030/DA9034"); MODULE_AUTHOR("Eric Miao "); MODULE_AUTHOR("Mike Rapoport "); MODULE_LICENSE("GPL"); MODULE_ALIAS("platform:da903x-backlight"); alue='30'>30space:mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-02-06 19:36:04 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2017-02-06 19:36:04 -0800
commit8b1b41ee74f9712c355d66dc105bbea663ae0afd (patch)
tree4c3f410f3cb01c7b00b474e376a60f27a7ff99a8 /drivers/usb/chipidea/udc.c
parentf7d6040aa45df6ffd9e891114125dc919f18b96b (diff)
parentbfb34527a32a1a576d9bfb7026d3ab0369a6cd60 (diff)
Merge branch 'libnvdimm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm
Pull libnvdimm fixes from Dan Williams: "None of these are showstoppers for 4.10 and could wait for 4.11 merge window, but they are low enough risk for this late in the cycle and the fixes have waiting users . They have received a build success notification from the 0day robot, pass the latest ndctl unit tests, and appeared in next: - Fix a crash that can result when SIGINT is sent to a process that is awaiting completion of an address range scrub command. We were not properly cleaning up the workqueue after wait_event_interruptible(). - Fix a memory hotplug failure condition that results from not reserving enough space out of persistent memory for the memmap. By default we align to 2M allocations that the memory hotplug code assumes, but if the administrator specifies a non-default 4K-alignment then we can fail to correctly size the reservation. - A one line fix to improve the predictability of libnvdimm block device names. A common operation is to reconfigure /dev/pmem0 into a different mode. For example, a reconfiguration might set a new mode that reserves some of the capacity for a struct page memmap array. It surprises users if the device name changes to "/dev/pmem0.1" after the mode change and then back to /dev/pmem0 after a reboot. - Add 'const' to some function pointer tables" * 'libnvdimm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm: libnvdimm, pfn: fix memmap reservation size versus 4K alignment acpi, nfit: fix acpi_nfit_flush_probe() crash libnvdimm, namespace: do not delete namespace-id 0 nvdimm: constify device_type structures
Diffstat (limited to 'drivers/usb/chipidea/udc.c')