Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
spec-sw
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
fmc-projects
spec
spec-sw
Commits
caf334c1
Commit
caf334c1
authored
12 years ago
by
Alessandro Rubini
Browse files
Options
Downloads
Patches
Plain Diff
wr-nic-gpio: filled, only I/O is missing now
parent
dd22dc58
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
kernel/wr-nic-gpio.c
+87
-0
87 additions, 0 deletions
kernel/wr-nic-gpio.c
with
87 additions
and
0 deletions
kernel/wr-nic-gpio.c
+
87
−
0
View file @
caf334c1
/*
* Copyright (C) 2012 CERN (www.cern.ch)
* Author: Alessandro Rubini <rubini@gnudd.com>
*
* Released according to the GNU GPL, version 2 or any later version.
*
* This work is part of the White Rabbit project, a research effort led
* by CERN, the European Institute for Nuclear Research.
*/
#include
<linux/kernel.h>
#include
<linux/module.h>
#include
<linux/slab.h>
#include
<linux/gpio.h>
#include
<linux/fmc.h>
#include
"spec.h"
#include
"wr-nic.h"
static
inline
struct
fmc_device
*
gc_to_fmc
(
struct
gpio_chip
*
gc
)
{
struct
device
*
dev
=
gc
->
dev
;
return
container_of
(
dev
,
struct
fmc_device
,
dev
);
}
static
int
wrn_gpio_input
(
struct
gpio_chip
*
chip
,
unsigned
offset
)
{
//struct fmc_device *fmc = gc_to_fmc(chip);
//struct wrn_drvdata *dd = fmc_get_drvdata(fmc);
//fmc_writel(fmc, ...); /* FIXME */
return
-
EAGAIN
;
}
static
int
wrn_gpio_output
(
struct
gpio_chip
*
chip
,
unsigned
offset
,
int
value
)
{
return
-
EAGAIN
;
}
int
wrn_gpio_get
(
struct
gpio_chip
*
chip
,
unsigned
offset
)
{
return
-
EAGAIN
;
}
void
wrn_gpio_set
(
struct
gpio_chip
*
chip
,
unsigned
offset
,
int
value
)
{
return
;
}
static
const
char
*
wrn_gpio_names
[]
=
{
"dire"
,
"fare"
,
"baciare"
,
"lettera"
,
"testamento"
};
static
struct
gpio_chip
wrn_gpio_template
=
{
.
label
=
"wr-nic"
,
.
owner
=
THIS_MODULE
,
/* FIXME: request, free, for multi-function operation */
.
direction_input
=
wrn_gpio_input
,
.
direction_output
=
wrn_gpio_output
,
.
get
=
wrn_gpio_get
,
.
set
=
wrn_gpio_set
,
.
base
=
-
1
,
/* request dynamic */
.
ngpio
=
5
,
.
names
=
wrn_gpio_names
,
};
int
wrn_gpio_init
(
struct
fmc_device
*
fmc
)
{
struct
wrn_drvdata
*
dd
=
fmc_get_drvdata
(
fmc
);
struct
gpio_chip
*
gc
;
int
ret
;
gc
=
devm_kzalloc
(
&
fmc
->
dev
,
sizeof
(
*
gc
),
GFP_KERNEL
);
if
(
!
gc
)
return
-
ENOMEM
;
*
gc
=
wrn_gpio_template
;
gc
->
dev
=
&
fmc
->
dev
;
ret
=
gpiochip_add
(
gc
);
if
(
ret
<
0
)
goto
out_free
;
dd
->
gc
=
gc
;
/* FIXME: program the DAC for each port (sysfs attributes?) */
return
0
;
out_free:
kfree
(
gc
);
return
ret
;
}
void
wrn_gpio_exit
(
struct
fmc_device
*
fmc
)
{
int
ret
;
struct
wrn_drvdata
*
dd
=
fmc_get_drvdata
(
fmc
);
struct
gpio_chip
*
gc
=
dd
->
gc
;
ret
=
gpiochip_remove
(
gc
);
if
(
ret
)
dev_err
(
fmc
->
hwdev
,
"DANGER %i! gpio chip can't be removed
\n
"
,
ret
);
return
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment