From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
To: Mark Brown <broonie@kernel.org>
Cc: mark.rutland@arm.com, devicetree@vger.kernel.org,
alsa-devel@alsa-project.org, bgoswami@codeaurora.org,
lgirdwood@gmail.com, vkoul@kernel.org, robh+dt@kernel.org,
srini@kernel.org
Subject: Re: [PATCH 2/6] ASoC: wcd934x: add support to wcd9340/wcd9341 codec
Date: Tue, 2 Jul 2019 17:37:01 +0100 [thread overview]
Message-ID: <2e2a32dd-3dca-5391-1bfa-ab1c1f420e3a@linaro.org> (raw)
In-Reply-To: <20190702144411.GP2793@sirena.org.uk>
Thanks Mark for taking time to review this patch.
On 02/07/2019 15:44, Mark Brown wrote:
> On Tue, Jul 02, 2019 at 09:09:16AM +0100, Srinivas Kandagatla wrote:
>
>> +#define WCD_VERSION_WCD9341_1_1 5
>> +#define WCD_IS_1_0(wcd) \
>> + ((wcd->type == WCD934X) ? \
>> + ((wcd->version == WCD_VERSION_1_0 || \
>> + wcd->version == WCD_VERSION_WCD9340_1_0 || \
>> + wcd->version == WCD_VERSION_WCD9341_1_0) ? 1 : 0) : 0)
>
> Eew. If you really need these make them functions and write
> normal code with switch statements rather than abusing the
> ternery operator like this, it's really not terribly readable.
>
I agree, will fix this and such use of ternary operators in the code.
>> +static void wcd934x_update_reg_defaults(struct wcd934x_codec *wcd)
>> +{
>> + struct regmap *rm = wcd->regmap;
>> +
>> + regmap_update_bits(rm, WCD934X_BIAS_VBG_FINE_ADJ, 0xFF, 0x75);
>> + regmap_update_bits(rm, WCD934X_CODEC_CPR_SVS_CX_VDD, 0xFF, 0x7C);
>
> What's all this stuff doing? Should you be uing a regmap patch?
>
I will try that in next version.
>> +static int wcd934x_disable_master_bias(struct wcd934x_codec *data)
>> +{
>> + if (data->master_bias_users <= 0)
>> + return 0;
>> +
>> + data->master_bias_users--;
>
> There's an awful lot of these refcounted things - are you sure
> none of them could be supply widgets?
I did not like it either, will remove them as this might be redundant.
"MCLK" is already a supply widget.
>
>> +static void wcd934x_get_version(struct wcd934x_codec *wcd)
>> +{
>> + int val1, val2, version, ret;
>> + struct regmap *regmap;
>> + u16 id_minor;
>> + u32 version_mask = 0;
>> +
>> + regmap = wcd->regmap;
>> + version = 0;
>> +
>> + ret = regmap_bulk_read(regmap, WCD934X_CHIP_TIER_CTRL_CHIP_ID_BYTE0,
>> + (u8 *)&id_minor, sizeof(u16));
>> +
>> + if (ret)
>> + return;
>
> No error reporting at all?
I agree, will fix this in next version.
>
>> + regmap_read(regmap, WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT14, &val1);
>> + regmap_read(regmap, WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT15, &val2);
>> +
>> + dev_info(wcd->dev, "%s: chip version :0x%x 0x:%x\n",
>> + __func__, val1, val2);
>
> We don't report id_minor as part of the version? Also the format
> string there just seems mangled and not even internally
> consistent.
>
>> + version_mask |= (!!((u8)val1 & 0x80)) << DSD_DISABLED_MASK;
>> + version_mask |= (!!((u8)val2 & 0x01)) << SLNQ_DISABLED_MASK;
>> +
>> + switch (version_mask) {
>> + case DSD_DISABLED | SLNQ_DISABLED:
>> + if (id_minor == 0)
>> + version = WCD_VERSION_WCD9340_1_0;
>> + else if (id_minor == 0x01)
>> + version = WCD_VERSION_WCD9340_1_1;
>
> This looks like you're trying to write a switch statement on the
> minor version...
>
Will move to switch and any such occurrences.
>> +static void wcd934x_update_cpr_defaults(struct wcd934x_codec *data)
>> +{
>> + int i;
>> +
>> + __wcd934x_cdc_mclk_enable(data, true);
>> +
>> + wcd934x_set_sido_input_src(data, SIDO_SOURCE_RCO_BG);
>> + regmap_write(data->regmap, WCD934X_CODEC_CPR_SVS2_MIN_CX_VDD, 0x2C);
>> + regmap_update_bits(data->regmap, WCD934X_CODEC_RPM_CLK_GATE,
>> + 0x10, 0x00);
>> +
>> + for (i = 0; i < ARRAY_SIZE(cpr_defaults); i++) {
>> + regmap_bulk_write(data->regmap,
>> + WCD934X_CODEC_CPR_WR_DATA_0,
>> + (u8 *)&cpr_defaults[i].wr_data, 4);
>> + regmap_bulk_write(data->regmap,
>> + WCD934X_CODEC_CPR_WR_ADDR_0,
>> + (u8 *)&cpr_defaults[i].wr_addr, 4);
>
> What is "cpr" and should you be using a regmap patch here? Why
> is this not with the other default updates? You've got loads of
> random undocumented sequences like this all through the driver,
> are they patches or are they things that should be controllable
> by the user?
It makes sense to have a single default map here, I will do the in next
version. And regarding user controllable, I will go thru the list once
again in detail and remove user controllable registers.
>
>
>> +static int wcd934x_get_micbias_val(struct device *dev, const char *micbias)
>> +{
>> + int mv;
>> +
>> + if (of_property_read_u32(dev->of_node, micbias, &mv))
>> + mv = WCD934X_DEF_MICBIAS_MV;
>> +
>> + if (mv < 1000 || mv > 2850)
>> + mv = WCD934X_DEF_MICBIAS_MV;
>
>> + return of_platform_populate(wcd->dev->of_node, NULL, NULL, wcd->dev);
>
> Why are we doing this?
I will not be using MFD in this instance as most of the resources like
interrupts, pins, clks, SoundWire are modeled as proper drivers with
their respective subsystems.
This gives a advantage of reusing those drivers like SoundWire, pinctrl
on other Qualcomm IPs as well!
Also I did not wanted to have a custom functions or hooks in the
drivers, so platform bus made much sense for me to use here, which can
take care of bringing up and tearing down the devices with proper parent
child relationship.
This will instantiate all the child devices like pinctrl, SoundWire
Controller and so on.
>
>> +{
>> + struct device *dev = wcd->dev;
>> + struct device_node *np = dev->of_node;
>> + int ret;
>> + /*
>> + * INTR1 consists of all possible interrupt sources Ear OCP,
>
> Missing blank line.
>
Yes, I will fix such instances in the driver in next version.
>> + * HPH OCP, MBHC, MAD, VBAT, and SVA
>> + * INTR2 is a subset of first interrupt sources MAD, VBAT, and SVA
>> + */
>> + wcd->irq = of_irq_get_byname(wcd->dev->of_node, "intr1");
>> + if (wcd->irq < 0) {
>> + if (wcd->irq != -EPROBE_DEFER)
>> + dev_err(wcd->dev, "Unable to configure IRQ\n");
>
> It's helpful to print what the error code was, it can help people
> debug things.
I agree!
>
>> + wcd->reset_gpio = of_get_named_gpio(np, "reset-gpios", 0);
>> + if (wcd->reset_gpio < 0) {
>> + dev_err(dev, "Reset gpio missing in DT\n");
>> + return wcd->reset_gpio;
>> + }
>
> devm_gpiod_get()
Make sense!
>
>> +static int wcd934x_bring_up(struct wcd934x_codec *wcd)
>> +{
>> + struct regmap *wcd_regmap = wcd->regmap;
>> + u16 id_minor, id_major;
>> + int ret;
>
>> + dev_info(wcd->dev, "%s: wcd9xxx chip id major 0x%x, minor 0x%x\n",
>> + __func__, id_major, id_minor);
>> +
>
> What was with the other verison parsing and printing code?
I will fix this in next version with single place to print the version
number.
Thanks,
srini
>
next prev parent reply other threads:[~2019-07-02 16:37 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-02 8:09 [PATCH 0/6] ASoC: Add support to WCD9340/WCD9341 codec Srinivas Kandagatla
2019-07-02 8:09 ` [PATCH 1/6] ASoC: dt-bindings: add dt bindings for WCD9340/WCD9341 audio codec Srinivas Kandagatla
2019-07-02 14:02 ` Mark Brown
2019-07-02 16:36 ` Srinivas Kandagatla
2019-07-22 22:55 ` Rob Herring
2019-07-22 22:59 ` Rob Herring
2019-07-02 8:09 ` [PATCH 2/6] ASoC: wcd934x: add support to wcd9340/wcd9341 codec Srinivas Kandagatla
2019-07-02 14:44 ` Mark Brown
2019-07-02 16:37 ` Srinivas Kandagatla [this message]
2019-07-02 16:57 ` Mark Brown
2019-07-03 8:49 ` Srinivas Kandagatla
2019-07-03 11:52 ` Mark Brown
2019-07-03 12:06 ` Srinivas Kandagatla
2019-07-02 8:09 ` [PATCH 3/6] ASoC: wcd934x: add basic controls Srinivas Kandagatla
2019-07-02 8:09 ` [PATCH 4/6] ASoC: wcd934x: add playback dapm widgets Srinivas Kandagatla
2019-07-02 8:09 ` [PATCH 5/6] ASoC: wcd934x: add capture " Srinivas Kandagatla
2019-07-02 8:09 ` [PATCH 6/6] ASoC: wcd934x: add audio routings Srinivas Kandagatla
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=2e2a32dd-3dca-5391-1bfa-ab1c1f420e3a@linaro.org \
--to=srinivas.kandagatla@linaro.org \
--cc=alsa-devel@alsa-project.org \
--cc=bgoswami@codeaurora.org \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=lgirdwood@gmail.com \
--cc=mark.rutland@arm.com \
--cc=robh+dt@kernel.org \
--cc=srini@kernel.org \
--cc=vkoul@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).