sdmmc_ioreg.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /* $OpenBSD: sdmmc_ioreg.h,v 1.4 2007/06/02 01:48:37 uwe Exp $ */
  2. /*
  3. * Copyright (c) 2006 Uwe Stuehler <uwe@openbsd.org>
  4. *
  5. * Permission to use, copy, modify, and distribute this software for any
  6. * purpose with or without fee is hereby granted, provided that the above
  7. * copyright notice and this permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  10. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  11. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  12. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  13. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  14. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  15. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  16. */
  17. #ifndef _SDMMC_IOREG_H
  18. #define _SDMMC_IOREG_H
  19. /* SDIO commands */ /* response type */
  20. #define SD_IO_SEND_OP_COND 5 /* R4 */
  21. #define SD_IO_RW_DIRECT 52 /* R5 */
  22. #define SD_IO_RW_EXTENDED 53 /* R5? */
  23. /* CMD52 arguments */
  24. #define SD_ARG_CMD52_READ (0<<31)
  25. #define SD_ARG_CMD52_WRITE (1<<31)
  26. #define SD_ARG_CMD52_FUNC_SHIFT 28
  27. #define SD_ARG_CMD52_FUNC_MASK 0x7
  28. #define SD_ARG_CMD52_EXCHANGE (1<<27)
  29. #define SD_ARG_CMD52_REG_SHIFT 9
  30. #define SD_ARG_CMD52_REG_MASK 0x1ffff
  31. #define SD_ARG_CMD52_DATA_SHIFT 0
  32. #define SD_ARG_CMD52_DATA_MASK 0xff
  33. #define SD_R5_DATA(resp) ((resp)[0] & 0xff)
  34. /* CMD53 arguments */
  35. #define SD_ARG_CMD53_READ (0<<31)
  36. #define SD_ARG_CMD53_WRITE (1<<31)
  37. #define SD_ARG_CMD53_FUNC_SHIFT 28
  38. #define SD_ARG_CMD53_FUNC_MASK 0x7
  39. #define SD_ARG_CMD53_BLOCK_MODE (1<<27)
  40. #define SD_ARG_CMD53_INCREMENT (1<<26)
  41. #define SD_ARG_CMD53_REG_SHIFT 9
  42. #define SD_ARG_CMD53_REG_MASK 0x1ffff
  43. #define SD_ARG_CMD53_LENGTH_SHIFT 0
  44. #define SD_ARG_CMD53_LENGTH_MASK 0x1ff
  45. #define SD_ARG_CMD53_LENGTH_MAX 64 /* XXX should be 511? */
  46. /* 48-bit response decoding (32 bits w/o CRC) */
  47. #define MMC_R4(resp) ((resp)[0])
  48. #define MMC_R5(resp) ((resp)[0])
  49. /* SD R4 response (IO OCR) */
  50. #define SD_IO_OCR_MEM_READY (1<<31)
  51. #define SD_IO_OCR_NUM_FUNCTIONS(ocr) (((ocr) >> 28) & 0x3)
  52. /* XXX big fat memory present "flag" because we don't know better */
  53. #define SD_IO_OCR_MEM_PRESENT (0xf<<24)
  54. #define SD_IO_OCR_MASK 0x00fffff0
  55. /* Card Common Control Registers (CCCR) */
  56. #define SD_IO_CCCR_START 0x00000
  57. #define SD_IO_CCCR_SIZE 0x100
  58. #define SD_IO_CCCR_FN_ENABLE 0x02
  59. #define SD_IO_CCCR_FN_READY 0x03
  60. #define SD_IO_CCCR_INT_ENABLE 0x04
  61. #define SD_IO_CCCR_CTL 0x06
  62. #define CCCR_CTL_RES (1<<3)
  63. #define SD_IO_CCCR_BUS_WIDTH 0x07
  64. #define CCCR_BUS_WIDTH_4 (1<<1)
  65. #define CCCR_BUS_WIDTH_1 (1<<0)
  66. #define SD_IO_CCCR_CISPTR 0x09 /* XXX 9-10, 10-11, or 9-12 */
  67. /* Function Basic Registers (FBR) */
  68. #define SD_IO_FBR_START 0x00100
  69. #define SD_IO_FBR_SIZE 0x00700
  70. /* Card Information Structure (CIS) */
  71. #define SD_IO_CIS_START 0x01000
  72. #define SD_IO_CIS_SIZE 0x17000
  73. /* CIS tuple codes (based on PC Card 16) */
  74. #define SD_IO_CISTPL_VERS_1 0x15
  75. #define SD_IO_CISTPL_MANFID 0x20
  76. #define SD_IO_CISTPL_FUNCID 0x21
  77. #define SD_IO_CISTPL_FUNCE 0x22
  78. /* CISTPL_FUNCID codes */
  79. #define SDMMC_FUNCTION_WLAN 0x0c
  80. #endif