Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'for-rmk' of git://git.kernel.org/pub/scm/linux/kernel/git/ycmiao/pxa-linux-2.6 into devel

authored by

Russell King and committed by
Russell King
47992cbd 4655a0de

+1548 -308
+286
Documentation/arm/pxa/mfp.txt
··· 1 + MFP Configuration for PXA2xx/PXA3xx Processors 2 + 3 + Eric Miao <eric.miao@marvell.com> 4 + 5 + MFP stands for Multi-Function Pin, which is the pin-mux logic on PXA3xx and 6 + later PXA series processors. This document describes the existing MFP API, 7 + and how board/platform driver authors could make use of it. 8 + 9 + Basic Concept 10 + =============== 11 + 12 + Unlike the GPIO alternate function settings on PXA25x and PXA27x, a new MFP 13 + mechanism is introduced from PXA3xx to completely move the pin-mux functions 14 + out of the GPIO controller. In addition to pin-mux configurations, the MFP 15 + also controls the low power state, driving strength, pull-up/down and event 16 + detection of each pin. Below is a diagram of internal connections between 17 + the MFP logic and the remaining SoC peripherals: 18 + 19 + +--------+ 20 + | |--(GPIO19)--+ 21 + | GPIO | | 22 + | |--(GPIO...) | 23 + +--------+ | 24 + | +---------+ 25 + +--------+ +------>| | 26 + | PWM2 |--(PWM_OUT)-------->| MFP | 27 + +--------+ +------>| |-------> to external PAD 28 + | +---->| | 29 + +--------+ | | +-->| | 30 + | SSP2 |---(TXD)----+ | | +---------+ 31 + +--------+ | | 32 + | | 33 + +--------+ | | 34 + | Keypad |--(MKOUT4)----+ | 35 + +--------+ | 36 + | 37 + +--------+ | 38 + | UART2 |---(TXD)--------+ 39 + +--------+ 40 + 41 + NOTE: the external pad is named as MFP_PIN_GPIO19, it doesn't necessarily 42 + mean it's dedicated for GPIO19, only as a hint that internally this pin 43 + can be routed from GPIO19 of the GPIO controller. 44 + 45 + To better understand the change from PXA25x/PXA27x GPIO alternate function 46 + to this new MFP mechanism, here are several key points: 47 + 48 + 1. GPIO controller on PXA3xx is now a dedicated controller, same as other 49 + internal controllers like PWM, SSP and UART, with 128 internal signals 50 + which can be routed to external through one or more MFPs (e.g. GPIO<0> 51 + can be routed through either MFP_PIN_GPIO0 as well as MFP_PIN_GPIO0_2, 52 + see arch/arm/mach-pxa/mach/include/mfp-pxa300.h) 53 + 54 + 2. Alternate function configuration is removed from this GPIO controller, 55 + the remaining functions are pure GPIO-specific, i.e. 56 + 57 + - GPIO signal level control 58 + - GPIO direction control 59 + - GPIO level change detection 60 + 61 + 3. Low power state for each pin is now controlled by MFP, this means the 62 + PGSRx registers on PXA2xx are now useless on PXA3xx 63 + 64 + 4. Wakeup detection is now controlled by MFP, PWER does not control the 65 + wakeup from GPIO(s) any more, depending on the sleeping state, ADxER 66 + (as defined in pxa3xx-regs.h) controls the wakeup from MFP 67 + 68 + NOTE: with such a clear separation of MFP and GPIO, by GPIO<xx> we normally 69 + mean it is a GPIO signal, and by MFP<xxx> or pin xxx, we mean a physical 70 + pad (or ball). 71 + 72 + MFP API Usage 73 + =============== 74 + 75 + For board code writers, here are some guidelines: 76 + 77 + 1. include ONE of the following header files in your <board>.c: 78 + 79 + - #include <mach/mfp-pxa25x.h> 80 + - #include <mach/mfp-pxa27x.h> 81 + - #include <mach/mfp-pxa300.h> 82 + - #include <mach/mfp-pxa320.h> 83 + - #include <mach/mfp-pxa930.h> 84 + 85 + NOTE: only one file in your <board>.c, depending on the processors used, 86 + because pin configuration definitions may conflict in these file (i.e. 87 + same name, different meaning and settings on different processors). E.g. 88 + for zylonite platform, which support both PXA300/PXA310 and PXA320, two 89 + separate files are introduced: zylonite_pxa300.c and zylonite_pxa320.c 90 + (in addition to handle MFP configuration differences, they also handle 91 + the other differences between the two combinations). 92 + 93 + NOTE: PXA300 and PXA310 are almost identical in pin configurations (with 94 + PXA310 supporting some additional ones), thus the difference is actually 95 + covered in a single mfp-pxa300.h. 96 + 97 + 2. prepare an array for the initial pin configurations, e.g.: 98 + 99 + static unsigned long mainstone_pin_config[] __initdata = { 100 + /* Chip Select */ 101 + GPIO15_nCS_1, 102 + 103 + /* LCD - 16bpp Active TFT */ 104 + GPIOxx_TFT_LCD_16BPP, 105 + GPIO16_PWM0_OUT, /* Backlight */ 106 + 107 + /* MMC */ 108 + GPIO32_MMC_CLK, 109 + GPIO112_MMC_CMD, 110 + GPIO92_MMC_DAT_0, 111 + GPIO109_MMC_DAT_1, 112 + GPIO110_MMC_DAT_2, 113 + GPIO111_MMC_DAT_3, 114 + 115 + ... 116 + 117 + /* GPIO */ 118 + GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH, 119 + }; 120 + 121 + a) once the pin configurations are passed to pxa{2xx,3xx}_mfp_config(), 122 + and written to the actual registers, they are useless and may discard, 123 + adding '__initdata' will help save some additional bytes here. 124 + 125 + b) when there is only one possible pin configurations for a component, 126 + some simplified definitions can be used, e.g. GPIOxx_TFT_LCD_16BPP on 127 + PXA25x and PXA27x processors 128 + 129 + c) if by board design, a pin can be configured to wake up the system 130 + from low power state, it can be 'OR'ed with any of: 131 + 132 + WAKEUP_ON_EDGE_BOTH 133 + WAKEUP_ON_EDGE_RISE 134 + WAKEUP_ON_EDGE_FALL 135 + WAKEUP_ON_LEVEL_HIGH - specifically for enabling of keypad GPIOs, 136 + 137 + to indicate that this pin has the capability of wake-up the system, 138 + and on which edge(s). This, however, doesn't necessarily mean the 139 + pin _will_ wakeup the system, it will only when set_irq_wake() is 140 + invoked with the corresponding GPIO IRQ (GPIO_IRQ(xx) or gpio_to_irq()) 141 + and eventually calls gpio_set_wake() for the actual register setting. 142 + 143 + d) although PXA3xx MFP supports edge detection on each pin, the 144 + internal logic will only wakeup the system when those specific bits 145 + in ADxER registers are set, which can be well mapped to the 146 + corresponding peripheral, thus set_irq_wake() can be called with 147 + the peripheral IRQ to enable the wakeup. 148 + 149 + 150 + MFP on PXA3xx 151 + =============== 152 + 153 + Every external I/O pad on PXA3xx (excluding those for special purpose) has 154 + one MFP logic associated, and is controlled by one MFP register (MFPR). 155 + 156 + The MFPR has the following bit definitions (for PXA300/PXA310/PXA320): 157 + 158 + 31 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 159 + +-------------------------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 160 + | RESERVED |PS|PU|PD| DRIVE |SS|SD|SO|EC|EF|ER|--| AF_SEL | 161 + +-------------------------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 162 + 163 + Bit 3: RESERVED 164 + Bit 4: EDGE_RISE_EN - enable detection of rising edge on this pin 165 + Bit 5: EDGE_FALL_EN - enable detection of falling edge on this pin 166 + Bit 6: EDGE_CLEAR - disable edge detection on this pin 167 + Bit 7: SLEEP_OE_N - enable outputs during low power modes 168 + Bit 8: SLEEP_DATA - output data on the pin during low power modes 169 + Bit 9: SLEEP_SEL - selection control for low power modes signals 170 + Bit 13: PULLDOWN_EN - enable the internal pull-down resistor on this pin 171 + Bit 14: PULLUP_EN - enable the internal pull-up resistor on this pin 172 + Bit 15: PULL_SEL - pull state controlled by selected alternate function 173 + (0) or by PULL{UP,DOWN}_EN bits (1) 174 + 175 + Bit 0 - 2: AF_SEL - alternate function selection, 8 possibilities, from 0-7 176 + Bit 10-12: DRIVE - drive strength and slew rate 177 + 0b000 - fast 1mA 178 + 0b001 - fast 2mA 179 + 0b002 - fast 3mA 180 + 0b003 - fast 4mA 181 + 0b004 - slow 6mA 182 + 0b005 - fast 6mA 183 + 0b006 - slow 10mA 184 + 0b007 - fast 10mA 185 + 186 + MFP Design for PXA2xx/PXA3xx 187 + ============================== 188 + 189 + Due to the difference of pin-mux handling between PXA2xx and PXA3xx, a unified 190 + MFP API is introduced to cover both series of processors. 191 + 192 + The basic idea of this design is to introduce definitions for all possible pin 193 + configurations, these definitions are processor and platform independent, and 194 + the actual API invoked to convert these definitions into register settings and 195 + make them effective there-after. 196 + 197 + Files Involved 198 + -------------- 199 + 200 + - arch/arm/mach-pxa/include/mach/mfp.h 201 + 202 + for 203 + 1. Unified pin definitions - enum constants for all configurable pins 204 + 2. processor-neutral bit definitions for a possible MFP configuration 205 + 206 + - arch/arm/mach-pxa/include/mach/mfp-pxa3xx.h 207 + 208 + for PXA3xx specific MFPR register bit definitions and PXA3xx common pin 209 + configurations 210 + 211 + - arch/arm/mach-pxa/include/mach/mfp-pxa2xx.h 212 + 213 + for PXA2xx specific definitions and PXA25x/PXA27x common pin configurations 214 + 215 + - arch/arm/mach-pxa/include/mach/mfp-pxa25x.h 216 + arch/arm/mach-pxa/include/mach/mfp-pxa27x.h 217 + arch/arm/mach-pxa/include/mach/mfp-pxa300.h 218 + arch/arm/mach-pxa/include/mach/mfp-pxa320.h 219 + arch/arm/mach-pxa/include/mach/mfp-pxa930.h 220 + 221 + for processor specific definitions 222 + 223 + - arch/arm/mach-pxa/mfp-pxa3xx.c 224 + - arch/arm/mach-pxa/mfp-pxa2xx.c 225 + 226 + for implementation of the pin configuration to take effect for the actual 227 + processor. 228 + 229 + Pin Configuration 230 + ----------------- 231 + 232 + The following comments are copied from mfp.h (see the actual source code 233 + for most updated info) 234 + 235 + /* 236 + * a possible MFP configuration is represented by a 32-bit integer 237 + * 238 + * bit 0.. 9 - MFP Pin Number (1024 Pins Maximum) 239 + * bit 10..12 - Alternate Function Selection 240 + * bit 13..15 - Drive Strength 241 + * bit 16..18 - Low Power Mode State 242 + * bit 19..20 - Low Power Mode Edge Detection 243 + * bit 21..22 - Run Mode Pull State 244 + * 245 + * to facilitate the definition, the following macros are provided 246 + * 247 + * MFP_CFG_DEFAULT - default MFP configuration value, with 248 + * alternate function = 0, 249 + * drive strength = fast 3mA (MFP_DS03X) 250 + * low power mode = default 251 + * edge detection = none 252 + * 253 + * MFP_CFG - default MFPR value with alternate function 254 + * MFP_CFG_DRV - default MFPR value with alternate function and 255 + * pin drive strength 256 + * MFP_CFG_LPM - default MFPR value with alternate function and 257 + * low power mode 258 + * MFP_CFG_X - default MFPR value with alternate function, 259 + * pin drive strength and low power mode 260 + */ 261 + 262 + Examples of pin configurations are: 263 + 264 + #define GPIO94_SSP3_RXD MFP_CFG_X(GPIO94, AF1, DS08X, FLOAT) 265 + 266 + which reads GPIO94 can be configured as SSP3_RXD, with alternate function 267 + selection of 1, driving strength of 0b101, and a float state in low power 268 + modes. 269 + 270 + NOTE: this is the default setting of this pin being configured as SSP3_RXD 271 + which can be modified a bit in board code, though it is not recommended to 272 + do so, simply because this default setting is usually carefully encoded, 273 + and is supposed to work in most cases. 274 + 275 + Register Settings 276 + ----------------- 277 + 278 + Register settings on PXA3xx for a pin configuration is actually very 279 + straight-forward, most bits can be converted directly into MFPR value 280 + in a easier way. Two sets of MFPR values are calculated: the run-time 281 + ones and the low power mode ones, to allow different settings. 282 + 283 + The conversion from a generic pin configuration to the actual register 284 + settings on PXA2xx is a bit complicated: many registers are involved, 285 + including GAFRx, GPDRx, PGSRx, PWER, PKWR, PFER and PRER. Please see 286 + mfp-pxa2xx.c for how the conversion is made.
+90 -2
Documentation/fb/pxafb.txt
··· 5 5 options=<OPTIONS> when modular or video=pxafb:<OPTIONS> when built in. 6 6 7 7 For example: 8 - modprobe pxafb options=mode:640x480-8,passive 8 + modprobe pxafb options=vmem:2M,mode:640x480-8,passive 9 9 or on the kernel command line 10 - video=pxafb:mode:640x480-8,passive 10 + video=pxafb:vmem:2M,mode:640x480-8,passive 11 + 12 + vmem: VIDEO_MEM_SIZE 13 + Amount of video memory to allocate (can be suffixed with K or M 14 + for kilobytes or megabytes) 11 15 12 16 mode:XRESxYRES[-BPP] 13 17 XRES == LCCR1_PPL + 1 ··· 56 52 pixclockpol:POLARITY 57 53 pixel clock polarity 58 54 0 => falling edge, 1 => rising edge 55 + 56 + 57 + Overlay Support for PXA27x and later LCD controllers 58 + ==================================================== 59 + 60 + PXA27x and later processors support overlay1 and overlay2 on-top of the 61 + base framebuffer (although under-neath the base is also possible). They 62 + support palette and no-palette RGB formats, as well as YUV formats (only 63 + available on overlay2). These overlays have dedicated DMA channels and 64 + behave in a similar way as a framebuffer. 65 + 66 + However, there are some differences between these overlay framebuffers 67 + and normal framebuffers, as listed below: 68 + 69 + 1. overlay can start at a 32-bit word aligned position within the base 70 + framebuffer, which means they have a start (x, y). This information 71 + is encoded into var->nonstd (no, var->xoffset and var->yoffset are 72 + not for such purpose). 73 + 74 + 2. overlay framebuffer is allocated dynamically according to specified 75 + 'struct fb_var_screeninfo', the amount is decided by: 76 + 77 + var->xres_virtual * var->yres_virtual * bpp 78 + 79 + bpp = 16 -- for RGB565 or RGBT555 80 + = 24 -- for YUV444 packed 81 + = 24 -- for YUV444 planar 82 + = 16 -- for YUV422 planar (1 pixel = 1 Y + 1/2 Cb + 1/2 Cr) 83 + = 12 -- for YUV420 planar (1 pixel = 1 Y + 1/4 Cb + 1/4 Cr) 84 + 85 + NOTE: 86 + 87 + a. overlay does not support panning in x-direction, thus 88 + var->xres_virtual will always be equal to var->xres 89 + 90 + b. line length of overlay(s) must be on a 32-bit word boundary, 91 + for YUV planar modes, it is a requirement for the component 92 + with minimum bits per pixel, e.g. for YUV420, Cr component 93 + for one pixel is actually 2-bits, it means the line length 94 + should be a multiple of 16-pixels 95 + 96 + c. starting horizontal position (XPOS) should start on a 32-bit 97 + word boundary, otherwise the fb_check_var() will just fail. 98 + 99 + d. the rectangle of the overlay should be within the base plane, 100 + otherwise fail 101 + 102 + Applications should follow the sequence below to operate an overlay 103 + framebuffer: 104 + 105 + a. open("/dev/fb[1-2]", ...) 106 + b. ioctl(fd, FBIOGET_VSCREENINFO, ...) 107 + c. modify 'var' with desired parameters: 108 + 1) var->xres and var->yres 109 + 2) larger var->yres_virtual if more memory is required, 110 + usually for double-buffering 111 + 3) var->nonstd for starting (x, y) and color format 112 + 4) var->{red, green, blue, transp} if RGB mode is to be used 113 + d. ioctl(fd, FBIOPUT_VSCREENINFO, ...) 114 + e. ioctl(fd, FBIOGET_FSCREENINFO, ...) 115 + f. mmap 116 + g. ... 117 + 118 + 3. for YUV planar formats, these are actually not supported within the 119 + framebuffer framework, application has to take care of the offsets 120 + and lengths of each component within the framebuffer. 121 + 122 + 4. var->nonstd is used to pass starting (x, y) position and color format, 123 + the detailed bit fields are shown below: 124 + 125 + 31 23 20 10 0 126 + +-----------------+---+----------+----------+ 127 + | ... unused ... |FOR| XPOS | YPOS | 128 + +-----------------+---+----------+----------+ 129 + 130 + FOR - color format, as defined by OVERLAY_FORMAT_* in pxafb.h 131 + 0 - RGB 132 + 1 - YUV444 PACKED 133 + 2 - YUV444 PLANAR 134 + 3 - YUV422 PLANAR 135 + 4 - YUR420 PLANAR 136 + 137 + XPOS - starting horizontal position 138 + YPOS - starting vertical position
+16
arch/arm/mach-pxa/generic.c
··· 24 24 #include <asm/system.h> 25 25 #include <asm/pgtable.h> 26 26 #include <asm/mach/map.h> 27 + #include <asm/mach-types.h> 27 28 28 29 #include <mach/pxa-regs.h> 29 30 #include <mach/reset.h> ··· 39 38 if (cpu_is_pxa3xx()) 40 39 pxa3xx_clear_reset_status(mask); 41 40 } 41 + 42 + unsigned long get_clock_tick_rate(void) 43 + { 44 + unsigned long clock_tick_rate; 45 + 46 + if (cpu_is_pxa25x()) 47 + clock_tick_rate = 3686400; 48 + else if (machine_is_mainstone()) 49 + clock_tick_rate = 3249600; 50 + else 51 + clock_tick_rate = 3250000; 52 + 53 + return clock_tick_rate; 54 + } 55 + EXPORT_SYMBOL(get_clock_tick_rate); 42 56 43 57 /* 44 58 * Get the clock frequency as reflected by CCCR and the turbo flag.
+2
arch/arm/mach-pxa/include/mach/hardware.h
··· 291 291 */ 292 292 extern unsigned int get_memclk_frequency_10khz(void); 293 293 294 + /* return the clock tick rate of the OS timer */ 295 + extern unsigned long get_clock_tick_rate(void); 294 296 #endif 295 297 296 298 #if defined(CONFIG_MACH_ARMCORE) && defined(CONFIG_PCI)
+1
arch/arm/mach-pxa/include/mach/mfp-pxa930.h
··· 421 421 #define GPIO20_PWM0 MFP_CFG_LPM(GPIO20, AF2, PULL_LOW) 422 422 #define GPIO21_PWM2 MFP_CFG_LPM(GPIO21, AF3, PULL_LOW) 423 423 #define GPIO22_PWM3 MFP_CFG_LPM(GPIO22, AF3, PULL_LOW) 424 + #define GPIO32_PWM0 MFP_CFG_LPM(GPIO32, AF4, PULL_LOW) 424 425 425 426 /* CIR */ 426 427 #define GPIO46_CIR_OUT MFP_CFG(GPIO46, AF1)
+1
arch/arm/mach-pxa/include/mach/pxafb.h
··· 113 113 unsigned int num_modes; 114 114 115 115 unsigned int lcd_conn; 116 + unsigned long video_mem_size; 116 117 117 118 u_int fixed_modes:1, 118 119 cmap_inverse:1,
+35 -25
arch/arm/mach-pxa/include/mach/regs-lcd.h
··· 12 12 #define LCCR3 (0x00C) /* LCD Controller Control Register 3 */ 13 13 #define LCCR4 (0x010) /* LCD Controller Control Register 4 */ 14 14 #define LCCR5 (0x014) /* LCD Controller Control Register 5 */ 15 - #define DFBR0 (0x020) /* DMA Channel 0 Frame Branch Register */ 16 - #define DFBR1 (0x024) /* DMA Channel 1 Frame Branch Register */ 17 - #define LCSR (0x038) /* LCD Controller Status Register */ 15 + #define LCSR (0x038) /* LCD Controller Status Register 0 */ 16 + #define LCSR1 (0x034) /* LCD Controller Status Register 1 */ 18 17 #define LIIDR (0x03C) /* LCD Controller Interrupt ID Register */ 19 18 #define TMEDRGBR (0x040) /* TMED RGB Seed Register */ 20 19 #define TMEDCR (0x044) /* TMED Control Register */ 21 20 21 + #define FBR0 (0x020) /* DMA Channel 0 Frame Branch Register */ 22 + #define FBR1 (0x024) /* DMA Channel 1 Frame Branch Register */ 23 + #define FBR2 (0x028) /* DMA Channel 2 Frame Branch Register */ 24 + #define FBR3 (0x02C) /* DMA Channel 2 Frame Branch Register */ 25 + #define FBR4 (0x030) /* DMA Channel 2 Frame Branch Register */ 26 + #define FBR5 (0x110) /* DMA Channel 2 Frame Branch Register */ 27 + #define FBR6 (0x114) /* DMA Channel 2 Frame Branch Register */ 28 + 29 + #define OVL1C1 (0x050) /* Overlay 1 Control Register 1 */ 30 + #define OVL1C2 (0x060) /* Overlay 1 Control Register 2 */ 31 + #define OVL2C1 (0x070) /* Overlay 2 Control Register 1 */ 32 + #define OVL2C2 (0x080) /* Overlay 2 Control Register 2 */ 33 + 22 34 #define CMDCR (0x100) /* Command Control Register */ 23 35 #define PRSR (0x104) /* Panel Read Status Register */ 24 36 25 - #define LCCR3_1BPP (0 << 24) 26 - #define LCCR3_2BPP (1 << 24) 27 - #define LCCR3_4BPP (2 << 24) 28 - #define LCCR3_8BPP (3 << 24) 29 - #define LCCR3_16BPP (4 << 24) 30 - #define LCCR3_18BPP (5 << 24) 31 - #define LCCR3_18BPP_P (6 << 24) 32 - #define LCCR3_19BPP (7 << 24) 33 - #define LCCR3_19BPP_P (1 << 29) 34 - #define LCCR3_24BPP ((1 << 29) | (1 << 24)) 35 - #define LCCR3_25BPP ((1 << 29) | (2 << 24)) 37 + #define LCCR3_BPP(x) ((((x) & 0x7) << 24) | (((x) & 0x8) ? (1 << 29) : 0)) 36 38 37 39 #define LCCR3_PDFOR_0 (0 << 30) 38 40 #define LCCR3_PDFOR_1 (1 << 30) ··· 44 42 #define LCCR4_PAL_FOR_0 (0 << 15) 45 43 #define LCCR4_PAL_FOR_1 (1 << 15) 46 44 #define LCCR4_PAL_FOR_2 (2 << 15) 45 + #define LCCR4_PAL_FOR_3 (3 << 15) 47 46 #define LCCR4_PAL_FOR_MASK (3 << 15) 48 47 49 48 #define FDADR0 (0x200) /* DMA Channel 0 Frame Descriptor Address Register */ 50 - #define FSADR0 (0x204) /* DMA Channel 0 Frame Source Address Register */ 51 - #define FIDR0 (0x208) /* DMA Channel 0 Frame ID Register */ 52 - #define LDCMD0 (0x20C) /* DMA Channel 0 Command Register */ 53 49 #define FDADR1 (0x210) /* DMA Channel 1 Frame Descriptor Address Register */ 54 - #define FSADR1 (0x214) /* DMA Channel 1 Frame Source Address Register */ 55 - #define FIDR1 (0x218) /* DMA Channel 1 Frame ID Register */ 56 - #define LDCMD1 (0x21C) /* DMA Channel 1 Command Register */ 50 + #define FDADR2 (0x220) /* DMA Channel 2 Frame Descriptor Address Register */ 51 + #define FDADR3 (0x230) /* DMA Channel 3 Frame Descriptor Address Register */ 52 + #define FDADR4 (0x240) /* DMA Channel 4 Frame Descriptor Address Register */ 53 + #define FDADR5 (0x250) /* DMA Channel 5 Frame Descriptor Address Register */ 57 54 #define FDADR6 (0x260) /* DMA Channel 6 Frame Descriptor Address Register */ 58 - #define FSADR6 (0x264) /* DMA Channel 6 Frame Source Address Register */ 59 - #define FIDR6 (0x268) /* DMA Channel 6 Frame ID Register */ 60 55 61 56 #define LCCR0_ENB (1 << 0) /* LCD Controller enable */ 62 57 #define LCCR0_CMS (1 << 1) /* Color/Monochrome Display Select */ ··· 125 126 #define LCCR3_PCD Fld (8, 0) /* Pixel Clock Divisor */ 126 127 #define LCCR3_PixClkDiv(Div) (((Div) << FShft (LCCR3_PCD))) 127 128 128 - #define LCCR3_BPP Fld (3, 24) /* Bit Per Pixel */ 129 - #define LCCR3_Bpp(Bpp) (((Bpp) << FShft (LCCR3_BPP))) 130 - 131 129 #define LCCR3_ACB Fld (8, 8) /* AC Bias */ 132 130 #define LCCR3_Acb(Acb) (((Acb) << FShft (LCCR3_ACB))) 133 131 ··· 153 157 #define LCSR_RD_ST (1 << 11) /* read status */ 154 158 #define LCSR_CMD_INT (1 << 12) /* command interrupt */ 155 159 160 + #define LCSR1_IU(x) (1 << ((x) + 23)) /* Input FIFO underrun */ 161 + #define LCSR1_BS(x) (1 << ((x) + 15)) /* Branch Status */ 162 + #define LCSR1_EOF(x) (1 << ((x) + 7)) /* End of Frame Status */ 163 + #define LCSR1_SOF(x) (1 << ((x) - 1)) /* Start of Frame Status */ 164 + 156 165 #define LDCMD_PAL (1 << 26) /* instructs DMA to load palette buffer */ 166 + 167 + /* overlay control registers */ 168 + #define OVLxC1_PPL(x) ((((x) - 1) & 0x3ff) << 0) /* Pixels Per Line */ 169 + #define OVLxC1_LPO(x) ((((x) - 1) & 0x3ff) << 10) /* Number of Lines */ 170 + #define OVLxC1_BPP(x) (((x) & 0xf) << 20) /* Bits Per Pixel */ 171 + #define OVLxC1_OEN (1 << 31) /* Enable bit for Overlay */ 172 + #define OVLxC2_XPOS(x) (((x) & 0x3ff) << 0) /* Horizontal Position */ 173 + #define OVLxC2_YPOS(x) (((x) & 0x3ff) << 10) /* Vertical Position */ 174 + #define OVL2C2_PFOR(x) (((x) & 0x7) << 20) /* Pixel Format */ 157 175 158 176 /* smartpanel related */ 159 177 #define PRSR_DATA(x) ((x) & 0xff) /* Panel Data */
+8
arch/arm/mach-pxa/include/mach/timex.h
··· 10 10 * published by the Free Software Foundation. 11 11 */ 12 12 13 + /* Various drivers are still using the constant of CLOCK_TICK_RATE, for 14 + * those drivers to at least work, the definition is provided here. 15 + * 16 + * NOTE: this is no longer accurate when multiple processors and boards 17 + * are selected, newer drivers should not depend on this any more. Use 18 + * either the clocksource/clockevent or get this at run-time by calling 19 + * get_clock_tick_rate() (as defined in generic.c). 20 + */ 13 21 14 22 #if defined(CONFIG_PXA25x) 15 23 /* PXA250/210 timer base */
+412
arch/arm/mach-pxa/tavorevb.c
··· 18 18 #include <linux/clk.h> 19 19 #include <linux/gpio.h> 20 20 #include <linux/smc91x.h> 21 + #include <linux/pwm_backlight.h> 21 22 22 23 #include <asm/mach-types.h> 23 24 #include <asm/mach/arch.h> 24 25 #include <mach/hardware.h> 25 26 #include <mach/pxa3xx-regs.h> 26 27 #include <mach/mfp-pxa930.h> 28 + #include <mach/pxafb.h> 29 + #include <mach/pxa27x_keypad.h> 27 30 28 31 #include "devices.h" 29 32 #include "generic.h" ··· 36 33 /* Ethernet */ 37 34 DF_nCS1_nCS3, 38 35 GPIO47_GPIO, 36 + 37 + /* LCD */ 38 + GPIO23_LCD_DD0, 39 + GPIO24_LCD_DD1, 40 + GPIO25_LCD_DD2, 41 + GPIO26_LCD_DD3, 42 + GPIO27_LCD_DD4, 43 + GPIO28_LCD_DD5, 44 + GPIO29_LCD_DD6, 45 + GPIO44_LCD_DD7, 46 + GPIO21_LCD_CS, 47 + GPIO22_LCD_CS2, 48 + 49 + GPIO17_LCD_FCLK_RD, 50 + GPIO18_LCD_LCLK_A0, 51 + GPIO19_LCD_PCLK_WR, 52 + 53 + /* LCD Backlight */ 54 + GPIO43_PWM3, /* primary backlight */ 55 + GPIO32_PWM0, /* secondary backlight */ 56 + 57 + /* Keypad */ 58 + GPIO0_KP_MKIN_0, 59 + GPIO2_KP_MKIN_1, 60 + GPIO4_KP_MKIN_2, 61 + GPIO6_KP_MKIN_3, 62 + GPIO8_KP_MKIN_4, 63 + GPIO10_KP_MKIN_5, 64 + GPIO12_KP_MKIN_6, 65 + GPIO1_KP_MKOUT_0, 66 + GPIO3_KP_MKOUT_1, 67 + GPIO5_KP_MKOUT_2, 68 + GPIO7_KP_MKOUT_3, 69 + GPIO9_KP_MKOUT_4, 70 + GPIO11_KP_MKOUT_5, 71 + GPIO13_KP_MKOUT_6, 72 + 73 + GPIO14_KP_DKIN_2, 74 + GPIO15_KP_DKIN_3, 39 75 }; 40 76 41 77 #define TAVOREVB_ETH_PHYS (0x14000000) ··· 106 64 }, 107 65 }; 108 66 67 + #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE) 68 + static unsigned int tavorevb_matrix_key_map[] = { 69 + /* KEY(row, col, key_code) */ 70 + KEY(0, 4, KEY_A), KEY(0, 5, KEY_B), KEY(0, 6, KEY_C), 71 + KEY(1, 4, KEY_E), KEY(1, 5, KEY_F), KEY(1, 6, KEY_G), 72 + KEY(2, 4, KEY_I), KEY(2, 5, KEY_J), KEY(2, 6, KEY_K), 73 + KEY(3, 4, KEY_M), KEY(3, 5, KEY_N), KEY(3, 6, KEY_O), 74 + KEY(4, 5, KEY_R), KEY(4, 6, KEY_S), 75 + KEY(5, 4, KEY_U), KEY(5, 4, KEY_V), KEY(5, 6, KEY_W), 76 + 77 + KEY(6, 4, KEY_Y), KEY(6, 5, KEY_Z), 78 + 79 + KEY(0, 3, KEY_0), KEY(2, 0, KEY_1), KEY(2, 1, KEY_2), KEY(2, 2, KEY_3), 80 + KEY(2, 3, KEY_4), KEY(1, 0, KEY_5), KEY(1, 1, KEY_6), KEY(1, 2, KEY_7), 81 + KEY(1, 3, KEY_8), KEY(0, 2, KEY_9), 82 + 83 + KEY(6, 6, KEY_SPACE), 84 + KEY(0, 0, KEY_KPASTERISK), /* * */ 85 + KEY(0, 1, KEY_KPDOT), /* # */ 86 + 87 + KEY(4, 1, KEY_UP), 88 + KEY(4, 3, KEY_DOWN), 89 + KEY(4, 0, KEY_LEFT), 90 + KEY(4, 2, KEY_RIGHT), 91 + KEY(6, 0, KEY_HOME), 92 + KEY(3, 2, KEY_END), 93 + KEY(6, 1, KEY_DELETE), 94 + KEY(5, 2, KEY_BACK), 95 + KEY(6, 3, KEY_CAPSLOCK), /* KEY_LEFTSHIFT), */ 96 + 97 + KEY(4, 4, KEY_ENTER), /* scroll push */ 98 + KEY(6, 2, KEY_ENTER), /* keypad action */ 99 + 100 + KEY(3, 1, KEY_SEND), 101 + KEY(5, 3, KEY_RECORD), 102 + KEY(5, 0, KEY_VOLUMEUP), 103 + KEY(5, 1, KEY_VOLUMEDOWN), 104 + 105 + KEY(3, 0, KEY_F22), /* soft1 */ 106 + KEY(3, 3, KEY_F23), /* soft2 */ 107 + }; 108 + 109 + static struct pxa27x_keypad_platform_data tavorevb_keypad_info = { 110 + .matrix_key_rows = 7, 111 + .matrix_key_cols = 7, 112 + .matrix_key_map = tavorevb_matrix_key_map, 113 + .matrix_key_map_size = ARRAY_SIZE(tavorevb_matrix_key_map), 114 + .debounce_interval = 30, 115 + }; 116 + 117 + static void __init tavorevb_init_keypad(void) 118 + { 119 + pxa_set_keypad_info(&tavorevb_keypad_info); 120 + } 121 + #else 122 + static inline void tavorevb_init_keypad(void) {} 123 + #endif /* CONFIG_KEYBOARD_PXA27x || CONFIG_KEYBOARD_PXA27x_MODULE */ 124 + 125 + #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE) 126 + static struct platform_pwm_backlight_data tavorevb_backlight_data[] = { 127 + [0] = { 128 + /* primary backlight */ 129 + .pwm_id = 2, 130 + .max_brightness = 100, 131 + .dft_brightness = 100, 132 + .pwm_period_ns = 100000, 133 + }, 134 + [1] = { 135 + /* secondary backlight */ 136 + .pwm_id = 0, 137 + .max_brightness = 100, 138 + .dft_brightness = 100, 139 + .pwm_period_ns = 100000, 140 + }, 141 + }; 142 + 143 + static struct platform_device tavorevb_backlight_devices[] = { 144 + [0] = { 145 + .name = "pwm-backlight", 146 + .id = 0, 147 + .dev = { 148 + .platform_data = &tavorevb_backlight_data[0], 149 + }, 150 + }, 151 + [1] = { 152 + .name = "pwm-backlight", 153 + .id = 1, 154 + .dev = { 155 + .platform_data = &tavorevb_backlight_data[1], 156 + }, 157 + }, 158 + }; 159 + 160 + static uint16_t panel_init[] = { 161 + /* DSTB OUT */ 162 + SMART_CMD(0x00), 163 + SMART_CMD_NOOP, 164 + SMART_DELAY(1), 165 + 166 + SMART_CMD(0x00), 167 + SMART_CMD_NOOP, 168 + SMART_DELAY(1), 169 + 170 + SMART_CMD(0x00), 171 + SMART_CMD_NOOP, 172 + SMART_DELAY(1), 173 + 174 + /* STB OUT */ 175 + SMART_CMD(0x00), 176 + SMART_CMD(0x1D), 177 + SMART_DAT(0x00), 178 + SMART_DAT(0x05), 179 + SMART_DELAY(1), 180 + 181 + /* P-ON Init sequence */ 182 + SMART_CMD(0x00), /* OSC ON */ 183 + SMART_CMD(0x00), 184 + SMART_DAT(0x00), 185 + SMART_DAT(0x01), 186 + SMART_CMD(0x00), 187 + SMART_CMD(0x01), /* SOURCE DRIVER SHIFT DIRECTION and display RAM setting */ 188 + SMART_DAT(0x01), 189 + SMART_DAT(0x27), 190 + SMART_CMD(0x00), 191 + SMART_CMD(0x02), /* LINE INV */ 192 + SMART_DAT(0x02), 193 + SMART_DAT(0x00), 194 + SMART_CMD(0x00), 195 + SMART_CMD(0x03), /* IF mode(1) */ 196 + SMART_DAT(0x01), /* 8bit smart mode(8-8),high speed write mode */ 197 + SMART_DAT(0x30), 198 + SMART_CMD(0x07), 199 + SMART_CMD(0x00), /* RAM Write Mode */ 200 + SMART_DAT(0x00), 201 + SMART_DAT(0x03), 202 + SMART_CMD(0x00), 203 + 204 + /* DISPLAY Setting, 262K, fixed(NO scroll), no split screen */ 205 + SMART_CMD(0x07), 206 + SMART_DAT(0x40), /* 16/18/19 BPP */ 207 + SMART_DAT(0x00), 208 + SMART_CMD(0x00), 209 + SMART_CMD(0x08), /* BP, FP Seting, BP=2H, FP=3H */ 210 + SMART_DAT(0x03), 211 + SMART_DAT(0x02), 212 + SMART_CMD(0x00), 213 + SMART_CMD(0x0C), /* IF mode(2), using internal clock & MPU */ 214 + SMART_DAT(0x00), 215 + SMART_DAT(0x00), 216 + SMART_CMD(0x00), 217 + SMART_CMD(0x0D), /* Frame setting, 1Min. Frequence, 16CLK */ 218 + SMART_DAT(0x00), 219 + SMART_DAT(0x10), 220 + SMART_CMD(0x00), 221 + SMART_CMD(0x12), /* Timing(1),ASW W=4CLK, ASW ST=1CLK */ 222 + SMART_DAT(0x03), 223 + SMART_DAT(0x02), 224 + SMART_CMD(0x00), 225 + SMART_CMD(0x13), /* Timing(2),OEV ST=0.5CLK, OEV ED=1CLK */ 226 + SMART_DAT(0x01), 227 + SMART_DAT(0x02), 228 + SMART_CMD(0x00), 229 + SMART_CMD(0x14), /* Timing(3), ASW HOLD=0.5CLK */ 230 + SMART_DAT(0x00), 231 + SMART_DAT(0x00), 232 + SMART_CMD(0x00), 233 + SMART_CMD(0x15), /* Timing(4), CKV ST=0CLK, CKV ED=1CLK */ 234 + SMART_DAT(0x20), 235 + SMART_DAT(0x00), 236 + SMART_CMD(0x00), 237 + SMART_CMD(0x1C), 238 + SMART_DAT(0x00), 239 + SMART_DAT(0x00), 240 + SMART_CMD(0x03), 241 + SMART_CMD(0x00), 242 + SMART_DAT(0x04), 243 + SMART_DAT(0x03), 244 + SMART_CMD(0x03), 245 + SMART_CMD(0x01), 246 + SMART_DAT(0x03), 247 + SMART_DAT(0x04), 248 + SMART_CMD(0x03), 249 + SMART_CMD(0x02), 250 + SMART_DAT(0x04), 251 + SMART_DAT(0x03), 252 + SMART_CMD(0x03), 253 + SMART_CMD(0x03), 254 + SMART_DAT(0x03), 255 + SMART_DAT(0x03), 256 + SMART_CMD(0x03), 257 + SMART_CMD(0x04), 258 + SMART_DAT(0x01), 259 + SMART_DAT(0x01), 260 + SMART_CMD(0x03), 261 + SMART_CMD(0x05), 262 + SMART_DAT(0x00), 263 + SMART_DAT(0x00), 264 + SMART_CMD(0x04), 265 + SMART_CMD(0x02), 266 + SMART_DAT(0x00), 267 + SMART_DAT(0x00), 268 + SMART_CMD(0x04), 269 + SMART_CMD(0x03), 270 + SMART_DAT(0x01), 271 + SMART_DAT(0x3F), 272 + SMART_DELAY(0), 273 + 274 + /* DISP RAM setting: 240*320 */ 275 + SMART_CMD(0x04), /* HADDR, START 0 */ 276 + SMART_CMD(0x06), 277 + SMART_DAT(0x00), 278 + SMART_DAT(0x00), /* x1,3 */ 279 + SMART_CMD(0x04), /* HADDR, END 4 */ 280 + SMART_CMD(0x07), 281 + SMART_DAT(0x00), 282 + SMART_DAT(0xEF), /* x2, 7 */ 283 + SMART_CMD(0x04), /* VADDR, START 8 */ 284 + SMART_CMD(0x08), 285 + SMART_DAT(0x00), /* y1, 10 */ 286 + SMART_DAT(0x00), /* y1, 11 */ 287 + SMART_CMD(0x04), /* VADDR, END 12 */ 288 + SMART_CMD(0x09), 289 + SMART_DAT(0x01), /* y2, 14 */ 290 + SMART_DAT(0x3F), /* y2, 15 */ 291 + SMART_CMD(0x02), /* RAM ADDR SETTING 16 */ 292 + SMART_CMD(0x00), 293 + SMART_DAT(0x00), 294 + SMART_DAT(0x00), /* x1, 19 */ 295 + SMART_CMD(0x02), /* RAM ADDR SETTING 20 */ 296 + SMART_CMD(0x01), 297 + SMART_DAT(0x00), /* y1, 22 */ 298 + SMART_DAT(0x00), /* y1, 23 */ 299 + }; 300 + 301 + static uint16_t panel_on[] = { 302 + /* Power-IC ON */ 303 + SMART_CMD(0x01), 304 + SMART_CMD(0x02), 305 + SMART_DAT(0x07), 306 + SMART_DAT(0x7D), 307 + SMART_CMD(0x01), 308 + SMART_CMD(0x03), 309 + SMART_DAT(0x00), 310 + SMART_DAT(0x05), 311 + SMART_CMD(0x01), 312 + SMART_CMD(0x04), 313 + SMART_DAT(0x00), 314 + SMART_DAT(0x00), 315 + SMART_CMD(0x01), 316 + SMART_CMD(0x05), 317 + SMART_DAT(0x00), 318 + SMART_DAT(0x15), 319 + SMART_CMD(0x01), 320 + SMART_CMD(0x00), 321 + SMART_DAT(0xC0), 322 + SMART_DAT(0x10), 323 + SMART_DELAY(30), 324 + 325 + /* DISP ON */ 326 + SMART_CMD(0x01), 327 + SMART_CMD(0x01), 328 + SMART_DAT(0x00), 329 + SMART_DAT(0x01), 330 + SMART_CMD(0x01), 331 + SMART_CMD(0x00), 332 + SMART_DAT(0xFF), 333 + SMART_DAT(0xFE), 334 + SMART_DELAY(150), 335 + }; 336 + 337 + static uint16_t panel_off[] = { 338 + SMART_CMD(0x00), 339 + SMART_CMD(0x1E), 340 + SMART_DAT(0x00), 341 + SMART_DAT(0x0A), 342 + SMART_CMD(0x01), 343 + SMART_CMD(0x00), 344 + SMART_DAT(0xFF), 345 + SMART_DAT(0xEE), 346 + SMART_CMD(0x01), 347 + SMART_CMD(0x00), 348 + SMART_DAT(0xF8), 349 + SMART_DAT(0x12), 350 + SMART_CMD(0x01), 351 + SMART_CMD(0x00), 352 + SMART_DAT(0xE8), 353 + SMART_DAT(0x11), 354 + SMART_CMD(0x01), 355 + SMART_CMD(0x00), 356 + SMART_DAT(0xC0), 357 + SMART_DAT(0x11), 358 + SMART_CMD(0x01), 359 + SMART_CMD(0x00), 360 + SMART_DAT(0x40), 361 + SMART_DAT(0x11), 362 + SMART_CMD(0x01), 363 + SMART_CMD(0x00), 364 + SMART_DAT(0x00), 365 + SMART_DAT(0x10), 366 + }; 367 + 368 + static uint16_t update_framedata[] = { 369 + /* write ram */ 370 + SMART_CMD(0x02), 371 + SMART_CMD(0x02), 372 + 373 + /* write frame data */ 374 + SMART_CMD_WRITE_FRAME, 375 + }; 376 + 377 + static void ltm020d550_lcd_power(int on, struct fb_var_screeninfo *var) 378 + { 379 + struct fb_info *info = container_of(var, struct fb_info, var); 380 + 381 + if (on) { 382 + pxafb_smart_queue(info, ARRAY_AND_SIZE(panel_init)); 383 + pxafb_smart_queue(info, ARRAY_AND_SIZE(panel_on)); 384 + } else { 385 + pxafb_smart_queue(info, ARRAY_AND_SIZE(panel_off)); 386 + } 387 + 388 + if (pxafb_smart_flush(info)) 389 + pr_err("%s: timed out\n", __func__); 390 + } 391 + 392 + static void ltm020d550_update(struct fb_info *info) 393 + { 394 + pxafb_smart_queue(info, ARRAY_AND_SIZE(update_framedata)); 395 + pxafb_smart_flush(info); 396 + } 397 + 398 + static struct pxafb_mode_info toshiba_ltm020d550_modes[] = { 399 + [0] = { 400 + .xres = 240, 401 + .yres = 320, 402 + .bpp = 16, 403 + .a0csrd_set_hld = 30, 404 + .a0cswr_set_hld = 30, 405 + .wr_pulse_width = 30, 406 + .rd_pulse_width = 170, 407 + .op_hold_time = 30, 408 + .cmd_inh_time = 60, 409 + 410 + /* L_LCLK_A0 and L_LCLK_RD active low */ 411 + .sync = FB_SYNC_HOR_HIGH_ACT | 412 + FB_SYNC_VERT_HIGH_ACT, 413 + }, 414 + }; 415 + 416 + static struct pxafb_mach_info tavorevb_lcd_info = { 417 + .modes = toshiba_ltm020d550_modes, 418 + .num_modes = 1, 419 + .lcd_conn = LCD_SMART_PANEL_8BPP | LCD_PCLK_EDGE_FALL, 420 + .pxafb_lcd_power = ltm020d550_lcd_power, 421 + .smart_update = ltm020d550_update, 422 + }; 423 + 424 + static void __init tavorevb_init_lcd(void) 425 + { 426 + platform_device_register(&tavorevb_backlight_devices[0]); 427 + platform_device_register(&tavorevb_backlight_devices[1]); 428 + set_pxa_fb_info(&tavorevb_lcd_info); 429 + } 430 + #else 431 + static inline void tavorevb_init_lcd(void) {} 432 + #endif /* CONFIG_FB_PXA || CONFIG_FB_PXA_MODULE */ 433 + 109 434 static void __init tavorevb_init(void) 110 435 { 111 436 /* initialize MFP configurations */ 112 437 pxa3xx_mfp_config(ARRAY_AND_SIZE(tavorevb_mfp_cfg)); 113 438 114 439 platform_device_register(&smc91x_device); 440 + 441 + tavorevb_init_lcd(); 442 + tavorevb_init_keypad(); 115 443 } 116 444 117 445 MACHINE_START(TAVOREVB, "PXA930 Evaluation Board (aka TavorEVB)")
+1 -9
arch/arm/mach-pxa/time.c
··· 24 24 #include <asm/mach/time.h> 25 25 #include <mach/hardware.h> 26 26 #include <mach/pxa-regs.h> 27 - #include <asm/mach-types.h> 28 27 29 28 /* 30 29 * This is PXA's sched_clock implementation. This has a resolution ··· 150 151 151 152 static void __init pxa_timer_init(void) 152 153 { 153 - unsigned long clock_tick_rate; 154 + unsigned long clock_tick_rate = get_clock_tick_rate(); 154 155 155 156 OIER = 0; 156 157 OSSR = OSSR_M0 | OSSR_M1 | OSSR_M2 | OSSR_M3; 157 - 158 - if (cpu_is_pxa25x()) 159 - clock_tick_rate = 3686400; 160 - else if (machine_is_mainstone()) 161 - clock_tick_rate = 3249600; 162 - else 163 - clock_tick_rate = 3250000; 164 158 165 159 set_oscr2ns_scale(clock_tick_rate); 166 160
+4
arch/arm/mach-sa1100/include/mach/hardware.h
··· 59 59 # define __REG(x) (*((volatile unsigned long *)io_p2v(x))) 60 60 # define __PREG(x) (io_v2p((unsigned long)&(x))) 61 61 62 + static inline unsigned long get_clock_tick_rate(void) 63 + { 64 + return 3686400; 65 + } 62 66 #else 63 67 64 68 # define __REG(x) io_p2v(x)
+7 -5
drivers/rtc/rtc-sa1100.c
··· 38 38 #include <mach/pxa-regs.h> 39 39 #endif 40 40 41 - #define TIMER_FREQ CLOCK_TICK_RATE 42 41 #define RTC_DEF_DIVIDER 32768 - 1 43 42 #define RTC_DEF_TRIM 0 44 43 45 44 static unsigned long rtc_freq = 1024; 45 + static unsigned long timer_freq; 46 46 static struct rtc_time rtc_alarm; 47 47 static DEFINE_SPINLOCK(sa1100_rtc_lock); 48 48 ··· 157 157 rtc_update_irq(rtc, rtc_timer1_count, RTC_PF | RTC_IRQF); 158 158 159 159 if (rtc_timer1_count == 1) 160 - rtc_timer1_count = (rtc_freq * ((1<<30)/(TIMER_FREQ>>2))); 160 + rtc_timer1_count = (rtc_freq * ((1 << 30) / (timer_freq >> 2))); 161 161 162 162 return IRQ_HANDLED; 163 163 } ··· 166 166 { 167 167 if (data & RTC_PF) { 168 168 /* interpolate missed periods and set match for the next */ 169 - unsigned long period = TIMER_FREQ/rtc_freq; 169 + unsigned long period = timer_freq / rtc_freq; 170 170 unsigned long oscr = OSCR; 171 171 unsigned long osmr1 = OSMR1; 172 172 unsigned long missed = (oscr - osmr1)/period; ··· 263 263 return 0; 264 264 case RTC_PIE_ON: 265 265 spin_lock_irq(&sa1100_rtc_lock); 266 - OSMR1 = TIMER_FREQ/rtc_freq + OSCR; 266 + OSMR1 = timer_freq / rtc_freq + OSCR; 267 267 OIER |= OIER_E1; 268 268 rtc_timer1_count = 1; 269 269 spin_unlock_irq(&sa1100_rtc_lock); ··· 271 271 case RTC_IRQP_READ: 272 272 return put_user(rtc_freq, (unsigned long *)arg); 273 273 case RTC_IRQP_SET: 274 - if (arg < 1 || arg > TIMER_FREQ) 274 + if (arg < 1 || arg > timer_freq) 275 275 return -EINVAL; 276 276 rtc_freq = arg; 277 277 return 0; ··· 351 351 static int sa1100_rtc_probe(struct platform_device *pdev) 352 352 { 353 353 struct rtc_device *rtc; 354 + 355 + timer_freq = get_clock_tick_rate(); 354 356 355 357 /* 356 358 * According to the manual we should be able to let RTTR be zero
+5
drivers/video/Kconfig
··· 1817 1817 1818 1818 If unsure, say N. 1819 1819 1820 + config FB_PXA_OVERLAY 1821 + bool "Support PXA27x/PXA3xx Overlay(s) as framebuffer" 1822 + default n 1823 + depends on FB_PXA && (PXA27x || PXA3xx) 1824 + 1820 1825 config FB_PXA_SMARTPANEL 1821 1826 bool "PXA Smartpanel LCD support" 1822 1827 default n
+613 -246
drivers/video/pxafb.c
··· 20 20 * 21 21 * linux-arm-kernel@lists.arm.linux.org.uk 22 22 * 23 + * Add support for overlay1 and overlay2 based on pxafb_overlay.c: 24 + * 25 + * Copyright (C) 2004, Intel Corporation 26 + * 27 + * 2003/08/27: <yu.tang@intel.com> 28 + * 2004/03/10: <stanley.cai@intel.com> 29 + * 2004/10/28: <yan.yin@intel.com> 30 + * 31 + * Copyright (C) 2006-2008 Marvell International Ltd. 32 + * All Rights Reserved 23 33 */ 24 34 25 35 #include <linux/module.h> ··· 76 66 LCCR0_SFM | LCCR0_LDM | LCCR0_ENB) 77 67 78 68 #define LCCR3_INVALID_CONFIG_MASK (LCCR3_HSP | LCCR3_VSP |\ 79 - LCCR3_PCD | LCCR3_BPP) 69 + LCCR3_PCD | LCCR3_BPP(0xf)) 80 70 81 71 static int pxafb_activate_var(struct fb_var_screeninfo *var, 82 72 struct pxafb_info *); 83 73 static void set_ctrlr_state(struct pxafb_info *fbi, u_int state); 74 + static void setup_base_frame(struct pxafb_info *fbi, int branch); 75 + static int setup_frame_dma(struct pxafb_info *fbi, int dma, int pal, 76 + unsigned long offset, size_t size); 77 + 78 + static unsigned long video_mem_size = 0; 84 79 85 80 static inline unsigned long 86 81 lcd_readl(struct pxafb_info *fbi, unsigned int off) ··· 167 152 val |= ((blue >> 8) & 0x000000fc); 168 153 ((u32 *)(fbi->palette_cpu))[regno] = val; 169 154 break; 155 + case LCCR4_PAL_FOR_3: 156 + val = ((red << 8) & 0x00ff0000); 157 + val |= ((green >> 0) & 0x0000ff00); 158 + val |= ((blue >> 8) & 0x000000ff); 159 + ((u32 *)(fbi->palette_cpu))[regno] = val; 160 + break; 170 161 } 171 162 172 163 return 0; ··· 233 212 return ret; 234 213 } 235 214 236 - /* 237 - * pxafb_bpp_to_lccr3(): 238 - * Convert a bits per pixel value to the correct bit pattern for LCCR3 239 - */ 240 - static int pxafb_bpp_to_lccr3(struct fb_var_screeninfo *var) 215 + /* calculate pixel depth, transparency bit included, >=16bpp formats _only_ */ 216 + static inline int var_to_depth(struct fb_var_screeninfo *var) 241 217 { 242 - int ret = 0; 218 + return var->red.length + var->green.length + 219 + var->blue.length + var->transp.length; 220 + } 221 + 222 + /* calculate 4-bit BPP value for LCCR3 and OVLxC1 */ 223 + static int pxafb_var_to_bpp(struct fb_var_screeninfo *var) 224 + { 225 + int bpp = -EINVAL; 226 + 243 227 switch (var->bits_per_pixel) { 244 - case 1: ret = LCCR3_1BPP; break; 245 - case 2: ret = LCCR3_2BPP; break; 246 - case 4: ret = LCCR3_4BPP; break; 247 - case 8: ret = LCCR3_8BPP; break; 248 - case 16: ret = LCCR3_16BPP; break; 228 + case 1: bpp = 0; break; 229 + case 2: bpp = 1; break; 230 + case 4: bpp = 2; break; 231 + case 8: bpp = 3; break; 232 + case 16: bpp = 4; break; 249 233 case 24: 250 - switch (var->red.length + var->green.length + 251 - var->blue.length + var->transp.length) { 252 - case 18: ret = LCCR3_18BPP_P | LCCR3_PDFOR_3; break; 253 - case 19: ret = LCCR3_19BPP_P; break; 234 + switch (var_to_depth(var)) { 235 + case 18: bpp = 6; break; /* 18-bits/pixel packed */ 236 + case 19: bpp = 8; break; /* 19-bits/pixel packed */ 237 + case 24: bpp = 9; break; 254 238 } 255 239 break; 256 240 case 32: 257 - switch (var->red.length + var->green.length + 258 - var->blue.length + var->transp.length) { 259 - case 18: ret = LCCR3_18BPP | LCCR3_PDFOR_3; break; 260 - case 19: ret = LCCR3_19BPP; break; 261 - case 24: ret = LCCR3_24BPP | LCCR3_PDFOR_3; break; 262 - case 25: ret = LCCR3_25BPP; break; 241 + switch (var_to_depth(var)) { 242 + case 18: bpp = 5; break; /* 18-bits/pixel unpacked */ 243 + case 19: bpp = 7; break; /* 19-bits/pixel unpacked */ 244 + case 25: bpp = 10; break; 263 245 } 264 246 break; 265 247 } 266 - return ret; 248 + return bpp; 249 + } 250 + 251 + /* 252 + * pxafb_var_to_lccr3(): 253 + * Convert a bits per pixel value to the correct bit pattern for LCCR3 254 + * 255 + * NOTE: for PXA27x with overlays support, the LCCR3_PDFOR_x bits have an 256 + * implication of the acutal use of transparency bit, which we handle it 257 + * here separatedly. See PXA27x Developer's Manual, Section <<7.4.6 Pixel 258 + * Formats>> for the valid combination of PDFOR, PAL_FOR for various BPP. 259 + * 260 + * Transparency for palette pixel formats is not supported at the moment. 261 + */ 262 + static uint32_t pxafb_var_to_lccr3(struct fb_var_screeninfo *var) 263 + { 264 + int bpp = pxafb_var_to_bpp(var); 265 + uint32_t lccr3; 266 + 267 + if (bpp < 0) 268 + return 0; 269 + 270 + lccr3 = LCCR3_BPP(bpp); 271 + 272 + switch (var_to_depth(var)) { 273 + case 16: lccr3 |= var->transp.length ? LCCR3_PDFOR_3 : 0; break; 274 + case 18: lccr3 |= LCCR3_PDFOR_3; break; 275 + case 24: lccr3 |= var->transp.length ? LCCR3_PDFOR_2 : LCCR3_PDFOR_3; 276 + break; 277 + case 19: 278 + case 25: lccr3 |= LCCR3_PDFOR_0; break; 279 + } 280 + return lccr3; 281 + } 282 + 283 + #define SET_PIXFMT(v, r, g, b, t) \ 284 + ({ \ 285 + (v)->transp.offset = (t) ? (r) + (g) + (b) : 0; \ 286 + (v)->transp.length = (t) ? (t) : 0; \ 287 + (v)->blue.length = (b); (v)->blue.offset = 0; \ 288 + (v)->green.length = (g); (v)->green.offset = (b); \ 289 + (v)->red.length = (r); (v)->red.offset = (b) + (g); \ 290 + }) 291 + 292 + /* set the RGBT bitfields of fb_var_screeninf according to 293 + * var->bits_per_pixel and given depth 294 + */ 295 + static void pxafb_set_pixfmt(struct fb_var_screeninfo *var, int depth) 296 + { 297 + if (depth == 0) 298 + depth = var->bits_per_pixel; 299 + 300 + if (var->bits_per_pixel < 16) { 301 + /* indexed pixel formats */ 302 + var->red.offset = 0; var->red.length = 8; 303 + var->green.offset = 0; var->green.length = 8; 304 + var->blue.offset = 0; var->blue.length = 8; 305 + var->transp.offset = 0; var->transp.length = 8; 306 + } 307 + 308 + switch (depth) { 309 + case 16: var->transp.length ? 310 + SET_PIXFMT(var, 5, 5, 5, 1) : /* RGBT555 */ 311 + SET_PIXFMT(var, 5, 6, 5, 0); break; /* RGB565 */ 312 + case 18: SET_PIXFMT(var, 6, 6, 6, 0); break; /* RGB666 */ 313 + case 19: SET_PIXFMT(var, 6, 6, 6, 1); break; /* RGBT666 */ 314 + case 24: var->transp.length ? 315 + SET_PIXFMT(var, 8, 8, 7, 1) : /* RGBT887 */ 316 + SET_PIXFMT(var, 8, 8, 8, 0); break; /* RGB888 */ 317 + case 25: SET_PIXFMT(var, 8, 8, 8, 1); break; /* RGBT888 */ 318 + } 267 319 } 268 320 269 321 #ifdef CONFIG_CPU_FREQ ··· 398 304 var->lower_margin = mode->lower_margin; 399 305 var->sync = mode->sync; 400 306 var->grayscale = mode->cmap_greyscale; 401 - var->xres_virtual = var->xres; 402 - var->yres_virtual = var->yres; 307 + 308 + /* set the initial RGBA bitfields */ 309 + pxafb_set_pixfmt(var, mode->depth); 310 + } 311 + 312 + static int pxafb_adjust_timing(struct pxafb_info *fbi, 313 + struct fb_var_screeninfo *var) 314 + { 315 + int line_length; 316 + 317 + var->xres = max_t(int, var->xres, MIN_XRES); 318 + var->yres = max_t(int, var->yres, MIN_YRES); 319 + 320 + if (!(fbi->lccr0 & LCCR0_LCDT)) { 321 + clamp_val(var->hsync_len, 1, 64); 322 + clamp_val(var->vsync_len, 1, 64); 323 + clamp_val(var->left_margin, 1, 255); 324 + clamp_val(var->right_margin, 1, 255); 325 + clamp_val(var->upper_margin, 1, 255); 326 + clamp_val(var->lower_margin, 1, 255); 327 + } 328 + 329 + /* make sure each line is aligned on word boundary */ 330 + line_length = var->xres * var->bits_per_pixel / 8; 331 + line_length = ALIGN(line_length, 4); 332 + var->xres = line_length * 8 / var->bits_per_pixel; 333 + 334 + /* we don't support xpan, force xres_virtual to be equal to xres */ 335 + var->xres_virtual = var->xres; 336 + 337 + if (var->accel_flags & FB_ACCELF_TEXT) 338 + var->yres_virtual = fbi->fb.fix.smem_len / line_length; 339 + else 340 + var->yres_virtual = max(var->yres_virtual, var->yres); 341 + 342 + /* check for limits */ 343 + if (var->xres > MAX_XRES || var->yres > MAX_YRES) 344 + return -EINVAL; 345 + 346 + if (var->yres > var->yres_virtual) 347 + return -EINVAL; 348 + 349 + return 0; 403 350 } 404 351 405 352 /* ··· 456 321 { 457 322 struct pxafb_info *fbi = (struct pxafb_info *)info; 458 323 struct pxafb_mach_info *inf = fbi->dev->platform_data; 459 - 460 - if (var->xres < MIN_XRES) 461 - var->xres = MIN_XRES; 462 - if (var->yres < MIN_YRES) 463 - var->yres = MIN_YRES; 324 + int err; 464 325 465 326 if (inf->fixed_modes) { 466 327 struct pxafb_mode_info *mode; ··· 465 334 if (!mode) 466 335 return -EINVAL; 467 336 pxafb_setmode(var, mode); 468 - } else { 469 - if (var->xres > inf->modes->xres) 470 - return -EINVAL; 471 - if (var->yres > inf->modes->yres) 472 - return -EINVAL; 473 - if (var->bits_per_pixel > inf->modes->bpp) 474 - return -EINVAL; 475 337 } 476 338 477 - var->xres_virtual = 478 - max(var->xres_virtual, var->xres); 479 - var->yres_virtual = 480 - max(var->yres_virtual, var->yres); 339 + /* do a test conversion to BPP fields to check the color formats */ 340 + err = pxafb_var_to_bpp(var); 341 + if (err < 0) 342 + return err; 481 343 482 - /* 483 - * Setup the RGB parameters for this display. 484 - * 485 - * The pixel packing format is described on page 7-11 of the 486 - * PXA2XX Developer's Manual. 487 - */ 488 - if (var->bits_per_pixel == 16) { 489 - var->red.offset = 11; var->red.length = 5; 490 - var->green.offset = 5; var->green.length = 6; 491 - var->blue.offset = 0; var->blue.length = 5; 492 - var->transp.offset = var->transp.length = 0; 493 - } else if (var->bits_per_pixel > 16) { 494 - struct pxafb_mode_info *mode; 344 + pxafb_set_pixfmt(var, var_to_depth(var)); 495 345 496 - mode = pxafb_getmode(inf, var); 497 - if (!mode) 498 - return -EINVAL; 499 - 500 - switch (mode->depth) { 501 - case 18: /* RGB666 */ 502 - var->transp.offset = var->transp.length = 0; 503 - var->red.offset = 12; var->red.length = 6; 504 - var->green.offset = 6; var->green.length = 6; 505 - var->blue.offset = 0; var->blue.length = 6; 506 - break; 507 - case 19: /* RGBT666 */ 508 - var->transp.offset = 18; var->transp.length = 1; 509 - var->red.offset = 12; var->red.length = 6; 510 - var->green.offset = 6; var->green.length = 6; 511 - var->blue.offset = 0; var->blue.length = 6; 512 - break; 513 - case 24: /* RGB888 */ 514 - var->transp.offset = var->transp.length = 0; 515 - var->red.offset = 16; var->red.length = 8; 516 - var->green.offset = 8; var->green.length = 8; 517 - var->blue.offset = 0; var->blue.length = 8; 518 - break; 519 - case 25: /* RGBT888 */ 520 - var->transp.offset = 24; var->transp.length = 1; 521 - var->red.offset = 16; var->red.length = 8; 522 - var->green.offset = 8; var->green.length = 8; 523 - var->blue.offset = 0; var->blue.length = 8; 524 - break; 525 - default: 526 - return -EINVAL; 527 - } 528 - } else { 529 - var->red.offset = var->green.offset = 0; 530 - var->blue.offset = var->transp.offset = 0; 531 - var->red.length = 8; 532 - var->green.length = 8; 533 - var->blue.length = 8; 534 - var->transp.length = 0; 535 - } 346 + err = pxafb_adjust_timing(fbi, var); 347 + if (err) 348 + return err; 536 349 537 350 #ifdef CONFIG_CPU_FREQ 538 351 pr_debug("pxafb: dma period = %d ps\n", ··· 484 409 #endif 485 410 486 411 return 0; 487 - } 488 - 489 - static inline void pxafb_set_truecolor(u_int is_true_color) 490 - { 491 - /* do your machine-specific setup if needed */ 492 412 } 493 413 494 414 /* ··· 518 448 519 449 fbi->palette_cpu = (u16 *)&fbi->dma_buff->palette[0]; 520 450 521 - /* 522 - * Set (any) board control register to handle new color depth 523 - */ 524 - pxafb_set_truecolor(fbi->fb.fix.visual == FB_VISUAL_TRUECOLOR); 525 - 526 451 if (fbi->fb.var.bits_per_pixel >= 16) 527 452 fb_dealloc_cmap(&fbi->fb.cmap); 528 453 else ··· 525 460 526 461 pxafb_activate_var(var, fbi); 527 462 463 + return 0; 464 + } 465 + 466 + static int pxafb_pan_display(struct fb_var_screeninfo *var, 467 + struct fb_info *info) 468 + { 469 + struct pxafb_info *fbi = (struct pxafb_info *)info; 470 + int dma = DMA_MAX + DMA_BASE; 471 + 472 + if (fbi->state != C_ENABLE) 473 + return 0; 474 + 475 + setup_base_frame(fbi, 1); 476 + 477 + if (fbi->lccr0 & LCCR0_SDS) 478 + lcd_writel(fbi, FBR1, fbi->fdadr[dma + 1] | 0x1); 479 + 480 + lcd_writel(fbi, FBR0, fbi->fdadr[dma] | 0x1); 528 481 return 0; 529 482 } 530 483 ··· 581 498 return 0; 582 499 } 583 500 584 - static int pxafb_mmap(struct fb_info *info, 585 - struct vm_area_struct *vma) 586 - { 587 - struct pxafb_info *fbi = (struct pxafb_info *)info; 588 - unsigned long off = vma->vm_pgoff << PAGE_SHIFT; 589 - 590 - if (off < info->fix.smem_len) { 591 - vma->vm_pgoff += fbi->video_offset / PAGE_SIZE; 592 - return dma_mmap_writecombine(fbi->dev, vma, fbi->map_cpu, 593 - fbi->map_dma, fbi->map_size); 594 - } 595 - return -EINVAL; 596 - } 597 - 598 501 static struct fb_ops pxafb_ops = { 599 502 .owner = THIS_MODULE, 600 503 .fb_check_var = pxafb_check_var, 601 504 .fb_set_par = pxafb_set_par, 505 + .fb_pan_display = pxafb_pan_display, 602 506 .fb_setcolreg = pxafb_setcolreg, 603 507 .fb_fillrect = cfb_fillrect, 604 508 .fb_copyarea = cfb_copyarea, 605 509 .fb_imageblit = cfb_imageblit, 606 510 .fb_blank = pxafb_blank, 607 - .fb_mmap = pxafb_mmap, 608 511 }; 512 + 513 + #ifdef CONFIG_FB_PXA_OVERLAY 514 + static void overlay1fb_setup(struct pxafb_layer *ofb) 515 + { 516 + int size = ofb->fb.fix.line_length * ofb->fb.var.yres_virtual; 517 + unsigned long start = ofb->video_mem_phys; 518 + setup_frame_dma(ofb->fbi, DMA_OV1, PAL_NONE, start, size); 519 + } 520 + 521 + /* Depending on the enable status of overlay1/2, the DMA should be 522 + * updated from FDADRx (when disabled) or FBRx (when enabled). 523 + */ 524 + static void overlay1fb_enable(struct pxafb_layer *ofb) 525 + { 526 + int enabled = lcd_readl(ofb->fbi, OVL1C1) & OVLxC1_OEN; 527 + uint32_t fdadr1 = ofb->fbi->fdadr[DMA_OV1] | (enabled ? 0x1 : 0); 528 + 529 + lcd_writel(ofb->fbi, enabled ? FBR1 : FDADR1, fdadr1); 530 + lcd_writel(ofb->fbi, OVL1C2, ofb->control[1]); 531 + lcd_writel(ofb->fbi, OVL1C1, ofb->control[0] | OVLxC1_OEN); 532 + } 533 + 534 + static void overlay1fb_disable(struct pxafb_layer *ofb) 535 + { 536 + uint32_t lccr5 = lcd_readl(ofb->fbi, LCCR5); 537 + 538 + lcd_writel(ofb->fbi, OVL1C1, ofb->control[0] & ~OVLxC1_OEN); 539 + 540 + lcd_writel(ofb->fbi, LCSR1, LCSR1_BS(1)); 541 + lcd_writel(ofb->fbi, LCCR5, lccr5 & ~LCSR1_BS(1)); 542 + lcd_writel(ofb->fbi, FBR1, ofb->fbi->fdadr[DMA_OV1] | 0x3); 543 + 544 + if (wait_for_completion_timeout(&ofb->branch_done, 1 * HZ) == 0) 545 + pr_warning("%s: timeout disabling overlay1\n", __func__); 546 + 547 + lcd_writel(ofb->fbi, LCCR5, lccr5); 548 + } 549 + 550 + static void overlay2fb_setup(struct pxafb_layer *ofb) 551 + { 552 + int size, div = 1, pfor = NONSTD_TO_PFOR(ofb->fb.var.nonstd); 553 + unsigned long start[3] = { ofb->video_mem_phys, 0, 0 }; 554 + 555 + if (pfor == OVERLAY_FORMAT_RGB || pfor == OVERLAY_FORMAT_YUV444_PACKED) { 556 + size = ofb->fb.fix.line_length * ofb->fb.var.yres_virtual; 557 + setup_frame_dma(ofb->fbi, DMA_OV2_Y, -1, start[0], size); 558 + } else { 559 + size = ofb->fb.var.xres_virtual * ofb->fb.var.yres_virtual; 560 + switch (pfor) { 561 + case OVERLAY_FORMAT_YUV444_PLANAR: div = 1; break; 562 + case OVERLAY_FORMAT_YUV422_PLANAR: div = 2; break; 563 + case OVERLAY_FORMAT_YUV420_PLANAR: div = 4; break; 564 + } 565 + start[1] = start[0] + size; 566 + start[2] = start[1] + size / div; 567 + setup_frame_dma(ofb->fbi, DMA_OV2_Y, -1, start[0], size); 568 + setup_frame_dma(ofb->fbi, DMA_OV2_Cb, -1, start[1], size / div); 569 + setup_frame_dma(ofb->fbi, DMA_OV2_Cr, -1, start[2], size / div); 570 + } 571 + } 572 + 573 + static void overlay2fb_enable(struct pxafb_layer *ofb) 574 + { 575 + int pfor = NONSTD_TO_PFOR(ofb->fb.var.nonstd); 576 + int enabled = lcd_readl(ofb->fbi, OVL2C1) & OVLxC1_OEN; 577 + uint32_t fdadr2 = ofb->fbi->fdadr[DMA_OV2_Y] | (enabled ? 0x1 : 0); 578 + uint32_t fdadr3 = ofb->fbi->fdadr[DMA_OV2_Cb] | (enabled ? 0x1 : 0); 579 + uint32_t fdadr4 = ofb->fbi->fdadr[DMA_OV2_Cr] | (enabled ? 0x1 : 0); 580 + 581 + if (pfor == OVERLAY_FORMAT_RGB || pfor == OVERLAY_FORMAT_YUV444_PACKED) 582 + lcd_writel(ofb->fbi, enabled ? FBR2 : FDADR2, fdadr2); 583 + else { 584 + lcd_writel(ofb->fbi, enabled ? FBR2 : FDADR2, fdadr2); 585 + lcd_writel(ofb->fbi, enabled ? FBR3 : FDADR3, fdadr3); 586 + lcd_writel(ofb->fbi, enabled ? FBR4 : FDADR4, fdadr4); 587 + } 588 + lcd_writel(ofb->fbi, OVL2C2, ofb->control[1]); 589 + lcd_writel(ofb->fbi, OVL2C1, ofb->control[0] | OVLxC1_OEN); 590 + } 591 + 592 + static void overlay2fb_disable(struct pxafb_layer *ofb) 593 + { 594 + uint32_t lccr5 = lcd_readl(ofb->fbi, LCCR5); 595 + 596 + lcd_writel(ofb->fbi, OVL2C1, ofb->control[0] & ~OVLxC1_OEN); 597 + 598 + lcd_writel(ofb->fbi, LCSR1, LCSR1_BS(2)); 599 + lcd_writel(ofb->fbi, LCCR5, lccr5 & ~LCSR1_BS(2)); 600 + lcd_writel(ofb->fbi, FBR2, ofb->fbi->fdadr[DMA_OV2_Y] | 0x3); 601 + lcd_writel(ofb->fbi, FBR3, ofb->fbi->fdadr[DMA_OV2_Cb] | 0x3); 602 + lcd_writel(ofb->fbi, FBR4, ofb->fbi->fdadr[DMA_OV2_Cr] | 0x3); 603 + 604 + if (wait_for_completion_timeout(&ofb->branch_done, 1 * HZ) == 0) 605 + pr_warning("%s: timeout disabling overlay2\n", __func__); 606 + } 607 + 608 + static struct pxafb_layer_ops ofb_ops[] = { 609 + [0] = { 610 + .enable = overlay1fb_enable, 611 + .disable = overlay1fb_disable, 612 + .setup = overlay1fb_setup, 613 + }, 614 + [1] = { 615 + .enable = overlay2fb_enable, 616 + .disable = overlay2fb_disable, 617 + .setup = overlay2fb_setup, 618 + }, 619 + }; 620 + 621 + static int overlayfb_open(struct fb_info *info, int user) 622 + { 623 + struct pxafb_layer *ofb = (struct pxafb_layer *)info; 624 + 625 + /* no support for framebuffer console on overlay */ 626 + if (user == 0) 627 + return -ENODEV; 628 + 629 + /* allow only one user at a time */ 630 + if (atomic_inc_and_test(&ofb->usage)) 631 + return -EBUSY; 632 + 633 + /* unblank the base framebuffer */ 634 + fb_blank(&ofb->fbi->fb, FB_BLANK_UNBLANK); 635 + return 0; 636 + } 637 + 638 + static int overlayfb_release(struct fb_info *info, int user) 639 + { 640 + struct pxafb_layer *ofb = (struct pxafb_layer*) info; 641 + 642 + atomic_dec(&ofb->usage); 643 + ofb->ops->disable(ofb); 644 + 645 + free_pages_exact(ofb->video_mem, ofb->video_mem_size); 646 + ofb->video_mem = NULL; 647 + ofb->video_mem_size = 0; 648 + return 0; 649 + } 650 + 651 + static int overlayfb_check_var(struct fb_var_screeninfo *var, 652 + struct fb_info *info) 653 + { 654 + struct pxafb_layer *ofb = (struct pxafb_layer *)info; 655 + struct fb_var_screeninfo *base_var = &ofb->fbi->fb.var; 656 + int xpos, ypos, pfor, bpp; 657 + 658 + xpos = NONSTD_TO_XPOS(var->nonstd); 659 + ypos = NONSTD_TO_XPOS(var->nonstd); 660 + pfor = NONSTD_TO_PFOR(var->nonstd); 661 + 662 + bpp = pxafb_var_to_bpp(var); 663 + if (bpp < 0) 664 + return -EINVAL; 665 + 666 + /* no support for YUV format on overlay1 */ 667 + if (ofb->id == OVERLAY1 && pfor != 0) 668 + return -EINVAL; 669 + 670 + /* for YUV packed formats, bpp = 'minimum bpp of YUV components' */ 671 + switch (pfor) { 672 + case OVERLAY_FORMAT_RGB: 673 + bpp = pxafb_var_to_bpp(var); 674 + if (bpp < 0) 675 + return -EINVAL; 676 + 677 + pxafb_set_pixfmt(var, var_to_depth(var)); 678 + break; 679 + case OVERLAY_FORMAT_YUV444_PACKED: bpp = 24; break; 680 + case OVERLAY_FORMAT_YUV444_PLANAR: bpp = 8; break; 681 + case OVERLAY_FORMAT_YUV422_PLANAR: bpp = 4; break; 682 + case OVERLAY_FORMAT_YUV420_PLANAR: bpp = 2; break; 683 + default: 684 + return -EINVAL; 685 + } 686 + 687 + /* each line must start at a 32-bit word boundary */ 688 + if ((xpos * bpp) % 32) 689 + return -EINVAL; 690 + 691 + /* xres must align on 32-bit word boundary */ 692 + var->xres = roundup(var->xres * bpp, 32) / bpp; 693 + 694 + if ((xpos + var->xres > base_var->xres) || 695 + (ypos + var->yres > base_var->yres)) 696 + return -EINVAL; 697 + 698 + var->xres_virtual = var->xres; 699 + var->yres_virtual = max(var->yres, var->yres_virtual); 700 + return 0; 701 + } 702 + 703 + static int overlayfb_map_video_memory(struct pxafb_layer *ofb) 704 + { 705 + struct fb_var_screeninfo *var = &ofb->fb.var; 706 + int pfor = NONSTD_TO_PFOR(var->nonstd); 707 + int size, bpp = 0; 708 + 709 + switch (pfor) { 710 + case OVERLAY_FORMAT_RGB: bpp = var->bits_per_pixel; break; 711 + case OVERLAY_FORMAT_YUV444_PACKED: bpp = 24; break; 712 + case OVERLAY_FORMAT_YUV444_PLANAR: bpp = 24; break; 713 + case OVERLAY_FORMAT_YUV422_PLANAR: bpp = 16; break; 714 + case OVERLAY_FORMAT_YUV420_PLANAR: bpp = 12; break; 715 + } 716 + 717 + ofb->fb.fix.line_length = var->xres_virtual * bpp / 8; 718 + 719 + size = PAGE_ALIGN(ofb->fb.fix.line_length * var->yres_virtual); 720 + 721 + /* don't re-allocate if the original video memory is enough */ 722 + if (ofb->video_mem) { 723 + if (ofb->video_mem_size >= size) 724 + return 0; 725 + 726 + free_pages_exact(ofb->video_mem, ofb->video_mem_size); 727 + } 728 + 729 + ofb->video_mem = alloc_pages_exact(size, GFP_KERNEL | __GFP_ZERO); 730 + if (ofb->video_mem == NULL) 731 + return -ENOMEM; 732 + 733 + ofb->video_mem_phys = virt_to_phys(ofb->video_mem); 734 + ofb->video_mem_size = size; 735 + 736 + ofb->fb.fix.smem_start = ofb->video_mem_phys; 737 + ofb->fb.fix.smem_len = ofb->fb.fix.line_length * var->yres_virtual; 738 + ofb->fb.screen_base = ofb->video_mem; 739 + return 0; 740 + } 741 + 742 + static int overlayfb_set_par(struct fb_info *info) 743 + { 744 + struct pxafb_layer *ofb = (struct pxafb_layer *)info; 745 + struct fb_var_screeninfo *var = &info->var; 746 + int xpos, ypos, pfor, bpp, ret; 747 + 748 + ret = overlayfb_map_video_memory(ofb); 749 + if (ret) 750 + return ret; 751 + 752 + bpp = pxafb_var_to_bpp(var); 753 + xpos = NONSTD_TO_XPOS(var->nonstd); 754 + ypos = NONSTD_TO_XPOS(var->nonstd); 755 + pfor = NONSTD_TO_PFOR(var->nonstd); 756 + 757 + ofb->control[0] = OVLxC1_PPL(var->xres) | OVLxC1_LPO(var->yres) | 758 + OVLxC1_BPP(bpp); 759 + ofb->control[1] = OVLxC2_XPOS(xpos) | OVLxC2_YPOS(ypos); 760 + 761 + if (ofb->id == OVERLAY2) 762 + ofb->control[1] |= OVL2C2_PFOR(pfor); 763 + 764 + ofb->ops->setup(ofb); 765 + ofb->ops->enable(ofb); 766 + return 0; 767 + } 768 + 769 + static struct fb_ops overlay_fb_ops = { 770 + .owner = THIS_MODULE, 771 + .fb_open = overlayfb_open, 772 + .fb_release = overlayfb_release, 773 + .fb_check_var = overlayfb_check_var, 774 + .fb_set_par = overlayfb_set_par, 775 + }; 776 + 777 + static void __devinit init_pxafb_overlay(struct pxafb_info *fbi, 778 + struct pxafb_layer *ofb, int id) 779 + { 780 + sprintf(ofb->fb.fix.id, "overlay%d", id + 1); 781 + 782 + ofb->fb.fix.type = FB_TYPE_PACKED_PIXELS; 783 + ofb->fb.fix.xpanstep = 0; 784 + ofb->fb.fix.ypanstep = 1; 785 + 786 + ofb->fb.var.activate = FB_ACTIVATE_NOW; 787 + ofb->fb.var.height = -1; 788 + ofb->fb.var.width = -1; 789 + ofb->fb.var.vmode = FB_VMODE_NONINTERLACED; 790 + 791 + ofb->fb.fbops = &overlay_fb_ops; 792 + ofb->fb.flags = FBINFO_FLAG_DEFAULT; 793 + ofb->fb.node = -1; 794 + ofb->fb.pseudo_palette = NULL; 795 + 796 + ofb->id = id; 797 + ofb->ops = &ofb_ops[id]; 798 + atomic_set(&ofb->usage, 0); 799 + ofb->fbi = fbi; 800 + init_completion(&ofb->branch_done); 801 + } 802 + 803 + static int __devinit pxafb_overlay_init(struct pxafb_info *fbi) 804 + { 805 + int i, ret; 806 + 807 + for (i = 0; i < 2; i++) { 808 + init_pxafb_overlay(fbi, &fbi->overlay[i], i); 809 + ret = register_framebuffer(&fbi->overlay[i].fb); 810 + if (ret) { 811 + dev_err(fbi->dev, "failed to register overlay %d\n", i); 812 + return ret; 813 + } 814 + } 815 + 816 + /* mask all IU/BS/EOF/SOF interrupts */ 817 + lcd_writel(fbi, LCCR5, ~0); 818 + 819 + /* place overlay(s) on top of base */ 820 + fbi->lccr0 |= LCCR0_OUC; 821 + pr_info("PXA Overlay driver loaded successfully!\n"); 822 + return 0; 823 + } 824 + 825 + static void __devexit pxafb_overlay_exit(struct pxafb_info *fbi) 826 + { 827 + int i; 828 + 829 + for (i = 0; i < 2; i++) 830 + unregister_framebuffer(&fbi->overlay[i].fb); 831 + } 832 + #else 833 + static inline void pxafb_overlay_init(struct pxafb_info *fbi) {} 834 + static inline void pxafb_overlay_exit(struct pxafb_info *fbi) {} 835 + #endif /* CONFIG_FB_PXA_OVERLAY */ 609 836 610 837 /* 611 838 * Calculate the PCD value from the clock rate (in picoseconds). ··· 996 603 EXPORT_SYMBOL(pxafb_get_hsync_time); 997 604 998 605 static int setup_frame_dma(struct pxafb_info *fbi, int dma, int pal, 999 - unsigned int offset, size_t size) 606 + unsigned long start, size_t size) 1000 607 { 1001 608 struct pxafb_dma_descriptor *dma_desc, *pal_desc; 1002 609 unsigned int dma_desc_off, pal_desc_off; 1003 610 1004 - if (dma < 0 || dma >= DMA_MAX) 611 + if (dma < 0 || dma >= DMA_MAX * 2) 1005 612 return -EINVAL; 1006 613 1007 614 dma_desc = &fbi->dma_buff->dma_desc[dma]; 1008 615 dma_desc_off = offsetof(struct pxafb_dma_buff, dma_desc[dma]); 1009 616 1010 - dma_desc->fsadr = fbi->screen_dma + offset; 617 + dma_desc->fsadr = start; 1011 618 dma_desc->fidr = 0; 1012 619 dma_desc->ldcmd = size; 1013 620 1014 - if (pal < 0 || pal >= PAL_MAX) { 621 + if (pal < 0 || pal >= PAL_MAX * 2) { 1015 622 dma_desc->fdadr = fbi->dma_buff_phys + dma_desc_off; 1016 623 fbi->fdadr[dma] = fbi->dma_buff_phys + dma_desc_off; 1017 624 } else { ··· 1035 642 } 1036 643 1037 644 return 0; 645 + } 646 + 647 + static void setup_base_frame(struct pxafb_info *fbi, int branch) 648 + { 649 + struct fb_var_screeninfo *var = &fbi->fb.var; 650 + struct fb_fix_screeninfo *fix = &fbi->fb.fix; 651 + int nbytes, dma, pal, bpp = var->bits_per_pixel; 652 + unsigned long offset; 653 + 654 + dma = DMA_BASE + (branch ? DMA_MAX : 0); 655 + pal = (bpp >= 16) ? PAL_NONE : PAL_BASE + (branch ? PAL_MAX : 0); 656 + 657 + nbytes = fix->line_length * var->yres; 658 + offset = fix->line_length * var->yoffset + fbi->video_mem_phys; 659 + 660 + if (fbi->lccr0 & LCCR0_SDS) { 661 + nbytes = nbytes / 2; 662 + setup_frame_dma(fbi, dma + 1, PAL_NONE, offset + nbytes, nbytes); 663 + } 664 + 665 + setup_frame_dma(fbi, dma, pal, offset, nbytes); 1038 666 } 1039 667 1040 668 #ifdef CONFIG_FB_PXA_SMARTPANEL ··· 1111 697 lcd_writel(fbi, LCCR1, fbi->reg_lccr1); 1112 698 lcd_writel(fbi, LCCR2, fbi->reg_lccr2); 1113 699 lcd_writel(fbi, LCCR3, fbi->reg_lccr3); 700 + lcd_writel(fbi, LCCR4, fbi->reg_lccr4); 1114 701 lcd_writel(fbi, FDADR0, fbi->fdadr[0]); 1115 702 lcd_writel(fbi, FDADR6, fbi->fdadr[6]); 1116 703 ··· 1306 891 struct pxafb_info *fbi) 1307 892 { 1308 893 u_long flags; 1309 - size_t nbytes; 1310 894 1311 - #if DEBUG_VAR 1312 - if (!(fbi->lccr0 & LCCR0_LCDT)) { 1313 - if (var->xres < 16 || var->xres > 1024) 1314 - printk(KERN_ERR "%s: invalid xres %d\n", 1315 - fbi->fb.fix.id, var->xres); 1316 - switch (var->bits_per_pixel) { 1317 - case 1: 1318 - case 2: 1319 - case 4: 1320 - case 8: 1321 - case 16: 1322 - case 24: 1323 - case 32: 1324 - break; 1325 - default: 1326 - printk(KERN_ERR "%s: invalid bit depth %d\n", 1327 - fbi->fb.fix.id, var->bits_per_pixel); 1328 - break; 1329 - } 1330 - 1331 - if (var->hsync_len < 1 || var->hsync_len > 64) 1332 - printk(KERN_ERR "%s: invalid hsync_len %d\n", 1333 - fbi->fb.fix.id, var->hsync_len); 1334 - if (var->left_margin < 1 || var->left_margin > 255) 1335 - printk(KERN_ERR "%s: invalid left_margin %d\n", 1336 - fbi->fb.fix.id, var->left_margin); 1337 - if (var->right_margin < 1 || var->right_margin > 255) 1338 - printk(KERN_ERR "%s: invalid right_margin %d\n", 1339 - fbi->fb.fix.id, var->right_margin); 1340 - if (var->yres < 1 || var->yres > 1024) 1341 - printk(KERN_ERR "%s: invalid yres %d\n", 1342 - fbi->fb.fix.id, var->yres); 1343 - if (var->vsync_len < 1 || var->vsync_len > 64) 1344 - printk(KERN_ERR "%s: invalid vsync_len %d\n", 1345 - fbi->fb.fix.id, var->vsync_len); 1346 - if (var->upper_margin < 0 || var->upper_margin > 255) 1347 - printk(KERN_ERR "%s: invalid upper_margin %d\n", 1348 - fbi->fb.fix.id, var->upper_margin); 1349 - if (var->lower_margin < 0 || var->lower_margin > 255) 1350 - printk(KERN_ERR "%s: invalid lower_margin %d\n", 1351 - fbi->fb.fix.id, var->lower_margin); 1352 - } 1353 - #endif 1354 895 /* Update shadow copy atomically */ 1355 896 local_irq_save(flags); 1356 897 ··· 1317 946 #endif 1318 947 setup_parallel_timing(fbi, var); 1319 948 949 + setup_base_frame(fbi, 0); 950 + 1320 951 fbi->reg_lccr0 = fbi->lccr0 | 1321 952 (LCCR0_LDM | LCCR0_SFM | LCCR0_IUM | LCCR0_EFM | 1322 953 LCCR0_QDM | LCCR0_BM | LCCR0_OUM); 1323 954 1324 - fbi->reg_lccr3 |= pxafb_bpp_to_lccr3(var); 1325 - 1326 - nbytes = var->yres * fbi->fb.fix.line_length; 1327 - 1328 - if ((fbi->lccr0 & LCCR0_SDS) == LCCR0_Dual) { 1329 - nbytes = nbytes / 2; 1330 - setup_frame_dma(fbi, DMA_LOWER, PAL_NONE, nbytes, nbytes); 1331 - } 1332 - 1333 - if ((var->bits_per_pixel >= 16) || (fbi->lccr0 & LCCR0_LCDT)) 1334 - setup_frame_dma(fbi, DMA_BASE, PAL_NONE, 0, nbytes); 1335 - else 1336 - setup_frame_dma(fbi, DMA_BASE, PAL_BASE, 0, nbytes); 955 + fbi->reg_lccr3 |= pxafb_var_to_lccr3(var); 1337 956 1338 957 fbi->reg_lccr4 = lcd_readl(fbi, LCCR4) & ~LCCR4_PAL_FOR_MASK; 1339 958 fbi->reg_lccr4 |= (fbi->lccr4 & LCCR4_PAL_FOR_MASK); ··· 1337 976 (lcd_readl(fbi, LCCR1) != fbi->reg_lccr1) || 1338 977 (lcd_readl(fbi, LCCR2) != fbi->reg_lccr2) || 1339 978 (lcd_readl(fbi, LCCR3) != fbi->reg_lccr3) || 979 + (lcd_readl(fbi, LCCR4) != fbi->reg_lccr4) || 1340 980 (lcd_readl(fbi, FDADR0) != fbi->fdadr[0]) || 1341 981 (lcd_readl(fbi, FDADR1) != fbi->fdadr[1])) 1342 982 pxafb_schedule_work(fbi, C_REENABLE); ··· 1384 1022 return; 1385 1023 1386 1024 /* Sequence from 11.7.10 */ 1025 + lcd_writel(fbi, LCCR4, fbi->reg_lccr4); 1387 1026 lcd_writel(fbi, LCCR3, fbi->reg_lccr3); 1388 1027 lcd_writel(fbi, LCCR2, fbi->reg_lccr2); 1389 1028 lcd_writel(fbi, LCCR1, fbi->reg_lccr1); ··· 1426 1063 static irqreturn_t pxafb_handle_irq(int irq, void *dev_id) 1427 1064 { 1428 1065 struct pxafb_info *fbi = dev_id; 1429 - unsigned int lccr0, lcsr = lcd_readl(fbi, LCSR); 1066 + unsigned int lccr0, lcsr, lcsr1; 1430 1067 1068 + lcsr = lcd_readl(fbi, LCSR); 1431 1069 if (lcsr & LCSR_LDD) { 1432 1070 lccr0 = lcd_readl(fbi, LCCR0); 1433 1071 lcd_writel(fbi, LCCR0, lccr0 | LCCR0_LDM); ··· 1439 1075 if (lcsr & LCSR_CMD_INT) 1440 1076 complete(&fbi->command_done); 1441 1077 #endif 1442 - 1443 1078 lcd_writel(fbi, LCSR, lcsr); 1079 + 1080 + #ifdef CONFIG_FB_PXA_OVERLAY 1081 + lcsr1 = lcd_readl(fbi, LCSR1); 1082 + if (lcsr1 & LCSR1_BS(1)) 1083 + complete(&fbi->overlay[0].branch_done); 1084 + 1085 + if (lcsr1 & LCSR1_BS(2)) 1086 + complete(&fbi->overlay[1].branch_done); 1087 + 1088 + lcd_writel(fbi, LCSR1, lcsr1); 1089 + #endif 1444 1090 return IRQ_HANDLED; 1445 1091 } 1446 1092 ··· 1641 1267 #define pxafb_resume NULL 1642 1268 #endif 1643 1269 1644 - /* 1645 - * pxafb_map_video_memory(): 1646 - * Allocates the DRAM memory for the frame buffer. This buffer is 1647 - * remapped into a non-cached, non-buffered, memory region to 1648 - * allow palette and pixel writes to occur without flushing the 1649 - * cache. Once this area is remapped, all virtual memory 1650 - * access to the video memory should occur at the new region. 1651 - */ 1652 - static int __devinit pxafb_map_video_memory(struct pxafb_info *fbi) 1270 + static int __devinit pxafb_init_video_memory(struct pxafb_info *fbi) 1653 1271 { 1654 - /* 1655 - * We reserve one page for the palette, plus the size 1656 - * of the framebuffer. 1657 - */ 1658 - fbi->video_offset = PAGE_ALIGN(sizeof(struct pxafb_dma_buff)); 1659 - fbi->map_size = PAGE_ALIGN(fbi->fb.fix.smem_len + fbi->video_offset); 1660 - fbi->map_cpu = dma_alloc_writecombine(fbi->dev, fbi->map_size, 1661 - &fbi->map_dma, GFP_KERNEL); 1272 + int size = PAGE_ALIGN(fbi->video_mem_size); 1662 1273 1663 - if (fbi->map_cpu) { 1664 - /* prevent initial garbage on screen */ 1665 - memset(fbi->map_cpu, 0, fbi->map_size); 1666 - fbi->fb.screen_base = fbi->map_cpu + fbi->video_offset; 1667 - fbi->screen_dma = fbi->map_dma + fbi->video_offset; 1274 + fbi->video_mem = alloc_pages_exact(size, GFP_KERNEL | __GFP_ZERO); 1275 + if (fbi->video_mem == NULL) 1276 + return -ENOMEM; 1668 1277 1669 - /* 1670 - * FIXME: this is actually the wrong thing to place in 1671 - * smem_start. But fbdev suffers from the problem that 1672 - * it needs an API which doesn't exist (in this case, 1673 - * dma_writecombine_mmap) 1674 - */ 1675 - fbi->fb.fix.smem_start = fbi->screen_dma; 1676 - fbi->palette_size = fbi->fb.var.bits_per_pixel == 8 ? 256 : 16; 1278 + fbi->video_mem_phys = virt_to_phys(fbi->video_mem); 1279 + fbi->video_mem_size = size; 1677 1280 1678 - fbi->dma_buff = (void *) fbi->map_cpu; 1679 - fbi->dma_buff_phys = fbi->map_dma; 1680 - fbi->palette_cpu = (u16 *) fbi->dma_buff->palette; 1281 + fbi->fb.fix.smem_start = fbi->video_mem_phys; 1282 + fbi->fb.fix.smem_len = fbi->video_mem_size; 1283 + fbi->fb.screen_base = fbi->video_mem; 1681 1284 1682 - pr_debug("pxafb: palette_mem_size = 0x%08x\n", fbi->palette_size*sizeof(u16)); 1683 - } 1684 - 1685 - return fbi->map_cpu ? 0 : -ENOMEM; 1686 - } 1687 - 1688 - static void pxafb_decode_mode_info(struct pxafb_info *fbi, 1689 - struct pxafb_mode_info *modes, 1690 - unsigned int num_modes) 1691 - { 1692 - unsigned int i, smemlen; 1693 - 1694 - pxafb_setmode(&fbi->fb.var, &modes[0]); 1695 - 1696 - for (i = 0; i < num_modes; i++) { 1697 - smemlen = modes[i].xres * modes[i].yres * modes[i].bpp / 8; 1698 - if (smemlen > fbi->fb.fix.smem_len) 1699 - fbi->fb.fix.smem_len = smemlen; 1700 - } 1285 + return fbi->video_mem ? 0 : -ENOMEM; 1701 1286 } 1702 1287 1703 1288 static void pxafb_decode_mach_info(struct pxafb_info *fbi, 1704 1289 struct pxafb_mach_info *inf) 1705 1290 { 1706 1291 unsigned int lcd_conn = inf->lcd_conn; 1292 + struct pxafb_mode_info *m; 1293 + int i; 1707 1294 1708 1295 fbi->cmap_inverse = inf->cmap_inverse; 1709 1296 fbi->cmap_static = inf->cmap_static; 1297 + fbi->lccr4 = inf->lccr4; 1710 1298 1711 1299 switch (lcd_conn & LCD_TYPE_MASK) { 1712 1300 case LCD_TYPE_MONO_STN: ··· 1693 1357 /* fall back to backward compatibility way */ 1694 1358 fbi->lccr0 = inf->lccr0; 1695 1359 fbi->lccr3 = inf->lccr3; 1696 - fbi->lccr4 = inf->lccr4; 1697 1360 goto decode_mode; 1698 1361 } 1699 1362 ··· 1706 1371 fbi->lccr3 |= (lcd_conn & LCD_PCLK_EDGE_FALL) ? LCCR3_PCP : 0; 1707 1372 1708 1373 decode_mode: 1709 - pxafb_decode_mode_info(fbi, inf->modes, inf->num_modes); 1374 + pxafb_setmode(&fbi->fb.var, &inf->modes[0]); 1375 + 1376 + /* decide video memory size as follows: 1377 + * 1. default to mode of maximum resolution 1378 + * 2. allow platform to override 1379 + * 3. allow module parameter to override 1380 + */ 1381 + for (i = 0, m = &inf->modes[0]; i < inf->num_modes; i++, m++) 1382 + fbi->video_mem_size = max_t(size_t, fbi->video_mem_size, 1383 + m->xres * m->yres * m->bpp / 8); 1384 + 1385 + if (inf->video_mem_size > fbi->video_mem_size) 1386 + fbi->video_mem_size = inf->video_mem_size; 1387 + 1388 + if (video_mem_size > fbi->video_mem_size) 1389 + fbi->video_mem_size = video_mem_size; 1710 1390 } 1711 1391 1712 1392 static struct pxafb_info * __devinit pxafb_init_fbinfo(struct device *dev) ··· 1749 1399 fbi->fb.fix.type = FB_TYPE_PACKED_PIXELS; 1750 1400 fbi->fb.fix.type_aux = 0; 1751 1401 fbi->fb.fix.xpanstep = 0; 1752 - fbi->fb.fix.ypanstep = 0; 1402 + fbi->fb.fix.ypanstep = 1; 1753 1403 fbi->fb.fix.ywrapstep = 0; 1754 1404 fbi->fb.fix.accel = FB_ACCEL_NONE; 1755 1405 ··· 1757 1407 fbi->fb.var.activate = FB_ACTIVATE_NOW; 1758 1408 fbi->fb.var.height = -1; 1759 1409 fbi->fb.var.width = -1; 1760 - fbi->fb.var.accel_flags = 0; 1410 + fbi->fb.var.accel_flags = FB_ACCELF_TEXT; 1761 1411 fbi->fb.var.vmode = FB_VMODE_NONINTERLACED; 1762 1412 1763 1413 fbi->fb.fbops = &pxafb_ops; ··· 1849 1499 1850 1500 s[0] = '\0'; 1851 1501 1852 - if (!strncmp(this_opt, "mode:", 5)) { 1502 + if (!strncmp(this_opt, "vmem:", 5)) { 1503 + video_mem_size = memparse(this_opt + 5, NULL); 1504 + } else if (!strncmp(this_opt, "mode:", 5)) { 1853 1505 return parse_opt_mode(dev, this_opt); 1854 1506 } else if (!strncmp(this_opt, "pixclock:", 9)) { 1855 1507 mode->pixclock = simple_strtoul(this_opt+9, NULL, 0); ··· 2088 1736 goto failed_free_res; 2089 1737 } 2090 1738 2091 - /* Initialize video memory */ 2092 - ret = pxafb_map_video_memory(fbi); 1739 + fbi->dma_buff_size = PAGE_ALIGN(sizeof(struct pxafb_dma_buff)); 1740 + fbi->dma_buff = dma_alloc_coherent(fbi->dev, fbi->dma_buff_size, 1741 + &fbi->dma_buff_phys, GFP_KERNEL); 1742 + if (fbi->dma_buff == NULL) { 1743 + dev_err(&dev->dev, "failed to allocate memory for DMA\n"); 1744 + ret = -ENOMEM; 1745 + goto failed_free_io; 1746 + } 1747 + 1748 + ret = pxafb_init_video_memory(fbi); 2093 1749 if (ret) { 2094 1750 dev_err(&dev->dev, "Failed to allocate video RAM: %d\n", ret); 2095 1751 ret = -ENOMEM; 2096 - goto failed_free_io; 1752 + goto failed_free_dma; 2097 1753 } 2098 1754 2099 1755 irq = platform_get_irq(dev, 0); ··· 2149 1789 goto failed_free_cmap; 2150 1790 } 2151 1791 1792 + pxafb_overlay_init(fbi); 1793 + 2152 1794 #ifdef CONFIG_CPU_FREQ 2153 1795 fbi->freq_transition.notifier_call = pxafb_freq_transition; 2154 1796 fbi->freq_policy.notifier_call = pxafb_freq_policy; ··· 2173 1811 failed_free_irq: 2174 1812 free_irq(irq, fbi); 2175 1813 failed_free_mem: 2176 - dma_free_writecombine(&dev->dev, fbi->map_size, 2177 - fbi->map_cpu, fbi->map_dma); 1814 + free_pages_exact(fbi->video_mem, fbi->video_mem_size); 1815 + failed_free_dma: 1816 + dma_free_coherent(&dev->dev, fbi->dma_buff_size, 1817 + fbi->dma_buff, fbi->dma_buff_phys); 2178 1818 failed_free_io: 2179 1819 iounmap(fbi->mmio_base); 2180 1820 failed_free_res: ··· 2201 1837 2202 1838 info = &fbi->fb; 2203 1839 1840 + pxafb_overlay_exit(fbi); 2204 1841 unregister_framebuffer(info); 2205 1842 2206 1843 pxafb_disable_controller(fbi); ··· 2212 1847 irq = platform_get_irq(dev, 0); 2213 1848 free_irq(irq, fbi); 2214 1849 2215 - dma_free_writecombine(&dev->dev, fbi->map_size, 2216 - fbi->map_cpu, fbi->map_dma); 1850 + free_pages_exact(fbi->video_mem, fbi->video_mem_size); 1851 + 1852 + dma_free_writecombine(&dev->dev, fbi->dma_buff_size, 1853 + fbi->dma_buff, fbi->dma_buff_phys); 2217 1854 2218 1855 iounmap(fbi->mmio_base); 2219 1856
+61 -16
drivers/video/pxafb.h
··· 54 54 #define PALETTE_SIZE (256 * 4) 55 55 #define CMD_BUFF_SIZE (1024 * 50) 56 56 57 + /* NOTE: the palette and frame dma descriptors are doubled to allow 58 + * the 2nd set for branch settings (FBRx) 59 + */ 57 60 struct pxafb_dma_buff { 58 61 unsigned char palette[PAL_MAX * PALETTE_SIZE]; 59 62 uint16_t cmd_buff[CMD_BUFF_SIZE]; 60 - struct pxafb_dma_descriptor pal_desc[PAL_MAX]; 61 - struct pxafb_dma_descriptor dma_desc[DMA_MAX]; 63 + struct pxafb_dma_descriptor pal_desc[PAL_MAX * 2]; 64 + struct pxafb_dma_descriptor dma_desc[DMA_MAX * 2]; 65 + }; 66 + 67 + enum { 68 + OVERLAY1, 69 + OVERLAY2, 70 + }; 71 + 72 + enum { 73 + OVERLAY_FORMAT_RGB = 0, 74 + OVERLAY_FORMAT_YUV444_PACKED, 75 + OVERLAY_FORMAT_YUV444_PLANAR, 76 + OVERLAY_FORMAT_YUV422_PLANAR, 77 + OVERLAY_FORMAT_YUV420_PLANAR, 78 + }; 79 + 80 + #define NONSTD_TO_XPOS(x) (((x) >> 0) & 0x3ff) 81 + #define NONSTD_TO_YPOS(x) (((x) >> 10) & 0x3ff) 82 + #define NONSTD_TO_PFOR(x) (((x) >> 20) & 0x7) 83 + 84 + struct pxafb_layer; 85 + 86 + struct pxafb_layer_ops { 87 + void (*enable)(struct pxafb_layer *); 88 + void (*disable)(struct pxafb_layer *); 89 + void (*setup)(struct pxafb_layer *); 90 + }; 91 + 92 + struct pxafb_layer { 93 + struct fb_info fb; 94 + int id; 95 + atomic_t usage; 96 + uint32_t control[2]; 97 + 98 + struct pxafb_layer_ops *ops; 99 + 100 + void __iomem *video_mem; 101 + unsigned long video_mem_phys; 102 + size_t video_mem_size; 103 + struct completion branch_done; 104 + 105 + struct pxafb_info *fbi; 62 106 }; 63 107 64 108 struct pxafb_info { ··· 113 69 void __iomem *mmio_base; 114 70 115 71 struct pxafb_dma_buff *dma_buff; 72 + size_t dma_buff_size; 116 73 dma_addr_t dma_buff_phys; 117 - dma_addr_t fdadr[DMA_MAX]; 74 + dma_addr_t fdadr[DMA_MAX * 2]; 118 75 119 - /* 120 - * These are the addresses we mapped 121 - * the framebuffer memory region to. 122 - */ 123 - /* raw memory addresses */ 124 - dma_addr_t map_dma; /* physical */ 125 - u_char * map_cpu; /* virtual */ 126 - u_int map_size; 127 - 128 - /* addresses of pieces placed in raw buffer */ 129 - u_char * screen_cpu; /* virtual address of frame buffer */ 130 - dma_addr_t screen_dma; /* physical address of frame buffer */ 76 + void __iomem *video_mem; /* virtual address of frame buffer */ 77 + unsigned long video_mem_phys; /* physical address of frame buffer */ 78 + size_t video_mem_size; /* size of the frame buffer */ 131 79 u16 * palette_cpu; /* virtual address of palette memory */ 132 80 u_int palette_size; 133 - ssize_t video_offset; 134 81 135 82 u_int lccr0; 136 83 u_int lccr3; ··· 155 120 struct task_struct *smart_thread; 156 121 #endif 157 122 123 + #ifdef CONFIG_FB_PXA_OVERLAY 124 + struct pxafb_layer overlay[2]; 125 + #endif 126 + 158 127 #ifdef CONFIG_CPU_FREQ 159 128 struct notifier_block freq_transition; 160 129 struct notifier_block freq_policy; ··· 189 150 */ 190 151 #define MIN_XRES 64 191 152 #define MIN_YRES 64 153 + 154 + /* maximum X and Y resolutions - note these are limits from the register 155 + * bits length instead of the real ones 156 + */ 157 + #define MAX_XRES 1024 158 + #define MAX_YRES 1024 192 159 193 160 #endif /* __PXAFB_H__ */
+6 -5
drivers/watchdog/sa1100_wdt.c
··· 36 36 #include <mach/reset.h> 37 37 #include <mach/hardware.h> 38 38 39 - #define OSCR_FREQ CLOCK_TICK_RATE 40 - 39 + static unsigned long oscr_freq; 41 40 static unsigned long sa1100wdt_users; 42 41 static int pre_margin; 43 42 static int boot_status; ··· 123 124 break; 124 125 } 125 126 126 - pre_margin = OSCR_FREQ * time; 127 + pre_margin = oscr_freq * time; 127 128 OSMR3 = OSCR + pre_margin; 128 129 /*fall through*/ 129 130 130 131 case WDIOC_GETTIMEOUT: 131 - ret = put_user(pre_margin / OSCR_FREQ, p); 132 + ret = put_user(pre_margin / oscr_freq, p); 132 133 break; 133 134 } 134 135 return ret; ··· 155 156 { 156 157 int ret; 157 158 159 + oscr_freq = get_clock_tick_rate(); 160 + 158 161 /* 159 162 * Read the reset status, and save it for later. If 160 163 * we suspend, RCSR will be cleared, and the watchdog ··· 164 163 */ 165 164 boot_status = (reset_status & RESET_STATUS_WATCHDOG) ? 166 165 WDIOF_CARDRESET : 0; 167 - pre_margin = OSCR_FREQ * margin; 166 + pre_margin = oscr_freq * margin; 168 167 169 168 ret = misc_register(&sa1100dog_miscdev); 170 169 if (ret == 0)