Commit aac51f09 authored by Richard Purdie's avatar Richard Purdie Committed by Linus Torvalds

[PATCH] w100fb: Rewrite for platform independence

The code w100fb was based on was horribly Sharp SL-C7x0 specific and there
was little else that could be done as I had no access to anything else with
a w100 in it.  There is no real documentation about this chipset available.

Ian Molton has access to other platforms with the w100 (Toshiba e-series)
and so between us, we've improved w100fb and made it platform independent.
Ian Molton also added support for the very similar w3220 and w3200
chipsets.

There are a lot of changes here and it nearly amounts to a rewrite of the
driver but it has been extensively tested and is being used in preference
to the original driver in the Zaurus community.  I'd therefore like to
update the mainline code to reflect this.
Signed-off-by: default avatarRichard Purdie <rpurdie@rpsys.net>
Acked-by: default avatarAntonino Daplas <adaplas@pol.net>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 8cc3c7af
This diff is collapsed.
...@@ -5,9 +5,12 @@ ...@@ -5,9 +5,12 @@
* *
* Copyright (C) 2002, ATI Corp. * Copyright (C) 2002, ATI Corp.
* Copyright (C) 2004-2005 Richard Purdie * Copyright (C) 2004-2005 Richard Purdie
* Copyright (c) 2005 Ian Molton <spyro@f2s.com>
* *
* Modified to work with 2.6 by Richard Purdie <rpurdie@rpsys.net> * Modified to work with 2.6 by Richard Purdie <rpurdie@rpsys.net>
* *
* w32xx support by Ian Molton
*
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as * it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation. * published by the Free Software Foundation.
...@@ -157,6 +160,22 @@ ...@@ -157,6 +160,22 @@
#define mmMC_PERF_COUNTERS 0x01B4 #define mmMC_PERF_COUNTERS 0x01B4
/* Block MC End: */ /* Block MC End: */
/* Block BM Start: */
#define mmBM_EXT_MEM_BANDWIDTH 0x0A00
#define mmBM_OFFSET 0x0A04
#define mmBM_MEM_EXT_TIMING_CNTL 0x0A08
#define mmBM_MEM_EXT_CNTL 0x0A0C
#define mmBM_MEM_MODE_REG 0x0A10
#define mmBM_MEM_IO_CNTL 0x0A18
#define mmBM_CONFIG 0x0A1C
#define mmBM_STATUS 0x0A20
#define mmBM_DEBUG 0x0A24
#define mmBM_PERF_MON_CNTL 0x0A28
#define mmBM_PERF_COUNTERS 0x0A2C
#define mmBM_PERF2_MON_CNTL 0x0A30
#define mmBM_PERF2_COUNTERS 0x0A34
/* Block BM End: */
/* Block RBBM Start: */ /* Block RBBM Start: */
#define mmWAIT_UNTIL 0x1400 #define mmWAIT_UNTIL 0x1400
#define mmISYNC_CNTL 0x1404 #define mmISYNC_CNTL 0x1404
...@@ -191,14 +210,19 @@ ...@@ -191,14 +210,19 @@
#define W100_REG_BASE 0x10000 #define W100_REG_BASE 0x10000
#define W100_REG_LEN 0x2000 #define W100_REG_LEN 0x2000
#define MEM_INT_BASE_VALUE 0x100000 #define MEM_INT_BASE_VALUE 0x100000
#define MEM_INT_TOP_VALUE_W100 0x15ffff
#define MEM_EXT_BASE_VALUE 0x800000 #define MEM_EXT_BASE_VALUE 0x800000
#define MEM_EXT_TOP_VALUE 0x9fffff #define MEM_INT_SIZE 0x05ffff
#define MEM_WINDOW_BASE 0x100000
#define MEM_WINDOW_SIZE 0xf00000
#define WRAP_BUF_BASE_VALUE 0x80000 #define WRAP_BUF_BASE_VALUE 0x80000
#define WRAP_BUF_TOP_VALUE 0xbffff #define WRAP_BUF_TOP_VALUE 0xbffff
#define CHIP_ID_W100 0x57411002
#define CHIP_ID_W3200 0x56441002
#define CHIP_ID_W3220 0x57441002
/* data structure definitions */ /* Register structure definitions */
struct wrap_top_dir_t { struct wrap_top_dir_t {
unsigned long top_addr : 23; unsigned long top_addr : 23;
...@@ -364,8 +388,8 @@ union intf_cntl_u { ...@@ -364,8 +388,8 @@ union intf_cntl_u {
struct cpu_defaults_t { struct cpu_defaults_t {
unsigned char unpack_rd_data : 1; unsigned char unpack_rd_data : 1;
unsigned char access_ind_addr_a: 1; unsigned char access_ind_addr_a : 1;
unsigned char access_ind_addr_b: 1; unsigned char access_ind_addr_b : 1;
unsigned char access_scratch_reg : 1; unsigned char access_scratch_reg : 1;
unsigned char pack_wr_data : 1; unsigned char pack_wr_data : 1;
unsigned char transition_size : 1; unsigned char transition_size : 1;
...@@ -378,6 +402,120 @@ union cpu_defaults_u { ...@@ -378,6 +402,120 @@ union cpu_defaults_u {
struct cpu_defaults_t f; struct cpu_defaults_t f;
} __attribute__((packed)); } __attribute__((packed));
struct crtc_total_t {
unsigned long crtc_h_total : 10;
unsigned long : 6;
unsigned long crtc_v_total : 10;
unsigned long : 6;
} __attribute__((packed));
union crtc_total_u {
unsigned long val : 32;
struct crtc_total_t f;
} __attribute__((packed));
struct crtc_ss_t {
unsigned long ss_start : 10;
unsigned long : 6;
unsigned long ss_end : 10;
unsigned long : 2;
unsigned long ss_align : 1;
unsigned long ss_pol : 1;
unsigned long ss_run_mode : 1;
unsigned long ss_en : 1;
} __attribute__((packed));
union crtc_ss_u {
unsigned long val : 32;
struct crtc_ss_t f;
} __attribute__((packed));
struct active_h_disp_t {
unsigned long active_h_start : 10;
unsigned long : 6;
unsigned long active_h_end : 10;
unsigned long : 6;
} __attribute__((packed));
union active_h_disp_u {
unsigned long val : 32;
struct active_h_disp_t f;
} __attribute__((packed));
struct active_v_disp_t {
unsigned long active_v_start : 10;
unsigned long : 6;
unsigned long active_v_end : 10;
unsigned long : 6;
} __attribute__((packed));
union active_v_disp_u {
unsigned long val : 32;
struct active_v_disp_t f;
} __attribute__((packed));
struct graphic_h_disp_t {
unsigned long graphic_h_start : 10;
unsigned long : 6;
unsigned long graphic_h_end : 10;
unsigned long : 6;
} __attribute__((packed));
union graphic_h_disp_u {
unsigned long val : 32;
struct graphic_h_disp_t f;
} __attribute__((packed));
struct graphic_v_disp_t {
unsigned long graphic_v_start : 10;
unsigned long : 6;
unsigned long graphic_v_end : 10;
unsigned long : 6;
} __attribute__((packed));
union graphic_v_disp_u{
unsigned long val : 32;
struct graphic_v_disp_t f;
} __attribute__((packed));
struct graphic_ctrl_t_w100 {
unsigned long color_depth : 3;
unsigned long portrait_mode : 2;
unsigned long low_power_on : 1;
unsigned long req_freq : 4;
unsigned long en_crtc : 1;
unsigned long en_graphic_req : 1;
unsigned long en_graphic_crtc : 1;
unsigned long total_req_graphic : 9;
unsigned long lcd_pclk_on : 1;
unsigned long lcd_sclk_on : 1;
unsigned long pclk_running : 1;
unsigned long sclk_running : 1;
unsigned long : 6;
} __attribute__((packed));
struct graphic_ctrl_t_w32xx {
unsigned long color_depth : 3;
unsigned long portrait_mode : 2;
unsigned long low_power_on : 1;
unsigned long req_freq : 4;
unsigned long en_crtc : 1;
unsigned long en_graphic_req : 1;
unsigned long en_graphic_crtc : 1;
unsigned long total_req_graphic : 10;
unsigned long lcd_pclk_on : 1;
unsigned long lcd_sclk_on : 1;
unsigned long pclk_running : 1;
unsigned long sclk_running : 1;
unsigned long : 5;
} __attribute__((packed));
union graphic_ctrl_u {
unsigned long val : 32;
struct graphic_ctrl_t_w100 f_w100;
struct graphic_ctrl_t_w32xx f_w32xx;
} __attribute__((packed));
struct video_ctrl_t { struct video_ctrl_t {
unsigned long video_mode : 1; unsigned long video_mode : 1;
unsigned long keyer_en : 1; unsigned long keyer_en : 1;
...@@ -480,6 +618,16 @@ union mc_ext_mem_location_u { ...@@ -480,6 +618,16 @@ union mc_ext_mem_location_u {
struct mc_ext_mem_location_t f; struct mc_ext_mem_location_t f;
} __attribute__((packed)); } __attribute__((packed));
struct mc_fb_location_t {
unsigned long mc_fb_start : 16;
unsigned long mc_fb_top : 16;
} __attribute__((packed));
union mc_fb_location_u {
unsigned long val : 32;
struct mc_fb_location_t f;
} __attribute__((packed));
struct clk_pin_cntl_t { struct clk_pin_cntl_t {
unsigned long osc_en : 1; unsigned long osc_en : 1;
unsigned long osc_gain : 5; unsigned long osc_gain : 5;
...@@ -579,6 +727,13 @@ union pclk_cntl_u { ...@@ -579,6 +727,13 @@ union pclk_cntl_u {
struct pclk_cntl_t f; struct pclk_cntl_t f;
} __attribute__((packed)); } __attribute__((packed));
#define TESTCLK_SRC_PLL 0x01
#define TESTCLK_SRC_SCLK 0x02
#define TESTCLK_SRC_PCLK 0x03
/* 4 and 5 seem to by XTAL/M */
#define TESTCLK_SRC_XTAL 0x06
struct clk_test_cntl_t { struct clk_test_cntl_t {
unsigned long testclk_sel : 4; unsigned long testclk_sel : 4;
unsigned long : 3; unsigned long : 3;
......
/* /*
* Support for the w100 frame buffer. * Support for the w100 frame buffer.
* *
* Copyright (c) 2004 Richard Purdie * Copyright (c) 2004-2005 Richard Purdie
* Copyright (c) 2005 Ian Molton
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as * it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation. * published by the Free Software Foundation.
*/ */
#define W100_GPIO_PORT_A 0
#define W100_GPIO_PORT_B 1
#define CLK_SRC_XTAL 0
#define CLK_SRC_PLL 1
struct w100fb_par;
unsigned long w100fb_gpio_read(int port);
void w100fb_gpio_write(int port, unsigned long value);
/* LCD Specific Routines and Config */
struct w100_tg_info {
void (*change)(struct w100fb_par*);
void (*suspend)(struct w100fb_par*);
void (*resume)(struct w100fb_par*);
};
/* General Platform Specific w100 Register Values */
struct w100_gen_regs {
unsigned long lcd_format;
unsigned long lcdd_cntl1;
unsigned long lcdd_cntl2;
unsigned long genlcd_cntl1;
unsigned long genlcd_cntl2;
unsigned long genlcd_cntl3;
};
struct w100_gpio_regs {
unsigned long init_data1;
unsigned long init_data2;
unsigned long gpio_dir1;
unsigned long gpio_oe1;
unsigned long gpio_dir2;
unsigned long gpio_oe2;
};
/* Optional External Memory Configuration */
struct w100_mem_info {
unsigned long ext_cntl;
unsigned long sdram_mode_reg;
unsigned long ext_timing_cntl;
unsigned long io_cntl;
unsigned int size;
};
struct w100_bm_mem_info {
unsigned long ext_mem_bw;
unsigned long offset;
unsigned long ext_timing_ctl;
unsigned long ext_cntl;
unsigned long mode_reg;
unsigned long io_cntl;
unsigned long config;
};
/* LCD Mode definition */
struct w100_mode {
unsigned int xres;
unsigned int yres;
unsigned short left_margin;
unsigned short right_margin;
unsigned short upper_margin;
unsigned short lower_margin;
unsigned long crtc_ss;
unsigned long crtc_ls;
unsigned long crtc_gs;
unsigned long crtc_vpos_gs;
unsigned long crtc_rev;
unsigned long crtc_dclk;
unsigned long crtc_gclk;
unsigned long crtc_goe;
unsigned long crtc_ps1_active;
char pll_freq;
char fast_pll_freq;
int sysclk_src;
int sysclk_divider;
int pixclk_src;
int pixclk_divider;
int pixclk_divider_rotated;
};
struct w100_pll_info {
uint16_t freq; /* desired Fout for PLL (Mhz) */
uint8_t M; /* input divider */
uint8_t N_int; /* VCO multiplier */
uint8_t N_fac; /* VCO multiplier fractional part */
uint8_t tfgoal;
uint8_t lock_time;
};
/* Initial Video mode orientation flags */
#define INIT_MODE_ROTATED 0x1
#define INIT_MODE_FLIPPED 0x2
/* /*
* This structure describes the machine which we are running on. * This structure describes the machine which we are running on.
* It is set by machine specific code and used in the probe routine * It is set by machine specific code and used in the probe routine
* of drivers/video/w100fb.c * of drivers/video/w100fb.c
*/ */
struct w100fb_mach_info { struct w100fb_mach_info {
void (*w100fb_ssp_send)(u8 adrs, u8 data); /* General Platform Specific Registers */
int comadj; struct w100_gen_regs *regs;
int phadadj; /* Table of modes the LCD is capable of */
struct w100_mode *modelist;
unsigned int num_modes;
/* Hooks for any platform specific tg/lcd code (optional) */
struct w100_tg_info *tg;
/* External memory definition (if present) */
struct w100_mem_info *mem;
/* Additional External memory definition (if present) */
struct w100_bm_mem_info *bm_mem;
/* GPIO definitions (optional) */
struct w100_gpio_regs *gpio;
/* Initial Mode flags */
unsigned int init_mode;
/* Xtal Frequency */
unsigned int xtal_freq;
/* Enable Xtal input doubler (1 == enable) */
unsigned int xtal_dbl;
};
/* General frame buffer data structure */
struct w100fb_par {
unsigned int chip_id;
unsigned int xres;
unsigned int yres;
unsigned int extmem_active;
unsigned int flip;
unsigned int blanked;
unsigned int fastpll_mode;
unsigned long hsync_len;
struct w100_mode *mode;
struct w100_pll_info *pll_table;
struct w100fb_mach_info *mach;
uint32_t *saved_intmem;
uint32_t *saved_extmem;
}; };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment