diff options
author | 2015-08-28 09:58:54 +0800 | |
---|---|---|
committer | 2015-09-01 12:44:00 +0800 | |
commit | e44e3482bdb4d0ebde2d8b41830ac2cdb07948fb (patch) | |
tree | 66b09f592c55df2878107a468a91d21506104d3f /qemu/roms/u-boot/drivers/gpio/mvgpio.c | |
parent | 9ca8dbcc65cfc63d6f5ef3312a33184e1d726e00 (diff) |
Add qemu 2.4.0
Change-Id: Ic99cbad4b61f8b127b7dc74d04576c0bcbaaf4f5
Signed-off-by: Yang Zhang <yang.z.zhang@intel.com>
Diffstat (limited to 'qemu/roms/u-boot/drivers/gpio/mvgpio.c')
-rw-r--r-- | qemu/roms/u-boot/drivers/gpio/mvgpio.c | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/qemu/roms/u-boot/drivers/gpio/mvgpio.c b/qemu/roms/u-boot/drivers/gpio/mvgpio.c new file mode 100644 index 000000000..888aa07c4 --- /dev/null +++ b/qemu/roms/u-boot/drivers/gpio/mvgpio.c @@ -0,0 +1,97 @@ +/* + * (C) Copyright 2011 + * eInfochips Ltd. <www.einfochips.com> + * Written-by: Ajay Bhargav <ajay.bhargav@einfochips.com> + * + * (C) Copyright 2010 + * Marvell Semiconductor <www.marvell.com> + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include <common.h> +#include <asm/io.h> +#include <asm/errno.h> +#include "mvgpio.h" +#include <asm/gpio.h> + +#ifndef MV_MAX_GPIO +#define MV_MAX_GPIO 128 +#endif + +int gpio_request(unsigned gpio, const char *label) +{ + if (gpio >= MV_MAX_GPIO) { + printf("%s: Invalid GPIO requested %d\n", __func__, gpio); + return -1; + } + return 0; +} + +int gpio_free(unsigned gpio) +{ + return 0; +} + +int gpio_direction_input(unsigned gpio) +{ + struct gpio_reg *gpio_reg_bank; + + if (gpio >= MV_MAX_GPIO) { + printf("%s: Invalid GPIO %d\n", __func__, gpio); + return -1; + } + + gpio_reg_bank = get_gpio_base(GPIO_TO_REG(gpio)); + writel(GPIO_TO_BIT(gpio), &gpio_reg_bank->gcdr); + return 0; +} + +int gpio_direction_output(unsigned gpio, int value) +{ + struct gpio_reg *gpio_reg_bank; + + if (gpio >= MV_MAX_GPIO) { + printf("%s: Invalid GPIO %d\n", __func__, gpio); + return -1; + } + + gpio_reg_bank = get_gpio_base(GPIO_TO_REG(gpio)); + writel(GPIO_TO_BIT(gpio), &gpio_reg_bank->gsdr); + gpio_set_value(gpio, value); + return 0; +} + +int gpio_get_value(unsigned gpio) +{ + struct gpio_reg *gpio_reg_bank; + u32 gpio_val; + + if (gpio >= MV_MAX_GPIO) { + printf("%s: Invalid GPIO %d\n", __func__, gpio); + return -1; + } + + gpio_reg_bank = get_gpio_base(GPIO_TO_REG(gpio)); + gpio_val = readl(&gpio_reg_bank->gplr); + + return GPIO_VAL(gpio, gpio_val); +} + +int gpio_set_value(unsigned gpio, int value) +{ + struct gpio_reg *gpio_reg_bank; + + if (gpio >= MV_MAX_GPIO) { + printf("%s: Invalid GPIO %d\n", __func__, gpio); + return -1; + } + + gpio_reg_bank = get_gpio_base(GPIO_TO_REG(gpio)); + if (value) + writel(GPIO_TO_BIT(gpio), &gpio_reg_bank->gpsr); + else + writel(GPIO_TO_BIT(gpio), &gpio_reg_bank->gpcr); + + return 0; +} |