blob: f7ec2d9139d63f5dcf87f714665d8cde2c643452 [file] [log] [blame]
Gabriel FERNANDEZb9b8e612014-02-27 16:24:15 +01001/************************************************************************
2File : Clock H/w specific Information
3
4Author: Pankaj Dev <pankaj.dev@st.com>
5
6Copyright (C) 2014 STMicroelectronics
7************************************************************************/
8
9#ifndef __CLKGEN_INFO_H
10#define __CLKGEN_INFO_H
11
Gabriel Fernandez46a57af2015-10-07 11:08:57 +020012extern spinlock_t clkgen_a9_lock;
13
Gabriel FERNANDEZb9b8e612014-02-27 16:24:15 +010014struct clkgen_field {
15 unsigned int offset;
16 unsigned int mask;
17 unsigned int shift;
18};
19
20static inline unsigned long clkgen_read(void __iomem *base,
21 struct clkgen_field *field)
22{
23 return (readl(base + field->offset) >> field->shift) & field->mask;
24}
25
26
27static inline void clkgen_write(void __iomem *base, struct clkgen_field *field,
28 unsigned long val)
29{
30 writel((readl(base + field->offset) &
31 ~(field->mask << field->shift)) | (val << field->shift),
32 base + field->offset);
33
34 return;
35}
36
37#define CLKGEN_FIELD(_offset, _mask, _shift) { \
38 .offset = _offset, \
39 .mask = _mask, \
40 .shift = _shift, \
41 }
42
43#define CLKGEN_READ(pll, field) clkgen_read(pll->regs_base, \
44 &pll->data->field)
45
46#define CLKGEN_WRITE(pll, field, val) clkgen_write(pll->regs_base, \
47 &pll->data->field, val)
48
49#endif /*__CLKGEN_INFO_H*/
50