1 /* Cypress Antioch HAL for OMAP KERNEL header file (cyashalomapkernel.h)
2 ## ===========================
3 ## Copyright (C) 2010 Cypress Semiconductor
5 ## This program is free software; you can redistribute it and/or
6 ## modify it under the terms of the GNU General Public License
7 ## as published by the Free Software Foundation; either version 2
8 ## of the License, or (at your option) any later version.
10 ## This program is distributed in the hope that it will be useful,
11 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ## GNU General Public License for more details.
15 ## You should have received a copy of the GNU General Public License
16 ## along with this program; if not, write to the Free Software
17 ## Foundation, Inc., 51 Franklin Street, Fifth Floor
18 ## Boston, MA 02110-1301, USA.
19 ## ===========================
23 * This file contains the defintion of the hardware abstraction
24 * layer on OMAP3430 talking to the West Bridge Astoria device
28 #ifndef _INCLUDED_CYASHALOMAP_KERNEL_H_
29 #define _INCLUDED_CYASHALOMAP_KERNEL_H_
31 #include <linux/kernel.h>
32 #include <linux/module.h>
33 #include <linux/wait.h>
34 #include <linux/string.h>
35 /* include does not seem to work
36 * moving for patch submission
37 #include <mach/gpmc.h>
39 #include <linux/../../arch/arm/plat-omap/include/plat/gpmc.h>
40 typedef struct cy_as_hal_sleep_channel_t {
41 wait_queue_head_t wq ;
42 } cy_as_hal_sleep_channel ;
44 /* moved to staging location, eventual location
46 #include <mach/westbridge/cyashaldef.h>
47 #include <linux/westbridge/cyastypes.h>
48 #include <linux/westbridge/cyas_cplus_start.h>
50 #include "../cyashaldef.h"
51 #include "../../../../../../../include/linux/westbridge/cyastypes.h"
52 #include "../../../../../../../include/linux/westbridge/cyas_cplus_start.h"
53 #include "cyasomapdev_kernel.h"
56 * Below are the data structures that must be defined by the HAL layer
60 * The HAL layer must define a TAG for identifying a specific Astoria
61 * device in the system. In this case the tag is a void * which is
62 * really an OMAP device pointer
64 typedef void *cy_as_hal_device_tag ;
67 /* This must be included after the CyAsHalDeviceTag type is defined */
69 /* moved to staging location, eventual location
71 * #include <linux/westbridge/cyashalcb.h>
73 #include "../../../../../../../include/linux/westbridge/cyashalcb.h"
75 * Below are the functions that communicate with the West Bridge
76 * device. These are system dependent and must be defined by
77 * the HAL layer for a given system.
81 * This function must be defined to write a register within the Antioch
82 * device. The addr value is the address of the register to write with
83 * respect to the base address of the Antioch device.
86 cy_as_hal_write_register(cy_as_hal_device_tag tag,
87 uint16_t addr, uint16_t data) ;
90 * This function must be defined to read a register from
91 * the west bridge device. The addr value is the address of
92 * the register to read with respect to the base address
93 * of the west bridge device.
96 cy_as_hal_read_register(cy_as_hal_device_tag tag, uint16_t addr) ;
99 * This function must be defined to transfer a block of data
100 * to the west bridge device. This function can use the burst write
101 * (DMA) capabilities of Antioch to do this, or it can just copy
102 * the data using writes.
105 cy_as_hal_dma_setup_write(cy_as_hal_device_tag tag,
106 uint8_t ep, void *buf, uint32_t size, uint16_t maxsize) ;
109 * This function must be defined to transfer a block of data
110 * from the Antioch device. This function can use the burst
111 * read (DMA) capabilities of Antioch to do this, or it can
112 * just copy the data using reads.
115 cy_as_hal_dma_setup_read(cy_as_hal_device_tag tag, uint8_t ep,
116 void *buf, uint32_t size, uint16_t maxsize) ;
119 * This function must be defined to cancel any pending DMA request.
122 cy_as_hal_dma_cancel_request(cy_as_hal_device_tag tag, uint8_t ep) ;
125 * This function must be defined to allow the Antioch API to
126 * register a callback function that is called when a DMA transfer
130 cy_as_hal_dma_register_callback(cy_as_hal_device_tag tag,
131 cy_as_hal_dma_complete_callback cb) ;
134 * This function must be defined to return the maximum size of DMA
135 * request that can be handled on the given endpoint. The return
136 * value should be the maximum size in bytes that the DMA module can
140 cy_as_hal_dma_max_request_size(cy_as_hal_device_tag tag,
141 cy_as_end_point_number_t ep) ;
144 * This function must be defined to set the state of the WAKEUP pin
145 * on the Antioch device. Generally this is done via a GPIO of some
149 cy_as_hal_set_wakeup_pin(cy_as_hal_device_tag tag, cy_bool state) ;
152 * This function is called when the Antioch PLL loses lock, because
153 * of a problem in the supply voltage or the input clock.
156 cy_as_hal_pll_lock_loss_handler(cy_as_hal_device_tag tag) ;
159 /**********************************************************************
161 * Below are the functions that must be defined to provide the basic
162 * operating system services required by the API.
164 ***********************************************************************/
167 * This function is required by the API to allocate memory. This function
168 * is expected to work exactly like malloc().
171 cy_as_hal_alloc(uint32_t cnt) ;
174 * This function is required by the API to free memory allocated with
175 * CyAsHalAlloc(). This function is expected to work exacly like free().
178 cy_as_hal_free(void *mem_p) ;
181 * This function is required by the API to allocate memory during a
182 * callback. This function must be able to provide storage at inturupt
186 cy_as_hal_c_b_alloc(uint32_t cnt) ;
189 * This function is required by the API to free memory allocated with
193 cy_as_hal_c_b_free(void *ptr) ;
196 * This function is required to set a block of memory to a specific
197 * value. This function is expected to work exactly like memset()
200 cy_as_hal_mem_set(void *ptr, uint8_t value, uint32_t cnt) ;
203 * This function is expected to create a sleep channel. The data
204 * structure that represents the sleep channel is given by the
205 * pointer in the argument.
208 cy_as_hal_create_sleep_channel(cy_as_hal_sleep_channel *channel) ;
211 * This function is expected to destroy a sleep channel. The data
212 * structure that represents the sleep channel is given by
213 * the pointer in the argument.
218 cy_as_hal_destroy_sleep_channel(cy_as_hal_sleep_channel *channel) ;
221 cy_as_hal_sleep_on(cy_as_hal_sleep_channel *channel, uint32_t ms) ;
224 cy_as_hal_wake(cy_as_hal_sleep_channel *channel) ;
227 cy_as_hal_disable_interrupts(void) ;
230 cy_as_hal_enable_interrupts(uint32_t);
233 cy_as_hal_sleep150(void);
236 cy_as_hal_sleep(uint32_t ms);
239 cy_as_hal_is_polling(void);
241 void cy_as_hal_init_dev_registers(cy_as_hal_device_tag tag,
242 cy_bool is_standby_wakeup);
245 * required only in spi mode
247 cy_bool cy_as_hal_sync_device_clocks(cy_as_hal_device_tag tag);
249 void cy_as_hal_read_regs_before_standby(cy_as_hal_device_tag tag);
253 #define cy_as_hal_assert(cond) if (!(cond))\
254 printk(KERN_WARNING"assertion failed at %s:%d\n", __FILE__, __LINE__);
256 #define cy_as_hal_assert(cond)
259 #define cy_as_hal_print_message printk
261 /* removable debug printks */
262 #ifndef WESTBRIDGE_NDEBUG
263 #define DBG_PRINT_ENABLED
266 /*#define MBOX_ACCESS_DBG_PRINT_ENABLED*/
269 #ifdef DBG_PRINT_ENABLED
270 /* Debug printing enabled */
272 #define DBGPRN(...) printk(__VA_ARGS__)
273 #define DBGPRN_FUNC_NAME printk("<1> %x:_func: %s\n", \
274 current->pid, __func__)
277 /** NO DEBUG PRINTING **/
279 #define DBGPRN_FUNC_NAME
284 CyAsMiscSetLogLevel(uint8_t level)
286 debug_level = level ;
289 #ifdef CY_AS_LOG_SUPPORT
292 cy_as_log_debug_message(int level, const char *str)
294 if (level <= debug_level)
295 cy_as_hal_print_message("log %d: %s\n", level, str) ;
301 * print buffer helper
303 void cyashal_prn_buf(void *buf, uint16_t offset, int len);
306 * These are the functions that are not part of the HAL layer,
307 * but are required to be called for this HAL.
309 int start_o_m_a_p_kernel(const char *pgm,
310 cy_as_hal_device_tag *tag, cy_bool debug) ;
311 int stop_o_m_a_p_kernel(const char *pgm, cy_as_hal_device_tag tag) ;
312 int omap_start_intr(cy_as_hal_device_tag tag) ;
313 void cy_as_hal_set_ep_dma_mode(uint8_t ep, bool sg_xfer_enabled);
315 /* moved to staging location
316 #include <linux/westbridge/cyas_cplus_end.h>
318 #include "../../../../../../../include/linux/westbridge/cyas_cplus_start.h"