.. | .. |
---|
242 | 242 | return true; |
---|
243 | 243 | } |
---|
244 | 244 | |
---|
| 245 | +/* |
---|
| 246 | + * Note the number of natively supported chip selects for MX51 is 4. Some |
---|
| 247 | + * devices may have less actual SS pins but the register map supports 4. When |
---|
| 248 | + * using gpio chip selects the cs values passed into the macros below can go |
---|
| 249 | + * outside the range 0 - 3. We therefore need to limit the cs value to avoid |
---|
| 250 | + * corrupting bits outside the allocated locations. |
---|
| 251 | + * |
---|
| 252 | + * The simplest way to do this is to just mask the cs bits to 2 bits. This |
---|
| 253 | + * still allows all 4 native chip selects to work as well as gpio chip selects |
---|
| 254 | + * (which can use any of the 4 chip select configurations). |
---|
| 255 | + */ |
---|
| 256 | + |
---|
245 | 257 | #define MX51_ECSPI_CTRL 0x08 |
---|
246 | 258 | #define MX51_ECSPI_CTRL_ENABLE (1 << 0) |
---|
247 | 259 | #define MX51_ECSPI_CTRL_XCH (1 << 2) |
---|
.. | .. |
---|
250 | 262 | #define MX51_ECSPI_CTRL_DRCTL(drctl) ((drctl) << 16) |
---|
251 | 263 | #define MX51_ECSPI_CTRL_POSTDIV_OFFSET 8 |
---|
252 | 264 | #define MX51_ECSPI_CTRL_PREDIV_OFFSET 12 |
---|
253 | | -#define MX51_ECSPI_CTRL_CS(cs) ((cs) << 18) |
---|
| 265 | +#define MX51_ECSPI_CTRL_CS(cs) ((cs & 3) << 18) |
---|
254 | 266 | #define MX51_ECSPI_CTRL_BL_OFFSET 20 |
---|
255 | 267 | #define MX51_ECSPI_CTRL_BL_MASK (0xfff << 20) |
---|
256 | 268 | |
---|
257 | 269 | #define MX51_ECSPI_CONFIG 0x0c |
---|
258 | | -#define MX51_ECSPI_CONFIG_SCLKPHA(cs) (1 << ((cs) + 0)) |
---|
259 | | -#define MX51_ECSPI_CONFIG_SCLKPOL(cs) (1 << ((cs) + 4)) |
---|
260 | | -#define MX51_ECSPI_CONFIG_SBBCTRL(cs) (1 << ((cs) + 8)) |
---|
261 | | -#define MX51_ECSPI_CONFIG_SSBPOL(cs) (1 << ((cs) + 12)) |
---|
262 | | -#define MX51_ECSPI_CONFIG_SCLKCTL(cs) (1 << ((cs) + 20)) |
---|
| 270 | +#define MX51_ECSPI_CONFIG_SCLKPHA(cs) (1 << ((cs & 3) + 0)) |
---|
| 271 | +#define MX51_ECSPI_CONFIG_SCLKPOL(cs) (1 << ((cs & 3) + 4)) |
---|
| 272 | +#define MX51_ECSPI_CONFIG_SBBCTRL(cs) (1 << ((cs & 3) + 8)) |
---|
| 273 | +#define MX51_ECSPI_CONFIG_SSBPOL(cs) (1 << ((cs & 3) + 12)) |
---|
| 274 | +#define MX51_ECSPI_CONFIG_SCLKCTL(cs) (1 << ((cs & 3) + 20)) |
---|
263 | 275 | |
---|
264 | 276 | #define MX51_ECSPI_INT 0x10 |
---|
265 | 277 | #define MX51_ECSPI_INT_TEEN (1 << 0) |
---|
.. | .. |
---|
1554 | 1566 | struct spi_imx_data *spi_imx = spi_master_get_devdata(master); |
---|
1555 | 1567 | int ret; |
---|
1556 | 1568 | |
---|
1557 | | - ret = pm_runtime_get_sync(spi_imx->dev); |
---|
| 1569 | + ret = pm_runtime_resume_and_get(spi_imx->dev); |
---|
1558 | 1570 | if (ret < 0) { |
---|
1559 | | - pm_runtime_put_noidle(spi_imx->dev); |
---|
1560 | 1571 | dev_err(spi_imx->dev, "failed to enable clock\n"); |
---|
1561 | 1572 | return ret; |
---|
1562 | 1573 | } |
---|
.. | .. |
---|
1766 | 1777 | spi_bitbang_stop(&spi_imx->bitbang); |
---|
1767 | 1778 | |
---|
1768 | 1779 | ret = pm_runtime_get_sync(spi_imx->dev); |
---|
1769 | | - if (ret < 0) { |
---|
1770 | | - pm_runtime_put_noidle(spi_imx->dev); |
---|
1771 | | - dev_err(spi_imx->dev, "failed to enable clock\n"); |
---|
1772 | | - return ret; |
---|
1773 | | - } |
---|
1774 | | - |
---|
1775 | | - writel(0, spi_imx->base + MXC_CSPICTRL); |
---|
| 1780 | + if (ret >= 0) |
---|
| 1781 | + writel(0, spi_imx->base + MXC_CSPICTRL); |
---|
| 1782 | + else |
---|
| 1783 | + dev_warn(spi_imx->dev, "failed to enable clock, skip hw disable\n"); |
---|
1776 | 1784 | |
---|
1777 | 1785 | pm_runtime_dont_use_autosuspend(spi_imx->dev); |
---|
1778 | 1786 | pm_runtime_put_sync(spi_imx->dev); |
---|