| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Based on drivers/video/omap/lcd_inn1510.c |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * LCD panel support for the Amstrad E3 (Delta) videophone. |
|---|
| 5 | 6 | * |
|---|
| 6 | 7 | * 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 | 8 | */ |
|---|
| 22 | 9 | |
|---|
| 23 | 10 | #include <linux/module.h> |
|---|
| 24 | 11 | #include <linux/platform_device.h> |
|---|
| 25 | 12 | #include <linux/io.h> |
|---|
| 26 | 13 | #include <linux/delay.h> |
|---|
| 14 | +#include <linux/gpio/consumer.h> |
|---|
| 27 | 15 | #include <linux/lcd.h> |
|---|
| 28 | | -#include <linux/gpio.h> |
|---|
| 29 | 16 | |
|---|
| 30 | 17 | #include <mach/hardware.h> |
|---|
| 31 | | -#include <mach/board-ams-delta.h> |
|---|
| 32 | 18 | |
|---|
| 33 | 19 | #include "omapfb.h" |
|---|
| 34 | 20 | |
|---|
| .. | .. |
|---|
| 41 | 27 | /* LCD class device section */ |
|---|
| 42 | 28 | |
|---|
| 43 | 29 | static int ams_delta_lcd; |
|---|
| 30 | +static struct gpio_desc *gpiod_vblen; |
|---|
| 31 | +static struct gpio_desc *gpiod_ndisp; |
|---|
| 44 | 32 | |
|---|
| 45 | 33 | static int ams_delta_lcd_set_power(struct lcd_device *dev, int power) |
|---|
| 46 | 34 | { |
|---|
| .. | .. |
|---|
| 99 | 87 | |
|---|
| 100 | 88 | /* omapfb panel section */ |
|---|
| 101 | 89 | |
|---|
| 102 | | -static 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 | | - |
|---|
| 115 | | -static 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 | | - |
|---|
| 121 | | -static void ams_delta_panel_cleanup(struct lcd_panel *panel) |
|---|
| 122 | | -{ |
|---|
| 123 | | - gpio_free_array(_gpios, ARRAY_SIZE(_gpios)); |
|---|
| 124 | | -} |
|---|
| 125 | | - |
|---|
| 126 | 90 | static int ams_delta_panel_enable(struct lcd_panel *panel) |
|---|
| 127 | 91 | { |
|---|
| 128 | | - gpio_set_value(AMS_DELTA_GPIO_PIN_LCD_NDISP, 1); |
|---|
| 129 | | - gpio_set_value(AMS_DELTA_GPIO_PIN_LCD_VBLEN, 1); |
|---|
| 92 | + gpiod_set_value(gpiod_ndisp, 1); |
|---|
| 93 | + gpiod_set_value(gpiod_vblen, 1); |
|---|
| 130 | 94 | return 0; |
|---|
| 131 | 95 | } |
|---|
| 132 | 96 | |
|---|
| 133 | 97 | static void ams_delta_panel_disable(struct lcd_panel *panel) |
|---|
| 134 | 98 | { |
|---|
| 135 | | - gpio_set_value(AMS_DELTA_GPIO_PIN_LCD_VBLEN, 0); |
|---|
| 136 | | - gpio_set_value(AMS_DELTA_GPIO_PIN_LCD_NDISP, 0); |
|---|
| 99 | + gpiod_set_value(gpiod_vblen, 0); |
|---|
| 100 | + gpiod_set_value(gpiod_ndisp, 0); |
|---|
| 137 | 101 | } |
|---|
| 138 | 102 | |
|---|
| 139 | 103 | static struct lcd_panel ams_delta_panel = { |
|---|
| .. | .. |
|---|
| 154 | 118 | .pcd = 0, |
|---|
| 155 | 119 | .acb = 37, |
|---|
| 156 | 120 | |
|---|
| 157 | | - .init = ams_delta_panel_init, |
|---|
| 158 | | - .cleanup = ams_delta_panel_cleanup, |
|---|
| 159 | 121 | .enable = ams_delta_panel_enable, |
|---|
| 160 | 122 | .disable = ams_delta_panel_disable, |
|---|
| 161 | 123 | }; |
|---|
| .. | .. |
|---|
| 166 | 128 | static int ams_delta_panel_probe(struct platform_device *pdev) |
|---|
| 167 | 129 | { |
|---|
| 168 | 130 | struct lcd_device *lcd_device = NULL; |
|---|
| 169 | | -#ifdef CONFIG_LCD_CLASS_DEVICE |
|---|
| 170 | 131 | int ret; |
|---|
| 171 | 132 | |
|---|
| 133 | + gpiod_vblen = devm_gpiod_get(&pdev->dev, "vblen", GPIOD_OUT_LOW); |
|---|
| 134 | + if (IS_ERR(gpiod_vblen)) { |
|---|
| 135 | + ret = PTR_ERR(gpiod_vblen); |
|---|
| 136 | + dev_err(&pdev->dev, "VBLEN GPIO request failed (%d)\n", ret); |
|---|
| 137 | + return ret; |
|---|
| 138 | + } |
|---|
| 139 | + |
|---|
| 140 | + gpiod_ndisp = devm_gpiod_get(&pdev->dev, "ndisp", GPIOD_OUT_LOW); |
|---|
| 141 | + if (IS_ERR(gpiod_ndisp)) { |
|---|
| 142 | + ret = PTR_ERR(gpiod_ndisp); |
|---|
| 143 | + dev_err(&pdev->dev, "NDISP GPIO request failed (%d)\n", ret); |
|---|
| 144 | + return ret; |
|---|
| 145 | + } |
|---|
| 146 | + |
|---|
| 147 | +#ifdef CONFIG_LCD_CLASS_DEVICE |
|---|
| 172 | 148 | lcd_device = lcd_device_register("omapfb", &pdev->dev, NULL, |
|---|
| 173 | 149 | &ams_delta_lcd_ops); |
|---|
| 174 | 150 | |
|---|