16 #include <linux/module.h>
17 #include <linux/kernel.h>
23 #define MFPR_SIZE (PAGE_SIZE)
26 #define MFPR_PULL_SEL (0x1 << 15)
27 #define MFPR_PULLUP_EN (0x1 << 14)
28 #define MFPR_PULLDOWN_EN (0x1 << 13)
29 #define MFPR_SLEEP_SEL (0x1 << 9)
30 #define MFPR_SLEEP_OE_N (0x1 << 7)
31 #define MFPR_EDGE_CLEAR (0x1 << 6)
32 #define MFPR_EDGE_FALL_EN (0x1 << 5)
33 #define MFPR_EDGE_RISE_EN (0x1 << 4)
35 #define MFPR_SLEEP_DATA(x) ((x) << 8)
36 #define MFPR_DRIVE(x) (((x) & 0x7) << 10)
37 #define MFPR_AF_SEL(x) (((x) & 0x7) << 0)
39 #define MFPR_EDGE_NONE (0)
40 #define MFPR_EDGE_RISE (MFPR_EDGE_RISE_EN)
41 #define MFPR_EDGE_FALL (MFPR_EDGE_FALL_EN)
42 #define MFPR_EDGE_BOTH (MFPR_EDGE_RISE | MFPR_EDGE_FALL)
60 #define MFPR_LPM_INPUT (0)
61 #define MFPR_LPM_DRIVE_LOW (MFPR_SLEEP_DATA(0) | MFPR_PULLDOWN_EN)
62 #define MFPR_LPM_DRIVE_HIGH (MFPR_SLEEP_DATA(1) | MFPR_PULLUP_EN)
63 #define MFPR_LPM_PULL_LOW (MFPR_LPM_DRIVE_LOW | MFPR_SLEEP_OE_N)
64 #define MFPR_LPM_PULL_HIGH (MFPR_LPM_DRIVE_HIGH | MFPR_SLEEP_OE_N)
65 #define MFPR_LPM_FLOAT (MFPR_SLEEP_OE_N)
66 #define MFPR_LPM_MASK (0xe080)
81 #define MFPR_PULL_NONE (0)
82 #define MFPR_PULL_LOW (MFPR_PULL_SEL | MFPR_PULLDOWN_EN)
83 #define MFPR_PULL_BOTH (MFPR_PULL_LOW | MFPR_PULLUP_EN)
84 #define MFPR_PULL_HIGH (MFPR_PULL_SEL | MFPR_PULLUP_EN)
85 #define MFPR_PULL_FLOAT (MFPR_PULL_SEL)
93 static void __iomem *mfpr_mmio_base;
105 static const unsigned long mfpr_lpm[] = {
116 static const unsigned long mfpr_pull[] = {
125 static const unsigned long mfpr_edge[] = {
132 #define mfpr_readl(off) \
133 __raw_readl(mfpr_mmio_base + (off))
135 #define mfpr_writel(off, val) \
136 __raw_writel(val, mfpr_mmio_base + (off))
138 #define mfp_configured(p) ((p)->config != -1)
144 static unsigned long mfpr_off_readback;
145 #define mfpr_sync() (void)__raw_readl(mfpr_mmio_base + mfpr_off_readback)
147 static inline void __mfp_config_run(
struct mfp_pin *
p)
153 static inline void __mfp_config_lpm(
struct mfp_pin *
p)
171 for (i = 0; i < num; i++, mfp_cfgs++) {
172 unsigned long tmp,
c = *mfp_cfgs;
200 p->
config =
c; __mfp_config_run(p);
204 spin_unlock_irqrestore(&mfp_spin_lock, flags);
215 spin_unlock_irqrestore(&mfp_spin_lock, flags);
229 spin_unlock_irqrestore(&mfp_spin_lock, flags);
240 mfpr_mmio_base = mfpr_base;
245 struct mfp_addr_map *
p;
252 mfpr_off_readback = map[0].offset;
259 mfp_table[
i].mfpr_off =
offset;
260 mfp_table[
i].mfpr_run = 0;
261 mfp_table[
i].mfpr_lpm = 0;
263 }
while ((i <= p->
end) && (p->end != -1));
266 spin_unlock_irqrestore(&mfp_spin_lock, flags);
271 struct mfp_pin *p = &mfp_table[0];
274 for (pin = 0; pin <
ARRAY_SIZE(mfp_table); pin++, p++)
280 struct mfp_pin *p = &mfp_table[0];
283 for (pin = 0; pin <
ARRAY_SIZE(mfp_table); pin++, p++)