ARM: cpu topology: Add debugfs interface for cpu_power
[cmplus.git] / include / linux / hsi_driver_if.h
blob6e7a0daaf4df4786e2d1875eb87254d13ad0f00b
1 /*
2 * hsi_driver_if.h
4 * Header for the HSI driver low level interface.
6 * Copyright (C) 2007-2008 Nokia Corporation. All rights reserved.
7 * Copyright (C) 2009 Texas Instruments, Inc.
9 * Author: Carlos Chinea <carlos.chinea@nokia.com>
10 * Author: Sebastien JAN <s-jan@ti.com>
12 * This package is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
16 * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 #ifndef __HSI_DRIVER_IF_H__
22 #define __HSI_DRIVER_IF_H__
24 #include <linux/platform_device.h>
25 #include <linux/device.h>
26 #include <linux/clk.h>
27 #include <linux/notifier.h>
29 /* The number of ports handled by the driver (MAX:2). Reducing this value
30 * optimizes the driver memory footprint.
32 #define HSI_MAX_PORTS 2
34 /* bit-field definition for allowed controller IDs and channels */
35 #define ANY_HSI_CONTROLLER -1
37 /* HSR special divisor values set to control the auto-divisor Rx mode */
38 #define HSI_HSR_DIVISOR_AUTO 0x1000 /* Activate auto Rx */
39 #define HSI_SSR_DIVISOR_USE_TIMEOUT 0x1001 /* De-activate auto-Rx (SSI) */
41 enum {
42 HSI_EVENT_BREAK_DETECTED = 0,
43 HSI_EVENT_ERROR,
44 HSI_EVENT_PRE_SPEED_CHANGE,
45 HSI_EVENT_POST_SPEED_CHANGE,
46 HSI_EVENT_CAWAKE_UP,
47 HSI_EVENT_CAWAKE_DOWN,
48 HSI_EVENT_HSR_DATAAVAILABLE,
51 enum {
52 HSI_IOCTL_ACWAKE_DOWN = 0, /* Unset HST ACWAKE line for channel */
53 HSI_IOCTL_ACWAKE_UP, /* Set HSI wakeup line (acwake) for channel */
54 HSI_IOCTL_SEND_BREAK, /* Send a HW BREAK frame in FRAME mode */
55 HSI_IOCTL_GET_ACWAKE, /* Get HST CAWAKE line status */
56 HSI_IOCTL_FLUSH_RX, /* Force the HSR to idle state */
57 HSI_IOCTL_FLUSH_TX, /* Force the HST to idle state */
58 HSI_IOCTL_GET_CAWAKE, /* Get CAWAKE (HSR) line status */
59 HSI_IOCTL_SET_RX, /* Set HSR configuration */
60 HSI_IOCTL_GET_RX, /* Get HSR configuration */
61 HSI_IOCTL_SET_TX, /* Set HST configuration */
62 HSI_IOCTL_GET_TX, /* Get HST configuration */
63 HSI_IOCTL_SW_RESET, /* Force a HSI SW RESET */
64 HSI_IOCTL_GET_FIFO_OCCUPANCY, /* Get amount of words in RX FIFO */
65 HSI_IOCTL_SET_WAKE_RX_3WIRES_MODE, /* Enable RX wakeup 3-wires mode */
66 HSI_IOCTL_SET_WAKE_RX_4WIRES_MODE, /* Enable RX wakeup 4-wires mode */
69 /* Forward references */
70 struct hsi_device;
71 struct hsi_channel;
73 /* DPS */
74 struct hst_ctx {
75 u32 mode;
76 u32 flow;
77 u32 frame_size;
78 u32 divisor;
79 u32 arb_mode;
80 u32 channels;
83 struct hsr_ctx {
84 u32 mode;
85 u32 flow;
86 u32 frame_size;
87 u32 divisor;
88 u32 counters;
89 u32 channels;
92 struct hsi_port_ctx {
93 int port_number; /* Range [1, 2] */
94 u32 sys_mpu_enable[2];
95 struct hst_ctx hst;
96 struct hsr_ctx hsr;
97 const char *cawake_padconf_name;
98 int cawake_padconf_hsi_mode;
102 * struct hsi_ctrl_ctx - hsi controller regs context
103 * @sysconfig: keeps HSI_SYSCONFIG reg state
104 * @gdd_gcr: keeps DMA_GCR reg state
105 * @dll: keeps HSR_DLL state
106 * @pctx: array of port context
108 struct hsi_ctrl_ctx {
109 u32 sysconfig;
110 u32 gdd_gcr;
111 u32 dll;
112 struct hsi_port_ctx *pctx;
114 /* END DPS */
117 * struct hsi_device - HSI device object (Virtual)
118 * @n_ctrl: associated HSI controller platform id number
119 * @n_p: port number
120 * @n_ch: channel number
121 * @ch: channel descriptor
122 * @device: associated device
124 struct hsi_device {
125 int n_ctrl;
126 unsigned int n_p;
127 unsigned int n_ch;
128 struct hsi_channel *ch;
129 struct device device;
132 #define to_hsi_device(dev) container_of(dev, struct hsi_device, device)
135 * struct hsi_device_driver - HSI driver instance container
136 * @ctrl_mask: bit-field indicating the supported HSI device ids
137 * @ch_mask: bit-field indicating enabled channels for this port
138 * @probe: probe callback (driver registering)
139 * @remove: remove callback (driver un-registering)
140 * @suspend: suspend callback
141 * @resume: resume callback
142 * @driver: associated device_driver object
144 struct hsi_device_driver {
145 unsigned long ctrl_mask;
146 unsigned long ch_mask[HSI_MAX_PORTS];
147 int (*probe) (struct hsi_device *dev);
148 int (*remove) (struct hsi_device *dev);
149 int (*suspend) (struct hsi_device *dev, pm_message_t mesg);
150 int (*resume) (struct hsi_device *dev);
151 struct device_driver driver;
152 void *priv_data;
156 #define to_hsi_device_driver(drv) container_of(drv, \
157 struct hsi_device_driver, \
158 driver)
160 int hsi_register_driver(struct hsi_device_driver *driver);
161 void hsi_unregister_driver(struct hsi_device_driver *driver);
162 int hsi_open(struct hsi_device *dev);
163 int hsi_write(struct hsi_device *dev, u32 * addr, unsigned int size);
164 int hsi_write_cancel(struct hsi_device *dev);
165 int hsi_read(struct hsi_device *dev, u32 * addr, unsigned int size);
166 int hsi_read_cancel(struct hsi_device *dev);
167 int hsi_poll(struct hsi_device *dev);
168 int hsi_unpoll(struct hsi_device *dev);
169 int hsi_ioctl(struct hsi_device *dev, unsigned int command, void *arg);
170 void hsi_close(struct hsi_device *dev);
171 void hsi_set_read_cb(struct hsi_device *dev,
172 void (*read_cb) (struct hsi_device *dev,
173 unsigned int size));
174 void hsi_set_write_cb(struct hsi_device *dev,
175 void (*write_cb) (struct hsi_device *dev,
176 unsigned int size));
177 void hsi_set_port_event_cb(struct hsi_device *dev,
178 void (*port_event_cb) (struct hsi_device *dev,
179 unsigned int event,
180 void *arg));
181 #endif /* __HSI_DRIVER_IF_H__ */