summaryrefslogtreecommitdiff
path: root/packages/kexecboot/linux-kexecboot-2.6.24/htcuni.patch
diff options
context:
space:
mode:
Diffstat (limited to 'packages/kexecboot/linux-kexecboot-2.6.24/htcuni.patch')
-rw-r--r--packages/kexecboot/linux-kexecboot-2.6.24/htcuni.patch7920
1 files changed, 0 insertions, 7920 deletions
diff --git a/packages/kexecboot/linux-kexecboot-2.6.24/htcuni.patch b/packages/kexecboot/linux-kexecboot-2.6.24/htcuni.patch
deleted file mode 100644
index 8448c4ec06..0000000000
--- a/packages/kexecboot/linux-kexecboot-2.6.24/htcuni.patch
+++ /dev/null
@@ -1,7920 +0,0 @@
----
- arch/arm/Kconfig | 2
- arch/arm/mach-pxa/Kconfig | 89 +
- arch/arm/mach-pxa/Makefile | 1
- arch/arm/mach-pxa/generic.c | 13
- arch/arm/mach-pxa/htcuniversal/Makefile | 19
- arch/arm/mach-pxa/htcuniversal/htcuniversal.c | 468 +++++
- arch/arm/mach-pxa/htcuniversal/htcuniversal_ak4641.c | 917 +++++++++++
- arch/arm/mach-pxa/htcuniversal/htcuniversal_ak4641.h | 65
- arch/arm/mach-pxa/htcuniversal/htcuniversal_asic3_leds.c | 143 +
- arch/arm/mach-pxa/htcuniversal/htcuniversal_bl.c | 61
- arch/arm/mach-pxa/htcuniversal/htcuniversal_bt.c | 135 +
- arch/arm/mach-pxa/htcuniversal/htcuniversal_bt.h | 17
- arch/arm/mach-pxa/htcuniversal/htcuniversal_buttons.c | 87 +
- arch/arm/mach-pxa/htcuniversal/htcuniversal_core.c | 226 ++
- arch/arm/mach-pxa/htcuniversal/htcuniversal_lcd.c | 212 ++
- arch/arm/mach-pxa/htcuniversal/htcuniversal_phone.c | 167 ++
- arch/arm/mach-pxa/htcuniversal/htcuniversal_phone.h | 16
- arch/arm/mach-pxa/htcuniversal/htcuniversal_pm.c | 69
- arch/arm/mach-pxa/htcuniversal/htcuniversal_power2.c | 97 +
- arch/arm/mach-pxa/htcuniversal/htcuniversal_ts2.c | 490 ++++++
- arch/arm/mach-pxa/htcuniversal/htcuniversal_udc.c | 71
- arch/arm/mach-pxa/htcuniversal/tsc2046_ts.h | 20
- drivers/input/keyboard/Kconfig | 7
- drivers/input/keyboard/Makefile | 1
- drivers/input/keyboard/asic3_keys.c | 131 +
- drivers/leds/Kconfig | 7
- drivers/leds/Makefile | 1
- drivers/leds/leds-asic3.c | 189 ++
- drivers/mfd/Kconfig | 10
- drivers/mfd/Makefile | 2
- drivers/mfd/asic3_base.c | 1208 +++++++++++++++
- drivers/mfd/soc-core.c | 106 +
- drivers/mfd/soc-core.h | 30
- drivers/mmc/host/Kconfig | 6
- drivers/mmc/host/Makefile | 1
- drivers/mmc/host/asic3_mmc.c | 900 +++++++++++
- drivers/mmc/host/asic3_mmc.h | 25
- drivers/serial/pxa.c | 22
- include/asm-arm/arch-pxa/clock.h | 27
- include/asm-arm/arch-pxa/htcuniversal-asic.h | 213 ++
- include/asm-arm/arch-pxa/htcuniversal-gpio.h | 220 ++
- include/asm-arm/arch-pxa/htcuniversal-init.h | 14
- include/asm-arm/arch-pxa/htcuniversal.h | 3
- include/asm-arm/arch-pxa/irqs.h | 2
- include/asm-arm/arch-pxa/pxa-pm_ll.h | 6
- include/asm-arm/arch-pxa/pxa-regs.h | 2
- include/asm-arm/arch-pxa/serial.h | 78
- include/asm-arm/hardware/asic3_keys.h | 18
- include/asm-arm/hardware/asic3_leds.h | 34
- include/asm-arm/hardware/ipaq-asic3.h | 602 +++++++
- include/linux/backlight.h | 7
- include/linux/gpiodev.h | 44
- include/linux/input_pda.h | 47
- include/linux/ioport.h | 1
- include/linux/soc/asic3_base.h | 104 +
- include/linux/soc/tmio_mmc.h | 17
- 56 files changed, 7469 insertions(+), 1 deletion(-)
-
-Index: linux-2.6.24/arch/arm/mach-pxa/htcuniversal/Makefile
-===================================================================
---- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ linux-2.6.24/arch/arm/mach-pxa/htcuniversal/Makefile 2008-03-10 16:09:23.000000000 +0000
-@@ -0,0 +1,19 @@
-+#
-+# Makefile for HTC Universal
-+#
-+
-+snd-htcuniversal-ak4641-objs := htcuniversal_ak4641.o
-+
-+obj-$(CONFIG_MACH_HTCUNIVERSAL) += htcuniversal.o
-+obj-$(CONFIG_HTCUNIVERSAL_CORE) += htcuniversal_core.o
-+obj-$(CONFIG_HTCUNIVERSAL_POWER) += htcuniversal_power2.o
-+obj-$(CONFIG_HTCUNIVERSAL_LCD) += htcuniversal_lcd.o
-+obj-$(CONFIG_HTCUNIVERSAL_BACKLIGHT) += htcuniversal_bl.o
-+obj-$(CONFIG_HTCUNIVERSAL_TS2) += htcuniversal_ts2.o
-+obj-$(CONFIG_HTCUNIVERSAL_BUTTONS) += htcuniversal_buttons.o
-+obj-$(CONFIG_HTCUNIVERSAL_BLUETOOTH) += htcuniversal_bt.o
-+obj-$(CONFIG_HTCUNIVERSAL_PHONE) += htcuniversal_phone.o
-+obj-$(CONFIG_HTCUNIVERSAL_ASIC3_LEDS) += htcuniversal_asic3_leds.o
-+obj-$(CONFIG_HTCUNIVERSAL_UDC) += htcuniversal_udc.o
-+
-+obj-$(CONFIG_HTCUNIVERSAL_AK4641) += htcuniversal_ak4641.o
-Index: linux-2.6.24/arch/arm/mach-pxa/htcuniversal/htcuniversal.c
-===================================================================
---- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ linux-2.6.24/arch/arm/mach-pxa/htcuniversal/htcuniversal.c 2008-03-10 16:09:23.000000000 +0000
-@@ -0,0 +1,468 @@
-+/*
-+ * Hardware definitions for HTC Universal
-+ *
-+ * Copyright (c) 2006 Oleg Gusev
-+ *
-+ * Use consistent with the GNU GPL is permitted,
-+ * provided that this copyright notice is
-+ * preserved in its entirety in all copies and derived works.
-+ *
-+ */
-+
-+#include <linux/kernel.h>
-+#include <linux/init.h>
-+#include <linux/platform_device.h>
-+#include <linux/irq.h>
-+#include <linux/input.h>
-+#include <linux/gpio_keys.h>
-+#include <linux/soc/asic3_base.h>
-+
-+#include <asm/mach-types.h>
-+#include <asm/hardware.h>
-+#include <asm/setup.h>
-+
-+#include <asm/mach/irq.h>
-+#include <asm/mach/arch.h>
-+
-+#include <asm/arch/bitfield.h>
-+#include <asm/arch/pxa-regs.h>
-+#include <asm/arch/serial.h>
-+#include <asm/arch/pxa27x_keyboard.h>
-+#include <asm/arch/pxafb.h>
-+#include <asm/arch/irda.h>
-+#include <asm/arch/ohci.h>
-+
-+#include <asm/arch/htcuniversal.h>
-+#include <asm/arch/htcuniversal-gpio.h>
-+#include <asm/arch/htcuniversal-init.h>
-+#include <asm/arch/htcuniversal-asic.h>
-+
-+#include <asm/hardware/ipaq-asic3.h>
-+
-+#include "../generic.h"
-+
-+#include "htcuniversal_bt.h"
-+#include "htcuniversal_phone.h"
-+#include "tsc2046_ts.h"
-+
-+/*
-+ * IRDA
-+ */
-+
-+static void htcuniversal_irda_transceiver_mode(struct device *dev, int mode)
-+{
-+ /* */
-+}
-+
-+static struct pxaficp_platform_data htcuniversal_ficp_platform_data = {
-+ .transceiver_cap = IR_SIRMODE | IR_FIRMODE,
-+ .transceiver_mode = htcuniversal_irda_transceiver_mode,
-+};
-+
-+/*
-+ * Bluetooth - Relies on other loadable modules, like ASIC3 and Core,
-+ * so make the calls indirectly through pointers. Requires that the
-+ * htcuniversal_bt module be loaded before any attempt to use
-+ * bluetooth (obviously).
-+ */
-+
-+static struct htcuniversal_bt_funcs bt_funcs;
-+
-+static void
-+htcuniversal_bt_configure( int state )
-+{
-+ if (bt_funcs.configure != NULL)
-+ bt_funcs.configure( state );
-+}
-+
-+static struct htcuniversal_phone_funcs phone_funcs;
-+
-+static void
-+htcuniversal_phone_configure( int state )
-+{
-+ if (phone_funcs.configure != NULL)
-+ phone_funcs.configure( state );
-+}
-+
-+//void htcuniversal_ll_pm_init(void);
-+
-+extern struct platform_device htcuniversal_bl;
-+static struct platform_device htcuniversal_lcd = { .name = "htcuniversal_lcd", };
-+//static struct platform_device htcuniversal_kbd = { .name = "htcuniversal_kbd", };
-+static struct platform_device htcuniversal_buttons = { .name = "htcuniversal_buttons", };
-+//static struct platform_device htcuniversal_ts = { .name = "htcuniversal_ts", };
-+//static struct platform_device htcuniversal_bt = { .name = "htcuniversal_bt", };
-+//static struct platform_device htcuniversal_phone = { .name = "htcuniversal_phone", };
-+static struct platform_device htcuniversal_power = { .name = "htcuniversal_power", };
-+static struct platform_device htcuniversal_udc = { .name = "htcuniversal_udc", };
-+
-+static struct tsc2046_mach_info htcuniversal_ts_platform_data = {
-+ .port = 1,
-+ .clock = CKEN_SSP1,
-+ .pwrbit_X = 1,
-+ .pwrbit_Y = 1,
-+ .irq = 0 /* asic3 irq */
-+};
-+
-+static struct platform_device htcuniversal_ts = {
-+ .name = "htcuniversal_ts",
-+ .dev = {
-+ .platform_data = &htcuniversal_ts_platform_data,
-+ },
-+};
-+
-+
-+/* Bluetooth */
-+
-+static struct platform_device htcuniversal_bt = {
-+ .name = "htcuniversal_bt",
-+ .id = -1,
-+ .dev = {
-+ .platform_data = &bt_funcs,
-+ },
-+};
-+
-+static struct platform_device htcuniversal_phone = {
-+ .name = "htcuniversal_phone",
-+ .id = -1,
-+ .dev = {
-+ .platform_data = &phone_funcs,
-+ },
-+};
-+
-+/* PXA2xx Keys */
-+
-+static struct gpio_keys_button htcuniversal_button_table[] = {
-+ { KEY_POWER, GPIO_NR_HTCUNIVERSAL_KEY_ON_N, 1 },
-+};
-+
-+static struct gpio_keys_platform_data htcuniversal_pxa_keys_data = {
-+ .buttons = htcuniversal_button_table,
-+ .nbuttons = ARRAY_SIZE(htcuniversal_button_table),
-+};
-+
-+static struct platform_device htcuniversal_pxa_keys = {
-+ .name = "gpio-keys",
-+ .dev = {
-+ .platform_data = &htcuniversal_pxa_keys_data,
-+ },
-+ .id = -1,
-+};
-+
-+/****************************************************************
-+ * Keyboard
-+ ****************************************************************/
-+
-+static struct pxa27x_keyboard_platform_data htcuniversal_kbd = {
-+ .nr_rows = 8,
-+ .nr_cols = 8,
-+ .keycodes = {
-+ {
-+ /* row 0 */
-+ KEY_ENTER,
-+ KEY_MINUS,
-+ KEY_ESC,
-+ KEY_1,
-+ KEY_TAB,
-+ KEY_CAPSLOCK,
-+ KEY_LEFTSHIFT,
-+ KEY_RIGHTALT, /* Fn */
-+ }, { /* row 1 */
-+ KEY_COMMA,
-+ KEY_EQUAL,
-+ KEY_F1,
-+ KEY_2,
-+ KEY_Q,
-+ KEY_A,
-+ KEY_Z,
-+ KEY_LEFTCTRL,
-+ }, { /* row 2 */
-+ KEY_UP,
-+ KEY_I,
-+ KEY_F2,
-+ KEY_3,
-+ KEY_W,
-+ KEY_S,
-+ KEY_X,
-+ KEY_F6,
-+ }, { /* row 3 */
-+ KEY_DOT,
-+ KEY_O,
-+ KEY_F3,
-+ KEY_4,
-+ KEY_E,
-+ KEY_D,
-+ KEY_C,
-+ KEY_LEFTALT,
-+ }, { /* row 4 */
-+ KEY_F9,
-+ KEY_P,
-+ KEY_F4,
-+ KEY_5,
-+ KEY_R,
-+ KEY_F,
-+ KEY_V,
-+ KEY_SPACE,
-+ }, { /* row 5 */
-+ KEY_RIGHT,
-+ KEY_BACKSPACE,
-+ KEY_F5,
-+ KEY_6,
-+ KEY_T,
-+ KEY_G,
-+ KEY_B,
-+ KEY_F7,
-+ }, { /* row 6 */
-+ KEY_F9,
-+ KEY_K,
-+ KEY_9,
-+ KEY_7,
-+ KEY_Y,
-+ KEY_H,
-+ KEY_N,
-+ KEY_LEFT,
-+ }, { /* row 7 */
-+ KEY_F10,
-+ KEY_L,
-+ KEY_0,
-+ KEY_8,
-+ KEY_U,
-+ KEY_J,
-+ KEY_M,
-+ KEY_DOWN,
-+ },
-+ },
-+ .gpio_modes = {
-+ GPIO_NR_HTCUNIVERSAL_KP_MKIN0_MD,
-+ GPIO_NR_HTCUNIVERSAL_KP_MKIN1_MD,
-+ GPIO_NR_HTCUNIVERSAL_KP_MKIN2_MD,
-+ GPIO_NR_HTCUNIVERSAL_KP_MKIN3_MD,
-+ GPIO_NR_HTCUNIVERSAL_KP_MKIN4_MD,
-+ GPIO_NR_HTCUNIVERSAL_KP_MKIN5_MD,
-+ GPIO_NR_HTCUNIVERSAL_KP_MKIN6_MD,
-+ GPIO_NR_HTCUNIVERSAL_KP_MKIN7_MD,
-+ GPIO_NR_HTCUNIVERSAL_KP_MKOUT0_MD,
-+ GPIO_NR_HTCUNIVERSAL_KP_MKOUT1_MD,
-+ GPIO_NR_HTCUNIVERSAL_KP_MKOUT2_MD,
-+ GPIO_NR_HTCUNIVERSAL_KP_MKOUT3_MD,
-+ GPIO_NR_HTCUNIVERSAL_KP_MKOUT4_MD,
-+ GPIO_NR_HTCUNIVERSAL_KP_MKOUT5_MD,
-+ GPIO_NR_HTCUNIVERSAL_KP_MKOUT6_MD,
-+ GPIO_NR_HTCUNIVERSAL_KP_MKOUT7_MD,
-+ },
-+};
-+
-+static struct platform_device htcuniversal_pxa_keyboard = {
-+ .name = "pxa27x-keyboard",
-+ .id = -1,
-+ .dev = {
-+ .platform_data = &htcuniversal_kbd,
-+ },
-+};
-+/* Core Hardware Functions */
-+
-+struct platform_device htcuniversal_core = {
-+ .name = "htcuniversal_core",
-+ .id = 0,
-+ .dev = {
-+ .platform_data = NULL,
-+ },
-+};
-+
-+static struct platform_device *devices[] __initdata = {
-+ &htcuniversal_core,
-+// &htcuniversal_flash,
-+ &htcuniversal_pxa_keyboard,
-+ &htcuniversal_pxa_keys,
-+};
-+
-+static struct platform_device *htcuniversal_asic3_devices[] __initdata = {
-+ &htcuniversal_lcd,
-+#ifdef CONFIG_HTCUNIVERSAL_BACKLIGHT
-+ &htcuniversal_bl,
-+#endif
-+ &htcuniversal_buttons,
-+ &htcuniversal_ts,
-+ &htcuniversal_bt,
-+ &htcuniversal_phone,
-+ &htcuniversal_power,
-+ &htcuniversal_udc,
-+};
-+
-+static struct asic3_platform_data htcuniversal_asic3_platform_data = {
-+
-+ /* Setting ASIC3 GPIO registers to the below initialization states
-+ * HTC Universal asic3 information:
-+ * http://wiki.xda-developers.com/index.php?pagename=UniversalASIC3
-+ * http://wiki.xda-developers.com/index.php?pagename=ASIC3
-+ *
-+ * dir: Direction of the GPIO pin. 0: input, 1: output.
-+ * If unknown, set as output to avoid power consuming floating input nodes
-+ * init: Initial state of the GPIO bits
-+ *
-+ * These registers are configured as they are on Wince.
-+ */
-+ .gpio_a = {
-+ .dir = (1<<GPIOA_LCD_PWR5_ON) |
-+ (1<<GPIOA_FLASHLIGHT) |
-+ (1<<GPIOA_UNKNOWN9) |
-+ (1<<GPIOA_SPK_PWR2_ON) |
-+ (1<<GPIOA_UNKNOWN4) |
-+ (1<<GPIOA_EARPHONE_PWR_ON)|
-+ (1<<GPIOA_AUDIO_PWR_ON) |
-+ (1<<GPIOA_SPK_PWR1_ON) |
-+ (1<<GPIOA_I2C_EN),
-+ .init = (1<<GPIOA_LCD_PWR5_ON) |
-+ (1<<GPIOA_I2C_EN),
-+ .sleep_out = 0x0000,
-+ .batt_fault_out = 0x0000,
-+ .alt_function = 0x0000,
-+ .sleep_conf = 0x000c,
-+ },
-+ .gpio_b = {
-+ .dir = 0xc142,
-+ .init = 0x8842, // TODO: 0x0900
-+ .sleep_out = 0x0000,
-+ .batt_fault_out = 0x0000,
-+ .alt_function = 0x0000,
-+ .sleep_conf = 0x000c,
-+ },
-+ .gpio_c = {
-+ .dir = 0xc7e7,
-+ .init = 0xc6e0, // TODO: 0x8000
-+ .sleep_out = 0x0000,
-+ .batt_fault_out = 0x0000,
-+ .alt_function = 0x0007, // GPIOC_LED_RED | GPIOC_LED_GREEN | GPIOC_LED_BLUE
-+ .sleep_conf = 0x000c,
-+ },
-+ .gpio_d = {
-+ .dir = 0xffc0,
-+ .init = 0x7840, // TODO: 0x0000
-+ .sleep_out = 0x0000,
-+ .batt_fault_out = 0x0000,
-+ .alt_function = 0x0000,
-+ .sleep_conf = 0x0008,
-+ },
-+ .bus_shift = 1,
-+ .irq_base = HTCUNIVERSAL_ASIC3_IRQ_BASE,
-+
-+ .child_platform_devs = htcuniversal_asic3_devices,
-+ .num_child_platform_devs = ARRAY_SIZE(htcuniversal_asic3_devices),
-+};
-+
-+static struct resource htcuniversal_asic3_resources[] = {
-+ [0] = {
-+ .start = HTCUNIVERSAL_ASIC3_GPIO_PHYS,
-+ .end = HTCUNIVERSAL_ASIC3_GPIO_PHYS + IPAQ_ASIC3_MAP_SIZE,
-+ .flags = IORESOURCE_MEM,
-+ },
-+ [1] = {
-+ .start = HTCUNIVERSAL_IRQ(ASIC3_EXT_INT),
-+ .end = HTCUNIVERSAL_IRQ(ASIC3_EXT_INT),
-+ .flags = IORESOURCE_IRQ,
-+ },
-+ [2] = {
-+ .start = HTCUNIVERSAL_ASIC3_MMC_PHYS,
-+ .end = HTCUNIVERSAL_ASIC3_MMC_PHYS + IPAQ_ASIC3_MAP_SIZE,
-+ .flags = IORESOURCE_MEM,
-+ },
-+ [3] = {
-+ .start = HTCUNIVERSAL_IRQ(ASIC3_SDIO_INT_N),
-+ .flags = IORESOURCE_IRQ,
-+ },
-+};
-+
-+struct platform_device htcuniversal_asic3 = {
-+ .name = "asic3",
-+ .id = 0,
-+ .num_resources = ARRAY_SIZE(htcuniversal_asic3_resources),
-+ .resource = htcuniversal_asic3_resources,
-+ .dev = { .platform_data = &htcuniversal_asic3_platform_data, },
-+};
-+EXPORT_SYMBOL(htcuniversal_asic3);
-+
-+static struct pxafb_mode_info htcuniversal_lcd_modes[] = {
-+{
-+ .pixclock = 96153,
-+ .xres = 480,
-+ .yres = 640,
-+ .bpp = 16,
-+ .hsync_len = 4,
-+ .vsync_len = 1,
-+ .left_margin = 20,
-+ .right_margin = 8,
-+ .upper_margin = 7,
-+ .lower_margin = 8,
-+
-+// .sync = FB_SYNC_HOR_LOW_ACT|FB_SYNC_VERT_LOW_ACT,
-+
-+},
-+};
-+
-+static struct pxafb_mach_info sony_acx526akm = {
-+ .modes = htcuniversal_lcd_modes,
-+ .num_modes = ARRAY_SIZE(htcuniversal_lcd_modes),
-+
-+ /* fixme: use constants defined in pxafb.h */
-+ .lccr0 = 0x00000080,
-+ .lccr3 = 0x00400000,
-+// .lccr4 = 0x80000000,
-+};
-+
-+static void __init htcuniversal_init_irq(void)
-+{
-+ pxa27x_init_irq();
-+}
-+
-+static struct platform_pxa_serial_funcs htcuniversal_pxa_bt_funcs = {
-+ .configure = htcuniversal_bt_configure,
-+};
-+static struct platform_pxa_serial_funcs htcuniversal_pxa_phone_funcs = {
-+ .configure = htcuniversal_phone_configure,
-+};
-+
-+/* USB OHCI */
-+
-+static int htcuniversal_ohci_init(struct device *dev)
-+{
-+ /* missing GPIO setup here */
-+
-+ /* got the value from wince */
-+ UHCHR=UHCHR_CGR;
-+
-+ return 0;
-+}
-+
-+static struct pxaohci_platform_data htcuniversal_ohci_platform_data = {
-+ .port_mode = PMM_PERPORT_MODE,
-+ .init = htcuniversal_ohci_init,
-+};
-+
-+static void __init htcuniversal_map_io(void)
-+{
-+ pxa_map_io();
-+
-+ pxa_set_btuart_info(&htcuniversal_pxa_bt_funcs);
-+ pxa_set_ffuart_info(&htcuniversal_pxa_phone_funcs);
-+}
-+
-+static void __init htcuniversal_init(void)
-+{
-+ set_pxa_fb_info(&sony_acx526akm);
-+
-+ platform_device_register(&htcuniversal_asic3);
-+ platform_add_devices(devices, ARRAY_SIZE(devices) );
-+ pxa_set_ficp_info(&htcuniversal_ficp_platform_data);
-+ pxa_set_ohci_info(&htcuniversal_ohci_platform_data);
-+}
-+
-+MACHINE_START(HTCUNIVERSAL, "HTC Universal")
-+ /* Maintainer xanadux.org */
-+ .phys_io = 0x40000000,
-+ .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
-+ .boot_params = 0xa0000100,
-+ .map_io = htcuniversal_map_io,
-+ .init_irq = htcuniversal_init_irq,
-+ .init_machine = htcuniversal_init,
-+ .timer = &pxa_timer,
-+MACHINE_END
-Index: linux-2.6.24/arch/arm/mach-pxa/htcuniversal/htcuniversal_ak4641.c
-===================================================================
---- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ linux-2.6.24/arch/arm/mach-pxa/htcuniversal/htcuniversal_ak4641.c 2008-03-10 16:09:23.000000000 +0000
-@@ -0,0 +1,917 @@
-+/*
-+ * Audio support for codec Asahi Kasei AK4641
-+ *
-+ * 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.
-+ *
-+ * Copyright (c) 2006 Giorgio Padrin <giorgio@mandarinlogiq.org>
-+ *
-+ * History:
-+ *
-+ * 2006-03 Written -- Giorgio Padrin
-+ * 2006-09 Test and debug on machine (HP hx4700) -- Elshin Roman <roxmail@list.ru>
-+ *
-+ * AK4641 codec device driver
-+ *
-+ * Copyright (c) 2005 SDG Systems, LLC
-+ *
-+ * Based on code:
-+ * Copyright (c) 2002 Hewlett-Packard Company
-+ * Copyright (c) 2000 Nicolas Pitre <nico@cam.org>
-+ * Copyright (c) 2000 Lernout & Hauspie Speech Products, N.V.
-+ *
-+ * This program is free software; you can redistribute it and/or
-+ * modify it under the terms of the GNU General Public License.
-+ */
-+
-+#include <sound/driver.h>
-+
-+#include <linux/module.h>
-+#include <linux/init.h>
-+#include <linux/types.h>
-+#include <linux/string.h>
-+#include <linux/slab.h>
-+#include <linux/errno.h>
-+#include <linux/ioctl.h>
-+#include <linux/delay.h>
-+#include <linux/i2c.h>
-+
-+#include <sound/core.h>
-+#include <sound/control.h>
-+#include <sound/initval.h>
-+#include <sound/info.h>
-+
-+#include "htcuniversal_ak4641.h"
-+
-+/* Registers */
-+#define R_PM1 0x00
-+#define R_PM2 0x01
-+#define R_SEL1 0x02
-+#define R_SEL2 0x03
-+#define R_MODE1 0x04
-+#define R_MODE2 0x05
-+#define R_DAC 0x06
-+#define R_MIC 0x07
-+#define REG_TIMER 0x08
-+#define REG_ALC1 0x09
-+#define REG_ALC2 0x0a
-+#define R_PGA 0x0b
-+#define R_ATTL 0x0c
-+#define R_ATTR 0x0d
-+#define REG_VOL 0x0e
-+#define R_STATUS 0x0f
-+#define REG_EQLO 0x10
-+#define REG_EQMID 0x11
-+#define REG_EQHI 0x12
-+#define REG_BTIF 0x13
-+
-+/* Register flags */
-+/* REG_PWR1 */
-+#define R_PM1_PMADC 0x01
-+#define R_PM1_PMMIC 0x02
-+#define REG_PWR1_PMAUX 0x04
-+#define REG_PWR1_PMMO 0x08
-+#define R_PM1_PMLO 0x10
-+/* unused 0x20 */
-+/* unused 0x40 */
-+#define R_PM1_PMVCM 0x80
-+
-+/* REG_PWR2 */
-+#define R_PM2_PMDAC 0x01
-+/* unused 0x02 */
-+/* unused 0x04 */
-+#define R_PM2_PMMO2 0x08
-+#define REG_PWR2_MCKAC 0x10
-+/* unused 0x20 */
-+/* unused 0x40 */
-+#define R_PM2_MCKPD 0x80
-+
-+/* REG_SEL1 */
-+#define R_SEL1_PSMO2 0x01
-+/* unused 0x02 */
-+/* unused 0x04 */
-+/* unused 0x08 */
-+#define REG_SEL1_MICM 0x10
-+#define REG_SEL1_DACM 0x20
-+#define REG_SEL1_PSMO 0x40
-+#define REG_SEL1_MOGN 0x80
-+
-+/* REG_SEL2 */
-+#define R_SEL2_PSLOR 0x01
-+#define R_SEL2_PSLOL 0x02
-+#define REG_SEL2_AUXSI 0x04
-+/* unused 0x08 */
-+#define REG_SEL2_MICL 0x10
-+#define REG_SEL2_AUXL 0x20
-+/* unused 0x40 */
-+#define R_SEL2_DACL 0x80
-+
-+/* REG_MODE1 */
-+#define REG_MODE1_DIF0 0x01
-+#define REG_MODE1_DIF1 0x02
-+/* unused 0x04 */
-+/* unused 0x08 */
-+/* unused 0x10 */
-+/* unused 0x20 */
-+/* unused 0x40 */
-+/* unused 0x80 */
-+
-+/* REG_MODE2 */
-+/* unused 0x01 */
-+#define REG_MODE2_LOOP 0x02
-+#define REG_MODE2_HPM 0x04
-+/* unused 0x08 */
-+/* unused 0x10 */
-+#define REG_MODE2_MCK0 0x20
-+#define REG_MODE2_MCK1 0x40
-+/* unused 0x80 */
-+
-+/* REG_DAC */
-+#define REG_DAC_DEM0 0x01
-+#define REG_DAC_DEM1 0x02
-+#define REG_DAC_EQ 0x04
-+/* unused 0x08 */
-+#define R_DAC_DATTC 0x10
-+#define R_DAC_SMUTE 0x20
-+#define REG_DAC_TM 0x40
-+/* unused 0x80 */
-+
-+/* REG_MIC */
-+#define R_MIC_MGAIN 0x01
-+#define R_MIC_MSEL 0x02
-+#define R_MIC_MICAD 0x04
-+#define R_MIC_MPWRI 0x08
-+#define R_MIC_MPWRE 0x10
-+#define REG_MIC_AUXAD 0x20
-+/* unused 0x40 */
-+/* unused 0x80 */
-+
-+/* REG_TIMER */
-+
-+#define REG_TIMER_LTM0 0x01
-+#define REG_TIMER_LTM1 0x02
-+#define REG_TIMER_WTM0 0x04
-+#define REG_TIMER_WTM1 0x08
-+#define REG_TIMER_ZTM0 0x10
-+#define REG_TIMER_ZTM1 0x20
-+/* unused 0x40 */
-+/* unused 0x80 */
-+
-+#define REG_ALC1_LMTH 0x01
-+#define REG_ALC1_RATT 0x02
-+#define REG_ALC1_LMAT0 0x04
-+#define REG_ALC1_LMAT1 0x08
-+#define REG_ALC1_ZELM 0x10
-+#define REG_ALC1_ALC1 0x20
-+/* unused 0x40 */
-+/* unused 0x80 */
-+
-+/* REG_ALC2 */
-+
-+/* REG_PGA */
-+
-+/* REG_ATTL */
-+
-+/* REG_ATTR */
-+
-+/* REG_VOL */
-+#define REG_VOL_ATTM 0x80
-+
-+/* REG_STATUS */
-+#define R_STATUS_DTMIC 0x01
-+
-+/* REG_EQ controls use 4 bits for each of 5 EQ levels */
-+
-+/* Bluetooth not yet implemented */
-+#define REG_BTIF_PMAD2 0x01
-+#define REG_BTIF_PMDA2 0x02
-+#define REG_BTIF_PMBIF 0x04
-+#define REG_BTIF_ADC2 0x08
-+#define REG_BTIF_DAC2 0x10
-+#define REG_BTIF_BTFMT0 0x20
-+#define REG_BTIF_BTFMT1 0x40
-+/* unused 0x80 */
-+
-+/* begin {{ I2C }} */
-+
-+static struct i2c_driver snd_ak4641_i2c_driver = {
-+ .driver = {
-+ .name = "ak4641-i2c"
-+ },
-+};
-+
-+static int snd_ak4641_i2c_init(void)
-+{
-+ return i2c_add_driver(&snd_ak4641_i2c_driver);
-+}
-+
-+static void snd_ak4641_i2c_free(void)
-+{
-+ i2c_del_driver(&snd_ak4641_i2c_driver);
-+}
-+
-+static inline int snd_ak4641_i2c_probe(struct snd_ak4641 *ak)
-+{
-+ if (ak->i2c_client.adapter == NULL) return -EINVAL;
-+ ak->i2c_client.addr = 0x12;
-+ if (i2c_smbus_xfer(ak->i2c_client.adapter, ak->i2c_client.addr,
-+ 0, 0, 0, I2C_SMBUS_QUICK, NULL) < 0)
-+ return -ENODEV;
-+ else return 0;
-+}
-+
-+static int snd_ak4641_i2c_attach(struct snd_ak4641 *ak)
-+{
-+ int ret = 0;
-+ if ((ret = snd_ak4641_i2c_probe(ak)) < 0) return ret;
-+ snprintf(ak->i2c_client.name, sizeof(ak->i2c_client.name),
-+ "ak4641-i2c at %d-%04x",
-+ i2c_adapter_id(ak->i2c_client.adapter), ak->i2c_client.addr);
-+ return i2c_attach_client(&ak->i2c_client);
-+}
-+
-+static void snd_ak4641_i2c_detach(struct snd_ak4641 *ak)
-+{
-+ i2c_detach_client(&ak->i2c_client);
-+}
-+
-+/* end {{ I2C }} */
-+
-+
-+/* begin {{ Registers & Cache Ops }} */
-+
-+static int snd_ak4641_hwsync(struct snd_ak4641 *ak, int read, u8 reg)
-+{
-+ struct i2c_msg msgs[2];
-+ u8 buf[2];
-+ int ret;
-+
-+ snd_assert(reg < ARRAY_SIZE(ak->regs), return -EINVAL);
-+
-+ /* setup i2c msgs */
-+ msgs[0].addr = ak->i2c_client.addr;
-+ msgs[0].flags = 0;
-+ msgs[0].buf = buf;
-+ if (!read)
-+ msgs[0].len = 2;
-+ else {
-+ msgs[1].flags = I2C_M_RD;
-+ msgs[1].addr = msgs[0].addr;
-+ msgs[1].buf = msgs[0].buf + 1;
-+ msgs[0].len = 1;
-+ msgs[1].len = 1;
-+ }
-+
-+ buf[0] = reg;
-+
-+ /* regs[reg] -> buffer, on write */
-+ if (!read) buf[1] = ak->regs[reg];
-+
-+ /* i2c transfer */
-+ ret = i2c_transfer(ak->i2c_client.adapter, msgs, read ? 2 : 1);
-+ if (ret != (read ? 2 : 1)) return ret; /* transfer error */ //@@ error ret < 0, or not ?
-+
-+ /* regs[reg] <- buffer, on read */
-+ if (read) ak->regs[reg] = buf[1];
-+
-+ return 0;
-+}
-+
-+static inline int snd_ak4641_hwsync_read(struct snd_ak4641 *ak, u8 reg)
-+{
-+ return snd_ak4641_hwsync(ak, 1, reg);
-+}
-+
-+static inline int snd_ak4641_hwsync_write(struct snd_ak4641 *ak, u8 reg)
-+{
-+ return snd_ak4641_hwsync(ak, 0, reg);
-+}
-+
-+static int snd_ak4641_hwsync_read_all(struct snd_ak4641 *ak)
-+{
-+ u8 reg;
-+ for (reg = 0; reg < ARRAY_SIZE(ak->regs); reg++)
-+ if (snd_ak4641_hwsync_read(ak, reg) < 0) return -1;
-+ return 0;
-+}
-+
-+static int snd_ak4641_hwsync_write_all(struct snd_ak4641 *ak)
-+{
-+ u8 reg;
-+ for (reg = 0; reg < ARRAY_SIZE(ak->regs); reg++)
-+ if (snd_ak4641_hwsync_write(ak, reg) < 0) return -1;
-+ return 0;
-+}
-+
-+static int snd_ak4641_reg_changed(struct snd_ak4641 *ak, u8 reg)
-+{
-+ if ((reg != R_PGA && ak->powered_on) ||
-+ (reg == R_PGA && (ak->regs[R_PM1] & R_PM1_PMMIC)))
-+ return snd_ak4641_hwsync_write(ak, reg);
-+ return 0;
-+}
-+
-+/* end {{ Registers & Cache Ops }}*/
-+
-+
-+static inline void snd_ak4641_lock(struct snd_ak4641 *ak)
-+{
-+ down(&ak->sem);
-+}
-+
-+static inline void snd_ak4641_unlock(struct snd_ak4641 *ak)
-+{
-+ up(&ak->sem);
-+}
-+
-+#define WRITE_MASK(i, val, mask) (((i) & ~(mask)) | ((val) & (mask)))
-+
-+
-+/* begin {{ Controls }} */
-+
-+#define INV_RANGE(val, mask) \
-+ (~(val) & (mask))
-+
-+/*-begin----------------------------------------------------------*/
-+static int snd_ak4641_actl_playback_volume_info(struct snd_kcontrol *kcontrol,
-+ struct snd_ctl_elem_info *uinfo)
-+{
-+ uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
-+ uinfo->count = 2;
-+ uinfo->value.integer.min = 0;
-+ uinfo->value.integer.max = 0xff;
-+ return 0;
-+}
-+
-+static int snd_ak4641_actl_playback_volume_get(struct snd_kcontrol *kcontrol,
-+ struct snd_ctl_elem_value *ucontrol)
-+{
-+ struct snd_ak4641 *ak = (struct snd_ak4641 *) kcontrol->private_data;
-+
-+ snd_ak4641_lock(ak);
-+ ucontrol->value.integer.value[0] = INV_RANGE(ak->regs[R_ATTL], 0xff);
-+ ucontrol->value.integer.value[1] = INV_RANGE(ak->regs[R_ATTR], 0xff);
-+ snd_ak4641_unlock(ak);
-+ return 0;
-+}
-+
-+static int snd_ak4641_actl_playback_volume_put(struct snd_kcontrol *kcontrol,
-+ struct snd_ctl_elem_value *ucontrol)
-+{
-+ struct snd_ak4641 *ak = (struct snd_ak4641 *) kcontrol->private_data;
-+
-+ snd_ak4641_lock(ak);
-+ ak->regs[R_ATTL] = INV_RANGE(ucontrol->value.integer.value[0], 0xff);
-+ ak->regs[R_ATTR] = INV_RANGE(ucontrol->value.integer.value[1], 0xff);
-+ snd_ak4641_reg_changed(ak, R_ATTL);
-+ snd_ak4641_reg_changed(ak, R_ATTR);
-+ snd_ak4641_unlock(ak);
-+ return 0;
-+}
-+/*-end------------------------------------------------------------*/
-+
-+/*-begin----------------------------------------------------------*/
-+static int snd_ak4641_actl_mic_gain_info(struct snd_kcontrol *kcontrol,
-+ struct snd_ctl_elem_info *uinfo)
-+{
-+ uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
-+ uinfo->count = 1;
-+ uinfo->value.integer.min = 0;
-+ uinfo->value.integer.max = 0x7f;
-+ return 0;
-+}
-+
-+static int snd_ak4641_actl_mic_gain_get(struct snd_kcontrol *kcontrol,
-+ struct snd_ctl_elem_value *ucontrol)
-+{
-+ struct snd_ak4641 *ak = (struct snd_ak4641 *) kcontrol->private_data;
-+
-+ ucontrol->value.integer.value[0] = ak->regs[R_PGA];
-+ return 0;
-+}
-+
-+static int snd_ak4641_actl_mic_gain_put(struct snd_kcontrol *kcontrol,
-+ struct snd_ctl_elem_value *ucontrol)
-+{
-+ struct snd_ak4641 *ak = (struct snd_ak4641 *) kcontrol->private_data;
-+
-+ snd_ak4641_lock(ak);
-+ ak->regs[R_PGA] = ucontrol->value.integer.value[0];
-+ snd_ak4641_reg_changed(ak, R_PGA);
-+ snd_ak4641_unlock(ak);
-+ return 0;
-+}
-+/*-end------------------------------------------------------------*/
-+
-+#define ACTL(ctl_name, _name) \
-+static struct snd_kcontrol_new snd_ak4641_actl_ ## ctl_name = \
-+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = _name, \
-+ .info = snd_ak4641_actl_ ## ctl_name ## _info, \
-+ .get = snd_ak4641_actl_ ## ctl_name ## _get, .put = snd_ak4641_actl_ ## ctl_name ## _put };
-+
-+ACTL(playback_volume, "Master Playback Volume")
-+ACTL(mic_gain, "Mic Capture Gain")
-+
-+struct snd_ak4641_uctl_bool {
-+ int (*get) (struct snd_ak4641 *uda);
-+ int (*set) (struct snd_ak4641 *uda, int on);
-+};
-+
-+static int snd_ak4641_actl_bool_info(struct snd_kcontrol *kcontrol,
-+ struct snd_ctl_elem_info *uinfo)
-+{
-+ uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
-+ uinfo->count = 1;
-+ return 0;
-+}
-+
-+static int snd_ak4641_actl_bool_get(struct snd_kcontrol *kcontrol,
-+ struct snd_ctl_elem_value *ucontrol)
-+{
-+ struct snd_ak4641 *ak = (struct snd_ak4641 *) kcontrol->private_data;
-+ struct snd_ak4641_uctl_bool *uctl =
-+ (struct snd_ak4641_uctl_bool *) kcontrol->private_value;
-+
-+ ucontrol->value.integer.value[0] = uctl->get(ak);
-+ return 0;
-+}
-+
-+static int snd_ak4641_actl_bool_put(struct snd_kcontrol *kcontrol,
-+ struct snd_ctl_elem_value *ucontrol)
-+{
-+ struct snd_ak4641 *ak = (struct snd_ak4641 *) kcontrol->private_data;
-+ struct snd_ak4641_uctl_bool *uctl =
-+ (struct snd_ak4641_uctl_bool *) kcontrol->private_value;
-+
-+ return uctl->set(ak, ucontrol->value.integer.value[0]);
-+}
-+
-+/*-begin----------------------------------------------------------*/
-+static int snd_ak4641_uctl_playback_switch_get(struct snd_ak4641 *ak)
-+{
-+ return (ak->regs[R_DAC] & R_DAC_SMUTE) == 0x00;
-+}
-+
-+static int snd_ak4641_uctl_playback_switch_set(struct snd_ak4641 *ak, int on)
-+{
-+ snd_ak4641_lock(ak);
-+ ak->regs[R_DAC] = WRITE_MASK(ak->regs[R_DAC],
-+ on ? 0x00 : R_DAC_SMUTE, R_DAC_SMUTE);
-+ snd_ak4641_reg_changed(ak, R_DAC);
-+ snd_ak4641_unlock(ak);
-+ return 0;
-+}
-+/*-end------------------------------------------------------------*/
-+
-+/*-begin----------------------------------------------------------*/
-+static int snd_ak4641_uctl_mic_boost_get(struct snd_ak4641 *ak)
-+{
-+ return (ak->regs[R_MIC] & R_MIC_MGAIN) == R_MIC_MGAIN;
-+}
-+
-+static int snd_ak4641_uctl_mic_boost_set(struct snd_ak4641 *ak, int on)
-+{
-+ snd_ak4641_lock(ak);
-+ ak->regs[R_MIC] = WRITE_MASK(ak->regs[R_MIC],
-+ on ? R_MIC_MGAIN : 0x00, R_MIC_MGAIN);
-+ snd_ak4641_reg_changed(ak, R_MIC);
-+ snd_ak4641_unlock(ak);
-+ return 0;
-+}
-+/*-end------------------------------------------------------------*/
-+
-+/*-begin----------------------------------------------------------*/
-+static int snd_ak4641_uctl_mono_out_get(struct snd_ak4641 *ak)
-+{
-+ printk("mono_out status 0x%8.8x -> 0x%8.8x\n",ak->regs[R_SEL1], ak->regs[R_SEL1] & REG_SEL1_PSMO);
-+ return (ak->regs[R_SEL1] & REG_SEL1_PSMO) == REG_SEL1_PSMO;
-+}
-+
-+static int snd_ak4641_uctl_mono_out_set(struct snd_ak4641 *ak, int on)
-+{
-+ printk("phone mic enable called. on=%d\n",on);
-+ snd_ak4641_lock(ak);
-+ ak->regs[R_PM1] = WRITE_MASK(ak->regs[R_PM1], on ? R_PM1_PMMIC : 0x00, R_PM1_PMMIC);
-+ ak->regs[R_PM1] = WRITE_MASK(ak->regs[R_PM1], on ? REG_PWR1_PMMO : 0x00, REG_PWR1_PMMO);
-+ snd_ak4641_reg_changed(ak, R_PM1);
-+
-+ snd_ak4641_hwsync_write(ak, R_PGA); /* mic PGA gain is reset when PMMIC = 0 */
-+
-+ /* internal mic */
-+ ak->regs[R_MIC] = WRITE_MASK(ak->regs[R_MIC], on ? R_MIC_MPWRI : 0x0, R_MIC_MPWRI);
-+ ak->regs[R_MIC] = WRITE_MASK(ak->regs[R_MIC], 0x0, R_MIC_MSEL);
-+ snd_ak4641_hwsync_write(ak, R_MIC);
-+
-+// ak->regs[REG_BTIF] = WRITE_MASK(ak->regs[REG_BTIF], 0x0, REG_BTIF_DAC2);
-+// snd_ak4641_hwsync_write(ak, REG_BTIF);
-+ /* */
-+// ak->regs[REG_VOL] = WRITE_MASK(ak->regs[REG_VOL], on ? REG_VOL_ATTM : 0x00, REG_VOL_ATTM);
-+// ak->regs[R_SEL1] = WRITE_MASK(ak->regs[R_SEL1], on ? REG_SEL1_MOGN : 0x00, REG_SEL1_MOGN);
-+ ak->regs[R_SEL1] = WRITE_MASK(ak->regs[R_SEL1], on ? REG_SEL1_MICM : 0x00, REG_SEL1_MICM);
-+ ak->regs[R_SEL1] = WRITE_MASK(ak->regs[R_SEL1], on ? REG_SEL1_PSMO : 0x00, REG_SEL1_PSMO);
-+ snd_ak4641_reg_changed(ak, R_SEL1);
-+ snd_ak4641_unlock(ak);
-+ return 0;
-+}
-+/*-end------------------------------------------------------------*/
-+
-+#define ACTL_BOOL(ctl_name, _name) \
-+static struct snd_ak4641_uctl_bool snd_ak4641_actl_ ## ctl_name ## _pvalue = \
-+{ .get = snd_ak4641_uctl_ ## ctl_name ## _get, \
-+ .set = snd_ak4641_uctl_ ## ctl_name ## _set }; \
-+static struct snd_kcontrol_new snd_ak4641_actl_ ## ctl_name = \
-+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = _name, .info = snd_ak4641_actl_bool_info, \
-+ .get = snd_ak4641_actl_bool_get, .put = snd_ak4641_actl_bool_put, \
-+ .private_value = (unsigned long) &snd_ak4641_actl_ ## ctl_name ## _pvalue };
-+
-+ACTL_BOOL(playback_switch, "Master Playback Switch")
-+ACTL_BOOL(mic_boost, "Mic Boost (+20dB)")
-+ACTL_BOOL(mono_out, "Phone mic enable")
-+
-+static void snd_ak4641_headphone_on(struct snd_ak4641 *ak, int on);
-+static void snd_ak4641_speaker_on(struct snd_ak4641 *ak, int on);
-+static void snd_ak4641_select_mic(struct snd_ak4641 *ak);
-+
-+void snd_ak4641_hp_connected(struct snd_ak4641 *ak, int connected)
-+{
-+ snd_ak4641_lock(ak);
-+ if (connected != ak->hp_connected) {
-+ ak->hp_connected = connected;
-+
-+ /* headphone or speaker, on playback */
-+ if (ak->playback_on) {
-+ if (connected) {
-+ snd_ak4641_headphone_on