aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/message/i2o/iop.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/message/i2o/iop.c')
-rw-r--r--drivers/message/i2o/iop.c87
1 files changed, 56 insertions, 31 deletions
diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
index 50c8cedf7a2d..62b0d8bed186 100644
--- a/drivers/message/i2o/iop.c
+++ b/drivers/message/i2o/iop.c
@@ -68,7 +68,7 @@ extern void i2o_device_exit(void);
68 */ 68 */
69void i2o_msg_nop(struct i2o_controller *c, u32 m) 69void i2o_msg_nop(struct i2o_controller *c, u32 m)
70{ 70{
71 struct i2o_message __iomem *msg = c->in_queue.virt + m; 71 struct i2o_message __iomem *msg = i2o_msg_in_to_virt(c, m);
72 72
73 writel(THREE_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); 73 writel(THREE_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]);
74 writel(I2O_CMD_UTIL_NOP << 24 | HOST_TID << 12 | ADAPTER_TID, 74 writel(I2O_CMD_UTIL_NOP << 24 | HOST_TID << 12 | ADAPTER_TID,
@@ -452,8 +452,6 @@ static int i2o_iop_clear(struct i2o_controller *c)
452 /* Enable all IOPs */ 452 /* Enable all IOPs */
453 i2o_iop_enable_all(); 453 i2o_iop_enable_all();
454 454
455 i2o_status_get(c);
456
457 return rc; 455 return rc;
458} 456}
459 457
@@ -591,12 +589,11 @@ static int i2o_iop_init_outbound_queue(struct i2o_controller *c)
591 if (m == I2O_QUEUE_EMPTY) 589 if (m == I2O_QUEUE_EMPTY)
592 return -ETIMEDOUT; 590 return -ETIMEDOUT;
593 591
594 writel(EIGHT_WORD_MSG_SIZE | TRL_OFFSET_6, &msg->u.head[0]); 592 writel(EIGHT_WORD_MSG_SIZE | SGL_OFFSET_6, &msg->u.head[0]);
595 writel(I2O_CMD_OUTBOUND_INIT << 24 | HOST_TID << 12 | ADAPTER_TID, 593 writel(I2O_CMD_OUTBOUND_INIT << 24 | HOST_TID << 12 | ADAPTER_TID,
596 &msg->u.head[1]); 594 &msg->u.head[1]);
597 writel(i2o_exec_driver.context, &msg->u.s.icntxt); 595 writel(i2o_exec_driver.context, &msg->u.s.icntxt);
598 writel(0x0106, &msg->u.s.tcntxt); /* FIXME: why 0x0106, maybe in 596 writel(0x00000000, &msg->u.s.tcntxt);
599 Spec? */
600 writel(PAGE_SIZE, &msg->body[0]); 597 writel(PAGE_SIZE, &msg->body[0]);
601 writel(MSG_FRAME_SIZE << 16 | 0x80, &msg->body[1]); /* Outbound msg frame 598 writel(MSG_FRAME_SIZE << 16 | 0x80, &msg->body[1]); /* Outbound msg frame
602 size in words and Initcode */ 599 size in words and Initcode */
@@ -891,8 +888,12 @@ void i2o_iop_remove(struct i2o_controller *c)
891 list_for_each_entry_safe(dev, tmp, &c->devices, list) 888 list_for_each_entry_safe(dev, tmp, &c->devices, list)
892 i2o_device_remove(dev); 889 i2o_device_remove(dev);
893 890
891 device_del(&c->device);
892
894 /* Ask the IOP to switch to RESET state */ 893 /* Ask the IOP to switch to RESET state */
895 i2o_iop_reset(c); 894 i2o_iop_reset(c);
895
896 put_device(&c->device);
896} 897}
897 898
898/** 899/**
@@ -971,8 +972,10 @@ static int i2o_systab_build(void)
971 systab->iops[count].frame_size = sb->inbound_frame_size; 972 systab->iops[count].frame_size = sb->inbound_frame_size;
972 systab->iops[count].last_changed = change_ind; 973 systab->iops[count].last_changed = change_ind;
973 systab->iops[count].iop_capabilities = sb->iop_capabilities; 974 systab->iops[count].iop_capabilities = sb->iop_capabilities;
974 systab->iops[count].inbound_low = i2o_ptr_low(c->post_port); 975 systab->iops[count].inbound_low =
975 systab->iops[count].inbound_high = i2o_ptr_high(c->post_port); 976 i2o_dma_low(c->base.phys + I2O_IN_PORT);
977 systab->iops[count].inbound_high =
978 i2o_dma_high(c->base.phys + I2O_IN_PORT);
976 979
977 count++; 980 count++;
978 } 981 }
@@ -1110,6 +1113,30 @@ static int i2o_hrt_get(struct i2o_controller *c)
1110} 1113}
1111 1114
1112/** 1115/**
1116 * i2o_iop_free - Free the i2o_controller struct
1117 * @c: I2O controller to free
1118 */
1119void i2o_iop_free(struct i2o_controller *c)
1120{
1121 kfree(c);
1122};
1123
1124
1125/**
1126 * i2o_iop_release - release the memory for a I2O controller
1127 * @dev: I2O controller which should be released
1128 *
1129 * Release the allocated memory. This function is called if refcount of
1130 * device reaches 0 automatically.
1131 */
1132static void i2o_iop_release(struct device *dev)
1133{
1134 struct i2o_controller *c = to_i2o_controller(dev);
1135
1136 i2o_iop_free(c);
1137};
1138
1139/**
1113 * i2o_iop_alloc - Allocate and initialize a i2o_controller struct 1140 * i2o_iop_alloc - Allocate and initialize a i2o_controller struct
1114 * 1141 *
1115 * Allocate the necessary memory for a i2o_controller struct and 1142 * Allocate the necessary memory for a i2o_controller struct and
@@ -1137,6 +1164,10 @@ struct i2o_controller *i2o_iop_alloc(void)
1137 c->unit = unit++; 1164 c->unit = unit++;
1138 sprintf(c->name, "iop%d", c->unit); 1165 sprintf(c->name, "iop%d", c->unit);
1139 1166
1167 device_initialize(&c->device);
1168 c->device.release = &i2o_iop_release;
1169 snprintf(c->device.bus_id, BUS_ID_SIZE, "iop%d", c->unit);
1170
1140#if BITS_PER_LONG == 64 1171#if BITS_PER_LONG == 64
1141 spin_lock_init(&c->context_list_lock); 1172 spin_lock_init(&c->context_list_lock);
1142 atomic_set(&c->context_list_counter, 0); 1173 atomic_set(&c->context_list_counter, 0);
@@ -1147,15 +1178,6 @@ struct i2o_controller *i2o_iop_alloc(void)
1147}; 1178};
1148 1179
1149/** 1180/**
1150 * i2o_iop_free - Free the i2o_controller struct
1151 * @c: I2O controller to free
1152 */
1153void i2o_iop_free(struct i2o_controller *c)
1154{
1155 kfree(c);
1156};
1157
1158/**
1159 * i2o_iop_add - Initialize the I2O controller and add him to the I2O core 1181 * i2o_iop_add - Initialize the I2O controller and add him to the I2O core
1160 * @c: controller 1182 * @c: controller
1161 * 1183 *
@@ -1168,6 +1190,11 @@ int i2o_iop_add(struct i2o_controller *c)
1168{ 1190{
1169 int rc; 1191 int rc;
1170 1192
1193 if((rc = device_add(&c->device))) {
1194 printk(KERN_ERR "%s: could not register controller\n", c->name);
1195 goto iop_reset;
1196 }
1197
1171 printk(KERN_INFO "%s: Activating I2O controller...\n", c->name); 1198 printk(KERN_INFO "%s: Activating I2O controller...\n", c->name);
1172 printk(KERN_INFO "%s: This may take a few minutes if there are many " 1199 printk(KERN_INFO "%s: This may take a few minutes if there are many "
1173 "devices\n", c->name); 1200 "devices\n", c->name);
@@ -1175,30 +1202,23 @@ int i2o_iop_add(struct i2o_controller *c)
1175 if ((rc = i2o_iop_activate(c))) { 1202 if ((rc = i2o_iop_activate(c))) {
1176 printk(KERN_ERR "%s: could not activate controller\n", 1203 printk(KERN_ERR "%s: could not activate controller\n",
1177 c->name); 1204 c->name);
1178 i2o_iop_reset(c); 1205 goto iop_reset;
1179 return rc;
1180 } 1206 }
1181 1207
1182 pr_debug("%s: building sys table...\n", c->name); 1208 pr_debug("%s: building sys table...\n", c->name);
1183 1209
1184 if ((rc = i2o_systab_build())) { 1210 if ((rc = i2o_systab_build()))
1185 i2o_iop_reset(c); 1211 goto iop_reset;
1186 return rc;
1187 }
1188 1212
1189 pr_debug("%s: online controller...\n", c->name); 1213 pr_debug("%s: online controller...\n", c->name);
1190 1214
1191 if ((rc = i2o_iop_online(c))) { 1215 if ((rc = i2o_iop_online(c)))
1192 i2o_iop_reset(c); 1216 goto iop_reset;
1193 return rc;
1194 }
1195 1217
1196 pr_debug("%s: getting LCT...\n", c->name); 1218 pr_debug("%s: getting LCT...\n", c->name);
1197 1219
1198 if ((rc = i2o_exec_lct_get(c))) { 1220 if ((rc = i2o_exec_lct_get(c)))
1199 i2o_iop_reset(c); 1221 goto iop_reset;
1200 return rc;
1201 }
1202 1222
1203 list_add(&c->list, &i2o_controllers); 1223 list_add(&c->list, &i2o_controllers);
1204 1224
@@ -1207,6 +1227,11 @@ int i2o_iop_add(struct i2o_controller *c)
1207 printk(KERN_INFO "%s: Controller added\n", c->name); 1227 printk(KERN_INFO "%s: Controller added\n", c->name);
1208 1228
1209 return 0; 1229 return 0;
1230
1231iop_reset:
1232 i2o_iop_reset(c);
1233
1234 return rc;
1210}; 1235};
1211 1236
1212/** 1237/**