1/*
2 *  linux/include/asm-sh/ide.h
3 *
4 *  Copyright (C) 1994-1996  Linus Torvalds & authors
5 */
6
7/*
8 *  This file contains the i386 architecture specific IDE code.
9 *  In future, SuperH code.
10 */
11
12#ifndef __ASM_SH_IDE_H
13#define __ASM_SH_IDE_H
14
15#ifdef __KERNEL__
16
17#include <linux/config.h>
18#include <asm/machvec.h>
19
20#ifndef MAX_HWIFS
21/* Should never have less than 2, ide-pci.c(ide_match_hwif) requires it */
22#define MAX_HWIFS	2
23#endif
24
25#define ide__sti()	__sti()
26
27static __inline__ int ide_default_irq_hp600(ide_ioreg_t base)
28{
29	switch (base) {
30		case 0x01f0: return 93;
31		case 0x0170: return 94;
32		default:
33			return 0;
34	}
35}
36
37static __inline__ int ide_default_irq(ide_ioreg_t base)
38{
39	if (MACH_HP600) {
40		return ide_default_irq_hp600(base);
41	}
42	switch (base) {
43		case 0x01f0: return 14;
44		case 0x0170: return 15;
45		default:
46			return 0;
47	}
48}
49
50static __inline__ ide_ioreg_t ide_default_io_base_hp600(int index)
51{
52	switch (index) {
53		case 0:
54			return 0x01f0;
55		case 1:
56			return 0x0170;
57		default:
58			return 0;
59	}
60}
61
62static __inline__ ide_ioreg_t ide_default_io_base(int index)
63{
64	if (MACH_HP600) {
65		return ide_default_io_base_hp600(index);
66	}
67	switch (index) {
68		case 0:
69			return 0x1f0;
70		case 1:
71			return 0x170;
72		default:
73			return 0;
74	}
75}
76
77static __inline__ void ide_init_hwif_ports(hw_regs_t *hw, ide_ioreg_t data_port, ide_ioreg_t ctrl_port, int *irq)
78{
79	ide_ioreg_t reg = data_port;
80	int i;
81
82	for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
83		hw->io_ports[i] = reg;
84		reg += 1;
85	}
86	if (ctrl_port) {
87		hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port;
88	} else {
89		hw->io_ports[IDE_CONTROL_OFFSET] = hw->io_ports[IDE_DATA_OFFSET] + 0x206;
90	}
91	if (irq != NULL)
92		*irq = 0;
93	hw->io_ports[IDE_IRQ_OFFSET] = 0;
94}
95
96static __inline__ void ide_init_default_hwifs(void)
97{
98#ifndef CONFIG_BLK_DEV_IDEPCI
99	hw_regs_t hw;
100	int index;
101
102	for(index = 0; index < MAX_HWIFS; index++) {
103		ide_init_hwif_ports(&hw, ide_default_io_base(index), 0, NULL);
104		hw.irq = ide_default_irq(ide_default_io_base(index));
105		ide_register_hw(&hw, NULL);
106	}
107#endif /* CONFIG_BLK_DEV_IDEPCI */
108}
109
110typedef union {
111	unsigned all			: 8;	/* all of the bits together */
112	struct {
113		unsigned head		: 4;	/* always zeros here */
114		unsigned unit		: 1;	/* drive select number, 0 or 1 */
115		unsigned bit5		: 1;	/* always 1 */
116		unsigned lba		: 1;	/* using LBA instead of CHS */
117		unsigned bit7		: 1;	/* always 1 */
118	} b;
119} select_t;
120
121typedef union {
122	unsigned all			: 8;	/* all of the bits together */
123	struct {
124		unsigned bit0		: 1;
125		unsigned nIEN		: 1;	/* device INTRQ to host */
126		unsigned SRST		: 1;	/* host soft reset bit */
127		unsigned bit3		: 1;	/* ATA-2 thingy */
128		unsigned reserved456	: 3;
129		unsigned HOB		: 1;	/* 48-bit address ordering */
130	} b;
131} control_t;
132
133#define ide_request_irq(irq,hand,flg,dev,id)	request_irq((irq),(hand),(flg),(dev),(id))
134#define ide_free_irq(irq,dev_id)		free_irq((irq), (dev_id))
135#define ide_check_region(from,extent)		check_region((from), (extent))
136#define ide_request_region(from,extent,name)	request_region((from), (extent), (name))
137#define ide_release_region(from,extent)		release_region((from), (extent))
138
139/*
140 * The following are not needed for the non-m68k ports
141 */
142#define ide_ack_intr(hwif)		(1)
143#define ide_fix_driveid(id)		do {} while (0)
144#define ide_release_lock(lock)		do {} while (0)
145#define ide_get_lock(lock, hdlr, data)	do {} while (0)
146
147#endif /* __KERNEL__ */
148
149#endif /* __ASM_SH_IDE_H */
150