Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 1 | /* |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 2 | * Freescale SPI controller driver. |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 3 | * |
| 4 | * Maintainer: Kumar Gala |
| 5 | * |
| 6 | * Copyright (C) 2006 Polycom, Inc. |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 7 | * Copyright 2010 Freescale Semiconductor, Inc. |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 8 | * |
Anton Vorontsov | 4c1fba44 | 2009-10-12 20:49:27 +0400 | [diff] [blame] | 9 | * CPM SPI and QE buffer descriptors mode support: |
| 10 | * Copyright (c) 2009 MontaVista Software, Inc. |
| 11 | * Author: Anton Vorontsov <avorontsov@ru.mvista.com> |
| 12 | * |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 13 | * This program is free software; you can redistribute it and/or modify it |
| 14 | * under the terms of the GNU General Public License as published by the |
| 15 | * Free Software Foundation; either version 2 of the License, or (at your |
| 16 | * option) any later version. |
| 17 | */ |
| 18 | #include <linux/module.h> |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 19 | #include <linux/types.h> |
| 20 | #include <linux/kernel.h> |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 21 | #include <linux/interrupt.h> |
| 22 | #include <linux/delay.h> |
| 23 | #include <linux/irq.h> |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 24 | #include <linux/spi/spi.h> |
| 25 | #include <linux/spi/spi_bitbang.h> |
| 26 | #include <linux/platform_device.h> |
| 27 | #include <linux/fsl_devices.h> |
Anton Vorontsov | 4c1fba44 | 2009-10-12 20:49:27 +0400 | [diff] [blame] | 28 | #include <linux/dma-mapping.h> |
| 29 | #include <linux/mm.h> |
| 30 | #include <linux/mutex.h> |
Anton Vorontsov | 35b4b3c | 2009-03-31 15:24:37 -0700 | [diff] [blame] | 31 | #include <linux/of.h> |
| 32 | #include <linux/of_platform.h> |
Andreas Larsson | e8beacb | 2013-02-15 16:52:21 +0100 | [diff] [blame] | 33 | #include <linux/of_address.h> |
| 34 | #include <linux/of_irq.h> |
Anton Vorontsov | 35b4b3c | 2009-03-31 15:24:37 -0700 | [diff] [blame] | 35 | #include <linux/gpio.h> |
| 36 | #include <linux/of_gpio.h> |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 37 | |
Grant Likely | ca632f5 | 2011-06-06 01:16:30 -0600 | [diff] [blame] | 38 | #include "spi-fsl-lib.h" |
Andreas Larsson | e8beacb | 2013-02-15 16:52:21 +0100 | [diff] [blame] | 39 | #include "spi-fsl-cpm.h" |
| 40 | #include "spi-fsl-spi.h" |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 41 | |
Andreas Larsson | c3f3e77 | 2013-02-15 16:52:24 +0100 | [diff] [blame^] | 42 | #define TYPE_FSL 0 |
| 43 | |
| 44 | struct fsl_spi_match_data { |
| 45 | int type; |
| 46 | }; |
| 47 | |
| 48 | static struct fsl_spi_match_data of_fsl_spi_fsl_config = { |
| 49 | .type = TYPE_FSL, |
| 50 | }; |
| 51 | |
| 52 | static struct of_device_id of_fsl_spi_match[] = { |
| 53 | { |
| 54 | .compatible = "fsl,spi", |
| 55 | .data = &of_fsl_spi_fsl_config, |
| 56 | }, |
| 57 | {} |
| 58 | }; |
| 59 | MODULE_DEVICE_TABLE(of, of_fsl_spi_match); |
| 60 | |
| 61 | static int fsl_spi_get_type(struct device *dev) |
| 62 | { |
| 63 | const struct of_device_id *match; |
| 64 | |
| 65 | if (dev->of_node) { |
| 66 | match = of_match_node(of_fsl_spi_match, dev->of_node); |
| 67 | if (match && match->data) |
| 68 | return ((struct fsl_spi_match_data *)match->data)->type; |
| 69 | } |
| 70 | return TYPE_FSL; |
| 71 | } |
| 72 | |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 73 | static void fsl_spi_change_mode(struct spi_device *spi) |
Anton Vorontsov | a35c171 | 2009-10-12 20:49:24 +0400 | [diff] [blame] | 74 | { |
| 75 | struct mpc8xxx_spi *mspi = spi_master_get_devdata(spi->master); |
| 76 | struct spi_mpc8xxx_cs *cs = spi->controller_state; |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 77 | struct fsl_spi_reg *reg_base = mspi->reg_base; |
| 78 | __be32 __iomem *mode = ®_base->mode; |
Anton Vorontsov | a35c171 | 2009-10-12 20:49:24 +0400 | [diff] [blame] | 79 | unsigned long flags; |
| 80 | |
| 81 | if (cs->hw_mode == mpc8xxx_spi_read_reg(mode)) |
| 82 | return; |
| 83 | |
| 84 | /* Turn off IRQs locally to minimize time that SPI is disabled. */ |
| 85 | local_irq_save(flags); |
| 86 | |
| 87 | /* Turn off SPI unit prior changing mode */ |
| 88 | mpc8xxx_spi_write_reg(mode, cs->hw_mode & ~SPMODE_ENABLE); |
Anton Vorontsov | a35c171 | 2009-10-12 20:49:24 +0400 | [diff] [blame] | 89 | |
Anton Vorontsov | 4c1fba44 | 2009-10-12 20:49:27 +0400 | [diff] [blame] | 90 | /* When in CPM mode, we need to reinit tx and rx. */ |
| 91 | if (mspi->flags & SPI_CPM_MODE) { |
Andreas Larsson | e8beacb | 2013-02-15 16:52:21 +0100 | [diff] [blame] | 92 | fsl_spi_cpm_reinit_txrx(mspi); |
Anton Vorontsov | 4c1fba44 | 2009-10-12 20:49:27 +0400 | [diff] [blame] | 93 | } |
Joakim Tjernlund | f9218c2 | 2010-05-22 02:18:02 -0600 | [diff] [blame] | 94 | mpc8xxx_spi_write_reg(mode, cs->hw_mode); |
Anton Vorontsov | a35c171 | 2009-10-12 20:49:24 +0400 | [diff] [blame] | 95 | local_irq_restore(flags); |
| 96 | } |
| 97 | |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 98 | static void fsl_spi_chipselect(struct spi_device *spi, int value) |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 99 | { |
Anton Vorontsov | 575c580 | 2009-06-18 16:49:08 -0700 | [diff] [blame] | 100 | struct mpc8xxx_spi *mpc8xxx_spi = spi_master_get_devdata(spi->master); |
Kenth Eriksson | 5039a86 | 2012-03-30 17:05:30 +0200 | [diff] [blame] | 101 | struct fsl_spi_platform_data *pdata; |
Anton Vorontsov | 364fdbc | 2009-03-31 15:24:36 -0700 | [diff] [blame] | 102 | bool pol = spi->mode & SPI_CS_HIGH; |
Anton Vorontsov | 575c580 | 2009-06-18 16:49:08 -0700 | [diff] [blame] | 103 | struct spi_mpc8xxx_cs *cs = spi->controller_state; |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 104 | |
Kenth Eriksson | 5039a86 | 2012-03-30 17:05:30 +0200 | [diff] [blame] | 105 | pdata = spi->dev.parent->parent->platform_data; |
| 106 | |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 107 | if (value == BITBANG_CS_INACTIVE) { |
Anton Vorontsov | 364fdbc | 2009-03-31 15:24:36 -0700 | [diff] [blame] | 108 | if (pdata->cs_control) |
| 109 | pdata->cs_control(spi, !pol); |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 110 | } |
| 111 | |
| 112 | if (value == BITBANG_CS_ACTIVE) { |
Anton Vorontsov | 575c580 | 2009-06-18 16:49:08 -0700 | [diff] [blame] | 113 | mpc8xxx_spi->rx_shift = cs->rx_shift; |
| 114 | mpc8xxx_spi->tx_shift = cs->tx_shift; |
| 115 | mpc8xxx_spi->get_rx = cs->get_rx; |
| 116 | mpc8xxx_spi->get_tx = cs->get_tx; |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 117 | |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 118 | fsl_spi_change_mode(spi); |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 119 | |
Anton Vorontsov | 364fdbc | 2009-03-31 15:24:36 -0700 | [diff] [blame] | 120 | if (pdata->cs_control) |
| 121 | pdata->cs_control(spi, pol); |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 122 | } |
| 123 | } |
| 124 | |
Andreas Larsson | b48c4e3 | 2013-02-15 16:52:23 +0100 | [diff] [blame] | 125 | static void fsl_spi_qe_cpu_set_shifts(u32 *rx_shift, u32 *tx_shift, |
| 126 | int bits_per_word, int msb_first) |
| 127 | { |
| 128 | *rx_shift = 0; |
| 129 | *tx_shift = 0; |
| 130 | if (msb_first) { |
| 131 | if (bits_per_word <= 8) { |
| 132 | *rx_shift = 16; |
| 133 | *tx_shift = 24; |
| 134 | } else if (bits_per_word <= 16) { |
| 135 | *rx_shift = 16; |
| 136 | *tx_shift = 16; |
| 137 | } |
| 138 | } else { |
| 139 | if (bits_per_word <= 8) |
| 140 | *rx_shift = 8; |
| 141 | } |
| 142 | } |
| 143 | |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 144 | static int mspi_apply_cpu_mode_quirks(struct spi_mpc8xxx_cs *cs, |
| 145 | struct spi_device *spi, |
| 146 | struct mpc8xxx_spi *mpc8xxx_spi, |
| 147 | int bits_per_word) |
Joakim Tjernlund | 0398fb7 | 2010-05-14 09:14:26 +0000 | [diff] [blame] | 148 | { |
| 149 | cs->rx_shift = 0; |
| 150 | cs->tx_shift = 0; |
| 151 | if (bits_per_word <= 8) { |
| 152 | cs->get_rx = mpc8xxx_spi_rx_buf_u8; |
| 153 | cs->get_tx = mpc8xxx_spi_tx_buf_u8; |
Joakim Tjernlund | 0398fb7 | 2010-05-14 09:14:26 +0000 | [diff] [blame] | 154 | } else if (bits_per_word <= 16) { |
| 155 | cs->get_rx = mpc8xxx_spi_rx_buf_u16; |
| 156 | cs->get_tx = mpc8xxx_spi_tx_buf_u16; |
Joakim Tjernlund | 0398fb7 | 2010-05-14 09:14:26 +0000 | [diff] [blame] | 157 | } else if (bits_per_word <= 32) { |
| 158 | cs->get_rx = mpc8xxx_spi_rx_buf_u32; |
| 159 | cs->get_tx = mpc8xxx_spi_tx_buf_u32; |
| 160 | } else |
| 161 | return -EINVAL; |
| 162 | |
Andreas Larsson | b48c4e3 | 2013-02-15 16:52:23 +0100 | [diff] [blame] | 163 | if (mpc8xxx_spi->set_shifts) |
| 164 | mpc8xxx_spi->set_shifts(&cs->rx_shift, &cs->tx_shift, |
| 165 | bits_per_word, |
| 166 | !(spi->mode & SPI_LSB_FIRST)); |
| 167 | |
Joakim Tjernlund | 0398fb7 | 2010-05-14 09:14:26 +0000 | [diff] [blame] | 168 | mpc8xxx_spi->rx_shift = cs->rx_shift; |
| 169 | mpc8xxx_spi->tx_shift = cs->tx_shift; |
| 170 | mpc8xxx_spi->get_rx = cs->get_rx; |
| 171 | mpc8xxx_spi->get_tx = cs->get_tx; |
| 172 | |
| 173 | return bits_per_word; |
| 174 | } |
| 175 | |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 176 | static int mspi_apply_qe_mode_quirks(struct spi_mpc8xxx_cs *cs, |
| 177 | struct spi_device *spi, |
| 178 | int bits_per_word) |
Joakim Tjernlund | 0398fb7 | 2010-05-14 09:14:26 +0000 | [diff] [blame] | 179 | { |
| 180 | /* QE uses Little Endian for words > 8 |
| 181 | * so transform all words > 8 into 8 bits |
| 182 | * Unfortnatly that doesn't work for LSB so |
| 183 | * reject these for now */ |
| 184 | /* Note: 32 bits word, LSB works iff |
| 185 | * tfcr/rfcr is set to CPMFCR_GBL */ |
| 186 | if (spi->mode & SPI_LSB_FIRST && |
| 187 | bits_per_word > 8) |
| 188 | return -EINVAL; |
| 189 | if (bits_per_word > 8) |
| 190 | return 8; /* pretend its 8 bits */ |
| 191 | return bits_per_word; |
| 192 | } |
| 193 | |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 194 | static int fsl_spi_setup_transfer(struct spi_device *spi, |
| 195 | struct spi_transfer *t) |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 196 | { |
Anton Vorontsov | 575c580 | 2009-06-18 16:49:08 -0700 | [diff] [blame] | 197 | struct mpc8xxx_spi *mpc8xxx_spi; |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 198 | int bits_per_word = 0; |
Joakim Tjernlund | 0398fb7 | 2010-05-14 09:14:26 +0000 | [diff] [blame] | 199 | u8 pm; |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 200 | u32 hz = 0; |
Anton Vorontsov | 575c580 | 2009-06-18 16:49:08 -0700 | [diff] [blame] | 201 | struct spi_mpc8xxx_cs *cs = spi->controller_state; |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 202 | |
Anton Vorontsov | 575c580 | 2009-06-18 16:49:08 -0700 | [diff] [blame] | 203 | mpc8xxx_spi = spi_master_get_devdata(spi->master); |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 204 | |
| 205 | if (t) { |
| 206 | bits_per_word = t->bits_per_word; |
| 207 | hz = t->speed_hz; |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 208 | } |
| 209 | |
| 210 | /* spi_transfer level calls that work per-word */ |
| 211 | if (!bits_per_word) |
| 212 | bits_per_word = spi->bits_per_word; |
| 213 | |
| 214 | /* Make sure its a bit width we support [4..16, 32] */ |
| 215 | if ((bits_per_word < 4) |
| 216 | || ((bits_per_word > 16) && (bits_per_word != 32))) |
| 217 | return -EINVAL; |
| 218 | |
Joakim Tjernlund | c9bfcb3 | 2008-05-12 14:02:30 -0700 | [diff] [blame] | 219 | if (!hz) |
| 220 | hz = spi->max_speed_hz; |
| 221 | |
Joakim Tjernlund | 0398fb7 | 2010-05-14 09:14:26 +0000 | [diff] [blame] | 222 | if (!(mpc8xxx_spi->flags & SPI_CPM_MODE)) |
| 223 | bits_per_word = mspi_apply_cpu_mode_quirks(cs, spi, |
| 224 | mpc8xxx_spi, |
| 225 | bits_per_word); |
| 226 | else if (mpc8xxx_spi->flags & SPI_QE) |
| 227 | bits_per_word = mspi_apply_qe_mode_quirks(cs, spi, |
| 228 | bits_per_word); |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 229 | |
Joakim Tjernlund | 0398fb7 | 2010-05-14 09:14:26 +0000 | [diff] [blame] | 230 | if (bits_per_word < 0) |
| 231 | return bits_per_word; |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 232 | |
| 233 | if (bits_per_word == 32) |
| 234 | bits_per_word = 0; |
| 235 | else |
| 236 | bits_per_word = bits_per_word - 1; |
| 237 | |
Anton Vorontsov | 32421da | 2007-07-31 00:38:41 -0700 | [diff] [blame] | 238 | /* mask out bits we are going to set */ |
Joakim Tjernlund | c9bfcb3 | 2008-05-12 14:02:30 -0700 | [diff] [blame] | 239 | cs->hw_mode &= ~(SPMODE_LEN(0xF) | SPMODE_DIV16 |
| 240 | | SPMODE_PM(0xF)); |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 241 | |
Joakim Tjernlund | c9bfcb3 | 2008-05-12 14:02:30 -0700 | [diff] [blame] | 242 | cs->hw_mode |= SPMODE_LEN(bits_per_word); |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 243 | |
Anton Vorontsov | 575c580 | 2009-06-18 16:49:08 -0700 | [diff] [blame] | 244 | if ((mpc8xxx_spi->spibrg / hz) > 64) { |
Peter Korsgaard | 53604db | 2008-09-13 02:33:14 -0700 | [diff] [blame] | 245 | cs->hw_mode |= SPMODE_DIV16; |
Ernst Schwab | 4f4517c | 2010-02-16 21:02:57 -0700 | [diff] [blame] | 246 | pm = (mpc8xxx_spi->spibrg - 1) / (hz * 64) + 1; |
Anton Vorontsov | fd8a11e | 2009-06-18 16:49:01 -0700 | [diff] [blame] | 247 | |
| 248 | WARN_ONCE(pm > 16, "%s: Requested speed is too low: %d Hz. " |
| 249 | "Will use %d Hz instead.\n", dev_name(&spi->dev), |
Anton Vorontsov | 575c580 | 2009-06-18 16:49:08 -0700 | [diff] [blame] | 250 | hz, mpc8xxx_spi->spibrg / 1024); |
Anton Vorontsov | fd8a11e | 2009-06-18 16:49:01 -0700 | [diff] [blame] | 251 | if (pm > 16) |
Peter Korsgaard | 53604db | 2008-09-13 02:33:14 -0700 | [diff] [blame] | 252 | pm = 16; |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 253 | } else { |
Ernst Schwab | 4f4517c | 2010-02-16 21:02:57 -0700 | [diff] [blame] | 254 | pm = (mpc8xxx_spi->spibrg - 1) / (hz * 4) + 1; |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 255 | } |
Chen Gong | a61f534 | 2008-07-23 21:29:52 -0700 | [diff] [blame] | 256 | if (pm) |
| 257 | pm--; |
| 258 | |
| 259 | cs->hw_mode |= SPMODE_PM(pm); |
David Brownell | dccd573 | 2007-07-17 04:04:02 -0700 | [diff] [blame] | 260 | |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 261 | fsl_spi_change_mode(spi); |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 262 | return 0; |
| 263 | } |
| 264 | |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 265 | static int fsl_spi_cpu_bufs(struct mpc8xxx_spi *mspi, |
Anton Vorontsov | 4c1fba44 | 2009-10-12 20:49:27 +0400 | [diff] [blame] | 266 | struct spi_transfer *t, unsigned int len) |
| 267 | { |
| 268 | u32 word; |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 269 | struct fsl_spi_reg *reg_base = mspi->reg_base; |
Anton Vorontsov | 4c1fba44 | 2009-10-12 20:49:27 +0400 | [diff] [blame] | 270 | |
| 271 | mspi->count = len; |
| 272 | |
| 273 | /* enable rx ints */ |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 274 | mpc8xxx_spi_write_reg(®_base->mask, SPIM_NE); |
Anton Vorontsov | 4c1fba44 | 2009-10-12 20:49:27 +0400 | [diff] [blame] | 275 | |
| 276 | /* transmit word */ |
| 277 | word = mspi->get_tx(mspi); |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 278 | mpc8xxx_spi_write_reg(®_base->transmit, word); |
Anton Vorontsov | 4c1fba44 | 2009-10-12 20:49:27 +0400 | [diff] [blame] | 279 | |
| 280 | return 0; |
| 281 | } |
| 282 | |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 283 | static int fsl_spi_bufs(struct spi_device *spi, struct spi_transfer *t, |
Anton Vorontsov | 4c1fba44 | 2009-10-12 20:49:27 +0400 | [diff] [blame] | 284 | bool is_dma_mapped) |
| 285 | { |
| 286 | struct mpc8xxx_spi *mpc8xxx_spi = spi_master_get_devdata(spi->master); |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 287 | struct fsl_spi_reg *reg_base; |
Anton Vorontsov | 4c1fba44 | 2009-10-12 20:49:27 +0400 | [diff] [blame] | 288 | unsigned int len = t->len; |
| 289 | u8 bits_per_word; |
| 290 | int ret; |
| 291 | |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 292 | reg_base = mpc8xxx_spi->reg_base; |
Joakim Tjernlund | c9bfcb3 | 2008-05-12 14:02:30 -0700 | [diff] [blame] | 293 | bits_per_word = spi->bits_per_word; |
| 294 | if (t->bits_per_word) |
| 295 | bits_per_word = t->bits_per_word; |
Anton Vorontsov | 4c1fba44 | 2009-10-12 20:49:27 +0400 | [diff] [blame] | 296 | |
Peter Korsgaard | aa77d96 | 2008-09-13 02:33:15 -0700 | [diff] [blame] | 297 | if (bits_per_word > 8) { |
| 298 | /* invalid length? */ |
| 299 | if (len & 1) |
| 300 | return -EINVAL; |
Joakim Tjernlund | c9bfcb3 | 2008-05-12 14:02:30 -0700 | [diff] [blame] | 301 | len /= 2; |
Peter Korsgaard | aa77d96 | 2008-09-13 02:33:15 -0700 | [diff] [blame] | 302 | } |
| 303 | if (bits_per_word > 16) { |
| 304 | /* invalid length? */ |
| 305 | if (len & 1) |
| 306 | return -EINVAL; |
Joakim Tjernlund | c9bfcb3 | 2008-05-12 14:02:30 -0700 | [diff] [blame] | 307 | len /= 2; |
Peter Korsgaard | aa77d96 | 2008-09-13 02:33:15 -0700 | [diff] [blame] | 308 | } |
Anton Vorontsov | 4c1fba44 | 2009-10-12 20:49:27 +0400 | [diff] [blame] | 309 | |
| 310 | mpc8xxx_spi->tx = t->tx_buf; |
| 311 | mpc8xxx_spi->rx = t->rx_buf; |
Peter Korsgaard | aa77d96 | 2008-09-13 02:33:15 -0700 | [diff] [blame] | 312 | |
Anton Vorontsov | 575c580 | 2009-06-18 16:49:08 -0700 | [diff] [blame] | 313 | INIT_COMPLETION(mpc8xxx_spi->done); |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 314 | |
Anton Vorontsov | 4c1fba44 | 2009-10-12 20:49:27 +0400 | [diff] [blame] | 315 | if (mpc8xxx_spi->flags & SPI_CPM_MODE) |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 316 | ret = fsl_spi_cpm_bufs(mpc8xxx_spi, t, is_dma_mapped); |
Anton Vorontsov | 4c1fba44 | 2009-10-12 20:49:27 +0400 | [diff] [blame] | 317 | else |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 318 | ret = fsl_spi_cpu_bufs(mpc8xxx_spi, t, len); |
Anton Vorontsov | 4c1fba44 | 2009-10-12 20:49:27 +0400 | [diff] [blame] | 319 | if (ret) |
| 320 | return ret; |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 321 | |
Anton Vorontsov | 575c580 | 2009-06-18 16:49:08 -0700 | [diff] [blame] | 322 | wait_for_completion(&mpc8xxx_spi->done); |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 323 | |
| 324 | /* disable rx ints */ |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 325 | mpc8xxx_spi_write_reg(®_base->mask, 0); |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 326 | |
Anton Vorontsov | 4c1fba44 | 2009-10-12 20:49:27 +0400 | [diff] [blame] | 327 | if (mpc8xxx_spi->flags & SPI_CPM_MODE) |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 328 | fsl_spi_cpm_bufs_complete(mpc8xxx_spi); |
Anton Vorontsov | 4c1fba44 | 2009-10-12 20:49:27 +0400 | [diff] [blame] | 329 | |
Anton Vorontsov | 575c580 | 2009-06-18 16:49:08 -0700 | [diff] [blame] | 330 | return mpc8xxx_spi->count; |
Joakim Tjernlund | c9bfcb3 | 2008-05-12 14:02:30 -0700 | [diff] [blame] | 331 | } |
| 332 | |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 333 | static void fsl_spi_do_one_msg(struct spi_message *m) |
Anton Vorontsov | b9b9af1 | 2009-06-18 16:49:06 -0700 | [diff] [blame] | 334 | { |
| 335 | struct spi_device *spi = m->spi; |
| 336 | struct spi_transfer *t; |
| 337 | unsigned int cs_change; |
| 338 | const int nsecs = 50; |
| 339 | int status; |
| 340 | |
| 341 | cs_change = 1; |
| 342 | status = 0; |
| 343 | list_for_each_entry(t, &m->transfers, transfer_list) { |
| 344 | if (t->bits_per_word || t->speed_hz) { |
| 345 | /* Don't allow changes if CS is active */ |
| 346 | status = -EINVAL; |
| 347 | |
| 348 | if (cs_change) |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 349 | status = fsl_spi_setup_transfer(spi, t); |
Anton Vorontsov | b9b9af1 | 2009-06-18 16:49:06 -0700 | [diff] [blame] | 350 | if (status < 0) |
| 351 | break; |
| 352 | } |
| 353 | |
| 354 | if (cs_change) { |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 355 | fsl_spi_chipselect(spi, BITBANG_CS_ACTIVE); |
Anton Vorontsov | b9b9af1 | 2009-06-18 16:49:06 -0700 | [diff] [blame] | 356 | ndelay(nsecs); |
| 357 | } |
| 358 | cs_change = t->cs_change; |
| 359 | if (t->len) |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 360 | status = fsl_spi_bufs(spi, t, m->is_dma_mapped); |
Anton Vorontsov | b9b9af1 | 2009-06-18 16:49:06 -0700 | [diff] [blame] | 361 | if (status) { |
| 362 | status = -EMSGSIZE; |
| 363 | break; |
| 364 | } |
| 365 | m->actual_length += t->len; |
| 366 | |
| 367 | if (t->delay_usecs) |
| 368 | udelay(t->delay_usecs); |
| 369 | |
| 370 | if (cs_change) { |
| 371 | ndelay(nsecs); |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 372 | fsl_spi_chipselect(spi, BITBANG_CS_INACTIVE); |
Anton Vorontsov | b9b9af1 | 2009-06-18 16:49:06 -0700 | [diff] [blame] | 373 | ndelay(nsecs); |
| 374 | } |
| 375 | } |
| 376 | |
| 377 | m->status = status; |
| 378 | m->complete(m->context); |
| 379 | |
| 380 | if (status || !cs_change) { |
| 381 | ndelay(nsecs); |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 382 | fsl_spi_chipselect(spi, BITBANG_CS_INACTIVE); |
Anton Vorontsov | b9b9af1 | 2009-06-18 16:49:06 -0700 | [diff] [blame] | 383 | } |
| 384 | |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 385 | fsl_spi_setup_transfer(spi, NULL); |
Anton Vorontsov | b9b9af1 | 2009-06-18 16:49:06 -0700 | [diff] [blame] | 386 | } |
| 387 | |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 388 | static int fsl_spi_setup(struct spi_device *spi) |
Joakim Tjernlund | c9bfcb3 | 2008-05-12 14:02:30 -0700 | [diff] [blame] | 389 | { |
Anton Vorontsov | 575c580 | 2009-06-18 16:49:08 -0700 | [diff] [blame] | 390 | struct mpc8xxx_spi *mpc8xxx_spi; |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 391 | struct fsl_spi_reg *reg_base; |
Joakim Tjernlund | c9bfcb3 | 2008-05-12 14:02:30 -0700 | [diff] [blame] | 392 | int retval; |
| 393 | u32 hw_mode; |
Anton Vorontsov | 575c580 | 2009-06-18 16:49:08 -0700 | [diff] [blame] | 394 | struct spi_mpc8xxx_cs *cs = spi->controller_state; |
Joakim Tjernlund | c9bfcb3 | 2008-05-12 14:02:30 -0700 | [diff] [blame] | 395 | |
Joakim Tjernlund | c9bfcb3 | 2008-05-12 14:02:30 -0700 | [diff] [blame] | 396 | if (!spi->max_speed_hz) |
| 397 | return -EINVAL; |
| 398 | |
| 399 | if (!cs) { |
| 400 | cs = kzalloc(sizeof *cs, GFP_KERNEL); |
| 401 | if (!cs) |
| 402 | return -ENOMEM; |
| 403 | spi->controller_state = cs; |
| 404 | } |
Anton Vorontsov | 575c580 | 2009-06-18 16:49:08 -0700 | [diff] [blame] | 405 | mpc8xxx_spi = spi_master_get_devdata(spi->master); |
Joakim Tjernlund | c9bfcb3 | 2008-05-12 14:02:30 -0700 | [diff] [blame] | 406 | |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 407 | reg_base = mpc8xxx_spi->reg_base; |
| 408 | |
Thomas Weber | 8839316 | 2010-03-16 11:47:56 +0100 | [diff] [blame] | 409 | hw_mode = cs->hw_mode; /* Save original settings */ |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 410 | cs->hw_mode = mpc8xxx_spi_read_reg(®_base->mode); |
Joakim Tjernlund | c9bfcb3 | 2008-05-12 14:02:30 -0700 | [diff] [blame] | 411 | /* mask out bits we are going to set */ |
| 412 | cs->hw_mode &= ~(SPMODE_CP_BEGIN_EDGECLK | SPMODE_CI_INACTIVEHIGH |
| 413 | | SPMODE_REV | SPMODE_LOOP); |
| 414 | |
| 415 | if (spi->mode & SPI_CPHA) |
| 416 | cs->hw_mode |= SPMODE_CP_BEGIN_EDGECLK; |
| 417 | if (spi->mode & SPI_CPOL) |
| 418 | cs->hw_mode |= SPMODE_CI_INACTIVEHIGH; |
| 419 | if (!(spi->mode & SPI_LSB_FIRST)) |
| 420 | cs->hw_mode |= SPMODE_REV; |
| 421 | if (spi->mode & SPI_LOOP) |
| 422 | cs->hw_mode |= SPMODE_LOOP; |
| 423 | |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 424 | retval = fsl_spi_setup_transfer(spi, NULL); |
Joakim Tjernlund | c9bfcb3 | 2008-05-12 14:02:30 -0700 | [diff] [blame] | 425 | if (retval < 0) { |
| 426 | cs->hw_mode = hw_mode; /* Restore settings */ |
| 427 | return retval; |
| 428 | } |
Andreas Larsson | f482cd0 | 2013-02-15 16:52:22 +0100 | [diff] [blame] | 429 | |
| 430 | /* Initialize chipselect - might be active for SPI_CS_HIGH mode */ |
| 431 | fsl_spi_chipselect(spi, BITBANG_CS_INACTIVE); |
| 432 | |
Joakim Tjernlund | c9bfcb3 | 2008-05-12 14:02:30 -0700 | [diff] [blame] | 433 | return 0; |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 434 | } |
| 435 | |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 436 | static void fsl_spi_cpu_irq(struct mpc8xxx_spi *mspi, u32 events) |
Anton Vorontsov | 4c1fba44 | 2009-10-12 20:49:27 +0400 | [diff] [blame] | 437 | { |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 438 | struct fsl_spi_reg *reg_base = mspi->reg_base; |
| 439 | |
Anton Vorontsov | 4c1fba44 | 2009-10-12 20:49:27 +0400 | [diff] [blame] | 440 | /* We need handle RX first */ |
| 441 | if (events & SPIE_NE) { |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 442 | u32 rx_data = mpc8xxx_spi_read_reg(®_base->receive); |
Anton Vorontsov | 4c1fba44 | 2009-10-12 20:49:27 +0400 | [diff] [blame] | 443 | |
| 444 | if (mspi->rx) |
| 445 | mspi->get_rx(rx_data, mspi); |
| 446 | } |
| 447 | |
| 448 | if ((events & SPIE_NF) == 0) |
| 449 | /* spin until TX is done */ |
| 450 | while (((events = |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 451 | mpc8xxx_spi_read_reg(®_base->event)) & |
Anton Vorontsov | 4c1fba44 | 2009-10-12 20:49:27 +0400 | [diff] [blame] | 452 | SPIE_NF) == 0) |
| 453 | cpu_relax(); |
| 454 | |
| 455 | /* Clear the events */ |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 456 | mpc8xxx_spi_write_reg(®_base->event, events); |
Anton Vorontsov | 4c1fba44 | 2009-10-12 20:49:27 +0400 | [diff] [blame] | 457 | |
| 458 | mspi->count -= 1; |
| 459 | if (mspi->count) { |
| 460 | u32 word = mspi->get_tx(mspi); |
| 461 | |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 462 | mpc8xxx_spi_write_reg(®_base->transmit, word); |
Anton Vorontsov | 4c1fba44 | 2009-10-12 20:49:27 +0400 | [diff] [blame] | 463 | } else { |
| 464 | complete(&mspi->done); |
| 465 | } |
| 466 | } |
| 467 | |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 468 | static irqreturn_t fsl_spi_irq(s32 irq, void *context_data) |
Anton Vorontsov | 4c1fba44 | 2009-10-12 20:49:27 +0400 | [diff] [blame] | 469 | { |
| 470 | struct mpc8xxx_spi *mspi = context_data; |
| 471 | irqreturn_t ret = IRQ_NONE; |
| 472 | u32 events; |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 473 | struct fsl_spi_reg *reg_base = mspi->reg_base; |
Anton Vorontsov | 4c1fba44 | 2009-10-12 20:49:27 +0400 | [diff] [blame] | 474 | |
| 475 | /* Get interrupt events(tx/rx) */ |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 476 | events = mpc8xxx_spi_read_reg(®_base->event); |
Anton Vorontsov | 4c1fba44 | 2009-10-12 20:49:27 +0400 | [diff] [blame] | 477 | if (events) |
| 478 | ret = IRQ_HANDLED; |
| 479 | |
| 480 | dev_dbg(mspi->dev, "%s: events %x\n", __func__, events); |
| 481 | |
| 482 | if (mspi->flags & SPI_CPM_MODE) |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 483 | fsl_spi_cpm_irq(mspi, events); |
Anton Vorontsov | 4c1fba44 | 2009-10-12 20:49:27 +0400 | [diff] [blame] | 484 | else |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 485 | fsl_spi_cpu_irq(mspi, events); |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 486 | |
| 487 | return ret; |
| 488 | } |
Anton Vorontsov | 4c1fba44 | 2009-10-12 20:49:27 +0400 | [diff] [blame] | 489 | |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 490 | static void fsl_spi_remove(struct mpc8xxx_spi *mspi) |
Anton Vorontsov | 87ec0e9 | 2009-10-12 20:49:25 +0400 | [diff] [blame] | 491 | { |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 492 | iounmap(mspi->reg_base); |
| 493 | fsl_spi_cpm_free(mspi); |
Anton Vorontsov | 87ec0e9 | 2009-10-12 20:49:25 +0400 | [diff] [blame] | 494 | } |
| 495 | |
Grant Likely | fd4a319 | 2012-12-07 16:57:14 +0000 | [diff] [blame] | 496 | static struct spi_master * fsl_spi_probe(struct device *dev, |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 497 | struct resource *mem, unsigned int irq) |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 498 | { |
Anton Vorontsov | 35b4b3c | 2009-03-31 15:24:37 -0700 | [diff] [blame] | 499 | struct fsl_spi_platform_data *pdata = dev->platform_data; |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 500 | struct spi_master *master; |
Anton Vorontsov | 575c580 | 2009-06-18 16:49:08 -0700 | [diff] [blame] | 501 | struct mpc8xxx_spi *mpc8xxx_spi; |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 502 | struct fsl_spi_reg *reg_base; |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 503 | u32 regval; |
| 504 | int ret = 0; |
| 505 | |
Anton Vorontsov | 575c580 | 2009-06-18 16:49:08 -0700 | [diff] [blame] | 506 | master = spi_alloc_master(dev, sizeof(struct mpc8xxx_spi)); |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 507 | if (master == NULL) { |
| 508 | ret = -ENOMEM; |
| 509 | goto err; |
| 510 | } |
| 511 | |
Anton Vorontsov | 35b4b3c | 2009-03-31 15:24:37 -0700 | [diff] [blame] | 512 | dev_set_drvdata(dev, master); |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 513 | |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 514 | ret = mpc8xxx_spi_probe(dev, mem, irq); |
| 515 | if (ret) |
| 516 | goto err_probe; |
David Brownell | e7db06b | 2009-06-17 16:26:04 -0700 | [diff] [blame] | 517 | |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 518 | master->setup = fsl_spi_setup; |
Joakim Tjernlund | c9bfcb3 | 2008-05-12 14:02:30 -0700 | [diff] [blame] | 519 | |
Anton Vorontsov | 575c580 | 2009-06-18 16:49:08 -0700 | [diff] [blame] | 520 | mpc8xxx_spi = spi_master_get_devdata(master); |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 521 | mpc8xxx_spi->spi_do_one_msg = fsl_spi_do_one_msg; |
| 522 | mpc8xxx_spi->spi_remove = fsl_spi_remove; |
Andreas Larsson | c3f3e77 | 2013-02-15 16:52:24 +0100 | [diff] [blame^] | 523 | mpc8xxx_spi->type = fsl_spi_get_type(dev); |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 524 | |
| 525 | ret = fsl_spi_cpm_init(mpc8xxx_spi); |
Anton Vorontsov | 4c1fba44 | 2009-10-12 20:49:27 +0400 | [diff] [blame] | 526 | if (ret) |
| 527 | goto err_cpm_init; |
| 528 | |
Andreas Larsson | b48c4e3 | 2013-02-15 16:52:23 +0100 | [diff] [blame] | 529 | if (mpc8xxx_spi->flags & SPI_QE_CPU_MODE) |
| 530 | mpc8xxx_spi->set_shifts = fsl_spi_qe_cpu_set_shifts; |
| 531 | |
| 532 | if (mpc8xxx_spi->set_shifts) |
| 533 | /* 8 bits per word and MSB first */ |
| 534 | mpc8xxx_spi->set_shifts(&mpc8xxx_spi->rx_shift, |
| 535 | &mpc8xxx_spi->tx_shift, 8, 1); |
Joakim Tjernlund | f29ba28 | 2007-07-17 04:04:12 -0700 | [diff] [blame] | 536 | |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 537 | mpc8xxx_spi->reg_base = ioremap(mem->start, resource_size(mem)); |
| 538 | if (mpc8xxx_spi->reg_base == NULL) { |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 539 | ret = -ENOMEM; |
Anton Vorontsov | 4c1fba44 | 2009-10-12 20:49:27 +0400 | [diff] [blame] | 540 | goto err_ioremap; |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 541 | } |
| 542 | |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 543 | /* Register for SPI Interrupt */ |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 544 | ret = request_irq(mpc8xxx_spi->irq, fsl_spi_irq, |
| 545 | 0, "fsl_spi", mpc8xxx_spi); |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 546 | |
| 547 | if (ret != 0) |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 548 | goto free_irq; |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 549 | |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 550 | reg_base = mpc8xxx_spi->reg_base; |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 551 | |
| 552 | /* SPI controller initializations */ |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 553 | mpc8xxx_spi_write_reg(®_base->mode, 0); |
| 554 | mpc8xxx_spi_write_reg(®_base->mask, 0); |
| 555 | mpc8xxx_spi_write_reg(®_base->command, 0); |
| 556 | mpc8xxx_spi_write_reg(®_base->event, 0xffffffff); |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 557 | |
| 558 | /* Enable SPI interface */ |
| 559 | regval = pdata->initial_spmode | SPMODE_INIT_VAL | SPMODE_ENABLE; |
Anton Vorontsov | 87ec0e9 | 2009-10-12 20:49:25 +0400 | [diff] [blame] | 560 | if (mpc8xxx_spi->flags & SPI_QE_CPU_MODE) |
Joakim Tjernlund | f29ba28 | 2007-07-17 04:04:12 -0700 | [diff] [blame] | 561 | regval |= SPMODE_OP; |
| 562 | |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 563 | mpc8xxx_spi_write_reg(®_base->mode, regval); |
Joakim Tjernlund | c9bfcb3 | 2008-05-12 14:02:30 -0700 | [diff] [blame] | 564 | |
| 565 | ret = spi_register_master(master); |
| 566 | if (ret < 0) |
| 567 | goto unreg_master; |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 568 | |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 569 | dev_info(dev, "at 0x%p (irq = %d), %s mode\n", reg_base, |
Anton Vorontsov | 87ec0e9 | 2009-10-12 20:49:25 +0400 | [diff] [blame] | 570 | mpc8xxx_spi->irq, mpc8xxx_spi_strmode(mpc8xxx_spi->flags)); |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 571 | |
Anton Vorontsov | 35b4b3c | 2009-03-31 15:24:37 -0700 | [diff] [blame] | 572 | return master; |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 573 | |
Joakim Tjernlund | c9bfcb3 | 2008-05-12 14:02:30 -0700 | [diff] [blame] | 574 | unreg_master: |
Anton Vorontsov | 575c580 | 2009-06-18 16:49:08 -0700 | [diff] [blame] | 575 | free_irq(mpc8xxx_spi->irq, mpc8xxx_spi); |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 576 | free_irq: |
| 577 | iounmap(mpc8xxx_spi->reg_base); |
Anton Vorontsov | 4c1fba44 | 2009-10-12 20:49:27 +0400 | [diff] [blame] | 578 | err_ioremap: |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 579 | fsl_spi_cpm_free(mpc8xxx_spi); |
Anton Vorontsov | 4c1fba44 | 2009-10-12 20:49:27 +0400 | [diff] [blame] | 580 | err_cpm_init: |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 581 | err_probe: |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 582 | spi_master_put(master); |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 583 | err: |
Anton Vorontsov | 35b4b3c | 2009-03-31 15:24:37 -0700 | [diff] [blame] | 584 | return ERR_PTR(ret); |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 585 | } |
| 586 | |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 587 | static void fsl_spi_cs_control(struct spi_device *spi, bool on) |
Anton Vorontsov | 35b4b3c | 2009-03-31 15:24:37 -0700 | [diff] [blame] | 588 | { |
Herton Ronaldo Krzesinski | 067aa48 | 2012-05-11 15:29:50 -0700 | [diff] [blame] | 589 | struct device *dev = spi->dev.parent->parent; |
Anton Vorontsov | 575c580 | 2009-06-18 16:49:08 -0700 | [diff] [blame] | 590 | struct mpc8xxx_spi_probe_info *pinfo = to_of_pinfo(dev->platform_data); |
Anton Vorontsov | 35b4b3c | 2009-03-31 15:24:37 -0700 | [diff] [blame] | 591 | u16 cs = spi->chip_select; |
| 592 | int gpio = pinfo->gpios[cs]; |
| 593 | bool alow = pinfo->alow_flags[cs]; |
| 594 | |
| 595 | gpio_set_value(gpio, on ^ alow); |
| 596 | } |
| 597 | |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 598 | static int of_fsl_spi_get_chipselects(struct device *dev) |
Anton Vorontsov | 35b4b3c | 2009-03-31 15:24:37 -0700 | [diff] [blame] | 599 | { |
Grant Likely | 61c7a08 | 2010-04-13 16:12:29 -0700 | [diff] [blame] | 600 | struct device_node *np = dev->of_node; |
Anton Vorontsov | 35b4b3c | 2009-03-31 15:24:37 -0700 | [diff] [blame] | 601 | struct fsl_spi_platform_data *pdata = dev->platform_data; |
Anton Vorontsov | 575c580 | 2009-06-18 16:49:08 -0700 | [diff] [blame] | 602 | struct mpc8xxx_spi_probe_info *pinfo = to_of_pinfo(pdata); |
Grant Likely | e80beb2 | 2013-02-12 17:48:37 +0000 | [diff] [blame] | 603 | int ngpios; |
Anton Vorontsov | 35b4b3c | 2009-03-31 15:24:37 -0700 | [diff] [blame] | 604 | int i = 0; |
| 605 | int ret; |
| 606 | |
| 607 | ngpios = of_gpio_count(np); |
Grant Likely | e80beb2 | 2013-02-12 17:48:37 +0000 | [diff] [blame] | 608 | if (ngpios <= 0) { |
Anton Vorontsov | 35b4b3c | 2009-03-31 15:24:37 -0700 | [diff] [blame] | 609 | /* |
| 610 | * SPI w/o chip-select line. One SPI device is still permitted |
| 611 | * though. |
| 612 | */ |
| 613 | pdata->max_chipselect = 1; |
| 614 | return 0; |
| 615 | } |
| 616 | |
Roel Kluin | 0214154 | 2009-06-16 15:31:15 -0700 | [diff] [blame] | 617 | pinfo->gpios = kmalloc(ngpios * sizeof(*pinfo->gpios), GFP_KERNEL); |
Anton Vorontsov | 35b4b3c | 2009-03-31 15:24:37 -0700 | [diff] [blame] | 618 | if (!pinfo->gpios) |
| 619 | return -ENOMEM; |
Roel Kluin | 0214154 | 2009-06-16 15:31:15 -0700 | [diff] [blame] | 620 | memset(pinfo->gpios, -1, ngpios * sizeof(*pinfo->gpios)); |
Anton Vorontsov | 35b4b3c | 2009-03-31 15:24:37 -0700 | [diff] [blame] | 621 | |
Roel Kluin | 0214154 | 2009-06-16 15:31:15 -0700 | [diff] [blame] | 622 | pinfo->alow_flags = kzalloc(ngpios * sizeof(*pinfo->alow_flags), |
Anton Vorontsov | 35b4b3c | 2009-03-31 15:24:37 -0700 | [diff] [blame] | 623 | GFP_KERNEL); |
| 624 | if (!pinfo->alow_flags) { |
| 625 | ret = -ENOMEM; |
| 626 | goto err_alloc_flags; |
| 627 | } |
| 628 | |
| 629 | for (; i < ngpios; i++) { |
| 630 | int gpio; |
| 631 | enum of_gpio_flags flags; |
| 632 | |
| 633 | gpio = of_get_gpio_flags(np, i, &flags); |
| 634 | if (!gpio_is_valid(gpio)) { |
| 635 | dev_err(dev, "invalid gpio #%d: %d\n", i, gpio); |
Anton Vorontsov | 783058f | 2009-10-12 20:49:22 +0400 | [diff] [blame] | 636 | ret = gpio; |
Anton Vorontsov | 35b4b3c | 2009-03-31 15:24:37 -0700 | [diff] [blame] | 637 | goto err_loop; |
| 638 | } |
| 639 | |
| 640 | ret = gpio_request(gpio, dev_name(dev)); |
| 641 | if (ret) { |
| 642 | dev_err(dev, "can't request gpio #%d: %d\n", i, ret); |
| 643 | goto err_loop; |
| 644 | } |
| 645 | |
| 646 | pinfo->gpios[i] = gpio; |
| 647 | pinfo->alow_flags[i] = flags & OF_GPIO_ACTIVE_LOW; |
| 648 | |
| 649 | ret = gpio_direction_output(pinfo->gpios[i], |
| 650 | pinfo->alow_flags[i]); |
| 651 | if (ret) { |
| 652 | dev_err(dev, "can't set output direction for gpio " |
| 653 | "#%d: %d\n", i, ret); |
| 654 | goto err_loop; |
| 655 | } |
| 656 | } |
| 657 | |
| 658 | pdata->max_chipselect = ngpios; |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 659 | pdata->cs_control = fsl_spi_cs_control; |
Anton Vorontsov | 35b4b3c | 2009-03-31 15:24:37 -0700 | [diff] [blame] | 660 | |
| 661 | return 0; |
| 662 | |
| 663 | err_loop: |
| 664 | while (i >= 0) { |
| 665 | if (gpio_is_valid(pinfo->gpios[i])) |
| 666 | gpio_free(pinfo->gpios[i]); |
| 667 | i--; |
| 668 | } |
| 669 | |
| 670 | kfree(pinfo->alow_flags); |
| 671 | pinfo->alow_flags = NULL; |
| 672 | err_alloc_flags: |
| 673 | kfree(pinfo->gpios); |
| 674 | pinfo->gpios = NULL; |
| 675 | return ret; |
| 676 | } |
| 677 | |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 678 | static int of_fsl_spi_free_chipselects(struct device *dev) |
Anton Vorontsov | 35b4b3c | 2009-03-31 15:24:37 -0700 | [diff] [blame] | 679 | { |
| 680 | struct fsl_spi_platform_data *pdata = dev->platform_data; |
Anton Vorontsov | 575c580 | 2009-06-18 16:49:08 -0700 | [diff] [blame] | 681 | struct mpc8xxx_spi_probe_info *pinfo = to_of_pinfo(pdata); |
Anton Vorontsov | 35b4b3c | 2009-03-31 15:24:37 -0700 | [diff] [blame] | 682 | int i; |
| 683 | |
| 684 | if (!pinfo->gpios) |
| 685 | return 0; |
| 686 | |
| 687 | for (i = 0; i < pdata->max_chipselect; i++) { |
| 688 | if (gpio_is_valid(pinfo->gpios[i])) |
| 689 | gpio_free(pinfo->gpios[i]); |
| 690 | } |
| 691 | |
| 692 | kfree(pinfo->gpios); |
| 693 | kfree(pinfo->alow_flags); |
| 694 | return 0; |
| 695 | } |
| 696 | |
Grant Likely | fd4a319 | 2012-12-07 16:57:14 +0000 | [diff] [blame] | 697 | static int of_fsl_spi_probe(struct platform_device *ofdev) |
Anton Vorontsov | 35b4b3c | 2009-03-31 15:24:37 -0700 | [diff] [blame] | 698 | { |
| 699 | struct device *dev = &ofdev->dev; |
Grant Likely | 61c7a08 | 2010-04-13 16:12:29 -0700 | [diff] [blame] | 700 | struct device_node *np = ofdev->dev.of_node; |
Anton Vorontsov | 35b4b3c | 2009-03-31 15:24:37 -0700 | [diff] [blame] | 701 | struct spi_master *master; |
| 702 | struct resource mem; |
Andreas Larsson | e8beacb | 2013-02-15 16:52:21 +0100 | [diff] [blame] | 703 | int irq; |
Anton Vorontsov | 35b4b3c | 2009-03-31 15:24:37 -0700 | [diff] [blame] | 704 | int ret = -ENOMEM; |
| 705 | |
Grant Likely | 18d306d | 2011-02-22 21:02:43 -0700 | [diff] [blame] | 706 | ret = of_mpc8xxx_spi_probe(ofdev); |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 707 | if (ret) |
| 708 | return ret; |
Anton Vorontsov | 35b4b3c | 2009-03-31 15:24:37 -0700 | [diff] [blame] | 709 | |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 710 | ret = of_fsl_spi_get_chipselects(dev); |
Anton Vorontsov | 35b4b3c | 2009-03-31 15:24:37 -0700 | [diff] [blame] | 711 | if (ret) |
| 712 | goto err; |
| 713 | |
| 714 | ret = of_address_to_resource(np, 0, &mem); |
| 715 | if (ret) |
| 716 | goto err; |
| 717 | |
Andreas Larsson | e8beacb | 2013-02-15 16:52:21 +0100 | [diff] [blame] | 718 | irq = irq_of_parse_and_map(np, 0); |
| 719 | if (!irq) { |
Anton Vorontsov | 35b4b3c | 2009-03-31 15:24:37 -0700 | [diff] [blame] | 720 | ret = -EINVAL; |
| 721 | goto err; |
| 722 | } |
| 723 | |
Andreas Larsson | e8beacb | 2013-02-15 16:52:21 +0100 | [diff] [blame] | 724 | master = fsl_spi_probe(dev, &mem, irq); |
Anton Vorontsov | 35b4b3c | 2009-03-31 15:24:37 -0700 | [diff] [blame] | 725 | if (IS_ERR(master)) { |
| 726 | ret = PTR_ERR(master); |
| 727 | goto err; |
| 728 | } |
| 729 | |
Anton Vorontsov | 35b4b3c | 2009-03-31 15:24:37 -0700 | [diff] [blame] | 730 | return 0; |
| 731 | |
| 732 | err: |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 733 | of_fsl_spi_free_chipselects(dev); |
Anton Vorontsov | 35b4b3c | 2009-03-31 15:24:37 -0700 | [diff] [blame] | 734 | return ret; |
| 735 | } |
| 736 | |
Grant Likely | fd4a319 | 2012-12-07 16:57:14 +0000 | [diff] [blame] | 737 | static int of_fsl_spi_remove(struct platform_device *ofdev) |
Anton Vorontsov | 35b4b3c | 2009-03-31 15:24:37 -0700 | [diff] [blame] | 738 | { |
| 739 | int ret; |
| 740 | |
Anton Vorontsov | 575c580 | 2009-06-18 16:49:08 -0700 | [diff] [blame] | 741 | ret = mpc8xxx_spi_remove(&ofdev->dev); |
Anton Vorontsov | 35b4b3c | 2009-03-31 15:24:37 -0700 | [diff] [blame] | 742 | if (ret) |
| 743 | return ret; |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 744 | of_fsl_spi_free_chipselects(&ofdev->dev); |
Anton Vorontsov | 35b4b3c | 2009-03-31 15:24:37 -0700 | [diff] [blame] | 745 | return 0; |
| 746 | } |
| 747 | |
Grant Likely | 18d306d | 2011-02-22 21:02:43 -0700 | [diff] [blame] | 748 | static struct platform_driver of_fsl_spi_driver = { |
Grant Likely | 4018294 | 2010-04-13 16:13:02 -0700 | [diff] [blame] | 749 | .driver = { |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 750 | .name = "fsl_spi", |
Grant Likely | 4018294 | 2010-04-13 16:13:02 -0700 | [diff] [blame] | 751 | .owner = THIS_MODULE, |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 752 | .of_match_table = of_fsl_spi_match, |
Grant Likely | 4018294 | 2010-04-13 16:13:02 -0700 | [diff] [blame] | 753 | }, |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 754 | .probe = of_fsl_spi_probe, |
Grant Likely | fd4a319 | 2012-12-07 16:57:14 +0000 | [diff] [blame] | 755 | .remove = of_fsl_spi_remove, |
Anton Vorontsov | 35b4b3c | 2009-03-31 15:24:37 -0700 | [diff] [blame] | 756 | }; |
| 757 | |
| 758 | #ifdef CONFIG_MPC832x_RDB |
| 759 | /* |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 760 | * XXX XXX XXX |
Anton Vorontsov | 35b4b3c | 2009-03-31 15:24:37 -0700 | [diff] [blame] | 761 | * This is "legacy" platform driver, was used by the MPC8323E-RDB boards |
| 762 | * only. The driver should go away soon, since newer MPC8323E-RDB's device |
| 763 | * tree can work with OpenFirmware driver. But for now we support old trees |
| 764 | * as well. |
| 765 | */ |
Grant Likely | fd4a319 | 2012-12-07 16:57:14 +0000 | [diff] [blame] | 766 | static int plat_mpc8xxx_spi_probe(struct platform_device *pdev) |
Anton Vorontsov | 35b4b3c | 2009-03-31 15:24:37 -0700 | [diff] [blame] | 767 | { |
| 768 | struct resource *mem; |
Uwe Kleine-König | e9a172f | 2010-01-20 13:49:44 -0700 | [diff] [blame] | 769 | int irq; |
Anton Vorontsov | 35b4b3c | 2009-03-31 15:24:37 -0700 | [diff] [blame] | 770 | struct spi_master *master; |
| 771 | |
| 772 | if (!pdev->dev.platform_data) |
| 773 | return -EINVAL; |
| 774 | |
| 775 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 776 | if (!mem) |
| 777 | return -EINVAL; |
| 778 | |
| 779 | irq = platform_get_irq(pdev, 0); |
Uwe Kleine-König | e9a172f | 2010-01-20 13:49:44 -0700 | [diff] [blame] | 780 | if (irq <= 0) |
Anton Vorontsov | 35b4b3c | 2009-03-31 15:24:37 -0700 | [diff] [blame] | 781 | return -EINVAL; |
| 782 | |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 783 | master = fsl_spi_probe(&pdev->dev, mem, irq); |
Alexandru Gheorghiu | e4d4378 | 2013-03-14 11:07:31 +0200 | [diff] [blame] | 784 | return PTR_RET(master); |
Anton Vorontsov | 35b4b3c | 2009-03-31 15:24:37 -0700 | [diff] [blame] | 785 | } |
| 786 | |
Grant Likely | fd4a319 | 2012-12-07 16:57:14 +0000 | [diff] [blame] | 787 | static int plat_mpc8xxx_spi_remove(struct platform_device *pdev) |
Anton Vorontsov | 35b4b3c | 2009-03-31 15:24:37 -0700 | [diff] [blame] | 788 | { |
Anton Vorontsov | 575c580 | 2009-06-18 16:49:08 -0700 | [diff] [blame] | 789 | return mpc8xxx_spi_remove(&pdev->dev); |
Anton Vorontsov | 35b4b3c | 2009-03-31 15:24:37 -0700 | [diff] [blame] | 790 | } |
| 791 | |
Anton Vorontsov | 575c580 | 2009-06-18 16:49:08 -0700 | [diff] [blame] | 792 | MODULE_ALIAS("platform:mpc8xxx_spi"); |
| 793 | static struct platform_driver mpc8xxx_spi_driver = { |
| 794 | .probe = plat_mpc8xxx_spi_probe, |
Grant Likely | fd4a319 | 2012-12-07 16:57:14 +0000 | [diff] [blame] | 795 | .remove = plat_mpc8xxx_spi_remove, |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 796 | .driver = { |
Anton Vorontsov | 575c580 | 2009-06-18 16:49:08 -0700 | [diff] [blame] | 797 | .name = "mpc8xxx_spi", |
Kay Sievers | 7e38c3c | 2008-04-10 21:29:20 -0700 | [diff] [blame] | 798 | .owner = THIS_MODULE, |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 799 | }, |
| 800 | }; |
| 801 | |
Anton Vorontsov | 35b4b3c | 2009-03-31 15:24:37 -0700 | [diff] [blame] | 802 | static bool legacy_driver_failed; |
| 803 | |
| 804 | static void __init legacy_driver_register(void) |
| 805 | { |
Anton Vorontsov | 575c580 | 2009-06-18 16:49:08 -0700 | [diff] [blame] | 806 | legacy_driver_failed = platform_driver_register(&mpc8xxx_spi_driver); |
Anton Vorontsov | 35b4b3c | 2009-03-31 15:24:37 -0700 | [diff] [blame] | 807 | } |
| 808 | |
| 809 | static void __exit legacy_driver_unregister(void) |
| 810 | { |
| 811 | if (legacy_driver_failed) |
| 812 | return; |
Anton Vorontsov | 575c580 | 2009-06-18 16:49:08 -0700 | [diff] [blame] | 813 | platform_driver_unregister(&mpc8xxx_spi_driver); |
Anton Vorontsov | 35b4b3c | 2009-03-31 15:24:37 -0700 | [diff] [blame] | 814 | } |
| 815 | #else |
| 816 | static void __init legacy_driver_register(void) {} |
| 817 | static void __exit legacy_driver_unregister(void) {} |
| 818 | #endif /* CONFIG_MPC832x_RDB */ |
| 819 | |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 820 | static int __init fsl_spi_init(void) |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 821 | { |
Anton Vorontsov | 35b4b3c | 2009-03-31 15:24:37 -0700 | [diff] [blame] | 822 | legacy_driver_register(); |
Grant Likely | 18d306d | 2011-02-22 21:02:43 -0700 | [diff] [blame] | 823 | return platform_driver_register(&of_fsl_spi_driver); |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 824 | } |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 825 | module_init(fsl_spi_init); |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 826 | |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 827 | static void __exit fsl_spi_exit(void) |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 828 | { |
Grant Likely | 18d306d | 2011-02-22 21:02:43 -0700 | [diff] [blame] | 829 | platform_driver_unregister(&of_fsl_spi_driver); |
Anton Vorontsov | 35b4b3c | 2009-03-31 15:24:37 -0700 | [diff] [blame] | 830 | legacy_driver_unregister(); |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 831 | } |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 832 | module_exit(fsl_spi_exit); |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 833 | |
| 834 | MODULE_AUTHOR("Kumar Gala"); |
Mingkai Hu | b36ece8 | 2010-10-12 18:18:31 +0800 | [diff] [blame] | 835 | MODULE_DESCRIPTION("Simple Freescale SPI Driver"); |
Kumar Gala | ccf0699 | 2006-05-20 15:00:15 -0700 | [diff] [blame] | 836 | MODULE_LICENSE("GPL"); |