Linux Audio

Check our new training course

Loading...
v4.10.11
 
  1/*
  2 * Based on drivers/video/omap/lcd_inn1510.c
  3 *
  4 * LCD panel support for the Amstrad E3 (Delta) videophone.
  5 *
  6 * Copyright (C) 2006 Jonathan McDowell <noodles@earth.li>
  7 *
  8 * This program is free software; you can redistribute it and/or modify it
  9 * under the terms of the GNU General Public License as published by the
 10 * Free Software Foundation; either version 2 of the License, or (at your
 11 * option) any later version.
 12 *
 13 * This program is distributed in the hope that it will be useful, but
 14 * WITHOUT ANY WARRANTY; without even the implied warranty of
 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 16 * General Public License for more details.
 17 *
 18 * You should have received a copy of the GNU General Public License along
 19 * with this program; if not, write to the Free Software Foundation, Inc.,
 20 * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 21 */
 22
 23#include <linux/module.h>
 24#include <linux/platform_device.h>
 25#include <linux/io.h>
 26#include <linux/delay.h>
 
 27#include <linux/lcd.h>
 28#include <linux/gpio.h>
 29
 30#include <mach/hardware.h>
 31#include <mach/board-ams-delta.h>
 32
 33#include "omapfb.h"
 34
 35#define AMS_DELTA_DEFAULT_CONTRAST	112
 36
 37#define AMS_DELTA_MAX_CONTRAST		0x00FF
 38#define AMS_DELTA_LCD_POWER		0x0100
 39
 40
 41/* LCD class device section */
 42
 43static int ams_delta_lcd;
 
 
 44
 45static int ams_delta_lcd_set_power(struct lcd_device *dev, int power)
 46{
 47	if (power == FB_BLANK_UNBLANK) {
 48		if (!(ams_delta_lcd & AMS_DELTA_LCD_POWER)) {
 49			omap_writeb(ams_delta_lcd & AMS_DELTA_MAX_CONTRAST,
 50					OMAP_PWL_ENABLE);
 51			omap_writeb(1, OMAP_PWL_CLK_ENABLE);
 52			ams_delta_lcd |= AMS_DELTA_LCD_POWER;
 53		}
 54	} else {
 55		if (ams_delta_lcd & AMS_DELTA_LCD_POWER) {
 56			omap_writeb(0, OMAP_PWL_ENABLE);
 57			omap_writeb(0, OMAP_PWL_CLK_ENABLE);
 58			ams_delta_lcd &= ~AMS_DELTA_LCD_POWER;
 59		}
 60	}
 61	return 0;
 62}
 63
 64static int ams_delta_lcd_set_contrast(struct lcd_device *dev, int value)
 65{
 66	if ((value >= 0) && (value <= AMS_DELTA_MAX_CONTRAST)) {
 67		omap_writeb(value, OMAP_PWL_ENABLE);
 68		ams_delta_lcd &= ~AMS_DELTA_MAX_CONTRAST;
 69		ams_delta_lcd |= value;
 70	}
 71	return 0;
 72}
 73
 74#ifdef CONFIG_LCD_CLASS_DEVICE
 75static int ams_delta_lcd_get_power(struct lcd_device *dev)
 76{
 77	if (ams_delta_lcd & AMS_DELTA_LCD_POWER)
 78		return FB_BLANK_UNBLANK;
 79	else
 80		return FB_BLANK_POWERDOWN;
 81}
 82
 83static int ams_delta_lcd_get_contrast(struct lcd_device *dev)
 84{
 85	if (!(ams_delta_lcd & AMS_DELTA_LCD_POWER))
 86		return 0;
 87
 88	return ams_delta_lcd & AMS_DELTA_MAX_CONTRAST;
 89}
 90
 91static struct lcd_ops ams_delta_lcd_ops = {
 92	.get_power = ams_delta_lcd_get_power,
 93	.set_power = ams_delta_lcd_set_power,
 94	.get_contrast = ams_delta_lcd_get_contrast,
 95	.set_contrast = ams_delta_lcd_set_contrast,
 96};
 97#endif
 98
 99
100/* omapfb panel section */
101
102static const struct gpio _gpios[] = {
103	{
104		.gpio	= AMS_DELTA_GPIO_PIN_LCD_VBLEN,
105		.flags	= GPIOF_OUT_INIT_LOW,
106		.label	= "lcd_vblen",
107	},
108	{
109		.gpio	= AMS_DELTA_GPIO_PIN_LCD_NDISP,
110		.flags	= GPIOF_OUT_INIT_LOW,
111		.label	= "lcd_ndisp",
112	},
113};
114
115static int ams_delta_panel_init(struct lcd_panel *panel,
116		struct omapfb_device *fbdev)
117{
118	return gpio_request_array(_gpios, ARRAY_SIZE(_gpios));
119}
120
121static void ams_delta_panel_cleanup(struct lcd_panel *panel)
122{
123	gpio_free_array(_gpios, ARRAY_SIZE(_gpios));
124}
125
126static int ams_delta_panel_enable(struct lcd_panel *panel)
127{
128	gpio_set_value(AMS_DELTA_GPIO_PIN_LCD_NDISP, 1);
129	gpio_set_value(AMS_DELTA_GPIO_PIN_LCD_VBLEN, 1);
130	return 0;
131}
132
133static void ams_delta_panel_disable(struct lcd_panel *panel)
134{
135	gpio_set_value(AMS_DELTA_GPIO_PIN_LCD_VBLEN, 0);
136	gpio_set_value(AMS_DELTA_GPIO_PIN_LCD_NDISP, 0);
137}
138
139static unsigned long ams_delta_panel_get_caps(struct lcd_panel *panel)
140{
141	return 0;
142}
143
144static struct lcd_panel ams_delta_panel = {
145	.name		= "ams-delta",
146	.config		= 0,
147
148	.bpp		= 12,
149	.data_lines	= 16,
150	.x_res		= 480,
151	.y_res		= 320,
152	.pixel_clock	= 4687,
153	.hsw		= 3,
154	.hfp		= 1,
155	.hbp		= 1,
156	.vsw		= 1,
157	.vfp		= 0,
158	.vbp		= 0,
159	.pcd		= 0,
160	.acb		= 37,
161
162	.init		= ams_delta_panel_init,
163	.cleanup	= ams_delta_panel_cleanup,
164	.enable		= ams_delta_panel_enable,
165	.disable	= ams_delta_panel_disable,
166	.get_caps	= ams_delta_panel_get_caps,
167};
168
169
170/* platform driver section */
171
172static int ams_delta_panel_probe(struct platform_device *pdev)
173{
174	struct lcd_device *lcd_device = NULL;
175#ifdef CONFIG_LCD_CLASS_DEVICE
176	int ret;
177
 
 
 
 
 
 
 
 
 
 
 
178	lcd_device = lcd_device_register("omapfb", &pdev->dev, NULL,
179						&ams_delta_lcd_ops);
180
181	if (IS_ERR(lcd_device)) {
182		ret = PTR_ERR(lcd_device);
 
183		dev_err(&pdev->dev, "failed to register device\n");
184		return ret;
185	}
186
187	platform_set_drvdata(pdev, lcd_device);
188	lcd_device->props.max_contrast = AMS_DELTA_MAX_CONTRAST;
189#endif
190
191	ams_delta_lcd_set_contrast(lcd_device, AMS_DELTA_DEFAULT_CONTRAST);
192	ams_delta_lcd_set_power(lcd_device, FB_BLANK_UNBLANK);
193
194	omapfb_register_panel(&ams_delta_panel);
195	return 0;
196}
197
198static int ams_delta_panel_remove(struct platform_device *pdev)
199{
200	return 0;
201}
202
203static int ams_delta_panel_suspend(struct platform_device *pdev,
204		pm_message_t mesg)
205{
206	return 0;
207}
208
209static int ams_delta_panel_resume(struct platform_device *pdev)
210{
211	return 0;
212}
213
214static struct platform_driver ams_delta_panel_driver = {
215	.probe		= ams_delta_panel_probe,
216	.remove		= ams_delta_panel_remove,
217	.suspend	= ams_delta_panel_suspend,
218	.resume		= ams_delta_panel_resume,
219	.driver		= {
220		.name	= "lcd_ams_delta",
221	},
222};
223
224module_platform_driver(ams_delta_panel_driver);
v6.2
  1// SPDX-License-Identifier: GPL-2.0-or-later
  2/*
  3 * Based on drivers/video/omap/lcd_inn1510.c
  4 *
  5 * LCD panel support for the Amstrad E3 (Delta) videophone.
  6 *
  7 * Copyright (C) 2006 Jonathan McDowell <noodles@earth.li>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  8 */
  9
 10#include <linux/module.h>
 11#include <linux/platform_device.h>
 12#include <linux/io.h>
 13#include <linux/delay.h>
 14#include <linux/gpio/consumer.h>
 15#include <linux/lcd.h>
 
 16
 17#include <linux/soc/ti/omap1-io.h>
 
 18
 19#include "omapfb.h"
 20
 21#define AMS_DELTA_DEFAULT_CONTRAST	112
 22
 23#define AMS_DELTA_MAX_CONTRAST		0x00FF
 24#define AMS_DELTA_LCD_POWER		0x0100
 25
 26
 27/* LCD class device section */
 28
 29static int ams_delta_lcd;
 30static struct gpio_desc *gpiod_vblen;
 31static struct gpio_desc *gpiod_ndisp;
 32
 33static int ams_delta_lcd_set_power(struct lcd_device *dev, int power)
 34{
 35	if (power == FB_BLANK_UNBLANK) {
 36		if (!(ams_delta_lcd & AMS_DELTA_LCD_POWER)) {
 37			omap_writeb(ams_delta_lcd & AMS_DELTA_MAX_CONTRAST,
 38					OMAP_PWL_ENABLE);
 39			omap_writeb(1, OMAP_PWL_CLK_ENABLE);
 40			ams_delta_lcd |= AMS_DELTA_LCD_POWER;
 41		}
 42	} else {
 43		if (ams_delta_lcd & AMS_DELTA_LCD_POWER) {
 44			omap_writeb(0, OMAP_PWL_ENABLE);
 45			omap_writeb(0, OMAP_PWL_CLK_ENABLE);
 46			ams_delta_lcd &= ~AMS_DELTA_LCD_POWER;
 47		}
 48	}
 49	return 0;
 50}
 51
 52static int ams_delta_lcd_set_contrast(struct lcd_device *dev, int value)
 53{
 54	if ((value >= 0) && (value <= AMS_DELTA_MAX_CONTRAST)) {
 55		omap_writeb(value, OMAP_PWL_ENABLE);
 56		ams_delta_lcd &= ~AMS_DELTA_MAX_CONTRAST;
 57		ams_delta_lcd |= value;
 58	}
 59	return 0;
 60}
 61
 62#ifdef CONFIG_LCD_CLASS_DEVICE
 63static int ams_delta_lcd_get_power(struct lcd_device *dev)
 64{
 65	if (ams_delta_lcd & AMS_DELTA_LCD_POWER)
 66		return FB_BLANK_UNBLANK;
 67	else
 68		return FB_BLANK_POWERDOWN;
 69}
 70
 71static int ams_delta_lcd_get_contrast(struct lcd_device *dev)
 72{
 73	if (!(ams_delta_lcd & AMS_DELTA_LCD_POWER))
 74		return 0;
 75
 76	return ams_delta_lcd & AMS_DELTA_MAX_CONTRAST;
 77}
 78
 79static struct lcd_ops ams_delta_lcd_ops = {
 80	.get_power = ams_delta_lcd_get_power,
 81	.set_power = ams_delta_lcd_set_power,
 82	.get_contrast = ams_delta_lcd_get_contrast,
 83	.set_contrast = ams_delta_lcd_set_contrast,
 84};
 85#endif
 86
 87
 88/* omapfb panel section */
 89
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 90static int ams_delta_panel_enable(struct lcd_panel *panel)
 91{
 92	gpiod_set_value(gpiod_ndisp, 1);
 93	gpiod_set_value(gpiod_vblen, 1);
 94	return 0;
 95}
 96
 97static void ams_delta_panel_disable(struct lcd_panel *panel)
 98{
 99	gpiod_set_value(gpiod_vblen, 0);
100	gpiod_set_value(gpiod_ndisp, 0);
 
 
 
 
 
101}
102
103static struct lcd_panel ams_delta_panel = {
104	.name		= "ams-delta",
105	.config		= 0,
106
107	.bpp		= 12,
108	.data_lines	= 16,
109	.x_res		= 480,
110	.y_res		= 320,
111	.pixel_clock	= 4687,
112	.hsw		= 3,
113	.hfp		= 1,
114	.hbp		= 1,
115	.vsw		= 1,
116	.vfp		= 0,
117	.vbp		= 0,
118	.pcd		= 0,
119	.acb		= 37,
120
 
 
121	.enable		= ams_delta_panel_enable,
122	.disable	= ams_delta_panel_disable,
 
123};
124
125
126/* platform driver section */
127
128static int ams_delta_panel_probe(struct platform_device *pdev)
129{
130	struct lcd_device *lcd_device = NULL;
 
 
131
132	gpiod_vblen = devm_gpiod_get(&pdev->dev, "vblen", GPIOD_OUT_LOW);
133	if (IS_ERR(gpiod_vblen))
134		return dev_err_probe(&pdev->dev, PTR_ERR(gpiod_vblen),
135				     "VBLEN GPIO request failed\n");
136
137	gpiod_ndisp = devm_gpiod_get(&pdev->dev, "ndisp", GPIOD_OUT_LOW);
138	if (IS_ERR(gpiod_ndisp))
139		return dev_err_probe(&pdev->dev, PTR_ERR(gpiod_ndisp),
140				     "NDISP GPIO request failed\n");
141
142#ifdef CONFIG_LCD_CLASS_DEVICE
143	lcd_device = lcd_device_register("omapfb", &pdev->dev, NULL,
144						&ams_delta_lcd_ops);
145
146	if (IS_ERR(lcd_device)) {
147		int ret = PTR_ERR(lcd_device);
148
149		dev_err(&pdev->dev, "failed to register device\n");
150		return ret;
151	}
152
153	platform_set_drvdata(pdev, lcd_device);
154	lcd_device->props.max_contrast = AMS_DELTA_MAX_CONTRAST;
155#endif
156
157	ams_delta_lcd_set_contrast(lcd_device, AMS_DELTA_DEFAULT_CONTRAST);
158	ams_delta_lcd_set_power(lcd_device, FB_BLANK_UNBLANK);
159
160	omapfb_register_panel(&ams_delta_panel);
161	return 0;
162}
163
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164static struct platform_driver ams_delta_panel_driver = {
165	.probe		= ams_delta_panel_probe,
 
 
 
166	.driver		= {
167		.name	= "lcd_ams_delta",
168	},
169};
170
171module_platform_driver(ams_delta_panel_driver);
172
173MODULE_AUTHOR("Jonathan McDowell <noodles@earth.li>");
174MODULE_DESCRIPTION("LCD panel support for the Amstrad E3 (Delta) videophone");
175MODULE_LICENSE("GPL");