diff options
author | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2005-12-13 02:01:21 -0500 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2006-01-08 22:53:55 -0500 |
commit | cc5d0189b9ba95260857a5018a1c2fef90008507 (patch) | |
tree | 1202c94b6b3cb81a96d0a0e54424cad10eef68bb /sound | |
parent | 9cf84d7c97992dbe5360b241327341c07ce30fc9 (diff) |
[PATCH] powerpc: Remove device_node addrs/n_addr
The pre-parsed addrs/n_addrs fields in struct device_node are finally
gone. Remove the dodgy heuristics that did that parsing at boot and
remove the fields themselves since we now have a good replacement with
the new OF parsing code. This patch also fixes a bunch of drivers to use
the new code instead, so that at least pmac32, pseries, iseries and g5
defconfigs build.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/oss/dmasound/dmasound_awacs.c | 81 | ||||
-rw-r--r-- | sound/ppc/pmac.c | 100 | ||||
-rw-r--r-- | sound/ppc/pmac.h | 3 |
3 files changed, 114 insertions, 70 deletions
diff --git a/sound/oss/dmasound/dmasound_awacs.c b/sound/oss/dmasound/dmasound_awacs.c index cebd881b91ae..74f975676ccb 100644 --- a/sound/oss/dmasound/dmasound_awacs.c +++ b/sound/oss/dmasound/dmasound_awacs.c | |||
@@ -125,6 +125,7 @@ static int awacs_rate_index; | |||
125 | static int awacs_subframe; | 125 | static int awacs_subframe; |
126 | static struct device_node* awacs_node; | 126 | static struct device_node* awacs_node; |
127 | static struct device_node* i2s_node; | 127 | static struct device_node* i2s_node; |
128 | static struct resource awacs_rsrc[3]; | ||
128 | 129 | ||
129 | static char awacs_name[64]; | 130 | static char awacs_name[64]; |
130 | static int awacs_revision; | 131 | static int awacs_revision; |
@@ -667,9 +668,12 @@ static void PMacIrqCleanup(void) | |||
667 | iounmap(awacs_txdma); | 668 | iounmap(awacs_txdma); |
668 | iounmap(awacs_rxdma); | 669 | iounmap(awacs_rxdma); |
669 | 670 | ||
670 | release_OF_resource(awacs_node, 0); | 671 | release_mem_region(awacs_rsrc[0].start, |
671 | release_OF_resource(awacs_node, 1); | 672 | awacs_rsrc[0].end - awacs_rsrc[0].start + 1); |
672 | release_OF_resource(awacs_node, 2); | 673 | release_mem_region(awacs_rsrc[1].start, |
674 | awacs_rsrc[1].end - awacs_rsrc[1].start + 1); | ||
675 | release_mem_region(awacs_rsrc[2].start, | ||
676 | awacs_rsrc[2].end - awacs_rsrc[2].start + 1); | ||
673 | 677 | ||
674 | kfree(awacs_tx_cmd_space); | 678 | kfree(awacs_tx_cmd_space); |
675 | kfree(awacs_rx_cmd_space); | 679 | kfree(awacs_rx_cmd_space); |
@@ -2863,46 +2867,58 @@ printk("dmasound_pmac: couldn't find a Codec we can handle\n"); | |||
2863 | * other info if necessary (early AWACS we want to read chip ids) | 2867 | * other info if necessary (early AWACS we want to read chip ids) |
2864 | */ | 2868 | */ |
2865 | 2869 | ||
2866 | if (io->n_addrs < 3 || io->n_intrs < 3) { | 2870 | if (of_get_address(io, 2, NULL, NULL) == NULL || io->n_intrs < 3) { |
2867 | /* OK - maybe we need to use the 'awacs' node (on earlier | 2871 | /* OK - maybe we need to use the 'awacs' node (on earlier |
2868 | * machines). | 2872 | * machines). |
2869 | */ | 2873 | */ |
2870 | if (awacs_node) { | 2874 | if (awacs_node) { |
2871 | io = awacs_node ; | 2875 | io = awacs_node ; |
2872 | if (io->n_addrs < 3 || io->n_intrs < 3) { | 2876 | if (of_get_address(io, 2, NULL, NULL) == NULL || |
2873 | printk("dmasound_pmac: can't use %s" | 2877 | io->n_intrs < 3) { |
2874 | " (%d addrs, %d intrs)\n", | 2878 | printk("dmasound_pmac: can't use %s\n", |
2875 | io->full_name, io->n_addrs, io->n_intrs); | 2879 | io->full_name); |
2876 | return -ENODEV; | 2880 | return -ENODEV; |
2877 | } | 2881 | } |
2878 | } else { | 2882 | } else |
2879 | printk("dmasound_pmac: can't use %s (%d addrs, %d intrs)\n", | 2883 | printk("dmasound_pmac: can't use %s\n", io->full_name); |
2880 | io->full_name, io->n_addrs, io->n_intrs); | ||
2881 | } | ||
2882 | } | 2884 | } |
2883 | 2885 | ||
2884 | if (!request_OF_resource(io, 0, NULL)) { | 2886 | if (of_address_to_resource(io, 0, &awacs_rsrc[0]) || |
2887 | request_mem_region(awacs_rsrc[0].start, | ||
2888 | awacs_rsrc[0].end - awacs_rsrc[0].start + 1, | ||
2889 | " (IO)") == NULL) { | ||
2885 | printk(KERN_ERR "dmasound: can't request IO resource !\n"); | 2890 | printk(KERN_ERR "dmasound: can't request IO resource !\n"); |
2886 | return -ENODEV; | 2891 | return -ENODEV; |
2887 | } | 2892 | } |
2888 | if (!request_OF_resource(io, 1, " (tx dma)")) { | 2893 | if (of_address_to_resource(io, 1, &awacs_rsrc[1]) || |
2889 | release_OF_resource(io, 0); | 2894 | request_mem_region(awacs_rsrc[1].start, |
2890 | printk(KERN_ERR "dmasound: can't request TX DMA resource !\n"); | 2895 | awacs_rsrc[1].end - awacs_rsrc[1].start + 1, |
2896 | " (tx dma)") == NULL) { | ||
2897 | release_mem_region(awacs_rsrc[0].start, | ||
2898 | awacs_rsrc[0].end - awacs_rsrc[0].start + 1); | ||
2899 | printk(KERN_ERR "dmasound: can't request Tx DMA resource !\n"); | ||
2891 | return -ENODEV; | 2900 | return -ENODEV; |
2892 | } | 2901 | } |
2893 | 2902 | if (of_address_to_resource(io, 2, &awacs_rsrc[2]) || | |
2894 | if (!request_OF_resource(io, 2, " (rx dma)")) { | 2903 | request_mem_region(awacs_rsrc[2].start, |
2895 | release_OF_resource(io, 0); | 2904 | awacs_rsrc[2].end - awacs_rsrc[2].start + 1, |
2896 | release_OF_resource(io, 1); | 2905 | " (rx dma)") == NULL) { |
2897 | printk(KERN_ERR "dmasound: can't request RX DMA resource !\n"); | 2906 | release_mem_region(awacs_rsrc[0].start, |
2907 | awacs_rsrc[0].end - awacs_rsrc[0].start + 1); | ||
2908 | release_mem_region(awacs_rsrc[1].start, | ||
2909 | awacs_rsrc[1].end - awacs_rsrc[1].start + 1); | ||
2910 | printk(KERN_ERR "dmasound: can't request Rx DMA resource !\n"); | ||
2898 | return -ENODEV; | 2911 | return -ENODEV; |
2899 | } | 2912 | } |
2900 | 2913 | ||
2901 | awacs_beep_dev = input_allocate_device(); | 2914 | awacs_beep_dev = input_allocate_device(); |
2902 | if (!awacs_beep_dev) { | 2915 | if (!awacs_beep_dev) { |
2903 | release_OF_resource(io, 0); | 2916 | release_mem_region(awacs_rsrc[0].start, |
2904 | release_OF_resource(io, 1); | 2917 | awacs_rsrc[0].end - awacs_rsrc[0].start + 1); |
2905 | release_OF_resource(io, 2); | 2918 | release_mem_region(awacs_rsrc[1].start, |
2919 | awacs_rsrc[1].end - awacs_rsrc[1].start + 1); | ||
2920 | release_mem_region(awacs_rsrc[2].start, | ||
2921 | awacs_rsrc[2].end - awacs_rsrc[2].start + 1); | ||
2906 | printk(KERN_ERR "dmasound: can't allocate input device !\n"); | 2922 | printk(KERN_ERR "dmasound: can't allocate input device !\n"); |
2907 | return -ENOMEM; | 2923 | return -ENOMEM; |
2908 | } | 2924 | } |
@@ -2916,11 +2932,11 @@ printk("dmasound_pmac: couldn't find a Codec we can handle\n"); | |||
2916 | 2932 | ||
2917 | /* all OF versions I've seen use this value */ | 2933 | /* all OF versions I've seen use this value */ |
2918 | if (i2s_node) | 2934 | if (i2s_node) |
2919 | i2s = ioremap(io->addrs[0].address, 0x1000); | 2935 | i2s = ioremap(awacs_rsrc[0].start, 0x1000); |
2920 | else | 2936 | else |
2921 | awacs = ioremap(io->addrs[0].address, 0x1000); | 2937 | awacs = ioremap(awacs_rsrc[0].start, 0x1000); |
2922 | awacs_txdma = ioremap(io->addrs[1].address, 0x100); | 2938 | awacs_txdma = ioremap(awacs_rsrc[1].start, 0x100); |
2923 | awacs_rxdma = ioremap(io->addrs[2].address, 0x100); | 2939 | awacs_rxdma = ioremap(awacs_rsrc[2].start, 0x100); |
2924 | 2940 | ||
2925 | /* first of all make sure that the chip is powered up....*/ | 2941 | /* first of all make sure that the chip is powered up....*/ |
2926 | pmac_call_feature(PMAC_FTR_SOUND_CHIP_ENABLE, io, 0, 1); | 2942 | pmac_call_feature(PMAC_FTR_SOUND_CHIP_ENABLE, io, 0, 1); |
@@ -3083,9 +3099,10 @@ printk("dmasound_pmac: Awacs/Screamer Codec Mfct: %d Rev %d\n", mfg, rev); | |||
3083 | struct device_node* mio; | 3099 | struct device_node* mio; |
3084 | macio_base = NULL; | 3100 | macio_base = NULL; |
3085 | for (mio = io->parent; mio; mio = mio->parent) { | 3101 | for (mio = io->parent; mio; mio = mio->parent) { |
3086 | if (strcmp(mio->name, "mac-io") == 0 | 3102 | if (strcmp(mio->name, "mac-io") == 0) { |
3087 | && mio->n_addrs > 0) { | 3103 | struct resource r; |
3088 | macio_base = ioremap(mio->addrs[0].address, 0x40); | 3104 | if (of_address_to_resource(mio, 0, &r) == 0) |
3105 | macio_base = ioremap(r.start, 0x40); | ||
3089 | break; | 3106 | break; |
3090 | } | 3107 | } |
3091 | } | 3108 | } |
diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c index 9b2b00fdc1ae..a642e4cfcf45 100644 --- a/sound/ppc/pmac.c +++ b/sound/ppc/pmac.c | |||
@@ -803,21 +803,17 @@ static int snd_pmac_free(struct snd_pmac *chip) | |||
803 | iounmap(chip->playback.dma); | 803 | iounmap(chip->playback.dma); |
804 | if (chip->capture.dma) | 804 | if (chip->capture.dma) |
805 | iounmap(chip->capture.dma); | 805 | iounmap(chip->capture.dma); |
806 | #ifndef CONFIG_PPC64 | 806 | |
807 | if (chip->node) { | 807 | if (chip->node) { |
808 | int i; | 808 | int i; |
809 | |||
810 | for (i = 0; i < 3; i++) { | 809 | for (i = 0; i < 3; i++) { |
811 | if (chip->of_requested & (1 << i)) { | 810 | if (chip->requested & (1 << i)) |
812 | if (chip->is_k2) | 811 | release_mem_region(chip->rsrc[i].start, |
813 | release_OF_resource(chip->node->parent, | 812 | chip->rsrc[i].end - |
814 | i); | 813 | chip->rsrc[i].start + 1); |
815 | else | ||
816 | release_OF_resource(chip->node, i); | ||
817 | } | ||
818 | } | 814 | } |
819 | } | 815 | } |
820 | #endif /* CONFIG_PPC64 */ | 816 | |
821 | if (chip->pdev) | 817 | if (chip->pdev) |
822 | pci_dev_put(chip->pdev); | 818 | pci_dev_put(chip->pdev); |
823 | kfree(chip); | 819 | kfree(chip); |
@@ -991,6 +987,11 @@ static int __init snd_pmac_detect(struct snd_pmac *chip) | |||
991 | chip->can_byte_swap = 0; /* FIXME: check this */ | 987 | chip->can_byte_swap = 0; /* FIXME: check this */ |
992 | chip->control_mask = MASK_IEPC | 0x11;/* disable IEE */ | 988 | chip->control_mask = MASK_IEPC | 0x11;/* disable IEE */ |
993 | break; | 989 | break; |
990 | default: | ||
991 | printk(KERN_ERR "snd: Unknown layout ID 0x%x\n", | ||
992 | layout_id); | ||
993 | return -ENODEV; | ||
994 | |||
994 | } | 995 | } |
995 | } | 996 | } |
996 | prop = (unsigned int *)get_property(sound, "device-id", NULL); | 997 | prop = (unsigned int *)get_property(sound, "device-id", NULL); |
@@ -1175,46 +1176,69 @@ int __init snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return) | |||
1175 | } | 1176 | } |
1176 | 1177 | ||
1177 | np = chip->node; | 1178 | np = chip->node; |
1179 | chip->requested = 0; | ||
1178 | if (chip->is_k2) { | 1180 | if (chip->is_k2) { |
1179 | if (np->parent->n_addrs < 2 || np->n_intrs < 3) { | 1181 | static char *rnames[] = { |
1182 | "Sound Control", "Sound DMA" }; | ||
1183 | if (np->n_intrs < 3) { | ||
1180 | err = -ENODEV; | 1184 | err = -ENODEV; |
1181 | goto __error; | 1185 | goto __error; |
1182 | } | 1186 | } |
1183 | for (i = 0; i < 2; i++) { | 1187 | for (i = 0; i < 2; i ++) { |
1184 | #ifndef CONFIG_PPC64 | 1188 | if (of_address_to_resource(np->parent, i, |
1185 | static char *name[2] = { "- Control", "- DMA" }; | 1189 | &chip->rsrc[i])) { |
1186 | if (! request_OF_resource(np->parent, i, name[i])) { | 1190 | printk(KERN_ERR "snd: can't translate rsrc " |
1187 | snd_printk(KERN_ERR "pmac: can't request resource %d!\n", i); | 1191 | " %d (%s)\n", i, rnames[i]); |
1192 | err = -ENODEV; | ||
1193 | goto __error; | ||
1194 | } | ||
1195 | if (request_mem_region(chip->rsrc[i].start, | ||
1196 | chip->rsrc[i].end - | ||
1197 | chip->rsrc[i].start + 1, | ||
1198 | rnames[i]) == NULL) { | ||
1199 | printk(KERN_ERR "snd: can't request rsrc " | ||
1200 | " %d (%s: 0x%08lx:%08lx)\n", | ||
1201 | i, rnames[i], chip->rsrc[i].start, | ||
1202 | chip->rsrc[i].end); | ||
1188 | err = -ENODEV; | 1203 | err = -ENODEV; |
1189 | goto __error; | 1204 | goto __error; |
1190 | } | 1205 | } |
1191 | chip->of_requested |= (1 << i); | 1206 | chip->requested |= (1 << i); |
1192 | #endif /* CONFIG_PPC64 */ | ||
1193 | ctrl_addr = np->parent->addrs[0].address; | ||
1194 | txdma_addr = np->parent->addrs[1].address; | ||
1195 | rxdma_addr = txdma_addr + 0x100; | ||
1196 | } | 1207 | } |
1197 | 1208 | ctrl_addr = chip->rsrc[0].start; | |
1209 | txdma_addr = chip->rsrc[1].start; | ||
1210 | rxdma_addr = txdma_addr + 0x100; | ||
1198 | } else { | 1211 | } else { |
1199 | if (np->n_addrs < 3 || np->n_intrs < 3) { | 1212 | static char *rnames[] = { |
1213 | "Sound Control", "Sound Tx DMA", "Sound Rx DMA" }; | ||
1214 | if (np->n_intrs < 3) { | ||
1200 | err = -ENODEV; | 1215 | err = -ENODEV; |
1201 | goto __error; | 1216 | goto __error; |
1202 | } | 1217 | } |
1203 | 1218 | for (i = 0; i < 3; i ++) { | |
1204 | for (i = 0; i < 3; i++) { | 1219 | if (of_address_to_resource(np->parent, i, |
1205 | #ifndef CONFIG_PPC64 | 1220 | &chip->rsrc[i])) { |
1206 | static char *name[3] = { "- Control", "- Tx DMA", "- Rx DMA" }; | 1221 | printk(KERN_ERR "snd: can't translate rsrc " |
1207 | if (! request_OF_resource(np, i, name[i])) { | 1222 | " %d (%s)\n", i, rnames[i]); |
1208 | snd_printk(KERN_ERR "pmac: can't request resource %d!\n", i); | 1223 | err = -ENODEV; |
1224 | goto __error; | ||
1225 | } | ||
1226 | if (request_mem_region(chip->rsrc[i].start, | ||
1227 | chip->rsrc[i].end - | ||
1228 | chip->rsrc[i].start + 1, | ||
1229 | rnames[i]) == NULL) { | ||
1230 | printk(KERN_ERR "snd: can't request rsrc " | ||
1231 | " %d (%s: 0x%08lx:%08lx)\n", | ||
1232 | i, rnames[i], chip->rsrc[i].start, | ||
1233 | chip->rsrc[i].end); | ||
1209 | err = -ENODEV; | 1234 | err = -ENODEV; |
1210 | goto __error; | 1235 | goto __error; |
1211 | } | 1236 | } |
1212 | chip->of_requested |= (1 << i); | 1237 | chip->requested |= (1 << i); |
1213 | #endif /* CONFIG_PPC64 */ | ||
1214 | ctrl_addr = np->addrs[0].address; | ||
1215 | txdma_addr = np->addrs[1].address; | ||
1216 | rxdma_addr = np->addrs[2].address; | ||
1217 | } | 1238 | } |
1239 | ctrl_addr = chip->rsrc[0].start; | ||
1240 | txdma_addr = chip->rsrc[1].start; | ||
1241 | rxdma_addr = chip->rsrc[2].start; | ||
1218 | } | 1242 | } |
1219 | 1243 | ||
1220 | chip->awacs = ioremap(ctrl_addr, 0x1000); | 1244 | chip->awacs = ioremap(ctrl_addr, 0x1000); |
@@ -1266,9 +1290,11 @@ int __init snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return) | |||
1266 | } else if (chip->is_pbook_G3) { | 1290 | } else if (chip->is_pbook_G3) { |
1267 | struct device_node* mio; | 1291 | struct device_node* mio; |
1268 | for (mio = chip->node->parent; mio; mio = mio->parent) { | 1292 | for (mio = chip->node->parent; mio; mio = mio->parent) { |
1269 | if (strcmp(mio->name, "mac-io") == 0 | 1293 | if (strcmp(mio->name, "mac-io") == 0) { |
1270 | && mio->n_addrs > 0) { | 1294 | struct resource r; |
1271 | chip->macio_base = ioremap(mio->addrs[0].address, 0x40); | 1295 | if (of_address_to_resource(mio, 0, &r) == 0) |
1296 | chip->macio_base = | ||
1297 | ioremap(r.start, 0x40); | ||
1272 | break; | 1298 | break; |
1273 | } | 1299 | } |
1274 | } | 1300 | } |
diff --git a/sound/ppc/pmac.h b/sound/ppc/pmac.h index 086da7a18909..3a9bd4dbb9a6 100644 --- a/sound/ppc/pmac.h +++ b/sound/ppc/pmac.h | |||
@@ -113,7 +113,8 @@ struct snd_pmac { | |||
113 | unsigned int initialized : 1; | 113 | unsigned int initialized : 1; |
114 | unsigned int feature_is_set : 1; | 114 | unsigned int feature_is_set : 1; |
115 | 115 | ||
116 | unsigned int of_requested; | 116 | unsigned int requested; |
117 | struct resource rsrc[3]; | ||
117 | 118 | ||
118 | int num_freqs; | 119 | int num_freqs; |
119 | int *freq_table; | 120 | int *freq_table; |