From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932450AbcBPNmW (ORCPT ); Tue, 16 Feb 2016 08:42:22 -0500 Received: from mout.kundenserver.de ([217.72.192.74]:52831 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932109AbcBPNmU convert rfc822-to-8bit (ORCPT ); Tue, 16 Feb 2016 08:42:20 -0500 From: Arnd Bergmann To: Andreas =?ISO-8859-1?Q?Irest=E5l?= Cc: Lars-Peter Clausen , Liam Girdwood , Mark Brown , Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , devicetree@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Andreas =?ISO-8859-1?Q?Irest=E5l?= Subject: Re: [PATCH v2 5/5] ASoC: adau17x1: Support platform data via DT Date: Tue, 16 Feb 2016 14:42:02 +0100 Message-ID: <4053162.T8NAULHXMt@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) In-Reply-To: <1455627405-18155-6-git-send-email-andire@axis.com> References: <1455627405-18155-1-git-send-email-andire@axis.com> <1455627405-18155-6-git-send-email-andire@axis.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT Content-Type: text/plain; charset="iso-8859-1" X-Provags-ID: V03:K0:MkdjNsPCn+KBAVl65vrw/HZTMAVhDmoCj4OA69v5jNtXG6TpUL1 ylUWOKKSFtV+fnRIu23/f57xP75V7n0MPN8bNUVUeUiH2utd5hrBL6KxitWg20cX30su017 dxMDZ7yxYK568Goq/YewMr7Js+J5+T2OMoFU3e76/2AuHaQM0T8X2OmlM+GSAhdx4EPuudc HxiMk9wN5fE+OlPCclX0g== X-UI-Out-Filterresults: notjunk:1;V01:K0:v7iWWO95hBw=:I+T5GmrsNOhZoEMEhatGAD MGeNI2fSofynqpNDoVp1hxS7weAhEVGzz7LzNIOGJL+lVmcl6FFhjBXmFVzHy4RTs4e7OaXA9 MpDqeTYex7ablLXemR9Xa1pFXQjiA6gZYhObn/uqtkaWfj+gjO7z2ZCohJ4fiyHCM4cw3TebC +DZ7HM7fG/hnxAZyM0KuLbO2QmagKGrSOlEj4FY8V71Emoix9WfvbYbi/J+91OvgziBQd4idB lPpK5rpjDvd+4BTKAPdrGtDggDCU9LcZ1g7cqk6k78ns0Zqr/sEkip3tQ1icYl1Yr/GU/dsDQ +MUGoGT3arPR8gfYwU9ww7WD+vINlLdAYNO6nx8661YBU7SIHoTJzKDwbLOmOKXXJfXHmr9ci G7S1Azm29L1RtzFtyoqM3CftB6CQ1n+llPdHTa2uT7mEs9MqbvA6XdhS6GFIbO4UWcVcqNaZ5 xsa6ILmBfP8Q9bpW8FiYyvg4/v793NvkKp6oNW6Mk/XSKRGSFmHJvgqz9YRNMLpboCEbtO1bc g5Fg7bpqjckkwzugfInb9rxiW+qIroVTCTQN+s9LWevwNieU9zJgj0dKvYzdXcwhati7lhe3a BLXY4Y2eY8eYwVj0BicASow7TybXIjFGynBmmWJVaJyQXS3hgxMtfQzAjuw78o45wb6mbepi0 1bXAwo/KDdwyTl8P2Bi+5gTyxKdbUHweeS8czzANNHU3zi8yMuom13E2RTM3mVQCwSMLGyqoC U4JYCsUK/3GduHVL Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tuesday 16 February 2016 13:56:45 Andreas Irestål wrote: > Currently, it is only possible to configure HW-specific options to the > adau17x1 codecs by providing a platform data struct. With this patch, > it is possible to provide the same data via DT instead. > > Signed-off-by: Andreas Irestål > --- > .../devicetree/bindings/sound/adi,adau17x1.txt | 31 +++++ > include/dt-bindings/sound/adau17x1.h | 14 +++ > sound/soc/codecs/adau1761.c | 127 +++++++++++++++++++++ > sound/soc/codecs/adau1781.c | 48 ++++++++ > 4 files changed, 220 insertions(+) > create mode 100644 include/dt-bindings/sound/adau17x1.h It would be nicer to avoid the need for the extra header file, those tend to cause more problems than they solve. > diff --git a/Documentation/devicetree/bindings/sound/adi,adau17x1.txt b/Documentation/devicetree/bindings/sound/adi,adau17x1.txt > index 8dbce0e..6050602 100644 > --- a/Documentation/devicetree/bindings/sound/adi,adau17x1.txt > +++ b/Documentation/devicetree/bindings/sound/adi,adau17x1.txt > @@ -13,6 +13,32 @@ Required properties: > - reg: The i2c address. Value depends on the state of ADDR0 > and ADDR1, as wired in hardware. > > +Optional properties: > + > + - adi,input-differential bool to set if the input is differential > + - adi,digital-microphone bool to set if there is a digital microphone > + connected to digmic/jackdet pin. > + - adi,micbias-vg Microphone bias voltage > + MICBIAS_0_90_AVDD - 0.9 * AVDD > + MICBIAS_0_65_AVDD - 0.65 * AVDD This could be an integer property, or possibly two (mutually exclusive) boolean properties. > +Optional properties (ADAU1361/ADAU1461/ADAU1761/ADAU1961 only) > + > + - adi,jack-detection If present, configures codec to use the digmic/jackdet > + pin for jack detection. must provide one of > + JACKDETECT_ACTIVE_LO or JACKDETECT_ACTIVE_HI followed > + by debounce time in ms, which must be 5, 10, 20, or 40. I would use one integer property for debounce and one bool property for polarity. > +The output mode must be one of: > + OUTPUT_MODE_HEADPHONE - Headphone output > + OUTPUT_MODE_HEADPHONE_CAPLESS - Capless headphone output > + OUTPUT_MODE_LINE - Line output And something along the same lines here. Or just document the three modes as numbers in the binding file. > +#ifdef CONFIG_OF > +static void adau1781_pdata_from_of(struct device *dev, > + struct adau1781_platform_data *pdata) You can remove the #ifdef here... > + if (!dev->platform_data && np) { if you change this to if (IS_ENABLED(CONFIG_OF) && np) { > + of_pdata = devm_kzalloc(dev, sizeof(*of_pdata), GFP_KERNEL); > + if (!of_pdata) > + return -ENOMEM; > + adau1781_pdata_from_of(dev, of_pdata); > + dev->platform_data = of_pdata; and here I'd try to avoid the dynamic allocation and just add the fields to the driver private structure. You can copy the information from the platform data in the 'else' path. Arnd