0001
0002
0003
0004
0005
0006
0007
0008 #ifndef __ALCOR_PCI_H
0009 #define __ALCOR_PCI_H
0010
0011 #define ALCOR_SD_CARD 0
0012 #define ALCOR_MS_CARD 1
0013
0014 #define DRV_NAME_ALCOR_PCI_SDMMC "alcor_sdmmc"
0015 #define DRV_NAME_ALCOR_PCI_MS "alcor_ms"
0016
0017 #define PCI_ID_ALCOR_MICRO 0x1AEA
0018 #define PCI_ID_AU6601 0x6601
0019 #define PCI_ID_AU6621 0x6621
0020 #define PCI_ID_AU6625 0x6625
0021
0022 #define MHZ_TO_HZ(freq) ((freq) * 1000 * 1000)
0023
0024 #define AU6601_BASE_CLOCK 31000000
0025 #define AU6601_MIN_CLOCK 150000
0026 #define AU6601_MAX_CLOCK 208000000
0027 #define AU6601_MAX_DMA_SEGMENTS 64
0028 #define AU6601_MAX_PIO_SEGMENTS 1
0029 #define AU6601_MAX_DMA_BLOCK_SIZE 0x1000
0030 #define AU6601_MAX_PIO_BLOCK_SIZE 0x200
0031 #define AU6601_MAX_DMA_BLOCKS 1
0032 #define AU6601_DMA_LOCAL_SEGMENTS 1
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050 #define AU6601_REG_SDMA_ADDR 0x00
0051 #define AU6601_SDMA_MASK 0xffffffff
0052
0053 #define AU6601_DMA_BOUNDARY 0x05
0054 #define AU6621_DMA_PAGE_CNT 0x05
0055
0056 #define AU6601_REG_BUFFER 0x08
0057
0058 #define AU6621_DMA_CTRL 0x0c
0059 #define AU6621_DMA_ENABLE BIT(0)
0060
0061 #define AU6601_REG_CMD_OPCODE 0x23
0062
0063 #define AU6601_REG_CMD_ARG 0x24
0064
0065 #define AU6601_REG_CMD_RSP0 0x30
0066 #define AU6601_REG_CMD_RSP1 0x34
0067 #define AU6601_REG_CMD_RSP2 0x38
0068 #define AU6601_REG_CMD_RSP3 0x3C
0069
0070
0071
0072 #define AU6601_TIME_OUT_CTRL 0x69
0073
0074 #define AU6601_REG_BLOCK_SIZE 0x6c
0075
0076 #define AU6601_POWER_CONTROL 0x70
0077
0078
0079 #define AU6601_CLK_SELECT 0x72
0080 #define AU6601_CLK_OVER_CLK 0x80
0081 #define AU6601_CLK_384_MHZ 0x30
0082 #define AU6601_CLK_125_MHZ 0x20
0083 #define AU6601_CLK_48_MHZ 0x10
0084 #define AU6601_CLK_EXT_PLL 0x04
0085 #define AU6601_CLK_X2_MODE 0x02
0086 #define AU6601_CLK_ENABLE 0x01
0087 #define AU6601_CLK_31_25_MHZ 0x00
0088
0089 #define AU6601_CLK_DIVIDER 0x73
0090
0091 #define AU6601_INTERFACE_MODE_CTRL 0x74
0092 #define AU6601_DLINK_MODE 0x80
0093 #define AU6601_INTERRUPT_DELAY_TIME 0x40
0094 #define AU6601_SIGNAL_REQ_CTRL 0x30
0095 #define AU6601_MS_CARD_WP BIT(3)
0096 #define AU6601_SD_CARD_WP BIT(0)
0097
0098
0099
0100
0101
0102 #define AU6601_ACTIVE_CTRL 0x75
0103 #define AU6601_XD_CARD BIT(4)
0104
0105 #define AU6601_MS_CARD BIT(3)
0106 #define AU6601_SD_CARD BIT(0)
0107
0108
0109
0110
0111 #define AU6601_DETECT_STATUS 0x76
0112 #define AU6601_DETECT_EN BIT(7)
0113 #define AU6601_MS_DETECTED BIT(3)
0114 #define AU6601_SD_DETECTED BIT(0)
0115 #define AU6601_DETECT_STATUS_M 0xf
0116
0117 #define AU6601_REG_SW_RESET 0x79
0118 #define AU6601_BUF_CTRL_RESET BIT(7)
0119 #define AU6601_RESET_DATA BIT(3)
0120 #define AU6601_RESET_CMD BIT(0)
0121
0122 #define AU6601_OUTPUT_ENABLE 0x7a
0123
0124 #define AU6601_PAD_DRIVE0 0x7b
0125 #define AU6601_PAD_DRIVE1 0x7c
0126 #define AU6601_PAD_DRIVE2 0x7d
0127
0128 #define AU6601_FUNCTION 0x7f
0129
0130 #define AU6601_CMD_XFER_CTRL 0x81
0131 #define AU6601_CMD_17_BYTE_CRC 0xc0
0132 #define AU6601_CMD_6_BYTE_WO_CRC 0x80
0133 #define AU6601_CMD_6_BYTE_CRC 0x40
0134 #define AU6601_CMD_START_XFER 0x20
0135 #define AU6601_CMD_STOP_WAIT_RDY 0x10
0136 #define AU6601_CMD_NO_RESP 0x00
0137
0138 #define AU6601_REG_BUS_CTRL 0x82
0139 #define AU6601_BUS_WIDTH_4BIT 0x20
0140 #define AU6601_BUS_WIDTH_8BIT 0x10
0141 #define AU6601_BUS_WIDTH_1BIT 0x00
0142
0143 #define AU6601_DATA_XFER_CTRL 0x83
0144 #define AU6601_DATA_WRITE BIT(7)
0145 #define AU6601_DATA_DMA_MODE BIT(6)
0146 #define AU6601_DATA_START_XFER BIT(0)
0147
0148 #define AU6601_DATA_PIN_STATE 0x84
0149 #define AU6601_BUS_STAT_CMD BIT(15)
0150
0151
0152
0153 #define AU6601_BUS_STAT_DAT3 BIT(3)
0154 #define AU6601_BUS_STAT_DAT2 BIT(2)
0155 #define AU6601_BUS_STAT_DAT1 BIT(1)
0156 #define AU6601_BUS_STAT_DAT0 BIT(0)
0157 #define AU6601_BUS_STAT_DAT_MASK 0xf
0158
0159 #define AU6601_OPT 0x85
0160 #define AU6601_OPT_CMD_LINE_LEVEL 0x80
0161 #define AU6601_OPT_NCRC_16_CLK BIT(4)
0162 #define AU6601_OPT_CMD_NWT BIT(3)
0163 #define AU6601_OPT_STOP_CLK BIT(2)
0164 #define AU6601_OPT_DDR_MODE BIT(1)
0165 #define AU6601_OPT_SD_18V BIT(0)
0166
0167 #define AU6601_CLK_DELAY 0x86
0168 #define AU6601_CLK_DATA_POSITIVE_EDGE 0x80
0169 #define AU6601_CLK_CMD_POSITIVE_EDGE 0x40
0170 #define AU6601_CLK_POSITIVE_EDGE_ALL (AU6601_CLK_CMD_POSITIVE_EDGE \
0171 | AU6601_CLK_DATA_POSITIVE_EDGE)
0172
0173
0174 #define AU6601_REG_INT_STATUS 0x90
0175 #define AU6601_REG_INT_ENABLE 0x94
0176 #define AU6601_INT_DATA_END_BIT_ERR BIT(22)
0177 #define AU6601_INT_DATA_CRC_ERR BIT(21)
0178 #define AU6601_INT_DATA_TIMEOUT_ERR BIT(20)
0179 #define AU6601_INT_CMD_INDEX_ERR BIT(19)
0180 #define AU6601_INT_CMD_END_BIT_ERR BIT(18)
0181 #define AU6601_INT_CMD_CRC_ERR BIT(17)
0182 #define AU6601_INT_CMD_TIMEOUT_ERR BIT(16)
0183 #define AU6601_INT_ERROR BIT(15)
0184 #define AU6601_INT_OVER_CURRENT_ERR BIT(8)
0185 #define AU6601_INT_CARD_INSERT BIT(7)
0186 #define AU6601_INT_CARD_REMOVE BIT(6)
0187 #define AU6601_INT_READ_BUF_RDY BIT(5)
0188 #define AU6601_INT_WRITE_BUF_RDY BIT(4)
0189 #define AU6601_INT_DMA_END BIT(3)
0190 #define AU6601_INT_DATA_END BIT(1)
0191 #define AU6601_INT_CMD_END BIT(0)
0192
0193 #define AU6601_INT_NORMAL_MASK 0x00007FFF
0194 #define AU6601_INT_ERROR_MASK 0xFFFF8000
0195
0196 #define AU6601_INT_CMD_MASK (AU6601_INT_CMD_END | \
0197 AU6601_INT_CMD_TIMEOUT_ERR | AU6601_INT_CMD_CRC_ERR | \
0198 AU6601_INT_CMD_END_BIT_ERR | AU6601_INT_CMD_INDEX_ERR)
0199 #define AU6601_INT_DATA_MASK (AU6601_INT_DATA_END | AU6601_INT_DMA_END | \
0200 AU6601_INT_READ_BUF_RDY | AU6601_INT_WRITE_BUF_RDY | \
0201 AU6601_INT_DATA_TIMEOUT_ERR | AU6601_INT_DATA_CRC_ERR | \
0202 AU6601_INT_DATA_END_BIT_ERR)
0203 #define AU6601_INT_ALL_MASK ((u32)-1)
0204
0205
0206
0207 #define AU6601_MS_STATUS 0xa0
0208
0209 #define AU6601_MS_BUS_MODE_CTRL 0xa1
0210 #define AU6601_MS_BUS_8BIT_MODE 0x03
0211 #define AU6601_MS_BUS_4BIT_MODE 0x01
0212 #define AU6601_MS_BUS_1BIT_MODE 0x00
0213
0214 #define AU6601_MS_TPC_CMD 0xa2
0215 #define AU6601_MS_TPC_READ_PAGE_DATA 0x02
0216 #define AU6601_MS_TPC_READ_REG 0x04
0217 #define AU6601_MS_TPC_GET_INT 0x07
0218 #define AU6601_MS_TPC_WRITE_PAGE_DATA 0x0D
0219 #define AU6601_MS_TPC_WRITE_REG 0x0B
0220 #define AU6601_MS_TPC_SET_RW_REG_ADRS 0x08
0221 #define AU6601_MS_TPC_SET_CMD 0x0E
0222 #define AU6601_MS_TPC_EX_SET_CMD 0x09
0223 #define AU6601_MS_TPC_READ_SHORT_DATA 0x03
0224 #define AU6601_MS_TPC_WRITE_SHORT_DATA 0x0C
0225
0226 #define AU6601_MS_TRANSFER_MODE 0xa3
0227 #define AU6601_MS_XFER_INT_TIMEOUT_CHK BIT(2)
0228 #define AU6601_MS_XFER_DMA_ENABLE BIT(1)
0229 #define AU6601_MS_XFER_START BIT(0)
0230
0231 #define AU6601_MS_DATA_PIN_STATE 0xa4
0232
0233 #define AU6601_MS_INT_STATUS 0xb0
0234 #define AU6601_MS_INT_ENABLE 0xb4
0235 #define AU6601_MS_INT_OVER_CURRENT_ERROR BIT(23)
0236 #define AU6601_MS_INT_DATA_CRC_ERROR BIT(21)
0237 #define AU6601_MS_INT_INT_TIMEOUT BIT(20)
0238 #define AU6601_MS_INT_INT_RESP_ERROR BIT(19)
0239 #define AU6601_MS_INT_CED_ERROR BIT(18)
0240 #define AU6601_MS_INT_TPC_TIMEOUT BIT(16)
0241 #define AU6601_MS_INT_ERROR BIT(15)
0242 #define AU6601_MS_INT_CARD_INSERT BIT(7)
0243 #define AU6601_MS_INT_CARD_REMOVE BIT(6)
0244 #define AU6601_MS_INT_BUF_READ_RDY BIT(5)
0245 #define AU6601_MS_INT_BUF_WRITE_RDY BIT(4)
0246 #define AU6601_MS_INT_DMA_END BIT(3)
0247 #define AU6601_MS_INT_TPC_END BIT(1)
0248
0249 #define AU6601_MS_INT_DATA_MASK 0x00000038
0250 #define AU6601_MS_INT_TPC_MASK 0x003d8002
0251 #define AU6601_MS_INT_TPC_ERROR 0x003d0000
0252
0253 #define ALCOR_PCIE_LINK_CTRL_OFFSET 0x10
0254 #define ALCOR_PCIE_LINK_CAP_OFFSET 0x0c
0255 #define ALCOR_CAP_START_OFFSET 0x34
0256
0257 struct alcor_dev_cfg {
0258 u8 dma;
0259 };
0260
0261 struct alcor_pci_priv {
0262 struct pci_dev *pdev;
0263 struct pci_dev *parent_pdev;
0264 struct device *dev;
0265 void __iomem *iobase;
0266 unsigned int irq;
0267
0268 unsigned long id;
0269
0270 struct alcor_dev_cfg *cfg;
0271
0272
0273 int pdev_cap_off;
0274 u8 pdev_aspm_cap;
0275 int parent_cap_off;
0276 u8 parent_aspm_cap;
0277 u8 ext_config_dev_aspm;
0278 };
0279
0280 void alcor_write8(struct alcor_pci_priv *priv, u8 val, unsigned int addr);
0281 void alcor_write16(struct alcor_pci_priv *priv, u16 val, unsigned int addr);
0282 void alcor_write32(struct alcor_pci_priv *priv, u32 val, unsigned int addr);
0283 void alcor_write32be(struct alcor_pci_priv *priv, u32 val, unsigned int addr);
0284 u8 alcor_read8(struct alcor_pci_priv *priv, unsigned int addr);
0285 u32 alcor_read32(struct alcor_pci_priv *priv, unsigned int addr);
0286 u32 alcor_read32be(struct alcor_pci_priv *priv, unsigned int addr);
0287 #endif