|
@@ -23,6 +23,7 @@
|
|
struct sunxi_sram_func {
|
|
struct sunxi_sram_func {
|
|
char *func;
|
|
char *func;
|
|
u8 val;
|
|
u8 val;
|
|
|
|
+ u32 reg_val;
|
|
};
|
|
};
|
|
|
|
|
|
struct sunxi_sram_data {
|
|
struct sunxi_sram_data {
|
|
@@ -39,10 +40,11 @@ struct sunxi_sram_desc {
|
|
bool claimed;
|
|
bool claimed;
|
|
};
|
|
};
|
|
|
|
|
|
-#define SUNXI_SRAM_MAP(_val, _func) \
|
|
|
|
|
|
+#define SUNXI_SRAM_MAP(_reg_val, _val, _func) \
|
|
{ \
|
|
{ \
|
|
.func = _func, \
|
|
.func = _func, \
|
|
.val = _val, \
|
|
.val = _val, \
|
|
|
|
+ .reg_val = _reg_val, \
|
|
}
|
|
}
|
|
|
|
|
|
#define SUNXI_SRAM_DATA(_name, _reg, _off, _width, ...) \
|
|
#define SUNXI_SRAM_DATA(_name, _reg, _off, _width, ...) \
|
|
@@ -57,14 +59,20 @@ struct sunxi_sram_desc {
|
|
|
|
|
|
static struct sunxi_sram_desc sun4i_a10_sram_a3_a4 = {
|
|
static struct sunxi_sram_desc sun4i_a10_sram_a3_a4 = {
|
|
.data = SUNXI_SRAM_DATA("A3-A4", 0x4, 0x4, 2,
|
|
.data = SUNXI_SRAM_DATA("A3-A4", 0x4, 0x4, 2,
|
|
- SUNXI_SRAM_MAP(0, "cpu"),
|
|
|
|
- SUNXI_SRAM_MAP(1, "emac")),
|
|
|
|
|
|
+ SUNXI_SRAM_MAP(0, 0, "cpu"),
|
|
|
|
+ SUNXI_SRAM_MAP(1, 1, "emac")),
|
|
};
|
|
};
|
|
|
|
|
|
static struct sunxi_sram_desc sun4i_a10_sram_d = {
|
|
static struct sunxi_sram_desc sun4i_a10_sram_d = {
|
|
.data = SUNXI_SRAM_DATA("D", 0x4, 0x0, 1,
|
|
.data = SUNXI_SRAM_DATA("D", 0x4, 0x0, 1,
|
|
- SUNXI_SRAM_MAP(0, "cpu"),
|
|
|
|
- SUNXI_SRAM_MAP(1, "usb-otg")),
|
|
|
|
|
|
+ SUNXI_SRAM_MAP(0, 0, "cpu"),
|
|
|
|
+ SUNXI_SRAM_MAP(1, 1, "usb-otg")),
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+static struct sunxi_sram_desc sun50i_a64_sram_c = {
|
|
|
|
+ .data = SUNXI_SRAM_DATA("C", 0x4, 24, 1,
|
|
|
|
+ SUNXI_SRAM_MAP(0, 1, "cpu"),
|
|
|
|
+ SUNXI_SRAM_MAP(1, 0, "de2")),
|
|
};
|
|
};
|
|
|
|
|
|
static const struct of_device_id sunxi_sram_dt_ids[] = {
|
|
static const struct of_device_id sunxi_sram_dt_ids[] = {
|
|
@@ -76,6 +84,10 @@ static const struct of_device_id sunxi_sram_dt_ids[] = {
|
|
.compatible = "allwinner,sun4i-a10-sram-d",
|
|
.compatible = "allwinner,sun4i-a10-sram-d",
|
|
.data = &sun4i_a10_sram_d.data,
|
|
.data = &sun4i_a10_sram_d.data,
|
|
},
|
|
},
|
|
|
|
+ {
|
|
|
|
+ .compatible = "allwinner,sun50i-a64-sram-c",
|
|
|
|
+ .data = &sun50i_a64_sram_c.data,
|
|
|
|
+ },
|
|
{}
|
|
{}
|
|
};
|
|
};
|
|
|
|
|
|
@@ -121,7 +133,8 @@ static int sunxi_sram_show(struct seq_file *s, void *data)
|
|
|
|
|
|
for (func = sram_data->func; func->func; func++) {
|
|
for (func = sram_data->func; func->func; func++) {
|
|
seq_printf(s, "\t\t%s%c\n", func->func,
|
|
seq_printf(s, "\t\t%s%c\n", func->func,
|
|
- func->val == val ? '*' : ' ');
|
|
|
|
|
|
+ func->reg_val == val ?
|
|
|
|
+ '*' : ' ');
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -149,10 +162,13 @@ static inline struct sunxi_sram_desc *to_sram_desc(const struct sunxi_sram_data
|
|
}
|
|
}
|
|
|
|
|
|
static const struct sunxi_sram_data *sunxi_sram_of_parse(struct device_node *node,
|
|
static const struct sunxi_sram_data *sunxi_sram_of_parse(struct device_node *node,
|
|
- unsigned int *value)
|
|
|
|
|
|
+ unsigned int *reg_value)
|
|
{
|
|
{
|
|
const struct of_device_id *match;
|
|
const struct of_device_id *match;
|
|
|
|
+ const struct sunxi_sram_data *data;
|
|
|
|
+ struct sunxi_sram_func *func;
|
|
struct of_phandle_args args;
|
|
struct of_phandle_args args;
|
|
|
|
+ u8 val;
|
|
int ret;
|
|
int ret;
|
|
|
|
|
|
ret = of_parse_phandle_with_fixed_args(node, "allwinner,sram", 1, 0,
|
|
ret = of_parse_phandle_with_fixed_args(node, "allwinner,sram", 1, 0,
|
|
@@ -165,8 +181,7 @@ static const struct sunxi_sram_data *sunxi_sram_of_parse(struct device_node *nod
|
|
goto err;
|
|
goto err;
|
|
}
|
|
}
|
|
|
|
|
|
- if (value)
|
|
|
|
- *value = args.args[0];
|
|
|
|
|
|
+ val = args.args[0];
|
|
|
|
|
|
match = of_match_node(sunxi_sram_dt_ids, args.np);
|
|
match = of_match_node(sunxi_sram_dt_ids, args.np);
|
|
if (!match) {
|
|
if (!match) {
|
|
@@ -174,6 +189,26 @@ static const struct sunxi_sram_data *sunxi_sram_of_parse(struct device_node *nod
|
|
goto err;
|
|
goto err;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ data = match->data;
|
|
|
|
+ if (!data) {
|
|
|
|
+ ret = -EINVAL;
|
|
|
|
+ goto err;
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ for (func = data->func; func->func; func++) {
|
|
|
|
+ if (val == func->val) {
|
|
|
|
+ if (reg_value)
|
|
|
|
+ *reg_value = func->reg_val;
|
|
|
|
+
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!func->func) {
|
|
|
|
+ ret = -EINVAL;
|
|
|
|
+ goto err;
|
|
|
|
+ }
|
|
|
|
+
|
|
of_node_put(args.np);
|
|
of_node_put(args.np);
|
|
return match->data;
|
|
return match->data;
|
|
|
|
|
|
@@ -190,6 +225,9 @@ int sunxi_sram_claim(struct device *dev)
|
|
u32 val, mask;
|
|
u32 val, mask;
|
|
|
|
|
|
if (IS_ERR(base))
|
|
if (IS_ERR(base))
|
|
|
|
+ return PTR_ERR(base);
|
|
|
|
+
|
|
|
|
+ if (!base)
|
|
return -EPROBE_DEFER;
|
|
return -EPROBE_DEFER;
|
|
|
|
|
|
if (!dev || !dev->of_node)
|
|
if (!dev || !dev->of_node)
|
|
@@ -267,6 +305,7 @@ static int sunxi_sram_probe(struct platform_device *pdev)
|
|
|
|
|
|
static const struct of_device_id sunxi_sram_dt_match[] = {
|
|
static const struct of_device_id sunxi_sram_dt_match[] = {
|
|
{ .compatible = "allwinner,sun4i-a10-sram-controller" },
|
|
{ .compatible = "allwinner,sun4i-a10-sram-controller" },
|
|
|
|
+ { .compatible = "allwinner,sun50i-a64-sram-controller" },
|
|
{ },
|
|
{ },
|
|
};
|
|
};
|
|
MODULE_DEVICE_TABLE(of, sunxi_sram_dt_match);
|
|
MODULE_DEVICE_TABLE(of, sunxi_sram_dt_match);
|