|
@@ -449,12 +449,31 @@ static int at91_ebi_dev_setup(struct at91_ebi *ebi, struct device_node *np,
|
|
struct at91_ebi_dev_config conf = { };
|
|
struct at91_ebi_dev_config conf = { };
|
|
struct device *dev = ebi->dev;
|
|
struct device *dev = ebi->dev;
|
|
struct at91_ebi_dev *ebid;
|
|
struct at91_ebi_dev *ebid;
|
|
- int ret, numcs = 0, i;
|
|
|
|
|
|
+ unsigned long cslines = 0;
|
|
|
|
+ int ret, numcs = 0, nentries, i;
|
|
bool apply = false;
|
|
bool apply = false;
|
|
|
|
+ u32 cs;
|
|
|
|
|
|
- numcs = of_property_count_elems_of_size(np, "reg",
|
|
|
|
- reg_cells * sizeof(u32));
|
|
|
|
- if (numcs <= 0) {
|
|
|
|
|
|
+ nentries = of_property_count_elems_of_size(np, "reg",
|
|
|
|
+ reg_cells * sizeof(u32));
|
|
|
|
+ for (i = 0; i < nentries; i++) {
|
|
|
|
+ ret = of_property_read_u32_index(np, "reg", i * reg_cells,
|
|
|
|
+ &cs);
|
|
|
|
+ if (ret)
|
|
|
|
+ return ret;
|
|
|
|
+
|
|
|
|
+ if (cs >= AT91_MATRIX_EBI_NUM_CS ||
|
|
|
|
+ !(ebi->caps->available_cs & BIT(cs))) {
|
|
|
|
+ dev_err(dev, "invalid reg property in %s\n",
|
|
|
|
+ np->full_name);
|
|
|
|
+ return -EINVAL;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!test_and_set_bit(cs, &cslines))
|
|
|
|
+ numcs++;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!numcs) {
|
|
dev_err(dev, "invalid reg property in %s\n", np->full_name);
|
|
dev_err(dev, "invalid reg property in %s\n", np->full_name);
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
@@ -473,21 +492,8 @@ static int at91_ebi_dev_setup(struct at91_ebi *ebi, struct device_node *np,
|
|
else if (ret)
|
|
else if (ret)
|
|
apply = true;
|
|
apply = true;
|
|
|
|
|
|
- for (i = 0; i < numcs; i++) {
|
|
|
|
- u32 cs;
|
|
|
|
-
|
|
|
|
- ret = of_property_read_u32_index(np, "reg", i * reg_cells,
|
|
|
|
- &cs);
|
|
|
|
- if (ret)
|
|
|
|
- return ret;
|
|
|
|
-
|
|
|
|
- if (cs > AT91_MATRIX_EBI_NUM_CS ||
|
|
|
|
- !(ebi->caps->available_cs & BIT(cs))) {
|
|
|
|
- dev_err(dev, "invalid reg property in %s\n",
|
|
|
|
- np->full_name);
|
|
|
|
- return -EINVAL;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ i = 0;
|
|
|
|
+ for_each_set_bit(cs, &cslines, AT91_MATRIX_EBI_NUM_CS) {
|
|
ebid->configs[i].cs = cs;
|
|
ebid->configs[i].cs = cs;
|
|
|
|
|
|
if (apply) {
|
|
if (apply) {
|
|
@@ -506,6 +512,8 @@ static int at91_ebi_dev_setup(struct at91_ebi *ebi, struct device_node *np,
|
|
if (ebi->ebi_csa && apply)
|
|
if (ebi->ebi_csa && apply)
|
|
regmap_field_update_bits(ebi->ebi_csa,
|
|
regmap_field_update_bits(ebi->ebi_csa,
|
|
BIT(cs), 0);
|
|
BIT(cs), 0);
|
|
|
|
+
|
|
|
|
+ i++;
|
|
}
|
|
}
|
|
|
|
|
|
list_add_tail(&ebid->node, &ebi->devs);
|
|
list_add_tail(&ebid->node, &ebi->devs);
|