[ARM] 4664/1: Add basic support for HTC Magician PDA phones
authorPhilipp Zabel <philipp.zabel@gmail.com>
Thu, 22 Nov 2007 16:59:11 +0000 (17:59 +0100)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Mon, 28 Jan 2008 13:13:16 +0000 (13:13 +0000)
This includes irda, gpio keys, pxafb, backlight, ohci and flash
(read-only).

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
arch/arm/mach-pxa/Kconfig
arch/arm/mach-pxa/Makefile
arch/arm/mach-pxa/magician.c [new file with mode: 0644]
include/asm-arm/arch-pxa/magician.h [new file with mode: 0644]

index b08f55d906c8275feb8e60be8c159f35c2205eff..619f6fc2bfe18b0306832e09f898a559100a0b1a 100644 (file)
@@ -112,6 +112,12 @@ config MACH_ARMCORE
        select PXA27x
        select IWMMXT
 
+config MACH_MAGICIAN
+       bool "Enable HTC Magician Support"
+       depends on ARCH_PXA
+       select PXA27x
+       select IWMMXT
+
 endchoice
 
 if PXA_SHARPSL
index 04f8323c8c89350d1ed01b40245e4bf508b178e1..fca4e819dc5d0d16387b7a23f504664d0ddcc243 100644 (file)
@@ -22,6 +22,7 @@ obj-$(CONFIG_MACH_AKITA)      += akita-ioexp.o
 obj-$(CONFIG_MACH_POODLE)      += poodle.o corgi_ssp.o
 obj-$(CONFIG_MACH_TOSA)                += tosa.o
 obj-$(CONFIG_MACH_EM_X270)     += em-x270.o
+obj-$(CONFIG_MACH_MAGICIAN)    += magician.o
 obj-$(CONFIG_ARCH_PXA_ESERIES) += eseries.o
 
 ifeq ($(CONFIG_MACH_ZYLONITE),y)
diff --git a/arch/arm/mach-pxa/magician.c b/arch/arm/mach-pxa/magician.c
new file mode 100644 (file)
index 0000000..d98ef7a
--- /dev/null
@@ -0,0 +1,218 @@
+/*
+ * Support for HTC Magician PDA phones:
+ * i-mate JAM, O2 Xda mini, Orange SPV M500, Qtek s100, Qtek s110
+ * and T-Mobile MDA Compact.
+ *
+ * Copyright (c) 2006-2007 Philipp Zabel
+ *
+ * Based on hx4700.c, spitz.c and others.
+ *
+ * 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
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/gpio_keys.h>
+#include <linux/input.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/map.h>
+#include <linux/mtd/physmap.h>
+
+#include <asm/gpio.h>
+#include <asm/hardware.h>
+#include <asm/mach-types.h>
+#include <asm/mach/arch.h>
+#include <asm/arch/magician.h>
+#include <asm/arch/pxa-regs.h>
+#include <asm/arch/pxafb.h>
+#include <asm/arch/irda.h>
+#include <asm/arch/ohci.h>
+
+#include "generic.h"
+
+/*
+ * IRDA
+ */
+
+static void magician_irda_transceiver_mode(struct device *dev, int mode)
+{
+       gpio_set_value(GPIO83_MAGICIAN_nIR_EN, mode & IR_OFF);
+}
+
+static struct pxaficp_platform_data magician_ficp_info = {
+       .transceiver_cap  = IR_SIRMODE | IR_OFF,
+       .transceiver_mode = magician_irda_transceiver_mode,
+};
+
+/*
+ * GPIO Keys
+ */
+
+static struct gpio_keys_button magician_button_table[] = {
+       {KEY_POWER,      GPIO0_MAGICIAN_KEY_POWER,      0, "Power button"},
+       {KEY_ESC,        GPIO37_MAGICIAN_KEY_HANGUP,    0, "Hangup button"},
+       {KEY_F10,        GPIO38_MAGICIAN_KEY_CONTACTS,  0, "Contacts button"},
+       {KEY_CALENDAR,   GPIO90_MAGICIAN_KEY_CALENDAR,  0, "Calendar button"},
+       {KEY_CAMERA,     GPIO91_MAGICIAN_KEY_CAMERA,    0, "Camera button"},
+       {KEY_UP,         GPIO93_MAGICIAN_KEY_UP,        0, "Up button"},
+       {KEY_DOWN,       GPIO94_MAGICIAN_KEY_DOWN,      0, "Down button"},
+       {KEY_LEFT,       GPIO95_MAGICIAN_KEY_LEFT,      0, "Left button"},
+       {KEY_RIGHT,      GPIO96_MAGICIAN_KEY_RIGHT,     0, "Right button"},
+       {KEY_KPENTER,    GPIO97_MAGICIAN_KEY_ENTER,     0, "Action button"},
+       {KEY_RECORD,     GPIO98_MAGICIAN_KEY_RECORD,    0, "Record button"},
+       {KEY_VOLUMEUP,   GPIO100_MAGICIAN_KEY_VOL_UP,   0, "Volume up"},
+       {KEY_VOLUMEDOWN, GPIO101_MAGICIAN_KEY_VOL_DOWN, 0, "Volume down"},
+       {KEY_PHONE,      GPIO102_MAGICIAN_KEY_PHONE,    0, "Phone button"},
+       {KEY_PLAY,       GPIO99_MAGICIAN_HEADPHONE_IN,  0, "Headset button"},
+};
+
+static struct gpio_keys_platform_data gpio_keys_data = {
+       .buttons  = magician_button_table,
+       .nbuttons = ARRAY_SIZE(magician_button_table),
+};
+
+static struct platform_device gpio_keys = {
+       .name = "gpio-keys",
+       .dev  = {
+               .platform_data = &gpio_keys_data,
+       },
+       .id   = -1,
+};
+
+/*
+ * LCD - Toppoly TD028STEB1
+ */
+
+static struct pxafb_mode_info toppoly_modes[] = {
+       {
+               .pixclock     = 96153,
+               .bpp          = 16,
+               .xres         = 240,
+               .yres         = 320,
+               .hsync_len    = 11,
+               .vsync_len    = 3,
+               .left_margin  = 19,
+               .upper_margin = 2,
+               .right_margin = 10,
+               .lower_margin = 2,
+               .sync         = 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,
+};
+
+/*
+ * Backlight
+ */
+
+static void magician_set_bl_intensity(int intensity)
+{
+       if (intensity) {
+               PWM_CTRL0 = 1;
+               PWM_PERVAL0 = 0xc8;
+               PWM_PWDUTY0 = intensity;
+               pxa_set_cken(CKEN_PWM0, 1);
+       } else {
+               pxa_set_cken(CKEN_PWM0, 0);
+       }
+}
+
+static struct generic_bl_info backlight_info = {
+       .default_intensity = 0x64,
+       .limit_mask        = 0x0b,
+       .max_intensity     = 0xc7,
+       .set_bl_intensity  = magician_set_bl_intensity,
+};
+
+static struct platform_device backlight = {
+       .name = "corgi-bl",
+       .dev  = {
+               .platform_data = &backlight_info,
+       },
+       .id   = -1,
+};
+
+
+/*
+ * USB OHCI
+ */
+
+static int magician_ohci_init(struct device *dev)
+{
+       UHCHR = (UHCHR | UHCHR_SSEP2 | UHCHR_PCPL | UHCHR_CGR) &
+           ~(UHCHR_SSEP1 | UHCHR_SSEP3 | UHCHR_SSE);
+
+       return 0;
+}
+
+static struct pxaohci_platform_data magician_ohci_info = {
+       .port_mode    = PMM_PERPORT_MODE,
+       .init         = magician_ohci_init,
+       .power_budget = 0,
+};
+
+
+/*
+ * StrataFlash
+ */
+
+#define PXA_CS_SIZE            0x04000000
+
+static struct resource strataflash_resource = {
+       .start = PXA_CS0_PHYS,
+       .end   = PXA_CS0_PHYS + PXA_CS_SIZE - 1,
+       .flags = IORESOURCE_MEM,
+};
+
+static struct physmap_flash_data strataflash_data = {
+       .width = 4,
+};
+
+static struct platform_device strataflash = {
+       .name          = "physmap-flash",
+       .id            = -1,
+       .num_resources = 1,
+       .resource      = &strataflash_resource,
+       .dev = {
+               .platform_data = &strataflash_data,
+       },
+};
+
+/*
+ * Platform devices
+ */
+
+static struct platform_device *devices[] __initdata = {
+       &gpio_keys,
+       &backlight,
+       &strataflash,
+};
+
+static void __init magician_init(void)
+{
+       platform_add_devices(devices, ARRAY_SIZE(devices));
+       pxa_set_ohci_info(&magician_ohci_info);
+       pxa_set_ficp_info(&magician_ficp_info);
+       set_pxa_fb_info(&toppoly_info);
+}
+
+
+MACHINE_START(MAGICIAN, "HTC Magician")
+       .phys_io = 0x40000000,
+       .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
+       .boot_params = 0xa0000100,
+       .map_io = pxa_map_io,
+       .init_irq = pxa27x_init_irq,
+       .init_machine = magician_init,
+       .timer = &pxa_timer,
+MACHINE_END
diff --git a/include/asm-arm/arch-pxa/magician.h b/include/asm-arm/arch-pxa/magician.h
new file mode 100644 (file)
index 0000000..337f51f
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ * GPIO and IRQ definitions for HTC Magician PDA phones
+ *
+ * Copyright (c) 2007 Philipp Zabel
+ *
+ * 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
+ * published by the Free Software Foundation.
+ *
+ */
+
+#ifndef _MAGICIAN_H_
+#define _MAGICIAN_H_
+
+#include <asm/arch/pxa-regs.h>
+
+/*
+ * PXA GPIOs
+ */
+
+#define GPIO0_MAGICIAN_KEY_POWER               0
+#define GPIO9_MAGICIAN_UNKNOWN                 9
+#define GPIO10_MAGICIAN_GSM_IRQ                        10
+#define GPIO11_MAGICIAN_GSM_OUT1               11
+#define GPIO13_MAGICIAN_CPLD_IRQ               13
+#define GPIO18_MAGICIAN_UNKNOWN                        18
+#define GPIO22_MAGICIAN_VIBRA_EN               22
+#define GPIO26_MAGICIAN_GSM_POWER              26
+#define GPIO27_MAGICIAN_USBC_PUEN              27
+#define GPIO30_MAGICIAN_nCHARGE_EN             30
+#define GPIO37_MAGICIAN_KEY_HANGUP             37
+#define GPIO38_MAGICIAN_KEY_CONTACTS           38
+#define GPIO40_MAGICIAN_GSM_OUT2               40
+#define GPIO48_MAGICIAN_UNKNOWN                        48
+#define GPIO56_MAGICIAN_UNKNOWN                        56
+#define GPIO57_MAGICIAN_CAM_RESET              57
+#define GPIO83_MAGICIAN_nIR_EN                 83
+#define GPIO86_MAGICIAN_GSM_RESET              86
+#define GPIO87_MAGICIAN_GSM_SELECT             87
+#define GPIO90_MAGICIAN_KEY_CALENDAR           90
+#define GPIO91_MAGICIAN_KEY_CAMERA             91
+#define GPIO93_MAGICIAN_KEY_UP                 93
+#define GPIO94_MAGICIAN_KEY_DOWN               94
+#define GPIO95_MAGICIAN_KEY_LEFT               95
+#define GPIO96_MAGICIAN_KEY_RIGHT              96
+#define GPIO97_MAGICIAN_KEY_ENTER              97
+#define GPIO98_MAGICIAN_KEY_RECORD             98
+#define GPIO99_MAGICIAN_HEADPHONE_IN           99
+#define GPIO100_MAGICIAN_KEY_VOL_UP            100
+#define GPIO101_MAGICIAN_KEY_VOL_DOWN          101
+#define GPIO102_MAGICIAN_KEY_PHONE             102
+#define GPIO103_MAGICIAN_LED_KP                        103
+#define GPIO104_MAGICIAN_LCD_POWER_1           104
+#define GPIO105_MAGICIAN_LCD_POWER_2           105
+#define GPIO106_MAGICIAN_LCD_POWER_3           106
+#define GPIO107_MAGICIAN_DS1WM_IRQ             107
+#define GPIO108_MAGICIAN_GSM_READY             108
+#define GPIO114_MAGICIAN_UNKNOWN               114
+#define GPIO115_MAGICIAN_nPEN_IRQ              115
+#define GPIO116_MAGICIAN_nCAM_EN               116
+#define GPIO119_MAGICIAN_UNKNOWN               119
+#define GPIO120_MAGICIAN_UNKNOWN               120
+
+/*
+ * PXA GPIO alternate function mode & direction
+ */
+
+#define GPIO0_MAGICIAN_KEY_POWER_MD            (0 | GPIO_IN)
+#define GPIO9_MAGICIAN_UNKNOWN_MD              (9 | GPIO_IN)
+#define GPIO10_MAGICIAN_GSM_IRQ_MD             (10 | GPIO_IN)
+#define GPIO11_MAGICIAN_GSM_OUT1_MD            (11 | GPIO_OUT)
+#define GPIO13_MAGICIAN_CPLD_IRQ_MD            (13 | GPIO_IN)
+#define GPIO18_MAGICIAN_UNKNOWN_MD             (18 | GPIO_OUT)
+#define GPIO22_MAGICIAN_VIBRA_EN_MD            (22 | GPIO_OUT)
+#define GPIO26_MAGICIAN_GSM_POWER_MD           (26 | GPIO_OUT)
+#define GPIO27_MAGICIAN_USBC_PUEN_MD           (27 | GPIO_OUT)
+#define GPIO30_MAGICIAN_nCHARGE_EN_MD          (30 | GPIO_OUT)
+#define GPIO37_MAGICIAN_KEY_HANGUP_MD          (37 | GPIO_OUT)
+#define GPIO38_MAGICIAN_KEY_CONTACTS_MD                (38 | GPIO_OUT)
+#define GPIO40_MAGICIAN_GSM_OUT2_MD            (40 | GPIO_OUT)
+#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 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)
+#define GPIO90_MAGICIAN_KEY_CALENDAR_MD                (90 | GPIO_OUT)
+#define GPIO91_MAGICIAN_KEY_CAMERA_MD          (91 | GPIO_OUT)
+#define GPIO93_MAGICIAN_KEY_UP_MD              (93 | GPIO_IN)
+#define GPIO94_MAGICIAN_KEY_DOWN_MD            (94 | GPIO_IN)
+#define GPIO95_MAGICIAN_KEY_LEFT_MD            (95 | GPIO_IN)
+#define GPIO96_MAGICIAN_KEY_RIGHT_MD           (96 | GPIO_IN)
+#define GPIO97_MAGICIAN_KEY_ENTER_MD           (97 | GPIO_IN)
+#define GPIO98_MAGICIAN_KEY_RECORD_MD          (98 | GPIO_IN)
+#define GPIO99_MAGICIAN_HEADPHONE_IN_MD                (99 | GPIO_IN)
+#define GPIO100_MAGICIAN_KEY_VOL_UP_MD         (100 | GPIO_IN)
+#define GPIO101_MAGICIAN_KEY_VOL_DOWN_MD       (101 | GPIO_IN)
+#define GPIO102_MAGICIAN_KEY_PHONE_MD          (102 | GPIO_IN)
+#define GPIO103_MAGICIAN_LED_KP_MD             (103 | GPIO_OUT)
+#define GPIO104_MAGICIAN_LCD_POWER_1_MD        (104 | GPIO_OUT)
+#define GPIO105_MAGICIAN_LCD_POWER_2_MD                (105 | GPIO_OUT)
+#define GPIO106_MAGICIAN_LCD_POWER_3_MD                (106 | GPIO_OUT)
+#define GPIO107_MAGICIAN_DS1WM_IRQ_MD          (107 | GPIO_IN)
+#define GPIO108_MAGICIAN_GSM_READY_MD          (108 | GPIO_IN)
+#define GPIO114_MAGICIAN_UNKNOWN_MD            (114 | GPIO_OUT)
+#define GPIO115_MAGICIAN_nPEN_IRQ_MD           (115 | GPIO_IN)
+#define GPIO116_MAGICIAN_nCAM_EN_MD            (116 | GPIO_OUT)
+#define GPIO119_MAGICIAN_UNKNOWN_MD            (119 | GPIO_OUT)
+#define GPIO120_MAGICIAN_UNKNOWN_MD            (120 | GPIO_OUT)
+
+#endif /* _MAGICIAN_H_ */