<commit_before>/*
 * Based on sound/arm/pxa2xx-ac97.c and sound/soc/pxa/pxa2xx-ac97.c
 * which contain:
 *
 * Author:	<NAME>
 * Created:	Dec 02, 2004
 * Copyright:	MontaVista Software Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#include <linux/kernel.h>
#include <linux/platform_device.h>
#include <linux/interrupt.h>
#include <linux/clk.h>
#include <linux/delay.h>

#include <sound/ac97_codec.h>
#include <sound/pxa2xx-lib.h>

#include <asm/irq.h>
#include <mach/regs-ac97.h>
#include <mach/pxa2xx-gpio.h>
#include <mach/audio.h>

static DEFINE_MUTEX(car_mutex);
static DECLARE_WAIT_QUEUE_HEAD(gsr_wq);
static volatile long gsr_bits;
static struct clk *ac97_clk;
static struct clk *ac97conf_clk;
static int reset_gpio;

/*
 * 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
};

/**
 * set_resetgpio_mode - 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.
 */
static void set_resetgpio_mode(int resetgpio_action)
{
	int mode = 0;

	if (reset_gpio)
		switch (resetgpio_action) {
		case RESETGPIO_NORMAL_ALTFUNC:
			if (reset_gpio == 113)
				mode = 113 | GPIO_OUT | GPIO_DFLT_LOW;
			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);
}
<commit_msg>pxa2xx-ac97: fix reset gpio mode setting<commit_after>/*
 * Based on sound/arm/pxa2xx-ac97.c and sound/soc/pxa/pxa2xx-ac97.c
 * which contain:
 *
 * Author:	<NAME>
 * Created:	Dec 02, 2004
 * Copyright:	MontaVista Software Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#include <linux/kernel.h>
#include <linux/platform_device.h>
#include <linux/interrupt.h>
#include <linux/clk.h>
#include <linux/delay.h>

#include <sound/ac97_codec.h>
#include <sound/pxa2xx-lib.h>

#include <asm/irq.h>
#include <mach/regs-ac97.h>
#include <mach/pxa2xx-gpio.h>
#include <mach/audio.h>

static DEFINE_MUTEX(car_mutex);
static DECLARE_WAIT_QUEUE_HEAD(gsr_wq);
static volatile long gsr_bits;
static struct clk *ac97_clk;
static struct clk *ac97conf_clk;
static int reset_gpio;

/*
 * 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
};

/**
 * set_resetgpio_mode - 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.
 */
static void set_resetgpio_mode(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);
}

{'fraction_non_alphanumeric': 0.09156570363466915, 'fraction_numerical': 0.024231127679403542, 'mean_word_length': 4.0328253223915596, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6059504', 'n_tokens_mistral': 1672, 'n_tokens_neox': 1543, 'n_words': 478}