2 * twl4030_core.c - driver for TWL4030 PM and audio CODEC device
4 * Copyright (C) 2005-2006 Texas Instruments, Inc.
6 * Modifications to defer interrupt handling to a kernel thread:
7 * Copyright (C) 2006 MontaVista Software, Inc.
9 * Based on tlv320aic23.c:
10 * Copyright (c) by Kai Svahn <kai.svahn@nokia.com>
12 * Code cleanup and modifications to IRQ handler.
13 * by syed khasim <x0khasim@ti.com>
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 #include <linux/module.h>
32 #include <linux/kernel_stat.h>
33 #include <linux/init.h>
34 #include <linux/time.h>
35 #include <linux/interrupt.h>
36 #include <linux/random.h>
37 #include <linux/syscalls.h>
38 #include <linux/kthread.h>
40 #include <linux/i2c.h>
41 #include <linux/slab.h>
42 #include <linux/clk.h>
43 #include <linux/device.h>
46 #include <asm/mach/irq.h>
48 #include <asm/arch/twl4030.h>
49 #include <asm/arch/gpio.h>
50 #include <asm/arch/mux.h>
52 /**** Macro Definitions */
53 #define TWL_CLIENT_STRING "TWL4030-ID"
54 #define TWL_CLIENT_USED 1
55 #define TWL_CLIENT_FREE 0
61 /** Primary Interrupt Handler on TWL4030 Registers */
63 /**** Register Definitions */
65 #define REG_PIH_ISR_P1 (0x1)
66 #define REG_PIH_ISR_P2 (0x2)
67 #define REG_PIH_SIR (0x3)
69 /* Triton Core internal information (BEGIN) */
71 /* Last - for index max*/
72 #define TWL4030_MODULE_LAST TWL4030_MODULE_SECURED_REG
75 #define TWL4030_NUM_SLAVES 0x04
76 #define TWL4030_SLAVENUM_NUM0 0x00
77 #define TWL4030_SLAVENUM_NUM1 0x01
78 #define TWL4030_SLAVENUM_NUM2 0x02
79 #define TWL4030_SLAVENUM_NUM3 0x03
80 #define TWL4030_SLAVEID_ID0 0x48
81 #define TWL4030_SLAVEID_ID1 0x49
82 #define TWL4030_SLAVEID_ID2 0x4A
83 #define TWL4030_SLAVEID_ID3 0x4B
85 /* Base Address defns */
87 #define TWL4030_BASEADD_USB 0x0000
89 #define TWL4030_BASEADD_AUDIO_VOICE 0x0000
90 #define TWL4030_BASEADD_GPIO 0x0098
92 #define TWL4030_BASEADD_INTBR 0x0085
93 #define TWL4030_BASEADD_PIH 0x0080
94 #define TWL4030_BASEADD_TEST 0x004C
96 #define TWL4030_BASEADD_INTERRUPTS 0x00B9
97 #define TWL4030_BASEADD_LED 0x00EE
98 #define TWL4030_BASEADD_MADC 0x0000
99 #define TWL4030_BASEADD_MAIN_CHARGE 0x0074
100 #define TWL4030_BASEADD_PRECHARGE 0x00AA
101 #define TWL4030_BASEADD_PWM0 0x00F8
102 #define TWL4030_BASEADD_PWM1 0x00FB
103 #define TWL4030_BASEADD_PWMA 0x00EF
104 #define TWL4030_BASEADD_PWMB 0x00F1
105 #define TWL4030_BASEADD_KEYPAD 0x00D2
107 #define TWL4030_BASEADD_BACKUP 0x0014
108 #define TWL4030_BASEADD_INT 0x002E
109 #define TWL4030_BASEADD_PM_MASTER 0x0036
110 #define TWL4030_BASEADD_PM_RECIEVER 0x005B
111 #define TWL4030_BASEADD_RTC 0x001C
112 #define TWL4030_BASEADD_SECURED_REG 0x0000
114 /* Triton Core internal information (END) */
116 /* Few power values */
117 #define R_CFG_BOOT 0x05
118 #define R_PROTECT_KEY 0x0E
121 #define KEY_UNLOCK1 0xce
122 #define KEY_UNLOCK2 0xec
123 #define KEY_LOCK 0x00
125 #define HFCLK_FREQ_19p2_MHZ (1 << 0)
126 #define HFCLK_FREQ_26_MHZ (2 << 0)
127 #define HFCLK_FREQ_38p4_MHZ (3 << 0)
128 #define HIGH_PERF_SQ (1 << 3)
130 /* on I2C-1 for 2430SDP */
131 #define CONFIG_I2C_TWL4030_ID 1
133 /**** Helper functions */
135 twl4030_detect_client(struct i2c_adapter *adapter, unsigned char sid);
136 static int twl4030_attach_adapter(struct i2c_adapter *adapter);
137 static int twl4030_detach_client(struct i2c_client *client);
138 static void do_twl4030_irq(unsigned int irq, irq_desc_t *desc);
140 static void twl_init_irq(void);
142 /**** Data Structures */
143 /* To have info on T2 IRQ substem activated or not */
144 static unsigned char twl_irq_used = FREE;
146 /* Structure to define on TWL4030 Slave ID */
147 struct twl4030_client {
148 struct i2c_client client;
149 const char client_name[sizeof(TWL_CLIENT_STRING) + 1];
150 const unsigned char address;
151 const char adapter_index;
154 /* max numb of i2c_msg required is for read =2 */
155 struct i2c_msg xfer_msg[2];
157 /* To lock access to xfer_msg */
158 struct semaphore xfer_lock;
162 struct twl4030mapping {
163 unsigned char sid; /* Slave ID */
164 unsigned char base; /* base address */
167 /* mapping the module id to slave id and base address */
168 static struct twl4030mapping twl4030_map[TWL4030_MODULE_LAST + 1] = {
169 { TWL4030_SLAVENUM_NUM0, TWL4030_BASEADD_USB },
170 { TWL4030_SLAVENUM_NUM1, TWL4030_BASEADD_AUDIO_VOICE },
171 { TWL4030_SLAVENUM_NUM1, TWL4030_BASEADD_GPIO },
172 { TWL4030_SLAVENUM_NUM1, TWL4030_BASEADD_INTBR },
173 { TWL4030_SLAVENUM_NUM1, TWL4030_BASEADD_PIH },
174 { TWL4030_SLAVENUM_NUM1, TWL4030_BASEADD_TEST },
175 { TWL4030_SLAVENUM_NUM2, TWL4030_BASEADD_KEYPAD },
176 { TWL4030_SLAVENUM_NUM2, TWL4030_BASEADD_MADC },
177 { TWL4030_SLAVENUM_NUM2, TWL4030_BASEADD_INTERRUPTS },
178 { TWL4030_SLAVENUM_NUM2, TWL4030_BASEADD_LED },
179 { TWL4030_SLAVENUM_NUM2, TWL4030_BASEADD_MAIN_CHARGE },
180 { TWL4030_SLAVENUM_NUM2, TWL4030_BASEADD_PRECHARGE },
181 { TWL4030_SLAVENUM_NUM2, TWL4030_BASEADD_PWM0 },
182 { TWL4030_SLAVENUM_NUM2, TWL4030_BASEADD_PWM1 },
183 { TWL4030_SLAVENUM_NUM2, TWL4030_BASEADD_PWMA },
184 { TWL4030_SLAVENUM_NUM2, TWL4030_BASEADD_PWMB },
185 { TWL4030_SLAVENUM_NUM3, TWL4030_BASEADD_BACKUP },
186 { TWL4030_SLAVENUM_NUM3, TWL4030_BASEADD_INT },
187 { TWL4030_SLAVENUM_NUM3, TWL4030_BASEADD_PM_MASTER },
188 { TWL4030_SLAVENUM_NUM3, TWL4030_BASEADD_PM_RECIEVER },
189 { TWL4030_SLAVENUM_NUM3, TWL4030_BASEADD_RTC },
190 { TWL4030_SLAVENUM_NUM3, TWL4030_BASEADD_SECURED_REG },
193 static struct twl4030_client twl4030_modules[TWL4030_NUM_SLAVES] = {
195 .address = TWL4030_SLAVEID_ID0,
196 .client_name = TWL_CLIENT_STRING "0",
197 .adapter_index = CONFIG_I2C_TWL4030_ID,
200 .address = TWL4030_SLAVEID_ID1,
201 .client_name = TWL_CLIENT_STRING "1",
202 .adapter_index = CONFIG_I2C_TWL4030_ID,
205 .address = TWL4030_SLAVEID_ID2,
206 .client_name = TWL_CLIENT_STRING "2",
207 .adapter_index = CONFIG_I2C_TWL4030_ID,
210 .address = TWL4030_SLAVEID_ID3,
211 .client_name = TWL_CLIENT_STRING "3",
212 .adapter_index = CONFIG_I2C_TWL4030_ID,
216 /* One Client Driver , 4 Clients */
217 static struct i2c_driver twl4030_driver = {
218 .driver.name = "TWL4030 I2C",
219 .attach_adapter = twl4030_attach_adapter,
220 .detach_client = twl4030_detach_client,
224 * TWL4030 doesn't have PIH mask, hence dummy function for mask
228 static void twl4030_i2c_ackirq(unsigned int irq) {}
229 static void twl4030_i2c_disableint(unsigned int irq) {}
230 static void twl4030_i2c_enableint(unsigned int irq) {}
232 /* information for processing in the Work Item */
233 static struct irq_chip twl4030_irq_chip = {
234 .ack = twl4030_i2c_ackirq,
235 .mask = twl4030_i2c_disableint,
236 .unmask = twl4030_i2c_enableint,
239 /* Global Functions */
241 * @brief twl4030_i2c_write - Writes a n bit register in TWL4030
243 * @param mod_no - module number
244 * @param *value - an array of num_bytes+1 containing data to write
245 * IMPORTANT - Allocate value num_bytes+1 and valid data starts at
247 * @param reg - register address (just offset will do)
248 * @param num_bytes - number of bytes to transfer
250 * @return result of operation - 0 is success
252 int twl4030_i2c_write(u8 mod_no, u8 * value, u8 reg, u8 num_bytes)
256 struct twl4030_client *client;
259 if (unlikely(mod_no > TWL4030_MODULE_LAST)) {
260 printk(KERN_ERR "TWL4030: Invalid module Number\n");
263 sid = twl4030_map[mod_no].sid;
264 client = &(twl4030_modules[sid]);
266 if (unlikely(client->inuse != TWL_CLIENT_USED)) {
268 "TWL4030: I2C Client[%d] is not initialized[%d]\n",
272 down(&(client->xfer_lock));
274 * [MSG1]: fill the register address data
275 * fill the data Tx buffer
277 msg = &(client->xfer_msg[0]);
278 msg->addr = client->address;
279 msg->len = num_bytes + 1;
282 /* over write the first byte of buffer with the register address */
283 *value = twl4030_map[mod_no].base + reg;
284 ret = i2c_transfer(client->client.adapter, client->xfer_msg, 1);
285 up(&(client->xfer_lock));
287 /* i2cTransfer returns num messages.translate it pls.. */
294 * @brief twl4030_i2c_read - Reads a n bit register in TWL4030
296 * @param mod_no - module number
297 * @param *value - an array of num_bytes containing data to be read
298 * @param reg - register address (just offset will do)
299 * @param num_bytes - number of bytes to transfer
301 * @return result of operation - num_bytes is success else failure.
303 int twl4030_i2c_read(u8 mod_no, u8 * value, u8 reg, u8 num_bytes)
308 struct twl4030_client *client;
310 if (unlikely(mod_no > TWL4030_MODULE_LAST)) {
311 printk(KERN_ERR "TWL4030: Invalid module Number\n");
314 sid = twl4030_map[mod_no].sid;
315 client = &(twl4030_modules[sid]);
317 if (unlikely(client->inuse != TWL_CLIENT_USED)) {
319 "TWL4030: I2C Client[%d] is not initialized[%d]\n",
323 down(&(client->xfer_lock));
324 /* [MSG1] fill the register address data */
325 msg = &(client->xfer_msg[0]);
326 msg->addr = client->address;
328 val = twl4030_map[mod_no].base + reg;
330 /* [MSG2] fill the data rx buffer */
331 msg = &(client->xfer_msg[1]);
332 msg->addr = client->address;
333 msg->flags = I2C_M_RD; /* Read the register value */
334 msg->len = num_bytes; /* only n bytes */
336 ret = i2c_transfer(client->client.adapter, client->xfer_msg, 2);
337 up(&(client->xfer_lock));
339 /* i2cTransfer returns num messages.translate it pls.. */
346 * @brief twl4030_i2c_write_u8 - Writes a 8 bit register in TWL4030
348 * @param mod_no - module number
349 * @param value - the value to be written 8 bit
350 * @param reg - register address (just offset will do)
352 * @return result of operation - 0 is success
354 int twl4030_i2c_write_u8(u8 mod_no, u8 value, u8 reg)
357 /* 2 bytes offset 1 contains the data offset 0 is used by i2c_write */
358 u8 temp_buffer[2] = { 0 };
359 /* offset 1 contains the data */
360 temp_buffer[1] = value;
361 ret = twl4030_i2c_write(mod_no, temp_buffer, reg, 1);
366 * @brief twl4030_i2c_read_u8 - Reads a 8 bit register from TWL4030
368 * @param mod_no - module number
369 * @param *value - the value read 8 bit
370 * @param reg - register address (just offset will do)
372 * @return result of operation - 0 is success
374 int twl4030_i2c_read_u8(u8 mod_no, u8 * value, u8 reg)
377 ret = twl4030_i2c_read(mod_no, value, reg, 1);
381 /**** Helper Functions */
384 * do_twl4030_module_irq() is the desc->handle method for each of the twl4030
385 * module interrupts. It executes in kernel thread context.
386 * On entry, cpu interrupts are disabled.
388 static void do_twl4030_module_irq(unsigned int irq, irq_desc_t *desc)
390 struct irqaction *action;
391 const unsigned int cpu = smp_processor_id();
394 * Earlier this was desc->triggered = 1;
396 desc->status = IRQ_INPROGRESS;
399 * The desc->handle method would normally call the desc->chip->ack
400 * method here, but we won't bother since our ack method is NULL.
404 kstat_cpu(cpu).irqs[irq]++;
406 action = desc->action;
415 /* Call the ISR with cpu interrupts enabled */
416 ret = action->handler(irq, action->dev_id);
417 if (ret == IRQ_HANDLED)
418 status |= action->flags;
420 action = action->next;
423 if (status & IRQF_SAMPLE_RANDOM)
424 add_interrupt_randomness(irq);
428 if (retval != IRQ_HANDLED)
429 printk(KERN_ERR "ISR for TWL4030 module"
430 " irq %d can't handle interrupt\n", irq);
433 * Here is where we should call the unmask method, but
434 * again we won't bother since it is NULL.
437 printk(KERN_CRIT "TWL4030 module irq %d has no ISR"
438 " but can't be masked!\n", irq);
440 printk(KERN_CRIT "TWL4030 module irq %d is disabled but can't"
441 " be masked!\n", irq);
445 * twl4030_irq_thread() runs as a kernel thread. It queries the twl4030
446 * interrupt controller to see which modules are generating interrupt requests
447 * and then calls the desc->handle method for each module requesting service.
449 static int twl4030_irq_thread(void *data)
452 irq_desc_t *desc = irq_desc + irq;
453 static unsigned i2c_errors;
454 const static unsigned max_i2c_errors = 100;
456 while (!kthread_should_stop()) {
461 ret = twl4030_i2c_read_u8(TWL4030_MODULE_PIH, &pih_isr,
464 printk(KERN_WARNING "I2C error %d while reading TWL4030"
465 " PIH ISR register.\n", ret);
466 if (++i2c_errors >= max_i2c_errors) {
467 printk(KERN_ERR "Maximum I2C error count"
468 " exceeded. Terminating %s.\n",
475 for (module_irq = IH_TWL4030_BASE; 0 != pih_isr;
476 pih_isr >>= 1, module_irq++) {
478 irq_desc_t *d = irq_desc + module_irq;
482 d->handle_irq(module_irq, d);
490 set_current_state(TASK_INTERRUPTIBLE);
491 desc->chip->unmask(irq);
497 set_current_state(TASK_RUNNING);
502 * do_twl4030_irq() is the desc->handle method for the twl4030 interrupt.
503 * This is a chained interrupt, so there is no desc->action method for it.
504 * Now we need to query the interrupt controller in the twl4030 to determine
505 * which module is generating the interrupt request. However, we can't do i2c
506 * transactions in interrupt context, so we must defer that work to a kernel
507 * thread. All we do here is acknowledge and mask the interrupt and wakeup
510 static void do_twl4030_irq(unsigned int irq, irq_desc_t *desc)
512 const unsigned int cpu = smp_processor_id();
513 struct task_struct *thread = (struct task_struct *)desc->chip_data;
516 * Earlier this was desc->triggered = 1;
518 desc->status = IRQ_INPROGRESS;
521 * Acknowledge, clear _AND_ disable the interrupt.
523 desc->chip->ack(irq);
526 kstat_cpu(cpu).irqs[irq]++;
528 if (thread && thread->state != TASK_RUNNING)
529 wake_up_process(thread);
533 /* attach a client to the adapter */
534 static int twl4030_detect_client(struct i2c_adapter *adapter, unsigned char sid)
537 struct twl4030_client *client;
538 if (unlikely(sid >= TWL4030_NUM_SLAVES)) {
539 printk(KERN_ERR "TWL4030: sid[%d] >MOD_LAST[%d]\n", sid,
544 /* Check basic functionality */
545 if (!(err = i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA |
546 I2C_FUNC_SMBUS_WRITE_BYTE))) {
548 "TWL4030: SlaveID=%d functionality check failed\n", sid);
551 client = &(twl4030_modules[sid]);
552 if (unlikely(client->inuse)) {
553 printk(KERN_ERR "TWL4030: Client is already in Use.....\n");
554 printk("%s[ID=0x%x] NOT attached to I2c Adapter %s\n",
555 client->client_name, client->address, adapter->name);
559 memset(&(client->client), 0, sizeof(struct i2c_client));
561 client->client.addr = client->address;
562 client->client.adapter = adapter;
563 client->client.driver = &twl4030_driver;
565 memcpy(&(client->client.name), client->client_name,
566 sizeof(TWL_CLIENT_STRING) + 1);
567 printk("TWL4030: TRY attach Slave %s on Adapter %s[%d][%x]\n",
568 client->client_name, adapter->name, err, err);
569 if ((err = i2c_attach_client(&(client->client))))
571 "TWL4030: Couldn't attach Slave %s on Adapter "
573 client->client_name, adapter->name, err, err);
575 client->inuse = TWL_CLIENT_USED;
576 init_MUTEX(&client->xfer_lock);
581 /* adapter callback */
582 static int twl4030_attach_adapter(struct i2c_adapter *adapter)
586 static int twl_i2c_adapter = 1;
587 for (i = 0; i < TWL4030_NUM_SLAVES; i++) {
588 /* Check if I need to hook on to this adapter or not */
589 if (twl4030_modules[i].adapter_index == twl_i2c_adapter) {
590 if ((ret = twl4030_detect_client(adapter, i)))
597 * Check if the PIH module is initialized, if yes, then init
598 * the T2 Interrupt subsystem
600 if ((twl4030_modules[twl4030_map[TWL4030_MODULE_PIH].sid].inuse ==
601 TWL_CLIENT_USED) && (twl_irq_used != USED)) {
609 "TWL4030: TWL_CLIENT(Idx=%d] REGISTRATION FAILED=%d[0x%x]\n", i,
612 /* ignore current slave..it never got registered */
615 /* now remove all those from the current adapter... */
616 if (twl4030_modules[i].adapter_index == twl_i2c_adapter)
617 (void)twl4030_detach_client(&(twl4030_modules[i].client));
623 /* adapter's callback */
624 static int twl4030_detach_client(struct i2c_client *iclient)
627 if ((err = i2c_detach_client(iclient))) {
629 "TWL4030: Client deregistration failed, client not detached.\n");
635 struct task_struct *start_twl4030_irq_thread(int irq)
637 struct task_struct *thread;
639 thread = kthread_create(twl4030_irq_thread, (void *)irq,
640 "twl4030 irq %d", irq);
642 printk(KERN_ERR "%s: could not create twl4030 irq %d thread!\n",
649 * These three functions should be part of Voltage frame work
650 * added here to complete the functionality for now.
652 static int protect_pm_master(void)
655 e = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, KEY_LOCK,
660 static int unprotect_pm_master(void)
663 e |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, KEY_UNLOCK1,
665 e |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, KEY_UNLOCK2,
670 int power_companion_init(void)
673 u32 rate, ctrl = HFCLK_FREQ_26_MHZ;
676 osc = clk_get(NULL,"osc_ck");
677 rate = clk_get_rate(osc);
681 case 19200000 : ctrl = HFCLK_FREQ_19p2_MHZ; break;
682 case 26000000 : ctrl = HFCLK_FREQ_26_MHZ; break;
683 case 38400000 : ctrl = HFCLK_FREQ_38p4_MHZ; break;
686 ctrl |= HIGH_PERF_SQ;
687 e |= unprotect_pm_master();
688 /* effect->MADC+USB ck en */
689 e |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, ctrl, R_CFG_BOOT);
690 e |= protect_pm_master();
695 static void twl_init_irq(void)
701 * We end up with interrupts from other modules before
702 * they get a chance to handle them...
705 res = twl4030_i2c_write_u8(TWL4030_MODULE_INT, 0xFF, 0x00);
712 res = twl4030_i2c_write_u8(TWL4030_MODULE_INT, 0xFF, 0x02);
719 res = twl4030_i2c_write_u8(TWL4030_MODULE_INT, 0xFF, 0x1);
726 res = twl4030_i2c_write_u8(TWL4030_MODULE_INT, 0xFF, 0x3);
732 /* Clear off any other pending interrupts on power */
734 res = twl4030_i2c_write_u8(TWL4030_MODULE_INT, 0xFF, 0x00);
741 res = twl4030_i2c_write_u8(TWL4030_MODULE_INT, 0xFF, 0x02);
746 /* POWER HACK (END) */
747 /* Slave address 0x4A */
750 res = twl4030_i2c_write_u8(TWL4030_MODULE_INTERRUPTS, 0xFF, 0x3);
757 res = twl4030_i2c_write_u8(TWL4030_MODULE_INTERRUPTS, 0xFF, 0x4);
764 res = twl4030_i2c_write_u8(TWL4030_MODULE_INTERRUPTS, 0xFF, 0x7);
771 res = twl4030_i2c_write_u8(TWL4030_MODULE_INTERRUPTS, 0xFF, 0x8);
779 res = twl4030_i2c_write_u8(TWL4030_MODULE_MADC, 0xFF, 0x62);
786 res = twl4030_i2c_write_u8(TWL4030_MODULE_MADC, 0xFF, 0x64);
794 res = twl4030_i2c_write_u8(TWL4030_MODULE_KEYPAD, 0xFF, (0x12));
802 twl4030_i2c_read_u8(TWL4030_MODULE_KEYPAD, &clear, 0x11);
803 twl4030_i2c_read_u8(TWL4030_MODULE_KEYPAD, &clear, 0x11);
807 res = twl4030_i2c_write_u8(TWL4030_MODULE_KEYPAD, 0xFF, (0x14));
813 /* Slave address 0x49 */
815 res = twl4030_i2c_write_u8(TWL4030_MODULE_GPIO, 0xFF, (0x1C));
822 res = twl4030_i2c_write_u8(TWL4030_MODULE_GPIO, 0xFF, (0x1D));
829 res = twl4030_i2c_write_u8(TWL4030_MODULE_GPIO, 0xFF, (0x1E));
836 res = twl4030_i2c_write_u8(TWL4030_MODULE_GPIO, 0xFF, (0x22));
843 res = twl4030_i2c_write_u8(TWL4030_MODULE_GPIO, 0xFF, (0x23));
850 res = twl4030_i2c_write_u8(TWL4030_MODULE_GPIO, 0xFF, (0x24));
856 /* install an irq handler for each of the PIH modules */
857 for (i = IH_TWL4030_BASE; i < IH_TWL4030_END; i++) {
858 set_irq_chip(i, &twl4030_irq_chip);
859 set_irq_handler(i, do_twl4030_module_irq);
860 set_irq_flags(i, IRQF_VALID);
863 /* install an irq handler to demultiplex the TWL4030 interrupt */
864 set_irq_data(TWL4030_IRQNUM, start_twl4030_irq_thread(TWL4030_IRQNUM));
865 set_irq_type(TWL4030_IRQNUM, IRQT_FALLING);
866 set_irq_chained_handler(TWL4030_IRQNUM, do_twl4030_irq);
868 res = power_companion_init();
877 "TWL4030: Unable to register interrupt "
878 "subsystem[%d][%d]\n", res, line);
881 static int __init twl4030_init(void)
884 if ((res = i2c_register_driver(THIS_MODULE, &twl4030_driver))) {
885 printk(KERN_ERR "TWL4030: Driver registration failed \n");
888 printk(KERN_INFO "TWL4030: Driver registration complete.\n");
892 static void __exit twl4030_exit(void)
894 if (i2c_del_driver(&twl4030_driver))
896 "TWL4030: Driver remove failed, module not removed\n");
900 subsys_initcall(twl4030_init);
901 module_exit(twl4030_exit);
903 EXPORT_SYMBOL(twl4030_i2c_write_u8);
904 EXPORT_SYMBOL(twl4030_i2c_read_u8);
905 EXPORT_SYMBOL(twl4030_i2c_read);
906 EXPORT_SYMBOL(twl4030_i2c_write);
908 MODULE_AUTHOR("Texas Instruments, Inc.");
909 MODULE_DESCRIPTION("I2C Core interface for TWL4030");
910 MODULE_LICENSE("GPL");