linux/include/linux/wm97xx.h

/* SPDX-License-Identifier: GPL-2.0 */

/*
 * Register bits and API for Wolfson WM97xx series of codecs
 */

#ifndef _LINUX_WM97XX_H
#define _LINUX_WM97XX_H

#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/ac97_codec.h>
#include <sound/initval.h>
#include <linux/types.h>
#include <linux/list.h>
#include <linux/input.h>	/* Input device layer */
#include <linux/platform_device.h>

/*
 * WM97xx variants
 */
#define WM97xx_GENERIC
#define WM97xx_WM1613

/*
 * WM97xx AC97 Touchscreen registers
 */
#define AC97_WM97XX_DIGITISER1
#define AC97_WM97XX_DIGITISER2
#define AC97_WM97XX_DIGITISER_RD
#define AC97_WM9713_DIG1
#define AC97_WM9713_DIG2
#define AC97_WM9713_DIG3

/*
 * WM97xx register bits
 */
#define WM97XX_POLL
#define WM97XX_ADCSEL_X
#define WM97XX_ADCSEL_Y
#define WM97XX_ADCSEL_PRES
#define WM97XX_AUX_ID1
#define WM97XX_AUX_ID2
#define WM97XX_AUX_ID3
#define WM97XX_AUX_ID4
#define WM97XX_ADCSEL_MASK
#define WM97XX_COO
#define WM97XX_CTC
#define WM97XX_CM_RATE_93
#define WM97XX_CM_RATE_187
#define WM97XX_CM_RATE_375
#define WM97XX_CM_RATE_750
#define WM97XX_CM_RATE_8K
#define WM97XX_CM_RATE_12K
#define WM97XX_CM_RATE_24K
#define WM97XX_CM_RATE_48K
#define WM97XX_CM_RATE_MASK
#define WM97XX_RATE(i)
#define WM97XX_DELAY(i)
#define WM97XX_DELAY_MASK
#define WM97XX_SLEN
#define WM97XX_SLT(i)
#define WM97XX_SLT_MASK
#define WM97XX_PRP_DETW
#define WM97XX_PRP_DET
#define WM97XX_PRP_DET_DIG
#define WM97XX_RPR
#define WM97XX_PEN_DOWN

/* WM9712 Bits */
#define WM9712_45W
#define WM9712_PDEN
#define WM9712_WAIT
#define WM9712_PIL
#define WM9712_MASK_HI
#define WM9712_MASK_EDGE
#define WM9712_MASK_SYNC
#define WM9712_RPU(i)
#define WM9712_PD(i)

/* WM9712 Registers */
#define AC97_WM9712_POWER
#define AC97_WM9712_REV

/* WM9705 Bits */
#define WM9705_PDEN
#define WM9705_PINV
#define WM9705_BSEN
#define WM9705_BINV
#define WM9705_WAIT
#define WM9705_PIL
#define WM9705_PHIZ
#define WM9705_MASK_HI
#define WM9705_MASK_EDGE
#define WM9705_MASK_SYNC
#define WM9705_PDD(i)


/* WM9713 Bits */
#define WM9713_PDPOL
#define WM9713_POLL
#define WM9713_CTC
#define WM9713_ADCSEL_X
#define WM9713_ADCSEL_Y
#define WM9713_ADCSEL_PRES
#define WM9713_COO
#define WM9713_45W
#define WM9713_PDEN
#define WM9713_ADCSEL_MASK
#define WM9713_WAIT

/* AUX ADC ID's */
#define TS_COMP1
#define TS_COMP2
#define TS_BMON
#define TS_WIPER

/* ID numbers */
#define WM97XX_ID1
#define WM9712_ID2
#define WM9705_ID2
#define WM9713_ID2

/* Codec GPIO's */
#define WM97XX_MAX_GPIO
#define WM97XX_GPIO_1
#define WM97XX_GPIO_2
#define WM97XX_GPIO_3
#define WM97XX_GPIO_4
#define WM97XX_GPIO_5
#define WM97XX_GPIO_6
#define WM97XX_GPIO_7
#define WM97XX_GPIO_8
#define WM97XX_GPIO_9
#define WM97XX_GPIO_10
#define WM97XX_GPIO_11
#define WM97XX_GPIO_12
#define WM97XX_GPIO_13
#define WM97XX_GPIO_14
#define WM97XX_GPIO_15


#define AC97_LINK_FRAME


/*---------------- Return codes from sample reading functions ---------------*/

/* More data is available; call the sample gathering function again */
#define RC_AGAIN
/* The returned sample is valid */
#define RC_VALID
/* The pen is up (the first RC_VALID without RC_PENUP means pen is down) */
#define RC_PENUP
/* The pen is down (RC_VALID implies RC_PENDOWN, but sometimes it is helpful
   to tell the handler that the pen is down but we don't know yet his coords,
   so the handler should not sleep or wait for pendown irq) */
#define RC_PENDOWN

/*
 * The wm97xx driver provides a private API for writing platform-specific
 * drivers.
 */

/* The structure used to return arch specific sampled data into */
struct wm97xx_data {};

/*
 * Codec GPIO status
 */
enum wm97xx_gpio_status {};

/*
 * Codec GPIO direction
 */
enum wm97xx_gpio_dir {};

/*
 * Codec GPIO polarity
 */
enum wm97xx_gpio_pol {};

/*
 * Codec GPIO sticky
 */
enum wm97xx_gpio_sticky {};

/*
 * Codec GPIO wake
 */
enum wm97xx_gpio_wake {};

/*
 * Digitiser ioctl commands
 */
#define WM97XX_DIG_START
#define WM97XX_DIG_STOP
#define WM97XX_PHY_INIT
#define WM97XX_AUX_PREPARE
#define WM97XX_DIG_RESTORE

struct wm97xx;

extern struct wm97xx_codec_drv wm9705_codec;
extern struct wm97xx_codec_drv wm9712_codec;
extern struct wm97xx_codec_drv wm9713_codec;

/*
 * Codec driver interface - allows mapping to WM9705/12/13 and newer codecs
 */
struct wm97xx_codec_drv {};


/* Machine specific and accelerated touch operations */
struct wm97xx_mach_ops {};

struct wm97xx {};

struct wm97xx_batt_pdata {};

struct wm97xx_pdata {};

/*
 * Codec GPIO access (not supported on WM9705)
 * This can be used to set/get codec GPIO and Virtual GPIO status.
 */
enum wm97xx_gpio_status wm97xx_get_gpio(struct wm97xx *wm, u32 gpio);
void wm97xx_set_gpio(struct wm97xx *wm, u32 gpio,
			  enum wm97xx_gpio_status status);
void wm97xx_config_gpio(struct wm97xx *wm, u32 gpio,
				     enum wm97xx_gpio_dir dir,
				     enum wm97xx_gpio_pol pol,
				     enum wm97xx_gpio_sticky sticky,
				     enum wm97xx_gpio_wake wake);

void wm97xx_set_suspend_mode(struct wm97xx *wm, u16 mode);

/* codec AC97 IO access */
int wm97xx_reg_read(struct wm97xx *wm, u16 reg);
void wm97xx_reg_write(struct wm97xx *wm, u16 reg, u16 val);

/* aux adc readback */
int wm97xx_read_aux_adc(struct wm97xx *wm, u16 adcsel);

/* machine ops */
int wm97xx_register_mach_ops(struct wm97xx *, struct wm97xx_mach_ops *);
void wm97xx_unregister_mach_ops(struct wm97xx *);

#endif