2 * Copyright 2008, Michael Lotz. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 #include <KernelExport.h>
9 #include <ata_adapter.h>
11 #define IT8211_CONTROLLER_MODULE_NAME "busses/ata/it8211/driver_v1"
12 #define IT8211_CHANNEL_MODULE_NAME "busses/ata/it8211/channel/v1"
14 #define PCI_VENDOR_ITE 0x1283
15 #define PCI_DEVICE_ITE_IT8211 0x8211
17 static ata_adapter_interface
*sATAAdapter
;
18 static device_manager_info
*sDeviceManager
;
22 it8211_set_channel(void *channelCookie
, ata_channel channel
)
24 sATAAdapter
->set_channel((ata_adapter_channel_info
*)channelCookie
,
30 it8211_write_command_block_regs(void *channelCookie
, ata_task_file
*taskFile
,
31 ata_reg_mask registerMask
)
33 return sATAAdapter
->write_command_block_regs(
34 (ata_adapter_channel_info
*)channelCookie
, taskFile
, registerMask
);
39 it8211_read_command_block_regs(void *channelCookie
, ata_task_file
*taskFile
,
40 ata_reg_mask registerMask
)
42 return sATAAdapter
->read_command_block_regs(
43 (ata_adapter_channel_info
*)channelCookie
, taskFile
, registerMask
);
48 it8211_get_altstatus(void *channelCookie
)
50 return sATAAdapter
->get_altstatus((ata_adapter_channel_info
*)channelCookie
);
55 it8211_write_device_control(void *channelCookie
, uint8 value
)
57 return sATAAdapter
->write_device_control(
58 (ata_adapter_channel_info
*)channelCookie
, value
);
63 it8211_write_pio(void *channelCookie
, uint16
*data
, int count
, bool force16bit
)
65 return sATAAdapter
->write_pio(
66 (ata_adapter_channel_info
*)channelCookie
, data
, count
, force16bit
);
71 it8211_read_pio(void *channelCookie
, uint16
*data
, int count
, bool force16bit
)
73 return sATAAdapter
->read_pio(
74 (ata_adapter_channel_info
*)channelCookie
, data
, count
, force16bit
);
79 it8211_prepare_dma(void *channelCookie
, const physical_entry
*sgList
,
80 size_t sgListCount
, bool toDevice
)
82 return sATAAdapter
->prepare_dma((ata_adapter_channel_info
*)channelCookie
,
83 sgList
, sgListCount
, toDevice
);
88 it8211_start_dma(void *channelCookie
)
90 return sATAAdapter
->start_dma((ata_adapter_channel_info
*)channelCookie
);
95 it8211_finish_dma(void *channelCookie
)
97 return sATAAdapter
->finish_dma((ata_adapter_channel_info
*)channelCookie
);
102 init_channel(device_node
*node
, void **channelCookie
)
104 return sATAAdapter
->init_channel(node
,
105 (ata_adapter_channel_info
**)channelCookie
,
106 sizeof(ata_adapter_channel_info
), sATAAdapter
->inthand
);
111 uninit_channel(void *channelCookie
)
113 sATAAdapter
->uninit_channel((ata_adapter_channel_info
*)channelCookie
);
118 channel_removed(void *channelCookie
)
120 sATAAdapter
->channel_removed((ata_adapter_channel_info
*)channelCookie
);
125 init_controller(device_node
*node
, void **cookie
)
127 return sATAAdapter
->init_controller(node
,
128 (ata_adapter_controller_info
**)cookie
,
129 sizeof(ata_adapter_controller_info
));
134 uninit_controller(void *cookie
)
136 sATAAdapter
->uninit_controller((ata_adapter_controller_info
*)cookie
);
141 controller_removed(void *cookie
)
143 sATAAdapter
->controller_removed((ata_adapter_controller_info
*)cookie
);
148 probe_controller(device_node
*parent
)
150 return sATAAdapter
->probe_controller(parent
,
151 IT8211_CONTROLLER_MODULE_NAME
, "it8211",
152 "ITE IT8211", IT8211_CHANNEL_MODULE_NAME
,
154 true, /* command queuing */
155 1, /* 16 bit alignment */
156 0xffff, /* 64k boundary */
157 0x10000, /* up to 64k per scatter/gather block */
158 false); /* no compatibility mode */
163 supports_device(device_node
*parent
)
169 if (sDeviceManager
->get_attr_string(parent
, B_DEVICE_BUS
, &bus
, false) != B_OK
170 || sDeviceManager
->get_attr_uint16(parent
, B_DEVICE_VENDOR_ID
, &vendorID
, false) != B_OK
171 || sDeviceManager
->get_attr_uint16(parent
, B_DEVICE_ID
, &deviceID
, false) != B_OK
) {
175 if (strcmp(bus
, "pci") != 0 || vendorID
!= PCI_VENDOR_ITE
176 || deviceID
!= PCI_DEVICE_ITE_IT8211
)
183 module_dependency module_dependencies
[] = {
184 { B_DEVICE_MANAGER_MODULE_NAME
, (module_info
**)&sDeviceManager
},
185 { ATA_ADAPTER_MODULE_NAME
, (module_info
**)&sATAAdapter
},
190 // exported interface
191 static ata_controller_interface sChannelInterface
= {
194 IT8211_CHANNEL_MODULE_NAME
,
199 NULL
, // supports device
200 NULL
, // register device
203 NULL
, // register child devices
209 &it8211_write_command_block_regs
,
210 &it8211_read_command_block_regs
,
211 &it8211_get_altstatus
,
212 &it8211_write_device_control
,
221 static driver_module_info sControllerInterface
= {
223 IT8211_CONTROLLER_MODULE_NAME
,
232 NULL
, // register child devices
238 module_info
*modules
[] = {
239 (module_info
*)&sControllerInterface
,
240 (module_info
*)&sChannelInterface
,