• Home
  • Raw
  • Download

Lines Matching full:spi

7  * controller. The interface to the display is SPI and the display's
20 #include <linux/spi/spi.h>
105 * for the SPI transfer. According to the datasheet, the controller
110 * @s: pointer to an SPI device
139 struct spi_device *spi; member
146 * @spi: spi device
149 static int ili922x_read_status(struct spi_device *spi, u16 *rs) in ili922x_read_status() argument
162 CHECK_FREQ_REG(spi, &xfer); in ili922x_read_status()
176 ret = spi_sync(spi, &msg); in ili922x_read_status()
178 dev_dbg(&spi->dev, "Error sending SPI message 0x%x", ret); in ili922x_read_status()
188 * @spi: spi device
192 static int ili922x_read(struct spi_device *spi, u8 reg, u16 *rx) in ili922x_read() argument
206 CHECK_FREQ_REG(spi, &xfer_regindex); in ili922x_read()
227 CHECK_FREQ_REG(spi, &xfer_regvalue); in ili922x_read()
230 ret = spi_sync(spi, &msg); in ili922x_read()
232 dev_dbg(&spi->dev, "Error sending SPI message 0x%x", ret); in ili922x_read()
242 * @spi: struct spi_device *
246 static int ili922x_write(struct spi_device *spi, u8 reg, u16 value) in ili922x_write() argument
261 CHECK_FREQ_REG(spi, &xfer_regindex); in ili922x_write()
271 ret = spi_sync(spi, &msg); in ili922x_write()
283 CHECK_FREQ_REG(spi, &xfer_regvalue); in ili922x_write()
287 ret = spi_sync(spi, &msg); in ili922x_write()
289 dev_err(&spi->dev, "Error sending SPI message 0x%x", ret); in ili922x_write()
299 * @spi: pointer to an SPI device
301 static void ili922x_reg_dump(struct spi_device *spi) in ili922x_reg_dump() argument
306 dev_dbg(&spi->dev, "ILI922x configuration registers:\n"); in ili922x_reg_dump()
309 ili922x_read(spi, reg, &rx); in ili922x_reg_dump()
310 dev_dbg(&spi->dev, "reg @ 0x%02X: 0x%04X\n", reg, rx); in ili922x_reg_dump()
314 static inline void ili922x_reg_dump(struct spi_device *spi) {} in ili922x_reg_dump() argument
319 * @spi: spi device
321 static void set_write_to_gram_reg(struct spi_device *spi) in set_write_to_gram_reg() argument
341 spi_sync(spi, &msg); in set_write_to_gram_reg()
346 * @spi: spi device
352 static int ili922x_poweron(struct spi_device *spi) in ili922x_poweron() argument
357 ret = ili922x_write(spi, REG_POWER_CONTROL_1, 0x0000); in ili922x_poweron()
359 ret += ili922x_write(spi, REG_POWER_CONTROL_2, 0x0000); in ili922x_poweron()
360 ret += ili922x_write(spi, REG_POWER_CONTROL_3, 0x0000); in ili922x_poweron()
362 ret += ili922x_write(spi, REG_POWER_CONTROL_4, 0x0000); in ili922x_poweron()
365 ret += ili922x_write(spi, 0x56, 0x080F); in ili922x_poweron()
366 ret += ili922x_write(spi, REG_POWER_CONTROL_1, 0x4240); in ili922x_poweron()
368 ret += ili922x_write(spi, REG_POWER_CONTROL_2, 0x0000); in ili922x_poweron()
369 ret += ili922x_write(spi, REG_POWER_CONTROL_3, 0x0014); in ili922x_poweron()
371 ret += ili922x_write(spi, REG_POWER_CONTROL_4, 0x1319); in ili922x_poweron()
379 * @spi: spi device
381 static int ili922x_poweroff(struct spi_device *spi) in ili922x_poweroff() argument
386 ret = ili922x_write(spi, REG_POWER_CONTROL_1, 0x0000); in ili922x_poweroff()
388 ret += ili922x_write(spi, REG_POWER_CONTROL_2, 0x0000); in ili922x_poweroff()
389 ret += ili922x_write(spi, REG_POWER_CONTROL_3, 0x0000); in ili922x_poweroff()
391 ret += ili922x_write(spi, REG_POWER_CONTROL_4, 0x0000); in ili922x_poweroff()
400 * @spi: spi device
402 static void ili922x_display_init(struct spi_device *spi) in ili922x_display_init() argument
404 ili922x_write(spi, REG_START_OSCILLATION, 1); in ili922x_display_init()
406 ili922x_write(spi, REG_DRIVER_OUTPUT_CONTROL, 0x691B); in ili922x_display_init()
407 ili922x_write(spi, REG_LCD_AC_DRIVEING_CONTROL, 0x0700); in ili922x_display_init()
408 ili922x_write(spi, REG_ENTRY_MODE, 0x1030); in ili922x_display_init()
409 ili922x_write(spi, REG_COMPARE_1, 0x0000); in ili922x_display_init()
410 ili922x_write(spi, REG_COMPARE_2, 0x0000); in ili922x_display_init()
411 ili922x_write(spi, REG_DISPLAY_CONTROL_1, 0x0037); in ili922x_display_init()
412 ili922x_write(spi, REG_DISPLAY_CONTROL_2, 0x0202); in ili922x_display_init()
413 ili922x_write(spi, REG_DISPLAY_CONTROL_3, 0x0000); in ili922x_display_init()
414 ili922x_write(spi, REG_FRAME_CYCLE_CONTROL, 0x0000); in ili922x_display_init()
417 ili922x_write(spi, REG_EXT_INTF_CONTROL, 0x0110); in ili922x_display_init()
419 ili922x_poweron(spi); in ili922x_display_init()
421 ili922x_write(spi, REG_GAMMA_CONTROL_1, 0x0302); in ili922x_display_init()
422 ili922x_write(spi, REG_GAMMA_CONTROL_2, 0x0407); in ili922x_display_init()
423 ili922x_write(spi, REG_GAMMA_CONTROL_3, 0x0304); in ili922x_display_init()
424 ili922x_write(spi, REG_GAMMA_CONTROL_4, 0x0203); in ili922x_display_init()
425 ili922x_write(spi, REG_GAMMA_CONTROL_5, 0x0706); in ili922x_display_init()
426 ili922x_write(spi, REG_GAMMA_CONTROL_6, 0x0407); in ili922x_display_init()
427 ili922x_write(spi, REG_GAMMA_CONTROL_7, 0x0706); in ili922x_display_init()
428 ili922x_write(spi, REG_GAMMA_CONTROL_8, 0x0000); in ili922x_display_init()
429 ili922x_write(spi, REG_GAMMA_CONTROL_9, 0x0C06); in ili922x_display_init()
430 ili922x_write(spi, REG_GAMMA_CONTROL_10, 0x0F00); in ili922x_display_init()
431 ili922x_write(spi, REG_RAM_ADDRESS_SET, 0x0000); in ili922x_display_init()
432 ili922x_write(spi, REG_GATE_SCAN_CONTROL, 0x0000); in ili922x_display_init()
433 ili922x_write(spi, REG_VERT_SCROLL_CONTROL, 0x0000); in ili922x_display_init()
434 ili922x_write(spi, REG_FIRST_SCREEN_DRIVE_POS, 0xDB00); in ili922x_display_init()
435 ili922x_write(spi, REG_SECOND_SCREEN_DRIVE_POS, 0xDB00); in ili922x_display_init()
436 ili922x_write(spi, REG_RAM_ADDR_POS_H, 0xAF00); in ili922x_display_init()
437 ili922x_write(spi, REG_RAM_ADDR_POS_V, 0xDB00); in ili922x_display_init()
438 ili922x_reg_dump(spi); in ili922x_display_init()
439 set_write_to_gram_reg(spi); in ili922x_display_init()
447 ret = ili922x_poweron(lcd->spi); in ili922x_lcd_power()
449 ret = ili922x_poweroff(lcd->spi); in ili922x_lcd_power()
476 static int ili922x_probe(struct spi_device *spi) in ili922x_probe() argument
483 ili = devm_kzalloc(&spi->dev, sizeof(*ili), GFP_KERNEL); in ili922x_probe()
487 ili->spi = spi; in ili922x_probe()
488 spi_set_drvdata(spi, ili); in ili922x_probe()
491 ret = ili922x_read(spi, REG_DRIVER_CODE_READ, &reg); in ili922x_probe()
493 dev_err(&spi->dev, in ili922x_probe()
499 dev_info(&spi->dev, "ILI%x found, SPI freq %d, mode %d\n", in ili922x_probe()
500 reg, spi->max_speed_hz, spi->mode); in ili922x_probe()
502 ret = ili922x_read_status(spi, &reg); in ili922x_probe()
504 dev_err(&spi->dev, "reading RS failed...\n"); in ili922x_probe()
508 dev_dbg(&spi->dev, "status: 0x%x\n", reg); in ili922x_probe()
510 ili922x_display_init(spi); in ili922x_probe()
514 lcd = devm_lcd_device_register(&spi->dev, "ili922xlcd", &spi->dev, ili, in ili922x_probe()
517 dev_err(&spi->dev, "cannot register LCD\n"); in ili922x_probe()
522 spi_set_drvdata(spi, ili); in ili922x_probe()
529 static int ili922x_remove(struct spi_device *spi) in ili922x_remove() argument
531 ili922x_poweroff(spi); in ili922x_remove()