mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-12-23 11:33:32 +00:00
83d290c56f
When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>
96 lines
1.9 KiB
C
96 lines
1.9 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* (C) Copyright 2011
|
|
* eInfochips Ltd. <www.einfochips.com>
|
|
* Written-by: Ajay Bhargav <contact@8051projects.net>
|
|
*
|
|
* (C) Copyright 2010
|
|
* Marvell Semiconductor <www.marvell.com>
|
|
*/
|
|
|
|
#include <common.h>
|
|
#include <asm/io.h>
|
|
#include <linux/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;
|
|
}
|