cdu31a.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. /*
  2. * Definitions for a Sony interface CDROM drive.
  3. *
  4. * Corey Minyard (minyard@wf-rch.cirr.com)
  5. *
  6. * Copyright (C) 1993 Corey Minyard
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21. *
  22. */
  23. /*
  24. * General defines.
  25. */
  26. #define SONY_XA_DISK_TYPE 0x20
  27. /*
  28. * Offsets (from the base address) and bits for the various write registers
  29. * of the drive.
  30. */
  31. #define SONY_CMD_REG_OFFSET 0
  32. #define SONY_PARAM_REG_OFFSET 1
  33. #define SONY_WRITE_REG_OFFSET 2
  34. #define SONY_CONTROL_REG_OFFSET 3
  35. # define SONY_ATTN_CLR_BIT 0x01
  36. # define SONY_RES_RDY_CLR_BIT 0x02
  37. # define SONY_DATA_RDY_CLR_BIT 0x04
  38. # define SONY_ATTN_INT_EN_BIT 0x08
  39. # define SONY_RES_RDY_INT_EN_BIT 0x10
  40. # define SONY_DATA_RDY_INT_EN_BIT 0x20
  41. # define SONY_PARAM_CLR_BIT 0x40
  42. # define SONY_DRIVE_RESET_BIT 0x80
  43. /*
  44. * Offsets (from the base address) and bits for the various read registers
  45. * of the drive.
  46. */
  47. #define SONY_STATUS_REG_OFFSET 0
  48. # define SONY_ATTN_BIT 0x01
  49. # define SONY_RES_RDY_BIT 0x02
  50. # define SONY_DATA_RDY_BIT 0x04
  51. # define SONY_ATTN_INT_ST_BIT 0x08
  52. # define SONY_RES_RDY_INT_ST_BIT 0x10
  53. # define SONY_DATA_RDY_INT_ST_BIT 0x20
  54. # define SONY_DATA_REQUEST_BIT 0x40
  55. # define SONY_BUSY_BIT 0x80
  56. #define SONY_RESULT_REG_OFFSET 1
  57. #define SONY_READ_REG_OFFSET 2
  58. #define SONY_FIFOST_REG_OFFSET 3
  59. # define SONY_PARAM_WRITE_RDY_BIT 0x01
  60. # define SONY_PARAM_REG_EMPTY_BIT 0x02
  61. # define SONY_RES_REG_NOT_EMP_BIT 0x04
  62. # define SONY_RES_REG_FULL_BIT 0x08
  63. #define LOG_START_OFFSET 150 /* Offset of first logical sector */
  64. #define SONY_DETECT_TIMEOUT (8*HZ/10) /* Maximum amount of time
  65. that drive detection code
  66. will wait for response
  67. from drive (in 1/100th's
  68. of seconds). */
  69. #define SONY_JIFFIES_TIMEOUT (10*HZ) /* Maximum number of times the
  70. drive will wait/try for an
  71. operation */
  72. #define SONY_RESET_TIMEOUT HZ /* Maximum number of times the
  73. drive will wait/try a reset
  74. operation */
  75. #define SONY_READY_RETRIES 20000 /* How many times to retry a
  76. spin waiting for a register
  77. to come ready */
  78. #define MAX_CDU31A_RETRIES 3 /* How many times to retry an
  79. operation */
  80. /* Commands to request or set drive control parameters and disc information */
  81. #define SONY_REQ_DRIVE_CONFIG_CMD 0x00 /* Returns s_sony_drive_config */
  82. #define SONY_REQ_DRIVE_MODE_CMD 0x01
  83. #define SONY_REQ_DRIVE_PARAM_CMD 0x02
  84. #define SONY_REQ_MECH_STATUS_CMD 0x03
  85. #define SONY_REQ_AUDIO_STATUS_CMD 0x04
  86. #define SONY_SET_DRIVE_PARAM_CMD 0x10
  87. #define SONY_REQ_TOC_DATA_CMD 0x20 /* Returns s_sony_toc */
  88. #define SONY_REQ_SUBCODE_ADDRESS_CMD 0x21 /* Returns s_sony_subcode */
  89. #define SONY_REQ_UPC_EAN_CMD 0x22
  90. #define SONY_REQ_ISRC_CMD 0x23
  91. #define SONY_REQ_TOC_DATA_SPEC_CMD 0x24 /* Returns s_sony_session_toc */
  92. /* Commands to request information from the drive */
  93. #define SONY_READ_TOC_CMD 0x30 /* let the drive firmware grab the TOC */
  94. #define SONY_SEEK_CMD 0x31
  95. #define SONY_READ_CMD 0x32
  96. #define SONY_READ_BLKERR_STAT_CMD 0x34
  97. #define SONY_ABORT_CMD 0x35
  98. #define SONY_READ_TOC_SPEC_CMD 0x36
  99. /* Commands to control audio */
  100. #define SONY_AUDIO_PLAYBACK_CMD 0x40
  101. #define SONY_AUDIO_STOP_CMD 0x41
  102. #define SONY_AUDIO_SCAN_CMD 0x42
  103. /* Miscellaneous control commands */
  104. #define SONY_EJECT_CMD 0x50
  105. #define SONY_SPIN_UP_CMD 0x51
  106. #define SONY_SPIN_DOWN_CMD 0x52
  107. /* Diagnostic commands */
  108. #define SONY_WRITE_BUFFER_CMD 0x60
  109. #define SONY_READ_BUFFER_CMD 0x61
  110. #define SONY_DIAGNOSTICS_CMD 0x62
  111. /*
  112. * The following are command parameters for the set drive parameter command
  113. */
  114. #define SONY_SD_DECODE_PARAM 0x00
  115. #define SONY_SD_INTERFACE_PARAM 0x01
  116. #define SONY_SD_BUFFERING_PARAM 0x02
  117. #define SONY_SD_AUDIO_PARAM 0x03
  118. #define SONY_SD_AUDIO_VOLUME 0x04
  119. #define SONY_SD_MECH_CONTROL 0x05
  120. #define SONY_SD_AUTO_SPIN_DOWN_TIME 0x06
  121. /*
  122. * The following are parameter bits for the mechanical control command
  123. */
  124. #define SONY_AUTO_SPIN_UP_BIT 0x01
  125. #define SONY_AUTO_EJECT_BIT 0x02
  126. #define SONY_DOUBLE_SPEED_BIT 0x04
  127. /*
  128. * The following extract information from the drive configuration about
  129. * the drive itself.
  130. */
  131. #define SONY_HWC_GET_LOAD_MECH(c) (c.hw_config[0] & 0x03)
  132. #define SONY_HWC_EJECT(c) (c.hw_config[0] & 0x04)
  133. #define SONY_HWC_LED_SUPPORT(c) (c.hw_config[0] & 0x08)
  134. #define SONY_HWC_DOUBLE_SPEED(c) (c.hw_config[0] & 0x10)
  135. #define SONY_HWC_GET_BUF_MEM_SIZE(c) ((c.hw_config[0] & 0xc0) >> 6)
  136. #define SONY_HWC_AUDIO_PLAYBACK(c) (c.hw_config[1] & 0x01)
  137. #define SONY_HWC_ELECTRIC_VOLUME(c) (c.hw_config[1] & 0x02)
  138. #define SONY_HWC_ELECTRIC_VOLUME_CTL(c) (c.hw_config[1] & 0x04)
  139. #define SONY_HWC_CADDY_LOAD_MECH 0x00
  140. #define SONY_HWC_TRAY_LOAD_MECH 0x01
  141. #define SONY_HWC_POPUP_LOAD_MECH 0x02
  142. #define SONY_HWC_UNKWN_LOAD_MECH 0x03
  143. #define SONY_HWC_8KB_BUFFER 0x00
  144. #define SONY_HWC_32KB_BUFFER 0x01
  145. #define SONY_HWC_64KB_BUFFER 0x02
  146. #define SONY_HWC_UNKWN_BUFFER 0x03
  147. /*
  148. * This is the complete status returned from the drive configuration request
  149. * command.
  150. */
  151. struct s_sony_drive_config
  152. {
  153. unsigned char exec_status[2];
  154. char vendor_id[8];
  155. char product_id[16];
  156. char product_rev_level[8];
  157. unsigned char hw_config[2];
  158. };
  159. /* The following is returned from the request subcode address command */
  160. struct s_sony_subcode
  161. {
  162. unsigned char exec_status[2];
  163. unsigned char address :4;
  164. unsigned char control :4;
  165. unsigned char track_num;
  166. unsigned char index_num;
  167. unsigned char rel_msf[3];
  168. unsigned char reserved1;
  169. unsigned char abs_msf[3];
  170. };
  171. #define MAX_TRACKS 100 /* The maximum tracks a disk may have. */
  172. /*
  173. * The following is returned from the request TOC (Table Of Contents) command.
  174. * (last_track_num-first_track_num+1) values are valid in tracks.
  175. */
  176. struct s_sony_toc
  177. {
  178. unsigned char exec_status[2];
  179. unsigned char address0 :4;
  180. unsigned char control0 :4;
  181. unsigned char point0;
  182. unsigned char first_track_num;
  183. unsigned char disk_type;
  184. unsigned char dummy0;
  185. unsigned char address1 :4;
  186. unsigned char control1 :4;
  187. unsigned char point1;
  188. unsigned char last_track_num;
  189. unsigned char dummy1;
  190. unsigned char dummy2;
  191. unsigned char address2 :4;
  192. unsigned char control2 :4;
  193. unsigned char point2;
  194. unsigned char lead_out_start_msf[3];
  195. struct
  196. {
  197. unsigned char address :4;
  198. unsigned char control :4;
  199. unsigned char track;
  200. unsigned char track_start_msf[3];
  201. } tracks[MAX_TRACKS];
  202. unsigned int lead_out_start_lba;
  203. };
  204. struct s_sony_session_toc
  205. {
  206. unsigned char exec_status[2];
  207. unsigned char session_number;
  208. unsigned char address0 :4;
  209. unsigned char control0 :4;
  210. unsigned char point0;
  211. unsigned char first_track_num;
  212. unsigned char disk_type;
  213. unsigned char dummy0;
  214. unsigned char address1 :4;
  215. unsigned char control1 :4;
  216. unsigned char point1;
  217. unsigned char last_track_num;
  218. unsigned char dummy1;
  219. unsigned char dummy2;
  220. unsigned char address2 :4;
  221. unsigned char control2 :4;
  222. unsigned char point2;
  223. unsigned char lead_out_start_msf[3];
  224. unsigned char addressb0 :4;
  225. unsigned char controlb0 :4;
  226. unsigned char pointb0;
  227. unsigned char next_poss_prog_area_msf[3];
  228. unsigned char num_mode_5_pointers;
  229. unsigned char max_start_outer_leadout_msf[3];
  230. unsigned char addressb1 :4;
  231. unsigned char controlb1 :4;
  232. unsigned char pointb1;
  233. unsigned char dummyb0_1[4];
  234. unsigned char num_skip_interval_pointers;
  235. unsigned char num_skip_track_assignments;
  236. unsigned char dummyb0_2;
  237. unsigned char addressb2 :4;
  238. unsigned char controlb2 :4;
  239. unsigned char pointb2;
  240. unsigned char tracksb2[7];
  241. unsigned char addressb3 :4;
  242. unsigned char controlb3 :4;
  243. unsigned char pointb3;
  244. unsigned char tracksb3[7];
  245. unsigned char addressb4 :4;
  246. unsigned char controlb4 :4;
  247. unsigned char pointb4;
  248. unsigned char tracksb4[7];
  249. unsigned char addressc0 :4;
  250. unsigned char controlc0 :4;
  251. unsigned char pointc0;
  252. unsigned char dummyc0[7];
  253. struct
  254. {
  255. unsigned char address :4;
  256. unsigned char control :4;
  257. unsigned char track;
  258. unsigned char track_start_msf[3];
  259. } tracks[MAX_TRACKS];
  260. unsigned int start_track_lba;
  261. unsigned int lead_out_start_lba;
  262. unsigned int mint;
  263. unsigned int maxt;
  264. };
  265. struct s_all_sessions_toc
  266. {
  267. unsigned char sessions;
  268. unsigned int track_entries;
  269. unsigned char first_track_num;
  270. unsigned char last_track_num;
  271. unsigned char disk_type;
  272. unsigned char lead_out_start_msf[3];
  273. struct
  274. {
  275. unsigned char address :4;
  276. unsigned char control :4;
  277. unsigned char track;
  278. unsigned char track_start_msf[3];
  279. } tracks[MAX_TRACKS];
  280. unsigned int start_track_lba;
  281. unsigned int lead_out_start_lba;
  282. };
  283. /*
  284. * The following are errors returned from the drive.
  285. */
  286. /* Command error group */
  287. #define SONY_ILL_CMD_ERR 0x10
  288. #define SONY_ILL_PARAM_ERR 0x11
  289. /* Mechanism group */
  290. #define SONY_NOT_LOAD_ERR 0x20
  291. #define SONY_NO_DISK_ERR 0x21
  292. #define SONY_NOT_SPIN_ERR 0x22
  293. #define SONY_SPIN_ERR 0x23
  294. #define SONY_SPINDLE_SERVO_ERR 0x25
  295. #define SONY_FOCUS_SERVO_ERR 0x26
  296. #define SONY_EJECT_MECH_ERR 0x29
  297. #define SONY_AUDIO_PLAYING_ERR 0x2a
  298. #define SONY_EMERGENCY_EJECT_ERR 0x2c
  299. /* Seek error group */
  300. #define SONY_FOCUS_ERR 0x30
  301. #define SONY_FRAME_SYNC_ERR 0x31
  302. #define SONY_SUBCODE_ADDR_ERR 0x32
  303. #define SONY_BLOCK_SYNC_ERR 0x33
  304. #define SONY_HEADER_ADDR_ERR 0x34
  305. /* Read error group */
  306. #define SONY_ILL_TRACK_R_ERR 0x40
  307. #define SONY_MODE_0_R_ERR 0x41
  308. #define SONY_ILL_MODE_R_ERR 0x42
  309. #define SONY_ILL_BLOCK_SIZE_R_ERR 0x43
  310. #define SONY_MODE_R_ERR 0x44
  311. #define SONY_FORM_R_ERR 0x45
  312. #define SONY_LEAD_OUT_R_ERR 0x46
  313. #define SONY_BUFFER_OVERRUN_R_ERR 0x47
  314. /* Data error group */
  315. #define SONY_UNREC_CIRC_ERR 0x53
  316. #define SONY_UNREC_LECC_ERR 0x57
  317. /* Subcode error group */
  318. #define SONY_NO_TOC_ERR 0x60
  319. #define SONY_SUBCODE_DATA_NVAL_ERR 0x61
  320. #define SONY_FOCUS_ON_TOC_READ_ERR 0x63
  321. #define SONY_FRAME_SYNC_ON_TOC_READ_ERR 0x64
  322. #define SONY_TOC_DATA_ERR 0x65
  323. /* Hardware failure group */
  324. #define SONY_HW_FAILURE_ERR 0x70
  325. #define SONY_LEAD_IN_A_ERR 0x91
  326. #define SONY_LEAD_OUT_A_ERR 0x92
  327. #define SONY_DATA_TRACK_A_ERR 0x93
  328. /*
  329. * The following are returned from the Read With Block Error Status command.
  330. * They are not errors but information (Errors from the 0x5x group above may
  331. * also be returned
  332. */
  333. #define SONY_NO_CIRC_ERR_BLK_STAT 0x50
  334. #define SONY_NO_LECC_ERR_BLK_STAT 0x54
  335. #define SONY_RECOV_LECC_ERR_BLK_STAT 0x55
  336. #define SONY_NO_ERR_DETECTION_STAT 0x59
  337. /*
  338. * The following is not an error returned by the drive, but by the code
  339. * that talks to the drive. It is returned because of a timeout.
  340. */
  341. #define SONY_TIMEOUT_OP_ERR 0x01
  342. #define SONY_SIGNAL_OP_ERR 0x02
  343. #define SONY_BAD_DATA_ERR 0x03
  344. /*
  345. * The following are attention code for asynchronous events from the drive.
  346. */
  347. /* Standard attention group */
  348. #define SONY_EMER_EJECT_ATTN 0x2c
  349. #define SONY_HW_FAILURE_ATTN 0x70
  350. #define SONY_MECH_LOADED_ATTN 0x80
  351. #define SONY_EJECT_PUSHED_ATTN 0x81
  352. /* Audio attention group */
  353. #define SONY_AUDIO_PLAY_DONE_ATTN 0x90
  354. #define SONY_LEAD_IN_ERR_ATTN 0x91
  355. #define SONY_LEAD_OUT_ERR_ATTN 0x92
  356. #define SONY_DATA_TRACK_ERR_ATTN 0x93
  357. #define SONY_AUDIO_PLAYBACK_ERR_ATTN 0x94
  358. /* Auto spin up group */
  359. #define SONY_SPIN_UP_COMPLETE_ATTN 0x24
  360. #define SONY_SPINDLE_SERVO_ERR_ATTN 0x25
  361. #define SONY_FOCUS_SERVO_ERR_ATTN 0x26
  362. #define SONY_TOC_READ_DONE_ATTN 0x62
  363. #define SONY_FOCUS_ON_TOC_READ_ERR_ATTN 0x63
  364. #define SONY_SYNC_ON_TOC_READ_ERR_ATTN 0x65
  365. /* Auto eject group */
  366. #define SONY_SPIN_DOWN_COMPLETE_ATTN 0x27
  367. #define SONY_EJECT_COMPLETE_ATTN 0x28
  368. #define SONY_EJECT_MECH_ERR_ATTN 0x29