Dirk Behme | 53736ba | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Register definitions for the OMAP3 McSPI Controller |
| 3 | * |
| 4 | * Copyright (C) 2010 Dirk Behme <dirk.behme@googlemail.com> |
| 5 | * |
| 6 | * Parts taken from linux/drivers/spi/omap2_mcspi.c |
| 7 | * Copyright (C) 2005, 2006 Nokia Corporation |
| 8 | * |
| 9 | * Modified by Ruslan Araslanov <ruslan.araslanov@vitecmm.com> |
| 10 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 11 | * SPDX-License-Identifier: GPL-2.0+ |
Dirk Behme | 53736ba | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 12 | */ |
| 13 | |
| 14 | #ifndef _OMAP3_SPI_H_ |
| 15 | #define _OMAP3_SPI_H_ |
| 16 | |
Nikita Kiryanov | 2ff9762 | 2015-07-30 23:56:18 +0300 | [diff] [blame] | 17 | #if defined(CONFIG_AM33XX) || defined(CONFIG_AM43XX) |
Tom Rini | 4c0620b | 2012-08-08 14:29:51 -0700 | [diff] [blame] | 18 | #define OMAP3_MCSPI1_BASE 0x48030100 |
| 19 | #define OMAP3_MCSPI2_BASE 0x481A0100 |
| 20 | #else |
Dirk Behme | 53736ba | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 21 | #define OMAP3_MCSPI1_BASE 0x48098000 |
| 22 | #define OMAP3_MCSPI2_BASE 0x4809A000 |
| 23 | #define OMAP3_MCSPI3_BASE 0x480B8000 |
| 24 | #define OMAP3_MCSPI4_BASE 0x480BA000 |
Tom Rini | 4c0620b | 2012-08-08 14:29:51 -0700 | [diff] [blame] | 25 | #endif |
Dirk Behme | 53736ba | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 26 | |
| 27 | #define OMAP3_MCSPI_MAX_FREQ 48000000 |
| 28 | |
| 29 | /* OMAP3 McSPI registers */ |
| 30 | struct mcspi_channel { |
| 31 | unsigned int chconf; /* 0x2C, 0x40, 0x54, 0x68 */ |
| 32 | unsigned int chstat; /* 0x30, 0x44, 0x58, 0x6C */ |
| 33 | unsigned int chctrl; /* 0x34, 0x48, 0x5C, 0x70 */ |
| 34 | unsigned int tx; /* 0x38, 0x4C, 0x60, 0x74 */ |
| 35 | unsigned int rx; /* 0x3C, 0x50, 0x64, 0x78 */ |
| 36 | }; |
| 37 | |
| 38 | struct mcspi { |
| 39 | unsigned char res1[0x10]; |
| 40 | unsigned int sysconfig; /* 0x10 */ |
| 41 | unsigned int sysstatus; /* 0x14 */ |
| 42 | unsigned int irqstatus; /* 0x18 */ |
| 43 | unsigned int irqenable; /* 0x1C */ |
| 44 | unsigned int wakeupenable; /* 0x20 */ |
| 45 | unsigned int syst; /* 0x24 */ |
| 46 | unsigned int modulctrl; /* 0x28 */ |
| 47 | struct mcspi_channel channel[4]; /* channel0: 0x2C - 0x3C, bus 0 & 1 & 2 & 3 */ |
| 48 | /* channel1: 0x40 - 0x50, bus 0 & 1 */ |
| 49 | /* channel2: 0x54 - 0x64, bus 0 & 1 */ |
| 50 | /* channel3: 0x68 - 0x78, bus 0 */ |
| 51 | }; |
| 52 | |
| 53 | /* per-register bitmasks */ |
| 54 | #define OMAP3_MCSPI_SYSCONFIG_SMARTIDLE (2 << 3) |
Jagan Teki | 3e1b4dc | 2015-10-23 01:38:32 +0530 | [diff] [blame] | 55 | #define OMAP3_MCSPI_SYSCONFIG_ENAWAKEUP BIT(2) |
| 56 | #define OMAP3_MCSPI_SYSCONFIG_AUTOIDLE BIT(0) |
| 57 | #define OMAP3_MCSPI_SYSCONFIG_SOFTRESET BIT(1) |
Dirk Behme | 53736ba | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 58 | |
Jagan Teki | 3e1b4dc | 2015-10-23 01:38:32 +0530 | [diff] [blame] | 59 | #define OMAP3_MCSPI_SYSSTATUS_RESETDONE BIT(0) |
Dirk Behme | 53736ba | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 60 | |
Jagan Teki | 3e1b4dc | 2015-10-23 01:38:32 +0530 | [diff] [blame] | 61 | #define OMAP3_MCSPI_MODULCTRL_SINGLE BIT(0) |
| 62 | #define OMAP3_MCSPI_MODULCTRL_MS BIT(2) |
| 63 | #define OMAP3_MCSPI_MODULCTRL_STEST BIT(3) |
Dirk Behme | 53736ba | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 64 | |
Jagan Teki | 3e1b4dc | 2015-10-23 01:38:32 +0530 | [diff] [blame] | 65 | #define OMAP3_MCSPI_CHCONF_PHA BIT(0) |
| 66 | #define OMAP3_MCSPI_CHCONF_POL BIT(1) |
Jagan Teki | 0ebc0ec | 2015-10-23 01:02:49 +0530 | [diff] [blame] | 67 | #define OMAP3_MCSPI_CHCONF_CLKD_MASK GENMASK(5, 2) |
Jagan Teki | 3e1b4dc | 2015-10-23 01:38:32 +0530 | [diff] [blame] | 68 | #define OMAP3_MCSPI_CHCONF_EPOL BIT(6) |
Jagan Teki | 0ebc0ec | 2015-10-23 01:02:49 +0530 | [diff] [blame] | 69 | #define OMAP3_MCSPI_CHCONF_WL_MASK GENMASK(11, 7) |
| 70 | #define OMAP3_MCSPI_CHCONF_TRM_RX_ONLY BIT(12) |
| 71 | #define OMAP3_MCSPI_CHCONF_TRM_TX_ONLY BIT(13) |
| 72 | #define OMAP3_MCSPI_CHCONF_TRM_MASK GENMASK(13, 12) |
Jagan Teki | 3e1b4dc | 2015-10-23 01:38:32 +0530 | [diff] [blame] | 73 | #define OMAP3_MCSPI_CHCONF_DMAW BIT(14) |
| 74 | #define OMAP3_MCSPI_CHCONF_DMAR BIT(15) |
| 75 | #define OMAP3_MCSPI_CHCONF_DPE0 BIT(16) |
| 76 | #define OMAP3_MCSPI_CHCONF_DPE1 BIT(17) |
| 77 | #define OMAP3_MCSPI_CHCONF_IS BIT(18) |
| 78 | #define OMAP3_MCSPI_CHCONF_TURBO BIT(19) |
| 79 | #define OMAP3_MCSPI_CHCONF_FORCE BIT(20) |
Dirk Behme | 53736ba | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 80 | |
Jagan Teki | 3e1b4dc | 2015-10-23 01:38:32 +0530 | [diff] [blame] | 81 | #define OMAP3_MCSPI_CHSTAT_RXS BIT(0) |
| 82 | #define OMAP3_MCSPI_CHSTAT_TXS BIT(1) |
| 83 | #define OMAP3_MCSPI_CHSTAT_EOT BIT(2) |
Dirk Behme | 53736ba | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 84 | |
Jagan Teki | 3e1b4dc | 2015-10-23 01:38:32 +0530 | [diff] [blame] | 85 | #define OMAP3_MCSPI_CHCTRL_EN BIT(0) |
ajoy | cc1182b | 2012-11-17 21:10:15 +0000 | [diff] [blame] | 86 | #define OMAP3_MCSPI_CHCTRL_DIS (0 << 0) |
Dirk Behme | 53736ba | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 87 | |
Jagan Teki | 3e1b4dc | 2015-10-23 01:38:32 +0530 | [diff] [blame] | 88 | #define OMAP3_MCSPI_WAKEUPENABLE_WKEN BIT(0) |
Dirk Behme | 53736ba | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 89 | |
| 90 | struct omap3_spi_slave { |
| 91 | struct spi_slave slave; |
| 92 | struct mcspi *regs; |
| 93 | unsigned int freq; |
| 94 | unsigned int mode; |
| 95 | }; |
| 96 | |
| 97 | static inline struct omap3_spi_slave *to_omap3_spi(struct spi_slave *slave) |
| 98 | { |
| 99 | return container_of(slave, struct omap3_spi_slave, slave); |
| 100 | } |
| 101 | |
Nikita Kiryanov | 5753d09 | 2013-10-16 17:23:25 +0300 | [diff] [blame] | 102 | int omap3_spi_txrx(struct spi_slave *slave, unsigned int len, const void *txp, |
| 103 | void *rxp, unsigned long flags); |
| 104 | int omap3_spi_write(struct spi_slave *slave, unsigned int len, const void *txp, |
Dirk Behme | 53736ba | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 105 | unsigned long flags); |
Nikita Kiryanov | 5753d09 | 2013-10-16 17:23:25 +0300 | [diff] [blame] | 106 | int omap3_spi_read(struct spi_slave *slave, unsigned int len, void *rxp, |
Dirk Behme | 53736ba | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 107 | unsigned long flags); |
| 108 | |
| 109 | #endif /* _OMAP3_SPI_H_ */ |