From patchwork Sun Apr 28 09:37:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 13645971 Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC72E55E49 for ; Sun, 28 Apr 2024 09:37:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.17.22 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714297051; cv=none; b=dEIXbpgdMoWR/eXt0dCUetKZs7vJVm8K+NfOPdnT90dUTQdCG/pYlwM9utwnnqBvAlkEjaG+GComOKaCHOC6JPwAmCxK87rPaSLT7deA3wTCRnuun94rBNVIPoxNZlfoZ5fL1l5Nz0P6ohMCgEUeunc1RhXhiGnrmm6puUw2d1I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714297051; c=relaxed/simple; bh=nColKKzV0soArb61v4X9w8QJe/4erO6BS6uJMMwIgVk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=a2E/EvY79naCuyADq1fxBl/hsh8akdOtRMFtNiX5zQFlR/iN/P9Kvkl0V9LChvIvsDX2YC5jBTVQAq4LOmKHfmZbUfXcH1NyWYlxfhcka4Df39w8qerrtZq4EeQTi3JRrXCjqNE6z8GPGwckplemcswxLGbs/Sbg7qZtNA9co6w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de; spf=pass smtp.mailfrom=gmx.de; dkim=pass (2048-bit key) header.d=gmx.de header.i=oswald.buddenhagen@gmx.de header.b=heL7XUy1; arc=none smtp.client-ip=212.227.17.22 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmx.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.de header.i=oswald.buddenhagen@gmx.de header.b="heL7XUy1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1714297038; x=1714901838; i=oswald.buddenhagen@gmx.de; bh=1ZmXywRbewDSRLH05bIq+ZhQEmKuuatpJW1xITotxsU=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:Message-ID:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=heL7XUy18u2vxlALHoNeHuwm3Wv8TzSJgx03BZgiiHa0itdpbFN8FoGbqeQBoWIq DA+lAGvv9HArQCuelVSUfcjOeqhbDCS3wUUzg+IY6IeKDzxpUo/cz2icv91GbJM04 O2Qr4TCFQ5n2Dtn8hL+nAT6yG3NuKyD8OXWYVXXYKEJayuoRu566MnbW8ORbW/Ed7 Y43GDsfsZpKIxTi1h2qhiY7ZUxIjwnWj2T3+UpSvGc7wDwJVQiPCOnuCSmZIPNGNl Hir4HrZjXG9d5t6SvosmaCR0u92nXV+qDzUcmE0ee+eOX2x8eWouJ3aDQqk7IErxa 99pcEIKRoZtDlzrQ2A== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.124]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1M3UV8-1s0T0O1k5S-001EiD; Sun, 28 Apr 2024 11:37:18 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1s10yD-Q8q-00; Sun, 28 Apr 2024 11:37:17 +0200 From: Oswald Buddenhagen To: linux-sound@vger.kernel.org Cc: Takashi Iwai , Jaroslav Kysela , Pietro Caruso Subject: [PATCH v2 1/4] ALSA: emu10k1: simplify E-MU card FPGA reset sequence Date: Sun, 28 Apr 2024 11:37:14 +0200 Message-ID: <20240428093717.3198716-2-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.44.0.701.g2cf7baacf3.dirty In-Reply-To: <20240428093717.3198716-1-oswald.buddenhagen@gmx.de> References: <20240428093717.3198716-1-oswald.buddenhagen@gmx.de> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Provags-ID: V03:K1:OuQjrX5K2N8DLhb8mOnm6Iqb8oP3FcAHLr/wFIhznIbkTA4OOGF gUouPeTJzzNeG6CqoiK31oDe6QezT8MRgCdDVDSDek4vQd0jZ1oHhio3CQ5g+WTrcX6QS6p Rdz1BMvCB5SbatSnh95eIV5dk9LSyxo0+AwPYZXM3Rsgc18kDEiSDb4j67L/6QG7tLBTR24 9LpFt3aEkfflHBey82S6A== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:BRFh0FJCGo4=;GF2rffgEF6i0eLqHxWeRZsEcpw2 EW/SUGb0dlF0Tii9CC8f8N4U6V/ZCaM47iIHyUXDV/oU6nd9P1T/qgBKZrgDssp4uBhR4kTuP W07YnuWEtfAAWJvac7o2ZAsj5u7ueNjBP9fRx6f3OHQwG42hw4aR0mdQzT/NBdat1j/YPDTG/ bSeNvHaqxhTk0NLjVq1/HD5NzORH3UstqYPTdGa03tftsEihv2uqUoqESKQxJreJ4/egSg85f tSrtXwq03WMbicFg9PsR+5taUePs7Ki3EgiuwycdTOt65gbJrgwzltSww0bxFKR67PPFhKteR /d2ba/sF+/6K5ia6rQV0UYUbl947w5Q4xe+0C5y8QPqshHRViIiUlX3gcKus8XZrDaSmZ5bqO OmCSSwcXehaqL67PWKE4nGMoQESQy8+hcDme0aYiKeEy9AnQYdyzeiRUEbssyoU3nHgPyVJej f6FjU3pDOoODKeoxELPCf6tji2R2HaAKY8BWCZNPj5UQ+bAShJdAWgGoM+RhD3LL/If9JiPZT /nHIYrwr2OGkuXPQ4F/MH64O3BJB6xibrVAxJH6FC3mnI8bUeSuhyEwTWpok0GN19R8AR8e5X hiPb12cLY1nEEpFUGyHShES77N+Vypu25NrkkNGfLPmcogtLKuLo9UX+i4qMBCWg6A2Aq9d/p 0iiEz2a1gl7U4CJSf98e3gV2eaWWGhqljZSSnPOfc1qAwDez1CCFVQuXeKi5Wu5NTfbizmkws xPItnU85lnTC4aAjkJHNbFTjWQbf/CvBWbeasUVL7zHQ299fyZYxjCOje/lWx4Dcn/LSYBoAW 4wcJD0fGWq2dlQpplRnKzm/RKSHkC/gx65EYuBYZQcjmg= Firstly, it is pointless to explicitly disable the power to the dock prior to resetting the FPGA, as the latter will do the former anyway. Secondly, it doesn't make much sense to check whether the FPGA is already programmed. It's much simpler to just presume it is, and issue the self-reset command. If it isn't, the effect isn't worse than the checks themselves. As a side effect, we lose the info if the reset fails, but there is no plausible way how that could happen unless the card burns out while operating, and in that case we'll detect a firmware upload failure a bit later anyway. Signed-off-by: Oswald Buddenhagen --- sound/pci/emu10k1/emu10k1_main.c | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index 8ccc0178360c..353dd3b61c61 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c @@ -864,28 +864,9 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 *emu) snd_emu1010_fpga_lock(emu); - /* Disable 48Volt power to Audio Dock */ - snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_PWR, 0); - - /* ID, should read & 0x7f = 0x55. (Bit 7 is the IRQ bit) */ - snd_emu1010_fpga_read(emu, EMU_HANA_ID, ®); - dev_dbg(emu->card->dev, "reg1 = 0x%x\n", reg); - if ((reg & 0x3f) == 0x15) { - /* FPGA netlist already present so clear it */ - /* Return to programming mode */ - - snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, EMU_HANA_FPGA_CONFIG_HANA); - } - snd_emu1010_fpga_read(emu, EMU_HANA_ID, ®); - dev_dbg(emu->card->dev, "reg2 = 0x%x\n", reg); - if ((reg & 0x3f) == 0x15) { - /* FPGA failed to return to programming mode */ - dev_info(emu->card->dev, - "emu1010: FPGA failed to return to programming mode\n"); - return -ENODEV; - } - dev_info(emu->card->dev, "emu1010: EMU_HANA_ID = 0x%x\n", reg); - + dev_info(emu->card->dev, "emu1010: Loading Hana Firmware\n"); + snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, + EMU_HANA_FPGA_CONFIG_HANA); err = snd_emu1010_load_firmware(emu, 0, &emu->firmware); if (err < 0) { dev_info(emu->card->dev, "emu1010: Loading Firmware failed\n"); From patchwork Sun Apr 28 09:37:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 13645962 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D08EDE56C for ; Sun, 28 Apr 2024 09:37:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.17.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714297047; cv=none; b=TLjEHxy5gKJ+L+IMSAfW5Ld1EEZY+imfO3QTgpkSHCdgbrvMIJP014BdvcwY5TfyGUT1al7KaEnR90g7iEu0+MXzHA2Reqck/wjBtSutqlZKmJREj0Uzl+qCpkyn0W+n5DB4vJHLd8YP2HO/kvQGdAt2ypx4PvLTwJkZpYHTRLg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714297047; c=relaxed/simple; bh=FZlUkxsA3h9RSUCax5XbxtSOrOZFere+WoEZUnYq60g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eDIxdT2AKlvCQqa2gpIMy2eiHGim75/tko2jeSa5/JNJ4dLO0Q1LJzoE1EeAoIXH2m3GcjLCi5xi4IHL4Ww6qBM28g+27R1jryT+6rxKMY2NIw8pxM2rfkrTxzTiU4w5lHtxEeFiOTPg6PB8Jh8tQ4mjPSrrdUXP3FXrjYhJK1s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de; spf=pass smtp.mailfrom=gmx.de; dkim=pass (2048-bit key) header.d=gmx.de header.i=oswald.buddenhagen@gmx.de header.b=SGhgVoYT; arc=none smtp.client-ip=212.227.17.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmx.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.de header.i=oswald.buddenhagen@gmx.de header.b="SGhgVoYT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1714297038; x=1714901838; i=oswald.buddenhagen@gmx.de; bh=oZeTDnMRPB8enV0FVGxnayR+kaCJpbjx5s1efV04cw8=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:Message-ID:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=SGhgVoYTsLho4mHOpr8fotwVV0EGEoO6PlzNL6XSRIEtLa0MRmNGGAMh/WiwpcSS JrQusPaPxBTm2/vihraP6+SA8KGEXtzBbSxiWGyczHaLPFyZmqVvv7EhrdtmlxWj1 rrBisGJfFbf2oWq9MzvMrADwR1aS5Ou5NMXy55eGhGeezhkYDbi9SrU82Ukppl+lM p3gSF8Rm19rCfTNXnDxNEPgtw6GN+eUqvFzBKchTEESFKfiOcswAEtc4q/33D2dvv JWy6awLqP7L/3n9G/qqUBrsdsYnsaDhN1dEg5NdouQ5lGg2I/57Git/M+MJhRcDE4 LJey4yII8zNB2xFmeg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.124]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MGyxX-1rwMPt1oUl-00E9Bo; Sun, 28 Apr 2024 11:37:18 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1s10yD-Q8v-00; Sun, 28 Apr 2024 11:37:17 +0200 From: Oswald Buddenhagen To: linux-sound@vger.kernel.org Cc: Takashi Iwai , Jaroslav Kysela , Pietro Caruso Subject: [PATCH v2 2/4] ALSA: emu10k1: make snd_emu1010_load_firmware_entry() void Date: Sun, 28 Apr 2024 11:37:15 +0200 Message-ID: <20240428093717.3198716-3-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.44.0.701.g2cf7baacf3.dirty In-Reply-To: <20240428093717.3198716-1-oswald.buddenhagen@gmx.de> References: <20240428093717.3198716-1-oswald.buddenhagen@gmx.de> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Provags-ID: V03:K1:R9s5UgxdC6tTqxbO8ZqROgkw3e4OE6DUUv5C9V8bvp/ULVoRtFb 7yHNEG4SqIrD+E39b+N0/mkOi0t6yJV1LpCFRXbYr2FAK9FKxSWGQbwJHTHge/YrO3ulpar 5BlN913U3fecgHVQVrgJfXZmBjMZ6CHXyUx/K1PQWgTUtwmdukBRz9a7dJ135kONDyVBQ8L IO5nmvAjgt7+DAl7bI25w== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:ra9LuY7vVxI=;qcSKbtkAsiNFSFzV0rXzX2jYCE+ XbG3l4O6QHjYkMVAnV2XXqaFvoP74l5RjHV4FqZT4dT237AseJkIRlU5R0FCJRtvJ+mRtVyKC xdnQhYFzV2hZ31USK74bxsJHYMRpkVapgBslH6yH1MdpVEfKsWP1/YHD9sG7XRVPhaRH/nW1u D2dWxNIgkf9Ix7uoQW9ZCOuvq3QOT+2QSG8AjlFwA+sESbw0eGZNW963twNr1I0pOVcVcapy4 TyoFHzsbGlEfxihO9Ow+Gtdt2BtSxhe6QNZbkUoRU7tZshFPpxfy46TaTHwJ99m3nd2Mnd1DY /oOx5l77VM0fipP4UZeU58ieo+oJlh3g3ml/BwL3JyuYOsWEB8uCmtB7LB7AXKTY90qzlKDbP cc0yQLKpBRrh8orts+FicbdMN03Aif/zm+5uFnuMYSVWt50VL6dJs13Ik56WU4fGkIAeew3XB iuRpfFpNkheBk6IBkFU8HOBMEUQFMTY/nTVzELnx9VofpEMFPtGtj5m1YnI5Z5ZQDkBvvi5SB dsiCWdUPM9prXW+Wxa5EGiefnHLWb+R7B3R3QUqocUDqv9QGOgpn5CVMNboL3NELavVsxmbFP /y3RCeGPc+HZjL0/bsg3WlgeRTwARQdiWuSRtkXZR4Q/TS7ozQkoVIQDh9Y7hSw47fNuqWicv zVL6R8JDYyMAtXyly0oaPJxcLmb0WTWNroE4Vmt77sRJFlJ7YRpIP9YGJPQxQwyF0YJE5D5Ef IxOm4QzalScO7HGTsYNXSzF5sOIYsJMF4tyAxPx651zuZviHNcytaz5CcnoLhkOpo86LPMYT5 /lBtsMN0JSDmXZS2Z6ed82mz8cioKlvfBZJw/UL3JfMQA= There is only one call site, and there we already know that we actually have a firmware. Signed-off-by: Oswald Buddenhagen --- sound/pci/emu10k1/emu10k1_main.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index 353dd3b61c61..ec010971a220 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c @@ -652,17 +652,14 @@ static int snd_emu10k1_cardbus_init(struct snd_emu10k1 *emu) return 0; } -static int snd_emu1010_load_firmware_entry(struct snd_emu10k1 *emu, +static void snd_emu1010_load_firmware_entry(struct snd_emu10k1 *emu, const struct firmware *fw_entry) { int n, i; u16 reg; u8 value; __always_unused u16 write_post; - if (!fw_entry) - return -EIO; - /* The FPGA is a Xilinx Spartan IIE XC2S50E */ /* On E-MU 0404b it is a Xilinx Spartan III XC3S50 */ /* GPIO7 -> FPGA PGMN @@ -694,8 +691,6 @@ static int snd_emu1010_load_firmware_entry(struct snd_emu10k1 *emu, outw(0x10, emu->port + A_GPIO); write_post = inw(emu->port + A_GPIO); spin_unlock_irq(&emu->emu_lock); - - return 0; } /* firmware file names, per model, init-fw and dock-fw (optional) */ @@ -729,7 +724,8 @@ static int snd_emu1010_load_firmware(struct snd_emu10k1 *emu, int dock, return err; } - return snd_emu1010_load_firmware_entry(emu, *fw); + snd_emu1010_load_firmware_entry(emu, *fw); + return 0; } static void snd_emu1010_load_dock_firmware(struct snd_emu10k1 *emu) From patchwork Sun Apr 28 09:37:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 13645961 Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D08B979E1 for ; Sun, 28 Apr 2024 09:37:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.17.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714297047; cv=none; b=cDjCy3FYu417YltSaDgFI2GM4FwiRTE5LBGoEeynsddHmIOIiD+jfjhNOaJTdbvj9772Z2cnlcVT8Iih7n1fGW2HMDjZDC1RZPbqc/JfmhIsYVImwWsYWUC0IJ1qiibZ5ODfJe8JT93mHt4KNvqwKQLHfR0GZ5iZd45cuurj1is= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714297047; c=relaxed/simple; bh=Pw7/Sq7a0fRT2V37KZymqzEADXthPFxUNLQTq//mV9Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kKinJHW5HzJHDbnmPdXkSD2yrJKImCgQaXww+Tj8R/fQ+zE+8ZN+3zxGPwaE5rfpwHOIzIzU9czN63ZUSzENUieEhie2r9j46Y/EXFCZoDtai6AoCbhaqR5Cqcjwm/WDcYu9MXYuYKZS1myIjk3GcEpH5lcaSzBw/Xmbiqkg9w0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de; spf=pass smtp.mailfrom=gmx.de; dkim=pass (2048-bit key) header.d=gmx.de header.i=oswald.buddenhagen@gmx.de header.b=pEvu1zi1; arc=none smtp.client-ip=212.227.17.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmx.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.de header.i=oswald.buddenhagen@gmx.de header.b="pEvu1zi1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1714297038; x=1714901838; i=oswald.buddenhagen@gmx.de; bh=UKOQG/UCIJ9Tvj5eZzBfjFmYvKPDrPkyqUg/JXaktBA=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:Message-ID:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=pEvu1zi1fEG16hzyrcIVHNO/g+PZ/TWUSVZ6AKCl5SCR8m281mFPcqxDNhF2UPXE RBePnnLqWQWuvZzUy2qxo7bMq0pLXWvccMQuDRj0Oq0M7KiH4YA3AcJTgsUbGy2wE fCDvRfZPuTO4X19YS6lfmInP3kLwLDkeLrF5cl6RxQd2WW7G1+lQBWDMtgoRtjUaG Rp12jY9ZBo9QkMQ6R2ElkA1aimzZUGOC5KPzj7U6W1BqEDd1saTBItNtRteFTJlFJ 62QdbnV77uJ45k4M0yhc89DykAFqNbnwS1Q2oixgww8pPdqM1IwpFx+29nApi7nMD mTAZOIo0nHTvbkUlkg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.124]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MxUrx-1suT0Z1cDZ-00zPv8; Sun, 28 Apr 2024 11:37:18 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1s10yD-Q90-00; Sun, 28 Apr 2024 11:37:17 +0200 From: Oswald Buddenhagen To: linux-sound@vger.kernel.org Cc: Takashi Iwai , Jaroslav Kysela , Pietro Caruso Subject: [PATCH v2 3/4] ALSA: emu10k1: move snd_emu1010_load_firmware_entry() to io.c Date: Sun, 28 Apr 2024 11:37:16 +0200 Message-ID: <20240428093717.3198716-4-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.44.0.701.g2cf7baacf3.dirty In-Reply-To: <20240428093717.3198716-1-oswald.buddenhagen@gmx.de> References: <20240428093717.3198716-1-oswald.buddenhagen@gmx.de> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Provags-ID: V03:K1:AeOJoEX1dOF9ZNOgy2s+iU8HmG9Y9Qd2Y8P2mf/QuD4ywkXmdlv oLDmeUzL5SJNpF5ndE+I+hDqk+0sp55Dq+p3f74dcRHNmPM8HERDyplfcl7CbMCtpUkkz6+ IrBxwbCY6sw8ReE+FZjDPVEejVnmVa/T8RMEQAdwO0ZoANB++X0Mwyqd3Zdnz+wR10Vchcd PeuBnD6UdVkFF6/BENxAQ== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:d+gWKwRv7p0=;6oC6aOmVPb3VJ+sNZayPQtzav7P rsesvO3Y/8GBu6il20H/S7CXU3ef4ZhF8kQGQFu8XEbHwTRdSDxR9CllrTDD8C8+Y0dARh6Xg AI6fTuB1JrV3e8yq2IwSsH6c/8UswFL01LJz8JGPJZaIWvF6K080DtuIsZqcd7dNCTFFPgyof ck9seEUjorPCIQZcrYeBf+5BHIJFXoLB1yXfiUQzwU/0cZWU2Bp9YiBwTZpAAZvTi8M9oJxm3 YB2iGZSsJjS9YWk5C4UD8PCQw+m1D94hLwJSM1SIhABN/5fd3t2rNmQeGGBXbjZlCfUIe97fN xrFQRozGdUzHSq//2aX8queuPFw/0is6y6wiU/ct8mWPtQi9trs36ynu85rmePVHenoOeNoK5 V5/IKyHrsCOaQ62XOfjQ3F5vhqmjfMsl4zY8LMaWxI3rY4+wnyJGYj+VnAm31sS5eIsDtKIqe pC8co6wdYfTaxtrcssV164uzRU7XqL49rdke0StHFV+ypzd1ce08MGjSOK+jPti4tBu/K7m0R uug8w3HcMfnftUVgTQlKIcFBg6IzH3pdolq9bHGAaQFf3IB1JCEOfjCIVZ+b97YkzWJ6Y/Dvq fgQ10OpxPlvHYiC9z2RwTveskV2drjfTMk/XehbUDB+YrTH6CBu8cK3sWAjrQAues/3BGSl2P 0JAekUHKUGW6IWV+irvNCc/dGykzXs06yoSfZXZDxlrRI7LClZqz2evWxpCh+JpOtACPbEh8G NzuMaoIYkIw+2cm2K0HOajdHkHb6XA6/EQhJ7DEhI7e4UkGRr8hI/9XCAfyeUXog7SjqHAea4 R5u/fMkEtEsSQsZO1DuHGJ79fg+WUcNmdbOZ/1sfy9i2g= It is a low-level I/O access function, so io.c is the natural place for it. While we're moving the code, reduce the scope of some variables, use compound assignment operators, and add/adjust some comments. Signed-off-by: Oswald Buddenhagen --- include/sound/emu10k1.h | 1 + sound/pci/emu10k1/emu10k1_main.c | 41 --------------------------- sound/pci/emu10k1/io.c | 48 ++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 41 deletions(-) diff --git a/include/sound/emu10k1.h b/include/sound/emu10k1.h index 234b5baea69c..2856f4717c93 100644 --- a/include/sound/emu10k1.h +++ b/include/sound/emu10k1.h @@ -1843,6 +1843,7 @@ void snd_emu1010_fpga_link_dst_src_write(struct snd_emu10k1 *emu, u32 dst, u32 s u32 snd_emu1010_fpga_link_dst_src_read(struct snd_emu10k1 *emu, u32 dst); int snd_emu1010_get_raw_rate(struct snd_emu10k1 *emu, u8 src); void snd_emu1010_update_clock(struct snd_emu10k1 *emu); +void snd_emu1010_load_firmware_entry(struct snd_emu10k1 *emu, const struct firmware *fw_entry); unsigned int snd_emu10k1_efx_read(struct snd_emu10k1 *emu, unsigned int pc); void snd_emu10k1_intr_enable(struct snd_emu10k1 *emu, unsigned int intrenb); void snd_emu10k1_intr_disable(struct snd_emu10k1 *emu, unsigned int intrenb); diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index ec010971a220..c8aa4143ac4f 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c @@ -652,47 +652,6 @@ static int snd_emu10k1_cardbus_init(struct snd_emu10k1 *emu) return 0; } -static void snd_emu1010_load_firmware_entry(struct snd_emu10k1 *emu, - const struct firmware *fw_entry) -{ - int n, i; - u16 reg; - u8 value; - __always_unused u16 write_post; - - /* The FPGA is a Xilinx Spartan IIE XC2S50E */ - /* On E-MU 0404b it is a Xilinx Spartan III XC3S50 */ - /* GPIO7 -> FPGA PGMN - * GPIO6 -> FPGA CCLK - * GPIO5 -> FPGA DIN - * FPGA CONFIG OFF -> FPGA PGMN - */ - spin_lock_irq(&emu->emu_lock); - outw(0x00, emu->port + A_GPIO); /* Set PGMN low for 100uS. */ - write_post = inw(emu->port + A_GPIO); - udelay(100); - outw(0x80, emu->port + A_GPIO); /* Leave bit 7 set during netlist setup. */ - write_post = inw(emu->port + A_GPIO); - udelay(100); /* Allow FPGA memory to clean */ - for (n = 0; n < fw_entry->size; n++) { - value = fw_entry->data[n]; - for (i = 0; i < 8; i++) { - reg = 0x80; - if (value & 0x1) - reg = reg | 0x20; - value = value >> 1; - outw(reg, emu->port + A_GPIO); - write_post = inw(emu->port + A_GPIO); - outw(reg | 0x40, emu->port + A_GPIO); - write_post = inw(emu->port + A_GPIO); - } - } - /* After programming, set GPIO bit 4 high again. */ - outw(0x10, emu->port + A_GPIO); - write_post = inw(emu->port + A_GPIO); - spin_unlock_irq(&emu->emu_lock); -} - /* firmware file names, per model, init-fw and dock-fw (optional) */ static const char * const firmware_names[5][2] = { [EMU_MODEL_EMU1010] = { diff --git a/sound/pci/emu10k1/io.c b/sound/pci/emu10k1/io.c index f4a1c2d4b078..fafa299efa5c 100644 --- a/sound/pci/emu10k1/io.c +++ b/sound/pci/emu10k1/io.c @@ -422,6 +422,54 @@ void snd_emu1010_update_clock(struct snd_emu10k1 *emu) snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_LEDS_2, leds); } +void snd_emu1010_load_firmware_entry(struct snd_emu10k1 *emu, + const struct firmware *fw_entry) +{ + __always_unused u16 write_post; + + // On E-MU 1010 rev1 the FPGA is a Xilinx Spartan IIE XC2S50E. + // On E-MU 0404b it is a Xilinx Spartan III XC3S50. + // The wiring is as follows: + // GPO7 -> FPGA input & 1K resistor -> FPGA /PGMN <- FPGA output + // In normal operation, the active low reset line is held up by + // an FPGA output, while the GPO pin performs its duty as control + // register access strobe signal. Writing the respective bit to + // EMU_HANA_FPGA_CONFIG puts the FPGA output into high-Z mode, at + // which point the GPO pin can control the reset line through the + // resistor. + // GPO6 -> FPGA CCLK & FPGA input + // GPO5 -> FPGA DIN (dual function) + + // Assert reset line for 100uS + outw(0x00, emu->port + A_GPIO); + write_post = inw(emu->port + A_GPIO); + udelay(100); + outw(0x80, emu->port + A_GPIO); + write_post = inw(emu->port + A_GPIO); + udelay(100); // Allow FPGA memory to clean + + // Upload the netlist. Keep reset line high! + for (int n = 0; n < fw_entry->size; n++) { + u8 value = fw_entry->data[n]; + for (int i = 0; i < 8; i++) { + u16 reg = 0x80; + if (value & 1) + reg |= 0x20; + value >>= 1; + outw(reg, emu->port + A_GPIO); + write_post = inw(emu->port + A_GPIO); + outw(reg | 0x40, emu->port + A_GPIO); + write_post = inw(emu->port + A_GPIO); + } + } + + // After programming, set GPIO bit 4 high again. + // This appears to be a config word that the rev1 Hana + // firmware reads; weird things happen without this. + outw(0x10, emu->port + A_GPIO); + write_post = inw(emu->port + A_GPIO); +} + void snd_emu10k1_intr_enable(struct snd_emu10k1 *emu, unsigned int intrenb) { unsigned long flags; From patchwork Sun Apr 28 09:37:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 13645969 Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC6F855E44 for ; Sun, 28 Apr 2024 09:37:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.17.22 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714297050; cv=none; b=d/RpiJ++AqV9T/hHNySeSDMMXFn7PxfpHjHDYEXJhKQg9pEGUXg7QNnxibgn9eI+sgVFCgvdwuUKU5Rxp7VCL/6LlMyO4yksz7S2EVFYaayHfmvXUPFxA7h/hGYoAgmujiCzrvG5fIGAxUIX8NvlAAIT19jU2L2YpB5mj+g1G6A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714297050; c=relaxed/simple; bh=U67Nsm4It4LOqwHUkQxaRtYNhNGmVaYa7ybYir9aa34=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EbyAwHIvmFAGZftliWvFtpjidem7SiPgu12rV/LySGTc28W13Zdx7ifCcNMaj+ytM9o94lTnmccSmDex4+jq9WqnZjjT8jX+gz0qmKuPVjmfkcEPDmW5YyzFAtjRMDBEZ8QvKooipsL7vJnrQ5kqwCxAc+qXi901+cjUWKioK/A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de; spf=pass smtp.mailfrom=gmx.de; dkim=pass (2048-bit key) header.d=gmx.de header.i=oswald.buddenhagen@gmx.de header.b=OUxGyfJW; arc=none smtp.client-ip=212.227.17.22 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmx.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.de header.i=oswald.buddenhagen@gmx.de header.b="OUxGyfJW" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1714297038; x=1714901838; i=oswald.buddenhagen@gmx.de; bh=UI4+vg2KILDd+22vYE6+H4glg6FLDNGnaxRL4oHvIoE=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:Message-ID:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=OUxGyfJWrrHtuHUL2iz/KH9voReklsONuLYAzdVwUJ/51gfpN+LZfIP/z4j/YM1P lbkuUbEttUYPqmpNV3EMfB85GM4+Z9roa8byDyYqsvwTkIQd8691epLDK4tUt/Cjw RogvuwvWdPK7FpG3T5yXERb9/NCi/mrGLGlzH0nqbLgDMsCZajAn7QSeGN7ytxwq/ PcdSodE3I//SXIBbVPQEVM8yvSk4EhkuyPpwDP/QNWq6nbhGAdAvkPJAW8rXhDJmI /FcjnpkzyWXGuM6JorV6aDWRY0fBoZQPJbQtO37qqvHKxj2TCNh/WHD2s0PgLGhqu 9I9TXx5Z7U6SKPApHQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.124]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1Mnpru-1sTD7s1fH0-00pPk4; Sun, 28 Apr 2024 11:37:18 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1s10yD-Q95-00; Sun, 28 Apr 2024 11:37:17 +0200 From: Oswald Buddenhagen To: linux-sound@vger.kernel.org Cc: Takashi Iwai , Jaroslav Kysela , Pietro Caruso Subject: [PATCH v2 4/4] ALSA: emu10k1: move code for entering E-MU card FPGA programming mode Date: Sun, 28 Apr 2024 11:37:17 +0200 Message-ID: <20240428093717.3198716-5-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.44.0.701.g2cf7baacf3.dirty In-Reply-To: <20240428093717.3198716-1-oswald.buddenhagen@gmx.de> References: <20240428093717.3198716-1-oswald.buddenhagen@gmx.de> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Provags-ID: V03:K1:Hg1hQXxXRCneuifK+9vD8a1M0ZLVLttFzD2ppwXu7GuKSSFbjVH p1fPv5A3dzerl3FzU0f7GQZBQEkr+rbFyZybxRyW2ftS7f3IiasMYKsVTz0Or4Ait8sRp7S JAT2AE6bilZyVLEn5kUKsn/CznGNgEsBftsi3F7au6PY24TJqdIslnD+zoW5C03Vp3YLt94 NDakjk8Q4QLFXqaRDZCnw== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:c3Q78/2NwMo=;04VpsxYklG+Hc6LIxmBjT7nD8QK TF3MsrSi9hUKyDfZD3Ah//a3RC69MbYRgmgns9SKSKi/evv/OAogZD00vycP4LfPJfssw+VuJ 9V7hHhapNNzr+s3ZKOKnpZYpjTbJ5QgPumXBDd/aDO8JuINiQ3Z8eiFi+OPpiEan1/GFNrX92 Eg5OQ/Zv53m6RhgD7qvOX2RT7J4s6fRCH2ejyioU8QXSU8pzJCKJJ9tFWlW23HQCxM0X2+nkw xJ8rrmn9P5wqF216YWzHUKc3lYYDfXHbdTxuIYcQweQFnyLPaYLkYaf4I2brHx9/u4VfZK8NX AWKe/gyrQo3O+BDD6736lRZsGOlJ1cYioAzEwPeumy3p0TlsGx6ZZ5lr7fJrgB2wpWIWPU8k+ /JyKpuUp4xBdxEHVeYz0GXiWQ5C8YfEDcDK3l5nIYJ/jvVnkz1IBTkSwHy6BPjQAneAP8r3n0 /WW0HAvsWiJECFglKJuPIYwq5+zDRntLwk9cnvRSr26n2Bb7dWunbvauF6m31/SBpdI1YbMEG uL+HhOXH+/y7G34gh0XDmfDYiGCPs5L55kb266xrcktofUPo3+I2ADMqmhM20nlINgn6Aq55r hLaUwZCT1MA/LBdfbO6F7lchJ6Rf6M9R+E6u5y4KUQOjLmE0hNGqSUTfatezSu+wdOzK/SnZK 0ZmmbYlRvmYnwtFgINkx0hm9OThpSG1GiaaZkUtNVV4xTITfIHCgiZHPJIGiDYfH4NP4BPu0A QcAhXYr6F8DlPc8PfNfCG1cwov1S89IrsrEBxnvD2s0a8k9nDRxLRcpTeesWokaxQnVqUKYgI f5w54jQuoZpNUeUBcX/HzESvSx6chF7A/0aaJkrd88blg= ... into snd_emu1010_load_firmware_entry(). This makes it clearer that these steps belong together tightly, as implied by prior commits. Signed-off-by: Oswald Buddenhagen --- include/sound/emu10k1.h | 2 +- sound/pci/emu10k1/emu10k1_main.c | 7 +------ sound/pci/emu10k1/io.c | 7 ++++++- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/sound/emu10k1.h b/include/sound/emu10k1.h index 2856f4717c93..b83862259eec 100644 --- a/include/sound/emu10k1.h +++ b/include/sound/emu10k1.h @@ -1843,7 +1843,7 @@ void snd_emu1010_fpga_link_dst_src_write(struct snd_emu10k1 *emu, u32 dst, u32 s u32 snd_emu1010_fpga_link_dst_src_read(struct snd_emu10k1 *emu, u32 dst); int snd_emu1010_get_raw_rate(struct snd_emu10k1 *emu, u8 src); void snd_emu1010_update_clock(struct snd_emu10k1 *emu); -void snd_emu1010_load_firmware_entry(struct snd_emu10k1 *emu, const struct firmware *fw_entry); +void snd_emu1010_load_firmware_entry(struct snd_emu10k1 *emu, int dock, const struct firmware *fw_entry); unsigned int snd_emu10k1_efx_read(struct snd_emu10k1 *emu, unsigned int pc); void snd_emu10k1_intr_enable(struct snd_emu10k1 *emu, unsigned int intrenb); void snd_emu10k1_intr_disable(struct snd_emu10k1 *emu, unsigned int intrenb); diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index c8aa4143ac4f..5b8a5ba825bd 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c @@ -683,7 +683,7 @@ static int snd_emu1010_load_firmware(struct snd_emu10k1 *emu, int dock, return err; } - snd_emu1010_load_firmware_entry(emu, *fw); + snd_emu1010_load_firmware_entry(emu, dock, *fw); return 0; } @@ -699,9 +699,6 @@ static void snd_emu1010_load_dock_firmware(struct snd_emu10k1 *emu) msleep(200); dev_info(emu->card->dev, "emu1010: Loading Audio Dock Firmware\n"); - /* Return to Audio Dock programming mode */ - snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, - EMU_HANA_FPGA_CONFIG_AUDIODOCK); err = snd_emu1010_load_firmware(emu, 1, &emu->dock_fw); if (err < 0) return; @@ -820,8 +817,6 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 *emu) snd_emu1010_fpga_lock(emu); dev_info(emu->card->dev, "emu1010: Loading Hana Firmware\n"); - snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, - EMU_HANA_FPGA_CONFIG_HANA); err = snd_emu1010_load_firmware(emu, 0, &emu->firmware); if (err < 0) { dev_info(emu->card->dev, "emu1010: Loading Firmware failed\n"); diff --git a/sound/pci/emu10k1/io.c b/sound/pci/emu10k1/io.c index fafa299efa5c..b60ab5671e00 100644 --- a/sound/pci/emu10k1/io.c +++ b/sound/pci/emu10k1/io.c @@ -422,7 +422,7 @@ void snd_emu1010_update_clock(struct snd_emu10k1 *emu) snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_LEDS_2, leds); } -void snd_emu1010_load_firmware_entry(struct snd_emu10k1 *emu, +void snd_emu1010_load_firmware_entry(struct snd_emu10k1 *emu, int dock, const struct firmware *fw_entry) { __always_unused u16 write_post; @@ -440,6 +440,11 @@ void snd_emu1010_load_firmware_entry(struct snd_emu10k1 *emu, // GPO6 -> FPGA CCLK & FPGA input // GPO5 -> FPGA DIN (dual function) + // If the FPGA is already programmed, return it to programming mode + snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, + dock ? EMU_HANA_FPGA_CONFIG_AUDIODOCK : + EMU_HANA_FPGA_CONFIG_HANA); + // Assert reset line for 100uS outw(0x00, emu->port + A_GPIO); write_post = inw(emu->port + A_GPIO);