blob: d480a514c983792082e4715c7a9990812db372ba [file] [log] [blame]
Thomas Gleixnerb886d83c2019-06-01 10:08:55 +02001// SPDX-License-Identifier: GPL-2.0-only
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +02002/**
3 * ipoctal.c
4 *
5 * driver for the GE IP-OCTAL boards
Samuel Iglesias Gonsalvez76859722012-11-16 16:19:58 +01006 *
7 * Copyright (C) 2009-2012 CERN (www.cern.ch)
8 * Author: Nicolas Serafini, EIC2 SA
9 * Author: Samuel Iglesias Gonsalvez <siglesias@igalia.com>
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +020010 */
11
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +020012#include <linux/device.h>
13#include <linux/module.h>
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +020014#include <linux/interrupt.h>
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +020015#include <linux/sched.h>
16#include <linux/tty.h>
17#include <linux/serial.h>
18#include <linux/tty_flip.h>
19#include <linux/slab.h>
Jens Taprogge64802dc2012-09-04 17:01:08 +020020#include <linux/io.h>
Samuel Iglesias Gonsalvez7dbce022012-11-16 19:33:45 +010021#include <linux/ipack.h>
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +020022#include "ipoctal.h"
23#include "scc2698.h"
24
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +020025#define IP_OCTAL_ID_SPACE_VECTOR 0x41
26#define IP_OCTAL_NB_BLOCKS 4
27
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +020028static const struct tty_operations ipoctal_fops;
29
Jens Taprogge70a32812012-09-12 14:55:26 +020030struct ipoctal_channel {
31 struct ipoctal_stats stats;
32 unsigned int nb_bytes;
Jens Taprogge70a32812012-09-12 14:55:26 +020033 wait_queue_head_t queue;
34 spinlock_t lock;
35 unsigned int pointer_read;
36 unsigned int pointer_write;
Jens Taprogge70a32812012-09-12 14:55:26 +020037 struct tty_port tty_port;
38 union scc2698_channel __iomem *regs;
39 union scc2698_block __iomem *block_regs;
Jens Taproggeef79de02012-09-12 14:55:28 +020040 unsigned int board_id;
Jens Taprogge4e4732a2012-09-12 14:55:29 +020041 u8 isr_rx_rdy_mask;
42 u8 isr_tx_rdy_mask;
Samuel Iglesias Gonsalvezb0d17fb2012-12-10 11:50:07 +010043 unsigned int rx_enable;
Jens Taprogge70a32812012-09-12 14:55:26 +020044};
45
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +020046struct ipoctal {
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +020047 struct ipack_device *dev;
48 unsigned int board_id;
Jens Taprogge70a32812012-09-12 14:55:26 +020049 struct ipoctal_channel channel[NR_CHANNELS];
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +020050 struct tty_driver *tty_drv;
Jens Taproggefe4a3ed2012-09-27 12:37:36 +020051 u8 __iomem *mem8_space;
Jens Taprogge402228d2012-09-27 12:37:34 +020052 u8 __iomem *int_space;
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +020053};
54
Federico Vaga82a82342014-09-02 17:31:41 +020055static inline struct ipoctal *chan_to_ipoctal(struct ipoctal_channel *chan,
56 unsigned int index)
57{
58 return container_of(chan, struct ipoctal, channel[index]);
59}
60
Federico Vaga78f22bc2014-09-02 17:31:39 +020061static void ipoctal_reset_channel(struct ipoctal_channel *channel)
62{
63 iowrite8(CR_DISABLE_RX | CR_DISABLE_TX, &channel->regs->w.cr);
64 channel->rx_enable = 0;
65 iowrite8(CR_CMD_RESET_RX, &channel->regs->w.cr);
66 iowrite8(CR_CMD_RESET_TX, &channel->regs->w.cr);
67 iowrite8(CR_CMD_RESET_ERR_STATUS, &channel->regs->w.cr);
68 iowrite8(CR_CMD_RESET_MR, &channel->regs->w.cr);
69}
70
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +020071static int ipoctal_port_activate(struct tty_port *port, struct tty_struct *tty)
72{
Jens Taprogge70a32812012-09-12 14:55:26 +020073 struct ipoctal_channel *channel;
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +020074
Jens Taprogge9c1d7842012-09-12 14:55:42 +020075 channel = dev_get_drvdata(tty->dev);
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +020076
Samuel Iglesias Gonsalveza3882b72012-12-10 11:50:03 +010077 /*
78 * Enable RX. TX will be enabled when
79 * there is something to send
80 */
Jens Taprogge459e6d72012-09-12 14:55:27 +020081 iowrite8(CR_ENABLE_RX, &channel->regs->w.cr);
Samuel Iglesias Gonsalvezb0d17fb2012-12-10 11:50:07 +010082 channel->rx_enable = 1;
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +020083 return 0;
84}
85
86static int ipoctal_open(struct tty_struct *tty, struct file *file)
87{
Federico Vaga82a82342014-09-02 17:31:41 +020088 struct ipoctal_channel *channel = dev_get_drvdata(tty->dev);
89 struct ipoctal *ipoctal = chan_to_ipoctal(channel, tty->index);
90 int err;
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +020091
Jens Taproggeef79de02012-09-12 14:55:28 +020092 tty->driver_data = channel;
Samuel Iglesias Gonsálvez1337b072012-07-13 13:33:13 +020093
Federico Vaga82a82342014-09-02 17:31:41 +020094 if (!ipack_get_carrier(ipoctal->dev))
95 return -EBUSY;
96
97 err = tty_port_open(&channel->tty_port, tty, file);
98 if (err)
99 ipack_put_carrier(ipoctal->dev);
100
101 return err;
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200102}
103
104static void ipoctal_reset_stats(struct ipoctal_stats *stats)
105{
106 stats->tx = 0;
107 stats->rx = 0;
108 stats->rcv_break = 0;
109 stats->framing_err = 0;
110 stats->overrun_err = 0;
111 stats->parity_err = 0;
112}
113
Jens Taproggeef79de02012-09-12 14:55:28 +0200114static void ipoctal_free_channel(struct ipoctal_channel *channel)
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200115{
Jens Taprogge70a32812012-09-12 14:55:26 +0200116 ipoctal_reset_stats(&channel->stats);
117 channel->pointer_read = 0;
118 channel->pointer_write = 0;
119 channel->nb_bytes = 0;
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200120}
121
122static void ipoctal_close(struct tty_struct *tty, struct file *filp)
123{
Jens Taproggeef79de02012-09-12 14:55:28 +0200124 struct ipoctal_channel *channel = tty->driver_data;
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200125
Jens Taprogge70a32812012-09-12 14:55:26 +0200126 tty_port_close(&channel->tty_port, tty, filp);
Samuel Iglesias Gonsalvez7e5730d2012-12-10 11:49:59 +0100127 ipoctal_free_channel(channel);
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200128}
129
130static int ipoctal_get_icount(struct tty_struct *tty,
131 struct serial_icounter_struct *icount)
132{
Jens Taproggeef79de02012-09-12 14:55:28 +0200133 struct ipoctal_channel *channel = tty->driver_data;
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200134
135 icount->cts = 0;
136 icount->dsr = 0;
137 icount->rng = 0;
138 icount->dcd = 0;
Jens Taprogge70a32812012-09-12 14:55:26 +0200139 icount->rx = channel->stats.rx;
140 icount->tx = channel->stats.tx;
141 icount->frame = channel->stats.framing_err;
142 icount->parity = channel->stats.parity_err;
143 icount->brk = channel->stats.rcv_break;
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200144 return 0;
145}
146
Jiri Slaby2e124b42013-01-03 15:53:06 +0100147static void ipoctal_irq_rx(struct ipoctal_channel *channel, u8 sr)
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200148{
Jiri Slaby92a19f92013-01-03 15:53:03 +0100149 struct tty_port *port = &channel->tty_port;
Samuel Iglesias Gonsalvezab0a71f2012-09-12 14:55:43 +0200150 unsigned char value;
Samuel Iglesias Gonsalvezb5071f22012-12-10 11:50:01 +0100151 unsigned char flag;
Samuel Iglesias Gonsalvezab0a71f2012-09-12 14:55:43 +0200152 u8 isr;
Jens Taprogge87cfb952012-09-12 14:55:30 +0200153
Samuel Iglesias Gonsalvezab0a71f2012-09-12 14:55:43 +0200154 do {
155 value = ioread8(&channel->regs->r.rhr);
Samuel Iglesias Gonsalvezb5071f22012-12-10 11:50:01 +0100156 flag = TTY_NORMAL;
Samuel Iglesias Gonsalvezab0a71f2012-09-12 14:55:43 +0200157 /* Error: count statistics */
158 if (sr & SR_ERROR) {
159 iowrite8(CR_CMD_RESET_ERR_STATUS, &channel->regs->w.cr);
Jens Taprogge87cfb952012-09-12 14:55:30 +0200160
Samuel Iglesias Gonsalvezab0a71f2012-09-12 14:55:43 +0200161 if (sr & SR_OVERRUN_ERROR) {
162 channel->stats.overrun_err++;
163 /* Overrun doesn't affect the current character*/
Jiri Slaby92a19f92013-01-03 15:53:03 +0100164 tty_insert_flip_char(port, 0, TTY_OVERRUN);
Samuel Iglesias Gonsalvezab0a71f2012-09-12 14:55:43 +0200165 }
166 if (sr & SR_PARITY_ERROR) {
167 channel->stats.parity_err++;
168 flag = TTY_PARITY;
169 }
170 if (sr & SR_FRAMING_ERROR) {
171 channel->stats.framing_err++;
172 flag = TTY_FRAME;
173 }
174 if (sr & SR_RECEIVED_BREAK) {
175 channel->stats.rcv_break++;
176 flag = TTY_BREAK;
177 }
Jens Taprogge87cfb952012-09-12 14:55:30 +0200178 }
Jiri Slaby92a19f92013-01-03 15:53:03 +0100179 tty_insert_flip_char(port, value, flag);
Jens Taprogge87cfb952012-09-12 14:55:30 +0200180
Samuel Iglesias Gonsalvezab0a71f2012-09-12 14:55:43 +0200181 /* Check if there are more characters in RX FIFO
182 * If there are more, the isr register for this channel
183 * has enabled the RxRDY|FFULL bit.
184 */
185 isr = ioread8(&channel->block_regs->r.isr);
186 sr = ioread8(&channel->regs->r.sr);
187 } while (isr & channel->isr_rx_rdy_mask);
188
Jiri Slaby2e124b42013-01-03 15:53:06 +0100189 tty_flip_buffer_push(port);
Jens Taprogge87cfb952012-09-12 14:55:30 +0200190}
191
192static void ipoctal_irq_tx(struct ipoctal_channel *channel)
193{
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200194 unsigned char value;
Jens Taprogge87cfb952012-09-12 14:55:30 +0200195 unsigned int *pointer_write = &channel->pointer_write;
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200196
Alberto Garcia69a6b9b2012-12-10 11:49:58 +0100197 if (channel->nb_bytes == 0)
Jens Taprogge87cfb952012-09-12 14:55:30 +0200198 return;
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200199
Federico Vaga968d04e2014-06-26 09:46:24 +0200200 spin_lock(&channel->lock);
Jens Taprogge87cfb952012-09-12 14:55:30 +0200201 value = channel->tty_port.xmit_buf[*pointer_write];
202 iowrite8(value, &channel->regs->w.thr);
203 channel->stats.tx++;
Jens Taprogge87cfb952012-09-12 14:55:30 +0200204 (*pointer_write)++;
205 *pointer_write = *pointer_write % PAGE_SIZE;
206 channel->nb_bytes--;
Federico Vaga968d04e2014-06-26 09:46:24 +0200207 spin_unlock(&channel->lock);
Jens Taprogge87cfb952012-09-12 14:55:30 +0200208}
209
210static void ipoctal_irq_channel(struct ipoctal_channel *channel)
211{
212 u8 isr, sr;
Jens Taprogge87cfb952012-09-12 14:55:30 +0200213
Jens Taprogge87cfb952012-09-12 14:55:30 +0200214 /* The HW is organized in pair of channels. See which register we need
215 * to read from */
216 isr = ioread8(&channel->block_regs->r.isr);
217 sr = ioread8(&channel->regs->r.sr);
218
Federico Vaga95e838c2014-09-01 13:49:56 +0200219 if (isr & (IMR_DELTA_BREAK_A | IMR_DELTA_BREAK_B))
220 iowrite8(CR_CMD_RESET_BREAK_CHANGE, &channel->regs->w.cr);
221
Samuel Iglesias Gonsalvez9d01b6f2012-12-10 11:50:02 +0100222 if ((sr & SR_TX_EMPTY) && (channel->nb_bytes == 0)) {
Jens Taprogge87cfb952012-09-12 14:55:30 +0200223 iowrite8(CR_DISABLE_TX, &channel->regs->w.cr);
Samuel Iglesias Gonsalvez9d01b6f2012-12-10 11:50:02 +0100224 /* In case of RS-485, change from TX to RX when finishing TX.
225 * Half-duplex. */
226 if (channel->board_id == IPACK1_DEVICE_ID_SBS_OCTAL_485) {
227 iowrite8(CR_CMD_NEGATE_RTSN, &channel->regs->w.cr);
228 iowrite8(CR_ENABLE_RX, &channel->regs->w.cr);
Samuel Iglesias Gonsalvez2910fe22013-01-18 08:57:21 +0100229 channel->rx_enable = 1;
Samuel Iglesias Gonsalvez9d01b6f2012-12-10 11:50:02 +0100230 }
Jens Taprogge87cfb952012-09-12 14:55:30 +0200231 }
232
233 /* RX data */
234 if ((isr & channel->isr_rx_rdy_mask) && (sr & SR_RX_READY))
Jiri Slaby2e124b42013-01-03 15:53:06 +0100235 ipoctal_irq_rx(channel, sr);
Jens Taprogge87cfb952012-09-12 14:55:30 +0200236
237 /* TX of each character */
238 if ((isr & channel->isr_tx_rdy_mask) && (sr & SR_TX_READY))
239 ipoctal_irq_tx(channel);
Jens Taprogge87cfb952012-09-12 14:55:30 +0200240}
241
Jens Taproggefaa75c42012-09-12 14:55:38 +0200242static irqreturn_t ipoctal_irq_handler(void *arg)
Jens Taprogge87cfb952012-09-12 14:55:30 +0200243{
244 unsigned int i;
245 struct ipoctal *ipoctal = (struct ipoctal *) arg;
246
Jens Taproggeea991142012-09-13 12:32:20 +0200247 /* Clear the IPack device interrupt */
Jens Taprogge402228d2012-09-27 12:37:34 +0200248 readw(ipoctal->int_space + ACK_INT_REQ0);
249 readw(ipoctal->int_space + ACK_INT_REQ1);
Jens Taproggeea991142012-09-13 12:32:20 +0200250
Samuel Iglesias Gonsalvez21d27ed2012-12-10 11:50:04 +0100251 /* Check all channels */
252 for (i = 0; i < NR_CHANNELS; i++)
253 ipoctal_irq_channel(&ipoctal->channel[i]);
254
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200255 return IRQ_HANDLED;
256}
257
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200258static const struct tty_port_operations ipoctal_tty_port_ops = {
259 .dtr_rts = NULL,
260 .activate = ipoctal_port_activate,
261};
262
263static int ipoctal_inst_slot(struct ipoctal *ipoctal, unsigned int bus_nr,
Jens Taproggec6e2dfa2012-09-13 12:32:21 +0200264 unsigned int slot)
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200265{
Jens Taprogge402228d2012-09-27 12:37:34 +0200266 int res;
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200267 int i;
268 struct tty_driver *tty;
269 char name[20];
Jens Taprogge70a32812012-09-12 14:55:26 +0200270 struct ipoctal_channel *channel;
Jens Taprogge402228d2012-09-27 12:37:34 +0200271 struct ipack_region *region;
272 void __iomem *addr;
Jens Taprogge70a32812012-09-12 14:55:26 +0200273 union scc2698_channel __iomem *chan_regs;
274 union scc2698_block __iomem *block_regs;
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200275
Jens Taprogge2ec678d2012-09-27 12:37:33 +0200276 ipoctal->board_id = ipoctal->dev->id_device;
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200277
Jens Taprogge402228d2012-09-27 12:37:34 +0200278 region = &ipoctal->dev->region[IPACK_IO_SPACE];
Christoph Hellwig4bdc0d62020-01-06 09:43:50 +0100279 addr = devm_ioremap(&ipoctal->dev->dev,
Jens Taprogge402228d2012-09-27 12:37:34 +0200280 region->start, region->size);
281 if (!addr) {
Samuel Iglesias Gonsalvez42b38202012-05-25 13:08:13 +0200282 dev_err(&ipoctal->dev->dev,
283 "Unable to map slot [%d:%d] IO space!\n",
284 bus_nr, slot);
Jens Taprogge402228d2012-09-27 12:37:34 +0200285 return -EADDRNOTAVAIL;
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200286 }
Jens Taprogge402228d2012-09-27 12:37:34 +0200287 /* Save the virtual address to access the registers easily */
288 chan_regs =
289 (union scc2698_channel __iomem *) addr;
290 block_regs =
291 (union scc2698_block __iomem *) addr;
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200292
Jens Taprogge402228d2012-09-27 12:37:34 +0200293 region = &ipoctal->dev->region[IPACK_INT_SPACE];
294 ipoctal->int_space =
Christoph Hellwig4bdc0d62020-01-06 09:43:50 +0100295 devm_ioremap(&ipoctal->dev->dev,
Jens Taprogge402228d2012-09-27 12:37:34 +0200296 region->start, region->size);
297 if (!ipoctal->int_space) {
Jens Taproggeea991142012-09-13 12:32:20 +0200298 dev_err(&ipoctal->dev->dev,
299 "Unable to map slot [%d:%d] INT space!\n",
300 bus_nr, slot);
Jens Taprogge402228d2012-09-27 12:37:34 +0200301 return -EADDRNOTAVAIL;
Jens Taproggeea991142012-09-13 12:32:20 +0200302 }
303
Jens Taproggefe4a3ed2012-09-27 12:37:36 +0200304 region = &ipoctal->dev->region[IPACK_MEM8_SPACE];
305 ipoctal->mem8_space =
Christoph Hellwig4bdc0d62020-01-06 09:43:50 +0100306 devm_ioremap(&ipoctal->dev->dev,
Jens Taprogge402228d2012-09-27 12:37:34 +0200307 region->start, 0x8000);
Julia Lawallfc8d7132013-01-21 14:02:53 +0100308 if (!ipoctal->mem8_space) {
Samuel Iglesias Gonsalvez42b38202012-05-25 13:08:13 +0200309 dev_err(&ipoctal->dev->dev,
Jens Taproggefe4a3ed2012-09-27 12:37:36 +0200310 "Unable to map slot [%d:%d] MEM8 space!\n",
Samuel Iglesias Gonsalvez42b38202012-05-25 13:08:13 +0200311 bus_nr, slot);
Jens Taprogge402228d2012-09-27 12:37:34 +0200312 return -EADDRNOTAVAIL;
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200313 }
314
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200315
316 /* Disable RX and TX before touching anything */
317 for (i = 0; i < NR_CHANNELS ; i++) {
Jens Taprogge70a32812012-09-12 14:55:26 +0200318 struct ipoctal_channel *channel = &ipoctal->channel[i];
319 channel->regs = chan_regs + i;
320 channel->block_regs = block_regs + (i >> 1);
Jens Taproggeef79de02012-09-12 14:55:28 +0200321 channel->board_id = ipoctal->board_id;
Jens Taprogge4e4732a2012-09-12 14:55:29 +0200322 if (i & 1) {
323 channel->isr_tx_rdy_mask = ISR_TxRDY_B;
324 channel->isr_rx_rdy_mask = ISR_RxRDY_FFULL_B;
325 } else {
326 channel->isr_tx_rdy_mask = ISR_TxRDY_A;
327 channel->isr_rx_rdy_mask = ISR_RxRDY_FFULL_A;
328 }
Jens Taprogge70a32812012-09-12 14:55:26 +0200329
Federico Vaga78f22bc2014-09-02 17:31:39 +0200330 ipoctal_reset_channel(channel);
Jens Taprogge459e6d72012-09-12 14:55:27 +0200331 iowrite8(MR1_CHRL_8_BITS | MR1_ERROR_CHAR | MR1_RxINT_RxRDY,
332 &channel->regs->w.mr); /* mr1 */
333 iowrite8(0, &channel->regs->w.mr); /* mr2 */
334 iowrite8(TX_CLK_9600 | RX_CLK_9600, &channel->regs->w.csr);
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200335 }
336
337 for (i = 0; i < IP_OCTAL_NB_BLOCKS; i++) {
Jens Taprogge459e6d72012-09-12 14:55:27 +0200338 iowrite8(ACR_BRG_SET2, &block_regs[i].w.acr);
339 iowrite8(OPCR_MPP_OUTPUT | OPCR_MPOa_RTSN | OPCR_MPOb_RTSN,
340 &block_regs[i].w.opcr);
341 iowrite8(IMR_TxRDY_A | IMR_RxRDY_FFULL_A | IMR_DELTA_BREAK_A |
342 IMR_TxRDY_B | IMR_RxRDY_FFULL_B | IMR_DELTA_BREAK_B,
343 &block_regs[i].w.imr);
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200344 }
345
Jens Taproggec6e2dfa2012-09-13 12:32:21 +0200346 /* Dummy write */
Jens Taproggefe4a3ed2012-09-27 12:37:36 +0200347 iowrite8(1, ipoctal->mem8_space + 1);
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200348
349 /* Register the TTY device */
350
351 /* Each IP-OCTAL channel is a TTY port */
352 tty = alloc_tty_driver(NR_CHANNELS);
353
Jens Taprogge402228d2012-09-27 12:37:34 +0200354 if (!tty)
355 return -ENOMEM;
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200356
357 /* Fill struct tty_driver with ipoctal data */
358 tty->owner = THIS_MODULE;
Jens Taprogge3f3a5922012-09-12 14:55:41 +0200359 tty->driver_name = KBUILD_MODNAME;
360 sprintf(name, KBUILD_MODNAME ".%d.%d.", bus_nr, slot);
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200361 tty->name = name;
362 tty->major = 0;
363
364 tty->minor_start = 0;
365 tty->type = TTY_DRIVER_TYPE_SERIAL;
366 tty->subtype = SERIAL_TYPE_NORMAL;
367 tty->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
368 tty->init_termios = tty_std_termios;
369 tty->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
370 tty->init_termios.c_ispeed = 9600;
371 tty->init_termios.c_ospeed = 9600;
372
373 tty_set_operations(tty, &ipoctal_fops);
374 res = tty_register_driver(tty);
375 if (res) {
Samuel Iglesias Gonsalvez42b38202012-05-25 13:08:13 +0200376 dev_err(&ipoctal->dev->dev, "Can't register tty driver.\n");
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200377 put_tty_driver(tty);
Jens Taprogge402228d2012-09-27 12:37:34 +0200378 return res;
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200379 }
380
381 /* Save struct tty_driver for use it when uninstalling the device */
382 ipoctal->tty_drv = tty;
383
384 for (i = 0; i < NR_CHANNELS; i++) {
Jens Taprogge2afb41d2012-09-12 14:55:40 +0200385 struct device *tty_dev;
386
Jens Taprogge70a32812012-09-12 14:55:26 +0200387 channel = &ipoctal->channel[i];
388 tty_port_init(&channel->tty_port);
389 tty_port_alloc_xmit_buf(&channel->tty_port);
390 channel->tty_port.ops = &ipoctal_tty_port_ops;
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200391
Jens Taprogge70a32812012-09-12 14:55:26 +0200392 ipoctal_reset_stats(&channel->stats);
393 channel->nb_bytes = 0;
Jens Taprogge70a32812012-09-12 14:55:26 +0200394 spin_lock_init(&channel->lock);
395 channel->pointer_read = 0;
396 channel->pointer_write = 0;
Linus Torvalds3498d132012-10-01 12:26:52 -0700397 tty_dev = tty_port_register_device(&channel->tty_port, tty, i, NULL);
Jens Taprogge2afb41d2012-09-12 14:55:40 +0200398 if (IS_ERR(tty_dev)) {
399 dev_err(&ipoctal->dev->dev, "Failed to register tty device.\n");
Jiri Slaby191c5f12012-11-15 09:49:56 +0100400 tty_port_destroy(&channel->tty_port);
Jens Taprogge2afb41d2012-09-12 14:55:40 +0200401 continue;
402 }
Jens Taprogge9c1d7842012-09-12 14:55:42 +0200403 dev_set_drvdata(tty_dev, channel);
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200404 }
405
Federico Vaga4847cc02014-07-03 10:53:58 +0200406 /*
407 * IP-OCTAL has different addresses to copy its IRQ vector.
408 * Depending of the carrier these addresses are accesible or not.
409 * More info in the datasheet.
410 */
411 ipoctal->dev->bus->ops->request_irq(ipoctal->dev,
412 ipoctal_irq_handler, ipoctal);
413
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200414 return 0;
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200415}
416
Jens Taprogge70a32812012-09-12 14:55:26 +0200417static inline int ipoctal_copy_write_buffer(struct ipoctal_channel *channel,
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200418 const unsigned char *buf,
419 int count)
420{
421 unsigned long flags;
422 int i;
Jens Taprogge70a32812012-09-12 14:55:26 +0200423 unsigned int *pointer_read = &channel->pointer_read;
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200424
425 /* Copy the bytes from the user buffer to the internal one */
426 for (i = 0; i < count; i++) {
Jens Taprogge70a32812012-09-12 14:55:26 +0200427 if (i <= (PAGE_SIZE - channel->nb_bytes)) {
428 spin_lock_irqsave(&channel->lock, flags);
429 channel->tty_port.xmit_buf[*pointer_read] = buf[i];
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200430 *pointer_read = (*pointer_read + 1) % PAGE_SIZE;
Jens Taprogge70a32812012-09-12 14:55:26 +0200431 channel->nb_bytes++;
432 spin_unlock_irqrestore(&channel->lock, flags);
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200433 } else {
434 break;
435 }
436 }
437 return i;
438}
439
Jens Taprogge699a89f2012-09-12 14:55:31 +0200440static int ipoctal_write_tty(struct tty_struct *tty,
441 const unsigned char *buf, int count)
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200442{
Jens Taprogge699a89f2012-09-12 14:55:31 +0200443 struct ipoctal_channel *channel = tty->driver_data;
Samuel Iglesias Gonsalvezd0460062012-09-13 12:32:23 +0200444 unsigned int char_copied;
Jens Taprogge699a89f2012-09-12 14:55:31 +0200445
Samuel Iglesias Gonsalvezd0460062012-09-13 12:32:23 +0200446 char_copied = ipoctal_copy_write_buffer(channel, buf, count);
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200447
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200448 /* As the IP-OCTAL 485 only supports half duplex, do it manually */
Jens Taproggeef79de02012-09-12 14:55:28 +0200449 if (channel->board_id == IPACK1_DEVICE_ID_SBS_OCTAL_485) {
Jens Taprogge459e6d72012-09-12 14:55:27 +0200450 iowrite8(CR_DISABLE_RX, &channel->regs->w.cr);
Samuel Iglesias Gonsalvezb0d17fb2012-12-10 11:50:07 +0100451 channel->rx_enable = 0;
Jens Taprogge459e6d72012-09-12 14:55:27 +0200452 iowrite8(CR_CMD_ASSERT_RTSN, &channel->regs->w.cr);
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200453 }
454
455 /*
456 * Send a packet and then disable TX to avoid failure after several send
457 * operations
458 */
Jens Taprogge459e6d72012-09-12 14:55:27 +0200459 iowrite8(CR_ENABLE_TX, &channel->regs->w.cr);
Samuel Iglesias Gonsalvezd0460062012-09-13 12:32:23 +0200460 return char_copied;
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200461}
462
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200463static int ipoctal_write_room(struct tty_struct *tty)
464{
Jens Taproggeef79de02012-09-12 14:55:28 +0200465 struct ipoctal_channel *channel = tty->driver_data;
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200466
Jens Taprogge70a32812012-09-12 14:55:26 +0200467 return PAGE_SIZE - channel->nb_bytes;
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200468}
469
470static int ipoctal_chars_in_buffer(struct tty_struct *tty)
471{
Jens Taproggeef79de02012-09-12 14:55:28 +0200472 struct ipoctal_channel *channel = tty->driver_data;
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200473
Jens Taprogge70a32812012-09-12 14:55:26 +0200474 return channel->nb_bytes;
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200475}
476
477static void ipoctal_set_termios(struct tty_struct *tty,
478 struct ktermios *old_termios)
479{
480 unsigned int cflag;
481 unsigned char mr1 = 0;
482 unsigned char mr2 = 0;
483 unsigned char csr = 0;
Jens Taproggeef79de02012-09-12 14:55:28 +0200484 struct ipoctal_channel *channel = tty->driver_data;
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200485 speed_t baud;
486
Alan Cox857196e2012-07-26 19:00:51 +0100487 cflag = tty->termios.c_cflag;
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200488
489 /* Disable and reset everything before change the setup */
Federico Vaga78f22bc2014-09-02 17:31:39 +0200490 ipoctal_reset_channel(channel);
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200491
492 /* Set Bits per chars */
493 switch (cflag & CSIZE) {
494 case CS6:
495 mr1 |= MR1_CHRL_6_BITS;
496 break;
497 case CS7:
498 mr1 |= MR1_CHRL_7_BITS;
499 break;
500 case CS8:
501 default:
502 mr1 |= MR1_CHRL_8_BITS;
503 /* By default, select CS8 */
Alan Cox857196e2012-07-26 19:00:51 +0100504 tty->termios.c_cflag = (cflag & ~CSIZE) | CS8;
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200505 break;
506 }
507
508 /* Set Parity */
509 if (cflag & PARENB)
510 if (cflag & PARODD)
511 mr1 |= MR1_PARITY_ON | MR1_PARITY_ODD;
512 else
513 mr1 |= MR1_PARITY_ON | MR1_PARITY_EVEN;
514 else
515 mr1 |= MR1_PARITY_OFF;
516
517 /* Mark or space parity is not supported */
Alan Cox857196e2012-07-26 19:00:51 +0100518 tty->termios.c_cflag &= ~CMSPAR;
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200519
520 /* Set stop bits */
521 if (cflag & CSTOPB)
522 mr2 |= MR2_STOP_BITS_LENGTH_2;
523 else
524 mr2 |= MR2_STOP_BITS_LENGTH_1;
525
526 /* Set the flow control */
Jens Taproggeef79de02012-09-12 14:55:28 +0200527 switch (channel->board_id) {
Jens Taprogge7db5e3c2012-09-04 17:01:16 +0200528 case IPACK1_DEVICE_ID_SBS_OCTAL_232:
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200529 if (cflag & CRTSCTS) {
530 mr1 |= MR1_RxRTS_CONTROL_ON;
531 mr2 |= MR2_TxRTS_CONTROL_OFF | MR2_CTS_ENABLE_TX_ON;
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200532 } else {
533 mr1 |= MR1_RxRTS_CONTROL_OFF;
534 mr2 |= MR2_TxRTS_CONTROL_OFF | MR2_CTS_ENABLE_TX_OFF;
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200535 }
536 break;
Jens Taprogge7db5e3c2012-09-04 17:01:16 +0200537 case IPACK1_DEVICE_ID_SBS_OCTAL_422:
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200538 mr1 |= MR1_RxRTS_CONTROL_OFF;
539 mr2 |= MR2_TxRTS_CONTROL_OFF | MR2_CTS_ENABLE_TX_OFF;
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200540 break;
Jens Taprogge7db5e3c2012-09-04 17:01:16 +0200541 case IPACK1_DEVICE_ID_SBS_OCTAL_485:
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200542 mr1 |= MR1_RxRTS_CONTROL_OFF;
543 mr2 |= MR2_TxRTS_CONTROL_ON | MR2_CTS_ENABLE_TX_OFF;
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200544 break;
545 default:
546 return;
547 break;
548 }
549
550 baud = tty_get_baud_rate(tty);
Alan Cox857196e2012-07-26 19:00:51 +0100551 tty_termios_encode_baud_rate(&tty->termios, baud, baud);
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200552
553 /* Set baud rate */
Alan Cox857196e2012-07-26 19:00:51 +0100554 switch (baud) {
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200555 case 75:
556 csr |= TX_CLK_75 | RX_CLK_75;
557 break;
558 case 110:
559 csr |= TX_CLK_110 | RX_CLK_110;
560 break;
561 case 150:
562 csr |= TX_CLK_150 | RX_CLK_150;
563 break;
564 case 300:
565 csr |= TX_CLK_300 | RX_CLK_300;
566 break;
567 case 600:
568 csr |= TX_CLK_600 | RX_CLK_600;
569 break;
570 case 1200:
571 csr |= TX_CLK_1200 | RX_CLK_1200;
572 break;
573 case 1800:
574 csr |= TX_CLK_1800 | RX_CLK_1800;
575 break;
576 case 2000:
577 csr |= TX_CLK_2000 | RX_CLK_2000;
578 break;
579 case 2400:
580 csr |= TX_CLK_2400 | RX_CLK_2400;
581 break;
582 case 4800:
583 csr |= TX_CLK_4800 | RX_CLK_4800;
584 break;
585 case 9600:
586 csr |= TX_CLK_9600 | RX_CLK_9600;
587 break;
588 case 19200:
589 csr |= TX_CLK_19200 | RX_CLK_19200;
590 break;
591 case 38400:
592 default:
593 csr |= TX_CLK_38400 | RX_CLK_38400;
594 /* In case of default, we establish 38400 bps */
Alan Cox857196e2012-07-26 19:00:51 +0100595 tty_termios_encode_baud_rate(&tty->termios, 38400, 38400);
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200596 break;
597 }
598
599 mr1 |= MR1_ERROR_CHAR;
600 mr1 |= MR1_RxINT_RxRDY;
601
602 /* Write the control registers */
Jens Taprogge459e6d72012-09-12 14:55:27 +0200603 iowrite8(mr1, &channel->regs->w.mr);
604 iowrite8(mr2, &channel->regs->w.mr);
605 iowrite8(csr, &channel->regs->w.csr);
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200606
Samuel Iglesias Gonsalvezb0d17fb2012-12-10 11:50:07 +0100607 /* Enable again the RX, if it was before */
608 if (channel->rx_enable)
609 iowrite8(CR_ENABLE_RX, &channel->regs->w.cr);
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200610}
611
612static void ipoctal_hangup(struct tty_struct *tty)
613{
614 unsigned long flags;
Jens Taproggeef79de02012-09-12 14:55:28 +0200615 struct ipoctal_channel *channel = tty->driver_data;
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200616
Jens Taproggeef79de02012-09-12 14:55:28 +0200617 if (channel == NULL)
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200618 return;
619
Jens Taprogge70a32812012-09-12 14:55:26 +0200620 spin_lock_irqsave(&channel->lock, flags);
621 channel->nb_bytes = 0;
622 channel->pointer_read = 0;
623 channel->pointer_write = 0;
624 spin_unlock_irqrestore(&channel->lock, flags);
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200625
Jens Taprogge70a32812012-09-12 14:55:26 +0200626 tty_port_hangup(&channel->tty_port);
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200627
Federico Vaga78f22bc2014-09-02 17:31:39 +0200628 ipoctal_reset_channel(channel);
Peter Hurleyd41861c2016-04-09 17:53:25 -0700629 tty_port_set_initialized(&channel->tty_port, 0);
Jens Taprogge70a32812012-09-12 14:55:26 +0200630 wake_up_interruptible(&channel->tty_port.open_wait);
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200631}
632
Samuel Iglesias Gonsalveze0f8d322012-12-10 11:50:08 +0100633static void ipoctal_shutdown(struct tty_struct *tty)
634{
635 struct ipoctal_channel *channel = tty->driver_data;
636
637 if (channel == NULL)
638 return;
639
Federico Vaga78f22bc2014-09-02 17:31:39 +0200640 ipoctal_reset_channel(channel);
Peter Hurleyd41861c2016-04-09 17:53:25 -0700641 tty_port_set_initialized(&channel->tty_port, 0);
Samuel Iglesias Gonsalveze0f8d322012-12-10 11:50:08 +0100642}
643
Federico Vaga82a82342014-09-02 17:31:41 +0200644static void ipoctal_cleanup(struct tty_struct *tty)
645{
646 struct ipoctal_channel *channel = tty->driver_data;
647 struct ipoctal *ipoctal = chan_to_ipoctal(channel, tty->index);
648
649 /* release the carrier driver */
650 ipack_put_carrier(ipoctal->dev);
651}
652
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200653static const struct tty_operations ipoctal_fops = {
654 .ioctl = NULL,
655 .open = ipoctal_open,
656 .close = ipoctal_close,
657 .write = ipoctal_write_tty,
658 .set_termios = ipoctal_set_termios,
659 .write_room = ipoctal_write_room,
660 .chars_in_buffer = ipoctal_chars_in_buffer,
661 .get_icount = ipoctal_get_icount,
662 .hangup = ipoctal_hangup,
Samuel Iglesias Gonsalveze0f8d322012-12-10 11:50:08 +0100663 .shutdown = ipoctal_shutdown,
Federico Vaga82a82342014-09-02 17:31:41 +0200664 .cleanup = ipoctal_cleanup,
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200665};
666
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200667static int ipoctal_probe(struct ipack_device *dev)
668{
669 int res;
670 struct ipoctal *ipoctal;
671
672 ipoctal = kzalloc(sizeof(struct ipoctal), GFP_KERNEL);
673 if (ipoctal == NULL)
674 return -ENOMEM;
675
676 ipoctal->dev = dev;
Jens Taproggef9e314d2012-09-27 12:37:25 +0200677 res = ipoctal_inst_slot(ipoctal, dev->bus->bus_nr, dev->slot);
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200678 if (res)
679 goto out_uninst;
680
Jens Taprogge1adda492012-09-12 14:55:39 +0200681 dev_set_drvdata(&dev->dev, ipoctal);
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200682 return 0;
683
684out_uninst:
685 kfree(ipoctal);
686 return res;
687}
688
689static void __ipoctal_remove(struct ipoctal *ipoctal)
690{
691 int i;
692
Samuel Iglesias Gonsálvez690949e2012-09-11 13:35:08 +0200693 ipoctal->dev->bus->ops->free_irq(ipoctal->dev);
694
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200695 for (i = 0; i < NR_CHANNELS; i++) {
Jens Taprogge70a32812012-09-12 14:55:26 +0200696 struct ipoctal_channel *channel = &ipoctal->channel[i];
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200697 tty_unregister_device(ipoctal->tty_drv, i);
Jens Taprogge70a32812012-09-12 14:55:26 +0200698 tty_port_free_xmit_buf(&channel->tty_port);
Jiri Slaby191c5f12012-11-15 09:49:56 +0100699 tty_port_destroy(&channel->tty_port);
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200700 }
701
702 tty_unregister_driver(ipoctal->tty_drv);
703 put_tty_driver(ipoctal->tty_drv);
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200704 kfree(ipoctal);
705}
706
Jens Taprogge1adda492012-09-12 14:55:39 +0200707static void ipoctal_remove(struct ipack_device *idev)
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200708{
Jens Taprogge1adda492012-09-12 14:55:39 +0200709 __ipoctal_remove(dev_get_drvdata(&idev->dev));
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200710}
711
Jens Taproggefdfc8cf2012-09-04 17:01:18 +0200712static DEFINE_IPACK_DEVICE_TABLE(ipoctal_ids) = {
713 { IPACK_DEVICE(IPACK_ID_VERSION_1, IPACK1_VENDOR_ID_SBS,
714 IPACK1_DEVICE_ID_SBS_OCTAL_232) },
715 { IPACK_DEVICE(IPACK_ID_VERSION_1, IPACK1_VENDOR_ID_SBS,
716 IPACK1_DEVICE_ID_SBS_OCTAL_422) },
717 { IPACK_DEVICE(IPACK_ID_VERSION_1, IPACK1_VENDOR_ID_SBS,
718 IPACK1_DEVICE_ID_SBS_OCTAL_485) },
719 { 0, },
720};
721
722MODULE_DEVICE_TABLE(ipack, ipoctal_ids);
723
Jens Taproggee8011132012-09-04 17:01:17 +0200724static const struct ipack_driver_ops ipoctal_drv_ops = {
Jens Taprogge4aa09d42012-09-04 17:01:19 +0200725 .probe = ipoctal_probe,
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200726 .remove = ipoctal_remove,
727};
728
Jens Taproggee8011132012-09-04 17:01:17 +0200729static struct ipack_driver driver = {
730 .ops = &ipoctal_drv_ops,
Jens Taproggefdfc8cf2012-09-04 17:01:18 +0200731 .id_table = ipoctal_ids,
Jens Taproggee8011132012-09-04 17:01:17 +0200732};
733
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200734static int __init ipoctal_init(void)
735{
Samuel Iglesias Gonsalvezec440332012-05-18 11:10:05 +0200736 return ipack_driver_register(&driver, THIS_MODULE, KBUILD_MODNAME);
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200737}
738
739static void __exit ipoctal_exit(void)
740{
Samuel Iglesias Gonsalvezba4dc612012-05-09 15:27:21 +0200741 ipack_driver_unregister(&driver);
742}
743
744MODULE_DESCRIPTION("IP-Octal 232, 422 and 485 device driver");
745MODULE_LICENSE("GPL");
746
747module_init(ipoctal_init);
748module_exit(ipoctal_exit);