diff options
author | Scott Jiang <scott.jiang.linux@gmail.com> | 2014-04-04 04:27:17 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-04-14 12:45:25 -0400 |
commit | 766e3721990d2c78e0d614b57753f105adbaa8c5 (patch) | |
tree | ad70e47a2d981a096ad604e30ecb3da9b07d2a13 | |
parent | c9eaa447e77efe77b7fa4c953bd62de8297fd6c5 (diff) |
spi: convert spi-bfin-v3.c to a multiplatform driver
Spi v3 controller is not only used on Blackfin. So rename it
and use ioread/iowrite api to make it work on other platform.
Signed-off-by: Scott Jiang <scott.jiang.linux@gmail.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r-- | arch/blackfin/mach-bf609/boards/ezkit.c | 22 | ||||
-rw-r--r-- | drivers/spi/Kconfig | 4 | ||||
-rw-r--r-- | drivers/spi/Makefile | 2 | ||||
-rw-r--r-- | drivers/spi/spi-adi-v3.c (renamed from drivers/spi/spi-bfin-v3.c) | 420 | ||||
-rw-r--r-- | include/linux/spi/adi_spi3.h (renamed from arch/blackfin/include/asm/bfin_spi3.h) | 20 |
5 files changed, 242 insertions, 226 deletions
diff --git a/arch/blackfin/mach-bf609/boards/ezkit.c b/arch/blackfin/mach-bf609/boards/ezkit.c index 943f7e95ec15..1ba4600de69f 100644 --- a/arch/blackfin/mach-bf609/boards/ezkit.c +++ b/arch/blackfin/mach-bf609/boards/ezkit.c | |||
@@ -20,7 +20,7 @@ | |||
20 | #include <linux/pinctrl/machine.h> | 20 | #include <linux/pinctrl/machine.h> |
21 | #include <linux/pinctrl/pinconf-generic.h> | 21 | #include <linux/pinctrl/pinconf-generic.h> |
22 | #include <linux/platform_data/pinctrl-adi2.h> | 22 | #include <linux/platform_data/pinctrl-adi2.h> |
23 | #include <asm/bfin_spi3.h> | 23 | #include <linux/spi/adi_spi3.h> |
24 | #include <asm/dma.h> | 24 | #include <asm/dma.h> |
25 | #include <asm/gpio.h> | 25 | #include <asm/gpio.h> |
26 | #include <asm/nand.h> | 26 | #include <asm/nand.h> |
@@ -767,13 +767,13 @@ static struct flash_platform_data bfin_spi_flash_data = { | |||
767 | .type = "w25q32", | 767 | .type = "w25q32", |
768 | }; | 768 | }; |
769 | 769 | ||
770 | static struct bfin_spi3_chip spi_flash_chip_info = { | 770 | static struct adi_spi3_chip spi_flash_chip_info = { |
771 | .enable_dma = true, /* use dma transfer with this chip*/ | 771 | .enable_dma = true, /* use dma transfer with this chip*/ |
772 | }; | 772 | }; |
773 | #endif | 773 | #endif |
774 | 774 | ||
775 | #if IS_ENABLED(CONFIG_SPI_SPIDEV) | 775 | #if IS_ENABLED(CONFIG_SPI_SPIDEV) |
776 | static struct bfin_spi3_chip spidev_chip_info = { | 776 | static struct adi_spi3_chip spidev_chip_info = { |
777 | .enable_dma = true, | 777 | .enable_dma = true, |
778 | }; | 778 | }; |
779 | #endif | 779 | #endif |
@@ -1736,7 +1736,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = { | |||
1736 | }, | 1736 | }, |
1737 | #endif | 1737 | #endif |
1738 | }; | 1738 | }; |
1739 | #if IS_ENABLED(CONFIG_SPI_BFIN_V3) | 1739 | #if IS_ENABLED(CONFIG_SPI_ADI_V3) |
1740 | /* SPI (0) */ | 1740 | /* SPI (0) */ |
1741 | static struct resource bfin_spi0_resource[] = { | 1741 | static struct resource bfin_spi0_resource[] = { |
1742 | { | 1742 | { |
@@ -1777,13 +1777,13 @@ static struct resource bfin_spi1_resource[] = { | |||
1777 | }; | 1777 | }; |
1778 | 1778 | ||
1779 | /* SPI controller data */ | 1779 | /* SPI controller data */ |
1780 | static struct bfin_spi3_master bf60x_spi_master_info0 = { | 1780 | static struct adi_spi3_master bf60x_spi_master_info0 = { |
1781 | .num_chipselect = MAX_CTRL_CS + MAX_BLACKFIN_GPIOS, | 1781 | .num_chipselect = MAX_CTRL_CS + MAX_BLACKFIN_GPIOS, |
1782 | .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0}, | 1782 | .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0}, |
1783 | }; | 1783 | }; |
1784 | 1784 | ||
1785 | static struct platform_device bf60x_spi_master0 = { | 1785 | static struct platform_device bf60x_spi_master0 = { |
1786 | .name = "bfin-spi3", | 1786 | .name = "adi-spi3", |
1787 | .id = 0, /* Bus number */ | 1787 | .id = 0, /* Bus number */ |
1788 | .num_resources = ARRAY_SIZE(bfin_spi0_resource), | 1788 | .num_resources = ARRAY_SIZE(bfin_spi0_resource), |
1789 | .resource = bfin_spi0_resource, | 1789 | .resource = bfin_spi0_resource, |
@@ -1792,13 +1792,13 @@ static struct platform_device bf60x_spi_master0 = { | |||
1792 | }, | 1792 | }, |
1793 | }; | 1793 | }; |
1794 | 1794 | ||
1795 | static struct bfin_spi3_master bf60x_spi_master_info1 = { | 1795 | static struct adi_spi3_master bf60x_spi_master_info1 = { |
1796 | .num_chipselect = MAX_CTRL_CS + MAX_BLACKFIN_GPIOS, | 1796 | .num_chipselect = MAX_CTRL_CS + MAX_BLACKFIN_GPIOS, |
1797 | .pin_req = {P_SPI1_SCK, P_SPI1_MISO, P_SPI1_MOSI, 0}, | 1797 | .pin_req = {P_SPI1_SCK, P_SPI1_MISO, P_SPI1_MOSI, 0}, |
1798 | }; | 1798 | }; |
1799 | 1799 | ||
1800 | static struct platform_device bf60x_spi_master1 = { | 1800 | static struct platform_device bf60x_spi_master1 = { |
1801 | .name = "bfin-spi3", | 1801 | .name = "adi-spi3", |
1802 | .id = 1, /* Bus number */ | 1802 | .id = 1, /* Bus number */ |
1803 | .num_resources = ARRAY_SIZE(bfin_spi1_resource), | 1803 | .num_resources = ARRAY_SIZE(bfin_spi1_resource), |
1804 | .resource = bfin_spi1_resource, | 1804 | .resource = bfin_spi1_resource, |
@@ -1990,7 +1990,7 @@ static struct platform_device *ezkit_devices[] __initdata = { | |||
1990 | &bfin_sdh_device, | 1990 | &bfin_sdh_device, |
1991 | #endif | 1991 | #endif |
1992 | 1992 | ||
1993 | #if IS_ENABLED(CONFIG_SPI_BFIN_V3) | 1993 | #if IS_ENABLED(CONFIG_SPI_ADI_V3) |
1994 | &bf60x_spi_master0, | 1994 | &bf60x_spi_master0, |
1995 | &bf60x_spi_master1, | 1995 | &bf60x_spi_master1, |
1996 | #endif | 1996 | #endif |
@@ -2051,8 +2051,8 @@ static struct pinctrl_map __initdata bfin_pinmux_map[] = { | |||
2051 | PIN_MAP_MUX_GROUP_DEFAULT("bfin_sir.1", "pinctrl-adi2.0", NULL, "uart1"), | 2051 | PIN_MAP_MUX_GROUP_DEFAULT("bfin_sir.1", "pinctrl-adi2.0", NULL, "uart1"), |
2052 | PIN_MAP_MUX_GROUP_DEFAULT("bfin-sdh.0", "pinctrl-adi2.0", NULL, "rsi0"), | 2052 | PIN_MAP_MUX_GROUP_DEFAULT("bfin-sdh.0", "pinctrl-adi2.0", NULL, "rsi0"), |
2053 | PIN_MAP_MUX_GROUP_DEFAULT("stmmaceth.0", "pinctrl-adi2.0", NULL, "eth0"), | 2053 | PIN_MAP_MUX_GROUP_DEFAULT("stmmaceth.0", "pinctrl-adi2.0", NULL, "eth0"), |
2054 | PIN_MAP_MUX_GROUP_DEFAULT("bfin-spi3.0", "pinctrl-adi2.0", NULL, "spi0"), | 2054 | PIN_MAP_MUX_GROUP_DEFAULT("adi-spi3.0", "pinctrl-adi2.0", NULL, "spi0"), |
2055 | PIN_MAP_MUX_GROUP_DEFAULT("bfin-spi3.1", "pinctrl-adi2.0", NULL, "spi1"), | 2055 | PIN_MAP_MUX_GROUP_DEFAULT("adi-spi3.1", "pinctrl-adi2.0", NULL, "spi1"), |
2056 | PIN_MAP_MUX_GROUP_DEFAULT("i2c-bfin-twi.0", "pinctrl-adi2.0", NULL, "twi0"), | 2056 | PIN_MAP_MUX_GROUP_DEFAULT("i2c-bfin-twi.0", "pinctrl-adi2.0", NULL, "twi0"), |
2057 | PIN_MAP_MUX_GROUP_DEFAULT("i2c-bfin-twi.1", "pinctrl-adi2.0", NULL, "twi1"), | 2057 | PIN_MAP_MUX_GROUP_DEFAULT("i2c-bfin-twi.1", "pinctrl-adi2.0", NULL, "twi1"), |
2058 | PIN_MAP_MUX_GROUP_DEFAULT("bfin-rotary", "pinctrl-adi2.0", NULL, "rotary"), | 2058 | PIN_MAP_MUX_GROUP_DEFAULT("bfin-rotary", "pinctrl-adi2.0", NULL, "rotary"), |
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig index 60f2b41c7310..a52e0edb7146 100644 --- a/drivers/spi/Kconfig +++ b/drivers/spi/Kconfig | |||
@@ -91,8 +91,8 @@ config SPI_BFIN5XX | |||
91 | help | 91 | help |
92 | This is the SPI controller master driver for Blackfin 5xx processor. | 92 | This is the SPI controller master driver for Blackfin 5xx processor. |
93 | 93 | ||
94 | config SPI_BFIN_V3 | 94 | config SPI_ADI_V3 |
95 | tristate "SPI controller v3 for Blackfin" | 95 | tristate "SPI controller v3 for ADI" |
96 | depends on BF60x | 96 | depends on BF60x |
97 | help | 97 | help |
98 | This is the SPI controller v3 master driver | 98 | This is the SPI controller v3 master driver |
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile index bd792669e563..71e65dfc0ea3 100644 --- a/drivers/spi/Makefile +++ b/drivers/spi/Makefile | |||
@@ -18,7 +18,7 @@ obj-$(CONFIG_SPI_BCM2835) += spi-bcm2835.o | |||
18 | obj-$(CONFIG_SPI_BCM63XX) += spi-bcm63xx.o | 18 | obj-$(CONFIG_SPI_BCM63XX) += spi-bcm63xx.o |
19 | obj-$(CONFIG_SPI_BCM63XX_HSSPI) += spi-bcm63xx-hsspi.o | 19 | obj-$(CONFIG_SPI_BCM63XX_HSSPI) += spi-bcm63xx-hsspi.o |
20 | obj-$(CONFIG_SPI_BFIN5XX) += spi-bfin5xx.o | 20 | obj-$(CONFIG_SPI_BFIN5XX) += spi-bfin5xx.o |
21 | obj-$(CONFIG_SPI_BFIN_V3) += spi-bfin-v3.o | 21 | obj-$(CONFIG_SPI_ADI_V3) += spi-adi-v3.o |
22 | obj-$(CONFIG_SPI_BFIN_SPORT) += spi-bfin-sport.o | 22 | obj-$(CONFIG_SPI_BFIN_SPORT) += spi-bfin-sport.o |
23 | obj-$(CONFIG_SPI_BITBANG) += spi-bitbang.o | 23 | obj-$(CONFIG_SPI_BITBANG) += spi-bitbang.o |
24 | obj-$(CONFIG_SPI_BUTTERFLY) += spi-butterfly.o | 24 | obj-$(CONFIG_SPI_BUTTERFLY) += spi-butterfly.o |
diff --git a/drivers/spi/spi-bfin-v3.c b/drivers/spi/spi-adi-v3.c index 4089d0e0d84e..0c2914cfcdb5 100644 --- a/drivers/spi/spi-bfin-v3.c +++ b/drivers/spi/spi-adi-v3.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Analog Devices SPI3 controller driver | 2 | * Analog Devices SPI3 controller driver |
3 | * | 3 | * |
4 | * Copyright (c) 2013 Analog Devices Inc. | 4 | * Copyright (c) 2014 Analog Devices Inc. |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License version 2 as | 7 | * it under the terms of the GNU General Public License version 2 as |
@@ -26,35 +26,34 @@ | |||
26 | #include <linux/platform_device.h> | 26 | #include <linux/platform_device.h> |
27 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
28 | #include <linux/spi/spi.h> | 28 | #include <linux/spi/spi.h> |
29 | #include <linux/spi/adi_spi3.h> | ||
29 | #include <linux/types.h> | 30 | #include <linux/types.h> |
30 | 31 | ||
31 | #include <asm/bfin_spi3.h> | ||
32 | #include <asm/cacheflush.h> | ||
33 | #include <asm/dma.h> | 32 | #include <asm/dma.h> |
34 | #include <asm/portmux.h> | 33 | #include <asm/portmux.h> |
35 | 34 | ||
36 | enum bfin_spi_state { | 35 | enum adi_spi_state { |
37 | START_STATE, | 36 | START_STATE, |
38 | RUNNING_STATE, | 37 | RUNNING_STATE, |
39 | DONE_STATE, | 38 | DONE_STATE, |
40 | ERROR_STATE | 39 | ERROR_STATE |
41 | }; | 40 | }; |
42 | 41 | ||
43 | struct bfin_spi_master; | 42 | struct adi_spi_master; |
44 | 43 | ||
45 | struct bfin_spi_transfer_ops { | 44 | struct adi_spi_transfer_ops { |
46 | void (*write) (struct bfin_spi_master *); | 45 | void (*write) (struct adi_spi_master *); |
47 | void (*read) (struct bfin_spi_master *); | 46 | void (*read) (struct adi_spi_master *); |
48 | void (*duplex) (struct bfin_spi_master *); | 47 | void (*duplex) (struct adi_spi_master *); |
49 | }; | 48 | }; |
50 | 49 | ||
51 | /* runtime info for spi master */ | 50 | /* runtime info for spi master */ |
52 | struct bfin_spi_master { | 51 | struct adi_spi_master { |
53 | /* SPI framework hookup */ | 52 | /* SPI framework hookup */ |
54 | struct spi_master *master; | 53 | struct spi_master *master; |
55 | 54 | ||
56 | /* Regs base of SPI controller */ | 55 | /* Regs base of SPI controller */ |
57 | struct bfin_spi_regs __iomem *regs; | 56 | struct adi_spi_regs __iomem *regs; |
58 | 57 | ||
59 | /* Pin request list */ | 58 | /* Pin request list */ |
60 | u16 *pin_req; | 59 | u16 *pin_req; |
@@ -65,7 +64,7 @@ struct bfin_spi_master { | |||
65 | /* Current message transfer state info */ | 64 | /* Current message transfer state info */ |
66 | struct spi_message *cur_msg; | 65 | struct spi_message *cur_msg; |
67 | struct spi_transfer *cur_transfer; | 66 | struct spi_transfer *cur_transfer; |
68 | struct bfin_spi_device *cur_chip; | 67 | struct adi_spi_device *cur_chip; |
69 | unsigned transfer_len; | 68 | unsigned transfer_len; |
70 | 69 | ||
71 | /* transfer buffer */ | 70 | /* transfer buffer */ |
@@ -90,12 +89,12 @@ struct bfin_spi_master { | |||
90 | u32 ssel; | 89 | u32 ssel; |
91 | 90 | ||
92 | unsigned long sclk; | 91 | unsigned long sclk; |
93 | enum bfin_spi_state state; | 92 | enum adi_spi_state state; |
94 | 93 | ||
95 | const struct bfin_spi_transfer_ops *ops; | 94 | const struct adi_spi_transfer_ops *ops; |
96 | }; | 95 | }; |
97 | 96 | ||
98 | struct bfin_spi_device { | 97 | struct adi_spi_device { |
99 | u32 control; | 98 | u32 control; |
100 | u32 clock; | 99 | u32 clock; |
101 | u32 ssel; | 100 | u32 ssel; |
@@ -105,17 +104,25 @@ struct bfin_spi_device { | |||
105 | u32 cs_gpio; | 104 | u32 cs_gpio; |
106 | u32 tx_dummy_val; /* tx value for rx only transfer */ | 105 | u32 tx_dummy_val; /* tx value for rx only transfer */ |
107 | bool enable_dma; | 106 | bool enable_dma; |
108 | const struct bfin_spi_transfer_ops *ops; | 107 | const struct adi_spi_transfer_ops *ops; |
109 | }; | 108 | }; |
110 | 109 | ||
111 | static void bfin_spi_enable(struct bfin_spi_master *drv_data) | 110 | static void adi_spi_enable(struct adi_spi_master *drv_data) |
112 | { | 111 | { |
113 | bfin_write_or(&drv_data->regs->control, SPI_CTL_EN); | 112 | u32 ctl; |
113 | |||
114 | ctl = ioread32(&drv_data->regs->control); | ||
115 | ctl |= SPI_CTL_EN; | ||
116 | iowrite32(ctl, &drv_data->regs->control); | ||
114 | } | 117 | } |
115 | 118 | ||
116 | static void bfin_spi_disable(struct bfin_spi_master *drv_data) | 119 | static void adi_spi_disable(struct adi_spi_master *drv_data) |
117 | { | 120 | { |
118 | bfin_write_and(&drv_data->regs->control, ~SPI_CTL_EN); | 121 | u32 ctl; |
122 | |||
123 | ctl = ioread32(&drv_data->regs->control); | ||
124 | ctl &= ~SPI_CTL_EN; | ||
125 | iowrite32(ctl, &drv_data->regs->control); | ||
119 | } | 126 | } |
120 | 127 | ||
121 | /* Caculate the SPI_CLOCK register value based on input HZ */ | 128 | /* Caculate the SPI_CLOCK register value based on input HZ */ |
@@ -128,35 +135,43 @@ static u32 hz_to_spi_clock(u32 sclk, u32 speed_hz) | |||
128 | return spi_clock; | 135 | return spi_clock; |
129 | } | 136 | } |
130 | 137 | ||
131 | static int bfin_spi_flush(struct bfin_spi_master *drv_data) | 138 | static int adi_spi_flush(struct adi_spi_master *drv_data) |
132 | { | 139 | { |
133 | unsigned long limit = loops_per_jiffy << 1; | 140 | unsigned long limit = loops_per_jiffy << 1; |
134 | 141 | ||
135 | /* wait for stop and clear stat */ | 142 | /* wait for stop and clear stat */ |
136 | while (!(bfin_read(&drv_data->regs->status) & SPI_STAT_SPIF) && --limit) | 143 | while (!(ioread32(&drv_data->regs->status) & SPI_STAT_SPIF) && --limit) |
137 | cpu_relax(); | 144 | cpu_relax(); |
138 | 145 | ||
139 | bfin_write(&drv_data->regs->status, 0xFFFFFFFF); | 146 | iowrite32(0xFFFFFFFF, &drv_data->regs->status); |
140 | 147 | ||
141 | return limit; | 148 | return limit; |
142 | } | 149 | } |
143 | 150 | ||
144 | /* Chip select operation functions for cs_change flag */ | 151 | /* Chip select operation functions for cs_change flag */ |
145 | static void bfin_spi_cs_active(struct bfin_spi_master *drv_data, struct bfin_spi_device *chip) | 152 | static void adi_spi_cs_active(struct adi_spi_master *drv_data, struct adi_spi_device *chip) |
146 | { | 153 | { |
147 | if (likely(chip->cs < MAX_CTRL_CS)) | 154 | if (likely(chip->cs < MAX_CTRL_CS)) { |
148 | bfin_write_and(&drv_data->regs->ssel, ~chip->ssel); | 155 | u32 reg; |
149 | else | 156 | reg = ioread32(&drv_data->regs->ssel); |
157 | reg &= ~chip->ssel; | ||
158 | iowrite32(reg, &drv_data->regs->ssel); | ||
159 | } else { | ||
150 | gpio_set_value(chip->cs_gpio, 0); | 160 | gpio_set_value(chip->cs_gpio, 0); |
161 | } | ||
151 | } | 162 | } |
152 | 163 | ||
153 | static void bfin_spi_cs_deactive(struct bfin_spi_master *drv_data, | 164 | static void adi_spi_cs_deactive(struct adi_spi_master *drv_data, |
154 | struct bfin_spi_device *chip) | 165 | struct adi_spi_device *chip) |
155 | { | 166 | { |
156 | if (likely(chip->cs < MAX_CTRL_CS)) | 167 | if (likely(chip->cs < MAX_CTRL_CS)) { |
157 | bfin_write_or(&drv_data->regs->ssel, chip->ssel); | 168 | u32 reg; |
158 | else | 169 | reg = ioread32(&drv_data->regs->ssel); |
170 | reg |= chip->ssel; | ||
171 | iowrite32(reg, &drv_data->regs->ssel); | ||
172 | } else { | ||
159 | gpio_set_value(chip->cs_gpio, 1); | 173 | gpio_set_value(chip->cs_gpio, 1); |
174 | } | ||
160 | 175 | ||
161 | /* Move delay here for consistency */ | 176 | /* Move delay here for consistency */ |
162 | if (chip->cs_chg_udelay) | 177 | if (chip->cs_chg_udelay) |
@@ -164,187 +179,192 @@ static void bfin_spi_cs_deactive(struct bfin_spi_master *drv_data, | |||
164 | } | 179 | } |
165 | 180 | ||
166 | /* enable or disable the pin muxed by GPIO and SPI CS to work as SPI CS */ | 181 | /* enable or disable the pin muxed by GPIO and SPI CS to work as SPI CS */ |
167 | static inline void bfin_spi_cs_enable(struct bfin_spi_master *drv_data, | 182 | static inline void adi_spi_cs_enable(struct adi_spi_master *drv_data, |
168 | struct bfin_spi_device *chip) | 183 | struct adi_spi_device *chip) |
169 | { | 184 | { |
170 | if (chip->cs < MAX_CTRL_CS) | 185 | if (chip->cs < MAX_CTRL_CS) { |
171 | bfin_write_or(&drv_data->regs->ssel, chip->ssel >> 8); | 186 | u32 reg; |
187 | reg = ioread32(&drv_data->regs->ssel); | ||
188 | reg |= chip->ssel >> 8; | ||
189 | iowrite32(reg, &drv_data->regs->ssel); | ||
190 | } | ||
172 | } | 191 | } |
173 | 192 | ||
174 | static inline void bfin_spi_cs_disable(struct bfin_spi_master *drv_data, | 193 | static inline void adi_spi_cs_disable(struct adi_spi_master *drv_data, |
175 | struct bfin_spi_device *chip) | 194 | struct adi_spi_device *chip) |
176 | { | 195 | { |
177 | if (chip->cs < MAX_CTRL_CS) | 196 | if (chip->cs < MAX_CTRL_CS) { |
178 | bfin_write_and(&drv_data->regs->ssel, ~(chip->ssel >> 8)); | 197 | u32 reg; |
198 | reg = ioread32(&drv_data->regs->ssel); | ||
199 | reg &= ~(chip->ssel >> 8); | ||
200 | iowrite32(reg, &drv_data->regs->ssel); | ||
201 | } | ||
179 | } | 202 | } |
180 | 203 | ||
181 | /* stop controller and re-config current chip*/ | 204 | /* stop controller and re-config current chip*/ |
182 | static void bfin_spi_restore_state(struct bfin_spi_master *drv_data) | 205 | static void adi_spi_restore_state(struct adi_spi_master *drv_data) |
183 | { | 206 | { |
184 | struct bfin_spi_device *chip = drv_data->cur_chip; | 207 | struct adi_spi_device *chip = drv_data->cur_chip; |
185 | 208 | ||
186 | /* Clear status and disable clock */ | 209 | /* Clear status and disable clock */ |
187 | bfin_write(&drv_data->regs->status, 0xFFFFFFFF); | 210 | iowrite32(0xFFFFFFFF, &drv_data->regs->status); |
188 | bfin_write(&drv_data->regs->rx_control, 0x0); | 211 | iowrite32(0x0, &drv_data->regs->rx_control); |
189 | bfin_write(&drv_data->regs->tx_control, 0x0); | 212 | iowrite32(0x0, &drv_data->regs->tx_control); |
190 | bfin_spi_disable(drv_data); | 213 | adi_spi_disable(drv_data); |
191 | |||
192 | SSYNC(); | ||
193 | 214 | ||
194 | /* Load the registers */ | 215 | /* Load the registers */ |
195 | bfin_write(&drv_data->regs->control, chip->control); | 216 | iowrite32(chip->control, &drv_data->regs->control); |
196 | bfin_write(&drv_data->regs->clock, chip->clock); | 217 | iowrite32(chip->clock, &drv_data->regs->clock); |
197 | 218 | ||
198 | bfin_spi_enable(drv_data); | 219 | adi_spi_enable(drv_data); |
199 | drv_data->tx_num = drv_data->rx_num = 0; | 220 | drv_data->tx_num = drv_data->rx_num = 0; |
200 | /* we always choose tx transfer initiate */ | 221 | /* we always choose tx transfer initiate */ |
201 | bfin_write(&drv_data->regs->rx_control, SPI_RXCTL_REN); | 222 | iowrite32(SPI_RXCTL_REN, &drv_data->regs->rx_control); |
202 | bfin_write(&drv_data->regs->tx_control, | 223 | iowrite32(SPI_TXCTL_TEN | SPI_TXCTL_TTI, &drv_data->regs->tx_control); |
203 | SPI_TXCTL_TEN | SPI_TXCTL_TTI); | 224 | adi_spi_cs_active(drv_data, chip); |
204 | bfin_spi_cs_active(drv_data, chip); | ||
205 | } | 225 | } |
206 | 226 | ||
207 | /* discard invalid rx data and empty rfifo */ | 227 | /* discard invalid rx data and empty rfifo */ |
208 | static inline void dummy_read(struct bfin_spi_master *drv_data) | 228 | static inline void dummy_read(struct adi_spi_master *drv_data) |
209 | { | 229 | { |
210 | while (!(bfin_read(&drv_data->regs->status) & SPI_STAT_RFE)) | 230 | while (!(ioread32(&drv_data->regs->status) & SPI_STAT_RFE)) |
211 | bfin_read(&drv_data->regs->rfifo); | 231 | ioread32(&drv_data->regs->rfifo); |
212 | } | 232 | } |
213 | 233 | ||
214 | static void bfin_spi_u8_write(struct bfin_spi_master *drv_data) | 234 | static void adi_spi_u8_write(struct adi_spi_master *drv_data) |
215 | { | 235 | { |
216 | dummy_read(drv_data); | 236 | dummy_read(drv_data); |
217 | while (drv_data->tx < drv_data->tx_end) { | 237 | while (drv_data->tx < drv_data->tx_end) { |
218 | bfin_write(&drv_data->regs->tfifo, (*(u8 *)(drv_data->tx++))); | 238 | iowrite32(*(u8 *)(drv_data->tx++), &drv_data->regs->tfifo); |
219 | while (bfin_read(&drv_data->regs->status) & SPI_STAT_RFE) | 239 | while (ioread32(&drv_data->regs->status) & SPI_STAT_RFE) |
220 | cpu_relax(); | 240 | cpu_relax(); |
221 | bfin_read(&drv_data->regs->rfifo); | 241 | ioread32(&drv_data->regs->rfifo); |
222 | } | 242 | } |
223 | } | 243 | } |
224 | 244 | ||
225 | static void bfin_spi_u8_read(struct bfin_spi_master *drv_data) | 245 | static void adi_spi_u8_read(struct adi_spi_master *drv_data) |
226 | { | 246 | { |
227 | u32 tx_val = drv_data->cur_chip->tx_dummy_val; | 247 | u32 tx_val = drv_data->cur_chip->tx_dummy_val; |
228 | 248 | ||
229 | dummy_read(drv_data); | 249 | dummy_read(drv_data); |
230 | while (drv_data->rx < drv_data->rx_end) { | 250 | while (drv_data->rx < drv_data->rx_end) { |
231 | bfin_write(&drv_data->regs->tfifo, tx_val); | 251 | iowrite32(tx_val, &drv_data->regs->tfifo); |
232 | while (bfin_read(&drv_data->regs->status) & SPI_STAT_RFE) | 252 | while (ioread32(&drv_data->regs->status) & SPI_STAT_RFE) |
233 | cpu_relax(); | 253 | cpu_relax(); |
234 | *(u8 *)(drv_data->rx++) = bfin_read(&drv_data->regs->rfifo); | 254 | *(u8 *)(drv_data->rx++) = ioread32(&drv_data->regs->rfifo); |
235 | } | 255 | } |
236 | } | 256 | } |
237 | 257 | ||
238 | static void bfin_spi_u8_duplex(struct bfin_spi_master *drv_data) | 258 | static void adi_spi_u8_duplex(struct adi_spi_master *drv_data) |
239 | { | 259 | { |
240 | dummy_read(drv_data); | 260 | dummy_read(drv_data); |
241 | while (drv_data->rx < drv_data->rx_end) { | 261 | while (drv_data->rx < drv_data->rx_end) { |
242 | bfin_write(&drv_data->regs->tfifo, (*(u8 *)(drv_data->tx++))); | 262 | iowrite32(*(u8 *)(drv_data->tx++), &drv_data->regs->tfifo); |
243 | while (bfin_read(&drv_data->regs->status) & SPI_STAT_RFE) | 263 | while (ioread32(&drv_data->regs->status) & SPI_STAT_RFE) |
244 | cpu_relax(); | 264 | cpu_relax(); |
245 | *(u8 *)(drv_data->rx++) = bfin_read(&drv_data->regs->rfifo); | 265 | *(u8 *)(drv_data->rx++) = ioread32(&drv_data->regs->rfifo); |
246 | } | 266 | } |
247 | } | 267 | } |
248 | 268 | ||
249 | static const struct bfin_spi_transfer_ops bfin_bfin_spi_transfer_ops_u8 = { | 269 | static const struct adi_spi_transfer_ops adi_spi_transfer_ops_u8 = { |
250 | .write = bfin_spi_u8_write, | 270 | .write = adi_spi_u8_write, |
251 | .read = bfin_spi_u8_read, | 271 | .read = adi_spi_u8_read, |
252 | .duplex = bfin_spi_u8_duplex, | 272 | .duplex = adi_spi_u8_duplex, |
253 | }; | 273 | }; |
254 | 274 | ||
255 | static void bfin_spi_u16_write(struct bfin_spi_master *drv_data) | 275 | static void adi_spi_u16_write(struct adi_spi_master *drv_data) |
256 | { | 276 | { |
257 | dummy_read(drv_data); | 277 | dummy_read(drv_data); |
258 | while (drv_data->tx < drv_data->tx_end) { | 278 | while (drv_data->tx < drv_data->tx_end) { |
259 | bfin_write(&drv_data->regs->tfifo, (*(u16 *)drv_data->tx)); | 279 | iowrite32(*(u16 *)drv_data->tx, &drv_data->regs->tfifo); |
260 | drv_data->tx += 2; | 280 | drv_data->tx += 2; |
261 | while (bfin_read(&drv_data->regs->status) & SPI_STAT_RFE) | 281 | while (ioread32(&drv_data->regs->status) & SPI_STAT_RFE) |
262 | cpu_relax(); | 282 | cpu_relax(); |
263 | bfin_read(&drv_data->regs->rfifo); | 283 | ioread32(&drv_data->regs->rfifo); |
264 | } | 284 | } |
265 | } | 285 | } |
266 | 286 | ||
267 | static void bfin_spi_u16_read(struct bfin_spi_master *drv_data) | 287 | static void adi_spi_u16_read(struct adi_spi_master *drv_data) |
268 | { | 288 | { |
269 | u32 tx_val = drv_data->cur_chip->tx_dummy_val; | 289 | u32 tx_val = drv_data->cur_chip->tx_dummy_val; |
270 | 290 | ||
271 | dummy_read(drv_data); | 291 | dummy_read(drv_data); |
272 | while (drv_data->rx < drv_data->rx_end) { | 292 | while (drv_data->rx < drv_data->rx_end) { |
273 | bfin_write(&drv_data->regs->tfifo, tx_val); | 293 | iowrite32(tx_val, &drv_data->regs->tfifo); |
274 | while (bfin_read(&drv_data->regs->status) & SPI_STAT_RFE) | 294 | while (ioread32(&drv_data->regs->status) & SPI_STAT_RFE) |
275 | cpu_relax(); | 295 | cpu_relax(); |
276 | *(u16 *)drv_data->rx = bfin_read(&drv_data->regs->rfifo); | 296 | *(u16 *)drv_data->rx = ioread32(&drv_data->regs->rfifo); |
277 | drv_data->rx += 2; | 297 | drv_data->rx += 2; |
278 | } | 298 | } |
279 | } | 299 | } |
280 | 300 | ||
281 | static void bfin_spi_u16_duplex(struct bfin_spi_master *drv_data) | 301 | static void adi_spi_u16_duplex(struct adi_spi_master *drv_data) |
282 | { | 302 | { |
283 | dummy_read(drv_data); | 303 | dummy_read(drv_data); |
284 | while (drv_data->rx < drv_data->rx_end) { | 304 | while (drv_data->rx < drv_data->rx_end) { |
285 | bfin_write(&drv_data->regs->tfifo, (*(u16 *)drv_data->tx)); | 305 | iowrite32(*(u16 *)drv_data->tx, &drv_data->regs->tfifo); |
286 | drv_data->tx += 2; | 306 | drv_data->tx += 2; |
287 | while (bfin_read(&drv_data->regs->status) & SPI_STAT_RFE) | 307 | while (ioread32(&drv_data->regs->status) & SPI_STAT_RFE) |
288 | cpu_relax(); | 308 | cpu_relax(); |
289 | *(u16 *)drv_data->rx = bfin_read(&drv_data->regs->rfifo); | 309 | *(u16 *)drv_data->rx = ioread32(&drv_data->regs->rfifo); |
290 | drv_data->rx += 2; | 310 | drv_data->rx += 2; |
291 | } | 311 | } |
292 | } | 312 | } |
293 | 313 | ||
294 | static const struct bfin_spi_transfer_ops bfin_bfin_spi_transfer_ops_u16 = { | 314 | static const struct adi_spi_transfer_ops adi_spi_transfer_ops_u16 = { |
295 | .write = bfin_spi_u16_write, | 315 | .write = adi_spi_u16_write, |
296 | .read = bfin_spi_u16_read, | 316 | .read = adi_spi_u16_read, |
297 | .duplex = bfin_spi_u16_duplex, | 317 | .duplex = adi_spi_u16_duplex, |
298 | }; | 318 | }; |
299 | 319 | ||
300 | static void bfin_spi_u32_write(struct bfin_spi_master *drv_data) | 320 | static void adi_spi_u32_write(struct adi_spi_master *drv_data) |
301 | { | 321 | { |
302 | dummy_read(drv_data); | 322 | dummy_read(drv_data); |
303 | while (drv_data->tx < drv_data->tx_end) { | 323 | while (drv_data->tx < drv_data->tx_end) { |
304 | bfin_write(&drv_data->regs->tfifo, (*(u32 *)drv_data->tx)); | 324 | iowrite32(*(u32 *)drv_data->tx, &drv_data->regs->tfifo); |
305 | drv_data->tx += 4; | 325 | drv_data->tx += 4; |
306 | while (bfin_read(&drv_data->regs->status) & SPI_STAT_RFE) | 326 | while (ioread32(&drv_data->regs->status) & SPI_STAT_RFE) |
307 | cpu_relax(); | 327 | cpu_relax(); |
308 | bfin_read(&drv_data->regs->rfifo); | 328 | ioread32(&drv_data->regs->rfifo); |
309 | } | 329 | } |
310 | } | 330 | } |
311 | 331 | ||
312 | static void bfin_spi_u32_read(struct bfin_spi_master *drv_data) | 332 | static void adi_spi_u32_read(struct adi_spi_master *drv_data) |
313 | { | 333 | { |
314 | u32 tx_val = drv_data->cur_chip->tx_dummy_val; | 334 | u32 tx_val = drv_data->cur_chip->tx_dummy_val; |
315 | 335 | ||
316 | dummy_read(drv_data); | 336 | dummy_read(drv_data); |
317 | while (drv_data->rx < drv_data->rx_end) { | 337 | while (drv_data->rx < drv_data->rx_end) { |
318 | bfin_write(&drv_data->regs->tfifo, tx_val); | 338 | iowrite32(tx_val, &drv_data->regs->tfifo); |
319 | while (bfin_read(&drv_data->regs->status) & SPI_STAT_RFE) | 339 | while (ioread32(&drv_data->regs->status) & SPI_STAT_RFE) |
320 | cpu_relax(); | 340 | cpu_relax(); |
321 | *(u32 *)drv_data->rx = bfin_read(&drv_data->regs->rfifo); | 341 | *(u32 *)drv_data->rx = ioread32(&drv_data->regs->rfifo); |
322 | drv_data->rx += 4; | 342 | drv_data->rx += 4; |
323 | } | 343 | } |
324 | } | 344 | } |
325 | 345 | ||
326 | static void bfin_spi_u32_duplex(struct bfin_spi_master *drv_data) | 346 | static void adi_spi_u32_duplex(struct adi_spi_master *drv_data) |
327 | { | 347 | { |
328 | dummy_read(drv_data); | 348 | dummy_read(drv_data); |
329 | while (drv_data->rx < drv_data->rx_end) { | 349 | while (drv_data->rx < drv_data->rx_end) { |
330 | bfin_write(&drv_data->regs->tfifo, (*(u32 *)drv_data->tx)); | 350 | iowrite32(*(u32 *)drv_data->tx, &drv_data->regs->tfifo); |
331 | drv_data->tx += 4; | 351 | drv_data->tx += 4; |
332 | while (bfin_read(&drv_data->regs->status) & SPI_STAT_RFE) | 352 | while (ioread32(&drv_data->regs->status) & SPI_STAT_RFE) |
333 | cpu_relax(); | 353 | cpu_relax(); |
334 | *(u32 *)drv_data->rx = bfin_read(&drv_data->regs->rfifo); | 354 | *(u32 *)drv_data->rx = ioread32(&drv_data->regs->rfifo); |
335 | drv_data->rx += 4; | 355 | drv_data->rx += 4; |
336 | } | 356 | } |
337 | } | 357 | } |
338 | 358 | ||
339 | static const struct bfin_spi_transfer_ops bfin_bfin_spi_transfer_ops_u32 = { | 359 | static const struct adi_spi_transfer_ops adi_spi_transfer_ops_u32 = { |
340 | .write = bfin_spi_u32_write, | 360 | .write = adi_spi_u32_write, |
341 | .read = bfin_spi_u32_read, | 361 | .read = adi_spi_u32_read, |
342 | .duplex = bfin_spi_u32_duplex, | 362 | .duplex = adi_spi_u32_duplex, |
343 | }; | 363 | }; |
344 | 364 | ||
345 | 365 | ||
346 | /* test if there is more transfer to be done */ | 366 | /* test if there is more transfer to be done */ |
347 | static void bfin_spi_next_transfer(struct bfin_spi_master *drv) | 367 | static void adi_spi_next_transfer(struct adi_spi_master *drv) |
348 | { | 368 | { |
349 | struct spi_message *msg = drv->cur_msg; | 369 | struct spi_message *msg = drv->cur_msg; |
350 | struct spi_transfer *t = drv->cur_transfer; | 370 | struct spi_transfer *t = drv->cur_transfer; |
@@ -360,15 +380,15 @@ static void bfin_spi_next_transfer(struct bfin_spi_master *drv) | |||
360 | } | 380 | } |
361 | } | 381 | } |
362 | 382 | ||
363 | static void bfin_spi_giveback(struct bfin_spi_master *drv_data) | 383 | static void adi_spi_giveback(struct adi_spi_master *drv_data) |
364 | { | 384 | { |
365 | struct bfin_spi_device *chip = drv_data->cur_chip; | 385 | struct adi_spi_device *chip = drv_data->cur_chip; |
366 | 386 | ||
367 | bfin_spi_cs_deactive(drv_data, chip); | 387 | adi_spi_cs_deactive(drv_data, chip); |
368 | spi_finalize_current_message(drv_data->master); | 388 | spi_finalize_current_message(drv_data->master); |
369 | } | 389 | } |
370 | 390 | ||
371 | static int bfin_spi_setup_transfer(struct bfin_spi_master *drv) | 391 | static int adi_spi_setup_transfer(struct adi_spi_master *drv) |
372 | { | 392 | { |
373 | struct spi_transfer *t = drv->cur_transfer; | 393 | struct spi_transfer *t = drv->cur_transfer; |
374 | u32 cr, cr_width; | 394 | u32 cr, cr_width; |
@@ -393,34 +413,33 @@ static int bfin_spi_setup_transfer(struct bfin_spi_master *drv) | |||
393 | switch (t->bits_per_word) { | 413 | switch (t->bits_per_word) { |
394 | case 8: | 414 | case 8: |
395 | cr_width = SPI_CTL_SIZE08; | 415 | cr_width = SPI_CTL_SIZE08; |
396 | drv->ops = &bfin_bfin_spi_transfer_ops_u8; | 416 | drv->ops = &adi_spi_transfer_ops_u8; |
397 | break; | 417 | break; |
398 | case 16: | 418 | case 16: |
399 | cr_width = SPI_CTL_SIZE16; | 419 | cr_width = SPI_CTL_SIZE16; |
400 | drv->ops = &bfin_bfin_spi_transfer_ops_u16; | 420 | drv->ops = &adi_spi_transfer_ops_u16; |
401 | break; | 421 | break; |
402 | case 32: | 422 | case 32: |
403 | cr_width = SPI_CTL_SIZE32; | 423 | cr_width = SPI_CTL_SIZE32; |
404 | drv->ops = &bfin_bfin_spi_transfer_ops_u32; | 424 | drv->ops = &adi_spi_transfer_ops_u32; |
405 | break; | 425 | break; |
406 | default: | 426 | default: |
407 | return -EINVAL; | 427 | return -EINVAL; |
408 | } | 428 | } |
409 | cr = bfin_read(&drv->regs->control) & ~SPI_CTL_SIZE; | 429 | cr = ioread32(&drv->regs->control) & ~SPI_CTL_SIZE; |
410 | cr |= cr_width; | 430 | cr |= cr_width; |
411 | bfin_write(&drv->regs->control, cr); | 431 | iowrite32(cr, &drv->regs->control); |
412 | 432 | ||
413 | /* speed setup */ | 433 | /* speed setup */ |
414 | bfin_write(&drv->regs->clock, | 434 | iowrite32(hz_to_spi_clock(drv->sclk, t->speed_hz), &drv->regs->clock); |
415 | hz_to_spi_clock(drv->sclk, t->speed_hz)); | ||
416 | return 0; | 435 | return 0; |
417 | } | 436 | } |
418 | 437 | ||
419 | static int bfin_spi_dma_xfer(struct bfin_spi_master *drv_data) | 438 | static int adi_spi_dma_xfer(struct adi_spi_master *drv_data) |
420 | { | 439 | { |
421 | struct spi_transfer *t = drv_data->cur_transfer; | 440 | struct spi_transfer *t = drv_data->cur_transfer; |
422 | struct spi_message *msg = drv_data->cur_msg; | 441 | struct spi_message *msg = drv_data->cur_msg; |
423 | struct bfin_spi_device *chip = drv_data->cur_chip; | 442 | struct adi_spi_device *chip = drv_data->cur_chip; |
424 | u32 dma_config; | 443 | u32 dma_config; |
425 | unsigned long word_count, word_size; | 444 | unsigned long word_count, word_size; |
426 | void *tx_buf, *rx_buf; | 445 | void *tx_buf, *rx_buf; |
@@ -498,17 +517,16 @@ static int bfin_spi_dma_xfer(struct bfin_spi_master *drv_data) | |||
498 | set_dma_config(drv_data->rx_dma, dma_config | WNR); | 517 | set_dma_config(drv_data->rx_dma, dma_config | WNR); |
499 | enable_dma(drv_data->tx_dma); | 518 | enable_dma(drv_data->tx_dma); |
500 | enable_dma(drv_data->rx_dma); | 519 | enable_dma(drv_data->rx_dma); |
501 | SSYNC(); | ||
502 | 520 | ||
503 | bfin_write(&drv_data->regs->rx_control, SPI_RXCTL_REN | SPI_RXCTL_RDR_NE); | 521 | iowrite32(SPI_RXCTL_REN | SPI_RXCTL_RDR_NE, |
504 | SSYNC(); | 522 | &drv_data->regs->rx_control); |
505 | bfin_write(&drv_data->regs->tx_control, | 523 | iowrite32(SPI_TXCTL_TEN | SPI_TXCTL_TTI | SPI_TXCTL_TDR_NF, |
506 | SPI_TXCTL_TEN | SPI_TXCTL_TTI | SPI_TXCTL_TDR_NF); | 524 | &drv_data->regs->tx_control); |
507 | 525 | ||
508 | return 0; | 526 | return 0; |
509 | } | 527 | } |
510 | 528 | ||
511 | static int bfin_spi_pio_xfer(struct bfin_spi_master *drv_data) | 529 | static int adi_spi_pio_xfer(struct adi_spi_master *drv_data) |
512 | { | 530 | { |
513 | struct spi_message *msg = drv_data->cur_msg; | 531 | struct spi_message *msg = drv_data->cur_msg; |
514 | 532 | ||
@@ -529,19 +547,19 @@ static int bfin_spi_pio_xfer(struct bfin_spi_master *drv_data) | |||
529 | return -EIO; | 547 | return -EIO; |
530 | } | 548 | } |
531 | 549 | ||
532 | if (!bfin_spi_flush(drv_data)) | 550 | if (!adi_spi_flush(drv_data)) |
533 | return -EIO; | 551 | return -EIO; |
534 | msg->actual_length += drv_data->transfer_len; | 552 | msg->actual_length += drv_data->transfer_len; |
535 | tasklet_schedule(&drv_data->pump_transfers); | 553 | tasklet_schedule(&drv_data->pump_transfers); |
536 | return 0; | 554 | return 0; |
537 | } | 555 | } |
538 | 556 | ||
539 | static void bfin_spi_pump_transfers(unsigned long data) | 557 | static void adi_spi_pump_transfers(unsigned long data) |
540 | { | 558 | { |
541 | struct bfin_spi_master *drv_data = (struct bfin_spi_master *)data; | 559 | struct adi_spi_master *drv_data = (struct adi_spi_master *)data; |
542 | struct spi_message *msg = NULL; | 560 | struct spi_message *msg = NULL; |
543 | struct spi_transfer *t = NULL; | 561 | struct spi_transfer *t = NULL; |
544 | struct bfin_spi_device *chip = NULL; | 562 | struct adi_spi_device *chip = NULL; |
545 | int ret; | 563 | int ret; |
546 | 564 | ||
547 | /* Get current state information */ | 565 | /* Get current state information */ |
@@ -552,7 +570,7 @@ static void bfin_spi_pump_transfers(unsigned long data) | |||
552 | /* Handle for abort */ | 570 | /* Handle for abort */ |
553 | if (drv_data->state == ERROR_STATE) { | 571 | if (drv_data->state == ERROR_STATE) { |
554 | msg->status = -EIO; | 572 | msg->status = -EIO; |
555 | bfin_spi_giveback(drv_data); | 573 | adi_spi_giveback(drv_data); |
556 | return; | 574 | return; |
557 | } | 575 | } |
558 | 576 | ||
@@ -560,14 +578,14 @@ static void bfin_spi_pump_transfers(unsigned long data) | |||
560 | if (t->delay_usecs) | 578 | if (t->delay_usecs) |
561 | udelay(t->delay_usecs); | 579 | udelay(t->delay_usecs); |
562 | if (t->cs_change) | 580 | if (t->cs_change) |
563 | bfin_spi_cs_deactive(drv_data, chip); | 581 | adi_spi_cs_deactive(drv_data, chip); |
564 | bfin_spi_next_transfer(drv_data); | 582 | adi_spi_next_transfer(drv_data); |
565 | t = drv_data->cur_transfer; | 583 | t = drv_data->cur_transfer; |
566 | } | 584 | } |
567 | /* Handle end of message */ | 585 | /* Handle end of message */ |
568 | if (drv_data->state == DONE_STATE) { | 586 | if (drv_data->state == DONE_STATE) { |
569 | msg->status = 0; | 587 | msg->status = 0; |
570 | bfin_spi_giveback(drv_data); | 588 | adi_spi_giveback(drv_data); |
571 | return; | 589 | return; |
572 | } | 590 | } |
573 | 591 | ||
@@ -577,34 +595,34 @@ static void bfin_spi_pump_transfers(unsigned long data) | |||
577 | return; | 595 | return; |
578 | } | 596 | } |
579 | 597 | ||
580 | ret = bfin_spi_setup_transfer(drv_data); | 598 | ret = adi_spi_setup_transfer(drv_data); |
581 | if (ret) { | 599 | if (ret) { |
582 | msg->status = ret; | 600 | msg->status = ret; |
583 | bfin_spi_giveback(drv_data); | 601 | adi_spi_giveback(drv_data); |
584 | } | 602 | } |
585 | 603 | ||
586 | bfin_write(&drv_data->regs->status, 0xFFFFFFFF); | 604 | iowrite32(0xFFFFFFFF, &drv_data->regs->status); |
587 | bfin_spi_cs_active(drv_data, chip); | 605 | adi_spi_cs_active(drv_data, chip); |
588 | drv_data->state = RUNNING_STATE; | 606 | drv_data->state = RUNNING_STATE; |
589 | 607 | ||
590 | if (chip->enable_dma) | 608 | if (chip->enable_dma) |
591 | ret = bfin_spi_dma_xfer(drv_data); | 609 | ret = adi_spi_dma_xfer(drv_data); |
592 | else | 610 | else |
593 | ret = bfin_spi_pio_xfer(drv_data); | 611 | ret = adi_spi_pio_xfer(drv_data); |
594 | if (ret) { | 612 | if (ret) { |
595 | msg->status = ret; | 613 | msg->status = ret; |
596 | bfin_spi_giveback(drv_data); | 614 | adi_spi_giveback(drv_data); |
597 | } | 615 | } |
598 | } | 616 | } |
599 | 617 | ||
600 | static int bfin_spi_transfer_one_message(struct spi_master *master, | 618 | static int adi_spi_transfer_one_message(struct spi_master *master, |
601 | struct spi_message *m) | 619 | struct spi_message *m) |
602 | { | 620 | { |
603 | struct bfin_spi_master *drv_data = spi_master_get_devdata(master); | 621 | struct adi_spi_master *drv_data = spi_master_get_devdata(master); |
604 | 622 | ||
605 | drv_data->cur_msg = m; | 623 | drv_data->cur_msg = m; |
606 | drv_data->cur_chip = spi_get_ctldata(drv_data->cur_msg->spi); | 624 | drv_data->cur_chip = spi_get_ctldata(drv_data->cur_msg->spi); |
607 | bfin_spi_restore_state(drv_data); | 625 | adi_spi_restore_state(drv_data); |
608 | 626 | ||
609 | drv_data->state = START_STATE; | 627 | drv_data->state = START_STATE; |
610 | drv_data->cur_transfer = list_entry(drv_data->cur_msg->transfers.next, | 628 | drv_data->cur_transfer = list_entry(drv_data->cur_msg->transfers.next, |
@@ -630,15 +648,15 @@ static const u16 ssel[][MAX_SPI_SSEL] = { | |||
630 | P_SPI2_SSEL6, P_SPI2_SSEL7}, | 648 | P_SPI2_SSEL6, P_SPI2_SSEL7}, |
631 | }; | 649 | }; |
632 | 650 | ||
633 | static int bfin_spi_setup(struct spi_device *spi) | 651 | static int adi_spi_setup(struct spi_device *spi) |
634 | { | 652 | { |
635 | struct bfin_spi_master *drv_data = spi_master_get_devdata(spi->master); | 653 | struct adi_spi_master *drv_data = spi_master_get_devdata(spi->master); |
636 | struct bfin_spi_device *chip = spi_get_ctldata(spi); | 654 | struct adi_spi_device *chip = spi_get_ctldata(spi); |
637 | u32 bfin_ctl_reg = SPI_CTL_ODM | SPI_CTL_PSSE; | 655 | u32 ctl_reg = SPI_CTL_ODM | SPI_CTL_PSSE; |
638 | int ret = -EINVAL; | 656 | int ret = -EINVAL; |
639 | 657 | ||
640 | if (!chip) { | 658 | if (!chip) { |
641 | struct bfin_spi3_chip *chip_info = spi->controller_data; | 659 | struct adi_spi3_chip *chip_info = spi->controller_data; |
642 | 660 | ||
643 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); | 661 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); |
644 | if (!chip) { | 662 | if (!chip) { |
@@ -646,7 +664,7 @@ static int bfin_spi_setup(struct spi_device *spi) | |||
646 | return -ENOMEM; | 664 | return -ENOMEM; |
647 | } | 665 | } |
648 | if (chip_info) { | 666 | if (chip_info) { |
649 | if (chip_info->control & ~bfin_ctl_reg) { | 667 | if (chip_info->control & ~ctl_reg) { |
650 | dev_err(&spi->dev, | 668 | dev_err(&spi->dev, |
651 | "do not set bits that the SPI framework manages\n"); | 669 | "do not set bits that the SPI framework manages\n"); |
652 | goto error; | 670 | goto error; |
@@ -657,6 +675,7 @@ static int bfin_spi_setup(struct spi_device *spi) | |||
657 | chip->enable_dma = chip_info->enable_dma; | 675 | chip->enable_dma = chip_info->enable_dma; |
658 | } | 676 | } |
659 | chip->cs = spi->chip_select; | 677 | chip->cs = spi->chip_select; |
678 | |||
660 | if (chip->cs < MAX_CTRL_CS) { | 679 | if (chip->cs < MAX_CTRL_CS) { |
661 | chip->ssel = (1 << chip->cs) << 8; | 680 | chip->ssel = (1 << chip->cs) << 8; |
662 | ret = peripheral_request(ssel[spi->master->bus_num] | 681 | ret = peripheral_request(ssel[spi->master->bus_num] |
@@ -678,7 +697,7 @@ static int bfin_spi_setup(struct spi_device *spi) | |||
678 | } | 697 | } |
679 | 698 | ||
680 | /* force a default base state */ | 699 | /* force a default base state */ |
681 | chip->control &= bfin_ctl_reg; | 700 | chip->control &= ctl_reg; |
682 | 701 | ||
683 | if (spi->mode & SPI_CPOL) | 702 | if (spi->mode & SPI_CPOL) |
684 | chip->control |= SPI_CTL_CPOL; | 703 | chip->control |= SPI_CTL_CPOL; |
@@ -692,8 +711,8 @@ static int bfin_spi_setup(struct spi_device *spi) | |||
692 | 711 | ||
693 | chip->clock = hz_to_spi_clock(drv_data->sclk, spi->max_speed_hz); | 712 | chip->clock = hz_to_spi_clock(drv_data->sclk, spi->max_speed_hz); |
694 | 713 | ||
695 | bfin_spi_cs_enable(drv_data, chip); | 714 | adi_spi_cs_enable(drv_data, chip); |
696 | bfin_spi_cs_deactive(drv_data, chip); | 715 | adi_spi_cs_deactive(drv_data, chip); |
697 | 716 | ||
698 | return 0; | 717 | return 0; |
699 | error: | 718 | error: |
@@ -705,10 +724,10 @@ error: | |||
705 | return ret; | 724 | return ret; |
706 | } | 725 | } |
707 | 726 | ||
708 | static void bfin_spi_cleanup(struct spi_device *spi) | 727 | static void adi_spi_cleanup(struct spi_device *spi) |
709 | { | 728 | { |
710 | struct bfin_spi_device *chip = spi_get_ctldata(spi); | 729 | struct adi_spi_device *chip = spi_get_ctldata(spi); |
711 | struct bfin_spi_master *drv_data = spi_master_get_devdata(spi->master); | 730 | struct adi_spi_master *drv_data = spi_master_get_devdata(spi->master); |
712 | 731 | ||
713 | if (!chip) | 732 | if (!chip) |
714 | return; | 733 | return; |
@@ -716,7 +735,7 @@ static void bfin_spi_cleanup(struct spi_device *spi) | |||
716 | if (chip->cs < MAX_CTRL_CS) { | 735 | if (chip->cs < MAX_CTRL_CS) { |
717 | peripheral_free(ssel[spi->master->bus_num] | 736 | peripheral_free(ssel[spi->master->bus_num] |
718 | [chip->cs-1]); | 737 | [chip->cs-1]); |
719 | bfin_spi_cs_disable(drv_data, chip); | 738 | adi_spi_cs_disable(drv_data, chip); |
720 | } else { | 739 | } else { |
721 | gpio_free(chip->cs_gpio); | 740 | gpio_free(chip->cs_gpio); |
722 | } | 741 | } |
@@ -725,10 +744,11 @@ static void bfin_spi_cleanup(struct spi_device *spi) | |||
725 | spi_set_ctldata(spi, NULL); | 744 | spi_set_ctldata(spi, NULL); |
726 | } | 745 | } |
727 | 746 | ||
728 | static irqreturn_t bfin_spi_tx_dma_isr(int irq, void *dev_id) | 747 | static irqreturn_t adi_spi_tx_dma_isr(int irq, void *dev_id) |
729 | { | 748 | { |
730 | struct bfin_spi_master *drv_data = dev_id; | 749 | struct adi_spi_master *drv_data = dev_id; |
731 | u32 dma_stat = get_dma_curr_irqstat(drv_data->tx_dma); | 750 | u32 dma_stat = get_dma_curr_irqstat(drv_data->tx_dma); |
751 | u32 tx_ctl; | ||
732 | 752 | ||
733 | clear_dma_irqstat(drv_data->tx_dma); | 753 | clear_dma_irqstat(drv_data->tx_dma); |
734 | if (dma_stat & DMA_DONE) { | 754 | if (dma_stat & DMA_DONE) { |
@@ -739,13 +759,15 @@ static irqreturn_t bfin_spi_tx_dma_isr(int irq, void *dev_id) | |||
739 | if (drv_data->tx) | 759 | if (drv_data->tx) |
740 | drv_data->state = ERROR_STATE; | 760 | drv_data->state = ERROR_STATE; |
741 | } | 761 | } |
742 | bfin_write_and(&drv_data->regs->tx_control, ~SPI_TXCTL_TDR_NF); | 762 | tx_ctl = ioread32(&drv_data->regs->tx_control); |
763 | tx_ctl &= ~SPI_TXCTL_TDR_NF; | ||
764 | iowrite32(tx_ctl, &drv_data->regs->tx_control); | ||
743 | return IRQ_HANDLED; | 765 | return IRQ_HANDLED; |
744 | } | 766 | } |
745 | 767 | ||
746 | static irqreturn_t bfin_spi_rx_dma_isr(int irq, void *dev_id) | 768 | static irqreturn_t adi_spi_rx_dma_isr(int irq, void *dev_id) |
747 | { | 769 | { |
748 | struct bfin_spi_master *drv_data = dev_id; | 770 | struct adi_spi_master *drv_data = dev_id; |
749 | struct spi_message *msg = drv_data->cur_msg; | 771 | struct spi_message *msg = drv_data->cur_msg; |
750 | u32 dma_stat = get_dma_curr_irqstat(drv_data->rx_dma); | 772 | u32 dma_stat = get_dma_curr_irqstat(drv_data->rx_dma); |
751 | 773 | ||
@@ -760,8 +782,8 @@ static irqreturn_t bfin_spi_rx_dma_isr(int irq, void *dev_id) | |||
760 | dev_err(&drv_data->master->dev, | 782 | dev_err(&drv_data->master->dev, |
761 | "spi rx dma error: %d\n", dma_stat); | 783 | "spi rx dma error: %d\n", dma_stat); |
762 | } | 784 | } |
763 | bfin_write(&drv_data->regs->tx_control, 0); | 785 | iowrite32(0, &drv_data->regs->tx_control); |
764 | bfin_write(&drv_data->regs->rx_control, 0); | 786 | iowrite32(0, &drv_data->regs->rx_control); |
765 | if (drv_data->rx_num != drv_data->tx_num) | 787 | if (drv_data->rx_num != drv_data->tx_num) |
766 | dev_dbg(&drv_data->master->dev, | 788 | dev_dbg(&drv_data->master->dev, |
767 | "dma interrupt missing: tx=%d,rx=%d\n", | 789 | "dma interrupt missing: tx=%d,rx=%d\n", |
@@ -770,12 +792,12 @@ static irqreturn_t bfin_spi_rx_dma_isr(int irq, void *dev_id) | |||
770 | return IRQ_HANDLED; | 792 | return IRQ_HANDLED; |
771 | } | 793 | } |
772 | 794 | ||
773 | static int bfin_spi_probe(struct platform_device *pdev) | 795 | static int adi_spi_probe(struct platform_device *pdev) |
774 | { | 796 | { |
775 | struct device *dev = &pdev->dev; | 797 | struct device *dev = &pdev->dev; |
776 | struct bfin_spi3_master *info = dev_get_platdata(dev); | 798 | struct adi_spi3_master *info = dev_get_platdata(dev); |
777 | struct spi_master *master; | 799 | struct spi_master *master; |
778 | struct bfin_spi_master *drv_data; | 800 | struct adi_spi_master *drv_data; |
779 | struct resource *mem, *res; | 801 | struct resource *mem, *res; |
780 | unsigned int tx_dma, rx_dma; | 802 | unsigned int tx_dma, rx_dma; |
781 | unsigned long sclk; | 803 | unsigned long sclk; |
@@ -819,9 +841,9 @@ static int bfin_spi_probe(struct platform_device *pdev) | |||
819 | 841 | ||
820 | master->bus_num = pdev->id; | 842 | master->bus_num = pdev->id; |
821 | master->num_chipselect = info->num_chipselect; | 843 | master->num_chipselect = info->num_chipselect; |
822 | master->cleanup = bfin_spi_cleanup; | 844 | master->cleanup = adi_spi_cleanup; |
823 | master->setup = bfin_spi_setup; | 845 | master->setup = adi_spi_setup; |
824 | master->transfer_one_message = bfin_spi_transfer_one_message; | 846 | master->transfer_one_message = adi_spi_transfer_one_message; |
825 | master->bits_per_word_mask = SPI_BPW_MASK(32) | SPI_BPW_MASK(16) | | 847 | master->bits_per_word_mask = SPI_BPW_MASK(32) | SPI_BPW_MASK(16) | |
826 | SPI_BPW_MASK(8); | 848 | SPI_BPW_MASK(8); |
827 | 849 | ||
@@ -845,28 +867,28 @@ static int bfin_spi_probe(struct platform_device *pdev) | |||
845 | dev_err(dev, "can not request SPI TX DMA channel\n"); | 867 | dev_err(dev, "can not request SPI TX DMA channel\n"); |
846 | goto err_put_master; | 868 | goto err_put_master; |
847 | } | 869 | } |
848 | set_dma_callback(tx_dma, bfin_spi_tx_dma_isr, drv_data); | 870 | set_dma_callback(tx_dma, adi_spi_tx_dma_isr, drv_data); |
849 | 871 | ||
850 | ret = request_dma(rx_dma, "SPI_RX_DMA"); | 872 | ret = request_dma(rx_dma, "SPI_RX_DMA"); |
851 | if (ret) { | 873 | if (ret) { |
852 | dev_err(dev, "can not request SPI RX DMA channel\n"); | 874 | dev_err(dev, "can not request SPI RX DMA channel\n"); |
853 | goto err_free_tx_dma; | 875 | goto err_free_tx_dma; |
854 | } | 876 | } |
855 | set_dma_callback(drv_data->rx_dma, bfin_spi_rx_dma_isr, drv_data); | 877 | set_dma_callback(drv_data->rx_dma, adi_spi_rx_dma_isr, drv_data); |
856 | 878 | ||
857 | /* request CLK, MOSI and MISO */ | 879 | /* request CLK, MOSI and MISO */ |
858 | ret = peripheral_request_list(drv_data->pin_req, "bfin-spi3"); | 880 | ret = peripheral_request_list(drv_data->pin_req, "adi-spi3"); |
859 | if (ret < 0) { | 881 | if (ret < 0) { |
860 | dev_err(dev, "can not request spi pins\n"); | 882 | dev_err(dev, "can not request spi pins\n"); |
861 | goto err_free_rx_dma; | 883 | goto err_free_rx_dma; |
862 | } | 884 | } |
863 | 885 | ||
864 | bfin_write(&drv_data->regs->control, SPI_CTL_MSTR | SPI_CTL_CPHA); | 886 | iowrite32(SPI_CTL_MSTR | SPI_CTL_CPHA, &drv_data->regs->control); |
865 | bfin_write(&drv_data->regs->ssel, 0x0000FE00); | 887 | iowrite32(0x0000FE00, &drv_data->regs->ssel); |
866 | bfin_write(&drv_data->regs->delay, 0x0); | 888 | iowrite32(0x0, &drv_data->regs->delay); |
867 | 889 | ||
868 | tasklet_init(&drv_data->pump_transfers, | 890 | tasklet_init(&drv_data->pump_transfers, |
869 | bfin_spi_pump_transfers, (unsigned long)drv_data); | 891 | adi_spi_pump_transfers, (unsigned long)drv_data); |
870 | /* register with the SPI framework */ | 892 | /* register with the SPI framework */ |
871 | ret = devm_spi_register_master(dev, master); | 893 | ret = devm_spi_register_master(dev, master); |
872 | if (ret) { | 894 | if (ret) { |
@@ -888,43 +910,41 @@ err_put_master: | |||
888 | return ret; | 910 | return ret; |
889 | } | 911 | } |
890 | 912 | ||
891 | static int bfin_spi_remove(struct platform_device *pdev) | 913 | static int adi_spi_remove(struct platform_device *pdev) |
892 | { | 914 | { |
893 | struct spi_master *master = platform_get_drvdata(pdev); | 915 | struct spi_master *master = platform_get_drvdata(pdev); |
894 | struct bfin_spi_master *drv_data = spi_master_get_devdata(master); | 916 | struct adi_spi_master *drv_data = spi_master_get_devdata(master); |
895 | |||
896 | bfin_spi_disable(drv_data); | ||
897 | 917 | ||
918 | adi_spi_disable(drv_data); | ||
898 | peripheral_free_list(drv_data->pin_req); | 919 | peripheral_free_list(drv_data->pin_req); |
899 | free_dma(drv_data->rx_dma); | 920 | free_dma(drv_data->rx_dma); |
900 | free_dma(drv_data->tx_dma); | 921 | free_dma(drv_data->tx_dma); |
901 | |||
902 | return 0; | 922 | return 0; |
903 | } | 923 | } |
904 | 924 | ||
905 | #ifdef CONFIG_PM | 925 | #ifdef CONFIG_PM |
906 | static int bfin_spi_suspend(struct device *dev) | 926 | static int adi_spi_suspend(struct device *dev) |
907 | { | 927 | { |
908 | struct spi_master *master = dev_get_drvdata(dev); | 928 | struct spi_master *master = dev_get_drvdata(dev); |
909 | struct bfin_spi_master *drv_data = spi_master_get_devdata(master); | 929 | struct adi_spi_master *drv_data = spi_master_get_devdata(master); |
910 | 930 | ||
911 | spi_master_suspend(master); | 931 | spi_master_suspend(master); |
912 | 932 | ||
913 | drv_data->control = bfin_read(&drv_data->regs->control); | 933 | drv_data->control = ioread32(&drv_data->regs->control); |
914 | drv_data->ssel = bfin_read(&drv_data->regs->ssel); | 934 | drv_data->ssel = ioread32(&drv_data->regs->ssel); |
915 | 935 | ||
916 | bfin_write(&drv_data->regs->control, SPI_CTL_MSTR | SPI_CTL_CPHA); | 936 | iowrite32(SPI_CTL_MSTR | SPI_CTL_CPHA, &drv_data->regs->control); |
917 | bfin_write(&drv_data->regs->ssel, 0x0000FE00); | 937 | iowrite32(0x0000FE00, &drv_data->regs->ssel); |
918 | dma_disable_irq(drv_data->rx_dma); | 938 | dma_disable_irq(drv_data->rx_dma); |
919 | dma_disable_irq(drv_data->tx_dma); | 939 | dma_disable_irq(drv_data->tx_dma); |
920 | 940 | ||
921 | return 0; | 941 | return 0; |
922 | } | 942 | } |
923 | 943 | ||
924 | static int bfin_spi_resume(struct device *dev) | 944 | static int adi_spi_resume(struct device *dev) |
925 | { | 945 | { |
926 | struct spi_master *master = dev_get_drvdata(dev); | 946 | struct spi_master *master = dev_get_drvdata(dev); |
927 | struct bfin_spi_master *drv_data = spi_master_get_devdata(master); | 947 | struct adi_spi_master *drv_data = spi_master_get_devdata(master); |
928 | int ret = 0; | 948 | int ret = 0; |
929 | 949 | ||
930 | /* bootrom may modify spi and dma status when resume in spi boot mode */ | 950 | /* bootrom may modify spi and dma status when resume in spi boot mode */ |
@@ -932,8 +952,8 @@ static int bfin_spi_resume(struct device *dev) | |||
932 | 952 | ||
933 | dma_enable_irq(drv_data->rx_dma); | 953 | dma_enable_irq(drv_data->rx_dma); |
934 | dma_enable_irq(drv_data->tx_dma); | 954 | dma_enable_irq(drv_data->tx_dma); |
935 | bfin_write(&drv_data->regs->control, drv_data->control); | 955 | iowrite32(drv_data->control, &drv_data->regs->control); |
936 | bfin_write(&drv_data->regs->ssel, drv_data->ssel); | 956 | iowrite32(drv_data->ssel, &drv_data->regs->ssel); |
937 | 957 | ||
938 | ret = spi_master_resume(master); | 958 | ret = spi_master_resume(master); |
939 | if (ret) { | 959 | if (ret) { |
@@ -944,21 +964,21 @@ static int bfin_spi_resume(struct device *dev) | |||
944 | return ret; | 964 | return ret; |
945 | } | 965 | } |
946 | #endif | 966 | #endif |
947 | static const struct dev_pm_ops bfin_spi_pm_ops = { | 967 | static const struct dev_pm_ops adi_spi_pm_ops = { |
948 | SET_SYSTEM_SLEEP_PM_OPS(bfin_spi_suspend, bfin_spi_resume) | 968 | SET_SYSTEM_SLEEP_PM_OPS(adi_spi_suspend, adi_spi_resume) |
949 | }; | 969 | }; |
950 | 970 | ||
951 | MODULE_ALIAS("platform:bfin-spi3"); | 971 | MODULE_ALIAS("platform:adi-spi3"); |
952 | static struct platform_driver bfin_spi_driver = { | 972 | static struct platform_driver adi_spi_driver = { |
953 | .driver = { | 973 | .driver = { |
954 | .name = "bfin-spi3", | 974 | .name = "adi-spi3", |
955 | .owner = THIS_MODULE, | 975 | .owner = THIS_MODULE, |
956 | .pm = &bfin_spi_pm_ops, | 976 | .pm = &adi_spi_pm_ops, |
957 | }, | 977 | }, |
958 | .remove = bfin_spi_remove, | 978 | .remove = adi_spi_remove, |
959 | }; | 979 | }; |
960 | 980 | ||
961 | module_platform_driver_probe(bfin_spi_driver, bfin_spi_probe); | 981 | module_platform_driver_probe(adi_spi_driver, adi_spi_probe); |
962 | 982 | ||
963 | MODULE_DESCRIPTION("Analog Devices SPI3 controller driver"); | 983 | MODULE_DESCRIPTION("Analog Devices SPI3 controller driver"); |
964 | MODULE_AUTHOR("Scott Jiang <Scott.Jiang.Linux@gmail.com>"); | 984 | MODULE_AUTHOR("Scott Jiang <Scott.Jiang.Linux@gmail.com>"); |
diff --git a/arch/blackfin/include/asm/bfin_spi3.h b/include/linux/spi/adi_spi3.h index 0957e65a54be..c84123aa1d06 100644 --- a/arch/blackfin/include/asm/bfin_spi3.h +++ b/include/linux/spi/adi_spi3.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Analog Devices SPI3 controller driver | 2 | * Analog Devices SPI3 controller driver |
3 | * | 3 | * |
4 | * Copyright (c) 2011 Analog Devices Inc. | 4 | * Copyright (c) 2014 Analog Devices Inc. |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License version 2 as | 7 | * it under the terms of the GNU General Public License version 2 as |
@@ -11,14 +11,10 @@ | |||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
18 | */ | 14 | */ |
19 | 15 | ||
20 | #ifndef _SPI_CHANNEL_H_ | 16 | #ifndef _ADI_SPI3_H_ |
21 | #define _SPI_CHANNEL_H_ | 17 | #define _ADI_SPI3_H_ |
22 | 18 | ||
23 | #include <linux/types.h> | 19 | #include <linux/types.h> |
24 | 20 | ||
@@ -209,9 +205,9 @@ | |||
209 | #define SPI_ILAT_CLR_TFI 0x00000800 /* Transmit Finish Indication */ | 205 | #define SPI_ILAT_CLR_TFI 0x00000800 /* Transmit Finish Indication */ |
210 | 206 | ||
211 | /* | 207 | /* |
212 | * bfin spi3 registers layout | 208 | * adi spi3 registers layout |
213 | */ | 209 | */ |
214 | struct bfin_spi_regs { | 210 | struct adi_spi_regs { |
215 | u32 revid; | 211 | u32 revid; |
216 | u32 control; | 212 | u32 control; |
217 | u32 rx_control; | 213 | u32 rx_control; |
@@ -240,7 +236,7 @@ struct bfin_spi_regs { | |||
240 | #define MAX_CTRL_CS 8 /* cs in spi controller */ | 236 | #define MAX_CTRL_CS 8 /* cs in spi controller */ |
241 | 237 | ||
242 | /* device.platform_data for SSP controller devices */ | 238 | /* device.platform_data for SSP controller devices */ |
243 | struct bfin_spi3_master { | 239 | struct adi_spi3_master { |
244 | u16 num_chipselect; | 240 | u16 num_chipselect; |
245 | u16 pin_req[7]; | 241 | u16 pin_req[7]; |
246 | }; | 242 | }; |
@@ -248,11 +244,11 @@ struct bfin_spi3_master { | |||
248 | /* spi_board_info.controller_data for SPI slave devices, | 244 | /* spi_board_info.controller_data for SPI slave devices, |
249 | * copied to spi_device.platform_data ... mostly for dma tuning | 245 | * copied to spi_device.platform_data ... mostly for dma tuning |
250 | */ | 246 | */ |
251 | struct bfin_spi3_chip { | 247 | struct adi_spi3_chip { |
252 | u32 control; | 248 | u32 control; |
253 | u16 cs_chg_udelay; /* Some devices require 16-bit delays */ | 249 | u16 cs_chg_udelay; /* Some devices require 16-bit delays */ |
254 | u32 tx_dummy_val; /* tx value for rx only transfer */ | 250 | u32 tx_dummy_val; /* tx value for rx only transfer */ |
255 | bool enable_dma; | 251 | bool enable_dma; |
256 | }; | 252 | }; |
257 | 253 | ||
258 | #endif /* _SPI_CHANNEL_H_ */ | 254 | #endif /* _ADI_SPI3_H_ */ |