Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
Simple VME FMC Carrier SVEC - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
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 VME FMC Carrier SVEC - Software
Commits
6b0f3de3
Commit
6b0f3de3
authored
Nov 22, 2012
by
Luis Fernando Ruiz Gago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More sysfs attributes
parent
a91e0076
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
104 additions
and
38 deletions
+104
-38
svec-sysfs.c
kernel/svec-sysfs.c
+83
-5
svec.h
kernel/svec.h
+3
-4
svec_drv.c
kernel/svec_drv.c
+18
-29
No files found.
kernel/svec-sysfs.c
View file @
6b0f3de3
...
...
@@ -12,14 +12,15 @@
#include <linux/ctype.h>
#include "svec.h"
static
ssize_t
svec_show_bootloader_active
(
struct
device
*
pdev
,
struct
device_attribute
*
attr
,
char
*
buf
)
static
ssize_t
svec_show_bootloader_active
(
struct
device
*
pdev
,
struct
device_attribute
*
attr
,
char
*
buf
)
{
struct
svec_dev
*
card
=
dev_get_drvdata
(
pdev
);
size_t
ret
;
int
active
;
active
=
svec_bootloader_
check
(
card
);
active
=
svec_bootloader_
is_active
(
card
);
if
(
active
<
0
)
return
-
EINVAL
;
...
...
@@ -28,8 +29,10 @@ svec_show_bootloader_active(struct device *pdev, struct device_attribute *attr,
return
ret
;
}
static
ssize_t
svec_store_bootloader_active
(
struct
device
*
pdev
,
struct
device_attribute
*
attr
,
const
char
*
buf
,
size_t
count
)
static
ssize_t
svec_store_bootloader_active
(
struct
device
*
pdev
,
struct
device_attribute
*
attr
,
const
char
*
buf
,
size_t
count
)
{
struct
svec_dev
*
card
=
dev_get_drvdata
(
pdev
);
...
...
@@ -38,13 +41,87 @@ svec_store_bootloader_active(struct device *pdev, struct device_attribute *attr,
return
count
;
}
static
ssize_t
svec_show_firmware_name
(
struct
device
*
pdev
,
struct
device_attribute
*
attr
,
char
*
buf
)
{
struct
svec_dev
*
card
=
dev_get_drvdata
(
pdev
);
size_t
ret
;
int
bl_active
;
bl_active
=
svec_bootloader_is_active
(
card
);
if
(
bl_active
<
0
)
return
-
EINVAL
;
if
(
bl_active
)
ret
=
snprintf
(
buf
,
PAGE_SIZE
,
"%s (not active)
\n
"
,
card
->
fw_name
);
else
ret
=
snprintf
(
buf
,
PAGE_SIZE
,
"%s
\n
"
,
card
->
fw_name
);
return
ret
;
}
static
ssize_t
svec_store_firmware_name
(
struct
device
*
pdev
,
struct
device_attribute
*
attr
,
const
char
*
buf
,
size_t
count
)
{
int
error
;
struct
svec_dev
*
card
=
dev_get_drvdata
(
pdev
);
error
=
svec_load_fpga_file
(
card
,
buf
);
if
(
!
error
)
snprintf
(
card
->
fw_name
,
PAGE_SIZE
,
"%s"
,
buf
);
return
count
;
}
static
ssize_t
svec_show_interrupt_vector
(
struct
device
*
pdev
,
struct
device_attribute
*
attr
,
char
*
buf
)
{
struct
svec_dev
*
card
=
dev_get_drvdata
(
pdev
);
return
snprintf
(
buf
,
PAGE_SIZE
,
"0x%x
\n
"
,
card
->
vector
);
}
static
ssize_t
svec_show_interrupt_level
(
struct
device
*
pdev
,
struct
device_attribute
*
attr
,
char
*
buf
)
{
struct
svec_dev
*
card
=
dev_get_drvdata
(
pdev
);
return
snprintf
(
buf
,
PAGE_SIZE
,
"%d
\n
"
,
card
->
level
);
}
/********************** SVEC board attributes ***********************/
static
DEVICE_ATTR
(
bootloader_active
,
S_IWUSR
|
S_IRUGO
,
svec_show_bootloader_active
,
svec_store_bootloader_active
);
static
DEVICE_ATTR
(
firmware_name
,
S_IWUSR
|
S_IRUGO
,
svec_show_firmware_name
,
svec_store_firmware_name
);
static
DEVICE_ATTR
(
interrupt_vector
,
S_IRUGO
,
svec_show_interrupt_vector
,
NULL
);
static
DEVICE_ATTR
(
interrupt_level
,
S_IRUGO
,
svec_show_interrupt_level
,
NULL
);
static
struct
attribute
*
svec_attrs
[]
=
{
&
dev_attr_bootloader_active
.
attr
,
&
dev_attr_firmware_name
.
attr
,
&
dev_attr_interrupt_vector
.
attr
,
&
dev_attr_interrupt_level
.
attr
,
NULL
,
};
...
...
@@ -52,6 +129,7 @@ static struct attribute_group svec_attr_group = {
.
attrs
=
svec_attrs
,
};
/******************** sysfs file management ***************************/
int
svec_create_sysfs_files
(
struct
svec_dev
*
card
)
{
int
error
=
0
;
...
...
kernel/svec.h
View file @
6b0f3de3
...
...
@@ -48,12 +48,11 @@ struct svec_dev {
struct
gpio_chip
*
gpio
;
};
int
svec_bootloader_check
(
struct
svec_dev
*
svec
);
int
svec_bootloader_unlock
(
struct
svec_dev
*
svec
);
/* Functions and data in svec-vme.c */
extern
int
svec_bootloader_is_active
(
struct
svec_dev
*
svec
);
extern
int
svec_bootloader_unlock
(
struct
svec_dev
*
svec
);
extern
int
svec_load_fpga
(
struct
svec_dev
*
svec
,
const
void
*
data
,
int
size
);
extern
int
svec_load_fpga_file
(
struct
svec_dev
*
svec
,
char
*
name
);
extern
int
svec_load_fpga_file
(
struct
svec_dev
*
svec
,
c
onst
c
har
*
name
);
extern
char
*
svec_fw_name
;
extern
int
spec_use_msi
;
...
...
kernel/svec_drv.c
View file @
6b0f3de3
...
...
@@ -152,7 +152,7 @@ int svec_bootloader_unlock (struct svec_dev *svec)
return
0
;
}
int
svec_bootloader_
check
(
struct
svec_dev
*
svec
)
int
svec_bootloader_
is_active
(
struct
svec_dev
*
svec
)
{
uint32_t
idc
;
char
*
buf
=
(
char
*
)
&
idc
;
...
...
@@ -169,13 +169,15 @@ int svec_bootloader_check(struct svec_dev *svec)
idc
=
swapbe32
(
ioread32
(
addr
));
idc
=
htonl
(
idc
);
printk
(
KERN_INFO
PFX
"IDCode value %x.
\n
"
,
idc
);
if
(
strncmp
(
buf
,
"SVEC"
,
4
)
==
0
)
{
printk
(
KERN_INFO
PFX
"IDCode value %x [%s].
\n
"
,
idc
,
buf
);
/* Bootloader active. Unlocked */
return
1
;
}
else
printk
(
KERN_INFO
PFX
"IDCode value %x.
\n
"
,
idc
);
/* Bootloader not active. Locked */
return
0
;
...
...
@@ -184,12 +186,8 @@ int svec_bootloader_check(struct svec_dev *svec)
int
svec_load_fpga
(
struct
svec_dev
*
svec
,
const
void
*
blob
,
int
size
)
{
const
uint32_t
boot_seq
[
8
]
=
{
0xde
,
0xad
,
0xbe
,
0xef
,
0xca
,
0xfe
,
0xba
,
0xbe
};
const
uint32_t
*
data
=
blob
;
void
*
loader_addr
;
/* FPGA loader virtual address */
char
id_string
[
5
];
/* Null terminated string. Should be 'SVEC' */
const
char
svec_idr
[
4
]
=
"SVEC"
;
uint32_t
idc
;
uint32_t
n
;
uint32_t
rval
;
int
xldr_fifo_r0
;
/* Bitstream data input control register */
...
...
@@ -208,31 +206,22 @@ int svec_load_fpga(struct svec_dev *svec, const void *blob, int size)
printk
(
KERN_ERR
PFX
"CS/CSR window not found
\n
"
);
return
-
EINVAL
;
}
loader_addr
=
svec
->
cs_csr
->
kernel_va
+
BASE_LOADER
;
/* Magic sequence: unlock bootloader mode, disable application FPGA */
for
(
i
=
0
;
i
<
8
;
i
++
)
iowrite32
(
swapbe32
(
boot_seq
[
i
]),
loader_addr
+
XLDR_REG_BTRIGR
);
printk
(
KERN_ERR
PFX
"wrote unlock sequence at %x
\n
"
,
(
unsigned
int
)
loader_addr
+
XLDR_REG_BTRIGR
);
/* Check if we are really talking to a SVEC */
/* Looking for 'SVEC' string */
idc
=
swapbe32
(
ioread32
(
loader_addr
+
XLDR_REG_IDR
));
id_string
[
0
]
=
(
idc
>>
24
)
&
0xff
;
id_string
[
1
]
=
(
idc
>>
16
)
&
0xff
;
id_string
[
2
]
=
(
idc
>>
8
)
&
0xff
;
id_string
[
3
]
=
(
idc
>>
0
)
&
0xff
;
id_string
[
4
]
=
0
;
/* Unlock (activate) bootloader */
if
(
svec_bootloader_unlock
(
svec
))
{
printk
(
KERN_ERR
PFX
"Bootloader unlock failed
\n
"
);
return
-
EINVAL
;
}
if
(
strncmp
(
id_string
,
svec_idr
,
4
))
{
printk
(
KERN_ERR
PFX
"Invalid IDCode value %x [%s].
\n
"
,
idc
,
&
id_string
[
0
]
);
return
-
EINVAL
;
/* Check if bootloader is active */
if
(
!
svec_bootloader_is_active
(
svec
))
{
printk
(
KERN_ERR
PFX
"Bootloader locked after unlock!
\n
"
);
return
-
EINVAL
;
}
printk
(
KERN_INFO
PFX
"IDCode value %x [%s].
\n
"
,
idc
,
&
id_string
[
0
]);
/* FPGA loader virtual address */
loader_addr
=
svec
->
cs_csr
->
kernel_va
+
BASE_LOADER
;
i
=
0
;
iowrite32
(
swapbe32
(
XLDR_CSR_SWRST
),
loader_addr
+
XLDR_REG_CSR
);
iowrite32
(
swapbe32
(
XLDR_CSR_START
|
XLDR_CSR_MSBF
),
loader_addr
+
XLDR_REG_CSR
);
...
...
@@ -320,7 +309,7 @@ static int __devinit svec_match(struct device *pdev, unsigned int ndev)
return
1
;
}
int
svec_load_fpga_file
(
struct
svec_dev
*
svec
,
char
*
name
)
int
svec_load_fpga_file
(
struct
svec_dev
*
svec
,
c
onst
c
har
*
name
)
{
struct
device
*
dev
=
svec
->
dev
;
const
struct
firmware
*
fw
;
...
...
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