aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
authorMengdong Lin <mengdong.lin@intel.com>2013-06-25 05:58:49 -0400
committerTakashi Iwai <tiwai@suse.de>2013-06-25 02:13:56 -0400
commit7295b26438ec018a16159e45d514e1c94c554c5b (patch)
tree7727f97b3f7ab33a97435447b9bd11c9c6002933 /sound/pci
parent8b2c7a5c404d7accb9790e1d5a1a518dd0a77a5e (diff)
ALSA: hda - clean up code to reset hda link
This patch is a cleanup to the previous patch "reset hda link during system/ runtime suspend". In this patch - azx_enter_link_reset() and azx_exit_link_reset() are defined for entering and exiting the link reset respectively. azx_link_reset() is no longer used and replaced by azx_enter_link_reset(). - azx_reset() reuses the above two new functions for a link reset cycle Signed-off-by: Mengdong Lin <mengdong.lin@intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/hda/hda_intel.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 9f110c7ba092..f39de9055097 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -1121,7 +1121,7 @@ static void azx_load_dsp_cleanup(struct hda_bus *bus,
1121#endif 1121#endif
1122 1122
1123/* enter link reset */ 1123/* enter link reset */
1124static void azx_reset_link(struct azx *chip) 1124static void azx_enter_link_reset(struct azx *chip)
1125{ 1125{
1126 unsigned long timeout; 1126 unsigned long timeout;
1127 1127
@@ -1134,11 +1134,22 @@ static void azx_reset_link(struct azx *chip)
1134 usleep_range(500, 1000); 1134 usleep_range(500, 1000);
1135} 1135}
1136 1136
1137/* reset codec link */ 1137/* exit link reset */
1138static int azx_reset(struct azx *chip, int full_reset) 1138static void azx_exit_link_reset(struct azx *chip)
1139{ 1139{
1140 unsigned long timeout; 1140 unsigned long timeout;
1141 1141
1142 azx_writeb(chip, GCTL, azx_readb(chip, GCTL) | ICH6_GCTL_RESET);
1143
1144 timeout = jiffies + msecs_to_jiffies(100);
1145 while (!azx_readb(chip, GCTL) &&
1146 time_before(jiffies, timeout))
1147 usleep_range(500, 1000);
1148}
1149
1150/* reset codec link */
1151static int azx_reset(struct azx *chip, int full_reset)
1152{
1142 if (!full_reset) 1153 if (!full_reset)
1143 goto __skip; 1154 goto __skip;
1144 1155
@@ -1146,12 +1157,7 @@ static int azx_reset(struct azx *chip, int full_reset)
1146 azx_writeb(chip, STATESTS, STATESTS_INT_MASK); 1157 azx_writeb(chip, STATESTS, STATESTS_INT_MASK);
1147 1158
1148 /* reset controller */ 1159 /* reset controller */
1149 azx_writel(chip, GCTL, azx_readl(chip, GCTL) & ~ICH6_GCTL_RESET); 1160 azx_enter_link_reset(chip);
1150
1151 timeout = jiffies + msecs_to_jiffies(100);
1152 while (azx_readb(chip, GCTL) &&
1153 time_before(jiffies, timeout))
1154 usleep_range(500, 1000);
1155 1161
1156 /* delay for >= 100us for codec PLL to settle per spec 1162 /* delay for >= 100us for codec PLL to settle per spec
1157 * Rev 0.9 section 5.5.1 1163 * Rev 0.9 section 5.5.1
@@ -1159,12 +1165,7 @@ static int azx_reset(struct azx *chip, int full_reset)
1159 usleep_range(500, 1000); 1165 usleep_range(500, 1000);
1160 1166
1161 /* Bring controller out of reset */ 1167 /* Bring controller out of reset */
1162 azx_writeb(chip, GCTL, azx_readb(chip, GCTL) | ICH6_GCTL_RESET); 1168 azx_exit_link_reset(chip);
1163
1164 timeout = jiffies + msecs_to_jiffies(100);
1165 while (!azx_readb(chip, GCTL) &&
1166 time_before(jiffies, timeout))
1167 usleep_range(500, 1000);
1168 1169
1169 /* Brent Chartrand said to wait >= 540us for codecs to initialize */ 1170 /* Brent Chartrand said to wait >= 540us for codecs to initialize */
1170 usleep_range(1000, 1200); 1171 usleep_range(1000, 1200);
@@ -2908,7 +2909,7 @@ static int azx_suspend(struct device *dev)
2908 if (chip->initialized) 2909 if (chip->initialized)
2909 snd_hda_suspend(chip->bus); 2910 snd_hda_suspend(chip->bus);
2910 azx_stop_chip(chip); 2911 azx_stop_chip(chip);
2911 azx_reset_link(chip); 2912 azx_enter_link_reset(chip);
2912 if (chip->irq >= 0) { 2913 if (chip->irq >= 0) {
2913 free_irq(chip->irq, chip); 2914 free_irq(chip->irq, chip);
2914 chip->irq = -1; 2915 chip->irq = -1;
@@ -2961,7 +2962,7 @@ static int azx_runtime_suspend(struct device *dev)
2961 struct azx *chip = card->private_data; 2962 struct azx *chip = card->private_data;
2962 2963
2963 azx_stop_chip(chip); 2964 azx_stop_chip(chip);
2964 azx_reset_link(chip); 2965 azx_enter_link_reset(chip);
2965 azx_clear_irq_pending(chip); 2966 azx_clear_irq_pending(chip);
2966 return 0; 2967 return 0;
2967} 2968}