Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* ------------------------------------------------------------------------ * |
| 2 | * i2c-parport.h I2C bus over parallel port * |
| 3 | * ------------------------------------------------------------------------ * |
Jean Delvare | 3585925 | 2010-03-02 12:23:44 +0100 | [diff] [blame] | 4 | Copyright (C) 2003-2010 Jean Delvare <khali@linux-fr.org> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | |
| 6 | This program is free software; you can redistribute it and/or modify |
| 7 | it under the terms of the GNU General Public License as published by |
| 8 | the Free Software Foundation; either version 2 of the License, or |
| 9 | (at your option) any later version. |
| 10 | |
| 11 | This program is distributed in the hope that it will be useful, |
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | GNU General Public License for more details. |
| 15 | |
| 16 | You should have received a copy of the GNU General Public License |
| 17 | along with this program; if not, write to the Free Software |
| 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 19 | * ------------------------------------------------------------------------ */ |
| 20 | |
| 21 | #ifdef DATA |
| 22 | #undef DATA |
| 23 | #endif |
| 24 | |
| 25 | #define DATA 0 |
| 26 | #define STAT 1 |
| 27 | #define CTRL 2 |
| 28 | |
| 29 | struct lineop { |
| 30 | u8 val; |
| 31 | u8 port; |
| 32 | u8 inverted; |
| 33 | }; |
| 34 | |
| 35 | struct adapter_parm { |
| 36 | struct lineop setsda; |
| 37 | struct lineop setscl; |
| 38 | struct lineop getsda; |
| 39 | struct lineop getscl; |
| 40 | struct lineop init; |
Jean Delvare | 3585925 | 2010-03-02 12:23:44 +0100 | [diff] [blame] | 41 | unsigned int smbus_alert:1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | }; |
| 43 | |
| 44 | static struct adapter_parm adapter_parm[] = { |
| 45 | /* type 0: Philips adapter */ |
| 46 | { |
| 47 | .setsda = { 0x80, DATA, 1 }, |
| 48 | .setscl = { 0x08, CTRL, 0 }, |
| 49 | .getsda = { 0x80, STAT, 0 }, |
| 50 | .getscl = { 0x08, STAT, 0 }, |
| 51 | }, |
| 52 | /* type 1: home brew teletext adapter */ |
| 53 | { |
| 54 | .setsda = { 0x02, DATA, 0 }, |
| 55 | .setscl = { 0x01, DATA, 0 }, |
| 56 | .getsda = { 0x80, STAT, 1 }, |
| 57 | }, |
| 58 | /* type 2: Velleman K8000 adapter */ |
| 59 | { |
| 60 | .setsda = { 0x02, CTRL, 1 }, |
| 61 | .setscl = { 0x08, CTRL, 1 }, |
| 62 | .getsda = { 0x10, STAT, 0 }, |
| 63 | }, |
| 64 | /* type 3: ELV adapter */ |
| 65 | { |
| 66 | .setsda = { 0x02, DATA, 1 }, |
| 67 | .setscl = { 0x01, DATA, 1 }, |
| 68 | .getsda = { 0x40, STAT, 1 }, |
| 69 | .getscl = { 0x08, STAT, 1 }, |
| 70 | }, |
| 71 | /* type 4: ADM1032 evaluation board */ |
| 72 | { |
| 73 | .setsda = { 0x02, DATA, 1 }, |
| 74 | .setscl = { 0x01, DATA, 1 }, |
| 75 | .getsda = { 0x10, STAT, 1 }, |
| 76 | .init = { 0xf0, DATA, 0 }, |
Jean Delvare | 3585925 | 2010-03-02 12:23:44 +0100 | [diff] [blame] | 77 | .smbus_alert = 1, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | }, |
| 79 | /* type 5: ADM1025, ADM1030 and ADM1031 evaluation boards */ |
| 80 | { |
| 81 | .setsda = { 0x02, DATA, 1 }, |
| 82 | .setscl = { 0x01, DATA, 1 }, |
| 83 | .getsda = { 0x10, STAT, 1 }, |
| 84 | }, |
Peter Korsgaard | 1d26f45 | 2005-11-26 20:18:43 +0100 | [diff] [blame] | 85 | /* type 6: Barco LPT->DVI (K5800236) adapter */ |
| 86 | { |
| 87 | .setsda = { 0x02, DATA, 1 }, |
| 88 | .setscl = { 0x01, DATA, 1 }, |
| 89 | .getsda = { 0x20, STAT, 0 }, |
| 90 | .getscl = { 0x40, STAT, 0 }, |
| 91 | .init = { 0xfc, DATA, 0 }, |
| 92 | }, |
Jonathan McDowell | 55249cf | 2007-02-13 22:09:02 +0100 | [diff] [blame] | 93 | /* type 7: One For All JP1 parallel port adapter */ |
| 94 | { |
| 95 | .setsda = { 0x01, DATA, 0 }, |
| 96 | .setscl = { 0x02, DATA, 0 }, |
| 97 | .getsda = { 0x80, STAT, 1 }, |
| 98 | .init = { 0x04, DATA, 1 }, |
| 99 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | }; |
| 101 | |
Mark M. Hoffman | e97b81d | 2006-03-23 16:50:25 +0100 | [diff] [blame] | 102 | static int type = -1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | module_param(type, int, 0); |
| 104 | MODULE_PARM_DESC(type, |
| 105 | "Type of adapter:\n" |
| 106 | " 0 = Philips adapter\n" |
| 107 | " 1 = home brew teletext adapter\n" |
| 108 | " 2 = Velleman K8000 adapter\n" |
| 109 | " 3 = ELV adapter\n" |
| 110 | " 4 = ADM1032 evaluation board\n" |
Peter Korsgaard | 1d26f45 | 2005-11-26 20:18:43 +0100 | [diff] [blame] | 111 | " 5 = ADM1025, ADM1030 and ADM1031 evaluation boards\n" |
| 112 | " 6 = Barco LPT->DVI (K5800236) adapter\n" |
Jonathan McDowell | 55249cf | 2007-02-13 22:09:02 +0100 | [diff] [blame] | 113 | " 7 = One For All JP1 parallel port adapter\n" |
Peter Korsgaard | 1d26f45 | 2005-11-26 20:18:43 +0100 | [diff] [blame] | 114 | ); |