Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/arm/nvidia simplify gpio kpi
details: https://anonhg.NetBSD.org/src/rev/35feaafb9c16
branches: trunk
changeset: 337888:35feaafb9c16
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Sat May 02 17:06:53 2015 +0000
description:
simplify gpio kpi
diffstat:
sys/arch/arm/nvidia/tegra_gpio.c | 28 ++++++++++++++++++++++------
sys/arch/arm/nvidia/tegra_var.h | 4 ++--
2 files changed, 24 insertions(+), 8 deletions(-)
diffs (90 lines):
diff -r 88b05138c5aa -r 35feaafb9c16 sys/arch/arm/nvidia/tegra_gpio.c
--- a/sys/arch/arm/nvidia/tegra_gpio.c Sat May 02 16:20:41 2015 +0000
+++ b/sys/arch/arm/nvidia/tegra_gpio.c Sat May 02 17:06:53 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_gpio.c,v 1.1 2015/05/02 12:08:32 jmcneill Exp $ */
+/* $NetBSD: tegra_gpio.c,v 1.2 2015/05/02 17:06:53 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -29,7 +29,7 @@
#include "locators.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tegra_gpio.c,v 1.1 2015/05/02 12:08:32 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_gpio.c,v 1.2 2015/05/02 17:06:53 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -250,25 +250,41 @@
}
static const struct tegra_gpio_pinbank *
-tegra_gpio_pinbank_lookup(const char *bankname)
+tegra_gpio_pin_lookup(const char *pinname, int *ppin)
{
+ char bankname[3];
u_int n;
+ int pin;
+
+ KASSERT(strlen(pinname) == 2 || strlen(pinname) == 3);
+
+ memset(bankname, 0, sizeof(bankname));
+ bankname[0] = pinname[0];
+ if (strlen(pinname) == 2) {
+ pin = pinname[1] - '0';
+ } else {
+ bankname[1] = pinname[1];
+ pin = pinname[2] - '0';
+ }
for (n = 0; n < __arraycount(tegra_gpio_pinbanks); n++) {
const struct tegra_gpio_pinbank *pb =
&tegra_gpio_pinbanks[n];
- if (strcmp(pb->name, bankname) == 0)
+ if (strcmp(pb->name, bankname) == 0) {
+ *ppin = pin;
return pb;
+ }
}
return NULL;
}
struct tegra_gpio_pin *
-tegra_gpio_acquire(const char *bankname, int pin, u_int flags)
+tegra_gpio_acquire(const char *pinname, u_int flags)
{
struct tegra_gpio_bank bank;
struct tegra_gpio_pin *gpin;
+ int pin;
device_t dev;
dev = device_find_by_driver_unit("tegragpio", 0);
@@ -276,7 +292,7 @@
return NULL;
bank.bank_sc = device_private(dev);
- bank.bank_pb = tegra_gpio_pinbank_lookup(bankname);
+ bank.bank_pb = tegra_gpio_pin_lookup(pinname, &pin);
if (bank.bank_pb == NULL)
return NULL;
diff -r 88b05138c5aa -r 35feaafb9c16 sys/arch/arm/nvidia/tegra_var.h
--- a/sys/arch/arm/nvidia/tegra_var.h Sat May 02 16:20:41 2015 +0000
+++ b/sys/arch/arm/nvidia/tegra_var.h Sat May 02 17:06:53 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_var.h,v 1.5 2015/05/02 12:08:32 jmcneill Exp $ */
+/* $NetBSD: tegra_var.h,v 1.6 2015/05/02 17:06:53 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -77,7 +77,7 @@
int tegra_car_periph_sdmmc_set_div(u_int, u_int);
struct tegra_gpio_pin;
-struct tegra_gpio_pin *tegra_gpio_acquire(const char *, int, u_int);
+struct tegra_gpio_pin *tegra_gpio_acquire(const char *, u_int);
void tegra_gpio_release(struct tegra_gpio_pin *);
int tegra_gpio_read(struct tegra_gpio_pin *);
void tegra_gpio_write(struct tegra_gpio_pin *, int);
Home |
Main Index |
Thread Index |
Old Index