From: Maciej Strozek <mstrozek@opensource.cirrus.com>
To: Mark Brown <broonie@kernel.org>
Cc: James Schulman <james.schulman@cirrus.com>,
David Rhodes <david.rhodes@cirrus.com>,
Liam Girdwood <lgirdwood@gmail.com>,
<alsa-devel@alsa-project.org>, <patches@opensource.cirrus.com>,
<linux-sound@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
Maciej Strozek <mstrozek@opensource.cirrus.com>
Subject: [PATCH 5/7] ASoC: cs43130: Add handling of ACPI
Date: Fri, 17 Nov 2023 14:13:42 +0000 [thread overview]
Message-ID: <20231117141344.64320-6-mstrozek@opensource.cirrus.com> (raw)
In-Reply-To: <20231117141344.64320-1-mstrozek@opensource.cirrus.com>
Signed-off-by: Maciej Strozek <mstrozek@opensource.cirrus.com>
---
sound/soc/codecs/cs43130.c | 44 ++++++++++++++++++++++++--------------
1 file changed, 28 insertions(+), 16 deletions(-)
diff --git a/sound/soc/codecs/cs43130.c b/sound/soc/codecs/cs43130.c
index 447abbaa6f47..fd39328579fb 100644
--- a/sound/soc/codecs/cs43130.c
+++ b/sound/soc/codecs/cs43130.c
@@ -16,7 +16,7 @@
#include <linux/platform_device.h>
#include <linux/pm.h>
#include <linux/i2c.h>
-#include <linux/of.h>
+#include <linux/property.h>
#include <linux/regmap.h>
#include <linux/slab.h>
#include <sound/core.h>
@@ -2400,14 +2400,12 @@ static const u16 cs43130_dc_threshold[CS43130_DC_THRESHOLD] = {
120,
};
-static int cs43130_handle_device_data(struct i2c_client *i2c_client,
- struct cs43130_private *cs43130)
+static int cs43130_handle_device_data(struct cs43130_private *cs43130)
{
- struct device_node *np = i2c_client->dev.of_node;
unsigned int val;
int i;
- if (of_property_read_u32(np, "cirrus,xtal-ibias", &val) < 0) {
+ if (device_property_read_u32(cs43130->dev, "cirrus,xtal-ibias", &val) < 0) {
/* Crystal is unused. System clock is used for external MCLK */
cs43130->xtal_ibias = CS43130_XTAL_UNUSED;
return 0;
@@ -2429,18 +2427,18 @@ static int cs43130_handle_device_data(struct i2c_client *i2c_client,
return -EINVAL;
}
- cs43130->dc_meas = of_property_read_bool(np, "cirrus,dc-measure");
- cs43130->ac_meas = of_property_read_bool(np, "cirrus,ac-measure");
+ cs43130->dc_meas = device_property_read_bool(cs43130->dev, "cirrus,dc-measure");
+ cs43130->ac_meas = device_property_read_bool(cs43130->dev, "cirrus,ac-measure");
- if (of_property_read_u16_array(np, "cirrus,ac-freq", cs43130->ac_freq,
- CS43130_AC_FREQ) < 0) {
+ if (!device_property_read_u16_array(cs43130->dev, "cirrus,ac-freq", cs43130->ac_freq,
+ CS43130_AC_FREQ)) {
for (i = 0; i < CS43130_AC_FREQ; i++)
cs43130->ac_freq[i] = cs43130_ac_freq[i];
}
- if (of_property_read_u16_array(np, "cirrus,dc-threshold",
+ if (!device_property_read_u16_array(cs43130->dev, "cirrus,dc-threshold",
cs43130->dc_threshold,
- CS43130_DC_THRESHOLD) < 0) {
+ CS43130_DC_THRESHOLD)) {
for (i = 0; i < CS43130_DC_THRESHOLD; i++)
cs43130->dc_threshold[i] = cs43130_dc_threshold[i];
}
@@ -2469,11 +2467,12 @@ static int cs43130_i2c_probe(struct i2c_client *client)
return ret;
}
- if (cs43130->dev->of_node) {
- ret = cs43130_handle_device_data(client, cs43130);
+ if (dev_fwnode(cs43130->dev)) {
+ ret = cs43130_handle_device_data(cs43130);
if (ret != 0)
return ret;
}
+
for (i = 0; i < ARRAY_SIZE(cs43130->supplies); i++)
cs43130->supplies[i].supply = cs43130_supply_names[i];
@@ -2704,6 +2703,7 @@ static const struct dev_pm_ops cs43130_runtime_pm = {
NULL)
};
+#if IS_ENABLED(CONFIG_OF)
static const struct of_device_id cs43130_of_match[] = {
{.compatible = "cirrus,cs43130",},
{.compatible = "cirrus,cs4399",},
@@ -2713,6 +2713,17 @@ static const struct of_device_id cs43130_of_match[] = {
};
MODULE_DEVICE_TABLE(of, cs43130_of_match);
+#endif
+
+#if IS_ENABLED(CONFIG_ACPI)
+static const struct acpi_device_id cs43130_acpi_match[] = {
+ { "CSC4399", 0 },
+ {}
+};
+
+MODULE_DEVICE_TABLE(acpi, cs43130_acpi_match);
+#endif
+
static const struct i2c_device_id cs43130_i2c_id[] = {
{"cs43130", 0},
@@ -2726,9 +2737,10 @@ MODULE_DEVICE_TABLE(i2c, cs43130_i2c_id);
static struct i2c_driver cs43130_i2c_driver = {
.driver = {
- .name = "cs43130",
- .of_match_table = cs43130_of_match,
- .pm = &cs43130_runtime_pm,
+ .name = "cs43130",
+ .of_match_table = of_match_ptr(cs43130_of_match),
+ .acpi_match_table = ACPI_PTR(cs43130_acpi_match),
+ .pm = &cs43130_runtime_pm,
},
.id_table = cs43130_i2c_id,
.probe = cs43130_i2c_probe,
--
2.34.1
next prev parent reply other threads:[~2023-11-17 14:14 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-17 14:13 [PATCH 0/7] ASoC: cs43130: Fixes and improvements Maciej Strozek
2023-11-17 14:13 ` [PATCH 1/7] ASoC: cs43130: Fix the position of const qualifier Maciej Strozek
2023-11-17 14:13 ` [PATCH 2/7] ASoC: cs43130: Fix incorrect frame delay configuration Maciej Strozek
2023-11-17 14:13 ` [PATCH 3/7] ASoC: cs43130: Allow configuration of bit clock and frame inversion Maciej Strozek
2023-11-17 20:21 ` Mark Brown
2023-11-17 14:13 ` [PATCH 4/7] ASoC: cs43130: Store device in private struct and use it more consistently Maciej Strozek
2023-11-17 14:13 ` Maciej Strozek [this message]
2023-11-17 14:13 ` [PATCH 6/7] ASoC: cs43130: Allow driver to work without IRQ thread Maciej Strozek
2023-11-17 16:36 ` Mark Brown
2023-11-20 9:43 ` Maciej Strozek
2023-11-20 9:55 ` Charles Keepax
2023-11-17 14:13 ` [PATCH 7/7] ASoC:cs43130: Add switch to control normal and alt hp inputs Maciej Strozek
2023-11-17 15:53 ` [PATCH 0/7] ASoC: cs43130: Fixes and improvements Charles Keepax
2023-11-18 0:32 ` (subset) " Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231117141344.64320-6-mstrozek@opensource.cirrus.com \
--to=mstrozek@opensource.cirrus.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=david.rhodes@cirrus.com \
--cc=james.schulman@cirrus.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=patches@opensource.cirrus.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®