// SPDX-License-Identifier: GPL-2.0
/*
* Support for SuperH MigoR Quarter VGA LCD Panel
*
* Copyright (C) 2008 Magnus Damm
*
* Based on lcd_powertip.c from Kenati Technologies Pvt Ltd.
* Copyright (c) 2007 Ujjwal Pande <ujjwal@kenati.com>,
*/
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/fb.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/gpio.h>
#include <video/sh_mobile_lcdc.h>
#include <cpu/sh7722.h>
#include <mach/migor.h>
/* LCD Module is a PH240320T according to board schematics. This module
* is made up of a 240x320 LCD hooked up to a R61505U (or HX8347-A01?)
* Driver IC. This IC is connected to the SH7722 built-in LCDC using a
* SYS-80 interface configured in 16 bit mode.
*
* Index 0: "Device Code Read" returns 0x1505.
*/
static void reset_lcd_module(void )
{
gpio_set_value(GPIO_PTH2, 0 );
mdelay(2 );
gpio_set_value(GPIO_PTH2, 1 );
mdelay(1 );
}
/* DB0-DB7 are connected to D1-D8, and DB8-DB15 to D10-D17 */
static unsigned long adjust_reg18(unsigned short data)
{
unsigned long tmp1, tmp2;
tmp1 = (data<<1 | 0 x00000001) & 0 x000001FF;
tmp2 = (data<<2 | 0 x00000200) & 0 x0003FE00;
return tmp1 | tmp2;
}
static void write_reg(void *sys_ops_handle,
struct sh_mobile_lcdc_sys_bus_ops *sys_ops,
unsigned short reg, unsigned short data)
{
sys_ops->write_index(sys_ops_handle, adjust_reg18(reg << 8 | data));
}
static void write_reg16(void *sys_ops_handle,
struct sh_mobile_lcdc_sys_bus_ops *sys_ops,
unsigned short reg, unsigned short data)
{
sys_ops->write_index(sys_ops_handle, adjust_reg18(reg));
sys_ops->write_data(sys_ops_handle, adjust_reg18(data));
}
static unsigned long read_reg16(void *sys_ops_handle,
struct sh_mobile_lcdc_sys_bus_ops *sys_ops,
unsigned short reg)
{
unsigned long data;
sys_ops->write_index(sys_ops_handle, adjust_reg18(reg));
data = sys_ops->read_data(sys_ops_handle);
return ((data >> 1 ) & 0 xff) | ((data >> 2 ) & 0 xff00);
}
static void migor_lcd_qvga_seq(void *sys_ops_handle,
struct sh_mobile_lcdc_sys_bus_ops *sys_ops,
unsigned short const *data, int no_data)
{
int i;
for (i = 0 ; i < no_data; i += 2 )
write_reg16(sys_ops_handle, sys_ops, data[i], data[i + 1 ]);
}
static const unsigned short sync_data[] = {
0 x0000, 0 x0000, 0 x0000, 0 x0000, 0 x0000, 0 x0000, 0 x0000, 0 x0000,
};
static const unsigned short magic0_data[] = {
0 x0060, 0 x2700, 0 x0008, 0 x0808, 0 x0090, 0 x001A, 0 x0007, 0 x0001,
0 x0017, 0 x0001, 0 x0019, 0 x0000, 0 x0010, 0 x17B0, 0 x0011, 0 x0116,
0 x0012, 0 x0198, 0 x0013, 0 x1400, 0 x0029, 0 x000C, 0 x0012, 0 x01B8,
};
static const unsigned short magic1_data[] = {
0 x0030, 0 x0307, 0 x0031, 0 x0303, 0 x0032, 0 x0603, 0 x0033, 0 x0202,
0 x0034, 0 x0202, 0 x0035, 0 x0202, 0 x0036, 0 x1F1F, 0 x0037, 0 x0303,
0 x0038, 0 x0303, 0 x0039, 0 x0603, 0 x003A, 0 x0202, 0 x003B, 0 x0102,
0 x003C, 0 x0204, 0 x003D, 0 x0000, 0 x0001, 0 x0100, 0 x0002, 0 x0300,
0 x0003, 0 x5028, 0 x0020, 0 x00ef, 0 x0021, 0 x0000, 0 x0004, 0 x0000,
0 x0009, 0 x0000, 0 x000A, 0 x0008, 0 x000C, 0 x0000, 0 x000D, 0 x0000,
0 x0015, 0 x8000,
};
static const unsigned short magic2_data[] = {
0 x0061, 0 x0001, 0 x0092, 0 x0100, 0 x0093, 0 x0001, 0 x0007, 0 x0021,
};
static const unsigned short magic3_data[] = {
0 x0010, 0 x16B0, 0 x0011, 0 x0111, 0 x0007, 0 x0061,
};
int migor_lcd_qvga_setup(void *sohandle, struct sh_mobile_lcdc_sys_bus_ops *so)
{
unsigned long xres = 320 ;
unsigned long yres = 240 ;
int k;
reset_lcd_module();
migor_lcd_qvga_seq(sohandle, so, sync_data, ARRAY_SIZE(sync_data));
if (read_reg16(sohandle, so, 0 ) != 0 x1505)
return -ENODEV;
pr_info("Migo-R QVGA LCD Module detected.\n" );
migor_lcd_qvga_seq(sohandle, so, sync_data, ARRAY_SIZE(sync_data));
write_reg16(sohandle, so, 0 x00A4, 0 x0001);
mdelay(10 );
migor_lcd_qvga_seq(sohandle, so, magic0_data, ARRAY_SIZE(magic0_data));
mdelay(100 );
migor_lcd_qvga_seq(sohandle, so, magic1_data, ARRAY_SIZE(magic1_data));
write_reg16(sohandle, so, 0 x0050, 0 xef - (yres - 1 ));
write_reg16(sohandle, so, 0 x0051, 0 x00ef);
write_reg16(sohandle, so, 0 x0052, 0 x0000);
write_reg16(sohandle, so, 0 x0053, xres - 1 );
migor_lcd_qvga_seq(sohandle, so, magic2_data, ARRAY_SIZE(magic2_data));
mdelay(10 );
migor_lcd_qvga_seq(sohandle, so, magic3_data, ARRAY_SIZE(magic3_data));
mdelay(40 );
/* clear GRAM to avoid displaying garbage */
write_reg16(sohandle, so, 0 x0020, 0 x0000); /* horiz addr */
write_reg16(sohandle, so, 0 x0021, 0 x0000); /* vert addr */
for (k = 0 ; k < (xres * 256 ); k++) /* yes, 256 words per line */
write_reg16(sohandle, so, 0 x0022, 0 x0000);
write_reg16(sohandle, so, 0 x0020, 0 x0000); /* reset horiz addr */
write_reg16(sohandle, so, 0 x0021, 0 x0000); /* reset vert addr */
write_reg16(sohandle, so, 0 x0007, 0 x0173);
mdelay(40 );
/* enable display */
write_reg(sohandle, so, 0 x00, 0 x22);
mdelay(100 );
return 0 ;
}
Messung V0.5 in Prozent C=91 H=88 G=89
¤ Dauer der Verarbeitung: 0.1 Sekunden
(vorverarbeitet am 2026-06-07)
¤
*© Formatika GbR, Deutschland