Index: arch/arm/mach-s3c2442/htchermes/Kconfig =================================================================== RCS file: /cvs/linux/kernel26/arch/arm/mach-s3c2442/htchermes/Kconfig,v retrieving revision 1.5 diff -u -r1.5 Kconfig --- arch/arm/mach-s3c2442/htchermes/Kconfig 16 May 2007 18:04:31 -0000 1.5 +++ arch/arm/mach-s3c2442/htchermes/Kconfig 15 Sep 2007 19:44:39 -0000 @@ -3,6 +3,7 @@ bool "HTC Hermes aka TyTN" select CPU_S3C2440 select CPU_S3C2442 + select BOARD_IRQ_MAP_BIG help Say Y here if you are using the HTC Hermes. Index: arch/arm/mach-s3c2442/htchermes/htchermes.c =================================================================== RCS file: /cvs/linux/kernel26/arch/arm/mach-s3c2442/htchermes/htchermes.c,v retrieving revision 1.13 diff -u -r1.13 htchermes.c --- arch/arm/mach-s3c2442/htchermes/htchermes.c 18 Jul 2007 19:15:30 -0000 1.13 +++ arch/arm/mach-s3c2442/htchermes/htchermes.c 15 Sep 2007 19:44:39 -0000 @@ -1,62 +1,193 @@ -/* linux/arch/arm/mach-s3c2442/mach-htchermes.c +/* Code to support the HTC Hermes phone. + * + * (c) Copyright 2007 Kevin O'Connor * * Based on the code by Ben Dooks * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License. * -*/ + */ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include +#include // MACH_TYPE_HTCHERMES +#include // MACHINE_START +#include // struct map_desc +#include // struct platform_device -static struct map_desc htchermes_iodesc[] __initdata = { +#include // MTD_WRITEABLE +#include // struct mtd_partition +#include // struct s3c2410_nand_set + +#include // for regs-serial.h +#include // struct s3c24xx_uart_clksrc + +#include // s3c_device_* +#include // struct s3c24xx_board +#include // s3c2410_pm_init +#include // S3C2410_UDC_P_ENABLE + +#include // gpio_get_value +#include // KEY_* +#include // struct gpio_keys_platform_data +#include // struct pda_power_pdata +#include // struct gpio_led +#include // struct htc_egpio_platform_data +#include // struct htc_bbkeys_platform_data + +#include "htchermes-gpio.h" // GPIO_NR_* + +// Ughh +#define IRQ_BOARD_START (IRQ_S3C2440_AC97+1) + + +/**************************************************************** + * EGPIO + ****************************************************************/ + +// Location of the egpio chip in physical ram. +enum { EGPIO_BASE = 0x08000000 }; + +static struct resource egpio_resources[] = { + [0] = { + .start = EGPIO_BASE, + .end = EGPIO_BASE + 0x10, + .flags = IORESOURCE_MEM, + }, + [1] = { + .start = IRQ_NR_HTCHERMES_EGPIO_IRQ, + .end = IRQ_NR_HTCHERMES_EGPIO_IRQ, + .flags = IORESOURCE_IRQ, + }, +}; + +struct htc_egpio_pinInfo pins[] = { + // Input pins with IRQs + {.gpio = EGPIO_NR_HTCHERMES_PWR_IN_PWR + , .type = HTC_EGPIO_TYPE_INPUT + , .input_irq = EGPIO_NR_HTCHERMES_PWR_IRQ}, + // Output pins that default on + {.gpio = EGPIO_NR_HTCHERMES_PWR_CHARGE, .type = HTC_EGPIO_TYPE_OUTPUT + , .output_initial = 1}, // Disable charger + {.gpio = HTCHERMES_EGPIO(0, 9), .type = HTC_EGPIO_TYPE_OUTPUT + , .output_initial = 1}, // XXX - must be on - reason unknown +}; + +struct htc_egpio_platform_data egpio_data = { + .irq_base = IRQ_BOARD_START, + .gpio_base = HTCHERMES_EGPIO_BASE, + .nrRegs = 5, + .ackRegister = 2, + .pins = pins, + .nr_pins = ARRAY_SIZE(pins), +}; + +static struct platform_device egpio = { + .name = "htc-egpio", + .id = -1, + .resource = egpio_resources, + .num_resources = ARRAY_SIZE(egpio_resources), + .dev = { + .platform_data = &egpio_data, + }, +}; + +// Compatibility wrappers +#define IRQ_EGPIO(x) (IRQ_BOARD_START + (x) - HTCHERMES_EGPIO_BASE) + + +/**************************************************************** + * Front keypad + ****************************************************************/ + +#define HTCHERMES_BBKEYS_BASE (HTCHERMES_EGPIO_BASE + GPIO_BASE_INCREMENT) +#define BBKEYS_GPIO(reg,bit) (HTCHERMES_BBKEYS_BASE + 8*(reg) + (bit)) + +static struct resource bbkeys_resources[] = { + [0] = { + .start = IRQ_NR_HTCHERMES_FK_IRQ, + .end = IRQ_NR_HTCHERMES_FK_IRQ, + .flags = IORESOURCE_IRQ, + }, +}; + +static struct htc_bbkeys_platform_data bbkeys_data = { + .sda_gpio = GPIO_NR_HTCHERMES_FK_SDA, + .scl_gpio = GPIO_NR_HTCHERMES_FK_SCL, + .gpio_base = HTCHERMES_BBKEYS_BASE, + + .ackreg = 3, + .key1reg = 0, + .key2reg = 1, + .buttons = { + -1, + KEY_LEFTMETA, // Windows key + KEY_OK, // Ok + KEY_ENTER, // Joystick press + KEY_DOWN, // Joystick down + KEY_LEFT, // Joystick left + KEY_UP, // Joystick up + KEY_RIGHT, // Joystick right + -1, + KEY_RIGHTCTRL, // Right menu + -1, + KEY_LEFTCTRL, // Left menu + KEY_WWW, // Browser button + KEY_EMAIL, // Mail button + KEY_PHONE, // Call button + KEY_ESC, // Hangup + } +}; + +static struct platform_device bbkeys = { + .name = "htc-bbkeys", + .id = -1, + .resource = bbkeys_resources, + .num_resources = ARRAY_SIZE(bbkeys_resources), + .dev = { + .platform_data = &bbkeys_data, + }, }; + +/**************************************************************** + * LEDS + ****************************************************************/ + +struct gpio_led hermes_leds[] = { + { .name = "hermes:vibra", .gpio = GPIO_NR_HTCHERMES_VIBRA }, + { .name = "hermes:kbd_bl", .gpio = EGPIO_NR_HTCHERMES_KBD_BACKLIGHT }, + { .name = "hermes:flashlight", .gpio = GPIO_NR_HTCHERMES_FLASHLIGHT }, +#if 0 + { .name = "hermes:phone_bl", .gpio = BBKEYS_GPIO(1, 5) }, + + { .name = "hermesLeft:green", .gpio = BBKEYS_GPIO(2, 2) }, + { .name = "hermesLeft:blue", .gpio = BBKEYS_GPIO(2, 3) }, + { .name = "hermesLeft:alter", .gpio = BBKEYS_GPIO(2, 4) }, + { .name = "hermesRight:green", .gpio = BBKEYS_GPIO(2, 5) }, + { .name = "hermesRight:red", .gpio = BBKEYS_GPIO(2, 6) }, + { .name = "hermesRight:alter", .gpio = BBKEYS_GPIO(2, 7) }, +#endif +}; + +static struct gpio_led_platform_data hermes_led_info = { + .leds = hermes_leds, + .num_leds = ARRAY_SIZE(hermes_leds), +}; + +static struct platform_device leds = { + .name = "leds-gpio", + .id = -1, + .dev = { + .platform_data = &hermes_led_info, + } +}; + + +/**************************************************************** + * Serial + ****************************************************************/ + static struct s3c24xx_uart_clksrc htchermes_serial_clocks[] = { [0] = { .name = "fclk", @@ -111,6 +242,11 @@ } }; + +/**************************************************************** + * Nand + ****************************************************************/ + static struct mtd_partition htchermes_nand_part[] = { [0] = { .name = "Whole Flash", @@ -137,16 +273,18 @@ .sets = htchermes_nand_sets, }; + +/**************************************************************** + * Buttons + ****************************************************************/ + static struct gpio_keys_button htchermes_gpio_keys_table[] = { - {KEY_POWER, S3C2410_GPF0, 1, "Power button"}, /* power*/ - {KEY_CAMERA, S3C2410_GPF4, 1, "Camera button"}, /* camera */ -#if 0 - {KEY_CALENDAR, S3C2410_GPG0, 1, "Calendar button"}, /* play */ - {KEY_CONTACTS, S3C2410_GPG2, 1, "Contacts button"}, /* person */ - {KEY_MAIL, S3C2410_GPG3, 1, "Mail button"}, /* nevo */ - {KEY_HOMEPAGE, S3C2410_GPG7, 1, "Home button"}, /* arrow */ - {KEY_ENTER, S3C2410_GPG9, 1, "Ok button"}, /* ok */ -#endif + {KEY_POWER, S3C2410_GPF0, 1, "Power button"}, + {KEY_CAMERA, S3C2410_GPF4, 1, "Camera button"}, + {KEY_SETUP, S3C2410_GPG3, 1, "Comm mgr button"}, + {KEY_ENTER, S3C2410_GPG6, 1, "Jog wheel click"}, + {KEY_OK, S3C2410_GPG1, 1, "Side ok button"}, + {KEY_AUDIO, S3C2410_GPG5, 1, "PTT button"}, }; static struct gpio_keys_platform_data htchermes_gpio_keys_data = { @@ -154,12 +292,15 @@ .nbuttons = ARRAY_SIZE(htchermes_gpio_keys_table), }; -static struct platform_device s3c_device_gpiokeys = { +static struct platform_device gpiokeys = { .name = "gpio-keys", .dev = { .platform_data = &htchermes_gpio_keys_data, } }; -/* LCD */ + +/**************************************************************** + * LCD + ****************************************************************/ static struct platform_device htchermes_lcd = { .name = "vsfb", @@ -169,17 +310,97 @@ }, }; + +/**************************************************************** + * Power management + ****************************************************************/ + +static int ac_on(void) +{ + int haspower = !gpio_get_value(EGPIO_NR_HTCHERMES_PWR_IN_PWR); + int hashigh = !gpio_get_value(EGPIO_NR_HTCHERMES_PWR_IN_HIGHPWR); + return haspower && hashigh; +} + +static int usb_on(void) +{ + int haspower = !gpio_get_value(EGPIO_NR_HTCHERMES_PWR_IN_PWR); + int hashigh = !gpio_get_value(EGPIO_NR_HTCHERMES_PWR_IN_HIGHPWR); + return haspower && !hashigh; +} + +static struct pda_power_pdata power_pdata = { + .is_ac_online = ac_on, + .is_usb_online = usb_on, +}; + +static struct resource power_resources[] = { + [0] = { + .name = "ac", + .start = IRQ_EGPIO(EGPIO_NR_HTCHERMES_PWR_IN_PWR), + .end = IRQ_EGPIO(EGPIO_NR_HTCHERMES_PWR_IN_PWR), + .flags = IORESOURCE_IRQ, + }, +}; + +static struct platform_device power_dev = { + .name = "pda-power", + .id = -1, + .resource = power_resources, + .num_resources = ARRAY_SIZE(power_resources), + .dev = { + .platform_data = &power_pdata, + }, +}; + + +/**************************************************************** + * USB client controller + ****************************************************************/ + +static void udc_command(enum s3c2410_udc_cmd_e cmd) +{ + switch (cmd) { + case S3C2410_UDC_P_ENABLE: + printk(KERN_NOTICE "USB cmd disconnect\n"); + gpio_set_value(GPIO_NR_HTCHERMES_USB_PUEN, 1); + break; + case S3C2410_UDC_P_DISABLE: + printk(KERN_NOTICE "USB cmd connect\n"); + gpio_set_value(GPIO_NR_HTCHERMES_USB_PUEN, 0); + break; + default: + break; + } +} + +static struct s3c2410_udc_mach_info udc_cfg = { + .udc_command = udc_command, +}; + + +/**************************************************************** + * Init + ****************************************************************/ + static struct platform_device *htchermes_devices[] __initdata = { &s3c_device_usb, &s3c_device_wdt, &s3c_device_i2c, &s3c_device_iis, - &s3c_device_nand, +// &s3c_device_nand, &s3c_device_rtc, &s3c_device_usbgadget, &s3c_device_sdi, - &s3c_device_gpiokeys, + &egpio, +// &bbkeys, // &htchermes_lcd, + &leds, + &gpiokeys, + &power_dev, +}; + +static struct map_desc htchermes_iodesc[] __initdata = { }; static struct s3c24xx_board htchermes_board __initdata = { @@ -189,7 +410,7 @@ static void __init htchermes_map_io(void) { - s3c_device_nand.dev.platform_data = &htchermes_nand_info; +// s3c_device_nand.dev.platform_data = &htchermes_nand_info; s3c24xx_init_io(htchermes_iodesc, ARRAY_SIZE(htchermes_iodesc)); s3c24xx_init_clocks(16934000); @@ -197,13 +418,9 @@ s3c24xx_set_board(&htchermes_board); } -static void __init htchermes_init_irq(void) -{ - s3c24xx_init_irq(); -} - static void __init htchermes_init_machine(void) { + s3c24xx_udc_set_platdata(&udc_cfg); s3c2410_pm_init(); } @@ -213,7 +430,7 @@ .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc, .boot_params = S3C2410_SDRAM_PA + 0x100, .map_io = htchermes_map_io, - .init_irq = htchermes_init_irq, + .init_irq = s3c24xx_init_irq, .init_machine = htchermes_init_machine, .timer = &s3c24xx_timer, MACHINE_END --- /dev/null 2007-06-27 19:11:51.515574419 -0400 +++ arch/arm/mach-s3c2442/htchermes/htchermes-gpio.h 2007-09-08 23:51:46.000000000 -0400 @@ -0,0 +1,52 @@ +/* HTC Hermes GPIOs */ +#ifndef _HTCHERMES_GPIO_H_ +#define _HTCHERMES_GPIO_H_ + +#include "linux/gpiodev2.h" // GPIO_BASE_INCREMENT + + +/**************************************************************** + * EGPIO + ****************************************************************/ + +#define IRQ_NR_HTCHERMES_EGPIO_IRQ IRQ_EINT1 +#define HTCHERMES_EGPIO_BASE GPIO_BASE_INCREMENT +#define HTCHERMES_EGPIO(reg,bit) (HTCHERMES_EGPIO_BASE + 16*(reg) + (bit)) + + +/**************************************************************** + * Front keypad + ****************************************************************/ + +#define GPIO_NR_HTCHERMES_FK_SDA S3C2410_GPC12 +#define GPIO_NR_HTCHERMES_FK_SCL S3C2410_GPC11 +#define IRQ_NR_HTCHERMES_FK_IRQ IRQ_EINT3 + + +/**************************************************************** + * Power + ****************************************************************/ + +#define EGPIO_NR_HTCHERMES_PWR_IRQ HTCHERMES_EGPIO(2, 3) +#define EGPIO_NR_HTCHERMES_PWR_IN_PWR HTCHERMES_EGPIO(4, 2) +#define EGPIO_NR_HTCHERMES_PWR_IN_HIGHPWR HTCHERMES_EGPIO(4, 1) +#define EGPIO_NR_HTCHERMES_PWR_CHARGE HTCHERMES_EGPIO(0, 10) + + +/**************************************************************** + * LEDS + ****************************************************************/ + +#define GPIO_NR_HTCHERMES_FLASHLIGHT S3C2410_GPC6 +#define GPIO_NR_HTCHERMES_VIBRA S3C2410_GPB4 +#define EGPIO_NR_HTCHERMES_KBD_BACKLIGHT HTCHERMES_EGPIO(1, 3) + + +/**************************************************************** + * USB + ****************************************************************/ + +#define GPIO_NR_HTCHERMES_USB_PUEN S3C2410_GPH10 + + +#endif /* htchermes-gpio.h */