aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-pxa2xx-pci.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/spi/spi-pxa2xx-pci.c')
-rw-r--r--drivers/spi/spi-pxa2xx-pci.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/drivers/spi/spi-pxa2xx-pci.c b/drivers/spi/spi-pxa2xx-pci.c
index c1865c92ccb9..20ebbc764693 100644
--- a/drivers/spi/spi-pxa2xx-pci.c
+++ b/drivers/spi/spi-pxa2xx-pci.c
@@ -7,6 +7,8 @@
7#include <linux/of_device.h> 7#include <linux/of_device.h>
8#include <linux/module.h> 8#include <linux/module.h>
9#include <linux/spi/pxa2xx_spi.h> 9#include <linux/spi/pxa2xx_spi.h>
10#include <linux/clk.h>
11#include <linux/clk-provider.h>
10 12
11enum { 13enum {
12 PORT_CE4100, 14 PORT_CE4100,
@@ -21,6 +23,7 @@ struct pxa_spi_info {
21 int tx_chan_id; 23 int tx_chan_id;
22 int rx_slave_id; 24 int rx_slave_id;
23 int rx_chan_id; 25 int rx_chan_id;
26 unsigned long max_clk_rate;
24}; 27};
25 28
26static struct pxa_spi_info spi_info_configs[] = { 29static struct pxa_spi_info spi_info_configs[] = {
@@ -32,6 +35,7 @@ static struct pxa_spi_info spi_info_configs[] = {
32 .tx_chan_id = -1, 35 .tx_chan_id = -1,
33 .rx_slave_id = -1, 36 .rx_slave_id = -1,
34 .rx_chan_id = -1, 37 .rx_chan_id = -1,
38 .max_clk_rate = 3686400,
35 }, 39 },
36 [PORT_BYT] = { 40 [PORT_BYT] = {
37 .type = LPSS_SSP, 41 .type = LPSS_SSP,
@@ -41,6 +45,7 @@ static struct pxa_spi_info spi_info_configs[] = {
41 .tx_chan_id = 0, 45 .tx_chan_id = 0,
42 .rx_slave_id = 1, 46 .rx_slave_id = 1,
43 .rx_chan_id = 1, 47 .rx_chan_id = 1,
48 .max_clk_rate = 50000000,
44 }, 49 },
45}; 50};
46 51
@@ -53,6 +58,7 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev,
53 struct pxa2xx_spi_master spi_pdata; 58 struct pxa2xx_spi_master spi_pdata;
54 struct ssp_device *ssp; 59 struct ssp_device *ssp;
55 struct pxa_spi_info *c; 60 struct pxa_spi_info *c;
61 char buf[40];
56 62
57 ret = pcim_enable_device(dev); 63 ret = pcim_enable_device(dev);
58 if (ret) 64 if (ret)
@@ -84,6 +90,12 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev,
84 ssp->port_id = (c->port_id >= 0) ? c->port_id : dev->devfn; 90 ssp->port_id = (c->port_id >= 0) ? c->port_id : dev->devfn;
85 ssp->type = c->type; 91 ssp->type = c->type;
86 92
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);
96 if (IS_ERR(ssp->clk))
97 return PTR_ERR(ssp->clk);
98
87 memset(&pi, 0, sizeof(pi)); 99 memset(&pi, 0, sizeof(pi));
88 pi.parent = &dev->dev; 100 pi.parent = &dev->dev;
89 pi.name = "pxa2xx-spi"; 101 pi.name = "pxa2xx-spi";
@@ -92,8 +104,10 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev,
92 pi.size_data = sizeof(spi_pdata); 104 pi.size_data = sizeof(spi_pdata);
93 105
94 pdev = platform_device_register_full(&pi); 106 pdev = platform_device_register_full(&pi);
95 if (IS_ERR(pdev)) 107 if (IS_ERR(pdev)) {
108 clk_unregister(ssp->clk);
96 return PTR_ERR(pdev); 109 return PTR_ERR(pdev);
110 }
97 111
98 pci_set_drvdata(dev, pdev); 112 pci_set_drvdata(dev, pdev);
99 113
@@ -103,8 +117,13 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev,
103static void pxa2xx_spi_pci_remove(struct pci_dev *dev) 117static void pxa2xx_spi_pci_remove(struct pci_dev *dev)
104{ 118{
105 struct platform_device *pdev = pci_get_drvdata(dev); 119 struct platform_device *pdev = pci_get_drvdata(dev);
120 struct pxa2xx_spi_master *spi_pdata;
121
122 spi_pdata = dev_get_platdata(&pdev->dev);
106 123
107 platform_device_unregister(pdev); 124 platform_device_unregister(pdev);
125 clk_unregister(spi_pdata->ssp.clk);
126 pci_set_drvdata(dev, NULL);
108} 127}
109 128
110static const struct pci_device_id pxa2xx_spi_pci_devices[] = { 129static const struct pci_device_id pxa2xx_spi_pci_devices[] = {