~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/arm/mach-s3c64xx/dev-backlight.c

Version: ~ [ linux-4.20-rc2 ] ~ [ linux-4.19.1 ] ~ [ linux-4.18.18 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.80 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.136 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.163 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.125 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.60 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.39.4 ] ~ [ linux-2.6.38.8 ] ~ [ linux-2.6.37.6 ] ~ [ linux-2.6.36.4 ] ~ [ linux-2.6.35.14 ] ~ [ linux-2.6.34.15 ] ~ [ linux-2.6.33.20 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.31.14 ] ~ [ linux-2.6.30.10 ] ~ [ linux-2.6.29.6 ] ~ [ linux-2.6.28.10 ] ~ [ linux-2.6.27.62 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 //
  3 // Copyright (c) 2011 Samsung Electronics Co., Ltd.
  4 //              http://www.samsung.com
  5 //
  6 // Common infrastructure for PWM Backlight for Samsung boards
  7 
  8 #include <linux/gpio.h>
  9 #include <linux/platform_device.h>
 10 #include <linux/slab.h>
 11 #include <linux/io.h>
 12 #include <linux/pwm_backlight.h>
 13 
 14 #include <plat/devs.h>
 15 #include <plat/gpio-cfg.h>
 16 
 17 #include "backlight.h"
 18 
 19 struct samsung_bl_drvdata {
 20         struct platform_pwm_backlight_data plat_data;
 21         struct samsung_bl_gpio_info *gpio_info;
 22 };
 23 
 24 static int samsung_bl_init(struct device *dev)
 25 {
 26         int ret = 0;
 27         struct platform_pwm_backlight_data *pdata = dev->platform_data;
 28         struct samsung_bl_drvdata *drvdata = container_of(pdata,
 29                                         struct samsung_bl_drvdata, plat_data);
 30         struct samsung_bl_gpio_info *bl_gpio_info = drvdata->gpio_info;
 31 
 32         ret = gpio_request(bl_gpio_info->no, "Backlight");
 33         if (ret) {
 34                 printk(KERN_ERR "failed to request GPIO for LCD Backlight\n");
 35                 return ret;
 36         }
 37 
 38         /* Configure GPIO pin with specific GPIO function for PWM timer */
 39         s3c_gpio_cfgpin(bl_gpio_info->no, bl_gpio_info->func);
 40 
 41         return 0;
 42 }
 43 
 44 static void samsung_bl_exit(struct device *dev)
 45 {
 46         struct platform_pwm_backlight_data *pdata = dev->platform_data;
 47         struct samsung_bl_drvdata *drvdata = container_of(pdata,
 48                                         struct samsung_bl_drvdata, plat_data);
 49         struct samsung_bl_gpio_info *bl_gpio_info = drvdata->gpio_info;
 50 
 51         s3c_gpio_cfgpin(bl_gpio_info->no, S3C_GPIO_OUTPUT);
 52         gpio_free(bl_gpio_info->no);
 53 }
 54 
 55 /* Initialize few important fields of platform_pwm_backlight_data
 56  * structure with default values. These fields can be overridden by
 57  * board-specific values sent from machine file.
 58  * For ease of operation, these fields are initialized with values
 59  * used by most samsung boards.
 60  * Users has the option of sending info about other parameters
 61  * for their specific boards
 62  */
 63 
 64 static struct samsung_bl_drvdata samsung_dfl_bl_data __initdata = {
 65         .plat_data = {
 66                 .max_brightness = 255,
 67                 .dft_brightness = 255,
 68                 .enable_gpio    = -1,
 69                 .init           = samsung_bl_init,
 70                 .exit           = samsung_bl_exit,
 71         },
 72 };
 73 
 74 static struct platform_device samsung_dfl_bl_device __initdata = {
 75         .name           = "pwm-backlight",
 76 };
 77 
 78 /* samsung_bl_set - Set board specific data (if any) provided by user for
 79  * PWM Backlight control and register specific PWM and backlight device.
 80  * @gpio_info:  structure containing GPIO info for PWM timer
 81  * @bl_data:    structure containing Backlight control data
 82  */
 83 void __init samsung_bl_set(struct samsung_bl_gpio_info *gpio_info,
 84         struct platform_pwm_backlight_data *bl_data)
 85 {
 86         int ret = 0;
 87         struct platform_device *samsung_bl_device;
 88         struct samsung_bl_drvdata *samsung_bl_drvdata;
 89         struct platform_pwm_backlight_data *samsung_bl_data;
 90 
 91         samsung_bl_device = kmemdup(&samsung_dfl_bl_device,
 92                         sizeof(struct platform_device), GFP_KERNEL);
 93         if (!samsung_bl_device)
 94                 return;
 95 
 96         samsung_bl_drvdata = kmemdup(&samsung_dfl_bl_data,
 97                                 sizeof(samsung_dfl_bl_data), GFP_KERNEL);
 98         if (!samsung_bl_drvdata)
 99                 goto err_data;
100 
101         samsung_bl_device->dev.platform_data = &samsung_bl_drvdata->plat_data;
102         samsung_bl_drvdata->gpio_info = gpio_info;
103         samsung_bl_data = &samsung_bl_drvdata->plat_data;
104 
105         /* Copy board specific data provided by user */
106         samsung_bl_device->dev.parent = &samsung_device_pwm.dev;
107 
108         if (bl_data->max_brightness)
109                 samsung_bl_data->max_brightness = bl_data->max_brightness;
110         if (bl_data->dft_brightness)
111                 samsung_bl_data->dft_brightness = bl_data->dft_brightness;
112         if (bl_data->lth_brightness)
113                 samsung_bl_data->lth_brightness = bl_data->lth_brightness;
114         if (bl_data->enable_gpio >= 0)
115                 samsung_bl_data->enable_gpio = bl_data->enable_gpio;
116         if (bl_data->init)
117                 samsung_bl_data->init = bl_data->init;
118         if (bl_data->notify)
119                 samsung_bl_data->notify = bl_data->notify;
120         if (bl_data->notify_after)
121                 samsung_bl_data->notify_after = bl_data->notify_after;
122         if (bl_data->exit)
123                 samsung_bl_data->exit = bl_data->exit;
124         if (bl_data->check_fb)
125                 samsung_bl_data->check_fb = bl_data->check_fb;
126 
127         /* Register the Backlight dev */
128         ret = platform_device_register(samsung_bl_device);
129         if (ret) {
130                 printk(KERN_ERR "failed to register backlight device: %d\n", ret);
131                 goto err_plat_reg2;
132         }
133 
134         return;
135 
136 err_plat_reg2:
137         kfree(samsung_bl_data);
138 err_data:
139         kfree(samsung_bl_device);
140 }
141 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp