From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 604941A3173 for ; Mon, 24 Mar 2025 09:58:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742810289; cv=none; b=n2TppJ2BaivGRpIx7CXuYyEUe5E0Ywqh+IZFUwC4a+UsAacnfGyxNpeKtvOJH04m1EFE4OLia6HAWZersN0ZIsSWimEQamFbQ8cOU3DANE+veyAtQK8Gomj7w7+vcSDyNGDryqCCTVaViyIk39PoaKGjuubJb7UIsVoPssGbBrA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742810289; c=relaxed/simple; bh=OHg1Gocf3MVAxryxLA/xQ+5RT7slspVi+KujcHZqyMU=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=l+G79IKvymw6vLqXJfmbvZj3KK4UxAIG7aZ9jaQetz78mKOIH20kmQwzgEuDvKHVx1GvmegNoGBmD0mkZzE7d4o6IrvQ1WD5BNJTSDW3ehM5pICWJ2nCSDrorzBL3chM7ScIE1lwOlkzpCCzkeyu+YiwmjS072t2HbsLIVo9y3c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=spfymTR+; arc=none smtp.client-ip=209.85.167.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="spfymTR+" Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-54963160818so4995698e87.2 for ; Mon, 24 Mar 2025 02:58:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1742810285; x=1743415085; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=MPGPUbUSiYN5rbP1AyBJpFJROiY6lURz5npYEhG7kPM=; b=spfymTR+q2YO9IXeQV8zJTlk/fIsFgVaMze6osPrwJPUQ0qDzci/WNcZtknTp12fJO F3jFAwmvfmlkscYBJaySGc70Q75XTj00+5/ujXBHBYyd6y2g2mhUeMMYnnWvINbGpbdZ PJbJsPQhzW3uRb+4YjmsQOTPXzhRGgk/GLfsuPa3wjUiNvYJU+bsWjsNpH6KF5zAuxea FwOeEHRHY8/YeD0Uqdx5/CafvuYb0B7OCPaTvjLgrKIlHN8lLHCGadzkavwC9U79I68j cfLuNgXM7FEMHolTvlHx3IWDG7nQ/2mklNASV1V7s5BGGrlIsMN360hcbElSD5/OZtTt s69g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742810285; x=1743415085; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MPGPUbUSiYN5rbP1AyBJpFJROiY6lURz5npYEhG7kPM=; b=hggYchfu4hHF50FsDCnGWoKcisdlZ0jQ803bIcwO2w+3rxRnu5ayInhLx1AdDPLXb4 4Lcy64CFjJQC4NMX+IoRt1MT4kzGjB09YhnOM2QCf1JT91iSuDrTS2LkGOPFXRrGWpPc UPk9D0GUfU7llTLU9LqzbGoe2rY2tWDncWUZmZPO2o8pwa3DUobAfH1dJkWGNLt7RbSa qfF/Lxz1JZ2H38FFUOzGL/nHC+VPLVsHgGOuo0V7GnxuDq5CKqC9a2QIb5TaQTOhbl8n DEUUak+qApZCf05Zc96uTTazHEY/ghvUZx6xTljstI5jdmC1Ogp2oHuubg+LDAYb9JW9 eB4w== X-Forwarded-Encrypted: i=1; AJvYcCWmDyBmKtCyzf6Jk8PLRW+iGAxWGKwPiDjeMCxCWaTlGV5PaMf3FMem4IevCYEh7V6miGyb/A1c5czEzME=@vger.kernel.org X-Gm-Message-State: AOJu0YxqXgntPrbsqO5KKwfid0nRRBAybiTusV/HcpIPoyqhvf8vEIAW mHh4Fa8ljEdrqkU23gZvgbiqMus10jaK2w98PsEGhyGQ/eLoeUxe4nziNJofSvCMhiBzQIa54ha 6zNaby+1zMdsw2gvZOvEBGs8O9cPriNB+ugi97g== X-Gm-Gg: ASbGncvz4oWlDd6TEU8mz95r45ubCGDB2KlZ5/gZ1upxb0BnDG4twqyN+y5dVF/LGSh 8kf9LGQ7qH5A3eM4K44SYo5Gd5I7d8ZGrEL2hmhrdf0SXvpeHe1BH+9YS0GXdILRx9pf2mR594M rPoG3MfGnDwQD1J4ICaLwWrYY= X-Google-Smtp-Source: AGHT+IGFsn3NoPz0najqV+IyhexXJLWBrCkDs/jIJqPrU8OWba6VOwjZMM5PPRVIKcz1oO7UGeYDUXXGPDpt9IuYXJ4= X-Received: by 2002:a05:6512:1589:b0:549:7590:ff24 with SMTP id 2adb3069b0e04-54ad648589amr4088805e87.22.1742810285409; Mon, 24 Mar 2025 02:58:05 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20250324-wcd-gpiod-v1-0-27afa472e331@nxp.com> <20250324-wcd-gpiod-v1-2-27afa472e331@nxp.com> In-Reply-To: From: Linus Walleij Date: Mon, 24 Mar 2025 10:57:53 +0100 X-Gm-Features: AQ5f1Jq7SF51RGQ0IJIEpnbKXCAd1Gopipv6p1fkqvQKEyRcyxOHT8HxFUdiM2Q Message-ID: Subject: Re: [PATCH 2/3] ASoC: codec: wcd938x: Convert to GPIO descriptors To: Peng Fan Cc: Johan Hovold , Steev Klimaszewski , "Peng Fan (OSS)" , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Bartosz Golaszewski , Srinivas Kandagatla , "linux-sound@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-gpio@vger.kernel.org" , "linux-arm-msm@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Mar 24, 2025 at 9:34=E2=80=AFAM Peng Fan wrote: > > Subject: Re: [PATCH 2/3] ASoC: codec: wcd938x: Convert to GPIO > > descriptors > > > > On Mon, Mar 24, 2025 at 9:09=E2=80=AFAM Peng Fan > > wrote: > > > > > ok, then the only suspecting point is > > > wcd938x->reset_gpio =3D devm_gpiod_get(dev, "reset", GPIOD_ASIS); > > > > > > I may need to use GPIOD_OUT_LOW to configure it to output as set > > raw > > > set value as 1. > > > > I think there may be a bug in gpiod_configure_flags() in gpiolib.c: > > > > /* Process flags */ > > if (dflags & GPIOD_FLAGS_BIT_DIR_OUT) > > ret =3D gpiod_direction_output_nonotify(desc, > > !!(dflags & GPIOD_FLAGS_BIT_DIR_VAL)); > > else > > ret =3D gpiod_direction_input_nonotify(desc); > > > > Shouldn't this be: > > > > if (dflags & GPIOD_FLAGS_BIT_DIR_OUT) > > ret =3D gpiod_direction_output_nonotify(desc, > > !!(dflags & GPIOD_FLAGS_BIT_DIR_VAL)); > > else if (dflags & GPIOD_FLAGS_BIT_DIR_SET) > > ret =3D gpiod_direction_input_nonotify(desc); > > Using GPIO_ASIS should not change direction. > This change makes sense. Actually when looking closer at it I was wrong. >From : enum gpiod_flags { GPIOD_ASIS =3D 0, GPIOD_IN =3D GPIOD_FLAGS_BIT_DIR_SET, GPIOD_OUT_LOW =3D GPIOD_FLAGS_BIT_DIR_SET | GPIOD_FLAGS_BIT_DIR_OUT, GPIOD_OUT_HIGH =3D GPIOD_FLAGS_BIT_DIR_SET | GPIOD_FLAGS_BIT_DIR_OUT= | GPIOD_FLAGS_BIT_DIR_VAL, GPIOD_OUT_LOW_OPEN_DRAIN =3D GPIOD_OUT_LOW | GPIOD_FLAGS_BIT_OPEN_DRAIN= , GPIOD_OUT_HIGH_OPEN_DRAIN =3D GPIOD_OUT_HIGH | GPIOD_FLAGS_BIT_OPEN_DRA= IN, }; So GPIOD_ASIS does not set GPIOD_FLAGS_BIT_DIR_SET. Then gpiod_configure_flags() has: /* No particular flag request, return here... */ if (!(dflags & GPIOD_FLAGS_BIT_DIR_SET)) { gpiod_dbg(desc, "no flags found for GPIO %s\n", name); return 0; } /* Process flags */ if (dflags & GPIOD_FLAGS_BIT_DIR_OUT) ret =3D gpiod_direction_output_nonotify(desc, !!(dflags & GPIOD_FLAGS_BIT_DIR_VAL)); else ret =3D gpiod_direction_input_nonotify(desc); So the function bails out right above (you could check the debug print there if in doubt.) So the behaviour is correct. So now I have no idea what is going on again :/ But I would suggest trying to set GPIOD_OUT_LOW when requesting the line and just check if that solves Steev:s problem (trial-and-error). Yours, Linus Walleij