/* $Id: T6963.c,v 1.14 2004/01/09 04:16:06 reinelt Exp $ * * driver for display modules based on the Toshiba T6963 chip * * Copyright 1999, 2000 Michael Reinelt * * This file is part of LCD4Linux. * * LCD4Linux is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * LCD4Linux is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * * $Log: T6963.c,v $ * Revision 1.14 2004/01/09 04:16:06 reinelt * added 'section' argument to cfg_get(), but NULLed it on all calls by now. * * Revision 1.13 2003/10/05 17:58:50 reinelt * libtool junk; copyright messages cleaned up * * Revision 1.12 2003/09/29 06:12:56 reinelt * changed default HD44780 wiring: unused signals are GND * * Revision 1.11 2003/09/13 06:45:43 reinelt * icons for all remaining drivers * * Revision 1.10 2003/08/16 07:31:35 reinelt * double buffering in all drivers * * Revision 1.9 2003/08/15 07:54:07 reinelt * HD44780 4 bit mode implemented * * Revision 1.8 2003/08/01 05:15:42 reinelt * last cleanups for 0.9.9 * * Revision 1.7 2003/07/24 04:48:09 reinelt * 'soft clear' needed for virtual rows * * Revision 1.6 2003/04/07 06:03:00 reinelt * further parallel port abstraction * * Revision 1.5 2003/02/22 07:53:10 reinelt * cfg_get(key,defval) * * Revision 1.4 2002/08/21 06:09:53 reinelt * some T6963 fixes, ndelay wrap * * Revision 1.3 2002/08/19 04:41:20 reinelt * introduced bar.c, moved bar stuff from display.h to bar.h * * Revision 1.2 2002/08/17 12:54:08 reinelt * minor T6963 changes * * Revision 1.1 2002/04/29 11:00:26 reinelt * * added Toshiba T6963 driver * added ndelay() with nanosecond resolution * * */ /* * * exported fuctions: * * struct LCD T6963[] * */ #include "config.h" #include #include #include #include #include "debug.h" #include "cfg.h" #include "display.h" #include "bar.h" #include "icon.h" #include "parport.h" #include "udelay.h" #include "pixmap.h" #define XRES 6 #define YRES 8 static LCD Lcd; static int Icons; unsigned char *Buffer1, *Buffer2; static unsigned char SIGNAL_CE; static unsigned char SIGNAL_CD; static unsigned char SIGNAL_RD; static unsigned char SIGNAL_WR; // Fixme: static int bug=0; // perform normal status check void T6_status1 (void) { int n; // turn off data line drivers parport_direction (1); // lower CE and RD parport_control (SIGNAL_CE | SIGNAL_RD, 0); // Access Time: 150 ns ndelay(150); // wait for STA0=1 and STA1=1 n=0; do { rep_nop(); if (++n>1000) { debug("hang in status1"); bug=1; break; } } while ((parport_read() & 0x03) != 0x03); // rise RD and CE parport_control (SIGNAL_RD | SIGNAL_CE, SIGNAL_RD | SIGNAL_CE); // Output Hold Time: 50 ns ndelay(50); // turn on data line drivers parport_direction (0); } // perform status check in "auto mode" void T6_status2 (void) { int n; // turn off data line drivers parport_direction (1); // lower RD and CE parport_control (SIGNAL_RD | SIGNAL_CE, 0); // Access Time: 150 ns ndelay(150); // wait for STA3=1 n=0; do { rep_nop(); if (++n>1000) { debug("hang in status2"); bug=1; break; } } while ((parport_read() & 0x08) != 0x08); // rise RD and CE parport_control (SIGNAL_RD | SIGNAL_CE, SIGNAL_RD | SIGNAL_CE); // Output Hold Time: 50 ns ndelay(50); // turn on data line drivers parport_direction (0); } static void T6_write_cmd (unsigned char cmd) { // wait until the T6963 is idle T6_status1(); // put data on DB1..DB8 parport_data (cmd); // lower WR and CE parport_control (SIGNAL_WR | SIGNAL_CE, 0); // Pulse width ndelay(80); // rise WR and CE parport_control (SIGNAL_WR | SIGNAL_CE, SIGNAL_WR | SIGNAL_CE); // Data Hold Time ndelay(40); } static void T6_write_data (unsigned char data) { // wait until the T6963 is idle T6_status1(); // put data on DB1..DB8 parport_data (data); // lower C/D parport_control (SIGNAL_CD, 0); // C/D Setup Time ndelay(20); // lower WR and CE parport_control (SIGNAL_WR | SIGNAL_CE, 0); // Pulse Width ndelay(80); // rise WR and CE parport_control (SIGNAL_WR | SIGNAL_CE, SIGNAL_WR | SIGNAL_CE); // Data Hold Time ndelay(40); // rise CD parport_control (SIGNAL_CD, SIGNAL_CD); } static void T6_write_auto (unsigned char data) { // wait until the T6963 is idle T6_status2(); // put data on DB1..DB8 parport_data (data); // lower C/D parport_control (SIGNAL_CD, 0); // C/D Setup Time ndelay(20); // lower WR and CE parport_control (SIGNAL_WR | SIGNAL_CE, 0); // Pulse Width ndelay(80); // rise WR and CE parport_control (SIGNAL_WR | SIGNAL_CE, SIGNAL_WR | SIGNAL_CE); // Data Hold Time ndelay(40); // rise CD parport_control (SIGNAL_CD, SIGNA
/* $Id: udelay.h,v 1.9 2005/01/18 06:30:24 reinelt Exp $
 *
 * short delays 
 *
 * Copyright (C) 1999, 2000 Michael Reinelt <reinelt@eunet.at>
 * Copyright (C) 2004 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>
 *
 * This file is part of LCD4Linux.
 *
 * LCD4Linux is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * LCD4Linux is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 *
 * $Log: udelay.h,v $
 * Revision 1.9  2005/01/18 06:30:24  reinelt
 * added (C) to all copyright statements
 *
 * Revision 1.8  2004/06/26 12:05:00  reinelt
 *
 * uh-oh... the last CVS log message messed up things a lot...
 *
 * Revision 1.7  2004/06/26 09:27:21  reinelt
 *
 * added '-W' to CFLAGS
 * changed all C++ comments to C ones
 * cleaned up a lot of signed/unsigned mistakes
 *
 * Revision 1.6  2004/06/20 10:09:56  reinelt
 *
 * 'const'ified the whole source
 *
 * Revision 1.5  2003/10/05 17:58:50  reinelt
 * libtool junk; copyright messages cleaned up
 *
 * Revision 1.4  2002/04/29 11:00:28  reinelt
 *
 * added Toshiba T6963 driver
 * added ndelay() with nanosecond resolution
 *
 * Revision 1.3  2001/03/12 13:44:58  reinelt
 *
 * new udelay() using Time Stamp Counters
 *
 * Revision 1.2  2001/03/12 12:39:36  reinelt
 *
 * reworked autoconf a lot: drivers may be excluded, #define's went to config.h
 *
 * Revision 1.1  2000/04/15 16:56:52  reinelt
 *
 * moved delay loops to udelay.c
 * renamed -d (debugging) switch to -v (verbose)
 * new switch -d to calibrate delay loop
 * 'Delay' entry for HD44780 back again
 * delay loops will not calibrate automatically, because this will fail with high CPU load
 *
 */

#ifndef _UDELAY_H_
#define _UDELAY_H_

/* stolen from linux/asm-i386/processor.h */
/* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */
static inline void rep_nop (void)
{
  __asm__ __volatile__("rep; nop");
}


#ifdef USE_OLD_UDELAY

extern unsigned long loops_per_usec;
void udelay_calibrate (void);

#else

void udelay_init (void);

#endif

void ndelay (const unsigned long nsec);

#define udelay(usec) ndelay(usec*1000)

#endif