// SPDX-License-Identifier: GPL-2.0-or-later
/*
* PMac Tumbler/Snapper lowlevel functions
*
* Copyright (c) by Takashi Iwai <tiwai@suse.de>
*
* Rene Rebe <rene.rebe@gmx.net>:
* * update from shadow registers on wakeup and headphone plug
* * automatically toggle DRC on headphone plug
*/
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/i2c.h>
#include <linux/kmod.h>
#include <linux/slab.h>
#include <linux/interrupt.h>
#include <linux/string.h>
#include <linux/of_irq.h>
#include <linux/io.h>
#include <sound/core.h>
#include <asm/irq.h>
#include <asm/machdep.h>
#include <asm/pmac_feature.h>
#include "pmac.h"
#include "tumbler_volume.h"
#undef DEBUG
#ifdef DEBUG
#define DBG(fmt...) printk(KERN_DEBUG fmt)
#else
#define DBG(fmt...)
#endif
#define IS_G4DA (of_machine_is_compatible("PowerMac3,4"))
/* i2c address for tumbler */
#define TAS_I2C_ADDR 0x34
/* registers */
#define TAS_REG_MCS 0x01 /* main control */
#define TAS_REG_DRC 0x02
#define TAS_REG_VOL 0x04
#define TAS_REG_TREBLE 0x05
#define TAS_REG_BASS 0x06
#define TAS_REG_INPUT1 0x07
#define TAS_REG_INPUT2 0x08
/* tas3001c */
#define TAS_REG_PCM TAS_REG_INPUT1
/* tas3004 */
#define TAS_REG_LMIX TAS_REG_INPUT1
#define TAS_REG_RMIX TAS_REG_INPUT2
#define TAS_REG_MCS2 0x43 /* main control 2 */
#define TAS_REG_ACS 0x40 /* analog control */
/* mono volumes for tas3001c/tas3004 */
enum {
VOL_IDX_PCM_MONO, /* tas3001c only */
VOL_IDX_BASS, VOL_IDX_TREBLE,
VOL_IDX_LAST_MONO
};
/* stereo volumes for tas3004 */
enum {
VOL_IDX_PCM, VOL_IDX_PCM2, VOL_IDX_ADC,
VOL_IDX_LAST_MIX
};
struct pmac_gpio {
unsigned int addr;
u8 active_val;
u8 inactive_val;
u8 active_state;
};
struct pmac_tumbler {
struct