aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandre Belloni <alexandre.belloni@free-electrons.com>2014-05-28 19:20:16 -0400
committerNicolas Ferre <nicolas.ferre@atmel.com>2014-07-09 09:13:34 -0400
commitec38846ad59d7b780540afcec101b24139933195 (patch)
tree1279ea1224062da69953fc0140b658fc293261a2
parent67c2b145cd5e3f74a901164d04d9ae19b1462906 (diff)
backlight: atmel-pwm-bl: remove obsolete driver
The atmel-pwm-bl driver is now obsolete. It is not used by any mainlined boards and is replaced by the generic pwm_bl with the pawm-atmel driver using the generic PWM framework. Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> Acked-by: Hans-Christian Egtvedt <egtvedt@samfundet.no> Acked-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
-rw-r--r--drivers/video/backlight/Kconfig11
-rw-r--r--drivers/video/backlight/Makefile1
-rw-r--r--drivers/video/backlight/atmel-pwm-bl.c223
-rw-r--r--include/linux/atmel-pwm-bl.h43
4 files changed, 0 insertions, 278 deletions
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
index 5d449059a556..c3c18339b8cb 100644
--- a/drivers/video/backlight/Kconfig
+++ b/drivers/video/backlight/Kconfig
@@ -178,17 +178,6 @@ config BACKLIGHT_ATMEL_LCDC
178 If in doubt, it's safe to enable this option; it doesn't kick 178 If in doubt, it's safe to enable this option; it doesn't kick
179 in unless the board's description says it's wired that way. 179 in unless the board's description says it's wired that way.
180 180
181config BACKLIGHT_ATMEL_PWM
182 tristate "Atmel PWM backlight control"
183 depends on ATMEL_PWM
184 help
185 Say Y here if you want to use the PWM peripheral in Atmel AT91 and
186 AVR32 devices. This driver will need additional platform data to know
187 which PWM instance to use and how to configure it.
188
189 To compile this driver as a module, choose M here: the module will be
190 called atmel-pwm-bl.
191
192config BACKLIGHT_EP93XX 181config BACKLIGHT_EP93XX
193 tristate "Cirrus EP93xx Backlight Driver" 182 tristate "Cirrus EP93xx Backlight Driver"
194 depends on FB_EP93XX 183 depends on FB_EP93XX
diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile
index bb820024f346..351451dbb607 100644
--- a/drivers/video/backlight/Makefile
+++ b/drivers/video/backlight/Makefile
@@ -25,7 +25,6 @@ obj-$(CONFIG_BACKLIGHT_ADP8860) += adp8860_bl.o
25obj-$(CONFIG_BACKLIGHT_ADP8870) += adp8870_bl.o 25obj-$(CONFIG_BACKLIGHT_ADP8870) += adp8870_bl.o
26obj-$(CONFIG_BACKLIGHT_APPLE) += apple_bl.o 26obj-$(CONFIG_BACKLIGHT_APPLE) += apple_bl.o
27obj-$(CONFIG_BACKLIGHT_AS3711) += as3711_bl.o 27obj-$(CONFIG_BACKLIGHT_AS3711) += as3711_bl.o
28obj-$(CONFIG_BACKLIGHT_ATMEL_PWM) += atmel-pwm-bl.o
29obj-$(CONFIG_BACKLIGHT_BD6107) += bd6107.o 28obj-$(CONFIG_BACKLIGHT_BD6107) += bd6107.o
30obj-$(CONFIG_BACKLIGHT_CARILLO_RANCH) += cr_bllcd.o 29obj-$(CONFIG_BACKLIGHT_CARILLO_RANCH) += cr_bllcd.o
31obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += backlight.o 30obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += backlight.o
diff --git a/drivers/video/backlight/atmel-pwm-bl.c b/drivers/video/backlight/atmel-pwm-bl.c
deleted file mode 100644
index 261b1a4ec3d8..000000000000
--- a/drivers/video/backlight/atmel-pwm-bl.c
+++ /dev/null
@@ -1,223 +0,0 @@
1/*
2 * Copyright (C) 2008 Atmel Corporation
3 *
4 * Backlight driver using Atmel PWM peripheral.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published by
8 * the Free Software Foundation.
9 */
10#include <linux/init.h>
11#include <linux/kernel.h>
12#include <linux/module.h>
13#include <linux/platform_device.h>
14#include <linux/fb.h>
15#include <linux/gpio.h>
16#include <linux/backlight.h>
17#include <linux/atmel_pwm.h>
18#include <linux/atmel-pwm-bl.h>
19#include <linux/slab.h>
20
21struct atmel_pwm_bl {
22 const struct atmel_pwm_bl_platform_data *pdata;
23 struct backlight_device *bldev;
24 struct platform_device *pdev;
25 struct pwm_channel pwmc;
26 int gpio_on;
27};
28
29static void atmel_pwm_bl_set_gpio_on(struct atmel_pwm_bl *pwmbl, int on)
30{
31 if (!gpio_is_valid(pwmbl->gpio_on))
32 return;
33
34 gpio_set_value(pwmbl->gpio_on, on ^ pwmbl->pdata->on_active_low);
35}
36
37static int atmel_pwm_bl_set_intensity(struct backlight_device *bd)
38{
39 struct atmel_pwm_bl *pwmbl = bl_get_data(bd);
40 int intensity = bd->props.brightness;
41 int pwm_duty;
42
43 if (bd->props.power != FB_BLANK_UNBLANK)
44 intensity = 0;
45 if (bd->props.fb_blank != FB_BLANK_UNBLANK)
46 intensity = 0;
47
48 if (pwmbl->pdata->pwm_active_low)
49 pwm_duty = pwmbl->pdata->pwm_duty_min + intensity;
50 else
51 pwm_duty = pwmbl->pdata->pwm_duty_max - intensity;
52
53 if (pwm_duty > pwmbl->pdata->pwm_duty_max)
54 pwm_duty = pwmbl->pdata->pwm_duty_max;
55 if (pwm_duty < pwmbl->pdata->pwm_duty_min)
56 pwm_duty = pwmbl->pdata->pwm_duty_min;
57
58 if (!intensity) {
59 atmel_pwm_bl_set_gpio_on(pwmbl, 0);
60 pwm_channel_writel(&pwmbl->pwmc, PWM_CUPD, pwm_duty);
61 pwm_channel_disable(&pwmbl->pwmc);
62 } else {
63 pwm_channel_enable(&pwmbl->pwmc);
64 pwm_channel_writel(&pwmbl->pwmc, PWM_CUPD, pwm_duty);
65 atmel_pwm_bl_set_gpio_on(pwmbl, 1);
66 }
67
68 return 0;
69}
70
71static int atmel_pwm_bl_get_intensity(struct backlight_device *bd)
72{
73 struct atmel_pwm_bl *pwmbl = bl_get_data(bd);
74 u32 cdty;
75 u32 intensity;
76
77 cdty = pwm_channel_readl(&pwmbl->pwmc, PWM_CDTY);
78 if (pwmbl->pdata->pwm_active_low)
79 intensity = cdty - pwmbl->pdata->pwm_duty_min;
80 else
81 intensity = pwmbl->pdata->pwm_duty_max - cdty;
82
83 return intensity & 0xffff;
84}
85
86static int atmel_pwm_bl_init_pwm(struct atmel_pwm_bl *pwmbl)
87{
88 unsigned long pwm_rate = pwmbl->pwmc.mck;
89 unsigned long prescale = DIV_ROUND_UP(pwm_rate,
90 (pwmbl->pdata->pwm_frequency *
91 pwmbl->pdata->pwm_compare_max)) - 1;
92
93 /*
94 * Prescale must be power of two and maximum 0xf in size because of
95 * hardware limit. PWM speed will be:
96 * PWM module clock speed / (2 ^ prescale).
97 */
98 prescale = fls(prescale);
99 if (prescale > 0xf)
100 prescale = 0xf;
101
102 pwm_channel_writel(&pwmbl->pwmc, PWM_CMR, prescale);
103 pwm_channel_writel(&pwmbl->pwmc, PWM_CDTY,
104 pwmbl->pdata->pwm_duty_min +
105 pwmbl->bldev->props.brightness);
106 pwm_channel_writel(&pwmbl->pwmc, PWM_CPRD,
107 pwmbl->pdata->pwm_compare_max);
108
109 dev_info(&pwmbl->pdev->dev, "Atmel PWM backlight driver (%lu Hz)\n",
110 pwmbl->pwmc.mck / pwmbl->pdata->pwm_compare_max /
111 (1 << prescale));
112
113 return pwm_channel_enable(&pwmbl->pwmc);
114}
115
116static const struct backlight_ops atmel_pwm_bl_ops = {
117 .get_brightness = atmel_pwm_bl_get_intensity,
118 .update_status = atmel_pwm_bl_set_intensity,
119};
120
121static int atmel_pwm_bl_probe(struct platform_device *pdev)
122{
123 struct backlight_properties props;
124 const struct atmel_pwm_bl_platform_data *pdata;
125 struct backlight_device *bldev;
126 struct atmel_pwm_bl *pwmbl;
127 unsigned long flags;
128 int retval;
129
130 pdata = dev_get_platdata(&pdev->dev);
131 if (!pdata)
132 return -ENODEV;
133
134 if (pdata->pwm_compare_max < pdata->pwm_duty_max ||
135 pdata->pwm_duty_min > pdata->pwm_duty_max ||
136 pdata->pwm_frequency == 0)
137 return -EINVAL;
138
139 pwmbl = devm_kzalloc(&pdev->dev, sizeof(struct atmel_pwm_bl),
140 GFP_KERNEL);
141 if (!pwmbl)
142 return -ENOMEM;
143
144 pwmbl->pdev = pdev;
145 pwmbl->pdata = pdata;
146 pwmbl->gpio_on = pdata->gpio_on;
147
148 retval = pwm_channel_alloc(pdata->pwm_channel, &pwmbl->pwmc);
149 if (retval)
150 return retval;
151
152 if (gpio_is_valid(pwmbl->gpio_on)) {
153 /* Turn display off by default. */
154 if (pdata->on_active_low)
155 flags = GPIOF_OUT_INIT_HIGH;
156 else
157 flags = GPIOF_OUT_INIT_LOW;
158
159 retval = devm_gpio_request_one(&pdev->dev, pwmbl->gpio_on,
160 flags, "gpio_atmel_pwm_bl");
161 if (retval)
162 goto err_free_pwm;
163 }
164
165 memset(&props, 0, sizeof(struct backlight_properties));
166 props.type = BACKLIGHT_RAW;
167 props.max_brightness = pdata->pwm_duty_max - pdata->pwm_duty_min;
168 bldev = devm_backlight_device_register(&pdev->dev, "atmel-pwm-bl",
169 &pdev->dev, pwmbl, &atmel_pwm_bl_ops,
170 &props);
171 if (IS_ERR(bldev)) {
172 retval = PTR_ERR(bldev);
173 goto err_free_pwm;
174 }
175
176 pwmbl->bldev = bldev;
177
178 platform_set_drvdata(pdev, pwmbl);
179
180 /* Power up the backlight by default at middle intesity. */
181 bldev->props.power = FB_BLANK_UNBLANK;
182 bldev->props.brightness = bldev->props.max_brightness / 2;
183
184 retval = atmel_pwm_bl_init_pwm(pwmbl);
185 if (retval)
186 goto err_free_pwm;
187
188 atmel_pwm_bl_set_intensity(bldev);
189
190 return 0;
191
192err_free_pwm:
193 pwm_channel_free(&pwmbl->pwmc);
194
195 return retval;
196}
197
198static int atmel_pwm_bl_remove(struct platform_device *pdev)
199{
200 struct atmel_pwm_bl *pwmbl = platform_get_drvdata(pdev);
201
202 atmel_pwm_bl_set_gpio_on(pwmbl, 0);
203 pwm_channel_disable(&pwmbl->pwmc);
204 pwm_channel_free(&pwmbl->pwmc);
205
206 return 0;
207}
208
209static struct platform_driver atmel_pwm_bl_driver = {
210 .driver = {
211 .name = "atmel-pwm-bl",
212 },
213 /* REVISIT add suspend() and resume() */
214 .probe = atmel_pwm_bl_probe,
215 .remove = atmel_pwm_bl_remove,
216};
217
218module_platform_driver(atmel_pwm_bl_driver);
219
220MODULE_AUTHOR("Hans-Christian egtvedt <hans-christian.egtvedt@atmel.com>");
221MODULE_DESCRIPTION("Atmel PWM backlight driver");
222MODULE_LICENSE("GPL");
223MODULE_ALIAS("platform:atmel-pwm-bl");
diff --git a/include/linux/atmel-pwm-bl.h b/include/linux/atmel-pwm-bl.h
deleted file mode 100644
index 0153a47806c2..000000000000
--- a/include/linux/atmel-pwm-bl.h
+++ /dev/null
@@ -1,43 +0,0 @@
1/*
2 * Copyright (C) 2007 Atmel Corporation
3 *
4 * Driver for the AT32AP700X PS/2 controller (PSIF).
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation.
9 */
10
11#ifndef __INCLUDE_ATMEL_PWM_BL_H
12#define __INCLUDE_ATMEL_PWM_BL_H
13
14/**
15 * struct atmel_pwm_bl_platform_data
16 * @pwm_channel: which PWM channel in the PWM module to use.
17 * @pwm_frequency: PWM frequency to generate, the driver will try to be as
18 * close as the prescaler allows.
19 * @pwm_compare_max: value to use in the PWM channel compare register.
20 * @pwm_duty_max: maximum duty cycle value, must be less than or equal to
21 * pwm_compare_max.
22 * @pwm_duty_min: minimum duty cycle value, must be less than pwm_duty_max.
23 * @pwm_active_low: set to one if the low part of the PWM signal increases the
24 * brightness of the backlight.
25 * @gpio_on: GPIO line to control the backlight on/off, set to -1 if not used.
26 * @on_active_low: set to one if the on/off signal is on when GPIO is low.
27 *
28 * This struct must be added to the platform device in the board code. It is
29 * used by the atmel-pwm-bl driver to setup the GPIO to control on/off and the
30 * PWM device.
31 */
32struct atmel_pwm_bl_platform_data {
33 unsigned int pwm_channel;
34 unsigned int pwm_frequency;
35 unsigned int pwm_compare_max;
36 unsigned int pwm_duty_max;
37 unsigned int pwm_duty_min;
38 unsigned int pwm_active_low;
39 int gpio_on;
40 unsigned int on_active_low;
41};
42
43#endif /* __INCLUDE_ATMEL_PWM_BL_H */