Commit 2534af5d authored by Alejandro Mery's avatar Alejandro Mery
Browse files

fexc: change uboot output to generate a .c

parent 987a169b
...@@ -32,11 +32,10 @@ ...@@ -32,11 +32,10 @@
#define pr_debug(...) #define pr_debug(...)
#endif #endif
static inline void out_dram_member(FILE *out, const char *key, uint32_t val) static inline void out_u32_member(FILE *out, const char *key, int hexa, uint32_t val)
{ {
const char *fmt; const char *fmt;
if (strncmp(key, "tpr", 3) == 0 || if (hexa)
strncmp(key, "emr", 3) == 0)
fmt = "\t.%s = %#x,\n"; fmt = "\t.%s = %#x,\n";
else else
fmt = "\t.%s = %u,\n"; fmt = "\t.%s = %u,\n";
...@@ -44,15 +43,18 @@ static inline void out_dram_member(FILE *out, const char *key, uint32_t val) ...@@ -44,15 +43,18 @@ static inline void out_dram_member(FILE *out, const char *key, uint32_t val)
fprintf(out, fmt, key, val); fprintf(out, fmt, key, val);
} }
/*
* DRAM
*/
static int generate_dram_struct(FILE *out, struct script_section *sp) static int generate_dram_struct(FILE *out, struct script_section *sp)
{ {
struct list_entry *le; struct list_entry *le;
struct script_entry *ep; struct script_entry *ep;
struct script_single_entry *val; struct script_single_entry *val;
const char *key; const char *key;
int ret = 1; int ret = 1, hexa;
fprintf(out, "struct dram_para para = {\n"); fprintf(out, "static struct dram_para dram_para = {\n");
for (le = list_first(&sp->entries); le; for (le = list_first(&sp->entries); le;
le = list_next(&sp->entries, le)) { le = list_next(&sp->entries, le)) {
ep = container_of(le, struct script_entry, entries); ep = container_of(le, struct script_entry, entries);
...@@ -68,11 +70,17 @@ static int generate_dram_struct(FILE *out, struct script_section *sp) ...@@ -68,11 +70,17 @@ static int generate_dram_struct(FILE *out, struct script_section *sp)
else if (strcmp(key, "clk") == 0) else if (strcmp(key, "clk") == 0)
key = "clock"; key = "clock";
if (strncmp(key, "tpr", 3) == 0 ||
strncmp(key, "emr", 3) == 0)
hexa = 1;
else
hexa = 0;
switch (ep->type) { switch (ep->type) {
case SCRIPT_VALUE_TYPE_SINGLE_WORD: case SCRIPT_VALUE_TYPE_SINGLE_WORD:
val = container_of(ep, struct script_single_entry, entry); val = container_of(ep, struct script_single_entry, entry);
if (val->value > 0) if (val->value > 0)
out_dram_member(out, key, val->value); out_u32_member(out, key, hexa, val->value);
/* pass through */ /* pass through */
case SCRIPT_VALUE_TYPE_NULL: case SCRIPT_VALUE_TYPE_NULL:
continue; continue;
...@@ -93,7 +101,10 @@ int script_generate_uboot(FILE *out, const char *UNUSED(filename), ...@@ -93,7 +101,10 @@ int script_generate_uboot(FILE *out, const char *UNUSED(filename),
struct script_section *section; struct script_section *section;
const char *section_name; const char *section_name;
fprintf(out, "/* this file is generated, don't edit it yourself */\n\n"); fputs("/* this file is generated, don't edit it yourself */\n\n"
"#include <common.h>\n"
"#include <asm/arch/dram.h>\n\n",
out);
section_name = "dram_para"; section_name = "dram_para";
section = script_find_section(script, section_name); section = script_find_section(script, section_name);
...@@ -101,6 +112,10 @@ int script_generate_uboot(FILE *out, const char *UNUSED(filename), ...@@ -101,6 +112,10 @@ int script_generate_uboot(FILE *out, const char *UNUSED(filename),
goto missing_section; goto missing_section;
generate_dram_struct(out, section); generate_dram_struct(out, section);
fputs("\nint sunxi_dram_init(void)\n"
"{\n\treturn DRAMC_init(&dram_para);\n}\n",
out);
return 1; return 1;
missing_section: missing_section:
pr_err("%s: critical section missing", section_name); pr_err("%s: critical section missing", section_name);
......
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