pxa2xx-ac97-lib: move set_resetgpio to pxa27x.c
Subsystems (4)
PATCH 1/2 pxa2xx-ac97-lib: move set_resetgpio to pxa27x.c
The code related to set_resetgpio is pxa27x specific and should not be present in sound driver lib. Move it to appropriate place.
The code is moved to arch/arm as it will be converted from (exported) pxa_gpio_mode() calls to use MFP which are unexported to modules.
--- arch/arm/mach-pxa/include/mach/audio.h | 24 ++++++++++++++++ arch/arm/mach-pxa/pxa27x.c | 37 +++++++++++++++++++++++++ sound/arm/pxa2xx-ac97-lib.c | 47 +++----------------------------- 3 files changed, 65 insertions(+), 43 deletions(-)
arch/arm/mach-pxa/include/mach/audio.h +24 -0
@@ -24,4 +24,28 @@ typedef struct {extern void pxa_set_ac97_info (pxa2xx_audio_ops_t *ops); +/* +* Beware PXA27x bugs: +* +* o Slot 12 read from modem space will hang controller. +* o CDONE, SDONE interrupt fails after any slot 12 IO. +* +* We therefore have an hybrid approach for waiting on SDONE (interrupt or +* 1 jiffy timeout if interrupt never comes). +*/ + +enum { +RESETGPIO_FORCE_HIGH , +RESETGPIO_FORCE_LOW , +RESETGPIO_NORMAL_ALTFUNC +}; + +#if defined(CONFIG_PXA27x) +extern void pxa27x_ac97_reset (int reset_gpio,int resetgpio_action); +#else +static inline void pxa27x_ac97_reset (int reset_gpio,int resetgpio_action) +{ +} +#endif +#endif
arch/arm/mach-pxa/pxa27x.c +37 -0
@@ -28,6 +28,7 @@#include <mach/pm.h> #include <mach/dma.h> #include <mach/i2c.h> +#include <mach/audio.h> #include "generic.h" #include "devices.h"
@@ -345,6 +346,42 @@ void __init pxa27x_set_i2c_power_info(struct i2c_pxa_platform_data *info)pxa_register_device (&pxa27x_device_i2c_power, info); } +/** +* pxa27x_ac97_reset - computes and sets the AC97_RESET gpio mode on PXA +* @mode: chosen action +* +* As the PXA27x CPUs suffer from a AC97 bug, a manual control of the reset line +* must be done to insure proper work of AC97 reset line. This function +* computes the correct gpio_mode for further use by reset functions, and +* applied the change through pxa_gpio_mode. +*/ +/* temporary include */ +#include <mach/pxa2xx-gpio.h> +void pxa27x_ac97_reset (int reset_gpio,int resetgpio_action) +{ +int mode =0 ; + +if (reset_gpio) +switch (resetgpio_action) { +case RESETGPIO_NORMAL_ALTFUNC : +if (reset_gpio ==113 ) + mode =113 |GPIO_ALT_FN_2_OUT ; +if (reset_gpio ==95 ) + mode =95 |GPIO_ALT_FN_1_OUT ; +break ; +case RESETGPIO_FORCE_LOW : + mode = reset_gpio |GPIO_OUT |GPIO_DFLT_LOW ; +break ; +case RESETGPIO_FORCE_HIGH : + mode = reset_gpio |GPIO_OUT |GPIO_DFLT_HIGH ; +break ; + }; + +if (mode) +pxa_gpio_mode (mode); +} +EXPORT_SYMBOL (pxa27x_ac97_reset); +static struct platform_device *devices[]__initdata = { &pxa27x_device_udc, &pxa_device_ffuart,
sound/arm/pxa2xx-ac97-lib.c +4 -43
73 lines not on this page · raw message
Signature · 1 line
1.6.2.4
PATCH 2/2 pxa2xx: make pxa2xx_ac97_reset use MFP
Stop using obsolete pxa_gpio_mode, use MFP and GPIO API for setting pin parameters.
--- arch/arm/mach-pxa/pxa27x.c | 20 ++++++++++---------- 1 files changed, 10 insertions(+), 10 deletions(-)
arch/arm/mach-pxa/pxa27x.c +10 -10
@@ -355,30 +355,30 @@ void __init pxa27x_set_i2c_power_info(struct i2c_pxa_platform_data *info)* computes the correct gpio_mode for further use by reset functions, and * applied the change through pxa_gpio_mode. */ -/* temporary include */ -#include <mach/pxa2xx-gpio.h> void pxa27x_ac97_reset (int reset_gpio,int resetgpio_action) { -int mode =0 ; +unsigned long mfp[1 ] = {0 };if (reset_gpio)switch (resetgpio_action) {case RESETGPIO_NORMAL_ALTFUNC :if (reset_gpio ==113 ) - mode =113 |GPIO_ALT_FN_2_OUT ; + mfp[0 ] = GPIO113_AC97_nRESET;if (reset_gpio ==95 ) - mode =95 |GPIO_ALT_FN_1_OUT ; + mfp[0 ] = GPIO95_AC97_nRESET; +pxa2xx_mfp_config (mfp,1 );break ;case RESETGPIO_FORCE_LOW : - mode = reset_gpio |GPIO_OUT |GPIO_DFLT_LOW ; + mfp[0 ] =MFP_CFG_OUT (GPIO0 ,AF0 ,DRIVE_LOW ) |MFP_PIN (reset_gpio); +pxa2xx_mfp_config (mfp,1 ); +gpio_direction_output (reset_gpio,0 );break ;case RESETGPIO_FORCE_HIGH : - mode = reset_gpio |GPIO_OUT |GPIO_DFLT_HIGH ; + mfp[0 ] =MFP_CFG_OUT (GPIO0 ,AF0 ,DRIVE_HIGH ) |MFP_PIN (reset_gpio); +pxa2xx_mfp_config (mfp,1 ); +gpio_direction_output (reset_gpio,1 );break ; }; - -if (mode) -pxa_gpio_mode (mode); }EXPORT_SYMBOL (pxa27x_ac97_reset);
Signature · 1 line
1.6.2.4
Quoted 6 lines · Dmitry Eremin-Solenikov
The code related to
set_resetgpiois pxa27x specific and should not be present in sound driver lib. Move it to appropriate place.The code is moved to
arch/armas it will be converted from (exported)pxa_gpio_mode()calls to use MFP which are unexported to modules.
Having thought a while about this, and based on Mark's previous comment, I'm thinking of moving this code to another place might not be the best choice, there are two other ways out from my POV:
1. having mfp.c export mfp_config() for external usage
2. or having something like IrDA, i.e. platform specific hooks to make the driver code generic
I personally prefer way 2) but don't have time for a clean solution yet, maybe you can help take a look into this. That would be nice.
- eric
Quoted 7 lines · Eric Miao
there are two other ways out from my POV:
2. or having something like IrDA, i.e. platform specific hooks to make the driver code generic
I personally prefer way 2) but don't have time for a clean solution yet, maybe you can help take a look into this. That would be nice.
For 2 we should probably just move all the reset implementations into the CPU code and then either have a function to select the implementation or keep using the current code but move the functions it references.
I don't really mind how this is done so long as you guys are happy with it, though if we're going to move the pxa27x functions only a better commit log explaining the issue with the MFP API would be nice.