Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
M
Mock Turtle
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
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
Mock Turtle
Commits
ce4d377c
Commit
ce4d377c
authored
May 09, 2018
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sw:drv: autodetect endianess
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
91a7c46e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
35 deletions
+45
-35
linux-driver.rst
doc/software/linux-driver.rst
+3
-0
mockturtle-core.c
software/kernel/mockturtle-core.c
+38
-27
mockturtle-drv.h
software/kernel/mockturtle-drv.h
+4
-8
No files found.
doc/software/linux-driver.rst
View file @
ce4d377c
...
...
@@ -81,6 +81,9 @@ The Mock Turtle device driver is based on the platform Linux subsystem
describes the Mock Turtle device. Typically, this mechanism involves the
development of a Linux module or the DeviceTree.
This driver handles all platform_device instances which name is one of
the following: "mock-turtle", "mockturtle".
The Mock Turtle device driver expects 5 ``resources`` from the platform
device.
...
...
software/kernel/mockturtle-core.c
View file @
ce4d377c
...
...
@@ -32,12 +32,6 @@
static
DEFINE_IDA
(
trtl_ida
);
struct
trtl_memory_ops
memops
=
{
.
read
=
NULL
,
.
write
=
NULL
,
};
static
int
trtl_dev_uevent
(
struct
device
*
dev
,
struct
kobj_uevent_env
*
env
)
{
add_uevent_var
(
env
,
"DEVMODE=%#o"
,
0440
);
...
...
@@ -565,6 +559,38 @@ static int trtl_resource_validation(struct platform_device *pdev)
return
0
;
}
static
int
trtl_endianess
(
struct
trtl_dev
*
trtl
)
{
uint32_t
signature
;
signature
=
ioread32
(
trtl
->
base_cfg
);
if
(
signature
==
TRTL_CONFIG_ROM_SIGNATURE
)
return
0
;
signature
=
ioread32be
(
trtl
->
base_cfg
);
if
(
signature
==
TRTL_CONFIG_ROM_SIGNATURE
)
return
1
;
return
-
1
;
}
static
int
trtl_memops_detect
(
struct
trtl_dev
*
trtl
)
{
switch
(
trtl_endianess
(
trtl
))
{
case
0
:
trtl
->
memops
.
read
=
ioread32
;
trtl
->
memops
.
write
=
iowrite32
;
return
0
;
case
1
:
trtl
->
memops
.
read
=
ioread32be
;
trtl
->
memops
.
write
=
iowrite32be
;
return
0
;
default:
dev_err
(
&
trtl
->
dev
,
"Invalid endianess
\n
"
);
return
-
EINVAL
;
}
}
/**
* It initialize the TRTL device (device, CPUs, HMQs)
*/
...
...
@@ -587,22 +613,6 @@ int trtl_probe(struct platform_device *pdev)
platform_set_drvdata
(
pdev
,
trtl
);
/* Assign IO operation */
switch
(
pdev
->
id_entry
->
driver_data
)
{
case
TRTL_VER_SPEC
:
memops
.
read
=
ioread32
;
memops
.
write
=
iowrite32
;
break
;
case
TRTL_VER_SVEC
:
memops
.
read
=
ioread32be
;
memops
.
write
=
iowrite32be
;
break
;
default:
dev_err
(
&
trtl
->
dev
,
"Unknow version %lu
\n
"
,
pdev
->
id_entry
->
driver_data
);
return
-
EINVAL
;
}
r
=
platform_get_resource
(
pdev
,
IORESOURCE_MEM
,
TRTL_MEM_BASE
);
trtl
->
base_core
=
ioremap
(
r
->
start
,
resource_size
(
r
));
trtl
->
base_csr
=
trtl
->
base_core
+
TRTL_ADDR_OFFSET_CSR
;
...
...
@@ -610,6 +620,8 @@ int trtl_probe(struct platform_device *pdev)
trtl
->
base_hmq
=
trtl
->
base_core
+
TRTL_ADDR_OFFSET_HMQ
;
trtl
->
base_cfg
=
trtl
->
base_core
+
TRTL_ADDR_OFFSET_CONFIG_ROM
;
trtl_memops_detect
(
trtl
);
/* Register the device */
err
=
dev_set_name
(
&
trtl
->
dev
,
"trtl-%04x"
,
pdev
->
id
);
if
(
err
)
...
...
@@ -734,11 +746,10 @@ int trtl_remove(struct platform_device *pdev)
static
const
struct
platform_device_id
trtl_id
[]
=
{
{
.
name
=
"mock-turtle-spec"
,
.
driver_data
=
TRTL_VER_SPEC
,
},
{
.
name
=
"mock-turtle-svec"
,
.
driver_data
=
TRTL_VER_SVEC
,
.
name
=
"mock-turtle"
,
},
{
.
name
=
"mockturtle"
,
},
/* TODO we should support different version */
...
...
software/kernel/mockturtle-drv.h
View file @
ce4d377c
...
...
@@ -37,12 +37,6 @@
extern
struct
class
trtl_cdev_class
;
enum
mock_turtle_versions
{
TRTL_VER_SPEC
=
0
,
TRTL_VER_SVEC
,
/* TODO actually all versioning */
};
/**
* It enumerates the IRQ sources
...
...
@@ -221,19 +215,21 @@ struct trtl_dev {
struct
tty_driver
*
tty_driver
;
struct
trtl_memory_ops
memops
;
struct
dentry
*
dbg_dir
;
/**< root debug directory */
struct
dentry
*
dbg_info
;
/**< information */
};
static
inline
u32
trtl_ioread
(
struct
trtl_dev
*
trtl
,
void
*
addr
)
{
return
memops
.
read
(
addr
);
return
trtl
->
memops
.
read
(
addr
);
}
static
inline
void
trtl_iowrite
(
struct
trtl_dev
*
trtl
,
u32
value
,
void
*
addr
)
{
return
memops
.
write
(
value
,
addr
);
return
trtl
->
memops
.
write
(
value
,
addr
);
}
/* Global data */
...
...
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