From patchwork Thu Oct 24 21:16:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13849754 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 9090D1A76AC for ; Thu, 24 Oct 2024 21:16:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729804597; cv=none; b=ER8eQrG43/MDOSOYlUxwH60iciN4tdJumHXkkKgZTSO6FkzJ/fY4hySplJrssFF09SXxo9HLeNuACdo6UCT/P1AIRnmq+kPe25MLk2KVRZyoE2VfD2DV9srAKLgEV7Gxzjy9ECDoB9mnSTM/85saqAXwD3gh8WdcVRSarBUstE4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729804597; c=relaxed/simple; bh=2IMHuhpsxZHbKyuInV8qY+4h0UG5uVBA7dInnkIMJzU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=QArbIz4HI5TWtENRmD7+dffELrEiKxAxz395vgx2odQwLxKhZ9/RFTWa4Yt4UDoDJAadQoRITXx2H4NQWloNRsEGkaYMqzY732kg75WZOEGh1Z4jnhu0f/98zRf2CpFScieClXSOyGJKnCPUqZ5WepXE10xwXTqYk8qNI2I4WhA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=arcd7cRW; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="arcd7cRW" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729804594; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=FQHuESxQ97tz+BpUNwpra+dtQhsyTAAaMXlbuHXSpck=; b=arcd7cRWa/VJ4e1GyyMXipP7O3e7WHuEWTQFlM9WQFHWY5ArgTWXSfFtWJ6S9FSLedK7u+ VxYRiM3iqB/4jqHj9KXiF765lme+WPTn8aUD6lgmKp3f/+3+kRviMjVIZcdn8N89dhxM0z 6Pe3+jmyKqIttl1ZsqTRV7fGzmWC/7Y= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-203-SANIgVe4PW2eXp5NqEAPpQ-1; Thu, 24 Oct 2024 17:16:29 -0400 X-MC-Unique: SANIgVe4PW2eXp5NqEAPpQ-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A05051956048; Thu, 24 Oct 2024 21:16:27 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.75]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E07011956088; Thu, 24 Oct 2024 21:16:24 +0000 (UTC) From: Hans de Goede To: Cezary Rojewski , Liam Girdwood , Peter Ujfalusi , Pierre-Louis Bossart , Bard Liao , Mark Brown Cc: Hans de Goede , linux-sound@vger.kernel.org Subject: [PATCH 1/2] ASoC: Intel: bytcr_rt5640: Add support for non ACPI instantiated codec Date: Thu, 24 Oct 2024 23:16:14 +0200 Message-ID: <20241024211615.79518-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com On some x86 Bay Trail tablets which shipped with Android as factory OS, the DSDT is so broken that the codec needs to be manually instantatiated by the special x86-android-tablets.ko "fixup" driver for cases like this. This means that the codec-dev cannot be retrieved through its ACPI fwnode, add support to the bytcr_rt5640 machine driver for such manually instantiated rt5640 i2c_clients. An example of a tablet which needs this is the Vexia EDU ATLA 10 tablet, which has been distributed to schools in the Spanish AndalucĂ­a region. Signed-off-by: Hans de Goede --- sound/soc/intel/boards/bytcr_rt5640.c | 33 ++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/sound/soc/intel/boards/bytcr_rt5640.c b/sound/soc/intel/boards/bytcr_rt5640.c index 2ed49acb4e36..8dfd91cc3668 100644 --- a/sound/soc/intel/boards/bytcr_rt5640.c +++ b/sound/soc/intel/boards/bytcr_rt5640.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -32,6 +33,8 @@ #include "../atom/sst-atom-controls.h" #include "../common/soc-intel-quirks.h" +#define BYT_RT5640_FALLBACK_CODEC_DEV_NAME "i2c-rt5640" + enum { BYT_RT5640_DMIC1_MAP, BYT_RT5640_DMIC2_MAP, @@ -1698,9 +1701,33 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev) codec_dev = acpi_get_first_physical_node(adev); acpi_dev_put(adev); - if (!codec_dev) - return -EPROBE_DEFER; - priv->codec_dev = get_device(codec_dev); + + if (codec_dev) { + priv->codec_dev = get_device(codec_dev); + } else { + /* + * Special case for Android tablets where the codec i2c_client + * has been manually instantiated by x86_android_tablets.ko due + * to a broken DSDT. + */ + codec_dev = bus_find_device_by_name(&i2c_bus_type, NULL, + BYT_RT5640_FALLBACK_CODEC_DEV_NAME); + if (!codec_dev) + return -EPROBE_DEFER; + + if (!i2c_verify_client(codec_dev)) { + dev_err(dev, "Error '%s' is not an i2c_client\n", + BYT_RT5640_FALLBACK_CODEC_DEV_NAME); + put_device(codec_dev); + } + + /* fixup codec name */ + strscpy(byt_rt5640_codec_name, BYT_RT5640_FALLBACK_CODEC_DEV_NAME, + sizeof(byt_rt5640_codec_name)); + + /* bus_find_device() returns a reference no need to get() */ + priv->codec_dev = codec_dev; + } /* * swap SSP0 if bytcr is detected