Blame view

drivers/ide/ide-h8300.c 2.42 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
  /*
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2
3
4
5
6
   * H8/300 generic IDE interface
   */
  
  #include <linux/init.h>
  #include <linux/ide.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
7
8
9
  
  #include <asm/io.h>
  #include <asm/irq.h>
eb3aff553   Bartlomiej Zolnierkiewicz   ide: print messag...
10
  #define DRV_NAME "ide-h8300"
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
11
12
13
14
15
16
17
18
19
20
21
22
23
  #define bswap(d) \
  ({					\
  	u16 r;				\
  	__asm__("mov.b %w1,r1h
  \t"	\
  		"mov.b %x1,r1l
  \t"	\
  		"mov.w r1,%0"		\
  		:"=r"(r)		\
  		:"r"(d)			\
  		:"er1");		\
  	(r);				\
  })
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
24
25
26
27
28
29
30
31
32
33
34
35
36
  static void mm_outsw(unsigned long addr, void *buf, u32 len)
  {
  	unsigned short *bp = (unsigned short *)buf;
  	for (; len > 0; len--, bp++)
  		*(volatile u16 *)addr = bswap(*bp);
  }
  
  static void mm_insw(unsigned long addr, void *buf, u32 len)
  {
  	unsigned short *bp = (unsigned short *)buf;
  	for (; len > 0; len--, bp++)
  		*bp = bswap(*(volatile u16 *)addr);
  }
adb1af980   Bartlomiej Zolnierkiewicz   ide: pass command...
37
  static void h8300_input_data(ide_drive_t *drive, struct ide_cmd *cmd,
f04ff9cbb   Bartlomiej Zolnierkiewicz   ide-h8300: add ->...
38
39
40
41
  			     void *buf, unsigned int len)
  {
  	mm_insw(drive->hwif->io_ports.data_addr, buf, (len + 1) / 2);
  }
adb1af980   Bartlomiej Zolnierkiewicz   ide: pass command...
42
  static void h8300_output_data(ide_drive_t *drive, struct ide_cmd *cmd,
f04ff9cbb   Bartlomiej Zolnierkiewicz   ide-h8300: add ->...
43
44
45
46
  			      void *buf, unsigned int len)
  {
  	mm_outsw(drive->hwif->io_ports.data_addr, buf, (len + 1) / 2);
  }
374e042c3   Bartlomiej Zolnierkiewicz   ide: add struct i...
47
48
49
50
  static const struct ide_tp_ops h8300_tp_ops = {
  	.exec_command		= ide_exec_command,
  	.read_status		= ide_read_status,
  	.read_altstatus		= ide_read_altstatus,
ecf3a31d2   Sergei Shtylyov   ide: turn set_irq...
51
  	.write_devctl		= ide_write_devctl,
374e042c3   Bartlomiej Zolnierkiewicz   ide: add struct i...
52

abb596b25   Sergei Shtylyov   ide: turn selectp...
53
  	.dev_select		= ide_dev_select,
cfd30daa0   Sergei Shtylyov   ide-h8300: remove...
54
55
  	.tf_load		= ide_tf_load,
  	.tf_read		= ide_tf_read,
374e042c3   Bartlomiej Zolnierkiewicz   ide: add struct i...
56
57
58
59
  
  	.input_data		= h8300_input_data,
  	.output_data		= h8300_output_data,
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
60
  #define H8300_IDE_GAP (2)
9f36d3143   Bartlomiej Zolnierkiewicz   ide: remove hw_re...
61
  static inline void hw_setup(struct ide_hw *hw)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
62
63
  {
  	int i;
9f36d3143   Bartlomiej Zolnierkiewicz   ide: remove hw_re...
64
  	memset(hw, 0, sizeof(*hw));
4c3032d8a   Bartlomiej Zolnierkiewicz   ide: add struct i...
65
66
67
  	for (i = 0; i <= 7; i++)
  		hw->io_ports_array[i] = CONFIG_H8300_IDE_BASE + H8300_IDE_GAP*i;
  	hw->io_ports.ctl_addr = CONFIG_H8300_IDE_ALT;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
68
  	hw->irq = EXT_IRQ0 + CONFIG_H8300_IDE_IRQ;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
69
  }
f81eb80bb   Bartlomiej Zolnierkiewicz   ide-h8300: use st...
70
  static const struct ide_port_info h8300_port_info = {
374e042c3   Bartlomiej Zolnierkiewicz   ide: add struct i...
71
  	.tp_ops			= &h8300_tp_ops,
f81eb80bb   Bartlomiej Zolnierkiewicz   ide-h8300: use st...
72
  	.host_flags		= IDE_HFLAG_NO_IO_32BIT | IDE_HFLAG_NO_DMA,
29e52cf79   Bartlomiej Zolnierkiewicz   ide: remove chips...
73
  	.chipset		= ide_generic,
f81eb80bb   Bartlomiej Zolnierkiewicz   ide-h8300: use st...
74
  };
ade2daf9c   Bartlomiej Zolnierkiewicz   ide: make remaini...
75
  static int __init h8300_ide_init(void)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
76
  {
9f36d3143   Bartlomiej Zolnierkiewicz   ide: remove hw_re...
77
  	struct ide_hw hw, *hws[] = { &hw };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
78

740c397cc   Bartlomiej Zolnierkiewicz   ide-h8300: print ...
79
80
  	printk(KERN_INFO DRV_NAME ": H8/300 generic IDE interface
  ");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
81
82
83
84
85
86
87
88
  	if (!request_region(CONFIG_H8300_IDE_BASE, H8300_IDE_GAP*8, "ide-h8300"))
  		goto out_busy;
  	if (!request_region(CONFIG_H8300_IDE_ALT, H8300_IDE_GAP, "ide-h8300")) {
  		release_region(CONFIG_H8300_IDE_BASE, H8300_IDE_GAP*8);
  		goto out_busy;
  	}
  
  	hw_setup(&hw);
dca398305   Bartlomiej Zolnierkiewicz   ide: pass number ...
89
  	return ide_host_add(&h8300_port_info, hws, 1, NULL);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
90
91
92
93
  
  out_busy:
  	printk(KERN_ERR "ide-h8300: IDE I/F resource already used.
  ");
ade2daf9c   Bartlomiej Zolnierkiewicz   ide: make remaini...
94
95
  
  	return -EBUSY;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
96
  }
ade2daf9c   Bartlomiej Zolnierkiewicz   ide: make remaini...
97
98
  
  module_init(h8300_ide_init);
f95dc3200   Adrian Bunk   ide/h8300/ide-h83...
99
100
  
  MODULE_LICENSE("GPL");