alauda.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * Driver for Alauda-based card readers
  3. *
  4. * Current development and maintenance by:
  5. * (c) 2005 Daniel Drake <dsd@gentoo.org>
  6. *
  7. * See alauda.c for more explanation.
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License as published by the
  11. * Free Software Foundation; either version 2, or (at your option) any
  12. * later version.
  13. *
  14. * This program is distributed in the hope that it will be useful, but
  15. * WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License along
  20. * with this program; if not, write to the Free Software Foundation, Inc.,
  21. * 675 Mass Ave, Cambridge, MA 02139, USA.
  22. */
  23. #ifndef _USB_ALAUDA_H
  24. #define _USB_ALAUDA_H
  25. /*
  26. * Status bytes
  27. */
  28. #define ALAUDA_STATUS_ERROR 0x01
  29. #define ALAUDA_STATUS_READY 0x40
  30. /*
  31. * Control opcodes (for request field)
  32. */
  33. #define ALAUDA_GET_XD_MEDIA_STATUS 0x08
  34. #define ALAUDA_GET_SM_MEDIA_STATUS 0x98
  35. #define ALAUDA_ACK_XD_MEDIA_CHANGE 0x0a
  36. #define ALAUDA_ACK_SM_MEDIA_CHANGE 0x9a
  37. #define ALAUDA_GET_XD_MEDIA_SIG 0x86
  38. #define ALAUDA_GET_SM_MEDIA_SIG 0x96
  39. /*
  40. * Bulk command identity (byte 0)
  41. */
  42. #define ALAUDA_BULK_CMD 0x40
  43. /*
  44. * Bulk opcodes (byte 1)
  45. */
  46. #define ALAUDA_BULK_GET_REDU_DATA 0x85
  47. #define ALAUDA_BULK_READ_BLOCK 0x94
  48. #define ALAUDA_BULK_ERASE_BLOCK 0xa3
  49. #define ALAUDA_BULK_WRITE_BLOCK 0xb4
  50. #define ALAUDA_BULK_GET_STATUS2 0xb7
  51. #define ALAUDA_BULK_RESET_MEDIA 0xe0
  52. /*
  53. * Port to operate on (byte 8)
  54. */
  55. #define ALAUDA_PORT_XD 0x00
  56. #define ALAUDA_PORT_SM 0x01
  57. /*
  58. * LBA and PBA are unsigned ints. Special values.
  59. */
  60. #define UNDEF 0xffff
  61. #define SPARE 0xfffe
  62. #define UNUSABLE 0xfffd
  63. int init_alauda(struct us_data *us);
  64. int alauda_transport(struct scsi_cmnd *srb, struct us_data *us);
  65. struct alauda_media_info {
  66. unsigned long capacity; /* total media size in bytes */
  67. unsigned int pagesize; /* page size in bytes */
  68. unsigned int blocksize; /* number of pages per block */
  69. unsigned int uzonesize; /* number of usable blocks per zone */
  70. unsigned int zonesize; /* number of blocks per zone */
  71. unsigned int blockmask; /* mask to get page from address */
  72. unsigned char pageshift;
  73. unsigned char blockshift;
  74. unsigned char zoneshift;
  75. u16 **lba_to_pba; /* logical to physical block map */
  76. u16 **pba_to_lba; /* physical to logical block map */
  77. };
  78. struct alauda_info {
  79. struct alauda_media_info port[2];
  80. int wr_ep; /* endpoint to write data out of */
  81. unsigned char sense_key;
  82. unsigned long sense_asc; /* additional sense code */
  83. unsigned long sense_ascq; /* additional sense code qualifier */
  84. };
  85. #endif