linux/drivers/fsi/fsi-master.h

/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * FSI master definitions. These comprise the core <--> master interface,
 * to allow the core to interact with the (hardware-specific) masters.
 *
 * Copyright (C) IBM Corporation 2016
 */

#ifndef DRIVERS_FSI_MASTER_H
#define DRIVERS_FSI_MASTER_H

#include <linux/device.h>
#include <linux/mutex.h>

/*
 * Master registers
 *
 * These are used by hardware masters, such as the one in the FSP2, AST2600 and
 * the hub master in POWER processors.
 */

/* Control Registers */
#define FSI_MMODE
#define FSI_MDLYR
#define FSI_MCRSP
#define FSI_MENP0
#define FSI_MLEVP0
#define FSI_MSENP0
#define FSI_MCENP0
#define FSI_MAEB
#define FSI_MVER
#define FSI_MSTAP0
#define FSI_MRESP0
#define FSI_MESRB0
#define FSI_MRESB0
#define FSI_MSCSB0
#define FSI_MATRB0
#define FSI_MDTRB0
#define FSI_MECTRL

/* MMODE: Mode control */
#define FSI_MMODE_EIP
#define FSI_MMODE_ECRC
#define FSI_MMODE_RELA
#define FSI_MMODE_EPC
#define FSI_MMODE_P8_TO_LSB
						/*   MSB=1, LSB=0 is 0.8 ms */
						/*   MSB=0, LSB=1 is 0.9 ms */
#define FSI_MMODE_CRS0SHFT
#define FSI_MMODE_CRS0MASK
#define FSI_MMODE_CRS1SHFT
#define FSI_MMODE_CRS1MASK

/* MRESB: Reset bridge */
#define FSI_MRESB_RST_GEN
#define FSI_MRESB_RST_ERR

/* MRESP: Reset port */
#define FSI_MRESP_RST_ALL_MASTER
#define FSI_MRESP_RST_ALL_LINK
#define FSI_MRESP_RST_MCR
#define FSI_MRESP_RST_PYE
#define FSI_MRESP_RST_ALL

/* MECTRL: Error control */
#define FSI_MECTRL_EOAE
						/* master 0 in error */
#define FSI_MECTRL_P8_AUTO_TERM

#define FSI_HUB_LINK_OFFSET
#define FSI_HUB_LINK_SIZE
#define FSI_HUB_MASTER_MAX_LINKS

/*
 * Protocol definitions
 *
 * These are used by low level masters that bit-bang out the protocol
 */

/* Various protocol delays */
#define FSI_ECHO_DELAY_CLOCKS
#define FSI_SEND_DELAY_CLOCKS
#define FSI_PRE_BREAK_CLOCKS
#define FSI_BREAK_CLOCKS
#define FSI_POST_BREAK_CLOCKS
#define FSI_INIT_CLOCKS
#define FSI_MASTER_DPOLL_CLOCKS
#define FSI_MASTER_EPOLL_CLOCKS

/* Various retry maximums */
#define FSI_CRC_ERR_RETRIES
#define FSI_MASTER_MAX_BUSY
#define FSI_MASTER_MTOE_COUNT

/* Command encodings */
#define FSI_CMD_DPOLL
#define FSI_CMD_EPOLL
#define FSI_CMD_TERM
#define FSI_CMD_ABS_AR
#define FSI_CMD_REL_AR
#define FSI_CMD_SAME_AR

/* Slave responses */
#define FSI_RESP_ACK
#define FSI_RESP_BUSY
#define FSI_RESP_ERRA
#define FSI_RESP_ERRC

/* Misc */
#define FSI_CRC_SIZE

/* fsi-master definition and flags */
#define FSI_MASTER_FLAG_SWCLOCK

/*
 * Structures and function prototypes
 *
 * These are common to all masters
 */

struct fsi_master {};

#define to_fsi_master(d)

/**
 * fsi_master registration & lifetime: the fsi_master_register() and
 * fsi_master_unregister() functions will take ownership of the master, and
 * ->dev in particular. The registration path performs a get_device(), which
 * takes the first reference on the device. Similarly, the unregistration path
 * performs a put_device(), which may well drop the last reference.
 *
 * This means that master implementations *may* need to hold their own
 * reference (via get_device()) on master->dev. In particular, if the device's
 * ->release callback frees the fsi_master, then fsi_master_unregister will
 * invoke this free if no other reference is held.
 *
 * The same applies for the error path of fsi_master_register; if the call
 * fails, dev->release will have been invoked.
 */
extern int fsi_master_register(struct fsi_master *master);
extern void fsi_master_unregister(struct fsi_master *master);

extern int fsi_master_rescan(struct fsi_master *master);

#endif /* DRIVERS_FSI_MASTER_H */