Lines Matching refs:pdev
291 static int idt_smb_write_byte(struct idt_89hpesx_dev *pdev, in idt_smb_write_byte() argument
308 sts = idt_smb_safe(write_byte, pdev->client, ccode, in idt_smb_write_byte()
323 static int idt_smb_read_byte(struct idt_89hpesx_dev *pdev, in idt_smb_read_byte() argument
340 sts = idt_smb_safe(read_byte, pdev->client, ccode); in idt_smb_read_byte()
356 static int idt_smb_write_word(struct idt_89hpesx_dev *pdev, in idt_smb_write_word() argument
376 sts = idt_smb_safe(write_word, pdev->client, ccode, in idt_smb_write_word()
390 sts = idt_smb_safe(write_byte, pdev->client, ccode, in idt_smb_write_word()
405 static int idt_smb_read_word(struct idt_89hpesx_dev *pdev, in idt_smb_read_word() argument
425 sts = idt_smb_safe(read_word, pdev->client, ccode); in idt_smb_read_word()
440 sts = idt_smb_safe(read_byte, pdev->client, ccode); in idt_smb_read_word()
456 static int idt_smb_write_block(struct idt_89hpesx_dev *pdev, in idt_smb_write_block() argument
469 return idt_smb_safe(write_block, pdev->client, ccode, seq->bytecnt, in idt_smb_write_block()
479 static int idt_smb_read_block(struct idt_89hpesx_dev *pdev, in idt_smb_read_block() argument
493 sts = idt_smb_safe(read_block, pdev->client, ccode, seq->data); in idt_smb_read_block()
509 static int idt_smb_write_i2c_block(struct idt_89hpesx_dev *pdev, in idt_smb_write_i2c_block() argument
526 return idt_smb_safe(write_i2c_block, pdev->client, ccode, in idt_smb_write_i2c_block()
539 static int idt_smb_read_i2c_block(struct idt_89hpesx_dev *pdev, in idt_smb_read_i2c_block() argument
553 sts = idt_smb_safe(read_i2c_block, pdev->client, ccode, in idt_smb_read_i2c_block()
577 static int idt_eeprom_read_byte(struct idt_89hpesx_dev *pdev, u16 memaddr, in idt_eeprom_read_byte() argument
580 struct device *dev = &pdev->client->dev; in idt_eeprom_read_byte()
586 smbseq.ccode = pdev->iniccode | CCODE_EEPROM; in idt_eeprom_read_byte()
597 eeseq.cmd = pdev->inieecmd | EEPROM_OP_READ; in idt_eeprom_read_byte()
598 eeseq.eeaddr = pdev->eeaddr; in idt_eeprom_read_byte()
600 ret = pdev->smb_write(pdev, &smbseq); in idt_eeprom_read_byte()
609 ret = pdev->smb_read(pdev, &smbseq); in idt_eeprom_read_byte()
649 static int idt_eeprom_write(struct idt_89hpesx_dev *pdev, u16 memaddr, u16 len, in idt_eeprom_write() argument
652 struct device *dev = &pdev->client->dev; in idt_eeprom_write()
659 smbseq.ccode = pdev->iniccode | CCODE_EEPROM; in idt_eeprom_write()
665 mutex_lock(&pdev->smb_mtx); in idt_eeprom_write()
669 eeseq.cmd = pdev->inieecmd | EEPROM_OP_WRITE; in idt_eeprom_write()
670 eeseq.eeaddr = pdev->eeaddr; in idt_eeprom_write()
673 ret = pdev->smb_write(pdev, &smbseq); in idt_eeprom_write()
686 ret = idt_eeprom_read_byte(pdev, memaddr, &eeseq.data); in idt_eeprom_write()
700 mutex_unlock(&pdev->smb_mtx); in idt_eeprom_write()
715 static int idt_eeprom_read(struct idt_89hpesx_dev *pdev, u16 memaddr, u16 len, in idt_eeprom_read() argument
724 mutex_lock(&pdev->smb_mtx); in idt_eeprom_read()
727 ret = idt_eeprom_read_byte(pdev, memaddr, &buf[idx]); in idt_eeprom_read()
730 mutex_unlock(&pdev->smb_mtx); in idt_eeprom_read()
751 static int idt_csr_write(struct idt_89hpesx_dev *pdev, u16 csraddr, in idt_csr_write() argument
754 struct device *dev = &pdev->client->dev; in idt_csr_write()
760 smbseq.ccode = pdev->iniccode | CCODE_CSR; in idt_csr_write()
764 mutex_lock(&pdev->smb_mtx); in idt_csr_write()
768 csrseq.cmd = pdev->inicsrcmd | CSR_OP_WRITE; in idt_csr_write()
771 ret = pdev->smb_write(pdev, &smbseq); in idt_csr_write()
780 csrseq.cmd = pdev->inicsrcmd | CSR_OP_READ; in idt_csr_write()
781 ret = pdev->smb_write(pdev, &smbseq); in idt_csr_write()
790 ret = pdev->smb_read(pdev, &smbseq); in idt_csr_write()
806 mutex_unlock(&pdev->smb_mtx); in idt_csr_write()
817 static int idt_csr_read(struct idt_89hpesx_dev *pdev, u16 csraddr, u32 *data) in idt_csr_read() argument
819 struct device *dev = &pdev->client->dev; in idt_csr_read()
825 smbseq.ccode = pdev->iniccode | CCODE_CSR; in idt_csr_read()
829 mutex_lock(&pdev->smb_mtx); in idt_csr_read()
833 csrseq.cmd = pdev->inicsrcmd | CSR_OP_READ; in idt_csr_read()
835 ret = pdev->smb_write(pdev, &smbseq); in idt_csr_read()
844 ret = pdev->smb_read(pdev, &smbseq); in idt_csr_read()
863 mutex_unlock(&pdev->smb_mtx); in idt_csr_read()
886 struct idt_89hpesx_dev *pdev; in eeprom_write() local
890 pdev = dev_get_drvdata(kobj_to_dev(kobj)); in eeprom_write()
893 ret = idt_eeprom_write(pdev, (u16)off, (u16)count, (u8 *)buf); in eeprom_write()
910 struct idt_89hpesx_dev *pdev; in eeprom_read() local
914 pdev = dev_get_drvdata(kobj_to_dev(kobj)); in eeprom_read()
917 ret = idt_eeprom_read(pdev, (u16)off, (u16)count, (u8 *)buf); in eeprom_read()
939 struct idt_89hpesx_dev *pdev = filep->private_data; in idt_dbgfs_csr_write() local
995 pdev->csr = (csraddr >> 2); in idt_dbgfs_csr_write()
1003 ret = idt_csr_write(pdev, pdev->csr, csrval); in idt_dbgfs_csr_write()
1033 struct idt_89hpesx_dev *pdev = filep->private_data; in idt_dbgfs_csr_read() local
1039 ret = idt_csr_read(pdev, pdev->csr, &csrval); in idt_dbgfs_csr_read()
1044 csraddr = ((u32)pdev->csr << 2); in idt_dbgfs_csr_read()
1081 static void idt_set_defval(struct idt_89hpesx_dev *pdev) in idt_set_defval() argument
1084 pdev->eesize = 0; in idt_set_defval()
1085 pdev->eero = true; in idt_set_defval()
1086 pdev->inieecmd = 0; in idt_set_defval()
1087 pdev->eeaddr = 0; in idt_set_defval()
1121 static void idt_get_fw_data(struct idt_89hpesx_dev *pdev) in idt_get_fw_data() argument
1123 struct device *dev = &pdev->client->dev; in idt_get_fw_data()
1141 idt_set_defval(pdev); in idt_get_fw_data()
1146 pdev->eesize = (u32)ee_id->driver_data; in idt_get_fw_data()
1153 pdev->inieecmd = 0; in idt_get_fw_data()
1154 pdev->eeaddr = EEPROM_DEF_ADDR << 1; in idt_get_fw_data()
1156 pdev->inieecmd = EEPROM_USA; in idt_get_fw_data()
1157 pdev->eeaddr = eeprom_addr << 1; in idt_get_fw_data()
1162 pdev->eero = true; in idt_get_fw_data()
1164 pdev->eero = false; in idt_get_fw_data()
1167 pdev->eesize, pdev->eeaddr); in idt_get_fw_data()
1176 struct idt_89hpesx_dev *pdev; in idt_create_pdev() local
1179 pdev = devm_kmalloc(&client->dev, sizeof(struct idt_89hpesx_dev), in idt_create_pdev()
1181 if (pdev == NULL) in idt_create_pdev()
1185 pdev->client = client; in idt_create_pdev()
1186 i2c_set_clientdata(client, pdev); in idt_create_pdev()
1189 idt_get_fw_data(pdev); in idt_create_pdev()
1192 pdev->inicsrcmd = CSR_DWE; in idt_create_pdev()
1193 pdev->csr = CSR_DEF; in idt_create_pdev()
1197 pdev->iniccode = CCODE_PEC; in idt_create_pdev()
1200 pdev->iniccode = 0; in idt_create_pdev()
1203 return pdev; in idt_create_pdev()
1210 static void idt_free_pdev(struct idt_89hpesx_dev *pdev) in idt_free_pdev() argument
1213 i2c_set_clientdata(pdev->client, NULL); in idt_free_pdev()
1221 static int idt_set_smbus_ops(struct idt_89hpesx_dev *pdev) in idt_set_smbus_ops() argument
1223 struct i2c_adapter *adapter = pdev->client->adapter; in idt_set_smbus_ops()
1224 struct device *dev = &pdev->client->dev; in idt_set_smbus_ops()
1229 pdev->smb_read = idt_smb_read_block; in idt_set_smbus_ops()
1233 pdev->smb_read = idt_smb_read_i2c_block; in idt_set_smbus_ops()
1239 pdev->smb_read = idt_smb_read_word; in idt_set_smbus_ops()
1243 pdev->smb_read = idt_smb_read_byte; in idt_set_smbus_ops()
1253 pdev->smb_write = idt_smb_write_block; in idt_set_smbus_ops()
1257 pdev->smb_write = idt_smb_write_i2c_block; in idt_set_smbus_ops()
1263 pdev->smb_write = idt_smb_write_word; in idt_set_smbus_ops()
1267 pdev->smb_write = idt_smb_write_byte; in idt_set_smbus_ops()
1275 mutex_init(&pdev->smb_mtx); in idt_set_smbus_ops()
1285 static int idt_check_dev(struct idt_89hpesx_dev *pdev) in idt_check_dev() argument
1287 struct device *dev = &pdev->client->dev; in idt_check_dev()
1292 ret = idt_csr_read(pdev, IDT_VIDDID_CSR, &viddid); in idt_check_dev()
1315 static int idt_create_sysfs_files(struct idt_89hpesx_dev *pdev) in idt_create_sysfs_files() argument
1317 struct device *dev = &pdev->client->dev; in idt_create_sysfs_files()
1321 if (pdev->eesize == 0) { in idt_create_sysfs_files()
1327 pdev->ee_file = devm_kmalloc(dev, sizeof(*pdev->ee_file), GFP_KERNEL); in idt_create_sysfs_files()
1328 if (!pdev->ee_file) in idt_create_sysfs_files()
1332 memcpy(pdev->ee_file, &bin_attr_eeprom, sizeof(*pdev->ee_file)); in idt_create_sysfs_files()
1335 if (pdev->eero) { in idt_create_sysfs_files()
1336 pdev->ee_file->attr.mode &= ~0200; in idt_create_sysfs_files()
1337 pdev->ee_file->write = NULL; in idt_create_sysfs_files()
1340 pdev->ee_file->size = pdev->eesize; in idt_create_sysfs_files()
1341 ret = sysfs_create_bin_file(&dev->kobj, pdev->ee_file); in idt_create_sysfs_files()
1354 static void idt_remove_sysfs_files(struct idt_89hpesx_dev *pdev) in idt_remove_sysfs_files() argument
1356 struct device *dev = &pdev->client->dev; in idt_remove_sysfs_files()
1359 if (pdev->eesize == 0) in idt_remove_sysfs_files()
1363 sysfs_remove_bin_file(&dev->kobj, pdev->ee_file); in idt_remove_sysfs_files()
1371 static void idt_create_dbgfs_files(struct idt_89hpesx_dev *pdev) in idt_create_dbgfs_files() argument
1373 struct i2c_client *cli = pdev->client; in idt_create_dbgfs_files()
1378 pdev->csr_dir = debugfs_create_dir(fname, csr_dbgdir); in idt_create_dbgfs_files()
1381 pdev->csr_file = debugfs_create_file(cli->name, 0600, in idt_create_dbgfs_files()
1382 pdev->csr_dir, pdev, &csr_dbgfs_ops); in idt_create_dbgfs_files()
1389 static void idt_remove_dbgfs_files(struct idt_89hpesx_dev *pdev) in idt_remove_dbgfs_files() argument
1392 debugfs_remove_recursive(pdev->csr_dir); in idt_remove_dbgfs_files()
1400 struct idt_89hpesx_dev *pdev; in idt_probe() local
1404 pdev = idt_create_pdev(client); in idt_probe()
1405 if (IS_ERR(pdev)) in idt_probe()
1406 return PTR_ERR(pdev); in idt_probe()
1409 ret = idt_set_smbus_ops(pdev); in idt_probe()
1414 ret = idt_check_dev(pdev); in idt_probe()
1419 ret = idt_create_sysfs_files(pdev); in idt_probe()
1424 idt_create_dbgfs_files(pdev); in idt_probe()
1429 idt_free_pdev(pdev); in idt_probe()
1439 struct idt_89hpesx_dev *pdev = i2c_get_clientdata(client); in idt_remove() local
1442 idt_remove_dbgfs_files(pdev); in idt_remove()
1445 idt_remove_sysfs_files(pdev); in idt_remove()
1448 idt_free_pdev(pdev); in idt_remove()