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.
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>
43 #include <media/timb_video.h>
45 #include <linux/timb_dma.h>
47 #include <linux/ks8842.h>
49 #include "timberdale.h"
51 #define DRIVER_NAME "timberdale"
53 struct timberdale_device
{
54 resource_size_t ctl_mapbase
;
55 unsigned char __iomem
*ctl_membase
;
63 /*--------------------------------------------------------------------------*/
65 static struct tsc2007_platform_data timberdale_tsc2007_platform_data
= {
70 static struct i2c_board_info timberdale_i2c_board_info
[] = {
72 I2C_BOARD_INFO("tsc2007", 0x48),
73 .platform_data
= &timberdale_tsc2007_platform_data
,
74 .irq
= IRQ_TIMBERDALE_TSC_INT
78 static __devinitdata
struct xiic_i2c_platform_data
79 timberdale_xiic_platform_data
= {
80 .devices
= timberdale_i2c_board_info
,
81 .num_devices
= ARRAY_SIZE(timberdale_i2c_board_info
)
84 static __devinitdata
struct ocores_i2c_platform_data
85 timberdale_ocores_platform_data
= {
88 .devices
= timberdale_i2c_board_info
,
89 .num_devices
= ARRAY_SIZE(timberdale_i2c_board_info
)
92 static const __devinitconst
struct resource timberdale_xiic_resources
[] = {
96 .flags
= IORESOURCE_MEM
,
99 .start
= IRQ_TIMBERDALE_I2C
,
100 .end
= IRQ_TIMBERDALE_I2C
,
101 .flags
= IORESOURCE_IRQ
,
105 static const __devinitconst
struct resource timberdale_ocores_resources
[] = {
107 .start
= OCORESOFFSET
,
109 .flags
= IORESOURCE_MEM
,
112 .start
= IRQ_TIMBERDALE_I2C
,
113 .end
= IRQ_TIMBERDALE_I2C
,
114 .flags
= IORESOURCE_IRQ
,
118 const struct max7301_platform_data timberdale_max7301_platform_data
= {
122 const struct mc33880_platform_data timberdale_mc33880_platform_data
= {
126 static struct spi_board_info timberdale_spi_16bit_board_info
[] = {
128 .modalias
= "max7301",
129 .max_speed_hz
= 26000,
132 .platform_data
= &timberdale_max7301_platform_data
136 static struct spi_board_info timberdale_spi_8bit_board_info
[] = {
138 .modalias
= "mc33880",
139 .max_speed_hz
= 4000,
142 .platform_data
= &timberdale_mc33880_platform_data
146 static __devinitdata
struct xspi_platform_data timberdale_xspi_platform_data
= {
148 .little_endian
= true,
149 /* bits per word and devices will be filled in runtime depending
154 static const __devinitconst
struct resource timberdale_spi_resources
[] = {
158 .flags
= IORESOURCE_MEM
,
161 .start
= IRQ_TIMBERDALE_SPI
,
162 .end
= IRQ_TIMBERDALE_SPI
,
163 .flags
= IORESOURCE_IRQ
,
167 static __devinitdata
struct ks8842_platform_data
168 timberdale_ks8842_platform_data
= {
169 .rx_dma_channel
= DMA_ETH_RX
,
170 .tx_dma_channel
= DMA_ETH_TX
173 static const __devinitconst
struct resource timberdale_eth_resources
[] = {
177 .flags
= IORESOURCE_MEM
,
180 .start
= IRQ_TIMBERDALE_ETHSW_IF
,
181 .end
= IRQ_TIMBERDALE_ETHSW_IF
,
182 .flags
= IORESOURCE_IRQ
,
186 static __devinitdata
struct timbgpio_platform_data
187 timberdale_gpio_platform_data
= {
189 .nr_pins
= GPIO_NR_PINS
,
193 static const __devinitconst
struct resource timberdale_gpio_resources
[] = {
197 .flags
= IORESOURCE_MEM
,
200 .start
= IRQ_TIMBERDALE_GPIO
,
201 .end
= IRQ_TIMBERDALE_GPIO
,
202 .flags
= IORESOURCE_IRQ
,
206 static const __devinitconst
struct resource timberdale_mlogicore_resources
[] = {
208 .start
= MLCOREOFFSET
,
210 .flags
= IORESOURCE_MEM
,
213 .start
= IRQ_TIMBERDALE_MLCORE
,
214 .end
= IRQ_TIMBERDALE_MLCORE
,
215 .flags
= IORESOURCE_IRQ
,
218 .start
= IRQ_TIMBERDALE_MLCORE_BUF
,
219 .end
= IRQ_TIMBERDALE_MLCORE_BUF
,
220 .flags
= IORESOURCE_IRQ
,
224 static const __devinitconst
struct resource timberdale_uart_resources
[] = {
228 .flags
= IORESOURCE_MEM
,
231 .start
= IRQ_TIMBERDALE_UART
,
232 .end
= IRQ_TIMBERDALE_UART
,
233 .flags
= IORESOURCE_IRQ
,
237 static const __devinitconst
struct resource timberdale_uartlite_resources
[] = {
239 .start
= UARTLITEOFFSET
,
241 .flags
= IORESOURCE_MEM
,
244 .start
= IRQ_TIMBERDALE_UARTLITE
,
245 .end
= IRQ_TIMBERDALE_UARTLITE
,
246 .flags
= IORESOURCE_IRQ
,
250 static __devinitdata
struct i2c_board_info timberdale_adv7180_i2c_board_info
= {
251 /* Requires jumper JP9 to be off */
252 I2C_BOARD_INFO("adv7180", 0x42 >> 1),
253 .irq
= IRQ_TIMBERDALE_ADV7180
256 static __devinitdata
struct timb_video_platform_data
257 timberdale_video_platform_data
= {
258 .dma_channel
= DMA_VIDEO_RX
,
261 .info
= &timberdale_adv7180_i2c_board_info
265 static const __devinitconst
struct resource
266 timberdale_radio_resources
[] = {
270 .flags
= IORESOURCE_MEM
,
273 .start
= IRQ_TIMBERDALE_RDS
,
274 .end
= IRQ_TIMBERDALE_RDS
,
275 .flags
= IORESOURCE_IRQ
,
279 static __devinitdata
struct i2c_board_info timberdale_tef6868_i2c_board_info
= {
280 I2C_BOARD_INFO("tef6862", 0x60)
283 static __devinitdata
struct i2c_board_info timberdale_saa7706_i2c_board_info
= {
284 I2C_BOARD_INFO("saa7706h", 0x1C)
287 static __devinitdata
struct timb_radio_platform_data
288 timberdale_radio_platform_data
= {
290 .tuner
= &timberdale_tef6868_i2c_board_info
,
291 .dsp
= &timberdale_saa7706_i2c_board_info
294 static const __devinitconst
struct resource timberdale_video_resources
[] = {
296 .start
= LOGIWOFFSET
,
298 .flags
= IORESOURCE_MEM
,
301 note that the "frame buffer" is located in DMA area
302 starting at 0x1200000
306 static __devinitdata
struct timb_dma_platform_data timb_dma_platform_data
= {
313 .descriptor_elements
= 1
319 .descriptor_elements
= 1
325 .descriptor_elements
= 1
331 .descriptor_elements
= 1
336 .bytes_per_line
= 1440,
338 .descriptor_elements
= 16
341 /* Video framedrop */
354 .descriptor_elements
= 1
360 .descriptor_elements
= 1
365 static const __devinitconst
struct resource timberdale_dma_resources
[] = {
369 .flags
= IORESOURCE_MEM
,
372 .start
= IRQ_TIMBERDALE_DMA
,
373 .end
= IRQ_TIMBERDALE_DMA
,
374 .flags
= IORESOURCE_IRQ
,
378 static __devinitdata
struct mfd_cell timberdale_cells_bar0_cfg0
[] = {
381 .num_resources
= ARRAY_SIZE(timberdale_dma_resources
),
382 .resources
= timberdale_dma_resources
,
383 .platform_data
= &timb_dma_platform_data
,
384 .pdata_size
= sizeof(timb_dma_platform_data
),
388 .num_resources
= ARRAY_SIZE(timberdale_uart_resources
),
389 .resources
= timberdale_uart_resources
,
393 .num_resources
= ARRAY_SIZE(timberdale_xiic_resources
),
394 .resources
= timberdale_xiic_resources
,
395 .platform_data
= &timberdale_xiic_platform_data
,
396 .pdata_size
= sizeof(timberdale_xiic_platform_data
),
400 .num_resources
= ARRAY_SIZE(timberdale_gpio_resources
),
401 .resources
= timberdale_gpio_resources
,
402 .platform_data
= &timberdale_gpio_platform_data
,
403 .pdata_size
= sizeof(timberdale_gpio_platform_data
),
406 .name
= "timb-video",
407 .num_resources
= ARRAY_SIZE(timberdale_video_resources
),
408 .resources
= timberdale_video_resources
,
409 .platform_data
= &timberdale_video_platform_data
,
410 .pdata_size
= sizeof(timberdale_video_platform_data
),
413 .name
= "timb-radio",
414 .num_resources
= ARRAY_SIZE(timberdale_radio_resources
),
415 .resources
= timberdale_radio_resources
,
416 .platform_data
= &timberdale_radio_platform_data
,
417 .pdata_size
= sizeof(timberdale_radio_platform_data
),
420 .name
= "xilinx_spi",
421 .num_resources
= ARRAY_SIZE(timberdale_spi_resources
),
422 .resources
= timberdale_spi_resources
,
423 .platform_data
= &timberdale_xspi_platform_data
,
424 .pdata_size
= sizeof(timberdale_xspi_platform_data
),
428 .num_resources
= ARRAY_SIZE(timberdale_eth_resources
),
429 .resources
= timberdale_eth_resources
,
430 .platform_data
= &timberdale_ks8842_platform_data
,
431 .pdata_size
= sizeof(timberdale_ks8842_platform_data
),
435 static __devinitdata
struct mfd_cell timberdale_cells_bar0_cfg1
[] = {
438 .num_resources
= ARRAY_SIZE(timberdale_dma_resources
),
439 .resources
= timberdale_dma_resources
,
440 .platform_data
= &timb_dma_platform_data
,
441 .pdata_size
= sizeof(timb_dma_platform_data
),
445 .num_resources
= ARRAY_SIZE(timberdale_uart_resources
),
446 .resources
= timberdale_uart_resources
,
450 .num_resources
= ARRAY_SIZE(timberdale_uartlite_resources
),
451 .resources
= timberdale_uartlite_resources
,
455 .num_resources
= ARRAY_SIZE(timberdale_xiic_resources
),
456 .resources
= timberdale_xiic_resources
,
457 .platform_data
= &timberdale_xiic_platform_data
,
458 .pdata_size
= sizeof(timberdale_xiic_platform_data
),
462 .num_resources
= ARRAY_SIZE(timberdale_gpio_resources
),
463 .resources
= timberdale_gpio_resources
,
464 .platform_data
= &timberdale_gpio_platform_data
,
465 .pdata_size
= sizeof(timberdale_gpio_platform_data
),
468 .name
= "timb-mlogicore",
469 .num_resources
= ARRAY_SIZE(timberdale_mlogicore_resources
),
470 .resources
= timberdale_mlogicore_resources
,
473 .name
= "timb-video",
474 .num_resources
= ARRAY_SIZE(timberdale_video_resources
),
475 .resources
= timberdale_video_resources
,
476 .platform_data
= &timberdale_video_platform_data
,
477 .pdata_size
= sizeof(timberdale_video_platform_data
),
480 .name
= "timb-radio",
481 .num_resources
= ARRAY_SIZE(timberdale_radio_resources
),
482 .resources
= timberdale_radio_resources
,
483 .platform_data
= &timberdale_radio_platform_data
,
484 .pdata_size
= sizeof(timberdale_radio_platform_data
),
487 .name
= "xilinx_spi",
488 .num_resources
= ARRAY_SIZE(timberdale_spi_resources
),
489 .resources
= timberdale_spi_resources
,
490 .platform_data
= &timberdale_xspi_platform_data
,
491 .pdata_size
= sizeof(timberdale_xspi_platform_data
),
495 .num_resources
= ARRAY_SIZE(timberdale_eth_resources
),
496 .resources
= timberdale_eth_resources
,
497 .platform_data
= &timberdale_ks8842_platform_data
,
498 .pdata_size
= sizeof(timberdale_ks8842_platform_data
),
502 static __devinitdata
struct mfd_cell timberdale_cells_bar0_cfg2
[] = {
505 .num_resources
= ARRAY_SIZE(timberdale_dma_resources
),
506 .resources
= timberdale_dma_resources
,
507 .platform_data
= &timb_dma_platform_data
,
508 .pdata_size
= sizeof(timb_dma_platform_data
),
512 .num_resources
= ARRAY_SIZE(timberdale_uart_resources
),
513 .resources
= timberdale_uart_resources
,
517 .num_resources
= ARRAY_SIZE(timberdale_xiic_resources
),
518 .resources
= timberdale_xiic_resources
,
519 .platform_data
= &timberdale_xiic_platform_data
,
520 .pdata_size
= sizeof(timberdale_xiic_platform_data
),
524 .num_resources
= ARRAY_SIZE(timberdale_gpio_resources
),
525 .resources
= timberdale_gpio_resources
,
526 .platform_data
= &timberdale_gpio_platform_data
,
527 .pdata_size
= sizeof(timberdale_gpio_platform_data
),
530 .name
= "timb-video",
531 .num_resources
= ARRAY_SIZE(timberdale_video_resources
),
532 .resources
= timberdale_video_resources
,
533 .platform_data
= &timberdale_video_platform_data
,
534 .pdata_size
= sizeof(timberdale_video_platform_data
),
537 .name
= "timb-radio",
538 .num_resources
= ARRAY_SIZE(timberdale_radio_resources
),
539 .resources
= timberdale_radio_resources
,
540 .platform_data
= &timberdale_radio_platform_data
,
541 .pdata_size
= sizeof(timberdale_radio_platform_data
),
544 .name
= "xilinx_spi",
545 .num_resources
= ARRAY_SIZE(timberdale_spi_resources
),
546 .resources
= timberdale_spi_resources
,
547 .platform_data
= &timberdale_xspi_platform_data
,
548 .pdata_size
= sizeof(timberdale_xspi_platform_data
),
552 static __devinitdata
struct mfd_cell timberdale_cells_bar0_cfg3
[] = {
555 .num_resources
= ARRAY_SIZE(timberdale_dma_resources
),
556 .resources
= timberdale_dma_resources
,
557 .platform_data
= &timb_dma_platform_data
,
558 .pdata_size
= sizeof(timb_dma_platform_data
),
562 .num_resources
= ARRAY_SIZE(timberdale_uart_resources
),
563 .resources
= timberdale_uart_resources
,
566 .name
= "ocores-i2c",
567 .num_resources
= ARRAY_SIZE(timberdale_ocores_resources
),
568 .resources
= timberdale_ocores_resources
,
569 .platform_data
= &timberdale_ocores_platform_data
,
570 .pdata_size
= sizeof(timberdale_ocores_platform_data
),
574 .num_resources
= ARRAY_SIZE(timberdale_gpio_resources
),
575 .resources
= timberdale_gpio_resources
,
576 .platform_data
= &timberdale_gpio_platform_data
,
577 .pdata_size
= sizeof(timberdale_gpio_platform_data
),
580 .name
= "timb-video",
581 .num_resources
= ARRAY_SIZE(timberdale_video_resources
),
582 .resources
= timberdale_video_resources
,
583 .platform_data
= &timberdale_video_platform_data
,
584 .pdata_size
= sizeof(timberdale_video_platform_data
),
587 .name
= "timb-radio",
588 .num_resources
= ARRAY_SIZE(timberdale_radio_resources
),
589 .resources
= timberdale_radio_resources
,
590 .platform_data
= &timberdale_radio_platform_data
,
591 .pdata_size
= sizeof(timberdale_radio_platform_data
),
594 .name
= "xilinx_spi",
595 .num_resources
= ARRAY_SIZE(timberdale_spi_resources
),
596 .resources
= timberdale_spi_resources
,
597 .platform_data
= &timberdale_xspi_platform_data
,
598 .pdata_size
= sizeof(timberdale_xspi_platform_data
),
602 .num_resources
= ARRAY_SIZE(timberdale_eth_resources
),
603 .resources
= timberdale_eth_resources
,
604 .platform_data
= &timberdale_ks8842_platform_data
,
605 .pdata_size
= sizeof(timberdale_ks8842_platform_data
),
609 static const __devinitconst
struct resource timberdale_sdhc_resources
[] = {
610 /* located in bar 1 and bar 2 */
612 .start
= SDHC0OFFSET
,
614 .flags
= IORESOURCE_MEM
,
617 .start
= IRQ_TIMBERDALE_SDHC
,
618 .end
= IRQ_TIMBERDALE_SDHC
,
619 .flags
= IORESOURCE_IRQ
,
623 static __devinitdata
struct mfd_cell timberdale_cells_bar1
[] = {
626 .num_resources
= ARRAY_SIZE(timberdale_sdhc_resources
),
627 .resources
= timberdale_sdhc_resources
,
631 static __devinitdata
struct mfd_cell timberdale_cells_bar2
[] = {
634 .num_resources
= ARRAY_SIZE(timberdale_sdhc_resources
),
635 .resources
= timberdale_sdhc_resources
,
639 static ssize_t
show_fw_ver(struct device
*dev
, struct device_attribute
*attr
,
642 struct pci_dev
*pdev
= to_pci_dev(dev
);
643 struct timberdale_device
*priv
= pci_get_drvdata(pdev
);
645 return sprintf(buf
, "%d.%d.%d\n", priv
->fw
.major
, priv
->fw
.minor
,
649 static DEVICE_ATTR(fw_ver
, S_IRUGO
, show_fw_ver
, NULL
);
651 /*--------------------------------------------------------------------------*/
653 static int __devinit
timb_probe(struct pci_dev
*dev
,
654 const struct pci_device_id
*id
)
656 struct timberdale_device
*priv
;
658 resource_size_t mapbase
;
659 struct msix_entry
*msix_entries
= NULL
;
662 priv
= kzalloc(sizeof(*priv
), GFP_KERNEL
);
666 pci_set_drvdata(dev
, priv
);
668 err
= pci_enable_device(dev
);
672 mapbase
= pci_resource_start(dev
, 0);
674 dev_err(&dev
->dev
, "No resource\n");
678 /* create a resource for the PCI master register */
679 priv
->ctl_mapbase
= mapbase
+ CHIPCTLOFFSET
;
680 if (!request_mem_region(priv
->ctl_mapbase
, CHIPCTLSIZE
, "timb-ctl")) {
681 dev_err(&dev
->dev
, "Failed to request ctl mem\n");
685 priv
->ctl_membase
= ioremap(priv
->ctl_mapbase
, CHIPCTLSIZE
);
686 if (!priv
->ctl_membase
) {
687 dev_err(&dev
->dev
, "ioremap failed for ctl mem\n");
691 /* read the HW config */
692 priv
->fw
.major
= ioread32(priv
->ctl_membase
+ TIMB_REV_MAJOR
);
693 priv
->fw
.minor
= ioread32(priv
->ctl_membase
+ TIMB_REV_MINOR
);
694 priv
->fw
.config
= ioread32(priv
->ctl_membase
+ TIMB_HW_CONFIG
);
696 if (priv
->fw
.major
> TIMB_SUPPORTED_MAJOR
) {
697 dev_err(&dev
->dev
, "The driver supports an older "
698 "version of the FPGA, please update the driver to "
699 "support %d.%d\n", priv
->fw
.major
, priv
->fw
.minor
);
702 if (priv
->fw
.major
< TIMB_SUPPORTED_MAJOR
||
703 priv
->fw
.minor
< TIMB_REQUIRED_MINOR
) {
704 dev_err(&dev
->dev
, "The FPGA image is too old (%d.%d), "
705 "please upgrade the FPGA to at least: %d.%d\n",
706 priv
->fw
.major
, priv
->fw
.minor
,
707 TIMB_SUPPORTED_MAJOR
, TIMB_REQUIRED_MINOR
);
711 msix_entries
= kzalloc(TIMBERDALE_NR_IRQS
* sizeof(*msix_entries
),
716 for (i
= 0; i
< TIMBERDALE_NR_IRQS
; i
++)
717 msix_entries
[i
].entry
= i
;
719 err
= pci_enable_msix(dev
, msix_entries
, TIMBERDALE_NR_IRQS
);
722 "MSI-X init failed: %d, expected entries: %d\n",
723 err
, TIMBERDALE_NR_IRQS
);
727 err
= device_create_file(&dev
->dev
, &dev_attr_fw_ver
);
729 goto err_create_file
;
731 /* Reset all FPGA PLB peripherals */
732 iowrite32(0x1, priv
->ctl_membase
+ TIMB_SW_RST
);
734 /* update IRQ offsets in I2C board info */
735 for (i
= 0; i
< ARRAY_SIZE(timberdale_i2c_board_info
); i
++)
736 timberdale_i2c_board_info
[i
].irq
=
737 msix_entries
[timberdale_i2c_board_info
[i
].irq
].vector
;
739 /* Update the SPI configuration depending on the HW (8 or 16 bit) */
740 if (priv
->fw
.config
& TIMB_HW_CONFIG_SPI_8BIT
) {
741 timberdale_xspi_platform_data
.bits_per_word
= 8;
742 timberdale_xspi_platform_data
.devices
=
743 timberdale_spi_8bit_board_info
;
744 timberdale_xspi_platform_data
.num_devices
=
745 ARRAY_SIZE(timberdale_spi_8bit_board_info
);
747 timberdale_xspi_platform_data
.bits_per_word
= 16;
748 timberdale_xspi_platform_data
.devices
=
749 timberdale_spi_16bit_board_info
;
750 timberdale_xspi_platform_data
.num_devices
=
751 ARRAY_SIZE(timberdale_spi_16bit_board_info
);
754 ip_setup
= priv
->fw
.config
& TIMB_HW_VER_MASK
;
757 err
= mfd_add_devices(&dev
->dev
, -1,
758 timberdale_cells_bar0_cfg0
,
759 ARRAY_SIZE(timberdale_cells_bar0_cfg0
),
760 &dev
->resource
[0], msix_entries
[0].vector
);
763 err
= mfd_add_devices(&dev
->dev
, -1,
764 timberdale_cells_bar0_cfg1
,
765 ARRAY_SIZE(timberdale_cells_bar0_cfg1
),
766 &dev
->resource
[0], msix_entries
[0].vector
);
769 err
= mfd_add_devices(&dev
->dev
, -1,
770 timberdale_cells_bar0_cfg2
,
771 ARRAY_SIZE(timberdale_cells_bar0_cfg2
),
772 &dev
->resource
[0], msix_entries
[0].vector
);
775 err
= mfd_add_devices(&dev
->dev
, -1,
776 timberdale_cells_bar0_cfg3
,
777 ARRAY_SIZE(timberdale_cells_bar0_cfg3
),
778 &dev
->resource
[0], msix_entries
[0].vector
);
781 dev_err(&dev
->dev
, "Uknown IP setup: %d.%d.%d\n",
782 priv
->fw
.major
, priv
->fw
.minor
, ip_setup
);
789 dev_err(&dev
->dev
, "mfd_add_devices failed: %d\n", err
);
793 err
= mfd_add_devices(&dev
->dev
, 0,
794 timberdale_cells_bar1
, ARRAY_SIZE(timberdale_cells_bar1
),
795 &dev
->resource
[1], msix_entries
[0].vector
);
797 dev_err(&dev
->dev
, "mfd_add_devices failed: %d\n", err
);
801 /* only version 0 and 3 have the iNand routed to SDHCI */
802 if (((priv
->fw
.config
& TIMB_HW_VER_MASK
) == TIMB_HW_VER0
) ||
803 ((priv
->fw
.config
& TIMB_HW_VER_MASK
) == TIMB_HW_VER3
)) {
804 err
= mfd_add_devices(&dev
->dev
, 1, timberdale_cells_bar2
,
805 ARRAY_SIZE(timberdale_cells_bar2
),
806 &dev
->resource
[2], msix_entries
[0].vector
);
808 dev_err(&dev
->dev
, "mfd_add_devices failed: %d\n", err
);
816 "Found Timberdale Card. Rev: %d.%d, HW config: 0x%02x\n",
817 priv
->fw
.major
, priv
->fw
.minor
, priv
->fw
.config
);
822 mfd_remove_devices(&dev
->dev
);
824 device_remove_file(&dev
->dev
, &dev_attr_fw_ver
);
826 pci_disable_msix(dev
);
830 iounmap(priv
->ctl_membase
);
832 release_mem_region(priv
->ctl_mapbase
, CHIPCTLSIZE
);
834 pci_set_drvdata(dev
, NULL
);
836 pci_disable_device(dev
);
839 pci_set_drvdata(dev
, NULL
);
843 static void __devexit
timb_remove(struct pci_dev
*dev
)
845 struct timberdale_device
*priv
= pci_get_drvdata(dev
);
847 mfd_remove_devices(&dev
->dev
);
849 device_remove_file(&dev
->dev
, &dev_attr_fw_ver
);
851 iounmap(priv
->ctl_membase
);
852 release_mem_region(priv
->ctl_mapbase
, CHIPCTLSIZE
);
854 pci_disable_msix(dev
);
855 pci_disable_device(dev
);
856 pci_set_drvdata(dev
, NULL
);
860 static struct pci_device_id timberdale_pci_tbl
[] = {
861 { PCI_DEVICE(PCI_VENDOR_ID_TIMB
, PCI_DEVICE_ID_TIMB
) },
864 MODULE_DEVICE_TABLE(pci
, timberdale_pci_tbl
);
866 static struct pci_driver timberdale_pci_driver
= {
868 .id_table
= timberdale_pci_tbl
,
870 .remove
= __devexit_p(timb_remove
),
873 static int __init
timberdale_init(void)
877 err
= pci_register_driver(&timberdale_pci_driver
);
880 "Failed to register PCI driver for %s device.\n",
881 timberdale_pci_driver
.name
);
885 printk(KERN_INFO
"Driver for %s has been successfully registered.\n",
886 timberdale_pci_driver
.name
);
891 static void __exit
timberdale_exit(void)
893 pci_unregister_driver(&timberdale_pci_driver
);
895 printk(KERN_INFO
"Driver for %s has been successfully unregistered.\n",
896 timberdale_pci_driver
.name
);
899 module_init(timberdale_init
);
900 module_exit(timberdale_exit
);
902 MODULE_AUTHOR("Mocean Laboratories <info@mocean-labs.com>");
903 MODULE_VERSION(DRV_VERSION
);
904 MODULE_LICENSE("GPL v2");