-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for the Stretch S6000 Xtensa core variant. Signed-off-by: Johannes Weiner <jw@emlix.com> Signed-off-by: Oskar Schirmer <os@emlix.com> Signed-off-by: Chris Zankel <chris@zankel.net>
- Loading branch information
Johannes Weiner
authored and
Chris Zankel
committed
Apr 3, 2009
1 parent
eff35af
commit 000af2c
Showing
8 changed files
with
481 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Generic GPIO API implementation for xtensa. | ||
* | ||
* Stolen from x86, which is derived from the generic GPIO API for powerpc: | ||
* | ||
* Copyright (c) 2007-2008 MontaVista Software, Inc. | ||
* | ||
* Author: Anton Vorontsov <avorontsov@ru.mvista.com> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
*/ | ||
|
||
#ifndef _ASM_XTENSA_GPIO_H | ||
#define _ASM_XTENSA_GPIO_H | ||
|
||
#include <asm-generic/gpio.h> | ||
|
||
#ifdef CONFIG_GPIOLIB | ||
|
||
/* | ||
* Just call gpiolib. | ||
*/ | ||
static inline int gpio_get_value(unsigned int gpio) | ||
{ | ||
return __gpio_get_value(gpio); | ||
} | ||
|
||
static inline void gpio_set_value(unsigned int gpio, int value) | ||
{ | ||
__gpio_set_value(gpio, value); | ||
} | ||
|
||
static inline int gpio_cansleep(unsigned int gpio) | ||
{ | ||
return __gpio_cansleep(gpio); | ||
} | ||
|
||
/* | ||
* Not implemented, yet. | ||
*/ | ||
static inline int gpio_to_irq(unsigned int gpio) | ||
{ | ||
return -ENOSYS; | ||
} | ||
|
||
static inline int irq_to_gpio(unsigned int irq) | ||
{ | ||
return -EINVAL; | ||
} | ||
|
||
#endif /* CONFIG_GPIOLIB */ | ||
|
||
#endif /* _ASM_XTENSA_GPIO_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# s6000 Makefile | ||
|
||
obj-y += irq.o gpio.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* s6000 gpio driver | ||
* | ||
* Copyright (c) 2009 emlix GmbH | ||
* Authors: Oskar Schirmer <os@emlix.com> | ||
* Johannes Weiner <jw@emlix.com> | ||
*/ | ||
#include <linux/kernel.h> | ||
#include <linux/module.h> | ||
#include <linux/init.h> | ||
#include <linux/io.h> | ||
#include <linux/gpio.h> | ||
|
||
#include <variant/hardware.h> | ||
|
||
#define S6_GPIO_DATA 0x000 | ||
#define S6_GPIO_IS 0x404 | ||
#define S6_GPIO_IBE 0x408 | ||
#define S6_GPIO_IEV 0x40C | ||
#define S6_GPIO_IE 0x410 | ||
#define S6_GPIO_RIS 0x414 | ||
#define S6_GPIO_MIS 0x418 | ||
#define S6_GPIO_IC 0x41C | ||
#define S6_GPIO_AFSEL 0x420 | ||
#define S6_GPIO_DIR 0x800 | ||
#define S6_GPIO_BANK(nr) ((nr) * 0x1000) | ||
#define S6_GPIO_MASK(nr) (4 << (nr)) | ||
#define S6_GPIO_OFFSET(nr) \ | ||
(S6_GPIO_BANK((nr) >> 3) + S6_GPIO_MASK((nr) & 7)) | ||
|
||
static int direction_input(struct gpio_chip *chip, unsigned int off) | ||
{ | ||
writeb(0, S6_REG_GPIO + S6_GPIO_DIR + S6_GPIO_OFFSET(off)); | ||
return 0; | ||
} | ||
|
||
static int get(struct gpio_chip *chip, unsigned int off) | ||
{ | ||
return readb(S6_REG_GPIO + S6_GPIO_DATA + S6_GPIO_OFFSET(off)); | ||
} | ||
|
||
static int direction_output(struct gpio_chip *chip, unsigned int off, int val) | ||
{ | ||
unsigned rel = S6_GPIO_OFFSET(off); | ||
writeb(~0, S6_REG_GPIO + S6_GPIO_DIR + rel); | ||
writeb(val ? ~0 : 0, S6_REG_GPIO + S6_GPIO_DATA + rel); | ||
return 0; | ||
} | ||
|
||
static void set(struct gpio_chip *chip, unsigned int off, int val) | ||
{ | ||
writeb(val ? ~0 : 0, S6_REG_GPIO + S6_GPIO_DATA + S6_GPIO_OFFSET(off)); | ||
} | ||
|
||
static struct gpio_chip gpiochip = { | ||
.owner = THIS_MODULE, | ||
.direction_input = direction_input, | ||
.get = get, | ||
.direction_output = direction_output, | ||
.set = set, | ||
.base = 0, | ||
.ngpio = 24, | ||
.can_sleep = 0, /* no blocking io needed */ | ||
.exported = 0, /* no exporting to userspace */ | ||
}; | ||
|
||
static int gpio_init(void) | ||
{ | ||
return gpiochip_add(&gpiochip); | ||
} | ||
device_initcall(gpio_init); |
Oops, something went wrong.