diff options
author | Timur Tabi <timur@freescale.com> | 2011-12-01 20:52:46 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2011-12-02 05:37:17 -0500 |
commit | a806aa9207ad59933464efbe6009394723713c0d (patch) | |
tree | 4a120f350c9ab924938c8d672cbb5c324c30cc73 /sound/soc/fsl | |
parent | 6f526f0a86dbb22fd2fc5a873f55c9e2341a79c0 (diff) |
ASoC: p1022ds: add support for fsl,P1022 and fsl,P1022DS model names
Commit ab827d97 ("powerpc/85xx: Rework P1022DS device tree") renamed the
the /model property of the P1022DS device tree from "fsl,P1022" to
"fsl,P1022DS". To support both old and new device trees, the ASoC
machine driver for the P1022DS needs to query the /model property and
update the platform driver object dynamically.
Signed-off-by: Timur Tabi <timur@freescale.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/fsl')
-rw-r--r-- | sound/soc/fsl/p1022_ds.c | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/sound/soc/fsl/p1022_ds.c b/sound/soc/fsl/p1022_ds.c index 2c064a9824ad..309162652287 100644 --- a/sound/soc/fsl/p1022_ds.c +++ b/sound/soc/fsl/p1022_ds.c | |||
@@ -540,12 +540,6 @@ static struct platform_driver p1022_ds_driver = { | |||
540 | .probe = p1022_ds_probe, | 540 | .probe = p1022_ds_probe, |
541 | .remove = __devexit_p(p1022_ds_remove), | 541 | .remove = __devexit_p(p1022_ds_remove), |
542 | .driver = { | 542 | .driver = { |
543 | /* The name must match the 'model' property in the device tree, | ||
544 | * in lowercase letters, but only the part after that last | ||
545 | * comma. This is because some model properties have a "fsl," | ||
546 | * prefix. | ||
547 | */ | ||
548 | .name = "snd-soc-p1022", | ||
549 | .owner = THIS_MODULE, | 543 | .owner = THIS_MODULE, |
550 | }, | 544 | }, |
551 | }; | 545 | }; |
@@ -559,13 +553,39 @@ static int __init p1022_ds_init(void) | |||
559 | { | 553 | { |
560 | struct device_node *guts_np; | 554 | struct device_node *guts_np; |
561 | struct resource res; | 555 | struct resource res; |
556 | const char *sprop; | ||
557 | |||
558 | /* | ||
559 | * Check if we're actually running on a P1022DS. Older device trees | ||
560 | * have a model of "fsl,P1022" and newer ones use "fsl,P1022DS", so we | ||
561 | * need to support both. The SSI driver uses that property to link to | ||
562 | * the machine driver, so have to match it. | ||
563 | */ | ||
564 | sprop = of_get_property(of_find_node_by_path("/"), "model", NULL); | ||
565 | if (!sprop) { | ||
566 | pr_err("snd-soc-p1022ds: missing /model node"); | ||
567 | return -ENODEV; | ||
568 | } | ||
569 | |||
570 | pr_debug("snd-soc-p1022ds: board model name is %s\n", sprop); | ||
562 | 571 | ||
563 | pr_info("Freescale P1022 DS ALSA SoC machine driver\n"); | 572 | /* |
573 | * The name of this board, taken from the device tree. Normally, this is a* | ||
574 | * fixed string, but some P1022DS device trees have a /model property of | ||
575 | * "fsl,P1022", and others have "fsl,P1022DS". | ||
576 | */ | ||
577 | if (strcasecmp(sprop, "fsl,p1022ds") == 0) | ||
578 | p1022_ds_driver.driver.name = "snd-soc-p1022ds"; | ||
579 | else if (strcasecmp(sprop, "fsl,p1022") == 0) | ||
580 | p1022_ds_driver.driver.name = "snd-soc-p1022"; | ||
581 | else | ||
582 | return -ENODEV; | ||
564 | 583 | ||
565 | /* Get the physical address of the global utilities registers */ | 584 | /* Get the physical address of the global utilities registers */ |
566 | guts_np = of_find_compatible_node(NULL, NULL, "fsl,p1022-guts"); | 585 | guts_np = of_find_compatible_node(NULL, NULL, "fsl,p1022-guts"); |
567 | if (of_address_to_resource(guts_np, 0, &res)) { | 586 | if (of_address_to_resource(guts_np, 0, &res)) { |
568 | pr_err("p1022-ds: missing/invalid global utilities node\n"); | 587 | pr_err("snd-soc-p1022ds: missing/invalid global utils node\n"); |
588 | of_node_put(guts_np); | ||
569 | return -EINVAL; | 589 | return -EINVAL; |
570 | } | 590 | } |
571 | guts_phys = res.start; | 591 | guts_phys = res.start; |