Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
FMC ADC 100M 14b 4cha - Software
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
FMC ADC 100M 14b 4cha - Software
Commits
4ac10688
Commit
4ac10688
authored
Aug 12, 2016
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel: isolate FMC io functions
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
0a777e94
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
13 deletions
+23
-13
fmc-adc-100m14b4cha.h
kernel/fmc-adc-100m14b4cha.h
+13
-3
onewire.c
kernel/onewire.c
+2
-2
spi.c
kernel/spi.c
+8
-8
No files found.
kernel/fmc-adc-100m14b4cha.h
View file @
4ac10688
...
...
@@ -419,13 +419,23 @@ static inline struct fa_dev *get_zfadc(struct device *dev)
return
NULL
;
}
static
inline
u32
fa_ioread
(
struct
fa_dev
*
fa
,
unsigned
long
addr
)
{
return
fmc_readl
(
fa
->
fmc
,
addr
);
}
static
inline
void
fa_iowrite
(
struct
fa_dev
*
fa
,
u32
value
,
unsigned
long
addr
)
{
fmc_writel
(
fa
->
fmc
,
value
,
addr
);
}
static
inline
uint32_t
fa_readl
(
struct
fa_dev
*
fa
,
unsigned
int
base_off
,
const
struct
zfa_field_desc
*
field
)
{
uint32_t
cur
;
cur
=
f
mc_readl
(
fa
->
fmc
,
base_off
+
field
->
offset
);
cur
=
f
a_ioread
(
fa
,
base_off
+
field
->
offset
);
if
(
field
->
is_bitfield
)
{
/* apply mask and shift right accordlying to the mask */
cur
&=
field
->
mask
;
...
...
@@ -446,7 +456,7 @@ static inline void fa_writel(struct fa_dev *fa,
val
=
usr_val
;
/* Read current register value first if it's a bitfield */
if
(
field
->
is_bitfield
)
{
cur
=
f
mc_readl
(
fa
->
fmc
,
base_off
+
field
->
offset
);
cur
=
f
a_ioread
(
fa
,
base_off
+
field
->
offset
);
/* */
cur
&=
~
field
->
mask
;
/* clear bits according to the mask */
val
=
usr_val
*
(
field
->
mask
&
-
(
field
->
mask
));
...
...
@@ -457,7 +467,7 @@ static inline void fa_writel(struct fa_dev *fa,
val
&=
field
->
mask
;
val
|=
cur
;
}
f
mc_writel
(
fa
->
fmc
,
val
,
base_off
+
field
->
offset
);
f
a_iowrite
(
fa
,
val
,
base_off
+
field
->
offset
);
}
/* Global variable exported by fa-core.c */
...
...
kernel/onewire.c
View file @
4ac10688
...
...
@@ -57,12 +57,12 @@
static
void
ow_writel
(
struct
fa_dev
*
fa
,
uint32_t
val
,
unsigned
long
reg
)
{
f
mc_writel
(
fa
->
fmc
,
val
,
fa
->
fa_ow_base
+
reg
);
f
a_iowrite
(
fa
,
val
,
fa
->
fa_ow_base
+
reg
);
}
static
uint32_t
ow_readl
(
struct
fa_dev
*
fa
,
unsigned
long
reg
)
{
return
f
mc_readl
(
fa
->
fmc
,
fa
->
fa_ow_base
+
reg
);
return
f
a_ioread
(
fa
,
fa
->
fa_ow_base
+
reg
);
}
static
int
ow_reset
(
struct
fa_dev
*
fa
,
int
port
)
...
...
kernel/spi.c
View file @
4ac10688
...
...
@@ -41,19 +41,19 @@ int fa_spi_xfer(struct fa_dev *fa, int cs, int num_bits,
int
err
=
0
;
/* Put out value (LSB-aligned) in the T0 register (bits 0..31) */
f
mc_writel
(
fa
->
fmc
,
tx
,
fa
->
fa_spi_base
+
FA_SPI_TX
(
0
));
f
a_iowrite
(
fa
,
tx
,
fa
->
fa_spi_base
+
FA_SPI_TX
(
0
));
/* Configure SPI controller */
regval
=
FA_SPI_CTRL_ASS
|
/* Automatic Slave Select*/
FA_SPI_CTRL_Tx_NEG
|
/* Change on falling edge */
num_bits
;
/* In CHAR_LEN field */
f
mc_writel
(
fa
->
fmc
,
regval
,
fa
->
fa_spi_base
+
FA_SPI_CTRL
);
f
a_iowrite
(
fa
,
regval
,
fa
->
fa_spi_base
+
FA_SPI_CTRL
);
/* Set Chip Select */
f
mc_writel
(
fa
->
fmc
,
(
1
<<
cs
),
fa
->
fa_spi_base
+
FA_SPI_CS
);
f
a_iowrite
(
fa
,
(
1
<<
cs
),
fa
->
fa_spi_base
+
FA_SPI_CS
);
/* Start transfer */
f
mc_writel
(
fa
->
fmc
,
regval
|
FA_SPI_CTRL_GO
,
f
a_iowrite
(
fa
,
regval
|
FA_SPI_CTRL_GO
,
fa
->
fa_spi_base
+
FA_SPI_CTRL
);
/* Wait transfer complete */
while
(
f
mc_readl
(
fa
->
fmc
,
fa
->
fa_spi_base
+
FA_SPI_CTRL
)
while
(
f
a_ioread
(
fa
,
fa
->
fa_spi_base
+
FA_SPI_CTRL
)
&
FA_SPI_CTRL_BUSY
)
{
if
(
jiffies
>
j
)
{
dev_err
(
&
fa
->
fmc
->
dev
,
"SPI transfer error
\n
"
);
...
...
@@ -62,12 +62,12 @@ int fa_spi_xfer(struct fa_dev *fa, int cs, int num_bits,
}
}
/* Transfer compleate, read data */
regval
=
f
mc_readl
(
fa
->
fmc
,
fa
->
fa_spi_base
+
FA_SPI_RX
(
0
));
regval
=
f
a_ioread
(
fa
,
fa
->
fa_spi_base
+
FA_SPI_RX
(
0
));
if
(
rx
)
*
rx
=
regval
;
out:
/* Clear Chip Select */
f
mc_writel
(
fa
->
fmc
,
0
,
fa
->
fa_spi_base
+
FA_SPI_CTRL
);
f
a_iowrite
(
fa
,
0
,
fa
->
fa_spi_base
+
FA_SPI_CTRL
);
return
err
;
}
...
...
@@ -79,7 +79,7 @@ int fa_spi_init(struct fa_dev *fa)
int
i
;
/* Divider must be 100, according to firmware guide */
f
mc_writel
(
fa
->
fmc
,
100
,
fa
->
fa_spi_base
+
FA_SPI_DIV
);
f
a_iowrite
(
fa
,
100
,
fa
->
fa_spi_base
+
FA_SPI_DIV
);
/* Force 2's complement data output (register 1, bit 5) */
fa_spi_xfer
(
fa
,
FA_SPI_SS_ADC
,
16
,
(
1
<<
8
)
|
(
1
<<
5
),
&
rx
);
...
...
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