]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
Merge git://git.denx.de/u-boot-dm
authorTom Rini <trini@ti.com>
Sun, 26 Oct 2014 18:03:08 +0000 (14:03 -0400)
committerTom Rini <trini@ti.com>
Sun, 26 Oct 2014 18:03:08 +0000 (14:03 -0400)
Fix a trivial conflict over adding <dm.h>

Conflicts:
arch/arm/cpu/armv7/omap3/board.c

Signed-off-by: Tom Rini <trini@ti.com>
1  2 
arch/arm/cpu/armv7/omap3/board.c
common/cmd_gpio.c
drivers/serial/serial.c
include/asm-generic/gpio.h

index a1c5b099165059f2fe1ccd61747a64b904382077,e6996b50f6b91e3bc5561bb7e3b1cab7a57e252e..c942fe67eeb2148c0dcce6abbaea21d3193653c2
   * SPDX-License-Identifier:   GPL-2.0+
   */
  #include <common.h>
+ #include <dm.h>
 +#include <mmc.h>
  #include <spl.h>
  #include <asm/io.h>
  #include <asm/arch/sys_proto.h>
  #include <asm/arch/mem.h>
  #include <asm/cache.h>
  #include <asm/armv7.h>
- #include <asm/arch/gpio.h>
+ #include <asm/gpio.h>
  #include <asm/omap_common.h>
  #include <asm/arch/mmc_host_def.h>
  #include <i2c.h>
@@@ -39,6 -39,27 +40,27 @@@ static void omap3_setup_aux_cr(void)
  static void omap3_invalidate_l2_cache_secure(void);
  #endif
  
+ #ifdef CONFIG_DM_GPIO
+ static const struct omap_gpio_platdata omap34xx_gpio[] = {
+       { 0, OMAP34XX_GPIO1_BASE, METHOD_GPIO_24XX },
+       { 1, OMAP34XX_GPIO2_BASE, METHOD_GPIO_24XX },
+       { 2, OMAP34XX_GPIO3_BASE, METHOD_GPIO_24XX },
+       { 3, OMAP34XX_GPIO4_BASE, METHOD_GPIO_24XX },
+       { 4, OMAP34XX_GPIO5_BASE, METHOD_GPIO_24XX },
+       { 5, OMAP34XX_GPIO6_BASE, METHOD_GPIO_24XX },
+ };
+ U_BOOT_DEVICES(am33xx_gpios) = {
+       { "gpio_omap", &omap34xx_gpio[0] },
+       { "gpio_omap", &omap34xx_gpio[1] },
+       { "gpio_omap", &omap34xx_gpio[2] },
+       { "gpio_omap", &omap34xx_gpio[3] },
+       { "gpio_omap", &omap34xx_gpio[4] },
+       { "gpio_omap", &omap34xx_gpio[5] },
+ };
+ #else
  static const struct gpio_bank gpio_bank_34xx[6] = {
        { (void *)OMAP34XX_GPIO1_BASE, METHOD_GPIO_24XX },
        { (void *)OMAP34XX_GPIO2_BASE, METHOD_GPIO_24XX },
@@@ -50,6 -71,8 +72,8 @@@
  
  const struct gpio_bank *const omap_gpio_bank = gpio_bank_34xx;
  
+ #endif
  #ifdef CONFIG_SPL_BUILD
  /*
  * We use static variables because global data is not ready yet.
@@@ -267,7 -290,7 +291,7 @@@ int __weak misc_init_r(void
   * Routine: wait_for_command_complete
   * Description: Wait for posting to finish on watchdog
   *****************************************************************************/
 -void wait_for_command_complete(struct watchdog *wd_base)
 +static void wait_for_command_complete(struct watchdog *wd_base)
  {
        int pending = 1;
        do {
diff --combined common/cmd_gpio.c
index 8d946f42acc3e3602fb6407d0fb40ce0e34eac64,c0cdc5f6fdfd7669d0151c07367f0e974a05f26b..65d6df451c6d4f4c5dc9c26a94a02a536b42386e
@@@ -12,7 -12,7 +12,7 @@@
  #include <dm.h>
  #include <asm/gpio.h>
  
 -int __weak name_to_gpio(const char *name)
 +__weak int name_to_gpio(const char *name)
  {
        return simple_strtoul(name, NULL, 10);
  }
@@@ -25,13 -25,6 +25,6 @@@ enum gpio_cmd 
  };
  
  #if defined(CONFIG_DM_GPIO) && !defined(gpio_status)
- static const char * const gpio_function[GPIOF_COUNT] = {
-       "input",
-       "output",
-       "unused",
-       "unknown",
-       "func",
- };
  
  /* A few flags used by show_gpio() */
  enum {
        FLAG_SHOW_NEWLINE       = 1 << 2,
  };
  
- static void show_gpio(struct udevice *dev, const char *bank_name, int offset,
-                     int *flagsp)
+ static void gpio_get_description(struct udevice *dev, const char *bank_name,
+                                int offset, int *flagsp)
  {
-       struct dm_gpio_ops *ops = gpio_get_ops(dev);
-       int func = GPIOF_UNKNOWN;
        char buf[80];
        int ret;
  
-       BUILD_BUG_ON(GPIOF_COUNT != ARRAY_SIZE(gpio_function));
-       if (ops->get_function) {
-               ret = ops->get_function(dev, offset);
-               if (ret >= 0 && ret < ARRAY_SIZE(gpio_function))
-                       func = ret;
-       }
-       if (!(*flagsp & FLAG_SHOW_ALL) && func == GPIOF_UNUSED)
+       ret = gpio_get_function(dev, offset, NULL);
+       if (ret < 0)
+               goto err;
+       if (!(*flagsp & FLAG_SHOW_ALL) && ret == GPIOF_UNUSED)
                return;
        if ((*flagsp & FLAG_SHOW_BANK) && bank_name) {
                if (*flagsp & FLAG_SHOW_NEWLINE) {
                printf("Bank %s:\n", bank_name);
                *flagsp &= ~FLAG_SHOW_BANK;
        }
-       *buf = '\0';
-       if (ops->get_state) {
-               ret = ops->get_state(dev, offset, buf, sizeof(buf));
-               if (ret) {
-                       puts("<unknown>");
-                       return;
-               }
-       } else {
-               sprintf(buf, "%s%u: %8s %d", bank_name, offset,
-                       gpio_function[func], ops->get_value(dev, offset));
-       }
  
-       puts(buf);
-       puts("\n");
+       ret = gpio_get_status(dev, offset, buf, sizeof(buf));
+       if (ret)
+               goto err;
+       printf("%s\n", buf);
+       return;
+ err:
+       printf("Error %d\n", ret);
  }
  
  static int do_gpio_status(bool all, const char *gpio_name)
                if (all)
                        flags |= FLAG_SHOW_ALL;
                bank_name = gpio_get_bank_info(dev, &num_bits);
-               if (!num_bits)
+               if (!num_bits) {
+                       debug("GPIO device %s has no bits\n", dev->name);
                        continue;
+               }
                banklen = bank_name ? strlen(bank_name) : 0;
  
                if (!gpio_name || !bank_name ||
                        p = gpio_name + banklen;
                        if (gpio_name && *p) {
                                offset = simple_strtoul(p, NULL, 10);
-                               show_gpio(dev, bank_name, offset, &flags);
+                               gpio_get_description(dev, bank_name, offset,
+                                                    &flags);
                        } else {
                                for (offset = 0; offset < num_bits; offset++) {
-                                       show_gpio(dev, bank_name, offset,
-                                                 &flags);
+                                       gpio_get_description(dev, bank_name,
+                                                            offset, &flags);
                                }
                        }
                }
diff --combined drivers/serial/serial.c
index 71cb97d14f0c49c8e2a760ab087a88ca5afe2ed3,bbe60af627e4c452eb7a76fb6c7552819439dcff..18e41b2302a2181ba6f38c53ecc71c682fb5cad0
@@@ -157,7 -157,6 +157,6 @@@ serial_initfunc(sh_serial_initialize)
  serial_initfunc(arm_dcc_initialize);
  serial_initfunc(mxs_auart_initialize);
  serial_initfunc(arc_serial_initialize);
- serial_initfunc(uniphier_serial_initialize);
  
  /**
   * serial_register() - Register serial driver with serial driver core
@@@ -251,33 -250,32 +250,32 @@@ void serial_initialize(void
        arm_dcc_initialize();
        mxs_auart_initialize();
        arc_serial_initialize();
-       uniphier_serial_initialize();
  
        serial_assign(default_serial_console()->name);
  }
  
 -int serial_stub_start(struct stdio_dev *sdev)
 +static int serial_stub_start(struct stdio_dev *sdev)
  {
        struct serial_device *dev = sdev->priv;
  
        return dev->start();
  }
  
 -int serial_stub_stop(struct stdio_dev *sdev)
 +static int serial_stub_stop(struct stdio_dev *sdev)
  {
        struct serial_device *dev = sdev->priv;
  
        return dev->stop();
  }
  
 -void serial_stub_putc(struct stdio_dev *sdev, const char ch)
 +static void serial_stub_putc(struct stdio_dev *sdev, const char ch)
  {
        struct serial_device *dev = sdev->priv;
  
        dev->putc(ch);
  }
  
 -void serial_stub_puts(struct stdio_dev *sdev, const char *str)
 +static void serial_stub_puts(struct stdio_dev *sdev, const char *str)
  {
        struct serial_device *dev = sdev->priv;
  
index 347805ed51559bfb1bf9256c27603bfa3a8246a5,4ec411b37285355e5e289aa560b442e4c7fb9743..f81b51aa301feec3f13dc787c95626c2f84012a8
@@@ -29,6 -29,9 +29,9 @@@
   * Request a GPIO. This should be called before any of the other functions
   * are used on this GPIO.
   *
+  * Note: With driver model, the label is allocated so there is no need for
+  * the caller to preserve it.
+  *
   * @param gp  GPIO number
   * @param label       User label for this GPIO
   * @return 0 if ok, -1 on error
@@@ -80,7 -83,7 +83,7 @@@ int gpio_get_value(unsigned gpio)
  int gpio_set_value(unsigned gpio, int value);
  
  /* State of a GPIO, as reported by get_function() */
- enum {
+ enum gpio_func_t {
        GPIOF_INPUT = 0,
        GPIOF_OUTPUT,
        GPIOF_UNUSED,           /* Not claimed */
  
  struct udevice;
  
+ /**
+  * gpio_get_status() - get the current GPIO status as a string
+  *
+  * Obtain the current GPIO status as a string which can be presented to the
+  * user. A typical string is:
+  *
+  * "b4:  in: 1 [x] sdmmc_cd"
+  *
+  * which means this is GPIO bank b, offset 4, currently set to input, current
+  * value 1, [x] means that it is requested and the owner is 'sdmmc_cd'
+  *
+  * @dev:      Device to check
+  * @offset:   Offset of device GPIO to check
+  * @buf:      Place to put string
+  * @buffsize: Size of string including \0
+  */
+ int gpio_get_status(struct udevice *dev, int offset, char *buf, int buffsize);
+ /**
+  * gpio_get_function() - get the current function for a GPIO pin
+  *
+  * Note this returns GPIOF_UNUSED if the GPIO is not requested.
+  *
+  * @dev:      Device to check
+  * @offset:   Offset of device GPIO to check
+  * @namep:    If non-NULL, this is set to the nane given when the GPIO
+  *            was requested, or -1 if it has not been requested
+  * @return  -ENODATA if the driver returned an unknown function,
+  * -ENODEV if the device is not active, -EINVAL if the offset is invalid.
+  * GPIOF_UNUSED if the GPIO has not been requested. Otherwise returns the
+  * function from enum gpio_func_t.
+  */
+ int gpio_get_function(struct udevice *dev, int offset, const char **namep);
+ /**
+  * gpio_get_raw_function() - get the current raw function for a GPIO pin
+  *
+  * Note this does not return GPIOF_UNUSED - it will always return the GPIO
+  * driver's view of a pin function, even if it is not correctly set up.
+  *
+  * @dev:      Device to check
+  * @offset:   Offset of device GPIO to check
+  * @namep:    If non-NULL, this is set to the nane given when the GPIO
+  *            was requested, or -1 if it has not been requested
+  * @return  -ENODATA if the driver returned an unknown function,
+  * -ENODEV if the device is not active, -EINVAL if the offset is invalid.
+  * Otherwise returns the function from enum gpio_func_t.
+  */
+ int gpio_get_raw_function(struct udevice *dev, int offset, const char **namep);
+ /**
+  * gpio_requestf() - request a GPIO using a format string for the owner
+  *
+  * This is a helper function for gpio_request(). It allows you to provide
+  * a printf()-format string for the GPIO owner. It calls gpio_request() with
+  * the string that is created
+  */
+ int gpio_requestf(unsigned gpio, const char *fmt, ...)
+               __attribute__ ((format (__printf__, 2, 3)));
  /**
   * struct struct dm_gpio_ops - Driver model GPIO operations
   *
@@@ -135,8 -198,6 +198,6 @@@ struct dm_gpio_ops 
         * @return current function - GPIOF_...
         */
        int (*get_function)(struct udevice *dev, unsigned offset);
-       int (*get_state)(struct udevice *dev, unsigned offset, char *state,
-                        int maxlen);
  };
  
  /**
   * @gpio_base: Base GPIO number for this device. For the first active device
   * this will be 0; the numbering for others will follow sequentially so that
   * @gpio_base for device 1 will equal the number of GPIOs in device 0.
+  * @name: Array of pointers to the name for each GPIO in this bank. The
+  * value of the pointer will be NULL if the GPIO has not been claimed.
   */
  struct gpio_dev_priv {
        const char *bank_name;
        unsigned gpio_count;
        unsigned gpio_base;
+       char **name;
  };
  
  /* Access the GPIO operations for a device */
@@@ -193,6 -257,4 +257,6 @@@ const char *gpio_get_bank_info(struct u
  int gpio_lookup_name(const char *name, struct udevice **devp,
                     unsigned int *offsetp, unsigned int *gpiop);
  
 +int name_to_gpio(const char *name);
 +
  #endif        /* _ASM_GENERIC_GPIO_H_ */