diff options
author | Jeff Garzik <jeff@garzik.org> | 2007-05-27 22:58:54 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-07-09 12:17:33 -0400 |
commit | b2d46b61bdb2bd45b93f88892461fa568df721d4 (patch) | |
tree | 440c060a073424ec4c3a08ace2ac1a357c4aef12 /drivers/ata/sata_sx4.c | |
parent | 5d4c51f6beab08ada99064bab6ee74e995a4f24d (diff) |
[libata] sata_sx4: named constant cleanup
* convert tabs to spaces
* convert some hex numbers to (1 << n) preferred format
* document i2c and timer control register bits
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/ata/sata_sx4.c')
-rw-r--r-- | drivers/ata/sata_sx4.c | 115 |
1 files changed, 63 insertions, 52 deletions
diff --git a/drivers/ata/sata_sx4.c b/drivers/ata/sata_sx4.c index 2d14f3d56d92..ff0a78dc8b86 100644 --- a/drivers/ata/sata_sx4.c +++ b/drivers/ata/sata_sx4.c | |||
@@ -87,48 +87,59 @@ enum { | |||
87 | 87 | ||
88 | board_20621 = 0, /* FastTrak S150 SX4 */ | 88 | board_20621 = 0, /* FastTrak S150 SX4 */ |
89 | 89 | ||
90 | PDC_RESET = (1 << 11), /* HDMA reset */ | 90 | PDC_MASK_INT = (1 << 10), /* HDMA/ATA mask int */ |
91 | PDC_RESET = (1 << 11), /* HDMA/ATA reset */ | ||
91 | 92 | ||
92 | PDC_MAX_HDMA = 32, | 93 | PDC_MAX_HDMA = 32, |
93 | PDC_HDMA_Q_MASK = (PDC_MAX_HDMA - 1), | 94 | PDC_HDMA_Q_MASK = (PDC_MAX_HDMA - 1), |
94 | 95 | ||
95 | PDC_DIMM0_SPD_DEV_ADDRESS = 0x50, | 96 | PDC_DIMM0_SPD_DEV_ADDRESS = 0x50, |
96 | PDC_DIMM1_SPD_DEV_ADDRESS = 0x51, | 97 | PDC_DIMM1_SPD_DEV_ADDRESS = 0x51, |
97 | PDC_MAX_DIMM_MODULE = 0x02, | 98 | PDC_I2C_CONTROL = 0x48, |
98 | PDC_I2C_CONTROL_OFFSET = 0x48, | 99 | PDC_I2C_ADDR_DATA = 0x4C, |
99 | PDC_I2C_ADDR_DATA_OFFSET = 0x4C, | 100 | PDC_DIMM0_CONTROL = 0x80, |
100 | PDC_DIMM0_CONTROL_OFFSET = 0x80, | 101 | PDC_DIMM1_CONTROL = 0x84, |
101 | PDC_DIMM1_CONTROL_OFFSET = 0x84, | 102 | PDC_SDRAM_CONTROL = 0x88, |
102 | PDC_SDRAM_CONTROL_OFFSET = 0x88, | 103 | PDC_I2C_WRITE = 0, /* master -> slave */ |
103 | PDC_I2C_WRITE = 0x00000000, | 104 | PDC_I2C_READ = (1 << 6), /* master <- slave */ |
104 | PDC_I2C_READ = 0x00000040, | 105 | PDC_I2C_START = (1 << 7), /* start I2C proto */ |
105 | PDC_I2C_START = 0x00000080, | 106 | PDC_I2C_MASK_INT = (1 << 5), /* mask I2C interrupt */ |
106 | PDC_I2C_MASK_INT = 0x00000020, | 107 | PDC_I2C_COMPLETE = (1 << 16), /* I2C normal compl. */ |
107 | PDC_I2C_COMPLETE = 0x00010000, | 108 | PDC_I2C_NO_ACK = (1 << 20), /* slave no-ack addr */ |
108 | PDC_I2C_NO_ACK = 0x00100000, | 109 | PDC_DIMM_SPD_SUBADDRESS_START = 0x00, |
109 | PDC_DIMM_SPD_SUBADDRESS_START = 0x00, | 110 | PDC_DIMM_SPD_SUBADDRESS_END = 0x7F, |
110 | PDC_DIMM_SPD_SUBADDRESS_END = 0x7F, | 111 | PDC_DIMM_SPD_ROW_NUM = 3, |
111 | PDC_DIMM_SPD_ROW_NUM = 3, | 112 | PDC_DIMM_SPD_COLUMN_NUM = 4, |
112 | PDC_DIMM_SPD_COLUMN_NUM = 4, | 113 | PDC_DIMM_SPD_MODULE_ROW = 5, |
113 | PDC_DIMM_SPD_MODULE_ROW = 5, | 114 | PDC_DIMM_SPD_TYPE = 11, |
114 | PDC_DIMM_SPD_TYPE = 11, | 115 | PDC_DIMM_SPD_FRESH_RATE = 12, |
115 | PDC_DIMM_SPD_FRESH_RATE = 12, | 116 | PDC_DIMM_SPD_BANK_NUM = 17, |
116 | PDC_DIMM_SPD_BANK_NUM = 17, | 117 | PDC_DIMM_SPD_CAS_LATENCY = 18, |
117 | PDC_DIMM_SPD_CAS_LATENCY = 18, | 118 | PDC_DIMM_SPD_ATTRIBUTE = 21, |
118 | PDC_DIMM_SPD_ATTRIBUTE = 21, | 119 | PDC_DIMM_SPD_ROW_PRE_CHARGE = 27, |
119 | PDC_DIMM_SPD_ROW_PRE_CHARGE = 27, | 120 | PDC_DIMM_SPD_ROW_ACTIVE_DELAY = 28, |
120 | PDC_DIMM_SPD_ROW_ACTIVE_DELAY = 28, | 121 | PDC_DIMM_SPD_RAS_CAS_DELAY = 29, |
121 | PDC_DIMM_SPD_RAS_CAS_DELAY = 29, | 122 | PDC_DIMM_SPD_ACTIVE_PRECHARGE = 30, |
122 | PDC_DIMM_SPD_ACTIVE_PRECHARGE = 30, | 123 | PDC_DIMM_SPD_SYSTEM_FREQ = 126, |
123 | PDC_DIMM_SPD_SYSTEM_FREQ = 126, | 124 | PDC_CTL_STATUS = 0x08, |
124 | PDC_CTL_STATUS = 0x08, | 125 | PDC_DIMM_WINDOW_CTLR = 0x0C, |
125 | PDC_DIMM_WINDOW_CTLR = 0x0C, | 126 | PDC_TIME_CONTROL = 0x3C, |
126 | PDC_TIME_CONTROL = 0x3C, | 127 | PDC_TIME_PERIOD = 0x40, |
127 | PDC_TIME_PERIOD = 0x40, | 128 | PDC_TIME_COUNTER = 0x44, |
128 | PDC_TIME_COUNTER = 0x44, | 129 | PDC_GENERAL_CTLR = 0x484, |
129 | PDC_GENERAL_CTLR = 0x484, | 130 | PCI_PLL_INIT = 0x8A531824, |
130 | PCI_PLL_INIT = 0x8A531824, | 131 | PCI_X_TCOUNT = 0xEE1E5CFF, |
131 | PCI_X_TCOUNT = 0xEE1E5CFF | 132 | |
133 | /* PDC_TIME_CONTROL bits */ | ||
134 | PDC_TIMER_BUZZER = (1 << 10), | ||
135 | PDC_TIMER_MODE_PERIODIC = 0, /* bits 9:8 == 00 */ | ||
136 | PDC_TIMER_MODE_ONCE = (1 << 8), /* bits 9:8 == 01 */ | ||
137 | PDC_TIMER_ENABLE = (1 << 7), | ||
138 | PDC_TIMER_MASK_INT = (1 << 5), | ||
139 | PDC_TIMER_SEQ_MASK = 0x1f, /* SEQ ID for timer */ | ||
140 | PDC_TIMER_DEFAULT = PDC_TIMER_MODE_ONCE | | ||
141 | PDC_TIMER_ENABLE | | ||
142 | PDC_TIMER_MASK_INT, | ||
132 | }; | 143 | }; |
133 | 144 | ||
134 | 145 | ||
@@ -999,17 +1010,17 @@ static unsigned int pdc20621_i2c_read(struct ata_host *host, u32 device, | |||
999 | i2creg |= subaddr << 16; | 1010 | i2creg |= subaddr << 16; |
1000 | 1011 | ||
1001 | /* Set the device and subaddress */ | 1012 | /* Set the device and subaddress */ |
1002 | writel(i2creg, mmio + PDC_I2C_ADDR_DATA_OFFSET); | 1013 | writel(i2creg, mmio + PDC_I2C_ADDR_DATA); |
1003 | readl(mmio + PDC_I2C_ADDR_DATA_OFFSET); | 1014 | readl(mmio + PDC_I2C_ADDR_DATA); |
1004 | 1015 | ||
1005 | /* Write Control to perform read operation, mask int */ | 1016 | /* Write Control to perform read operation, mask int */ |
1006 | writel(PDC_I2C_READ | PDC_I2C_START | PDC_I2C_MASK_INT, | 1017 | writel(PDC_I2C_READ | PDC_I2C_START | PDC_I2C_MASK_INT, |
1007 | mmio + PDC_I2C_CONTROL_OFFSET); | 1018 | mmio + PDC_I2C_CONTROL); |
1008 | 1019 | ||
1009 | for (count = 0; count <= 1000; count ++) { | 1020 | for (count = 0; count <= 1000; count ++) { |
1010 | status = readl(mmio + PDC_I2C_CONTROL_OFFSET); | 1021 | status = readl(mmio + PDC_I2C_CONTROL); |
1011 | if (status & PDC_I2C_COMPLETE) { | 1022 | if (status & PDC_I2C_COMPLETE) { |
1012 | status = readl(mmio + PDC_I2C_ADDR_DATA_OFFSET); | 1023 | status = readl(mmio + PDC_I2C_ADDR_DATA); |
1013 | break; | 1024 | break; |
1014 | } else if (count == 1000) | 1025 | } else if (count == 1000) |
1015 | return 0; | 1026 | return 0; |
@@ -1099,8 +1110,8 @@ static int pdc20621_prog_dimm0(struct ata_host *host) | |||
1099 | data |= (((size / 16) - 1) << 16); | 1110 | data |= (((size / 16) - 1) << 16); |
1100 | data |= (0 << 23); | 1111 | data |= (0 << 23); |
1101 | data |= 8; | 1112 | data |= 8; |
1102 | writel(data, mmio + PDC_DIMM0_CONTROL_OFFSET); | 1113 | writel(data, mmio + PDC_DIMM0_CONTROL); |
1103 | readl(mmio + PDC_DIMM0_CONTROL_OFFSET); | 1114 | readl(mmio + PDC_DIMM0_CONTROL); |
1104 | return size; | 1115 | return size; |
1105 | } | 1116 | } |
1106 | 1117 | ||
@@ -1122,27 +1133,27 @@ static unsigned int pdc20621_prog_dimm_global(struct ata_host *host) | |||
1122 | */ | 1133 | */ |
1123 | 1134 | ||
1124 | data = 0x022259F1; | 1135 | data = 0x022259F1; |
1125 | writel(data, mmio + PDC_SDRAM_CONTROL_OFFSET); | 1136 | writel(data, mmio + PDC_SDRAM_CONTROL); |
1126 | readl(mmio + PDC_SDRAM_CONTROL_OFFSET); | 1137 | readl(mmio + PDC_SDRAM_CONTROL); |
1127 | 1138 | ||
1128 | /* Turn on for ECC */ | 1139 | /* Turn on for ECC */ |
1129 | pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS, | 1140 | pdc20621_i2c_read(host, PDC_DIMM0_SPD_DEV_ADDRESS, |
1130 | PDC_DIMM_SPD_TYPE, &spd0); | 1141 | PDC_DIMM_SPD_TYPE, &spd0); |
1131 | if (spd0 == 0x02) { | 1142 | if (spd0 == 0x02) { |
1132 | data |= (0x01 << 16); | 1143 | data |= (0x01 << 16); |
1133 | writel(data, mmio + PDC_SDRAM_CONTROL_OFFSET); | 1144 | writel(data, mmio + PDC_SDRAM_CONTROL); |
1134 | readl(mmio + PDC_SDRAM_CONTROL_OFFSET); | 1145 | readl(mmio + PDC_SDRAM_CONTROL); |
1135 | printk(KERN_ERR "Local DIMM ECC Enabled\n"); | 1146 | printk(KERN_ERR "Local DIMM ECC Enabled\n"); |
1136 | } | 1147 | } |
1137 | 1148 | ||
1138 | /* DIMM Initialization Select/Enable (bit 18/19) */ | 1149 | /* DIMM Initialization Select/Enable (bit 18/19) */ |
1139 | data &= (~(1<<18)); | 1150 | data &= (~(1<<18)); |
1140 | data |= (1<<19); | 1151 | data |= (1<<19); |
1141 | writel(data, mmio + PDC_SDRAM_CONTROL_OFFSET); | 1152 | writel(data, mmio + PDC_SDRAM_CONTROL); |
1142 | 1153 | ||
1143 | error = 1; | 1154 | error = 1; |
1144 | for (i = 1; i <= 10; i++) { /* polling ~5 secs */ | 1155 | for (i = 1; i <= 10; i++) { /* polling ~5 secs */ |
1145 | data = readl(mmio + PDC_SDRAM_CONTROL_OFFSET); | 1156 | data = readl(mmio + PDC_SDRAM_CONTROL); |
1146 | if (!(data & (1<<19))) { | 1157 | if (!(data & (1<<19))) { |
1147 | error = 0; | 1158 | error = 0; |
1148 | break; | 1159 | break; |
@@ -1176,7 +1187,7 @@ static unsigned int pdc20621_dimm_init(struct ata_host *host) | |||
1176 | VPRINTK("Time Period Register (0x40): 0x%x\n", time_period); | 1187 | VPRINTK("Time Period Register (0x40): 0x%x\n", time_period); |
1177 | 1188 | ||
1178 | /* Enable timer */ | 1189 | /* Enable timer */ |
1179 | writel(0x00001a0, mmio + PDC_TIME_CONTROL); | 1190 | writel(PDC_TIMER_DEFAULT, mmio + PDC_TIME_CONTROL); |
1180 | readl(mmio + PDC_TIME_CONTROL); | 1191 | readl(mmio + PDC_TIME_CONTROL); |
1181 | 1192 | ||
1182 | /* Wait 3 seconds */ | 1193 | /* Wait 3 seconds */ |