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: bcm2835-pm: Use 'reg-names' to get resources

If available in firmware, find resources by their 'reg-names' position
instead of relying on hardcoded offsets. Care is taken to support old
firmware nonetheless.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Link: https://lore.kernel.org/r/20220625113619.15944-7-stefan.wahren@i2se.com

authored by

Nicolas Saenz Julienne and committed by
Lee Jones
01e7865d f2906aa8

+41 -20
+41 -20
drivers/mfd/bcm2835-pm.c
··· 25 25 { .name = "bcm2835-power" }, 26 26 }; 27 27 28 + static int bcm2835_pm_get_pdata(struct platform_device *pdev, 29 + struct bcm2835_pm *pm) 30 + { 31 + if (of_find_property(pm->dev->of_node, "reg-names", NULL)) { 32 + struct resource *res; 33 + 34 + pm->base = devm_platform_ioremap_resource_byname(pdev, "pm"); 35 + if (IS_ERR(pm->base)) 36 + return PTR_ERR(pm->base); 37 + 38 + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "asb"); 39 + if (res) { 40 + pm->asb = devm_ioremap_resource(&pdev->dev, res); 41 + if (IS_ERR(pm->asb)) 42 + pm->asb = NULL; 43 + } 44 + 45 + return 0; 46 + } 47 + 48 + /* If no 'reg-names' property is found we can assume we're using old DTB. */ 49 + pm->base = devm_platform_ioremap_resource(pdev, 0); 50 + if (IS_ERR(pm->base)) 51 + return PTR_ERR(pm->base); 52 + 53 + pm->asb = devm_platform_ioremap_resource(pdev, 1); 54 + if (IS_ERR(pm->asb)) 55 + pm->asb = NULL; 56 + 57 + return 0; 58 + } 59 + 28 60 static int bcm2835_pm_probe(struct platform_device *pdev) 29 61 { 30 - struct resource *res; 31 62 struct device *dev = &pdev->dev; 32 63 struct bcm2835_pm *pm; 33 64 int ret; ··· 70 39 71 40 pm->dev = dev; 72 41 73 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 74 - pm->base = devm_ioremap_resource(dev, res); 75 - if (IS_ERR(pm->base)) 76 - return PTR_ERR(pm->base); 42 + ret = bcm2835_pm_get_pdata(pdev, pm); 43 + if (ret) 44 + return ret; 77 45 78 46 ret = devm_mfd_add_devices(dev, -1, 79 47 bcm2835_pm_devs, ARRAY_SIZE(bcm2835_pm_devs), ··· 80 50 if (ret) 81 51 return ret; 82 52 83 - /* We'll use the presence of the AXI ASB regs in the 53 + /* 54 + * We'll use the presence of the AXI ASB regs in the 84 55 * bcm2835-pm binding as the key for whether we can reference 85 56 * the full PM register range and support power domains. 86 57 */ 87 - res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 88 - if (res) { 89 - pm->asb = devm_ioremap_resource(dev, res); 90 - if (IS_ERR(pm->asb)) 91 - return PTR_ERR(pm->asb); 92 - 93 - ret = devm_mfd_add_devices(dev, -1, 94 - bcm2835_power_devs, 95 - ARRAY_SIZE(bcm2835_power_devs), 96 - NULL, 0, NULL); 97 - if (ret) 98 - return ret; 99 - } 100 - 58 + if (pm->asb) 59 + return devm_mfd_add_devices(dev, -1, bcm2835_power_devs, 60 + ARRAY_SIZE(bcm2835_power_devs), 61 + NULL, 0, NULL); 101 62 return 0; 102 63 } 103 64