brcm2708: add device detection and use it for network, leds and preinit
[openwrt.git] / target / linux / brcm2708 / patches-4.1 / 0198-bcm2835-gpiomem-Fix-for-ARCH_BCM2835-builds.patch
1 From 6413adc1fbf4c3e9a2bcd707dd7776f419988d7c Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.org>
3 Date: Tue, 6 Oct 2015 10:16:58 +0100
4 Subject: [PATCH 198/203] bcm2835-gpiomem: Fix for ARCH_BCM2835 builds
5
6 Build on ARCH_BCM2835, and fail to probe if no IO resource.
7
8 See: https://github.com/raspberrypi/linux/issues/1154
9 ---
10  drivers/char/broadcom/bcm2835-gpiomem.c | 25 ++++++++++---------------
11  1 file changed, 10 insertions(+), 15 deletions(-)
12
13 --- a/drivers/char/broadcom/bcm2835-gpiomem.c
14 +++ b/drivers/char/broadcom/bcm2835-gpiomem.c
15 @@ -143,7 +143,6 @@ static int bcm2835_gpiomem_probe(struct
16         int err;
17         void *ptr_err;
18         struct device *dev = &pdev->dev;
19 -       struct device_node *node = dev->of_node;
20         struct resource *ioresource;
21  
22         /* Allocate buffers and instance data */
23 @@ -157,6 +156,15 @@ static int bcm2835_gpiomem_probe(struct
24  
25         inst->dev = dev;
26  
27 +       ioresource = platform_get_resource(pdev, IORESOURCE_MEM, 0);
28 +       if (ioresource) {
29 +               inst->gpio_regs_phys = ioresource->start;
30 +       } else {
31 +               dev_err(inst->dev, "failed to get IO resource");
32 +               err = -ENOENT;
33 +               goto failed_get_resource;
34 +       }
35 +
36         /* Create character device entries */
37  
38         err = alloc_chrdev_region(&bcm2835_gpiomem_devid,
39 @@ -187,20 +195,6 @@ static int bcm2835_gpiomem_probe(struct
40         if (IS_ERR(ptr_err))
41                 goto failed_device_create;
42  
43 -       /* Get address from device tree if available (*_resource() correctly
44 -          converts the bus address in device tree to a physical address),
45 -          or use hardcoded offset + BCM2708_PERI_BASE if not.
46 -          (In spite of its name 2708 actually seems to have the correct
47 -          mach-dependent value on 2709 etc, as it is defined in
48 -          mach-bcm270x/platform.h) */
49 -
50 -       if (node) {
51 -               ioresource = platform_get_resource(pdev, IORESOURCE_MEM, 0);
52 -               inst->gpio_regs_phys = ioresource->start;
53 -       } else {
54 -               inst->gpio_regs_phys = GPIO_BASE;
55 -       }
56 -
57         dev_info(inst->dev, "Initialised: Registers at 0x%08lx",
58                 inst->gpio_regs_phys);
59  
60 @@ -214,6 +208,7 @@ failed_class_create:
61  failed_cdev_add:
62         unregister_chrdev_region(bcm2835_gpiomem_devid, 1);
63  failed_alloc_chrdev:
64 +failed_get_resource:
65         kfree(inst);
66  failed_inst_alloc:
67         dev_err(inst->dev, "could not load bcm2835_gpiomem");