/* SPDX-License-Identifier: GPL-2.0-only */1/* OMAP SSI internal interface.2*3* Copyright (C) 2010 Nokia Corporation. All rights reserved.4* Copyright (C) 2013 Sebastian Reichel5*6* Contact: Carlos Chinea <[email protected]>7*/89#ifndef __LINUX_HSI_OMAP_SSI_H__10#define __LINUX_HSI_OMAP_SSI_H__1112#include <linux/device.h>13#include <linux/module.h>14#include <linux/platform_device.h>15#include <linux/hsi/hsi.h>16#include <linux/gpio/consumer.h>17#include <linux/interrupt.h>18#include <linux/io.h>1920#define SSI_MAX_CHANNELS 821#define SSI_MAX_GDD_LCH 822#define SSI_BYTES_TO_FRAMES(x) ((((x) - 1) >> 2) + 1)2324#define SSI_WAKE_EN 02526/**27* struct omap_ssm_ctx - OMAP synchronous serial module (TX/RX) context28* @mode: Bit transmission mode29* @channels: Number of channels30* @framesize: Frame size in bits31* @timeout: RX frame timeout32* @divisor: TX divider33* @arb_mode: Arbitration mode for TX frame (Round robin, priority)34*/35struct omap_ssm_ctx {36u32 mode;37u32 channels;38u32 frame_size;39union {40u32 timeout; /* Rx Only */41struct {42u32 arb_mode;43u32 divisor;44}; /* Tx only */45};46};4748/**49* struct omap_ssi_port - OMAP SSI port data50* @dev: device associated to the port (HSI port)51* @pdev: platform device associated to the port52* @sst_dma: SSI transmitter physical base address53* @ssr_dma: SSI receiver physical base address54* @sst_base: SSI transmitter base address55* @ssr_base: SSI receiver base address56* @wk_lock: spin lock to serialize access to the wake lines57* @lock: Spin lock to serialize access to the SSI port58* @channels: Current number of channels configured (1,2,4 or 8)59* @txqueue: TX message queues60* @rxqueue: RX message queues61* @brkqueue: Queue of incoming HWBREAK requests (FRAME mode)62* @errqueue: Queue for failed messages63* @errqueue_work: Delayed Work for failed messages64* @irq: IRQ number65* @wake_irq: IRQ number for incoming wake line (-1 if none)66* @wake_gpio: GPIO number for incoming wake line (-1 if none)67* @flags: flags to keep track of states68* @wk_refcount: Reference count for output wake line69* @work: worker for starting TX70* @sys_mpu_enable: Context for the interrupt enable register for irq 071* @sst: Context for the synchronous serial transmitter72* @ssr: Context for the synchronous serial receiver73*/74struct omap_ssi_port {75struct device *dev;76struct device *pdev;77dma_addr_t sst_dma;78dma_addr_t ssr_dma;79void __iomem *sst_base;80void __iomem *ssr_base;81spinlock_t wk_lock;82spinlock_t lock;83unsigned int channels;84struct list_head txqueue[SSI_MAX_CHANNELS];85struct list_head rxqueue[SSI_MAX_CHANNELS];86struct list_head brkqueue;87struct list_head errqueue;88struct delayed_work errqueue_work;89unsigned int irq;90int wake_irq;91struct gpio_desc *wake_gpio;92bool wktest:1; /* FIXME: HACK to be removed */93unsigned long flags;94unsigned int wk_refcount;95struct work_struct work;96/* OMAP SSI port context */97u32 sys_mpu_enable; /* We use only one irq */98struct omap_ssm_ctx sst;99struct omap_ssm_ctx ssr;100u32 loss_count;101u32 port_id;102#ifdef CONFIG_DEBUG_FS103struct dentry *dir;104#endif105};106107/**108* struct gdd_trn - GDD transaction data109* @msg: Pointer to the HSI message being served110* @sg: Pointer to the current sg entry being served111*/112struct gdd_trn {113struct hsi_msg *msg;114struct scatterlist *sg;115};116117/**118* struct omap_ssi_controller - OMAP SSI controller data119* @dev: device associated to the controller (HSI controller)120* @sys: SSI I/O base address121* @gdd: GDD I/O base address122* @fck: SSI functional clock123* @gdd_irq: IRQ line for GDD124* @gdd_tasklet: bottom half for DMA transfers125* @gdd_trn: Array of GDD transaction data for ongoing GDD transfers126* @lock: lock to serialize access to GDD127* @fck_nb: DVFS notfifier block128* @fck_rate: clock rate129* @loss_count: To follow if we need to restore context or not130* @max_speed: Maximum TX speed (Kb/s) set by the clients.131* @gdd_gcr: SSI GDD saved context132* @get_loss: Pointer to omap_pm_get_dev_context_loss_count, if any133* @port: Array of pointers of the ports of the controller134* @dir: Debugfs SSI root directory135*/136struct omap_ssi_controller {137struct device *dev;138void __iomem *sys;139void __iomem *gdd;140struct clk *fck;141unsigned int gdd_irq;142struct tasklet_struct gdd_tasklet;143struct gdd_trn gdd_trn[SSI_MAX_GDD_LCH];144spinlock_t lock;145struct notifier_block fck_nb;146unsigned long fck_rate;147u32 loss_count;148u32 max_speed;149/* OMAP SSI Controller context */150u32 gdd_gcr;151int (*get_loss)(struct device *dev);152struct omap_ssi_port **port;153#ifdef CONFIG_DEBUG_FS154struct dentry *dir;155#endif156};157158void omap_ssi_port_update_fclk(struct hsi_controller *ssi,159struct omap_ssi_port *omap_port);160161extern struct platform_driver ssi_port_pdriver;162163#endif /* __LINUX_HSI_OMAP_SSI_H__ */164165166