diff options
137 files changed, 5820 insertions, 604 deletions
diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c index 5a375e5fef21..bc90364a96c7 100644 --- a/arch/arm/common/dmabounce.c +++ b/arch/arm/common/dmabounce.c | |||
@@ -308,15 +308,11 @@ static inline void unmap_single(struct device *dev, dma_addr_t dma_addr, | |||
308 | memcpy(ptr, buf->safe, size); | 308 | memcpy(ptr, buf->safe, size); |
309 | 309 | ||
310 | /* | 310 | /* |
311 | * DMA buffers must have the same cache properties | 311 | * Since we may have written to a page cache page, |
312 | * as if they were really used for DMA - which means | 312 | * we need to ensure that the data will be coherent |
313 | * data must be written back to RAM. Note that | 313 | * with user mappings. |
314 | * we don't use dmac_flush_range() here for the | ||
315 | * bidirectional case because we know the cache | ||
316 | * lines will be coherent with the data written. | ||
317 | */ | 314 | */ |
318 | dmac_clean_range(ptr, ptr + size); | 315 | __cpuc_flush_kernel_dcache_area(ptr, size); |
319 | outer_clean_range(__pa(ptr), __pa(ptr) + size); | ||
320 | } | 316 | } |
321 | free_safe_buffer(dev->archdata.dmabounce, buf); | 317 | free_safe_buffer(dev->archdata.dmabounce, buf); |
322 | } | 318 | } |
diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h index 73eceb87e588..730aefcfbee3 100644 --- a/arch/arm/include/asm/cacheflush.h +++ b/arch/arm/include/asm/cacheflush.h | |||
@@ -211,7 +211,7 @@ struct cpu_cache_fns { | |||
211 | 211 | ||
212 | void (*coherent_kern_range)(unsigned long, unsigned long); | 212 | void (*coherent_kern_range)(unsigned long, unsigned long); |
213 | void (*coherent_user_range)(unsigned long, unsigned long); | 213 | void (*coherent_user_range)(unsigned long, unsigned long); |
214 | void (*flush_kern_dcache_page)(void *); | 214 | void (*flush_kern_dcache_area)(void *, size_t); |
215 | 215 | ||
216 | void (*dma_inv_range)(const void *, const void *); | 216 | void (*dma_inv_range)(const void *, const void *); |
217 | void (*dma_clean_range)(const void *, const void *); | 217 | void (*dma_clean_range)(const void *, const void *); |
@@ -236,7 +236,7 @@ extern struct cpu_cache_fns cpu_cache; | |||
236 | #define __cpuc_flush_user_range cpu_cache.flush_user_range | 236 | #define __cpuc_flush_user_range cpu_cache.flush_user_range |
237 | #define __cpuc_coherent_kern_range cpu_cache.coherent_kern_range | 237 | #define __cpuc_coherent_kern_range cpu_cache.coherent_kern_range |
238 | #define __cpuc_coherent_user_range cpu_cache.coherent_user_range | 238 | #define __cpuc_coherent_user_range cpu_cache.coherent_user_range |
239 | #define __cpuc_flush_dcache_page cpu_cache.flush_kern_dcache_page | 239 | #define __cpuc_flush_dcache_area cpu_cache.flush_kern_dcache_area |
240 | 240 | ||
241 | /* | 241 | /* |
242 | * These are private to the dma-mapping API. Do not use directly. | 242 | * These are private to the dma-mapping API. Do not use directly. |
@@ -255,14 +255,14 @@ extern struct cpu_cache_fns cpu_cache; | |||
255 | #define __cpuc_flush_user_range __glue(_CACHE,_flush_user_cache_range) | 255 | #define __cpuc_flush_user_range __glue(_CACHE,_flush_user_cache_range) |
256 | #define __cpuc_coherent_kern_range __glue(_CACHE,_coherent_kern_range) | 256 | #define __cpuc_coherent_kern_range __glue(_CACHE,_coherent_kern_range) |
257 | #define __cpuc_coherent_user_range __glue(_CACHE,_coherent_user_range) | 257 | #define __cpuc_coherent_user_range __glue(_CACHE,_coherent_user_range) |
258 | #define __cpuc_flush_dcache_page __glue(_CACHE,_flush_kern_dcache_page) | 258 | #define __cpuc_flush_dcache_area __glue(_CACHE,_flush_kern_dcache_area) |
259 | 259 | ||
260 | extern void __cpuc_flush_kern_all(void); | 260 | extern void __cpuc_flush_kern_all(void); |
261 | extern void __cpuc_flush_user_all(void); | 261 | extern void __cpuc_flush_user_all(void); |
262 | extern void __cpuc_flush_user_range(unsigned long, unsigned long, unsigned int); | 262 | extern void __cpuc_flush_user_range(unsigned long, unsigned long, unsigned int); |
263 | extern void __cpuc_coherent_kern_range(unsigned long, unsigned long); | 263 | extern void __cpuc_coherent_kern_range(unsigned long, unsigned long); |
264 | extern void __cpuc_coherent_user_range(unsigned long, unsigned long); | 264 | extern void __cpuc_coherent_user_range(unsigned long, unsigned long); |
265 | extern void __cpuc_flush_dcache_page(void *); | 265 | extern void __cpuc_flush_dcache_area(void *, size_t); |
266 | 266 | ||
267 | /* | 267 | /* |
268 | * These are private to the dma-mapping API. Do not use directly. | 268 | * These are private to the dma-mapping API. Do not use directly. |
@@ -448,7 +448,7 @@ static inline void flush_kernel_dcache_page(struct page *page) | |||
448 | { | 448 | { |
449 | /* highmem pages are always flushed upon kunmap already */ | 449 | /* highmem pages are always flushed upon kunmap already */ |
450 | if ((cache_is_vivt() || cache_is_vipt_aliasing()) && !PageHighMem(page)) | 450 | if ((cache_is_vivt() || cache_is_vipt_aliasing()) && !PageHighMem(page)) |
451 | __cpuc_flush_dcache_page(page_address(page)); | 451 | __cpuc_flush_dcache_area(page_address(page), PAGE_SIZE); |
452 | } | 452 | } |
453 | 453 | ||
454 | #define flush_dcache_mmap_lock(mapping) \ | 454 | #define flush_dcache_mmap_lock(mapping) \ |
@@ -465,13 +465,6 @@ static inline void flush_kernel_dcache_page(struct page *page) | |||
465 | */ | 465 | */ |
466 | #define flush_icache_page(vma,page) do { } while (0) | 466 | #define flush_icache_page(vma,page) do { } while (0) |
467 | 467 | ||
468 | static inline void flush_ioremap_region(unsigned long phys, void __iomem *virt, | ||
469 | unsigned offset, size_t size) | ||
470 | { | ||
471 | const void *start = (void __force *)virt + offset; | ||
472 | dmac_inv_range(start, start + size); | ||
473 | } | ||
474 | |||
475 | /* | 468 | /* |
476 | * flush_cache_vmap() is used when creating mappings (eg, via vmap, | 469 | * flush_cache_vmap() is used when creating mappings (eg, via vmap, |
477 | * vmalloc, ioremap etc) in kernel space for pages. On non-VIPT | 470 | * vmalloc, ioremap etc) in kernel space for pages. On non-VIPT |
diff --git a/arch/arm/mach-kirkwood/Kconfig b/arch/arm/mach-kirkwood/Kconfig index 8bf09ae5b347..f6c6196a51fa 100644 --- a/arch/arm/mach-kirkwood/Kconfig +++ b/arch/arm/mach-kirkwood/Kconfig | |||
@@ -52,6 +52,12 @@ config MACH_OPENRD_BASE | |||
52 | Say 'Y' here if you want your kernel to support the | 52 | Say 'Y' here if you want your kernel to support the |
53 | Marvell OpenRD Base Board. | 53 | Marvell OpenRD Base Board. |
54 | 54 | ||
55 | config MACH_NETSPACE_V2 | ||
56 | bool "LaCie Network Space v2 NAS Board" | ||
57 | help | ||
58 | Say 'Y' here if you want your kernel to support the | ||
59 | LaCie Network Space v2 NAS. | ||
60 | |||
55 | endmenu | 61 | endmenu |
56 | 62 | ||
57 | endif | 63 | endif |
diff --git a/arch/arm/mach-kirkwood/Makefile b/arch/arm/mach-kirkwood/Makefile index 9f2f67b2b63d..d4d7f53b0fb9 100644 --- a/arch/arm/mach-kirkwood/Makefile +++ b/arch/arm/mach-kirkwood/Makefile | |||
@@ -8,5 +8,6 @@ obj-$(CONFIG_MACH_SHEEVAPLUG) += sheevaplug-setup.o | |||
8 | obj-$(CONFIG_MACH_TS219) += ts219-setup.o tsx1x-common.o | 8 | obj-$(CONFIG_MACH_TS219) += ts219-setup.o tsx1x-common.o |
9 | obj-$(CONFIG_MACH_TS41X) += ts41x-setup.o tsx1x-common.o | 9 | obj-$(CONFIG_MACH_TS41X) += ts41x-setup.o tsx1x-common.o |
10 | obj-$(CONFIG_MACH_OPENRD_BASE) += openrd_base-setup.o | 10 | obj-$(CONFIG_MACH_OPENRD_BASE) += openrd_base-setup.o |
11 | obj-$(CONFIG_MACH_NETSPACE_V2) += netspace_v2-setup.o | ||
11 | 12 | ||
12 | obj-$(CONFIG_CPU_IDLE) += cpuidle.o | 13 | obj-$(CONFIG_CPU_IDLE) += cpuidle.o |
diff --git a/arch/arm/mach-kirkwood/netspace_v2-setup.c b/arch/arm/mach-kirkwood/netspace_v2-setup.c new file mode 100644 index 000000000000..9a064065bebe --- /dev/null +++ b/arch/arm/mach-kirkwood/netspace_v2-setup.c | |||
@@ -0,0 +1,325 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-kirkwood/netspace_v2-setup.c | ||
3 | * | ||
4 | * LaCie Network Space v2 board setup | ||
5 | * | ||
6 | * Copyright (C) 2009 Simon Guinot <sguinot@lacie.com> | ||
7 | * Copyright (C) 2009 Benoît Canet <benoit.canet@gmail.com> | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation; either version 2 of the License, or | ||
12 | * (at your option) any later version. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | * GNU General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, write to the Free Software | ||
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
22 | */ | ||
23 | |||
24 | #include <linux/kernel.h> | ||
25 | #include <linux/init.h> | ||
26 | #include <linux/platform_device.h> | ||
27 | #include <linux/mtd/physmap.h> | ||
28 | #include <linux/spi/flash.h> | ||
29 | #include <linux/spi/spi.h> | ||
30 | #include <linux/ata_platform.h> | ||
31 | #include <linux/mv643xx_eth.h> | ||
32 | #include <linux/i2c.h> | ||
33 | #include <linux/i2c/at24.h> | ||
34 | #include <linux/input.h> | ||
35 | #include <linux/gpio.h> | ||
36 | #include <linux/gpio_keys.h> | ||
37 | #include <linux/leds.h> | ||
38 | #include <asm/mach-types.h> | ||
39 | #include <asm/mach/arch.h> | ||
40 | #include <asm/mach/time.h> | ||
41 | #include <mach/kirkwood.h> | ||
42 | #include <plat/time.h> | ||
43 | #include "common.h" | ||
44 | #include "mpp.h" | ||
45 | |||
46 | /***************************************************************************** | ||
47 | * 512KB SPI Flash on Boot Device (MACRONIX MX25L4005) | ||
48 | ****************************************************************************/ | ||
49 | |||
50 | static struct mtd_partition netspace_v2_flash_parts[] = { | ||
51 | { | ||
52 | .name = "u-boot", | ||
53 | .size = MTDPART_SIZ_FULL, | ||
54 | .offset = 0, | ||
55 | .mask_flags = MTD_WRITEABLE, /* force read-only */ | ||
56 | }, | ||
57 | }; | ||
58 | |||
59 | static const struct flash_platform_data netspace_v2_flash = { | ||
60 | .type = "mx25l4005a", | ||
61 | .name = "spi_flash", | ||
62 | .parts = netspace_v2_flash_parts, | ||
63 | .nr_parts = ARRAY_SIZE(netspace_v2_flash_parts), | ||
64 | }; | ||
65 | |||
66 | static struct spi_board_info __initdata netspace_v2_spi_slave_info[] = { | ||
67 | { | ||
68 | .modalias = "m25p80", | ||
69 | .platform_data = &netspace_v2_flash, | ||
70 | .irq = -1, | ||
71 | .max_speed_hz = 20000000, | ||
72 | .bus_num = 0, | ||
73 | .chip_select = 0, | ||
74 | }, | ||
75 | }; | ||
76 | |||
77 | /***************************************************************************** | ||
78 | * Ethernet | ||
79 | ****************************************************************************/ | ||
80 | |||
81 | static struct mv643xx_eth_platform_data netspace_v2_ge00_data = { | ||
82 | .phy_addr = MV643XX_ETH_PHY_ADDR(8), | ||
83 | }; | ||
84 | |||
85 | /***************************************************************************** | ||
86 | * I2C devices | ||
87 | ****************************************************************************/ | ||
88 | |||
89 | static struct at24_platform_data at24c04 = { | ||
90 | .byte_len = SZ_4K / 8, | ||
91 | .page_size = 16, | ||
92 | }; | ||
93 | |||
94 | /* | ||
95 | * i2c addr | chip | description | ||
96 | * 0x50 | HT24LC04 | eeprom (512B) | ||
97 | */ | ||
98 | |||
99 | static struct i2c_board_info __initdata netspace_v2_i2c_info[] = { | ||
100 | { | ||
101 | I2C_BOARD_INFO("24c04", 0x50), | ||
102 | .platform_data = &at24c04, | ||
103 | } | ||
104 | }; | ||
105 | |||
106 | /***************************************************************************** | ||
107 | * SATA | ||
108 | ****************************************************************************/ | ||
109 | |||
110 | static struct mv_sata_platform_data netspace_v2_sata_data = { | ||
111 | .n_ports = 2, | ||
112 | }; | ||
113 | |||
114 | #define NETSPACE_V2_GPIO_SATA0_POWER 16 | ||
115 | #define NETSPACE_V2_GPIO_SATA1_POWER 17 | ||
116 | |||
117 | static void __init netspace_v2_sata_power_init(void) | ||
118 | { | ||
119 | int err; | ||
120 | |||
121 | err = gpio_request(NETSPACE_V2_GPIO_SATA0_POWER, "SATA0 power"); | ||
122 | if (err == 0) { | ||
123 | err = gpio_direction_output(NETSPACE_V2_GPIO_SATA0_POWER, 1); | ||
124 | if (err) | ||
125 | gpio_free(NETSPACE_V2_GPIO_SATA0_POWER); | ||
126 | } | ||
127 | if (err) | ||
128 | pr_err("netspace_v2: failed to setup SATA0 power\n"); | ||
129 | } | ||
130 | |||
131 | /***************************************************************************** | ||
132 | * GPIO keys | ||
133 | ****************************************************************************/ | ||
134 | |||
135 | #define NETSPACE_V2_PUSH_BUTTON 32 | ||
136 | |||
137 | static struct gpio_keys_button netspace_v2_buttons[] = { | ||
138 | [0] = { | ||
139 | .code = KEY_POWER, | ||
140 | .gpio = NETSPACE_V2_PUSH_BUTTON, | ||
141 | .desc = "Power push button", | ||
142 | .active_low = 0, | ||
143 | }, | ||
144 | }; | ||
145 | |||
146 | static struct gpio_keys_platform_data netspace_v2_button_data = { | ||
147 | .buttons = netspace_v2_buttons, | ||
148 | .nbuttons = ARRAY_SIZE(netspace_v2_buttons), | ||
149 | }; | ||
150 | |||
151 | static struct platform_device netspace_v2_gpio_buttons = { | ||
152 | .name = "gpio-keys", | ||
153 | .id = -1, | ||
154 | .dev = { | ||
155 | .platform_data = &netspace_v2_button_data, | ||
156 | }, | ||
157 | }; | ||
158 | |||
159 | /***************************************************************************** | ||
160 | * GPIO LEDs | ||
161 | ****************************************************************************/ | ||
162 | |||
163 | /* | ||
164 | * The blue front LED is wired to a CPLD and can blink in relation with the | ||
165 | * SATA activity. | ||
166 | * | ||
167 | * The following array detail the different LED registers and the combination | ||
168 | * of their possible values: | ||
169 | * | ||
170 | * cmd_led | slow_led | /SATA active | LED state | ||
171 | * | | | | ||
172 | * 1 | 0 | x | off | ||
173 | * - | 1 | x | on | ||
174 | * 0 | 0 | 1 | on | ||
175 | * 0 | 0 | 0 | blink (rate 300ms) | ||
176 | */ | ||
177 | |||
178 | #define NETSPACE_V2_GPIO_RED_LED 12 | ||
179 | #define NETSPACE_V2_GPIO_BLUE_LED_SLOW 29 | ||
180 | #define NETSPACE_V2_GPIO_BLUE_LED_CMD 30 | ||
181 | |||
182 | |||
183 | static struct gpio_led netspace_v2_gpio_led_pins[] = { | ||
184 | { | ||
185 | .name = "ns_v2:red:fail", | ||
186 | .gpio = NETSPACE_V2_GPIO_RED_LED, | ||
187 | }, | ||
188 | }; | ||
189 | |||
190 | static struct gpio_led_platform_data netspace_v2_gpio_leds_data = { | ||
191 | .num_leds = ARRAY_SIZE(netspace_v2_gpio_led_pins), | ||
192 | .leds = netspace_v2_gpio_led_pins, | ||
193 | }; | ||
194 | |||
195 | static struct platform_device netspace_v2_gpio_leds = { | ||
196 | .name = "leds-gpio", | ||
197 | .id = -1, | ||
198 | .dev = { | ||
199 | .platform_data = &netspace_v2_gpio_leds_data, | ||
200 | }, | ||
201 | }; | ||
202 | |||
203 | static void __init netspace_v2_gpio_leds_init(void) | ||
204 | { | ||
205 | platform_device_register(&netspace_v2_gpio_leds); | ||
206 | |||
207 | /* | ||
208 | * Configure the front blue LED to blink in relation with the SATA | ||
209 | * activity. | ||
210 | */ | ||
211 | if (gpio_request(NETSPACE_V2_GPIO_BLUE_LED_SLOW, | ||
212 | "SATA blue LED slow") != 0) | ||
213 | return; | ||
214 | if (gpio_direction_output(NETSPACE_V2_GPIO_BLUE_LED_SLOW, 0) != 0) | ||
215 | goto err_free_1; | ||
216 | if (gpio_request(NETSPACE_V2_GPIO_BLUE_LED_CMD, | ||
217 | "SATA blue LED command") != 0) | ||
218 | goto err_free_1; | ||
219 | if (gpio_direction_output(NETSPACE_V2_GPIO_BLUE_LED_CMD, 0) != 0) | ||
220 | goto err_free_2; | ||
221 | |||
222 | return; | ||
223 | |||
224 | err_free_2: | ||
225 | gpio_free(NETSPACE_V2_GPIO_BLUE_LED_CMD); | ||
226 | err_free_1: | ||
227 | gpio_free(NETSPACE_V2_GPIO_BLUE_LED_SLOW); | ||
228 | pr_err("netspace_v2: failed to configure SATA blue LED\n"); | ||
229 | } | ||
230 | |||
231 | /***************************************************************************** | ||
232 | * Timer | ||
233 | ****************************************************************************/ | ||
234 | |||
235 | static void netspace_v2_timer_init(void) | ||
236 | { | ||
237 | kirkwood_tclk = 166666667; | ||
238 | orion_time_init(IRQ_KIRKWOOD_BRIDGE, kirkwood_tclk); | ||
239 | } | ||
240 | |||
241 | struct sys_timer netspace_v2_timer = { | ||
242 | .init = netspace_v2_timer_init, | ||
243 | }; | ||
244 | |||
245 | /***************************************************************************** | ||
246 | * General Setup | ||
247 | ****************************************************************************/ | ||
248 | |||
249 | static unsigned int netspace_v2_mpp_config[] __initdata = { | ||
250 | MPP0_SPI_SCn, | ||
251 | MPP1_SPI_MOSI, | ||
252 | MPP2_SPI_SCK, | ||
253 | MPP3_SPI_MISO, | ||
254 | MPP4_NF_IO6, | ||
255 | MPP5_NF_IO7, | ||
256 | MPP6_SYSRST_OUTn, | ||
257 | MPP8_TW_SDA, | ||
258 | MPP9_TW_SCK, | ||
259 | MPP10_UART0_TXD, | ||
260 | MPP11_UART0_RXD, | ||
261 | MPP12_GPO, /* Red led */ | ||
262 | MPP14_GPIO, /* USB fuse */ | ||
263 | MPP16_GPIO, /* SATA 0 power */ | ||
264 | MPP18_NF_IO0, | ||
265 | MPP19_NF_IO1, | ||
266 | MPP20_SATA1_ACTn, | ||
267 | MPP21_SATA0_ACTn, | ||
268 | MPP24_GPIO, /* USB mode select */ | ||
269 | MPP25_GPIO, /* Fan rotation fail */ | ||
270 | MPP26_GPIO, /* USB device vbus */ | ||
271 | MPP28_GPIO, /* USB enable host vbus */ | ||
272 | MPP29_GPIO, /* Blue led (slow register) */ | ||
273 | MPP30_GPIO, /* Blue led (command register) */ | ||
274 | MPP31_GPIO, /* Board power off */ | ||
275 | MPP32_GPIO, /* Power button (0 = Released, 1 = Pushed) */ | ||
276 | 0 | ||
277 | }; | ||
278 | |||
279 | #define NETSPACE_V2_GPIO_POWER_OFF 31 | ||
280 | |||
281 | static void netspace_v2_power_off(void) | ||
282 | { | ||
283 | gpio_set_value(NETSPACE_V2_GPIO_POWER_OFF, 1); | ||
284 | } | ||
285 | |||
286 | static void __init netspace_v2_init(void) | ||
287 | { | ||
288 | /* | ||
289 | * Basic setup. Needs to be called early. | ||
290 | */ | ||
291 | kirkwood_init(); | ||
292 | kirkwood_mpp_conf(netspace_v2_mpp_config); | ||
293 | |||
294 | netspace_v2_sata_power_init(); | ||
295 | |||
296 | kirkwood_ehci_init(); | ||
297 | kirkwood_ge00_init(&netspace_v2_ge00_data); | ||
298 | kirkwood_sata_init(&netspace_v2_sata_data); | ||
299 | kirkwood_uart0_init(); | ||
300 | spi_register_board_info(netspace_v2_spi_slave_info, | ||
301 | ARRAY_SIZE(netspace_v2_spi_slave_info)); | ||
302 | kirkwood_spi_init(); | ||
303 | kirkwood_i2c_init(); | ||
304 | i2c_register_board_info(0, netspace_v2_i2c_info, | ||
305 | ARRAY_SIZE(netspace_v2_i2c_info)); | ||
306 | |||
307 | netspace_v2_gpio_leds_init(); | ||
308 | platform_device_register(&netspace_v2_gpio_buttons); | ||
309 | |||
310 | if (gpio_request(NETSPACE_V2_GPIO_POWER_OFF, "power-off") == 0 && | ||
311 | gpio_direction_output(NETSPACE_V2_GPIO_POWER_OFF, 0) == 0) | ||
312 | pm_power_off = netspace_v2_power_off; | ||
313 | else | ||
314 | pr_err("netspace_v2: failed to configure power-off GPIO\n"); | ||
315 | } | ||
316 | |||
317 | MACHINE_START(NETSPACE_V2, "LaCie Network Space v2") | ||
318 | .phys_io = KIRKWOOD_REGS_PHYS_BASE, | ||
319 | .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc, | ||
320 | .boot_params = 0x00000100, | ||
321 | .init_machine = netspace_v2_init, | ||
322 | .map_io = kirkwood_map_io, | ||
323 | .init_irq = kirkwood_init_irq, | ||
324 | .timer = &netspace_v2_timer, | ||
325 | MACHINE_END | ||
diff --git a/arch/arm/mach-pxa/Kconfig b/arch/arm/mach-pxa/Kconfig index e6d8e10ae5d1..8a0837ea0294 100644 --- a/arch/arm/mach-pxa/Kconfig +++ b/arch/arm/mach-pxa/Kconfig | |||
@@ -110,6 +110,8 @@ config MACH_CM_X300 | |||
110 | bool "CompuLab CM-X300 modules" | 110 | bool "CompuLab CM-X300 modules" |
111 | select PXA3xx | 111 | select PXA3xx |
112 | select CPU_PXA300 | 112 | select CPU_PXA300 |
113 | select CPU_PXA310 | ||
114 | select HAVE_PWM | ||
113 | 115 | ||
114 | config ARCH_GUMSTIX | 116 | config ARCH_GUMSTIX |
115 | bool "Gumstix XScale 255 boards" | 117 | bool "Gumstix XScale 255 boards" |
@@ -240,7 +242,6 @@ config MACH_COLIBRI300 | |||
240 | select PXA3xx | 242 | select PXA3xx |
241 | select CPU_PXA300 | 243 | select CPU_PXA300 |
242 | select CPU_PXA310 | 244 | select CPU_PXA310 |
243 | select HAVE_PWM | ||
244 | 245 | ||
245 | config MACH_COLIBRI320 | 246 | config MACH_COLIBRI320 |
246 | bool "Toradex Colibri PXA320" | 247 | bool "Toradex Colibri PXA320" |
diff --git a/arch/arm/mach-pxa/devices.c b/arch/arm/mach-pxa/devices.c index 3395463bb5a6..8e10db148f1b 100644 --- a/arch/arm/mach-pxa/devices.c +++ b/arch/arm/mach-pxa/devices.c | |||
@@ -4,7 +4,6 @@ | |||
4 | #include <linux/platform_device.h> | 4 | #include <linux/platform_device.h> |
5 | #include <linux/dma-mapping.h> | 5 | #include <linux/dma-mapping.h> |
6 | 6 | ||
7 | #include <mach/hardware.h> | ||
8 | #include <mach/udc.h> | 7 | #include <mach/udc.h> |
9 | #include <mach/pxafb.h> | 8 | #include <mach/pxafb.h> |
10 | #include <mach/mmc.h> | 9 | #include <mach/mmc.h> |
@@ -14,6 +13,7 @@ | |||
14 | #include <mach/pxa2xx_spi.h> | 13 | #include <mach/pxa2xx_spi.h> |
15 | #include <mach/camera.h> | 14 | #include <mach/camera.h> |
16 | #include <mach/audio.h> | 15 | #include <mach/audio.h> |
16 | #include <mach/hardware.h> | ||
17 | #include <plat/i2c.h> | 17 | #include <plat/i2c.h> |
18 | #include <plat/pxa3xx_nand.h> | 18 | #include <plat/pxa3xx_nand.h> |
19 | 19 | ||
diff --git a/arch/arm/mach-s3c2410/include/mach/spi.h b/arch/arm/mach-s3c2410/include/mach/spi.h index 193b39d654ed..4d9588373aa5 100644 --- a/arch/arm/mach-s3c2410/include/mach/spi.h +++ b/arch/arm/mach-s3c2410/include/mach/spi.h | |||
@@ -18,6 +18,8 @@ struct s3c2410_spi_info { | |||
18 | unsigned int num_cs; /* total chipselects */ | 18 | unsigned int num_cs; /* total chipselects */ |
19 | int bus_num; /* bus number to use. */ | 19 | int bus_num; /* bus number to use. */ |
20 | 20 | ||
21 | unsigned int use_fiq:1; /* use fiq */ | ||
22 | |||
21 | void (*gpio_setup)(struct s3c2410_spi_info *spi, int enable); | 23 | void (*gpio_setup)(struct s3c2410_spi_info *spi, int enable); |
22 | void (*set_cs)(struct s3c2410_spi_info *spi, int cs, int pol); | 24 | void (*set_cs)(struct s3c2410_spi_info *spi, int cs, int pol); |
23 | }; | 25 | }; |
diff --git a/arch/arm/mm/cache-fa.S b/arch/arm/mm/cache-fa.S index b63a8f7b95cf..a89444a3c016 100644 --- a/arch/arm/mm/cache-fa.S +++ b/arch/arm/mm/cache-fa.S | |||
@@ -127,15 +127,16 @@ ENTRY(fa_coherent_user_range) | |||
127 | mov pc, lr | 127 | mov pc, lr |
128 | 128 | ||
129 | /* | 129 | /* |
130 | * flush_kern_dcache_page(kaddr) | 130 | * flush_kern_dcache_area(void *addr, size_t size) |
131 | * | 131 | * |
132 | * Ensure that the data held in the page kaddr is written back | 132 | * Ensure that the data held in the page kaddr is written back |
133 | * to the page in question. | 133 | * to the page in question. |
134 | * | 134 | * |
135 | * - kaddr - kernel address (guaranteed to be page aligned) | 135 | * - addr - kernel address |
136 | * - size - size of region | ||
136 | */ | 137 | */ |
137 | ENTRY(fa_flush_kern_dcache_page) | 138 | ENTRY(fa_flush_kern_dcache_area) |
138 | add r1, r0, #PAGE_SZ | 139 | add r1, r0, r1 |
139 | 1: mcr p15, 0, r0, c7, c14, 1 @ clean & invalidate D line | 140 | 1: mcr p15, 0, r0, c7, c14, 1 @ clean & invalidate D line |
140 | add r0, r0, #CACHE_DLINESIZE | 141 | add r0, r0, #CACHE_DLINESIZE |
141 | cmp r0, r1 | 142 | cmp r0, r1 |
@@ -213,7 +214,7 @@ ENTRY(fa_cache_fns) | |||
213 | .long fa_flush_user_cache_range | 214 | .long fa_flush_user_cache_range |
214 | .long fa_coherent_kern_range | 215 | .long fa_coherent_kern_range |
215 | .long fa_coherent_user_range | 216 | .long fa_coherent_user_range |
216 | .long fa_flush_kern_dcache_page | 217 | .long fa_flush_kern_dcache_area |
217 | .long fa_dma_inv_range | 218 | .long fa_dma_inv_range |
218 | .long fa_dma_clean_range | 219 | .long fa_dma_clean_range |
219 | .long fa_dma_flush_range | 220 | .long fa_dma_flush_range |
diff --git a/arch/arm/mm/cache-l2x0.c b/arch/arm/mm/cache-l2x0.c index 747f9a9021bb..cb8fc6573b1b 100644 --- a/arch/arm/mm/cache-l2x0.c +++ b/arch/arm/mm/cache-l2x0.c | |||
@@ -28,69 +28,120 @@ | |||
28 | static void __iomem *l2x0_base; | 28 | static void __iomem *l2x0_base; |
29 | static DEFINE_SPINLOCK(l2x0_lock); | 29 | static DEFINE_SPINLOCK(l2x0_lock); |
30 | 30 | ||
31 | static inline void sync_writel(unsigned long val, unsigned long reg, | 31 | static inline void cache_wait(void __iomem *reg, unsigned long mask) |
32 | unsigned long complete_mask) | ||
33 | { | 32 | { |
34 | unsigned long flags; | ||
35 | |||
36 | spin_lock_irqsave(&l2x0_lock, flags); | ||
37 | writel(val, l2x0_base + reg); | ||
38 | /* wait for the operation to complete */ | 33 | /* wait for the operation to complete */ |
39 | while (readl(l2x0_base + reg) & complete_mask) | 34 | while (readl(reg) & mask) |
40 | ; | 35 | ; |
41 | spin_unlock_irqrestore(&l2x0_lock, flags); | ||
42 | } | 36 | } |
43 | 37 | ||
44 | static inline void cache_sync(void) | 38 | static inline void cache_sync(void) |
45 | { | 39 | { |
46 | sync_writel(0, L2X0_CACHE_SYNC, 1); | 40 | void __iomem *base = l2x0_base; |
41 | writel(0, base + L2X0_CACHE_SYNC); | ||
42 | cache_wait(base + L2X0_CACHE_SYNC, 1); | ||
47 | } | 43 | } |
48 | 44 | ||
49 | static inline void l2x0_inv_all(void) | 45 | static inline void l2x0_inv_all(void) |
50 | { | 46 | { |
47 | unsigned long flags; | ||
48 | |||
51 | /* invalidate all ways */ | 49 | /* invalidate all ways */ |
52 | sync_writel(0xff, L2X0_INV_WAY, 0xff); | 50 | spin_lock_irqsave(&l2x0_lock, flags); |
51 | writel(0xff, l2x0_base + L2X0_INV_WAY); | ||
52 | cache_wait(l2x0_base + L2X0_INV_WAY, 0xff); | ||
53 | cache_sync(); | 53 | cache_sync(); |
54 | spin_unlock_irqrestore(&l2x0_lock, flags); | ||
54 | } | 55 | } |
55 | 56 | ||
56 | static void l2x0_inv_range(unsigned long start, unsigned long end) | 57 | static void l2x0_inv_range(unsigned long start, unsigned long end) |
57 | { | 58 | { |
58 | unsigned long addr; | 59 | void __iomem *base = l2x0_base; |
60 | unsigned long flags; | ||
59 | 61 | ||
62 | spin_lock_irqsave(&l2x0_lock, flags); | ||
60 | if (start & (CACHE_LINE_SIZE - 1)) { | 63 | if (start & (CACHE_LINE_SIZE - 1)) { |
61 | start &= ~(CACHE_LINE_SIZE - 1); | 64 | start &= ~(CACHE_LINE_SIZE - 1); |
62 | sync_writel(start, L2X0_CLEAN_INV_LINE_PA, 1); | 65 | cache_wait(base + L2X0_CLEAN_INV_LINE_PA, 1); |
66 | writel(start, base + L2X0_CLEAN_INV_LINE_PA); | ||
63 | start += CACHE_LINE_SIZE; | 67 | start += CACHE_LINE_SIZE; |
64 | } | 68 | } |
65 | 69 | ||
66 | if (end & (CACHE_LINE_SIZE - 1)) { | 70 | if (end & (CACHE_LINE_SIZE - 1)) { |
67 | end &= ~(CACHE_LINE_SIZE - 1); | 71 | end &= ~(CACHE_LINE_SIZE - 1); |
68 | sync_writel(end, L2X0_CLEAN_INV_LINE_PA, 1); | 72 | cache_wait(base + L2X0_CLEAN_INV_LINE_PA, 1); |
73 | writel(end, base + L2X0_CLEAN_INV_LINE_PA); | ||
69 | } | 74 | } |
70 | 75 | ||
71 | for (addr = start; addr < end; addr += CACHE_LINE_SIZE) | 76 | while (start < end) { |
72 | sync_writel(addr, L2X0_INV_LINE_PA, 1); | 77 | unsigned long blk_end = start + min(end - start, 4096UL); |
78 | |||
79 | while (start < blk_end) { | ||
80 | cache_wait(base + L2X0_INV_LINE_PA, 1); | ||
81 | writel(start, base + L2X0_INV_LINE_PA); | ||
82 | start += CACHE_LINE_SIZE; | ||
83 | } | ||
84 | |||
85 | if (blk_end < end) { | ||
86 | spin_unlock_irqrestore(&l2x0_lock, flags); | ||
87 | spin_lock_irqsave(&l2x0_lock, flags); | ||
88 | } | ||
89 | } | ||
90 | cache_wait(base + L2X0_INV_LINE_PA, 1); | ||
73 | cache_sync(); | 91 | cache_sync(); |
92 | spin_unlock_irqrestore(&l2x0_lock, flags); | ||
74 | } | 93 | } |
75 | 94 | ||
76 | static void l2x0_clean_range(unsigned long start, unsigned long end) | 95 | static void l2x0_clean_range(unsigned long start, unsigned long end) |
77 | { | 96 | { |
78 | unsigned long addr; | 97 | void __iomem *base = l2x0_base; |
98 | unsigned long flags; | ||
79 | 99 | ||
100 | spin_lock_irqsave(&l2x0_lock, flags); | ||
80 | start &= ~(CACHE_LINE_SIZE - 1); | 101 | start &= ~(CACHE_LINE_SIZE - 1); |
81 | for (addr = start; addr < end; addr += CACHE_LINE_SIZE) | 102 | while (start < end) { |
82 | sync_writel(addr, L2X0_CLEAN_LINE_PA, 1); | 103 | unsigned long blk_end = start + min(end - start, 4096UL); |
104 | |||
105 | while (start < blk_end) { | ||
106 | cache_wait(base + L2X0_CLEAN_LINE_PA, 1); | ||
107 | writel(start, base + L2X0_CLEAN_LINE_PA); | ||
108 | start += CACHE_LINE_SIZE; | ||
109 | } | ||
110 | |||
111 | if (blk_end < end) { | ||
112 | spin_unlock_irqrestore(&l2x0_lock, flags); | ||
113 | spin_lock_irqsave(&l2x0_lock, flags); | ||
114 | } | ||
115 | } | ||
116 | cache_wait(base + L2X0_CLEAN_LINE_PA, 1); | ||
83 | cache_sync(); | 117 | cache_sync(); |
118 | spin_unlock_irqrestore(&l2x0_lock, flags); | ||
84 | } | 119 | } |
85 | 120 | ||
86 | static void l2x0_flush_range(unsigned long start, unsigned long end) | 121 | static void l2x0_flush_range(unsigned long start, unsigned long end) |
87 | { | 122 | { |
88 | unsigned long addr; | 123 | void __iomem *base = l2x0_base; |
124 | unsigned long flags; | ||
89 | 125 | ||
126 | spin_lock_irqsave(&l2x0_lock, flags); | ||
90 | start &= ~(CACHE_LINE_SIZE - 1); | 127 | start &= ~(CACHE_LINE_SIZE - 1); |
91 | for (addr = start; addr < end; addr += CACHE_LINE_SIZE) | 128 | while (start < end) { |
92 | sync_writel(addr, L2X0_CLEAN_INV_LINE_PA, 1); | 129 | unsigned long blk_end = start + min(end - start, 4096UL); |
130 | |||
131 | while (start < blk_end) { | ||
132 | cache_wait(base + L2X0_CLEAN_INV_LINE_PA, 1); | ||
133 | writel(start, base + L2X0_CLEAN_INV_LINE_PA); | ||
134 | start += CACHE_LINE_SIZE; | ||
135 | } | ||
136 | |||
137 | if (blk_end < end) { | ||
138 | spin_unlock_irqrestore(&l2x0_lock, flags); | ||
139 | spin_lock_irqsave(&l2x0_lock, flags); | ||
140 | } | ||
141 | } | ||
142 | cache_wait(base + L2X0_CLEAN_INV_LINE_PA, 1); | ||
93 | cache_sync(); | 143 | cache_sync(); |
144 | spin_unlock_irqrestore(&l2x0_lock, flags); | ||
94 | } | 145 | } |
95 | 146 | ||
96 | void __init l2x0_init(void __iomem *base, __u32 aux_val, __u32 aux_mask) | 147 | void __init l2x0_init(void __iomem *base, __u32 aux_val, __u32 aux_mask) |
diff --git a/arch/arm/mm/cache-v3.S b/arch/arm/mm/cache-v3.S index 8a4abebc478a..2a482731ea36 100644 --- a/arch/arm/mm/cache-v3.S +++ b/arch/arm/mm/cache-v3.S | |||
@@ -72,14 +72,15 @@ ENTRY(v3_coherent_user_range) | |||
72 | mov pc, lr | 72 | mov pc, lr |
73 | 73 | ||
74 | /* | 74 | /* |
75 | * flush_kern_dcache_page(void *page) | 75 | * flush_kern_dcache_area(void *page, size_t size) |
76 | * | 76 | * |
77 | * Ensure no D cache aliasing occurs, either with itself or | 77 | * Ensure no D cache aliasing occurs, either with itself or |
78 | * the I cache | 78 | * the I cache |
79 | * | 79 | * |
80 | * - addr - page aligned address | 80 | * - addr - kernel address |
81 | * - size - region size | ||
81 | */ | 82 | */ |
82 | ENTRY(v3_flush_kern_dcache_page) | 83 | ENTRY(v3_flush_kern_dcache_area) |
83 | /* FALLTHROUGH */ | 84 | /* FALLTHROUGH */ |
84 | 85 | ||
85 | /* | 86 | /* |
@@ -129,7 +130,7 @@ ENTRY(v3_cache_fns) | |||
129 | .long v3_flush_user_cache_range | 130 | .long v3_flush_user_cache_range |
130 | .long v3_coherent_kern_range | 131 | .long v3_coherent_kern_range |
131 | .long v3_coherent_user_range | 132 | .long v3_coherent_user_range |
132 | .long v3_flush_kern_dcache_page | 133 | .long v3_flush_kern_dcache_area |
133 | .long v3_dma_inv_range | 134 | .long v3_dma_inv_range |
134 | .long v3_dma_clean_range | 135 | .long v3_dma_clean_range |
135 | .long v3_dma_flush_range | 136 | .long v3_dma_flush_range |
diff --git a/arch/arm/mm/cache-v4.S b/arch/arm/mm/cache-v4.S index 3668611cb400..5c7da3e372e9 100644 --- a/arch/arm/mm/cache-v4.S +++ b/arch/arm/mm/cache-v4.S | |||
@@ -82,14 +82,15 @@ ENTRY(v4_coherent_user_range) | |||
82 | mov pc, lr | 82 | mov pc, lr |
83 | 83 | ||
84 | /* | 84 | /* |
85 | * flush_kern_dcache_page(void *page) | 85 | * flush_kern_dcache_area(void *addr, size_t size) |
86 | * | 86 | * |
87 | * Ensure no D cache aliasing occurs, either with itself or | 87 | * Ensure no D cache aliasing occurs, either with itself or |
88 | * the I cache | 88 | * the I cache |
89 | * | 89 | * |
90 | * - addr - page aligned address | 90 | * - addr - kernel address |
91 | * - size - region size | ||
91 | */ | 92 | */ |
92 | ENTRY(v4_flush_kern_dcache_page) | 93 | ENTRY(v4_flush_kern_dcache_area) |
93 | /* FALLTHROUGH */ | 94 | /* FALLTHROUGH */ |
94 | 95 | ||
95 | /* | 96 | /* |
@@ -141,7 +142,7 @@ ENTRY(v4_cache_fns) | |||
141 | .long v4_flush_user_cache_range | 142 | .long v4_flush_user_cache_range |
142 | .long v4_coherent_kern_range | 143 | .long v4_coherent_kern_range |
143 | .long v4_coherent_user_range | 144 | .long v4_coherent_user_range |
144 | .long v4_flush_kern_dcache_page | 145 | .long v4_flush_kern_dcache_area |
145 | .long v4_dma_inv_range | 146 | .long v4_dma_inv_range |
146 | .long v4_dma_clean_range | 147 | .long v4_dma_clean_range |
147 | .long v4_dma_flush_range | 148 | .long v4_dma_flush_range |
diff --git a/arch/arm/mm/cache-v4wb.S b/arch/arm/mm/cache-v4wb.S index 2ebc1b3bf856..3dbedf1ec0e7 100644 --- a/arch/arm/mm/cache-v4wb.S +++ b/arch/arm/mm/cache-v4wb.S | |||
@@ -114,15 +114,16 @@ ENTRY(v4wb_flush_user_cache_range) | |||
114 | mov pc, lr | 114 | mov pc, lr |
115 | 115 | ||
116 | /* | 116 | /* |
117 | * flush_kern_dcache_page(void *page) | 117 | * flush_kern_dcache_area(void *addr, size_t size) |
118 | * | 118 | * |
119 | * Ensure no D cache aliasing occurs, either with itself or | 119 | * Ensure no D cache aliasing occurs, either with itself or |
120 | * the I cache | 120 | * the I cache |
121 | * | 121 | * |
122 | * - addr - page aligned address | 122 | * - addr - kernel address |
123 | * - size - region size | ||
123 | */ | 124 | */ |
124 | ENTRY(v4wb_flush_kern_dcache_page) | 125 | ENTRY(v4wb_flush_kern_dcache_area) |
125 | add r1, r0, #PAGE_SZ | 126 | add r1, r0, r1 |
126 | /* fall through */ | 127 | /* fall through */ |
127 | 128 | ||
128 | /* | 129 | /* |
@@ -224,7 +225,7 @@ ENTRY(v4wb_cache_fns) | |||
224 | .long v4wb_flush_user_cache_range | 225 | .long v4wb_flush_user_cache_range |
225 | .long v4wb_coherent_kern_range | 226 | .long v4wb_coherent_kern_range |
226 | .long v4wb_coherent_user_range | 227 | .long v4wb_coherent_user_range |
227 | .long v4wb_flush_kern_dcache_page | 228 | .long v4wb_flush_kern_dcache_area |
228 | .long v4wb_dma_inv_range | 229 | .long v4wb_dma_inv_range |
229 | .long v4wb_dma_clean_range | 230 | .long v4wb_dma_clean_range |
230 | .long v4wb_dma_flush_range | 231 | .long v4wb_dma_flush_range |
diff --git a/arch/arm/mm/cache-v4wt.S b/arch/arm/mm/cache-v4wt.S index c54fa2cc40e6..b3b7410270b4 100644 --- a/arch/arm/mm/cache-v4wt.S +++ b/arch/arm/mm/cache-v4wt.S | |||
@@ -117,17 +117,18 @@ ENTRY(v4wt_coherent_user_range) | |||
117 | mov pc, lr | 117 | mov pc, lr |
118 | 118 | ||
119 | /* | 119 | /* |
120 | * flush_kern_dcache_page(void *page) | 120 | * flush_kern_dcache_area(void *addr, size_t size) |
121 | * | 121 | * |
122 | * Ensure no D cache aliasing occurs, either with itself or | 122 | * Ensure no D cache aliasing occurs, either with itself or |
123 | * the I cache | 123 | * the I cache |
124 | * | 124 | * |
125 | * - addr - page aligned address | 125 | * - addr - kernel address |
126 | * - size - region size | ||
126 | */ | 127 | */ |
127 | ENTRY(v4wt_flush_kern_dcache_page) | 128 | ENTRY(v4wt_flush_kern_dcache_area) |
128 | mov r2, #0 | 129 | mov r2, #0 |
129 | mcr p15, 0, r2, c7, c5, 0 @ invalidate I cache | 130 | mcr p15, 0, r2, c7, c5, 0 @ invalidate I cache |
130 | add r1, r0, #PAGE_SZ | 131 | add r1, r0, r1 |
131 | /* fallthrough */ | 132 | /* fallthrough */ |
132 | 133 | ||
133 | /* | 134 | /* |
@@ -180,7 +181,7 @@ ENTRY(v4wt_cache_fns) | |||
180 | .long v4wt_flush_user_cache_range | 181 | .long v4wt_flush_user_cache_range |
181 | .long v4wt_coherent_kern_range | 182 | .long v4wt_coherent_kern_range |
182 | .long v4wt_coherent_user_range | 183 | .long v4wt_coherent_user_range |
183 | .long v4wt_flush_kern_dcache_page | 184 | .long v4wt_flush_kern_dcache_area |
184 | .long v4wt_dma_inv_range | 185 | .long v4wt_dma_inv_range |
185 | .long v4wt_dma_clean_range | 186 | .long v4wt_dma_clean_range |
186 | .long v4wt_dma_flush_range | 187 | .long v4wt_dma_flush_range |
diff --git a/arch/arm/mm/cache-v6.S b/arch/arm/mm/cache-v6.S index 295e25dd6381..4ba0a24ce6f5 100644 --- a/arch/arm/mm/cache-v6.S +++ b/arch/arm/mm/cache-v6.S | |||
@@ -159,15 +159,16 @@ ENDPROC(v6_coherent_user_range) | |||
159 | ENDPROC(v6_coherent_kern_range) | 159 | ENDPROC(v6_coherent_kern_range) |
160 | 160 | ||
161 | /* | 161 | /* |
162 | * v6_flush_kern_dcache_page(kaddr) | 162 | * v6_flush_kern_dcache_area(void *addr, size_t size) |
163 | * | 163 | * |
164 | * Ensure that the data held in the page kaddr is written back | 164 | * Ensure that the data held in the page kaddr is written back |
165 | * to the page in question. | 165 | * to the page in question. |
166 | * | 166 | * |
167 | * - kaddr - kernel address (guaranteed to be page aligned) | 167 | * - addr - kernel address |
168 | * - size - region size | ||
168 | */ | 169 | */ |
169 | ENTRY(v6_flush_kern_dcache_page) | 170 | ENTRY(v6_flush_kern_dcache_area) |
170 | add r1, r0, #PAGE_SZ | 171 | add r1, r0, r1 |
171 | 1: | 172 | 1: |
172 | #ifdef HARVARD_CACHE | 173 | #ifdef HARVARD_CACHE |
173 | mcr p15, 0, r0, c7, c14, 1 @ clean & invalidate D line | 174 | mcr p15, 0, r0, c7, c14, 1 @ clean & invalidate D line |
@@ -271,7 +272,7 @@ ENTRY(v6_cache_fns) | |||
271 | .long v6_flush_user_cache_range | 272 | .long v6_flush_user_cache_range |
272 | .long v6_coherent_kern_range | 273 | .long v6_coherent_kern_range |
273 | .long v6_coherent_user_range | 274 | .long v6_coherent_user_range |
274 | .long v6_flush_kern_dcache_page | 275 | .long v6_flush_kern_dcache_area |
275 | .long v6_dma_inv_range | 276 | .long v6_dma_inv_range |
276 | .long v6_dma_clean_range | 277 | .long v6_dma_clean_range |
277 | .long v6_dma_flush_range | 278 | .long v6_dma_flush_range |
diff --git a/arch/arm/mm/cache-v7.S b/arch/arm/mm/cache-v7.S index e1bd9759617f..9073db849fb4 100644 --- a/arch/arm/mm/cache-v7.S +++ b/arch/arm/mm/cache-v7.S | |||
@@ -186,16 +186,17 @@ ENDPROC(v7_coherent_kern_range) | |||
186 | ENDPROC(v7_coherent_user_range) | 186 | ENDPROC(v7_coherent_user_range) |
187 | 187 | ||
188 | /* | 188 | /* |
189 | * v7_flush_kern_dcache_page(kaddr) | 189 | * v7_flush_kern_dcache_area(void *addr, size_t size) |
190 | * | 190 | * |
191 | * Ensure that the data held in the page kaddr is written back | 191 | * Ensure that the data held in the page kaddr is written back |
192 | * to the page in question. | 192 | * to the page in question. |
193 | * | 193 | * |
194 | * - kaddr - kernel address (guaranteed to be page aligned) | 194 | * - addr - kernel address |
195 | * - size - region size | ||
195 | */ | 196 | */ |
196 | ENTRY(v7_flush_kern_dcache_page) | 197 | ENTRY(v7_flush_kern_dcache_area) |
197 | dcache_line_size r2, r3 | 198 | dcache_line_size r2, r3 |
198 | add r1, r0, #PAGE_SZ | 199 | add r1, r0, r1 |
199 | 1: | 200 | 1: |
200 | mcr p15, 0, r0, c7, c14, 1 @ clean & invalidate D line / unified line | 201 | mcr p15, 0, r0, c7, c14, 1 @ clean & invalidate D line / unified line |
201 | add r0, r0, r2 | 202 | add r0, r0, r2 |
@@ -203,7 +204,7 @@ ENTRY(v7_flush_kern_dcache_page) | |||
203 | blo 1b | 204 | blo 1b |
204 | dsb | 205 | dsb |
205 | mov pc, lr | 206 | mov pc, lr |
206 | ENDPROC(v7_flush_kern_dcache_page) | 207 | ENDPROC(v7_flush_kern_dcache_area) |
207 | 208 | ||
208 | /* | 209 | /* |
209 | * v7_dma_inv_range(start,end) | 210 | * v7_dma_inv_range(start,end) |
@@ -279,7 +280,7 @@ ENTRY(v7_cache_fns) | |||
279 | .long v7_flush_user_cache_range | 280 | .long v7_flush_user_cache_range |
280 | .long v7_coherent_kern_range | 281 | .long v7_coherent_kern_range |
281 | .long v7_coherent_user_range | 282 | .long v7_coherent_user_range |
282 | .long v7_flush_kern_dcache_page | 283 | .long v7_flush_kern_dcache_area |
283 | .long v7_dma_inv_range | 284 | .long v7_dma_inv_range |
284 | .long v7_dma_clean_range | 285 | .long v7_dma_clean_range |
285 | .long v7_dma_flush_range | 286 | .long v7_dma_flush_range |
diff --git a/arch/arm/mm/flush.c b/arch/arm/mm/flush.c index 329594e760cd..6f3a4b7a3b82 100644 --- a/arch/arm/mm/flush.c +++ b/arch/arm/mm/flush.c | |||
@@ -131,7 +131,7 @@ void __flush_dcache_page(struct address_space *mapping, struct page *page) | |||
131 | */ | 131 | */ |
132 | if (addr) | 132 | if (addr) |
133 | #endif | 133 | #endif |
134 | __cpuc_flush_dcache_page(addr); | 134 | __cpuc_flush_dcache_area(addr, PAGE_SIZE); |
135 | 135 | ||
136 | /* | 136 | /* |
137 | * If this is a page cache page, and we have an aliasing VIPT cache, | 137 | * If this is a page cache page, and we have an aliasing VIPT cache, |
@@ -258,5 +258,5 @@ void __flush_anon_page(struct vm_area_struct *vma, struct page *page, unsigned l | |||
258 | * in this mapping of the page. FIXME: this is overkill | 258 | * in this mapping of the page. FIXME: this is overkill |
259 | * since we actually ask for a write-back and invalidate. | 259 | * since we actually ask for a write-back and invalidate. |
260 | */ | 260 | */ |
261 | __cpuc_flush_dcache_page(page_address(page)); | 261 | __cpuc_flush_dcache_area(page_address(page), PAGE_SIZE); |
262 | } | 262 | } |
diff --git a/arch/arm/mm/highmem.c b/arch/arm/mm/highmem.c index 30f82fb5918c..2be1ec7c1b41 100644 --- a/arch/arm/mm/highmem.c +++ b/arch/arm/mm/highmem.c | |||
@@ -79,7 +79,7 @@ void kunmap_atomic(void *kvaddr, enum km_type type) | |||
79 | unsigned int idx = type + KM_TYPE_NR * smp_processor_id(); | 79 | unsigned int idx = type + KM_TYPE_NR * smp_processor_id(); |
80 | 80 | ||
81 | if (kvaddr >= (void *)FIXADDR_START) { | 81 | if (kvaddr >= (void *)FIXADDR_START) { |
82 | __cpuc_flush_dcache_page((void *)vaddr); | 82 | __cpuc_flush_dcache_area((void *)vaddr, PAGE_SIZE); |
83 | #ifdef CONFIG_DEBUG_HIGHMEM | 83 | #ifdef CONFIG_DEBUG_HIGHMEM |
84 | BUG_ON(vaddr != __fix_to_virt(FIX_KMAP_BEGIN + idx)); | 84 | BUG_ON(vaddr != __fix_to_virt(FIX_KMAP_BEGIN + idx)); |
85 | set_pte_ext(TOP_PTE(vaddr), __pte(0), 0); | 85 | set_pte_ext(TOP_PTE(vaddr), __pte(0), 0); |
diff --git a/arch/arm/mm/nommu.c b/arch/arm/mm/nommu.c index 900811cc9130..374a8311bc84 100644 --- a/arch/arm/mm/nommu.c +++ b/arch/arm/mm/nommu.c | |||
@@ -61,7 +61,7 @@ void setup_mm_for_reboot(char mode) | |||
61 | 61 | ||
62 | void flush_dcache_page(struct page *page) | 62 | void flush_dcache_page(struct page *page) |
63 | { | 63 | { |
64 | __cpuc_flush_dcache_page(page_address(page)); | 64 | __cpuc_flush_dcache_area(page_address(page), PAGE_SIZE); |
65 | } | 65 | } |
66 | EXPORT_SYMBOL(flush_dcache_page); | 66 | EXPORT_SYMBOL(flush_dcache_page); |
67 | 67 | ||
diff --git a/arch/arm/mm/proc-arm1020.S b/arch/arm/mm/proc-arm1020.S index d9fb4b98c49f..8012e24282b2 100644 --- a/arch/arm/mm/proc-arm1020.S +++ b/arch/arm/mm/proc-arm1020.S | |||
@@ -231,17 +231,18 @@ ENTRY(arm1020_coherent_user_range) | |||
231 | mov pc, lr | 231 | mov pc, lr |
232 | 232 | ||
233 | /* | 233 | /* |
234 | * flush_kern_dcache_page(void *page) | 234 | * flush_kern_dcache_area(void *addr, size_t size) |
235 | * | 235 | * |
236 | * Ensure no D cache aliasing occurs, either with itself or | 236 | * Ensure no D cache aliasing occurs, either with itself or |
237 | * the I cache | 237 | * the I cache |
238 | * | 238 | * |
239 | * - page - page aligned address | 239 | * - addr - kernel address |
240 | * - size - region size | ||
240 | */ | 241 | */ |
241 | ENTRY(arm1020_flush_kern_dcache_page) | 242 | ENTRY(arm1020_flush_kern_dcache_area) |
242 | mov ip, #0 | 243 | mov ip, #0 |
243 | #ifndef CONFIG_CPU_DCACHE_DISABLE | 244 | #ifndef CONFIG_CPU_DCACHE_DISABLE |
244 | add r1, r0, #PAGE_SZ | 245 | add r1, r0, r1 |
245 | 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry | 246 | 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry |
246 | mcr p15, 0, ip, c7, c10, 4 @ drain WB | 247 | mcr p15, 0, ip, c7, c10, 4 @ drain WB |
247 | add r0, r0, #CACHE_DLINESIZE | 248 | add r0, r0, #CACHE_DLINESIZE |
@@ -335,7 +336,7 @@ ENTRY(arm1020_cache_fns) | |||
335 | .long arm1020_flush_user_cache_range | 336 | .long arm1020_flush_user_cache_range |
336 | .long arm1020_coherent_kern_range | 337 | .long arm1020_coherent_kern_range |
337 | .long arm1020_coherent_user_range | 338 | .long arm1020_coherent_user_range |
338 | .long arm1020_flush_kern_dcache_page | 339 | .long arm1020_flush_kern_dcache_area |
339 | .long arm1020_dma_inv_range | 340 | .long arm1020_dma_inv_range |
340 | .long arm1020_dma_clean_range | 341 | .long arm1020_dma_clean_range |
341 | .long arm1020_dma_flush_range | 342 | .long arm1020_dma_flush_range |
diff --git a/arch/arm/mm/proc-arm1020e.S b/arch/arm/mm/proc-arm1020e.S index 7453b75dcea5..41fe25d234f5 100644 --- a/arch/arm/mm/proc-arm1020e.S +++ b/arch/arm/mm/proc-arm1020e.S | |||
@@ -225,17 +225,18 @@ ENTRY(arm1020e_coherent_user_range) | |||
225 | mov pc, lr | 225 | mov pc, lr |
226 | 226 | ||
227 | /* | 227 | /* |
228 | * flush_kern_dcache_page(void *page) | 228 | * flush_kern_dcache_area(void *addr, size_t size) |
229 | * | 229 | * |
230 | * Ensure no D cache aliasing occurs, either with itself or | 230 | * Ensure no D cache aliasing occurs, either with itself or |
231 | * the I cache | 231 | * the I cache |
232 | * | 232 | * |
233 | * - page - page aligned address | 233 | * - addr - kernel address |
234 | * - size - region size | ||
234 | */ | 235 | */ |
235 | ENTRY(arm1020e_flush_kern_dcache_page) | 236 | ENTRY(arm1020e_flush_kern_dcache_area) |
236 | mov ip, #0 | 237 | mov ip, #0 |
237 | #ifndef CONFIG_CPU_DCACHE_DISABLE | 238 | #ifndef CONFIG_CPU_DCACHE_DISABLE |
238 | add r1, r0, #PAGE_SZ | 239 | add r1, r0, r1 |
239 | 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry | 240 | 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry |
240 | add r0, r0, #CACHE_DLINESIZE | 241 | add r0, r0, #CACHE_DLINESIZE |
241 | cmp r0, r1 | 242 | cmp r0, r1 |
@@ -321,7 +322,7 @@ ENTRY(arm1020e_cache_fns) | |||
321 | .long arm1020e_flush_user_cache_range | 322 | .long arm1020e_flush_user_cache_range |
322 | .long arm1020e_coherent_kern_range | 323 | .long arm1020e_coherent_kern_range |
323 | .long arm1020e_coherent_user_range | 324 | .long arm1020e_coherent_user_range |
324 | .long arm1020e_flush_kern_dcache_page | 325 | .long arm1020e_flush_kern_dcache_area |
325 | .long arm1020e_dma_inv_range | 326 | .long arm1020e_dma_inv_range |
326 | .long arm1020e_dma_clean_range | 327 | .long arm1020e_dma_clean_range |
327 | .long arm1020e_dma_flush_range | 328 | .long arm1020e_dma_flush_range |
diff --git a/arch/arm/mm/proc-arm1022.S b/arch/arm/mm/proc-arm1022.S index 8eb72d75a8b6..20a5b1b31a70 100644 --- a/arch/arm/mm/proc-arm1022.S +++ b/arch/arm/mm/proc-arm1022.S | |||
@@ -214,17 +214,18 @@ ENTRY(arm1022_coherent_user_range) | |||
214 | mov pc, lr | 214 | mov pc, lr |
215 | 215 | ||
216 | /* | 216 | /* |
217 | * flush_kern_dcache_page(void *page) | 217 | * flush_kern_dcache_area(void *addr, size_t size) |
218 | * | 218 | * |
219 | * Ensure no D cache aliasing occurs, either with itself or | 219 | * Ensure no D cache aliasing occurs, either with itself or |
220 | * the I cache | 220 | * the I cache |
221 | * | 221 | * |
222 | * - page - page aligned address | 222 | * - addr - kernel address |
223 | * - size - region size | ||
223 | */ | 224 | */ |
224 | ENTRY(arm1022_flush_kern_dcache_page) | 225 | ENTRY(arm1022_flush_kern_dcache_area) |
225 | mov ip, #0 | 226 | mov ip, #0 |
226 | #ifndef CONFIG_CPU_DCACHE_DISABLE | 227 | #ifndef CONFIG_CPU_DCACHE_DISABLE |
227 | add r1, r0, #PAGE_SZ | 228 | add r1, r0, r1 |
228 | 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry | 229 | 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry |
229 | add r0, r0, #CACHE_DLINESIZE | 230 | add r0, r0, #CACHE_DLINESIZE |
230 | cmp r0, r1 | 231 | cmp r0, r1 |
@@ -310,7 +311,7 @@ ENTRY(arm1022_cache_fns) | |||
310 | .long arm1022_flush_user_cache_range | 311 | .long arm1022_flush_user_cache_range |
311 | .long arm1022_coherent_kern_range | 312 | .long arm1022_coherent_kern_range |
312 | .long arm1022_coherent_user_range | 313 | .long arm1022_coherent_user_range |
313 | .long arm1022_flush_kern_dcache_page | 314 | .long arm1022_flush_kern_dcache_area |
314 | .long arm1022_dma_inv_range | 315 | .long arm1022_dma_inv_range |
315 | .long arm1022_dma_clean_range | 316 | .long arm1022_dma_clean_range |
316 | .long arm1022_dma_flush_range | 317 | .long arm1022_dma_flush_range |
diff --git a/arch/arm/mm/proc-arm1026.S b/arch/arm/mm/proc-arm1026.S index 3b59f0d67139..96aedb10fcc4 100644 --- a/arch/arm/mm/proc-arm1026.S +++ b/arch/arm/mm/proc-arm1026.S | |||
@@ -208,17 +208,18 @@ ENTRY(arm1026_coherent_user_range) | |||
208 | mov pc, lr | 208 | mov pc, lr |
209 | 209 | ||
210 | /* | 210 | /* |
211 | * flush_kern_dcache_page(void *page) | 211 | * flush_kern_dcache_area(void *addr, size_t size) |
212 | * | 212 | * |
213 | * Ensure no D cache aliasing occurs, either with itself or | 213 | * Ensure no D cache aliasing occurs, either with itself or |
214 | * the I cache | 214 | * the I cache |
215 | * | 215 | * |
216 | * - page - page aligned address | 216 | * - addr - kernel address |
217 | * - size - region size | ||
217 | */ | 218 | */ |
218 | ENTRY(arm1026_flush_kern_dcache_page) | 219 | ENTRY(arm1026_flush_kern_dcache_area) |
219 | mov ip, #0 | 220 | mov ip, #0 |
220 | #ifndef CONFIG_CPU_DCACHE_DISABLE | 221 | #ifndef CONFIG_CPU_DCACHE_DISABLE |
221 | add r1, r0, #PAGE_SZ | 222 | add r1, r0, r1 |
222 | 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry | 223 | 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry |
223 | add r0, r0, #CACHE_DLINESIZE | 224 | add r0, r0, #CACHE_DLINESIZE |
224 | cmp r0, r1 | 225 | cmp r0, r1 |
@@ -304,7 +305,7 @@ ENTRY(arm1026_cache_fns) | |||
304 | .long arm1026_flush_user_cache_range | 305 | .long arm1026_flush_user_cache_range |
305 | .long arm1026_coherent_kern_range | 306 | .long arm1026_coherent_kern_range |
306 | .long arm1026_coherent_user_range | 307 | .long arm1026_coherent_user_range |
307 | .long arm1026_flush_kern_dcache_page | 308 | .long arm1026_flush_kern_dcache_area |
308 | .long arm1026_dma_inv_range | 309 | .long arm1026_dma_inv_range |
309 | .long arm1026_dma_clean_range | 310 | .long arm1026_dma_clean_range |
310 | .long arm1026_dma_flush_range | 311 | .long arm1026_dma_flush_range |
diff --git a/arch/arm/mm/proc-arm920.S b/arch/arm/mm/proc-arm920.S index 2b7c197cc58d..471669e2d7cb 100644 --- a/arch/arm/mm/proc-arm920.S +++ b/arch/arm/mm/proc-arm920.S | |||
@@ -207,15 +207,16 @@ ENTRY(arm920_coherent_user_range) | |||
207 | mov pc, lr | 207 | mov pc, lr |
208 | 208 | ||
209 | /* | 209 | /* |
210 | * flush_kern_dcache_page(void *page) | 210 | * flush_kern_dcache_area(void *addr, size_t size) |
211 | * | 211 | * |
212 | * Ensure no D cache aliasing occurs, either with itself or | 212 | * Ensure no D cache aliasing occurs, either with itself or |
213 | * the I cache | 213 | * the I cache |
214 | * | 214 | * |
215 | * - addr - page aligned address | 215 | * - addr - kernel address |
216 | * - size - region size | ||
216 | */ | 217 | */ |
217 | ENTRY(arm920_flush_kern_dcache_page) | 218 | ENTRY(arm920_flush_kern_dcache_area) |
218 | add r1, r0, #PAGE_SZ | 219 | add r1, r0, r1 |
219 | 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry | 220 | 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry |
220 | add r0, r0, #CACHE_DLINESIZE | 221 | add r0, r0, #CACHE_DLINESIZE |
221 | cmp r0, r1 | 222 | cmp r0, r1 |
@@ -293,7 +294,7 @@ ENTRY(arm920_cache_fns) | |||
293 | .long arm920_flush_user_cache_range | 294 | .long arm920_flush_user_cache_range |
294 | .long arm920_coherent_kern_range | 295 | .long arm920_coherent_kern_range |
295 | .long arm920_coherent_user_range | 296 | .long arm920_coherent_user_range |
296 | .long arm920_flush_kern_dcache_page | 297 | .long arm920_flush_kern_dcache_area |
297 | .long arm920_dma_inv_range | 298 | .long arm920_dma_inv_range |
298 | .long arm920_dma_clean_range | 299 | .long arm920_dma_clean_range |
299 | .long arm920_dma_flush_range | 300 | .long arm920_dma_flush_range |
diff --git a/arch/arm/mm/proc-arm922.S b/arch/arm/mm/proc-arm922.S index 06a1aa4e3398..ee111b00fa41 100644 --- a/arch/arm/mm/proc-arm922.S +++ b/arch/arm/mm/proc-arm922.S | |||
@@ -209,15 +209,16 @@ ENTRY(arm922_coherent_user_range) | |||
209 | mov pc, lr | 209 | mov pc, lr |
210 | 210 | ||
211 | /* | 211 | /* |
212 | * flush_kern_dcache_page(void *page) | 212 | * flush_kern_dcache_area(void *addr, size_t size) |
213 | * | 213 | * |
214 | * Ensure no D cache aliasing occurs, either with itself or | 214 | * Ensure no D cache aliasing occurs, either with itself or |
215 | * the I cache | 215 | * the I cache |
216 | * | 216 | * |
217 | * - addr - page aligned address | 217 | * - addr - kernel address |
218 | * - size - region size | ||
218 | */ | 219 | */ |
219 | ENTRY(arm922_flush_kern_dcache_page) | 220 | ENTRY(arm922_flush_kern_dcache_area) |
220 | add r1, r0, #PAGE_SZ | 221 | add r1, r0, r1 |
221 | 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry | 222 | 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry |
222 | add r0, r0, #CACHE_DLINESIZE | 223 | add r0, r0, #CACHE_DLINESIZE |
223 | cmp r0, r1 | 224 | cmp r0, r1 |
@@ -295,7 +296,7 @@ ENTRY(arm922_cache_fns) | |||
295 | .long arm922_flush_user_cache_range | 296 | .long arm922_flush_user_cache_range |
296 | .long arm922_coherent_kern_range | 297 | .long arm922_coherent_kern_range |
297 | .long arm922_coherent_user_range | 298 | .long arm922_coherent_user_range |
298 | .long arm922_flush_kern_dcache_page | 299 | .long arm922_flush_kern_dcache_area |
299 | .long arm922_dma_inv_range | 300 | .long arm922_dma_inv_range |
300 | .long arm922_dma_clean_range | 301 | .long arm922_dma_clean_range |
301 | .long arm922_dma_flush_range | 302 | .long arm922_dma_flush_range |
diff --git a/arch/arm/mm/proc-arm925.S b/arch/arm/mm/proc-arm925.S index cb53435a85ae..8deb5bde58e4 100644 --- a/arch/arm/mm/proc-arm925.S +++ b/arch/arm/mm/proc-arm925.S | |||
@@ -251,15 +251,16 @@ ENTRY(arm925_coherent_user_range) | |||
251 | mov pc, lr | 251 | mov pc, lr |
252 | 252 | ||
253 | /* | 253 | /* |
254 | * flush_kern_dcache_page(void *page) | 254 | * flush_kern_dcache_area(void *addr, size_t size) |
255 | * | 255 | * |
256 | * Ensure no D cache aliasing occurs, either with itself or | 256 | * Ensure no D cache aliasing occurs, either with itself or |
257 | * the I cache | 257 | * the I cache |
258 | * | 258 | * |
259 | * - addr - page aligned address | 259 | * - addr - kernel address |
260 | * - size - region size | ||
260 | */ | 261 | */ |
261 | ENTRY(arm925_flush_kern_dcache_page) | 262 | ENTRY(arm925_flush_kern_dcache_area) |
262 | add r1, r0, #PAGE_SZ | 263 | add r1, r0, r1 |
263 | 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry | 264 | 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry |
264 | add r0, r0, #CACHE_DLINESIZE | 265 | add r0, r0, #CACHE_DLINESIZE |
265 | cmp r0, r1 | 266 | cmp r0, r1 |
@@ -346,7 +347,7 @@ ENTRY(arm925_cache_fns) | |||
346 | .long arm925_flush_user_cache_range | 347 | .long arm925_flush_user_cache_range |
347 | .long arm925_coherent_kern_range | 348 | .long arm925_coherent_kern_range |
348 | .long arm925_coherent_user_range | 349 | .long arm925_coherent_user_range |
349 | .long arm925_flush_kern_dcache_page | 350 | .long arm925_flush_kern_dcache_area |
350 | .long arm925_dma_inv_range | 351 | .long arm925_dma_inv_range |
351 | .long arm925_dma_clean_range | 352 | .long arm925_dma_clean_range |
352 | .long arm925_dma_flush_range | 353 | .long arm925_dma_flush_range |
diff --git a/arch/arm/mm/proc-arm926.S b/arch/arm/mm/proc-arm926.S index 1c4848704bb3..64db6e275a44 100644 --- a/arch/arm/mm/proc-arm926.S +++ b/arch/arm/mm/proc-arm926.S | |||
@@ -214,15 +214,16 @@ ENTRY(arm926_coherent_user_range) | |||
214 | mov pc, lr | 214 | mov pc, lr |
215 | 215 | ||
216 | /* | 216 | /* |
217 | * flush_kern_dcache_page(void *page) | 217 | * flush_kern_dcache_area(void *addr, size_t size) |
218 | * | 218 | * |
219 | * Ensure no D cache aliasing occurs, either with itself or | 219 | * Ensure no D cache aliasing occurs, either with itself or |
220 | * the I cache | 220 | * the I cache |
221 | * | 221 | * |
222 | * - addr - page aligned address | 222 | * - addr - kernel address |
223 | * - size - region size | ||
223 | */ | 224 | */ |
224 | ENTRY(arm926_flush_kern_dcache_page) | 225 | ENTRY(arm926_flush_kern_dcache_area) |
225 | add r1, r0, #PAGE_SZ | 226 | add r1, r0, r1 |
226 | 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry | 227 | 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry |
227 | add r0, r0, #CACHE_DLINESIZE | 228 | add r0, r0, #CACHE_DLINESIZE |
228 | cmp r0, r1 | 229 | cmp r0, r1 |
@@ -309,7 +310,7 @@ ENTRY(arm926_cache_fns) | |||
309 | .long arm926_flush_user_cache_range | 310 | .long arm926_flush_user_cache_range |
310 | .long arm926_coherent_kern_range | 311 | .long arm926_coherent_kern_range |
311 | .long arm926_coherent_user_range | 312 | .long arm926_coherent_user_range |
312 | .long arm926_flush_kern_dcache_page | 313 | .long arm926_flush_kern_dcache_area |
313 | .long arm926_dma_inv_range | 314 | .long arm926_dma_inv_range |
314 | .long arm926_dma_clean_range | 315 | .long arm926_dma_clean_range |
315 | .long arm926_dma_flush_range | 316 | .long arm926_dma_flush_range |
diff --git a/arch/arm/mm/proc-arm940.S b/arch/arm/mm/proc-arm940.S index 5b0f8464c8f2..8196b9f401fb 100644 --- a/arch/arm/mm/proc-arm940.S +++ b/arch/arm/mm/proc-arm940.S | |||
@@ -141,14 +141,15 @@ ENTRY(arm940_coherent_user_range) | |||
141 | /* FALLTHROUGH */ | 141 | /* FALLTHROUGH */ |
142 | 142 | ||
143 | /* | 143 | /* |
144 | * flush_kern_dcache_page(void *page) | 144 | * flush_kern_dcache_area(void *addr, size_t size) |
145 | * | 145 | * |
146 | * Ensure no D cache aliasing occurs, either with itself or | 146 | * Ensure no D cache aliasing occurs, either with itself or |
147 | * the I cache | 147 | * the I cache |
148 | * | 148 | * |
149 | * - addr - page aligned address | 149 | * - addr - kernel address |
150 | * - size - region size | ||
150 | */ | 151 | */ |
151 | ENTRY(arm940_flush_kern_dcache_page) | 152 | ENTRY(arm940_flush_kern_dcache_area) |
152 | mov ip, #0 | 153 | mov ip, #0 |
153 | mov r1, #(CACHE_DSEGMENTS - 1) << 4 @ 4 segments | 154 | mov r1, #(CACHE_DSEGMENTS - 1) << 4 @ 4 segments |
154 | 1: orr r3, r1, #(CACHE_DENTRIES - 1) << 26 @ 64 entries | 155 | 1: orr r3, r1, #(CACHE_DENTRIES - 1) << 26 @ 64 entries |
@@ -238,7 +239,7 @@ ENTRY(arm940_cache_fns) | |||
238 | .long arm940_flush_user_cache_range | 239 | .long arm940_flush_user_cache_range |
239 | .long arm940_coherent_kern_range | 240 | .long arm940_coherent_kern_range |
240 | .long arm940_coherent_user_range | 241 | .long arm940_coherent_user_range |
241 | .long arm940_flush_kern_dcache_page | 242 | .long arm940_flush_kern_dcache_area |
242 | .long arm940_dma_inv_range | 243 | .long arm940_dma_inv_range |
243 | .long arm940_dma_clean_range | 244 | .long arm940_dma_clean_range |
244 | .long arm940_dma_flush_range | 245 | .long arm940_dma_flush_range |
diff --git a/arch/arm/mm/proc-arm946.S b/arch/arm/mm/proc-arm946.S index 40c0449a139b..9a951239c86c 100644 --- a/arch/arm/mm/proc-arm946.S +++ b/arch/arm/mm/proc-arm946.S | |||
@@ -183,16 +183,17 @@ ENTRY(arm946_coherent_user_range) | |||
183 | mov pc, lr | 183 | mov pc, lr |
184 | 184 | ||
185 | /* | 185 | /* |
186 | * flush_kern_dcache_page(void *page) | 186 | * flush_kern_dcache_area(void *addr, size_t size) |
187 | * | 187 | * |
188 | * Ensure no D cache aliasing occurs, either with itself or | 188 | * Ensure no D cache aliasing occurs, either with itself or |
189 | * the I cache | 189 | * the I cache |
190 | * | 190 | * |
191 | * - addr - page aligned address | 191 | * - addr - kernel address |
192 | * - size - region size | ||
192 | * (same as arm926) | 193 | * (same as arm926) |
193 | */ | 194 | */ |
194 | ENTRY(arm946_flush_kern_dcache_page) | 195 | ENTRY(arm946_flush_kern_dcache_area) |
195 | add r1, r0, #PAGE_SZ | 196 | add r1, r0, r1 |
196 | 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry | 197 | 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry |
197 | add r0, r0, #CACHE_DLINESIZE | 198 | add r0, r0, #CACHE_DLINESIZE |
198 | cmp r0, r1 | 199 | cmp r0, r1 |
@@ -280,7 +281,7 @@ ENTRY(arm946_cache_fns) | |||
280 | .long arm946_flush_user_cache_range | 281 | .long arm946_flush_user_cache_range |
281 | .long arm946_coherent_kern_range | 282 | .long arm946_coherent_kern_range |
282 | .long arm946_coherent_user_range | 283 | .long arm946_coherent_user_range |
283 | .long arm946_flush_kern_dcache_page | 284 | .long arm946_flush_kern_dcache_area |
284 | .long arm946_dma_inv_range | 285 | .long arm946_dma_inv_range |
285 | .long arm946_dma_clean_range | 286 | .long arm946_dma_clean_range |
286 | .long arm946_dma_flush_range | 287 | .long arm946_dma_flush_range |
diff --git a/arch/arm/mm/proc-feroceon.S b/arch/arm/mm/proc-feroceon.S index d0d7795200fc..dbc39383e66a 100644 --- a/arch/arm/mm/proc-feroceon.S +++ b/arch/arm/mm/proc-feroceon.S | |||
@@ -226,16 +226,17 @@ ENTRY(feroceon_coherent_user_range) | |||
226 | mov pc, lr | 226 | mov pc, lr |
227 | 227 | ||
228 | /* | 228 | /* |
229 | * flush_kern_dcache_page(void *page) | 229 | * flush_kern_dcache_area(void *addr, size_t size) |
230 | * | 230 | * |
231 | * Ensure no D cache aliasing occurs, either with itself or | 231 | * Ensure no D cache aliasing occurs, either with itself or |
232 | * the I cache | 232 | * the I cache |
233 | * | 233 | * |
234 | * - addr - page aligned address | 234 | * - addr - kernel address |
235 | * - size - region size | ||
235 | */ | 236 | */ |
236 | .align 5 | 237 | .align 5 |
237 | ENTRY(feroceon_flush_kern_dcache_page) | 238 | ENTRY(feroceon_flush_kern_dcache_area) |
238 | add r1, r0, #PAGE_SZ | 239 | add r1, r0, r1 |
239 | 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry | 240 | 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry |
240 | add r0, r0, #CACHE_DLINESIZE | 241 | add r0, r0, #CACHE_DLINESIZE |
241 | cmp r0, r1 | 242 | cmp r0, r1 |
@@ -246,7 +247,7 @@ ENTRY(feroceon_flush_kern_dcache_page) | |||
246 | mov pc, lr | 247 | mov pc, lr |
247 | 248 | ||
248 | .align 5 | 249 | .align 5 |
249 | ENTRY(feroceon_range_flush_kern_dcache_page) | 250 | ENTRY(feroceon_range_flush_kern_dcache_area) |
250 | mrs r2, cpsr | 251 | mrs r2, cpsr |
251 | add r1, r0, #PAGE_SZ - CACHE_DLINESIZE @ top addr is inclusive | 252 | add r1, r0, #PAGE_SZ - CACHE_DLINESIZE @ top addr is inclusive |
252 | orr r3, r2, #PSR_I_BIT | 253 | orr r3, r2, #PSR_I_BIT |
@@ -372,7 +373,7 @@ ENTRY(feroceon_cache_fns) | |||
372 | .long feroceon_flush_user_cache_range | 373 | .long feroceon_flush_user_cache_range |
373 | .long feroceon_coherent_kern_range | 374 | .long feroceon_coherent_kern_range |
374 | .long feroceon_coherent_user_range | 375 | .long feroceon_coherent_user_range |
375 | .long feroceon_flush_kern_dcache_page | 376 | .long feroceon_flush_kern_dcache_area |
376 | .long feroceon_dma_inv_range | 377 | .long feroceon_dma_inv_range |
377 | .long feroceon_dma_clean_range | 378 | .long feroceon_dma_clean_range |
378 | .long feroceon_dma_flush_range | 379 | .long feroceon_dma_flush_range |
@@ -383,7 +384,7 @@ ENTRY(feroceon_range_cache_fns) | |||
383 | .long feroceon_flush_user_cache_range | 384 | .long feroceon_flush_user_cache_range |
384 | .long feroceon_coherent_kern_range | 385 | .long feroceon_coherent_kern_range |
385 | .long feroceon_coherent_user_range | 386 | .long feroceon_coherent_user_range |
386 | .long feroceon_range_flush_kern_dcache_page | 387 | .long feroceon_range_flush_kern_dcache_area |
387 | .long feroceon_range_dma_inv_range | 388 | .long feroceon_range_dma_inv_range |
388 | .long feroceon_range_dma_clean_range | 389 | .long feroceon_range_dma_clean_range |
389 | .long feroceon_range_dma_flush_range | 390 | .long feroceon_range_dma_flush_range |
diff --git a/arch/arm/mm/proc-mohawk.S b/arch/arm/mm/proc-mohawk.S index 52b5fd74fbb3..9674d36cc97d 100644 --- a/arch/arm/mm/proc-mohawk.S +++ b/arch/arm/mm/proc-mohawk.S | |||
@@ -186,15 +186,16 @@ ENTRY(mohawk_coherent_user_range) | |||
186 | mov pc, lr | 186 | mov pc, lr |
187 | 187 | ||
188 | /* | 188 | /* |
189 | * flush_kern_dcache_page(void *page) | 189 | * flush_kern_dcache_area(void *addr, size_t size) |
190 | * | 190 | * |
191 | * Ensure no D cache aliasing occurs, either with itself or | 191 | * Ensure no D cache aliasing occurs, either with itself or |
192 | * the I cache | 192 | * the I cache |
193 | * | 193 | * |
194 | * - addr - page aligned address | 194 | * - addr - kernel address |
195 | * - size - region size | ||
195 | */ | 196 | */ |
196 | ENTRY(mohawk_flush_kern_dcache_page) | 197 | ENTRY(mohawk_flush_kern_dcache_area) |
197 | add r1, r0, #PAGE_SZ | 198 | add r1, r0, r1 |
198 | 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry | 199 | 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry |
199 | add r0, r0, #CACHE_DLINESIZE | 200 | add r0, r0, #CACHE_DLINESIZE |
200 | cmp r0, r1 | 201 | cmp r0, r1 |
@@ -273,7 +274,7 @@ ENTRY(mohawk_cache_fns) | |||
273 | .long mohawk_flush_user_cache_range | 274 | .long mohawk_flush_user_cache_range |
274 | .long mohawk_coherent_kern_range | 275 | .long mohawk_coherent_kern_range |
275 | .long mohawk_coherent_user_range | 276 | .long mohawk_coherent_user_range |
276 | .long mohawk_flush_kern_dcache_page | 277 | .long mohawk_flush_kern_dcache_area |
277 | .long mohawk_dma_inv_range | 278 | .long mohawk_dma_inv_range |
278 | .long mohawk_dma_clean_range | 279 | .long mohawk_dma_clean_range |
279 | .long mohawk_dma_flush_range | 280 | .long mohawk_dma_flush_range |
diff --git a/arch/arm/mm/proc-syms.c b/arch/arm/mm/proc-syms.c index ac5c80062b70..3e6210b4d6d4 100644 --- a/arch/arm/mm/proc-syms.c +++ b/arch/arm/mm/proc-syms.c | |||
@@ -27,8 +27,7 @@ EXPORT_SYMBOL(__cpuc_flush_kern_all); | |||
27 | EXPORT_SYMBOL(__cpuc_flush_user_all); | 27 | EXPORT_SYMBOL(__cpuc_flush_user_all); |
28 | EXPORT_SYMBOL(__cpuc_flush_user_range); | 28 | EXPORT_SYMBOL(__cpuc_flush_user_range); |
29 | EXPORT_SYMBOL(__cpuc_coherent_kern_range); | 29 | EXPORT_SYMBOL(__cpuc_coherent_kern_range); |
30 | EXPORT_SYMBOL(__cpuc_flush_dcache_page); | 30 | EXPORT_SYMBOL(__cpuc_flush_dcache_area); |
31 | EXPORT_SYMBOL(dmac_inv_range); /* because of flush_ioremap_region() */ | ||
32 | #else | 31 | #else |
33 | EXPORT_SYMBOL(cpu_cache); | 32 | EXPORT_SYMBOL(cpu_cache); |
34 | #endif | 33 | #endif |
diff --git a/arch/arm/mm/proc-v6.S b/arch/arm/mm/proc-v6.S index 5485c821101c..395cc90c6613 100644 --- a/arch/arm/mm/proc-v6.S +++ b/arch/arm/mm/proc-v6.S | |||
@@ -254,10 +254,9 @@ __pj4_v6_proc_info: | |||
254 | .long 0x560f5810 | 254 | .long 0x560f5810 |
255 | .long 0xff0ffff0 | 255 | .long 0xff0ffff0 |
256 | .long PMD_TYPE_SECT | \ | 256 | .long PMD_TYPE_SECT | \ |
257 | PMD_SECT_BUFFERABLE | \ | ||
258 | PMD_SECT_CACHEABLE | \ | ||
259 | PMD_SECT_AP_WRITE | \ | 257 | PMD_SECT_AP_WRITE | \ |
260 | PMD_SECT_AP_READ | 258 | PMD_SECT_AP_READ | \ |
259 | PMD_FLAGS | ||
261 | .long PMD_TYPE_SECT | \ | 260 | .long PMD_TYPE_SECT | \ |
262 | PMD_SECT_XN | \ | 261 | PMD_SECT_XN | \ |
263 | PMD_SECT_AP_WRITE | \ | 262 | PMD_SECT_AP_WRITE | \ |
diff --git a/arch/arm/mm/proc-xsc3.S b/arch/arm/mm/proc-xsc3.S index fab134e29826..96456f548798 100644 --- a/arch/arm/mm/proc-xsc3.S +++ b/arch/arm/mm/proc-xsc3.S | |||
@@ -226,15 +226,16 @@ ENTRY(xsc3_coherent_user_range) | |||
226 | mov pc, lr | 226 | mov pc, lr |
227 | 227 | ||
228 | /* | 228 | /* |
229 | * flush_kern_dcache_page(void *page) | 229 | * flush_kern_dcache_area(void *addr, size_t size) |
230 | * | 230 | * |
231 | * Ensure no D cache aliasing occurs, either with itself or | 231 | * Ensure no D cache aliasing occurs, either with itself or |
232 | * the I cache. | 232 | * the I cache. |
233 | * | 233 | * |
234 | * - addr - page aligned address | 234 | * - addr - kernel address |
235 | * - size - region size | ||
235 | */ | 236 | */ |
236 | ENTRY(xsc3_flush_kern_dcache_page) | 237 | ENTRY(xsc3_flush_kern_dcache_area) |
237 | add r1, r0, #PAGE_SZ | 238 | add r1, r0, r1 |
238 | 1: mcr p15, 0, r0, c7, c14, 1 @ clean/invalidate L1 D line | 239 | 1: mcr p15, 0, r0, c7, c14, 1 @ clean/invalidate L1 D line |
239 | add r0, r0, #CACHELINESIZE | 240 | add r0, r0, #CACHELINESIZE |
240 | cmp r0, r1 | 241 | cmp r0, r1 |
@@ -309,7 +310,7 @@ ENTRY(xsc3_cache_fns) | |||
309 | .long xsc3_flush_user_cache_range | 310 | .long xsc3_flush_user_cache_range |
310 | .long xsc3_coherent_kern_range | 311 | .long xsc3_coherent_kern_range |
311 | .long xsc3_coherent_user_range | 312 | .long xsc3_coherent_user_range |
312 | .long xsc3_flush_kern_dcache_page | 313 | .long xsc3_flush_kern_dcache_area |
313 | .long xsc3_dma_inv_range | 314 | .long xsc3_dma_inv_range |
314 | .long xsc3_dma_clean_range | 315 | .long xsc3_dma_clean_range |
315 | .long xsc3_dma_flush_range | 316 | .long xsc3_dma_flush_range |
diff --git a/arch/arm/mm/proc-xscale.S b/arch/arm/mm/proc-xscale.S index f056c283682d..93df47265f2d 100644 --- a/arch/arm/mm/proc-xscale.S +++ b/arch/arm/mm/proc-xscale.S | |||
@@ -284,15 +284,16 @@ ENTRY(xscale_coherent_user_range) | |||
284 | mov pc, lr | 284 | mov pc, lr |
285 | 285 | ||
286 | /* | 286 | /* |
287 | * flush_kern_dcache_page(void *page) | 287 | * flush_kern_dcache_area(void *addr, size_t size) |
288 | * | 288 | * |
289 | * Ensure no D cache aliasing occurs, either with itself or | 289 | * Ensure no D cache aliasing occurs, either with itself or |
290 | * the I cache | 290 | * the I cache |
291 | * | 291 | * |
292 | * - addr - page aligned address | 292 | * - addr - kernel address |
293 | * - size - region size | ||
293 | */ | 294 | */ |
294 | ENTRY(xscale_flush_kern_dcache_page) | 295 | ENTRY(xscale_flush_kern_dcache_area) |
295 | add r1, r0, #PAGE_SZ | 296 | add r1, r0, r1 |
296 | 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry | 297 | 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry |
297 | mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry | 298 | mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry |
298 | add r0, r0, #CACHELINESIZE | 299 | add r0, r0, #CACHELINESIZE |
@@ -368,7 +369,7 @@ ENTRY(xscale_cache_fns) | |||
368 | .long xscale_flush_user_cache_range | 369 | .long xscale_flush_user_cache_range |
369 | .long xscale_coherent_kern_range | 370 | .long xscale_coherent_kern_range |
370 | .long xscale_coherent_user_range | 371 | .long xscale_coherent_user_range |
371 | .long xscale_flush_kern_dcache_page | 372 | .long xscale_flush_kern_dcache_area |
372 | .long xscale_dma_inv_range | 373 | .long xscale_dma_inv_range |
373 | .long xscale_dma_clean_range | 374 | .long xscale_dma_clean_range |
374 | .long xscale_dma_flush_range | 375 | .long xscale_dma_flush_range |
@@ -392,7 +393,7 @@ ENTRY(xscale_80200_A0_A1_cache_fns) | |||
392 | .long xscale_flush_user_cache_range | 393 | .long xscale_flush_user_cache_range |
393 | .long xscale_coherent_kern_range | 394 | .long xscale_coherent_kern_range |
394 | .long xscale_coherent_user_range | 395 | .long xscale_coherent_user_range |
395 | .long xscale_flush_kern_dcache_page | 396 | .long xscale_flush_kern_dcache_area |
396 | .long xscale_dma_flush_range | 397 | .long xscale_dma_flush_range |
397 | .long xscale_dma_clean_range | 398 | .long xscale_dma_clean_range |
398 | .long xscale_dma_flush_range | 399 | .long xscale_dma_flush_range |
diff --git a/arch/arm/tools/mach-types b/arch/arm/tools/mach-types index 07b976da6174..c3a74ce24ef6 100644 --- a/arch/arm/tools/mach-types +++ b/arch/arm/tools/mach-types | |||
@@ -12,7 +12,7 @@ | |||
12 | # | 12 | # |
13 | # http://www.arm.linux.org.uk/developer/machines/?action=new | 13 | # http://www.arm.linux.org.uk/developer/machines/?action=new |
14 | # | 14 | # |
15 | # Last update: Wed Nov 25 22:14:58 2009 | 15 | # Last update: Wed Dec 16 20:06:34 2009 |
16 | # | 16 | # |
17 | # machine_is_xxx CONFIG_xxxx MACH_TYPE_xxx number | 17 | # machine_is_xxx CONFIG_xxxx MACH_TYPE_xxx number |
18 | # | 18 | # |
@@ -1776,6 +1776,7 @@ cybook3 MACH_CYBOOK3 CYBOOK3 1784 | |||
1776 | wdg002 MACH_WDG002 WDG002 1785 | 1776 | wdg002 MACH_WDG002 WDG002 1785 |
1777 | sg560adsl MACH_SG560ADSL SG560ADSL 1786 | 1777 | sg560adsl MACH_SG560ADSL SG560ADSL 1786 |
1778 | nextio_n2800_ica MACH_NEXTIO_N2800_ICA NEXTIO_N2800_ICA 1787 | 1778 | nextio_n2800_ica MACH_NEXTIO_N2800_ICA NEXTIO_N2800_ICA 1787 |
1779 | dove_db MACH_DOVE_DB DOVE_DB 1788 | ||
1779 | marvell_newdb MACH_MARVELL_NEWDB MARVELL_NEWDB 1789 | 1780 | marvell_newdb MACH_MARVELL_NEWDB MARVELL_NEWDB 1789 |
1780 | vandihud MACH_VANDIHUD VANDIHUD 1790 | 1781 | vandihud MACH_VANDIHUD VANDIHUD 1790 |
1781 | magx_e8 MACH_MAGX_E8 MAGX_E8 1791 | 1782 | magx_e8 MACH_MAGX_E8 MAGX_E8 1791 |
@@ -2536,3 +2537,44 @@ c3ax03 MACH_C3AX03 C3AX03 2549 | |||
2536 | mxt_td60 MACH_MXT_TD60 MXT_TD60 2550 | 2537 | mxt_td60 MACH_MXT_TD60 MXT_TD60 2550 |
2537 | esyx MACH_ESYX ESYX 2551 | 2538 | esyx MACH_ESYX ESYX 2551 |
2538 | bulldog MACH_BULLDOG BULLDOG 2553 | 2539 | bulldog MACH_BULLDOG BULLDOG 2553 |
2540 | derell_me2000 MACH_DERELL_ME2000 DERELL_ME2000 2554 | ||
2541 | bcmring_base MACH_BCMRING_BASE BCMRING_BASE 2555 | ||
2542 | bcmring_evm MACH_BCMRING_EVM BCMRING_EVM 2556 | ||
2543 | bcmring_evm_jazz MACH_BCMRING_EVM_JAZZ BCMRING_EVM_JAZZ 2557 | ||
2544 | bcmring_sp MACH_BCMRING_SP BCMRING_SP 2558 | ||
2545 | bcmring_sv MACH_BCMRING_SV BCMRING_SV 2559 | ||
2546 | bcmring_sv_jazz MACH_BCMRING_SV_JAZZ BCMRING_SV_JAZZ 2560 | ||
2547 | bcmring_tablet MACH_BCMRING_TABLET BCMRING_TABLET 2561 | ||
2548 | bcmring_vp MACH_BCMRING_VP BCMRING_VP 2562 | ||
2549 | bcmring_evm_seikor MACH_BCMRING_EVM_SEIKOR BCMRING_EVM_SEIKOR 2563 | ||
2550 | bcmring_sp_wqvga MACH_BCMRING_SP_WQVGA BCMRING_SP_WQVGA 2564 | ||
2551 | bcmring_custom MACH_BCMRING_CUSTOM BCMRING_CUSTOM 2565 | ||
2552 | acer_s200 MACH_ACER_S200 ACER_S200 2566 | ||
2553 | bt270 MACH_BT270 BT270 2567 | ||
2554 | iseo MACH_ISEO ISEO 2568 | ||
2555 | cezanne MACH_CEZANNE CEZANNE 2569 | ||
2556 | lucca MACH_LUCCA LUCCA 2570 | ||
2557 | supersmart MACH_SUPERSMART SUPERSMART 2571 | ||
2558 | magnolia2 MACH_MAGNOLIA2 MAGNOLIA2 2573 | ||
2559 | emxx MACH_EMXX EMXX 2574 | ||
2560 | outlaw MACH_OUTLAW OUTLAW 2575 | ||
2561 | riot_bei2 MACH_RIOT_BEI2 RIOT_BEI2 2576 | ||
2562 | riot_vox MACH_RIOT_VOX RIOT_VOX 2577 | ||
2563 | riot_x37 MACH_RIOT_X37 RIOT_X37 2578 | ||
2564 | mega25mx MACH_MEGA25MX MEGA25MX 2579 | ||
2565 | benzina2 MACH_BENZINA2 BENZINA2 2580 | ||
2566 | ignite MACH_IGNITE IGNITE 2581 | ||
2567 | foggia MACH_FOGGIA FOGGIA 2582 | ||
2568 | arezzo MACH_AREZZO AREZZO 2583 | ||
2569 | leica_skywalker MACH_LEICA_SKYWALKER LEICA_SKYWALKER 2584 | ||
2570 | jacinto2_jamr MACH_JACINTO2_JAMR JACINTO2_JAMR 2585 | ||
2571 | gts_nova MACH_GTS_NOVA GTS_NOVA 2586 | ||
2572 | p3600 MACH_P3600 P3600 2587 | ||
2573 | dlt2 MACH_DLT2 DLT2 2588 | ||
2574 | df3120 MACH_DF3120 DF3120 2589 | ||
2575 | ecucore_9g20 MACH_ECUCORE_9G20 ECUCORE_9G20 2590 | ||
2576 | nautel_lpc3240 MACH_NAUTEL_LPC3240 NAUTEL_LPC3240 2591 | ||
2577 | glacier MACH_GLACIER GLACIER 2592 | ||
2578 | phrazer_bulldog MACH_PHRAZER_BULLDOG PHRAZER_BULLDOG 2593 | ||
2579 | omap3_bulldog MACH_OMAP3_BULLDOG OMAP3_BULLDOG 2594 | ||
2580 | pca101 MACH_PCA101 PCA101 2595 | ||
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 95ccbe377f9c..bf28945c610d 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig | |||
@@ -998,6 +998,23 @@ config SENSORS_LIS3_SPI | |||
998 | will be called lis3lv02d and a specific module for the SPI transport | 998 | will be called lis3lv02d and a specific module for the SPI transport |
999 | is called lis3lv02d_spi. | 999 | is called lis3lv02d_spi. |
1000 | 1000 | ||
1001 | config SENSORS_LIS3_I2C | ||
1002 | tristate "STMicroeletronics LIS3LV02Dx three-axis digital accelerometer (I2C)" | ||
1003 | depends on I2C && INPUT | ||
1004 | select INPUT_POLLDEV | ||
1005 | default n | ||
1006 | help | ||
1007 | This driver provides support for the LIS3LV02Dx accelerometer connected | ||
1008 | via I2C. The accelerometer data is readable via | ||
1009 | /sys/devices/platform/lis3lv02d. | ||
1010 | |||
1011 | This driver also provides an absolute input class device, allowing | ||
1012 | the device to act as a pinball machine-esque joystick. | ||
1013 | |||
1014 | This driver can also be built as modules. If so, the core module | ||
1015 | will be called lis3lv02d and a specific module for the I2C transport | ||
1016 | is called lis3lv02d_i2c. | ||
1017 | |||
1001 | config SENSORS_APPLESMC | 1018 | config SENSORS_APPLESMC |
1002 | tristate "Apple SMC (Motion sensor, light sensor, keyboard backlight)" | 1019 | tristate "Apple SMC (Motion sensor, light sensor, keyboard backlight)" |
1003 | depends on INPUT && X86 | 1020 | depends on INPUT && X86 |
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index 33c2ee105284..4131e253f96a 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile | |||
@@ -55,6 +55,7 @@ obj-$(CONFIG_SENSORS_IT87) += it87.o | |||
55 | obj-$(CONFIG_SENSORS_K8TEMP) += k8temp.o | 55 | obj-$(CONFIG_SENSORS_K8TEMP) += k8temp.o |
56 | obj-$(CONFIG_SENSORS_LIS3LV02D) += lis3lv02d.o hp_accel.o | 56 | obj-$(CONFIG_SENSORS_LIS3LV02D) += lis3lv02d.o hp_accel.o |
57 | obj-$(CONFIG_SENSORS_LIS3_SPI) += lis3lv02d.o lis3lv02d_spi.o | 57 | obj-$(CONFIG_SENSORS_LIS3_SPI) += lis3lv02d.o lis3lv02d_spi.o |
58 | obj-$(CONFIG_SENSORS_LIS3_I2C) += lis3lv02d.o lis3lv02d_i2c.o | ||
58 | obj-$(CONFIG_SENSORS_LM63) += lm63.o | 59 | obj-$(CONFIG_SENSORS_LM63) += lm63.o |
59 | obj-$(CONFIG_SENSORS_LM70) += lm70.o | 60 | obj-$(CONFIG_SENSORS_LM70) += lm70.o |
60 | obj-$(CONFIG_SENSORS_LM73) += lm73.o | 61 | obj-$(CONFIG_SENSORS_LM73) += lm73.o |
diff --git a/drivers/hwmon/lis3lv02d_i2c.c b/drivers/hwmon/lis3lv02d_i2c.c new file mode 100644 index 000000000000..dc1f5402c1d7 --- /dev/null +++ b/drivers/hwmon/lis3lv02d_i2c.c | |||
@@ -0,0 +1,183 @@ | |||
1 | /* | ||
2 | * drivers/hwmon/lis3lv02d_i2c.c | ||
3 | * | ||
4 | * Implements I2C interface for lis3lv02d (STMicroelectronics) accelerometer. | ||
5 | * Driver is based on corresponding SPI driver written by Daniel Mack | ||
6 | * (lis3lv02d_spi.c (C) 2009 Daniel Mack <daniel@caiaq.de> ). | ||
7 | * | ||
8 | * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). | ||
9 | * | ||
10 | * Contact: Samu Onkalo <samu.p.onkalo@nokia.com> | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * version 2 as published by the Free Software Foundation. | ||
15 | * | ||
16 | * This program is distributed in the hope that it will be useful, but | ||
17 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
19 | * General Public License for more details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU General Public License | ||
22 | * along with this program; if not, write to the Free Software | ||
23 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
24 | * 02110-1301 USA | ||
25 | */ | ||
26 | |||
27 | #include <linux/module.h> | ||
28 | #include <linux/kernel.h> | ||
29 | #include <linux/init.h> | ||
30 | #include <linux/err.h> | ||
31 | #include <linux/i2c.h> | ||
32 | #include "lis3lv02d.h" | ||
33 | |||
34 | #define DRV_NAME "lis3lv02d_i2c" | ||
35 | |||
36 | static inline s32 lis3_i2c_write(struct lis3lv02d *lis3, int reg, u8 value) | ||
37 | { | ||
38 | struct i2c_client *c = lis3->bus_priv; | ||
39 | return i2c_smbus_write_byte_data(c, reg, value); | ||
40 | } | ||
41 | |||
42 | static inline s32 lis3_i2c_read(struct lis3lv02d *lis3, int reg, u8 *v) | ||
43 | { | ||
44 | struct i2c_client *c = lis3->bus_priv; | ||
45 | *v = i2c_smbus_read_byte_data(c, reg); | ||
46 | return 0; | ||
47 | } | ||
48 | |||
49 | static int lis3_i2c_init(struct lis3lv02d *lis3) | ||
50 | { | ||
51 | u8 reg; | ||
52 | int ret; | ||
53 | |||
54 | /* power up the device */ | ||
55 | ret = lis3->read(lis3, CTRL_REG1, ®); | ||
56 | if (ret < 0) | ||
57 | return ret; | ||
58 | |||
59 | reg |= CTRL1_PD0; | ||
60 | return lis3->write(lis3, CTRL_REG1, reg); | ||
61 | } | ||
62 | |||
63 | /* Default axis mapping but it can be overwritten by platform data */ | ||
64 | static struct axis_conversion lis3lv02d_axis_map = { LIS3_DEV_X, | ||
65 | LIS3_DEV_Y, | ||
66 | LIS3_DEV_Z }; | ||
67 | |||
68 | static int __devinit lis3lv02d_i2c_probe(struct i2c_client *client, | ||
69 | const struct i2c_device_id *id) | ||
70 | { | ||
71 | int ret = 0; | ||
72 | struct lis3lv02d_platform_data *pdata = client->dev.platform_data; | ||
73 | |||
74 | if (pdata) { | ||
75 | if (pdata->axis_x) | ||
76 | lis3lv02d_axis_map.x = pdata->axis_x; | ||
77 | |||
78 | if (pdata->axis_y) | ||
79 | lis3lv02d_axis_map.y = pdata->axis_y; | ||
80 | |||
81 | if (pdata->axis_z) | ||
82 | lis3lv02d_axis_map.z = pdata->axis_z; | ||
83 | |||
84 | if (pdata->setup_resources) | ||
85 | ret = pdata->setup_resources(); | ||
86 | |||
87 | if (ret) | ||
88 | goto fail; | ||
89 | } | ||
90 | |||
91 | lis3_dev.pdata = pdata; | ||
92 | lis3_dev.bus_priv = client; | ||
93 | lis3_dev.init = lis3_i2c_init; | ||
94 | lis3_dev.read = lis3_i2c_read; | ||
95 | lis3_dev.write = lis3_i2c_write; | ||
96 | lis3_dev.irq = client->irq; | ||
97 | lis3_dev.ac = lis3lv02d_axis_map; | ||
98 | |||
99 | i2c_set_clientdata(client, &lis3_dev); | ||
100 | ret = lis3lv02d_init_device(&lis3_dev); | ||
101 | fail: | ||
102 | return ret; | ||
103 | } | ||
104 | |||
105 | static int __devexit lis3lv02d_i2c_remove(struct i2c_client *client) | ||
106 | { | ||
107 | struct lis3lv02d *lis3 = i2c_get_clientdata(client); | ||
108 | struct lis3lv02d_platform_data *pdata = client->dev.platform_data; | ||
109 | |||
110 | if (pdata && pdata->release_resources) | ||
111 | pdata->release_resources(); | ||
112 | |||
113 | lis3lv02d_joystick_disable(); | ||
114 | lis3lv02d_poweroff(lis3); | ||
115 | |||
116 | return lis3lv02d_remove_fs(&lis3_dev); | ||
117 | } | ||
118 | |||
119 | #ifdef CONFIG_PM | ||
120 | static int lis3lv02d_i2c_suspend(struct i2c_client *client, pm_message_t mesg) | ||
121 | { | ||
122 | struct lis3lv02d *lis3 = i2c_get_clientdata(client); | ||
123 | |||
124 | if (!lis3->pdata->wakeup_flags) | ||
125 | lis3lv02d_poweroff(lis3); | ||
126 | return 0; | ||
127 | } | ||
128 | |||
129 | static int lis3lv02d_i2c_resume(struct i2c_client *client) | ||
130 | { | ||
131 | struct lis3lv02d *lis3 = i2c_get_clientdata(client); | ||
132 | |||
133 | if (!lis3->pdata->wakeup_flags) | ||
134 | lis3lv02d_poweron(lis3); | ||
135 | return 0; | ||
136 | } | ||
137 | |||
138 | static void lis3lv02d_i2c_shutdown(struct i2c_client *client) | ||
139 | { | ||
140 | lis3lv02d_i2c_suspend(client, PMSG_SUSPEND); | ||
141 | } | ||
142 | #else | ||
143 | #define lis3lv02d_i2c_suspend NULL | ||
144 | #define lis3lv02d_i2c_resume NULL | ||
145 | #define lis3lv02d_i2c_shutdown NULL | ||
146 | #endif | ||
147 | |||
148 | static const struct i2c_device_id lis3lv02d_id[] = { | ||
149 | {"lis3lv02d", 0 }, | ||
150 | {} | ||
151 | }; | ||
152 | |||
153 | MODULE_DEVICE_TABLE(i2c, lis3lv02d_id); | ||
154 | |||
155 | static struct i2c_driver lis3lv02d_i2c_driver = { | ||
156 | .driver = { | ||
157 | .name = DRV_NAME, | ||
158 | .owner = THIS_MODULE, | ||
159 | }, | ||
160 | .suspend = lis3lv02d_i2c_suspend, | ||
161 | .shutdown = lis3lv02d_i2c_shutdown, | ||
162 | .resume = lis3lv02d_i2c_resume, | ||
163 | .probe = lis3lv02d_i2c_probe, | ||
164 | .remove = __devexit_p(lis3lv02d_i2c_remove), | ||
165 | .id_table = lis3lv02d_id, | ||
166 | }; | ||
167 | |||
168 | static int __init lis3lv02d_init(void) | ||
169 | { | ||
170 | return i2c_add_driver(&lis3lv02d_i2c_driver); | ||
171 | } | ||
172 | |||
173 | static void __exit lis3lv02d_exit(void) | ||
174 | { | ||
175 | i2c_del_driver(&lis3lv02d_i2c_driver); | ||
176 | } | ||
177 | |||
178 | MODULE_AUTHOR("Nokia Corporation"); | ||
179 | MODULE_DESCRIPTION("lis3lv02d I2C interface"); | ||
180 | MODULE_LICENSE("GPL"); | ||
181 | |||
182 | module_init(lis3lv02d_init); | ||
183 | module_exit(lis3lv02d_exit); | ||
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index e4f599f20e38..8a0e1ec95e4a 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig | |||
@@ -229,6 +229,12 @@ config LEDS_PWM | |||
229 | help | 229 | help |
230 | This option enables support for pwm driven LEDs | 230 | This option enables support for pwm driven LEDs |
231 | 231 | ||
232 | config LEDS_REGULATOR | ||
233 | tristate "REGULATOR driven LED support" | ||
234 | depends on LEDS_CLASS && REGULATOR | ||
235 | help | ||
236 | This option enables support for regulator driven LEDs. | ||
237 | |||
232 | config LEDS_BD2802 | 238 | config LEDS_BD2802 |
233 | tristate "LED driver for BD2802 RGB LED" | 239 | tristate "LED driver for BD2802 RGB LED" |
234 | depends on LEDS_CLASS && I2C | 240 | depends on LEDS_CLASS && I2C |
@@ -236,6 +242,33 @@ config LEDS_BD2802 | |||
236 | This option enables support for BD2802GU RGB LED driver chips | 242 | This option enables support for BD2802GU RGB LED driver chips |
237 | accessed via the I2C bus. | 243 | accessed via the I2C bus. |
238 | 244 | ||
245 | config LEDS_INTEL_SS4200 | ||
246 | tristate "LED driver for Intel NAS SS4200 series" | ||
247 | depends on LEDS_CLASS && PCI && DMI | ||
248 | help | ||
249 | This option enables support for the Intel SS4200 series of | ||
250 | Network Attached Storage servers. You may control the hard | ||
251 | drive or power LEDs on the front panel. Using this driver | ||
252 | can stop the front LED from blinking after startup. | ||
253 | |||
254 | config LEDS_LT3593 | ||
255 | tristate "LED driver for LT3593 controllers" | ||
256 | depends on LEDS_CLASS && GENERIC_GPIO | ||
257 | help | ||
258 | This option enables support for LEDs driven by a Linear Technology | ||
259 | LT3593 controller. This controller uses a special one-wire pulse | ||
260 | coding protocol to set the brightness. | ||
261 | |||
262 | config LEDS_ADP5520 | ||
263 | tristate "LED Support for ADP5520/ADP5501 PMIC" | ||
264 | depends on LEDS_CLASS && PMIC_ADP5520 | ||
265 | help | ||
266 | This option enables support for on-chip LED drivers found | ||
267 | on Analog Devices ADP5520/ADP5501 PMICs. | ||
268 | |||
269 | To compile this driver as a module, choose M here: the module will | ||
270 | be called leds-adp5520. | ||
271 | |||
239 | comment "LED Triggers" | 272 | comment "LED Triggers" |
240 | 273 | ||
241 | config LEDS_TRIGGERS | 274 | config LEDS_TRIGGERS |
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index 46d72704d606..9e63869d7c0d 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile | |||
@@ -29,6 +29,10 @@ obj-$(CONFIG_LEDS_DA903X) += leds-da903x.o | |||
29 | obj-$(CONFIG_LEDS_WM831X_STATUS) += leds-wm831x-status.o | 29 | obj-$(CONFIG_LEDS_WM831X_STATUS) += leds-wm831x-status.o |
30 | obj-$(CONFIG_LEDS_WM8350) += leds-wm8350.o | 30 | obj-$(CONFIG_LEDS_WM8350) += leds-wm8350.o |
31 | obj-$(CONFIG_LEDS_PWM) += leds-pwm.o | 31 | obj-$(CONFIG_LEDS_PWM) += leds-pwm.o |
32 | obj-$(CONFIG_LEDS_REGULATOR) += leds-regulator.o | ||
33 | obj-$(CONFIG_LEDS_INTEL_SS4200) += leds-ss4200.o | ||
34 | obj-$(CONFIG_LEDS_LT3593) += leds-lt3593.o | ||
35 | obj-$(CONFIG_LEDS_ADP5520) += leds-adp5520.o | ||
32 | 36 | ||
33 | # LED SPI Drivers | 37 | # LED SPI Drivers |
34 | obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o | 38 | obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o |
diff --git a/drivers/leds/leds-adp5520.c b/drivers/leds/leds-adp5520.c new file mode 100644 index 000000000000..a8f315902131 --- /dev/null +++ b/drivers/leds/leds-adp5520.c | |||
@@ -0,0 +1,230 @@ | |||
1 | /* | ||
2 | * LEDs driver for Analog Devices ADP5520/ADP5501 MFD PMICs | ||
3 | * | ||
4 | * Copyright 2009 Analog Devices Inc. | ||
5 | * | ||
6 | * Loosely derived from leds-da903x: | ||
7 | * Copyright (C) 2008 Compulab, Ltd. | ||
8 | * Mike Rapoport <mike@compulab.co.il> | ||
9 | * | ||
10 | * Copyright (C) 2006-2008 Marvell International Ltd. | ||
11 | * Eric Miao <eric.miao@marvell.com> | ||
12 | * | ||
13 | * Licensed under the GPL-2 or later. | ||
14 | */ | ||
15 | |||
16 | #include <linux/module.h> | ||
17 | #include <linux/kernel.h> | ||
18 | #include <linux/init.h> | ||
19 | #include <linux/platform_device.h> | ||
20 | #include <linux/leds.h> | ||
21 | #include <linux/workqueue.h> | ||
22 | #include <linux/mfd/adp5520.h> | ||
23 | |||
24 | struct adp5520_led { | ||
25 | struct led_classdev cdev; | ||
26 | struct work_struct work; | ||
27 | struct device *master; | ||
28 | enum led_brightness new_brightness; | ||
29 | int id; | ||
30 | int flags; | ||
31 | }; | ||
32 | |||
33 | static void adp5520_led_work(struct work_struct *work) | ||
34 | { | ||
35 | struct adp5520_led *led = container_of(work, struct adp5520_led, work); | ||
36 | adp5520_write(led->master, ADP5520_LED1_CURRENT + led->id - 1, | ||
37 | led->new_brightness >> 2); | ||
38 | } | ||
39 | |||
40 | static void adp5520_led_set(struct led_classdev *led_cdev, | ||
41 | enum led_brightness value) | ||
42 | { | ||
43 | struct adp5520_led *led; | ||
44 | |||
45 | led = container_of(led_cdev, struct adp5520_led, cdev); | ||
46 | led->new_brightness = value; | ||
47 | schedule_work(&led->work); | ||
48 | } | ||
49 | |||
50 | static int adp5520_led_setup(struct adp5520_led *led) | ||
51 | { | ||
52 | struct device *dev = led->master; | ||
53 | int flags = led->flags; | ||
54 | int ret = 0; | ||
55 | |||
56 | switch (led->id) { | ||
57 | case FLAG_ID_ADP5520_LED1_ADP5501_LED0: | ||
58 | ret |= adp5520_set_bits(dev, ADP5520_LED_TIME, | ||
59 | (flags >> ADP5520_FLAG_OFFT_SHIFT) & | ||
60 | ADP5520_FLAG_OFFT_MASK); | ||
61 | ret |= adp5520_set_bits(dev, ADP5520_LED_CONTROL, | ||
62 | ADP5520_LED1_EN); | ||
63 | break; | ||
64 | case FLAG_ID_ADP5520_LED2_ADP5501_LED1: | ||
65 | ret |= adp5520_set_bits(dev, ADP5520_LED_TIME, | ||
66 | ((flags >> ADP5520_FLAG_OFFT_SHIFT) & | ||
67 | ADP5520_FLAG_OFFT_MASK) << 2); | ||
68 | ret |= adp5520_clr_bits(dev, ADP5520_LED_CONTROL, | ||
69 | ADP5520_R3_MODE); | ||
70 | ret |= adp5520_set_bits(dev, ADP5520_LED_CONTROL, | ||
71 | ADP5520_LED2_EN); | ||
72 | break; | ||
73 | case FLAG_ID_ADP5520_LED3_ADP5501_LED2: | ||
74 | ret |= adp5520_set_bits(dev, ADP5520_LED_TIME, | ||
75 | ((flags >> ADP5520_FLAG_OFFT_SHIFT) & | ||
76 | ADP5520_FLAG_OFFT_MASK) << 4); | ||
77 | ret |= adp5520_clr_bits(dev, ADP5520_LED_CONTROL, | ||
78 | ADP5520_C3_MODE); | ||
79 | ret |= adp5520_set_bits(dev, ADP5520_LED_CONTROL, | ||
80 | ADP5520_LED3_EN); | ||
81 | break; | ||
82 | } | ||
83 | |||
84 | return ret; | ||
85 | } | ||
86 | |||
87 | static int __devinit adp5520_led_prepare(struct platform_device *pdev) | ||
88 | { | ||
89 | struct adp5520_leds_platform_data *pdata = pdev->dev.platform_data; | ||
90 | struct device *dev = pdev->dev.parent; | ||
91 | int ret = 0; | ||
92 | |||
93 | ret |= adp5520_write(dev, ADP5520_LED1_CURRENT, 0); | ||
94 | ret |= adp5520_write(dev, ADP5520_LED2_CURRENT, 0); | ||
95 | ret |= adp5520_write(dev, ADP5520_LED3_CURRENT, 0); | ||
96 | ret |= adp5520_write(dev, ADP5520_LED_TIME, pdata->led_on_time << 6); | ||
97 | ret |= adp5520_write(dev, ADP5520_LED_FADE, FADE_VAL(pdata->fade_in, | ||
98 | pdata->fade_out)); | ||
99 | |||
100 | return ret; | ||
101 | } | ||
102 | |||
103 | static int __devinit adp5520_led_probe(struct platform_device *pdev) | ||
104 | { | ||
105 | struct adp5520_leds_platform_data *pdata = pdev->dev.platform_data; | ||
106 | struct adp5520_led *led, *led_dat; | ||
107 | struct led_info *cur_led; | ||
108 | int ret, i; | ||
109 | |||
110 | if (pdata == NULL) { | ||
111 | dev_err(&pdev->dev, "missing platform data\n"); | ||
112 | return -ENODEV; | ||
113 | } | ||
114 | |||
115 | if (pdata->num_leds > ADP5520_01_MAXLEDS) { | ||
116 | dev_err(&pdev->dev, "can't handle more than %d LEDS\n", | ||
117 | ADP5520_01_MAXLEDS); | ||
118 | return -EFAULT; | ||
119 | } | ||
120 | |||
121 | led = kzalloc(sizeof(*led) * pdata->num_leds, GFP_KERNEL); | ||
122 | if (led == NULL) { | ||
123 | dev_err(&pdev->dev, "failed to alloc memory\n"); | ||
124 | return -ENOMEM; | ||
125 | } | ||
126 | |||
127 | ret = adp5520_led_prepare(pdev); | ||
128 | |||
129 | if (ret) { | ||
130 | dev_err(&pdev->dev, "failed to write\n"); | ||
131 | goto err_free; | ||
132 | } | ||
133 | |||
134 | for (i = 0; i < pdata->num_leds; ++i) { | ||
135 | cur_led = &pdata->leds[i]; | ||
136 | led_dat = &led[i]; | ||
137 | |||
138 | led_dat->cdev.name = cur_led->name; | ||
139 | led_dat->cdev.default_trigger = cur_led->default_trigger; | ||
140 | led_dat->cdev.brightness_set = adp5520_led_set; | ||
141 | led_dat->cdev.brightness = LED_OFF; | ||
142 | |||
143 | if (cur_led->flags & ADP5520_FLAG_LED_MASK) | ||
144 | led_dat->flags = cur_led->flags; | ||
145 | else | ||
146 | led_dat->flags = i + 1; | ||
147 | |||
148 | led_dat->id = led_dat->flags & ADP5520_FLAG_LED_MASK; | ||
149 | |||
150 | led_dat->master = pdev->dev.parent; | ||
151 | led_dat->new_brightness = LED_OFF; | ||
152 | |||
153 | INIT_WORK(&led_dat->work, adp5520_led_work); | ||
154 | |||
155 | ret = led_classdev_register(led_dat->master, &led_dat->cdev); | ||
156 | if (ret) { | ||
157 | dev_err(&pdev->dev, "failed to register LED %d\n", | ||
158 | led_dat->id); | ||
159 | goto err; | ||
160 | } | ||
161 | |||
162 | ret = adp5520_led_setup(led_dat); | ||
163 | if (ret) { | ||
164 | dev_err(&pdev->dev, "failed to write\n"); | ||
165 | i++; | ||
166 | goto err; | ||
167 | } | ||
168 | } | ||
169 | |||
170 | platform_set_drvdata(pdev, led); | ||
171 | return 0; | ||
172 | |||
173 | err: | ||
174 | if (i > 0) { | ||
175 | for (i = i - 1; i >= 0; i--) { | ||
176 | led_classdev_unregister(&led[i].cdev); | ||
177 | cancel_work_sync(&led[i].work); | ||
178 | } | ||
179 | } | ||
180 | |||
181 | err_free: | ||
182 | kfree(led); | ||
183 | return ret; | ||
184 | } | ||
185 | |||
186 | static int __devexit adp5520_led_remove(struct platform_device *pdev) | ||
187 | { | ||
188 | struct adp5520_leds_platform_data *pdata = pdev->dev.platform_data; | ||
189 | struct adp5520_led *led; | ||
190 | int i; | ||
191 | |||
192 | led = platform_get_drvdata(pdev); | ||
193 | |||
194 | adp5520_clr_bits(led->master, ADP5520_LED_CONTROL, | ||
195 | ADP5520_LED1_EN | ADP5520_LED2_EN | ADP5520_LED3_EN); | ||
196 | |||
197 | for (i = 0; i < pdata->num_leds; i++) { | ||
198 | led_classdev_unregister(&led[i].cdev); | ||
199 | cancel_work_sync(&led[i].work); | ||
200 | } | ||
201 | |||
202 | kfree(led); | ||
203 | return 0; | ||
204 | } | ||
205 | |||
206 | static struct platform_driver adp5520_led_driver = { | ||
207 | .driver = { | ||
208 | .name = "adp5520-led", | ||
209 | .owner = THIS_MODULE, | ||
210 | }, | ||
211 | .probe = adp5520_led_probe, | ||
212 | .remove = __devexit_p(adp5520_led_remove), | ||
213 | }; | ||
214 | |||
215 | static int __init adp5520_led_init(void) | ||
216 | { | ||
217 | return platform_driver_register(&adp5520_led_driver); | ||
218 | } | ||
219 | module_init(adp5520_led_init); | ||
220 | |||
221 | static void __exit adp5520_led_exit(void) | ||
222 | { | ||
223 | platform_driver_unregister(&adp5520_led_driver); | ||
224 | } | ||
225 | module_exit(adp5520_led_exit); | ||
226 | |||
227 | MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>"); | ||
228 | MODULE_DESCRIPTION("LEDS ADP5520(01) Driver"); | ||
229 | MODULE_LICENSE("GPL"); | ||
230 | MODULE_ALIAS("platform:adp5520-led"); | ||
diff --git a/drivers/leds/leds-alix2.c b/drivers/leds/leds-alix2.c index 731d4eef3425..f59ffadf5125 100644 --- a/drivers/leds/leds-alix2.c +++ b/drivers/leds/leds-alix2.c | |||
@@ -11,11 +11,24 @@ | |||
11 | #include <linux/module.h> | 11 | #include <linux/module.h> |
12 | #include <linux/platform_device.h> | 12 | #include <linux/platform_device.h> |
13 | #include <linux/string.h> | 13 | #include <linux/string.h> |
14 | #include <linux/pci.h> | ||
14 | 15 | ||
15 | static int force = 0; | 16 | static int force = 0; |
16 | module_param(force, bool, 0444); | 17 | module_param(force, bool, 0444); |
17 | MODULE_PARM_DESC(force, "Assume system has ALIX.2/ALIX.3 style LEDs"); | 18 | MODULE_PARM_DESC(force, "Assume system has ALIX.2/ALIX.3 style LEDs"); |
18 | 19 | ||
20 | #define MSR_LBAR_GPIO 0x5140000C | ||
21 | #define CS5535_GPIO_SIZE 256 | ||
22 | |||
23 | static u32 gpio_base; | ||
24 | |||
25 | static struct pci_device_id divil_pci[] = { | ||
26 | { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_ISA) }, | ||
27 | { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_ISA) }, | ||
28 | { } /* NULL entry */ | ||
29 | }; | ||
30 | MODULE_DEVICE_TABLE(pci, divil_pci); | ||
31 | |||
19 | struct alix_led { | 32 | struct alix_led { |
20 | struct led_classdev cdev; | 33 | struct led_classdev cdev; |
21 | unsigned short port; | 34 | unsigned short port; |
@@ -30,9 +43,9 @@ static void alix_led_set(struct led_classdev *led_cdev, | |||
30 | container_of(led_cdev, struct alix_led, cdev); | 43 | container_of(led_cdev, struct alix_led, cdev); |
31 | 44 | ||
32 | if (brightness) | 45 | if (brightness) |
33 | outl(led_dev->on_value, led_dev->port); | 46 | outl(led_dev->on_value, gpio_base + led_dev->port); |
34 | else | 47 | else |
35 | outl(led_dev->off_value, led_dev->port); | 48 | outl(led_dev->off_value, gpio_base + led_dev->port); |
36 | } | 49 | } |
37 | 50 | ||
38 | static struct alix_led alix_leds[] = { | 51 | static struct alix_led alix_leds[] = { |
@@ -41,7 +54,7 @@ static struct alix_led alix_leds[] = { | |||
41 | .name = "alix:1", | 54 | .name = "alix:1", |
42 | .brightness_set = alix_led_set, | 55 | .brightness_set = alix_led_set, |
43 | }, | 56 | }, |
44 | .port = 0x6100, | 57 | .port = 0x00, |
45 | .on_value = 1 << 22, | 58 | .on_value = 1 << 22, |
46 | .off_value = 1 << 6, | 59 | .off_value = 1 << 6, |
47 | }, | 60 | }, |
@@ -50,7 +63,7 @@ static struct alix_led alix_leds[] = { | |||
50 | .name = "alix:2", | 63 | .name = "alix:2", |
51 | .brightness_set = alix_led_set, | 64 | .brightness_set = alix_led_set, |
52 | }, | 65 | }, |
53 | .port = 0x6180, | 66 | .port = 0x80, |
54 | .on_value = 1 << 25, | 67 | .on_value = 1 << 25, |
55 | .off_value = 1 << 9, | 68 | .off_value = 1 << 9, |
56 | }, | 69 | }, |
@@ -59,7 +72,7 @@ static struct alix_led alix_leds[] = { | |||
59 | .name = "alix:3", | 72 | .name = "alix:3", |
60 | .brightness_set = alix_led_set, | 73 | .brightness_set = alix_led_set, |
61 | }, | 74 | }, |
62 | .port = 0x6180, | 75 | .port = 0x80, |
63 | .on_value = 1 << 27, | 76 | .on_value = 1 << 27, |
64 | .off_value = 1 << 11, | 77 | .off_value = 1 << 11, |
65 | }, | 78 | }, |
@@ -101,64 +114,104 @@ static struct platform_driver alix_led_driver = { | |||
101 | }, | 114 | }, |
102 | }; | 115 | }; |
103 | 116 | ||
104 | static int __init alix_present(void) | 117 | static int __init alix_present(unsigned long bios_phys, |
118 | const char *alix_sig, | ||
119 | size_t alix_sig_len) | ||
105 | { | 120 | { |
106 | const unsigned long bios_phys = 0x000f0000; | ||
107 | const size_t bios_len = 0x00010000; | 121 | const size_t bios_len = 0x00010000; |
108 | const char alix_sig[] = "PC Engines ALIX."; | ||
109 | const size_t alix_sig_len = sizeof(alix_sig) - 1; | ||
110 | |||
111 | const char *bios_virt; | 122 | const char *bios_virt; |
112 | const char *scan_end; | 123 | const char *scan_end; |
113 | const char *p; | 124 | const char *p; |
114 | int ret = 0; | 125 | char name[64]; |
115 | 126 | ||
116 | if (force) { | 127 | if (force) { |
117 | printk(KERN_NOTICE "%s: forced to skip BIOS test, " | 128 | printk(KERN_NOTICE "%s: forced to skip BIOS test, " |
118 | "assume system has ALIX.2 style LEDs\n", | 129 | "assume system has ALIX.2 style LEDs\n", |
119 | KBUILD_MODNAME); | 130 | KBUILD_MODNAME); |
120 | ret = 1; | 131 | return 1; |
121 | goto out; | ||
122 | } | 132 | } |
123 | 133 | ||
124 | bios_virt = phys_to_virt(bios_phys); | 134 | bios_virt = phys_to_virt(bios_phys); |
125 | scan_end = bios_virt + bios_len - (alix_sig_len + 2); | 135 | scan_end = bios_virt + bios_len - (alix_sig_len + 2); |
126 | for (p = bios_virt; p < scan_end; p++) { | 136 | for (p = bios_virt; p < scan_end; p++) { |
127 | const char *tail; | 137 | const char *tail; |
138 | char *a; | ||
128 | 139 | ||
129 | if (memcmp(p, alix_sig, alix_sig_len) != 0) { | 140 | if (memcmp(p, alix_sig, alix_sig_len) != 0) |
130 | continue; | 141 | continue; |
131 | } | 142 | |
143 | memcpy(name, p, sizeof(name)); | ||
144 | |||
145 | /* remove the first \0 character from string */ | ||
146 | a = strchr(name, '\0'); | ||
147 | if (a) | ||
148 | *a = ' '; | ||
149 | |||
150 | /* cut the string at a newline */ | ||
151 | a = strchr(name, '\r'); | ||
152 | if (a) | ||
153 | *a = '\0'; | ||
132 | 154 | ||
133 | tail = p + alix_sig_len; | 155 | tail = p + alix_sig_len; |
134 | if ((tail[0] == '2' || tail[0] == '3') && tail[1] == '\0') { | 156 | if ((tail[0] == '2' || tail[0] == '3')) { |
135 | printk(KERN_INFO | 157 | printk(KERN_INFO |
136 | "%s: system is recognized as \"%s\"\n", | 158 | "%s: system is recognized as \"%s\"\n", |
137 | KBUILD_MODNAME, p); | 159 | KBUILD_MODNAME, name); |
138 | ret = 1; | 160 | return 1; |
139 | break; | ||
140 | } | 161 | } |
141 | } | 162 | } |
142 | 163 | ||
143 | out: | 164 | return 0; |
144 | return ret; | ||
145 | } | 165 | } |
146 | 166 | ||
147 | static struct platform_device *pdev; | 167 | static struct platform_device *pdev; |
148 | 168 | ||
149 | static int __init alix_led_init(void) | 169 | static int __init alix_pci_led_init(void) |
150 | { | 170 | { |
151 | int ret; | 171 | u32 low, hi; |
152 | 172 | ||
153 | if (!alix_present()) { | 173 | if (pci_dev_present(divil_pci) == 0) { |
154 | ret = -ENODEV; | 174 | printk(KERN_WARNING KBUILD_MODNAME": DIVIL not found\n"); |
155 | goto out; | 175 | return -ENODEV; |
156 | } | 176 | } |
157 | 177 | ||
158 | /* enable output on GPIO for LED 1,2,3 */ | 178 | /* Grab the GPIO I/O range */ |
159 | outl(1 << 6, 0x6104); | 179 | rdmsr(MSR_LBAR_GPIO, low, hi); |
160 | outl(1 << 9, 0x6184); | 180 | |
161 | outl(1 << 11, 0x6184); | 181 | /* Check the mask and whether GPIO is enabled (sanity check) */ |
182 | if (hi != 0x0000f001) { | ||
183 | printk(KERN_WARNING KBUILD_MODNAME": GPIO not enabled\n"); | ||
184 | return -ENODEV; | ||
185 | } | ||
186 | |||
187 | /* Mask off the IO base address */ | ||
188 | gpio_base = low & 0x0000ff00; | ||
189 | |||
190 | if (!request_region(gpio_base, CS5535_GPIO_SIZE, KBUILD_MODNAME)) { | ||
191 | printk(KERN_ERR KBUILD_MODNAME": can't allocate I/O for GPIO\n"); | ||
192 | return -ENODEV; | ||
193 | } | ||
194 | |||
195 | /* Set GPIO function to output */ | ||
196 | outl(1 << 6, gpio_base + 0x04); | ||
197 | outl(1 << 9, gpio_base + 0x84); | ||
198 | outl(1 << 11, gpio_base + 0x84); | ||
199 | |||
200 | return 0; | ||
201 | } | ||
202 | |||
203 | static int __init alix_led_init(void) | ||
204 | { | ||
205 | int ret = -ENODEV; | ||
206 | const char tinybios_sig[] = "PC Engines ALIX."; | ||
207 | const char coreboot_sig[] = "PC Engines\0ALIX."; | ||
208 | |||
209 | if (alix_present(0xf0000, tinybios_sig, sizeof(tinybios_sig) - 1) || | ||
210 | alix_present(0x500, coreboot_sig, sizeof(coreboot_sig) - 1)) | ||
211 | ret = alix_pci_led_init(); | ||
212 | |||
213 | if (ret < 0) | ||
214 | return ret; | ||
162 | 215 | ||
163 | pdev = platform_device_register_simple(KBUILD_MODNAME, -1, NULL, 0); | 216 | pdev = platform_device_register_simple(KBUILD_MODNAME, -1, NULL, 0); |
164 | if (!IS_ERR(pdev)) { | 217 | if (!IS_ERR(pdev)) { |
@@ -168,7 +221,6 @@ static int __init alix_led_init(void) | |||
168 | } else | 221 | } else |
169 | ret = PTR_ERR(pdev); | 222 | ret = PTR_ERR(pdev); |
170 | 223 | ||
171 | out: | ||
172 | return ret; | 224 | return ret; |
173 | } | 225 | } |
174 | 226 | ||
@@ -176,6 +228,7 @@ static void __exit alix_led_exit(void) | |||
176 | { | 228 | { |
177 | platform_device_unregister(pdev); | 229 | platform_device_unregister(pdev); |
178 | platform_driver_unregister(&alix_led_driver); | 230 | platform_driver_unregister(&alix_led_driver); |
231 | release_region(gpio_base, CS5535_GPIO_SIZE); | ||
179 | } | 232 | } |
180 | 233 | ||
181 | module_init(alix_led_init); | 234 | module_init(alix_led_init); |
diff --git a/drivers/leds/leds-cobalt-qube.c b/drivers/leds/leds-cobalt-qube.c index 8816806accd2..da5fb016b1a5 100644 --- a/drivers/leds/leds-cobalt-qube.c +++ b/drivers/leds/leds-cobalt-qube.c | |||
@@ -31,7 +31,7 @@ static struct led_classdev qube_front_led = { | |||
31 | .name = "qube::front", | 31 | .name = "qube::front", |
32 | .brightness = LED_FULL, | 32 | .brightness = LED_FULL, |
33 | .brightness_set = qube_front_led_set, | 33 | .brightness_set = qube_front_led_set, |
34 | .default_trigger = "ide-disk", | 34 | .default_trigger = "default-on", |
35 | }; | 35 | }; |
36 | 36 | ||
37 | static int __devinit cobalt_qube_led_probe(struct platform_device *pdev) | 37 | static int __devinit cobalt_qube_led_probe(struct platform_device *pdev) |
@@ -43,7 +43,7 @@ static int __devinit cobalt_qube_led_probe(struct platform_device *pdev) | |||
43 | if (!res) | 43 | if (!res) |
44 | return -EBUSY; | 44 | return -EBUSY; |
45 | 45 | ||
46 | led_port = ioremap(res->start, res->end - res->start + 1); | 46 | led_port = ioremap(res->start, resource_size(res)); |
47 | if (!led_port) | 47 | if (!led_port) |
48 | return -ENOMEM; | 48 | return -ENOMEM; |
49 | 49 | ||
diff --git a/drivers/leds/leds-cobalt-raq.c b/drivers/leds/leds-cobalt-raq.c index defc212105f3..438d48384636 100644 --- a/drivers/leds/leds-cobalt-raq.c +++ b/drivers/leds/leds-cobalt-raq.c | |||
@@ -84,7 +84,7 @@ static int __devinit cobalt_raq_led_probe(struct platform_device *pdev) | |||
84 | if (!res) | 84 | if (!res) |
85 | return -EBUSY; | 85 | return -EBUSY; |
86 | 86 | ||
87 | led_port = ioremap(res->start, res->end - res->start + 1); | 87 | led_port = ioremap(res->start, resource_size(res)); |
88 | if (!led_port) | 88 | if (!led_port) |
89 | return -ENOMEM; | 89 | return -ENOMEM; |
90 | 90 | ||
diff --git a/drivers/leds/leds-lt3593.c b/drivers/leds/leds-lt3593.c new file mode 100644 index 000000000000..fee40a841959 --- /dev/null +++ b/drivers/leds/leds-lt3593.c | |||
@@ -0,0 +1,217 @@ | |||
1 | /* | ||
2 | * LEDs driver for LT3593 controllers | ||
3 | * | ||
4 | * See the datasheet at http://cds.linear.com/docs/Datasheet/3593f.pdf | ||
5 | * | ||
6 | * Copyright (c) 2009 Daniel Mack <daniel@caiaq.de> | ||
7 | * | ||
8 | * Based on leds-gpio.c, | ||
9 | * | ||
10 | * Copyright (C) 2007 8D Technologies inc. | ||
11 | * Raphael Assenat <raph@8d.com> | ||
12 | * Copyright (C) 2008 Freescale Semiconductor, Inc. | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or modify | ||
15 | * it under the terms of the GNU General Public License version 2 as | ||
16 | * published by the Free Software Foundation. | ||
17 | */ | ||
18 | |||
19 | #include <linux/kernel.h> | ||
20 | #include <linux/init.h> | ||
21 | #include <linux/platform_device.h> | ||
22 | #include <linux/leds.h> | ||
23 | #include <linux/workqueue.h> | ||
24 | #include <linux/delay.h> | ||
25 | #include <linux/gpio.h> | ||
26 | |||
27 | struct lt3593_led_data { | ||
28 | struct led_classdev cdev; | ||
29 | unsigned gpio; | ||
30 | struct work_struct work; | ||
31 | u8 new_level; | ||
32 | }; | ||
33 | |||
34 | static void lt3593_led_work(struct work_struct *work) | ||
35 | { | ||
36 | int pulses; | ||
37 | struct lt3593_led_data *led_dat = | ||
38 | container_of(work, struct lt3593_led_data, work); | ||
39 | |||
40 | /* | ||
41 | * The LT3593 resets its internal current level register to the maximum | ||
42 | * level on the first falling edge on the control pin. Each following | ||
43 | * falling edge decreases the current level by 625uA. Up to 32 pulses | ||
44 | * can be sent, so the maximum power reduction is 20mA. | ||
45 | * After a timeout of 128us, the value is taken from the register and | ||
46 | * applied is to the output driver. | ||
47 | */ | ||
48 | |||
49 | if (led_dat->new_level == 0) { | ||
50 | gpio_set_value_cansleep(led_dat->gpio, 0); | ||
51 | return; | ||
52 | } | ||
53 | |||
54 | pulses = 32 - (led_dat->new_level * 32) / 255; | ||
55 | |||
56 | if (pulses == 0) { | ||
57 | gpio_set_value_cansleep(led_dat->gpio, 0); | ||
58 | mdelay(1); | ||
59 | gpio_set_value_cansleep(led_dat->gpio, 1); | ||
60 | return; | ||
61 | } | ||
62 | |||
63 | gpio_set_value_cansleep(led_dat->gpio, 1); | ||
64 | |||
65 | while (pulses--) { | ||
66 | gpio_set_value_cansleep(led_dat->gpio, 0); | ||
67 | udelay(1); | ||
68 | gpio_set_value_cansleep(led_dat->gpio, 1); | ||
69 | udelay(1); | ||
70 | } | ||
71 | } | ||
72 | |||
73 | static void lt3593_led_set(struct led_classdev *led_cdev, | ||
74 | enum led_brightness value) | ||
75 | { | ||
76 | struct lt3593_led_data *led_dat = | ||
77 | container_of(led_cdev, struct lt3593_led_data, cdev); | ||
78 | |||
79 | led_dat->new_level = value; | ||
80 | schedule_work(&led_dat->work); | ||
81 | } | ||
82 | |||
83 | static int __devinit create_lt3593_led(const struct gpio_led *template, | ||
84 | struct lt3593_led_data *led_dat, struct device *parent) | ||
85 | { | ||
86 | int ret, state; | ||
87 | |||
88 | /* skip leds on GPIOs that aren't available */ | ||
89 | if (!gpio_is_valid(template->gpio)) { | ||
90 | printk(KERN_INFO "%s: skipping unavailable LT3593 LED at gpio %d (%s)\n", | ||
91 | KBUILD_MODNAME, template->gpio, template->name); | ||
92 | return 0; | ||
93 | } | ||
94 | |||
95 | ret = gpio_request(template->gpio, template->name); | ||
96 | if (ret < 0) | ||
97 | return ret; | ||
98 | |||
99 | led_dat->cdev.name = template->name; | ||
100 | led_dat->cdev.default_trigger = template->default_trigger; | ||
101 | led_dat->gpio = template->gpio; | ||
102 | |||
103 | led_dat->cdev.brightness_set = lt3593_led_set; | ||
104 | |||
105 | state = (template->default_state == LEDS_GPIO_DEFSTATE_ON); | ||
106 | led_dat->cdev.brightness = state ? LED_FULL : LED_OFF; | ||
107 | |||
108 | if (!template->retain_state_suspended) | ||
109 | led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME; | ||
110 | |||
111 | ret = gpio_direction_output(led_dat->gpio, state); | ||
112 | if (ret < 0) | ||
113 | goto err; | ||
114 | |||
115 | INIT_WORK(&led_dat->work, lt3593_led_work); | ||
116 | |||
117 | ret = led_classdev_register(parent, &led_dat->cdev); | ||
118 | if (ret < 0) | ||
119 | goto err; | ||
120 | |||
121 | printk(KERN_INFO "%s: registered LT3593 LED '%s' at GPIO %d\n", | ||
122 | KBUILD_MODNAME, template->name, template->gpio); | ||
123 | |||
124 | return 0; | ||
125 | |||
126 | err: | ||
127 | gpio_free(led_dat->gpio); | ||
128 | return ret; | ||
129 | } | ||
130 | |||
131 | static void delete_lt3593_led(struct lt3593_led_data *led) | ||
132 | { | ||
133 | if (!gpio_is_valid(led->gpio)) | ||
134 | return; | ||
135 | |||
136 | led_classdev_unregister(&led->cdev); | ||
137 | cancel_work_sync(&led->work); | ||
138 | gpio_free(led->gpio); | ||
139 | } | ||
140 | |||
141 | static int __devinit lt3593_led_probe(struct platform_device *pdev) | ||
142 | { | ||
143 | struct gpio_led_platform_data *pdata = pdev->dev.platform_data; | ||
144 | struct lt3593_led_data *leds_data; | ||
145 | int i, ret = 0; | ||
146 | |||
147 | if (!pdata) | ||
148 | return -EBUSY; | ||
149 | |||
150 | leds_data = kzalloc(sizeof(struct lt3593_led_data) * pdata->num_leds, | ||
151 | GFP_KERNEL); | ||
152 | if (!leds_data) | ||
153 | return -ENOMEM; | ||
154 | |||
155 | for (i = 0; i < pdata->num_leds; i++) { | ||
156 | ret = create_lt3593_led(&pdata->leds[i], &leds_data[i], | ||
157 | &pdev->dev); | ||
158 | if (ret < 0) | ||
159 | goto err; | ||
160 | } | ||
161 | |||
162 | platform_set_drvdata(pdev, leds_data); | ||
163 | |||
164 | return 0; | ||
165 | |||
166 | err: | ||
167 | for (i = i - 1; i >= 0; i--) | ||
168 | delete_lt3593_led(&leds_data[i]); | ||
169 | |||
170 | kfree(leds_data); | ||
171 | |||
172 | return ret; | ||
173 | } | ||
174 | |||
175 | static int __devexit lt3593_led_remove(struct platform_device *pdev) | ||
176 | { | ||
177 | int i; | ||
178 | struct gpio_led_platform_data *pdata = pdev->dev.platform_data; | ||
179 | struct lt3593_led_data *leds_data; | ||
180 | |||
181 | leds_data = platform_get_drvdata(pdev); | ||
182 | |||
183 | for (i = 0; i < pdata->num_leds; i++) | ||
184 | delete_lt3593_led(&leds_data[i]); | ||
185 | |||
186 | kfree(leds_data); | ||
187 | |||
188 | return 0; | ||
189 | } | ||
190 | |||
191 | static struct platform_driver lt3593_led_driver = { | ||
192 | .probe = lt3593_led_probe, | ||
193 | .remove = __devexit_p(lt3593_led_remove), | ||
194 | .driver = { | ||
195 | .name = "leds-lt3593", | ||
196 | .owner = THIS_MODULE, | ||
197 | }, | ||
198 | }; | ||
199 | |||
200 | MODULE_ALIAS("platform:leds-lt3593"); | ||
201 | |||
202 | static int __init lt3593_led_init(void) | ||
203 | { | ||
204 | return platform_driver_register(<3593_led_driver); | ||
205 | } | ||
206 | |||
207 | static void __exit lt3593_led_exit(void) | ||
208 | { | ||
209 | platform_driver_unregister(<3593_led_driver); | ||
210 | } | ||
211 | |||
212 | module_init(lt3593_led_init); | ||
213 | module_exit(lt3593_led_exit); | ||
214 | |||
215 | MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>"); | ||
216 | MODULE_DESCRIPTION("LED driver for LT3593 controllers"); | ||
217 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c index cdfdc8714e10..88b1dd091cfb 100644 --- a/drivers/leds/leds-pwm.c +++ b/drivers/leds/leds-pwm.c | |||
@@ -27,7 +27,6 @@ struct led_pwm_data { | |||
27 | struct pwm_device *pwm; | 27 | struct pwm_device *pwm; |
28 | unsigned int active_low; | 28 | unsigned int active_low; |
29 | unsigned int period; | 29 | unsigned int period; |
30 | unsigned int max_brightness; | ||
31 | }; | 30 | }; |
32 | 31 | ||
33 | static void led_pwm_set(struct led_classdev *led_cdev, | 32 | static void led_pwm_set(struct led_classdev *led_cdev, |
@@ -35,7 +34,7 @@ static void led_pwm_set(struct led_classdev *led_cdev, | |||
35 | { | 34 | { |
36 | struct led_pwm_data *led_dat = | 35 | struct led_pwm_data *led_dat = |
37 | container_of(led_cdev, struct led_pwm_data, cdev); | 36 | container_of(led_cdev, struct led_pwm_data, cdev); |
38 | unsigned int max = led_dat->max_brightness; | 37 | unsigned int max = led_dat->cdev.max_brightness; |
39 | unsigned int period = led_dat->period; | 38 | unsigned int period = led_dat->period; |
40 | 39 | ||
41 | if (brightness == 0) { | 40 | if (brightness == 0) { |
@@ -77,10 +76,10 @@ static int led_pwm_probe(struct platform_device *pdev) | |||
77 | led_dat->cdev.name = cur_led->name; | 76 | led_dat->cdev.name = cur_led->name; |
78 | led_dat->cdev.default_trigger = cur_led->default_trigger; | 77 | led_dat->cdev.default_trigger = cur_led->default_trigger; |
79 | led_dat->active_low = cur_led->active_low; | 78 | led_dat->active_low = cur_led->active_low; |
80 | led_dat->max_brightness = cur_led->max_brightness; | ||
81 | led_dat->period = cur_led->pwm_period_ns; | 79 | led_dat->period = cur_led->pwm_period_ns; |
82 | led_dat->cdev.brightness_set = led_pwm_set; | 80 | led_dat->cdev.brightness_set = led_pwm_set; |
83 | led_dat->cdev.brightness = LED_OFF; | 81 | led_dat->cdev.brightness = LED_OFF; |
82 | led_dat->cdev.max_brightness = cur_led->max_brightness; | ||
84 | led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME; | 83 | led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME; |
85 | 84 | ||
86 | ret = led_classdev_register(&pdev->dev, &led_dat->cdev); | 85 | ret = led_classdev_register(&pdev->dev, &led_dat->cdev); |
diff --git a/drivers/leds/leds-regulator.c b/drivers/leds/leds-regulator.c new file mode 100644 index 000000000000..7f00de3ef922 --- /dev/null +++ b/drivers/leds/leds-regulator.c | |||
@@ -0,0 +1,242 @@ | |||
1 | /* | ||
2 | * leds-regulator.c - LED class driver for regulator driven LEDs. | ||
3 | * | ||
4 | * Copyright (C) 2009 Antonio Ospite <ospite@studenti.unina.it> | ||
5 | * | ||
6 | * Inspired by leds-wm8350 driver. | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | * | ||
12 | */ | ||
13 | |||
14 | #include <linux/module.h> | ||
15 | #include <linux/err.h> | ||
16 | #include <linux/workqueue.h> | ||
17 | #include <linux/leds.h> | ||
18 | #include <linux/leds-regulator.h> | ||
19 | #include <linux/platform_device.h> | ||
20 | #include <linux/regulator/consumer.h> | ||
21 | |||
22 | #define to_regulator_led(led_cdev) \ | ||
23 | container_of(led_cdev, struct regulator_led, cdev) | ||
24 | |||
25 | struct regulator_led { | ||
26 | struct led_classdev cdev; | ||
27 | enum led_brightness value; | ||
28 | int enabled; | ||
29 | struct mutex mutex; | ||
30 | struct work_struct work; | ||
31 | |||
32 | struct regulator *vcc; | ||
33 | }; | ||
34 | |||
35 | static inline int led_regulator_get_max_brightness(struct regulator *supply) | ||
36 | { | ||
37 | int ret; | ||
38 | int voltage = regulator_list_voltage(supply, 0); | ||
39 | |||
40 | if (voltage <= 0) | ||
41 | return 1; | ||
42 | |||
43 | /* even if regulator can't change voltages, | ||
44 | * we still assume it can change status | ||
45 | * and the LED can be turned on and off. | ||
46 | */ | ||
47 | ret = regulator_set_voltage(supply, voltage, voltage); | ||
48 | if (ret < 0) | ||
49 | return 1; | ||
50 | |||
51 | return regulator_count_voltages(supply); | ||
52 | } | ||
53 | |||
54 | static int led_regulator_get_voltage(struct regulator *supply, | ||
55 | enum led_brightness brightness) | ||
56 | { | ||
57 | if (brightness == 0) | ||
58 | return -EINVAL; | ||
59 | |||
60 | return regulator_list_voltage(supply, brightness - 1); | ||
61 | } | ||
62 | |||
63 | |||
64 | static void regulator_led_enable(struct regulator_led *led) | ||
65 | { | ||
66 | int ret; | ||
67 | |||
68 | if (led->enabled) | ||
69 | return; | ||
70 | |||
71 | ret = regulator_enable(led->vcc); | ||
72 | if (ret != 0) { | ||
73 | dev_err(led->cdev.dev, "Failed to enable vcc: %d\n", ret); | ||
74 | return; | ||
75 | } | ||
76 | |||
77 | led->enabled = 1; | ||
78 | } | ||
79 | |||
80 | static void regulator_led_disable(struct regulator_led *led) | ||
81 | { | ||
82 | int ret; | ||
83 | |||
84 | if (!led->enabled) | ||
85 | return; | ||
86 | |||
87 | ret = regulator_disable(led->vcc); | ||
88 | if (ret != 0) { | ||
89 | dev_err(led->cdev.dev, "Failed to disable vcc: %d\n", ret); | ||
90 | return; | ||
91 | } | ||
92 | |||
93 | led->enabled = 0; | ||
94 | } | ||
95 | |||
96 | static void regulator_led_set_value(struct regulator_led *led) | ||
97 | { | ||
98 | int voltage; | ||
99 | int ret; | ||
100 | |||
101 | mutex_lock(&led->mutex); | ||
102 | |||
103 | if (led->value == LED_OFF) { | ||
104 | regulator_led_disable(led); | ||
105 | goto out; | ||
106 | } | ||
107 | |||
108 | if (led->cdev.max_brightness > 1) { | ||
109 | voltage = led_regulator_get_voltage(led->vcc, led->value); | ||
110 | dev_dbg(led->cdev.dev, "brightness: %d voltage: %d\n", | ||
111 | led->value, voltage); | ||
112 | |||
113 | ret = regulator_set_voltage(led->vcc, voltage, voltage); | ||
114 | if (ret != 0) | ||
115 | dev_err(led->cdev.dev, "Failed to set voltage %d: %d\n", | ||
116 | voltage, ret); | ||
117 | } | ||
118 | |||
119 | regulator_led_enable(led); | ||
120 | |||
121 | out: | ||
122 | mutex_unlock(&led->mutex); | ||
123 | } | ||
124 | |||
125 | static void led_work(struct work_struct *work) | ||
126 | { | ||
127 | struct regulator_led *led; | ||
128 | |||
129 | led = container_of(work, struct regulator_led, work); | ||
130 | regulator_led_set_value(led); | ||
131 | } | ||
132 | |||
133 | static void regulator_led_brightness_set(struct led_classdev *led_cdev, | ||
134 | enum led_brightness value) | ||
135 | { | ||
136 | struct regulator_led *led = to_regulator_led(led_cdev); | ||
137 | |||
138 | led->value = value; | ||
139 | schedule_work(&led->work); | ||
140 | } | ||
141 | |||
142 | static int __devinit regulator_led_probe(struct platform_device *pdev) | ||
143 | { | ||
144 | struct led_regulator_platform_data *pdata = pdev->dev.platform_data; | ||
145 | struct regulator_led *led; | ||
146 | struct regulator *vcc; | ||
147 | int ret = 0; | ||
148 | |||
149 | if (pdata == NULL) { | ||
150 | dev_err(&pdev->dev, "no platform data\n"); | ||
151 | return -ENODEV; | ||
152 | } | ||
153 | |||
154 | vcc = regulator_get_exclusive(&pdev->dev, "vled"); | ||
155 | if (IS_ERR(vcc)) { | ||
156 | dev_err(&pdev->dev, "Cannot get vcc for %s\n", pdata->name); | ||
157 | return PTR_ERR(vcc); | ||
158 | } | ||
159 | |||
160 | led = kzalloc(sizeof(*led), GFP_KERNEL); | ||
161 | if (led == NULL) { | ||
162 | ret = -ENOMEM; | ||
163 | goto err_vcc; | ||
164 | } | ||
165 | |||
166 | led->cdev.max_brightness = led_regulator_get_max_brightness(vcc); | ||
167 | if (pdata->brightness > led->cdev.max_brightness) { | ||
168 | dev_err(&pdev->dev, "Invalid default brightness %d\n", | ||
169 | pdata->brightness); | ||
170 | ret = -EINVAL; | ||
171 | goto err_led; | ||
172 | } | ||
173 | led->value = pdata->brightness; | ||
174 | |||
175 | led->cdev.brightness_set = regulator_led_brightness_set; | ||
176 | led->cdev.name = pdata->name; | ||
177 | led->cdev.flags |= LED_CORE_SUSPENDRESUME; | ||
178 | led->vcc = vcc; | ||
179 | |||
180 | mutex_init(&led->mutex); | ||
181 | INIT_WORK(&led->work, led_work); | ||
182 | |||
183 | platform_set_drvdata(pdev, led); | ||
184 | |||
185 | ret = led_classdev_register(&pdev->dev, &led->cdev); | ||
186 | if (ret < 0) { | ||
187 | cancel_work_sync(&led->work); | ||
188 | goto err_led; | ||
189 | } | ||
190 | |||
191 | /* to expose the default value to userspace */ | ||
192 | led->cdev.brightness = led->value; | ||
193 | |||
194 | /* Set the default led status */ | ||
195 | regulator_led_set_value(led); | ||
196 | |||
197 | return 0; | ||
198 | |||
199 | err_led: | ||
200 | kfree(led); | ||
201 | err_vcc: | ||
202 | regulator_put(vcc); | ||
203 | return ret; | ||
204 | } | ||
205 | |||
206 | static int __devexit regulator_led_remove(struct platform_device *pdev) | ||
207 | { | ||
208 | struct regulator_led *led = platform_get_drvdata(pdev); | ||
209 | |||
210 | led_classdev_unregister(&led->cdev); | ||
211 | cancel_work_sync(&led->work); | ||
212 | regulator_led_disable(led); | ||
213 | regulator_put(led->vcc); | ||
214 | kfree(led); | ||
215 | return 0; | ||
216 | } | ||
217 | |||
218 | static struct platform_driver regulator_led_driver = { | ||
219 | .driver = { | ||
220 | .name = "leds-regulator", | ||
221 | .owner = THIS_MODULE, | ||
222 | }, | ||
223 | .probe = regulator_led_probe, | ||
224 | .remove = __devexit_p(regulator_led_remove), | ||
225 | }; | ||
226 | |||
227 | static int __init regulator_led_init(void) | ||
228 | { | ||
229 | return platform_driver_register(®ulator_led_driver); | ||
230 | } | ||
231 | module_init(regulator_led_init); | ||
232 | |||
233 | static void __exit regulator_led_exit(void) | ||
234 | { | ||
235 | platform_driver_unregister(®ulator_led_driver); | ||
236 | } | ||
237 | module_exit(regulator_led_exit); | ||
238 | |||
239 | MODULE_AUTHOR("Antonio Ospite <ospite@studenti.unina.it>"); | ||
240 | MODULE_DESCRIPTION("Regulator driven LED driver"); | ||
241 | MODULE_LICENSE("GPL"); | ||
242 | MODULE_ALIAS("platform:leds-regulator"); | ||
diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c new file mode 100644 index 000000000000..97f04984c1ca --- /dev/null +++ b/drivers/leds/leds-ss4200.c | |||
@@ -0,0 +1,556 @@ | |||
1 | /* | ||
2 | * SS4200-E Hardware API | ||
3 | * Copyright (c) 2009, Intel Corporation. | ||
4 | * Copyright IBM Corporation, 2009 | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms and conditions of the GNU General Public License, | ||
8 | * version 2, as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
13 | * more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License along with | ||
16 | * this program; if not, write to the Free Software Foundation, Inc., | ||
17 | * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | * | ||
19 | * Author: Dave Hansen <dave@sr71.net> | ||
20 | */ | ||
21 | |||
22 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
23 | |||
24 | #include <linux/dmi.h> | ||
25 | #include <linux/init.h> | ||
26 | #include <linux/ioport.h> | ||
27 | #include <linux/kernel.h> | ||
28 | #include <linux/leds.h> | ||
29 | #include <linux/module.h> | ||
30 | #include <linux/pci.h> | ||
31 | #include <linux/types.h> | ||
32 | #include <linux/uaccess.h> | ||
33 | |||
34 | MODULE_AUTHOR("Rodney Girod <rgirod@confocus.com>, Dave Hansen <dave@sr71.net>"); | ||
35 | MODULE_DESCRIPTION("Intel NAS/Home Server ICH7 GPIO Driver"); | ||
36 | MODULE_LICENSE("GPL"); | ||
37 | |||
38 | /* | ||
39 | * ICH7 LPC/GPIO PCI Config register offsets | ||
40 | */ | ||
41 | #define PMBASE 0x040 | ||
42 | #define GPIO_BASE 0x048 | ||
43 | #define GPIO_CTRL 0x04c | ||
44 | #define GPIO_EN 0x010 | ||
45 | |||
46 | /* | ||
47 | * The ICH7 GPIO register block is 64 bytes in size. | ||
48 | */ | ||
49 | #define ICH7_GPIO_SIZE 64 | ||
50 | |||
51 | /* | ||
52 | * Define register offsets within the ICH7 register block. | ||
53 | */ | ||
54 | #define GPIO_USE_SEL 0x000 | ||
55 | #define GP_IO_SEL 0x004 | ||
56 | #define GP_LVL 0x00c | ||
57 | #define GPO_BLINK 0x018 | ||
58 | #define GPI_INV 0x030 | ||
59 | #define GPIO_USE_SEL2 0x034 | ||
60 | #define GP_IO_SEL2 0x038 | ||
61 | #define GP_LVL2 0x03c | ||
62 | |||
63 | /* | ||
64 | * PCI ID of the Intel ICH7 LPC Device within which the GPIO block lives. | ||
65 | */ | ||
66 | static struct pci_device_id ich7_lpc_pci_id[] = | ||
67 | { | ||
68 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_0) }, | ||
69 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_1) }, | ||
70 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_30) }, | ||
71 | { } /* NULL entry */ | ||
72 | }; | ||
73 | |||
74 | MODULE_DEVICE_TABLE(pci, ich7_lpc_pci_id); | ||
75 | |||
76 | static int __init ss4200_led_dmi_callback(const struct dmi_system_id *id) | ||
77 | { | ||
78 | pr_info("detected '%s'\n", id->ident); | ||
79 | return 1; | ||
80 | } | ||
81 | |||
82 | static unsigned int __initdata nodetect; | ||
83 | module_param_named(nodetect, nodetect, bool, 0); | ||
84 | MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection"); | ||
85 | |||
86 | /* | ||
87 | * struct nas_led_whitelist - List of known good models | ||
88 | * | ||
89 | * Contains the known good models this driver is compatible with. | ||
90 | * When adding a new model try to be as strict as possible. This | ||
91 | * makes it possible to keep the false positives (the model is | ||
92 | * detected as working, but in reality it is not) as low as | ||
93 | * possible. | ||
94 | */ | ||
95 | static struct dmi_system_id __initdata nas_led_whitelist[] = { | ||
96 | { | ||
97 | .callback = ss4200_led_dmi_callback, | ||
98 | .ident = "Intel SS4200-E", | ||
99 | .matches = { | ||
100 | DMI_MATCH(DMI_SYS_VENDOR, "Intel"), | ||
101 | DMI_MATCH(DMI_PRODUCT_NAME, "SS4200-E"), | ||
102 | DMI_MATCH(DMI_PRODUCT_VERSION, "1.00.00") | ||
103 | } | ||
104 | }, | ||
105 | }; | ||
106 | |||
107 | /* | ||
108 | * Base I/O address assigned to the Power Management register block | ||
109 | */ | ||
110 | static u32 g_pm_io_base; | ||
111 | |||
112 | /* | ||
113 | * Base I/O address assigned to the ICH7 GPIO register block | ||
114 | */ | ||
115 | static u32 nas_gpio_io_base; | ||
116 | |||
117 | /* | ||
118 | * When we successfully register a region, we are returned a resource. | ||
119 | * We use these to identify which regions we need to release on our way | ||
120 | * back out. | ||
121 | */ | ||
122 | static struct resource *gp_gpio_resource; | ||
123 | |||
124 | struct nasgpio_led { | ||
125 | char *name; | ||
126 | u32 gpio_bit; | ||
127 | struct led_classdev led_cdev; | ||
128 | }; | ||
129 | |||
130 | /* | ||
131 | * gpio_bit(s) are the ICH7 GPIO bit assignments | ||
132 | */ | ||
133 | static struct nasgpio_led nasgpio_leds[] = { | ||
134 | { .name = "hdd1:blue:sata", .gpio_bit = 0 }, | ||
135 | { .name = "hdd1:amber:sata", .gpio_bit = 1 }, | ||
136 | { .name = "hdd2:blue:sata", .gpio_bit = 2 }, | ||
137 | { .name = "hdd2:amber:sata", .gpio_bit = 3 }, | ||
138 | { .name = "hdd3:blue:sata", .gpio_bit = 4 }, | ||
139 | { .name = "hdd3:amber:sata", .gpio_bit = 5 }, | ||
140 | { .name = "hdd4:blue:sata", .gpio_bit = 6 }, | ||
141 | { .name = "hdd4:amber:sata", .gpio_bit = 7 }, | ||
142 | { .name = "power:blue:power", .gpio_bit = 27}, | ||
143 | { .name = "power:amber:power", .gpio_bit = 28}, | ||
144 | }; | ||
145 | |||
146 | #define NAS_RECOVERY 0x00000400 /* GPIO10 */ | ||
147 | |||
148 | static struct nasgpio_led * | ||
149 | led_classdev_to_nasgpio_led(struct led_classdev *led_cdev) | ||
150 | { | ||
151 | return container_of(led_cdev, struct nasgpio_led, led_cdev); | ||
152 | } | ||
153 | |||
154 | static struct nasgpio_led *get_led_named(char *name) | ||
155 | { | ||
156 | int i; | ||
157 | for (i = 0; i < ARRAY_SIZE(nasgpio_leds); i++) { | ||
158 | if (strcmp(nasgpio_leds[i].name, name)) | ||
159 | continue; | ||
160 | return &nasgpio_leds[i]; | ||
161 | } | ||
162 | return NULL; | ||
163 | } | ||
164 | |||
165 | /* | ||
166 | * This protects access to the gpio ports. | ||
167 | */ | ||
168 | static DEFINE_SPINLOCK(nasgpio_gpio_lock); | ||
169 | |||
170 | /* | ||
171 | * There are two gpio ports, one for blinking and the other | ||
172 | * for power. @port tells us if we're doing blinking or | ||
173 | * power control. | ||
174 | * | ||
175 | * Caller must hold nasgpio_gpio_lock | ||
176 | */ | ||
177 | static void __nasgpio_led_set_attr(struct led_classdev *led_cdev, | ||
178 | u32 port, u32 value) | ||
179 | { | ||
180 | struct nasgpio_led *led = led_classdev_to_nasgpio_led(led_cdev); | ||
181 | u32 gpio_out; | ||
182 | |||
183 | gpio_out = inl(nas_gpio_io_base + port); | ||
184 | if (value) | ||
185 | gpio_out |= (1<<led->gpio_bit); | ||
186 | else | ||
187 | gpio_out &= ~(1<<led->gpio_bit); | ||
188 | |||
189 | outl(gpio_out, nas_gpio_io_base + port); | ||
190 | } | ||
191 | |||
192 | static void nasgpio_led_set_attr(struct led_classdev *led_cdev, | ||
193 | u32 port, u32 value) | ||
194 | { | ||
195 | spin_lock(&nasgpio_gpio_lock); | ||
196 | __nasgpio_led_set_attr(led_cdev, port, value); | ||
197 | spin_unlock(&nasgpio_gpio_lock); | ||
198 | } | ||
199 | |||
200 | u32 nasgpio_led_get_attr(struct led_classdev *led_cdev, u32 port) | ||
201 | { | ||
202 | struct nasgpio_led *led = led_classdev_to_nasgpio_led(led_cdev); | ||
203 | u32 gpio_in; | ||
204 | |||
205 | spin_lock(&nasgpio_gpio_lock); | ||
206 | gpio_in = inl(nas_gpio_io_base + port); | ||
207 | spin_unlock(&nasgpio_gpio_lock); | ||
208 | if (gpio_in & (1<<led->gpio_bit)) | ||
209 | return 1; | ||
210 | return 0; | ||
211 | } | ||
212 | |||
213 | /* | ||
214 | * There is actual brightness control in the hardware, | ||
215 | * but it is via smbus commands and not implemented | ||
216 | * in this driver. | ||
217 | */ | ||
218 | static void nasgpio_led_set_brightness(struct led_classdev *led_cdev, | ||
219 | enum led_brightness brightness) | ||
220 | { | ||
221 | u32 setting = 0; | ||
222 | if (brightness >= LED_HALF) | ||
223 | setting = 1; | ||
224 | /* | ||
225 | * Hold the lock across both operations. This ensures | ||
226 | * consistency so that both the "turn off blinking" | ||
227 | * and "turn light off" operations complete as a set. | ||
228 | */ | ||
229 | spin_lock(&nasgpio_gpio_lock); | ||
230 | /* | ||
231 | * LED class documentation asks that past blink state | ||
232 | * be disabled when brightness is turned to zero. | ||
233 | */ | ||
234 | if (brightness == 0) | ||
235 | __nasgpio_led_set_attr(led_cdev, GPO_BLINK, 0); | ||
236 | __nasgpio_led_set_attr(led_cdev, GP_LVL, setting); | ||
237 | spin_unlock(&nasgpio_gpio_lock); | ||
238 | } | ||
239 | |||
240 | static int nasgpio_led_set_blink(struct led_classdev *led_cdev, | ||
241 | unsigned long *delay_on, | ||
242 | unsigned long *delay_off) | ||
243 | { | ||
244 | u32 setting = 1; | ||
245 | if (!(*delay_on == 0 && *delay_off == 0) && | ||
246 | !(*delay_on == 500 && *delay_off == 500)) | ||
247 | return -EINVAL; | ||
248 | /* | ||
249 | * These are very approximate. | ||
250 | */ | ||
251 | *delay_on = 500; | ||
252 | *delay_off = 500; | ||
253 | |||
254 | nasgpio_led_set_attr(led_cdev, GPO_BLINK, setting); | ||
255 | |||
256 | return 0; | ||
257 | } | ||
258 | |||
259 | |||
260 | /* | ||
261 | * Initialize the ICH7 GPIO registers for NAS usage. The BIOS should have | ||
262 | * already taken care of this, but we will do so in a non destructive manner | ||
263 | * so that we have what we need whether the BIOS did it or not. | ||
264 | */ | ||
265 | static int __devinit ich7_gpio_init(struct device *dev) | ||
266 | { | ||
267 | int i; | ||
268 | u32 config_data = 0; | ||
269 | u32 all_nas_led = 0; | ||
270 | |||
271 | for (i = 0; i < ARRAY_SIZE(nasgpio_leds); i++) | ||
272 | all_nas_led |= (1<<nasgpio_leds[i].gpio_bit); | ||
273 | |||
274 | spin_lock(&nasgpio_gpio_lock); | ||
275 | /* | ||
276 | * We need to enable all of the GPIO lines used by the NAS box, | ||
277 | * so we will read the current Use Selection and add our usage | ||
278 | * to it. This should be benign with regard to the original | ||
279 | * BIOS configuration. | ||
280 | */ | ||
281 | config_data = inl(nas_gpio_io_base + GPIO_USE_SEL); | ||
282 | dev_dbg(dev, ": Data read from GPIO_USE_SEL = 0x%08x\n", config_data); | ||
283 | config_data |= all_nas_led + NAS_RECOVERY; | ||
284 | outl(config_data, nas_gpio_io_base + GPIO_USE_SEL); | ||
285 | config_data = inl(nas_gpio_io_base + GPIO_USE_SEL); | ||
286 | dev_dbg(dev, ": GPIO_USE_SEL = 0x%08x\n\n", config_data); | ||
287 | |||
288 | /* | ||
289 | * The LED GPIO outputs need to be configured for output, so we | ||
290 | * will ensure that all LED lines are cleared for output and the | ||
291 | * RECOVERY line ready for input. This too should be benign with | ||
292 | * regard to BIOS configuration. | ||
293 | */ | ||
294 | config_data = inl(nas_gpio_io_base + GP_IO_SEL); | ||
295 | dev_dbg(dev, ": Data read from GP_IO_SEL = 0x%08x\n", | ||
296 | config_data); | ||
297 | config_data &= ~all_nas_led; | ||
298 | config_data |= NAS_RECOVERY; | ||
299 | outl(config_data, nas_gpio_io_base + GP_IO_SEL); | ||
300 | config_data = inl(nas_gpio_io_base + GP_IO_SEL); | ||
301 | dev_dbg(dev, ": GP_IO_SEL = 0x%08x\n", config_data); | ||
302 | |||
303 | /* | ||
304 | * In our final system, the BIOS will initialize the state of all | ||
305 | * of the LEDs. For now, we turn them all off (or Low). | ||
306 | */ | ||
307 | config_data = inl(nas_gpio_io_base + GP_LVL); | ||
308 | dev_dbg(dev, ": Data read from GP_LVL = 0x%08x\n", config_data); | ||
309 | /* | ||
310 | * In our final system, the BIOS will initialize the blink state of all | ||
311 | * of the LEDs. For now, we turn blink off for all of them. | ||
312 | */ | ||
313 | config_data = inl(nas_gpio_io_base + GPO_BLINK); | ||
314 | dev_dbg(dev, ": Data read from GPO_BLINK = 0x%08x\n", config_data); | ||
315 | |||
316 | /* | ||
317 | * At this moment, I am unsure if anything needs to happen with GPI_INV | ||
318 | */ | ||
319 | config_data = inl(nas_gpio_io_base + GPI_INV); | ||
320 | dev_dbg(dev, ": Data read from GPI_INV = 0x%08x\n", config_data); | ||
321 | |||
322 | spin_unlock(&nasgpio_gpio_lock); | ||
323 | return 0; | ||
324 | } | ||
325 | |||
326 | static void ich7_lpc_cleanup(struct device *dev) | ||
327 | { | ||
328 | /* | ||
329 | * If we were given exclusive use of the GPIO | ||
330 | * I/O Address range, we must return it. | ||
331 | */ | ||
332 | if (gp_gpio_resource) { | ||
333 | dev_dbg(dev, ": Releasing GPIO I/O addresses\n"); | ||
334 | release_region(nas_gpio_io_base, ICH7_GPIO_SIZE); | ||
335 | gp_gpio_resource = NULL; | ||
336 | } | ||
337 | } | ||
338 | |||
339 | /* | ||
340 | * The OS has determined that the LPC of the Intel ICH7 Southbridge is present | ||
341 | * so we can retrive the required operational information and prepare the GPIO. | ||
342 | */ | ||
343 | static struct pci_dev *nas_gpio_pci_dev; | ||
344 | static int __devinit ich7_lpc_probe(struct pci_dev *dev, | ||
345 | const struct pci_device_id *id) | ||
346 | { | ||
347 | int status; | ||
348 | u32 gc = 0; | ||
349 | |||
350 | status = pci_enable_device(dev); | ||
351 | if (status) { | ||
352 | dev_err(&dev->dev, "pci_enable_device failed\n"); | ||
353 | return -EIO; | ||
354 | } | ||
355 | |||
356 | nas_gpio_pci_dev = dev; | ||
357 | status = pci_read_config_dword(dev, PMBASE, &g_pm_io_base); | ||
358 | if (status) | ||
359 | goto out; | ||
360 | g_pm_io_base &= 0x00000ff80; | ||
361 | |||
362 | status = pci_read_config_dword(dev, GPIO_CTRL, &gc); | ||
363 | if (!(GPIO_EN & gc)) { | ||
364 | status = -EEXIST; | ||
365 | dev_info(&dev->dev, | ||
366 | "ERROR: The LPC GPIO Block has not been enabled.\n"); | ||
367 | goto out; | ||
368 | } | ||
369 | |||
370 | status = pci_read_config_dword(dev, GPIO_BASE, &nas_gpio_io_base); | ||
371 | if (0 > status) { | ||
372 | dev_info(&dev->dev, "Unable to read GPIOBASE.\n"); | ||
373 | goto out; | ||
374 | } | ||
375 | dev_dbg(&dev->dev, ": GPIOBASE = 0x%08x\n", nas_gpio_io_base); | ||
376 | nas_gpio_io_base &= 0x00000ffc0; | ||
377 | |||
378 | /* | ||
379 | * Insure that we have exclusive access to the GPIO I/O address range. | ||
380 | */ | ||
381 | gp_gpio_resource = request_region(nas_gpio_io_base, ICH7_GPIO_SIZE, | ||
382 | KBUILD_MODNAME); | ||
383 | if (NULL == gp_gpio_resource) { | ||
384 | dev_info(&dev->dev, | ||
385 | "ERROR Unable to register GPIO I/O addresses.\n"); | ||
386 | status = -1; | ||
387 | goto out; | ||
388 | } | ||
389 | |||
390 | /* | ||
391 | * Initialize the GPIO for NAS/Home Server Use | ||
392 | */ | ||
393 | ich7_gpio_init(&dev->dev); | ||
394 | |||
395 | out: | ||
396 | if (status) { | ||
397 | ich7_lpc_cleanup(&dev->dev); | ||
398 | pci_disable_device(dev); | ||
399 | } | ||
400 | return status; | ||
401 | } | ||
402 | |||
403 | static void ich7_lpc_remove(struct pci_dev *dev) | ||
404 | { | ||
405 | ich7_lpc_cleanup(&dev->dev); | ||
406 | pci_disable_device(dev); | ||
407 | } | ||
408 | |||
409 | /* | ||
410 | * pci_driver structure passed to the PCI modules | ||
411 | */ | ||
412 | static struct pci_driver nas_gpio_pci_driver = { | ||
413 | .name = KBUILD_MODNAME, | ||
414 | .id_table = ich7_lpc_pci_id, | ||
415 | .probe = ich7_lpc_probe, | ||
416 | .remove = ich7_lpc_remove, | ||
417 | }; | ||
418 | |||
419 | static struct led_classdev *get_classdev_for_led_nr(int nr) | ||
420 | { | ||
421 | struct nasgpio_led *nas_led = &nasgpio_leds[nr]; | ||
422 | struct led_classdev *led = &nas_led->led_cdev; | ||
423 | return led; | ||
424 | } | ||
425 | |||
426 | |||
427 | static void set_power_light_amber_noblink(void) | ||
428 | { | ||
429 | struct nasgpio_led *amber = get_led_named("power:amber:power"); | ||
430 | struct nasgpio_led *blue = get_led_named("power:blue:power"); | ||
431 | |||
432 | if (!amber || !blue) | ||
433 | return; | ||
434 | /* | ||
435 | * LED_OFF implies disabling future blinking | ||
436 | */ | ||
437 | pr_debug("setting blue off and amber on\n"); | ||
438 | |||
439 | nasgpio_led_set_brightness(&blue->led_cdev, LED_OFF); | ||
440 | nasgpio_led_set_brightness(&amber->led_cdev, LED_FULL); | ||
441 | } | ||
442 | |||
443 | static ssize_t nas_led_blink_show(struct device *dev, | ||
444 | struct device_attribute *attr, char *buf) | ||
445 | { | ||
446 | struct led_classdev *led = dev_get_drvdata(dev); | ||
447 | int blinking = 0; | ||
448 | if (nasgpio_led_get_attr(led, GPO_BLINK)) | ||
449 | blinking = 1; | ||
450 | return sprintf(buf, "%u\n", blinking); | ||
451 | } | ||
452 | |||
453 | static ssize_t nas_led_blink_store(struct device *dev, | ||
454 | struct device_attribute *attr, | ||
455 | const char *buf, size_t size) | ||
456 | { | ||
457 | int ret; | ||
458 | struct led_classdev *led = dev_get_drvdata(dev); | ||
459 | unsigned long blink_state; | ||
460 | |||
461 | ret = strict_strtoul(buf, 10, &blink_state); | ||
462 | if (ret) | ||
463 | return ret; | ||
464 | |||
465 | nasgpio_led_set_attr(led, GPO_BLINK, blink_state); | ||
466 | |||
467 | return size; | ||
468 | } | ||
469 | |||
470 | static DEVICE_ATTR(blink, 0644, nas_led_blink_show, nas_led_blink_store); | ||
471 | |||
472 | static int register_nasgpio_led(int led_nr) | ||
473 | { | ||
474 | int ret; | ||
475 | struct nasgpio_led *nas_led = &nasgpio_leds[led_nr]; | ||
476 | struct led_classdev *led = get_classdev_for_led_nr(led_nr); | ||
477 | |||
478 | led->name = nas_led->name; | ||
479 | led->brightness = LED_OFF; | ||
480 | if (nasgpio_led_get_attr(led, GP_LVL)) | ||
481 | led->brightness = LED_FULL; | ||
482 | led->brightness_set = nasgpio_led_set_brightness; | ||
483 | led->blink_set = nasgpio_led_set_blink; | ||
484 | ret = led_classdev_register(&nas_gpio_pci_dev->dev, led); | ||
485 | if (ret) | ||
486 | return ret; | ||
487 | ret = device_create_file(led->dev, &dev_attr_blink); | ||
488 | if (ret) | ||
489 | led_classdev_unregister(led); | ||
490 | return ret; | ||
491 | } | ||
492 | |||
493 | static void unregister_nasgpio_led(int led_nr) | ||
494 | { | ||
495 | struct led_classdev *led = get_classdev_for_led_nr(led_nr); | ||
496 | led_classdev_unregister(led); | ||
497 | device_remove_file(led->dev, &dev_attr_blink); | ||
498 | } | ||
499 | /* | ||
500 | * module load/initialization | ||
501 | */ | ||
502 | static int __init nas_gpio_init(void) | ||
503 | { | ||
504 | int i; | ||
505 | int ret = 0; | ||
506 | int nr_devices = 0; | ||
507 | |||
508 | nr_devices = dmi_check_system(nas_led_whitelist); | ||
509 | if (nodetect) { | ||
510 | pr_info("skipping hardware autodetection\n"); | ||
511 | pr_info("Please send 'dmidecode' output to dave@sr71.net\n"); | ||
512 | nr_devices++; | ||
513 | } | ||
514 | |||
515 | if (nr_devices <= 0) { | ||
516 | pr_info("no LED devices found\n"); | ||
517 | return -ENODEV; | ||
518 | } | ||
519 | |||
520 | pr_info("registering PCI driver\n"); | ||
521 | ret = pci_register_driver(&nas_gpio_pci_driver); | ||
522 | if (ret) | ||
523 | return ret; | ||
524 | for (i = 0; i < ARRAY_SIZE(nasgpio_leds); i++) { | ||
525 | ret = register_nasgpio_led(i); | ||
526 | if (ret) | ||
527 | goto out_err; | ||
528 | } | ||
529 | /* | ||
530 | * When the system powers on, the BIOS leaves the power | ||
531 | * light blue and blinking. This will turn it solid | ||
532 | * amber once the driver is loaded. | ||
533 | */ | ||
534 | set_power_light_amber_noblink(); | ||
535 | return 0; | ||
536 | out_err: | ||
537 | for (; i >= 0; i--) | ||
538 | unregister_nasgpio_led(i); | ||
539 | pci_unregister_driver(&nas_gpio_pci_driver); | ||
540 | return ret; | ||
541 | } | ||
542 | |||
543 | /* | ||
544 | * module unload | ||
545 | */ | ||
546 | static void __exit nas_gpio_exit(void) | ||
547 | { | ||
548 | int i; | ||
549 | pr_info("Unregistering driver\n"); | ||
550 | for (i = 0; i < ARRAY_SIZE(nasgpio_leds); i++) | ||
551 | unregister_nasgpio_led(i); | ||
552 | pci_unregister_driver(&nas_gpio_pci_driver); | ||
553 | } | ||
554 | |||
555 | module_init(nas_gpio_init); | ||
556 | module_exit(nas_gpio_exit); | ||
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 1a7a9fc50ea1..e3551d20464f 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig | |||
@@ -203,6 +203,7 @@ config CS5535_MFGPT | |||
203 | 203 | ||
204 | config CS5535_MFGPT_DEFAULT_IRQ | 204 | config CS5535_MFGPT_DEFAULT_IRQ |
205 | int | 205 | int |
206 | depends on CS5535_MFGPT | ||
206 | default 7 | 207 | default 7 |
207 | help | 208 | help |
208 | MFGPTs on the CS5535 require an interrupt. The selected IRQ | 209 | MFGPTs on the CS5535 require an interrupt. The selected IRQ |
diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c index cdb845b68ab5..06b64085a355 100644 --- a/drivers/mmc/core/sdio.c +++ b/drivers/mmc/core/sdio.c | |||
@@ -516,7 +516,8 @@ int mmc_attach_sdio(struct mmc_host *host, u32 ocr) | |||
516 | * The number of functions on the card is encoded inside | 516 | * The number of functions on the card is encoded inside |
517 | * the ocr. | 517 | * the ocr. |
518 | */ | 518 | */ |
519 | card->sdio_funcs = funcs = (ocr & 0x70000000) >> 28; | 519 | funcs = (ocr & 0x70000000) >> 28; |
520 | card->sdio_funcs = 0; | ||
520 | 521 | ||
521 | /* | 522 | /* |
522 | * If needed, disconnect card detection pull-up resistor. | 523 | * If needed, disconnect card detection pull-up resistor. |
@@ -528,7 +529,7 @@ int mmc_attach_sdio(struct mmc_host *host, u32 ocr) | |||
528 | /* | 529 | /* |
529 | * Initialize (but don't add) all present functions. | 530 | * Initialize (but don't add) all present functions. |
530 | */ | 531 | */ |
531 | for (i = 0;i < funcs;i++) { | 532 | for (i = 0; i < funcs; i++, card->sdio_funcs++) { |
532 | err = sdio_init_func(host->card, i + 1); | 533 | err = sdio_init_func(host->card, i + 1); |
533 | if (err) | 534 | if (err) |
534 | goto remove; | 535 | goto remove; |
diff --git a/drivers/mmc/core/sdio_bus.c b/drivers/mmc/core/sdio_bus.c index d37464e296a5..9e060c87e64d 100644 --- a/drivers/mmc/core/sdio_bus.c +++ b/drivers/mmc/core/sdio_bus.c | |||
@@ -248,12 +248,15 @@ int sdio_add_func(struct sdio_func *func) | |||
248 | /* | 248 | /* |
249 | * Unregister a SDIO function with the driver model, and | 249 | * Unregister a SDIO function with the driver model, and |
250 | * (eventually) free it. | 250 | * (eventually) free it. |
251 | * This function can be called through error paths where sdio_add_func() was | ||
252 | * never executed (because a failure occurred at an earlier point). | ||
251 | */ | 253 | */ |
252 | void sdio_remove_func(struct sdio_func *func) | 254 | void sdio_remove_func(struct sdio_func *func) |
253 | { | 255 | { |
254 | if (sdio_func_present(func)) | 256 | if (!sdio_func_present(func)) |
255 | device_del(&func->dev); | 257 | return; |
256 | 258 | ||
259 | device_del(&func->dev); | ||
257 | put_device(&func->dev); | 260 | put_device(&func->dev); |
258 | } | 261 | } |
259 | 262 | ||
diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig index 9d405b181781..ce1d28884e29 100644 --- a/drivers/mmc/host/Kconfig +++ b/drivers/mmc/host/Kconfig | |||
@@ -44,6 +44,19 @@ config MMC_SDHCI_IO_ACCESSORS | |||
44 | This is silent Kconfig symbol that is selected by the drivers that | 44 | This is silent Kconfig symbol that is selected by the drivers that |
45 | need to overwrite SDHCI IO memory accessors. | 45 | need to overwrite SDHCI IO memory accessors. |
46 | 46 | ||
47 | config MMC_SDHCI_BIG_ENDIAN_32BIT_BYTE_SWAPPER | ||
48 | bool | ||
49 | select MMC_SDHCI_IO_ACCESSORS | ||
50 | help | ||
51 | This option is selected by drivers running on big endian hosts | ||
52 | and performing I/O to a SDHCI controller through a bus that | ||
53 | implements a hardware byte swapper using a 32-bit datum. | ||
54 | This endian mapping mode is called "data invariance" and | ||
55 | has the effect of scrambling the addresses and formats of data | ||
56 | accessed in sizes other than the datum size. | ||
57 | |||
58 | This is the case for the Freescale eSDHC and Nintendo Wii SDHCI. | ||
59 | |||
47 | config MMC_SDHCI_PCI | 60 | config MMC_SDHCI_PCI |
48 | tristate "SDHCI support on PCI bus" | 61 | tristate "SDHCI support on PCI bus" |
49 | depends on MMC_SDHCI && PCI | 62 | depends on MMC_SDHCI && PCI |
@@ -75,11 +88,29 @@ config MMC_RICOH_MMC | |||
75 | config MMC_SDHCI_OF | 88 | config MMC_SDHCI_OF |
76 | tristate "SDHCI support on OpenFirmware platforms" | 89 | tristate "SDHCI support on OpenFirmware platforms" |
77 | depends on MMC_SDHCI && PPC_OF | 90 | depends on MMC_SDHCI && PPC_OF |
78 | select MMC_SDHCI_IO_ACCESSORS | ||
79 | help | 91 | help |
80 | This selects the OF support for Secure Digital Host Controller | 92 | This selects the OF support for Secure Digital Host Controller |
81 | Interfaces. So far, only the Freescale eSDHC controller is known | 93 | Interfaces. |
82 | to exist on OF platforms. | 94 | |
95 | If unsure, say N. | ||
96 | |||
97 | config MMC_SDHCI_OF_ESDHC | ||
98 | bool "SDHCI OF support for the Freescale eSDHC controller" | ||
99 | depends on MMC_SDHCI_OF | ||
100 | select MMC_SDHCI_BIG_ENDIAN_32BIT_BYTE_SWAPPER | ||
101 | help | ||
102 | This selects the Freescale eSDHC controller support. | ||
103 | |||
104 | If unsure, say N. | ||
105 | |||
106 | config MMC_SDHCI_OF_HLWD | ||
107 | bool "SDHCI OF support for the Nintendo Wii SDHCI controllers" | ||
108 | depends on MMC_SDHCI_OF | ||
109 | select MMC_SDHCI_BIG_ENDIAN_32BIT_BYTE_SWAPPER | ||
110 | help | ||
111 | This selects the Secure Digital Host Controller Interface (SDHCI) | ||
112 | found in the "Hollywood" chipset of the Nintendo Wii video game | ||
113 | console. | ||
83 | 114 | ||
84 | If unsure, say N. | 115 | If unsure, say N. |
85 | 116 | ||
diff --git a/drivers/mmc/host/Makefile b/drivers/mmc/host/Makefile index ded4d8cdd9d7..3d253dd4240f 100644 --- a/drivers/mmc/host/Makefile +++ b/drivers/mmc/host/Makefile | |||
@@ -13,7 +13,6 @@ obj-$(CONFIG_MMC_MXC) += mxcmmc.o | |||
13 | obj-$(CONFIG_MMC_SDHCI) += sdhci.o | 13 | obj-$(CONFIG_MMC_SDHCI) += sdhci.o |
14 | obj-$(CONFIG_MMC_SDHCI_PCI) += sdhci-pci.o | 14 | obj-$(CONFIG_MMC_SDHCI_PCI) += sdhci-pci.o |
15 | obj-$(CONFIG_MMC_RICOH_MMC) += ricoh_mmc.o | 15 | obj-$(CONFIG_MMC_RICOH_MMC) += ricoh_mmc.o |
16 | obj-$(CONFIG_MMC_SDHCI_OF) += sdhci-of.o | ||
17 | obj-$(CONFIG_MMC_SDHCI_PLTFM) += sdhci-pltfm.o | 16 | obj-$(CONFIG_MMC_SDHCI_PLTFM) += sdhci-pltfm.o |
18 | obj-$(CONFIG_MMC_SDHCI_S3C) += sdhci-s3c.o | 17 | obj-$(CONFIG_MMC_SDHCI_S3C) += sdhci-s3c.o |
19 | obj-$(CONFIG_MMC_WBSD) += wbsd.o | 18 | obj-$(CONFIG_MMC_WBSD) += wbsd.o |
@@ -37,6 +36,11 @@ obj-$(CONFIG_MMC_CB710) += cb710-mmc.o | |||
37 | obj-$(CONFIG_MMC_VIA_SDMMC) += via-sdmmc.o | 36 | obj-$(CONFIG_MMC_VIA_SDMMC) += via-sdmmc.o |
38 | obj-$(CONFIG_SDH_BFIN) += bfin_sdh.o | 37 | obj-$(CONFIG_SDH_BFIN) += bfin_sdh.o |
39 | 38 | ||
39 | obj-$(CONFIG_MMC_SDHCI_OF) += sdhci-of.o | ||
40 | sdhci-of-y := sdhci-of-core.o | ||
41 | sdhci-of-$(CONFIG_MMC_SDHCI_OF_ESDHC) += sdhci-of-esdhc.o | ||
42 | sdhci-of-$(CONFIG_MMC_SDHCI_OF_HLWD) += sdhci-of-hlwd.o | ||
43 | |||
40 | ifeq ($(CONFIG_CB710_DEBUG),y) | 44 | ifeq ($(CONFIG_CB710_DEBUG),y) |
41 | CFLAGS-cb710-mmc += -DDEBUG | 45 | CFLAGS-cb710-mmc += -DDEBUG |
42 | endif | 46 | endif |
diff --git a/drivers/mmc/host/sdhci-of.c b/drivers/mmc/host/sdhci-of-core.c index 01ab916c2802..55e33135edb4 100644 --- a/drivers/mmc/host/sdhci-of.c +++ b/drivers/mmc/host/sdhci-of-core.c | |||
@@ -22,62 +22,37 @@ | |||
22 | #include <linux/of_platform.h> | 22 | #include <linux/of_platform.h> |
23 | #include <linux/mmc/host.h> | 23 | #include <linux/mmc/host.h> |
24 | #include <asm/machdep.h> | 24 | #include <asm/machdep.h> |
25 | #include "sdhci-of.h" | ||
25 | #include "sdhci.h" | 26 | #include "sdhci.h" |
26 | 27 | ||
27 | struct sdhci_of_data { | 28 | #ifdef CONFIG_MMC_SDHCI_BIG_ENDIAN_32BIT_BYTE_SWAPPER |
28 | unsigned int quirks; | ||
29 | struct sdhci_ops ops; | ||
30 | }; | ||
31 | |||
32 | struct sdhci_of_host { | ||
33 | unsigned int clock; | ||
34 | u16 xfer_mode_shadow; | ||
35 | }; | ||
36 | 29 | ||
37 | /* | 30 | /* |
38 | * Ops and quirks for the Freescale eSDHC controller. | 31 | * These accessors are designed for big endian hosts doing I/O to |
32 | * little endian controllers incorporating a 32-bit hardware byte swapper. | ||
39 | */ | 33 | */ |
40 | 34 | ||
41 | #define ESDHC_DMA_SYSCTL 0x40c | 35 | u32 sdhci_be32bs_readl(struct sdhci_host *host, int reg) |
42 | #define ESDHC_DMA_SNOOP 0x00000040 | ||
43 | |||
44 | #define ESDHC_SYSTEM_CONTROL 0x2c | ||
45 | #define ESDHC_CLOCK_MASK 0x0000fff0 | ||
46 | #define ESDHC_PREDIV_SHIFT 8 | ||
47 | #define ESDHC_DIVIDER_SHIFT 4 | ||
48 | #define ESDHC_CLOCK_PEREN 0x00000004 | ||
49 | #define ESDHC_CLOCK_HCKEN 0x00000002 | ||
50 | #define ESDHC_CLOCK_IPGEN 0x00000001 | ||
51 | |||
52 | #define ESDHC_HOST_CONTROL_RES 0x05 | ||
53 | |||
54 | static u32 esdhc_readl(struct sdhci_host *host, int reg) | ||
55 | { | 36 | { |
56 | return in_be32(host->ioaddr + reg); | 37 | return in_be32(host->ioaddr + reg); |
57 | } | 38 | } |
58 | 39 | ||
59 | static u16 esdhc_readw(struct sdhci_host *host, int reg) | 40 | u16 sdhci_be32bs_readw(struct sdhci_host *host, int reg) |
60 | { | 41 | { |
61 | u16 ret; | 42 | return in_be16(host->ioaddr + (reg ^ 0x2)); |
62 | |||
63 | if (unlikely(reg == SDHCI_HOST_VERSION)) | ||
64 | ret = in_be16(host->ioaddr + reg); | ||
65 | else | ||
66 | ret = in_be16(host->ioaddr + (reg ^ 0x2)); | ||
67 | return ret; | ||
68 | } | 43 | } |
69 | 44 | ||
70 | static u8 esdhc_readb(struct sdhci_host *host, int reg) | 45 | u8 sdhci_be32bs_readb(struct sdhci_host *host, int reg) |
71 | { | 46 | { |
72 | return in_8(host->ioaddr + (reg ^ 0x3)); | 47 | return in_8(host->ioaddr + (reg ^ 0x3)); |
73 | } | 48 | } |
74 | 49 | ||
75 | static void esdhc_writel(struct sdhci_host *host, u32 val, int reg) | 50 | void sdhci_be32bs_writel(struct sdhci_host *host, u32 val, int reg) |
76 | { | 51 | { |
77 | out_be32(host->ioaddr + reg, val); | 52 | out_be32(host->ioaddr + reg, val); |
78 | } | 53 | } |
79 | 54 | ||
80 | static void esdhc_writew(struct sdhci_host *host, u16 val, int reg) | 55 | void sdhci_be32bs_writew(struct sdhci_host *host, u16 val, int reg) |
81 | { | 56 | { |
82 | struct sdhci_of_host *of_host = sdhci_priv(host); | 57 | struct sdhci_of_host *of_host = sdhci_priv(host); |
83 | int base = reg & ~0x3; | 58 | int base = reg & ~0x3; |
@@ -92,106 +67,21 @@ static void esdhc_writew(struct sdhci_host *host, u16 val, int reg) | |||
92 | of_host->xfer_mode_shadow = val; | 67 | of_host->xfer_mode_shadow = val; |
93 | return; | 68 | return; |
94 | case SDHCI_COMMAND: | 69 | case SDHCI_COMMAND: |
95 | esdhc_writel(host, val << 16 | of_host->xfer_mode_shadow, | 70 | sdhci_be32bs_writel(host, val << 16 | of_host->xfer_mode_shadow, |
96 | SDHCI_TRANSFER_MODE); | 71 | SDHCI_TRANSFER_MODE); |
97 | return; | 72 | return; |
98 | case SDHCI_BLOCK_SIZE: | ||
99 | /* | ||
100 | * Two last DMA bits are reserved, and first one is used for | ||
101 | * non-standard blksz of 4096 bytes that we don't support | ||
102 | * yet. So clear the DMA boundary bits. | ||
103 | */ | ||
104 | val &= ~SDHCI_MAKE_BLKSZ(0x7, 0); | ||
105 | /* fall through */ | ||
106 | } | 73 | } |
107 | clrsetbits_be32(host->ioaddr + base, 0xffff << shift, val << shift); | 74 | clrsetbits_be32(host->ioaddr + base, 0xffff << shift, val << shift); |
108 | } | 75 | } |
109 | 76 | ||
110 | static void esdhc_writeb(struct sdhci_host *host, u8 val, int reg) | 77 | void sdhci_be32bs_writeb(struct sdhci_host *host, u8 val, int reg) |
111 | { | 78 | { |
112 | int base = reg & ~0x3; | 79 | int base = reg & ~0x3; |
113 | int shift = (reg & 0x3) * 8; | 80 | int shift = (reg & 0x3) * 8; |
114 | 81 | ||
115 | /* Prevent SDHCI core from writing reserved bits (e.g. HISPD). */ | ||
116 | if (reg == SDHCI_HOST_CONTROL) | ||
117 | val &= ~ESDHC_HOST_CONTROL_RES; | ||
118 | |||
119 | clrsetbits_be32(host->ioaddr + base , 0xff << shift, val << shift); | 82 | clrsetbits_be32(host->ioaddr + base , 0xff << shift, val << shift); |
120 | } | 83 | } |
121 | 84 | #endif /* CONFIG_MMC_SDHCI_BIG_ENDIAN_32BIT_BYTE_SWAPPER */ | |
122 | static void esdhc_set_clock(struct sdhci_host *host, unsigned int clock) | ||
123 | { | ||
124 | int pre_div = 2; | ||
125 | int div = 1; | ||
126 | |||
127 | clrbits32(host->ioaddr + ESDHC_SYSTEM_CONTROL, ESDHC_CLOCK_IPGEN | | ||
128 | ESDHC_CLOCK_HCKEN | ESDHC_CLOCK_PEREN | ESDHC_CLOCK_MASK); | ||
129 | |||
130 | if (clock == 0) | ||
131 | goto out; | ||
132 | |||
133 | while (host->max_clk / pre_div / 16 > clock && pre_div < 256) | ||
134 | pre_div *= 2; | ||
135 | |||
136 | while (host->max_clk / pre_div / div > clock && div < 16) | ||
137 | div++; | ||
138 | |||
139 | dev_dbg(mmc_dev(host->mmc), "desired SD clock: %d, actual: %d\n", | ||
140 | clock, host->max_clk / pre_div / div); | ||
141 | |||
142 | pre_div >>= 1; | ||
143 | div--; | ||
144 | |||
145 | setbits32(host->ioaddr + ESDHC_SYSTEM_CONTROL, ESDHC_CLOCK_IPGEN | | ||
146 | ESDHC_CLOCK_HCKEN | ESDHC_CLOCK_PEREN | | ||
147 | div << ESDHC_DIVIDER_SHIFT | pre_div << ESDHC_PREDIV_SHIFT); | ||
148 | mdelay(100); | ||
149 | out: | ||
150 | host->clock = clock; | ||
151 | } | ||
152 | |||
153 | static int esdhc_enable_dma(struct sdhci_host *host) | ||
154 | { | ||
155 | setbits32(host->ioaddr + ESDHC_DMA_SYSCTL, ESDHC_DMA_SNOOP); | ||
156 | return 0; | ||
157 | } | ||
158 | |||
159 | static unsigned int esdhc_get_max_clock(struct sdhci_host *host) | ||
160 | { | ||
161 | struct sdhci_of_host *of_host = sdhci_priv(host); | ||
162 | |||
163 | return of_host->clock; | ||
164 | } | ||
165 | |||
166 | static unsigned int esdhc_get_min_clock(struct sdhci_host *host) | ||
167 | { | ||
168 | struct sdhci_of_host *of_host = sdhci_priv(host); | ||
169 | |||
170 | return of_host->clock / 256 / 16; | ||
171 | } | ||
172 | |||
173 | static struct sdhci_of_data sdhci_esdhc = { | ||
174 | .quirks = SDHCI_QUIRK_FORCE_BLK_SZ_2048 | | ||
175 | SDHCI_QUIRK_BROKEN_CARD_DETECTION | | ||
176 | SDHCI_QUIRK_NO_BUSY_IRQ | | ||
177 | SDHCI_QUIRK_NONSTANDARD_CLOCK | | ||
178 | SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK | | ||
179 | SDHCI_QUIRK_PIO_NEEDS_DELAY | | ||
180 | SDHCI_QUIRK_RESTORE_IRQS_AFTER_RESET | | ||
181 | SDHCI_QUIRK_NO_CARD_NO_RESET, | ||
182 | .ops = { | ||
183 | .readl = esdhc_readl, | ||
184 | .readw = esdhc_readw, | ||
185 | .readb = esdhc_readb, | ||
186 | .writel = esdhc_writel, | ||
187 | .writew = esdhc_writew, | ||
188 | .writeb = esdhc_writeb, | ||
189 | .set_clock = esdhc_set_clock, | ||
190 | .enable_dma = esdhc_enable_dma, | ||
191 | .get_max_clock = esdhc_get_max_clock, | ||
192 | .get_min_clock = esdhc_get_min_clock, | ||
193 | }, | ||
194 | }; | ||
195 | 85 | ||
196 | #ifdef CONFIG_PM | 86 | #ifdef CONFIG_PM |
197 | 87 | ||
@@ -301,9 +191,14 @@ static int __devexit sdhci_of_remove(struct of_device *ofdev) | |||
301 | } | 191 | } |
302 | 192 | ||
303 | static const struct of_device_id sdhci_of_match[] = { | 193 | static const struct of_device_id sdhci_of_match[] = { |
194 | #ifdef CONFIG_MMC_SDHCI_OF_ESDHC | ||
304 | { .compatible = "fsl,mpc8379-esdhc", .data = &sdhci_esdhc, }, | 195 | { .compatible = "fsl,mpc8379-esdhc", .data = &sdhci_esdhc, }, |
305 | { .compatible = "fsl,mpc8536-esdhc", .data = &sdhci_esdhc, }, | 196 | { .compatible = "fsl,mpc8536-esdhc", .data = &sdhci_esdhc, }, |
306 | { .compatible = "fsl,esdhc", .data = &sdhci_esdhc, }, | 197 | { .compatible = "fsl,esdhc", .data = &sdhci_esdhc, }, |
198 | #endif | ||
199 | #ifdef CONFIG_MMC_SDHCI_OF_HLWD | ||
200 | { .compatible = "nintendo,hollywood-sdhci", .data = &sdhci_hlwd, }, | ||
201 | #endif | ||
307 | { .compatible = "generic-sdhci", }, | 202 | { .compatible = "generic-sdhci", }, |
308 | {}, | 203 | {}, |
309 | }; | 204 | }; |
diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c new file mode 100644 index 000000000000..d5b11a17e648 --- /dev/null +++ b/drivers/mmc/host/sdhci-of-esdhc.c | |||
@@ -0,0 +1,143 @@ | |||
1 | /* | ||
2 | * Freescale eSDHC controller driver. | ||
3 | * | ||
4 | * Copyright (c) 2007 Freescale Semiconductor, Inc. | ||
5 | * Copyright (c) 2009 MontaVista Software, Inc. | ||
6 | * | ||
7 | * Authors: Xiaobo Xie <X.Xie@freescale.com> | ||
8 | * Anton Vorontsov <avorontsov@ru.mvista.com> | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or (at | ||
13 | * your option) any later version. | ||
14 | */ | ||
15 | |||
16 | #include <linux/io.h> | ||
17 | #include <linux/delay.h> | ||
18 | #include <linux/mmc/host.h> | ||
19 | #include "sdhci-of.h" | ||
20 | #include "sdhci.h" | ||
21 | |||
22 | /* | ||
23 | * Ops and quirks for the Freescale eSDHC controller. | ||
24 | */ | ||
25 | |||
26 | #define ESDHC_DMA_SYSCTL 0x40c | ||
27 | #define ESDHC_DMA_SNOOP 0x00000040 | ||
28 | |||
29 | #define ESDHC_SYSTEM_CONTROL 0x2c | ||
30 | #define ESDHC_CLOCK_MASK 0x0000fff0 | ||
31 | #define ESDHC_PREDIV_SHIFT 8 | ||
32 | #define ESDHC_DIVIDER_SHIFT 4 | ||
33 | #define ESDHC_CLOCK_PEREN 0x00000004 | ||
34 | #define ESDHC_CLOCK_HCKEN 0x00000002 | ||
35 | #define ESDHC_CLOCK_IPGEN 0x00000001 | ||
36 | |||
37 | #define ESDHC_HOST_CONTROL_RES 0x05 | ||
38 | |||
39 | static u16 esdhc_readw(struct sdhci_host *host, int reg) | ||
40 | { | ||
41 | u16 ret; | ||
42 | |||
43 | if (unlikely(reg == SDHCI_HOST_VERSION)) | ||
44 | ret = in_be16(host->ioaddr + reg); | ||
45 | else | ||
46 | ret = sdhci_be32bs_readw(host, reg); | ||
47 | return ret; | ||
48 | } | ||
49 | |||
50 | static void esdhc_writew(struct sdhci_host *host, u16 val, int reg) | ||
51 | { | ||
52 | if (reg == SDHCI_BLOCK_SIZE) { | ||
53 | /* | ||
54 | * Two last DMA bits are reserved, and first one is used for | ||
55 | * non-standard blksz of 4096 bytes that we don't support | ||
56 | * yet. So clear the DMA boundary bits. | ||
57 | */ | ||
58 | val &= ~SDHCI_MAKE_BLKSZ(0x7, 0); | ||
59 | } | ||
60 | sdhci_be32bs_writew(host, val, reg); | ||
61 | } | ||
62 | |||
63 | static void esdhc_writeb(struct sdhci_host *host, u8 val, int reg) | ||
64 | { | ||
65 | /* Prevent SDHCI core from writing reserved bits (e.g. HISPD). */ | ||
66 | if (reg == SDHCI_HOST_CONTROL) | ||
67 | val &= ~ESDHC_HOST_CONTROL_RES; | ||
68 | sdhci_be32bs_writeb(host, val, reg); | ||
69 | } | ||
70 | |||
71 | static void esdhc_set_clock(struct sdhci_host *host, unsigned int clock) | ||
72 | { | ||
73 | int pre_div = 2; | ||
74 | int div = 1; | ||
75 | |||
76 | clrbits32(host->ioaddr + ESDHC_SYSTEM_CONTROL, ESDHC_CLOCK_IPGEN | | ||
77 | ESDHC_CLOCK_HCKEN | ESDHC_CLOCK_PEREN | ESDHC_CLOCK_MASK); | ||
78 | |||
79 | if (clock == 0) | ||
80 | goto out; | ||
81 | |||
82 | while (host->max_clk / pre_div / 16 > clock && pre_div < 256) | ||
83 | pre_div *= 2; | ||
84 | |||
85 | while (host->max_clk / pre_div / div > clock && div < 16) | ||
86 | div++; | ||
87 | |||
88 | dev_dbg(mmc_dev(host->mmc), "desired SD clock: %d, actual: %d\n", | ||
89 | clock, host->max_clk / pre_div / div); | ||
90 | |||
91 | pre_div >>= 1; | ||
92 | div--; | ||
93 | |||
94 | setbits32(host->ioaddr + ESDHC_SYSTEM_CONTROL, ESDHC_CLOCK_IPGEN | | ||
95 | ESDHC_CLOCK_HCKEN | ESDHC_CLOCK_PEREN | | ||
96 | div << ESDHC_DIVIDER_SHIFT | pre_div << ESDHC_PREDIV_SHIFT); | ||
97 | mdelay(100); | ||
98 | out: | ||
99 | host->clock = clock; | ||
100 | } | ||
101 | |||
102 | static int esdhc_enable_dma(struct sdhci_host *host) | ||
103 | { | ||
104 | setbits32(host->ioaddr + ESDHC_DMA_SYSCTL, ESDHC_DMA_SNOOP); | ||
105 | return 0; | ||
106 | } | ||
107 | |||
108 | static unsigned int esdhc_get_max_clock(struct sdhci_host *host) | ||
109 | { | ||
110 | struct sdhci_of_host *of_host = sdhci_priv(host); | ||
111 | |||
112 | return of_host->clock; | ||
113 | } | ||
114 | |||
115 | static unsigned int esdhc_get_min_clock(struct sdhci_host *host) | ||
116 | { | ||
117 | struct sdhci_of_host *of_host = sdhci_priv(host); | ||
118 | |||
119 | return of_host->clock / 256 / 16; | ||
120 | } | ||
121 | |||
122 | struct sdhci_of_data sdhci_esdhc = { | ||
123 | .quirks = SDHCI_QUIRK_FORCE_BLK_SZ_2048 | | ||
124 | SDHCI_QUIRK_BROKEN_CARD_DETECTION | | ||
125 | SDHCI_QUIRK_NO_BUSY_IRQ | | ||
126 | SDHCI_QUIRK_NONSTANDARD_CLOCK | | ||
127 | SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK | | ||
128 | SDHCI_QUIRK_PIO_NEEDS_DELAY | | ||
129 | SDHCI_QUIRK_RESTORE_IRQS_AFTER_RESET | | ||
130 | SDHCI_QUIRK_NO_CARD_NO_RESET, | ||
131 | .ops = { | ||
132 | .readl = sdhci_be32bs_readl, | ||
133 | .readw = esdhc_readw, | ||
134 | .readb = sdhci_be32bs_readb, | ||
135 | .writel = sdhci_be32bs_writel, | ||
136 | .writew = esdhc_writew, | ||
137 | .writeb = esdhc_writeb, | ||
138 | .set_clock = esdhc_set_clock, | ||
139 | .enable_dma = esdhc_enable_dma, | ||
140 | .get_max_clock = esdhc_get_max_clock, | ||
141 | .get_min_clock = esdhc_get_min_clock, | ||
142 | }, | ||
143 | }; | ||
diff --git a/drivers/mmc/host/sdhci-of-hlwd.c b/drivers/mmc/host/sdhci-of-hlwd.c new file mode 100644 index 000000000000..35117f3ed757 --- /dev/null +++ b/drivers/mmc/host/sdhci-of-hlwd.c | |||
@@ -0,0 +1,65 @@ | |||
1 | /* | ||
2 | * drivers/mmc/host/sdhci-of-hlwd.c | ||
3 | * | ||
4 | * Nintendo Wii Secure Digital Host Controller Interface. | ||
5 | * Copyright (C) 2009 The GameCube Linux Team | ||
6 | * Copyright (C) 2009 Albert Herranz | ||
7 | * | ||
8 | * Based on sdhci-of-esdhc.c | ||
9 | * | ||
10 | * Copyright (c) 2007 Freescale Semiconductor, Inc. | ||
11 | * Copyright (c) 2009 MontaVista Software, Inc. | ||
12 | * | ||
13 | * Authors: Xiaobo Xie <X.Xie@freescale.com> | ||
14 | * Anton Vorontsov <avorontsov@ru.mvista.com> | ||
15 | * | ||
16 | * This program is free software; you can redistribute it and/or modify | ||
17 | * it under the terms of the GNU General Public License as published by | ||
18 | * the Free Software Foundation; either version 2 of the License, or (at | ||
19 | * your option) any later version. | ||
20 | */ | ||
21 | |||
22 | #include <linux/delay.h> | ||
23 | #include <linux/mmc/host.h> | ||
24 | #include "sdhci-of.h" | ||
25 | #include "sdhci.h" | ||
26 | |||
27 | /* | ||
28 | * Ops and quirks for the Nintendo Wii SDHCI controllers. | ||
29 | */ | ||
30 | |||
31 | /* | ||
32 | * We need a small delay after each write, or things go horribly wrong. | ||
33 | */ | ||
34 | #define SDHCI_HLWD_WRITE_DELAY 5 /* usecs */ | ||
35 | |||
36 | static void sdhci_hlwd_writel(struct sdhci_host *host, u32 val, int reg) | ||
37 | { | ||
38 | sdhci_be32bs_writel(host, val, reg); | ||
39 | udelay(SDHCI_HLWD_WRITE_DELAY); | ||
40 | } | ||
41 | |||
42 | static void sdhci_hlwd_writew(struct sdhci_host *host, u16 val, int reg) | ||
43 | { | ||
44 | sdhci_be32bs_writew(host, val, reg); | ||
45 | udelay(SDHCI_HLWD_WRITE_DELAY); | ||
46 | } | ||
47 | |||
48 | static void sdhci_hlwd_writeb(struct sdhci_host *host, u8 val, int reg) | ||
49 | { | ||
50 | sdhci_be32bs_writeb(host, val, reg); | ||
51 | udelay(SDHCI_HLWD_WRITE_DELAY); | ||
52 | } | ||
53 | |||
54 | struct sdhci_of_data sdhci_hlwd = { | ||
55 | .quirks = SDHCI_QUIRK_32BIT_DMA_ADDR | | ||
56 | SDHCI_QUIRK_32BIT_DMA_SIZE, | ||
57 | .ops = { | ||
58 | .readl = sdhci_be32bs_readl, | ||
59 | .readw = sdhci_be32bs_readw, | ||
60 | .readb = sdhci_be32bs_readb, | ||
61 | .writel = sdhci_hlwd_writel, | ||
62 | .writew = sdhci_hlwd_writew, | ||
63 | .writeb = sdhci_hlwd_writeb, | ||
64 | }, | ||
65 | }; | ||
diff --git a/drivers/mmc/host/sdhci-of.h b/drivers/mmc/host/sdhci-of.h new file mode 100644 index 000000000000..ad09ad9915d8 --- /dev/null +++ b/drivers/mmc/host/sdhci-of.h | |||
@@ -0,0 +1,42 @@ | |||
1 | /* | ||
2 | * OpenFirmware bindings for Secure Digital Host Controller Interface. | ||
3 | * | ||
4 | * Copyright (c) 2007 Freescale Semiconductor, Inc. | ||
5 | * Copyright (c) 2009 MontaVista Software, Inc. | ||
6 | * | ||
7 | * Authors: Xiaobo Xie <X.Xie@freescale.com> | ||
8 | * Anton Vorontsov <avorontsov@ru.mvista.com> | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or (at | ||
13 | * your option) any later version. | ||
14 | */ | ||
15 | |||
16 | #ifndef __SDHCI_OF_H | ||
17 | #define __SDHCI_OF_H | ||
18 | |||
19 | #include <linux/types.h> | ||
20 | #include "sdhci.h" | ||
21 | |||
22 | struct sdhci_of_data { | ||
23 | unsigned int quirks; | ||
24 | struct sdhci_ops ops; | ||
25 | }; | ||
26 | |||
27 | struct sdhci_of_host { | ||
28 | unsigned int clock; | ||
29 | u16 xfer_mode_shadow; | ||
30 | }; | ||
31 | |||
32 | extern u32 sdhci_be32bs_readl(struct sdhci_host *host, int reg); | ||
33 | extern u16 sdhci_be32bs_readw(struct sdhci_host *host, int reg); | ||
34 | extern u8 sdhci_be32bs_readb(struct sdhci_host *host, int reg); | ||
35 | extern void sdhci_be32bs_writel(struct sdhci_host *host, u32 val, int reg); | ||
36 | extern void sdhci_be32bs_writew(struct sdhci_host *host, u16 val, int reg); | ||
37 | extern void sdhci_be32bs_writeb(struct sdhci_host *host, u8 val, int reg); | ||
38 | |||
39 | extern struct sdhci_of_data sdhci_esdhc; | ||
40 | extern struct sdhci_of_data sdhci_hlwd; | ||
41 | |||
42 | #endif /* __SDHCI_OF_H */ | ||
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index ce5f1d73dc04..842f46f94284 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h | |||
@@ -8,6 +8,8 @@ | |||
8 | * the Free Software Foundation; either version 2 of the License, or (at | 8 | * the Free Software Foundation; either version 2 of the License, or (at |
9 | * your option) any later version. | 9 | * your option) any later version. |
10 | */ | 10 | */ |
11 | #ifndef __SDHCI_H | ||
12 | #define __SDHCI_H | ||
11 | 13 | ||
12 | #include <linux/scatterlist.h> | 14 | #include <linux/scatterlist.h> |
13 | #include <linux/compiler.h> | 15 | #include <linux/compiler.h> |
@@ -408,3 +410,5 @@ extern void sdhci_remove_host(struct sdhci_host *host, int dead); | |||
408 | extern int sdhci_suspend_host(struct sdhci_host *host, pm_message_t state); | 410 | extern int sdhci_suspend_host(struct sdhci_host *host, pm_message_t state); |
409 | extern int sdhci_resume_host(struct sdhci_host *host); | 411 | extern int sdhci_resume_host(struct sdhci_host *host); |
410 | #endif | 412 | #endif |
413 | |||
414 | #endif /* __SDHCI_H */ | ||
diff --git a/drivers/mtd/maps/pxa2xx-flash.c b/drivers/mtd/maps/pxa2xx-flash.c index 74fa075c838a..b13f6417b5b2 100644 --- a/drivers/mtd/maps/pxa2xx-flash.c +++ b/drivers/mtd/maps/pxa2xx-flash.c | |||
@@ -20,14 +20,23 @@ | |||
20 | 20 | ||
21 | #include <asm/io.h> | 21 | #include <asm/io.h> |
22 | #include <mach/hardware.h> | 22 | #include <mach/hardware.h> |
23 | #include <asm/cacheflush.h> | ||
24 | 23 | ||
25 | #include <asm/mach/flash.h> | 24 | #include <asm/mach/flash.h> |
26 | 25 | ||
26 | #define CACHELINESIZE 32 | ||
27 | |||
27 | static void pxa2xx_map_inval_cache(struct map_info *map, unsigned long from, | 28 | static void pxa2xx_map_inval_cache(struct map_info *map, unsigned long from, |
28 | ssize_t len) | 29 | ssize_t len) |
29 | { | 30 | { |
30 | flush_ioremap_region(map->phys, map->cached, from, len); | 31 | unsigned long start = (unsigned long)map->cached + from; |
32 | unsigned long end = start + len; | ||
33 | |||
34 | start &= ~(CACHELINESIZE - 1); | ||
35 | while (start < end) { | ||
36 | /* invalidate D cache line */ | ||
37 | asm volatile ("mcr p15, 0, %0, c7, c6, 1" : : "r" (start)); | ||
38 | start += CACHELINESIZE; | ||
39 | } | ||
31 | } | 40 | } |
32 | 41 | ||
33 | struct pxa2xx_flash_info { | 42 | struct pxa2xx_flash_info { |
diff --git a/drivers/pcmcia/pxa2xx_base.c b/drivers/pcmcia/pxa2xx_base.c index 3aabf1e37988..76e640bccde8 100644 --- a/drivers/pcmcia/pxa2xx_base.c +++ b/drivers/pcmcia/pxa2xx_base.c | |||
@@ -291,7 +291,7 @@ static int pxa2xx_drv_pcmcia_probe(struct platform_device *dev) | |||
291 | skt->nr = ops->first + i; | 291 | skt->nr = ops->first + i; |
292 | skt->ops = ops; | 292 | skt->ops = ops; |
293 | skt->socket.owner = ops->owner; | 293 | skt->socket.owner = ops->owner; |
294 | skt->socket.dev.parent = dev; | 294 | skt->socket.dev.parent = &dev->dev; |
295 | skt->socket.pci_irq = NO_IRQ; | 295 | skt->socket.pci_irq = NO_IRQ; |
296 | 296 | ||
297 | ret = pxa2xx_drv_pcmcia_add_one(skt); | 297 | ret = pxa2xx_drv_pcmcia_add_one(skt); |
@@ -304,8 +304,8 @@ static int pxa2xx_drv_pcmcia_probe(struct platform_device *dev) | |||
304 | soc_pcmcia_remove_one(&sinfo->skt[i]); | 304 | soc_pcmcia_remove_one(&sinfo->skt[i]); |
305 | kfree(sinfo); | 305 | kfree(sinfo); |
306 | } else { | 306 | } else { |
307 | pxa2xx_configure_sockets(dev); | 307 | pxa2xx_configure_sockets(&dev->dev); |
308 | dev_set_drvdata(dev, sinfo); | 308 | dev_set_drvdata(&dev->dev, sinfo); |
309 | } | 309 | } |
310 | 310 | ||
311 | return ret; | 311 | return ret; |
diff --git a/drivers/rtc/rtc-ds1305.c b/drivers/rtc/rtc-ds1305.c index 259db7f3535b..9630e7d3314e 100644 --- a/drivers/rtc/rtc-ds1305.c +++ b/drivers/rtc/rtc-ds1305.c | |||
@@ -778,6 +778,8 @@ static int __devinit ds1305_probe(struct spi_device *spi) | |||
778 | spi->irq, status); | 778 | spi->irq, status); |
779 | goto fail1; | 779 | goto fail1; |
780 | } | 780 | } |
781 | |||
782 | device_set_wakeup_capable(&spi->dev, 1); | ||
781 | } | 783 | } |
782 | 784 | ||
783 | /* export NVRAM */ | 785 | /* export NVRAM */ |
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index 8a99da6f2f24..c4ec5c158aa1 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c | |||
@@ -881,6 +881,8 @@ read_rtc: | |||
881 | "unable to request IRQ!\n"); | 881 | "unable to request IRQ!\n"); |
882 | goto exit_irq; | 882 | goto exit_irq; |
883 | } | 883 | } |
884 | |||
885 | device_set_wakeup_capable(&client->dev, 1); | ||
884 | set_bit(HAS_ALARM, &ds1307->flags); | 886 | set_bit(HAS_ALARM, &ds1307->flags); |
885 | dev_dbg(&client->dev, "got IRQ %d\n", client->irq); | 887 | dev_dbg(&client->dev, "got IRQ %d\n", client->irq); |
886 | } | 888 | } |
diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c index 713f7bf5afb3..5317bbcbc7a0 100644 --- a/drivers/rtc/rtc-ds1374.c +++ b/drivers/rtc/rtc-ds1374.c | |||
@@ -383,6 +383,8 @@ static int ds1374_probe(struct i2c_client *client, | |||
383 | dev_err(&client->dev, "unable to request IRQ\n"); | 383 | dev_err(&client->dev, "unable to request IRQ\n"); |
384 | goto out_free; | 384 | goto out_free; |
385 | } | 385 | } |
386 | |||
387 | device_set_wakeup_capable(&client->dev, 1); | ||
386 | } | 388 | } |
387 | 389 | ||
388 | ds1374->rtc = rtc_device_register(client->name, &client->dev, | 390 | ds1374->rtc = rtc_device_register(client->name, &client->dev, |
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig index 2d9d70359360..f55eb0107336 100644 --- a/drivers/spi/Kconfig +++ b/drivers/spi/Kconfig | |||
@@ -216,6 +216,17 @@ config SPI_S3C24XX | |||
216 | help | 216 | help |
217 | SPI driver for Samsung S3C24XX series ARM SoCs | 217 | SPI driver for Samsung S3C24XX series ARM SoCs |
218 | 218 | ||
219 | config SPI_S3C24XX_FIQ | ||
220 | bool "S3C24XX driver with FIQ pseudo-DMA" | ||
221 | depends on SPI_S3C24XX | ||
222 | select FIQ | ||
223 | help | ||
224 | Enable FIQ support for the S3C24XX SPI driver to provide pseudo | ||
225 | DMA by using the fast-interrupt request framework, This allows | ||
226 | the driver to get DMA-like performance when there are either | ||
227 | no free DMA channels, or when doing transfers that required both | ||
228 | TX and RX data paths. | ||
229 | |||
219 | config SPI_S3C24XX_GPIO | 230 | config SPI_S3C24XX_GPIO |
220 | tristate "Samsung S3C24XX series SPI by GPIO" | 231 | tristate "Samsung S3C24XX series SPI by GPIO" |
221 | depends on ARCH_S3C2410 && EXPERIMENTAL | 232 | depends on ARCH_S3C2410 && EXPERIMENTAL |
@@ -226,6 +237,13 @@ config SPI_S3C24XX_GPIO | |||
226 | the inbuilt hardware cannot provide the transfer mode, or | 237 | the inbuilt hardware cannot provide the transfer mode, or |
227 | where the board is using non hardware connected pins. | 238 | where the board is using non hardware connected pins. |
228 | 239 | ||
240 | config SPI_S3C64XX | ||
241 | tristate "Samsung S3C64XX series type SPI" | ||
242 | depends on ARCH_S3C64XX && EXPERIMENTAL | ||
243 | select S3C64XX_DMA | ||
244 | help | ||
245 | SPI driver for Samsung S3C64XX and newer SoCs. | ||
246 | |||
229 | config SPI_SH_MSIOF | 247 | config SPI_SH_MSIOF |
230 | tristate "SuperH MSIOF SPI controller" | 248 | tristate "SuperH MSIOF SPI controller" |
231 | depends on SUPERH && HAVE_CLK | 249 | depends on SUPERH && HAVE_CLK |
@@ -289,6 +307,16 @@ config SPI_NUC900 | |||
289 | # Add new SPI master controllers in alphabetical order above this line | 307 | # Add new SPI master controllers in alphabetical order above this line |
290 | # | 308 | # |
291 | 309 | ||
310 | config SPI_DESIGNWARE | ||
311 | bool "DesignWare SPI controller core support" | ||
312 | depends on SPI_MASTER | ||
313 | help | ||
314 | general driver for SPI controller core from DesignWare | ||
315 | |||
316 | config SPI_DW_PCI | ||
317 | tristate "PCI interface driver for DW SPI core" | ||
318 | depends on SPI_DESIGNWARE && PCI | ||
319 | |||
292 | # | 320 | # |
293 | # There are lots of SPI device types, with sensors and memory | 321 | # There are lots of SPI device types, with sensors and memory |
294 | # being probably the most widely used ones. | 322 | # being probably the most widely used ones. |
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile index ed8c1675b52f..f3d2810ba11c 100644 --- a/drivers/spi/Makefile +++ b/drivers/spi/Makefile | |||
@@ -16,6 +16,8 @@ obj-$(CONFIG_SPI_BFIN) += spi_bfin5xx.o | |||
16 | obj-$(CONFIG_SPI_BITBANG) += spi_bitbang.o | 16 | obj-$(CONFIG_SPI_BITBANG) += spi_bitbang.o |
17 | obj-$(CONFIG_SPI_AU1550) += au1550_spi.o | 17 | obj-$(CONFIG_SPI_AU1550) += au1550_spi.o |
18 | obj-$(CONFIG_SPI_BUTTERFLY) += spi_butterfly.o | 18 | obj-$(CONFIG_SPI_BUTTERFLY) += spi_butterfly.o |
19 | obj-$(CONFIG_SPI_DESIGNWARE) += dw_spi.o | ||
20 | obj-$(CONFIG_SPI_DW_PCI) += dw_spi_pci.o | ||
19 | obj-$(CONFIG_SPI_GPIO) += spi_gpio.o | 21 | obj-$(CONFIG_SPI_GPIO) += spi_gpio.o |
20 | obj-$(CONFIG_SPI_IMX) += spi_imx.o | 22 | obj-$(CONFIG_SPI_IMX) += spi_imx.o |
21 | obj-$(CONFIG_SPI_LM70_LLP) += spi_lm70llp.o | 23 | obj-$(CONFIG_SPI_LM70_LLP) += spi_lm70llp.o |
@@ -30,7 +32,8 @@ obj-$(CONFIG_SPI_MPC52xx) += mpc52xx_spi.o | |||
30 | obj-$(CONFIG_SPI_MPC8xxx) += spi_mpc8xxx.o | 32 | obj-$(CONFIG_SPI_MPC8xxx) += spi_mpc8xxx.o |
31 | obj-$(CONFIG_SPI_PPC4xx) += spi_ppc4xx.o | 33 | obj-$(CONFIG_SPI_PPC4xx) += spi_ppc4xx.o |
32 | obj-$(CONFIG_SPI_S3C24XX_GPIO) += spi_s3c24xx_gpio.o | 34 | obj-$(CONFIG_SPI_S3C24XX_GPIO) += spi_s3c24xx_gpio.o |
33 | obj-$(CONFIG_SPI_S3C24XX) += spi_s3c24xx.o | 35 | obj-$(CONFIG_SPI_S3C24XX) += spi_s3c24xx_hw.o |
36 | obj-$(CONFIG_SPI_S3C64XX) += spi_s3c64xx.o | ||
34 | obj-$(CONFIG_SPI_TXX9) += spi_txx9.o | 37 | obj-$(CONFIG_SPI_TXX9) += spi_txx9.o |
35 | obj-$(CONFIG_SPI_XILINX) += xilinx_spi.o | 38 | obj-$(CONFIG_SPI_XILINX) += xilinx_spi.o |
36 | obj-$(CONFIG_SPI_XILINX_OF) += xilinx_spi_of.o | 39 | obj-$(CONFIG_SPI_XILINX_OF) += xilinx_spi_of.o |
@@ -39,6 +42,11 @@ obj-$(CONFIG_SPI_SH_SCI) += spi_sh_sci.o | |||
39 | obj-$(CONFIG_SPI_SH_MSIOF) += spi_sh_msiof.o | 42 | obj-$(CONFIG_SPI_SH_MSIOF) += spi_sh_msiof.o |
40 | obj-$(CONFIG_SPI_STMP3XXX) += spi_stmp.o | 43 | obj-$(CONFIG_SPI_STMP3XXX) += spi_stmp.o |
41 | obj-$(CONFIG_SPI_NUC900) += spi_nuc900.o | 44 | obj-$(CONFIG_SPI_NUC900) += spi_nuc900.o |
45 | |||
46 | # special build for s3c24xx spi driver with fiq support | ||
47 | spi_s3c24xx_hw-y := spi_s3c24xx.o | ||
48 | spi_s3c24xx_hw-$(CONFIG_SPI_S3C24XX_FIQ) += spi_s3c24xx_fiq.o | ||
49 | |||
42 | # ... add above this line ... | 50 | # ... add above this line ... |
43 | 51 | ||
44 | # SPI protocol drivers (device/link on bus) | 52 | # SPI protocol drivers (device/link on bus) |
diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c index f5b3fdbb1e27..d21c24eaf0a9 100644 --- a/drivers/spi/atmel_spi.c +++ b/drivers/spi/atmel_spi.c | |||
@@ -189,14 +189,14 @@ static void atmel_spi_next_xfer_data(struct spi_master *master, | |||
189 | 189 | ||
190 | /* use scratch buffer only when rx or tx data is unspecified */ | 190 | /* use scratch buffer only when rx or tx data is unspecified */ |
191 | if (xfer->rx_buf) | 191 | if (xfer->rx_buf) |
192 | *rx_dma = xfer->rx_dma + xfer->len - len; | 192 | *rx_dma = xfer->rx_dma + xfer->len - *plen; |
193 | else { | 193 | else { |
194 | *rx_dma = as->buffer_dma; | 194 | *rx_dma = as->buffer_dma; |
195 | if (len > BUFFER_SIZE) | 195 | if (len > BUFFER_SIZE) |
196 | len = BUFFER_SIZE; | 196 | len = BUFFER_SIZE; |
197 | } | 197 | } |
198 | if (xfer->tx_buf) | 198 | if (xfer->tx_buf) |
199 | *tx_dma = xfer->tx_dma + xfer->len - len; | 199 | *tx_dma = xfer->tx_dma + xfer->len - *plen; |
200 | else { | 200 | else { |
201 | *tx_dma = as->buffer_dma; | 201 | *tx_dma = as->buffer_dma; |
202 | if (len > BUFFER_SIZE) | 202 | if (len > BUFFER_SIZE) |
@@ -788,7 +788,7 @@ static int __init atmel_spi_probe(struct platform_device *pdev) | |||
788 | spin_lock_init(&as->lock); | 788 | spin_lock_init(&as->lock); |
789 | INIT_LIST_HEAD(&as->queue); | 789 | INIT_LIST_HEAD(&as->queue); |
790 | as->pdev = pdev; | 790 | as->pdev = pdev; |
791 | as->regs = ioremap(regs->start, (regs->end - regs->start) + 1); | 791 | as->regs = ioremap(regs->start, resource_size(regs)); |
792 | if (!as->regs) | 792 | if (!as->regs) |
793 | goto out_free_buffer; | 793 | goto out_free_buffer; |
794 | as->irq = irq; | 794 | as->irq = irq; |
diff --git a/drivers/spi/dw_spi.c b/drivers/spi/dw_spi.c new file mode 100644 index 000000000000..31620fae77be --- /dev/null +++ b/drivers/spi/dw_spi.c | |||
@@ -0,0 +1,944 @@ | |||
1 | /* | ||
2 | * dw_spi.c - Designware SPI core controller driver (refer pxa2xx_spi.c) | ||
3 | * | ||
4 | * Copyright (c) 2009, Intel Corporation. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms and conditions of the GNU General Public License, | ||
8 | * version 2, as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
13 | * more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License along with | ||
16 | * this program; if not, write to the Free Software Foundation, Inc., | ||
17 | * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | */ | ||
19 | |||
20 | #include <linux/dma-mapping.h> | ||
21 | #include <linux/interrupt.h> | ||
22 | #include <linux/highmem.h> | ||
23 | #include <linux/delay.h> | ||
24 | |||
25 | #include <linux/spi/dw_spi.h> | ||
26 | #include <linux/spi/spi.h> | ||
27 | |||
28 | #ifdef CONFIG_DEBUG_FS | ||
29 | #include <linux/debugfs.h> | ||
30 | #endif | ||
31 | |||
32 | #define START_STATE ((void *)0) | ||
33 | #define RUNNING_STATE ((void *)1) | ||
34 | #define DONE_STATE ((void *)2) | ||
35 | #define ERROR_STATE ((void *)-1) | ||
36 | |||
37 | #define QUEUE_RUNNING 0 | ||
38 | #define QUEUE_STOPPED 1 | ||
39 | |||
40 | #define MRST_SPI_DEASSERT 0 | ||
41 | #define MRST_SPI_ASSERT 1 | ||
42 | |||
43 | /* Slave spi_dev related */ | ||
44 | struct chip_data { | ||
45 | u16 cr0; | ||
46 | u8 cs; /* chip select pin */ | ||
47 | u8 n_bytes; /* current is a 1/2/4 byte op */ | ||
48 | u8 tmode; /* TR/TO/RO/EEPROM */ | ||
49 | u8 type; /* SPI/SSP/MicroWire */ | ||
50 | |||
51 | u8 poll_mode; /* 1 means use poll mode */ | ||
52 | |||
53 | u32 dma_width; | ||
54 | u32 rx_threshold; | ||
55 | u32 tx_threshold; | ||
56 | u8 enable_dma; | ||
57 | u8 bits_per_word; | ||
58 | u16 clk_div; /* baud rate divider */ | ||
59 | u32 speed_hz; /* baud rate */ | ||
60 | int (*write)(struct dw_spi *dws); | ||
61 | int (*read)(struct dw_spi *dws); | ||
62 | void (*cs_control)(u32 command); | ||
63 | }; | ||
64 | |||
65 | #ifdef CONFIG_DEBUG_FS | ||
66 | static int spi_show_regs_open(struct inode *inode, struct file *file) | ||
67 | { | ||
68 | file->private_data = inode->i_private; | ||
69 | return 0; | ||
70 | } | ||
71 | |||
72 | #define SPI_REGS_BUFSIZE 1024 | ||
73 | static ssize_t spi_show_regs(struct file *file, char __user *user_buf, | ||
74 | size_t count, loff_t *ppos) | ||
75 | { | ||
76 | struct dw_spi *dws; | ||
77 | char *buf; | ||
78 | u32 len = 0; | ||
79 | ssize_t ret; | ||
80 | |||
81 | dws = file->private_data; | ||
82 | |||
83 | buf = kzalloc(SPI_REGS_BUFSIZE, GFP_KERNEL); | ||
84 | if (!buf) | ||
85 | return 0; | ||
86 | |||
87 | len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, | ||
88 | "MRST SPI0 registers:\n"); | ||
89 | len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, | ||
90 | "=================================\n"); | ||
91 | len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, | ||
92 | "CTRL0: \t\t0x%08x\n", dw_readl(dws, ctrl0)); | ||
93 | len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, | ||
94 | "CTRL1: \t\t0x%08x\n", dw_readl(dws, ctrl1)); | ||
95 | len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, | ||
96 | "SSIENR: \t0x%08x\n", dw_readl(dws, ssienr)); | ||
97 | len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, | ||
98 | "SER: \t\t0x%08x\n", dw_readl(dws, ser)); | ||
99 | len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, | ||
100 | "BAUDR: \t\t0x%08x\n", dw_readl(dws, baudr)); | ||
101 | len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, | ||
102 | "TXFTLR: \t0x%08x\n", dw_readl(dws, txfltr)); | ||
103 | len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, | ||
104 | "RXFTLR: \t0x%08x\n", dw_readl(dws, rxfltr)); | ||
105 | len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, | ||
106 | "TXFLR: \t\t0x%08x\n", dw_readl(dws, txflr)); | ||
107 | len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, | ||
108 | "RXFLR: \t\t0x%08x\n", dw_readl(dws, rxflr)); | ||
109 | len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, | ||
110 | "SR: \t\t0x%08x\n", dw_readl(dws, sr)); | ||
111 | len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, | ||
112 | "IMR: \t\t0x%08x\n", dw_readl(dws, imr)); | ||
113 | len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, | ||
114 | "ISR: \t\t0x%08x\n", dw_readl(dws, isr)); | ||
115 | len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, | ||
116 | "DMACR: \t\t0x%08x\n", dw_readl(dws, dmacr)); | ||
117 | len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, | ||
118 | "DMATDLR: \t0x%08x\n", dw_readl(dws, dmatdlr)); | ||
119 | len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, | ||
120 | "DMARDLR: \t0x%08x\n", dw_readl(dws, dmardlr)); | ||
121 | len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, | ||
122 | "=================================\n"); | ||
123 | |||
124 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, len); | ||
125 | kfree(buf); | ||
126 | return ret; | ||
127 | } | ||
128 | |||
129 | static const struct file_operations mrst_spi_regs_ops = { | ||
130 | .owner = THIS_MODULE, | ||
131 | .open = spi_show_regs_open, | ||
132 | .read = spi_show_regs, | ||
133 | }; | ||
134 | |||
135 | static int mrst_spi_debugfs_init(struct dw_spi *dws) | ||
136 | { | ||
137 | dws->debugfs = debugfs_create_dir("mrst_spi", NULL); | ||
138 | if (!dws->debugfs) | ||
139 | return -ENOMEM; | ||
140 | |||
141 | debugfs_create_file("registers", S_IFREG | S_IRUGO, | ||
142 | dws->debugfs, (void *)dws, &mrst_spi_regs_ops); | ||
143 | return 0; | ||
144 | } | ||
145 | |||
146 | static void mrst_spi_debugfs_remove(struct dw_spi *dws) | ||
147 | { | ||
148 | if (dws->debugfs) | ||
149 | debugfs_remove_recursive(dws->debugfs); | ||
150 | } | ||
151 | |||
152 | #else | ||
153 | static inline int mrst_spi_debugfs_init(struct dw_spi *dws) | ||
154 | { | ||
155 | } | ||
156 | |||
157 | static inline void mrst_spi_debugfs_remove(struct dw_spi *dws) | ||
158 | { | ||
159 | } | ||
160 | #endif /* CONFIG_DEBUG_FS */ | ||
161 | |||
162 | static void wait_till_not_busy(struct dw_spi *dws) | ||
163 | { | ||
164 | unsigned long end = jiffies + usecs_to_jiffies(1000); | ||
165 | |||
166 | while (time_before(jiffies, end)) { | ||
167 | if (!(dw_readw(dws, sr) & SR_BUSY)) | ||
168 | return; | ||
169 | } | ||
170 | dev_err(&dws->master->dev, | ||
171 | "DW SPI: Stutus keeps busy for 1000us after a read/write!\n"); | ||
172 | } | ||
173 | |||
174 | static void flush(struct dw_spi *dws) | ||
175 | { | ||
176 | while (dw_readw(dws, sr) & SR_RF_NOT_EMPT) | ||
177 | dw_readw(dws, dr); | ||
178 | |||
179 | wait_till_not_busy(dws); | ||
180 | } | ||
181 | |||
182 | static void null_cs_control(u32 command) | ||
183 | { | ||
184 | } | ||
185 | |||
186 | static int null_writer(struct dw_spi *dws) | ||
187 | { | ||
188 | u8 n_bytes = dws->n_bytes; | ||
189 | |||
190 | if (!(dw_readw(dws, sr) & SR_TF_NOT_FULL) | ||
191 | || (dws->tx == dws->tx_end)) | ||
192 | return 0; | ||
193 | dw_writew(dws, dr, 0); | ||
194 | dws->tx += n_bytes; | ||
195 | |||
196 | wait_till_not_busy(dws); | ||
197 | return 1; | ||
198 | } | ||
199 | |||
200 | static int null_reader(struct dw_spi *dws) | ||
201 | { | ||
202 | u8 n_bytes = dws->n_bytes; | ||
203 | |||
204 | while ((dw_readw(dws, sr) & SR_RF_NOT_EMPT) | ||
205 | && (dws->rx < dws->rx_end)) { | ||
206 | dw_readw(dws, dr); | ||
207 | dws->rx += n_bytes; | ||
208 | } | ||
209 | wait_till_not_busy(dws); | ||
210 | return dws->rx == dws->rx_end; | ||
211 | } | ||
212 | |||
213 | static int u8_writer(struct dw_spi *dws) | ||
214 | { | ||
215 | if (!(dw_readw(dws, sr) & SR_TF_NOT_FULL) | ||
216 | || (dws->tx == dws->tx_end)) | ||
217 | return 0; | ||
218 | |||
219 | dw_writew(dws, dr, *(u8 *)(dws->tx)); | ||
220 | ++dws->tx; | ||
221 | |||
222 | wait_till_not_busy(dws); | ||
223 | return 1; | ||
224 | } | ||
225 | |||
226 | static int u8_reader(struct dw_spi *dws) | ||
227 | { | ||
228 | while ((dw_readw(dws, sr) & SR_RF_NOT_EMPT) | ||
229 | && (dws->rx < dws->rx_end)) { | ||
230 | *(u8 *)(dws->rx) = dw_readw(dws, dr); | ||
231 | ++dws->rx; | ||
232 | } | ||
233 | |||
234 | wait_till_not_busy(dws); | ||
235 | return dws->rx == dws->rx_end; | ||
236 | } | ||
237 | |||
238 | static int u16_writer(struct dw_spi *dws) | ||
239 | { | ||
240 | if (!(dw_readw(dws, sr) & SR_TF_NOT_FULL) | ||
241 | || (dws->tx == dws->tx_end)) | ||
242 | return 0; | ||
243 | |||
244 | dw_writew(dws, dr, *(u16 *)(dws->tx)); | ||
245 | dws->tx += 2; | ||
246 | |||
247 | wait_till_not_busy(dws); | ||
248 | return 1; | ||
249 | } | ||
250 | |||
251 | static int u16_reader(struct dw_spi *dws) | ||
252 | { | ||
253 | u16 temp; | ||
254 | |||
255 | while ((dw_readw(dws, sr) & SR_RF_NOT_EMPT) | ||
256 | && (dws->rx < dws->rx_end)) { | ||
257 | temp = dw_readw(dws, dr); | ||
258 | *(u16 *)(dws->rx) = temp; | ||
259 | dws->rx += 2; | ||
260 | } | ||
261 | |||
262 | wait_till_not_busy(dws); | ||
263 | return dws->rx == dws->rx_end; | ||
264 | } | ||
265 | |||
266 | static void *next_transfer(struct dw_spi *dws) | ||
267 | { | ||
268 | struct spi_message *msg = dws->cur_msg; | ||
269 | struct spi_transfer *trans = dws->cur_transfer; | ||
270 | |||
271 | /* Move to next transfer */ | ||
272 | if (trans->transfer_list.next != &msg->transfers) { | ||
273 | dws->cur_transfer = | ||
274 | list_entry(trans->transfer_list.next, | ||
275 | struct spi_transfer, | ||
276 | transfer_list); | ||
277 | return RUNNING_STATE; | ||
278 | } else | ||
279 | return DONE_STATE; | ||
280 | } | ||
281 | |||
282 | /* | ||
283 | * Note: first step is the protocol driver prepares | ||
284 | * a dma-capable memory, and this func just need translate | ||
285 | * the virt addr to physical | ||
286 | */ | ||
287 | static int map_dma_buffers(struct dw_spi *dws) | ||
288 | { | ||
289 | if (!dws->cur_msg->is_dma_mapped || !dws->dma_inited | ||
290 | || !dws->cur_chip->enable_dma) | ||
291 | return 0; | ||
292 | |||
293 | if (dws->cur_transfer->tx_dma) | ||
294 | dws->tx_dma = dws->cur_transfer->tx_dma; | ||
295 | |||
296 | if (dws->cur_transfer->rx_dma) | ||
297 | dws->rx_dma = dws->cur_transfer->rx_dma; | ||
298 | |||
299 | return 1; | ||
300 | } | ||
301 | |||
302 | /* Caller already set message->status; dma and pio irqs are blocked */ | ||
303 | static void giveback(struct dw_spi *dws) | ||
304 | { | ||
305 | struct spi_transfer *last_transfer; | ||
306 | unsigned long flags; | ||
307 | struct spi_message *msg; | ||
308 | |||
309 | spin_lock_irqsave(&dws->lock, flags); | ||
310 | msg = dws->cur_msg; | ||
311 | dws->cur_msg = NULL; | ||
312 | dws->cur_transfer = NULL; | ||
313 | dws->prev_chip = dws->cur_chip; | ||
314 | dws->cur_chip = NULL; | ||
315 | dws->dma_mapped = 0; | ||
316 | queue_work(dws->workqueue, &dws->pump_messages); | ||
317 | spin_unlock_irqrestore(&dws->lock, flags); | ||
318 | |||
319 | last_transfer = list_entry(msg->transfers.prev, | ||
320 | struct spi_transfer, | ||
321 | transfer_list); | ||
322 | |||
323 | if (!last_transfer->cs_change) | ||
324 | dws->cs_control(MRST_SPI_DEASSERT); | ||
325 | |||
326 | msg->state = NULL; | ||
327 | if (msg->complete) | ||
328 | msg->complete(msg->context); | ||
329 | } | ||
330 | |||
331 | static void int_error_stop(struct dw_spi *dws, const char *msg) | ||
332 | { | ||
333 | /* Stop and reset hw */ | ||
334 | flush(dws); | ||
335 | spi_enable_chip(dws, 0); | ||
336 | |||
337 | dev_err(&dws->master->dev, "%s\n", msg); | ||
338 | dws->cur_msg->state = ERROR_STATE; | ||
339 | tasklet_schedule(&dws->pump_transfers); | ||
340 | } | ||
341 | |||
342 | static void transfer_complete(struct dw_spi *dws) | ||
343 | { | ||
344 | /* Update total byte transfered return count actual bytes read */ | ||
345 | dws->cur_msg->actual_length += dws->len; | ||
346 | |||
347 | /* Move to next transfer */ | ||
348 | dws->cur_msg->state = next_transfer(dws); | ||
349 | |||
350 | /* Handle end of message */ | ||
351 | if (dws->cur_msg->state == DONE_STATE) { | ||
352 | dws->cur_msg->status = 0; | ||
353 | giveback(dws); | ||
354 | } else | ||
355 | tasklet_schedule(&dws->pump_transfers); | ||
356 | } | ||
357 | |||
358 | static irqreturn_t interrupt_transfer(struct dw_spi *dws) | ||
359 | { | ||
360 | u16 irq_status, irq_mask = 0x3f; | ||
361 | |||
362 | irq_status = dw_readw(dws, isr) & irq_mask; | ||
363 | /* Error handling */ | ||
364 | if (irq_status & (SPI_INT_TXOI | SPI_INT_RXOI | SPI_INT_RXUI)) { | ||
365 | dw_readw(dws, txoicr); | ||
366 | dw_readw(dws, rxoicr); | ||
367 | dw_readw(dws, rxuicr); | ||
368 | int_error_stop(dws, "interrupt_transfer: fifo overrun"); | ||
369 | return IRQ_HANDLED; | ||
370 | } | ||
371 | |||
372 | /* INT comes from tx */ | ||
373 | if (dws->tx && (irq_status & SPI_INT_TXEI)) { | ||
374 | while (dws->tx < dws->tx_end) | ||
375 | dws->write(dws); | ||
376 | |||
377 | if (dws->tx == dws->tx_end) { | ||
378 | spi_mask_intr(dws, SPI_INT_TXEI); | ||
379 | transfer_complete(dws); | ||
380 | } | ||
381 | } | ||
382 | |||
383 | /* INT comes from rx */ | ||
384 | if (dws->rx && (irq_status & SPI_INT_RXFI)) { | ||
385 | if (dws->read(dws)) | ||
386 | transfer_complete(dws); | ||
387 | } | ||
388 | return IRQ_HANDLED; | ||
389 | } | ||
390 | |||
391 | static irqreturn_t dw_spi_irq(int irq, void *dev_id) | ||
392 | { | ||
393 | struct dw_spi *dws = dev_id; | ||
394 | |||
395 | if (!dws->cur_msg) { | ||
396 | spi_mask_intr(dws, SPI_INT_TXEI); | ||
397 | /* Never fail */ | ||
398 | return IRQ_HANDLED; | ||
399 | } | ||
400 | |||
401 | return dws->transfer_handler(dws); | ||
402 | } | ||
403 | |||
404 | /* Must be called inside pump_transfers() */ | ||
405 | static void poll_transfer(struct dw_spi *dws) | ||
406 | { | ||
407 | if (dws->tx) { | ||
408 | while (dws->write(dws)) | ||
409 | dws->read(dws); | ||
410 | } | ||
411 | |||
412 | dws->read(dws); | ||
413 | transfer_complete(dws); | ||
414 | } | ||
415 | |||
416 | static void dma_transfer(struct dw_spi *dws, int cs_change) | ||
417 | { | ||
418 | } | ||
419 | |||
420 | static void pump_transfers(unsigned long data) | ||
421 | { | ||
422 | struct dw_spi *dws = (struct dw_spi *)data; | ||
423 | struct spi_message *message = NULL; | ||
424 | struct spi_transfer *transfer = NULL; | ||
425 | struct spi_transfer *previous = NULL; | ||
426 | struct spi_device *spi = NULL; | ||
427 | struct chip_data *chip = NULL; | ||
428 | u8 bits = 0; | ||
429 | u8 imask = 0; | ||
430 | u8 cs_change = 0; | ||
431 | u16 clk_div = 0; | ||
432 | u32 speed = 0; | ||
433 | u32 cr0 = 0; | ||
434 | |||
435 | /* Get current state information */ | ||
436 | message = dws->cur_msg; | ||
437 | transfer = dws->cur_transfer; | ||
438 | chip = dws->cur_chip; | ||
439 | spi = message->spi; | ||
440 | |||
441 | if (message->state == ERROR_STATE) { | ||
442 | message->status = -EIO; | ||
443 | goto early_exit; | ||
444 | } | ||
445 | |||
446 | /* Handle end of message */ | ||
447 | if (message->state == DONE_STATE) { | ||
448 | message->status = 0; | ||
449 | goto early_exit; | ||
450 | } | ||
451 | |||
452 | /* Delay if requested at end of transfer*/ | ||
453 | if (message->state == RUNNING_STATE) { | ||
454 | previous = list_entry(transfer->transfer_list.prev, | ||
455 | struct spi_transfer, | ||
456 | transfer_list); | ||
457 | if (previous->delay_usecs) | ||
458 | udelay(previous->delay_usecs); | ||
459 | } | ||
460 | |||
461 | dws->n_bytes = chip->n_bytes; | ||
462 | dws->dma_width = chip->dma_width; | ||
463 | dws->cs_control = chip->cs_control; | ||
464 | |||
465 | dws->rx_dma = transfer->rx_dma; | ||
466 | dws->tx_dma = transfer->tx_dma; | ||
467 | dws->tx = (void *)transfer->tx_buf; | ||
468 | dws->tx_end = dws->tx + transfer->len; | ||
469 | dws->rx = transfer->rx_buf; | ||
470 | dws->rx_end = dws->rx + transfer->len; | ||
471 | dws->write = dws->tx ? chip->write : null_writer; | ||
472 | dws->read = dws->rx ? chip->read : null_reader; | ||
473 | dws->cs_change = transfer->cs_change; | ||
474 | dws->len = dws->cur_transfer->len; | ||
475 | if (chip != dws->prev_chip) | ||
476 | cs_change = 1; | ||
477 | |||
478 | cr0 = chip->cr0; | ||
479 | |||
480 | /* Handle per transfer options for bpw and speed */ | ||
481 | if (transfer->speed_hz) { | ||
482 | speed = chip->speed_hz; | ||
483 | |||
484 | if (transfer->speed_hz != speed) { | ||
485 | speed = transfer->speed_hz; | ||
486 | if (speed > dws->max_freq) { | ||
487 | printk(KERN_ERR "MRST SPI0: unsupported" | ||
488 | "freq: %dHz\n", speed); | ||
489 | message->status = -EIO; | ||
490 | goto early_exit; | ||
491 | } | ||
492 | |||
493 | /* clk_div doesn't support odd number */ | ||
494 | clk_div = dws->max_freq / speed; | ||
495 | clk_div = (clk_div >> 1) << 1; | ||
496 | |||
497 | chip->speed_hz = speed; | ||
498 | chip->clk_div = clk_div; | ||
499 | } | ||
500 | } | ||
501 | if (transfer->bits_per_word) { | ||
502 | bits = transfer->bits_per_word; | ||
503 | |||
504 | switch (bits) { | ||
505 | case 8: | ||
506 | dws->n_bytes = 1; | ||
507 | dws->dma_width = 1; | ||
508 | dws->read = (dws->read != null_reader) ? | ||
509 | u8_reader : null_reader; | ||
510 | dws->write = (dws->write != null_writer) ? | ||
511 | u8_writer : null_writer; | ||
512 | break; | ||
513 | case 16: | ||
514 | dws->n_bytes = 2; | ||
515 | dws->dma_width = 2; | ||
516 | dws->read = (dws->read != null_reader) ? | ||
517 | u16_reader : null_reader; | ||
518 | dws->write = (dws->write != null_writer) ? | ||
519 | u16_writer : null_writer; | ||
520 | break; | ||
521 | default: | ||
522 | printk(KERN_ERR "MRST SPI0: unsupported bits:" | ||
523 | "%db\n", bits); | ||
524 | message->status = -EIO; | ||
525 | goto early_exit; | ||
526 | } | ||
527 | |||
528 | cr0 = (bits - 1) | ||
529 | | (chip->type << SPI_FRF_OFFSET) | ||
530 | | (spi->mode << SPI_MODE_OFFSET) | ||
531 | | (chip->tmode << SPI_TMOD_OFFSET); | ||
532 | } | ||
533 | message->state = RUNNING_STATE; | ||
534 | |||
535 | /* Check if current transfer is a DMA transaction */ | ||
536 | dws->dma_mapped = map_dma_buffers(dws); | ||
537 | |||
538 | if (!dws->dma_mapped && !chip->poll_mode) { | ||
539 | if (dws->rx) | ||
540 | imask |= SPI_INT_RXFI; | ||
541 | if (dws->tx) | ||
542 | imask |= SPI_INT_TXEI; | ||
543 | dws->transfer_handler = interrupt_transfer; | ||
544 | } | ||
545 | |||
546 | /* | ||
547 | * Reprogram registers only if | ||
548 | * 1. chip select changes | ||
549 | * 2. clk_div is changed | ||
550 | * 3. control value changes | ||
551 | */ | ||
552 | if (dw_readw(dws, ctrl0) != cr0 || cs_change || clk_div) { | ||
553 | spi_enable_chip(dws, 0); | ||
554 | |||
555 | if (dw_readw(dws, ctrl0) != cr0) | ||
556 | dw_writew(dws, ctrl0, cr0); | ||
557 | |||
558 | /* Set the interrupt mask, for poll mode just diable all int */ | ||
559 | spi_mask_intr(dws, 0xff); | ||
560 | if (!chip->poll_mode) | ||
561 | spi_umask_intr(dws, imask); | ||
562 | |||
563 | spi_set_clk(dws, clk_div ? clk_div : chip->clk_div); | ||
564 | spi_chip_sel(dws, spi->chip_select); | ||
565 | spi_enable_chip(dws, 1); | ||
566 | |||
567 | if (cs_change) | ||
568 | dws->prev_chip = chip; | ||
569 | } | ||
570 | |||
571 | if (dws->dma_mapped) | ||
572 | dma_transfer(dws, cs_change); | ||
573 | |||
574 | if (chip->poll_mode) | ||
575 | poll_transfer(dws); | ||
576 | |||
577 | return; | ||
578 | |||
579 | early_exit: | ||
580 | giveback(dws); | ||
581 | return; | ||
582 | } | ||
583 | |||
584 | static void pump_messages(struct work_struct *work) | ||
585 | { | ||
586 | struct dw_spi *dws = | ||
587 | container_of(work, struct dw_spi, pump_messages); | ||
588 | unsigned long flags; | ||
589 | |||
590 | /* Lock queue and check for queue work */ | ||
591 | spin_lock_irqsave(&dws->lock, flags); | ||
592 | if (list_empty(&dws->queue) || dws->run == QUEUE_STOPPED) { | ||
593 | dws->busy = 0; | ||
594 | spin_unlock_irqrestore(&dws->lock, flags); | ||
595 | return; | ||
596 | } | ||
597 | |||
598 | /* Make sure we are not already running a message */ | ||
599 | if (dws->cur_msg) { | ||
600 | spin_unlock_irqrestore(&dws->lock, flags); | ||
601 | return; | ||
602 | } | ||
603 | |||
604 | /* Extract head of queue */ | ||
605 | dws->cur_msg = list_entry(dws->queue.next, struct spi_message, queue); | ||
606 | list_del_init(&dws->cur_msg->queue); | ||
607 | |||
608 | /* Initial message state*/ | ||
609 | dws->cur_msg->state = START_STATE; | ||
610 | dws->cur_transfer = list_entry(dws->cur_msg->transfers.next, | ||
611 | struct spi_transfer, | ||
612 | transfer_list); | ||
613 | dws->cur_chip = spi_get_ctldata(dws->cur_msg->spi); | ||
614 | |||
615 | /* Mark as busy and launch transfers */ | ||
616 | tasklet_schedule(&dws->pump_transfers); | ||
617 | |||
618 | dws->busy = 1; | ||
619 | spin_unlock_irqrestore(&dws->lock, flags); | ||
620 | } | ||
621 | |||
622 | /* spi_device use this to queue in their spi_msg */ | ||
623 | static int dw_spi_transfer(struct spi_device *spi, struct spi_message *msg) | ||
624 | { | ||
625 | struct dw_spi *dws = spi_master_get_devdata(spi->master); | ||
626 | unsigned long flags; | ||
627 | |||
628 | spin_lock_irqsave(&dws->lock, flags); | ||
629 | |||
630 | if (dws->run == QUEUE_STOPPED) { | ||
631 | spin_unlock_irqrestore(&dws->lock, flags); | ||
632 | return -ESHUTDOWN; | ||
633 | } | ||
634 | |||
635 | msg->actual_length = 0; | ||
636 | msg->status = -EINPROGRESS; | ||
637 | msg->state = START_STATE; | ||
638 | |||
639 | list_add_tail(&msg->queue, &dws->queue); | ||
640 | |||
641 | if (dws->run == QUEUE_RUNNING && !dws->busy) { | ||
642 | |||
643 | if (dws->cur_transfer || dws->cur_msg) | ||
644 | queue_work(dws->workqueue, | ||
645 | &dws->pump_messages); | ||
646 | else { | ||
647 | /* If no other data transaction in air, just go */ | ||
648 | spin_unlock_irqrestore(&dws->lock, flags); | ||
649 | pump_messages(&dws->pump_messages); | ||
650 | return 0; | ||
651 | } | ||
652 | } | ||
653 | |||
654 | spin_unlock_irqrestore(&dws->lock, flags); | ||
655 | return 0; | ||
656 | } | ||
657 | |||
658 | /* This may be called twice for each spi dev */ | ||
659 | static int dw_spi_setup(struct spi_device *spi) | ||
660 | { | ||
661 | struct dw_spi_chip *chip_info = NULL; | ||
662 | struct chip_data *chip; | ||
663 | |||
664 | if (spi->bits_per_word != 8 && spi->bits_per_word != 16) | ||
665 | return -EINVAL; | ||
666 | |||
667 | /* Only alloc on first setup */ | ||
668 | chip = spi_get_ctldata(spi); | ||
669 | if (!chip) { | ||
670 | chip = kzalloc(sizeof(struct chip_data), GFP_KERNEL); | ||
671 | if (!chip) | ||
672 | return -ENOMEM; | ||
673 | |||
674 | chip->cs_control = null_cs_control; | ||
675 | chip->enable_dma = 0; | ||
676 | } | ||
677 | |||
678 | /* | ||
679 | * Protocol drivers may change the chip settings, so... | ||
680 | * if chip_info exists, use it | ||
681 | */ | ||
682 | chip_info = spi->controller_data; | ||
683 | |||
684 | /* chip_info doesn't always exist */ | ||
685 | if (chip_info) { | ||
686 | if (chip_info->cs_control) | ||
687 | chip->cs_control = chip_info->cs_control; | ||
688 | |||
689 | chip->poll_mode = chip_info->poll_mode; | ||
690 | chip->type = chip_info->type; | ||
691 | |||
692 | chip->rx_threshold = 0; | ||
693 | chip->tx_threshold = 0; | ||
694 | |||
695 | chip->enable_dma = chip_info->enable_dma; | ||
696 | } | ||
697 | |||
698 | if (spi->bits_per_word <= 8) { | ||
699 | chip->n_bytes = 1; | ||
700 | chip->dma_width = 1; | ||
701 | chip->read = u8_reader; | ||
702 | chip->write = u8_writer; | ||
703 | } else if (spi->bits_per_word <= 16) { | ||
704 | chip->n_bytes = 2; | ||
705 | chip->dma_width = 2; | ||
706 | chip->read = u16_reader; | ||
707 | chip->write = u16_writer; | ||
708 | } else { | ||
709 | /* Never take >16b case for MRST SPIC */ | ||
710 | dev_err(&spi->dev, "invalid wordsize\n"); | ||
711 | return -EINVAL; | ||
712 | } | ||
713 | chip->bits_per_word = spi->bits_per_word; | ||
714 | |||
715 | chip->speed_hz = spi->max_speed_hz; | ||
716 | if (chip->speed_hz) | ||
717 | chip->clk_div = 25000000 / chip->speed_hz; | ||
718 | else | ||
719 | chip->clk_div = 8; /* default value */ | ||
720 | |||
721 | chip->tmode = 0; /* Tx & Rx */ | ||
722 | /* Default SPI mode is SCPOL = 0, SCPH = 0 */ | ||
723 | chip->cr0 = (chip->bits_per_word - 1) | ||
724 | | (chip->type << SPI_FRF_OFFSET) | ||
725 | | (spi->mode << SPI_MODE_OFFSET) | ||
726 | | (chip->tmode << SPI_TMOD_OFFSET); | ||
727 | |||
728 | spi_set_ctldata(spi, chip); | ||
729 | return 0; | ||
730 | } | ||
731 | |||
732 | static void dw_spi_cleanup(struct spi_device *spi) | ||
733 | { | ||
734 | struct chip_data *chip = spi_get_ctldata(spi); | ||
735 | kfree(chip); | ||
736 | } | ||
737 | |||
738 | static int __init init_queue(struct dw_spi *dws) | ||
739 | { | ||
740 | INIT_LIST_HEAD(&dws->queue); | ||
741 | spin_lock_init(&dws->lock); | ||
742 | |||
743 | dws->run = QUEUE_STOPPED; | ||
744 | dws->busy = 0; | ||
745 | |||
746 | tasklet_init(&dws->pump_transfers, | ||
747 | pump_transfers, (unsigned long)dws); | ||
748 | |||
749 | INIT_WORK(&dws->pump_messages, pump_messages); | ||
750 | dws->workqueue = create_singlethread_workqueue( | ||
751 | dev_name(dws->master->dev.parent)); | ||
752 | if (dws->workqueue == NULL) | ||
753 | return -EBUSY; | ||
754 | |||
755 | return 0; | ||
756 | } | ||
757 | |||
758 | static int start_queue(struct dw_spi *dws) | ||
759 | { | ||
760 | unsigned long flags; | ||
761 | |||
762 | spin_lock_irqsave(&dws->lock, flags); | ||
763 | |||
764 | if (dws->run == QUEUE_RUNNING || dws->busy) { | ||
765 | spin_unlock_irqrestore(&dws->lock, flags); | ||
766 | return -EBUSY; | ||
767 | } | ||
768 | |||
769 | dws->run = QUEUE_RUNNING; | ||
770 | dws->cur_msg = NULL; | ||
771 | dws->cur_transfer = NULL; | ||
772 | dws->cur_chip = NULL; | ||
773 | dws->prev_chip = NULL; | ||
774 | spin_unlock_irqrestore(&dws->lock, flags); | ||
775 | |||
776 | queue_work(dws->workqueue, &dws->pump_messages); | ||
777 | |||
778 | return 0; | ||
779 | } | ||
780 | |||
781 | static int stop_queue(struct dw_spi *dws) | ||
782 | { | ||
783 | unsigned long flags; | ||
784 | unsigned limit = 50; | ||
785 | int status = 0; | ||
786 | |||
787 | spin_lock_irqsave(&dws->lock, flags); | ||
788 | dws->run = QUEUE_STOPPED; | ||
789 | while (!list_empty(&dws->queue) && dws->busy && limit--) { | ||
790 | spin_unlock_irqrestore(&dws->lock, flags); | ||
791 | msleep(10); | ||
792 | spin_lock_irqsave(&dws->lock, flags); | ||
793 | } | ||
794 | |||
795 | if (!list_empty(&dws->queue) || dws->busy) | ||
796 | status = -EBUSY; | ||
797 | spin_unlock_irqrestore(&dws->lock, flags); | ||
798 | |||
799 | return status; | ||
800 | } | ||
801 | |||
802 | static int destroy_queue(struct dw_spi *dws) | ||
803 | { | ||
804 | int status; | ||
805 | |||
806 | status = stop_queue(dws); | ||
807 | if (status != 0) | ||
808 | return status; | ||
809 | destroy_workqueue(dws->workqueue); | ||
810 | return 0; | ||
811 | } | ||
812 | |||
813 | /* Restart the controller, disable all interrupts, clean rx fifo */ | ||
814 | static void spi_hw_init(struct dw_spi *dws) | ||
815 | { | ||
816 | spi_enable_chip(dws, 0); | ||
817 | spi_mask_intr(dws, 0xff); | ||
818 | spi_enable_chip(dws, 1); | ||
819 | flush(dws); | ||
820 | } | ||
821 | |||
822 | int __devinit dw_spi_add_host(struct dw_spi *dws) | ||
823 | { | ||
824 | struct spi_master *master; | ||
825 | int ret; | ||
826 | |||
827 | BUG_ON(dws == NULL); | ||
828 | |||
829 | master = spi_alloc_master(dws->parent_dev, 0); | ||
830 | if (!master) { | ||
831 | ret = -ENOMEM; | ||
832 | goto exit; | ||
833 | } | ||
834 | |||
835 | dws->master = master; | ||
836 | dws->type = SSI_MOTO_SPI; | ||
837 | dws->prev_chip = NULL; | ||
838 | dws->dma_inited = 0; | ||
839 | dws->dma_addr = (dma_addr_t)(dws->paddr + 0x60); | ||
840 | |||
841 | ret = request_irq(dws->irq, dw_spi_irq, 0, | ||
842 | "dw_spi", dws); | ||
843 | if (ret < 0) { | ||
844 | dev_err(&master->dev, "can not get IRQ\n"); | ||
845 | goto err_free_master; | ||
846 | } | ||
847 | |||
848 | master->mode_bits = SPI_CPOL | SPI_CPHA; | ||
849 | master->bus_num = dws->bus_num; | ||
850 | master->num_chipselect = dws->num_cs; | ||
851 | master->cleanup = dw_spi_cleanup; | ||
852 | master->setup = dw_spi_setup; | ||
853 | master->transfer = dw_spi_transfer; | ||
854 | |||
855 | dws->dma_inited = 0; | ||
856 | |||
857 | /* Basic HW init */ | ||
858 | spi_hw_init(dws); | ||
859 | |||
860 | /* Initial and start queue */ | ||
861 | ret = init_queue(dws); | ||
862 | if (ret) { | ||
863 | dev_err(&master->dev, "problem initializing queue\n"); | ||
864 | goto err_diable_hw; | ||
865 | } | ||
866 | ret = start_queue(dws); | ||
867 | if (ret) { | ||
868 | dev_err(&master->dev, "problem starting queue\n"); | ||
869 | goto err_diable_hw; | ||
870 | } | ||
871 | |||
872 | spi_master_set_devdata(master, dws); | ||
873 | ret = spi_register_master(master); | ||
874 | if (ret) { | ||
875 | dev_err(&master->dev, "problem registering spi master\n"); | ||
876 | goto err_queue_alloc; | ||
877 | } | ||
878 | |||
879 | mrst_spi_debugfs_init(dws); | ||
880 | return 0; | ||
881 | |||
882 | err_queue_alloc: | ||
883 | destroy_queue(dws); | ||
884 | err_diable_hw: | ||
885 | spi_enable_chip(dws, 0); | ||
886 | free_irq(dws->irq, dws); | ||
887 | err_free_master: | ||
888 | spi_master_put(master); | ||
889 | exit: | ||
890 | return ret; | ||
891 | } | ||
892 | EXPORT_SYMBOL(dw_spi_add_host); | ||
893 | |||
894 | void __devexit dw_spi_remove_host(struct dw_spi *dws) | ||
895 | { | ||
896 | int status = 0; | ||
897 | |||
898 | if (!dws) | ||
899 | return; | ||
900 | mrst_spi_debugfs_remove(dws); | ||
901 | |||
902 | /* Remove the queue */ | ||
903 | status = destroy_queue(dws); | ||
904 | if (status != 0) | ||
905 | dev_err(&dws->master->dev, "dw_spi_remove: workqueue will not " | ||
906 | "complete, message memory not freed\n"); | ||
907 | |||
908 | spi_enable_chip(dws, 0); | ||
909 | /* Disable clk */ | ||
910 | spi_set_clk(dws, 0); | ||
911 | free_irq(dws->irq, dws); | ||
912 | |||
913 | /* Disconnect from the SPI framework */ | ||
914 | spi_unregister_master(dws->master); | ||
915 | } | ||
916 | |||
917 | int dw_spi_suspend_host(struct dw_spi *dws) | ||
918 | { | ||
919 | int ret = 0; | ||
920 | |||
921 | ret = stop_queue(dws); | ||
922 | if (ret) | ||
923 | return ret; | ||
924 | spi_enable_chip(dws, 0); | ||
925 | spi_set_clk(dws, 0); | ||
926 | return ret; | ||
927 | } | ||
928 | EXPORT_SYMBOL(dw_spi_suspend_host); | ||
929 | |||
930 | int dw_spi_resume_host(struct dw_spi *dws) | ||
931 | { | ||
932 | int ret; | ||
933 | |||
934 | spi_hw_init(dws); | ||
935 | ret = start_queue(dws); | ||
936 | if (ret) | ||
937 | dev_err(&dws->master->dev, "fail to start queue (%d)\n", ret); | ||
938 | return ret; | ||
939 | } | ||
940 | EXPORT_SYMBOL(dw_spi_resume_host); | ||
941 | |||
942 | MODULE_AUTHOR("Feng Tang <feng.tang@intel.com>"); | ||
943 | MODULE_DESCRIPTION("Driver for DesignWare SPI controller core"); | ||
944 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/spi/dw_spi_pci.c b/drivers/spi/dw_spi_pci.c new file mode 100644 index 000000000000..34ba69161734 --- /dev/null +++ b/drivers/spi/dw_spi_pci.c | |||
@@ -0,0 +1,169 @@ | |||
1 | /* | ||
2 | * mrst_spi_pci.c - PCI interface driver for DW SPI Core | ||
3 | * | ||
4 | * Copyright (c) 2009, Intel Corporation. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms and conditions of the GNU General Public License, | ||
8 | * version 2, as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
13 | * more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License along | ||
16 | * with this program; if not, write to the Free Software Foundation, | ||
17 | * Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | */ | ||
19 | |||
20 | #include <linux/interrupt.h> | ||
21 | #include <linux/pci.h> | ||
22 | #include <linux/spi/dw_spi.h> | ||
23 | #include <linux/spi/spi.h> | ||
24 | |||
25 | #define DRIVER_NAME "dw_spi_pci" | ||
26 | |||
27 | struct dw_spi_pci { | ||
28 | struct pci_dev *pdev; | ||
29 | struct dw_spi dws; | ||
30 | }; | ||
31 | |||
32 | static int __devinit spi_pci_probe(struct pci_dev *pdev, | ||
33 | const struct pci_device_id *ent) | ||
34 | { | ||
35 | struct dw_spi_pci *dwpci; | ||
36 | struct dw_spi *dws; | ||
37 | int pci_bar = 0; | ||
38 | int ret; | ||
39 | |||
40 | printk(KERN_INFO "DW: found PCI SPI controller(ID: %04x:%04x)\n", | ||
41 | pdev->vendor, pdev->device); | ||
42 | |||
43 | ret = pci_enable_device(pdev); | ||
44 | if (ret) | ||
45 | return ret; | ||
46 | |||
47 | dwpci = kzalloc(sizeof(struct dw_spi_pci), GFP_KERNEL); | ||
48 | if (!dwpci) { | ||
49 | ret = -ENOMEM; | ||
50 | goto err_disable; | ||
51 | } | ||
52 | |||
53 | dwpci->pdev = pdev; | ||
54 | dws = &dwpci->dws; | ||
55 | |||
56 | /* Get basic io resource and map it */ | ||
57 | dws->paddr = pci_resource_start(pdev, pci_bar); | ||
58 | dws->iolen = pci_resource_len(pdev, pci_bar); | ||
59 | |||
60 | ret = pci_request_region(pdev, pci_bar, dev_name(&pdev->dev)); | ||
61 | if (ret) | ||
62 | goto err_kfree; | ||
63 | |||
64 | dws->regs = ioremap_nocache((unsigned long)dws->paddr, | ||
65 | pci_resource_len(pdev, pci_bar)); | ||
66 | if (!dws->regs) { | ||
67 | ret = -ENOMEM; | ||
68 | goto err_release_reg; | ||
69 | } | ||
70 | |||
71 | dws->parent_dev = &pdev->dev; | ||
72 | dws->bus_num = 0; | ||
73 | dws->num_cs = 4; | ||
74 | dws->max_freq = 25000000; /* for Moorestwon */ | ||
75 | dws->irq = pdev->irq; | ||
76 | |||
77 | ret = dw_spi_add_host(dws); | ||
78 | if (ret) | ||
79 | goto err_unmap; | ||
80 | |||
81 | /* PCI hook and SPI hook use the same drv data */ | ||
82 | pci_set_drvdata(pdev, dwpci); | ||
83 | return 0; | ||
84 | |||
85 | err_unmap: | ||
86 | iounmap(dws->regs); | ||
87 | err_release_reg: | ||
88 | pci_release_region(pdev, pci_bar); | ||
89 | err_kfree: | ||
90 | kfree(dwpci); | ||
91 | err_disable: | ||
92 | pci_disable_device(pdev); | ||
93 | return ret; | ||
94 | } | ||
95 | |||
96 | static void __devexit spi_pci_remove(struct pci_dev *pdev) | ||
97 | { | ||
98 | struct dw_spi_pci *dwpci = pci_get_drvdata(pdev); | ||
99 | |||
100 | pci_set_drvdata(pdev, NULL); | ||
101 | iounmap(dwpci->dws.regs); | ||
102 | pci_release_region(pdev, 0); | ||
103 | kfree(dwpci); | ||
104 | pci_disable_device(pdev); | ||
105 | } | ||
106 | |||
107 | #ifdef CONFIG_PM | ||
108 | static int spi_suspend(struct pci_dev *pdev, pm_message_t state) | ||
109 | { | ||
110 | struct dw_spi_pci *dwpci = pci_get_drvdata(pdev); | ||
111 | int ret; | ||
112 | |||
113 | ret = dw_spi_suspend_host(&dwpci->dws); | ||
114 | if (ret) | ||
115 | return ret; | ||
116 | pci_save_state(pdev); | ||
117 | pci_disable_device(pdev); | ||
118 | pci_set_power_state(pdev, pci_choose_state(pdev, state)); | ||
119 | return ret; | ||
120 | } | ||
121 | |||
122 | static int spi_resume(struct pci_dev *pdev) | ||
123 | { | ||
124 | struct dw_spi_pci *dwpci = pci_get_drvdata(pdev); | ||
125 | int ret; | ||
126 | |||
127 | pci_set_power_state(pdev, PCI_D0); | ||
128 | pci_restore_state(pdev); | ||
129 | ret = pci_enable_device(pdev); | ||
130 | if (ret) | ||
131 | return ret; | ||
132 | return dw_spi_resume_host(&dwpci->dws); | ||
133 | } | ||
134 | #else | ||
135 | #define spi_suspend NULL | ||
136 | #define spi_resume NULL | ||
137 | #endif | ||
138 | |||
139 | static const struct pci_device_id pci_ids[] __devinitdata = { | ||
140 | /* Intel Moorestown platform SPI controller 0 */ | ||
141 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0800) }, | ||
142 | {}, | ||
143 | }; | ||
144 | |||
145 | static struct pci_driver dw_spi_driver = { | ||
146 | .name = DRIVER_NAME, | ||
147 | .id_table = pci_ids, | ||
148 | .probe = spi_pci_probe, | ||
149 | .remove = __devexit_p(spi_pci_remove), | ||
150 | .suspend = spi_suspend, | ||
151 | .resume = spi_resume, | ||
152 | }; | ||
153 | |||
154 | static int __init mrst_spi_init(void) | ||
155 | { | ||
156 | return pci_register_driver(&dw_spi_driver); | ||
157 | } | ||
158 | |||
159 | static void __exit mrst_spi_exit(void) | ||
160 | { | ||
161 | pci_unregister_driver(&dw_spi_driver); | ||
162 | } | ||
163 | |||
164 | module_init(mrst_spi_init); | ||
165 | module_exit(mrst_spi_exit); | ||
166 | |||
167 | MODULE_AUTHOR("Feng Tang <feng.tang@intel.com>"); | ||
168 | MODULE_DESCRIPTION("PCI interface driver for DW SPI Core"); | ||
169 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/spi/spi_bfin5xx.c b/drivers/spi/spi_bfin5xx.c index 73e24ef5a2f9..1d41058bbab2 100644 --- a/drivers/spi/spi_bfin5xx.c +++ b/drivers/spi/spi_bfin5xx.c | |||
@@ -1294,7 +1294,7 @@ static int __init bfin_spi_probe(struct platform_device *pdev) | |||
1294 | goto out_error_get_res; | 1294 | goto out_error_get_res; |
1295 | } | 1295 | } |
1296 | 1296 | ||
1297 | drv_data->regs_base = ioremap(res->start, (res->end - res->start + 1)); | 1297 | drv_data->regs_base = ioremap(res->start, resource_size(res)); |
1298 | if (drv_data->regs_base == NULL) { | 1298 | if (drv_data->regs_base == NULL) { |
1299 | dev_err(dev, "Cannot map IO\n"); | 1299 | dev_err(dev, "Cannot map IO\n"); |
1300 | status = -ENXIO; | 1300 | status = -ENXIO; |
diff --git a/drivers/spi/spi_mpc8xxx.c b/drivers/spi/spi_mpc8xxx.c index e9390d747bfc..1fb2a6ea328c 100644 --- a/drivers/spi/spi_mpc8xxx.c +++ b/drivers/spi/spi_mpc8xxx.c | |||
@@ -1013,7 +1013,7 @@ mpc8xxx_spi_probe(struct device *dev, struct resource *mem, unsigned int irq) | |||
1013 | 1013 | ||
1014 | init_completion(&mpc8xxx_spi->done); | 1014 | init_completion(&mpc8xxx_spi->done); |
1015 | 1015 | ||
1016 | mpc8xxx_spi->base = ioremap(mem->start, mem->end - mem->start + 1); | 1016 | mpc8xxx_spi->base = ioremap(mem->start, resource_size(mem)); |
1017 | if (mpc8xxx_spi->base == NULL) { | 1017 | if (mpc8xxx_spi->base == NULL) { |
1018 | ret = -ENOMEM; | 1018 | ret = -ENOMEM; |
1019 | goto err_ioremap; | 1019 | goto err_ioremap; |
diff --git a/drivers/spi/spi_s3c24xx.c b/drivers/spi/spi_s3c24xx.c index 276591569c8b..c010733877ae 100644 --- a/drivers/spi/spi_s3c24xx.c +++ b/drivers/spi/spi_s3c24xx.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* linux/drivers/spi/spi_s3c24xx.c | 1 | /* linux/drivers/spi/spi_s3c24xx.c |
2 | * | 2 | * |
3 | * Copyright (c) 2006 Ben Dooks | 3 | * Copyright (c) 2006 Ben Dooks |
4 | * Copyright (c) 2006 Simtec Electronics | 4 | * Copyright 2006-2009 Simtec Electronics |
5 | * Ben Dooks <ben@simtec.co.uk> | 5 | * Ben Dooks <ben@simtec.co.uk> |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or modify | 7 | * This program is free software; you can redistribute it and/or modify |
@@ -28,6 +28,11 @@ | |||
28 | #include <plat/regs-spi.h> | 28 | #include <plat/regs-spi.h> |
29 | #include <mach/spi.h> | 29 | #include <mach/spi.h> |
30 | 30 | ||
31 | #include <plat/fiq.h> | ||
32 | #include <asm/fiq.h> | ||
33 | |||
34 | #include "spi_s3c24xx_fiq.h" | ||
35 | |||
31 | /** | 36 | /** |
32 | * s3c24xx_spi_devstate - per device data | 37 | * s3c24xx_spi_devstate - per device data |
33 | * @hz: Last frequency calculated for @sppre field. | 38 | * @hz: Last frequency calculated for @sppre field. |
@@ -42,6 +47,13 @@ struct s3c24xx_spi_devstate { | |||
42 | u8 sppre; | 47 | u8 sppre; |
43 | }; | 48 | }; |
44 | 49 | ||
50 | enum spi_fiq_mode { | ||
51 | FIQ_MODE_NONE = 0, | ||
52 | FIQ_MODE_TX = 1, | ||
53 | FIQ_MODE_RX = 2, | ||
54 | FIQ_MODE_TXRX = 3, | ||
55 | }; | ||
56 | |||
45 | struct s3c24xx_spi { | 57 | struct s3c24xx_spi { |
46 | /* bitbang has to be first */ | 58 | /* bitbang has to be first */ |
47 | struct spi_bitbang bitbang; | 59 | struct spi_bitbang bitbang; |
@@ -52,6 +64,11 @@ struct s3c24xx_spi { | |||
52 | int len; | 64 | int len; |
53 | int count; | 65 | int count; |
54 | 66 | ||
67 | struct fiq_handler fiq_handler; | ||
68 | enum spi_fiq_mode fiq_mode; | ||
69 | unsigned char fiq_inuse; | ||
70 | unsigned char fiq_claimed; | ||
71 | |||
55 | void (*set_cs)(struct s3c2410_spi_info *spi, | 72 | void (*set_cs)(struct s3c2410_spi_info *spi, |
56 | int cs, int pol); | 73 | int cs, int pol); |
57 | 74 | ||
@@ -67,6 +84,7 @@ struct s3c24xx_spi { | |||
67 | struct s3c2410_spi_info *pdata; | 84 | struct s3c2410_spi_info *pdata; |
68 | }; | 85 | }; |
69 | 86 | ||
87 | |||
70 | #define SPCON_DEFAULT (S3C2410_SPCON_MSTR | S3C2410_SPCON_SMOD_INT) | 88 | #define SPCON_DEFAULT (S3C2410_SPCON_MSTR | S3C2410_SPCON_SMOD_INT) |
71 | #define SPPIN_DEFAULT (S3C2410_SPPIN_KEEP) | 89 | #define SPPIN_DEFAULT (S3C2410_SPPIN_KEEP) |
72 | 90 | ||
@@ -127,7 +145,7 @@ static int s3c24xx_spi_update_state(struct spi_device *spi, | |||
127 | } | 145 | } |
128 | 146 | ||
129 | if (spi->mode != cs->mode) { | 147 | if (spi->mode != cs->mode) { |
130 | u8 spcon = SPCON_DEFAULT; | 148 | u8 spcon = SPCON_DEFAULT | S3C2410_SPCON_ENSCK; |
131 | 149 | ||
132 | if (spi->mode & SPI_CPHA) | 150 | if (spi->mode & SPI_CPHA) |
133 | spcon |= S3C2410_SPCON_CPHA_FMTB; | 151 | spcon |= S3C2410_SPCON_CPHA_FMTB; |
@@ -214,13 +232,196 @@ static inline unsigned int hw_txbyte(struct s3c24xx_spi *hw, int count) | |||
214 | return hw->tx ? hw->tx[count] : 0; | 232 | return hw->tx ? hw->tx[count] : 0; |
215 | } | 233 | } |
216 | 234 | ||
235 | #ifdef CONFIG_SPI_S3C24XX_FIQ | ||
236 | /* Support for FIQ based pseudo-DMA to improve the transfer speed. | ||
237 | * | ||
238 | * This code uses the assembly helper in spi_s3c24xx_spi.S which is | ||
239 | * used by the FIQ core to move data between main memory and the peripheral | ||
240 | * block. Since this is code running on the processor, there is no problem | ||
241 | * with cache coherency of the buffers, so we can use any buffer we like. | ||
242 | */ | ||
243 | |||
244 | /** | ||
245 | * struct spi_fiq_code - FIQ code and header | ||
246 | * @length: The length of the code fragment, excluding this header. | ||
247 | * @ack_offset: The offset from @data to the word to place the IRQ ACK bit at. | ||
248 | * @data: The code itself to install as a FIQ handler. | ||
249 | */ | ||
250 | struct spi_fiq_code { | ||
251 | u32 length; | ||
252 | u32 ack_offset; | ||
253 | u8 data[0]; | ||
254 | }; | ||
255 | |||
256 | extern struct spi_fiq_code s3c24xx_spi_fiq_txrx; | ||
257 | extern struct spi_fiq_code s3c24xx_spi_fiq_tx; | ||
258 | extern struct spi_fiq_code s3c24xx_spi_fiq_rx; | ||
259 | |||
260 | /** | ||
261 | * ack_bit - turn IRQ into IRQ acknowledgement bit | ||
262 | * @irq: The interrupt number | ||
263 | * | ||
264 | * Returns the bit to write to the interrupt acknowledge register. | ||
265 | */ | ||
266 | static inline u32 ack_bit(unsigned int irq) | ||
267 | { | ||
268 | return 1 << (irq - IRQ_EINT0); | ||
269 | } | ||
270 | |||
271 | /** | ||
272 | * s3c24xx_spi_tryfiq - attempt to claim and setup FIQ for transfer | ||
273 | * @hw: The hardware state. | ||
274 | * | ||
275 | * Claim the FIQ handler (only one can be active at any one time) and | ||
276 | * then setup the correct transfer code for this transfer. | ||
277 | * | ||
278 | * This call updates all the necessary state information if sucessful, | ||
279 | * so the caller does not need to do anything more than start the transfer | ||
280 | * as normal, since the IRQ will have been re-routed to the FIQ handler. | ||
281 | */ | ||
282 | void s3c24xx_spi_tryfiq(struct s3c24xx_spi *hw) | ||
283 | { | ||
284 | struct pt_regs regs; | ||
285 | enum spi_fiq_mode mode; | ||
286 | struct spi_fiq_code *code; | ||
287 | int ret; | ||
288 | |||
289 | if (!hw->fiq_claimed) { | ||
290 | /* try and claim fiq if we haven't got it, and if not | ||
291 | * then return and simply use another transfer method */ | ||
292 | |||
293 | ret = claim_fiq(&hw->fiq_handler); | ||
294 | if (ret) | ||
295 | return; | ||
296 | } | ||
297 | |||
298 | if (hw->tx && !hw->rx) | ||
299 | mode = FIQ_MODE_TX; | ||
300 | else if (hw->rx && !hw->tx) | ||
301 | mode = FIQ_MODE_RX; | ||
302 | else | ||
303 | mode = FIQ_MODE_TXRX; | ||
304 | |||
305 | regs.uregs[fiq_rspi] = (long)hw->regs; | ||
306 | regs.uregs[fiq_rrx] = (long)hw->rx; | ||
307 | regs.uregs[fiq_rtx] = (long)hw->tx + 1; | ||
308 | regs.uregs[fiq_rcount] = hw->len - 1; | ||
309 | regs.uregs[fiq_rirq] = (long)S3C24XX_VA_IRQ; | ||
310 | |||
311 | set_fiq_regs(®s); | ||
312 | |||
313 | if (hw->fiq_mode != mode) { | ||
314 | u32 *ack_ptr; | ||
315 | |||
316 | hw->fiq_mode = mode; | ||
317 | |||
318 | switch (mode) { | ||
319 | case FIQ_MODE_TX: | ||
320 | code = &s3c24xx_spi_fiq_tx; | ||
321 | break; | ||
322 | case FIQ_MODE_RX: | ||
323 | code = &s3c24xx_spi_fiq_rx; | ||
324 | break; | ||
325 | case FIQ_MODE_TXRX: | ||
326 | code = &s3c24xx_spi_fiq_txrx; | ||
327 | break; | ||
328 | default: | ||
329 | code = NULL; | ||
330 | } | ||
331 | |||
332 | BUG_ON(!code); | ||
333 | |||
334 | ack_ptr = (u32 *)&code->data[code->ack_offset]; | ||
335 | *ack_ptr = ack_bit(hw->irq); | ||
336 | |||
337 | set_fiq_handler(&code->data, code->length); | ||
338 | } | ||
339 | |||
340 | s3c24xx_set_fiq(hw->irq, true); | ||
341 | |||
342 | hw->fiq_mode = mode; | ||
343 | hw->fiq_inuse = 1; | ||
344 | } | ||
345 | |||
346 | /** | ||
347 | * s3c24xx_spi_fiqop - FIQ core code callback | ||
348 | * @pw: Data registered with the handler | ||
349 | * @release: Whether this is a release or a return. | ||
350 | * | ||
351 | * Called by the FIQ code when another module wants to use the FIQ, so | ||
352 | * return whether we are currently using this or not and then update our | ||
353 | * internal state. | ||
354 | */ | ||
355 | static int s3c24xx_spi_fiqop(void *pw, int release) | ||
356 | { | ||
357 | struct s3c24xx_spi *hw = pw; | ||
358 | int ret = 0; | ||
359 | |||
360 | if (release) { | ||
361 | if (hw->fiq_inuse) | ||
362 | ret = -EBUSY; | ||
363 | |||
364 | /* note, we do not need to unroute the FIQ, as the FIQ | ||
365 | * vector code de-routes it to signal the end of transfer */ | ||
366 | |||
367 | hw->fiq_mode = FIQ_MODE_NONE; | ||
368 | hw->fiq_claimed = 0; | ||
369 | } else { | ||
370 | hw->fiq_claimed = 1; | ||
371 | } | ||
372 | |||
373 | return ret; | ||
374 | } | ||
375 | |||
376 | /** | ||
377 | * s3c24xx_spi_initfiq - setup the information for the FIQ core | ||
378 | * @hw: The hardware state. | ||
379 | * | ||
380 | * Setup the fiq_handler block to pass to the FIQ core. | ||
381 | */ | ||
382 | static inline void s3c24xx_spi_initfiq(struct s3c24xx_spi *hw) | ||
383 | { | ||
384 | hw->fiq_handler.dev_id = hw; | ||
385 | hw->fiq_handler.name = dev_name(hw->dev); | ||
386 | hw->fiq_handler.fiq_op = s3c24xx_spi_fiqop; | ||
387 | } | ||
388 | |||
389 | /** | ||
390 | * s3c24xx_spi_usefiq - return if we should be using FIQ. | ||
391 | * @hw: The hardware state. | ||
392 | * | ||
393 | * Return true if the platform data specifies whether this channel is | ||
394 | * allowed to use the FIQ. | ||
395 | */ | ||
396 | static inline bool s3c24xx_spi_usefiq(struct s3c24xx_spi *hw) | ||
397 | { | ||
398 | return hw->pdata->use_fiq; | ||
399 | } | ||
400 | |||
401 | /** | ||
402 | * s3c24xx_spi_usingfiq - return if channel is using FIQ | ||
403 | * @spi: The hardware state. | ||
404 | * | ||
405 | * Return whether the channel is currently using the FIQ (separate from | ||
406 | * whether the FIQ is claimed). | ||
407 | */ | ||
408 | static inline bool s3c24xx_spi_usingfiq(struct s3c24xx_spi *spi) | ||
409 | { | ||
410 | return spi->fiq_inuse; | ||
411 | } | ||
412 | #else | ||
413 | |||
414 | static inline void s3c24xx_spi_initfiq(struct s3c24xx_spi *s) { } | ||
415 | static inline void s3c24xx_spi_tryfiq(struct s3c24xx_spi *s) { } | ||
416 | static inline bool s3c24xx_spi_usefiq(struct s3c24xx_spi *s) { return false; } | ||
417 | static inline bool s3c24xx_spi_usingfiq(struct s3c24xx_spi *s) { return false; } | ||
418 | |||
419 | #endif /* CONFIG_SPI_S3C24XX_FIQ */ | ||
420 | |||
217 | static int s3c24xx_spi_txrx(struct spi_device *spi, struct spi_transfer *t) | 421 | static int s3c24xx_spi_txrx(struct spi_device *spi, struct spi_transfer *t) |
218 | { | 422 | { |
219 | struct s3c24xx_spi *hw = to_hw(spi); | 423 | struct s3c24xx_spi *hw = to_hw(spi); |
220 | 424 | ||
221 | dev_dbg(&spi->dev, "txrx: tx %p, rx %p, len %d\n", | ||
222 | t->tx_buf, t->rx_buf, t->len); | ||
223 | |||
224 | hw->tx = t->tx_buf; | 425 | hw->tx = t->tx_buf; |
225 | hw->rx = t->rx_buf; | 426 | hw->rx = t->rx_buf; |
226 | hw->len = t->len; | 427 | hw->len = t->len; |
@@ -228,11 +429,14 @@ static int s3c24xx_spi_txrx(struct spi_device *spi, struct spi_transfer *t) | |||
228 | 429 | ||
229 | init_completion(&hw->done); | 430 | init_completion(&hw->done); |
230 | 431 | ||
432 | hw->fiq_inuse = 0; | ||
433 | if (s3c24xx_spi_usefiq(hw) && t->len >= 3) | ||
434 | s3c24xx_spi_tryfiq(hw); | ||
435 | |||
231 | /* send the first byte */ | 436 | /* send the first byte */ |
232 | writeb(hw_txbyte(hw, 0), hw->regs + S3C2410_SPTDAT); | 437 | writeb(hw_txbyte(hw, 0), hw->regs + S3C2410_SPTDAT); |
233 | 438 | ||
234 | wait_for_completion(&hw->done); | 439 | wait_for_completion(&hw->done); |
235 | |||
236 | return hw->count; | 440 | return hw->count; |
237 | } | 441 | } |
238 | 442 | ||
@@ -254,17 +458,27 @@ static irqreturn_t s3c24xx_spi_irq(int irq, void *dev) | |||
254 | goto irq_done; | 458 | goto irq_done; |
255 | } | 459 | } |
256 | 460 | ||
257 | hw->count++; | 461 | if (!s3c24xx_spi_usingfiq(hw)) { |
462 | hw->count++; | ||
258 | 463 | ||
259 | if (hw->rx) | 464 | if (hw->rx) |
260 | hw->rx[count] = readb(hw->regs + S3C2410_SPRDAT); | 465 | hw->rx[count] = readb(hw->regs + S3C2410_SPRDAT); |
261 | 466 | ||
262 | count++; | 467 | count++; |
468 | |||
469 | if (count < hw->len) | ||
470 | writeb(hw_txbyte(hw, count), hw->regs + S3C2410_SPTDAT); | ||
471 | else | ||
472 | complete(&hw->done); | ||
473 | } else { | ||
474 | hw->count = hw->len; | ||
475 | hw->fiq_inuse = 0; | ||
476 | |||
477 | if (hw->rx) | ||
478 | hw->rx[hw->len-1] = readb(hw->regs + S3C2410_SPRDAT); | ||
263 | 479 | ||
264 | if (count < hw->len) | ||
265 | writeb(hw_txbyte(hw, count), hw->regs + S3C2410_SPTDAT); | ||
266 | else | ||
267 | complete(&hw->done); | 480 | complete(&hw->done); |
481 | } | ||
268 | 482 | ||
269 | irq_done: | 483 | irq_done: |
270 | return IRQ_HANDLED; | 484 | return IRQ_HANDLED; |
@@ -322,6 +536,10 @@ static int __init s3c24xx_spi_probe(struct platform_device *pdev) | |||
322 | platform_set_drvdata(pdev, hw); | 536 | platform_set_drvdata(pdev, hw); |
323 | init_completion(&hw->done); | 537 | init_completion(&hw->done); |
324 | 538 | ||
539 | /* initialise fiq handler */ | ||
540 | |||
541 | s3c24xx_spi_initfiq(hw); | ||
542 | |||
325 | /* setup the master state. */ | 543 | /* setup the master state. */ |
326 | 544 | ||
327 | /* the spi->mode bits understood by this driver: */ | 545 | /* the spi->mode bits understood by this driver: */ |
diff --git a/drivers/spi/spi_s3c24xx_fiq.S b/drivers/spi/spi_s3c24xx_fiq.S new file mode 100644 index 000000000000..3793cae361db --- /dev/null +++ b/drivers/spi/spi_s3c24xx_fiq.S | |||
@@ -0,0 +1,116 @@ | |||
1 | /* linux/drivers/spi/spi_s3c24xx_fiq.S | ||
2 | * | ||
3 | * Copyright 2009 Simtec Electronics | ||
4 | * Ben Dooks <ben@simtec.co.uk> | ||
5 | * | ||
6 | * S3C24XX SPI - FIQ pseudo-DMA transfer code | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | */ | ||
12 | |||
13 | #include <linux/linkage.h> | ||
14 | #include <asm/assembler.h> | ||
15 | |||
16 | #include <mach/map.h> | ||
17 | #include <mach/regs-irq.h> | ||
18 | #include <plat/regs-spi.h> | ||
19 | |||
20 | #include "spi_s3c24xx_fiq.h" | ||
21 | |||
22 | .text | ||
23 | |||
24 | @ entry to these routines is as follows, with the register names | ||
25 | @ defined in fiq.h so that they can be shared with the C files which | ||
26 | @ setup the calling registers. | ||
27 | @ | ||
28 | @ fiq_rirq The base of the IRQ registers to find S3C2410_SRCPND | ||
29 | @ fiq_rtmp Temporary register to hold tx/rx data | ||
30 | @ fiq_rspi The base of the SPI register block | ||
31 | @ fiq_rtx The tx buffer pointer | ||
32 | @ fiq_rrx The rx buffer pointer | ||
33 | @ fiq_rcount The number of bytes to move | ||
34 | |||
35 | @ each entry starts with a word entry of how long it is | ||
36 | @ and an offset to the irq acknowledgment word | ||
37 | |||
38 | ENTRY(s3c24xx_spi_fiq_rx) | ||
39 | s3c24xx_spi_fix_rx: | ||
40 | .word fiq_rx_end - fiq_rx_start | ||
41 | .word fiq_rx_irq_ack - fiq_rx_start | ||
42 | fiq_rx_start: | ||
43 | ldr fiq_rtmp, fiq_rx_irq_ack | ||
44 | str fiq_rtmp, [ fiq_rirq, # S3C2410_SRCPND - S3C24XX_VA_IRQ ] | ||
45 | |||
46 | ldrb fiq_rtmp, [ fiq_rspi, # S3C2410_SPRDAT ] | ||
47 | strb fiq_rtmp, [ fiq_rrx ], #1 | ||
48 | |||
49 | mov fiq_rtmp, #0xff | ||
50 | strb fiq_rtmp, [ fiq_rspi, # S3C2410_SPTDAT ] | ||
51 | |||
52 | subs fiq_rcount, fiq_rcount, #1 | ||
53 | subnes pc, lr, #4 @@ return, still have work to do | ||
54 | |||
55 | @@ set IRQ controller so that next op will trigger IRQ | ||
56 | mov fiq_rtmp, #0 | ||
57 | str fiq_rtmp, [ fiq_rirq, # S3C2410_INTMOD - S3C24XX_VA_IRQ ] | ||
58 | subs pc, lr, #4 | ||
59 | |||
60 | fiq_rx_irq_ack: | ||
61 | .word 0 | ||
62 | fiq_rx_end: | ||
63 | |||
64 | ENTRY(s3c24xx_spi_fiq_txrx) | ||
65 | s3c24xx_spi_fiq_txrx: | ||
66 | .word fiq_txrx_end - fiq_txrx_start | ||
67 | .word fiq_txrx_irq_ack - fiq_txrx_start | ||
68 | fiq_txrx_start: | ||
69 | |||
70 | ldrb fiq_rtmp, [ fiq_rspi, # S3C2410_SPRDAT ] | ||
71 | strb fiq_rtmp, [ fiq_rrx ], #1 | ||
72 | |||
73 | ldr fiq_rtmp, fiq_txrx_irq_ack | ||
74 | str fiq_rtmp, [ fiq_rirq, # S3C2410_SRCPND - S3C24XX_VA_IRQ ] | ||
75 | |||
76 | ldrb fiq_rtmp, [ fiq_rtx ], #1 | ||
77 | strb fiq_rtmp, [ fiq_rspi, # S3C2410_SPTDAT ] | ||
78 | |||
79 | subs fiq_rcount, fiq_rcount, #1 | ||
80 | subnes pc, lr, #4 @@ return, still have work to do | ||
81 | |||
82 | mov fiq_rtmp, #0 | ||
83 | str fiq_rtmp, [ fiq_rirq, # S3C2410_INTMOD - S3C24XX_VA_IRQ ] | ||
84 | subs pc, lr, #4 | ||
85 | |||
86 | fiq_txrx_irq_ack: | ||
87 | .word 0 | ||
88 | |||
89 | fiq_txrx_end: | ||
90 | |||
91 | ENTRY(s3c24xx_spi_fiq_tx) | ||
92 | s3c24xx_spi_fix_tx: | ||
93 | .word fiq_tx_end - fiq_tx_start | ||
94 | .word fiq_tx_irq_ack - fiq_tx_start | ||
95 | fiq_tx_start: | ||
96 | ldrb fiq_rtmp, [ fiq_rspi, # S3C2410_SPRDAT ] | ||
97 | |||
98 | ldr fiq_rtmp, fiq_tx_irq_ack | ||
99 | str fiq_rtmp, [ fiq_rirq, # S3C2410_SRCPND - S3C24XX_VA_IRQ ] | ||
100 | |||
101 | ldrb fiq_rtmp, [ fiq_rtx ], #1 | ||
102 | strb fiq_rtmp, [ fiq_rspi, # S3C2410_SPTDAT ] | ||
103 | |||
104 | subs fiq_rcount, fiq_rcount, #1 | ||
105 | subnes pc, lr, #4 @@ return, still have work to do | ||
106 | |||
107 | mov fiq_rtmp, #0 | ||
108 | str fiq_rtmp, [ fiq_rirq, # S3C2410_INTMOD - S3C24XX_VA_IRQ ] | ||
109 | subs pc, lr, #4 | ||
110 | |||
111 | fiq_tx_irq_ack: | ||
112 | .word 0 | ||
113 | |||
114 | fiq_tx_end: | ||
115 | |||
116 | .end | ||
diff --git a/drivers/spi/spi_s3c24xx_fiq.h b/drivers/spi/spi_s3c24xx_fiq.h new file mode 100644 index 000000000000..a5950bb25b51 --- /dev/null +++ b/drivers/spi/spi_s3c24xx_fiq.h | |||
@@ -0,0 +1,26 @@ | |||
1 | /* linux/drivers/spi/spi_s3c24xx_fiq.h | ||
2 | * | ||
3 | * Copyright 2009 Simtec Electronics | ||
4 | * Ben Dooks <ben@simtec.co.uk> | ||
5 | * | ||
6 | * S3C24XX SPI - FIQ pseudo-DMA transfer support | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | */ | ||
12 | |||
13 | /* We have R8 through R13 to play with */ | ||
14 | |||
15 | #ifdef __ASSEMBLY__ | ||
16 | #define __REG_NR(x) r##x | ||
17 | #else | ||
18 | #define __REG_NR(x) (x) | ||
19 | #endif | ||
20 | |||
21 | #define fiq_rspi __REG_NR(8) | ||
22 | #define fiq_rtmp __REG_NR(9) | ||
23 | #define fiq_rrx __REG_NR(10) | ||
24 | #define fiq_rtx __REG_NR(11) | ||
25 | #define fiq_rcount __REG_NR(12) | ||
26 | #define fiq_rirq __REG_NR(13) | ||
diff --git a/drivers/spi/spi_s3c64xx.c b/drivers/spi/spi_s3c64xx.c new file mode 100644 index 000000000000..88a456dba967 --- /dev/null +++ b/drivers/spi/spi_s3c64xx.c | |||
@@ -0,0 +1,1196 @@ | |||
1 | /* linux/drivers/spi/spi_s3c64xx.c | ||
2 | * | ||
3 | * Copyright (C) 2009 Samsung Electronics Ltd. | ||
4 | * Jaswinder Singh <jassi.brar@samsung.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
19 | */ | ||
20 | |||
21 | #include <linux/init.h> | ||
22 | #include <linux/module.h> | ||
23 | #include <linux/workqueue.h> | ||
24 | #include <linux/delay.h> | ||
25 | #include <linux/clk.h> | ||
26 | #include <linux/dma-mapping.h> | ||
27 | #include <linux/platform_device.h> | ||
28 | #include <linux/spi/spi.h> | ||
29 | |||
30 | #include <mach/dma.h> | ||
31 | #include <plat/spi.h> | ||
32 | |||
33 | /* Registers and bit-fields */ | ||
34 | |||
35 | #define S3C64XX_SPI_CH_CFG 0x00 | ||
36 | #define S3C64XX_SPI_CLK_CFG 0x04 | ||
37 | #define S3C64XX_SPI_MODE_CFG 0x08 | ||
38 | #define S3C64XX_SPI_SLAVE_SEL 0x0C | ||
39 | #define S3C64XX_SPI_INT_EN 0x10 | ||
40 | #define S3C64XX_SPI_STATUS 0x14 | ||
41 | #define S3C64XX_SPI_TX_DATA 0x18 | ||
42 | #define S3C64XX_SPI_RX_DATA 0x1C | ||
43 | #define S3C64XX_SPI_PACKET_CNT 0x20 | ||
44 | #define S3C64XX_SPI_PENDING_CLR 0x24 | ||
45 | #define S3C64XX_SPI_SWAP_CFG 0x28 | ||
46 | #define S3C64XX_SPI_FB_CLK 0x2C | ||
47 | |||
48 | #define S3C64XX_SPI_CH_HS_EN (1<<6) /* High Speed Enable */ | ||
49 | #define S3C64XX_SPI_CH_SW_RST (1<<5) | ||
50 | #define S3C64XX_SPI_CH_SLAVE (1<<4) | ||
51 | #define S3C64XX_SPI_CPOL_L (1<<3) | ||
52 | #define S3C64XX_SPI_CPHA_B (1<<2) | ||
53 | #define S3C64XX_SPI_CH_RXCH_ON (1<<1) | ||
54 | #define S3C64XX_SPI_CH_TXCH_ON (1<<0) | ||
55 | |||
56 | #define S3C64XX_SPI_CLKSEL_SRCMSK (3<<9) | ||
57 | #define S3C64XX_SPI_CLKSEL_SRCSHFT 9 | ||
58 | #define S3C64XX_SPI_ENCLK_ENABLE (1<<8) | ||
59 | #define S3C64XX_SPI_PSR_MASK 0xff | ||
60 | |||
61 | #define S3C64XX_SPI_MODE_CH_TSZ_BYTE (0<<29) | ||
62 | #define S3C64XX_SPI_MODE_CH_TSZ_HALFWORD (1<<29) | ||
63 | #define S3C64XX_SPI_MODE_CH_TSZ_WORD (2<<29) | ||
64 | #define S3C64XX_SPI_MODE_CH_TSZ_MASK (3<<29) | ||
65 | #define S3C64XX_SPI_MODE_BUS_TSZ_BYTE (0<<17) | ||
66 | #define S3C64XX_SPI_MODE_BUS_TSZ_HALFWORD (1<<17) | ||
67 | #define S3C64XX_SPI_MODE_BUS_TSZ_WORD (2<<17) | ||
68 | #define S3C64XX_SPI_MODE_BUS_TSZ_MASK (3<<17) | ||
69 | #define S3C64XX_SPI_MODE_RXDMA_ON (1<<2) | ||
70 | #define S3C64XX_SPI_MODE_TXDMA_ON (1<<1) | ||
71 | #define S3C64XX_SPI_MODE_4BURST (1<<0) | ||
72 | |||
73 | #define S3C64XX_SPI_SLAVE_AUTO (1<<1) | ||
74 | #define S3C64XX_SPI_SLAVE_SIG_INACT (1<<0) | ||
75 | |||
76 | #define S3C64XX_SPI_ACT(c) writel(0, (c)->regs + S3C64XX_SPI_SLAVE_SEL) | ||
77 | |||
78 | #define S3C64XX_SPI_DEACT(c) writel(S3C64XX_SPI_SLAVE_SIG_INACT, \ | ||
79 | (c)->regs + S3C64XX_SPI_SLAVE_SEL) | ||
80 | |||
81 | #define S3C64XX_SPI_INT_TRAILING_EN (1<<6) | ||
82 | #define S3C64XX_SPI_INT_RX_OVERRUN_EN (1<<5) | ||
83 | #define S3C64XX_SPI_INT_RX_UNDERRUN_EN (1<<4) | ||
84 | #define S3C64XX_SPI_INT_TX_OVERRUN_EN (1<<3) | ||
85 | #define S3C64XX_SPI_INT_TX_UNDERRUN_EN (1<<2) | ||
86 | #define S3C64XX_SPI_INT_RX_FIFORDY_EN (1<<1) | ||
87 | #define S3C64XX_SPI_INT_TX_FIFORDY_EN (1<<0) | ||
88 | |||
89 | #define S3C64XX_SPI_ST_RX_OVERRUN_ERR (1<<5) | ||
90 | #define S3C64XX_SPI_ST_RX_UNDERRUN_ERR (1<<4) | ||
91 | #define S3C64XX_SPI_ST_TX_OVERRUN_ERR (1<<3) | ||
92 | #define S3C64XX_SPI_ST_TX_UNDERRUN_ERR (1<<2) | ||
93 | #define S3C64XX_SPI_ST_RX_FIFORDY (1<<1) | ||
94 | #define S3C64XX_SPI_ST_TX_FIFORDY (1<<0) | ||
95 | |||
96 | #define S3C64XX_SPI_PACKET_CNT_EN (1<<16) | ||
97 | |||
98 | #define S3C64XX_SPI_PND_TX_UNDERRUN_CLR (1<<4) | ||
99 | #define S3C64XX_SPI_PND_TX_OVERRUN_CLR (1<<3) | ||
100 | #define S3C64XX_SPI_PND_RX_UNDERRUN_CLR (1<<2) | ||
101 | #define S3C64XX_SPI_PND_RX_OVERRUN_CLR (1<<1) | ||
102 | #define S3C64XX_SPI_PND_TRAILING_CLR (1<<0) | ||
103 | |||
104 | #define S3C64XX_SPI_SWAP_RX_HALF_WORD (1<<7) | ||
105 | #define S3C64XX_SPI_SWAP_RX_BYTE (1<<6) | ||
106 | #define S3C64XX_SPI_SWAP_RX_BIT (1<<5) | ||
107 | #define S3C64XX_SPI_SWAP_RX_EN (1<<4) | ||
108 | #define S3C64XX_SPI_SWAP_TX_HALF_WORD (1<<3) | ||
109 | #define S3C64XX_SPI_SWAP_TX_BYTE (1<<2) | ||
110 | #define S3C64XX_SPI_SWAP_TX_BIT (1<<1) | ||
111 | #define S3C64XX_SPI_SWAP_TX_EN (1<<0) | ||
112 | |||
113 | #define S3C64XX_SPI_FBCLK_MSK (3<<0) | ||
114 | |||
115 | #define S3C64XX_SPI_ST_TRLCNTZ(v, i) ((((v) >> (i)->rx_lvl_offset) & \ | ||
116 | (((i)->fifo_lvl_mask + 1))) \ | ||
117 | ? 1 : 0) | ||
118 | |||
119 | #define S3C64XX_SPI_ST_TX_DONE(v, i) ((((v) >> (i)->rx_lvl_offset) & \ | ||
120 | (((i)->fifo_lvl_mask + 1) << 1)) \ | ||
121 | ? 1 : 0) | ||
122 | #define TX_FIFO_LVL(v, i) (((v) >> 6) & (i)->fifo_lvl_mask) | ||
123 | #define RX_FIFO_LVL(v, i) (((v) >> (i)->rx_lvl_offset) & (i)->fifo_lvl_mask) | ||
124 | |||
125 | #define S3C64XX_SPI_MAX_TRAILCNT 0x3ff | ||
126 | #define S3C64XX_SPI_TRAILCNT_OFF 19 | ||
127 | |||
128 | #define S3C64XX_SPI_TRAILCNT S3C64XX_SPI_MAX_TRAILCNT | ||
129 | |||
130 | #define msecs_to_loops(t) (loops_per_jiffy / 1000 * HZ * t) | ||
131 | |||
132 | #define SUSPND (1<<0) | ||
133 | #define SPIBUSY (1<<1) | ||
134 | #define RXBUSY (1<<2) | ||
135 | #define TXBUSY (1<<3) | ||
136 | |||
137 | /** | ||
138 | * struct s3c64xx_spi_driver_data - Runtime info holder for SPI driver. | ||
139 | * @clk: Pointer to the spi clock. | ||
140 | * @master: Pointer to the SPI Protocol master. | ||
141 | * @workqueue: Work queue for the SPI xfer requests. | ||
142 | * @cntrlr_info: Platform specific data for the controller this driver manages. | ||
143 | * @tgl_spi: Pointer to the last CS left untoggled by the cs_change hint. | ||
144 | * @work: Work | ||
145 | * @queue: To log SPI xfer requests. | ||
146 | * @lock: Controller specific lock. | ||
147 | * @state: Set of FLAGS to indicate status. | ||
148 | * @rx_dmach: Controller's DMA channel for Rx. | ||
149 | * @tx_dmach: Controller's DMA channel for Tx. | ||
150 | * @sfr_start: BUS address of SPI controller regs. | ||
151 | * @regs: Pointer to ioremap'ed controller registers. | ||
152 | * @xfer_completion: To indicate completion of xfer task. | ||
153 | * @cur_mode: Stores the active configuration of the controller. | ||
154 | * @cur_bpw: Stores the active bits per word settings. | ||
155 | * @cur_speed: Stores the active xfer clock speed. | ||
156 | */ | ||
157 | struct s3c64xx_spi_driver_data { | ||
158 | void __iomem *regs; | ||
159 | struct clk *clk; | ||
160 | struct platform_device *pdev; | ||
161 | struct spi_master *master; | ||
162 | struct workqueue_struct *workqueue; | ||
163 | struct s3c64xx_spi_cntrlr_info *cntrlr_info; | ||
164 | struct spi_device *tgl_spi; | ||
165 | struct work_struct work; | ||
166 | struct list_head queue; | ||
167 | spinlock_t lock; | ||
168 | enum dma_ch rx_dmach; | ||
169 | enum dma_ch tx_dmach; | ||
170 | unsigned long sfr_start; | ||
171 | struct completion xfer_completion; | ||
172 | unsigned state; | ||
173 | unsigned cur_mode, cur_bpw; | ||
174 | unsigned cur_speed; | ||
175 | }; | ||
176 | |||
177 | static struct s3c2410_dma_client s3c64xx_spi_dma_client = { | ||
178 | .name = "samsung-spi-dma", | ||
179 | }; | ||
180 | |||
181 | static void flush_fifo(struct s3c64xx_spi_driver_data *sdd) | ||
182 | { | ||
183 | struct s3c64xx_spi_cntrlr_info *sci = sdd->cntrlr_info; | ||
184 | void __iomem *regs = sdd->regs; | ||
185 | unsigned long loops; | ||
186 | u32 val; | ||
187 | |||
188 | writel(0, regs + S3C64XX_SPI_PACKET_CNT); | ||
189 | |||
190 | val = readl(regs + S3C64XX_SPI_CH_CFG); | ||
191 | val |= S3C64XX_SPI_CH_SW_RST; | ||
192 | val &= ~S3C64XX_SPI_CH_HS_EN; | ||
193 | writel(val, regs + S3C64XX_SPI_CH_CFG); | ||
194 | |||
195 | /* Flush TxFIFO*/ | ||
196 | loops = msecs_to_loops(1); | ||
197 | do { | ||
198 | val = readl(regs + S3C64XX_SPI_STATUS); | ||
199 | } while (TX_FIFO_LVL(val, sci) && loops--); | ||
200 | |||
201 | /* Flush RxFIFO*/ | ||
202 | loops = msecs_to_loops(1); | ||
203 | do { | ||
204 | val = readl(regs + S3C64XX_SPI_STATUS); | ||
205 | if (RX_FIFO_LVL(val, sci)) | ||
206 | readl(regs + S3C64XX_SPI_RX_DATA); | ||
207 | else | ||
208 | break; | ||
209 | } while (loops--); | ||
210 | |||
211 | val = readl(regs + S3C64XX_SPI_CH_CFG); | ||
212 | val &= ~S3C64XX_SPI_CH_SW_RST; | ||
213 | writel(val, regs + S3C64XX_SPI_CH_CFG); | ||
214 | |||
215 | val = readl(regs + S3C64XX_SPI_MODE_CFG); | ||
216 | val &= ~(S3C64XX_SPI_MODE_TXDMA_ON | S3C64XX_SPI_MODE_RXDMA_ON); | ||
217 | writel(val, regs + S3C64XX_SPI_MODE_CFG); | ||
218 | |||
219 | val = readl(regs + S3C64XX_SPI_CH_CFG); | ||
220 | val &= ~(S3C64XX_SPI_CH_RXCH_ON | S3C64XX_SPI_CH_TXCH_ON); | ||
221 | writel(val, regs + S3C64XX_SPI_CH_CFG); | ||
222 | } | ||
223 | |||
224 | static void enable_datapath(struct s3c64xx_spi_driver_data *sdd, | ||
225 | struct spi_device *spi, | ||
226 | struct spi_transfer *xfer, int dma_mode) | ||
227 | { | ||
228 | struct s3c64xx_spi_cntrlr_info *sci = sdd->cntrlr_info; | ||
229 | void __iomem *regs = sdd->regs; | ||
230 | u32 modecfg, chcfg; | ||
231 | |||
232 | modecfg = readl(regs + S3C64XX_SPI_MODE_CFG); | ||
233 | modecfg &= ~(S3C64XX_SPI_MODE_TXDMA_ON | S3C64XX_SPI_MODE_RXDMA_ON); | ||
234 | |||
235 | chcfg = readl(regs + S3C64XX_SPI_CH_CFG); | ||
236 | chcfg &= ~S3C64XX_SPI_CH_TXCH_ON; | ||
237 | |||
238 | if (dma_mode) { | ||
239 | chcfg &= ~S3C64XX_SPI_CH_RXCH_ON; | ||
240 | } else { | ||
241 | /* Always shift in data in FIFO, even if xfer is Tx only, | ||
242 | * this helps setting PCKT_CNT value for generating clocks | ||
243 | * as exactly needed. | ||
244 | */ | ||
245 | chcfg |= S3C64XX_SPI_CH_RXCH_ON; | ||
246 | writel(((xfer->len * 8 / sdd->cur_bpw) & 0xffff) | ||
247 | | S3C64XX_SPI_PACKET_CNT_EN, | ||
248 | regs + S3C64XX_SPI_PACKET_CNT); | ||
249 | } | ||
250 | |||
251 | if (xfer->tx_buf != NULL) { | ||
252 | sdd->state |= TXBUSY; | ||
253 | chcfg |= S3C64XX_SPI_CH_TXCH_ON; | ||
254 | if (dma_mode) { | ||
255 | modecfg |= S3C64XX_SPI_MODE_TXDMA_ON; | ||
256 | s3c2410_dma_config(sdd->tx_dmach, 1); | ||
257 | s3c2410_dma_enqueue(sdd->tx_dmach, (void *)sdd, | ||
258 | xfer->tx_dma, xfer->len); | ||
259 | s3c2410_dma_ctrl(sdd->tx_dmach, S3C2410_DMAOP_START); | ||
260 | } else { | ||
261 | unsigned char *buf = (unsigned char *) xfer->tx_buf; | ||
262 | int i = 0; | ||
263 | while (i < xfer->len) | ||
264 | writeb(buf[i++], regs + S3C64XX_SPI_TX_DATA); | ||
265 | } | ||
266 | } | ||
267 | |||
268 | if (xfer->rx_buf != NULL) { | ||
269 | sdd->state |= RXBUSY; | ||
270 | |||
271 | if (sci->high_speed && sdd->cur_speed >= 30000000UL | ||
272 | && !(sdd->cur_mode & SPI_CPHA)) | ||
273 | chcfg |= S3C64XX_SPI_CH_HS_EN; | ||
274 | |||
275 | if (dma_mode) { | ||
276 | modecfg |= S3C64XX_SPI_MODE_RXDMA_ON; | ||
277 | chcfg |= S3C64XX_SPI_CH_RXCH_ON; | ||
278 | writel(((xfer->len * 8 / sdd->cur_bpw) & 0xffff) | ||
279 | | S3C64XX_SPI_PACKET_CNT_EN, | ||
280 | regs + S3C64XX_SPI_PACKET_CNT); | ||
281 | s3c2410_dma_config(sdd->rx_dmach, 1); | ||
282 | s3c2410_dma_enqueue(sdd->rx_dmach, (void *)sdd, | ||
283 | xfer->rx_dma, xfer->len); | ||
284 | s3c2410_dma_ctrl(sdd->rx_dmach, S3C2410_DMAOP_START); | ||
285 | } | ||
286 | } | ||
287 | |||
288 | writel(modecfg, regs + S3C64XX_SPI_MODE_CFG); | ||
289 | writel(chcfg, regs + S3C64XX_SPI_CH_CFG); | ||
290 | } | ||
291 | |||
292 | static inline void enable_cs(struct s3c64xx_spi_driver_data *sdd, | ||
293 | struct spi_device *spi) | ||
294 | { | ||
295 | struct s3c64xx_spi_csinfo *cs; | ||
296 | |||
297 | if (sdd->tgl_spi != NULL) { /* If last device toggled after mssg */ | ||
298 | if (sdd->tgl_spi != spi) { /* if last mssg on diff device */ | ||
299 | /* Deselect the last toggled device */ | ||
300 | cs = sdd->tgl_spi->controller_data; | ||
301 | cs->set_level(spi->mode & SPI_CS_HIGH ? 0 : 1); | ||
302 | } | ||
303 | sdd->tgl_spi = NULL; | ||
304 | } | ||
305 | |||
306 | cs = spi->controller_data; | ||
307 | cs->set_level(spi->mode & SPI_CS_HIGH ? 1 : 0); | ||
308 | } | ||
309 | |||
310 | static int wait_for_xfer(struct s3c64xx_spi_driver_data *sdd, | ||
311 | struct spi_transfer *xfer, int dma_mode) | ||
312 | { | ||
313 | struct s3c64xx_spi_cntrlr_info *sci = sdd->cntrlr_info; | ||
314 | void __iomem *regs = sdd->regs; | ||
315 | unsigned long val; | ||
316 | int ms; | ||
317 | |||
318 | /* millisecs to xfer 'len' bytes @ 'cur_speed' */ | ||
319 | ms = xfer->len * 8 * 1000 / sdd->cur_speed; | ||
320 | ms += 5; /* some tolerance */ | ||
321 | |||
322 | if (dma_mode) { | ||
323 | val = msecs_to_jiffies(ms) + 10; | ||
324 | val = wait_for_completion_timeout(&sdd->xfer_completion, val); | ||
325 | } else { | ||
326 | val = msecs_to_loops(ms); | ||
327 | do { | ||
328 | val = readl(regs + S3C64XX_SPI_STATUS); | ||
329 | } while (RX_FIFO_LVL(val, sci) < xfer->len && --val); | ||
330 | } | ||
331 | |||
332 | if (!val) | ||
333 | return -EIO; | ||
334 | |||
335 | if (dma_mode) { | ||
336 | u32 status; | ||
337 | |||
338 | /* | ||
339 | * DmaTx returns after simply writing data in the FIFO, | ||
340 | * w/o waiting for real transmission on the bus to finish. | ||
341 | * DmaRx returns only after Dma read data from FIFO which | ||
342 | * needs bus transmission to finish, so we don't worry if | ||
343 | * Xfer involved Rx(with or without Tx). | ||
344 | */ | ||
345 | if (xfer->rx_buf == NULL) { | ||
346 | val = msecs_to_loops(10); | ||
347 | status = readl(regs + S3C64XX_SPI_STATUS); | ||
348 | while ((TX_FIFO_LVL(status, sci) | ||
349 | || !S3C64XX_SPI_ST_TX_DONE(status, sci)) | ||
350 | && --val) { | ||
351 | cpu_relax(); | ||
352 | status = readl(regs + S3C64XX_SPI_STATUS); | ||
353 | } | ||
354 | |||
355 | if (!val) | ||
356 | return -EIO; | ||
357 | } | ||
358 | } else { | ||
359 | unsigned char *buf; | ||
360 | int i; | ||
361 | |||
362 | /* If it was only Tx */ | ||
363 | if (xfer->rx_buf == NULL) { | ||
364 | sdd->state &= ~TXBUSY; | ||
365 | return 0; | ||
366 | } | ||
367 | |||
368 | i = 0; | ||
369 | buf = xfer->rx_buf; | ||
370 | while (i < xfer->len) | ||
371 | buf[i++] = readb(regs + S3C64XX_SPI_RX_DATA); | ||
372 | |||
373 | sdd->state &= ~RXBUSY; | ||
374 | } | ||
375 | |||
376 | return 0; | ||
377 | } | ||
378 | |||
379 | static inline void disable_cs(struct s3c64xx_spi_driver_data *sdd, | ||
380 | struct spi_device *spi) | ||
381 | { | ||
382 | struct s3c64xx_spi_csinfo *cs = spi->controller_data; | ||
383 | |||
384 | if (sdd->tgl_spi == spi) | ||
385 | sdd->tgl_spi = NULL; | ||
386 | |||
387 | cs->set_level(spi->mode & SPI_CS_HIGH ? 0 : 1); | ||
388 | } | ||
389 | |||
390 | static void s3c64xx_spi_config(struct s3c64xx_spi_driver_data *sdd) | ||
391 | { | ||
392 | struct s3c64xx_spi_cntrlr_info *sci = sdd->cntrlr_info; | ||
393 | void __iomem *regs = sdd->regs; | ||
394 | u32 val; | ||
395 | |||
396 | /* Disable Clock */ | ||
397 | val = readl(regs + S3C64XX_SPI_CLK_CFG); | ||
398 | val &= ~S3C64XX_SPI_ENCLK_ENABLE; | ||
399 | writel(val, regs + S3C64XX_SPI_CLK_CFG); | ||
400 | |||
401 | /* Set Polarity and Phase */ | ||
402 | val = readl(regs + S3C64XX_SPI_CH_CFG); | ||
403 | val &= ~(S3C64XX_SPI_CH_SLAVE | | ||
404 | S3C64XX_SPI_CPOL_L | | ||
405 | S3C64XX_SPI_CPHA_B); | ||
406 | |||
407 | if (sdd->cur_mode & SPI_CPOL) | ||
408 | val |= S3C64XX_SPI_CPOL_L; | ||
409 | |||
410 | if (sdd->cur_mode & SPI_CPHA) | ||
411 | val |= S3C64XX_SPI_CPHA_B; | ||
412 | |||
413 | writel(val, regs + S3C64XX_SPI_CH_CFG); | ||
414 | |||
415 | /* Set Channel & DMA Mode */ | ||
416 | val = readl(regs + S3C64XX_SPI_MODE_CFG); | ||
417 | val &= ~(S3C64XX_SPI_MODE_BUS_TSZ_MASK | ||
418 | | S3C64XX_SPI_MODE_CH_TSZ_MASK); | ||
419 | |||
420 | switch (sdd->cur_bpw) { | ||
421 | case 32: | ||
422 | val |= S3C64XX_SPI_MODE_BUS_TSZ_WORD; | ||
423 | break; | ||
424 | case 16: | ||
425 | val |= S3C64XX_SPI_MODE_BUS_TSZ_HALFWORD; | ||
426 | break; | ||
427 | default: | ||
428 | val |= S3C64XX_SPI_MODE_BUS_TSZ_BYTE; | ||
429 | break; | ||
430 | } | ||
431 | val |= S3C64XX_SPI_MODE_CH_TSZ_BYTE; /* Always 8bits wide */ | ||
432 | |||
433 | writel(val, regs + S3C64XX_SPI_MODE_CFG); | ||
434 | |||
435 | /* Configure Clock */ | ||
436 | val = readl(regs + S3C64XX_SPI_CLK_CFG); | ||
437 | val &= ~S3C64XX_SPI_PSR_MASK; | ||
438 | val |= ((clk_get_rate(sci->src_clk) / sdd->cur_speed / 2 - 1) | ||
439 | & S3C64XX_SPI_PSR_MASK); | ||
440 | writel(val, regs + S3C64XX_SPI_CLK_CFG); | ||
441 | |||
442 | /* Enable Clock */ | ||
443 | val = readl(regs + S3C64XX_SPI_CLK_CFG); | ||
444 | val |= S3C64XX_SPI_ENCLK_ENABLE; | ||
445 | writel(val, regs + S3C64XX_SPI_CLK_CFG); | ||
446 | } | ||
447 | |||
448 | void s3c64xx_spi_dma_rxcb(struct s3c2410_dma_chan *chan, void *buf_id, | ||
449 | int size, enum s3c2410_dma_buffresult res) | ||
450 | { | ||
451 | struct s3c64xx_spi_driver_data *sdd = buf_id; | ||
452 | unsigned long flags; | ||
453 | |||
454 | spin_lock_irqsave(&sdd->lock, flags); | ||
455 | |||
456 | if (res == S3C2410_RES_OK) | ||
457 | sdd->state &= ~RXBUSY; | ||
458 | else | ||
459 | dev_err(&sdd->pdev->dev, "DmaAbrtRx-%d\n", size); | ||
460 | |||
461 | /* If the other done */ | ||
462 | if (!(sdd->state & TXBUSY)) | ||
463 | complete(&sdd->xfer_completion); | ||
464 | |||
465 | spin_unlock_irqrestore(&sdd->lock, flags); | ||
466 | } | ||
467 | |||
468 | void s3c64xx_spi_dma_txcb(struct s3c2410_dma_chan *chan, void *buf_id, | ||
469 | int size, enum s3c2410_dma_buffresult res) | ||
470 | { | ||
471 | struct s3c64xx_spi_driver_data *sdd = buf_id; | ||
472 | unsigned long flags; | ||
473 | |||
474 | spin_lock_irqsave(&sdd->lock, flags); | ||
475 | |||
476 | if (res == S3C2410_RES_OK) | ||
477 | sdd->state &= ~TXBUSY; | ||
478 | else | ||
479 | dev_err(&sdd->pdev->dev, "DmaAbrtTx-%d \n", size); | ||
480 | |||
481 | /* If the other done */ | ||
482 | if (!(sdd->state & RXBUSY)) | ||
483 | complete(&sdd->xfer_completion); | ||
484 | |||
485 | spin_unlock_irqrestore(&sdd->lock, flags); | ||
486 | } | ||
487 | |||
488 | #define XFER_DMAADDR_INVALID DMA_BIT_MASK(32) | ||
489 | |||
490 | static int s3c64xx_spi_map_mssg(struct s3c64xx_spi_driver_data *sdd, | ||
491 | struct spi_message *msg) | ||
492 | { | ||
493 | struct device *dev = &sdd->pdev->dev; | ||
494 | struct spi_transfer *xfer; | ||
495 | |||
496 | if (msg->is_dma_mapped) | ||
497 | return 0; | ||
498 | |||
499 | /* First mark all xfer unmapped */ | ||
500 | list_for_each_entry(xfer, &msg->transfers, transfer_list) { | ||
501 | xfer->rx_dma = XFER_DMAADDR_INVALID; | ||
502 | xfer->tx_dma = XFER_DMAADDR_INVALID; | ||
503 | } | ||
504 | |||
505 | /* Map until end or first fail */ | ||
506 | list_for_each_entry(xfer, &msg->transfers, transfer_list) { | ||
507 | |||
508 | if (xfer->tx_buf != NULL) { | ||
509 | xfer->tx_dma = dma_map_single(dev, xfer->tx_buf, | ||
510 | xfer->len, DMA_TO_DEVICE); | ||
511 | if (dma_mapping_error(dev, xfer->tx_dma)) { | ||
512 | dev_err(dev, "dma_map_single Tx failed\n"); | ||
513 | xfer->tx_dma = XFER_DMAADDR_INVALID; | ||
514 | return -ENOMEM; | ||
515 | } | ||
516 | } | ||
517 | |||
518 | if (xfer->rx_buf != NULL) { | ||
519 | xfer->rx_dma = dma_map_single(dev, xfer->rx_buf, | ||
520 | xfer->len, DMA_FROM_DEVICE); | ||
521 | if (dma_mapping_error(dev, xfer->rx_dma)) { | ||
522 | dev_err(dev, "dma_map_single Rx failed\n"); | ||
523 | dma_unmap_single(dev, xfer->tx_dma, | ||
524 | xfer->len, DMA_TO_DEVICE); | ||
525 | xfer->tx_dma = XFER_DMAADDR_INVALID; | ||
526 | xfer->rx_dma = XFER_DMAADDR_INVALID; | ||
527 | return -ENOMEM; | ||
528 | } | ||
529 | } | ||
530 | } | ||
531 | |||
532 | return 0; | ||
533 | } | ||
534 | |||
535 | static void s3c64xx_spi_unmap_mssg(struct s3c64xx_spi_driver_data *sdd, | ||
536 | struct spi_message *msg) | ||
537 | { | ||
538 | struct device *dev = &sdd->pdev->dev; | ||
539 | struct spi_transfer *xfer; | ||
540 | |||
541 | if (msg->is_dma_mapped) | ||
542 | return; | ||
543 | |||
544 | list_for_each_entry(xfer, &msg->transfers, transfer_list) { | ||
545 | |||
546 | if (xfer->rx_buf != NULL | ||
547 | && xfer->rx_dma != XFER_DMAADDR_INVALID) | ||
548 | dma_unmap_single(dev, xfer->rx_dma, | ||
549 | xfer->len, DMA_FROM_DEVICE); | ||
550 | |||
551 | if (xfer->tx_buf != NULL | ||
552 | && xfer->tx_dma != XFER_DMAADDR_INVALID) | ||
553 | dma_unmap_single(dev, xfer->tx_dma, | ||
554 | xfer->len, DMA_TO_DEVICE); | ||
555 | } | ||
556 | } | ||
557 | |||
558 | static void handle_msg(struct s3c64xx_spi_driver_data *sdd, | ||
559 | struct spi_message *msg) | ||
560 | { | ||
561 | struct s3c64xx_spi_cntrlr_info *sci = sdd->cntrlr_info; | ||
562 | struct spi_device *spi = msg->spi; | ||
563 | struct s3c64xx_spi_csinfo *cs = spi->controller_data; | ||
564 | struct spi_transfer *xfer; | ||
565 | int status = 0, cs_toggle = 0; | ||
566 | u32 speed; | ||
567 | u8 bpw; | ||
568 | |||
569 | /* If Master's(controller) state differs from that needed by Slave */ | ||
570 | if (sdd->cur_speed != spi->max_speed_hz | ||
571 | || sdd->cur_mode != spi->mode | ||
572 | || sdd->cur_bpw != spi->bits_per_word) { | ||
573 | sdd->cur_bpw = spi->bits_per_word; | ||
574 | sdd->cur_speed = spi->max_speed_hz; | ||
575 | sdd->cur_mode = spi->mode; | ||
576 | s3c64xx_spi_config(sdd); | ||
577 | } | ||
578 | |||
579 | /* Map all the transfers if needed */ | ||
580 | if (s3c64xx_spi_map_mssg(sdd, msg)) { | ||
581 | dev_err(&spi->dev, | ||
582 | "Xfer: Unable to map message buffers!\n"); | ||
583 | status = -ENOMEM; | ||
584 | goto out; | ||
585 | } | ||
586 | |||
587 | /* Configure feedback delay */ | ||
588 | writel(cs->fb_delay & 0x3, sdd->regs + S3C64XX_SPI_FB_CLK); | ||
589 | |||
590 | list_for_each_entry(xfer, &msg->transfers, transfer_list) { | ||
591 | |||
592 | unsigned long flags; | ||
593 | int use_dma; | ||
594 | |||
595 | INIT_COMPLETION(sdd->xfer_completion); | ||
596 | |||
597 | /* Only BPW and Speed may change across transfers */ | ||
598 | bpw = xfer->bits_per_word ? : spi->bits_per_word; | ||
599 | speed = xfer->speed_hz ? : spi->max_speed_hz; | ||
600 | |||
601 | if (bpw != sdd->cur_bpw || speed != sdd->cur_speed) { | ||
602 | sdd->cur_bpw = bpw; | ||
603 | sdd->cur_speed = speed; | ||
604 | s3c64xx_spi_config(sdd); | ||
605 | } | ||
606 | |||
607 | /* Polling method for xfers not bigger than FIFO capacity */ | ||
608 | if (xfer->len <= ((sci->fifo_lvl_mask >> 1) + 1)) | ||
609 | use_dma = 0; | ||
610 | else | ||
611 | use_dma = 1; | ||
612 | |||
613 | spin_lock_irqsave(&sdd->lock, flags); | ||
614 | |||
615 | /* Pending only which is to be done */ | ||
616 | sdd->state &= ~RXBUSY; | ||
617 | sdd->state &= ~TXBUSY; | ||
618 | |||
619 | enable_datapath(sdd, spi, xfer, use_dma); | ||
620 | |||
621 | /* Slave Select */ | ||
622 | enable_cs(sdd, spi); | ||
623 | |||
624 | /* Start the signals */ | ||
625 | S3C64XX_SPI_ACT(sdd); | ||
626 | |||
627 | spin_unlock_irqrestore(&sdd->lock, flags); | ||
628 | |||
629 | status = wait_for_xfer(sdd, xfer, use_dma); | ||
630 | |||
631 | /* Quiese the signals */ | ||
632 | S3C64XX_SPI_DEACT(sdd); | ||
633 | |||
634 | if (status) { | ||
635 | dev_err(&spi->dev, "I/O Error: \ | ||
636 | rx-%d tx-%d res:rx-%c tx-%c len-%d\n", | ||
637 | xfer->rx_buf ? 1 : 0, xfer->tx_buf ? 1 : 0, | ||
638 | (sdd->state & RXBUSY) ? 'f' : 'p', | ||
639 | (sdd->state & TXBUSY) ? 'f' : 'p', | ||
640 | xfer->len); | ||
641 | |||
642 | if (use_dma) { | ||
643 | if (xfer->tx_buf != NULL | ||
644 | && (sdd->state & TXBUSY)) | ||
645 | s3c2410_dma_ctrl(sdd->tx_dmach, | ||
646 | S3C2410_DMAOP_FLUSH); | ||
647 | if (xfer->rx_buf != NULL | ||
648 | && (sdd->state & RXBUSY)) | ||
649 | s3c2410_dma_ctrl(sdd->rx_dmach, | ||
650 | S3C2410_DMAOP_FLUSH); | ||
651 | } | ||
652 | |||
653 | goto out; | ||
654 | } | ||
655 | |||
656 | if (xfer->delay_usecs) | ||
657 | udelay(xfer->delay_usecs); | ||
658 | |||
659 | if (xfer->cs_change) { | ||
660 | /* Hint that the next mssg is gonna be | ||
661 | for the same device */ | ||
662 | if (list_is_last(&xfer->transfer_list, | ||
663 | &msg->transfers)) | ||
664 | cs_toggle = 1; | ||
665 | else | ||
666 | disable_cs(sdd, spi); | ||
667 | } | ||
668 | |||
669 | msg->actual_length += xfer->len; | ||
670 | |||
671 | flush_fifo(sdd); | ||
672 | } | ||
673 | |||
674 | out: | ||
675 | if (!cs_toggle || status) | ||
676 | disable_cs(sdd, spi); | ||
677 | else | ||
678 | sdd->tgl_spi = spi; | ||
679 | |||
680 | s3c64xx_spi_unmap_mssg(sdd, msg); | ||
681 | |||
682 | msg->status = status; | ||
683 | |||
684 | if (msg->complete) | ||
685 | msg->complete(msg->context); | ||
686 | } | ||
687 | |||
688 | static int acquire_dma(struct s3c64xx_spi_driver_data *sdd) | ||
689 | { | ||
690 | if (s3c2410_dma_request(sdd->rx_dmach, | ||
691 | &s3c64xx_spi_dma_client, NULL) < 0) { | ||
692 | dev_err(&sdd->pdev->dev, "cannot get RxDMA\n"); | ||
693 | return 0; | ||
694 | } | ||
695 | s3c2410_dma_set_buffdone_fn(sdd->rx_dmach, s3c64xx_spi_dma_rxcb); | ||
696 | s3c2410_dma_devconfig(sdd->rx_dmach, S3C2410_DMASRC_HW, | ||
697 | sdd->sfr_start + S3C64XX_SPI_RX_DATA); | ||
698 | |||
699 | if (s3c2410_dma_request(sdd->tx_dmach, | ||
700 | &s3c64xx_spi_dma_client, NULL) < 0) { | ||
701 | dev_err(&sdd->pdev->dev, "cannot get TxDMA\n"); | ||
702 | s3c2410_dma_free(sdd->rx_dmach, &s3c64xx_spi_dma_client); | ||
703 | return 0; | ||
704 | } | ||
705 | s3c2410_dma_set_buffdone_fn(sdd->tx_dmach, s3c64xx_spi_dma_txcb); | ||
706 | s3c2410_dma_devconfig(sdd->tx_dmach, S3C2410_DMASRC_MEM, | ||
707 | sdd->sfr_start + S3C64XX_SPI_TX_DATA); | ||
708 | |||
709 | return 1; | ||
710 | } | ||
711 | |||
712 | static void s3c64xx_spi_work(struct work_struct *work) | ||
713 | { | ||
714 | struct s3c64xx_spi_driver_data *sdd = container_of(work, | ||
715 | struct s3c64xx_spi_driver_data, work); | ||
716 | unsigned long flags; | ||
717 | |||
718 | /* Acquire DMA channels */ | ||
719 | while (!acquire_dma(sdd)) | ||
720 | msleep(10); | ||
721 | |||
722 | spin_lock_irqsave(&sdd->lock, flags); | ||
723 | |||
724 | while (!list_empty(&sdd->queue) | ||
725 | && !(sdd->state & SUSPND)) { | ||
726 | |||
727 | struct spi_message *msg; | ||
728 | |||
729 | msg = container_of(sdd->queue.next, struct spi_message, queue); | ||
730 | |||
731 | list_del_init(&msg->queue); | ||
732 | |||
733 | /* Set Xfer busy flag */ | ||
734 | sdd->state |= SPIBUSY; | ||
735 | |||
736 | spin_unlock_irqrestore(&sdd->lock, flags); | ||
737 | |||
738 | handle_msg(sdd, msg); | ||
739 | |||
740 | spin_lock_irqsave(&sdd->lock, flags); | ||
741 | |||
742 | sdd->state &= ~SPIBUSY; | ||
743 | } | ||
744 | |||
745 | spin_unlock_irqrestore(&sdd->lock, flags); | ||
746 | |||
747 | /* Free DMA channels */ | ||
748 | s3c2410_dma_free(sdd->tx_dmach, &s3c64xx_spi_dma_client); | ||
749 | s3c2410_dma_free(sdd->rx_dmach, &s3c64xx_spi_dma_client); | ||
750 | } | ||
751 | |||
752 | static int s3c64xx_spi_transfer(struct spi_device *spi, | ||
753 | struct spi_message *msg) | ||
754 | { | ||
755 | struct s3c64xx_spi_driver_data *sdd; | ||
756 | unsigned long flags; | ||
757 | |||
758 | sdd = spi_master_get_devdata(spi->master); | ||
759 | |||
760 | spin_lock_irqsave(&sdd->lock, flags); | ||
761 | |||
762 | if (sdd->state & SUSPND) { | ||
763 | spin_unlock_irqrestore(&sdd->lock, flags); | ||
764 | return -ESHUTDOWN; | ||
765 | } | ||
766 | |||
767 | msg->status = -EINPROGRESS; | ||
768 | msg->actual_length = 0; | ||
769 | |||
770 | list_add_tail(&msg->queue, &sdd->queue); | ||
771 | |||
772 | queue_work(sdd->workqueue, &sdd->work); | ||
773 | |||
774 | spin_unlock_irqrestore(&sdd->lock, flags); | ||
775 | |||
776 | return 0; | ||
777 | } | ||
778 | |||
779 | /* | ||
780 | * Here we only check the validity of requested configuration | ||
781 | * and save the configuration in a local data-structure. | ||
782 | * The controller is actually configured only just before we | ||
783 | * get a message to transfer. | ||
784 | */ | ||
785 | static int s3c64xx_spi_setup(struct spi_device *spi) | ||
786 | { | ||
787 | struct s3c64xx_spi_csinfo *cs = spi->controller_data; | ||
788 | struct s3c64xx_spi_driver_data *sdd; | ||
789 | struct s3c64xx_spi_cntrlr_info *sci; | ||
790 | struct spi_message *msg; | ||
791 | u32 psr, speed; | ||
792 | unsigned long flags; | ||
793 | int err = 0; | ||
794 | |||
795 | if (cs == NULL || cs->set_level == NULL) { | ||
796 | dev_err(&spi->dev, "No CS for SPI(%d)\n", spi->chip_select); | ||
797 | return -ENODEV; | ||
798 | } | ||
799 | |||
800 | sdd = spi_master_get_devdata(spi->master); | ||
801 | sci = sdd->cntrlr_info; | ||
802 | |||
803 | spin_lock_irqsave(&sdd->lock, flags); | ||
804 | |||
805 | list_for_each_entry(msg, &sdd->queue, queue) { | ||
806 | /* Is some mssg is already queued for this device */ | ||
807 | if (msg->spi == spi) { | ||
808 | dev_err(&spi->dev, | ||
809 | "setup: attempt while mssg in queue!\n"); | ||
810 | spin_unlock_irqrestore(&sdd->lock, flags); | ||
811 | return -EBUSY; | ||
812 | } | ||
813 | } | ||
814 | |||
815 | if (sdd->state & SUSPND) { | ||
816 | spin_unlock_irqrestore(&sdd->lock, flags); | ||
817 | dev_err(&spi->dev, | ||
818 | "setup: SPI-%d not active!\n", spi->master->bus_num); | ||
819 | return -ESHUTDOWN; | ||
820 | } | ||
821 | |||
822 | spin_unlock_irqrestore(&sdd->lock, flags); | ||
823 | |||
824 | if (spi->bits_per_word != 8 | ||
825 | && spi->bits_per_word != 16 | ||
826 | && spi->bits_per_word != 32) { | ||
827 | dev_err(&spi->dev, "setup: %dbits/wrd not supported!\n", | ||
828 | spi->bits_per_word); | ||
829 | err = -EINVAL; | ||
830 | goto setup_exit; | ||
831 | } | ||
832 | |||
833 | /* Check if we can provide the requested rate */ | ||
834 | speed = clk_get_rate(sci->src_clk) / 2 / (0 + 1); /* Max possible */ | ||
835 | |||
836 | if (spi->max_speed_hz > speed) | ||
837 | spi->max_speed_hz = speed; | ||
838 | |||
839 | psr = clk_get_rate(sci->src_clk) / 2 / spi->max_speed_hz - 1; | ||
840 | psr &= S3C64XX_SPI_PSR_MASK; | ||
841 | if (psr == S3C64XX_SPI_PSR_MASK) | ||
842 | psr--; | ||
843 | |||
844 | speed = clk_get_rate(sci->src_clk) / 2 / (psr + 1); | ||
845 | if (spi->max_speed_hz < speed) { | ||
846 | if (psr+1 < S3C64XX_SPI_PSR_MASK) { | ||
847 | psr++; | ||
848 | } else { | ||
849 | err = -EINVAL; | ||
850 | goto setup_exit; | ||
851 | } | ||
852 | } | ||
853 | |||
854 | speed = clk_get_rate(sci->src_clk) / 2 / (psr + 1); | ||
855 | if (spi->max_speed_hz >= speed) | ||
856 | spi->max_speed_hz = speed; | ||
857 | else | ||
858 | err = -EINVAL; | ||
859 | |||
860 | setup_exit: | ||
861 | |||
862 | /* setup() returns with device de-selected */ | ||
863 | disable_cs(sdd, spi); | ||
864 | |||
865 | return err; | ||
866 | } | ||
867 | |||
868 | static void s3c64xx_spi_hwinit(struct s3c64xx_spi_driver_data *sdd, int channel) | ||
869 | { | ||
870 | struct s3c64xx_spi_cntrlr_info *sci = sdd->cntrlr_info; | ||
871 | void __iomem *regs = sdd->regs; | ||
872 | unsigned int val; | ||
873 | |||
874 | sdd->cur_speed = 0; | ||
875 | |||
876 | S3C64XX_SPI_DEACT(sdd); | ||
877 | |||
878 | /* Disable Interrupts - we use Polling if not DMA mode */ | ||
879 | writel(0, regs + S3C64XX_SPI_INT_EN); | ||
880 | |||
881 | writel(sci->src_clk_nr << S3C64XX_SPI_CLKSEL_SRCSHFT, | ||
882 | regs + S3C64XX_SPI_CLK_CFG); | ||
883 | writel(0, regs + S3C64XX_SPI_MODE_CFG); | ||
884 | writel(0, regs + S3C64XX_SPI_PACKET_CNT); | ||
885 | |||
886 | /* Clear any irq pending bits */ | ||
887 | writel(readl(regs + S3C64XX_SPI_PENDING_CLR), | ||
888 | regs + S3C64XX_SPI_PENDING_CLR); | ||
889 | |||
890 | writel(0, regs + S3C64XX_SPI_SWAP_CFG); | ||
891 | |||
892 | val = readl(regs + S3C64XX_SPI_MODE_CFG); | ||
893 | val &= ~S3C64XX_SPI_MODE_4BURST; | ||
894 | val &= ~(S3C64XX_SPI_MAX_TRAILCNT << S3C64XX_SPI_TRAILCNT_OFF); | ||
895 | val |= (S3C64XX_SPI_TRAILCNT << S3C64XX_SPI_TRAILCNT_OFF); | ||
896 | writel(val, regs + S3C64XX_SPI_MODE_CFG); | ||
897 | |||
898 | flush_fifo(sdd); | ||
899 | } | ||
900 | |||
901 | static int __init s3c64xx_spi_probe(struct platform_device *pdev) | ||
902 | { | ||
903 | struct resource *mem_res, *dmatx_res, *dmarx_res; | ||
904 | struct s3c64xx_spi_driver_data *sdd; | ||
905 | struct s3c64xx_spi_cntrlr_info *sci; | ||
906 | struct spi_master *master; | ||
907 | int ret; | ||
908 | |||
909 | if (pdev->id < 0) { | ||
910 | dev_err(&pdev->dev, | ||
911 | "Invalid platform device id-%d\n", pdev->id); | ||
912 | return -ENODEV; | ||
913 | } | ||
914 | |||
915 | if (pdev->dev.platform_data == NULL) { | ||
916 | dev_err(&pdev->dev, "platform_data missing!\n"); | ||
917 | return -ENODEV; | ||
918 | } | ||
919 | |||
920 | /* Check for availability of necessary resource */ | ||
921 | |||
922 | dmatx_res = platform_get_resource(pdev, IORESOURCE_DMA, 0); | ||
923 | if (dmatx_res == NULL) { | ||
924 | dev_err(&pdev->dev, "Unable to get SPI-Tx dma resource\n"); | ||
925 | return -ENXIO; | ||
926 | } | ||
927 | |||
928 | dmarx_res = platform_get_resource(pdev, IORESOURCE_DMA, 1); | ||
929 | if (dmarx_res == NULL) { | ||
930 | dev_err(&pdev->dev, "Unable to get SPI-Rx dma resource\n"); | ||
931 | return -ENXIO; | ||
932 | } | ||
933 | |||
934 | mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
935 | if (mem_res == NULL) { | ||
936 | dev_err(&pdev->dev, "Unable to get SPI MEM resource\n"); | ||
937 | return -ENXIO; | ||
938 | } | ||
939 | |||
940 | master = spi_alloc_master(&pdev->dev, | ||
941 | sizeof(struct s3c64xx_spi_driver_data)); | ||
942 | if (master == NULL) { | ||
943 | dev_err(&pdev->dev, "Unable to allocate SPI Master\n"); | ||
944 | return -ENOMEM; | ||
945 | } | ||
946 | |||
947 | sci = pdev->dev.platform_data; | ||
948 | |||
949 | platform_set_drvdata(pdev, master); | ||
950 | |||
951 | sdd = spi_master_get_devdata(master); | ||
952 | sdd->master = master; | ||
953 | sdd->cntrlr_info = sci; | ||
954 | sdd->pdev = pdev; | ||
955 | sdd->sfr_start = mem_res->start; | ||
956 | sdd->tx_dmach = dmatx_res->start; | ||
957 | sdd->rx_dmach = dmarx_res->start; | ||
958 | |||
959 | sdd->cur_bpw = 8; | ||
960 | |||
961 | master->bus_num = pdev->id; | ||
962 | master->setup = s3c64xx_spi_setup; | ||
963 | master->transfer = s3c64xx_spi_transfer; | ||
964 | master->num_chipselect = sci->num_cs; | ||
965 | master->dma_alignment = 8; | ||
966 | /* the spi->mode bits understood by this driver: */ | ||
967 | master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; | ||
968 | |||
969 | if (request_mem_region(mem_res->start, | ||
970 | resource_size(mem_res), pdev->name) == NULL) { | ||
971 | dev_err(&pdev->dev, "Req mem region failed\n"); | ||
972 | ret = -ENXIO; | ||
973 | goto err0; | ||
974 | } | ||
975 | |||
976 | sdd->regs = ioremap(mem_res->start, resource_size(mem_res)); | ||
977 | if (sdd->regs == NULL) { | ||
978 | dev_err(&pdev->dev, "Unable to remap IO\n"); | ||
979 | ret = -ENXIO; | ||
980 | goto err1; | ||
981 | } | ||
982 | |||
983 | if (sci->cfg_gpio == NULL || sci->cfg_gpio(pdev)) { | ||
984 | dev_err(&pdev->dev, "Unable to config gpio\n"); | ||
985 | ret = -EBUSY; | ||
986 | goto err2; | ||
987 | } | ||
988 | |||
989 | /* Setup clocks */ | ||
990 | sdd->clk = clk_get(&pdev->dev, "spi"); | ||
991 | if (IS_ERR(sdd->clk)) { | ||
992 | dev_err(&pdev->dev, "Unable to acquire clock 'spi'\n"); | ||
993 | ret = PTR_ERR(sdd->clk); | ||
994 | goto err3; | ||
995 | } | ||
996 | |||
997 | if (clk_enable(sdd->clk)) { | ||
998 | dev_err(&pdev->dev, "Couldn't enable clock 'spi'\n"); | ||
999 | ret = -EBUSY; | ||
1000 | goto err4; | ||
1001 | } | ||
1002 | |||
1003 | if (sci->src_clk_nr == S3C64XX_SPI_SRCCLK_PCLK) | ||
1004 | sci->src_clk = sdd->clk; | ||
1005 | else | ||
1006 | sci->src_clk = clk_get(&pdev->dev, sci->src_clk_name); | ||
1007 | if (IS_ERR(sci->src_clk)) { | ||
1008 | dev_err(&pdev->dev, | ||
1009 | "Unable to acquire clock '%s'\n", sci->src_clk_name); | ||
1010 | ret = PTR_ERR(sci->src_clk); | ||
1011 | goto err5; | ||
1012 | } | ||
1013 | |||
1014 | if (sci->src_clk != sdd->clk && clk_enable(sci->src_clk)) { | ||
1015 | dev_err(&pdev->dev, "Couldn't enable clock '%s'\n", | ||
1016 | sci->src_clk_name); | ||
1017 | ret = -EBUSY; | ||
1018 | goto err6; | ||
1019 | } | ||
1020 | |||
1021 | sdd->workqueue = create_singlethread_workqueue( | ||
1022 | dev_name(master->dev.parent)); | ||
1023 | if (sdd->workqueue == NULL) { | ||
1024 | dev_err(&pdev->dev, "Unable to create workqueue\n"); | ||
1025 | ret = -ENOMEM; | ||
1026 | goto err7; | ||
1027 | } | ||
1028 | |||
1029 | /* Setup Deufult Mode */ | ||
1030 | s3c64xx_spi_hwinit(sdd, pdev->id); | ||
1031 | |||
1032 | spin_lock_init(&sdd->lock); | ||
1033 | init_completion(&sdd->xfer_completion); | ||
1034 | INIT_WORK(&sdd->work, s3c64xx_spi_work); | ||
1035 | INIT_LIST_HEAD(&sdd->queue); | ||
1036 | |||
1037 | if (spi_register_master(master)) { | ||
1038 | dev_err(&pdev->dev, "cannot register SPI master\n"); | ||
1039 | ret = -EBUSY; | ||
1040 | goto err8; | ||
1041 | } | ||
1042 | |||
1043 | dev_dbg(&pdev->dev, "Samsung SoC SPI Driver loaded for Bus SPI-%d \ | ||
1044 | with %d Slaves attached\n", | ||
1045 | pdev->id, master->num_chipselect); | ||
1046 | dev_dbg(&pdev->dev, "\tIOmem=[0x%x-0x%x]\ | ||
1047 | \tDMA=[Rx-%d, Tx-%d]\n", | ||
1048 | mem_res->end, mem_res->start, | ||
1049 | sdd->rx_dmach, sdd->tx_dmach); | ||
1050 | |||
1051 | return 0; | ||
1052 | |||
1053 | err8: | ||
1054 | destroy_workqueue(sdd->workqueue); | ||
1055 | err7: | ||
1056 | if (sci->src_clk != sdd->clk) | ||
1057 | clk_disable(sci->src_clk); | ||
1058 | err6: | ||
1059 | if (sci->src_clk != sdd->clk) | ||
1060 | clk_put(sci->src_clk); | ||
1061 | err5: | ||
1062 | clk_disable(sdd->clk); | ||
1063 | err4: | ||
1064 | clk_put(sdd->clk); | ||
1065 | err3: | ||
1066 | err2: | ||
1067 | iounmap((void *) sdd->regs); | ||
1068 | err1: | ||
1069 | release_mem_region(mem_res->start, resource_size(mem_res)); | ||
1070 | err0: | ||
1071 | platform_set_drvdata(pdev, NULL); | ||
1072 | spi_master_put(master); | ||
1073 | |||
1074 | return ret; | ||
1075 | } | ||
1076 | |||
1077 | static int s3c64xx_spi_remove(struct platform_device *pdev) | ||
1078 | { | ||
1079 | struct spi_master *master = spi_master_get(platform_get_drvdata(pdev)); | ||
1080 | struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master); | ||
1081 | struct s3c64xx_spi_cntrlr_info *sci = sdd->cntrlr_info; | ||
1082 | struct resource *mem_res; | ||
1083 | unsigned long flags; | ||
1084 | |||
1085 | spin_lock_irqsave(&sdd->lock, flags); | ||
1086 | sdd->state |= SUSPND; | ||
1087 | spin_unlock_irqrestore(&sdd->lock, flags); | ||
1088 | |||
1089 | while (sdd->state & SPIBUSY) | ||
1090 | msleep(10); | ||
1091 | |||
1092 | spi_unregister_master(master); | ||
1093 | |||
1094 | destroy_workqueue(sdd->workqueue); | ||
1095 | |||
1096 | if (sci->src_clk != sdd->clk) | ||
1097 | clk_disable(sci->src_clk); | ||
1098 | |||
1099 | if (sci->src_clk != sdd->clk) | ||
1100 | clk_put(sci->src_clk); | ||
1101 | |||
1102 | clk_disable(sdd->clk); | ||
1103 | clk_put(sdd->clk); | ||
1104 | |||
1105 | iounmap((void *) sdd->regs); | ||
1106 | |||
1107 | mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
1108 | release_mem_region(mem_res->start, resource_size(mem_res)); | ||
1109 | |||
1110 | platform_set_drvdata(pdev, NULL); | ||
1111 | spi_master_put(master); | ||
1112 | |||
1113 | return 0; | ||
1114 | } | ||
1115 | |||
1116 | #ifdef CONFIG_PM | ||
1117 | static int s3c64xx_spi_suspend(struct platform_device *pdev, pm_message_t state) | ||
1118 | { | ||
1119 | struct spi_master *master = spi_master_get(platform_get_drvdata(pdev)); | ||
1120 | struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master); | ||
1121 | struct s3c64xx_spi_cntrlr_info *sci = sdd->cntrlr_info; | ||
1122 | struct s3c64xx_spi_csinfo *cs; | ||
1123 | unsigned long flags; | ||
1124 | |||
1125 | spin_lock_irqsave(&sdd->lock, flags); | ||
1126 | sdd->state |= SUSPND; | ||
1127 | spin_unlock_irqrestore(&sdd->lock, flags); | ||
1128 | |||
1129 | while (sdd->state & SPIBUSY) | ||
1130 | msleep(10); | ||
1131 | |||
1132 | /* Disable the clock */ | ||
1133 | if (sci->src_clk != sdd->clk) | ||
1134 | clk_disable(sci->src_clk); | ||
1135 | |||
1136 | clk_disable(sdd->clk); | ||
1137 | |||
1138 | sdd->cur_speed = 0; /* Output Clock is stopped */ | ||
1139 | |||
1140 | return 0; | ||
1141 | } | ||
1142 | |||
1143 | static int s3c64xx_spi_resume(struct platform_device *pdev) | ||
1144 | { | ||
1145 | struct spi_master *master = spi_master_get(platform_get_drvdata(pdev)); | ||
1146 | struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master); | ||
1147 | struct s3c64xx_spi_cntrlr_info *sci = sdd->cntrlr_info; | ||
1148 | unsigned long flags; | ||
1149 | |||
1150 | sci->cfg_gpio(pdev); | ||
1151 | |||
1152 | /* Enable the clock */ | ||
1153 | if (sci->src_clk != sdd->clk) | ||
1154 | clk_enable(sci->src_clk); | ||
1155 | |||
1156 | clk_enable(sdd->clk); | ||
1157 | |||
1158 | s3c64xx_spi_hwinit(sdd, pdev->id); | ||
1159 | |||
1160 | spin_lock_irqsave(&sdd->lock, flags); | ||
1161 | sdd->state &= ~SUSPND; | ||
1162 | spin_unlock_irqrestore(&sdd->lock, flags); | ||
1163 | |||
1164 | return 0; | ||
1165 | } | ||
1166 | #else | ||
1167 | #define s3c64xx_spi_suspend NULL | ||
1168 | #define s3c64xx_spi_resume NULL | ||
1169 | #endif /* CONFIG_PM */ | ||
1170 | |||
1171 | static struct platform_driver s3c64xx_spi_driver = { | ||
1172 | .driver = { | ||
1173 | .name = "s3c64xx-spi", | ||
1174 | .owner = THIS_MODULE, | ||
1175 | }, | ||
1176 | .remove = s3c64xx_spi_remove, | ||
1177 | .suspend = s3c64xx_spi_suspend, | ||
1178 | .resume = s3c64xx_spi_resume, | ||
1179 | }; | ||
1180 | MODULE_ALIAS("platform:s3c64xx-spi"); | ||
1181 | |||
1182 | static int __init s3c64xx_spi_init(void) | ||
1183 | { | ||
1184 | return platform_driver_probe(&s3c64xx_spi_driver, s3c64xx_spi_probe); | ||
1185 | } | ||
1186 | module_init(s3c64xx_spi_init); | ||
1187 | |||
1188 | static void __exit s3c64xx_spi_exit(void) | ||
1189 | { | ||
1190 | platform_driver_unregister(&s3c64xx_spi_driver); | ||
1191 | } | ||
1192 | module_exit(s3c64xx_spi_exit); | ||
1193 | |||
1194 | MODULE_AUTHOR("Jaswinder Singh <jassi.brar@samsung.com>"); | ||
1195 | MODULE_DESCRIPTION("S3C64XX SPI Controller Driver"); | ||
1196 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/spi/spi_sh_sci.c b/drivers/spi/spi_sh_sci.c index 7d36720eb982..a65c12ffa733 100644 --- a/drivers/spi/spi_sh_sci.c +++ b/drivers/spi/spi_sh_sci.c | |||
@@ -148,7 +148,7 @@ static int sh_sci_spi_probe(struct platform_device *dev) | |||
148 | ret = -ENOENT; | 148 | ret = -ENOENT; |
149 | goto err1; | 149 | goto err1; |
150 | } | 150 | } |
151 | sp->membase = ioremap(r->start, r->end - r->start + 1); | 151 | sp->membase = ioremap(r->start, resource_size(r)); |
152 | if (!sp->membase) { | 152 | if (!sp->membase) { |
153 | ret = -ENXIO; | 153 | ret = -ENXIO; |
154 | goto err1; | 154 | goto err1; |
diff --git a/drivers/spi/spi_txx9.c b/drivers/spi/spi_txx9.c index 19f75627c3de..dfa024b633e1 100644 --- a/drivers/spi/spi_txx9.c +++ b/drivers/spi/spi_txx9.c | |||
@@ -375,12 +375,10 @@ static int __init txx9spi_probe(struct platform_device *dev) | |||
375 | res = platform_get_resource(dev, IORESOURCE_MEM, 0); | 375 | res = platform_get_resource(dev, IORESOURCE_MEM, 0); |
376 | if (!res) | 376 | if (!res) |
377 | goto exit_busy; | 377 | goto exit_busy; |
378 | if (!devm_request_mem_region(&dev->dev, | 378 | if (!devm_request_mem_region(&dev->dev, res->start, resource_size(res), |
379 | res->start, res->end - res->start + 1, | ||
380 | "spi_txx9")) | 379 | "spi_txx9")) |
381 | goto exit_busy; | 380 | goto exit_busy; |
382 | c->membase = devm_ioremap(&dev->dev, | 381 | c->membase = devm_ioremap(&dev->dev, res->start, resource_size(res)); |
383 | res->start, res->end - res->start + 1); | ||
384 | if (!c->membase) | 382 | if (!c->membase) |
385 | goto exit_busy; | 383 | goto exit_busy; |
386 | 384 | ||
diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c index 9c446e6003d5..ea1bec3c9a13 100644 --- a/drivers/spi/spidev.c +++ b/drivers/spi/spidev.c | |||
@@ -53,7 +53,7 @@ | |||
53 | #define SPIDEV_MAJOR 153 /* assigned */ | 53 | #define SPIDEV_MAJOR 153 /* assigned */ |
54 | #define N_SPI_MINORS 32 /* ... up to 256 */ | 54 | #define N_SPI_MINORS 32 /* ... up to 256 */ |
55 | 55 | ||
56 | static unsigned long minors[N_SPI_MINORS / BITS_PER_LONG]; | 56 | static DECLARE_BITMAP(minors, N_SPI_MINORS); |
57 | 57 | ||
58 | 58 | ||
59 | /* Bit masks for spi_device.mode management. Note that incorrect | 59 | /* Bit masks for spi_device.mode management. Note that incorrect |
@@ -558,7 +558,7 @@ static struct class *spidev_class; | |||
558 | 558 | ||
559 | /*-------------------------------------------------------------------------*/ | 559 | /*-------------------------------------------------------------------------*/ |
560 | 560 | ||
561 | static int spidev_probe(struct spi_device *spi) | 561 | static int __devinit spidev_probe(struct spi_device *spi) |
562 | { | 562 | { |
563 | struct spidev_data *spidev; | 563 | struct spidev_data *spidev; |
564 | int status; | 564 | int status; |
@@ -607,7 +607,7 @@ static int spidev_probe(struct spi_device *spi) | |||
607 | return status; | 607 | return status; |
608 | } | 608 | } |
609 | 609 | ||
610 | static int spidev_remove(struct spi_device *spi) | 610 | static int __devexit spidev_remove(struct spi_device *spi) |
611 | { | 611 | { |
612 | struct spidev_data *spidev = spi_get_drvdata(spi); | 612 | struct spidev_data *spidev = spi_get_drvdata(spi); |
613 | 613 | ||
@@ -629,7 +629,7 @@ static int spidev_remove(struct spi_device *spi) | |||
629 | return 0; | 629 | return 0; |
630 | } | 630 | } |
631 | 631 | ||
632 | static struct spi_driver spidev_spi = { | 632 | static struct spi_driver spidev_spi_driver = { |
633 | .driver = { | 633 | .driver = { |
634 | .name = "spidev", | 634 | .name = "spidev", |
635 | .owner = THIS_MODULE, | 635 | .owner = THIS_MODULE, |
@@ -661,14 +661,14 @@ static int __init spidev_init(void) | |||
661 | 661 | ||
662 | spidev_class = class_create(THIS_MODULE, "spidev"); | 662 | spidev_class = class_create(THIS_MODULE, "spidev"); |
663 | if (IS_ERR(spidev_class)) { | 663 | if (IS_ERR(spidev_class)) { |
664 | unregister_chrdev(SPIDEV_MAJOR, spidev_spi.driver.name); | 664 | unregister_chrdev(SPIDEV_MAJOR, spidev_spi_driver.driver.name); |
665 | return PTR_ERR(spidev_class); | 665 | return PTR_ERR(spidev_class); |
666 | } | 666 | } |
667 | 667 | ||
668 | status = spi_register_driver(&spidev_spi); | 668 | status = spi_register_driver(&spidev_spi_driver); |
669 | if (status < 0) { | 669 | if (status < 0) { |
670 | class_destroy(spidev_class); | 670 | class_destroy(spidev_class); |
671 | unregister_chrdev(SPIDEV_MAJOR, spidev_spi.driver.name); | 671 | unregister_chrdev(SPIDEV_MAJOR, spidev_spi_driver.driver.name); |
672 | } | 672 | } |
673 | return status; | 673 | return status; |
674 | } | 674 | } |
@@ -676,9 +676,9 @@ module_init(spidev_init); | |||
676 | 676 | ||
677 | static void __exit spidev_exit(void) | 677 | static void __exit spidev_exit(void) |
678 | { | 678 | { |
679 | spi_unregister_driver(&spidev_spi); | 679 | spi_unregister_driver(&spidev_spi_driver); |
680 | class_destroy(spidev_class); | 680 | class_destroy(spidev_class); |
681 | unregister_chrdev(SPIDEV_MAJOR, spidev_spi.driver.name); | 681 | unregister_chrdev(SPIDEV_MAJOR, spidev_spi_driver.driver.name); |
682 | } | 682 | } |
683 | module_exit(spidev_exit); | 683 | module_exit(spidev_exit); |
684 | 684 | ||
diff --git a/drivers/video/backlight/adp5520_bl.c b/drivers/video/backlight/adp5520_bl.c index 4c10edecfb66..86d95c228adb 100644 --- a/drivers/video/backlight/adp5520_bl.c +++ b/drivers/video/backlight/adp5520_bl.c | |||
@@ -85,7 +85,7 @@ static int adp5520_bl_get_brightness(struct backlight_device *bl) | |||
85 | return error ? data->current_brightness : reg_val; | 85 | return error ? data->current_brightness : reg_val; |
86 | } | 86 | } |
87 | 87 | ||
88 | static struct backlight_ops adp5520_bl_ops = { | 88 | static const struct backlight_ops adp5520_bl_ops = { |
89 | .update_status = adp5520_bl_update_status, | 89 | .update_status = adp5520_bl_update_status, |
90 | .get_brightness = adp5520_bl_get_brightness, | 90 | .get_brightness = adp5520_bl_get_brightness, |
91 | }; | 91 | }; |
diff --git a/drivers/video/backlight/adx_bl.c b/drivers/video/backlight/adx_bl.c index 2c3bdfc620b7..d769b0bab21a 100644 --- a/drivers/video/backlight/adx_bl.c +++ b/drivers/video/backlight/adx_bl.c | |||
@@ -61,7 +61,7 @@ static int adx_backlight_check_fb(struct fb_info *fb) | |||
61 | return 1; | 61 | return 1; |
62 | } | 62 | } |
63 | 63 | ||
64 | static struct backlight_ops adx_backlight_ops = { | 64 | static const struct backlight_ops adx_backlight_ops = { |
65 | .options = 0, | 65 | .options = 0, |
66 | .update_status = adx_backlight_update_status, | 66 | .update_status = adx_backlight_update_status, |
67 | .get_brightness = adx_backlight_get_brightness, | 67 | .get_brightness = adx_backlight_get_brightness, |
diff --git a/drivers/video/backlight/atmel-pwm-bl.c b/drivers/video/backlight/atmel-pwm-bl.c index 2cf7ba52f67c..f625ffc69ad3 100644 --- a/drivers/video/backlight/atmel-pwm-bl.c +++ b/drivers/video/backlight/atmel-pwm-bl.c | |||
@@ -113,7 +113,7 @@ static int atmel_pwm_bl_init_pwm(struct atmel_pwm_bl *pwmbl) | |||
113 | return pwm_channel_enable(&pwmbl->pwmc); | 113 | return pwm_channel_enable(&pwmbl->pwmc); |
114 | } | 114 | } |
115 | 115 | ||
116 | static struct backlight_ops atmel_pwm_bl_ops = { | 116 | static const struct backlight_ops atmel_pwm_bl_ops = { |
117 | .get_brightness = atmel_pwm_bl_get_intensity, | 117 | .get_brightness = atmel_pwm_bl_get_intensity, |
118 | .update_status = atmel_pwm_bl_set_intensity, | 118 | .update_status = atmel_pwm_bl_set_intensity, |
119 | }; | 119 | }; |
diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c index 6615ac7fa60a..18829cf68b1b 100644 --- a/drivers/video/backlight/backlight.c +++ b/drivers/video/backlight/backlight.c | |||
@@ -269,7 +269,7 @@ EXPORT_SYMBOL(backlight_force_update); | |||
269 | * ERR_PTR() or a pointer to the newly allocated device. | 269 | * ERR_PTR() or a pointer to the newly allocated device. |
270 | */ | 270 | */ |
271 | struct backlight_device *backlight_device_register(const char *name, | 271 | struct backlight_device *backlight_device_register(const char *name, |
272 | struct device *parent, void *devdata, struct backlight_ops *ops) | 272 | struct device *parent, void *devdata, const struct backlight_ops *ops) |
273 | { | 273 | { |
274 | struct backlight_device *new_bd; | 274 | struct backlight_device *new_bd; |
275 | int rc; | 275 | int rc; |
diff --git a/drivers/video/backlight/corgi_lcd.c b/drivers/video/backlight/corgi_lcd.c index 96774949cd30..b4bcf8043797 100644 --- a/drivers/video/backlight/corgi_lcd.c +++ b/drivers/video/backlight/corgi_lcd.c | |||
@@ -451,7 +451,7 @@ void corgi_lcd_limit_intensity(int limit) | |||
451 | } | 451 | } |
452 | EXPORT_SYMBOL(corgi_lcd_limit_intensity); | 452 | EXPORT_SYMBOL(corgi_lcd_limit_intensity); |
453 | 453 | ||
454 | static struct backlight_ops corgi_bl_ops = { | 454 | static const struct backlight_ops corgi_bl_ops = { |
455 | .get_brightness = corgi_bl_get_intensity, | 455 | .get_brightness = corgi_bl_get_intensity, |
456 | .update_status = corgi_bl_update_status, | 456 | .update_status = corgi_bl_update_status, |
457 | }; | 457 | }; |
diff --git a/drivers/video/backlight/cr_bllcd.c b/drivers/video/backlight/cr_bllcd.c index b9fe62b475c6..da86db4374a0 100644 --- a/drivers/video/backlight/cr_bllcd.c +++ b/drivers/video/backlight/cr_bllcd.c | |||
@@ -108,7 +108,7 @@ static int cr_backlight_get_intensity(struct backlight_device *bd) | |||
108 | return intensity; | 108 | return intensity; |
109 | } | 109 | } |
110 | 110 | ||
111 | static struct backlight_ops cr_backlight_ops = { | 111 | static const struct backlight_ops cr_backlight_ops = { |
112 | .get_brightness = cr_backlight_get_intensity, | 112 | .get_brightness = cr_backlight_get_intensity, |
113 | .update_status = cr_backlight_set_intensity, | 113 | .update_status = cr_backlight_set_intensity, |
114 | }; | 114 | }; |
@@ -201,7 +201,7 @@ static int cr_backlight_probe(struct platform_device *pdev) | |||
201 | if (IS_ERR(ldp)) { | 201 | if (IS_ERR(ldp)) { |
202 | backlight_device_unregister(bdp); | 202 | backlight_device_unregister(bdp); |
203 | pci_dev_put(lpc_dev); | 203 | pci_dev_put(lpc_dev); |
204 | return PTR_ERR(bdp); | 204 | return PTR_ERR(ldp); |
205 | } | 205 | } |
206 | 206 | ||
207 | pci_read_config_dword(lpc_dev, CRVML_REG_GPIOBAR, | 207 | pci_read_config_dword(lpc_dev, CRVML_REG_GPIOBAR, |
diff --git a/drivers/video/backlight/da903x_bl.c b/drivers/video/backlight/da903x_bl.c index f2d76dae1eb3..74cdc640173d 100644 --- a/drivers/video/backlight/da903x_bl.c +++ b/drivers/video/backlight/da903x_bl.c | |||
@@ -95,7 +95,7 @@ static int da903x_backlight_get_brightness(struct backlight_device *bl) | |||
95 | return data->current_brightness; | 95 | return data->current_brightness; |
96 | } | 96 | } |
97 | 97 | ||
98 | static struct backlight_ops da903x_backlight_ops = { | 98 | static const struct backlight_ops da903x_backlight_ops = { |
99 | .update_status = da903x_backlight_update_status, | 99 | .update_status = da903x_backlight_update_status, |
100 | .get_brightness = da903x_backlight_get_brightness, | 100 | .get_brightness = da903x_backlight_get_brightness, |
101 | }; | 101 | }; |
diff --git a/drivers/video/backlight/generic_bl.c b/drivers/video/backlight/generic_bl.c index 6d27f62fdcd0..e6d348e63596 100644 --- a/drivers/video/backlight/generic_bl.c +++ b/drivers/video/backlight/generic_bl.c | |||
@@ -70,7 +70,7 @@ void corgibl_limit_intensity(int limit) | |||
70 | } | 70 | } |
71 | EXPORT_SYMBOL(corgibl_limit_intensity); | 71 | EXPORT_SYMBOL(corgibl_limit_intensity); |
72 | 72 | ||
73 | static struct backlight_ops genericbl_ops = { | 73 | static const struct backlight_ops genericbl_ops = { |
74 | .options = BL_CORE_SUSPENDRESUME, | 74 | .options = BL_CORE_SUSPENDRESUME, |
75 | .get_brightness = genericbl_get_intensity, | 75 | .get_brightness = genericbl_get_intensity, |
76 | .update_status = genericbl_send_intensity, | 76 | .update_status = genericbl_send_intensity, |
diff --git a/drivers/video/backlight/hp680_bl.c b/drivers/video/backlight/hp680_bl.c index 7fb4eefff80d..f7cc528d5be7 100644 --- a/drivers/video/backlight/hp680_bl.c +++ b/drivers/video/backlight/hp680_bl.c | |||
@@ -98,7 +98,7 @@ static int hp680bl_get_intensity(struct backlight_device *bd) | |||
98 | return current_intensity; | 98 | return current_intensity; |
99 | } | 99 | } |
100 | 100 | ||
101 | static struct backlight_ops hp680bl_ops = { | 101 | static const struct backlight_ops hp680bl_ops = { |
102 | .get_brightness = hp680bl_get_intensity, | 102 | .get_brightness = hp680bl_get_intensity, |
103 | .update_status = hp680bl_set_intensity, | 103 | .update_status = hp680bl_set_intensity, |
104 | }; | 104 | }; |
diff --git a/drivers/video/backlight/jornada720_bl.c b/drivers/video/backlight/jornada720_bl.c index 7aed2565c1bd..db9071fc5665 100644 --- a/drivers/video/backlight/jornada720_bl.c +++ b/drivers/video/backlight/jornada720_bl.c | |||
@@ -93,7 +93,7 @@ out: | |||
93 | return ret; | 93 | return ret; |
94 | } | 94 | } |
95 | 95 | ||
96 | static struct backlight_ops jornada_bl_ops = { | 96 | static const struct backlight_ops jornada_bl_ops = { |
97 | .get_brightness = jornada_bl_get_brightness, | 97 | .get_brightness = jornada_bl_get_brightness, |
98 | .update_status = jornada_bl_update_status, | 98 | .update_status = jornada_bl_update_status, |
99 | .options = BL_CORE_SUSPENDRESUME, | 99 | .options = BL_CORE_SUSPENDRESUME, |
diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c index a38fda1742dd..939e7b830cf3 100644 --- a/drivers/video/backlight/kb3886_bl.c +++ b/drivers/video/backlight/kb3886_bl.c | |||
@@ -134,7 +134,7 @@ static int kb3886bl_get_intensity(struct backlight_device *bd) | |||
134 | return kb3886bl_intensity; | 134 | return kb3886bl_intensity; |
135 | } | 135 | } |
136 | 136 | ||
137 | static struct backlight_ops kb3886bl_ops = { | 137 | static const struct backlight_ops kb3886bl_ops = { |
138 | .get_brightness = kb3886bl_get_intensity, | 138 | .get_brightness = kb3886bl_get_intensity, |
139 | .update_status = kb3886bl_send_intensity, | 139 | .update_status = kb3886bl_send_intensity, |
140 | }; | 140 | }; |
diff --git a/drivers/video/backlight/locomolcd.c b/drivers/video/backlight/locomolcd.c index 6b488b8a7eee..00a9591b0003 100644 --- a/drivers/video/backlight/locomolcd.c +++ b/drivers/video/backlight/locomolcd.c | |||
@@ -141,7 +141,7 @@ static int locomolcd_get_intensity(struct backlight_device *bd) | |||
141 | return current_intensity; | 141 | return current_intensity; |
142 | } | 142 | } |
143 | 143 | ||
144 | static struct backlight_ops locomobl_data = { | 144 | static const struct backlight_ops locomobl_data = { |
145 | .get_brightness = locomolcd_get_intensity, | 145 | .get_brightness = locomolcd_get_intensity, |
146 | .update_status = locomolcd_set_intensity, | 146 | .update_status = locomolcd_set_intensity, |
147 | }; | 147 | }; |
diff --git a/drivers/video/backlight/mbp_nvidia_bl.c b/drivers/video/backlight/mbp_nvidia_bl.c index 9edb8d7c295f..2e78b0784bdc 100644 --- a/drivers/video/backlight/mbp_nvidia_bl.c +++ b/drivers/video/backlight/mbp_nvidia_bl.c | |||
@@ -33,7 +33,7 @@ struct dmi_match_data { | |||
33 | unsigned long iostart; | 33 | unsigned long iostart; |
34 | unsigned long iolen; | 34 | unsigned long iolen; |
35 | /* Backlight operations structure. */ | 35 | /* Backlight operations structure. */ |
36 | struct backlight_ops backlight_ops; | 36 | const struct backlight_ops backlight_ops; |
37 | }; | 37 | }; |
38 | 38 | ||
39 | /* Module parameters. */ | 39 | /* Module parameters. */ |
@@ -220,6 +220,24 @@ static const struct dmi_system_id __initdata mbp_device_table[] = { | |||
220 | }, | 220 | }, |
221 | { | 221 | { |
222 | .callback = mbp_dmi_match, | 222 | .callback = mbp_dmi_match, |
223 | .ident = "MacBookPro 5,3", | ||
224 | .matches = { | ||
225 | DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."), | ||
226 | DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro5,3"), | ||
227 | }, | ||
228 | .driver_data = (void *)&nvidia_chipset_data, | ||
229 | }, | ||
230 | { | ||
231 | .callback = mbp_dmi_match, | ||
232 | .ident = "MacBookPro 5,4", | ||
233 | .matches = { | ||
234 | DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."), | ||
235 | DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro5,4"), | ||
236 | }, | ||
237 | .driver_data = (void *)&nvidia_chipset_data, | ||
238 | }, | ||
239 | { | ||
240 | .callback = mbp_dmi_match, | ||
223 | .ident = "MacBookPro 5,5", | 241 | .ident = "MacBookPro 5,5", |
224 | .matches = { | 242 | .matches = { |
225 | DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."), | 243 | DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."), |
diff --git a/drivers/video/backlight/omap1_bl.c b/drivers/video/backlight/omap1_bl.c index 8693e5fcd2eb..409ca9643528 100644 --- a/drivers/video/backlight/omap1_bl.c +++ b/drivers/video/backlight/omap1_bl.c | |||
@@ -125,7 +125,7 @@ static int omapbl_get_intensity(struct backlight_device *dev) | |||
125 | return bl->current_intensity; | 125 | return bl->current_intensity; |
126 | } | 126 | } |
127 | 127 | ||
128 | static struct backlight_ops omapbl_ops = { | 128 | static const struct backlight_ops omapbl_ops = { |
129 | .get_brightness = omapbl_get_intensity, | 129 | .get_brightness = omapbl_get_intensity, |
130 | .update_status = omapbl_update_status, | 130 | .update_status = omapbl_update_status, |
131 | }; | 131 | }; |
diff --git a/drivers/video/backlight/progear_bl.c b/drivers/video/backlight/progear_bl.c index 9edaf24fd82d..075786e05034 100644 --- a/drivers/video/backlight/progear_bl.c +++ b/drivers/video/backlight/progear_bl.c | |||
@@ -54,7 +54,7 @@ static int progearbl_get_intensity(struct backlight_device *bd) | |||
54 | return intensity - HW_LEVEL_MIN; | 54 | return intensity - HW_LEVEL_MIN; |
55 | } | 55 | } |
56 | 56 | ||
57 | static struct backlight_ops progearbl_ops = { | 57 | static const struct backlight_ops progearbl_ops = { |
58 | .get_brightness = progearbl_get_intensity, | 58 | .get_brightness = progearbl_get_intensity, |
59 | .update_status = progearbl_set_intensity, | 59 | .update_status = progearbl_set_intensity, |
60 | }; | 60 | }; |
diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c index 887166267443..9d2ec2a1cce8 100644 --- a/drivers/video/backlight/pwm_bl.c +++ b/drivers/video/backlight/pwm_bl.c | |||
@@ -22,8 +22,10 @@ | |||
22 | 22 | ||
23 | struct pwm_bl_data { | 23 | struct pwm_bl_data { |
24 | struct pwm_device *pwm; | 24 | struct pwm_device *pwm; |
25 | struct device *dev; | ||
25 | unsigned int period; | 26 | unsigned int period; |
26 | int (*notify)(int brightness); | 27 | int (*notify)(struct device *, |
28 | int brightness); | ||
27 | }; | 29 | }; |
28 | 30 | ||
29 | static int pwm_backlight_update_status(struct backlight_device *bl) | 31 | static int pwm_backlight_update_status(struct backlight_device *bl) |
@@ -39,7 +41,7 @@ static int pwm_backlight_update_status(struct backlight_device *bl) | |||
39 | brightness = 0; | 41 | brightness = 0; |
40 | 42 | ||
41 | if (pb->notify) | 43 | if (pb->notify) |
42 | brightness = pb->notify(brightness); | 44 | brightness = pb->notify(pb->dev, brightness); |
43 | 45 | ||
44 | if (brightness == 0) { | 46 | if (brightness == 0) { |
45 | pwm_config(pb->pwm, 0, pb->period); | 47 | pwm_config(pb->pwm, 0, pb->period); |
@@ -56,7 +58,7 @@ static int pwm_backlight_get_brightness(struct backlight_device *bl) | |||
56 | return bl->props.brightness; | 58 | return bl->props.brightness; |
57 | } | 59 | } |
58 | 60 | ||
59 | static struct backlight_ops pwm_backlight_ops = { | 61 | static const struct backlight_ops pwm_backlight_ops = { |
60 | .update_status = pwm_backlight_update_status, | 62 | .update_status = pwm_backlight_update_status, |
61 | .get_brightness = pwm_backlight_get_brightness, | 63 | .get_brightness = pwm_backlight_get_brightness, |
62 | }; | 64 | }; |
@@ -88,6 +90,7 @@ static int pwm_backlight_probe(struct platform_device *pdev) | |||
88 | 90 | ||
89 | pb->period = data->pwm_period_ns; | 91 | pb->period = data->pwm_period_ns; |
90 | pb->notify = data->notify; | 92 | pb->notify = data->notify; |
93 | pb->dev = &pdev->dev; | ||
91 | 94 | ||
92 | pb->pwm = pwm_request(data->pwm_id, "backlight"); | 95 | pb->pwm = pwm_request(data->pwm_id, "backlight"); |
93 | if (IS_ERR(pb->pwm)) { | 96 | if (IS_ERR(pb->pwm)) { |
@@ -146,7 +149,7 @@ static int pwm_backlight_suspend(struct platform_device *pdev, | |||
146 | struct pwm_bl_data *pb = dev_get_drvdata(&bl->dev); | 149 | struct pwm_bl_data *pb = dev_get_drvdata(&bl->dev); |
147 | 150 | ||
148 | if (pb->notify) | 151 | if (pb->notify) |
149 | pb->notify(0); | 152 | pb->notify(pb->dev, 0); |
150 | pwm_config(pb->pwm, 0, pb->period); | 153 | pwm_config(pb->pwm, 0, pb->period); |
151 | pwm_disable(pb->pwm); | 154 | pwm_disable(pb->pwm); |
152 | return 0; | 155 | return 0; |
diff --git a/drivers/video/backlight/tosa_bl.c b/drivers/video/backlight/tosa_bl.c index 43edbada12d1..e14ce4d469f5 100644 --- a/drivers/video/backlight/tosa_bl.c +++ b/drivers/video/backlight/tosa_bl.c | |||
@@ -72,7 +72,7 @@ static int tosa_bl_get_brightness(struct backlight_device *dev) | |||
72 | return props->brightness; | 72 | return props->brightness; |
73 | } | 73 | } |
74 | 74 | ||
75 | static struct backlight_ops bl_ops = { | 75 | static const struct backlight_ops bl_ops = { |
76 | .get_brightness = tosa_bl_get_brightness, | 76 | .get_brightness = tosa_bl_get_brightness, |
77 | .update_status = tosa_bl_update_status, | 77 | .update_status = tosa_bl_update_status, |
78 | }; | 78 | }; |
diff --git a/drivers/video/backlight/wm831x_bl.c b/drivers/video/backlight/wm831x_bl.c index 467bdb7efb23..e32add37a203 100644 --- a/drivers/video/backlight/wm831x_bl.c +++ b/drivers/video/backlight/wm831x_bl.c | |||
@@ -112,7 +112,7 @@ static int wm831x_backlight_get_brightness(struct backlight_device *bl) | |||
112 | return data->current_brightness; | 112 | return data->current_brightness; |
113 | } | 113 | } |
114 | 114 | ||
115 | static struct backlight_ops wm831x_backlight_ops = { | 115 | static const struct backlight_ops wm831x_backlight_ops = { |
116 | .options = BL_CORE_SUSPENDRESUME, | 116 | .options = BL_CORE_SUSPENDRESUME, |
117 | .update_status = wm831x_backlight_update_status, | 117 | .update_status = wm831x_backlight_update_status, |
118 | .get_brightness = wm831x_backlight_get_brightness, | 118 | .get_brightness = wm831x_backlight_get_brightness, |
diff --git a/drivers/video/via/viafbdev.c b/drivers/video/via/viafbdev.c index 10d8c4b4baeb..d8df17a7d5fc 100644 --- a/drivers/video/via/viafbdev.c +++ b/drivers/video/via/viafbdev.c | |||
@@ -680,7 +680,7 @@ static int viafb_ioctl(struct fb_info *info, u_int cmd, u_long arg) | |||
680 | if (!viafb_gamma_table) | 680 | if (!viafb_gamma_table) |
681 | return -ENOMEM; | 681 | return -ENOMEM; |
682 | if (copy_from_user(viafb_gamma_table, argp, | 682 | if (copy_from_user(viafb_gamma_table, argp, |
683 | sizeof(viafb_gamma_table))) { | 683 | 256 * sizeof(u32))) { |
684 | kfree(viafb_gamma_table); | 684 | kfree(viafb_gamma_table); |
685 | return -EFAULT; | 685 | return -EFAULT; |
686 | } | 686 | } |
@@ -694,7 +694,7 @@ static int viafb_ioctl(struct fb_info *info, u_int cmd, u_long arg) | |||
694 | return -ENOMEM; | 694 | return -ENOMEM; |
695 | viafb_get_gamma_table(viafb_gamma_table); | 695 | viafb_get_gamma_table(viafb_gamma_table); |
696 | if (copy_to_user(argp, viafb_gamma_table, | 696 | if (copy_to_user(argp, viafb_gamma_table, |
697 | sizeof(viafb_gamma_table))) { | 697 | 256 * sizeof(u32))) { |
698 | kfree(viafb_gamma_table); | 698 | kfree(viafb_gamma_table); |
699 | return -EFAULT; | 699 | return -EFAULT; |
700 | } | 700 | } |
diff --git a/fs/Kconfig b/fs/Kconfig index f8fccaaad628..64d44efad7a5 100644 --- a/fs/Kconfig +++ b/fs/Kconfig | |||
@@ -6,10 +6,6 @@ menu "File systems" | |||
6 | 6 | ||
7 | if BLOCK | 7 | if BLOCK |
8 | 8 | ||
9 | config FS_JOURNAL_INFO | ||
10 | bool | ||
11 | default n | ||
12 | |||
13 | source "fs/ext2/Kconfig" | 9 | source "fs/ext2/Kconfig" |
14 | source "fs/ext3/Kconfig" | 10 | source "fs/ext3/Kconfig" |
15 | source "fs/ext4/Kconfig" | 11 | source "fs/ext4/Kconfig" |
diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c index b639dcf7c778..346b69405363 100644 --- a/fs/binfmt_aout.c +++ b/fs/binfmt_aout.c | |||
@@ -32,7 +32,7 @@ | |||
32 | 32 | ||
33 | static int load_aout_binary(struct linux_binprm *, struct pt_regs * regs); | 33 | static int load_aout_binary(struct linux_binprm *, struct pt_regs * regs); |
34 | static int load_aout_library(struct file*); | 34 | static int load_aout_library(struct file*); |
35 | static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file, unsigned long limit); | 35 | static int aout_core_dump(struct coredump_params *cprm); |
36 | 36 | ||
37 | static struct linux_binfmt aout_format = { | 37 | static struct linux_binfmt aout_format = { |
38 | .module = THIS_MODULE, | 38 | .module = THIS_MODULE, |
@@ -89,8 +89,9 @@ if (file->f_op->llseek) { \ | |||
89 | * dumping of the process results in another error.. | 89 | * dumping of the process results in another error.. |
90 | */ | 90 | */ |
91 | 91 | ||
92 | static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file, unsigned long limit) | 92 | static int aout_core_dump(struct coredump_params *cprm) |
93 | { | 93 | { |
94 | struct file *file = cprm->file; | ||
94 | mm_segment_t fs; | 95 | mm_segment_t fs; |
95 | int has_dumped = 0; | 96 | int has_dumped = 0; |
96 | unsigned long dump_start, dump_size; | 97 | unsigned long dump_start, dump_size; |
@@ -108,16 +109,16 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file, u | |||
108 | current->flags |= PF_DUMPCORE; | 109 | current->flags |= PF_DUMPCORE; |
109 | strncpy(dump.u_comm, current->comm, sizeof(dump.u_comm)); | 110 | strncpy(dump.u_comm, current->comm, sizeof(dump.u_comm)); |
110 | dump.u_ar0 = offsetof(struct user, regs); | 111 | dump.u_ar0 = offsetof(struct user, regs); |
111 | dump.signal = signr; | 112 | dump.signal = cprm->signr; |
112 | aout_dump_thread(regs, &dump); | 113 | aout_dump_thread(cprm->regs, &dump); |
113 | 114 | ||
114 | /* If the size of the dump file exceeds the rlimit, then see what would happen | 115 | /* If the size of the dump file exceeds the rlimit, then see what would happen |
115 | if we wrote the stack, but not the data area. */ | 116 | if we wrote the stack, but not the data area. */ |
116 | if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > limit) | 117 | if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit) |
117 | dump.u_dsize = 0; | 118 | dump.u_dsize = 0; |
118 | 119 | ||
119 | /* Make sure we have enough room to write the stack and data areas. */ | 120 | /* Make sure we have enough room to write the stack and data areas. */ |
120 | if ((dump.u_ssize + 1) * PAGE_SIZE > limit) | 121 | if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit) |
121 | dump.u_ssize = 0; | 122 | dump.u_ssize = 0; |
122 | 123 | ||
123 | /* make sure we actually have a data and stack area to dump */ | 124 | /* make sure we actually have a data and stack area to dump */ |
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 97b6e9efeb7f..edd90c49003c 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c | |||
@@ -45,7 +45,7 @@ static unsigned long elf_map(struct file *, unsigned long, struct elf_phdr *, | |||
45 | * don't even try. | 45 | * don't even try. |
46 | */ | 46 | */ |
47 | #ifdef CONFIG_ELF_CORE | 47 | #ifdef CONFIG_ELF_CORE |
48 | static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file, unsigned long limit); | 48 | static int elf_core_dump(struct coredump_params *cprm); |
49 | #else | 49 | #else |
50 | #define elf_core_dump NULL | 50 | #define elf_core_dump NULL |
51 | #endif | 51 | #endif |
@@ -1272,8 +1272,9 @@ static int writenote(struct memelfnote *men, struct file *file, | |||
1272 | } | 1272 | } |
1273 | #undef DUMP_WRITE | 1273 | #undef DUMP_WRITE |
1274 | 1274 | ||
1275 | #define DUMP_WRITE(addr, nr) \ | 1275 | #define DUMP_WRITE(addr, nr) \ |
1276 | if ((size += (nr)) > limit || !dump_write(file, (addr), (nr))) \ | 1276 | if ((size += (nr)) > cprm->limit || \ |
1277 | !dump_write(cprm->file, (addr), (nr))) \ | ||
1277 | goto end_coredump; | 1278 | goto end_coredump; |
1278 | 1279 | ||
1279 | static void fill_elf_header(struct elfhdr *elf, int segs, | 1280 | static void fill_elf_header(struct elfhdr *elf, int segs, |
@@ -1901,7 +1902,7 @@ static struct vm_area_struct *next_vma(struct vm_area_struct *this_vma, | |||
1901 | * and then they are actually written out. If we run out of core limit | 1902 | * and then they are actually written out. If we run out of core limit |
1902 | * we just truncate. | 1903 | * we just truncate. |
1903 | */ | 1904 | */ |
1904 | static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file, unsigned long limit) | 1905 | static int elf_core_dump(struct coredump_params *cprm) |
1905 | { | 1906 | { |
1906 | int has_dumped = 0; | 1907 | int has_dumped = 0; |
1907 | mm_segment_t fs; | 1908 | mm_segment_t fs; |
@@ -1947,7 +1948,7 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file, un | |||
1947 | * notes. This also sets up the file header. | 1948 | * notes. This also sets up the file header. |
1948 | */ | 1949 | */ |
1949 | if (!fill_note_info(elf, segs + 1, /* including notes section */ | 1950 | if (!fill_note_info(elf, segs + 1, /* including notes section */ |
1950 | &info, signr, regs)) | 1951 | &info, cprm->signr, cprm->regs)) |
1951 | goto cleanup; | 1952 | goto cleanup; |
1952 | 1953 | ||
1953 | has_dumped = 1; | 1954 | has_dumped = 1; |
@@ -2009,14 +2010,14 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file, un | |||
2009 | #endif | 2010 | #endif |
2010 | 2011 | ||
2011 | /* write out the notes section */ | 2012 | /* write out the notes section */ |
2012 | if (!write_note_info(&info, file, &foffset)) | 2013 | if (!write_note_info(&info, cprm->file, &foffset)) |
2013 | goto end_coredump; | 2014 | goto end_coredump; |
2014 | 2015 | ||
2015 | if (elf_coredump_extra_notes_write(file, &foffset)) | 2016 | if (elf_coredump_extra_notes_write(cprm->file, &foffset)) |
2016 | goto end_coredump; | 2017 | goto end_coredump; |
2017 | 2018 | ||
2018 | /* Align to page */ | 2019 | /* Align to page */ |
2019 | if (!dump_seek(file, dataoff - foffset)) | 2020 | if (!dump_seek(cprm->file, dataoff - foffset)) |
2020 | goto end_coredump; | 2021 | goto end_coredump; |
2021 | 2022 | ||
2022 | for (vma = first_vma(current, gate_vma); vma != NULL; | 2023 | for (vma = first_vma(current, gate_vma); vma != NULL; |
@@ -2033,12 +2034,13 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file, un | |||
2033 | page = get_dump_page(addr); | 2034 | page = get_dump_page(addr); |
2034 | if (page) { | 2035 | if (page) { |
2035 | void *kaddr = kmap(page); | 2036 | void *kaddr = kmap(page); |
2036 | stop = ((size += PAGE_SIZE) > limit) || | 2037 | stop = ((size += PAGE_SIZE) > cprm->limit) || |
2037 | !dump_write(file, kaddr, PAGE_SIZE); | 2038 | !dump_write(cprm->file, kaddr, |
2039 | PAGE_SIZE); | ||
2038 | kunmap(page); | 2040 | kunmap(page); |
2039 | page_cache_release(page); | 2041 | page_cache_release(page); |
2040 | } else | 2042 | } else |
2041 | stop = !dump_seek(file, PAGE_SIZE); | 2043 | stop = !dump_seek(cprm->file, PAGE_SIZE); |
2042 | if (stop) | 2044 | if (stop) |
2043 | goto end_coredump; | 2045 | goto end_coredump; |
2044 | } | 2046 | } |
diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c index 7b055385db8e..c25256a5c5b0 100644 --- a/fs/binfmt_elf_fdpic.c +++ b/fs/binfmt_elf_fdpic.c | |||
@@ -76,7 +76,7 @@ static int elf_fdpic_map_file_by_direct_mmap(struct elf_fdpic_params *, | |||
76 | struct file *, struct mm_struct *); | 76 | struct file *, struct mm_struct *); |
77 | 77 | ||
78 | #ifdef CONFIG_ELF_CORE | 78 | #ifdef CONFIG_ELF_CORE |
79 | static int elf_fdpic_core_dump(long, struct pt_regs *, struct file *, unsigned long limit); | 79 | static int elf_fdpic_core_dump(struct coredump_params *cprm); |
80 | #endif | 80 | #endif |
81 | 81 | ||
82 | static struct linux_binfmt elf_fdpic_format = { | 82 | static struct linux_binfmt elf_fdpic_format = { |
@@ -1326,8 +1326,9 @@ static int writenote(struct memelfnote *men, struct file *file) | |||
1326 | #undef DUMP_WRITE | 1326 | #undef DUMP_WRITE |
1327 | #undef DUMP_SEEK | 1327 | #undef DUMP_SEEK |
1328 | 1328 | ||
1329 | #define DUMP_WRITE(addr, nr) \ | 1329 | #define DUMP_WRITE(addr, nr) \ |
1330 | if ((size += (nr)) > limit || !dump_write(file, (addr), (nr))) \ | 1330 | if ((size += (nr)) > cprm->limit || \ |
1331 | !dump_write(cprm->file, (addr), (nr))) \ | ||
1331 | goto end_coredump; | 1332 | goto end_coredump; |
1332 | 1333 | ||
1333 | static inline void fill_elf_fdpic_header(struct elfhdr *elf, int segs) | 1334 | static inline void fill_elf_fdpic_header(struct elfhdr *elf, int segs) |
@@ -1582,8 +1583,7 @@ static int elf_fdpic_dump_segments(struct file *file, size_t *size, | |||
1582 | * and then they are actually written out. If we run out of core limit | 1583 | * and then they are actually written out. If we run out of core limit |
1583 | * we just truncate. | 1584 | * we just truncate. |
1584 | */ | 1585 | */ |
1585 | static int elf_fdpic_core_dump(long signr, struct pt_regs *regs, | 1586 | static int elf_fdpic_core_dump(struct coredump_params *cprm) |
1586 | struct file *file, unsigned long limit) | ||
1587 | { | 1587 | { |
1588 | #define NUM_NOTES 6 | 1588 | #define NUM_NOTES 6 |
1589 | int has_dumped = 0; | 1589 | int has_dumped = 0; |
@@ -1642,7 +1642,7 @@ static int elf_fdpic_core_dump(long signr, struct pt_regs *regs, | |||
1642 | goto cleanup; | 1642 | goto cleanup; |
1643 | #endif | 1643 | #endif |
1644 | 1644 | ||
1645 | if (signr) { | 1645 | if (cprm->signr) { |
1646 | struct core_thread *ct; | 1646 | struct core_thread *ct; |
1647 | struct elf_thread_status *tmp; | 1647 | struct elf_thread_status *tmp; |
1648 | 1648 | ||
@@ -1661,14 +1661,14 @@ static int elf_fdpic_core_dump(long signr, struct pt_regs *regs, | |||
1661 | int sz; | 1661 | int sz; |
1662 | 1662 | ||
1663 | tmp = list_entry(t, struct elf_thread_status, list); | 1663 | tmp = list_entry(t, struct elf_thread_status, list); |
1664 | sz = elf_dump_thread_status(signr, tmp); | 1664 | sz = elf_dump_thread_status(cprm->signr, tmp); |
1665 | thread_status_size += sz; | 1665 | thread_status_size += sz; |
1666 | } | 1666 | } |
1667 | } | 1667 | } |
1668 | 1668 | ||
1669 | /* now collect the dump for the current */ | 1669 | /* now collect the dump for the current */ |
1670 | fill_prstatus(prstatus, current, signr); | 1670 | fill_prstatus(prstatus, current, cprm->signr); |
1671 | elf_core_copy_regs(&prstatus->pr_reg, regs); | 1671 | elf_core_copy_regs(&prstatus->pr_reg, cprm->regs); |
1672 | 1672 | ||
1673 | segs = current->mm->map_count; | 1673 | segs = current->mm->map_count; |
1674 | #ifdef ELF_CORE_EXTRA_PHDRS | 1674 | #ifdef ELF_CORE_EXTRA_PHDRS |
@@ -1703,7 +1703,7 @@ static int elf_fdpic_core_dump(long signr, struct pt_regs *regs, | |||
1703 | 1703 | ||
1704 | /* Try to dump the FPU. */ | 1704 | /* Try to dump the FPU. */ |
1705 | if ((prstatus->pr_fpvalid = | 1705 | if ((prstatus->pr_fpvalid = |
1706 | elf_core_copy_task_fpregs(current, regs, fpu))) | 1706 | elf_core_copy_task_fpregs(current, cprm->regs, fpu))) |
1707 | fill_note(notes + numnote++, | 1707 | fill_note(notes + numnote++, |
1708 | "CORE", NT_PRFPREG, sizeof(*fpu), fpu); | 1708 | "CORE", NT_PRFPREG, sizeof(*fpu), fpu); |
1709 | #ifdef ELF_CORE_COPY_XFPREGS | 1709 | #ifdef ELF_CORE_COPY_XFPREGS |
@@ -1774,7 +1774,7 @@ static int elf_fdpic_core_dump(long signr, struct pt_regs *regs, | |||
1774 | 1774 | ||
1775 | /* write out the notes section */ | 1775 | /* write out the notes section */ |
1776 | for (i = 0; i < numnote; i++) | 1776 | for (i = 0; i < numnote; i++) |
1777 | if (!writenote(notes + i, file)) | 1777 | if (!writenote(notes + i, cprm->file)) |
1778 | goto end_coredump; | 1778 | goto end_coredump; |
1779 | 1779 | ||
1780 | /* write out the thread status notes section */ | 1780 | /* write out the thread status notes section */ |
@@ -1783,14 +1783,15 @@ static int elf_fdpic_core_dump(long signr, struct pt_regs *regs, | |||
1783 | list_entry(t, struct elf_thread_status, list); | 1783 | list_entry(t, struct elf_thread_status, list); |
1784 | 1784 | ||
1785 | for (i = 0; i < tmp->num_notes; i++) | 1785 | for (i = 0; i < tmp->num_notes; i++) |
1786 | if (!writenote(&tmp->notes[i], file)) | 1786 | if (!writenote(&tmp->notes[i], cprm->file)) |
1787 | goto end_coredump; | 1787 | goto end_coredump; |
1788 | } | 1788 | } |
1789 | 1789 | ||
1790 | if (!dump_seek(file, dataoff)) | 1790 | if (!dump_seek(cprm->file, dataoff)) |
1791 | goto end_coredump; | 1791 | goto end_coredump; |
1792 | 1792 | ||
1793 | if (elf_fdpic_dump_segments(file, &size, &limit, mm_flags) < 0) | 1793 | if (elf_fdpic_dump_segments(cprm->file, &size, &cprm->limit, |
1794 | mm_flags) < 0) | ||
1794 | goto end_coredump; | 1795 | goto end_coredump; |
1795 | 1796 | ||
1796 | #ifdef ELF_CORE_WRITE_EXTRA_DATA | 1797 | #ifdef ELF_CORE_WRITE_EXTRA_DATA |
diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c index a2796651e756..d4a00ea1054c 100644 --- a/fs/binfmt_flat.c +++ b/fs/binfmt_flat.c | |||
@@ -87,7 +87,7 @@ static int load_flat_shared_library(int id, struct lib_info *p); | |||
87 | #endif | 87 | #endif |
88 | 88 | ||
89 | static int load_flat_binary(struct linux_binprm *, struct pt_regs * regs); | 89 | static int load_flat_binary(struct linux_binprm *, struct pt_regs * regs); |
90 | static int flat_core_dump(long signr, struct pt_regs *regs, struct file *file, unsigned long limit); | 90 | static int flat_core_dump(struct coredump_params *cprm); |
91 | 91 | ||
92 | static struct linux_binfmt flat_format = { | 92 | static struct linux_binfmt flat_format = { |
93 | .module = THIS_MODULE, | 93 | .module = THIS_MODULE, |
@@ -102,10 +102,10 @@ static struct linux_binfmt flat_format = { | |||
102 | * Currently only a stub-function. | 102 | * Currently only a stub-function. |
103 | */ | 103 | */ |
104 | 104 | ||
105 | static int flat_core_dump(long signr, struct pt_regs *regs, struct file *file, unsigned long limit) | 105 | static int flat_core_dump(struct coredump_params *cprm) |
106 | { | 106 | { |
107 | printk("Process %s:%d received signr %d and should have core dumped\n", | 107 | printk("Process %s:%d received signr %d and should have core dumped\n", |
108 | current->comm, current->pid, (int) signr); | 108 | current->comm, current->pid, (int) cprm->signr); |
109 | return(1); | 109 | return(1); |
110 | } | 110 | } |
111 | 111 | ||
diff --git a/fs/binfmt_som.c b/fs/binfmt_som.c index eff74b9c9e77..2a9b5330cc5e 100644 --- a/fs/binfmt_som.c +++ b/fs/binfmt_som.c | |||
@@ -43,7 +43,7 @@ static int load_som_library(struct file *); | |||
43 | * don't even try. | 43 | * don't even try. |
44 | */ | 44 | */ |
45 | #if 0 | 45 | #if 0 |
46 | static int som_core_dump(long signr, struct pt_regs *regs, unsigned long limit); | 46 | static int som_core_dump(struct coredump_params *cprm); |
47 | #else | 47 | #else |
48 | #define som_core_dump NULL | 48 | #define som_core_dump NULL |
49 | #endif | 49 | #endif |
diff --git a/fs/btrfs/Kconfig b/fs/btrfs/Kconfig index 402afe0a0bfb..7bb3c020e570 100644 --- a/fs/btrfs/Kconfig +++ b/fs/btrfs/Kconfig | |||
@@ -4,7 +4,6 @@ config BTRFS_FS | |||
4 | select LIBCRC32C | 4 | select LIBCRC32C |
5 | select ZLIB_INFLATE | 5 | select ZLIB_INFLATE |
6 | select ZLIB_DEFLATE | 6 | select ZLIB_DEFLATE |
7 | select FS_JOURNAL_INFO | ||
8 | help | 7 | help |
9 | Btrfs is a new filesystem with extents, writable snapshotting, | 8 | Btrfs is a new filesystem with extents, writable snapshotting, |
10 | support for multiple devices and many more features. | 9 | support for multiple devices and many more features. |
@@ -826,7 +826,9 @@ static int de_thread(struct task_struct *tsk) | |||
826 | attach_pid(tsk, PIDTYPE_PID, task_pid(leader)); | 826 | attach_pid(tsk, PIDTYPE_PID, task_pid(leader)); |
827 | transfer_pid(leader, tsk, PIDTYPE_PGID); | 827 | transfer_pid(leader, tsk, PIDTYPE_PGID); |
828 | transfer_pid(leader, tsk, PIDTYPE_SID); | 828 | transfer_pid(leader, tsk, PIDTYPE_SID); |
829 | |||
829 | list_replace_rcu(&leader->tasks, &tsk->tasks); | 830 | list_replace_rcu(&leader->tasks, &tsk->tasks); |
831 | list_replace_init(&leader->sibling, &tsk->sibling); | ||
830 | 832 | ||
831 | tsk->group_leader = tsk; | 833 | tsk->group_leader = tsk; |
832 | leader->group_leader = tsk; | 834 | leader->group_leader = tsk; |
@@ -1761,17 +1763,20 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs) | |||
1761 | struct mm_struct *mm = current->mm; | 1763 | struct mm_struct *mm = current->mm; |
1762 | struct linux_binfmt * binfmt; | 1764 | struct linux_binfmt * binfmt; |
1763 | struct inode * inode; | 1765 | struct inode * inode; |
1764 | struct file * file; | ||
1765 | const struct cred *old_cred; | 1766 | const struct cred *old_cred; |
1766 | struct cred *cred; | 1767 | struct cred *cred; |
1767 | int retval = 0; | 1768 | int retval = 0; |
1768 | int flag = 0; | 1769 | int flag = 0; |
1769 | int ispipe = 0; | 1770 | int ispipe = 0; |
1770 | unsigned long core_limit = current->signal->rlim[RLIMIT_CORE].rlim_cur; | ||
1771 | char **helper_argv = NULL; | 1771 | char **helper_argv = NULL; |
1772 | int helper_argc = 0; | 1772 | int helper_argc = 0; |
1773 | int dump_count = 0; | 1773 | int dump_count = 0; |
1774 | static atomic_t core_dump_count = ATOMIC_INIT(0); | 1774 | static atomic_t core_dump_count = ATOMIC_INIT(0); |
1775 | struct coredump_params cprm = { | ||
1776 | .signr = signr, | ||
1777 | .regs = regs, | ||
1778 | .limit = current->signal->rlim[RLIMIT_CORE].rlim_cur, | ||
1779 | }; | ||
1775 | 1780 | ||
1776 | audit_core_dumps(signr); | 1781 | audit_core_dumps(signr); |
1777 | 1782 | ||
@@ -1827,15 +1832,15 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs) | |||
1827 | ispipe = format_corename(corename, signr); | 1832 | ispipe = format_corename(corename, signr); |
1828 | unlock_kernel(); | 1833 | unlock_kernel(); |
1829 | 1834 | ||
1830 | if ((!ispipe) && (core_limit < binfmt->min_coredump)) | 1835 | if ((!ispipe) && (cprm.limit < binfmt->min_coredump)) |
1831 | goto fail_unlock; | 1836 | goto fail_unlock; |
1832 | 1837 | ||
1833 | if (ispipe) { | 1838 | if (ispipe) { |
1834 | if (core_limit == 0) { | 1839 | if (cprm.limit == 0) { |
1835 | /* | 1840 | /* |
1836 | * Normally core limits are irrelevant to pipes, since | 1841 | * Normally core limits are irrelevant to pipes, since |
1837 | * we're not writing to the file system, but we use | 1842 | * we're not writing to the file system, but we use |
1838 | * core_limit of 0 here as a speacial value. Any | 1843 | * cprm.limit of 0 here as a speacial value. Any |
1839 | * non-zero limit gets set to RLIM_INFINITY below, but | 1844 | * non-zero limit gets set to RLIM_INFINITY below, but |
1840 | * a limit of 0 skips the dump. This is a consistent | 1845 | * a limit of 0 skips the dump. This is a consistent |
1841 | * way to catch recursive crashes. We can still crash | 1846 | * way to catch recursive crashes. We can still crash |
@@ -1868,25 +1873,25 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs) | |||
1868 | goto fail_dropcount; | 1873 | goto fail_dropcount; |
1869 | } | 1874 | } |
1870 | 1875 | ||
1871 | core_limit = RLIM_INFINITY; | 1876 | cprm.limit = RLIM_INFINITY; |
1872 | 1877 | ||
1873 | /* SIGPIPE can happen, but it's just never processed */ | 1878 | /* SIGPIPE can happen, but it's just never processed */ |
1874 | if (call_usermodehelper_pipe(helper_argv[0], helper_argv, NULL, | 1879 | if (call_usermodehelper_pipe(helper_argv[0], helper_argv, NULL, |
1875 | &file)) { | 1880 | &cprm.file)) { |
1876 | printk(KERN_INFO "Core dump to %s pipe failed\n", | 1881 | printk(KERN_INFO "Core dump to %s pipe failed\n", |
1877 | corename); | 1882 | corename); |
1878 | goto fail_dropcount; | 1883 | goto fail_dropcount; |
1879 | } | 1884 | } |
1880 | } else | 1885 | } else |
1881 | file = filp_open(corename, | 1886 | cprm.file = filp_open(corename, |
1882 | O_CREAT | 2 | O_NOFOLLOW | O_LARGEFILE | flag, | 1887 | O_CREAT | 2 | O_NOFOLLOW | O_LARGEFILE | flag, |
1883 | 0600); | 1888 | 0600); |
1884 | if (IS_ERR(file)) | 1889 | if (IS_ERR(cprm.file)) |
1885 | goto fail_dropcount; | 1890 | goto fail_dropcount; |
1886 | inode = file->f_path.dentry->d_inode; | 1891 | inode = cprm.file->f_path.dentry->d_inode; |
1887 | if (inode->i_nlink > 1) | 1892 | if (inode->i_nlink > 1) |
1888 | goto close_fail; /* multiple links - don't dump */ | 1893 | goto close_fail; /* multiple links - don't dump */ |
1889 | if (!ispipe && d_unhashed(file->f_path.dentry)) | 1894 | if (!ispipe && d_unhashed(cprm.file->f_path.dentry)) |
1890 | goto close_fail; | 1895 | goto close_fail; |
1891 | 1896 | ||
1892 | /* AK: actually i see no reason to not allow this for named pipes etc., | 1897 | /* AK: actually i see no reason to not allow this for named pipes etc., |
@@ -1899,21 +1904,22 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs) | |||
1899 | */ | 1904 | */ |
1900 | if (inode->i_uid != current_fsuid()) | 1905 | if (inode->i_uid != current_fsuid()) |
1901 | goto close_fail; | 1906 | goto close_fail; |
1902 | if (!file->f_op) | 1907 | if (!cprm.file->f_op) |
1903 | goto close_fail; | 1908 | goto close_fail; |
1904 | if (!file->f_op->write) | 1909 | if (!cprm.file->f_op->write) |
1905 | goto close_fail; | 1910 | goto close_fail; |
1906 | if (!ispipe && do_truncate(file->f_path.dentry, 0, 0, file) != 0) | 1911 | if (!ispipe && |
1912 | do_truncate(cprm.file->f_path.dentry, 0, 0, cprm.file) != 0) | ||
1907 | goto close_fail; | 1913 | goto close_fail; |
1908 | 1914 | ||
1909 | retval = binfmt->core_dump(signr, regs, file, core_limit); | 1915 | retval = binfmt->core_dump(&cprm); |
1910 | 1916 | ||
1911 | if (retval) | 1917 | if (retval) |
1912 | current->signal->group_exit_code |= 0x80; | 1918 | current->signal->group_exit_code |= 0x80; |
1913 | close_fail: | 1919 | close_fail: |
1914 | if (ispipe && core_pipe_limit) | 1920 | if (ispipe && core_pipe_limit) |
1915 | wait_for_dump_helpers(file); | 1921 | wait_for_dump_helpers(cprm.file); |
1916 | filp_close(file, NULL); | 1922 | filp_close(cprm.file, NULL); |
1917 | fail_dropcount: | 1923 | fail_dropcount: |
1918 | if (dump_count) | 1924 | if (dump_count) |
1919 | atomic_dec(&core_dump_count); | 1925 | atomic_dec(&core_dump_count); |
diff --git a/fs/ext4/Kconfig b/fs/ext4/Kconfig index e5f6774846e4..9acf7e808139 100644 --- a/fs/ext4/Kconfig +++ b/fs/ext4/Kconfig | |||
@@ -2,7 +2,6 @@ config EXT4_FS | |||
2 | tristate "The Extended 4 (ext4) filesystem" | 2 | tristate "The Extended 4 (ext4) filesystem" |
3 | select JBD2 | 3 | select JBD2 |
4 | select CRC16 | 4 | select CRC16 |
5 | select FS_JOURNAL_INFO | ||
6 | help | 5 | help |
7 | This is the next generation of the ext3 filesystem. | 6 | This is the next generation of the ext3 filesystem. |
8 | 7 | ||
diff --git a/fs/gfs2/Kconfig b/fs/gfs2/Kconfig index b192c661caa6..4dcddf83326f 100644 --- a/fs/gfs2/Kconfig +++ b/fs/gfs2/Kconfig | |||
@@ -10,7 +10,6 @@ config GFS2_FS | |||
10 | select SLOW_WORK | 10 | select SLOW_WORK |
11 | select QUOTA | 11 | select QUOTA |
12 | select QUOTACTL | 12 | select QUOTACTL |
13 | select FS_JOURNAL_INFO | ||
14 | help | 13 | help |
15 | A cluster filesystem. | 14 | A cluster filesystem. |
16 | 15 | ||
diff --git a/fs/jbd/Kconfig b/fs/jbd/Kconfig index a8408983abd4..4e28beeed157 100644 --- a/fs/jbd/Kconfig +++ b/fs/jbd/Kconfig | |||
@@ -1,6 +1,5 @@ | |||
1 | config JBD | 1 | config JBD |
2 | tristate | 2 | tristate |
3 | select FS_JOURNAL_INFO | ||
4 | help | 3 | help |
5 | This is a generic journalling layer for block devices. It is | 4 | This is a generic journalling layer for block devices. It is |
6 | currently used by the ext3 file system, but it could also be | 5 | currently used by the ext3 file system, but it could also be |
diff --git a/fs/jbd2/Kconfig b/fs/jbd2/Kconfig index 0f7d1ceafdfd..f32f346f4b0a 100644 --- a/fs/jbd2/Kconfig +++ b/fs/jbd2/Kconfig | |||
@@ -1,7 +1,6 @@ | |||
1 | config JBD2 | 1 | config JBD2 |
2 | tristate | 2 | tristate |
3 | select CRC32 | 3 | select CRC32 |
4 | select FS_JOURNAL_INFO | ||
5 | help | 4 | help |
6 | This is a generic journaling layer for block devices that support | 5 | This is a generic journaling layer for block devices that support |
7 | both 32-bit and 64-bit block numbers. It is currently used by | 6 | both 32-bit and 64-bit block numbers. It is currently used by |
diff --git a/fs/namespace.c b/fs/namespace.c index faab1273281e..7d70d63ceb29 100644 --- a/fs/namespace.c +++ b/fs/namespace.c | |||
@@ -2068,7 +2068,7 @@ struct mnt_namespace *copy_mnt_ns(unsigned long flags, struct mnt_namespace *ns, | |||
2068 | * create_mnt_ns - creates a private namespace and adds a root filesystem | 2068 | * create_mnt_ns - creates a private namespace and adds a root filesystem |
2069 | * @mnt: pointer to the new root filesystem mountpoint | 2069 | * @mnt: pointer to the new root filesystem mountpoint |
2070 | */ | 2070 | */ |
2071 | static struct mnt_namespace *create_mnt_ns(struct vfsmount *mnt) | 2071 | struct mnt_namespace *create_mnt_ns(struct vfsmount *mnt) |
2072 | { | 2072 | { |
2073 | struct mnt_namespace *new_ns; | 2073 | struct mnt_namespace *new_ns; |
2074 | 2074 | ||
@@ -2080,6 +2080,7 @@ static struct mnt_namespace *create_mnt_ns(struct vfsmount *mnt) | |||
2080 | } | 2080 | } |
2081 | return new_ns; | 2081 | return new_ns; |
2082 | } | 2082 | } |
2083 | EXPORT_SYMBOL(create_mnt_ns); | ||
2083 | 2084 | ||
2084 | SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name, | 2085 | SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name, |
2085 | char __user *, type, unsigned long, flags, void __user *, data) | 2086 | char __user *, type, unsigned long, flags, void __user *, data) |
diff --git a/fs/nfs/super.c b/fs/nfs/super.c index d5b112bcf3de..ce907efc5508 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c | |||
@@ -2648,13 +2648,21 @@ out_freepage: | |||
2648 | static int nfs_follow_remote_path(struct vfsmount *root_mnt, | 2648 | static int nfs_follow_remote_path(struct vfsmount *root_mnt, |
2649 | const char *export_path, struct vfsmount *mnt_target) | 2649 | const char *export_path, struct vfsmount *mnt_target) |
2650 | { | 2650 | { |
2651 | struct mnt_namespace *ns_private; | ||
2651 | struct nameidata nd; | 2652 | struct nameidata nd; |
2652 | struct super_block *s; | 2653 | struct super_block *s; |
2653 | int ret; | 2654 | int ret; |
2654 | 2655 | ||
2656 | ns_private = create_mnt_ns(root_mnt); | ||
2657 | ret = PTR_ERR(ns_private); | ||
2658 | if (IS_ERR(ns_private)) | ||
2659 | goto out_mntput; | ||
2660 | |||
2655 | ret = vfs_path_lookup(root_mnt->mnt_root, root_mnt, | 2661 | ret = vfs_path_lookup(root_mnt->mnt_root, root_mnt, |
2656 | export_path, LOOKUP_FOLLOW, &nd); | 2662 | export_path, LOOKUP_FOLLOW, &nd); |
2657 | 2663 | ||
2664 | put_mnt_ns(ns_private); | ||
2665 | |||
2658 | if (ret != 0) | 2666 | if (ret != 0) |
2659 | goto out_err; | 2667 | goto out_err; |
2660 | 2668 | ||
diff --git a/fs/nilfs2/Kconfig b/fs/nilfs2/Kconfig index 1225af7b2166..251da07b2a1d 100644 --- a/fs/nilfs2/Kconfig +++ b/fs/nilfs2/Kconfig | |||
@@ -2,7 +2,6 @@ config NILFS2_FS | |||
2 | tristate "NILFS2 file system support (EXPERIMENTAL)" | 2 | tristate "NILFS2 file system support (EXPERIMENTAL)" |
3 | depends on EXPERIMENTAL | 3 | depends on EXPERIMENTAL |
4 | select CRC32 | 4 | select CRC32 |
5 | select FS_JOURNAL_INFO | ||
6 | help | 5 | help |
7 | NILFS2 is a log-structured file system (LFS) supporting continuous | 6 | NILFS2 is a log-structured file system (LFS) supporting continuous |
8 | snapshotting. In addition to versioning capability of the entire | 7 | snapshotting. In addition to versioning capability of the entire |
diff --git a/fs/ramfs/file-nommu.c b/fs/ramfs/file-nommu.c index 32fae4040ebf..2efc57173fd7 100644 --- a/fs/ramfs/file-nommu.c +++ b/fs/ramfs/file-nommu.c | |||
@@ -60,7 +60,7 @@ const struct inode_operations ramfs_file_inode_operations = { | |||
60 | */ | 60 | */ |
61 | int ramfs_nommu_expand_for_mapping(struct inode *inode, size_t newsize) | 61 | int ramfs_nommu_expand_for_mapping(struct inode *inode, size_t newsize) |
62 | { | 62 | { |
63 | unsigned long npages, xpages, loop, limit; | 63 | unsigned long npages, xpages, loop; |
64 | struct page *pages; | 64 | struct page *pages; |
65 | unsigned order; | 65 | unsigned order; |
66 | void *data; | 66 | void *data; |
diff --git a/fs/reiserfs/Kconfig b/fs/reiserfs/Kconfig index ac7cd75c86f8..513f431038f9 100644 --- a/fs/reiserfs/Kconfig +++ b/fs/reiserfs/Kconfig | |||
@@ -1,7 +1,6 @@ | |||
1 | config REISERFS_FS | 1 | config REISERFS_FS |
2 | tristate "Reiserfs support" | 2 | tristate "Reiserfs support" |
3 | select CRC32 | 3 | select CRC32 |
4 | select FS_JOURNAL_INFO | ||
5 | help | 4 | help |
6 | Stores not just filenames but the files themselves in a balanced | 5 | Stores not just filenames but the files themselves in a balanced |
7 | tree. Uses journalling. | 6 | tree. Uses journalling. |
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c index 3a28e7751b3c..290ae38fca8a 100644 --- a/fs/reiserfs/inode.c +++ b/fs/reiserfs/inode.c | |||
@@ -2538,6 +2538,12 @@ static int reiserfs_writepage(struct page *page, struct writeback_control *wbc) | |||
2538 | return reiserfs_write_full_page(page, wbc); | 2538 | return reiserfs_write_full_page(page, wbc); |
2539 | } | 2539 | } |
2540 | 2540 | ||
2541 | static void reiserfs_truncate_failed_write(struct inode *inode) | ||
2542 | { | ||
2543 | truncate_inode_pages(inode->i_mapping, inode->i_size); | ||
2544 | reiserfs_truncate_file(inode, 0); | ||
2545 | } | ||
2546 | |||
2541 | static int reiserfs_write_begin(struct file *file, | 2547 | static int reiserfs_write_begin(struct file *file, |
2542 | struct address_space *mapping, | 2548 | struct address_space *mapping, |
2543 | loff_t pos, unsigned len, unsigned flags, | 2549 | loff_t pos, unsigned len, unsigned flags, |
@@ -2604,6 +2610,8 @@ static int reiserfs_write_begin(struct file *file, | |||
2604 | if (ret) { | 2610 | if (ret) { |
2605 | unlock_page(page); | 2611 | unlock_page(page); |
2606 | page_cache_release(page); | 2612 | page_cache_release(page); |
2613 | /* Truncate allocated blocks */ | ||
2614 | reiserfs_truncate_failed_write(inode); | ||
2607 | } | 2615 | } |
2608 | return ret; | 2616 | return ret; |
2609 | } | 2617 | } |
@@ -2701,9 +2709,7 @@ static int reiserfs_write_end(struct file *file, struct address_space *mapping, | |||
2701 | ** transaction tracking stuff when the size changes. So, we have | 2709 | ** transaction tracking stuff when the size changes. So, we have |
2702 | ** to do the i_size updates here. | 2710 | ** to do the i_size updates here. |
2703 | */ | 2711 | */ |
2704 | pos += copied; | 2712 | if (pos + copied > inode->i_size) { |
2705 | |||
2706 | if (pos > inode->i_size) { | ||
2707 | struct reiserfs_transaction_handle myth; | 2713 | struct reiserfs_transaction_handle myth; |
2708 | lock_depth = reiserfs_write_lock_once(inode->i_sb); | 2714 | lock_depth = reiserfs_write_lock_once(inode->i_sb); |
2709 | locked = true; | 2715 | locked = true; |
@@ -2721,7 +2727,7 @@ static int reiserfs_write_end(struct file *file, struct address_space *mapping, | |||
2721 | goto journal_error; | 2727 | goto journal_error; |
2722 | 2728 | ||
2723 | reiserfs_update_inode_transaction(inode); | 2729 | reiserfs_update_inode_transaction(inode); |
2724 | inode->i_size = pos; | 2730 | inode->i_size = pos + copied; |
2725 | /* | 2731 | /* |
2726 | * this will just nest into our transaction. It's important | 2732 | * this will just nest into our transaction. It's important |
2727 | * to use mark_inode_dirty so the inode gets pushed around on the | 2733 | * to use mark_inode_dirty so the inode gets pushed around on the |
@@ -2751,6 +2757,10 @@ static int reiserfs_write_end(struct file *file, struct address_space *mapping, | |||
2751 | reiserfs_write_unlock_once(inode->i_sb, lock_depth); | 2757 | reiserfs_write_unlock_once(inode->i_sb, lock_depth); |
2752 | unlock_page(page); | 2758 | unlock_page(page); |
2753 | page_cache_release(page); | 2759 | page_cache_release(page); |
2760 | |||
2761 | if (pos + len > inode->i_size) | ||
2762 | reiserfs_truncate_failed_write(inode); | ||
2763 | |||
2754 | return ret == 0 ? copied : ret; | 2764 | return ret == 0 ? copied : ret; |
2755 | 2765 | ||
2756 | journal_error: | 2766 | journal_error: |
diff --git a/include/linux/backlight.h b/include/linux/backlight.h index 0f5f57858a23..8c4f884db6b4 100644 --- a/include/linux/backlight.h +++ b/include/linux/backlight.h | |||
@@ -36,18 +36,18 @@ struct backlight_device; | |||
36 | struct fb_info; | 36 | struct fb_info; |
37 | 37 | ||
38 | struct backlight_ops { | 38 | struct backlight_ops { |
39 | unsigned int options; | 39 | const unsigned int options; |
40 | 40 | ||
41 | #define BL_CORE_SUSPENDRESUME (1 << 0) | 41 | #define BL_CORE_SUSPENDRESUME (1 << 0) |
42 | 42 | ||
43 | /* Notify the backlight driver some property has changed */ | 43 | /* Notify the backlight driver some property has changed */ |
44 | int (*update_status)(struct backlight_device *); | 44 | int (* const update_status)(struct backlight_device *); |
45 | /* Return the current backlight brightness (accounting for power, | 45 | /* Return the current backlight brightness (accounting for power, |
46 | fb_blank etc.) */ | 46 | fb_blank etc.) */ |
47 | int (*get_brightness)(struct backlight_device *); | 47 | int (* const get_brightness)(struct backlight_device *); |
48 | /* Check if given framebuffer device is the one bound to this backlight; | 48 | /* Check if given framebuffer device is the one bound to this backlight; |
49 | return 0 if not, !=0 if it is. If NULL, backlight always matches the fb. */ | 49 | return 0 if not, !=0 if it is. If NULL, backlight always matches the fb. */ |
50 | int (*check_fb)(struct fb_info *); | 50 | int (* const check_fb)(struct fb_info *); |
51 | }; | 51 | }; |
52 | 52 | ||
53 | /* This structure defines all the properties of a backlight */ | 53 | /* This structure defines all the properties of a backlight */ |
@@ -86,7 +86,7 @@ struct backlight_device { | |||
86 | registered this device has been unloaded, and if class_get_devdata() | 86 | registered this device has been unloaded, and if class_get_devdata() |
87 | points to something in the body of that driver, it is also invalid. */ | 87 | points to something in the body of that driver, it is also invalid. */ |
88 | struct mutex ops_lock; | 88 | struct mutex ops_lock; |
89 | struct backlight_ops *ops; | 89 | const struct backlight_ops *ops; |
90 | 90 | ||
91 | /* The framebuffer notifier block */ | 91 | /* The framebuffer notifier block */ |
92 | struct notifier_block fb_notif; | 92 | struct notifier_block fb_notif; |
@@ -103,7 +103,7 @@ static inline void backlight_update_status(struct backlight_device *bd) | |||
103 | } | 103 | } |
104 | 104 | ||
105 | extern struct backlight_device *backlight_device_register(const char *name, | 105 | extern struct backlight_device *backlight_device_register(const char *name, |
106 | struct device *dev, void *devdata, struct backlight_ops *ops); | 106 | struct device *dev, void *devdata, const struct backlight_ops *ops); |
107 | extern void backlight_device_unregister(struct backlight_device *bd); | 107 | extern void backlight_device_unregister(struct backlight_device *bd); |
108 | extern void backlight_force_update(struct backlight_device *bd, | 108 | extern void backlight_force_update(struct backlight_device *bd, |
109 | enum backlight_update_reason reason); | 109 | enum backlight_update_reason reason); |
diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h index aece486ac734..cd4349bdc34e 100644 --- a/include/linux/binfmts.h +++ b/include/linux/binfmts.h | |||
@@ -68,6 +68,14 @@ struct linux_binprm{ | |||
68 | 68 | ||
69 | #define BINPRM_MAX_RECURSION 4 | 69 | #define BINPRM_MAX_RECURSION 4 |
70 | 70 | ||
71 | /* Function parameter for binfmt->coredump */ | ||
72 | struct coredump_params { | ||
73 | long signr; | ||
74 | struct pt_regs *regs; | ||
75 | struct file *file; | ||
76 | unsigned long limit; | ||
77 | }; | ||
78 | |||
71 | /* | 79 | /* |
72 | * This structure defines the functions that are used to load the binary formats that | 80 | * This structure defines the functions that are used to load the binary formats that |
73 | * linux accepts. | 81 | * linux accepts. |
@@ -77,7 +85,7 @@ struct linux_binfmt { | |||
77 | struct module *module; | 85 | struct module *module; |
78 | int (*load_binary)(struct linux_binprm *, struct pt_regs * regs); | 86 | int (*load_binary)(struct linux_binprm *, struct pt_regs * regs); |
79 | int (*load_shlib)(struct file *); | 87 | int (*load_shlib)(struct file *); |
80 | int (*core_dump)(long signr, struct pt_regs *regs, struct file *file, unsigned long limit); | 88 | int (*core_dump)(struct coredump_params *cprm); |
81 | unsigned long min_coredump; /* minimal dump size */ | 89 | unsigned long min_coredump; /* minimal dump size */ |
82 | int hasvdso; | 90 | int hasvdso; |
83 | }; | 91 | }; |
diff --git a/include/linux/init_task.h b/include/linux/init_task.h index 5ed8b9c50355..abec69b63d7e 100644 --- a/include/linux/init_task.h +++ b/include/linux/init_task.h | |||
@@ -111,12 +111,6 @@ extern struct cred init_cred; | |||
111 | # define INIT_PERF_EVENTS(tsk) | 111 | # define INIT_PERF_EVENTS(tsk) |
112 | #endif | 112 | #endif |
113 | 113 | ||
114 | #ifdef CONFIG_FS_JOURNAL_INFO | ||
115 | #define INIT_JOURNAL_INFO .journal_info = NULL, | ||
116 | #else | ||
117 | #define INIT_JOURNAL_INFO | ||
118 | #endif | ||
119 | |||
120 | /* | 114 | /* |
121 | * INIT_TASK is used to set up the first task table, touch at | 115 | * INIT_TASK is used to set up the first task table, touch at |
122 | * your own risk!. Base=0, limit=0x1fffff (=2MB) | 116 | * your own risk!. Base=0, limit=0x1fffff (=2MB) |
@@ -168,6 +162,7 @@ extern struct cred init_cred; | |||
168 | .signal = {{0}}}, \ | 162 | .signal = {{0}}}, \ |
169 | .blocked = {{0}}, \ | 163 | .blocked = {{0}}, \ |
170 | .alloc_lock = __SPIN_LOCK_UNLOCKED(tsk.alloc_lock), \ | 164 | .alloc_lock = __SPIN_LOCK_UNLOCKED(tsk.alloc_lock), \ |
165 | .journal_info = NULL, \ | ||
171 | .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \ | 166 | .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \ |
172 | .fs_excl = ATOMIC_INIT(0), \ | 167 | .fs_excl = ATOMIC_INIT(0), \ |
173 | .pi_lock = __RAW_SPIN_LOCK_UNLOCKED(tsk.pi_lock), \ | 168 | .pi_lock = __RAW_SPIN_LOCK_UNLOCKED(tsk.pi_lock), \ |
@@ -178,7 +173,6 @@ extern struct cred init_cred; | |||
178 | [PIDTYPE_SID] = INIT_PID_LINK(PIDTYPE_SID), \ | 173 | [PIDTYPE_SID] = INIT_PID_LINK(PIDTYPE_SID), \ |
179 | }, \ | 174 | }, \ |
180 | .dirties = INIT_PROP_LOCAL_SINGLE(dirties), \ | 175 | .dirties = INIT_PROP_LOCAL_SINGLE(dirties), \ |
181 | INIT_JOURNAL_INFO \ | ||
182 | INIT_IDS \ | 176 | INIT_IDS \ |
183 | INIT_PERF_EVENTS(tsk) \ | 177 | INIT_PERF_EVENTS(tsk) \ |
184 | INIT_TRACE_IRQFLAGS \ | 178 | INIT_TRACE_IRQFLAGS \ |
diff --git a/include/linux/kmemleak.h b/include/linux/kmemleak.h index 3c7497d46ee9..99d9a6766f7e 100644 --- a/include/linux/kmemleak.h +++ b/include/linux/kmemleak.h | |||
@@ -32,8 +32,7 @@ extern void kmemleak_padding(const void *ptr, unsigned long offset, | |||
32 | size_t size) __ref; | 32 | size_t size) __ref; |
33 | extern void kmemleak_not_leak(const void *ptr) __ref; | 33 | extern void kmemleak_not_leak(const void *ptr) __ref; |
34 | extern void kmemleak_ignore(const void *ptr) __ref; | 34 | extern void kmemleak_ignore(const void *ptr) __ref; |
35 | extern void kmemleak_scan_area(const void *ptr, unsigned long offset, | 35 | extern void kmemleak_scan_area(const void *ptr, size_t size, gfp_t gfp) __ref; |
36 | size_t length, gfp_t gfp) __ref; | ||
37 | extern void kmemleak_no_scan(const void *ptr) __ref; | 36 | extern void kmemleak_no_scan(const void *ptr) __ref; |
38 | 37 | ||
39 | static inline void kmemleak_alloc_recursive(const void *ptr, size_t size, | 38 | static inline void kmemleak_alloc_recursive(const void *ptr, size_t size, |
@@ -84,8 +83,7 @@ static inline void kmemleak_not_leak(const void *ptr) | |||
84 | static inline void kmemleak_ignore(const void *ptr) | 83 | static inline void kmemleak_ignore(const void *ptr) |
85 | { | 84 | { |
86 | } | 85 | } |
87 | static inline void kmemleak_scan_area(const void *ptr, unsigned long offset, | 86 | static inline void kmemleak_scan_area(const void *ptr, size_t size, gfp_t gfp) |
88 | size_t length, gfp_t gfp) | ||
89 | { | 87 | { |
90 | } | 88 | } |
91 | static inline void kmemleak_erase(void **ptr) | 89 | static inline void kmemleak_erase(void **ptr) |
diff --git a/include/linux/leds-lp3944.h b/include/linux/leds-lp3944.h index afc9f9fd70f5..2618aa9063bc 100644 --- a/include/linux/leds-lp3944.h +++ b/include/linux/leds-lp3944.h | |||
@@ -12,9 +12,6 @@ | |||
12 | #ifndef __LINUX_LEDS_LP3944_H | 12 | #ifndef __LINUX_LEDS_LP3944_H |
13 | #define __LINUX_LEDS_LP3944_H | 13 | #define __LINUX_LEDS_LP3944_H |
14 | 14 | ||
15 | #include <linux/leds.h> | ||
16 | #include <linux/workqueue.h> | ||
17 | |||
18 | #define LP3944_LED0 0 | 15 | #define LP3944_LED0 0 |
19 | #define LP3944_LED1 1 | 16 | #define LP3944_LED1 1 |
20 | #define LP3944_LED2 2 | 17 | #define LP3944_LED2 2 |
diff --git a/include/linux/leds-pca9532.h b/include/linux/leds-pca9532.h index 96eea90f01a8..f158eb1149aa 100644 --- a/include/linux/leds-pca9532.h +++ b/include/linux/leds-pca9532.h | |||
@@ -32,7 +32,7 @@ struct pca9532_led { | |||
32 | struct i2c_client *client; | 32 | struct i2c_client *client; |
33 | char *name; | 33 | char *name; |
34 | struct led_classdev ldev; | 34 | struct led_classdev ldev; |
35 | struct work_struct work; | 35 | struct work_struct work; |
36 | enum pca9532_type type; | 36 | enum pca9532_type type; |
37 | enum pca9532_state state; | 37 | enum pca9532_state state; |
38 | }; | 38 | }; |
diff --git a/include/linux/leds-regulator.h b/include/linux/leds-regulator.h new file mode 100644 index 000000000000..5a8eb389aab8 --- /dev/null +++ b/include/linux/leds-regulator.h | |||
@@ -0,0 +1,46 @@ | |||
1 | /* | ||
2 | * leds-regulator.h - platform data structure for regulator driven LEDs. | ||
3 | * | ||
4 | * Copyright (C) 2009 Antonio Ospite <ospite@studenti.unina.it> | ||
5 | * | ||
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 | ||
8 | * published by the Free Software Foundation. | ||
9 | * | ||
10 | */ | ||
11 | |||
12 | #ifndef __LINUX_LEDS_REGULATOR_H | ||
13 | #define __LINUX_LEDS_REGULATOR_H | ||
14 | |||
15 | /* | ||
16 | * Use "vled" as supply id when declaring the regulator consumer: | ||
17 | * | ||
18 | * static struct regulator_consumer_supply pcap_regulator_VVIB_consumers [] = { | ||
19 | * { .dev_name = "leds-regulator.0", supply = "vled" }, | ||
20 | * }; | ||
21 | * | ||
22 | * If you have several regulator driven LEDs, you can append a numerical id to | ||
23 | * .dev_name as done above, and use the same id when declaring the platform | ||
24 | * device: | ||
25 | * | ||
26 | * static struct led_regulator_platform_data a780_vibrator_data = { | ||
27 | * .name = "a780::vibrator", | ||
28 | * }; | ||
29 | * | ||
30 | * static struct platform_device a780_vibrator = { | ||
31 | * .name = "leds-regulator", | ||
32 | * .id = 0, | ||
33 | * .dev = { | ||
34 | * .platform_data = &a780_vibrator_data, | ||
35 | * }, | ||
36 | * }; | ||
37 | */ | ||
38 | |||
39 | #include <linux/leds.h> | ||
40 | |||
41 | struct led_regulator_platform_data { | ||
42 | char *name; /* LED name as expected by LED class */ | ||
43 | enum led_brightness brightness; /* initial brightness value */ | ||
44 | }; | ||
45 | |||
46 | #endif /* __LINUX_LEDS_REGULATOR_H */ | ||
diff --git a/include/linux/mnt_namespace.h b/include/linux/mnt_namespace.h index d9ebf1037dfa..d74785c2393a 100644 --- a/include/linux/mnt_namespace.h +++ b/include/linux/mnt_namespace.h | |||
@@ -23,6 +23,7 @@ struct proc_mounts { | |||
23 | 23 | ||
24 | struct fs_struct; | 24 | struct fs_struct; |
25 | 25 | ||
26 | extern struct mnt_namespace *create_mnt_ns(struct vfsmount *mnt); | ||
26 | extern struct mnt_namespace *copy_mnt_ns(unsigned long, struct mnt_namespace *, | 27 | extern struct mnt_namespace *copy_mnt_ns(unsigned long, struct mnt_namespace *, |
27 | struct fs_struct *); | 28 | struct fs_struct *); |
28 | extern void put_mnt_ns(struct mnt_namespace *ns); | 29 | extern void put_mnt_ns(struct mnt_namespace *ns); |
diff --git a/include/linux/pwm_backlight.h b/include/linux/pwm_backlight.h index 7a9754c96775..01b3d759f1fc 100644 --- a/include/linux/pwm_backlight.h +++ b/include/linux/pwm_backlight.h | |||
@@ -10,7 +10,7 @@ struct platform_pwm_backlight_data { | |||
10 | unsigned int dft_brightness; | 10 | unsigned int dft_brightness; |
11 | unsigned int pwm_period_ns; | 11 | unsigned int pwm_period_ns; |
12 | int (*init)(struct device *dev); | 12 | int (*init)(struct device *dev); |
13 | int (*notify)(int brightness); | 13 | int (*notify)(struct device *dev, int brightness); |
14 | void (*exit)(struct device *dev); | 14 | void (*exit)(struct device *dev); |
15 | }; | 15 | }; |
16 | 16 | ||
diff --git a/include/linux/sched.h b/include/linux/sched.h index 244c287a5ac1..211ed32befbd 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -1446,10 +1446,8 @@ struct task_struct { | |||
1446 | gfp_t lockdep_reclaim_gfp; | 1446 | gfp_t lockdep_reclaim_gfp; |
1447 | #endif | 1447 | #endif |
1448 | 1448 | ||
1449 | #ifdef CONFIG_FS_JOURNAL_INFO | ||
1450 | /* journalling filesystem info */ | 1449 | /* journalling filesystem info */ |
1451 | void *journal_info; | 1450 | void *journal_info; |
1452 | #endif | ||
1453 | 1451 | ||
1454 | /* stacked block device info */ | 1452 | /* stacked block device info */ |
1455 | struct bio *bio_list, **bio_tail; | 1453 | struct bio *bio_list, **bio_tail; |
diff --git a/include/linux/spi/dw_spi.h b/include/linux/spi/dw_spi.h new file mode 100644 index 000000000000..51b3e771a9a3 --- /dev/null +++ b/include/linux/spi/dw_spi.h | |||
@@ -0,0 +1,212 @@ | |||
1 | #ifndef DW_SPI_HEADER_H | ||
2 | #define DW_SPI_HEADER_H | ||
3 | #include <linux/io.h> | ||
4 | |||
5 | /* Bit fields in CTRLR0 */ | ||
6 | #define SPI_DFS_OFFSET 0 | ||
7 | |||
8 | #define SPI_FRF_OFFSET 4 | ||
9 | #define SPI_FRF_SPI 0x0 | ||
10 | #define SPI_FRF_SSP 0x1 | ||
11 | #define SPI_FRF_MICROWIRE 0x2 | ||
12 | #define SPI_FRF_RESV 0x3 | ||
13 | |||
14 | #define SPI_MODE_OFFSET 6 | ||
15 | #define SPI_SCPH_OFFSET 6 | ||
16 | #define SPI_SCOL_OFFSET 7 | ||
17 | #define SPI_TMOD_OFFSET 8 | ||
18 | #define SPI_TMOD_TR 0x0 /* xmit & recv */ | ||
19 | #define SPI_TMOD_TO 0x1 /* xmit only */ | ||
20 | #define SPI_TMOD_RO 0x2 /* recv only */ | ||
21 | #define SPI_TMOD_EPROMREAD 0x3 /* eeprom read mode */ | ||
22 | |||
23 | #define SPI_SLVOE_OFFSET 10 | ||
24 | #define SPI_SRL_OFFSET 11 | ||
25 | #define SPI_CFS_OFFSET 12 | ||
26 | |||
27 | /* Bit fields in SR, 7 bits */ | ||
28 | #define SR_MASK 0x7f /* cover 7 bits */ | ||
29 | #define SR_BUSY (1 << 0) | ||
30 | #define SR_TF_NOT_FULL (1 << 1) | ||
31 | #define SR_TF_EMPT (1 << 2) | ||
32 | #define SR_RF_NOT_EMPT (1 << 3) | ||
33 | #define SR_RF_FULL (1 << 4) | ||
34 | #define SR_TX_ERR (1 << 5) | ||
35 | #define SR_DCOL (1 << 6) | ||
36 | |||
37 | /* Bit fields in ISR, IMR, RISR, 7 bits */ | ||
38 | #define SPI_INT_TXEI (1 << 0) | ||
39 | #define SPI_INT_TXOI (1 << 1) | ||
40 | #define SPI_INT_RXUI (1 << 2) | ||
41 | #define SPI_INT_RXOI (1 << 3) | ||
42 | #define SPI_INT_RXFI (1 << 4) | ||
43 | #define SPI_INT_MSTI (1 << 5) | ||
44 | |||
45 | /* TX RX interrupt level threshhold, max can be 256 */ | ||
46 | #define SPI_INT_THRESHOLD 32 | ||
47 | |||
48 | enum dw_ssi_type { | ||
49 | SSI_MOTO_SPI = 0, | ||
50 | SSI_TI_SSP, | ||
51 | SSI_NS_MICROWIRE, | ||
52 | }; | ||
53 | |||
54 | struct dw_spi_reg { | ||
55 | u32 ctrl0; | ||
56 | u32 ctrl1; | ||
57 | u32 ssienr; | ||
58 | u32 mwcr; | ||
59 | u32 ser; | ||
60 | u32 baudr; | ||
61 | u32 txfltr; | ||
62 | u32 rxfltr; | ||
63 | u32 txflr; | ||
64 | u32 rxflr; | ||
65 | u32 sr; | ||
66 | u32 imr; | ||
67 | u32 isr; | ||
68 | u32 risr; | ||
69 | u32 txoicr; | ||
70 | u32 rxoicr; | ||
71 | u32 rxuicr; | ||
72 | u32 msticr; | ||
73 | u32 icr; | ||
74 | u32 dmacr; | ||
75 | u32 dmatdlr; | ||
76 | u32 dmardlr; | ||
77 | u32 idr; | ||
78 | u32 version; | ||
79 | u32 dr; /* Currently oper as 32 bits, | ||
80 | though only low 16 bits matters */ | ||
81 | } __packed; | ||
82 | |||
83 | struct dw_spi { | ||
84 | struct spi_master *master; | ||
85 | struct spi_device *cur_dev; | ||
86 | struct device *parent_dev; | ||
87 | enum dw_ssi_type type; | ||
88 | |||
89 | void __iomem *regs; | ||
90 | unsigned long paddr; | ||
91 | u32 iolen; | ||
92 | int irq; | ||
93 | u32 max_freq; /* max bus freq supported */ | ||
94 | |||
95 | u16 bus_num; | ||
96 | u16 num_cs; /* supported slave numbers */ | ||
97 | |||
98 | /* Driver message queue */ | ||
99 | struct workqueue_struct *workqueue; | ||
100 | struct work_struct pump_messages; | ||
101 | spinlock_t lock; | ||
102 | struct list_head queue; | ||
103 | int busy; | ||
104 | int run; | ||
105 | |||
106 | /* Message Transfer pump */ | ||
107 | struct tasklet_struct pump_transfers; | ||
108 | |||
109 | /* Current message transfer state info */ | ||
110 | struct spi_message *cur_msg; | ||
111 | struct spi_transfer *cur_transfer; | ||
112 | struct chip_data *cur_chip; | ||
113 | struct chip_data *prev_chip; | ||
114 | size_t len; | ||
115 | void *tx; | ||
116 | void *tx_end; | ||
117 | void *rx; | ||
118 | void *rx_end; | ||
119 | int dma_mapped; | ||
120 | dma_addr_t rx_dma; | ||
121 | dma_addr_t tx_dma; | ||
122 | size_t rx_map_len; | ||
123 | size_t tx_map_len; | ||
124 | u8 n_bytes; /* current is a 1/2 bytes op */ | ||
125 | u8 max_bits_per_word; /* maxim is 16b */ | ||
126 | u32 dma_width; | ||
127 | int cs_change; | ||
128 | int (*write)(struct dw_spi *dws); | ||
129 | int (*read)(struct dw_spi *dws); | ||
130 | irqreturn_t (*transfer_handler)(struct dw_spi *dws); | ||
131 | void (*cs_control)(u32 command); | ||
132 | |||
133 | /* Dma info */ | ||
134 | int dma_inited; | ||
135 | struct dma_chan *txchan; | ||
136 | struct dma_chan *rxchan; | ||
137 | int txdma_done; | ||
138 | int rxdma_done; | ||
139 | u64 tx_param; | ||
140 | u64 rx_param; | ||
141 | struct device *dma_dev; | ||
142 | dma_addr_t dma_addr; | ||
143 | |||
144 | /* Bus interface info */ | ||
145 | void *priv; | ||
146 | #ifdef CONFIG_DEBUG_FS | ||
147 | struct dentry *debugfs; | ||
148 | #endif | ||
149 | }; | ||
150 | |||
151 | #define dw_readl(dw, name) \ | ||
152 | __raw_readl(&(((struct dw_spi_reg *)dw->regs)->name)) | ||
153 | #define dw_writel(dw, name, val) \ | ||
154 | __raw_writel((val), &(((struct dw_spi_reg *)dw->regs)->name)) | ||
155 | #define dw_readw(dw, name) \ | ||
156 | __raw_readw(&(((struct dw_spi_reg *)dw->regs)->name)) | ||
157 | #define dw_writew(dw, name, val) \ | ||
158 | __raw_writew((val), &(((struct dw_spi_reg *)dw->regs)->name)) | ||
159 | |||
160 | static inline void spi_enable_chip(struct dw_spi *dws, int enable) | ||
161 | { | ||
162 | dw_writel(dws, ssienr, (enable ? 1 : 0)); | ||
163 | } | ||
164 | |||
165 | static inline void spi_set_clk(struct dw_spi *dws, u16 div) | ||
166 | { | ||
167 | dw_writel(dws, baudr, div); | ||
168 | } | ||
169 | |||
170 | static inline void spi_chip_sel(struct dw_spi *dws, u16 cs) | ||
171 | { | ||
172 | if (cs > dws->num_cs) | ||
173 | return; | ||
174 | dw_writel(dws, ser, 1 << cs); | ||
175 | } | ||
176 | |||
177 | /* Disable IRQ bits */ | ||
178 | static inline void spi_mask_intr(struct dw_spi *dws, u32 mask) | ||
179 | { | ||
180 | u32 new_mask; | ||
181 | |||
182 | new_mask = dw_readl(dws, imr) & ~mask; | ||
183 | dw_writel(dws, imr, new_mask); | ||
184 | } | ||
185 | |||
186 | /* Enable IRQ bits */ | ||
187 | static inline void spi_umask_intr(struct dw_spi *dws, u32 mask) | ||
188 | { | ||
189 | u32 new_mask; | ||
190 | |||
191 | new_mask = dw_readl(dws, imr) | mask; | ||
192 | dw_writel(dws, imr, new_mask); | ||
193 | } | ||
194 | |||
195 | /* | ||
196 | * Each SPI slave device to work with dw_api controller should | ||
197 | * has such a structure claiming its working mode (PIO/DMA etc), | ||
198 | * which can be save in the "controller_data" member of the | ||
199 | * struct spi_device | ||
200 | */ | ||
201 | struct dw_spi_chip { | ||
202 | u8 poll_mode; /* 0 for contoller polling mode */ | ||
203 | u8 type; /* SPI/SSP/Micrwire */ | ||
204 | u8 enable_dma; | ||
205 | void (*cs_control)(u32 command); | ||
206 | }; | ||
207 | |||
208 | extern int dw_spi_add_host(struct dw_spi *dws); | ||
209 | extern void dw_spi_remove_host(struct dw_spi *dws); | ||
210 | extern int dw_spi_suspend_host(struct dw_spi *dws); | ||
211 | extern int dw_spi_resume_host(struct dw_spi *dws); | ||
212 | #endif /* DW_SPI_HEADER_H */ | ||
diff --git a/include/linux/vt.h b/include/linux/vt.h index 3fb9944e50a6..d5dd0bc408fd 100644 --- a/include/linux/vt.h +++ b/include/linux/vt.h | |||
@@ -84,6 +84,8 @@ struct vt_setactivate { | |||
84 | 84 | ||
85 | #define VT_SETACTIVATE 0x560F /* Activate and set the mode of a console */ | 85 | #define VT_SETACTIVATE 0x560F /* Activate and set the mode of a console */ |
86 | 86 | ||
87 | #ifdef __KERNEL__ | ||
88 | |||
87 | #ifdef CONFIG_VT_CONSOLE | 89 | #ifdef CONFIG_VT_CONSOLE |
88 | 90 | ||
89 | extern int vt_kmsg_redirect(int new); | 91 | extern int vt_kmsg_redirect(int new); |
@@ -97,6 +99,8 @@ static inline int vt_kmsg_redirect(int new) | |||
97 | 99 | ||
98 | #endif | 100 | #endif |
99 | 101 | ||
102 | #endif /* __KERNEL__ */ | ||
103 | |||
100 | #define vt_get_kmsg_redirect() vt_kmsg_redirect(-1) | 104 | #define vt_get_kmsg_redirect() vt_kmsg_redirect(-1) |
101 | 105 | ||
102 | #endif /* _LINUX_VT_H */ | 106 | #endif /* _LINUX_VT_H */ |
diff --git a/kernel/exit.c b/kernel/exit.c index 5962d7ccf243..546774a31a66 100644 --- a/kernel/exit.c +++ b/kernel/exit.c | |||
@@ -68,10 +68,10 @@ static void __unhash_process(struct task_struct *p) | |||
68 | detach_pid(p, PIDTYPE_SID); | 68 | detach_pid(p, PIDTYPE_SID); |
69 | 69 | ||
70 | list_del_rcu(&p->tasks); | 70 | list_del_rcu(&p->tasks); |
71 | list_del_init(&p->sibling); | ||
71 | __get_cpu_var(process_counts)--; | 72 | __get_cpu_var(process_counts)--; |
72 | } | 73 | } |
73 | list_del_rcu(&p->thread_group); | 74 | list_del_rcu(&p->thread_group); |
74 | list_del_init(&p->sibling); | ||
75 | } | 75 | } |
76 | 76 | ||
77 | /* | 77 | /* |
@@ -736,12 +736,9 @@ static struct task_struct *find_new_reaper(struct task_struct *father) | |||
736 | /* | 736 | /* |
737 | * Any that need to be release_task'd are put on the @dead list. | 737 | * Any that need to be release_task'd are put on the @dead list. |
738 | */ | 738 | */ |
739 | static void reparent_thread(struct task_struct *father, struct task_struct *p, | 739 | static void reparent_leader(struct task_struct *father, struct task_struct *p, |
740 | struct list_head *dead) | 740 | struct list_head *dead) |
741 | { | 741 | { |
742 | if (p->pdeath_signal) | ||
743 | group_send_sig_info(p->pdeath_signal, SEND_SIG_NOINFO, p); | ||
744 | |||
745 | list_move_tail(&p->sibling, &p->real_parent->children); | 742 | list_move_tail(&p->sibling, &p->real_parent->children); |
746 | 743 | ||
747 | if (task_detached(p)) | 744 | if (task_detached(p)) |
@@ -780,12 +777,18 @@ static void forget_original_parent(struct task_struct *father) | |||
780 | reaper = find_new_reaper(father); | 777 | reaper = find_new_reaper(father); |
781 | 778 | ||
782 | list_for_each_entry_safe(p, n, &father->children, sibling) { | 779 | list_for_each_entry_safe(p, n, &father->children, sibling) { |
783 | p->real_parent = reaper; | 780 | struct task_struct *t = p; |
784 | if (p->parent == father) { | 781 | do { |
785 | BUG_ON(task_ptrace(p)); | 782 | t->real_parent = reaper; |
786 | p->parent = p->real_parent; | 783 | if (t->parent == father) { |
787 | } | 784 | BUG_ON(task_ptrace(t)); |
788 | reparent_thread(father, p, &dead_children); | 785 | t->parent = t->real_parent; |
786 | } | ||
787 | if (t->pdeath_signal) | ||
788 | group_send_sig_info(t->pdeath_signal, | ||
789 | SEND_SIG_NOINFO, t); | ||
790 | } while_each_thread(p, t); | ||
791 | reparent_leader(father, p, &dead_children); | ||
789 | } | 792 | } |
790 | write_unlock_irq(&tasklist_lock); | 793 | write_unlock_irq(&tasklist_lock); |
791 | 794 | ||
@@ -1551,14 +1554,9 @@ static int do_wait_thread(struct wait_opts *wo, struct task_struct *tsk) | |||
1551 | struct task_struct *p; | 1554 | struct task_struct *p; |
1552 | 1555 | ||
1553 | list_for_each_entry(p, &tsk->children, sibling) { | 1556 | list_for_each_entry(p, &tsk->children, sibling) { |
1554 | /* | 1557 | int ret = wait_consider_task(wo, 0, p); |
1555 | * Do not consider detached threads. | 1558 | if (ret) |
1556 | */ | 1559 | return ret; |
1557 | if (!task_detached(p)) { | ||
1558 | int ret = wait_consider_task(wo, 0, p); | ||
1559 | if (ret) | ||
1560 | return ret; | ||
1561 | } | ||
1562 | } | 1560 | } |
1563 | 1561 | ||
1564 | return 0; | 1562 | return 0; |
diff --git a/kernel/fork.c b/kernel/fork.c index 202a0ba63d3c..5b2959b3ffc2 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -1291,7 +1291,6 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
1291 | } | 1291 | } |
1292 | 1292 | ||
1293 | if (likely(p->pid)) { | 1293 | if (likely(p->pid)) { |
1294 | list_add_tail(&p->sibling, &p->real_parent->children); | ||
1295 | tracehook_finish_clone(p, clone_flags, trace); | 1294 | tracehook_finish_clone(p, clone_flags, trace); |
1296 | 1295 | ||
1297 | if (thread_group_leader(p)) { | 1296 | if (thread_group_leader(p)) { |
@@ -1303,6 +1302,7 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
1303 | p->signal->tty = tty_kref_get(current->signal->tty); | 1302 | p->signal->tty = tty_kref_get(current->signal->tty); |
1304 | attach_pid(p, PIDTYPE_PGID, task_pgrp(current)); | 1303 | attach_pid(p, PIDTYPE_PGID, task_pgrp(current)); |
1305 | attach_pid(p, PIDTYPE_SID, task_session(current)); | 1304 | attach_pid(p, PIDTYPE_SID, task_session(current)); |
1305 | list_add_tail(&p->sibling, &p->real_parent->children); | ||
1306 | list_add_tail_rcu(&p->tasks, &init_task.tasks); | 1306 | list_add_tail_rcu(&p->tasks, &init_task.tasks); |
1307 | __get_cpu_var(process_counts)++; | 1307 | __get_cpu_var(process_counts)++; |
1308 | } | 1308 | } |
diff --git a/kernel/module.c b/kernel/module.c index a65dc787a27b..e96b8ed1cb6a 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
@@ -1910,9 +1910,7 @@ static void kmemleak_load_module(struct module *mod, Elf_Ehdr *hdr, | |||
1910 | unsigned int i; | 1910 | unsigned int i; |
1911 | 1911 | ||
1912 | /* only scan the sections containing data */ | 1912 | /* only scan the sections containing data */ |
1913 | kmemleak_scan_area(mod->module_core, (unsigned long)mod - | 1913 | kmemleak_scan_area(mod, sizeof(struct module), GFP_KERNEL); |
1914 | (unsigned long)mod->module_core, | ||
1915 | sizeof(struct module), GFP_KERNEL); | ||
1916 | 1914 | ||
1917 | for (i = 1; i < hdr->e_shnum; i++) { | 1915 | for (i = 1; i < hdr->e_shnum; i++) { |
1918 | if (!(sechdrs[i].sh_flags & SHF_ALLOC)) | 1916 | if (!(sechdrs[i].sh_flags & SHF_ALLOC)) |
@@ -1921,8 +1919,7 @@ static void kmemleak_load_module(struct module *mod, Elf_Ehdr *hdr, | |||
1921 | && strncmp(secstrings + sechdrs[i].sh_name, ".bss", 4) != 0) | 1919 | && strncmp(secstrings + sechdrs[i].sh_name, ".bss", 4) != 0) |
1922 | continue; | 1920 | continue; |
1923 | 1921 | ||
1924 | kmemleak_scan_area(mod->module_core, sechdrs[i].sh_addr - | 1922 | kmemleak_scan_area((void *)sechdrs[i].sh_addr, |
1925 | (unsigned long)mod->module_core, | ||
1926 | sechdrs[i].sh_size, GFP_KERNEL); | 1923 | sechdrs[i].sh_size, GFP_KERNEL); |
1927 | } | 1924 | } |
1928 | } | 1925 | } |
@@ -2250,6 +2247,12 @@ static noinline struct module *load_module(void __user *umod, | |||
2250 | "_ftrace_events", | 2247 | "_ftrace_events", |
2251 | sizeof(*mod->trace_events), | 2248 | sizeof(*mod->trace_events), |
2252 | &mod->num_trace_events); | 2249 | &mod->num_trace_events); |
2250 | /* | ||
2251 | * This section contains pointers to allocated objects in the trace | ||
2252 | * code and not scanning it leads to false positives. | ||
2253 | */ | ||
2254 | kmemleak_scan_area(mod->trace_events, sizeof(*mod->trace_events) * | ||
2255 | mod->num_trace_events, GFP_KERNEL); | ||
2253 | #endif | 2256 | #endif |
2254 | #ifdef CONFIG_FTRACE_MCOUNT_RECORD | 2257 | #ifdef CONFIG_FTRACE_MCOUNT_RECORD |
2255 | /* sechdrs[0].sh_size is always zero */ | 2258 | /* sechdrs[0].sh_size is always zero */ |
diff --git a/kernel/printk.c b/kernel/printk.c index 1ded8e7dd19b..17463ca2e229 100644 --- a/kernel/printk.c +++ b/kernel/printk.c | |||
@@ -1412,7 +1412,7 @@ static LIST_HEAD(dump_list); | |||
1412 | 1412 | ||
1413 | /** | 1413 | /** |
1414 | * kmsg_dump_register - register a kernel log dumper. | 1414 | * kmsg_dump_register - register a kernel log dumper. |
1415 | * @dump: pointer to the kmsg_dumper structure | 1415 | * @dumper: pointer to the kmsg_dumper structure |
1416 | * | 1416 | * |
1417 | * Adds a kernel log dumper to the system. The dump callback in the | 1417 | * Adds a kernel log dumper to the system. The dump callback in the |
1418 | * structure will be called when the kernel oopses or panics and must be | 1418 | * structure will be called when the kernel oopses or panics and must be |
@@ -1442,7 +1442,7 @@ EXPORT_SYMBOL_GPL(kmsg_dump_register); | |||
1442 | 1442 | ||
1443 | /** | 1443 | /** |
1444 | * kmsg_dump_unregister - unregister a kmsg dumper. | 1444 | * kmsg_dump_unregister - unregister a kmsg dumper. |
1445 | * @dump: pointer to the kmsg_dumper structure | 1445 | * @dumper: pointer to the kmsg_dumper structure |
1446 | * | 1446 | * |
1447 | * Removes a dump device from the system. Returns zero on success and | 1447 | * Removes a dump device from the system. Returns zero on success and |
1448 | * %-EINVAL otherwise. | 1448 | * %-EINVAL otherwise. |
diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 45e4bef0012a..6665761c006d 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c | |||
@@ -1131,7 +1131,7 @@ static struct ctl_table vm_table[] = { | |||
1131 | .data = &sysctl_max_map_count, | 1131 | .data = &sysctl_max_map_count, |
1132 | .maxlen = sizeof(sysctl_max_map_count), | 1132 | .maxlen = sizeof(sysctl_max_map_count), |
1133 | .mode = 0644, | 1133 | .mode = 0644, |
1134 | .proc_handler = proc_dointvec, | 1134 | .proc_handler = proc_dointvec_minmax, |
1135 | .extra1 = &zero, | 1135 | .extra1 = &zero, |
1136 | }, | 1136 | }, |
1137 | #else | 1137 | #else |
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 8cf9938dd147..25c3ed594c54 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug | |||
@@ -360,6 +360,7 @@ config DEBUG_KMEMLEAK | |||
360 | select DEBUG_FS if SYSFS | 360 | select DEBUG_FS if SYSFS |
361 | select STACKTRACE if STACKTRACE_SUPPORT | 361 | select STACKTRACE if STACKTRACE_SUPPORT |
362 | select KALLSYMS | 362 | select KALLSYMS |
363 | select CRC32 | ||
363 | help | 364 | help |
364 | Say Y here if you want to enable the memory leak | 365 | Say Y here if you want to enable the memory leak |
365 | detector. The memory allocation/freeing is traced in a way | 366 | detector. The memory allocation/freeing is traced in a way |
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 735343fc857a..d4996cf46eb6 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c | |||
@@ -1179,7 +1179,18 @@ qualifier: | |||
1179 | * %ps output the name of a text symbol without offset | 1179 | * %ps output the name of a text symbol without offset |
1180 | * %pF output the name of a function pointer with its offset | 1180 | * %pF output the name of a function pointer with its offset |
1181 | * %pf output the name of a function pointer without its offset | 1181 | * %pf output the name of a function pointer without its offset |
1182 | * %pR output the address range in a struct resource | 1182 | * %pR output the address range in a struct resource with decoded flags |
1183 | * %pr output the address range in a struct resource with raw flags | ||
1184 | * %pM output a 6-byte MAC address with colons | ||
1185 | * %pm output a 6-byte MAC address without colons | ||
1186 | * %pI4 print an IPv4 address without leading zeros | ||
1187 | * %pi4 print an IPv4 address with leading zeros | ||
1188 | * %pI6 print an IPv6 address with colons | ||
1189 | * %pi6 print an IPv6 address without colons | ||
1190 | * %pI6c print an IPv6 address as specified by | ||
1191 | * http://www.ietf.org/id/draft-kawamura-ipv6-text-representation-03.txt | ||
1192 | * %pU[bBlL] print a UUID/GUID in big or little endian using lower or upper | ||
1193 | * case. | ||
1183 | * %n is ignored | 1194 | * %n is ignored |
1184 | * | 1195 | * |
1185 | * The return value is the number of characters which would | 1196 | * The return value is the number of characters which would |
diff --git a/mm/kmemleak.c b/mm/kmemleak.c index 13f33b3081ec..5b069e4f5e48 100644 --- a/mm/kmemleak.c +++ b/mm/kmemleak.c | |||
@@ -93,6 +93,7 @@ | |||
93 | #include <linux/nodemask.h> | 93 | #include <linux/nodemask.h> |
94 | #include <linux/mm.h> | 94 | #include <linux/mm.h> |
95 | #include <linux/workqueue.h> | 95 | #include <linux/workqueue.h> |
96 | #include <linux/crc32.h> | ||
96 | 97 | ||
97 | #include <asm/sections.h> | 98 | #include <asm/sections.h> |
98 | #include <asm/processor.h> | 99 | #include <asm/processor.h> |
@@ -108,7 +109,6 @@ | |||
108 | #define MSECS_MIN_AGE 5000 /* minimum object age for reporting */ | 109 | #define MSECS_MIN_AGE 5000 /* minimum object age for reporting */ |
109 | #define SECS_FIRST_SCAN 60 /* delay before the first scan */ | 110 | #define SECS_FIRST_SCAN 60 /* delay before the first scan */ |
110 | #define SECS_SCAN_WAIT 600 /* subsequent auto scanning delay */ | 111 | #define SECS_SCAN_WAIT 600 /* subsequent auto scanning delay */ |
111 | #define GRAY_LIST_PASSES 25 /* maximum number of gray list scans */ | ||
112 | #define MAX_SCAN_SIZE 4096 /* maximum size of a scanned block */ | 112 | #define MAX_SCAN_SIZE 4096 /* maximum size of a scanned block */ |
113 | 113 | ||
114 | #define BYTES_PER_POINTER sizeof(void *) | 114 | #define BYTES_PER_POINTER sizeof(void *) |
@@ -119,8 +119,8 @@ | |||
119 | /* scanning area inside a memory block */ | 119 | /* scanning area inside a memory block */ |
120 | struct kmemleak_scan_area { | 120 | struct kmemleak_scan_area { |
121 | struct hlist_node node; | 121 | struct hlist_node node; |
122 | unsigned long offset; | 122 | unsigned long start; |
123 | size_t length; | 123 | size_t size; |
124 | }; | 124 | }; |
125 | 125 | ||
126 | #define KMEMLEAK_GREY 0 | 126 | #define KMEMLEAK_GREY 0 |
@@ -149,6 +149,8 @@ struct kmemleak_object { | |||
149 | int min_count; | 149 | int min_count; |
150 | /* the total number of pointers found pointing to this object */ | 150 | /* the total number of pointers found pointing to this object */ |
151 | int count; | 151 | int count; |
152 | /* checksum for detecting modified objects */ | ||
153 | u32 checksum; | ||
152 | /* memory ranges to be scanned inside an object (empty for all) */ | 154 | /* memory ranges to be scanned inside an object (empty for all) */ |
153 | struct hlist_head area_list; | 155 | struct hlist_head area_list; |
154 | unsigned long trace[MAX_TRACE]; | 156 | unsigned long trace[MAX_TRACE]; |
@@ -164,8 +166,6 @@ struct kmemleak_object { | |||
164 | #define OBJECT_REPORTED (1 << 1) | 166 | #define OBJECT_REPORTED (1 << 1) |
165 | /* flag set to not scan the object */ | 167 | /* flag set to not scan the object */ |
166 | #define OBJECT_NO_SCAN (1 << 2) | 168 | #define OBJECT_NO_SCAN (1 << 2) |
167 | /* flag set on newly allocated objects */ | ||
168 | #define OBJECT_NEW (1 << 3) | ||
169 | 169 | ||
170 | /* number of bytes to print per line; must be 16 or 32 */ | 170 | /* number of bytes to print per line; must be 16 or 32 */ |
171 | #define HEX_ROW_SIZE 16 | 171 | #define HEX_ROW_SIZE 16 |
@@ -241,8 +241,6 @@ struct early_log { | |||
241 | const void *ptr; /* allocated/freed memory block */ | 241 | const void *ptr; /* allocated/freed memory block */ |
242 | size_t size; /* memory block size */ | 242 | size_t size; /* memory block size */ |
243 | int min_count; /* minimum reference count */ | 243 | int min_count; /* minimum reference count */ |
244 | unsigned long offset; /* scan area offset */ | ||
245 | size_t length; /* scan area length */ | ||
246 | unsigned long trace[MAX_TRACE]; /* stack trace */ | 244 | unsigned long trace[MAX_TRACE]; /* stack trace */ |
247 | unsigned int trace_len; /* stack trace length */ | 245 | unsigned int trace_len; /* stack trace length */ |
248 | }; | 246 | }; |
@@ -323,11 +321,6 @@ static bool color_gray(const struct kmemleak_object *object) | |||
323 | object->count >= object->min_count; | 321 | object->count >= object->min_count; |
324 | } | 322 | } |
325 | 323 | ||
326 | static bool color_black(const struct kmemleak_object *object) | ||
327 | { | ||
328 | return object->min_count == KMEMLEAK_BLACK; | ||
329 | } | ||
330 | |||
331 | /* | 324 | /* |
332 | * Objects are considered unreferenced only if their color is white, they have | 325 | * Objects are considered unreferenced only if their color is white, they have |
333 | * not be deleted and have a minimum age to avoid false positives caused by | 326 | * not be deleted and have a minimum age to avoid false positives caused by |
@@ -335,7 +328,7 @@ static bool color_black(const struct kmemleak_object *object) | |||
335 | */ | 328 | */ |
336 | static bool unreferenced_object(struct kmemleak_object *object) | 329 | static bool unreferenced_object(struct kmemleak_object *object) |
337 | { | 330 | { |
338 | return (object->flags & OBJECT_ALLOCATED) && color_white(object) && | 331 | return (color_white(object) && object->flags & OBJECT_ALLOCATED) && |
339 | time_before_eq(object->jiffies + jiffies_min_age, | 332 | time_before_eq(object->jiffies + jiffies_min_age, |
340 | jiffies_last_scan); | 333 | jiffies_last_scan); |
341 | } | 334 | } |
@@ -348,11 +341,13 @@ static void print_unreferenced(struct seq_file *seq, | |||
348 | struct kmemleak_object *object) | 341 | struct kmemleak_object *object) |
349 | { | 342 | { |
350 | int i; | 343 | int i; |
344 | unsigned int msecs_age = jiffies_to_msecs(jiffies - object->jiffies); | ||
351 | 345 | ||
352 | seq_printf(seq, "unreferenced object 0x%08lx (size %zu):\n", | 346 | seq_printf(seq, "unreferenced object 0x%08lx (size %zu):\n", |
353 | object->pointer, object->size); | 347 | object->pointer, object->size); |
354 | seq_printf(seq, " comm \"%s\", pid %d, jiffies %lu\n", | 348 | seq_printf(seq, " comm \"%s\", pid %d, jiffies %lu (age %d.%03ds)\n", |
355 | object->comm, object->pid, object->jiffies); | 349 | object->comm, object->pid, object->jiffies, |
350 | msecs_age / 1000, msecs_age % 1000); | ||
356 | hex_dump_object(seq, object); | 351 | hex_dump_object(seq, object); |
357 | seq_printf(seq, " backtrace:\n"); | 352 | seq_printf(seq, " backtrace:\n"); |
358 | 353 | ||
@@ -381,6 +376,7 @@ static void dump_object_info(struct kmemleak_object *object) | |||
381 | pr_notice(" min_count = %d\n", object->min_count); | 376 | pr_notice(" min_count = %d\n", object->min_count); |
382 | pr_notice(" count = %d\n", object->count); | 377 | pr_notice(" count = %d\n", object->count); |
383 | pr_notice(" flags = 0x%lx\n", object->flags); | 378 | pr_notice(" flags = 0x%lx\n", object->flags); |
379 | pr_notice(" checksum = %d\n", object->checksum); | ||
384 | pr_notice(" backtrace:\n"); | 380 | pr_notice(" backtrace:\n"); |
385 | print_stack_trace(&trace, 4); | 381 | print_stack_trace(&trace, 4); |
386 | } | 382 | } |
@@ -522,12 +518,13 @@ static struct kmemleak_object *create_object(unsigned long ptr, size_t size, | |||
522 | INIT_HLIST_HEAD(&object->area_list); | 518 | INIT_HLIST_HEAD(&object->area_list); |
523 | spin_lock_init(&object->lock); | 519 | spin_lock_init(&object->lock); |
524 | atomic_set(&object->use_count, 1); | 520 | atomic_set(&object->use_count, 1); |
525 | object->flags = OBJECT_ALLOCATED | OBJECT_NEW; | 521 | object->flags = OBJECT_ALLOCATED; |
526 | object->pointer = ptr; | 522 | object->pointer = ptr; |
527 | object->size = size; | 523 | object->size = size; |
528 | object->min_count = min_count; | 524 | object->min_count = min_count; |
529 | object->count = -1; /* no color initially */ | 525 | object->count = 0; /* white color initially */ |
530 | object->jiffies = jiffies; | 526 | object->jiffies = jiffies; |
527 | object->checksum = 0; | ||
531 | 528 | ||
532 | /* task information */ | 529 | /* task information */ |
533 | if (in_irq()) { | 530 | if (in_irq()) { |
@@ -720,14 +717,13 @@ static void make_black_object(unsigned long ptr) | |||
720 | * Add a scanning area to the object. If at least one such area is added, | 717 | * Add a scanning area to the object. If at least one such area is added, |
721 | * kmemleak will only scan these ranges rather than the whole memory block. | 718 | * kmemleak will only scan these ranges rather than the whole memory block. |
722 | */ | 719 | */ |
723 | static void add_scan_area(unsigned long ptr, unsigned long offset, | 720 | static void add_scan_area(unsigned long ptr, size_t size, gfp_t gfp) |
724 | size_t length, gfp_t gfp) | ||
725 | { | 721 | { |
726 | unsigned long flags; | 722 | unsigned long flags; |
727 | struct kmemleak_object *object; | 723 | struct kmemleak_object *object; |
728 | struct kmemleak_scan_area *area; | 724 | struct kmemleak_scan_area *area; |
729 | 725 | ||
730 | object = find_and_get_object(ptr, 0); | 726 | object = find_and_get_object(ptr, 1); |
731 | if (!object) { | 727 | if (!object) { |
732 | kmemleak_warn("Adding scan area to unknown object at 0x%08lx\n", | 728 | kmemleak_warn("Adding scan area to unknown object at 0x%08lx\n", |
733 | ptr); | 729 | ptr); |
@@ -741,7 +737,7 @@ static void add_scan_area(unsigned long ptr, unsigned long offset, | |||
741 | } | 737 | } |
742 | 738 | ||
743 | spin_lock_irqsave(&object->lock, flags); | 739 | spin_lock_irqsave(&object->lock, flags); |
744 | if (offset + length > object->size) { | 740 | if (ptr + size > object->pointer + object->size) { |
745 | kmemleak_warn("Scan area larger than object 0x%08lx\n", ptr); | 741 | kmemleak_warn("Scan area larger than object 0x%08lx\n", ptr); |
746 | dump_object_info(object); | 742 | dump_object_info(object); |
747 | kmem_cache_free(scan_area_cache, area); | 743 | kmem_cache_free(scan_area_cache, area); |
@@ -749,8 +745,8 @@ static void add_scan_area(unsigned long ptr, unsigned long offset, | |||
749 | } | 745 | } |
750 | 746 | ||
751 | INIT_HLIST_NODE(&area->node); | 747 | INIT_HLIST_NODE(&area->node); |
752 | area->offset = offset; | 748 | area->start = ptr; |
753 | area->length = length; | 749 | area->size = size; |
754 | 750 | ||
755 | hlist_add_head(&area->node, &object->area_list); | 751 | hlist_add_head(&area->node, &object->area_list); |
756 | out_unlock: | 752 | out_unlock: |
@@ -786,7 +782,7 @@ static void object_no_scan(unsigned long ptr) | |||
786 | * processed later once kmemleak is fully initialized. | 782 | * processed later once kmemleak is fully initialized. |
787 | */ | 783 | */ |
788 | static void __init log_early(int op_type, const void *ptr, size_t size, | 784 | static void __init log_early(int op_type, const void *ptr, size_t size, |
789 | int min_count, unsigned long offset, size_t length) | 785 | int min_count) |
790 | { | 786 | { |
791 | unsigned long flags; | 787 | unsigned long flags; |
792 | struct early_log *log; | 788 | struct early_log *log; |
@@ -808,8 +804,6 @@ static void __init log_early(int op_type, const void *ptr, size_t size, | |||
808 | log->ptr = ptr; | 804 | log->ptr = ptr; |
809 | log->size = size; | 805 | log->size = size; |
810 | log->min_count = min_count; | 806 | log->min_count = min_count; |
811 | log->offset = offset; | ||
812 | log->length = length; | ||
813 | if (op_type == KMEMLEAK_ALLOC) | 807 | if (op_type == KMEMLEAK_ALLOC) |
814 | log->trace_len = __save_stack_trace(log->trace); | 808 | log->trace_len = __save_stack_trace(log->trace); |
815 | crt_early_log++; | 809 | crt_early_log++; |
@@ -858,7 +852,7 @@ void __ref kmemleak_alloc(const void *ptr, size_t size, int min_count, | |||
858 | if (atomic_read(&kmemleak_enabled) && ptr && !IS_ERR(ptr)) | 852 | if (atomic_read(&kmemleak_enabled) && ptr && !IS_ERR(ptr)) |
859 | create_object((unsigned long)ptr, size, min_count, gfp); | 853 | create_object((unsigned long)ptr, size, min_count, gfp); |
860 | else if (atomic_read(&kmemleak_early_log)) | 854 | else if (atomic_read(&kmemleak_early_log)) |
861 | log_early(KMEMLEAK_ALLOC, ptr, size, min_count, 0, 0); | 855 | log_early(KMEMLEAK_ALLOC, ptr, size, min_count); |
862 | } | 856 | } |
863 | EXPORT_SYMBOL_GPL(kmemleak_alloc); | 857 | EXPORT_SYMBOL_GPL(kmemleak_alloc); |
864 | 858 | ||
@@ -873,7 +867,7 @@ void __ref kmemleak_free(const void *ptr) | |||
873 | if (atomic_read(&kmemleak_enabled) && ptr && !IS_ERR(ptr)) | 867 | if (atomic_read(&kmemleak_enabled) && ptr && !IS_ERR(ptr)) |
874 | delete_object_full((unsigned long)ptr); | 868 | delete_object_full((unsigned long)ptr); |
875 | else if (atomic_read(&kmemleak_early_log)) | 869 | else if (atomic_read(&kmemleak_early_log)) |
876 | log_early(KMEMLEAK_FREE, ptr, 0, 0, 0, 0); | 870 | log_early(KMEMLEAK_FREE, ptr, 0, 0); |
877 | } | 871 | } |
878 | EXPORT_SYMBOL_GPL(kmemleak_free); | 872 | EXPORT_SYMBOL_GPL(kmemleak_free); |
879 | 873 | ||
@@ -888,7 +882,7 @@ void __ref kmemleak_free_part(const void *ptr, size_t size) | |||
888 | if (atomic_read(&kmemleak_enabled) && ptr && !IS_ERR(ptr)) | 882 | if (atomic_read(&kmemleak_enabled) && ptr && !IS_ERR(ptr)) |
889 | delete_object_part((unsigned long)ptr, size); | 883 | delete_object_part((unsigned long)ptr, size); |
890 | else if (atomic_read(&kmemleak_early_log)) | 884 | else if (atomic_read(&kmemleak_early_log)) |
891 | log_early(KMEMLEAK_FREE_PART, ptr, size, 0, 0, 0); | 885 | log_early(KMEMLEAK_FREE_PART, ptr, size, 0); |
892 | } | 886 | } |
893 | EXPORT_SYMBOL_GPL(kmemleak_free_part); | 887 | EXPORT_SYMBOL_GPL(kmemleak_free_part); |
894 | 888 | ||
@@ -903,7 +897,7 @@ void __ref kmemleak_not_leak(const void *ptr) | |||
903 | if (atomic_read(&kmemleak_enabled) && ptr && !IS_ERR(ptr)) | 897 | if (atomic_read(&kmemleak_enabled) && ptr && !IS_ERR(ptr)) |
904 | make_gray_object((unsigned long)ptr); | 898 | make_gray_object((unsigned long)ptr); |
905 | else if (atomic_read(&kmemleak_early_log)) | 899 | else if (atomic_read(&kmemleak_early_log)) |
906 | log_early(KMEMLEAK_NOT_LEAK, ptr, 0, 0, 0, 0); | 900 | log_early(KMEMLEAK_NOT_LEAK, ptr, 0, 0); |
907 | } | 901 | } |
908 | EXPORT_SYMBOL(kmemleak_not_leak); | 902 | EXPORT_SYMBOL(kmemleak_not_leak); |
909 | 903 | ||
@@ -919,22 +913,21 @@ void __ref kmemleak_ignore(const void *ptr) | |||
919 | if (atomic_read(&kmemleak_enabled) && ptr && !IS_ERR(ptr)) | 913 | if (atomic_read(&kmemleak_enabled) && ptr && !IS_ERR(ptr)) |
920 | make_black_object((unsigned long)ptr); | 914 | make_black_object((unsigned long)ptr); |
921 | else if (atomic_read(&kmemleak_early_log)) | 915 | else if (atomic_read(&kmemleak_early_log)) |
922 | log_early(KMEMLEAK_IGNORE, ptr, 0, 0, 0, 0); | 916 | log_early(KMEMLEAK_IGNORE, ptr, 0, 0); |
923 | } | 917 | } |
924 | EXPORT_SYMBOL(kmemleak_ignore); | 918 | EXPORT_SYMBOL(kmemleak_ignore); |
925 | 919 | ||
926 | /* | 920 | /* |
927 | * Limit the range to be scanned in an allocated memory block. | 921 | * Limit the range to be scanned in an allocated memory block. |
928 | */ | 922 | */ |
929 | void __ref kmemleak_scan_area(const void *ptr, unsigned long offset, | 923 | void __ref kmemleak_scan_area(const void *ptr, size_t size, gfp_t gfp) |
930 | size_t length, gfp_t gfp) | ||
931 | { | 924 | { |
932 | pr_debug("%s(0x%p)\n", __func__, ptr); | 925 | pr_debug("%s(0x%p)\n", __func__, ptr); |
933 | 926 | ||
934 | if (atomic_read(&kmemleak_enabled) && ptr && !IS_ERR(ptr)) | 927 | if (atomic_read(&kmemleak_enabled) && ptr && !IS_ERR(ptr)) |
935 | add_scan_area((unsigned long)ptr, offset, length, gfp); | 928 | add_scan_area((unsigned long)ptr, size, gfp); |
936 | else if (atomic_read(&kmemleak_early_log)) | 929 | else if (atomic_read(&kmemleak_early_log)) |
937 | log_early(KMEMLEAK_SCAN_AREA, ptr, 0, 0, offset, length); | 930 | log_early(KMEMLEAK_SCAN_AREA, ptr, size, 0); |
938 | } | 931 | } |
939 | EXPORT_SYMBOL(kmemleak_scan_area); | 932 | EXPORT_SYMBOL(kmemleak_scan_area); |
940 | 933 | ||
@@ -948,11 +941,25 @@ void __ref kmemleak_no_scan(const void *ptr) | |||
948 | if (atomic_read(&kmemleak_enabled) && ptr && !IS_ERR(ptr)) | 941 | if (atomic_read(&kmemleak_enabled) && ptr && !IS_ERR(ptr)) |
949 | object_no_scan((unsigned long)ptr); | 942 | object_no_scan((unsigned long)ptr); |
950 | else if (atomic_read(&kmemleak_early_log)) | 943 | else if (atomic_read(&kmemleak_early_log)) |
951 | log_early(KMEMLEAK_NO_SCAN, ptr, 0, 0, 0, 0); | 944 | log_early(KMEMLEAK_NO_SCAN, ptr, 0, 0); |
952 | } | 945 | } |
953 | EXPORT_SYMBOL(kmemleak_no_scan); | 946 | EXPORT_SYMBOL(kmemleak_no_scan); |
954 | 947 | ||
955 | /* | 948 | /* |
949 | * Update an object's checksum and return true if it was modified. | ||
950 | */ | ||
951 | static bool update_checksum(struct kmemleak_object *object) | ||
952 | { | ||
953 | u32 old_csum = object->checksum; | ||
954 | |||
955 | if (!kmemcheck_is_obj_initialized(object->pointer, object->size)) | ||
956 | return false; | ||
957 | |||
958 | object->checksum = crc32(0, (void *)object->pointer, object->size); | ||
959 | return object->checksum != old_csum; | ||
960 | } | ||
961 | |||
962 | /* | ||
956 | * Memory scanning is a long process and it needs to be interruptable. This | 963 | * Memory scanning is a long process and it needs to be interruptable. This |
957 | * function checks whether such interrupt condition occured. | 964 | * function checks whether such interrupt condition occured. |
958 | */ | 965 | */ |
@@ -1031,11 +1038,14 @@ static void scan_block(void *_start, void *_end, | |||
1031 | * added to the gray_list. | 1038 | * added to the gray_list. |
1032 | */ | 1039 | */ |
1033 | object->count++; | 1040 | object->count++; |
1034 | if (color_gray(object)) | 1041 | if (color_gray(object)) { |
1035 | list_add_tail(&object->gray_list, &gray_list); | 1042 | list_add_tail(&object->gray_list, &gray_list); |
1036 | else | 1043 | spin_unlock_irqrestore(&object->lock, flags); |
1037 | put_object(object); | 1044 | continue; |
1045 | } | ||
1046 | |||
1038 | spin_unlock_irqrestore(&object->lock, flags); | 1047 | spin_unlock_irqrestore(&object->lock, flags); |
1048 | put_object(object); | ||
1039 | } | 1049 | } |
1040 | } | 1050 | } |
1041 | 1051 | ||
@@ -1075,14 +1085,47 @@ static void scan_object(struct kmemleak_object *object) | |||
1075 | } | 1085 | } |
1076 | } else | 1086 | } else |
1077 | hlist_for_each_entry(area, elem, &object->area_list, node) | 1087 | hlist_for_each_entry(area, elem, &object->area_list, node) |
1078 | scan_block((void *)(object->pointer + area->offset), | 1088 | scan_block((void *)area->start, |
1079 | (void *)(object->pointer + area->offset | 1089 | (void *)(area->start + area->size), |
1080 | + area->length), object, 0); | 1090 | object, 0); |
1081 | out: | 1091 | out: |
1082 | spin_unlock_irqrestore(&object->lock, flags); | 1092 | spin_unlock_irqrestore(&object->lock, flags); |
1083 | } | 1093 | } |
1084 | 1094 | ||
1085 | /* | 1095 | /* |
1096 | * Scan the objects already referenced (gray objects). More objects will be | ||
1097 | * referenced and, if there are no memory leaks, all the objects are scanned. | ||
1098 | */ | ||
1099 | static void scan_gray_list(void) | ||
1100 | { | ||
1101 | struct kmemleak_object *object, *tmp; | ||
1102 | |||
1103 | /* | ||
1104 | * The list traversal is safe for both tail additions and removals | ||
1105 | * from inside the loop. The kmemleak objects cannot be freed from | ||
1106 | * outside the loop because their use_count was incremented. | ||
1107 | */ | ||
1108 | object = list_entry(gray_list.next, typeof(*object), gray_list); | ||
1109 | while (&object->gray_list != &gray_list) { | ||
1110 | cond_resched(); | ||
1111 | |||
1112 | /* may add new objects to the list */ | ||
1113 | if (!scan_should_stop()) | ||
1114 | scan_object(object); | ||
1115 | |||
1116 | tmp = list_entry(object->gray_list.next, typeof(*object), | ||
1117 | gray_list); | ||
1118 | |||
1119 | /* remove the object from the list and release it */ | ||
1120 | list_del(&object->gray_list); | ||
1121 | put_object(object); | ||
1122 | |||
1123 | object = tmp; | ||
1124 | } | ||
1125 | WARN_ON(!list_empty(&gray_list)); | ||
1126 | } | ||
1127 | |||
1128 | /* | ||
1086 | * Scan data sections and all the referenced memory blocks allocated via the | 1129 | * Scan data sections and all the referenced memory blocks allocated via the |
1087 | * kernel's standard allocators. This function must be called with the | 1130 | * kernel's standard allocators. This function must be called with the |
1088 | * scan_mutex held. | 1131 | * scan_mutex held. |
@@ -1090,10 +1133,9 @@ out: | |||
1090 | static void kmemleak_scan(void) | 1133 | static void kmemleak_scan(void) |
1091 | { | 1134 | { |
1092 | unsigned long flags; | 1135 | unsigned long flags; |
1093 | struct kmemleak_object *object, *tmp; | 1136 | struct kmemleak_object *object; |
1094 | int i; | 1137 | int i; |
1095 | int new_leaks = 0; | 1138 | int new_leaks = 0; |
1096 | int gray_list_pass = 0; | ||
1097 | 1139 | ||
1098 | jiffies_last_scan = jiffies; | 1140 | jiffies_last_scan = jiffies; |
1099 | 1141 | ||
@@ -1114,7 +1156,6 @@ static void kmemleak_scan(void) | |||
1114 | #endif | 1156 | #endif |
1115 | /* reset the reference count (whiten the object) */ | 1157 | /* reset the reference count (whiten the object) */ |
1116 | object->count = 0; | 1158 | object->count = 0; |
1117 | object->flags &= ~OBJECT_NEW; | ||
1118 | if (color_gray(object) && get_object(object)) | 1159 | if (color_gray(object) && get_object(object)) |
1119 | list_add_tail(&object->gray_list, &gray_list); | 1160 | list_add_tail(&object->gray_list, &gray_list); |
1120 | 1161 | ||
@@ -1172,62 +1213,36 @@ static void kmemleak_scan(void) | |||
1172 | 1213 | ||
1173 | /* | 1214 | /* |
1174 | * Scan the objects already referenced from the sections scanned | 1215 | * Scan the objects already referenced from the sections scanned |
1175 | * above. More objects will be referenced and, if there are no memory | 1216 | * above. |
1176 | * leaks, all the objects will be scanned. The list traversal is safe | ||
1177 | * for both tail additions and removals from inside the loop. The | ||
1178 | * kmemleak objects cannot be freed from outside the loop because their | ||
1179 | * use_count was increased. | ||
1180 | */ | 1217 | */ |
1181 | repeat: | 1218 | scan_gray_list(); |
1182 | object = list_entry(gray_list.next, typeof(*object), gray_list); | ||
1183 | while (&object->gray_list != &gray_list) { | ||
1184 | cond_resched(); | ||
1185 | |||
1186 | /* may add new objects to the list */ | ||
1187 | if (!scan_should_stop()) | ||
1188 | scan_object(object); | ||
1189 | |||
1190 | tmp = list_entry(object->gray_list.next, typeof(*object), | ||
1191 | gray_list); | ||
1192 | |||
1193 | /* remove the object from the list and release it */ | ||
1194 | list_del(&object->gray_list); | ||
1195 | put_object(object); | ||
1196 | |||
1197 | object = tmp; | ||
1198 | } | ||
1199 | |||
1200 | if (scan_should_stop() || ++gray_list_pass >= GRAY_LIST_PASSES) | ||
1201 | goto scan_end; | ||
1202 | 1219 | ||
1203 | /* | 1220 | /* |
1204 | * Check for new objects allocated during this scanning and add them | 1221 | * Check for new or unreferenced objects modified since the previous |
1205 | * to the gray list. | 1222 | * scan and color them gray until the next scan. |
1206 | */ | 1223 | */ |
1207 | rcu_read_lock(); | 1224 | rcu_read_lock(); |
1208 | list_for_each_entry_rcu(object, &object_list, object_list) { | 1225 | list_for_each_entry_rcu(object, &object_list, object_list) { |
1209 | spin_lock_irqsave(&object->lock, flags); | 1226 | spin_lock_irqsave(&object->lock, flags); |
1210 | if ((object->flags & OBJECT_NEW) && !color_black(object) && | 1227 | if (color_white(object) && (object->flags & OBJECT_ALLOCATED) |
1211 | get_object(object)) { | 1228 | && update_checksum(object) && get_object(object)) { |
1212 | object->flags &= ~OBJECT_NEW; | 1229 | /* color it gray temporarily */ |
1230 | object->count = object->min_count; | ||
1213 | list_add_tail(&object->gray_list, &gray_list); | 1231 | list_add_tail(&object->gray_list, &gray_list); |
1214 | } | 1232 | } |
1215 | spin_unlock_irqrestore(&object->lock, flags); | 1233 | spin_unlock_irqrestore(&object->lock, flags); |
1216 | } | 1234 | } |
1217 | rcu_read_unlock(); | 1235 | rcu_read_unlock(); |
1218 | 1236 | ||
1219 | if (!list_empty(&gray_list)) | 1237 | /* |
1220 | goto repeat; | 1238 | * Re-scan the gray list for modified unreferenced objects. |
1221 | 1239 | */ | |
1222 | scan_end: | 1240 | scan_gray_list(); |
1223 | WARN_ON(!list_empty(&gray_list)); | ||
1224 | 1241 | ||
1225 | /* | 1242 | /* |
1226 | * If scanning was stopped or new objects were being allocated at a | 1243 | * If scanning was stopped do not report any new unreferenced objects. |
1227 | * higher rate than gray list scanning, do not report any new | ||
1228 | * unreferenced objects. | ||
1229 | */ | 1244 | */ |
1230 | if (scan_should_stop() || gray_list_pass >= GRAY_LIST_PASSES) | 1245 | if (scan_should_stop()) |
1231 | return; | 1246 | return; |
1232 | 1247 | ||
1233 | /* | 1248 | /* |
@@ -1642,8 +1657,7 @@ void __init kmemleak_init(void) | |||
1642 | kmemleak_ignore(log->ptr); | 1657 | kmemleak_ignore(log->ptr); |
1643 | break; | 1658 | break; |
1644 | case KMEMLEAK_SCAN_AREA: | 1659 | case KMEMLEAK_SCAN_AREA: |
1645 | kmemleak_scan_area(log->ptr, log->offset, log->length, | 1660 | kmemleak_scan_area(log->ptr, log->size, GFP_KERNEL); |
1646 | GFP_KERNEL); | ||
1647 | break; | 1661 | break; |
1648 | case KMEMLEAK_NO_SCAN: | 1662 | case KMEMLEAK_NO_SCAN: |
1649 | kmemleak_no_scan(log->ptr); | 1663 | kmemleak_no_scan(log->ptr); |
diff --git a/mm/readahead.c b/mm/readahead.c index aa1aa2345235..033bc135a41f 100644 --- a/mm/readahead.c +++ b/mm/readahead.c | |||
@@ -547,5 +547,17 @@ page_cache_async_readahead(struct address_space *mapping, | |||
547 | 547 | ||
548 | /* do read-ahead */ | 548 | /* do read-ahead */ |
549 | ondemand_readahead(mapping, ra, filp, true, offset, req_size); | 549 | ondemand_readahead(mapping, ra, filp, true, offset, req_size); |
550 | |||
551 | #ifdef CONFIG_BLOCK | ||
552 | /* | ||
553 | * Normally the current page is !uptodate and lock_page() will be | ||
554 | * immediately called to implicitly unplug the device. However this | ||
555 | * is not always true for RAID conifgurations, where data arrives | ||
556 | * not strictly in their submission order. In this case we need to | ||
557 | * explicitly kick off the IO. | ||
558 | */ | ||
559 | if (PageUptodate(page)) | ||
560 | blk_run_backing_dev(mapping->backing_dev_info, NULL); | ||
561 | #endif | ||
550 | } | 562 | } |
551 | EXPORT_SYMBOL_GPL(page_cache_async_readahead); | 563 | EXPORT_SYMBOL_GPL(page_cache_async_readahead); |
@@ -2275,9 +2275,11 @@ kmem_cache_create (const char *name, size_t size, size_t align, | |||
2275 | /* | 2275 | /* |
2276 | * Determine if the slab management is 'on' or 'off' slab. | 2276 | * Determine if the slab management is 'on' or 'off' slab. |
2277 | * (bootstrapping cannot cope with offslab caches so don't do | 2277 | * (bootstrapping cannot cope with offslab caches so don't do |
2278 | * it too early on.) | 2278 | * it too early on. Always use on-slab management when |
2279 | * SLAB_NOLEAKTRACE to avoid recursive calls into kmemleak) | ||
2279 | */ | 2280 | */ |
2280 | if ((size >= (PAGE_SIZE >> 3)) && !slab_early_init) | 2281 | if ((size >= (PAGE_SIZE >> 3)) && !slab_early_init && |
2282 | !(flags & SLAB_NOLEAKTRACE)) | ||
2281 | /* | 2283 | /* |
2282 | * Size is large, assume best to place the slab management obj | 2284 | * Size is large, assume best to place the slab management obj |
2283 | * off-slab (should allow better packing of objs). | 2285 | * off-slab (should allow better packing of objs). |
@@ -2596,8 +2598,8 @@ static struct slab *alloc_slabmgmt(struct kmem_cache *cachep, void *objp, | |||
2596 | * kmemleak does not treat the ->s_mem pointer as a reference | 2598 | * kmemleak does not treat the ->s_mem pointer as a reference |
2597 | * to the object. Otherwise we will not report the leak. | 2599 | * to the object. Otherwise we will not report the leak. |
2598 | */ | 2600 | */ |
2599 | kmemleak_scan_area(slabp, offsetof(struct slab, list), | 2601 | kmemleak_scan_area(&slabp->list, sizeof(struct list_head), |
2600 | sizeof(struct list_head), local_flags); | 2602 | local_flags); |
2601 | if (!slabp) | 2603 | if (!slabp) |
2602 | return NULL; | 2604 | return NULL; |
2603 | } else { | 2605 | } else { |