| Date: | 2010-01-11 04:29:44 (3 years 4 months ago) |
|---|---|
| Author: | Lars C. |
| Commit: | 9005746d81c36afa38c4a2e9339149e9c7b7f0e0 |
| Message: | From 5b3f9de4171368d9a99fa4c8b8b1bcc8505fb3c6 Mon Sep 17 00:00:00
2001 Subject: [PATCH] /opt/Projects/openwrt/target/linux/xburst/patches-2.6.31/103-serial.patch |
| Files: |
drivers/serial/8250.c (8 diffs) |
Change Details
| drivers/serial/8250.c | ||
|---|---|---|
| 199 | 199 | [PORT_16550A] = { |
| 200 | 200 | .name = "16550A", |
| 201 | 201 | .fifo_size = 16, |
| 202 | .tx_loadsz = 16, | |
| 202 | .tx_loadsz = 8, | |
| 203 | 203 | .fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10, |
| 204 | 204 | .flags = UART_CAP_FIFO, |
| 205 | 205 | }, |
| ... | ... | |
| 406 | 406 | static void mem_serial_out(struct uart_port *p, int offset, int value) |
| 407 | 407 | { |
| 408 | 408 | offset = map_8250_out_reg(p, offset) << p->regshift; |
| 409 | #if defined(CONFIG_JZSOC) | |
| 410 | if (offset == (UART_FCR << p->regshift)) | |
| 411 | value |= 0x10; /* set FCR.UUE */ | |
| 412 | #endif | |
| 409 | 413 | writeb(value, p->membase + offset); |
| 410 | 414 | } |
| 411 | 415 | |
| ... | ... | |
| 2214 | 2218 | serial_unlink_irq_chain(up); |
| 2215 | 2219 | } |
| 2216 | 2220 | |
| 2221 | #if defined(CONFIG_JZSOC) && !defined(CONFIG_SOC_JZ4730) | |
| 2222 | static unsigned short quot1[3] = {0}; /* quot[0]:baud_div, quot[1]:umr, quot[2]:uacr */ | |
| 2223 | static unsigned short * serial8250_get_divisor(struct uart_port *port, unsigned int baud) | |
| 2224 | { | |
| 2225 | int err, sum, i, j; | |
| 2226 | int a[12], b[12]; | |
| 2227 | unsigned short div, umr, uacr; | |
| 2228 | unsigned short umr_best, div_best, uacr_best; | |
| 2229 | long long t0, t1, t2, t3; | |
| 2230 | ||
| 2231 | sum = 0; | |
| 2232 | umr_best = div_best = uacr_best = 0; | |
| 2233 | div = 1; | |
| 2234 | ||
| 2235 | if ((port->uartclk % (16 * baud)) == 0) { | |
| 2236 | quot1[0] = port->uartclk / (16 * baud); | |
| 2237 | quot1[1] = 16; | |
| 2238 | quot1[2] = 0; | |
| 2239 | return quot1; | |
| 2240 | } | |
| 2241 | ||
| 2242 | while (1) { | |
| 2243 | umr = port->uartclk / (baud * div); | |
| 2244 | if (umr > 32) { | |
| 2245 | div++; | |
| 2246 | continue; | |
| 2247 | } | |
| 2248 | if (umr < 4) { | |
| 2249 | break; | |
| 2250 | } | |
| 2251 | for (i = 0; i < 12; i++) { | |
| 2252 | a[i] = umr; | |
| 2253 | b[i] = 0; | |
| 2254 | sum = 0; | |
| 2255 | for (j = 0; j <= i; j++) { | |
| 2256 | sum += a[j]; | |
| 2257 | } | |
| 2258 | ||
| 2259 | /* the precision could be 1/2^(36) due to the value of t0 */ | |
| 2260 | t0 = 0x1000000000LL; | |
| 2261 | t1 = (i + 1) * t0; | |
| 2262 | t2 = (sum * div) * t0; | |
| 2263 | t3 = div * t0; | |
| 2264 | do_div(t1, baud); | |
| 2265 | do_div(t2, port->uartclk); | |
| 2266 | do_div(t3, (2 * port->uartclk)); | |
| 2267 | err = t1 - t2 - t3; | |
| 2268 | ||
| 2269 | if (err > 0) { | |
| 2270 | a[i] += 1; | |
| 2271 | b[i] = 1; | |
| 2272 | } | |
| 2273 | } | |
| 2274 | ||
| 2275 | uacr = 0; | |
| 2276 | for (i = 0; i < 12; i++) { | |
| 2277 | if (b[i] == 1) { | |
| 2278 | uacr |= 1 << i; | |
| 2279 | } | |
| 2280 | } | |
| 2281 | ||
| 2282 | /* the best value of umr should be near 16, and the value of uacr should better be smaller */ | |
| 2283 | if (abs(umr - 16) < abs(umr_best - 16) || (abs(umr - 16) == abs(umr_best - 16) && uacr_best > uacr)) { | |
| 2284 | div_best = div; | |
| 2285 | umr_best = umr; | |
| 2286 | uacr_best = uacr; | |
| 2287 | } | |
| 2288 | div++; | |
| 2289 | } | |
| 2290 | ||
| 2291 | quot1[0] = div_best; | |
| 2292 | quot1[1] = umr_best; | |
| 2293 | quot1[2] = uacr_best; | |
| 2294 | ||
| 2295 | return quot1; | |
| 2296 | } | |
| 2297 | #else | |
| 2217 | 2298 | static unsigned int serial8250_get_divisor(struct uart_port *port, unsigned int baud) |
| 2218 | 2299 | { |
| 2219 | 2300 | unsigned int quot; |
| ... | ... | |
| 2233 | 2314 | |
| 2234 | 2315 | return quot; |
| 2235 | 2316 | } |
| 2317 | #endif | |
| 2236 | 2318 | |
| 2237 | 2319 | static void |
| 2238 | 2320 | serial8250_set_termios(struct uart_port *port, struct ktermios *termios, |
| ... | ... | |
| 2242 | 2324 | unsigned char cval, fcr = 0; |
| 2243 | 2325 | unsigned long flags; |
| 2244 | 2326 | unsigned int baud, quot; |
| 2327 | #if defined(CONFIG_JZSOC) && !defined(CONFIG_SOC_JZ4730) | |
| 2328 | unsigned short *quot1; | |
| 2329 | #endif | |
| 2245 | 2330 | |
| 2246 | 2331 | switch (termios->c_cflag & CSIZE) { |
| 2247 | 2332 | case CS5: |
| ... | ... | |
| 2276 | 2361 | baud = uart_get_baud_rate(port, termios, old, |
| 2277 | 2362 | port->uartclk / 16 / 0xffff, |
| 2278 | 2363 | port->uartclk / 16); |
| 2364 | #if defined(CONFIG_JZSOC) && !defined(CONFIG_SOC_JZ4730) | |
| 2365 | quot1 = serial8250_get_divisor(port, baud); | |
| 2366 | quot = quot1[0]; /* not usefull, just let gcc happy */ | |
| 2367 | #else | |
| 2279 | 2368 | quot = serial8250_get_divisor(port, baud); |
| 2369 | #endif | |
| 2280 | 2370 | |
| 2281 | 2371 | /* |
| 2282 | 2372 | * Oxford Semi 952 rev B workaround |
| ... | ... | |
| 2354 | 2444 | if (up->capabilities & UART_CAP_UUE) |
| 2355 | 2445 | up->ier |= UART_IER_UUE | UART_IER_RTOIE; |
| 2356 | 2446 | |
| 2447 | #ifdef CONFIG_JZSOC | |
| 2448 | up->ier |= UART_IER_RTOIE; /* Set this flag, or very slow */ | |
| 2449 | #endif | |
| 2450 | ||
| 2357 | 2451 | serial_out(up, UART_IER, up->ier); |
| 2358 | 2452 | |
| 2359 | 2453 | if (up->capabilities & UART_CAP_EFR) { |
| ... | ... | |
| 2388 | 2482 | serial_outp(up, UART_LCR, cval | UART_LCR_DLAB);/* set DLAB */ |
| 2389 | 2483 | } |
| 2390 | 2484 | |
| 2485 | #if defined(CONFIG_JZSOC) && !defined(CONFIG_SOC_JZ4730) | |
| 2486 | #define UART_UMR 9 | |
| 2487 | #define UART_UACR 10 | |
| 2488 | serial_dl_write(up, quot1[0]); | |
| 2489 | serial_outp(up, UART_UMR, quot1[1]); | |
| 2490 | serial_outp(up, UART_UACR, quot1[2]); | |
| 2491 | #else | |
| 2391 | 2492 | serial_dl_write(up, quot); |
| 2493 | #endif | |
| 2392 | 2494 | |
| 2393 | 2495 | /* |
| 2394 | 2496 | * LCR DLAB must be set to enable 64-byte FIFO mode. If the FCR |
Branches:
ben-wpan
ben-wpan-stefan
5396a9238205f20f811ea57898980d3ca82df0b6
jz-2.6.34
jz-2.6.34-rc5
jz-2.6.34-rc6
jz-2.6.34-rc7
jz-2.6.35
jz-2.6.36
jz-2.6.37
jz-2.6.38
jz-2.6.39
jz-3.0
jz-3.1
jz-3.2
jz-3.3
jz-3.4
jz-3.5
jz-3.6
jz-3.6-rc2-pwm
jz-3.9
jz-3.9-clk
jz-3.9-rc8
jz47xx
jz47xx-2.6.38
master
Tags:
od-2011-09-04
od-2011-09-18
v2.6.34-rc5
v2.6.34-rc6
v2.6.34-rc7
v3.9
