1 /****************************************************************************
3 * Copyright (c) 2014 - 2018 Samsung Electronics Co., Ltd. All rights reserved
5 ****************************************************************************/
7 #ifndef __SCSC_MIF_ABS_H
8 #define __SCSC_MIF_ABS_H
10 #ifdef CONFIG_SCSC_QOS
11 #include <linux/pm_qos.h>
13 #include <linux/types.h>
14 #include <scsc/scsc_mifram.h>
15 #include <scsc/scsc_mx.h>
20 enum scsc_mif_abs_target
{
21 SCSC_MIF_ABS_TARGET_R4
= 0,
22 SCSC_MIF_ABS_TARGET_M4
= 1,
23 #ifdef CONFIG_SCSC_MX450_GDB_SUPPORT
24 SCSC_MIF_ABS_TARGET_M4_1
= 2
28 #ifdef CONFIG_SCSC_SMAPPER
29 #define SCSC_MIF_SMAPPER_MAX_BANKS 32
31 struct scsc_mif_smapper_info
{
36 enum scsc_mif_abs_bank_type
{
37 SCSC_MIF_ABS_NO_BANK
= 0,
38 SCSC_MIF_ABS_SMALL_BANK
= 1,
39 SCSC_MIF_ABS_LARGE_BANK
= 2
43 #ifdef CONFIG_SCSC_QOS
44 struct scsc_mifqos_request
{
45 struct pm_qos_request pm_qos_req_mif
;
46 struct pm_qos_request pm_qos_req_int
;
47 struct pm_qos_request pm_qos_req_cl0
;
48 struct pm_qos_request pm_qos_req_cl1
;
52 #define SCSC_REG_READ_WLBT_STAT 0
55 * Abstraction of the Maxwell "Memory Interface" aka MIF.
57 * There will be at least two implementations of this
58 * interface - The native AXI one and a PCIe based emulation.
60 * A reference to an interface will be passed to the
61 * scsc_mx driver when the system startsup.
65 * Destroy this interface.
67 * This should be called when the underlying device is
70 void (*destroy
)(struct scsc_mif_abs
*interface
);
71 /* Return an unique id for this host, and prefreabrly identifies specific device (example pcie0, pcie1) */
72 char *(*get_uid
)(struct scsc_mif_abs
*interface
);
74 * Controls the hardware "reset" state of the Maxwell
77 * Setting reset=TRUE places the subsystem in its low
78 * power "reset" state. This function is called
79 * by the Maxwell Manager near the end of the subsystem
80 * shutdown process, before "unmapping" the interface.
82 * Setting reset=FALSE release the subsystem reset state.
83 * The subystem will then start its cold boot sequence. This
85 * by the Subsystem Manager near the end of the subsystem
86 * startup process after installing the maxwell firmware and
87 * other resources in MIF RAM.
89 int (*reset
)(struct scsc_mif_abs
*interface
, bool reset
);
91 * This function maps the Maxwell interface hardware (MIF
92 * DRAM) into kernel memory space.
94 * Amount of memory allocated must be defined and returned
95 * on (*allocated) by the abstraction layer implemenation.
97 * This returns kernel-space pointer to the start of the
98 * shared MIF DRAM. The Maxwell Manager will load firmware
99 * to this location and configure the MIF Heap Manager to
100 * manage any unused memory at the end of the DRAM region.
102 * The scsc_mx driver should call this when the Maxwell
103 * subsystem is required by any service client.
105 * The mailbox, irq and dram functions are only usable once
106 * this call has returned. HERE: Should we rename this to
107 * "open" and return a handle to these conditional methods?
109 void *(*map
)(struct scsc_mif_abs
*interface
, size_t *allocated
);
111 * The inverse of "map". Should be called once the maxwell
112 * subsystem is no longer required and has been placed into
113 * "reset" state (see reset method).
115 void (*unmap
)(struct scsc_mif_abs
*interface
, void *mem
);
118 * The Mailbox pointer returned can be used for direct access
119 * to the hardware register for efficiency.
120 * The pointer is guaranteed to remain valid between map and unmap calls.
121 * HERE: If we are not assuming AP v R4 same-endianess then this
122 * should be explicitly leu32 or u8[4] (or something equivalent).
124 u32
*(*get_mbox_ptr
)(struct scsc_mif_abs
*interface
, u32 mbox_index
);
126 * Incoming MIF Interrupt Hardware Controls
128 /** Get the incoming interrupt source mask */
129 u32 (*irq_bit_mask_status_get
)(struct scsc_mif_abs
*interface
);
131 /** Get the incoming interrupt pending (waiting *AND* not masked) mask */
132 u32 (*irq_get
)(struct scsc_mif_abs
*interface
);
134 void (*irq_bit_clear
)(struct scsc_mif_abs
*interface
, int bit_num
);
135 void (*irq_bit_mask
)(struct scsc_mif_abs
*interface
, int bit_num
);
136 void (*irq_bit_unmask
)(struct scsc_mif_abs
*interface
, int bit_num
);
139 * Outgoing MIF Interrupt Hardware Controls
141 void (*irq_bit_set
)(struct scsc_mif_abs
*interface
, int bit_num
, enum scsc_mif_abs_target target
);
144 * Register handler for the interrupt from the
145 * MIF Interrupt Hardware.
147 * This is used by the MIF Interrupt Manager to
148 * register a handler that demultiplexes the
149 * individual interrupt sources (MIF Interrupt Bits)
150 * to source-specific handlers.
152 void (*irq_reg_handler
)(struct scsc_mif_abs
*interface
, void (*handler
)(int irq
, void *data
), void *dev
);
153 void (*irq_unreg_handler
)(struct scsc_mif_abs
*interface
);
155 /* Clear HW interrupt line */
156 void (*irq_clear
)(void);
157 void (*irq_reg_reset_request_handler
)(struct scsc_mif_abs
*interface
, void (*handler
)(int irq
, void *data
), void *dev
);
158 void (*irq_unreg_reset_request_handler
)(struct scsc_mif_abs
*interface
);
161 * Install suspend/resume handlers for the MIF abstraction driver
163 void (*suspend_reg_handler
)(struct scsc_mif_abs
*abs
,
164 int (*suspend
)(struct scsc_mif_abs
*abs
, void *data
),
165 void (*resume
)(struct scsc_mif_abs
*abs
, void *data
),
167 void (*suspend_unreg_handler
)(struct scsc_mif_abs
*abs
);
170 * Return kernel-space pointer to MIF ram.
171 * The pointer is guaranteed to remain valid between map and unmap calls.
173 void *(*get_mifram_ptr
)(struct scsc_mif_abs
*interface
, scsc_mifram_ref ref
);
174 /* Maps kernel-space pointer to MIF RAM to portable reference */
175 int (*get_mifram_ref
)(struct scsc_mif_abs
*interface
, void *ptr
, scsc_mifram_ref
*ref
);
177 /* Return physical page frame number corresponding to the physical addres to which
178 * the virtual address is mapped . Needed in mmap file operations*/
179 uintptr_t (*get_mifram_pfn
)(struct scsc_mif_abs
*interface
);
182 * Return physical address from MIF ram address.
184 void *(*get_mifram_phy_ptr
)(struct scsc_mif_abs
*interface
, scsc_mifram_ref ref
);
185 /** Return a kernel device associated 1:1 with the Maxwell instance.
186 * This is published only for the purpose of associating service drivers with a Maxwell instance
187 * for logging purposes. Clients should not make any assumptions about the device type.
188 * In some configurations this may be the associated host-interface device (AXI/PCIe),
189 * but this may change in future.
191 struct device
*(*get_mif_device
)(struct scsc_mif_abs
*interface
);
194 void (*mif_dump_registers
)(struct scsc_mif_abs
*interface
);
195 void (*mif_cleanup
)(struct scsc_mif_abs
*interface
);
196 void (*mif_restart
)(struct scsc_mif_abs
*interface
);
198 #ifdef CONFIG_SCSC_SMAPPER
200 int (*mif_smapper_get_mapping
)(struct scsc_mif_abs
*interface
, u8
*phy_map
, u16
*align
);
201 int (*mif_smapper_get_bank_info
)(struct scsc_mif_abs
*interface
, u8 bank
, struct scsc_mif_smapper_info
*bank_info
);
202 int (*mif_smapper_write_sram
)(struct scsc_mif_abs
*interface
, u8 bank
, u8 num_entries
, u8 first_entry
, dma_addr_t
*addr
);
203 void (*mif_smapper_configure
)(struct scsc_mif_abs
*interface
, u32 granularity
);
204 u32 (*mif_smapper_get_bank_base_address
)(struct scsc_mif_abs
*interface
, u8 bank
);
206 #ifdef CONFIG_SCSC_QOS
207 int (*mif_pm_qos_add_request
)(struct scsc_mif_abs
*interface
, struct scsc_mifqos_request
*qos_req
, enum scsc_qos_config config
);
208 int (*mif_pm_qos_update_request
)(struct scsc_mif_abs
*interface
, struct scsc_mifqos_request
*qos_req
, enum scsc_qos_config config
);
209 int (*mif_pm_qos_remove_request
)(struct scsc_mif_abs
*interface
, struct scsc_mifqos_request
*qos_req
);
211 int (*mif_read_register
)(struct scsc_mif_abs
*interface
, u64 id
, u32
*val
);
216 struct scsc_mif_abs_driver
{
218 void (*probe
)(struct scsc_mif_abs_driver
*abs_driver
, struct scsc_mif_abs
*abs
);
219 void (*remove
)(struct scsc_mif_abs
*abs
);
222 extern void scsc_mif_abs_register(struct scsc_mif_abs_driver
*driver
);
223 extern void scsc_mif_abs_unregister(struct scsc_mif_abs_driver
*driver
);
225 /* mmap-debug driver */
226 struct scsc_mif_mmap_driver
{
228 void (*probe
)(struct scsc_mif_mmap_driver
*mmap_driver
, struct scsc_mif_abs
*abs
);
229 void (*remove
)(struct scsc_mif_abs
*abs
);
232 extern void scsc_mif_mmap_register(struct scsc_mif_mmap_driver
*mmap_driver
);
233 extern void scsc_mif_mmap_unregister(struct scsc_mif_mmap_driver
*mmap_driver
);