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

drv: WIP

parent addaddae
......@@ -72,6 +72,17 @@ 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 (unlikely(len > 64)) {
*dlc = 0;
return false;
} else {
*dlc = can_len2dlc(len);
if (unlikely(*dlc == can_len2dlc(len-1))) {
*dlc = 0;
return false;
}
}
/*
if (len <= 8){
*dlc = len;
goto exit_ok;
......@@ -98,6 +109,7 @@ static bool ctu_can_fd_len_to_dlc(u8 len, u8 *dlc)
if (*dlc == 0)
return false;
exit_ok:
*/
return true;
}
......@@ -198,6 +210,8 @@ void ctu_can_fd_abort_tx(struct ctucanfd_priv *priv)
ctu_can_fd_write32(priv, CTU_CAN_FD_MODE, reg.u32);
}
// TODO: rather than set(value, mask) interface, provide native set(val), clr(val)
// interface to potentially avoid unnecessary write
static void ctu_can_fd_int_conf(struct ctucanfd_priv *priv, enum ctu_can_fd_regs sreg,
enum ctu_can_fd_regs creg,
union ctu_can_fd_int_stat mask,
......
......@@ -124,6 +124,8 @@
struct ctucanfd_priv {
void __iomem *mem_base;
u32 (*read_reg)(struct ctucanfd_priv *priv, enum ctu_can_fd_regs reg);
void (*write_reg)(struct ctucanfd_priv *priv, enum ctu_can_fd_regs reg, u32 val);
};
static inline void ctu_can_fd_write32(struct ctucanfd_priv *priv, enum ctu_can_fd_regs reg,
......
......@@ -98,12 +98,18 @@ typedef __u16 __bitwise __sum16;
typedef __u32 __bitwise __wsum;
*/
__attribute__((noinline))
static inline void iowrite32(u32 value, void *addr) {*(volatile u32*)addr = value;}
__attribute__((noinline))
static inline void iowrite16(u16 value, void *addr) {*(volatile u16*)addr = value;}
__attribute__((noinline))
static inline void iowrite8(u8 value, void *addr) {*(volatile u8*)addr = value;}
__attribute__((noinline))
static inline u32 ioread32(const void *addr) {return *(const volatile u32*)addr;}
__attribute__((noinline))
static inline u16 ioread16(const void *addr) {return *(const volatile u16*)addr;}
__attribute__((noinline))
static inline u8 ioread8(const void *addr) {return *(const volatile u8*)addr;}
/* CAN DLC to real data length conversion helpers */
......
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