Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
raspberrypi-kernel
提交
0732a9d2
R
raspberrypi-kernel
项目概览
openeuler
/
raspberrypi-kernel
通知
13
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
raspberrypi-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
0732a9d2
编写于
10月 05, 2013
作者:
M
Mark Brown
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
spi/s3c64xx: Use core message handling
Signed-off-by:
N
Mark Brown
<
broonie@linaro.org
>
上级
2cc6e2e0
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
56 addition
and
96 deletion
+56
-96
drivers/spi/spi-s3c64xx.c
drivers/spi/spi-s3c64xx.c
+56
-96
未找到文件。
drivers/spi/spi-s3c64xx.c
浏览文件 @
0732a9d2
...
...
@@ -879,121 +879,81 @@ static int s3c64xx_spi_prepare_message(struct spi_master *master,
return
0
;
}
static
int
s3c64xx_spi_transfer_one_message
(
struct
spi_master
*
master
,
struct
spi_message
*
msg
)
static
int
s3c64xx_spi_transfer_one
(
struct
spi_master
*
master
,
struct
spi_device
*
spi
,
struct
spi_transfer
*
xfer
)
{
struct
s3c64xx_spi_driver_data
*
sdd
=
spi_master_get_devdata
(
master
);
struct
spi_device
*
spi
=
msg
->
spi
;
struct
spi_transfer
*
xfer
;
int
status
=
0
,
cs_toggle
=
0
;
int
status
;
u32
speed
;
u8
bpw
;
unsigned
long
flags
;
int
use_dma
;
list_for_each_entry
(
xfer
,
&
msg
->
transfers
,
transfer_list
)
{
unsigned
long
flags
;
int
use_dma
;
INIT_COMPLETION
(
sdd
->
xfer_completion
);
/* Only BPW and Speed may change across transfers */
bpw
=
xfer
->
bits_per_word
;
speed
=
xfer
->
speed_hz
?
:
spi
->
max_speed_hz
;
if
(
xfer
->
len
%
(
bpw
/
8
))
{
dev_err
(
&
spi
->
dev
,
"Xfer length(%u) not a multiple of word size(%u)
\n
"
,
xfer
->
len
,
bpw
/
8
);
status
=
-
EIO
;
goto
out
;
}
if
(
bpw
!=
sdd
->
cur_bpw
||
speed
!=
sdd
->
cur_speed
)
{
sdd
->
cur_bpw
=
bpw
;
sdd
->
cur_speed
=
speed
;
s3c64xx_spi_config
(
sdd
);
}
/* Slave Select */
enable_cs
(
sdd
,
spi
);
/* Polling method for xfers not bigger than FIFO capacity */
use_dma
=
0
;
if
(
!
is_polling
(
sdd
)
&&
(
sdd
->
rx_dma
.
ch
&&
sdd
->
tx_dma
.
ch
&&
(
xfer
->
len
>
((
FIFO_LVL_MASK
(
sdd
)
>>
1
)
+
1
))))
use_dma
=
1
;
spin_lock_irqsave
(
&
sdd
->
lock
,
flags
);
INIT_COMPLETION
(
sdd
->
xfer_completion
);
/* Pending only which is to be done
*/
sdd
->
state
&=
~
RXBUSY
;
sdd
->
state
&=
~
TXBUSY
;
/* Only BPW and Speed may change across transfers
*/
bpw
=
xfer
->
bits_per_word
;
speed
=
xfer
->
speed_hz
?
:
spi
->
max_speed_hz
;
enable_datapath
(
sdd
,
spi
,
xfer
,
use_dma
);
/* Start the signals */
writel
(
0
,
sdd
->
regs
+
S3C64XX_SPI_SLAVE_SEL
);
if
(
xfer
->
len
%
(
bpw
/
8
))
{
dev_err
(
&
spi
->
dev
,
"Xfer length(%u) not a multiple of word size(%u)
\n
"
,
xfer
->
len
,
bpw
/
8
);
return
-
EIO
;
}
/* Start the signals */
writel
(
0
,
sdd
->
regs
+
S3C64XX_SPI_SLAVE_SEL
);
if
(
bpw
!=
sdd
->
cur_bpw
||
speed
!=
sdd
->
cur_speed
)
{
sdd
->
cur_bpw
=
bpw
;
sdd
->
cur_speed
=
speed
;
s3c64xx_spi_config
(
sdd
);
}
spin_unlock_irqrestore
(
&
sdd
->
lock
,
flags
);
/* Polling method for xfers not bigger than FIFO capacity */
use_dma
=
0
;
if
(
!
is_polling
(
sdd
)
&&
(
sdd
->
rx_dma
.
ch
&&
sdd
->
tx_dma
.
ch
&&
(
xfer
->
len
>
((
FIFO_LVL_MASK
(
sdd
)
>>
1
)
+
1
))))
use_dma
=
1
;
status
=
wait_for_xfer
(
sdd
,
xfer
,
use_dma
);
spin_lock_irqsave
(
&
sdd
->
lock
,
flags
);
if
(
status
)
{
dev_err
(
&
spi
->
dev
,
"I/O Error: rx-%d tx-%d res:rx-%c tx-%c len-%d
\n
"
,
xfer
->
rx_buf
?
1
:
0
,
xfer
->
tx_buf
?
1
:
0
,
(
sdd
->
state
&
RXBUSY
)
?
'f'
:
'p'
,
(
sdd
->
state
&
TXBUSY
)
?
'f'
:
'p'
,
xfer
->
len
);
/* Pending only which is to be done */
sdd
->
state
&=
~
RXBUSY
;
sdd
->
state
&=
~
TXBUSY
;
if
(
use_dma
)
{
if
(
xfer
->
tx_buf
!=
NULL
&&
(
sdd
->
state
&
TXBUSY
))
s3c64xx_spi_dma_stop
(
sdd
,
&
sdd
->
tx_dma
);
if
(
xfer
->
rx_buf
!=
NULL
&&
(
sdd
->
state
&
RXBUSY
))
s3c64xx_spi_dma_stop
(
sdd
,
&
sdd
->
rx_dma
);
}
enable_datapath
(
sdd
,
spi
,
xfer
,
use_dma
);
goto
out
;
}
/* Start the signals */
writel
(
0
,
sdd
->
regs
+
S3C64XX_SPI_SLAVE_SEL
);
flush_fifo
(
sdd
);
/* Start the signals */
writel
(
0
,
sdd
->
regs
+
S3C64XX_SPI_SLAVE_SEL
);
if
(
xfer
->
delay_usecs
)
udelay
(
xfer
->
delay_usecs
);
spin_unlock_irqrestore
(
&
sdd
->
lock
,
flags
);
if
(
xfer
->
cs_change
)
{
/* Hint that the next mssg is gonna be
for the same device */
if
(
list_is_last
(
&
xfer
->
transfer_list
,
&
msg
->
transfers
))
cs_toggle
=
1
;
status
=
wait_for_xfer
(
sdd
,
xfer
,
use_dma
);
if
(
status
)
{
dev_err
(
&
spi
->
dev
,
"I/O Error: rx-%d tx-%d res:rx-%c tx-%c len-%d
\n
"
,
xfer
->
rx_buf
?
1
:
0
,
xfer
->
tx_buf
?
1
:
0
,
(
sdd
->
state
&
RXBUSY
)
?
'f'
:
'p'
,
(
sdd
->
state
&
TXBUSY
)
?
'f'
:
'p'
,
xfer
->
len
);
if
(
use_dma
)
{
if
(
xfer
->
tx_buf
!=
NULL
&&
(
sdd
->
state
&
TXBUSY
))
s3c64xx_spi_dma_stop
(
sdd
,
&
sdd
->
tx_dma
);
if
(
xfer
->
rx_buf
!=
NULL
&&
(
sdd
->
state
&
RXBUSY
))
s3c64xx_spi_dma_stop
(
sdd
,
&
sdd
->
rx_dma
);
}
msg
->
actual_length
+=
xfer
->
len
;
}
out:
if
(
!
cs_toggle
||
status
)
{
/* Quiese the signals */
writel
(
S3C64XX_SPI_SLAVE_SIG_INACT
,
sdd
->
regs
+
S3C64XX_SPI_SLAVE_SEL
);
disable_cs
(
sdd
,
spi
);
}
else
{
sdd
->
tgl_spi
=
spi
;
flush_fifo
(
sdd
)
;
}
s3c64xx_spi_unmap_mssg
(
sdd
,
msg
);
msg
->
status
=
status
;
spi_finalize_current_message
(
master
);
return
0
;
return
status
;
}
static
int
s3c64xx_spi_unprepare_message
(
struct
spi_master
*
master
,
...
...
@@ -1379,7 +1339,7 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
master
->
cleanup
=
s3c64xx_spi_cleanup
;
master
->
prepare_transfer_hardware
=
s3c64xx_spi_prepare_transfer
;
master
->
prepare_message
=
s3c64xx_spi_prepare_message
;
master
->
transfer_one
_message
=
s3c64xx_spi_transfer_one_messag
e
;
master
->
transfer_one
=
s3c64xx_spi_transfer_on
e
;
master
->
unprepare_message
=
s3c64xx_spi_unprepare_message
;
master
->
unprepare_transfer_hardware
=
s3c64xx_spi_unprepare_transfer
;
master
->
num_chipselect
=
sci
->
num_cs
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录