Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
Simple PCIe FMC carrier SPEC - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Simple PCIe FMC carrier SPEC - Software
Commits
caf334c1
Commit
caf334c1
authored
Jul 28, 2012
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wr-nic-gpio: filled, only I/O is missing now
parent
dd22dc58
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
87 additions
and
0 deletions
+87
-0
wr-nic-gpio.c
kernel/wr-nic-gpio.c
+87
-0
No files found.
kernel/wr-nic-gpio.c
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/kernel.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/gpio.h>
#include <linux/gpio.h>
#include <linux/fmc.h>
#include <linux/fmc.h>
#include "spec.h"
#include "spec.h"
#include "wr-nic.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
)
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
;
return
0
;
out_free:
kfree
(
gc
);
return
ret
;
}
}
void
wrn_gpio_exit
(
struct
fmc_device
*
fmc
)
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
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment