KGDB: Remove set but unused newPC
[linux-2.6/next.git] / drivers / mfd / timberdale.c
blobac5995026c8836f392806293a6092c4f1ce30ac7
1 /*
2 * timberdale.c timberdale FPGA MFD driver
3 * Copyright (c) 2009 Intel Corporation
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 /* Supports:
20 * Timberdale FPGA
23 #include <linux/kernel.h>
24 #include <linux/module.h>
25 #include <linux/pci.h>
26 #include <linux/msi.h>
27 #include <linux/mfd/core.h>
28 #include <linux/slab.h>
30 #include <linux/timb_gpio.h>
32 #include <linux/i2c.h>
33 #include <linux/i2c-ocores.h>
34 #include <linux/i2c-xiic.h>
35 #include <linux/i2c/tsc2007.h>
37 #include <linux/spi/spi.h>
38 #include <linux/spi/xilinx_spi.h>
39 #include <linux/spi/max7301.h>
40 #include <linux/spi/mc33880.h>
42 #include <media/timb_radio.h>
44 #include <linux/timb_dma.h>
46 #include "timberdale.h"
48 #define DRIVER_NAME "timberdale"
50 struct timberdale_device {
51 resource_size_t ctl_mapbase;
52 unsigned char __iomem *ctl_membase;
53 struct {
54 u32 major;
55 u32 minor;
56 u32 config;
57 } fw;
60 /*--------------------------------------------------------------------------*/
62 static struct tsc2007_platform_data timberdale_tsc2007_platform_data = {
63 .model = 2003,
64 .x_plate_ohms = 100
67 static struct i2c_board_info timberdale_i2c_board_info[] = {
69 I2C_BOARD_INFO("tsc2007", 0x48),
70 .platform_data = &timberdale_tsc2007_platform_data,
71 .irq = IRQ_TIMBERDALE_TSC_INT
75 static __devinitdata struct xiic_i2c_platform_data
76 timberdale_xiic_platform_data = {
77 .devices = timberdale_i2c_board_info,
78 .num_devices = ARRAY_SIZE(timberdale_i2c_board_info)
81 static __devinitdata struct ocores_i2c_platform_data
82 timberdale_ocores_platform_data = {
83 .regstep = 4,
84 .clock_khz = 62500,
85 .devices = timberdale_i2c_board_info,
86 .num_devices = ARRAY_SIZE(timberdale_i2c_board_info)
89 static const __devinitconst struct resource timberdale_xiic_resources[] = {
91 .start = XIICOFFSET,
92 .end = XIICEND,
93 .flags = IORESOURCE_MEM,
96 .start = IRQ_TIMBERDALE_I2C,
97 .end = IRQ_TIMBERDALE_I2C,
98 .flags = IORESOURCE_IRQ,
102 static const __devinitconst struct resource timberdale_ocores_resources[] = {
104 .start = OCORESOFFSET,
105 .end = OCORESEND,
106 .flags = IORESOURCE_MEM,
109 .start = IRQ_TIMBERDALE_I2C,
110 .end = IRQ_TIMBERDALE_I2C,
111 .flags = IORESOURCE_IRQ,
115 const struct max7301_platform_data timberdale_max7301_platform_data = {
116 .base = 200
119 const struct mc33880_platform_data timberdale_mc33880_platform_data = {
120 .base = 100
123 static struct spi_board_info timberdale_spi_16bit_board_info[] = {
125 .modalias = "max7301",
126 .max_speed_hz = 26000,
127 .chip_select = 2,
128 .mode = SPI_MODE_0,
129 .platform_data = &timberdale_max7301_platform_data
133 static struct spi_board_info timberdale_spi_8bit_board_info[] = {
135 .modalias = "mc33880",
136 .max_speed_hz = 4000,
137 .chip_select = 1,
138 .mode = SPI_MODE_1,
139 .platform_data = &timberdale_mc33880_platform_data
143 static __devinitdata struct xspi_platform_data timberdale_xspi_platform_data = {
144 .num_chipselect = 3,
145 .little_endian = true,
146 /* bits per word and devices will be filled in runtime depending
147 * on the HW config
151 static const __devinitconst struct resource timberdale_spi_resources[] = {
153 .start = SPIOFFSET,
154 .end = SPIEND,
155 .flags = IORESOURCE_MEM,
158 .start = IRQ_TIMBERDALE_SPI,
159 .end = IRQ_TIMBERDALE_SPI,
160 .flags = IORESOURCE_IRQ,
164 static const __devinitconst struct resource timberdale_eth_resources[] = {
166 .start = ETHOFFSET,
167 .end = ETHEND,
168 .flags = IORESOURCE_MEM,
171 .start = IRQ_TIMBERDALE_ETHSW_IF,
172 .end = IRQ_TIMBERDALE_ETHSW_IF,
173 .flags = IORESOURCE_IRQ,
177 static __devinitdata struct timbgpio_platform_data
178 timberdale_gpio_platform_data = {
179 .gpio_base = 0,
180 .nr_pins = GPIO_NR_PINS,
181 .irq_base = 200,
184 static const __devinitconst struct resource timberdale_gpio_resources[] = {
186 .start = GPIOOFFSET,
187 .end = GPIOEND,
188 .flags = IORESOURCE_MEM,
191 .start = IRQ_TIMBERDALE_GPIO,
192 .end = IRQ_TIMBERDALE_GPIO,
193 .flags = IORESOURCE_IRQ,
197 static const __devinitconst struct resource timberdale_mlogicore_resources[] = {
199 .start = MLCOREOFFSET,
200 .end = MLCOREEND,
201 .flags = IORESOURCE_MEM,
204 .start = IRQ_TIMBERDALE_MLCORE,
205 .end = IRQ_TIMBERDALE_MLCORE,
206 .flags = IORESOURCE_IRQ,
209 .start = IRQ_TIMBERDALE_MLCORE_BUF,
210 .end = IRQ_TIMBERDALE_MLCORE_BUF,
211 .flags = IORESOURCE_IRQ,
215 static const __devinitconst struct resource timberdale_uart_resources[] = {
217 .start = UARTOFFSET,
218 .end = UARTEND,
219 .flags = IORESOURCE_MEM,
222 .start = IRQ_TIMBERDALE_UART,
223 .end = IRQ_TIMBERDALE_UART,
224 .flags = IORESOURCE_IRQ,
228 static const __devinitconst struct resource timberdale_uartlite_resources[] = {
230 .start = UARTLITEOFFSET,
231 .end = UARTLITEEND,
232 .flags = IORESOURCE_MEM,
235 .start = IRQ_TIMBERDALE_UARTLITE,
236 .end = IRQ_TIMBERDALE_UARTLITE,
237 .flags = IORESOURCE_IRQ,
241 static const __devinitconst struct resource timberdale_radio_resources[] = {
243 .start = RDSOFFSET,
244 .end = RDSEND,
245 .flags = IORESOURCE_MEM,
248 .start = IRQ_TIMBERDALE_RDS,
249 .end = IRQ_TIMBERDALE_RDS,
250 .flags = IORESOURCE_IRQ,
254 static __devinitdata struct i2c_board_info timberdale_tef6868_i2c_board_info = {
255 I2C_BOARD_INFO("tef6862", 0x60)
258 static __devinitdata struct i2c_board_info timberdale_saa7706_i2c_board_info = {
259 I2C_BOARD_INFO("saa7706h", 0x1C)
262 static __devinitdata struct timb_radio_platform_data
263 timberdale_radio_platform_data = {
264 .i2c_adapter = 0,
265 .tuner = {
266 .module_name = "tef6862",
267 .info = &timberdale_tef6868_i2c_board_info
269 .dsp = {
270 .module_name = "saa7706h",
271 .info = &timberdale_saa7706_i2c_board_info
275 static __devinitdata struct timb_dma_platform_data timb_dma_platform_data = {
276 .nr_channels = 10,
277 .channels = {
279 /* UART RX */
280 .rx = true,
281 .descriptors = 2,
282 .descriptor_elements = 1
285 /* UART TX */
286 .rx = false,
287 .descriptors = 2,
288 .descriptor_elements = 1
291 /* MLB RX */
292 .rx = true,
293 .descriptors = 2,
294 .descriptor_elements = 1
297 /* MLB TX */
298 .rx = false,
299 .descriptors = 2,
300 .descriptor_elements = 1
303 /* Video RX */
304 .rx = true,
305 .bytes_per_line = 1440,
306 .descriptors = 2,
307 .descriptor_elements = 16
310 /* Video framedrop */
313 /* SDHCI RX */
314 .rx = true,
317 /* SDHCI TX */
320 /* ETH RX */
321 .rx = true,
322 .descriptors = 2,
323 .descriptor_elements = 1
326 /* ETH TX */
327 .rx = false,
328 .descriptors = 2,
329 .descriptor_elements = 1
334 static const __devinitconst struct resource timberdale_dma_resources[] = {
336 .start = DMAOFFSET,
337 .end = DMAEND,
338 .flags = IORESOURCE_MEM,
341 .start = IRQ_TIMBERDALE_DMA,
342 .end = IRQ_TIMBERDALE_DMA,
343 .flags = IORESOURCE_IRQ,
347 static __devinitdata struct mfd_cell timberdale_cells_bar0_cfg0[] = {
349 .name = "timb-dma",
350 .num_resources = ARRAY_SIZE(timberdale_dma_resources),
351 .resources = timberdale_dma_resources,
352 .platform_data = &timb_dma_platform_data,
353 .data_size = sizeof(timb_dma_platform_data),
356 .name = "timb-uart",
357 .num_resources = ARRAY_SIZE(timberdale_uart_resources),
358 .resources = timberdale_uart_resources,
361 .name = "xiic-i2c",
362 .num_resources = ARRAY_SIZE(timberdale_xiic_resources),
363 .resources = timberdale_xiic_resources,
364 .platform_data = &timberdale_xiic_platform_data,
365 .data_size = sizeof(timberdale_xiic_platform_data),
368 .name = "timb-gpio",
369 .num_resources = ARRAY_SIZE(timberdale_gpio_resources),
370 .resources = timberdale_gpio_resources,
371 .platform_data = &timberdale_gpio_platform_data,
372 .data_size = sizeof(timberdale_gpio_platform_data),
375 .name = "timb-radio",
376 .num_resources = ARRAY_SIZE(timberdale_radio_resources),
377 .resources = timberdale_radio_resources,
378 .platform_data = &timberdale_radio_platform_data,
379 .data_size = sizeof(timberdale_radio_platform_data),
382 .name = "xilinx_spi",
383 .num_resources = ARRAY_SIZE(timberdale_spi_resources),
384 .resources = timberdale_spi_resources,
385 .platform_data = &timberdale_xspi_platform_data,
386 .data_size = sizeof(timberdale_xspi_platform_data),
389 .name = "ks8842",
390 .num_resources = ARRAY_SIZE(timberdale_eth_resources),
391 .resources = timberdale_eth_resources,
395 static __devinitdata struct mfd_cell timberdale_cells_bar0_cfg1[] = {
397 .name = "timb-dma",
398 .num_resources = ARRAY_SIZE(timberdale_dma_resources),
399 .resources = timberdale_dma_resources,
400 .platform_data = &timb_dma_platform_data,
401 .data_size = sizeof(timb_dma_platform_data),
404 .name = "timb-uart",
405 .num_resources = ARRAY_SIZE(timberdale_uart_resources),
406 .resources = timberdale_uart_resources,
409 .name = "uartlite",
410 .num_resources = ARRAY_SIZE(timberdale_uartlite_resources),
411 .resources = timberdale_uartlite_resources,
414 .name = "xiic-i2c",
415 .num_resources = ARRAY_SIZE(timberdale_xiic_resources),
416 .resources = timberdale_xiic_resources,
417 .platform_data = &timberdale_xiic_platform_data,
418 .data_size = sizeof(timberdale_xiic_platform_data),
421 .name = "timb-gpio",
422 .num_resources = ARRAY_SIZE(timberdale_gpio_resources),
423 .resources = timberdale_gpio_resources,
424 .platform_data = &timberdale_gpio_platform_data,
425 .data_size = sizeof(timberdale_gpio_platform_data),
428 .name = "timb-mlogicore",
429 .num_resources = ARRAY_SIZE(timberdale_mlogicore_resources),
430 .resources = timberdale_mlogicore_resources,
433 .name = "timb-radio",
434 .num_resources = ARRAY_SIZE(timberdale_radio_resources),
435 .resources = timberdale_radio_resources,
436 .platform_data = &timberdale_radio_platform_data,
437 .data_size = sizeof(timberdale_radio_platform_data),
440 .name = "xilinx_spi",
441 .num_resources = ARRAY_SIZE(timberdale_spi_resources),
442 .resources = timberdale_spi_resources,
443 .platform_data = &timberdale_xspi_platform_data,
444 .data_size = sizeof(timberdale_xspi_platform_data),
447 .name = "ks8842",
448 .num_resources = ARRAY_SIZE(timberdale_eth_resources),
449 .resources = timberdale_eth_resources,
453 static __devinitdata struct mfd_cell timberdale_cells_bar0_cfg2[] = {
455 .name = "timb-dma",
456 .num_resources = ARRAY_SIZE(timberdale_dma_resources),
457 .resources = timberdale_dma_resources,
458 .platform_data = &timb_dma_platform_data,
459 .data_size = sizeof(timb_dma_platform_data),
462 .name = "timb-uart",
463 .num_resources = ARRAY_SIZE(timberdale_uart_resources),
464 .resources = timberdale_uart_resources,
467 .name = "xiic-i2c",
468 .num_resources = ARRAY_SIZE(timberdale_xiic_resources),
469 .resources = timberdale_xiic_resources,
470 .platform_data = &timberdale_xiic_platform_data,
471 .data_size = sizeof(timberdale_xiic_platform_data),
474 .name = "timb-gpio",
475 .num_resources = ARRAY_SIZE(timberdale_gpio_resources),
476 .resources = timberdale_gpio_resources,
477 .platform_data = &timberdale_gpio_platform_data,
478 .data_size = sizeof(timberdale_gpio_platform_data),
481 .name = "timb-radio",
482 .num_resources = ARRAY_SIZE(timberdale_radio_resources),
483 .resources = timberdale_radio_resources,
484 .platform_data = &timberdale_radio_platform_data,
485 .data_size = sizeof(timberdale_radio_platform_data),
488 .name = "xilinx_spi",
489 .num_resources = ARRAY_SIZE(timberdale_spi_resources),
490 .resources = timberdale_spi_resources,
491 .platform_data = &timberdale_xspi_platform_data,
492 .data_size = sizeof(timberdale_xspi_platform_data),
496 static __devinitdata struct mfd_cell timberdale_cells_bar0_cfg3[] = {
498 .name = "timb-dma",
499 .num_resources = ARRAY_SIZE(timberdale_dma_resources),
500 .resources = timberdale_dma_resources,
501 .platform_data = &timb_dma_platform_data,
502 .data_size = sizeof(timb_dma_platform_data),
505 .name = "timb-uart",
506 .num_resources = ARRAY_SIZE(timberdale_uart_resources),
507 .resources = timberdale_uart_resources,
510 .name = "ocores-i2c",
511 .num_resources = ARRAY_SIZE(timberdale_ocores_resources),
512 .resources = timberdale_ocores_resources,
513 .platform_data = &timberdale_ocores_platform_data,
514 .data_size = sizeof(timberdale_ocores_platform_data),
517 .name = "timb-gpio",
518 .num_resources = ARRAY_SIZE(timberdale_gpio_resources),
519 .resources = timberdale_gpio_resources,
520 .platform_data = &timberdale_gpio_platform_data,
521 .data_size = sizeof(timberdale_gpio_platform_data),
524 .name = "timb-radio",
525 .num_resources = ARRAY_SIZE(timberdale_radio_resources),
526 .resources = timberdale_radio_resources,
527 .platform_data = &timberdale_radio_platform_data,
528 .data_size = sizeof(timberdale_radio_platform_data),
531 .name = "xilinx_spi",
532 .num_resources = ARRAY_SIZE(timberdale_spi_resources),
533 .resources = timberdale_spi_resources,
534 .platform_data = &timberdale_xspi_platform_data,
535 .data_size = sizeof(timberdale_xspi_platform_data),
538 .name = "ks8842",
539 .num_resources = ARRAY_SIZE(timberdale_eth_resources),
540 .resources = timberdale_eth_resources,
544 static const __devinitconst struct resource timberdale_sdhc_resources[] = {
545 /* located in bar 1 and bar 2 */
547 .start = SDHC0OFFSET,
548 .end = SDHC0END,
549 .flags = IORESOURCE_MEM,
552 .start = IRQ_TIMBERDALE_SDHC,
553 .end = IRQ_TIMBERDALE_SDHC,
554 .flags = IORESOURCE_IRQ,
558 static __devinitdata struct mfd_cell timberdale_cells_bar1[] = {
560 .name = "sdhci",
561 .num_resources = ARRAY_SIZE(timberdale_sdhc_resources),
562 .resources = timberdale_sdhc_resources,
566 static __devinitdata struct mfd_cell timberdale_cells_bar2[] = {
568 .name = "sdhci",
569 .num_resources = ARRAY_SIZE(timberdale_sdhc_resources),
570 .resources = timberdale_sdhc_resources,
574 static ssize_t show_fw_ver(struct device *dev, struct device_attribute *attr,
575 char *buf)
577 struct pci_dev *pdev = to_pci_dev(dev);
578 struct timberdale_device *priv = pci_get_drvdata(pdev);
580 return sprintf(buf, "%d.%d.%d\n", priv->fw.major, priv->fw.minor,
581 priv->fw.config);
584 static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL);
586 /*--------------------------------------------------------------------------*/
588 static int __devinit timb_probe(struct pci_dev *dev,
589 const struct pci_device_id *id)
591 struct timberdale_device *priv;
592 int err, i;
593 resource_size_t mapbase;
594 struct msix_entry *msix_entries = NULL;
595 u8 ip_setup;
597 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
598 if (!priv)
599 return -ENOMEM;
601 pci_set_drvdata(dev, priv);
603 err = pci_enable_device(dev);
604 if (err)
605 goto err_enable;
607 mapbase = pci_resource_start(dev, 0);
608 if (!mapbase) {
609 dev_err(&dev->dev, "No resource\n");
610 goto err_start;
613 /* create a resource for the PCI master register */
614 priv->ctl_mapbase = mapbase + CHIPCTLOFFSET;
615 if (!request_mem_region(priv->ctl_mapbase, CHIPCTLSIZE, "timb-ctl")) {
616 dev_err(&dev->dev, "Failed to request ctl mem\n");
617 goto err_request;
620 priv->ctl_membase = ioremap(priv->ctl_mapbase, CHIPCTLSIZE);
621 if (!priv->ctl_membase) {
622 dev_err(&dev->dev, "ioremap failed for ctl mem\n");
623 goto err_ioremap;
626 /* read the HW config */
627 priv->fw.major = ioread32(priv->ctl_membase + TIMB_REV_MAJOR);
628 priv->fw.minor = ioread32(priv->ctl_membase + TIMB_REV_MINOR);
629 priv->fw.config = ioread32(priv->ctl_membase + TIMB_HW_CONFIG);
631 if (priv->fw.major > TIMB_SUPPORTED_MAJOR) {
632 dev_err(&dev->dev, "The driver supports an older "
633 "version of the FPGA, please update the driver to "
634 "support %d.%d\n", priv->fw.major, priv->fw.minor);
635 goto err_ioremap;
637 if (priv->fw.major < TIMB_SUPPORTED_MAJOR ||
638 priv->fw.minor < TIMB_REQUIRED_MINOR) {
639 dev_err(&dev->dev, "The FPGA image is too old (%d.%d), "
640 "please upgrade the FPGA to at least: %d.%d\n",
641 priv->fw.major, priv->fw.minor,
642 TIMB_SUPPORTED_MAJOR, TIMB_REQUIRED_MINOR);
643 goto err_ioremap;
646 msix_entries = kzalloc(TIMBERDALE_NR_IRQS * sizeof(*msix_entries),
647 GFP_KERNEL);
648 if (!msix_entries)
649 goto err_ioremap;
651 for (i = 0; i < TIMBERDALE_NR_IRQS; i++)
652 msix_entries[i].entry = i;
654 err = pci_enable_msix(dev, msix_entries, TIMBERDALE_NR_IRQS);
655 if (err) {
656 dev_err(&dev->dev,
657 "MSI-X init failed: %d, expected entries: %d\n",
658 err, TIMBERDALE_NR_IRQS);
659 goto err_msix;
662 err = device_create_file(&dev->dev, &dev_attr_fw_ver);
663 if (err)
664 goto err_create_file;
666 /* Reset all FPGA PLB peripherals */
667 iowrite32(0x1, priv->ctl_membase + TIMB_SW_RST);
669 /* update IRQ offsets in I2C board info */
670 for (i = 0; i < ARRAY_SIZE(timberdale_i2c_board_info); i++)
671 timberdale_i2c_board_info[i].irq =
672 msix_entries[timberdale_i2c_board_info[i].irq].vector;
674 /* Update the SPI configuration depending on the HW (8 or 16 bit) */
675 if (priv->fw.config & TIMB_HW_CONFIG_SPI_8BIT) {
676 timberdale_xspi_platform_data.bits_per_word = 8;
677 timberdale_xspi_platform_data.devices =
678 timberdale_spi_8bit_board_info;
679 timberdale_xspi_platform_data.num_devices =
680 ARRAY_SIZE(timberdale_spi_8bit_board_info);
681 } else {
682 timberdale_xspi_platform_data.bits_per_word = 16;
683 timberdale_xspi_platform_data.devices =
684 timberdale_spi_16bit_board_info;
685 timberdale_xspi_platform_data.num_devices =
686 ARRAY_SIZE(timberdale_spi_16bit_board_info);
689 ip_setup = priv->fw.config & TIMB_HW_VER_MASK;
690 switch (ip_setup) {
691 case TIMB_HW_VER0:
692 err = mfd_add_devices(&dev->dev, -1,
693 timberdale_cells_bar0_cfg0,
694 ARRAY_SIZE(timberdale_cells_bar0_cfg0),
695 &dev->resource[0], msix_entries[0].vector);
696 break;
697 case TIMB_HW_VER1:
698 err = mfd_add_devices(&dev->dev, -1,
699 timberdale_cells_bar0_cfg1,
700 ARRAY_SIZE(timberdale_cells_bar0_cfg1),
701 &dev->resource[0], msix_entries[0].vector);
702 break;
703 case TIMB_HW_VER2:
704 err = mfd_add_devices(&dev->dev, -1,
705 timberdale_cells_bar0_cfg2,
706 ARRAY_SIZE(timberdale_cells_bar0_cfg2),
707 &dev->resource[0], msix_entries[0].vector);
708 break;
709 case TIMB_HW_VER3:
710 err = mfd_add_devices(&dev->dev, -1,
711 timberdale_cells_bar0_cfg3,
712 ARRAY_SIZE(timberdale_cells_bar0_cfg3),
713 &dev->resource[0], msix_entries[0].vector);
714 break;
715 default:
716 dev_err(&dev->dev, "Uknown IP setup: %d.%d.%d\n",
717 priv->fw.major, priv->fw.minor, ip_setup);
718 err = -ENODEV;
719 goto err_mfd;
720 break;
723 if (err) {
724 dev_err(&dev->dev, "mfd_add_devices failed: %d\n", err);
725 goto err_mfd;
728 err = mfd_add_devices(&dev->dev, 0,
729 timberdale_cells_bar1, ARRAY_SIZE(timberdale_cells_bar1),
730 &dev->resource[1], msix_entries[0].vector);
731 if (err) {
732 dev_err(&dev->dev, "mfd_add_devices failed: %d\n", err);
733 goto err_mfd2;
736 /* only version 0 and 3 have the iNand routed to SDHCI */
737 if (((priv->fw.config & TIMB_HW_VER_MASK) == TIMB_HW_VER0) ||
738 ((priv->fw.config & TIMB_HW_VER_MASK) == TIMB_HW_VER3)) {
739 err = mfd_add_devices(&dev->dev, 1, timberdale_cells_bar2,
740 ARRAY_SIZE(timberdale_cells_bar2),
741 &dev->resource[2], msix_entries[0].vector);
742 if (err) {
743 dev_err(&dev->dev, "mfd_add_devices failed: %d\n", err);
744 goto err_mfd2;
748 kfree(msix_entries);
750 dev_info(&dev->dev,
751 "Found Timberdale Card. Rev: %d.%d, HW config: 0x%02x\n",
752 priv->fw.major, priv->fw.minor, priv->fw.config);
754 return 0;
756 err_mfd2:
757 mfd_remove_devices(&dev->dev);
758 err_mfd:
759 device_remove_file(&dev->dev, &dev_attr_fw_ver);
760 err_create_file:
761 pci_disable_msix(dev);
762 err_msix:
763 iounmap(priv->ctl_membase);
764 err_ioremap:
765 release_mem_region(priv->ctl_mapbase, CHIPCTLSIZE);
766 err_request:
767 pci_set_drvdata(dev, NULL);
768 err_start:
769 pci_disable_device(dev);
770 err_enable:
771 kfree(msix_entries);
772 kfree(priv);
773 pci_set_drvdata(dev, NULL);
774 return -ENODEV;
777 static void __devexit timb_remove(struct pci_dev *dev)
779 struct timberdale_device *priv = pci_get_drvdata(dev);
781 mfd_remove_devices(&dev->dev);
783 device_remove_file(&dev->dev, &dev_attr_fw_ver);
785 iounmap(priv->ctl_membase);
786 release_mem_region(priv->ctl_mapbase, CHIPCTLSIZE);
788 pci_disable_msix(dev);
789 pci_disable_device(dev);
790 pci_set_drvdata(dev, NULL);
791 kfree(priv);
794 static struct pci_device_id timberdale_pci_tbl[] = {
795 { PCI_DEVICE(PCI_VENDOR_ID_TIMB, PCI_DEVICE_ID_TIMB) },
796 { 0 }
798 MODULE_DEVICE_TABLE(pci, timberdale_pci_tbl);
800 static struct pci_driver timberdale_pci_driver = {
801 .name = DRIVER_NAME,
802 .id_table = timberdale_pci_tbl,
803 .probe = timb_probe,
804 .remove = __devexit_p(timb_remove),
807 static int __init timberdale_init(void)
809 int err;
811 err = pci_register_driver(&timberdale_pci_driver);
812 if (err < 0) {
813 printk(KERN_ERR
814 "Failed to register PCI driver for %s device.\n",
815 timberdale_pci_driver.name);
816 return -ENODEV;
819 printk(KERN_INFO "Driver for %s has been successfully registered.\n",
820 timberdale_pci_driver.name);
822 return 0;
825 static void __exit timberdale_exit(void)
827 pci_unregister_driver(&timberdale_pci_driver);
829 printk(KERN_INFO "Driver for %s has been successfully unregistered.\n",
830 timberdale_pci_driver.name);
833 module_init(timberdale_init);
834 module_exit(timberdale_exit);
836 MODULE_AUTHOR("Mocean Laboratories <info@mocean-labs.com>");
837 MODULE_VERSION(DRV_VERSION);
838 MODULE_LICENSE("GPL v2");