RFT: x86_32: Move OLPC XO-1 audio GPIO to software nodes
Subsystems (4)
Linus Walleij
maintainerPATCH 1/1 RFT: x86_32: Move OLPC XO-1 audio GPIO to software nodes
This needs real hardware to continue.
At the TODO spot, we need the name of the actual PCI device providing the cs5535 device.
If we can get this working, we can move over the rest of the hogs etc to software nodes and get rid of all the custom cs5535_gpio_set(), cs5535_gpio_clear() etc.
If it turns out that no-one is willing to actually test OLPC XO-1 patches, I will follow up with a patch to just delete the XO-1 support altogether.
--- arch/x86/platform/olpc/olpc.c | 33 ++++++++++++++++++++++++++++++++ sound/pci/cs5535audio/cs5535audio.c | 3 +-- sound/pci/cs5535audio/cs5535audio.h | 26 +++++++++++++------------ sound/pci/cs5535audio/cs5535audio_olpc.c | 32 +++++++++++++++---------------- sound/pci/cs5535audio/cs5535audio_pcm.c | 4 ++-- 5 files changed, 66 insertions(+), 32 deletions(-)
arch/x86/platform/olpc/olpc.c +33 -0
@@ -10,6 +10,8 @@#include <linux/init.h> #include <linux/export.h> #include <linux/delay.h> +#include <linux/gpio/machine.h> +#include <linux/gpio/property.h> #include <linux/io.h> #include <linux/string.h> #include <linux/platform_device.h>
@@ -17,6 +19,7 @@#include <linux/syscore_ops.h> #include <linux/mutex.h> #include <linux/olpc-ec.h> +#include <linux/property.h> #include <asm/geode.h> #include <asm/setup.h>
@@ -283,6 +286,32 @@ static struct olpc_ec_driver ec_xo1_5_driver = {#endif }; +/* +* Create software nodes for GPIO look-ups so we can keep the +* CS5535 GPIO driver abstract without peeking under the hood. +*/ +static const struct software_node cs5535_gpiochip_node = { + .name ="cs5535-gpio" , +}; + +static const struct property_entry olpc_snd_props[] = { +PROPERTY_ENTRY_GPIO ("mic-ac-gpios" , &cs5535_gpiochip_node, +OLPC_GPIO_MIC_AC ,GPIO_ACTIVE_HIGH ), + {} +}; + +static const struct software_node olpc_snd_node = { +/* TODO: dev_name(&pci->dev) for the OLPC CS5535 PCI device */ + .name ="" , + .properties = olpc_snd_props, +}; + +static const struct software_node *olpc_sw_nodes[] = { + &cs5535_gpiochip_node, + &olpc_snd_node, +NULL +}; +static int __init olpc_init (void ) {int r =0 ;
@@ -315,6 +344,10 @@ static int __init olpc_init(void)return r; } + r =software_node_register_node_group (olpc_sw_nodes); +if (r) +return r; +return 0 ; }
sound/pci/cs5535audio/cs5535audio.c +1 -2
@@ -164,7 +164,7 @@ static int snd_cs5535audio_mixer(struct cs5535audio *cs5535au)snd_ac97_tune_hardware (cs5535au->ac97, ac97_quirks, ac97_quirk); - err =olpc_quirks (card, cs5535au->ac97); + err =olpc_quirks (card, cs5535au);if (err <0 ) {dev_err (card->dev,"olpc quirks failed\n" );return err;
@@ -241,7 +241,6 @@ static irqreturn_t snd_cs5535audio_interrupt(int irq, void *dev_id)static void snd_cs5535audio_free (struct snd_card *card) { -olpc_quirks_cleanup (); } static int snd_cs5535audio_create(struct snd_card *card,
sound/pci/cs5535audio/cs5535audio.h +14 -12
@@ -2,6 +2,8 @@#ifndef __SOUND_CS5535AUDIO_H#define __SOUND_CS5535AUDIO_H +#include <linux/gpio/consumer.h> +#define cs_writel (cs5535au, reg, val) outl(val, (cs5535au)->port + reg)#define cs_writeb (cs5535au, reg, val) outb(val, (cs5535au)->port + reg)#define cs_readl (cs5535au, reg) inl((cs5535au)->port + reg)
@@ -93,6 +95,7 @@ struct cs5535audio {struct snd_pcm_substream *playback_substream;struct snd_pcm_substream *capture_substream;struct cs5535audio_dma dmas[NUM_CS5535AUDIO_DMAS ]; +struct gpio_desc *mic_ac; };extern const struct dev_pm_ops snd_cs5535audio_pm;
@@ -100,25 +103,24 @@ extern const struct dev_pm_ops snd_cs5535audio_pm;#ifdef CONFIG_OLPC void olpc_prequirks (struct snd_card *card,struct snd_ac97_template *ac97); -int olpc_quirks (struct snd_card *card,struct snd_ac97 *ac97); -void olpc_quirks_cleanup (void ); -void olpc_analog_input (struct snd_ac97 *ac97,int on); +int olpc_quirks (struct snd_card *card,struct cs5535audio *cs5535au); +void olpc_analog_input (struct cs5535audio *cs5535au,int on);void olpc_mic_bias (struct snd_ac97 *ac97,int on); -static inline void olpc_capture_open (struct snd_ac97 *ac97) +static inline void olpc_capture_open (struct cs5535audio *cs5535au) {/* default to Analog Input off */ -olpc_analog_input (ac97,0 ); +olpc_analog_input (cs5535au,0 );/* enable MIC Bias for recording */ -olpc_mic_bias (ac97,1 ); +olpc_mic_bias (cs5535au->ac97,1 ); } -static inline void olpc_capture_close (struct snd_ac97 *ac97) +static inline void olpc_capture_close (struct cs5535audio *cs5535au) {/* disable Analog Input */ -olpc_analog_input (ac97,0 ); +olpc_analog_input (cs5535au,0 );/* disable the MIC Bias (so the recording LED turns off) */ -olpc_mic_bias (ac97,0 ); +olpc_mic_bias (cs5535au->ac97,0 ); }#else static inline void olpc_prequirks(struct snd_card *card,
@@ -128,10 +130,10 @@ static inline int olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97) return 0; }static inline void olpc_quirks_cleanup (void ) { } -static inline void olpc_analog_input (struct snd_ac97 *ac97,int on) { } +static inline void olpc_analog_input (struct cs5535audio *cs5535au,int on) { }static inline void olpc_mic_bias (struct snd_ac97 *ac97,int on) { } -static inline void olpc_capture_open (struct snd_ac97 *ac97) { } -static inline void olpc_capture_close (struct snd_ac97 *ac97) { } +static inline void olpc_capture_open (struct cs5535audio *cs5535au) { } +static inline void olpc_capture_close (struct cs5535audio *cs5535au) { }#endif int snd_cs5535audio_pcm (struct cs5535audio *cs5535audio);
sound/pci/cs5535audio/cs5535audio_olpc.c +16 -16
@@ -9,7 +9,7 @@#include <sound/info.h> #include <sound/control.h> #include <sound/ac97_codec.h> -#include <linux/gpio.h> +#include <linux/gpio/consumer.h> #include <asm/olpc.h> #include "cs5535audio.h"
@@ -21,8 +21,9 @@* It has an Analog Input mode that is switched into (after disabling the * High Pass Filter) via GPIO. It is supported on B2 and later models. */ -void olpc_analog_input (struct snd_ac97 *ac97,int on) +void olpc_analog_input (struct cs5535audio *cs5535au,int on) { +struct snd_ac97 *ac97 = cs5535au->ac97;int err;if (!machine_is_olpc ())
@@ -38,7 +39,7 @@ void olpc_analog_input(struct snd_ac97 *ac97, int on) }/* set Analog Input through GPIO */ -gpio_set_value (OLPC_GPIO_MIC_AC , on); +gpiod_set_value (cs5535au->mic_ac, on); }/*
@@ -70,7 +71,9 @@ static int olpc_dc_info(struct snd_kcontrol *kctl,static int olpc_dc_get (struct snd_kcontrol *kctl,struct snd_ctl_elem_value *v) { - v->value.integer.value[0 ] =gpio_get_value (OLPC_GPIO_MIC_AC ); +struct cs5535audio *cs5535au =snd_kcontrol_chip (kctl); + + v->value.integer.value[0 ] =gpiod_get_value (cs5535au->mic_ac);return 0 ; }
@@ -78,7 +81,7 @@ static int olpc_dc_put(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *v) {struct cs5535audio *cs5535au =snd_kcontrol_chip (kctl); -olpc_analog_input (cs5535au->ac97, v->value.integer.value[0 ]); +olpc_analog_input (cs5535au, v->value.integer.value[0 ]);return 1 ; }
@@ -141,19 +144,22 @@ void olpc_prequirks(struct snd_card *card, ac97->scaps |=AC97_SCAP_INV_EAPD ; } -int olpc_quirks (struct snd_card *card,struct snd_ac97 *ac97) +int olpc_quirks (struct snd_card *card,struct cs5535audio *cs5535au) { +struct snd_ac97 *ac97 = cs5535au->ac97;struct snd_ctl_elem_id elem;int i, err;if (!machine_is_olpc ())return 0 ; -if (gpio_request (OLPC_GPIO_MIC_AC ,DRV_NAME )) { -dev_err (card->dev,"unable to allocate MIC GPIO\n" ); -return -EIO ; + cs5535au->mic_ac =devm_gpiod_get_optional (card->dev,"mic-ac" , +GPIOD_OUT_LOW ); +if (IS_ERR (cs5535au->mic_ac)) { +dev_err (card->dev,"unable to allocate MIC AC GPIO\n" ); +return PTR_ERR (cs5535au->mic_ac); } -gpio_direction_output (OLPC_GPIO_MIC_AC ,0 ); +gpiod_set_consumer_name (cs5535au->mic_ac,DRV_NAME );/* drop the original AD1888 HPF control */ memset (&elem,0 ,sizeof (elem));
@@ -179,9 +185,3 @@ int olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97)olpc_mic_bias (ac97,0 );return 0 ; } - -void olpc_quirks_cleanup (void ) -{ -if (machine_is_olpc ()) -gpio_free (OLPC_GPIO_MIC_AC ); -}
sound/pci/cs5535audio/cs5535audio_pcm.c +2 -2
@@ -341,14 +341,14 @@ static int snd_cs5535audio_capture_open(struct snd_pcm_substream *substream) SNDRV_PCM_HW_PARAM_PERIODS);if (err <0 )return err; -olpc_capture_open (cs5535au->ac97); +olpc_capture_open (cs5535au);return 0 ; }static int snd_cs5535audio_capture_close (struct snd_pcm_substream *substream) {struct cs5535audio *cs5535au =snd_pcm_substream_chip (substream); -olpc_capture_close (cs5535au->ac97); +olpc_capture_close (cs5535au);return 0 ; }
---
base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
change-id: 20260319-asoc-olpc-ff15cf19420b
Best regards,
Signature · 1 line
Linus Walleij <[email protected]>
Bartosz Golaszewski
maintainerQuoted 45 lines · Linus Walleij
This needs real hardware to continue.
At the TODO spot, we need the name of the actual PCI device providing the cs5535 device.
If we can get this working, we can move over the rest of the hogs etc to software nodes and get rid of all the custom
cs5535_gpio_set(),cs5535_gpio_clear()etc.If it turns out that no-one is willing to actually test OLPC XO-1 patches, I will follow up with a patch to just delete the XO-1 support altogether.
Signed-off-by Linus Walleij <[email protected]>--- arch/x86/platform/olpc/olpc.c | 33 ++++++++++++++++++++++++++++++++ sound/pci/cs5535audio/cs5535audio.c | 3 +-- sound/pci/cs5535audio/cs5535audio.h | 26 +++++++++++++------------ sound/pci/cs5535audio/cs5535audio_olpc.c | 32 +++++++++++++++---------------- sound/pci/cs5535audio/cs5535audio_pcm.c | 4 ++-- 5 files changed, 66 insertions(+), 32 deletions(-)arch/x86/platform/olpc/olpc.c +3
-0@@ -10,6 +10,8 @@#include <linux/init.h> #include <linux/export.h> #include <linux/delay.h> +#include <linux/gpio/machine.h> +#include <linux/gpio/property.h> #include <linux/io.h> #include <linux/string.h> #include <linux/platform_device.h> @@ -17,6 +19,7 @@#include <linux/syscore_ops.h> #include <linux/mutex.h> #include <linux/olpc-ec.h> +#include <linux/property.h> #include <asm/geode.h> #include <asm/setup.h>
arch/x86/platform/olpc/olpc.c static struct olpc_ec_driver ec_xo1_5_driver = { · line 295
Quoted 10 lines
arch/x86/platform/olpc/olpc.c +7
-0@@ -283,6 +286,32 @@ static struct olpc_ec_driver ec_xo1_5_driver = {#endif }; +/* +* Create software nodes for GPIO look-ups so we can keep the +* CS5535 GPIO driver abstract without peeking under the hood. +*/ +static const struct software_node cs5535_gpiochip_node = { + .name ="cs5535-gpio" , +};
Ugh, I'm actively trying to move away from the "dangling software node" approach. :( I've been sending patches attaching software nodes to their target controller devices and I'm trying to come up with a way of automated assignment of secondary firmware nodes for this particular use-case.
I should have NAKed this idea when it was first introduced in GPIO swnode code but I just didn't really understand what was going on here.
Could we instead define the software node in cs5535-mfd.c and assign it to the GPIO cell, then expose it in linux/cs5535.h as a symbol visible to this file?
Bart
Linus Walleij
maintainerQuoted 2 lines · Bartosz Golaszewski
Could we instead define the software node in
cs5535-mfd.cand assign it to the GPIO cell, then expose it inlinux/cs5535.has a symbol visible to this file?
Yes we can, but as this should like with the GPIO itself only be done to the device if and only if it is an OLPC laptop, it means adding another #include <asm/olpc.h> and restrict that include to only happen when using x86.
This PCI-standard-device-but-not-quite mess is a big headache.
I kind of hope no-one will step up and test this so I can just delete the whole mess.
Yours,
Linus Walleij
kernel test robot
build botkernel test robot noticed the following build errors:
Hi Linus,
kernel test robot noticed the following build errors:
[auto build test ERROR on 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f]
url: https://github.com/intel-lab-lkp/linux/commits/Linus-Walleij/RFT-x86_32-Move-OLPC-XO-1-audio-GPIO-to-software-nodes/20260326-073823 base: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f patch link: https://lore.kernel.org/r/20260325-asoc-olpc-v1-1-ebe6de05c7e2%40kernel.org patch subject: [PATCH] RFT: x86_32: Move OLPC XO-1 audio GPIO to software nodes config: sparc-randconfig-001-20260326 (https://download.01.org/0day-ci/archive/20260326/[email protected]/config) compiler: sparc-linux-gcc (GCC) 8.5.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260326/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
sound/pci/cs5535audio/cs5535audio.c: In function 'snd_cs5535audio_mixer':
>> sound/pci/cs5535audio/cs5535audio.c:167:26: error: passing argument 2 of 'olpc_quirks' from incompatible pointer type [-Werror=incompatible-pointer-types]
err = olpc_quirks(card, cs5535au);
^~~~~~~~ In file included from sound/pci/cs5535audio/cs5535audio.c:24:
sound/pci/cs5535audio/cs5535audio.h:128:71: note: expected 'struct snd_ac97 *' but argument is of type 'struct cs5535audio *'
static inline int olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97)
~~~~~~~~~~~~~~~~~^~~~
cc1: some warnings being treated as errors
vim +/olpc_quirks +167 sound/pci/cs5535audio/cs5535audio.c
134
135 static int snd_cs5535audio_mixer(struct cs5535audio *cs5535au)
136 {
137 struct snd_card *card = cs5535au->card;
138 struct snd_ac97_bus *pbus;
139 struct snd_ac97_template ac97;
140 int err;
141 static const struct snd_ac97_bus_ops ops = {
142 .write = snd_cs5535audio_ac97_codec_write,
143 .read = snd_cs5535audio_ac97_codec_read,
144 };
145
146 err = snd_ac97_bus(card, 0, &ops, NULL, &pbus);
147 if (err < 0)
148 return err;
149
150 memset(&ac97, 0, sizeof(ac97));
151 ac97.scaps = AC97_SCAP_AUDIO | AC97_SCAP_SKIP_MODEM
152 | AC97_SCAP_POWER_SAVE;
153 ac97.private_data = cs5535au;
154 ac97.pci = cs5535au->pci;
155
156 /* set any OLPC-specific scaps */
157 olpc_prequirks(card, &ac97);
158
159 err = snd_ac97_mixer(pbus, &ac97, &cs5535au->ac97);
160 if (err < 0) {
161 dev_err(card->dev, "mixer failed\n");
162 return err;
163 }
164
165 snd_ac97_tune_hardware(cs5535au->ac97, ac97_quirks, ac97_quirk);
166
> 167 err = olpc_quirks(card, cs5535au);
168 if (err < 0) {
169 dev_err(card->dev, "olpc quirks failed\n");
170 return err;
171 }
172
173 return 0;
174 }
175
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botkernel test robot noticed the following build errors:
Hi Linus,
kernel test robot noticed the following build errors:
[auto build test ERROR on 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f]
url: https://github.com/intel-lab-lkp/linux/commits/Linus-Walleij/RFT-x86_32-Move-OLPC-XO-1-audio-GPIO-to-software-nodes/20260326-073823 base: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f patch link: https://lore.kernel.org/r/20260325-asoc-olpc-v1-1-ebe6de05c7e2%40kernel.org patch subject: [PATCH] RFT: x86_32: Move OLPC XO-1 audio GPIO to software nodes config: sparc64-allmodconfig (https://download.01.org/0day-ci/archive/20260326/[email protected]/config) compiler: clang version 23.0.0git (https://github.com/llvm/llvm-project 054e11d1a17e5ba88bb1a8ef32fad3346e80b186) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260326/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
>> sound/pci/cs5535audio/cs5535audio.c:167:26: error: incompatible pointer types passing 'struct cs5535audio *' to parameter of type 'struct snd_ac97 *' [-Wincompatible-pointer-types]
167 | err = olpc_quirks(card, cs5535au);
| ^~~~~~~~ sound/pci/cs5535audio/cs5535audio.h:128:71: note: passing argument to parameter 'ac97' here
128 | static inline int olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97)
| ^
1 error generated.
vim +167 sound/pci/cs5535audio/cs5535audio.c
134
135 static int snd_cs5535audio_mixer(struct cs5535audio *cs5535au)
136 {
137 struct snd_card *card = cs5535au->card;
138 struct snd_ac97_bus *pbus;
139 struct snd_ac97_template ac97;
140 int err;
141 static const struct snd_ac97_bus_ops ops = {
142 .write = snd_cs5535audio_ac97_codec_write,
143 .read = snd_cs5535audio_ac97_codec_read,
144 };
145
146 err = snd_ac97_bus(card, 0, &ops, NULL, &pbus);
147 if (err < 0)
148 return err;
149
150 memset(&ac97, 0, sizeof(ac97));
151 ac97.scaps = AC97_SCAP_AUDIO | AC97_SCAP_SKIP_MODEM
152 | AC97_SCAP_POWER_SAVE;
153 ac97.private_data = cs5535au;
154 ac97.pci = cs5535au->pci;
155
156 /* set any OLPC-specific scaps */
157 olpc_prequirks(card, &ac97);
158
159 err = snd_ac97_mixer(pbus, &ac97, &cs5535au->ac97);
160 if (err < 0) {
161 dev_err(card->dev, "mixer failed\n");
162 return err;
163 }
164
165 snd_ac97_tune_hardware(cs5535au->ac97, ac97_quirks, ac97_quirk);
166
> 167 err = olpc_quirks(card, cs5535au);
168 if (err < 0) {
169 dev_err(card->dev, "olpc quirks failed\n");
170 return err;
171 }
172
173 return 0;
174 }
175
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki