pinctrl-imx.c (6724af486903df57338c14424e02599e371cf563) | pinctrl-imx.c (323de9efdf3e75d1dfb48003a52e59d6d9d4c7a5) |
---|---|
1/* 2 * Core driver for the imx pin controller 3 * 4 * Copyright (C) 2012 Freescale Semiconductor, Inc. 5 * Copyright (C) 2012 Linaro Ltd. 6 * 7 * Author: Dong Aisheng <dong.aisheng@linaro.org> 8 * --- 592 unchanged lines hidden (view full) --- 601 func->groups[i] = child->name; 602 grp = &info->groups[grp_index++]; 603 imx_pinctrl_parse_groups(child, grp, info, i++); 604 } 605 606 return 0; 607} 608 | 1/* 2 * Core driver for the imx pin controller 3 * 4 * Copyright (C) 2012 Freescale Semiconductor, Inc. 5 * Copyright (C) 2012 Linaro Ltd. 6 * 7 * Author: Dong Aisheng <dong.aisheng@linaro.org> 8 * --- 592 unchanged lines hidden (view full) --- 601 func->groups[i] = child->name; 602 grp = &info->groups[grp_index++]; 603 imx_pinctrl_parse_groups(child, grp, info, i++); 604 } 605 606 return 0; 607} 608 |
609/* 610 * Check if the DT contains pins in the direct child nodes. This indicates the 611 * newer DT format to store pins. This function returns true if the first found 612 * fsl,pins property is in a child of np. Otherwise false is returned. 613 */ 614static bool imx_pinctrl_dt_is_flat_functions(struct device_node *np) 615{ 616 struct device_node *function_np; 617 struct device_node *pinctrl_np; 618 619 for_each_child_of_node(np, function_np) { 620 if (of_property_read_bool(function_np, "fsl,pins")) 621 return true; 622 623 for_each_child_of_node(function_np, pinctrl_np) { 624 if (of_property_read_bool(pinctrl_np, "fsl,pins")) 625 return false; 626 } 627 } 628 629 return true; 630} 631 |
|
609static int imx_pinctrl_probe_dt(struct platform_device *pdev, 610 struct imx_pinctrl_soc_info *info) 611{ 612 struct device_node *np = pdev->dev.of_node; 613 struct device_node *child; 614 u32 nfuncs = 0; 615 u32 i = 0; | 632static int imx_pinctrl_probe_dt(struct platform_device *pdev, 633 struct imx_pinctrl_soc_info *info) 634{ 635 struct device_node *np = pdev->dev.of_node; 636 struct device_node *child; 637 u32 nfuncs = 0; 638 u32 i = 0; |
639 bool flat_funcs; |
|
616 617 if (!np) 618 return -ENODEV; 619 | 640 641 if (!np) 642 return -ENODEV; 643 |
620 nfuncs = of_get_child_count(np); 621 if (nfuncs <= 0) { 622 dev_err(&pdev->dev, "no functions defined\n"); 623 return -EINVAL; | 644 flat_funcs = imx_pinctrl_dt_is_flat_functions(np); 645 if (flat_funcs) { 646 nfuncs = 1; 647 } else { 648 nfuncs = of_get_child_count(np); 649 if (nfuncs <= 0) { 650 dev_err(&pdev->dev, "no functions defined\n"); 651 return -EINVAL; 652 } |
624 } 625 626 info->nfunctions = nfuncs; 627 info->functions = devm_kzalloc(&pdev->dev, nfuncs * sizeof(struct imx_pmx_func), 628 GFP_KERNEL); 629 if (!info->functions) 630 return -ENOMEM; 631 | 653 } 654 655 info->nfunctions = nfuncs; 656 info->functions = devm_kzalloc(&pdev->dev, nfuncs * sizeof(struct imx_pmx_func), 657 GFP_KERNEL); 658 if (!info->functions) 659 return -ENOMEM; 660 |
632 info->ngroups = 0; 633 for_each_child_of_node(np, child) 634 info->ngroups += of_get_child_count(child); | 661 if (flat_funcs) { 662 info->ngroups = of_get_child_count(np); 663 } else { 664 info->ngroups = 0; 665 for_each_child_of_node(np, child) 666 info->ngroups += of_get_child_count(child); 667 } |
635 info->groups = devm_kzalloc(&pdev->dev, info->ngroups * sizeof(struct imx_pin_group), 636 GFP_KERNEL); 637 if (!info->groups) 638 return -ENOMEM; 639 | 668 info->groups = devm_kzalloc(&pdev->dev, info->ngroups * sizeof(struct imx_pin_group), 669 GFP_KERNEL); 670 if (!info->groups) 671 return -ENOMEM; 672 |
640 for_each_child_of_node(np, child) 641 imx_pinctrl_parse_functions(child, info, i++); | 673 if (flat_funcs) { 674 imx_pinctrl_parse_functions(np, info, 0); 675 } else { 676 for_each_child_of_node(np, child) 677 imx_pinctrl_parse_functions(child, info, i++); 678 } |
642 643 return 0; 644} 645 646int imx_pinctrl_probe(struct platform_device *pdev, 647 struct imx_pinctrl_soc_info *info) 648{ 649 struct imx_pinctrl *ipctl; --- 35 unchanged lines hidden (view full) --- 685 dev_err(&pdev->dev, "fail to probe dt properties\n"); 686 return ret; 687 } 688 689 ipctl->info = info; 690 ipctl->dev = info->dev; 691 platform_set_drvdata(pdev, ipctl); 692 ipctl->pctl = pinctrl_register(&imx_pinctrl_desc, &pdev->dev, ipctl); | 679 680 return 0; 681} 682 683int imx_pinctrl_probe(struct platform_device *pdev, 684 struct imx_pinctrl_soc_info *info) 685{ 686 struct imx_pinctrl *ipctl; --- 35 unchanged lines hidden (view full) --- 722 dev_err(&pdev->dev, "fail to probe dt properties\n"); 723 return ret; 724 } 725 726 ipctl->info = info; 727 ipctl->dev = info->dev; 728 platform_set_drvdata(pdev, ipctl); 729 ipctl->pctl = pinctrl_register(&imx_pinctrl_desc, &pdev->dev, ipctl); |
693 if (!ipctl->pctl) { | 730 if (IS_ERR(ipctl->pctl)) { |
694 dev_err(&pdev->dev, "could not register IMX pinctrl driver\n"); | 731 dev_err(&pdev->dev, "could not register IMX pinctrl driver\n"); |
695 return -EINVAL; | 732 return PTR_ERR(ipctl->pctl); |
696 } 697 698 dev_info(&pdev->dev, "initialized IMX pinctrl driver\n"); 699 700 return 0; 701} 702 703int imx_pinctrl_remove(struct platform_device *pdev) 704{ 705 struct imx_pinctrl *ipctl = platform_get_drvdata(pdev); 706 707 pinctrl_unregister(ipctl->pctl); 708 709 return 0; 710} | 733 } 734 735 dev_info(&pdev->dev, "initialized IMX pinctrl driver\n"); 736 737 return 0; 738} 739 740int imx_pinctrl_remove(struct platform_device *pdev) 741{ 742 struct imx_pinctrl *ipctl = platform_get_drvdata(pdev); 743 744 pinctrl_unregister(ipctl->pctl); 745 746 return 0; 747} |