diff options
Diffstat (limited to 'sound/soc/fsl/p1022_ds.c')
-rw-r--r-- | sound/soc/fsl/p1022_ds.c | 49 |
1 files changed, 36 insertions, 13 deletions
diff --git a/sound/soc/fsl/p1022_ds.c b/sound/soc/fsl/p1022_ds.c index 2c064a9824a..a5d4e80a9cf 100644 --- a/sound/soc/fsl/p1022_ds.c +++ b/sound/soc/fsl/p1022_ds.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/interrupt.h> | 14 | #include <linux/interrupt.h> |
15 | #include <linux/of_device.h> | 15 | #include <linux/of_device.h> |
16 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
17 | #include <linux/of_i2c.h> | ||
17 | #include <sound/soc.h> | 18 | #include <sound/soc.h> |
18 | #include <asm/fsl_guts.h> | 19 | #include <asm/fsl_guts.h> |
19 | 20 | ||
@@ -252,8 +253,9 @@ static int get_parent_cell_index(struct device_node *np) | |||
252 | static int codec_node_dev_name(struct device_node *np, char *buf, size_t len) | 253 | static int codec_node_dev_name(struct device_node *np, char *buf, size_t len) |
253 | { | 254 | { |
254 | const u32 *iprop; | 255 | const u32 *iprop; |
255 | int bus, addr; | 256 | int addr; |
256 | char temp[DAI_NAME_SIZE]; | 257 | char temp[DAI_NAME_SIZE]; |
258 | struct i2c_client *i2c; | ||
257 | 259 | ||
258 | of_modalias_node(np, temp, DAI_NAME_SIZE); | 260 | of_modalias_node(np, temp, DAI_NAME_SIZE); |
259 | 261 | ||
@@ -263,11 +265,12 @@ static int codec_node_dev_name(struct device_node *np, char *buf, size_t len) | |||
263 | 265 | ||
264 | addr = be32_to_cpup(iprop); | 266 | addr = be32_to_cpup(iprop); |
265 | 267 | ||
266 | bus = get_parent_cell_index(np); | 268 | /* We need the adapter number */ |
267 | if (bus < 0) | 269 | i2c = of_find_i2c_device_by_node(np); |
268 | return bus; | 270 | if (!i2c) |
271 | return -ENODEV; | ||
269 | 272 | ||
270 | snprintf(buf, len, "%s.%u-%04x", temp, bus, addr); | 273 | snprintf(buf, len, "%s.%u-%04x", temp, i2c->adapter->nr, addr); |
271 | 274 | ||
272 | return 0; | 275 | return 0; |
273 | } | 276 | } |
@@ -540,12 +543,6 @@ static struct platform_driver p1022_ds_driver = { | |||
540 | .probe = p1022_ds_probe, | 543 | .probe = p1022_ds_probe, |
541 | .remove = __devexit_p(p1022_ds_remove), | 544 | .remove = __devexit_p(p1022_ds_remove), |
542 | .driver = { | 545 | .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, | 546 | .owner = THIS_MODULE, |
550 | }, | 547 | }, |
551 | }; | 548 | }; |
@@ -559,13 +556,39 @@ static int __init p1022_ds_init(void) | |||
559 | { | 556 | { |
560 | struct device_node *guts_np; | 557 | struct device_node *guts_np; |
561 | struct resource res; | 558 | struct resource res; |
559 | const char *sprop; | ||
560 | |||
561 | /* | ||
562 | * Check if we're actually running on a P1022DS. Older device trees | ||
563 | * have a model of "fsl,P1022" and newer ones use "fsl,P1022DS", so we | ||
564 | * need to support both. The SSI driver uses that property to link to | ||
565 | * the machine driver, so have to match it. | ||
566 | */ | ||
567 | sprop = of_get_property(of_find_node_by_path("/"), "model", NULL); | ||
568 | if (!sprop) { | ||
569 | pr_err("snd-soc-p1022ds: missing /model node"); | ||
570 | return -ENODEV; | ||
571 | } | ||
572 | |||
573 | pr_debug("snd-soc-p1022ds: board model name is %s\n", sprop); | ||
562 | 574 | ||
563 | pr_info("Freescale P1022 DS ALSA SoC machine driver\n"); | 575 | /* |
576 | * The name of this board, taken from the device tree. Normally, this is a* | ||
577 | * fixed string, but some P1022DS device trees have a /model property of | ||
578 | * "fsl,P1022", and others have "fsl,P1022DS". | ||
579 | */ | ||
580 | if (strcasecmp(sprop, "fsl,p1022ds") == 0) | ||
581 | p1022_ds_driver.driver.name = "snd-soc-p1022ds"; | ||
582 | else if (strcasecmp(sprop, "fsl,p1022") == 0) | ||
583 | p1022_ds_driver.driver.name = "snd-soc-p1022"; | ||
584 | else | ||
585 | return -ENODEV; | ||
564 | 586 | ||
565 | /* Get the physical address of the global utilities registers */ | 587 | /* Get the physical address of the global utilities registers */ |
566 | guts_np = of_find_compatible_node(NULL, NULL, "fsl,p1022-guts"); | 588 | guts_np = of_find_compatible_node(NULL, NULL, "fsl,p1022-guts"); |
567 | if (of_address_to_resource(guts_np, 0, &res)) { | 589 | if (of_address_to_resource(guts_np, 0, &res)) { |
568 | pr_err("p1022-ds: missing/invalid global utilities node\n"); | 590 | pr_err("snd-soc-p1022ds: missing/invalid global utils node\n"); |
591 | of_node_put(guts_np); | ||
569 | return -EINVAL; | 592 | return -EINVAL; |
570 | } | 593 | } |
571 | guts_phys = res.start; | 594 | guts_phys = res.start; |