cafe_ccic-regs.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /*
  2. * Register definitions for the m88alp01 camera interface. Offsets in bytes
  3. * as given in the spec.
  4. *
  5. * Copyright 2006 One Laptop Per Child Association, Inc.
  6. *
  7. * Written by Jonathan Corbet, corbet@lwn.net.
  8. *
  9. * This file may be distributed under the terms of the GNU General
  10. * Public License, version 2.
  11. */
  12. #define REG_Y0BAR 0x00
  13. #define REG_Y1BAR 0x04
  14. #define REG_Y2BAR 0x08
  15. /* ... */
  16. #define REG_IMGPITCH 0x24 /* Image pitch register */
  17. #define IMGP_YP_SHFT 2 /* Y pitch params */
  18. #define IMGP_YP_MASK 0x00003ffc /* Y pitch field */
  19. #define IMGP_UVP_SHFT 18 /* UV pitch (planar) */
  20. #define IMGP_UVP_MASK 0x3ffc0000
  21. #define REG_IRQSTATRAW 0x28 /* RAW IRQ Status */
  22. #define IRQ_EOF0 0x00000001 /* End of frame 0 */
  23. #define IRQ_EOF1 0x00000002 /* End of frame 1 */
  24. #define IRQ_EOF2 0x00000004 /* End of frame 2 */
  25. #define IRQ_SOF0 0x00000008 /* Start of frame 0 */
  26. #define IRQ_SOF1 0x00000010 /* Start of frame 1 */
  27. #define IRQ_SOF2 0x00000020 /* Start of frame 2 */
  28. #define IRQ_OVERFLOW 0x00000040 /* FIFO overflow */
  29. #define IRQ_TWSIW 0x00010000 /* TWSI (smbus) write */
  30. #define IRQ_TWSIR 0x00020000 /* TWSI read */
  31. #define IRQ_TWSIE 0x00040000 /* TWSI error */
  32. #define TWSIIRQS (IRQ_TWSIW|IRQ_TWSIR|IRQ_TWSIE)
  33. #define FRAMEIRQS (IRQ_EOF0|IRQ_EOF1|IRQ_EOF2|IRQ_SOF0|IRQ_SOF1|IRQ_SOF2)
  34. #define ALLIRQS (TWSIIRQS|FRAMEIRQS|IRQ_OVERFLOW)
  35. #define REG_IRQMASK 0x2c /* IRQ mask - same bits as IRQSTAT */
  36. #define REG_IRQSTAT 0x30 /* IRQ status / clear */
  37. #define REG_IMGSIZE 0x34 /* Image size */
  38. #define IMGSZ_V_MASK 0x1fff0000
  39. #define IMGSZ_V_SHIFT 16
  40. #define IMGSZ_H_MASK 0x00003fff
  41. #define REG_IMGOFFSET 0x38 /* IMage offset */
  42. #define REG_CTRL0 0x3c /* Control 0 */
  43. #define C0_ENABLE 0x00000001 /* Makes the whole thing go */
  44. /* Mask for all the format bits */
  45. #define C0_DF_MASK 0x00fffffc /* Bits 2-23 */
  46. /* RGB ordering */
  47. #define C0_RGB4_RGBX 0x00000000
  48. #define C0_RGB4_XRGB 0x00000004
  49. #define C0_RGB4_BGRX 0x00000008
  50. #define C0_RGB4_XBGR 0x0000000c
  51. #define C0_RGB5_RGGB 0x00000000
  52. #define C0_RGB5_GRBG 0x00000004
  53. #define C0_RGB5_GBRG 0x00000008
  54. #define C0_RGB5_BGGR 0x0000000c
  55. /* Spec has two fields for DIN and DOUT, but they must match, so
  56. combine them here. */
  57. #define C0_DF_YUV 0x00000000 /* Data is YUV */
  58. #define C0_DF_RGB 0x000000a0 /* ... RGB */
  59. #define C0_DF_BAYER 0x00000140 /* ... Bayer */
  60. /* 8-8-8 must be missing from the below - ask */
  61. #define C0_RGBF_565 0x00000000
  62. #define C0_RGBF_444 0x00000800
  63. #define C0_RGB_BGR 0x00001000 /* Blue comes first */
  64. #define C0_YUV_PLANAR 0x00000000 /* YUV 422 planar format */
  65. #define C0_YUV_PACKED 0x00008000 /* YUV 422 packed */
  66. #define C0_YUV_420PL 0x0000a000 /* YUV 420 planar */
  67. /* Think that 420 packed must be 111 - ask */
  68. #define C0_YUVE_YUYV 0x00000000 /* Y1CbY0Cr */
  69. #define C0_YUVE_YVYU 0x00010000 /* Y1CrY0Cb */
  70. #define C0_YUVE_VYUY 0x00020000 /* CrY1CbY0 */
  71. #define C0_YUVE_UYVY 0x00030000 /* CbY1CrY0 */
  72. #define C0_YUVE_XYUV 0x00000000 /* 420: .YUV */
  73. #define C0_YUVE_XYVU 0x00010000 /* 420: .YVU */
  74. #define C0_YUVE_XUVY 0x00020000 /* 420: .UVY */
  75. #define C0_YUVE_XVUY 0x00030000 /* 420: .VUY */
  76. /* Bayer bits 18,19 if needed */
  77. #define C0_HPOL_LOW 0x01000000 /* HSYNC polarity active low */
  78. #define C0_VPOL_LOW 0x02000000 /* VSYNC polarity active low */
  79. #define C0_VCLK_LOW 0x04000000 /* VCLK on falling edge */
  80. #define C0_DOWNSCALE 0x08000000 /* Enable downscaler */
  81. #define C0_SIFM_MASK 0xc0000000 /* SIF mode bits */
  82. #define C0_SIF_HVSYNC 0x00000000 /* Use H/VSYNC */
  83. #define CO_SOF_NOSYNC 0x40000000 /* Use inband active signaling */
  84. #define REG_CTRL1 0x40 /* Control 1 */
  85. #define C1_444ALPHA 0x00f00000 /* Alpha field in RGB444 */
  86. #define C1_ALPHA_SHFT 20
  87. #define C1_DMAB32 0x00000000 /* 32-byte DMA burst */
  88. #define C1_DMAB16 0x02000000 /* 16-byte DMA burst */
  89. #define C1_DMAB64 0x04000000 /* 64-byte DMA burst */
  90. #define C1_DMAB_MASK 0x06000000
  91. #define C1_TWOBUFS 0x08000000 /* Use only two DMA buffers */
  92. #define C1_PWRDWN 0x10000000 /* Power down */
  93. #define REG_CLKCTRL 0x88 /* Clock control */
  94. #define CLK_DIV_MASK 0x0000ffff /* Upper bits RW "reserved" */
  95. #define REG_GPR 0xb4 /* General purpose register. This
  96. controls inputs to the power and reset
  97. pins on the OV7670 used with OLPC;
  98. other deployments could differ. */
  99. #define GPR_C1EN 0x00000020 /* Pad 1 (power down) enable */
  100. #define GPR_C0EN 0x00000010 /* Pad 0 (reset) enable */
  101. #define GPR_C1 0x00000002 /* Control 1 value */
  102. /*
  103. * Control 0 is wired to reset on OLPC machines. For ov7x sensors,
  104. * it is active low, for 0v6x, instead, it's active high. What
  105. * fun.
  106. */
  107. #define GPR_C0 0x00000001 /* Control 0 value */
  108. #define REG_TWSIC0 0xb8 /* TWSI (smbus) control 0 */
  109. #define TWSIC0_EN 0x00000001 /* TWSI enable */
  110. #define TWSIC0_MODE 0x00000002 /* 1 = 16-bit, 0 = 8-bit */
  111. #define TWSIC0_SID 0x000003fc /* Slave ID */
  112. #define TWSIC0_SID_SHIFT 2
  113. #define TWSIC0_CLKDIV 0x0007fc00 /* Clock divider */
  114. #define TWSIC0_MASKACK 0x00400000 /* Mask ack from sensor */
  115. #define TWSIC0_OVMAGIC 0x00800000 /* Make it work on OV sensors */
  116. #define REG_TWSIC1 0xbc /* TWSI control 1 */
  117. #define TWSIC1_DATA 0x0000ffff /* Data to/from camchip */
  118. #define TWSIC1_ADDR 0x00ff0000 /* Address (register) */
  119. #define TWSIC1_ADDR_SHIFT 16
  120. #define TWSIC1_READ 0x01000000 /* Set for read op */
  121. #define TWSIC1_WSTAT 0x02000000 /* Write status */
  122. #define TWSIC1_RVALID 0x04000000 /* Read data valid */
  123. #define TWSIC1_ERROR 0x08000000 /* Something screwed up */
  124. #define REG_UBAR 0xc4 /* Upper base address register */
  125. /*
  126. * Here's the weird global control registers which are said to live
  127. * way up here.
  128. */
  129. #define REG_GL_CSR 0x3004 /* Control/status register */
  130. #define GCSR_SRS 0x00000001 /* SW Reset set */
  131. #define GCSR_SRC 0x00000002 /* SW Reset clear */
  132. #define GCSR_MRS 0x00000004 /* Master reset set */
  133. #define GCSR_MRC 0x00000008 /* HW Reset clear */
  134. #define GCSR_CCIC_EN 0x00004000 /* CCIC Clock enable */
  135. #define REG_GL_IMASK 0x300c /* Interrupt mask register */
  136. #define GIMSK_CCIC_EN 0x00000004 /* CCIC Interrupt enable */
  137. #define REG_GL_FCR 0x3038 /* GPIO functional control register */
  138. #define GFCR_GPIO_ON 0x08 /* Camera GPIO enabled */
  139. #define REG_GL_GPIOR 0x315c /* GPIO register */
  140. #define GGPIO_OUT 0x80000 /* GPIO output */
  141. #define GGPIO_VAL 0x00008 /* Output pin value */
  142. #define REG_LEN REG_GL_IMASK + 4
  143. /*
  144. * Useful stuff that probably belongs somewhere global.
  145. */
  146. #define VGA_WIDTH 640
  147. #define VGA_HEIGHT 480