2 * drivers/i2c/chips/menelaus.c
4 * Copyright (C) 2004 Texas Instruments, Inc.
6 * Some parts based tps65010.c:
7 * Copyright (C) 2004 Texas Instruments and
8 * Copyright (C) 2004-2005 David Brownell
10 * Some parts based on tlv320aic24.c:
11 * Copyright (C) by Kai Svahn <kai.svahn@nokia.com>
13 * Changes for interrupt handling and clean-up by
14 * Tony Lindgren <tony@atomide.com> and Imre Deak <imre.deak@nokia.com>
15 * Cleanup and generalized support for voltage setting by
17 * Added support for controlling VCORE and regulator sleep states,
18 * Amit Kucheria <amit.kucheria@nokia.com>
19 * Copyright (C) 2005, 2006 Nokia Corporation
21 * This program is free software; you can redistribute it and/or modify
22 * it under the terms of the GNU General Public License as published by
23 * the Free Software Foundation; either version 2 of the License, or
24 * (at your option) any later version.
26 * This program is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 * GNU General Public License for more details.
31 * You should have received a copy of the GNU General Public License
32 * along with this program; if not, write to the Free Software
33 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
36 #include <linux/module.h>
37 #include <linux/i2c.h>
38 #include <linux/interrupt.h>
39 #include <linux/sched.h>
40 #include <linux/mutex.h>
41 #include <linux/workqueue.h>
43 #include <asm/mach-types.h>
44 #include <asm/mach/irq.h>
46 #include <asm/arch/mux.h>
47 #include <asm/arch/gpio.h>
48 #include <asm/arch/menelaus.h>
52 #define DRIVER_NAME "menelaus"
54 #define pr_err(fmt, arg...) printk(KERN_ERR DRIVER_NAME ": ", ## arg);
56 #define MENELAUS_I2C_ADDRESS 0x72
58 #define MENELAUS_REV 0x01
59 #define MENELAUS_VCORE_CTRL1 0x02
60 #define MENELAUS_VCORE_CTRL2 0x03
61 #define MENELAUS_VCORE_CTRL3 0x04
62 #define MENELAUS_VCORE_CTRL4 0x05
63 #define MENELAUS_VCORE_CTRL5 0x06
64 #define MENELAUS_DCDC_CTRL1 0x07
65 #define MENELAUS_DCDC_CTRL2 0x08
66 #define MENELAUS_DCDC_CTRL3 0x09
67 #define MENELAUS_LDO_CTRL1 0x0A
68 #define MENELAUS_LDO_CTRL2 0x0B
69 #define MENELAUS_LDO_CTRL3 0x0C
70 #define MENELAUS_LDO_CTRL4 0x0D
71 #define MENELAUS_LDO_CTRL5 0x0E
72 #define MENELAUS_LDO_CTRL6 0x0F
73 #define MENELAUS_LDO_CTRL7 0x10
74 #define MENELAUS_LDO_CTRL8 0x11
75 #define MENELAUS_SLEEP_CTRL1 0x12
76 #define MENELAUS_SLEEP_CTRL2 0x13
77 #define MENELAUS_DEVICE_OFF 0x14
78 #define MENELAUS_OSC_CTRL 0x15
79 #define MENELAUS_DETECT_CTRL 0x16
80 #define MENELAUS_INT_MASK1 0x17
81 #define MENELAUS_INT_MASK2 0x18
82 #define MENELAUS_INT_STATUS1 0x19
83 #define MENELAUS_INT_STATUS2 0x1A
84 #define MENELAUS_INT_ACK1 0x1B
85 #define MENELAUS_INT_ACK2 0x1C
86 #define MENELAUS_GPIO_CTRL 0x1D
87 #define MENELAUS_GPIO_IN 0x1E
88 #define MENELAUS_GPIO_OUT 0x1F
89 #define MENELAUS_BBSMS 0x20
90 #define MENELAUS_RTC_CTRL 0x21
91 #define MENELAUS_RTC_UPDATE 0x22
92 #define MENELAUS_RTC_SEC 0x23
93 #define MENELAUS_RTC_MIN 0x24
94 #define MENELAUS_RTC_HR 0x25
95 #define MENELAUS_RTC_DAY 0x26
96 #define MENELAUS_RTC_MON 0x27
97 #define MENELAUS_RTC_YR 0x28
98 #define MENELAUS_RTC_WKDAY 0x29
99 #define MENELAUS_RTC_AL_SEC 0x2A
100 #define MENELAUS_RTC_AL_MIN 0x2B
101 #define MENELAUS_RTC_AL_HR 0x2C
102 #define MENELAUS_RTC_AL_DAY 0x2D
103 #define MENELAUS_RTC_AL_MON 0x2E
104 #define MENELAUS_RTC_AL_YR 0x2F
105 #define MENELAUS_RTC_COMP_MSB 0x30
106 #define MENELAUS_RTC_COMP_LSB 0x31
107 #define MENELAUS_S1_PULL_EN 0x32
108 #define MENELAUS_S1_PULL_DIR 0x33
109 #define MENELAUS_S2_PULL_EN 0x34
110 #define MENELAUS_S2_PULL_DIR 0x35
111 #define MENELAUS_MCT_CTRL1 0x36
112 #define MENELAUS_MCT_CTRL2 0x37
113 #define MENELAUS_MCT_CTRL3 0x38
114 #define MENELAUS_MCT_PIN_ST 0x39
115 #define MENELAUS_DEBOUNCE1 0x3A
117 #define IH_MENELAUS_IRQS 12
118 #define MENELAUS_MMC_S1CD_IRQ 0 /* MMC slot 1 card change */
119 #define MENELAUS_MMC_S2CD_IRQ 1 /* MMC slot 2 card change */
120 #define MENELAUS_MMC_S1D1_IRQ 2 /* MMC DAT1 low in slot 1 */
121 #define MENELAUS_MMC_S2D1_IRQ 3 /* MMC DAT1 low in slot 2 */
122 #define MENELAUS_LOWBAT_IRQ 4 /* Low battery */
123 #define MENELAUS_HOTDIE_IRQ 5 /* Hot die detect */
124 #define MENELAUS_UVLO_IRQ 6 /* UVLO detect */
125 #define MENELAUS_TSHUT_IRQ 7 /* Thermal shutdown */
126 #define MENELAUS_RTCTMR_IRQ 8 /* RTC timer */
127 #define MENELAUS_RTCALM_IRQ 9 /* RTC alarm */
128 #define MENELAUS_RTCERR_IRQ 10 /* RTC error */
129 #define MENELAUS_PSHBTN_IRQ 11 /* Push button */
130 #define MENELAUS_RESERVED12_IRQ 12 /* Reserved */
131 #define MENELAUS_RESERVED13_IRQ 13 /* Reserved */
132 #define MENELAUS_RESERVED14_IRQ 14 /* Reserved */
133 #define MENELAUS_RESERVED15_IRQ 15 /* Reserved */
135 static void menelaus_work(struct work_struct *_menelaus);
137 /* Initialized by menelaus_init */
138 static unsigned short normal_i2c[] = { MENELAUS_I2C_ADDRESS, I2C_CLIENT_END };
142 struct menelaus_chip {
143 unsigned long initialized;
145 struct i2c_client client;
146 struct work_struct work;
148 unsigned vcore_hw_mode:1;
150 void (*mmc_callback)(void *data, u8 mask);
151 void *mmc_callback_data;
154 static struct menelaus_chip menelaus;
155 static struct menelaus_platform_data *menelaus_pdata;
157 static int menelaus_write_reg(int reg, u8 value)
159 int val = i2c_smbus_write_byte_data(&menelaus.client, reg, value);
162 pr_err("write error");
169 static int menelaus_read_reg(int reg)
171 int val = i2c_smbus_read_byte_data(&menelaus.client, reg);
174 pr_err("read error");
179 static int menelaus_enable_irq(int irq)
182 return menelaus_write_reg(MENELAUS_INT_MASK2,
183 menelaus_read_reg(MENELAUS_INT_MASK2)
184 & ~(1 << (irq - 8)));
186 return menelaus_write_reg(MENELAUS_INT_MASK1,
187 menelaus_read_reg(MENELAUS_INT_MASK1)
191 static int menelaus_disable_irq(int irq)
194 return menelaus_write_reg(menelaus_read_reg(MENELAUS_INT_MASK2)
198 return menelaus_write_reg(MENELAUS_INT_MASK1,
199 menelaus_read_reg(MENELAUS_INT_MASK1)
203 static int menelaus_ack_irq(int irq)
206 return menelaus_write_reg(MENELAUS_INT_ACK2, 1 << (irq - 8));
208 return menelaus_write_reg(MENELAUS_INT_ACK1, 1 << irq);
211 /* Adds a handler for an interrupt. Does not run in interrupt context */
212 static int menelaus_add_irq_work(int irq, void * handler)
216 mutex_lock(&menelaus.lock);
217 menelaus.handlers[irq] = handler;
218 ret = menelaus_enable_irq(irq);
219 mutex_unlock(&menelaus.lock);
224 /* Removes handler for an interrupt */
225 static int menelaus_remove_irq_work(int irq)
229 mutex_lock(&menelaus.lock);
230 ret = menelaus_disable_irq(irq);
231 menelaus.handlers[irq] = NULL;
232 mutex_unlock(&menelaus.lock);
238 * Gets scheduled when a card detect interrupt happens. Note that in some cases
239 * this line is wired to card cover switch rather than the card detect switch
240 * in each slot. In this case the cards are not seen by menelaus.
241 * FIXME: Add handling for D1 too
243 static int menelaus_mmc_cd_work(struct menelaus_chip * menelaus_hw)
246 unsigned char card_mask = 0;
248 reg = menelaus_read_reg(MENELAUS_MCT_PIN_ST);
253 card_mask |= (1 << 0);
256 card_mask |= (1 << 1);
258 if (menelaus_hw->mmc_callback)
259 menelaus_hw->mmc_callback(menelaus_hw->mmc_callback_data,
266 * Toggles the MMC slots between open-drain and push-pull mode.
268 int menelaus_set_mmc_opendrain(int slot, int enable)
272 if (slot != 1 && slot != 2)
274 mutex_lock(&menelaus.lock);
275 ret = menelaus_read_reg(MENELAUS_MCT_CTRL1);
277 mutex_unlock(&menelaus.lock);
292 ret = menelaus_write_reg(MENELAUS_MCT_CTRL1, val);
293 mutex_unlock(&menelaus.lock);
297 EXPORT_SYMBOL(menelaus_set_mmc_opendrain);
299 int menelaus_set_slot_sel(int enable)
303 mutex_lock(&menelaus.lock);
304 ret = menelaus_read_reg(MENELAUS_GPIO_CTRL);
312 ret = menelaus_write_reg(MENELAUS_GPIO_CTRL, ret);
314 mutex_unlock(&menelaus.lock);
317 EXPORT_SYMBOL(menelaus_set_slot_sel);
319 int menelaus_set_mmc_slot(int slot, int enable, int power, int cd_en)
323 if (slot != 1 && slot != 2)
328 mutex_lock(&menelaus.lock);
330 ret = menelaus_read_reg(MENELAUS_MCT_CTRL2);
336 val |= (1 << 4) | (1 << 6);
338 val &= ~((1 << 4) | (1 << 6));
341 val |= (1 << 5) | (1 << 7);
343 val &= ~((1 << 5) | (1 << 7));
345 ret = menelaus_write_reg(MENELAUS_MCT_CTRL2, val);
349 ret = menelaus_read_reg(MENELAUS_MCT_CTRL3);
365 b = menelaus_read_reg(MENELAUS_MCT_CTRL2);
368 ret = menelaus_write_reg(MENELAUS_MCT_CTRL2, b);
372 /* Disable autonomous shutdown */
374 ret = menelaus_write_reg(MENELAUS_MCT_CTRL3, val);
376 mutex_unlock(&menelaus.lock);
379 EXPORT_SYMBOL(menelaus_set_mmc_slot);
381 #include <linux/delay.h>
383 int menelaus_register_mmc_callback(void (*callback)(void *data, u8 card_mask),
388 menelaus.mmc_callback_data = data;
389 menelaus.mmc_callback = callback;
390 ret = menelaus_add_irq_work(MENELAUS_MMC_S1CD_IRQ,
391 menelaus_mmc_cd_work);
394 ret = menelaus_add_irq_work(MENELAUS_MMC_S2CD_IRQ,
395 menelaus_mmc_cd_work);
398 ret = menelaus_add_irq_work(MENELAUS_MMC_S1D1_IRQ,
399 menelaus_mmc_cd_work);
402 ret = menelaus_add_irq_work(MENELAUS_MMC_S2D1_IRQ,
403 menelaus_mmc_cd_work);
407 EXPORT_SYMBOL(menelaus_register_mmc_callback);
409 void menelaus_unregister_mmc_callback(void)
411 menelaus_remove_irq_work(MENELAUS_MMC_S1CD_IRQ);
412 menelaus_remove_irq_work(MENELAUS_MMC_S2CD_IRQ);
413 menelaus_remove_irq_work(MENELAUS_MMC_S1D1_IRQ);
414 menelaus_remove_irq_work(MENELAUS_MMC_S2D1_IRQ);
416 menelaus.mmc_callback = NULL;
417 menelaus.mmc_callback_data = 0;
419 EXPORT_SYMBOL(menelaus_unregister_mmc_callback);
421 struct menelaus_vtg {
429 struct menelaus_vtg_value {
434 static int menelaus_set_voltage(const struct menelaus_vtg *vtg, int mV,
435 int vtg_val, int mode)
439 mutex_lock(&menelaus.lock);
443 ret = menelaus_read_reg(vtg->vtg_reg);
446 val = ret & ~(((1 << vtg->vtg_bits) - 1) << vtg->vtg_shift);
447 val |= vtg_val << vtg->vtg_shift;
449 printk("menelaus: Setting voltage '%s' to %d mV (reg 0x%02x, val 0x%02x)\n",
450 vtg->name, mV, vtg->vtg_reg, val);
452 ret = menelaus_write_reg(vtg->vtg_reg, val);
456 ret = menelaus_write_reg(vtg->mode_reg, mode);
458 mutex_unlock(&menelaus.lock);
460 /* Wait for voltage to stabilize */
466 static int menelaus_get_vtg_value(int vtg, const struct menelaus_vtg_value *tbl,
471 for (i = 0; i < n; i++, tbl++)
477 /* Vcore can be programmed in two ways:
478 * SW-controlled: Required voltage is programmed into VCORE_CTRL1
479 * HW-controlled: Required range (roof-floor) is programmed into VCORE_CTRL3
482 * Call correct 'set' function accordingly
485 static const struct menelaus_vtg_value vcore_values[] = {
507 int menelaus_set_vcore_sw(unsigned int mV)
511 val = menelaus_get_vtg_value(mV, vcore_values, ARRAY_SIZE(vcore_values));
515 printk("menelaus: Setting VCORE to %d mV (val 0x%02x)\n", mV, val);
518 /* Set SW mode and the voltage in one go. */
519 mutex_lock(&menelaus.lock);
520 ret = menelaus_write_reg(MENELAUS_VCORE_CTRL1, val);
522 menelaus.vcore_hw_mode = 0;
523 mutex_unlock(&menelaus.lock);
529 int menelaus_set_vcore_hw(unsigned int roof_mV, unsigned int floor_mV)
531 int fval, rval, val, ret;
533 rval = menelaus_get_vtg_value(roof_mV, vcore_values, ARRAY_SIZE(vcore_values));
536 fval = menelaus_get_vtg_value(floor_mV, vcore_values, ARRAY_SIZE(vcore_values));
541 printk("menelaus: Setting VCORE FLOOR to %d mV and ROOF to %d mV\n",
545 mutex_lock(&menelaus.lock);
546 ret = menelaus_write_reg(MENELAUS_VCORE_CTRL3, fval);
549 ret = menelaus_write_reg(MENELAUS_VCORE_CTRL4, rval);
552 if (!menelaus.vcore_hw_mode) {
553 val = menelaus_read_reg(MENELAUS_VCORE_CTRL1);
554 val |= ((1 << 7) | (1 << 5)); /* HW mode, turn OFF byte comparator */
555 ret = menelaus_write_reg(MENELAUS_VCORE_CTRL1, val);
556 menelaus.vcore_hw_mode = 1;
560 mutex_unlock(&menelaus.lock);
564 static const struct menelaus_vtg vmem_vtg = {
566 .vtg_reg = MENELAUS_LDO_CTRL1,
569 .mode_reg = MENELAUS_LDO_CTRL3,
572 static const struct menelaus_vtg_value vmem_values[] = {
579 int menelaus_set_vmem(unsigned int mV)
584 return menelaus_set_voltage(&vmem_vtg, 0, 0, 0);
586 val = menelaus_get_vtg_value(mV, vmem_values, ARRAY_SIZE(vmem_values));
589 return menelaus_set_voltage(&vmem_vtg, mV, val, 0x02);
591 EXPORT_SYMBOL(menelaus_set_vmem);
593 static const struct menelaus_vtg vio_vtg = {
595 .vtg_reg = MENELAUS_LDO_CTRL1,
598 .mode_reg = MENELAUS_LDO_CTRL4,
601 static const struct menelaus_vtg_value vio_values[] = {
608 int menelaus_set_vio(unsigned int mV)
613 return menelaus_set_voltage(&vio_vtg, 0, 0, 0);
615 val = menelaus_get_vtg_value(mV, vio_values, ARRAY_SIZE(vio_values));
618 return menelaus_set_voltage(&vio_vtg, mV, val, 0x02);
620 EXPORT_SYMBOL(menelaus_set_vio);
622 static const struct menelaus_vtg_value vdcdc_values[] = {
633 static const struct menelaus_vtg vdcdc2_vtg = {
635 .vtg_reg = MENELAUS_DCDC_CTRL1,
638 .mode_reg = MENELAUS_DCDC_CTRL2,
641 static const struct menelaus_vtg vdcdc3_vtg = {
643 .vtg_reg = MENELAUS_DCDC_CTRL1,
646 .mode_reg = MENELAUS_DCDC_CTRL3,
649 int menelaus_set_vdcdc(int dcdc, unsigned int mV)
651 const struct menelaus_vtg *vtg;
654 if (dcdc != 2 && dcdc != 3)
662 return menelaus_set_voltage(vtg, 0, 0, 0);
664 val = menelaus_get_vtg_value(mV, vdcdc_values, ARRAY_SIZE(vdcdc_values));
667 return menelaus_set_voltage(vtg, mV, val, 0x03);
670 static const struct menelaus_vtg_value vmmc_values[] = {
677 static const struct menelaus_vtg vmmc_vtg = {
679 .vtg_reg = MENELAUS_LDO_CTRL1,
682 .mode_reg = MENELAUS_LDO_CTRL7,
685 int menelaus_set_vmmc(unsigned int mV)
690 return menelaus_set_voltage(&vmmc_vtg, 0, 0, 0);
692 val = menelaus_get_vtg_value(mV, vmmc_values, ARRAY_SIZE(vmmc_values));
695 return menelaus_set_voltage(&vmmc_vtg, mV, val, 0x02);
697 EXPORT_SYMBOL(menelaus_set_vmmc);
700 static const struct menelaus_vtg_value vaux_values[] = {
707 static const struct menelaus_vtg vaux_vtg = {
709 .vtg_reg = MENELAUS_LDO_CTRL1,
712 .mode_reg = MENELAUS_LDO_CTRL6,
715 int menelaus_set_vaux(unsigned int mV)
720 return menelaus_set_voltage(&vaux_vtg, 0, 0, 0);
722 val = menelaus_get_vtg_value(mV, vaux_values, ARRAY_SIZE(vaux_values));
725 return menelaus_set_voltage(&vaux_vtg, mV, val, 0x02);
727 EXPORT_SYMBOL(menelaus_set_vaux);
729 int menelaus_get_slot_pin_states(void)
731 return menelaus_read_reg(MENELAUS_MCT_PIN_ST);
733 EXPORT_SYMBOL(menelaus_get_slot_pin_states);
735 int menelaus_set_regulator_sleep(int enable, u32 val)
739 mutex_lock(&menelaus.lock);
740 ret = menelaus_write_reg(MENELAUS_SLEEP_CTRL2, val);
744 printk("menelaus: regulator sleep configuration: %02x\n", val);
746 ret = menelaus_read_reg(MENELAUS_GPIO_CTRL);
749 t = ((1 << 6) | 0x04);
754 ret = menelaus_write_reg(MENELAUS_GPIO_CTRL, ret);
756 mutex_unlock(&menelaus.lock);
760 /*-----------------------------------------------------------------------*/
762 /* Handles Menelaus interrupts. Does not run in interrupt context */
763 static void menelaus_work(struct work_struct *_menelaus)
765 struct menelaus_chip *menelaus =
766 container_of(_menelaus, struct menelaus_chip, work);
767 int (*handler)(struct menelaus_chip *menelaus);
773 isr = menelaus_read_reg(MENELAUS_INT_STATUS1) |
774 (menelaus_read_reg(MENELAUS_INT_STATUS2) << 8);
779 for (i = 0; i < IH_MENELAUS_IRQS; i++) {
780 if (isr & (1 << i)) {
781 mutex_lock(&menelaus->lock);
782 menelaus_disable_irq(i);
784 if (menelaus->handlers[i]) {
785 handler = menelaus->handlers[i];
788 menelaus_enable_irq(i);
789 mutex_unlock(&menelaus->lock);
793 enable_irq(menelaus->irq);
797 * We cannot use I2C in interrupt context, so we just schedule work.
799 static irqreturn_t menelaus_irq(int irq, void *_menelaus)
801 struct menelaus_chip *menelaus = _menelaus;
803 disable_irq_nosync(irq);
804 (void)schedule_work(&menelaus->work);
809 static struct i2c_driver menelaus_i2c_driver;
811 static int menelaus_probe(struct i2c_adapter *adapter, int address, int kind)
813 struct i2c_client *c;
817 if (test_and_set_bit(0, &menelaus.initialized))
820 c = &menelaus.client;
821 strncpy(c->name, DRIVER_NAME, sizeof(c->name));
823 c->adapter = adapter;
824 c->driver = &menelaus_i2c_driver;
827 if ((err = i2c_attach_client(c)) < 0) {
828 pr_err("couldn't attach\n");
832 /* If a true probe check the device */
833 if (kind < 0 && (rev = menelaus_read_reg(MENELAUS_REV)) < 0) {
834 pr_err("device not found");
839 /* Most likely Menelaus interrupt is at SYS_NIRQ */
840 omap_cfg_reg(W19_24XX_SYS_NIRQ);
841 menelaus.irq = INT_24XX_SYS_NIRQ;
843 /* Ack and disable all Menelaus interrupts */
844 menelaus_write_reg(MENELAUS_INT_ACK1, 0xff);
845 menelaus_write_reg(MENELAUS_INT_ACK2, 0xff);
846 menelaus_write_reg(MENELAUS_INT_MASK1, 0xff);
847 menelaus_write_reg(MENELAUS_INT_MASK2, 0xff);
849 /* Set output buffer strengths */
850 menelaus_write_reg(MENELAUS_MCT_CTRL1, 0x73);
852 err = request_irq(menelaus.irq, menelaus_irq, IRQF_DISABLED,
853 DRIVER_NAME, &menelaus);
855 printk(KERN_ERR "Could not get Menelaus IRQ\n");
859 mutex_init(&menelaus.lock);
860 INIT_WORK(&menelaus.work, menelaus_work);
863 pr_info("Menelaus rev %d.%d\n", rev >> 4, rev & 0x0f);
865 val = menelaus_read_reg(MENELAUS_VCORE_CTRL1);
869 menelaus.vcore_hw_mode = 1;
871 menelaus.vcore_hw_mode = 0;
873 if (menelaus_pdata != NULL && menelaus_pdata->late_init != NULL) {
874 err = menelaus_pdata->late_init(&c->dev);
881 free_irq(menelaus.irq, &menelaus);
882 flush_scheduled_work();
884 i2c_detach_client(c);
886 clear_bit(0, &menelaus.initialized);
890 static int menelaus_remove(struct i2c_client *client)
894 free_irq(menelaus.irq, &menelaus);
896 if ((err = i2c_detach_client(client))) {
897 pr_err("client deregistration failed\n");
901 clear_bit(0, &menelaus.initialized);
906 /*-----------------------------------------------------------------------*/
908 static int menelaus_scan_bus(struct i2c_adapter *bus)
910 if (!i2c_check_functionality(bus, I2C_FUNC_SMBUS_BYTE_DATA |
911 I2C_FUNC_SMBUS_WRITE_BYTE)) {
912 pr_err("invalid i2c bus functionality\n");
916 return i2c_probe(bus, &addr_data, menelaus_probe);
919 static struct i2c_driver menelaus_i2c_driver = {
923 .id = I2C_DRIVERID_MISC, /*FIXME:accroding to i2c-ids.h */
924 .class = I2C_CLASS_HWMON,
925 .attach_adapter = menelaus_scan_bus,
926 .detach_client = menelaus_remove,
929 static int __init menelaus_init(void)
933 if ((res = i2c_add_driver(&menelaus_i2c_driver)) < 0) {
934 pr_err("driver registration failed\n");
941 static void __exit menelaus_exit(void)
943 if (i2c_del_driver(&menelaus_i2c_driver) < 0)
944 pr_err("driver remove failed\n");
946 /* FIXME: Shutdown menelaus parts that can be shut down */
949 void __init menelaus_set_platform_data(struct menelaus_platform_data *pdata)
951 menelaus_pdata = pdata;
954 MODULE_AUTHOR("Texas Instruments, Inc.");
955 MODULE_DESCRIPTION("I2C interface for Menelaus.");
956 MODULE_LICENSE("GPL");
958 module_init(menelaus_init);
959 module_exit(menelaus_exit);