mirror of https://gitee.com/openkylin/linux.git
staging: olpc_dcon: Convert all uses of old GPIO API to new descriptor API
This commit eliminate all uses of legacy integer base GPIO API in olpc_dcon_xo_1_5.c and replace them with new descriptor GPIO API like those in olpc_dcon_xo_1.c. Also pull some common code with olpc_dcon_xo_1.c to olpc_dcon.h for code sharing. Signed-off-by: Jerry Lin <wahahab11@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
0f7741bb87
commit
523275a8b3
|
@ -97,6 +97,11 @@ struct dcon_platform_data {
|
|||
int (*read_status)(u8 *status);
|
||||
};
|
||||
|
||||
struct dcon_gpio {
|
||||
const char *name;
|
||||
unsigned long flags;
|
||||
};
|
||||
|
||||
#include <linux/interrupt.h>
|
||||
|
||||
irqreturn_t dcon_interrupt(int irq, void *id);
|
||||
|
|
|
@ -26,11 +26,6 @@ enum dcon_gpios {
|
|||
OLPC_DCON_BLANK,
|
||||
};
|
||||
|
||||
struct dcon_gpio {
|
||||
const char *name;
|
||||
unsigned long flags;
|
||||
};
|
||||
|
||||
static const struct dcon_gpio gpios_asis[] = {
|
||||
[OLPC_DCON_STAT0] = { .name = "dcon_stat0", .flags = GPIOD_ASIS },
|
||||
[OLPC_DCON_STAT1] = { .name = "dcon_stat1", .flags = GPIOD_ASIS },
|
||||
|
@ -39,7 +34,7 @@ static const struct dcon_gpio gpios_asis[] = {
|
|||
[OLPC_DCON_BLANK] = { .name = "dcon_blank", .flags = GPIOD_ASIS },
|
||||
};
|
||||
|
||||
struct gpio_desc *gpios[5];
|
||||
static struct gpio_desc *gpios[5];
|
||||
|
||||
static int dcon_init_xo_1(struct dcon_priv *dcon)
|
||||
{
|
||||
|
|
|
@ -7,7 +7,9 @@
|
|||
|
||||
#include <linux/acpi.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/gpio/consumer.h>
|
||||
#include <linux/gpio/machine.h>
|
||||
#include <asm/olpc.h>
|
||||
|
||||
/* TODO: this eventually belongs in linux/vx855.h */
|
||||
|
@ -38,6 +40,33 @@
|
|||
|
||||
#define PREFIX "OLPC DCON:"
|
||||
|
||||
enum dcon_gpios {
|
||||
OLPC_DCON_STAT0,
|
||||
OLPC_DCON_STAT1,
|
||||
OLPC_DCON_LOAD,
|
||||
};
|
||||
|
||||
struct gpiod_lookup_table gpios_table = {
|
||||
.dev_id = NULL,
|
||||
.table = {
|
||||
GPIO_LOOKUP("VX855 South Bridge", VX855_GPIO(1), "dcon_load",
|
||||
GPIO_ACTIVE_LOW),
|
||||
GPIO_LOOKUP("VX855 South Bridge", VX855_GPI(10), "dcon_stat0",
|
||||
GPIO_ACTIVE_LOW),
|
||||
GPIO_LOOKUP("VX855 South Bridge", VX855_GPI(11), "dcon_stat1",
|
||||
GPIO_ACTIVE_LOW),
|
||||
{ },
|
||||
},
|
||||
};
|
||||
|
||||
static const struct dcon_gpio gpios_asis[] = {
|
||||
[OLPC_DCON_STAT0] = { .name = "dcon_stat0", .flags = GPIOD_ASIS },
|
||||
[OLPC_DCON_STAT1] = { .name = "dcon_stat1", .flags = GPIOD_ASIS },
|
||||
[OLPC_DCON_LOAD] = { .name = "dcon_load", .flags = GPIOD_ASIS },
|
||||
};
|
||||
|
||||
static struct gpio_desc *gpios[3];
|
||||
|
||||
static void dcon_clear_irq(void)
|
||||
{
|
||||
/* irq status will appear in PMIO_Rx50[6] (RW1C) on gpio12 */
|
||||
|
@ -57,6 +86,25 @@ static int dcon_was_irq(void)
|
|||
static int dcon_init_xo_1_5(struct dcon_priv *dcon)
|
||||
{
|
||||
unsigned int irq;
|
||||
const struct dcon_gpio *pin = &gpios_asis[0];
|
||||
int i;
|
||||
int ret;
|
||||
|
||||
/* Add GPIO look up table */
|
||||
gpios_table.dev_id = dev_name(&dcon->client->dev);
|
||||
gpiod_add_lookup_table(&gpios_table);
|
||||
|
||||
/* Get GPIO descriptor */
|
||||
for (i = 0; i < ARRAY_SIZE(gpios_asis); i++) {
|
||||
gpios[i] = devm_gpiod_get(&dcon->client->dev, pin[i].name,
|
||||
pin[i].flags);
|
||||
if (IS_ERR(gpios[i])) {
|
||||
ret = PTR_ERR(gpios[i]);
|
||||
pr_err("failed to request %s GPIO: %d\n", pin[i].name,
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
dcon_clear_irq();
|
||||
|
||||
|
@ -131,7 +179,7 @@ static void dcon_wiggle_xo_1_5(void)
|
|||
|
||||
static void dcon_set_dconload_xo_1_5(int val)
|
||||
{
|
||||
gpio_set_value(VX855_GPIO(1), val);
|
||||
gpiod_set_value(gpios[OLPC_DCON_LOAD], val);
|
||||
}
|
||||
|
||||
static int dcon_read_status_xo_1_5(u8 *status)
|
||||
|
@ -140,8 +188,8 @@ static int dcon_read_status_xo_1_5(u8 *status)
|
|||
return -1;
|
||||
|
||||
/* i believe this is the same as "inb(0x44b) & 3" */
|
||||
*status = gpio_get_value(VX855_GPI(10));
|
||||
*status |= gpio_get_value(VX855_GPI(11)) << 1;
|
||||
*status = gpiod_get_value(gpios[OLPC_DCON_STAT0]);
|
||||
*status |= gpiod_get_value(gpios[OLPC_DCON_STAT1]) << 1;
|
||||
|
||||
dcon_clear_irq();
|
||||
|
||||
|
|
Loading…
Reference in New Issue