2 +++ b/drivers/ata/pata_rbppc_cf.c
5 + * Copyright (C) 2008-2009 Noah Fontes <nfontes@transtruct.org>
6 + * Copyright (C) Mikrotik 2007
8 + * This program is free software; you can redistribute it and/or modify it
9 + * under the terms of the GNU General Public License as published by the
10 + * Free Software Foundation; either version 2 of the License, or (at your
11 + * option) any later version.
14 +#include <linux/kernel.h>
15 +#include <linux/module.h>
16 +#include <linux/init.h>
17 +#include <scsi/scsi_host.h>
18 +#include <linux/libata.h>
19 +#include <linux/of_platform.h>
20 +#include <linux/ata_platform.h>
24 +#define DRV_NAME "pata_rbppc_cf"
25 +#define DRV_VERSION "0.0.2"
27 +#define DEV2SEL_OFFSET 0x00100000
29 +#define IMMR_LBCFG_OFFSET 0x00005000
30 +#define IMMR_LBCFG_SIZE 0x00001000
32 +#define LOCAL_BUS_MCMR 0x00000078
33 +#define MxMR_OP_MASK 0x30000000
34 +#define MxMR_OP_NORMAL 0x00000000
35 +#define MxMR_OP_WRITE 0x10000000
36 +#define MxMR_OP_READ 0x20000000
37 +#define MxMR_OP_RUN 0x30000000
38 +#define MxMR_LUPWAIT_LOW 0x08000000
39 +#define MxMR_LUPWAIT_HIGH 0x00000000
40 +#define MxMR_LUPWAIT_ENABLE 0x00040000
41 +#define MxMR_RLF_MASK 0x0003c000
42 +#define MxMR_RLF_SHIFT 14
43 +#define MxMR_WLF_MASK 0x00003c00
44 +#define MxMR_WLF_SHIFT 10
45 +#define MxMR_MAD_MASK 0x0000003f
46 +#define LOCAL_BUS_MDR 0x00000088
47 +#define LOCAL_BUS_LCRR 0x000000D4
48 +#define LCRR_CLKDIV_MASK 0x0000000f
52 +#define UPM_READ_SINGLE_OFFSET 0x00
53 +#define UPM_WRITE_SINGLE_OFFSET 0x18
54 +#define UPM_DATA_SIZE 0x40
56 +#define LBT_CPUIN_MIN 0
57 +#define LBT_CPUOUT_MIN 1
58 +#define LBT_CPUOUT_MAX 2
59 +#define LBT_EXTDEL_MIN 3
60 +#define LBT_EXTDEL_MAX 4
63 +/* UPM machine configuration bits */
64 +#define N_BASE 0x00f00000
65 +#define N_CS 0xf0000000
66 +#define N_CS_H1 0xc0000000
67 +#define N_CS_H2 0x30000000
68 +#define N_WE 0x0f000000
69 +#define N_WE_H1 0x0c000000
70 +#define N_WE_H2 0x03000000
71 +#define N_OE 0x00030000
72 +#define N_OE_H1 0x00020000
73 +#define N_OE_H2 0x00010000
74 +#define WAEN 0x00001000
75 +#define REDO_2 0x00000100
76 +#define REDO_3 0x00000200
77 +#define REDO_4 0x00000300
78 +#define LOOP 0x00000080
79 +#define NA 0x00000008
80 +#define UTA 0x00000004
81 +#define LAST 0x00000001
83 +#define REDO_VAL(mult) (REDO_2 * ((mult) - 1))
84 +#define REDO_MAX_MULT 4
86 +#define READ_BASE (N_BASE | N_WE)
87 +#define WRITE_BASE (N_BASE | N_OE)
88 +#define EMPTY (N_BASE | N_CS | N_OE | N_WE | LAST)
90 +#define EOF_UPM_SETTINGS 0
91 +#define ANOTHER_TIMING 1
93 +#define OA_CPUIN_MIN 0x01
94 +#define OA_CPUOUT_MAX 0x02
95 +#define OD_CPUOUT_MIN 0x04
96 +#define OA_CPUOUT_DELTA 0x06
97 +#define OA_EXTDEL_MAX 0x08
98 +#define OD_EXTDEL_MIN 0x10
99 +#define OA_EXTDEL_DELTA 0x18
100 +#define O_MIN_CYCLE_TIME 0x20
101 +#define O_MINUS_PREV 0x40
102 +#define O_HALF_CYCLE 0x80
104 +extern void __iomem *localbus_map(unsigned long addr, unsigned int len);
105 +extern void localbus_unmap(void __iomem *addr);
107 +struct rbppc_cf_info {
108 + unsigned lbcfg_addr;
109 + unsigned clk_time_ps;
111 + u32 lb_timings[LBT_SIZE];
113 +static struct rbppc_cf_info *rbinfo = NULL;
115 +struct upm_setting {
118 + unsigned clk_minus;
119 + unsigned group_size;
123 +static const struct upm_setting cfUpmReadSingle[] = {
124 + { READ_BASE | N_OE,
125 + /* t1 - ADDR setup time */
126 + { 70, 50, 30, 30, 25, 15, 10 }, 0, 0, (OA_CPUOUT_DELTA |
128 + { READ_BASE | N_OE_H1,
129 + { 0, 0, 0, 0, 0, 0, 0 }, 0, 0, O_HALF_CYCLE },
131 + /* t2 - OE0 time */
132 + { 290, 290, 290, 80, 70, 65, 55 }, 0, 2, (OA_CPUOUT_MAX |
134 + { READ_BASE | WAEN,
135 + { 1, 1, 1, 1, 1, 0, 0 }, 0, 0, 0 },
137 + { 1, 1, 1, 1, 1, 1, 1 }, 0, 0, 0 },
138 + { READ_BASE | N_OE,
139 + /* t9 - ADDR hold time */
140 + { 20, 15, 10, 10, 10, 10, 10 }, 0, 0, (OA_CPUOUT_DELTA |
142 + { READ_BASE | N_OE | N_CS_H2,
143 + { 0, 0, 0, 0, 0, 0, 0 }, 0, 0, O_HALF_CYCLE },
144 + { READ_BASE | N_OE | N_CS,
145 + /* t6Z -IORD data tristate */
146 + { 30, 30, 30, 30, 30, 20, 20 }, 1, 1, O_MINUS_PREV },
148 + /* t2i -IORD recovery time */
149 + { 0, 0, 0, 70, 25, 25, 20 }, 2, 0, 0 },
151 + /* CS 0 -> 1 MAX */
152 + { 0, 0, 0, 0, 0, 0, 0 }, 1, 0, (OA_CPUOUT_DELTA |
154 + { READ_BASE | N_OE | N_CS | LAST,
155 + { 1, 1, 1, 1, 1, 1, 1 }, 0, 0, 0 },
156 + { EOF_UPM_SETTINGS,
157 + /* min total cycle time - includes turnaround and ALE cycle */
158 + { 600, 383, 240, 180, 120, 100, 80 }, 2, 0, O_MIN_CYCLE_TIME },
161 +static const struct upm_setting cfUpmWriteSingle[] = {
162 + { WRITE_BASE | N_WE,
163 + /* t1 - ADDR setup time */
164 + { 70, 50, 30, 30, 25, 15, 10 }, 0, 0, (OA_CPUOUT_DELTA |
166 + { WRITE_BASE | N_WE_H1,
167 + { 0, 0, 0, 0, 0, 0, 0 }, 0, 0, O_HALF_CYCLE },
169 + /* t2 - WE0 time */
170 + { 290, 290, 290, 80, 70, 65, 55 }, 0, 1, OA_CPUOUT_DELTA },
171 + { WRITE_BASE | WAEN,
172 + { 1, 1, 1, 1, 1, 0, 0 }, 0, 0, 0 },
173 + { WRITE_BASE | N_WE,
174 + /* t9 - ADDR hold time */
175 + { 20, 15, 10, 10, 10, 10, 10 }, 0, 0, (OA_CPUOUT_DELTA |
177 + { WRITE_BASE | N_WE | N_CS_H2,
178 + { 0, 0, 0, 0, 0, 0, 0 }, 0, 0, O_HALF_CYCLE },
179 + { WRITE_BASE | N_WE | N_CS,
180 + /* t4 - DATA hold time */
181 + { 30, 20, 15, 10, 10, 10, 10 }, 0, 1, O_MINUS_PREV },
183 + /* t2i -IOWR recovery time */
184 + { 0, 0, 0, 70, 25, 25, 20 }, 1, 0, 0 },
186 + /* CS 0 -> 1 MAX */
187 + { 0, 0, 0, 0, 0, 0, 0 }, 0, 0, (OA_CPUOUT_DELTA |
189 + { WRITE_BASE | N_WE | N_CS | UTA | LAST,
190 + { 1, 1, 1, 1, 1, 1, 1 }, 0, 0, 0 },
191 + /* min total cycle time - includes ALE cycle */
192 + { EOF_UPM_SETTINGS,
193 + { 600, 383, 240, 180, 120, 100, 80 }, 1, 0, O_MIN_CYCLE_TIME },
196 +static u8 rbppc_cf_check_status(struct ata_port *ap) {
197 + u8 val = ioread8(ap->ioaddr.status_addr);
203 +static u8 rbppc_cf_check_altstatus(struct ata_port *ap) {
204 + u8 val = ioread8(ap->ioaddr.altstatus_addr);
210 +static void rbppc_cf_dummy_noret(struct ata_port *ap) { }
211 +static int rbppc_cf_dummy_ret0(struct ata_port *ap) { return 0; }
213 +static int ps2clk(int ps, unsigned clk_time_ps) {
215 + if (ps <= 0) return 0;
217 + /* round down if <= 2% over clk border, but no more than 1/4 clk cycle */
218 + psMaxOver = ps * 2 / 100;
219 + if (4 * psMaxOver > clk_time_ps) {
220 + psMaxOver = clk_time_ps / 4;
222 + return (ps + clk_time_ps - 1 - psMaxOver) / clk_time_ps;
225 +static int upm_gen_ps_table(const struct upm_setting *upm,
226 + int mode, struct rbppc_cf_info *info,
229 + int lastUpmValIdx = 0;
230 + int group_start_idx = -1;
231 + int group_left_num = -1;
232 + int clk_time_ps = info->clk_time_ps;
234 + for (uidx = 0; upm[uidx].value != EOF_UPM_SETTINGS; ++uidx) {
235 + const struct upm_setting *us = upm + uidx;
236 + unsigned opt = us->options;
237 + int ps = us->ns[mode] * 1000 - us->clk_minus * clk_time_ps;
239 + if (opt & OA_CPUIN_MIN) ps += info->lb_timings[LBT_CPUIN_MIN];
240 + if (opt & OD_CPUOUT_MIN) ps -= info->lb_timings[LBT_CPUOUT_MIN];
241 + if (opt & OA_CPUOUT_MAX) ps += info->lb_timings[LBT_CPUOUT_MAX];
242 + if (opt & OD_EXTDEL_MIN) ps -= info->lb_timings[LBT_EXTDEL_MIN];
243 + if (opt & OA_EXTDEL_MAX) ps += info->lb_timings[LBT_EXTDEL_MAX];
245 + if (us->value == ANOTHER_TIMING) {
246 + /* use longest timing from alternatives */
247 + if (psFinal[lastUpmValIdx] < ps) {
248 + psFinal[lastUpmValIdx] = ps;
253 + if (us->group_size) {
254 + group_start_idx = uidx;
255 + group_left_num = us->group_size;
257 + else if (group_left_num > 0) {
258 + /* group time is divided on all group members */
259 + int clk = ps2clk(ps, clk_time_ps);
260 + psFinal[group_start_idx] -= clk * clk_time_ps;
263 + if ((opt & O_MINUS_PREV) && lastUpmValIdx > 0) {
264 + int clk = ps2clk(psFinal[lastUpmValIdx],
266 + ps -= clk * clk_time_ps;
268 + lastUpmValIdx = uidx;
270 + psFinal[uidx] = ps;
275 +static int free_half(int ps, int clk, int clk_time_ps) {
276 + if (clk < 2) return 0;
277 + return (clk * clk_time_ps - ps) * 2 >= clk_time_ps;
280 +static void upm_gen_clk_table(const struct upm_setting *upm,
281 + int mode, int clk_time_ps,
282 + int max_uidx, const int *psFinal, int *clkFinal) {
283 + int clk_cycle_time;
287 + /* convert picoseconds to clocks */
289 + for (uidx = 0; uidx < max_uidx; ++uidx) {
290 + int clk = ps2clk(psFinal[uidx], clk_time_ps);
291 + clkFinal[uidx] = clk;
295 + /* check possibility of half cycle usage */
296 + for (uidx = 1; uidx < max_uidx - 1; ++uidx) {
297 + if ((upm[uidx].options & O_HALF_CYCLE) &&
298 + free_half(psFinal[uidx - 1], clkFinal[uidx - 1],
300 + free_half(psFinal[uidx + 1], clkFinal[uidx + 1],
303 + --clkFinal[uidx - 1];
304 + --clkFinal[uidx + 1];
308 + if ((upm[max_uidx].options & O_MIN_CYCLE_TIME) == 0) return;
310 + /* check cycle time, adjust timings if needed */
311 + clk_cycle_time = (ps2clk(upm[max_uidx].ns[mode] * 1000, clk_time_ps) -
312 + upm[max_uidx].clk_minus);
314 + while (clk_total < clk_cycle_time) {
315 + /* extend all timings in round-robin to match cycle time */
316 + if (clkFinal[uidx]) {
318 + printk(KERN_INFO "extending %u by 1 clk\n", uidx);
324 + if (uidx == max_uidx) uidx = 0;
328 +static void add_data_val(unsigned val, int *clkLeft, int maxClk,
329 + unsigned *data, int *dataIdx) {
330 + if (*clkLeft == 0) return;
332 + if (maxClk == 0 && *clkLeft >= LOOP_SIZE * 2) {
337 + times = *clkLeft / LOOP_SIZE;
338 + if (times > REDO_MAX_MULT * 2) times = REDO_MAX_MULT * 2;
339 + times1 = times / 2;
340 + times2 = times - times1;
343 + data[*dataIdx] = val | REDO_VAL(times1);
345 + data[*dataIdx] = val | REDO_VAL(times2);
348 + *clkLeft -= times * LOOP_SIZE;
352 + if (maxClk < 1 || maxClk > REDO_MAX_MULT) maxClk = REDO_MAX_MULT;
353 + if (*clkLeft < maxClk) maxClk = *clkLeft;
355 + *clkLeft -= maxClk;
356 + val |= REDO_VAL(maxClk);
358 + data[*dataIdx] = val;
362 +static int upm_gen_final_data(const struct upm_setting *upm,
363 + int max_uidx, int *clkFinal, unsigned *data) {
368 + for (uidx = 0; uidx < max_uidx; ++uidx) {
369 + int clk = clkFinal[uidx];
371 + add_data_val(upm[uidx].value, &clk, 0,
378 +static int conv_upm_table(const struct upm_setting *upm,
379 + int mode, struct rbppc_cf_info *info,
389 + max_uidx = upm_gen_ps_table(upm, mode, info, psFinal);
391 + upm_gen_clk_table(upm, mode, info->clk_time_ps, max_uidx,
392 + psFinal, clkFinal);
395 + /* dump out debug info */
396 + for (uidx = 0; uidx < max_uidx; ++uidx) {
397 + if (clkFinal[uidx]) {
398 + printk(KERN_INFO "idx %d val %08x clk %d ps %d\n",
399 + uidx, upm[uidx].value,
400 + clkFinal[uidx], psFinal[uidx]);
405 + data_len = upm_gen_final_data(upm, max_uidx, clkFinal, data);
408 + for (uidx = 0; uidx < data_len; ++uidx) {
409 + printk(KERN_INFO "cf UPM x result: idx %d val %08x\n",
416 +static int gen_upm_data(int mode, struct rbppc_cf_info *info, unsigned *data) {
419 + for (i = 0; i < UPM_DATA_SIZE; ++i) {
423 + if (conv_upm_table(cfUpmReadSingle, mode, info, data + UPM_READ_SINGLE_OFFSET)) {
426 + if (conv_upm_table(cfUpmWriteSingle, mode, info, data + UPM_WRITE_SINGLE_OFFSET)) {
432 +static void rbppc_cf_program_upm(void *upmMemAddr, volatile void *lbcfg_mxmr, volatile void *lbcfg_mdr, const unsigned *upmData, unsigned offset, unsigned len) {
436 + mxmr = in_be32(lbcfg_mxmr);
437 + mxmr &= ~(MxMR_OP_MASK | MxMR_MAD_MASK);
438 + mxmr |= (MxMR_OP_WRITE | offset);
439 + out_be32(lbcfg_mxmr, mxmr);
440 + in_be32(lbcfg_mxmr); /* flush MxMR write */
442 + for (i = 0; i < len; ++i) {
444 + unsigned data = upmData[i + offset];
445 + out_be32(lbcfg_mdr, data);
446 + in_be32(lbcfg_mdr); /* flush MDR write */
448 + iowrite8(1, upmMemAddr); /* dummy write to any CF addr */
450 + /* wait for dummy write to complete */
451 + for (to = 10000; to >= 0; --to) {
452 + mxmr = in_be32(lbcfg_mxmr);
453 + if (((mxmr ^ (i + 1)) & MxMR_MAD_MASK) == 0) {
457 + printk(KERN_ERR "rbppc_cf_program_upm: UPMx program error at 0x%x: Timeout\n", i);
461 + mxmr &= ~(MxMR_OP_MASK | MxMR_RLF_MASK | MxMR_WLF_MASK);
462 + mxmr |= (MxMR_OP_NORMAL | (LOOP_SIZE << MxMR_RLF_SHIFT) | (LOOP_SIZE << MxMR_WLF_SHIFT));
463 + out_be32(lbcfg_mxmr, mxmr);
466 +static int rbppc_cf_update_piomode(struct ata_port *ap, int mode) {
467 + struct rbppc_cf_info *info = (struct rbppc_cf_info *)ap->host->private_data;
469 + unsigned upmData[UPM_DATA_SIZE];
471 + if (gen_upm_data(mode, info, upmData)) {
475 + lbcfgBase = ioremap_nocache(info->lbcfg_addr, IMMR_LBCFG_SIZE);
477 + rbppc_cf_program_upm(ap->ioaddr.cmd_addr, ((char *)lbcfgBase) + LOCAL_BUS_MCMR, ((char *)lbcfgBase) + LOCAL_BUS_MDR, upmData, 0, UPM_DATA_SIZE);
478 + iounmap(lbcfgBase);
482 +static void rbppc_cf_set_piomode(struct ata_port *ap, struct ata_device *adev)
484 + struct rbppc_cf_info *info = (struct rbppc_cf_info *)ap->host->private_data;
485 + int mode = adev->pio_mode - XFER_PIO_0;
487 + DPRINTK("rbppc_cf_set_piomode: PIO %d\n", mode);
488 + if (mode < 0) mode = 0;
489 + if (mode > 6) mode = 6;
491 + if (info->cur_mode < 0 || info->cur_mode > mode) {
492 + if (rbppc_cf_update_piomode(ap, mode) == 0) {
493 + printk(KERN_INFO "rbppc_cf_set_piomode: PIO mode changed to %d\n", mode);
494 + info->cur_mode = mode;
499 +static struct scsi_host_template rbppc_cf_sht = {
500 + ATA_BASE_SHT(DRV_NAME),
503 +static struct ata_port_operations rbppc_cf_port_ops = {
504 + .inherits = &ata_bmdma_port_ops,
506 + .sff_check_status = rbppc_cf_check_status,
507 + .sff_check_altstatus = rbppc_cf_check_altstatus,
509 + .set_piomode = rbppc_cf_set_piomode,
511 + .port_start = rbppc_cf_dummy_ret0,
513 + .sff_irq_clear = rbppc_cf_dummy_noret,
516 +static int rbppc_cf_init_info(struct of_device *pdev, struct rbppc_cf_info *info) {
517 + struct device_node *np;
518 + struct resource res;
522 + unsigned lbc_clk_khz;
523 + unsigned lbc_extra_divider = 1;
524 + unsigned ccb_freq_hz;
527 + u32ptr = of_get_property(pdev->node, "lbc_extra_divider", NULL);
528 + if (u32ptr && *u32ptr) {
529 + lbc_extra_divider = *u32ptr;
531 + printk(KERN_INFO "rbppc_cf_init_info: LBC extra divider %u\n",
532 + lbc_extra_divider);
536 + np = of_find_node_by_type(NULL, "serial");
538 + printk(KERN_ERR "rbppc_cf_init_info: No serial node found\n");
541 + u32ptr = of_get_property(np, "clock-frequency", NULL);
542 + if (u32ptr == 0 || *u32ptr == 0) {
543 + printk(KERN_ERR "rbppc_cf_init_info: Serial does not have clock-frequency\n");
547 + ccb_freq_hz = *u32ptr;
550 + np = of_find_node_by_type(NULL, "soc");
552 + printk(KERN_ERR "rbppc_cf_init_info: No soc node found\n");
555 + if (of_address_to_resource(np, 0, &res)) {
556 + printk(KERN_ERR "rbppc_cf_init_info: soc does not have resource\n");
560 + info->lbcfg_addr = res.start + IMMR_LBCFG_OFFSET;
563 + lbcfgBase = ioremap_nocache(info->lbcfg_addr, IMMR_LBCFG_SIZE);
564 + lbcfg_lcrr = ((char*)lbcfgBase) + LOCAL_BUS_LCRR;
565 + lb_div = (in_be32(lbcfg_lcrr) & LCRR_CLKDIV_MASK) * lbc_extra_divider;
566 + iounmap(lbcfgBase);
568 + lbc_clk_khz = ccb_freq_hz / (1000 * lb_div);
569 + info->clk_time_ps = 1000000000 / lbc_clk_khz;
570 + printk(KERN_INFO "rbppc_cf_init_info: Using Local-Bus clock %u kHz %u ps\n",
571 + lbc_clk_khz, info->clk_time_ps);
573 + u32ptr = of_get_property(pdev->node, "lb-timings", NULL);
575 + memcpy(info->lb_timings, u32ptr, LBT_SIZE * sizeof(*u32ptr));
577 + printk(KERN_INFO "rbppc_cf_init_info: Got LB timings <%u %u %u %u %u>\n",
578 + u32ptr[0], u32ptr[1], u32ptr[2], u32ptr[3], u32ptr[4]);
581 + info->cur_mode = -1;
585 +static int rbppc_cf_probe(struct of_device *pdev,
586 + const struct of_device_id *match)
588 + struct ata_host *host;
589 + struct ata_port *ap;
590 + struct rbppc_cf_info *info = NULL;
591 + struct resource res;
597 + printk(KERN_INFO "rbppc_cf_probe: MikroTik RouterBOARD 600 series Compact Flash PATA driver, version " DRV_VERSION "\n");
599 + if (rbinfo == NULL) {
600 + info = kmalloc(sizeof(*info), GFP_KERNEL);
601 + if (info == NULL) {
602 + printk(KERN_ERR "rbppc_cf_probe: Out of memory\n");
605 + memset(info, 0, sizeof(*info));
607 + if (rbppc_cf_init_info(pdev, info)) {
613 + u32ptr = of_get_property(pdev->node, "interrupt-at-level", NULL);
615 + irq_level = *u32ptr;
616 + printk(KERN_INFO "rbppc_cf_probe: IRQ level %u\n", irq_level);
619 + if (of_address_to_resource(pdev->node, 0, &res)) {
620 + printk(KERN_ERR "rbppc_cf_probe: No reg property found\n");
624 + host = ata_host_alloc(&pdev->dev, 1);
628 + baddr = localbus_map(res.start, res.end - res.start + 1);
629 + host->iomap = baddr;
630 + host->private_data = rbinfo;
632 + ap = host->ports[0];
633 + ap->ops = &rbppc_cf_port_ops;
634 + ap->pio_mask = 0x7F; /* PIO modes 0-6 */
635 + ap->flags = ATA_FLAG_NO_LEGACY;
636 + ap->mwdma_mask = 0;
638 + ap->ioaddr.cmd_addr = baddr;
639 + ata_sff_std_ports(&ap->ioaddr);
640 + ap->ioaddr.ctl_addr = ap->ioaddr.cmd_addr + 14;
641 + ap->ioaddr.altstatus_addr = ap->ioaddr.ctl_addr;
642 + ap->ioaddr.bmdma_addr = 0;
644 + err = ata_host_activate(
646 + irq_of_parse_and_map(pdev->node, 0), ata_sff_interrupt,
647 + irq_level ? IRQF_TRIGGER_HIGH : IRQF_TRIGGER_LOW,
649 + if (!err) return 0;
651 + localbus_unmap(baddr);
660 +static int rbppc_cf_remove(struct of_device *pdev)
662 + struct device *dev = &pdev->dev;
663 + struct ata_host *host = dev_get_drvdata(dev);
665 + if (host == NULL) return -1;
667 + ata_host_detach(host);
671 +static struct of_device_id rbppc_cf_ids[] = {
676 +static struct of_platform_driver rbppc_cf_driver = {
678 + .probe = rbppc_cf_probe,
679 + .remove = rbppc_cf_remove,
680 + .match_table = rbppc_cf_ids,
682 + .name = "rbppc-cf",
683 + .owner = THIS_MODULE,
687 +static int __init rbppc_init(void)
689 + return of_register_platform_driver(&rbppc_cf_driver);
692 +static void __exit rbppc_exit(void)
694 + of_unregister_platform_driver(&rbppc_cf_driver);
697 +MODULE_AUTHOR("Mikrotikls SIA");
698 +MODULE_AUTHOR("Noah Fontes");
699 +MODULE_DESCRIPTION("MikroTik RouterBOARD 600 series Compact Flash PATA driver");
700 +MODULE_LICENSE("GPL");
701 +MODULE_VERSION(DRV_VERSION);
703 +module_init(rbppc_init);
704 +module_exit(rbppc_exit);