aboutsummaryrefslogtreecommitdiffstats
path: root/sound/ppc/tumbler.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/ppc/tumbler.c')
-rw-r--r--sound/ppc/tumbler.c55
1 files changed, 34 insertions, 21 deletions
diff --git a/sound/ppc/tumbler.c b/sound/ppc/tumbler.c
index 8f074c7936e6..54e333fbb1d0 100644
--- a/sound/ppc/tumbler.c
+++ b/sound/ppc/tumbler.c
@@ -1031,32 +1031,40 @@ static irqreturn_t headphone_intr(int irq, void *devid)
1031/* look for audio-gpio device */ 1031/* look for audio-gpio device */
1032static struct device_node *find_audio_device(const char *name) 1032static struct device_node *find_audio_device(const char *name)
1033{ 1033{
1034 struct device_node *gpiop;
1034 struct device_node *np; 1035 struct device_node *np;
1035 1036
1036 if (! (np = find_devices("gpio"))) 1037 gpiop = of_find_node_by_name(NULL, "gpio");
1038 if (! gpiop)
1037 return NULL; 1039 return NULL;
1038 1040
1039 for (np = np->child; np; np = np->sibling) { 1041 for (np = of_get_next_child(gpiop, NULL); np;
1040 const char *property = get_property(np, "audio-gpio", NULL); 1042 np = of_get_next_child(gpiop, np)) {
1043 const char *property = of_get_property(np, "audio-gpio", NULL);
1041 if (property && strcmp(property, name) == 0) 1044 if (property && strcmp(property, name) == 0)
1042 return np; 1045 break;
1043 } 1046 }
1044 return NULL; 1047 of_node_put(gpiop);
1048 return np;
1045} 1049}
1046 1050
1047/* look for audio-gpio device */ 1051/* look for audio-gpio device */
1048static struct device_node *find_compatible_audio_device(const char *name) 1052static struct device_node *find_compatible_audio_device(const char *name)
1049{ 1053{
1054 struct device_node *gpiop;
1050 struct device_node *np; 1055 struct device_node *np;
1051 1056
1052 if (! (np = find_devices("gpio"))) 1057 gpiop = of_find_node_by_name(NULL, "gpio");
1058 if (!gpiop)
1053 return NULL; 1059 return NULL;
1054 1060
1055 for (np = np->child; np; np = np->sibling) { 1061 for (np = of_get_next_child(gpiop, NULL); np;
1062 np = of_get_next_child(gpiop, np)) {
1056 if (device_is_compatible(np, name)) 1063 if (device_is_compatible(np, name))
1057 return np; 1064 break;
1058 } 1065 }
1059 return NULL; 1066 of_node_put(gpiop);
1067 return np;
1060} 1068}
1061 1069
1062/* find an audio device and get its address */ 1070/* find an audio device and get its address */
@@ -1066,6 +1074,7 @@ static long tumbler_find_device(const char *device, const char *platform,
1066 struct device_node *node; 1074 struct device_node *node;
1067 const u32 *base; 1075 const u32 *base;
1068 u32 addr; 1076 u32 addr;
1077 long ret;
1069 1078
1070 if (is_compatible) 1079 if (is_compatible)
1071 node = find_compatible_audio_device(device); 1080 node = find_compatible_audio_device(device);
@@ -1077,12 +1086,13 @@ static long tumbler_find_device(const char *device, const char *platform,
1077 return -ENODEV; 1086 return -ENODEV;
1078 } 1087 }
1079 1088
1080 base = get_property(node, "AAPL,address", NULL); 1089 base = of_get_property(node, "AAPL,address", NULL);
1081 if (! base) { 1090 if (! base) {
1082 base = get_property(node, "reg", NULL); 1091 base = of_get_property(node, "reg", NULL);
1083 if (!base) { 1092 if (!base) {
1084 DBG("(E) cannot find address for device %s !\n", device); 1093 DBG("(E) cannot find address for device %s !\n", device);
1085 snd_printd("cannot find address for device %s\n", device); 1094 snd_printd("cannot find address for device %s\n", device);
1095 of_node_put(node);
1086 return -ENODEV; 1096 return -ENODEV;
1087 } 1097 }
1088 addr = *base; 1098 addr = *base;
@@ -1093,7 +1103,7 @@ static long tumbler_find_device(const char *device, const char *platform,
1093 1103
1094 gp->addr = addr & 0x0000ffff; 1104 gp->addr = addr & 0x0000ffff;
1095 /* Try to find the active state, default to 0 ! */ 1105 /* Try to find the active state, default to 0 ! */
1096 base = get_property(node, "audio-gpio-active-state", NULL); 1106 base = of_get_property(node, "audio-gpio-active-state", NULL);
1097 if (base) { 1107 if (base) {
1098 gp->active_state = *base; 1108 gp->active_state = *base;
1099 gp->active_val = (*base) ? 0x5 : 0x4; 1109 gp->active_val = (*base) ? 0x5 : 0x4;
@@ -1108,7 +1118,7 @@ static long tumbler_find_device(const char *device, const char *platform,
1108 * as we don't yet have an interpreter for these things 1118 * as we don't yet have an interpreter for these things
1109 */ 1119 */
1110 if (platform) 1120 if (platform)
1111 prop = get_property(node, platform, NULL); 1121 prop = of_get_property(node, platform, NULL);
1112 if (prop) { 1122 if (prop) {
1113 if (prop[3] == 0x9 && prop[4] == 0x9) { 1123 if (prop[3] == 0x9 && prop[4] == 0x9) {
1114 gp->active_val = 0xd; 1124 gp->active_val = 0xd;
@@ -1124,7 +1134,9 @@ static long tumbler_find_device(const char *device, const char *platform,
1124 DBG("(I) GPIO device %s found, offset: %x, active state: %d !\n", 1134 DBG("(I) GPIO device %s found, offset: %x, active state: %d !\n",
1125 device, gp->addr, gp->active_state); 1135 device, gp->addr, gp->active_state);
1126 1136
1127 return irq_of_parse_and_map(node, 0); 1137 ret = irq_of_parse_and_map(node, 0);
1138 of_node_put(node);
1139 return ret;
1128} 1140}
1129 1141
1130/* reset audio */ 1142/* reset audio */
@@ -1310,7 +1322,7 @@ int __init snd_pmac_tumbler_init(struct snd_pmac *chip)
1310{ 1322{
1311 int i, err; 1323 int i, err;
1312 struct pmac_tumbler *mix; 1324 struct pmac_tumbler *mix;
1313 u32 *paddr; 1325 const u32 *paddr;
1314 struct device_node *tas_node, *np; 1326 struct device_node *tas_node, *np;
1315 char *chipname; 1327 char *chipname;
1316 1328
@@ -1331,9 +1343,9 @@ int __init snd_pmac_tumbler_init(struct snd_pmac *chip)
1331 1343
1332 for (np = chip->node->child; np; np = np->sibling) { 1344 for (np = chip->node->child; np; np = np->sibling) {
1333 if (!strcmp(np->name, "sound")) { 1345 if (!strcmp(np->name, "sound")) {
1334 if (get_property(np, "has-anded-reset", NULL)) 1346 if (of_get_property(np, "has-anded-reset", NULL))
1335 mix->anded_reset = 1; 1347 mix->anded_reset = 1;
1336 if (get_property(np, "layout-id", NULL)) 1348 if (of_get_property(np, "layout-id", NULL))
1337 mix->reset_on_sleep = 0; 1349 mix->reset_on_sleep = 0;
1338 break; 1350 break;
1339 } 1351 }
@@ -1342,19 +1354,20 @@ int __init snd_pmac_tumbler_init(struct snd_pmac *chip)
1342 return err; 1354 return err;
1343 1355
1344 /* set up TAS */ 1356 /* set up TAS */
1345 tas_node = find_devices("deq"); 1357 tas_node = of_find_node_by_name(NULL, "deq");
1346 if (tas_node == NULL) 1358 if (tas_node == NULL)
1347 tas_node = find_devices("codec"); 1359 tas_node = of_find_node_by_name(NULL, "codec");
1348 if (tas_node == NULL) 1360 if (tas_node == NULL)
1349 return -ENODEV; 1361 return -ENODEV;
1350 1362
1351 paddr = (u32 *)get_property(tas_node, "i2c-address", NULL); 1363 paddr = of_get_property(tas_node, "i2c-address", NULL);
1352 if (paddr == NULL) 1364 if (paddr == NULL)
1353 paddr = (u32 *)get_property(tas_node, "reg", NULL); 1365 paddr = of_get_property(tas_node, "reg", NULL);
1354 if (paddr) 1366 if (paddr)
1355 mix->i2c.addr = (*paddr) >> 1; 1367 mix->i2c.addr = (*paddr) >> 1;
1356 else 1368 else
1357 mix->i2c.addr = TAS_I2C_ADDR; 1369 mix->i2c.addr = TAS_I2C_ADDR;
1370 of_node_put(tas_node);
1358 1371
1359 DBG("(I) TAS i2c address is: %x\n", mix->i2c.addr); 1372 DBG("(I) TAS i2c address is: %x\n", mix->i2c.addr);
1360 1373