summaryrefslogtreecommitdiff
path: root/packages/linux/linux-ezx-2.6.21/patches/ezx-eoc.patch
diff options
context:
space:
mode:
Diffstat (limited to 'packages/linux/linux-ezx-2.6.21/patches/ezx-eoc.patch')
-rw-r--r--packages/linux/linux-ezx-2.6.21/patches/ezx-eoc.patch265
1 files changed, 110 insertions, 155 deletions
diff --git a/packages/linux/linux-ezx-2.6.21/patches/ezx-eoc.patch b/packages/linux/linux-ezx-2.6.21/patches/ezx-eoc.patch
index 77c79fd107..bf93ebc854 100644
--- a/packages/linux/linux-ezx-2.6.21/patches/ezx-eoc.patch
+++ b/packages/linux/linux-ezx-2.6.21/patches/ezx-eoc.patch
@@ -1,8 +1,8 @@
Index: linux-2.6.21/arch/arm/mach-pxa/ezx-eoc.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ linux-2.6.21/arch/arm/mach-pxa/ezx-eoc.c 2007-09-11 20:14:33.000000000 -0300
-@@ -0,0 +1,267 @@
++++ linux-2.6.21/arch/arm/mach-pxa/ezx-eoc.c 2007-09-24 23:40:45.000000000 -0300
+@@ -0,0 +1,260 @@
+/*
+ * EZX EOC Driver for Motorola EZX phones
+ *
@@ -21,8 +21,7 @@ Index: linux-2.6.21/arch/arm/mach-pxa/ezx-eoc.c
+#include <asm/arch/hardware.h>
+#include <asm/arch/pxa-regs.h>
+#include <asm/arch/ezx.h>
-+
-+#include "ezx-eoc.h"
++#include <asm/arch/udc.h>
+
+#if 1
+#define EOC_DBG printk
@@ -30,25 +29,23 @@ Index: linux-2.6.21/arch/arm/mach-pxa/ezx-eoc.c
+#define EOC_DBG(x, args...)
+#endif
+
++#define REG_INT_STATUS 32
++#define REG_INT_MASK 33
++#define REG_INT_SENSE 34
++#define REG_POWER_CONTROL_0 35
++#define REG_POWER_CONTROL_1 36
++#define REG_CONN_CONTROL 37
++
+#define EOC_REG_ADDR_SIZE 1
+#define EOC_REG_DATA_SIZE 3
++#define EOC_FUNC_NOTHING 0
++#define EOC_FUNC_USB_NET 1
+
-+struct ezx_eoc_platform_data *pdata;
-+static int eoc_func = EOC_FUNC_USB_NET;
+static const char eoc_i2c_driver_name[] = "ezx-eoc";
-+
-+/* Addresses to scan */
-+static unsigned short normal_i2c[] = {
-+ 0x17, /* Address for version 2.0 and above */
-+ // 0x7C, /* Address for versions prior too 2.0 */
-+ I2C_CLIENT_END
-+};
-+
-+/* I2C Magic */
-+I2C_CLIENT_INSMOD;
++static int eoc_func = EOC_FUNC_USB_NET;
++static struct pxa2xx_udc_mach_info ezx_udc_info;
+
+static int ezx_eoc_attach_adapter(struct i2c_adapter *adapter);
-+static int ezx_eoc_detect(struct i2c_adapter *adapter, int address, int kind);
+static int ezx_eoc_detach_client(struct i2c_client *client);
+
+static struct i2c_client *eoc_i2c_client = NULL;
@@ -57,82 +54,68 @@ Index: linux-2.6.21/arch/arm/mach-pxa/ezx-eoc.c
+ .driver = {
+ .name = (char *)eoc_i2c_driver_name,
+ },
-+ .id = I2C_DRIVERID_EEPROM,
+ .attach_adapter = ezx_eoc_attach_adapter,
+ .detach_client = ezx_eoc_detach_client,
+};
+
+int eoc_reg_read(int reg, unsigned int *reg_value)
+{
-+ unsigned char reg_num = reg;
-+ unsigned char value[EOC_REG_DATA_SIZE];
-+ int retval;
-+
-+ struct i2c_msg msgs[2] =
-+ {
-+ { 0, 0, EOC_REG_ADDR_SIZE, &reg_num },
-+ { 0, I2C_M_RD, EOC_REG_DATA_SIZE, value }
-+ };
-+
-+ /* check if we have initialized */ /*not necessary --WM
-+ if (eoc_i2c_client == NULL)
-+ {
-+ EOC_DBG("eoc_reg_read: not initialized\n");
-+ return -EINVAL;
-+ }
-+*/
-+ msgs[0].addr = msgs[1].addr = eoc_i2c_client->addr;
-+
-+ /* transfer message to client */
-+ retval = i2c_transfer(eoc_i2c_client->adapter, msgs, 2);
-+ if (retval >= 0)
-+ {
-+ *reg_value = (value[2] << 0);
-+ *reg_value |= (value[1] << 8);
-+ *reg_value |= (value[0] << 16);
-+ }
-+ return retval;
++ unsigned char reg_num = reg;
++ unsigned char value[EOC_REG_DATA_SIZE];
++ int retval;
++
++ struct i2c_msg msgs[2] =
++ {
++ { eoc_i2c_client->addr, 0, EOC_REG_ADDR_SIZE, &reg_num },
++ { eoc_i2c_client->addr, I2C_M_RD, EOC_REG_DATA_SIZE, value }
++ };
++
++ /* transfer message to client */
++ retval = i2c_transfer(eoc_i2c_client->adapter, msgs, 2);
++ if (retval < 0)
++ return retval;
++
++ *reg_value = (value[2] << 0);
++ *reg_value |= (value[1] << 8);
++ *reg_value |= (value[0] << 16);
++ return 0;
+}
-+EXPORT_SYMBOL_GPL(eoc_reg_read);
+
+int eoc_reg_write(int reg, unsigned int reg_value)
+{
-+ unsigned char value[EOC_REG_ADDR_SIZE + EOC_REG_DATA_SIZE];
-+ int retval;
-+
-+ /* check if we have initialized */ /*not necessary --WM
-+ if (eoc_i2c_client == NULL)
-+ {
-+ EOC_DBG("eoc_reg_write: not initialized\n");
-+ return -EINVAL;
-+ }
-+*/
-+ /* Copy the data into a buffer into the correct format */
-+ value[0] = reg;
-+ value[1] = (reg_value >> 16) & 0xFF;
-+ value[2] = (reg_value >> 8) & 0xFF;
-+ value[3] = (reg_value >> 0) & 0xFF;
-+
-+ /* Write the data to the EOC */
-+ retval = i2c_master_send (eoc_i2c_client, value, EOC_REG_ADDR_SIZE + EOC_REG_DATA_SIZE);
-+
-+ return retval;
++ unsigned char value[EOC_REG_ADDR_SIZE + EOC_REG_DATA_SIZE];
++ int retval;
++
++ /* Copy the data into a buffer into the correct format */
++ value[0] = reg;
++ value[1] = (reg_value >> 16) & 0xFF;
++ value[2] = (reg_value >> 8) & 0xFF;
++ value[3] = (reg_value >> 0) & 0xFF;
++
++ /* Write the data to the EOC */
++ retval = i2c_master_send (eoc_i2c_client, value, EOC_REG_ADDR_SIZE + EOC_REG_DATA_SIZE);
++ if (retval < 0)
++ return retval;
++ return 0;
+}
-+EXPORT_SYMBOL_GPL(eoc_reg_write);
+
+static void eoc_switch_to_usb(void)
+{
++ EOC_DBG("EOC: Switching to USB\n");
+ pxa_gpio_mode(GPIO34_USB_P2_2_MD);
+ pxa_gpio_mode(GPIO35_USB_P2_1_MD);
+ pxa_gpio_mode(GPIO36_USB_P2_4_MD);
+ pxa_gpio_mode(GPIO39_USB_P2_6_MD);
+ pxa_gpio_mode(GPIO40_USB_P2_5_MD);
+ pxa_gpio_mode(GPIO53_USB_P2_3_MD);
-+ EOC_DBG("ALEX;*********************************************emu_switch_to_usb;\n");
++ UP2OCR = 0x02000000;
++ /* FIXME change eoc bits to USB */
++
+}
+
+static void eoc_switch_to_nothing(void)
+{
++ EOC_DBG("EOC: Switching do disconnected\n");
+ pxa_gpio_mode(GPIO34_TXENB | GPIO_OUT);
+ set_GPIO(GPIO34_TXENB);
+ pxa_gpio_mode(GPIO35_XRXD | GPIO_IN);
@@ -140,6 +123,7 @@ Index: linux-2.6.21/arch/arm/mach-pxa/ezx-eoc.c
+ pxa_gpio_mode(GPIO39_VPOUT | GPIO_IN);
+ pxa_gpio_mode(GPIO40_VPIN | GPIO_IN);
+ pxa_gpio_mode(GPIO53_VMIN | GPIO_IN);
++ /* FIXME disconnect mini usb port */
+}
+
+static void eoc_switch_to_default(void)
@@ -154,73 +138,56 @@ Index: linux-2.6.21/arch/arm/mach-pxa/ezx-eoc.c
+ }
+}
+
-+
+static int ezx_eoc_attach_adapter(struct i2c_adapter *adapter)
+{
-+ return i2c_probe(adapter, &addr_data, ezx_eoc_detect);
-+}
-+
-+/* This function is called by i2c_probe */
-+static int ezx_eoc_detect(struct i2c_adapter *adapter, int address, int kind)
-+{
-+ struct i2c_client *new_client;
+ int err = 0;
++ EOC_DBG(">>>>attach adapter enter\n");
++
++ if (eoc_i2c_client != NULL) {
++ EOC_DBG(">>>>already loaded!!!\n");
++ return 0;
++ }
+
-+ if (!(new_client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL)))
++ if (!(eoc_i2c_client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL)))
+ return -ENOMEM;
+
-+ new_client->addr = address;
-+ new_client->adapter = adapter;
-+ new_client->driver = &eoc_i2c_driver;
-+ new_client->flags = 0;
-+ strlcpy(new_client->name, eoc_i2c_driver_name, I2C_NAME_SIZE);
++ eoc_i2c_client->addr = 0x17;
++ eoc_i2c_client->adapter = adapter;
++ eoc_i2c_client->driver = &eoc_i2c_driver;
++ eoc_i2c_client->flags = 0;
++ strlcpy(eoc_i2c_client->name, eoc_i2c_driver_name, I2C_NAME_SIZE);
+
-+ if ((err = i2c_attach_client(new_client))) {
-+ kfree(new_client);
++ if ((err = i2c_attach_client(eoc_i2c_client))) {
++ kfree(eoc_i2c_client);
++ eoc_i2c_client = NULL;
+ return err;
+ }
-+
-+ eoc_i2c_client = new_client;
-+
-+ if (pdata && pdata->init)
-+ pdata->init();
++ eoc_reg_write(REG_INT_MASK, 0x0000FEF);
++ eoc_reg_write(REG_POWER_CONTROL_0, 0x0000C00);
++ eoc_reg_write(REG_POWER_CONTROL_1, 0x000000C);
++ eoc_reg_write(REG_CONN_CONTROL,0x0021044);
+
+ eoc_switch_to_default();
-+
++ EOC_DBG(">>>>attach adapter exit\n");
+ return 0;
++
+}
+
+static int ezx_eoc_detach_client(struct i2c_client *client)
+{
-+ int err;
-+
-+ err = i2c_detach_client(client);
-+ if (err)
-+ return err;
-+
-+ return 0;
++ return i2c_detach_client(client);
+}
+
+static int __init ezx_eoc_probe(struct platform_device *dev)
+{
+ int ret;
+
-+ pdata = dev->dev.platform_data;
-+
+ ret = i2c_add_driver(&eoc_i2c_driver);
+ if (ret != 0)
+ return -EINVAL;
-+
-+ /*
-+ * I think we should save platform_data and call init and eoc_switch
-+ * from ezx_eoc_detect, after client is setup.
-+ * And there is no need for all the "check if initialised" checks if
-+ * you assure that you only call read/write after the client is set.
-+ * Probably, this was causing the crash on i2c-core too.
-+ * --WM
-+ */
-+
-+ /* FIXME: should set udc_info here -WM */
++
++ pxa_set_udc_info(&ezx_udc_info);
++
+ return 0;
+}
+
@@ -241,6 +208,34 @@ Index: linux-2.6.21/arch/arm/mach-pxa/ezx-eoc.c
+ return 0;
+}
+
++/* USB Device Controller */
++static int udc_connected_status;
++static void ezx_udc_command(int cmd)
++{
++ switch (cmd) {
++ case PXA2XX_UDC_CMD_DISCONNECT:
++ printk(KERN_NOTICE "USB cmd disconnect\n");
++// ezx_pcap_bit_set(PCAP_BIT_BUSCTRL_USB_PU,0);
++ udc_connected_status = 0;
++ break;
++ case PXA2XX_UDC_CMD_CONNECT:
++ printk(KERN_NOTICE "USB cmd connect\n");
++// ezx_pcap_bit_set(PCAP_BIT_BUSCTRL_USB_PU,1);
++ udc_connected_status = 1;
++ break;
++ }
++}
++
++static int ezx_udc_is_connected(void)
++{
++ return udc_connected_status;
++}
++
++static struct pxa2xx_udc_mach_info ezx_udc_info __initdata = {
++ .udc_is_connected = ezx_udc_is_connected,
++ .udc_command = ezx_udc_command,
++};
++
+static struct platform_driver ezx_eoc_driver = {
+ .probe = ezx_eoc_probe,
+ .remove = ezx_eoc_remove,
@@ -266,52 +261,12 @@ Index: linux-2.6.21/arch/arm/mach-pxa/ezx-eoc.c
+MODULE_DESCRIPTION("EZX EOC I2C driver");
+MODULE_LICENSE("GPL");
+
-+/* doesnt module_init work?? -WM */
-+/*late_initcall(ezx_eoc_init);*/
+module_init(ezx_eoc_init);
+module_exit(ezx_eoc_exit);
-Index: linux-2.6.21/arch/arm/mach-pxa/ezx-eoc.h
-===================================================================
---- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ linux-2.6.21/arch/arm/mach-pxa/ezx-eoc.h 2007-09-09 21:46:27.000000000 -0300
-@@ -0,0 +1,33 @@
-+/*
-+ * linux/arch/arm/mach-pxa/ezx-eoc.h
-+ *
-+ * Copyright (C) Alex Zhang <celeber2@gmail.com>
-+ *
-+ * 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 __EZX_EOC_H__
-+#define __EZX_EOC_H__
-+
-+enum {
-+ POWER_IC_REG_EOC_INT_STATUS,
-+ POWER_IC_REG_EOC_INT_MASK,
-+ POWER_IC_REG_EOC_INT_SENSE,
-+ POWER_IC_REG_EOC_POWER_CONTROL_0,
-+ POWER_IC_REG_EOC_POWER_CONTROL_1,
-+ POWER_IC_REG_EOC_CONN_CONTROL,
-+ POWER_IC_REG_EOC_NUM
-+};
-+
-+enum {
-+ EOC_FUNC_NOTHING,
-+ EOC_FUNC_USB_NET,
-+};
-+
-+struct ezx_eoc_platform_data {
-+ int (*init)(void);
-+};
-+
-+#endif /* __EZX_EOC_H__ */
Index: linux-2.6.21/arch/arm/mach-pxa/Kconfig
===================================================================
---- linux-2.6.21.orig/arch/arm/mach-pxa/Kconfig 2007-09-09 21:46:27.000000000 -0300
-+++ linux-2.6.21/arch/arm/mach-pxa/Kconfig 2007-09-09 21:46:27.000000000 -0300
+--- linux-2.6.21.orig/arch/arm/mach-pxa/Kconfig 2007-09-24 20:15:00.000000000 -0300
++++ linux-2.6.21/arch/arm/mach-pxa/Kconfig 2007-09-24 20:15:16.000000000 -0300
@@ -108,6 +108,12 @@
config EZX_PCAP
bool "PCAP Support"
@@ -327,8 +282,8 @@ Index: linux-2.6.21/arch/arm/mach-pxa/Kconfig
depends on EZX_PCAP
Index: linux-2.6.21/arch/arm/mach-pxa/Makefile
===================================================================
---- linux-2.6.21.orig/arch/arm/mach-pxa/Makefile 2007-09-09 21:46:27.000000000 -0300
-+++ linux-2.6.21/arch/arm/mach-pxa/Makefile 2007-09-09 21:46:27.000000000 -0300
+--- linux-2.6.21.orig/arch/arm/mach-pxa/Makefile 2007-09-24 20:15:00.000000000 -0300
++++ linux-2.6.21/arch/arm/mach-pxa/Makefile 2007-09-24 20:15:16.000000000 -0300
@@ -27,6 +27,7 @@
obj-$(CONFIG_EZX_BP) += ezx-bp.o
obj-$(CONFIG_EZX_PCAP) += ezx-pcap.o