1/* 2 * BK Id: SCCS/s.ide.h 1.16 09/28/01 07:54:24 trini 3 */ 4/* 5 * linux/include/asm-ppc/ide.h 6 * 7 * Copyright (C) 1994-1996 Linus Torvalds & authors */ 8 9/* 10 * This file contains the ppc architecture specific IDE code. 11 */ 12 13#ifndef __ASMPPC_IDE_H 14#define __ASMPPC_IDE_H 15 16#ifdef __KERNEL__ 17 18#include <linux/sched.h> 19#include <asm/processor.h> 20#include <asm/mpc8xx.h> 21 22#ifndef MAX_HWIFS 23#define MAX_HWIFS 8 24#endif 25 26#include <asm/hdreg.h> 27 28#include <linux/config.h> 29#include <linux/hdreg.h> 30#include <linux/ioport.h> 31#include <asm/io.h> 32 33extern void ppc_generic_ide_fix_driveid(struct hd_driveid *id); 34 35struct ide_machdep_calls { 36 int (*default_irq)(ide_ioreg_t base); 37 ide_ioreg_t (*default_io_base)(int index); 38 int (*ide_check_region)(ide_ioreg_t from, unsigned int extent); 39 void (*ide_request_region)(ide_ioreg_t from, 40 unsigned int extent, 41 const char *name); 42 void (*ide_release_region)(ide_ioreg_t from, 43 unsigned int extent); 44 void (*ide_init_hwif)(hw_regs_t *hw, 45 ide_ioreg_t data_port, 46 ide_ioreg_t ctrl_port, 47 int *irq); 48}; 49 50extern struct ide_machdep_calls ppc_ide_md; 51 52void ppc_generic_ide_fix_driveid(struct hd_driveid *id); 53#define ide_fix_driveid(id) ppc_generic_ide_fix_driveid((id)) 54 55#undef SUPPORT_SLOW_DATA_PORTS 56#define SUPPORT_SLOW_DATA_PORTS 0 57#undef SUPPORT_VLB_SYNC 58#define SUPPORT_VLB_SYNC 0 59 60#define ide__sti() __sti() 61 62static __inline__ int ide_default_irq(ide_ioreg_t base) 63{ 64 if (ppc_ide_md.default_irq) 65 return ppc_ide_md.default_irq(base); 66 return 0; 67} 68 69static __inline__ ide_ioreg_t ide_default_io_base(int index) 70{ 71 if (ppc_ide_md.default_io_base) 72 return ppc_ide_md.default_io_base(index); 73 return 0; 74} 75 76static __inline__ void ide_init_hwif_ports(hw_regs_t *hw, 77 ide_ioreg_t data_port, 78 ide_ioreg_t ctrl_port, int *irq) 79{ 80 if (ppc_ide_md.ide_init_hwif != NULL) 81 ppc_ide_md.ide_init_hwif(hw, data_port, ctrl_port, irq); 82} 83 84static __inline__ void ide_init_default_hwifs(void) 85{ 86#ifndef CONFIG_BLK_DEV_IDEPCI 87 hw_regs_t hw; 88 int index; 89 ide_ioreg_t base; 90 91 for (index = 0; index < MAX_HWIFS; index++) { 92 base = ide_default_io_base(index); 93 if (base == 0) 94 continue; 95 ide_init_hwif_ports(&hw, base, 0, NULL); 96 hw.irq = ide_default_irq(base); 97 ide_register_hw(&hw, NULL); 98 } 99#endif /* CONFIG_BLK_DEV_IDEPCI */ 100} 101 102static __inline__ int ide_check_region (ide_ioreg_t from, unsigned int extent) 103{ 104 if (ppc_ide_md.ide_check_region) 105 return ppc_ide_md.ide_check_region(from, extent); 106 return 0; 107} 108 109static __inline__ void ide_request_region (ide_ioreg_t from, unsigned int extent, const char *name) 110{ 111 if (ppc_ide_md.ide_request_region) 112 ppc_ide_md.ide_request_region(from, extent, name); 113} 114 115static __inline__ void ide_release_region (ide_ioreg_t from, unsigned int extent) 116{ 117 if (ppc_ide_md.ide_release_region) 118 ppc_ide_md.ide_release_region(from, extent); 119} 120 121typedef union { 122 unsigned all : 8; /* all of the bits together */ 123 struct { 124 unsigned bit7 : 1; /* always 1 */ 125 unsigned lba : 1; /* using LBA instead of CHS */ 126 unsigned bit5 : 1; /* always 1 */ 127 unsigned unit : 1; /* drive select number, 0/1 */ 128 unsigned head : 4; /* always zeros here */ 129 } b; 130} select_t; 131 132typedef union { 133 unsigned all : 8; /* all of the bits together */ 134 struct { 135 unsigned HOB : 1; /* 48-bit address ordering */ 136 unsigned reserved456 : 3; 137 unsigned bit3 : 1; /* ATA-2 thingy */ 138 unsigned SRST : 1; /* host soft reset bit */ 139 unsigned nIEN : 1; /* device INTRQ to host */ 140 unsigned bit0 : 1; 141 } b; 142} control_t; 143 144#if !defined(ide_request_irq) 145#define ide_request_irq(irq,hand,flg,dev,id) request_irq((irq),(hand),(flg),(dev),(id)) 146#endif 147 148#if !defined(ide_free_irq) 149#define ide_free_irq(irq,dev_id) free_irq((irq), (dev_id)) 150#endif 151 152/* 153 * The following are not needed for the non-m68k ports 154 * unless direct IDE on 8xx 155 */ 156#if defined CONFIG_APUS || defined CONFIG_BLK_DEV_MPC8xx_IDE 157#define ide_ack_intr(hwif) (hwif->hw.ack_intr ? hwif->hw.ack_intr(hwif) : 1) 158#else 159#define ide_ack_intr(hwif) (1) 160#endif 161#define ide_release_lock(lock) do {} while (0) 162#define ide_get_lock(lock, hdlr, data) do {} while (0) 163 164#endif /* __KERNEL__ */ 165 166#endif /* __ASMPPC_IDE_H */ 167