xref: /kernel/linux/linux-5.10/drivers/ide/qd65xx.h (revision 8c2ecf20)
18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (c) 2000	Linus Torvalds & authors
48c2ecf20Sopenharmony_ci */
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci/*
78c2ecf20Sopenharmony_ci * Authors:	Petr Soucek <petr@ryston.cz>
88c2ecf20Sopenharmony_ci * 		Samuel Thibault <samuel.thibault@ens-lyon.org>
98c2ecf20Sopenharmony_ci */
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci/* truncates a in [b,c] */
128c2ecf20Sopenharmony_ci#define IDE_IN(a,b,c)   ( ((a)<(b)) ? (b) : ( (a)>(c) ? (c) : (a)) )
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#define IDE_IMPLY(a,b)	((!(a)) || (b))
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci#define QD_TIM1_PORT		(base)
178c2ecf20Sopenharmony_ci#define QD_CONFIG_PORT		(base+0x01)
188c2ecf20Sopenharmony_ci#define QD_TIM2_PORT		(base+0x02)
198c2ecf20Sopenharmony_ci#define QD_CONTROL_PORT		(base+0x03)
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci#define QD_CONFIG_IDE_BASEPORT	0x01
228c2ecf20Sopenharmony_ci#define QD_CONFIG_BASEPORT	0x02
238c2ecf20Sopenharmony_ci#define QD_CONFIG_ID3		0x04
248c2ecf20Sopenharmony_ci#define QD_CONFIG_DISABLED	0x08
258c2ecf20Sopenharmony_ci#define QD_CONFIG_QD6500	0xc0
268c2ecf20Sopenharmony_ci#define QD_CONFIG_QD6580_A	0xa0
278c2ecf20Sopenharmony_ci#define QD_CONFIG_QD6580_B	0x50
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci#define QD_CONTR_SEC_DISABLED	0x01
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci#define QD_ID3			((config & QD_CONFIG_ID3)!=0)
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci#define QD_CONFIG(hwif)		((hwif)->config_data & 0x00ff)
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_cistatic inline u8 QD_TIMING(ide_drive_t *drive)
368c2ecf20Sopenharmony_ci{
378c2ecf20Sopenharmony_ci	return (unsigned long)ide_get_drivedata(drive) & 0x00ff;
388c2ecf20Sopenharmony_ci}
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_cistatic inline u8 QD_TIMREG(ide_drive_t *drive)
418c2ecf20Sopenharmony_ci{
428c2ecf20Sopenharmony_ci	return ((unsigned long)ide_get_drivedata(drive) & 0xff00) >> 8;
438c2ecf20Sopenharmony_ci}
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci#define QD6500_DEF_DATA		((QD_TIM1_PORT<<8) | (QD_ID3 ? 0x0c : 0x08))
468c2ecf20Sopenharmony_ci#define QD6580_DEF_DATA		((QD_TIM1_PORT<<8) | (QD_ID3 ? 0x0a : 0x00))
478c2ecf20Sopenharmony_ci#define QD6580_DEF_DATA2	((QD_TIM2_PORT<<8) | (QD_ID3 ? 0x0a : 0x00))
488c2ecf20Sopenharmony_ci#define QD_DEF_CONTR		(0x40 | ((control & 0x02) ? 0x9f : 0x1f))
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci#define QD_TESTVAL		0x19	/* safe value */
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci/* Drive specific timing taken from DOS driver v3.7 */
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_cistatic struct qd65xx_timing_s {
558c2ecf20Sopenharmony_ci	s8	offset;   /* ofset from the beginning of Model Number" */
568c2ecf20Sopenharmony_ci	char	model[4];    /* 4 chars from Model number, no conversion */
578c2ecf20Sopenharmony_ci	s16	active;   /* active time */
588c2ecf20Sopenharmony_ci	s16	recovery; /* recovery time */
598c2ecf20Sopenharmony_ci} qd65xx_timing [] = {
608c2ecf20Sopenharmony_ci	{ 30, "2040", 110, 225 },  /* Conner CP30204			*/
618c2ecf20Sopenharmony_ci	{ 30, "2045", 135, 225 },  /* Conner CP30254			*/
628c2ecf20Sopenharmony_ci	{ 30, "1040", 155, 325 },  /* Conner CP30104			*/
638c2ecf20Sopenharmony_ci	{ 30, "1047", 135, 265 },  /* Conner CP30174			*/
648c2ecf20Sopenharmony_ci	{ 30, "5344", 135, 225 },  /* Conner CP3544			*/
658c2ecf20Sopenharmony_ci	{ 30, "01 4", 175, 405 },  /* Conner CP-3104			*/
668c2ecf20Sopenharmony_ci	{ 27, "C030", 175, 375 },  /* Conner CP3000			*/
678c2ecf20Sopenharmony_ci	{  8, "PL42", 110, 295 },  /* Quantum LP240			*/
688c2ecf20Sopenharmony_ci	{  8, "PL21", 110, 315 },  /* Quantum LP120			*/
698c2ecf20Sopenharmony_ci	{  8, "PL25", 175, 385 },  /* Quantum LP52			*/
708c2ecf20Sopenharmony_ci	{  4, "PA24", 110, 285 },  /* WD Piranha SP4200			*/
718c2ecf20Sopenharmony_ci	{  6, "2200", 110, 260 },  /* WD Caviar AC2200			*/
728c2ecf20Sopenharmony_ci	{  6, "3204", 110, 235 },  /* WD Caviar AC2340			*/
738c2ecf20Sopenharmony_ci	{  6, "1202", 110, 265 },  /* WD Caviar AC2120			*/
748c2ecf20Sopenharmony_ci	{  0, "DS3-", 135, 315 },  /* Teac SD340			*/
758c2ecf20Sopenharmony_ci	{  8, "KM32", 175, 355 },  /* Toshiba MK234			*/
768c2ecf20Sopenharmony_ci	{  2, "53A1", 175, 355 },  /* Seagate ST351A			*/
778c2ecf20Sopenharmony_ci	{  2, "4108", 175, 295 },  /* Seagate ST1480A			*/
788c2ecf20Sopenharmony_ci	{  2, "1344", 175, 335 },  /* Seagate ST3144A			*/
798c2ecf20Sopenharmony_ci	{  6, "7 12", 110, 225 },  /* Maxtor 7213A			*/
808c2ecf20Sopenharmony_ci	{ 30, "02F4", 145, 295 },  /* Conner 3204F			*/
818c2ecf20Sopenharmony_ci	{  2, "1302", 175, 335 },  /* Seagate ST3120A			*/
828c2ecf20Sopenharmony_ci	{  2, "2334", 145, 265 },  /* Seagate ST3243A			*/
838c2ecf20Sopenharmony_ci	{  2, "2338", 145, 275 },  /* Seagate ST3283A			*/
848c2ecf20Sopenharmony_ci	{  2, "3309", 145, 275 },  /* Seagate ST3390A			*/
858c2ecf20Sopenharmony_ci	{  2, "5305", 145, 275 },  /* Seagate ST3550A			*/
868c2ecf20Sopenharmony_ci	{  2, "4100", 175, 295 },  /* Seagate ST1400A			*/
878c2ecf20Sopenharmony_ci	{  2, "4110", 175, 295 },  /* Seagate ST1401A			*/
888c2ecf20Sopenharmony_ci	{  2, "6300", 135, 265 },  /* Seagate ST3600A			*/
898c2ecf20Sopenharmony_ci	{  2, "5300", 135, 265 },  /* Seagate ST3500A			*/
908c2ecf20Sopenharmony_ci	{  6, "7 31", 135, 225 },  /* Maxtor 7131 AT			*/
918c2ecf20Sopenharmony_ci	{  6, "7 43", 115, 265 },  /* Maxtor 7345 AT			*/
928c2ecf20Sopenharmony_ci	{  6, "7 42", 110, 255 },  /* Maxtor 7245 AT			*/
938c2ecf20Sopenharmony_ci	{  6, "3 04", 135, 265 },  /* Maxtor 340 AT			*/
948c2ecf20Sopenharmony_ci	{  6, "61 0", 135, 285 },  /* WD AC160				*/
958c2ecf20Sopenharmony_ci	{  6, "1107", 135, 235 },  /* WD AC1170				*/
968c2ecf20Sopenharmony_ci	{  6, "2101", 110, 220 },  /* WD AC1210				*/
978c2ecf20Sopenharmony_ci	{  6, "4202", 135, 245 },  /* WD AC2420				*/
988c2ecf20Sopenharmony_ci	{  6, "41 0", 175, 355 },  /* WD Caviar 140			*/
998c2ecf20Sopenharmony_ci	{  6, "82 0", 175, 355 },  /* WD Caviar 280			*/
1008c2ecf20Sopenharmony_ci	{  8, "PL01", 175, 375 },  /* Quantum LP105			*/
1018c2ecf20Sopenharmony_ci	{  8, "PL25", 110, 295 },  /* Quantum LP525			*/
1028c2ecf20Sopenharmony_ci	{ 10, "4S 2", 175, 385 },  /* Quantum ELS42			*/
1038c2ecf20Sopenharmony_ci	{ 10, "8S 5", 175, 385 },  /* Quantum ELS85			*/
1048c2ecf20Sopenharmony_ci	{ 10, "1S72", 175, 385 },  /* Quantum ELS127			*/
1058c2ecf20Sopenharmony_ci	{ 10, "1S07", 175, 385 },  /* Quantum ELS170			*/
1068c2ecf20Sopenharmony_ci	{  8, "ZE42", 135, 295 },  /* Quantum EZ240			*/
1078c2ecf20Sopenharmony_ci	{  8, "ZE21", 175, 385 },  /* Quantum EZ127			*/
1088c2ecf20Sopenharmony_ci	{  8, "ZE58", 175, 385 },  /* Quantum EZ85			*/
1098c2ecf20Sopenharmony_ci	{  8, "ZE24", 175, 385 },  /* Quantum EZ42			*/
1108c2ecf20Sopenharmony_ci	{ 27, "C036", 155, 325 },  /* Conner CP30064			*/
1118c2ecf20Sopenharmony_ci	{ 27, "C038", 155, 325 },  /* Conner CP30084			*/
1128c2ecf20Sopenharmony_ci	{  6, "2205", 110, 255 },  /* WDC AC2250			*/
1138c2ecf20Sopenharmony_ci	{  2, " CHA", 140, 415 },  /* WDC AH series; WDC AH260, WDC	*/
1148c2ecf20Sopenharmony_ci	{  2, " CLA", 140, 415 },  /* WDC AL series: WDC AL2120, 2170,	*/
1158c2ecf20Sopenharmony_ci	{  4, "UC41", 140, 415 },  /* WDC CU140				*/
1168c2ecf20Sopenharmony_ci	{  6, "1207", 130, 275 },  /* WDC AC2170			*/
1178c2ecf20Sopenharmony_ci	{  6, "2107", 130, 275 },  /* WDC AC1270			*/
1188c2ecf20Sopenharmony_ci	{  6, "5204", 130, 275 },  /* WDC AC2540			*/
1198c2ecf20Sopenharmony_ci	{ 30, "3004", 110, 235 },  /* Conner CP30340			*/
1208c2ecf20Sopenharmony_ci	{ 30, "0345", 135, 255 },  /* Conner CP30544			*/
1218c2ecf20Sopenharmony_ci	{ 12, "12A3", 175, 320 },  /* MAXTOR LXT-213A			*/
1228c2ecf20Sopenharmony_ci	{ 12, "43A0", 145, 240 },  /* MAXTOR LXT-340A			*/
1238c2ecf20Sopenharmony_ci	{  6, "7 21", 180, 290 },  /* Maxtor 7120 AT			*/
1248c2ecf20Sopenharmony_ci	{  6, "7 71", 135, 240 },  /* Maxtor 7170 AT			*/
1258c2ecf20Sopenharmony_ci	{ 12, "45\0000", 110, 205 },   /* MAXTOR MXT-540		*/
1268c2ecf20Sopenharmony_ci	{  8, "PL11", 180, 290 },  /* QUANTUM LP110A			*/
1278c2ecf20Sopenharmony_ci	{  8, "OG21", 150, 275 },  /* QUANTUM GO120			*/
1288c2ecf20Sopenharmony_ci	{ 12, "42A5", 175, 320 },  /* MAXTOR LXT-245A			*/
1298c2ecf20Sopenharmony_ci	{  2, "2309", 175, 295 },  /* ST3290A				*/
1308c2ecf20Sopenharmony_ci	{  2, "3358", 180, 310 },  /* ST3385A				*/
1318c2ecf20Sopenharmony_ci	{  2, "6355", 180, 310 },  /* ST3655A				*/
1328c2ecf20Sopenharmony_ci	{  2, "1900", 175, 270 },  /* ST9100A				*/
1338c2ecf20Sopenharmony_ci	{  2, "1954", 175, 270 },  /* ST9145A				*/
1348c2ecf20Sopenharmony_ci	{  2, "1909", 175, 270 },  /* ST9190AG				*/
1358c2ecf20Sopenharmony_ci	{  2, "2953", 175, 270 },  /* ST9235A				*/
1368c2ecf20Sopenharmony_ci	{  2, "1359", 175, 270 },  /* ST3195A				*/
1378c2ecf20Sopenharmony_ci	{ 24, "3R11", 175, 290 },  /* ALPS ELECTRIC Co.,LTD, DR311C	*/
1388c2ecf20Sopenharmony_ci	{  0, "2M26", 175, 215 },  /* M262XT-0Ah			*/
1398c2ecf20Sopenharmony_ci	{  4, "2253", 175, 300 },  /* HP C2235A				*/
1408c2ecf20Sopenharmony_ci	{  4, "-32A", 145, 245 },  /* H3133-A2				*/
1418c2ecf20Sopenharmony_ci	{ 30, "0326", 150, 270 },  /* Samsung Electronics 120MB		*/
1428c2ecf20Sopenharmony_ci	{ 30, "3044", 110, 195 },  /* Conner CFA340A			*/
1438c2ecf20Sopenharmony_ci	{ 30, "43A0", 110, 195 },  /* Conner CFA340A			*/
1448c2ecf20Sopenharmony_ci	{ -1, "    ", 175, 415 }   /* unknown disk name			*/
1458c2ecf20Sopenharmony_ci};
146