Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
linux-elphel
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
linux-elphel
Commits
4c1dde53
Commit
4c1dde53
authored
Apr 08, 2016
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Plain Diff
continue with sensor port i2c
parents
50663cc1
bc970067
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
197 additions
and
58 deletions
+197
-58
Makefile
src/drivers/elphel/Makefile
+3
-2
elphel393-mem.c
src/drivers/elphel/elphel393-mem.c
+28
-25
sensor_i2c.c
src/drivers/elphel/sensor_i2c.c
+166
-31
No files found.
src/drivers/elphel/Makefile
View file @
4c1dde53
...
@@ -8,5 +8,6 @@ obj-$(CONFIG_ELPHELDRVONMICROZED) += elphel393-mem.o
...
@@ -8,5 +8,6 @@ obj-$(CONFIG_ELPHELDRVONMICROZED) += elphel393-mem.o
obj-$(CONFIG_ELPHEL393_INIT)
+=
elphel393-init.o
obj-$(CONFIG_ELPHEL393_INIT)
+=
elphel393-init.o
obj-$(CONFIG_ELPHEL393)
+=
x393.o
obj-$(CONFIG_ELPHEL393)
+=
x393.o
obj-$(CONFIG_ELPHEL393)
+=
sensor_i2c.o
obj-$(CONFIG_ELPHEL393)
+=
sensor_i2c.o
fpgajtag-y
:=
fpgajtag353.o x393.o
obj-$(CONFIG_ELPHEL393)
+=
fpgajtag353.o
obj-$(CONFIG_ELPHEL393_EXTERNAL)
+=
fpgajtag.o
#fpgajtag-y := fpgajtag353.o x393.o
\ No newline at end of file
#obj-$(CONFIG_ELPHEL393_EXTERNAL)
+=
fpgajtag.o
\ No newline at end of file
src/drivers/elphel/elphel393-mem.c
View file @
4c1dde53
...
@@ -18,6 +18,10 @@
...
@@ -18,6 +18,10 @@
*! You should have received a copy of the GNU General Public License
*! You should have received a copy of the GNU General Public License
*! along with this program. If not, see <http://www.gnu.org/licenses/>.
*! along with this program. If not, see <http://www.gnu.org/licenses/>.
*!****************************************************************************/
*!****************************************************************************/
#define DRV_NAME "elphel393-mem"
#define pr_fmt(fmt) DRV_NAME": " fmt
#include <linux/module.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/init.h>
#include <linux/of.h>
#include <linux/of.h>
...
@@ -74,7 +78,7 @@ static int __init elphelmem_init(void)
...
@@ -74,7 +78,7 @@ static int __init elphelmem_init(void)
node
=
of_find_node_by_name
(
NULL
,
"elphel393-mem"
);
node
=
of_find_node_by_name
(
NULL
,
"elphel393-mem"
);
if
(
!
node
)
if
(
!
node
)
{
{
pr
intk
(
"DMA buffer allocation ERROR: No device tree node found
\n
"
);
pr
_err
(
"DMA buffer allocation ERROR: No device tree node found
\n
"
);
return
-
ENODEV
;
return
-
ENODEV
;
}
}
...
@@ -116,34 +120,33 @@ static int __init elphelmem_init(void)
...
@@ -116,34 +120,33 @@ static int __init elphelmem_init(void)
// allocate continuous virtual memory range
// allocate continuous virtual memory range
// _elphel_buf.vaddr = kmalloc((_elphel_buf.size*PAGE_SIZE) ,GFP_KERNEL);
// _elphel_buf.vaddr = kmalloc((_elphel_buf.size*PAGE_SIZE) ,GFP_KERNEL);
_elphel_buf
.
vaddr
=
dma_alloc_coherent
(
NULL
,(
_elphel_buf
.
size
*
PAGE_SIZE
),
&
(
_elphel_buf
.
paddr
),
GFP_KERNEL
);
_elphel_buf
.
vaddr
=
dma_alloc_coherent
(
NULL
,(
_elphel_buf
.
size
*
PAGE_SIZE
),
&
(
_elphel_buf
.
paddr
),
GFP_KERNEL
);
if
(
_elphel_buf
.
p
addr
)
{
if
(
_elphel_buf
.
v
addr
)
{
pr
intk
(
"Allocated %u pages for DMA at address 0x%x
\n
"
,
(
u32
)
_elphel_buf
.
size
,
(
u32
)
_elphel_buf
.
paddr
);
pr
_info
(
"Allocated %u pages for DMA at address 0x%x
\n
"
,
(
u32
)
_elphel_buf
.
size
,
(
u32
)
_elphel_buf
.
paddr
);
}
else
{
}
else
{
pr
intk
(
"ERROR allocating coherent DMA memory buffer
"
);
pr
_err
(
"ERROR allocating coherent DMA memory buffer
\n
"
);
}
}
_elphel_buf
.
h2d_vaddr
=
kzalloc
((
_elphel_buf
.
h2d_size
*
PAGE_SIZE
)
,
GFP_KERNEL
);
_elphel_buf
.
h2d_vaddr
=
kzalloc
((
_elphel_buf
.
h2d_size
*
PAGE_SIZE
)
,
GFP_KERNEL
);
if
(
!
_elphel_buf
.
h2d_vaddr
){
if
(
!
_elphel_buf
.
h2d_vaddr
){
_elphel_buf
.
h2d_size
=
0
;
_elphel_buf
.
h2d_size
=
0
;
pr
intk
(
"ERROR allocating H2D DMA memory buffer
"
);
pr
_err
(
"ERROR allocating H2D DMA memory buffer
\n
"
);
}
}
_elphel_buf
.
d2h_vaddr
=
kzalloc
((
_elphel_buf
.
d2h_size
*
PAGE_SIZE
)
,
GFP_KERNEL
);
_elphel_buf
.
d2h_vaddr
=
kzalloc
((
_elphel_buf
.
d2h_size
*
PAGE_SIZE
)
,
GFP_KERNEL
);
if
(
!
_elphel_buf
.
d2h_vaddr
){
if
(
!
_elphel_buf
.
d2h_vaddr
){
_elphel_buf
.
d2h_size
=
0
;
_elphel_buf
.
d2h_size
=
0
;
pr
intk
(
"ERROR allocating D2H DMA memory buffer
"
);
pr
_err
(
"ERROR allocating D2H DMA memory buffer
\n
"
);
}
}
_elphel_buf
.
bidir_vaddr
=
kzalloc
((
_elphel_buf
.
bidir_size
*
PAGE_SIZE
)
,
GFP_KERNEL
);
_elphel_buf
.
bidir_vaddr
=
kzalloc
((
_elphel_buf
.
bidir_size
*
PAGE_SIZE
)
,
GFP_KERNEL
);
if
(
!
_elphel_buf
.
bidir_vaddr
){
if
(
!
_elphel_buf
.
bidir_vaddr
){
_elphel_buf
.
bidir_size
=
0
;
_elphel_buf
.
bidir_size
=
0
;
pr
intk
(
"ERROR allocating Bidirectional DMA memory buffer
"
);
pr
_err
(
"ERROR allocating Bidirectional DMA memory buffer
\n
"
);
}
}
pr_info
(
"Coherent buffer vaddr: 0x%08X
\n
"
,(
u32
)
pElphel_buf
->
vaddr
);
printk
(
"Coherent buffer vaddr: 0x%08X
\n
"
,(
u32
)
pElphel_buf
->
vaddr
);
pr_info
(
"Coherent buffer paddr: 0x%08X
\n
"
,(
u32
)
pElphel_buf
->
paddr
);
printk
(
"Coherent buffer paddr: 0x%08X
\n
"
,(
u32
)
pElphel_buf
->
paddr
);
pr_info
(
"Coherent buffer length: 0x%08X
\n
"
,(
u32
)
pElphel_buf
->
size
*
PAGE_SIZE
);
printk
(
"Coherent buffer length: 0x%08X
\n
"
,(
u32
)
pElphel_buf
->
size
*
PAGE_SIZE
);
return
0
;
return
0
;
}
}
...
@@ -155,7 +158,7 @@ dma_map_single(struct device *dev, void *cpu_addr, size_t size,
...
@@ -155,7 +158,7 @@ dma_map_single(struct device *dev, void *cpu_addr, size_t size,
*/
*/
static
void
__exit
elphelmem_exit
(
void
)
static
void
__exit
elphelmem_exit
(
void
)
{
{
printk
(
"DMA buffer disabled
\n
"
);
pr_info
(
"DMA buffer disabled
\n
"
);
}
}
...
@@ -240,7 +243,7 @@ static ssize_t sync_for_device_h2d(struct device *dev, struct device_attribute *
...
@@ -240,7 +243,7 @@ static ssize_t sync_for_device_h2d(struct device *dev, struct device_attribute *
paddr
=
_elphel_buf
.
h2d_paddr
;
paddr
=
_elphel_buf
.
h2d_paddr
;
len
=
_elphel_buf
.
h2d_size
*
PAGE_SIZE
;
len
=
_elphel_buf
.
h2d_size
*
PAGE_SIZE
;
}
}
pr
intk
(
"
\n
addr=0x%08x, size = 0x%08x
\n
"
,
paddr
,
len
);
pr
_info
(
"
\n
addr=0x%08x, size = 0x%08x
\n
"
,
paddr
,
len
);
dma_sync_single_for_device
(
dev
,
paddr
,
len
,
DMA_TO_DEVICE
);
dma_sync_single_for_device
(
dev
,
paddr
,
len
,
DMA_TO_DEVICE
);
return
count
;
return
count
;
...
@@ -255,7 +258,7 @@ static ssize_t sync_for_cpu_d2h(struct device *dev, struct device_attribute *att
...
@@ -255,7 +258,7 @@ static ssize_t sync_for_cpu_d2h(struct device *dev, struct device_attribute *att
paddr
=
_elphel_buf
.
d2h_paddr
;
paddr
=
_elphel_buf
.
d2h_paddr
;
len
=
_elphel_buf
.
d2h_size
*
PAGE_SIZE
;
len
=
_elphel_buf
.
d2h_size
*
PAGE_SIZE
;
}
}
printk
(
"
\n
addr=0x%08x, size = 0x%08x
\n
"
,
paddr
,
len
);
pr_info
(
"
\n
addr=0x%08x, size = 0x%08x
\n
"
,
paddr
,
len
);
dma_sync_single_for_cpu
(
dev
,
paddr
,
len
,
DMA_FROM_DEVICE
);
dma_sync_single_for_cpu
(
dev
,
paddr
,
len
,
DMA_FROM_DEVICE
);
return
count
;
return
count
;
...
@@ -271,7 +274,7 @@ static ssize_t sync_for_device_d2h(struct device *dev, struct device_attribute *
...
@@ -271,7 +274,7 @@ static ssize_t sync_for_device_d2h(struct device *dev, struct device_attribute *
paddr
=
_elphel_buf
.
d2h_paddr
;
paddr
=
_elphel_buf
.
d2h_paddr
;
len
=
_elphel_buf
.
d2h_size
*
PAGE_SIZE
;
len
=
_elphel_buf
.
d2h_size
*
PAGE_SIZE
;
}
}
printk
(
"
\n
addr=0x%08x, size = 0x%08x
\n
"
,
paddr
,
len
);
pr_info
(
"
\n
addr=0x%08x, size = 0x%08x
\n
"
,
paddr
,
len
);
dma_sync_single_for_device
(
dev
,
paddr
,
len
,
DMA_FROM_DEVICE
);
dma_sync_single_for_device
(
dev
,
paddr
,
len
,
DMA_FROM_DEVICE
);
return
count
;
return
count
;
...
@@ -286,7 +289,7 @@ static ssize_t sync_for_cpu_bidir(struct device *dev, struct device_attribute *a
...
@@ -286,7 +289,7 @@ static ssize_t sync_for_cpu_bidir(struct device *dev, struct device_attribute *a
paddr
=
_elphel_buf
.
bidir_paddr
;
paddr
=
_elphel_buf
.
bidir_paddr
;
len
=
_elphel_buf
.
bidir_size
*
PAGE_SIZE
;
len
=
_elphel_buf
.
bidir_size
*
PAGE_SIZE
;
}
}
printk
(
"
\n
addr=0x%08x, size = 0x%08x
\n
"
,
paddr
,
len
);
pr_info
(
"
\n
addr=0x%08x, size = 0x%08x
\n
"
,
paddr
,
len
);
dma_sync_single_for_cpu
(
dev
,
paddr
,
len
,
DMA_BIDIRECTIONAL
);
dma_sync_single_for_cpu
(
dev
,
paddr
,
len
,
DMA_BIDIRECTIONAL
);
return
count
;
return
count
;
...
@@ -302,7 +305,7 @@ static ssize_t sync_for_device_bidir(struct device *dev, struct device_attribute
...
@@ -302,7 +305,7 @@ static ssize_t sync_for_device_bidir(struct device *dev, struct device_attribute
paddr
=
_elphel_buf
.
bidir_paddr
;
paddr
=
_elphel_buf
.
bidir_paddr
;
len
=
_elphel_buf
.
bidir_size
*
PAGE_SIZE
;
len
=
_elphel_buf
.
bidir_size
*
PAGE_SIZE
;
}
}
printk
(
"
\n
addr=0x%08x, size = 0x%08x
\n
"
,
paddr
,
len
);
pr_info
(
"
\n
addr=0x%08x, size = 0x%08x
\n
"
,
paddr
,
len
);
dma_sync_single_for_device
(
dev
,
paddr
,
len
,
DMA_BIDIRECTIONAL
);
dma_sync_single_for_device
(
dev
,
paddr
,
len
,
DMA_BIDIRECTIONAL
);
return
count
;
return
count
;
...
@@ -386,13 +389,13 @@ static int elphel393_mem_sysfs_register(struct platform_device *pdev)
...
@@ -386,13 +389,13 @@ static int elphel393_mem_sysfs_register(struct platform_device *pdev)
static
int
elphel393_mem_probe
(
struct
platform_device
*
pdev
)
static
int
elphel393_mem_probe
(
struct
platform_device
*
pdev
)
{
{
elphel393_mem_sysfs_register
(
pdev
);
elphel393_mem_sysfs_register
(
pdev
);
dev_info
(
&
pdev
->
dev
,
"Probing elphel393-mem
\n
"
);
pr_info
(
"Probing elphel393-mem
\n
"
);
if
(
_elphel_buf
.
h2d_vaddr
){
if
(
_elphel_buf
.
h2d_vaddr
){
// mapped as DMA_BIDIRECTIONAL, each time will be synchronized when passing control from soft to hard and back
// mapped as DMA_BIDIRECTIONAL, each time will be synchronized when passing control from soft to hard and back
pElphel_buf
->
h2d_paddr
=
dma_map_single
(
&
pdev
->
dev
,
_elphel_buf
.
h2d_vaddr
,
(
_elphel_buf
.
h2d_size
*
PAGE_SIZE
),
DMA_TO_DEVICE
);
pElphel_buf
->
h2d_paddr
=
dma_map_single
(
&
pdev
->
dev
,
_elphel_buf
.
h2d_vaddr
,
(
_elphel_buf
.
h2d_size
*
PAGE_SIZE
),
DMA_TO_DEVICE
);
if
(
!
pElphel_buf
->
h2d_paddr
){
if
(
!
pElphel_buf
->
h2d_paddr
){
pr
intk
(
"ERROR in dma_map_single() for bidirectional buffer
"
);
pr
_err
(
"ERROR in dma_map_single() for bidirectional buffer
\n
"
);
return
0
;
return
0
;
}
}
// printk("H2D DMA buffer location:\t\t0x%08X\n", pElphel_buf->h2d_paddr);
// printk("H2D DMA buffer location:\t\t0x%08X\n", pElphel_buf->h2d_paddr);
...
@@ -402,7 +405,7 @@ static int elphel393_mem_probe(struct platform_device *pdev)
...
@@ -402,7 +405,7 @@ static int elphel393_mem_probe(struct platform_device *pdev)
// mapped as DMA_BIDIRECTIONAL, each time will be synchronized when passing control from soft to hard and back
// mapped as DMA_BIDIRECTIONAL, each time will be synchronized when passing control from soft to hard and back
pElphel_buf
->
d2h_paddr
=
dma_map_single
(
&
pdev
->
dev
,
_elphel_buf
.
d2h_vaddr
,
(
_elphel_buf
.
d2h_size
*
PAGE_SIZE
),
DMA_FROM_DEVICE
);
pElphel_buf
->
d2h_paddr
=
dma_map_single
(
&
pdev
->
dev
,
_elphel_buf
.
d2h_vaddr
,
(
_elphel_buf
.
d2h_size
*
PAGE_SIZE
),
DMA_FROM_DEVICE
);
if
(
!
pElphel_buf
->
d2h_paddr
){
if
(
!
pElphel_buf
->
d2h_paddr
){
pr
intk
(
"ERROR in dma_map_single() for bidirectional buffer
"
);
pr
_err
(
"ERROR in dma_map_single() for bidirectional buffer
\n
"
);
return
0
;
return
0
;
}
}
// printk("D2H DMA buffer location:\t\t0x%08X\n", pElphel_buf->d2h_paddr);
// printk("D2H DMA buffer location:\t\t0x%08X\n", pElphel_buf->d2h_paddr);
...
@@ -413,7 +416,7 @@ static int elphel393_mem_probe(struct platform_device *pdev)
...
@@ -413,7 +416,7 @@ static int elphel393_mem_probe(struct platform_device *pdev)
// mapped as DMA_BIDIRECTIONAL, each time will be synchronized when passing control from soft to hard and back
// mapped as DMA_BIDIRECTIONAL, each time will be synchronized when passing control from soft to hard and back
pElphel_buf
->
bidir_paddr
=
dma_map_single
(
&
pdev
->
dev
,
_elphel_buf
.
bidir_vaddr
,
(
_elphel_buf
.
bidir_size
*
PAGE_SIZE
),
DMA_BIDIRECTIONAL
);
pElphel_buf
->
bidir_paddr
=
dma_map_single
(
&
pdev
->
dev
,
_elphel_buf
.
bidir_vaddr
,
(
_elphel_buf
.
bidir_size
*
PAGE_SIZE
),
DMA_BIDIRECTIONAL
);
if
(
!
pElphel_buf
->
bidir_paddr
){
if
(
!
pElphel_buf
->
bidir_paddr
){
pr
intk
(
"ERROR in dma_map_single() for bidirectional buffer
"
);
pr
_err
(
"ERROR in dma_map_single() for bidirectional buffer
\n
"
);
return
0
;
return
0
;
}
}
// printk("Bidirectional DMA buffer location:\t0x%08X\n", pElphel_buf->bidir_paddr);
// printk("Bidirectional DMA buffer location:\t0x%08X\n", pElphel_buf->bidir_paddr);
...
@@ -438,7 +441,7 @@ static int elphel393_mem_probe(struct platform_device *pdev)
...
@@ -438,7 +441,7 @@ static int elphel393_mem_probe(struct platform_device *pdev)
static
int
elphel393_mem_remove
(
struct
platform_device
*
pdev
)
static
int
elphel393_mem_remove
(
struct
platform_device
*
pdev
)
{
{
dev_info
(
&
pdev
->
dev
,
"Removing elphel393-mem"
);
pr_info
(
"Removing elphel393-mem"
);
return
0
;
return
0
;
}
}
...
@@ -452,7 +455,7 @@ static struct platform_driver elphel393_mem = {
...
@@ -452,7 +455,7 @@ static struct platform_driver elphel393_mem = {
.
probe
=
elphel393_mem_probe
,
.
probe
=
elphel393_mem_probe
,
.
remove
=
elphel393_mem_remove
,
.
remove
=
elphel393_mem_remove
,
.
driver
=
{
.
driver
=
{
.
name
=
"elphel393-mem"
,
.
name
=
DRV_NAME
,
.
owner
=
THIS_MODULE
,
.
owner
=
THIS_MODULE
,
.
of_match_table
=
elphel393_mem_of_match
,
.
of_match_table
=
elphel393_mem_of_match
,
.
pm
=
NULL
,
/* power management */
.
pm
=
NULL
,
/* power management */
...
@@ -463,5 +466,5 @@ module_platform_driver(elphel393_mem);
...
@@ -463,5 +466,5 @@ module_platform_driver(elphel393_mem);
module_init
(
elphelmem_init
);
module_init
(
elphelmem_init
);
module_exit
(
elphelmem_exit
);
module_exit
(
elphelmem_exit
);
MODULE_LICENSE
(
"GPL"
);
MODULE_LICENSE
(
"GPL"
);
MODULE_AUTHOR
(
"Elphel, Inc."
);
MODULE_DESCRIPTION
(
"Reserve a large chunk of contiguous memory at boot"
);
src/drivers/elphel/sensor_i2c.c
View file @
4c1dde53
This diff is collapsed.
Click to expand it.
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