11 #include <linux/kernel.h>
15 #include <linux/module.h>
16 #include <linux/time.h>
22 #define TA(x) ((x) << 2)
23 #define RHOLD(x) ((x) << 4)
24 #define RSTROBE(x) ((x) << 7)
25 #define RSETUP(x) ((x) << 13)
26 #define WHOLD(x) ((x) << 17)
27 #define WSTROBE(x) ((x) << 20)
28 #define WSETUP(x) ((x) << 26)
32 #define RSTROBE_MAX 0x3f
33 #define RSETUP_MAX 0xf
35 #define WSTROBE_MAX 0x3f
36 #define WSETUP_MAX 0xf
38 #define TIMING_MASK (TA(TA_MAX) | \
40 RSTROBE(RSTROBE_MAX) | \
41 RSETUP(RSETUP_MAX) | \
43 WSTROBE(WSTROBE_MAX) | \
55 static int aemif_calc_rate(
int wanted,
unsigned long clk,
int max)
61 pr_debug(
"%s: result %d from %ld, %d\n", __func__, result, clk, wanted);
68 else if (result > max)
93 int ta, rhold, rstrobe, rsetup, whold, wstrobe, wsetup;
95 struct clk *aemif_clk;
96 unsigned long clkrate;
102 if (IS_ERR(aemif_clk))
103 return PTR_ERR(aemif_clk);
109 ta = aemif_calc_rate(t->
ta, clkrate,
TA_MAX);
117 if (ta < 0 || rhold < 0 || rstrobe < 0 || rsetup < 0 ||
118 whold < 0 || wstrobe < 0 || wsetup < 0) {
119 pr_err(
"%s: cannot get suitable timings\n", __func__);