]> rtime.felk.cvut.cz Git - zynq/linux.git/commitdiff
gpio: gpio-xilinx: Remove CONFIG_OF conditionals
authorMichal Simek <michal.simek@xilinx.com>
Tue, 27 Nov 2012 14:40:47 +0000 (15:40 +0100)
committerMichal Simek <michal.simek@xilinx.com>
Wed, 28 Nov 2012 08:55:29 +0000 (09:55 +0100)
CONFIG_OF is mandatory for all Xilinx platforms. For this reason
all conditional compiling regarding this option can be removed.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
arch/arm/mach-zynq/include/mach/gpio.h
drivers/gpio/gpio-xilinx.c

index 47d0c96f5c72ee7162b3eb10591470ab7d40a87f..b0b35079d14c2cf3b2ec49fb8f6a3c1968e47953 100644 (file)
 #define ARCH_NR_GPIOS          512
 #define XGPIOPS_IRQBASE                128
 
-struct xgpio_platform_data {
-        unsigned int            state;
-        unsigned int            dir;
-       unsigned int            width;
-};
 
 extern int gpio_direction_input(unsigned gpio);
 extern int gpio_direction_output(unsigned gpio, int value);
index b8b8a328b039203522284be7b450fdab51dcb51b..ac468d5e774d9e44bd88e8443a40fb5bba352bf8 100644 (file)
 #define xgpio_writereg(offset, val)    __raw_writel(val, offset)
 
 struct xgpio_instance {
-#ifdef CONFIG_OF
        struct of_mm_gpio_chip mmchip;
-#else
-       struct gpio_chip gc;
-       void __iomem *regs;
-#endif
        u32 gpio_state;         /* GPIO state shadow register */
        u32 gpio_dir;           /* GPIO direction shadow register */
        u32 offset;
@@ -55,17 +50,12 @@ struct xgpio_instance {
  */
 static int xgpio_get(struct gpio_chip *gc, unsigned int gpio)
 {
-#ifdef CONFIG_OF
        struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
        struct xgpio_instance *chip =
            container_of(mm_gc, struct xgpio_instance, mmchip);
 
        void __iomem *regs = mm_gc->regs + chip->offset;
-#else
-       struct xgpio_instance *chip = container_of(gc, struct xgpio_instance,
-                                                  gc);
-       void __iomem *regs = chip->regs;
-#endif
+
        return (xgpio_readreg(regs + XGPIO_DATA_OFFSET) >> gpio) & 1;
 }
 
@@ -81,16 +71,10 @@ static int xgpio_get(struct gpio_chip *gc, unsigned int gpio)
 static void xgpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
 {
        unsigned long flags;
-#ifdef CONFIG_OF
        struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
        struct xgpio_instance *chip =
            container_of(mm_gc, struct xgpio_instance, mmchip);
        void __iomem *regs = mm_gc->regs;
-#else
-       struct xgpio_instance *chip = container_of(gc, struct xgpio_instance,
-                                                  gc);
-       void __iomem *regs = chip->regs;
-#endif
 
        spin_lock_irqsave(&chip->gpio_lock, flags);
 
@@ -118,16 +102,10 @@ static void xgpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
 static int xgpio_dir_in(struct gpio_chip *gc, unsigned int gpio)
 {
        unsigned long flags;
-#ifdef CONFIG_OF
        struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
        struct xgpio_instance *chip =
            container_of(mm_gc, struct xgpio_instance, mmchip);
        void __iomem *regs = mm_gc->regs;
-#else
-       struct xgpio_instance *chip = container_of(gc, struct xgpio_instance,
-                                                  gc);
-       void __iomem *regs = chip->regs;
-#endif
 
        spin_lock_irqsave(&chip->gpio_lock, flags);
 
@@ -153,16 +131,10 @@ static int xgpio_dir_in(struct gpio_chip *gc, unsigned int gpio)
 static int xgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
 {
        unsigned long flags;
-#ifdef CONFIG_OF
        struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
        struct xgpio_instance *chip =
            container_of(mm_gc, struct xgpio_instance, mmchip);
        void __iomem *regs = mm_gc->regs;
-#else
-       struct xgpio_instance *chip = container_of(gc, struct xgpio_instance,
-                                                  gc);
-       void __iomem *regs = chip->regs;
-#endif
 
        spin_lock_irqsave(&chip->gpio_lock, flags);
 
@@ -182,7 +154,6 @@ static int xgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
        return 0;
 }
 
-#ifdef CONFIG_OF
 /**
  * xgpio_save_regs - Set initial values of GPIO pins
  * @mm_gc: pointer to memory mapped GPIO chip structure
@@ -321,126 +292,14 @@ static struct of_device_id xgpio_of_match[] __devinitdata = {
        { /* end of list */ },
 };
 
-#else
-
-/**
- * xgpio_probe - Probe method for the GPIO device
- * @pdev:      platform device instance
- *
- * This function allocates memory resources for the xgpio device and initializes
- * the driver structures.
- *
- * Return:     0 on success, negative error otherwise.
- */
-static int __init xgpio_probe(struct platform_device *pdev)
-{
-       int ret;
-       struct xgpio_instance *chip;
-       struct gpio_chip *gc;
-       struct resource *mem_res = NULL;
-       struct xgpio_platform_data *pdata;
-
-       chip = kzalloc(sizeof(struct xgpio_instance), GFP_KERNEL);
-       if (!chip) {
-               dev_err(&pdev->dev, "couldn't allocate memory for gpio private "
-                       "data\n");
-               return -ENOMEM;
-       }
-
-       platform_set_drvdata(pdev, chip);
-
-       mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       if (!mem_res) {
-               dev_err(&pdev->dev, "No memory resource\n");
-               ret = -ENODEV;
-               goto err_free_gpio;
-       }
-
-       if (!request_mem_region(mem_res->start, resource_size(mem_res),
-                               pdev->name)) {
-               dev_err(&pdev->dev, "Cannot request IO\n");
-               ret = -ENXIO;
-               goto err_free_gpio;
-       }
-
-       pdata = pdev->dev.platform_data;
-       if (pdata == NULL) {
-               dev_err(&pdev->dev, "Cannot find platform data\n");
-               return -ENODEV;
-       }
-
-       chip->regs = ioremap(mem_res->start, resource_size(mem_res));
-       if (chip->regs == NULL) {
-               dev_err(&pdev->dev, "Couldn't ioremap memory at 0x%08lx\n",
-                       (unsigned long)mem_res->start);
-               ret = -ENOMEM;
-               goto err_release_region;
-       }
-
-       chip->gpio_state = pdata->state;
-       chip->gpio_dir = pdata->dir;
-
-       xgpio_writereg(chip->regs + XGPIO_DATA_OFFSET, chip->gpio_state);
-       xgpio_writereg(chip->regs + XGPIO_TRI_OFFSET, chip->gpio_dir);
-
-       /* configure the gpio chip */
-       gc = &chip->gc;
-       gc->label = "xgpio";
-       gc->owner = THIS_MODULE;
-       gc->dev = &pdev->dev;
-       gc->get = xgpio_get;
-       gc->set = xgpio_set;
-       gc->direction_input = xgpio_dir_in;
-       gc->direction_output = xgpio_dir_out;
-       gc->dbg_show = NULL;
-       gc->base = 0;           /* default pin base */
-       gc->ngpio = pdata->width;
-       gc->can_sleep = 0;
-
-       ret = gpiochip_add(gc);
-       if (ret < 0) {
-               dev_err(&pdev->dev, "gpio gc registration failed\n");
-               goto err_iounmap;
-       } else
-               dev_info(&pdev->dev, "gpio at 0x%08lx mapped to 0x%08lx\n",
-                        (unsigned long)mem_res->start,
-                        (unsigned long)chip->regs);
-
-       return 0;
-
-err_iounmap:
-       iounmap(chip->regs);
-err_release_region:
-       release_mem_region(mem_res->start, resource_size(mem_res));
-err_free_gpio:
-       platform_set_drvdata(pdev, NULL);
-       kfree(chip);
-
-       return ret;
-}
-
-static struct platform_driver xgpio_driver = {
-       .driver = {
-               .name   = "xilinx_gpio",
-               .owner  = THIS_MODULE,
-       },
-       .probe          = xgpio_probe,
-};
-
-#endif /* CONFIG_OF */
-
 static int __init xgpio_init(void)
 {
-#ifdef CONFIG_OF
        struct device_node *np;
 
        for_each_matching_node(np, xgpio_of_match)
                xgpio_of_probe(np);
 
        return 0;
-#else
-       return platform_driver_register(&xgpio_driver);
-#endif
 }
 
 /* Make sure we get initialized before anyone else tries to use us */