From 103a1754894eecf488103f7739061e7e767049ad Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Wed, 9 Apr 2008 19:11:52 +0100 Subject: [ARM] 4943/2: magician: fix magician.h GPIO header includes PXA GPIO definitions were split from pxa-regs.h into pxa2xx-gpio.h. Signed-off-by: Philipp Zabel Signed-off-by: Russell King --- include/asm-arm/arch-pxa/magician.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/asm-arm/arch-pxa/magician.h') diff --git a/include/asm-arm/arch-pxa/magician.h b/include/asm-arm/arch-pxa/magician.h index 337f51f06b3a..13762e80bf54 100644 --- a/include/asm-arm/arch-pxa/magician.h +++ b/include/asm-arm/arch-pxa/magician.h @@ -12,7 +12,7 @@ #ifndef _MAGICIAN_H_ #define _MAGICIAN_H_ -#include +#include /* * PXA GPIOs -- cgit v1.2.3-59-g8ed1b From 70e357f8426c54e1500ac4fdb6b1172df16d8b93 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Wed, 9 Apr 2008 19:22:57 +0100 Subject: [ARM] 4948/1: magician: use htc-egpio to drive the GPIO/IRQ expander CPLD needed for power management (audio, BT, charging, GSM, LCD, SD), GSM, flash and SD operation and audio routing. Signed-off-by: Philipp Zabel Signed-off-by: Russell King --- arch/arm/configs/magician_defconfig | 1 + arch/arm/mach-pxa/magician.c | 60 ++++++++++++++++++++++++++++++++++++- include/asm-arm/arch-pxa/irqs.h | 3 +- include/asm-arm/arch-pxa/magician.h | 53 ++++++++++++++++++++++++++++++++ 4 files changed, 115 insertions(+), 2 deletions(-) (limited to 'include/asm-arm/arch-pxa/magician.h') diff --git a/arch/arm/configs/magician_defconfig b/arch/arm/configs/magician_defconfig index 703d741f5a23..76960c71d890 100644 --- a/arch/arm/configs/magician_defconfig +++ b/arch/arm/configs/magician_defconfig @@ -712,6 +712,7 @@ CONFIG_SSB_POSSIBLE=y # Multifunction device drivers # # CONFIG_MFD_SM501 is not set +CONFIG_HTC_EGPIO=y # # Multimedia devices diff --git a/arch/arm/mach-pxa/magician.c b/arch/arm/mach-pxa/magician.c index 0160cd8f6c65..3b7e8bac7344 100644 --- a/arch/arm/mach-pxa/magician.c +++ b/arch/arm/mach-pxa/magician.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -84,6 +85,62 @@ static struct platform_device gpio_keys = { .id = -1, }; + +/* + * EGPIO (Xilinx CPLD) + * + * 7 32-bit aligned 8-bit registers: 3x output, 1x irq, 3x input + */ + +static struct resource egpio_resources[] = { + [0] = { + .start = PXA_CS3_PHYS, + .end = PXA_CS3_PHYS + 0x20, + .flags = IORESOURCE_MEM, + }, + [1] = { + .start = gpio_to_irq(GPIO13_MAGICIAN_CPLD_IRQ), + .end = gpio_to_irq(GPIO13_MAGICIAN_CPLD_IRQ), + .flags = IORESOURCE_IRQ, + }, +}; + +static struct htc_egpio_chip egpio_chips[] = { + [0] = { + .reg_start = 0, + .gpio_base = MAGICIAN_EGPIO(0, 0), + .num_gpios = 24, + .direction = HTC_EGPIO_OUTPUT, + .initial_values = 0x40, /* EGPIO_MAGICIAN_GSM_RESET */ + }, + [1] = { + .reg_start = 4, + .gpio_base = MAGICIAN_EGPIO(4, 0), + .num_gpios = 24, + .direction = HTC_EGPIO_INPUT, + }, +}; + +static struct htc_egpio_platform_data egpio_info = { + .reg_width = 8, + .bus_width = 32, + .irq_base = IRQ_BOARD_START, + .num_irqs = 4, + .ack_register = 3, + .chip = egpio_chips, + .num_chips = ARRAY_SIZE(egpio_chips), +}; + +static struct platform_device egpio = { + .name = "htc-egpio", + .id = -1, + .resource = egpio_resources, + .num_resources = ARRAY_SIZE(egpio_resources), + .dev = { + .platform_data = &egpio_info, + }, +}; + /* * LCD - Toppoly TD028STEB1 */ @@ -182,8 +239,8 @@ static struct physmap_flash_data strataflash_data = { static struct platform_device strataflash = { .name = "physmap-flash", .id = -1, - .num_resources = 1, .resource = &strataflash_resource, + .num_resources = 1, .dev = { .platform_data = &strataflash_data, }, @@ -195,6 +252,7 @@ static struct platform_device strataflash = { static struct platform_device *devices[] __initdata = { &gpio_keys, + &egpio, &backlight, &strataflash, }; diff --git a/include/asm-arm/arch-pxa/irqs.h b/include/asm-arm/arch-pxa/irqs.h index c562b972a4a6..50c77eacbd5e 100644 --- a/include/asm-arm/arch-pxa/irqs.h +++ b/include/asm-arm/arch-pxa/irqs.h @@ -181,7 +181,8 @@ #elif defined(CONFIG_ARCH_LUBBOCK) || \ defined(CONFIG_MACH_LOGICPD_PXA270) || \ defined(CONFIG_MACH_MAINSTONE) || \ - defined(CONFIG_MACH_PCM027) + defined(CONFIG_MACH_PCM027) || \ + defined(CONFIG_MACH_MAGICIAN) #define NR_IRQS (IRQ_BOARD_END) #else #define NR_IRQS (IRQ_BOARD_START) diff --git a/include/asm-arm/arch-pxa/magician.h b/include/asm-arm/arch-pxa/magician.h index 13762e80bf54..216921db9d63 100644 --- a/include/asm-arm/arch-pxa/magician.h +++ b/include/asm-arm/arch-pxa/magician.h @@ -12,6 +12,7 @@ #ifndef _MAGICIAN_H_ #define _MAGICIAN_H_ +#include #include /* @@ -108,4 +109,56 @@ #define GPIO119_MAGICIAN_UNKNOWN_MD (119 | GPIO_OUT) #define GPIO120_MAGICIAN_UNKNOWN_MD (120 | GPIO_OUT) +/* + * CPLD IRQs + */ + +#define IRQ_MAGICIAN_SD (IRQ_BOARD_START + 0) +#define IRQ_MAGICIAN_EP (IRQ_BOARD_START + 1) +#define IRQ_MAGICIAN_BT (IRQ_BOARD_START + 2) +#define IRQ_MAGICIAN_AC (IRQ_BOARD_START + 3) + +/* + * CPLD EGPIOs + */ + +#define MAGICIAN_EGPIO_BASE 0x80 /* GPIO_BOARD_START */ +#define MAGICIAN_EGPIO(reg,bit) \ + (MAGICIAN_EGPIO_BASE + 8*reg + bit) + +/* output */ + +#define EGPIO_MAGICIAN_TOPPOLY_POWER MAGICIAN_EGPIO(0, 2) +#define EGPIO_MAGICIAN_LED_POWER MAGICIAN_EGPIO(0, 5) +#define EGPIO_MAGICIAN_GSM_RESET MAGICIAN_EGPIO(0, 6) +#define EGPIO_MAGICIAN_LCD_POWER MAGICIAN_EGPIO(0, 7) +#define EGPIO_MAGICIAN_SPK_POWER MAGICIAN_EGPIO(1, 0) +#define EGPIO_MAGICIAN_EP_POWER MAGICIAN_EGPIO(1, 1) +#define EGPIO_MAGICIAN_IN_SEL0 MAGICIAN_EGPIO(1, 2) +#define EGPIO_MAGICIAN_IN_SEL1 MAGICIAN_EGPIO(1, 3) +#define EGPIO_MAGICIAN_MIC_POWER MAGICIAN_EGPIO(1, 4) +#define EGPIO_MAGICIAN_CODEC_RESET MAGICIAN_EGPIO(1, 5) +#define EGPIO_MAGICIAN_CODEC_POWER MAGICIAN_EGPIO(1, 6) +#define EGPIO_MAGICIAN_BL_POWER MAGICIAN_EGPIO(1, 7) +#define EGPIO_MAGICIAN_SD_POWER MAGICIAN_EGPIO(2, 0) +#define EGPIO_MAGICIAN_CARKIT_MIC MAGICIAN_EGPIO(2, 1) +#define EGPIO_MAGICIAN_UNKNOWN_WAVEDEV_DLL MAGICIAN_EGPIO(2, 2) +#define EGPIO_MAGICIAN_FLASH_VPP MAGICIAN_EGPIO(2, 3) +#define EGPIO_MAGICIAN_BL_POWER2 MAGICIAN_EGPIO(2, 4) +#define EGPIO_MAGICIAN_CHARGE_EN MAGICIAN_EGPIO(2, 5) +#define EGPIO_MAGICIAN_GSM_POWER MAGICIAN_EGPIO(2, 7) + +/* input */ + +#define EGPIO_MAGICIAN_CABLE_STATE_AC MAGICIAN_EGPIO(4, 0) +#define EGPIO_MAGICIAN_CABLE_STATE_USB MAGICIAN_EGPIO(4, 1) + +#define EGPIO_MAGICIAN_BOARD_ID0 MAGICIAN_EGPIO(5, 0) +#define EGPIO_MAGICIAN_BOARD_ID1 MAGICIAN_EGPIO(5, 1) +#define EGPIO_MAGICIAN_BOARD_ID2 MAGICIAN_EGPIO(5, 2) +#define EGPIO_MAGICIAN_LCD_SELECT MAGICIAN_EGPIO(5, 3) +#define EGPIO_MAGICIAN_nSD_READONLY MAGICIAN_EGPIO(5, 4) + +#define EGPIO_MAGICIAN_EP_INSERT MAGICIAN_EGPIO(6, 1) + #endif /* _MAGICIAN_H_ */ -- cgit v1.2.3-59-g8ed1b From e07ff8d8091eff8e208fe1e406c15e5de0fffd63 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Wed, 9 Apr 2008 19:27:10 +0100 Subject: [ARM] 4952/1: magician: add LCD detection, LCD power switching, update pxafb settings All magician devices I've encountered so far have featured the Toppoly TD028STEB1 display, so the Samsung LTP280QV support is untested. The power-on sequence is not correct because pxafb doesn't yet support enabling the LCD controller in the middle of the it. Signed-off-by: Philipp Zabel Signed-off-by: Russell King --- arch/arm/mach-pxa/magician.c | 121 +++++++++++++++++++++++++++++++++--- include/asm-arm/arch-pxa/magician.h | 2 + 2 files changed, 116 insertions(+), 7 deletions(-) (limited to 'include/asm-arm/arch-pxa/magician.h') diff --git a/arch/arm/mach-pxa/magician.c b/arch/arm/mach-pxa/magician.c index d152a086e734..7de3bfe543b4 100644 --- a/arch/arm/mach-pxa/magician.c +++ b/arch/arm/mach-pxa/magician.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -144,7 +145,7 @@ static struct platform_device egpio = { }; /* - * LCD - Toppoly TD028STEB1 + * LCD - Toppoly TD028STEB1 or Samsung LTP280QV */ static struct pxafb_mode_info toppoly_modes[] = { @@ -163,12 +164,99 @@ static struct pxafb_mode_info toppoly_modes[] = { }, }; +static struct pxafb_mode_info samsung_modes[] = { + { + .pixclock = 96153, + .bpp = 16, + .xres = 240, + .yres = 320, + .hsync_len = 8, + .vsync_len = 4, + .left_margin = 9, + .upper_margin = 4, + .right_margin = 9, + .lower_margin = 4, + .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, + }, +}; + +static void toppoly_lcd_power(int on, struct fb_var_screeninfo *si) +{ + pr_debug("Toppoly LCD power\n"); + + if (on) { + pr_debug("on\n"); + gpio_set_value(EGPIO_MAGICIAN_TOPPOLY_POWER, 1); + gpio_set_value(GPIO106_MAGICIAN_LCD_POWER_3, 1); + udelay(2000); + gpio_set_value(EGPIO_MAGICIAN_LCD_POWER, 1); + udelay(2000); + /* FIXME: enable LCDC here */ + udelay(2000); + gpio_set_value(GPIO104_MAGICIAN_LCD_POWER_1, 1); + udelay(2000); + gpio_set_value(GPIO105_MAGICIAN_LCD_POWER_2, 1); + } else { + pr_debug("off\n"); + msleep(15); + gpio_set_value(GPIO105_MAGICIAN_LCD_POWER_2, 0); + udelay(500); + gpio_set_value(GPIO104_MAGICIAN_LCD_POWER_1, 0); + udelay(1000); + gpio_set_value(GPIO106_MAGICIAN_LCD_POWER_3, 0); + gpio_set_value(EGPIO_MAGICIAN_LCD_POWER, 0); + } +} + +static void samsung_lcd_power(int on, struct fb_var_screeninfo *si) +{ + pr_debug("Samsung LCD power\n"); + + if (on) { + pr_debug("on\n"); + if (system_rev < 3) + gpio_set_value(GPIO75_MAGICIAN_SAMSUNG_POWER, 1); + else + gpio_set_value(EGPIO_MAGICIAN_LCD_POWER, 1); + mdelay(10); + gpio_set_value(GPIO106_MAGICIAN_LCD_POWER_3, 1); + mdelay(10); + gpio_set_value(GPIO104_MAGICIAN_LCD_POWER_1, 1); + mdelay(30); + gpio_set_value(GPIO105_MAGICIAN_LCD_POWER_2, 1); + mdelay(10); + } else { + pr_debug("off\n"); + mdelay(10); + gpio_set_value(GPIO105_MAGICIAN_LCD_POWER_2, 0); + mdelay(30); + gpio_set_value(GPIO104_MAGICIAN_LCD_POWER_1, 0); + mdelay(10); + gpio_set_value(GPIO106_MAGICIAN_LCD_POWER_3, 0); + mdelay(10); + if (system_rev < 3) + gpio_set_value(GPIO75_MAGICIAN_SAMSUNG_POWER, 0); + else + gpio_set_value(EGPIO_MAGICIAN_LCD_POWER, 0); + } +} + static struct pxafb_mach_info toppoly_info = { - .modes = toppoly_modes, - .num_modes = 1, - .fixed_modes = 1, - .lccr0 = LCCR0_Color | LCCR0_Sngl | LCCR0_Act, - .lccr3 = LCCR3_PixRsEdg, + .modes = toppoly_modes, + .num_modes = 1, + .fixed_modes = 1, + .lccr0 = LCCR0_Color | LCCR0_Sngl | LCCR0_Act, + .lccr3 = LCCR3_PixRsEdg, + .pxafb_lcd_power = toppoly_lcd_power, +}; + +static struct pxafb_mach_info samsung_info = { + .modes = samsung_modes, + .num_modes = 1, + .fixed_modes = 1, + .lccr0 = LCCR0_LDDALT | LCCR0_Color | LCCR0_Sngl | LCCR0_Act, + .lccr3 = LCCR3_PixFlEdg, + .pxafb_lcd_power = samsung_lcd_power, }; /* @@ -358,12 +446,31 @@ static struct platform_device *devices[] __initdata = { static void __init magician_init(void) { + void __iomem *cpld; + int lcd_select; + platform_add_devices(devices, ARRAY_SIZE(devices)); pxa_set_i2c_info(NULL); pxa_set_mci_info(&magician_mci_info); pxa_set_ohci_info(&magician_ohci_info); pxa_set_ficp_info(&magician_ficp_info); - set_pxa_fb_info(&toppoly_info); + + /* Check LCD type we have */ + cpld = ioremap_nocache(PXA_CS3_PHYS, 0x1000); + if (cpld) { + u8 board_id = __raw_readb(cpld+0x14); + system_rev = board_id & 0x7; + lcd_select = board_id & 0x8; + iounmap(cpld); + pr_info("LCD type: %s\n", lcd_select ? "Samsung" : "Toppoly"); + if (lcd_select && (system_rev < 3)) + pxa_gpio_mode(GPIO75_MAGICIAN_SAMSUNG_POWER_MD); + pxa_gpio_mode(GPIO104_MAGICIAN_LCD_POWER_1_MD); + pxa_gpio_mode(GPIO105_MAGICIAN_LCD_POWER_2_MD); + pxa_gpio_mode(GPIO106_MAGICIAN_LCD_POWER_3_MD); + set_pxa_fb_info(lcd_select ? &samsung_info : &toppoly_info); + } else + pr_err("LCD detection: CPLD mapping failed\n"); } diff --git a/include/asm-arm/arch-pxa/magician.h b/include/asm-arm/arch-pxa/magician.h index 216921db9d63..b34fd5683e2d 100644 --- a/include/asm-arm/arch-pxa/magician.h +++ b/include/asm-arm/arch-pxa/magician.h @@ -35,6 +35,7 @@ #define GPIO48_MAGICIAN_UNKNOWN 48 #define GPIO56_MAGICIAN_UNKNOWN 56 #define GPIO57_MAGICIAN_CAM_RESET 57 +#define GPIO75_MAGICIAN_SAMSUNG_POWER 75 #define GPIO83_MAGICIAN_nIR_EN 83 #define GPIO86_MAGICIAN_GSM_RESET 86 #define GPIO87_MAGICIAN_GSM_SELECT 87 @@ -82,6 +83,7 @@ #define GPIO48_MAGICIAN_UNKNOWN_MD (48 | GPIO_OUT) #define GPIO56_MAGICIAN_UNKNOWN_MD (56 | GPIO_OUT) #define GPIO57_MAGICIAN_CAM_RESET_MD (57 | GPIO_OUT) +#define GPIO75_MAGICIAN_SAMSUNG_POWER_MD (75 | GPIO_OUT) #define GPIO83_MAGICIAN_nIR_EN_MD (83 | GPIO_OUT) #define GPIO86_MAGICIAN_GSM_RESET_MD (86 | GPIO_OUT) #define GPIO87_MAGICIAN_GSM_SELECT_MD (87 | GPIO_OUT) -- cgit v1.2.3-59-g8ed1b