Commit 0d7ead12 authored by Martin Jeřábek's avatar Martin Jeřábek Committed by Martin Jeřábek

driver: add/remove static/inline, move some functions to header

parent ccada871
......@@ -37,42 +37,42 @@
#include "ctu_can_fd_hw.h"
inline void ctu_can_fd_write32(void *base, enum ctu_can_fd_regs reg,
u32 val)
static inline void ctu_can_fd_write32(void *base, enum ctu_can_fd_regs reg,
u32 val)
{
iowrite32(val, (char *)base + reg);
}
inline void ctu_can_fd_write16(void *base, enum ctu_can_fd_regs reg,
u16 val)
static inline void ctu_can_fd_write16(void *base, enum ctu_can_fd_regs reg,
u16 val)
{
iowrite16(val, (char *)base + reg);
}
inline void ctu_can_fd_write8(void *base, enum ctu_can_fd_regs reg,
u8 val)
static inline void ctu_can_fd_write8(void *base, enum ctu_can_fd_regs reg,
u8 val)
{
iowrite8(val, (char *)base + reg);
}
inline void ctu_can_fd_write_txt_buf(void *base,
enum ctu_can_fd_regs buf_base,
u32 offset, u32 val)
static inline void ctu_can_fd_write_txt_buf(void *base,
enum ctu_can_fd_regs buf_base,
u32 offset, u32 val)
{
iowrite32(val, (char *)base + buf_base + offset);
}
inline u32 ctu_can_fd_read32(const void *base, enum ctu_can_fd_regs reg)
static inline u32 ctu_can_fd_read32(const void *base, enum ctu_can_fd_regs reg)
{
return ioread32((const char *)base + reg);
}
inline u16 ctu_can_fd_read16(const void *base, enum ctu_can_fd_regs reg)
static inline u16 ctu_can_fd_read16(const void *base, enum ctu_can_fd_regs reg)
{
return ioread16((const char *)base + reg);
}
inline u8 ctu_can_fd_read8(const void *base, enum ctu_can_fd_regs reg)
static inline u8 ctu_can_fd_read8(const void *base, enum ctu_can_fd_regs reg)
{
return ioread8((const char *)base + reg);
}
......@@ -109,6 +109,7 @@ static inline void ctu_can_fd_hwid_to_id(union ctu_can_fd_identifier_w hwid,
}
// TODO: use can_len2dlc
static bool ctu_can_fd_len_to_dlc(u8 len, u8 *dlc)
{
if (len <= 8){
......@@ -265,8 +266,8 @@ static void ctu_can_fd_int_conf(void *base, enum ctu_can_fd_regs sreg,
const union ctu_can_fd_int_stat *mask,
const union ctu_can_fd_int_stat *val)
{
union ctu_can_fd_int_stat reg;
reg.u32 = ctu_can_fd_read32(base, sreg);
//union ctu_can_fd_int_stat reg;
//reg.u32 = ctu_can_fd_read32(base, sreg);
ctu_can_fd_write32(base, sreg, mask->u32 & val->u32);
ctu_can_fd_write32(base, creg, mask->u32 & (~val->u32));
......@@ -302,7 +303,7 @@ void ctu_can_fd_set_mode(void *base, const struct can_ctrlmode *mode)
}
static const struct can_bittiming_const ctu_can_fd_bit_timing_max = {
const struct can_bittiming_const ctu_can_fd_bit_timing_max = {
.name = "ctu_can_fd",
.tseg1_min = 2,
.tseg1_max = 190,
......@@ -314,7 +315,7 @@ static const struct can_bittiming_const ctu_can_fd_bit_timing_max = {
.brp_inc = 1,
};
static const struct can_bittiming_const ctu_can_fd_bit_timing_data_max = {
const struct can_bittiming_const ctu_can_fd_bit_timing_data_max = {
.name = "ctu_can_fd",
.tseg1_min = 2,
.tseg1_max = 94,
......@@ -681,7 +682,7 @@ bool ctu_can_fd_is_txt_buf_accessible(const void *base, u8 buf)
return true;
}
static bool ctu_can_fd_txt_buf_give_command(void *base, u8 cmd, u8 buf)
bool ctu_can_fd_txt_buf_give_command(void *base, u8 cmd, u8 buf)
{
union ctu_can_fd_tx_command reg;
reg.u32 = 0;
......@@ -715,21 +716,6 @@ static bool ctu_can_fd_txt_buf_give_command(void *base, u8 cmd, u8 buf)
return true;
}
inline void ctu_can_fd_txt_set_empty(void *base, u8 buf)
{
ctu_can_fd_txt_buf_give_command(base, 0x1, buf);
}
inline void ctu_can_fd_txt_set_rdy(void *base, u8 buf)
{
ctu_can_fd_txt_buf_give_command(base, 0x2, buf);
}
inline void ctu_can_fd_txt_set_abort(void *base, u8 buf)
{
ctu_can_fd_txt_buf_give_command(base, 0x4, buf);
}
void ctu_can_fd_set_txt_priority(void *base, const u8 *prio)
{
union ctu_can_fd_tx_priority reg;
......
......@@ -581,7 +581,7 @@ bool ctu_can_fd_is_txt_buf_accessible(const void *base, u8 buf);
* Returns:
* Status of the TXT Buffer.
*/
static bool ctu_can_fd_txt_buf_give_command(void *base, u8 cmd, u8 buf);
bool ctu_can_fd_txt_buf_give_command(void *base, u8 cmd, u8 buf);
/*
......@@ -593,7 +593,10 @@ static bool ctu_can_fd_txt_buf_give_command(void *base, u8 cmd, u8 buf);
* Returns:
* Status of the TXT Buffer.
*/
inline void ctu_can_fd_txt_set_empty(void *base, u8 buf);
static inline void ctu_can_fd_txt_set_empty(void *base, u8 buf)
{
ctu_can_fd_txt_buf_give_command(base, 0x1, buf);
}
/*
......@@ -605,7 +608,10 @@ inline void ctu_can_fd_txt_set_empty(void *base, u8 buf);
* Returns:
* Status of the TXT Buffer.
*/
inline void ctu_can_fd_txt_set_rdy(void *base, u8 buf);
static inline void ctu_can_fd_txt_set_rdy(void *base, u8 buf)
{
ctu_can_fd_txt_buf_give_command(base, 0x2, buf);
}
/*
......@@ -617,7 +623,10 @@ inline void ctu_can_fd_txt_set_rdy(void *base, u8 buf);
* Returns:
* Status of the TXT Buffer.
*/
inline void ctu_can_fd_txt_set_abort(void *base, u8 buf);
static inline void ctu_can_fd_txt_set_abort(void *base, u8 buf)
{
ctu_can_fd_txt_buf_give_command(base, 0x4, buf);
}
/*
......@@ -690,4 +699,7 @@ u32 ctu_can_fd_get_rx_frame_ctr(const void *base);
*/
union ctu_can_fd_debug_register ctu_can_fd_read_debug_info(const void *base);
extern const struct can_bittiming_const ctu_can_fd_bit_timing_max;
extern const struct can_bittiming_const ctu_can_fd_bit_timing_data_max;
#endif
#include "ctu_can_fd_linux_defs.h"
/* CAN DLC to real data length conversion helpers */
static const u8 dlc2len[] = {0, 1, 2, 3, 4, 5, 6, 7,
8, 12, 16, 20, 24, 32, 48, 64};
/* get data length from can_dlc with sanitized can_dlc */
u8 can_dlc2len(u8 can_dlc)
{
return dlc2len[can_dlc & 0x0F];
}
static const u8 len2dlc[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, /* 0 - 8 */
9, 9, 9, 9, /* 9 - 12 */
10, 10, 10, 10, /* 13 - 16 */
11, 11, 11, 11, /* 17 - 20 */
12, 12, 12, 12, /* 21 - 24 */
13, 13, 13, 13, 13, 13, 13, 13, /* 25 - 32 */
14, 14, 14, 14, 14, 14, 14, 14, /* 33 - 40 */
14, 14, 14, 14, 14, 14, 14, 14, /* 41 - 48 */
15, 15, 15, 15, 15, 15, 15, 15, /* 49 - 56 */
15, 15, 15, 15, 15, 15, 15, 15}; /* 57 - 64 */
/* map the sanitized data length to an appropriate data length code */
u8 can_len2dlc(u8 len)
{
if (unlikely(len > 64))
return 0xF;
return len2dlc[len];
}
......@@ -105,6 +105,10 @@ static inline u32 ioread32(const void *addr) {return *(const volatile u32*)addr;
static inline u16 ioread16(const void *addr) {return *(const volatile u16*)addr;}
static inline u8 ioread8(const void *addr) {return *(const volatile u8*)addr;}
/* CAN DLC to real data length conversion helpers */
u8 can_dlc2len(u8 can_dlc);
u8 can_len2dlc(u8 len);
/*
* CAN bit-timing parameters
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment