diff options
Diffstat (limited to 'drivers/spi/spi-nuc900.c')
-rw-r--r-- | drivers/spi/spi-nuc900.c | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/drivers/spi/spi-nuc900.c b/drivers/spi/spi-nuc900.c index bae97ffec4b9..16e30de650b0 100644 --- a/drivers/spi/spi-nuc900.c +++ b/drivers/spi/spi-nuc900.c | |||
@@ -9,7 +9,6 @@ | |||
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <linux/module.h> | 11 | #include <linux/module.h> |
12 | #include <linux/init.h> | ||
13 | #include <linux/spinlock.h> | 12 | #include <linux/spinlock.h> |
14 | #include <linux/workqueue.h> | 13 | #include <linux/workqueue.h> |
15 | #include <linux/interrupt.h> | 14 | #include <linux/interrupt.h> |
@@ -38,7 +37,9 @@ | |||
38 | /* usi register bit */ | 37 | /* usi register bit */ |
39 | #define ENINT (0x01 << 17) | 38 | #define ENINT (0x01 << 17) |
40 | #define ENFLG (0x01 << 16) | 39 | #define ENFLG (0x01 << 16) |
40 | #define SLEEP (0x0f << 12) | ||
41 | #define TXNUM (0x03 << 8) | 41 | #define TXNUM (0x03 << 8) |
42 | #define TXBITLEN (0x1f << 3) | ||
42 | #define TXNEG (0x01 << 2) | 43 | #define TXNEG (0x01 << 2) |
43 | #define RXNEG (0x01 << 1) | 44 | #define RXNEG (0x01 << 1) |
44 | #define LSB (0x01 << 10) | 45 | #define LSB (0x01 << 10) |
@@ -58,11 +59,8 @@ struct nuc900_spi { | |||
58 | unsigned char *rx; | 59 | unsigned char *rx; |
59 | struct clk *clk; | 60 | struct clk *clk; |
60 | struct spi_master *master; | 61 | struct spi_master *master; |
61 | struct spi_device *curdev; | ||
62 | struct device *dev; | ||
63 | struct nuc900_spi_info *pdata; | 62 | struct nuc900_spi_info *pdata; |
64 | spinlock_t lock; | 63 | spinlock_t lock; |
65 | struct resource *res; | ||
66 | }; | 64 | }; |
67 | 65 | ||
68 | static inline struct nuc900_spi *to_hw(struct spi_device *sdev) | 66 | static inline struct nuc900_spi *to_hw(struct spi_device *sdev) |
@@ -119,19 +117,16 @@ static void nuc900_spi_chipsel(struct spi_device *spi, int value) | |||
119 | } | 117 | } |
120 | } | 118 | } |
121 | 119 | ||
122 | static void nuc900_spi_setup_txnum(struct nuc900_spi *hw, | 120 | static void nuc900_spi_setup_txnum(struct nuc900_spi *hw, unsigned int txnum) |
123 | unsigned int txnum) | ||
124 | { | 121 | { |
125 | unsigned int val; | 122 | unsigned int val; |
126 | unsigned long flags; | 123 | unsigned long flags; |
127 | 124 | ||
128 | spin_lock_irqsave(&hw->lock, flags); | 125 | spin_lock_irqsave(&hw->lock, flags); |
129 | 126 | ||
130 | val = __raw_readl(hw->regs + USI_CNT); | 127 | val = __raw_readl(hw->regs + USI_CNT) & ~TXNUM; |
131 | 128 | ||
132 | if (!txnum) | 129 | if (txnum) |
133 | val &= ~TXNUM; | ||
134 | else | ||
135 | val |= txnum << 0x08; | 130 | val |= txnum << 0x08; |
136 | 131 | ||
137 | __raw_writel(val, hw->regs + USI_CNT); | 132 | __raw_writel(val, hw->regs + USI_CNT); |
@@ -148,7 +143,7 @@ static void nuc900_spi_setup_txbitlen(struct nuc900_spi *hw, | |||
148 | 143 | ||
149 | spin_lock_irqsave(&hw->lock, flags); | 144 | spin_lock_irqsave(&hw->lock, flags); |
150 | 145 | ||
151 | val = __raw_readl(hw->regs + USI_CNT); | 146 | val = __raw_readl(hw->regs + USI_CNT) & ~TXBITLEN; |
152 | 147 | ||
153 | val |= (txbitlen << 0x03); | 148 | val |= (txbitlen << 0x03); |
154 | 149 | ||
@@ -287,12 +282,11 @@ static void nuc900_set_sleep(struct nuc900_spi *hw, unsigned int sleep) | |||
287 | 282 | ||
288 | spin_lock_irqsave(&hw->lock, flags); | 283 | spin_lock_irqsave(&hw->lock, flags); |
289 | 284 | ||
290 | val = __raw_readl(hw->regs + USI_CNT); | 285 | val = __raw_readl(hw->regs + USI_CNT) & ~SLEEP; |
291 | 286 | ||
292 | if (sleep) | 287 | if (sleep) |
293 | val |= (sleep << 12); | 288 | val |= (sleep << 12); |
294 | else | 289 | |
295 | val &= ~(0x0f << 12); | ||
296 | __raw_writel(val, hw->regs + USI_CNT); | 290 | __raw_writel(val, hw->regs + USI_CNT); |
297 | 291 | ||
298 | spin_unlock_irqrestore(&hw->lock, flags); | 292 | spin_unlock_irqrestore(&hw->lock, flags); |
@@ -338,6 +332,7 @@ static int nuc900_spi_probe(struct platform_device *pdev) | |||
338 | { | 332 | { |
339 | struct nuc900_spi *hw; | 333 | struct nuc900_spi *hw; |
340 | struct spi_master *master; | 334 | struct spi_master *master; |
335 | struct resource *res; | ||
341 | int err = 0; | 336 | int err = 0; |
342 | 337 | ||
343 | master = spi_alloc_master(&pdev->dev, sizeof(struct nuc900_spi)); | 338 | master = spi_alloc_master(&pdev->dev, sizeof(struct nuc900_spi)); |
@@ -349,7 +344,6 @@ static int nuc900_spi_probe(struct platform_device *pdev) | |||
349 | hw = spi_master_get_devdata(master); | 344 | hw = spi_master_get_devdata(master); |
350 | hw->master = master; | 345 | hw->master = master; |
351 | hw->pdata = dev_get_platdata(&pdev->dev); | 346 | hw->pdata = dev_get_platdata(&pdev->dev); |
352 | hw->dev = &pdev->dev; | ||
353 | 347 | ||
354 | if (hw->pdata == NULL) { | 348 | if (hw->pdata == NULL) { |
355 | dev_err(&pdev->dev, "No platform data supplied\n"); | 349 | dev_err(&pdev->dev, "No platform data supplied\n"); |
@@ -369,8 +363,8 @@ static int nuc900_spi_probe(struct platform_device *pdev) | |||
369 | hw->bitbang.chipselect = nuc900_spi_chipsel; | 363 | hw->bitbang.chipselect = nuc900_spi_chipsel; |
370 | hw->bitbang.txrx_bufs = nuc900_spi_txrx; | 364 | hw->bitbang.txrx_bufs = nuc900_spi_txrx; |
371 | 365 | ||
372 | hw->res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 366 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
373 | hw->regs = devm_ioremap_resource(&pdev->dev, hw->res); | 367 | hw->regs = devm_ioremap_resource(&pdev->dev, res); |
374 | if (IS_ERR(hw->regs)) { | 368 | if (IS_ERR(hw->regs)) { |
375 | err = PTR_ERR(hw->regs); | 369 | err = PTR_ERR(hw->regs); |
376 | goto err_pdata; | 370 | goto err_pdata; |