Lines Matching full:scom
3 * SCOM FSI Client device driver
22 /* SCOM engine register set */
47 /* SCOM address encodings */
51 /* SCOM indirect stuff */
145 static int put_indirect_scom_form0(struct scom_device *scom, uint64_t value, in put_indirect_scom_form0() argument
156 rc = __put_scom(scom, ind_data, ind_addr, status); in put_indirect_scom_form0()
160 rc = __get_scom(scom, &ind_data, addr, status); in put_indirect_scom_form0()
170 static int put_indirect_scom_form1(struct scom_device *scom, uint64_t value, in put_indirect_scom_form1() argument
180 return __put_scom(scom, ind_data, ind_addr, status); in put_indirect_scom_form1()
183 static int get_indirect_scom_form0(struct scom_device *scom, uint64_t *value, in get_indirect_scom_form0() argument
191 rc = __put_scom(scom, ind_data, ind_addr, status); in get_indirect_scom_form0()
195 rc = __get_scom(scom, &ind_data, addr, status); in get_indirect_scom_form0()
206 static int raw_put_scom(struct scom_device *scom, uint64_t value, in raw_put_scom() argument
211 return put_indirect_scom_form1(scom, value, addr, status); in raw_put_scom()
213 return put_indirect_scom_form0(scom, value, addr, status); in raw_put_scom()
215 return __put_scom(scom, value, addr, status); in raw_put_scom()
218 static int raw_get_scom(struct scom_device *scom, uint64_t *value, in raw_get_scom() argument
224 return get_indirect_scom_form0(scom, value, addr, status); in raw_get_scom()
226 return __get_scom(scom, value, addr, status); in raw_get_scom()
229 static int handle_fsi2pib_status(struct scom_device *scom, uint32_t status) in handle_fsi2pib_status() argument
234 fsi_device_write(scom->fsi_dev, SCOM_FSI2PIB_RESET_REG, &dummy, in handle_fsi2pib_status()
247 static int handle_pib_status(struct scom_device *scom, uint8_t status) in handle_pib_status() argument
257 fsi_device_write(scom->fsi_dev, SCOM_FSI2PIB_RESET_REG, &dummy, in handle_pib_status()
275 static int put_scom(struct scom_device *scom, uint64_t value, in put_scom() argument
281 rc = raw_put_scom(scom, value, addr, &status); in put_scom()
285 rc = handle_fsi2pib_status(scom, status); in put_scom()
289 return handle_pib_status(scom, in put_scom()
294 static int get_scom(struct scom_device *scom, uint64_t *value, in get_scom() argument
300 rc = raw_get_scom(scom, value, addr, &status); in get_scom()
304 rc = handle_fsi2pib_status(scom, status); in get_scom()
308 return handle_pib_status(scom, in get_scom()
316 struct scom_device *scom = filep->private_data; in scom_read() local
317 struct device *dev = &scom->fsi_dev->dev; in scom_read()
324 mutex_lock(&scom->lock); in scom_read()
325 if (scom->dead) in scom_read()
328 rc = get_scom(scom, &val, *offset); in scom_read()
329 mutex_unlock(&scom->lock); in scom_read()
346 struct scom_device *scom = filep->private_data; in scom_write() local
347 struct device *dev = &scom->fsi_dev->dev; in scom_write()
359 mutex_lock(&scom->lock); in scom_write()
360 if (scom->dead) in scom_write()
363 rc = put_scom(scom, val, *offset); in scom_write()
364 mutex_unlock(&scom->lock); in scom_write()
404 static int scom_raw_read(struct scom_device *scom, void __user *argp) in scom_raw_read() argument
413 rc = raw_get_scom(scom, &acc.data, acc.addr, &status); in scom_raw_read()
422 static int scom_raw_write(struct scom_device *scom, void __user *argp) in scom_raw_write() argument
433 rc = raw_get_scom(scom, &prev_data, acc.addr, &status); in scom_raw_write()
443 rc = raw_put_scom(scom, data, acc.addr, &status); in scom_raw_write()
453 static int scom_reset(struct scom_device *scom, void __user *argp) in scom_reset() argument
461 rc = fsi_device_write(scom->fsi_dev, SCOM_PIB_RESET_REG, &dummy, in scom_reset()
464 rc = fsi_device_write(scom->fsi_dev, SCOM_FSI2PIB_RESET_REG, &dummy, in scom_reset()
469 static int scom_check(struct scom_device *scom, void __user *argp) in scom_check() argument
477 struct scom_device *scom = file->private_data; in scom_ioctl() local
481 mutex_lock(&scom->lock); in scom_ioctl()
482 if (scom->dead) { in scom_ioctl()
483 mutex_unlock(&scom->lock); in scom_ioctl()
488 rc = scom_check(scom, argp); in scom_ioctl()
491 rc = scom_raw_read(scom, argp); in scom_ioctl()
494 rc = scom_raw_write(scom, argp); in scom_ioctl()
497 rc = scom_reset(scom, argp); in scom_ioctl()
500 mutex_unlock(&scom->lock); in scom_ioctl()
506 struct scom_device *scom = container_of(inode->i_cdev, struct scom_device, cdev); in scom_open() local
508 file->private_data = scom; in scom_open()
524 struct scom_device *scom = container_of(dev, struct scom_device, dev); in scom_free() local
526 put_device(&scom->fsi_dev->dev); in scom_free()
527 kfree(scom); in scom_free()
533 struct scom_device *scom; in scom_probe() local
536 scom = kzalloc(sizeof(*scom), GFP_KERNEL); in scom_probe()
537 if (!scom) in scom_probe()
539 dev_set_drvdata(dev, scom); in scom_probe()
540 mutex_init(&scom->lock); in scom_probe()
544 kfree(scom); in scom_probe()
547 scom->fsi_dev = fsi_dev; in scom_probe()
550 scom->dev.type = &fsi_cdev_type; in scom_probe()
551 scom->dev.parent = dev; in scom_probe()
552 scom->dev.release = scom_free; in scom_probe()
553 device_initialize(&scom->dev); in scom_probe()
556 rc = fsi_get_new_minor(fsi_dev, fsi_dev_scom, &scom->dev.devt, &didx); in scom_probe()
560 dev_set_name(&scom->dev, "scom%d", didx); in scom_probe()
561 cdev_init(&scom->cdev, &scom_fops); in scom_probe()
562 rc = cdev_device_add(&scom->cdev, &scom->dev); in scom_probe()
565 rc, dev_name(&scom->dev)); in scom_probe()
571 fsi_free_minor(scom->dev.devt); in scom_probe()
573 put_device(&scom->dev); in scom_probe()
579 struct scom_device *scom = dev_get_drvdata(dev); in scom_remove() local
581 mutex_lock(&scom->lock); in scom_remove()
582 scom->dead = true; in scom_remove()
583 mutex_unlock(&scom->lock); in scom_remove()
584 cdev_device_del(&scom->cdev, &scom->dev); in scom_remove()
585 fsi_free_minor(scom->dev.devt); in scom_remove()
586 put_device(&scom->dev); in scom_remove()
608 .name = "scom",
628 MODULE_DESCRIPTION("SCOM FSI Client device driver");