2 * ddbridge-io.h: Digital Devices bridge I/O inline functions
4 * Copyright (C) 2010-2017 Digital Devices GmbH
5 * Ralph Metzler <rjkm@metzlerbros.de>
6 * Marcus Metzler <mocm@metzlerbros.de>
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 only, as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
19 #ifndef __DDBRIDGE_IO_H__
20 #define __DDBRIDGE_IO_H__
26 /******************************************************************************/
28 static inline u32
ddblreadl(struct ddb_link
*link
, u32 adr
)
30 return readl(link
->dev
->regs
+ adr
);
33 static inline void ddblwritel(struct ddb_link
*link
, u32 val
, u32 adr
)
35 writel(val
, link
->dev
->regs
+ adr
);
38 static inline u32
ddbreadl(struct ddb
*dev
, u32 adr
)
40 return readl(dev
->regs
+ adr
);
43 static inline void ddbwritel(struct ddb
*dev
, u32 val
, u32 adr
)
45 writel(val
, dev
->regs
+ adr
);
48 static inline void ddbcpyto(struct ddb
*dev
, u32 adr
, void *src
, long count
)
50 memcpy_toio(dev
->regs
+ adr
, src
, count
);
53 static inline void ddbcpyfrom(struct ddb
*dev
, void *dst
, u32 adr
, long count
)
55 memcpy_fromio(dst
, dev
->regs
+ adr
, count
);
58 static inline u32
safe_ddbreadl(struct ddb
*dev
, u32 adr
)
60 u32 val
= ddbreadl(dev
, adr
);
62 /* (ddb)readl returns (uint)-1 (all bits set) on failure, catch that */
64 dev_err(&dev
->pdev
->dev
, "ddbreadl failure, adr=%08x\n", adr
);
71 #endif /* __DDBRIDGE_IO_H__ */