/* * Copyright (C) 2007-2010 ST-Ericsson * License terms: GNU General Public License (GPL) version 2 * Low-level core for exclusive access to the AB3550 IC on the I2C bus * and some basic chip-configuration. * Author: Bengt Jonsson <bengt.g.jonsson@stericsson.com> * Author: Mattias Nilsson <mattias.i.nilsson@stericsson.com> * Author: Mattias Wallin <mattias.wallin@stericsson.com> * Author: Rickard Andersson <rickard.andersson@stericsson.com> */#include<linux/i2c.h>#include<linux/mutex.h>#include<linux/err.h>#include<linux/platform_device.h>#include<linux/slab.h>#include<linux/device.h>#include<linux/irq.h>#include<linux/interrupt.h>#include<linux/random.h>#include<linux/workqueue.h>#include<linux/debugfs.h>#include<linux/seq_file.h>#include<linux/uaccess.h>#include<linux/mfd/abx500.h>#include<linux/list.h>#include<linux/bitops.h>#include<linux/spinlock.h>#include<linux/mfd/core.h>#define AB3550_NAME_STRING "ab3550"#define AB3550_ID_FORMAT_STRING "AB3550 %s"#define AB3550_NUM_BANKS 2#define AB3550_NUM_EVENT_REG 5/* These are the only registers inside AB3550 used in this main file *//* Chip ID register */#define AB3550_CID_REG 0x20/* Interrupt event registers */#define AB3550_EVENT_BANK 0#define AB3550_EVENT_REG 0x22/* Read/write operation values. */#define AB3550_PERM_RD (0x01)#define AB3550_PERM_WR (0x02)/* Read/write permissions. */#define AB3550_PERM_RO (AB3550_PERM_RD)#define AB3550_PERM_RW (AB3550_PERM_RD | AB3550_PERM_WR)/** * struct ab3550 * @access_mutex: lock out concurrent accesses to the AB registers * @i2c_client: I2C client for this chip * @chip_name: name of this chip variant * @chip_id: 8 bit chip ID for this chip variant * @mask_work: a worker for writing to mask registers * @event_lock: a lock to protect the event_mask * @event_mask: a local copy of the mask event registers * @startup_events: a copy of the first reading of the event registers * @startup_events_read: whether the first events have been read */structab3550{structmutexaccess_mutex;structi2c_client*i2c_client[AB3550_NUM_BANKS];charchip_name[32];u8chip_id;structwork_structmask_work;spinlock_tevent_lock;u8event_mask[AB3550_NUM_EVENT_REG];u8startup_events[AB3550_NUM_EVENT_REG];boolstartup_events_read;#ifdef CONFIG_DEBUG_FSunsignedintdebug_bank;unsignedintdebug_address;#endif};/** * struct ab3550_reg_range * @first: the first address of the range * @last: the last address of the range * @perm: access permissions for the range */structab3550_reg_range{u8first;u8last;u8perm;};/** * struct ab3550_reg_ranges * @count: the number of ranges in the list * @range: the list of register ranges */structab3550_reg_ranges{u8count;conststructab3550_reg_range*range;};/*