Lines Matching +full:- +full:spi

1 // SPDX-License-Identifier: GPL-2.0-only
3 * l4f00242t03.c -- support for Epson L4F00242T03 LCD
5 * Copyright 2007-2009 Freescale Semiconductor, Inc. All Rights Reserved.
21 #include <linux/spi/spi.h>
24 struct spi_device *spi; member
46 static void l4f00242t03_lcd_init(struct spi_device *spi) in l4f00242t03_lcd_init() argument
48 struct l4f00242t03_priv *priv = spi_get_drvdata(spi); in l4f00242t03_lcd_init()
52 dev_dbg(&spi->dev, "initializing LCD\n"); in l4f00242t03_lcd_init()
54 ret = regulator_set_voltage(priv->io_reg, 1800000, 1800000); in l4f00242t03_lcd_init()
56 dev_err(&spi->dev, "failed to set the IO regulator voltage.\n"); in l4f00242t03_lcd_init()
59 ret = regulator_enable(priv->io_reg); in l4f00242t03_lcd_init()
61 dev_err(&spi->dev, "failed to enable the IO regulator.\n"); in l4f00242t03_lcd_init()
65 ret = regulator_set_voltage(priv->core_reg, 2800000, 2800000); in l4f00242t03_lcd_init()
67 dev_err(&spi->dev, "failed to set the core regulator voltage.\n"); in l4f00242t03_lcd_init()
68 regulator_disable(priv->io_reg); in l4f00242t03_lcd_init()
71 ret = regulator_enable(priv->core_reg); in l4f00242t03_lcd_init()
73 dev_err(&spi->dev, "failed to enable the core regulator.\n"); in l4f00242t03_lcd_init()
74 regulator_disable(priv->io_reg); in l4f00242t03_lcd_init()
78 l4f00242t03_reset(priv->reset); in l4f00242t03_lcd_init()
80 gpiod_set_value(priv->enable, 1); in l4f00242t03_lcd_init()
82 spi_write(spi, (const u8 *)cmd, ARRAY_SIZE(cmd) * sizeof(u16)); in l4f00242t03_lcd_init()
85 static void l4f00242t03_lcd_powerdown(struct spi_device *spi) in l4f00242t03_lcd_powerdown() argument
87 struct l4f00242t03_priv *priv = spi_get_drvdata(spi); in l4f00242t03_lcd_powerdown()
89 dev_dbg(&spi->dev, "Powering down LCD\n"); in l4f00242t03_lcd_powerdown()
91 gpiod_set_value(priv->enable, 0); in l4f00242t03_lcd_powerdown()
93 regulator_disable(priv->io_reg); in l4f00242t03_lcd_powerdown()
94 regulator_disable(priv->core_reg); in l4f00242t03_lcd_powerdown()
101 return priv->lcd_state; in l4f00242t03_lcd_power_get()
107 struct spi_device *spi = priv->spi; in l4f00242t03_lcd_power_set() local
116 if (priv->lcd_state <= FB_BLANK_NORMAL) { in l4f00242t03_lcd_power_set()
118 } else if (priv->lcd_state < FB_BLANK_POWERDOWN) { in l4f00242t03_lcd_power_set()
119 dev_dbg(&spi->dev, "Resuming LCD\n"); in l4f00242t03_lcd_power_set()
121 spi_write(spi, (const u8 *)&slpout, sizeof(u16)); in l4f00242t03_lcd_power_set()
123 spi_write(spi, (const u8 *)&dison, sizeof(u16)); in l4f00242t03_lcd_power_set()
125 /* priv->lcd_state == FB_BLANK_POWERDOWN */ in l4f00242t03_lcd_power_set()
126 l4f00242t03_lcd_init(spi); in l4f00242t03_lcd_power_set()
127 priv->lcd_state = FB_BLANK_VSYNC_SUSPEND; in l4f00242t03_lcd_power_set()
128 l4f00242t03_lcd_power_set(priv->ld, power); in l4f00242t03_lcd_power_set()
131 if (priv->lcd_state <= FB_BLANK_NORMAL) { in l4f00242t03_lcd_power_set()
133 dev_dbg(&spi->dev, "Standby the LCD\n"); in l4f00242t03_lcd_power_set()
135 spi_write(spi, (const u8 *)&disoff, sizeof(u16)); in l4f00242t03_lcd_power_set()
137 spi_write(spi, (const u8 *)&slpin, sizeof(u16)); in l4f00242t03_lcd_power_set()
138 } else if (priv->lcd_state < FB_BLANK_POWERDOWN) { in l4f00242t03_lcd_power_set()
141 /* priv->lcd_state == FB_BLANK_POWERDOWN */ in l4f00242t03_lcd_power_set()
142 l4f00242t03_lcd_init(spi); in l4f00242t03_lcd_power_set()
143 priv->lcd_state = FB_BLANK_UNBLANK; in l4f00242t03_lcd_power_set()
148 if (priv->lcd_state != FB_BLANK_POWERDOWN) { in l4f00242t03_lcd_power_set()
150 spi_write(spi, (const u8 *)&disoff, sizeof(u16)); in l4f00242t03_lcd_power_set()
152 l4f00242t03_lcd_powerdown(spi); in l4f00242t03_lcd_power_set()
156 priv->lcd_state = power; in l4f00242t03_lcd_power_set()
166 static int l4f00242t03_probe(struct spi_device *spi) in l4f00242t03_probe() argument
171 priv = devm_kzalloc(&spi->dev, sizeof(struct l4f00242t03_priv), in l4f00242t03_probe()
174 return -ENOMEM; in l4f00242t03_probe()
176 spi_set_drvdata(spi, priv); in l4f00242t03_probe()
177 spi->bits_per_word = 9; in l4f00242t03_probe()
178 ret = spi_setup(spi); in l4f00242t03_probe()
180 return dev_err_probe(&spi->dev, ret, "Unable to setup spi.\n"); in l4f00242t03_probe()
182 priv->spi = spi; in l4f00242t03_probe()
184 priv->reset = devm_gpiod_get(&spi->dev, "reset", GPIOD_OUT_HIGH); in l4f00242t03_probe()
185 if (IS_ERR(priv->reset)) in l4f00242t03_probe()
186 return dev_err_probe(&spi->dev, PTR_ERR(priv->reset), in l4f00242t03_probe()
188 gpiod_set_consumer_name(priv->reset, "lcd l4f00242t03 reset"); in l4f00242t03_probe()
190 priv->enable = devm_gpiod_get(&spi->dev, "enable", GPIOD_OUT_LOW); in l4f00242t03_probe()
191 if (IS_ERR(priv->enable)) in l4f00242t03_probe()
192 return dev_err_probe(&spi->dev, PTR_ERR(priv->enable), in l4f00242t03_probe()
194 gpiod_set_consumer_name(priv->enable, "lcd l4f00242t03 data enable"); in l4f00242t03_probe()
196 priv->io_reg = devm_regulator_get(&spi->dev, "vdd"); in l4f00242t03_probe()
197 if (IS_ERR(priv->io_reg)) in l4f00242t03_probe()
198 return dev_err_probe(&spi->dev, PTR_ERR(priv->io_reg), in l4f00242t03_probe()
202 priv->core_reg = devm_regulator_get(&spi->dev, "vcore"); in l4f00242t03_probe()
203 if (IS_ERR(priv->core_reg)) in l4f00242t03_probe()
204 return dev_err_probe(&spi->dev, PTR_ERR(priv->core_reg), in l4f00242t03_probe()
208 priv->ld = devm_lcd_device_register(&spi->dev, "l4f00242t03", &spi->dev, in l4f00242t03_probe()
210 if (IS_ERR(priv->ld)) in l4f00242t03_probe()
211 return PTR_ERR(priv->ld); in l4f00242t03_probe()
214 l4f00242t03_lcd_init(spi); in l4f00242t03_probe()
215 priv->lcd_state = FB_BLANK_VSYNC_SUSPEND; in l4f00242t03_probe()
216 l4f00242t03_lcd_power_set(priv->ld, FB_BLANK_UNBLANK); in l4f00242t03_probe()
218 dev_info(&spi->dev, "Epson l4f00242t03 lcd probed.\n"); in l4f00242t03_probe()
223 static void l4f00242t03_remove(struct spi_device *spi) in l4f00242t03_remove() argument
225 struct l4f00242t03_priv *priv = spi_get_drvdata(spi); in l4f00242t03_remove()
227 l4f00242t03_lcd_power_set(priv->ld, FB_BLANK_POWERDOWN); in l4f00242t03_remove()
230 static void l4f00242t03_shutdown(struct spi_device *spi) in l4f00242t03_shutdown() argument
232 struct l4f00242t03_priv *priv = spi_get_drvdata(spi); in l4f00242t03_shutdown()
235 l4f00242t03_lcd_power_set(priv->ld, FB_BLANK_POWERDOWN); in l4f00242t03_shutdown()