Drivers for 4.11 #2:
- more EBI fixes -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEl0I5XWmUIrwBfFMm2KKDO9oT4sIFAliLx1UACgkQ2KKDO9oT 4sJMNQ//e6D1s+u/vT4E9HhYdgxtf/5aniWRKyG/KrP75xG16DocBrPxKX+FjZYR kCu67jh0OYvtU6GneKVM3NrbdefMTA8vDjoNur6BYL2lV8ZGu7tdSCEr3sOFja2X yN83ylwA9Z8b+sv5fV+JNGGrwsT83Y0OFN2qyp+ivOdOY6ozy7kA9hbaW0LfiMtK taB9EZYULBnIrBOigNX68yG8ArWy9iPK6O1LE7tfPimJ6z4IsyTIaqXr6XYhnqtc vl7GrEVC23XC4u8giSMxhflmzOYLv0EyCEC2U1Jb8l6XuHqfRcKPj52c4APqdlF6 OMu23nrJ6eVenH9IUgWDzleNsCyblQm20EUtD3ADeBNhTSBJSE9kg6gs6XtHAzjS mkiKMqlj04F3wST0sDCHwY8oZyRJ8hCgjqt7PTxo4nSadl9Z1Oe4PnnJhkqEVQxu 6MIGOyqp+TntMTPAR0S4e/wDarRF3KRf0J5n/x/ceixzd/Cx4ysSg94insftVjM0 TfImgZSNAs8P1NaISPg8/1OHxz3X34f7i/i16gRb02hsyNPNJjV4UFOUzKoykOWT +jCnDxr3X1ZVSliGMN7+vgSMRdFLu/l1N9w4PJPRxSPadQcjJV7NwdgexD/OLFNS w8wocMyCaG4Tcb69RMYdW4AhRUAT4zOoKMoPlLMGP1mmxeJk5AE= =udxv -----END PGP SIGNATURE----- Merge tag 'at91-ab-4.11-drivers2' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux into next/drivers Drivers for 4.11 #2: - more EBI fixes * tag 'at91-ab-4.11-drivers2' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: memory: atmel-ebi: Enable the SMC clock if specified memory: atmel-ebi: Properly handle multiple reference to the same CS memory: atmel-ebi: Fix the test to enable generic SMC logic Signed-off-by: Olof Johansson <olof@lixom.net>
This commit is contained in:
commit
2998954c40
|
@ -76,9 +76,11 @@ struct at91_ebi_caps {
|
||||||
|
|
||||||
struct at91_ebi {
|
struct at91_ebi {
|
||||||
struct clk *clk;
|
struct clk *clk;
|
||||||
struct regmap *smc;
|
|
||||||
struct regmap *matrix;
|
struct regmap *matrix;
|
||||||
|
struct {
|
||||||
|
struct regmap *regmap;
|
||||||
|
struct clk *clk;
|
||||||
|
} smc;
|
||||||
struct regmap_field *ebi_csa;
|
struct regmap_field *ebi_csa;
|
||||||
|
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
|
@ -395,22 +397,26 @@ static int at91sam9_ebi_init(struct at91_ebi *ebi)
|
||||||
field.id_offset = AT91SAM9_SMC_GENERIC_BLK_SZ;
|
field.id_offset = AT91SAM9_SMC_GENERIC_BLK_SZ;
|
||||||
|
|
||||||
field.reg = AT91SAM9_SMC_SETUP(AT91SAM9_SMC_GENERIC);
|
field.reg = AT91SAM9_SMC_SETUP(AT91SAM9_SMC_GENERIC);
|
||||||
fields->setup = devm_regmap_field_alloc(ebi->dev, ebi->smc, field);
|
fields->setup = devm_regmap_field_alloc(ebi->dev, ebi->smc.regmap,
|
||||||
|
field);
|
||||||
if (IS_ERR(fields->setup))
|
if (IS_ERR(fields->setup))
|
||||||
return PTR_ERR(fields->setup);
|
return PTR_ERR(fields->setup);
|
||||||
|
|
||||||
field.reg = AT91SAM9_SMC_PULSE(AT91SAM9_SMC_GENERIC);
|
field.reg = AT91SAM9_SMC_PULSE(AT91SAM9_SMC_GENERIC);
|
||||||
fields->pulse = devm_regmap_field_alloc(ebi->dev, ebi->smc, field);
|
fields->pulse = devm_regmap_field_alloc(ebi->dev, ebi->smc.regmap,
|
||||||
|
field);
|
||||||
if (IS_ERR(fields->pulse))
|
if (IS_ERR(fields->pulse))
|
||||||
return PTR_ERR(fields->pulse);
|
return PTR_ERR(fields->pulse);
|
||||||
|
|
||||||
field.reg = AT91SAM9_SMC_CYCLE(AT91SAM9_SMC_GENERIC);
|
field.reg = AT91SAM9_SMC_CYCLE(AT91SAM9_SMC_GENERIC);
|
||||||
fields->cycle = devm_regmap_field_alloc(ebi->dev, ebi->smc, field);
|
fields->cycle = devm_regmap_field_alloc(ebi->dev, ebi->smc.regmap,
|
||||||
|
field);
|
||||||
if (IS_ERR(fields->cycle))
|
if (IS_ERR(fields->cycle))
|
||||||
return PTR_ERR(fields->cycle);
|
return PTR_ERR(fields->cycle);
|
||||||
|
|
||||||
field.reg = AT91SAM9_SMC_MODE(AT91SAM9_SMC_GENERIC);
|
field.reg = AT91SAM9_SMC_MODE(AT91SAM9_SMC_GENERIC);
|
||||||
fields->mode = devm_regmap_field_alloc(ebi->dev, ebi->smc, field);
|
fields->mode = devm_regmap_field_alloc(ebi->dev, ebi->smc.regmap,
|
||||||
|
field);
|
||||||
return PTR_ERR_OR_ZERO(fields->mode);
|
return PTR_ERR_OR_ZERO(fields->mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -423,22 +429,26 @@ static int sama5d3_ebi_init(struct at91_ebi *ebi)
|
||||||
field.id_offset = SAMA5_SMC_GENERIC_BLK_SZ;
|
field.id_offset = SAMA5_SMC_GENERIC_BLK_SZ;
|
||||||
|
|
||||||
field.reg = AT91SAM9_SMC_SETUP(SAMA5_SMC_GENERIC);
|
field.reg = AT91SAM9_SMC_SETUP(SAMA5_SMC_GENERIC);
|
||||||
fields->setup = devm_regmap_field_alloc(ebi->dev, ebi->smc, field);
|
fields->setup = devm_regmap_field_alloc(ebi->dev, ebi->smc.regmap,
|
||||||
|
field);
|
||||||
if (IS_ERR(fields->setup))
|
if (IS_ERR(fields->setup))
|
||||||
return PTR_ERR(fields->setup);
|
return PTR_ERR(fields->setup);
|
||||||
|
|
||||||
field.reg = AT91SAM9_SMC_PULSE(SAMA5_SMC_GENERIC);
|
field.reg = AT91SAM9_SMC_PULSE(SAMA5_SMC_GENERIC);
|
||||||
fields->pulse = devm_regmap_field_alloc(ebi->dev, ebi->smc, field);
|
fields->pulse = devm_regmap_field_alloc(ebi->dev, ebi->smc.regmap,
|
||||||
|
field);
|
||||||
if (IS_ERR(fields->pulse))
|
if (IS_ERR(fields->pulse))
|
||||||
return PTR_ERR(fields->pulse);
|
return PTR_ERR(fields->pulse);
|
||||||
|
|
||||||
field.reg = AT91SAM9_SMC_CYCLE(SAMA5_SMC_GENERIC);
|
field.reg = AT91SAM9_SMC_CYCLE(SAMA5_SMC_GENERIC);
|
||||||
fields->cycle = devm_regmap_field_alloc(ebi->dev, ebi->smc, field);
|
fields->cycle = devm_regmap_field_alloc(ebi->dev, ebi->smc.regmap,
|
||||||
|
field);
|
||||||
if (IS_ERR(fields->cycle))
|
if (IS_ERR(fields->cycle))
|
||||||
return PTR_ERR(fields->cycle);
|
return PTR_ERR(fields->cycle);
|
||||||
|
|
||||||
field.reg = SAMA5_SMC_MODE(SAMA5_SMC_GENERIC);
|
field.reg = SAMA5_SMC_MODE(SAMA5_SMC_GENERIC);
|
||||||
fields->mode = devm_regmap_field_alloc(ebi->dev, ebi->smc, field);
|
fields->mode = devm_regmap_field_alloc(ebi->dev, ebi->smc.regmap,
|
||||||
|
field);
|
||||||
return PTR_ERR_OR_ZERO(fields->mode);
|
return PTR_ERR_OR_ZERO(fields->mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -449,12 +459,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",
|
nentries = of_property_count_elems_of_size(np, "reg",
|
||||||
reg_cells * sizeof(u32));
|
reg_cells * sizeof(u32));
|
||||||
if (numcs <= 0) {
|
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 +502,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++) {
|
i = 0;
|
||||||
u32 cs;
|
for_each_set_bit(cs, &cslines, AT91_MATRIX_EBI_NUM_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;
|
|
||||||
}
|
|
||||||
|
|
||||||
ebid->configs[i].cs = cs;
|
ebid->configs[i].cs = cs;
|
||||||
|
|
||||||
if (apply) {
|
if (apply) {
|
||||||
|
@ -503,9 +519,11 @@ static int at91_ebi_dev_setup(struct at91_ebi *ebi, struct device_node *np,
|
||||||
* Attach the EBI device to the generic SMC logic if at least
|
* Attach the EBI device to the generic SMC logic if at least
|
||||||
* one "atmel,smc-" property is present.
|
* one "atmel,smc-" property is present.
|
||||||
*/
|
*/
|
||||||
if (ebi->ebi_csa && ret)
|
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);
|
||||||
|
@ -669,7 +687,7 @@ static int at91_ebi_dev_disable(struct at91_ebi *ebi, struct device_node *np)
|
||||||
static int at91_ebi_probe(struct platform_device *pdev)
|
static int at91_ebi_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct device *dev = &pdev->dev;
|
struct device *dev = &pdev->dev;
|
||||||
struct device_node *child, *np = dev->of_node;
|
struct device_node *child, *np = dev->of_node, *smc_np;
|
||||||
const struct of_device_id *match;
|
const struct of_device_id *match;
|
||||||
struct at91_ebi *ebi;
|
struct at91_ebi *ebi;
|
||||||
int ret, reg_cells;
|
int ret, reg_cells;
|
||||||
|
@ -694,9 +712,22 @@ static int at91_ebi_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
ebi->clk = clk;
|
ebi->clk = clk;
|
||||||
|
|
||||||
ebi->smc = syscon_regmap_lookup_by_phandle(np, "atmel,smc");
|
smc_np = of_parse_phandle(dev->of_node, "atmel,smc", 0);
|
||||||
if (IS_ERR(ebi->smc))
|
|
||||||
return PTR_ERR(ebi->smc);
|
ebi->smc.regmap = syscon_node_to_regmap(smc_np);
|
||||||
|
if (IS_ERR(ebi->smc.regmap))
|
||||||
|
return PTR_ERR(ebi->smc.regmap);
|
||||||
|
|
||||||
|
ebi->smc.clk = of_clk_get(smc_np, 0);
|
||||||
|
if (IS_ERR(ebi->smc.clk)) {
|
||||||
|
if (PTR_ERR(ebi->smc.clk) != -ENOENT)
|
||||||
|
return PTR_ERR(ebi->smc.clk);
|
||||||
|
|
||||||
|
ebi->smc.clk = NULL;
|
||||||
|
}
|
||||||
|
ret = clk_prepare_enable(ebi->smc.clk);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The sama5d3 does not provide an EBICSA register and thus does need
|
* The sama5d3 does not provide an EBICSA register and thus does need
|
||||||
|
|
Loading…
Reference in New Issue