Автор работы: Пользователь скрыл имя, 17 Января 2012 в 14:29, курсовая работа
В настоящее время только Philips производит более 150 наименований I2C-совместимых устройств, функционально предназначенных работы в электронном оборудовании различного назначения. В их числе ИС памяти, видеопроцессоров и модулей обработки аудио- и видео-сигналов, АЦП и ЦАП, драйверы ЖК-индикаторов, процессоры со встоенным аппаратным контроллером I2C шины и многое другое.
Введение 5
1 Шина управления I2C 10
2 Исследование драйвера 14
Заключение 15
Список использованных источников 16
1047 dev_err(&adapter->dev, "Block read not supported "
1048 "under I2C emulation!\n");
1049 return -1;
1050 } else {
1051 msg[0].len = data->block[0] + 2;
1052 if (msg[0].len > I2C_SMBUS_BLOCK_MAX + 2) {
1053 dev_err(&adapter->dev, "smbus_access called with "
1054 "invalid block write size (%d)\n",
1055 data->block[0]);
1056 return -1;
1057 }
1058 for (i = 1; i < msg[0].len; i++)
1059 msgbuf0[i] = data->block[i-1];
1060 }
1061 break;
1062 case I2C_SMBUS_BLOCK_PROC_CALL:
1063 dev_dbg(&adapter->dev, "Block process call not supported "
1064 "under I2C emulation!\n");
1065 return -1;
1066 case I2C_SMBUS_I2C_BLOCK_DATA:
1067 if (read_write == I2C_SMBUS_READ) {
1068 msg[1].len = I2C_SMBUS_BLOCK_MAX;
1069 } else {
1070 msg[0].len = data->block[0] + 1;
1071 if (msg[0].len > I2C_SMBUS_BLOCK_MAX + 1) {
1072 dev_err(&adapter->dev, "i2c_smbus_xfer_emulated called with
1073 "
1074 "invalid block write size (%d)\n",
1075 data->block[0]);
1076 return -1;
1077 }
1078 for (i = 1; i <= data->block[0]; i++)
1079 msgbuf0[i] = data->block[i];
1080 }
1081 break;
1082 default:
1083 dev_err(&adapter->dev, "smbus_access called with invalid size (%d)
1084 \n",
1085 size);
1086 return -1;
1087 }
1088
1089 i = ((flags & I2C_CLIENT_PEC) && size != I2C_SMBUS_QUICK
1090 && size != I2C_SMBUS_I2C_BLOCK_DATA);
1091 if (i) {
1092 /* Compute PEC if first message is a write */
1093 if (!(msg[0].flags & I2C_M_RD)) {
1094 if (num == 1) /* Write only */
1095 i2c_smbus_add_pec(&msg[0]);
1096 else /* Write followed by read */
1097 partial_pec = i2c_smbus_msg_pec(0, &msg[0]);
1098 }
1099 /* Ask for PEC if last message is a read */
1100 if (msg[num-1].flags & I2C_M_RD)
1101 msg[num-1].len++;
1102 }
1103
1104 if (i2c_transfer(adapter, msg, num) < 0)
1105 return -1;
1106
1107 /* Check PEC if last message is a read */
1108 if (i && (msg[num-1].flags & I2C_M_RD)) {
1109
if (i2c_smbus_check_pec(partial_
1110 return -1;
1111 }
1112
1113 if (read_write == I2C_SMBUS_READ)
1114 switch(size) {
1115 case I2C_SMBUS_BYTE:
1116 data->byte = msgbuf0[0];
1117 break;
1118 case I2C_SMBUS_BYTE_DATA:
1119 data->byte = msgbuf1[0];
1120 break;
1121 case I2C_SMBUS_WORD_DATA:
1122 case I2C_SMBUS_PROC_CALL:
1123 data->word = msgbuf1[0] | (msgbuf1[1] << 8);
1124 break;
1125 case I2C_SMBUS_I2C_BLOCK_DATA:
1126 /* fixed at 32 for now */
1127 data->block[0] = I2C_SMBUS_BLOCK_MAX;
1128 for (i = 0; i < I2C_SMBUS_BLOCK_MAX; i++)
1129 data->block[i+1] = msgbuf1[i];
1130 break;
1131 }
1132 return 0;
1133 }
1134
1135
1136 s32 i2c_smbus_xfer(struct i2c_adapter * adapter, u16 addr, unsigned short
1137 flags,
1138 char read_write, u8 command, int size,
1139 union i2c_smbus_data * data)
1140 {
1141 s32 res;
1142
1143 flags &= I2C_M_TEN | I2C_CLIENT_PEC;
1144
1145 if (adapter->algo->smbus_xfer) {
1146 down(&adapter->bus_lock);
1147
res = adapter->algo->smbus_xfer(adap
1148
1149 up(&adapter->bus_lock);
1150 } else
1151
res = i2c_smbus_xfer_emulated(adapte
1152
1153
1154 return res;
1155 }
1156
1157
1158 /* Next four are needed by i2c-isa */
1159 EXPORT_SYMBOL_GPL(i2c_adapter_
1160 EXPORT_SYMBOL_GPL(i2c_adapter_
1161 EXPORT_SYMBOL_GPL(i2c_adapter_
1162 EXPORT_SYMBOL_GPL(i2c_bus_type
1163
1164 EXPORT_SYMBOL(i2c_add_adapter)
1165 EXPORT_SYMBOL(i2c_del_adapter)
1166 EXPORT_SYMBOL(i2c_add_driver);
1167 EXPORT_SYMBOL(i2c_del_driver);
1168 EXPORT_SYMBOL(i2c_attach_
1169 EXPORT_SYMBOL(i2c_detach_
1170 EXPORT_SYMBOL(i2c_use_client);
1171 EXPORT_SYMBOL(i2c_release_
1172 EXPORT_SYMBOL(i2c_clients_
1173 EXPORT_SYMBOL(i2c_check_addr);
1174
1175 EXPORT_SYMBOL(i2c_master_send)
1176 EXPORT_SYMBOL(i2c_master_recv)
1177 EXPORT_SYMBOL(i2c_control);
1178 EXPORT_SYMBOL(i2c_transfer);
1179 EXPORT_SYMBOL(i2c_get_adapter)
1180 EXPORT_SYMBOL(i2c_put_adapter)
1181 EXPORT_SYMBOL(i2c_probe);
1182
1183 EXPORT_SYMBOL(i2c_smbus_xfer);
1184 EXPORT_SYMBOL(i2c_smbus_write_
1185 EXPORT_SYMBOL(i2c_smbus_read_
1186 EXPORT_SYMBOL(i2c_smbus_write_
1187 EXPORT_SYMBOL(i2c_smbus_read_
1188 EXPORT_SYMBOL(i2c_smbus_write_
1189 EXPORT_SYMBOL(i2c_smbus_read_
1190 EXPORT_SYMBOL(i2c_smbus_write_
1191 EXPORT_SYMBOL(i2c_smbus_write_
Информация о работе Исследование драйвера ядра Linux для шины I2C