2 * CE4100's SPI device is more or less the same one as found on PXA
6 #include <linux/platform_device.h>
7 #include <linux/of_device.h>
8 #include <linux/module.h>
9 #include <linux/spi/pxa2xx_spi.h>
10 #include <linux/clk.h>
11 #include <linux/clk-provider.h>
19 enum pxa_ssp_type type
;
26 unsigned long max_clk_rate
;
29 static struct pxa_spi_info spi_info_configs
[] = {
38 .max_clk_rate
= 3686400,
48 .max_clk_rate
= 50000000,
52 static int pxa2xx_spi_pci_probe(struct pci_dev
*dev
,
53 const struct pci_device_id
*ent
)
55 struct platform_device_info pi
;
57 struct platform_device
*pdev
;
58 struct pxa2xx_spi_master spi_pdata
;
59 struct ssp_device
*ssp
;
60 struct pxa_spi_info
*c
;
63 ret
= pcim_enable_device(dev
);
67 ret
= pcim_iomap_regions(dev
, 1 << 0, "PXA2xx SPI");
71 c
= &spi_info_configs
[ent
->driver_data
];
73 memset(&spi_pdata
, 0, sizeof(spi_pdata
));
74 spi_pdata
.num_chipselect
= (c
->num_chipselect
> 0) ?
75 c
->num_chipselect
: dev
->devfn
;
76 spi_pdata
.tx_slave_id
= c
->tx_slave_id
;
77 spi_pdata
.tx_chan_id
= c
->tx_chan_id
;
78 spi_pdata
.rx_slave_id
= c
->rx_slave_id
;
79 spi_pdata
.rx_chan_id
= c
->rx_chan_id
;
80 spi_pdata
.enable_dma
= c
->rx_slave_id
>= 0 && c
->tx_slave_id
>= 0;
83 ssp
->phys_base
= pci_resource_start(dev
, 0);
84 ssp
->mmio_base
= pcim_iomap_table(dev
)[0];
85 if (!ssp
->mmio_base
) {
86 dev_err(&dev
->dev
, "failed to ioremap() registers\n");
90 ssp
->port_id
= (c
->port_id
>= 0) ? c
->port_id
: dev
->devfn
;
93 snprintf(buf
, sizeof(buf
), "pxa2xx-spi.%d", ssp
->port_id
);
94 ssp
->clk
= clk_register_fixed_rate(&dev
->dev
, buf
, NULL
,
95 CLK_IS_ROOT
, c
->max_clk_rate
);
97 return PTR_ERR(ssp
->clk
);
99 memset(&pi
, 0, sizeof(pi
));
100 pi
.parent
= &dev
->dev
;
101 pi
.name
= "pxa2xx-spi";
102 pi
.id
= ssp
->port_id
;
103 pi
.data
= &spi_pdata
;
104 pi
.size_data
= sizeof(spi_pdata
);
106 pdev
= platform_device_register_full(&pi
);
108 clk_unregister(ssp
->clk
);
109 return PTR_ERR(pdev
);
112 pci_set_drvdata(dev
, pdev
);
117 static void pxa2xx_spi_pci_remove(struct pci_dev
*dev
)
119 struct platform_device
*pdev
= pci_get_drvdata(dev
);
120 struct pxa2xx_spi_master
*spi_pdata
;
122 spi_pdata
= dev_get_platdata(&pdev
->dev
);
124 platform_device_unregister(pdev
);
125 clk_unregister(spi_pdata
->ssp
.clk
);
126 pci_set_drvdata(dev
, NULL
);
129 static const struct pci_device_id pxa2xx_spi_pci_devices
[] = {
130 { PCI_VDEVICE(INTEL
, 0x2e6a), PORT_CE4100
},
131 { PCI_VDEVICE(INTEL
, 0x0f0e), PORT_BYT
},
134 MODULE_DEVICE_TABLE(pci
, pxa2xx_spi_pci_devices
);
136 static struct pci_driver pxa2xx_spi_pci_driver
= {
137 .name
= "pxa2xx_spi_pci",
138 .id_table
= pxa2xx_spi_pci_devices
,
139 .probe
= pxa2xx_spi_pci_probe
,
140 .remove
= pxa2xx_spi_pci_remove
,
143 module_pci_driver(pxa2xx_spi_pci_driver
);
145 MODULE_DESCRIPTION("CE4100/LPSS PCI-SPI glue code for PXA's driver");
146 MODULE_LICENSE("GPL v2");
147 MODULE_AUTHOR("Sebastian Andrzej Siewior <bigeasy@linutronix.de>");