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.

mfd: twl: Remove platform data support

There is no in-tree machine that provides a struct twl4030_platform_data
since commit e92fc4f04a34 ("ARM: OMAP2+: Drop legacy board file for
LDP"). So assume dev_get_platdata() returns NULL in twl_probe() and
simplify accordingly.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Link: https://lore.kernel.org/r/20220614152148.252820-1-u.kleine-koenig@pengutronix.de

authored by

Uwe Kleine-König and committed by
Lee Jones
4a346a03 4907f699

+5 -373
+5 -318
drivers/mfd/twl-core.c
··· 656 656 can_wakeup, irq0, irq1); 657 657 } 658 658 659 - static struct device * 660 - add_regulator_linked(int num, struct regulator_init_data *pdata, 661 - struct regulator_consumer_supply *consumers, 662 - unsigned num_consumers, unsigned long features) 663 - { 664 - struct twl_regulator_driver_data drv_data; 665 - 666 - /* regulator framework demands init_data ... */ 667 - if (!pdata) 668 - return NULL; 669 - 670 - if (consumers) { 671 - pdata->consumer_supplies = consumers; 672 - pdata->num_consumer_supplies = num_consumers; 673 - } 674 - 675 - if (pdata->driver_data) { 676 - /* If we have existing drv_data, just add the flags */ 677 - struct twl_regulator_driver_data *tmp; 678 - tmp = pdata->driver_data; 679 - tmp->features |= features; 680 - } else { 681 - /* add new driver data struct, used only during init */ 682 - drv_data.features = features; 683 - drv_data.set_voltage = NULL; 684 - drv_data.get_voltage = NULL; 685 - drv_data.data = NULL; 686 - pdata->driver_data = &drv_data; 687 - } 688 - 689 - /* NOTE: we currently ignore regulator IRQs, e.g. for short circuits */ 690 - return add_numbered_child(TWL_MODULE_PM_MASTER, "twl_reg", num, 691 - pdata, sizeof(*pdata), false, 0, 0); 692 - } 693 - 694 - static struct device * 695 - add_regulator(int num, struct regulator_init_data *pdata, 696 - unsigned long features) 697 - { 698 - return add_regulator_linked(num, pdata, NULL, 0, features); 699 - } 700 - 701 - /* 702 - * NOTE: We know the first 8 IRQs after pdata->base_irq are 703 - * for the PIH, and the next are for the PWR_INT SIH, since 704 - * that's how twl_init_irq() sets things up. 705 - */ 706 - 707 - static int 708 - add_children(struct twl4030_platform_data *pdata, unsigned irq_base, 709 - unsigned long features) 710 - { 711 - struct device *child; 712 - 713 - if (IS_ENABLED(CONFIG_GPIO_TWL4030) && pdata->gpio) { 714 - child = add_child(TWL4030_MODULE_GPIO, "twl4030_gpio", 715 - pdata->gpio, sizeof(*pdata->gpio), 716 - false, irq_base + GPIO_INTR_OFFSET, 0); 717 - if (IS_ERR(child)) 718 - return PTR_ERR(child); 719 - } 720 - 721 - if (IS_ENABLED(CONFIG_KEYBOARD_TWL4030) && pdata->keypad) { 722 - child = add_child(TWL4030_MODULE_KEYPAD, "twl4030_keypad", 723 - pdata->keypad, sizeof(*pdata->keypad), 724 - true, irq_base + KEYPAD_INTR_OFFSET, 0); 725 - if (IS_ERR(child)) 726 - return PTR_ERR(child); 727 - } 728 - 729 - if (IS_ENABLED(CONFIG_TWL4030_MADC) && pdata->madc && 730 - twl_class_is_4030()) { 731 - child = add_child(TWL4030_MODULE_MADC, "twl4030_madc", 732 - pdata->madc, sizeof(*pdata->madc), 733 - true, irq_base + MADC_INTR_OFFSET, 0); 734 - if (IS_ERR(child)) 735 - return PTR_ERR(child); 736 - } 737 - 738 - if (IS_ENABLED(CONFIG_RTC_DRV_TWL4030)) { 739 - /* 740 - * REVISIT platform_data here currently might expose the 741 - * "msecure" line ... but for now we just expect board 742 - * setup to tell the chip "it's always ok to SET_TIME". 743 - * Eventually, Linux might become more aware of such 744 - * HW security concerns, and "least privilege". 745 - */ 746 - child = add_child(TWL_MODULE_RTC, "twl_rtc", NULL, 0, 747 - true, irq_base + RTC_INTR_OFFSET, 0); 748 - if (IS_ERR(child)) 749 - return PTR_ERR(child); 750 - } 751 - 752 - if (IS_ENABLED(CONFIG_PWM_TWL)) { 753 - child = add_child(TWL_MODULE_PWM, "twl-pwm", NULL, 0, 754 - false, 0, 0); 755 - if (IS_ERR(child)) 756 - return PTR_ERR(child); 757 - } 758 - 759 - if (IS_ENABLED(CONFIG_PWM_TWL_LED)) { 760 - child = add_child(TWL_MODULE_LED, "twl-pwmled", NULL, 0, 761 - false, 0, 0); 762 - if (IS_ERR(child)) 763 - return PTR_ERR(child); 764 - } 765 - 766 - if (IS_ENABLED(CONFIG_TWL4030_USB) && pdata->usb && 767 - twl_class_is_4030()) { 768 - 769 - static struct regulator_consumer_supply usb1v5 = { 770 - .supply = "usb1v5", 771 - }; 772 - static struct regulator_consumer_supply usb1v8 = { 773 - .supply = "usb1v8", 774 - }; 775 - static struct regulator_consumer_supply usb3v1 = { 776 - .supply = "usb3v1", 777 - }; 778 - 779 - /* First add the regulators so that they can be used by transceiver */ 780 - if (IS_ENABLED(CONFIG_REGULATOR_TWL4030)) { 781 - /* this is a template that gets copied */ 782 - struct regulator_init_data usb_fixed = { 783 - .constraints.valid_modes_mask = 784 - REGULATOR_MODE_NORMAL 785 - | REGULATOR_MODE_STANDBY, 786 - .constraints.valid_ops_mask = 787 - REGULATOR_CHANGE_MODE 788 - | REGULATOR_CHANGE_STATUS, 789 - }; 790 - 791 - child = add_regulator_linked(TWL4030_REG_VUSB1V5, 792 - &usb_fixed, &usb1v5, 1, 793 - features); 794 - if (IS_ERR(child)) 795 - return PTR_ERR(child); 796 - 797 - child = add_regulator_linked(TWL4030_REG_VUSB1V8, 798 - &usb_fixed, &usb1v8, 1, 799 - features); 800 - if (IS_ERR(child)) 801 - return PTR_ERR(child); 802 - 803 - child = add_regulator_linked(TWL4030_REG_VUSB3V1, 804 - &usb_fixed, &usb3v1, 1, 805 - features); 806 - if (IS_ERR(child)) 807 - return PTR_ERR(child); 808 - 809 - } 810 - 811 - child = add_child(TWL_MODULE_USB, "twl4030_usb", 812 - pdata->usb, sizeof(*pdata->usb), true, 813 - /* irq0 = USB_PRES, irq1 = USB */ 814 - irq_base + USB_PRES_INTR_OFFSET, 815 - irq_base + USB_INTR_OFFSET); 816 - 817 - if (IS_ERR(child)) 818 - return PTR_ERR(child); 819 - 820 - /* we need to connect regulators to this transceiver */ 821 - if (IS_ENABLED(CONFIG_REGULATOR_TWL4030) && child) { 822 - usb1v5.dev_name = dev_name(child); 823 - usb1v8.dev_name = dev_name(child); 824 - usb3v1.dev_name = dev_name(child); 825 - } 826 - } 827 - 828 - if (IS_ENABLED(CONFIG_TWL4030_WATCHDOG) && twl_class_is_4030()) { 829 - child = add_child(TWL_MODULE_PM_RECEIVER, "twl4030_wdt", NULL, 830 - 0, false, 0, 0); 831 - if (IS_ERR(child)) 832 - return PTR_ERR(child); 833 - } 834 - 835 - if (IS_ENABLED(CONFIG_INPUT_TWL4030_PWRBUTTON) && twl_class_is_4030()) { 836 - child = add_child(TWL_MODULE_PM_MASTER, "twl4030_pwrbutton", 837 - NULL, 0, true, irq_base + 8 + 0, 0); 838 - if (IS_ERR(child)) 839 - return PTR_ERR(child); 840 - } 841 - 842 - if (IS_ENABLED(CONFIG_MFD_TWL4030_AUDIO) && pdata->audio && 843 - twl_class_is_4030()) { 844 - child = add_child(TWL4030_MODULE_AUDIO_VOICE, "twl4030-audio", 845 - pdata->audio, sizeof(*pdata->audio), 846 - false, 0, 0); 847 - if (IS_ERR(child)) 848 - return PTR_ERR(child); 849 - } 850 - 851 - /* twl4030 regulators */ 852 - if (IS_ENABLED(CONFIG_REGULATOR_TWL4030) && twl_class_is_4030()) { 853 - child = add_regulator(TWL4030_REG_VPLL1, pdata->vpll1, 854 - features); 855 - if (IS_ERR(child)) 856 - return PTR_ERR(child); 857 - 858 - child = add_regulator(TWL4030_REG_VIO, pdata->vio, 859 - features); 860 - if (IS_ERR(child)) 861 - return PTR_ERR(child); 862 - 863 - child = add_regulator(TWL4030_REG_VDD1, pdata->vdd1, 864 - features); 865 - if (IS_ERR(child)) 866 - return PTR_ERR(child); 867 - 868 - child = add_regulator(TWL4030_REG_VDD2, pdata->vdd2, 869 - features); 870 - if (IS_ERR(child)) 871 - return PTR_ERR(child); 872 - 873 - child = add_regulator(TWL4030_REG_VMMC1, pdata->vmmc1, 874 - features); 875 - if (IS_ERR(child)) 876 - return PTR_ERR(child); 877 - 878 - child = add_regulator(TWL4030_REG_VDAC, pdata->vdac, 879 - features); 880 - if (IS_ERR(child)) 881 - return PTR_ERR(child); 882 - 883 - child = add_regulator((features & TWL4030_VAUX2) 884 - ? TWL4030_REG_VAUX2_4030 885 - : TWL4030_REG_VAUX2, 886 - pdata->vaux2, features); 887 - if (IS_ERR(child)) 888 - return PTR_ERR(child); 889 - 890 - child = add_regulator(TWL4030_REG_VINTANA1, pdata->vintana1, 891 - features); 892 - if (IS_ERR(child)) 893 - return PTR_ERR(child); 894 - 895 - child = add_regulator(TWL4030_REG_VINTANA2, pdata->vintana2, 896 - features); 897 - if (IS_ERR(child)) 898 - return PTR_ERR(child); 899 - 900 - child = add_regulator(TWL4030_REG_VINTDIG, pdata->vintdig, 901 - features); 902 - if (IS_ERR(child)) 903 - return PTR_ERR(child); 904 - } 905 - 906 - /* maybe add LDOs that are omitted on cost-reduced parts */ 907 - if (IS_ENABLED(CONFIG_REGULATOR_TWL4030) && !(features & TPS_SUBSET) 908 - && twl_class_is_4030()) { 909 - child = add_regulator(TWL4030_REG_VPLL2, pdata->vpll2, 910 - features); 911 - if (IS_ERR(child)) 912 - return PTR_ERR(child); 913 - 914 - child = add_regulator(TWL4030_REG_VMMC2, pdata->vmmc2, 915 - features); 916 - if (IS_ERR(child)) 917 - return PTR_ERR(child); 918 - 919 - child = add_regulator(TWL4030_REG_VSIM, pdata->vsim, 920 - features); 921 - if (IS_ERR(child)) 922 - return PTR_ERR(child); 923 - 924 - child = add_regulator(TWL4030_REG_VAUX1, pdata->vaux1, 925 - features); 926 - if (IS_ERR(child)) 927 - return PTR_ERR(child); 928 - 929 - child = add_regulator(TWL4030_REG_VAUX3, pdata->vaux3, 930 - features); 931 - if (IS_ERR(child)) 932 - return PTR_ERR(child); 933 - 934 - child = add_regulator(TWL4030_REG_VAUX4, pdata->vaux4, 935 - features); 936 - if (IS_ERR(child)) 937 - return PTR_ERR(child); 938 - } 939 - 940 - if (IS_ENABLED(CONFIG_CHARGER_TWL4030) && pdata->bci && 941 - !(features & (TPS_SUBSET | TWL5031))) { 942 - child = add_child(TWL_MODULE_MAIN_CHARGE, "twl4030_bci", 943 - pdata->bci, sizeof(*pdata->bci), false, 944 - /* irq0 = CHG_PRES, irq1 = BCI */ 945 - irq_base + BCI_PRES_INTR_OFFSET, 946 - irq_base + BCI_INTR_OFFSET); 947 - if (IS_ERR(child)) 948 - return PTR_ERR(child); 949 - } 950 - 951 - if (IS_ENABLED(CONFIG_TWL4030_POWER) && pdata->power) { 952 - child = add_child(TWL_MODULE_PM_MASTER, "twl4030_power", 953 - pdata->power, sizeof(*pdata->power), false, 954 - 0, 0); 955 - if (IS_ERR(child)) 956 - return PTR_ERR(child); 957 - } 958 - 959 - return 0; 960 - } 961 - 962 659 /*----------------------------------------------------------------------*/ 963 660 964 661 /* ··· 684 987 return e; 685 988 } 686 989 687 - static void clocks_init(struct device *dev, 688 - struct twl4030_clock_init_data *clock) 990 + static void clocks_init(struct device *dev) 689 991 { 690 992 int e = 0; 691 993 struct clk *osc; ··· 714 1018 } 715 1019 716 1020 ctrl |= HIGH_PERF_SQ; 717 - if (clock && clock->ck32k_lowpwr_enable) 718 - ctrl |= CK32K_LOWPWR_EN; 719 1021 720 1022 e |= unprotect_pm_master(); 721 1023 /* effect->MADC+USB ck en */ ··· 757 1063 static int 758 1064 twl_probe(struct i2c_client *client, const struct i2c_device_id *id) 759 1065 { 760 - struct twl4030_platform_data *pdata = dev_get_platdata(&client->dev); 761 1066 struct device_node *node = client->dev.of_node; 762 1067 struct platform_device *pdev; 763 1068 const struct regmap_config *twl_regmap_config; ··· 764 1071 int status; 765 1072 unsigned i, num_slaves; 766 1073 767 - if (!node && !pdata) { 1074 + if (!node) { 768 1075 dev_err(&client->dev, "no platform data\n"); 769 1076 return -EINVAL; 770 1077 } ··· 854 1161 twl_priv->ready = true; 855 1162 856 1163 /* setup clock framework */ 857 - clocks_init(&client->dev, pdata ? pdata->clock : NULL); 1164 + clocks_init(&client->dev); 858 1165 859 1166 /* read TWL IDCODE Register */ 860 1167 if (twl_class_is_4030()) { ··· 902 1209 TWL4030_DCDC_GLOBAL_CFG); 903 1210 } 904 1211 905 - if (node) { 906 - if (pdata) 907 - twl_auxdata_lookup[0].platform_data = pdata->gpio; 908 - status = of_platform_populate(node, NULL, twl_auxdata_lookup, 909 - &client->dev); 910 - } else { 911 - status = add_children(pdata, irq_base, id->driver_data); 912 - } 1212 + status = of_platform_populate(node, NULL, twl_auxdata_lookup, 1213 + &client->dev); 913 1214 914 1215 fail: 915 1216 if (status < 0)
-55
include/linux/mfd/twl.h
··· 694 694 unsigned int irq_base; 695 695 }; 696 696 697 - struct twl4030_platform_data { 698 - struct twl4030_clock_init_data *clock; 699 - struct twl4030_bci_platform_data *bci; 700 - struct twl4030_gpio_platform_data *gpio; 701 - struct twl4030_madc_platform_data *madc; 702 - struct twl4030_keypad_data *keypad; 703 - struct twl4030_usb_data *usb; 704 - struct twl4030_power_data *power; 705 - struct twl4030_audio_data *audio; 706 - 707 - /* Common LDO regulators for TWL4030/TWL6030 */ 708 - struct regulator_init_data *vdac; 709 - struct regulator_init_data *vaux1; 710 - struct regulator_init_data *vaux2; 711 - struct regulator_init_data *vaux3; 712 - struct regulator_init_data *vdd1; 713 - struct regulator_init_data *vdd2; 714 - struct regulator_init_data *vdd3; 715 - /* TWL4030 LDO regulators */ 716 - struct regulator_init_data *vpll1; 717 - struct regulator_init_data *vpll2; 718 - struct regulator_init_data *vmmc1; 719 - struct regulator_init_data *vmmc2; 720 - struct regulator_init_data *vsim; 721 - struct regulator_init_data *vaux4; 722 - struct regulator_init_data *vio; 723 - struct regulator_init_data *vintana1; 724 - struct regulator_init_data *vintana2; 725 - struct regulator_init_data *vintdig; 726 - /* TWL6030 LDO regulators */ 727 - struct regulator_init_data *vmmc; 728 - struct regulator_init_data *vpp; 729 - struct regulator_init_data *vusim; 730 - struct regulator_init_data *vana; 731 - struct regulator_init_data *vcxio; 732 - struct regulator_init_data *vusb; 733 - struct regulator_init_data *clk32kg; 734 - struct regulator_init_data *v1v8; 735 - struct regulator_init_data *v2v1; 736 - /* TWL6032 LDO regulators */ 737 - struct regulator_init_data *ldo1; 738 - struct regulator_init_data *ldo2; 739 - struct regulator_init_data *ldo3; 740 - struct regulator_init_data *ldo4; 741 - struct regulator_init_data *ldo5; 742 - struct regulator_init_data *ldo6; 743 - struct regulator_init_data *ldo7; 744 - struct regulator_init_data *ldoln; 745 - struct regulator_init_data *ldousb; 746 - /* TWL6032 DCDC regulators */ 747 - struct regulator_init_data *smps3; 748 - struct regulator_init_data *smps4; 749 - struct regulator_init_data *vio6025; 750 - }; 751 - 752 697 struct twl_regulator_driver_data { 753 698 int (*set_voltage)(void *data, int target_uV); 754 699 int (*get_voltage)(void *data);