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
0e644a55
Commit
0e644a55
authored
Mar 10, 2020
by
Federico Vaga
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/dlamprid-dev' into feature/platform
parents
35650ac5
365ee811
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
76 additions
and
283 deletions
+76
-283
.gitignore
.gitignore
+1
-0
Makefile
Makefile
+6
-6
Kbuild
kernel/Kbuild
+1
-2
Makefile
kernel/Makefile
+1
-1
fa-core.c
kernel/fa-core.c
+3
-3
fa-dma.c
kernel/fa-dma.c
+12
-9
fa-regtable.c
kernel/fa-regtable.c
+6
-0
fa-zio-drv.c
kernel/fa-zio-drv.c
+27
-3
fmc-adc-100m14b4cha.h
kernel/fmc-adc-100m14b4cha.h
+10
-11
onewire.c
kernel/onewire.c
+0
-238
fau-calibration.c
tools/fau-calibration.c
+2
-3
fau-trg-config.c
tools/fau-trg-config.c
+3
-3
parport-burst.c
tools/parport-burst.c
+4
-4
No files found.
.gitignore
View file @
0e644a55
...
...
@@ -6,6 +6,7 @@
*.order
*.symvers
*.mod.c
*.mod
*.o.d
*.tmp
*.lof
...
...
Makefile
View file @
0e644a55
...
...
@@ -11,21 +11,21 @@ SVEC_SW ?= svec-sw
VMEBUS
?=
$(REPO_PARENT)
/vmebridge
# Use the absolute path so it can be used by submodule
# FMC_
BUS_
ABS and ZIO_ABS has to be absolut path,
# FMC_ABS and ZIO_ABS has to be absolut path,
# due to beeing passed to the Kbuild
FMC_
BUS_ABS
?=
$
(
abspath
$(FMC_BUS
)
)
FMC_
ABS
?=
$
(
abspath
$(FMC
)
)
ZIO_ABS
?=
$
(
abspath
$(ZIO)
)
SVEC_SW_ABS
?=
$
(
abspath
$(SVEC_SW)
)
VMEBUS_ABS
?=
$
(
abspath
$(VMEBUS)
)
export
FMC_
BUS_
ABS
export
FMC_ABS
export
ZIO_ABS
export
SVEC_SW_ABS
export
VMEBUS_ABS
DIRS
=
$(FMC_
BUS_
ABS)
$(ZIO_ABS)
kernel tools
DIRS
=
$(FMC_ABS)
$(ZIO_ABS)
kernel tools
kernel
:
$(FMC_
BUS_
ABS) $(ZIO_ABS)
kernel
:
$(FMC_ABS) $(ZIO_ABS)
.PHONY
:
all clean modules install modules_install $(DIRS)
.PHONY
:
gitmodules prereq_install prereq_install_warn
...
...
@@ -58,4 +58,4 @@ $(ZIO_ABS): zio-init_repo
# init submodule if missing
zio-init_repo
:
@
test
-d
$(ZIO_ABS)
/
doc
||
(
echo
"Checking out submodule
$(ZIO_ABS)
"
&&
git submodule update
--init
$(ZIO_ABS)
)
@
test
-d
$(ZIO_ABS)
/
Documentation
||
(
echo
"Checking out submodule
$(ZIO_ABS)
"
&&
git submodule update
--init
$(ZIO_ABS)
)
kernel/Kbuild
View file @
0e644a55
...
...
@@ -19,7 +19,7 @@ SUBMODULE_VERSIONS-y += MODULE_INFO(version_zio,\"$(ZIO_VERSION)\");
ccflags-y += -DADDITIONAL_VERSIONS="$(SUBMODULE_VERSIONS-y)"
ccflags-y += -DGIT_VERSION=\"$(GIT_VERSION)\" \
-I$(ZIO_ABS)/include \
-
I
$(FMC_ABS)/include \
-
iquote
$(FMC_ABS)/include \
-I $(VMEBUS_ABS)/driver \
-I$(src)
...
...
@@ -41,5 +41,4 @@ fmc-adc-100m14b4ch-y += fa-zio-trg.o
fmc-adc-100m14b4ch-y += fa-irq.o
fmc-adc-100m14b4ch-y += fa-debug.o
fmc-adc-100m14b4ch-y += fa-dma.o
fmc-adc-100m14b4ch-y += onewire.o
fmc-adc-100m14b4ch-y += spi.o
kernel/Makefile
View file @
0e644a55
...
...
@@ -20,7 +20,7 @@ ZIO_ABS ?= $(DKMSTREE)/zio/$(ZIO_VERSION)/source
ZIO_EXTRA_SYMBOLS-y
=
$(DKMSTREE)
/zio/kernel-
$(KVERSION)
-
$(
shell
uname
-p
)
/module/Module.symvers
else
ZIO_ABS
?=
$
(
abspath
$(ZIO)
)
ZIO_EXTRA_SYMBOLS-y
=
$(ZIO_ABS)
/Module.symvers
ZIO_EXTRA_SYMBOLS-y
=
$(ZIO_ABS)
/
drivers/zio/
Module.symvers
ZIO_VERSION
?=
$(
shell
cd
$(ZIO_ABS)
;
git describe
--always
--dirty
--long
--tags
)
FMC_ABS
?=
$
(
abspath
$(FMC)
)
FMC_EXTRA_SYMBOLS-y
=
$(FMC_ABS)
/drivers/fmc/Module.symvers
...
...
kernel/fa-core.c
View file @
0e644a55
...
...
@@ -9,8 +9,9 @@
#include <linux/init.h>
#include <linux/version.h>
#include <linux/dmaengine.h>
#include <linux/ipmi-fru.h>
#include <linux/fmc.h>
#include <linux/mod_devicetable.h>
#include "linux/ipmi-fru.h"
#include "linux/fmc.h"
#include "fmc-adc-100m14b4cha.h"
...
...
@@ -443,7 +444,6 @@ struct fa_modlist {
static
struct
fa_modlist
mods
[]
=
{
{
"spi"
,
fa_spi_init
,
fa_spi_exit
},
{
"onewire"
,
fa_onewire_init
,
fa_onewire_exit
},
{
"zio"
,
fa_zio_init
,
fa_zio_exit
},
{
"debug"
,
fa_debug_init
,
fa_debug_exit
},
{
"calibration"
,
fa_calib_init
,
fa_calib_exit
},
...
...
kernel/fa-dma.c
View file @
0e644a55
...
...
@@ -400,7 +400,7 @@ static bool fa_dmaengine_filter(struct dma_chan *dchan, void *arg)
break
;
case
ADC_VER_SVEC
:
/* The channel must be on the VME bus */
device_ref
=
fa
->
pdev
->
dev
.
parent
->
parent
;
device_ref
=
fa
->
pdev
->
dev
.
parent
->
parent
->
parent
->
parent
->
parent
;
break
;
default:
dev_warn
(
&
cset
->
head
.
dev
,
...
...
@@ -451,14 +451,17 @@ static int zfad_dma_start(struct zio_cset *cset)
goto
err
;
}
memset
(
&
sconfig
,
0
,
sizeof
(
sconfig
));
sconfig
.
direction
=
DMA_DEV_TO_MEM
;
if
(
fa
->
n_shots
==
1
)
sconfig
.
src_addr
=
zfad_dev_mem_offset
(
cset
);
sconfig
.
src_addr_width
=
8
;
/* 2 bytes for each channel (4) */
err
=
dmaengine_slave_config
(
dchan
,
&
sconfig
);
if
(
err
)
goto
err_config
;
if
(
fa
->
pdev
->
id_entry
->
driver_data
==
ADC_VER_SPEC
)
{
memset
(
&
sconfig
,
0
,
sizeof
(
sconfig
));
sconfig
.
direction
=
DMA_DEV_TO_MEM
;
if
(
fa
->
n_shots
==
1
)
sconfig
.
src_addr
=
zfad_dev_mem_offset
(
cset
);
sconfig
.
src_addr_width
=
8
;
/* 2 bytes for each channel (4) */
err
=
dmaengine_slave_config
(
dchan
,
&
sconfig
);
if
(
err
)
goto
err_config
;
}
for
(
i
=
0
;
i
<
fa
->
n_shots
;
++
i
)
{
err
=
zfad_dma_prep_slave_sg
(
dchan
,
cset
,
&
zfad_block
[
i
]);
if
(
err
)
...
...
kernel/fa-regtable.c
View file @
0e644a55
...
...
@@ -105,6 +105,12 @@ const struct zfa_field_desc zfad_regs[] = {
[
ZFA_IRQ_VIC_DISABLE_MASK
]
=
{
0x0C
,
0x00000003
,
0
},
[
ZFA_IRQ_VIC_MASK_STATUS
]
=
{
0x10
,
0x00000003
,
0
},
/* DS18B20 UID/Temperature */
[
ZFA_DS18B20_ID_U
]
=
{
0x00
,
0xFFFFFFFF
,
0
},
[
ZFA_DS18B20_ID_L
]
=
{
0x04
,
0xFFFFFFFF
,
0
},
[
ZFA_DS18B20_TEMP
]
=
{
0x08
,
0x0000FFFF
,
0
},
[
ZFA_DS18B20_STAT
]
=
{
0x0C
,
0x00000003
,
0
},
/* UTC */
[
ZFA_UTC_SECONDS_U
]
=
{
0x00
,
~
0x0
,
0
},
[
ZFA_UTC_SECONDS_L
]
=
{
0x04
,
~
0x0
,
0
},
...
...
kernel/fa-zio-drv.c
View file @
0e644a55
...
...
@@ -150,7 +150,7 @@ static struct zio_attribute zfad_chan_ext_zattr[] = {
};
static
struct
zio_attribute
zfad_dev_ext_zattr
[]
=
{
/* Get Mezzanine temperature from
onewire
*/
/* Get Mezzanine temperature from
the DS18B20 chip
*/
ZIO_PARAM_EXT
(
"temperature"
,
ZIO_RO_PERM
,
ZFA_SW_R_NOADDRES_TEMP
,
0
),
};
...
...
@@ -193,10 +193,13 @@ static int zfad_conf_set(struct device *dev, struct zio_attribute *zattr,
return
0
;
case
ZFA_SW_CH1_OFFSET_ZERO
:
i
--
;
/*fallthrough*/
case
ZFA_SW_CH2_OFFSET_ZERO
:
i
--
;
/*fallthrough*/
case
ZFA_SW_CH3_OFFSET_ZERO
:
i
--
;
/*fallthrough*/
case
ZFA_SW_CH4_OFFSET_ZERO
:
i
--
;
...
...
@@ -223,10 +226,13 @@ static int zfad_conf_set(struct device *dev, struct zio_attribute *zattr,
/* FIXME temporary until TLV control */
case
ZFA_CH1_OFFSET
:
i
--
;
/*fallthrough*/
case
ZFA_CH2_OFFSET
:
i
--
;
/*fallthrough*/
case
ZFA_CH3_OFFSET
:
i
--
;
/*fallthrough*/
case
ZFA_CH4_OFFSET
:
i
--
;
...
...
@@ -252,9 +258,13 @@ static int zfad_conf_set(struct device *dev, struct zio_attribute *zattr,
break
;
/* FIXME temporary until TLV control */
case
ZFA_CH1_CTL_TERM
:
/*fallthrough*/
case
ZFA_CH2_CTL_TERM
:
/*fallthrough*/
case
ZFA_CH3_CTL_TERM
:
/*fallthrough*/
case
ZFA_CH4_CTL_TERM
:
/*fallthrough*/
case
ZFA_CHx_CTL_TERM
:
if
(
usr_val
>
1
)
usr_val
=
1
;
...
...
@@ -263,10 +273,13 @@ static int zfad_conf_set(struct device *dev, struct zio_attribute *zattr,
/* FIXME temporary until TLV control */
case
ZFA_CH1_CTL_RANGE
:
i
--
;
/*fallthrough*/
case
ZFA_CH2_CTL_RANGE
:
i
--
;
/*fallthrough*/
case
ZFA_CH3_CTL_RANGE
:
i
--
;
/*fallthrough*/
case
ZFA_CH4_CTL_RANGE
:
i
--
;
range
=
zfad_convert_user_range
(
usr_val
);
...
...
@@ -336,10 +349,13 @@ static int zfad_info_get(struct device *dev, struct zio_attribute *zattr,
/* FIXME temporary until TLV control */
case
ZFA_CH1_OFFSET
:
i
--
;
/*fallthrough*/
case
ZFA_CH2_OFFSET
:
i
--
;
/*fallthrough*/
case
ZFA_CH3_OFFSET
:
i
--
;
/*fallthrough*/
case
ZFA_CH4_OFFSET
:
i
--
;
*
usr_val
=
fa
->
user_offset
[
i
];
...
...
@@ -349,30 +365,38 @@ static int zfad_info_get(struct device *dev, struct zio_attribute *zattr,
*
usr_val
=
fa
->
user_offset
[
to_zio_chan
(
dev
)
->
index
];
return
0
;
case
ZFAT_ADC_TST_PATTERN
:
/*fallthrough*/
case
ZFA_SW_R_NOADDRES_NBIT
:
/*fallthrough*/
case
ZFA_SW_R_NOADDERS_AUTO
:
/* ZIO automatically return the attribute value */
return
0
;
case
ZFA_SW_R_NOADDRES_TEMP
:
/*
*
Onewire
returns units of 1/16 degree. We return units
*
DS18B20
returns units of 1/16 degree. We return units
* of 1/1000 of a degree instead.
*/
*
usr_val
=
fa_read_temp
(
fa
,
0
);
*
usr_val
=
fa_readl
(
fa
,
fa
->
fa_ow_base
,
&
zfad_regs
[
ZFA_DS18B20_TEMP
]);
*
usr_val
=
(
*
usr_val
*
1000
+
8
)
/
16
;
return
0
;
case
ZFA_SW_CH1_OFFSET_ZERO
:
i
--
;
/*fallthrough*/
case
ZFA_SW_CH2_OFFSET_ZERO
:
i
--
;
/*fallthrough*/
case
ZFA_SW_CH3_OFFSET_ZERO
:
i
--
;
/*fallthrough*/
case
ZFA_SW_CH4_OFFSET_ZERO
:
i
--
;
*
usr_val
=
fa
->
zero_offset
[
i
];
return
0
;
case
ZFA_CHx_SAT
:
/*fallthrough*/
case
ZFA_CHx_CTL_TERM
:
/*fallthrough*/
case
ZFA_CHx_CTL_RANGE
:
reg_index
=
zfad_get_chx_index
(
zattr
->
id
,
to_zio_chan
(
dev
));
break
;
...
...
kernel/fmc-adc-100m14b4cha.h
View file @
0e644a55
...
...
@@ -11,11 +11,10 @@
#include <linux/types.h>
#else
#include <stdint.h>
#endif
#ifndef BIT
#define BIT(nr) (1UL << (nr))
#endif
#endif
/* Trigger sources */
#define FA100M14B4C_TRG_SRC_EXT BIT(0)
...
...
@@ -160,7 +159,7 @@ struct fa_calib {
#include <linux/workqueue.h>
#include <linux/debugfs.h>
#include <linux/platform_device.h>
#include
<linux/fmc.h>
#include
"linux/fmc.h"
#include <linux/zio.h>
#include <linux/zio-dma.h>
...
...
@@ -172,7 +171,7 @@ struct fa_calib {
#define ADC_CSR_OFF 0x1000
#define ADC_EIC_OFF 0x1500
#define ADC_OW_OFF 0x1700
#define ADC_OW_OFF
0x1700
#define ADC_SPI_OFF 0x1800
#define ADC_UTC_OFF 0x1900
...
...
@@ -317,6 +316,11 @@ enum zfadc_dregs_enum {
ZFA_IRQ_VIC_DISABLE_MASK
,
ZFA_IRQ_VIC_ENABLE_MASK
,
ZFA_IRQ_VIC_MASK_STATUS
,
/* DS18B20 UID/Temperature */
ZFA_DS18B20_ID_U
,
ZFA_DS18B20_ID_L
,
ZFA_DS18B20_TEMP
,
ZFA_DS18B20_STAT
,
/* UTC core */
ZFA_UTC_SECONDS_U
,
ZFA_UTC_SECONDS_L
,
...
...
@@ -402,7 +406,7 @@ struct fa_dev {
struct
fmc_slot
*
slot
;
struct
fa_memory_ops
memops
;
/* carrier common base offset addresses
obtained from SDB
*/
/* carrier common base offset addresses */
void
*
fa_adc_csr_base
;
void
*
fa_spi_base
;
void
*
fa_ow_base
;
...
...
@@ -576,7 +580,7 @@ extern struct bin_attribute dev_attr_calibration;
/* Global variable exported by fa-core.c */
extern
struct
workqueue_struct
*
fa_workqueue
;
/* Global variable exported by fa-reg
field
.c */
/* Global variable exported by fa-reg
table
.c */
extern
const
struct
zfa_field_desc
zfad_regs
[];
/* Functions exported by fa-core.c */
...
...
@@ -611,11 +615,6 @@ extern int fa_free_irqs(struct fa_dev *fa);
extern
int
fa_enable_irqs
(
struct
fa_dev
*
fa
);
extern
int
fa_disable_irqs
(
struct
fa_dev
*
fa
);
/* Functions exported by onewire.c */
extern
int
fa_onewire_init
(
struct
fa_dev
*
fa
);
extern
void
fa_onewire_exit
(
struct
fa_dev
*
fa
);
extern
int
fa_read_temp
(
struct
fa_dev
*
fa
,
int
verbose
);
/* functions exported by spi.c */
extern
int
fa_spi_xfer
(
struct
fa_dev
*
fa
,
int
cs
,
int
num_bits
,
uint32_t
tx
,
uint32_t
*
rx
);
...
...
kernel/onewire.c
deleted
100644 → 0
View file @
35650ac5
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Access to 1w thermometer
*
* Copyright (C) 2012 CERN (www.cern.ch)
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
* Author: Alessandro Rubini <rubini@gnudd.com>
*
* Copied from the fine-delay driver and updated with fmc-adc variable
*/
#include <linux/jiffies.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/delay.h>
#include "fmc-adc-100m14b4cha.h"
#define R_CSR 0x0
#define R_CDR 0x4
#define CSR_DAT_MSK (1<<0)
#define CSR_RST_MSK (1<<1)
#define CSR_OVD_MSK (1<<2)
#define CSR_CYC_MSK (1<<3)
#define CSR_PWR_MSK (1<<4)
#define CSR_IRQ_MSK (1<<6)
#define CSR_IEN_MSK (1<<7)
#define CSR_SEL_OFS 8
#define CSR_SEL_MSK (0xF<<8)
#define CSR_POWER_OFS 16
#define CSR_POWER_MSK (0xFFFF<<16)
#define CDR_NOR_MSK (0xFFFF<<0)
#define CDR_OVD_OFS 16
#define CDR_OVD_MSK (0xFFFF<<16)
#define CLK_DIV_NOR (624)
#define CLK_DIV_OVD (124)
#define CMD_ROM_SEARCH 0xF0
#define CMD_ROM_READ 0x33
#define CMD_ROM_MATCH 0x55
#define CMD_ROM_SKIP 0xCC
#define CMD_ROM_ALARM_SEARCH 0xEC
#define CMD_CONVERT_TEMP 0x44
#define CMD_WRITE_SCRATCHPAD 0x4E
#define CMD_READ_SCRATCHPAD 0xBE
#define CMD_COPY_SCRATCHPAD 0x48
#define CMD_RECALL_EEPROM 0xB8
#define CMD_READ_POWER_SUPPLY 0xB4
#define FA_OW_PORT 0
/* what is this slow? */
static
void
ow_writel
(
struct
fa_dev
*
fa
,
uint32_t
val
,
unsigned
long
reg
)
{
fa_iowrite
(
fa
,
val
,
fa
->
fa_ow_base
+
reg
);
}
static
uint32_t
ow_readl
(
struct
fa_dev
*
fa
,
unsigned
long
reg
)
{
return
fa_ioread
(
fa
,
fa
->
fa_ow_base
+
reg
);
}
static
int
ow_reset
(
struct
fa_dev
*
fa
,
int
port
)
{
uint32_t
reg
,
data
;
data
=
((
port
<<
CSR_SEL_OFS
)
&
CSR_SEL_MSK
)
|
CSR_CYC_MSK
|
CSR_RST_MSK
;
ow_writel
(
fa
,
data
,
R_CSR
);
while
(
ow_readl
(
fa
,
R_CSR
)
&
CSR_CYC_MSK
)
/* FIXME: timeout */
;
reg
=
ow_readl
(
fa
,
R_CSR
);
return
~
reg
&
CSR_DAT_MSK
;
}
static
int
slot
(
struct
fa_dev
*
fa
,
int
port
,
int
bit
)
{
uint32_t
reg
,
data
;
data
=
((
port
<<
CSR_SEL_OFS
)
&
CSR_SEL_MSK
)
|
CSR_CYC_MSK
|
(
bit
&
CSR_DAT_MSK
);
ow_writel
(
fa
,
data
,
R_CSR
);
while
(
ow_readl
(
fa
,
R_CSR
)
&
CSR_CYC_MSK
)
/* FIXME: timeout */
;
reg
=
ow_readl
(
fa
,
R_CSR
);
return
reg
&
CSR_DAT_MSK
;
}
static
int
read_bit
(
struct
fa_dev
*
fa
,
int
port
)
{
return
slot
(
fa
,
port
,
0x1
);
}
static
int
write_bit
(
struct
fa_dev
*
fa
,
int
port
,
int
bit
)
{
return
slot
(
fa
,
port
,
bit
);
}
static
int
ow_read_byte
(
struct
fa_dev
*
fa
,
int
port
)
{
int
byte
=
0
,
i
;
for
(
i
=
0
;
i
<
8
;
i
++
)
byte
|=
(
read_bit
(
fa
,
port
)
<<
i
);
return
byte
;
}
static
int
ow_write_byte
(
struct
fa_dev
*
fa
,
int
port
,
int
byte
)
{
int
data
=
0
;
int
i
;
for
(
i
=
0
;
i
<
8
;
i
++
)
{
data
|=
write_bit
(
fa
,
port
,
(
byte
&
0x1
))
<<
i
;
byte
>>=
1
;
}
return
0
;
/* success */
}
static
int
ow_write_block
(
struct
fa_dev
*
fa
,
int
port
,
uint8_t
*
block
,
int
len
)
{
int
i
;
for
(
i
=
0
;
i
<
len
;
i
++
)
ow_write_byte
(
fa
,
port
,
block
[
i
]);
return
0
;
}
static
int
ow_read_block
(
struct
fa_dev
*
fa
,
int
port
,
uint8_t
*
block
,
int
len
)
{
int
i
;
for
(
i
=
0
;
i
<
len
;
i
++
)
block
[
i
]
=
ow_read_byte
(
fa
,
port
);
return
0
;
}
static
int
ds18x_read_serial
(
struct
fa_dev
*
fa
)
{
if
(
!
ow_reset
(
fa
,
0
))
{
pr_err
(
"%s: Failure in resetting one-wire channel
\n
"
,
KBUILD_MODNAME
);
return
-
EIO
;
}
ow_write_byte
(
fa
,
FA_OW_PORT
,
CMD_ROM_READ
);
return
ow_read_block
(
fa
,
FA_OW_PORT
,
fa
->
ds18_id
,
8
);
}
static
int
ds18x_access
(
struct
fa_dev
*
fa
)
{
if
(
!
ow_reset
(
fa
,
0
))
goto
out
;
if
(
0
)
{
/* select the rom among several of them */
if
(
ow_write_byte
(
fa
,
FA_OW_PORT
,
CMD_ROM_MATCH
)
<
0
)
goto
out
;
return
ow_write_block
(
fa
,
FA_OW_PORT
,
fa
->
ds18_id
,
8
);
}
else
{
/* we have one only, so skip rom */
return
ow_write_byte
(
fa
,
FA_OW_PORT
,
CMD_ROM_SKIP
);
}
out:
pr_err
(
"%s: Failure in one-wire communication
\n
"
,
KBUILD_MODNAME
);
return
-
EIO
;
}
static
void
__temp_command_and_next_t
(
struct
fa_dev
*
fa
,
int
cfg_reg
)
{
int
ms
;
ds18x_access
(
fa
);
ow_write_byte
(
fa
,
FA_OW_PORT
,
CMD_CONVERT_TEMP
);
/* The conversion takes some time, so mark when will it be ready */
ms
=
94
*
(
1
<<
(
cfg_reg
>>
5
));
fa
->
next_t
=
jiffies
+
msecs_to_jiffies
(
ms
);
}
int
fa_read_temp
(
struct
fa_dev
*
fa
,
int
verbose
)
{
int
i
,
temp
;
unsigned
long
j
;
uint8_t
data
[
9
];
/* If first conversion, ask for it first */
if
(
fa
->
next_t
==
0
)
__temp_command_and_next_t
(
fa
,
0x7f
/* we ignore: max time */
);
/* Wait for it to be ready: (FIXME: we need a time policy here) */
j
=
jiffies
;
if
(
time_before
(
j
,
fa
->
next_t
))
{
/* If we cannot sleep, return the previous value */
if
(
in_atomic
())
return
fa
->
temp
;
msleep
(
jiffies_to_msecs
(
fa
->
next_t
-
j
));
}
ds18x_access
(
fa
);
ow_write_byte
(
fa
,
FA_OW_PORT
,
CMD_READ_SCRATCHPAD
);
ow_read_block
(
fa
,
FA_OW_PORT
,
data
,
9
);
if
(
verbose
>
1
)
{
pr_info
(
"%s: Scratchpad: "
,
__func__
);
for
(
i
=
0
;
i
<
9
;
i
++
)
printk
(
KERN_CONT
"%02x%c"
,
data
[
i
],
i
==
8
?
'\n'
:
':'
);
}
temp
=
((
int
)
data
[
1
]
<<
8
)
|
((
int
)
data
[
0
]);
if
(
temp
&
0x1000
)
temp
=
-
0x10000
+
temp
;
fa
->
temp
=
temp
;
if
(
verbose
)
{
pr_info
(
"%s: Temperature 0x%x (%i bits: %i.%03i)
\n
"
,
__func__
,
temp
,
9
+
(
data
[
4
]
>>
5
),
temp
/
16
,
(
temp
&
0xf
)
*
1000
/
16
);
}
__temp_command_and_next_t
(
fa
,
data
[
4
]);
/* start next conversion */
return
temp
;
}
int
fa_onewire_init
(
struct
fa_dev
*
fa
)
{
ow_writel
(
fa
,
((
CLK_DIV_NOR
&
CDR_NOR_MSK
)
|
((
CLK_DIV_OVD
<<
CDR_OVD_OFS
)
&
CDR_OVD_MSK
)),
R_CDR
);
if
(
ds18x_read_serial
(
fa
)
<
0
)
return
-
EIO
;
return
0
;
}
void
fa_onewire_exit
(
struct
fa_dev
*
fa
)
{
/* Nothing to do */
}
tools/fau-calibration.c
View file @
0e644a55
...
...
@@ -18,7 +18,6 @@
#include <fmc-adc-100m14b4cha.h>
static
const
char
program_name
[]
=
"fau-calibration"
;
static
char
options
[]
=
"hf:o:D:b"
;
static
const
char
help_msg
[]
=
"Usage: fau-calibration [options]
\n
"
...
...
@@ -117,9 +116,9 @@ static void fau_calibration_dump_human(struct fa_calib *calib)
* Print binary calibration data on stdout
* @calib: calibration data
*/
static
void
fau_calibration_dump_machine
(
struct
fa_calib
*
calib
)
static
int
fau_calibration_dump_machine
(
struct
fa_calib
*
calib
)
{
write
(
fileno
(
stdout
),
calib
,
sizeof
(
*
calib
));
return
write
(
fileno
(
stdout
),
calib
,
sizeof
(
*
calib
));
}
/**
...
...
tools/fau-trg-config.c
View file @
0e644a55
...
...
@@ -53,7 +53,7 @@ const char *attribute[] = {
/* Write a sysfs attribute */
int
fau_write_attribute
(
enum
fau_attribute
attr
,
uint32_t
val
)
{
int
fd
;
int
ret
,
fd
;
char
buf
[
buf_len
],
fullpath
[
200
];
/* convert val to string */
...
...
@@ -66,9 +66,9 @@ int fau_write_attribute(enum fau_attribute attr, uint32_t val)
fd
=
open
(
fullpath
,
O_WRONLY
);
if
(
fd
<
0
)
return
-
ENOENT
;
write
(
fd
,
buf
,
strlen
(
buf
));
ret
=
write
(
fd
,
buf
,
strlen
(
buf
));
close
(
fd
);
return
0
;
return
ret
;
}
static
void
fau_help
()
...
...
tools/parport-burst.c
View file @
0e644a55
...
...
@@ -41,7 +41,7 @@ static void print_version(char *pname)
int
main
(
int
argc
,
char
**
argv
)
{
int
fd
,
addr
,
count
,
usec
;
int
fd
,
addr
,
count
,
usec
,
ret
;
int64_t
tics
;
if
((
argc
==
2
)
&&
...
...
@@ -83,15 +83,15 @@ int main(int argc, char **argv)
char
b
[]
=
{
0x00
,
0xff
};
lseek
(
fd
,
addr
,
SEEK_SET
);
write
(
fd
,
b
+
1
,
1
);
ret
=
write
(
fd
,
b
+
1
,
1
);
lseek
(
fd
,
addr
,
SEEK_SET
);
write
(
fd
,
b
+
0
,
1
);
ret
=
write
(
fd
,
b
+
0
,
1
);
if
(
count
>
1
)
{
tics
+=
usec
;
delay_to
(
tics
);
}
}
while
(
--
count
);
return
0
;
return
ret
;
}
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