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
= {
291 .info
= &timberdale_tef6868_i2c_board_info
294 .info
= &timberdale_saa7706_i2c_board_info
298 static const __devinitconst
struct resource timberdale_video_resources
[] = {
300 .start
= LOGIWOFFSET
,
302 .flags
= IORESOURCE_MEM
,
305 note that the "frame buffer" is located in DMA area
306 starting at 0x1200000
310 static __devinitdata
struct timb_dma_platform_data timb_dma_platform_data
= {
317 .descriptor_elements
= 1
323 .descriptor_elements
= 1
329 .descriptor_elements
= 1
335 .descriptor_elements
= 1
340 .bytes_per_line
= 1440,
342 .descriptor_elements
= 16
345 /* Video framedrop */
358 .descriptor_elements
= 1
364 .descriptor_elements
= 1
369 static const __devinitconst
struct resource timberdale_dma_resources
[] = {
373 .flags
= IORESOURCE_MEM
,
376 .start
= IRQ_TIMBERDALE_DMA
,
377 .end
= IRQ_TIMBERDALE_DMA
,
378 .flags
= IORESOURCE_IRQ
,
382 static __devinitdata
struct mfd_cell timberdale_cells_bar0_cfg0
[] = {
385 .num_resources
= ARRAY_SIZE(timberdale_dma_resources
),
386 .resources
= timberdale_dma_resources
,
387 .platform_data
= &timb_dma_platform_data
,
388 .pdata_size
= sizeof(timb_dma_platform_data
),
392 .num_resources
= ARRAY_SIZE(timberdale_uart_resources
),
393 .resources
= timberdale_uart_resources
,
397 .num_resources
= ARRAY_SIZE(timberdale_xiic_resources
),
398 .resources
= timberdale_xiic_resources
,
399 .platform_data
= &timberdale_xiic_platform_data
,
400 .pdata_size
= sizeof(timberdale_xiic_platform_data
),
404 .num_resources
= ARRAY_SIZE(timberdale_gpio_resources
),
405 .resources
= timberdale_gpio_resources
,
406 .platform_data
= &timberdale_gpio_platform_data
,
407 .pdata_size
= sizeof(timberdale_gpio_platform_data
),
410 .name
= "timb-video",
411 .num_resources
= ARRAY_SIZE(timberdale_video_resources
),
412 .resources
= timberdale_video_resources
,
413 .platform_data
= &timberdale_video_platform_data
,
414 .pdata_size
= sizeof(timberdale_video_platform_data
),
417 .name
= "timb-radio",
418 .num_resources
= ARRAY_SIZE(timberdale_radio_resources
),
419 .resources
= timberdale_radio_resources
,
420 .platform_data
= &timberdale_radio_platform_data
,
421 .pdata_size
= sizeof(timberdale_radio_platform_data
),
424 .name
= "xilinx_spi",
425 .num_resources
= ARRAY_SIZE(timberdale_spi_resources
),
426 .resources
= timberdale_spi_resources
,
427 .platform_data
= &timberdale_xspi_platform_data
,
428 .pdata_size
= sizeof(timberdale_xspi_platform_data
),
432 .num_resources
= ARRAY_SIZE(timberdale_eth_resources
),
433 .resources
= timberdale_eth_resources
,
434 .platform_data
= &timberdale_ks8842_platform_data
,
435 .pdata_size
= sizeof(timberdale_ks8842_platform_data
),
439 static __devinitdata
struct mfd_cell timberdale_cells_bar0_cfg1
[] = {
442 .num_resources
= ARRAY_SIZE(timberdale_dma_resources
),
443 .resources
= timberdale_dma_resources
,
444 .platform_data
= &timb_dma_platform_data
,
445 .pdata_size
= sizeof(timb_dma_platform_data
),
449 .num_resources
= ARRAY_SIZE(timberdale_uart_resources
),
450 .resources
= timberdale_uart_resources
,
454 .num_resources
= ARRAY_SIZE(timberdale_uartlite_resources
),
455 .resources
= timberdale_uartlite_resources
,
459 .num_resources
= ARRAY_SIZE(timberdale_xiic_resources
),
460 .resources
= timberdale_xiic_resources
,
461 .platform_data
= &timberdale_xiic_platform_data
,
462 .pdata_size
= sizeof(timberdale_xiic_platform_data
),
466 .num_resources
= ARRAY_SIZE(timberdale_gpio_resources
),
467 .resources
= timberdale_gpio_resources
,
468 .platform_data
= &timberdale_gpio_platform_data
,
469 .pdata_size
= sizeof(timberdale_gpio_platform_data
),
472 .name
= "timb-mlogicore",
473 .num_resources
= ARRAY_SIZE(timberdale_mlogicore_resources
),
474 .resources
= timberdale_mlogicore_resources
,
477 .name
= "timb-video",
478 .num_resources
= ARRAY_SIZE(timberdale_video_resources
),
479 .resources
= timberdale_video_resources
,
480 .platform_data
= &timberdale_video_platform_data
,
481 .pdata_size
= sizeof(timberdale_video_platform_data
),
484 .name
= "timb-radio",
485 .num_resources
= ARRAY_SIZE(timberdale_radio_resources
),
486 .resources
= timberdale_radio_resources
,
487 .platform_data
= &timberdale_radio_platform_data
,
488 .pdata_size
= sizeof(timberdale_radio_platform_data
),
491 .name
= "xilinx_spi",
492 .num_resources
= ARRAY_SIZE(timberdale_spi_resources
),
493 .resources
= timberdale_spi_resources
,
494 .platform_data
= &timberdale_xspi_platform_data
,
495 .pdata_size
= sizeof(timberdale_xspi_platform_data
),
499 .num_resources
= ARRAY_SIZE(timberdale_eth_resources
),
500 .resources
= timberdale_eth_resources
,
501 .platform_data
= &timberdale_ks8842_platform_data
,
502 .pdata_size
= sizeof(timberdale_ks8842_platform_data
),
506 static __devinitdata
struct mfd_cell timberdale_cells_bar0_cfg2
[] = {
509 .num_resources
= ARRAY_SIZE(timberdale_dma_resources
),
510 .resources
= timberdale_dma_resources
,
511 .platform_data
= &timb_dma_platform_data
,
512 .pdata_size
= sizeof(timb_dma_platform_data
),
516 .num_resources
= ARRAY_SIZE(timberdale_uart_resources
),
517 .resources
= timberdale_uart_resources
,
521 .num_resources
= ARRAY_SIZE(timberdale_xiic_resources
),
522 .resources
= timberdale_xiic_resources
,
523 .platform_data
= &timberdale_xiic_platform_data
,
524 .pdata_size
= sizeof(timberdale_xiic_platform_data
),
528 .num_resources
= ARRAY_SIZE(timberdale_gpio_resources
),
529 .resources
= timberdale_gpio_resources
,
530 .platform_data
= &timberdale_gpio_platform_data
,
531 .pdata_size
= sizeof(timberdale_gpio_platform_data
),
534 .name
= "timb-video",
535 .num_resources
= ARRAY_SIZE(timberdale_video_resources
),
536 .resources
= timberdale_video_resources
,
537 .platform_data
= &timberdale_video_platform_data
,
538 .pdata_size
= sizeof(timberdale_video_platform_data
),
541 .name
= "timb-radio",
542 .num_resources
= ARRAY_SIZE(timberdale_radio_resources
),
543 .resources
= timberdale_radio_resources
,
544 .platform_data
= &timberdale_radio_platform_data
,
545 .pdata_size
= sizeof(timberdale_radio_platform_data
),
548 .name
= "xilinx_spi",
549 .num_resources
= ARRAY_SIZE(timberdale_spi_resources
),
550 .resources
= timberdale_spi_resources
,
551 .platform_data
= &timberdale_xspi_platform_data
,
552 .pdata_size
= sizeof(timberdale_xspi_platform_data
),
556 static __devinitdata
struct mfd_cell timberdale_cells_bar0_cfg3
[] = {
559 .num_resources
= ARRAY_SIZE(timberdale_dma_resources
),
560 .resources
= timberdale_dma_resources
,
561 .platform_data
= &timb_dma_platform_data
,
562 .pdata_size
= sizeof(timb_dma_platform_data
),
566 .num_resources
= ARRAY_SIZE(timberdale_uart_resources
),
567 .resources
= timberdale_uart_resources
,
570 .name
= "ocores-i2c",
571 .num_resources
= ARRAY_SIZE(timberdale_ocores_resources
),
572 .resources
= timberdale_ocores_resources
,
573 .platform_data
= &timberdale_ocores_platform_data
,
574 .pdata_size
= sizeof(timberdale_ocores_platform_data
),
578 .num_resources
= ARRAY_SIZE(timberdale_gpio_resources
),
579 .resources
= timberdale_gpio_resources
,
580 .platform_data
= &timberdale_gpio_platform_data
,
581 .pdata_size
= sizeof(timberdale_gpio_platform_data
),
584 .name
= "timb-video",
585 .num_resources
= ARRAY_SIZE(timberdale_video_resources
),
586 .resources
= timberdale_video_resources
,
587 .platform_data
= &timberdale_video_platform_data
,
588 .pdata_size
= sizeof(timberdale_video_platform_data
),
591 .name
= "timb-radio",
592 .num_resources
= ARRAY_SIZE(timberdale_radio_resources
),
593 .resources
= timberdale_radio_resources
,
594 .platform_data
= &timberdale_radio_platform_data
,
595 .pdata_size
= sizeof(timberdale_radio_platform_data
),
598 .name
= "xilinx_spi",
599 .num_resources
= ARRAY_SIZE(timberdale_spi_resources
),
600 .resources
= timberdale_spi_resources
,
601 .platform_data
= &timberdale_xspi_platform_data
,
602 .pdata_size
= sizeof(timberdale_xspi_platform_data
),
606 .num_resources
= ARRAY_SIZE(timberdale_eth_resources
),
607 .resources
= timberdale_eth_resources
,
608 .platform_data
= &timberdale_ks8842_platform_data
,
609 .pdata_size
= sizeof(timberdale_ks8842_platform_data
),
613 static const __devinitconst
struct resource timberdale_sdhc_resources
[] = {
614 /* located in bar 1 and bar 2 */
616 .start
= SDHC0OFFSET
,
618 .flags
= IORESOURCE_MEM
,
621 .start
= IRQ_TIMBERDALE_SDHC
,
622 .end
= IRQ_TIMBERDALE_SDHC
,
623 .flags
= IORESOURCE_IRQ
,
627 static __devinitdata
struct mfd_cell timberdale_cells_bar1
[] = {
630 .num_resources
= ARRAY_SIZE(timberdale_sdhc_resources
),
631 .resources
= timberdale_sdhc_resources
,
635 static __devinitdata
struct mfd_cell timberdale_cells_bar2
[] = {
638 .num_resources
= ARRAY_SIZE(timberdale_sdhc_resources
),
639 .resources
= timberdale_sdhc_resources
,
643 static ssize_t
show_fw_ver(struct device
*dev
, struct device_attribute
*attr
,
646 struct pci_dev
*pdev
= to_pci_dev(dev
);
647 struct timberdale_device
*priv
= pci_get_drvdata(pdev
);
649 return sprintf(buf
, "%d.%d.%d\n", priv
->fw
.major
, priv
->fw
.minor
,
653 static DEVICE_ATTR(fw_ver
, S_IRUGO
, show_fw_ver
, NULL
);
655 /*--------------------------------------------------------------------------*/
657 static int __devinit
timb_probe(struct pci_dev
*dev
,
658 const struct pci_device_id
*id
)
660 struct timberdale_device
*priv
;
662 resource_size_t mapbase
;
663 struct msix_entry
*msix_entries
= NULL
;
666 priv
= kzalloc(sizeof(*priv
), GFP_KERNEL
);
670 pci_set_drvdata(dev
, priv
);
672 err
= pci_enable_device(dev
);
676 mapbase
= pci_resource_start(dev
, 0);
678 dev_err(&dev
->dev
, "No resource\n");
682 /* create a resource for the PCI master register */
683 priv
->ctl_mapbase
= mapbase
+ CHIPCTLOFFSET
;
684 if (!request_mem_region(priv
->ctl_mapbase
, CHIPCTLSIZE
, "timb-ctl")) {
685 dev_err(&dev
->dev
, "Failed to request ctl mem\n");
689 priv
->ctl_membase
= ioremap(priv
->ctl_mapbase
, CHIPCTLSIZE
);
690 if (!priv
->ctl_membase
) {
691 dev_err(&dev
->dev
, "ioremap failed for ctl mem\n");
695 /* read the HW config */
696 priv
->fw
.major
= ioread32(priv
->ctl_membase
+ TIMB_REV_MAJOR
);
697 priv
->fw
.minor
= ioread32(priv
->ctl_membase
+ TIMB_REV_MINOR
);
698 priv
->fw
.config
= ioread32(priv
->ctl_membase
+ TIMB_HW_CONFIG
);
700 if (priv
->fw
.major
> TIMB_SUPPORTED_MAJOR
) {
701 dev_err(&dev
->dev
, "The driver supports an older "
702 "version of the FPGA, please update the driver to "
703 "support %d.%d\n", priv
->fw
.major
, priv
->fw
.minor
);
706 if (priv
->fw
.major
< TIMB_SUPPORTED_MAJOR
||
707 priv
->fw
.minor
< TIMB_REQUIRED_MINOR
) {
708 dev_err(&dev
->dev
, "The FPGA image is too old (%d.%d), "
709 "please upgrade the FPGA to at least: %d.%d\n",
710 priv
->fw
.major
, priv
->fw
.minor
,
711 TIMB_SUPPORTED_MAJOR
, TIMB_REQUIRED_MINOR
);
715 msix_entries
= kzalloc(TIMBERDALE_NR_IRQS
* sizeof(*msix_entries
),
720 for (i
= 0; i
< TIMBERDALE_NR_IRQS
; i
++)
721 msix_entries
[i
].entry
= i
;
723 err
= pci_enable_msix(dev
, msix_entries
, TIMBERDALE_NR_IRQS
);
726 "MSI-X init failed: %d, expected entries: %d\n",
727 err
, TIMBERDALE_NR_IRQS
);
731 err
= device_create_file(&dev
->dev
, &dev_attr_fw_ver
);
733 goto err_create_file
;
735 /* Reset all FPGA PLB peripherals */
736 iowrite32(0x1, priv
->ctl_membase
+ TIMB_SW_RST
);
738 /* update IRQ offsets in I2C board info */
739 for (i
= 0; i
< ARRAY_SIZE(timberdale_i2c_board_info
); i
++)
740 timberdale_i2c_board_info
[i
].irq
=
741 msix_entries
[timberdale_i2c_board_info
[i
].irq
].vector
;
743 /* Update the SPI configuration depending on the HW (8 or 16 bit) */
744 if (priv
->fw
.config
& TIMB_HW_CONFIG_SPI_8BIT
) {
745 timberdale_xspi_platform_data
.bits_per_word
= 8;
746 timberdale_xspi_platform_data
.devices
=
747 timberdale_spi_8bit_board_info
;
748 timberdale_xspi_platform_data
.num_devices
=
749 ARRAY_SIZE(timberdale_spi_8bit_board_info
);
751 timberdale_xspi_platform_data
.bits_per_word
= 16;
752 timberdale_xspi_platform_data
.devices
=
753 timberdale_spi_16bit_board_info
;
754 timberdale_xspi_platform_data
.num_devices
=
755 ARRAY_SIZE(timberdale_spi_16bit_board_info
);
758 ip_setup
= priv
->fw
.config
& TIMB_HW_VER_MASK
;
761 err
= mfd_add_devices(&dev
->dev
, -1,
762 timberdale_cells_bar0_cfg0
,
763 ARRAY_SIZE(timberdale_cells_bar0_cfg0
),
764 &dev
->resource
[0], msix_entries
[0].vector
);
767 err
= mfd_add_devices(&dev
->dev
, -1,
768 timberdale_cells_bar0_cfg1
,
769 ARRAY_SIZE(timberdale_cells_bar0_cfg1
),
770 &dev
->resource
[0], msix_entries
[0].vector
);
773 err
= mfd_add_devices(&dev
->dev
, -1,
774 timberdale_cells_bar0_cfg2
,
775 ARRAY_SIZE(timberdale_cells_bar0_cfg2
),
776 &dev
->resource
[0], msix_entries
[0].vector
);
779 err
= mfd_add_devices(&dev
->dev
, -1,
780 timberdale_cells_bar0_cfg3
,
781 ARRAY_SIZE(timberdale_cells_bar0_cfg3
),
782 &dev
->resource
[0], msix_entries
[0].vector
);
785 dev_err(&dev
->dev
, "Uknown IP setup: %d.%d.%d\n",
786 priv
->fw
.major
, priv
->fw
.minor
, ip_setup
);
793 dev_err(&dev
->dev
, "mfd_add_devices failed: %d\n", err
);
797 err
= mfd_add_devices(&dev
->dev
, 0,
798 timberdale_cells_bar1
, ARRAY_SIZE(timberdale_cells_bar1
),
799 &dev
->resource
[1], msix_entries
[0].vector
);
801 dev_err(&dev
->dev
, "mfd_add_devices failed: %d\n", err
);
805 /* only version 0 and 3 have the iNand routed to SDHCI */
806 if (((priv
->fw
.config
& TIMB_HW_VER_MASK
) == TIMB_HW_VER0
) ||
807 ((priv
->fw
.config
& TIMB_HW_VER_MASK
) == TIMB_HW_VER3
)) {
808 err
= mfd_add_devices(&dev
->dev
, 1, timberdale_cells_bar2
,
809 ARRAY_SIZE(timberdale_cells_bar2
),
810 &dev
->resource
[2], msix_entries
[0].vector
);
812 dev_err(&dev
->dev
, "mfd_add_devices failed: %d\n", err
);
820 "Found Timberdale Card. Rev: %d.%d, HW config: 0x%02x\n",
821 priv
->fw
.major
, priv
->fw
.minor
, priv
->fw
.config
);
826 mfd_remove_devices(&dev
->dev
);
828 device_remove_file(&dev
->dev
, &dev_attr_fw_ver
);
830 pci_disable_msix(dev
);
832 iounmap(priv
->ctl_membase
);
834 release_mem_region(priv
->ctl_mapbase
, CHIPCTLSIZE
);
836 pci_set_drvdata(dev
, NULL
);
838 pci_disable_device(dev
);
842 pci_set_drvdata(dev
, NULL
);
846 static void __devexit
timb_remove(struct pci_dev
*dev
)
848 struct timberdale_device
*priv
= pci_get_drvdata(dev
);
850 mfd_remove_devices(&dev
->dev
);
852 device_remove_file(&dev
->dev
, &dev_attr_fw_ver
);
854 iounmap(priv
->ctl_membase
);
855 release_mem_region(priv
->ctl_mapbase
, CHIPCTLSIZE
);
857 pci_disable_msix(dev
);
858 pci_disable_device(dev
);
859 pci_set_drvdata(dev
, NULL
);
863 static struct pci_device_id timberdale_pci_tbl
[] = {
864 { PCI_DEVICE(PCI_VENDOR_ID_TIMB
, PCI_DEVICE_ID_TIMB
) },
867 MODULE_DEVICE_TABLE(pci
, timberdale_pci_tbl
);
869 static struct pci_driver timberdale_pci_driver
= {
871 .id_table
= timberdale_pci_tbl
,
873 .remove
= __devexit_p(timb_remove
),
876 static int __init
timberdale_init(void)
880 err
= pci_register_driver(&timberdale_pci_driver
);
883 "Failed to register PCI driver for %s device.\n",
884 timberdale_pci_driver
.name
);
888 printk(KERN_INFO
"Driver for %s has been successfully registered.\n",
889 timberdale_pci_driver
.name
);
894 static void __exit
timberdale_exit(void)
896 pci_unregister_driver(&timberdale_pci_driver
);
898 printk(KERN_INFO
"Driver for %s has been successfully unregistered.\n",
899 timberdale_pci_driver
.name
);
902 module_init(timberdale_init
);
903 module_exit(timberdale_exit
);
905 MODULE_AUTHOR("Mocean Laboratories <info@mocean-labs.com>");
906 MODULE_VERSION(DRV_VERSION
);
907 MODULE_LICENSE("GPL v2");