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
e1485041
Commit
e1485041
authored
Feb 23, 2016
by
Mikhail Karpenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add libahci_debug
parent
98ffa008
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
949 additions
and
37 deletions
+949
-37
.cproject
.cproject
+8
-3
ahci_elphel.c
src/drivers/ata/ahci_elphel.c
+50
-34
libahci_debug.c
src/drivers/ata/libahci_debug.c
+781
-0
libahci_debug.h
src/drivers/ata/libahci_debug.h
+110
-0
No files found.
.cproject
View file @
e1485041
...
@@ -34,12 +34,12 @@
...
@@ -34,12 +34,12 @@
</option>
</option>
<option
id=
"gnu.c.compiler.option.include.paths.1702086126"
name=
"Include paths (-I)"
superClass=
"gnu.c.compiler.option.include.paths"
valueType=
"includePath"
>
<option
id=
"gnu.c.compiler.option.include.paths.1702086126"
name=
"Include paths (-I)"
superClass=
"gnu.c.compiler.option.include.paths"
valueType=
"includePath"
>
<listOptionValue
builtIn=
"false"
value=
""${workspace_loc:/linux-elphel/linux/source/include}""
/>
<listOptionValue
builtIn=
"false"
value=
""${workspace_loc:/linux-elphel/linux/source/include}""
/>
<listOptionValue
builtIn=
"false"
value=
""${workspace_loc:/linux-elphel/linux/source/include/uapi}""
/>
<listOptionValue
builtIn=
"false"
value=
""${workspace_loc:/linux-elphel/linux/source/arch/arm/include}""
/>
<listOptionValue
builtIn=
"false"
value=
""${workspace_loc:/linux-elphel/linux/source/arch/arm/include/uapi}""
/>
<listOptionValue
builtIn=
"false"
value=
""${workspace_loc:/linux-elphel/linux/arch/arm/include/generated}""
/>
<listOptionValue
builtIn=
"false"
value=
""${workspace_loc:/linux-elphel/linux/arch/arm/include/generated}""
/>
<listOptionValue
builtIn=
"false"
value=
""${workspace_loc:/linux-elphel/linux/arch/arm/include/generated/uapi}""
/>
<listOptionValue
builtIn=
"false"
value=
""${workspace_loc:/linux-elphel/linux/arch/arm/include/generated/uapi}""
/>
<listOptionValue
builtIn=
"false"
value=
""${workspace_loc:/linux-elphel/linux/include/generated/uapi}""
/>
<listOptionValue
builtIn=
"false"
value=
""${workspace_loc:/linux-elphel/linux/include/generated/uapi}""
/>
<listOptionValue
builtIn=
"false"
value=
""${workspace_loc:/linux-elphel/linux/source/arch/arm/include}""
/>
<listOptionValue
builtIn=
"false"
value=
""${workspace_loc:/linux-elphel/linux/source/arch/arm/include/uapi}""
/>
<listOptionValue
builtIn=
"false"
value=
""${workspace_loc:/linux-elphel/linux/source/include/uapi}""
/>
<listOptionValue
builtIn=
"false"
value=
""${workspace_loc:/linux-elphel/linux/source/arch/arm/plat-versatile/include}""
/>
<listOptionValue
builtIn=
"false"
value=
""${workspace_loc:/linux-elphel/linux/source/arch/arm/plat-versatile/include}""
/>
<listOptionValue
builtIn=
"false"
value=
""${workspace_loc:/linux-elphel/linux/source/drivers/scsi}""
/>
<listOptionValue
builtIn=
"false"
value=
""${workspace_loc:/linux-elphel/linux/source/drivers/scsi}""
/>
<listOptionValue
builtIn=
"false"
value=
""${workspace_loc:/linux-elphel/linux/source/arch/arm/boot/compressed}""
/>
<listOptionValue
builtIn=
"false"
value=
""${workspace_loc:/linux-elphel/linux/source/arch/arm/boot/compressed}""
/>
...
@@ -83,4 +83,9 @@
...
@@ -83,4 +83,9 @@
<autodiscovery
enabled=
"true"
problemReportingEnabled=
"true"
selectedProfileId=
""
/>
<autodiscovery
enabled=
"true"
problemReportingEnabled=
"true"
selectedProfileId=
""
/>
</scannerConfigBuildInfo>
</scannerConfigBuildInfo>
</storageModule>
</storageModule>
<storageModule
moduleId=
"refreshScope"
versionNumber=
"2"
>
<configuration
configurationName=
"Default"
>
<resource
resourceType=
"PROJECT"
workspacePath=
"/linux-elphel"
/>
</configuration>
</storageModule>
</cproject>
</cproject>
src/drivers/ata/ahci_elphel.c
View file @
e1485041
...
@@ -23,9 +23,9 @@
...
@@ -23,9 +23,9 @@
#include <linux/platform_device.h>
#include <linux/platform_device.h>
#include <linux/dma-mapping.h>
#include <linux/dma-mapping.h>
#include "ahci.h"
#include "ahci.h"
#include "libahci_debug.h"
#define DRV_NAME "elphel-ahci"
#define DRV_NAME "elphel-ahci"
#define MARKER "+"
/* Property names from device tree, these are specific for the controller */
/* Property names from device tree, these are specific for the controller */
#define PROP_NAME_CLB_OFFS "clb_offs"
#define PROP_NAME_CLB_OFFS "clb_offs"
...
@@ -50,8 +50,10 @@ static int elphel_port_start(struct ata_port *ap)
...
@@ -50,8 +50,10 @@ static int elphel_port_start(struct ata_port *ap)
struct
ahci_host_priv
*
hpriv
=
ap
->
host
->
private_data
;
struct
ahci_host_priv
*
hpriv
=
ap
->
host
->
private_data
;
const
struct
elphel_ahci_priv
*
dpriv
=
hpriv
->
plat_data
;
const
struct
elphel_ahci_priv
*
dpriv
=
hpriv
->
plat_data
;
libahci_debug_init
(
ap
->
host
);
dev_info
(
dev
,
"starting port %d"
,
ap
->
port_no
);
dev_info
(
dev
,
"starting port %d"
,
ap
->
port_no
);
/*
pp = devm_kzalloc(dev, sizeof(struct ahci_port_priv), GFP_KERNEL);
pp
=
devm_kzalloc
(
dev
,
sizeof
(
struct
ahci_port_priv
),
GFP_KERNEL
);
if
(
!
pp
)
if
(
!
pp
)
return
-
ENOMEM
;
return
-
ENOMEM
;
...
@@ -60,27 +62,31 @@ static int elphel_port_start(struct ata_port *ap)
...
@@ -60,27 +62,31 @@ static int elphel_port_start(struct ata_port *ap)
return
-
ENOMEM
;
return
-
ENOMEM
;
memset
(
mem
,
0
,
AHCI_CMD_TBL_AR_SZ
);
memset
(
mem
,
0
,
AHCI_CMD_TBL_AR_SZ
);
pp
->
cmd_tbl
=
mem
;
pp
->
cmd_tbl
=
mem
;
pp->cmd_tbl_dma = mem_dma;
*/
pp
->
cmd_tbl_dma
=
mem_dma
;
/*
/*
* Set predefined addresses
* Set predefined addresses
*/
*/
/*
pp->cmd_slot = hpriv->mmio + dpriv->clb_offs;
pp
->
cmd_slot
=
hpriv
->
mmio
+
dpriv
->
clb_offs
;
pp
->
cmd_slot_dma
=
virt_to_phys
(
pp
->
cmd_slot
);
pp
->
cmd_slot_dma
=
virt_to_phys
(
pp
->
cmd_slot
);
pp
->
rx_fis
=
hpriv
->
mmio
+
dpriv
->
fb_offs
;
pp
->
rx_fis
=
hpriv
->
mmio
+
dpriv
->
fb_offs
;
pp->rx_fis_dma = virt_to_phys(pp->rx_fis);*/
pp
->
rx_fis_dma
=
virt_to_phys
(
pp
->
rx_fis
);
dev_info
(
dev
,
"cmd_slot and rx_fis addresses are set"
);
dev_info
(
dev
,
"
\t
mmio address: 0x%p"
,
hpriv
->
mmio
);
dev_info
(
dev
,
"
\t
command slot virtual address: 0x%p"
,
pp
->
cmd_slot
);
dev_info
(
dev
,
"
\r
x fis virtual address: 0x%p"
,
pp
->
rx_fis
);
/*
/*
* Save off initial list of interrupts to be enabled.
* Save off initial list of interrupts to be enabled.
* This could be changed later
* This could be changed later
*/
*/
/*
pp->intr_mask = DEF_PORT_IRQ;
pp
->
intr_mask
=
DEF_PORT_IRQ
;
ap
->
private_data
=
pp
;
ap
->
private_data
=
pp
;
return ahci_port_resume(ap);*/
return
ahci_port_resume
(
ap
);
return
0
;
}
}
static
int
elphel_parse_prop
(
const
struct
device_node
*
devn
,
static
int
elphel_parse_prop
(
const
struct
device_node
*
devn
,
...
@@ -109,9 +115,9 @@ static int elphel_drv_probe(struct platform_device *pdev)
...
@@ -109,9 +115,9 @@ static int elphel_drv_probe(struct platform_device *pdev)
struct
elphel_ahci_priv
*
drv_priv
;
struct
elphel_ahci_priv
*
drv_priv
;
struct
device
*
dev
=
&
pdev
->
dev
;
struct
device
*
dev
=
&
pdev
->
dev
;
const
struct
of_device_id
*
match
;
const
struct
of_device_id
*
match
;
void
__iomem
*
mmio
=
NULL
;
struct
resource
*
res
;
struct
resource
*
res
;
unsigned
int
reg_val
;
dev_info
(
&
pdev
->
dev
,
"probing Elphel AHCI driver"
);
dev_info
(
&
pdev
->
dev
,
"probing Elphel AHCI driver"
);
drv_priv
=
devm_kzalloc
(
dev
,
sizeof
(
struct
elphel_ahci_priv
),
GFP_KERNEL
);
drv_priv
=
devm_kzalloc
(
dev
,
sizeof
(
struct
elphel_ahci_priv
),
GFP_KERNEL
);
...
@@ -126,39 +132,31 @@ static int elphel_drv_probe(struct platform_device *pdev)
...
@@ -126,39 +132,31 @@ static int elphel_drv_probe(struct platform_device *pdev)
if
(
ret
!=
0
)
if
(
ret
!=
0
)
return
ret
;
return
ret
;
/*
hpriv = ahci_platform_get_resources(pdev);
hpriv
=
ahci_platform_get_resources
(
pdev
);
if
(
IS_ERR
(
hpriv
))
if
(
IS_ERR
(
hpriv
))
return
PTR_ERR
(
hpriv
);
return
PTR_ERR
(
hpriv
);
hpriv->plat_data = drv_priv;
dev_info(dev, "ahci platform resources set");*/
dev_info
(
dev
,
"get IORESOURCE_MEM"
);
res
=
platform_get_resource
(
pdev
,
IORESOURCE_MEM
,
0
);
if
(
!
res
)
{
dev_err
(
dev
,
"can not get resourse"
);
return
-
EINVAL
;
}
dev_info
(
dev
,
"resource name: %s"
,
res
->
name
);
dev_info
(
dev
,
"resource start: 0x%08x"
,
res
->
start
);
dev_info
(
dev
,
"resource end: 0x%08x"
,
res
->
end
);
/*mmio = hpriv->mmio;
hpriv
->
plat_data
=
drv_priv
;
if (!mmio) {
dev_err(dev, "mmio pointer is not initialized");
ahci_platform_disable_resources(hpriv);
return -EINVAL;
}
dev_info(dev, "mmio pointer: 0x%08p", mmio);
dev_info(dev, "HOST CAP register: 0x%08x", readl(mmio + HOST_CAP));
ahci_platform_disable_resources(hpriv);*/
/*ret = ahci_platform_init_host(pdev, hpriv, &ahci_elphel_port_info,
reg_val
=
readl
(
hpriv
->
mmio
+
HOST_CAP
);
dev_info
(
dev
,
"HOST CAP register: 0x%08x"
,
reg_val
);
reg_val
=
readl
(
hpriv
->
mmio
+
HOST_CTL
);
dev_info
(
dev
,
"HOST GHC register: 0x%08x"
,
reg_val
);
reg_val
=
readl
(
hpriv
->
mmio
+
HOST_IRQ_STAT
);
dev_info
(
dev
,
"HOST IS register: 0x%08x"
,
reg_val
);
reg_val
=
readl
(
hpriv
->
mmio
+
HOST_PORTS_IMPL
);
dev_info
(
dev
,
"HOST PI register: 0x%08x"
,
reg_val
);
reg_val
=
readl
(
hpriv
->
mmio
+
HOST_VERSION
);
dev_info
(
dev
,
"HOST VS register: 0x%08x"
,
reg_val
);
ret
=
ahci_platform_init_host
(
pdev
,
hpriv
,
&
ahci_elphel_port_info
,
&
ahci_platform_sht
);
&
ahci_platform_sht
);
if
(
ret
)
{
if
(
ret
)
{
dev_err
(
dev
,
"can not initialize platform host"
);
ahci_platform_disable_resources
(
hpriv
);
ahci_platform_disable_resources
(
hpriv
);
return
ret
;
return
ret
;
}
}
dev_info(dev, "ahci platform host initialized");
*/
dev_info
(
dev
,
"ahci platform host initialized"
);
return
0
;
return
0
;
}
}
...
@@ -166,12 +164,30 @@ static int elphel_drv_probe(struct platform_device *pdev)
...
@@ -166,12 +164,30 @@ static int elphel_drv_probe(struct platform_device *pdev)
static
int
elphel_drv_remove
(
struct
platform_device
*
pdev
)
static
int
elphel_drv_remove
(
struct
platform_device
*
pdev
)
{
{
dev_info
(
&
pdev
->
dev
,
"removing Elphel AHCI driver"
);
dev_info
(
&
pdev
->
dev
,
"removing Elphel AHCI driver"
);
//ata_platform_remove_one(pdev);
ata_platform_remove_one
(
pdev
);
libahci_debug_exit
();
return
0
;
}
static
unsigned
int
elphel_read_id
(
struct
ata_device
*
dev
,
struct
ata_taskfile
*
tf
,
u16
*
id
)
{
u32
err_mask
;
struct
device
*
d
=
&
dev
->
tdev
;
err_mask
=
ata_do_dev_read_id
(
dev
,
tf
,
id
);
if
(
err_mask
)
return
err_mask
;
dev_info
(
d
,
"issue identify command"
);
return
0
;
}
}
static
struct
ata_port_operations
ahci_elphel_ops
=
{
static
struct
ata_port_operations
ahci_elphel_ops
=
{
.
inherits
=
&
ahci_ops
,
.
inherits
=
&
ahci_ops
,
.
port_start
=
elphel_port_start
,
.
port_start
=
elphel_port_start
,
.
read_id
=
elphel_read_id
,
};
};
static
const
struct
ata_port_info
ahci_elphel_port_info
=
{
static
const
struct
ata_port_info
ahci_elphel_port_info
=
{
...
...
src/drivers/ata/libahci_debug.c
0 → 100644
View file @
e1485041
This diff is collapsed.
Click to expand it.
src/drivers/ata/libahci_debug.h
0 → 100644
View file @
e1485041
/*
* libahci_debug.h
*
* Created on: Jan 20, 2016
* Author: mk
*/
#include "ahci.h"
#ifndef _LIBAHCI_DEBUG_H_
#define _LIBAHCI_DEBUG_H_
#define ROOT_DIR_NAME "ahci_exp"
#define FILE_NAME_CFIS "cfis"
#define FILE_NAME_CHDR "chdr"
#define MARKER "++"
#define EVT_MARKER ">"
#define CMD_FIS_SZ 20
#define CMD_HDR_SZ 16
#define CMD_DMA_BUFSZ 512
#define PORT_RESERVED_2 40
#define PORT_VENDOR_BYTES 16
#define LIBAHCI_DEBUG_BUFSZ 16384
struct
libahci_debug_list
{
unsigned
int
debug
;
unsigned
int
port_n
;
char
*
libahci_debug_buf
;
int
head
;
int
tail
;
struct
list_head
node
;
struct
mutex
read_mutex
;
wait_queue_head_t
debug_wait
;
spinlock_t
debug_list_lock
;
};
struct
simple_buff
{
char
*
buff
;
int
head
;
int
tail
;
bool
initialized
;
};
struct
ahci_cmd_fis
{
__le32
dw0
;
__le32
dw1
;
__le32
dw2
;
__le32
dw3
;
__le32
dw4
;
};
struct
ahci_cmd
{
struct
ahci_cmd_hdr
hdr
;
struct
ahci_cmd_fis
fis
;
struct
scatterlist
sg
;
char
*
sg_buff
;
int
cmd_sent
;
};
// AHCI Port registers
struct
port_regs
{
// Port command list base address
u32
PxCLB
;
// Port command list based address upper 32-bits
u32
PxCLBU
;
// Port FIS base address
u32
PxFB
;
// Port FIS base address upper 32-bits
u32
PxFBU
;
u32
PxIS
;
u32
PxIE
;
u32
PxCMD
;
u32
reserved_1
;
u32
PxTFD
;
u32
PxSIG
;
u32
PxSSTS
;
u32
PxSCTL
;
u32
PxSERR
;
u32
PxSACT
;
u32
PxCI
;
u32
PxSNTF
;
u32
PxFBS
;
u32
PxDEVSLP
;
char
reserved_2
[
PORT_RESERVED_2
];
char
PxVS
[
PORT_VENDOR_BYTES
];
};
struct
host_regs
{
u32
CAP
;
u32
GHC
;
u32
IS
;
u32
PI
;
u32
VS
;
u32
CCC_CTL
;
u32
CCC_PORTS
;
u32
EM_LOC
;
u32
EM_CTL
;
u32
CAP2
;
u32
BOHC
;
};
int
libahci_debug_init
(
struct
ata_host
*
host
);
void
libahci_debug_exit
(
void
);
void
libahci_debug_event
(
const
struct
ata_port
*
port
,
char
*
msg
,
size_t
msg_sz
);
void
libahci_debug_dump_region
(
const
struct
ata_port
*
ap
,
const
u32
*
buf
,
size_t
buff_sz
,
const
char
*
prefix
);
void
libahci_debug_dump_irq
(
u32
status
);
void
libahci_debug_dump_sg
(
const
struct
ata_queued_cmd
*
qc
,
const
char
*
prefix
);
void
libahci_debug_irq_notify
(
const
struct
ata_port
*
ap
);
void
libahci_debug_exec_cmd
(
struct
ata_port
*
ap
);
#endif
/* _LIBAHCI_DEBUG_H_ */
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