Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

misc: xilinx_sdfec: Add ability to get/set config

- Add capability to get SD-FEC config data using ioctl
XSDFEC_GET_CONFIG.

- Add capability to set SD-FEC data order using ioctl
SDFEC_SET_ORDER.

- Add capability to set SD-FEC bypass option using ioctl
XSDFEC_SET_BYPASS.

- Add capability to set SD-FEC active state using ioctl
XSDFEC_IS_ACTIVE.

Tested-by: Dragan Cvetic <dragan.cvetic@xilinx.com>
Signed-off-by: Derek Kiernan <derek.kiernan@xilinx.com>
Signed-off-by: Dragan Cvetic <dragan.cvetic@xilinx.com>
Link: https://lore.kernel.org/r/1564216438-322406-5-git-send-email-dragan.cvetic@xilinx.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Dragan Cvetic and committed by
Greg Kroah-Hartman
77dd39d9 20ec628e

+145
+88
drivers/misc/xilinx_sdfec.c
··· 273 273 xsdfec->state = XSDFEC_STOPPED; 274 274 } 275 275 276 + static int xsdfec_get_config(struct xsdfec_dev *xsdfec, void __user *arg) 277 + { 278 + int err; 279 + 280 + err = copy_to_user(arg, &xsdfec->config, sizeof(xsdfec->config)); 281 + if (err) 282 + err = -EFAULT; 283 + 284 + return err; 285 + } 286 + 276 287 static int xsdfec_set_turbo(struct xsdfec_dev *xsdfec, void __user *arg) 277 288 { 278 289 struct xsdfec_turbo turbo; ··· 602 591 return ret; 603 592 } 604 593 594 + static int xsdfec_set_order(struct xsdfec_dev *xsdfec, void __user *arg) 595 + { 596 + bool order_invalid; 597 + enum xsdfec_order order; 598 + int err; 599 + 600 + err = get_user(order, (enum xsdfec_order *)arg); 601 + if (err) 602 + return -EFAULT; 603 + 604 + order_invalid = (order != XSDFEC_MAINTAIN_ORDER) && 605 + (order != XSDFEC_OUT_OF_ORDER); 606 + if (order_invalid) 607 + return -EINVAL; 608 + 609 + /* Verify Device has not started */ 610 + if (xsdfec->state == XSDFEC_STARTED) 611 + return -EIO; 612 + 613 + xsdfec_regwrite(xsdfec, XSDFEC_ORDER_ADDR, order); 614 + 615 + xsdfec->config.order = order; 616 + 617 + return 0; 618 + } 619 + 620 + static int xsdfec_set_bypass(struct xsdfec_dev *xsdfec, bool __user *arg) 621 + { 622 + bool bypass; 623 + int err; 624 + 625 + err = get_user(bypass, arg); 626 + if (err) 627 + return -EFAULT; 628 + 629 + /* Verify Device has not started */ 630 + if (xsdfec->state == XSDFEC_STARTED) 631 + return -EIO; 632 + 633 + if (bypass) 634 + xsdfec_regwrite(xsdfec, XSDFEC_BYPASS_ADDR, 1); 635 + else 636 + xsdfec_regwrite(xsdfec, XSDFEC_BYPASS_ADDR, 0); 637 + 638 + xsdfec->config.bypass = bypass; 639 + 640 + return 0; 641 + } 642 + 643 + static int xsdfec_is_active(struct xsdfec_dev *xsdfec, bool __user *arg) 644 + { 645 + u32 reg_value; 646 + bool is_active; 647 + int err; 648 + 649 + reg_value = xsdfec_regread(xsdfec, XSDFEC_ACTIVE_ADDR); 650 + /* using a double ! operator instead of casting */ 651 + is_active = !!(reg_value & XSDFEC_IS_ACTIVITY_SET); 652 + err = put_user(is_active, arg); 653 + if (err) 654 + return -EFAULT; 655 + 656 + return err; 657 + } 658 + 605 659 static u32 606 660 xsdfec_translate_axis_width_cfg_val(enum xsdfec_axis_width axis_width_cfg) 607 661 { ··· 757 681 } 758 682 759 683 switch (cmd) { 684 + case XSDFEC_GET_CONFIG: 685 + rval = xsdfec_get_config(xsdfec, arg); 686 + break; 760 687 case XSDFEC_SET_TURBO: 761 688 rval = xsdfec_set_turbo(xsdfec, arg); 762 689 break; ··· 768 689 break; 769 690 case XSDFEC_ADD_LDPC_CODE_PARAMS: 770 691 rval = xsdfec_add_ldpc(xsdfec, arg); 692 + break; 693 + case XSDFEC_SET_ORDER: 694 + rval = xsdfec_set_order(xsdfec, arg); 695 + break; 696 + case XSDFEC_SET_BYPASS: 697 + rval = xsdfec_set_bypass(xsdfec, arg); 698 + break; 699 + case XSDFEC_IS_ACTIVE: 700 + rval = xsdfec_is_active(xsdfec, (bool __user *)arg); 771 701 break; 772 702 default: 773 703 /* Should not get here */
+57
include/uapi/misc/xilinx_sdfec.h
··· 288 288 #define XSDFEC_ADD_LDPC_CODE_PARAMS \ 289 289 _IOW(XSDFEC_MAGIC, 5, struct xsdfec_ldpc_params) 290 290 /** 291 + * DOC: XSDFEC_GET_CONFIG 292 + * @Parameters 293 + * 294 + * @struct xsdfec_config * 295 + * Pointer to the &struct xsdfec_config that contains the current 296 + * configuration settings of the SD-FEC Block 297 + * 298 + * @Description 299 + * 300 + * ioctl that returns SD-FEC core configuration 301 + */ 302 + #define XSDFEC_GET_CONFIG _IOR(XSDFEC_MAGIC, 6, struct xsdfec_config) 303 + /** 291 304 * DOC: XSDFEC_GET_TURBO 292 305 * @Parameters 293 306 * ··· 313 300 * ioctl that returns SD-FEC turbo param values 314 301 */ 315 302 #define XSDFEC_GET_TURBO _IOR(XSDFEC_MAGIC, 7, struct xsdfec_turbo) 303 + /** 304 + * DOC: XSDFEC_SET_ORDER 305 + * @Parameters 306 + * 307 + * @struct unsigned long * 308 + * Pointer to the unsigned long that contains a value from the 309 + * @enum xsdfec_order 310 + * 311 + * @Description 312 + * 313 + * ioctl that sets order, if order of blocks can change from input to output 314 + * 315 + * This can only be used when the driver is in the XSDFEC_STOPPED state 316 + */ 317 + #define XSDFEC_SET_ORDER _IOW(XSDFEC_MAGIC, 8, unsigned long) 318 + /** 319 + * DOC: XSDFEC_SET_BYPASS 320 + * @Parameters 321 + * 322 + * @struct bool * 323 + * Pointer to bool that sets the bypass value, where false results in 324 + * normal operation and false results in the SD-FEC performing the 325 + * configured operations (same number of cycles) but output data matches 326 + * the input data 327 + * 328 + * @Description 329 + * 330 + * ioctl that sets bypass. 331 + * 332 + * This can only be used when the driver is in the XSDFEC_STOPPED state 333 + */ 334 + #define XSDFEC_SET_BYPASS _IOW(XSDFEC_MAGIC, 9, bool) 335 + /** 336 + * DOC: XSDFEC_IS_ACTIVE 337 + * @Parameters 338 + * 339 + * @struct bool * 340 + * Pointer to bool that returns true if the SD-FEC is processing data 341 + * 342 + * @Description 343 + * 344 + * ioctl that determines if SD-FEC is processing data 345 + */ 346 + #define XSDFEC_IS_ACTIVE _IOR(XSDFEC_MAGIC, 10, bool) 316 347 #endif /* __XILINX_SDFEC_H__ */